MCPcopy Create free account
hub / github.com/tiann/hapi / CursorSession

Class CursorSession

cli/src/cursor/session.ts:15–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13type CursorModelApplyHandler = (model: string | null | undefined) => Promise<string | null>;
14
15export class CursorSession extends AgentSessionBase<EnhancedMode> {
16 readonly cursorArgs?: string[];
17 model?: string;
18 readonly startedBy: 'runner' | 'terminal';
19 readonly startingMode: 'local' | 'remote';
20 localLaunchFailure: LocalLaunchFailure | null = null;
21 private modelApplyHandler: CursorModelApplyHandler | null = null;
22
23 constructor(opts: {
24 api: ApiClient;
25 client: ApiSessionClient;
26 path: string;
27 logPath: string;
28 sessionId: string | null;
29 messageQueue: MessageQueue2<EnhancedMode>;
30 onModeChange: (mode: 'local' | 'remote') => void;
31 mode?: 'local' | 'remote';
32 startedBy: 'runner' | 'terminal';
33 startingMode: 'local' | 'remote';
34 cursorArgs?: string[];
35 model?: string;
36 permissionMode?: PermissionMode;
37 }) {
38 super({
39 api: opts.api,
40 client: opts.client,
41 path: opts.path,
42 logPath: opts.logPath,
43 sessionId: opts.sessionId,
44 messageQueue: opts.messageQueue,
45 onModeChange: opts.onModeChange,
46 mode: opts.mode,
47 sessionLabel: 'CursorSession',
48 sessionIdLabel: 'Cursor',
49 applySessionIdToMetadata: (metadata, sessionId, extras) => ({
50 ...metadata,
51 cursorSessionId: sessionId,
52 ...extras
53 }),
54 permissionMode: opts.permissionMode
55 });
56
57 this.cursorArgs = opts.cursorArgs;
58 this.model = opts.model;
59 this.startedBy = opts.startedBy;
60 this.startingMode = opts.startingMode;
61 this.permissionMode = opts.permissionMode;
62 }
63
64 setPermissionMode = (mode: PermissionMode): void => {
65 this.permissionMode = mode;
66 };
67
68 setModel = (model: string | null | undefined): void => {
69 this.model = model ?? undefined;
70 };
71
72 registerModelApplyHandler = (handler: CursorModelApplyHandler): (() => void) => {

Callers

nothing calls this directly

Calls 3

sendAgentMessageMethod · 0.80
sendUserMessageMethod · 0.80
sendSessionEventMethod · 0.80

Tested by

no test coverage detected