@fabric-harness/sdk 6.14.1 → 6.15.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/dist/agent-definition.js +2 -2
- package/dist/agent-definition.js.map +1 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +10 -0
- package/dist/agent.js.map +1 -1
- package/dist/channel-runtime.d.ts +1 -1
- package/dist/channel-runtime.d.ts.map +1 -1
- package/dist/channel-runtime.js.map +1 -1
- package/dist/channel.d.ts +9 -1
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +22 -9
- package/dist/channel.js.map +1 -1
- package/dist/conversation-ownership.d.ts +10 -4
- package/dist/conversation-ownership.d.ts.map +1 -1
- package/dist/conversation-ownership.js +27 -5
- package/dist/conversation-ownership.js.map +1 -1
- package/dist/env-model-provider.d.ts +38 -0
- package/dist/env-model-provider.d.ts.map +1 -0
- package/dist/env-model-provider.js +47 -0
- package/dist/env-model-provider.js.map +1 -0
- package/dist/experimental.d.ts +1 -0
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +1 -0
- package/dist/experimental.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +1 -0
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +9 -0
- package/dist/loop.js.map +1 -1
- package/dist/model.d.ts +3 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +186 -33
- package/dist/model.js.map +1 -1
- package/dist/persistent-agent.d.ts +3 -0
- package/dist/persistent-agent.d.ts.map +1 -1
- package/dist/persistent-agent.js.map +1 -1
- package/dist/pi-loop-runtime.d.ts +2 -0
- package/dist/pi-loop-runtime.d.ts.map +1 -1
- package/dist/pi-loop-runtime.js +133 -10
- package/dist/pi-loop-runtime.js.map +1 -1
- package/dist/policy.d.ts +6 -0
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +23 -0
- package/dist/policy.js.map +1 -1
- package/dist/session.d.ts +4 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +193 -120
- package/dist/session.js.map +1 -1
- package/dist/strict.d.ts +2 -1
- package/dist/strict.d.ts.map +1 -1
- package/dist/strict.js +1 -0
- package/dist/strict.js.map +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/types.d.ts +10 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAE1B,MAAM,qBAAqB,CAAC;AAyB7B,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,aAAa,CAAC;AAYpE,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,cAAc,CAAC;AAiCnE,OAAO,KAAK,EACV,gBAAgB,EAKhB,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAEhB,WAAW,EACX,WAAW,EAMX,aAAa,EAGb,WAAW,EACX,YAAY,EAEZ,cAAc,EAEd,YAAY,EACZ,WAAW,EACX,eAAe,EAEf,YAAY,EACZ,WAAW,EACZ,MAAM,YAAY,CAAC;AAmDpB;;;;;GAKG;AACH,wBA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ACpH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,YAAY,EAAE,EACvB,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,CAAC,EAAE;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,GAC9C,qBAAqB,GAAG,SAAS,CAwBnC"}
|
package/dist/session.js
CHANGED
|
@@ -8,15 +8,16 @@ import { estimateSessionEntryTokens, evaluateContextBudget, isContextOverflowErr
|
|
|
8
8
|
import { CostBudgetTracker } from "./cost-budget.js";
|
|
9
9
|
import { deliveredSignalToEntryData, renderDeliveredMessage } from "./delivered-message.js";
|
|
10
10
|
import { dynamicStateEntriesForTool, unwrapDynamicToolResult } from "./dynamic-agent.js";
|
|
11
|
+
import { ENV_MODEL_PROVIDER_SLOT, explicitModelProviderError, getEnvModelProviderSlot, rejectsCallerModelProvider, usesCallerOnlyModelProvider, } from "./env-model-provider.js";
|
|
11
12
|
import { FabricError } from "./error.js";
|
|
12
13
|
import { createFabricFs } from "./filesystem.js";
|
|
13
14
|
import { openGovernedVoice, } from "./governed-voice.js";
|
|
14
15
|
import { SessionHistory, buildModelMessagesFromHistory, findTrailingDanglingToolCalls, findTrailingUnfinishedTasks, } from "./history.js";
|
|
15
16
|
import { getLogger } from "./logger.js";
|
|
16
|
-
import { defaultLoopRuntime } from "./loop.js";
|
|
17
|
+
import { defaultLoopRuntime, sessionToolPolicyDispatchers } from "./loop.js";
|
|
17
18
|
import { defaultModelProvider, generateWithRuntime } from "./model.js";
|
|
18
19
|
import { evaluateToolCallPolicyInSandbox, policiedSandboxEnv, runWithSandboxPolicyApproval, } from "./policied-sandbox.js";
|
|
19
|
-
import { canonicalizeToolCall, clampCommandTimeout, evaluateCommandPolicy } from "./policy.js";
|
|
20
|
+
import { aliasedToolDenial, canonicalizeToolCall, clampCommandTimeout, evaluateCommandPolicy, evaluateToolNameRestrictions, RUNTIME_TOOL_ALIAS_POLICY, } from "./policy.js";
|
|
20
21
|
import { createAttachmentHydrationBudget, hydrateModelMessageAttachments, preparePromptAttachments, recordsToModelAttachments, validatePromptAttachments, } from "./prompt-attachments.js";
|
|
21
22
|
import { buildResultRetryPrompt, validateResult } from "./result.js";
|
|
22
23
|
import { registerSandbox, serializeSandboxRef, unregisterSandbox } from "./sandbox-ref.js";
|
|
@@ -37,6 +38,25 @@ const AFFINITY_KEY_REGEX = /^aff_[0-7][0-9A-HJKMNP-TV-Z]{25}$/;
|
|
|
37
38
|
function isResolvedDynamicModelProvider(value) {
|
|
38
39
|
return "provider" in value && !("generate" in value);
|
|
39
40
|
}
|
|
41
|
+
/** Resolve a model switch without changing the origin of the resolver's result. */
|
|
42
|
+
async function resolveProviderForModel(options, model) {
|
|
43
|
+
const fallback = getEnvModelProviderSlot(options);
|
|
44
|
+
const callerResolver = options.modelProviderResolver;
|
|
45
|
+
const resolver = callerResolver ??
|
|
46
|
+
(options.modelProvider === undefined ? fallback?.modelProviderResolver : undefined);
|
|
47
|
+
if (!resolver)
|
|
48
|
+
return;
|
|
49
|
+
const resolved = await resolver(model);
|
|
50
|
+
const { provider, model: resolvedModel } = isResolvedDynamicModelProvider(resolved)
|
|
51
|
+
? resolved
|
|
52
|
+
: { provider: resolved };
|
|
53
|
+
if (callerResolver !== undefined)
|
|
54
|
+
options.modelProvider = provider;
|
|
55
|
+
else
|
|
56
|
+
options[ENV_MODEL_PROVIDER_SLOT] = { ...fallback, modelProvider: provider };
|
|
57
|
+
if (resolvedModel !== undefined)
|
|
58
|
+
options.model = resolvedModel;
|
|
59
|
+
}
|
|
40
60
|
function encodeBase32(buf, length) {
|
|
41
61
|
let result = "";
|
|
42
62
|
let bitIndex = 0; // 0 = MSB of buf[0]
|
|
@@ -299,13 +319,13 @@ export class StubFabricSession {
|
|
|
299
319
|
});
|
|
300
320
|
}
|
|
301
321
|
const inlineAttachments = validatePromptAttachments(options.images, options.documents);
|
|
322
|
+
const runtime = options.loopRuntime ?? this.options.loopRuntime ?? defaultLoopRuntime;
|
|
302
323
|
const durable = await this.getDurableRuntime();
|
|
303
324
|
if (this.options.streamRecovery !== undefined &&
|
|
304
325
|
(this.options.streamRecovery !== "replace" ||
|
|
305
326
|
durable ||
|
|
306
327
|
!this.store.appendEntry ||
|
|
307
|
-
|
|
308
|
-
.supportsStreamRecovery !== true)) {
|
|
328
|
+
runtime.supportsStreamRecovery !== true)) {
|
|
309
329
|
throw new FabricError({
|
|
310
330
|
code: "INVALID_CONFIG",
|
|
311
331
|
message: "streamRecovery: 'replace' requires an inline loop with supportsStreamRecovery: true and SessionStore.appendEntry. Delegated durable runtimes own their recovery contract.",
|
|
@@ -362,6 +382,9 @@ export class StubFabricSession {
|
|
|
362
382
|
throw error;
|
|
363
383
|
}
|
|
364
384
|
}
|
|
385
|
+
if (this.hasUnsupportedPiModelProvider(options, this.options, runtime)) {
|
|
386
|
+
throw explicitModelProviderError();
|
|
387
|
+
}
|
|
365
388
|
let role = this.resolveRole(options.role ?? this.options.role ?? this.agent.role);
|
|
366
389
|
const promptSubscriber = options.onEvent;
|
|
367
390
|
if (promptSubscriber)
|
|
@@ -371,25 +394,28 @@ export class StubFabricSession {
|
|
|
371
394
|
try {
|
|
372
395
|
let sandbox = createScopedSandboxEnv(await this.sandbox, options.cwd);
|
|
373
396
|
let tools = this.resolveTools(options.tools, options.commands, options.policy ?? this.options.policy);
|
|
397
|
+
const callerOnly = usesCallerOnlyModelProvider(runtime);
|
|
398
|
+
const turnModelProvider = () => this.effectiveModelProvider(options.modelProvider, callerOnly);
|
|
374
399
|
let joinedRenderReady = false;
|
|
375
|
-
const currentTurnConfiguration = () =>
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
? {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
: {}),
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
400
|
+
const currentTurnConfiguration = () => {
|
|
401
|
+
const modelProvider = turnModelProvider();
|
|
402
|
+
return {
|
|
403
|
+
...(typeof this.options.model === "string" ? { model: this.options.model } : {}),
|
|
404
|
+
...(this.options.thinkingLevel !== undefined
|
|
405
|
+
? { thinkingLevel: this.options.thinkingLevel }
|
|
406
|
+
: {}),
|
|
407
|
+
...(modelProvider !== undefined ? { modelProvider } : {}),
|
|
408
|
+
tools,
|
|
409
|
+
sandbox,
|
|
410
|
+
// The prompt's policy over the rendered agent's (call over session over agent), so a
|
|
411
|
+
// dynamic agent's turn refresh never widens what this prompt allowed. The key is always
|
|
412
|
+
// present: `undefined` tells the loop a refresh removed the policy.
|
|
413
|
+
policy: options.policy ?? this.options.policy,
|
|
414
|
+
...(options.role === undefined && typeof this.options.role === "object"
|
|
415
|
+
? { systemInstruction: this.options.role.content }
|
|
416
|
+
: {}),
|
|
417
|
+
};
|
|
418
|
+
};
|
|
393
419
|
const refreshDynamic = async (input) => {
|
|
394
420
|
if (!dynamic)
|
|
395
421
|
return currentTurnConfiguration();
|
|
@@ -423,22 +449,12 @@ export class StubFabricSession {
|
|
|
423
449
|
this.options.model = config.model;
|
|
424
450
|
else
|
|
425
451
|
Reflect.deleteProperty(this.options, "model");
|
|
426
|
-
if (
|
|
427
|
-
config.model !== priorModel &&
|
|
428
|
-
this.options.modelProviderResolver) {
|
|
429
|
-
const resolved = await this.options.modelProviderResolver(config.model);
|
|
430
|
-
if (isResolvedDynamicModelProvider(resolved)) {
|
|
431
|
-
this.options.modelProvider = resolved.provider;
|
|
432
|
-
if (resolved.model !== undefined)
|
|
433
|
-
this.options.model = resolved.model;
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
this.options.modelProvider = resolved;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
else if (config.modelProvider !== undefined) {
|
|
452
|
+
if (config.modelProvider !== undefined) {
|
|
440
453
|
this.options.modelProvider = config.modelProvider;
|
|
441
454
|
}
|
|
455
|
+
else if (typeof config.model === "string" && config.model !== priorModel) {
|
|
456
|
+
await resolveProviderForModel(this.options, config.model);
|
|
457
|
+
}
|
|
442
458
|
if (config.thinkingLevel !== undefined)
|
|
443
459
|
this.options.thinkingLevel = config.thinkingLevel;
|
|
444
460
|
else
|
|
@@ -601,10 +617,14 @@ export class StubFabricSession {
|
|
|
601
617
|
// Use tool-based result extraction when a validator is provided and the caller
|
|
602
618
|
// has not explicitly opted into delimiter-based extraction.
|
|
603
619
|
const useResultTools = options.result !== undefined && options.resultExtraction === undefined;
|
|
604
|
-
const
|
|
620
|
+
const dispatchTools = (calls, policy, approvalTimeoutMs, attribution) => this.executeToolCalls(calls, tools, sandbox,
|
|
621
|
+
// The prompt's policy wins over the loop's current turn policy.
|
|
622
|
+
options.policy ?? policy, approvalTimeoutMs, options.onApproval, attribution, options.signal, undefined, streamRecovery ? (data) => streamRecovery.record("tool_call", data) : undefined);
|
|
623
|
+
sessionToolPolicyDispatchers.add(dispatchTools);
|
|
605
624
|
let runtimeEndData;
|
|
606
625
|
const runRuntime = () => {
|
|
607
626
|
runtimeEndData = undefined;
|
|
627
|
+
const modelProvider = turnModelProvider();
|
|
608
628
|
return runtime.runPrompt({
|
|
609
629
|
sessionId: this.id,
|
|
610
630
|
...(streamRecovery ? { streamRecovery: "replace" } : {}),
|
|
@@ -627,9 +647,7 @@ export class StubFabricSession {
|
|
|
627
647
|
thinkingLevel: options.thinkingLevel ?? this.options.thinkingLevel ?? this.agent.thinkingLevel,
|
|
628
648
|
}
|
|
629
649
|
: {}),
|
|
630
|
-
...(
|
|
631
|
-
? { modelProvider: options.modelProvider ?? this.options.modelProvider }
|
|
632
|
-
: {}),
|
|
650
|
+
...(modelProvider !== undefined ? { modelProvider } : {}),
|
|
633
651
|
...(options.maxIterations !== undefined ? { maxIterations: options.maxIterations } : {}),
|
|
634
652
|
...(options.modelTimeoutMs !== undefined
|
|
635
653
|
? { modelTimeoutMs: options.modelTimeoutMs }
|
|
@@ -750,10 +768,7 @@ export class StubFabricSession {
|
|
|
750
768
|
},
|
|
751
769
|
}
|
|
752
770
|
: {}),
|
|
753
|
-
executeToolCalls:
|
|
754
|
-
// The prompt's policy wins (call over session over agent). A loop may pass none for
|
|
755
|
-
// model-issued calls, and a dynamic agent's turn refresh passes its rendered agent policy.
|
|
756
|
-
options.policy ?? policy, approvalTimeoutMs, options.onApproval, attribution, options.signal, undefined, streamRecovery ? (data) => streamRecovery.record("tool_call", data) : undefined),
|
|
771
|
+
executeToolCalls: dispatchTools,
|
|
757
772
|
recordToolAdditions: async (toolCallId, names) => {
|
|
758
773
|
if (names.length === 0)
|
|
759
774
|
return;
|
|
@@ -936,6 +951,10 @@ export class StubFabricSession {
|
|
|
936
951
|
}
|
|
937
952
|
async skill(name, options = {}) {
|
|
938
953
|
const skill = this.resolveSkill(name);
|
|
954
|
+
// A valid skill must pass the inline prompt's Pi preflight before it records skill_start.
|
|
955
|
+
if (skill && this.hasUnsupportedPiModelProvider(options) && !(await this.getDurableRuntime())) {
|
|
956
|
+
throw explicitModelProviderError();
|
|
957
|
+
}
|
|
939
958
|
await this.recordEntry("skill_start", { skill: name });
|
|
940
959
|
await this.emit("skill_start", { skill: name });
|
|
941
960
|
if (!skill)
|
|
@@ -1012,6 +1031,10 @@ export class StubFabricSession {
|
|
|
1012
1031
|
if (depth > MAX_TASK_DEPTH) {
|
|
1013
1032
|
throw new Error(`Task nesting exceeds MAX_TASK_DEPTH (${MAX_TASK_DEPTH}). Refusing to spawn deeper child task at depth ${depth}.`);
|
|
1014
1033
|
}
|
|
1034
|
+
// Match the inline child's session options before recording task_start or resolving its role model.
|
|
1035
|
+
if (this.hasUnsupportedPiModelProvider(options, { ...this.options, ...options })) {
|
|
1036
|
+
throw explicitModelProviderError();
|
|
1037
|
+
}
|
|
1015
1038
|
const startedAt = new Date().toISOString();
|
|
1016
1039
|
await this.recordEntry("task_start", {
|
|
1017
1040
|
taskId,
|
|
@@ -1051,19 +1074,6 @@ export class StubFabricSession {
|
|
|
1051
1074
|
options.signal.addEventListener("abort", forwardAbort, { once: true });
|
|
1052
1075
|
try {
|
|
1053
1076
|
const { agent: _agent, checkpoint: _checkpoint, depth: _depth, id: _taskOptionId, metadata: _metadata, ...childPromptOptions } = options;
|
|
1054
|
-
let delegatedModelResolution;
|
|
1055
|
-
if (delegatedRole?.model &&
|
|
1056
|
-
options.model === undefined &&
|
|
1057
|
-
options.modelProvider === undefined &&
|
|
1058
|
-
this.options.modelProviderResolver) {
|
|
1059
|
-
const resolved = await this.options.modelProviderResolver(delegatedRole.model);
|
|
1060
|
-
delegatedModelResolution = isResolvedDynamicModelProvider(resolved)
|
|
1061
|
-
? {
|
|
1062
|
-
model: resolved.model ?? delegatedRole.model,
|
|
1063
|
-
modelProvider: resolved.provider,
|
|
1064
|
-
}
|
|
1065
|
-
: { model: delegatedRole.model, modelProvider: resolved };
|
|
1066
|
-
}
|
|
1067
1077
|
const childOptions = {
|
|
1068
1078
|
...this.options,
|
|
1069
1079
|
...options,
|
|
@@ -1082,7 +1092,6 @@ export class StubFabricSession {
|
|
|
1082
1092
|
: {}),
|
|
1083
1093
|
}
|
|
1084
1094
|
: {}),
|
|
1085
|
-
...(delegatedModelResolution ?? {}),
|
|
1086
1095
|
store: this.store,
|
|
1087
1096
|
sandbox: await this.sandbox,
|
|
1088
1097
|
// Propagate depth so nested tasks can enforce MAX_TASK_DEPTH.
|
|
@@ -1096,8 +1105,14 @@ export class StubFabricSession {
|
|
|
1096
1105
|
// this interaction. Reusing the parent's dynamic runtime would refresh
|
|
1097
1106
|
// the root agent on every child turn and replace the delegated role's
|
|
1098
1107
|
// instructions, model, and capabilities.
|
|
1099
|
-
if (delegatedRole)
|
|
1108
|
+
if (delegatedRole) {
|
|
1100
1109
|
Reflect.deleteProperty(childOptions, "dynamic");
|
|
1110
|
+
if (delegatedRole.model &&
|
|
1111
|
+
options.model === undefined &&
|
|
1112
|
+
options.modelProvider === undefined) {
|
|
1113
|
+
await resolveProviderForModel(childOptions, delegatedRole.model);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1101
1116
|
// A policy the caller set on this session, or on the task itself, stays
|
|
1102
1117
|
// explicit for the child, so the child's dynamic refresh cannot replace it.
|
|
1103
1118
|
const childExplicitPolicy = options.policy ?? explicitSessionPolicies.get(this.options);
|
|
@@ -1607,8 +1622,17 @@ export class StubFabricSession {
|
|
|
1607
1622
|
});
|
|
1608
1623
|
}
|
|
1609
1624
|
}
|
|
1625
|
+
hasUnsupportedPiModelProvider(options, sessionOptions = this.options, runtime = options.loopRuntime ?? sessionOptions.loopRuntime ?? defaultLoopRuntime) {
|
|
1626
|
+
return (!options.toolCalls?.length &&
|
|
1627
|
+
rejectsCallerModelProvider(runtime) &&
|
|
1628
|
+
(options.modelProvider ?? sessionOptions.modelProvider) !== undefined);
|
|
1629
|
+
}
|
|
1630
|
+
effectiveModelProvider(override, callerOnly = false) {
|
|
1631
|
+
return (override ?? this.options.modelProvider ??
|
|
1632
|
+
(callerOnly ? undefined : getEnvModelProviderSlot(this.options)?.modelProvider));
|
|
1633
|
+
}
|
|
1610
1634
|
resolveModelContextWindow(options) {
|
|
1611
|
-
const provider =
|
|
1635
|
+
const provider = this.effectiveModelProvider(options.modelProvider);
|
|
1612
1636
|
if (!provider)
|
|
1613
1637
|
return undefined;
|
|
1614
1638
|
const model = typeof (options.model ?? this.options.model ?? this.agent.model) === "string"
|
|
@@ -1648,7 +1672,7 @@ export class StubFabricSession {
|
|
|
1648
1672
|
if (canonicalEntries.length === 0)
|
|
1649
1673
|
return summarizeEntries(canonicalEntries);
|
|
1650
1674
|
const deterministic = summarizeEntries(canonicalEntries);
|
|
1651
|
-
const provider = this.
|
|
1675
|
+
const provider = this.effectiveModelProvider(control.modelProvider) ?? defaultModelProvider;
|
|
1652
1676
|
const timeoutMs = control.timeoutMs !== undefined && control.timeoutMs > 0
|
|
1653
1677
|
? control.timeoutMs
|
|
1654
1678
|
: COMPACTION_SUMMARY_TIMEOUT_MS;
|
|
@@ -1857,6 +1881,30 @@ export class StubFabricSession {
|
|
|
1857
1881
|
const scoped = createScopedSandboxEnv(env, this.options.cwd);
|
|
1858
1882
|
return wrapWithPolicy(scoped, this.options.policy, this.options.bypassPolicyEnforcement);
|
|
1859
1883
|
}
|
|
1884
|
+
toolAliasDenial(toolName, policyToolName, policy) {
|
|
1885
|
+
if (toolName === policyToolName)
|
|
1886
|
+
return undefined;
|
|
1887
|
+
return (aliasedToolDenial(toolName, policyToolName, policy) ??
|
|
1888
|
+
(policy === this.options.policy
|
|
1889
|
+
? undefined
|
|
1890
|
+
: aliasedToolDenial(toolName, policyToolName, this.options.policy)) ??
|
|
1891
|
+
aliasedToolDenial(toolName, policyToolName, this.options[RUNTIME_TOOL_ALIAS_POLICY]?.()));
|
|
1892
|
+
}
|
|
1893
|
+
assertToolAliasAtExecution(tool, toolName, policyToolName, policy) {
|
|
1894
|
+
if ((tool.policyAlias || toolName) !== policyToolName) {
|
|
1895
|
+
throw new FabricError({
|
|
1896
|
+
code: "POLICY_DENIED",
|
|
1897
|
+
message: `Policy alias changed before executing tool: ${toolName}`,
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
const denial = this.toolAliasDenial(toolName, policyToolName, policy);
|
|
1901
|
+
if (denial) {
|
|
1902
|
+
throw new FabricError({
|
|
1903
|
+
code: "POLICY_DENIED",
|
|
1904
|
+
message: denial.reason ?? `Tool denied by policy: ${toolName}`,
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1860
1908
|
async executeToolCalls(calls, tools, sessionSandbox, callPolicy, approvalTimeoutMs, approvalHandler, attribution, signal, prepareOutput, recordToolCall) {
|
|
1861
1909
|
const results = [];
|
|
1862
1910
|
const policy = callPolicy ?? this.options.policy;
|
|
@@ -1868,9 +1916,10 @@ export class StubFabricSession {
|
|
|
1868
1916
|
// Decided when these tools were resolved, and never derived again from
|
|
1869
1917
|
// the definition: a tool not classified then runs as an ordinary tool.
|
|
1870
1918
|
const proposal = this.resolvedProposal(tools, requestedCall.tool, tool);
|
|
1919
|
+
const policyToolName = (!proposal && tool?.policyAlias) || requestedCall.tool;
|
|
1871
1920
|
const canonical = canonicalizeToolCall({
|
|
1872
1921
|
...requestedCall,
|
|
1873
|
-
tool:
|
|
1922
|
+
tool: policyToolName,
|
|
1874
1923
|
});
|
|
1875
1924
|
const call = { ...requestedCall, input: canonical.input };
|
|
1876
1925
|
// Providers are allowed to omit a call id. Mint one once at the session
|
|
@@ -1897,10 +1946,12 @@ export class StubFabricSession {
|
|
|
1897
1946
|
const executingPrincipal = toolExecutingPrincipal(tool);
|
|
1898
1947
|
const mountDecision = this.checkMountWriteAccess(call);
|
|
1899
1948
|
// Policy judges a proposal tool by its own name; resolution refuses an alias.
|
|
1900
|
-
const policyCall =
|
|
1949
|
+
const policyCall = { ...call, tool: policyToolName };
|
|
1901
1950
|
// File paths are judged in every form the sandbox reaches, as its layer
|
|
1902
1951
|
// judges them, so an approval is asked for here when one is needed there.
|
|
1903
|
-
const decision =
|
|
1952
|
+
const decision = this.toolAliasDenial(call.tool, policyToolName, policy) ??
|
|
1953
|
+
mountDecision ??
|
|
1954
|
+
evaluateToolCallPolicyInSandbox(policyCall, policy, sandbox);
|
|
1904
1955
|
const commandDecision = this.evaluateScopedCommandToolCall(tool, call.input, policy, renderedCommand);
|
|
1905
1956
|
if (!decision.allowed && !decision.approvalRequired) {
|
|
1906
1957
|
const error = decision.reason ?? `Tool call denied by policy: ${call.tool}`;
|
|
@@ -2053,7 +2104,7 @@ export class StubFabricSession {
|
|
|
2053
2104
|
? { approvals: approvalGrants.map(approvalGrantToJson) }
|
|
2054
2105
|
: {}),
|
|
2055
2106
|
...(tool?.metadata?.effect ? { effect: tool.metadata.effect } : {}),
|
|
2056
|
-
...(tool?.durable ? { durable: true } : {}),
|
|
2107
|
+
...(tool?.durable ? { durable: true, policyToolName } : {}),
|
|
2057
2108
|
// Recovery grants a scoped command only if it still renders this command.
|
|
2058
2109
|
...(tool?.durable && boundCommand !== undefined ? { renderedCommand: boundCommand } : {}),
|
|
2059
2110
|
toolCallId,
|
|
@@ -2107,32 +2158,35 @@ export class StubFabricSession {
|
|
|
2107
2158
|
const input = effectiveInput;
|
|
2108
2159
|
const submission = currentSubmissionContext();
|
|
2109
2160
|
const agentName = this.agent.name ?? submission?.agent;
|
|
2110
|
-
const execute = () =>
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2161
|
+
const execute = () => {
|
|
2162
|
+
this.assertToolAliasAtExecution(tool, call.tool, policyToolName, policy);
|
|
2163
|
+
return Promise.resolve(executeTool(tool, input, {
|
|
2164
|
+
sandbox,
|
|
2165
|
+
...(renderedCommand !== undefined ? { __fabricScopedCommand: renderedCommand } : {}),
|
|
2166
|
+
toolCallId,
|
|
2167
|
+
...(signal ? { signal } : {}),
|
|
2168
|
+
onOrphanSettled: (settlement) => this.recordSandboxOrphanSettlement(call.tool, toolCallId, settlement),
|
|
2169
|
+
...(approvalGrant ? { approval: approvalGrant } : {}),
|
|
2170
|
+
...(this.options.actor ? { actor: this.options.actor } : {}),
|
|
2171
|
+
...(this.options.tenantId ? { tenantId: this.options.tenantId } : {}),
|
|
2172
|
+
...(this.agent.id ? { agentId: this.agent.id } : {}),
|
|
2173
|
+
...(agentName ? { agentName } : {}),
|
|
2174
|
+
policyVersion: approvalInputDigest(policy ?? null),
|
|
2175
|
+
...(policy ? { policy } : {}),
|
|
2176
|
+
inputDigest: approvalInputDigest(input),
|
|
2177
|
+
...(tool.durable ? { step: this.createToolStep(toolCallId) } : {}),
|
|
2178
|
+
log: this.createToolProgressLogger(call.tool, toolCallId),
|
|
2179
|
+
harness: { sandbox },
|
|
2180
|
+
...(submission
|
|
2181
|
+
? {
|
|
2182
|
+
__fabricSubmission: {
|
|
2183
|
+
submissionId: submission.submissionId,
|
|
2184
|
+
attemptId: submission.attemptId,
|
|
2185
|
+
},
|
|
2186
|
+
}
|
|
2187
|
+
: {}),
|
|
2188
|
+
}));
|
|
2189
|
+
};
|
|
2136
2190
|
const rawOutput = await abandonToolOnAbort(approvedSandboxCalls.reduceRight((next, approvedCall) => () => runWithSandboxPolicyApproval(sandbox, approvedCall, next), execute), signal);
|
|
2137
2191
|
const dynamicOutput = unwrapDynamicToolResult(rawOutput);
|
|
2138
2192
|
const hookOutput = unwrapHookToolRunResult(dynamicOutput.output);
|
|
@@ -2676,32 +2730,35 @@ export class StubFabricSession {
|
|
|
2676
2730
|
const authorization = await this.authorizeRecoveredToolCall(call, toolName, tool, toolCallId, recoveryPolicy, sandbox, scoped, rendered);
|
|
2677
2731
|
const submission = currentSubmissionContext();
|
|
2678
2732
|
const agentName = this.agent.name ?? submission?.agent;
|
|
2679
|
-
const execute = () =>
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2733
|
+
const execute = () => {
|
|
2734
|
+
this.assertToolAliasAtExecution(tool, toolName, authorization.policyToolName, recoveryPolicy);
|
|
2735
|
+
return Promise.resolve(executeTool(tool, call.data?.input, {
|
|
2736
|
+
sandbox,
|
|
2737
|
+
...(scoped !== undefined ? { __fabricScopedCommand: scoped } : {}),
|
|
2738
|
+
toolCallId,
|
|
2739
|
+
...(signal ? { signal } : {}),
|
|
2740
|
+
onOrphanSettled: (settlement) => this.recordSandboxOrphanSettlement(toolName, toolCallId, settlement),
|
|
2741
|
+
...(authorization.approval ? { approval: authorization.approval } : {}),
|
|
2742
|
+
...(this.options.actor ? { actor: this.options.actor } : {}),
|
|
2743
|
+
...(this.options.tenantId ? { tenantId: this.options.tenantId } : {}),
|
|
2744
|
+
...(this.agent.id ? { agentId: this.agent.id } : {}),
|
|
2745
|
+
...(agentName ? { agentName } : {}),
|
|
2746
|
+
policyVersion: authorization.policyDigest,
|
|
2747
|
+
...(recoveryPolicy ? { policy: recoveryPolicy } : {}),
|
|
2748
|
+
inputDigest: authorization.inputDigest,
|
|
2749
|
+
step: this.createToolStep(toolCallId),
|
|
2750
|
+
log: this.createToolProgressLogger(toolName, toolCallId),
|
|
2751
|
+
harness: { sandbox },
|
|
2752
|
+
...(submission
|
|
2753
|
+
? {
|
|
2754
|
+
__fabricSubmission: {
|
|
2755
|
+
submissionId: submission.submissionId,
|
|
2756
|
+
attemptId: submission.attemptId,
|
|
2757
|
+
},
|
|
2758
|
+
}
|
|
2759
|
+
: {}),
|
|
2760
|
+
}));
|
|
2761
|
+
};
|
|
2705
2762
|
// Only re-grant the sandbox gate(s) whose persisted approvals were
|
|
2706
2763
|
// verified against the active policy and recorded command.
|
|
2707
2764
|
const approvedCalls = [
|
|
@@ -2849,12 +2906,26 @@ export class StubFabricSession {
|
|
|
2849
2906
|
});
|
|
2850
2907
|
}
|
|
2851
2908
|
const policyDigest = approvalInputDigest(policy ?? null);
|
|
2909
|
+
const policyToolName = tool.policyAlias || toolName;
|
|
2910
|
+
const recordedName = call.data?.policyToolName;
|
|
2911
|
+
// A legacy entry lacks evidence that an alias approval was absent or was
|
|
2912
|
+
// issued for the same name. Keep unrelated legacy recovery available.
|
|
2913
|
+
if (recordedName === undefined
|
|
2914
|
+
? policyToolName !== toolName ||
|
|
2915
|
+
evaluateToolNameRestrictions(toolName, policy)?.approvalRequired
|
|
2916
|
+
: recordedName !== policyToolName) {
|
|
2917
|
+
throw new FabricError({
|
|
2918
|
+
code: "POLICY_DENIED",
|
|
2919
|
+
message: `Recovered tool ${toolName} has no matching recorded policy name.`,
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2852
2922
|
const policyCall = {
|
|
2853
|
-
tool:
|
|
2923
|
+
tool: policyToolName,
|
|
2854
2924
|
input,
|
|
2855
2925
|
id: toolCallId,
|
|
2856
2926
|
};
|
|
2857
|
-
const toolDecision = this.
|
|
2927
|
+
const toolDecision = this.toolAliasDenial(toolName, policyToolName, policy) ??
|
|
2928
|
+
this.checkMountWriteAccess({ tool: toolName, input, id: toolCallId }) ??
|
|
2858
2929
|
evaluateToolCallPolicyInSandbox(policyCall, policy, sandbox);
|
|
2859
2930
|
const commandDecision = this.evaluateScopedCommandToolCall(tool, input, policy, scopedCommand);
|
|
2860
2931
|
const decisions = [toolDecision, commandDecision];
|
|
@@ -2874,7 +2945,7 @@ export class StubFabricSession {
|
|
|
2874
2945
|
}
|
|
2875
2946
|
const requiresApproval = decisions.some((decision) => decision.approvalRequired);
|
|
2876
2947
|
if (!requiresApproval)
|
|
2877
|
-
return { inputDigest, policyDigest };
|
|
2948
|
+
return { inputDigest, policyDigest, policyToolName };
|
|
2878
2949
|
const rawApprovals = Array.isArray(call.data?.approvals)
|
|
2879
2950
|
? call.data.approvals
|
|
2880
2951
|
: call.data?.approval !== undefined
|
|
@@ -2932,6 +3003,7 @@ export class StubFabricSession {
|
|
|
2932
3003
|
: {}),
|
|
2933
3004
|
inputDigest,
|
|
2934
3005
|
policyDigest,
|
|
3006
|
+
policyToolName,
|
|
2935
3007
|
};
|
|
2936
3008
|
}
|
|
2937
3009
|
async recordEntry(type, data) {
|
|
@@ -3640,6 +3712,7 @@ function compactionControlFor(options) {
|
|
|
3640
3712
|
return {
|
|
3641
3713
|
...(options.signal !== undefined ? { signal: options.signal } : {}),
|
|
3642
3714
|
...(options.modelTimeoutMs !== undefined ? { timeoutMs: options.modelTimeoutMs } : {}),
|
|
3715
|
+
...(options.modelProvider !== undefined ? { modelProvider: options.modelProvider } : {}),
|
|
3643
3716
|
};
|
|
3644
3717
|
}
|
|
3645
3718
|
/** AbortError for a cancelled prompt, carrying the signal's reason when it has one. */
|