@kindgi/agents 0.1.2 → 0.1.4-rc.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/blocks.d.ts +101 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +149 -0
- package/dist/blocks.js.map +1 -0
- package/dist/conversation-binding.d.ts +9 -1
- package/dist/conversation-binding.d.ts.map +1 -1
- package/dist/define.d.ts +17 -2
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +93 -6
- package/dist/define.js.map +1 -1
- package/dist/guardrails-gate.d.ts +7 -4
- package/dist/guardrails-gate.d.ts.map +1 -1
- package/dist/guardrails-gate.js +5 -2
- package/dist/guardrails-gate.js.map +1 -1
- package/dist/handlers/compose-result.d.ts.map +1 -1
- package/dist/handlers/compose-result.js +3 -0
- package/dist/handlers/compose-result.js.map +1 -1
- package/dist/handlers/context.d.ts +24 -0
- package/dist/handlers/context.d.ts.map +1 -1
- package/dist/handlers/dispatch-tools.d.ts.map +1 -1
- package/dist/handlers/dispatch-tools.js +69 -43
- package/dist/handlers/dispatch-tools.js.map +1 -1
- package/dist/handlers/errors.d.ts +12 -1
- package/dist/handlers/errors.d.ts.map +1 -1
- package/dist/handlers/errors.js.map +1 -1
- package/dist/handlers/evaluate-guardrails.d.ts.map +1 -1
- package/dist/handlers/evaluate-guardrails.js +36 -1
- package/dist/handlers/evaluate-guardrails.js.map +1 -1
- package/dist/handlers/gate-decision.d.ts +62 -0
- package/dist/handlers/gate-decision.d.ts.map +1 -0
- package/dist/handlers/gate-decision.js +55 -0
- package/dist/handlers/gate-decision.js.map +1 -0
- package/dist/handlers/model-call.d.ts +10 -0
- package/dist/handlers/model-call.d.ts.map +1 -1
- package/dist/handlers/model-call.js +120 -34
- package/dist/handlers/model-call.js.map +1 -1
- package/dist/handlers/persist-provenance.d.ts.map +1 -1
- package/dist/handlers/persist-provenance.js +3 -1
- package/dist/handlers/persist-provenance.js.map +1 -1
- package/dist/handlers/persist-user-message.d.ts.map +1 -1
- package/dist/handlers/persist-user-message.js +5 -16
- package/dist/handlers/persist-user-message.js.map +1 -1
- package/dist/handlers/public-types.d.ts +37 -3
- package/dist/handlers/public-types.d.ts.map +1 -1
- package/dist/handlers/rehydrate.d.ts.map +1 -1
- package/dist/handlers/rehydrate.js +91 -1
- package/dist/handlers/rehydrate.js.map +1 -1
- package/dist/handlers/render-prompt.d.ts.map +1 -1
- package/dist/handlers/render-prompt.js +4 -1
- package/dist/handlers/render-prompt.js.map +1 -1
- package/dist/handlers/replay.d.ts +143 -0
- package/dist/handlers/replay.d.ts.map +1 -0
- package/dist/handlers/replay.js +177 -0
- package/dist/handlers/replay.js.map +1 -0
- package/dist/handlers/resolve-blocks.d.ts +32 -0
- package/dist/handlers/resolve-blocks.d.ts.map +1 -0
- package/dist/handlers/resolve-blocks.js +129 -0
- package/dist/handlers/resolve-blocks.js.map +1 -0
- package/dist/handlers/resolve-tools.d.ts +6 -2
- package/dist/handlers/resolve-tools.d.ts.map +1 -1
- package/dist/handlers/resolve-tools.js +59 -27
- package/dist/handlers/resolve-tools.js.map +1 -1
- package/dist/handlers/result-shape.d.ts +7 -0
- package/dist/handlers/result-shape.d.ts.map +1 -1
- package/dist/handlers/result-shape.js.map +1 -1
- package/dist/handlers/run-retrievals.d.ts.map +1 -1
- package/dist/handlers/run-retrievals.js +35 -35
- package/dist/handlers/run-retrievals.js.map +1 -1
- package/dist/handlers/run-snapshot.d.ts.map +1 -1
- package/dist/handlers/run-snapshot.js +1 -0
- package/dist/handlers/run-snapshot.js.map +1 -1
- package/dist/handlers/setup.d.ts +2 -0
- package/dist/handlers/setup.d.ts.map +1 -1
- package/dist/handlers/setup.js +29 -12
- package/dist/handlers/setup.js.map +1 -1
- package/dist/handlers/tool-hitl.d.ts +5 -9
- package/dist/handlers/tool-hitl.d.ts.map +1 -1
- package/dist/handlers/tool-hitl.js +5 -0
- package/dist/handlers/tool-hitl.js.map +1 -1
- package/dist/handlers/turn-environment.d.ts +13 -2
- package/dist/handlers/turn-environment.d.ts.map +1 -1
- package/dist/handlers/turn-environment.js +12 -3
- package/dist/handlers/turn-environment.js.map +1 -1
- package/dist/handlers/turn-provenance.d.ts +67 -0
- package/dist/handlers/turn-provenance.d.ts.map +1 -0
- package/dist/handlers/turn-provenance.js +160 -0
- package/dist/handlers/turn-provenance.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/invoke.d.ts +14 -1
- package/dist/invoke.d.ts.map +1 -1
- package/dist/invoke.js +37 -19
- package/dist/invoke.js.map +1 -1
- package/dist/pins.d.ts +54 -0
- package/dist/pins.d.ts.map +1 -0
- package/dist/pins.js +51 -0
- package/dist/pins.js.map +1 -0
- package/dist/prompt.d.ts +12 -2
- package/dist/prompt.d.ts.map +1 -1
- package/dist/prompt.js +41 -4
- package/dist/prompt.js.map +1 -1
- package/dist/provenance-emit.d.ts +4 -2
- package/dist/provenance-emit.d.ts.map +1 -1
- package/dist/provenance-emit.js +4 -2
- package/dist/provenance-emit.js.map +1 -1
- package/dist/run-snapshot-binding.d.ts +5 -0
- package/dist/run-snapshot-binding.d.ts.map +1 -1
- package/dist/schema.d.ts +34 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +16 -0
- package/dist/schema.js.map +1 -1
- package/dist/streaming.d.ts +5 -0
- package/dist/streaming.d.ts.map +1 -1
- package/dist/streaming.js.map +1 -1
- package/dist/types.d.ts +65 -2
- package/dist/types.d.ts.map +1 -1
- package/migrations/0003_hesitant_captain_cross.sql +2 -0
- package/migrations/0004_stormy_moondragon.sql +1 -0
- package/migrations/meta/0003_snapshot.json +321 -0
- package/migrations/meta/0004_snapshot.json +327 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +15 -15
- package/src/blocks.ts +231 -0
- package/src/conversation-binding.ts +9 -1
- package/src/define.ts +104 -7
- package/src/guardrails-gate.ts +17 -3
- package/src/handlers/compose-result.ts +3 -0
- package/src/handlers/context.ts +24 -0
- package/src/handlers/dispatch-tools.ts +75 -44
- package/src/handlers/errors.ts +13 -0
- package/src/handlers/evaluate-guardrails.ts +41 -1
- package/src/handlers/gate-decision.ts +101 -0
- package/src/handlers/model-call.ts +163 -33
- package/src/handlers/persist-provenance.ts +3 -1
- package/src/handlers/persist-user-message.ts +3 -16
- package/src/handlers/public-types.ts +38 -3
- package/src/handlers/rehydrate.ts +141 -9
- package/src/handlers/render-prompt.ts +13 -7
- package/src/handlers/replay.ts +314 -0
- package/src/handlers/resolve-blocks.ts +188 -0
- package/src/handlers/resolve-tools.ts +76 -28
- package/src/handlers/result-shape.ts +8 -0
- package/src/handlers/run-retrievals.ts +45 -41
- package/src/handlers/run-snapshot.ts +1 -0
- package/src/handlers/setup.ts +30 -22
- package/src/handlers/tool-hitl.ts +6 -10
- package/src/handlers/turn-environment.ts +28 -3
- package/src/handlers/turn-provenance.ts +230 -0
- package/src/index.ts +44 -0
- package/src/invoke.ts +49 -20
- package/src/pins.ts +98 -0
- package/src/prompt.ts +52 -4
- package/src/provenance-emit.ts +4 -1
- package/src/run-snapshot-binding.ts +6 -0
- package/src/schema.ts +16 -0
- package/src/streaming.ts +5 -0
- package/src/types.ts +68 -2
|
@@ -11,6 +11,11 @@ export declare function resolveToolHitl(agent: Agent, tool: Tool): ResolvedToolH
|
|
|
11
11
|
* a different hash.
|
|
12
12
|
*/
|
|
13
13
|
export declare function hashToolArgs(args: unknown): string;
|
|
14
|
+
/**
|
|
15
|
+
* The `NodeContext.record` key of a tool call's gate, before its call id:
|
|
16
|
+
* the journal names the waitpoint a call parked on under this key.
|
|
17
|
+
*/
|
|
18
|
+
export declare const TOOL_GATE_RECORD_PREFIX = "tool-hitl-gate:";
|
|
14
19
|
/**
|
|
15
20
|
* Deterministic waitpoint token for a tool-call gate. Includes both
|
|
16
21
|
* the model-generated call id (unique per iteration) AND the args hash
|
|
@@ -22,15 +27,6 @@ export declare function computeToolCallWaitToken(input: {
|
|
|
22
27
|
readonly callId: string;
|
|
23
28
|
readonly argsHash: string;
|
|
24
29
|
}): string;
|
|
25
|
-
/**
|
|
26
|
-
* Shape the tool-level waitpoint resolves to when the reviewer decides.
|
|
27
|
-
* Same shape as session-gate decisions — the approvals-complete route
|
|
28
|
-
* materializes it identically.
|
|
29
|
-
*/
|
|
30
|
-
export interface ToolHitlDecision {
|
|
31
|
-
readonly decided: 'approve' | 'reject';
|
|
32
|
-
readonly rationale?: string;
|
|
33
|
-
}
|
|
34
30
|
/**
|
|
35
31
|
* In-conversation cache of decisions for `ask_on_first_use`. Persisted
|
|
36
32
|
* on `agent_conversations.metadata.hitlToolDecisions` — a flat map of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-hitl.d.ts","sourceRoot":"","sources":["../../src/handlers/tool-hitl.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;CACxD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,gBAAgB,CAkC1E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAElD;AAWD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,GAAG,MAAM,CAKT;AAED
|
|
1
|
+
{"version":3,"file":"tool-hitl.d.ts","sourceRoot":"","sources":["../../src/handlers/tool-hitl.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;CACxD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,gBAAgB,CAkC1E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAElD;AAWD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,oBAAoB,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,GAAG,MAAM,CAKT;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,oBAAoB,GAAG,MAAM,CAE7D"}
|
|
@@ -63,6 +63,11 @@ function canonicalStringify(value) {
|
|
|
63
63
|
const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));
|
|
64
64
|
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalStringify(v)}`).join(',')}}`;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The `NodeContext.record` key of a tool call's gate, before its call id:
|
|
68
|
+
* the journal names the waitpoint a call parked on under this key.
|
|
69
|
+
*/
|
|
70
|
+
export const TOOL_GATE_RECORD_PREFIX = 'tool-hitl-gate:';
|
|
66
71
|
/**
|
|
67
72
|
* Deterministic waitpoint token for a tool-call gate. Includes both
|
|
68
73
|
* the model-generated call id (unique per iteration) AND the args hash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-hitl.js","sourceRoot":"","sources":["../../src/handlers/tool-hitl.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC,EAAE;AACF,sEAAsE;AACtE,yDAAyD;AACzD,wEAAwE;AACxE,YAAY;AACZ,EAAE;AACF,oEAAoE;AACpE,6EAA6E;AAC7E,0EAA0E;AAC1E,6DAA6D;AAC7D,4CAA4C;AAC5C,4EAA4E;AAC5E,EAAE;AACF,qEAAqE;AACrE,cAAc;AACd,EAAE;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,UAAU,eAAe,CAAC,KAAY,EAAE,IAAU;IACtD,MAAM,IAAI,GAAG,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAI,EAAE,KAAK,CAAC;IAChC,MAAM,WAAW,GAAG,IAAI,EAAE,mBAAmB,IAAI,UAAU,CAAC;IAE5D,mEAAmE;IACnE,mEAAmE;IACnE,oCAAoC;IACpC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;IAC1D,CAAC;IAED,wCAAwC;IACxC,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,EAAuB,CAAC,CAAC;IAC1E,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,GACR,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW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nContext } from './context.js';
|
|
4
|
+
import { type PinnedBlockVersions } from './resolve-blocks.js';
|
|
4
5
|
/** The conversation the turn runs in: open, and opened with this agent version. */
|
|
5
6
|
export declare function loadTurnConversation(ctx: TurnContext): Promise<Conversation>;
|
|
6
7
|
/** The model a turn was routed to, as `setup` journals it. */
|
|
@@ -8,14 +9,24 @@ export interface PinnedRoute {
|
|
|
8
9
|
readonly providerId: string;
|
|
9
10
|
readonly model: string;
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The tool version each of the agent's tool references resolved to, by
|
|
14
|
+
* tool id, as `setup` journals it: a resumed turn runs these versions,
|
|
15
|
+
* whatever the registry holds by then.
|
|
16
|
+
*/
|
|
17
|
+
export type PinnedToolVersions = Readonly<Record<string, string>>;
|
|
11
18
|
/**
|
|
12
19
|
* Resolve the turn's guardrails, tools, tenant policy, tool-error policy
|
|
13
20
|
* and model onto `ctx`. With `pinned`, the route is that provider and
|
|
14
21
|
* model, still under the tenant's current policy; one no longer
|
|
15
|
-
* registered or allowed fails the turn.
|
|
22
|
+
* registered or allowed fails the turn. With `pinnedTools`, each tool is
|
|
23
|
+
* that exact version, not its range resolved again; one no longer
|
|
24
|
+
* registered fails the turn.
|
|
16
25
|
*/
|
|
17
|
-
export declare function resolveTurnEnvironment(ctx: TurnContext, pinned?: PinnedRoute): Promise<PinnedRoute & {
|
|
26
|
+
export declare function resolveTurnEnvironment(ctx: TurnContext, pinned?: PinnedRoute, pinnedTools?: PinnedToolVersions, pinnedBlocks?: PinnedBlockVersions): Promise<PinnedRoute & {
|
|
18
27
|
readonly toolCount: number;
|
|
28
|
+
readonly toolVersions: PinnedToolVersions;
|
|
29
|
+
readonly blockVersions?: PinnedBlockVersions;
|
|
19
30
|
}>;
|
|
20
31
|
/**
|
|
21
32
|
* The turn's approval rules: the agent's, held to the tenant's `hitl`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-environment.d.ts","sourceRoot":"","sources":["../../src/handlers/turn-environment.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,mBAAmB,CAAC;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"turn-environment.d.ts","sourceRoot":"","sources":["../../src/handlers/turn-environment.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,mBAAmB,CAAC;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,qBAAqB,CAAC;AAIlF,mFAAmF;AACnF,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CA4BlF;AAED,8DAA8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,WAAW,EAChB,MAAM,CAAC,EAAE,WAAW,EACpB,WAAW,CAAC,EAAE,kBAAkB,EAChC,YAAY,CAAC,EAAE,mBAAmB,GACjC,OAAO,CACR,WAAW,GAAG;IACZ,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAC1C,QAAQ,CAAC,aAAa,CAAC,EAAE,mBAAmB,CAAC;CAC9C,CACF,CAyFA;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAiB1F"}
|
|
@@ -13,6 +13,7 @@ import { resolveGuardrails } from '../guardrails-gate.js';
|
|
|
13
13
|
import { resolveEffectiveHitlPolicy } from '../hitl-policy.js';
|
|
14
14
|
import { mergeTenantPolicies } from '../tenant-policy.js';
|
|
15
15
|
import { throwAgentTurnFailure } from './errors.js';
|
|
16
|
+
import { resolveTurnBlocks } from './resolve-blocks.js';
|
|
16
17
|
import { resolveTurnTools } from './resolve-tools.js';
|
|
17
18
|
import { effectiveToolErrorPolicy } from './tool-errors.js';
|
|
18
19
|
/** The conversation the turn runs in: open, and opened with this agent version. */
|
|
@@ -45,9 +46,11 @@ export async function loadTurnConversation(ctx) {
|
|
|
45
46
|
* Resolve the turn's guardrails, tools, tenant policy, tool-error policy
|
|
46
47
|
* and model onto `ctx`. With `pinned`, the route is that provider and
|
|
47
48
|
* model, still under the tenant's current policy; one no longer
|
|
48
|
-
* registered or allowed fails the turn.
|
|
49
|
+
* registered or allowed fails the turn. With `pinnedTools`, each tool is
|
|
50
|
+
* that exact version, not its range resolved again; one no longer
|
|
51
|
+
* registered fails the turn.
|
|
49
52
|
*/
|
|
50
|
-
export async function resolveTurnEnvironment(ctx, pinned) {
|
|
53
|
+
export async function resolveTurnEnvironment(ctx, pinned, pinnedTools, pinnedBlocks) {
|
|
51
54
|
const invResolution = resolveGuardrails(ctx.input.agent, ctx.bindings);
|
|
52
55
|
if (invResolution.missing.length > 0) {
|
|
53
56
|
throwAgentTurnFailure({
|
|
@@ -60,7 +63,11 @@ export async function resolveTurnEnvironment(ctx, pinned) {
|
|
|
60
63
|
// This turn's tools come from the tenant's own registry — never a
|
|
61
64
|
// registry shared across concurrent turns of other tenants.
|
|
62
65
|
const tenantTools = await ctx.bindings.toolRegistry.forTenant(ctx.input.tenantId);
|
|
63
|
-
ctx.tools = resolveTurnTools(tenantTools, ctx.input.agent);
|
|
66
|
+
ctx.tools = resolveTurnTools(tenantTools, ctx.input.agent, pinnedTools);
|
|
67
|
+
// The data blocks, at the versions pinned (the turn's own on resume).
|
|
68
|
+
const blocks = await resolveTurnBlocks(ctx, pinnedBlocks);
|
|
69
|
+
if (blocks !== undefined)
|
|
70
|
+
ctx.blocks = blocks;
|
|
64
71
|
const capability = ctx.input.agent.capabilities[0];
|
|
65
72
|
if (capability === undefined) {
|
|
66
73
|
throwAgentTurnFailure({
|
|
@@ -121,6 +128,8 @@ export async function resolveTurnEnvironment(ctx, pinned) {
|
|
|
121
128
|
providerId: routed.value.provider.metadata.id,
|
|
122
129
|
model: routed.value.model.name,
|
|
123
130
|
toolCount: ctx.tools.definitions.length,
|
|
131
|
+
toolVersions: Object.fromEntries([...ctx.tools.byName].map(([id, binding]) => [id, binding.resolvedVersion])),
|
|
132
|
+
...(blocks !== undefined && { blockVersions: blocks.versions }),
|
|
124
133
|
};
|
|
125
134
|
}
|
|
126
135
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-environment.js","sourceRoot":"","sources":["../../src/handlers/turn-environment.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAK7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAA4B,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAwB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAElF,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,GAAgB;IACzD,MAAM,IAAI,GAAG,MAAM,GAAG,CAA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C,cAAc,CAAC,QAAQ,CAGjD,MAAM,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qBAAqB,CAAC;gBACpB,IAAI,EAAE,2BAA2B;gBACjC,OAAO,EAAE,kDAAkD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBACnH,UAAU,EAAE,MAAM;aACnB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,0BAA0B,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,6EAA6E;AAC7E,KAAK,UAAU,sBAAsB,CAAC,GAAgB;IACpD,MAAM,GAAG,GACP,GAAG,CAAC,QAAQ,CAAC,cAAc,KAAK,SAAS;QACvC,CAAC,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAGxC,aAAa,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpD,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO,wBAAwB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provenance nodes and edges an agent turn records, in one place:
|
|
3
|
+
* the steps add them as they run, and a turn resumed after a park
|
|
4
|
+
* (`rehydrate.ts`) adds those of the steps that ran before it from what
|
|
5
|
+
* they left durable (the conversation, the journal). Either way the DAG
|
|
6
|
+
* is the same.
|
|
7
|
+
*/
|
|
8
|
+
import type { ProvenanceBuilder } from '@kindgi/provenance';
|
|
9
|
+
import type { Timestamp } from '@kindgi/types';
|
|
10
|
+
import type { ConversationMessage, RetrievedFact } from '../types.js';
|
|
11
|
+
import type { TurnContext } from './context.js';
|
|
12
|
+
import type { GateDecision } from './gate-decision.js';
|
|
13
|
+
/** The turn's user message. */
|
|
14
|
+
export declare function addInputNode(provenance: ProvenanceBuilder, message: ConversationMessage): void;
|
|
15
|
+
/** The facts the turn retrieved for its user message. */
|
|
16
|
+
export declare function addRetrievalNodes(provenance: ProvenanceBuilder, retrieved: readonly RetrievedFact[], input: ConversationMessage): void;
|
|
17
|
+
/** One model call: its identity; its usage is the cost ledger's, by `callId`. */
|
|
18
|
+
export interface ModelCallFacts {
|
|
19
|
+
readonly step: number;
|
|
20
|
+
readonly callId: string;
|
|
21
|
+
readonly provider: {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly model: string;
|
|
24
|
+
};
|
|
25
|
+
readonly finishReason: string;
|
|
26
|
+
readonly at: Timestamp;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A model call, `caused-by` the turn's user message and `influenced-by`
|
|
30
|
+
* each of this turn's tool results it read: all of them so far, since
|
|
31
|
+
* the call's input holds every message of the turn before it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function addModelCallNode(provenance: ProvenanceBuilder, call: ModelCallFacts, inputSequence: number, toolResultIds: readonly string[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* A tool call the model at `step` made, and its result: the stored tool
|
|
36
|
+
* message (a tool's output, a rejected approval's, or a failed call's).
|
|
37
|
+
* `version` is the tool the agent's binding resolved, when it has one.
|
|
38
|
+
*/
|
|
39
|
+
export declare function addToolNodes(provenance: ProvenanceBuilder, step: number, result: ConversationMessage, version: {
|
|
40
|
+
readonly resolvedVersion: string;
|
|
41
|
+
readonly requestedRange: string;
|
|
42
|
+
} | undefined): void;
|
|
43
|
+
/**
|
|
44
|
+
* The tool calls of one model step: a node pair for each result the step
|
|
45
|
+
* stored, and their invocation ids added to the turn's tool results.
|
|
46
|
+
*/
|
|
47
|
+
export declare function addStepToolNodes(ctx: TurnContext, step: number, stored: readonly ConversationMessage[]): void;
|
|
48
|
+
/** A tool call's approval, decided: the wait it parked on and the answer. */
|
|
49
|
+
export interface ToolApproval {
|
|
50
|
+
readonly waitTokenId: string;
|
|
51
|
+
/** When the call parked on the approval. */
|
|
52
|
+
readonly parkedAt: Timestamp;
|
|
53
|
+
/** When the decision reached the run. */
|
|
54
|
+
readonly decidedAt: Timestamp;
|
|
55
|
+
readonly decision: GateDecision;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The approval a tool call waited on, as the session gate records its own:
|
|
59
|
+
* a `wait` node (the agent parked) `resumed-from` a `resume` node (the
|
|
60
|
+
* decision, its actor whoever decided). The call `waited-on` the wait, and
|
|
61
|
+
* its result was `caused-by` the decision: the tool's output when approved,
|
|
62
|
+
* the rejection when not.
|
|
63
|
+
*/
|
|
64
|
+
export declare function addToolApprovalNodes(provenance: ProvenanceBuilder, invocationId: string, approval: ToolApproval, agentId: string): void;
|
|
65
|
+
/** A gate decision as a `resume` node records it. */
|
|
66
|
+
export declare function decisionOf(decision: GateDecision): 'approve' | 'reject' | 'unreadable';
|
|
67
|
+
//# sourceMappingURL=turn-provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-provenance.d.ts","sourceRoot":"","sources":["../../src/handlers/turn-provenance.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,+BAA+B;AAC/B,wBAAgB,YAAY,CAAC,UAAU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QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,iBAAiB,EAC7B,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,MAAM,GACd,IAAI,CA4BN;AAED,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAGtF"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
/** The turn's user message. */
|
|
4
|
+
export function addInputNode(provenance, message) {
|
|
5
|
+
provenance.addNode({
|
|
6
|
+
id: `input:${message.sequence}`,
|
|
7
|
+
kind: 'input',
|
|
8
|
+
timestamp: message.createdAt,
|
|
9
|
+
...(message.actor !== undefined && { actor: message.actor }),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/** The facts the turn retrieved for its user message. */
|
|
13
|
+
export function addRetrievalNodes(provenance, retrieved, input) {
|
|
14
|
+
for (const r of retrieved) {
|
|
15
|
+
provenance.addNode({
|
|
16
|
+
id: `retrieval:${r.fact.id}`,
|
|
17
|
+
kind: 'retrieval',
|
|
18
|
+
timestamp: input.createdAt,
|
|
19
|
+
...(r.fact.contentHash !== undefined && { contentHash: r.fact.contentHash }),
|
|
20
|
+
attributes: {
|
|
21
|
+
factId: r.fact.id,
|
|
22
|
+
factType: r.fact.type,
|
|
23
|
+
intentScope: r.intent.scope,
|
|
24
|
+
...(r.score !== undefined && { score: r.score }),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
provenance.addEdge({
|
|
28
|
+
from: `retrieval:${r.fact.id}`,
|
|
29
|
+
to: `input:${input.sequence}`,
|
|
30
|
+
kind: 'influenced-by',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A model call, `caused-by` the turn's user message and `influenced-by`
|
|
36
|
+
* each of this turn's tool results it read: all of them so far, since
|
|
37
|
+
* the call's input holds every message of the turn before it.
|
|
38
|
+
*/
|
|
39
|
+
export function addModelCallNode(provenance, call, inputSequence, toolResultIds) {
|
|
40
|
+
const id = `model-call:${call.step}`;
|
|
41
|
+
provenance.addNode({
|
|
42
|
+
id,
|
|
43
|
+
kind: 'model-call',
|
|
44
|
+
timestamp: call.at,
|
|
45
|
+
modelVersion: `${call.provider.id}/${call.provider.model}`,
|
|
46
|
+
attributes: {
|
|
47
|
+
step: call.step,
|
|
48
|
+
callId: call.callId,
|
|
49
|
+
providerId: call.provider.id,
|
|
50
|
+
model: call.provider.model,
|
|
51
|
+
finishReason: call.finishReason,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
provenance.addEdge({ from: id, to: `input:${inputSequence}`, kind: 'caused-by' });
|
|
55
|
+
for (const invocationId of toolResultIds) {
|
|
56
|
+
provenance.addEdge({ from: id, to: `tool-result:${invocationId}`, kind: 'influenced-by' });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A tool call the model at `step` made, and its result: the stored tool
|
|
61
|
+
* message (a tool's output, a rejected approval's, or a failed call's).
|
|
62
|
+
* `version` is the tool the agent's binding resolved, when it has one.
|
|
63
|
+
*/
|
|
64
|
+
export function addToolNodes(provenance, step, result, version) {
|
|
65
|
+
const call = result.toolCall;
|
|
66
|
+
if (call === undefined)
|
|
67
|
+
return;
|
|
68
|
+
const callNodeId = `tool-call:${call.invocationId}`;
|
|
69
|
+
const resultNodeId = `tool-result:${call.invocationId}`;
|
|
70
|
+
provenance.addNode({
|
|
71
|
+
id: callNodeId,
|
|
72
|
+
kind: 'tool-call',
|
|
73
|
+
timestamp: result.createdAt,
|
|
74
|
+
attributes: {
|
|
75
|
+
toolId: call.toolId,
|
|
76
|
+
invocationId: call.invocationId,
|
|
77
|
+
// The version the registry picked for the turn and the range the
|
|
78
|
+
// agent asked for, so a replay can pin against the same version.
|
|
79
|
+
...(version !== undefined && {
|
|
80
|
+
toolVersion: version.resolvedVersion,
|
|
81
|
+
toolVersionRange: version.requestedRange,
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
provenance.addNode({ id: resultNodeId, kind: 'tool-result', timestamp: result.createdAt });
|
|
86
|
+
provenance.addEdge({ from: callNodeId, to: `model-call:${step}`, kind: 'invoked' });
|
|
87
|
+
provenance.addEdge({ from: resultNodeId, to: callNodeId, kind: 'produced' });
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The tool calls of one model step: a node pair for each result the step
|
|
91
|
+
* stored, and their invocation ids added to the turn's tool results.
|
|
92
|
+
*/
|
|
93
|
+
export function addStepToolNodes(ctx, step, stored) {
|
|
94
|
+
for (const result of stored) {
|
|
95
|
+
if (result.role !== 'tool' || result.toolCall === undefined)
|
|
96
|
+
continue;
|
|
97
|
+
const { invocationId, toolId } = result.toolCall;
|
|
98
|
+
if (ctx.provenance !== undefined) {
|
|
99
|
+
addToolNodes(ctx.provenance, step, result, versionOf(ctx, toolId));
|
|
100
|
+
const approval = ctx.toolApprovals?.get(invocationId);
|
|
101
|
+
if (approval !== undefined) {
|
|
102
|
+
addToolApprovalNodes(ctx.provenance, invocationId, approval, ctx.input.agent.id);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
ctx.toolResultIds ??= [];
|
|
106
|
+
ctx.toolResultIds.push(invocationId);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The approval a tool call waited on, as the session gate records its own:
|
|
111
|
+
* a `wait` node (the agent parked) `resumed-from` a `resume` node (the
|
|
112
|
+
* decision, its actor whoever decided). The call `waited-on` the wait, and
|
|
113
|
+
* its result was `caused-by` the decision: the tool's output when approved,
|
|
114
|
+
* the rejection when not.
|
|
115
|
+
*/
|
|
116
|
+
export function addToolApprovalNodes(provenance, invocationId, approval, agentId) {
|
|
117
|
+
const waitId = `tool-hitl-gate-wait:${invocationId}`;
|
|
118
|
+
const resumeId = `tool-hitl-gate-resume:${invocationId}`;
|
|
119
|
+
const { decision } = approval;
|
|
120
|
+
provenance.addNode({
|
|
121
|
+
id: waitId,
|
|
122
|
+
kind: 'wait',
|
|
123
|
+
timestamp: approval.parkedAt,
|
|
124
|
+
actor: `agent:${agentId}`,
|
|
125
|
+
attributes: { gate: 'tool-call', invocationId, waitTokenId: approval.waitTokenId },
|
|
126
|
+
});
|
|
127
|
+
provenance.addNode({
|
|
128
|
+
id: resumeId,
|
|
129
|
+
kind: 'resume',
|
|
130
|
+
timestamp: approval.decidedAt,
|
|
131
|
+
...(decision.decidedBy !== undefined && { actor: decision.decidedBy }),
|
|
132
|
+
attributes: {
|
|
133
|
+
gate: 'tool-call',
|
|
134
|
+
decision: decisionOf(decision),
|
|
135
|
+
...(!decision.approved &&
|
|
136
|
+
decision.reason === 'rejected' &&
|
|
137
|
+
decision.rationale !== undefined && { rationale: decision.rationale }),
|
|
138
|
+
...(decision.approvalId !== undefined && { approvalId: decision.approvalId }),
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
provenance.addEdge({ from: `tool-call:${invocationId}`, to: waitId, kind: 'waited-on' });
|
|
142
|
+
provenance.addEdge({ from: waitId, to: resumeId, kind: 'resumed-from' });
|
|
143
|
+
provenance.addEdge({ from: `tool-result:${invocationId}`, to: resumeId, kind: 'caused-by' });
|
|
144
|
+
}
|
|
145
|
+
/** A gate decision as a `resume` node records it. */
|
|
146
|
+
export function decisionOf(decision) {
|
|
147
|
+
if (decision.approved)
|
|
148
|
+
return 'approve';
|
|
149
|
+
return decision.reason === 'rejected' ? 'reject' : 'unreadable';
|
|
150
|
+
}
|
|
151
|
+
/** The version the agent's binding of `toolId` resolved, if it has one. */
|
|
152
|
+
function versionOf(ctx, toolId) {
|
|
153
|
+
const bindings = [...(ctx.tools?.byName.values() ?? [])];
|
|
154
|
+
const binding = ctx.tools?.byName.get(toolId) ??
|
|
155
|
+
bindings.find((b) => b.tool.id === toolId);
|
|
156
|
+
return binding === undefined
|
|
157
|
+
? undefined
|
|
158
|
+
: { resolvedVersion: binding.resolvedVersion, requestedRange: binding.requestedRange };
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=turn-provenance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-provenance.js","sourceRoot":"","sources":["../../src/handlers/turn-provenance.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAiBjC,+BAA+B;AAC/B,MAAM,UAAU,YAAY,CAAC,UAA6B,EAAE,OAA4B;IACtF,UAAU,CAAC,OAAO,CAAC;QACjB,EAAE,EAAE,SAAS,OAAO,CAAC,QAAQ,EAAE;QAC/B,IAAI,EAAE,OAAO;QACb,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;KAC7D,CAAC,CAAC;AACL,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,iBAAiB,CAC/B,UAA6B,EAC7B,SAAmC,EACnC,KAA0B;IAE1B,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QAC1B,UAAU,CAAC,OAAO,CAAC;YACjB,EAAE,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE;YAC5B,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAC5E,UAAU,E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,MAAM,UAAU,UAAU,CAAC,QAAsB;IAC/C,IAAI,QAAQ,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IACxC,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC;AAClE,CAAC;AAED,2EAA2E;AAC3E,SAAS,SAAS,CAChB,GAAgB,EAChB,MAAc;IAEd,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzD,MAAM,OAAO,GACX,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAE,CAAC,CAAC,IAAI,CAAC,EAAwB,KAAK,MAAM,CAAC,CAAC;IACpE,OAAO,OAAO,KAAK,SAAS;QAC1B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC;AAC3F,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
export type { AppendMessageInput, ConversationBinding, ConversationPage, ConversationPageCursor, ListConversationsInput, ListConversationsPageInput, OpenConversationInput, ReadMessagesInput, } from './conversation-binding.js';
|
|
2
2
|
export type { RunSnapshotBinding, RunSnapshotRecord, RunSnapshotWriteInput, } from './run-snapshot-binding.js';
|
|
3
3
|
export { defineAgent } from './define.js';
|
|
4
|
+
export { BLOCK_KINDS, MODEL_SETTINGS_SCHEMA, settingsSchemaIssues, validateBlock, } from './blocks.js';
|
|
5
|
+
export type { BlockDefinition, BlockIssue, BlockKind, BlockReader, InvalidBlock, ModelSettings, PromptBlockContent, SettingsBlockContent, } from './blocks.js';
|
|
4
6
|
export type { DefineAgentSpec } from './define.js';
|
|
5
7
|
export { resolveEffectiveHitlPolicy } from './hitl-policy.js';
|
|
8
|
+
export { AGENT_GATE_SUBJECTS, SESSION_GATE_SUBJECT, TOOL_CALL_GATE_SUBJECT, readGateDecision, } from './handlers/gate-decision.js';
|
|
9
|
+
export type { GateDecision, GateDecisionValue } from './handlers/gate-decision.js';
|
|
6
10
|
export type { EffectiveHitlPolicy } from './hitl-policy.js';
|
|
7
11
|
export { agentStepOutput, invokeAgent, resumeAgentTurn } from './invoke.js';
|
|
12
|
+
export { isReadOnlyTool } from './handlers/replay.js';
|
|
13
|
+
export { SESSION_GATE_RECORD } from './handlers/setup.js';
|
|
14
|
+
export type { ReplayApproval, ReplayBinding, ReplayToolDecision, ReplayToolInput, ReplayToolTrace, ReplayTurnRef, ReplayTurnReport, } from './handlers/replay.js';
|
|
8
15
|
export type { AgentStepOutput, AgentTurnAbortedError, AgentTurnResult, AgentTurnUsage, AgentTurnWarning, BudgetExceededError, CapabilityRoutingError, InvokeAgentBindings, InvokeAgentError, InvokeAgentInput, ModelInvocationError, OutputSchemaViolationError, ResumeAgentTurnInput, RunSnapshotError, ToolInvocationError, UnresolvedToolError, } from './invoke.js';
|
|
9
16
|
export { buildRunTrace, categorizeOutcomes, evaluateGate, evaluateSessionGate, resolveGuardrails, } from './guardrails-gate.js';
|
|
10
17
|
export type { HitlRequiredError, GuardrailViolationError, GuardrailsBindings, SessionGateResult, UnresolvedGuardrailError, } from './guardrails-gate.js';
|
|
@@ -15,11 +22,13 @@ export { AUTO_INJECTED_VARS, renderInstructions } from './prompt.js';
|
|
|
15
22
|
export { formatRetrievedForPrompt, runRetrievals } from './retrieval.js';
|
|
16
23
|
export type { RetrievalBindings } from './retrieval.js';
|
|
17
24
|
export type { MissingParameterError, PromptRenderError, RenderContext, RenderFailureError, RenderResult, } from './prompt.js';
|
|
25
|
+
export { pinChanges, pinsDigest } from './pins.js';
|
|
26
|
+
export type { AgentDerivation, AgentDerivationReason, AgentPins, PinChange, PinSet, } from './pins.js';
|
|
18
27
|
export { createAgentRegistry } from './registry.js';
|
|
19
28
|
export type { AgentRegistry } from './registry.js';
|
|
20
29
|
export { AGENTS_TENANT_SCOPED_TABLES, agentConversations, agentRunSnapshots, } from './schema.js';
|
|
21
30
|
export type { AgentConversationRow, AgentRunSnapshotRow, NewAgentConversationRow, NewAgentRunSnapshotRow, } from './schema.js';
|
|
22
|
-
export type { Agent, AgentBindings, AgentId, AgentOutputSpec, Conversation, ConversationId, ConversationMessage, ConversationPolicy, MessageRole, PromptParameter, RetrievalIntent, RetrievedFact, ToolRef, TurnBudget, } from './types.js';
|
|
31
|
+
export type { Agent, AgentBindings, AgentId, AgentOutputSpec, BlockRef, Conversation, ConversationId, ConversationMessage, ConversationPolicy, MessageRole, PromptParameter, PromptRef, RetrievalIntent, RetrievedFact, ToolRef, TurnBudget, } from './types.js';
|
|
23
32
|
export { DEFAULT_TOOL_ERRORS, effectiveToolErrorPolicy } from './handlers/tool-errors.js';
|
|
24
33
|
export type { ToolErrorPolicy, ToolErrorResult } from './handlers/tool-errors.js';
|
|
25
34
|
export type { ToolErrorKind, ToolErrorsSpec } from '@kindgi/policy-contract';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;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Ae,EACf,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,GACX,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
3
|
export { defineAgent } from './define.js';
|
|
4
|
+
export { BLOCK_KINDS, MODEL_SETTINGS_SCHEMA, settingsSchemaIssues, validateBlock, } from './blocks.js';
|
|
4
5
|
export { resolveEffectiveHitlPolicy } from './hitl-policy.js';
|
|
6
|
+
export { AGENT_GATE_SUBJECTS, SESSION_GATE_SUBJECT, TOOL_CALL_GATE_SUBJECT, readGateDecision, } from './handlers/gate-decision.js';
|
|
5
7
|
export { agentStepOutput, invokeAgent, resumeAgentTurn } from './invoke.js';
|
|
8
|
+
export { isReadOnlyTool } from './handlers/replay.js';
|
|
9
|
+
export { SESSION_GATE_RECORD } from './handlers/setup.js';
|
|
6
10
|
export { buildRunTrace, categorizeOutcomes, evaluateGate, evaluateSessionGate, resolveGuardrails, } from './guardrails-gate.js';
|
|
7
11
|
export { persistProvenance } from './provenance-emit.js';
|
|
8
12
|
export { AUTO_INJECTED_VARS, renderInstructions } from './prompt.js';
|
|
9
13
|
export { formatRetrievedForPrompt, runRetrievals } from './retrieval.js';
|
|
14
|
+
export { pinChanges, pinsDigest } from './pins.js';
|
|
10
15
|
export { createAgentRegistry } from './registry.js';
|
|
11
16
|
export { AGENTS_TENANT_SCOPED_TABLES, agentConversations, agentRunSnapshots, } from './schema.js';
|
|
12
17
|
export { DEFAULT_TOOL_ERRORS, effectiveToolErrorPolicy } from './handlers/tool-errors.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAiBjC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,MAAM,iBAAiB,CAAC;AAM9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,qDAAqD;AACrD,sEAAsE;AACtE,wEAAwE;AACxE,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,8BAA8B,EAC9B,iBAAiB,EACjB,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,GACX,MAAM,sBAAsB,CAAC"}
|
package/dist/invoke.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Result, RunId, TenantId } from '@kindgi/types';
|
|
1
|
+
import type { OrgId, Result, RunId, TenantId } from '@kindgi/types';
|
|
2
2
|
import { type InvokeAgentError } from './handlers/errors.js';
|
|
3
3
|
import type { InvokeAgentBindings, InvokeAgentInput } from './handlers/public-types.js';
|
|
4
4
|
import type { AgentTurnResult } from './handlers/result-shape.js';
|
|
5
|
+
import type { RunSnapshotRecord } from './run-snapshot-binding.js';
|
|
5
6
|
import type { Agent } from './types.js';
|
|
6
7
|
/**
|
|
7
8
|
* Execute one agent turn end-to-end as a flow run: one `runGraph`
|
|
@@ -27,10 +28,22 @@ export interface ResumeAgentTurnInput {
|
|
|
27
28
|
* handler's agent-version-mismatch guard).
|
|
28
29
|
*/
|
|
29
30
|
readonly agent: Agent;
|
|
31
|
+
/**
|
|
32
|
+
* The org of the run's project (the snapshot's `projectId`), when it has
|
|
33
|
+
* one. The caller resolves it from the project, as for `invokeAgent`'s
|
|
34
|
+
* `orgId`, so the resumed turn's tools and guardrails see it too.
|
|
35
|
+
*/
|
|
36
|
+
readonly orgId?: OrgId;
|
|
30
37
|
}
|
|
31
38
|
export declare function resumeAgentTurn(input: ResumeAgentTurnInput, bindings: InvokeAgentBindings): Promise<Result<AgentTurnResult, InvokeAgentError>>;
|
|
32
39
|
export type { AgentStepOutput, AgentTurnResult, AgentTurnUsage, AgentTurnWarning, } from './handlers/result-shape.js';
|
|
33
40
|
export { agentStepOutput } from './handlers/result-shape.js';
|
|
34
41
|
export type { AgentTurnAbortedError, BudgetExceededError, CapabilityRoutingError, InvokeAgentError, ModelInvocationError, OutputSchemaViolationError, RunSnapshotError, ToolInvocationError, UnresolvedToolError, } from './handlers/errors.js';
|
|
35
42
|
export type { HitlBindings, HitlEnqueueInput, HitlEnqueueResult, InvokeAgentBindings, InvokeAgentInput, } from './handlers/public-types.js';
|
|
43
|
+
/**
|
|
44
|
+
* The `InvokeAgentInput` a resumed turn runs with: the one captured in its
|
|
45
|
+
* snapshot at run start, the agent the caller resolved, and the org of the
|
|
46
|
+
* run's project, which the caller resolves as for `invokeAgent`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function turnInputFromSnapshot(snapshot: RunSnapshotRecord, input: Pick<ResumeAgentTurnInput, 'agent' | 'orgId'>): InvokeAgentInput;
|
|
36
49
|
//# sourceMappingURL=invoke.d.ts.map
|
package/dist/invoke.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../src/invoke.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../src/invoke.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKpE,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAExF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;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,gBAAgB,CAsBlB"}
|
package/dist/invoke.js
CHANGED
|
@@ -64,7 +64,15 @@ export async function invokeAgent(input, bindings) {
|
|
|
64
64
|
flow: AGENT_TURN_FLOW,
|
|
65
65
|
handlers,
|
|
66
66
|
input: input.userMessage,
|
|
67
|
+
// The run's record names the agent, its version and the conversation.
|
|
68
|
+
agent: {
|
|
69
|
+
id: input.agent.id,
|
|
70
|
+
version: input.agent.version,
|
|
71
|
+
conversationId: input.conversationId,
|
|
72
|
+
},
|
|
67
73
|
...(input.parent !== undefined && { parent: input.parent }),
|
|
74
|
+
// A replay's run says so, and which eval run and past run it is for.
|
|
75
|
+
...(input.replay !== undefined && { replay: input.replay }),
|
|
68
76
|
...(input.dryRun === true && { options: { dryRun: true } }),
|
|
69
77
|
// Authorization — carry principal + authz into the run so every
|
|
70
78
|
// tool invocation inside the agent's turn is checked.
|
|
@@ -162,25 +170,7 @@ export async function resumeAgentTurn(input, bindings) {
|
|
|
162
170
|
};
|
|
163
171
|
}
|
|
164
172
|
// 3. Reconstruct the InvokeAgentInput envelope from the snapshot.
|
|
165
|
-
const reconstructedInput =
|
|
166
|
-
tenantId: snapshot.tenantId,
|
|
167
|
-
projectId: snapshot.projectId,
|
|
168
|
-
agent: input.agent,
|
|
169
|
-
conversationId: snapshot.conversationId,
|
|
170
|
-
userMessage: snapshot.userMessage,
|
|
171
|
-
...(snapshot.parameters !== undefined && { parameters: snapshot.parameters }),
|
|
172
|
-
...(snapshot.input !== undefined && { input: snapshot.input }),
|
|
173
|
-
...(snapshot.participantId !== undefined && { participantId: snapshot.participantId }),
|
|
174
|
-
...(snapshot.dryRun && { dryRun: true }),
|
|
175
|
-
...(snapshot.principal !== undefined &&
|
|
176
|
-
snapshot.principal !== null && {
|
|
177
|
-
principal: snapshot.principal,
|
|
178
|
-
}),
|
|
179
|
-
...(snapshot.authz !== undefined &&
|
|
180
|
-
snapshot.authz !== null && {
|
|
181
|
-
authz: snapshot.authz,
|
|
182
|
-
}),
|
|
183
|
-
};
|
|
173
|
+
const reconstructedInput = turnInputFromSnapshot(snapshot, input);
|
|
184
174
|
// 4. Build the same TurnContext + handlers as invokeAgent().
|
|
185
175
|
const started = Date.now();
|
|
186
176
|
const maxWallMs = input.agent.budget?.maxWallMs ?? DEFAULT_MAX_WALL_MS;
|
|
@@ -226,4 +216,32 @@ export async function resumeAgentTurn(input, bindings) {
|
|
|
226
216
|
}
|
|
227
217
|
}
|
|
228
218
|
export { agentStepOutput } from './handlers/result-shape.js';
|
|
219
|
+
/**
|
|
220
|
+
* The `InvokeAgentInput` a resumed turn runs with: the one captured in its
|
|
221
|
+
* snapshot at run start, the agent the caller resolved, and the org of the
|
|
222
|
+
* run's project, which the caller resolves as for `invokeAgent`.
|
|
223
|
+
*/
|
|
224
|
+
export function turnInputFromSnapshot(snapshot, input) {
|
|
225
|
+
return {
|
|
226
|
+
tenantId: snapshot.tenantId,
|
|
227
|
+
projectId: snapshot.projectId,
|
|
228
|
+
...(input.orgId !== undefined && { orgId: input.orgId }),
|
|
229
|
+
agent: input.agent,
|
|
230
|
+
conversationId: snapshot.conversationId,
|
|
231
|
+
userMessage: snapshot.userMessage,
|
|
232
|
+
...(snapshot.parameters !== undefined && { parameters: snapshot.parameters }),
|
|
233
|
+
...(snapshot.input !== undefined && { input: snapshot.input }),
|
|
234
|
+
...(snapshot.participantId !== undefined && { participantId: snapshot.participantId }),
|
|
235
|
+
...(snapshot.dryRun && { dryRun: true }),
|
|
236
|
+
...(snapshot.principal !== undefined &&
|
|
237
|
+
snapshot.principal !== null && {
|
|
238
|
+
principal: snapshot.principal,
|
|
239
|
+
}),
|
|
240
|
+
...(snapshot.authz !== undefined &&
|
|
241
|
+
snapshot.authz !== null && {
|
|
242
|
+
authz: snapshot.authz,
|
|
243
|
+
}),
|
|
244
|
+
...(snapshot.replay !== undefined && snapshot.replay !== null && { replay: snapshot.replay }),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
229
247
|
//# sourceMappingURL=invoke.js.map
|