@sema-agent/client-core 0.94.0 → 0.96.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 (332) hide show
  1. package/CHANGELOG.md +521 -0
  2. package/README.md +104 -57
  3. package/dist/adapt/arms.js +12 -7
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.d.ts +1 -0
  6. package/dist/adapt/toolCards.js +18 -5
  7. package/dist/adapt/wireShapes.js +5 -24
  8. package/dist/adapter/activeRunSelfHeal.d.ts +12 -3
  9. package/dist/adapter/activeRunSelfHeal.js +50 -16
  10. package/dist/adapter/downstream/eventToSdkMessage.js +33 -18
  11. package/dist/adapter/downstream/terminalToSdkResult.js +19 -12
  12. package/dist/adapter/runStream.js +30 -46
  13. package/dist/adapter/types.d.ts +7 -0
  14. package/dist/adapter/types.js +15 -0
  15. package/dist/agentSession/backgroundView.js +5 -1
  16. package/dist/agentSession/engineAgentRegistryRead.js +7 -5
  17. package/dist/agentSession/engineSessionBackgroundStop.js +25 -17
  18. package/dist/agentsWireCaps.d.ts +2 -0
  19. package/dist/agentsWireCaps.js +13 -2
  20. package/dist/approvalDecidedByCapability.d.ts +0 -1
  21. package/dist/approvalDecidedByCapability.js +2 -7
  22. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  23. package/dist/approvalsStreamLiveCapability.js +2 -6
  24. package/dist/atMostOnce.d.ts +8 -0
  25. package/dist/atMostOnce.js +36 -0
  26. package/dist/attachmentSeatCapability.d.ts +0 -1
  27. package/dist/attachmentSeatCapability.js +0 -3
  28. package/dist/attachmentsWireCaps.js +11 -6
  29. package/dist/bashExitReading.d.ts +10 -0
  30. package/dist/bashExitReading.js +12 -0
  31. package/dist/callerCwdCapability.d.ts +0 -5
  32. package/dist/callerCwdCapability.js +2 -13
  33. package/dist/centerWiringCapability.d.ts +1 -7
  34. package/dist/centerWiringCapability.js +18 -27
  35. package/dist/classifierStatus.js +4 -4
  36. package/dist/classifierVerdictWire.js +4 -16
  37. package/dist/clientSlice.js +1 -1
  38. package/dist/cloudConfigWireCaps.d.ts +3 -3
  39. package/dist/cloudConfigWireCaps.js +85 -43
  40. package/dist/compensations.js +1 -1
  41. package/dist/coreValuePorts.d.ts +11 -7
  42. package/dist/coreValuePorts.js +5 -8
  43. package/dist/credentialProvenance.d.ts +28 -0
  44. package/dist/credentialProvenance.js +76 -0
  45. package/dist/cycleOrder.d.ts +15 -0
  46. package/dist/cycleOrder.js +45 -0
  47. package/dist/decideFailureNote.js +7 -2
  48. package/dist/decideReceipt.d.ts +2 -1
  49. package/dist/decideReceipt.js +39 -14
  50. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  51. package/dist/declared/supportFloorDeclared.js +5 -0
  52. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  53. package/dist/deviceExecutorManagementCapability.js +7 -16
  54. package/dist/deviceRebind.d.ts +88 -0
  55. package/dist/deviceRebind.js +242 -0
  56. package/dist/displayUntrusted.d.ts +8 -3
  57. package/dist/displayUntrusted.js +661 -63
  58. package/dist/engineAgentAbsence.d.ts +2 -2
  59. package/dist/engineAgentPanelStore.d.ts +8 -18
  60. package/dist/engineAgentPanelStore.js +19 -537
  61. package/dist/engineCapReader.d.ts +6 -6
  62. package/dist/engineCapReader.js +30 -43
  63. package/dist/engineCapsCache.d.ts +13 -2
  64. package/dist/engineCapsCache.js +276 -44
  65. package/dist/engineCredentialRequirement.d.ts +9 -0
  66. package/dist/engineCredentialRequirement.js +23 -0
  67. package/dist/engineDirectory.d.ts +79 -0
  68. package/dist/engineDirectory.js +186 -0
  69. package/dist/engineEnvSourcing.d.ts +53 -0
  70. package/dist/engineEnvSourcing.js +81 -0
  71. package/dist/engineErrorCodes.d.ts +28 -4
  72. package/dist/engineErrorCodes.js +68 -25
  73. package/dist/engineIdentity.js +2 -0
  74. package/dist/engineNoticeCodes.d.ts +17 -0
  75. package/dist/engineNoticeCodes.js +57 -3
  76. package/dist/engineWireSdk.js +2 -2
  77. package/dist/engineWordRenames.d.ts +8 -0
  78. package/dist/engineWordRenames.js +13 -0
  79. package/dist/executionLaneCapability.d.ts +2 -3
  80. package/dist/executionLaneCapability.js +18 -23
  81. package/dist/fileHistoryCaptureCapability.d.ts +14 -1
  82. package/dist/fileHistoryCaptureCapability.js +72 -6
  83. package/dist/fileHistoryLegNotice.d.ts +3 -2
  84. package/dist/fileHistoryLegNotice.js +51 -2
  85. package/dist/fleet/bgSubagentRow.d.ts +15 -0
  86. package/dist/fleet/bgSubagentRow.js +67 -0
  87. package/dist/fleet/fleetLedger.d.ts +3 -0
  88. package/dist/fleet/fleetLedger.js +153 -122
  89. package/dist/fleet/fleetProjection.d.ts +1 -3
  90. package/dist/fleet/fleetProjection.js +19 -19
  91. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  92. package/dist/fleetAgentPanelProjection.js +7 -197
  93. package/dist/fleetAgentRowLike.d.ts +16 -0
  94. package/dist/fleetAgentRowLike.js +1 -0
  95. package/dist/fleetTaskDesc.js +4 -17
  96. package/dist/gateOutcome.d.ts +12 -1
  97. package/dist/gateOutcome.js +87 -18
  98. package/dist/gateVocabulary.d.ts +7 -2
  99. package/dist/gateVocabulary.js +5 -1
  100. package/dist/generated/engineAskFaceTables.js +1 -1
  101. package/dist/generated/engineFactTables.d.ts +5 -3
  102. package/dist/generated/engineFactTables.js +17 -4
  103. package/dist/generated/engineNoticeTables.js +12 -3
  104. package/dist/generated/sdkFactTables.d.ts +2 -0
  105. package/dist/generated/sdkFactTables.js +17 -0
  106. package/dist/generated/settingsSchemaFns.d.ts +13 -0
  107. package/dist/generated/settingsSchemaFns.js +75 -0
  108. package/dist/generated/toolNameTables.d.ts +1 -0
  109. package/dist/generated/toolNameTables.js +1 -0
  110. package/dist/headlessPermissionModeWire.d.ts +1 -1
  111. package/dist/headlessPermissionModeWire.js +1 -1
  112. package/dist/headlessReconnectWire.js +49 -20
  113. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  114. package/dist/hitl/allowRuleShadow.js +49 -8
  115. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  116. package/dist/hitl/approvalCompleteParked.js +14 -0
  117. package/dist/hitl/approvalEndingCause.d.ts +7 -0
  118. package/dist/hitl/approvalEndingCause.js +71 -0
  119. package/dist/hitl/approvalHolds.d.ts +12 -2
  120. package/dist/hitl/approvalHolds.js +53 -2
  121. package/dist/hitl/approvalsFeed.js +23 -11
  122. package/dist/hitl/askGateWire.d.ts +2 -1
  123. package/dist/hitl/askGateWire.js +26 -1
  124. package/dist/hitl/askParkRowRouting.js +1 -1
  125. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  126. package/dist/hitl/automaticAnswerVerdict.js +15 -10
  127. package/dist/hitl/crashConverged.js +2 -0
  128. package/dist/hitl/decisionConflict.d.ts +3 -0
  129. package/dist/hitl/decisionConflict.js +41 -0
  130. package/dist/hitl/decisionRefusal.d.ts +12 -0
  131. package/dist/hitl/decisionRefusal.js +63 -4
  132. package/dist/hitl/frameRouter.d.ts +0 -1
  133. package/dist/hitl/frameRouter.js +32 -57
  134. package/dist/hitl/gateLedger.d.ts +5 -0
  135. package/dist/hitl/gateLedger.js +21 -0
  136. package/dist/hitl/hitlBridge.d.ts +17 -2
  137. package/dist/hitl/hitlBridge.js +91 -55
  138. package/dist/hitl/hitlHostSurface.js +3 -11
  139. package/dist/hitl/livePendingAsk.d.ts +16 -6
  140. package/dist/hitl/livePendingAsk.js +36 -4
  141. package/dist/hitl/localAllowRule.d.ts +1 -0
  142. package/dist/hitl/localAllowRule.js +2 -2
  143. package/dist/hitl/noAllowCause.d.ts +2 -1
  144. package/dist/hitl/noAllowCause.js +3 -2
  145. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  146. package/dist/hitl/parkExpiryJudgements.js +46 -0
  147. package/dist/hitl/parkResolver.d.ts +4 -7
  148. package/dist/hitl/parkResolver.js +12 -34
  149. package/dist/hitl/parkRowBirthWait.d.ts +1 -0
  150. package/dist/hitl/parkRowBirthWait.js +2 -2
  151. package/dist/hitl/persistedRulesWire.js +5 -1
  152. package/dist/hitl/planReviewWire.d.ts +3 -2
  153. package/dist/hitl/planReviewWire.js +154 -50
  154. package/dist/hitl/replayedApproval.d.ts +9 -0
  155. package/dist/hitl/replayedApproval.js +139 -10
  156. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  157. package/dist/hitl/resumeRunningCard.js +15 -4
  158. package/dist/hitl/sessionPolicyDeliverable.js +8 -6
  159. package/dist/hitl/standingRows.d.ts +18 -0
  160. package/dist/hitl/standingRows.js +127 -0
  161. package/dist/hitl/toolApprovalWire.d.ts +39 -7
  162. package/dist/hitl/toolApprovalWire.js +351 -61
  163. package/dist/hookMatcherVerdict.d.ts +1 -9
  164. package/dist/hookMatcherVerdict.js +21 -61
  165. package/dist/hooksWireCaps.js +40 -8
  166. package/dist/host.d.ts +5 -0
  167. package/dist/host.js +3 -1
  168. package/dist/hostCallbackGuard.d.ts +2 -0
  169. package/dist/hostCallbackGuard.js +31 -0
  170. package/dist/index.d.ts +48 -17
  171. package/dist/index.js +36 -15
  172. package/dist/interactiveInterrupt.d.ts +8 -0
  173. package/dist/interactiveInterrupt.js +54 -0
  174. package/dist/limitsWire.d.ts +5 -0
  175. package/dist/limitsWire.js +49 -3
  176. package/dist/liveModelCatalog.d.ts +95 -0
  177. package/dist/liveModelCatalog.js +297 -32
  178. package/dist/mcpEngineLeg.d.ts +25 -0
  179. package/dist/mcpEngineLeg.js +71 -15
  180. package/dist/mcpPanel.js +2 -1
  181. package/dist/mcpProbeCapability.d.ts +0 -5
  182. package/dist/mcpProbeCapability.js +2 -12
  183. package/dist/mcpReconnect.d.ts +1 -3
  184. package/dist/mcpReconnect.js +10 -5
  185. package/dist/memoryComplianceCapability.d.ts +0 -5
  186. package/dist/memoryComplianceCapability.js +2 -12
  187. package/dist/memoryOriginCapability.d.ts +0 -5
  188. package/dist/memoryOriginCapability.js +2 -12
  189. package/dist/memorySpecWire.js +2 -2
  190. package/dist/memoryVerbsWire.d.ts +1 -1
  191. package/dist/memoryVerbsWire.js +4 -0
  192. package/dist/model/liveCatalogShape.d.ts +14 -0
  193. package/dist/model/liveCatalogShape.js +71 -0
  194. package/dist/model/modelSupplyRules.d.ts +1 -0
  195. package/dist/model/modelSupplyRules.js +30 -9
  196. package/dist/model/modelsPolicy.d.ts +21 -0
  197. package/dist/model/modelsPolicy.js +90 -0
  198. package/dist/modelIdentityResolvability.d.ts +2 -2
  199. package/dist/modelIdentityResolvability.js +14 -12
  200. package/dist/modelSwitchFallback.d.ts +69 -0
  201. package/dist/modelSwitchFallback.js +206 -0
  202. package/dist/noticePresentation.d.ts +68 -0
  203. package/dist/noticePresentation.js +247 -0
  204. package/dist/notifications.js +12 -11
  205. package/dist/outputStyleSeatCapability.d.ts +0 -2
  206. package/dist/outputStyleSeatCapability.js +2 -10
  207. package/dist/ownKey.d.ts +8 -0
  208. package/dist/ownKey.js +66 -0
  209. package/dist/panelReduce.d.ts +114 -0
  210. package/dist/panelReduce.js +1135 -0
  211. package/dist/panelStateHolder.d.ts +17 -0
  212. package/dist/panelStateHolder.js +201 -0
  213. package/dist/peerFrames.js +13 -9
  214. package/dist/peerLaneCapability.d.ts +0 -1
  215. package/dist/peerLaneCapability.js +2 -6
  216. package/dist/permissionModesCapability.d.ts +0 -5
  217. package/dist/permissionModesCapability.js +5 -16
  218. package/dist/permissionRuleIssue.js +0 -3
  219. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  220. package/dist/permissionRulesWriteCapability.js +2 -6
  221. package/dist/permissionsAllowGrantCapability.d.ts +0 -1
  222. package/dist/permissionsAllowGrantCapability.js +3 -9
  223. package/dist/permissionsDeclaration.d.ts +8 -0
  224. package/dist/permissionsDeclaration.js +101 -41
  225. package/dist/printPermissionOutcome.d.ts +12 -0
  226. package/dist/printPermissionOutcome.js +50 -0
  227. package/dist/printToolResultFrame.d.ts +1 -0
  228. package/dist/printToolResultFrame.js +5 -17
  229. package/dist/promptBlockedCopy.d.ts +5 -0
  230. package/dist/promptBlockedCopy.js +35 -0
  231. package/dist/promptDelivery.js +0 -8
  232. package/dist/protocolSegment.d.ts +9 -6
  233. package/dist/protocolSegment.js +31 -21
  234. package/dist/providerRejection.d.ts +4 -0
  235. package/dist/providerRejection.js +75 -14
  236. package/dist/replayBody.d.ts +12 -0
  237. package/dist/replayBody.js +25 -0
  238. package/dist/resumeRefusalCopy.d.ts +18 -1
  239. package/dist/resumeRefusalCopy.js +127 -32
  240. package/dist/retryStatus.d.ts +9 -1
  241. package/dist/retryStatus.js +9 -2
  242. package/dist/rewindArchiveCapability.d.ts +5 -14
  243. package/dist/rewindArchiveCapability.js +18 -61
  244. package/dist/rewindArchiveReading.d.ts +15 -0
  245. package/dist/rewindArchiveReading.js +56 -0
  246. package/dist/rewindEngineAction.d.ts +21 -0
  247. package/dist/rewindEngineAction.js +36 -0
  248. package/dist/rewindWireCaps.d.ts +2 -1
  249. package/dist/rewindWireCaps.js +1 -0
  250. package/dist/ruleCompileVerdict.d.ts +9 -1
  251. package/dist/ruleCompileVerdict.js +29 -4
  252. package/dist/runTerminal.d.ts +15 -12
  253. package/dist/runTerminal.js +60 -35
  254. package/dist/sandboxWire.js +13 -0
  255. package/dist/sdkRegistryTransit.d.ts +2 -1
  256. package/dist/sdkRegistryTransit.js +1 -0
  257. package/dist/sealedKeyCapability.d.ts +0 -5
  258. package/dist/sealedKeyCapability.js +3 -15
  259. package/dist/seam.js +4 -2
  260. package/dist/seatContract.d.ts +125 -34
  261. package/dist/seatContract.js +583 -179
  262. package/dist/sessionIdSegment.d.ts +1 -0
  263. package/dist/sessionIdSegment.js +11 -0
  264. package/dist/sessionMemoryErase.d.ts +1 -1
  265. package/dist/sessionMemoryErase.js +6 -1
  266. package/dist/sessionMemoryStatus.js +3 -2
  267. package/dist/sessionPolicyCapability.d.ts +0 -1
  268. package/dist/sessionPolicyCapability.js +2 -6
  269. package/dist/sessionReadRedactionCapability.d.ts +0 -5
  270. package/dist/sessionReadRedactionCapability.js +2 -13
  271. package/dist/sessionSyncFileHistory.d.ts +4 -0
  272. package/dist/sessionSyncFileHistory.js +66 -0
  273. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -2
  274. package/dist/sessionSyncFileHistoryCapability.js +2 -9
  275. package/dist/skillToolListsCapability.d.ts +0 -2
  276. package/dist/skillToolListsCapability.js +2 -9
  277. package/dist/skillsWireCaps.d.ts +4 -0
  278. package/dist/skillsWireCaps.js +66 -1
  279. package/dist/sqlEngineCapability.d.ts +0 -1
  280. package/dist/sqlEngineCapability.js +9 -14
  281. package/dist/steerPriorityCapability.d.ts +0 -2
  282. package/dist/steerPriorityCapability.js +3 -12
  283. package/dist/storePostureCapability.d.ts +1 -5
  284. package/dist/storePostureCapability.js +16 -22
  285. package/dist/streamDrainingLegs.d.ts +6 -0
  286. package/dist/streamDrainingLegs.js +23 -0
  287. package/dist/subagent/engineCompactWire.js +13 -38
  288. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  289. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  290. package/dist/subagent/engineSubagentOutput.js +5 -20
  291. package/dist/subagent/engineSubagentSteer.js +7 -5
  292. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  293. package/dist/subagent/engineSubagentTail.js +7 -32
  294. package/dist/subagentContentStore.js +7 -18
  295. package/dist/supportFloor.d.ts +1 -0
  296. package/dist/supportFloor.js +15 -14
  297. package/dist/systemReminderTag.d.ts +1 -0
  298. package/dist/systemReminderTag.js +8 -0
  299. package/dist/terminalStatuses.d.ts +30 -0
  300. package/dist/terminalStatuses.js +67 -0
  301. package/dist/toolHistoryMismatch.d.ts +0 -3
  302. package/dist/toolHistoryMismatch.js +3 -7
  303. package/dist/toolResult.d.ts +6 -1
  304. package/dist/toolResult.js +90 -37
  305. package/dist/toolResultContent.d.ts +2 -0
  306. package/dist/toolResultContent.js +63 -0
  307. package/dist/types/engineState.d.ts +2 -1
  308. package/dist/usageAnalytics.d.ts +146 -0
  309. package/dist/usageAnalytics.js +335 -0
  310. package/dist/userInvokedSkillsCapability.d.ts +0 -2
  311. package/dist/userInvokedSkillsCapability.js +2 -9
  312. package/dist/webSearchBackendCapability.d.ts +0 -1
  313. package/dist/webSearchBackendCapability.js +3 -7
  314. package/dist/webSearchWireCaps.js +3 -11
  315. package/dist/wireErrorTriage.d.ts +2 -0
  316. package/dist/wireErrorTriage.js +34 -5
  317. package/dist/wireFailureShape.d.ts +23 -2
  318. package/dist/wireFailureShape.js +88 -43
  319. package/dist/wireRefusalCopy.js +2 -18
  320. package/dist/workflowClient.js +7 -11
  321. package/dist/workflowsJournalCapability.d.ts +0 -1
  322. package/dist/workflowsJournalCapability.js +2 -6
  323. package/dist/writeProtectionCapability.d.ts +0 -1
  324. package/dist/writeProtectionCapability.js +5 -10
  325. package/docs/INTEGRATION-CLIENTS.md +2279 -27
  326. package/package.json +5 -5
  327. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  328. package/dist/engineCapsGenerationGuard.js +0 -19
  329. package/dist/panelRunningHistory.d.ts +0 -22
  330. package/dist/panelRunningHistory.js +0 -82
  331. package/dist/registryConflict.d.ts +0 -3
  332. package/dist/registryConflict.js +0 -44
