@sema-agent/client-core 0.94.0 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/CHANGELOG.md +521 -0
  2. package/README.md +104 -57
  3. package/dist/adapt/arms.js +12 -7
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.d.ts +1 -0
  6. package/dist/adapt/toolCards.js +18 -5
  7. package/dist/adapt/wireShapes.js +5 -24
  8. package/dist/adapter/activeRunSelfHeal.d.ts +12 -3
  9. package/dist/adapter/activeRunSelfHeal.js +50 -16
  10. package/dist/adapter/downstream/eventToSdkMessage.js +33 -18
  11. package/dist/adapter/downstream/terminalToSdkResult.js +19 -12
  12. package/dist/adapter/runStream.js +30 -46
  13. package/dist/adapter/types.d.ts +7 -0
  14. package/dist/adapter/types.js +15 -0
  15. package/dist/agentSession/backgroundView.js +5 -1
  16. package/dist/agentSession/engineAgentRegistryRead.js +7 -5
  17. package/dist/agentSession/engineSessionBackgroundStop.js +25 -17
  18. package/dist/agentsWireCaps.d.ts +2 -0
  19. package/dist/agentsWireCaps.js +13 -2
  20. package/dist/approvalDecidedByCapability.d.ts +0 -1
  21. package/dist/approvalDecidedByCapability.js +2 -7
  22. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  23. package/dist/approvalsStreamLiveCapability.js +2 -6
  24. package/dist/atMostOnce.d.ts +8 -0
  25. package/dist/atMostOnce.js +36 -0
  26. package/dist/attachmentSeatCapability.d.ts +0 -1
  27. package/dist/attachmentSeatCapability.js +0 -3
  28. package/dist/attachmentsWireCaps.js +11 -6
  29. package/dist/bashExitReading.d.ts +10 -0
  30. package/dist/bashExitReading.js +12 -0
  31. package/dist/callerCwdCapability.d.ts +0 -5
  32. package/dist/callerCwdCapability.js +2 -13
  33. package/dist/centerWiringCapability.d.ts +1 -7
  34. package/dist/centerWiringCapability.js +18 -27
  35. package/dist/classifierStatus.js +4 -4
  36. package/dist/classifierVerdictWire.js +4 -16
  37. package/dist/clientSlice.js +1 -1
  38. package/dist/cloudConfigWireCaps.d.ts +3 -3
  39. package/dist/cloudConfigWireCaps.js +85 -43
  40. package/dist/compensations.js +1 -1
  41. package/dist/coreValuePorts.d.ts +11 -7
  42. package/dist/coreValuePorts.js +5 -8
  43. package/dist/credentialProvenance.d.ts +28 -0
  44. package/dist/credentialProvenance.js +76 -0
  45. package/dist/cycleOrder.d.ts +15 -0
  46. package/dist/cycleOrder.js +45 -0
  47. package/dist/decideFailureNote.js +7 -2
  48. package/dist/decideReceipt.d.ts +2 -1
  49. package/dist/decideReceipt.js +39 -14
  50. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  51. package/dist/declared/supportFloorDeclared.js +5 -0
  52. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  53. package/dist/deviceExecutorManagementCapability.js +7 -16
  54. package/dist/deviceRebind.d.ts +88 -0
  55. package/dist/deviceRebind.js +242 -0
  56. package/dist/displayUntrusted.d.ts +8 -3
  57. package/dist/displayUntrusted.js +661 -63
  58. package/dist/engineAgentAbsence.d.ts +2 -2
  59. package/dist/engineAgentPanelStore.d.ts +8 -18
  60. package/dist/engineAgentPanelStore.js +19 -537
  61. package/dist/engineCapReader.d.ts +6 -6
  62. package/dist/engineCapReader.js +30 -43
  63. package/dist/engineCapsCache.d.ts +13 -2
  64. package/dist/engineCapsCache.js +276 -44
  65. package/dist/engineCredentialRequirement.d.ts +9 -0
  66. package/dist/engineCredentialRequirement.js +23 -0
  67. package/dist/engineDirectory.d.ts +79 -0
  68. package/dist/engineDirectory.js +186 -0
  69. package/dist/engineEnvSourcing.d.ts +53 -0
  70. package/dist/engineEnvSourcing.js +81 -0
  71. package/dist/engineErrorCodes.d.ts +28 -4
  72. package/dist/engineErrorCodes.js +68 -25
  73. package/dist/engineIdentity.js +2 -0
  74. package/dist/engineNoticeCodes.d.ts +17 -0
  75. package/dist/engineNoticeCodes.js +57 -3
  76. package/dist/engineWireSdk.js +2 -2
  77. package/dist/engineWordRenames.d.ts +8 -0
  78. package/dist/engineWordRenames.js +13 -0
  79. package/dist/executionLaneCapability.d.ts +2 -3
  80. package/dist/executionLaneCapability.js +18 -23
  81. package/dist/fileHistoryCaptureCapability.d.ts +14 -1
  82. package/dist/fileHistoryCaptureCapability.js +72 -6
  83. package/dist/fileHistoryLegNotice.d.ts +3 -2
  84. package/dist/fileHistoryLegNotice.js +51 -2
  85. package/dist/fleet/bgSubagentRow.d.ts +15 -0
  86. package/dist/fleet/bgSubagentRow.js +67 -0
  87. package/dist/fleet/fleetLedger.d.ts +3 -0
  88. package/dist/fleet/fleetLedger.js +153 -122
  89. package/dist/fleet/fleetProjection.d.ts +1 -3
  90. package/dist/fleet/fleetProjection.js +19 -19
  91. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  92. package/dist/fleetAgentPanelProjection.js +7 -197
  93. package/dist/fleetAgentRowLike.d.ts +16 -0
  94. package/dist/fleetAgentRowLike.js +1 -0
  95. package/dist/fleetTaskDesc.js +4 -17
  96. package/dist/gateOutcome.d.ts +12 -1
  97. package/dist/gateOutcome.js +87 -18
  98. package/dist/gateVocabulary.d.ts +7 -2
  99. package/dist/gateVocabulary.js +5 -1
  100. package/dist/generated/engineAskFaceTables.js +1 -1
  101. package/dist/generated/engineFactTables.d.ts +5 -3
  102. package/dist/generated/engineFactTables.js +17 -4
  103. package/dist/generated/engineNoticeTables.js +12 -3
  104. package/dist/generated/sdkFactTables.d.ts +2 -0
  105. package/dist/generated/sdkFactTables.js +17 -0
  106. package/dist/generated/settingsSchemaFns.d.ts +13 -0
  107. package/dist/generated/settingsSchemaFns.js +75 -0
  108. package/dist/generated/toolNameTables.d.ts +1 -0
  109. package/dist/generated/toolNameTables.js +1 -0
  110. package/dist/headlessPermissionModeWire.d.ts +1 -1
  111. package/dist/headlessPermissionModeWire.js +1 -1
  112. package/dist/headlessReconnectWire.js +49 -20
  113. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  114. package/dist/hitl/allowRuleShadow.js +49 -8
  115. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  116. package/dist/hitl/approvalCompleteParked.js +14 -0
  117. package/dist/hitl/approvalEndingCause.d.ts +7 -0
  118. package/dist/hitl/approvalEndingCause.js +71 -0
  119. package/dist/hitl/approvalHolds.d.ts +12 -2
  120. package/dist/hitl/approvalHolds.js +53 -2
  121. package/dist/hitl/approvalsFeed.js +23 -11
  122. package/dist/hitl/askGateWire.d.ts +2 -1
  123. package/dist/hitl/askGateWire.js +26 -1
  124. package/dist/hitl/askParkRowRouting.js +1 -1
  125. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  126. package/dist/hitl/automaticAnswerVerdict.js +15 -10
  127. package/dist/hitl/crashConverged.js +2 -0
  128. package/dist/hitl/decisionConflict.d.ts +3 -0
  129. package/dist/hitl/decisionConflict.js +41 -0
  130. package/dist/hitl/decisionRefusal.d.ts +12 -0
  131. package/dist/hitl/decisionRefusal.js +63 -4
  132. package/dist/hitl/frameRouter.d.ts +0 -1
  133. package/dist/hitl/frameRouter.js +32 -57
  134. package/dist/hitl/gateLedger.d.ts +5 -0
  135. package/dist/hitl/gateLedger.js +21 -0
  136. package/dist/hitl/hitlBridge.d.ts +17 -2
  137. package/dist/hitl/hitlBridge.js +91 -55
  138. package/dist/hitl/hitlHostSurface.js +3 -11
  139. package/dist/hitl/livePendingAsk.d.ts +16 -6
  140. package/dist/hitl/livePendingAsk.js +36 -4
  141. package/dist/hitl/localAllowRule.d.ts +1 -0
  142. package/dist/hitl/localAllowRule.js +2 -2
  143. package/dist/hitl/noAllowCause.d.ts +2 -1
  144. package/dist/hitl/noAllowCause.js +3 -2
  145. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  146. package/dist/hitl/parkExpiryJudgements.js +46 -0
  147. package/dist/hitl/parkResolver.d.ts +4 -7
  148. package/dist/hitl/parkResolver.js +12 -34
  149. package/dist/hitl/parkRowBirthWait.d.ts +1 -0
  150. package/dist/hitl/parkRowBirthWait.js +2 -2
  151. package/dist/hitl/persistedRulesWire.js +5 -1
  152. package/dist/hitl/planReviewWire.d.ts +3 -2
  153. package/dist/hitl/planReviewWire.js +154 -50
  154. package/dist/hitl/replayedApproval.d.ts +9 -0
  155. package/dist/hitl/replayedApproval.js +139 -10
  156. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  157. package/dist/hitl/resumeRunningCard.js +15 -4
  158. package/dist/hitl/sessionPolicyDeliverable.js +8 -6
  159. package/dist/hitl/standingRows.d.ts +18 -0
  160. package/dist/hitl/standingRows.js +127 -0
  161. package/dist/hitl/toolApprovalWire.d.ts +39 -7
  162. package/dist/hitl/toolApprovalWire.js +351 -61
  163. package/dist/hookMatcherVerdict.d.ts +1 -9
  164. package/dist/hookMatcherVerdict.js +21 -61
  165. package/dist/hooksWireCaps.js +40 -8
  166. package/dist/host.d.ts +5 -0
  167. package/dist/host.js +3 -1
  168. package/dist/hostCallbackGuard.d.ts +2 -0
  169. package/dist/hostCallbackGuard.js +31 -0
  170. package/dist/index.d.ts +48 -17
  171. package/dist/index.js +36 -15
  172. package/dist/interactiveInterrupt.d.ts +8 -0
  173. package/dist/interactiveInterrupt.js +54 -0
  174. package/dist/limitsWire.d.ts +5 -0
  175. package/dist/limitsWire.js +49 -3
  176. package/dist/liveModelCatalog.d.ts +95 -0
  177. package/dist/liveModelCatalog.js +297 -32
  178. package/dist/mcpEngineLeg.d.ts +25 -0
  179. package/dist/mcpEngineLeg.js +71 -15
  180. package/dist/mcpPanel.js +2 -1
  181. package/dist/mcpProbeCapability.d.ts +0 -5
  182. package/dist/mcpProbeCapability.js +2 -12
  183. package/dist/mcpReconnect.d.ts +1 -3
  184. package/dist/mcpReconnect.js +10 -5
  185. package/dist/memoryComplianceCapability.d.ts +0 -5
  186. package/dist/memoryComplianceCapability.js +2 -12
  187. package/dist/memoryOriginCapability.d.ts +0 -5
  188. package/dist/memoryOriginCapability.js +2 -12
  189. package/dist/memorySpecWire.js +2 -2
  190. package/dist/memoryVerbsWire.d.ts +1 -1
  191. package/dist/memoryVerbsWire.js +4 -0
  192. package/dist/model/liveCatalogShape.d.ts +14 -0
  193. package/dist/model/liveCatalogShape.js +71 -0
  194. package/dist/model/modelSupplyRules.d.ts +1 -0
  195. package/dist/model/modelSupplyRules.js +30 -9
  196. package/dist/model/modelsPolicy.d.ts +21 -0
  197. package/dist/model/modelsPolicy.js +90 -0
  198. package/dist/modelIdentityResolvability.d.ts +2 -2
  199. package/dist/modelIdentityResolvability.js +14 -12
  200. package/dist/modelSwitchFallback.d.ts +69 -0
  201. package/dist/modelSwitchFallback.js +206 -0
  202. package/dist/noticePresentation.d.ts +68 -0
  203. package/dist/noticePresentation.js +247 -0
  204. package/dist/notifications.js +12 -11
  205. package/dist/outputStyleSeatCapability.d.ts +0 -2
  206. package/dist/outputStyleSeatCapability.js +2 -10
  207. package/dist/ownKey.d.ts +8 -0
  208. package/dist/ownKey.js +66 -0
  209. package/dist/panelReduce.d.ts +114 -0
  210. package/dist/panelReduce.js +1135 -0
  211. package/dist/panelStateHolder.d.ts +17 -0
  212. package/dist/panelStateHolder.js +201 -0
  213. package/dist/peerFrames.js +13 -9
  214. package/dist/peerLaneCapability.d.ts +0 -1
  215. package/dist/peerLaneCapability.js +2 -6
  216. package/dist/permissionModesCapability.d.ts +0 -5
  217. package/dist/permissionModesCapability.js +5 -16
  218. package/dist/permissionRuleIssue.js +0 -3
  219. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  220. package/dist/permissionRulesWriteCapability.js +2 -6
  221. package/dist/permissionsAllowGrantCapability.d.ts +0 -1
  222. package/dist/permissionsAllowGrantCapability.js +3 -9
  223. package/dist/permissionsDeclaration.d.ts +8 -0
  224. package/dist/permissionsDeclaration.js +101 -41
  225. package/dist/printPermissionOutcome.d.ts +12 -0
  226. package/dist/printPermissionOutcome.js +50 -0
  227. package/dist/printToolResultFrame.d.ts +1 -0
  228. package/dist/printToolResultFrame.js +5 -17
  229. package/dist/promptBlockedCopy.d.ts +5 -0
  230. package/dist/promptBlockedCopy.js +35 -0
  231. package/dist/promptDelivery.js +0 -8
  232. package/dist/protocolSegment.d.ts +9 -6
  233. package/dist/protocolSegment.js +31 -21
  234. package/dist/providerRejection.d.ts +4 -0
  235. package/dist/providerRejection.js +75 -14
  236. package/dist/replayBody.d.ts +12 -0
  237. package/dist/replayBody.js +25 -0
  238. package/dist/resumeRefusalCopy.d.ts +18 -1
  239. package/dist/resumeRefusalCopy.js +127 -32
  240. package/dist/retryStatus.d.ts +9 -1
  241. package/dist/retryStatus.js +9 -2
  242. package/dist/rewindArchiveCapability.d.ts +5 -14
  243. package/dist/rewindArchiveCapability.js +18 -61
  244. package/dist/rewindArchiveReading.d.ts +15 -0
  245. package/dist/rewindArchiveReading.js +56 -0
  246. package/dist/rewindEngineAction.d.ts +21 -0
  247. package/dist/rewindEngineAction.js +36 -0
  248. package/dist/rewindWireCaps.d.ts +2 -1
  249. package/dist/rewindWireCaps.js +1 -0
  250. package/dist/ruleCompileVerdict.d.ts +9 -1
  251. package/dist/ruleCompileVerdict.js +29 -4
  252. package/dist/runTerminal.d.ts +15 -12
  253. package/dist/runTerminal.js +60 -35
  254. package/dist/sandboxWire.js +13 -0
  255. package/dist/sdkRegistryTransit.d.ts +2 -1
  256. package/dist/sdkRegistryTransit.js +1 -0
  257. package/dist/sealedKeyCapability.d.ts +0 -5
  258. package/dist/sealedKeyCapability.js +3 -15
  259. package/dist/seam.js +4 -2
  260. package/dist/seatContract.d.ts +125 -34
  261. package/dist/seatContract.js +583 -179
  262. package/dist/sessionIdSegment.d.ts +1 -0
  263. package/dist/sessionIdSegment.js +11 -0
  264. package/dist/sessionMemoryErase.d.ts +1 -1
  265. package/dist/sessionMemoryErase.js +6 -1
  266. package/dist/sessionMemoryStatus.js +3 -2
  267. package/dist/sessionPolicyCapability.d.ts +0 -1
  268. package/dist/sessionPolicyCapability.js +2 -6
  269. package/dist/sessionReadRedactionCapability.d.ts +0 -5
  270. package/dist/sessionReadRedactionCapability.js +2 -13
  271. package/dist/sessionSyncFileHistory.d.ts +4 -0
  272. package/dist/sessionSyncFileHistory.js +66 -0
  273. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -2
  274. package/dist/sessionSyncFileHistoryCapability.js +2 -9
  275. package/dist/skillToolListsCapability.d.ts +0 -2
  276. package/dist/skillToolListsCapability.js +2 -9
  277. package/dist/skillsWireCaps.d.ts +4 -0
  278. package/dist/skillsWireCaps.js +66 -1
  279. package/dist/sqlEngineCapability.d.ts +0 -1
  280. package/dist/sqlEngineCapability.js +9 -14
  281. package/dist/steerPriorityCapability.d.ts +0 -2
  282. package/dist/steerPriorityCapability.js +3 -12
  283. package/dist/storePostureCapability.d.ts +1 -5
  284. package/dist/storePostureCapability.js +16 -22
  285. package/dist/streamDrainingLegs.d.ts +6 -0
  286. package/dist/streamDrainingLegs.js +23 -0
  287. package/dist/subagent/engineCompactWire.js +13 -38
  288. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  289. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  290. package/dist/subagent/engineSubagentOutput.js +5 -20
  291. package/dist/subagent/engineSubagentSteer.js +7 -5
  292. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  293. package/dist/subagent/engineSubagentTail.js +7 -32
  294. package/dist/subagentContentStore.js +7 -18
  295. package/dist/supportFloor.d.ts +1 -0
  296. package/dist/supportFloor.js +15 -14
  297. package/dist/systemReminderTag.d.ts +1 -0
  298. package/dist/systemReminderTag.js +8 -0
  299. package/dist/terminalStatuses.d.ts +30 -0
  300. package/dist/terminalStatuses.js +67 -0
  301. package/dist/toolHistoryMismatch.d.ts +0 -3
  302. package/dist/toolHistoryMismatch.js +3 -7
  303. package/dist/toolResult.d.ts +6 -1
  304. package/dist/toolResult.js +90 -37
  305. package/dist/toolResultContent.d.ts +2 -0
  306. package/dist/toolResultContent.js +63 -0
  307. package/dist/types/engineState.d.ts +2 -1
  308. package/dist/usageAnalytics.d.ts +146 -0
  309. package/dist/usageAnalytics.js +335 -0
  310. package/dist/userInvokedSkillsCapability.d.ts +0 -2
  311. package/dist/userInvokedSkillsCapability.js +2 -9
  312. package/dist/webSearchBackendCapability.d.ts +0 -1
  313. package/dist/webSearchBackendCapability.js +3 -7
  314. package/dist/webSearchWireCaps.js +3 -11
  315. package/dist/wireErrorTriage.d.ts +2 -0
  316. package/dist/wireErrorTriage.js +34 -5
  317. package/dist/wireFailureShape.d.ts +23 -2
  318. package/dist/wireFailureShape.js +88 -43
  319. package/dist/wireRefusalCopy.js +2 -18
  320. package/dist/workflowClient.js +7 -11
  321. package/dist/workflowsJournalCapability.d.ts +0 -1
  322. package/dist/workflowsJournalCapability.js +2 -6
  323. package/dist/writeProtectionCapability.d.ts +0 -1
  324. package/dist/writeProtectionCapability.js +5 -10
  325. package/docs/INTEGRATION-CLIENTS.md +2279 -27
  326. package/package.json +5 -5
  327. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  328. package/dist/engineCapsGenerationGuard.js +0 -19
  329. package/dist/panelRunningHistory.d.ts +0 -22
  330. package/dist/panelRunningHistory.js +0 -82
  331. package/dist/registryConflict.d.ts +0 -3
  332. package/dist/registryConflict.js +0 -44
