@sema-agent/client-core 0.104.1 → 0.106.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 (175) hide show
  1. package/CHANGELOG.md +310 -0
  2. package/README.md +36 -14
  3. package/dist/adapt/arms.js +23 -6
  4. package/dist/adapter/activeRunSelfHeal.d.ts +14 -2
  5. package/dist/adapter/activeRunSelfHeal.js +90 -12
  6. package/dist/adapter/downstream/eventToSdkMessage.d.ts +0 -5
  7. package/dist/adapter/downstream/eventToSdkMessage.js +24 -23
  8. package/dist/adapter/downstream/terminalToSdkResult.js +2 -3
  9. package/dist/adapter/downstream/wiringManifestView.d.ts +7 -3
  10. package/dist/adapter/downstream/wiringManifestView.js +25 -1
  11. package/dist/adapter/runStream.js +8 -5
  12. package/dist/approvalReachWire.d.ts +1 -0
  13. package/dist/approvalReachWire.js +4 -1
  14. package/dist/approvalSeat.d.ts +21 -0
  15. package/dist/approvalSeat.js +73 -0
  16. package/dist/assistantInbox.d.ts +2 -0
  17. package/dist/assistantInbox.js +3 -0
  18. package/dist/checkpointRowVerdict.d.ts +23 -0
  19. package/dist/checkpointRowVerdict.js +89 -0
  20. package/dist/cloudConfigWireCaps.js +3 -0
  21. package/dist/compensations.js +6 -6
  22. package/dist/coreValuePorts.d.ts +14 -1
  23. package/dist/coreValuePorts.js +14 -0
  24. package/dist/decideFailureNote.js +3 -1
  25. package/dist/decideReceipt.d.ts +9 -0
  26. package/dist/decideReceipt.js +29 -1
  27. package/dist/declared/supportFloorDeclared.js +2 -2
  28. package/dist/deviceRebind.d.ts +7 -0
  29. package/dist/deviceRebind.js +39 -5
  30. package/dist/displayUntrusted.d.ts +4 -2
  31. package/dist/displayUntrusted.js +45 -22
  32. package/dist/engineAddress.d.ts +3 -0
  33. package/dist/engineAddress.js +25 -0
  34. package/dist/engineDirectory.js +9 -17
  35. package/dist/engineErrorCodes.d.ts +8 -0
  36. package/dist/engineErrorCodes.js +8 -0
  37. package/dist/engineGenerationPort.d.ts +11 -2
  38. package/dist/engineGenerationPort.js +63 -9
  39. package/dist/engineHealthFacts.d.ts +5 -0
  40. package/dist/engineHealthFacts.js +11 -0
  41. package/dist/engineNoticeCodes.d.ts +26 -3
  42. package/dist/engineNoticeCodes.js +52 -7
  43. package/dist/engineRowRef.js +1 -1
  44. package/dist/errorSupplementRoles.js +2 -0
  45. package/dist/eventLeg.d.ts +3 -3
  46. package/dist/eventLeg.js +25 -4
  47. package/dist/fleet/fleetProjection.js +26 -5
  48. package/dist/generated/engineFactTables.d.ts +3 -1
  49. package/dist/generated/engineFactTables.js +4 -1
  50. package/dist/generated/engineNoticeTables.js +19 -4
  51. package/dist/generated/sdkFactTables.d.ts +5 -0
  52. package/dist/generated/sdkFactTables.js +24 -0
  53. package/dist/generated/settingsSchemaFns.d.ts +11 -0
  54. package/dist/generated/settingsSchemaFns.js +2 -1
  55. package/dist/generated/settingsSchemaSafetyMergeSpec.js +1 -1
  56. package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -1
  57. package/dist/generated/settingsSchemaSettingsSources.js +22 -2
  58. package/dist/headlessReconnectWire.js +31 -4
  59. package/dist/hitl/approvalLiveFace.d.ts +17 -0
  60. package/dist/hitl/approvalLiveFace.js +35 -0
  61. package/dist/hitl/approvalQueueRow.d.ts +21 -0
  62. package/dist/hitl/approvalQueueRow.js +69 -0
  63. package/dist/hitl/approvalsFeed.d.ts +5 -4
  64. package/dist/hitl/approvalsFeed.js +38 -6
  65. package/dist/hitl/askGateWire.js +26 -2
  66. package/dist/hitl/askParkRowRouting.d.ts +4 -3
  67. package/dist/hitl/askParkRowRouting.js +15 -3
  68. package/dist/hitl/automaticAnswerVerdict.js +13 -10
  69. package/dist/hitl/crashConverged.d.ts +5 -1
  70. package/dist/hitl/decisionConflict.js +2 -1
  71. package/dist/hitl/decisionRefusal.js +1 -1
  72. package/dist/hitl/decisionSend.d.ts +1 -0
  73. package/dist/hitl/decisionSend.js +14 -2
  74. package/dist/hitl/frameRouter.d.ts +4 -0
  75. package/dist/hitl/frameRouter.js +18 -5
  76. package/dist/hitl/gateIdentity.d.ts +1 -0
  77. package/dist/hitl/gateIdentity.js +3 -0
  78. package/dist/hitl/hitlBridge.d.ts +1 -1
  79. package/dist/hitl/hitlBridge.js +26 -5
  80. package/dist/hitl/livePendingAsk.d.ts +5 -0
  81. package/dist/hitl/livePendingAsk.js +6 -1
  82. package/dist/hitl/planReviewCard.d.ts +23 -0
  83. package/dist/hitl/planReviewCard.js +250 -0
  84. package/dist/hitl/planReviewWire.d.ts +39 -14
  85. package/dist/hitl/planReviewWire.js +450 -163
  86. package/dist/hitl/sessionAllowRoute.d.ts +2 -0
  87. package/dist/hitl/sessionAllowRoute.js +7 -0
  88. package/dist/hitl/sessionPolicyWire.d.ts +1 -7
  89. package/dist/hitl/sessionPolicyWire.js +3 -43
  90. package/dist/hitl/subagentSource.d.ts +1 -0
  91. package/dist/hitl/subagentSource.js +13 -0
  92. package/dist/hitl/toolApprovalWire.d.ts +3 -2
  93. package/dist/hitl/toolApprovalWire.js +79 -37
  94. package/dist/hostSettingsSource.d.ts +5 -2
  95. package/dist/hostSettingsSource.js +19 -10
  96. package/dist/hostTurnSettings.d.ts +5 -6
  97. package/dist/hostTurnSettings.js +106 -26
  98. package/dist/i18n/messages.en.d.ts +85 -12
  99. package/dist/i18n/messages.en.js +85 -12
  100. package/dist/i18n/messages.zh.js +88 -12
  101. package/dist/index.d.ts +35 -4
  102. package/dist/index.js +19 -2
  103. package/dist/liveInitToolFace.js +0 -1
  104. package/dist/liveModelCatalog.d.ts +15 -0
  105. package/dist/liveModelCatalog.js +40 -0
  106. package/dist/mcpTransportKindsCapability.d.ts +18 -0
  107. package/dist/mcpTransportKindsCapability.js +75 -0
  108. package/dist/mcpWireCaps.d.ts +4 -1
  109. package/dist/mcpWireCaps.js +25 -14
  110. package/dist/modelCapabilityProbe.js +66 -33
  111. package/dist/notifications.d.ts +9 -0
  112. package/dist/notifications.js +11 -2
  113. package/dist/ownKey.d.ts +4 -1
  114. package/dist/ownKey.js +8 -2
  115. package/dist/permissionModeWriteCapability.d.ts +13 -0
  116. package/dist/permissionModeWriteCapability.js +35 -0
  117. package/dist/permissionsAllowGrantCapability.d.ts +3 -0
  118. package/dist/permissionsAllowGrantCapability.js +26 -3
  119. package/dist/permissionsDeclaration.d.ts +25 -3
  120. package/dist/permissionsDeclaration.js +69 -41
  121. package/dist/planReviewCardFacts.d.ts +116 -0
  122. package/dist/planReviewCardFacts.js +469 -0
  123. package/dist/projectSeed.d.ts +39 -0
  124. package/dist/projectSeed.js +80 -0
  125. package/dist/promptDelivery.js +1 -1
  126. package/dist/reattachWindow.d.ts +8 -1
  127. package/dist/reattachWindow.js +44 -12
  128. package/dist/replayBody.d.ts +7 -6
  129. package/dist/replayBody.js +62 -7
  130. package/dist/request/taskRequest.js +3 -4
  131. package/dist/ruleCompileVerdict.d.ts +0 -2
  132. package/dist/ruleCompileVerdict.js +0 -31
  133. package/dist/ruleRefusalSentence.js +0 -3
  134. package/dist/runFollow.d.ts +30 -0
  135. package/dist/runFollow.js +117 -0
  136. package/dist/runLedgerSnapshot.d.ts +20 -0
  137. package/dist/runLedgerSnapshot.js +272 -0
  138. package/dist/runPermissionModeSwitch.d.ts +57 -0
  139. package/dist/runPermissionModeSwitch.js +135 -0
  140. package/dist/runReattachPolicy.d.ts +16 -5
  141. package/dist/runReattachPolicy.js +72 -24
  142. package/dist/runTerminal.js +30 -8
  143. package/dist/sandboxWire.d.ts +0 -3
  144. package/dist/sandboxWire.js +0 -9
  145. package/dist/seam.d.ts +17 -7
  146. package/dist/seam.js +13 -1
  147. package/dist/seatContract.d.ts +57 -7
  148. package/dist/seatContract.js +133 -3
  149. package/dist/serverSupportRange.d.ts +18 -0
  150. package/dist/serverSupportRange.js +25 -0
  151. package/dist/sessionEngine.d.ts +156 -0
  152. package/dist/sessionEngine.js +464 -0
  153. package/dist/sessionMap.d.ts +11 -1
  154. package/dist/sessionMap.js +35 -9
  155. package/dist/sessionMemoryErase.d.ts +1 -1
  156. package/dist/sessionMemoryErase.js +5 -0
  157. package/dist/sessionMemoryStatus.d.ts +27 -1
  158. package/dist/sessionMemoryStatus.js +117 -0
  159. package/dist/sessionMemorySync.d.ts +31 -0
  160. package/dist/sessionMemorySync.js +95 -0
  161. package/dist/sessionRowTag.d.ts +4 -0
  162. package/dist/sessionRowTag.js +18 -0
  163. package/dist/settingsLayerAdmission.d.ts +1 -0
  164. package/dist/settingsLayerAdmission.js +4 -1
  165. package/dist/sseIdleTriage.d.ts +3 -1
  166. package/dist/sseIdleTriage.js +19 -4
  167. package/dist/subagent/engineSubagentTail.js +2 -0
  168. package/dist/subagentContentStore.d.ts +3 -0
  169. package/dist/subagentContentStore.js +10 -1
  170. package/dist/toolResult.js +1 -1
  171. package/dist/turnFailurePresentation.d.ts +5 -2
  172. package/dist/turnFailurePresentation.js +12 -4
  173. package/dist/wireRefusalCopy.js +2 -6
  174. package/docs/INTEGRATION-CLIENTS.md +1507 -18
  175. package/package.json +5 -5