@@ -9,10 +9,10 @@ import { recordEngineToolLabel } from '../engineToolLabelStore.js';
9
9
  import { registerSubagentAlias, registerSubagentContentAlias } from '../subagentContentStore.js';
10
10
  import { readAsyncLaunchedAgentReceipt } from '../toolResult.js';
11
11
  import { recordWorkflowAgentTaskId } from '../workflow.js';
12
- import { isTerminalStatus } from '../runTerminal.js';
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 } from '../ownKey.js';
15
+ import { 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';
@@ -74,6 +74,7 @@ const assistantArm = function* (m, { ctx, idOf, text, cards, inst }) {
74
74
  uuid: idOf(m),
75
75
  session_id: ctx.sessionId,
76
76
  parent_tool_use_id: null,
77
+ ...(readFrameTrueMark(m, '_sema_tool_recovered') ? { _sema_tool_recovered: true } : {}),
77
78
  }, ctx.now());
78
79
  if (decision === 'reject' || decision === 'cancel') {
79
80
  cards.resetResponseId();
@@ -469,6 +470,7 @@ const textSegmentEndArm = function* (m, { text }) {
469
470
  if (content.length === 0)
470
471
  return;
471
472
  const r = text.replaceAnswerSegment(content, m);
473
+ yield* text.drainLive();
472
474
  yield chrome({
473
475
  kind: 'text_segment_end',
474
476
  laneProof: mainLane(),
@@ -491,6 +493,7 @@ const thinkingSegmentEndArm = function* (m, { text }) {
491
493
  if (content.length === 0)
492
494
  return;
493
495
  const r = text.replaceThinkingSegment(content, m);
496
+ yield* text.drainLive();
494
497
  yield chrome({
495
498
  kind: 'thinking_segment_end',
496
499
  laneProof: mainLane(),
@@ -542,6 +545,7 @@ const toolEndResultArm = function* (m, { idOf, cards, panel }) {
542
545
  eventId: closeEventId,
543
546
  parentToolCallId: closeParent,
544
547
  ...(typeof closeDenialKindRaw === 'string' ? { denialKind: closeDenialKindRaw } : {}),
548
+ ...(readFrameTrueMark(m, 'notExecuted') ? { notExecuted: true } : {}),
545
549
  });
546
550
  const s = structured !== undefined && structured !== null && typeof structured === 'object'
547
551
  ? structured
@@ -572,7 +576,6 @@ const toolEndResultArm = function* (m, { idOf, cards, panel }) {
572
576
  });
573
577
  }
574
578
  };
575
- const TERMINAL_TICK_STATUSES = new Set(['completed', 'failed']);
576
579
  const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
577
580
  const taskIdRaw = m.taskId;
578
581
  const taskId = typeof taskIdRaw === 'string' ? taskIdRaw : undefined;
@@ -661,9 +664,9 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
661
664
  totalTokens: typeof usage.totalTokens === 'number' ? usage.totalTokens : 0,
662
665
  },
663
666
  });
