@sema-agent/client-core 0.93.1 → 0.95.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 (321) hide show
  1. package/CHANGELOG.md +554 -0
  2. package/README.md +89 -55
  3. package/dist/adapt/arms.js +13 -11
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.js +2 -2
  6. package/dist/adapt/wireShapes.js +3 -8
  7. package/dist/adapter/activeRunSelfHeal.d.ts +8 -3
  8. package/dist/adapter/activeRunSelfHeal.js +20 -12
  9. package/dist/adapter/downstream/eventToSdkMessage.js +24 -17
  10. package/dist/adapter/downstream/terminalToSdkResult.js +13 -6
  11. package/dist/adapter/runStream.js +2 -1
  12. package/dist/adapter/types.d.ts +7 -0
  13. package/dist/adapter/types.js +15 -0
  14. package/dist/agentSession/backgroundView.js +5 -1
  15. package/dist/agentSession/engineAgentRegistryRead.js +2 -1
  16. package/dist/agentSession/engineSessionBackgroundStop.js +5 -3
  17. package/dist/agentsWireCaps.d.ts +17 -0
  18. package/dist/agentsWireCaps.js +111 -1
  19. package/dist/approvalDecidedByCapability.d.ts +0 -1
  20. package/dist/approvalDecidedByCapability.js +2 -7
  21. package/dist/approvalReachWire.d.ts +18 -0
  22. package/dist/approvalReachWire.js +58 -0
  23. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  24. package/dist/approvalsStreamLiveCapability.js +15 -14
  25. package/dist/atMostOnce.d.ts +8 -0
  26. package/dist/atMostOnce.js +36 -0
  27. package/dist/attachmentSeatCapability.d.ts +0 -1
  28. package/dist/attachmentSeatCapability.js +0 -3
  29. package/dist/attachmentsWireCaps.js +11 -6
  30. package/dist/bashExitReading.d.ts +10 -0
  31. package/dist/bashExitReading.js +12 -0
  32. package/dist/callerCwdCapability.d.ts +15 -0
  33. package/dist/callerCwdCapability.js +42 -0
  34. package/dist/centerWiringCapability.d.ts +1 -3
  35. package/dist/centerWiringCapability.js +18 -21
  36. package/dist/classifierStatus.js +4 -4
  37. package/dist/cloudConfigWireCaps.js +43 -21
  38. package/dist/compensations.js +1 -1
  39. package/dist/controlRouter.js +3 -10
  40. package/dist/coreValuePorts.d.ts +64 -1
  41. package/dist/coreValuePorts.js +30 -0
  42. package/dist/cycleOrder.d.ts +15 -0
  43. package/dist/cycleOrder.js +45 -0
  44. package/dist/decideFailureNote.js +4 -1
  45. package/dist/decideReceipt.d.ts +2 -1
  46. package/dist/decideReceipt.js +41 -13
  47. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  48. package/dist/declared/supportFloorDeclared.js +5 -0
  49. package/dist/detachWire.d.ts +1 -4
  50. package/dist/detachWire.js +1 -1
  51. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  52. package/dist/deviceExecutorManagementCapability.js +36 -40
  53. package/dist/deviceFlowPolling.d.ts +5 -0
  54. package/dist/deviceFlowPolling.js +28 -0
  55. package/dist/deviceRebind.d.ts +88 -0
  56. package/dist/deviceRebind.js +242 -0
  57. package/dist/displayUntrusted.d.ts +1 -0
  58. package/dist/displayUntrusted.js +963 -30
  59. package/dist/engineAgentAbsence.d.ts +2 -2
  60. package/dist/engineAgentPanelStore.d.ts +8 -18
  61. package/dist/engineAgentPanelStore.js +19 -537
  62. package/dist/engineCapReader.d.ts +6 -6
  63. package/dist/engineCapReader.js +30 -43
  64. package/dist/engineCapsCache.d.ts +7 -2
  65. package/dist/engineCapsCache.js +64 -26
  66. package/dist/engineCredentialRequirement.d.ts +9 -0
  67. package/dist/engineCredentialRequirement.js +23 -0
  68. package/dist/engineEnvSourcing.d.ts +53 -0
  69. package/dist/engineEnvSourcing.js +81 -0
  70. package/dist/engineErrorCodes.d.ts +19 -4
  71. package/dist/engineErrorCodes.js +39 -21
  72. package/dist/engineIdentity.js +2 -0
  73. package/dist/engineNoticeCodes.d.ts +22 -2
  74. package/dist/engineNoticeCodes.js +73 -6
  75. package/dist/engineRefusedToolName.d.ts +1 -0
  76. package/dist/engineRefusedToolName.js +8 -0
  77. package/dist/engineWireSdk.js +2 -2
  78. package/dist/executionLaneCapability.d.ts +2 -3
  79. package/dist/executionLaneCapability.js +28 -28
  80. package/dist/fileHistoryCaptureCapability.d.ts +0 -1
  81. package/dist/fileHistoryCaptureCapability.js +13 -12
  82. package/dist/fileHistoryLegNotice.d.ts +14 -2
  83. package/dist/fileHistoryLegNotice.js +101 -15
  84. package/dist/fleet/fleetLedger.d.ts +2 -0
  85. package/dist/fleet/fleetLedger.js +74 -52
  86. package/dist/fleet/fleetProjection.d.ts +0 -3
  87. package/dist/fleet/fleetProjection.js +9 -16
  88. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  89. package/dist/fleetAgentPanelProjection.js +7 -197
  90. package/dist/fleetAgentRowLike.d.ts +16 -0
  91. package/dist/fleetAgentRowLike.js +1 -0
  92. package/dist/gateOutcome.d.ts +2 -1
  93. package/dist/gateOutcome.js +33 -18
  94. package/dist/gateVocabulary.js +1 -1
  95. package/dist/generated/engineAskFaceTables.d.ts +3 -0
  96. package/dist/generated/engineAskFaceTables.js +12 -0
  97. package/dist/generated/engineFactTables.d.ts +4 -2
  98. package/dist/generated/engineFactTables.js +13 -0
  99. package/dist/generated/engineNoticeTables.d.ts +5 -0
  100. package/dist/generated/engineNoticeTables.js +7 -0
  101. package/dist/generated/sdkFactTables.d.ts +5 -0
  102. package/dist/generated/sdkFactTables.js +34 -0
  103. package/dist/generated/settingsSchemaFns.d.ts +10 -0
  104. package/dist/generated/settingsSchemaFns.js +22 -0
  105. package/dist/generated/settingsSchemaTables.d.ts +3 -0
  106. package/dist/generated/settingsSchemaTables.js +3 -0
  107. package/dist/headlessPermissionModeWire.d.ts +2 -2
  108. package/dist/headlessPermissionModeWire.js +11 -21
  109. package/dist/headlessReconnectWire.js +49 -20
  110. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  111. package/dist/hitl/allowRuleShadow.js +49 -8
  112. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  113. package/dist/hitl/approvalCompleteParked.js +14 -0
  114. package/dist/hitl/approvalEndingCause.d.ts +5 -0
  115. package/dist/hitl/approvalEndingCause.js +61 -0
  116. package/dist/hitl/approvalHolds.d.ts +46 -0
  117. package/dist/hitl/approvalHolds.js +140 -0
  118. package/dist/hitl/approvalOutcomeNote.js +2 -1
  119. package/dist/hitl/approvalResolution.js +9 -1
  120. package/dist/hitl/approvalsFeed.js +23 -6
  121. package/dist/hitl/askGateWire.d.ts +2 -1
  122. package/dist/hitl/askGateWire.js +29 -1
  123. package/dist/hitl/automaticAnswerVerdict.d.ts +8 -2
  124. package/dist/hitl/automaticAnswerVerdict.js +71 -23
  125. package/dist/hitl/crashConverged.js +2 -0
  126. package/dist/hitl/decisionConflict.d.ts +3 -0
  127. package/dist/hitl/decisionConflict.js +43 -0
  128. package/dist/hitl/decisionRefusal.d.ts +23 -0
  129. package/dist/hitl/decisionRefusal.js +88 -0
  130. package/dist/hitl/frameRouter.d.ts +10 -0
  131. package/dist/hitl/frameRouter.js +71 -32
  132. package/dist/hitl/gateLedger.d.ts +8 -0
  133. package/dist/hitl/gateLedger.js +38 -0
  134. package/dist/hitl/hitlBridge.d.ts +14 -3
  135. package/dist/hitl/hitlBridge.js +75 -62
  136. package/dist/hitl/hitlHostSurface.d.ts +3 -0
  137. package/dist/hitl/hitlHostSurface.js +17 -15
  138. package/dist/hitl/livePendingAsk.d.ts +16 -6
  139. package/dist/hitl/livePendingAsk.js +36 -4
  140. package/dist/hitl/localAllowRule.js +2 -1
  141. package/dist/hitl/noAllowCause.d.ts +9 -0
  142. package/dist/hitl/noAllowCause.js +26 -0
  143. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  144. package/dist/hitl/parkExpiryJudgements.js +46 -0
  145. package/dist/hitl/parkResolver.d.ts +3 -7
  146. package/dist/hitl/parkResolver.js +55 -28
  147. package/dist/hitl/parkRowBirthWait.js +2 -1
  148. package/dist/hitl/persistedRulesWire.d.ts +6 -1
  149. package/dist/hitl/persistedRulesWire.js +16 -4
  150. package/dist/hitl/planReviewWire.d.ts +2 -3
  151. package/dist/hitl/planReviewWire.js +86 -39
  152. package/dist/hitl/replayedApproval.d.ts +8 -0
  153. package/dist/hitl/replayedApproval.js +125 -10
  154. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  155. package/dist/hitl/resumeRunningCard.js +15 -4
  156. package/dist/hitl/sessionPolicyDeliverable.d.ts +1 -1
  157. package/dist/hitl/sessionPolicyDeliverable.js +3 -8
  158. package/dist/hitl/sessionPolicyWire.js +1 -1
  159. package/dist/hitl/toolApprovalWire.d.ts +50 -5
  160. package/dist/hitl/toolApprovalWire.js +368 -56
  161. package/dist/hooksWireCaps.js +38 -6
  162. package/dist/host.d.ts +5 -0
  163. package/dist/host.js +3 -1
  164. package/dist/hostCallbackGuard.d.ts +1 -0
  165. package/dist/hostCallbackGuard.js +25 -0
  166. package/dist/humanTurnRead.d.ts +15 -1
  167. package/dist/humanTurnRead.js +28 -2
  168. package/dist/index.d.ts +45 -14
  169. package/dist/index.js +33 -12
  170. package/dist/interactiveInterrupt.d.ts +8 -0
  171. package/dist/interactiveInterrupt.js +54 -0
  172. package/dist/limitsWire.d.ts +5 -1
  173. package/dist/limitsWire.js +51 -13
  174. package/dist/liveModelCatalog.d.ts +109 -0
  175. package/dist/liveModelCatalog.js +344 -18
  176. package/dist/mcpEngineLeg.d.ts +25 -0
  177. package/dist/mcpEngineLeg.js +71 -15
  178. package/dist/mcpPanel.js +2 -1
  179. package/dist/mcpProbeCapability.d.ts +0 -1
  180. package/dist/mcpProbeCapability.js +13 -12
  181. package/dist/mcpReconnect.d.ts +1 -3
  182. package/dist/mcpReconnect.js +20 -10
  183. package/dist/memoryComplianceCapability.d.ts +0 -1
  184. package/dist/memoryComplianceCapability.js +14 -13
  185. package/dist/memoryOriginCapability.d.ts +0 -1
  186. package/dist/memoryOriginCapability.js +14 -13
  187. package/dist/memoryVerbsWire.d.ts +1 -1
  188. package/dist/memoryVerbsWire.js +4 -0
  189. package/dist/model/liveCatalogShape.d.ts +14 -0
  190. package/dist/model/liveCatalogShape.js +71 -0
  191. package/dist/model/modelSupplyRules.d.ts +1 -0
  192. package/dist/model/modelSupplyRules.js +30 -9
  193. package/dist/model/modelsPolicy.d.ts +21 -0
  194. package/dist/model/modelsPolicy.js +90 -0
  195. package/dist/modelIdentityResolvability.d.ts +4 -2
  196. package/dist/modelIdentityResolvability.js +25 -5
  197. package/dist/modelSwitchFallback.d.ts +69 -0
  198. package/dist/modelSwitchFallback.js +206 -0
  199. package/dist/notifications.js +12 -11
  200. package/dist/outputStyleSeatCapability.d.ts +15 -0
  201. package/dist/outputStyleSeatCapability.js +42 -0
  202. package/dist/ownKey.d.ts +7 -0
  203. package/dist/ownKey.js +58 -0
  204. package/dist/panelReduce.d.ts +114 -0
  205. package/dist/panelReduce.js +1135 -0
  206. package/dist/panelStateHolder.d.ts +17 -0
  207. package/dist/panelStateHolder.js +201 -0
  208. package/dist/peerLaneCapability.d.ts +0 -1
  209. package/dist/peerLaneCapability.js +15 -14
  210. package/dist/permissionModesCapability.d.ts +0 -1
  211. package/dist/permissionModesCapability.js +5 -10
  212. package/dist/permissionRuleIssue.js +1 -1
  213. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  214. package/dist/permissionRulesWriteCapability.js +15 -14
  215. package/dist/permissionsAllowGrantCapability.d.ts +2 -1
  216. package/dist/permissionsAllowGrantCapability.js +35 -19
  217. package/dist/permissionsDeclaration.d.ts +16 -1
  218. package/dist/permissionsDeclaration.js +142 -15
  219. package/dist/printToolResultFrame.js +2 -10
  220. package/dist/promptDelivery.js +0 -8
  221. package/dist/protocolSegment.d.ts +1 -0
  222. package/dist/protocolSegment.js +13 -1
  223. package/dist/request/taskRequest.d.ts +11 -3
  224. package/dist/request/taskRequest.js +13 -1
  225. package/dist/resultFrameKeys.d.ts +4 -0
  226. package/dist/resultFrameKeys.js +13 -0
  227. package/dist/resumeRefusalCopy.d.ts +18 -1
  228. package/dist/resumeRefusalCopy.js +132 -31
  229. package/dist/retryStatus.js +6 -4
  230. package/dist/rewindArchiveCapability.d.ts +2 -1
  231. package/dist/rewindArchiveCapability.js +28 -15
  232. package/dist/rewindEngineAction.d.ts +21 -0
  233. package/dist/rewindEngineAction.js +36 -0
  234. package/dist/rewindWireCaps.d.ts +2 -1
  235. package/dist/rewindWireCaps.js +1 -0
  236. package/dist/{hitl/rosterMountedNames.d.ts → rosterMountedNames.d.ts} +1 -1
  237. package/dist/runCancelContext.js +2 -1
  238. package/dist/runTerminal.d.ts +0 -11
  239. package/dist/runTerminal.js +4 -27
  240. package/dist/sdkRegistryTransit.d.ts +2 -1
  241. package/dist/sdkRegistryTransit.js +1 -0
  242. package/dist/sealedKeyCapability.d.ts +0 -1
  243. package/dist/sealedKeyCapability.js +19 -20
  244. package/dist/seatContract.d.ts +85 -28
  245. package/dist/seatContract.js +512 -148
  246. package/dist/sessionIdSegment.d.ts +1 -0
  247. package/dist/sessionIdSegment.js +11 -0
  248. package/dist/sessionMemoryErase.d.ts +1 -1
  249. package/dist/sessionMemoryErase.js +6 -1
  250. package/dist/sessionMemoryStatus.js +3 -2
  251. package/dist/sessionPolicyCapability.d.ts +0 -1
  252. package/dist/sessionPolicyCapability.js +14 -13
  253. package/dist/sessionReadRedactionCapability.d.ts +15 -0
  254. package/dist/sessionReadRedactionCapability.js +42 -0
  255. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -1
  256. package/dist/sessionSyncFileHistoryCapability.js +13 -12
  257. package/dist/skillToolListsCapability.d.ts +0 -1
  258. package/dist/skillToolListsCapability.js +13 -12
  259. package/dist/skillsWireCaps.d.ts +4 -0
  260. package/dist/skillsWireCaps.js +66 -1
  261. package/dist/sqlEngineCapability.d.ts +0 -1
  262. package/dist/sqlEngineCapability.js +21 -21
  263. package/dist/steerPriorityCapability.d.ts +0 -1
  264. package/dist/steerPriorityCapability.js +18 -19
  265. package/dist/storePostureCapability.d.ts +1 -1
  266. package/dist/storePostureCapability.js +16 -16
  267. package/dist/streamDrainingLegs.d.ts +6 -0
  268. package/dist/streamDrainingLegs.js +23 -0
  269. package/dist/subagent/agentStateDetail.d.ts +1 -0
  270. package/dist/subagent/agentStateDetail.js +41 -0
  271. package/dist/subagent/engineCompactWire.d.ts +15 -0
  272. package/dist/subagent/engineCompactWire.js +82 -45
  273. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  274. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  275. package/dist/subagent/engineSubagentOutput.js +5 -20
  276. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  277. package/dist/subagent/engineSubagentTail.js +7 -32
  278. package/dist/subagentContentStore.js +3 -3
  279. package/dist/supportFloor.js +2 -5
  280. package/dist/taskRequestWords.d.ts +2 -4
  281. package/dist/taskRequestWords.js +3 -2
  282. package/dist/terminalStatuses.d.ts +30 -0
  283. package/dist/terminalStatuses.js +67 -0
  284. package/dist/toolResult.d.ts +5 -0
  285. package/dist/toolResult.js +88 -36
  286. package/dist/types/engineState.d.ts +2 -1
  287. package/dist/usageAnalytics.d.ts +146 -0
  288. package/dist/usageAnalytics.js +311 -0
  289. package/dist/userAttachmentEnvelope.d.ts +22 -1
  290. package/dist/userAttachmentEnvelope.js +90 -2
  291. package/dist/userInvokedSkillsCapability.d.ts +0 -1
  292. package/dist/userInvokedSkillsCapability.js +13 -12
  293. package/dist/webSearchBackendCapability.d.ts +0 -1
  294. package/dist/webSearchBackendCapability.js +20 -19
  295. package/dist/webSearchWireCaps.js +3 -11
  296. package/dist/wireErrorTriage.d.ts +11 -0
  297. package/dist/wireErrorTriage.js +35 -0
  298. package/dist/wireFailureShape.d.ts +10 -0
  299. package/dist/wireFailureShape.js +72 -5
  300. package/dist/wireRefusalCopy.d.ts +6 -1
  301. package/dist/wireRefusalCopy.js +23 -25
  302. package/dist/wiringInstructionsAttribution.d.ts +10 -0
  303. package/dist/wiringInstructionsAttribution.js +67 -0
  304. package/dist/workflowClient.js +19 -2
  305. package/dist/workflowsJournalCapability.d.ts +0 -1
  306. package/dist/workflowsJournalCapability.js +13 -12
  307. package/dist/writeProtectionCapability.d.ts +0 -1
  308. package/dist/writeProtectionCapability.js +26 -26
  309. package/docs/INTEGRATION-CLIENTS.md +1733 -52
  310. package/package.json +5 -5
  311. package/dist/askSurvivesStandingAnswer.d.ts +0 -13
  312. package/dist/askSurvivesStandingAnswer.js +0 -53
  313. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  314. package/dist/engineCapsGenerationGuard.js +0 -19
  315. package/dist/hitl/askSurvivesPosture.d.ts +0 -20
  316. package/dist/hitl/askSurvivesPosture.js +0 -48
  317. package/dist/panelRunningHistory.d.ts +0 -22
  318. package/dist/panelRunningHistory.js +0 -82
  319. package/dist/registryConflict.d.ts +0 -3
  320. package/dist/registryConflict.js +0 -44
  321. /package/dist/{hitl/rosterMountedNames.js → rosterMountedNames.js} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { hostLog } from '../host.js';
