@sema-agent/client-core 0.97.1 → 0.99.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 (353) hide show
  1. package/CHANGELOG.md +607 -0
  2. package/README.md +96 -46
  3. package/dist/adapt/arms.d.ts +1 -0
  4. package/dist/adapt/arms.js +188 -53
  5. package/dist/adapt/ids.d.ts +12 -1
  6. package/dist/adapt/ids.js +59 -8
  7. package/dist/adapt/instanceLedger.d.ts +50 -0
  8. package/dist/adapt/instanceLedger.js +147 -0
  9. package/dist/adapt/panelTasks.d.ts +1 -1
  10. package/dist/adapt/panelTasks.js +2 -2
  11. package/dist/adapt/textStream.d.ts +1 -0
  12. package/dist/adapt/textStream.js +24 -7
  13. package/dist/adapt/toolCards.d.ts +27 -5
  14. package/dist/adapt/toolCards.js +39 -6
  15. package/dist/adapt/wireShapes.js +6 -2
  16. package/dist/adapt.d.ts +2 -0
  17. package/dist/adapt.js +8 -3
  18. package/dist/adapter/activeRunSelfHeal.d.ts +9 -3
  19. package/dist/adapter/activeRunSelfHeal.js +205 -313
  20. package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
  21. package/dist/adapter/downstream/eventToSdkMessage.js +77 -36
  22. package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
  23. package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
  24. package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
  25. package/dist/adapter/runStream.js +79 -48
  26. package/dist/adapter/types.d.ts +4 -4
  27. package/dist/adapter/types.js +2 -1
  28. package/dist/agentSession/backgroundView.js +2 -1
  29. package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
  30. package/dist/agentSession/engineAgentRegistryRead.js +12 -13
  31. package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
  32. package/dist/agentsWireCaps.d.ts +8 -11
  33. package/dist/agentsWireCaps.js +196 -194
  34. package/dist/approvalDecidedByCapability.d.ts +0 -4
  35. package/dist/approvalDecidedByCapability.js +0 -6
  36. package/dist/approvalsStreamLiveCapability.d.ts +0 -4
  37. package/dist/approvalsStreamLiveCapability.js +0 -6
  38. package/dist/assistantInbox.d.ts +34 -0
  39. package/dist/assistantInbox.js +118 -0
  40. package/dist/centerWiringCapability.js +9 -1
  41. package/dist/clientSlice.d.ts +0 -9
  42. package/dist/clientSlice.js +0 -3
  43. package/dist/cloudConfigWireCaps.d.ts +5 -3
  44. package/dist/cloudConfigWireCaps.js +106 -64
  45. package/dist/compensations.js +1 -1
  46. package/dist/connectorStatus.d.ts +21 -0
  47. package/dist/connectorStatus.js +112 -0
  48. package/dist/controlRouter.d.ts +18 -3
  49. package/dist/controlRouter.js +106 -67
  50. package/dist/coreValuePorts.d.ts +29 -4
  51. package/dist/coreValuePorts.js +10 -0
  52. package/dist/corruptSessionCopy.d.ts +2 -1
  53. package/dist/corruptSessionCopy.js +3 -3
  54. package/dist/decideReceipt.d.ts +2 -2
  55. package/dist/decideReceipt.js +5 -2
  56. package/dist/declared/supportFloorDeclared.js +3 -3
  57. package/dist/detachWire.js +3 -2
  58. package/dist/deviceExecutorManagementCapability.d.ts +0 -4
  59. package/dist/deviceExecutorManagementCapability.js +0 -6
  60. package/dist/deviceRebind.d.ts +49 -1
  61. package/dist/deviceRebind.js +221 -3
  62. package/dist/devicesFace.d.ts +34 -0
  63. package/dist/devicesFace.js +90 -0
  64. package/dist/displayUntrusted.d.ts +2 -0
  65. package/dist/displayUntrusted.js +253 -76
  66. package/dist/engineAgentAbsence.d.ts +1 -1
  67. package/dist/engineAgentPanelStore.d.ts +12 -4
  68. package/dist/engineAgentPanelStore.js +16 -11
  69. package/dist/engineCapReader.d.ts +2 -5
  70. package/dist/engineCapReader.js +8 -10
  71. package/dist/engineCapsCache.d.ts +12 -0
  72. package/dist/engineCapsCache.js +76 -18
  73. package/dist/engineCapsChange.d.ts +2 -0
  74. package/dist/engineCapsChange.js +9 -0
  75. package/dist/engineClosedSets.d.ts +1 -0
  76. package/dist/engineClosedSets.js +4 -1
  77. package/dist/engineErrorCodes.d.ts +11 -3
  78. package/dist/engineErrorCodes.js +11 -8
  79. package/dist/engineIdentity.d.ts +1 -0
  80. package/dist/engineIdentity.js +8 -0
  81. package/dist/engineRowRef.d.ts +28 -0
  82. package/dist/engineRowRef.js +114 -0
  83. package/dist/engineSessionMessages.d.ts +68 -0
  84. package/dist/engineSessionMessages.js +370 -0
  85. package/dist/engineTargetSeat.d.ts +27 -0
  86. package/dist/engineTargetSeat.js +199 -0
  87. package/dist/engineToolDirectory.d.ts +0 -9
  88. package/dist/engineToolDirectory.js +1 -94
  89. package/dist/engineUrl.d.ts +18 -0
  90. package/dist/engineUrl.js +52 -0
  91. package/dist/engineWireFor.js +3 -8
  92. package/dist/env/uiLanguage.d.ts +11 -1
  93. package/dist/env/uiLanguage.js +38 -2
  94. package/dist/eventLeg.d.ts +100 -0
  95. package/dist/eventLeg.js +305 -0
  96. package/dist/executionLaneCapability.d.ts +0 -4
  97. package/dist/executionLaneCapability.js +3 -16
  98. package/dist/fileHistoryCaptureCapability.d.ts +2 -5
  99. package/dist/fileHistoryCaptureCapability.js +13 -21
  100. package/dist/fileHistoryLegNotice.d.ts +2 -1
  101. package/dist/fileHistoryLegNotice.js +3 -3
  102. package/dist/fleet/fleetLedger.d.ts +0 -3
  103. package/dist/fleet/fleetLedger.js +21 -36
  104. package/dist/fleet/fleetProjection.d.ts +2 -2
  105. package/dist/fleet/fleetProjection.js +10 -8
  106. package/dist/frameBinding.d.ts +8 -0
  107. package/dist/frameBinding.js +35 -0
  108. package/dist/gateFailureCodes.d.ts +2 -0
  109. package/dist/gateFailureCodes.js +15 -0
  110. package/dist/gateOutcome.d.ts +3 -1
  111. package/dist/gateOutcome.js +41 -8
  112. package/dist/gateVocabulary.d.ts +10 -4
  113. package/dist/gateVocabulary.js +107 -47
  114. package/dist/generated/engineAskFaceTables.js +2 -2
  115. package/dist/generated/engineFactTables.d.ts +22 -3
  116. package/dist/generated/engineFactTables.js +51 -4
  117. package/dist/generated/engineNoticeTables.js +18 -3
  118. package/dist/generated/settingsSchemaFns.d.ts +6 -0
  119. package/dist/generated/settingsSchemaFns.js +57 -0
  120. package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
  121. package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
  122. package/dist/generated/settingsSchemaTables.d.ts +1 -0
  123. package/dist/generated/settingsSchemaTables.js +4 -0
  124. package/dist/generated/settingsSchemaTypes.d.ts +105 -0
  125. package/dist/generated/settingsSchemaTypes.js +1 -0
  126. package/dist/generated/toolNameTables.d.ts +1 -0
  127. package/dist/generated/toolNameTables.js +1 -0
  128. package/dist/hitl/allowRuleShadow.d.ts +8 -2
  129. package/dist/hitl/allowRuleShadow.js +36 -29
  130. package/dist/hitl/approvalCardReading.d.ts +15 -0
  131. package/dist/hitl/approvalCardReading.js +154 -0
  132. package/dist/hitl/approvalCardReasons.d.ts +14 -0
  133. package/dist/hitl/approvalCardReasons.js +119 -0
  134. package/dist/hitl/approvalHolds.d.ts +50 -15
  135. package/dist/hitl/approvalHolds.js +177 -27
  136. package/dist/hitl/approvalResolution.d.ts +51 -26
  137. package/dist/hitl/approvalResolution.js +86 -122
  138. package/dist/hitl/approvalsFeed.js +6 -18
  139. package/dist/hitl/askClassPair.d.ts +2 -0
  140. package/dist/hitl/askClassPair.js +17 -0
  141. package/dist/hitl/askGateWire.d.ts +20 -2
  142. package/dist/hitl/askGateWire.js +50 -1
  143. package/dist/hitl/askParkRowRouting.d.ts +5 -0
  144. package/dist/hitl/askParkRowRouting.js +32 -1
  145. package/dist/hitl/askSettlementLine.d.ts +28 -0
  146. package/dist/hitl/askSettlementLine.js +99 -0
  147. package/dist/hitl/automaticAnswerVerdict.d.ts +3 -2
  148. package/dist/hitl/automaticAnswerVerdict.js +29 -13
  149. package/dist/hitl/crashConverged.d.ts +11 -20
  150. package/dist/hitl/crashConverged.js +56 -0
  151. package/dist/hitl/crashConvergedNotice.d.ts +6 -3
  152. package/dist/hitl/crashConvergedNotice.js +48 -24
  153. package/dist/hitl/decisionConflict.js +3 -10
  154. package/dist/hitl/decisionRefusal.d.ts +40 -1
  155. package/dist/hitl/decisionRefusal.js +199 -42
  156. package/dist/hitl/frameRouter.d.ts +5 -2
  157. package/dist/hitl/frameRouter.js +27 -24
  158. package/dist/hitl/gateLedger.d.ts +2 -0
  159. package/dist/hitl/gateLedger.js +50 -13
  160. package/dist/hitl/hitlBridge.d.ts +2 -2
  161. package/dist/hitl/hitlBridge.js +13 -10
  162. package/dist/hitl/livePendingAsk.d.ts +3 -3
  163. package/dist/hitl/livePendingAsk.js +7 -18
  164. package/dist/hitl/parkResolver.d.ts +2 -24
  165. package/dist/hitl/parkResolver.js +61 -97
  166. package/dist/hitl/persistedRulesWire.d.ts +25 -0
  167. package/dist/hitl/persistedRulesWire.js +104 -2
  168. package/dist/hitl/planReviewWire.d.ts +31 -13
  169. package/dist/hitl/planReviewWire.js +120 -78
  170. package/dist/hitl/refusedToolNameProse.d.ts +0 -1
  171. package/dist/hitl/refusedToolNameProse.js +0 -3
  172. package/dist/hitl/replayedApproval.d.ts +4 -3
  173. package/dist/hitl/replayedApproval.js +7 -4
  174. package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
  175. package/dist/hitl/sessionPolicyDeliverable.js +48 -7
  176. package/dist/hitl/sessionPolicyWire.d.ts +34 -21
  177. package/dist/hitl/sessionPolicyWire.js +179 -70
  178. package/dist/hitl/standingRows.d.ts +20 -2
  179. package/dist/hitl/standingRows.js +69 -8
  180. package/dist/hitl/suspendedReopen.d.ts +2 -1
  181. package/dist/hitl/suspendedReopen.js +7 -10
  182. package/dist/hitl/toolApprovalWire.d.ts +103 -156
  183. package/dist/hitl/toolApprovalWire.js +661 -411
  184. package/dist/hookMatcherVerdict.d.ts +6 -1
  185. package/dist/hookMatcherVerdict.js +14 -7
  186. package/dist/hooksWireCaps.d.ts +2 -2
  187. package/dist/hooksWireCaps.js +174 -81
  188. package/dist/host.d.ts +21 -0
  189. package/dist/hostTurnSettings.d.ts +71 -0
  190. package/dist/hostTurnSettings.js +291 -0
  191. package/dist/humanTurn.d.ts +14 -1
  192. package/dist/humanTurn.js +100 -12
  193. package/dist/humanTurnRead.d.ts +2 -0
  194. package/dist/humanTurnRead.js +22 -1
  195. package/dist/i18n/messages.en.d.ts +703 -0
  196. package/dist/i18n/messages.en.js +701 -0
  197. package/dist/i18n/messages.zh.d.ts +3 -0
  198. package/dist/i18n/messages.zh.js +837 -0
  199. package/dist/i18n/translate.d.ts +25 -0
  200. package/dist/i18n/translate.js +127 -0
  201. package/dist/index.d.ts +78 -29
  202. package/dist/index.js +54 -18
  203. package/dist/inheritEnvCapability.d.ts +32 -0
  204. package/dist/inheritEnvCapability.js +104 -0
  205. package/dist/inheritEnvWire.d.ts +3 -2
  206. package/dist/inheritEnvWire.js +12 -14
  207. package/dist/interactiveHalt.js +17 -6
  208. package/dist/liveModelCatalog.d.ts +3 -3
  209. package/dist/liveModelCatalog.js +15 -13
  210. package/dist/liveQuestionStore.d.ts +2 -21
  211. package/dist/mcpLiveness.d.ts +2 -1
  212. package/dist/mcpPanel.d.ts +10 -1
  213. package/dist/mcpPanel.js +40 -13
  214. package/dist/mcpProbeCapability.d.ts +2 -1
  215. package/dist/mcpProbeCapability.js +7 -11
  216. package/dist/mcpProbeWire.d.ts +9 -2
  217. package/dist/mcpProbeWire.js +6 -1
  218. package/dist/mcpWireCaps.d.ts +47 -2
  219. package/dist/mcpWireCaps.js +164 -16
  220. package/dist/memoryEntriesWire.d.ts +4 -9
  221. package/dist/memoryEntriesWire.js +5 -10
  222. package/dist/model/modelSupplyRules.d.ts +0 -2
  223. package/dist/model/modelSupplyRules.js +3 -12
  224. package/dist/model/modelsPolicy.d.ts +0 -5
  225. package/dist/model/modelsPolicy.js +6 -36
  226. package/dist/model/onboardJudgement.d.ts +93 -0
  227. package/dist/model/onboardJudgement.js +415 -0
  228. package/dist/model/subagentModelWord.d.ts +31 -0
  229. package/dist/model/subagentModelWord.js +261 -0
  230. package/dist/model/tierVocabulary.d.ts +2 -0
  231. package/dist/model/tierVocabulary.js +17 -5
  232. package/dist/modelCapabilityProbe.d.ts +64 -0
  233. package/dist/modelCapabilityProbe.js +600 -0
  234. package/dist/modelIdentityResolvability.d.ts +3 -0
  235. package/dist/modelIdentityResolvability.js +26 -17
  236. package/dist/notifications.d.ts +6 -0
  237. package/dist/notifications.js +71 -23
  238. package/dist/outputStyleSeatCapability.d.ts +0 -3
  239. package/dist/outputStyleSeatCapability.js +0 -3
  240. package/dist/ownKey.d.ts +22 -0
  241. package/dist/ownKey.js +94 -3
  242. package/dist/panelReduce.d.ts +21 -10
  243. package/dist/panelReduce.js +728 -550
  244. package/dist/panelStateHolder.d.ts +3 -7
  245. package/dist/panelStateHolder.js +14 -130
  246. package/dist/peerLaneCapability.d.ts +0 -4
  247. package/dist/peerLaneCapability.js +0 -6
  248. package/dist/permissionRuleIssue.js +2 -0
  249. package/dist/permissionRulesWriteCapability.d.ts +2 -5
  250. package/dist/permissionRulesWriteCapability.js +8 -12
  251. package/dist/permissionWireCaps.d.ts +2 -2
  252. package/dist/permissionWireCaps.js +2 -0
  253. package/dist/permissionsAllowGrantCapability.d.ts +0 -4
  254. package/dist/permissionsAllowGrantCapability.js +0 -6
  255. package/dist/permissionsDeclaration.d.ts +0 -11
  256. package/dist/permissionsDeclaration.js +60 -53
  257. package/dist/pluginHooksWire.d.ts +46 -3
  258. package/dist/pluginHooksWire.js +219 -16
  259. package/dist/preemptWire.d.ts +44 -0
  260. package/dist/preemptWire.js +83 -0
  261. package/dist/printModelStatus.d.ts +63 -0
  262. package/dist/printModelStatus.js +155 -0
  263. package/dist/printToolResultFrame.js +15 -4
  264. package/dist/replayBody.d.ts +3 -0
  265. package/dist/replayBody.js +14 -0
  266. package/dist/request/taskRequest.d.ts +11 -6
  267. package/dist/request/taskRequest.js +112 -19
  268. package/dist/resumeRefusalCopy.d.ts +13 -9
  269. package/dist/resumeRefusalCopy.js +81 -118
  270. package/dist/retryStatus.d.ts +45 -0
  271. package/dist/retryStatus.js +185 -1
  272. package/dist/rewindArchiveCapability.d.ts +0 -4
  273. package/dist/rewindArchiveCapability.js +2 -10
  274. package/dist/rewindArchiveReading.d.ts +0 -1
  275. package/dist/rewindArchiveReading.js +0 -3
  276. package/dist/runCancelContext.d.ts +2 -1
  277. package/dist/runCancelContext.js +4 -2
  278. package/dist/runReattachPolicy.d.ts +31 -0
  279. package/dist/runReattachPolicy.js +46 -0
  280. package/dist/runTerminal.d.ts +3 -6
  281. package/dist/runTerminal.js +8 -9
  282. package/dist/sandboxWire.d.ts +3 -1
  283. package/dist/sandboxWire.js +76 -27
  284. package/dist/scenarioRefusal.d.ts +9 -0
  285. package/dist/scenarioRefusal.js +111 -0
  286. package/dist/scenarioWire.js +1 -1
  287. package/dist/seam.d.ts +48 -2
  288. package/dist/seam.js +25 -4
  289. package/dist/seatContract.d.ts +311 -18
  290. package/dist/seatContract.js +824 -100
  291. package/dist/selfOrchestrationDenial.js +7 -19
  292. package/dist/sessionIdSegment.d.ts +6 -0
  293. package/dist/sessionIdSegment.js +24 -0
  294. package/dist/sessionMemoryStatus.js +6 -11
  295. package/dist/sessionPolicyCapability.d.ts +2 -5
  296. package/dist/sessionPolicyCapability.js +8 -12
  297. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
  298. package/dist/sessionSyncFileHistoryCapability.js +0 -3
  299. package/dist/settingsHooksSalvage.d.ts +44 -0
  300. package/dist/settingsHooksSalvage.js +211 -0
  301. package/dist/skillToolListsCapability.d.ts +2 -4
  302. package/dist/skillToolListsCapability.js +8 -9
  303. package/dist/sqlEngineCapability.d.ts +0 -4
  304. package/dist/sqlEngineCapability.js +0 -6
  305. package/dist/sseIdleTriage.js +3 -2
  306. package/dist/steerPriorityCapability.d.ts +0 -3
  307. package/dist/steerPriorityCapability.js +0 -3
  308. package/dist/streamDrainingLegs.d.ts +4 -0
  309. package/dist/streamDrainingLegs.js +6 -1
  310. package/dist/subagent/engineCompactWire.d.ts +0 -1
  311. package/dist/subagent/engineCompactWire.js +7 -5
  312. package/dist/subagent/engineSubagentResume.js +15 -9
  313. package/dist/subagent/engineTaskHandleWire.js +4 -7
  314. package/dist/subagentContentStore.d.ts +3 -0
  315. package/dist/subagentContentStore.js +22 -10
  316. package/dist/submitReopen.d.ts +24 -0
  317. package/dist/submitReopen.js +75 -0
  318. package/dist/terminalStatuses.d.ts +3 -0
  319. package/dist/terminalStatuses.js +10 -2
  320. package/dist/toolHistoryMismatch.js +3 -2
  321. package/dist/toolResult.d.ts +10 -1
  322. package/dist/toolResult.js +34 -6
  323. package/dist/toolRoster.d.ts +3 -4
  324. package/dist/toolRoster.js +21 -22
  325. package/dist/turnFailurePresentation.d.ts +39 -0
  326. package/dist/turnFailurePresentation.js +402 -0
  327. package/dist/usageAnalytics.js +6 -11
  328. package/dist/userAttachmentEnvelope.d.ts +1 -0
  329. package/dist/userAttachmentEnvelope.js +37 -7
  330. package/dist/userAttachmentSeat.d.ts +21 -0
  331. package/dist/userAttachmentSeat.js +75 -0
  332. package/dist/userInvokedSkillsCapability.d.ts +11 -4
  333. package/dist/userInvokedSkillsCapability.js +31 -10
  334. package/dist/webSearchBackendCapability.d.ts +0 -4
  335. package/dist/webSearchBackendCapability.js +0 -6
  336. package/dist/wireErrorTriage.d.ts +7 -0
  337. package/dist/wireErrorTriage.js +26 -23
  338. package/dist/wireFailureShape.d.ts +62 -5
  339. package/dist/wireFailureShape.js +106 -5
  340. package/dist/wireRefusalCopy.d.ts +25 -3
  341. package/dist/wireRefusalCopy.js +74 -80
  342. package/dist/workflowsJournalCapability.d.ts +2 -5
  343. package/dist/workflowsJournalCapability.js +8 -12
  344. package/dist/writeProtectionCapability.d.ts +0 -4
  345. package/dist/writeProtectionCapability.js +0 -6
  346. package/docs/INTEGRATION-CLIENTS.md +1775 -56
  347. package/package.json +6 -5
  348. package/dist/attachmentSeatCapability.d.ts +0 -12
  349. package/dist/attachmentSeatCapability.js +0 -23
  350. package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
  351. package/dist/hitl/approvalOutcomeNote.js +0 -29
  352. package/dist/sessionReadRedactionCapability.d.ts +0 -13
  353. package/dist/sessionReadRedactionCapability.js +0 -35
