@sema-agent/client-core 0.98.0 → 0.99.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 +199 -0
- package/README.md +35 -22
- package/dist/adapt/arms.js +61 -20
- package/dist/adapt/panelTasks.d.ts +1 -1
- package/dist/adapt/panelTasks.js +2 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +4 -3
- package/dist/adapter/activeRunSelfHeal.js +162 -293
- package/dist/adapter/downstream/eventToSdkMessage.js +52 -4
- package/dist/adapter/runStream.js +52 -37
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +0 -3
- package/dist/agentsWireCaps.js +33 -24
- package/dist/cloudConfigWireCaps.d.ts +1 -1
- package/dist/cloudConfigWireCaps.js +26 -4
- package/dist/controlRouter.d.ts +4 -2
- package/dist/controlRouter.js +39 -51
- package/dist/coreValuePorts.d.ts +26 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/detachWire.js +3 -2
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +3 -0
- package/dist/engineAgentPanelStore.d.ts +7 -0
- package/dist/engineAgentPanelStore.js +14 -0
- package/dist/engineCapReader.d.ts +2 -1
- package/dist/engineCapReader.js +7 -5
- package/dist/engineCapsCache.d.ts +8 -0
- package/dist/engineCapsCache.js +59 -6
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineErrorCodes.d.ts +2 -1
- package/dist/engineErrorCodes.js +2 -7
- package/dist/engineRowRef.js +3 -0
- package/dist/engineSessionMessages.d.ts +1 -0
- package/dist/engineSessionMessages.js +7 -1
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +2 -1
- package/dist/env/uiLanguage.js +3 -2
- package/dist/eventLeg.d.ts +8 -0
- package/dist/eventLeg.js +61 -41
- package/dist/fileHistoryCaptureCapability.d.ts +2 -1
- package/dist/fileHistoryCaptureCapability.js +12 -18
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/frameBinding.d.ts +3 -0
- package/dist/frameBinding.js +12 -0
- package/dist/gateOutcome.js +16 -2
- package/dist/gateVocabulary.d.ts +8 -7
- package/dist/gateVocabulary.js +71 -73
- package/dist/generated/engineFactTables.d.ts +17 -1
- package/dist/generated/engineFactTables.js +29 -0
- package/dist/generated/engineNoticeTables.js +9 -3
- package/dist/generated/settingsSchemaFns.d.ts +6 -0
- package/dist/generated/settingsSchemaFns.js +57 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaTables.d.ts +1 -0
- package/dist/generated/settingsSchemaTables.js +4 -0
- package/dist/generated/settingsSchemaTypes.d.ts +105 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +2 -1
- package/dist/hitl/allowRuleShadow.js +17 -14
- package/dist/hitl/approvalCardReasons.d.ts +3 -2
- package/dist/hitl/approvalCardReasons.js +27 -28
- package/dist/hitl/approvalHolds.d.ts +3 -0
- package/dist/hitl/approvalHolds.js +73 -29
- package/dist/hitl/askClassPair.d.ts +1 -1
- package/dist/hitl/askClassPair.js +16 -0
- package/dist/hitl/askGateWire.js +2 -1
- package/dist/hitl/askSettlementLine.d.ts +14 -4
- package/dist/hitl/askSettlementLine.js +67 -47
- package/dist/hitl/automaticAnswerVerdict.d.ts +2 -1
- package/dist/hitl/automaticAnswerVerdict.js +8 -8
- package/dist/hitl/crashConvergedNotice.d.ts +5 -4
- package/dist/hitl/crashConvergedNotice.js +28 -41
- package/dist/hitl/frameRouter.js +7 -8
- package/dist/hitl/hitlBridge.d.ts +1 -0
- package/dist/hitl/hitlBridge.js +3 -3
- package/dist/hitl/persistedRulesWire.d.ts +6 -5
- package/dist/hitl/persistedRulesWire.js +55 -73
- package/dist/hitl/planReviewWire.d.ts +5 -0
- package/dist/hitl/planReviewWire.js +8 -0
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +46 -3
- package/dist/hitl/sessionPolicyWire.d.ts +2 -1
- package/dist/hitl/sessionPolicyWire.js +23 -24
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +17 -5
- package/dist/hitl/toolApprovalWire.js +79 -40
- package/dist/hooksWireCaps.js +145 -56
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +71 -0
- package/dist/hostTurnSettings.js +291 -0
- package/dist/humanTurn.d.ts +14 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +582 -0
- package/dist/i18n/messages.en.js +582 -0
- package/dist/i18n/messages.zh.js +718 -1
- package/dist/index.d.ts +29 -13
- package/dist/index.js +18 -9
- package/dist/inheritEnvCapability.d.ts +3 -2
- package/dist/inheritEnvCapability.js +3 -3
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +12 -14
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +2 -1
- package/dist/liveModelCatalog.js +14 -8
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +40 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +3 -1
- package/dist/mcpProbeWire.js +5 -0
- package/dist/mcpWireCaps.d.ts +34 -0
- package/dist/mcpWireCaps.js +117 -17
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +64 -0
- package/dist/modelCapabilityProbe.js +600 -0
- package/dist/modelIdentityResolvability.d.ts +3 -0
- package/dist/modelIdentityResolvability.js +26 -17
- package/dist/ownKey.d.ts +7 -0
- package/dist/ownKey.js +34 -0
- package/dist/panelReduce.d.ts +6 -1
- package/dist/panelReduce.js +50 -3
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.d.ts +2 -1
- package/dist/permissionRulesWriteCapability.js +8 -6
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +217 -11
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/request/taskRequest.d.ts +11 -5
- package/dist/request/taskRequest.js +112 -16
- package/dist/resumeRefusalCopy.d.ts +12 -9
- package/dist/resumeRefusalCopy.js +70 -143
- package/dist/retryStatus.d.ts +37 -0
- package/dist/retryStatus.js +79 -0
- package/dist/scenarioRefusal.d.ts +9 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/seam.d.ts +25 -1
- package/dist/seam.js +10 -1
- package/dist/seatContract.d.ts +260 -10
- package/dist/seatContract.js +692 -19
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -1
- package/dist/sessionPolicyCapability.js +8 -6
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -1
- package/dist/skillToolListsCapability.js +8 -6
- package/dist/sseIdleTriage.js +3 -2
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagentContentStore.d.ts +3 -0
- package/dist/subagentContentStore.js +22 -0
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolRoster.d.ts +3 -2
- package/dist/toolRoster.js +21 -20
- package/dist/turnFailurePresentation.d.ts +12 -1
- package/dist/turnFailurePresentation.js +212 -15
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -1
- package/dist/userInvokedSkillsCapability.js +31 -7
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +23 -1
- package/dist/wireFailureShape.js +2 -1
- package/dist/wireRefusalCopy.d.ts +13 -1
- package/dist/wireRefusalCopy.js +24 -28
- package/dist/workflowsJournalCapability.d.ts +2 -1
- package/dist/workflowsJournalCapability.js +8 -6
- package/docs/INTEGRATION-CLIENTS.md +542 -30
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hostLog } from '../host.js';
|
|
2
2
|
import { liveFrameCallKey } from './gateIdentity.js';
|
|
3
|
-
import { decideReceiptReopen } from '../decideReceipt.js';
|
|
3
|
+
import { decideReceiptReopen, readDecideReceipt } from '../decideReceipt.js';
|
|
4
4
|
export const APPROVAL_SETTLED_HOWS = Object.freeze(['answered', 'interrupted', 'closed_by_engine']);
|
|
5
5
|
export const SETTLED_APPROVALS_MAX_ENTRIES = 4096;
|
|
6
6
|
const nonEmpty = (v) => typeof v === 'string' && v !== '';
|
|
@@ -73,7 +73,7 @@ export async function awaitApprovalHolder(hold, signal, asker) {
|
|
|
73
73
|
}
|
|
74
74
|
if (r.kind !== 'unsettled' || r.cause !== 'interrupted' || hold.trailing === undefined)
|
|
75
75
|
return HOLDER_FREE;
|
|
76
|
-
const landed = await hold.trailing.then(() =>
|
|
76
|
+
const landed = await hold.trailing.then((raw) => decideReceiptReopen(readDecideReceipt(raw)) === null, () => false);
|
|
77
77
|
return landed ? Object.freeze({ kind: 'settled', how: 'interrupted', outcome: r }) : HOLDER_FREE;
|
|
78
78
|
}
|
|
79
79
|
finally {
|
|
@@ -98,7 +98,7 @@ async function awaitHostHolder(hold, signal, asker) {
|
|
|
98
98
|
unsubscribe();
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
function holdHostCard(identity) {
|
|
101
|
+
function holdHostCard(identity, signal) {
|
|
102
102
|
const h = approvalDecisionHolds;
|
|
103
103
|
const key = `hitl-host:${++h.clock}`;
|
|
104
104
|
let resolveReleased = () => { };
|
|
@@ -109,41 +109,71 @@ function holdHostCard(identity) {
|
|
|
109
109
|
const hold = { lane: 'host', identity: frozen, phase: 'card', released };
|
|
110
110
|
h.inFlight.set(key, hold);
|
|
111
111
|
let done = false;
|
|
112
|
-
|
|
112
|
+
let stopFollowing = () => { };
|
|
113
|
+
const release = (settled) => {
|
|
114
|
+
if (done)
|
|
115
|
+
return;
|
|
116
|
+
done = true;
|
|
117
|
+
stopFollowing();
|
|
118
|
+
const how = settled === 'answered' || settled === 'interrupted' ? settled : undefined;
|
|
119
|
+
if (how !== undefined && nonEmpty(frozen.approvalId))
|
|
120
|
+
noteSettled(frozen.approvalId, how, false, how === 'interrupted' ? interruptedThere('decide') : nothingSentHere('decide'), true);
|
|
121
|
+
if (h.inFlight.get(key) === hold)
|
|
122
|
+
h.inFlight.delete(key);
|
|
123
|
+
resolveReleased(how);
|
|
124
|
+
};
|
|
125
|
+
const handle = Object.freeze({
|
|
113
126
|
identity: frozen,
|
|
114
127
|
sending: () => {
|
|
115
|
-
if (!done)
|
|
116
|
-
hold.phase = 'respond';
|
|
117
|
-
},
|
|
118
|
-
release: (settled) => {
|
|
119
128
|
if (done)
|
|
120
129
|
return;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (how !== undefined && nonEmpty(frozen.approvalId))
|
|
124
|
-
noteSettled(frozen.approvalId, how, false, how === 'interrupted' ? interruptedThere('decide') : nothingSentHere('decide'), true);
|
|
125
|
-
if (h.inFlight.get(key) === hold)
|
|
126
|
-
h.inFlight.delete(key);
|
|
127
|
-
resolveReleased(how);
|
|
130
|
+
hold.phase = 'respond';
|
|
131
|
+
stopFollowing();
|
|
128
132
|
},
|
|
133
|
+
release,
|
|
134
|
+
});
|
|
135
|
+
stopFollowing = followCallerSignal(signal, () => {
|
|
136
|
+
if (!done && hold.phase === 'card')
|
|
137
|
+
release();
|
|
129
138
|
});
|
|
139
|
+
return handle;
|
|
140
|
+
}
|
|
141
|
+
function callerSignalAborted(signal) {
|
|
142
|
+
if (signal === undefined || signal === null)
|
|
143
|
+
return false;
|
|
144
|
+
try {
|
|
145
|
+
return signal.aborted === true;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
130
150
|
}
|
|
131
|
-
const CLAIM_MAX_ROUNDS = 8;
|
|
132
151
|
export async function claimApprovalCardFor(who, signal) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
let leave = () => { };
|
|
153
|
+
const left = new Promise((resolve) => {
|
|
154
|
+
leave = () => resolve('aborted');
|
|
155
|
+
});
|
|
156
|
+
const unsubscribe = followCallerSignal(signal, leave);
|
|
157
|
+
try {
|
|
158
|
+
for (;;) {
|
|
159
|
+
if (callerSignalAborted(signal))
|
|
160
|
+
return Object.freeze({ kind: 'aborted' });
|
|
161
|
+
const entry = settledApprovalOf(who.approvalId);
|
|
162
|
+
if (settledForDurableLane(entry) && entry !== undefined)
|
|
163
|
+
return Object.freeze({ kind: 'joined', outcome: { ...entry.outcome, joinedInFlight: true } });
|
|
164
|
+
const holder = approvalHoldFor(who);
|
|
165
|
+
if (holder === undefined)
|
|
166
|
+
return Object.freeze({ kind: 'held', hold: holdHostCard(who, signal) });
|
|
167
|
+
const wait = await Promise.race([awaitApprovalHolder(holder, undefined, 'decide'), left]);
|
|
168
|
+
if (wait === 'aborted')
|
|
169
|
+
return Object.freeze({ kind: 'aborted' });
|
|
170
|
+
if (wait.kind === 'settled')
|
|
171
|
+
return Object.freeze({ kind: 'joined', outcome: { ...wait.outcome, joinedInFlight: true } });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
unsubscribe();
|
|
145
176
|
}
|
|
146
|
-
return Object.freeze({ kind: 'held', hold: holdHostCard(who) });
|
|
147
177
|
}
|
|
148
178
|
export const approvalDecisionHolds = { inFlight: new Map(), settled: new Map(), openReads: new Set(), outcomes: new Map(), clock: 0 };
|
|
149
179
|
export function settledApprovalOf(approvalId) {
|
|
@@ -180,6 +210,20 @@ function engineClosedOutcome() {
|
|
|
180
210
|
export function noteEngineClosedApproval(approvalId, parked) {
|
|
181
211
|
noteSettled(approvalId, 'closed_by_engine', parked, engineClosedOutcome());
|
|
182
212
|
}
|
|
213
|
+
export function settleEngineClosedApproval(frame, parked) {
|
|
214
|
+
let id;
|
|
215
|
+
try {
|
|
216
|
+
const d = typeof frame === 'object' && frame !== null ? Object.getOwnPropertyDescriptor(frame, 'approvalId') : undefined;
|
|
217
|
+
id = d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if (!nonEmpty(id))
|
|
223
|
+
return false;
|
|
224
|
+
noteEngineClosedApproval(id, parked);
|
|
225
|
+
return supersedeLiveCard(liveFrameCallKey(id), parked);
|
|
226
|
+
}
|
|
183
227
|
export function noteHolderSettledApproval(approvalId, how, outcome) {
|
|
184
228
|
noteSettled(approvalId, how, false, outcome, true);
|
|
185
229
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CORE_MODE_ARBITRATION } from '../generated/engineFactTables.js';
|
|
2
2
|
export declare const DEPLOYMENT_LIST_ASK_CLASSES: readonly (keyof typeof CORE_MODE_ARBITRATION)[];
|
|
3
3
|
export type AskClassPairReading = {
|
|
4
4
|
readonly state: 'pair';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CORE_MODE_ARBITRATION } from '../generated/engineFactTables.js';
|
|
1
2
|
export const DEPLOYMENT_LIST_ASK_CLASSES = Object.freeze(['ask_rule']);
|
|
2
3
|
const ABSENT = Object.freeze({ state: 'absent' });
|
|
3
4
|
const MALFORMED = Object.freeze({ state: 'malformed' });
|
|
@@ -35,8 +36,23 @@ export function readAskClassPairState(v) {
|
|
|
35
36
|
return MALFORMED;
|
|
36
37
|
if (classes[0] !== askClass)
|
|
37
38
|
return MALFORMED;
|
|
39
|
+
if (!inCanonicalOrder(classes))
|
|
40
|
+
return MALFORMED;
|
|
38
41
|
return Object.freeze({ state: 'pair', askClass, classes: Object.freeze(classes) });
|
|
39
42
|
}
|
|
43
|
+
function inCanonicalOrder(classes) {
|
|
44
|
+
const order = Object.keys(CORE_MODE_ARBITRATION);
|
|
45
|
+
let last = -1;
|
|
46
|
+
for (const c of classes) {
|
|
47
|
+
const rank = order.indexOf(c);
|
|
48
|
+
if (rank < 0)
|
|
49
|
+
continue;
|
|
50
|
+
if (rank <= last)
|
|
51
|
+
return false;
|
|
52
|
+
last = rank;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
40
56
|
export function readAskClassPair(v) {
|
|
41
57
|
const r = readAskClassPairState(v);
|
|
42
58
|
return r.state === 'pair' ? { askClass: r.askClass, classes: r.classes } : undefined;
|
package/dist/hitl/askGateWire.js
CHANGED
|
@@ -6,6 +6,7 @@ import { abortableSleep } from '../abortableSleep.js';
|
|
|
6
6
|
import { hostLog } from '../host.js';
|
|
7
7
|
import { decideAcceptedNotResolved, readDecideReceipt } from '../decideReceipt.js';
|
|
8
8
|
import { APPROVAL_EXPIRED } from '../engineErrorCodes.js';
|
|
9
|
+
import { isNotFoundFailure } from '../wireErrorTriage.js';
|
|
9
10
|
import { readDecisionRefusalAsk } from './decisionRefusal.js';
|
|
10
11
|
import { resumeReopenFromError } from './suspendedReopen.js';
|
|
11
12
|
import { refusedParkFromError, resumeRefusalFromError } from '../resumeRefusalCopy.js';
|
|
@@ -192,7 +193,7 @@ export function lateDecideOutcomeOf(reply, opts) {
|
|
|
192
193
|
const r = readDecisionRefusalAsk(e);
|
|
193
194
|
if (r.reading !== 'settled' && !(r.reading === 'not_settled' && r.gateMoved))
|
|
194
195
|
return LATE_UNKNOWN;
|
|
195
|
-
const probeWorthy = status === 404 || status === 410 || (
|
|
196
|
+
const probeWorthy = status === 404 || status === 410 || isNotFoundFailure(e) !== false;
|
|
196
197
|
return Object.freeze(probeWorthy ? { kind: 'settled-elsewhere', probeWorthy: true } : { kind: 'settled-elsewhere' });
|
|
197
198
|
}
|
|
198
199
|
catch {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { UiLanguage } from '../env/uiLanguage.js';
|
|
2
|
+
export declare function askEndingCauseClause(cause: string | undefined, lang?: UiLanguage): string | undefined;
|
|
2
3
|
export interface AskSettlementInput {
|
|
3
4
|
readonly cause?: string | undefined;
|
|
4
5
|
readonly toolName?: string | undefined;
|
|
5
6
|
readonly parked?: boolean | undefined;
|
|
6
7
|
}
|
|
7
|
-
export declare function askSettlementLine(settled: AskSettlementInput): string | undefined;
|
|
8
|
+
export declare function askSettlementLine(settled: AskSettlementInput, lang?: UiLanguage): string | undefined;
|
|
8
9
|
export type AskAcceptedFollow = 'following' | 'already-following' | 'not-following';
|
|
9
10
|
export interface AskAcceptedInput {
|
|
10
11
|
readonly decision?: string | undefined;
|
|
@@ -13,6 +14,15 @@ export interface AskAcceptedInput {
|
|
|
13
14
|
readonly follow?: AskAcceptedFollow | undefined;
|
|
14
15
|
readonly executed?: string | undefined;
|
|
15
16
|
}
|
|
16
|
-
export declare function askAcceptedLine(accepted: AskAcceptedInput): string;
|
|
17
|
+
export declare function askAcceptedLine(accepted: AskAcceptedInput, lang?: UiLanguage): string;
|
|
17
18
|
export type AskParkedCardForm = 'approval' | 'question' | 'queue_no_deadline';
|
|
18
|
-
export declare function askParkedCardNote(form?: string | undefined, toolName?: string | undefined): string;
|
|
19
|
+
export declare function askParkedCardNote(form?: string | undefined, toolName?: string | undefined, lang?: UiLanguage): string;
|
|
20
|
+
export interface AskHumanSettledInput {
|
|
21
|
+
readonly kind?: string | undefined;
|
|
22
|
+
readonly decision?: string | undefined;
|
|
23
|
+
readonly taskId?: string | undefined;
|
|
24
|
+
readonly late?: boolean | undefined;
|
|
25
|
+
readonly follow?: AskAcceptedFollow | undefined;
|
|
26
|
+
readonly executed?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare function askHumanSettlementLine(settled: AskHumanSettledInput, lang?: UiLanguage): string | undefined;
|
|
@@ -1,79 +1,99 @@
|
|
|
1
1
|
import { displayUntrusted, quoteUntrustedForSentence } from '../displayUntrusted.js';
|
|
2
|
+
import { msg, renderMessage } from '../i18n/translate.js';
|
|
2
3
|
import { guardedRead, readOwnDataValue } from '../ownKey.js';
|
|
3
|
-
const
|
|
4
|
-
routing_failure_fail_closed: '
|
|
5
|
-
run_cancelled: '
|
|
6
|
-
run_exited: '
|
|
7
|
-
batch_aborted: '
|
|
8
|
-
batch_sibling_withdrawn: '
|
|
9
|
-
batch_bound_elsewhere: '
|
|
10
|
-
adhoc_leg_no_durable_domain: '
|
|
11
|
-
orphan_ttl_exceeded:
|
|
12
|
-
crashed_before_park: '
|
|
13
|
-
shutdown_before_park: '
|
|
14
|
-
ttl_expired: '
|
|
15
|
-
broadcast_lost: '
|
|
16
|
-
stream_disconnected: '
|
|
17
|
-
undeliverable: '
|
|
4
|
+
const ENDING_CAUSE_KEYS = Object.freeze({
|
|
5
|
+
routing_failure_fail_closed: 'approval.settle.cause.routingFailureFailClosed',
|
|
6
|
+
run_cancelled: 'approval.settle.cause.runCancelled',
|
|
7
|
+
run_exited: 'approval.settle.cause.runExited',
|
|
8
|
+
batch_aborted: 'approval.settle.cause.batchAborted',
|
|
9
|
+
batch_sibling_withdrawn: 'approval.settle.cause.batchSiblingWithdrawn',
|
|
10
|
+
batch_bound_elsewhere: 'approval.settle.cause.batchBoundElsewhere',
|
|
11
|
+
adhoc_leg_no_durable_domain: 'approval.settle.cause.adhocLegNoDurableDomain',
|
|
12
|
+
orphan_ttl_exceeded: 'approval.settle.cause.orphanTtlExceeded',
|
|
13
|
+
crashed_before_park: 'approval.settle.cause.crashedBeforePark',
|
|
14
|
+
shutdown_before_park: 'approval.settle.cause.shutdownBeforePark',
|
|
15
|
+
ttl_expired: 'approval.settle.cause.ttlExpired',
|
|
16
|
+
broadcast_lost: 'approval.settle.cause.broadcastLost',
|
|
17
|
+
stream_disconnected: 'approval.settle.cause.streamDisconnected',
|
|
18
|
+
undeliverable: 'approval.settle.cause.undeliverable',
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
return typeof cause === 'string' && Object.hasOwn(
|
|
20
|
+
function endingCauseKeyOf(cause) {
|
|
21
|
+
return typeof cause === 'string' && Object.hasOwn(ENDING_CAUSE_KEYS, cause) ? ENDING_CAUSE_KEYS[cause] : undefined;
|
|
22
|
+
}
|
|
23
|
+
export function askEndingCauseClause(cause, lang) {
|
|
24
|
+
const key = endingCauseKeyOf(cause);
|
|
25
|
+
return key !== undefined ? renderMessage(msg(key), lang) : undefined;
|
|
21
26
|
}
|
|
22
27
|
function ownSlot(o, key) {
|
|
23
28
|
if (typeof o !== 'object' || o === null)
|
|
24
29
|
return undefined;
|
|
25
30
|
return guardedRead(() => readOwnDataValue(o, key));
|
|
26
31
|
}
|
|
27
|
-
function subjectOf(toolName, named,
|
|
32
|
+
function subjectOf(toolName, named, generic) {
|
|
28
33
|
const quoted = typeof toolName === 'string' ? guardedRead(() => quoteUntrustedForSentence(toolName, 80)) : undefined;
|
|
29
|
-
return quoted === undefined ?
|
|
34
|
+
return quoted === undefined ? msg(generic) : msg(named, { tool: quoted });
|
|
30
35
|
}
|
|
31
|
-
|
|
32
|
-
export function askSettlementLine(settled) {
|
|
36
|
+
export function askSettlementLine(settled, lang) {
|
|
33
37
|
if (ownSlot(settled, 'parked') === true)
|
|
34
38
|
return undefined;
|
|
35
39
|
const cause = ownSlot(settled, 'cause');
|
|
36
40
|
if (typeof cause !== 'string' || cause === '')
|
|
37
41
|
return undefined;
|
|
38
|
-
const subject = subjectOf(ownSlot(settled, 'toolName'),
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
return `${subject} ended on the engine without an answer${why}.${SETTLEMENT_TAIL}`;
|
|
42
|
+
const subject = subjectOf(ownSlot(settled, 'toolName'), 'approval.settle.subject.named', 'approval.settle.subject.generic');
|
|
43
|
+
const clauseKey = endingCauseKeyOf(cause);
|
|
44
|
+
return renderMessage(clauseKey !== undefined ? msg('approval.settle.endedKnown', { subject, clause: msg(clauseKey) }) : msg('approval.settle.endedUnknown', { subject }), lang);
|
|
42
45
|
}
|
|
43
46
|
const TASK_ID_MAX = 64;
|
|
44
|
-
const
|
|
45
|
-
allowed: '
|
|
46
|
-
denied: '
|
|
47
|
+
const EXECUTED_TAIL_KEYS = Object.freeze({
|
|
48
|
+
allowed: 'approval.settle.executed.allowed',
|
|
49
|
+
denied: 'approval.settle.executed.denied',
|
|
47
50
|
});
|
|
48
|
-
const
|
|
49
|
-
following: '
|
|
50
|
-
'already-following': '
|
|
51
|
+
const FOLLOW_CLAUSE_KEYS = Object.freeze({
|
|
52
|
+
following: 'approval.settle.follow.following',
|
|
53
|
+
'already-following': 'approval.settle.follow.alreadyFollowing',
|
|
51
54
|
});
|
|
52
|
-
export function askAcceptedLine(accepted) {
|
|
55
|
+
export function askAcceptedLine(accepted, lang) {
|
|
53
56
|
const decision = ownSlot(accepted, 'decision');
|
|
54
|
-
const what = decision === 'approve' ? 'approved' : decision === 'deny' ? 'denied' : 'answered';
|
|
55
|
-
const late = ownSlot(accepted, 'late') === false ? '' : '
|
|
57
|
+
const what = msg(decision === 'approve' ? 'approval.settle.what.approved' : decision === 'deny' ? 'approval.settle.what.denied' : 'approval.settle.what.answered');
|
|
58
|
+
const late = ownSlot(accepted, 'late') === false ? '' : msg('approval.settle.late');
|
|
56
59
|
const rawTask = ownSlot(accepted, 'taskId');
|
|
57
60
|
const shownTask = typeof rawTask === 'string' ? guardedRead(() => displayUntrusted(rawTask, { max: TASK_ID_MAX, blanks: true })) : undefined;
|
|
58
|
-
const where = shownTask === undefined || shownTask === '' ? '' :
|
|
61
|
+
const where = shownTask === undefined || shownTask === '' ? '' : msg('approval.settle.where', { task: shownTask });
|
|
59
62
|
const follow = ownSlot(accepted, 'follow');
|
|
60
63
|
const executed = ownSlot(accepted, 'executed');
|
|
61
|
-
const tail = executed === 'allowed' || executed === 'denied' ?
|
|
64
|
+
const tail = executed === 'allowed' || executed === 'denied' ? msg(EXECUTED_TAIL_KEYS[executed]) : '';
|
|
62
65
|
if (follow === 'following' || follow === 'already-following') {
|
|
63
|
-
return
|
|
66
|
+
return renderMessage(msg('approval.settle.acceptedFollowing', { what, late, where, follow: msg(FOLLOW_CLAUSE_KEYS[follow]), tail }), lang);
|
|
64
67
|
}
|
|
65
|
-
return (
|
|
66
|
-
`this screen is not following that run, so what it does next will not show up here by itself.${tail}`);
|
|
68
|
+
return renderMessage(msg('approval.settle.acceptedNotFollowing', { what, late, where, tail }), lang);
|
|
67
69
|
}
|
|
68
|
-
const
|
|
69
|
-
approval:
|
|
70
|
-
question:
|
|
71
|
-
queue_no_deadline:
|
|
70
|
+
const PARKED_CARD_NOTE_KEYS = Object.freeze({
|
|
71
|
+
approval: 'approval.settle.parkedNote.approval',
|
|
72
|
+
question: 'approval.settle.parkedNote.question',
|
|
73
|
+
queue_no_deadline: 'approval.settle.parkedNote.queueNoDeadline',
|
|
72
74
|
});
|
|
73
|
-
export function askParkedCardNote(form, toolName) {
|
|
75
|
+
export function askParkedCardNote(form, toolName, lang) {
|
|
74
76
|
const key = form === 'question' || form === 'queue_no_deadline' ? form : 'approval';
|
|
75
|
-
const template = PARKED_CARD_NOTES[key];
|
|
76
77
|
if (key !== 'queue_no_deadline')
|
|
77
|
-
return
|
|
78
|
-
return
|
|
78
|
+
return renderMessage(msg(PARKED_CARD_NOTE_KEYS[key]), lang);
|
|
79
|
+
return renderMessage(msg(PARKED_CARD_NOTE_KEYS[key], { subject: subjectOf(toolName, 'approval.settle.parkedSubject.named', 'approval.settle.parkedSubject.generic') }), lang);
|
|
80
|
+
}
|
|
81
|
+
export function askHumanSettlementLine(settled, lang) {
|
|
82
|
+
const kind = ownSlot(settled, 'kind');
|
|
83
|
+
if (kind === 'accepted-not-resolved')
|
|
84
|
+
return askAcceptedLine(settled, lang);
|
|
85
|
+
if (kind === 'expired-reaped')
|
|
86
|
+
return renderMessage(msg('approval.settleHuman.expiredReaped'), lang);
|
|
87
|
+
if (kind === 'settled-elsewhere')
|
|
88
|
+
return renderMessage(msg('approval.settleHuman.settledElsewhere'), lang);
|
|
89
|
+
if (kind !== 'resumed')
|
|
90
|
+
return undefined;
|
|
91
|
+
const decision = ownSlot(settled, 'decision');
|
|
92
|
+
const what = msg(decision === 'approve' ? 'approval.settle.what.approved' : decision === 'deny' ? 'approval.settle.what.denied' : 'approval.settle.what.answered');
|
|
93
|
+
const rawTask = ownSlot(settled, 'taskId');
|
|
94
|
+
const shownTask = typeof rawTask === 'string' ? guardedRead(() => displayUntrusted(rawTask, { max: TASK_ID_MAX, blanks: true })) : undefined;
|
|
95
|
+
const where = shownTask === undefined || shownTask === '' ? '' : msg('approval.settle.where', { task: shownTask });
|
|
96
|
+
const executed = ownSlot(settled, 'executed');
|
|
97
|
+
const tail = executed === 'allowed' || executed === 'denied' ? msg(EXECUTED_TAIL_KEYS[executed]) : '';
|
|
98
|
+
return renderMessage(msg(ownSlot(settled, 'late') === false ? 'approval.settleHuman.resumed' : 'approval.settleHuman.resumedLate', { what, where, tail }), lang);
|
|
79
99
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CoreModeArbitrationRow } from '../generated/engineFactTables.js';
|
|
2
2
|
import { CORE_ASK_FACES } from '../generated/engineAskFaceTables.js';
|
|
3
|
+
import type { UiLanguage } from '../env/uiLanguage.js';
|
|
3
4
|
export type AutomaticAnswerLane = 'mode_posture' | 'standing_rule' | 'permission_request_hook';
|
|
4
5
|
export type AutomaticAnswerAskFace = (typeof CORE_ASK_FACES)[number];
|
|
5
6
|
export interface AutomaticAnswerFacts {
|
|
@@ -22,6 +23,6 @@ export type AutomaticAnswerVerdict = {
|
|
|
22
23
|
export declare const MODE_ARBITRATION: Readonly<Record<"hook" | "write_protection" | "mode" | "target_unresolved" | "content_question" | "ancestor" | "dangerous_delete" | "unverifiable_delete" | "unverifiable_shell_text" | "transcript_write" | "org_rule" | "rule_unreadable" | "ask_rule" | "denial_limit_fallback" | "classifier_no_ruling" | "requires_user_interaction" | "operator_forced" | "shell_floor" | "probe" | "tool_marks_mcp" | "tool_marks_a2a" | "policy_rra" | "artifact_shared_read" | "unstated" | "ordinary", CoreModeArbitrationRow>>;
|
|
23
24
|
export declare function foldModeArbitrationRow(classes: Iterable<string>, askFace?: AutomaticAnswerAskFace): CoreModeArbitrationRow;
|
|
24
25
|
export declare function automaticAnswerVerdict(card: object | null | undefined, lane: AutomaticAnswerLane, facts?: AutomaticAnswerFacts | null): AutomaticAnswerVerdict;
|
|
25
|
-
export declare function mandatedApprovalDetailOf(card: object | null | undefined): string;
|
|
26
|
+
export declare function mandatedApprovalDetailOf(card: object | null | undefined, lang?: UiLanguage): string;
|
|
26
27
|
export type PermissionRequestHookScope = 'allow_or_deny' | 'deny_only' | 'skip';
|
|
27
28
|
export declare function permissionRequestHookScope(verdict: AutomaticAnswerVerdict | null | undefined): PermissionRequestHookScope;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CORE_MODE_ARBITRATION, CORE_MODE_RELEASE_REASONS } from '../generated/engineFactTables.js';
|
|
2
2
|
import { CORE_RELEASABLE_ASK_CLASSES_BY_FACE, CORE_SHELL_FACE_TOOL_NAMES } from '../generated/engineAskFaceTables.js';
|
|
3
3
|
import { mandatedApprovalDetail } from '../gateVocabulary.js';
|
|
4
|
+
import { msg, renderMessage } from '../i18n/translate.js';
|
|
4
5
|
import { readAskOrigin, readOwnNonEmptyString } from '../ownKey.js';
|
|
5
6
|
import { readAskClassPairState } from './askClassPair.js';
|
|
6
7
|
import { readRequiresRealApproval } from './approvalCardReading.js';
|
|
@@ -179,26 +180,25 @@ export function automaticAnswerVerdict(card, lane, facts) {
|
|
|
179
180
|
return UNKNOWN.card_unreadable;
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
|
-
export function mandatedApprovalDetailOf(card) {
|
|
183
|
+
export function mandatedApprovalDetailOf(card, lang) {
|
|
183
184
|
try {
|
|
184
185
|
if (typeof card !== 'object' || card === null)
|
|
185
|
-
return mandatedApprovalDetail();
|
|
186
|
+
return mandatedApprovalDetail(lang);
|
|
186
187
|
const pair = readAskClassPairState(card);
|
|
187
188
|
if (pair.state !== 'pair')
|
|
188
|
-
return mandatedApprovalDetail();
|
|
189
|
+
return mandatedApprovalDetail(lang);
|
|
189
190
|
const classes = pair.classes;
|
|
190
191
|
if (classes.some((c) => !Object.hasOwn(TABLE, c)))
|
|
191
|
-
return mandatedApprovalDetail();
|
|
192
|
+
return mandatedApprovalDetail(lang);
|
|
192
193
|
const row = foldModeArbitrationRow(classes);
|
|
193
194
|
if (row.classifierEligible || row.sandboxAdmission)
|
|
194
|
-
return mandatedApprovalDetail();
|
|
195
|
-
return
|
|
195
|
+
return mandatedApprovalDetail(lang);
|
|
196
|
+
return renderMessage(msg('approval.mandate.noAutomaticCheck'), lang);
|
|
196
197
|
}
|
|
197
198
|
catch {
|
|
198
|
-
return mandatedApprovalDetail();
|
|
199
|
+
return mandatedApprovalDetail(lang);
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
|
-
const MANDATED_NO_AUTOMATIC_CHECK_DETAIL = 'no saved allow rule and no remembered answer can retire this question, and no automatic check answers it; each call is settled on its own, by you here, and an answer covers only that call';
|
|
202
202
|
export function permissionRequestHookScope(verdict) {
|
|
203
203
|
try {
|
|
204
204
|
const kind = typeof verdict === 'object' && verdict !== null ? verdict.kind : undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { UiLanguage } from '../env/uiLanguage.js';
|
|
1
2
|
import type { CrashConvergedProjection, CrashConvergedRowReading } from './crashConverged.js';
|
|
2
3
|
export declare const NEEDS_HUMAN_REASON_ORDER: readonly ["approved_then_interrupted", "pending_unsafe", "contradictory", "unstable_row"];
|
|
3
|
-
export declare function crashConvergedNeedsHumanSentence(reason: string | undefined, n: number, total: number): string | undefined;
|
|
4
|
-
export declare function crashConvergedNotice(projection: CrashConvergedProjection | undefined): string | undefined;
|
|
5
|
-
export declare function crashConvergedRowSentence(projection: CrashConvergedProjection | undefined, row: Pick<CrashConvergedRowReading, 'approvalId'
|
|
6
|
-
export declare function crashConvergedCauseSentence(cause: string | undefined): string | undefined;
|
|
4
|
+
export declare function crashConvergedNeedsHumanSentence(reason: string | undefined, n: number, total: number, lang?: UiLanguage): string | undefined;
|
|
5
|
+
export declare function crashConvergedNotice(projection: CrashConvergedProjection | undefined, lang?: UiLanguage): string | undefined;
|
|
6
|
+
export declare function crashConvergedRowSentence(projection: CrashConvergedProjection | undefined, row: Pick<CrashConvergedRowReading, 'approvalId'>, lang?: UiLanguage): string | undefined;
|
|
7
|
+
export declare function crashConvergedCauseSentence(cause: string | undefined, lang?: UiLanguage): string | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { msg, renderMessage } from '../i18n/translate.js';
|
|
1
2
|
import { askEndingCauseClause } from './askSettlementLine.js';
|
|
2
3
|
import { crashConvergedRowInProjection, isCrashConvergedCause, readCrashConvergedNoticeFacts } from './crashConverged.js';
|
|
3
4
|
export const NEEDS_HUMAN_REASON_ORDER = Object.freeze(['approved_then_interrupted', 'pending_unsafe', 'contradictory', 'unstable_row']);
|
|
@@ -7,53 +8,40 @@ const _orderHasNoDuplicate = true;
|
|
|
7
8
|
void _orderCoversReasons;
|
|
8
9
|
void _orderInsideReasons;
|
|
9
10
|
void _orderHasNoDuplicate;
|
|
10
|
-
const RECORDED = 'based on what was recorded';
|
|
11
|
-
const NO_AUTO_RERUN = 'sema has not re-run anything';
|
|
12
11
|
const plural = (n, one, many) => (n === 1 ? one : many);
|
|
13
12
|
const NEEDS_HUMAN_CLAUSES = Object.freeze({
|
|
14
|
-
approved_then_interrupted: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
pending_unsafe: {
|
|
19
|
-
one: `had not started, ${RECORDED}, but the engine did not mark it as safe to re-run`,
|
|
20
|
-
many: `had not started, ${RECORDED}, but the engine did not mark them as safe to re-run`,
|
|
21
|
-
},
|
|
22
|
-
contradictory: { one: 'has a contradictory record', many: 'have contradictory records' },
|
|
23
|
-
unstable_row: {
|
|
24
|
-
one: 'has a record that read differently each time it was read',
|
|
25
|
-
many: 'have records that read differently each time they were read',
|
|
26
|
-
},
|
|
13
|
+
approved_then_interrupted: { one: 'session.crashConverged.reason.approvedThenInterrupted.one', many: 'session.crashConverged.reason.approvedThenInterrupted.many' },
|
|
14
|
+
pending_unsafe: { one: 'session.crashConverged.reason.pendingUnsafe.one', many: 'session.crashConverged.reason.pendingUnsafe.many' },
|
|
15
|
+
contradictory: { one: 'session.crashConverged.reason.contradictory.one', many: 'session.crashConverged.reason.contradictory.many' },
|
|
16
|
+
unstable_row: { one: 'session.crashConverged.reason.unstableRow.one', many: 'session.crashConverged.reason.unstableRow.many' },
|
|
27
17
|
});
|
|
28
|
-
const FALLBACK_CLAUSE = Object.freeze({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
const RESUME_SAFE_CLAUSE = `had not started, ${RECORDED}, and can be re-run`;
|
|
33
|
-
const countedClause = (clause, n, total) => `${n} of ${total} ${n === 1 ? clause.one : clause.many}`;
|
|
18
|
+
const FALLBACK_CLAUSE = Object.freeze({ one: 'session.crashConverged.fallback.one', many: 'session.crashConverged.fallback.many' });
|
|
19
|
+
const RESUME_SAFE_CLAUSE = 'session.crashConverged.resumeSafe';
|
|
20
|
+
const countedClause = (clause, n, total, lang) => renderMessage(msg('session.crashConverged.counted', { n, total, clause: msg(n === 1 ? clause.one : clause.many) }), lang);
|
|
34
21
|
const isNeedsHumanReason = (v) => typeof v === 'string' && Object.hasOwn(NEEDS_HUMAN_CLAUSES, v);
|
|
35
|
-
export function crashConvergedNeedsHumanSentence(reason, n, total) {
|
|
22
|
+
export function crashConvergedNeedsHumanSentence(reason, n, total, lang) {
|
|
36
23
|
if (!isNeedsHumanReason(reason))
|
|
37
24
|
return undefined;
|
|
38
25
|
if (typeof n !== 'number' || !Number.isSafeInteger(n) || n < 1)
|
|
39
26
|
return undefined;
|
|
40
27
|
if (typeof total !== 'number' || !Number.isSafeInteger(total) || total < n)
|
|
41
28
|
return undefined;
|
|
42
|
-
return countedClause(NEEDS_HUMAN_CLAUSES[reason], n, total);
|
|
29
|
+
return countedClause(NEEDS_HUMAN_CLAUSES[reason], n, total, lang);
|
|
43
30
|
}
|
|
44
|
-
function needsHumanClauses(reasons, total) {
|
|
31
|
+
function needsHumanClauses(reasons, total, lang) {
|
|
45
32
|
const clauses = [];
|
|
46
33
|
for (const reason of NEEDS_HUMAN_REASON_ORDER) {
|
|
47
34
|
const n = reasons.filter((r) => r === reason).length;
|
|
48
35
|
if (n > 0)
|
|
49
|
-
clauses.push(countedClause(NEEDS_HUMAN_CLAUSES[reason], n, total));
|
|
36
|
+
clauses.push(countedClause(NEEDS_HUMAN_CLAUSES[reason], n, total, lang));
|
|
50
37
|
}
|
|
51
38
|
const fallback = reasons.filter((r) => !isNeedsHumanReason(r)).length;
|
|
52
39
|
if (fallback > 0)
|
|
53
|
-
clauses.push(countedClause(FALLBACK_CLAUSE, fallback, total));
|
|
54
|
-
|
|
40
|
+
clauses.push(countedClause(FALLBACK_CLAUSE, fallback, total, lang));
|
|
41
|
+
const joined = clauses.join(renderMessage(msg('session.crashConverged.clauseJoin'), lang));
|
|
42
|
+
return renderMessage(msg(plural(reasons.length, 'session.crashConverged.needsHumanBody.one', 'session.crashConverged.needsHumanBody.many'), { clauses: joined }), lang);
|
|
55
43
|
}
|
|
56
|
-
export function crashConvergedNotice(projection) {
|
|
44
|
+
export function crashConvergedNotice(projection, lang) {
|
|
57
45
|
const facts = readCrashConvergedNoticeFacts(projection);
|
|
58
46
|
if (facts === undefined)
|
|
59
47
|
return undefined;
|
|
@@ -61,16 +49,15 @@ export function crashConvergedNotice(projection) {
|
|
|
61
49
|
if (total === 0 && dropped === 0)
|
|
62
50
|
return undefined;
|
|
63
51
|
if (total === 0) {
|
|
64
|
-
return
|
|
52
|
+
return renderMessage(msg(plural(dropped, 'session.crashConverged.droppedOnly.one', 'session.crashConverged.droppedOnly.many'), { count: dropped }), lang);
|
|
65
53
|
}
|
|
66
|
-
const recordedAs = causes !== undefined && causes.length > 0 ?
|
|
67
|
-
const head =
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
return `${head}; ${body}. ${NO_AUTO_RERUN}.${droppedClause}`;
|
|
54
|
+
const recordedAs = causes !== undefined && causes.length > 0 ? msg('session.crashConverged.recordedAs', { causes: causes.join(', ') }) : '';
|
|
55
|
+
const head = renderMessage(msg(plural(total, 'session.crashConverged.head.one', 'session.crashConverged.head.many'), { total, recorded: recordedAs }), lang);
|
|
56
|
+
const body = needsHumanReasons.length > 0 ? needsHumanClauses(needsHumanReasons, total, lang) : renderMessage(msg(plural(total, 'session.crashConverged.rerunnable.one', 'session.crashConverged.rerunnable.many')), lang);
|
|
57
|
+
const droppedClause = dropped > 0 ? msg(plural(dropped, 'session.crashConverged.droppedTail.one', 'session.crashConverged.droppedTail.many'), { count: dropped }) : '';
|
|
58
|
+
return renderMessage(msg('session.crashConverged.line', { head, body, dropped: droppedClause }), lang);
|
|
72
59
|
}
|
|
73
|
-
export function crashConvergedRowSentence(projection, row) {
|
|
60
|
+
export function crashConvergedRowSentence(projection, row, lang) {
|
|
74
61
|
const hit = crashConvergedRowInProjection(projection, row);
|
|
75
62
|
if (hit === undefined)
|
|
76
63
|
return undefined;
|
|
@@ -82,13 +69,13 @@ export function crashConvergedRowSentence(projection, row) {
|
|
|
82
69
|
return undefined;
|
|
83
70
|
}
|
|
84
71
|
if (hit.bucket === 'resumeSafe')
|
|
85
|
-
return descriptor === undefined ? RESUME_SAFE_CLAUSE : undefined;
|
|
72
|
+
return descriptor === undefined ? renderMessage(msg(RESUME_SAFE_CLAUSE), lang) : undefined;
|
|
86
73
|
const reason = descriptor !== undefined && Object.hasOwn(descriptor, 'value') ? descriptor.value : undefined;
|
|
87
|
-
return (isNeedsHumanReason(reason) ? NEEDS_HUMAN_CLAUSES[reason] : FALLBACK_CLAUSE).one;
|
|
74
|
+
return renderMessage(msg((isNeedsHumanReason(reason) ? NEEDS_HUMAN_CLAUSES[reason] : FALLBACK_CLAUSE).one), lang);
|
|
88
75
|
}
|
|
89
|
-
export function crashConvergedCauseSentence(cause) {
|
|
76
|
+
export function crashConvergedCauseSentence(cause, lang) {
|
|
90
77
|
if (typeof cause !== 'string' || cause === '')
|
|
91
78
|
return undefined;
|
|
92
|
-
const clause = isCrashConvergedCause(cause) ? askEndingCauseClause(cause) : undefined;
|
|
93
|
-
return clause === undefined ? '
|
|
79
|
+
const clause = isCrashConvergedCause(cause) ? askEndingCauseClause(cause, lang) : undefined;
|
|
80
|
+
return renderMessage(clause === undefined ? msg('session.crashConverged.cause.neutral') : msg('session.crashConverged.cause.withClause', { clause }), lang);
|
|
94
81
|
}
|
package/dist/hitl/frameRouter.js
CHANGED
|
@@ -8,11 +8,11 @@ import { readRunTerminal, runTerminalCode, runTerminalGateKind, runTerminalGateT
|
|
|
8
8
|
import { parkHeldCallIdOf } from '../engineRowRef.js';
|
|
9
9
|
import { inheritFrameBinding } from '../frameBinding.js';
|
|
10
10
|
import { surfaceForCurrentSession, surfaceReplayedApprovalListUnreadable } from './hitlHostSurface.js';
|
|
11
|
-
import { liveCardHoldOf, noteEngineClosedApproval,
|
|
11
|
+
import { liveCardHoldOf, noteEngineClosedApproval, settleEngineClosedApproval } from './approvalHolds.js';
|
|
12
12
|
import { approvalCompleteParked } from './approvalCompleteParked.js';
|
|
13
13
|
import { liveFrameCallKey } from './gateIdentity.js';
|
|
14
14
|
import { SEMA_DENIAL_KIND_KEY, hasLedgerPositionKey } from './gateLedger.js';
|
|
15
|
-
import { replayedApprovalDisposition, settledApprovalDisposition } from './replayedApproval.js';
|
|
15
|
+
import { replayedApprovalClosesCardFrame, replayedApprovalDisposition, settledApprovalDisposition } from './replayedApproval.js';
|
|
16
16
|
import { settleWithinDeadline } from '../abortableSleep.js';
|
|
17
17
|
import { ccToolDenialKindForSettledBy } from '../gateVocabulary.js';
|
|
18
18
|
import { REJECT_MESSAGE } from '../adapt/wireShapes.js';
|
|
@@ -285,12 +285,9 @@ const TOOL_END_ARMS = [
|
|
|
285
285
|
async function routeToolApprovalFrame(ev, ctx) {
|
|
286
286
|
const { led, deps } = ctx;
|
|
287
287
|
if (ev.type === 'tool_approval_complete') {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
noteEngineClosedApproval(id, parked);
|
|
292
|
-
if (typeof id === 'string' && id !== '' && supersedeLiveCard(liveFrameCallKey(id), parked)) {
|
|
293
|
-
hostLog('debug', `liveHitlAskWire: tool_approval_complete for ${id} arrived while its card was waiting — card withdrawn (nothing will be sent from it)`);
|
|
288
|
+
if (settleEngineClosedApproval(ev, approvalCompleteParked(ev))) {
|
|
289
|
+
const id = ev.approvalId;
|
|
290
|
+
hostLog('debug', `liveHitlAskWire: tool_approval_complete for ${String(id)} arrived while its card was waiting — card withdrawn (nothing will be sent from it)`);
|
|
294
291
|
}
|
|
295
292
|
return { kind: 'skip' };
|
|
296
293
|
}
|
|
@@ -307,6 +304,8 @@ async function routeToolApprovalFrame(ev, ctx) {
|
|
|
307
304
|
: `liveHitlAskWire: tool_approval frame ${ev.approvalId} read back from the run event log is ${disposition.kind}` +
|
|
308
305
|
`${disposition.kind === 'unknown' ? ` (${disposition.why})` : disposition.cause !== undefined ? ` (${disposition.cause})` : ''}` +
|
|
309
306
|
' — not raised as a question, no decision sent');
|
|
307
|
+
if (settledHere === undefined && replayedApprovalClosesCardFrame(disposition))
|
|
308
|
+
noteEngineClosedApproval(ev.approvalId, false);
|
|
310
309
|
if (disposition.kind === 'unknown' && ctx.signal?.aborted !== true)
|
|
311
310
|
surfaceReplayedApprovalListUnreadable();
|
|
312
311
|
if (deps.onReplayedApproval !== undefined) {
|
|
@@ -3,6 +3,7 @@ import type { PermissionResult } from '@sema-agent/agent-types';
|
|
|
3
3
|
import type { ApprovalsListEnvelope } from './crashConverged.js';
|
|
4
4
|
import { type SuspendedReopenReading } from './suspendedReopen.js';
|
|
5
5
|
export declare const DEFAULT_DENY_REASON = "The user rejected this tool use";
|
|
6
|
+
export declare const MAX_DENY_REASON_CHARS = 4096;
|
|
6
7
|
export declare function denyReasonForWire(reason: string | undefined, tag: string): string | undefined;
|
|
7
8
|
export interface HitlPermissionDecisionLike {
|
|
8
9
|
behavior: 'allow' | 'ask' | 'deny';
|