@sema-agent/client-core 0.97.0 → 0.98.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 (281) hide show
  1. package/CHANGELOG.md +429 -0
  2. package/README.md +74 -36
  3. package/dist/adapt/arms.d.ts +1 -0
  4. package/dist/adapt/arms.js +128 -34
  5. package/dist/adapt/ids.d.ts +12 -1
  6. package/dist/adapt/ids.js +59 -8
  7. package/dist/adapt/instanceLedger.d.ts +50 -0
  8. package/dist/adapt/instanceLedger.js +147 -0
  9. package/dist/adapt/textStream.d.ts +1 -0
  10. package/dist/adapt/textStream.js +24 -7
  11. package/dist/adapt/toolCards.d.ts +27 -5
  12. package/dist/adapt/toolCards.js +39 -6
  13. package/dist/adapt/wireShapes.js +6 -2
  14. package/dist/adapt.d.ts +2 -0
  15. package/dist/adapt.js +8 -3
  16. package/dist/adapter/activeRunSelfHeal.d.ts +5 -0
  17. package/dist/adapter/activeRunSelfHeal.js +51 -28
  18. package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
  19. package/dist/adapter/downstream/eventToSdkMessage.js +27 -34
  20. package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
  21. package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
  22. package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
  23. package/dist/adapter/runStream.js +29 -13
  24. package/dist/adapter/types.d.ts +4 -4
  25. package/dist/agentSession/backgroundView.js +2 -1
  26. package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
  27. package/dist/agentSession/engineAgentRegistryRead.js +12 -13
  28. package/dist/agentsWireCaps.d.ts +8 -6
  29. package/dist/agentsWireCaps.js +177 -162
  30. package/dist/approvalDecidedByCapability.d.ts +0 -4
  31. package/dist/approvalDecidedByCapability.js +0 -6
  32. package/dist/approvalsStreamLiveCapability.d.ts +0 -4
  33. package/dist/approvalsStreamLiveCapability.js +0 -6
  34. package/dist/assistantInbox.d.ts +34 -0
  35. package/dist/assistantInbox.js +118 -0
  36. package/dist/centerWiringCapability.js +9 -1
  37. package/dist/clientSlice.d.ts +0 -9
  38. package/dist/clientSlice.js +0 -3
  39. package/dist/cloudConfigWireCaps.d.ts +4 -2
  40. package/dist/cloudConfigWireCaps.js +81 -61
  41. package/dist/compensations.js +1 -1
  42. package/dist/connectorStatus.d.ts +21 -0
  43. package/dist/connectorStatus.js +112 -0
  44. package/dist/controlRouter.d.ts +14 -1
  45. package/dist/controlRouter.js +68 -17
  46. package/dist/coreValuePorts.d.ts +3 -3
  47. package/dist/decideReceipt.d.ts +2 -2
  48. package/dist/decideReceipt.js +5 -2
  49. package/dist/declared/supportFloorDeclared.js +3 -3
  50. package/dist/deviceExecutorManagementCapability.d.ts +0 -4
  51. package/dist/deviceExecutorManagementCapability.js +0 -6
  52. package/dist/deviceRebind.d.ts +49 -1
  53. package/dist/deviceRebind.js +221 -3
  54. package/dist/displayUntrusted.d.ts +1 -0
  55. package/dist/displayUntrusted.js +250 -76
  56. package/dist/engineAgentAbsence.d.ts +1 -1
  57. package/dist/engineAgentPanelStore.d.ts +5 -4
  58. package/dist/engineAgentPanelStore.js +3 -12
  59. package/dist/engineCapReader.d.ts +0 -4
  60. package/dist/engineCapReader.js +1 -5
  61. package/dist/engineCapsCache.d.ts +4 -0
  62. package/dist/engineCapsCache.js +17 -12
  63. package/dist/engineClosedSets.d.ts +1 -0
  64. package/dist/engineClosedSets.js +4 -1
  65. package/dist/engineErrorCodes.d.ts +9 -2
  66. package/dist/engineErrorCodes.js +9 -1
  67. package/dist/engineIdentity.d.ts +1 -0
  68. package/dist/engineIdentity.js +8 -0
  69. package/dist/engineRowRef.d.ts +28 -0
  70. package/dist/engineRowRef.js +111 -0
  71. package/dist/engineSessionMessages.d.ts +67 -0
  72. package/dist/engineSessionMessages.js +364 -0
  73. package/dist/engineToolDirectory.d.ts +18 -0
  74. package/dist/engineToolDirectory.js +85 -0
  75. package/dist/engineUrl.d.ts +18 -0
  76. package/dist/engineUrl.js +52 -0
  77. package/dist/env/uiLanguage.d.ts +9 -0
  78. package/dist/env/uiLanguage.js +35 -0
  79. package/dist/eventLeg.d.ts +92 -0
  80. package/dist/eventLeg.js +285 -0
  81. package/dist/executionLaneCapability.d.ts +0 -4
  82. package/dist/executionLaneCapability.js +3 -16
  83. package/dist/fileHistoryCaptureCapability.d.ts +0 -4
  84. package/dist/fileHistoryCaptureCapability.js +5 -7
  85. package/dist/fleet/fleetLedger.d.ts +0 -3
  86. package/dist/fleet/fleetLedger.js +21 -36
  87. package/dist/fleet/fleetProjection.d.ts +2 -2
  88. package/dist/fleet/fleetProjection.js +10 -8
  89. package/dist/frameBinding.d.ts +5 -0
  90. package/dist/frameBinding.js +23 -0
  91. package/dist/gateFailureCodes.d.ts +2 -0
  92. package/dist/gateFailureCodes.js +15 -0
  93. package/dist/gateOutcome.d.ts +3 -1
  94. package/dist/gateOutcome.js +25 -6
  95. package/dist/gateVocabulary.d.ts +5 -0
  96. package/dist/gateVocabulary.js +64 -2
  97. package/dist/generated/engineAskFaceTables.js +2 -2
  98. package/dist/generated/engineFactTables.d.ts +6 -3
  99. package/dist/generated/engineFactTables.js +22 -4
  100. package/dist/generated/engineNoticeTables.js +9 -0
  101. package/dist/generated/toolNameTables.d.ts +1 -0
  102. package/dist/generated/toolNameTables.js +1 -0
  103. package/dist/hitl/allowRuleShadow.d.ts +6 -1
  104. package/dist/hitl/allowRuleShadow.js +21 -17
  105. package/dist/hitl/approvalCardReading.d.ts +15 -0
  106. package/dist/hitl/approvalCardReading.js +154 -0
  107. package/dist/hitl/approvalCardReasons.d.ts +13 -0
  108. package/dist/hitl/approvalCardReasons.js +120 -0
  109. package/dist/hitl/approvalHolds.d.ts +47 -15
  110. package/dist/hitl/approvalHolds.js +134 -28
  111. package/dist/hitl/approvalResolution.d.ts +51 -26
  112. package/dist/hitl/approvalResolution.js +86 -122
  113. package/dist/hitl/approvalsFeed.js +6 -18
  114. package/dist/hitl/askClassPair.d.ts +2 -0
  115. package/dist/hitl/askClassPair.js +1 -0
  116. package/dist/hitl/askGateWire.d.ts +20 -2
  117. package/dist/hitl/askGateWire.js +49 -1
  118. package/dist/hitl/askParkRowRouting.d.ts +5 -0
  119. package/dist/hitl/askParkRowRouting.js +32 -1
  120. package/dist/hitl/askSettlementLine.d.ts +18 -0
  121. package/dist/hitl/askSettlementLine.js +79 -0
  122. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  123. package/dist/hitl/automaticAnswerVerdict.js +21 -5
  124. package/dist/hitl/crashConverged.d.ts +11 -20
  125. package/dist/hitl/crashConverged.js +56 -0
  126. package/dist/hitl/crashConvergedNotice.d.ts +3 -1
  127. package/dist/hitl/crashConvergedNotice.js +48 -11
  128. package/dist/hitl/decisionConflict.js +3 -10
  129. package/dist/hitl/decisionRefusal.d.ts +40 -1
  130. package/dist/hitl/decisionRefusal.js +199 -42
  131. package/dist/hitl/frameRouter.d.ts +5 -2
  132. package/dist/hitl/frameRouter.js +20 -16
  133. package/dist/hitl/gateLedger.d.ts +2 -0
  134. package/dist/hitl/gateLedger.js +50 -13
  135. package/dist/hitl/hitlBridge.d.ts +1 -2
  136. package/dist/hitl/hitlBridge.js +10 -7
  137. package/dist/hitl/livePendingAsk.d.ts +3 -3
  138. package/dist/hitl/livePendingAsk.js +7 -18
  139. package/dist/hitl/parkResolver.d.ts +2 -24
  140. package/dist/hitl/parkResolver.js +61 -97
  141. package/dist/hitl/persistedRulesWire.d.ts +24 -0
  142. package/dist/hitl/persistedRulesWire.js +122 -2
  143. package/dist/hitl/planReviewWire.d.ts +26 -13
  144. package/dist/hitl/planReviewWire.js +112 -78
  145. package/dist/hitl/refusedToolNameProse.d.ts +0 -1
  146. package/dist/hitl/refusedToolNameProse.js +0 -3
  147. package/dist/hitl/replayedApproval.d.ts +4 -3
  148. package/dist/hitl/replayedApproval.js +7 -4
  149. package/dist/hitl/sessionPolicyDeliverable.js +2 -4
  150. package/dist/hitl/sessionPolicyWire.d.ts +32 -20
  151. package/dist/hitl/sessionPolicyWire.js +162 -52
  152. package/dist/hitl/standingRows.d.ts +20 -2
  153. package/dist/hitl/standingRows.js +69 -8
  154. package/dist/hitl/toolApprovalWire.d.ts +87 -152
  155. package/dist/hitl/toolApprovalWire.js +591 -380
  156. package/dist/hookMatcherVerdict.d.ts +6 -1
  157. package/dist/hookMatcherVerdict.js +14 -7
  158. package/dist/hooksWireCaps.d.ts +2 -2
  159. package/dist/hooksWireCaps.js +59 -55
  160. package/dist/i18n/messages.en.d.ts +121 -0
  161. package/dist/i18n/messages.en.js +119 -0
  162. package/dist/i18n/messages.zh.d.ts +3 -0
  163. package/dist/i18n/messages.zh.js +120 -0
  164. package/dist/i18n/translate.d.ts +25 -0
  165. package/dist/i18n/translate.js +127 -0
  166. package/dist/index.d.ts +53 -18
  167. package/dist/index.js +38 -10
  168. package/dist/inheritEnvCapability.d.ts +31 -0
  169. package/dist/inheritEnvCapability.js +104 -0
  170. package/dist/liveModelCatalog.d.ts +1 -2
  171. package/dist/liveModelCatalog.js +2 -6
  172. package/dist/liveQuestionStore.d.ts +2 -21
  173. package/dist/mcpLiveness.d.ts +2 -1
  174. package/dist/mcpProbeWire.d.ts +6 -1
  175. package/dist/mcpProbeWire.js +1 -1
  176. package/dist/mcpWireCaps.d.ts +13 -2
  177. package/dist/mcpWireCaps.js +48 -0
  178. package/dist/memoryEntriesWire.d.ts +4 -9
  179. package/dist/model/modelSupplyRules.d.ts +0 -2
  180. package/dist/model/modelSupplyRules.js +3 -12
  181. package/dist/model/modelsPolicy.d.ts +0 -5
  182. package/dist/model/modelsPolicy.js +6 -36
  183. package/dist/model/subagentModelWord.d.ts +31 -0
  184. package/dist/model/subagentModelWord.js +261 -0
  185. package/dist/notifications.d.ts +6 -0
  186. package/dist/notifications.js +71 -23
  187. package/dist/outputStyleSeatCapability.d.ts +0 -3
  188. package/dist/outputStyleSeatCapability.js +0 -3
  189. package/dist/ownKey.d.ts +15 -0
  190. package/dist/ownKey.js +60 -3
  191. package/dist/panelReduce.d.ts +15 -9
  192. package/dist/panelReduce.js +680 -549
  193. package/dist/panelStateHolder.d.ts +3 -7
  194. package/dist/panelStateHolder.js +14 -130
  195. package/dist/peerLaneCapability.d.ts +0 -4
  196. package/dist/peerLaneCapability.js +0 -6
  197. package/dist/permissionRulesWriteCapability.d.ts +0 -4
  198. package/dist/permissionRulesWriteCapability.js +0 -6
  199. package/dist/permissionWireCaps.d.ts +2 -2
  200. package/dist/permissionWireCaps.js +2 -0
  201. package/dist/permissionsAllowGrantCapability.d.ts +0 -4
  202. package/dist/permissionsAllowGrantCapability.js +0 -6
  203. package/dist/permissionsDeclaration.d.ts +0 -11
  204. package/dist/permissionsDeclaration.js +60 -53
  205. package/dist/pluginHooksWire.d.ts +1 -1
  206. package/dist/pluginHooksWire.js +3 -6
  207. package/dist/preemptWire.d.ts +44 -0
  208. package/dist/preemptWire.js +83 -0
  209. package/dist/printToolResultFrame.js +15 -4
  210. package/dist/replayBody.d.ts +3 -0
  211. package/dist/replayBody.js +14 -0
  212. package/dist/request/taskRequest.d.ts +0 -1
  213. package/dist/request/taskRequest.js +0 -3
  214. package/dist/resumeRefusalCopy.d.ts +2 -1
  215. package/dist/resumeRefusalCopy.js +38 -2
  216. package/dist/retryStatus.d.ts +8 -0
  217. package/dist/retryStatus.js +106 -1
  218. package/dist/rewindArchiveCapability.d.ts +0 -4
  219. package/dist/rewindArchiveCapability.js +2 -10
  220. package/dist/rewindArchiveReading.d.ts +0 -1
  221. package/dist/rewindArchiveReading.js +0 -3
  222. package/dist/runCancelContext.d.ts +2 -1
  223. package/dist/runCancelContext.js +4 -2
  224. package/dist/runReattachPolicy.d.ts +31 -0
  225. package/dist/runReattachPolicy.js +46 -0
  226. package/dist/runTerminal.d.ts +3 -6
  227. package/dist/runTerminal.js +8 -9
  228. package/dist/sandboxWire.d.ts +3 -1
  229. package/dist/sandboxWire.js +76 -27
  230. package/dist/scenarioWire.js +1 -1
  231. package/dist/seam.d.ts +24 -2
  232. package/dist/seam.js +15 -3
  233. package/dist/seatContract.d.ts +53 -10
  234. package/dist/seatContract.js +132 -81
  235. package/dist/sessionPolicyCapability.d.ts +0 -4
  236. package/dist/sessionPolicyCapability.js +0 -6
  237. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
  238. package/dist/sessionSyncFileHistoryCapability.js +0 -3
  239. package/dist/skillToolListsCapability.d.ts +0 -3
  240. package/dist/skillToolListsCapability.js +0 -3
  241. package/dist/sqlEngineCapability.d.ts +0 -4
  242. package/dist/sqlEngineCapability.js +0 -6
  243. package/dist/steerPriorityCapability.d.ts +0 -3
  244. package/dist/steerPriorityCapability.js +0 -3
  245. package/dist/streamDrainingLegs.d.ts +4 -0
  246. package/dist/streamDrainingLegs.js +6 -1
  247. package/dist/subagent/engineCompactWire.d.ts +0 -1
  248. package/dist/subagent/engineCompactWire.js +7 -5
  249. package/dist/subagent/engineTaskHandleWire.js +4 -7
  250. package/dist/subagentContentStore.js +1 -11
  251. package/dist/submitReopen.d.ts +24 -0
  252. package/dist/submitReopen.js +75 -0
  253. package/dist/terminalStatuses.d.ts +3 -0
  254. package/dist/terminalStatuses.js +10 -2
  255. package/dist/toolResult.d.ts +10 -1
  256. package/dist/toolResult.js +34 -6
  257. package/dist/toolRoster.d.ts +0 -2
  258. package/dist/toolRoster.js +0 -2
  259. package/dist/turnFailurePresentation.d.ts +28 -0
  260. package/dist/turnFailurePresentation.js +205 -0
  261. package/dist/userInvokedSkillsCapability.d.ts +0 -3
  262. package/dist/userInvokedSkillsCapability.js +0 -3
  263. package/dist/webSearchBackendCapability.d.ts +0 -4
  264. package/dist/webSearchBackendCapability.js +0 -6
  265. package/dist/wireErrorTriage.js +5 -24
  266. package/dist/wireFailureShape.d.ts +62 -5
  267. package/dist/wireFailureShape.js +105 -5
  268. package/dist/wireRefusalCopy.d.ts +12 -2
  269. package/dist/wireRefusalCopy.js +50 -52
  270. package/dist/workflowsJournalCapability.d.ts +0 -4
  271. package/dist/workflowsJournalCapability.js +0 -6
  272. package/dist/writeProtectionCapability.d.ts +0 -4
  273. package/dist/writeProtectionCapability.js +0 -6
  274. package/docs/INTEGRATION-CLIENTS.md +1305 -46
  275. package/package.json +5 -4
  276. package/dist/attachmentSeatCapability.d.ts +0 -12
  277. package/dist/attachmentSeatCapability.js +0 -23
  278. package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
  279. package/dist/hitl/approvalOutcomeNote.js +0 -29
  280. package/dist/sessionReadRedactionCapability.d.ts +0 -13
  281. package/dist/sessionReadRedactionCapability.js +0 -35