@@ -1,5 +1,6 @@
1
1
  import { hostLog } from '../host.js';
2
- import { resumeRetryLaterFromError } from '../wireErrorTriage.js';
2
+ import { isNotFoundFailure, resumeRetryLaterFromError } from '../wireErrorTriage.js';
3
+ import { readThrownSlot, THROWN_SLOT_UNREADABLE } from '../wireFailureShape.js';
3
4
  import { RESUME_SESSION_NOT_FOUND } from '../engineErrorCodes.js';
4
5
  import { displayUntrusted } from '../displayUntrusted.js';
5
6
  import { engineCapTrue } from '../engineCapsCache.js';
@@ -25,15 +26,22 @@ const RETENTION_LAPSED_CODES = new Set([
25
26
  RESUME_SESSION_NOT_FOUND,
26
27
  ]);
27
28
  function shapeOf(e) {
28
- const o = (e ?? {});
29
+ const status = readThrownSlot(e ?? {}, 'status', 'data');
30
+ const errorCode = readThrownSlot(e ?? {}, 'errorCode', 'data');
31
+ const message = readThrownSlot(e ?? {}, 'message');
32
+ if (status === THROWN_SLOT_UNREADABLE || errorCode === THROWN_SLOT_UNREADABLE) {
33
+ return { message: typeof message === 'string' && message !== '' ? message : String(e), unreadable: true };
34
+ }
29
35
  return {
30
- ...(typeof o.status === 'number' ? { status: o.status } : {}),
31
- ...(typeof o.errorCode === 'string' ? { errorCode: o.errorCode } : {}),
32
- message: typeof o.message === 'string' && o.message !== '' ? o.message : String(e),
36
+ ...(typeof status === 'number' ? { status } : {}),
37
+ ...(typeof errorCode === 'string' ? { errorCode } : {}),
38
+ message: typeof message === 'string' && message !== '' ? message : String(e),
33
39
  };
34
40
  }