@@ -1,11 +1,41 @@
1
- function readGuarded(o, key) {
1
+ export const THROWN_SLOT_UNREADABLE = Symbol('thrown-slot-unreadable');
2
+ export function readThrownSlot(o, key, own = false) {
2
3
  try {
4
+ if (own && !Object.hasOwn(o, key))
5
+ return undefined;
3
6
  return o[key];
4
7
  }
5
8
  catch {
6
- return undefined;
9
+ return THROWN_SLOT_UNREADABLE;
10
+ }
11
+ }
12
+ function readGuarded(o, key) {
13
+ const v = readThrownSlot(o, key);
14
+ return v === THROWN_SLOT_UNREADABLE ? undefined : v;
15
+ }
16
+ export function thrownIsInstanceOf(e, cls) {
17
+ try {
18
+ return e instanceof cls;
19
+ }
20
+ catch {
21
+ return false;
7
22
  }
8
23
  }
24
+ export function readThrownExtra(o) {
25
+ if (o === null || o === undefined)
26
+ return { state: 'absent' };
27
+ const slot = readThrownSlot(o, 'extra');
28
+ if (slot === THROWN_SLOT_UNREADABLE)
29
+ return { state: 'unreadable' };
30
+ try {
31
+ if (typeof slot !== 'object' || slot === null || Array.isArray(slot))
32
+ return { state: 'absent' };
33
+ }
34
+ catch {
35
+ return { state: 'unreadable' };
36
+ }
37
+ return { state: 'object', value: slot };
38
+ }
9
39
  function readErrorSlot(obj, key, accept) {
10
40
  try {
11
41
  const o = obj;
@@ -18,15 +48,10 @@ function readErrorSlot(obj, key, accept) {
18
48
  }
19
49
  if (accept(top))
20
50
  return top;
21
- let extra;
22
- try {
23
- extra = o['extra'];
24
- }
25
- catch {
26
- extra = undefined;
27
- }
28
- if (typeof extra !== 'object' || extra === null || Array.isArray(extra))
51
+ const reading = readThrownExtra(obj);
52
+ if (reading.state !== 'object')
29
53
  return undefined;
54
+ const extra = reading.value;
30
55
  let fromExtra;
31
56
  try {
32
57
  fromExtra = Object.hasOwn(extra, key) ? extra[key] : undefined;
@@ -83,28 +108,25 @@ export function readErrorStrictStringList(o, key) {
83
108
  return undefined;
84
109
  }
85
110
  }
111
+ export const WIRE_FAILURE_UNRENDERABLE_TEXT = 'the call failed with an error this client could not render';
112
+ function userFacingReasonOf(e, ownMessage) {
113
+ if (ownMessage !== undefined)
114
+ return ownMessage;
115
+ if (typeof e === 'string')
116
+ return e !== '' ? e : WIRE_FAILURE_UNRENDERABLE_TEXT;
117
+ if (typeof e === 'number' || typeof e === 'boolean' || typeof e === 'bigint')
118
+ return String(e);
119
+ return WIRE_FAILURE_UNRENDERABLE_TEXT;
120
+ }
86
121
  export function wireFailureShapeOf(e) {
87
122
  const o = e ?? {};
88
123
  const status = readGuarded(o, 'status');
89
124
  const errorCode = readGuarded(o, 'errorCode');
90
125
  const rawMessage = readGuarded(o, 'message');
91
126
  const retryAfterMs = readGuarded(o, 'retryAfterMs');
92
- let extra;
93
- let extraUnreadable = false;
94
- try {
95
- extra = o['extra'];
96
- }
97
- catch {
98
- extraUnreadable = true;
99
- }
100
- let extraObj;
101
- try {
102
- extraObj = typeof extra === 'object' && extra !== null && !Array.isArray(extra) ? extra : undefined;
103
- }
104
- catch {
105
- extraObj = undefined;
106
- extraUnreadable = true;
107
- }
127
+ const extraReading = readThrownExtra(e);
128
+ let extraUnreadable = extraReading.state === 'unreadable';
129
+ const extraObj = extraReading.state === 'object' ? extraReading.value : undefined;
108
130
  let committedPresent = false;
109
131
  let committedRaw;
110
132
  if (extraObj !== undefined) {
@@ -141,13 +163,7 @@ export function wireFailureShapeOf(e) {
141
163
  const bodyVerdict = ownString('verdict');
142
164
  const bodyCurrentName = ownString('currentName');
143
165
  const ownMessage = typeof rawMessage === 'string' && rawMessage !== '' ? rawMessage : undefined;
144
- let message;
145
- try {
146
- message = ownMessage !== undefined ? ownMessage : String(e);
147
- }
148
- catch {
149
- message = WIRE_FAILURE_UNRENDERABLE_TEXT;
150
- }
166
+ const message = userFacingReasonOf(e, ownMessage);
151
167
  const sec = typeof retryAfterMs === 'number' && Number.isFinite(retryAfterMs) && retryAfterMs >= 0
152
168
  ? Math.ceil(retryAfterMs / 1000)
153
169
  : undefined;
@@ -168,12 +184,10 @@ export function wireFailureShapeOf(e) {
168
184
  ...(bodyVerdict !== undefined ? { bodyVerdict } : {}),
169
185
  ...(bodyCurrentName !== undefined ? { bodyCurrentName } : {}),
170
186
  message,
171
- ...(ownMessage !== undefined ? { ownMessage } : {}),
172
187
  };
173
188
  }
174
- export const WIRE_FAILURE_UNRENDERABLE_TEXT = 'the call failed with an error this client could not render';
175
189
  export function wireFailureTextsOf(e) {
176
- const { ownMessage } = wireFailureShapeOf(e);
190
+ const { message } = wireFailureShapeOf(e);
177
191
  let log;
178
192
  try {
179
193
  log = String(e).slice(0, 300);
@@ -181,11 +195,42 @@ export function wireFailureTextsOf(e) {
181
195
  catch {
182
196
  log = '<unprintable thrown value>';
183
197
  }
184
- if (ownMessage !== undefined)
185
- return { reason: ownMessage, log };
186
- if (typeof e === 'string')
187
- return { reason: e !== '' ? e : WIRE_FAILURE_UNRENDERABLE_TEXT, log };
188
- if (typeof e === 'number' || typeof e === 'boolean' || typeof e === 'bigint')
189
- return { reason: String(e), log };
190
- return { reason: WIRE_FAILURE_UNRENDERABLE_TEXT, log };
198
+ return { reason: message, log };
199
+ }
200
+ export function readBlockedBy(o) {
201
+ const judge = (v) => (typeof v === 'string' && v.length > 0 ? { kind: 'named', code: v } : { kind: 'unreadable' });
202
+ try {
203
+ const top = o['blockedBy'];
204
+ if (top !== undefined)
205
+ return judge(top);
206
+ const reading = readThrownExtra(o);
207
+ if (reading.state === 'unreadable')
208
+ return { kind: 'unreadable' };
209
+ if (reading.state === 'object' && Object.hasOwn(reading.value, 'blockedBy')) {
210
+ return judge(reading.value['blockedBy']);
211
+ }
212
+ return { kind: 'absent' };
213
+ }
214
+ catch {
215
+ return { kind: 'unreadable' };
216
+ }
217
+ }
218
+ export function readRefusalField(o) {
219
+ const str = (rec) => {
220
+ let v;
221
+ try {
222
+ v = rec.field;
223
+ }
224
+ catch {
225
+ return undefined;
226
+ }
227
+ return typeof v === 'string' && v !== '' ? v : undefined;
228
+ };
229
+ const reading = readThrownExtra(o);
230
+ if (reading.state === 'object') {
231
+ const fromExtra = str(reading.value);
232
+ if (fromExtra !== undefined)
233
+ return fromExtra;
234
+ }
235
+ return str(o);
191
236
  }
@@ -1,6 +1,6 @@
1
- import { readErrorNumber, readErrorRecord, readErrorStrictStringList, readErrorString, readErrorStringList } from './wireFailureShape.js';
1
+ import { readErrorNumber, readErrorRecord, readErrorStrictStringList, readErrorString, readErrorStringList, readRefusalField } from './wireFailureShape.js';
2
2
  import { readOwnNonEmptyString } from './ownKey.js';
3
- import { ACTIVE_RUN_BUSY_ERROR_CODE, FLEET_LEASE_UNAVAILABLE, REQUEST_AUTONOMY_LANE_REFUSED, REQUEST_FIELD_CONFLICT, RESUME_POLICY_FOLD_CODE, SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE, USAGE_WINDOW_EXHAUSTED } from './engineErrorCodes.js';
3
+ import { ACTIVE_RUN_BUSY_ERROR_CODE, FLEET_LEASE_UNAVAILABLE, REQUEST_AUTONOMY_LANE_REFUSED, REQUEST_FIELD_CONFLICT, RESUME_OUTCOME_INVALID, RESUME_POLICY_FOLD_CODE, SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE, USAGE_WINDOW_EXHAUSTED } from './engineErrorCodes.js';
4
4
  import { capForDisplay } from './fleetTaskDesc.js';
5
5
  import { effectiveWireErrorCode } from './wireErrorTriage.js';
6
6
  import { CORE_TOOL_DECLARATION_CODES } from './generated/engineFactTables.js';
@@ -184,23 +184,7 @@ export function scenarioAssignmentUnknownFromError(err) {
184
184
  const SETTLED_BY_NOT_IN_PROOF = 'settled_by_not_in_proof';
185
185
  const DECIDED_BY_NOT_IN_PROOF = 'decided_by_not_in_proof';
186
186
  const RETIRED_DECISION_KEY = 'settledBy';
187
- const RESUME_OUTCOME_INVALID = 'resume_outcome_invalid';
188
187
  const APPROVAL_NON_BINDING_FIELDS = new Set(['hostDecision', 'approver']);
189
- function readRefusalField(o) {
190
- let extra;
191
- try {
192
- extra = o.extra;
193
- }
194
- catch {
195
- extra = undefined;
196
- }
197
- if (typeof extra === 'object' && extra !== null && !Array.isArray(extra)) {
198
- const fromExtra = readStringField(extra, 'field');
199
- if (fromExtra !== undefined)
200
- return fromExtra;
201
- }
202
- return readStringField(o, 'field');
203
- }
204
188
  export function denyAttributionRefusalFromError(err, sentAttributionKey) {
205
189
  try {
206
190
  if (err === null || typeof err !== 'object')
@@ -5,7 +5,7 @@ import { makeEngineWireClient } from './engineWireSdk.js';
5
5
  import { engineWireDebugEnabled } from './engineWireTarget.js';
6
6
  import { hostLog } from './host.js';
7
7
  import { isReadCredentialRefusal } from './readCredentialRefusal.js';
8
- import { isInStreamDrainingEnd, streamDrainingDecision } from './wireErrorTriage.js';
8
+ import { createStreamDrainingLegs } from './streamDrainingLegs.js';
9
9
  function coerceRunStatus(s) {
10
10
  switch (s) {
11
11
  case 'completed':
@@ -585,11 +585,10 @@ async function consumeWorkflowActivity(l, cfg) {
585
585
  emitActivityTick(l);
586
586
  return;
587
587
  }
588
- let drainEnds = 0;
588
+ const drains = createStreamDrainingLegs();
589
589
  while (!l.closed && !l.abort.signal.aborted) {
590
590
  let sawFrame = false;
591
591
  let threw = false;
592
- let lastDrainEnd;
593
592
  try {
594
593
  const stream = client.workflows.stream(l.workflowId, {
595
594
  signal: l.abort.signal,
@@ -600,12 +599,8 @@ async function consumeWorkflowActivity(l, cfg) {
600
599
  return;
601
600
  sawFrame = true;
602
601
  l.connected = true;
603
- if (isInStreamDrainingEnd(frame)) {
604
- lastDrainEnd = frame;
602
+ if (drains.see(frame))
605
603
  continue;
606
- }
607
- lastDrainEnd = undefined;
608
- drainEnds = 0;
609
604
  try {
610
605
  foldWorkflowActivityFrame(l, frame);
611
606
  }
@@ -624,6 +619,7 @@ async function consumeWorkflowActivity(l, cfg) {
624
619
  }
625
620
  }
626
621
  l.connected = false;
622
+ const drained = drains.legEnded(threw ? 'threw' : 'returned');
627
623
  if (!sawFrame && !threw) {
628
624
  l.closed = true;
629
625
  l.closedReason = 'terminal';
@@ -642,8 +638,8 @@ async function consumeWorkflowActivity(l, cfg) {
642
638
  }
643
639
  }
644
640
  let waitMs = WORKFLOW_ACTIVITY_RECONNECT_MS;
645
- if (lastDrainEnd !== undefined) {
646
- const decision = streamDrainingDecision(lastDrainEnd, drainEnds++);
641
+ if (drained !== undefined) {
642
+ const decision = drained;
647
643
  if ('giveUp' in decision) {
648
644
  l.closed = true;
649
645
  l.closedReason = 'error';
@@ -798,8 +794,8 @@ export function createLiveWorkflowSource(config) {
798
794
  connected = false;
799
795
  unauthorized = isReadCredentialRefusal(err);
800
796
  if (err instanceof APIError) {
801
- code = err.status;
802
797
  degraded = err.status === 501 || err.status === 404;
798
+ code = degraded ? err.status : null;
803
799
  lastError = `${err.status} ${err.message}`;
804
800
  }
805
801
  else {
@@ -14,5 +14,4 @@ export declare function noteEngineCapsForWorkflowsJournal(baseUrl: string, caps:
14
14
  export declare function observedWorkflowsJournal(baseUrl?: string | undefined): WorkflowsJournalReading;
15
15
  export declare function workflowsJournalAvailable(reading: WorkflowsJournalReading): 'yes' | 'no' | 'unknown';
16
16
  export declare function workflowsJournalDoctorDetail(reading: WorkflowsJournalReading): string;
17
- export declare function forgetWorkflowsJournalReading(baseUrl: string | undefined): void;
18
17
  export declare function __resetWorkflowsJournalReadingsForTests(): void;
@@ -1,12 +1,11 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
2
  import { createEngineCapReader } from './engineCapReader.js';
3
+ import { ownDataField } from './ownKey.js';
3
4
  export function projectWorkflowsJournalCapability(caps) {
4
5
  try {
5
6
  if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
6
7
  return undefined;
7
- if (!Object.hasOwn(caps, 'workflowsJournal'))
8
- return { kind: 'not_reported' };
9
- const v = caps.workflowsJournal;
8
+ const v = ownDataField(caps, 'workflowsJournal');
10
9
  if (v === undefined)
11
10
  return { kind: 'not_reported' };
12
11
  if (typeof v !== 'boolean')
@@ -47,9 +46,6 @@ export function workflowsJournalDoctorDetail(reading) {
47
46
  return 'workflow journal on — a workflow’s execution journal can be read';
48
47
  }
49
48
  }
50
- export function forgetWorkflowsJournalReading(baseUrl) {
51
- reader.forget(baseUrl);
52
- }
53
49
  export function __resetWorkflowsJournalReadingsForTests() {
54
50
  reader.__resetForTests();
55
51
  }
@@ -28,5 +28,4 @@ export declare function noteEngineCapsForWriteProtection(baseUrl: string, caps:
28
28
  export declare function observedWriteProtection(baseUrl?: string | undefined): WriteProtectionReading;
29
29
  export declare function writeProtectionDoctorDetail(reading: WriteProtectionReading): string;
30
30
  export declare function writeProtectionPostureDetail(posture: WriteProtectionPostureView): string;
31
- export declare function forgetWriteProtectionReading(baseUrl: string | undefined): void;
32
31
  export declare function __resetWriteProtectionReadingsForTests(): void;
@@ -1,25 +1,23 @@
1
1
  import { capForDisplay } from './fleetTaskDesc.js';
2
2
  import { engineWireTarget } from './engineWireTarget.js';
3
3
  import { createEngineCapReader } from './engineCapReader.js';
4
+ import { ownDataField } from './ownKey.js';
4
5
  export function projectWriteProtectionCapability(caps) {
5
6
  try {
6
7
  if (caps === null || typeof caps !== 'object')
7
8
  return undefined;
8
9
  if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
9
10
  return undefined;
10
- if (!Object.hasOwn(caps, 'writeProtection'))
11
- return { kind: 'not_reported' };
12
- const wp = caps.writeProtection;
11
+ const wp = ownDataField(caps, 'writeProtection');
13
12
  if (wp === null)
14
13
  return { kind: 'none' };
15
14
  if (wp === undefined)
16
15
  return { kind: 'not_reported' };
17
16
  if (typeof wp !== 'object' || Array.isArray(wp))
18
17
  return undefined;
19
- const w = wp;
20
- const armed = w.armed;
21
- const replaced = w.replaced;
22
- const rows = w.rows;
18
+ const armed = ownDataField(wp, 'armed');
19
+ const replaced = ownDataField(wp, 'replaced');
20
+ const rows = ownDataField(wp, 'rows');
23
21
  if (typeof armed !== 'boolean')
24
22
  return undefined;
25
23
  if (typeof replaced !== 'boolean')
@@ -114,9 +112,6 @@ export function writeProtectionPostureDetail(posture) {
114
112
  : '';
115
113
  return `source ${source} · ${String(posture.rows.length)} ${posture.rows.length === 1 ? 'name' : 'names'}: ${shown}${more}${dropped}`;
116
114
  }
117
- export function forgetWriteProtectionReading(baseUrl) {
118
- reader.forget(baseUrl);
119
- }
120
115
  export function __resetWriteProtectionReadingsForTests() {
121
116
  reader.__resetForTests();
122
117
  }