subharness 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -9
- package/dist/adapters/approval-context.d.ts +2 -0
- package/dist/adapters/approval-context.js +9 -0
- package/dist/adapters/approval-context.js.map +1 -0
- package/dist/adapters/approval-lifetime.d.ts +8 -0
- package/dist/adapters/approval-lifetime.js +50 -0
- package/dist/adapters/approval-lifetime.js.map +1 -0
- package/dist/adapters/claude-approvals.d.ts +4 -0
- package/dist/adapters/claude-approvals.js +32 -0
- package/dist/adapters/claude-approvals.js.map +1 -0
- package/dist/adapters/claude-permissions.js +1 -1
- package/dist/adapters/claude-permissions.js.map +1 -1
- package/dist/adapters/claude-process.d.ts +3 -0
- package/dist/adapters/claude-process.js +11 -1
- package/dist/adapters/claude-process.js.map +1 -1
- package/dist/adapters/claude-result.d.ts +2 -0
- package/dist/adapters/claude-result.js +22 -0
- package/dist/adapters/claude-result.js.map +1 -0
- package/dist/adapters/claude.js +60 -12
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/codex-approvals.d.ts +6 -0
- package/dist/adapters/codex-approvals.js +111 -0
- package/dist/adapters/codex-approvals.js.map +1 -0
- package/dist/adapters/codex.js +36 -3
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/copilot-permissions.d.ts +26 -0
- package/dist/adapters/copilot-permissions.js +121 -0
- package/dist/adapters/copilot-permissions.js.map +1 -0
- package/dist/adapters/copilot-tools.d.ts +12 -0
- package/dist/adapters/copilot-tools.js +61 -0
- package/dist/adapters/copilot-tools.js.map +1 -0
- package/dist/adapters/copilot.d.ts +108 -0
- package/dist/adapters/copilot.js +819 -0
- package/dist/adapters/copilot.js.map +1 -0
- package/dist/adapters/cursor-cli-approvals.d.ts +2 -0
- package/dist/adapters/cursor-cli-approvals.js +83 -0
- package/dist/adapters/cursor-cli-approvals.js.map +1 -0
- package/dist/adapters/cursor-cli-model.d.ts +4 -0
- package/dist/adapters/cursor-cli-model.js +64 -0
- package/dist/adapters/cursor-cli-model.js.map +1 -0
- package/dist/adapters/cursor-cli-session.d.ts +32 -0
- package/dist/adapters/cursor-cli-session.js +316 -0
- package/dist/adapters/cursor-cli-session.js.map +1 -0
- package/dist/adapters/cursor-cli-tools.d.ts +20 -0
- package/dist/adapters/cursor-cli-tools.js +181 -0
- package/dist/adapters/cursor-cli-tools.js.map +1 -0
- package/dist/adapters/cursor-cli.d.ts +2 -0
- package/dist/adapters/cursor-cli.js +306 -0
- package/dist/adapters/cursor-cli.js.map +1 -0
- package/dist/adapters/cursor-model.d.ts +7 -0
- package/dist/adapters/cursor-model.js +67 -0
- package/dist/adapters/cursor-model.js.map +1 -0
- package/dist/adapters/cursor-rpc.d.ts +42 -0
- package/dist/adapters/cursor-rpc.js +271 -0
- package/dist/adapters/cursor-rpc.js.map +1 -0
- package/dist/adapters/cursor-session.d.ts +4 -0
- package/dist/adapters/cursor-session.js +327 -0
- package/dist/adapters/cursor-session.js.map +1 -0
- package/dist/adapters/cursor-startup.d.ts +16 -0
- package/dist/adapters/cursor-startup.js +74 -0
- package/dist/adapters/cursor-startup.js.map +1 -0
- package/dist/adapters/cursor-tools.d.ts +11 -0
- package/dist/adapters/cursor-tools.js +49 -0
- package/dist/adapters/cursor-tools.js.map +1 -0
- package/dist/adapters/cursor.d.ts +6 -0
- package/dist/adapters/cursor.js +17 -0
- package/dist/adapters/cursor.js.map +1 -0
- package/dist/adapters/fx-approvals.d.ts +2 -0
- package/dist/adapters/fx-approvals.js +14 -0
- package/dist/adapters/fx-approvals.js.map +1 -0
- package/dist/adapters/fx-auth.d.ts +12 -2
- package/dist/adapters/fx-auth.js +51 -61
- package/dist/adapters/fx-auth.js.map +1 -1
- package/dist/adapters/fx-profile.d.ts +8 -0
- package/dist/adapters/fx-profile.js +101 -0
- package/dist/adapters/fx-profile.js.map +1 -0
- package/dist/adapters/fx-rpc.d.ts +2 -0
- package/dist/adapters/fx-rpc.js +30 -4
- package/dist/adapters/fx-rpc.js.map +1 -1
- package/dist/adapters/fx-status.d.ts +2 -0
- package/dist/adapters/fx-status.js +96 -0
- package/dist/adapters/fx-status.js.map +1 -0
- package/dist/adapters/fx.js +77 -30
- package/dist/adapters/fx.js.map +1 -1
- package/dist/adapters/opencode-access.d.ts +13 -0
- package/dist/adapters/opencode-access.js +76 -0
- package/dist/adapters/opencode-access.js.map +1 -0
- package/dist/adapters/opencode-config.d.ts +11 -0
- package/dist/adapters/opencode-config.js +238 -0
- package/dist/adapters/opencode-config.js.map +1 -0
- package/dist/adapters/opencode-http.d.ts +28 -0
- package/dist/adapters/opencode-http.js +297 -0
- package/dist/adapters/opencode-http.js.map +1 -0
- package/dist/adapters/opencode-tools.d.ts +19 -0
- package/dist/adapters/opencode-tools.js +127 -0
- package/dist/adapters/opencode-tools.js.map +1 -0
- package/dist/adapters/opencode.d.ts +2 -0
- package/dist/adapters/opencode.js +569 -0
- package/dist/adapters/opencode.js.map +1 -0
- package/dist/adapters/rpc.d.ts +3 -0
- package/dist/adapters/rpc.js +45 -4
- package/dist/adapters/rpc.js.map +1 -1
- package/dist/adapters/types.d.ts +7 -0
- package/dist/adapters/types.js.map +1 -1
- package/dist/approvals/schema.d.ts +4 -0
- package/dist/approvals/schema.js +70 -0
- package/dist/approvals/schema.js.map +1 -0
- package/dist/approvals/types.d.ts +47 -0
- package/dist/approvals/types.js +2 -0
- package/dist/approvals/types.js.map +1 -0
- package/dist/cli/args.d.ts +3 -2
- package/dist/cli/args.js +24 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/dashboard-client.d.ts +5 -1
- package/dist/cli/dashboard-client.js +162 -15
- package/dist/cli/dashboard-client.js.map +1 -1
- package/dist/cli/dashboard-controller.d.ts +7 -0
- package/dist/cli/dashboard-controller.js +27 -0
- package/dist/cli/dashboard-controller.js.map +1 -0
- package/dist/cli/dashboard-detail-view.d.ts +16 -0
- package/dist/cli/dashboard-detail-view.js +162 -0
- package/dist/cli/dashboard-detail-view.js.map +1 -0
- package/dist/cli/dashboard-history-view.d.ts +29 -0
- package/dist/cli/dashboard-history-view.js +211 -0
- package/dist/cli/dashboard-history-view.js.map +1 -0
- package/dist/cli/dashboard-input.d.ts +14 -0
- package/dist/cli/dashboard-input.js +128 -0
- package/dist/cli/dashboard-input.js.map +1 -0
- package/dist/cli/dashboard-layout.d.ts +12 -1
- package/dist/cli/dashboard-layout.js +32 -30
- package/dist/cli/dashboard-layout.js.map +1 -1
- package/dist/cli/dashboard-renderer.d.ts +30 -2
- package/dist/cli/dashboard-renderer.js +125 -7
- package/dist/cli/dashboard-renderer.js.map +1 -1
- package/dist/cli/dashboard-style.d.ts +9 -0
- package/dist/cli/dashboard-style.js +36 -0
- package/dist/cli/dashboard-style.js.map +1 -0
- package/dist/cli/dashboard.d.ts +5 -3
- package/dist/cli/dashboard.js +102 -12
- package/dist/cli/dashboard.js.map +1 -1
- package/dist/cli/help.d.ts +1 -1
- package/dist/cli/help.js +37 -12
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/input.d.ts +1 -0
- package/dist/cli/input.js +23 -17
- package/dist/cli/input.js.map +1 -1
- package/dist/cli/main.js +6 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output.js +17 -1
- package/dist/cli/output.js.map +1 -1
- package/dist/config/access-provenance.d.ts +10 -0
- package/dist/config/access-provenance.js +31 -0
- package/dist/config/access-provenance.js.map +1 -0
- package/dist/config/access.d.ts +12 -2
- package/dist/config/access.js +125 -27
- package/dist/config/access.js.map +1 -1
- package/dist/config/loader.js +1 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/oidc.js +4 -2
- package/dist/config/oidc.js.map +1 -1
- package/dist/config/project.js +2 -1
- package/dist/config/project.js.map +1 -1
- package/dist/config/resolve-access.js +24 -10
- package/dist/config/resolve-access.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/process-diagnostics.d.ts +2 -0
- package/dist/process-diagnostics.js +11 -0
- package/dist/process-diagnostics.js.map +1 -0
- package/dist/runtime/access-errors.d.ts +4 -0
- package/dist/runtime/access-errors.js +25 -0
- package/dist/runtime/access-errors.js.map +1 -0
- package/dist/runtime/approval-registry.d.ts +27 -0
- package/dist/runtime/approval-registry.js +126 -0
- package/dist/runtime/approval-registry.js.map +1 -0
- package/dist/runtime/client.js +54 -14
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/coordinator.d.ts +17 -1
- package/dist/runtime/coordinator.js +124 -6
- package/dist/runtime/coordinator.js.map +1 -1
- package/dist/runtime/dashboard-sanitize.d.ts +2 -0
- package/dist/runtime/dashboard-sanitize.js +7 -0
- package/dist/runtime/dashboard-sanitize.js.map +1 -0
- package/dist/runtime/dashboard.d.ts +43 -1
- package/dist/runtime/dashboard.js +2 -3
- package/dist/runtime/dashboard.js.map +1 -1
- package/dist/runtime/definition.js +11 -1
- package/dist/runtime/definition.js.map +1 -1
- package/dist/runtime/select-native.d.ts +2 -1
- package/dist/runtime/select-native.js +28 -10
- package/dist/runtime/select-native.js.map +1 -1
- package/dist/runtime/service.js +24 -1
- package/dist/runtime/service.js.map +1 -1
- package/dist/runtime/types.d.ts +9 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/runtime/worker-approvals.d.ts +21 -0
- package/dist/runtime/worker-approvals.js +51 -0
- package/dist/runtime/worker-approvals.js.map +1 -0
- package/dist/runtime/worker-client.js +73 -20
- package/dist/runtime/worker-client.js.map +1 -1
- package/dist/runtime/worker-server.d.ts +2 -0
- package/dist/runtime/worker-server.js +39 -10
- package/dist/runtime/worker-server.js.map +1 -1
- package/dist/sdk/definitions.d.ts +4 -1
- package/dist/sdk/definitions.js +16 -2
- package/dist/sdk/definitions.js.map +1 -1
- package/dist/sdk/permission-validation.js +10 -1
- package/dist/sdk/permission-validation.js.map +1 -1
- package/dist/sdk/types.d.ts +29 -1
- package/dist/sdk/types.js.map +1 -1
- package/package.json +4 -1
- package/sdk/access-config.md +86 -4
- package/sdk/adapter-contract.md +7 -13
- package/sdk/additional-harnesses.md +43 -0
- package/sdk/agent-skill.md +7 -4
- package/sdk/agent.md +5 -3
- package/sdk/approvals.md +120 -0
- package/sdk/authentication.md +1 -1
- package/sdk/cli/dashboard-design.md +44 -4
- package/sdk/cli/dashboard-inspection.md +25 -0
- package/sdk/cli/index.md +20 -11
- package/sdk/cli/output.md +10 -4
- package/sdk/completion-notifications.md +2 -0
- package/sdk/config.md +1 -1
- package/sdk/copilot.md +53 -0
- package/sdk/cursor.md +68 -0
- package/sdk/diagnostics.md +29 -0
- package/sdk/distribution.md +53 -1
- package/sdk/evals.md +10 -4
- package/sdk/fx.md +51 -6
- package/sdk/harnesses.md +13 -13
- package/sdk/index.md +4 -2
- package/sdk/message-delivery.md +1 -1
- package/sdk/opencode.md +57 -0
- package/sdk/permissions.md +7 -5
- package/sdk/pr-integration.md +1 -1
- package/sdk/project-team.md +2 -0
- package/sdk/sessions.md +4 -1
- package/sdk/tools.md +1 -1
- package/sdk/v1-runtime.md +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../src/adapters/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAUvE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,WAAW,GAAG,8CAA8C,CAAC;AAyGnE,MAAM,YAAY,GAAwB;IACxC,YAAY,EAAE,OAAO,CAA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,UAAU,YAAY,CAAC,OAAe,EAAE,MAAmB;IAC9D,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IACjC,OAAO,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QACjC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,EAAE,OAAO,CAAC,CAAC;QACZ,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { CopilotClient, RuntimeConnection } from \"@github/copilot-sdk\";\nimport type {\n CopilotClientOptions,\n CurrentModel,\n GetAuthStatusResponse,\n ModelInfo,\n ProviderConfig,\n SessionConfig,\n SessionEvent,\n} from \"@github/copilot-sdk\";\nimport { chmod, mkdtemp, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { AgentError } from \"../errors.js\";\nimport { CopilotPermissions } from \"./copilot-permissions.js\";\nimport { copilotTools } from \"./copilot-tools.js\";\nimport type { AdapterOptions, NativeSession } from \"./types.js\";\n\nconst GATEWAY_URL = \"https://ai-gateway.vercel.sh/coding-agent/v1\";\n\ntype CopilotHarness = {\n readonly kind: \"copilot\";\n readonly model: string;\n};\n\ntype CopilotRoute =\n | { readonly kind: \"subscription\"; readonly model: string }\n | { readonly kind: \"github\"; readonly model: string; readonly token: string }\n | {\n readonly kind: \"byok\";\n readonly model: string;\n readonly token: string;\n readonly provider: \"openai\" | \"anthropic\" | \"azure\";\n readonly baseUrl: string;\n readonly wireApi?: \"completions\" | \"responses\";\n readonly apiVersion?: string;\n readonly wireModel?: string;\n }\n | { readonly kind: \"gateway\"; readonly model: string; readonly token: string; readonly bearer: boolean };\n\ntype PermissionResult = { readonly kind: string };\ntype AllowedModels = {\n readonly allowedModels?: string[];\n readonly effectiveAllowedModels?: string[];\n readonly fallbackModel?: string;\n readonly modelId?: string;\n};\ntype CopilotEndpoint = {\n readonly type: string;\n readonly wireApi?: string;\n readonly transport?: string;\n readonly baseUrl: string;\n readonly apiKey?: string;\n readonly headers: Record<string, string | undefined>;\n readonly sessionToken?: unknown;\n};\n\ninterface ActiveTurn {\n messageId?: string;\n started: boolean;\n turnId?: string;\n buffered: SessionEvent[];\n chunks?: string[];\n response: string;\n terminalError?: AgentError;\n interrupted: boolean;\n closing: boolean;\n settled: boolean;\n completion: Promise<string>;\n stopping?: Promise<void>;\n stopHealth?: () => void;\n resolve(value: string): void;\n reject(error: AgentError): void;\n}\n\nexport interface CopilotNativeSession {\n readonly sessionId: string;\n readonly rpc: {\n readonly model: {\n getCurrent(): Promise<CurrentModel>;\n setAllowedModels(params: { allowedModels: string[] }): Promise<AllowedModels>;\n };\n readonly provider: { getEndpoint(params?: { modelId?: string }): Promise<CopilotEndpoint> };\n readonly permissions: {\n setMode(params: { mode: \"manual\" }): Promise<{ success: boolean; mode: string }>;\n setRequired(params: { required: boolean }): Promise<{ success: boolean }>;\n handlePendingPermissionRequest(params: { requestId: string; result: { kind: string } }): Promise<PermissionResult>;\n };\n readonly metadata: {\n isProcessing(): Promise<{ processing: boolean }>;\n activity(): Promise<{ abortable: boolean; hasActiveWork: boolean }>;\n };\n readonly tools: {\n getBuiltinDescriptors(params: Record<string, never>): Promise<{ tools: Array<{ name: string }> }>;\n initializeAndValidate(): Promise<Record<string, never>>;\n getCurrentMetadata(): Promise<{ tools: Array<{ name: string }> | null }>;\n };\n abort(params?: Record<string, never>): Promise<{ success: boolean }>;\n };\n on(handler: (event: SessionEvent) => void): () => void;\n send(options: unknown): Promise<string>;\n disconnect(): Promise<void>;\n}\n\nexport interface CopilotNativeClient {\n start(): Promise<void>;\n createSession(config: SessionConfig): Promise<CopilotNativeSession>;\n deleteSession(sessionId: string): Promise<void>;\n stop(): Promise<Error[]>;\n forceStop(): Promise<void>;\n ping(message?: string): Promise<{ message: string; timestamp: string; protocolVersion?: number }>;\n getAuthStatus(): Promise<GetAuthStatusResponse>;\n listModels(): Promise<ModelInfo[]>;\n}\n\nexport interface CopilotDependencies {\n createClient(options: CopilotClientOptions): CopilotNativeClient;\n cancellationTimeoutMs?: number;\n cleanupTimeoutMs?: number;\n healthIntervalMs?: number;\n healthTimeoutMs?: number;\n}\n\nconst dependencies: CopilotDependencies = {\n createClient: options => new CopilotClient(options) as unknown as CopilotNativeClient,\n};\n\nexport const openCopilot = createCopilotOpener(dependencies);\n\n/** Dependency injection replaces only the native SDK/runtime boundary in tests. */\nexport function createCopilotOpener(deps: CopilotDependencies) {\n return async (options: AdapterOptions): Promise<NativeSession> => {\n const route = validateOptions(options);\n const tools = copilotTools(options.agent);\n const cleanupTimeoutMs = deps.cleanupTimeoutMs ?? 25_000;\n const healthIntervalMs = Math.max(1, deps.healthIntervalMs ?? 1_000);\n const healthTimeoutMs = Math.max(1, deps.healthTimeoutMs ?? 1_000);\n const stateDirectory = await privateStateDirectory();\n const queuedEvents: SessionEvent[] = [];\n let runtimeEventHandler: ((event: SessionEvent) => void) | undefined;\n const onEvent = (event: SessionEvent): void => {\n if (runtimeEventHandler) runtimeEventHandler(event);\n else queuedEvents.push(event);\n };\n let client: CopilotNativeClient | undefined;\n let native: CopilotNativeSession | undefined;\n const environment = isolatedEnvironment(options.env, route.kind === \"subscription\");\n try {\n client = deps.createClient({\n connection: RuntimeConnection.forStdio({ env: environment }),\n mode: \"copilot-cli\",\n workingDirectory: options.cwd,\n baseDirectory: route.kind === \"subscription\" ? undefined : stateDirectory,\n useLoggedInUser: route.kind === \"subscription\",\n gitHubToken: route.kind === \"github\" ? route.token : undefined,\n logLevel: \"none\",\n });\n await client.start();\n } catch {\n if (await cleanup(client, undefined, stateDirectory, cleanupTimeoutMs)) throw cleanupError();\n throw new AgentError(\"HARNESS_UNAVAILABLE\", \"The Copilot native runtime is missing or incompatible.\");\n }\n\n try {\n await verifyClientAccess(client, route);\n native = await client.createSession({\n model: route.model,\n workingDirectory: options.cwd,\n configDirectory: stateDirectory,\n enableConfigDiscovery: false,\n ...(route.kind === \"github\" ? { enableManagedSettings: true } : {}),\n enableSessionStore: false,\n skipEmbeddingRetrieval: true,\n embeddingCacheStorage: \"in-memory\",\n remoteSession: \"off\",\n onEvent,\n systemMessage: options.agent.instructions\n ? { mode: \"append\", content: options.agent.instructions }\n : undefined,\n ...tools.config,\n gitHubToken: route.kind === \"github\" ? route.token : undefined,\n provider: providerConfiguration(route),\n });\n } catch (error) {\n const failure = classifySessionStartup(error);\n if (await cleanup(client, undefined, stateDirectory, cleanupTimeoutMs)) throw cleanupError();\n throw failure;\n }\n\n try {\n if (queuedEvents.some(requiresInput)) throw inputRequired();\n await verifyNativeSelection(client, native, route);\n await verifyNativeTools(native, tools.names);\n if (queuedEvents.some(requiresInput)) throw inputRequired();\n } catch (error) {\n const cleanupFailed = await cleanup(client, native, stateDirectory, cleanupTimeoutMs);\n if (cleanupFailed) throw cleanupError();\n if (error instanceof AgentError) throw error;\n throw new AgentError(\"HARNESS_ERROR\", \"Copilot startup verification failed.\");\n }\n\n let closed = false;\n let closing: Promise<void> | undefined;\n let active: ActiveTurn | undefined;\n let selectionChanged = false;\n let poisoned = false;\n const cancellationTimeoutMs = deps.cancellationTimeoutMs ?? 3_000;\n let stopAffectedWork: ((current: ActiveTurn) => void) | undefined;\n const permissions = new CopilotPermissions(options.onApproval, error => {\n if (active) {\n active.terminalError = error;\n stopAffectedWork?.(active);\n }\n });\n\n const finish = async (current: ActiveTurn): Promise<void> => {\n if (current.settled) return;\n current.settled = true;\n current.stopHealth?.();\n tools.stopAdmission();\n permissions.clear();\n try {\n await tools.drain();\n if (current.closing) throw new AgentError(\"SESSION_CLOSED\", \"The Copilot session closed during the turn.\");\n if (current.interrupted) throw new AgentError(\"INTERRUPTED\", \"The Copilot turn was interrupted.\");\n await verifyPinnedSelection(client!, native!, route);\n if (selectionChanged) throw selectionError();\n if (current.terminalError) throw current.terminalError;\n if (Buffer.byteLength(current.response, \"utf8\") > 1024 * 1024) {\n throw new AgentError(\"RESPONSE_TOO_LARGE\", \"The Copilot response exceeds 1 MiB.\");\n }\n current.resolve(current.response);\n } catch (error) {\n current.reject(error instanceof AgentError\n ? error\n : new AgentError(\"HARNESS_ERROR\", \"Copilot could not complete the turn.\"));\n } finally {\n if (active === current) active = undefined;\n }\n };\n\n const stopActiveTurn = async (current: ActiveTurn): Promise<void> => {\n tools.stopAdmission();\n permissions.clear();\n let acknowledgement;\n try {\n acknowledgement = await boundedNativeCall(\n native!.rpc.abort({}),\n cancellationTimeoutMs,\n );\n }\n catch { throw cleanupError(); }\n if (!acknowledgement.success) throw cleanupError();\n await waitForNativeIdle(native!, cancellationTimeoutMs);\n await tools.drain();\n await finish(current);\n await current.completion.catch(() => {});\n };\n const ensureStopped = (current: ActiveTurn): Promise<void> => current.stopping ??= stopActiveTurn(current);\n const failUnconfirmedAffectedWork = async (current: ActiveTurn): Promise<void> => {\n if (current.settled) return;\n poisoned = true;\n current.stopHealth?.();\n tools.stopAdmission();\n permissions.clear();\n current.settled = true;\n current.terminalError = cleanupError();\n await tools.drain();\n current.reject(current.terminalError);\n };\n const failTerminalTurn = async (current: ActiveTurn, error: AgentError): Promise<void> => {\n if (current.settled) return;\n poisoned = true;\n current.stopHealth?.();\n tools.stopAdmission();\n permissions.clear();\n current.settled = true;\n await tools.drain();\n current.reject(error);\n if (active === current) active = undefined;\n };\n const startHealthMonitor = (current: ActiveTurn): void => {\n const controller = new AbortController();\n current.stopHealth = () => controller.abort();\n void (async () => {\n while (await monitorDelay(healthIntervalMs, controller.signal)) {\n if (current.settled || closed) return;\n try {\n await boundedNativeCall(client!.ping(), healthTimeoutMs, controller.signal);\n } catch {\n if (controller.signal.aborted || current.settled || closed) return;\n await failTerminalTurn(\n current,\n new AgentError(\"HARNESS_ERROR\", \"The Copilot native transport became unavailable.\"),\n );\n return;\n }\n }\n })();\n };\n stopAffectedWork = current => {\n void ensureStopped(current).catch(() => failUnconfirmedAffectedWork(current));\n };\n\n const handleEvent = (event: SessionEvent): void => {\n if (event.type === \"session.model_change\" && event.agentId === undefined) {\n const changed = event.data.newModel;\n if (changed !== route.model) selectionChanged = true;\n }\n const current = active;\n if (event.type === \"session.shutdown\") {\n if (current && !current.settled) {\n void failTerminalTurn(\n current,\n new AgentError(\"HARNESS_ERROR\", \"The Copilot native session shut down unexpectedly.\"),\n );\n }\n return;\n }\n if (event.type === \"permission.completed\") {\n permissions.withdraw(event.data.requestId);\n return;\n }\n if (event.type === \"permission.requested\") {\n if (current && !current.settled) permissions.handle(native!.rpc.permissions, event.data);\n else if (!event.data.resolvedByHook) {\n void native!.rpc.permissions.handlePendingPermissionRequest({\n requestId: event.data.requestId,\n result: { kind: \"user-not-available\" },\n }).catch(() => {});\n }\n return;\n }\n if (!current || current.settled) return;\n if (requiresInput(event)) {\n current.terminalError = inputRequired();\n stopAffectedWork?.(current);\n return;\n }\n if (event.agentId !== undefined) return;\n if (current.messageId === undefined) {\n current.buffered.push(event);\n return;\n }\n if (event.type === \"user.message\") {\n if (event.data.messageId === current.messageId) {\n current.started = true;\n current.turnId = event.data.turnId;\n }\n return;\n }\n if (event.type === \"assistant.message\") {\n if (event.data.originatingMessageId !== current.messageId) return;\n current.started = true;\n current.turnId = event.data.turnId ?? current.turnId;\n // BYOK reports the provider-facing model/deployment here, not the separately pinned behavior model.\n if (route.kind !== \"byok\" && event.data.model !== undefined && event.data.model !== route.model) {\n current.terminalError = selectionError();\n return;\n }\n if (event.data.chunkCount !== undefined && event.data.chunkIndex !== undefined) {\n current.chunks ??= [];\n current.chunks[event.data.chunkIndex] = event.data.content;\n current.response = current.chunks.join(\"\");\n } else {\n current.chunks = undefined;\n current.response = event.data.content;\n }\n if (Buffer.byteLength(current.response, \"utf8\") > 1024 * 1024) {\n current.terminalError = new AgentError(\"RESPONSE_TOO_LARGE\", \"The Copilot response exceeds 1 MiB.\");\n }\n } else if (event.type === \"session.error\") {\n current.terminalError = new AgentError(\"HARNESS_ERROR\", \"Copilot reported a native execution error.\");\n } else if (event.type === \"session.idle\") {\n if (!current.started) return;\n if (event.data.aborted) current.interrupted = true;\n void waitForNativeIdle(native!, cancellationTimeoutMs)\n .then(\n () => finish(current),\n () => failUnconfirmedAffectedWork(current),\n );\n }\n };\n runtimeEventHandler = handleEvent;\n for (const event of queuedEvents.splice(0)) handleEvent(event);\n\n return {\n async turn(prompt) {\n if (closed) throw new AgentError(\"SESSION_CLOSED\", \"The Copilot session has closed.\");\n if (poisoned) throw cleanupError();\n if (active) throw new AgentError(\"SESSION_BUSY\", \"Copilot already has an active turn.\");\n selectionChanged = false;\n await verifyPinnedSelection(client!, native!, route);\n let resolve!: (value: string) => void;\n let reject!: (error: AgentError) => void;\n const current: ActiveTurn = {\n buffered: [], response: \"\", started: false, interrupted: false, closing: false, settled: false,\n completion: new Promise<string>((onResolve, onReject) => { resolve = onResolve; reject = onReject; }),\n resolve: value => resolve(value), reject: error => reject(error),\n };\n active = current;\n tools.start();\n startHealthMonitor(current);\n void (async () => {\n try {\n const messageId = await native!.send({ prompt, mode: \"enqueue\" });\n if (current.settled || closed || active !== current) {\n current.buffered.length = 0;\n return;\n }\n current.messageId = messageId;\n for (const event of current.buffered.splice(0)) handleEvent(event);\n } catch {\n current.buffered.length = 0;\n if (current.settled) return;\n current.settled = true;\n current.stopHealth?.();\n tools.stopAdmission();\n permissions.clear();\n await tools.drain();\n current.reject(new AgentError(\"HARNESS_ERROR\", \"Copilot could not submit the native turn.\"));\n if (active === current) active = undefined;\n }\n })();\n return await current.completion;\n },\n async steer() {\n throw new AgentError(\"UNSUPPORTED_DELIVERY\", \"Copilot does not expose verified active steering.\");\n },\n async interrupt() {\n const current = active;\n if (!current) return;\n current.interrupted = true;\n try { await ensureStopped(current); }\n catch {\n await failUnconfirmedAffectedWork(current);\n throw cleanupError();\n }\n },\n async resume() {\n throw new AgentError(\"RECOVERY_UNSUPPORTED\", \"Copilot cannot retry failed execution without replaying input.\");\n },\n async close() {\n if (closing) return await closing;\n closed = true;\n if (active) active.closing = true;\n active?.stopHealth?.();\n tools.stopAdmission();\n permissions.clear();\n closing = (async () => {\n runtimeEventHandler = () => {};\n let activeStopFailed = false;\n if (active) {\n try { await ensureStopped(active); }\n catch { activeStopFailed = true; }\n }\n const cleanupFailed = await cleanup(client, native, stateDirectory, cleanupTimeoutMs);\n await tools.drain();\n if (active && !active.settled) await finish(active);\n if (cleanupFailed || activeStopFailed) throw cleanupError();\n })();\n return await closing;\n },\n };\n };\n}\n\nfunction validateOptions(options: AdapterOptions): CopilotRoute {\n const harness = options.harness as unknown as CopilotHarness;\n if (harness.kind !== \"copilot\") throw new AgentError(\"INVALID_CONFIG\", \"Copilot received configuration for a different harness.\");\n if (typeof harness.model !== \"string\" || !harness.model.trim() || /\\s/u.test(harness.model)) {\n throw new AgentError(\"INVALID_CONFIG\", \"Copilot requires an explicit model identifier.\");\n }\n if (harness.model === \"auto\") throw new AgentError(\"INVALID_CONFIG\", \"Copilot does not support native automatic model routing.\");\n const access = options.access;\n if (access.type === \"subscription\") {\n if (access.provider !== undefined || hasProviderOptions(access)) unsupportedAccessOption();\n return { kind: \"subscription\", model: harness.model };\n }\n if (options.access.type === \"api-key\") {\n const token = requiredToken(access.token);\n if (access.provider === \"github\") {\n if (hasProviderOptions(access)) unsupportedAccessOption();\n return { kind: \"github\", model: harness.model, token };\n }\n if (access.provider !== \"openai\" && access.provider !== \"anthropic\" && access.provider !== \"azure\") {\n throw new AgentError(\"UNSUPPORTED_OPTION\", \"Copilot requires a supported explicit API-key provider.\");\n }\n if (access.provider === \"anthropic\" && (access.wireApi !== undefined || access.apiVersion !== undefined)) unsupportedAccessOption();\n if (access.provider === \"openai\" && access.apiVersion !== undefined) unsupportedAccessOption();\n if (access.provider === \"azure\" && access.baseUrl === undefined) {\n throw new AgentError(\"INVALID_CONFIG\", \"Copilot Azure access requires an explicit base URL.\");\n }\n return {\n kind: \"byok\",\n model: harness.model,\n token,\n provider: access.provider,\n baseUrl: access.baseUrl ?? (access.provider === \"openai\"\n ? \"https://api.openai.com/v1\"\n : \"https://api.anthropic.com\"),\n wireApi: access.provider === \"anthropic\" ? undefined : (access.wireApi ?? \"completions\"),\n apiVersion: access.apiVersion,\n wireModel: access.wireModel,\n };\n }\n if (access.type !== \"vercel-api-key\" && access.type !== \"vercel-oidc\") {\n throw new AgentError(\"UNSUPPORTED_OPTION\", \"Copilot received an unsupported access route.\");\n }\n if (access.provider !== undefined || hasProviderOptions(access)) unsupportedAccessOption();\n if (!/^[^\\s/]+\\/[^\\s/]+$/u.test(harness.model)) {\n throw new AgentError(\"INVALID_CONFIG\", \"Copilot Gateway access requires an explicit creator/model identifier.\");\n }\n return {\n kind: \"gateway\",\n model: harness.model,\n token: requiredToken(access.token),\n bearer: access.type === \"vercel-oidc\",\n };\n}\n\nfunction hasProviderOptions(access: AdapterOptions[\"access\"]): boolean {\n return access.baseUrl !== undefined || access.wireApi !== undefined\n || access.apiVersion !== undefined || access.wireModel !== undefined;\n}\n\nfunction unsupportedAccessOption(): never {\n throw new AgentError(\"UNSUPPORTED_OPTION\", \"Copilot received an option that is not supported for the selected access route.\");\n}\n\nfunction requiredToken(token: string | undefined): string {\n if (!token?.trim()) throw new AgentError(\"ACCESS_UNAVAILABLE\", \"The selected Copilot credential is unavailable.\");\n return token;\n}\n\nasync function privateStateDirectory(): Promise<string> {\n try {\n const directory = await mkdtemp(join(tmpdir(), \"subharness-copilot-\"));\n await chmod(directory, 0o700);\n return directory;\n } catch {\n throw new AgentError(\"HARNESS_UNAVAILABLE\", \"Copilot could not create private native state.\");\n }\n}\n\nfunction isolatedEnvironment(source: NodeJS.ProcessEnv, preserveNativeHome: boolean): Record<string, string> {\n const environment: Record<string, string> = {};\n for (const [name, value] of Object.entries(source)) if (value !== undefined) environment[name] = value;\n for (const name of Object.keys(environment)) {\n if (/^COPILOT_PROVIDER_/u.test(name) || [\n \"COPILOT_CLI_PATH\", \"COPILOT_MODEL\", \"COPILOT_API_URL\", \"COPILOT_SDK_AUTH_TOKEN\", \"COPILOT_GITHUB_TOKEN\",\n \"GITHUB_COPILOT_API_TOKEN\", \"GH_TOKEN\", \"GITHUB_TOKEN\", \"OPENAI_API_KEY\", \"OPENAI_BASE_URL\",\n \"ANTHROPIC_API_KEY\", \"ANTHROPIC_AUTH_TOKEN\", \"ANTHROPIC_BASE_URL\", \"GOOGLE_API_KEY\", \"GEMINI_API_KEY\",\n \"AZURE_OPENAI_API_KEY\", \"AZURE_OPENAI_ENDPOINT\", \"AI_GATEWAY_API_KEY\", \"VERCEL_OIDC_TOKEN\",\n ].includes(name)) delete environment[name];\n }\n if (!preserveNativeHome || !environment.COPILOT_HOME?.trim()) delete environment.COPILOT_HOME;\n environment.COPILOT_ALLOW_GET_PROVIDER_ENDPOINT = \"true\";\n return environment;\n}\n\nfunction providerConfiguration(route: CopilotRoute): ProviderConfig | undefined {\n if (route.kind === \"gateway\") {\n return {\n type: \"openai\",\n wireApi: \"completions\",\n baseUrl: GATEWAY_URL,\n ...(route.bearer ? { bearerToken: route.token } : { apiKey: route.token }),\n };\n }\n if (route.kind === \"byok\") {\n return {\n type: route.provider,\n ...(route.wireApi === undefined ? {} : { wireApi: route.wireApi }),\n transport: \"http\",\n baseUrl: route.baseUrl,\n apiKey: route.token,\n ...(route.provider === \"azure\" && route.apiVersion !== undefined\n ? { azure: { apiVersion: route.apiVersion } }\n : {}),\n modelId: route.model,\n ...(route.wireModel === undefined ? {} : { wireModel: route.wireModel }),\n };\n }\n return undefined;\n}\n\nasync function verifyClientAccess(client: CopilotNativeClient, route: CopilotRoute): Promise<void> {\n if (route.kind !== \"subscription\" && route.kind !== \"github\") return;\n await verifyAuthStatus(client, route);\n let models: unknown;\n try { models = await client.listModels(); }\n catch { throw new AgentError(\"HARNESS_ERROR\", \"Copilot could not verify the native model catalog.\"); }\n if (!Array.isArray(models) || models.some(model => !plainObject(model) || typeof model.id !== \"string\" || !model.id)) {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Copilot returned malformed native model metadata.\");\n }\n const matches = models.filter(model => model.id === route.model);\n if (matches.length === 0) throw selectionError();\n if (matches.length !== 1) throw new AgentError(\"PROTOCOL_ERROR\", \"Copilot returned ambiguous native model metadata.\");\n}\n\nasync function verifyAuthStatus(client: CopilotNativeClient, route: Extract<CopilotRoute, { kind: \"subscription\" | \"github\" }>): Promise<void> {\n let status: unknown;\n try { status = await client.getAuthStatus(); }\n catch { throw new AgentError(\"HARNESS_ERROR\", \"Copilot could not verify native authentication.\"); }\n if (!plainObject(status) || typeof status.isAuthenticated !== \"boolean\"\n || (status.authType !== undefined && typeof status.authType !== \"string\")) {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Copilot returned malformed native authentication metadata.\");\n }\n if (status.authType !== undefined && !new Set([\"user\", \"env\", \"gh-cli\", \"hmac\", \"api-key\", \"token\"]).has(status.authType)) {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Copilot returned unknown native authentication metadata.\");\n }\n if (!status.isAuthenticated) throw new AgentError(\"ACCESS_UNAVAILABLE\", \"The selected Copilot authentication is unavailable.\");\n const expected = route.kind === \"subscription\"\n ? status.authType === \"user\" || status.authType === \"gh-cli\"\n : status.authType === \"token\";\n if (!expected) throw new AgentError(\"INVALID_CONFIG\", \"Copilot native authentication does not match the selected access route.\");\n}\n\nfunction plainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nasync function verifyNativeSelection(client: CopilotNativeClient, native: CopilotNativeSession, route: CopilotRoute): Promise<void> {\n try {\n const mode = await native.rpc.permissions.setMode({ mode: \"manual\" });\n if (!mode.success || mode.mode !== \"manual\") throw selectionError();\n const permissionEvents = await native.rpc.permissions.setRequired({ required: true });\n if (!permissionEvents.success) throw selectionError();\n\n const before = await native.rpc.model.getCurrent();\n if (before.modelId !== route.model) throw selectionError();\n const policy = await native.rpc.model.setAllowedModels({ allowedModels: [route.model] });\n if (!exactModels(policy.allowedModels, route.model) || !exactModels(policy.effectiveAllowedModels, route.model)\n || policy.modelId !== route.model || policy.fallbackModel !== route.model) throw selectionError();\n const after = await native.rpc.model.getCurrent();\n if (after.modelId !== route.model) throw selectionError();\n\n await verifyPinnedSelection(client, native, route);\n const [processing, activity] = await Promise.all([\n native.rpc.metadata.isProcessing(),\n native.rpc.metadata.activity(),\n ]);\n if (processing.processing || activity.hasActiveWork) throw selectionError();\n } catch (error) {\n if (error instanceof AgentError) throw error;\n throw selectionError();\n }\n}\n\nasync function verifyPinnedSelection(client: CopilotNativeClient, native: CopilotNativeSession, route: CopilotRoute): Promise<void> {\n try {\n const current = await native.rpc.model.getCurrent();\n if (current.modelId !== route.model) throw selectionError();\n if (route.kind === \"subscription\" || route.kind === \"github\") {\n await verifyAuthStatus(client, route);\n return;\n }\n const endpoint: unknown = await native.rpc.provider.getEndpoint({ modelId: route.model });\n if (!plainObject(endpoint) || !plainObject(endpoint.headers)\n || Object.values(endpoint.headers).some(value => value !== undefined && typeof value !== \"string\")) {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Copilot returned malformed native provider metadata.\");\n }\n const expectedType = route.kind === \"gateway\" ? \"openai\" : route.provider;\n const expectedWireApi = route.kind === \"gateway\" ? \"completions\" : route.wireApi;\n const expectedBaseUrl = route.kind === \"gateway\" ? GATEWAY_URL : route.baseUrl;\n if (endpoint.type !== expectedType || endpoint.wireApi !== expectedWireApi\n || (endpoint.transport !== undefined && endpoint.transport !== \"http\")\n || endpoint.baseUrl !== expectedBaseUrl || endpoint.apiKey !== route.token\n || !authorizationMatches(endpoint.headers, route.token)\n || endpoint.sessionToken !== undefined) throw selectionError();\n } catch (error) {\n if (error instanceof AgentError) throw error;\n if (isMethodUnavailable(error)) {\n throw new AgentError(\"HARNESS_UNAVAILABLE\", \"The Copilot native runtime lacks required protocol capabilities.\");\n }\n throw new AgentError(\"HARNESS_ERROR\", \"Copilot could not verify the pinned native selection.\");\n }\n}\n\nasync function verifyNativeTools(native: CopilotNativeSession, declaredNames: string[]): Promise<void> {\n if (declaredNames.length === 0) return;\n try {\n const builtins = await native.rpc.tools.getBuiltinDescriptors({});\n const builtinNames = new Set(builtins.tools.map(tool => tool.name));\n if (declaredNames.some(name => builtinNames.has(name))) {\n throw new AgentError(\"INVALID_CONFIG\", \"A declared Copilot tool conflicts with a native built-in tool.\");\n }\n await native.rpc.tools.initializeAndValidate();\n const current = await native.rpc.tools.getCurrentMetadata();\n const currentNames = new Set(current.tools?.map(tool => tool.name) ?? []);\n if (declaredNames.some(name => !currentNames.has(name))) {\n throw new AgentError(\"HARNESS_ERROR\", \"Copilot could not verify the declared native tools.\");\n }\n } catch (error) {\n if (error instanceof AgentError) throw error;\n if (isMethodUnavailable(error)) {\n throw new AgentError(\"HARNESS_UNAVAILABLE\", \"The Copilot native runtime lacks required tool protocol capabilities.\");\n }\n throw new AgentError(\"HARNESS_ERROR\", \"Copilot could not initialize the declared native tools.\");\n }\n}\n\nfunction exactModels(models: string[] | undefined, selected: string): boolean {\n return models?.length === 1 && models[0] === selected;\n}\n\nfunction selectionError(): AgentError {\n return new AgentError(\"INVALID_CONFIG\", \"Copilot could not verify the requested model and provider selection.\");\n}\n\nfunction authorizationMatches(headers: Record<string, unknown>, token: string): boolean {\n const authorizations = Object.entries(headers)\n .filter(([name]) => name.toLowerCase() === \"authorization\")\n .map(([, value]) => value);\n return authorizations.length <= 1\n && (authorizations.length === 0 || authorizations[0] === `Bearer ${token}`);\n}\n\nfunction classifySessionStartup(error: unknown): AgentError {\n if (error instanceof AgentError) return error;\n if (isMethodUnavailable(error)) {\n return new AgentError(\"HARNESS_UNAVAILABLE\", \"The Copilot native runtime lacks required session capabilities.\");\n }\n if (typeof error === \"object\" && error !== null && (error as { code?: unknown }).code === -32602) {\n return new AgentError(\"INVALID_CONFIG\", \"Copilot rejected the explicit native session configuration.\");\n }\n return new AgentError(\"HARNESS_ERROR\", \"Copilot could not create the explicitly configured native session.\");\n}\n\nfunction isMethodUnavailable(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null) return false;\n const code = (error as { code?: unknown }).code;\n return code === -32601 || code === \"METHOD_NOT_FOUND\" || code === \"UNSUPPORTED_METHOD\";\n}\n\nasync function cleanup(\n client: CopilotNativeClient | undefined,\n native: CopilotNativeSession | undefined,\n directory: string,\n timeoutMs: number,\n): Promise<boolean> {\n let failed = false;\n if (native) {\n try { await boundedNativeCall(native.disconnect(), timeoutMs); } catch { failed = true; }\n if (client) {\n try { await boundedNativeCall(client.deleteSession(native.sessionId), timeoutMs); } catch { failed = true; }\n }\n }\n if (client) {\n let force = false;\n try {\n const errors = await boundedNativeCall(client.stop(), timeoutMs);\n if (errors.length > 0) {\n failed = true;\n force = true;\n }\n } catch {\n failed = true;\n force = true;\n }\n if (force) {\n try { await boundedNativeCall(client.forceStop(), timeoutMs); }\n catch { failed = true; }\n }\n }\n try { await rm(directory, { recursive: true }); } catch { failed = true; }\n return failed;\n}\n\nfunction cleanupError(): AgentError {\n return new AgentError(\"CANCELLATION_FAILED\", \"Copilot native process cleanup could not be confirmed.\");\n}\n\nfunction inputRequired(): AgentError {\n return new AgentError(\"INPUT_REQUIRED\", \"Copilot requested unsupported interactive input.\");\n}\n\nfunction requiresInput(event: SessionEvent): boolean {\n if (event.type === \"permission.requested\") return event.data.resolvedByHook !== true;\n return new Set<string>([\n \"user_input.requested\",\n \"elicitation.requested\",\n \"sampling.requested\",\n \"mcp.oauth_required\",\n \"mcp.headers_refresh_required\",\n \"external_tool.requested\",\n \"ui.ephemeral_query\",\n \"auto_mode_switch.requested\",\n \"session_limits_exhausted.requested\",\n \"exit_plan_mode.requested\",\n ]).has(event.type);\n}\n\nasync function waitForNativeIdle(native: CopilotNativeSession, timeoutMs: number): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (true) {\n const remaining = deadline - Date.now();\n if (remaining <= 0) throw cleanupError();\n try {\n const [processing, activity] = await boundedNativeCall(\n Promise.all([\n native.rpc.metadata.isProcessing(),\n native.rpc.metadata.activity(),\n ]),\n remaining,\n );\n if (!processing.processing && !activity.hasActiveWork) return;\n } catch { throw cleanupError(); }\n const pause = Math.min(10, deadline - Date.now());\n if (pause <= 0) throw cleanupError();\n await new Promise(resolve => setTimeout(resolve, pause));\n }\n}\n\nasync function boundedNativeCall<T>(call: Promise<T>, timeoutMs: number, signal?: AbortSignal): Promise<T> {\n let timer: NodeJS.Timeout | undefined;\n let abort: (() => void) | undefined;\n try {\n const pending: Promise<T>[] = [\n call,\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(() => reject(cleanupError()), timeoutMs);\n }),\n ];\n if (signal) {\n pending.push(new Promise<T>((_resolve, reject) => {\n abort = () => reject(new Error(\"native-call-monitor-stopped\"));\n if (signal.aborted) abort();\n else signal.addEventListener(\"abort\", abort, { once: true });\n }));\n }\n return await Promise.race(pending);\n } finally {\n if (timer) clearTimeout(timer);\n if (signal && abort) signal.removeEventListener(\"abort\", abort);\n }\n}\n\nasync function monitorDelay(delayMs: number, signal: AbortSignal): Promise<boolean> {\n if (signal.aborted) return false;\n return await new Promise(resolve => {\n const timer = setTimeout(() => {\n signal.removeEventListener(\"abort\", stop);\n resolve(true);\n }, delayMs);\n const stop = () => {\n clearTimeout(timer);\n resolve(false);\n };\n signal.addEventListener(\"abort\", stop, { once: true });\n });\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AgentError } from "../errors.js";
|
|
2
|
+
import { approvalContext } from "./approval-context.js";
|
|
3
|
+
export function cursorCliApproval(params) {
|
|
4
|
+
try {
|
|
5
|
+
return convert(params);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
throw new AgentError("INPUT_REQUIRED", "Cursor requested a permission that cannot be represented safely.");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function convert(params) {
|
|
12
|
+
if (!record(params) || !text(params.sessionId) || !record(params.toolCall) || !Array.isArray(params.options))
|
|
13
|
+
throw new Error();
|
|
14
|
+
const call = params.toolCall;
|
|
15
|
+
if (!text(call.toolCallId) || !text(call.title)
|
|
16
|
+
|| (call.name !== undefined && !text(call.name))
|
|
17
|
+
|| (call.kind !== undefined && !["read", "edit", "delete", "move", "search", "execute", "think", "fetch", "switch_mode", "other"].includes(String(call.kind)))
|
|
18
|
+
|| (call.status !== undefined && !["pending", "in_progress", "completed", "failed"].includes(String(call.status)))
|
|
19
|
+
|| (call.content !== undefined && (!Array.isArray(call.content) || !call.content.every(validContent)))
|
|
20
|
+
|| (call.locations !== undefined && (!Array.isArray(call.locations) || !call.locations.every(location => record(location) && text(location.path)
|
|
21
|
+
&& (location.line === undefined || (Number.isSafeInteger(location.line) && Number(location.line) >= 0))))))
|
|
22
|
+
throw new Error();
|
|
23
|
+
const ids = new Set();
|
|
24
|
+
const choices = [];
|
|
25
|
+
for (const choice of params.options) {
|
|
26
|
+
if (!record(choice) || !text(choice.optionId) || !text(choice.name) || typeof choice.kind !== "string"
|
|
27
|
+
|| !["allow_once", "reject_once", "allow_always", "reject_always"].includes(choice.kind) || ids.has(choice.optionId))
|
|
28
|
+
throw new Error();
|
|
29
|
+
ids.add(choice.optionId);
|
|
30
|
+
if (choice.kind === "allow_once" || choice.kind === "reject_once")
|
|
31
|
+
choices.push({ optionId: choice.optionId, name: choice.name, kind: choice.kind });
|
|
32
|
+
}
|
|
33
|
+
if (!choices.length)
|
|
34
|
+
throw new Error();
|
|
35
|
+
const request = {
|
|
36
|
+
kind: "permission", harness: "cursor", message: call.title,
|
|
37
|
+
requestedSchema: {
|
|
38
|
+
type: "object", properties: { decision: { type: "string", oneOf: choices.map(choice => ({ const: choice.optionId, title: choice.name })) } },
|
|
39
|
+
required: ["decision"],
|
|
40
|
+
},
|
|
41
|
+
context: {
|
|
42
|
+
sessionId: params.sessionId,
|
|
43
|
+
toolCall: approvalContext(call, ["toolCallId", "name", "title", "kind", "status", "rawInput", "content", "locations"]),
|
|
44
|
+
options: choices.map(choice => approvalContext(choice, ["optionId", "name", "kind"])),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const serialized = JSON.stringify(request, (_key, value) => {
|
|
48
|
+
if (["undefined", "function", "symbol", "bigint"].includes(typeof value)
|
|
49
|
+
|| (typeof value === "number" && !Number.isFinite(value)))
|
|
50
|
+
throw new Error();
|
|
51
|
+
return value;
|
|
52
|
+
});
|
|
53
|
+
if (Buffer.byteLength(serialized) > 64 * 1024)
|
|
54
|
+
throw new Error();
|
|
55
|
+
return JSON.parse(serialized);
|
|
56
|
+
}
|
|
57
|
+
function record(value) {
|
|
58
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
59
|
+
&& [Object.prototype, null].includes(Object.getPrototypeOf(value));
|
|
60
|
+
}
|
|
61
|
+
function text(value) { return typeof value === "string" && value.trim().length > 0; }
|
|
62
|
+
function validContent(value) {
|
|
63
|
+
if (!record(value))
|
|
64
|
+
return false;
|
|
65
|
+
if (value.type === "diff")
|
|
66
|
+
return text(value.path) && typeof value.newText === "string"
|
|
67
|
+
&& (value.oldText === undefined || value.oldText === null || typeof value.oldText === "string");
|
|
68
|
+
if (value.type === "terminal")
|
|
69
|
+
return text(value.terminalId);
|
|
70
|
+
if (value.type !== "content" || !record(value.content))
|
|
71
|
+
return false;
|
|
72
|
+
const block = value.content;
|
|
73
|
+
switch (block.type) {
|
|
74
|
+
case "text": return typeof block.text === "string";
|
|
75
|
+
case "image":
|
|
76
|
+
case "audio": return text(block.data) && text(block.mimeType);
|
|
77
|
+
case "resource_link": return text(block.uri) && text(block.name);
|
|
78
|
+
case "resource": return record(block.resource) && text(block.resource.uri)
|
|
79
|
+
&& (typeof block.resource.text === "string" || typeof block.resource.blob === "string");
|
|
80
|
+
default: return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=cursor-cli-approvals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-cli-approvals.js","sourceRoot":"","sources":["../../src/adapters/cursor-cli-approvals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,IAAI,CAAC;QAAC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IAAC,CAAC;IAC/B,MAAM,CAAC;QAAC,MAAM,IAAI,UAAU,CAAC,gBAAgB,EAAE,kEAAkE,CAAC,CAAC;IAAC,CAAC;AACvH,CAAC;AAED,SAAS,OAAO,CAAC,MAAe;IAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,EAAE,CAAC;IAChI,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;WAC1C,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;WAC7C,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CA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nimport { AgentError } from \"../errors.js\";\nimport { approvalContext } from \"./approval-context.js\";\n\nexport function cursorCliApproval(params: unknown): NativeApprovalRequest {\n try { return convert(params); }\n catch { throw new AgentError(\"INPUT_REQUIRED\", \"Cursor requested a permission that cannot be represented safely.\"); }\n}\n\nfunction convert(params: unknown): NativeApprovalRequest {\n if (!record(params) || !text(params.sessionId) || !record(params.toolCall) || !Array.isArray(params.options)) throw new Error();\n const call = params.toolCall;\n if (!text(call.toolCallId) || !text(call.title)\n || (call.name !== undefined && !text(call.name))\n || (call.kind !== undefined && ![\"read\", \"edit\", \"delete\", \"move\", \"search\", \"execute\", \"think\", \"fetch\", \"switch_mode\", \"other\"].includes(String(call.kind)))\n || (call.status !== undefined && ![\"pending\", \"in_progress\", \"completed\", \"failed\"].includes(String(call.status)))\n || (call.content !== undefined && (!Array.isArray(call.content) || !call.content.every(validContent)))\n || (call.locations !== undefined && (!Array.isArray(call.locations) || !call.locations.every(location => record(location) && text(location.path)\n && (location.line === undefined || (Number.isSafeInteger(location.line) && Number(location.line) >= 0)))))) throw new Error();\n\n const ids = new Set<string>();\n const choices: { optionId: string; name: string; kind: string }[] = [];\n for (const choice of params.options) {\n if (!record(choice) || !text(choice.optionId) || !text(choice.name) || typeof choice.kind !== \"string\"\n || ![\"allow_once\", \"reject_once\", \"allow_always\", \"reject_always\"].includes(choice.kind) || ids.has(choice.optionId)) throw new Error();\n ids.add(choice.optionId);\n if (choice.kind === \"allow_once\" || choice.kind === \"reject_once\") choices.push({ optionId: choice.optionId, name: choice.name, kind: choice.kind });\n }\n if (!choices.length) throw new Error();\n const request: NativeApprovalRequest = {\n kind: \"permission\", harness: \"cursor\", message: call.title,\n requestedSchema: {\n type: \"object\", properties: { decision: { type: \"string\", oneOf: choices.map(choice => ({ const: choice.optionId, title: choice.name })) } },\n required: [\"decision\"],\n },\n context: {\n sessionId: params.sessionId,\n toolCall: approvalContext(call, [\"toolCallId\", \"name\", \"title\", \"kind\", \"status\", \"rawInput\", \"content\", \"locations\"]),\n options: choices.map(choice => approvalContext(choice, [\"optionId\", \"name\", \"kind\"])),\n },\n };\n const serialized = JSON.stringify(request, (_key, value: unknown) => {\n if ([\"undefined\", \"function\", \"symbol\", \"bigint\"].includes(typeof value)\n || (typeof value === \"number\" && !Number.isFinite(value))) throw new Error();\n return value;\n });\n if (Buffer.byteLength(serialized) > 64 * 1024) throw new Error();\n return JSON.parse(serialized) as NativeApprovalRequest;\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n && [Object.prototype, null].includes(Object.getPrototypeOf(value));\n}\nfunction text(value: unknown): value is string { return typeof value === \"string\" && value.trim().length > 0; }\n\nfunction validContent(value: unknown): boolean {\n if (!record(value)) return false;\n if (value.type === \"diff\") return text(value.path) && typeof value.newText === \"string\"\n && (value.oldText === undefined || value.oldText === null || typeof value.oldText === \"string\");\n if (value.type === \"terminal\") return text(value.terminalId);\n if (value.type !== \"content\" || !record(value.content)) return false;\n const block = value.content;\n switch (block.type) {\n case \"text\": return typeof block.text === \"string\";\n case \"image\": case \"audio\": return text(block.data) && text(block.mimeType);\n case \"resource_link\": return text(block.uri) && text(block.name);\n case \"resource\": return record(block.resource) && text(block.resource.uri)\n && (typeof block.resource.text === \"string\" || typeof block.resource.blob === \"string\");\n default: return false;\n }\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CursorRpc } from "./cursor-rpc.js";
|
|
2
|
+
export declare function selectCursorCliModel(created: unknown, requested: string): string;
|
|
3
|
+
export declare function applyCursorCliModel(rpc: CursorRpc, sessionId: string, selected: string): Promise<void>;
|
|
4
|
+
export declare function verifyCursorCliModelUpdate(configOptions: unknown, selected: string): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AgentError } from "../errors.js";
|
|
2
|
+
const ROUTING_MODELS = new Set(["auto", "auto-smart", "default", "default[]"]);
|
|
3
|
+
export function selectCursorCliModel(created, requested) {
|
|
4
|
+
if (ROUTING_MODELS.has(requested)) {
|
|
5
|
+
throw new AgentError("UNSUPPORTED_OPTION", "Cursor subscription access requires a concrete native model.");
|
|
6
|
+
}
|
|
7
|
+
const session = object(created, "Cursor returned an invalid native session.");
|
|
8
|
+
const models = object(session.models, "Cursor returned an invalid native model catalog.");
|
|
9
|
+
if (!Array.isArray(models.availableModels)) {
|
|
10
|
+
throw new AgentError("PROTOCOL_ERROR", "Cursor returned an invalid native model catalog.");
|
|
11
|
+
}
|
|
12
|
+
const identifiers = new Set();
|
|
13
|
+
for (const entry of models.availableModels) {
|
|
14
|
+
const model = object(entry, "Cursor returned an invalid native model catalog.");
|
|
15
|
+
if (typeof model.modelId !== "string" || !model.modelId || identifiers.has(model.modelId)) {
|
|
16
|
+
throw new AgentError("PROTOCOL_ERROR", "Cursor returned an invalid native model catalog.");
|
|
17
|
+
}
|
|
18
|
+
identifiers.add(model.modelId);
|
|
19
|
+
}
|
|
20
|
+
if (!identifiers.has(requested)) {
|
|
21
|
+
throw new AgentError("INVALID_CONFIG", "The requested Cursor model is not a concrete base ID in the native catalog.");
|
|
22
|
+
}
|
|
23
|
+
modelOption(session.configOptions);
|
|
24
|
+
return requested;
|
|
25
|
+
}
|
|
26
|
+
export async function applyCursorCliModel(rpc, sessionId, selected) {
|
|
27
|
+
const configured = await rpc.request("session/set_config_option", { sessionId, configId: "model", value: selected }, 15_000);
|
|
28
|
+
verifySelected(modelOption(object(configured, "Cursor returned an invalid native model configuration.").configOptions), selected);
|
|
29
|
+
}
|
|
30
|
+
export function verifyCursorCliModelUpdate(configOptions, selected) {
|
|
31
|
+
if (!Array.isArray(configOptions)) {
|
|
32
|
+
throw new AgentError("PROTOCOL_ERROR", "Cursor returned an invalid native model configuration.");
|
|
33
|
+
}
|
|
34
|
+
const matches = configOptions.filter(value => value && typeof value === "object" && !Array.isArray(value) && value.id === "model");
|
|
35
|
+
if (!matches.length)
|
|
36
|
+
return;
|
|
37
|
+
if (matches.length !== 1)
|
|
38
|
+
throw new AgentError("PROTOCOL_ERROR", "Cursor returned an invalid native model configuration.");
|
|
39
|
+
verifySelected(modelOption(matches), selected);
|
|
40
|
+
}
|
|
41
|
+
function modelOption(configOptions) {
|
|
42
|
+
if (!Array.isArray(configOptions)) {
|
|
43
|
+
throw new AgentError("PROTOCOL_ERROR", "Cursor returned an invalid native model configuration.");
|
|
44
|
+
}
|
|
45
|
+
const matches = configOptions.filter(value => value && typeof value === "object" && !Array.isArray(value) && value.id === "model");
|
|
46
|
+
if (matches.length !== 1)
|
|
47
|
+
throw new AgentError("PROTOCOL_ERROR", "Cursor returned an invalid native model configuration.");
|
|
48
|
+
const option = object(matches[0], "Cursor returned an invalid native model configuration.");
|
|
49
|
+
if (typeof option.currentValue !== "string") {
|
|
50
|
+
throw new AgentError("PROTOCOL_ERROR", "Cursor returned an invalid native model configuration.");
|
|
51
|
+
}
|
|
52
|
+
return option;
|
|
53
|
+
}
|
|
54
|
+
function verifySelected(option, selected) {
|
|
55
|
+
if (option.currentValue !== selected) {
|
|
56
|
+
throw new AgentError("INVALID_CONFIG", "Cursor changed the explicitly selected native model.");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function object(value, message) {
|
|
60
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
61
|
+
throw new AgentError("PROTOCOL_ERROR", message);
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=cursor-cli-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-cli-model.js","sourceRoot":"","sources":["../../src/adapters/cursor-cli-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;AAE/E,MAAM,UAAU,oBAAoB,CAAC,OAAgB,EAAE,SAAiB;IACtE,IAA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,IAAK,KAAa,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC;IAC5I,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,gBAAgB,EAAE,wDAAwD,CAAC,CAAC;IAC3H,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,wDAAwD,CAAC,CAAC;IAC5F,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,UAAU,CAAC,gBAAgB,EAAE,wDAAwD,CAAC,CAAC;IACnG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,MAA+B,EAAE,QAAgB;IACvE,IAAI,MAAM,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;QACrC,MAAM,IAAI,UAAU,CAAC,gBAAgB,EAAE,sDAAsD,CAAC,CAAC;IACjG,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,KAAc,EAAE,OAAe;IAC7C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACjH,OAAO,KAA4B,CAAC;AACtC,CAAC","sourcesContent":["import { AgentError } from \"../errors.js\";\nimport type { CursorRpc } from \"./cursor-rpc.js\";\n\nconst ROUTING_MODELS = new Set([\"auto\", \"auto-smart\", \"default\", \"default[]\"]);\n\nexport function selectCursorCliModel(created: unknown, requested: string): string {\n if (ROUTING_MODELS.has(requested)) {\n throw new AgentError(\"UNSUPPORTED_OPTION\", \"Cursor subscription access requires a concrete native model.\");\n }\n const session = object(created, \"Cursor returned an invalid native session.\");\n const models = object(session.models, \"Cursor returned an invalid native model catalog.\");\n if (!Array.isArray(models.availableModels)) {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Cursor returned an invalid native model catalog.\");\n }\n const identifiers = new Set<string>();\n for (const entry of models.availableModels) {\n const model = object(entry, \"Cursor returned an invalid native model catalog.\");\n if (typeof model.modelId !== \"string\" || !model.modelId || identifiers.has(model.modelId)) {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Cursor returned an invalid native model catalog.\");\n }\n identifiers.add(model.modelId);\n }\n if (!identifiers.has(requested)) {\n throw new AgentError(\"INVALID_CONFIG\", \"The requested Cursor model is not a concrete base ID in the native catalog.\");\n }\n modelOption(session.configOptions);\n return requested;\n}\n\nexport async function applyCursorCliModel(rpc: CursorRpc, sessionId: string, selected: string): Promise<void> {\n const configured = await rpc.request(\"session/set_config_option\", { sessionId, configId: \"model\", value: selected }, 15_000);\n verifySelected(modelOption(object(configured, \"Cursor returned an invalid native model configuration.\").configOptions), selected);\n}\n\nexport function verifyCursorCliModelUpdate(configOptions: unknown, selected: string): void {\n if (!Array.isArray(configOptions)) {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Cursor returned an invalid native model configuration.\");\n }\n const matches = configOptions.filter(value => value && typeof value === \"object\" && !Array.isArray(value) && (value as any).id === \"model\");\n if (!matches.length) return;\n if (matches.length !== 1) throw new AgentError(\"PROTOCOL_ERROR\", \"Cursor returned an invalid native model configuration.\");\n verifySelected(modelOption(matches), selected);\n}\n\nfunction modelOption(configOptions: unknown): Record<string, unknown> {\n if (!Array.isArray(configOptions)) {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Cursor returned an invalid native model configuration.\");\n }\n const matches = configOptions.filter(value => value && typeof value === \"object\" && !Array.isArray(value) && (value as any).id === \"model\");\n if (matches.length !== 1) throw new AgentError(\"PROTOCOL_ERROR\", \"Cursor returned an invalid native model configuration.\");\n const option = object(matches[0], \"Cursor returned an invalid native model configuration.\");\n if (typeof option.currentValue !== \"string\") {\n throw new AgentError(\"PROTOCOL_ERROR\", \"Cursor returned an invalid native model configuration.\");\n }\n return option;\n}\n\nfunction verifySelected(option: Record<string, unknown>, selected: string): void {\n if (option.currentValue !== selected) {\n throw new AgentError(\"INVALID_CONFIG\", \"Cursor changed the explicitly selected native model.\");\n }\n}\n\nfunction object(value: unknown, message: string): Record<string, any> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) throw new AgentError(\"PROTOCOL_ERROR\", message);\n return value as Record<string, any>;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AdapterOptions, NativeSession } from "./types.js";
|
|
2
|
+
import type { CursorCliToolEndpoint } from "./cursor-cli-tools.js";
|
|
3
|
+
import { type CursorRpc } from "./cursor-rpc.js";
|
|
4
|
+
export declare class CursorCliSession implements NativeSession {
|
|
5
|
+
private readonly rpc;
|
|
6
|
+
private readonly sessionId;
|
|
7
|
+
private readonly selected;
|
|
8
|
+
private readonly options;
|
|
9
|
+
private readonly tools;
|
|
10
|
+
private readonly cleanup;
|
|
11
|
+
private closePromise?;
|
|
12
|
+
private active?;
|
|
13
|
+
private failure?;
|
|
14
|
+
private first;
|
|
15
|
+
private closed;
|
|
16
|
+
constructor(rpc: CursorRpc, sessionId: string, selected: string, options: AdapterOptions, tools: CursorCliToolEndpoint, cleanup: () => Promise<void>);
|
|
17
|
+
turn(prompt: string): Promise<string>;
|
|
18
|
+
steer(_prompt: string): Promise<void>;
|
|
19
|
+
interrupt(): Promise<void>;
|
|
20
|
+
resume(): Promise<string>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
private closeOwnedResources;
|
|
23
|
+
private message;
|
|
24
|
+
private finish;
|
|
25
|
+
private stop;
|
|
26
|
+
private fail;
|
|
27
|
+
private stopForModelFailure;
|
|
28
|
+
private unsupportedRequest;
|
|
29
|
+
private retireApprovals;
|
|
30
|
+
private retireApproval;
|
|
31
|
+
private respondCancelled;
|
|
32
|
+
}
|