35
41
  export function classifySubagentResumeFailure(e) {
36
- const { status, errorCode, message } = shapeOf(e);
42
+ const { status, errorCode, message, unreadable } = shapeOf(e);
43
+ if (unreadable === true)
44
+ return { reason: 'error', detail: message };
37
45
  if (status === undefined && errorCode === undefined) {
38
46
  const noAnswer = typeof e === 'object' ? noAnswerDetailFrom(e) : null;
39
47
  if (noAnswer !== null)
@@ -63,12 +71,10 @@ export function classifySubagentResumeFailure(e) {
63
71
  return { reason: 'row-contended', detail: message };
64
72
  if (errorCode === 'resume.row_gone')
65
73
  return { reason: 'row-gone', detail: message };
66
- if (errorCode === undefined && status === 404)
74
+ if (isNotFoundFailure(e) !== false)
67
75
  return { reason: 'not-found', detail: message };
68
76
  if (errorCode === undefined && status === 400)
69
77
  return { reason: 'bad-request', detail: message };
70
- if (errorCode?.startsWith('not_found.') === true)
71
- return { reason: 'not-found', detail: message };
72
78
  return { reason: 'error', detail: message };
73
79
  }
74
80
  export function resolveOwnerRunId(childTaskId, activeRunId) {
@@ -2,7 +2,6 @@ import { TaskStopConflictError } from '@sema-agent/sdk';
2
2
  import { hostLog } from '../host.js';
3
3
  import { clientHasVerbs, engineWireFor, INJECTED_WIRE_SETTLE_MS, noAnswerDetailFrom, sendOnce, settleInjected } from '../engineWireFor.js';
4
4
  import { engineWireDebugEnabled } from '../engineWireTarget.js';
5
- import { engineCapTrue } from '../engineCapsCache.js';
6
5
  import { engineSessionParamFor } from '../engineSessionParam.js';
7
6
  import { resolveOwnerContext } from './engineSubagentResume.js';
8
7
  import { engineTaskHandlesCapable } from './engineRowStopGate.js';
@@ -15,7 +14,7 @@ function usableTaskStopClient(client) {
15
14
  }
16
15
  const CAPS_KEY_REQUIRED_DETAIL = 'capability evidence for taskHandles is not available under the key the host named (capsBaseUrl) — nothing sent';
17
16
  import { spoolMarkerOf } from '../toolResult.js';
18
- import { STOP_CONFLICT_CODES, STOP_NOT_LANDED, STOP_NOT_LOCAL, STOP_PARKED, STOP_PARK_ARBITER_UNREACHABLE, STOP_PARK_RESUME_WON, } from '../engineErrorCodes.js';
17
+ import { STOP_NOT_LANDED, STOP_NOT_LOCAL, STOP_PARKED, STOP_PARK_ARBITER_UNREACHABLE, STOP_PARK_RESUME_WON, } from '../engineErrorCodes.js';
19
18
  function resolveHostRun(handle) {
20
19
  const runId = resolveOwnerContext(handle).runId;
21
20
  if (!runId) {
@@ -38,7 +37,7 @@ export async function fetchEngineTaskOutput(handle, opts) {
38
37
  if (wire.kind === 'no-target' || wire.kind === 'injected-unusable')
39
38
  return null;
40
39
  if (wire.kind === 'injected') {
41
- if (!engineCapTrue(wire.capsBaseUrl, 'taskHandles')) {
40
+ if (wire.capsBaseUrl === undefined || !engineTaskHandlesCapable(owner.key, wire.capsBaseUrl)) {
42
41
  hostLog('debug', `[task-handle] output ${handle}: ${CAPS_KEY_REQUIRED_DETAIL}`);
43
42
  return null;
44
43
  }
@@ -115,9 +114,7 @@ function terminalOutputHint(output) {
115
114
  export function classifyTaskStopConflict(e) {
116
115
  const detail = e instanceof Error ? e.message : String(e);
117
116
  const raw = e?.errorCode;
118
- const code = typeof raw === 'string'
119
- ? raw
120
- : (STOP_CONFLICT_CODES.find(c => detail.includes(c)) ?? '');
117
+ const code = typeof raw === 'string' ? raw : '';
121
118
  switch (code) {
122
119
  case STOP_NOT_LOCAL:
123
120
  return { ok: false, reason: 'not_local', detail };
@@ -139,7 +136,7 @@ export async function stopEngineTask(handle, opts) {
139
136
  if (wire.kind === 'no-target' || wire.kind === 'injected-unusable')
140
137
  return { ok: false, reason: 'unavailable' };
141
138
  if (wire.kind === 'injected') {
142
- if (!engineCapTrue(wire.capsBaseUrl, 'taskHandles'))
139
+ if (wire.capsBaseUrl === undefined || !engineTaskHandlesCapable(owner.key, wire.capsBaseUrl))
143
140
  return { ok: false, reason: 'unavailable', detail: CAPS_KEY_REQUIRED_DETAIL };
144
141
  }
145
142
  else if (!engineTaskHandlesCapable(owner.key)) {
@@ -33,6 +33,9 @@ export interface SubagentContentEvent {
33
33
  isError?: boolean | undefined;
34
34
  }
35
35
  export declare function coerceOutput(v: unknown): string | undefined;
36
+ export declare function subagentContentEventOf(ev: {
37
+ readonly type: string;
38
+ }): SubagentContentEvent | undefined;
36
39
  export interface SubagentContentStoreConfig {
37
40
  maxBytesPerTask: number;
38
41
  maxBytesTotal: number;
@@ -1,17 +1,29 @@
1
1
  import { DEFAULT_SESSION_KEY } from './sessionSlot.js';
2
2
  import { toolEndOutputText } from './toolResultContent.js';
3
3
  export function coerceOutput(v) {
4
- if (v === undefined || v === null)
4
+ return toolEndOutputText(v);
5
+ }
6
+ export function subagentContentEventOf(ev) {
7
+ const t = ev.type;
8
+ if (t !== 'text_delta' && t !== 'reasoning_delta' && t !== 'text' && t !== 'reasoning' && t !== 'tool_start' && t !== 'tool_end')
5
9
  return undefined;
6
- const text = toolEndOutputText(v);
7
- if (text !== undefined)
8
- return text;
9
- try {
10
- return JSON.stringify(v);
11
- }
12
- catch {
13
- return String(v);
14
- }
10
+ const sub = ev;
11
+ const parent = sub.parentToolCallId;
12
+ if (typeof parent !== 'string')
13
+ return undefined;
14
+ return {
15
+ type: sub.type,
16
+ taskId: sub.taskId ?? parent,
17
+ parentToolCallId: parent,
18
+ delta: sub.delta,
19
+ text: sub.text,
20
+ eventId: sub.eventId,
21
+ toolCallId: sub.toolCallId,
22
+ toolName: sub.toolName,
23
+ args: sub.args,
24
+ output: coerceOutput(sub.output),
25
+ isError: sub.isError,
26
+ };
15
27
  }
16
28
  const MAX_ITEMS_PER_TASK = 200;
17
29
  const MAX_TASKS = 32;
@@ -0,0 +1,24 @@
1
+ import { type AgentClient, type AgentEvent, type TaskRequest } from '@sema-agent/sdk';
2
+ type TasksStreamOptions = Parameters<AgentClient['tasks']['stream']>[1];
3
+ export type SubmitStreamOptions = Omit<TasksStreamOptions, 'idempotencyKey'>;
4
+ export interface SubmitStreamReopenDeps {
5
+ readonly client: {
6
+ readonly tasks: {
7
+ stream(request: TaskRequest, options: TasksStreamOptions): AsyncGenerator<AgentEvent>;
8
+ };
9
+ };
10
+ readonly request: TaskRequest;
11
+ readonly options: SubmitStreamOptions;
12
+ }
13
+ export interface SubmitStreamReading {
14
+ readonly idempotencyKey: string;
15
+ readonly attempts: 0 | 1 | 2;
16
+ readonly reopened: boolean;
17
+ readonly replay: boolean;
18
+ }
19
+ export interface BoundedSubmitStream {
20
+ readonly frames: AsyncGenerator<AgentEvent>;
21
+ reading(): SubmitStreamReading;
22
+ }
23
+ export declare function submitStreamWithBoundedReopen(deps: SubmitStreamReopenDeps): BoundedSubmitStream;
24
+ export {};
@@ -0,0 +1,75 @@
1
+ import { newIdempotencyKey } from '@sema-agent/sdk';
2
+ import { transportFailureScene } from './engineWireFor.js';
3
+ import { isReplayedTerminal } from './replayBody.js';
4
+ function boundByResponse(res) {
5
+ try {
6
+ const id = res.headers.get('x-task-id');
7
+ return typeof id === 'string' && id.length > 0;
8
+ }
9
+ catch {
10
+ return true;
11
+ }
12
+ }
13
+ function callerAborted(signal) {
14
+ try {
15
+ return signal !== null && signal !== undefined && signal.aborted === true;
16
+ }
17
+ catch {
18
+ return true;
19
+ }
20
+ }
21
+ function lostConnectionWithoutAnswer(error) {
22
+ const scene = transportFailureScene(error);
23
+ return scene.status === undefined && scene.end !== 'unreadable' && scene.noAnswer === 'connection-lost';
24
+ }
25
+ export function submitStreamWithBoundedReopen(deps) {
26
+ const idempotencyKey = newIdempotencyKey();
27
+ let attempts = 0;
28
+ let replay = false;
29
+ let consumerStopped = false;
30
+ async function* run() {
31
+ for (const attempt of [1, 2]) {
32
+ attempts = attempt;
33
+ let bound = false;
34
+ try {
35
+ const source = deps.client.tasks.stream(deps.request, {
36
+ ...deps.options,
37
+ idempotencyKey,
38
+ onResponse: (res) => {
39
+ if (boundByResponse(res))
40
+ bound = true;
41
+ deps.options.onResponse?.(res);
42
+ },
43
+ });
44
+ for await (const frame of source) {
45
+ bound = true;
46
+ if (isReplayedTerminal(frame))
47
+ replay = true;
48
+ yield frame;
49
+ }
50
+ return;
51
+ }
52
+ catch (error) {
53
+ if (attempt === 2 || bound || !lostConnectionWithoutAnswer(error))
54
+ throw error;
55
+ if (consumerStopped || callerAborted(deps.options.signal))
56
+ throw error;
57
+ }
58
+ }
59
+ }
60
+ const frames = run();
61
+ const innerReturn = frames.return.bind(frames);
62
+ const innerThrow = frames.throw.bind(frames);
63
+ frames.return = (value) => {
64
+ consumerStopped = true;
65
+ return innerReturn(value);
66
+ };
67
+ frames.throw = (error) => {
68
+ consumerStopped = true;
69
+ return innerThrow(error);
70
+ };
71
+ return {
72
+ frames,
73
+ reading: () => Object.freeze({ idempotencyKey, attempts, reopened: attempts === 2, replay }),
74
+ };
75
+ }
@@ -9,6 +9,9 @@ export declare function isSdkRunTerminal(status: unknown): status is SdkRunTermi
9
9
  export declare function isSdkRunTerminalNotSuccess(status: unknown): status is Exclude<SdkRunTerminalStatus, 'completed'>;
10
10
  export declare const SDK_PARKED_RUN_STATUSES: readonly ["suspended", "needs_review"];
11
11
  export declare function isSdkRunParked(status: unknown): status is (typeof SDK_PARKED_RUN_STATUSES)[number];
12
+ export declare const SDK_RUN_LIVE_STATUSES: readonly ["running", "suspended", "needs_review"];
13
+ export type SdkRunLiveStatus = (typeof SDK_RUN_LIVE_STATUSES)[number];
14
+ export declare function isSdkRunLive(status: string): status is SdkRunLiveStatus;
12
15
  export declare function isSdkRunFrameSynthesizable(status: unknown): boolean;
13
16
  export declare const SDK_FLEET_TASK_TERMINAL_STATUSES: readonly ["completed", "failed", "killed"];
14
17
  export type SdkFleetTaskTerminalStatus = (typeof SDK_FLEET_TASK_TERMINAL_STATUSES)[number];
@@ -1,4 +1,4 @@
1
- import { CORE_TERMINAL_CAUSE_KINDS } from './generated/engineFactTables.js';
1
+ import { CORE_TERMINAL_CAUSE_KINDS, CORE_TASK_NOTIFICATION_TERMINAL_STATUSES as GENERATED_TASK_NOTIFICATION_TERMINAL_STATUSES } from './generated/engineFactTables.js';
2
2
  function memberOf(table, word) {
3
3
  return typeof word === 'string' && table.includes(word);
4
4
  }
@@ -20,6 +20,14 @@ export const SDK_PARKED_RUN_STATUSES = Object.freeze(['suspended', 'needs_review
20
20
  export function isSdkRunParked(status) {
21
21
  return memberOf(SDK_PARKED_RUN_STATUSES, status);
22
22
  }
23
+ export const SDK_RUN_LIVE_STATUSES = Object.freeze(['running', ...SDK_PARKED_RUN_STATUSES]);
24
+ const _runLiveCoversPartition = true;
25
+ const _partitionCoversRunLive = true;
26
+ void _runLiveCoversPartition;
27
+ void _partitionCoversRunLive;
28
+ export function isSdkRunLive(status) {
29
+ return memberOf(SDK_RUN_LIVE_STATUSES, status);
30
+ }
23
31
  export function isSdkRunFrameSynthesizable(status) {
24
32
  return isSdkRunTerminal(status) || isSdkRunParked(status);
25
33
  }
@@ -30,7 +38,7 @@ export function isSdkFleetTaskTerminal(status) {
30
38
  export function isSdkFleetTaskTerminalNotSuccess(status) {
31
39
  return terminalNotSuccessOf(SDK_FLEET_TASK_TERMINAL_STATUSES, status);
32
40
  }
33
- export const CORE_TASK_NOTIFICATION_TERMINAL_STATUSES = Object.freeze(['completed', 'failed', 'killed', 'cancelled']);
41
+ export const CORE_TASK_NOTIFICATION_TERMINAL_STATUSES = GENERATED_TASK_NOTIFICATION_TERMINAL_STATUSES;
34
42
  export function isCoreTaskNotificationTerminal(status) {
35
43
  return memberOf(CORE_TASK_NOTIFICATION_TERMINAL_STATUSES, status);
36
44
  }
@@ -1,4 +1,5 @@
1
1
  import { rewindArchiveReadingAt, rewindConversationAvailability } from './rewindArchiveReading.js';
2
+ import { ownDataField } from './ownKey.js';
2
3
  export const TOOL_HISTORY_MISMATCH_KINDS = Object.freeze([
3
4
  'tool_use_without_result',
4
5
  'orphan_tool_result',
@@ -191,8 +192,8 @@ export function classifyToolHistoryMismatch(err) {
191
192
  let status;
192
193
  let rawMessage;
193
194
  try {
194
- code = err.code;
195
- status = err.status;
195
+ code = ownDataField(err, 'code');
196
+ status = ownDataField(err, 'status');
196
197
  rawMessage = err.message;
197
198
  }
198
199
  catch {
@@ -1,5 +1,6 @@
1
1
  import type { TaskResult, TaskStats } from '@sema-agent/sdk';
2
2
  import { type ModelFallbackReason } from './engineErrorCodes.js';
3
+ import type { toolKillCauseAcrossEngineIdentity } from './engineIdentity.js';
3
4
  export declare const STRUCTURED_DETAIL_TYPES: ReadonlySet<string>;
4
5
  export declare function structuredDetailType(structured: unknown): string | undefined;
5
6
  export declare const PROTOCOL_MARKERS: {
@@ -103,7 +104,15 @@ export type ToolCardOutcomeReading = {
103
104
  readonly kind: 'unreadable';
104
105
  };
105
106
  export declare function readToolCardOutcome(record: object | null | undefined): ToolCardOutcomeReading;
106
- export declare function wireOutputToBody(toolName: string, output: unknown, isError: boolean, truncated: boolean, flatten: FlattenWireOutput, structured?: unknown, leaderLedger?: boolean): ToolResultBody;
107
+ export interface ToolResultRowFlags {
108
+ readonly collateralAbort: boolean;
109
+ readonly interruptedNeverStarted: boolean;
110
+ readonly approvalWindowExpired: boolean;
111
+ readonly denialLimitWindowExpired: boolean;
112
+ }
113
+ export declare function toolResultRowFlagsOf(row: object | null | undefined): ToolResultRowFlags;
114
+ export type ToolKillCause = NonNullable<ReturnType<typeof toolKillCauseAcrossEngineIdentity>> | 'memory_pressure';
115
+ export declare function wireOutputToBody(toolName: string, output: unknown, isError: boolean, truncated: boolean, flatten: FlattenWireOutput, structured?: unknown, leaderLedger?: boolean, killCauseOf?: () => ToolKillCause | undefined): ToolResultBody;
107
116
  export declare function structuredToToolUseResult(structured: unknown, modelText?: string, leaderLedger?: boolean): {
108
117
  toolUseResult: unknown;
109
118
  isError?: boolean;
@@ -4,7 +4,7 @@ import { parseWorkflowPollEnvelope, projectWorkflowTaskOutput } from './workflow
4
4
  import { asModelFallbackReason } from './engineErrorCodes.js';
5
5
  import { frozenSet } from './frozenSet.js';
6
6
  import { bashExitOf, bashExitReadingFailed } from './bashExitReading.js';
7
- import { readFrameTrueMark } from './ownKey.js';
7
+ import { readFrameTrueMark, readFrameTrueMarkReading } from './ownKey.js';
8
8
  import { isCoreSemaTaskTerminal } from './terminalStatuses.js';
9
9
  import { CORE_ENGINE_CARD_TYPES } from './generated/engineFactTables.js';
10
10
  export const STRUCTURED_DETAIL_TYPES = frozenSet(CORE_ENGINE_CARD_TYPES);
@@ -314,7 +314,10 @@ export function readToolCardOutcome(record) {
314
314
  const block = toolResultBlockOf(record);
315
315
  if (block === undefined)
316
316
  return { kind: 'unreadable' };
317
- if (readFrameTrueMark(record, '_sema_not_executed'))
317
+ const notExecuted = readFrameTrueMarkReading(record, '_sema_not_executed');
318
+ if (notExecuted === 'unreadable')
319
+ return { kind: 'unreadable' };
320
+ if (notExecuted === 'marked')
318
321
  return cardDegraded('not-executed');
319
322
  const markerDesc = Object.getOwnPropertyDescriptor(record, '_sema_degraded');
320
323
  if (markerDesc === undefined)
@@ -329,7 +332,31 @@ export function readToolCardOutcome(record) {
329
332
  return { kind: 'unreadable' };
330
333
  }
331
334
  }
332
- export function wireOutputToBody(toolName, output, isError, truncated, flatten, structured, leaderLedger = true) {
335
+ export function toolResultRowFlagsOf(row) {
336
+ return Object.freeze({
337
+ collateralAbort: readFrameTrueMark(row, '_sema_collateral_abort'),
338
+ interruptedNeverStarted: readFrameTrueMark(row, '_sema_interrupted_never_started'),
339
+ approvalWindowExpired: readFrameTrueMark(row, '_sema_approval_window_expired'),
340
+ denialLimitWindowExpired: readFrameTrueMark(row, '_sema_denial_limit_window_expired'),
341
+ });
342
+ }
343
+ const TOOL_KILL_TEXT = {
344
+ engine_restarted: 'Command was killed when the engine restarted (exit 137)',
345
+ memory_pressure: 'Command was killed (exit 137 — the system ran out of memory; consider lowering build parallelism e.g. make -j2)',
346
+ unknown: 'Command was killed by signal 9 (exit 137)',
347
+ };
348
+ const isToolKillCause = (v) => v === 'engine_restarted' || v === 'memory_pressure';
349
+ const killedBySignalSentence = (killCauseOf) => {
350
+ let cause;
351
+ try {
352
+ cause = killCauseOf?.();
353
+ }
354
+ catch {
355
+ cause = undefined;
356
+ }
357
+ return TOOL_KILL_TEXT[isToolKillCause(cause) ? cause : 'unknown'];
358
+ };
359
+ export function wireOutputToBody(toolName, output, isError, truncated, flatten, structured, leaderLedger = true, killCauseOf) {
333
360
  const text = flatten(output);
334
361
  const name = (toolName || '').toLowerCase();
335
362
  const sType = structuredDetailType(structured);
@@ -380,7 +407,7 @@ export function wireOutputToBody(toolName, output, isError, truncated, flatten,
380
407
  const reason = slots.stderr.length > 0 ? slots.stderr : slots.stdout;
381
408
  let body = slots.exitCode != null ? `Exit code ${slots.exitCode}\n${reason}` : reason;
382
409
  if (slots.exitCode === 137) {
383
- body += `\nCommand was killed (exit 137 — possibly out-of-memory; consider lowering build parallelism e.g. make -j2)`;
410
+ body += `\n${killedBySignalSentence(killCauseOf)}`;
384
411
  }
385
412
  if (body.trim() === '' && text.trim() !== '')
386
413
  body = text;
@@ -400,8 +427,9 @@ export function wireOutputToBody(toolName, output, isError, truncated, flatten,
400
427
  };
401
428
  }
402
429
  const stdout = truncated ? `${text}\n…(truncated)` : text;
403
- if (isError || bashExitReadingFailed(exit))
404
- return { content: stdout, isError: true };
430
+ if (isError || bashExitReadingFailed(exit)) {
431
+ return { content: exit.exitCode === 137 ? `${stdout}\n${killedBySignalSentence(killCauseOf)}` : stdout, isError: true };
432
+ }
405
433
  return { content: stdout, isError, toolUseResult: { stdout, stderr: '', interrupted: false } };
406
434
  }
407
435
  if (name === 'taskoutput' || name === 'task_output') {
@@ -1,3 +1,4 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
1
2
  export interface ToolRosterPathTargetView {
2
3
  param: string;
3
4
  access: string;
@@ -12,7 +13,6 @@ export interface ToolRosterRenderHintsView {
12
13
  activity?: string;
13
14
  summaryParams?: readonly string[];
14
15
  resultCards?: readonly string[];
15
- approvalCard?: string;
16
16
  }
17
17
  export interface ToolRosterEntryView {
18
18
  name: string;
@@ -78,8 +78,8 @@ export type HandsSeamReading = {
78
78
  export declare function handsSeamReadingOf(view: {
79
79
  readonly hands?: WiringManifestHandsView;
80
80
  } | null | undefined): HandsSeamReading;
81
- export declare function handsSeamDetail(reading: HandsSeamReading): string;
82
- export declare function handsMountedDetail(reading: HandsMountedReading): string;
81
+ export declare function handsSeamDetail(reading: HandsSeamReading, lang?: UiLanguage): string;
82
+ export declare function handsMountedDetail(reading: HandsMountedReading, lang?: UiLanguage): string;
83
83
  export declare function toolRosterNames(roster: ToolRosterView | undefined): readonly string[];
84
84
  export interface ToolShim {
85
85
  name: string;
@@ -87,7 +87,6 @@ export interface ToolShim {
87
87
  family?: string;
88
88
  userFacingName?: string;
89
89
  activity?: string;
90
- approvalCard?: string;
91
90
  summaryParams?: readonly string[];
92
91
  effect?: string;
93
92
  egress?: boolean;
@@ -1,4 +1,5 @@
1
1
  import { displayUntrusted } from './displayUntrusted.js';
2
+ import { msg, renderMessage } from './i18n/translate.js';
2
3
  import { HANDS_REASON_NO_EXECUTION_ENV, projectHandsSection } from './handsSeam.js';
3
4
  const str = (v) => typeof v === 'string' && v.length > 0 ? v : undefined;
4
5
  const strArr = (v) => Array.isArray(v) ? v.filter((x) => typeof x === 'string') : undefined;
@@ -77,7 +78,6 @@ function readEntry(raw) {
77
78
  ...(str(hintsRaw.activity) !== undefined ? { activity: str(hintsRaw.activity) } : {}),
78
79
  ...(strArr(hintsRaw.summaryParams) !== undefined ? { summaryParams: strArr(hintsRaw.summaryParams) } : {}),
79
80
  ...(strArr(hintsRaw.resultCards) !== undefined ? { resultCards: strArr(hintsRaw.resultCards) } : {}),
80
- ...(str(hintsRaw.approvalCard) !== undefined ? { approvalCard: str(hintsRaw.approvalCard) } : {}),
81
81
  },
82
82
  }
83
83
  : {}),
@@ -145,55 +145,55 @@ export function handsSeamReadingOf(view) {
145
145
  return { kind: 'mounted' };
146
146
  return seam.reason !== undefined ? { kind: 'not_mounted', reason: seam.reason } : { kind: 'not_mounted' };
147
147
  }
148
- const HANDS_NONE_STEM = 'this leg of the run was assembled with NO built-in file-and-shell tools';
149
- const HANDS_NONE_TAIL = "so on this leg the model had no tool of the engine's own for editing files or running commands (tools mounted by other conditions, such as external servers, and sub-runs delegated to other legs are not covered by this reading)";
150
148
  const HANDS_REASON_DISPLAY_MAX = 64;
151
- const HANDS_NOT_REPORTED_SENTENCE = 'whether this leg has built-in file-and-shell tools is not stated here — the engine did not report its hands seam (older engines and servers, and the static half of a manifest, never do); the tool roster may still answer it';
152
- export function handsSeamDetail(reading) {
149
+ function handsNotReported(lang) {
150
+ return renderMessage(msg('notice.capability.hands.notReported'), lang);
151
+ }
152
+ export function handsSeamDetail(reading, lang) {
153
153
  const kind = typeof reading === 'object' && reading !== null ? reading.kind : undefined;
154
154
  switch (kind) {
155
155
  case 'mounted':
156
- return 'this leg of the run was assembled with its built-in file tools mounted — the engine says so; whether a shell is reachable is answered by the tool roster, not by this statement';
156
+ return renderMessage(msg('notice.capability.hands.seamMounted'), lang);
157
157
  case 'not_mounted': {
158
158
  const raw = reading.reason;
159
159
  const reason = typeof raw === 'string' && raw.length > 0 ? raw : undefined;
160
160
  const why = reason === undefined
161
- ? 'the engine states it mounted no hands on this leg (it gave no reason)'
161
+ ? msg('notice.capability.hands.whyNoReason')
162
162
  : reason === HANDS_REASON_NO_EXECUTION_ENV
163
- ? 'the engine states it mounted no hands on this leg because no execution environment was supplied'
164
- : `the engine states it mounted no hands on this leg (reason: ${displayUntrusted(reason, { max: HANDS_REASON_DISPLAY_MAX })}, a word this build does not know)`;
165
- return `${HANDS_NONE_STEM} — ${why}, ${HANDS_NONE_TAIL}`;
163
+ ? msg('notice.capability.hands.whyNoExecutionEnv')
164
+ : msg('notice.capability.hands.whyUnknownReason', { reason: displayUntrusted(reason, { max: HANDS_REASON_DISPLAY_MAX }) });
165
+ return renderMessage(msg('notice.capability.hands.noneLine', { stem: msg('notice.capability.hands.noneStem'), why, tail: msg('notice.capability.hands.noneTail') }), lang);
166
166
  }
167
167
  default:
168
- return HANDS_NOT_REPORTED_SENTENCE;
168
+ return handsNotReported(lang);
169
169
  }
170
170
  }
171
- export function handsMountedDetail(reading) {
171
+ export function handsMountedDetail(reading, lang) {
172
172
  const r = reading;
173
173
  const kind = typeof r === 'object' && r !== null ? r.kind : undefined;
174
174
  switch (kind) {
175
175
  case 'mounted': {
176
176
  const rows = r.rows;
177
177
  if (typeof rows === 'number' && Number.isInteger(rows) && rows > 0)
178
- return `this run was assembled with file-and-shell tools mounted (${rows} of them)`;
179
- return HANDS_NOT_REPORTED_SENTENCE;
178
+ return renderMessage(msg('notice.capability.hands.rosterMounted', { rows }), lang);
179
+ return handsNotReported(lang);
180
180
  }
181
181
  case 'not-mounted':
182
- return `${HANDS_NONE_STEM} — the engine reports a roster and not one row was mounted by that condition, ${HANDS_NONE_TAIL}`;
182
+ return renderMessage(msg('notice.capability.hands.rosterNotMounted', { stem: msg('notice.capability.hands.noneStem'), tail: msg('notice.capability.hands.noneTail') }), lang);
183
183
  case 'unknown':
184
184
  switch (r.why) {
185
185
  case 'no-manifest':
186
- return 'whether this run has file-and-shell tools is unknown — no assembly manifest was observed for it';
186
+ return renderMessage(msg('notice.capability.hands.unknownNoManifest'), lang);
187
187
  case 'no-roster':
188
- return 'whether this run has file-and-shell tools is unknown — the manifest carries no tool roster (the static half never does; only an engine-minted effective manifest reports one)';
188
+ return renderMessage(msg('notice.capability.hands.unknownNoRoster'), lang);
189
189
  case 'roster-unreadable':
190
- return 'whether this run has file-and-shell tools is unknown — the tool roster could not be read in the shape this reader knows';
190
+ return renderMessage(msg('notice.capability.hands.unknownRosterUnreadable'), lang);
191
191
  case 'mount-condition-absent':
192
- return 'whether this run has file-and-shell tools is unknown — this engine does not report which condition mounted each tool, so an empty count here would be a fact about the reader, not about the run';
192
+ return renderMessage(msg('notice.capability.hands.unknownMountConditionAbsent'), lang);
193
193
  }
194
- return HANDS_NOT_REPORTED_SENTENCE;
194
+ return handsNotReported(lang);
195
195
  }
196
- return HANDS_NOT_REPORTED_SENTENCE;
196
+ return handsNotReported(lang);
197
197
  }
198
198
  export function toolRosterNames(roster) {
199
199
  return roster?.entries.map((e) => e.name) ?? [];
@@ -208,7 +208,6 @@ export function toolShimFromRoster(entry) {
208
208
  ...(e.family !== undefined ? { family: e.family } : {}),
209
209
  ...(e.renderHints?.userFacingName !== undefined ? { userFacingName: e.renderHints.userFacingName } : {}),
210
210
  ...(e.renderHints?.activity !== undefined ? { activity: e.renderHints.activity } : {}),
211
- ...(e.renderHints?.approvalCard !== undefined ? { approvalCard: e.renderHints.approvalCard } : {}),
212
211
  ...(e.renderHints?.summaryParams !== undefined ? { summaryParams: e.renderHints.summaryParams } : {}),
213
212
  ...(e.effect !== undefined ? { effect: e.effect } : {}),
214
213
  ...(e.egress !== undefined ? { egress: e.egress } : {}),
@@ -0,0 +1,39 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ import { type TurnWireErrorVerdict } from './wireErrorTriage.js';
3
+ import { type LiveModelCatalog } from './liveModelCatalog.js';
4
+ import type { TaskRequestLike } from './request/taskRequest.js';
5
+ export type TurnFailureCategory = 'auth' | 'billing' | 'rate_limited' | 'invalid_request' | 'capability_unavailable' | 'timeout' | 'server_error' | 'connection_lost' | 'parked' | 'internal';
6
+ export declare const TURN_FAILURE_CATEGORIES: readonly TurnFailureCategory[];
7
+ export interface TurnFailureRetry {
8
+ readonly offer: boolean;
9
+ readonly basis: 'wire' | 'category';
10
+ }
11
+ export interface TurnFailurePresentation {
12
+ readonly category: TurnFailureCategory;
13
+ readonly kind: TurnWireErrorVerdict['kind'];
14
+ readonly status?: number;
15
+ readonly errorCode?: string;
16
+ readonly detail: string;
17
+ readonly headline?: string;
18
+ readonly name?: string;
19
+ readonly retry: TurnFailureRetry;
20
+ readonly waitSec?: number;
21
+ readonly notes: readonly string[];
22
+ readonly waitNote?: string;
23
+ }
24
+ export interface TurnFailureNotesContext {
25
+ readonly requestedScenario?: string;
26
+ readonly sentRequest?: TaskRequestLike;
27
+ readonly modelCatalog?: LiveModelCatalog | null;
28
+ readonly nowMs?: number;
29
+ }
30
+ export declare function turnFailurePresentation(err: {} | null | undefined, evidence?: {
31
+ readonly bound?: boolean;
32
+ readonly reopened?: boolean;
33
+ }, notesCtx?: TurnFailureNotesContext, lang?: UiLanguage): TurnFailurePresentation;
34
+ export type SeatTurnFailure = Pick<TurnFailurePresentation, 'category' | 'retry' | 'waitSec' | 'headline' | 'errorCode'>;
35
+ export declare function seatTurnFailureOf(err: {} | null | undefined, evidence?: {
36
+ readonly bound?: boolean;
37
+ readonly reopened?: boolean;
38
+ }): SeatTurnFailure;
39
+ export declare function readSeatTurnFailure(event: {} | null | undefined): SeatTurnFailure | undefined;