@sema-agent/client-core 0.107.0 → 0.109.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 +239 -0
- package/README.md +54 -36
- package/dist/adapt/arms.js +23 -8
- package/dist/adapt/textStream.d.ts +2 -0
- package/dist/adapt/textStream.js +37 -16
- package/dist/adapter/activeRunSelfHeal.d.ts +2 -0
- package/dist/adapter/activeRunSelfHeal.js +21 -4
- package/dist/adapter/downstream/eventToSdkMessage.js +2 -1
- package/dist/agentSession/engineAgentRegistryRead.js +2 -0
- package/dist/bashExitReading.d.ts +12 -0
- package/dist/bashExitReading.js +44 -0
- package/dist/checkpointRowVerdict.d.ts +6 -1
- package/dist/checkpointRowVerdict.js +30 -2
- package/dist/cloudConfigWireCaps.d.ts +10 -0
- package/dist/cloudConfigWireCaps.js +33 -0
- package/dist/compensations.js +1 -1
- package/dist/coreValuePorts.d.ts +17 -1
- package/dist/coreValuePorts.js +5 -0
- package/dist/decideReceipt.js +2 -1
- package/dist/engineAgentAbsence.d.ts +2 -0
- package/dist/engineAgentAbsence.js +28 -0
- package/dist/engineErrorCodes.d.ts +9 -0
- package/dist/engineErrorCodes.js +9 -0
- package/dist/engineHealthFacts.d.ts +17 -0
- package/dist/engineHealthFacts.js +42 -3
- package/dist/engineNoticeCodes.d.ts +147 -1
- package/dist/engineNoticeCodes.js +694 -57
- package/dist/engineTargetSeat.js +1 -0
- package/dist/errorSupplementRoles.js +6 -1
- package/dist/eventLeg.js +1 -1
- package/dist/executionLaneWords.js +2 -1
- package/dist/fleetTaskDesc.js +3 -3
- package/dist/gateOutcome.d.ts +10 -1
- package/dist/gateOutcome.js +48 -1
- package/dist/generated/engineFactTables.d.ts +2 -0
- package/dist/generated/engineFactTables.js +11 -0
- package/dist/generated/engineNoticeTables.js +6 -0
- package/dist/generated/settingsSchemaFns.d.ts +4 -2
- package/dist/generated/settingsSchemaFns.js +9 -3
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.js +9 -18
- package/dist/generated/settingsSchemaReservedMemberName.d.ts +1 -0
- package/dist/generated/settingsSchemaReservedMemberName.js +7 -0
- package/dist/generated/settingsSchemaTables.d.ts +2 -0
- package/dist/generated/settingsSchemaTables.js +10 -0
- package/dist/generated/settingsSchemaWireName.d.ts +1 -0
- package/dist/generated/settingsSchemaWireName.js +8 -0
- package/dist/headlessReconnectWire.js +12 -7
- package/dist/hitl/approvalAskers.d.ts +13 -0
- package/dist/hitl/approvalAskers.js +79 -0
- package/dist/hitl/approvalCardReasons.js +22 -4
- package/dist/hitl/approvalRequestFrameReading.d.ts +14 -0
- package/dist/hitl/approvalRequestFrameReading.js +79 -0
- package/dist/hitl/approvalResolution.d.ts +3 -0
- package/dist/hitl/approvalResolution.js +22 -4
- package/dist/hitl/approvalsFeed.js +4 -13
- package/dist/hitl/askParkRowRouting.js +10 -3
- package/dist/hitl/automaticAnswerVerdict.d.ts +5 -2
- package/dist/hitl/automaticAnswerVerdict.js +16 -2
- package/dist/hitl/decisionConflict.d.ts +2 -1
- package/dist/hitl/decisionConflict.js +4 -1
- package/dist/hitl/decisionRefusal.d.ts +1 -0
- package/dist/hitl/decisionRefusal.js +5 -2
- package/dist/hitl/decisionSend.js +2 -6
- package/dist/hitl/frameRouter.d.ts +3 -2
- package/dist/hitl/frameRouter.js +37 -7
- package/dist/hitl/gateLedger.d.ts +2 -0
- package/dist/hitl/gateLedger.js +3 -1
- package/dist/hitl/hitlBridge.d.ts +4 -0
- package/dist/hitl/hitlBridge.js +11 -8
- package/dist/hitl/livePendingAsk.js +17 -16
- package/dist/hitl/localAllowRule.js +2 -1
- package/dist/hitl/noAllowCause.d.ts +1 -1
- package/dist/hitl/noAllowCause.js +4 -2
- package/dist/hitl/parkExpiryJudgements.js +26 -1
- package/dist/hitl/parkOwnership.d.ts +2 -0
- package/dist/hitl/parkOwnership.js +48 -8
- package/dist/hitl/parkResolver.js +39 -30
- package/dist/hitl/parkRowBirthWait.d.ts +2 -0
- package/dist/hitl/parkRowBirthWait.js +8 -1
- package/dist/hitl/parkedUnresumable.d.ts +13 -0
- package/dist/hitl/parkedUnresumable.js +80 -0
- package/dist/hitl/permissionRuleScope.d.ts +4 -0
- package/dist/hitl/permissionRuleScope.js +31 -0
- package/dist/hitl/persistedRulesWire.d.ts +7 -1
- package/dist/hitl/persistedRulesWire.js +25 -8
- package/dist/hitl/planReviewWire.js +12 -16
- package/dist/hitl/policyDenyCause.d.ts +3 -0
- package/dist/hitl/policyDenyCause.js +16 -0
- package/dist/hitl/sessionAllowRoute.js +5 -4
- package/dist/hitl/sessionPolicyDeliverable.js +1 -1
- package/dist/hitl/standingRows.d.ts +1 -5
- package/dist/hitl/standingRows.js +15 -14
- package/dist/hitl/toolApprovalWire.d.ts +16 -4
- package/dist/hitl/toolApprovalWire.js +57 -17
- package/dist/hooksReaderGenerations.d.ts +1 -0
- package/dist/hooksReaderGenerations.js +12 -0
- package/dist/hooksWireCaps.js +12 -7
- package/dist/hostSettingsSource.js +2 -0
- package/dist/i18n/messages.en.d.ts +206 -1
- package/dist/i18n/messages.en.js +209 -4
- package/dist/i18n/messages.zh.js +214 -4
- package/dist/index.d.ts +35 -8
- package/dist/index.js +20 -5
- package/dist/liveModelCatalog.d.ts +4 -2
- package/dist/liveModelCatalog.js +164 -26
- package/dist/localEngineJudge.d.ts +75 -0
- package/dist/localEngineJudge.js +242 -0
- package/dist/localEngineOccupancy.d.ts +88 -0
- package/dist/localEngineOccupancy.js +269 -0
- package/dist/localEngineSeatReading.d.ts +29 -0
- package/dist/localEngineSeatReading.js +294 -0
- package/dist/localEngineSpawn.d.ts +113 -0
- package/dist/localEngineSpawn.js +486 -0
- package/dist/localEngineStep.d.ts +286 -0
- package/dist/localEngineStep.js +1086 -0
- package/dist/localEngineStopLadder.d.ts +29 -0
- package/dist/localEngineStopLadder.js +139 -0
- package/dist/localEngineSwapCard.d.ts +43 -0
- package/dist/localEngineSwapCard.js +205 -0
- package/dist/localEngineTiming.d.ts +8 -0
- package/dist/localEngineTiming.js +8 -0
- package/dist/mcpReconnect.js +12 -5
- package/dist/mcpWireCaps.js +2 -2
- package/dist/memoryEntriesWire.d.ts +1 -1
- package/dist/memoryEntriesWire.js +5 -0
- package/dist/model/catalogDefault.d.ts +25 -0
- package/dist/model/catalogDefault.js +44 -0
- package/dist/noticePresentation.d.ts +2 -0
- package/dist/noticePresentation.js +79 -1
- package/dist/ownKey.d.ts +10 -0
- package/dist/ownKey.js +15 -1
- package/dist/permissionWireCaps.d.ts +1 -0
- package/dist/permissionWireCaps.js +11 -0
- package/dist/pluginHooksWire.d.ts +5 -3
- package/dist/pluginHooksWire.js +116 -7
- package/dist/queuedDelivery.d.ts +1 -0
- package/dist/queuedDelivery.js +12 -0
- package/dist/resultFrameKeys.js +4 -2
- package/dist/resumeRefusalCopy.js +15 -8
- package/dist/ruleReadings.js +1 -1
- package/dist/runPermissionModeSwitch.d.ts +2 -1
- package/dist/runPermissionModeSwitch.js +16 -6
- package/dist/seam.d.ts +13 -2
- package/dist/seam.js +8 -1
- package/dist/seatContract.d.ts +103 -12
- package/dist/seatContract.js +344 -14
- package/dist/sessionBackground.js +2 -0
- package/dist/sessionEngine.d.ts +2 -1
- package/dist/sessionEngine.js +5 -0
- package/dist/settingsHooksSalvage.d.ts +5 -0
- package/dist/settingsHooksSalvage.js +54 -0
- package/dist/subagentContentStore.d.ts +12 -0
- package/dist/subagentContentStore.js +73 -12
- package/dist/supportFloor.js +2 -0
- package/dist/taskNotificationAdmission.d.ts +19 -0
- package/dist/taskNotificationAdmission.js +84 -0
- package/dist/toolResult.js +20 -6
- package/dist/webSearchWireCaps.js +9 -4
- package/dist/wireFailureShape.d.ts +20 -0
- package/dist/wireFailureShape.js +37 -6
- package/dist/wireRefusalCopy.d.ts +23 -2
- package/dist/wireRefusalCopy.js +93 -4
- package/docs/INTEGRATION-CLIENTS.md +1959 -15
- package/package.json +4 -4
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AUTO_MODE_UNAVAILABLE_CAUSES } from './autoModeUnavailable.js';
|
|
2
2
|
import { displayUntrusted } from './displayUntrusted.js';
|
|
3
3
|
import { CORE_ENGINE_NOTICE_CODES, CORE_MCP_INJECTION_DROP_REASONS, CORE_NOTICE_AUDIENCE, CORE_USER_INPUT_UNDRAINED_FAMILIES, } from './generated/engineNoticeTables.js';
|
|
4
|
-
import { CORE_APPROVAL_REMEDY_KINDS, CORE_ASK_UNRESOLVABLE_CAUSES, CORE_DURABLE_MANDATE_SOURCES, CORE_PERMISSION_MODE_FOLD_REASONS, } from './generated/engineFactTables.js';
|
|
4
|
+
import { CORE_APPROVAL_REMEDY_KINDS, CORE_ASK_UNRESOLVABLE_CAUSES, CORE_DISCARDED_DELIVERY_PATHS, CORE_DURABLE_MANDATE_SOURCES, CORE_PERMISSION_MODE_FOLD_REASONS, } from './generated/engineFactTables.js';
|
|
5
5
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
6
6
|
import { ownDataField, readOwnDataValue } from './ownKey.js';
|
|
7
|
+
import { inValueOf, slotReadOf } from './wireFailureShape.js';
|
|
7
8
|
export const ENGINE_NOTICE_CODES = CORE_ENGINE_NOTICE_CODES;
|
|
8
9
|
const CATALOG = new Set(ENGINE_NOTICE_CODES);
|
|
9
10
|
function audienceRow(table, code) {
|
|
@@ -25,9 +26,9 @@ export function readMcpInjectionDrop(notice) {
|
|
|
25
26
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
26
27
|
return undefined;
|
|
27
28
|
const n = notice;
|
|
28
|
-
if (
|
|
29
|
+
if (envelopeSeat(n, 'code') !== 'mcp.injection_dropped')
|
|
29
30
|
return undefined;
|
|
30
|
-
const d =
|
|
31
|
+
const d = envelopeSeat(n, 'detail');
|
|
31
32
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
32
33
|
return undefined;
|
|
33
34
|
const o = d;
|
|
@@ -43,6 +44,46 @@ export function readMcpInjectionDrop(notice) {
|
|
|
43
44
|
const field = typeof fieldIn === 'string' && fieldIn.length > 0 ? fieldIn : undefined;
|
|
44
45
|
return { sessionId, server, reason, ...(field !== undefined ? { field } : {}) };
|
|
45
46
|
}
|
|
47
|
+
const LEG_SELF = Object.freeze({ kind: 'self' });
|
|
48
|
+
const LEG_UNREADABLE = Object.freeze({ kind: 'unreadable' });
|
|
49
|
+
function readNoticeLeg(detail) {
|
|
50
|
+
try {
|
|
51
|
+
const source = slotReadOf(detail, 'sourceSessionId');
|
|
52
|
+
const agent = slotReadOf(detail, 'agentId');
|
|
53
|
+
if (source.presence === 'absent')
|
|
54
|
+
return agent.presence === 'absent' ? LEG_SELF : LEG_UNREADABLE;
|
|
55
|
+
if (source.presence !== 'present' || typeof source.value !== 'string' || source.value.length === 0)
|
|
56
|
+
return LEG_UNREADABLE;
|
|
57
|
+
const agentId = agent.presence === 'present' && typeof agent.value === 'string' && agent.value.length > 0 ? agent.value : undefined;
|
|
58
|
+
return Object.freeze({ kind: 'delegated', sourceSessionId: source.value, ...(agentId !== undefined ? { agentId } : {}) });
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return LEG_UNREADABLE;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function noticeCallSessionOf(facts) {
|
|
65
|
+
const str = (o, key) => {
|
|
66
|
+
const s = slotReadOf(o, key);
|
|
67
|
+
return s.presence === 'present' && typeof s.value === 'string' && s.value.length > 0 ? s.value : undefined;
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
if (typeof facts !== 'object' || facts === null)
|
|
71
|
+
return undefined;
|
|
72
|
+
const legSlot = slotReadOf(facts, 'leg');
|
|
73
|
+
const leg = legSlot.presence === 'present' ? legSlot.value : undefined;
|
|
74
|
+
if (typeof leg !== 'object' || leg === null)
|
|
75
|
+
return undefined;
|
|
76
|
+
const kind = str(leg, 'kind');
|
|
77
|
+
if (kind === 'delegated')
|
|
78
|
+
return str(leg, 'sourceSessionId');
|
|
79
|
+
if (kind !== 'self')
|
|
80
|
+
return undefined;
|
|
81
|
+
return str(facts, 'sessionId');
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
46
87
|
export const ASK_UNRESOLVABLE_CAUSES = CORE_ASK_UNRESOLVABLE_CAUSES;
|
|
47
88
|
const ASK_UNRESOLVABLE_CAUSE_SET = new Set(ASK_UNRESOLVABLE_CAUSES);
|
|
48
89
|
function optionalSeat(o, key) {
|
|
@@ -111,12 +152,15 @@ export function askUnresolvableRemedyContent(remedy, lang) {
|
|
|
111
152
|
return renderMessage(msg('notice.askUnresolvable.remedy.permissionMode', { mode: displayUntrusted(r.value, { max: 64 }) }), lang);
|
|
112
153
|
}
|
|
113
154
|
export function readAskUnresolvable(notice) {
|
|
155
|
+
return guardedRead(notice, readAskUnresolvableOf);
|
|
156
|
+
}
|
|
157
|
+
function readAskUnresolvableOf(notice) {
|
|
114
158
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
115
159
|
return undefined;
|
|
116
160
|
const n = notice;
|
|
117
|
-
if (
|
|
161
|
+
if (envelopeSeat(n, 'code') !== 'delegation.ask_unresolvable')
|
|
118
162
|
return undefined;
|
|
119
|
-
const d =
|
|
163
|
+
const d = envelopeSeat(n, 'detail');
|
|
120
164
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
121
165
|
return undefined;
|
|
122
166
|
const o = d;
|
|
@@ -131,7 +175,7 @@ export function readAskUnresolvable(notice) {
|
|
|
131
175
|
if (sessionId === undefined || toolName === undefined || toolCallId === undefined || cause === undefined) {
|
|
132
176
|
return undefined;
|
|
133
177
|
}
|
|
134
|
-
const parkIn = o
|
|
178
|
+
const parkIn = optionalSeat(o, 'parkLaneExisted');
|
|
135
179
|
const remedyIn = optionalSeat(o, 'remedy');
|
|
136
180
|
let remedies;
|
|
137
181
|
try {
|
|
@@ -148,6 +192,7 @@ export function readAskUnresolvable(notice) {
|
|
|
148
192
|
...(typeof parkIn === 'boolean' ? { parkLaneExisted: parkIn } : {}),
|
|
149
193
|
...(typeof remedyIn === 'string' && remedyIn.length > 0 ? { remedy: remedyIn } : {}),
|
|
150
194
|
...(remedies !== undefined ? { remedies } : {}),
|
|
195
|
+
leg: readNoticeLeg(o),
|
|
151
196
|
};
|
|
152
197
|
}
|
|
153
198
|
export const DURABLE_MANDATE_SOURCES = CORE_DURABLE_MANDATE_SOURCES;
|
|
@@ -156,9 +201,9 @@ export function readDurableGateUnavailable(notice) {
|
|
|
156
201
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
157
202
|
return undefined;
|
|
158
203
|
const n = notice;
|
|
159
|
-
if (
|
|
204
|
+
if (envelopeSeat(n, 'code') !== 'config.durable_gate_unavailable')
|
|
160
205
|
return undefined;
|
|
161
|
-
const d =
|
|
206
|
+
const d = envelopeSeat(n, 'detail');
|
|
162
207
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
163
208
|
return undefined;
|
|
164
209
|
const o = d;
|
|
@@ -201,9 +246,9 @@ export function readSkillsListingTruncated(notice) {
|
|
|
201
246
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
202
247
|
return undefined;
|
|
203
248
|
const n = notice;
|
|
204
|
-
if (
|
|
249
|
+
if (envelopeSeat(n, 'code') !== 'skills.listing_truncated')
|
|
205
250
|
return undefined;
|
|
206
|
-
const d =
|
|
251
|
+
const d = envelopeSeat(n, 'detail');
|
|
207
252
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
208
253
|
return undefined;
|
|
209
254
|
const o = d;
|
|
@@ -233,9 +278,9 @@ export function readMcpServerRedialed(notice) {
|
|
|
233
278
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
234
279
|
return undefined;
|
|
235
280
|
const n = notice;
|
|
236
|
-
if (
|
|
281
|
+
if (envelopeSeat(n, 'code') !== 'mcp.server_redialed')
|
|
237
282
|
return undefined;
|
|
238
|
-
const d =
|
|
283
|
+
const d = envelopeSeat(n, 'detail');
|
|
239
284
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
240
285
|
return undefined;
|
|
241
286
|
const o = d;
|
|
@@ -268,10 +313,10 @@ function readRootGrantNoticeOf(notice) {
|
|
|
268
313
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
269
314
|
return undefined;
|
|
270
315
|
const n = notice;
|
|
271
|
-
const code =
|
|
316
|
+
const code = envelopeSeat(n, 'code');
|
|
272
317
|
if (code !== 'approval.read_root_granted' && code !== 'approval.read_root_grant_rejected')
|
|
273
318
|
return undefined;
|
|
274
|
-
const d =
|
|
319
|
+
const d = envelopeSeat(n, 'detail');
|
|
275
320
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
276
321
|
return undefined;
|
|
277
322
|
const o = d;
|
|
@@ -285,14 +330,17 @@ function readRootGrantNoticeOf(notice) {
|
|
|
285
330
|
const root = str(o.root);
|
|
286
331
|
if (dir === undefined || root === undefined)
|
|
287
332
|
return undefined;
|
|
288
|
-
|
|
333
|
+
const covers = inValueOf(o, 'covers');
|
|
334
|
+
if (covers.state === 'unproven')
|
|
335
|
+
return undefined;
|
|
336
|
+
if (covers.state === 'present' && covers.value !== READ_ROOT_GRANT_COVERS_EXACT)
|
|
289
337
|
return undefined;
|
|
290
338
|
return {
|
|
291
339
|
outcome: 'granted',
|
|
292
340
|
toolCallId,
|
|
293
341
|
dir,
|
|
294
342
|
root,
|
|
295
|
-
...(
|
|
343
|
+
...(covers.state === 'present' ? { covers: READ_ROOT_GRANT_COVERS_EXACT } : {}),
|
|
296
344
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
297
345
|
};
|
|
298
346
|
}
|
|
@@ -312,9 +360,9 @@ export function readInstructionsSourceChanged(notice) {
|
|
|
312
360
|
return undefined;
|
|
313
361
|
try {
|
|
314
362
|
const n = notice;
|
|
315
|
-
if (
|
|
363
|
+
if (envelopeSeat(n, 'code') !== 'instructions.source_changed')
|
|
316
364
|
return undefined;
|
|
317
|
-
const d =
|
|
365
|
+
const d = envelopeSeat(n, 'detail');
|
|
318
366
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
319
367
|
return undefined;
|
|
320
368
|
const o = d;
|
|
@@ -338,9 +386,9 @@ export function readSessionRecordsSkipped(notice) {
|
|
|
338
386
|
return undefined;
|
|
339
387
|
try {
|
|
340
388
|
const n = notice;
|
|
341
|
-
if (
|
|
389
|
+
if (envelopeSeat(n, 'code') !== 'session.records_skipped')
|
|
342
390
|
return undefined;
|
|
343
|
-
const d =
|
|
391
|
+
const d = envelopeSeat(n, 'detail');
|
|
344
392
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
345
393
|
return undefined;
|
|
346
394
|
const o = d;
|
|
@@ -384,9 +432,9 @@ function readRuleStoreUnavailableOf(notice) {
|
|
|
384
432
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
385
433
|
return undefined;
|
|
386
434
|
const n = notice;
|
|
387
|
-
if (
|
|
435
|
+
if (envelopeSeat(n, 'code') !== 'permission.rule_store_unavailable')
|
|
388
436
|
return undefined;
|
|
389
|
-
const d =
|
|
437
|
+
const d = envelopeSeat(n, 'detail');
|
|
390
438
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
391
439
|
return undefined;
|
|
392
440
|
const o = d;
|
|
@@ -408,9 +456,9 @@ function readClassifierUnavailableOf(notice) {
|
|
|
408
456
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
409
457
|
return undefined;
|
|
410
458
|
const n = notice;
|
|
411
|
-
if (
|
|
459
|
+
if (envelopeSeat(n, 'code') !== 'classifier.unavailable')
|
|
412
460
|
return undefined;
|
|
413
|
-
const d =
|
|
461
|
+
const d = envelopeSeat(n, 'detail');
|
|
414
462
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
415
463
|
return undefined;
|
|
416
464
|
const o = d;
|
|
@@ -433,6 +481,7 @@ function readClassifierUnavailableOf(notice) {
|
|
|
433
481
|
disposition,
|
|
434
482
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
435
483
|
...(runId !== undefined ? { runId } : {}),
|
|
484
|
+
leg: readNoticeLeg(o),
|
|
436
485
|
};
|
|
437
486
|
}
|
|
438
487
|
export const PERMISSION_MODE_FOLD_REASONS = CORE_PERMISSION_MODE_FOLD_REASONS;
|
|
@@ -444,9 +493,9 @@ function readPermissionModeUnavailableOf(notice) {
|
|
|
444
493
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
445
494
|
return undefined;
|
|
446
495
|
const n = notice;
|
|
447
|
-
if (
|
|
496
|
+
if (envelopeSeat(n, 'code') !== 'config.permission_mode_unavailable')
|
|
448
497
|
return undefined;
|
|
449
|
-
const d =
|
|
498
|
+
const d = envelopeSeat(n, 'detail');
|
|
450
499
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
451
500
|
return undefined;
|
|
452
501
|
const o = d;
|
|
@@ -469,9 +518,9 @@ function readAskReleasedByModeOf(notice) {
|
|
|
469
518
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
470
519
|
return undefined;
|
|
471
520
|
const n = notice;
|
|
472
|
-
if (
|
|
521
|
+
if (envelopeSeat(n, 'code') !== 'permission.ask_released_by_mode')
|
|
473
522
|
return undefined;
|
|
474
|
-
const d =
|
|
523
|
+
const d = envelopeSeat(n, 'detail');
|
|
475
524
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
476
525
|
return undefined;
|
|
477
526
|
const o = d;
|
|
@@ -495,6 +544,7 @@ function readAskReleasedByModeOf(notice) {
|
|
|
495
544
|
firstToolCallId,
|
|
496
545
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
497
546
|
...(runId !== undefined ? { runId } : {}),
|
|
547
|
+
leg: readNoticeLeg(o),
|
|
498
548
|
};
|
|
499
549
|
}
|
|
500
550
|
export function readReadDenyUnapplied(notice) {
|
|
@@ -504,9 +554,9 @@ function readReadDenyUnappliedOf(notice) {
|
|
|
504
554
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
505
555
|
return undefined;
|
|
506
556
|
const n = notice;
|
|
507
|
-
if (
|
|
557
|
+
if (envelopeSeat(n, 'code') !== 'permission.read_deny_unapplied')
|
|
508
558
|
return undefined;
|
|
509
|
-
const d =
|
|
559
|
+
const d = envelopeSeat(n, 'detail');
|
|
510
560
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
511
561
|
return undefined;
|
|
512
562
|
const o = d;
|
|
@@ -521,7 +571,7 @@ function readReadDenyUnappliedOf(notice) {
|
|
|
521
571
|
rowCount === undefined || sessionId === undefined || runId === undefined) {
|
|
522
572
|
return undefined;
|
|
523
573
|
}
|
|
524
|
-
return { mode, toolCallId, tiers, rows, rowCount, sessionId, runId };
|
|
574
|
+
return { mode, toolCallId, tiers, rows, rowCount, sessionId, runId, leg: readNoticeLeg(o) };
|
|
525
575
|
}
|
|
526
576
|
export function readToolTurnRepaired(notice) {
|
|
527
577
|
return guardedRead(notice, readToolTurnRepairedOf);
|
|
@@ -529,6 +579,9 @@ export function readToolTurnRepaired(notice) {
|
|
|
529
579
|
function ownSeat(o, key) {
|
|
530
580
|
return Object.hasOwn(o, key) ? o[key] : undefined;
|
|
531
581
|
}
|
|
582
|
+
function envelopeSeat(o, key) {
|
|
583
|
+
return readOwnDataValue(o, key);
|
|
584
|
+
}
|
|
532
585
|
function optionalOwnSeat(o, key) {
|
|
533
586
|
try {
|
|
534
587
|
return ownSeat(o, key);
|
|
@@ -550,9 +603,9 @@ function readToolTurnRepairedOf(notice) {
|
|
|
550
603
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
551
604
|
return undefined;
|
|
552
605
|
const n = notice;
|
|
553
|
-
if (
|
|
606
|
+
if (envelopeSeat(n, 'code') !== 'context.tool_turn_repaired')
|
|
554
607
|
return undefined;
|
|
555
|
-
const d =
|
|
608
|
+
const d = envelopeSeat(n, 'detail');
|
|
556
609
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
557
610
|
return undefined;
|
|
558
611
|
const o = d;
|
|
@@ -585,9 +638,9 @@ function readModelUnreachableOf(notice) {
|
|
|
585
638
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
586
639
|
return undefined;
|
|
587
640
|
const n = notice;
|
|
588
|
-
if (
|
|
641
|
+
if (envelopeSeat(n, 'code') !== 'server.model_unreachable')
|
|
589
642
|
return undefined;
|
|
590
|
-
const d =
|
|
643
|
+
const d = envelopeSeat(n, 'detail');
|
|
591
644
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
592
645
|
return undefined;
|
|
593
646
|
const o = d;
|
|
@@ -609,9 +662,9 @@ function readAllowedToolNotGrantedOf(notice) {
|
|
|
609
662
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
610
663
|
return undefined;
|
|
611
664
|
const n = notice;
|
|
612
|
-
if (
|
|
665
|
+
if (envelopeSeat(n, 'code') !== 'permission.allowed_tool_not_granted')
|
|
613
666
|
return undefined;
|
|
614
|
-
const d =
|
|
667
|
+
const d = envelopeSeat(n, 'detail');
|
|
615
668
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
616
669
|
return undefined;
|
|
617
670
|
const o = d;
|
|
@@ -671,9 +724,9 @@ function readToolTurnIncompleteOf(notice) {
|
|
|
671
724
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
672
725
|
return undefined;
|
|
673
726
|
const n = notice;
|
|
674
|
-
if (
|
|
727
|
+
if (envelopeSeat(n, 'code') !== 'task.tool_turn_incomplete')
|
|
675
728
|
return undefined;
|
|
676
|
-
const d =
|
|
729
|
+
const d = envelopeSeat(n, 'detail');
|
|
677
730
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
678
731
|
return undefined;
|
|
679
732
|
const o = d;
|
|
@@ -695,6 +748,9 @@ function optionalNonEmpty(o, key) {
|
|
|
695
748
|
return undefined;
|
|
696
749
|
}
|
|
697
750
|
}
|
|
751
|
+
function undrainedInputKindOf(v) {
|
|
752
|
+
return v === 'steer' || v === 'approval_feedback' ? v : undefined;
|
|
753
|
+
}
|
|
698
754
|
export function readUserInputUndrained(notice) {
|
|
699
755
|
return guardedRead(notice, readUserInputUndrainedOf);
|
|
700
756
|
}
|
|
@@ -712,10 +768,10 @@ function readUserInputUndrainedOf(notice) {
|
|
|
712
768
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
713
769
|
return undefined;
|
|
714
770
|
const n = notice;
|
|
715
|
-
const kind = undrainedLaneOfCode(
|
|
771
|
+
const kind = undrainedLaneOfCode(envelopeSeat(n, 'code'));
|
|
716
772
|
if (kind === undefined)
|
|
717
773
|
return undefined;
|
|
718
|
-
const d =
|
|
774
|
+
const d = envelopeSeat(n, 'detail');
|
|
719
775
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
720
776
|
return undefined;
|
|
721
777
|
const o = d;
|
|
@@ -726,6 +782,7 @@ function readUserInputUndrainedOf(notice) {
|
|
|
726
782
|
const taskId = nonEmpty(optionalOwnSeat(o, 'taskId'));
|
|
727
783
|
const sessionId = nonEmpty(optionalOwnSeat(o, 'sessionId'));
|
|
728
784
|
const runId = nonEmpty(optionalOwnSeat(o, 'runId'));
|
|
785
|
+
const inputKind = kind === 'steer' ? undrainedInputKindOf(optionalOwnSeat(o, 'kind')) : undefined;
|
|
729
786
|
const childSeat = ownSeatOrUnreadable(o, 'childSessionId');
|
|
730
787
|
const childSessionId = nonEmpty(childSeat);
|
|
731
788
|
const childSeatProven = childSeat === undefined || childSessionId !== undefined;
|
|
@@ -739,6 +796,7 @@ function readUserInputUndrainedOf(notice) {
|
|
|
739
796
|
...(runId !== undefined ? { runId } : {}),
|
|
740
797
|
...(childSessionId !== undefined ? { childSessionId } : {}),
|
|
741
798
|
...(inputIds !== undefined ? { inputIds } : {}),
|
|
799
|
+
...(inputKind !== undefined ? { inputKind } : {}),
|
|
742
800
|
};
|
|
743
801
|
}
|
|
744
802
|
function exactInputIdList(v, count) {
|
|
@@ -849,11 +907,12 @@ const subagentFollowUpUndrainedSentence = (n) => `${messagesPhrase(n, 'follow-up
|
|
|
849
907
|
`Send ${itThem(n)} again if you still need ${itThem(n)}.`;
|
|
850
908
|
const unrecognizedUndrainedSentence = (n, kind) => `${kind === 'followUp' ? `${messagesPhrase(n, 'follow-up message')} you queued` : `${messagesPhrase(n, 'message')} you sent during a run`} may not have been used, ` +
|
|
851
909
|
`and the reason was not reported in a form this version recognizes. Check the run's transcript before sending ${itThem(n)} again.`;
|
|
852
|
-
export function userInputUndrainedNotice(facts) {
|
|
910
|
+
export function userInputUndrainedNotice(facts, lang) {
|
|
853
911
|
let kind;
|
|
854
912
|
let count;
|
|
855
913
|
let cause;
|
|
856
914
|
let child;
|
|
915
|
+
let inputKind;
|
|
857
916
|
try {
|
|
858
917
|
if (facts === null || typeof facts !== 'object' || Array.isArray(facts))
|
|
859
918
|
return undefined;
|
|
@@ -871,6 +930,12 @@ export function userInputUndrainedNotice(facts) {
|
|
|
871
930
|
child = undefined;
|
|
872
931
|
}
|
|
873
932
|
const fromSubagent = typeof child === 'string' && child.length > 0;
|
|
933
|
+
try {
|
|
934
|
+
inputKind = Object.hasOwn(facts, 'inputKind') ? facts.inputKind : undefined;
|
|
935
|
+
}
|
|
936
|
+
catch {
|
|
937
|
+
inputKind = undefined;
|
|
938
|
+
}
|
|
874
939
|
const n = positiveInt(count);
|
|
875
940
|
if (n === undefined || !isUndrainedLane(kind))
|
|
876
941
|
return undefined;
|
|
@@ -879,6 +944,9 @@ export function userInputUndrainedNotice(facts) {
|
|
|
879
944
|
return fromSubagent ? subagentFollowUpUndrainedSentence(n) : followUpUndrainedSentence(n);
|
|
880
945
|
return unrecognizedUndrainedSentence(n, kind);
|
|
881
946
|
}
|
|
947
|
+
if (cause === 'leg_end' && inputKind === 'approval_feedback') {
|
|
948
|
+
return renderMessage(msg(n === 1 ? 'notice.userInputUndrained.approvalFeedback.one' : 'notice.userInputUndrained.approvalFeedback.other', { count: n }), lang);
|
|
949
|
+
}
|
|
882
950
|
if (cause === 'leg_end' && fromSubagent)
|
|
883
951
|
return subagentSteerUndrainedSentence(n);
|
|
884
952
|
if (typeof cause === 'string' && Object.hasOwn(STEER_UNDRAINED_SENTENCE, cause)) {
|
|
@@ -893,9 +961,9 @@ function readTurnInterruptedOf(notice) {
|
|
|
893
961
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
894
962
|
return undefined;
|
|
895
963
|
const n = notice;
|
|
896
|
-
if (
|
|
964
|
+
if (envelopeSeat(n, 'code') !== 'task.turn_interrupted')
|
|
897
965
|
return undefined;
|
|
898
|
-
const d =
|
|
966
|
+
const d = envelopeSeat(n, 'detail');
|
|
899
967
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
900
968
|
return undefined;
|
|
901
969
|
const o = d;
|
|
@@ -940,7 +1008,7 @@ export function steerCutVerdict(notice, messageId) {
|
|
|
940
1008
|
try {
|
|
941
1009
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
942
1010
|
return 'not_a_cut';
|
|
943
|
-
code =
|
|
1011
|
+
code = envelopeSeat(notice, 'code');
|
|
944
1012
|
}
|
|
945
1013
|
catch {
|
|
946
1014
|
return 'not_a_cut';
|
|
@@ -963,9 +1031,9 @@ function readFinishReasonUnknownOf(notice) {
|
|
|
963
1031
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
964
1032
|
return undefined;
|
|
965
1033
|
const n = notice;
|
|
966
|
-
if (
|
|
1034
|
+
if (envelopeSeat(n, 'code') !== 'route.finish_reason_unknown')
|
|
967
1035
|
return undefined;
|
|
968
|
-
const d =
|
|
1036
|
+
const d = envelopeSeat(n, 'detail');
|
|
969
1037
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
970
1038
|
return undefined;
|
|
971
1039
|
const o = d;
|
|
@@ -983,9 +1051,9 @@ function readStreamEndIgnoredOf(notice) {
|
|
|
983
1051
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
984
1052
|
return undefined;
|
|
985
1053
|
const n = notice;
|
|
986
|
-
if (
|
|
1054
|
+
if (envelopeSeat(n, 'code') !== 'route.stream_end_ignored')
|
|
987
1055
|
return undefined;
|
|
988
|
-
const d =
|
|
1056
|
+
const d = envelopeSeat(n, 'detail');
|
|
989
1057
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
990
1058
|
return undefined;
|
|
991
1059
|
const o = d;
|
|
@@ -1005,10 +1073,10 @@ function readContextMediaRemovedOf(notice) {
|
|
|
1005
1073
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1006
1074
|
return undefined;
|
|
1007
1075
|
const n = notice;
|
|
1008
|
-
const code =
|
|
1076
|
+
const code = envelopeSeat(n, 'code');
|
|
1009
1077
|
if (code !== 'context.media_removed' && code !== 'context.image_removed')
|
|
1010
1078
|
return undefined;
|
|
1011
|
-
const d =
|
|
1079
|
+
const d = envelopeSeat(n, 'detail');
|
|
1012
1080
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1013
1081
|
return undefined;
|
|
1014
1082
|
const o = d;
|
|
@@ -1037,9 +1105,9 @@ function readMcpAuthorizationRequiredOf(notice) {
|
|
|
1037
1105
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1038
1106
|
return undefined;
|
|
1039
1107
|
const n = notice;
|
|
1040
|
-
if (
|
|
1108
|
+
if (envelopeSeat(n, 'code') !== 'mcp.authorization_required')
|
|
1041
1109
|
return undefined;
|
|
1042
|
-
const d =
|
|
1110
|
+
const d = envelopeSeat(n, 'detail');
|
|
1043
1111
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1044
1112
|
return undefined;
|
|
1045
1113
|
const o = d;
|
|
@@ -1059,9 +1127,9 @@ function readSessionLineageRerootedOf(notice) {
|
|
|
1059
1127
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1060
1128
|
return undefined;
|
|
1061
1129
|
const n = notice;
|
|
1062
|
-
if (
|
|
1130
|
+
if (envelopeSeat(n, 'code') !== 'session.lineage_rerooted')
|
|
1063
1131
|
return undefined;
|
|
1064
|
-
const d =
|
|
1132
|
+
const d = envelopeSeat(n, 'detail');
|
|
1065
1133
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1066
1134
|
return undefined;
|
|
1067
1135
|
const o = d;
|
|
@@ -1093,6 +1161,562 @@ function readSessionLineageRerootedOf(notice) {
|
|
|
1093
1161
|
return undefined;
|
|
1094
1162
|
return { break: true, leaf, missingParentId, rootedAt, entriesCut: countReading(optionalOwnSeat(o, 'entriesCut')), ...common };
|
|
1095
1163
|
}
|
|
1164
|
+
function userCodeDetail(notice, code) {
|
|
1165
|
+
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1166
|
+
return undefined;
|
|
1167
|
+
const n = notice;
|
|
1168
|
+
if (envelopeSeat(n, 'code') !== code)
|
|
1169
|
+
return undefined;
|
|
1170
|
+
const d = envelopeSeat(n, 'detail');
|
|
1171
|
+
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1172
|
+
return undefined;
|
|
1173
|
+
return d;
|
|
1174
|
+
}
|
|
1175
|
+
const dataStr = (o, key) => nonEmpty(readOwnDataValue(o, key));
|
|
1176
|
+
const dataCount = (o, key) => {
|
|
1177
|
+
const v = readOwnDataValue(o, key);
|
|
1178
|
+
return typeof v === 'number' && Number.isSafeInteger(v) && v >= 0 ? v : undefined;
|
|
1179
|
+
};
|
|
1180
|
+
const optDataStr = (o, key) => {
|
|
1181
|
+
try {
|
|
1182
|
+
return dataStr(o, key);
|
|
1183
|
+
}
|
|
1184
|
+
catch {
|
|
1185
|
+
return undefined;
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
const optDataCount = (o, key) => {
|
|
1189
|
+
try {
|
|
1190
|
+
return dataCount(o, key);
|
|
1191
|
+
}
|
|
1192
|
+
catch {
|
|
1193
|
+
return undefined;
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
export function readMemorySessionPolluted(notice) {
|
|
1197
|
+
return guardedRead(notice, (n) => {
|
|
1198
|
+
const o = userCodeDetail(n, 'memory.session_polluted');
|
|
1199
|
+
if (o === undefined)
|
|
1200
|
+
return undefined;
|
|
1201
|
+
const reason = dataStr(o, 'reason');
|
|
1202
|
+
if (reason === undefined)
|
|
1203
|
+
return undefined;
|
|
1204
|
+
const sessionId = optDataStr(o, 'sessionId');
|
|
1205
|
+
return { reason, ...(sessionId !== undefined ? { sessionId } : {}) };
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
export function readMemoryHarvestQuarantined(notice) {
|
|
1209
|
+
return guardedRead(notice, (n) => {
|
|
1210
|
+
const o = userCodeDetail(n, 'memory.harvest_quarantined');
|
|
1211
|
+
if (o === undefined)
|
|
1212
|
+
return undefined;
|
|
1213
|
+
const count = dataCount(o, 'count');
|
|
1214
|
+
const moved = dataCount(o, 'moved');
|
|
1215
|
+
const escalated = dataCount(o, 'escalated');
|
|
1216
|
+
if (count === undefined || moved === undefined || escalated === undefined)
|
|
1217
|
+
return undefined;
|
|
1218
|
+
let rolledBack = false;
|
|
1219
|
+
try {
|
|
1220
|
+
rolledBack = readOwnDataValue(o, 'indexRolledBack') === true;
|
|
1221
|
+
}
|
|
1222
|
+
catch {
|
|
1223
|
+
rolledBack = false;
|
|
1224
|
+
}
|
|
1225
|
+
const reportId = optDataStr(o, 'reportId');
|
|
1226
|
+
const sessionId = optDataStr(o, 'sessionId');
|
|
1227
|
+
return {
|
|
1228
|
+
count,
|
|
1229
|
+
moved,
|
|
1230
|
+
escalated,
|
|
1231
|
+
...(rolledBack ? { indexRolledBack: true } : {}),
|
|
1232
|
+
...(reportId !== undefined ? { reportId } : {}),
|
|
1233
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
1234
|
+
};
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
export function readMemoryDelegationStaticMarkWaived(notice) {
|
|
1238
|
+
return guardedRead(notice, (n) => {
|
|
1239
|
+
const o = userCodeDetail(n, 'memory.delegation_static_mark_waived');
|
|
1240
|
+
if (o === undefined)
|
|
1241
|
+
return undefined;
|
|
1242
|
+
const reason = dataStr(o, 'reason');
|
|
1243
|
+
const runId = dataStr(o, 'runId');
|
|
1244
|
+
if (reason === undefined || runId === undefined)
|
|
1245
|
+
return undefined;
|
|
1246
|
+
const subagentType = optDataStr(o, 'subagentType');
|
|
1247
|
+
const sessionId = optDataStr(o, 'sessionId');
|
|
1248
|
+
return { reason, ...(subagentType !== undefined ? { subagentType } : {}), ...(sessionId !== undefined ? { sessionId } : {}), runId };
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
export function readMemoryCaptureOptedOut(notice) {
|
|
1252
|
+
return guardedRead(notice, (n) => {
|
|
1253
|
+
const o = userCodeDetail(n, 'memory.capture_opted_out');
|
|
1254
|
+
if (o === undefined)
|
|
1255
|
+
return undefined;
|
|
1256
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1257
|
+
const origin = dataStr(o, 'origin');
|
|
1258
|
+
if (sessionId === undefined || origin === undefined)
|
|
1259
|
+
return undefined;
|
|
1260
|
+
return { sessionId, origin };
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
export function readMemoryCaptureOptoutUnpersisted(notice) {
|
|
1264
|
+
return guardedRead(notice, (n) => {
|
|
1265
|
+
const o = userCodeDetail(n, 'memory.capture_optout_unpersisted');
|
|
1266
|
+
if (o === undefined)
|
|
1267
|
+
return undefined;
|
|
1268
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1269
|
+
if (sessionId === undefined)
|
|
1270
|
+
return undefined;
|
|
1271
|
+
const ingress = optDataStr(o, 'ingress');
|
|
1272
|
+
return { sessionId, ...(ingress !== undefined ? { ingress } : {}) };
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
export function readPeerInboundDisposition(notice) {
|
|
1276
|
+
return guardedRead(notice, (n) => {
|
|
1277
|
+
const o = userCodeDetail(n, 'peer.inbound_disposition');
|
|
1278
|
+
if (o === undefined)
|
|
1279
|
+
return undefined;
|
|
1280
|
+
const disposition = dataStr(o, 'disposition');
|
|
1281
|
+
const cause = dataStr(o, 'cause');
|
|
1282
|
+
const seq = dataCount(o, 'seq');
|
|
1283
|
+
const box = dataStr(o, 'box');
|
|
1284
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1285
|
+
const runId = dataStr(o, 'runId');
|
|
1286
|
+
if (disposition === undefined || cause === undefined || seq === undefined || box === undefined || sessionId === undefined || runId === undefined)
|
|
1287
|
+
return undefined;
|
|
1288
|
+
const fromSession = optDataStr(o, 'fromSession');
|
|
1289
|
+
return { disposition, cause, seq, box, ...(fromSession !== undefined ? { fromSession } : {}), sessionId, runId };
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
export function readPeerHeldSettled(notice) {
|
|
1293
|
+
return guardedRead(notice, (n) => {
|
|
1294
|
+
const o = userCodeDetail(n, 'peer.held_settled');
|
|
1295
|
+
if (o === undefined)
|
|
1296
|
+
return undefined;
|
|
1297
|
+
const settlement = dataStr(o, 'settlement');
|
|
1298
|
+
const reason = dataStr(o, 'reason');
|
|
1299
|
+
const seq = dataCount(o, 'seq');
|
|
1300
|
+
const box = dataStr(o, 'box');
|
|
1301
|
+
const heldCount = dataCount(o, 'heldCount');
|
|
1302
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1303
|
+
const runId = dataStr(o, 'runId');
|
|
1304
|
+
if (settlement === undefined || reason === undefined || seq === undefined || box === undefined || heldCount === undefined || sessionId === undefined || runId === undefined)
|
|
1305
|
+
return undefined;
|
|
1306
|
+
const fromSession = optDataStr(o, 'fromSession');
|
|
1307
|
+
return { settlement, reason, seq, box, ...(fromSession !== undefined ? { fromSession } : {}), heldCount, sessionId, runId };
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
export function readPeerIdleSubscription(notice) {
|
|
1311
|
+
return guardedRead(notice, (n) => {
|
|
1312
|
+
const o = userCodeDetail(n, 'peer.idle_subscription');
|
|
1313
|
+
if (o === undefined)
|
|
1314
|
+
return undefined;
|
|
1315
|
+
const outcome = dataStr(o, 'outcome');
|
|
1316
|
+
const fromSession = dataStr(o, 'fromSession');
|
|
1317
|
+
const seq = dataCount(o, 'seq');
|
|
1318
|
+
const box = dataStr(o, 'box');
|
|
1319
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1320
|
+
const runId = dataStr(o, 'runId');
|
|
1321
|
+
if (outcome === undefined || fromSession === undefined || seq === undefined || box === undefined || sessionId === undefined || runId === undefined)
|
|
1322
|
+
return undefined;
|
|
1323
|
+
const live = optDataCount(o, 'live');
|
|
1324
|
+
return { outcome, fromSession, ...(live !== undefined ? { live } : {}), seq, box, sessionId, runId };
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
export function readClassifierDenialLimit(notice) {
|
|
1328
|
+
return guardedRead(notice, (n) => {
|
|
1329
|
+
const o = userCodeDetail(n, 'classifier.denial_limit');
|
|
1330
|
+
if (o === undefined)
|
|
1331
|
+
return undefined;
|
|
1332
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1333
|
+
const runId = dataStr(o, 'runId');
|
|
1334
|
+
const toolName = dataStr(o, 'toolName');
|
|
1335
|
+
const toolCallId = dataStr(o, 'toolCallId');
|
|
1336
|
+
const consecutive = dataCount(o, 'consecutive');
|
|
1337
|
+
const total = dataCount(o, 'total');
|
|
1338
|
+
const limit = dataStr(o, 'limit');
|
|
1339
|
+
if (sessionId === undefined || runId === undefined || toolName === undefined || toolCallId === undefined || consecutive === undefined || total === undefined || limit === undefined)
|
|
1340
|
+
return undefined;
|
|
1341
|
+
return { sessionId, runId, toolName, toolCallId, consecutive, total, limit };
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
export function readTaskLateApproval(notice) {
|
|
1345
|
+
return guardedRead(notice, (n) => {
|
|
1346
|
+
const o = userCodeDetail(n, 'task.late_approval');
|
|
1347
|
+
if (o === undefined)
|
|
1348
|
+
return undefined;
|
|
1349
|
+
const toolName = dataStr(o, 'toolName');
|
|
1350
|
+
const toolCallId = dataStr(o, 'toolCallId');
|
|
1351
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1352
|
+
const runId = dataStr(o, 'runId');
|
|
1353
|
+
if (toolName === undefined || toolCallId === undefined || sessionId === undefined || runId === undefined)
|
|
1354
|
+
return undefined;
|
|
1355
|
+
const taskId = optDataStr(o, 'taskId');
|
|
1356
|
+
return { toolName, toolCallId, sessionId, runId, ...(taskId !== undefined ? { taskId } : {}) };
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
export function readTaskHaltUnconsumed(notice) {
|
|
1360
|
+
return guardedRead(notice, (n) => {
|
|
1361
|
+
const o = userCodeDetail(n, 'task.halt_unconsumed');
|
|
1362
|
+
if (o === undefined)
|
|
1363
|
+
return undefined;
|
|
1364
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1365
|
+
const runId = dataStr(o, 'runId');
|
|
1366
|
+
if (sessionId === undefined || runId === undefined)
|
|
1367
|
+
return undefined;
|
|
1368
|
+
const taskId = optDataStr(o, 'taskId');
|
|
1369
|
+
return { sessionId, runId, ...(taskId !== undefined ? { taskId } : {}) };
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
export function readSteeringParkedInputBlocked(notice) {
|
|
1373
|
+
return guardedRead(notice, (n) => {
|
|
1374
|
+
const o = userCodeDetail(n, 'steering.parked_input_blocked');
|
|
1375
|
+
if (o === undefined)
|
|
1376
|
+
return undefined;
|
|
1377
|
+
const sessionId = dataStr(o, 'sessionId');
|
|
1378
|
+
const runId = dataStr(o, 'runId');
|
|
1379
|
+
if (sessionId === undefined || runId === undefined)
|
|
1380
|
+
return undefined;
|
|
1381
|
+
const inputId = optDataStr(o, 'inputId');
|
|
1382
|
+
const taskId = optDataStr(o, 'taskId');
|
|
1383
|
+
return { ...(inputId !== undefined ? { inputId } : {}), sessionId, runId, ...(taskId !== undefined ? { taskId } : {}) };
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
function viewStr(v, key) {
|
|
1387
|
+
if (typeof v !== 'object' || v === null || Array.isArray(v))
|
|
1388
|
+
return undefined;
|
|
1389
|
+
return nonEmpty(readOwnDataValue(v, key));
|
|
1390
|
+
}
|
|
1391
|
+
function viewCount(v, key) {
|
|
1392
|
+
if (typeof v !== 'object' || v === null || Array.isArray(v))
|
|
1393
|
+
return undefined;
|
|
1394
|
+
const x = readOwnDataValue(v, key);
|
|
1395
|
+
return typeof x === 'number' && Number.isSafeInteger(x) && x >= 0 ? x : undefined;
|
|
1396
|
+
}
|
|
1397
|
+
function viewBool(v, key) {
|
|
1398
|
+
if (typeof v !== 'object' || v === null || Array.isArray(v))
|
|
1399
|
+
return undefined;
|
|
1400
|
+
const x = readOwnDataValue(v, key);
|
|
1401
|
+
return typeof x === 'boolean' ? x : undefined;
|
|
1402
|
+
}
|
|
1403
|
+
function viewOptStr(v, key) {
|
|
1404
|
+
try {
|
|
1405
|
+
return viewStr(v, key);
|
|
1406
|
+
}
|
|
1407
|
+
catch {
|
|
1408
|
+
return undefined;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
function shownName(v) {
|
|
1412
|
+
if (v === undefined)
|
|
1413
|
+
return undefined;
|
|
1414
|
+
const s = displayUntrusted(v, { blanks: true, max: 64 });
|
|
1415
|
+
return s.length > 0 ? s : undefined;
|
|
1416
|
+
}
|
|
1417
|
+
function shownText(v, max) {
|
|
1418
|
+
if (v === undefined)
|
|
1419
|
+
return undefined;
|
|
1420
|
+
const s = displayUntrusted(v, { max });
|
|
1421
|
+
return s.length > 0 ? s : undefined;
|
|
1422
|
+
}
|
|
1423
|
+
function wordLookup(table, word) {
|
|
1424
|
+
return Object.hasOwn(table, word) ? table[word] : undefined;
|
|
1425
|
+
}
|
|
1426
|
+
function joinSentences(parts, lang) {
|
|
1427
|
+
return parts.filter((p) => p !== undefined && p.length > 0).join(lang === 'zh' ? '' : ' ');
|
|
1428
|
+
}
|
|
1429
|
+
export function memorySessionPollutedSentence(facts, lang) {
|
|
1430
|
+
try {
|
|
1431
|
+
const reason = shownText(viewStr(facts, 'reason'), 200);
|
|
1432
|
+
if (reason === undefined)
|
|
1433
|
+
return undefined;
|
|
1434
|
+
return renderMessage(msg('notice.memory.sessionPolluted', { reason }), lang);
|
|
1435
|
+
}
|
|
1436
|
+
catch {
|
|
1437
|
+
return undefined;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
export function memoryHarvestQuarantinedSentence(facts, lang) {
|
|
1441
|
+
try {
|
|
1442
|
+
const count = viewCount(facts, 'count');
|
|
1443
|
+
const moved = viewCount(facts, 'moved');
|
|
1444
|
+
const escalated = viewCount(facts, 'escalated');
|
|
1445
|
+
if (count === undefined || moved === undefined || escalated === undefined)
|
|
1446
|
+
return undefined;
|
|
1447
|
+
const rolledBack = viewBool(facts, 'indexRolledBack') === true;
|
|
1448
|
+
if (count === 0 && rolledBack)
|
|
1449
|
+
return renderMessage(msg('notice.memory.harvestQuarantined.indexOnly'), lang);
|
|
1450
|
+
return joinSentences([renderMessage(msg('notice.memory.harvestQuarantined.counts', { count, moved, escalated }), lang), rolledBack ? renderMessage(msg('notice.memory.harvestQuarantined.indexAlso'), lang) : undefined], lang);
|
|
1451
|
+
}
|
|
1452
|
+
catch {
|
|
1453
|
+
return undefined;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
export function memoryDelegationStaticMarkWaivedSentence(facts, lang) {
|
|
1457
|
+
try {
|
|
1458
|
+
const reason = shownText(viewStr(facts, 'reason'), 200);
|
|
1459
|
+
if (reason === undefined)
|
|
1460
|
+
return undefined;
|
|
1461
|
+
const agentType = shownName(viewOptStr(facts, 'subagentType'));
|
|
1462
|
+
return joinSentences([
|
|
1463
|
+
renderMessage(msg('notice.memory.delegationWaived.lead'), lang),
|
|
1464
|
+
agentType !== undefined ? renderMessage(msg('notice.memory.delegationWaived.agentType', { agentType }), lang) : undefined,
|
|
1465
|
+
renderMessage(msg('notice.memory.delegationWaived.reason', { reason }), lang),
|
|
1466
|
+
renderMessage(msg('notice.memory.delegationWaived.tail'), lang),
|
|
1467
|
+
], lang);
|
|
1468
|
+
}
|
|
1469
|
+
catch {
|
|
1470
|
+
return undefined;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
const CAPTURE_OPTED_OUT_LEDE = Object.freeze({
|
|
1474
|
+
'flip-verb': 'notice.memory.captureOptedOut.flipVerb',
|
|
1475
|
+
'standing-record': 'notice.memory.captureOptedOut.standingRecord',
|
|
1476
|
+
'delegation-floor': 'notice.memory.captureOptedOut.delegationFloor',
|
|
1477
|
+
'fork-origin': 'notice.memory.captureOptedOut.forkOrigin',
|
|
1478
|
+
declaration: 'notice.memory.captureOptedOut.declaration',
|
|
1479
|
+
});
|
|
1480
|
+
export function memoryCaptureOptedOutSentence(facts, lang) {
|
|
1481
|
+
try {
|
|
1482
|
+
const origin = viewStr(facts, 'origin');
|
|
1483
|
+
if (origin === undefined)
|
|
1484
|
+
return undefined;
|
|
1485
|
+
const key = wordLookup(CAPTURE_OPTED_OUT_LEDE, origin) ?? 'notice.memory.captureOptedOut.other';
|
|
1486
|
+
return joinSentences([renderMessage(msg(key), lang), renderMessage(msg('notice.memory.captureOptedOut.tail'), lang)], lang);
|
|
1487
|
+
}
|
|
1488
|
+
catch {
|
|
1489
|
+
return undefined;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
export function memoryCaptureOptoutUnpersistedSentence(facts, lang) {
|
|
1493
|
+
try {
|
|
1494
|
+
if (viewStr(facts, 'sessionId') === undefined)
|
|
1495
|
+
return undefined;
|
|
1496
|
+
const ingress = viewOptStr(facts, 'ingress');
|
|
1497
|
+
const key = ingress === 'declaration'
|
|
1498
|
+
? 'notice.memory.captureOptoutUnpersisted.declaration'
|
|
1499
|
+
: ingress === 'flip-verb'
|
|
1500
|
+
? 'notice.memory.captureOptoutUnpersisted.flipVerb'
|
|
1501
|
+
: 'notice.memory.captureOptoutUnpersisted.other';
|
|
1502
|
+
return joinSentences([renderMessage(msg('notice.memory.captureOptoutUnpersisted.lead'), lang), renderMessage(msg(key), lang)], lang);
|
|
1503
|
+
}
|
|
1504
|
+
catch {
|
|
1505
|
+
return undefined;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
const PEER_SUBJECT_KEYS = Object.freeze({
|
|
1509
|
+
message: ['notice.peer.subject.message', 'notice.peer.subject.messageFrom'],
|
|
1510
|
+
notice: ['notice.peer.subject.notice', 'notice.peer.subject.noticeFrom'],
|
|
1511
|
+
held: ['notice.peer.subject.held', 'notice.peer.subject.heldFrom'],
|
|
1512
|
+
});
|
|
1513
|
+
function peerSubject(kind, seq, fromSession) {
|
|
1514
|
+
const from = shownName(fromSession);
|
|
1515
|
+
const [plain, withFrom] = PEER_SUBJECT_KEYS[kind];
|
|
1516
|
+
return from === undefined ? msg(plain, { seq }) : msg(withFrom, { seq, from });
|
|
1517
|
+
}
|
|
1518
|
+
const PEER_INBOUND_SENTENCE = Object.freeze({
|
|
1519
|
+
refused: ['notice.peer.inbound.refused', 'message'],
|
|
1520
|
+
admission_refused: ['notice.peer.inbound.admissionRefused', 'message'],
|
|
1521
|
+
held: ['notice.peer.inbound.held', 'message'],
|
|
1522
|
+
notice_unrouted: ['notice.peer.inbound.noticeUnrouted', 'notice'],
|
|
1523
|
+
notice_user_only: ['notice.peer.inbound.noticeUserOnly', 'notice'],
|
|
1524
|
+
resupply_exhausted: ['notice.peer.inbound.resupplyExhausted', 'message'],
|
|
1525
|
+
});
|
|
1526
|
+
export function peerInboundDispositionSentence(facts, lang) {
|
|
1527
|
+
try {
|
|
1528
|
+
const disposition = viewStr(facts, 'disposition');
|
|
1529
|
+
const causeRaw = viewStr(facts, 'cause');
|
|
1530
|
+
const seq = viewCount(facts, 'seq');
|
|
1531
|
+
if (disposition === undefined || causeRaw === undefined || seq === undefined)
|
|
1532
|
+
return undefined;
|
|
1533
|
+
const cause = shownText(causeRaw, 160);
|
|
1534
|
+
const [key, kind] = wordLookup(PEER_INBOUND_SENTENCE, disposition) ?? ['notice.peer.inbound.other', 'message'];
|
|
1535
|
+
const subject = peerSubject(kind, seq, viewOptStr(facts, 'fromSession'));
|
|
1536
|
+
return joinSentences([renderMessage(msg(key, { subject }), lang), cause !== undefined ? renderMessage(msg('notice.peer.inbound.cause', { cause }), lang) : undefined], lang);
|
|
1537
|
+
}
|
|
1538
|
+
catch {
|
|
1539
|
+
return undefined;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
function peerHeldSettledKey(settlement, reason) {
|
|
1543
|
+
if (reason === 'decided_elsewhere')
|
|
1544
|
+
return 'notice.peer.held.decidedElsewhere';
|
|
1545
|
+
if (settlement === 'retired')
|
|
1546
|
+
return reason === 'superseded' ? 'notice.peer.held.retiredSuperseded' : 'notice.peer.held.retiredOther';
|
|
1547
|
+
if (reason === 'evicted' && (settlement === 'expired' || settlement === 'dropped'))
|
|
1548
|
+
return 'notice.peer.held.evicted';
|
|
1549
|
+
if (settlement === 'delivered' && reason === 'approved')
|
|
1550
|
+
return 'notice.peer.held.deliveredApproved';
|
|
1551
|
+
if (settlement === 'delivered' && reason === 'rejudge')
|
|
1552
|
+
return 'notice.peer.held.deliveredRejudged';
|
|
1553
|
+
if (settlement === 'dropped' && reason === 'rejudge')
|
|
1554
|
+
return 'notice.peer.held.droppedRejudged';
|
|
1555
|
+
if (settlement === 'dropped' && reason === 'inject_failed')
|
|
1556
|
+
return 'notice.peer.held.droppedInjectFailed';
|
|
1557
|
+
if (settlement === 'expired' && reason === 'deadline')
|
|
1558
|
+
return 'notice.peer.held.expiredDeadline';
|
|
1559
|
+
if (settlement === 'expired' && reason === 'cancelled')
|
|
1560
|
+
return 'notice.peer.held.expiredCancelled';
|
|
1561
|
+
if (settlement === 'expired' && reason === 'shutdown')
|
|
1562
|
+
return 'notice.peer.held.expiredShutdown';
|
|
1563
|
+
if (settlement === 'denied')
|
|
1564
|
+
return 'notice.peer.held.denied';
|
|
1565
|
+
if (settlement === 'refused')
|
|
1566
|
+
return 'notice.peer.held.refused';
|
|
1567
|
+
return 'notice.peer.held.other';
|
|
1568
|
+
}
|
|
1569
|
+
export function peerHeldSettledSentence(facts, lang) {
|
|
1570
|
+
try {
|
|
1571
|
+
const settlement = viewStr(facts, 'settlement');
|
|
1572
|
+
const reason = viewStr(facts, 'reason');
|
|
1573
|
+
const seq = viewCount(facts, 'seq');
|
|
1574
|
+
const heldCount = viewCount(facts, 'heldCount');
|
|
1575
|
+
if (settlement === undefined || reason === undefined || seq === undefined || heldCount === undefined)
|
|
1576
|
+
return undefined;
|
|
1577
|
+
const subject = peerSubject('held', seq, viewOptStr(facts, 'fromSession'));
|
|
1578
|
+
return renderMessage(msg(peerHeldSettledKey(settlement, reason), { subject, heldCount }), lang);
|
|
1579
|
+
}
|
|
1580
|
+
catch {
|
|
1581
|
+
return undefined;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
const PEER_IDLE_SENTENCE = Object.freeze({
|
|
1585
|
+
recorded: 'notice.peer.idle.recorded',
|
|
1586
|
+
refreshed: 'notice.peer.idle.refreshed',
|
|
1587
|
+
full: 'notice.peer.idle.full',
|
|
1588
|
+
refused: 'notice.peer.idle.refused',
|
|
1589
|
+
});
|
|
1590
|
+
export function peerIdleSubscriptionSentence(facts, lang) {
|
|
1591
|
+
try {
|
|
1592
|
+
const outcome = viewStr(facts, 'outcome');
|
|
1593
|
+
const from = shownName(viewStr(facts, 'fromSession'));
|
|
1594
|
+
if (outcome === undefined || from === undefined)
|
|
1595
|
+
return undefined;
|
|
1596
|
+
let live;
|
|
1597
|
+
try {
|
|
1598
|
+
live = viewCount(facts, 'live');
|
|
1599
|
+
}
|
|
1600
|
+
catch {
|
|
1601
|
+
live = undefined;
|
|
1602
|
+
}
|
|
1603
|
+
const key = wordLookup(PEER_IDLE_SENTENCE, outcome) ?? 'notice.peer.idle.other';
|
|
1604
|
+
return joinSentences([renderMessage(msg(key, { from }), lang), live !== undefined ? renderMessage(msg('notice.peer.idle.waiting', { live }), lang) : undefined], lang);
|
|
1605
|
+
}
|
|
1606
|
+
catch {
|
|
1607
|
+
return undefined;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
export function classifierDenialLimitSentence(facts, lang) {
|
|
1611
|
+
try {
|
|
1612
|
+
const limit = viewStr(facts, 'limit');
|
|
1613
|
+
const consecutive = viewCount(facts, 'consecutive');
|
|
1614
|
+
const total = viewCount(facts, 'total');
|
|
1615
|
+
if (limit === undefined || consecutive === undefined || total === undefined)
|
|
1616
|
+
return undefined;
|
|
1617
|
+
const tool = shownName(viewOptStr(facts, 'toolName'));
|
|
1618
|
+
const n = limit === 'consecutive' ? consecutive : limit === 'total' ? total : 0;
|
|
1619
|
+
const key = limit === 'consecutive' && n > 0 ? 'notice.classifier.denialLimit.consecutive' : limit === 'total' && n > 0 ? 'notice.classifier.denialLimit.total' : 'notice.classifier.denialLimit.other';
|
|
1620
|
+
return joinSentences([
|
|
1621
|
+
renderMessage(msg(key, { count: n }), lang),
|
|
1622
|
+
tool !== undefined ? renderMessage(msg('notice.classifier.denialLimit.tool', { tool }), lang) : undefined,
|
|
1623
|
+
renderMessage(msg('notice.classifier.denialLimit.tail'), lang),
|
|
1624
|
+
], lang);
|
|
1625
|
+
}
|
|
1626
|
+
catch {
|
|
1627
|
+
return undefined;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
export function taskLateApprovalSentence(facts, lang) {
|
|
1631
|
+
try {
|
|
1632
|
+
const tool = shownName(viewStr(facts, 'toolName'));
|
|
1633
|
+
if (tool === undefined)
|
|
1634
|
+
return undefined;
|
|
1635
|
+
return renderMessage(msg('notice.task.lateApproval', { tool }), lang);
|
|
1636
|
+
}
|
|
1637
|
+
catch {
|
|
1638
|
+
return undefined;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
export function taskHaltUnconsumedSentence(facts, lang) {
|
|
1642
|
+
try {
|
|
1643
|
+
if (viewStr(facts, 'sessionId') === undefined || viewStr(facts, 'runId') === undefined)
|
|
1644
|
+
return undefined;
|
|
1645
|
+
return renderMessage(msg('notice.task.haltUnconsumed'), lang);
|
|
1646
|
+
}
|
|
1647
|
+
catch {
|
|
1648
|
+
return undefined;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
export function steeringParkedInputBlockedSentence(facts, lang) {
|
|
1652
|
+
try {
|
|
1653
|
+
if (viewStr(facts, 'sessionId') === undefined || viewStr(facts, 'runId') === undefined)
|
|
1654
|
+
return undefined;
|
|
1655
|
+
return renderMessage(msg('notice.steering.parkedInputBlocked'), lang);
|
|
1656
|
+
}
|
|
1657
|
+
catch {
|
|
1658
|
+
return undefined;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
const DURABLE_MANDATE_CLAUSE = Object.freeze({
|
|
1662
|
+
force_durable_gate: 'notice.durableGate.mandate.forceDurableGate',
|
|
1663
|
+
durable_approval: 'notice.durableGate.mandate.durableApproval',
|
|
1664
|
+
});
|
|
1665
|
+
const DURABLE_EXIT_ALT = Object.freeze({
|
|
1666
|
+
force_durable_gate: 'notice.durableGate.exitAlt.forceDurableGate',
|
|
1667
|
+
durable_approval: 'notice.durableGate.exitAlt.durableApproval',
|
|
1668
|
+
});
|
|
1669
|
+
const DURABLE_CAUSE_CLAUSE = Object.freeze({
|
|
1670
|
+
no_deployment_store: ['notice.durableGate.cause.noDeploymentStore', 'notice.durableGate.exit.noDeploymentStore'],
|
|
1671
|
+
task_store_disabled: ['notice.durableGate.cause.taskStoreDisabled', 'notice.durableGate.exit.taskStoreDisabled'],
|
|
1672
|
+
});
|
|
1673
|
+
export function durableGateUnavailableSentence(facts, lang) {
|
|
1674
|
+
try {
|
|
1675
|
+
const source = viewStr(facts, 'source');
|
|
1676
|
+
const cause = viewStr(facts, 'cause');
|
|
1677
|
+
if (source === undefined || cause === undefined)
|
|
1678
|
+
return undefined;
|
|
1679
|
+
const liveApprover = viewBool(facts, 'liveApprover');
|
|
1680
|
+
const liveQuestionFace = viewBool(facts, 'liveQuestionFace');
|
|
1681
|
+
const mandateKey = wordLookup(DURABLE_MANDATE_CLAUSE, source) ?? 'notice.durableGate.mandate.other';
|
|
1682
|
+
const [causeKey, exitKey] = wordLookup(DURABLE_CAUSE_CLAUSE, cause) ?? ['notice.durableGate.cause.other', 'notice.durableGate.exit.other'];
|
|
1683
|
+
const exitAltKey = wordLookup(DURABLE_EXIT_ALT, source);
|
|
1684
|
+
const approverKey = liveApprover === true ? 'notice.durableGate.approver.live' : liveApprover === false ? 'notice.durableGate.approver.noneAttached' : 'notice.durableGate.approver.unreported';
|
|
1685
|
+
return joinSentences([
|
|
1686
|
+
renderMessage(msg('notice.durableGate.lead', { mandate: msg(mandateKey), cause: msg(causeKey) }), lang),
|
|
1687
|
+
renderMessage(msg(approverKey), lang),
|
|
1688
|
+
liveQuestionFace === false ? renderMessage(msg('notice.durableGate.question.refused'), lang) : undefined,
|
|
1689
|
+
renderMessage(msg(exitKey), lang),
|
|
1690
|
+
exitAltKey !== undefined ? renderMessage(msg(exitAltKey), lang) : undefined,
|
|
1691
|
+
], lang);
|
|
1692
|
+
}
|
|
1693
|
+
catch {
|
|
1694
|
+
return undefined;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
const DISCARDED_DELIVERY_PATH_SET = new Set(CORE_DISCARDED_DELIVERY_PATHS);
|
|
1698
|
+
export function readDeliveryDiscarded(notice) {
|
|
1699
|
+
return guardedRead(notice, readDeliveryDiscardedOf);
|
|
1700
|
+
}
|
|
1701
|
+
function readDeliveryDiscardedOf(notice) {
|
|
1702
|
+
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1703
|
+
return undefined;
|
|
1704
|
+
const n = notice;
|
|
1705
|
+
if (envelopeSeat(n, 'code') !== 'delegation.delivery_discarded')
|
|
1706
|
+
return undefined;
|
|
1707
|
+
const d = envelopeSeat(n, 'detail');
|
|
1708
|
+
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1709
|
+
return undefined;
|
|
1710
|
+
const o = d;
|
|
1711
|
+
const taskId = nonEmpty(ownSeat(o, 'taskId'));
|
|
1712
|
+
const taskType = nonEmpty(ownSeat(o, 'taskType'));
|
|
1713
|
+
const sessionId = nonEmpty(ownSeat(o, 'sessionId'));
|
|
1714
|
+
if (taskId === undefined || taskType === undefined || sessionId === undefined)
|
|
1715
|
+
return undefined;
|
|
1716
|
+
const pathRaw = optionalOwnSeat(o, 'path');
|
|
1717
|
+
const path = typeof pathRaw === 'string' && DISCARDED_DELIVERY_PATH_SET.has(pathRaw) ? pathRaw : undefined;
|
|
1718
|
+
return { taskId, taskType, sessionId, ...(path !== undefined ? { path } : {}) };
|
|
1719
|
+
}
|
|
1096
1720
|
export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
|
|
1097
1721
|
'mcp.injection_dropped': readMcpInjectionDrop,
|
|
1098
1722
|
'delegation.ask_unresolvable': readAskUnresolvable,
|
|
@@ -1121,6 +1745,19 @@ export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
|
|
|
1121
1745
|
'context.media_removed': readContextMediaRemoved,
|
|
1122
1746
|
'context.image_removed': readContextMediaRemoved,
|
|
1123
1747
|
'session.lineage_rerooted': readSessionLineageRerooted,
|
|
1748
|
+
'memory.session_polluted': readMemorySessionPolluted,
|
|
1749
|
+
'memory.harvest_quarantined': readMemoryHarvestQuarantined,
|
|
1750
|
+
'memory.delegation_static_mark_waived': readMemoryDelegationStaticMarkWaived,
|
|
1751
|
+
'memory.capture_opted_out': readMemoryCaptureOptedOut,
|
|
1752
|
+
'memory.capture_optout_unpersisted': readMemoryCaptureOptoutUnpersisted,
|
|
1753
|
+
'peer.inbound_disposition': readPeerInboundDisposition,
|
|
1754
|
+
'peer.held_settled': readPeerHeldSettled,
|
|
1755
|
+
'peer.idle_subscription': readPeerIdleSubscription,
|
|
1756
|
+
'classifier.denial_limit': readClassifierDenialLimit,
|
|
1757
|
+
'task.late_approval': readTaskLateApproval,
|
|
1758
|
+
'task.halt_unconsumed': readTaskHaltUnconsumed,
|
|
1759
|
+
'steering.parked_input_blocked': readSteeringParkedInputBlocked,
|
|
1760
|
+
'delegation.delivery_discarded': readDeliveryDiscarded,
|
|
1124
1761
|
});
|
|
1125
1762
|
const _factReaderTablePin = true;
|
|
1126
1763
|
void _factReaderTablePin;
|
|
@@ -1128,10 +1765,10 @@ export function readEngineNoticeFacts(notice) {
|
|
|
1128
1765
|
try {
|
|
1129
1766
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1130
1767
|
return undefined;
|
|
1131
|
-
const code =
|
|
1768
|
+
const code = envelopeSeat(notice, 'code');
|
|
1132
1769
|
if (typeof code !== 'string' || !Object.hasOwn(ENGINE_NOTICE_FACT_READERS, code))
|
|
1133
1770
|
return undefined;
|
|
1134
|
-
const detail =
|
|
1771
|
+
const detail = envelopeSeat(notice, 'detail');
|
|
1135
1772
|
const k = code;
|
|
1136
1773
|
const facts = ENGINE_NOTICE_FACT_READERS[k]({ code: k, detail });
|
|
1137
1774
|
if (facts === undefined)
|