@namzu/sdk 31.1.0 → 33.0.0
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 +188 -0
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +4 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +4 -0
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +4 -0
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +4 -0
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/authorization/gate.d.ts +1 -1
- package/dist/authorization/gate.js +1 -1
- package/dist/connector/index.d.ts +1 -1
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +1 -1
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +71 -16
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +3 -2
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/http-redirect.d.ts +17 -0
- package/dist/connector/mcp/http-redirect.d.ts.map +1 -0
- package/dist/connector/mcp/http-redirect.js +31 -0
- package/dist/connector/mcp/http-redirect.js.map +1 -0
- package/dist/connector/mcp/http-sse.d.ts.map +1 -1
- package/dist/connector/mcp/http-sse.js +5 -0
- package/dist/connector/mcp/http-sse.js.map +1 -1
- package/dist/connector/mcp/image-admission.d.ts +16 -0
- package/dist/connector/mcp/image-admission.d.ts.map +1 -0
- package/dist/connector/mcp/image-admission.js +288 -0
- package/dist/connector/mcp/image-admission.js.map +1 -0
- package/dist/connector/mcp/stdio.d.ts +13 -0
- package/dist/connector/mcp/stdio.d.ts.map +1 -1
- package/dist/connector/mcp/stdio.js +66 -23
- package/dist/connector/mcp/stdio.js.map +1 -1
- package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
- package/dist/connector/mcp/streamable-http.js +3 -0
- package/dist/connector/mcp/streamable-http.js.map +1 -1
- package/dist/constants/tools/index.js +1 -1
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/directory/derive-supervisor.d.ts.map +1 -1
- package/dist/directory/derive-supervisor.js +5 -0
- package/dist/directory/derive-supervisor.js.map +1 -1
- package/dist/directory/derive.d.ts.map +1 -1
- package/dist/directory/derive.js +5 -0
- package/dist/directory/derive.js.map +1 -1
- package/dist/directory/load.d.ts.map +1 -1
- package/dist/directory/load.js +1 -0
- package/dist/directory/load.js.map +1 -1
- package/dist/directory/types.d.ts +2 -0
- package/dist/directory/types.d.ts.map +1 -1
- package/dist/execution/base.d.ts +13 -0
- package/dist/execution/base.d.ts.map +1 -1
- package/dist/execution/base.js +103 -8
- package/dist/execution/base.js.map +1 -1
- package/dist/execution/code-runtime/types.d.ts +11 -1
- package/dist/execution/code-runtime/types.d.ts.map +1 -1
- package/dist/execution/code-runtime/types.js.map +1 -1
- package/dist/execution/code-runtime/worker.d.ts.map +1 -1
- package/dist/execution/code-runtime/worker.js +67 -9
- package/dist/execution/code-runtime/worker.js.map +1 -1
- package/dist/execution/errors.d.ts +12 -0
- package/dist/execution/errors.d.ts.map +1 -0
- package/dist/execution/errors.js +21 -0
- package/dist/execution/errors.js.map +1 -0
- package/dist/execution/factory.d.ts.map +1 -1
- package/dist/execution/factory.js +1 -0
- package/dist/execution/factory.js.map +1 -1
- package/dist/execution/hybrid.d.ts +5 -0
- package/dist/execution/hybrid.d.ts.map +1 -1
- package/dist/execution/hybrid.js +36 -16
- package/dist/execution/hybrid.js.map +1 -1
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +1 -0
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/local.d.ts +13 -0
- package/dist/execution/local.d.ts.map +1 -1
- package/dist/execution/local.js +145 -19
- package/dist/execution/local.js.map +1 -1
- package/dist/execution/output.d.ts +27 -0
- package/dist/execution/output.d.ts.map +1 -0
- package/dist/execution/output.js +105 -0
- package/dist/execution/output.js.map +1 -0
- package/dist/execution/remote.d.ts +26 -2
- package/dist/execution/remote.d.ts.map +1 -1
- package/dist/execution/remote.js +86 -15
- package/dist/execution/remote.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +1 -0
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +9 -3
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/process/kill-tree.d.ts +11 -13
- package/dist/process/kill-tree.d.ts.map +1 -1
- package/dist/process/kill-tree.js +11 -13
- package/dist/process/kill-tree.js.map +1 -1
- package/dist/provider/errors.d.ts +1 -0
- package/dist/provider/errors.d.ts.map +1 -1
- package/dist/provider/errors.js +39 -1
- package/dist/provider/errors.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +31 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +5 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +5 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +7 -5
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +9 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +2 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/tool/execute.d.ts +7 -1
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +201 -54
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/run/command-gate.d.ts.map +1 -1
- package/dist/run/command-gate.js +11 -0
- package/dist/run/command-gate.js.map +1 -1
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +6 -1
- package/dist/run/reporter.js.map +1 -1
- package/dist/run/workspace-fingerprint.d.ts +4 -4
- package/dist/run/workspace-fingerprint.d.ts.map +1 -1
- package/dist/run/workspace-fingerprint.js +6 -4
- package/dist/run/workspace-fingerprint.js.map +1 -1
- package/dist/runtime/bidi/index.d.ts +1 -1
- package/dist/runtime/bidi/index.d.ts.map +1 -1
- package/dist/runtime/bidi/index.js +1 -1
- package/dist/runtime/bidi/index.js.map +1 -1
- package/dist/runtime/bidi/session.d.ts +19 -0
- package/dist/runtime/bidi/session.d.ts.map +1 -1
- package/dist/runtime/bidi/session.js +150 -26
- package/dist/runtime/bidi/session.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +43 -1
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +824 -174
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +5 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +47 -4
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +1 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +34 -14
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +2 -2
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +84 -22
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts +13 -0
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts.map +1 -0
- package/dist/runtime/query/iteration/provider-rejected-image.js +91 -0
- package/dist/runtime/query/iteration/provider-rejected-image.js.map +1 -0
- package/dist/runtime/query/iteration/stream-turn.d.ts +4 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +7 -3
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/request-rich-content.d.ts +13 -0
- package/dist/runtime/query/request-rich-content.d.ts.map +1 -1
- package/dist/runtime/query/request-rich-content.js +173 -17
- package/dist/runtime/query/request-rich-content.js.map +1 -1
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +1 -0
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +5 -1
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +66 -1
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/tool-output-budget.d.ts.map +1 -1
- package/dist/runtime/query/tool-output-budget.js +45 -16
- package/dist/runtime/query/tool-output-budget.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +6 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +4 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +193 -41
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/delegating.d.ts +2 -1
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +6 -5
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/scheduler/local.d.ts +2 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +2 -2
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/workspace/driver.d.ts +12 -4
- package/dist/session/workspace/driver.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.d.ts +17 -3
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +153 -34
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/skills/registry.d.ts +15 -0
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +33 -0
- package/dist/skills/registry.js.map +1 -1
- package/dist/store/attachment/index.d.ts +24 -2
- package/dist/store/attachment/index.d.ts.map +1 -1
- package/dist/store/attachment/index.js +52 -5
- package/dist/store/attachment/index.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +39 -2
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/lsp.d.ts +1 -1
- package/dist/tools/builtins/run-code.d.ts.map +1 -1
- package/dist/tools/builtins/run-code.js +24 -16
- package/dist/tools/builtins/run-code.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts +2 -1
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +250 -6
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +100 -30
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/types/agent/base.d.ts +4 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +1 -0
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/dist/types/agent/manager.d.ts +1 -1
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +10 -1
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +12 -12
- package/dist/types/bidi/index.d.ts +19 -2
- package/dist/types/bidi/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +18 -0
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/connector/execution-context.d.ts +3 -1
- package/dist/types/connector/execution-context.d.ts.map +1 -1
- package/dist/types/execution/index.d.ts +43 -1
- package/dist/types/execution/index.d.ts.map +1 -1
- package/dist/types/hitl/index.d.ts +11 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +31 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +43 -0
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +14 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +1 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/error.d.ts +4 -1
- package/dist/types/provider/error.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +14 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +10 -2
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/sandbox/index.d.ts +15 -10
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +129 -12
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/workspace/ref.d.ts +5 -0
- package/dist/types/workspace/ref.d.ts.map +1 -1
- package/dist/utils/abort.d.ts +8 -0
- package/dist/utils/abort.d.ts.map +1 -1
- package/dist/utils/abort.js +16 -0
- package/dist/utils/abort.js.map +1 -1
- package/package.json +4 -4
- package/src/agents/ReactiveAgent.ts +4 -0
- package/src/agents/SupervisorAgent.ts +4 -0
- package/src/agents/runAgent.ts +8 -0
- package/src/authorization/gate.ts +1 -1
- package/src/connector/index.ts +2 -0
- package/src/connector/mcp/adapter.ts +82 -21
- package/src/connector/mcp/client.ts +2 -1
- package/src/connector/mcp/http-redirect.ts +32 -0
- package/src/connector/mcp/http-sse.ts +5 -0
- package/src/connector/mcp/image-admission.ts +272 -0
- package/src/connector/mcp/stdio.ts +63 -21
- package/src/connector/mcp/streamable-http.ts +3 -0
- package/src/constants/tools/index.ts +1 -1
- package/src/directory/derive-supervisor.ts +5 -0
- package/src/directory/derive.ts +5 -0
- package/src/directory/load.ts +1 -0
- package/src/directory/types.ts +2 -0
- package/src/execution/base.ts +124 -7
- package/src/execution/code-runtime/types.ts +15 -1
- package/src/execution/code-runtime/worker.ts +72 -9
- package/src/execution/errors.ts +24 -0
- package/src/execution/factory.ts +1 -0
- package/src/execution/hybrid.ts +47 -16
- package/src/execution/index.ts +1 -0
- package/src/execution/local.ts +164 -19
- package/src/execution/output.ts +104 -0
- package/src/execution/remote.ts +122 -17
- package/src/manager/agent/lifecycle.ts +1 -0
- package/src/plugin/lifecycle.ts +9 -3
- package/src/process/kill-tree.ts +11 -13
- package/src/provider/errors.ts +40 -1
- package/src/provider/fallback.ts +39 -0
- package/src/provider/idle-timeout.ts +8 -0
- package/src/provider/retry.ts +8 -0
- package/src/public-runtime.ts +23 -2
- package/src/public-types.ts +11 -0
- package/src/registry/tool/execute.ts +230 -64
- package/src/run/command-gate.ts +12 -0
- package/src/run/reporter.ts +7 -1
- package/src/run/workspace-fingerprint.ts +5 -4
- package/src/runtime/bidi/index.ts +1 -1
- package/src/runtime/bidi/session.ts +177 -28
- package/src/runtime/query/executor.ts +987 -172
- package/src/runtime/query/index.ts +59 -6
- package/src/runtime/query/iteration/index.ts +69 -29
- package/src/runtime/query/iteration/phases/advisory.ts +2 -2
- package/src/runtime/query/iteration/phases/tool-review.ts +87 -23
- package/src/runtime/query/iteration/provider-rejected-image.ts +106 -0
- package/src/runtime/query/iteration/stream-turn.ts +12 -2
- package/src/runtime/query/request-rich-content.ts +213 -15
- package/src/runtime/query/result.ts +1 -0
- package/src/runtime/query/resume-pending.ts +83 -1
- package/src/runtime/query/tool-output-budget.ts +52 -17
- package/src/runtime/query/tooling.ts +10 -0
- package/src/sandbox/provider/local.ts +213 -45
- package/src/scheduler/delegating.ts +6 -5
- package/src/scheduler/local.ts +3 -2
- package/src/session/workspace/driver.ts +12 -4
- package/src/session/workspace/git-worktree.ts +173 -34
- package/src/skills/registry.ts +47 -0
- package/src/store/attachment/index.ts +100 -15
- package/src/tools/builtins/computer-use.ts +45 -2
- package/src/tools/builtins/run-code.ts +24 -16
- package/src/tools/builtins/skill.ts +325 -7
- package/src/tools/coordinator/agent.ts +108 -33
- package/src/types/agent/base.ts +4 -0
- package/src/types/agent/factory.ts +1 -0
- package/src/types/agent/manager.ts +1 -1
- package/src/types/agent/scheduler.ts +10 -1
- package/src/types/bidi/index.ts +19 -2
- package/src/types/computer-use/index.ts +19 -0
- package/src/types/connector/execution-context.ts +3 -0
- package/src/types/execution/index.ts +46 -1
- package/src/types/hitl/index.ts +11 -0
- package/src/types/message/index.ts +78 -1
- package/src/types/plugin/index.ts +15 -0
- package/src/types/provider/error.ts +4 -1
- package/src/types/provider/interface.ts +18 -0
- package/src/types/run/events.ts +18 -4
- package/src/types/sandbox/index.ts +15 -10
- package/src/types/tool/index.ts +159 -15
- package/src/types/workspace/ref.ts +5 -0
- package/src/utils/abort.ts +18 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/** One minute is long enough for remote stores without letting a run wedge forever. */
|
|
2
|
+
export const DEFAULT_ATTACHMENT_RESOLVE_TIMEOUT_MS = 60_000;
|
|
3
|
+
const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
1
4
|
/** A reference nothing could resolve. */
|
|
2
5
|
export class AttachmentNotFoundError extends Error {
|
|
3
6
|
details;
|
|
@@ -25,6 +28,15 @@ export class AttachmentMediaTypeMismatchError extends Error {
|
|
|
25
28
|
this.details = details;
|
|
26
29
|
}
|
|
27
30
|
}
|
|
31
|
+
/** A store did not settle the materialization phase within its declared bound. */
|
|
32
|
+
export class AttachmentResolutionTimeoutError extends Error {
|
|
33
|
+
details;
|
|
34
|
+
constructor(details) {
|
|
35
|
+
super(`Stored attachment resolution timed out after ${details.timeoutMs}ms.`);
|
|
36
|
+
this.name = 'AttachmentResolutionTimeoutError';
|
|
37
|
+
this.details = details;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
28
40
|
export const isStoredAttachment = (attachment) => attachment.type === 'stored';
|
|
29
41
|
/**
|
|
30
42
|
* Turn a stored attachment into an inline one, or refuse.
|
|
@@ -36,10 +48,14 @@ export const isStoredAttachment = (attachment) => attachment.type === 'stored';
|
|
|
36
48
|
* branches returns the message unchanged.
|
|
37
49
|
*/
|
|
38
50
|
export async function resolveAttachment(attachment, store, options = {}) {
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
options.signal?.throwIfAborted();
|
|
52
|
+
const timeoutMs = resolveAttachmentTimeoutMs(options.timeoutMs);
|
|
41
53
|
if (!isStoredAttachment(attachment))
|
|
42
54
|
return attachment;
|
|
55
|
+
return await withAttachmentDeadline(options.signal, timeoutMs, async (signal) => resolveAttachmentWithSignal(attachment, store, signal));
|
|
56
|
+
}
|
|
57
|
+
async function resolveAttachmentWithSignal(attachment, store, signal) {
|
|
58
|
+
signal?.throwIfAborted();
|
|
43
59
|
if (!store)
|
|
44
60
|
throw new NoAttachmentStoreError({ ref: attachment.ref });
|
|
45
61
|
const bytes = await awaitStoreRead(signal, () => signal ? store.get(attachment.ref, { signal }) : store.get(attachment.ref));
|
|
@@ -81,6 +97,7 @@ export async function resolveAttachment(attachment, store, options = {}) {
|
|
|
81
97
|
*/
|
|
82
98
|
export async function resolveAttachments(messages, store, options = {}) {
|
|
83
99
|
options.signal?.throwIfAborted();
|
|
100
|
+
const timeoutMs = resolveAttachmentTimeoutMs(options.timeoutMs);
|
|
84
101
|
// `Message` rather than a structural constraint: only some members of
|
|
85
102
|
// the union carry `attachments`, and a structural bound over a union
|
|
86
103
|
// like that is not assignable in either direction. Naming the real type
|
|
@@ -88,15 +105,45 @@ export async function resolveAttachments(messages, store, options = {}) {
|
|
|
88
105
|
const has = (message) => message.attachments;
|
|
89
106
|
if (!messages.some((m) => has(m)?.some(isStoredAttachment)))
|
|
90
107
|
return messages;
|
|
91
|
-
return await Promise.all(messages.map(async (message) => {
|
|
108
|
+
return await withAttachmentDeadline(options.signal, timeoutMs, async (signal) => Promise.all(messages.map(async (message) => {
|
|
92
109
|
const attachments = has(message);
|
|
93
110
|
if (!attachments?.some(isStoredAttachment))
|
|
94
111
|
return message;
|
|
95
112
|
return {
|
|
96
113
|
...message,
|
|
97
|
-
attachments: await Promise.all(attachments.map((attachment) =>
|
|
114
|
+
attachments: await Promise.all(attachments.map((attachment) => isStoredAttachment(attachment)
|
|
115
|
+
? resolveAttachmentWithSignal(attachment, store, signal)
|
|
116
|
+
: attachment)),
|
|
98
117
|
};
|
|
99
|
-
}));
|
|
118
|
+
})));
|
|
119
|
+
}
|
|
120
|
+
function resolveAttachmentTimeoutMs(value) {
|
|
121
|
+
const resolved = value ?? DEFAULT_ATTACHMENT_RESOLVE_TIMEOUT_MS;
|
|
122
|
+
if (!Number.isInteger(resolved) || resolved < 0 || resolved > MAX_TIMER_DELAY_MS) {
|
|
123
|
+
throw new RangeError(`attachmentResolveTimeoutMs must be an integer from 0 to ${MAX_TIMER_DELAY_MS}; received ${String(resolved)}`);
|
|
124
|
+
}
|
|
125
|
+
return resolved;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Own one timer for the whole parallel materialization phase.
|
|
129
|
+
*
|
|
130
|
+
* The caller's signal is an input, never the controller we abort. Whichever
|
|
131
|
+
* cause wins is latched by `AbortSignal.any`, and every store wait races that
|
|
132
|
+
* fused signal independently through `awaitStoreRead` below.
|
|
133
|
+
*/
|
|
134
|
+
async function withAttachmentDeadline(upstream, timeoutMs, start) {
|
|
135
|
+
upstream?.throwIfAborted();
|
|
136
|
+
if (timeoutMs === 0)
|
|
137
|
+
return await start(upstream);
|
|
138
|
+
const timeout = new AbortController();
|
|
139
|
+
const signal = upstream ? AbortSignal.any([upstream, timeout.signal]) : timeout.signal;
|
|
140
|
+
const timer = setTimeout(() => timeout.abort(new AttachmentResolutionTimeoutError({ timeoutMs })), timeoutMs);
|
|
141
|
+
try {
|
|
142
|
+
return await start(signal);
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
clearTimeout(timer);
|
|
146
|
+
}
|
|
100
147
|
}
|
|
101
148
|
/**
|
|
102
149
|
* Await a host store without handing it ownership of run cancellation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/attachment/index.ts"],"names":[],"mappings":"AA0EA,yCAAyC;AACzC,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,OAAO,CAAiB;IAEjC,YAAY,OAAwB;QACnC,KAAK,CAAC,0BAA0B,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;QAChD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,CAAC;CACD;AAED,yEAAyE;AACzE,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACvC,OAAO,CAAiB;IAEjC,YAAY,OAAwB;QACnC,KAAK,CACJ,2CAA2C,OAAO,CAAC,GAAG,0CAA0C,CAChG,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,CAAC;CACD;AAED,mEAAmE;AACnE,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IACjD,OAAO,CAAmD;IAEnE,YAAY,OAA0D;QACrE,KAAK,CACJ,eAAe,OAAO,CAAC,GAAG,kBAAkB,OAAO,CAAC,QAAQ,wBAAwB,OAAO,CAAC,MAAM,GAAG,CACrG,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAA;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,CAAC;CACD;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CACjC,UAA6B,EACwB,EAAE,CACtD,UAAgC,CAAC,IAAI,KAAK,QAAQ,CAAA;AAEpD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,UAA6B,EAC7B,KAAkC,EAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/attachment/index.ts"],"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AQ,EAAQ,EAAE;YACtC,IAAI,OAAO;gBAAE,OAAM;YACnB,OAAO,GAAG,IAAI,CAAA;YACd,OAAO,EAAE,CAAA;YACT,OAAO,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAA;QACD,MAAM,OAAO,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAErD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,IAAI,CAAC;YACJ,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,UAAU,CAAC,KAAK,CAAC,CAAA;QAClB,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computer-use.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/computer-use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAGX,eAAe,
|
|
1
|
+
{"version":3,"file":"computer-use.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/computer-use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAGX,eAAe,EAGf,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,2BAA2B,CAAA;AAG3E,eAAO,MAAM,sBAAsB,EAAG,cAAuB,CAAA;AAa7D,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmBhB,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAqHtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAAC,WAAW,CAAC,CA+BxF"}
|
|
@@ -110,6 +110,35 @@ function resultToToolResult(result) {
|
|
|
110
110
|
return { success: true, output: 'ok' };
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
function isOutcomeUnknown(value, action) {
|
|
114
|
+
if (typeof value !== 'object' || value === null)
|
|
115
|
+
return false;
|
|
116
|
+
const candidate = value;
|
|
117
|
+
return (candidate.code === 'computer_use_outcome_unknown' &&
|
|
118
|
+
candidate.action === action &&
|
|
119
|
+
candidate.outcome === 'unknown' &&
|
|
120
|
+
candidate.retrySafety === 'unsafe' &&
|
|
121
|
+
typeof candidate.timedOut === 'boolean' &&
|
|
122
|
+
typeof candidate.exitCode === 'number' &&
|
|
123
|
+
Number.isInteger(candidate.exitCode) &&
|
|
124
|
+
typeof candidate.message === 'string' &&
|
|
125
|
+
candidate.message.length > 0);
|
|
126
|
+
}
|
|
127
|
+
function unknownOutcomeToToolResult(error) {
|
|
128
|
+
return {
|
|
129
|
+
success: false,
|
|
130
|
+
output: '',
|
|
131
|
+
error: error.message,
|
|
132
|
+
data: {
|
|
133
|
+
code: error.code,
|
|
134
|
+
action: error.action,
|
|
135
|
+
outcome: error.outcome,
|
|
136
|
+
retrySafety: error.retrySafety,
|
|
137
|
+
timedOut: error.timedOut,
|
|
138
|
+
exitCode: error.exitCode,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
113
142
|
/**
|
|
114
143
|
* Factory: given a ComputerUseHost (provided by the consumer — e.g.
|
|
115
144
|
* @namzu/computer-use's SubprocessComputerUseHost), returns a ToolDefinition
|
|
@@ -149,8 +178,16 @@ export function createComputerUseTool(host) {
|
|
|
149
178
|
error: `computer_use: action "${input.type}" requires capability "${required}" which is not available on this host (displayServer=${host.capabilities.displayServer}).`,
|
|
150
179
|
};
|
|
151
180
|
}
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
try {
|
|
182
|
+
const result = await host.execute(input);
|
|
183
|
+
return resultToToolResult(result);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
if (isOutcomeUnknown(error, input.type)) {
|
|
187
|
+
return unknownOutcomeToToolResult(error);
|
|
188
|
+
}
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
154
191
|
},
|
|
155
192
|
});
|
|
156
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computer-use.js","sourceRoot":"","sources":["../../../src/tools/builtins/computer-use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"computer-use.js","sourceRoot":"","sources":["../../../src/tools/builtins/computer-use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AASvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,cAAuB,CAAA;AAE7D,8EAA8E;AAC9E,gEAAgE;AAChE,8EAA8E;AAE9E,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACnB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;CACnB,CAAC,CAAA;AAEF,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE7D,MAAM,YAAY,GAAG,CAAC,CAAC,kBAAkB,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2
|
export declare const LSP_TOOL_NAME = "lsp";
|
|
3
3
|
export declare const LspTool: import("../../types/tool/index.js").ToolDefinition<{
|
|
4
4
|
path: string;
|
|
5
|
-
operation: "hover" | "definition" | "references";
|
|
6
5
|
line: number;
|
|
6
|
+
operation: "hover" | "definition" | "references";
|
|
7
7
|
character: number;
|
|
8
8
|
} | {
|
|
9
9
|
query: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-code.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/run-code.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AA0CxE,eAAO,MAAM,kBAAkB,aAAa,CAAA;AAE5C,MAAM,WAAW,kBAAkB;IAClC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAChC;AAKD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB;;;
|
|
1
|
+
{"version":3,"file":"run-code.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/run-code.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AA0CxE,eAAO,MAAM,kBAAkB,aAAa,CAAA;AAE5C,MAAM,WAAW,kBAAkB;IAClC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAChC;AAKD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB;;;GAyGhE"}
|
|
@@ -10,12 +10,12 @@ import { defineTool } from '../defineTool.js';
|
|
|
10
10
|
* loop cannot reach further than the twenty calls could have.
|
|
11
11
|
*
|
|
12
12
|
* **The program's reach is the RUN's reach, and nothing wider.** Every
|
|
13
|
-
* capability it can call is a tool already in this run's registry
|
|
14
|
-
* narrowed by the turn's `allowedTools
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* capability it can call is a tool already in this run's registry and
|
|
14
|
+
* narrowed by the turn's `allowedTools`. The host dispatch records every
|
|
15
|
+
* child in the run and applies the run's operator authorization gate. An
|
|
16
|
+
* explicit allow proceeds; a denial or an undecided child fails closed and
|
|
17
|
+
* leaves a durable refusal, because an already-executing parent cannot open
|
|
18
|
+
* a second durable human-review turn on the program's behalf.
|
|
19
19
|
*
|
|
20
20
|
* Opt-in, and not in the default builtin set. A run that does not need
|
|
21
21
|
* model-authored control flow should not have a way to execute
|
|
@@ -72,20 +72,24 @@ export function buildRunCodeTool(options = {}) {
|
|
|
72
72
|
timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
73
73
|
maxOutputBytes: options.maxOutputBytes ?? DEFAULT_MAX_OUTPUT,
|
|
74
74
|
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
75
|
-
onHostCall: async (request) => {
|
|
76
|
-
// Through the
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
// forgot it would be the one a model reached through a
|
|
80
|
-
// program.
|
|
75
|
+
onHostCall: async (request, operation) => {
|
|
76
|
+
// Through the run-owned nested dispatch: registry narrowing,
|
|
77
|
+
// operator authorization, audit/event lineage and invocation
|
|
78
|
+
// cancellation remain host-owned rather than worker-owned.
|
|
81
79
|
try {
|
|
82
|
-
const toolResult = await dispatch(request.name, request.input
|
|
80
|
+
const toolResult = await dispatch(request.name, request.input, {
|
|
81
|
+
signal: operation.signal,
|
|
82
|
+
runtimeToolCallId: operation.runtimeToolCallId,
|
|
83
|
+
});
|
|
83
84
|
return toolResult.success
|
|
84
85
|
? { ok: true, value: toolResult.output }
|
|
85
86
|
: { ok: false, error: toolResult.error ?? 'the tool failed' };
|
|
86
87
|
}
|
|
87
88
|
catch (err) {
|
|
88
|
-
return {
|
|
89
|
+
return {
|
|
90
|
+
ok: false,
|
|
91
|
+
error: err instanceof Error ? err.message : String(err),
|
|
92
|
+
};
|
|
89
93
|
}
|
|
90
94
|
},
|
|
91
95
|
});
|
|
@@ -113,10 +117,14 @@ export function buildRunCodeTool(options = {}) {
|
|
|
113
117
|
// printed its progress and then hung has told the model
|
|
114
118
|
// where it got to, and discarding that leaves the model
|
|
115
119
|
// retrying from the start.
|
|
116
|
-
error: `The program ran longer than ${options.timeoutMs ?? DEFAULT_TIMEOUT_MS}ms and was stopped.`,
|
|
120
|
+
error: `The program ran longer than ${options.timeoutMs ?? DEFAULT_TIMEOUT_MS}ms and its worker was stopped. Admitted host calls were asked to cancel; an uncooperative one may still be running.`,
|
|
117
121
|
};
|
|
118
122
|
case 'cancelled':
|
|
119
|
-
return {
|
|
123
|
+
return {
|
|
124
|
+
success: false,
|
|
125
|
+
output: body,
|
|
126
|
+
error: 'The program was cancelled.',
|
|
127
|
+
};
|
|
120
128
|
default:
|
|
121
129
|
return { success: false, output: body, error: result.outcome.error };
|
|
122
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-code.js","sourceRoot":"","sources":["../../../src/tools/builtins/run-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,IAAI,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACR,0MAA0M,CAC1M;IACF,KAAK,EAAE,CAAC;SACN,KAAK,CAAC,CAAC,CAAC,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I,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAEjE,QAAQ,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;gBAC/B,KAAK,WAAW;oBACf,OAAO;wBACN,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,EAAE;wBACtG,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,eAAe,EAAE;qBAChE,CAAA;gBACF,KAAK,WAAW;oBACf,OAAO;wBACN,OAAO,EAAE,KAAK;wBACd,MAAM,EAAE,IAAI;wBACZ,2DAA2D;wBAC3D,wDAAwD;wBACxD,wDAAwD;wBACxD,2BAA2B;wBAC3B,KAAK,EAAE,+BAA+B,OAAO,CAAC,SAAS,IAAI,kBAAkB,qHAAqH;qBAClM,CAAA;gBACF,KAAK,WAAW;oBACf,OAAO;wBACN,OAAO,EAAE,KAAK;wBACd,MAAM,EAAE,IAAI;wBACZ,KAAK,EAAE,4BAA4B;qBACnC,CAAA;gBACF;oBACC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;YACtE,CAAC;QACF,CAAC;KACD,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
export declare function parseAllowedTools(declared: string | undefined): readonly string[] | undefined;
|
|
10
10
|
export declare const SKILL_TOOL_NAME = "skill";
|
|
11
11
|
export declare const SkillTool: import("../../public-types.js").ToolDefinition<{
|
|
12
|
-
name
|
|
12
|
+
name?: string | undefined;
|
|
13
|
+
cursor?: string | undefined;
|
|
13
14
|
}>;
|
|
14
15
|
//# sourceMappingURL=skill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/skill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/skill.ts"],"names":[],"mappings":"AAyOA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAW7F;AAED,eAAO,MAAM,eAAe,UAAU,CAAA;AAEtC,eAAO,MAAM,SAAS;;;EAmMpB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { isInvocableBy, skillInvocation } from '../../types/skills/index.js';
|
|
3
4
|
import { defineTool } from '../defineTool.js';
|
|
@@ -20,8 +21,151 @@ const inputSchema = z.object({
|
|
|
20
21
|
name: z
|
|
21
22
|
.string()
|
|
22
23
|
.min(1)
|
|
23
|
-
.
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('The skill to load, exactly as listed in the available-skills manifest. Omit it to list model-invocable skills.'),
|
|
26
|
+
cursor: z
|
|
27
|
+
.string()
|
|
28
|
+
.max(160)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe('Opaque continuation cursor returned by an earlier call in the same mode.'),
|
|
24
31
|
});
|
|
32
|
+
const CURSOR_PATTERN = /^v1\.([1-9][0-9]*)\.([A-Za-z0-9_-]{43})$/;
|
|
33
|
+
const LIST_CURSOR_PATTERN = /^v1\.list\.(0|[1-9][0-9]*)\.([01])\.([A-Za-z0-9_-]{43})$/;
|
|
34
|
+
const MAX_SKILLS_PER_PAGE = 20;
|
|
35
|
+
const OVERSIZED_CATALOG_WARNING = 'Some skills were omitted because their metadata is too large for this response budget.';
|
|
36
|
+
function snapshotDigest(snapshot) {
|
|
37
|
+
return createHash('sha256')
|
|
38
|
+
.update(JSON.stringify({
|
|
39
|
+
version: 1,
|
|
40
|
+
name: snapshot.name,
|
|
41
|
+
body: snapshot.body,
|
|
42
|
+
allowedTools: snapshot.allowedTools ?? null,
|
|
43
|
+
invocation: snapshot.invocation,
|
|
44
|
+
}))
|
|
45
|
+
.digest('base64url');
|
|
46
|
+
}
|
|
47
|
+
function cursorFor(offset, digest) {
|
|
48
|
+
return `v1.${offset}.${digest}`;
|
|
49
|
+
}
|
|
50
|
+
function parseCursor(cursor) {
|
|
51
|
+
const match = CURSOR_PATTERN.exec(cursor);
|
|
52
|
+
if (!match)
|
|
53
|
+
return undefined;
|
|
54
|
+
const offset = Number(match[1]);
|
|
55
|
+
if (!Number.isSafeInteger(offset))
|
|
56
|
+
return undefined;
|
|
57
|
+
return { offset, digest: match[2] ?? '' };
|
|
58
|
+
}
|
|
59
|
+
function listCursorFor(offset, warned, digest) {
|
|
60
|
+
return `v1.list.${offset}.${warned ? 1 : 0}.${digest}`;
|
|
61
|
+
}
|
|
62
|
+
function parseListCursor(cursor) {
|
|
63
|
+
const match = LIST_CURSOR_PATTERN.exec(cursor);
|
|
64
|
+
if (!match)
|
|
65
|
+
return undefined;
|
|
66
|
+
const offset = Number(match[1]);
|
|
67
|
+
if (!Number.isSafeInteger(offset))
|
|
68
|
+
return undefined;
|
|
69
|
+
return { offset, warned: match[2] === '1', digest: match[3] ?? '' };
|
|
70
|
+
}
|
|
71
|
+
function activeOutputCap(maxChars) {
|
|
72
|
+
return maxChars !== undefined && maxChars > 0 ? maxChars : undefined;
|
|
73
|
+
}
|
|
74
|
+
function listDigest(skills, maxChars) {
|
|
75
|
+
return createHash('sha256')
|
|
76
|
+
.update(JSON.stringify({ version: 1, kind: 'list', maxChars: maxChars ?? null, skills }))
|
|
77
|
+
.digest('base64url');
|
|
78
|
+
}
|
|
79
|
+
function serializeListPage(page) {
|
|
80
|
+
return JSON.stringify(page);
|
|
81
|
+
}
|
|
82
|
+
function fitsListBudget(page, maxChars) {
|
|
83
|
+
return maxChars === undefined || serializeListPage(page).length <= maxChars;
|
|
84
|
+
}
|
|
85
|
+
function pageSkillCatalog(input) {
|
|
86
|
+
const { skills, digest, start, warningAlreadyShown, maxChars } = input;
|
|
87
|
+
const retained = [];
|
|
88
|
+
let omitted = false;
|
|
89
|
+
let hasRetainedLater = false;
|
|
90
|
+
// Work backwards so the final retained entry is tested without a cursor.
|
|
91
|
+
// A last entry that fits by itself must not be dropped merely because an
|
|
92
|
+
// earlier page will need a continuation token to reach it.
|
|
93
|
+
for (let index = skills.length - 1; index >= start; index -= 1) {
|
|
94
|
+
const skill = skills[index];
|
|
95
|
+
if (!skill)
|
|
96
|
+
continue;
|
|
97
|
+
const nextCursor = hasRetainedLater ? listCursorFor(index + 1, true, digest) : null;
|
|
98
|
+
if (fitsListBudget({ skills: [skill], warnings: [], nextCursor }, maxChars)) {
|
|
99
|
+
retained.push({ index, skill });
|
|
100
|
+
hasRetainedLater = true;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
omitted = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
retained.reverse();
|
|
107
|
+
const warning = omitted && !warningAlreadyShown ? [OVERSIZED_CATALOG_WARNING] : [];
|
|
108
|
+
let count = Math.min(MAX_SKILLS_PER_PAGE, retained.length);
|
|
109
|
+
while (count > 0) {
|
|
110
|
+
const selected = retained.slice(0, count);
|
|
111
|
+
const last = selected.at(-1);
|
|
112
|
+
const hasMore = count < retained.length;
|
|
113
|
+
const page = {
|
|
114
|
+
skills: selected.map((entry) => entry.skill),
|
|
115
|
+
warnings: warning,
|
|
116
|
+
nextCursor: hasMore && last
|
|
117
|
+
? listCursorFor(last.index + 1, warningAlreadyShown || warning.length > 0, digest)
|
|
118
|
+
: null,
|
|
119
|
+
};
|
|
120
|
+
if (fitsListBudget(page, maxChars))
|
|
121
|
+
return page;
|
|
122
|
+
count -= 1;
|
|
123
|
+
}
|
|
124
|
+
if (warning.length > 0) {
|
|
125
|
+
const page = {
|
|
126
|
+
skills: [],
|
|
127
|
+
warnings: warning,
|
|
128
|
+
nextCursor: retained.length > 0 ? listCursorFor(start, true, digest) : null,
|
|
129
|
+
};
|
|
130
|
+
if (fitsListBudget(page, maxChars))
|
|
131
|
+
return page;
|
|
132
|
+
}
|
|
133
|
+
const empty = { skills: [], warnings: [], nextCursor: null };
|
|
134
|
+
return retained.length === 0 && fitsListBudget(empty, maxChars) ? empty : undefined;
|
|
135
|
+
}
|
|
136
|
+
function isCodePointBoundary(text, index) {
|
|
137
|
+
if (index <= 0 || index >= text.length)
|
|
138
|
+
return true;
|
|
139
|
+
const before = text.charCodeAt(index - 1);
|
|
140
|
+
const after = text.charCodeAt(index);
|
|
141
|
+
return !(before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff);
|
|
142
|
+
}
|
|
143
|
+
function boundaryAtOrBefore(text, index) {
|
|
144
|
+
const bounded = Math.max(0, Math.min(text.length, index));
|
|
145
|
+
return isCodePointBoundary(text, bounded) ? bounded : bounded - 1;
|
|
146
|
+
}
|
|
147
|
+
function continuationNotice(name, cursor) {
|
|
148
|
+
return `\n\n[More skill instructions remain. Call skill again with name "${name}" and cursor "${cursor}" before acting.]`;
|
|
149
|
+
}
|
|
150
|
+
function pageSkillBody(input) {
|
|
151
|
+
const { snapshot, digest, start, notice, maxChars } = input;
|
|
152
|
+
const remaining = `${snapshot.body.slice(start)}${notice}`;
|
|
153
|
+
if (maxChars === undefined || maxChars <= 0 || remaining.length <= maxChars) {
|
|
154
|
+
return { output: remaining };
|
|
155
|
+
}
|
|
156
|
+
// Estimate once, then remove exactly the overflow until the page fits.
|
|
157
|
+
// The cursor grows only at powers of ten, so this converges in a handful
|
|
158
|
+
// of steps without allocating an index for every character in a large file.
|
|
159
|
+
let end = boundaryAtOrBefore(snapshot.body, Math.min(snapshot.body.length - 1, start + maxChars));
|
|
160
|
+
while (end > start) {
|
|
161
|
+
const nextCursor = cursorFor(end, digest);
|
|
162
|
+
const output = `${snapshot.body.slice(start, end)}${continuationNotice(snapshot.name, nextCursor)}${notice}`;
|
|
163
|
+
if (output.length <= maxChars)
|
|
164
|
+
return { output, nextCursor };
|
|
165
|
+
end = boundaryAtOrBefore(snapshot.body, end - Math.max(1, output.length - maxChars));
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
25
169
|
/**
|
|
26
170
|
* `allowed-tools` as a list.
|
|
27
171
|
*
|
|
@@ -46,7 +190,7 @@ export function parseAllowedTools(declared) {
|
|
|
46
190
|
export const SKILL_TOOL_NAME = 'skill';
|
|
47
191
|
export const SkillTool = defineTool({
|
|
48
192
|
name: SKILL_TOOL_NAME,
|
|
49
|
-
description: '
|
|
193
|
+
description: 'Lists model-invocable skills when called without a name, or loads one skill by its exact listed name. Long lists and bodies return an opaque continuation cursor; keep calling in the same mode with that cursor until no continuation remains. The manifest carries only names and descriptions.',
|
|
50
194
|
inputSchema,
|
|
51
195
|
category: 'analysis',
|
|
52
196
|
permissions: [],
|
|
@@ -64,6 +208,64 @@ export const SkillTool = defineTool({
|
|
|
64
208
|
error: 'This run has no skills registry, so there is nothing to load. Proceed without the skill.',
|
|
65
209
|
};
|
|
66
210
|
}
|
|
211
|
+
if (input.name === undefined) {
|
|
212
|
+
if (!context.skills.catalog) {
|
|
213
|
+
return {
|
|
214
|
+
success: false,
|
|
215
|
+
output: '',
|
|
216
|
+
error: 'This skills registry cannot enumerate model-safe metadata. Use a skill name from the available-skills manifest.',
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
const skills = (await context.skills.catalog())
|
|
220
|
+
.filter((entry) => entry.invocation === undefined ||
|
|
221
|
+
entry.invocation === 'model' ||
|
|
222
|
+
entry.invocation === 'both')
|
|
223
|
+
.map((entry) => ({
|
|
224
|
+
name: entry.registeredName,
|
|
225
|
+
description: entry.description,
|
|
226
|
+
location: entry.location,
|
|
227
|
+
...(entry.allowedTools === undefined ? {} : { allowedTools: entry.allowedTools }),
|
|
228
|
+
}));
|
|
229
|
+
const maxChars = activeOutputCap(context.maxToolOutputChars);
|
|
230
|
+
const digest = listDigest(skills, maxChars);
|
|
231
|
+
let start = 0;
|
|
232
|
+
let warningAlreadyShown = false;
|
|
233
|
+
if (input.cursor !== undefined) {
|
|
234
|
+
const parsed = parseListCursor(input.cursor);
|
|
235
|
+
if (!parsed || parsed.digest !== digest || parsed.offset >= skills.length) {
|
|
236
|
+
return {
|
|
237
|
+
success: false,
|
|
238
|
+
output: '',
|
|
239
|
+
error: 'The skill-list continuation cursor is stale or invalid. Call skill again without a cursor to read the current catalog.',
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
start = parsed.offset;
|
|
243
|
+
warningAlreadyShown = parsed.warned;
|
|
244
|
+
}
|
|
245
|
+
const page = pageSkillCatalog({
|
|
246
|
+
skills,
|
|
247
|
+
digest,
|
|
248
|
+
start,
|
|
249
|
+
warningAlreadyShown,
|
|
250
|
+
maxChars,
|
|
251
|
+
});
|
|
252
|
+
if (!page) {
|
|
253
|
+
return {
|
|
254
|
+
success: false,
|
|
255
|
+
output: '',
|
|
256
|
+
error: 'The model-visible tool-output budget is too small to list skill metadata safely. Increase maxToolOutputChars and retry.',
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
success: true,
|
|
261
|
+
output: serializeListPage(page),
|
|
262
|
+
data: {
|
|
263
|
+
kind: 'list',
|
|
264
|
+
count: page.skills.length,
|
|
265
|
+
...(page.nextCursor === null ? {} : { nextCursor: page.nextCursor }),
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
67
269
|
// The registry answers with a load RESULT, not a skill — the shape
|
|
68
270
|
// mirrors the implementation rather than an adapter, so there is
|
|
69
271
|
// nothing between them to drift.
|
|
@@ -80,6 +282,7 @@ export const SkillTool = defineTool({
|
|
|
80
282
|
};
|
|
81
283
|
}
|
|
82
284
|
const skill = loaded.skill;
|
|
285
|
+
const invocation = skillInvocation(skill);
|
|
83
286
|
if (!isInvocableBy(skill, 'model')) {
|
|
84
287
|
// Reachable even though the manifest omits it: the model can name
|
|
85
288
|
// anything, and a check that only filtered the listing would be a
|
|
@@ -92,6 +295,49 @@ export const SkillTool = defineTool({
|
|
|
92
295
|
};
|
|
93
296
|
}
|
|
94
297
|
const allowed = parseAllowedTools(skill.metadata.allowedTools);
|
|
298
|
+
const snapshot = {
|
|
299
|
+
name: input.name,
|
|
300
|
+
body: skill.body ?? '(this skill has no body)',
|
|
301
|
+
allowedTools: allowed,
|
|
302
|
+
invocation,
|
|
303
|
+
};
|
|
304
|
+
const digest = snapshotDigest(snapshot);
|
|
305
|
+
let start = 0;
|
|
306
|
+
if (input.cursor !== undefined) {
|
|
307
|
+
const parsed = parseCursor(input.cursor);
|
|
308
|
+
if (!parsed ||
|
|
309
|
+
parsed.digest !== digest ||
|
|
310
|
+
parsed.offset >= snapshot.body.length ||
|
|
311
|
+
!isCodePointBoundary(snapshot.body, parsed.offset)) {
|
|
312
|
+
return {
|
|
313
|
+
success: false,
|
|
314
|
+
output: '',
|
|
315
|
+
error: `The continuation cursor for "${input.name}" is stale or invalid. Call skill again without a cursor to read the current instructions.`,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
start = parsed.offset;
|
|
319
|
+
}
|
|
320
|
+
const notice = allowed === undefined
|
|
321
|
+
? ''
|
|
322
|
+
: `\n\n[While following this skill, restrict yourself to: ${allowed.length > 0 ? allowed.join(', ') : '(no tools)'}. This takes effect from your next turn.]`;
|
|
323
|
+
const page = pageSkillBody({
|
|
324
|
+
snapshot,
|
|
325
|
+
digest,
|
|
326
|
+
start,
|
|
327
|
+
notice,
|
|
328
|
+
maxChars: context.maxToolOutputChars,
|
|
329
|
+
});
|
|
330
|
+
if (!page) {
|
|
331
|
+
return {
|
|
332
|
+
success: false,
|
|
333
|
+
output: '',
|
|
334
|
+
error: `The model-visible tool-output budget is too small to read "${input.name}" safely. Increase maxToolOutputChars and retry.`,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
// Cursor and policy validation must finish before this mutation. A
|
|
338
|
+
// continuation is bound to the body AND its effective authorization
|
|
339
|
+
// metadata, so an edit to allowed-tools or invocation cannot widen the
|
|
340
|
+
// next batch under an old cursor.
|
|
95
341
|
if (allowed !== undefined) {
|
|
96
342
|
// Adopted, not merely announced. The notice below tells the model
|
|
97
343
|
// what happened; this is what makes it true whether or not the
|
|
@@ -104,15 +350,13 @@ export const SkillTool = defineTool({
|
|
|
104
350
|
// advice.
|
|
105
351
|
context.adoptSkillScope?.({ skill: skill.metadata.name, allowedTools: allowed });
|
|
106
352
|
}
|
|
107
|
-
const notice = allowed === undefined
|
|
108
|
-
? ''
|
|
109
|
-
: `\n\n[While following this skill, restrict yourself to: ${allowed.length > 0 ? allowed.join(', ') : '(no tools)'}. This takes effect from your next turn.]`;
|
|
110
353
|
return {
|
|
111
354
|
success: true,
|
|
112
|
-
output:
|
|
355
|
+
output: page.output,
|
|
113
356
|
data: {
|
|
114
357
|
skill: skill.metadata.name,
|
|
115
358
|
...(allowed === undefined ? {} : { allowedTools: allowed }),
|
|
359
|
+
...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }),
|
|
116
360
|
},
|
|
117
361
|
};
|
|
118
362
|
},
|