@sema-agent/client-core 0.93.1 → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/CHANGELOG.md +554 -0
  2. package/README.md +89 -55
  3. package/dist/adapt/arms.js +13 -11
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.js +2 -2
  6. package/dist/adapt/wireShapes.js +3 -8
  7. package/dist/adapter/activeRunSelfHeal.d.ts +8 -3
  8. package/dist/adapter/activeRunSelfHeal.js +20 -12
  9. package/dist/adapter/downstream/eventToSdkMessage.js +24 -17
  10. package/dist/adapter/downstream/terminalToSdkResult.js +13 -6
  11. package/dist/adapter/runStream.js +2 -1
  12. package/dist/adapter/types.d.ts +7 -0
  13. package/dist/adapter/types.js +15 -0
  14. package/dist/agentSession/backgroundView.js +5 -1
  15. package/dist/agentSession/engineAgentRegistryRead.js +2 -1
  16. package/dist/agentSession/engineSessionBackgroundStop.js +5 -3
  17. package/dist/agentsWireCaps.d.ts +17 -0
  18. package/dist/agentsWireCaps.js +111 -1
  19. package/dist/approvalDecidedByCapability.d.ts +0 -1
  20. package/dist/approvalDecidedByCapability.js +2 -7
  21. package/dist/approvalReachWire.d.ts +18 -0
  22. package/dist/approvalReachWire.js +58 -0
  23. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  24. package/dist/approvalsStreamLiveCapability.js +15 -14
  25. package/dist/atMostOnce.d.ts +8 -0
  26. package/dist/atMostOnce.js +36 -0
  27. package/dist/attachmentSeatCapability.d.ts +0 -1
  28. package/dist/attachmentSeatCapability.js +0 -3
  29. package/dist/attachmentsWireCaps.js +11 -6
  30. package/dist/bashExitReading.d.ts +10 -0
  31. package/dist/bashExitReading.js +12 -0
  32. package/dist/callerCwdCapability.d.ts +15 -0
  33. package/dist/callerCwdCapability.js +42 -0
  34. package/dist/centerWiringCapability.d.ts +1 -3
  35. package/dist/centerWiringCapability.js +18 -21
  36. package/dist/classifierStatus.js +4 -4
  37. package/dist/cloudConfigWireCaps.js +43 -21
  38. package/dist/compensations.js +1 -1
  39. package/dist/controlRouter.js +3 -10
  40. package/dist/coreValuePorts.d.ts +64 -1
  41. package/dist/coreValuePorts.js +30 -0
  42. package/dist/cycleOrder.d.ts +15 -0
  43. package/dist/cycleOrder.js +45 -0
  44. package/dist/decideFailureNote.js +4 -1
  45. package/dist/decideReceipt.d.ts +2 -1
  46. package/dist/decideReceipt.js +41 -13
  47. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  48. package/dist/declared/supportFloorDeclared.js +5 -0
  49. package/dist/detachWire.d.ts +1 -4
  50. package/dist/detachWire.js +1 -1
  51. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  52. package/dist/deviceExecutorManagementCapability.js +36 -40
  53. package/dist/deviceFlowPolling.d.ts +5 -0
  54. package/dist/deviceFlowPolling.js +28 -0
  55. package/dist/deviceRebind.d.ts +88 -0
  56. package/dist/deviceRebind.js +242 -0
  57. package/dist/displayUntrusted.d.ts +1 -0
  58. package/dist/displayUntrusted.js +963 -30
  59. package/dist/engineAgentAbsence.d.ts +2 -2
  60. package/dist/engineAgentPanelStore.d.ts +8 -18
  61. package/dist/engineAgentPanelStore.js +19 -537
  62. package/dist/engineCapReader.d.ts +6 -6
  63. package/dist/engineCapReader.js +30 -43
  64. package/dist/engineCapsCache.d.ts +7 -2
  65. package/dist/engineCapsCache.js +64 -26
  66. package/dist/engineCredentialRequirement.d.ts +9 -0
  67. package/dist/engineCredentialRequirement.js +23 -0
  68. package/dist/engineEnvSourcing.d.ts +53 -0
  69. package/dist/engineEnvSourcing.js +81 -0
  70. package/dist/engineErrorCodes.d.ts +19 -4
  71. package/dist/engineErrorCodes.js +39 -21
  72. package/dist/engineIdentity.js +2 -0
  73. package/dist/engineNoticeCodes.d.ts +22 -2
  74. package/dist/engineNoticeCodes.js +73 -6
  75. package/dist/engineRefusedToolName.d.ts +1 -0
  76. package/dist/engineRefusedToolName.js +8 -0
  77. package/dist/engineWireSdk.js +2 -2
  78. package/dist/executionLaneCapability.d.ts +2 -3
  79. package/dist/executionLaneCapability.js +28 -28
  80. package/dist/fileHistoryCaptureCapability.d.ts +0 -1
  81. package/dist/fileHistoryCaptureCapability.js +13 -12
  82. package/dist/fileHistoryLegNotice.d.ts +14 -2
  83. package/dist/fileHistoryLegNotice.js +101 -15
  84. package/dist/fleet/fleetLedger.d.ts +2 -0
  85. package/dist/fleet/fleetLedger.js +74 -52
  86. package/dist/fleet/fleetProjection.d.ts +0 -3
  87. package/dist/fleet/fleetProjection.js +9 -16
  88. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  89. package/dist/fleetAgentPanelProjection.js +7 -197
  90. package/dist/fleetAgentRowLike.d.ts +16 -0
  91. package/dist/fleetAgentRowLike.js +1 -0
  92. package/dist/gateOutcome.d.ts +2 -1
  93. package/dist/gateOutcome.js +33 -18
  94. package/dist/gateVocabulary.js +1 -1
  95. package/dist/generated/engineAskFaceTables.d.ts +3 -0
  96. package/dist/generated/engineAskFaceTables.js +12 -0
  97. package/dist/generated/engineFactTables.d.ts +4 -2
  98. package/dist/generated/engineFactTables.js +13 -0
  99. package/dist/generated/engineNoticeTables.d.ts +5 -0
  100. package/dist/generated/engineNoticeTables.js +7 -0
  101. package/dist/generated/sdkFactTables.d.ts +5 -0
  102. package/dist/generated/sdkFactTables.js +34 -0
  103. package/dist/generated/settingsSchemaFns.d.ts +10 -0
  104. package/dist/generated/settingsSchemaFns.js +22 -0
  105. package/dist/generated/settingsSchemaTables.d.ts +3 -0
  106. package/dist/generated/settingsSchemaTables.js +3 -0
  107. package/dist/headlessPermissionModeWire.d.ts +2 -2
  108. package/dist/headlessPermissionModeWire.js +11 -21
  109. package/dist/headlessReconnectWire.js +49 -20
  110. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  111. package/dist/hitl/allowRuleShadow.js +49 -8
  112. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  113. package/dist/hitl/approvalCompleteParked.js +14 -0
  114. package/dist/hitl/approvalEndingCause.d.ts +5 -0
  115. package/dist/hitl/approvalEndingCause.js +61 -0
  116. package/dist/hitl/approvalHolds.d.ts +46 -0
  117. package/dist/hitl/approvalHolds.js +140 -0
  118. package/dist/hitl/approvalOutcomeNote.js +2 -1
  119. package/dist/hitl/approvalResolution.js +9 -1
  120. package/dist/hitl/approvalsFeed.js +23 -6
  121. package/dist/hitl/askGateWire.d.ts +2 -1
  122. package/dist/hitl/askGateWire.js +29 -1
  123. package/dist/hitl/automaticAnswerVerdict.d.ts +8 -2
  124. package/dist/hitl/automaticAnswerVerdict.js +71 -23
  125. package/dist/hitl/crashConverged.js +2 -0
  126. package/dist/hitl/decisionConflict.d.ts +3 -0
  127. package/dist/hitl/decisionConflict.js +43 -0
  128. package/dist/hitl/decisionRefusal.d.ts +23 -0
  129. package/dist/hitl/decisionRefusal.js +88 -0
  130. package/dist/hitl/frameRouter.d.ts +10 -0
  131. package/dist/hitl/frameRouter.js +71 -32
  132. package/dist/hitl/gateLedger.d.ts +8 -0
  133. package/dist/hitl/gateLedger.js +38 -0
  134. package/dist/hitl/hitlBridge.d.ts +14 -3
  135. package/dist/hitl/hitlBridge.js +75 -62
  136. package/dist/hitl/hitlHostSurface.d.ts +3 -0
  137. package/dist/hitl/hitlHostSurface.js +17 -15
  138. package/dist/hitl/livePendingAsk.d.ts +16 -6
  139. package/dist/hitl/livePendingAsk.js +36 -4
  140. package/dist/hitl/localAllowRule.js +2 -1
  141. package/dist/hitl/noAllowCause.d.ts +9 -0
  142. package/dist/hitl/noAllowCause.js +26 -0
  143. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  144. package/dist/hitl/parkExpiryJudgements.js +46 -0
  145. package/dist/hitl/parkResolver.d.ts +3 -7
  146. package/dist/hitl/parkResolver.js +55 -28
  147. package/dist/hitl/parkRowBirthWait.js +2 -1
  148. package/dist/hitl/persistedRulesWire.d.ts +6 -1
  149. package/dist/hitl/persistedRulesWire.js +16 -4
  150. package/dist/hitl/planReviewWire.d.ts +2 -3
  151. package/dist/hitl/planReviewWire.js +86 -39
  152. package/dist/hitl/replayedApproval.d.ts +8 -0
  153. package/dist/hitl/replayedApproval.js +125 -10
  154. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  155. package/dist/hitl/resumeRunningCard.js +15 -4
  156. package/dist/hitl/sessionPolicyDeliverable.d.ts +1 -1
  157. package/dist/hitl/sessionPolicyDeliverable.js +3 -8
  158. package/dist/hitl/sessionPolicyWire.js +1 -1
  159. package/dist/hitl/toolApprovalWire.d.ts +50 -5
  160. package/dist/hitl/toolApprovalWire.js +368 -56
  161. package/dist/hooksWireCaps.js +38 -6
  162. package/dist/host.d.ts +5 -0
  163. package/dist/host.js +3 -1
  164. package/dist/hostCallbackGuard.d.ts +1 -0
  165. package/dist/hostCallbackGuard.js +25 -0
  166. package/dist/humanTurnRead.d.ts +15 -1
  167. package/dist/humanTurnRead.js +28 -2
  168. package/dist/index.d.ts +45 -14
  169. package/dist/index.js +33 -12
  170. package/dist/interactiveInterrupt.d.ts +8 -0
  171. package/dist/interactiveInterrupt.js +54 -0
  172. package/dist/limitsWire.d.ts +5 -1
  173. package/dist/limitsWire.js +51 -13
  174. package/dist/liveModelCatalog.d.ts +109 -0
  175. package/dist/liveModelCatalog.js +344 -18
  176. package/dist/mcpEngineLeg.d.ts +25 -0
  177. package/dist/mcpEngineLeg.js +71 -15
  178. package/dist/mcpPanel.js +2 -1
  179. package/dist/mcpProbeCapability.d.ts +0 -1
  180. package/dist/mcpProbeCapability.js +13 -12
  181. package/dist/mcpReconnect.d.ts +1 -3
  182. package/dist/mcpReconnect.js +20 -10
  183. package/dist/memoryComplianceCapability.d.ts +0 -1
  184. package/dist/memoryComplianceCapability.js +14 -13
  185. package/dist/memoryOriginCapability.d.ts +0 -1
  186. package/dist/memoryOriginCapability.js +14 -13
  187. package/dist/memoryVerbsWire.d.ts +1 -1
  188. package/dist/memoryVerbsWire.js +4 -0
  189. package/dist/model/liveCatalogShape.d.ts +14 -0
  190. package/dist/model/liveCatalogShape.js +71 -0
  191. package/dist/model/modelSupplyRules.d.ts +1 -0
  192. package/dist/model/modelSupplyRules.js +30 -9
  193. package/dist/model/modelsPolicy.d.ts +21 -0
  194. package/dist/model/modelsPolicy.js +90 -0
  195. package/dist/modelIdentityResolvability.d.ts +4 -2
  196. package/dist/modelIdentityResolvability.js +25 -5
  197. package/dist/modelSwitchFallback.d.ts +69 -0
  198. package/dist/modelSwitchFallback.js +206 -0
  199. package/dist/notifications.js +12 -11
  200. package/dist/outputStyleSeatCapability.d.ts +15 -0
  201. package/dist/outputStyleSeatCapability.js +42 -0
  202. package/dist/ownKey.d.ts +7 -0
  203. package/dist/ownKey.js +58 -0
  204. package/dist/panelReduce.d.ts +114 -0
  205. package/dist/panelReduce.js +1135 -0
  206. package/dist/panelStateHolder.d.ts +17 -0
  207. package/dist/panelStateHolder.js +201 -0
  208. package/dist/peerLaneCapability.d.ts +0 -1
  209. package/dist/peerLaneCapability.js +15 -14
  210. package/dist/permissionModesCapability.d.ts +0 -1
  211. package/dist/permissionModesCapability.js +5 -10
  212. package/dist/permissionRuleIssue.js +1 -1
  213. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  214. package/dist/permissionRulesWriteCapability.js +15 -14
  215. package/dist/permissionsAllowGrantCapability.d.ts +2 -1
  216. package/dist/permissionsAllowGrantCapability.js +35 -19
  217. package/dist/permissionsDeclaration.d.ts +16 -1
  218. package/dist/permissionsDeclaration.js +142 -15
  219. package/dist/printToolResultFrame.js +2 -10
  220. package/dist/promptDelivery.js +0 -8
  221. package/dist/protocolSegment.d.ts +1 -0
  222. package/dist/protocolSegment.js +13 -1
  223. package/dist/request/taskRequest.d.ts +11 -3
  224. package/dist/request/taskRequest.js +13 -1
  225. package/dist/resultFrameKeys.d.ts +4 -0
  226. package/dist/resultFrameKeys.js +13 -0
  227. package/dist/resumeRefusalCopy.d.ts +18 -1
  228. package/dist/resumeRefusalCopy.js +132 -31
  229. package/dist/retryStatus.js +6 -4
  230. package/dist/rewindArchiveCapability.d.ts +2 -1
  231. package/dist/rewindArchiveCapability.js +28 -15
  232. package/dist/rewindEngineAction.d.ts +21 -0
  233. package/dist/rewindEngineAction.js +36 -0
  234. package/dist/rewindWireCaps.d.ts +2 -1
  235. package/dist/rewindWireCaps.js +1 -0
  236. package/dist/{hitl/rosterMountedNames.d.ts → rosterMountedNames.d.ts} +1 -1
  237. package/dist/runCancelContext.js +2 -1
  238. package/dist/runTerminal.d.ts +0 -11
  239. package/dist/runTerminal.js +4 -27
  240. package/dist/sdkRegistryTransit.d.ts +2 -1
  241. package/dist/sdkRegistryTransit.js +1 -0
  242. package/dist/sealedKeyCapability.d.ts +0 -1
  243. package/dist/sealedKeyCapability.js +19 -20
  244. package/dist/seatContract.d.ts +85 -28
  245. package/dist/seatContract.js +512 -148
  246. package/dist/sessionIdSegment.d.ts +1 -0
  247. package/dist/sessionIdSegment.js +11 -0
  248. package/dist/sessionMemoryErase.d.ts +1 -1
  249. package/dist/sessionMemoryErase.js +6 -1
  250. package/dist/sessionMemoryStatus.js +3 -2
  251. package/dist/sessionPolicyCapability.d.ts +0 -1
  252. package/dist/sessionPolicyCapability.js +14 -13
  253. package/dist/sessionReadRedactionCapability.d.ts +15 -0
  254. package/dist/sessionReadRedactionCapability.js +42 -0
  255. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -1
  256. package/dist/sessionSyncFileHistoryCapability.js +13 -12
  257. package/dist/skillToolListsCapability.d.ts +0 -1
  258. package/dist/skillToolListsCapability.js +13 -12
  259. package/dist/skillsWireCaps.d.ts +4 -0
  260. package/dist/skillsWireCaps.js +66 -1
  261. package/dist/sqlEngineCapability.d.ts +0 -1
  262. package/dist/sqlEngineCapability.js +21 -21
  263. package/dist/steerPriorityCapability.d.ts +0 -1
  264. package/dist/steerPriorityCapability.js +18 -19
  265. package/dist/storePostureCapability.d.ts +1 -1
  266. package/dist/storePostureCapability.js +16 -16
  267. package/dist/streamDrainingLegs.d.ts +6 -0
  268. package/dist/streamDrainingLegs.js +23 -0
  269. package/dist/subagent/agentStateDetail.d.ts +1 -0
  270. package/dist/subagent/agentStateDetail.js +41 -0
  271. package/dist/subagent/engineCompactWire.d.ts +15 -0
  272. package/dist/subagent/engineCompactWire.js +82 -45
  273. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  274. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  275. package/dist/subagent/engineSubagentOutput.js +5 -20
  276. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  277. package/dist/subagent/engineSubagentTail.js +7 -32
  278. package/dist/subagentContentStore.js +3 -3
  279. package/dist/supportFloor.js +2 -5
  280. package/dist/taskRequestWords.d.ts +2 -4
  281. package/dist/taskRequestWords.js +3 -2
  282. package/dist/terminalStatuses.d.ts +30 -0
  283. package/dist/terminalStatuses.js +67 -0
  284. package/dist/toolResult.d.ts +5 -0
  285. package/dist/toolResult.js +88 -36
  286. package/dist/types/engineState.d.ts +2 -1
  287. package/dist/usageAnalytics.d.ts +146 -0
  288. package/dist/usageAnalytics.js +311 -0
  289. package/dist/userAttachmentEnvelope.d.ts +22 -1
  290. package/dist/userAttachmentEnvelope.js +90 -2
  291. package/dist/userInvokedSkillsCapability.d.ts +0 -1
  292. package/dist/userInvokedSkillsCapability.js +13 -12
  293. package/dist/webSearchBackendCapability.d.ts +0 -1
  294. package/dist/webSearchBackendCapability.js +20 -19
  295. package/dist/webSearchWireCaps.js +3 -11
  296. package/dist/wireErrorTriage.d.ts +11 -0
  297. package/dist/wireErrorTriage.js +35 -0
  298. package/dist/wireFailureShape.d.ts +10 -0
  299. package/dist/wireFailureShape.js +72 -5
  300. package/dist/wireRefusalCopy.d.ts +6 -1
  301. package/dist/wireRefusalCopy.js +23 -25
  302. package/dist/wiringInstructionsAttribution.d.ts +10 -0
  303. package/dist/wiringInstructionsAttribution.js +67 -0
  304. package/dist/workflowClient.js +19 -2
  305. package/dist/workflowsJournalCapability.d.ts +0 -1
  306. package/dist/workflowsJournalCapability.js +13 -12
  307. package/dist/writeProtectionCapability.d.ts +0 -1
  308. package/dist/writeProtectionCapability.js +26 -26
  309. package/docs/INTEGRATION-CLIENTS.md +1733 -52
  310. package/package.json +5 -5
  311. package/dist/askSurvivesStandingAnswer.d.ts +0 -13
  312. package/dist/askSurvivesStandingAnswer.js +0 -53
  313. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  314. package/dist/engineCapsGenerationGuard.js +0 -19
  315. package/dist/hitl/askSurvivesPosture.d.ts +0 -20
  316. package/dist/hitl/askSurvivesPosture.js +0 -48
  317. package/dist/panelRunningHistory.d.ts +0 -22
  318. package/dist/panelRunningHistory.js +0 -82
  319. package/dist/registryConflict.d.ts +0 -3
  320. package/dist/registryConflict.js +0 -44
  321. /package/dist/{hitl/rosterMountedNames.js → rosterMountedNames.js} +0 -0
