@sema-agent/client-core 0.108.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 +121 -0
- package/README.md +37 -24
- 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.js +1 -1
- 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 +1 -1
- package/dist/checkpointRowVerdict.js +4 -2
- package/dist/compensations.js +1 -1
- package/dist/engineAgentAbsence.d.ts +2 -0
- package/dist/engineAgentAbsence.js +28 -0
- package/dist/engineErrorCodes.d.ts +4 -0
- package/dist/engineErrorCodes.js +4 -0
- package/dist/engineHealthFacts.d.ts +17 -0
- package/dist/engineHealthFacts.js +42 -3
- package/dist/engineNoticeCodes.d.ts +128 -0
- package/dist/engineNoticeCodes.js +630 -55
- package/dist/errorSupplementRoles.js +4 -1
- package/dist/fleetTaskDesc.js +3 -3
- package/dist/generated/engineFactTables.d.ts +1 -0
- package/dist/generated/engineFactTables.js +6 -0
- package/dist/generated/engineNoticeTables.js +3 -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/approvalsFeed.js +1 -1
- package/dist/hitl/askParkRowRouting.js +5 -2
- 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/frameRouter.js +9 -1
- package/dist/hitl/hitlBridge.d.ts +4 -0
- package/dist/hitl/hitlBridge.js +9 -5
- 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 +7 -7
- 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 +2 -0
- package/dist/hitl/persistedRulesWire.js +11 -10
- package/dist/hitl/sessionAllowRoute.js +5 -4
- package/dist/hitl/standingRows.d.ts +1 -5
- package/dist/hitl/standingRows.js +15 -14
- package/dist/hitl/toolApprovalWire.d.ts +8 -2
- package/dist/hitl/toolApprovalWire.js +35 -14
- package/dist/hooksWireCaps.js +4 -3
- package/dist/hostSettingsSource.js +2 -0
- package/dist/i18n/messages.en.d.ts +168 -0
- package/dist/i18n/messages.en.js +169 -1
- package/dist/i18n/messages.zh.js +169 -1
- package/dist/index.d.ts +29 -7
- package/dist/index.js +16 -4
- 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/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/ruleReadings.js +1 -1
- package/dist/seam.d.ts +13 -2
- package/dist/seam.js +8 -1
- package/dist/seatContract.d.ts +42 -4
- package/dist/seatContract.js +180 -3
- package/dist/sessionBackground.js +2 -0
- package/dist/subagentContentStore.d.ts +12 -0
- package/dist/subagentContentStore.js +72 -11
- package/dist/toolResult.js +18 -5
- package/dist/wireFailureShape.d.ts +20 -0
- package/dist/wireFailureShape.js +37 -6
- package/dist/wireRefusalCopy.d.ts +21 -1
- package/dist/wireRefusalCopy.js +91 -2
- package/docs/INTEGRATION-CLIENTS.md +1152 -10
- package/package.json +3 -3
|
@@ -1,10 +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 { slotReadOf } from './wireFailureShape.js';
|
|
7
|
+
import { inValueOf, slotReadOf } from './wireFailureShape.js';
|
|
8
8
|
export const ENGINE_NOTICE_CODES = CORE_ENGINE_NOTICE_CODES;
|
|
9
9
|
const CATALOG = new Set(ENGINE_NOTICE_CODES);
|
|
10
10
|
function audienceRow(table, code) {
|
|
@@ -26,9 +26,9 @@ export function readMcpInjectionDrop(notice) {
|
|
|
26
26
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
27
27
|
return undefined;
|
|
28
28
|
const n = notice;
|
|
29
|
-
if (
|
|
29
|
+
if (envelopeSeat(n, 'code') !== 'mcp.injection_dropped')
|
|
30
30
|
return undefined;
|
|
31
|
-
const d =
|
|
31
|
+
const d = envelopeSeat(n, 'detail');
|
|
32
32
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
33
33
|
return undefined;
|
|
34
34
|
const o = d;
|
|
@@ -158,9 +158,9 @@ function readAskUnresolvableOf(notice) {
|
|
|
158
158
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
159
159
|
return undefined;
|
|
160
160
|
const n = notice;
|
|
161
|
-
if (
|
|
161
|
+
if (envelopeSeat(n, 'code') !== 'delegation.ask_unresolvable')
|
|
162
162
|
return undefined;
|
|
163
|
-
const d =
|
|
163
|
+
const d = envelopeSeat(n, 'detail');
|
|
164
164
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
165
165
|
return undefined;
|
|
166
166
|
const o = d;
|
|
@@ -201,9 +201,9 @@ export function readDurableGateUnavailable(notice) {
|
|
|
201
201
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
202
202
|
return undefined;
|
|
203
203
|
const n = notice;
|
|
204
|
-
if (
|
|
204
|
+
if (envelopeSeat(n, 'code') !== 'config.durable_gate_unavailable')
|
|
205
205
|
return undefined;
|
|
206
|
-
const d =
|
|
206
|
+
const d = envelopeSeat(n, 'detail');
|
|
207
207
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
208
208
|
return undefined;
|
|
209
209
|
const o = d;
|
|
@@ -246,9 +246,9 @@ export function readSkillsListingTruncated(notice) {
|
|
|
246
246
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
247
247
|
return undefined;
|
|
248
248
|
const n = notice;
|
|
249
|
-
if (
|
|
249
|
+
if (envelopeSeat(n, 'code') !== 'skills.listing_truncated')
|
|
250
250
|
return undefined;
|
|
251
|
-
const d =
|
|
251
|
+
const d = envelopeSeat(n, 'detail');
|
|
252
252
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
253
253
|
return undefined;
|
|
254
254
|
const o = d;
|
|
@@ -278,9 +278,9 @@ export function readMcpServerRedialed(notice) {
|
|
|
278
278
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
279
279
|
return undefined;
|
|
280
280
|
const n = notice;
|
|
281
|
-
if (
|
|
281
|
+
if (envelopeSeat(n, 'code') !== 'mcp.server_redialed')
|
|
282
282
|
return undefined;
|
|
283
|
-
const d =
|
|
283
|
+
const d = envelopeSeat(n, 'detail');
|
|
284
284
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
285
285
|
return undefined;
|
|
286
286
|
const o = d;
|
|
@@ -313,10 +313,10 @@ function readRootGrantNoticeOf(notice) {
|
|
|
313
313
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
314
314
|
return undefined;
|
|
315
315
|
const n = notice;
|
|
316
|
-
const code =
|
|
316
|
+
const code = envelopeSeat(n, 'code');
|
|
317
317
|
if (code !== 'approval.read_root_granted' && code !== 'approval.read_root_grant_rejected')
|
|
318
318
|
return undefined;
|
|
319
|
-
const d =
|
|
319
|
+
const d = envelopeSeat(n, 'detail');
|
|
320
320
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
321
321
|
return undefined;
|
|
322
322
|
const o = d;
|
|
@@ -330,14 +330,17 @@ function readRootGrantNoticeOf(notice) {
|
|
|
330
330
|
const root = str(o.root);
|
|
331
331
|
if (dir === undefined || root === undefined)
|
|
332
332
|
return undefined;
|
|
333
|
-
|
|
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)
|
|
334
337
|
return undefined;
|
|
335
338
|
return {
|
|
336
339
|
outcome: 'granted',
|
|
337
340
|
toolCallId,
|
|
338
341
|
dir,
|
|
339
342
|
root,
|
|
340
|
-
...(
|
|
343
|
+
...(covers.state === 'present' ? { covers: READ_ROOT_GRANT_COVERS_EXACT } : {}),
|
|
341
344
|
...(sessionId !== undefined ? { sessionId } : {}),
|
|
342
345
|
};
|
|
343
346
|
}
|
|
@@ -357,9 +360,9 @@ export function readInstructionsSourceChanged(notice) {
|
|
|
357
360
|
return undefined;
|
|
358
361
|
try {
|
|
359
362
|
const n = notice;
|
|
360
|
-
if (
|
|
363
|
+
if (envelopeSeat(n, 'code') !== 'instructions.source_changed')
|
|
361
364
|
return undefined;
|
|
362
|
-
const d =
|
|
365
|
+
const d = envelopeSeat(n, 'detail');
|
|
363
366
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
364
367
|
return undefined;
|
|
365
368
|
const o = d;
|
|
@@ -383,9 +386,9 @@ export function readSessionRecordsSkipped(notice) {
|
|
|
383
386
|
return undefined;
|
|
384
387
|
try {
|
|
385
388
|
const n = notice;
|
|
386
|
-
if (
|
|
389
|
+
if (envelopeSeat(n, 'code') !== 'session.records_skipped')
|
|
387
390
|
return undefined;
|
|
388
|
-
const d =
|
|
391
|
+
const d = envelopeSeat(n, 'detail');
|
|
389
392
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
390
393
|
return undefined;
|
|
391
394
|
const o = d;
|
|
@@ -429,9 +432,9 @@ function readRuleStoreUnavailableOf(notice) {
|
|
|
429
432
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
430
433
|
return undefined;
|
|
431
434
|
const n = notice;
|
|
432
|
-
if (
|
|
435
|
+
if (envelopeSeat(n, 'code') !== 'permission.rule_store_unavailable')
|
|
433
436
|
return undefined;
|
|
434
|
-
const d =
|
|
437
|
+
const d = envelopeSeat(n, 'detail');
|
|
435
438
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
436
439
|
return undefined;
|
|
437
440
|
const o = d;
|
|
@@ -453,9 +456,9 @@ function readClassifierUnavailableOf(notice) {
|
|
|
453
456
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
454
457
|
return undefined;
|
|
455
458
|
const n = notice;
|
|
456
|
-
if (
|
|
459
|
+
if (envelopeSeat(n, 'code') !== 'classifier.unavailable')
|
|
457
460
|
return undefined;
|
|
458
|
-
const d =
|
|
461
|
+
const d = envelopeSeat(n, 'detail');
|
|
459
462
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
460
463
|
return undefined;
|
|
461
464
|
const o = d;
|
|
@@ -490,9 +493,9 @@ function readPermissionModeUnavailableOf(notice) {
|
|
|
490
493
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
491
494
|
return undefined;
|
|
492
495
|
const n = notice;
|
|
493
|
-
if (
|
|
496
|
+
if (envelopeSeat(n, 'code') !== 'config.permission_mode_unavailable')
|
|
494
497
|
return undefined;
|
|
495
|
-
const d =
|
|
498
|
+
const d = envelopeSeat(n, 'detail');
|
|
496
499
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
497
500
|
return undefined;
|
|
498
501
|
const o = d;
|
|
@@ -515,9 +518,9 @@ function readAskReleasedByModeOf(notice) {
|
|
|
515
518
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
516
519
|
return undefined;
|
|
517
520
|
const n = notice;
|
|
518
|
-
if (
|
|
521
|
+
if (envelopeSeat(n, 'code') !== 'permission.ask_released_by_mode')
|
|
519
522
|
return undefined;
|
|
520
|
-
const d =
|
|
523
|
+
const d = envelopeSeat(n, 'detail');
|
|
521
524
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
522
525
|
return undefined;
|
|
523
526
|
const o = d;
|
|
@@ -551,9 +554,9 @@ function readReadDenyUnappliedOf(notice) {
|
|
|
551
554
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
552
555
|
return undefined;
|
|
553
556
|
const n = notice;
|
|
554
|
-
if (
|
|
557
|
+
if (envelopeSeat(n, 'code') !== 'permission.read_deny_unapplied')
|
|
555
558
|
return undefined;
|
|
556
|
-
const d =
|
|
559
|
+
const d = envelopeSeat(n, 'detail');
|
|
557
560
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
558
561
|
return undefined;
|
|
559
562
|
const o = d;
|
|
@@ -576,6 +579,9 @@ export function readToolTurnRepaired(notice) {
|
|
|
576
579
|
function ownSeat(o, key) {
|
|
577
580
|
return Object.hasOwn(o, key) ? o[key] : undefined;
|
|
578
581
|
}
|
|
582
|
+
function envelopeSeat(o, key) {
|
|
583
|
+
return readOwnDataValue(o, key);
|
|
584
|
+
}
|
|
579
585
|
function optionalOwnSeat(o, key) {
|
|
580
586
|
try {
|
|
581
587
|
return ownSeat(o, key);
|
|
@@ -597,9 +603,9 @@ function readToolTurnRepairedOf(notice) {
|
|
|
597
603
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
598
604
|
return undefined;
|
|
599
605
|
const n = notice;
|
|
600
|
-
if (
|
|
606
|
+
if (envelopeSeat(n, 'code') !== 'context.tool_turn_repaired')
|
|
601
607
|
return undefined;
|
|
602
|
-
const d =
|
|
608
|
+
const d = envelopeSeat(n, 'detail');
|
|
603
609
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
604
610
|
return undefined;
|
|
605
611
|
const o = d;
|
|
@@ -632,9 +638,9 @@ function readModelUnreachableOf(notice) {
|
|
|
632
638
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
633
639
|
return undefined;
|
|
634
640
|
const n = notice;
|
|
635
|
-
if (
|
|
641
|
+
if (envelopeSeat(n, 'code') !== 'server.model_unreachable')
|
|
636
642
|
return undefined;
|
|
637
|
-
const d =
|
|
643
|
+
const d = envelopeSeat(n, 'detail');
|
|
638
644
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
639
645
|
return undefined;
|
|
640
646
|
const o = d;
|
|
@@ -656,9 +662,9 @@ function readAllowedToolNotGrantedOf(notice) {
|
|
|
656
662
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
657
663
|
return undefined;
|
|
658
664
|
const n = notice;
|
|
659
|
-
if (
|
|
665
|
+
if (envelopeSeat(n, 'code') !== 'permission.allowed_tool_not_granted')
|
|
660
666
|
return undefined;
|
|
661
|
-
const d =
|
|
667
|
+
const d = envelopeSeat(n, 'detail');
|
|
662
668
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
663
669
|
return undefined;
|
|
664
670
|
const o = d;
|
|
@@ -718,9 +724,9 @@ function readToolTurnIncompleteOf(notice) {
|
|
|
718
724
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
719
725
|
return undefined;
|
|
720
726
|
const n = notice;
|
|
721
|
-
if (
|
|
727
|
+
if (envelopeSeat(n, 'code') !== 'task.tool_turn_incomplete')
|
|
722
728
|
return undefined;
|
|
723
|
-
const d =
|
|
729
|
+
const d = envelopeSeat(n, 'detail');
|
|
724
730
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
725
731
|
return undefined;
|
|
726
732
|
const o = d;
|
|
@@ -762,10 +768,10 @@ function readUserInputUndrainedOf(notice) {
|
|
|
762
768
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
763
769
|
return undefined;
|
|
764
770
|
const n = notice;
|
|
765
|
-
const kind = undrainedLaneOfCode(
|
|
771
|
+
const kind = undrainedLaneOfCode(envelopeSeat(n, 'code'));
|
|
766
772
|
if (kind === undefined)
|
|
767
773
|
return undefined;
|
|
768
|
-
const d =
|
|
774
|
+
const d = envelopeSeat(n, 'detail');
|
|
769
775
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
770
776
|
return undefined;
|
|
771
777
|
const o = d;
|
|
@@ -955,9 +961,9 @@ function readTurnInterruptedOf(notice) {
|
|
|
955
961
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
956
962
|
return undefined;
|
|
957
963
|
const n = notice;
|
|
958
|
-
if (
|
|
964
|
+
if (envelopeSeat(n, 'code') !== 'task.turn_interrupted')
|
|
959
965
|
return undefined;
|
|
960
|
-
const d =
|
|
966
|
+
const d = envelopeSeat(n, 'detail');
|
|
961
967
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
962
968
|
return undefined;
|
|
963
969
|
const o = d;
|
|
@@ -1002,7 +1008,7 @@ export function steerCutVerdict(notice, messageId) {
|
|
|
1002
1008
|
try {
|
|
1003
1009
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1004
1010
|
return 'not_a_cut';
|
|
1005
|
-
code =
|
|
1011
|
+
code = envelopeSeat(notice, 'code');
|
|
1006
1012
|
}
|
|
1007
1013
|
catch {
|
|
1008
1014
|
return 'not_a_cut';
|
|
@@ -1025,9 +1031,9 @@ function readFinishReasonUnknownOf(notice) {
|
|
|
1025
1031
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1026
1032
|
return undefined;
|
|
1027
1033
|
const n = notice;
|
|
1028
|
-
if (
|
|
1034
|
+
if (envelopeSeat(n, 'code') !== 'route.finish_reason_unknown')
|
|
1029
1035
|
return undefined;
|
|
1030
|
-
const d =
|
|
1036
|
+
const d = envelopeSeat(n, 'detail');
|
|
1031
1037
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1032
1038
|
return undefined;
|
|
1033
1039
|
const o = d;
|
|
@@ -1045,9 +1051,9 @@ function readStreamEndIgnoredOf(notice) {
|
|
|
1045
1051
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1046
1052
|
return undefined;
|
|
1047
1053
|
const n = notice;
|
|
1048
|
-
if (
|
|
1054
|
+
if (envelopeSeat(n, 'code') !== 'route.stream_end_ignored')
|
|
1049
1055
|
return undefined;
|
|
1050
|
-
const d =
|
|
1056
|
+
const d = envelopeSeat(n, 'detail');
|
|
1051
1057
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1052
1058
|
return undefined;
|
|
1053
1059
|
const o = d;
|
|
@@ -1067,10 +1073,10 @@ function readContextMediaRemovedOf(notice) {
|
|
|
1067
1073
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1068
1074
|
return undefined;
|
|
1069
1075
|
const n = notice;
|
|
1070
|
-
const code =
|
|
1076
|
+
const code = envelopeSeat(n, 'code');
|
|
1071
1077
|
if (code !== 'context.media_removed' && code !== 'context.image_removed')
|
|
1072
1078
|
return undefined;
|
|
1073
|
-
const d =
|
|
1079
|
+
const d = envelopeSeat(n, 'detail');
|
|
1074
1080
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1075
1081
|
return undefined;
|
|
1076
1082
|
const o = d;
|
|
@@ -1099,9 +1105,9 @@ function readMcpAuthorizationRequiredOf(notice) {
|
|
|
1099
1105
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1100
1106
|
return undefined;
|
|
1101
1107
|
const n = notice;
|
|
1102
|
-
if (
|
|
1108
|
+
if (envelopeSeat(n, 'code') !== 'mcp.authorization_required')
|
|
1103
1109
|
return undefined;
|
|
1104
|
-
const d =
|
|
1110
|
+
const d = envelopeSeat(n, 'detail');
|
|
1105
1111
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1106
1112
|
return undefined;
|
|
1107
1113
|
const o = d;
|
|
@@ -1121,9 +1127,9 @@ function readSessionLineageRerootedOf(notice) {
|
|
|
1121
1127
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1122
1128
|
return undefined;
|
|
1123
1129
|
const n = notice;
|
|
1124
|
-
if (
|
|
1130
|
+
if (envelopeSeat(n, 'code') !== 'session.lineage_rerooted')
|
|
1125
1131
|
return undefined;
|
|
1126
|
-
const d =
|
|
1132
|
+
const d = envelopeSeat(n, 'detail');
|
|
1127
1133
|
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
1128
1134
|
return undefined;
|
|
1129
1135
|
const o = d;
|
|
@@ -1155,6 +1161,562 @@ function readSessionLineageRerootedOf(notice) {
|
|
|
1155
1161
|
return undefined;
|
|
1156
1162
|
return { break: true, leaf, missingParentId, rootedAt, entriesCut: countReading(optionalOwnSeat(o, 'entriesCut')), ...common };
|
|
1157
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
|
+
}
|
|
1158
1720
|
export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
|
|
1159
1721
|
'mcp.injection_dropped': readMcpInjectionDrop,
|
|
1160
1722
|
'delegation.ask_unresolvable': readAskUnresolvable,
|
|
@@ -1183,6 +1745,19 @@ export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
|
|
|
1183
1745
|
'context.media_removed': readContextMediaRemoved,
|
|
1184
1746
|
'context.image_removed': readContextMediaRemoved,
|
|
1185
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,
|
|
1186
1761
|
});
|
|
1187
1762
|
const _factReaderTablePin = true;
|
|
1188
1763
|
void _factReaderTablePin;
|
|
@@ -1190,10 +1765,10 @@ export function readEngineNoticeFacts(notice) {
|
|
|
1190
1765
|
try {
|
|
1191
1766
|
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
1192
1767
|
return undefined;
|
|
1193
|
-
const code =
|
|
1768
|
+
const code = envelopeSeat(notice, 'code');
|
|
1194
1769
|
if (typeof code !== 'string' || !Object.hasOwn(ENGINE_NOTICE_FACT_READERS, code))
|
|
1195
1770
|
return undefined;
|
|
1196
|
-
const detail =
|
|
1771
|
+
const detail = envelopeSeat(notice, 'detail');
|
|
1197
1772
|
const k = code;
|
|
1198
1773
|
const facts = ENGINE_NOTICE_FACT_READERS[k]({ code: k, detail });
|
|
1199
1774
|
if (facts === undefined)
|