2
+ import { invokeHostCallbackIsolated } from '../hostCallbackGuard.js';
2
3
  import { engineWireDebugEnabled } from '../engineWireTarget.js';
3
4
  import { engineSessionParam, engineSessionParamFor } from '../engineSessionParam.js';
4
5
  import { enqueueBgChildNotification, isOwnWorkflowRun } from '../notifications.js';
@@ -7,7 +8,10 @@ import { rowIdTail } from '../workflow.js';
7
8
  import { recordEngineTranscriptId } from '../subagent/engineDelegatedPrompt.js';
8
9
  import { recordFleetRowAgentType } from './fleetRowAgentType.js';
9
10
  import { DEFAULT_SESSION_KEY } from '../sessionSlot.js';
10
- import { TERMINAL_FLEET_TASK_STATUSES, projectTasks, projectWorkflows, wireCycleSeq, wireParentId, } from './fleetProjection.js';
11
+ import { isSdkFleetTaskTerminal, isSdkFleetTaskTerminalNotSuccess } from '../terminalStatuses.js';
12
+ import { projectTasks, projectWorkflows, wireCycleSeq, wireParentId, } from './fleetProjection.js';
13
+ import { isInStreamDrainingEnd } from '../wireErrorTriage.js';
14
+ import { cycleSeqOrder, cycleSeqValue } from '../cycleOrder.js';
11
15
  export const TERMINAL_RETAIN_MS = 60_000;
