@sema-agent/client-core 0.88.0 → 0.90.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +208 -0
  2. package/README.md +27 -21
  3. package/dist/adapter/activeRunSelfHeal.js +4 -2
  4. package/dist/adapter/downstream/eventToSdkMessage.js +4 -2
  5. package/dist/adapter/downstream/wiringManifestView.d.ts +9 -0
  6. package/dist/adapter/downstream/wiringManifestView.js +27 -0
  7. package/dist/adapter/runStream.d.ts +2 -0
  8. package/dist/adapter/runStream.js +157 -32
  9. package/dist/attachmentsWireCaps.d.ts +13 -2
  10. package/dist/attachmentsWireCaps.js +25 -5
  11. package/dist/controlRouter.d.ts +7 -1
  12. package/dist/controlRouter.js +43 -1
  13. package/dist/coreValuePorts.d.ts +1 -0
  14. package/dist/disableSkillsWire.d.ts +17 -0
  15. package/dist/disableSkillsWire.js +52 -0
  16. package/dist/displayUntrusted.js +122 -55
  17. package/dist/engineCapReader.js +12 -1
  18. package/dist/engineNoticeCodes.d.ts +25 -9
  19. package/dist/engineNoticeCodes.js +161 -68
  20. package/dist/fileHistoryLegNotice.d.ts +20 -0
  21. package/dist/fileHistoryLegNotice.js +122 -0
  22. package/dist/gateOutcome.d.ts +1 -1
  23. package/dist/gateOutcome.js +1 -0
  24. package/dist/generated/engineFactTables.d.ts +1 -0
  25. package/dist/generated/engineFactTables.js +3 -0
  26. package/dist/generated/engineNoticeTables.d.ts +3 -0
  27. package/dist/generated/engineNoticeTables.js +107 -2
  28. package/dist/hitl/toolApprovalWire.d.ts +6 -2
  29. package/dist/hitl/toolApprovalWire.js +30 -0
  30. package/dist/hookToolAliases.d.ts +3 -0
  31. package/dist/hookToolAliases.js +10 -0
  32. package/dist/hooksWireCaps.js +80 -12
  33. package/dist/index.d.ts +14 -3
  34. package/dist/index.js +10 -3
  35. package/dist/permissionsAllowGrantCapability.d.ts +17 -0
  36. package/dist/permissionsAllowGrantCapability.js +75 -0
  37. package/dist/permissionsDeclaration.d.ts +25 -0
  38. package/dist/permissionsDeclaration.js +227 -0
  39. package/dist/pluginHooksWire.d.ts +46 -4
  40. package/dist/pluginHooksWire.js +277 -24
  41. package/dist/promptDelivery.d.ts +5 -2
  42. package/dist/promptDelivery.js +8 -3
  43. package/dist/providerRejection.d.ts +7 -0
  44. package/dist/providerRejection.js +58 -0
  45. package/dist/request/taskRequest.d.ts +2 -0
  46. package/dist/request/taskRequest.js +67 -9
  47. package/dist/runTerminal.d.ts +6 -0
  48. package/dist/runTerminal.js +23 -0
  49. package/dist/sdkRegistryTransit.d.ts +1 -0
  50. package/dist/sdkRegistryTransit.js +1 -0
  51. package/dist/seam.d.ts +3 -0
  52. package/dist/seatContract.d.ts +9 -1
  53. package/dist/seatContract.js +10 -0
  54. package/dist/subagent/engineSubagentSteer.d.ts +8 -1
  55. package/dist/subagent/engineSubagentSteer.js +26 -3
  56. package/dist/supportFloor.d.ts +10 -0
  57. package/dist/supportFloor.js +42 -0
  58. package/dist/taskRequestWords.d.ts +1 -0
  59. package/dist/taskRequestWords.js +14 -0
  60. package/docs/INTEGRATION-CLIENTS.md +896 -14
  61. package/package.json +3 -3
@@ -1,25 +1,19 @@
1
1
  import { AUTO_MODE_UNAVAILABLE_CAUSES } from './autoModeUnavailable.js';
2
- import { CORE_ENGINE_NOTICE_CODES, CORE_MCP_INJECTION_DROP_REASONS, CORE_NOTICE_AUDIENCE } from './generated/engineNoticeTables.js';
2
+ import { CORE_ENGINE_NOTICE_CODES, CORE_MCP_INJECTION_DROP_REASONS, CORE_NOTICE_AUDIENCE, } from './generated/engineNoticeTables.js';
3
3
  import { CORE_ASK_UNRESOLVABLE_CAUSES, CORE_DURABLE_MANDATE_SOURCES, CORE_PERMISSION_MODE_FOLD_REASONS, } from './generated/engineFactTables.js';
