theorum 0.1.15 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +241 -98
- package/esm/mod.d.ts +57 -28
- package/esm/mod.js +43 -23
- package/esm/src/cli/commands/bench.js +18 -18
- package/esm/src/cli/commands/fuzz-canary.d.ts +13 -0
- package/esm/src/cli/commands/fuzz-canary.js +191 -0
- package/esm/src/cli/commands/fuzz-guardrails.d.ts +3 -5
- package/esm/src/cli/commands/fuzz-guardrails.js +4 -581
- package/esm/src/cli/commands/guardrails-eval.d.ts +14 -0
- package/esm/src/cli/commands/guardrails-eval.js +15 -0
- package/esm/src/cli/commands/profile.js +35 -15
- package/esm/src/cli/commands/run.d.ts +3 -0
- package/esm/src/cli/commands/run.js +23 -32
- package/esm/src/cli/commands/test.d.ts +10 -1
- package/esm/src/cli/commands/test.js +34 -34
- package/esm/src/cli/event-log.d.ts +19 -0
- package/esm/src/cli/event-log.js +147 -0
- package/esm/src/cli/index.js +57 -11
- package/esm/src/cli/matrix/synthesizer.d.ts +10 -12
- package/esm/src/cli/matrix/synthesizer.js +45 -118
- package/esm/src/guardrails/canary-gate.d.ts +21 -0
- package/esm/src/guardrails/canary-gate.js +32 -0
- package/esm/src/guardrails/canary.d.ts +34 -0
- package/esm/src/guardrails/canary.js +150 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +17 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.js +151 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.d.ts +11 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.js +213 -0
- package/esm/src/guardrails/corpus/inbound-payloads.d.ts +10 -0
- package/esm/src/guardrails/corpus/inbound-payloads.js +125 -0
- package/esm/src/guardrails/corpus/live-attacks.d.ts +20 -0
- package/esm/src/guardrails/corpus/live-attacks.js +231 -0
- package/esm/src/guardrails/corpus/mod.d.ts +14 -0
- package/esm/src/guardrails/corpus/mod.js +11 -0
- package/esm/src/guardrails/corpus/secrets.d.ts +17 -0
- package/esm/src/guardrails/corpus/secrets.js +17 -0
- package/esm/src/guardrails/corpus/strings.d.ts +28 -0
- package/esm/src/guardrails/corpus/strings.js +34 -0
- package/esm/src/guardrails/corpus/types.d.ts +38 -0
- package/esm/src/guardrails/corpus/types.js +6 -0
- package/esm/src/guardrails/egress.d.ts +32 -0
- package/esm/src/guardrails/egress.js +87 -0
- package/esm/src/guardrails/error.d.ts +14 -23
- package/esm/src/guardrails/error.js +87 -76
- package/esm/src/guardrails/eval/corpus.d.ts +108 -0
- package/esm/src/guardrails/eval/corpus.js +978 -0
- package/esm/src/guardrails/eval/mod.d.ts +51 -0
- package/esm/src/guardrails/eval/mod.js +133 -0
- package/esm/src/guardrails/eval/score.d.ts +66 -0
- package/esm/src/guardrails/eval/score.js +114 -0
- package/esm/src/guardrails/events.d.ts +25 -0
- package/esm/src/guardrails/events.js +56 -0
- package/esm/src/guardrails/hits.d.ts +24 -0
- package/esm/src/guardrails/hits.js +45 -0
- package/esm/src/guardrails/injection.js +28 -5
- package/esm/src/guardrails/lexicon.d.ts +39 -0
- package/esm/src/guardrails/lexicon.js +200 -0
- package/esm/src/guardrails/live-outbound-gate.d.ts +41 -0
- package/esm/src/guardrails/live-outbound-gate.js +222 -0
- package/esm/src/guardrails/mod.d.ts +30 -6
- package/esm/src/guardrails/mod.js +20 -5
- package/esm/src/guardrails/network.d.ts +19 -0
- package/esm/src/guardrails/network.js +234 -0
- package/esm/src/guardrails/policy.d.ts +35 -0
- package/esm/src/guardrails/policy.js +50 -0
- package/esm/src/guardrails/progressive-yield.d.ts +51 -0
- package/esm/src/guardrails/progressive-yield.js +98 -0
- package/esm/src/guardrails/quota.d.ts +17 -3
- package/esm/src/guardrails/quota.js +18 -4
- package/esm/src/guardrails/sanitize.d.ts +45 -19
- package/esm/src/guardrails/sanitize.js +177 -94
- package/esm/src/guardrails/sensitive.js +2 -1
- package/esm/src/guardrails/serialize.d.ts +35 -0
- package/esm/src/guardrails/serialize.js +58 -0
- package/esm/src/guardrails/testing.d.ts +17 -0
- package/esm/src/guardrails/testing.js +13 -0
- package/esm/src/guardrails/theorum-error.d.ts +12 -0
- package/esm/src/guardrails/theorum-error.js +15 -0
- package/esm/src/guardrails/tool-directives.d.ts +48 -0
- package/esm/src/guardrails/tool-directives.js +124 -0
- package/esm/src/guardrails/tool-result.d.ts +93 -0
- package/esm/src/guardrails/tool-result.js +276 -0
- package/esm/src/guardrails/types.d.ts +291 -0
- package/esm/src/guardrails/types.js +72 -0
- package/esm/src/host/client-turn.d.ts +19 -0
- package/esm/src/host/client-turn.js +36 -0
- package/esm/src/host/mint-trace.d.ts +1 -1
- package/esm/src/host/mod.d.ts +5 -3
- package/esm/src/host/mod.js +4 -3
- package/esm/src/kernel/auth/crypto.d.ts +42 -0
- package/esm/src/kernel/auth/crypto.js +106 -0
- package/esm/src/kernel/auth/mod.d.ts +11 -0
- package/esm/src/kernel/auth/mod.js +11 -0
- package/esm/src/kernel/auth/oauth.d.ts +47 -0
- package/esm/src/kernel/auth/oauth.js +278 -0
- package/esm/src/kernel/auth/types.d.ts +133 -0
- package/esm/src/kernel/auth/types.js +13 -0
- package/esm/src/kernel/engine/delta.d.ts +24 -2
- package/esm/src/kernel/engine/delta.js +478 -39
- package/esm/src/kernel/engine/live-inbound.d.ts +21 -0
- package/esm/src/kernel/engine/live-inbound.js +31 -0
- package/esm/src/kernel/engine/live-ingress.d.ts +19 -0
- package/esm/src/kernel/engine/live-ingress.js +47 -0
- package/esm/src/kernel/engine/repair.js +13 -12
- package/esm/src/kernel/engine/runner/gates.d.ts +1 -1
- package/esm/src/kernel/engine/runner/gates.js +130 -43
- package/esm/src/kernel/engine/runner/mod.d.ts +6 -4
- package/esm/src/kernel/engine/runner/mod.js +192 -53
- package/esm/src/kernel/engine/runner/schema-validation.js +3 -3
- package/esm/src/kernel/engine/runner/stages.d.ts +39 -0
- package/esm/src/kernel/engine/runner/stages.js +89 -0
- package/esm/src/kernel/engine/runner/state.d.ts +31 -0
- package/esm/src/kernel/engine/runner/steps.d.ts +1 -1
- package/esm/src/kernel/engine/runner/steps.js +244 -43
- package/esm/src/kernel/engine/runner/stream.d.ts +9 -3
- package/esm/src/kernel/engine/runner/stream.js +140 -44
- package/esm/src/kernel/engine/session/mod.d.ts +25 -0
- package/esm/src/kernel/engine/session/mod.js +557 -0
- package/esm/src/kernel/interaction-parts.d.ts +14 -0
- package/esm/src/kernel/interaction-parts.js +23 -0
- package/esm/src/kernel/mod.d.ts +21 -10
- package/esm/src/kernel/mod.js +11 -8
- package/esm/src/kernel/profile-graph.d.ts +159 -0
- package/esm/src/kernel/profile-graph.js +156 -0
- package/esm/src/kernel/registry/attachments.d.ts +12 -10
- package/esm/src/kernel/registry/attachments.js +33 -27
- package/esm/src/kernel/registry/catalog.d.ts +25 -24
- package/esm/src/kernel/registry/catalog.js +60 -101
- package/esm/src/kernel/registry/ingress.d.ts +9 -4
- package/esm/src/kernel/registry/ingress.js +97 -75
- package/esm/src/kernel/registry/profile-outputs.d.ts +4 -0
- package/esm/src/kernel/registry/profile-outputs.js +8 -0
- package/esm/src/kernel/registry/profiles.d.ts +55 -12
- package/esm/src/kernel/registry/profiles.js +413 -73
- package/esm/src/kernel/registry/provider-request.js +13 -7
- package/esm/src/kernel/registry/resolve.d.ts +8 -8
- package/esm/src/kernel/registry/resolve.js +169 -154
- package/esm/src/kernel/registry/schemas.js +1 -1
- package/esm/src/kernel/registry/sole-model.d.ts +8 -0
- package/esm/src/kernel/registry/sole-model.js +10 -0
- package/esm/src/kernel/registry/system-prompt.d.ts +10 -0
- package/esm/src/kernel/registry/system-prompt.js +40 -0
- package/esm/src/kernel/registry/system-role.d.ts +8 -0
- package/esm/src/kernel/registry/system-role.js +14 -0
- package/esm/src/kernel/registry/vault.d.ts +12 -7
- package/esm/src/kernel/registry/vault.js +32 -10
- package/esm/src/kernel/schema.d.ts +231 -0
- package/esm/src/kernel/schema.js +607 -0
- package/esm/src/kernel/stages.d.ts +175 -0
- package/esm/src/kernel/stages.js +476 -0
- package/esm/src/kernel/stop.d.ts +78 -19
- package/esm/src/kernel/stop.js +51 -16
- package/esm/src/kernel/tools/events.d.ts +41 -0
- package/esm/src/kernel/tools/events.js +71 -0
- package/esm/src/kernel/tools/execute.d.ts +84 -0
- package/esm/src/kernel/tools/execute.js +614 -0
- package/esm/src/kernel/tools/harness.d.ts +8 -0
- package/esm/src/kernel/tools/harness.js +46 -0
- package/esm/src/kernel/tools/invoke.d.ts +10 -0
- package/esm/src/kernel/tools/invoke.js +101 -0
- package/esm/src/kernel/tools/mod.d.ts +13 -0
- package/esm/src/kernel/tools/mod.js +11 -0
- package/esm/src/kernel/tools/permission.d.ts +15 -0
- package/esm/src/kernel/tools/permission.js +47 -0
- package/esm/src/kernel/tools/project.d.ts +12 -0
- package/esm/src/kernel/tools/project.js +36 -0
- package/esm/src/kernel/tools/registry.d.ts +23 -0
- package/esm/src/kernel/tools/registry.js +81 -0
- package/esm/src/kernel/tools/remote.d.ts +94 -0
- package/esm/src/kernel/tools/remote.js +577 -0
- package/esm/src/kernel/tools/resolve.d.ts +39 -0
- package/esm/src/kernel/tools/resolve.js +283 -0
- package/esm/src/kernel/tools/schema.d.ts +15 -0
- package/esm/src/kernel/tools/schema.js +176 -0
- package/esm/src/kernel/tools/stage-run.d.ts +105 -0
- package/esm/src/kernel/tools/stage-run.js +155 -0
- package/esm/src/kernel/tools/types.d.ts +394 -0
- package/esm/src/kernel/tools/types.js +9 -0
- package/esm/src/kernel/types.d.ts +540 -256
- package/esm/src/kernel/util/find-last.d.ts +2 -0
- package/esm/src/kernel/util/find-last.js +10 -0
- package/esm/src/observability/destinations.d.ts +31 -0
- package/esm/src/observability/destinations.js +67 -0
- package/esm/src/observability/mod.d.ts +10 -3
- package/esm/src/observability/mod.js +6 -2
- package/esm/src/observability/policy.d.ts +27 -0
- package/esm/src/observability/policy.js +80 -0
- package/esm/src/observability/resolve-policy.d.ts +16 -0
- package/esm/src/observability/resolve-policy.js +64 -0
- package/esm/src/observability/trace-attach.d.ts +8 -4
- package/esm/src/observability/trace-attach.js +50 -29
- package/esm/src/observability/trace-record.d.ts +23 -13
- package/esm/src/observability/trace-record.js +96 -39
- package/esm/src/observability/trace-sink.d.ts +19 -0
- package/esm/src/observability/trace-sink.js +10 -0
- package/esm/src/observability/trace-usage.d.ts +10 -3
- package/esm/src/observability/trace-usage.js +70 -17
- package/esm/src/observability/trace.d.ts +18 -7
- package/esm/src/observability/trace.js +34 -17
- package/esm/src/observability/types.d.ts +113 -0
- package/esm/src/observability/types.js +11 -0
- package/esm/src/presets/google/speech-voices.d.ts +11 -0
- package/esm/src/presets/google/speech-voices.js +41 -0
- package/esm/src/presets/google.d.ts +36 -24
- package/esm/src/presets/google.js +50 -63
- package/esm/src/presets/mod.d.ts +2 -2
- package/esm/src/presets/mod.js +1 -1
- package/esm/src/providers/create-provider.d.ts +20 -17
- package/esm/src/providers/create-provider.js +72 -26
- package/esm/src/providers/google/interactions/framing.d.ts +23 -0
- package/esm/src/providers/google/interactions/framing.js +269 -0
- package/esm/src/providers/google/interactions/mod.d.ts +7 -0
- package/esm/src/providers/google/interactions/mod.js +7 -0
- package/esm/src/providers/google/interactions/stream.d.ts +83 -0
- package/esm/src/providers/google/interactions/stream.js +588 -0
- package/esm/src/providers/google/keys.d.ts +26 -0
- package/esm/src/providers/{keys.js → google/keys.js} +19 -31
- package/esm/src/providers/google/live/framing.d.ts +49 -0
- package/esm/src/providers/google/live/framing.js +552 -0
- package/esm/src/providers/google/live/openapi-schema.d.ts +6 -0
- package/esm/src/providers/google/live/openapi-schema.js +46 -0
- package/esm/src/providers/google/live/session.d.ts +25 -0
- package/esm/src/providers/google/live/session.js +134 -0
- package/esm/src/providers/google/live/stream.d.ts +45 -0
- package/esm/src/providers/google/live/stream.js +214 -0
- package/esm/src/providers/google/urls.d.ts +6 -0
- package/esm/src/providers/google/urls.js +6 -0
- package/esm/src/providers/local/local.d.ts +30 -0
- package/esm/src/providers/{local.js → local/local.js} +66 -126
- package/esm/src/providers/local/mod.d.ts +9 -0
- package/esm/src/providers/local/mod.js +9 -0
- package/esm/src/providers/mod.d.ts +6 -3
- package/esm/src/providers/mod.js +3 -1
- package/esm/src/providers/openrouter/cache-control.d.ts +24 -0
- package/esm/src/providers/openrouter/cache-control.js +23 -0
- package/esm/src/providers/openrouter/chat.d.ts +107 -0
- package/esm/src/providers/{openrouter.js → openrouter/chat.js} +117 -231
- package/esm/src/providers/openrouter/image.d.ts +34 -0
- package/esm/src/providers/openrouter/image.js +275 -0
- package/esm/src/providers/openrouter/openai/chat-payload.d.ts +24 -0
- package/esm/src/providers/openrouter/openai/chat-payload.js +82 -0
- package/esm/src/providers/openrouter/openai/compat.d.ts +53 -0
- package/esm/src/providers/openrouter/openai/compat.js +213 -0
- package/esm/src/providers/openrouter/openai/image-payload.d.ts +18 -0
- package/esm/src/providers/openrouter/openai/image-payload.js +90 -0
- package/esm/src/providers/openrouter/openai/sdk-messages.d.ts +22 -0
- package/esm/src/providers/openrouter/openai/sdk-messages.js +122 -0
- package/esm/src/providers/openrouter/resolve-api-key.d.ts +9 -0
- package/esm/src/providers/openrouter/resolve-api-key.js +24 -0
- package/esm/src/providers/openrouter/speech.d.ts +23 -0
- package/esm/src/providers/{speech.js → openrouter/speech.js} +32 -55
- package/esm/src/providers/probe.d.ts +1 -0
- package/esm/src/providers/probe.js +22 -0
- package/esm/src/providers/shared/pcm.d.ts +12 -0
- package/esm/src/providers/{pcm.js → shared/pcm.js} +16 -3
- package/esm/src/providers/shared/sse.d.ts +18 -0
- package/esm/src/providers/shared/sse.js +87 -0
- package/esm/src/providers/shared/tool-args.d.ts +17 -0
- package/esm/src/providers/shared/tool-args.js +45 -0
- package/esm/src/providers/shared/upstream-tap.d.ts +5 -0
- package/esm/src/providers/{google-tap.js → shared/upstream-tap.js} +4 -7
- package/esm/src/providers/shared/upstream-tape.d.ts +6 -0
- package/esm/src/providers/{gemini-tape.js → shared/upstream-tape.js} +12 -22
- package/esm/src/providers/types.d.ts +27 -0
- package/esm/src/providers/types.js +1 -0
- package/package.json +11 -7
- package/docs/cli.md +0 -97
- package/docs/guardrails.md +0 -178
- package/docs/host.md +0 -97
- package/docs/kernel.md +0 -404
- package/docs/observability.md +0 -105
- package/docs/openrouter.md +0 -125
- package/docs/presets-google.md +0 -91
- package/docs/presets.md +0 -88
- package/docs/providers.md +0 -202
- package/docs/streaming.md +0 -96
- package/esm/src/kernel/engine/boundary.d.ts +0 -10
- package/esm/src/kernel/engine/boundary.js +0 -55
- package/esm/src/kernel/engine/runner/tools.d.ts +0 -13
- package/esm/src/kernel/engine/runner/tools.js +0 -198
- package/esm/src/kernel/registry/tools.d.ts +0 -12
- package/esm/src/kernel/registry/tools.js +0 -36
- package/esm/src/providers/expose-for-tests.d.ts +0 -1
- package/esm/src/providers/expose-for-tests.js +0 -25
- package/esm/src/providers/gemini-tape.d.ts +0 -2
- package/esm/src/providers/google-tap.d.ts +0 -3
- package/esm/src/providers/interactions.d.ts +0 -5
- package/esm/src/providers/interactions.js +0 -169
- package/esm/src/providers/keys.d.ts +0 -19
- package/esm/src/providers/local.d.ts +0 -29
- package/esm/src/providers/openrouter-mod.d.ts +0 -13
- package/esm/src/providers/openrouter-mod.js +0 -12
- package/esm/src/providers/openrouter-payload.d.ts +0 -39
- package/esm/src/providers/openrouter-payload.js +0 -195
- package/esm/src/providers/openrouter.d.ts +0 -15
- package/esm/src/providers/pcm.d.ts +0 -7
- package/esm/src/providers/provider.d.ts +0 -15
- package/esm/src/providers/provider.js +0 -202
- package/esm/src/providers/speech.d.ts +0 -23
- package/esm/src/providers/sse.d.ts +0 -7
- package/esm/src/providers/sse.js +0 -55
- package/esm/src/streaming/mod.d.ts +0 -9
- package/esm/src/streaming/mod.js +0 -8
- /package/esm/src/{streaming → host}/readStreamingJsonStringField.d.ts +0 -0
- /package/esm/src/{streaming → host}/readStreamingJsonStringField.js +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool execute wiring around the stage spine: `pre_tool` outcomes (deny, gate,
|
|
3
|
+
* mutate, abort) and `post_tool` inject hand-off.
|
|
4
|
+
*
|
|
5
|
+
* Contract: `docs/contracts/stages.md` (tool execute pipeline).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { lexiconText } from '../../guardrails/lexicon.js';
|
|
10
|
+
import { runStage, stageEventFields } from '../stages.js';
|
|
11
|
+
import { isGateResumeGranted } from './permission.js';
|
|
12
|
+
import { plainToolInput } from './schema.js';
|
|
13
|
+
/** Stage support when only a tool-local `preTool` is present. */
|
|
14
|
+
function defaultToolStageSupport(ctx) {
|
|
15
|
+
return {
|
|
16
|
+
handlers: [],
|
|
17
|
+
profile: ctx.profile,
|
|
18
|
+
step: ctx.turn?.step ?? 1,
|
|
19
|
+
history: () => [],
|
|
20
|
+
injectAllowed: false,
|
|
21
|
+
host: ctx.host,
|
|
22
|
+
signal: ctx.signal,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Tool-local `preTool` (skipped when resume.granted) → host `pre_tool` →
|
|
27
|
+
* mutate re-parse. Emits the gate wire for a host confirm.
|
|
28
|
+
*/
|
|
29
|
+
export async function* runPreToolPipeline(args) {
|
|
30
|
+
const { tool, ctx, base, stages } = args;
|
|
31
|
+
let toolPreTool;
|
|
32
|
+
if (tool.preTool && !isGateResumeGranted(ctx.resume)) {
|
|
33
|
+
toolPreTool = (await tool.preTool(args.input, ctx)) ?? undefined;
|
|
34
|
+
}
|
|
35
|
+
if (!stages && toolPreTool === undefined) {
|
|
36
|
+
return { ok: true, input: args.input };
|
|
37
|
+
}
|
|
38
|
+
const pre = yield* runPreToolStages({
|
|
39
|
+
stages: stages ?? defaultToolStageSupport(ctx),
|
|
40
|
+
toolName: tool.name,
|
|
41
|
+
callId: base.callId ?? '',
|
|
42
|
+
input: args.input,
|
|
43
|
+
toolPreTool,
|
|
44
|
+
});
|
|
45
|
+
if (!pre.ok) {
|
|
46
|
+
if (pre.kind === 'gated')
|
|
47
|
+
yield gateEvent(base, pre.gate);
|
|
48
|
+
return pre;
|
|
49
|
+
}
|
|
50
|
+
if (!pre.mutated)
|
|
51
|
+
return { ok: true, input: pre.input };
|
|
52
|
+
const reparsed = tool.input.safeParse(plainToolInput(pre.input));
|
|
53
|
+
if (!reparsed.success) {
|
|
54
|
+
return {
|
|
55
|
+
ok: false,
|
|
56
|
+
kind: 'failed',
|
|
57
|
+
failure: {
|
|
58
|
+
code: 'invalid_input',
|
|
59
|
+
message: lexiconText('tool.input_invalid_after_mutate'),
|
|
60
|
+
details: reparsed.error.flatten(),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return { ok: true, input: reparsed.data };
|
|
65
|
+
}
|
|
66
|
+
/** Emit `pre_tool`, run tool `preTool` then host handlers, map affordances to an outcome. */
|
|
67
|
+
async function* runPreToolStages(args) {
|
|
68
|
+
const { stages, toolName, callId, input, toolPreTool } = args;
|
|
69
|
+
const applied = yield* runStage({
|
|
70
|
+
stage: 'pre_tool',
|
|
71
|
+
step: stages.step,
|
|
72
|
+
history: stages.history(),
|
|
73
|
+
handlers: [...(toolPreTool !== undefined ? [() => toolPreTool] : []), ...stages.handlers],
|
|
74
|
+
guardrails: stages.profile.guardrails,
|
|
75
|
+
injectAllowed: false,
|
|
76
|
+
host: stages.host,
|
|
77
|
+
signal: stages.signal,
|
|
78
|
+
callId,
|
|
79
|
+
tool: toolName,
|
|
80
|
+
input,
|
|
81
|
+
});
|
|
82
|
+
if (applied.abort) {
|
|
83
|
+
return { ok: false, kind: 'aborted', aborted: applied.abort };
|
|
84
|
+
}
|
|
85
|
+
if (applied.deny) {
|
|
86
|
+
return { ok: false, kind: 'failed', failure: applied.deny };
|
|
87
|
+
}
|
|
88
|
+
if (applied.confirm) {
|
|
89
|
+
const gate = {
|
|
90
|
+
kind: 'confirmation',
|
|
91
|
+
tool: toolName,
|
|
92
|
+
...(applied.confirm.summary ? { summary: applied.confirm.summary } : {}),
|
|
93
|
+
};
|
|
94
|
+
yield stageEventFields('pre_tool', { callId, toolName, callNotStarted: true, gate });
|
|
95
|
+
return { ok: false, kind: 'gated', gate };
|
|
96
|
+
}
|
|
97
|
+
if (applied.mutate && 'input' in applied.mutate) {
|
|
98
|
+
return { ok: true, input: applied.mutate.input, mutated: true };
|
|
99
|
+
}
|
|
100
|
+
return { ok: true, input, mutated: false };
|
|
101
|
+
}
|
|
102
|
+
/** Emit `post_tool`, run host handlers, hand back inject/abort. */
|
|
103
|
+
export async function* runPostToolStages(args) {
|
|
104
|
+
const { stages, toolName, callId, mutable, ...call } = args;
|
|
105
|
+
const applied = yield* runStage({
|
|
106
|
+
...call,
|
|
107
|
+
stage: 'post_tool',
|
|
108
|
+
step: stages.step,
|
|
109
|
+
history: stages.history(),
|
|
110
|
+
handlers: stages.handlers,
|
|
111
|
+
guardrails: stages.profile.guardrails,
|
|
112
|
+
injectAllowed: stages.injectAllowed,
|
|
113
|
+
injectWouldExceedMaxSteps: stages.injectWouldExceedMaxSteps,
|
|
114
|
+
mutable,
|
|
115
|
+
host: stages.host,
|
|
116
|
+
signal: stages.signal,
|
|
117
|
+
callId,
|
|
118
|
+
tool: toolName,
|
|
119
|
+
});
|
|
120
|
+
const terminal = {
|
|
121
|
+
...(applied.abort !== undefined ? { abort: applied.abort } : {}),
|
|
122
|
+
...(applied.deny ? { deny: applied.deny } : {}),
|
|
123
|
+
...(applied.mutate && 'output' in applied.mutate ? { mutate: applied.mutate } : {}),
|
|
124
|
+
};
|
|
125
|
+
if (applied.inject.length === 0)
|
|
126
|
+
return terminal;
|
|
127
|
+
// Prefer returning inject for the runner to apply after recording the provider
|
|
128
|
+
// tool result (Interactions continuation must exist first). When applyInject is
|
|
129
|
+
// set the caller wants immediate apply (e.g. invokeTool).
|
|
130
|
+
if (stages.applyInject) {
|
|
131
|
+
stages.applyInject(applied.inject);
|
|
132
|
+
return terminal;
|
|
133
|
+
}
|
|
134
|
+
return { ...terminal, inject: applied.inject };
|
|
135
|
+
}
|
|
136
|
+
function gateEvent(base, gate) {
|
|
137
|
+
return {
|
|
138
|
+
type: 'tool',
|
|
139
|
+
tool: {
|
|
140
|
+
...base,
|
|
141
|
+
phase: 'gate',
|
|
142
|
+
gate,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/** Emit observe `pre_tool` (callNotStarted) then the tool `gate` wire. */
|
|
147
|
+
export async function* emitGateSettlement(args) {
|
|
148
|
+
yield stageEventFields('pre_tool', {
|
|
149
|
+
callId: args.callId,
|
|
150
|
+
toolName: args.toolName,
|
|
151
|
+
callNotStarted: true,
|
|
152
|
+
gate: args.gate,
|
|
153
|
+
});
|
|
154
|
+
yield gateEvent(args.base, args.gate);
|
|
155
|
+
}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool registry types — single catalog, shared execution.
|
|
3
|
+
*
|
|
4
|
+
* Closed unions (`TOOL_*`) live in `../schema.ts`. This module owns the
|
|
5
|
+
* structural contracts built on those unions.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { z } from 'zod';
|
|
10
|
+
import type { GuardrailHit, Provenance, TurnTaint } from '../../guardrails/types.js';
|
|
11
|
+
import type { ToolCredential } from '../auth/types.js';
|
|
12
|
+
import type { AuthUnauthenticatedPolicy, HttpMethod, ToolAccess, ToolAuthType, ToolGateKind, ToolLoadTier, ToolPermission } from '../schema.js';
|
|
13
|
+
import type { InteractionPart, Profile, ToolId, TurnInput } from '../types.js';
|
|
14
|
+
export type { AuthUnauthenticatedPolicy, HttpMethod, ToolAccess, ToolAuthType, ToolGateKind, ToolPermission, };
|
|
15
|
+
export interface ToolLabels {
|
|
16
|
+
activity?: string;
|
|
17
|
+
activityPast?: string;
|
|
18
|
+
hiddenFromSettings?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ToolBase {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
category: string;
|
|
24
|
+
access: ToolAccess;
|
|
25
|
+
paths: string[];
|
|
26
|
+
loadTier: ToolLoadTier;
|
|
27
|
+
permission: ToolPermission;
|
|
28
|
+
labels?: ToolLabels;
|
|
29
|
+
}
|
|
30
|
+
export interface BuiltinWire {
|
|
31
|
+
interactions?: string;
|
|
32
|
+
openRouter?: string;
|
|
33
|
+
live?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface BuiltinToolDef extends ToolBase {
|
|
36
|
+
type: 'builtin';
|
|
37
|
+
wire: BuiltinWire;
|
|
38
|
+
conflictsWith?: string[];
|
|
39
|
+
/** When enabled, select the paid Vault key slot unless model.spec.key overrides. */
|
|
40
|
+
forcePaidKey?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface InteractiveRender {
|
|
43
|
+
kind: string;
|
|
44
|
+
prompt: string;
|
|
45
|
+
options?: string[];
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
export interface InvokeToolResume {
|
|
49
|
+
/**
|
|
50
|
+
* Legacy interactive value — unused for gates / ask_user answers.
|
|
51
|
+
* @deprecated Prefer a new user turn for ask_user answers.
|
|
52
|
+
*/
|
|
53
|
+
value?: unknown;
|
|
54
|
+
/**
|
|
55
|
+
* Gate resume:
|
|
56
|
+
* - `true` — skip confirm / permission / `preTool` re-ask and run the body
|
|
57
|
+
* - `false` — settle as deny (synthetic failure + `post_tool`, no body)
|
|
58
|
+
* - omit — first attempt (or auth credential retry without grant)
|
|
59
|
+
*/
|
|
60
|
+
granted?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface ToolContext {
|
|
63
|
+
profile: Profile;
|
|
64
|
+
callId: string;
|
|
65
|
+
sessionPermissions?: string[];
|
|
66
|
+
path?: string;
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
/** Turn-scoped facts: the step index and what this turn has already ingested. */
|
|
69
|
+
turn?: {
|
|
70
|
+
step: number;
|
|
71
|
+
taint?: TurnTaint;
|
|
72
|
+
};
|
|
73
|
+
resume?: InvokeToolResume;
|
|
74
|
+
credentials?: Record<string, ToolCredential>;
|
|
75
|
+
/** Opaque application context from `TurnRequest.host` / `InvokeToolRequest.host`; the kernel never reads it. */
|
|
76
|
+
host?: unknown;
|
|
77
|
+
}
|
|
78
|
+
export interface ToolFailure {
|
|
79
|
+
code: string;
|
|
80
|
+
message: string;
|
|
81
|
+
details?: unknown;
|
|
82
|
+
}
|
|
83
|
+
export interface ToolPause {
|
|
84
|
+
kind: 'interactive' | 'confirmation' | 'permission' | 'auth';
|
|
85
|
+
tool: string;
|
|
86
|
+
render?: InteractiveRender;
|
|
87
|
+
summary?: string;
|
|
88
|
+
input: unknown;
|
|
89
|
+
permission?: ToolPermission;
|
|
90
|
+
/** Auth challenge metadata when kind is 'auth' */
|
|
91
|
+
authChallenge?: {
|
|
92
|
+
slot: string;
|
|
93
|
+
authType: ToolAuthType;
|
|
94
|
+
message: string;
|
|
95
|
+
authorizationUrl?: string;
|
|
96
|
+
state?: string;
|
|
97
|
+
issuer?: string;
|
|
98
|
+
resource?: string;
|
|
99
|
+
requiredScopes?: string[];
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Confirm-to-run / permission / auth gate (stages contract).
|
|
104
|
+
* Not ask_user / awaiting — those complete the tool. Replaces ToolPause for gates.
|
|
105
|
+
*/
|
|
106
|
+
export interface ToolGate {
|
|
107
|
+
kind: ToolGateKind;
|
|
108
|
+
tool: string;
|
|
109
|
+
permission?: ToolPermission;
|
|
110
|
+
summary?: string;
|
|
111
|
+
authChallenge?: NonNullable<ToolPause['authChallenge']>;
|
|
112
|
+
}
|
|
113
|
+
export interface ToolWarning {
|
|
114
|
+
code: string;
|
|
115
|
+
message: string;
|
|
116
|
+
severity?: 'info' | 'warning' | 'error';
|
|
117
|
+
}
|
|
118
|
+
export interface ToolTraceStep {
|
|
119
|
+
name: string;
|
|
120
|
+
kind: string;
|
|
121
|
+
status: string;
|
|
122
|
+
inputs?: Record<string, unknown>;
|
|
123
|
+
outputs?: Record<string, unknown>;
|
|
124
|
+
}
|
|
125
|
+
export type ToolStreamEvent<TOut = unknown> = {
|
|
126
|
+
kind: 'progress';
|
|
127
|
+
data: unknown;
|
|
128
|
+
} | {
|
|
129
|
+
kind: 'trace';
|
|
130
|
+
step: ToolTraceStep;
|
|
131
|
+
} | {
|
|
132
|
+
kind: 'artifact';
|
|
133
|
+
artifact: unknown;
|
|
134
|
+
} | {
|
|
135
|
+
kind: 'warning';
|
|
136
|
+
warning: ToolWarning;
|
|
137
|
+
} | {
|
|
138
|
+
kind: 'complete';
|
|
139
|
+
output: TOut;
|
|
140
|
+
};
|
|
141
|
+
export type SyncToolHandler<TIn, TOut> = (input: TIn, ctx: ToolContext) => TOut | Promise<TOut>;
|
|
142
|
+
export type StreamToolHandler<TIn, TOut> = (input: TIn, ctx: ToolContext) => AsyncGenerator<ToolStreamEvent<TOut>>;
|
|
143
|
+
export type ToolHandler<TIn, TOut> = SyncToolHandler<TIn, TOut> | StreamToolHandler<TIn, TOut>;
|
|
144
|
+
/**
|
|
145
|
+
* Host lifecycle hooks and JSON schemas shared by every kernel-executed tool.
|
|
146
|
+
*
|
|
147
|
+
* Only members that depend on `TIn` live here. `input` and `output` stay declared
|
|
148
|
+
* on each concrete tool so `TOut` is still inferred from `output` rather than from
|
|
149
|
+
* a handler's return type — moving them here silently breaks inference for stream
|
|
150
|
+
* handlers. Builtins are provider-native and do not extend this.
|
|
151
|
+
*/
|
|
152
|
+
export interface ToolHostHooks<TIn = unknown> {
|
|
153
|
+
inputSchema: Record<string, unknown>;
|
|
154
|
+
outputSchema: Record<string, unknown>;
|
|
155
|
+
/**
|
|
156
|
+
* Tool-local `pre_tool` registrant (`docs/contracts/stages.md`).
|
|
157
|
+
* Runs before host `onStage` for `pre_tool`. May return deny / confirm / mutate.
|
|
158
|
+
*/
|
|
159
|
+
preTool?: (input: TIn, ctx: ToolContext) => import('../stages.js').StageResult | undefined | Promise<import('../stages.js').StageResult | undefined>;
|
|
160
|
+
exposeToModel?: boolean;
|
|
161
|
+
}
|
|
162
|
+
export interface FunctionToolDef<TIn = unknown, TOut = unknown> extends ToolBase, ToolHostHooks<TIn> {
|
|
163
|
+
type: 'function';
|
|
164
|
+
input: z.ZodType<TIn>;
|
|
165
|
+
output: z.ZodType<TOut>;
|
|
166
|
+
handler: ToolHandler<TIn, TOut>;
|
|
167
|
+
}
|
|
168
|
+
export interface HttpToolAuthConfig {
|
|
169
|
+
slot: string;
|
|
170
|
+
type: ToolAuthType;
|
|
171
|
+
headerName?: string;
|
|
172
|
+
headerPrefix?: string;
|
|
173
|
+
onUnauthenticated?: AuthUnauthenticatedPolicy;
|
|
174
|
+
/** Pre-resolved AS/resource metadata to bypass network discovery */
|
|
175
|
+
preResolved?: {
|
|
176
|
+
issuer?: string;
|
|
177
|
+
authorizationEndpoint?: string;
|
|
178
|
+
tokenEndpoint?: string;
|
|
179
|
+
resource?: string;
|
|
180
|
+
};
|
|
181
|
+
scopes?: string[];
|
|
182
|
+
clientId?: string;
|
|
183
|
+
redirectUri?: string;
|
|
184
|
+
}
|
|
185
|
+
export interface HttpToolDef<TIn = unknown, TOut = unknown> extends ToolBase, ToolHostHooks<TIn> {
|
|
186
|
+
type: 'http';
|
|
187
|
+
input: z.ZodType<TIn>;
|
|
188
|
+
output: z.ZodType<TOut>;
|
|
189
|
+
endpoint: string;
|
|
190
|
+
method: HttpMethod;
|
|
191
|
+
headers?: Record<string, string>;
|
|
192
|
+
auth?: HttpToolAuthConfig;
|
|
193
|
+
mapping?: {
|
|
194
|
+
pathParams?: string[];
|
|
195
|
+
queryParams?: string[];
|
|
196
|
+
bodyParam?: string;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export interface McpToolDef<TIn = unknown, TOut = unknown> extends ToolBase, ToolHostHooks<TIn> {
|
|
200
|
+
type: 'mcp';
|
|
201
|
+
input: z.ZodType<TIn>;
|
|
202
|
+
output: z.ZodType<TOut>;
|
|
203
|
+
serverUrl: string;
|
|
204
|
+
mcpToolName: string;
|
|
205
|
+
headers?: Record<string, string>;
|
|
206
|
+
auth?: HttpToolAuthConfig;
|
|
207
|
+
}
|
|
208
|
+
export type RegisteredTool<TIn = unknown, TOut = unknown> = BuiltinToolDef | FunctionToolDef<TIn, TOut> | HttpToolDef<TIn, TOut> | McpToolDef<TIn, TOut>;
|
|
209
|
+
export type ToolDefinitionInput<TIn = unknown, TOut = unknown> = BuiltinToolDef | (Omit<FunctionToolDef<TIn, TOut>, 'inputSchema' | 'outputSchema'> & {
|
|
210
|
+
input: z.ZodType<TIn>;
|
|
211
|
+
output: z.ZodType<TOut>;
|
|
212
|
+
}) | (Omit<HttpToolDef<TIn, TOut>, 'inputSchema' | 'outputSchema'> & {
|
|
213
|
+
input: z.ZodType<TIn>;
|
|
214
|
+
output: z.ZodType<TOut>;
|
|
215
|
+
}) | (Omit<McpToolDef<TIn, TOut>, 'inputSchema' | 'outputSchema'> & {
|
|
216
|
+
input: z.ZodType<TIn>;
|
|
217
|
+
output: z.ZodType<TOut>;
|
|
218
|
+
});
|
|
219
|
+
export interface WireFunctionTool {
|
|
220
|
+
type: 'function';
|
|
221
|
+
name: string;
|
|
222
|
+
description: string;
|
|
223
|
+
parameters: Record<string, unknown>;
|
|
224
|
+
}
|
|
225
|
+
export interface TurnToolSnapshot {
|
|
226
|
+
builtins: ToolId[];
|
|
227
|
+
/** Tool ids eligible this turn (custom: allow + path; builtin: model builtInTools + path). */
|
|
228
|
+
gated: ToolId[];
|
|
229
|
+
/** Schemas sent to the provider (respects loadTier + t2Loader promotion). */
|
|
230
|
+
visible: ToolId[];
|
|
231
|
+
/** Kernel-executable tools: eligible, visible, and loaded (excludes builtins). */
|
|
232
|
+
executable: ToolId[];
|
|
233
|
+
path?: string;
|
|
234
|
+
sessionPermissions?: string[];
|
|
235
|
+
wire: WireFunctionTool[];
|
|
236
|
+
}
|
|
237
|
+
export interface PromoteLoadedResult {
|
|
238
|
+
promoted: ToolId[];
|
|
239
|
+
failure?: ToolFailure;
|
|
240
|
+
}
|
|
241
|
+
/** Context for profile T1 tool selection via `profile.tools.t1Policy`. */
|
|
242
|
+
export interface ToolLoadContext {
|
|
243
|
+
profile: Profile;
|
|
244
|
+
input?: TurnInput;
|
|
245
|
+
path?: string;
|
|
246
|
+
sessionPermissions?: string[];
|
|
247
|
+
/** Tool ids eligible this turn. */
|
|
248
|
+
gated: ToolId[];
|
|
249
|
+
/** Opaque application context from `TurnRequest.host`; the kernel never reads it. */
|
|
250
|
+
host?: unknown;
|
|
251
|
+
}
|
|
252
|
+
/** Profile-owned T1 selection — which eligible T1 tools to wire at turn start. */
|
|
253
|
+
export type ToolPolicy = (ctx: ToolLoadContext) => ToolId[] | Promise<ToolId[]>;
|
|
254
|
+
export interface InvokeToolRequest {
|
|
255
|
+
profile: string;
|
|
256
|
+
name: string;
|
|
257
|
+
input: unknown;
|
|
258
|
+
/** Turn input context for `profile.tools.t1Policy` selection (same as `TurnRequest.input`). */
|
|
259
|
+
turnInput?: TurnInput;
|
|
260
|
+
/**
|
|
261
|
+
* T2 tools already promoted for this invoke (e.g. restored from pause metadata).
|
|
262
|
+
* Host must have run tools.t2Loader (or equivalent) before listing ids here.
|
|
263
|
+
*/
|
|
264
|
+
promoted?: ToolId[];
|
|
265
|
+
/** Selected model id — same as `TurnRequest.model` (builtins resolve from that model). */
|
|
266
|
+
model?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Optional turn snapshot from a gated turn. Cloned before use so concurrent host
|
|
269
|
+
* invokes do not share mutable visibility state.
|
|
270
|
+
*/
|
|
271
|
+
snapshot?: TurnToolSnapshot;
|
|
272
|
+
resume?: InvokeToolResume;
|
|
273
|
+
sessionPermissions?: string[];
|
|
274
|
+
/** Host credentials for authenticated HTTP / MCP tools keyed by auth slot. */
|
|
275
|
+
credentials?: Record<string, ToolCredential>;
|
|
276
|
+
path?: string;
|
|
277
|
+
signal?: AbortSignal;
|
|
278
|
+
/** Opaque application context handed to the tool as `ctx.host`; the kernel never reads it. */
|
|
279
|
+
host?: unknown;
|
|
280
|
+
/**
|
|
281
|
+
* Optional stage handler for this invoke — `pre_tool` / `post_tool` only
|
|
282
|
+
* (`docs/contracts/stages.md`).
|
|
283
|
+
*/
|
|
284
|
+
onStage?: import('../stages.js').StageHandler;
|
|
285
|
+
}
|
|
286
|
+
export interface ProfileToolsSpec {
|
|
287
|
+
/** Custom function tools this profile may run. Builtins live on models.*.builtInTools. */
|
|
288
|
+
allow: ToolId[];
|
|
289
|
+
/**
|
|
290
|
+
* Optional T1 policy — returns which eligible T1 tools to wire at turn start.
|
|
291
|
+
* Tools must already be on `allow` (custom) or `builtInTools` (builtin) and `loadTier: 'T1'`.
|
|
292
|
+
* Not supported on `type: 'live'` (Gemini Live wires declarations once at session setup).
|
|
293
|
+
*/
|
|
294
|
+
t1Policy?: ToolPolicy;
|
|
295
|
+
/**
|
|
296
|
+
* Optional designated function tool id for T2 promotion.
|
|
297
|
+
* Must be in `allow`. When that tool completes with `{ loaded: string[] }`, those T2 ids are promoted.
|
|
298
|
+
* Not supported on `type: 'live'`.
|
|
299
|
+
*/
|
|
300
|
+
t2Loader?: ToolId;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Live session tools — Gemini Live (and similar) fix function declarations at setup.
|
|
304
|
+
*
|
|
305
|
+
* Shape excludes `t1Policy` / `t2Loader`. Every id in `allow` (and each model's
|
|
306
|
+
* `builtInTools`) is wired at session setup regardless of `loadTier` —
|
|
307
|
+
* declarations cannot be added mid-session, so on live every allowed tool is
|
|
308
|
+
* effectively T0.
|
|
309
|
+
*/
|
|
310
|
+
export interface LiveProfileToolsSpec {
|
|
311
|
+
/** Custom tools wired once at session setup (every load tier). */
|
|
312
|
+
allow: ToolId[];
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Host profile tools — the explicit ceiling for host-driven `invokeTool` calls.
|
|
316
|
+
* Every id in `allow` is executable with no visibility tiers and no path gating.
|
|
317
|
+
*/
|
|
318
|
+
export interface HostProfileToolsSpec {
|
|
319
|
+
/** Custom function tools the host may invoke. */
|
|
320
|
+
allow: ToolId[];
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* What a tool body produced, before settlement projects, guards, and runs
|
|
324
|
+
* `post_tool`. Every transport returns this; one settlement consumes it.
|
|
325
|
+
*/
|
|
326
|
+
export type ToolBodyOutcome = {
|
|
327
|
+
kind: 'ok';
|
|
328
|
+
outputRaw: unknown;
|
|
329
|
+
modelResult: ModelToolResult;
|
|
330
|
+
} | {
|
|
331
|
+
kind: 'gated';
|
|
332
|
+
gate: ToolGate;
|
|
333
|
+
} | {
|
|
334
|
+
kind: 'aborted';
|
|
335
|
+
aborted: true | {
|
|
336
|
+
reason?: string;
|
|
337
|
+
};
|
|
338
|
+
} | {
|
|
339
|
+
kind: 'failed';
|
|
340
|
+
failure: ToolFailure;
|
|
341
|
+
/** True when the body never ran. */
|
|
342
|
+
callNotStarted: boolean;
|
|
343
|
+
};
|
|
344
|
+
export interface ModelToolResult {
|
|
345
|
+
finding: string;
|
|
346
|
+
/** Lean JSON for model reasoning — must not carry media bytes. */
|
|
347
|
+
data?: unknown;
|
|
348
|
+
/**
|
|
349
|
+
* Multimodal tool-result parts (text / image / audio / video / document).
|
|
350
|
+
* Adapters wire these with the same fidelity as user input parts.
|
|
351
|
+
*/
|
|
352
|
+
parts?: InteractionPart[];
|
|
353
|
+
/**
|
|
354
|
+
* Model-facing text, already fenced and redacted at the tool boundary.
|
|
355
|
+
*
|
|
356
|
+
* Set by `executeRegisteredTool`, which knows the tool's origin and the
|
|
357
|
+
* profile's policy. `formatToolResult` prefers it; when it is absent — a host
|
|
358
|
+
* formatting a recorded result outside the execution path — that function
|
|
359
|
+
* guards the composed text itself under full detection.
|
|
360
|
+
*/
|
|
361
|
+
modelText?: string;
|
|
362
|
+
/** Where these bytes came from. Set alongside `modelText`. */
|
|
363
|
+
provenance?: Provenance;
|
|
364
|
+
/** Directive signals found in the content; raises the turn's taint. */
|
|
365
|
+
suspicious?: GuardrailHit[];
|
|
366
|
+
}
|
|
367
|
+
export type ToolCallPhase = 'running' | 'progress' | 'trace' | 'artifact' | 'warning' | 'complete'
|
|
368
|
+
/**
|
|
369
|
+
* @deprecated Shipping interactive/confirm pause. Target: `gate` for
|
|
370
|
+
* confirm/permission/auth; awaiting is `complete` + awaiting payload.
|
|
371
|
+
*/
|
|
372
|
+
| 'pause'
|
|
373
|
+
/** pre_tool confirm / permission / auth — body did not run. */
|
|
374
|
+
| 'gate' | 'error'
|
|
375
|
+
/** Provider cancelled an in-flight tool call (e.g. live barge-in). */
|
|
376
|
+
| 'cancel';
|
|
377
|
+
export interface ToolCallEvent {
|
|
378
|
+
name: string;
|
|
379
|
+
/** Provider-native id or kernel-assigned call id. */
|
|
380
|
+
callId?: string;
|
|
381
|
+
arguments?: Record<string, unknown>;
|
|
382
|
+
/** Absent on raw provider tool-call events; set by kernel execution. */
|
|
383
|
+
phase?: ToolCallPhase;
|
|
384
|
+
data?: unknown;
|
|
385
|
+
step?: ToolTraceStep;
|
|
386
|
+
artifact?: unknown;
|
|
387
|
+
warning?: ToolWarning;
|
|
388
|
+
output?: unknown;
|
|
389
|
+
/** @deprecated Target: `gate` for confirm/permission/auth. */
|
|
390
|
+
pause?: ToolPause;
|
|
391
|
+
/** pre_tool gate — body did not run. */
|
|
392
|
+
gate?: ToolGate;
|
|
393
|
+
failure?: ToolFailure;
|
|
394
|
+
}
|