veryfront 0.1.1271 → 0.1.1272-rc.23458
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/esm/deno.js +1 -1
- package/esm/src/agent/hosted/executor-model-bridge.d.ts +2 -0
- package/esm/src/agent/hosted/executor-model-bridge.d.ts.map +1 -1
- package/esm/src/agent/hosted/executor-model-bridge.js +2 -0
- package/esm/src/agent/hosted/executor-model-dispatch.d.ts +3 -0
- package/esm/src/agent/hosted/executor-model-dispatch.d.ts.map +1 -1
- package/esm/src/agent/hosted/executor-model-dispatch.js +3 -0
- package/esm/src/agent/hosted/executor-skill-observation.d.ts +18 -0
- package/esm/src/agent/hosted/executor-skill-observation.d.ts.map +1 -0
- package/esm/src/agent/hosted/executor-skill-observation.js +96 -0
- package/esm/src/agent/hosted/executor-tool-bridge.d.ts +3 -0
- package/esm/src/agent/hosted/executor-tool-bridge.d.ts.map +1 -1
- package/esm/src/agent/hosted/executor-tool-bridge.js +10 -4
- package/esm/src/agent/hosted/managed-executor-broker.d.ts.map +1 -1
- package/esm/src/agent/hosted/managed-executor-broker.js +11 -5
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +23 -6
- package/esm/src/agent/runtime/load-skill-tool.d.ts +5 -0
- package/esm/src/agent/runtime/load-skill-tool.d.ts.map +1 -1
- package/esm/src/agent/runtime/load-skill-tool.js +26 -4
- package/esm/src/agent/runtime/manual-pause.d.ts +3 -0
- package/esm/src/agent/runtime/manual-pause.d.ts.map +1 -1
- package/esm/src/agent/runtime/manual-pause.js +1 -0
- package/esm/src/agent/runtime/skill-policy-enforcement.d.ts +23 -0
- package/esm/src/agent/runtime/skill-policy-enforcement.d.ts.map +1 -1
- package/esm/src/agent/runtime/skill-policy-enforcement.js +117 -18
- package/esm/src/html/hydration-script-builder/hydration-runtime.generated.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/hydration-runtime.generated.js +1 -1
- package/esm/src/platform/compat/http/pinned-fetch.d.ts +1 -1
- package/esm/src/platform/compat/http/pinned-fetch.d.ts.map +1 -1
- package/esm/src/tool/host-tools.d.ts.map +1 -1
- package/esm/src/tool/host-tools.js +4 -1
- package/esm/src/tool/provider-observed-skill-bodies.d.ts +16 -0
- package/esm/src/tool/provider-observed-skill-bodies.d.ts.map +1 -0
- package/esm/src/tool/provider-observed-skill-bodies.js +73 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.d.ts.map +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +9 -9
package/esm/deno.js
CHANGED
|
@@ -19,6 +19,8 @@ export interface ExecutorModelDispatchPermit {
|
|
|
19
19
|
assertActive(): void;
|
|
20
20
|
/** Enter the owner-selected scope for this exact provider invocation. */
|
|
21
21
|
run?<T>(operation: () => T): T;
|
|
22
|
+
/** Called after the provider accepts the dispatch. */
|
|
23
|
+
dispatchSucceeded?(): void;
|
|
22
24
|
}
|
|
23
25
|
/** Generic broker hook; hosted callers use the required persistence wrapper. */
|
|
24
26
|
export type ExecutorModelDispatchGate = (request: ExecutorModelDispatch, context: ExecutorOperationContext) => void | ExecutorModelDispatchPermit | Promise<void | ExecutorModelDispatchPermit>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-model-bridge.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/executor-model-bridge.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,KAAK,EAAgB,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAIrF,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,yBAAyB,EAE/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,KAAK,qBAAqB,EAY3B,MAAM,4BAA4B,CAAC;AAEpC,iFAAiF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tB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAuCrC;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE;IACtD,OAAO,EAAE,eAAe,CAAC;IACzB,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GAAG,OAAO,CAAC,6BAA6B,GAAG,SAAS,CAAC,CAcrD"}
|
|
@@ -139,6 +139,7 @@ export function createExecutorModelBroker(options) {
|
|
|
139
139
|
permit?.assertActive();
|
|
140
140
|
const dispatch = () => call.model.doGenerate({ ...call.options, abortSignal: context.signal });
|
|
141
141
|
result = await (permit?.run ? permit.run(dispatch) : dispatch());
|
|
142
|
+
permit?.dispatchSucceeded?.();
|
|
142
143
|
}
|
|
143
144
|
catch (error) {
|
|
144
145
|
return modelFailureOrThrow(error, context);
|
|
@@ -166,6 +167,7 @@ export function createExecutorModelBroker(options) {
|
|
|
166
167
|
permit?.assertActive();
|
|
167
168
|
const dispatch = () => call.model.doStream({ ...call.options, abortSignal: context.signal });
|
|
168
169
|
result = await (permit?.run ? permit.run(dispatch) : dispatch());
|
|
170
|
+
permit?.dispatchSucceeded?.();
|
|
169
171
|
}
|
|
170
172
|
catch (error) {
|
|
171
173
|
yield modelFailureOrThrow(error, context);
|
|
@@ -3,6 +3,7 @@ import type { ExecutorOperation } from "../executor/channel.js";
|
|
|
3
3
|
import { type ExecutorBinding } from "../executor/protocol.js";
|
|
4
4
|
import type { AgentModelRuntimeResolver } from "../runtime/model-transport.js";
|
|
5
5
|
import { type ExecutorModelGrant } from "./executor-model-grant.js";
|
|
6
|
+
import type { ExecutorSkillObservation } from "./executor-skill-observation.js";
|
|
6
7
|
/** Ingress-owned invocation authority. The sink already owns its exact run identity. */
|
|
7
8
|
export interface HostedExecutorModelScope {
|
|
8
9
|
readonly binding: ExecutorBinding;
|
|
@@ -15,6 +16,8 @@ interface HostedModelBrokerInput {
|
|
|
15
16
|
allowedModelIds: ReadonlySet<string>;
|
|
16
17
|
scope: HostedExecutorModelScope;
|
|
17
18
|
grant: ExecutorModelGrant;
|
|
19
|
+
/** Host-owned record updated with each prompt dispatched to the provider. */
|
|
20
|
+
skillObservation?: ExecutorSkillObservation;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Hosted model operations require a captured, acknowledging run event sink.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-model-dispatch.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/executor-model-dispatch.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,KAAK,EAAE,iBAAiB,EAA4B,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,KAAK,eAAe,EAA4B,MAAM,yBAAyB,CAAC;AACzF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAI/E,OAAO,EAAgC,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"executor-model-dispatch.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/executor-model-dispatch.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,KAAK,EAAE,iBAAiB,EAA4B,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,KAAK,eAAe,EAA4B,MAAM,yBAAyB,CAAC;AACzF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAI/E,OAAO,EAAgC,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAElG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AA+FhF,wFAAwF;AACxF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;CACnC;AAED,UAAU,sBAAsB;IAC9B,mBAAmB,EAAE,yBAAyB,GAAG,SAAS,CAAC;IAC3D,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,KAAK,EAAE,wBAAwB,CAAC;IAChC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;CAC7C;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,sBAAsB,GAAG;IAC9B,uFAAuF;IACvF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC5C,0FAA0F;IAC1F,wBAAwB,CAAC,EAAE,IAAI,CAAC;CACjC,GACA,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CA2CxC;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,KAAK,EAAE,sBAAsB,GAAG;IAC9B,QAAQ,EAAE;QAAE,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAA;KAAE,CAAC;CACpF,GACA,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAKxC"}
|
|
@@ -187,6 +187,9 @@ function createScopedHostedModelBroker(input, persist) {
|
|
|
187
187
|
run(operation) {
|
|
188
188
|
return runWithVeryfrontCloudModelCallCapture({ receipt, assertActive }, operation);
|
|
189
189
|
},
|
|
190
|
+
dispatchSucceeded() {
|
|
191
|
+
input.skillObservation?.observePrompt(request.options.prompt);
|
|
192
|
+
},
|
|
190
193
|
};
|
|
191
194
|
},
|
|
192
195
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ModelRuntimePromptMessage } from "../../provider/types.js";
|
|
2
|
+
import type { ProviderObservedSkillBody } from "../../tool/provider-observed-skill-bodies.js";
|
|
3
|
+
import { type TrustedSkillLoadHistoryMessage } from "../runtime/skill-policy-enforcement.js";
|
|
4
|
+
/**
|
|
5
|
+
* Host-side record of which skill bodies the provider has received, built only
|
|
6
|
+
* from load_skill results the host returned and model requests the host brokered.
|
|
7
|
+
*/
|
|
8
|
+
export interface ExecutorSkillObservation {
|
|
9
|
+
/** Record trusted historical load_skill bodies for later exact prompt matching. */
|
|
10
|
+
recordTrustedHistory(messages: readonly TrustedSkillLoadHistoryMessage[]): void;
|
|
11
|
+
/** Record a host-executed tool result; only successful load_skill bodies count. */
|
|
12
|
+
recordToolResult(toolName: string, toolCallId: string | undefined, result: unknown): void;
|
|
13
|
+
/** Mark bodies observed when a brokered model request carries their results. */
|
|
14
|
+
observePrompt(prompt: readonly ModelRuntimePromptMessage[]): void;
|
|
15
|
+
observedSkillBodies(): ProviderObservedSkillBody[];
|
|
16
|
+
}
|
|
17
|
+
export declare function createExecutorSkillObservation(): ExecutorSkillObservation;
|
|
18
|
+
//# sourceMappingURL=executor-skill-observation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor-skill-observation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/executor-skill-observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAE9F,OAAO,EAIL,KAAK,8BAA8B,EACpC,MAAM,wCAAwC,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,mFAAmF;IACnF,oBAAoB,CAAC,QAAQ,EAAE,SAAS,8BAA8B,EAAE,GAAG,IAAI,CAAC;IAChF,mFAAmF;IACnF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1F,gFAAgF;IAChF,aAAa,CAAC,MAAM,EAAE,SAAS,yBAAyB,EAAE,GAAG,IAAI,CAAC;IAClE,mBAAmB,IAAI,yBAAyB,EAAE,CAAC;CACpD;AAgCD,wBAAgB,8BAA8B,IAAI,wBAAwB,CA4DzE"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createPrivateMap } from "../../security/private-map.js";
|
|
2
|
+
import { isLoadSkillToolName } from "../platform-tool-names.js";
|
|
3
|
+
import { extractSkillId, extractSkillToolAvailability, snapshotTrustedSkillLoadResults, } from "../runtime/skill-policy-enforcement.js";
|
|
4
|
+
import { snapshotBoundedJsonValue } from "../../schemas/json-value.js";
|
|
5
|
+
import { readToolResultOwnDataProperty as readOwn } from "../../tool/result.js";
|
|
6
|
+
const hasOwn = Object.hasOwn;
|
|
7
|
+
const isArray = Array.isArray;
|
|
8
|
+
const keys = Object.keys;
|
|
9
|
+
const freeze = Object.freeze;
|
|
10
|
+
function equalBody(left, right) {
|
|
11
|
+
if (left === right)
|
|
12
|
+
return true;
|
|
13
|
+
if (typeof left !== "object" || left === null || typeof right !== "object" || right === null) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (isArray(left)) {
|
|
17
|
+
if (!isArray(right) || left.length !== right.length)
|
|
18
|
+
return false;
|
|
19
|
+
for (let index = 0; index < left.length; index++) {
|
|
20
|
+
if (!equalBody(left[index], right[index]))
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (isArray(right))
|
|
26
|
+
return false;
|
|
27
|
+
const names = keys(left);
|
|
28
|
+
if (names.length !== keys(right).length)
|
|
29
|
+
return false;
|
|
30
|
+
for (let index = 0; index < names.length; index++) {
|
|
31
|
+
const name = names[index];
|
|
32
|
+
if (!hasOwn(right, name) || !equalBody(left[name], right[name]))
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
export function createExecutorSkillObservation() {
|
|
38
|
+
const bodies = createPrivateMap();
|
|
39
|
+
const observed = createPrivateMap();
|
|
40
|
+
const recordBody = (toolName, toolCallId, result) => {
|
|
41
|
+
if (!toolCallId || !isLoadSkillToolName(toolName))
|
|
42
|
+
return;
|
|
43
|
+
const skillId = extractSkillId(result);
|
|
44
|
+
const snapshot = snapshotBoundedJsonValue(result);
|
|
45
|
+
const references = snapshot.success
|
|
46
|
+
? extractSkillToolAvailability(snapshot.value)?.references
|
|
47
|
+
: undefined;
|
|
48
|
+
// A repeated call ID is ambiguous provenance and never becomes observable.
|
|
49
|
+
bodies.set(toolCallId, bodies.has(toolCallId) || !skillId || !snapshot.success || references === undefined
|
|
50
|
+
? null
|
|
51
|
+
: { body: freeze({ skillId, references: freeze(references) }), value: snapshot.value });
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
recordTrustedHistory(messages) {
|
|
55
|
+
const results = snapshotTrustedSkillLoadResults(messages);
|
|
56
|
+
for (let index = 0; index < results.length; index++) {
|
|
57
|
+
if (!hasOwn(results, index))
|
|
58
|
+
continue;
|
|
59
|
+
const result = results[index];
|
|
60
|
+
recordBody(result.toolName, result.toolCallId, result.result);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
recordToolResult(toolName, toolCallId, result) {
|
|
64
|
+
recordBody(toolName, toolCallId, result);
|
|
65
|
+
},
|
|
66
|
+
observePrompt(prompt) {
|
|
67
|
+
for (let index = 0; index < prompt.length; index++) {
|
|
68
|
+
if (!hasOwn(prompt, index))
|
|
69
|
+
continue;
|
|
70
|
+
const message = prompt[index];
|
|
71
|
+
const content = readOwn(message, "content");
|
|
72
|
+
if (readOwn(message, "role") !== "tool" || !isArray(content))
|
|
73
|
+
continue;
|
|
74
|
+
for (let partIndex = 0; partIndex < content.length; partIndex++) {
|
|
75
|
+
if (!hasOwn(content, partIndex))
|
|
76
|
+
continue;
|
|
77
|
+
const part = content[partIndex];
|
|
78
|
+
const toolCallId = readOwn(part, "toolCallId");
|
|
79
|
+
const toolName = readOwn(part, "toolName");
|
|
80
|
+
if (readOwn(part, "type") !== "tool-result" || typeof toolCallId !== "string" ||
|
|
81
|
+
typeof toolName !== "string" || !isLoadSkillToolName(toolName))
|
|
82
|
+
continue;
|
|
83
|
+
const body = bodies.get(toolCallId);
|
|
84
|
+
const output = readOwn(part, "output");
|
|
85
|
+
if (!body || readOwn(output, "type") !== "json")
|
|
86
|
+
continue;
|
|
87
|
+
const snapshot = snapshotBoundedJsonValue(readOwn(output, "value"));
|
|
88
|
+
if (snapshot.success && equalBody(body.value, snapshot.value)) {
|
|
89
|
+
observed.set(toolCallId, body.body);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
observedSkillBodies: () => [...observed.values()],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RemoteToolSource, ToolExecutionContext } from "../../tool/types.js";
|
|
2
|
+
import type { ExecutorSkillObservation } from "./executor-skill-observation.js";
|
|
2
3
|
import { type AdmitExecutorToolCall } from "../../runtime/tool-call-admission-dispatch.js";
|
|
3
4
|
import type { ExecutorOperation } from "../executor/channel.js";
|
|
4
5
|
import { type ExecutorBinding } from "../executor/protocol.js";
|
|
@@ -31,5 +32,7 @@ export declare function createExecutorToolBroker(options: {
|
|
|
31
32
|
limits?: Partial<ExecutorToolLimits>;
|
|
32
33
|
/** Trusted private writer hook; absent preserves the released tool path. */
|
|
33
34
|
admitToolCall?: AdmitExecutorToolCall;
|
|
35
|
+
/** Host-owned record of skill bodies the brokered model requests delivered. */
|
|
36
|
+
skillObservation?: ExecutorSkillObservation;
|
|
34
37
|
}): ReadonlyMap<string, ExecutorOperation>;
|
|
35
38
|
//# sourceMappingURL=executor-tool-bridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-tool-bridge.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/executor-tool-bridge.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"executor-tool-bridge.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/executor-tool-bridge.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAKlF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,+CAA+C,CAAC;AAGvD,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAOL,KAAK,kBAAkB,EASxB,MAAM,2BAA2B,CAAC;AAOnC,yFAAyF;AACzF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjC,mGAAmG;IACnG,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,KAAK,EAAE;QACL,OAAO,EAAE,eAAe,CAAC;QACzB,MAAM,EAAE,WAAW,CAAC;QACpB,YAAY,IAAI,IAAI,CAAC;KACtB,CAAC;IACF,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACrD,yFAAyF;IACzF,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrC,4EAA4E;IAC5E,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;CAC7C,GAAG,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CA6QzC"}
|
|
@@ -2,6 +2,7 @@ import { copyPrivateSet, createPrivateSet } from "../../security/private-set.js"
|
|
|
2
2
|
import { copyPrivateMap, createPrivateMap } from "../../security/private-map.js";
|
|
3
3
|
import { pushPrivateArray } from "../../security/private-array.js";
|
|
4
4
|
import { chainPrivatePromise, createPrivateDeferred, observePrivatePromise, resolvePrivatePromise, } from "../../security/private-promise.js";
|
|
5
|
+
import { setProviderObservedSkillBodies, } from "../../tool/provider-observed-skill-bodies.js";
|
|
5
6
|
import { runWithToolCallAdmissionReceipt, } from "../../runtime/tool-call-admission-dispatch.js";
|
|
6
7
|
import { getToolCallAdmissionReceiptSchema } from "../../runtime/tool-call-admission-receipt.js";
|
|
7
8
|
import { DurableRunEventPersistenceError } from "../conversation/private-run-event.js";
|
|
@@ -19,6 +20,7 @@ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
|
19
20
|
*/
|
|
20
21
|
export function createExecutorToolBroker(options) {
|
|
21
22
|
const limits = executorToolLimits(options.limits);
|
|
23
|
+
const skillObservation = options.skillObservation;
|
|
22
24
|
const admitToolCall = options.admitToolCall;
|
|
23
25
|
if (admitToolCall !== undefined && typeof admitToolCall !== "function") {
|
|
24
26
|
throw new TypeError("Invalid tool-call admission hook");
|
|
@@ -181,6 +183,7 @@ export function createExecutorToolBroker(options) {
|
|
|
181
183
|
...call?.projectContext,
|
|
182
184
|
}
|
|
183
185
|
: capability.context,
|
|
186
|
+
observedSkillBodies: skillObservation?.observedSkillBodies() ?? [],
|
|
184
187
|
publisher: capability.publisher,
|
|
185
188
|
publisherReceiver: capability.publisherReceiver,
|
|
186
189
|
correlation: request,
|
|
@@ -194,10 +197,11 @@ export function createExecutorToolBroker(options) {
|
|
|
194
197
|
});
|
|
195
198
|
assertCall();
|
|
196
199
|
if (mode === "execute") {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
const delivered = executorToolJson(result === undefined ? null : result, limits.maxResultBytes);
|
|
201
|
+
yield executorToolJson({ type: "result", result: delivered });
|
|
202
|
+
// Resuming after yield means the channel drained the validated result frame.
|
|
203
|
+
if (call)
|
|
204
|
+
skillObservation?.recordToolResult(call.toolName, call.toolCallId, delivered);
|
|
201
205
|
}
|
|
202
206
|
else {
|
|
203
207
|
if (!isArray(result) || result.length > limits.maxToolsPerSource ||
|
|
@@ -375,6 +379,8 @@ async function* callWithProgress(options) {
|
|
|
375
379
|
}
|
|
376
380
|
},
|
|
377
381
|
};
|
|
382
|
+
// Only host-verified observations count; executor-side state never crosses the channel.
|
|
383
|
+
setProviderObservedSkillBodies(context, options.observedSkillBodies);
|
|
378
384
|
const started = chainPrivatePromise(resolvePrivatePromise(), () => {
|
|
379
385
|
check();
|
|
380
386
|
return options.invoke(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-executor-broker.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/managed-executor-broker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,+CAA+C,CAAC;AAavD,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"managed-executor-broker.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/managed-executor-broker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,+CAA+C,CAAC;AAavD,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,qCAAqC,CAAC;AAO7C,OAAO,KAAK,EAEV,4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ACpC,KAAK,EAAE,kBAAkB,CAAC;QAC1B,YAAY,CAAC,EAAE,iBAAiB,CAAC;QACjC,kFAAkF;QAClF,wBAAwB,CAAC,EAAE,IAAI,CAAC;KACjC,CAAC;IACF,KAAK,EAAE;QACL,6FAA6F;QAC7F,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC9F,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;QACrD,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAClE,aAAa,CAAC,EAAE,qBAAqB,CAAC;KACvC,CAAC;IACF,WAAW,EAAE,gBAAgB,CAAC;IAC9B,KAAK,EAAE,UAAU,CAAC;CACnB;AAQD,kEAAkE;AAClE,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,gCAAgC,EAChC,eAAe,CAChB,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,EACrC,qBAAqB,CAAC,EAAE,4BAA4B;;;;;mBAQ3C,yBAAyB,cACrB;QAAE,UAAU,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;KAAE,KACvD,OAAO,CAAC,sBAAsB,CAAC;;EAmTnC"}
|
|
@@ -4,6 +4,7 @@ import { hasTrustedPlatformSource, inheritTrustedPlatformSource, } from "../../t
|
|
|
4
4
|
import { hasTrustedHostToolProvenance, inheritTrustedHostToolProvenance, } from "../../tool/host-tool-provenance.js";
|
|
5
5
|
import { parseSourceIntegrationPolicyManifest, } from "../../integrations/source-policy.js";
|
|
6
6
|
import { snapshotOwnDataRecords } from "../../security/own-data-record.js";
|
|
7
|
+
import { createExecutorSkillObservation, } from "./executor-skill-observation.js";
|
|
7
8
|
import { reserveExecutorToolMetadata } from "./executor-tool-schema.js";
|
|
8
9
|
import { EXECUTOR_PROJECT_TOOL_SOURCE_ID } from "./executor-runtime-install-schema.js";
|
|
9
10
|
import { getExecutorProjectToolInstallSchema, } from "./executor-runtime-install-schema.js";
|
|
@@ -96,8 +97,9 @@ export function createManagedExecutorBroker(options, trustedRuntimeFactory) {
|
|
|
96
97
|
if (bindSessionOwnedWork !== undefined && typeof bindSessionOwnedWork !== "function") {
|
|
97
98
|
throw new TypeError("Invalid executor session-owned work binder");
|
|
98
99
|
}
|
|
100
|
+
const skillObservation = createExecutorSkillObservation();
|
|
99
101
|
// Validate every trusted capability before reserving pool admission.
|
|
100
|
-
buildBrokerOperations(validationBinding, new AbortController().signal, operationInput, installation, allowedModelIds, selectedModelId);
|
|
102
|
+
buildBrokerOperations(validationBinding, new AbortController().signal, operationInput, installation, allowedModelIds, selectedModelId, skillObservation);
|
|
101
103
|
let gate;
|
|
102
104
|
let localRuntime;
|
|
103
105
|
const session = pool.start({
|
|
@@ -115,7 +117,7 @@ export function createManagedExecutorBroker(options, trustedRuntimeFactory) {
|
|
|
115
117
|
};
|
|
116
118
|
}
|
|
117
119
|
const channelBinding = toChannelBinding(binding);
|
|
118
|
-
const operations = buildBrokerOperations(channelBinding, signal, operationInput, installation, allowedModelIds, selectedModelId);
|
|
120
|
+
const operations = buildBrokerOperations(channelBinding, signal, operationInput, installation, allowedModelIds, selectedModelId, skillObservation);
|
|
119
121
|
gate = createExecutorOperationGate({
|
|
120
122
|
binding: channelBinding,
|
|
121
123
|
signal,
|
|
@@ -185,7 +187,7 @@ export function createManagedExecutorBroker(options, trustedRuntimeFactory) {
|
|
|
185
187
|
},
|
|
186
188
|
}]]),
|
|
187
189
|
},
|
|
188
|
-
}, installation, allowedModelIds, selectedModelId);
|
|
190
|
+
}, installation, allowedModelIds, selectedModelId, skillObservation);
|
|
189
191
|
return createExecutorOperationGate({
|
|
190
192
|
binding: channelBinding,
|
|
191
193
|
signal: session.signal,
|
|
@@ -229,6 +231,8 @@ export function createManagedExecutorBroker(options, trustedRuntimeFactory) {
|
|
|
229
231
|
if (!session.accepted || gate.state !== "prepared") {
|
|
230
232
|
throw new Error("Managed executor runtime is not accepted");
|
|
231
233
|
}
|
|
234
|
+
streamInput.abortSignal.throwIfAborted();
|
|
235
|
+
skillObservation.recordTrustedHistory(streamInput.messages);
|
|
232
236
|
gate.beginExecution();
|
|
233
237
|
return await remoteAgent.stream(streamInput);
|
|
234
238
|
},
|
|
@@ -424,10 +428,11 @@ function installedToolNames(installation, catalog) {
|
|
|
424
428
|
}
|
|
425
429
|
return allowed;
|
|
426
430
|
}
|
|
427
|
-
function buildBrokerOperations(binding, signal, input, installation, allowedModelIds, selectedModelId) {
|
|
431
|
+
function buildBrokerOperations(binding, signal, input, installation, allowedModelIds, selectedModelId, skillObservation) {
|
|
428
432
|
const scope = { binding, signal, assertActive: () => signal.throwIfAborted() };
|
|
429
433
|
const model = installation.grant.execution.kind === "canonical"
|
|
430
434
|
? createHostedExecutorModelBroker({
|
|
435
|
+
skillObservation,
|
|
431
436
|
projectId: installation.grant.execution.projectId,
|
|
432
437
|
resolveModelRuntime: input.model.resolver,
|
|
433
438
|
allowedModelIds,
|
|
@@ -437,13 +442,14 @@ function buildBrokerOperations(binding, signal, input, installation, allowedMode
|
|
|
437
442
|
...(input.model.modelCallCaptureReceipts ? { modelCallCaptureReceipts: true } : {}),
|
|
438
443
|
})
|
|
439
444
|
: createEphemeralHostedExecutorModelBroker({
|
|
445
|
+
skillObservation,
|
|
440
446
|
resolveModelRuntime: input.model.resolver,
|
|
441
447
|
allowedModelIds,
|
|
442
448
|
scope,
|
|
443
449
|
grant: input.model.grant,
|
|
444
450
|
prepared: { conversationId: null, canonicalRootRun: null },
|
|
445
451
|
});
|
|
446
|
-
const tools = createExecutorToolBroker({ scope, ...input.tools });
|
|
452
|
+
const tools = createExecutorToolBroker({ scope, ...input.tools, skillObservation });
|
|
447
453
|
const persistence = createExecutorPersistenceBroker({
|
|
448
454
|
expectedBinding: binding,
|
|
449
455
|
capabilityIds: installation.capabilities.persistence,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,gBAAgB,EAKtB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,gBAAgB,EAKtB,MAAM,mBAAmB,CAAC;AA0D3B,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,6BAA6B,EAClC,KAAK,aAAa,EAIlB,KAAK,OAAO,EAGZ,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EAGd,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAqB,KAAK,MAAM,EAAY,MAAM,oBAAoB,CAAC;AA2B9E,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,8CAA8C,CAAC;AA+KtD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,8BAA8B,EAC9B,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACL,sBAAsB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;QACjC,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,GACA,OAAO,CAAC,aAAa,CAAC;IAoLzB;;;OAGG;IACG,MAAM,CACV,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,SAAS,CAAC,EAAE,2BAA2B,EACvC,aAAa,CAAC,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,MAAM,EAChC,WAAW,CAAC,EAAE,WAAW,EACzB,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GACnC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IA29FtC;;OAEG;YACW,wBAAwB;IAoEtC,OAAO,CAAC,0BAA0B;YAUpB,eAAe;IA0D7B;;OAEG;YACW,mBAAmB;IAMjC;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,sBAAsB;IAoB9B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC;IAI5B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC;QAC9B,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAIF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAGnC"}
|
|
@@ -6,7 +6,7 @@ import { forEachSequential } from "./sequential.js";
|
|
|
6
6
|
import { agentManualPauseBoundary, isAgentManualPauseBoundary, parseAgentPauseCheckpoint, } from "./manual-pause.js";
|
|
7
7
|
import { getAgentRuntimeToolCallPart } from "./message-adapter.js";
|
|
8
8
|
import { admitTerminalDispatch, createTerminalRunControl, isTerminalRunControlError, isTerminalRunToolName, terminalCompletionResponse, terminalDispatchRecord, terminalReceiptPersistenceFailure, } from "./terminal-run-control.js";
|
|
9
|
-
import { appendPrivateArray, concatPrivateArrays, filterPrivateArray, flatMapPrivateArray, forEachPrivateArray, mapPrivateArray, pushPrivateArray, somePrivateArray, } from "../../security/private-array.js";
|
|
9
|
+
import { appendPrivateArray, concatPrivateArrays, filterPrivateArray, flatMapPrivateArray, forEachPrivateArray, mapPrivateArray, pushPrivateArray, slicePrivateArray, somePrivateArray, } from "../../security/private-array.js";
|
|
10
10
|
import { utf8ByteLength } from "../../utils/utf8-byte-length.js";
|
|
11
11
|
import { createPrivateTextDecoder, encodePrivateText, PrivateTextEncoder, privateTextSlice, privateTextStartsWith, privateTextTrim, } from "../../security/private-text.js";
|
|
12
12
|
/**
|
|
@@ -59,7 +59,8 @@ import { resolveAgentSystem } from "./effective-agent-system.js";
|
|
|
59
59
|
import { resolveActiveProviderReplayProvider, resolveRuntimeGenAiProviderName, } from "./provider-replay-protocol.js";
|
|
60
60
|
import { attachOutputSchemaParser, resolveAgentOutputSchema, } from "../output-schema.js";
|
|
61
61
|
import { captureStreamedToolCallInput, collectFinalStreamToolResults, collectGeneratedToolResults, createToolErrorMessage, createToolResultMessage, getProviderExecutedToolNames, getToolResultError, hasSubstantiveAssistantText, isInterruptedClientToolCall, isRecoverablePlaceholderToolCall, isStreamedToolCallIncomplete, isToolResultPart, materializeStreamedToolCall, shouldContinueAfterStreamStep, } from "./tool-result-continuation.js";
|
|
62
|
-
import { enforceSkillPolicy, hasTrustedPlatformPolicyToolDefinition, hasTrustedPlatformPolicyToolResultPart, inheritTrustedPlatformPolicyToolResultPart, isFormInputToolName, isLoadSkillToolName, markTrustedPlatformPolicyToolResultPart, prepareTrustedPlatformPolicyMessageForPersistence, restoreTrustedPlatformPolicyResultsFromPersistedHistory, SUBMITTED_FORM_INPUT_CONTEXT_KEY, } from "./skill-policy-enforcement.js";
|
|
62
|
+
import { enforceSkillPolicy, getProviderObservedSkillBodies, getTrustedSkillLoadResultIds, hasTrustedPlatformPolicyToolDefinition, hasTrustedPlatformPolicyToolResultPart, inheritTrustedPlatformPolicyToolResultPart, isFormInputToolName, isLoadSkillToolName, markTrustedPlatformPolicyToolResultPart, prepareTrustedPlatformPolicyMessageForPersistence, restoreTrustedPlatformPolicyResultsFromPersistedHistory, restoreTrustedSkillLoadResultsFromPauseCheckpoint, SUBMITTED_FORM_INPUT_CONTEXT_KEY, } from "./skill-policy-enforcement.js";
|
|
63
|
+
import { setProviderObservedSkillBodies, } from "../../tool/provider-observed-skill-bodies.js";
|
|
63
64
|
import { AgentLoopSkillState } from "./agent-loop-skill-state.js";
|
|
64
65
|
import { isRuntimeGeneratedUserMessage, markRuntimeGeneratedUserMessage, } from "./runtime-message-origin.js";
|
|
65
66
|
import { EMPTY_RESPONSE_RECOVERY_PROMPT, RuntimeEmptyResponseError, } from "./empty-response-recovery.js";
|
|
@@ -1649,8 +1650,11 @@ const ownContextKeys = Reflect.ownKeys;
|
|
|
1649
1650
|
const contextDescriptor = Object.getOwnPropertyDescriptor;
|
|
1650
1651
|
const defineContextProperty = Object.defineProperty;
|
|
1651
1652
|
const readContextProperty = Reflect.get;
|
|
1652
|
-
function applicationExecutionContext(context) {
|
|
1653
|
+
function applicationExecutionContext(context, providerObservedSkillBodies) {
|
|
1653
1654
|
const projected = {};
|
|
1655
|
+
if (providerObservedSkillBodies !== undefined) {
|
|
1656
|
+
setProviderObservedSkillBodies(projected, providerObservedSkillBodies);
|
|
1657
|
+
}
|
|
1654
1658
|
if (!context)
|
|
1655
1659
|
return projected;
|
|
1656
1660
|
forEachPrivateArray(ownContextKeys(context), (key) => {
|
|
@@ -2836,6 +2840,8 @@ export class AgentRuntime {
|
|
|
2836
2840
|
currentSystemPrompt = preparedStep.systemPrompt;
|
|
2837
2841
|
currentRuntimeContext = preparedStep.runtimeContext;
|
|
2838
2842
|
const toolContext = preparedStep.toolContext;
|
|
2843
|
+
// Keep this snapshot fixed while calls from the same provider response execute.
|
|
2844
|
+
const providerObservedSkillBodies = getProviderObservedSkillBodies(currentMessages);
|
|
2839
2845
|
const effectiveToolExposurePlan = agentWriteFinalResponseToolGuardEnabled
|
|
2840
2846
|
? applyAgentWriteFinalResponseGuard(preparedStep.toolExposurePlan, {
|
|
2841
2847
|
reloadable: runtimeStepToolLoading.mode === "deferred",
|
|
@@ -3346,7 +3352,7 @@ export class AgentRuntime {
|
|
|
3346
3352
|
agentId: this.id,
|
|
3347
3353
|
}) ??
|
|
3348
3354
|
undefined);
|
|
3349
|
-
const executionContext = applicationExecutionContext(toolContext);
|
|
3355
|
+
const executionContext = applicationExecutionContext(toolContext, providerObservedSkillBodies);
|
|
3350
3356
|
executionContext.projectId = cacheCtx?.projectId ?? toolContext?.projectId;
|
|
3351
3357
|
throwIfAborted(abortSignal);
|
|
3352
3358
|
const result = await traceConfiguredToolExecution({
|
|
@@ -3497,6 +3503,8 @@ export class AgentRuntime {
|
|
|
3497
3503
|
markRuntimeGeneratedUserMessage(message);
|
|
3498
3504
|
return message;
|
|
3499
3505
|
});
|
|
3506
|
+
// JSON checkpoints drop in-memory trust markers; restore only the runtime-recorded results.
|
|
3507
|
+
restoreTrustedSkillLoadResultsFromPauseCheckpoint(currentMessages, checkpoint?.trustedSkillLoadResultIds);
|
|
3500
3508
|
applyProviderReplayCheckpointsToMessages(currentMessages, getRuntimeProviderReplayCheckpoints(this.config), { activeProvider: resolveActiveProviderReplayProvider(languageModel) });
|
|
3501
3509
|
const totalUsage = checkpoint?.usage ??
|
|
3502
3510
|
{ promptTokens: 0, completionTokens: 0, totalTokens: 0 };
|
|
@@ -3570,6 +3578,11 @@ export class AgentRuntime {
|
|
|
3570
3578
|
recoveredInterruptedLocalToolBatch,
|
|
3571
3579
|
hasSubmittedFormInput: skillState.hasSubmittedFormInput,
|
|
3572
3580
|
activeSkillDelegationOverrides: skillState.activeSkillDelegationOverrides,
|
|
3581
|
+
// Omitted when empty so checkpoints without trusted loads keep the prior shape.
|
|
3582
|
+
...(() => {
|
|
3583
|
+
const ids = getTrustedSkillLoadResultIds(currentMessages);
|
|
3584
|
+
return ids.length > 0 ? { trustedSkillLoadResultIds: ids } : {};
|
|
3585
|
+
})(),
|
|
3573
3586
|
resumeToolCallExecuted,
|
|
3574
3587
|
agentWriteFinalResponseToolGuardEnabled,
|
|
3575
3588
|
interruptedLocalToolBatchRecoveryStep,
|
|
@@ -3735,7 +3748,9 @@ export class AgentRuntime {
|
|
|
3735
3748
|
args: resumeToolCall.input,
|
|
3736
3749
|
status: "executing",
|
|
3737
3750
|
};
|
|
3738
|
-
const executionContext = applicationExecutionContext(toolContext
|
|
3751
|
+
const executionContext = applicationExecutionContext(toolContext,
|
|
3752
|
+
// Partial results from the parked assistant turn were not yet provider-observed.
|
|
3753
|
+
getProviderObservedSkillBodies(slicePrivateArray(currentMessages, 0, admittedTurn.start)));
|
|
3739
3754
|
try {
|
|
3740
3755
|
// The trusted parked call was already exposed in the prior segment.
|
|
3741
3756
|
// Recheck current authorization without requiring its lost step visibility.
|
|
@@ -3819,6 +3834,8 @@ export class AgentRuntime {
|
|
|
3819
3834
|
await this.recordToolError(persistMessage, toolCall, error instanceof Error ? error.message : String(error), { controller, encoder }, currentMessages, toolCalls);
|
|
3820
3835
|
}
|
|
3821
3836
|
}
|
|
3837
|
+
// Include the parked result delivered to this request, but exclude new same-step results.
|
|
3838
|
+
const providerObservedSkillBodies = getProviderObservedSkillBodies(currentMessages);
|
|
3822
3839
|
const modelMessages = toolResultContext
|
|
3823
3840
|
? createModelToolResultContextMessages(currentMessages, toolResultContext)
|
|
3824
3841
|
: currentMessages;
|
|
@@ -4620,7 +4637,7 @@ export class AgentRuntime {
|
|
|
4620
4637
|
const startTime = Date.now();
|
|
4621
4638
|
toolCall.args = applySkillDelegationOverridesToToolInput(tc.name, toolCall.args, skillState.activeSkillDelegationOverrides, resolveConfiguredTool(this.config.tools, tc.name, { agentId: this.id }) ?? undefined);
|
|
4622
4639
|
callbacks?.onToolCall?.(toolCall);
|
|
4623
|
-
const executionContext = applicationExecutionContext(toolContext);
|
|
4640
|
+
const executionContext = applicationExecutionContext(toolContext, providerObservedSkillBodies);
|
|
4624
4641
|
const result = await runWithToolCallOccurrenceDispatch(tc, () => traceConfiguredToolExecution({
|
|
4625
4642
|
mode: "stream",
|
|
4626
4643
|
agentId: this.id,
|
|
@@ -41,6 +41,11 @@ export type RuntimeLoadSkillToolOptions = {
|
|
|
41
41
|
description?: string;
|
|
42
42
|
logger?: RuntimeSkillMetadataLogger;
|
|
43
43
|
skillDocumentParserProvider?: SkillDocumentParserProvider;
|
|
44
|
+
/**
|
|
45
|
+
* Reject reference reads when the execution context carries no provider-observed
|
|
46
|
+
* skill body snapshot. Hosts that execute this tool for a remote runtime set it.
|
|
47
|
+
*/
|
|
48
|
+
requireProviderObservation?: boolean;
|
|
44
49
|
};
|
|
45
50
|
export declare const getRuntimeLoadSkillToolInputSchema: () => import("../../internal-agents/schema.js").Schema<import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
46
51
|
cursor: import("../../internal-agents/schema.js").Schema<number | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-skill-tool.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/load-skill-tool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,kCAAkC,CAAC;AAChF,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,qBAAqB,CAAC;AAUtE,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,iCAAiC,CAAC;AAWzC,OAAO,KAAK,EAEV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"load-skill-tool.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/load-skill-tool.ts"],"names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3C,MAAM,MAAM,0BAA0B,GAClC,0BAA0B,GAC1B,mCAAmC,GACnC,+BAA+B,GAC/B,2BAA2B,CAAC;AAuzChC;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,2BAA2B,GACnC,IAAI,CAAC,yBAAyB,EAAE,0BAA0B,CAAC,CA+Z7D"}
|
|
@@ -9,6 +9,7 @@ import { buildStrictRuntimeLoadedSkillResponse, normalizeStrictRuntimeSkillRefer
|
|
|
9
9
|
import { hasControlCharacters, isWellFormedUtf16 } from "../../skill/string-safety.js";
|
|
10
10
|
import { isOwnDataPropertyDescriptor, snapshotOwnDataPropertyArray, } from "./data-property-descriptor.js";
|
|
11
11
|
import { compareStrings } from "../../utils/compare.js";
|
|
12
|
+
import { hasProviderObservedSkillBody, hasProviderObservedSkillReferences, } from "../../tool/provider-observed-skill-bodies.js";
|
|
12
13
|
const ArrayIsArray = Array.isArray;
|
|
13
14
|
const ObjectDefineProperty = Object.defineProperty;
|
|
14
15
|
const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
@@ -27,7 +28,7 @@ function isRuntimeLoadSkillArray(value) {
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
/** Shared runtime load skill description value. */
|
|
30
|
-
export const RUNTIME_LOAD_SKILL_DESCRIPTION = `Load
|
|
31
|
+
export const RUNTIME_LOAD_SKILL_DESCRIPTION = `Load skill instructions; loading does not perform the task. ${LOAD_SKILL_POLICY_CLAUSES} ${LOAD_SKILL_OVERRIDE_FORWARDING} To discover authorized skill IDs, use the inventory object. Use a cursor listed in context when present, then follow each nextCursor value. To load a skill, use the load object with only skillId. Wait for the body result before choosing a reference; never batch the first body load with a reference read. To read a file listed in the loaded skill's references, use the reference object with that same skillId and the listed file path: {"reference":{"skillId":"<loaded-skill-id>","file":"<listed-relative-path>"}}. Reference filenames are not tool names or skill IDs. The legacy load.file form remains accepted.`;
|
|
31
32
|
function rememberBoundedRecordValue(record, key, value, maxEntries) {
|
|
32
33
|
const keys = Object.keys(record);
|
|
33
34
|
const keyIsEnumerable = keys.includes(key);
|
|
@@ -930,11 +931,20 @@ function buildRuntimeLoadSkillInputSchema(options, authorizationStore) {
|
|
|
930
931
|
: v.union([firstAlternative, secondAlternative, ...restAlternatives]);
|
|
931
932
|
})();
|
|
932
933
|
}
|
|
934
|
+
function buildUnobservedSkillBodyError(skillId) {
|
|
935
|
+
return {
|
|
936
|
+
error: `Read the load_skill result for "${skillId}" before requesting reference files. Retry this reference in the next step using a listed path.`,
|
|
937
|
+
};
|
|
938
|
+
}
|
|
933
939
|
async function loadRuntimeSkillReferenceFile(options, builtinStore, privateAuthority, authorizationStore, trustedResponseStore, trustedReferenceStore, loadedSkillResponses, loadedSkillReferenceResponses, skillId, file, executionContext, budget) {
|
|
934
940
|
const normalizedFile = normalizeStrictRuntimeSkillReferencePath(file);
|
|
935
941
|
if (!normalizedFile) {
|
|
936
942
|
return { error: `Invalid reference file path: ${file}` };
|
|
937
943
|
}
|
|
944
|
+
const observed = hasProviderObservedSkillBody(executionContext, skillId);
|
|
945
|
+
if (observed === false || (observed === undefined && options.requireProviderObservation === true)) {
|
|
946
|
+
return buildUnobservedSkillBodyError(skillId);
|
|
947
|
+
}
|
|
938
948
|
authorityAttempts: for (let attempt = 0; attempt < RUNTIME_SKILL_PRIVATE_AUTHORITY_MAX_ATTEMPTS; attempt += 1) {
|
|
939
949
|
let authorityGuard = privateAuthority.begin();
|
|
940
950
|
const loadedSkillKey = buildRuntimeSkillCacheKey(options.context, skillId);
|
|
@@ -942,13 +952,18 @@ async function loadRuntimeSkillReferenceFile(options, builtinStore, privateAutho
|
|
|
942
952
|
const cachedAuthorization = authorizationStore.get(loadedSkillKey);
|
|
943
953
|
const resumedReferenceIsAdvertised = !hasLoadedSkillResponse &&
|
|
944
954
|
executionContextAdvertisesReference(executionContext, skillId, file, normalizedFile);
|
|
955
|
+
const observedBodyMayAuthorizeColdReference = !hasLoadedSkillResponse &&
|
|
956
|
+
observed === true;
|
|
945
957
|
const reusableCachedAuthorization = cachedAuthorization &&
|
|
946
|
-
(!cachedAuthorization.requiresActiveSkillContext || resumedReferenceIsAdvertised
|
|
958
|
+
(!cachedAuthorization.requiresActiveSkillContext || resumedReferenceIsAdvertised ||
|
|
959
|
+
(observedBodyMayAuthorizeColdReference &&
|
|
960
|
+
hasProviderObservedSkillReferences(executionContext, skillId, cachedAuthorization.references) === true))
|
|
947
961
|
? cachedAuthorization
|
|
948
962
|
: undefined;
|
|
949
963
|
if (!reusableCachedAuthorization &&
|
|
950
964
|
!hasLoadedSkillResponse &&
|
|
951
|
-
!resumedReferenceIsAdvertised
|
|
965
|
+
!resumedReferenceIsAdvertised &&
|
|
966
|
+
!observedBodyMayAuthorizeColdReference) {
|
|
952
967
|
return {
|
|
953
968
|
error: `Skill "${skillId}" must be loaded before reference file "${normalizedFile}". ` +
|
|
954
969
|
`Call load_skill with {"load":{"skillId":"${skillId}"}} first, then request one of the listed reference files.`,
|
|
@@ -956,7 +971,8 @@ async function loadRuntimeSkillReferenceFile(options, builtinStore, privateAutho
|
|
|
956
971
|
}
|
|
957
972
|
let authorization = reusableCachedAuthorization;
|
|
958
973
|
if (!authorization) {
|
|
959
|
-
const requiresActiveSkillContext = !hasLoadedSkillResponse &&
|
|
974
|
+
const requiresActiveSkillContext = !hasLoadedSkillResponse &&
|
|
975
|
+
(resumedReferenceIsAdvertised || observedBodyMayAuthorizeColdReference);
|
|
960
976
|
const bodyPublication = privateAuthority.captureBody(loadedSkillKey);
|
|
961
977
|
const projectSkill = await loadRuntimeSkillBody(options, skillId, budget);
|
|
962
978
|
budget.throwIfTerminated();
|
|
@@ -1020,6 +1036,12 @@ async function loadRuntimeSkillReferenceFile(options, builtinStore, privateAutho
|
|
|
1020
1036
|
authorityGuard = published.guard;
|
|
1021
1037
|
authorization = published.value;
|
|
1022
1038
|
}
|
|
1039
|
+
// Bind the observation to this scope's body: a body seen under another
|
|
1040
|
+
// project or branch advertised a different reference list.
|
|
1041
|
+
if (hasProviderObservedSkillReferences(executionContext, skillId, authorization.references) ===
|
|
1042
|
+
false) {
|
|
1043
|
+
return buildUnobservedSkillBodyError(skillId);
|
|
1044
|
+
}
|
|
1023
1045
|
if (!authorization.has(normalizedFile)) {
|
|
1024
1046
|
const availableReferences = authorization.references.length > 0
|
|
1025
1047
|
? authorization.references.join(", ")
|