@@ -3618,6 +3618,8 @@ class SequenceReader {
3618
3618
  if (this.atomicBlanks === 'none')
3619
3619
  return false;
3620
3620
  const cp = nameBlankTokenAt(this.text, at);
3621
+ if (this.atomicBlanks === 'fillers')
3622
+ return cp !== -1 && !isFoldedBlank(cp);
3621
3623
  return this.atomicBlanks === 'all' ? cp !== -1 : isFoldedBlank(cp);
3622
3624
  }
3623
3625
  intermediateAt(at) {
@@ -3735,6 +3737,9 @@ function nameBlankTokenAt(text, at) {
3735
3737
  const cp = Number.parseInt(hit[1] ?? '', 16);
3736
3738
  return isNameBlank(cp) ? cp : -1;
3737
3739
  }
3740
+ function isMarkedNameBlank(net, c) {
3741
+ return net === 1 ? isNameBlank(c) : net === 2 ? isNameBlank(c) && !isRegexSpace(c) : false;
3742
+ }
3738
3743
  function buildScanView(text, o) {
3739
3744
  const chars = [];
3740
3745
  const starts = [];
@@ -3743,7 +3748,7 @@ function buildScanView(text, o) {
3743
3748
  const dropped = [];
3744
3749
  const spaceUnits = [];
3745
3750
  const contents = [];
3746
- const seq = new SequenceReader(text, o.blanks ? 'all' : 'none', o.blanks || o.fold, o.fold);
3751
+ const seq = new SequenceReader(text, o.blanks === 1 ? 'all' : o.blanks === 2 ? 'fillers' : 'none', o.blanks === 1 || o.fold, o.fold);
3747
3752
  const keep = (ch, s, e, unit = UNIT_NONE) => {
3748
3753
  chars.push(ch);
3749
3754
  starts.push(s);
@@ -3814,7 +3819,7 @@ function buildScanView(text, o) {
3814
3819
  continue;
3815
3820
  }
3816
3821
  }
3817
- if (o.blanks && isNameBlank(c)) {
3822
+ if (isMarkedNameBlank(o.blanks, c)) {
3818
3823
  drop(i, i + 1);
3819
3824
  i++;
3820
3825
  continue;
@@ -3984,7 +3989,7 @@ function screenSurfaces(text, o) {
3984
3989
  i = j;
3985
3990
  continue;
3986
3991
  }
3987
- else if (unsafe !== null && unsafe.test(ch) && !faceHitKept(ch, i, text)) {
3992
+ else if (unsafe !== null && unsafe.test(ch) && !faceHitKept(ch, i, text, face.keepCrlf === true)) {
3988
3993
  form = markOf(ch, face.mark);
3989
3994
  dotted = face.mark !== 'escape';
3990
3995
  }
@@ -4636,13 +4641,16 @@ function scanAndMask(text, o, trace, stats, phaseOut) {
4636
4641
  }
4637
4642
  return cur;
4638
4643
  }
4639
- const WASH_OPTIONS = Object.freeze({ urls: true, words: true, blanks: false, fold: false, face: null, escapeSpaces: null });
4644
+ const WASH_OPTIONS = Object.freeze({ urls: true, words: true, blanks: 0, fold: false, face: null, escapeSpaces: null });
4640
4645
  export function washCredentials(text) {
4641
4646
  if (typeof text !== 'string')
4642
4647
  return text;
4643
4648
  return scanAndMask(text, WASH_OPTIONS, false).text;
4644
4649
  }
4645
4650
  const NAME_BLANKS = NAME_BLANK_RANGES.map(([a, b]) => (a === b ? classEscape(a) : `${classEscape(a)}-${classEscape(b)}`)).join('');
4651
+ const NAME_FILLERS = NAME_BLANK_RANGES.filter(([a, b]) => !isRegexSpace(a) && !isRegexSpace(b))
4652
+ .map(([a, b]) => (a === b ? classEscape(a) : `${classEscape(a)}-${classEscape(b)}`))
4653
+ .join('');
4646
4654
  function classEscape(cp) {
4647
4655
  return `\\u${cp.toString(16).toUpperCase().padStart(4, '0')}`;
4648
4656
  }
@@ -4740,10 +4748,12 @@ function joinerKept(text, at, zwj) {
4740
4748
  function emojiPresented(cp, after) {
4741
4749
  return isPictograph(cp) && (isEmojiPresentation(cp) || after === 0xfe0f || (after !== -1 && isEmojiModifier(after)));
4742
4750
  }
4743
- function faceHitKept(ch, at, text) {
4751
+ function faceHitKept(ch, at, text, crlf = false) {
4744
4752
  if (ch.length > 2)
4745
4753
  return true;
4746
4754
  const c = ch.charCodeAt(0);
4755
+ if (crlf && c === 0x0d && ch.length === 1)
4756
+ return text.charCodeAt(at + 1) === 0x0a;
4747
4757
  return ch.length === 1 && (c === 0x200d || c === 0x200c) && joinerKept(text, at, c === 0x200d);
4748
4758
  }
4749
4759
  const RGI_TAG_FLAG = '\\u{1F3F4}\\u{E0067}\\u{E0062}(?:\\u{E0065}\\u{E006E}\\u{E0067}|\\u{E0073}\\u{E0063}\\u{E0074}|\\u{E0077}\\u{E006C}\\u{E0073})\\u{E007F}';
@@ -4771,7 +4781,7 @@ const FOLD_RUN_KEEPING_BLANKS = new RegExp(`[^\\S${NAME_BLANKS}]+`, 'g');
4771
4781
  const EDGE_SPACE = /^ | $/g;
4772
4782
  const foldWhitespace = (s, keepBlanks = false) => keepBlanks ? s.replace(FOLD_RUN_KEEPING_BLANKS, ' ').replace(EDGE_SPACE, '') : s.replace(FOLD_RUN, ' ').trim();
4773
4783
  export function applyDisplayFace(text, face) {
4774
- const markAll = (s) => face.unsafe === null ? s : s.replace(face.unsafe, (ch, at, whole) => (faceHitKept(ch, at, whole) ? ch : markOf(ch, face.mark)));
4784
+ const markAll = (s) => face.unsafe === null ? s : s.replace(face.unsafe, (ch, at, whole) => (faceHitKept(ch, at, whole, face.keepCrlf === true) ? ch : markOf(ch, face.mark)));
4775
4785
  const keepBlanks = face.keepBlanks === true;
4776
4786
  if (face.mark === 'space') {
4777
4787
  const marked = markAll(text);
@@ -4779,7 +4789,7 @@ export function applyDisplayFace(text, face) {
4779
4789
  }
4780
4790
  return markAll(face.fold ? foldWhitespace(text, keepBlanks) : text);
4781
4791
  }
4782
- function markTracked(t, re, mark, ledger) {
4792
+ function markTracked(t, re, mark, ledger, crlf = false) {
4783
4793
  const parts = [];
4784
4794
  const ids = [];
4785
4795
  const keep = (a, b) => {
@@ -4792,7 +4802,7 @@ function markTracked(t, re, mark, ledger) {
4792
4802
  const at = hit.index ?? 0;
4793
4803
  const ch = hit[0];
4794
4804
  keep(cursor, at);
4795
- if (faceHitKept(ch, at, t.text))
4805
+ if (faceHitKept(ch, at, t.text, crlf))
4796
4806
  keep(at, at + ch.length);
4797
4807
  else {
4798
4808
  const form = markOf(ch, mark);
@@ -4841,7 +4851,7 @@ function foldTracked(t, keepBlanks) {
4841
4851
  function faceTracked(t, face, ledger) {
4842
4852
  const keepBlanks = face.keepBlanks === true;
4843
4853
  const unsafe = face.unsafe;
4844
- const markAll = (x) => (unsafe === null ? x : markTracked(x, unsafe, face.mark, ledger));
4854
+ const markAll = (x) => (unsafe === null ? x : markTracked(x, unsafe, face.mark, ledger, face.keepCrlf === true));
4845
4855
  if (face.mark === 'space') {
4846
4856
  const marked = markAll(t);
4847
4857
  return face.fold ? foldTracked(marked, keepBlanks) : marked;
@@ -4920,20 +4930,33 @@ function collectMarks(t, ledger) {
4920
4930
  }
4921
4931
  return out;
4922
4932
  }
4923
- const PUBLIC_UNSAFE_BY_NETS = Object.freeze(Array.from({ length: 16 }, (_, i) => {
4924
- const controls = (i & 8) !== 0;
4925
- const bidi = (i & 4) !== 0;
4926
- const keep = (i & 2) !== 0;
4927
- const blanks = (i & 1) !== 0;
4928
- const members = `${controls ? `${keep ? C0_KEEP_LAYOUT : C0_ALL}${DEL_C1}${LONE_SURROGATE}` : ''}${bidi ? LINE_SEPARATORS : ''}${blanks ? NAME_BLANKS : ''}`;
4933
+ export const DISPLAY_DECISION_BODY = Object.freeze({
4934
+ foldLines: false,
4935
+ keepLayout: 'crlf',
4936
+ blanks: 'fillers',
4937
+ mark: 'escape',
4938
+ });
4939
+ const PUBLIC_UNSAFE_BY_NETS = Object.freeze(Array.from({ length: 24 }, (_, i) => {
4940
+ const net = i % 3;
4941
+ const rest = (i - net) / 3;
4942
+ const controls = (rest & 4) !== 0;
4943
+ const bidi = (rest & 2) !== 0;
4944
+ const keep = (rest & 1) !== 0;
4945
+ const blanks = net === 1 ? NAME_BLANKS : net === 2 ? NAME_FILLERS : '';
4946
+ const members = `${controls ? `${keep ? C0_KEEP_LAYOUT : C0_ALL}${DEL_C1}${LONE_SURROGATE}` : ''}${bidi ? LINE_SEPARATORS : ''}${blanks}`;
4929
4947
  return unsafeClass(members, bidi);
4930
4948
  }));
4949
+ function blankNetOf(opts) {
4950
+ return opts.blanks === true ? 1 : opts.blanks === 'fillers' ? 2 : 0;
4951
+ }
4952
+ const keepsLayout = (opts) => opts.keepLayout === true || opts.keepLayout === 'crlf';
4931
4953
  function publicFace(opts) {
4932
4954
  const fold = opts.foldLines !== false;
4933
- const keep = !fold && opts.keepLayout === true;
4934
- const blanks = opts.blanks === true;
4935
- const index = (opts.controls !== false ? 8 : 0) + (opts.bidi !== false ? 4 : 0) + (keep ? 2 : 0) + (blanks ? 1 : 0);
4936
- return { unsafe: PUBLIC_UNSAFE_BY_NETS[index] ?? null, fold, mark: opts.mark ?? 'escape', keepBlanks: blanks };
4955
+ const keep = !fold && keepsLayout(opts);
4956
+ const net = blankNetOf(opts);
4957
+ const index = ((opts.controls !== false ? 4 : 0) + (opts.bidi !== false ? 2 : 0) + (keep ? 1 : 0)) * 3 + net;
4958
+ const face = { unsafe: PUBLIC_UNSAFE_BY_NETS[index] ?? null, fold, mark: opts.mark ?? 'escape', keepBlanks: net === 1 };
4959
+ return keep && opts.keepLayout === 'crlf' && opts.controls !== false ? { ...face, keepCrlf: true } : face;
4937
4960
  }
4938
4961
  export const ESCAPE_FACE = Object.freeze({ ...publicFace({ foldLines: false }) });
4939
4962
  export const LABEL_FACE = Object.freeze({ ...publicFace({}) });
@@ -5007,7 +5030,7 @@ function escapeSpacesFor(o, face) {
5007
5030
  if (o.controls !== false) {
5008
5031
  for (const c of [0x09, 0x0a, 0x0b, 0x0c, 0x0d])
5009
5032
  set.add(c);
5010
- if (o.keepLayout === true) {
5033
+ if (keepsLayout(o)) {
5011
5034
  set.delete(0x09);
5012
5035
  set.delete(0x0a);
5013
5036
  }
@@ -5024,7 +5047,7 @@ function scanOptionsOf(o, face, queryByShape = false, wholeAddress = false) {
5024
5047
  queryByShape,
5025
5048
  wholeAddress,
5026
5049
  words: o.credentialWords !== false,
5027
- blanks: face.keepBlanks === true,
5050
+ blanks: blankNetOf(o),
5028
5051
  fold: face.fold,
5029
5052
  face,
5030
5053
  escapeSpaces: escapeSpacesFor(o, face),
@@ -5321,7 +5344,7 @@ function queryPartPhases(key, value, relax) {
5321
5344
  return hit;
5322
5345
  }
5323
5346
  const UPLOAD_PROBE_PREFIX = 'https://q.invalid/?';
5324
- const UPLOAD_SCAN_OPTIONS = Object.freeze({ urls: true, queryByShape: 'strict', wholeAddress: true, words: true, blanks: false, fold: false, face: null, escapeSpaces: null });
5347
+ const UPLOAD_SCAN_OPTIONS = Object.freeze({ urls: true, queryByShape: 'strict', wholeAddress: true, words: true, blanks: 0, fold: false, face: null, escapeSpaces: null });
5325
5348
  export function queryCarriesCredential(query) {
5326
5349
  if (typeof query !== 'string' || query.length === 0)
5327
5350
  return false;
@@ -0,0 +1,3 @@
1
+ export declare function tupleOriginUrlOf(raw: string): URL | undefined;
2
+ export declare function carriesNoCredentialSlots(u: URL): boolean;
3
+ export declare function isCenterRelativePath(path: string): boolean;
@@ -0,0 +1,25 @@
1
+ export function tupleOriginUrlOf(raw) {
2
+ try {
3
+ const u = new URL(raw);
4
+ return /^(?:https?|wss?|ftp):$/.test(u.protocol) ? u : undefined;
5
+ }
6
+ catch {
7
+ return undefined;
8
+ }
9
+ }
10
+ export function carriesNoCredentialSlots(u) {
11
+ return u.username === '' && u.password === '' && u.search === '' && u.hash === '';
12
+ }
13
+ export function isCenterRelativePath(path) {
14
+ if (path.length === 0 || path.charCodeAt(0) !== 0x2f)
15
+ return false;
16
+ const second = path.charCodeAt(1);
17
+ if (second === 0x2f || second === 0x5c)
18
+ return false;
19
+ if (/[\s\u0000-\u001f\u007f-\u009f\\?#]/u.test(path))
20
+ return false;
21
+ return path.split('/').every((segment) => {
22
+ const decoded = segment.replace(/%2e/gi, '.');
23
+ return decoded !== '.' && decoded !== '..';
24
+ });
25
+ }
@@ -1,21 +1,9 @@
1
1
  import { guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
2
+ import { isCenterRelativePath } from './engineAddress.js';
2
3
  const KIND_WORDS = ['managed'];
3
4
  const POSTURE_WORDS = ['single', 'multi'];
4
5
  const RULE_WORDS = ['only-one', 'none', 'ambiguous'];
5
6
  const UNREADABLE = Object.freeze({ kind: 'unreadable' });
6
- function isCenterRelativePath(path) {
7
- if (path.length === 0 || path.charCodeAt(0) !== 0x2f)
8
- return false;
9
- const second = path.charCodeAt(1);
10
- if (second === 0x2f || second === 0x5c)
11
- return false;
12
- if (/[\s\u0000-\u001f\u007f-\u009f\\?#]/u.test(path))
13
- return false;
14
- return path.split('/').every((segment) => {
15
- const decoded = segment.replace(/%2e/gi, '.');
16
- return decoded !== '.' && decoded !== '..';
17
- });
18
- }
19
7
  function isObj(v) {
20
8
  return typeof v === 'object' && v !== null && !Array.isArray(v);
21
9
  }
@@ -123,6 +111,9 @@ export function projectMeEngine(body) {
123
111
  return undefined;
124
112
  }
125
113
  }
114
+ function sameNameCount(set, name) {
115
+ return set.rows.filter((row) => row.name === name).length + set.unreadableNames.filter((n) => n === name).length;
116
+ }
126
117
  export function decideMeEngine(reading) {
127
118
  try {
128
119
  if (reading === undefined)
@@ -139,7 +130,9 @@ export function decideMeEngine(reading) {
139
130
  if (candidates === undefined)
140
131
  return unresolved('candidates');
141
132
  const picked = target.row;
142
- if (!candidates.rows.some((row) => row.name === picked.name && row.viaCenter === picked.viaCenter))
133
+ if (!candidates.rows.some((row) => row.name === picked.name && row.viaCenter === picked.viaCenter && row.scope === picked.scope))
134
+ return unresolved('conflict');
135
+ if (sameNameCount(candidates, picked.name) > 1)
143
136
  return unresolved('conflict');
144
137
  if (rule.kind === 'listed' && (candidates.rows.length !== 1 || candidates.unreadableRows !== 0))
145
138
  return unresolved('conflict');
@@ -171,12 +164,11 @@ export function engineOverrideOf(set, requested) {
171
164
  if (set === undefined)
172
165
  return { kind: 'unreadable' };
173
166
  const hits = set.rows.filter((row) => row.name === requested);
174
- const hidden = set.unreadableNames.filter((name) => name === requested).length;
175
- if (hits.length + hidden > 1)
167
+ if (sameNameCount(set, requested) > 1)
176
168
  return { kind: 'duplicate', name: requested };
177
169
  if (hits.length === 1)
178
170
  return { kind: 'select', engine: hits[0] };
179
- if (hidden === 1)
171
+ if (set.unreadableNames.some((name) => name === requested))
180
172
  return { kind: 'row-unreadable', name: requested };
181
173
  return { kind: 'not-listed', candidates: set };
182
174
  }
@@ -8,6 +8,7 @@ export declare const LIMITS_MAX_WALLTIME_EXCEEDED = "limits.max_walltime_exceede
8
8
  export declare function isLimitsExceededCode(code: string | undefined): boolean;
9
9
  export declare const USAGE_WINDOW_EXHAUSTED = "usage.window_exhausted";
10
10
  export declare const ENV_LIFETIME_EXPIRED = "env.lifetime_expired";
11
+ export declare const ENV_HOME_UNCONFIRMED = "env.home_unconfirmed";
11
12
  export declare const FLEET_LEASE_UNAVAILABLE = "fleet.lease_unavailable";
12
13
  export declare const CONFIG_LIMIT_INVALID = "config.limit_invalid";
13
14
  export declare const CONFIG_LIMIT_UNKNOWN_KEY = "config.limit_unknown_key";
@@ -42,6 +43,12 @@ export declare const CAPABILITY_IMAGE_INDEX_REQUIRED = "capability.image_index_r
42
43
  export declare const CAPABILITY_K8S_LANE_REQUIRED = "capability.k8s_lane_required";
43
44
  export declare const NOT_FOUND_IMAGE = "not_found.image";
44
45
  export declare const REQUEST_PRECONDITION_UNMET = "request.precondition_unmet";
46
+ export declare const ATTACHMENT_BUNDLE_INVALID = "attachment.bundle_invalid";
47
+ export declare const ATTACHMENT_BUNDLE_LANE_NOT_ISOLATED = "attachment.bundle_lane_not_isolated";
48
+ export declare const ATTACHMENT_BUNDLE_SEED_FIXED = "attachment.bundle_seed_fixed";
49
+ export declare const ATTACHMENT_BOUND_ELSEWHERE = "attachment.bound_elsewhere";
50
+ export declare const CONFLICT_SESSION_MEMORY_UNOBSERVED = "conflict.session_memory_unobserved";
51
+ export declare const CONFLICT_SESSION_ARCHIVE_STAMPED = "conflict.session_archive_stamped";
45
52
  export declare const GATE_PARKED_ERROR_CODE = "gate.parked";
46
53
  export declare const ACTIVE_RUN_BUSY_ERROR_CODE = "conflict.session_active_run";
47
54
  export declare const CONFLICT_IDEMPOTENCY_PAYLOAD_MISMATCH = "conflict.idempotency_payload_mismatch";
@@ -114,6 +121,7 @@ export declare function isDecideParkMovedCode(code: string | null | undefined):
114
121
  export declare const DECIDE_ROW_UNREVIVABLE = "decide.row_unrevivable";
115
122
  export declare function isDecideRowUnrevivableCode(code: string | null | undefined): boolean;
116
123
  export declare const APPROVAL_STALE = "approval_stale";
124
+ export declare const DECIDE_REQUIRES_BINDING = "decide_requires_binding";
117
125
  export declare const APPROVAL_BINDING_MISMATCH = "approval_binding_mismatch";
118
126
  export declare const CHECKPOINT_INVALID_OUTCOME = "checkpoint.invalid_outcome";
119
127
  export declare const RESUME_OUTCOME_INVALID = "resume_outcome_invalid";
@@ -11,6 +11,7 @@ export function isLimitsExceededCode(code) {
11
11
  }
12
12
  export const USAGE_WINDOW_EXHAUSTED = 'usage.window_exhausted';
13
13
  export const ENV_LIFETIME_EXPIRED = 'env.lifetime_expired';
14
+ export const ENV_HOME_UNCONFIRMED = 'env.home_unconfirmed';
14
15
  export const FLEET_LEASE_UNAVAILABLE = 'fleet.lease_unavailable';
15
16
  export const CONFIG_LIMIT_INVALID = 'config.limit_invalid';
16
17
  export const CONFIG_LIMIT_UNKNOWN_KEY = 'config.limit_unknown_key';
@@ -66,6 +67,12 @@ export const CAPABILITY_IMAGE_INDEX_REQUIRED = 'capability.image_index_required'
66
67
  export const CAPABILITY_K8S_LANE_REQUIRED = 'capability.k8s_lane_required';
67
68
  export const NOT_FOUND_IMAGE = 'not_found.image';
68
69
  export const REQUEST_PRECONDITION_UNMET = 'request.precondition_unmet';
70
+ export const ATTACHMENT_BUNDLE_INVALID = 'attachment.bundle_invalid';
71
+ export const ATTACHMENT_BUNDLE_LANE_NOT_ISOLATED = 'attachment.bundle_lane_not_isolated';
72
+ export const ATTACHMENT_BUNDLE_SEED_FIXED = 'attachment.bundle_seed_fixed';
73
+ export const ATTACHMENT_BOUND_ELSEWHERE = 'attachment.bound_elsewhere';
74
+ export const CONFLICT_SESSION_MEMORY_UNOBSERVED = 'conflict.session_memory_unobserved';
75
+ export const CONFLICT_SESSION_ARCHIVE_STAMPED = 'conflict.session_archive_stamped';
69
76
  export const GATE_PARKED_ERROR_CODE = 'gate.parked';
70
77
  export const ACTIVE_RUN_BUSY_ERROR_CODE = 'conflict.session_active_run';
71
78
  export const CONFLICT_IDEMPOTENCY_PAYLOAD_MISMATCH = 'conflict.idempotency_payload_mismatch';
@@ -214,6 +221,7 @@ export function isDecideRowUnrevivableCode(code) {
214
221
  return typeof code === 'string' && code === DECIDE_ROW_UNREVIVABLE;
215
222
  }
216
223
  export const APPROVAL_STALE = 'approval_stale';
224
+ export const DECIDE_REQUIRES_BINDING = 'decide_requires_binding';
217
225
  export const APPROVAL_BINDING_MISMATCH = 'approval_binding_mismatch';
218
226
  export const CHECKPOINT_INVALID_OUTCOME = 'checkpoint.invalid_outcome';
219
227
  export const RESUME_OUTCOME_INVALID = 'resume_outcome_invalid';
@@ -19,7 +19,9 @@ export interface EngineGenerationPort {
19
19
  endedMaterials: () => Promise<EndedGenerationMaterials>;
20
20
  replacementInFlight?: () => boolean;
21
21
  awaitEngineInstalled?: (signal: AbortSignal, maxMs: number) => Promise<boolean>;
22
+ endedBy?: (generation: number) => EngineGenerationEndFact | undefined;
22
23
  }
24
+ export type EngineGenerationEndFact = 'own-supervision' | 'external-replacement';
23
25
  export type EngineGenerationReading = {
24
26
  readonly known: true;
25
27
  readonly generation: number;
@@ -42,11 +44,18 @@ export interface ApprovalFrameGenerationFacts {
42
44
  export declare function approvalFrameGenerationVerdict(facts: ApprovalFrameGenerationFacts): 'admit' | 'drop';
43
45
  export declare const REATTACH_AWAIT_NEXT_ENGINE_MS = 245000;
44
46
  export declare function unreachableForSettle(liveness: ReattachLivenessReading): boolean;
45
- export type EndedGenerationSettleStep = 'await-next-engine' | 'refresh-credentials' | 'credentials-rejected' | 'hand-over-terminal' | 'parked' | 'engine-stopped';
47
+ export type EndedGenerationSettleStep = 'await-next-engine' | 'refresh-credentials' | 'credentials-rejected' | 'hand-over-terminal' | 'parked' | 'engine-stopped' | 'window-exhausted';
48
+ export interface EndedGenerationWaitReading {
49
+ readonly replacing: boolean;
50
+ readonly installed: boolean;
51
+ readonly generationBefore?: EngineGenerationReading;
52
+ readonly generationAfter?: EngineGenerationReading;
53
+ readonly replacingAfter?: boolean;
54
+ }
46
55
  export interface EndedGenerationSettleFacts {
47
56
  readonly liveness: ReattachLivenessReading;
48
57
  readonly canAwaitNextEngine: boolean;
49
- readonly awaitedNextEngine: boolean;
58
+ readonly waits?: readonly EndedGenerationWaitReading[];
50
59
  readonly refreshedCredentials: boolean | null;
51
60
  readonly terminalReadable?: boolean;
52
61
  }
@@ -60,25 +60,79 @@ export function unreachableForSettle(liveness) {
60
60
  return false;
61
61
  }
62
62
  }
63
+ const SETTLE_WAIT_ROUNDS_MAX = 8;
64
+ function waitSnapshotsOf(raw) {
65
+ if (raw === undefined)
66
+ return [];
67
+ if (!Array.isArray(raw))
68
+ return null;
69
+ const out = [];
70
+ const n = raw.length;
71
+ for (let i = 0; i < n; i++) {
72
+ const item = raw[i];
73
+ if (typeof item !== 'object' || item === null)
74
+ return null;
75
+ const o = item;
76
+ const replacing = o.replacing;
77
+ const installed = o.installed;
78
+ const replacingAfter = o.replacingAfter;
79
+ if (typeof replacing !== 'boolean' || typeof installed !== 'boolean')
80
+ return null;
81
+ if (replacingAfter !== undefined && typeof replacingAfter !== 'boolean')
82
+ return null;
83
+ out.push({ replacing, installed, generationBefore: o.generationBefore, generationAfter: o.generationAfter, replacingAfter });
84
+ }
85
+ return out;
86
+ }
63
87
  export function endedGenerationSettleStep(facts) {
64
88
  try {
65
89
  const liveness = facts.liveness;
66
- if (typeof liveness !== 'object' || liveness === null || !REATTACH_RUN_STATES.includes(liveness.state))
67
- return 'engine-stopped';
68
- if (facts.canAwaitNextEngine === true && facts.awaitedNextEngine !== true && unreachableForSettle(liveness))
90
+ const canAwait = facts.canAwaitNextEngine;
91
+ const rawWaits = facts.waits;
92
+ const refreshed = facts.refreshedCredentials;
93
+ const terminalReadable = facts.terminalReadable;
94
+ if (typeof liveness !== 'object' || liveness === null)
95
+ return 'window-exhausted';
96
+ const state = liveness.state;
97
+ const notFound = liveness.notFound;
98
+ if (!REATTACH_RUN_STATES.includes(state))
99
+ return 'window-exhausted';
100
+ if (!(refreshed === null || typeof refreshed === 'boolean'))
101
+ return 'window-exhausted';
102
+ const waits = waitSnapshotsOf(rawWaits);
103
+ if (waits === null)
104
+ return 'window-exhausted';
105
+ const reading = notFound === true ? { state: state, notFound: true } : { state: state };
106
+ const unreachable = unreachableForSettle(reading);
107
+ const k = waits.length;
108
+ const w = k === 0 ? undefined : waits[k - 1];
109
+ const unstable = w !== undefined &&
110
+ w.installed &&
111
+ (engineGenerationEnded({ run: knownOrUnknown(w.generationBefore), current: knownOrUnknown(w.generationAfter) }) || w.replacingAfter === true);
112
+ if (refreshed === null && canAwait === true && (unreachable || state === 'unauthorized') && (k === 0 || (unstable && k < SETTLE_WAIT_ROUNDS_MAX)))
69
113
  return 'await-next-engine';
70
- if (liveness.state === 'unauthorized')
71
- return facts.refreshedCredentials === null ? 'refresh-credentials' : 'credentials-rejected';
72
- if (liveness.state === 'done')
73
- return facts.terminalReadable === false ? 'engine-stopped' : 'hand-over-terminal';
74
- if (liveness.state === 'parked')
114
+ const answered401 = refreshed !== null || state === 'unauthorized';
115
+ const outcomeUnknown = w !== undefined && answered401 && ((!w.installed && w.replacing) || (unstable && k >= SETTLE_WAIT_ROUNDS_MAX));
116
+ if (state === 'unauthorized') {
117
+ if (refreshed === null)
118
+ return 'refresh-credentials';
119
+ return outcomeUnknown ? 'window-exhausted' : 'credentials-rejected';
120
+ }
121
+ if (outcomeUnknown && unreachable)
122
+ return 'window-exhausted';
123
+ if (state === 'done')
124
+ return terminalReadable === false ? 'engine-stopped' : 'hand-over-terminal';
125
+ if (state === 'parked')
75
126
  return 'parked';
76
127
  return 'engine-stopped';
77
128
  }
78
129
  catch {
79
- return 'engine-stopped';
130
+ return 'window-exhausted';
80
131
  }
81
132
  }
133
+ function knownOrUnknown(reading) {
134
+ return typeof reading === 'object' && reading !== null ? reading : UNKNOWN;
135
+ }
82
136
  export const AWAIT_ENGINE_INSTALL_POLL_MS = 200;
83
137
  export function awaitNextEngineInstalled(signal, maxMs, deps) {
84
138
  const clock = typeof deps.now === 'function' ? deps.now : () => performance.now();
@@ -14,10 +14,15 @@ export interface EngineHealthDrainingFacts {
14
14
  readonly since: number;
15
15
  readonly deadlineAt: number;
16
16
  }
17
+ export interface EngineHealthLeaseFacts {
18
+ readonly lingerMs: number;
19
+ readonly tickMs: number;
20
+ }
17
21
  export interface EngineHealthFacts {
18
22
  readonly center?: EngineHealthCenterFacts;
19
23
  readonly auth?: EngineHealthAuthFacts;
20
24
  readonly operator?: 'present' | 'absent';
21
25
  readonly draining?: EngineHealthDrainingFacts;
26
+ readonly engineLease?: EngineHealthLeaseFacts;
22
27
  }
23
28
  export declare function readEngineHealthFacts(health: object | null | undefined): EngineHealthFacts;
@@ -67,6 +67,15 @@ function drainingOf(health) {
67
67
  return undefined;
68
68
  return Object.freeze({ actionId, since, deadlineAt });
69
69
  }
70
+ function leaseOf(raw) {
71
+ if (!isObject(raw))
72
+ return undefined;
73
+ const lingerMs = epochMs(readOwnDataValue(raw, 'lingerMs'));
74
+ const tickMs = epochMs(readOwnDataValue(raw, 'tickMs'));
75
+ if (lingerMs === undefined || tickMs === undefined)
76
+ return undefined;
77
+ return Object.freeze({ lingerMs, tickMs });
78
+ }
70
79
  function guarded(read) {
71
80
  try {
72
81
  return read();
@@ -83,10 +92,12 @@ export function readEngineHealthFacts(health) {
83
92
  const operatorRaw = guarded(() => readOwnDataValue(health, 'operator'));
84
93
  const operator = operatorRaw === 'present' || operatorRaw === 'absent' ? operatorRaw : undefined;
85
94
  const draining = guarded(() => drainingOf(health));
95
+ const engineLease = guarded(() => leaseOf(readOwnDataValue(health, 'engineLease')));
86
96
  return Object.freeze({
87
97
  ...(center !== undefined ? { center } : {}),
88
98
  ...(auth !== undefined ? { auth } : {}),
89
99
  ...(operator !== undefined ? { operator } : {}),
90
100
  ...(draining !== undefined ? { draining } : {}),
101
+ ...(engineLease !== undefined ? { engineLease } : {}),
91
102
  });
92
103
  }
@@ -223,12 +223,14 @@ export interface StreamEndIgnoredFactsView {
223
223
  runId: string;
224
224
  }
225
225
  export declare function readStreamEndIgnored(notice: unknown): StreamEndIgnoredFactsView | undefined;
226
- export interface ContextImageRemovedFactsView {
226
+ export interface ContextMediaRemovedFactsView {
227
+ reason: string;
227
228
  images: number;
229
+ documents: number;
228
230
  sessionId: string;
229
231
  runId: string;
230
232
  }
231
- export declare function readContextImageRemoved(notice: {} | null | undefined): ContextImageRemovedFactsView | undefined;
233
+ export declare function readContextMediaRemoved(notice: {} | null | undefined): ContextMediaRemovedFactsView | undefined;
232
234
  export interface McpAuthorizationRequiredFactsView {
233
235
  server: string;
234
236
  reason: string;
@@ -237,6 +239,26 @@ export interface McpAuthorizationRequiredFactsView {
237
239
  runId: string;
238
240
  }
239
241
  export declare function readMcpAuthorizationRequired(notice: {} | null | undefined): McpAuthorizationRequiredFactsView | undefined;
242
+ interface SessionLineageRerootedCommon {
243
+ recordsDropped: NoticeCountReading;
244
+ recordsTotal: NoticeCountReading;
245
+ entriesOnPath: NoticeCountReading;
246
+ sessionId: string;
247
+ runId: string;
248
+ }
249
+ interface SessionLineageRerootedWhole extends SessionLineageRerootedCommon {
250
+ break: false;
251
+ leaf: string | null;
252
+ }
253
+ interface SessionLineageRerootedBroken extends SessionLineageRerootedCommon {
254
+ break: true;
255
+ leaf: string;
256
+ missingParentId: string;
257
+ rootedAt: string;
258
+ entriesCut: NoticeCountReading;
259
+ }
260
+ export type SessionLineageRerootedFactsView = SessionLineageRerootedWhole | SessionLineageRerootedBroken;
261
+ export declare function readSessionLineageRerooted(notice: {} | null | undefined): SessionLineageRerootedFactsView | undefined;
240
262
  export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
241
263
  readonly 'mcp.injection_dropped': typeof readMcpInjectionDrop;
242
264
  readonly 'delegation.ask_unresolvable': typeof readAskUnresolvable;
@@ -261,8 +283,9 @@ export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
261
283
  readonly 'task.turn_interrupted': typeof readTurnInterrupted;
262
284
  readonly 'route.finish_reason_unknown': typeof readFinishReasonUnknown;
263
285
  readonly 'route.stream_end_ignored': typeof readStreamEndIgnored;
264
- readonly 'context.image_removed': typeof readContextImageRemoved;
265
286
  readonly 'mcp.authorization_required': typeof readMcpAuthorizationRequired;
287
+ readonly 'context.media_removed': typeof readContextMediaRemoved;
288
+ readonly 'session.lineage_rerooted': typeof readSessionLineageRerooted;
266
289
  }>;
267
290
  type FactReaderTable = typeof ENGINE_NOTICE_FACT_READERS;
268
291
  export type EngineNoticeFactsCode = keyof FactReaderTable;
@@ -897,25 +897,28 @@ function readStreamEndIgnoredOf(notice) {
897
897
  return undefined;
898
898
  return { statement, word, frames, sessionId, runId };
899
899
  }
900
- export function readContextImageRemoved(notice) {
901
- return guardedRead(notice, readContextImageRemovedOf);
900
+ export function readContextMediaRemoved(notice) {
901
+ return guardedRead(notice, readContextMediaRemovedOf);
902
902
  }
903
- function readContextImageRemovedOf(notice) {
903
+ function readContextMediaRemovedOf(notice) {
904
904
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
905
905
  return undefined;
906
906
  const n = notice;
907
- if (ownSeat(n, 'code') !== 'context.image_removed')
907
+ if (ownSeat(n, 'code') !== 'context.media_removed')
908
908
  return undefined;
909
909
  const d = ownSeat(n, 'detail');
910
910
  if (typeof d !== 'object' || d === null || Array.isArray(d))
911
911
  return undefined;
912
912
  const o = d;
913
+ const reason = nonEmpty(ownSeat(o, 'reason'));
913
914
  const images = ownSeat(o, 'images');
915
+ const documents = ownSeat(o, 'documents');
914
916
  const sessionId = nonEmpty(ownSeat(o, 'sessionId'));
915
917
  const runId = nonEmpty(ownSeat(o, 'runId'));
916
- if (typeof images !== 'number' || !Number.isSafeInteger(images) || images < 1 || sessionId === undefined || runId === undefined)
918
+ const count = (v) => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0;
919
+ if (reason === undefined || !count(images) || !count(documents) || images + documents < 1 || sessionId === undefined || runId === undefined)
917
920
  return undefined;
918
- return { images, sessionId, runId };
921
+ return { reason, images, documents, sessionId, runId };
919
922
  }
920
923
  export function readMcpAuthorizationRequired(notice) {
921
924
  return guardedRead(notice, readMcpAuthorizationRequiredOf);
@@ -939,6 +942,47 @@ function readMcpAuthorizationRequiredOf(notice) {
939
942
  const authorizeUrl = nonEmpty(optionalOwnSeat(o, 'authorizeUrl'));
940
943
  return { server, reason, ...(authorizeUrl !== undefined ? { authorizeUrl } : {}), sessionId, runId };
941
944
  }
945
+ export function readSessionLineageRerooted(notice) {
946
+ return guardedRead(notice, readSessionLineageRerootedOf);
947
+ }
948
+ function readSessionLineageRerootedOf(notice) {
949
+ if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
950
+ return undefined;
951
+ const n = notice;
952
+ if (ownSeat(n, 'code') !== 'session.lineage_rerooted')
953
+ return undefined;
954
+ const d = ownSeat(n, 'detail');
955
+ if (typeof d !== 'object' || d === null || Array.isArray(d))
956
+ return undefined;
957
+ const o = d;
958
+ const brk = ownSeat(o, 'break');
959
+ if (brk !== true && brk !== false)
960
+ return undefined;
961
+ const sessionId = nonEmpty(ownSeat(o, 'sessionId'));
962
+ const runId = nonEmpty(ownSeat(o, 'runId'));
963
+ if (sessionId === undefined || runId === undefined)
964
+ return undefined;
965
+ const leafRaw = ownSeat(o, 'leaf');
966
+ const common = {
967
+ recordsDropped: countReading(optionalOwnSeat(o, 'recordsDropped')),
968
+ recordsTotal: countReading(optionalOwnSeat(o, 'recordsTotal')),
969
+ entriesOnPath: countReading(optionalOwnSeat(o, 'entriesOnPath')),
970
+ sessionId,
971
+ runId,
972
+ };
973
+ if (brk === false) {
974
+ const leaf = leafRaw === null ? null : nonEmpty(leafRaw);
975
+ if (leaf === undefined)
976
+ return undefined;
977
+ return { break: false, leaf, ...common };
978
+ }
979
+ const leaf = nonEmpty(leafRaw);
980
+ const missingParentId = nonEmpty(ownSeat(o, 'missingParentId'));
981
+ const rootedAt = nonEmpty(ownSeat(o, 'rootedAt'));
982
+ if (leaf === undefined || missingParentId === undefined || rootedAt === undefined)
983
+ return undefined;
984
+ return { break: true, leaf, missingParentId, rootedAt, entriesCut: countReading(optionalOwnSeat(o, 'entriesCut')), ...common };
985
+ }
942
986
  export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
943
987
  'mcp.injection_dropped': readMcpInjectionDrop,
944
988
  'delegation.ask_unresolvable': readAskUnresolvable,
@@ -963,8 +1007,9 @@ export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
963
1007
  'task.turn_interrupted': readTurnInterrupted,
964
1008
  'route.finish_reason_unknown': readFinishReasonUnknown,
965
1009
  'route.stream_end_ignored': readStreamEndIgnored,
966
- 'context.image_removed': readContextImageRemoved,
967
1010
  'mcp.authorization_required': readMcpAuthorizationRequired,
1011
+ 'context.media_removed': readContextMediaRemoved,
1012
+ 'session.lineage_rerooted': readSessionLineageRerooted,
968
1013
  });
969
1014
  const _factReaderTablePin = true;
970
1015
  void _factReaderTablePin;
@@ -74,7 +74,7 @@ export function mintEngineRowRef(eventId, bound) {
74
74
  export function terminalRunIdOf(ev) {
75
75
  if (ev.type !== 'done')
76
76
  return undefined;
77
- const v = (doneResultView(ev.result).engine ?? ev.result)?.runId;
77
+ const v = doneResultView(ev.result).body?.runId;
78
78
  return typeof v === 'string' && v.length > 0 ? v : undefined;
79
79
  }
80
80
  export const TRANSCRIPT_ROW_SIDECAR_KEYS = Object.freeze([