@@ -15,6 +15,7 @@ export interface ArmDeps extends ProjectionArmDeps {
15
15
  readonly panel: PanelTaskLedger;
16
16
  readonly flags: TurnFlags;
17
17
  readonly inst: AdapterInstanceLedger;
18
+ readonly pass: number;
18
19
  }
19
20
  export type ProjectionArmFn = (m: Frame, deps: ProjectionArmDeps) => Generator<AdapterOutput>;
20
21
  type ArmFn = (m: Frame, deps: ArmDeps) => Generator<AdapterOutput>;
@@ -1,4 +1,4 @@
1
- import { ccToolDenialKindForToolEnd } from '../gateOutcome.js';
1
+ import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../gateOutcome.js';
2
2
  import { isSubFlowSegmentEnd, SEGMENT_END_IDENTITY_KEYS, snapshotSegmentIdentity, snapshotIsSubFlow } from '../adapter/types.js';
3
3
  import { classifyPeerNotification, renderPeerFrameTranscriptText } from '../peerFrames.js';
4
4
  import { dropQueuedNotificationsForRun, isEngineWorkflowNotified, isWorkflowCompletionCardEnqueued, markEngineWorkflowNotified, noteOwnWorkflowRun, normalizeTaskNotification, noteWorkflowCompletionCardEnqueued, renderTaskNotificationXml, taskNotificationDedupKey } from '../notifications.js';
