@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
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reviewer's answer at an agent turn's approval gates: the tool-call
|
|
3
|
+
* gate (`dispatch-tools`) and the session gate (`setup`). A gate parks the
|
|
4
|
+
* turn on a waitpoint; the approvals route resumes it with the decision
|
|
5
|
+
* (`GateDecisionValue`): approve or reject, the reviewer's rationale, and
|
|
6
|
+
* who decided which approval.
|
|
7
|
+
*
|
|
8
|
+
* A gate fails closed. Only an explicit approve lets the tool run (or the
|
|
9
|
+
* session go on). Anything else blocks: a reject, and also a resume value
|
|
10
|
+
* that isn't a decision at all (a `value` that replaced it, a malformed
|
|
11
|
+
* payload), so no answer can be read as consent by omission.
|
|
12
|
+
*/
|
|
13
|
+
/** The approval subject an agent's tool-call gate parks on. */
|
|
14
|
+
export declare const TOOL_CALL_GATE_SUBJECT = "tool-call:pending";
|
|
15
|
+
/** The approval subject an agent's session gate (`afterTurns`) parks on. */
|
|
16
|
+
export declare const SESSION_GATE_SUBJECT = "agent-turn:session-hitl-gate";
|
|
17
|
+
/**
|
|
18
|
+
* The approval subjects an agent turn parks on. Their resume value is the
|
|
19
|
+
* reviewer's decision and nothing else, so the approvals route takes no
|
|
20
|
+
* `value` for them.
|
|
21
|
+
*/
|
|
22
|
+
export declare const AGENT_GATE_SUBJECTS: ReadonlySet<string>;
|
|
23
|
+
/**
|
|
24
|
+
* A gate's resume value: the reviewer's decision, as the approvals route
|
|
25
|
+
* (and the runtime, delivering a decision whose delivery was lost) completes
|
|
26
|
+
* the gate's waitpoint with it. The run's journal keeps it as it came.
|
|
27
|
+
*/
|
|
28
|
+
export interface GateDecisionValue {
|
|
29
|
+
readonly decided: 'approve' | 'reject';
|
|
30
|
+
readonly rationale?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Who decided, as an actor: `user:<userId>`, the reviewer's user. Absent
|
|
33
|
+
* from values written before it was recorded.
|
|
34
|
+
*/
|
|
35
|
+
readonly decidedBy?: string;
|
|
36
|
+
/** The approval decided. Absent from values written before it was recorded. */
|
|
37
|
+
readonly approvalId?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Who decided a gate, and which approval, when its value says. */
|
|
40
|
+
interface GateDecider {
|
|
41
|
+
readonly decidedBy?: string;
|
|
42
|
+
readonly approvalId?: string;
|
|
43
|
+
}
|
|
44
|
+
/** What a gate's resume value decides. */
|
|
45
|
+
export type GateDecision = GateDecider & ({
|
|
46
|
+
readonly approved: true;
|
|
47
|
+
} | {
|
|
48
|
+
readonly approved: false;
|
|
49
|
+
/** `rejected`: the reviewer said no. `unreadable`: the answer wasn't a decision. */
|
|
50
|
+
readonly reason: 'rejected' | 'unreadable';
|
|
51
|
+
/** The reviewer's rationale, or why an unreadable answer blocks. */
|
|
52
|
+
readonly rationale: string | undefined;
|
|
53
|
+
});
|
|
54
|
+
/** Why a gate blocks on an answer that isn't a decision. */
|
|
55
|
+
export declare const UNREADABLE_DECISION = "the approval's answer wasn't a decision (approve or reject), so it counts as a rejection";
|
|
56
|
+
/**
|
|
57
|
+
* The decision in a gate's resume value. Fails closed: only
|
|
58
|
+
* `{ decided: 'approve' }` approves.
|
|
59
|
+
*/
|
|
60
|
+
export declare function readGateDecision(value: unknown): GateDecision;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=gate-decision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-decision.d.ts","sourceRoot":"","sources":["../../src/handlers/gate-decision.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AAEH,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAE1D,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,iCAAiC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAGlD,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,mEAAmE;AACnE,UAAU,WAAW;IACnB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,0CAA0C;AAC1C,MAAM,MAAM,YAAY,GAAG,WAAW,GACpC,CACI;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,GAC3B;IACE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;IACzB,oFAAoF;IACpF,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,CAAC;IAC3C,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC,CACJ,CAAC;AAEJ,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,6FAC4D,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAwB7D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
/**
|
|
4
|
+
* The reviewer's answer at an agent turn's approval gates: the tool-call
|
|
5
|
+
* gate (`dispatch-tools`) and the session gate (`setup`). A gate parks the
|
|
6
|
+
* turn on a waitpoint; the approvals route resumes it with the decision
|
|
7
|
+
* (`GateDecisionValue`): approve or reject, the reviewer's rationale, and
|
|
8
|
+
* who decided which approval.
|
|
9
|
+
*
|
|
10
|
+
* A gate fails closed. Only an explicit approve lets the tool run (or the
|
|
11
|
+
* session go on). Anything else blocks: a reject, and also a resume value
|
|
12
|
+
* that isn't a decision at all (a `value` that replaced it, a malformed
|
|
13
|
+
* payload), so no answer can be read as consent by omission.
|
|
14
|
+
*/
|
|
15
|
+
/** The approval subject an agent's tool-call gate parks on. */
|
|
16
|
+
export const TOOL_CALL_GATE_SUBJECT = 'tool-call:pending';
|
|
17
|
+
/** The approval subject an agent's session gate (`afterTurns`) parks on. */
|
|
18
|
+
export const SESSION_GATE_SUBJECT = 'agent-turn:session-hitl-gate';
|
|
19
|
+
/**
|
|
20
|
+
* The approval subjects an agent turn parks on. Their resume value is the
|
|
21
|
+
* reviewer's decision and nothing else, so the approvals route takes no
|
|
22
|
+
* `value` for them.
|
|
23
|
+
*/
|
|
24
|
+
export const AGENT_GATE_SUBJECTS = new Set([
|
|
25
|
+
TOOL_CALL_GATE_SUBJECT,
|
|
26
|
+
SESSION_GATE_SUBJECT,
|
|
27
|
+
]);
|
|
28
|
+
/** Why a gate blocks on an answer that isn't a decision. */
|
|
29
|
+
export const UNREADABLE_DECISION = "the approval's answer wasn't a decision (approve or reject), so it counts as a rejection";
|
|
30
|
+
/**
|
|
31
|
+
* The decision in a gate's resume value. Fails closed: only
|
|
32
|
+
* `{ decided: 'approve' }` approves.
|
|
33
|
+
*/
|
|
34
|
+
export function readGateDecision(value) {
|
|
35
|
+
if (typeof value !== 'object' || value === null) {
|
|
36
|
+
return { approved: false, reason: 'unreadable', rationale: UNREADABLE_DECISION };
|
|
37
|
+
}
|
|
38
|
+
const { decided, rationale, decidedBy, approvalId } = value;
|
|
39
|
+
const decider = {
|
|
40
|
+
...(typeof decidedBy === 'string' && { decidedBy }),
|
|
41
|
+
...(typeof approvalId === 'string' && { approvalId }),
|
|
42
|
+
};
|
|
43
|
+
if (decided === 'approve')
|
|
44
|
+
return { approved: true, ...decider };
|
|
45
|
+
if (decided === 'reject') {
|
|
46
|
+
return {
|
|
47
|
+
approved: false,
|
|
48
|
+
reason: 'rejected',
|
|
49
|
+
rationale: typeof rationale === 'string' ? rationale : undefined,
|
|
50
|
+
...decider,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return { approved: false, reason: 'unreadable', rationale: UNREADABLE_DECISION };
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=gate-decision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-decision.js","sourceRoot":"","sources":["../../src/handlers/gate-decision.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAEjC;;;;;;;;;;;GAWG;AAEH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAE1D,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;A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7
7
|
* and accumulates usage on `ctx.usage`.
|
|
8
8
|
*
|
|
9
|
+
* Every call is recorded in the usage sink (`InvokeAgentBindings.usage`,
|
|
10
|
+
* the runtime's cost ledger) before the step goes on, a call that threw
|
|
11
|
+
* included. A sink that fails is tried again (a record is idempotent by
|
|
12
|
+
* call id); one that still fails fails the step when the call succeeded,
|
|
13
|
+
* so no answered call is left unrecorded. A call that failed keeps its
|
|
14
|
+
* own failure, which says it couldn't be recorded too. The call's id goes into
|
|
15
|
+
* the step's output and its provenance node, which keeps the call's
|
|
16
|
+
* identity (provider, model) while its usage lives in the ledger. A dry
|
|
17
|
+
* run spends nothing and records nothing.
|
|
18
|
+
*
|
|
9
19
|
* Output is a partial `AgentTurnIterationOutput` — `dispatch-tools`
|
|
10
20
|
* receives it and finishes composing the iteration output.
|
|
11
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-call.d.ts","sourceRoot":"","sources":["../../src/handlers/model-call.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-call.d.ts","sourceRoot":"","sources":["../../src/handlers/model-call.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKhE,OAAO,KAAK,EAA4B,WAAW,EAAE,MAAM,cAAc,CAAC;AAK1E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,CA0GnE"}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { recordModelUsage, } from '@kindgi/capabilities';
|
|
5
|
+
import { attemptsOf } from '@kindgi/capabilities/attempts';
|
|
3
6
|
import { emitTurnEvent } from '../streaming.js';
|
|
4
7
|
import { throwAgentTurnFailure } from './errors.js';
|
|
8
|
+
import { replayTag } from './replay.js';
|
|
9
|
+
import { addModelCallNode } from './turn-provenance.js';
|
|
5
10
|
/**
|
|
6
11
|
* Loop-body node #1. Invoke the model with the current
|
|
7
12
|
* `nextMessages` accumulator. Emits `model.call.started` +
|
|
8
13
|
* `model.call.completed`, records provenance for the model-call node,
|
|
9
14
|
* and accumulates usage on `ctx.usage`.
|
|
10
15
|
*
|
|
16
|
+
* Every call is recorded in the usage sink (`InvokeAgentBindings.usage`,
|
|
17
|
+
* the runtime's cost ledger) before the step goes on, a call that threw
|
|
18
|
+
* included. A sink that fails is tried again (a record is idempotent by
|
|
19
|
+
* call id); one that still fails fails the step when the call succeeded,
|
|
20
|
+
* so no answered call is left unrecorded. A call that failed keeps its
|
|
21
|
+
* own failure, which says it couldn't be recorded too. The call's id goes into
|
|
22
|
+
* the step's output and its provenance node, which keeps the call's
|
|
23
|
+
* identity (provider, model) while its usage lives in the ledger. A dry
|
|
24
|
+
* run spends nothing and records nothing.
|
|
25
|
+
*
|
|
11
26
|
* Output is a partial `AgentTurnIterationOutput` — `dispatch-tools`
|
|
12
27
|
* receives it and finishes composing the iteration output.
|
|
13
28
|
*/
|
|
@@ -23,6 +38,8 @@ export function buildModelCallHandler(ctx) {
|
|
|
23
38
|
const shaped = input;
|
|
24
39
|
const nextMessages = shaped?.nextMessages ?? [];
|
|
25
40
|
ctx.usage.steps += 1;
|
|
41
|
+
const step = ctx.usage.steps;
|
|
42
|
+
const callId = randomUUID();
|
|
26
43
|
await emitTurnEvent(ctx.bindings.onEvent, {
|
|
27
44
|
kind: 'model.call.started',
|
|
28
45
|
step: ctx.usage.steps,
|
|
@@ -51,28 +68,17 @@ export function buildModelCallHandler(ctx) {
|
|
|
51
68
|
...(ctx.tools.definitions.length > 0 && {
|
|
52
69
|
tools: ctx.tools.definitions,
|
|
53
70
|
}),
|
|
71
|
+
...modelSettingsOf(ctx),
|
|
54
72
|
abortSignal: ctx.turnAbort.signal,
|
|
55
73
|
};
|
|
74
|
+
const startedAt = Date.now();
|
|
56
75
|
try {
|
|
57
76
|
callResult = await ctx.provider.invoke(callInput);
|
|
58
77
|
}
|
|
59
78
|
catch (cause) {
|
|
60
|
-
|
|
61
|
-
throwAgentTurnFailure({
|
|
62
|
-
code: 'agent-turn-aborted',
|
|
63
|
-
message: `Agent turn aborted: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
64
|
-
reason: ctx.abortReason ?? 'timeout',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// The provider's own words (a 401's "invalid x-api-key", a 429)
|
|
68
|
-
// are what the caller needs; they're in `cause` too, but callers
|
|
69
|
-
// show `message`.
|
|
70
|
-
throwAgentTurnFailure({
|
|
71
|
-
code: 'model-invocation-failed',
|
|
72
|
-
message: `Model call to ${ctx.provider.metadata.id} (${ctx.model.name}) failed: ${describeCause(cause)}`,
|
|
73
|
-
cause,
|
|
74
|
-
});
|
|
79
|
+
return await failCall(ctx, kctx, { callId, step, cause, startedAt });
|
|
75
80
|
}
|
|
81
|
+
await recordAnswer(ctx, kctx, callId, step, callResult);
|
|
76
82
|
}
|
|
77
83
|
ctx.usage.promptTokens += callResult.usage.promptTokens;
|
|
78
84
|
ctx.usage.completionTokens += callResult.usage.completionTokens;
|
|
@@ -88,29 +94,18 @@ export function buildModelCallHandler(ctx) {
|
|
|
88
94
|
durationMs: callResult.durationMs,
|
|
89
95
|
});
|
|
90
96
|
if (ctx.provenance !== undefined && ctx.userMessage !== undefined) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
step: ctx.usage.steps,
|
|
99
|
-
promptTokens: callResult.usage.promptTokens,
|
|
100
|
-
completionTokens: callResult.usage.completionTokens,
|
|
101
|
-
costUsd: callResult.costUsd,
|
|
102
|
-
finishReason: callResult.finishReason,
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
ctx.provenance.addEdge({
|
|
106
|
-
from: modelCallNodeId,
|
|
107
|
-
to: `input:${ctx.userMessage.sequence}`,
|
|
108
|
-
kind: 'caused-by',
|
|
109
|
-
});
|
|
97
|
+
addModelCallNode(ctx.provenance, {
|
|
98
|
+
step: ctx.usage.steps,
|
|
99
|
+
callId,
|
|
100
|
+
provider: callResult.provider,
|
|
101
|
+
finishReason: callResult.finishReason,
|
|
102
|
+
at: new Date().toISOString(),
|
|
103
|
+
}, ctx.userMessage.sequence, ctx.toolResultIds ?? []);
|
|
110
104
|
}
|
|
111
105
|
// Partial iteration output — `dispatch-tools` finishes it.
|
|
112
106
|
const partial = {
|
|
113
107
|
step: ctx.usage.steps,
|
|
108
|
+
callId,
|
|
114
109
|
finishReason: callResult.finishReason,
|
|
115
110
|
message: callResult.message,
|
|
116
111
|
iterationUsage: {
|
|
@@ -124,6 +119,89 @@ export function buildModelCallHandler(ctx) {
|
|
|
124
119
|
return partial;
|
|
125
120
|
};
|
|
126
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* A call that answered: record it before the step goes on. A sink that
|
|
124
|
+
* still fails after its retries fails the step: an answered call isn't
|
|
125
|
+
* left unrecorded.
|
|
126
|
+
*/
|
|
127
|
+
async function recordAnswer(ctx, kctx, callId, step, answer) {
|
|
128
|
+
const { message: _answer, ...result } = answer;
|
|
129
|
+
const unrecorded = await recordCall(ctx, kctx, {
|
|
130
|
+
callId,
|
|
131
|
+
step,
|
|
132
|
+
status: 'ok',
|
|
133
|
+
result,
|
|
134
|
+
durationMs: answer.durationMs,
|
|
135
|
+
});
|
|
136
|
+
if (unrecorded !== undefined) {
|
|
137
|
+
throwAgentTurnFailure({
|
|
138
|
+
code: 'persistence-error',
|
|
139
|
+
message: `The model call couldn't be recorded: ${describeCause(unrecorded)}`,
|
|
140
|
+
cause: unrecorded,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A call that threw: record it, then fail the step with the call's own
|
|
146
|
+
* failure (aborted, or the provider's words). A record that failed too
|
|
147
|
+
* is said after it.
|
|
148
|
+
*/
|
|
149
|
+
async function failCall(ctx, kctx, failed) {
|
|
150
|
+
const { cause } = failed;
|
|
151
|
+
const attempts = attemptsOf(cause);
|
|
152
|
+
const unrecorded = await recordCall(ctx, kctx, {
|
|
153
|
+
callId: failed.callId,
|
|
154
|
+
step: failed.step,
|
|
155
|
+
status: 'failed',
|
|
156
|
+
error: { message: describeCause(cause), ...(attempts !== undefined && { attempts }) },
|
|
157
|
+
durationMs: Date.now() - failed.startedAt,
|
|
158
|
+
});
|
|
159
|
+
const andUnrecorded = unrecorded === undefined
|
|
160
|
+
? ''
|
|
161
|
+
: ` (and the failed call couldn't be recorded: ${describeCause(unrecorded)})`;
|
|
162
|
+
if (ctx.turnAbort.signal.aborted) {
|
|
163
|
+
throwAgentTurnFailure({
|
|
164
|
+
code: 'agent-turn-aborted',
|
|
165
|
+
message: `Agent turn aborted: ${cause instanceof Error ? cause.message : String(cause)}${andUnrecorded}`,
|
|
166
|
+
reason: ctx.abortReason ?? 'timeout',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
// The provider's own words (a 401's "invalid x-api-key", a 429) are
|
|
170
|
+
// what the caller needs; they're in `cause` too, but callers show
|
|
171
|
+
// `message`.
|
|
172
|
+
throwAgentTurnFailure({
|
|
173
|
+
code: 'model-invocation-failed',
|
|
174
|
+
message: `Model call to ${ctx.provider?.metadata.id} (${ctx.model?.name}) failed: ${describeCause(cause)}${andUnrecorded}`,
|
|
175
|
+
cause,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Record a model call in the usage sink, when the turn has one, trying
|
|
180
|
+
* a failing sink again. Resolves with the sink's last failure when it
|
|
181
|
+
* couldn't record; the caller decides what that means for the step.
|
|
182
|
+
*/
|
|
183
|
+
async function recordCall(ctx, kctx, call) {
|
|
184
|
+
const sink = ctx.bindings.usage;
|
|
185
|
+
if (sink === undefined || ctx.provider === undefined || ctx.model === undefined)
|
|
186
|
+
return;
|
|
187
|
+
const { input } = ctx;
|
|
188
|
+
const recorded = await recordModelUsage(sink, {
|
|
189
|
+
...call,
|
|
190
|
+
tenantId: input.tenantId,
|
|
191
|
+
projectId: input.projectId,
|
|
192
|
+
runId: kctx.runId,
|
|
193
|
+
agentId: input.agent.id,
|
|
194
|
+
agentVersion: input.agent.version,
|
|
195
|
+
conversationId: input.conversationId,
|
|
196
|
+
nodeId: kctx.nodeId,
|
|
197
|
+
providerId: ctx.provider.metadata.id,
|
|
198
|
+
model: ctx.model.name,
|
|
199
|
+
...(ctx.provider.metadata.fallback === true && { fallback: true }),
|
|
200
|
+
...(input.replay !== undefined && { replay: replayTag(input.replay) }),
|
|
201
|
+
occurredAt: new Date().toISOString(),
|
|
202
|
+
});
|
|
203
|
+
return recorded.kind === 'err' ? (recorded.error ?? new Error('no detail')) : undefined;
|
|
204
|
+
}
|
|
127
205
|
/** Longest cause text a failure message carries. */
|
|
128
206
|
const MAX_CAUSE_CHARS = 500;
|
|
129
207
|
/** A thrown value's message on one line, at most `MAX_CAUSE_CHARS` long. */
|
|
@@ -133,4 +211,12 @@ function describeCause(cause) {
|
|
|
133
211
|
return cause instanceof Error ? cause.name : 'no detail';
|
|
134
212
|
return text.length > MAX_CAUSE_CHARS ? `${text.slice(0, MAX_CAUSE_CHARS - 1)}…` : text;
|
|
135
213
|
}
|
|
214
|
+
/** The pinned model-settings block's values, as model-call fields; none when it has none. */
|
|
215
|
+
function modelSettingsOf(ctx) {
|
|
216
|
+
const settings = ctx.blocks?.modelSettings;
|
|
217
|
+
return {
|
|
218
|
+
...(settings?.temperature !== undefined && { temperature: settings.temperature }),
|
|
219
|
+
...(settings?.maxOutputTokens !== undefined && { maxOutputTokens: settings.maxOutputTokens }),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
136
222
|
//# sourceMappingURL=model-call.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-call.js","sourceRoot":"","sources":["../../src/handlers/model-call.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B,6BAA6B,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"persist-provenance.d.ts","sourceRoot":"","sources":["../../src/handlers/persist-provenance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,CAuB3E"}
|
|
@@ -22,7 +22,9 @@ export function buildPersistProvenanceHandler(ctx) {
|
|
|
22
22
|
// want).
|
|
23
23
|
return { persisted: false };
|
|
24
24
|
}
|
|
25
|
-
const persisted = await persistProvenance(ctx.provenance, ctx.provenanceBindings
|
|
25
|
+
const persisted = await persistProvenance(ctx.provenance, ctx.provenanceBindings, {
|
|
26
|
+
projectId: ctx.input.projectId,
|
|
27
|
+
});
|
|
26
28
|
if (persisted.kind === 'ok') {
|
|
27
29
|
ctx.persistedProvenance = persisted.value;
|
|
28
30
|
return { persisted: true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist-provenance.js","sourceRoot":"","sources":["../../src/handlers/persist-provenance.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAIjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAAC,GAAgB;IAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QAC5B,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,GAAG,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACzE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,wDAAwD;YACxD,0DAA0D;YAC1D,0DAA0D;Y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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist-user-message.d.ts","sourceRoot":"","sources":["../../src/handlers/persist-user-message.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"persist-user-message.d.ts","sourceRoot":"","sources":["../../src/handlers/persist-user-message.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,CAiC5E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
3
|
import { throwAgentTurnFailure } from './errors.js';
|
|
4
|
+
import { addInputNode } from './turn-provenance.js';
|
|
4
5
|
/**
|
|
5
6
|
* Persist the caller's user message BEFORE the model is called. A
|
|
6
7
|
* crash mid-turn leaves the question intact for a later replay. Also
|
|
@@ -24,14 +25,8 @@ export function buildPersistUserMessageHandler(ctx) {
|
|
|
24
25
|
};
|
|
25
26
|
ctx.userMessage = synthetic;
|
|
26
27
|
ctx.appended.push(synthetic);
|
|
27
|
-
if (ctx.provenance !== undefined)
|
|
28
|
-
ctx.provenance
|
|
29
|
-
id: `input:${synthetic.sequence}`,
|
|
30
|
-
kind: 'input',
|
|
31
|
-
timestamp: synthetic.createdAt,
|
|
32
|
-
...(synthetic.actor !== undefined && { actor: synthetic.actor }),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
28
|
+
if (ctx.provenance !== undefined)
|
|
29
|
+
addInputNode(ctx.provenance, synthetic);
|
|
35
30
|
return { sequence: synthetic.sequence };
|
|
36
31
|
}
|
|
37
32
|
const persisted = await ctx.bindings.conversationBinding.appendMessage({
|
|
@@ -45,14 +40,8 @@ export function buildPersistUserMessageHandler(ctx) {
|
|
|
45
40
|
throwAgentTurnFailure(persisted.error);
|
|
46
41
|
ctx.userMessage = persisted.value;
|
|
47
42
|
ctx.appended.push(persisted.value);
|
|
48
|
-
if (ctx.provenance !== undefined)
|
|
49
|
-
ctx.provenance.
|
|
50
|
-
id: `input:${persisted.value.sequence}`,
|
|
51
|
-
kind: 'input',
|
|
52
|
-
timestamp: persisted.value.createdAt,
|
|
53
|
-
...(persisted.value.actor !== undefined && { actor: persisted.value.actor }),
|
|
54
|
-
});
|
|
55
|
-
}
|
|
43
|
+
if (ctx.provenance !== undefined)
|
|
44
|
+
addInputNode(ctx.provenance, persisted.value);
|
|
56
45
|
return { sequence: persisted.value.sequence };
|
|
57
46
|
};
|
|
58
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist-user-message.js","sourceRoot":"","sources":["../../src/handlers/persist-user-message.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAQjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,8BAA8B,CAAC,GAAgB;IAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,SAAS,GAAwB;gBACrC,QAAQ,EAAE,CAAC,CAAC;gBACZ,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW;gBAC9B,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAe;gBAChD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;aACj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rE,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ;YAC5B,cAAc,EAAE,GAAG,CAAC,KAAK,CAAC,cAAc;YACxC,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW;YAC9B,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;SACjF,CAAC,CAAC;QACH,IAAI,SAAS,CAAC,IAAI,KAAK,KAAK;YAAE,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAErE,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC;QAClC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS;YAAE,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;QAEhF,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import type { Principal } from '@kindgi/authz';
|
|
2
|
-
import type { ProviderRegistry, TenantPolicy } from '@kindgi/capabilities';
|
|
2
|
+
import type { ProviderRegistry, TenantPolicy, UsageSink } from '@kindgi/capabilities';
|
|
3
3
|
import type { EmbeddingProviderRegistry } from '@kindgi/embedding';
|
|
4
4
|
import type { MemoryQueryBinding } from '@kindgi/memory';
|
|
5
5
|
import type { PolicyRegistry } from '@kindgi/policy-contract';
|
|
6
|
-
import type { ParentRunRef, RunBinding } from '@kindgi/runtime';
|
|
6
|
+
import type { ParentRunRef, RunBinding, RunReplayRef } from '@kindgi/runtime';
|
|
7
7
|
import type { ToolRegistry, ToolSecretRef } from '@kindgi/tools';
|
|
8
|
-
import type { ProjectId, ProvenanceId, RunId, TenantId, Timestamp } from '@kindgi/types';
|
|
8
|
+
import type { OrgId, ProjectId, ProvenanceId, RunId, TenantId, Timestamp } from '@kindgi/types';
|
|
9
|
+
import type { BlockReader } from '../blocks.js';
|
|
9
10
|
import type { ConversationBinding } from '../conversation-binding.js';
|
|
10
11
|
import type { GuardrailsBindings } from '../guardrails-gate.js';
|
|
11
12
|
import type { ProvenanceBindings } from '../provenance-emit.js';
|
|
12
13
|
import type { RunSnapshotBinding } from '../run-snapshot-binding.js';
|
|
13
14
|
import type { OnTurnEvent } from '../streaming.js';
|
|
14
15
|
import type { Agent, ConversationId } from '../types.js';
|
|
16
|
+
import type { ReplayBinding } from './replay.js';
|
|
15
17
|
/**
|
|
16
18
|
* The user-facing input to `invokeAgent`. Split out from `invoke.ts` so
|
|
17
19
|
* the handler modules can depend on the shape without pulling in the
|
|
@@ -27,6 +29,12 @@ export interface InvokeAgentInput {
|
|
|
27
29
|
* at the caller layer.
|
|
28
30
|
*/
|
|
29
31
|
readonly projectId: ProjectId;
|
|
32
|
+
/**
|
|
33
|
+
* The project's org, when it belongs to one: the runtime resolves it
|
|
34
|
+
* from the project, never from input. The turn's tools get it as
|
|
35
|
+
* `ToolContext.orgId`, its guardrails as `trace.orgId`.
|
|
36
|
+
*/
|
|
37
|
+
readonly orgId?: OrgId;
|
|
30
38
|
readonly agent: Agent;
|
|
31
39
|
readonly conversationId: ConversationId;
|
|
32
40
|
readonly userMessage: string;
|
|
@@ -43,6 +51,13 @@ export interface InvokeAgentInput {
|
|
|
43
51
|
* step. Recorded on the turn's run, so the flow can find its child.
|
|
44
52
|
*/
|
|
45
53
|
readonly parent?: ParentRunRef;
|
|
54
|
+
/**
|
|
55
|
+
* Marks the turn as a replay: an eval run re-running a past run (`of`)
|
|
56
|
+
* on this agent version. Recorded on the turn's run and in its snapshot.
|
|
57
|
+
* Its tool calls are decided by `InvokeAgentBindings.replay` (every call
|
|
58
|
+
* is refused when that isn't wired), and only a read-only tool can run.
|
|
59
|
+
*/
|
|
60
|
+
readonly replay?: RunReplayRef;
|
|
46
61
|
readonly participantId?: string;
|
|
47
62
|
readonly abortSignal?: AbortSignal;
|
|
48
63
|
/**
|
|
@@ -89,6 +104,12 @@ export interface InvokeAgentBindings extends GuardrailsBindings {
|
|
|
89
104
|
* sees another tenant's tools.
|
|
90
105
|
*/
|
|
91
106
|
readonly toolRegistry: ToolRegistry;
|
|
107
|
+
/**
|
|
108
|
+
* Data blocks (prompts and settings). Setup loads the blocks the agent
|
|
109
|
+
* references at their pinned versions. Optional: an agent that
|
|
110
|
+
* references blocks fails its turn (`block-unresolvable`) without it.
|
|
111
|
+
*/
|
|
112
|
+
readonly blockReader?: BlockReader;
|
|
92
113
|
/**
|
|
93
114
|
* Caller-plugged data-access surface for memory reads.
|
|
94
115
|
* The Kindgi runtime supplies a Postgres-backed implementation;
|
|
@@ -147,6 +168,12 @@ export interface InvokeAgentBindings extends GuardrailsBindings {
|
|
|
147
168
|
readonly onEvent?: OnTurnEvent;
|
|
148
169
|
readonly provenance?: ProvenanceBindings;
|
|
149
170
|
readonly hitl?: HitlBindings;
|
|
171
|
+
/**
|
|
172
|
+
* Where the turn records each model call (the runtime's cost ledger):
|
|
173
|
+
* its usage, provider, model, run, agent and step, before the step
|
|
174
|
+
* that made it goes on. Absent: calls aren't recorded.
|
|
175
|
+
*/
|
|
176
|
+
readonly usage?: UsageSink;
|
|
150
177
|
/**
|
|
151
178
|
* Declarative HTTP tools: optional secret resolver populated
|
|
152
179
|
* from the deployment's tenant-scoped `SecretBinding`. When present,
|
|
@@ -157,12 +184,19 @@ export interface InvokeAgentBindings extends GuardrailsBindings {
|
|
|
157
184
|
* unaffected.
|
|
158
185
|
*/
|
|
159
186
|
readonly resolveSecret?: (ref: ToolSecretRef) => Promise<string>;
|
|
187
|
+
/**
|
|
188
|
+
* How replay turns (`InvokeAgentInput.replay`) decide their tool calls,
|
|
189
|
+
* retrievals and session approval. Consulted only for a replay turn.
|
|
190
|
+
*/
|
|
191
|
+
readonly replay?: ReplayBinding;
|
|
160
192
|
}
|
|
161
193
|
export interface HitlBindings {
|
|
162
194
|
readonly enqueue: (input: HitlEnqueueInput) => Promise<HitlEnqueueResult>;
|
|
163
195
|
}
|
|
164
196
|
export interface HitlEnqueueInput {
|
|
165
197
|
readonly tenantId: TenantId;
|
|
198
|
+
/** The turn's project: approval lists filter by it. */
|
|
199
|
+
readonly projectId?: ProjectId;
|
|
166
200
|
readonly subjectKind: string;
|
|
167
201
|
readonly subjectRef: Readonly<Record<string, unknown>>;
|
|
168
202
|
readonly requiredRole?: 'standard' | 'senior' | 'admin';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-types.d.ts","sourceRoot":"","sources":["../../src/handlers/public-types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"public-types.d.ts","sourceRoot":"","sources":["../../src/handlers/public-types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,YAA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EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehydrate.d.ts","sourceRoot":"","sources":["../../src/handlers/rehydrate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rehydrate.d.ts","sourceRoot":"","sources":["../../src/handlers/rehydrate.ts"],"names":[],"mappings":"AA2CA,OAAO,EAAE,KAAK,YAAY,EAA0C,MAAM,iBAAiB,CAAC;AAI5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAwDhD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,OAAO,CAAC,OAAO,CAAC,CA0DlB"}
|