@code-yeongyu/senpi 2026.8.21-3 → 2026.8.22
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/CHANGELOG.md +12 -0
- package/dist/core/extensions/builtin/permission-system/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/index.js +7 -11
- package/dist/core/extensions/builtin/permission-system/index.js.map +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +14 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-kernel.ts +15 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/stream-retry.d.ts +21 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/stream-retry.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/stream-retry.js +36 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/stream-retry.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/types.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +95 -30
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -10,8 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
### Changed
|
|
12
12
|
|
|
13
|
+
### Removed
|
|
14
|
+
|
|
15
|
+
## [2026.8.22] - 2026-08-22
|
|
16
|
+
|
|
17
|
+
### Breaking Changes
|
|
18
|
+
|
|
13
19
|
### Fixed
|
|
14
20
|
|
|
21
|
+
- The `permission-system` builtin extension now handles rejection during `session_shutdown` without causing an unhandled promise rejection / `uncaughtException` when permission prompts are pending.
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
15
27
|
### Removed
|
|
16
28
|
|
|
17
29
|
## [2026.8.21-3] - 2026-08-21
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAuDnD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAuDnD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAoHxE"}
|
|
@@ -92,14 +92,12 @@ export default function permissionSystemExtension(pi) {
|
|
|
92
92
|
always: permissionRequest.always,
|
|
93
93
|
metadata: createRequestMetadata(event.toolName, event.input),
|
|
94
94
|
};
|
|
95
|
-
const
|
|
95
|
+
const askResultPromise = service.ask(request).then(() => ({ ok: true }), (error) => ({ ok: false, error }));
|
|
96
96
|
const isPending = service.list().some((pendingRequest) => pendingRequest.id === request.id);
|
|
97
97
|
if (!isPending) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
catch (error) {
|
|
102
|
-
return { block: true, reason: getReason(error) };
|
|
98
|
+
const askResult = await askResultPromise;
|
|
99
|
+
if (!askResult.ok) {
|
|
100
|
+
return { block: true, reason: getReason(askResult.error) };
|
|
103
101
|
}
|
|
104
102
|
continue;
|
|
105
103
|
}
|
|
@@ -117,11 +115,9 @@ export default function permissionSystemExtension(pi) {
|
|
|
117
115
|
service.reply(reply);
|
|
118
116
|
}
|
|
119
117
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
catch (error) {
|
|
124
|
-
return { block: true, reason: getReason(error) };
|
|
118
|
+
const askResult = await askResultPromise;
|
|
119
|
+
if (!askResult.ok) {
|
|
120
|
+
return { block: true, reason: getReason(askResult.error) };
|
|
125
121
|
}
|
|
126
122
|
}
|
|
127
123
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAA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C,GAAG,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC;QAED,KAAK,MAAM,cAAc,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;YAC7C,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,cAAc,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAClE,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { SettingsManager } from \"../../../settings-manager.ts\";\nimport type { ExtensionAPI } from \"../../types.ts\";\nimport { extractPatchedPaths } from \"../gpt-apply-patch/index.ts\";\nimport { parsePermissionFlag, parsePermissionPresetFlag } from \"./cli.ts\";\nimport { disabled } from \"./config.ts\";\nimport { createEventEmitter } from \"./events.ts\";\nimport { handleNoUI } from \"./non-interactive.ts\";\nimport { createBuiltinParserRegistry, type ParserRegistry } from \"./parsers.ts\";\nimport { showPermissionPrompt } from \"./prompt.ts\";\nimport { PermissionService } from \"./service.ts\";\nimport { loadPermissionSettings } from \"./settings.ts\";\nimport { appendApproved } from \"./storage.ts\";\nimport { CorrectedError, DeniedError, RejectedError, type Request, type Ruleset } from \"./types.ts\";\n\nfunction createRequestIDFactory(): () => string {\n\tlet counter = 0;\n\treturn () => {\n\t\tcounter += 1;\n\t\treturn `permission-${counter}`;\n\t};\n}\n\nfunction getReason(error: unknown): string {\n\tif (error instanceof DeniedError || error instanceof CorrectedError || error instanceof RejectedError) {\n\t\treturn error.message;\n\t}\n\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\n\treturn \"Permission request was rejected.\";\n}\n\nfunction createRequestMetadata(toolName: string, input: Record<string, unknown>): Record<string, unknown> {\n\tconst metadata: Record<string, unknown> = {\n\t\ttoolName,\n\t\t...input,\n\t};\n\n\tconst pathValue = typeof input.path === \"string\" ? input.path : undefined;\n\tconst filePathValue = typeof input.file_path === \"string\" ? input.file_path : undefined;\n\tconst patchTextValue =\n\t\ttypeof input.input === \"string\" ? input.input : typeof input.patchText === \"string\" ? input.patchText : undefined;\n\n\tif (toolName === \"edit\" || toolName === \"write\" || toolName === \"apply_patch\" || toolName === \"multiedit\") {\n\t\tmetadata.filepath = pathValue ?? filePathValue ?? extractPatchedPaths(patchTextValue ?? \"\")[0];\n\t}\n\n\tif (toolName === \"read\") {\n\t\tmetadata.filePath = pathValue ?? filePathValue;\n\t}\n\n\treturn metadata;\n}\n\nexport default function permissionSystemExtension(pi: ExtensionAPI): void {\n\tlet service: PermissionService | null = null;\n\tlet parserRegistry: ParserRegistry | null = null;\n\tlet cliRuleset: Ruleset = [];\n\tlet staticRuleset: Ruleset = [];\n\tlet initialApprovedCount = 0;\n\n\tconst nextRequestID = createRequestIDFactory();\n\n\tpi.registerFlag(\"permission\", {\n\t\tdescription: \"Set permission rules (format: tool=action or tool:pattern=action)\",\n\t\ttype: \"string\",\n\t});\n\tpi.registerFlag(\"permission-preset\", {\n\t\tdescription: \"Set permission preset (full-access, workspace, read-only, or ask)\",\n\t\ttype: \"string\",\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd);\n\t\tconst permissionFlag = pi.getFlag(\"permission\");\n\t\tconst permissionPresetFlag = pi.getFlag(\"permission-preset\");\n\t\tcliRuleset = typeof permissionFlag === \"string\" ? parsePermissionFlag(permissionFlag) : [];\n\t\tconst cliPreset =\n\t\t\ttypeof permissionPresetFlag === \"string\" ? parsePermissionPresetFlag(permissionPresetFlag) : undefined;\n\n\t\tif (typeof permissionPresetFlag === \"string\" && !cliPreset) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid --permission-preset \"${permissionPresetFlag}\". Expected one of: full-access, workspace, read-only, ask.`,\n\t\t\t);\n\t\t}\n\n\t\tconst loadedSettings = loadPermissionSettings(settingsManager, cliRuleset, ctx.cwd, cliPreset);\n\t\tstaticRuleset = loadedSettings.staticRuleset;\n\t\tconst approved = loadedSettings.approved;\n\t\tparserRegistry = createBuiltinParserRegistry();\n\t\tservice = new PermissionService(staticRuleset, approved, createEventEmitter(pi));\n\t\tinitialApprovedCount = approved.length;\n\n\t\tconst allTools = pi.getAllTools().map((tool) => tool.name);\n\t\tconst disabledTools = disabled(allTools, staticRuleset);\n\t\tconst activeTools = pi.getActiveTools().filter((toolName) => !disabledTools.has(toolName));\n\t\tpi.setActiveTools(activeTools);\n\t});\n\n\tpi.on(\"tool_call\", async (event, ctx) => {\n\t\tif (!service || !parserRegistry) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst permissionRequests = parserRegistry.parse(event.toolName, event.input, ctx.cwd);\n\t\tconst sessionID = ctx.sessionManager.getSessionId();\n\n\t\tfor (const permissionRequest of permissionRequests) {\n\t\t\tconst request: Request = {\n\t\t\t\tid: nextRequestID(),\n\t\t\t\tsessionID,\n\t\t\t\tpermission: permissionRequest.permission,\n\t\t\t\tpatterns: permissionRequest.patterns,\n\t\t\t\talways: permissionRequest.always,\n\t\t\t\tmetadata: createRequestMetadata(event.toolName, event.input),\n\t\t\t};\n\n\t\t\tconst askPromise = service.ask(request);\n\t\t\tconst isPending = service.list().some((pendingRequest) => pendingRequest.id === request.id);\n\n\t\t\tif (!isPending) {\n\t\t\t\ttry {\n\t\t\t\t\tawait askPromise;\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn { block: true, reason: getReason(error) };\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ctx.hasUI) {\n\t\t\t\tconst reply = await showPermissionPrompt(ctx, request);\n\t\t\t\tservice.reply(reply);\n\t\t\t} else {\n\t\t\t\tconst reply = handleNoUI(request, staticRuleset, cliRuleset, (eventName, data) => {\n\t\t\t\t\tif (eventName !== \"permission_asked\") {\n\t\t\t\t\t\tpi.events.emit(eventName, data);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (reply) {\n\t\t\t\t\tservice.reply(reply);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tawait askPromise;\n\t\t\t} catch (error) {\n\t\t\t\treturn { block: true, reason: getReason(error) };\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t});\n\n\tpi.on(\"session_shutdown\", async (event, ctx) => {\n\t\tvoid event;\n\n\t\tif (!service) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst approved = service.getApproved().slice(initialApprovedCount);\n\t\tif (approved.length > 0) {\n\t\t\tappendApproved(ctx.cwd, approved);\n\t\t}\n\n\t\tfor (const pendingRequest of service.list()) {\n\t\t\tservice.reply({ requestID: pendingRequest.id, reply: \"reject\" });\n\t\t}\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/permission-system/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAuB,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAA8B,MAAM,YAAY,CAAC;AAEpG,SAAS,sBAAsB;IAC9B,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,OAAO,GAAG,EAAE;QACX,OAAO,IAAI,CAAC,CAAC;QAC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J,CAAC","sourcesContent":["import { SettingsManager } from \"../../../settings-manager.ts\";\nimport type { ExtensionAPI } from \"../../types.ts\";\nimport { extractPatchedPaths } from \"../gpt-apply-patch/index.ts\";\nimport { parsePermissionFlag, parsePermissionPresetFlag } from \"./cli.ts\";\nimport { disabled } from \"./config.ts\";\nimport { createEventEmitter } from \"./events.ts\";\nimport { handleNoUI } from \"./non-interactive.ts\";\nimport { createBuiltinParserRegistry, type ParserRegistry } from \"./parsers.ts\";\nimport { showPermissionPrompt } from \"./prompt.ts\";\nimport { PermissionService } from \"./service.ts\";\nimport { loadPermissionSettings } from \"./settings.ts\";\nimport { appendApproved } from \"./storage.ts\";\nimport { CorrectedError, DeniedError, RejectedError, type Request, type Ruleset } from \"./types.ts\";\n\nfunction createRequestIDFactory(): () => string {\n\tlet counter = 0;\n\treturn () => {\n\t\tcounter += 1;\n\t\treturn `permission-${counter}`;\n\t};\n}\n\nfunction getReason(error: unknown): string {\n\tif (error instanceof DeniedError || error instanceof CorrectedError || error instanceof RejectedError) {\n\t\treturn error.message;\n\t}\n\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\n\treturn \"Permission request was rejected.\";\n}\n\nfunction createRequestMetadata(toolName: string, input: Record<string, unknown>): Record<string, unknown> {\n\tconst metadata: Record<string, unknown> = {\n\t\ttoolName,\n\t\t...input,\n\t};\n\n\tconst pathValue = typeof input.path === \"string\" ? input.path : undefined;\n\tconst filePathValue = typeof input.file_path === \"string\" ? input.file_path : undefined;\n\tconst patchTextValue =\n\t\ttypeof input.input === \"string\" ? input.input : typeof input.patchText === \"string\" ? input.patchText : undefined;\n\n\tif (toolName === \"edit\" || toolName === \"write\" || toolName === \"apply_patch\" || toolName === \"multiedit\") {\n\t\tmetadata.filepath = pathValue ?? filePathValue ?? extractPatchedPaths(patchTextValue ?? \"\")[0];\n\t}\n\n\tif (toolName === \"read\") {\n\t\tmetadata.filePath = pathValue ?? filePathValue;\n\t}\n\n\treturn metadata;\n}\n\nexport default function permissionSystemExtension(pi: ExtensionAPI): void {\n\tlet service: PermissionService | null = null;\n\tlet parserRegistry: ParserRegistry | null = null;\n\tlet cliRuleset: Ruleset = [];\n\tlet staticRuleset: Ruleset = [];\n\tlet initialApprovedCount = 0;\n\n\tconst nextRequestID = createRequestIDFactory();\n\n\tpi.registerFlag(\"permission\", {\n\t\tdescription: \"Set permission rules (format: tool=action or tool:pattern=action)\",\n\t\ttype: \"string\",\n\t});\n\tpi.registerFlag(\"permission-preset\", {\n\t\tdescription: \"Set permission preset (full-access, workspace, read-only, or ask)\",\n\t\ttype: \"string\",\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd);\n\t\tconst permissionFlag = pi.getFlag(\"permission\");\n\t\tconst permissionPresetFlag = pi.getFlag(\"permission-preset\");\n\t\tcliRuleset = typeof permissionFlag === \"string\" ? parsePermissionFlag(permissionFlag) : [];\n\t\tconst cliPreset =\n\t\t\ttypeof permissionPresetFlag === \"string\" ? parsePermissionPresetFlag(permissionPresetFlag) : undefined;\n\n\t\tif (typeof permissionPresetFlag === \"string\" && !cliPreset) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid --permission-preset \"${permissionPresetFlag}\". Expected one of: full-access, workspace, read-only, ask.`,\n\t\t\t);\n\t\t}\n\n\t\tconst loadedSettings = loadPermissionSettings(settingsManager, cliRuleset, ctx.cwd, cliPreset);\n\t\tstaticRuleset = loadedSettings.staticRuleset;\n\t\tconst approved = loadedSettings.approved;\n\t\tparserRegistry = createBuiltinParserRegistry();\n\t\tservice = new PermissionService(staticRuleset, approved, createEventEmitter(pi));\n\t\tinitialApprovedCount = approved.length;\n\n\t\tconst allTools = pi.getAllTools().map((tool) => tool.name);\n\t\tconst disabledTools = disabled(allTools, staticRuleset);\n\t\tconst activeTools = pi.getActiveTools().filter((toolName) => !disabledTools.has(toolName));\n\t\tpi.setActiveTools(activeTools);\n\t});\n\n\tpi.on(\"tool_call\", async (event, ctx) => {\n\t\tif (!service || !parserRegistry) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst permissionRequests = parserRegistry.parse(event.toolName, event.input, ctx.cwd);\n\t\tconst sessionID = ctx.sessionManager.getSessionId();\n\n\t\tfor (const permissionRequest of permissionRequests) {\n\t\t\tconst request: Request = {\n\t\t\t\tid: nextRequestID(),\n\t\t\t\tsessionID,\n\t\t\t\tpermission: permissionRequest.permission,\n\t\t\t\tpatterns: permissionRequest.patterns,\n\t\t\t\talways: permissionRequest.always,\n\t\t\t\tmetadata: createRequestMetadata(event.toolName, event.input),\n\t\t\t};\n\n\t\t\tconst askResultPromise = service.ask(request).then(\n\t\t\t\t() => ({ ok: true as const }),\n\t\t\t\t(error: unknown) => ({ ok: false as const, error }),\n\t\t\t);\n\t\t\tconst isPending = service.list().some((pendingRequest) => pendingRequest.id === request.id);\n\n\t\t\tif (!isPending) {\n\t\t\t\tconst askResult = await askResultPromise;\n\t\t\t\tif (!askResult.ok) {\n\t\t\t\t\treturn { block: true, reason: getReason(askResult.error) };\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ctx.hasUI) {\n\t\t\t\tconst reply = await showPermissionPrompt(ctx, request);\n\t\t\t\tservice.reply(reply);\n\t\t\t} else {\n\t\t\t\tconst reply = handleNoUI(request, staticRuleset, cliRuleset, (eventName, data) => {\n\t\t\t\t\tif (eventName !== \"permission_asked\") {\n\t\t\t\t\t\tpi.events.emit(eventName, data);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (reply) {\n\t\t\t\t\tservice.reply(reply);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst askResult = await askResultPromise;\n\t\t\tif (!askResult.ok) {\n\t\t\t\treturn { block: true, reason: getReason(askResult.error) };\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t});\n\n\tpi.on(\"session_shutdown\", async (event, ctx) => {\n\t\tvoid event;\n\n\t\tif (!service) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst approved = service.getApproved().slice(initialApprovedCount);\n\t\tif (approved.length > 0) {\n\t\t\tappendApproved(ctx.cwd, approved);\n\t\t}\n\n\t\tfor (const pendingRequest of service.list()) {\n\t\t\tservice.reply({ requestID: pendingRequest.id, reply: \"reject\" });\n\t\t}\n\t});\n}\n"]}
|
|
@@ -12,6 +12,20 @@
|
|
|
12
12
|
|
|
13
13
|
### Removed
|
|
14
14
|
|
|
15
|
+
## [2026.8.22] - 2026-08-22
|
|
16
|
+
|
|
17
|
+
### Breaking Changes
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Ruby and Julia eval cells now wait for the subprocess `ready` signal before execution timeouts begin, so interpreter startup under load cannot time out a state-setting cell and silently restart the kernel before the next cell runs.
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
|
|
15
29
|
## [2026.8.21-3] - 2026-08-21
|
|
16
30
|
|
|
17
31
|
### Breaking Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-codemode",
|
|
3
|
-
"version": "2026.8.
|
|
3
|
+
"version": "2026.8.22",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Source-only senpi extension package for codemode evaluation tools",
|
|
6
6
|
"type": "module",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/parser": "8.0.4",
|
|
34
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.
|
|
34
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.22",
|
|
35
35
|
"typebox": "1.3.16"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@code-yeongyu/senpi": "2026.8.
|
|
38
|
+
"@code-yeongyu/senpi": "2026.8.22"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@code-yeongyu/senpi": "2026.8.
|
|
41
|
+
"@code-yeongyu/senpi": "2026.8.22"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
44
44
|
"senpi",
|
|
@@ -26,6 +26,7 @@ export class SubprocessKernel {
|
|
|
26
26
|
private readonly onMessage?: (message: KernelToHostMessage) => void;
|
|
27
27
|
private readonly runs = new SubprocessRunQueue();
|
|
28
28
|
private process: SubprocessProcess | null = null;
|
|
29
|
+
private processReady = false;
|
|
29
30
|
private retirementPromise: Promise<void> | null = null;
|
|
30
31
|
private retirementProcess: SubprocessProcess | null = null;
|
|
31
32
|
private retirementFailure: Error | null = null;
|
|
@@ -109,7 +110,7 @@ export class SubprocessKernel {
|
|
|
109
110
|
|
|
110
111
|
private pumpRuns(): void {
|
|
111
112
|
const process = this.process;
|
|
112
|
-
if (this.closed || this.runs.active || !process || process.isRetiring) return;
|
|
113
|
+
if (this.closed || this.runs.active || !process || process.isRetiring || !this.processReady) return;
|
|
113
114
|
const run = this.runs.startNext(performance.now());
|
|
114
115
|
if (!run) return;
|
|
115
116
|
const timeoutMs = run.input.timeoutMs;
|
|
@@ -142,6 +143,7 @@ export class SubprocessKernel {
|
|
|
142
143
|
},
|
|
143
144
|
});
|
|
144
145
|
this.process = process;
|
|
146
|
+
this.processReady = false;
|
|
145
147
|
try {
|
|
146
148
|
process.send(
|
|
147
149
|
encodeBridgeFrame({ type: "init", sessionId: this.options.sessionId, connection: this.options.connection }),
|
|
@@ -165,6 +167,17 @@ export class SubprocessKernel {
|
|
|
165
167
|
|
|
166
168
|
private handleMessage(process: SubprocessProcess, message: KernelToHostMessage): void {
|
|
167
169
|
if (!this.accepts(process)) return;
|
|
170
|
+
if (message.type === "ready") {
|
|
171
|
+
this.processReady = true;
|
|
172
|
+
this.runs.handleMessage(message, this.onMessage);
|
|
173
|
+
this.pumpRuns();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (message.type === "init-failed") {
|
|
177
|
+
this.runs.handleMessage(message, this.onMessage);
|
|
178
|
+
this.failClosed(new KernelStartupError(message.error.message));
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
168
181
|
if (this.runs.handleMessage(message, this.onMessage)) this.pumpRuns();
|
|
169
182
|
}
|
|
170
183
|
|
|
@@ -176,6 +189,7 @@ export class SubprocessKernel {
|
|
|
176
189
|
return;
|
|
177
190
|
}
|
|
178
191
|
this.process = null;
|
|
192
|
+
this.processReady = false;
|
|
179
193
|
this.failClosed(new KernelExitedError(signal ?? code ?? "unknown"));
|
|
180
194
|
}
|
|
181
195
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@earendil-works/pi-agent-core",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "2026.8.
|
|
4
|
+
"version": "2026.8.22",
|
|
5
5
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"prepublishOnly": "npm run build"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.
|
|
40
|
-
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.8.
|
|
39
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.22",
|
|
40
|
+
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.8.22",
|
|
41
41
|
"diff": "9.0.0",
|
|
42
42
|
"ignore": "7.0.6",
|
|
43
43
|
"typebox": "1.3.16",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type CursorStreamRetryCause = "stall" | "transport" | "clean-end";
|
|
2
|
+
export declare class CursorRetryableStreamError extends Error {
|
|
3
|
+
readonly retryCause: CursorStreamRetryCause;
|
|
4
|
+
constructor(message: string, retryCause: CursorStreamRetryCause, options?: ErrorOptions);
|
|
5
|
+
}
|
|
6
|
+
export declare function isCursorRetryableStreamError(error: unknown): error is CursorRetryableStreamError;
|
|
7
|
+
export declare function cursorStreamRetryDelayMs(options: {
|
|
8
|
+
attempt: number;
|
|
9
|
+
baseDelayMs?: number;
|
|
10
|
+
fixedDelayMs?: number;
|
|
11
|
+
random?: () => number;
|
|
12
|
+
}): number;
|
|
13
|
+
export declare function shouldRetryCursorStream(options: {
|
|
14
|
+
error: unknown;
|
|
15
|
+
retries: number;
|
|
16
|
+
maxRetries: number;
|
|
17
|
+
sawTurnEnded: boolean;
|
|
18
|
+
aborted: boolean;
|
|
19
|
+
}): boolean;
|
|
20
|
+
export declare function waitForCursorStreamRetry(delayMs: number, signal?: AbortSignal): Promise<void>;
|
|
21
|
+
//# sourceMappingURL=stream-retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-retry.d.ts","sourceRoot":"","sources":["../../../src/api/cursor-agent/stream-retry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;AAEzE,qBAAa,0BAA2B,SAAQ,KAAK;IACpD,QAAQ,CAAC,UAAU,EAAE,sBAAsB,CAAC;gBAEhC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,YAAY;CAKvF;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,0BAA0B,CAEhG;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACtB,GAAG,MAAM,CAMT;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAChD,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CACjB,GAAG,OAAO,CAOV;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAanG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class CursorRetryableStreamError extends Error {
|
|
2
|
+
constructor(message, retryCause, options) {
|
|
3
|
+
super(message, options);
|
|
4
|
+
this.name = "CursorRetryableStreamError";
|
|
5
|
+
this.retryCause = retryCause;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export function isCursorRetryableStreamError(error) {
|
|
9
|
+
return error instanceof CursorRetryableStreamError;
|
|
10
|
+
}
|
|
11
|
+
export function cursorStreamRetryDelayMs(options) {
|
|
12
|
+
if (options.fixedDelayMs !== undefined)
|
|
13
|
+
return Math.max(0, options.fixedDelayMs);
|
|
14
|
+
const baseDelayMs = options.baseDelayMs ?? 1000;
|
|
15
|
+
const backoffMs = Math.min(baseDelayMs * 2 ** options.attempt, 60_000);
|
|
16
|
+
const jitter = Math.floor(backoffMs * 0.2 * (options.random ?? Math.random)());
|
|
17
|
+
return backoffMs + jitter;
|
|
18
|
+
}
|
|
19
|
+
export function shouldRetryCursorStream(options) {
|
|
20
|
+
return (!options.sawTurnEnded &&
|
|
21
|
+
!options.aborted &&
|
|
22
|
+
options.retries < options.maxRetries &&
|
|
23
|
+
isCursorRetryableStreamError(options.error));
|
|
24
|
+
}
|
|
25
|
+
export async function waitForCursorStreamRetry(delayMs, signal) {
|
|
26
|
+
if (delayMs <= 0 || signal?.aborted)
|
|
27
|
+
return;
|
|
28
|
+
await new Promise((resolve) => {
|
|
29
|
+
const timer = setTimeout(resolve, delayMs);
|
|
30
|
+
signal?.addEventListener("abort", () => {
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
resolve();
|
|
33
|
+
}, { once: true });
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=stream-retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-retry.js","sourceRoot":"","sources":["../../../src/api/cursor-agent/stream-retry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAGpD,YAAY,OAAe,EAAE,UAAkC,EAAE,OAAsB;QACtF,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAc;IAC1D,OAAO,KAAK,YAAY,0BAA0B,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAKxC;IACA,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACjF,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/E,OAAO,SAAS,GAAG,MAAM,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAMvC;IACA,OAAO,CACN,CAAC,OAAO,CAAC,YAAY;QACrB,CAAC,OAAO,CAAC,OAAO;QAChB,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,UAAU;QACpC,4BAA4B,CAAC,OAAO,CAAC,KAAK,CAAC,CAC3C,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,OAAe,EAAE,MAAoB;IACnF,IAAI,OAAO,IAAI,CAAC,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO;IAC5C,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3C,MAAM,EAAE,gBAAgB,CACvB,OAAO,EACP,GAAG,EAAE;YACJ,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,EAAE,CAAC;QACX,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACd,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["export type CursorStreamRetryCause = \"stall\" | \"transport\" | \"clean-end\";\n\nexport class CursorRetryableStreamError extends Error {\n\treadonly retryCause: CursorStreamRetryCause;\n\n\tconstructor(message: string, retryCause: CursorStreamRetryCause, options?: ErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.name = \"CursorRetryableStreamError\";\n\t\tthis.retryCause = retryCause;\n\t}\n}\n\nexport function isCursorRetryableStreamError(error: unknown): error is CursorRetryableStreamError {\n\treturn error instanceof CursorRetryableStreamError;\n}\n\nexport function cursorStreamRetryDelayMs(options: {\n\tattempt: number;\n\tbaseDelayMs?: number;\n\tfixedDelayMs?: number;\n\trandom?: () => number;\n}): number {\n\tif (options.fixedDelayMs !== undefined) return Math.max(0, options.fixedDelayMs);\n\tconst baseDelayMs = options.baseDelayMs ?? 1000;\n\tconst backoffMs = Math.min(baseDelayMs * 2 ** options.attempt, 60_000);\n\tconst jitter = Math.floor(backoffMs * 0.2 * (options.random ?? Math.random)());\n\treturn backoffMs + jitter;\n}\n\nexport function shouldRetryCursorStream(options: {\n\terror: unknown;\n\tretries: number;\n\tmaxRetries: number;\n\tsawTurnEnded: boolean;\n\taborted: boolean;\n}): boolean {\n\treturn (\n\t\t!options.sawTurnEnded &&\n\t\t!options.aborted &&\n\t\toptions.retries < options.maxRetries &&\n\t\tisCursorRetryableStreamError(options.error)\n\t);\n}\n\nexport async function waitForCursorStreamRetry(delayMs: number, signal?: AbortSignal): Promise<void> {\n\tif (delayMs <= 0 || signal?.aborted) return;\n\tawait new Promise<void>((resolve) => {\n\t\tconst timer = setTimeout(resolve, delayMs);\n\t\tsignal?.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t});\n}\n"]}
|
|
@@ -120,7 +120,12 @@ export interface CursorAgentOptions extends StreamOptions {
|
|
|
120
120
|
thinkingSelection?: ThinkingSelection;
|
|
121
121
|
/** Override stream health bounds for deterministic provider integration tests. */
|
|
122
122
|
streamHealthFailThresholdMs?: number;
|
|
123
|
+
/** @deprecated Accepted for compatibility; heartbeat/checkpoint frames are always liveness. */
|
|
123
124
|
streamHealthHeartbeatOnlyThresholdMs?: number;
|
|
125
|
+
/** Maximum pre-completion stall/transport retries (default 10). */
|
|
126
|
+
streamStallMaxRetries?: number;
|
|
127
|
+
/** Fixed retry delay for tests; production uses exponential backoff plus jitter. */
|
|
128
|
+
streamStallRetryDelayMs?: number;
|
|
124
129
|
/** Override the post-turn exec drain bound for deterministic tests. */
|
|
125
130
|
turnEndDrainTimeoutMs?: number;
|
|
126
131
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/cursor-agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,KAAK,EACX,UAAU,EACV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EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,OAAO,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC,CAAC;IAC9F,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACvC;AAED,yDAAyD;AACzD,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACxD,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wFAAwF;IACxF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,sEAAsE;IACtE,YAAY,CAAC,EAAE,uBAAuB,CAAC;IACvC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,kFAAkF;IAClF,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,+FAA+F;IAC/F,oCAAoC,CAAC,EAAE,MAAM,CAAC;IAC9C,mEAAmE;IACnE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,oFAAoF;IACpF,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,uEAAuE;IACvE,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/cursor-agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG","sourcesContent":["/**\n * Cursor exec-channel handler contracts.\n *\n * The Cursor agent protocol is server-driven: mid-turn, the server sends\n * `ExecServerMessage` frames asking the CLIENT to run a tool and blocks until\n * the reply arrives on the same stream. The host (coding-agent) supplies\n * these handlers; the `cursor-agent` API dispatches frames onto them, sends\n * their protobuf answers back on the wire, synthesizes already-resolved\n * `toolCall` blocks into the assistant message, and pairs each with a\n * `ToolResultMessage` delivered through {@link CursorToolResultHandler}.\n *\n * Everything here is type-only over the generated protobuf shapes, so it is\n * safe to import from browser-reachable modules.\n */\n\nimport type { StreamOptions, ThinkingSelection, ToolResultMessage } from \"../../types.ts\";\nimport type {\n\tDeleteArgs,\n\tDeleteResult,\n\tDiagnosticsArgs,\n\tDiagnosticsResult,\n\tGrepArgs,\n\tGrepResult,\n\tLsArgs,\n\tLsResult,\n\tMcpResult,\n\tPiBashExecArgs,\n\tPiBashExecResult,\n\tPiEditExecArgs,\n\tPiEditExecResult,\n\tPiFindExecArgs,\n\tPiFindExecResult,\n\tPiGrepExecArgs,\n\tPiGrepExecResult,\n\tPiLsExecArgs,\n\tPiLsExecResult,\n\tPiReadExecArgs,\n\tPiReadExecResult,\n\tPiWriteExecArgs,\n\tPiWriteExecResult,\n\tReadArgs,\n\tReadResult,\n\tShellArgs,\n\tShellResult,\n\tWriteArgs,\n\tWriteResult,\n} from \"./gen/agent_pb.ts\";\n\n/**\n * The three return forms an exec handler may use: a wire result with an\n * optional transcript pairing, a bare wire result, or a bare\n * `ToolResultMessage` from which the wire result is derived.\n */\nexport type CursorExecHandlerResult<T> = { result: T; toolResult?: ToolResultMessage } | T | ToolResultMessage;\n\n/**\n * Optional rewrite of a Cursor exec-channel tool result.\n * May return a Promise. Returning `undefined` keeps the original result.\n */\nexport type CursorToolResultHandler = (\n\tresult: ToolResultMessage,\n) => ToolResultMessage | undefined | Promise<ToolResultMessage | undefined>;\n\n/**\n * Identifies the synthesized assistant block a Cursor exec call was filed\n * under, so paths that produce no handler `toolResult` can still pair one.\n */\nexport interface CursorExecPairing {\n\ttoolCallId: string;\n\ttoolName: string;\n}\n\nexport interface CursorMcpCall {\n\tname: string;\n\tproviderIdentifier: string;\n\ttoolName: string;\n\ttoolCallId: string;\n\targs: Record<string, unknown>;\n\trawArgs: Record<string, Uint8Array>;\n\t/**\n\t * The frame asks only whether this call would be permitted — it must not\n\t * run. The server sends it to resolve a smart-mode approval decision ahead\n\t * of the real invocation; executing here would fire a side-effecting tool\n\t * the user has not yet been asked about (and fire it twice once the real\n\t * call arrives).\n\t */\n\tapprovalOnly?: boolean;\n}\n\nexport interface CursorShellStreamCallbacks {\n\tonStdout(data: string): void;\n\tonStderr(data: string): void;\n}\n\n/**\n * A modern Pi exec frame plus the call id the dispatcher minted for it.\n *\n * Unlike the legacy exec args (`ReadArgs`, `ShellArgs`, ...), the Pi frames\n * carry no `tool_call_id` field: the id rides the streamed `ToolCall`\n * envelope instead. The exec channel has no access to that envelope, so the\n * dispatcher mints an id and hands it to the handler, keeping the synthesized\n * transcript block and its paired `toolResult` on the same key.\n */\nexport interface CursorPiCall<TArgs> {\n\targs: TArgs;\n\ttoolCallId: string;\n}\n\nexport interface CursorExecHandlers {\n\tread?: (args: ReadArgs) => Promise<CursorExecHandlerResult<ReadResult>>;\n\tls?: (args: LsArgs) => Promise<CursorExecHandlerResult<LsResult>>;\n\tgrep?: (args: GrepArgs) => Promise<CursorExecHandlerResult<GrepResult>>;\n\twrite?: (args: WriteArgs) => Promise<CursorExecHandlerResult<WriteResult>>;\n\tdelete?: (args: DeleteArgs) => Promise<CursorExecHandlerResult<DeleteResult>>;\n\tshell?: (args: ShellArgs) => Promise<CursorExecHandlerResult<ShellResult>>;\n\tshellStream?: (\n\t\targs: ShellArgs,\n\t\tcallbacks: CursorShellStreamCallbacks,\n\t) => Promise<CursorExecHandlerResult<ShellResult>>;\n\tdiagnostics?: (args: DiagnosticsArgs) => Promise<CursorExecHandlerResult<DiagnosticsResult>>;\n\tmcp?: (call: CursorMcpCall) => Promise<CursorExecHandlerResult<McpResult>>;\n\t/**\n\t * Answers \"would this MCP call be permitted\", without running it.\n\t *\n\t * `true` only when the host's policy resolves to a definite allow. A\n\t * pending prompt is `false`: it can only be answered interactively at\n\t * execution time. When no handler is registered the provider refuses,\n\t * since it cannot decide.\n\t */\n\tmcpApprovalPreflight?: (call: CursorMcpCall) => Promise<boolean>;\n\t/**\n\t * Modern Cursor CLI Pi tool frames (`ExecServerMessage` 45-51). They are a\n\t * distinct frame family from the legacy `readArgs`/`shellArgs`/... set:\n\t * different args, different result oneofs, and no `tool_call_id`.\n\t */\n\tpiRead?: (call: CursorPiCall<PiReadExecArgs>) => Promise<CursorExecHandlerResult<PiReadExecResult>>;\n\tpiBash?: (call: CursorPiCall<PiBashExecArgs>) => Promise<CursorExecHandlerResult<PiBashExecResult>>;\n\tpiEdit?: (call: CursorPiCall<PiEditExecArgs>) => Promise<CursorExecHandlerResult<PiEditExecResult>>;\n\tpiWrite?: (call: CursorPiCall<PiWriteExecArgs>) => Promise<CursorExecHandlerResult<PiWriteExecResult>>;\n\tpiGrep?: (call: CursorPiCall<PiGrepExecArgs>) => Promise<CursorExecHandlerResult<PiGrepExecResult>>;\n\tpiFind?: (call: CursorPiCall<PiFindExecArgs>) => Promise<CursorExecHandlerResult<PiFindExecResult>>;\n\tpiLs?: (call: CursorPiCall<PiLsExecArgs>) => Promise<CursorExecHandlerResult<PiLsExecResult>>;\n\tonToolResult?: CursorToolResultHandler;\n}\n\n/** Stream options accepted by the `cursor-agent` API. */\nexport interface CursorAgentOptions extends StreamOptions {\n\t/** Optional server-side system prompt override (RunRequest.customSystemPrompt). */\n\tcustomSystemPrompt?: string;\n\t/** Conversation id override; defaults to `sessionId`, else a random UUID per stream. */\n\tconversationId?: string;\n\t/** Cursor exec/MCP tool handlers supplied by the host. */\n\texecHandlers?: CursorExecHandlers;\n\t/** Receives every exec-channel tool result for transcript pairing. */\n\tonToolResult?: CursorToolResultHandler;\n\t/**\n\t * Provenance-bearing thinking selection rendered into\n\t * `RequestedModel.parameters`; absent selections keep the representative\n\t * variant request shape.\n\t */\n\tthinkingSelection?: ThinkingSelection;\n\t/** Override stream health bounds for deterministic provider integration tests. */\n\tstreamHealthFailThresholdMs?: number;\n\tstreamHealthHeartbeatOnlyThresholdMs?: number;\n\t/** Override the post-turn exec drain bound for deterministic tests. */\n\tturnEndDrainTimeoutMs?: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/cursor-agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG","sourcesContent":["/**\n * Cursor exec-channel handler contracts.\n *\n * The Cursor agent protocol is server-driven: mid-turn, the server sends\n * `ExecServerMessage` frames asking the CLIENT to run a tool and blocks until\n * the reply arrives on the same stream. The host (coding-agent) supplies\n * these handlers; the `cursor-agent` API dispatches frames onto them, sends\n * their protobuf answers back on the wire, synthesizes already-resolved\n * `toolCall` blocks into the assistant message, and pairs each with a\n * `ToolResultMessage` delivered through {@link CursorToolResultHandler}.\n *\n * Everything here is type-only over the generated protobuf shapes, so it is\n * safe to import from browser-reachable modules.\n */\n\nimport type { StreamOptions, ThinkingSelection, ToolResultMessage } from \"../../types.ts\";\nimport type {\n\tDeleteArgs,\n\tDeleteResult,\n\tDiagnosticsArgs,\n\tDiagnosticsResult,\n\tGrepArgs,\n\tGrepResult,\n\tLsArgs,\n\tLsResult,\n\tMcpResult,\n\tPiBashExecArgs,\n\tPiBashExecResult,\n\tPiEditExecArgs,\n\tPiEditExecResult,\n\tPiFindExecArgs,\n\tPiFindExecResult,\n\tPiGrepExecArgs,\n\tPiGrepExecResult,\n\tPiLsExecArgs,\n\tPiLsExecResult,\n\tPiReadExecArgs,\n\tPiReadExecResult,\n\tPiWriteExecArgs,\n\tPiWriteExecResult,\n\tReadArgs,\n\tReadResult,\n\tShellArgs,\n\tShellResult,\n\tWriteArgs,\n\tWriteResult,\n} from \"./gen/agent_pb.ts\";\n\n/**\n * The three return forms an exec handler may use: a wire result with an\n * optional transcript pairing, a bare wire result, or a bare\n * `ToolResultMessage` from which the wire result is derived.\n */\nexport type CursorExecHandlerResult<T> = { result: T; toolResult?: ToolResultMessage } | T | ToolResultMessage;\n\n/**\n * Optional rewrite of a Cursor exec-channel tool result.\n * May return a Promise. Returning `undefined` keeps the original result.\n */\nexport type CursorToolResultHandler = (\n\tresult: ToolResultMessage,\n) => ToolResultMessage | undefined | Promise<ToolResultMessage | undefined>;\n\n/**\n * Identifies the synthesized assistant block a Cursor exec call was filed\n * under, so paths that produce no handler `toolResult` can still pair one.\n */\nexport interface CursorExecPairing {\n\ttoolCallId: string;\n\ttoolName: string;\n}\n\nexport interface CursorMcpCall {\n\tname: string;\n\tproviderIdentifier: string;\n\ttoolName: string;\n\ttoolCallId: string;\n\targs: Record<string, unknown>;\n\trawArgs: Record<string, Uint8Array>;\n\t/**\n\t * The frame asks only whether this call would be permitted — it must not\n\t * run. The server sends it to resolve a smart-mode approval decision ahead\n\t * of the real invocation; executing here would fire a side-effecting tool\n\t * the user has not yet been asked about (and fire it twice once the real\n\t * call arrives).\n\t */\n\tapprovalOnly?: boolean;\n}\n\nexport interface CursorShellStreamCallbacks {\n\tonStdout(data: string): void;\n\tonStderr(data: string): void;\n}\n\n/**\n * A modern Pi exec frame plus the call id the dispatcher minted for it.\n *\n * Unlike the legacy exec args (`ReadArgs`, `ShellArgs`, ...), the Pi frames\n * carry no `tool_call_id` field: the id rides the streamed `ToolCall`\n * envelope instead. The exec channel has no access to that envelope, so the\n * dispatcher mints an id and hands it to the handler, keeping the synthesized\n * transcript block and its paired `toolResult` on the same key.\n */\nexport interface CursorPiCall<TArgs> {\n\targs: TArgs;\n\ttoolCallId: string;\n}\n\nexport interface CursorExecHandlers {\n\tread?: (args: ReadArgs) => Promise<CursorExecHandlerResult<ReadResult>>;\n\tls?: (args: LsArgs) => Promise<CursorExecHandlerResult<LsResult>>;\n\tgrep?: (args: GrepArgs) => Promise<CursorExecHandlerResult<GrepResult>>;\n\twrite?: (args: WriteArgs) => Promise<CursorExecHandlerResult<WriteResult>>;\n\tdelete?: (args: DeleteArgs) => Promise<CursorExecHandlerResult<DeleteResult>>;\n\tshell?: (args: ShellArgs) => Promise<CursorExecHandlerResult<ShellResult>>;\n\tshellStream?: (\n\t\targs: ShellArgs,\n\t\tcallbacks: CursorShellStreamCallbacks,\n\t) => Promise<CursorExecHandlerResult<ShellResult>>;\n\tdiagnostics?: (args: DiagnosticsArgs) => Promise<CursorExecHandlerResult<DiagnosticsResult>>;\n\tmcp?: (call: CursorMcpCall) => Promise<CursorExecHandlerResult<McpResult>>;\n\t/**\n\t * Answers \"would this MCP call be permitted\", without running it.\n\t *\n\t * `true` only when the host's policy resolves to a definite allow. A\n\t * pending prompt is `false`: it can only be answered interactively at\n\t * execution time. When no handler is registered the provider refuses,\n\t * since it cannot decide.\n\t */\n\tmcpApprovalPreflight?: (call: CursorMcpCall) => Promise<boolean>;\n\t/**\n\t * Modern Cursor CLI Pi tool frames (`ExecServerMessage` 45-51). They are a\n\t * distinct frame family from the legacy `readArgs`/`shellArgs`/... set:\n\t * different args, different result oneofs, and no `tool_call_id`.\n\t */\n\tpiRead?: (call: CursorPiCall<PiReadExecArgs>) => Promise<CursorExecHandlerResult<PiReadExecResult>>;\n\tpiBash?: (call: CursorPiCall<PiBashExecArgs>) => Promise<CursorExecHandlerResult<PiBashExecResult>>;\n\tpiEdit?: (call: CursorPiCall<PiEditExecArgs>) => Promise<CursorExecHandlerResult<PiEditExecResult>>;\n\tpiWrite?: (call: CursorPiCall<PiWriteExecArgs>) => Promise<CursorExecHandlerResult<PiWriteExecResult>>;\n\tpiGrep?: (call: CursorPiCall<PiGrepExecArgs>) => Promise<CursorExecHandlerResult<PiGrepExecResult>>;\n\tpiFind?: (call: CursorPiCall<PiFindExecArgs>) => Promise<CursorExecHandlerResult<PiFindExecResult>>;\n\tpiLs?: (call: CursorPiCall<PiLsExecArgs>) => Promise<CursorExecHandlerResult<PiLsExecResult>>;\n\tonToolResult?: CursorToolResultHandler;\n}\n\n/** Stream options accepted by the `cursor-agent` API. */\nexport interface CursorAgentOptions extends StreamOptions {\n\t/** Optional server-side system prompt override (RunRequest.customSystemPrompt). */\n\tcustomSystemPrompt?: string;\n\t/** Conversation id override; defaults to `sessionId`, else a random UUID per stream. */\n\tconversationId?: string;\n\t/** Cursor exec/MCP tool handlers supplied by the host. */\n\texecHandlers?: CursorExecHandlers;\n\t/** Receives every exec-channel tool result for transcript pairing. */\n\tonToolResult?: CursorToolResultHandler;\n\t/**\n\t * Provenance-bearing thinking selection rendered into\n\t * `RequestedModel.parameters`; absent selections keep the representative\n\t * variant request shape.\n\t */\n\tthinkingSelection?: ThinkingSelection;\n\t/** Override stream health bounds for deterministic provider integration tests. */\n\tstreamHealthFailThresholdMs?: number;\n\t/** @deprecated Accepted for compatibility; heartbeat/checkpoint frames are always liveness. */\n\tstreamHealthHeartbeatOnlyThresholdMs?: number;\n\t/** Maximum pre-completion stall/transport retries (default 10). */\n\tstreamStallMaxRetries?: number;\n\t/** Fixed retry delay for tests; production uses exponential backoff plus jitter. */\n\tstreamStallRetryDelayMs?: number;\n\t/** Override the post-turn exec drain bound for deterministic tests. */\n\tturnEndDrainTimeoutMs?: number;\n}\n"]}
|
|
@@ -26,7 +26,7 @@ export declare const CURSOR_API_URL = "https://api2.cursor.sh";
|
|
|
26
26
|
export declare const CURSOR_CLIENT_VERSION = "cli-2026.07.23-e383d2b";
|
|
27
27
|
/** Maximum inbound silence before a Cursor turn without turnEnded is failed. */
|
|
28
28
|
export declare const CURSOR_STREAM_HEALTH_FAIL_THRESHOLD_MS = 30000;
|
|
29
|
-
/**
|
|
29
|
+
/** @deprecated Heartbeats and checkpoints count as inbound liveness without a separate deadline. */
|
|
30
30
|
export declare const CURSOR_STREAM_HEALTH_HEARTBEAT_ONLY_THRESHOLD_MS: number;
|
|
31
31
|
/** Maximum time allowed to drain exec handlers after turnEnded. */
|
|
32
32
|
export declare const CURSOR_TURN_END_DRAIN_TIMEOUT_MS = 5000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor-agent.d.ts","sourceRoot":"","sources":["../../src/api/cursor-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAIpC,OAAO,KAAK,EAEX,gBAAgB,EAGhB,OAAO,EAEP,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,eAAe,EACf,IAAI,EACJ,QAAQ,EACR,iBAAiB,EACjB,MAAM,aAAa,CAAC;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