@dsh-cc/tools 0.5.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/LICENSE +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +209 -0
- package/README.zh.md +200 -0
- package/lib/abort-utils.d.ts +80 -0
- package/lib/abort-utils.d.ts.map +1 -0
- package/lib/abort-utils.js +186 -0
- package/lib/abort-utils.js.map +1 -0
- package/lib/cc-names.d.ts +100 -0
- package/lib/cc-names.d.ts.map +1 -0
- package/lib/cc-names.js +197 -0
- package/lib/cc-names.js.map +1 -0
- package/lib/code-mode.d.ts +46 -0
- package/lib/code-mode.d.ts.map +1 -0
- package/lib/code-mode.js +380 -0
- package/lib/code-mode.js.map +1 -0
- package/lib/define-tool.d.ts +103 -0
- package/lib/define-tool.d.ts.map +1 -0
- package/lib/define-tool.js +354 -0
- package/lib/define-tool.js.map +1 -0
- package/lib/index.d.ts +348 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +289 -0
- package/lib/index.js.map +1 -0
- package/lib/invariant.d.ts +13 -0
- package/lib/invariant.d.ts.map +1 -0
- package/lib/invariant.js +123 -0
- package/lib/invariant.js.map +1 -0
- package/lib/json-render.d.ts +18 -0
- package/lib/json-render.d.ts.map +1 -0
- package/lib/json-render.js +111 -0
- package/lib/json-render.js.map +1 -0
- package/lib/json-schema-value.d.ts +18 -0
- package/lib/json-schema-value.d.ts.map +1 -0
- package/lib/json-schema-value.js +238 -0
- package/lib/json-schema-value.js.map +1 -0
- package/lib/json-schema.d.ts +101 -0
- package/lib/json-schema.d.ts.map +1 -0
- package/lib/json-schema.js +351 -0
- package/lib/json-schema.js.map +1 -0
- package/lib/presentation.d.ts +367 -0
- package/lib/presentation.d.ts.map +1 -0
- package/lib/presentation.js +8 -0
- package/lib/presentation.js.map +1 -0
- package/lib/py-names.d.ts +163 -0
- package/lib/py-names.d.ts.map +1 -0
- package/lib/py-names.js +236 -0
- package/lib/py-names.js.map +1 -0
- package/lib/py-render.d.ts +23 -0
- package/lib/py-render.d.ts.map +1 -0
- package/lib/py-render.js +434 -0
- package/lib/py-render.js.map +1 -0
- package/lib/py-sdk-doc.d.ts +29 -0
- package/lib/py-sdk-doc.d.ts.map +1 -0
- package/lib/py-sdk-doc.js +114 -0
- package/lib/py-sdk-doc.js.map +1 -0
- package/lib/py-types.d.ts +34 -0
- package/lib/py-types.d.ts.map +1 -0
- package/lib/py-types.js +40 -0
- package/lib/py-types.js.map +1 -0
- package/lib/run-code-defs.d.ts +77 -0
- package/lib/run-code-defs.d.ts.map +1 -0
- package/lib/run-code-defs.js +98 -0
- package/lib/run-code-defs.js.map +1 -0
- package/lib/runtime-code.d.ts +65 -0
- package/lib/runtime-code.d.ts.map +1 -0
- package/lib/runtime-code.js +129 -0
- package/lib/runtime-code.js.map +1 -0
- package/lib/runtime-core.d.ts +130 -0
- package/lib/runtime-core.d.ts.map +1 -0
- package/lib/runtime-core.js +33 -0
- package/lib/runtime-core.js.map +1 -0
- package/lib/runtime-execute.d.ts +82 -0
- package/lib/runtime-execute.d.ts.map +1 -0
- package/lib/runtime-execute.js +333 -0
- package/lib/runtime-execute.js.map +1 -0
- package/lib/runtime-registry.d.ts +131 -0
- package/lib/runtime-registry.d.ts.map +1 -0
- package/lib/runtime-registry.js +269 -0
- package/lib/runtime-registry.js.map +1 -0
- package/lib/runtime-results.d.ts +32 -0
- package/lib/runtime-results.d.ts.map +1 -0
- package/lib/runtime-results.js +163 -0
- package/lib/runtime-results.js.map +1 -0
- package/lib/runtime-schemas.d.ts +112 -0
- package/lib/runtime-schemas.d.ts.map +1 -0
- package/lib/runtime-schemas.js +222 -0
- package/lib/runtime-schemas.js.map +1 -0
- package/lib/scheduler.d.ts +22 -0
- package/lib/scheduler.d.ts.map +1 -0
- package/lib/scheduler.js +21 -0
- package/lib/scheduler.js.map +1 -0
- package/lib/schema-spec.d.ts +154 -0
- package/lib/schema-spec.d.ts.map +1 -0
- package/lib/schema-spec.js +9 -0
- package/lib/schema-spec.js.map +1 -0
- package/lib/schema.d.ts +5 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/schema.js +3 -0
- package/lib/schema.js.map +1 -0
- package/lib/testing.d.ts +25 -0
- package/lib/testing.d.ts.map +1 -0
- package/lib/testing.js +25 -0
- package/lib/testing.js.map +1 -0
- package/lib/tool-layer.d.ts +49 -0
- package/lib/tool-layer.d.ts.map +1 -0
- package/lib/tool-layer.js +57 -0
- package/lib/tool-layer.js.map +1 -0
- package/lib/tool-types.d.ts +385 -0
- package/lib/tool-types.d.ts.map +1 -0
- package/lib/tool-types.js +11 -0
- package/lib/tool-types.js.map +1 -0
- package/lib/ts-types.d.ts +37 -0
- package/lib/ts-types.d.ts.map +1 -0
- package/lib/ts-types.js +265 -0
- package/lib/ts-types.js.map +1 -0
- package/lib/types.d.ts +55 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +7 -0
- package/lib/types.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural core shared by the ToolRuntime facade and its free-function
|
|
3
|
+
* collaborator modules: the runtime's state fields plus every method
|
|
4
|
+
* signature the collaborators call through their `rt` parameter. The facade
|
|
5
|
+
* instance satisfies this interface structurally; collaborators stay acyclic
|
|
6
|
+
* at import time — this module imports NO value from `index.ts` (the only
|
|
7
|
+
* value edges here are the leaf SDK renderer table below).
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { renderToolsSdk } from "./ts-types.js";
|
|
11
|
+
import { renderToolsSdkPy } from "./py-types.js";
|
|
12
|
+
import { TOOL_RUNTIME_SCHEDULER } from "./scheduler.js";
|
|
13
|
+
/**
|
|
14
|
+
* Language → SDK-section renderer. The registry looks up the loaded
|
|
15
|
+
* `ctx.codeRuntime.language` in this table when assembling the `tools:sdk`
|
|
16
|
+
* section under a non-native mode; a runtime whose language is not a key
|
|
17
|
+
* fails the assembly loudly (same idiom as `toolOrder` violations). Adding a
|
|
18
|
+
* new backend language is three parallel edits — a {@link CodeSdkLanguage}
|
|
19
|
+
* member, an entry here, and a `RUN_CODE_FLAVORS` entry in `code-mode.ts` for
|
|
20
|
+
* its `run_code` schema strings — plus the renderer function this table points
|
|
21
|
+
* at. The `satisfies` clause pins this table's key set to that union, which
|
|
22
|
+
* the flavor table is checked against too, so any of the three left out is a
|
|
23
|
+
* typecheck failure. What no check reaches is the prose that names the values
|
|
24
|
+
* instead of deriving them: the seam's `dsh-code-runtime` README pair, its
|
|
25
|
+
* `CodeRuntime.language` JSDoc, and `docs/subsystems/code-runtime.md`
|
|
26
|
+
* with its zh pair, plus this package's own README pair and the
|
|
27
|
+
* {@link Config.mode} JSDoc.
|
|
28
|
+
*/
|
|
29
|
+
export const SDK_RENDERERS = {
|
|
30
|
+
typescript: renderToolsSdk,
|
|
31
|
+
python: renderToolsSdkPy,
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=runtime-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-core.js","sourceRoot":"","sources":["../src/runtime-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAKvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAyD;IACjF,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE,gBAAgB;CAC+C,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolRuntime execution-pipeline collaborators: execution creation, the
|
|
3
|
+
* pre-execute/ask/guard policy stages, around-dispatch, and the scheduler's
|
|
4
|
+
* staged entry points. Bodies are verbatim moves from the former `ToolRuntime`
|
|
5
|
+
* methods with `this.` → `rt.`; reverse calls into other clusters (registry
|
|
6
|
+
* resolution, approval ask, result materialization) go through `rt`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { MutableToolRunContext, ScheduledToolDispatch, ScheduledToolPreparation, ToolExecutionInput, ToolExecutionResult, ToolRunContext } from './tool-types.ts';
|
|
10
|
+
import type { ToolRuntimeCore } from './runtime-core.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Execute through pre-policy, guards, around-dispatch, post-policy,
|
|
13
|
+
* definition-owned content finalization, and final notification. Tool and
|
|
14
|
+
* listener failures resolve as materialized error results; an invisible tool
|
|
15
|
+
* reports `UNKNOWN_TOOL`. The returned outcome is the same lossless, frozen
|
|
16
|
+
* snapshot final observers receive. Cancellation
|
|
17
|
+
* arriving after entry and before final result materialization skips a
|
|
18
|
+
* not-yet-started body with `ABORTED_BEFORE_DISPATCH` or replaces a
|
|
19
|
+
* successful started outcome with `ABORTED`; already-started work is still
|
|
20
|
+
* drained and may retain a tool-owned structured error.
|
|
21
|
+
* @param rt - the owning runtime.
|
|
22
|
+
* @param exec - the typed same-process call input. The registry assigns its
|
|
23
|
+
* correlation token before policy begins.
|
|
24
|
+
* @returns the materialized final result.
|
|
25
|
+
*/
|
|
26
|
+
export declare function execute(rt: ToolRuntimeCore, exec: ToolExecutionInput): Promise<ToolExecutionResult>;
|
|
27
|
+
export declare function completeScheduledExecution(rt: ToolRuntimeCore, prepared: ScheduledToolPreparation): Promise<ToolExecutionResult>;
|
|
28
|
+
export declare function createExecution(rt: ToolRuntimeCore, exec: ToolExecutionInput): ScheduledToolPreparation | {
|
|
29
|
+
kind: 'ready';
|
|
30
|
+
exec: MutableToolRunContext;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Run the ordered pre-execute and monotonic guard stages for the scheduler.
|
|
34
|
+
* @param rt - the owning runtime.
|
|
35
|
+
* @param input - the caller-supplied execution input.
|
|
36
|
+
* @returns the prepared execution plus the next scheduler stage.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function prepareScheduledExecution(rt: ToolRuntimeCore, input: ToolExecutionInput): Promise<ScheduledToolPreparation>;
|
|
40
|
+
export declare function prepareExecution<T>(rt: ToolRuntimeCore, input: ToolExecutionInput, next: (prepared: ScheduledToolPreparation) => T | PromiseLike<T>): Promise<T>;
|
|
41
|
+
/** Whether the original caller signal is currently aborted. */
|
|
42
|
+
export declare function callerCancelled(rt: ToolRuntimeCore, exec: ToolRunContext): boolean;
|
|
43
|
+
/** Canonical cancellation outcome selected by whether the tool body started. */
|
|
44
|
+
export declare function cancellationResult(rt: ToolRuntimeCore, exec: ToolRunContext, prior?: ToolExecutionResult): ToolExecutionResult;
|
|
45
|
+
/**
|
|
46
|
+
* Dispatch the registered body with the original caller signal fused back
|
|
47
|
+
* into any around-wrapper replacement. Cancellation never abandons the body:
|
|
48
|
+
* a started promise reaches quiescence before its outcome becomes `ABORTED`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function dispatchToolBody(rt: ToolRuntimeCore, exec: MutableToolRunContext): Promise<ToolExecutionResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Run around-dispatch and the tool body. Tool and unknown-tool failures still
|
|
53
|
+
* receive post-execute; pipeline failures are already final.
|
|
54
|
+
* @param rt - the owning runtime.
|
|
55
|
+
* @param exec - the prepared execution.
|
|
56
|
+
* @returns whether the result still needs post-execute.
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export declare function dispatchScheduledExecution(rt: ToolRuntimeCore, exec: ToolRunContext): Promise<ScheduledToolDispatch>;
|
|
60
|
+
/**
|
|
61
|
+
* Run ordered post-execute, then apply definition-owned content finalization,
|
|
62
|
+
* materialize, and notify the final outcome.
|
|
63
|
+
* @param rt - the owning runtime.
|
|
64
|
+
* @param exec - the prepared execution.
|
|
65
|
+
* @param result - dispatch/pre result that still needs post-execute.
|
|
66
|
+
* @returns the materialized final result.
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export declare function finalizeScheduledExecution(rt: ToolRuntimeCore, exec: ToolRunContext, result: ToolExecutionResult): Promise<ToolExecutionResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Materialize the candidate, apply definition-owned content finalization,
|
|
72
|
+
* then materialize and notify the authoritative result.
|
|
73
|
+
* @param rt - the owning runtime.
|
|
74
|
+
* @param exec - the prepared execution.
|
|
75
|
+
* @param result - final result.
|
|
76
|
+
* @returns the materialized final result.
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export declare function finishScheduledExecution(rt: ToolRuntimeCore, exec: ToolRunContext, result: ToolExecutionResult): ToolExecutionResult;
|
|
80
|
+
/** Apply the snapshotted tool-owned content transform without exposing other result fields. */
|
|
81
|
+
export declare function applyFinalContent(rt: ToolRuntimeCore, exec: ToolRunContext, result: ToolExecutionResult): ToolExecutionResult;
|
|
82
|
+
//# sourceMappingURL=runtime-execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-execute.d.ts","sourceRoot":"","sources":["../src/runtime-execute.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,KAAK,EAAE,qBAAqB,EAAmB,qBAAqB,EAAE,wBAAwB,EAAiC,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEtN,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,OAAO,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAEzG;AAED,wBAAsB,0BAA0B,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgBtI;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,kBAAkB,GAAG,wBAAwB,GAAG;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AgB,iBAAiB,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAK7H"}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolRuntime execution-pipeline collaborators: execution creation, the
|
|
3
|
+
* pre-execute/ask/guard policy stages, around-dispatch, and the scheduler's
|
|
4
|
+
* staged entry points. Bodies are verbatim moves from the former `ToolRuntime`
|
|
5
|
+
* methods with `this.` → `rt.`; reverse calls into other clusters (registry
|
|
6
|
+
* resolution, approval ask, result materialization) go through `rt`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { scopeTarget } from '@deepseek-ai/dsh-scope';
|
|
10
|
+
import { assertNever, deepFreeze } from '@deepseek-ai/dsh-llm';
|
|
11
|
+
import { snapshotJsonValue } from '@deepseek-ai/dsh-session';
|
|
12
|
+
import { createExecutionToken, fuseToolSignals, isAborted, toolAbortedBeforeDispatchResult, toolAbortedResult, toolErrorResult, ToolNotFoundError } from "./abort-utils.js";
|
|
13
|
+
import { RUN_CODE_NAME } from "./code-mode.js";
|
|
14
|
+
/**
|
|
15
|
+
* Execute through pre-policy, guards, around-dispatch, post-policy,
|
|
16
|
+
* definition-owned content finalization, and final notification. Tool and
|
|
17
|
+
* listener failures resolve as materialized error results; an invisible tool
|
|
18
|
+
* reports `UNKNOWN_TOOL`. The returned outcome is the same lossless, frozen
|
|
19
|
+
* snapshot final observers receive. Cancellation
|
|
20
|
+
* arriving after entry and before final result materialization skips a
|
|
21
|
+
* not-yet-started body with `ABORTED_BEFORE_DISPATCH` or replaces a
|
|
22
|
+
* successful started outcome with `ABORTED`; already-started work is still
|
|
23
|
+
* drained and may retain a tool-owned structured error.
|
|
24
|
+
* @param rt - the owning runtime.
|
|
25
|
+
* @param exec - the typed same-process call input. The registry assigns its
|
|
26
|
+
* correlation token before policy begins.
|
|
27
|
+
* @returns the materialized final result.
|
|
28
|
+
*/
|
|
29
|
+
export async function execute(rt, exec) {
|
|
30
|
+
return rt.prepareExecution(exec, prepared => rt.completeScheduledExecution(prepared));
|
|
31
|
+
}
|
|
32
|
+
export async function completeScheduledExecution(rt, prepared) {
|
|
33
|
+
switch (prepared.kind) {
|
|
34
|
+
case 'dispatch': {
|
|
35
|
+
const dispatched = await rt.dispatchScheduledExecution(prepared.exec);
|
|
36
|
+
return dispatched.kind === 'post-result'
|
|
37
|
+
? await rt.finalizeScheduledExecution(prepared.exec, dispatched.result)
|
|
38
|
+
: rt.finishScheduledExecution(prepared.exec, dispatched.result);
|
|
39
|
+
}
|
|
40
|
+
case 'post-result':
|
|
41
|
+
return await rt.finalizeScheduledExecution(prepared.exec, prepared.result);
|
|
42
|
+
case 'final-result':
|
|
43
|
+
return rt.finishScheduledExecution(prepared.exec, prepared.result);
|
|
44
|
+
/* v8 ignore next -- closed-union exhaustiveness guard */
|
|
45
|
+
default:
|
|
46
|
+
return assertNever(prepared, 'scheduled tool preparation');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function createExecution(rt, exec) {
|
|
50
|
+
const deferredContexts = [];
|
|
51
|
+
const token = createExecutionToken();
|
|
52
|
+
const callId = exec.callId;
|
|
53
|
+
const rootCallId = exec.rootCallId ?? callId;
|
|
54
|
+
const name = exec.name;
|
|
55
|
+
const agent = exec.agent;
|
|
56
|
+
const parent = exec.parent;
|
|
57
|
+
const signal = exec.signal;
|
|
58
|
+
// Distinguish a mode-collapsed call (visible in the scope, denied only by
|
|
59
|
+
// the `code` collapse) from a genuinely unknown tool. A collapsed call is
|
|
60
|
+
// deterministically denied, so it terminates BEFORE the extensible policy
|
|
61
|
+
// pipeline: pre-execute listeners, approval `ask`, and guards must never
|
|
62
|
+
// observe — or worse, approve — a call that can only fail. An unknown tool
|
|
63
|
+
// keeps the historical dispatch-stage `UNKNOWN_TOOL` path so policy
|
|
64
|
+
// listeners still see every name that reaches the registry.
|
|
65
|
+
const visible = rt.get(name, agent);
|
|
66
|
+
const collapsed = visible !== undefined && rt.collapses(name, agent, parent !== undefined);
|
|
67
|
+
const concludingExecutions = rt.concludingExecutions;
|
|
68
|
+
const base = {
|
|
69
|
+
token,
|
|
70
|
+
callId,
|
|
71
|
+
rootCallId,
|
|
72
|
+
name,
|
|
73
|
+
signal,
|
|
74
|
+
...agent !== undefined ? { agent } : {},
|
|
75
|
+
...parent !== undefined ? { parent } : {},
|
|
76
|
+
deferContext(context) {
|
|
77
|
+
deferredContexts.push(context);
|
|
78
|
+
},
|
|
79
|
+
concludeTurn() {
|
|
80
|
+
concludingExecutions.add(this);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
// Capture the finalizer BEFORE argument materialization: the
|
|
84
|
+
// `finalizeContent` contract snapshots the callback when the call starts,
|
|
85
|
+
// and an arguments getter can replace or clear the registered callback
|
|
86
|
+
// during `snapshotJsonValue`. The collapse only decides whether the
|
|
87
|
+
// CAPTURED callback is retained: the pre-dispatch abort path keeps it
|
|
88
|
+
// (the cancellation contract routes aborted results through it — a getter
|
|
89
|
+
// that aborts mid-materialization before an invalid-args failure lands in
|
|
90
|
+
// the same retained path), while the `UNKNOWN_TOOL` denial and the
|
|
91
|
+
// invalid-args failure of a NON-ABORTED collapsed call drop it (the call
|
|
92
|
+
// could never execute).
|
|
93
|
+
const capturedFinalizer = visible?.finalizeContent?.bind(visible);
|
|
94
|
+
const finalizerFor = () => collapsed && !signal.aborted ? undefined : capturedFinalizer;
|
|
95
|
+
try {
|
|
96
|
+
const detached = snapshotJsonValue(exec.arguments);
|
|
97
|
+
if (detached === undefined) {
|
|
98
|
+
throw new TypeError('tool execution arguments must be losslessly JSON-serializable');
|
|
99
|
+
}
|
|
100
|
+
const execution = { ...base, arguments: deepFreeze(detached) };
|
|
101
|
+
rt.deferredContexts.set(execution, deferredContexts);
|
|
102
|
+
rt.contentFinalizers.set(execution, finalizerFor());
|
|
103
|
+
rt.cancellationStates.set(execution, {
|
|
104
|
+
callerSignal: signal,
|
|
105
|
+
bodyInvoked: false,
|
|
106
|
+
});
|
|
107
|
+
if (collapsed) {
|
|
108
|
+
// The collapse denies the call before the policy pipeline, but a
|
|
109
|
+
// pre-dispatch abort still keeps the established cancellation
|
|
110
|
+
// contract: `prepare`'s caller-cancellation check is skipped for
|
|
111
|
+
// final-results, so honor the abort here instead of surfacing
|
|
112
|
+
// `UNKNOWN_TOOL` on an already-cancelled call.
|
|
113
|
+
if (signal.aborted) {
|
|
114
|
+
return { kind: 'final-result', exec: execution, result: toolAbortedBeforeDispatchResult() };
|
|
115
|
+
}
|
|
116
|
+
// The name IS visible here, so the denial carries the route the model
|
|
117
|
+
// must take instead. Without it the model reads a bare `unknown tool`
|
|
118
|
+
// for a tool the prompt just declared and concludes the deployment is
|
|
119
|
+
// broken rather than correcting itself.
|
|
120
|
+
return {
|
|
121
|
+
kind: 'final-result',
|
|
122
|
+
exec: execution,
|
|
123
|
+
result: toolErrorResult(new ToolNotFoundError(name, `only \`${RUN_CODE_NAME}\` is callable directly — call \`${name}\` from inside a \`${RUN_CODE_NAME}\` program instead`)),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return { kind: 'ready', exec: execution };
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
const execution = { ...base, arguments: undefined };
|
|
130
|
+
rt.contentFinalizers.set(execution, finalizerFor());
|
|
131
|
+
return { kind: 'final-result', exec: execution, result: toolErrorResult(error) };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Run the ordered pre-execute and monotonic guard stages for the scheduler.
|
|
136
|
+
* @param rt - the owning runtime.
|
|
137
|
+
* @param input - the caller-supplied execution input.
|
|
138
|
+
* @returns the prepared execution plus the next scheduler stage.
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
export async function prepareScheduledExecution(rt, input) {
|
|
142
|
+
return rt.prepareExecution(input, prepared => prepared);
|
|
143
|
+
}
|
|
144
|
+
export async function prepareExecution(rt, input, next) {
|
|
145
|
+
const created = rt.createExecution(input);
|
|
146
|
+
if (created.kind !== 'ready')
|
|
147
|
+
return next(created);
|
|
148
|
+
const exec = created.exec;
|
|
149
|
+
if (rt.callerCancelled(exec)) {
|
|
150
|
+
return next({ kind: 'final-result', exec, result: toolAbortedBeforeDispatchResult() });
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
const carrier = scopeTarget(rt, exec.agent);
|
|
154
|
+
const gate = await rt.ctx.waterfall(carrier, 'tools/pre-execute', exec, () => Promise.resolve({ kind: 'allow' }));
|
|
155
|
+
const askResolution = gate.kind === 'ask'
|
|
156
|
+
? await rt.serviceAsk(exec, gate)
|
|
157
|
+
: { decision: gate, approvalCancelled: false };
|
|
158
|
+
const { decision } = askResolution;
|
|
159
|
+
if (rt.callerCancelled(exec) && askResolution.approvalCancelled) {
|
|
160
|
+
return await next({ kind: 'post-result', exec, result: toolAbortedBeforeDispatchResult() });
|
|
161
|
+
}
|
|
162
|
+
const denialReason = decision.kind === 'allow'
|
|
163
|
+
? rt.guardReason(exec)
|
|
164
|
+
: decision.reason;
|
|
165
|
+
if (denialReason !== undefined) {
|
|
166
|
+
return await next({
|
|
167
|
+
kind: 'post-result',
|
|
168
|
+
exec,
|
|
169
|
+
result: rt.materializeFinalResult({
|
|
170
|
+
content: [{ type: 'text', text: `Error: ${denialReason}` }],
|
|
171
|
+
isError: true,
|
|
172
|
+
error: { message: denialReason },
|
|
173
|
+
}),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
if (rt.callerCancelled(exec)) {
|
|
177
|
+
return await next({ kind: 'post-result', exec, result: toolAbortedBeforeDispatchResult() });
|
|
178
|
+
}
|
|
179
|
+
return await next({ kind: 'dispatch', exec });
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
return next({ kind: 'final-result', exec, result: toolErrorResult(error) });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/** Whether the original caller signal is currently aborted. */
|
|
186
|
+
export function callerCancelled(rt, exec) {
|
|
187
|
+
const state = rt.cancellationStates.get(exec);
|
|
188
|
+
/* v8 ignore next -- only registry-minted executions reach the staged scheduler methods */
|
|
189
|
+
if (state === undefined)
|
|
190
|
+
throw new Error('tool registry scheduler invariant violated: missing cancellation state');
|
|
191
|
+
return state.callerSignal.aborted;
|
|
192
|
+
}
|
|
193
|
+
/** Canonical cancellation outcome selected by whether the tool body started. */
|
|
194
|
+
export function cancellationResult(rt, exec, prior) {
|
|
195
|
+
const state = rt.cancellationStates.get(exec);
|
|
196
|
+
/* v8 ignore next -- only registry-minted executions reach the staged scheduler methods */
|
|
197
|
+
if (state === undefined)
|
|
198
|
+
throw new Error('tool registry scheduler invariant violated: missing cancellation state');
|
|
199
|
+
return state.bodyInvoked
|
|
200
|
+
? toolAbortedResult(prior)
|
|
201
|
+
: toolAbortedBeforeDispatchResult(prior);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Dispatch the registered body with the original caller signal fused back
|
|
205
|
+
* into any around-wrapper replacement. Cancellation never abandons the body:
|
|
206
|
+
* a started promise reaches quiescence before its outcome becomes `ABORTED`.
|
|
207
|
+
*/
|
|
208
|
+
export async function dispatchToolBody(rt, exec) {
|
|
209
|
+
const state = rt.cancellationStates.get(exec);
|
|
210
|
+
/* v8 ignore next -- only registry-minted executions reach the staged scheduler methods */
|
|
211
|
+
if (state === undefined)
|
|
212
|
+
throw new Error('tool registry scheduler invariant violated: missing cancellation state');
|
|
213
|
+
const wrapperSignal = exec.signal;
|
|
214
|
+
const fused = fuseToolSignals(state.callerSignal, wrapperSignal);
|
|
215
|
+
const signal = fused.signal;
|
|
216
|
+
if (isAborted(signal)) {
|
|
217
|
+
fused.dispose();
|
|
218
|
+
return toolAbortedBeforeDispatchResult();
|
|
219
|
+
}
|
|
220
|
+
exec.signal = signal;
|
|
221
|
+
try {
|
|
222
|
+
const tool = rt.resolveExecution(exec.name, exec.agent, exec.parent !== undefined);
|
|
223
|
+
if (!tool)
|
|
224
|
+
throw new ToolNotFoundError(exec.name);
|
|
225
|
+
state.bodyInvoked = true;
|
|
226
|
+
const returned = await tool.execute(exec.arguments, exec);
|
|
227
|
+
const result = rt.createSuccessResult(exec, tool, returned);
|
|
228
|
+
return isAborted(signal)
|
|
229
|
+
? toolAbortedResult(result)
|
|
230
|
+
: result;
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
return toolErrorResult(error);
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
fused.dispose();
|
|
237
|
+
exec.signal = wrapperSignal;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Run around-dispatch and the tool body. Tool and unknown-tool failures still
|
|
242
|
+
* receive post-execute; pipeline failures are already final.
|
|
243
|
+
* @param rt - the owning runtime.
|
|
244
|
+
* @param exec - the prepared execution.
|
|
245
|
+
* @returns whether the result still needs post-execute.
|
|
246
|
+
* @internal
|
|
247
|
+
*/
|
|
248
|
+
export async function dispatchScheduledExecution(rt, exec) {
|
|
249
|
+
try {
|
|
250
|
+
const mutableExec = exec;
|
|
251
|
+
const carrier = scopeTarget(rt, exec.agent);
|
|
252
|
+
const result = await rt.ctx.waterfall(carrier, 'tools/execute', mutableExec, () => rt.dispatchToolBody(mutableExec));
|
|
253
|
+
const normalized = rt.normalizeDispatchResult(exec, result);
|
|
254
|
+
const deferredContexts = rt.deferredContexts.get(exec);
|
|
255
|
+
/* v8 ignore next -- dispatch only receives executions minted by this registry's prepare stage */
|
|
256
|
+
if (deferredContexts === undefined)
|
|
257
|
+
throw new Error('tool registry scheduler invariant violated: unprepared execution');
|
|
258
|
+
const resultWithDeferredContexts = deferredContexts.length === 0
|
|
259
|
+
? normalized
|
|
260
|
+
: rt.markCanonical(exec, {
|
|
261
|
+
...normalized,
|
|
262
|
+
additionalContexts: [
|
|
263
|
+
...deferredContexts,
|
|
264
|
+
...normalized.additionalContexts ?? [],
|
|
265
|
+
],
|
|
266
|
+
});
|
|
267
|
+
return {
|
|
268
|
+
kind: 'post-result',
|
|
269
|
+
result: rt.callerCancelled(exec) && !resultWithDeferredContexts.isError
|
|
270
|
+
? rt.cancellationResult(exec, resultWithDeferredContexts)
|
|
271
|
+
: resultWithDeferredContexts,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
return { kind: 'final-result', result: toolErrorResult(error) };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Run ordered post-execute, then apply definition-owned content finalization,
|
|
280
|
+
* materialize, and notify the final outcome.
|
|
281
|
+
* @param rt - the owning runtime.
|
|
282
|
+
* @param exec - the prepared execution.
|
|
283
|
+
* @param result - dispatch/pre result that still needs post-execute.
|
|
284
|
+
* @returns the materialized final result.
|
|
285
|
+
* @internal
|
|
286
|
+
*/
|
|
287
|
+
export async function finalizeScheduledExecution(rt, exec, result) {
|
|
288
|
+
try {
|
|
289
|
+
const postResult = await rt.postExecute(exec, result);
|
|
290
|
+
return rt.finishScheduledExecution(exec, rt.callerCancelled(exec) && !postResult.isError
|
|
291
|
+
? rt.cancellationResult(exec, postResult)
|
|
292
|
+
: postResult);
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
return rt.finishScheduledExecution(exec, toolErrorResult(error));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Materialize the candidate, apply definition-owned content finalization,
|
|
300
|
+
* then materialize and notify the authoritative result.
|
|
301
|
+
* @param rt - the owning runtime.
|
|
302
|
+
* @param exec - the prepared execution.
|
|
303
|
+
* @param result - final result.
|
|
304
|
+
* @returns the materialized final result.
|
|
305
|
+
* @internal
|
|
306
|
+
*/
|
|
307
|
+
export function finishScheduledExecution(rt, exec, result) {
|
|
308
|
+
let materializedResult;
|
|
309
|
+
try {
|
|
310
|
+
materializedResult = rt.materializeFinalResult(result);
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
materializedResult = rt.materializeFinalResult(toolErrorResult(error));
|
|
314
|
+
}
|
|
315
|
+
let finalResult;
|
|
316
|
+
try {
|
|
317
|
+
finalResult = rt.materializeFinalResult(rt.applyFinalContent(exec, materializedResult));
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
finalResult = rt.materializeFinalResult(toolErrorResult(error));
|
|
321
|
+
}
|
|
322
|
+
rt.notifyResult(exec, finalResult);
|
|
323
|
+
return finalResult;
|
|
324
|
+
}
|
|
325
|
+
/** Apply the snapshotted tool-owned content transform without exposing other result fields. */
|
|
326
|
+
export function applyFinalContent(rt, exec, result) {
|
|
327
|
+
const finalizeContent = rt.contentFinalizers.get(exec);
|
|
328
|
+
if (finalizeContent === undefined)
|
|
329
|
+
return result;
|
|
330
|
+
const content = finalizeContent(exec, result);
|
|
331
|
+
return content === undefined ? result : { ...result, content };
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=runtime-execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-execute.js","sourceRoot":"","sources":["../src/runtime-execute.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,SAAS,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC3K,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAK9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,EAAmB,EAAE,IAAwB;IACzE,OAAO,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,EAA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AAA;AACpB,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,iBAAiB,CAAC,EAAmB,EAAE,IAAoB,EAAE,MAA2B;IACtG,MAAM,eAAe,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACtD,IAAI,eAAe,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IAChD,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC7C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAA;AAChE,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolRuntime registry collaborators: registration, reservation, admission,
|
|
3
|
+
* restriction, guards, and per-scope view resolution. Every function takes
|
|
4
|
+
* the owning runtime as its `rt: ToolRuntimeCore` first parameter; bodies are
|
|
5
|
+
* verbatim moves from the former `ToolRuntime` methods with `this.` → `rt.`.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { ScopeKey } from '@deepseek-ai/dsh-scope';
|
|
9
|
+
import type { ToolDefinition, ToolExecution, ToolExecutionInput, ToolExecutionMode, ToolGuard, ToolRestriction, ToolView } from './tool-types.ts';
|
|
10
|
+
import type { ToolRuntimeCore } from './runtime-core.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Register globally or in the calling agent scope. Scoped tools shadow
|
|
13
|
+
* globals; duplicates within one layer and the reserved `run_code` name fail.
|
|
14
|
+
* @param rt - the owning runtime.
|
|
15
|
+
* @param definition - tool schema, execution, and optional finalization/presentation callbacks.
|
|
16
|
+
* @returns the exact disposer that unregisters the tool.
|
|
17
|
+
*/
|
|
18
|
+
export declare function register(rt: ToolRuntimeCore, definition: ToolDefinition): () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Reserve a capability NAME in the calling layer without registering a
|
|
21
|
+
* visible definition. A reserved name joins the known/restrictable universe
|
|
22
|
+
* — a scope may later `restrict()` it away, and `toolOrder` may list it — but
|
|
23
|
+
* it never reaches the model-facing schema until a real `register()` supplies
|
|
24
|
+
* the definition. This is how a deferred-tool registry seeds the names a
|
|
25
|
+
* composition may gate before their heavy definitions load.
|
|
26
|
+
*
|
|
27
|
+
* The name stays out of the runtime's `get` and `schemas` views (only
|
|
28
|
+
* registered definitions are visible). Duplicate reservations within one
|
|
29
|
+
* layer fail, matching the duplicate-name rule for `register`.
|
|
30
|
+
* @param rt - the owning runtime.
|
|
31
|
+
* @param name - the capability name to make known without presenting.
|
|
32
|
+
* @returns the exact disposer that clears the reservation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function reserve(rt: ToolRuntimeCore, name: string): () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Whether a global tool name passes every scoped restriction on the viewing
|
|
37
|
+
* scope's chain. The answer ignores registration: a reserved or not-yet-loaded
|
|
38
|
+
* name is admitted if no `allow`/`deny` on the chain masks it, so a caller can
|
|
39
|
+
* gate whether a deferred capability may load for one agent. A name masked by
|
|
40
|
+
* an `allow` list it is absent from, or present in a `deny` list, is not
|
|
41
|
+
* admitted. When a name has multiple restrictions, they intersect (all must
|
|
42
|
+
* admit it), matching registration visibility.
|
|
43
|
+
* @param rt - the owning runtime.
|
|
44
|
+
* @param name - the capability name to test.
|
|
45
|
+
* @param scope - the viewing scope (the agent); omitted for the global view, which has no restrictions.
|
|
46
|
+
* @returns whether the name may load for that scope.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isAdmitted(rt: ToolRuntimeCore, name: string, scope?: ScopeKey): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Restrict global tools for the calling agent scope. Empty filters, unknown
|
|
51
|
+
* names, scope-local names, and reserved transport names fail. Restrictions
|
|
52
|
+
* intersect; scoped registrations remain visible.
|
|
53
|
+
* @param rt - the owning runtime.
|
|
54
|
+
* @param filter - global-tool mask: `allow` (keep only) and/or `deny` (remove).
|
|
55
|
+
* @returns the exact disposer that lifts this restriction.
|
|
56
|
+
*/
|
|
57
|
+
export declare function restrict(rt: ToolRuntimeCore, filter: ToolRestriction): () => void;
|
|
58
|
+
/**
|
|
59
|
+
* Register a monotonic guard after the extensible `tools/pre-execute`
|
|
60
|
+
* waterfall. A plain-context guard applies globally; one registered through
|
|
61
|
+
* `agent.ctx` applies only to that agent. Any matching guard may deny by
|
|
62
|
+
* returning a reason, while no guard can force-allow a call another guard
|
|
63
|
+
* denied. The exact effect disposer is returned for ordered ownership and
|
|
64
|
+
* HMR cleanup.
|
|
65
|
+
* @param rt - the owning runtime.
|
|
66
|
+
* @param guard - synchronous check; a returned string denies the execution.
|
|
67
|
+
* @returns the exact disposer that unregisters the guard.
|
|
68
|
+
*/
|
|
69
|
+
export declare function guard(rt: ToolRuntimeCore, guard: ToolGuard): () => void;
|
|
70
|
+
/** First monotonic denial from the global then the scope chain's guard layers, farthest first. */
|
|
71
|
+
export declare function guardReason(rt: ToolRuntimeCore, exec: ToolExecution): string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Resolve every registry fact one scope needs in one layer traversal. The
|
|
74
|
+
* visible map applies restrictions to the INHERITED surface, then the
|
|
75
|
+
* scope's own registrations and the reserved presentation transport; the
|
|
76
|
+
* other sets retain the pre-restriction facts needed by restriction and
|
|
77
|
+
* prompt-order validation.
|
|
78
|
+
*
|
|
79
|
+
* A restriction filters what a scope inherits — the global layer and every
|
|
80
|
+
* ancestor layer on its chain — and never what its OWN layer registers.
|
|
81
|
+
* That exemption is what a per-child capability filter has to keep intact:
|
|
82
|
+
* the delegation runtime registers a child's reporting and structured-output
|
|
83
|
+
* tools into the child's own layer, and a filter naming the capabilities the
|
|
84
|
+
* child may use must not strip the machinery it answers through.
|
|
85
|
+
*
|
|
86
|
+
* Reading the exempt set as "the global layer" instead of "not mine" held
|
|
87
|
+
* only while every model-facing tool sat in the host composition. Once
|
|
88
|
+
* presets moved them onto the agent plane they became an ANCESTOR
|
|
89
|
+
* contribution, so a child's filter silently stopped constraining anything
|
|
90
|
+
* it was given.
|
|
91
|
+
* @param rt - the owning runtime.
|
|
92
|
+
* @param scope - the viewing scope (the agent), or undefined for the global view.
|
|
93
|
+
* @returns the complete derived view for that scope.
|
|
94
|
+
*/
|
|
95
|
+
export declare function view(rt: ToolRuntimeCore, scope?: ScopeKey): ToolView;
|
|
96
|
+
/**
|
|
97
|
+
* Look up a tool as one scope sees it (scoped
|
|
98
|
+
* shadows global; a restricted-away global reads as absent). Presenters pass
|
|
99
|
+
* the calling agent so the rendered card matches the definition that
|
|
100
|
+
* actually executed.
|
|
101
|
+
* @param rt - the owning runtime.
|
|
102
|
+
* @param name - the tool name as registered.
|
|
103
|
+
* @param scope - the viewing scope (the agent); omitted = the global view.
|
|
104
|
+
* @returns the definition the scope resolves, or undefined when none is visible.
|
|
105
|
+
*/
|
|
106
|
+
export declare function get(rt: ToolRuntimeCore, name: string, scope?: ScopeKey): ToolDefinition | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Resolve the definition that MAY EXECUTE for a call, applying the mode
|
|
109
|
+
* collapse at the operation boundary that owns it. The registry view
|
|
110
|
+
* (`get`) is presentation-agnostic; here a MODEL-DIRECT call under `code`
|
|
111
|
+
* may only name the reserved `run_code` transport, while a nested
|
|
112
|
+
* sub-dispatch (a `parent` token set — the `run_code` SDK calling a tool
|
|
113
|
+
* it bound) may call any visible tool. Denial surfaces as `UNKNOWN_TOOL`
|
|
114
|
+
* through the executor, matching an absent definition.
|
|
115
|
+
* @param rt - the owning runtime.
|
|
116
|
+
* @param name - the tool name as registered.
|
|
117
|
+
* @param scope - the viewing scope (the agent); omitted = the global view.
|
|
118
|
+
* @param nested - whether the call is a transport sub-dispatch, not a model-direct call.
|
|
119
|
+
* @returns the definition that may run, or undefined when the call must be rejected.
|
|
120
|
+
*/
|
|
121
|
+
export declare function resolveExecution(rt: ToolRuntimeCore, name: string, scope: ScopeKey | undefined, nested: boolean): ToolDefinition | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Classify a pending call through the caller's visible tool definition. Only
|
|
124
|
+
* an exact `true` is parallel; unknown, hidden, undeclared, invalid, or
|
|
125
|
+
* throwing classifiers are exclusive.
|
|
126
|
+
* @param rt - the owning runtime.
|
|
127
|
+
* @param exec - call name, parsed arguments, and optional agent scope.
|
|
128
|
+
* @returns the fail-closed scheduling mode.
|
|
129
|
+
*/
|
|
130
|
+
export declare function executionMode(rt: ToolRuntimeCore, exec: ToolExecutionInput): ToolExecutionMode;
|
|
131
|
+
//# sourceMappingURL=runtime-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-registry.d.ts","sourceRoot":"","sources":["../src/runtime-registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAGtD,OAAO,KAAK,EAA2B,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1K,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,GAAG,MAAM,IAAI,CAyBpF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,IAAI,CASrE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,CAEvF;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,IAAI,CA2BjF;AAED;;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