12
16
  const liveBgViews = new Map();
13
17
  function viewsFor(sessionKey) {
@@ -58,6 +62,16 @@ export function clearAllRetainedFleetRowsFor(sessionKey) {
58
62
  }
59
63
  }
60
64
  }
65
+ export function forgetSettledTerminalRow(id) {
66
+ return forgetSettledTerminalRowFor(DEFAULT_SESSION_KEY, id);
67
+ }
68
+ export function forgetSettledTerminalRowFor(sessionKey, id) {
69
+ let forgotten = false;
70
+ for (const view of viewsFor(sessionKey))
71
+ if (view.forgetSettledTerminal(id))
72
+ forgotten = true;
73
+ return forgotten;
74
+ }
61
75
  export function __resetFleetLedgerRegistryForTests() {
62
76
  liveBgViews.clear();
63
77
  }
@@ -87,7 +101,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
87
101
  if (gen === undefined || tail.length === 0)
88
102
  return;
89
103
  const prior = cycleWatermark.get(tail);
90
- if (prior !== undefined && prior >= gen)
104
+ if (prior !== undefined && cycleSeqOrder(prior, gen) !== 'before')
91
105
  return;
92
106
  cycleWatermark.delete(tail);
93
107
  if (cycleWatermark.size >= CYCLE_WATERMARK_MAX) {
@@ -129,10 +143,24 @@ export function createFleetLedger(hooks = {}, opts = {}) {
129
143
  ...(retired ? { retiredByNotification: true } : {}),
130
144
  };
131
145
  };