664
- if (typeof m.status === 'string' && TERMINAL_TICK_STATUSES.has(m.status) && !panel.isLiveBound(taskId)) {
667
+ if (isCoreTaskProgressTerminal(m.status) && !panel.isLiveBound(taskId)) {
665
668
  ctx.probe?.('tick', JSON.stringify({ t: ctx.now(), taskId, lane: 'foreground', settle: m.status }));
666
- yield* panel.settleFromTerminalTick(taskId, m.status === 'failed');
669
+ yield* panel.settleFromTerminalTick(taskId, isCoreTaskProgressTerminalNotSuccess(m.status));
667
670
  }
668
671
  };
669
672
  const streamEventArm = function* (m, { text }) {
@@ -766,7 +769,7 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
766
769
  return;
767
770
  const taskId = fields.taskId;
768
771
  const rawStatus = fields.status;
769
- const terminal = isTerminalStatus(rawStatus);
772
+ const terminal = isCoreTaskNotificationTerminal(rawStatus);
770
773
  const settleAllowed = n.task_type === undefined || n.task_type === 'background_bash' || n.task_type === 'monitor';
771
774
  if (settleAllowed && terminal) {
772
775
  yield chrome({
@@ -798,7 +801,7 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
798
801
  });
799
802
  dropQueuedNotificationsForRun(taskId);
800
803
  if (n.task_type !== 'background_bash' && n.task_type !== 'monitor') {
801
- yield* panel.settleFromNotification(taskId, rawStatus !== 'completed');
804
+ yield* panel.settleFromNotification(taskId, isCoreTaskNotificationTerminalNotSuccess(rawStatus));
802
805
  }
803
806
  }
804
807
  const peerFrame = classifyPeerNotification(n);
@@ -855,6 +858,8 @@ const retryStatusArm = function* (m, { ctx, flags }) {
855
858
  ...(typeof m.errorStatus === 'number' ? { errorStatus: m.errorStatus } : {}),
856
859
  ...(typeof m.elapsedMs === 'number' ? { elapsedMs: m.elapsedMs } : {}),
857
860
  ...(typeof m.timeoutMs === 'number' ? { timeoutMs: m.timeoutMs } : {}),
861
+ ...(typeof m.providerCondition === 'string' && m.providerCondition.length > 0 ? { providerCondition: m.providerCondition } : {}),
862
+ ...(typeof m.providerConditionSource === 'string' && m.providerConditionSource.length > 0 ? { providerConditionSource: m.providerConditionSource } : {}),
858
863
  }, ctx.now());