4
4
  export const ENGINE_NOTICE_CODES = CORE_ENGINE_NOTICE_CODES;
5
5
  const CATALOG = new Set(ENGINE_NOTICE_CODES);
6
- export const SERVER_NOTICE_AUDIENCE = Object.freeze({
7
- 'instructions.source_changed': 'user',
8
- 'memory.layer_locked_legacy': 'operator',
9
- 'session.records_skipped': 'user',
10
- 'server.model_unreachable': 'user',
11
- });
12
6
  function audienceRow(table, code) {
13
7
  return Object.hasOwn(table, code) ? table[code] : undefined;
14
8
  }
15
9
  export function engineNoticeInCatalog(code) {
16
- return typeof code === 'string' && (CATALOG.has(code) || Object.hasOwn(SERVER_NOTICE_AUDIENCE, code));
10
+ return typeof code === 'string' && CATALOG.has(code);
17
11
  }
18
12
  export const ENGINE_NOTICE_AUDIENCE = CORE_NOTICE_AUDIENCE;
19
13
  export function noticeAudienceOf(code) {
20
14
  if (typeof code !== 'string')
21
15
  return 'operator';
22
- return audienceRow(ENGINE_NOTICE_AUDIENCE, code) ?? audienceRow(SERVER_NOTICE_AUDIENCE, code) ?? 'operator';
16
+ return audienceRow(ENGINE_NOTICE_AUDIENCE, code) ?? 'operator';
23
17
  }
24
18
  export const MCP_INJECTION_DROP_REASONS = CORE_MCP_INJECTION_DROP_REASONS;
25
19
  const DROP_REASONS = new Set(MCP_INJECTION_DROP_REASONS);