@@ -1,7 +1,8 @@
1
1
  import { readErrorNumber, readErrorString } from './wireFailureShape.js';
2
2
  import { readOwnDataNonEmptyString } from './ownKey.js';
3
- import { RESUME_CONTEXT_UNAVAILABLE, RESUME_PLACEMENT_MISMATCH, RESUME_PREFLIGHT_REJECTED, RESUME_POLICY_FOLD_CODE, PARKED_RESUME_STARTUP_FAILED, isStatusDerivedCoarseCode, RESUME_SESSION_NOT_FOUND, REQUEST_FIELD_CONFLICT, CHECKPOINT_UNSUPPORTED_VERSION, refusalSaysStillPending, } from './engineErrorCodes.js';
3
+ import { RESUME_CONTEXT_UNAVAILABLE, RESUME_PLACEMENT_MISMATCH, RESUME_PREFLIGHT_REJECTED, RESUME_POLICY_FOLD_CODE, PARKED_RESUME_STARTUP_FAILED, isStatusDerivedCoarseCode, RESUME_SESSION_NOT_FOUND, REQUEST_FIELD_CONFLICT, CHECKPOINT_UNSUPPORTED_VERSION, CHECKPOINT_WALLTIME_AXIS_RETIRED, CHECKPOINT_CONFIG_REFUSED, refusalSaysStillPending, refusalRetriableReading, } from './engineErrorCodes.js';
4
4
  import { capForDisplay } from './fleetTaskDesc.js';
