@inhuman.tools/turn 0.2.0 → 0.3.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/README.md +38 -0
- package/dist/agent-calls/acceptance.d.ts +1 -1
- package/dist/agent-calls/acceptance.d.ts.map +1 -1
- package/dist/agent-calls/acceptance.js +1 -1
- package/dist/agent-calls/acceptance.js.map +1 -1
- package/dist/agent-calls/callbacks.d.ts +1 -1
- package/dist/agent-calls/callbacks.d.ts.map +1 -1
- package/dist/agent-calls/callbacks.js +1 -1
- package/dist/agent-calls/callbacks.js.map +1 -1
- package/dist/agent-calls/delivery.d.ts +1 -1
- package/dist/agent-calls/delivery.d.ts.map +1 -1
- package/dist/agent-calls/delivery.js +1 -1
- package/dist/agent-calls/delivery.js.map +1 -1
- package/dist/agent-calls/operator.d.ts +1 -1
- package/dist/agent-calls/operator.d.ts.map +1 -1
- package/dist/agent-calls/operator.js +1 -1
- package/dist/agent-calls/operator.js.map +1 -1
- package/dist/agent-calls/runtime.d.ts +4 -2
- package/dist/agent-calls/runtime.d.ts.map +1 -1
- package/dist/agent-calls/runtime.js +17 -11
- package/dist/agent-calls/runtime.js.map +1 -1
- package/dist/agent-calls/types.d.ts +1 -1
- package/dist/agent-calls/types.d.ts.map +1 -1
- package/dist/context/compact-floors.d.ts +1 -1
- package/dist/context/compact-floors.d.ts.map +1 -1
- package/dist/context/compact.d.ts +1 -1
- package/dist/context/compact.d.ts.map +1 -1
- package/dist/context/compact.js +5 -4
- package/dist/context/compact.js.map +1 -1
- package/dist/context/history.d.ts +1 -1
- package/dist/context/history.d.ts.map +1 -1
- package/dist/context/history.js +35 -3
- package/dist/context/history.js.map +1 -1
- package/dist/context/retention/defaults.js +1 -1
- package/dist/context/retention/defaults.js.map +1 -1
- package/dist/context/retention/resolve.js +1 -1
- package/dist/context/retention/resolve.js.map +1 -1
- package/dist/context/retention/schema.js +1 -1
- package/dist/context/retention/schema.js.map +1 -1
- package/dist/context/retention/stamp.d.ts +1 -1
- package/dist/context/retention/stamp.d.ts.map +1 -1
- package/dist/context/retention/stamp.js +5 -2
- package/dist/context/retention/stamp.js.map +1 -1
- package/dist/context/retention/step.d.ts +1 -1
- package/dist/context/retention/step.d.ts.map +1 -1
- package/dist/context/retention/step.js +7 -4
- package/dist/context/retention/step.js.map +1 -1
- package/dist/context/retention/view.d.ts +1 -1
- package/dist/context/retention/view.d.ts.map +1 -1
- package/dist/context/retention/view.js +1 -1
- package/dist/context/retention/view.js.map +1 -1
- package/dist/context/spawn-history.d.ts +13 -0
- package/dist/context/spawn-history.d.ts.map +1 -0
- package/dist/context/spawn-history.js +82 -0
- package/dist/context/spawn-history.js.map +1 -0
- package/dist/context/squeeze.d.ts +1 -1
- package/dist/context/squeeze.d.ts.map +1 -1
- package/dist/context/squeeze.js +1 -1
- package/dist/context/squeeze.js.map +1 -1
- package/dist/context/tools.d.ts +2 -2
- package/dist/context/tools.d.ts.map +1 -1
- package/dist/context/tools.js +2 -2
- package/dist/context/tools.js.map +1 -1
- package/dist/context/transcript.d.ts +3 -1
- package/dist/context/transcript.d.ts.map +1 -1
- package/dist/context/transcript.js +17 -4
- package/dist/context/transcript.js.map +1 -1
- package/dist/policy-processor/classifier.d.ts.map +1 -1
- package/dist/policy-processor/classifier.js +3 -1
- package/dist/policy-processor/classifier.js.map +1 -1
- package/dist/policy-processor/scope.d.ts +1 -0
- package/dist/policy-processor/scope.d.ts.map +1 -1
- package/dist/policy-processor/scope.js +9 -2
- package/dist/policy-processor/scope.js.map +1 -1
- package/dist/policy-processor/unattended-guard.js +8 -2
- package/dist/policy-processor/unattended-guard.js.map +1 -1
- package/dist/resources/compact-assets.d.ts +5 -0
- package/dist/resources/compact-assets.d.ts.map +1 -0
- package/dist/resources/compact-assets.js +6 -0
- package/dist/resources/compact-assets.js.map +1 -0
- package/dist/resources/compact-snapshot.d.ts +21 -0
- package/dist/resources/compact-snapshot.d.ts.map +1 -0
- package/dist/resources/compact-snapshot.js +44 -0
- package/dist/resources/compact-snapshot.js.map +1 -0
- package/dist/resources/index.d.ts +6 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +19 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/module-bundle.d.ts +16 -0
- package/dist/resources/module-bundle.d.ts.map +1 -0
- package/dist/resources/module-bundle.js +78 -0
- package/dist/resources/module-bundle.js.map +1 -0
- package/dist/runtime/ambient-compact.d.ts +38 -0
- package/dist/runtime/ambient-compact.d.ts.map +1 -0
- package/dist/runtime/ambient-compact.js +123 -0
- package/dist/runtime/ambient-compact.js.map +1 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +8 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/ports.d.ts +33 -0
- package/dist/runtime/ports.d.ts.map +1 -0
- package/dist/runtime/ports.js +2 -0
- package/dist/runtime/ports.js.map +1 -0
- package/dist/runtime/prompt-message-of.d.ts +4 -0
- package/dist/runtime/prompt-message-of.d.ts.map +1 -0
- package/dist/runtime/prompt-message-of.js +8 -0
- package/dist/runtime/prompt-message-of.js.map +1 -0
- package/dist/runtime/re-act-loop-intent-detected-trigger.d.ts +32 -0
- package/dist/runtime/re-act-loop-intent-detected-trigger.d.ts.map +1 -0
- package/dist/runtime/re-act-loop-intent-detected-trigger.js +132 -0
- package/dist/runtime/re-act-loop-intent-detected-trigger.js.map +1 -0
- package/dist/runtime/round-boundary.d.ts +13 -0
- package/dist/runtime/round-boundary.d.ts.map +1 -0
- package/dist/runtime/round-boundary.js +210 -0
- package/dist/runtime/round-boundary.js.map +1 -0
- package/dist/runtime/round-stop.d.ts +9 -0
- package/dist/runtime/round-stop.d.ts.map +1 -0
- package/dist/runtime/round-stop.js +19 -0
- package/dist/runtime/round-stop.js.map +1 -0
- package/dist/runtime/tool-call.d.ts +4 -0
- package/dist/runtime/tool-call.d.ts.map +1 -0
- package/dist/runtime/tool-call.js +8 -0
- package/dist/runtime/tool-call.js.map +1 -0
- package/dist/runtime/turn-iterator.d.ts +32 -0
- package/dist/runtime/turn-iterator.d.ts.map +1 -0
- package/dist/runtime/turn-iterator.js +251 -0
- package/dist/runtime/turn-iterator.js.map +1 -0
- package/dist/runtime/turn-resolvers.d.ts +17 -0
- package/dist/runtime/turn-resolvers.d.ts.map +1 -0
- package/dist/runtime/turn-resolvers.js +29 -0
- package/dist/runtime/turn-resolvers.js.map +1 -0
- package/dist/session/cancel.d.ts +4 -1
- package/dist/session/cancel.d.ts.map +1 -1
- package/dist/session/cancel.js +10 -2
- package/dist/session/cancel.js.map +1 -1
- package/dist/session/commands.d.ts +1 -1
- package/dist/session/commands.d.ts.map +1 -1
- package/dist/session/commands.js +4 -2
- package/dist/session/commands.js.map +1 -1
- package/dist/session/compact-actor.d.ts +12 -5
- package/dist/session/compact-actor.d.ts.map +1 -1
- package/dist/session/compact-actor.js +64 -12
- package/dist/session/compact-actor.js.map +1 -1
- package/dist/session/compact-env.d.ts +31 -5
- package/dist/session/compact-env.d.ts.map +1 -1
- package/dist/session/compact-env.js +23 -13
- package/dist/session/compact-env.js.map +1 -1
- package/dist/session/compact.d.ts +6 -3
- package/dist/session/compact.d.ts.map +1 -1
- package/dist/session/compact.js.map +1 -1
- package/dist/session/index.d.ts +2 -2
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +2 -2
- package/dist/session/index.js.map +1 -1
- package/dist/session/park.d.ts +1 -1
- package/dist/session/park.d.ts.map +1 -1
- package/dist/session/park.js +1 -1
- package/dist/session/park.js.map +1 -1
- package/dist/session/side-channel-reminder.d.ts +1 -1
- package/dist/session/side-channel-reminder.d.ts.map +1 -1
- package/dist/session/side-channel-reminder.js +1 -1
- package/dist/session/side-channel-reminder.js.map +1 -1
- package/dist/session/types.d.ts +1 -1
- package/dist/session/types.d.ts.map +1 -1
- package/dist/session-runtime/ask-line.d.ts +7 -0
- package/dist/session-runtime/ask-line.d.ts.map +1 -0
- package/dist/session-runtime/ask-line.js +36 -0
- package/dist/session-runtime/ask-line.js.map +1 -0
- package/dist/session-runtime/durability.d.ts +25 -0
- package/dist/session-runtime/durability.d.ts.map +1 -0
- package/dist/session-runtime/durability.js +18 -0
- package/dist/session-runtime/durability.js.map +1 -0
- package/dist/session-runtime/effects.d.ts +53 -0
- package/dist/session-runtime/effects.d.ts.map +1 -0
- package/dist/session-runtime/effects.js +18 -0
- package/dist/session-runtime/effects.js.map +1 -0
- package/dist/session-runtime/index.d.ts +8 -0
- package/dist/session-runtime/index.d.ts.map +1 -0
- package/dist/session-runtime/index.js +8 -0
- package/dist/session-runtime/index.js.map +1 -0
- package/dist/session-runtime/interrupt.d.ts +3 -0
- package/dist/session-runtime/interrupt.d.ts.map +1 -0
- package/dist/session-runtime/interrupt.js +33 -0
- package/dist/session-runtime/interrupt.js.map +1 -0
- package/dist/session-runtime/recovery.d.ts +17 -0
- package/dist/session-runtime/recovery.d.ts.map +1 -0
- package/dist/session-runtime/recovery.js +119 -0
- package/dist/session-runtime/recovery.js.map +1 -0
- package/dist/session-runtime/runtime.d.ts +50 -0
- package/dist/session-runtime/runtime.d.ts.map +1 -0
- package/dist/session-runtime/runtime.js +533 -0
- package/dist/session-runtime/runtime.js.map +1 -0
- package/dist/session-runtime/summary.d.ts +26 -0
- package/dist/session-runtime/summary.d.ts.map +1 -0
- package/dist/session-runtime/summary.js +33 -0
- package/dist/session-runtime/summary.js.map +1 -0
- package/dist/tool-catalog/bindings.d.ts +6 -0
- package/dist/tool-catalog/bindings.d.ts.map +1 -0
- package/dist/tool-catalog/bindings.js +37 -0
- package/dist/tool-catalog/bindings.js.map +1 -0
- package/dist/tool-catalog/catalog.d.ts +1 -3
- package/dist/tool-catalog/catalog.d.ts.map +1 -1
- package/dist/tool-catalog/catalog.js +6 -34
- package/dist/tool-catalog/catalog.js.map +1 -1
- package/dist/tool-catalog/types.d.ts +8 -0
- package/dist/tool-catalog/types.d.ts.map +1 -1
- package/dist/tool-catalog/types.js.map +1 -1
- package/dist/tool-runtime/approval/approved.d.ts +1 -1
- package/dist/tool-runtime/approval/approved.d.ts.map +1 -1
- package/dist/tool-runtime/approval/approved.js +1 -1
- package/dist/tool-runtime/approval/approved.js.map +1 -1
- package/dist/tool-runtime/handler.d.ts.map +1 -1
- package/dist/tool-runtime/handler.js +291 -237
- package/dist/tool-runtime/handler.js.map +1 -1
- package/dist/tool-runtime/run-system-tool.d.ts +1 -0
- package/dist/tool-runtime/run-system-tool.d.ts.map +1 -1
- package/dist/tool-runtime/run-system-tool.js +30 -10
- package/dist/tool-runtime/run-system-tool.js.map +1 -1
- package/dist/tool-runtime/worker-tools.d.ts.map +1 -1
- package/dist/tool-runtime/worker-tools.js +2 -2
- package/dist/tool-runtime/worker-tools.js.map +1 -1
- package/package.json +29 -16
- package/src/agent-calls/acceptance.ts +1 -1
- package/src/agent-calls/callbacks.ts +1 -1
- package/src/agent-calls/delivery.ts +1 -1
- package/src/agent-calls/operator.ts +7 -1
- package/src/agent-calls/runtime.ts +23 -11
- package/src/agent-calls/types.ts +1 -1
- package/src/context/compact-floors.ts +1 -1
- package/src/context/compact.ts +4 -5
- package/src/context/history.ts +46 -4
- package/src/context/retention/defaults.ts +1 -1
- package/src/context/retention/resolve.ts +1 -1
- package/src/context/retention/schema.ts +1 -1
- package/src/context/retention/stamp.ts +7 -2
- package/src/context/retention/step.ts +7 -4
- package/src/context/retention/view.ts +1 -1
- package/src/context/spawn-history.ts +95 -0
- package/src/context/squeeze.ts +1 -1
- package/src/context/tools.ts +3 -2
- package/src/context/transcript.ts +15 -4
- package/src/policy-processor/README.md +1 -1
- package/src/policy-processor/classifier.ts +3 -1
- package/src/policy-processor/scope.ts +7 -2
- package/src/policy-processor/unattended-guard.ts +5 -2
- package/src/resources/compact-assets.ts +9 -0
- package/src/resources/compact-snapshot.ts +51 -0
- package/src/resources/index.ts +27 -0
- package/src/resources/module-bundle.ts +90 -0
- package/src/runtime/ambient-compact.ts +147 -0
- package/src/runtime/index.ts +17 -0
- package/src/runtime/ports.ts +28 -0
- package/src/runtime/prompt-message-of.ts +14 -0
- package/src/runtime/re-act-loop-intent-detected-trigger.ts +177 -0
- package/src/runtime/round-boundary.ts +248 -0
- package/src/runtime/round-stop.ts +24 -0
- package/src/runtime/tool-call.ts +10 -0
- package/src/runtime/turn-iterator.ts +312 -0
- package/src/runtime/turn-resolvers.ts +43 -0
- package/src/session/cancel.ts +11 -3
- package/src/session/commands.ts +5 -2
- package/src/session/compact-actor.ts +76 -16
- package/src/session/compact-env.ts +27 -18
- package/src/session/compact.ts +8 -3
- package/src/session/index.ts +7 -2
- package/src/session/park.ts +7 -1
- package/src/session/side-channel-reminder.ts +1 -1
- package/src/session/types.ts +1 -1
- package/src/session-runtime/ask-line.ts +39 -0
- package/src/session-runtime/durability.ts +41 -0
- package/src/session-runtime/effects.ts +35 -0
- package/src/session-runtime/index.ts +19 -0
- package/src/session-runtime/interrupt.ts +34 -0
- package/src/session-runtime/recovery.ts +145 -0
- package/src/session-runtime/runtime.ts +535 -0
- package/src/session-runtime/summary.ts +67 -0
- package/src/tool-catalog/bindings.ts +37 -0
- package/src/tool-catalog/catalog.ts +6 -31
- package/src/tool-catalog/types.ts +9 -0
- package/src/tool-runtime/approval/approved.ts +1 -1
- package/src/tool-runtime/handler.ts +40 -24
- package/src/tool-runtime/run-system-tool.ts +27 -11
- package/src/tool-runtime/worker-tools.ts +2 -2
|
@@ -1,22 +1,57 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
1
35
|
/**
|
|
2
36
|
* Project-bound mint of one model tool_call. Does not execute.
|
|
3
37
|
* Connection-sourced names are MCPToolJob; write_file / edit_file are
|
|
4
38
|
* FileMutateToolJob; pack / unknown are SystemToolJob.
|
|
5
|
-
* `agentCallFromWire` mints `agent__ask` / `agent__send`. `admit` wraps it
|
|
39
|
+
* `agentCallFromWire` mints `agent__ask` / `agent__send`. `admit` wraps it with frozen policy and retention facts.
|
|
6
40
|
* Both append onto `AdmitContext.parent` when the caller passes one. They do not enqueue.
|
|
7
41
|
* Bot-call pack tools and standing bot invocations mint BotCallJob.
|
|
8
42
|
* `scheme_repl` is a ProgrammaticJob bag. Inner admits reuse this door.
|
|
9
43
|
*/
|
|
10
44
|
import { createHash } from "node:crypto";
|
|
11
|
-
import { AgentCallJob, BotCallJob, AgentCallbackJob, AgentMessageJob, AgentNotifyJob, AGENT_ASK, AGENT_MESSAGE, AGENT_NOTIFY, AGENT_RESPOND, AGENT_SEND, AGENT_VOID, CallDelivery,
|
|
45
|
+
import { AgentCallJob, BotCallJob, AgentCallbackJob, AgentMessageJob, AgentNotifyJob, AGENT_ASK, AGENT_MESSAGE, AGENT_NOTIFY, AGENT_RESPOND, AGENT_SEND, AGENT_VOID, CallDelivery, FailureOutcome, FileMutateToolJob, MCPToolJob, McpToolExpectation, mcpToolListHas, parseWebExtractArgs, parseWebSearchArgs, ProgrammaticJob, SCHEME_REPL_TOOL_NAME, SCHEME_WATCH_TOOL_NAME, SessionTurn, storageIncludingOffTape, SystemToolJob, WEB_EXTRACT_TOOL_NAME, WEB_SEARCH_TOOL_NAME, WebExtractExpectation, WebExtractToolJob, WebSearchExpectation, WebSearchToolJob, writePluginMeta, } from "@inhuman.tools/harness-model";
|
|
12
46
|
import { parseJsonRecord } from "@inhuman.tools/harness-model/json-record";
|
|
47
|
+
import { action } from "mobx";
|
|
13
48
|
import { externalizePrior } from "./blob-port.js";
|
|
14
49
|
import { peelAgentCallArgs, requestIdOf } from "./peel.js";
|
|
15
50
|
import { workerToolAllowed } from "./worker-tools.js";
|
|
16
51
|
import { lineStartOfSpan, writeFileAdmitSnap } from "./write-admit.js";
|
|
17
52
|
import { policyOfTurn, stampJobRetention } from "../context/retention/index.js";
|
|
18
53
|
import { peelShellCwd } from "../policy-processor/peel-cwd.js";
|
|
19
|
-
import { agentCallSupportsNotify } from "../tool-catalog/index.js";
|
|
54
|
+
import { agentCallSupportsNotify, behaviorEntriesOf, } from "../tool-catalog/index.js";
|
|
20
55
|
function pluginRevision(catalog, pluginName) {
|
|
21
56
|
const record = catalog.pluginInstall?.plugins.get(pluginName);
|
|
22
57
|
if (record == null)
|
|
@@ -40,8 +75,12 @@ function priorProps(text) {
|
|
|
40
75
|
return text === null ? {} : externalizePrior(text);
|
|
41
76
|
}
|
|
42
77
|
function catalogFlags(entry) {
|
|
78
|
+
const continuation = entry?.continuation ?? {
|
|
79
|
+
kind: entry?.triggersReactLoop === false ? "none" : "observation",
|
|
80
|
+
};
|
|
43
81
|
return {
|
|
44
|
-
|
|
82
|
+
continuationJson: JSON.stringify(continuation),
|
|
83
|
+
triggersReactLoop: continuation.kind === "observation",
|
|
45
84
|
tapeHidden: entry?.tapeHidden ?? false,
|
|
46
85
|
isSideChannel: entry?.isSideChannel === true,
|
|
47
86
|
};
|
|
@@ -101,16 +140,16 @@ function admitExam(call, ctx, entry) {
|
|
|
101
140
|
bag.outcomeSnap ??= { ok: true, value: { job_id: bag.toolCallId, background: true } };
|
|
102
141
|
}
|
|
103
142
|
ctx.originTurn?.pushChild(bag);
|
|
104
|
-
const
|
|
105
|
-
let jobUuid
|
|
143
|
+
const admittedAction = exam.admit(prefix, input);
|
|
144
|
+
let jobUuid;
|
|
106
145
|
try {
|
|
107
146
|
jobUuid = bag.uuid;
|
|
108
147
|
}
|
|
109
148
|
catch {
|
|
110
149
|
jobUuid = "";
|
|
111
150
|
}
|
|
112
|
-
const actionRec = asRecord(
|
|
113
|
-
writePluginMeta(bag, pluginId, actionRec == null ?
|
|
151
|
+
const actionRec = asRecord(admittedAction);
|
|
152
|
+
writePluginMeta(bag, pluginId, actionRec == null ? admittedAction : { ...actionRec, jobUuid }, true);
|
|
114
153
|
return bag;
|
|
115
154
|
}
|
|
116
155
|
function rejectedComms(kind, toolCallId, name, argsJson, text) {
|
|
@@ -148,6 +187,9 @@ export function agentCallFromWire(call, catalog, ctx = {}) {
|
|
|
148
187
|
if (ctx.session != null && !workerToolAllowed(catalog, ctx.session.agent.spec.name, name, ctx.session)) {
|
|
149
188
|
return appendJob(ctx, ceilingJob(call));
|
|
150
189
|
}
|
|
190
|
+
const flags = catalogFlags(catalog.catalogEntry(call.function.name) ??
|
|
191
|
+
catalog.privateWorkerEntries.find((row) => row.wireName === call.function.name) ??
|
|
192
|
+
behaviorEntriesOf(ctx.session).find((row) => row.wireName === call.function.name));
|
|
151
193
|
const peeled = peelAgentCallArgs(call.function.arguments);
|
|
152
194
|
const spec = parseJsonRecord(peeled.argsJson)?.spec;
|
|
153
195
|
// Select the explicit child or bot node at admission;
|
|
@@ -159,6 +201,7 @@ export function agentCallFromWire(call, catalog, ctx = {}) {
|
|
|
159
201
|
argsJson: peeled.argsJson,
|
|
160
202
|
botName: spec.trim(),
|
|
161
203
|
voidLegal: name === AGENT_SEND ? peeled.voidLegal : false,
|
|
204
|
+
...flags,
|
|
162
205
|
readonly: peeled.readonly,
|
|
163
206
|
responseSchema: peeled.responseSchema,
|
|
164
207
|
...stamp(peeled.argsJson),
|
|
@@ -170,6 +213,7 @@ export function agentCallFromWire(call, catalog, ctx = {}) {
|
|
|
170
213
|
argsJson: peeled.argsJson,
|
|
171
214
|
regenerateable: false,
|
|
172
215
|
voidLegal: name === AGENT_SEND ? peeled.voidLegal : false,
|
|
216
|
+
...flags,
|
|
173
217
|
readonly: peeled.readonly,
|
|
174
218
|
responseSchema: peeled.responseSchema,
|
|
175
219
|
constitution: peeled.constitution,
|
|
@@ -180,93 +224,131 @@ export function agentCallFromWire(call, catalog, ctx = {}) {
|
|
|
180
224
|
...stamp(peeled.argsJson),
|
|
181
225
|
}));
|
|
182
226
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const turn = ctx.originTurn ?? ctx.session?.head ?? null;
|
|
193
|
-
stampJobRetention(job, policyOfTurn(turn instanceof SessionTurn ? turn : null), {
|
|
194
|
-
...(entry?.class === undefined ? {} : { entryClass: entry.class }),
|
|
195
|
-
...(entry?.retention === undefined ? {} : { hint: entry.retention }),
|
|
196
|
-
});
|
|
197
|
-
return job;
|
|
198
|
-
}
|
|
199
|
-
#admit(call, catalog, ctx) {
|
|
200
|
-
const place = (job) => appendJob(ctx, job);
|
|
201
|
-
const toolCallId = call.id;
|
|
202
|
-
const name = call.function.name;
|
|
203
|
-
const argsJson = call.function.arguments;
|
|
204
|
-
if (ctx.session != null && !workerToolAllowed(catalog, ctx.session.agent.spec.name, name, ctx.session)) {
|
|
205
|
-
return place(ceilingJob(call));
|
|
227
|
+
let ToolCallHandler = (() => {
|
|
228
|
+
let _instanceExtraInitializers = [];
|
|
229
|
+
let _admit_decorators;
|
|
230
|
+
return class ToolCallHandler {
|
|
231
|
+
static {
|
|
232
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
233
|
+
_admit_decorators = [action];
|
|
234
|
+
__esDecorate(this, null, _admit_decorators, { kind: "method", name: "admit", static: false, private: false, access: { has: obj => "admit" in obj, get: obj => obj.admit }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
235
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
206
236
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
toolName: name,
|
|
211
|
-
toolCallId,
|
|
212
|
-
argsJson,
|
|
213
|
-
...flagged,
|
|
214
|
-
});
|
|
215
|
-
if (job.background && job.toolCallId.trim() !== "") {
|
|
216
|
-
job.outcomeSnap ??= { ok: true, value: { job_id: job.toolCallId, background: true } };
|
|
217
|
-
}
|
|
218
|
-
return place(job);
|
|
237
|
+
kernel = __runInitializers(this, _instanceExtraInitializers);
|
|
238
|
+
constructor(kernel) {
|
|
239
|
+
this.kernel = kernel;
|
|
219
240
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
241
|
+
admit(call, catalog = this.kernel.catalog, ctx = {}) {
|
|
242
|
+
const job = this.#admit(call, catalog, { ...ctx, parent: undefined });
|
|
243
|
+
// R2: the horizon is resolved once, here, from the turn's R1 policy and the catalog as it is now.
|
|
244
|
+
const entry = catalog.catalogEntry(call.function.name) ??
|
|
245
|
+
this.kernel.catalog.catalogEntry(call.function.name) ??
|
|
246
|
+
catalog.privateWorkerEntries.find((row) => row.wireName === call.function.name) ??
|
|
247
|
+
behaviorEntriesOf(ctx.session).find((row) => row.wireName === call.function.name);
|
|
248
|
+
const policy = catalogFlags(entry);
|
|
249
|
+
job.continuationJson = policy.continuationJson;
|
|
250
|
+
job.triggersReactLoop = policy.triggersReactLoop;
|
|
251
|
+
job.isSideChannel = policy.isSideChannel;
|
|
252
|
+
job.tapeHidden = policy.tapeHidden;
|
|
253
|
+
const turn = ctx.originTurn ?? ctx.session?.head ?? null;
|
|
254
|
+
stampJobRetention(job, policyOfTurn(turn instanceof SessionTurn ? turn : null), {
|
|
255
|
+
...(entry?.class === undefined ? {} : { entryClass: entry.class }),
|
|
256
|
+
...(entry?.retention === undefined ? {} : { hint: entry.retention }),
|
|
257
|
+
});
|
|
258
|
+
return appendJob(ctx, job);
|
|
226
259
|
}
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
260
|
+
#admit(call, catalog, ctx) {
|
|
261
|
+
const place = (job) => appendJob(ctx, job);
|
|
262
|
+
const toolCallId = call.id;
|
|
263
|
+
const name = call.function.name;
|
|
264
|
+
const argsJson = call.function.arguments;
|
|
265
|
+
if (ctx.session != null && !workerToolAllowed(catalog, ctx.session.agent.spec.name, name, ctx.session)) {
|
|
266
|
+
return place(ceilingJob(call));
|
|
267
|
+
}
|
|
268
|
+
if (name === SCHEME_REPL_TOOL_NAME || name === SCHEME_WATCH_TOOL_NAME) {
|
|
269
|
+
const flagged = name === SCHEME_WATCH_TOOL_NAME ? { background: true, walkBoundary: true } : stamp(argsJson);
|
|
270
|
+
const job = new ProgrammaticJob({
|
|
271
|
+
toolName: name,
|
|
272
|
+
toolCallId,
|
|
273
|
+
argsJson,
|
|
274
|
+
...catalogFlags(catalog.catalogEntry(name) ?? this.kernel.catalog.catalogEntry(name)),
|
|
275
|
+
...flagged,
|
|
276
|
+
});
|
|
277
|
+
if (job.background && job.toolCallId.trim() !== "") {
|
|
278
|
+
job.outcomeSnap ??= { ok: true, value: { job_id: job.toolCallId, background: true } };
|
|
279
|
+
}
|
|
280
|
+
return place(job);
|
|
281
|
+
}
|
|
282
|
+
const viewEntry = catalog.catalogEntry(name);
|
|
283
|
+
const kernelEntry = this.kernel.catalog.catalogEntry(name);
|
|
284
|
+
const entry = viewEntry ?? kernelEntry ?? catalog.privateWorkerEntries.find((row) => row.wireName === name);
|
|
285
|
+
const regenerateable = viewEntry?.class === "read";
|
|
286
|
+
if (entry?.exam != null) {
|
|
287
|
+
return place(admitExam(call, ctx, entry));
|
|
288
|
+
}
|
|
289
|
+
if (entry?.packMeta?.kind === "bot-call") {
|
|
290
|
+
const meta = entry.packMeta;
|
|
291
|
+
const recipe = catalog.recipe(meta.target);
|
|
292
|
+
const known = recipe != null;
|
|
293
|
+
const revision = pluginRevision(catalog, meta.pluginName);
|
|
294
|
+
const peeled = peelAgentCallArgs(argsJson);
|
|
295
|
+
const job = new BotCallJob({
|
|
296
|
+
toolCallId,
|
|
297
|
+
name,
|
|
298
|
+
argsJson: peeled.argsJson,
|
|
299
|
+
botName: meta.target,
|
|
300
|
+
regenerateable: false,
|
|
301
|
+
voidLegal: peeled.voidLegal,
|
|
302
|
+
readonly: peeled.readonly,
|
|
303
|
+
responseSchema: peeled.responseSchema,
|
|
304
|
+
contributionPluginName: meta.pluginName,
|
|
305
|
+
contributionBotName: meta.target,
|
|
306
|
+
contributionRevision: revision,
|
|
307
|
+
...(meta.background ? { background: true, walkBoundary: true } : stamp(argsJson)),
|
|
308
|
+
...(known
|
|
309
|
+
? {}
|
|
310
|
+
: {
|
|
311
|
+
outcome: new FailureOutcome({
|
|
312
|
+
code: "unknown_recipe",
|
|
313
|
+
message: "unknown recipe",
|
|
314
|
+
}),
|
|
315
|
+
completed: true,
|
|
316
|
+
}),
|
|
317
|
+
});
|
|
318
|
+
if (known && meta.lifetime != null)
|
|
319
|
+
job.delivery = new CallDelivery({ lifetime: meta.lifetime });
|
|
320
|
+
return place(job);
|
|
321
|
+
}
|
|
322
|
+
if (entry?.source.kind === "connection") {
|
|
323
|
+
const hidden = viewEntry == null && !catalog.privateWorkerEntries.some((row) => row.wireName === name);
|
|
324
|
+
const blocked = ctx.session != null &&
|
|
325
|
+
mcpToolListHas(ctx.session.toolBlocklist, entry.source.connectionKey, entry.source.serverToolName);
|
|
326
|
+
if (hidden || blocked) {
|
|
327
|
+
return place(new MCPToolJob({
|
|
328
|
+
toolCallId,
|
|
329
|
+
name,
|
|
330
|
+
argsJson,
|
|
331
|
+
regenerateable: false,
|
|
332
|
+
connectionKey: entry.source.connectionKey,
|
|
333
|
+
serverToolName: entry.source.serverToolName,
|
|
334
|
+
expectation: new McpToolExpectation({
|
|
335
|
+
connectionId: entry.source.connectionKey,
|
|
336
|
+
serverToolName: entry.source.serverToolName,
|
|
337
|
+
argsJson,
|
|
252
338
|
}),
|
|
339
|
+
humanApprove: false,
|
|
253
340
|
completed: true,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (entry?.source.kind === "connection") {
|
|
261
|
-
const hidden = viewEntry == null && !catalog.privateWorkerEntries.some((row) => row.wireName === name);
|
|
262
|
-
const blocked = ctx.session != null &&
|
|
263
|
-
mcpToolListHas(ctx.session.toolBlocklist, entry.source.connectionKey, entry.source.serverToolName);
|
|
264
|
-
if (hidden || blocked) {
|
|
341
|
+
outcomeJson: JSON.stringify({
|
|
342
|
+
ok: false,
|
|
343
|
+
text: `unknown MCP tool "${entry.source.serverToolName}"`,
|
|
344
|
+
}),
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
265
347
|
return place(new MCPToolJob({
|
|
266
348
|
toolCallId,
|
|
267
349
|
name,
|
|
268
350
|
argsJson,
|
|
269
|
-
regenerateable
|
|
351
|
+
regenerateable,
|
|
270
352
|
connectionKey: entry.source.connectionKey,
|
|
271
353
|
serverToolName: entry.source.serverToolName,
|
|
272
354
|
expectation: new McpToolExpectation({
|
|
@@ -274,187 +356,159 @@ export class ToolCallHandler {
|
|
|
274
356
|
serverToolName: entry.source.serverToolName,
|
|
275
357
|
argsJson,
|
|
276
358
|
}),
|
|
277
|
-
humanApprove: false,
|
|
278
|
-
completed: true,
|
|
279
|
-
outcomeJson: JSON.stringify({
|
|
280
|
-
ok: false,
|
|
281
|
-
text: `unknown MCP tool "${entry.source.serverToolName}"`,
|
|
282
|
-
}),
|
|
283
359
|
}));
|
|
284
360
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
361
|
+
if (name === AGENT_ASK || name === AGENT_SEND) {
|
|
362
|
+
return agentCallFromWire(call, catalog, ctx);
|
|
363
|
+
}
|
|
364
|
+
const requestId = requestIdOf(argsJson);
|
|
365
|
+
const ownsOpen = ctx.session != null && requestId !== "" && ctx.session.agentCallbacks[requestId] != null;
|
|
366
|
+
if (name === AGENT_RESPOND || name === AGENT_VOID) {
|
|
367
|
+
if (ownsOpen) {
|
|
368
|
+
return place(new AgentCallbackJob({
|
|
369
|
+
toolCallId,
|
|
370
|
+
name,
|
|
371
|
+
argsJson,
|
|
372
|
+
regenerateable: false,
|
|
373
|
+
...stamp(argsJson),
|
|
374
|
+
}));
|
|
375
|
+
}
|
|
376
|
+
return place(rejectedComms("callback", toolCallId, name, argsJson, "no open callback"));
|
|
377
|
+
}
|
|
378
|
+
if (name === AGENT_NOTIFY) {
|
|
379
|
+
const open = ownsOpen && ctx.loadAgentCall != null ? ctx.loadAgentCall(requestId) : undefined;
|
|
380
|
+
if (open != null && agentCallSupportsNotify(catalog, open.name)) {
|
|
381
|
+
return place(new AgentNotifyJob({
|
|
382
|
+
toolCallId,
|
|
383
|
+
name,
|
|
384
|
+
argsJson,
|
|
385
|
+
regenerateable: false,
|
|
386
|
+
...stamp(argsJson),
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
return place(rejectedComms("notify", toolCallId, name, argsJson, "no open notify"));
|
|
390
|
+
}
|
|
391
|
+
if (name === AGENT_MESSAGE) {
|
|
392
|
+
return place(new AgentMessageJob({
|
|
393
|
+
toolCallId,
|
|
394
|
+
name,
|
|
295
395
|
argsJson,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const ownsOpen = ctx.session != null && requestId !== "" && ctx.session.agentCallbacks[requestId] != null;
|
|
304
|
-
if (name === AGENT_RESPOND || name === AGENT_VOID) {
|
|
305
|
-
if (ownsOpen) {
|
|
306
|
-
return place(new AgentCallbackJob({
|
|
396
|
+
regenerateable: false,
|
|
397
|
+
...stamp(argsJson),
|
|
398
|
+
}));
|
|
399
|
+
}
|
|
400
|
+
if (name === WEB_SEARCH_TOOL_NAME) {
|
|
401
|
+
const parsed = parseWebSearchArgs(argsJson);
|
|
402
|
+
return place(new WebSearchToolJob({
|
|
307
403
|
toolCallId,
|
|
308
404
|
name,
|
|
309
405
|
argsJson,
|
|
310
406
|
regenerateable: false,
|
|
407
|
+
expectation: new WebSearchExpectation({
|
|
408
|
+
connectionId: WEB_SEARCH_TOOL_NAME,
|
|
409
|
+
query: parsed.query,
|
|
410
|
+
limit: parsed.limit,
|
|
411
|
+
}),
|
|
311
412
|
...stamp(argsJson),
|
|
312
413
|
}));
|
|
313
414
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const open = ownsOpen && ctx.loadAgentCall != null ? ctx.loadAgentCall(requestId) : undefined;
|
|
318
|
-
if (open != null && agentCallSupportsNotify(catalog, open.name)) {
|
|
319
|
-
return place(new AgentNotifyJob({
|
|
415
|
+
if (name === WEB_EXTRACT_TOOL_NAME) {
|
|
416
|
+
const parsed = parseWebExtractArgs(argsJson);
|
|
417
|
+
return place(new WebExtractToolJob({
|
|
320
418
|
toolCallId,
|
|
321
419
|
name,
|
|
322
420
|
argsJson,
|
|
323
421
|
regenerateable: false,
|
|
422
|
+
expectation: new WebExtractExpectation({
|
|
423
|
+
connectionId: WEB_EXTRACT_TOOL_NAME,
|
|
424
|
+
url: parsed.url,
|
|
425
|
+
charLimit: parsed.charLimit,
|
|
426
|
+
}),
|
|
324
427
|
...stamp(argsJson),
|
|
325
428
|
}));
|
|
326
429
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
argsJson
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
argsJson
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
limit: parsed.limit,
|
|
359
|
-
}),
|
|
360
|
-
...stamp(argsJson),
|
|
361
|
-
}));
|
|
362
|
-
}
|
|
363
|
-
if (name === WEB_EXTRACT_TOOL_NAME) {
|
|
364
|
-
const parsed = parseWebExtractArgs(argsJson);
|
|
365
|
-
return place(new WebExtractToolJob({
|
|
366
|
-
toolCallId,
|
|
367
|
-
name,
|
|
368
|
-
argsJson,
|
|
369
|
-
regenerateable: false,
|
|
370
|
-
expectation: new WebExtractExpectation({
|
|
371
|
-
connectionId: WEB_EXTRACT_TOOL_NAME,
|
|
372
|
-
url: parsed.url,
|
|
373
|
-
charLimit: parsed.charLimit,
|
|
374
|
-
}),
|
|
375
|
-
...stamp(argsJson),
|
|
376
|
-
}));
|
|
377
|
-
}
|
|
378
|
-
const fileRoot = ctx.session?.path.trim() ?? "";
|
|
379
|
-
const fileSnap = (name === "write_file" || name === "edit_file") && fileRoot !== ""
|
|
380
|
-
? writeFileAdmitSnap(fileRoot, argsJson)
|
|
381
|
-
: null;
|
|
382
|
-
let oldString = "";
|
|
383
|
-
if (name === "edit_file") {
|
|
384
|
-
const parsed = parseJsonRecord(argsJson === "" ? "{}" : argsJson);
|
|
385
|
-
const old = parsed == null ? undefined : parsed.old_string;
|
|
386
|
-
if (typeof old === "string")
|
|
387
|
-
oldString = old;
|
|
388
|
-
}
|
|
389
|
-
const priorLineStart = name === "edit_file" && fileSnap?.priorContent != null ? lineStartOfSpan(fileSnap.priorContent, oldString) : null;
|
|
390
|
-
let shellArgsJson = argsJson;
|
|
391
|
-
let shellRefuse;
|
|
392
|
-
if (name === "shell") {
|
|
393
|
-
const parsed = parseJsonRecord(argsJson === "" ? "{}" : argsJson);
|
|
394
|
-
if (parsed != null) {
|
|
395
|
-
const command = parsed.command;
|
|
396
|
-
if (typeof command === "string" && command !== "") {
|
|
397
|
-
const cwdArg = typeof parsed.cwd === "string" ? parsed.cwd : undefined;
|
|
398
|
-
const peeled = peelShellCwd(command, cwdArg);
|
|
399
|
-
if (peeled !== null && peeled.command === "") {
|
|
400
|
-
shellRefuse = "cwd only; use the cwd arg on the next call";
|
|
401
|
-
}
|
|
402
|
-
else if (peeled !== null) {
|
|
403
|
-
shellArgsJson = JSON.stringify({
|
|
404
|
-
...parsed,
|
|
405
|
-
cwd: peeled.cwd,
|
|
406
|
-
command: peeled.command,
|
|
407
|
-
});
|
|
430
|
+
const fileRoot = ctx.session?.path.trim() ?? "";
|
|
431
|
+
const fileSnap = (name === "write_file" || name === "edit_file") && fileRoot !== ""
|
|
432
|
+
? writeFileAdmitSnap(fileRoot, argsJson)
|
|
433
|
+
: null;
|
|
434
|
+
let oldString = "";
|
|
435
|
+
if (name === "edit_file") {
|
|
436
|
+
const parsed = parseJsonRecord(argsJson === "" ? "{}" : argsJson);
|
|
437
|
+
const old = parsed == null ? undefined : parsed.old_string;
|
|
438
|
+
if (typeof old === "string")
|
|
439
|
+
oldString = old;
|
|
440
|
+
}
|
|
441
|
+
const priorLineStart = name === "edit_file" && fileSnap?.priorContent != null ? lineStartOfSpan(fileSnap.priorContent, oldString) : null;
|
|
442
|
+
let shellArgsJson = argsJson;
|
|
443
|
+
let shellRefuse;
|
|
444
|
+
if (name === "shell") {
|
|
445
|
+
const parsed = parseJsonRecord(argsJson === "" ? "{}" : argsJson);
|
|
446
|
+
if (parsed != null) {
|
|
447
|
+
const command = parsed.command;
|
|
448
|
+
if (typeof command === "string" && command !== "") {
|
|
449
|
+
const cwdArg = typeof parsed.cwd === "string" ? parsed.cwd : undefined;
|
|
450
|
+
const peeled = peelShellCwd(command, cwdArg);
|
|
451
|
+
if (peeled !== null && peeled.command === "") {
|
|
452
|
+
shellRefuse = "cwd only; use the cwd arg on the next call";
|
|
453
|
+
}
|
|
454
|
+
else if (peeled !== null) {
|
|
455
|
+
shellArgsJson = JSON.stringify({
|
|
456
|
+
...parsed,
|
|
457
|
+
cwd: peeled.cwd,
|
|
458
|
+
command: peeled.command,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
408
461
|
}
|
|
409
462
|
}
|
|
410
463
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return place(new SystemToolJob({
|
|
414
|
-
toolCallId,
|
|
415
|
-
name,
|
|
416
|
-
argsJson: shellArgsJson,
|
|
417
|
-
regenerateable: false,
|
|
418
|
-
completed: true,
|
|
419
|
-
outcomeJson: JSON.stringify({ ok: false, text: shellRefuse }),
|
|
420
|
-
}));
|
|
421
|
-
}
|
|
422
|
-
if (name === "write_file" || name === "edit_file") {
|
|
423
|
-
if (name === "write_file" && fileSnap?.refuse != null) {
|
|
424
|
-
return place(new FileMutateToolJob({
|
|
464
|
+
if (shellRefuse !== undefined) {
|
|
465
|
+
return place(new SystemToolJob({
|
|
425
466
|
toolCallId,
|
|
426
467
|
name,
|
|
427
|
-
argsJson,
|
|
468
|
+
argsJson: shellArgsJson,
|
|
428
469
|
regenerateable: false,
|
|
429
470
|
completed: true,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
471
|
+
outcomeJson: JSON.stringify({ ok: false, text: shellRefuse }),
|
|
472
|
+
}));
|
|
473
|
+
}
|
|
474
|
+
if (name === "write_file" || name === "edit_file") {
|
|
475
|
+
if (name === "write_file" && fileSnap?.refuse != null) {
|
|
476
|
+
return place(new FileMutateToolJob({
|
|
477
|
+
toolCallId,
|
|
478
|
+
name,
|
|
479
|
+
argsJson,
|
|
480
|
+
regenerateable: false,
|
|
481
|
+
completed: true,
|
|
482
|
+
existed: fileSnap.existed,
|
|
483
|
+
...priorProps(fileSnap.priorContent),
|
|
484
|
+
outcomeJson: JSON.stringify({ ok: false, text: fileSnap.refuse }),
|
|
485
|
+
}));
|
|
486
|
+
}
|
|
487
|
+
const prior = fileSnap == null
|
|
488
|
+
? {}
|
|
489
|
+
: {
|
|
490
|
+
...(fileSnap.existed === null ? {} : { existed: fileSnap.existed }),
|
|
491
|
+
...priorProps(fileSnap.priorContent),
|
|
492
|
+
...(priorLineStart == null ? {} : { priorLineStart }),
|
|
493
|
+
};
|
|
494
|
+
return place(new FileMutateToolJob({
|
|
495
|
+
toolCallId,
|
|
496
|
+
name,
|
|
497
|
+
argsJson,
|
|
498
|
+
regenerateable,
|
|
499
|
+
...catalogFlags(entry),
|
|
500
|
+
...prior,
|
|
433
501
|
}));
|
|
434
502
|
}
|
|
435
|
-
|
|
436
|
-
? {}
|
|
437
|
-
: {
|
|
438
|
-
...(fileSnap.existed === null ? {} : { existed: fileSnap.existed }),
|
|
439
|
-
...priorProps(fileSnap.priorContent),
|
|
440
|
-
...(priorLineStart == null ? {} : { priorLineStart }),
|
|
441
|
-
};
|
|
442
|
-
return place(new FileMutateToolJob({
|
|
503
|
+
return place(new SystemToolJob({
|
|
443
504
|
toolCallId,
|
|
444
505
|
name,
|
|
445
|
-
argsJson,
|
|
506
|
+
argsJson: shellArgsJson,
|
|
446
507
|
regenerateable,
|
|
447
508
|
...catalogFlags(entry),
|
|
448
|
-
...prior,
|
|
449
509
|
}));
|
|
450
510
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
argsJson: shellArgsJson,
|
|
455
|
-
regenerateable,
|
|
456
|
-
...catalogFlags(entry),
|
|
457
|
-
}));
|
|
458
|
-
}
|
|
459
|
-
}
|
|
511
|
+
};
|
|
512
|
+
})();
|
|
513
|
+
export { ToolCallHandler };
|
|
460
514
|
//# sourceMappingURL=handler.js.map
|