@@ -27,9 +21,9 @@ export function readMcpInjectionDrop(notice) {
27
21
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
28
22
  return undefined;
29
23
  const n = notice;
30
- if (n.code !== 'mcp.injection_dropped')
24
+ if (ownSeat(n, 'code') !== 'mcp.injection_dropped')
31
25
  return undefined;
32
- const d = n.detail;
26
+ const d = ownSeat(n, 'detail');
33
27
  if (typeof d !== 'object' || d === null || Array.isArray(d))
34
28
  return undefined;
35
29
  const o = d;
@@ -59,9 +53,9 @@ export function readAskUnresolvable(notice) {
59
53
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
60
54
  return undefined;
61
55
  const n = notice;
62
- if (n.code !== 'delegation.ask_unresolvable')
56
+ if (ownSeat(n, 'code') !== 'delegation.ask_unresolvable')
63
57
  return undefined;
64
- const d = n.detail;
58
+ const d = ownSeat(n, 'detail');
65
59
  if (typeof d !== 'object' || d === null || Array.isArray(d))
66
60
  return undefined;
67
61
  const o = d;
@@ -93,9 +87,9 @@ export function readDurableGateUnavailable(notice) {
93
87
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
94
88
  return undefined;
95
89
  const n = notice;
96
- if (n.code !== 'config.durable_gate_unavailable')
90
+ if (ownSeat(n, 'code') !== 'config.durable_gate_unavailable')
97
91
  return undefined;
98
- const d = n.detail;
92
+ const d = ownSeat(n, 'detail');
99
93
  if (typeof d !== 'object' || d === null || Array.isArray(d))
100
94
  return undefined;
101
95
  const o = d;
@@ -138,9 +132,9 @@ export function readSkillsListingTruncated(notice) {
138
132
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
139
133
  return undefined;
140
134
  const n = notice;
141
- if (n.code !== 'skills.listing_truncated')
135
+ if (ownSeat(n, 'code') !== 'skills.listing_truncated')
142
136
  return undefined;
143
- const d = n.detail;
137
+ const d = ownSeat(n, 'detail');
144
138
  if (typeof d !== 'object' || d === null || Array.isArray(d))
145
139
  return undefined;
146
140
  const o = d;
@@ -170,9 +164,9 @@ export function readMcpServerRedialed(notice) {
170
164
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
171
165
  return undefined;
172
166
  const n = notice;
173
- if (n.code !== 'mcp.server_redialed')
167
+ if (ownSeat(n, 'code') !== 'mcp.server_redialed')
174
168
  return undefined;
175
- const d = n.detail;
169
+ const d = ownSeat(n, 'detail');
176
170
  if (typeof d !== 'object' || d === null || Array.isArray(d))
177
171
  return undefined;
178
172
  const o = d;
@@ -205,9 +199,10 @@ function readRootGrantNoticeOf(notice) {
205
199
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
206
200
  return undefined;
207
201
  const n = notice;
208
- if (n.code !== 'approval.read_root_granted' && n.code !== 'approval.read_root_grant_rejected')
202
+ const code = ownSeat(n, 'code');
203
+ if (code !== 'approval.read_root_granted' && code !== 'approval.read_root_grant_rejected')
209
204
  return undefined;
210
- const d = n.detail;
205
+ const d = ownSeat(n, 'detail');
211
206
  if (typeof d !== 'object' || d === null || Array.isArray(d))
212
207
  return undefined;
213
208
  const o = d;
@@ -216,7 +211,7 @@ function readRootGrantNoticeOf(notice) {
216
211
  if (toolCallId === undefined)
217
212
  return undefined;
218
213
  const sessionId = str(o.sessionId);
219
- if (n.code === 'approval.read_root_granted') {
214
+ if (code === 'approval.read_root_granted') {
220
215
  const dir = str(o.dir);
221
216
  const root = str(o.root);
222
217
  if (dir === undefined || root === undefined)
@@ -248,9 +243,9 @@ export function readInstructionsSourceChanged(notice) {
248
243
  return undefined;
249
244
  try {
250
245
  const n = notice;
251
- if (n.code !== 'instructions.source_changed')
246
+ if (ownSeat(n, 'code') !== 'instructions.source_changed')
252
247
  return undefined;
253
- const d = n.detail;
248
+ const d = ownSeat(n, 'detail');
254
249
  if (typeof d !== 'object' || d === null || Array.isArray(d))
255
250
  return undefined;
256
251
  const o = d;
@@ -274,9 +269,9 @@ export function readSessionRecordsSkipped(notice) {
274
269
  return undefined;
275
270
  try {
276
271
  const n = notice;
277
- if (n.code !== 'session.records_skipped')
272
+ if (ownSeat(n, 'code') !== 'session.records_skipped')
278
273
  return undefined;
279
- const d = n.detail;
274
+ const d = ownSeat(n, 'detail');
280
275
  if (typeof d !== 'object' || d === null || Array.isArray(d))
281
276
  return undefined;
282
277
  const o = d;
@@ -320,9 +315,9 @@ function readRuleStoreUnavailableOf(notice) {
320
315
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
321
316
  return undefined;
322
317
  const n = notice;
323
- if (n.code !== 'permission.rule_store_unavailable')
318
+ if (ownSeat(n, 'code') !== 'permission.rule_store_unavailable')
324
319
  return undefined;
325
- const d = n.detail;
320
+ const d = ownSeat(n, 'detail');
326
321
  if (typeof d !== 'object' || d === null || Array.isArray(d))
327
322
  return undefined;
328
323
  const o = d;
@@ -344,9 +339,9 @@ function readClassifierUnavailableOf(notice) {
344
339
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
345
340
  return undefined;
346
341
  const n = notice;
347
- if (n.code !== 'classifier.unavailable')
342
+ if (ownSeat(n, 'code') !== 'classifier.unavailable')
348
343
  return undefined;
349
- const d = n.detail;
344
+ const d = ownSeat(n, 'detail');
350
345
  if (typeof d !== 'object' || d === null || Array.isArray(d))
351
346
  return undefined;
352
347
  const o = d;
@@ -380,9 +375,9 @@ function readPermissionModeUnavailableOf(notice) {
380
375
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
381
376
  return undefined;
382
377
  const n = notice;
383
- if (n.code !== 'config.permission_mode_unavailable')
378
+ if (ownSeat(n, 'code') !== 'config.permission_mode_unavailable')
384
379
  return undefined;
385
- const d = n.detail;
380
+ const d = ownSeat(n, 'detail');
386
381
  if (typeof d !== 'object' || d === null || Array.isArray(d))
387
382
  return undefined;
388
383
  const o = d;
@@ -405,9 +400,9 @@ function readAskReleasedByModeOf(notice) {
405
400
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
406
401
  return undefined;
407
402
  const n = notice;
408
- if (n.code !== 'permission.ask_released_by_mode')
403
+ if (ownSeat(n, 'code') !== 'permission.ask_released_by_mode')
409
404
  return undefined;
410
- const d = n.detail;
405
+ const d = ownSeat(n, 'detail');
411
406
  if (typeof d !== 'object' || d === null || Array.isArray(d))
412
407
  return undefined;
413
408
  const o = d;
@@ -440,9 +435,9 @@ function readReadDenyUnappliedOf(notice) {
440
435
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
441
436
  return undefined;
442
437
  const n = notice;
443
- if (n.code !== 'permission.read_deny_unapplied')
438
+ if (ownSeat(n, 'code') !== 'permission.read_deny_unapplied')
444
439
  return undefined;
445
- const d = n.detail;
440
+ const d = ownSeat(n, 'detail');
446
441
  if (typeof d !== 'object' || d === null || Array.isArray(d))
447
442
  return undefined;
448
443
  const o = d;
@@ -459,31 +454,6 @@ function readReadDenyUnappliedOf(notice) {
459
454
  }
460
455
  return { mode, toolCallId, tiers, rows, rowCount, sessionId, runId };
461
456
  }
462
- export function readLegacyModeSeedMigrated(notice) {
463
- return guardedRead(notice, readLegacyModeSeedMigratedOf);
464
- }
465
- function readLegacyModeSeedMigratedOf(notice) {
466
- if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
467
- return undefined;
468
- const n = notice;
469
- if (n.code !== 'resume.legacy_mode_seed_migrated')
470
- return undefined;
471
- const d = n.detail;
472
- if (typeof d !== 'object' || d === null || Array.isArray(d))
473
- return undefined;
474
- const o = d;
475
- const m = o.migrated;
476
- if (typeof m !== 'object' || m === null || Array.isArray(m))
477
- return undefined;
478
- const mo = m;
479
- const droppedKeys = nameList(mo.droppedKeys);
480
- const sessionId = nonEmpty(o.sessionId);
481
- const runId = nonEmpty(o.runId);
482
- if (droppedKeys === undefined || sessionId === undefined || runId === undefined)
483
- return undefined;
484
- const permissionMode = nonEmpty(optionalSeat(mo, 'permissionMode'));
485
- return { ...(permissionMode !== undefined ? { permissionMode } : {}), droppedKeys, sessionId, runId };
486
- }
487
457
  export function readToolTurnRepaired(notice) {
488
458
  return guardedRead(notice, readToolTurnRepairedOf);
489
459
  }
@@ -502,9 +472,9 @@ function readToolTurnRepairedOf(notice) {
502
472
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
503
473
  return undefined;
504
474
  const n = notice;
505
- if (n.code !== 'context.tool_turn_repaired')
475
+ if (ownSeat(n, 'code') !== 'context.tool_turn_repaired')
506
476
  return undefined;
507
- const d = n.detail;
477
+ const d = ownSeat(n, 'detail');
508
478
  if (typeof d !== 'object' || d === null || Array.isArray(d))
509
479
  return undefined;
510
480
  const o = d;
@@ -537,9 +507,9 @@ function readModelUnreachableOf(notice) {
537
507
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
538
508
  return undefined;
539
509
  const n = notice;
540
- if (n.code !== 'server.model_unreachable')
510
+ if (ownSeat(n, 'code') !== 'server.model_unreachable')
541
511
  return undefined;
542
- const d = n.detail;
512
+ const d = ownSeat(n, 'detail');
543
513
  if (typeof d !== 'object' || d === null || Array.isArray(d))
544
514
  return undefined;
545
515
  const o = d;
@@ -552,6 +522,127 @@ function readModelUnreachableOf(notice) {
552
522
  const proxyInUse = nonEmpty(optionalOwnSeat(o, 'proxyInUse'));
553
523
  return { code, targetHost, ...(proxyInUse !== undefined ? { proxyInUse } : {}), remedy, sessionId };
554
524
  }
525
+ const positiveInt = (v) => (typeof v === 'number' && Number.isInteger(v) && v > 0 ? v : undefined);
526
+ export function readToolTurnIncomplete(notice) {
527
+ return guardedRead(notice, readToolTurnIncompleteOf);
528
+ }
529
+ function optionalNameList(o, key) {
530
+ try {
531
+ const ids = nameList(ownSeat(o, key));
532
+ return ids !== undefined && ids.length > 0 ? ids : undefined;
533
+ }
534
+ catch {
535
+ return undefined;
536
+ }
537
+ }
538
+ function readToolTurnIncompleteOf(notice) {
539
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
540
+ return undefined;
541
+ const n = notice;
542
+ if (ownSeat(n, 'code') !== 'task.tool_turn_incomplete')
543
+ return undefined;
544
+ const d = ownSeat(n, 'detail');
545
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
546
+ return undefined;
547
+ const o = d;
548
+ const cause = nonEmpty(ownSeat(o, 'cause'));
549
+ const count = positiveInt(ownSeat(o, 'count'));
550
+ const toolCallIds = optionalNameList(o, 'toolCallIds');
551
+ const sessionId = nonEmpty(ownSeat(o, 'sessionId'));
552
+ const runId = nonEmpty(ownSeat(o, 'runId'));
553
+ if (cause === undefined || count === undefined || sessionId === undefined || runId === undefined)
554
+ return undefined;
555
+ return { cause, count, ...(toolCallIds !== undefined ? { toolCallIds } : {}), sessionId, runId };
556
+ }
557
+ export function readUserInputUndrained(notice) {
558
+ return guardedRead(notice, readUserInputUndrainedOf);
559
+ }
560
+ function readUserInputUndrainedOf(notice) {
561
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
562
+ return undefined;
563
+ const n = notice;
564
+ const code = ownSeat(n, 'code');
565
+ const kind = code === 'task.user_steer_undrained' ? 'steer' : code === 'task.user_followup_undrained' ? 'followUp' : undefined;
566
+ if (kind === undefined)
567
+ return undefined;
568
+ const d = ownSeat(n, 'detail');
569
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
570
+ return undefined;
571
+ const o = d;
572
+ const count = positiveInt(ownSeat(o, kind));
573
+ if (count === undefined)
574
+ return undefined;
575
+ const cause = nonEmpty(optionalOwnSeat(o, 'cause'));
576
+ const taskId = nonEmpty(optionalOwnSeat(o, 'taskId'));
577
+ const sessionId = nonEmpty(optionalOwnSeat(o, 'sessionId'));
578
+ const runId = nonEmpty(optionalOwnSeat(o, 'runId'));
579
+ const childSessionId = nonEmpty(optionalOwnSeat(o, 'childSessionId'));
580
+ return {
581
+ kind,
582
+ count,
583
+ ...(cause !== undefined ? { cause } : {}),
584
+ ...(taskId !== undefined ? { taskId } : {}),
585
+ ...(sessionId !== undefined ? { sessionId } : {}),
586
+ ...(runId !== undefined ? { runId } : {}),
587
+ ...(childSessionId !== undefined ? { childSessionId } : {}),
588
+ };
589
+ }
590
+ const messagesPhrase = (n, noun) => `${n} ${noun}${n === 1 ? '' : 's'}`;
591
+ const verbBe = (n) => (n === 1 ? 'was' : 'were');
592
+ const itThem = (n) => (n === 1 ? 'it' : 'them');
593
+ const STEER_UNDRAINED_SENTENCE = Object.freeze({
594
+ leg_end: (n) => `${messagesPhrase(n, 'message')} you sent while the run was in progress ${verbBe(n)} not used before the run ended and will not be delivered. ` +
595
+ `Send ${itThem(n)} again if you still need ${itThem(n)}.`,
596
+ crashed: (n) => `${messagesPhrase(n, 'message')} you sent to an earlier run ${verbBe(n)} accepted, but the server stopped before that run finished, ` +
597
+ `so whether the run used ${itThem(n)} is not known. Check that run's transcript and results before sending ${itThem(n)} again.`,
598
+ });
599
+ const _steerSentencePin = true;
600
+ void _steerSentencePin;
601
+ const followUpUndrainedSentence = (n) => `${messagesPhrase(n, 'follow-up message')} you queued ${verbBe(n)} not used before the run ended and will not be delivered. ` +
602
+ `Send ${itThem(n)} again if you still need ${itThem(n)}.`;
603
+ const subagentSteerUndrainedSentence = (n) => `${messagesPhrase(n, 'message')} you sent while the run was in progress ${verbBe(n)} not used before a sub-agent's run ended and will not be delivered. ` +
604
+ `Send ${itThem(n)} again if you still need ${itThem(n)}.`;
605
+ const subagentFollowUpUndrainedSentence = (n) => `${messagesPhrase(n, 'follow-up message')} you queued ${verbBe(n)} not used before a sub-agent's run ended and will not be delivered. ` +
606
+ `Send ${itThem(n)} again if you still need ${itThem(n)}.`;
607
+ 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, ` +
608
+ `and the reason was not reported in a form this version recognizes. Check the run's transcript before sending ${itThem(n)} again.`;
609
+ export function userInputUndrainedNotice(facts) {
610
+ let kind;
611
+ let count;
612
+ let cause;
613
+ let child;
614
+ try {
615
+ if (facts === null || typeof facts !== 'object' || Array.isArray(facts))
616
+ return undefined;
617
+ kind = Object.hasOwn(facts, 'kind') ? facts.kind : undefined;
618
+ count = Object.hasOwn(facts, 'count') ? facts.count : undefined;
619
+ cause = Object.hasOwn(facts, 'cause') ? facts.cause : undefined;
620
+ }
621
+ catch {
622
+ return undefined;
623
+ }
624
+ try {
625
+ child = Object.hasOwn(facts, 'childSessionId') ? facts.childSessionId : undefined;
626
+ }
627
+ catch {
628
+ child = undefined;
629
+ }
630
+ const fromSubagent = typeof child === 'string' && child.length > 0;
631
+ const n = positiveInt(count);
632
+ if (n === undefined || (kind !== 'steer' && kind !== 'followUp'))
633
+ return undefined;
634
+ if (kind === 'followUp') {
635
+ if (cause === undefined || cause === 'leg_end')
636
+ return fromSubagent ? subagentFollowUpUndrainedSentence(n) : followUpUndrainedSentence(n);
637
+ return unrecognizedUndrainedSentence(n, kind);
638
+ }
639
+ if (cause === 'leg_end' && fromSubagent)
640
+ return subagentSteerUndrainedSentence(n);
641
+ if (typeof cause === 'string' && Object.hasOwn(STEER_UNDRAINED_SENTENCE, cause)) {
642
+ return STEER_UNDRAINED_SENTENCE[cause](n);
643
+ }
644
+ return unrecognizedUndrainedSentence(n, kind);
645
+ }
555
646
  export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
556
647
  'mcp.injection_dropped': readMcpInjectionDrop,
557
648
  'delegation.ask_unresolvable': readAskUnresolvable,
@@ -567,9 +658,11 @@ export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
567
658
  'config.permission_mode_unavailable': readPermissionModeUnavailable,
568
659
  'permission.ask_released_by_mode': readAskReleasedByMode,
569
660
  'permission.read_deny_unapplied': readReadDenyUnapplied,
570
- 'resume.legacy_mode_seed_migrated': readLegacyModeSeedMigrated,
571
661
  'context.tool_turn_repaired': readToolTurnRepaired,
572
662
  'server.model_unreachable': readModelUnreachable,
663
+ 'task.tool_turn_incomplete': readToolTurnIncomplete,
664
+ 'task.user_steer_undrained': readUserInputUndrained,
665
+ 'task.user_followup_undrained': readUserInputUndrained,
573
666
  });
574
667
  const _factReaderTablePin = true;
575
668
  void _factReaderTablePin;
@@ -579,10 +672,10 @@ export function readEngineNoticeFacts(notice) {
579
672
  let code;
580
673
  let detail;
581
674
  try {
582
- code = notice.code;
675
+ code = ownSeat(notice, 'code');
583
676
  if (typeof code !== 'string' || !Object.hasOwn(ENGINE_NOTICE_FACT_READERS, code))
584
677
  return undefined;
585
- detail = notice.detail;
678
+ detail = ownSeat(notice, 'detail');
586
679
  }
587
680
  catch {
588
681
  return undefined;
@@ -0,0 +1,20 @@
1
+ import type { AgentEvent } from '@sema-agent/sdk';
2
+ import { type FileHistoryCaptureReading } from './fileHistoryCaptureCapability.js';
3
+ export type FileHistoryDeclarationFact = 'sent' | 'not_sent' | 'unknown';
4
+ export declare const FILE_HISTORY_LEG_VERDICTS: readonly ["not_honored", "not_offered", "honored", "not_declared", "unknown"];
5
+ export type FileHistoryLegNoticeVerdict = (typeof FILE_HISTORY_LEG_VERDICTS)[number];
6
+ export interface FileHistoryLegNoticeInput {
7
+ readonly capability: FileHistoryCaptureReading;
8
+ readonly declaration: FileHistoryDeclarationFact;
9
+ readonly captureOffByUser: boolean;
10
+ readonly legWord: string | undefined;
11
+ }
12
+ export declare function fileHistoryLegNoticeVerdict(input: FileHistoryLegNoticeInput): FileHistoryLegNoticeVerdict;
13
+ export declare function fileHistoryLegNoticeSentence(verdict: FileHistoryLegNoticeVerdict): string | null;
14
+ export declare function fileHistoryDeclarationOfBody(body: object | null | undefined): FileHistoryDeclarationFact;
15
+ export interface FileHistoryDeclarationLedger {
16
+ declared(requestKey: string, fact: FileHistoryDeclarationFact): boolean;
17
+ boundToRun(requestKey: string, runId: string, event: AgentEvent): boolean;
18
+ declarationOf(runId: string): FileHistoryDeclarationFact;
19
+ }
20
+ export declare function createFileHistoryDeclarationLedger(): FileHistoryDeclarationLedger;
@@ -0,0 +1,122 @@
1
+ import { fileHistoryCaptureMode } from './fileHistoryCaptureCapability.js';
2
+ import { frameProvesDelivery } from './promptDelivery.js';
3
+ import { FILE_HISTORY_DISABLED } from './request/taskRequest.js';
4
+ export const FILE_HISTORY_LEG_VERDICTS = Object.freeze(['not_honored', 'not_offered', 'honored', 'not_declared', 'unknown']);
5
+ function ownRead(o, key) {
6
+ return Object.hasOwn(o, key) ? o[key] : undefined;
7
+ }
8
+ function declarationOfInput(v) {
9
+ return v === 'sent' || v === 'not_sent' ? v : 'unknown';
10
+ }
11
+ export function fileHistoryLegNoticeVerdict(input) {
12
+ if (typeof input !== 'object' || input === null)
13
+ return 'unknown';
14
+ let capability;
15
+ let declaration;
16
+ let offByUser;
17
+ let legWord;
18
+ try {
19
+ capability = ownRead(input, 'capability');
20
+ declaration = declarationOfInput(ownRead(input, 'declaration'));
21
+ offByUser = ownRead(input, 'captureOffByUser') === true;
22
+ legWord = ownRead(input, 'legWord');
23
+ }
24
+ catch {
25
+ return 'unknown';
26
+ }
27
+ if (legWord !== 'on' && legWord !== FILE_HISTORY_DISABLED)
28
+ return 'unknown';
29
+ if (declaration === 'sent')
30
+ return legWord === 'on' ? 'not_honored' : 'honored';
31
+ if (!offByUser)
32
+ return 'not_declared';
33
+ const mode = fileHistoryCaptureMode(capability);
34
+ if (legWord === 'on' && mode === 'on-always')
35
+ return 'not_offered';
36
+ if (declaration === 'not_sent' && (legWord === FILE_HISTORY_DISABLED || mode === 'on-optional'))
37
+ return 'not_declared';
38
+ return 'unknown';
39
+ }
40
+ const NOT_HONORED_SENTENCE = 'The engine is still capturing file history for this session, though your settings asked it not to.';
41
+ const NOT_OFFERED_SENTENCE = 'This engine always captures file history and cannot turn it off per session, even though file checkpoints are off in your settings.';
42
+ export function fileHistoryLegNoticeSentence(verdict) {
43
+ if (verdict === 'not_honored')
44
+ return NOT_HONORED_SENTENCE;
45
+ if (verdict === 'not_offered')
46
+ return NOT_OFFERED_SENTENCE;
47
+ return null;
48
+ }
49
+ export function fileHistoryDeclarationOfBody(body) {
50
+ if (typeof body !== 'object' || body === null)
51
+ return 'unknown';
52
+ try {
53
+ if (Array.isArray(body))
54
+ return 'unknown';
55
+ if (typeof body.toJSON === 'function')
56
+ return 'unknown';
57
+ const d = Object.getOwnPropertyDescriptor(body, 'fileHistory');
58
+ const all = Object.getOwnPropertyDescriptors(body);
59
+ for (const k of Reflect.ownKeys(all)) {
60
+ const x = all[k];
61
+ if (x !== undefined && x.enumerable === true && !Object.hasOwn(x, 'value'))
62
+ return 'unknown';
63
+ }
64
+ const listed = Object.hasOwn(all, 'fileHistory') ? all.fileHistory : undefined;
65
+ const listedOn = listed !== undefined && listed.enumerable === true;
66
+ if (d === undefined || d.enumerable !== true)
67
+ return listedOn ? 'unknown' : 'not_sent';
68
+ if (!Object.hasOwn(d, 'value') || !listedOn || !Object.hasOwn(listed, 'value') || !Object.is(listed.value, d.value))
69
+ return 'unknown';
70
+ if (!Object.is(body.fileHistory, d.value))
71
+ return 'unknown';
72
+ if (typeof d.value === 'object' && d.value !== null)
73
+ return 'unknown';
74
+ return d.value === FILE_HISTORY_DISABLED ? 'sent' : 'not_sent';
75
+ }
76
+ catch {
77
+ return 'unknown';
78
+ }
79
+ }
80
+ const idOk = (v) => typeof v === 'string' && v.length > 0;
81
+ export function createFileHistoryDeclarationLedger() {
82
+ const factsByKey = new Map();
83
+ const keysByRun = new Map();
84
+ return Object.freeze({
85
+ declared(requestKey, fact) {
86
+ if (!idOk(requestKey) || (fact !== 'sent' && fact !== 'not_sent'))
87
+ return false;
88
+ let set = factsByKey.get(requestKey);
89
+ if (set === undefined)
90
+ factsByKey.set(requestKey, (set = new Set()));
91
+ set.add(fact);
92
+ return true;
93
+ },
94
+ boundToRun(requestKey, runId, event) {
95
+ if (!idOk(requestKey) || !idOk(runId) || !frameProvesDelivery(event))
96
+ return false;
97
+ let set = keysByRun.get(runId);
98
+ if (set === undefined)
99
+ keysByRun.set(runId, (set = new Set()));
100
+ set.add(requestKey);
101
+ return true;
102
+ },
103
+ declarationOf(runId) {
104
+ if (!idOk(runId))
105
+ return 'unknown';
106
+ const keys = keysByRun.get(runId);
107
+ if (keys === undefined)
108
+ return 'unknown';
109
+ let agreed;
110
+ for (const k of keys) {
111
+ const facts = factsByKey.get(k);
112
+ if (facts === undefined || facts.size !== 1)
113
+ return 'unknown';
114
+ const [only] = facts;
115
+ if (only === undefined || (agreed !== undefined && agreed !== only))
116
+ return 'unknown';
117
+ agreed = only;
118
+ }
119
+ return agreed ?? 'unknown';
120
+ },
121
+ });
122
+ }
@@ -40,7 +40,7 @@ export interface SettlementWhoView {
40
40
  approver?: string;
41
41
  window?: string;
42
42
  }
43
- export declare const SETTLEMENT_KIND_WORDS: readonly ["human_allowed", "human_refused", "approval_window_expired", "denial_limit_window_expired", "park_sla_expired", "no_approver", "approver_unavailable", "approver_error", "approver_contract", "presentation_failed", "blanket_allow_refused", "policy_refused", "task_aborted"];
43
+ export declare const SETTLEMENT_KIND_WORDS: readonly ["human_allowed", "human_refused", "approval_window_expired", "denial_limit_window_expired", "park_sla_expired", "no_approver", "approver_unavailable", "approver_error", "approver_contract", "presentation_failed", "blanket_allow_refused", "policy_allowed", "policy_refused", "task_aborted"];
44
44
  export interface SettlementView {
45
45
  kind: Settlement['kind'] | (string & {});
46
46
  who: SettlementWhoView;
@@ -20,6 +20,7 @@ export const SETTLEMENT_KIND_WORDS = Object.freeze([
20
20
  'approver_contract',
21
21
  'presentation_failed',
22
22
  'blanket_allow_refused',
23
+ 'policy_allowed',
23
24
  'policy_refused',
24
25
  'task_aborted',
25
26
  ]);
@@ -9,3 +9,4 @@ export declare const CORE_PERMISSION_MODE_FOLD_REASONS: readonly string[];
9
9
  export declare const CORE_ENGINE_CARD_TYPES: readonly string[];
10
10
  export declare const CORE_TOOL_DECLARATION_CODES: readonly string[];
11
11
  export declare const CORE_MODE_RELEASE_REASONS: readonly ["rule_unreadable"];
12
+ export declare const CORE_HOOK_TOOL_ALIASES: Readonly<Record<string, string>>;
@@ -114,3 +114,6 @@ export const CORE_TOOL_DECLARATION_CODES = Object.freeze([
114
114
  export const CORE_MODE_RELEASE_REASONS = Object.freeze([
115
115
  "rule_unreadable",
116
116
  ]);
117
+ export const CORE_HOOK_TOOL_ALIASES = Object.freeze(Object.assign(Object.create(null), Object.fromEntries([
118
+ ["ListPeers", "ListAgents"],
119
+ ])));
@@ -1,3 +1,6 @@
1
1
  export declare const CORE_ENGINE_NOTICE_CODES: readonly string[];
2
2
  export declare const CORE_NOTICE_AUDIENCE: Readonly<Record<string, 'user' | 'operator'>>;
3
3
  export declare const CORE_MCP_INJECTION_DROP_REASONS: readonly string[];
4
+ export declare const CORE_NOTICE_MINTER: Readonly<Record<string, 'engine' | 'server'>>;
5
+ export declare const CORE_USER_STEER_UNDRAINED_CAUSES: readonly ["leg_end", "crashed"];
6
+ export declare const CORE_TOOL_TURN_INCOMPLETE_CAUSES: readonly ["truncated", "unnamed", "bad_frame", "missing_result_synthesized"];