@bastani/atomic 0.9.4-alpha.5 → 0.9.4-alpha.7
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 +55 -0
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +4 -4
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/package.json +4 -4
- package/dist/builtin/subagents/CHANGELOG.md +20 -0
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +11 -1
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +11 -1
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +27 -4
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +25 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +3 -1
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +22 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +15 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +5 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +4 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +4 -1
- package/dist/builtin/subagents/src/runs/shared/attempt-watchdog.ts +126 -0
- package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +53 -0
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +52 -53
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +2 -0
- package/dist/builtin/subagents/src/shared/model-info.ts +16 -0
- package/dist/builtin/subagents/src/shared/types-config.ts +2 -0
- package/dist/builtin/web-access/CHANGELOG.md +6 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +12 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +34 -4
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +13 -25
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -0
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +11 -3
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -1
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +11 -4
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +2 -2
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts +7 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +26 -4
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +3 -1
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/copilot-model-catalog.d.ts +25 -74
- package/dist/core/copilot-model-catalog.d.ts.map +1 -1
- package/dist/core/copilot-model-catalog.js +118 -68
- package/dist/core/copilot-model-catalog.js.map +1 -1
- package/dist/core/copilot-model-synthesis.d.ts +10 -0
- package/dist/core/copilot-model-synthesis.d.ts.map +1 -0
- package/dist/core/copilot-model-synthesis.js +89 -0
- package/dist/core/copilot-model-synthesis.js.map +1 -0
- package/dist/core/extensions/api-types.d.ts +2 -1
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +3 -3
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/session-events.d.ts +7 -1
- package/dist/core/extensions/session-events.d.ts.map +1 -1
- package/dist/core/extensions/session-events.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +28 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +21 -3
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +2 -1
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +2 -12
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +8 -16
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/settings-manager-resource-accessors.d.ts +1 -0
- package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-resource-accessors.js +11 -0
- package/dist/core/settings-manager-resource-accessors.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts +2 -0
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +9 -0
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +2 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/timings.d.ts +7 -5
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +42 -24
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/read-selectors.d.ts.map +1 -1
- package/dist/core/tools/read-selectors.js +19 -1
- package/dist/core/tools/read-selectors.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +12 -23
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +14 -5
- package/dist/main-session.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +22 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +5 -5
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +1 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +6 -2
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +16 -5
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +1 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +1 -0
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +1 -0
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +2 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +1 -0
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +4 -3
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +28 -51
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +27 -51
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +19 -0
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +26 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +12 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/image-convert.d.ts +1 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +21 -15
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +41 -0
- package/dist/utils/mime.js.map +1 -1
- package/docs/extensions.md +11 -0
- package/docs/models.md +3 -3
- package/docs/providers.md +1 -1
- package/docs/rpc.md +60 -2
- package/docs/sdk.md +1 -1
- package/docs/settings.md +4 -1
- package/docs/subagents.md +6 -0
- package/docs/workflows.md +2 -0
- package/npm-shrinkwrap.json +138 -140
- package/package.json +15 -10
|
@@ -51,6 +51,7 @@ export type ModelFallbackFailureKind =
|
|
|
51
51
|
| "network_timeout"
|
|
52
52
|
| "transport_error"
|
|
53
53
|
| "model_unavailable"
|
|
54
|
+
| "request_incompatible"
|
|
54
55
|
| "cancelled"
|
|
55
56
|
| "task_failure"
|
|
56
57
|
| "unknown";
|
|
@@ -79,6 +80,7 @@ const FALLBACKABLE_FAILURE_KINDS: ReadonlySet<ModelFallbackFailureKind> = new Se
|
|
|
79
80
|
"network_timeout",
|
|
80
81
|
"transport_error",
|
|
81
82
|
"model_unavailable",
|
|
83
|
+
"request_incompatible",
|
|
82
84
|
]);
|
|
83
85
|
|
|
84
86
|
function asRecord(value: unknown): Record<string, unknown> | undefined {
|
|
@@ -157,6 +159,9 @@ function normalizeCode(value: string | number | undefined): string | undefined {
|
|
|
157
159
|
|
|
158
160
|
function kindFromStatus(status: number | undefined): ModelFallbackFailureKind | undefined {
|
|
159
161
|
switch (status) {
|
|
162
|
+
case 400:
|
|
163
|
+
case 413: case 422:
|
|
164
|
+
return "request_incompatible";
|
|
160
165
|
case 401:
|
|
161
166
|
case 403:
|
|
162
167
|
return "auth_on_candidate_provider";
|
|
@@ -193,6 +198,15 @@ function refusalKindFromCode(code: string | number | undefined): ModelFallbackFa
|
|
|
193
198
|
}
|
|
194
199
|
}
|
|
195
200
|
|
|
201
|
+
const REQUEST_INCOMPATIBLE_CODES: ReadonlySet<string> = new Set([
|
|
202
|
+
"invalid_request", "invalid_request_error", "bad_request", "context_length_exceeded",
|
|
203
|
+
"request_too_large", "too_large", "request_entity_too_large", "max_tokens",
|
|
204
|
+
"max_context_length", "context_window_exceeded",
|
|
205
|
+
]);
|
|
206
|
+
function requestIncompatibleKindFromCode(code: string | number | undefined): ModelFallbackFailureKind | undefined {
|
|
207
|
+
const normalizedCode = normalizeCode(code);
|
|
208
|
+
return normalizedCode !== undefined && REQUEST_INCOMPATIBLE_CODES.has(normalizedCode) ? "request_incompatible" : undefined;
|
|
209
|
+
}
|
|
196
210
|
function kindFromCode(code: string | number | undefined): ModelFallbackFailureKind | undefined {
|
|
197
211
|
const normalizedCode = normalizeCode(code);
|
|
198
212
|
if (normalizedCode === undefined) return undefined;
|
|
@@ -200,6 +214,8 @@ function kindFromCode(code: string | number | undefined): ModelFallbackFailureKi
|
|
|
200
214
|
if (refusalKind !== undefined) return refusalKind;
|
|
201
215
|
const httpStatusKind = kindFromStatus(integerFrom(code));
|
|
202
216
|
if (httpStatusKind !== undefined) return httpStatusKind;
|
|
217
|
+
const requestIncompatibleKind = requestIncompatibleKindFromCode(code);
|
|
218
|
+
if (requestIncompatibleKind !== undefined) return requestIncompatibleKind;
|
|
203
219
|
|
|
204
220
|
switch (normalizedCode) {
|
|
205
221
|
case "auth":
|
|
@@ -248,6 +264,18 @@ function kindFromCode(code: string | number | undefined): ModelFallbackFailureKi
|
|
|
248
264
|
}
|
|
249
265
|
}
|
|
250
266
|
|
|
267
|
+
const REQUEST_INCOMPATIBLE_FAILURE_PATTERNS: readonly RegExp[] = [
|
|
268
|
+
/\bcontext[_\s-]?length(?:[_\s-]?exceeded)?\b/i,
|
|
269
|
+
/\bcontext[_\s-]?window(?:[_\s-]?exceeded)?\b/i,
|
|
270
|
+
/\bmax[_\s-]?context\b/i,
|
|
271
|
+
/\bmax[_\s-]?tokens?\b/i,
|
|
272
|
+
/\brequest(?:[_\s-]?entity)?[_\s-]?too[_\s-]?large\b/i,
|
|
273
|
+
/\btoo[_\s-]?large\b/i,
|
|
274
|
+
/\b(?:unsupported|unknown|invalid)\s+(?:tool|parameter|function)\b/i,
|
|
275
|
+
/\b(?:tool|parameter|function)\s+(?:not\s+(?:supported|found|allowed)|unknown|invalid)\b/i,
|
|
276
|
+
/\binvalid[_\s-]?request(?:[_\s-]?error)?\b/i,
|
|
277
|
+
/\bbad[_\s-]?request\b/i,
|
|
278
|
+
];
|
|
251
279
|
const PROVIDER_REFUSAL_FAILURE_PATTERNS: readonly RegExp[] = [
|
|
252
280
|
/\bfinish[_\s-]?reason\b[^\n]*\bcontent[_\s-]?filter\b/i,
|
|
253
281
|
/\bcontent[_\s-]?filter(?:ed|ing)?\b/i,
|
|
@@ -283,6 +311,7 @@ function fallbackKindFromMessage(message: string, name: string | undefined): Mod
|
|
|
283
311
|
if (refusalKind !== undefined) return refusalKind;
|
|
284
312
|
const transportOutageKind = transportOutageKindFromMessage(message);
|
|
285
313
|
if (transportOutageKind !== undefined) return transportOutageKind;
|
|
314
|
+
if (REQUEST_INCOMPATIBLE_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return "request_incompatible";
|
|
286
315
|
const nameKind = kindFromCode(name);
|
|
287
316
|
if (nameKind !== undefined) return nameKind;
|
|
288
317
|
if (!RETRYABLE_MODEL_FAILURE_PATTERNS.some((pattern) => pattern.test(message))) return undefined;
|
|
@@ -371,9 +400,6 @@ function structuredSignal(
|
|
|
371
400
|
const directRefusalSignal = classifyAssistantRefusalSignal(value, source);
|
|
372
401
|
if (directRefusalSignal !== undefined) return directRefusalSignal;
|
|
373
402
|
|
|
374
|
-
const directMessageSignal = fallbackSignalFromDirectMessage(value, source);
|
|
375
|
-
if (directMessageSignal !== undefined) return directMessageSignal;
|
|
376
|
-
|
|
377
403
|
const codeKind = kindFromCode(codeFrom(value));
|
|
378
404
|
const nameKind = kindFromCode(errorName(value));
|
|
379
405
|
if (codeKind === "cancelled" || nameKind === "cancelled") return makeSignal("cancelled", value, source);
|
|
@@ -387,7 +413,6 @@ function structuredSignal(
|
|
|
387
413
|
if (isRefusalSignal(diagnosticSignal)) return diagnosticSignal;
|
|
388
414
|
firstNestedFallbackSignal ??= diagnosticSignal;
|
|
389
415
|
}
|
|
390
|
-
|
|
391
416
|
const cause = causeOf(value);
|
|
392
417
|
const causeSignal = structuredSignal(cause, nestedSeen, source)
|
|
393
418
|
?? fallbackSignalFromMessage(cause, source);
|
|
@@ -396,6 +421,11 @@ function structuredSignal(
|
|
|
396
421
|
firstNestedFallbackSignal ??= causeSignal;
|
|
397
422
|
}
|
|
398
423
|
|
|
424
|
+
// Direct-message classification runs after nested traversal so a generic wrapper
|
|
425
|
+
// ("invalid request"/"400 bad request") cannot mask a non-retryable nested signal.
|
|
426
|
+
const directMessageSignal = fallbackSignalFromDirectMessage(value, source);
|
|
427
|
+
if (directMessageSignal !== undefined) return directMessageSignal;
|
|
428
|
+
|
|
399
429
|
const statusKind = kindFromStatus(statusFrom(value));
|
|
400
430
|
if (statusKind !== undefined) return makeSignal(statusKind, value, source);
|
|
401
431
|
if (codeKind !== undefined) return makeSignal(codeKind, value, source);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-processor.d.ts","sourceRoot":"","sources":["../../src/cli/file-processor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAOjE,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAClC,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,sEAAsE;AACtE,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"file-processor.d.ts","sourceRoot":"","sources":["../../src/cli/file-processor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAOjE,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAClC,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,sEAAsE;AACtE,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CA+DpH","sourcesContent":["/**\n * Process @file CLI arguments into text content and image attachments\n */\n\nimport { access, readFile, stat } from \"node:fs/promises\";\nimport type { ImageContent } from \"@earendil-works/pi-ai/compat\";\nimport chalk from \"chalk\";\nimport { resolve } from \"path\";\nimport { resolveReadPath } from \"../core/tools/path-utils.ts\";\nimport { processImage } from \"../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../utils/mime.ts\";\n\nexport interface ProcessedFiles {\n\ttext: string;\n\timages: ImageContent[];\n}\n\nexport interface ProcessFileOptions {\n\t/** Whether to auto-resize images to 2000x2000 max. Default: true */\n\tautoResizeImages?: boolean;\n}\n\n/** Process @file arguments into text content and image attachments */\nexport async function processFileArguments(fileArgs: string[], options?: ProcessFileOptions): Promise<ProcessedFiles> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tlet text = \"\";\n\tconst images: ImageContent[] = [];\n\n\tfor (const fileArg of fileArgs) {\n\t\t// Expand and resolve path (handles ~ expansion and macOS screenshot Unicode spaces)\n\t\tconst absolutePath = resolve(resolveReadPath(fileArg, process.cwd()));\n\n\t\t// Check if file exists\n\t\ttry {\n\t\t\tawait access(absolutePath);\n\t\t} catch {\n\t\t\tconsole.error(chalk.red(`Error: File not found: ${absolutePath}`));\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\t// Check if file is empty\n\t\tconst stats = await stat(absolutePath);\n\t\tif (stats.size === 0) {\n\t\t\t// Skip empty files\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst mimeType = await detectSupportedImageMimeTypeFromFile(absolutePath);\n\n\t\tif (mimeType) {\n\t\t\t// Handle image file\n\t\t\tconst content = await readFile(absolutePath);\n\t\t\tconst processed = await processImage(content, mimeType, { autoResizeImages });\n\n\t\t\tif (!processed.ok) {\n\t\t\t\ttext += `<file name=\"${absolutePath}\">${processed.message}</file>\\n`;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst attachment: ImageContent = {\n\t\t\t\ttype: \"image\",\n\t\t\t\tmimeType: processed.mimeType,\n\t\t\t\tdata: processed.data,\n\t\t\t};\n\t\t\timages.push(attachment);\n\n\t\t\t// Add text reference to image with optional processing hints\n\t\t\tif (processed.hints.length > 0) {\n\t\t\t\ttext += `<file name=\"${absolutePath}\">${processed.hints.join(\"\\n\")}</file>\\n`;\n\t\t\t} else {\n\t\t\t\ttext += `<file name=\"${absolutePath}\"></file>\\n`;\n\t\t\t}\n\t\t} else {\n\t\t\t// Handle text file\n\t\t\ttry {\n\t\t\t\tconst content = await readFile(absolutePath, \"utf-8\");\n\t\t\t\ttext += `<file name=\"${absolutePath}\">\\n${content}\\n</file>\\n`;\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconsole.error(chalk.red(`Error: Could not read file ${absolutePath}: ${message}`));\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { text, images };\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import { access, readFile, stat } from "node:fs/promises";
|
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import { resolve } from "path";
|
|
7
7
|
import { resolveReadPath } from "../core/tools/path-utils.js";
|
|
8
|
-
import {
|
|
8
|
+
import { processImage } from "../utils/image-process.js";
|
|
9
9
|
import { detectSupportedImageMimeTypeFromFile } from "../utils/mime.js";
|
|
10
10
|
/** Process @file arguments into text content and image attachments */
|
|
11
11
|
export async function processFileArguments(fileArgs, options) {
|
|
@@ -33,32 +33,20 @@ export async function processFileArguments(fileArgs, options) {
|
|
|
33
33
|
if (mimeType) {
|
|
34
34
|
// Handle image file
|
|
35
35
|
const content = await readFile(absolutePath);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!resized) {
|
|
41
|
-
text += `<file name="${absolutePath}">[Image omitted: could not be resized below the inline image size limit.]</file>\n`;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
dimensionNote = formatDimensionNote(resized);
|
|
45
|
-
attachment = {
|
|
46
|
-
type: "image",
|
|
47
|
-
mimeType: resized.mimeType,
|
|
48
|
-
data: resized.data,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
attachment = {
|
|
53
|
-
type: "image",
|
|
54
|
-
mimeType,
|
|
55
|
-
data: content.toString("base64"),
|
|
56
|
-
};
|
|
36
|
+
const processed = await processImage(content, mimeType, { autoResizeImages });
|
|
37
|
+
if (!processed.ok) {
|
|
38
|
+
text += `<file name="${absolutePath}">${processed.message}</file>\n`;
|
|
39
|
+
continue;
|
|
57
40
|
}
|
|
41
|
+
const attachment = {
|
|
42
|
+
type: "image",
|
|
43
|
+
mimeType: processed.mimeType,
|
|
44
|
+
data: processed.data,
|
|
45
|
+
};
|
|
58
46
|
images.push(attachment);
|
|
59
|
-
// Add text reference to image with optional
|
|
60
|
-
if (
|
|
61
|
-
text += `<file name="${absolutePath}">${
|
|
47
|
+
// Add text reference to image with optional processing hints
|
|
48
|
+
if (processed.hints.length > 0) {
|
|
49
|
+
text += `<file name="${absolutePath}">${processed.hints.join("\n")}</file>\n`;
|
|
62
50
|
}
|
|
63
51
|
else {
|
|
64
52
|
text += `<file name="${absolutePath}"></file>\n`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-processor.js","sourceRoot":"","sources":["../../src/cli/file-processor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"file-processor.js","sourceRoot":"","sources":["../../src/cli/file-processor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,oCAAoC,EAAE,MAAM,kBAAkB,CAAC;AAYxE,sEAAsE;AACtE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,QAAkB,EAAE,OAA4B;IAC1F,MAAM,gBAAgB,GAAG,OAAO,EAAE,gBAAgB,IAAI,IAAI,CAAC;IAC3D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AC,UAAU,CAAC,CAAC;YAExB,6DAA6D;YAC7D,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,IAAI,IAAI,eAAe,YAAY,KAAK,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC/E,CAAC;iBAAM,CAAC;gBACP,IAAI,IAAI,eAAe,YAAY,aAAa,CAAC;YAClD,CAAC;QACF,CAAC;aAAM,CAAC;YACP,mBAAmB;YACnB,IAAI,CAAC;gBACJ,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;gBACtD,IAAI,IAAI,eAAe,YAAY,OAAO,OAAO,aAAa,CAAC;YAChE,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,8BAA8B,YAAY,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;gBACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Process @file CLI arguments into text content and image attachments\n */\n\nimport { access, readFile, stat } from \"node:fs/promises\";\nimport type { ImageContent } from \"@earendil-works/pi-ai/compat\";\nimport chalk from \"chalk\";\nimport { resolve } from \"path\";\nimport { resolveReadPath } from \"../core/tools/path-utils.ts\";\nimport { processImage } from \"../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../utils/mime.ts\";\n\nexport interface ProcessedFiles {\n\ttext: string;\n\timages: ImageContent[];\n}\n\nexport interface ProcessFileOptions {\n\t/** Whether to auto-resize images to 2000x2000 max. Default: true */\n\tautoResizeImages?: boolean;\n}\n\n/** Process @file arguments into text content and image attachments */\nexport async function processFileArguments(fileArgs: string[], options?: ProcessFileOptions): Promise<ProcessedFiles> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tlet text = \"\";\n\tconst images: ImageContent[] = [];\n\n\tfor (const fileArg of fileArgs) {\n\t\t// Expand and resolve path (handles ~ expansion and macOS screenshot Unicode spaces)\n\t\tconst absolutePath = resolve(resolveReadPath(fileArg, process.cwd()));\n\n\t\t// Check if file exists\n\t\ttry {\n\t\t\tawait access(absolutePath);\n\t\t} catch {\n\t\t\tconsole.error(chalk.red(`Error: File not found: ${absolutePath}`));\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\t// Check if file is empty\n\t\tconst stats = await stat(absolutePath);\n\t\tif (stats.size === 0) {\n\t\t\t// Skip empty files\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst mimeType = await detectSupportedImageMimeTypeFromFile(absolutePath);\n\n\t\tif (mimeType) {\n\t\t\t// Handle image file\n\t\t\tconst content = await readFile(absolutePath);\n\t\t\tconst processed = await processImage(content, mimeType, { autoResizeImages });\n\n\t\t\tif (!processed.ok) {\n\t\t\t\ttext += `<file name=\"${absolutePath}\">${processed.message}</file>\\n`;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst attachment: ImageContent = {\n\t\t\t\ttype: \"image\",\n\t\t\t\tmimeType: processed.mimeType,\n\t\t\t\tdata: processed.data,\n\t\t\t};\n\t\t\timages.push(attachment);\n\n\t\t\t// Add text reference to image with optional processing hints\n\t\t\tif (processed.hints.length > 0) {\n\t\t\t\ttext += `<file name=\"${absolutePath}\">${processed.hints.join(\"\\n\")}</file>\\n`;\n\t\t\t} else {\n\t\t\t\ttext += `<file name=\"${absolutePath}\"></file>\\n`;\n\t\t\t}\n\t\t} else {\n\t\t\t// Handle text file\n\t\t\ttry {\n\t\t\t\tconst content = await readFile(absolutePath, \"utf-8\");\n\t\t\t\ttext += `<file name=\"${absolutePath}\">\\n${content}\\n</file>\\n`;\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconsole.error(chalk.red(`Error: Could not read file ${absolutePath}: ${message}`));\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { text, images };\n}\n"]}
|
|
@@ -17,6 +17,7 @@ export declare function buildExtensionResourcePaths(this: AgentSession, entries:
|
|
|
17
17
|
}>;
|
|
18
18
|
export declare function getExtensionSourceLabel(this: AgentSession, extensionPath: string): string;
|
|
19
19
|
export declare function _applyExtensionBindings(this: AgentSession, runner: ExtensionRunner): void;
|
|
20
|
+
export declare function refreshCurrentModelFromRegistry(this: AgentSession): void;
|
|
20
21
|
export declare function _refreshCurrentModelFromRegistry(this: AgentSession): void;
|
|
21
22
|
export declare function _bindExtensionCore(this: AgentSession, runner: ExtensionRunner): void;
|
|
22
23
|
export declare function reload(this: AgentSession): Promise<void>;
|
|
@@ -30,6 +31,7 @@ export declare const agentSessionExtensionBindingsMethods: {
|
|
|
30
31
|
buildExtensionResourcePaths: typeof buildExtensionResourcePaths;
|
|
31
32
|
getExtensionSourceLabel: typeof getExtensionSourceLabel;
|
|
32
33
|
_applyExtensionBindings: typeof _applyExtensionBindings;
|
|
34
|
+
refreshCurrentModelFromRegistry: typeof refreshCurrentModelFromRegistry;
|
|
33
35
|
_refreshCurrentModelFromRegistry: typeof _refreshCurrentModelFromRegistry;
|
|
34
36
|
_bindExtensionCore: typeof _bindExtensionCore;
|
|
35
37
|
reload: typeof reload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-extension-bindings.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-extension-bindings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,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";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { ExtensionBindings } from \"./agent-session-types.ts\";\nimport type { ExtensionRunner } from \"./extensions/index.ts\";\nimport type { ResourceExtensionPaths } from \"./resource-loader.ts\";\nimport { emitSessionShutdownEvent } from \"./extensions/runner.ts\";\nimport type { SlashCommandInfo } from \"./slash-commands.ts\";\n\nexport async function bindExtensions(this: AgentSession, bindings: ExtensionBindings): Promise<void> {\n\tif (bindings.uiContext !== undefined) {\n\t\tthis._extensionUIContext = bindings.uiContext;\n\t}\n\tif (bindings.mode !== undefined) {\n\t\tthis._extensionMode = bindings.mode;\n\t}\n\tif (bindings.commandContextActions !== undefined) {\n\t\tthis._extensionCommandContextActions = bindings.commandContextActions;\n\t}\n\tif (bindings.shutdownHandler !== undefined) {\n\t\tthis._extensionShutdownHandler = bindings.shutdownHandler;\n\t}\n\tif (bindings.onError !== undefined) {\n\t\tthis._extensionErrorListener = bindings.onError;\n\t}\n\n\tthis._applyExtensionBindings(this._extensionRunner);\n\tawait this._extensionRunner.emit(this._sessionStartEvent);\n\tawait this.extendResourcesFromExtensions(this._sessionStartEvent.reason === \"reload\" ? \"reload\" : \"startup\");\n}\n\n\nexport async function extendResourcesFromExtensions(this: AgentSession, reason: \"startup\" | \"reload\"): Promise<void> {\n\tif (!this._extensionRunner.hasHandlers(\"resources_discover\")) {\n\t\treturn;\n\t}\n\n\tconst { skillPaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(\n\t\tthis._cwd,\n\t\treason,\n\t);\n\n\tif (skillPaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {\n\t\treturn;\n\t}\n\n\tconst extensionPaths: ResourceExtensionPaths = {\n\t\tskillPaths: this.buildExtensionResourcePaths(skillPaths),\n\t\tpromptPaths: this.buildExtensionResourcePaths(promptPaths),\n\t\tthemePaths: this.buildExtensionResourcePaths(themePaths),\n\t};\n\n\tthis._resourceLoader.extendResources(extensionPaths);\n\tthis._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());\n\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n}\n\n\nexport function buildExtensionResourcePaths(this: AgentSession, entries: Array<{ path: string; extensionPath: string }>): Array<{\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}> {\n\treturn entries.map((entry) => {\n\t\tconst source = this.getExtensionSourceLabel(entry.extensionPath);\n\t\tconst baseDir = entry.extensionPath.startsWith(\"<\") ? undefined : dirname(entry.extensionPath);\n\t\treturn {\n\t\t\tpath: entry.path,\n\t\t\tmetadata: {\n\t\t\t\tsource,\n\t\t\t\tscope: \"temporary\",\n\t\t\t\torigin: \"top-level\",\n\t\t\t\tbaseDir,\n\t\t\t},\n\t\t};\n\t});\n}\n\n\nexport function getExtensionSourceLabel(this: AgentSession, extensionPath: string): string {\n\tif (extensionPath.startsWith(\"<\")) {\n\t\treturn `extension:${extensionPath.replace(/[<>]/g, \"\")}`;\n\t}\n\tconst base = basename(extensionPath);\n\tconst name = base.replace(/\\.(ts|js)$/, \"\");\n\treturn `extension:${name}`;\n}\n\n\nexport function _applyExtensionBindings(this: AgentSession, runner: ExtensionRunner): void {\n\trunner.setUIContext(this._extensionUIContext, this._extensionMode);\n\trunner.bindCommandContext(this._extensionCommandContextActions);\n\n\tthis._extensionErrorUnsubscriber?.();\n\tthis._extensionErrorUnsubscriber = this._extensionErrorListener\n\t\t? runner.onError(this._extensionErrorListener)\n\t\t: undefined;\n}\n\n\nexport function _refreshCurrentModelFromRegistry(this: AgentSession): void {\n\tconst currentModel = this.model;\n\tif (!currentModel) {\n\t\treturn;\n\t}\n\n\tconst refreshedModel = this._modelRegistry.find(currentModel.provider, currentModel.id);\n\tif (!refreshedModel || refreshedModel === currentModel) {\n\t\treturn;\n\t}\n\n\tconst replay = this._getResumeContextWindowReplayForModel(refreshedModel);\n\tthis.agent.state.model = replay.model;\n\tif (currentModel.contextWindow !== replay.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: replay.contextWindow });\n\t}\n\tthis._refreshBaseSystemPromptFromActiveTools();\n}\n\n\nexport function _bindExtensionCore(this: AgentSession, runner: ExtensionRunner): void {\n\tconst getCommands = (): SlashCommandInfo[] => {\n\t\tconst extensionCommands: SlashCommandInfo[] = runner.getRegisteredCommands().map((command) => ({\n\t\t\tname: command.invocationName,\n\t\t\tdescription: command.description,\n\t\t\tsource: \"extension\",\n\t\t\tsourceInfo: command.sourceInfo,\n\t\t}));\n\n\t\tconst templates: SlashCommandInfo[] = this.promptTemplates.map((template) => ({\n\t\t\tname: template.name,\n\t\t\tdescription: template.description,\n\t\t\tsource: \"prompt\",\n\t\t\tsourceInfo: template.sourceInfo,\n\t\t}));\n\n\t\tconst skills: SlashCommandInfo[] = this._resourceLoader.getSkills().skills.map((skill) => ({\n\t\t\tname: `skill:${skill.name}`,\n\t\t\tdescription: skill.description,\n\t\t\tsource: \"skill\",\n\t\t\tsourceInfo: skill.sourceInfo,\n\t\t}));\n\n\t\treturn [...extensionCommands, ...templates, ...skills];\n\t};\n\n\trunner.bindCore(\n\t\t{\n\t\t\tsendMessage: (message, options) => {\n\t\t\t\tthis.sendCustomMessage(message, options).catch((err) => {\n\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\tevent: \"send_message\",\n\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tsendUserMessage: (content, options) => {\n\t\t\t\tthis.sendUserMessage(content, options).catch((err) => {\n\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\tevent: \"send_user_message\",\n\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tappendEntry: (customType, data) => {\n\t\t\t\tthis.sessionManager.appendCustomEntry(customType, data);\n\t\t\t},\n\t\t\tsetSessionName: (name) => {\n\t\t\t\tthis.setSessionName(name);\n\t\t\t},\n\t\t\tgetSessionName: () => {\n\t\t\t\treturn this.sessionManager.getSessionName();\n\t\t\t},\n\t\t\tsetLabel: (entryId, label) => {\n\t\t\t\tthis.sessionManager.appendLabelChange(entryId, label);\n\t\t\t},\n\t\t\tgetActiveTools: () => this.getActiveToolNames(),\n\t\t\tgetAllTools: () => this.getAllTools(),\n\t\t\tsetActiveTools: (toolNames) => this.setActiveToolsByName(toolNames),\n\t\t\trefreshTools: () => this._refreshToolRegistry(),\n\t\t\tgetCommands,\n\t\t\tsetModel: async (model) => {\n\t\t\t\tif (!this.modelRegistry.hasConfiguredAuth(model)) return false;\n\t\t\t\tawait this.setModel(model);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t\tsetThinkingLevel: (level) => this.setThinkingLevel(level),\n\t\t},\n\t\t{\n\t\t\tgetModel: () => this.model,\n\t\t\tisIdle: () => !this.isStreaming,\n\t\t\tisProjectTrusted: () => this.settingsManager.isProjectTrusted(),\n\t\t\tgetSignal: () => this.agent.signal,\n\t\t\tabort: () => this.abort(),\n\t\t\thasPendingMessages: () => this.pendingMessageCount > 0,\n\t\t\tshutdown: () => {\n\t\t\t\tthis._extensionShutdownHandler?.();\n\t\t\t},\n\t\t\tgetContextUsage: () => this.getContextUsage(),\n\t\t\tcompact: (options) => {\n\t\t\t\tvoid (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.compact({\n\t\t\t\t\t\t\t...(options?.compression_ratio === undefined ? {} : { compression_ratio: options.compression_ratio }),\n\t\t\t\t\t\t\t...(options?.preserve_recent === undefined ? {} : { preserve_recent: options.preserve_recent }),\n\t\t\t\t\t\t\t...(options?.query === undefined ? {} : { query: options.query }),\n\t\t\t\t\t\t});\n\t\t\t\t\t\toptions?.onComplete?.(result);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\toptions?.onError?.(err);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t},\n\t\t\tgetSystemPrompt: () => this.systemPrompt,\n\t\t\tgetSystemPromptOptions: () => this._baseSystemPromptOptions,\n\t\t},\n\t\t{\n\t\t\tregisterProvider: (name, config) => {\n\t\t\t\tthis._modelRegistry.registerProvider(name, config);\n\t\t\t\tthis._refreshCurrentModelFromRegistry();\n\t\t\t},\n\t\t\tunregisterProvider: (name) => {\n\t\t\t\tthis._modelRegistry.unregisterProvider(name);\n\t\t\t\tthis._refreshCurrentModelFromRegistry();\n\t\t\t},\n\t\t},\n\t);\n}\n\n\nexport async function reload(this: AgentSession): Promise<void> {\n\tconst previousFlagValues = this._extensionRunner.getFlagValues();\n\tawait emitSessionShutdownEvent(this._extensionRunner, { type: \"session_shutdown\", reason: \"reload\" });\n\tawait this.settingsManager.reload();\n\tresetApiProviders();\n\tawait this._resourceLoader.reload();\n\tthis._buildRuntime({\n\t\tactiveToolNames: this.getActiveToolNames(),\n\t\tflagValues: previousFlagValues,\n\t\tincludeAllExtensionTools: true,\n\t});\n\n\tconst hasBindings =\n\t\tthis._extensionUIContext ||\n\t\tthis._extensionCommandContextActions ||\n\t\tthis._extensionShutdownHandler ||\n\t\tthis._extensionErrorListener;\n\tif (hasBindings) {\n\t\tawait this._extensionRunner.emit({ type: \"session_start\", reason: \"reload\" });\n\t\tawait this.extendResourcesFromExtensions(\"reload\");\n\t}\n}\n\n// =========================================================================\n// Auto-Retry\n// =========================================================================\n\n/**\n * Check if an error is retryable (overloaded, rate limit, server errors).\n * Context overflow errors are NOT retryable (handled by compaction instead).\n */\n\nexport const agentSessionExtensionBindingsMethods = {\n\tbindExtensions,\n\textendResourcesFromExtensions,\n\tbuildExtensionResourcePaths,\n\tgetExtensionSourceLabel,\n\t_applyExtensionBindings,\n\t_refreshCurrentModelFromRegistry,\n\t_bindExtensionCore,\n\treload,\n};\n"]}
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AC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CA+GpF;AAGD,wBAAsB,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB9D;AAMD;;;GAGG;AAEH,eAAO,MAAM,oCAAoC;;;;;;;;;;CAUhD,CAAC","sourcesContent":["import { basename, dirname } from \"node:path\";\nimport { resetApiProviders } from \"@earendil-works/pi-ai/compat\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { ExtensionBindings } from \"./agent-session-types.ts\";\nimport type { ExtensionRunner } from \"./extensions/index.ts\";\nimport type { ResourceExtensionPaths } from \"./resource-loader.ts\";\nimport { emitSessionShutdownEvent } from \"./extensions/runner.ts\";\nimport type { SlashCommandInfo } from \"./slash-commands.ts\";\n\nexport async function bindExtensions(this: AgentSession, bindings: ExtensionBindings): Promise<void> {\n\tif (bindings.uiContext !== undefined) {\n\t\tthis._extensionUIContext = bindings.uiContext;\n\t}\n\tif (bindings.mode !== undefined) {\n\t\tthis._extensionMode = bindings.mode;\n\t}\n\tif (bindings.commandContextActions !== undefined) {\n\t\tthis._extensionCommandContextActions = bindings.commandContextActions;\n\t}\n\tif (bindings.shutdownHandler !== undefined) {\n\t\tthis._extensionShutdownHandler = bindings.shutdownHandler;\n\t}\n\tif (bindings.onError !== undefined) {\n\t\tthis._extensionErrorListener = bindings.onError;\n\t}\n\n\tthis._applyExtensionBindings(this._extensionRunner);\n\tawait this._extensionRunner.emit(this._sessionStartEvent);\n\tawait this.extendResourcesFromExtensions(this._sessionStartEvent.reason === \"reload\" ? \"reload\" : \"startup\");\n}\n\n\nexport async function extendResourcesFromExtensions(this: AgentSession, reason: \"startup\" | \"reload\"): Promise<void> {\n\tif (!this._extensionRunner.hasHandlers(\"resources_discover\")) {\n\t\treturn;\n\t}\n\n\tconst { skillPaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(\n\t\tthis._cwd,\n\t\treason,\n\t);\n\n\tif (skillPaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {\n\t\treturn;\n\t}\n\n\tconst extensionPaths: ResourceExtensionPaths = {\n\t\tskillPaths: this.buildExtensionResourcePaths(skillPaths),\n\t\tpromptPaths: this.buildExtensionResourcePaths(promptPaths),\n\t\tthemePaths: this.buildExtensionResourcePaths(themePaths),\n\t};\n\n\tthis._resourceLoader.extendResources(extensionPaths);\n\tthis._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());\n\tthis.agent.state.systemPrompt = this._systemPromptOverride ?? this._baseSystemPrompt;\n}\n\n\nexport function buildExtensionResourcePaths(this: AgentSession, entries: Array<{ path: string; extensionPath: string }>): Array<{\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}> {\n\treturn entries.map((entry) => {\n\t\tconst source = this.getExtensionSourceLabel(entry.extensionPath);\n\t\tconst baseDir = entry.extensionPath.startsWith(\"<\") ? undefined : dirname(entry.extensionPath);\n\t\treturn {\n\t\t\tpath: entry.path,\n\t\t\tmetadata: {\n\t\t\t\tsource,\n\t\t\t\tscope: \"temporary\",\n\t\t\t\torigin: \"top-level\",\n\t\t\t\tbaseDir,\n\t\t\t},\n\t\t};\n\t});\n}\n\n\nexport function getExtensionSourceLabel(this: AgentSession, extensionPath: string): string {\n\tif (extensionPath.startsWith(\"<\")) {\n\t\treturn `extension:${extensionPath.replace(/[<>]/g, \"\")}`;\n\t}\n\tconst base = basename(extensionPath);\n\tconst name = base.replace(/\\.(ts|js)$/, \"\");\n\treturn `extension:${name}`;\n}\n\n\nexport function _applyExtensionBindings(this: AgentSession, runner: ExtensionRunner): void {\n\trunner.setUIContext(this._extensionUIContext, this._extensionMode);\n\trunner.bindCommandContext(this._extensionCommandContextActions);\n\n\tthis._extensionErrorUnsubscriber?.();\n\tthis._extensionErrorUnsubscriber = this._extensionErrorListener\n\t\t? runner.onError(this._extensionErrorListener)\n\t\t: undefined;\n}\n\n\nexport function refreshCurrentModelFromRegistry(this: AgentSession): void {\n\tthis._refreshCurrentModelFromRegistry();\n}\n\nexport function _refreshCurrentModelFromRegistry(this: AgentSession): void {\n\tconst currentModel = this.model;\n\tif (!currentModel) {\n\t\treturn;\n\t}\n\n\tconst refreshedModel = this._modelRegistry.find(currentModel.provider, currentModel.id);\n\tif (!refreshedModel || refreshedModel === currentModel) {\n\t\treturn;\n\t}\n\n\tconst previousModel = currentModel;\n\tconst previousThinkingLevel = this.thinkingLevel;\n\tconst replay = this._getResumeContextWindowReplayForModel(refreshedModel);\n\tthis.agent.state.model = replay.model;\n\tif (currentModel.contextWindow !== replay.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: replay.contextWindow });\n\t}\n\tthis.setThinkingLevel(previousThinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\tthis._emit({ type: \"model_changed\", model: replay.model, previousModel, source: \"restore\" });\n}\n\n\nexport function _bindExtensionCore(this: AgentSession, runner: ExtensionRunner): void {\n\tconst getCommands = (): SlashCommandInfo[] => {\n\t\tconst extensionCommands: SlashCommandInfo[] = runner.getRegisteredCommands().map((command) => ({\n\t\t\tname: command.invocationName,\n\t\t\tdescription: command.description,\n\t\t\tsource: \"extension\",\n\t\t\tsourceInfo: command.sourceInfo,\n\t\t}));\n\n\t\tconst templates: SlashCommandInfo[] = this.promptTemplates.map((template) => ({\n\t\t\tname: template.name,\n\t\t\tdescription: template.description,\n\t\t\tsource: \"prompt\",\n\t\t\tsourceInfo: template.sourceInfo,\n\t\t}));\n\n\t\tconst skills: SlashCommandInfo[] = this._resourceLoader.getSkills().skills.map((skill) => ({\n\t\t\tname: `skill:${skill.name}`,\n\t\t\tdescription: skill.description,\n\t\t\tsource: \"skill\",\n\t\t\tsourceInfo: skill.sourceInfo,\n\t\t}));\n\n\t\treturn [...extensionCommands, ...templates, ...skills];\n\t};\n\n\trunner.bindCore(\n\t\t{\n\t\t\tsendMessage: (message, options) => {\n\t\t\t\tthis.sendCustomMessage(message, options).catch((err) => {\n\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\tevent: \"send_message\",\n\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tsendUserMessage: (content, options) => {\n\t\t\t\tthis.sendUserMessage(content, options).catch((err) => {\n\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\tevent: \"send_user_message\",\n\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tappendEntry: (customType, data) => {\n\t\t\t\tthis.sessionManager.appendCustomEntry(customType, data);\n\t\t\t},\n\t\t\tsetSessionName: (name) => {\n\t\t\t\tthis.setSessionName(name);\n\t\t\t},\n\t\t\tgetSessionName: () => {\n\t\t\t\treturn this.sessionManager.getSessionName();\n\t\t\t},\n\t\t\tsetLabel: (entryId, label) => {\n\t\t\t\tthis.sessionManager.appendLabelChange(entryId, label);\n\t\t\t},\n\t\t\tgetActiveTools: () => this.getActiveToolNames(),\n\t\t\tgetAllTools: () => this.getAllTools(),\n\t\t\tsetActiveTools: (toolNames) => this.setActiveToolsByName(toolNames),\n\t\t\trefreshTools: () => this._refreshToolRegistry(),\n\t\t\tgetCommands,\n\t\t\tsetModel: async (model) => {\n\t\t\t\tif (!this.modelRegistry.hasConfiguredAuth(model)) return false;\n\t\t\t\tawait this.setModel(model);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t\tsetThinkingLevel: (level) => this.setThinkingLevel(level),\n\t\t},\n\t\t{\n\t\t\tgetModel: () => this.model,\n\t\t\tisIdle: () => !this.isStreaming,\n\t\t\tisProjectTrusted: () => this.settingsManager.isProjectTrusted(),\n\t\t\tgetSignal: () => this.agent.signal,\n\t\t\tabort: () => this.abort(),\n\t\t\thasPendingMessages: () => this.pendingMessageCount > 0,\n\t\t\tshutdown: () => {\n\t\t\t\tthis._extensionShutdownHandler?.();\n\t\t\t},\n\t\t\tgetContextUsage: () => this.getContextUsage(),\n\t\t\tcompact: (options) => {\n\t\t\t\tvoid (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.compact({\n\t\t\t\t\t\t\t...(options?.compression_ratio === undefined ? {} : { compression_ratio: options.compression_ratio }),\n\t\t\t\t\t\t\t...(options?.preserve_recent === undefined ? {} : { preserve_recent: options.preserve_recent }),\n\t\t\t\t\t\t\t...(options?.query === undefined ? {} : { query: options.query }),\n\t\t\t\t\t\t});\n\t\t\t\t\t\toptions?.onComplete?.(result);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\toptions?.onError?.(err);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t},\n\t\t\tgetSystemPrompt: () => this.systemPrompt,\n\t\t\tgetSystemPromptOptions: () => this._baseSystemPromptOptions,\n\t\t},\n\t\t{\n\t\t\tregisterProvider: (name, config) => {\n\t\t\t\tthis._modelRegistry.registerProvider(name, config);\n\t\t\t\tthis.refreshCurrentModelFromRegistry();\n\t\t\t},\n\t\t\tunregisterProvider: (name) => {\n\t\t\t\tthis._modelRegistry.unregisterProvider(name);\n\t\t\t\tthis.refreshCurrentModelFromRegistry();\n\t\t\t},\n\t\t},\n\t);\n}\n\n\nexport async function reload(this: AgentSession): Promise<void> {\n\tconst previousFlagValues = this._extensionRunner.getFlagValues();\n\tawait emitSessionShutdownEvent(this._extensionRunner, { type: \"session_shutdown\", reason: \"reload\" });\n\tawait this.settingsManager.reload();\n\tresetApiProviders();\n\tawait this._resourceLoader.reload();\n\tthis._buildRuntime({\n\t\tactiveToolNames: this.getActiveToolNames(),\n\t\tflagValues: previousFlagValues,\n\t\tincludeAllExtensionTools: true,\n\t});\n\n\tconst hasBindings =\n\t\tthis._extensionUIContext ||\n\t\tthis._extensionCommandContextActions ||\n\t\tthis._extensionShutdownHandler ||\n\t\tthis._extensionErrorListener;\n\tif (hasBindings) {\n\t\tawait this._extensionRunner.emit({ type: \"session_start\", reason: \"reload\" });\n\t\tawait this.extendResourcesFromExtensions(\"reload\");\n\t}\n}\n\n// =========================================================================\n// Auto-Retry\n// =========================================================================\n\n/**\n * Check if an error is retryable (overloaded, rate limit, server errors).\n * Context overflow errors are NOT retryable (handled by compaction instead).\n */\n\nexport const agentSessionExtensionBindingsMethods = {\n\tbindExtensions,\n\textendResourcesFromExtensions,\n\tbuildExtensionResourcePaths,\n\tgetExtensionSourceLabel,\n\t_applyExtensionBindings,\n\trefreshCurrentModelFromRegistry,\n\t_refreshCurrentModelFromRegistry,\n\t_bindExtensionCore,\n\treload,\n};\n"]}
|
|
@@ -36,7 +36,7 @@ export async function extendResourcesFromExtensions(reason) {
|
|
|
36
36
|
};
|
|
37
37
|
this._resourceLoader.extendResources(extensionPaths);
|
|
38
38
|
this._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());
|
|
39
|
-
this.agent.state.systemPrompt = this._baseSystemPrompt;
|
|
39
|
+
this.agent.state.systemPrompt = this._systemPromptOverride ?? this._baseSystemPrompt;
|
|
40
40
|
}
|
|
41
41
|
export function buildExtensionResourcePaths(entries) {
|
|
42
42
|
return entries.map((entry) => {
|
|
@@ -69,6 +69,9 @@ export function _applyExtensionBindings(runner) {
|
|
|
69
69
|
? runner.onError(this._extensionErrorListener)
|
|
70
70
|
: undefined;
|
|
71
71
|
}
|
|
72
|
+
export function refreshCurrentModelFromRegistry() {
|
|
73
|
+
this._refreshCurrentModelFromRegistry();
|
|
74
|
+
}
|
|
72
75
|
export function _refreshCurrentModelFromRegistry() {
|
|
73
76
|
const currentModel = this.model;
|
|
74
77
|
if (!currentModel) {
|
|
@@ -78,12 +81,16 @@ export function _refreshCurrentModelFromRegistry() {
|
|
|
78
81
|
if (!refreshedModel || refreshedModel === currentModel) {
|
|
79
82
|
return;
|
|
80
83
|
}
|
|
84
|
+
const previousModel = currentModel;
|
|
85
|
+
const previousThinkingLevel = this.thinkingLevel;
|
|
81
86
|
const replay = this._getResumeContextWindowReplayForModel(refreshedModel);
|
|
82
87
|
this.agent.state.model = replay.model;
|
|
83
88
|
if (currentModel.contextWindow !== replay.contextWindow) {
|
|
84
89
|
this._emit({ type: "context_window_changed", contextWindow: replay.contextWindow });
|
|
85
90
|
}
|
|
91
|
+
this.setThinkingLevel(previousThinkingLevel);
|
|
86
92
|
this._refreshBaseSystemPromptFromActiveTools();
|
|
93
|
+
this._emit({ type: "model_changed", model: replay.model, previousModel, source: "restore" });
|
|
87
94
|
}
|
|
88
95
|
export function _bindExtensionCore(runner) {
|
|
89
96
|
const getCommands = () => {
|
|
@@ -183,11 +190,11 @@ export function _bindExtensionCore(runner) {
|
|
|
183
190
|
}, {
|
|
184
191
|
registerProvider: (name, config) => {
|
|
185
192
|
this._modelRegistry.registerProvider(name, config);
|
|
186
|
-
this.
|
|
193
|
+
this.refreshCurrentModelFromRegistry();
|
|
187
194
|
},
|
|
188
195
|
unregisterProvider: (name) => {
|
|
189
196
|
this._modelRegistry.unregisterProvider(name);
|
|
190
|
-
this.
|
|
197
|
+
this.refreshCurrentModelFromRegistry();
|
|
191
198
|
},
|
|
192
199
|
});
|
|
193
200
|
}
|
|
@@ -224,6 +231,7 @@ export const agentSessionExtensionBindingsMethods = {
|
|
|
224
231
|
buildExtensionResourcePaths,
|
|
225
232
|
getExtensionSourceLabel,
|
|
226
233
|
_applyExtensionBindings,
|
|
234
|
+
refreshCurrentModelFromRegistry,
|
|
227
235
|
_refreshCurrentModelFromRegistry,
|
|
228
236
|
_bindExtensionCore,
|
|
229
237
|
reload,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-extension-bindings.js","sourceRoot":"","sources":["../../src/core/agent-session-extension-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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CAAC;QAC9E,MAAM,IAAI,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;AACF,CAAC;AAED,4EAA4E;AAC5E,aAAa;AACb,4EAA4E;AAE5E;;;GAGG;AAEH,MAAM,CAAC,MAAM,oCAAoC,GAAG;IACnD,cAAc;IACd,6BAA6B;IAC7B,2BAA2B;IAC3B,uBAAuB;IACvB,uBAAuB;IACvB,gCAAgC;IAChC,kBAAkB;IAClB,MAAM;CACN,CAAC","sourcesContent":["import { basename, dirname } from \"node:path\";\nimport { resetApiProviders } from \"@earendil-works/pi-ai/compat\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { ExtensionBindings } from \"./agent-session-types.ts\";\nimport type { ExtensionRunner } from \"./extensions/index.ts\";\nimport type { ResourceExtensionPaths } from \"./resource-loader.ts\";\nimport { emitSessionShutdownEvent } from \"./extensions/runner.ts\";\nimport type { SlashCommandInfo } from \"./slash-commands.ts\";\n\nexport async function bindExtensions(this: AgentSession, bindings: ExtensionBindings): Promise<void> {\n\tif (bindings.uiContext !== undefined) {\n\t\tthis._extensionUIContext = bindings.uiContext;\n\t}\n\tif (bindings.mode !== undefined) {\n\t\tthis._extensionMode = bindings.mode;\n\t}\n\tif (bindings.commandContextActions !== undefined) {\n\t\tthis._extensionCommandContextActions = bindings.commandContextActions;\n\t}\n\tif (bindings.shutdownHandler !== undefined) {\n\t\tthis._extensionShutdownHandler = bindings.shutdownHandler;\n\t}\n\tif (bindings.onError !== undefined) {\n\t\tthis._extensionErrorListener = bindings.onError;\n\t}\n\n\tthis._applyExtensionBindings(this._extensionRunner);\n\tawait this._extensionRunner.emit(this._sessionStartEvent);\n\tawait this.extendResourcesFromExtensions(this._sessionStartEvent.reason === \"reload\" ? \"reload\" : \"startup\");\n}\n\n\nexport async function extendResourcesFromExtensions(this: AgentSession, reason: \"startup\" | \"reload\"): Promise<void> {\n\tif (!this._extensionRunner.hasHandlers(\"resources_discover\")) {\n\t\treturn;\n\t}\n\n\tconst { skillPaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(\n\t\tthis._cwd,\n\t\treason,\n\t);\n\n\tif (skillPaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {\n\t\treturn;\n\t}\n\n\tconst extensionPaths: ResourceExtensionPaths = {\n\t\tskillPaths: this.buildExtensionResourcePaths(skillPaths),\n\t\tpromptPaths: this.buildExtensionResourcePaths(promptPaths),\n\t\tthemePaths: this.buildExtensionResourcePaths(themePaths),\n\t};\n\n\tthis._resourceLoader.extendResources(extensionPaths);\n\tthis._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());\n\tthis.agent.state.systemPrompt = this._baseSystemPrompt;\n}\n\n\nexport function buildExtensionResourcePaths(this: AgentSession, entries: Array<{ path: string; extensionPath: string }>): Array<{\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}> {\n\treturn entries.map((entry) => {\n\t\tconst source = this.getExtensionSourceLabel(entry.extensionPath);\n\t\tconst baseDir = entry.extensionPath.startsWith(\"<\") ? undefined : dirname(entry.extensionPath);\n\t\treturn {\n\t\t\tpath: entry.path,\n\t\t\tmetadata: {\n\t\t\t\tsource,\n\t\t\t\tscope: \"temporary\",\n\t\t\t\torigin: \"top-level\",\n\t\t\t\tbaseDir,\n\t\t\t},\n\t\t};\n\t});\n}\n\n\nexport function getExtensionSourceLabel(this: AgentSession, extensionPath: string): string {\n\tif (extensionPath.startsWith(\"<\")) {\n\t\treturn `extension:${extensionPath.replace(/[<>]/g, \"\")}`;\n\t}\n\tconst base = basename(extensionPath);\n\tconst name = base.replace(/\\.(ts|js)$/, \"\");\n\treturn `extension:${name}`;\n}\n\n\nexport function _applyExtensionBindings(this: AgentSession, runner: ExtensionRunner): void {\n\trunner.setUIContext(this._extensionUIContext, this._extensionMode);\n\trunner.bindCommandContext(this._extensionCommandContextActions);\n\n\tthis._extensionErrorUnsubscriber?.();\n\tthis._extensionErrorUnsubscriber = this._extensionErrorListener\n\t\t? runner.onError(this._extensionErrorListener)\n\t\t: undefined;\n}\n\n\nexport function _refreshCurrentModelFromRegistry(this: AgentSession): void {\n\tconst currentModel = this.model;\n\tif (!currentModel) {\n\t\treturn;\n\t}\n\n\tconst refreshedModel = this._modelRegistry.find(currentModel.provider, currentModel.id);\n\tif (!refreshedModel || refreshedModel === currentModel) {\n\t\treturn;\n\t}\n\n\tconst replay = this._getResumeContextWindowReplayForModel(refreshedModel);\n\tthis.agent.state.model = replay.model;\n\tif (currentModel.contextWindow !== replay.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: replay.contextWindow });\n\t}\n\tthis._refreshBaseSystemPromptFromActiveTools();\n}\n\n\nexport function _bindExtensionCore(this: AgentSession, runner: ExtensionRunner): void {\n\tconst getCommands = (): SlashCommandInfo[] => {\n\t\tconst extensionCommands: SlashCommandInfo[] = runner.getRegisteredCommands().map((command) => ({\n\t\t\tname: command.invocationName,\n\t\t\tdescription: command.description,\n\t\t\tsource: \"extension\",\n\t\t\tsourceInfo: command.sourceInfo,\n\t\t}));\n\n\t\tconst templates: SlashCommandInfo[] = this.promptTemplates.map((template) => ({\n\t\t\tname: template.name,\n\t\t\tdescription: template.description,\n\t\t\tsource: \"prompt\",\n\t\t\tsourceInfo: template.sourceInfo,\n\t\t}));\n\n\t\tconst skills: SlashCommandInfo[] = this._resourceLoader.getSkills().skills.map((skill) => ({\n\t\t\tname: `skill:${skill.name}`,\n\t\t\tdescription: skill.description,\n\t\t\tsource: \"skill\",\n\t\t\tsourceInfo: skill.sourceInfo,\n\t\t}));\n\n\t\treturn [...extensionCommands, ...templates, ...skills];\n\t};\n\n\trunner.bindCore(\n\t\t{\n\t\t\tsendMessage: (message, options) => {\n\t\t\t\tthis.sendCustomMessage(message, options).catch((err) => {\n\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\tevent: \"send_message\",\n\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tsendUserMessage: (content, options) => {\n\t\t\t\tthis.sendUserMessage(content, options).catch((err) => {\n\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\tevent: \"send_user_message\",\n\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tappendEntry: (customType, data) => {\n\t\t\t\tthis.sessionManager.appendCustomEntry(customType, data);\n\t\t\t},\n\t\t\tsetSessionName: (name) => {\n\t\t\t\tthis.setSessionName(name);\n\t\t\t},\n\t\t\tgetSessionName: () => {\n\t\t\t\treturn this.sessionManager.getSessionName();\n\t\t\t},\n\t\t\tsetLabel: (entryId, label) => {\n\t\t\t\tthis.sessionManager.appendLabelChange(entryId, label);\n\t\t\t},\n\t\t\tgetActiveTools: () => this.getActiveToolNames(),\n\t\t\tgetAllTools: () => this.getAllTools(),\n\t\t\tsetActiveTools: (toolNames) => this.setActiveToolsByName(toolNames),\n\t\t\trefreshTools: () => this._refreshToolRegistry(),\n\t\t\tgetCommands,\n\t\t\tsetModel: async (model) => {\n\t\t\t\tif (!this.modelRegistry.hasConfiguredAuth(model)) return false;\n\t\t\t\tawait this.setModel(model);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t\tsetThinkingLevel: (level) => this.setThinkingLevel(level),\n\t\t},\n\t\t{\n\t\t\tgetModel: () => this.model,\n\t\t\tisIdle: () => !this.isStreaming,\n\t\t\tisProjectTrusted: () => this.settingsManager.isProjectTrusted(),\n\t\t\tgetSignal: () => this.agent.signal,\n\t\t\tabort: () => this.abort(),\n\t\t\thasPendingMessages: () => this.pendingMessageCount > 0,\n\t\t\tshutdown: () => {\n\t\t\t\tthis._extensionShutdownHandler?.();\n\t\t\t},\n\t\t\tgetContextUsage: () => this.getContextUsage(),\n\t\t\tcompact: (options) => {\n\t\t\t\tvoid (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.compact({\n\t\t\t\t\t\t\t...(options?.compression_ratio === undefined ? {} : { compression_ratio: options.compression_ratio }),\n\t\t\t\t\t\t\t...(options?.preserve_recent === undefined ? {} : { preserve_recent: options.preserve_recent }),\n\t\t\t\t\t\t\t...(options?.query === undefined ? {} : { query: options.query }),\n\t\t\t\t\t\t});\n\t\t\t\t\t\toptions?.onComplete?.(result);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\toptions?.onError?.(err);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t},\n\t\t\tgetSystemPrompt: () => this.systemPrompt,\n\t\t\tgetSystemPromptOptions: () => this._baseSystemPromptOptions,\n\t\t},\n\t\t{\n\t\t\tregisterProvider: (name, config) => {\n\t\t\t\tthis._modelRegistry.registerProvider(name, config);\n\t\t\t\tthis._refreshCurrentModelFromRegistry();\n\t\t\t},\n\t\t\tunregisterProvider: (name) => {\n\t\t\t\tthis._modelRegistry.unregisterProvider(name);\n\t\t\t\tthis._refreshCurrentModelFromRegistry();\n\t\t\t},\n\t\t},\n\t);\n}\n\n\nexport async function reload(this: AgentSession): Promise<void> {\n\tconst previousFlagValues = this._extensionRunner.getFlagValues();\n\tawait emitSessionShutdownEvent(this._extensionRunner, { type: \"session_shutdown\", reason: \"reload\" });\n\tawait this.settingsManager.reload();\n\tresetApiProviders();\n\tawait this._resourceLoader.reload();\n\tthis._buildRuntime({\n\t\tactiveToolNames: this.getActiveToolNames(),\n\t\tflagValues: previousFlagValues,\n\t\tincludeAllExtensionTools: true,\n\t});\n\n\tconst hasBindings =\n\t\tthis._extensionUIContext ||\n\t\tthis._extensionCommandContextActions ||\n\t\tthis._extensionShutdownHandler ||\n\t\tthis._extensionErrorListener;\n\tif (hasBindings) {\n\t\tawait this._extensionRunner.emit({ type: \"session_start\", reason: \"reload\" });\n\t\tawait this.extendResourcesFromExtensions(\"reload\");\n\t}\n}\n\n// =========================================================================\n// Auto-Retry\n// =========================================================================\n\n/**\n * Check if an error is retryable (overloaded, rate limit, server errors).\n * Context overflow errors are NOT retryable (handled by compaction instead).\n */\n\nexport const agentSessionExtensionBindingsMethods = {\n\tbindExtensions,\n\textendResourcesFromExtensions,\n\tbuildExtensionResourcePaths,\n\tgetExtensionSourceLabel,\n\t_applyExtensionBindings,\n\t_refreshCurrentModelFromRegistry,\n\t_bindExtensionCore,\n\treload,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-extension-bindings.js","sourceRoot":"","sources":["../../src/core/agent-session-extension-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,MAAM,CAAC,KAAK,UAAU,cAAc,CAAqB,QAA2B;IACnF,IAAI,QAAQ,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACtC,IAAI,CAAC,mBAAmB,GAAG,QAAQ,CAAC,SAAS,CAAC;IAC/C,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC;IACrC,CAAC;IACD,IAAI,QAAQ,CAAC,qBAAqB,KAAK,SAAS,EAAE,CAAC;QAClD,IAAI,CAAC,+BAA+B,GAAG,QAAQ,CAAC,qBAAqB,CAAC;IACvE,CAAC;IACD,IAAI,QAAQ,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QAC5C,IAAI,CAAC,yBAAyB,GAAG,QAAQ,CAAC,eAAe,CAAC;IAC3D,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,KAAK,SA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{ resetApiProviders } from \"@earendil-works/pi-ai/compat\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport type { ExtensionBindings } from \"./agent-session-types.ts\";\nimport type { ExtensionRunner } from \"./extensions/index.ts\";\nimport type { ResourceExtensionPaths } from \"./resource-loader.ts\";\nimport { emitSessionShutdownEvent } from \"./extensions/runner.ts\";\nimport type { SlashCommandInfo } from \"./slash-commands.ts\";\n\nexport async function bindExtensions(this: AgentSession, bindings: ExtensionBindings): Promise<void> {\n\tif (bindings.uiContext !== undefined) {\n\t\tthis._extensionUIContext = bindings.uiContext;\n\t}\n\tif (bindings.mode !== undefined) {\n\t\tthis._extensionMode = bindings.mode;\n\t}\n\tif (bindings.commandContextActions !== undefined) {\n\t\tthis._extensionCommandContextActions = bindings.commandContextActions;\n\t}\n\tif (bindings.shutdownHandler !== undefined) {\n\t\tthis._extensionShutdownHandler = bindings.shutdownHandler;\n\t}\n\tif (bindings.onError !== undefined) {\n\t\tthis._extensionErrorListener = bindings.onError;\n\t}\n\n\tthis._applyExtensionBindings(this._extensionRunner);\n\tawait this._extensionRunner.emit(this._sessionStartEvent);\n\tawait this.extendResourcesFromExtensions(this._sessionStartEvent.reason === \"reload\" ? \"reload\" : \"startup\");\n}\n\n\nexport async function extendResourcesFromExtensions(this: AgentSession, reason: \"startup\" | \"reload\"): Promise<void> {\n\tif (!this._extensionRunner.hasHandlers(\"resources_discover\")) {\n\t\treturn;\n\t}\n\n\tconst { skillPaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(\n\t\tthis._cwd,\n\t\treason,\n\t);\n\n\tif (skillPaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {\n\t\treturn;\n\t}\n\n\tconst extensionPaths: ResourceExtensionPaths = {\n\t\tskillPaths: this.buildExtensionResourcePaths(skillPaths),\n\t\tpromptPaths: this.buildExtensionResourcePaths(promptPaths),\n\t\tthemePaths: this.buildExtensionResourcePaths(themePaths),\n\t};\n\n\tthis._resourceLoader.extendResources(extensionPaths);\n\tthis._baseSystemPrompt = this._rebuildSystemPrompt(this.getActiveToolNames());\n\tthis.agent.state.systemPrompt = this._systemPromptOverride ?? this._baseSystemPrompt;\n}\n\n\nexport function buildExtensionResourcePaths(this: AgentSession, entries: Array<{ path: string; extensionPath: string }>): Array<{\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}> {\n\treturn entries.map((entry) => {\n\t\tconst source = this.getExtensionSourceLabel(entry.extensionPath);\n\t\tconst baseDir = entry.extensionPath.startsWith(\"<\") ? undefined : dirname(entry.extensionPath);\n\t\treturn {\n\t\t\tpath: entry.path,\n\t\t\tmetadata: {\n\t\t\t\tsource,\n\t\t\t\tscope: \"temporary\",\n\t\t\t\torigin: \"top-level\",\n\t\t\t\tbaseDir,\n\t\t\t},\n\t\t};\n\t});\n}\n\n\nexport function getExtensionSourceLabel(this: AgentSession, extensionPath: string): string {\n\tif (extensionPath.startsWith(\"<\")) {\n\t\treturn `extension:${extensionPath.replace(/[<>]/g, \"\")}`;\n\t}\n\tconst base = basename(extensionPath);\n\tconst name = base.replace(/\\.(ts|js)$/, \"\");\n\treturn `extension:${name}`;\n}\n\n\nexport function _applyExtensionBindings(this: AgentSession, runner: ExtensionRunner): void {\n\trunner.setUIContext(this._extensionUIContext, this._extensionMode);\n\trunner.bindCommandContext(this._extensionCommandContextActions);\n\n\tthis._extensionErrorUnsubscriber?.();\n\tthis._extensionErrorUnsubscriber = this._extensionErrorListener\n\t\t? runner.onError(this._extensionErrorListener)\n\t\t: undefined;\n}\n\n\nexport function refreshCurrentModelFromRegistry(this: AgentSession): void {\n\tthis._refreshCurrentModelFromRegistry();\n}\n\nexport function _refreshCurrentModelFromRegistry(this: AgentSession): void {\n\tconst currentModel = this.model;\n\tif (!currentModel) {\n\t\treturn;\n\t}\n\n\tconst refreshedModel = this._modelRegistry.find(currentModel.provider, currentModel.id);\n\tif (!refreshedModel || refreshedModel === currentModel) {\n\t\treturn;\n\t}\n\n\tconst previousModel = currentModel;\n\tconst previousThinkingLevel = this.thinkingLevel;\n\tconst replay = this._getResumeContextWindowReplayForModel(refreshedModel);\n\tthis.agent.state.model = replay.model;\n\tif (currentModel.contextWindow !== replay.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: replay.contextWindow });\n\t}\n\tthis.setThinkingLevel(previousThinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\tthis._emit({ type: \"model_changed\", model: replay.model, previousModel, source: \"restore\" });\n}\n\n\nexport function _bindExtensionCore(this: AgentSession, runner: ExtensionRunner): void {\n\tconst getCommands = (): SlashCommandInfo[] => {\n\t\tconst extensionCommands: SlashCommandInfo[] = runner.getRegisteredCommands().map((command) => ({\n\t\t\tname: command.invocationName,\n\t\t\tdescription: command.description,\n\t\t\tsource: \"extension\",\n\t\t\tsourceInfo: command.sourceInfo,\n\t\t}));\n\n\t\tconst templates: SlashCommandInfo[] = this.promptTemplates.map((template) => ({\n\t\t\tname: template.name,\n\t\t\tdescription: template.description,\n\t\t\tsource: \"prompt\",\n\t\t\tsourceInfo: template.sourceInfo,\n\t\t}));\n\n\t\tconst skills: SlashCommandInfo[] = this._resourceLoader.getSkills().skills.map((skill) => ({\n\t\t\tname: `skill:${skill.name}`,\n\t\t\tdescription: skill.description,\n\t\t\tsource: \"skill\",\n\t\t\tsourceInfo: skill.sourceInfo,\n\t\t}));\n\n\t\treturn [...extensionCommands, ...templates, ...skills];\n\t};\n\n\trunner.bindCore(\n\t\t{\n\t\t\tsendMessage: (message, options) => {\n\t\t\t\tthis.sendCustomMessage(message, options).catch((err) => {\n\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\tevent: \"send_message\",\n\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tsendUserMessage: (content, options) => {\n\t\t\t\tthis.sendUserMessage(content, options).catch((err) => {\n\t\t\t\t\trunner.emitError({\n\t\t\t\t\t\textensionPath: \"<runtime>\",\n\t\t\t\t\t\tevent: \"send_user_message\",\n\t\t\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tappendEntry: (customType, data) => {\n\t\t\t\tthis.sessionManager.appendCustomEntry(customType, data);\n\t\t\t},\n\t\t\tsetSessionName: (name) => {\n\t\t\t\tthis.setSessionName(name);\n\t\t\t},\n\t\t\tgetSessionName: () => {\n\t\t\t\treturn this.sessionManager.getSessionName();\n\t\t\t},\n\t\t\tsetLabel: (entryId, label) => {\n\t\t\t\tthis.sessionManager.appendLabelChange(entryId, label);\n\t\t\t},\n\t\t\tgetActiveTools: () => this.getActiveToolNames(),\n\t\t\tgetAllTools: () => this.getAllTools(),\n\t\t\tsetActiveTools: (toolNames) => this.setActiveToolsByName(toolNames),\n\t\t\trefreshTools: () => this._refreshToolRegistry(),\n\t\t\tgetCommands,\n\t\t\tsetModel: async (model) => {\n\t\t\t\tif (!this.modelRegistry.hasConfiguredAuth(model)) return false;\n\t\t\t\tawait this.setModel(model);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tgetThinkingLevel: () => this.thinkingLevel,\n\t\t\tsetThinkingLevel: (level) => this.setThinkingLevel(level),\n\t\t},\n\t\t{\n\t\t\tgetModel: () => this.model,\n\t\t\tisIdle: () => !this.isStreaming,\n\t\t\tisProjectTrusted: () => this.settingsManager.isProjectTrusted(),\n\t\t\tgetSignal: () => this.agent.signal,\n\t\t\tabort: () => this.abort(),\n\t\t\thasPendingMessages: () => this.pendingMessageCount > 0,\n\t\t\tshutdown: () => {\n\t\t\t\tthis._extensionShutdownHandler?.();\n\t\t\t},\n\t\t\tgetContextUsage: () => this.getContextUsage(),\n\t\t\tcompact: (options) => {\n\t\t\t\tvoid (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.compact({\n\t\t\t\t\t\t\t...(options?.compression_ratio === undefined ? {} : { compression_ratio: options.compression_ratio }),\n\t\t\t\t\t\t\t...(options?.preserve_recent === undefined ? {} : { preserve_recent: options.preserve_recent }),\n\t\t\t\t\t\t\t...(options?.query === undefined ? {} : { query: options.query }),\n\t\t\t\t\t\t});\n\t\t\t\t\t\toptions?.onComplete?.(result);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\toptions?.onError?.(err);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t},\n\t\t\tgetSystemPrompt: () => this.systemPrompt,\n\t\t\tgetSystemPromptOptions: () => this._baseSystemPromptOptions,\n\t\t},\n\t\t{\n\t\t\tregisterProvider: (name, config) => {\n\t\t\t\tthis._modelRegistry.registerProvider(name, config);\n\t\t\t\tthis.refreshCurrentModelFromRegistry();\n\t\t\t},\n\t\t\tunregisterProvider: (name) => {\n\t\t\t\tthis._modelRegistry.unregisterProvider(name);\n\t\t\t\tthis.refreshCurrentModelFromRegistry();\n\t\t\t},\n\t\t},\n\t);\n}\n\n\nexport async function reload(this: AgentSession): Promise<void> {\n\tconst previousFlagValues = this._extensionRunner.getFlagValues();\n\tawait emitSessionShutdownEvent(this._extensionRunner, { type: \"session_shutdown\", reason: \"reload\" });\n\tawait this.settingsManager.reload();\n\tresetApiProviders();\n\tawait this._resourceLoader.reload();\n\tthis._buildRuntime({\n\t\tactiveToolNames: this.getActiveToolNames(),\n\t\tflagValues: previousFlagValues,\n\t\tincludeAllExtensionTools: true,\n\t});\n\n\tconst hasBindings =\n\t\tthis._extensionUIContext ||\n\t\tthis._extensionCommandContextActions ||\n\t\tthis._extensionShutdownHandler ||\n\t\tthis._extensionErrorListener;\n\tif (hasBindings) {\n\t\tawait this._extensionRunner.emit({ type: \"session_start\", reason: \"reload\" });\n\t\tawait this.extendResourcesFromExtensions(\"reload\");\n\t}\n}\n\n// =========================================================================\n// Auto-Retry\n// =========================================================================\n\n/**\n * Check if an error is retryable (overloaded, rate limit, server errors).\n * Context overflow errors are NOT retryable (handled by compaction instead).\n */\n\nexport const agentSessionExtensionBindingsMethods = {\n\tbindExtensions,\n\textendResourcesFromExtensions,\n\tbuildExtensionResourcePaths,\n\tgetExtensionSourceLabel,\n\t_applyExtensionBindings,\n\trefreshCurrentModelFromRegistry,\n\t_refreshCurrentModelFromRegistry,\n\t_bindExtensionCore,\n\treload,\n};\n"]}
|
|
@@ -83,6 +83,7 @@ export interface AgentSessionMethodSurface {
|
|
|
83
83
|
headers?: Record<string, string>;
|
|
84
84
|
}>;
|
|
85
85
|
_installAgentToolHooks(): void;
|
|
86
|
+
_installAgentNextTurnRefresh(): void;
|
|
86
87
|
_emit(event: AgentSessionEvent): void;
|
|
87
88
|
_emitQueueUpdate(): void;
|
|
88
89
|
_createRetryPromiseForAgentEnd(event: AgentEvent): void;
|
|
@@ -187,6 +188,7 @@ export interface AgentSessionMethodSurface {
|
|
|
187
188
|
getExtensionSourceLabel(extensionPath: string): string;
|
|
188
189
|
_applyExtensionBindings(runner: ExtensionRunner): void;
|
|
189
190
|
_refreshCurrentModelFromRegistry(): void;
|
|
191
|
+
refreshCurrentModelFromRegistry(): void;
|
|
190
192
|
_bindExtensionCore(runner: ExtensionRunner): void;
|
|
191
193
|
_refreshToolRegistry(options?: {
|
|
192
194
|
activeToolNames?: string[];
|
|
@@ -238,7 +240,7 @@ export interface AgentSessionMethodSurface {
|
|
|
238
240
|
createReplacedSessionContext(): ReplacedSessionContext;
|
|
239
241
|
hasExtensionHandlers(eventType: string): boolean;
|
|
240
242
|
}
|
|
241
|
-
export interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface, "orchestrationContext" | "modelRegistry" | "state" | "model" | "thinkingLevel" | "isStreaming" | "systemPrompt" | "retryAttempt" | "isCompacting" | "messages" | "steeringMode" | "followUpMode" | "sessionFile" | "sessionId" | "sessionName" | "scopedModels" | "promptTemplates" | "pendingMessageCount" | "resourceLoader" | "autoCompactionEnabled" | "isRetrying" | "autoRetryEnabled" | "isBashRunning" | "hasPendingBashMessages" | "extensionRunner" | "subscribe" | "dispose" | "getActiveToolNames" | "getAllTools" | "getToolDefinition" | "setActiveToolsByName" | "setScopedModels" | "prompt" | "steer" | "followUp" | "sendCustomMessage" | "sendUserMessage" | "clearQueue" | "getSteeringMessages" | "getFollowUpMessages" | "abort" | "setModel" | "cycleModel" | "setThinkingLevel" | "cycleThinkingLevel" | "getAvailableThinkingLevels" | "supportsThinking" | "getAvailableContextWindows" | "supportsContextWindowSelection" | "setContextWindow" | "setSteeringMode" | "setFollowUpMode" | "compact" | "contextCompact" | "abortCompaction" | "abortBranchSummary" | "setAutoCompactionEnabled" | "bindExtensions" | "reload" | "abortRetry" | "setAutoRetryEnabled" | "executeBash" | "recordBashResult" | "abortBash" | "setSessionName" | "navigateTree" | "getUserMessagesForForking" | "getSessionStats" | "getContextUsage" | "exportToHtml" | "exportToJsonl" | "getLastAssistantText" | "createReplacedSessionContext" | "hasExtensionHandlers"> {
|
|
243
|
+
export interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface, "orchestrationContext" | "modelRegistry" | "state" | "model" | "thinkingLevel" | "isStreaming" | "systemPrompt" | "retryAttempt" | "isCompacting" | "messages" | "steeringMode" | "followUpMode" | "sessionFile" | "sessionId" | "sessionName" | "scopedModels" | "promptTemplates" | "pendingMessageCount" | "resourceLoader" | "autoCompactionEnabled" | "isRetrying" | "autoRetryEnabled" | "isBashRunning" | "hasPendingBashMessages" | "extensionRunner" | "subscribe" | "dispose" | "getActiveToolNames" | "getAllTools" | "getToolDefinition" | "setActiveToolsByName" | "setScopedModels" | "prompt" | "steer" | "followUp" | "sendCustomMessage" | "sendUserMessage" | "clearQueue" | "getSteeringMessages" | "getFollowUpMessages" | "abort" | "setModel" | "cycleModel" | "setThinkingLevel" | "cycleThinkingLevel" | "getAvailableThinkingLevels" | "supportsThinking" | "getAvailableContextWindows" | "supportsContextWindowSelection" | "setContextWindow" | "setSteeringMode" | "setFollowUpMode" | "compact" | "contextCompact" | "abortCompaction" | "abortBranchSummary" | "setAutoCompactionEnabled" | "bindExtensions" | "refreshCurrentModelFromRegistry" | "reload" | "abortRetry" | "setAutoRetryEnabled" | "executeBash" | "recordBashResult" | "abortBash" | "setSessionName" | "navigateTree" | "getUserMessagesForForking" | "getSessionStats" | "getContextUsage" | "exportToHtml" | "exportToJsonl" | "getLastAssistantText" | "createReplacedSessionContext" | "hasExtensionHandlers"> {
|
|
242
244
|
readonly agent: Agent;
|
|
243
245
|
readonly sessionManager: SessionManager;
|
|
244
246
|
readonly settingsManager: SettingsManager;
|
|
@@ -296,6 +298,7 @@ export interface AgentSessionInternalSurface extends AgentSessionMethodSurface,
|
|
|
296
298
|
_toolPromptGuidelines: Map<string, string[]>;
|
|
297
299
|
_baseSystemPrompt: string;
|
|
298
300
|
_baseSystemPromptOptions: BuildSystemPromptOptions;
|
|
301
|
+
_systemPromptOverride?: string;
|
|
299
302
|
_lastAssistantMessage: AssistantMessage | undefined;
|
|
300
303
|
}
|
|
301
304
|
//# sourceMappingURL=agent-session-methods.d.ts.map
|