@sema-agent/client-core 0.99.0 → 0.100.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/CHANGELOG.md +177 -0
- package/README.md +32 -19
- package/dist/adapt/arms.js +60 -36
- package/dist/adapt/panelTasks.d.ts +2 -1
- package/dist/adapt/panelTasks.js +32 -9
- package/dist/adapt/textStream.d.ts +1 -1
- package/dist/adapt/textStream.js +51 -28
- package/dist/adapter/activeRunSelfHeal.d.ts +7 -0
- package/dist/adapter/activeRunSelfHeal.js +58 -11
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +125 -9
- package/dist/adapter/downstream/terminalToSdkResult.js +10 -0
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/adapter/runStream.js +32 -5
- package/dist/adapter/types.d.ts +2 -0
- package/dist/agentsWireCaps.d.ts +7 -0
- package/dist/agentsWireCaps.js +100 -15
- package/dist/cloudConfigWireCaps.d.ts +10 -1
- package/dist/cloudConfigWireCaps.js +156 -62
- package/dist/compactionStatus.d.ts +34 -0
- package/dist/compactionStatus.js +196 -0
- package/dist/decideFailureNote.js +3 -3
- package/dist/displayUntrusted.js +150 -5
- package/dist/engineAgentPanelStore.d.ts +7 -4
- package/dist/engineErrorCodes.d.ts +9 -1
- package/dist/engineErrorCodes.js +9 -5
- package/dist/engineRowRef.js +1 -0
- package/dist/engineToolDirectory.d.ts +3 -0
- package/dist/engineToolDirectory.js +4 -2
- package/dist/eventLeg.d.ts +1 -7
- package/dist/eventLeg.js +7 -8
- package/dist/fileHistoryCaptureCapability.d.ts +0 -3
- package/dist/fileHistoryCaptureCapability.js +0 -4
- package/dist/generated/engineFactTables.d.ts +1 -0
- package/dist/generated/engineFactTables.js +27 -0
- package/dist/generated/engineNoticeTables.js +3 -0
- package/dist/generated/settingsSchemaFns.d.ts +12 -0
- package/dist/generated/settingsSchemaFns.js +13 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.js +162 -0
- package/dist/generated/settingsSchemaTables.d.ts +1 -0
- package/dist/generated/settingsSchemaTables.js +5 -0
- package/dist/generated/settingsSchemaTypes.d.ts +28 -0
- package/dist/hitl/allowRuleShadow.js +2 -2
- package/dist/hitl/approvalCardReasons.js +2 -2
- package/dist/hitl/approvalHolds.d.ts +14 -0
- package/dist/hitl/approvalHolds.js +41 -0
- package/dist/hitl/askClassPair.d.ts +2 -2
- package/dist/hitl/askClassPair.js +2 -2
- package/dist/hitl/attributionLadder.d.ts +23 -0
- package/dist/hitl/attributionLadder.js +67 -0
- package/dist/hitl/decisionLedger.d.ts +55 -0
- package/dist/hitl/decisionLedger.js +156 -0
- package/dist/hitl/decisionRefusal.d.ts +1 -0
- package/dist/hitl/decisionRefusal.js +1 -1
- package/dist/hitl/decisionSend.d.ts +113 -0
- package/dist/hitl/decisionSend.js +579 -0
- package/dist/hitl/hitlBridge.js +18 -6
- package/dist/hitl/planReviewWire.js +45 -76
- package/dist/hitl/sessionPolicyDeliverable.js +3 -6
- package/dist/hitl/toolApprovalWire.js +43 -109
- package/dist/hostTurnSettings.d.ts +46 -7
- package/dist/hostTurnSettings.js +408 -7
- package/dist/humanTurn.d.ts +2 -1
- package/dist/humanTurn.js +3 -3
- package/dist/i18n/messages.en.d.ts +131 -0
- package/dist/i18n/messages.en.js +143 -12
- package/dist/i18n/messages.zh.js +148 -12
- package/dist/index.d.ts +18 -2
- package/dist/index.js +10 -1
- package/dist/inheritEnvCapability.d.ts +1 -0
- package/dist/inheritEnvCapability.js +9 -2
- package/dist/inheritEnvWire.js +2 -2
- package/dist/injectionLaneNotice.d.ts +5 -0
- package/dist/injectionLaneNotice.js +46 -0
- package/dist/mcpPanel.js +2 -0
- package/dist/mcpReconnect.js +2 -2
- package/dist/mcpToolToggles.d.ts +6 -0
- package/dist/mcpToolToggles.js +46 -0
- package/dist/mcpWireCaps.d.ts +10 -4
- package/dist/mcpWireCaps.js +106 -71
- package/dist/mcpWireTransport.d.ts +4 -0
- package/dist/mcpWireTransport.js +18 -0
- package/dist/modelCapabilityProbe.d.ts +2 -1
- package/dist/modelCapabilityProbe.js +10 -9
- package/dist/modelIdentityResolvability.d.ts +2 -0
- package/dist/modelIdentityResolvability.js +23 -5
- package/dist/ownKey.d.ts +26 -0
- package/dist/ownKey.js +75 -0
- package/dist/panelReduce.d.ts +5 -0
- package/dist/panelReduce.js +45 -13
- package/dist/panelStateHolder.d.ts +1 -0
- package/dist/panelStateHolder.js +10 -1
- package/dist/permissionRuleIssue.d.ts +2 -1
- package/dist/permissionRuleIssue.js +22 -21
- package/dist/pluginHooksWire.js +12 -10
- package/dist/prepareRefusal.d.ts +8 -0
- package/dist/prepareRefusal.js +72 -0
- package/dist/request/taskRequest.d.ts +10 -10
- package/dist/request/taskRequest.js +106 -65
- package/dist/resumeRefusalCopy.d.ts +3 -1
- package/dist/resumeRefusalCopy.js +22 -4
- package/dist/retryStatus.d.ts +18 -0
- package/dist/retryStatus.js +76 -19
- package/dist/ruleRefusalSentence.d.ts +4 -0
- package/dist/ruleRefusalSentence.js +58 -0
- package/dist/sandboxWire.d.ts +2 -1
- package/dist/sandboxWire.js +55 -21
- package/dist/scenarioRefusal.d.ts +2 -1
- package/dist/scenarioRefusal.js +5 -5
- package/dist/seam.d.ts +24 -9
- package/dist/seam.js +44 -4
- package/dist/seatContract.d.ts +16 -8
- package/dist/seatContract.js +21 -6
- package/dist/settingsCredentialKeyPaths.d.ts +8 -0
- package/dist/settingsCredentialKeyPaths.js +219 -0
- package/dist/skillsWireCaps.d.ts +0 -3
- package/dist/skillsWireCaps.js +1 -2
- package/dist/subagentContentStore.d.ts +1 -0
- package/dist/subagentContentStore.js +135 -27
- package/dist/toolsFlagNames.d.ts +8 -0
- package/dist/toolsFlagNames.js +110 -0
- package/dist/turnFailurePresentation.js +15 -7
- package/dist/wireRefusalCopy.d.ts +51 -17
- package/dist/wireRefusalCopy.js +298 -135
- package/docs/INTEGRATION-CLIENTS.md +423 -26
- package/package.json +4 -4
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const DECISION_LEDGER_FAMILIES: readonly ["plan_review", "tool_approval", "elicitation"];
|
|
2
|
+
export type DecisionLedgerFamily = (typeof DECISION_LEDGER_FAMILIES)[number];
|
|
3
|
+
export type DecisionLedgerPhase = 'handed' | 'posting' | 'landed';
|
|
4
|
+
export type DecisionLedgerSettler = 'host' | 'package' | 'gate_left';
|
|
5
|
+
export interface DecisionLedgerOp {
|
|
6
|
+
readonly family: DecisionLedgerFamily;
|
|
7
|
+
keys: readonly string[];
|
|
8
|
+
readonly handedAt: number;
|
|
9
|
+
settledAt: number | null;
|
|
10
|
+
settler: DecisionLedgerSettler | null;
|
|
11
|
+
phase: DecisionLedgerPhase;
|
|
12
|
+
notApplied: boolean;
|
|
13
|
+
ownCallOpen: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface DecisionLedgerIdentityParts {
|
|
16
|
+
readonly taskId?: string | undefined;
|
|
17
|
+
readonly planTaskId?: string | undefined;
|
|
18
|
+
readonly approvalId?: string | undefined;
|
|
19
|
+
readonly callId?: string | undefined;
|
|
20
|
+
readonly askId?: string | undefined;
|
|
21
|
+
readonly elicitationId?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare function decisionLedgerKeysOf(parts: DecisionLedgerIdentityParts): string[];
|
|
24
|
+
export declare function planDecisionKey(taskId: string): string;
|
|
25
|
+
export declare function nextDecisionLedgerTick(): number;
|
|
26
|
+
export declare function decisionOpsWithKey(family: DecisionLedgerFamily, key: string): DecisionLedgerOp[];
|
|
27
|
+
export declare function decisionOpsOfFamily(family: DecisionLedgerFamily): readonly DecisionLedgerOp[];
|
|
28
|
+
export declare function openDecisionOp(family: DecisionLedgerFamily, keys: readonly string[], phase: DecisionLedgerPhase, ownCallOpen: boolean): DecisionLedgerOp;
|
|
29
|
+
export declare function settleDecisionOp(op: DecisionLedgerOp, by: DecisionLedgerSettler): void;
|
|
30
|
+
export declare function closeDecisionOp(op: DecisionLedgerOp, by: DecisionLedgerSettler): void;
|
|
31
|
+
export declare function addDecisionOpKeys(op: DecisionLedgerOp, keys: readonly string[]): void;
|
|
32
|
+
export declare function dropDecisionOp(op: DecisionLedgerOp): void;
|
|
33
|
+
export declare function markLatestDecisionNotApplied(family: DecisionLedgerFamily, key: string): void;
|
|
34
|
+
export declare function settleDecisionOpsOnGateLeft(family: DecisionLedgerFamily, key: string): void;
|
|
35
|
+
export declare function latestDecisionHandedMark(family: DecisionLedgerFamily, key: string): number | null;
|
|
36
|
+
export declare function readMarkOf(v: number | undefined): number | undefined;
|
|
37
|
+
export declare function decisionKeyInFlight(key: string, mark: number | undefined): boolean;
|
|
38
|
+
export type DecisionIdentity = {
|
|
39
|
+
readonly gate: 'plan_review';
|
|
40
|
+
readonly taskId: string;
|
|
41
|
+
} | {
|
|
42
|
+
readonly gate: 'tool_approval';
|
|
43
|
+
readonly approvalId?: string;
|
|
44
|
+
readonly callId?: string;
|
|
45
|
+
readonly askId?: string;
|
|
46
|
+
} | {
|
|
47
|
+
readonly gate: 'elicitation';
|
|
48
|
+
readonly elicitationId: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly gate: 'run';
|
|
51
|
+
readonly taskId: string;
|
|
52
|
+
};
|
|
53
|
+
export declare function decisionInFlightOf(identity: DecisionIdentity, readMark?: number): boolean;
|
|
54
|
+
export declare function decisionReadMark(): number;
|
|
55
|
+
export declare function __resetDecisionLedgerForTests(family?: DecisionLedgerFamily): void;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { guardedRead, readOwnDataNonEmptyString } from '../ownKey.js';
|
|
2
|
+
export const DECISION_LEDGER_FAMILIES = Object.freeze(['plan_review', 'tool_approval', 'elicitation']);
|
|
3
|
+
const FAMILY_CAPACITY = Object.freeze({ plan_review: 32, tool_approval: 64, elicitation: 64 });
|
|
4
|
+
const KEY_PREFIX = Object.freeze({ run: 'run\u0000', plan: 'plan\u0000', approval: 'approval\u0000', call: 'call\u0000', ask: 'ask\u0000', elicitation: 'elicitation\u0000' });
|
|
5
|
+
const nonEmpty = (v) => typeof v === 'string' && v !== '';
|
|
6
|
+
export function decisionLedgerKeysOf(parts) {
|
|
7
|
+
const out = [];
|
|
8
|
+
const add = (prefix, v) => {
|
|
9
|
+
if (nonEmpty(v) && !out.includes(prefix + v))
|
|
10
|
+
out.push(prefix + v);
|
|
11
|
+
};
|
|
12
|
+
add(KEY_PREFIX.run, parts.taskId);
|
|
13
|
+
add(KEY_PREFIX.plan, parts.planTaskId);
|
|
14
|
+
add(KEY_PREFIX.approval, parts.approvalId);
|
|
15
|
+
add(KEY_PREFIX.call, parts.callId);
|
|
16
|
+
add(KEY_PREFIX.ask, parts.askId);
|
|
17
|
+
add(KEY_PREFIX.elicitation, parts.elicitationId);
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
export function planDecisionKey(taskId) {
|
|
21
|
+
return KEY_PREFIX.plan + taskId;
|
|
22
|
+
}
|
|
23
|
+
const ledger = Object.freeze({ plan_review: [], tool_approval: [], elicitation: [] });
|
|
24
|
+
let ledgerClock = 0;
|
|
25
|
+
export function nextDecisionLedgerTick() {
|
|
26
|
+
return ++ledgerClock;
|
|
27
|
+
}
|
|
28
|
+
export function decisionOpsWithKey(family, key) {
|
|
29
|
+
return ledger[family].filter((op) => op.keys.includes(key));
|
|
30
|
+
}
|
|
31
|
+
export function decisionOpsOfFamily(family) {
|
|
32
|
+
return ledger[family];
|
|
33
|
+
}
|
|
34
|
+
export function openDecisionOp(family, keys, phase, ownCallOpen) {
|
|
35
|
+
const op = {
|
|
36
|
+
family,
|
|
37
|
+
keys: Object.freeze([...keys]),
|
|
38
|
+
handedAt: ++ledgerClock,
|
|
39
|
+
settledAt: null,
|
|
40
|
+
settler: null,
|
|
41
|
+
phase,
|
|
42
|
+
notApplied: false,
|
|
43
|
+
ownCallOpen,
|
|
44
|
+
};
|
|
45
|
+
const rows = ledger[family];
|
|
46
|
+
rows.push(op);
|
|
47
|
+
while (rows.length > FAMILY_CAPACITY[family]) {
|
|
48
|
+
let victim = rows.findIndex((o) => o.settledAt !== null && !o.ownCallOpen);
|
|
49
|
+
if (victim < 0)
|
|
50
|
+
victim = rows.findIndex((o) => o !== op && o.phase === 'handed' && !o.ownCallOpen);
|
|
51
|
+
if (victim < 0)
|
|
52
|
+
break;
|
|
53
|
+
rows.splice(victim, 1);
|
|
54
|
+
}
|
|
55
|
+
return op;
|
|
56
|
+
}
|
|
57
|
+
export function settleDecisionOp(op, by) {
|
|
58
|
+
if (op.settledAt !== null)
|
|
59
|
+
return;
|
|
60
|
+
op.settledAt = ++ledgerClock;
|
|
61
|
+
op.settler = by;
|
|
62
|
+
}
|
|
63
|
+
export function closeDecisionOp(op, by) {
|
|
64
|
+
if (op.phase === 'posting')
|
|
65
|
+
op.phase = 'landed';
|
|
66
|
+
settleDecisionOp(op, by);
|
|
67
|
+
op.ownCallOpen = false;
|
|
68
|
+
}
|
|
69
|
+
export function addDecisionOpKeys(op, keys) {
|
|
70
|
+
const extra = keys.filter((k) => !op.keys.includes(k));
|
|
71
|
+
if (extra.length > 0)
|
|
72
|
+
op.keys = Object.freeze([...op.keys, ...extra]);
|
|
73
|
+
}
|
|
74
|
+
export function dropDecisionOp(op) {
|
|
75
|
+
const rows = ledger[op.family];
|
|
76
|
+
const i = rows.indexOf(op);
|
|
77
|
+
if (i >= 0)
|
|
78
|
+
rows.splice(i, 1);
|
|
79
|
+
}
|
|
80
|
+
export function markLatestDecisionNotApplied(family, key) {
|
|
81
|
+
const ops = decisionOpsWithKey(family, key);
|
|
82
|
+
if (ops.some((op) => op.settledAt === null))
|
|
83
|
+
return;
|
|
84
|
+
let latest;
|
|
85
|
+
for (const op of ops)
|
|
86
|
+
if (latest === undefined || op.handedAt > latest.handedAt)
|
|
87
|
+
latest = op;
|
|
88
|
+
if (latest !== undefined)
|
|
89
|
+
latest.notApplied = true;
|
|
90
|
+
}
|
|
91
|
+
export function settleDecisionOpsOnGateLeft(family, key) {
|
|
92
|
+
for (const op of decisionOpsWithKey(family, key))
|
|
93
|
+
settleDecisionOp(op, 'gate_left');
|
|
94
|
+
}
|
|
95
|
+
export function latestDecisionHandedMark(family, key) {
|
|
96
|
+
let mark = null;
|
|
97
|
+
for (const op of decisionOpsWithKey(family, key))
|
|
98
|
+
if (mark === null || op.handedAt > mark)
|
|
99
|
+
mark = op.handedAt;
|
|
100
|
+
return mark;
|
|
101
|
+
}
|
|
102
|
+
function anyInFlight(keys, mark) {
|
|
103
|
+
if (keys.length === 0)
|
|
104
|
+
return false;
|
|
105
|
+
for (const family of DECISION_LEDGER_FAMILIES) {
|
|
106
|
+
for (const op of ledger[family]) {
|
|
107
|
+
if (!op.keys.some((k) => keys.includes(k)))
|
|
108
|
+
continue;
|
|
109
|
+
if (op.settledAt === null)
|
|
110
|
+
return true;
|
|
111
|
+
if (mark !== undefined && op.settledAt > mark && !op.notApplied)
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
export function readMarkOf(v) {
|
|
118
|
+
return typeof v === 'number' && Number.isFinite(v) ? v : undefined;
|
|
119
|
+
}
|
|
120
|
+
export function decisionKeyInFlight(key, mark) {
|
|
121
|
+
return anyInFlight([key], mark);
|
|
122
|
+
}
|
|
123
|
+
function queryKeysOf(identity) {
|
|
124
|
+
if (typeof identity !== 'object' || identity === null)
|
|
125
|
+
return [];
|
|
126
|
+
const gate = guardedRead(() => readOwnDataNonEmptyString(identity, 'gate'));
|
|
127
|
+
const s = (key) => guardedRead(() => readOwnDataNonEmptyString(identity, key));
|
|
128
|
+
switch (gate) {
|
|
129
|
+
case 'plan_review':
|
|
130
|
+
return decisionLedgerKeysOf({ planTaskId: s('taskId') });
|
|
131
|
+
case 'run':
|
|
132
|
+
return decisionLedgerKeysOf({ taskId: s('taskId') });
|
|
133
|
+
case 'tool_approval':
|
|
134
|
+
return decisionLedgerKeysOf({ approvalId: s('approvalId'), callId: s('callId'), askId: s('askId') });
|
|
135
|
+
case 'elicitation':
|
|
136
|
+
return decisionLedgerKeysOf({ elicitationId: s('elicitationId') });
|
|
137
|
+
default:
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function decisionInFlightOf(identity, readMark) {
|
|
142
|
+
try {
|
|
143
|
+
return anyInFlight(queryKeysOf(identity), readMarkOf(readMark));
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export function decisionReadMark() {
|
|
150
|
+
return ++ledgerClock;
|
|
151
|
+
}
|
|
152
|
+
export function __resetDecisionLedgerForTests(family) {
|
|
153
|
+
for (const f of DECISION_LEDGER_FAMILIES)
|
|
154
|
+
if (family === undefined || f === family)
|
|
155
|
+
ledger[f].length = 0;
|
|
156
|
+
}
|
|
@@ -2,6 +2,7 @@ import { type GateCurrentPending, type HitlSafetyCode } from './hitlBridge.js';
|
|
|
2
2
|
import { type DecisionRefusalConflict } from './decisionConflict.js';
|
|
3
3
|
import { type ProtocolErrorName } from '../wireFailureShape.js';
|
|
4
4
|
import { type DenyAttributionRefusalDetail } from '../wireRefusalCopy.js';
|
|
5
|
+
export declare const ASK_DECIDED_CODE = "conflict.ask_decided";
|
|
5
6
|
export type DecisionRefusalStanding = 'settled-elsewhere' | 'ambiguous' | 'refused-pending';
|
|
6
7
|
export type { DecisionRefusalConflict } from './decisionConflict.js';
|
|
7
8
|
export interface RefusalCarrier {
|
|
@@ -7,7 +7,7 @@ import { readLivePendingRows } from './livePendingAsk.js';
|
|
|
7
7
|
import { guardedRead, ownDataField, readOwnDataValue } from '../ownKey.js';
|
|
8
8
|
import { PROTOCOL_ERROR_NAME, isDisplayableWireCode, protocolErrorNameReading, readErrorRecord, readRefusalField } from '../wireFailureShape.js';
|
|
9
9
|
import { denyAttributionRefusalFromError } from '../wireRefusalCopy.js';
|
|
10
|
-
const ASK_DECIDED_CODE = 'conflict.ask_decided';
|
|
10
|
+
export const ASK_DECIDED_CODE = 'conflict.ask_decided';
|
|
11
11
|
const TRANSIENT_STATUSES = new Set([408, 425, 429, 502, 503, 504]);
|
|
12
12
|
export function refusalCarrierOf(err) {
|
|
13
13
|
if (typeof err !== 'object' || err === null)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { AgentClient, ElicitResponse } from '@sema-agent/sdk';
|
|
2
|
+
import { type AskGoneDetail } from '../decideReceipt.js';
|
|
3
|
+
import type { ApprovalDecidedByReading } from '../approvalDecidedByCapability.js';
|
|
4
|
+
import { type DecisionNoteAudit } from './approvalDecisionNoteAudit.js';
|
|
5
|
+
import { type DecisionRefusalClassified, type LiveAskPendingReading } from './decisionRefusal.js';
|
|
6
|
+
import { type HostApprovalCardHold } from './approvalHolds.js';
|
|
7
|
+
import { type ApprovalCardDecision, type ToolApprovalRespondAckView, type ToolApprovalRespondParkingView } from './toolApprovalWire.js';
|
|
8
|
+
export declare const HITL_DECISION_FAMILIES: readonly ["approval", "ask", "elicitation"];
|
|
9
|
+
export type HitlDecisionFamily = (typeof HITL_DECISION_FAMILIES)[number];
|
|
10
|
+
export declare const HITL_DECISION_NOT_APPLIED_CAUSES: readonly ["gone", "parked", "parking", "lane_disabled", "refused", "idempotency_crossed"];
|
|
11
|
+
export type HitlDecisionNotAppliedCause = (typeof HITL_DECISION_NOT_APPLIED_CAUSES)[number];
|
|
12
|
+
export declare const HITL_DECISION_UNCONFIRMED_CAUSES: readonly ["transport", "server_error", "local_error", "aborted", "gone_after_retry"];
|
|
13
|
+
export type HitlDecisionUnconfirmedCause = (typeof HITL_DECISION_UNCONFIRMED_CAUSES)[number];
|
|
14
|
+
export declare const HITL_DECISION_NOT_SENT_CAUSES: readonly ["aborted", "duplicate_in_flight", "invalid_request", "no_verb", "not_an_answer"];
|
|
15
|
+
export type HitlDecisionNotSentCause = (typeof HITL_DECISION_NOT_SENT_CAUSES)[number];
|
|
16
|
+
export interface HitlApprovalDecisionRequest {
|
|
17
|
+
readonly family: 'approval';
|
|
18
|
+
readonly approvalId: string;
|
|
19
|
+
readonly taskId?: string;
|
|
20
|
+
readonly toolCallId?: string;
|
|
21
|
+
readonly answer: ApprovalCardDecision;
|
|
22
|
+
}
|
|
23
|
+
export interface HitlAskDecisionRequest {
|
|
24
|
+
readonly family: 'ask';
|
|
25
|
+
readonly taskId: string;
|
|
26
|
+
readonly askId: string;
|
|
27
|
+
readonly approvalId?: string;
|
|
28
|
+
readonly toolCallId?: string;
|
|
29
|
+
readonly answer: ApprovalCardDecision;
|
|
30
|
+
}
|
|
31
|
+
export interface HitlElicitationDecisionRequest {
|
|
32
|
+
readonly family: 'elicitation';
|
|
33
|
+
readonly elicitationId: string;
|
|
34
|
+
readonly taskId?: string;
|
|
35
|
+
readonly response: ElicitResponse;
|
|
36
|
+
}
|
|
37
|
+
export type HitlDecisionSendRequest = HitlApprovalDecisionRequest | HitlAskDecisionRequest | HitlElicitationDecisionRequest;
|
|
38
|
+
export interface HitlDecisionSendClient {
|
|
39
|
+
readonly toolApprovals?: Partial<Pick<AgentClient['toolApprovals'], 'respond' | 'decideAsk'>>;
|
|
40
|
+
readonly elicitations?: Partial<Pick<AgentClient['elicitations'], 'respond'>>;
|
|
41
|
+
}
|
|
42
|
+
export interface HitlDecisionGate {
|
|
43
|
+
readonly family: HitlDecisionFamily;
|
|
44
|
+
readonly approvalId?: string;
|
|
45
|
+
readonly askId?: string;
|
|
46
|
+
readonly taskId?: string;
|
|
47
|
+
readonly elicitationId?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface HitlDecisionSendDeps {
|
|
50
|
+
readonly client: HitlDecisionSendClient;
|
|
51
|
+
readonly signal?: AbortSignal;
|
|
52
|
+
readonly approvalDecisionNoteCapable?: boolean;
|
|
53
|
+
readonly approvalDecidedBy?: ApprovalDecidedByReading;
|
|
54
|
+
readonly readPending?: (gate: HitlDecisionGate, opts: {
|
|
55
|
+
readonly signal: AbortSignal;
|
|
56
|
+
}) => Promise<LiveAskPendingReading>;
|
|
57
|
+
readonly hold?: HostApprovalCardHold;
|
|
58
|
+
}
|
|
59
|
+
interface HitlDecisionOutcomeBase {
|
|
60
|
+
readonly family: HitlDecisionFamily;
|
|
61
|
+
readonly attempts: number;
|
|
62
|
+
readonly fallback?: 'approval';
|
|
63
|
+
readonly noteDropped?: true;
|
|
64
|
+
readonly rememberDropped?: true;
|
|
65
|
+
readonly attributionDropped?: true;
|
|
66
|
+
readonly attributionRenamed?: true;
|
|
67
|
+
readonly pending?: LiveAskPendingReading;
|
|
68
|
+
}
|
|
69
|
+
export interface HitlDecisionApplied extends HitlDecisionOutcomeBase {
|
|
70
|
+
readonly kind: 'applied';
|
|
71
|
+
readonly ack?: ToolApprovalRespondAckView;
|
|
72
|
+
readonly noteAudit?: DecisionNoteAudit;
|
|
73
|
+
}
|
|
74
|
+
export interface HitlDecisionSettledElsewhere extends HitlDecisionOutcomeBase {
|
|
75
|
+
readonly kind: 'settled_elsewhere';
|
|
76
|
+
readonly firstDecision?: 'approve' | 'deny';
|
|
77
|
+
readonly contrary?: true;
|
|
78
|
+
readonly decidedAtMs?: number;
|
|
79
|
+
readonly actorLabel?: string;
|
|
80
|
+
readonly noteAudit?: DecisionNoteAudit;
|
|
81
|
+
}
|
|
82
|
+
export interface HitlDecisionNotApplied extends HitlDecisionOutcomeBase {
|
|
83
|
+
readonly kind: 'not_applied';
|
|
84
|
+
readonly cause: HitlDecisionNotAppliedCause;
|
|
85
|
+
readonly errorCode?: string;
|
|
86
|
+
readonly status?: number;
|
|
87
|
+
readonly sessionId?: string;
|
|
88
|
+
readonly gone?: AskGoneDetail;
|
|
89
|
+
readonly retryAfterMs?: number;
|
|
90
|
+
readonly parking?: ToolApprovalRespondParkingView;
|
|
91
|
+
readonly refusal?: DecisionRefusalClassified;
|
|
92
|
+
readonly closesOut?: true;
|
|
93
|
+
}
|
|
94
|
+
export interface HitlDecisionUnconfirmed extends HitlDecisionOutcomeBase {
|
|
95
|
+
readonly kind: 'unconfirmed';
|
|
96
|
+
readonly cause: HitlDecisionUnconfirmedCause;
|
|
97
|
+
readonly status?: number;
|
|
98
|
+
}
|
|
99
|
+
export interface HitlDecisionNotSent extends HitlDecisionOutcomeBase {
|
|
100
|
+
readonly kind: 'not_sent';
|
|
101
|
+
readonly cause: HitlDecisionNotSentCause;
|
|
102
|
+
}
|
|
103
|
+
export type HitlDecisionSendOutcome = HitlDecisionApplied | HitlDecisionSettledElsewhere | HitlDecisionNotApplied | HitlDecisionUnconfirmed | HitlDecisionNotSent;
|
|
104
|
+
export declare const HITL_DECISION_READBACK_BUDGET_MS = 4000;
|
|
105
|
+
export interface HitlDecisionSendTiming {
|
|
106
|
+
readonly delays?: readonly number[];
|
|
107
|
+
readonly budgetMs?: number;
|
|
108
|
+
readonly parkingDelayMs?: number;
|
|
109
|
+
}
|
|
110
|
+
export declare function __setHitlDecisionSendTimingForTests(t?: HitlDecisionSendTiming): void;
|
|
111
|
+
export declare function hitlAskIdempotencyKey(askId: string, verdict: 'approve' | 'deny'): string;
|
|
112
|
+
export declare function sendHitlDecision(request: HitlDecisionSendRequest, deps: HitlDecisionSendDeps): Promise<HitlDecisionSendOutcome>;
|
|
113
|
+
export {};
|