@@ -12,13 +12,63 @@ import { recordWorkflowAgentTaskId } from '../workflow.js';
12
12
  import { isCoreTaskNotificationTerminal, isCoreTaskNotificationTerminalNotSuccess, isCoreTaskProgressTerminal, isCoreTaskProgressTerminalNotSuccess } from '../terminalStatuses.js';
13
13
  import { readToolHistoryMismatchKey } from '../toolHistoryMismatch.js';
14
14
  import { readProviderRejectionResendKey } from '../providerRejection.js';
15
- import { readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
15
+ import { contextUsageReadingOf, guardedRead, readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
16
16
  import { washCredentials } from '../displayUntrusted.js';
17
17
  import { resolveEnginePanelTaskId } from '../engineAgentPanelStore.js';
18
18
  import { fleetRowAgentType } from '../fleet/fleetRowAgentType.js';
19
19
  import { chrome, mainLane, transcript, messageIdentityOf } from './ids.js';
20
+ import { engineRefOf } from '../engineRowRef.js';
21
+ import { isReplayMarked, RESULT_REPLAYED_TEXT } from '../replayBody.js';
20
22
  import { wiringManifestViewOf } from '../adapter/downstream/wiringManifestView.js';
23
+ import { isUnsettledHeldToolEnd } from '../engineRowRef.js';
21
24
  import { CANCEL_MESSAGE, decisionOf, flattenWireOutput, REJECT_MESSAGE, sanitizeToolUseBlock, shortTaskLabel, TASK_TOOL_NAMES, WORKFLOW_TOOL_NAMES, } from './wireShapes.js';
25
+ function hostOwnString(o, key) {
26
+ return readFrameStringKey(o, key);
27
+ }
28
+ function continuesParkDeclarationOf(ctx) {
29
+ const decl = guardedRead(() => ctx.continuesPark);
30
+ return typeof decl === 'object' && decl !== null ? decl : undefined;
31
+ }
32
+ function continuesParkWitness(ctx, row) {
33
+ const decl = continuesParkDeclarationOf(ctx);
34
+ if (decl === undefined)
35
+ return false;
36
+ if (hostOwnString(decl, 'toolCallId') !== row.toolCallId)
37
+ return false;
38
+ const cp = hostOwnString(decl, 'checkpointId');
39
+ if (cp !== undefined && row.checkpointId !== undefined && cp !== row.checkpointId)
40
+ return false;
41
+ const parkedTaskId = hostOwnString(decl, 'parkedTaskId');
42
+ if (parkedTaskId !== undefined && row.parkedRun !== undefined && parkedTaskId !== row.parkedRun)
43
+ return false;
44
+ return true;
45
+ }
46
+ function claimParkedCard(m, callId, toolName, deps) {
47
+ const { ctx, cards, inst, pass } = deps;
48
+ if (cards.has(callId))
49
+ return undefined;
50
+ const row = inst.parkedToolRowFor(ctx.sessionId, callId);
51
+ if (row === undefined)
52
+ return undefined;
53
+ if (readFrameStringKey(m, 'parentToolCallId') !== row.card.parentToolCallId)
54
+ return undefined;
55
+ if (toolName !== undefined && toolName !== row.card.name)
56
+ return undefined;
57
+ const frameRun = engineRefOf(m)?.taskId;
58
+ if (frameRun !== undefined) {
59
+ const decl = continuesParkDeclarationOf(ctx);
60
+ const allowed = [row.parkedRun, row.card.engineRef?.taskId, readFrameStringKey(decl, 'parkedTaskId'), readFrameStringKey(decl, 'continuationTaskId')].filter((x) => x !== undefined);
61
+ if (allowed.length > 0 && !allowed.includes(frameRun))
62
+ return undefined;
63
+ }
64
+ if (row.pass !== pass && !continuesParkWitness(ctx, row))
65
+ return undefined;
66
+ inst.dropParkedToolRow(row.key);
67
+ return row.card;
68
+ }
69
+ function laneOfCard(p) {
70
+ return p.parentToolCallId !== undefined && p.parentToolCallId !== '' ? { lane: 'subagent', parentToolCallId: p.parentToolCallId } : mainLane();
71
+ }
22
72
  function toolHistoryKeyCarry(m) {
23
73
  if (m._sema_api_error_message !== true)
24
74
  return {};
@@ -33,7 +83,8 @@ function providerResendKeyCarry(m) {
33
83
  const key = readProviderRejectionResendKey(typeof raw === 'object' && raw !== null ? raw : undefined);
34
84
  return key === undefined ? {} : { _sema_provider_rejection_resend: key };
35
85
  }
36
- const assistantArm = function* (m, { ctx, idOf, text, cards, inst }) {
86
+ const assistantArm = function* (m, deps) {
87
+ const { ctx, idOf, text, cards, inst } = deps;
37
88
  const message = m.message;
38
89
  const blocks = Array.isArray(message?.content)
39
90
  ? message.content
@@ -61,21 +112,27 @@ const assistantArm = function* (m, { ctx, idOf, text, cards, inst }) {
61
112
  }
62
113
  yield* text.takeAnswerSegment();
63
114
  yield* text.takeThinking();
64
- text.beginAssistantMessage();
65
- const cardIdentity = messageIdentityOf(m, ctx);
66
- yield transcript({
67
- type: 'assistant',
68
- message: {
69
- id: cards.mintResponseId(m),
70
- role: 'assistant',
71
- content: renderBlocks,
72
- ...(cardIdentity.model !== undefined ? { model: cardIdentity.model } : {}),
73
- },
74
- uuid: idOf(m),
75
- session_id: ctx.sessionId,
76
- parent_tool_use_id: null,
77
- ...(readFrameTrueMark(m, '_sema_tool_recovered') ? { _sema_tool_recovered: true } : {}),
78
- }, ctx.now());
115
+ const claimed = claimParkedCard(m, toolUseId, toolName, deps);
116
+ const startUuid = claimed !== undefined ? claimed.rowUuid : idOf(m);
117
+ if (claimed === undefined)
118
+ inst.noteStartRow(ctx.sessionId, toolUseId, startUuid);
119
+ if (claimed === undefined) {
120
+ text.beginAssistantMessage();
121
+ const cardIdentity = messageIdentityOf(m, ctx);
122
+ yield transcript({
123
+ type: 'assistant',
124
+ message: {
125
+ id: cards.mintResponseId(m),
126
+ role: 'assistant',
127
+ content: renderBlocks,
128
+ ...(cardIdentity.model !== undefined ? { model: cardIdentity.model } : {}),
129
+ },
130
+ uuid: startUuid,
131
+ session_id: ctx.sessionId,
132
+ parent_tool_use_id: null,
133
+ ...(readFrameTrueMark(m, '_sema_tool_recovered') ? { _sema_tool_recovered: true } : {}),
134
+ }, ctx.now());
135
+ }
79
136
  if (decision === 'reject' || decision === 'cancel') {
80
137
  cards.resetResponseId();
81
138
  yield transcript({
@@ -116,18 +173,23 @@ const assistantArm = function* (m, { ctx, idOf, text, cards, inst }) {
116
173
  }, ctx.now());
117
174
  return;
118
175
  }
119
- cards.open({
176
+ cards.open(claimed !== undefined ? { ...claimed, rawInput: san.rawInput } : {
120
177
  id: toolUseId,
121
178
  name: toolName,
122
179
  rawInput: san.rawInput,
123
180
  ...(san.eventId !== undefined ? { eventId: san.eventId } : {}),
124
181
  ...(san.parentToolCallId !== undefined ? { parentToolCallId: san.parentToolCallId } : {}),
182
+ engineRef: engineRefOf(m),
183
+ ...(startUuid !== undefined ? { rowUuid: startUuid } : {}),
125
184
  });
126
185
  if (WORKFLOW_TOOL_NAMES.has(toolName))
127
186
  inst.markWorkflowCard(toolUseId);
128
187
  return;
129
188
  }
130
189
  const textBlock = blocks.find(b => b?.type === 'text');
190
+ const thinkingBlock = blocks.find(b => b?.type === 'thinking');
191
+ if ((textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0) || (thinkingBlock && typeof thinkingBlock.thinking === 'string'))
192
+ text.anchorWindow(m);
131
193
  if (textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0) {
132
194
  const rowText = m._sema_api_error_message === true ? washCredentials(textBlock.text) : textBlock.text;
133
195
  text.appendAnswer(rowText);
@@ -145,7 +207,6 @@ const assistantArm = function* (m, { ctx, idOf, text, cards, inst }) {
145
207
  }, ctx.now());
146
208
  text.markEmittedText(rowText);
147
209
  }
148
- const thinkingBlock = blocks.find(b => b?.type === 'thinking');
149
210
  if (thinkingBlock && typeof thinkingBlock.thinking === 'string') {
150
211
  yield transcript({
151
212
  type: 'assistant',
@@ -360,20 +421,13 @@ const toolRosterDeltaArm = function* (m) {
360
421
  const contextUsageArm = function* (m) {
361
422
  if (isSubFlowSegmentEnd(m))
362
423
  return;
363
- const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
364
- const usedTokens = num(m.usedTokens);
365
- const windowTokens = num(m.windowTokens);
366
- const compactAtTokens = num(m.compactAtTokens);
367
- const sections = Array.isArray(m.sections) ? m.sections : undefined;
368
- if (usedTokens === undefined && windowTokens === undefined && compactAtTokens === undefined && sections === undefined)
424
+ const reading = contextUsageReadingOf(m);
425
+ if (reading === undefined)
369
426
  return;
370
427
  yield chrome({
371
428
  kind: 'context_usage',
372
429
  laneProof: mainLane(),
373
- ...(usedTokens !== undefined ? { usedTokens } : {}),
374
- ...(windowTokens !== undefined ? { windowTokens } : {}),
375
- ...(compactAtTokens !== undefined ? { compactAtTokens } : {}),
376
- ...(sections !== undefined ? { sections } : {}),
430
+ ...reading,
377
431
  ...(typeof m.eventId === 'string' && m.eventId.length > 0 ? { eventId: m.eventId } : {}),
378
432
  });
379
433
  };
@@ -516,7 +570,8 @@ const promptSuggestionsArm = function* (m) {
516
570
  yield chrome({ kind: 'prompt_suggestions', laneProof: mainLane(), suggestions: list });
517
571
  }
518
572
  };
519
- const toolEndResultArm = function* (m, { idOf, cards, panel }) {
573
+ const toolEndResultArm = function* (m, deps) {
574
+ const { idOf, cards, panel, ctx, inst, pass } = deps;
520
575
  const callId = typeof m.toolCallId === 'string' ? m.toolCallId : undefined;
521
576
  recordEngineToolLabel(callId, m.label);
522
577
  if (callId !== undefined) {
@@ -524,10 +579,25 @@ const toolEndResultArm = function* (m, { idOf, cards, panel }) {
524
579
  if (launched !== null)
525
580
  registerSubagentContentAlias(callId, launched.taskId);
526
581
  }
582
+ if (callId !== undefined && isUnsettledHeldToolEnd(m)) {
583
+ const held = cards.detach(callId);
584
+ if (held !== undefined) {
585
+ inst.parkToolRow({ sessionId: ctx.sessionId, toolCallId: callId, card: held, pass });
586
+ yield chrome({ kind: 'tool_parked', laneProof: laneOfCard(held), toolUseId: callId, ...(held.rowUuid !== undefined ? { rowUuid: held.rowUuid } : {}) });
587
+ }
588
+ return;
589
+ }
527
590
  if (callId !== undefined) {
528
591
  yield* panel.settle(callId, m.isError === true, m.output !== undefined ? flattenWireOutput(m.output) : undefined);
529
592
  }
530
- const p = callId !== undefined ? cards.peek(callId) : undefined;
593
+ let p = callId !== undefined ? cards.peek(callId) : undefined;
594
+ if (p === undefined && callId !== undefined) {
595
+ const claimed = claimParkedCard(m, callId, readFrameStringKey(m, 'toolName'), deps);
596
+ if (claimed !== undefined) {
597
+ cards.open(claimed);
598
+ p = claimed;
599
+ }
600
+ }
531
601
  if (p === undefined || callId === undefined)
532
602
  return;
533
603
  const structured = m.structured;
@@ -537,6 +607,7 @@ const toolEndResultArm = function* (m, { idOf, cards, panel }) {
537
607
  const closeParent = typeof closeParentRaw === 'string' ? closeParentRaw : undefined;
538
608
  const stampedRaw = m._sema_denial_kind;
539
609
  const closeDenialKindRaw = typeof stampedRaw === 'string' ? stampedRaw : ccToolDenialKindForToolEnd(m);
610
+ const closeGate = guardedRead(() => gateOutcomeOf(m));
540
611
  yield* cards.close(p, {
541
612
  output: m.output,
542
613
  structured,
@@ -544,8 +615,10 @@ const toolEndResultArm = function* (m, { idOf, cards, panel }) {
544
615
  isError: m.isError === true,
545
616
  eventId: closeEventId,
546
617
  parentToolCallId: closeParent,
618
+ engineRef: engineRefOf(m),
547
619
  ...(typeof closeDenialKindRaw === 'string' ? { denialKind: closeDenialKindRaw } : {}),
548
- ...(readFrameTrueMark(m, 'notExecuted') ? { notExecuted: true } : {}),
620
+ ...(closeGate !== undefined ? { gate: closeGate } : {}),
621
+ closeArm: m,
549
622
  });
550
623
  const s = structured !== undefined && structured !== null && typeof structured === 'object'
551
624
  ? structured
@@ -641,7 +714,7 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
641
714
  : typeof input.task === 'string'
642
715
  ? input.task
643
716
  : undefined;
644
- const identity = resolveEnginePanelTaskId(taskId, explicitParent);
717
+ const identity = resolveEnginePanelTaskId(taskId);
645
718
  if (!panel.isLive(taskId)) {
646
719
  yield* panel.start(taskId, fleetRowAgentType(identity.taskId));
647
720
  }
@@ -761,6 +834,8 @@ const resultArm = function* (m, { ctx, idOf, text, cards, panel, flags }) {
761
834
  resultLength: terminalText.length,
762
835
  });
763
836
  }
837
+ if (isReplayMarked(m))
838
+ yield chrome({ kind: 'result_replayed', laneProof: mainLane(), text: RESULT_REPLAYED_TEXT });
764
839
  };
765
840
  const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
766
841
  const n = (m.notification ?? {});
@@ -869,8 +944,27 @@ const retryStatusArm = function* (m, { ctx, flags }) {
869
944
  yield chrome({ kind: 'retry_status', laneProof: mainLane(), status });
870
945
  flags.noteRetryOverlay();
871
946
  };
947
+ const terminalFactArm = function* (m, { ctx, inst, pass }) {
948
+ const taskId = readFrameStringKey(m, 'taskId');
949
+ const paused = guardedRead(() => {
950
+ const d = Object.getOwnPropertyDescriptor(m, 'paused');
951
+ return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
952
+ });
953
+ if (typeof paused === 'object' && paused !== null) {
954
+ const heldCallId = readFrameStringKey(paused, 'heldCallId');
955
+ const checkpointId = readFrameStringKey(paused, 'checkpointId');
956
+ inst.noteParkedFact(ctx.sessionId, pass, {
957
+ ...(heldCallId !== undefined ? { heldCallId } : {}),
958
+ ...(checkpointId !== undefined ? { checkpointId } : {}),
959
+ ...(taskId !== undefined ? { taskId } : {}),
960
+ });
961
+ return;
962
+ }
963
+ inst.retireParkedRowsOfRun(ctx.sessionId, pass, taskId);
964
+ };
872
965
  export const ARMS = new Map([
873
966
  ['assistant', assistantArm],
967
+ ['terminal_fact', terminalFactArm],
874
968
  ['user', userArm],
875
969
  ['tool_end_result', toolEndResultArm],
876
970
  ['task_progress', taskProgressArm],
@@ -1,7 +1,16 @@
1
1
  import type { AdapterContext, AdapterOutput, ChromeEvent, LaneProof } from '../seam.js';
2
+ import { type EngineRowRef } from '../engineRowRef.js';
2
3
  export type Frame = Record<string, unknown>;
3
4
  export declare const mainLane: () => LaneProof;
4
- export type IdOf = (frame: Frame, suffix?: string) => string;
5
+ export interface RowSidecars {
6
+ readonly ref?: EngineRowRef;
7
+ readonly replay?: true;
8
+ }
9
+ export interface IdOf {
10
+ (frame: Frame, suffix?: string): string;
11
+ adopt(id: string, ref: EngineRowRef | undefined): string;
12
+ sidecarsOfId(id: string): RowSidecars | undefined;
13
+ }
5
14
  export declare function messageIdentityOf(frame: Frame, ctx: {
6
15
  model?: string;
7
16
  }): {
@@ -11,3 +20,5 @@ export declare function messageIdentityOf(frame: Frame, ctx: {
11
20
  export declare const chrome: (event: ChromeEvent) => AdapterOutput;
12
21
  export declare const transcript: (message: Frame, nowMs: number) => AdapterOutput;
13
22
  export declare function makeIdOf(ctx: AdapterContext): IdOf;
23
+ export declare function segmentRowId(idOf: IdOf, open: Frame, close: Frame | null, tag: 'text' | 'thinking'): string;
24
+ export declare function carryRowSidecars(out: AdapterOutput, idOf: IdOf): AdapterOutput;
package/dist/adapt/ids.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { deriveTranscriptId } from '../seam.js';
2
+ import { engineRefOf } from '../engineRowRef.js';
3
+ import { isReplayMarked } from '../replayBody.js';
2
4
  export const mainLane = () => ({ lane: 'main' });
3
5
  export function messageIdentityOf(frame, ctx) {
4
6
  const msg = frame.message;
@@ -24,17 +26,66 @@ export const transcript = (message, nowMs) => {
24
26
  : { ...message, timestamp: new Date(nowMs).toISOString() }),
25
27
  };
26
28
  };
29
+ function frameKeyOf(frame) {
30
+ if (frame === null)
31
+ return undefined;
32
+ return typeof frame.id === 'string' && frame.id.length > 0
33
+ ? frame.id
34
+ : typeof frame.uuid === 'string' && frame.uuid.length > 0
35
+ ? frame.uuid
36
+ : undefined;
37
+ }
27
38
  export function makeIdOf(ctx) {
28
- return (frame, suffix) => {
29
- const base = typeof frame.id === 'string' && frame.id.length > 0
30
- ? frame.id
31
- : typeof frame.uuid === 'string' && frame.uuid.length > 0
32
- ? frame.uuid
33
- : undefined;
34
- return deriveTranscriptId({
39
+ const ledger = new Map();
40
+ const note = (id, ref, replay) => {
41
+ if ((ref === undefined && !replay) || ledger.has(id))
42
+ return;
43
+ ledger.set(id, { ...(ref !== undefined ? { ref } : {}), ...(replay ? { replay: true } : {}) });
44
+ };
45
+ const idOf = (frame, suffix) => {
46
+ const base = frameKeyOf(frame);
47
+ const id = deriveTranscriptId({
35
48
  ...(base !== undefined ? { id: base } : {}),
36
- ...(typeof frame.seq === 'number' ? { seq: frame.seq } : {}),
37
49
  ...(typeof frame.toolCallId === 'string' ? { toolCallId: frame.toolCallId } : {}),
38
50
  }, ctx, suffix);
51
+ note(id, engineRefOf(frame), isReplayMarked(frame));
52
+ return id;
53
+ };
54
+ return Object.assign(idOf, {
55
+ adopt: (id, ref) => {
56
+ note(id, ref, false);
57
+ return id;
58
+ },
59
+ sidecarsOfId: (id) => {
60
+ const row = ledger.get(id);
61
+ if (row === undefined)
62
+ return undefined;
63
+ return { ...(row.ref !== undefined ? { ref: { ...row.ref } } : {}), ...(row.replay === true ? { replay: true } : {}) };
64
+ },
65
+ });
66
+ }
67
+ export function segmentRowId(idOf, open, close, tag) {
68
+ const closeKey = frameKeyOf(close);
69
+ if (closeKey === undefined)
70
+ return idOf.adopt(idOf({}, tag), engineRefOf(open));
71
+ return idOf(open, `${tag}~${closeKey}`);
72
+ }
73
+ export function carryRowSidecars(out, idOf) {
74
+ if (out.plane !== 'transcript')
75
+ return out;
76
+ const row = out.message;
77
+ const uuid = row.uuid;
78
+ if (typeof uuid !== 'string')
79
+ return out;
80
+ const side = idOf.sidecarsOfId(uuid);
81
+ if (side === undefined)
82
+ return out;
83
+ const addRef = side.ref !== undefined && !Object.hasOwn(row, '_sema_engine_ref');
84
+ const addReplay = side.replay === true && !Object.hasOwn(row, '_sema_replay');
85
+ if (!addRef && !addReplay)
86
+ return out;
87
+ return {
88
+ plane: 'transcript',
89
+ message: Object.assign({}, out.message, addRef ? { _sema_engine_ref: side.ref } : {}, addReplay ? { _sema_replay: true } : {}),
39
90
  };
40
91
  }
@@ -1,3 +1,17 @@
1
+ import type { PendingToolUse } from './toolCards.js';
2
+ import type { EngineRowRef } from '../engineRowRef.js';
3
+ export declare const PARKED_TOOL_ROWS_MAX = 64;
4
+ export declare const LATEST_START_ROWS_MAX = 1024;
5
+ export interface ParkedToolRow {
6
+ readonly key: string;
7
+ readonly sessionId: string;
8
+ readonly toolCallId: string;
9
+ readonly card: PendingToolUse;
10
+ readonly pass?: number;
11
+ readonly seq: number;
12
+ parkedRun?: string;
13
+ checkpointId?: string;
14
+ }
1
15
  export interface AdapterInstanceLedger {
2
16
  hasRenderedNotification(key: string): boolean;
3
17
  addRenderedNotification(key: string): void;
@@ -7,5 +21,41 @@ export interface AdapterInstanceLedger {
7
21
  markWorkflowCard(toolUseId: string): void;
8
22
  hasFiredSubagentStart(taskId: string): boolean;
9
23
  markFiredSubagentStart(taskId: string): void;
24
+ beginPass(): number;
25
+ parkToolRow(row: ParkToolRowInput): void;
26
+ parkedToolRowFor(sessionId: string, toolCallId: string): ParkedToolRow | undefined;
27
+ noteParkedFact(sessionId: string, pass: number, fact: ParkedTerminalFact): void;
28
+ retireParkedRowsOfRun(sessionId: string, pass: number, taskId: string | undefined): void;
29
+ dropParkedToolRow(key: string): void;
30
+ noteStartRow(sessionId: string, toolCallId: string, rowUuid: string | undefined): void;
31
+ listParkedToolRows(): ParkedToolRowSnapshot[];
32
+ takeParkedToolRows(rows: {} | null | undefined): number;
33
+ }
34
+ export interface ParkToolRowInput {
35
+ readonly sessionId: string;
36
+ readonly toolCallId: string;
37
+ readonly card: PendingToolUse;
38
+ readonly pass: number;
39
+ }
40
+ export interface ParkedTerminalFact {
41
+ readonly heldCallId?: string;
42
+ readonly checkpointId?: string;
43
+ readonly taskId?: string;
44
+ }
45
+ export interface ParkedToolCardSnapshot {
46
+ readonly id: string;
47
+ readonly name: string;
48
+ readonly rawInput: {} | null | undefined;
49
+ readonly eventId?: string;
50
+ readonly parentToolCallId?: string;
51
+ readonly rowUuid?: string;
52
+ readonly engineRef?: EngineRowRef;
53
+ }
54
+ export interface ParkedToolRowSnapshot {
55
+ readonly sessionId: string;
56
+ readonly toolCallId: string;
57
+ readonly parkedRun?: string;
58
+ readonly checkpointId?: string;
59
+ readonly card: ParkedToolCardSnapshot;
10
60
  }
11
61
  export declare function createAdapterInstanceLedger(): AdapterInstanceLedger;
@@ -1,8 +1,155 @@
1
+ export const PARKED_TOOL_ROWS_MAX = 64;
2
+ export const LATEST_START_ROWS_MAX = 1024;
3
+ const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
4
+ function ownData(o, key) {
5
+ try {
6
+ if (typeof o !== 'object' || o === null)
7
+ return undefined;
8
+ const d = Object.getOwnPropertyDescriptor(o, key);
9
+ return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
10
+ }
11
+ catch {
12
+ return undefined;
13
+ }
14
+ }
1
15
  export function createAdapterInstanceLedger() {
2
16
  const renderedNotifications = new Set();
3
17
  const seenWorkflowToolCallIds = new Set();
4
18
  const firedSubagentStartHookTaskIds = new Set();
19
+ const parkedRows = new Map();
20
+ let passSeq = 0;
21
+ let rowSeq = 0;
22
+ const addParkedRow = (r) => {
23
+ const seq = ++rowSeq;
24
+ const key = `${r.sessionId}\u0000${r.parkedRun ?? ''}\u0000${seq}`;
25
+ parkedRows.set(key, { ...r, key, seq });
26
+ while (parkedRows.size > PARKED_TOOL_ROWS_MAX) {
27
+ const oldest = parkedRows.keys().next();
28
+ if (oldest.done === true)
29
+ break;
30
+ parkedRows.delete(oldest.value);
31
+ }
32
+ };
33
+ const latestStartRows = new Map();
34
+ const callKey = (sessionId, toolCallId) => `${sessionId}\u0000${toolCallId}`;
35
+ const isClaimable = (r) => r.card.rowUuid !== undefined && latestStartRows.get(callKey(r.sessionId, r.toolCallId)) === r.card.rowUuid;
36
+ const setLatestStartRow = (key, rowUuid) => {
37
+ latestStartRows.delete(key);
38
+ latestStartRows.set(key, rowUuid);
39
+ if (latestStartRows.size <= LATEST_START_ROWS_MAX)
40
+ return;
41
+ const pinned = new Set([...parkedRows.values()].map((r) => callKey(r.sessionId, r.toolCallId)));
42
+ for (const k of latestStartRows.keys()) {
43
+ if (latestStartRows.size <= LATEST_START_ROWS_MAX)
44
+ break;
45
+ if (!pinned.has(k))
46
+ latestStartRows.delete(k);
47
+ }
48
+ };
49
+ const latestFor = (sessionId, toolCallId, pass) => {
50
+ let hit;
51
+ for (const r of parkedRows.values()) {
52
+ if (r.sessionId === sessionId && r.toolCallId === toolCallId && (pass === undefined || r.pass === pass))
53
+ hit = r;
54
+ }
55
+ return hit;
56
+ };
5
57
  return {
58
+ beginPass: () => ++passSeq,
59
+ parkToolRow: (row) => {
60
+ addParkedRow({ sessionId: row.sessionId, toolCallId: row.toolCallId, card: row.card, pass: row.pass });
61
+ },
62
+ parkedToolRowFor: (sessionId, toolCallId) => {
63
+ const r = latestFor(sessionId, toolCallId);
64
+ return r !== undefined && isClaimable(r) ? r : undefined;
65
+ },
66
+ noteParkedFact: (sessionId, pass, fact) => {
67
+ if (fact.heldCallId === undefined)
68
+ return;
69
+ const r = latestFor(sessionId, fact.heldCallId, pass);
70
+ if (r === undefined)
71
+ return;
72
+ if (fact.checkpointId !== undefined)
73
+ r.checkpointId = fact.checkpointId;
74
+ if (fact.taskId !== undefined)
75
+ r.parkedRun = fact.taskId;
76
+ },
77
+ retireParkedRowsOfRun: (sessionId, pass, taskId) => {
78
+ for (const [key, r] of parkedRows) {
79
+ if (r.sessionId !== sessionId)
80
+ continue;
81
+ if (r.parkedRun !== undefined ? r.parkedRun === taskId : r.pass === pass)
82
+ parkedRows.delete(key);
83
+ }
84
+ },
85
+ dropParkedToolRow: (key) => {
86
+ parkedRows.delete(key);
87
+ },
88
+ noteStartRow: (sessionId, toolCallId, rowUuid) => {
89
+ setLatestStartRow(callKey(sessionId, toolCallId), rowUuid ?? null);
90
+ },
91
+ listParkedToolRows: () => [...parkedRows.values()].filter(isClaimable).map((r) => ({
92
+ sessionId: r.sessionId,
93
+ toolCallId: r.toolCallId,
94
+ ...(r.parkedRun !== undefined ? { parkedRun: r.parkedRun } : {}),
95
+ ...(r.checkpointId !== undefined ? { checkpointId: r.checkpointId } : {}),
96
+ card: {
97
+ id: r.card.id,
98
+ name: r.card.name,
99
+ rawInput: r.card.rawInput,
100
+ ...(r.card.eventId !== undefined ? { eventId: r.card.eventId } : {}),
101
+ ...(r.card.parentToolCallId !== undefined ? { parentToolCallId: r.card.parentToolCallId } : {}),
102
+ ...(r.card.rowUuid !== undefined ? { rowUuid: r.card.rowUuid } : {}),
103
+ ...(r.card.engineRef !== undefined ? { engineRef: r.card.engineRef } : {}),
104
+ },
105
+ })),
106
+ takeParkedToolRows: (rows) => {
107
+ let n = 0;
108
+ let list = [];
109
+ try {
110
+ list = Array.isArray(rows) ? [...rows] : [];
111
+ }
112
+ catch {
113
+ list = [];
114
+ }
115
+ for (const raw of list) {
116
+ const sessionId = str(ownData(raw, 'sessionId'));
117
+ const toolCallId = str(ownData(raw, 'toolCallId'));
118
+ const card = ownData(raw, 'card');
119
+ const id = str(ownData(card, 'id'));
120
+ const name = str(ownData(card, 'name'));
121
+ if (sessionId === undefined || toolCallId === undefined || id === undefined || id !== toolCallId || name === undefined)
122
+ continue;
123
+ const rowUuid = str(ownData(card, 'rowUuid'));
124
+ if ([...parkedRows.values()].some((r) => r.sessionId === sessionId && r.toolCallId === toolCallId && r.card.rowUuid === rowUuid))
125
+ continue;
126
+ const eventId = str(ownData(card, 'eventId'));
127
+ const parentToolCallId = str(ownData(card, 'parentToolCallId'));
128
+ const engineRef = ownData(card, 'engineRef');
129
+ const parkedRun = str(ownData(raw, 'parkedRun'));
130
+ const checkpointId = str(ownData(raw, 'checkpointId'));
131
+ const ck = callKey(sessionId, toolCallId);
132
+ if (!latestStartRows.has(ck) && rowUuid !== undefined)
133
+ setLatestStartRow(ck, rowUuid);
134
+ addParkedRow({
135
+ sessionId,
136
+ toolCallId,
137
+ card: {
138
+ id,
139
+ name,
140
+ rawInput: ownData(card, 'rawInput'),
141
+ ...(eventId !== undefined ? { eventId } : {}),
142
+ ...(parentToolCallId !== undefined ? { parentToolCallId } : {}),
143
+ ...(rowUuid !== undefined ? { rowUuid } : {}),
144
+ ...(typeof engineRef === 'object' && engineRef !== null ? { engineRef: engineRef } : {}),
145
+ },
146
+ ...(parkedRun !== undefined ? { parkedRun } : {}),
147
+ ...(checkpointId !== undefined ? { checkpointId } : {}),
148
+ });
149
+ n++;
150
+ }
151
+ return n;
152
+ },
6
153
  hasRenderedNotification: (key) => renderedNotifications.has(key),
7
154
  addRenderedNotification: (key) => {
8
155
  renderedNotifications.add(key);
@@ -35,6 +35,7 @@ export interface TextStream {
35
35
  closeSegmentAuthorityWindowOnNextText(): void;
36
36
  replaceThinkingSegment(content: string, anchor?: Frame): ThinkingSegmentReplacement;
37
37
  segmentId(): string;
38
+ anchorWindow(frame: Frame): void;
38
39
  rotateSegmentIdentity(anchor: Frame): void;
39
40
  stampSegmentIdentity(out: AdapterOutput): AdapterOutput;
40
41
  readonly answerLength: number;