5
+ import { engineVersionTier } from './supportFloor.js';
5
6
  import { resumeRetryLaterFromError } from './wireErrorTriage.js';
6
7
  export const RESUME_REFUSAL_CODES = Object.freeze([
7
8
  RESUME_PLACEMENT_MISMATCH,
@@ -87,10 +88,9 @@ export function resumePolicyBlockContent(detail) {
87
88
  ].join(' · ');
88
89
  }
89
90
  export { resumeReopenFromError, resumeReopenContent } from './hitl/suspendedReopen.js';
90
- const RESUME_SESSION_NOT_FOUND_TAIL = `(${RESUME_SESSION_NOT_FOUND})`;
91
91
  const REQUIRE_EXISTING_BY_STATUS = new Map([
92
- [404, Object.freeze({ form: 'session_not_found', code: RESUME_SESSION_NOT_FOUND, coarse: 'not_found.resource' })],
93
- [422, Object.freeze({ form: 'session_id_missing', code: REQUEST_FIELD_CONFLICT, coarse: 'request.unprocessable' })],
92
+ [404, Object.freeze({ form: 'session_not_found', code: RESUME_SESSION_NOT_FOUND })],
93
+ [422, Object.freeze({ form: 'session_id_missing', code: REQUEST_FIELD_CONFLICT })],
94
94
  ]);
95
95
  export function requireExistingSessionRefusalFromError(err) {
96
96
  if (typeof err !== 'object' || err === null)
@@ -101,15 +101,7 @@ export function requireExistingSessionRefusalFromError(err) {
101
101
  const byStatus = typeof status === 'number' ? REQUIRE_EXISTING_BY_STATUS.get(status) : undefined;
102
102
  if (byStatus === undefined)
103
103
  return null;
104
- const code = o['errorCode'];
105
- if (code === byStatus.code)
106
- return Object.freeze({ code: RESUME_SESSION_NOT_FOUND, form: byStatus.form });
107
- if (code !== byStatus.coarse)
108
- return null;
109
- const message = o['message'];
110
- return typeof message === 'string' && message.endsWith(RESUME_SESSION_NOT_FOUND_TAIL)
111
- ? Object.freeze({ code: RESUME_SESSION_NOT_FOUND, form: byStatus.form })
112
- : null;
104
+ return o['errorCode'] === byStatus.code ? Object.freeze({ code: RESUME_SESSION_NOT_FOUND, form: byStatus.form }) : null;
113
105
  }
114
106
  catch {
115
107
  return null;
@@ -149,13 +141,13 @@ export function resumeContextUnavailableFromError(err) {
149
141
  }
150
142
  export function resumeContextUnavailableContent(d) {
151
143
  const sec = d.staleAfterSec;
152
- const retention = typeof sec === 'number' && Number.isSafeInteger(sec) && sec >= 1 ? `(本部署的会话保留时长为 ${sec} 秒)` : '';
144
+ const retention = typeof sec === 'number' && Number.isSafeInteger(sec) && sec >= 1 ? ` (this deployment keeps conversations for ${sec} seconds)` : '';
153
145
  const third = (d.runId !== undefined
154
- ? '错误里带了这条运行的 id,请用它自己恢复这条运行再决;调大会话保留时长只能避免以后再发生,救不回这一次'
155
- : '错误里没有带运行 id,请回到运行列表找到这条运行自己恢复它再决;调大会话保留时长只能避免以后再发生,救不回这一次') + retention;
146
+ ? "The error carries this run's id: use it to recover the run yourself, then decide again; raising the conversation retention time only prevents this from happening again and cannot rescue this one"
147
+ : 'The error carries no run id: go back to the run list, find this run and recover it yourself, then decide again; raising the conversation retention time only prevents this from happening again and cannot rescue this one') + retention;
156
148
  return [
157
- '这个批准无处投递:发起这次运行的会话当前没有可用的上下文来继续它',
158
- '什么都没有被决定,你的决定没有被消费,这张卡仍在等待',
149
+ 'This approval has nowhere to be delivered: the conversation that started this run has no usable context to continue it right now',
150
+ 'Nothing was decided and your decision was not consumed; this card is still waiting',
159
151
  third,
160
152
  ].join(' · ');
161
153
  }
@@ -167,17 +159,7 @@ function parkedResumeStartupCauseWord(err) {
167
159
  catch {
168
160
  named = undefined;
169
161
  }
170
- if (named !== undefined)
171
- return named;
172
- try {
173
- const extra = err.extra;
174
- if (typeof extra !== 'object' || extra === null || Array.isArray(extra))
175
- return undefined;
176
- return readOwnDataNonEmptyString(extra, 'cause');
177
- }
178
- catch {
179
- return undefined;
180
- }
162
+ return named;
181
163
  }
182
164
  export function parkedResumeStartupFromError(err, decision) {
183
165
  if (typeof err !== 'object' || err === null)
@@ -231,7 +213,15 @@ export function checkpointUnsupportedVersionFromError(err) {
231
213
  }
232
214
  if (code !== CHECKPOINT_UNSUPPORTED_VERSION || !refusalSaysStillPending(err))
233
215
  return null;
234
- return { code: CHECKPOINT_UNSUPPORTED_VERSION, retriable: true };
216
+ const writerVersion = readErrorString(err, 'writerVersion');
217
+ const readerVersion = readErrorString(err, 'readerVersion');
218
+ const versions = writerVersion !== undefined && writerVersion !== '' && readerVersion !== undefined && readerVersion !== '' ? { writerVersion, readerVersion } : {};
219
+ return { code: CHECKPOINT_UNSUPPORTED_VERSION, retriable: true, ...versions };
220
+ }
221
+ function writerEngineIsNewer(writer, reader) {
222
+ if (engineVersionTier(writer) === 'unknown' || engineVersionTier(reader) !== 'engine')
223
+ return false;
224
+ return engineVersionTier(reader, writer) === 'legacy';
235
225
  }
236
226
  function checkpointUnsupportedHasRun(kind) {
237
227
  switch (kind) {
@@ -250,7 +240,23 @@ const CHECKPOINT_UNSUPPORTED_WHAT = 'This server cannot continue this parked wor
250
240
  const CHECKPOINT_UNSUPPORTED_STILL_WAITING = 'Nothing was decided or resumed and the parked work is still waiting, but sending the same request again will not by itself continue it';
251
241
  const CHECKPOINT_UNSUPPORTED_DRAIN = " — whoever operates this deployment can find such parked work before an upgrade with the server's pre-upgrade drain check";
252
242
  export function checkpointUnsupportedVersionContent(detail, ctx) {
253
- void detail;
243
+ let writer;
244
+ let reader;
245
+ try {
246
+ writer = detail.writerVersion;
247
+ reader = detail.readerVersion;
248
+ }
249
+ catch {
250
+ writer = undefined;
251
+ reader = undefined;
252
+ }
253
+ if (writerEngineIsNewer(writer, reader)) {
254
+ return [
255
+ `This parked work was stored by a newer engine version (${String(writer)}) than this engine (${String(reader)})`,
256
+ CHECKPOINT_UNSUPPORTED_STILL_WAITING,
257
+ `Continue it on an engine at version ${String(writer)} or newer`,
258
+ ].join(' · ');
259
+ }
254
260
  let kind;
255
261
  let runId;
256
262
  try {
@@ -276,3 +282,98 @@ export function checkpointUnsupportedVersionContent(detail, ctx) {
276
282
  }
277
283
  return [CHECKPOINT_UNSUPPORTED_WHAT, CHECKPOINT_UNSUPPORTED_STILL_WAITING, outlet + CHECKPOINT_UNSUPPORTED_DRAIN].join(' · ');
278
284
  }
285
+ const REFUSED_PARK_CODES = new Set([CHECKPOINT_UNSUPPORTED_VERSION, CHECKPOINT_WALLTIME_AXIS_RETIRED, CHECKPOINT_CONFIG_REFUSED]);
286
+ const REFUSED_PARK_FIELD_TOKEN = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
287
+ export function refusedParkFromError(failure) {
288
+ if (typeof failure !== 'object' || failure === null)
289
+ return null;
290
+ let code;
291
+ let status;
292
+ try {
293
+ code = failure.errorCode;
294
+ status = failure.status;
295
+ }
296
+ catch {
297
+ return null;
298
+ }
299
+ if (typeof code !== 'string' || !REFUSED_PARK_CODES.has(code))
300
+ return null;
301
+ if (status !== undefined && status !== 409)
302
+ return null;
303
+ const reading = refusalRetriableReading(failure);
304
+ const stillPending = reading === true ? true : status === 409 && reading === false ? false : undefined;
305
+ const rawField = code === CHECKPOINT_CONFIG_REFUSED ? readErrorString(failure, 'field') : undefined;
306
+ const field = rawField !== undefined && REFUSED_PARK_FIELD_TOKEN.test(rawField) ? rawField : undefined;
307
+ return Object.freeze({
308
+ code: code,
309
+ ...(field !== undefined ? { field } : {}),
310
+ ...(stillPending !== undefined ? { stillPending } : {}),
311
+ });
312
+ }
313
+ function refusedParkShownRunId(runId) {
314
+ return typeof runId === 'string' && /^[A-Za-z0-9._:-]{1,128}$/.test(runId) ? runId : undefined;
315
+ }
316
+ function refusedParkWhy(code, field) {
317
+ switch (code) {
318
+ case CHECKPOINT_WALLTIME_AXIS_RETIRED:
319
+ return 'its run carries a wall-clock time allowance, which this engine version no longer enforces';
320
+ case CHECKPOINT_CONFIG_REFUSED:
321
+ return field === 'inheritedGate'
322
+ ? 'the permission-mode setting it was parked with can no longer be read'
323
+ : 'the engine refuses the task configuration it was parked with';
324
+ default:
325
+ return 'it was parked under conditions this engine version does not support (for example, by an earlier engine version)';
326
+ }
327
+ }
328
+ export function refusedParkContent(input) {
329
+ let what;
330
+ let lane;
331
+ let runId;
332
+ let rawCode;
333
+ let field;
334
+ let stillPending;
335
+ try {
336
+ what = input.what;
337
+ lane = input.lane;
338
+ runId = input.runId;
339
+ }
340
+ catch {
341
+ what = lane = runId = undefined;
342
+ }
343
+ try {
344
+ const facts = input.facts;
345
+ rawCode = facts.code;
346
+ field = facts.field;
347
+ stillPending = facts.stillPending;
348
+ }
349
+ catch {
350
+ rawCode = field = stillPending = undefined;
351
+ }
352
+ const code = rawCode === CHECKPOINT_WALLTIME_AXIS_RETIRED || rawCode === CHECKPOINT_CONFIG_REFUSED ? rawCode : CHECKPOINT_UNSUPPORTED_VERSION;
353
+ const shownWhat = typeof what === 'string' && what !== '' ? capForDisplay(what, 40) : 'parked step';
354
+ const why = refusedParkWhy(code, typeof field === 'string' ? field : undefined);
355
+ const shownRun = refusedParkShownRunId(runId);
356
+ const head = `This ${shownWhat} cannot be resumed by this engine version: ${why}. The same refusal comes back every time, so ` +
357
+ `answering it again will not help (nothing was decided and nothing was resumed).`;
358
+ const configMayReturn = code === CHECKPOINT_CONFIG_REFUSED && field !== 'inheritedGate' ? ' If that configuration is restored, the same answer can go through again.' : '';
359
+ if (lane === 'print') {
360
+ if (stillPending === false) {
361
+ return `${head} The engine ended that run (${code}); submit the work again as a new task.`;
362
+ }
363
+ const cancel = `POST /v1/runs/${shownRun ?? '<run id>'}/cancel`;
364
+ return `${head}${configMayReturn} The parked run still holds this session (${code}): cancel it (${cancel}), then submit the work again as a new task.`;
365
+ }
366
+ if (stillPending === false) {
367
+ return `${head} The engine ended that parked run, so this conversation is free: send the work again as a new message.`;
368
+ }
369
+ return `${head}${configMayReturn} The parked run keeps this conversation busy until it is cancelled.`;
370
+ }
371
+ export function refusedParkBlockedContent(taskId, lane = 'interactive') {
372
+ const runId = refusedParkShownRunId(taskId);
373
+ const head = `sema will not put the card for run ${runId ?? '<unknown>'} back on screen by itself: this engine version refuses to resume it.`;
374
+ if (lane === 'print') {
375
+ return `${head} Cancel the run (POST /v1/runs/${runId ?? '<run id>'}/cancel) and submit the work again as a new task.`;
376
+ }
377
+ return (`${head} To free this conversation, send a message to bring the card back and answer it — sema then offers to cancel ` +
378
+ `that run, after which you can send the work again as a new message.`);
379
+ }
@@ -1,3 +1,4 @@
1
+ import { displayUntrusted } from './displayUntrusted.js';
1
2
  export const BRAIN_STATUS_PHASES = [
2
3
  'rate_limited',
3
4
  'retrying',
@@ -40,6 +41,7 @@ export function mapBrainStatusToRetry(p, nowMs) {
40
41
  ...(timeoutMs !== undefined ? { timeoutMs } : {}),
41
42
  };
42
43
  const stalledDetail = typeof p.detail === 'string' && p.detail.length > 0 ? { detail: p.detail } : {};
44
+ const shown = (absent) => (typeof p.detail === 'string' ? displayUntrusted(p.detail) : absent);
43
45
  const extra = { ...counts, ...cause, ...producerTiming, ...failureStatus, ...waitProgress };
44
46
  switch (p.phase) {
45
47
  case 'recovered':
@@ -47,20 +49,20 @@ export function mapBrainStatusToRetry(p, nowMs) {
47
49
  case 'reconnecting':
48
50
  return { kind: 'stalled', deadline, ...extra, ...stalledDetail };
49
51
  case 'rate_limited':
50
- return { kind: 'error', deadline, ...extra, error: { formatted: p.detail ?? '', rateLimits: null } };
52
+ return { kind: 'error', deadline, ...extra, error: { formatted: shown(''), rateLimits: null } };
51
53
  case 'circuit_open':
52
54
  return {
53
55
  kind: 'error',
54
56
  deadline,
55
57
  ...extra,
56
- error: { formatted: p.detail ?? 'Service temporarily unavailable', isNetworkDown: true },
58
+ error: { formatted: shown('Service temporarily unavailable'), isNetworkDown: true },
57
59
  };
58
60
  case 'gave_up':
59
- return { kind: 'error', deadline, terminal: true, ...extra, error: { formatted: p.detail ?? '' } };
61
+ return { kind: 'error', deadline, terminal: true, ...extra, error: { formatted: shown('') } };
60
62
  case 'waiting_first_token':
61
63
  return { kind: 'waiting', deadline, ...extra, error: { formatted: '' } };
62
64
  case 'retrying':
63
- return { kind: 'error', deadline, ...extra, error: { formatted: p.detail ?? '' } };
65
+ return { kind: 'error', deadline, ...extra, error: { formatted: shown('') } };
64
66
  default:
65
67
  return { kind: 'error', deadline, ...extra, error: { formatted: '' } };
66
68
  }
@@ -1,3 +1,4 @@
1
+ import type { RewindMode } from './rewindWireCaps.js';
1
2
  export type RewindArchiveBit = 'on' | 'off' | 'not_reported' | 'malformed';
2
3
  export type RewindArchiveReading = {
3
4
  kind: 'unobserved';
@@ -18,7 +19,7 @@ export declare function observedRewindArchive(baseUrl?: string | undefined): Rew
18
19
  export declare function rewindCodeArchiveAvailability(reading: RewindArchiveReading, mode: RewindArchiveMode): RewindCodeArchive;
19
20
  export declare function rewindArchiveDoctorDetail(reading: RewindArchiveReading, mode: RewindArchiveMode): string;
20
21
  export declare function rewindConversationAvailability(reading: RewindArchiveReading): RewindCodeArchive;
22
+ export declare function engineRewindRefusedNow(option: RewindMode, reading?: RewindArchiveReading): boolean;
21
23
  export declare function rewindConversationDoctorDetail(reading: RewindArchiveReading): string;
22
24
  export declare function rewindRestoreFilesEpochDetail(reading: RewindArchiveReading): string;
23
- export declare function forgetRewindArchiveReading(baseUrl: string | undefined): void;
24
25
  export declare function __resetRewindArchiveReadingsForTests(): void;
@@ -1,5 +1,6 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
2
  import { createEngineCapReader } from './engineCapReader.js';
3
+ import { ownDataField } from './ownKey.js';
3
4
  import { _wireConversationRewindJudge } from './toolHistoryMismatch.js';
4
5
  const CAPS_KEYS = {
5
6
  conversationAnchor: 'resumeAt',
@@ -10,9 +11,7 @@ const CAPS_KEYS = {
10
11
  const _capsKeyPin = true;
11
12
  void _capsKeyPin;
12
13
  function bitOf(caps, key) {
13
- if (!Object.hasOwn(caps, key))
14
- return 'not_reported';
15
- const v = caps[key];
14
+ const v = ownDataField(caps, key);
16
15
  if (v === undefined)
17
16
  return 'not_reported';
18
17
  if (v === true)
@@ -22,15 +21,20 @@ function bitOf(caps, key) {
22
21
  return 'malformed';
23
22
  }
24
23
  export function projectRewindArchiveCapability(caps) {
25
- if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
24
+ try {
25
+ if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
26
+ return undefined;
27
+ return {
28
+ kind: 'present',
29
+ conversationAnchor: bitOf(caps, CAPS_KEYS.conversationAnchor),
30
+ forkRestore: bitOf(caps, CAPS_KEYS.forkRestore),
31
+ codeOnly: bitOf(caps, CAPS_KEYS.codeOnly),
32
+ restoreFilesEpoch: bitOf(caps, CAPS_KEYS.restoreFilesEpoch),
33
+ };
34
+ }
35
+ catch {
26
36
  return undefined;
27
- return {
28
- kind: 'present',
29
- conversationAnchor: bitOf(caps, CAPS_KEYS.conversationAnchor),
30
- forkRestore: bitOf(caps, CAPS_KEYS.forkRestore),
31
- codeOnly: bitOf(caps, CAPS_KEYS.codeOnly),
32
- restoreFilesEpoch: bitOf(caps, CAPS_KEYS.restoreFilesEpoch),
33
- };
37
+ }
34
38
  }
35
39
  const reader = createEngineCapReader({
36
40
  name: 'rewindArchive',
@@ -38,12 +42,12 @@ const reader = createEngineCapReader({
38
42
  makeUnobserved: () => ({ kind: 'unobserved' }),
39
43
  });
40
44
  export function noteEngineCapsForRewindArchive(baseUrl, caps, opts) {
41
- _wireConversationRewindJudge(conversationRewindJudge);
42
45
  reader.note(baseUrl, caps, opts);
43
46
  }
44
47
  function conversationRewindJudge(engineBaseUrl) {
45
48
  return rewindConversationAvailability(observedRewindArchive(engineBaseUrl));
46
49
  }
50
+ _wireConversationRewindJudge(conversationRewindJudge);
47
51
  export function observedRewindArchive(baseUrl = engineWireTarget()?.baseUrl) {
48
52
  return reader.observed(baseUrl);
49
53
  }
@@ -91,6 +95,18 @@ export function rewindConversationAvailability(reading) {
91
95
  return 'unavailable';
92
96
  return 'unknown';
93
97
  }
98
+ export function engineRewindRefusedNow(option, reading = observedRewindArchive()) {
99
+ switch (option) {
100
+ case 'both':
101
+ return rewindCodeArchiveAvailability(reading, 'both') === 'unavailable';
102
+ case 'code':
103
+ return rewindCodeArchiveAvailability(reading, 'code') === 'unavailable';
104
+ case 'conversation':
105
+ return rewindConversationAvailability(reading) === 'unavailable';
106
+ default:
107
+ return false;
108
+ }
109
+ }
94
110
  export function rewindConversationDoctorDetail(reading) {
95
111
  const lane = 'rewind to a message';
96
112
  if (reading.kind !== 'present') {
@@ -122,9 +138,6 @@ export function rewindRestoreFilesEpochDetail(reading) {
122
138
  return 'the restore-files epoch bit is reported in an unreadable shape, so a rewind with code restore built from this reading leaves the key out and moves the conversation only';
123
139
  }
124
140
  }
125
- export function forgetRewindArchiveReading(baseUrl) {
126
- reader.forget(baseUrl);
127
- }
128
141
  export function __resetRewindArchiveReadingsForTests() {
129
142
  reader.__resetForTests();
130
143
  }
@@ -0,0 +1,21 @@
1
+ import { type RewindArchiveReading } from './rewindArchiveCapability.js';
2
+ import { type RewindMode, type SeamRewindSpec } from './rewindWireCaps.js';
3
+ export type RewindRestoreOption = RewindMode | 'summarize' | 'summarize_up_to' | 'nevermind';
4
+ export type RewindTargetPosition = 'root' | 'after-root' | 'unknown';
5
+ export interface RewindTargetResolution {
6
+ readonly position: RewindTargetPosition;
7
+ readonly targetEntryId?: string;
8
+ readonly anchorUnresolved?: true;
9
+ }
10
+ export type RewindEngineNoneReason = 'not-an-engine-rewind' | 'no-engine-turn-to-rewind' | 'unresolved';
11
+ export type RewindEngineAction = {
12
+ readonly kind: 'none';
13
+ readonly reason: RewindEngineNoneReason;
14
+ } | {
15
+ readonly kind: 'arm';
16
+ readonly spec: SeamRewindSpec;
17
+ } | {
18
+ readonly kind: 'reopen';
19
+ };
20
+ export declare function decideRewindEngineAction(option: RewindRestoreOption, resolved: RewindTargetResolution, reading?: RewindArchiveReading): RewindEngineAction;
21
+ export declare function previewEngineRewind(option: RewindRestoreOption, resolved: RewindTargetResolution, reading?: RewindArchiveReading): RewindEngineAction['kind'];
@@ -0,0 +1,36 @@
1
+ import { observedRewindArchive } from './rewindArchiveCapability.js';
2
+ import { REWIND_MODES, rewindSpecForMode } from './rewindWireCaps.js';
3
+ import { readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
4
+ function modeOfOption(option) {
5
+ return REWIND_MODES.includes(option) ? option : undefined;
6
+ }
7
+ function carriesResumeAt(mode) {
8
+ return rewindSpecForMode(mode, 'x').resumeAt !== undefined;
9
+ }
10
+ function positionOf(resolved) {
11
+ const p = readOwnDataValue(resolved, 'position');
12
+ return p === 'root' || p === 'after-root' ? p : 'unknown';
13
+ }
14
+ export function decideRewindEngineAction(option, resolved, reading = observedRewindArchive()) {
15
+ const mode = modeOfOption(option);
16
+ if (mode === undefined)
17
+ return { kind: 'none', reason: 'not-an-engine-rewind' };
18
+ const position = positionOf(resolved);
19
+ const targetEntryId = readOwnDataNonEmptyString(resolved, 'targetEntryId');
20
+ if (!carriesResumeAt(mode)) {
21
+ if (targetEntryId !== undefined)
22
+ return { kind: 'arm', spec: rewindSpecForMode(mode, targetEntryId, reading) };
23
+ const unresolved = position === 'unknown' || readOwnDataValue(resolved, 'anchorUnresolved') === true;
24
+ return { kind: 'none', reason: unresolved ? 'unresolved' : 'no-engine-turn-to-rewind' };
25
+ }
26
+ if (position === 'root')
27
+ return { kind: 'reopen' };
28
+ if (position === 'unknown')
29
+ return { kind: 'none', reason: 'unresolved' };
30
+ return targetEntryId !== undefined
31
+ ? { kind: 'arm', spec: rewindSpecForMode(mode, targetEntryId, reading) }
32
+ : { kind: 'none', reason: 'no-engine-turn-to-rewind' };
33
+ }
34
+ export function previewEngineRewind(option, resolved, reading = observedRewindArchive()) {
35
+ return decideRewindEngineAction(option, resolved, reading).kind;
36
+ }
@@ -5,6 +5,7 @@ export interface SeamRewindSpec {
5
5
  restoreFiles?: boolean;
6
6
  rewindFilesTo?: string;
7
7
  }
8
- export type RewindMode = 'both' | 'conversation' | 'code';
8
+ export declare const REWIND_MODES: readonly ["both", "conversation", "code"];
9
+ export type RewindMode = (typeof REWIND_MODES)[number];
9
10
  export declare function rewindSpecForMode(mode: RewindMode, targetEntryId: string, reading?: RewindArchiveReading): SeamRewindSpec;
10
11
  export declare function projectRewind(pending: SeamRewindSpec | undefined): SeamRewindSpec;
@@ -1,3 +1,4 @@
1
+ export const REWIND_MODES = Object.freeze(['both', 'conversation', 'code']);
1
2
  function restoreFilesKeyMaySend(reading) {
2
3
  if (reading === undefined)
3
4
  return true;
@@ -1,2 +1,2 @@
1
- import type { ToolRosterView } from '../toolRoster.js';
1
+ import type { ToolRosterView } from './toolRoster.js';
2
2
  export declare function rosterMountedNames(roster: ToolRosterView | null | undefined): ReadonlySet<string> | 'absent' | 'unreadable';
@@ -34,6 +34,7 @@ export function readRunCancelContext(record) {
34
34
  };
35
35
  }
36
36
  import { readRunTerminal } from './runTerminal.js';
37
+ import { SDK_ABORT_CAUSES } from './generated/sdkFactTables.js';
37
38
  export const RUN_CANCELLED_CODE = 'cancelled';
38
39
  const LIVE_STATUSES = new Set(['running', 'queued', 'suspended', 'needs_review']);
39
40
  export function classifyRunAbortCause(record) {
@@ -56,7 +57,7 @@ export function classifyRunAbortCause(record) {
56
57
  return { kind: 'run_still_live', status };
57
58
  return { kind: 'unknown', ...(read !== null ? { terminal: read.kind } : {}) };
58
59
  }
59
- export const ABORT_CAUSES = Object.freeze(['client_disconnected', 'ask_park_grace_exhausted', 'cancel_verb']);
60
+ export const ABORT_CAUSES = SDK_ABORT_CAUSES;
60
61
  function ownDataOf(o, key) {
61
62
  const d = Object.getOwnPropertyDescriptor(o, key);
62
63
  return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
@@ -60,14 +60,3 @@ export declare function runTerminalGateKind(read: RunTerminalRead | null): strin
60
60
  export declare function runTerminalGateToolName(read: RunTerminalRead | null): string | undefined;
61
61
  export declare function runTerminalCode(read: RunTerminalRead | null): string | undefined;
62
62
  export declare function isReviewPark(read: RunTerminalRead | null): boolean;
63
- export declare const TERMINAL_CAUSE_KINDS: readonly ["completed", "failed", "blocked", "paused"];
64
- export type TerminalCauseKind = (typeof TERMINAL_CAUSE_KINDS)[number];
65
- export declare function isTerminalCauseKind(kind: unknown): kind is TerminalCauseKind;
66
- export declare const RUN_TERMINAL_NOT_SUCCESS_STATUSES: readonly ["failed", "killed", "blocked"];
67
- export type RunTerminalNotSuccessStatus = (typeof RUN_TERMINAL_NOT_SUCCESS_STATUSES)[number];
68
- export declare function isTerminalNotSuccess(status: unknown): status is RunTerminalNotSuccessStatus;
69
- export declare const RUN_TERMINAL_STATUSES: readonly ["completed", "failed", "killed", "blocked"];
70
- export type RunTerminalStatus = (typeof RUN_TERMINAL_STATUSES)[number];
71
- export declare function isTerminalStatus(status: unknown): status is RunTerminalStatus;
72
- export declare const TASK_NOTIFICATION_TERMINAL_STATUSES: readonly string[];
73
- export declare function isTaskNotificationTerminalStatus(status: string | undefined): boolean;
@@ -1,4 +1,5 @@
1
- import { CORE_PROMPT_BLOCK_CAUSES, CORE_TERMINAL_CAUSE_KINDS } from './generated/engineFactTables.js';
1
+ import { CORE_PROMPT_BLOCK_CAUSES } from './generated/engineFactTables.js';
2
+ import { isSdkRunParked } from './terminalStatuses.js';
2
3
  export const PROMPT_BLOCK_CAUSES = CORE_PROMPT_BLOCK_CAUSES;
3
4
  const PROMPT_BLOCKED_BY_HOOK_DETAIL_KIND = 'prompt_blocked_by_hook';
4
5
  function str(v) {
@@ -69,7 +70,6 @@ function blockedDetailOf(cause) {
69
70
  return undefined;
70
71
  }
71
72
  }
72
- const FLAT_PAUSED_STATUSES = ['suspended', 'needs_review'];
73
73
  export function readRunTerminal(result) {
74
74
  if (typeof result !== 'object' || result === null || Array.isArray(result))
75
75
  return null;
@@ -83,7 +83,7 @@ export function readRunTerminal(result) {
83
83
  if (kind === undefined)
84
84
  return { kind: 'unknown', plane: 'cause' };
85
85
  const parkWord = str(r.status);
86
- if (parkWord !== undefined && FLAT_PAUSED_STATUSES.includes(parkWord)) {
86
+ if (isSdkRunParked(parkWord)) {
87
87
  return { kind: 'paused', plane: 'cause', flatStatus: parkWord, ...(kind === 'paused' ? (pauseOf(c) ?? {}) : {}) };
88
88
  }
89
89
  switch (kind) {
@@ -138,7 +138,7 @@ export function readRunTerminal(result) {
138
138
  ...(code !== undefined ? { code } : {}),
139
139
  };
140
140
  }
141
- if (FLAT_PAUSED_STATUSES.includes(status)) {
141
+ if (isSdkRunParked(status)) {
142
142
  const gate = gateOf(r.checkpointGate);
143
143
  const checkpointId = str(r.checkpointId);
144
144
  const restoreMode = str(r.workspaceRestoreMode);
@@ -183,26 +183,3 @@ export function isReviewPark(read) {
183
183
  return true;
184
184
  return read !== null && read.kind === 'paused' && read.flatStatus === FLAT_REVIEW_STATUS;
185
185
  }
186
- export const TERMINAL_CAUSE_KINDS = CORE_TERMINAL_CAUSE_KINDS;
187
- export function isTerminalCauseKind(kind) {
188
- return typeof kind === 'string' && TERMINAL_CAUSE_KINDS.includes(kind);
189
- }
190
- export const RUN_TERMINAL_NOT_SUCCESS_STATUSES = Object.freeze([
191
- 'failed',
192
- 'killed',
193
- 'blocked',
194
- ]);
195
- export function isTerminalNotSuccess(status) {
196
- return typeof status === 'string' && RUN_TERMINAL_NOT_SUCCESS_STATUSES.includes(status);
197
- }
198
- export const RUN_TERMINAL_STATUSES = Object.freeze([
199
- 'completed',
200
- ...RUN_TERMINAL_NOT_SUCCESS_STATUSES,
201
- ]);
202
- export function isTerminalStatus(status) {
203
- return typeof status === 'string' && RUN_TERMINAL_STATUSES.includes(status);
204
- }
205
- export const TASK_NOTIFICATION_TERMINAL_STATUSES = Object.freeze(['completed', 'failed', 'killed', 'cancelled']);
206
- export function isTaskNotificationTerminalStatus(status) {
207
- return status !== undefined && TASK_NOTIFICATION_TERMINAL_STATUSES.includes(status);
208
- }
@@ -3,5 +3,6 @@ export { getMeConfig, getScopeConfigDraft, getEffective } from '@sema-agent/sdk/
3
3
  export { probeRegistryHealth, postFeedback } from '@sema-agent/sdk/registry';
4
4
  export { REGISTRY_AUTH_PATHS, skillContentAddress } from '@sema-agent/sdk/registry';
5
5
  export { requestDeviceCode, pollUntilApproved, refreshTokens, listScopes, switchScope } from '@sema-agent/sdk/registry';
6
+ export { classifyRegistryConflict } from '@sema-agent/sdk/registry';
6
7
  export { RegistryApiError, OAuthFlowError } from '@sema-agent/sdk/registry';
7
- export type { RegistryTokens, TokenProvider, } from '@sema-agent/sdk/registry';
8
+ export type { RegistryConflictClass, RegistryTokens, TokenProvider, } from '@sema-agent/sdk/registry';
@@ -3,4 +3,5 @@ export { getMeConfig, getScopeConfigDraft, getEffective } from '@sema-agent/sdk/
3
3
  export { probeRegistryHealth, postFeedback } from '@sema-agent/sdk/registry';
4
4
  export { REGISTRY_AUTH_PATHS, skillContentAddress } from '@sema-agent/sdk/registry';
5
5
  export { requestDeviceCode, pollUntilApproved, refreshTokens, listScopes, switchScope } from '@sema-agent/sdk/registry';
6
+ export { classifyRegistryConflict } from '@sema-agent/sdk/registry';
6
7
  export { RegistryApiError, OAuthFlowError } from '@sema-agent/sdk/registry';
@@ -13,5 +13,4 @@ export declare function noteEngineCapsForSealedKey(baseUrl: string, caps: unknow
13
13
  generation?: number;
14
14
  }): void;
15
15
  export declare function observedSealedKey(baseUrl?: string | undefined): SealedKeyReading;
16
- export declare function forgetSealedKeyReading(baseUrl: string | undefined): void;
17
16
  export declare function __resetSealedKeyReadingsForTests(): void;
@@ -1,27 +1,29 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
2
  import { createEngineCapReader } from './engineCapReader.js';
3
+ import { ownDataField } from './ownKey.js';
3
4
  function ownNonEmpty(seg, key) {
4
- if (!Object.hasOwn(seg, key))
5
- return undefined;
6
- const v = seg[key];
5
+ const v = ownDataField(seg, key);
7
6
  return typeof v === 'string' && v.length > 0 ? v : undefined;
8
7
  }
9
8
  export function projectSealedKeyCapability(caps) {
10
- if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
11
- return undefined;
12
- if (!Object.hasOwn(caps, 'sealedKey'))
13
- return { kind: 'not_reported' };
14
- const seg = caps.sealedKey;
15
- if (seg === undefined)
16
- return { kind: 'not_reported' };
17
- if (seg === null || typeof seg !== 'object' || Array.isArray(seg))
9
+ try {
10
+ if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
11
+ return undefined;
12
+ const seg = ownDataField(caps, 'sealedKey');
13
+ if (seg === undefined)
14
+ return { kind: 'not_reported' };
15
+ if (seg === null || typeof seg !== 'object' || Array.isArray(seg))
16
+ return undefined;
17
+ const alg = ownNonEmpty(seg, 'alg');
18
+ const publicKeyId = ownNonEmpty(seg, 'publicKeyId');
19
+ const publicKey = ownNonEmpty(seg, 'publicKey');
20
+ if (alg === undefined || publicKeyId === undefined || publicKey === undefined)
21
+ return undefined;
22
+ return { kind: 'present', alg, publicKeyId, publicKey };
23
+ }
24
+ catch {
18
25
  return undefined;
19
- const alg = ownNonEmpty(seg, 'alg');
20
- const publicKeyId = ownNonEmpty(seg, 'publicKeyId');
21
- const publicKey = ownNonEmpty(seg, 'publicKey');
22
- if (alg === undefined || publicKeyId === undefined || publicKey === undefined)
23
- return undefined;
24
- return { kind: 'present', alg, publicKeyId, publicKey };
26
+ }
25
27
  }
26
28
  const reader = createEngineCapReader({
27
29
  name: 'sealedKey',
@@ -34,9 +36,6 @@ export function noteEngineCapsForSealedKey(baseUrl, caps, opts) {
34
36
  export function observedSealedKey(baseUrl = engineWireTarget()?.baseUrl) {
35
37
  return reader.observed(baseUrl);
36
38
  }
37
- export function forgetSealedKeyReading(baseUrl) {
38
- reader.forget(baseUrl);
39
- }
40
39
  export function __resetSealedKeyReadingsForTests() {
41
40
  reader.__resetForTests();
42
41
  }