146
+ function forgetSettledTerminalRowOf(id) {
147
+ const live = taskMap.get(id);
148
+ if (live !== undefined && !isSdkFleetTaskTerminal(live.status))
149
+ return false;
150
+ const pooled = retained.get(id);
151
+ if (pooled?.retiredByNotification === true)
152
+ return false;
153
+ if (live === undefined && pooled === undefined)
154
+ return false;
155
+ taskMap.delete(id);
156
+ rowMeta.delete(id);
157
+ retained.delete(id);
158
+ return true;
159
+ }
132
160
  const bgView = {
133
161
  read: () => {
134
162
  const rows = [...taskMap.values()]
135
- .filter(r => !TERMINAL_FLEET_TASK_STATUSES.has(r.status ?? ''))
163
+ .filter(r => !isSdkFleetTaskTerminal(r.status))
136
164
  .map(r => toBgTask(r, false));
137
165
  const nowMs = nowFn();
138
166
  for (const [id, r] of retained) {
@@ -150,6 +178,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
150
178
  clearRetained: () => {
151
179
  retained.clear();
152
180
  },
181
+ forgetSettledTerminal: id => forgetSettledTerminalRowOf(id),
153
182
  };
154
183
  {
155
184
  let views = liveBgViews.get(sessionKey);
@@ -178,7 +207,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
178
207
  for (const row of frame.tasks) {
179
208
  taskMap.set(row.id, row);
180
209
  rowMeta.set(row.id, { receivedAtMs });
181
- if (!TERMINAL_FLEET_TASK_STATUSES.has(row.status ?? '')) {
210
+ if (!isSdkFleetTaskTerminal(row.status)) {
182
211
  const tail = rowIdTail(row.id);
183
212
  for (const id of [...retained.keys()]) {
184
213
  if (rowIdTail(id) === tail)
@@ -223,7 +252,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
223
252
  recordEngineTranscriptId(rowIdTail(row.id), row.transcriptId);
224
253
  }
225
254
  recordFleetRowAgentType(rowIdTail(row.id), row.agentType);
226
- if (TERMINAL_FLEET_TASK_STATUSES.has(row.status ?? '')) {
255
+ if (isSdkFleetTaskTerminal(row.status)) {
227
256
  retained.set(row.id, { row, expireAt: receivedAtMs + TERMINAL_RETAIN_MS });
228
257
  const tailT = rowIdTail(row.id);
229
258
  for (const id of [...retained.keys()]) {
@@ -244,33 +273,32 @@ export function createFleetLedger(hooks = {}, opts = {}) {
244
273
  }
245
274
  case 'task_remove': {
246
275
  const fr = frame;
247
- const removedGen = typeof fr.cycleSeq === 'number' && Number.isInteger(fr.cycleSeq) && fr.cycleSeq >= 1 ? fr.cycleSeq : undefined;
276
+ const removedGen = cycleSeqValue(fr.cycleSeq);
248
277
  const held = taskMap.get(frame.id);
249
278
  const heldGen = held !== undefined ? wireCycleSeq(held) : undefined;
250
- const stale = removedGen !== undefined && heldGen !== undefined && removedGen < heldGen;
279
+ const stale = cycleSeqOrder(removedGen, heldGen) === 'before';
280
+ const reason = typeof fr.removeReason === 'string' && fr.removeReason.length > 0 ? fr.removeReason : undefined;
251
281
  if (!stale) {
252
282
  taskMap.delete(frame.id);
253
283
  rowMeta.delete(frame.id);
254
- }
255
- if (hooks.onTaskRemoved !== undefined) {
256
- const reason = typeof fr.removeReason === 'string' && fr.removeReason.length > 0 ? fr.removeReason : undefined;
257
- try {
258
- const out = hooks.onTaskRemoved({
259
- id: frame.id,
260
- ...(reason !== undefined ? { removeReason: reason } : {}),
261
- ...(removedGen !== undefined ? { cycleSeq: removedGen } : {}),
262
- ...(stale ? { stale: true } : {}),
263
- ...(held === undefined ? { unknownRow: true } : {}),
264
- });
265
- if (out && typeof out.then === 'function') {
266
- void Promise.resolve(out).catch((e) => {
267
- hostLog('debug', `[fleet-frame] onTaskRemoved hook rejected: ${String(e).slice(0, 160)}`);
268
- });
284
+ if (reason === undefined) {
285
+ const pooled = retained.get(frame.id);
286
+ if (pooled !== undefined &&
287
+ pooled.row.status === 'killed' &&
288
+ cycleSeqOrder(removedGen, wireCycleSeq(pooled.row)) !== 'before' &&
289
+ forgetSettledTerminalRowOf(frame.id)) {
290
+ debug(`[fleet-frame] settled-level task_remove evicted the stopped row(id=${frame.id})`);
269
291
  }
270
292
  }
271
- catch (e) {
272
- hostLog('debug', `[fleet-frame] onTaskRemoved hook threw: ${String(e).slice(0, 160)}`);
273
- }
293
+ }
294
+ if (hooks.onTaskRemoved !== undefined) {
295
+ invokeHostCallbackIsolated('[fleet-frame] onTaskRemoved hook', () => hooks.onTaskRemoved?.({
296
+ id: frame.id,
297
+ ...(reason !== undefined ? { removeReason: reason } : {}),
298
+ ...(removedGen !== undefined ? { cycleSeq: removedGen } : {}),
299
+ ...(stale ? { stale: true } : {}),
300
+ ...(held === undefined ? { unknownRow: true } : {}),
301
+ }));
274
302
  }
275
303
  break;
276
304
  }
@@ -293,6 +321,10 @@ export function createFleetLedger(hooks = {}, opts = {}) {
293
321
  applyBgNotification(frame.notification, ing);
294
322
  break;
295
323
  default:
324
+ if (isInStreamDrainingEnd(frame)) {
325
+ debug('[fleet-frame] drain end frame — the engine is going down; the host reconnects');
326
+ break;
327
+ }
296
328
  droppedUnknownFrame++;
297
329
  debug(`[fleet-frame] UNKNOWN frame type ignored(type=${String(frame.type)})`);
298
330
  break;
@@ -340,29 +372,30 @@ export function createFleetLedger(hooks = {}, opts = {}) {
340
372
  ? 'own_parent'
341
373
  : 'absent_parent');
342
374
  debug(`[fleet-frame] bg_notification taskId=${n.taskId} status=${n.status} seq=${n.seq ?? '-'} accept=${evidence}`);
375
+ const notifTail = rowIdTail(n.taskId);
343
376
  const rowIds = [];
344
377
  for (const id of taskMap.keys()) {
345
- if (id === n.taskId || rowIdTail(id) === n.taskId)
378
+ if (rowIdTail(id) === notifTail)
346
379
  rowIds.push(id);
347
380
  }
348
- if (TERMINAL_FLEET_TASK_STATUSES.has(n.status)) {
381
+ if (isSdkFleetTaskTerminal(n.status)) {
349
382
  if (typeof n.parentTaskId === 'string' && n.parentTaskId) {
350
383
  recordBgParentRun(n.taskId, n.parentTaskId, ing?.session, ing?.sessionKey);
351
384
  }
352
385
  if (typeof n.transcriptId === 'string' && n.transcriptId.length > 0) {
353
386
  recordEngineTranscriptId(n.taskId, n.transcriptId);
354
387
  }
355
- const isWashGreen = (prior, next) => next === 'completed' && (prior === 'failed' || prior === 'killed');
388
+ const isWashGreen = (prior, next) => next === 'completed' && isSdkFleetTaskTerminalNotSuccess(prior);
356
389
  const coerced = n.status;
357
390
  const nowMs = nowFn();
358
391
  const writtenIds = new Set();
359
392
  let applied = false;
360
393
  let washBlocked = false;
361
394
  let staleBlocked = false;
362
- const notifSeq = typeof n.seq === 'number' && Number.isInteger(n.seq) && n.seq >= 1 ? n.seq : undefined;
395
+ const notifSeq = cycleSeqValue(n.seq);
363
396
  {
364
397
  const mark = cycleWatermark.get(n.taskId);
365
- if (notifSeq !== undefined && mark !== undefined && notifSeq < mark) {
398
+ if (cycleSeqOrder(notifSeq, mark) === 'before') {
366
399
  staleBlocked = true;
367
400
  debug(`[fleet-frame] bg_notification stale-cycle ignored(watermark=${mark} notif-seq=${notifSeq})`);
368
401
  }
@@ -372,13 +405,13 @@ export function createFleetLedger(hooks = {}, opts = {}) {
372
405
  if (!known)
373
406
  continue;
374
407
  const heldGen = wireCycleSeq(known);
375
- if (notifSeq !== undefined && heldGen !== undefined && notifSeq < heldGen) {
408
+ if (cycleSeqOrder(notifSeq, heldGen) === 'before') {
376
409
  staleBlocked = true;
377
410
  debug(`[fleet-frame] bg_notification stale-cycle ignored(row=${id} row-cycle=${heldGen} notif-seq=${notifSeq})`);
378
411
  continue;
379
412
  }
380
413
  const rowStatus = known.status ?? '';
381
- if (TERMINAL_FLEET_TASK_STATUSES.has(rowStatus)) {
414
+ if (isSdkFleetTaskTerminal(rowStatus)) {
382
415
  if (isWashGreen(rowStatus, n.status)) {
383
416
  washBlocked = true;
384
417
  debug(`[fleet-frame] bg_notification WASH-GREEN blocked(row=${id} row-status=${rowStatus} notif=${n.status})`);
@@ -418,10 +451,10 @@ export function createFleetLedger(hooks = {}, opts = {}) {
418
451
  for (const [id, entry] of retained) {
419
452
  if (writtenIds.has(id))
420
453
  continue;
421
- if (id !== n.taskId && rowIdTail(id) !== n.taskId)
454
+ if (rowIdTail(id) !== notifTail)
422
455
  continue;
423
456
  const retainedGen = wireCycleSeq(entry.row);
424
- if (notifSeq !== undefined && retainedGen !== undefined && notifSeq < retainedGen) {
457
+ if (cycleSeqOrder(notifSeq, retainedGen) === 'before') {
425
458
  staleBlocked = true;
426
459
  debug(`[fleet-frame] bg_notification stale-cycle ignored(retained=${id} row-cycle=${retainedGen} notif-seq=${notifSeq})`);
427
460
  continue;
@@ -450,12 +483,11 @@ export function createFleetLedger(hooks = {}, opts = {}) {
450
483
  const prior = getBgTerminalFacts(n.taskId);
451
484
  if (prior === undefined)
452
485
  return true;
453
- if (notifSeq !== undefined && prior.cycleSeq !== undefined) {
454
- if (notifSeq < prior.cycleSeq)
455
- return false;
456
- if (notifSeq > prior.cycleSeq)
457
- return true;
458
- }
486
+ const order = cycleSeqOrder(notifSeq, prior.cycleSeq);
487
+ if (order === 'before')
488
+ return false;
489
+ if (order === 'after')
490
+ return true;
459
491
  return !isWashGreen(prior.status, n.status);
460
492
  })()));
461
493
  if (factsAccepted)
@@ -482,17 +514,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
482
514
  debug(`[fleet-frame] bg_notification state-plane rejected as wash-green echo(taskId=${n.taskId} notif=${n.status})—— 通知面照常入队`);
483
515
  }
484
516
  }
485
- try {
486
- const out = hooks.onBgNotificationAccepted?.(n, rowIds, evidence);
487
- if (out && typeof out.then === 'function') {
488
- void Promise.resolve(out).catch((e) => {
489
- hostLog('debug', `[fleet-frame] onBgNotificationAccepted hook rejected: ${String(e).slice(0, 160)}`);
490
- });
491
- }
492
- }
493
- catch (e) {
494
- hostLog('debug', `[fleet-frame] onBgNotificationAccepted hook threw: ${String(e).slice(0, 160)}`);
495
- }
517
+ invokeHostCallbackIsolated('[fleet-frame] onBgNotificationAccepted hook', () => hooks.onBgNotificationAccepted?.(n, rowIds, evidence));
496
518
  enqueueBgChildNotification({
497
519
  taskId: n.taskId,
498
520
  status: n.status,
@@ -503,7 +525,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
503
525
  function project(nowMs, opts) {
504
526
  const viewingTaskId = opts.viewingTaskId;
505
527
  const liveRows = [...taskMap.values()].map(r => {
506
- if (TERMINAL_FLEET_TASK_STATUSES.has(r.status ?? ''))
528
+ if (isSdkFleetTaskTerminal(r.status))
507
529
  return r;
508
530
  const started = r.startedAt;
509
531
  if (typeof started === 'number' && started > 0 && started <= nowMs) {
@@ -10,7 +10,6 @@ export interface FleetTaskView {
10
10
  elapsedMs?: number;
11
11
  tokens?: number;
12
12
  tokenDir: 'down' | 'up';
13
- queuedCount?: number;
14
13
  awaitingPlanApproval: boolean;
15
14
  descendantCount: number;
16
15
  viewed: boolean;
@@ -51,9 +50,7 @@ export interface FleetWorkflowView {
51
50
  tokens?: number;
52
51
  failedCount?: number;
53
52
  startedCount?: number;
54
- errorCode?: string;
55
53
  }
56
- export declare const TERMINAL_FLEET_TASK_STATUSES: ReadonlySet<string>;
57
54
  export declare function coerceTaskStatus(s: string): FleetTaskStatus;
58
55
  export declare function coerceWorkflowStatus(s: string | undefined): FleetTaskStatus;
59
56
  export declare const CONTROL_TOOL_VERBS: ReadonlySet<string>;
@@ -1,12 +1,8 @@
1
1
  import { collapseLabel, escapeDisplayControlChars, taskDescFromName } from '../fleetTaskDesc.js';
2
2
  import { rowIdTail } from '../workflow.js';
3
+ import { cycleSeqValue } from '../cycleOrder.js';
3
4
  import { frozenSet } from '../frozenSet.js';
4
5
  import { CORE_RESERVED_AGENT_NAMES } from '../generated/engineFactTables.js';
5
- export const TERMINAL_FLEET_TASK_STATUSES = frozenSet([
6
- 'completed',
7
- 'failed',
8
- 'killed',
9
- ]);
10
6
  export function coerceTaskStatus(s) {
11
7
  switch (s) {
12
8
  case 'queued':
@@ -130,8 +126,7 @@ function wireStoppedBy(r) {
130
126
  return typeof v === 'string' && v.length > 0 ? v : undefined;
131
127
  }
132
128
  export function wireCycleSeq(r) {
133
- const v = r.cycleSeq;
134
- return typeof v === 'number' && Number.isInteger(v) && v > 0 ? v : undefined;
129
+ return cycleSeqValue(r.cycleSeq);
135
130
  }
136
131
  function wireRetiredBy(r) {
137
132
  const v = r.retiredBy;
@@ -182,7 +177,6 @@ export function projectTasks(allRows, opts) {
182
177
  ...wireNumberKey('elapsedMs', wireDuration(r.elapsedMs)),
183
178
  ...wireNumberKey('tokens', wireCount(r.tokens)),
184
179
  tokenDir: 'down',
185
- ...wireNumberKey('queuedCount', wireCount(r.queuedCount)),
186
180
  awaitingPlanApproval: r.awaitingPlanApproval ?? false,
187
181
  descendantCount: childCount.get(r.id) ?? 0,
188
182
  viewed: viewingTaskId !== undefined && rowIdTail(r.id) === viewingTaskId,
@@ -213,7 +207,6 @@ function wireNumberKey(key, v) {
213
207
  export function projectWorkflows(rows) {
214
208
  return rows.map(r => {
215
209
  const startedCount = wireStartedCount(r);
216
- const errorCode = wireErrorCode(r);
217
210
  return {
218
211
  id: r.id,
219
212
  name: collapseLabel(r.name ?? '') || 'Dynamic workflow',
@@ -225,14 +218,9 @@ export function projectWorkflows(rows) {
225
218
  ...wireNumberKey('tokens', wireCount(r.tokens)),
226
219
  ...wireNumberKey('failedCount', wireCount(r.failedCount)),
227
220
  ...(startedCount !== undefined ? { startedCount } : {}),
228
- ...(errorCode !== undefined ? { errorCode } : {}),
229
221
  };
230
222
  });
231
223
  }
232
- function wireErrorCode(r) {
233
- const v = r.errorCode;
234
- return typeof v === 'string' && v.length > 0 ? v : undefined;
235
- }
236
224
  const FLEET_TASK_VIEW_KEY_TUPLE = [
237
225
  'id',
238
226
  'name',
@@ -243,7 +231,6 @@ const FLEET_TASK_VIEW_KEY_TUPLE = [
243
231
  'elapsedMs',
244
232
  'tokens',
245
233
  'tokenDir',
246
- 'queuedCount',
247
234
  'awaitingPlanApproval',
248
235
  'descendantCount',
249
236
  'viewed',
@@ -271,7 +258,6 @@ const FLEET_WORKFLOW_VIEW_KEY_TUPLE = [
271
258
  'tokens',
272
259
  'failedCount',
273
260
  'startedCount',
274
- 'errorCode',
275
261
  ];
276
262
  export const FLEET_WORKFLOW_VIEW_KEYS = FLEET_WORKFLOW_VIEW_KEY_TUPLE;
277
263
  const FLEET_TASK_ROW_WIRE_KEY_TUPLE = [
@@ -337,6 +323,13 @@ export const FLEET_TASK_ROW_KEYS_NOT_PROJECTED = {
337
323
  owner: 'client-core 规范重构轮',
338
324
  reason: '同 agentType:两位在本层合成一个身份 label,分开带出去等于把 187 的 tjl 规则推给每个消费端各写一遍。',
339
325
  },
326
+ queuedCount: {
327
+ kind: 'by-design',
328
+ owner: 'client-core 0.95.0 CC-388',
329
+ reason: '幻影键:sdk 行型仍声明它,但任何 server 版本都不发(生产侧已整只删除,零生产者,契约里也从没列过)。' +
330
+ '投影一个永远缺席的可选位 = 假线索(读者以为「队列深度已经报了」),所以视图上不留位。' +
331
+ 'sdk 在下一个 major 删掉这条声明的同批,本条与 `FLEET_TASK_ROW_WIRE_KEYS` 的 `queuedCount` 一起删;真要队列深度 = 带生产者的新键,不是复活这一个。',
332
+ },
340
333
  workflowRunId: {
341
334
  kind: 'by-design',
342
335
  owner: 'client-core 规范重构轮',
@@ -1,20 +1,7 @@
1
- export interface FleetAgentRowLike {
2
- id: string;
3
- name?: string;
4
- description?: string;
5
- status?: string;
6
- tokens?: number;
7
- toolUses?: number;
8
- transcriptId?: string;
9
- currentTool?: {
10
- toolName: string;
11
- target?: string;
12
- };
13
- startedAt?: number;
14
- cycleSeq?: number;
15
- parentToolCallId?: string;
16
- }
17
- export declare const ABSENT_SETTLE_MS = 30000;
1
+ import { ABSENT_SETTLE_MS } from './panelReduce.js';
2
+ import type { FleetAgentRowLike } from './fleetAgentRowLike.js';
3
+ export type { FleetAgentRowLike };
4
+ export { ABSENT_SETTLE_MS };
18
5
  export declare function resetFleetAgentPanelProjection(): void;
19
6
  export declare function resetFleetAgentPanelProjectionFor(sessionKey: string): void;
20
7
  export declare function fleetAgentProjectionSize(): number;
@@ -1,212 +1,22 @@
1
- import { isStaleEngineAgentPanelEnd, publishEngineAgentPanelAbsence, publishEngineAgentPanelEvent } from './engineAgentPanelStore.js';
2
- import { __resetPanelRunningHistoryForTests, notePanelRowRunning, panelRowUnknownToConsumer, panelRowEndedIdentity, holdNewbornTerminalRow, peekHeldNewbornTerminalRow, dropHeldNewbornTerminalRow } from './panelRunningHistory.js';
3
- import { rowIdTail } from './workflow.js';
4
- import { TERMINAL_FLEET_TASK_STATUSES } from './fleet/fleetProjection.js';
1
+ import { ABSENT_SETTLE_MS, panelPresenceSize } from './panelReduce.js';
2
+ import { panelStateNow, stepEnginePanel } from './panelStateHolder.js';
5
3
  import { DEFAULT_SESSION_KEY } from './sessionSlot.js';
6
- import { isTerminalNotSuccess } from './runTerminal.js';
7
- export const ABSENT_SETTLE_MS = 30_000;
8
- const SETTLED_RETENTION_MS = ABSENT_SETTLE_MS * 4;
9
- function currentToolKeyOf(ct) {
10
- if (!ct || typeof ct.toolName !== 'string' || ct.toolName.length === 0)
11
- return undefined;
12
- return `${ct.toolName}\u0000${ct.target ?? ''}`;
13
- }
14
- const seen = new Map();
15
- function seenFor(sessionKey) {
16
- let m = seen.get(sessionKey);
17
- if (!m) {
18
- m = new Map();
19
- seen.set(sessionKey, m);
20
- }
21
- return m;
22
- }
4
+ export { ABSENT_SETTLE_MS };
23
5
  export function resetFleetAgentPanelProjection() {
24
- seen.clear();
25
- __resetPanelRunningHistoryForTests();
6
+ stepEnginePanel({ kind: 'fleet-rows-reset' });
26
7
  }
27
8
  export function resetFleetAgentPanelProjectionFor(sessionKey) {
28
- seen.delete(sessionKey);
9
+ stepEnginePanel({ kind: 'fleet-rows-reset', sessionKey });
29
10
  }
30
11
  export function fleetAgentProjectionSize() {
31
12
  return fleetAgentProjectionSizeFor(DEFAULT_SESSION_KEY);
32
13
  }
33
14
  export function fleetAgentProjectionSizeFor(sessionKey) {
34
- return seen.get(sessionKey)?.size ?? 0;
15
+ return panelPresenceSize(panelStateNow(), sessionKey);
35
16
  }
36
17
  export function projectFleetAgentRows(rows, nowMs = Date.now()) {
37
18
  projectFleetAgentRowsFor(DEFAULT_SESSION_KEY, rows, nowMs);
38
19
  }
39
20
  export function projectFleetAgentRowsFor(sessionKey, rows, nowMs = Date.now()) {
40
- const seenMap = seenFor(sessionKey);
41
- const present = new Set();
42
- for (const row of rows) {
43
- if (!row?.id)
44
- continue;
45
- const taskId = rowIdTail(row.id);
46
- if (!taskId)
47
- continue;
48
- present.add(taskId);
49
- const status = row.status ?? 'running';
50
- const wireTokens = typeof row.tokens === 'number' && Number.isInteger(row.tokens) && row.tokens >= 0 ? row.tokens : undefined;
51
- const tokens = wireTokens;
52
- const toolUses = typeof row.toolUses === 'number' ? row.toolUses : undefined;
53
- const transcriptId = row.transcriptId || undefined;
54
- const parentToolCallId = typeof row.parentToolCallId === 'string' && row.parentToolCallId.length > 0 ? row.parentToolCallId : undefined;
55
- const startedAt = typeof row.startedAt === 'number' && Number.isFinite(row.startedAt) && row.startedAt > 0 ? row.startedAt : undefined;
56
- const cycleSeq = typeof row.cycleSeq === 'number' && Number.isInteger(row.cycleSeq) && row.cycleSeq >= 1 ? row.cycleSeq : undefined;
57
- const currentTool = currentToolKeyOf(row.currentTool) !== undefined ? row.currentTool : undefined;
58
- const currentToolKey = currentToolKeyOf(row.currentTool);
59
- const prev = seenMap.get(taskId);
60
- const rowIdentity = { ...(cycleSeq !== undefined ? { cycleSeq } : {}), ...(startedAt !== undefined ? { startedAt } : {}) };
61
- const prevIdentity = prev !== undefined
62
- ? { ...(prev.cycleSeq !== undefined ? { cycleSeq: prev.cycleSeq } : {}), ...(prev.startedAt !== undefined ? { startedAt: prev.startedAt } : {}) }
63
- : undefined;
64
- if (prev !== undefined && isStaleEngineAgentPanelEnd(rowIdentity, prevIdentity))
65
- continue;
66
- const rowNewerCycle = prev !== undefined && isStaleEngineAgentPanelEnd(prevIdentity, rowIdentity);
67
- const sameCycle = prev !== undefined &&
68
- !prev.settled &&
69
- (startedAt === undefined || prev.startedAt === undefined || prev.startedAt === startedAt) &&
70
- (cycleSeq === undefined || prev.cycleSeq === undefined || prev.cycleSeq === cycleSeq);
71
- const knownTokens = tokens !== undefined ? tokens : sameCycle ? prev?.tokens : undefined;
72
- const carryIdentity = prev !== undefined && !rowNewerCycle;
73
- const knownStartedAt = startedAt !== undefined ? startedAt : carryIdentity ? prev.startedAt : undefined;
74
- const knownCycleSeq = cycleSeq !== undefined ? cycleSeq : carryIdentity ? prev.cycleSeq : undefined;
75
- if (TERMINAL_FLEET_TASK_STATUSES.has(status)) {
76
- const newbornTerminal = prev === undefined && panelRowUnknownToConsumer(taskId);
77
- const settledThisCycle = prev?.settled === true && !rowNewerCycle;
78
- const endedRec = prev === undefined ? panelRowEndedIdentity(taskId) : undefined;
79
- const frameCycle = { ...(cycleSeq !== undefined ? { cycleSeq } : {}), ...(startedAt !== undefined ? { startedAt } : {}) };
80
- if (endedRec !== undefined && isStaleEngineAgentPanelEnd(frameCycle, endedRec))
81
- continue;
82
- const endedSameCycle = endedRec !== undefined && !isStaleEngineAgentPanelEnd(endedRec, frameCycle);
83
- if (newbornTerminal) {
84
- holdNewbornTerminalRow(taskId, {
85
- kind: 'fleet-row',
86
- taskId,
87
- ...(row.name ? { name: row.name } : {}),
88
- ...(row.description ? { description: row.description } : {}),
89
- ...(knownTokens !== undefined ? { totalTokens: knownTokens } : {}),
90
- ...(toolUses !== undefined ? { toolUses } : {}),
91
- ...(transcriptId !== undefined ? { transcriptId } : {}),
92
- ...(parentToolCallId !== undefined ? { parentToolCallId } : {}),
93
- ...(knownStartedAt !== undefined ? { startedAt: knownStartedAt } : {}),
94
- ...(knownCycleSeq !== undefined ? { cycleSeq: knownCycleSeq } : {}),
95
- });
96
- }
97
- else if (!settledThisCycle) {
98
- if (rowNewerCycle ||
99
- (cycleSeq !== undefined && prev?.cycleSeq !== cycleSeq) ||
100
- (tokens !== undefined && prev?.tokens !== tokens) ||
101
- (toolUses !== undefined && prev?.toolUses !== toolUses) ||
102
- (transcriptId !== undefined && prev?.transcriptId !== transcriptId) ||
103
- (parentToolCallId !== undefined && prev?.parentToolCallId !== parentToolCallId) ||
104
- (startedAt !== undefined && prev?.startedAt !== startedAt)) {
105
- publishEngineAgentPanelEvent({
106
- kind: 'fleet-row',
107
- taskId,
108
- ...(row.name ? { name: row.name } : {}),
109
- ...(row.description ? { description: row.description } : {}),
110
- ...(knownTokens !== undefined ? { totalTokens: knownTokens } : {}),
111
- ...(toolUses !== undefined ? { toolUses } : {}),
112
- ...(transcriptId !== undefined ? { transcriptId } : {}),
113
- ...(parentToolCallId !== undefined ? { parentToolCallId } : {}),
114
- ...(knownStartedAt !== undefined ? { startedAt: knownStartedAt } : {}),
115
- ...(knownCycleSeq !== undefined ? { cycleSeq: knownCycleSeq } : {}),
116
- });
117
- }
118
- if (!endedSameCycle)
119
- publishEngineAgentPanelEvent({
120
- kind: 'end',
121
- taskId,
122
- isError: isTerminalNotSuccess(status),
123
- ...(knownCycleSeq !== undefined ? { cycleSeq: knownCycleSeq } : {}),
124
- ...(knownStartedAt !== undefined ? { startedAt: knownStartedAt } : {}),
125
- });
126
- }
127
- seenMap.set(taskId, {
128
- status,
129
- tokens: knownTokens,
130
- toolUses: toolUses !== undefined ? toolUses : prev?.toolUses,
131
- transcriptId: transcriptId !== undefined ? transcriptId : prev?.transcriptId,
132
- parentToolCallId: parentToolCallId !== undefined ? parentToolCallId : prev?.parentToolCallId,
133
- startedAt: knownStartedAt,
134
- cycleSeq: knownCycleSeq,
135
- currentToolKey: currentToolKey !== undefined ? currentToolKey : prev?.currentToolKey,
136
- lastSeenAt: nowMs,
137
- settled: true,
138
- settledAtMs: prev?.settled ? prev.settledAtMs : nowMs,
139
- absentReportedAtMs: undefined,
140
- });
141
- continue;
142
- }
143
- const cycleComparable = (cycleSeq !== undefined && prev?.cycleSeq !== undefined) || (startedAt !== undefined && prev?.startedAt !== undefined);
144
- const staleSnapshotOverHeldRow = prev !== undefined && prev.settled === true && cycleComparable && !rowNewerCycle && peekHeldNewbornTerminalRow(taskId) !== undefined;
145
- if (staleSnapshotOverHeldRow)
146
- continue;
147
- if (!prev ||
148
- prev.settled ||
149
- prev.absentReportedAtMs !== undefined ||
150
- prev.status !== status ||
151
- prev.tokens !== knownTokens ||
152
- (toolUses !== undefined && prev.toolUses !== toolUses) ||
153
- (transcriptId !== undefined && prev.transcriptId !== transcriptId) ||
154
- (parentToolCallId !== undefined && prev.parentToolCallId !== parentToolCallId) ||
155
- (startedAt !== undefined && prev.startedAt !== startedAt) ||
156
- (cycleSeq !== undefined && prev.cycleSeq !== cycleSeq) ||
157
- (currentToolKey !== undefined && prev.currentToolKey !== currentToolKey)) {
158
- notePanelRowRunning(taskId);
159
- dropHeldNewbornTerminalRow(taskId);
160
- publishEngineAgentPanelEvent({
161
- kind: 'fleet-row',
162
- taskId,
163
- ...(row.name ? { name: row.name } : {}),
164
- ...(row.description ? { description: row.description } : {}),
165
- ...(knownTokens !== undefined ? { totalTokens: knownTokens } : {}),
166
- ...(toolUses !== undefined ? { toolUses } : {}),
167
- ...(transcriptId !== undefined ? { transcriptId } : {}),
168
- ...(parentToolCallId !== undefined ? { parentToolCallId } : {}),
169
- ...(knownStartedAt !== undefined ? { startedAt: knownStartedAt } : {}),
170
- ...(knownCycleSeq !== undefined ? { cycleSeq: knownCycleSeq } : {}),
171
- ...(currentTool !== undefined ? { currentTool } : {}),
172
- });
173
- }
174
- seenMap.set(taskId, {
175
- status,
176
- tokens: knownTokens,
177
- toolUses: toolUses !== undefined ? toolUses : prev?.toolUses,
178
- transcriptId: transcriptId !== undefined ? transcriptId : prev?.transcriptId,
179
- parentToolCallId: parentToolCallId !== undefined ? parentToolCallId : prev?.parentToolCallId,
180
- startedAt: knownStartedAt,
181
- cycleSeq: knownCycleSeq,
182
- currentToolKey: currentToolKey !== undefined ? currentToolKey : prev?.currentToolKey,
183
- lastSeenAt: nowMs,
184
- settled: false,
185
- settledAtMs: undefined,
186
- absentReportedAtMs: undefined,
187
- });
188
- }
189
- for (const [taskId, s] of seenMap) {
190
- if (present.has(taskId) || s.settled || s.absentReportedAtMs !== undefined)
191
- continue;
192
- const absentForMs = nowMs - s.lastSeenAt;
193
- if (absentForMs <= ABSENT_SETTLE_MS)
194
- continue;
195
- publishEngineAgentPanelAbsence({ taskId, lastSeenAtMs: s.lastSeenAt, absentForMs });
196
- seenMap.set(taskId, { ...s, absentReportedAtMs: nowMs });
197
- }
198
- for (const [taskId, s] of seenMap) {
199
- if (present.has(taskId))
200
- continue;
201
- if (s.settled) {
202
- const settledAt = s.settledAtMs ?? s.lastSeenAt;
203
- if (nowMs - settledAt > SETTLED_RETENTION_MS)
204
- seenMap.delete(taskId);
205
- }
206
- else if (s.absentReportedAtMs !== undefined && nowMs - s.absentReportedAtMs > SETTLED_RETENTION_MS) {
207
- seenMap.delete(taskId);
208
- }
209
- }
210
- if (seenMap.size === 0)
211
- seen.delete(sessionKey);
21
+ stepEnginePanel({ kind: 'fleet-rows', sessionKey, rows, nowMs });
212
22
  }
@@ -0,0 +1,16 @@
1
+ export interface FleetAgentRowLike {
2
+ id: string;
3
+ name?: string;
4
+ description?: string;
5
+ status?: string;
6
+ tokens?: number;
7
+ toolUses?: number;
8
+ transcriptId?: string;
9
+ currentTool?: {
10
+ toolName: string;
11
+ target?: string;
12
+ };
13
+ startedAt?: number;
14
+ cycleSeq?: number;
15
+ parentToolCallId?: string;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -32,7 +32,7 @@ export interface GateModeReleaseView {
32
32
  mandate?: string;
33
33
  reason?: string;
34
34
  }
35
- export declare const GATE_MODE_RELEASE_REASON_WORDS: readonly ["rule_unreadable"];
35
+ export declare const GATE_MODE_RELEASE_REASON_WORDS: readonly ["rule_unreadable", "write_protection_unresolved"];
36
36
  export type GateModeReleaseReasonWord = (typeof CORE_MODE_RELEASE_REASONS)[number];
37
37
  export declare function isGateModeReleaseReasonWord(v: unknown): v is GateModeReleaseReasonWord;
38
38
  export interface SettlementWhoView {
@@ -61,6 +61,7 @@ export declare function gateApprover(g: GateOutcomeView | undefined): string | u
61
61
  export declare function isApprovalWindowExpiredGate(g: GateOutcomeView | undefined): boolean;
62
62
  export declare function isDenialLimitAutoDeniedGate(g: GateOutcomeView | undefined): boolean;
63
63
  export declare function isParkSlaExpiredGate(g: GateOutcomeView | undefined): boolean;
64
+ export declare function isApproverUnavailableGate(g: GateOutcomeView | undefined): boolean;
64
65
  export declare function isHumanSettledGate(g: GateOutcomeView | undefined): boolean;
65
66
  export declare function isPolicyRefusedGate(g: GateOutcomeView | undefined): boolean;
66
67
  export declare function ccToolDenialKindForToolEnd(frame: unknown): CcToolDenialKind | undefined;