859
864
  if (status === null) {
860
865
  if (flags.takeRetryOverlay())
@@ -1,9 +1,9 @@
1
1
  import { clearEnginePanelTaskResident, clearEnginePanelTaskResidentByWire, markEnginePanelTaskResident } from '../engineAgentPanelStore.js';
2
+ import { panelEndFact } from '../panelReduce.js';
2
3
  import { chrome, mainLane } from './ids.js';
3
4
  import { SUBAGENT_TOOL_NAMES } from './wireShapes.js';
4
5
  export function createPanelTaskLedger(ctx, cards, inst) {
5
6
  const taskCardBinding = new Map();
6
- const boundToolCalls = new Set();
7
7
  const livePanelTasks = new Set();
8
8
  const endedPanelTasks = new Set();
9
9
  const liveBoundPanelTasks = new Set();
@@ -33,7 +33,6 @@ export function createPanelTaskLedger(ctx, cards, inst) {
33
33
  return undefined;
34
34
  const target = parentToolCallId;
35
35
  taskCardBinding.set(taskId, target);
36
- boundToolCalls.add(target);
37
36
  if (cards.has(target))
38
37
  liveBoundPanelTasks.add(taskId);
39
38
  ctx.probe?.('bind', `bind ${taskId} -> ${target} via=explicit`);
@@ -85,12 +84,7 @@ export function createPanelTaskLedger(ctx, cards, inst) {
85
84
  yield chrome({
86
85
  kind: 'panel_task',
87
86
  laneProof: mintLane(),
88
- event: {
89
- kind: 'end',
90
- taskId,
91
- isError,
92
- ...(cardId !== null && report !== undefined ? { report } : {}),
93
- },
87
+ event: panelEndFact(taskId, isError, cardId !== null && report !== undefined ? { report } : undefined),
94
88
  });
95
89
  }
96
90
  },
@@ -102,7 +96,7 @@ export function createPanelTaskLedger(ctx, cards, inst) {
102
96
  yield chrome({
103
97
  kind: 'panel_task',
104
98
  laneProof: mainLane(),
105
- event: { kind: 'end', taskId, isError },
99
+ event: panelEndFact(taskId, isError),
106
100
  });
107
101
  if (inst.hasFiredSubagentStart(taskId)) {
108
102
  yield chrome({
@@ -144,7 +138,7 @@ export function createPanelTaskLedger(ctx, cards, inst) {
144
138
  yield chrome({
145
139
  kind: 'panel_task',
146
140
  laneProof: mintLane(),
147
- event: { kind: 'end', taskId, isError },
141
+ event: panelEndFact(taskId, isError),
148
142
  });
149
143
  },
150
144
  };
@@ -28,6 +28,7 @@ interface ToolEndPayload {
28
28
  eventId?: string | undefined;
29
29
  parentToolCallId?: string | undefined;
30
30
  denialKind?: string | undefined;
31
+ notExecuted?: boolean | undefined;
31
32
  }
32
33
  export interface OpenCardView {
33
34
  has(id: string): boolean;
@@ -2,6 +2,8 @@ import { deriveTranscriptId } from '../seam.js';
2
2
  import { degradedToolResultBody, detectEngineBgShellDetach, detectEngineBgShellReceipt, reportFindingsToolUseResult, structuredToToolUseResult, todoWriteToolUseResult, wireOutputToBody, } from '../toolResult.js';
3
3
  import { chrome, mainLane, transcript } from './ids.js';
4
4
  import { flattenWireOutput } from './wireShapes.js';
5
+ import { toolResultBlocksOf } from '../toolResultContent.js';
6
+ import { bashExitOf, bashExitReadingFailed } from '../bashExitReading.js';
5
7
  import { isCcToolDenialKind } from '../gateVocabulary.js';
6
8
  function toolUseResultParts(v) {
7
9
  return v !== undefined ? { tool_use_result: v } : {};
@@ -20,7 +22,17 @@ export function toolResultOutcomeOf(toolName, end, rawInput, owner, ledgerTier)
20
22
  if (rich === null && !isError && toolName === 'ReportFindings') {
21
23
  rich = reportFindingsToolUseResult(end?.structured, rawInput);
22
24
  }
23
- return { body, rich };
25
+ const failed = body.isError || rich?.isError === true || bashExitReadingFailed(bashExitOf(end?.structured, () => null));
26
+ const settled = failed && !body.isError ? { ...body, isError: true } : body;
27
+ return { body: withContentBlocks(settled, end), rich };
28
+ }
29
+ function withContentBlocks(body, end) {
30
+ if (body.isError || typeof body.content !== 'string' || end === undefined || end.output === undefined)
31
+ return body;
32
+ const blocks = toolResultBlocksOf(end.output, end.truncated === true);
33
+ if (blocks === undefined)
34
+ return body;
35
+ return { ...body, content: blocks, toolUseResult: body.toolUseResult !== undefined ? body.toolUseResult : body.content };
24
36
  }
25
37
  export function toolResultEnvelopeParts(o) {
26
38
  return {
@@ -34,15 +46,15 @@ export function createToolCardLedger(ctx, idOf) {
34
46
  let lastLiveTodos = [];
35
47
  function* buildToolResult(p, end) {
36
48
  const isError = end?.isError ?? false;
49
+ const parentToolCallId = end?.parentToolCallId ?? p.parentToolCallId;
37
50
  if ((p.name === 'Bash' || p.name === 'Monitor') && !isError) {
38
51
  const outputText = end?.output !== undefined ? flattenWireOutput(end.output) : undefined;
39
52
  const reg = detectEngineBgShellDetach(p.name, p.rawInput, end?.structured, outputText) ??
40
53
  detectEngineBgShellReceipt(p.name, p.rawInput, outputText, end?.structured);
41
54
  if (reg !== null) {
42
- yield chrome({ kind: 'bgshell_register', laneProof: mainLane(), taskId: reg.taskId, registration: reg });
55
+ yield chrome({ kind: 'bgshell_register', laneProof: parentToolCallId === undefined ? mainLane() : { lane: 'subagent', parentToolCallId }, taskId: reg.taskId, registration: reg });
43
56
  }
44
57
  }
45
- const parentToolCallId = end?.parentToolCallId ?? p.parentToolCallId;
46
58
  const outcome = toolResultOutcomeOf(p.name, end, p.rawInput, parentToolCallId === undefined ? 'leader' : 'subagent', (err) => {
47
59
  if (p.name !== 'TodoWrite')
48
60
  return null;
@@ -52,7 +64,7 @@ export function createToolCardLedger(ctx, idOf) {
52
64
  lastLiveTodos = todo.newTodos;
53
65
  return { toolUseResult: todo.toolUseResult, isError: todo.isError };
54
66
  });
55
- const { body, rich } = outcome;
67
+ const { body } = outcome;
56
68
  const eventId = end?.eventId ?? p.eventId;
57
69
  yield transcript({
58
70
  type: 'user',
@@ -63,7 +75,7 @@ export function createToolCardLedger(ctx, idOf) {
63
75
  type: 'tool_result',
64
76
  tool_use_id: p.id,
65
77
  content: body.content,
66
- is_error: rich?.isError === true || body.isError,
78
+ is_error: body.isError,
67
79
  },
68
80
  ],
69
81
  },
@@ -72,6 +84,7 @@ export function createToolCardLedger(ctx, idOf) {
72
84
  ...(parentToolCallId !== undefined ? { parent_tool_use_id: parentToolCallId } : {}),
73
85
  ...toolResultEnvelopeParts(outcome),
74
86
  ...(isCcToolDenialKind(end?.denialKind) ? { _sema_denial_kind: end.denialKind } : {}),
87
+ ...(end?.notExecuted === true ? { _sema_not_executed: true } : {}),
75
88
  }, ctx.now());
76
89
  }
77
90
  function* closeCard(p, end) {
@@ -1,4 +1,6 @@
1
1
  import { frozenSet } from '../frozenSet.js';
2
+ import { stripToolUseSideChannels } from '../adapter/types.js';
3
+ import { toolEndOutputText } from '../toolResultContent.js';
2
4
  export const FLUSH_INTERVAL_MS = 100;
3
5
  export const IDLE_FLUSH_MS = 1500;
4
6
  export const SUBAGENT_TOOL_NAMES = frozenSet(['Task', 'Agent', 'Fork']);
@@ -23,22 +25,7 @@ export function estimateCjkTokens(s) {
23
25
  return Math.round(t);
24
26
  }
25
27
  export function flattenWireOutput(output) {
26
- if (typeof output === 'string')
27
- return output;
28
- if (Array.isArray(output)) {
29
- const parts = [];
30
- for (const block of output) {
31
- if (block && typeof block === 'object') {
32
- const b = block;
33
- if (b.type === 'text' && typeof b.text === 'string')
34
- parts.push(b.text);
35
- else if (b.type === 'image')
36
- parts.push('[image]');
37
- }
38
- }
39
- return parts.join('');
40
- }
41
- return '';
28
+ return toolEndOutputText(output) ?? '';
42
29
  }
43
30
  export function shortTaskLabel(task) {
44
31
  const firstLine = (task.split('\n').find(l => l.trim()) ?? task).trim();
@@ -47,14 +34,8 @@ export function shortTaskLabel(task) {
47
34
  return label || 'subagent';
48
35
  }
49
36
  export function sanitizeToolUseBlock(block) {
50
- const out = { ...block };
51
- const rawInput = out.input;
52
- const eventId = typeof out.eventId === 'string' ? out.eventId : undefined;
53
- const parentToolCallId = typeof out.parentToolCallId === 'string' ? out.parentToolCallId : undefined;
54
- const label = typeof out.label === 'string' ? out.label : undefined;
55
- delete out.label;
56
- delete out.eventId;
57
- delete out.parentToolCallId;
37
+ const rawInput = block.input;
38
+ const { block: out, eventId, parentToolCallId, label } = stripToolUseSideChannels(block);
58
39
  if (out.input && typeof out.input === 'object') {
59
40
  const cleaned = {};
60
41
  for (const [k, val] of Object.entries(out.input)) {
@@ -1,15 +1,19 @@
1
1
  import type { ActiveRunBusySignal } from './runStream.js';
2
2
  import type { PlanReviewReopenTrigger } from '../hitl/planReviewWire.js';
3
+ import { atMostOnceFailureClass } from '../atMostOnce.js';
3
4
  export declare const PLAN_REVIEW_GATE_KIND = "plan_review";
4
5
  export declare const PLAN_REVIEW_GATE_KINDS: readonly string[];
5
6
  export declare const ASK_PARK_GATE_KINDS: readonly string[];
7
+ export type DurableDecideLeg = 'approval' | 'plan_review' | 'other_gate' | 'unreadable' | 'absent';
8
+ export declare function durableDecideLegOf(row: {
9
+ readonly gateKind?: string | null;
10
+ } | null | undefined): DurableDecideLeg;
6
11
  export declare function askParkForeignGateKind(row: {
7
12
  gateKind?: string | null;
8
13
  }): string | null;
9
14
  export declare const PLAN_REVIEW_STATES: readonly string[];
10
15
  export declare const ASK_PARK_STATES: readonly string[];
11
16
  export declare const RUNNING_STATES: readonly string[];
12
- export declare const CLAIM_RELEASED_STATES: readonly string[];
13
17
  export declare const CLAIM_HELD_STATES: readonly string[];
14
18
  export interface DurableRunRecordView {
15
19
  readonly status?: unknown;
@@ -47,6 +51,7 @@ export interface RunningChoiceRequest {
47
51
  status: string;
48
52
  canSteer: boolean;
49
53
  canCancel: boolean;
54
+ canAttach?: true;
50
55
  }
51
56
  export interface StaleParkChoiceRequest {
52
57
  taskId: string;
@@ -62,7 +67,8 @@ export interface ActiveRunSelfHealDeps {
62
67
  trigger?: PlanReviewReopenTrigger;
63
68
  }) => ReopenCardVerdict | Promise<ReopenCardVerdict>;
64
69
  reopenAskPark?: (taskId: string) => Promise<ReopenCardVerdict>;
65
- offerRunningChoice?: (req: RunningChoiceRequest) => Promise<'steer' | 'cancel' | 'wait'>;
70
+ offerRunningChoice?: (req: RunningChoiceRequest) => Promise<'steer' | 'cancel' | 'wait' | 'attach'>;
71
+ canAttachRunning?: boolean;
66
72
  offerStaleParkChoice?: (req: StaleParkChoiceRequest) => Promise<'cancel' | 'wait'>;
67
73
  deniedMessage?: string;
68
74
  signal?: AbortSignal;
@@ -134,6 +140,9 @@ export type SelfHealOutcome = {
134
140
  taskId: string;
135
141
  detail: string;
136
142
  delivery: 'rejected' | 'unknown';
143
+ } | {
144
+ kind: 'running-attach';
145
+ taskId: string;
137
146
  } | {
138
147
  kind: 'running-cancelled';
139
148
  taskId: string;
@@ -191,7 +200,7 @@ export interface SelfHealFollowDeclaration {
191
200
  following?: boolean;
192
201
  }
193
202
  export declare function readCancelRequested(body: unknown): boolean | undefined;
194
- export declare function atMostOnceFailureClass(e: unknown): 'rejected' | 'unknown';
203
+ export { atMostOnceFailureClass };
195
204
  export declare function clearRunningChoiceOffer(taskId: string, sessionId?: string): void;
196
205
  export declare function __resetRunningChoiceLedgerForTests(): void;
197
206
  export interface ClaimReleaseVerdict {
@@ -1,19 +1,47 @@
1
1
  import { abortableSleep } from '../abortableSleep.js';
2
2
  import { corruptStoredRowContent, corruptStoredRowWhere, effectiveWireErrorCode } from '../wireErrorTriage.js';
3
- import { steerBodyOf, steeringRefusedBeforeEngine, steeringStatusIs4xx, UNOBSERVED_STEER_PRIORITY } from '../controlRouter.js';
3
+ import { steerBodyOf, UNOBSERVED_STEER_PRIORITY } from '../controlRouter.js';
4
+ import { atMostOnceFailureClass } from '../atMostOnce.js';
4
5
  import { readSteerReceipt } from '../steerReceipt.js';
6
+ import { resumeAttachReplayDisclosure, runningAttachOffered } from '../hitl/resumeRunningCard.js';
7
+ import { isSdkRunTerminal, SDK_PARKED_RUN_STATUSES } from '../terminalStatuses.js';
5
8
  export const PLAN_REVIEW_GATE_KIND = 'plan_review';
6
- export const PLAN_REVIEW_GATE_KINDS = Object.freeze([PLAN_REVIEW_GATE_KIND, 'dry_run_review']);
7
- export const ASK_PARK_GATE_KINDS = Object.freeze(['human', 'irreversible_ask', 'policy_ask', 'tool_approval']);
9
+ const APPROVAL_LEG_GATE_KINDS = ['human', 'irreversible_ask'];
10
+ const PLAN_LEG_GATE_KINDS = ['plan_review'];
11
+ const CORE_GATE_KINDS = ['human', 'irreversible_ask', 'resource_limit', 'needs_review', 'plan_review', 'task_done'];
12
+ const _durableDecideLegPins = [true, true, true, true, true, true];
13
+ void _durableDecideLegPins;
14
+ export const PLAN_REVIEW_GATE_KINDS = Object.freeze([...PLAN_LEG_GATE_KINDS]);
15
+ export const ASK_PARK_GATE_KINDS = Object.freeze([...APPROVAL_LEG_GATE_KINDS]);
16
+ function gateKindReadingOf(row) {
17
+ let kind;
18
+ try {
19
+ kind = row !== null && typeof row === 'object' ? row.gateKind : undefined;
20
+ }
21
+ catch {
22
+ return { leg: 'unreadable', kind: null };
23
+ }
24
+ if (typeof kind !== 'string' || kind === '')
25
+ return { leg: 'absent', kind: null };
26
+ if (APPROVAL_LEG_GATE_KINDS.includes(kind))
27
+ return { leg: 'approval', kind };
28
+ if (PLAN_LEG_GATE_KINDS.includes(kind))
29
+ return { leg: 'plan_review', kind };
30
+ if (CORE_GATE_KINDS.includes(kind))
31
+ return { leg: 'other_gate', kind };
32
+ return { leg: 'unreadable', kind };
33
+ }
34
+ export function durableDecideLegOf(row) {
35
+ return gateKindReadingOf(row).leg;
36
+ }
8
37
  export function askParkForeignGateKind(row) {
9
- const kind = typeof row.gateKind === 'string' && row.gateKind.length > 0 ? row.gateKind : null;
10
- return kind !== null && !ASK_PARK_GATE_KINDS.includes(kind) ? kind : null;
38
+ const r = gateKindReadingOf(row);
39
+ return r.leg === 'approval' || r.leg === 'absent' ? null : (r.kind ?? '(unreadable)');
11
40
  }
12
41
  export const PLAN_REVIEW_STATES = Object.freeze(['needs_review']);
13
42
  export const ASK_PARK_STATES = Object.freeze(['suspended']);
14
43
  export const RUNNING_STATES = Object.freeze(['running']);
15
- export const CLAIM_RELEASED_STATES = Object.freeze(['completed', 'failed', 'blocked', 'timeout']);
16
- export const CLAIM_HELD_STATES = Object.freeze(['running', 'suspended', 'needs_review']);
44
+ export const CLAIM_HELD_STATES = Object.freeze(['running', ...SDK_PARKED_RUN_STATUSES]);
17
45
  export function selfHealSubmissionDisposition(outcome) {
18
46
  switch (outcome.kind) {
19
47
  case 'decision-pending':
@@ -29,6 +57,8 @@ export function selfHealSubmissionDisposition(outcome) {
29
57
  return 'not-delivered';
30
58
  case 'running-steered':
31
59
  return 'handed-off';
60
+ case 'running-attach':
61
+ return 'not-delivered';
32
62
  default:
33
63
  return 'not-delivered';
34
64
  }
@@ -261,11 +291,7 @@ function reopenedOfOutcome(outcome) {
261
291
  return null;
262
292
  }
263
293
  }
264
- export function atMostOnceFailureClass(e) {
265
- if (typeof e === 'object' && e !== null && steeringStatusIs4xx(e))
266
- return 'rejected';
267
- return typeof e === 'object' && e !== null && steeringRefusedBeforeEngine(e) !== undefined ? 'rejected' : 'unknown';
268
- }
294
+ export { atMostOnceFailureClass };
269
295
  const CANCEL_RELEASE_WAIT_MS = 10_000;
270
296
  const RUNNING_LIVENESS_RECHECK_TIMEOUT_MS = 4_000;
271
297
  const runningChoiceDeclined = new Set();
@@ -365,7 +391,7 @@ export async function waitForClaimRelease(taskId, deps) {
365
391
  if (holder === 'released') {
366
392
  return { released: true, waitedMs: waited(), aborted: false, lastStatus: status, lastHolder: holder };
367
393
  }
368
- if (status !== null && CLAIM_RELEASED_STATES.includes(status)) {
394
+ if (isSdkRunTerminal(status)) {
369
395
  return { released: true, waitedMs: waited(), aborted: false, lastStatus: status, lastHolder: holder };
370
396
  }
371
397
  }
@@ -698,7 +724,8 @@ async function runningChoiceArm(taskId, status, busy, statusFromWire, runs, deps
698
724
  const text = typeof deps?.deniedMessage === 'string' ? deps.deniedMessage : '';
699
725
  const canSteer = typeof runs?.steer === 'function' && text.length > 0;
700
726
  const canCancel = typeof runs?.cancel === 'function' && typeof runs?.get === 'function';
701
- if (!canSteer && !canCancel)
727
+ const canAttach = runningAttachOffered(deps?.canAttachRunning);
728
+ if (!canSteer && !canCancel && !canAttach)
702
729
  return notParked;
703
730
  if (injected && !canSteer)
704
731
  return notParked;
@@ -715,7 +742,7 @@ async function runningChoiceArm(taskId, status, busy, statusFromWire, runs, deps
715
742
  return planReviewArm(taskId, busy, deps);
716
743
  if (ASK_PARK_STATES.includes(fresh))
717
744
  return askParkArm(taskId, busy, runs, deps);
718
- if (CLAIM_RELEASED_STATES.includes(fresh))
745
+ if (isSdkRunTerminal(fresh))
719
746
  return { kind: 'running-settled', taskId, status: fresh };
720
747
  return { kind: 'not-parked', taskId, status: fresh };
721
748
  }
@@ -733,7 +760,7 @@ async function runningChoiceArm(taskId, status, busy, statusFromWire, runs, deps
733
760
  }
734
761
  else if (typeof offer === 'function') {
735
762
  try {
736
- choice = (await offer({ taskId, status, canSteer, canCancel })) ?? 'wait';
763
+ choice = (await offer({ taskId, status, canSteer, canCancel, ...(canAttach ? { canAttach: true } : {}) })) ?? 'wait';
737
764
  offerDelivered = true;
738
765
  }
739
766
  catch {
@@ -783,6 +810,8 @@ async function runningChoiceArm(taskId, status, busy, statusFromWire, runs, deps
783
810
  confirmedHeld: verdict.confirmedHeld,
784
811
  };
785
812
  }
813
+ if (choice === 'attach' && canAttach)
814
+ return { kind: 'running-attach', taskId };
786
815
  return notParked;
787
816
  }
788
817
  export const INTERACTIVE_WAY_OUT = 'run /clear to keep working in a fresh session';
@@ -841,6 +870,9 @@ const NO_CARD_VIEW_ATTACHED = 'this session has no view attached that can show d
841
870
  function injectedSubmissionRow(outcome, following = false) {
842
871
  const lead = INJECTED_LEAD;
843
872
  const id = 'taskId' in outcome && outcome.taskId ? ` (id ${outcome.taskId})` : '';
873
+ if (outcome.kind === 'running-attach') {
874
+ return `${lead} was not delivered: you chose to watch the reply already in progress${id} instead, and sema is replaying that reply here, so the part already shown above will appear again below. sema did not retry, so the model has not seen it.`;
875
+ }
844
876
  if (outcome.kind === 'running-steer-failed') {
845
877
  return outcome.delivery === 'unknown'
846
878
  ? `${lead} was passed to the reply already in progress${id}, but its delivery could not be confirmed ` +
@@ -1057,6 +1089,8 @@ function activeRunSelfHealBaseRow(outcome, signal, wayOut, following = false, ke
1057
1089
  `to it (${outcome.detail}). A steer is not safe to send twice, so sema did NOT retry it, and it did NOT ` +
1058
1090
  `cancel that run. That run may or may not have received your message — watch what it does next ` +
1059
1091
  `before sending it again.`);
1092
+ case 'running-attach':
1093
+ return (`${resumeAttachReplayDisclosure(outcome.taskId)} Your message was NOT sent; send it again once that run has finished.`);
1060
1094
  case 'running-cancelled':
1061
1095
  return outcome.releaseConfirmedByEngine === true
1062
1096
  ? `You chose to cancel run ${outcome.taskId}. The engine confirmed it is no longer holding this session, ` +
@@ -5,8 +5,10 @@ import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../../gateOutcome.js'
5
5
  import { projectToolRoster, projectToolRosterDelta } from '../../toolRoster.js';
6
6
  import { projectHandsSection } from '../../handsSeam.js';
7
7
  import { readMcpLiveness } from '../../mcpLiveness.js';
8
- import { SEGMENT_END_IDENTITY_KEYS } from '../types.js';
8
+ import { markMcpSectionDroppedNamedRows, readFrameTrueMark } from '../../ownKey.js';
9
+ import { SEGMENT_END_IDENTITY_KEYS, stripToolUseSideChannels } from '../types.js';
9
10
  import { frozenSet } from '../../frozenSet.js';
11
+ import { isCoreWorkflowRunTerminal } from '../../terminalStatuses.js';
10
12
  function armBody(body) {
11
13
  return body;
12
14
  }
@@ -38,7 +40,7 @@ export const INTERNAL_SDK_ARM_TYPES = frozenSet([
38
40
  'approval_revoke',
39
41
  'message_committed',
40
42
  ]);
41
- function assistantArm(ctx, content, eventId, parentToolCallId) {
43
+ function assistantArm(ctx, content, eventId, parentToolCallId, recovered) {
42
44
  const id = typeof eventId === 'string' && eventId.length > 0 ? eventId : undefined;
43
45
  const parent = typeof parentToolCallId === 'string' && parentToolCallId.length > 0 ? parentToolCallId : undefined;
44
46
  const model = parent === undefined && typeof ctx.model === 'string' && ctx.model.length > 0 ? ctx.model : undefined;
@@ -51,6 +53,7 @@ function assistantArm(ctx, content, eventId, parentToolCallId) {
51
53
  ...(model !== undefined ? { model } : {}),
52
54
  },
53
55
  parent_tool_use_id: parent ?? null,
56
+ ...(recovered === true ? { _sema_tool_recovered: true } : {}),
54
57
  }));
55
58
  }
56
59
  function streamEventArm(ctx, event) {
@@ -104,13 +107,13 @@ export function eventToSdkMessage(ev, ctx) {
104
107
  if (typeof ev.runId !== 'string' || ev.runId.length === 0) {
105
108
  return dropped('malformed', 'workflow_complete');
106
109
  }
107
- if (ev.status !== 'completed' && ev.status !== 'failed') {
110
+ if (!isCoreWorkflowRunTerminal(ev.status)) {
108
111
  return dropped('malformed', 'workflow_complete');
109
112
  }
110
113
  return projected(stamp(ctx, armBody({
111
114
  type: 'workflow_complete',
112
115
  runId: ev.runId,
113
- status: ev.status === 'failed' ? 'failed' : 'completed',
116
+ status: ev.status,
114
117
  summary: typeof ev.summary === 'string' ? ev.summary : '',
115
118
  })));
116
119
  }
@@ -126,20 +129,21 @@ export function eventToSdkMessage(ev, ctx) {
126
129
  delta: ev.delta,
127
130
  ...(ev.parentToolCallId !== undefined ? { parentToolCallId: ev.parentToolCallId } : {}),
128
131
  }));
129
- case 'tool_start':
130
- return projected(assistantArm(ctx, [
131
- {
132
- type: 'tool_use',
133
- id: ev.toolCallId,
134
- name: ev.toolName,
135
- input: ev.args,
136
- ...(typeof ev.label === 'string' && ev.label.length > 0 ? { label: ev.label } : {}),
137
- ...(ev.eventId !== undefined ? { eventId: ev.eventId } : {}),
138
- ...(ev.parentToolCallId !== undefined
139
- ? { parentToolCallId: ev.parentToolCallId }
140
- : {}),
141
- },
142
- ], ev.eventId, ev.parentToolCallId));
132
+ case 'tool_start': {
133
+ const toolUse = {
134
+ type: 'tool_use',
135
+ id: ev.toolCallId,
136
+ name: ev.toolName,
137
+ input: ev.args,
138
+ ...(typeof ev.label === 'string' && ev.label.length > 0 ? { label: ev.label } : {}),
139
+ ...(ev.eventId !== undefined ? { eventId: ev.eventId } : {}),
140
+ ...(ev.parentToolCallId !== undefined
141
+ ? { parentToolCallId: ev.parentToolCallId }
142
+ : {}),
143
+ };
144
+ const outBlock = ctx.lane === 'print' ? stripToolUseSideChannels(toolUse).block : toolUse;
145
+ return projected(assistantArm(ctx, [outBlock], ev.eventId, ev.parentToolCallId, readFrameTrueMark(ev, 'recovered')));
146
+ }
143
147
  case 'compacted': {
144
148
  const raw = ev;
145
149
  const freedTokens = typeof raw.freedTokens === 'number' && Number.isFinite(raw.freedTokens) && raw.freedTokens >= 0 ? raw.freedTokens : undefined;
@@ -175,6 +179,7 @@ export function eventToSdkMessage(ev, ctx) {
175
179
  const collateralAbort = ev._sema_collateral_abort;
176
180
  const denialKind = ccToolDenialKindForToolEnd(ev);
177
181
  const denialUnclassified = denialKind === undefined && toolEndGate?.disposition.kind === 'denied';
182
+ const toolEndNotExecuted = readFrameTrueMark(ev, 'notExecuted');
178
183
  return projected(stamp(ctx, armBody({
179
184
  type: 'tool_end_result',
180
185
  toolCallId: ev.toolCallId,
@@ -197,6 +202,7 @@ export function eventToSdkMessage(ev, ctx) {
197
202
  ...(collateralAbort === true ? { _sema_collateral_abort: true } : {}),
198
203
  ...(denialKind !== undefined ? { _sema_denial_kind: denialKind } : {}),
199
204
  ...(denialUnclassified ? { _sema_denial_unclassified: true } : {}),
205
+ ...(toolEndNotExecuted ? { notExecuted: true } : {}),
200
206
  ...(ev.eventId !== undefined ? { eventId: ev.eventId } : {}),
201
207
  ...(ev.parentToolCallId !== undefined
202
208
  ? { parentToolCallId: ev.parentToolCallId }
@@ -214,6 +220,9 @@ export function eventToSdkMessage(ev, ctx) {
214
220
  const elapsedMs = num(st2.elapsedMs);
215
221
  const timeoutMs = num(st2.timeoutMs);
216
222
  const errClass = typeof ev.errClass === 'string' && ev.errClass.length > 0 ? ev.errClass : undefined;
223
+ const nonEmptyStr = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
224
+ const providerCondition = nonEmptyStr(st2.providerCondition);
225
+ const providerConditionSource = nonEmptyStr(st2.providerConditionSource);
217
226
  return projected(stamp(ctx, armBody({
218
227
  type: 'retry_status',
219
228
  phase: ev.phase,
@@ -227,6 +236,8 @@ export function eventToSdkMessage(ev, ctx) {
227
236
  ...(errorStatus !== undefined ? { errorStatus } : {}),
228
237
  ...(elapsedMs !== undefined ? { elapsedMs } : {}),
229
238
  ...(timeoutMs !== undefined ? { timeoutMs } : {}),
239
+ ...(providerCondition !== undefined ? { providerCondition } : {}),
240
+ ...(providerConditionSource !== undefined ? { providerConditionSource } : {}),
230
241
  ...(typeof ev.eventId === 'string' ? { eventId: ev.eventId } : {}),
231
242
  ...(typeof ev.parentToolCallId === 'string' ? { parentToolCallId: ev.parentToolCallId } : {}),
232
243
  })));
@@ -470,12 +481,15 @@ export function projectMcpSection(raw) {
470
481
  if (!Array.isArray(raw))
471
482
  return undefined;
472
483
  const rows = [];
484
+ const droppedNamed = new Map();
473
485
  for (const e of raw) {
474
486
  if (typeof e !== 'object' || e === null || Array.isArray(e))
475
487
  continue;
476
488
  const r = e;
477
489
  const name = typeof r.name === 'string' && r.name.length > 0 ? r.name : undefined;
478
490
  const status = typeof r.status === 'string' && r.status.length > 0 ? r.status : undefined;
491
+ if (name !== undefined && status === undefined)
492
+ droppedNamed.set(name, (droppedNamed.get(name) ?? 0) + 1);
479
493
  if (name === undefined || status === undefined)
480
494
  continue;
481
495
  rows.push({
@@ -491,6 +505,7 @@ export function projectMcpSection(raw) {
491
505
  }
492
506
  if (raw.length > 0 && rows.length === 0)
493
507
  return undefined;
508
+ markMcpSectionDroppedNamedRows(rows, droppedNamed);
494
509
  return rows;
495
510
  }
496
511
  function projectModelGateSection(raw) {