@sema-agent/client-core 0.100.0 → 0.102.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 (358) hide show
  1. package/CHANGELOG.md +452 -0
  2. package/README.md +172 -120
  3. package/dist/adapt/arms.js +51 -16
  4. package/dist/adapt/textStream.js +7 -4
  5. package/dist/adapt/toolCards.d.ts +2 -1
  6. package/dist/adapt/toolCards.js +28 -13
  7. package/dist/adapt.d.ts +1 -1
  8. package/dist/adapt.js +8 -2
  9. package/dist/adapter/activeRunSelfHeal.d.ts +24 -2
  10. package/dist/adapter/activeRunSelfHeal.js +108 -6
  11. package/dist/adapter/downstream/eventToSdkMessage.js +38 -79
  12. package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
  13. package/dist/adapter/downstream/terminalToSdkResult.js +209 -39
  14. package/dist/adapter/downstream/wiringManifestView.d.ts +1 -0
  15. package/dist/adapter/downstream/wiringManifestView.js +138 -0
  16. package/dist/adapter/runStream.d.ts +4 -4
  17. package/dist/adapter/runStream.js +158 -43
  18. package/dist/agentsWireCaps.d.ts +2 -7
  19. package/dist/agentsWireCaps.js +1 -2
  20. package/dist/approvalDecidedByCapability.js +2 -2
  21. package/dist/approvalFrameFamilies.d.ts +33 -0
  22. package/dist/approvalFrameFamilies.js +120 -0
  23. package/dist/approvalsStreamLiveCapability.js +2 -2
  24. package/dist/attachmentsWireCaps.js +41 -13
  25. package/dist/callerCwdCapability.js +2 -2
  26. package/dist/centerWiringCapability.js +2 -2
  27. package/dist/clockReading.d.ts +2 -0
  28. package/dist/clockReading.js +4 -0
  29. package/dist/cloudConfigWireCaps.d.ts +19 -5
  30. package/dist/cloudConfigWireCaps.js +193 -56
  31. package/dist/compensations.js +1 -1
  32. package/dist/coreValuePorts.d.ts +12 -2
  33. package/dist/coreValuePorts.js +9 -0
  34. package/dist/decideFailureNote.js +5 -3
  35. package/dist/decideReceipt.js +2 -2
  36. package/dist/deviceExecutorManagementCapability.js +2 -2
  37. package/dist/deviceFlowPolling.js +1 -1
  38. package/dist/disableSkillsWire.d.ts +1 -1
  39. package/dist/disableSkillsWire.js +4 -3
  40. package/dist/displayUntrusted.d.ts +9 -4
  41. package/dist/displayUntrusted.js +834 -104
  42. package/dist/engineCapReader.js +1 -1
  43. package/dist/engineConfigDrift.js +1 -1
  44. package/dist/engineErrorCodes.d.ts +14 -5
  45. package/dist/engineErrorCodes.js +27 -6
  46. package/dist/engineGenerationConvergence.d.ts +39 -0
  47. package/dist/engineGenerationConvergence.js +95 -0
  48. package/dist/engineGenerationPort.d.ts +61 -0
  49. package/dist/engineGenerationPort.js +144 -0
  50. package/dist/engineHealthFacts.d.ts +23 -0
  51. package/dist/engineHealthFacts.js +92 -0
  52. package/dist/engineIdentity.d.ts +4 -0
  53. package/dist/engineIdentity.js +11 -0
  54. package/dist/engineNoticeCodes.d.ts +2 -5
  55. package/dist/engineRowRef.js +4 -0
  56. package/dist/engineSessionMessages.js +2 -2
  57. package/dist/engineToolDirectory.js +2 -2
  58. package/dist/engineWireFor.d.ts +99 -0
  59. package/dist/engineWireFor.js +248 -6
  60. package/dist/engineWireTarget.d.ts +1 -0
  61. package/dist/engineWireTarget.js +8 -0
  62. package/dist/env/uiLanguage.js +1 -1
  63. package/dist/errorSupplementRoles.d.ts +3 -0
  64. package/dist/errorSupplementRoles.js +37 -0
  65. package/dist/executionLaneCapability.js +2 -2
  66. package/dist/fileHistoryCaptureCapability.js +3 -3
  67. package/dist/finalVerifyWire.d.ts +6 -3
  68. package/dist/finalVerifyWire.js +6 -23
  69. package/dist/flagInput.d.ts +4 -0
  70. package/dist/flagInput.js +24 -0
  71. package/dist/fleet/fleetLedger.js +5 -2
  72. package/dist/fleet/fleetProjection.d.ts +1 -0
  73. package/dist/fleet/fleetProjection.js +16 -3
  74. package/dist/gateVocabulary.js +3 -0
  75. package/dist/generated/engineFactTables.d.ts +7 -3
  76. package/dist/generated/engineFactTables.js +52 -0
  77. package/dist/generated/engineNoticeTables.js +12 -0
  78. package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
  79. package/dist/generated/settingsSchemaActiveTiers.js +14 -0
  80. package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
  81. package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
  82. package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
  83. package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
  84. package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
  85. package/dist/generated/settingsSchemaDefaultModel.js +25 -0
  86. package/dist/generated/settingsSchemaFns.d.ts +54 -0
  87. package/dist/generated/settingsSchemaFns.js +26 -1
  88. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
  89. package/dist/generated/settingsSchemaMcpRequestEntry.js +1 -7
  90. package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
  91. package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
  92. package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
  93. package/dist/generated/settingsSchemaSettingsSources.js +58 -0
  94. package/dist/generated/settingsSchemaTables.d.ts +2 -0
  95. package/dist/generated/settingsSchemaTables.js +13 -0
  96. package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
  97. package/dist/generated/settingsSchemaUrlPattern.js +183 -0
  98. package/dist/headlessPermissionModeWire.d.ts +18 -2
  99. package/dist/headlessPermissionModeWire.js +30 -19
  100. package/dist/hitl/allowRuleShadow.js +7 -5
  101. package/dist/hitl/approvalCardReading.d.ts +3 -0
  102. package/dist/hitl/approvalCardReading.js +17 -0
  103. package/dist/hitl/approvalCompleteParked.js +1 -1
  104. package/dist/hitl/approvalDelivery.d.ts +87 -0
  105. package/dist/hitl/approvalDelivery.js +193 -0
  106. package/dist/hitl/approvalResolution.d.ts +11 -0
  107. package/dist/hitl/approvalResolution.js +50 -11
  108. package/dist/hitl/askClassPair.d.ts +6 -0
  109. package/dist/hitl/askClassPair.js +30 -3
  110. package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
  111. package/dist/hitl/askParkAutoReopenBlock.js +117 -0
  112. package/dist/hitl/askParkRowRouting.js +4 -1
  113. package/dist/hitl/attributionLadder.d.ts +42 -3
  114. package/dist/hitl/attributionLadder.js +79 -8
  115. package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
  116. package/dist/hitl/automaticAnswerVerdict.js +46 -11
  117. package/dist/hitl/crashConverged.js +2 -2
  118. package/dist/hitl/decisionConflict.d.ts +6 -2
  119. package/dist/hitl/decisionConflict.js +24 -9
  120. package/dist/hitl/decisionRefusal.d.ts +20 -10
  121. package/dist/hitl/decisionRefusal.js +99 -54
  122. package/dist/hitl/decisionSend.d.ts +3 -0
  123. package/dist/hitl/decisionSend.js +87 -103
  124. package/dist/hitl/frameRouter.d.ts +1 -0
  125. package/dist/hitl/frameRouter.js +9 -2
  126. package/dist/hitl/hitlBridge.d.ts +18 -6
  127. package/dist/hitl/hitlBridge.js +41 -37
  128. package/dist/hitl/livePendingAsk.js +4 -3
  129. package/dist/hitl/noAllowCause.js +1 -1
  130. package/dist/hitl/parkResolver.js +3 -2
  131. package/dist/hitl/persistedRulesWire.js +1 -0
  132. package/dist/hitl/planReviewWire.d.ts +4 -0
  133. package/dist/hitl/planReviewWire.js +59 -30
  134. package/dist/hitl/resumeRunningCard.d.ts +3 -2
  135. package/dist/hitl/resumeRunningCard.js +17 -11
  136. package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
  137. package/dist/hitl/sessionPolicyDeliverable.js +62 -29
  138. package/dist/hitl/sessionPolicyWire.d.ts +13 -3
  139. package/dist/hitl/sessionPolicyWire.js +81 -16
  140. package/dist/hitl/standingRows.js +1 -1
  141. package/dist/hitl/toolApprovalWire.d.ts +9 -10
  142. package/dist/hitl/toolApprovalWire.js +72 -54
  143. package/dist/hookMatcherVerdict.d.ts +2 -0
  144. package/dist/hookMatcherVerdict.js +12 -0
  145. package/dist/hooksCompactTransition.d.ts +19 -0
  146. package/dist/hooksCompactTransition.js +41 -0
  147. package/dist/hooksWireCaps.d.ts +1 -1
  148. package/dist/hooksWireCaps.js +202 -203
  149. package/dist/host.d.ts +1 -14
  150. package/dist/host.js +0 -8
  151. package/dist/hostCallbackGuard.d.ts +1 -0
  152. package/dist/hostCallbackGuard.js +1 -1
  153. package/dist/hostSettingsSource.d.ts +172 -0
  154. package/dist/hostSettingsSource.js +675 -0
  155. package/dist/hostTurnSettings.d.ts +73 -17
  156. package/dist/hostTurnSettings.js +594 -97
  157. package/dist/httpHookPolicy.d.ts +37 -0
  158. package/dist/httpHookPolicy.js +176 -0
  159. package/dist/humanTurn.d.ts +2 -1
  160. package/dist/humanTurn.js +37 -7
  161. package/dist/humanTurnRead.js +4 -3
  162. package/dist/humanTurnSentences.d.ts +10 -0
  163. package/dist/humanTurnSentences.js +74 -0
  164. package/dist/i18n/messages.en.d.ts +222 -2
  165. package/dist/i18n/messages.en.js +225 -5
  166. package/dist/i18n/messages.zh.js +237 -5
  167. package/dist/i18n/translate.js +3 -3
  168. package/dist/index.d.ts +77 -15
  169. package/dist/index.js +50 -13
  170. package/dist/inheritEnvCapability.d.ts +3 -1
  171. package/dist/inheritEnvCapability.js +31 -17
  172. package/dist/inheritEnvWire.d.ts +2 -1
  173. package/dist/inheritEnvWire.js +11 -5
  174. package/dist/interactiveHalt.d.ts +3 -1
  175. package/dist/interactiveHalt.js +2 -0
  176. package/dist/interactiveInterrupt.d.ts +2 -0
  177. package/dist/interactiveInterrupt.js +15 -0
  178. package/dist/interactiveToolsWire.d.ts +4 -2
  179. package/dist/interactiveToolsWire.js +5 -5
  180. package/dist/jsonFaithful.d.ts +20 -0
  181. package/dist/jsonFaithful.js +152 -0
  182. package/dist/limitsWire.d.ts +7 -2
  183. package/dist/limitsWire.js +19 -13
  184. package/dist/liveInitToolFace.d.ts +6 -1
  185. package/dist/liveInitToolFace.js +5 -3
  186. package/dist/liveModelCatalog.d.ts +22 -0
  187. package/dist/liveModelCatalog.js +132 -18
  188. package/dist/mcpPanel.js +1 -1
  189. package/dist/mcpProbeCapability.js +2 -2
  190. package/dist/mcpStatusSupersetKeys.d.ts +24 -0
  191. package/dist/mcpStatusSupersetKeys.js +45 -0
  192. package/dist/mcpToolToggles.js +2 -1
  193. package/dist/mcpWireCaps.d.ts +39 -1
  194. package/dist/mcpWireCaps.js +254 -50
  195. package/dist/memoryComplianceCapability.js +2 -2
  196. package/dist/memoryOriginCapability.js +2 -2
  197. package/dist/model/catalogDefault.d.ts +24 -0
  198. package/dist/model/catalogDefault.js +4 -0
  199. package/dist/model/liveCatalogShape.js +5 -4
  200. package/dist/model/modelsPolicy.js +4 -3
  201. package/dist/model/onboardJudgement.d.ts +1 -0
  202. package/dist/model/onboardJudgement.js +1 -1
  203. package/dist/model/subagentModelWord.js +2 -2
  204. package/dist/modelCapabilityProbe.js +6 -6
  205. package/dist/modelIdentityResolvability.d.ts +10 -1
  206. package/dist/modelIdentityResolvability.js +62 -39
  207. package/dist/modsFace.d.ts +8 -0
  208. package/dist/modsFace.js +59 -0
  209. package/dist/modsKernelIdentity.d.ts +10 -0
  210. package/dist/modsKernelIdentity.js +103 -0
  211. package/dist/modsKernelTransit.d.ts +8 -0
  212. package/dist/modsKernelTransit.js +6 -0
  213. package/dist/notifications.d.ts +30 -12
  214. package/dist/notifications.js +241 -53
  215. package/dist/outputStyleSeatCapability.js +2 -2
  216. package/dist/ownKey.d.ts +12 -0
  217. package/dist/ownKey.js +179 -3
  218. package/dist/panelReduce.js +1 -1
  219. package/dist/peerFrames.d.ts +1 -1
  220. package/dist/peerFrames.js +6 -2
  221. package/dist/peerLaneCapability.js +2 -2
  222. package/dist/permissionModesCapability.js +4 -4
  223. package/dist/permissionRuleIssue.js +2 -0
  224. package/dist/permissionRulesWriteCapability.js +2 -2
  225. package/dist/permissionsAllowGrantCapability.js +2 -2
  226. package/dist/permissionsDeclaration.d.ts +43 -4
  227. package/dist/permissionsDeclaration.js +102 -35
  228. package/dist/pluginHooksWire.d.ts +20 -4
  229. package/dist/pluginHooksWire.js +92 -53
  230. package/dist/prepareRefusal.d.ts +3 -2
  231. package/dist/prepareRefusal.js +27 -9
  232. package/dist/printInitToolFace.js +2 -2
  233. package/dist/printModelStatus.js +1 -1
  234. package/dist/printToolResultFrame.js +1 -1
  235. package/dist/projectMemory.d.ts +32 -0
  236. package/dist/projectMemory.js +70 -0
  237. package/dist/promptBlockedCopy.d.ts +2 -1
  238. package/dist/promptBlockedCopy.js +2 -1
  239. package/dist/promptDelivery.d.ts +23 -3
  240. package/dist/promptDelivery.js +169 -30
  241. package/dist/providerRejection.d.ts +19 -1
  242. package/dist/providerRejection.js +75 -4
  243. package/dist/queuedDelivery.d.ts +48 -0
  244. package/dist/queuedDelivery.js +233 -0
  245. package/dist/reattachWindow.d.ts +94 -0
  246. package/dist/reattachWindow.js +127 -0
  247. package/dist/request/printNotification.d.ts +1 -1
  248. package/dist/request/printNotification.js +6 -2
  249. package/dist/request/submissionIdentity.d.ts +37 -0
  250. package/dist/request/submissionIdentity.js +65 -0
  251. package/dist/request/taskRequest.d.ts +33 -4
  252. package/dist/request/taskRequest.js +341 -156
  253. package/dist/resultFrameKeys.d.ts +1 -0
  254. package/dist/resultFrameKeys.js +4 -1
  255. package/dist/retryStatus.d.ts +8 -0
  256. package/dist/retryStatus.js +57 -9
  257. package/dist/rewindArchiveCapability.js +2 -2
  258. package/dist/rewindEngineAction.d.ts +2 -0
  259. package/dist/rewindEngineAction.js +23 -1
  260. package/dist/rowKind.d.ts +36 -0
  261. package/dist/rowKind.js +97 -0
  262. package/dist/ruleCompileVerdict.d.ts +18 -0
  263. package/dist/ruleCompileVerdict.js +67 -2
  264. package/dist/ruleReadings.d.ts +58 -0
  265. package/dist/ruleReadings.js +132 -0
  266. package/dist/ruleRefusalSentence.d.ts +4 -0
  267. package/dist/ruleRefusalSentence.js +9 -3
  268. package/dist/runCancelContext.d.ts +0 -1
  269. package/dist/runCancelContext.js +1 -2
  270. package/dist/runTerminal.d.ts +5 -0
  271. package/dist/runTerminal.js +52 -17
  272. package/dist/sandboxWire.d.ts +1 -1
  273. package/dist/sandboxWire.js +4 -6
  274. package/dist/scenarioRefusal.js +1 -1
  275. package/dist/scenarioSkills.d.ts +20 -0
  276. package/dist/scenarioSkills.js +72 -0
  277. package/dist/scenarioWire.d.ts +5 -2
  278. package/dist/scenarioWire.js +9 -9
  279. package/dist/sealedKeyCapability.js +2 -2
  280. package/dist/seam.d.ts +2 -0
  281. package/dist/seam.js +3 -3
  282. package/dist/seatContract.d.ts +68 -7
  283. package/dist/seatContract.js +84 -25
  284. package/dist/selfOrchestrationDenial.js +1 -1
  285. package/dist/sessionBackground.d.ts +165 -0
  286. package/dist/sessionBackground.js +781 -0
  287. package/dist/sessionBackgroundHandoff.d.ts +54 -0
  288. package/dist/sessionBackgroundHandoff.js +321 -0
  289. package/dist/sessionMap.js +4 -1
  290. package/dist/sessionPolicyCapability.js +2 -2
  291. package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
  292. package/dist/sessionRulesChildrenReadLive.js +5 -0
  293. package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
  294. package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
  295. package/dist/sessionSyncFileHistoryCapability.js +2 -2
  296. package/dist/settingsCredentialKeyPaths.js +55 -15
  297. package/dist/settingsHooksSalvage.d.ts +1 -0
  298. package/dist/settingsHooksSalvage.js +7 -1
  299. package/dist/settingsLayerAdmission.d.ts +4 -0
  300. package/dist/settingsLayerAdmission.js +16 -0
  301. package/dist/skillToolListsCapability.js +6 -5
  302. package/dist/skillsWireCaps.d.ts +14 -0
  303. package/dist/skillsWireCaps.js +47 -16
  304. package/dist/slashCommandGate.d.ts +24 -0
  305. package/dist/slashCommandGate.js +74 -0
  306. package/dist/slashCommandTable.d.ts +14 -0
  307. package/dist/slashCommandTable.js +99 -0
  308. package/dist/sqlEngineCapability.js +2 -2
  309. package/dist/steerPriorityCapability.js +2 -2
  310. package/dist/storePostureCapability.js +2 -2
  311. package/dist/subagent/agentStateDetail.js +1 -1
  312. package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
  313. package/dist/subagent/engineDelegatedPrompt.js +38 -7
  314. package/dist/subagent/engineRowStopGate.js +2 -2
  315. package/dist/subagent/engineSubagentResume.js +3 -3
  316. package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
  317. package/dist/subagent/engineTaskHandleWire.js +10 -0
  318. package/dist/submitFailure.d.ts +8 -0
  319. package/dist/submitFailure.js +17 -0
  320. package/dist/supportFloor.d.ts +1 -0
  321. package/dist/supportFloor.js +7 -0
  322. package/dist/terminationIntent.d.ts +55 -0
  323. package/dist/terminationIntent.js +352 -0
  324. package/dist/thinkingLatch.d.ts +69 -0
  325. package/dist/thinkingLatch.js +255 -0
  326. package/dist/thinkingLatchWords.d.ts +7 -0
  327. package/dist/thinkingLatchWords.js +4 -0
  328. package/dist/toolHistoryMismatch.d.ts +8 -0
  329. package/dist/toolHistoryMismatch.js +37 -6
  330. package/dist/toolResult.d.ts +13 -3
  331. package/dist/toolResult.js +159 -32
  332. package/dist/toolResultContent.d.ts +13 -0
  333. package/dist/toolResultContent.js +82 -7
  334. package/dist/toolRoster.d.ts +18 -0
  335. package/dist/toolRoster.js +64 -0
  336. package/dist/turnFailurePresentation.js +27 -90
  337. package/dist/usageLimitAutoResume.d.ts +74 -0
  338. package/dist/usageLimitAutoResume.js +227 -0
  339. package/dist/userAttachmentEnvelope.js +1 -1
  340. package/dist/userAttachmentSeat.js +5 -5
  341. package/dist/userInvokedSkillsCapability.js +2 -2
  342. package/dist/webSearchBackendCapability.js +2 -2
  343. package/dist/wireErrorTriage.js +99 -50
  344. package/dist/wireFailureShape.d.ts +25 -1
  345. package/dist/wireFailureShape.js +92 -5
  346. package/dist/wireRefusalCopy.d.ts +24 -1
  347. package/dist/wireRefusalCopy.js +253 -32
  348. package/dist/wiringFleetDoctor.d.ts +3 -0
  349. package/dist/wiringFleetDoctor.js +21 -0
  350. package/dist/workflow.d.ts +2 -1
  351. package/dist/workflow.js +38 -1
  352. package/dist/workflowClient.d.ts +2 -7
  353. package/dist/workflowsJournalCapability.js +2 -2
  354. package/dist/writeProtectionCapability.js +2 -2
  355. package/docs/INTEGRATION-CLIENTS.md +907 -182
  356. package/package.json +14 -3
  357. package/dist/argvFlagValue.d.ts +0 -8
  358. package/dist/argvFlagValue.js +0 -37
@@ -1,3 +1,4 @@
1
+ import type { FinishReasonUnknownDetail } from '@sema-agent/sdk';
1
2
  import { CORE_TOOL_TURN_INCOMPLETE_CAUSES, CORE_USER_INPUT_UNDRAINED_CAUSES, CORE_USER_INPUT_UNDRAINED_FAMILIES } from './generated/engineNoticeTables.js';
2
3
  export type NoticeAudience = 'user' | 'operator';
3
4
  export declare const ENGINE_NOTICE_CODES: readonly string[];
@@ -202,11 +203,7 @@ export declare function readTurnInterrupted(notice: unknown): TurnInterruptedFac
202
203
  export declare function turnInterruptedNotice(facts: Pick<TurnInterruptedFactsView, 'lane'>): string | undefined;
203
204
  export type SteerCutVerdict = 'this_input' | 'other_input' | 'user_halt' | 'unattributed' | 'not_a_cut';
204
205
  export declare function steerCutVerdict(notice: unknown, messageId: string | undefined): SteerCutVerdict;
205
- export interface FinishReasonUnknownFactsView {
206
- finishReason: string;
207
- sessionId: string;
208
- runId: string;
209
- }
206
+ export type FinishReasonUnknownFactsView = FinishReasonUnknownDetail;
210
207
  export declare function readFinishReasonUnknown(notice: unknown): FinishReasonUnknownFactsView | undefined;
211
208
  export interface StreamEndIgnoredFactsView {
212
209
  statement: string;
@@ -97,6 +97,10 @@ export const TRANSCRIPT_ROW_SIDECAR_KEYS = Object.freeze([
97
97
  '_sema_api_error_code',
98
98
  '_sema_provider_condition',
99
99
  '_sema_terminal_owner',
100
+ '_sema_row_kind',
101
+ '_sema_coded_detail',
102
+ '_sema_task_notification',
103
+ '_sema_answered_by',
100
104
  ]);
101
105
  export function parkHeldCallIdOf(carrier) {
102
106
  return readFrameStringKey(carrier, 'toolCallId');
@@ -1,5 +1,5 @@
1
1
  import { isGateParkedToolEnd } from './gateOutcome.js';
2
- import { ownDataField, ownSendableField } from './ownKey.js';
2
+ import { appendOwnElement, ownDataField, ownSendableField } from './ownKey.js';
3
3
  const isObjectLike = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
4
4
  function optionalOwn(o, key) {
5
5
  try {
@@ -17,7 +17,7 @@ function itemsOf(a) {
17
17
  return undefined;
18
18
  const out = [];
19
19
  for (let i = 0; i < n; i += 1)
20
- out.push(ownDataField(a, String(i)));
20
+ appendOwnElement(out, ownDataField(a, String(i)));
21
21
  return out;
22
22
  }
23
23
  const JSON_MAX_DEPTH = 64;
@@ -1,5 +1,5 @@
1
1
  import { frozenSet } from './frozenSet.js';
2
- import { ownDataField } from './ownKey.js';
2
+ import { appendOwnElement, ownDataField } from './ownKey.js';
3
3
  import { hasCoreValuePort, mcpNamespace, mintNamespacePrefix } from './coreValuePorts.js';
4
4
  const notLanded = () => Object.freeze({ state: 'not_landed' });
5
5
  const unreadable = () => Object.freeze({ state: 'unreadable' });
@@ -21,7 +21,7 @@ function readHalf(half) {
21
21
  const name = ownDataField(row, 'name');
22
22
  if (typeof name !== 'string' || name.length === 0)
23
23
  return 'unreadable';
24
- names.push(name);
24
+ appendOwnElement(names, name);
25
25
  }
26
26
  return names;
27
27
  }
@@ -1,6 +1,7 @@
1
1
  import type { AgentClient } from '@sema-agent/sdk';
2
2
  import { type EngineWireClientConfig, type EngineWireInjection } from './engineWireSdk.js';
3
3
  import { type EngineWireTarget } from './engineWireTarget.js';
4
+ import { THROWN_SLOT_UNREADABLE, type SlotPresence } from './wireFailureShape.js';
4
5
  export declare const INJECTED_WIRE_SETTLE_MS = 60000;
5
6
  export type EngineWireTargetClientOptions = Pick<EngineWireClientConfig, 'timeoutMs' | 'maxRetries'>;
6
7
  export interface EngineWireInjected<C> {
@@ -22,6 +23,12 @@ export interface EngineWireNoTarget {
22
23
  export type EngineWireResolution<C> = EngineWireInjected<C> | EngineWireFromTarget | EngineWireInjectedUnusable | EngineWireNoTarget;
23
24
  export declare function engineWireFor<C extends object>(wire: EngineWireInjection<C> | undefined, sessionKey: string, usable: (client: object) => client is C): EngineWireResolution<C>;
24
25
  export declare function clientHasVerbs(client: object, verbs: ReadonlyArray<ReadonlyArray<string>>): boolean;
26
+ export declare function readSignalAborted(signal: AbortSignal): boolean | null;
27
+ export declare function readSignalReason(signal: AbortSignal): {
28
+ readonly reason: {} | null | undefined;
29
+ } | null;
30
+ export declare function tryListenAbortOnce(signal: AbortSignal, listener: () => void): boolean;
31
+ export declare function tryUnlistenAbort(signal: AbortSignal, listener: () => void): boolean;
25
32
  export interface LinkedAbortSignal {
26
33
  signal: AbortSignal;
27
34
  dispose: () => void;
@@ -36,6 +43,97 @@ export declare class EngineWireCancelledError extends Error {
36
43
  constructor();
37
44
  }
38
45
  export declare function connectionLostDetail(): string;
46
+ export type CauseSlotValue = {} | null | undefined;
47
+ type CauseChainEnd = 'complete' | 'depth_cap' | 'unreadable';
48
+ export declare function walkCauseChain(e: CauseSlotValue, visit: (layer: object, depth: number) => 'stop' | undefined, readCause?: (layer: object) => CauseSlotValue | typeof THROWN_SLOT_UNREADABLE, callableReach?: boolean): {
49
+ stopped: true;
50
+ } | {
51
+ stopped: false;
52
+ end: CauseChainEnd;
53
+ };
54
+ export declare const causeSlotProtected: (layer: object) => CauseSlotValue | typeof THROWN_SLOT_UNREADABLE;
55
+ export declare function causeSlotReadOf(layer: object): CauseSlotRead;
56
+ export interface CauseSlotRead {
57
+ readonly value: CauseSlotValue | typeof THROWN_SLOT_UNREADABLE;
58
+ readonly presence: SlotPresence;
59
+ }
60
+ export declare const TRANSIENT_TRANSPORT_CODES: readonly string[];
61
+ export type TransportChainReading = 'transient' | 'answered' | 'blocked' | 'none';
62
+ export interface ChainAnswer {
63
+ readonly layer: object;
64
+ readonly status: number;
65
+ }
66
+ export interface TransportChainVerdict {
67
+ readonly reading: TransportChainReading;
68
+ readonly answer?: ChainAnswer;
69
+ readonly chainEnd?: 'unreadable';
70
+ }
71
+ export declare function transportChainReading(e: CauseSlotValue, facets: 'retry' | 'code', stopOn?: (layer: object) => boolean, topStatusAlreadyRead?: boolean): TransportChainReading;
72
+ export declare function transportChainVerdict(e: CauseSlotValue, facets: 'retry' | 'code', stopOn?: (layer: object) => boolean, topStatusAlreadyRead?: boolean, noteTopCause?: (read: CauseSlotRead) => void, noteTopLocalCode?: (value: {} | null | undefined) => void): TransportChainVerdict;
73
+ export interface AnswerReading {
74
+ readonly answer: ChainAnswer | typeof THROWN_SLOT_UNREADABLE | undefined;
75
+ readonly chain: TransportChainVerdict;
76
+ readonly topCause?: CauseSlotRead;
77
+ readonly topLocalCode?: {
78
+ readonly value: CapturedLocalCode;
79
+ };
80
+ readonly topStatusSlot?: SlotPresence;
81
+ }
82
+ export declare function answerReadingOf(e: CauseSlotValue): AnswerReading;
83
+ export declare function answeringLayerOf(e: CauseSlotValue): ChainAnswer | typeof THROWN_SLOT_UNREADABLE | undefined;
84
+ export type CapturedCode = {
85
+ readonly state: 'read';
86
+ readonly wire?: string;
87
+ readonly blockedBy?: string;
88
+ } | {
89
+ readonly state: 'unreadable';
90
+ };
91
+ export type CapturedLocalCode = string | undefined | typeof THROWN_SLOT_UNREADABLE;
92
+ declare class AnswerCaptureRecord implements ChainAnswer {
93
+ protected readonly answerCaptureBrand: true;
94
+ readonly layer: object;
95
+ readonly status: number;
96
+ readonly code: CapturedCode;
97
+ readonly localCode: CapturedLocalCode;
98
+ constructor(layer: object, status: number, code: CapturedCode, localCode: CapturedLocalCode);
99
+ }
100
+ export type AnswerCapture = AnswerCaptureRecord;
101
+ export declare const CODE_UNREADABLE: CapturedCode;
102
+ export declare function captureAnswer(answer: ChainAnswer, codeSlot: {} | null | undefined): AnswerCapture;
103
+ declare class UnansweredCaptureRecord {
104
+ protected readonly unansweredCaptureBrand: true;
105
+ readonly layer: object;
106
+ readonly status: undefined;
107
+ readonly code: CapturedCode;
108
+ readonly localCode: CapturedLocalCode;
109
+ readonly statusSlot: SlotPresence;
110
+ constructor(layer: object, code: CapturedCode, localCode: CapturedLocalCode, statusSlot: SlotPresence);
111
+ }
112
+ export type UnansweredCapture = UnansweredCaptureRecord;
113
+ export declare function captureUnanswered(layer: object, codeSlot: {} | null | undefined, localCodeRead: {
114
+ readonly value: CapturedLocalCode;
115
+ } | undefined, statusSlot?: SlotPresence): UnansweredCapture;
116
+ export declare function effectiveCodeOf(code: CapturedCode): string | undefined;
117
+ export interface TriageReading {
118
+ readonly answer: AnswerCapture | typeof THROWN_SLOT_UNREADABLE | undefined;
119
+ readonly unanswered?: UnansweredCapture;
120
+ readonly topLocalCode?: TopLocalCodeReading;
121
+ readonly topCause?: TopCauseReading;
122
+ readonly transport: boolean;
123
+ readonly chainEnd?: 'unreadable';
124
+ }
125
+ export interface TopLocalCodeReading {
126
+ readonly layer: object;
127
+ readonly localCode: CapturedLocalCode;
128
+ }
129
+ export interface TopCauseReading {
130
+ readonly layer: object;
131
+ readonly read: CauseSlotRead;
132
+ }
133
+ export declare function ownReadingSlot<T extends object, K extends keyof T & string>(record: T | undefined, key: K): T[K] | undefined;
134
+ export declare function noteTriageReading(verdict: object, reading: TriageReading): void;
135
+ export declare function triageReadingOf(verdict: object): TriageReading | undefined;
136
+ export declare function attemptTimeoutOnChain(e: CauseSlotValue): boolean;
39
137
  export type EngineWireNoAnswerKind = 'deadline' | 'time-limit' | 'connection-lost' | 'cancelled';
40
138
  export declare function noAnswerKindOf(e: object | null | undefined): EngineWireNoAnswerKind | null;
41
139
  export declare function noAnswerDetailFrom(e: object | null | undefined): string | null;
@@ -64,3 +162,4 @@ export interface TransportFailureScene {
64
162
  }
65
163
  export declare function transportFailureScene(error: unknown): TransportFailureScene;
66
164
  export declare function settleInjected<T>(ms: number, signal: AbortSignal | null | undefined, run: (signal: AbortSignal) => Promise<T>): Promise<T>;
165
+ export {};
@@ -1,7 +1,8 @@
1
1
  import { settleWithinDeadline } from './abortableSleep.js';
2
2
  import { makeEngineWireClient } from './engineWireSdk.js';
3
3
  import { engineWireTargetFor } from './engineWireTarget.js';
4
- import { readThrownSlot } from './wireFailureShape.js';
4
+ import { foldedWireCodeReading, readThrownSlot, readThrownStatusSlot, slotReadOf, THROWN_SLOT_UNREADABLE } from './wireFailureShape.js';
5
+ import { guardedRead, readOwnDataValue } from './ownKey.js';
5
6
  export const INJECTED_WIRE_SETTLE_MS = 60_000;
6
7
  export function engineWireFor(wire, sessionKey, usable) {
7
8
  if (wire !== undefined) {
@@ -73,6 +74,40 @@ function quietlyRemoveAbortListener(signal, listener) {
73
74
  catch {
74
75
  }
75
76
  }
77
+ export function readSignalAborted(signal) {
78
+ try {
79
+ return signal.aborted === true;
80
+ }
81
+ catch {
82
+ return null;
83
+ }
84
+ }
85
+ export function readSignalReason(signal) {
86
+ try {
87
+ return { reason: signal.reason };
88
+ }
89
+ catch {
90
+ return null;
91
+ }
92
+ }
93
+ export function tryListenAbortOnce(signal, listener) {
94
+ try {
95
+ signal.addEventListener('abort', listener, { once: true });
96
+ return true;
97
+ }
98
+ catch {
99
+ return false;
100
+ }
101
+ }
102
+ export function tryUnlistenAbort(signal, listener) {
103
+ try {
104
+ signal.removeEventListener('abort', listener);
105
+ return true;
106
+ }
107
+ catch {
108
+ return false;
109
+ }
110
+ }
76
111
  export function linkedAbortSignal(caller, deadline) {
77
112
  const from = callerSignalOf(caller);
78
113
  if (from === undefined)
@@ -208,15 +243,38 @@ function allAttemptsFailedBeforeSend(errors) {
208
243
  return errors.every((x) => x !== null && typeof x === 'object' && isPreSendCode(x.code, x.syscall));
209
244
  }
210
245
  const CAUSE_CHAIN_MAX_LAYERS = 4;
211
- function walkCauseChain(e, visit) {
246
+ export function walkCauseChain(e, visit, readCause, callableReach = false) {
247
+ const seen = readCause === undefined ? undefined : new Set();
212
248
  let cur = e;
213
- for (let depth = 0; depth < CAUSE_CHAIN_MAX_LAYERS && cur !== null && typeof cur === 'object'; depth++) {
249
+ let depth = 0;
250
+ for (; depth < CAUSE_CHAIN_MAX_LAYERS && isChainLayer(cur, depth, callableReach); depth++) {
251
+ if (seen !== undefined) {
252
+ if (seen.has(cur))
253
+ return { stopped: false, end: 'complete' };
254
+ seen.add(cur);
255
+ }
214
256
  if (visit(cur, depth) === 'stop')
215
257
  return { stopped: true };
216
- cur = cur.cause;
258
+ cur = readCause === undefined ? cur.cause : readCause(cur);
259
+ if (cur === THROWN_SLOT_UNREADABLE)
260
+ return { stopped: false, end: 'unreadable' };
217
261
  }
218
- return { stopped: false, end: cur !== null && typeof cur === 'object' ? 'depth_cap' : 'complete' };
219
- }
262
+ return { stopped: false, end: isChainLayer(cur, depth, callableReach) && seen?.has(cur) !== true ? 'depth_cap' : 'complete' };
263
+ }
264
+ const CALLABLE_LAYER_REACH = 1;
265
+ function isChainLayer(v, depth, callableReach) {
266
+ return (typeof v === 'object' && v !== null) || (callableReach && typeof v === 'function' && depth <= CALLABLE_LAYER_REACH);
267
+ }
268
+ export const causeSlotProtected = (layer) => causeSlotReadOf(layer).value;
269
+ export function causeSlotReadOf(layer) {
270
+ const read = slotReadOf(layer, 'cause');
271
+ if (read.presence === 'unreadable')
272
+ return CAUSE_SLOT_UNREADABLE;
273
+ if (read.presence === 'present')
274
+ return Object.freeze({ value: read.value, presence: 'present' });
275
+ return readThrownSlot(layer, 'cause') === undefined ? Object.freeze({ value: undefined, presence: 'absent' }) : CAUSE_SLOT_UNREADABLE;
276
+ }
277
+ const CAUSE_SLOT_UNREADABLE = Object.freeze({ value: THROWN_SLOT_UNREADABLE, presence: 'unreadable' });
220
278
  function readLayerEvidence(layer) {
221
279
  const o = layer;
222
280
  const code = o.code;
@@ -230,6 +288,190 @@ function readLayerEvidence(layer) {
230
288
  function failedBeforeSend(e) {
231
289
  return walkCauseChain(e, (layer) => (readLayerEvidence(layer).proof !== null ? 'stop' : undefined)).stopped;
232
290
  }
291
+ export const TRANSIENT_TRANSPORT_CODES = Object.freeze([
292
+ 'ECONNREFUSED', 'ECONNRESET', 'ETIMEDOUT', 'EPIPE', 'EAI_AGAIN',
293
+ 'ENETUNREACH', 'EHOSTUNREACH', 'ECONNABORTED',
294
+ 'UND_ERR_CONNECT_TIMEOUT', 'UND_ERR_HEADERS_TIMEOUT', 'UND_ERR_BODY_TIMEOUT', 'UND_ERR_SOCKET',
295
+ ]);
296
+ function readLayerTransience(layer, facets, statusAlreadyRead = false, noteCode) {
297
+ if (!statusAlreadyRead) {
298
+ const status = readAnsweredStatus(layer);
299
+ if (typeof status === 'number')
300
+ return { t: 'answered', status };
301
+ if (status === THROWN_SLOT_UNREADABLE)
302
+ return { t: 'answered', status: undefined };
303
+ }
304
+ const callable = typeof layer === 'function';
305
+ if (facets === 'retry' && !callable) {
306
+ const name = readThrownSlot(layer, 'name');
307
+ if (name === 'TimeoutError' || name === 'AbortError')
308
+ return TRANSIENT_LAYER;
309
+ }
310
+ const code = readThrownSlot(layer, 'code', 'data');
311
+ noteCode?.(code);
312
+ if (callable)
313
+ return NONE_LAYER;
314
+ if (typeof code === 'string' && TRANSIENT_TRANSPORT_CODES.includes(code))
315
+ return TRANSIENT_LAYER;
316
+ if (facets === 'retry') {
317
+ const message = readThrownSlot(layer, 'message');
318
+ if (typeof message === 'string' && message.toLowerCase().includes('fetch failed'))
319
+ return TRANSIENT_LAYER;
320
+ }
321
+ return NONE_LAYER;
322
+ }
323
+ const TRANSIENT_LAYER = Object.freeze({ t: 'transient' });
324
+ const NONE_LAYER = Object.freeze({ t: 'none' });
325
+ export function transportChainReading(e, facets, stopOn, topStatusAlreadyRead = false) {
326
+ return transportChainVerdict(e, facets, stopOn, topStatusAlreadyRead).reading;
327
+ }
328
+ export function transportChainVerdict(e, facets, stopOn, topStatusAlreadyRead = false, noteTopCause, noteTopLocalCode) {
329
+ let reading = 'none';
330
+ let answer;
331
+ let layerIndex = 0;
332
+ let topCauseNoted = false;
333
+ const readCause = noteTopCause === undefined
334
+ ? causeSlotProtected
335
+ : (layer) => {
336
+ if (topCauseNoted || layer !== e)
337
+ return causeSlotProtected(layer);
338
+ topCauseNoted = true;
339
+ const read = causeSlotReadOf(layer);
340
+ noteTopCause(read);
341
+ return read.value;
342
+ };
343
+ const callableReach = facets === 'code';
344
+ const walked = walkCauseChain(e, (layer) => {
345
+ const isTop = layerIndex === 0;
346
+ const skipStatus = topStatusAlreadyRead && isTop;
347
+ layerIndex += 1;
348
+ if (stopOn !== undefined) {
349
+ let blocked;
350
+ try {
351
+ blocked = stopOn(layer);
352
+ }
353
+ catch {
354
+ blocked = true;
355
+ }
356
+ if (blocked) {
357
+ reading = 'blocked';
358
+ return 'stop';
359
+ }
360
+ }
361
+ const t = readLayerTransience(layer, facets, skipStatus, isTop ? noteTopLocalCode : undefined);
362
+ if (t.t === 'none')
363
+ return undefined;
364
+ reading = t.t;
365
+ if (t.t === 'answered' && t.status !== undefined)
366
+ answer = Object.freeze({ layer, status: t.status });
367
+ return 'stop';
368
+ }, readCause, callableReach);
369
+ const unreadableEnd = !walked.stopped && walked.end === 'unreadable';
370
+ return { reading, ...(answer !== undefined ? { answer } : {}), ...(unreadableEnd ? { chainEnd: 'unreadable' } : {}) };
371
+ }
372
+ function isHttpStatus(n) {
373
+ return Number.isInteger(n) && n >= 100 && n <= 599;
374
+ }
375
+ function readAnsweredStatus(o, notePresence) {
376
+ const s = readThrownStatusSlot(o, notePresence);
377
+ return typeof s === 'number' && !isHttpStatus(s) ? undefined : s;
378
+ }
379
+ const NO_CHAIN_VERDICT = Object.freeze({ reading: 'none' });
380
+ const NO_ANSWER = Object.freeze({ answer: undefined, chain: NO_CHAIN_VERDICT });
381
+ export function answerReadingOf(e) {
382
+ if (e === null || e === undefined || (typeof e !== 'object' && typeof e !== 'function'))
383
+ return NO_ANSWER;
384
+ let topStatusSlot = 'unreadable';
385
+ const status = readAnsweredStatus(e, (presence) => {
386
+ topStatusSlot = presence;
387
+ });
388
+ if (status === THROWN_SLOT_UNREADABLE)
389
+ return Object.freeze({ answer: THROWN_SLOT_UNREADABLE, chain: NO_CHAIN_VERDICT });
390
+ if (typeof status === 'number')
391
+ return Object.freeze({ answer: Object.freeze({ layer: e, status }), chain: NO_CHAIN_VERDICT });
392
+ let topCause;
393
+ let topLocalCode;
394
+ const chain = transportChainVerdict(e, 'code', undefined, true, (read) => {
395
+ topCause = read;
396
+ }, (value) => {
397
+ topLocalCode = Object.freeze({ value: localCodeOfSlot(value) });
398
+ });
399
+ const tc = {
400
+ ...(topCause !== undefined ? { topCause } : {}),
401
+ ...(topLocalCode !== undefined ? { topLocalCode } : {}),
402
+ topStatusSlot,
403
+ };
404
+ const chainAnswer = ownReadingSlot(chain, 'answer');
405
+ if (chain.reading === 'answered' && chainAnswer === undefined)
406
+ return Object.freeze({ answer: THROWN_SLOT_UNREADABLE, chain, ...tc });
407
+ return Object.freeze({ answer: chainAnswer, chain, ...tc });
408
+ }
409
+ export function answeringLayerOf(e) {
410
+ return answerReadingOf(e).answer;
411
+ }
412
+ function localCodeOfSlot(raw) {
413
+ return raw === THROWN_SLOT_UNREADABLE ? raw : typeof raw === 'string' ? raw : undefined;
414
+ }
415
+ class AnswerCaptureRecord {
416
+ layer;
417
+ status;
418
+ code;
419
+ localCode;
420
+ constructor(layer, status, code, localCode) {
421
+ this.layer = layer;
422
+ this.status = status;
423
+ this.code = code;
424
+ this.localCode = localCode;
425
+ }
426
+ }
427
+ export const CODE_UNREADABLE = Object.freeze(Object.assign(Object.create(null), { state: 'unreadable' }));
428
+ function capturedCodeOfSlot(layer, codeSlot) {
429
+ if (codeSlot === THROWN_SLOT_UNREADABLE)
430
+ return CODE_UNREADABLE;
431
+ const wire = typeof codeSlot === 'string' && codeSlot.length > 0 ? codeSlot : undefined;
432
+ const folded = foldedWireCodeReading(layer, wire);
433
+ return Object.freeze(Object.assign(Object.create(null), { state: 'read', ...(wire !== undefined ? { wire } : {}), ...(folded.folded && folded.code !== undefined ? { blockedBy: folded.code } : {}) }));
434
+ }
435
+ export function captureAnswer(answer, codeSlot) {
436
+ const captured = new AnswerCaptureRecord(answer.layer, answer.status, capturedCodeOfSlot(answer.layer, codeSlot), localCodeOfSlot(readThrownSlot(answer.layer, 'code', 'data')));
437
+ Object.freeze(captured);
438
+ return captured;
439
+ }
440
+ class UnansweredCaptureRecord {
441
+ layer;
442
+ status;
443
+ code;
444
+ localCode;
445
+ statusSlot;
446
+ constructor(layer, code, localCode, statusSlot) {
447
+ this.layer = layer;
448
+ this.status = undefined;
449
+ this.code = code;
450
+ this.localCode = localCode;
451
+ this.statusSlot = statusSlot;
452
+ }
453
+ }
454
+ export function captureUnanswered(layer, codeSlot, localCodeRead, statusSlot) {
455
+ const captured = new UnansweredCaptureRecord(layer, capturedCodeOfSlot(layer, codeSlot), localCodeRead !== undefined ? localCodeRead.value : THROWN_SLOT_UNREADABLE, statusSlot ?? 'unreadable');
456
+ Object.freeze(captured);
457
+ return captured;
458
+ }
459
+ export function effectiveCodeOf(code) {
460
+ return code.state === 'read' ? (code.blockedBy ?? code.wire) : undefined;
461
+ }
462
+ const TRIAGE_READINGS = new WeakMap();
463
+ export function ownReadingSlot(record, key) {
464
+ return record === undefined ? undefined : guardedRead(() => readOwnDataValue(record, key));
465
+ }
466
+ export function noteTriageReading(verdict, reading) {
467
+ TRIAGE_READINGS.set(verdict, Object.freeze({ ...reading }));
468
+ }
469
+ export function triageReadingOf(verdict) {
470
+ return TRIAGE_READINGS.get(verdict);
471
+ }
472
+ export function attemptTimeoutOnChain(e) {
473
+ return walkCauseChain(e, (layer) => (readThrownSlot(layer, 'name') === 'TimeoutError' ? 'stop' : undefined), causeSlotProtected).stopped;
474
+ }
233
475
  export function noAnswerKindOf(e) {
234
476
  return noAnswerKindWith(e, () => failedBeforeSend(e));
235
477
  }
@@ -7,4 +7,5 @@ export declare function installEngineWireTarget(t: EngineWireTarget | null): ()
7
7
  export declare function installEngineWireTargetFor(sessionKey: string, t: EngineWireTarget | null): () => void;
8
8
  export declare function engineWireTarget(): EngineWireTarget | null;
9
9
  export declare function engineWireTargetFor(sessionKey: string): EngineWireTarget | null;
10
+ export declare function engineWireTargetBaseUrl(sessionKey?: string): string | undefined;
10
11
  export declare function engineWireDebugEnabled(): boolean;
@@ -35,6 +35,14 @@ export function engineWireTargetFor(sessionKey) {
35
35
  ...(envPrincipal !== undefined ? { principal: envPrincipal } : {}),
36
36
  };
37
37
  }
38
+ export function engineWireTargetBaseUrl(sessionKey = DEFAULT_SESSION_KEY) {
39
+ try {
40
+ return engineWireTargetFor(sessionKey)?.baseUrl;
41
+ }
42
+ catch {
43
+ return undefined;
44
+ }
45
+ }
38
46
  export function engineWireDebugEnabled() {
39
47
  return Boolean(hostEnv().SEMA_DEBUG);
40
48
  }
@@ -17,7 +17,7 @@ function ownDataOf(v, key) {
17
17
  return undefined;
18
18
  try {
19
19
  const d = Object.getOwnPropertyDescriptor(v, key);
20
- return d !== undefined && 'value' in d ? d.value : undefined;
20
+ return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
21
21
  }
22
22
  catch {
23
23
  return undefined;
@@ -0,0 +1,3 @@
1
+ export type ErrorSupplementRole = 'replacement' | 'supplement';
2
+ export type ErrorSupplementReader = (...args: never[]) => string;
3
+ export declare function errorSupplementRoleOf(reader: ErrorSupplementReader): ErrorSupplementRole;
@@ -0,0 +1,37 @@
1
+ import { corruptSessionContent } from './corruptSessionCopy.js';
2
+ import { corruptStoredRowContent } from './wireErrorTriage.js';
3
+ import { resumeRefusalContent, resumeContextUnavailableContent, requireExistingSessionRefusalContent, checkpointUnsupportedVersionContent, } from './resumeRefusalCopy.js';
4
+ import { resumeReopenContent } from './hitl/suspendedReopen.js';
5
+ import { idempotencyPayloadMismatchContent } from './engineErrorCodes.js';
6
+ import { inheritEnvRefusalContent } from './inheritEnvWire.js';
7
+ import { usageWindowExhaustedContent, fleetLeaseUnavailableContent, settingsPermissionBucketRefusalContent, fieldLimitRefusalContent, autonomyLaneRefusalContent, userAttachmentRefusalContent, userInvokedSkillRefusalContent, unsupportedRuleRefusalContent, admissionWallRefusalContent, hostPostureRefusalContent, toolDeclarationRefusalContent, } from './wireRefusalCopy.js';
8
+ const ROLE_BY_READER = new Map([
9
+ [corruptSessionContent, 'replacement'],
10
+ [corruptStoredRowContent, 'replacement'],
11
+ [resumeRefusalContent, 'replacement'],
12
+ [resumeContextUnavailableContent, 'replacement'],
13
+ [requireExistingSessionRefusalContent, 'replacement'],
14
+ [checkpointUnsupportedVersionContent, 'replacement'],
15
+ [resumeReopenContent, 'replacement'],
16
+ [usageWindowExhaustedContent, 'replacement'],
17
+ [fleetLeaseUnavailableContent, 'replacement'],
18
+ [settingsPermissionBucketRefusalContent, 'replacement'],
19
+ [fieldLimitRefusalContent, 'replacement'],
20
+ [autonomyLaneRefusalContent, 'replacement'],
21
+ [idempotencyPayloadMismatchContent, 'replacement'],
22
+ [userAttachmentRefusalContent, 'replacement'],
23
+ [userInvokedSkillRefusalContent, 'replacement'],
24
+ [unsupportedRuleRefusalContent, 'replacement'],
25
+ [admissionWallRefusalContent, 'supplement'],
26
+ [hostPostureRefusalContent, 'supplement'],
27
+ [toolDeclarationRefusalContent, 'supplement'],
28
+ [inheritEnvRefusalContent, 'supplement'],
29
+ ]);
30
+ export function errorSupplementRoleOf(reader) {
31
+ try {
32
+ return ROLE_BY_READER.get(reader) ?? 'supplement';
33
+ }
34
+ catch {
35
+ return 'supplement';
36
+ }
37
+ }
@@ -1,5 +1,5 @@
1
1
  import { capForDisplay } from './fleetTaskDesc.js';
2
- import { engineWireTarget } from './engineWireTarget.js';
2
+ import { engineWireTargetBaseUrl } from './engineWireTarget.js';
3
3
  import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
4
4
  import { ownDataField } from './ownKey.js';
5
5
  export function projectExecutionLaneCapability(caps) {
@@ -49,7 +49,7 @@ const reader = createEngineCapReader({
49
49
  name: 'executionLane',
50
50
  project: projectExecutionLaneCapability,
51
51
  });
52
- export function observedExecutionLane(baseUrl = engineWireTarget()?.baseUrl) {
52
+ export function observedExecutionLane(baseUrl = engineWireTargetBaseUrl()) {
53
53
  return reader.observed(baseUrl);
54
54
  }
55
55
  export function toolsRunHereFromExecutionLane(reading) {
@@ -1,6 +1,6 @@
1
1
  import { msg, renderMessage } from './i18n/translate.js';
2
2
  import { capForDisplay } from './fleetTaskDesc.js';
3
- import { engineWireTarget } from './engineWireTarget.js';
3
+ import { engineWireTargetBaseUrl } from './engineWireTarget.js';
4
4
  import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
5
5
  import { refreshEngineCapsOnce } from './engineCapsCache.js';
6
6
  import { ownDataField } from './ownKey.js';
@@ -23,7 +23,7 @@ const reader = createEngineCapReader({
23
23
  name: 'fileHistoryCapture',
24
24
  project: projectFileHistoryCaptureCapability,
25
25
  });
26
- export function observedFileHistoryCapture(baseUrl = engineWireTarget()?.baseUrl) {
26
+ export function observedFileHistoryCapture(baseUrl = engineWireTargetBaseUrl()) {
27
27
  return reader.observed(baseUrl);
28
28
  }
29
29
  export function fileHistoryCaptureMode(reading) {
@@ -118,7 +118,7 @@ export async function judgeFileHistoryTighten(captureOffByUser, opts) {
118
118
  withinMs = 0;
119
119
  }
120
120
  }
121
- const baseUrl = explicitBase ?? engineWireTarget()?.baseUrl;
121
+ const baseUrl = explicitBase ?? engineWireTargetBaseUrl();
122
122
  const first = observedFileHistoryCapture(baseUrl);
123
123
  const v1 = fileHistoryTightenVerdict(first, captureOffByUser);
124
124
  if (v1 !== 'unjudged')
@@ -2,11 +2,14 @@ import type { SemaSettings } from '@sema-agent/sdk';
2
2
  import { type EnvLike } from './hostEnv.js';
3
3
  export type WireHooksConfig = NonNullable<SemaSettings['hooks']>;
4
4
  export declare const HEADLESS_FINAL_VERIFY_ENV = "SEMA_HEADLESS_FINAL_VERIFY";
5
- export declare function parseNoFinalVerifyArgv(argv: string[]): boolean;
5
+ export interface HeadlessFinalVerifyFlags {
6
+ readonly noFinalVerify?: boolean;
7
+ readonly finalVerify?: boolean;
8
+ }
6
9
  export declare function headlessFinalVerifyDisabledByEnv(env?: EnvLike): boolean;
7
10
  export declare function hasUserStopHook(wireHooks: WireHooksConfig | undefined): boolean;
8
- export declare function resolveHeadlessFinalVerify(argv: string[], env?: EnvLike, wireHooks?: WireHooksConfig): boolean;
9
- export declare function resolveHeadlessFinalVerifyDetail(argv: string[], env?: EnvLike, wireHooks?: WireHooksConfig): {
11
+ export declare function resolveHeadlessFinalVerify(flags: HeadlessFinalVerifyFlags | undefined, env?: EnvLike, wireHooks?: WireHooksConfig): boolean;
12
+ export declare function resolveHeadlessFinalVerifyDetail(flags: HeadlessFinalVerifyFlags | undefined, env?: EnvLike, wireHooks?: WireHooksConfig): {
10
13
  on: boolean;
11
14
  offReason?: 'flag' | 'env' | 'stop-hook';
12
15
  };
@@ -1,24 +1,7 @@
1
1
  import { hostEnv } from './hostEnv.js';
2
2
  import { envFlagOff, envFlagOn } from './envFlag.js';
3
+ import { flagTrue } from './flagInput.js';
3
4
  export const HEADLESS_FINAL_VERIFY_ENV = 'SEMA_HEADLESS_FINAL_VERIFY';
4
- export function parseNoFinalVerifyArgv(argv) {
5
- for (const a of argv) {
6
- if (a === '--')
7
- break;
8
- if (a === '--no-final-verify')
9
- return true;
10
- }
11
- return false;
12
- }
13
- function parseFinalVerifyArgv(argv) {
14
- for (const a of argv) {
15
- if (a === '--')
16
- break;
17
- if (a === '--final-verify')
18
- return true;
19
- }
20
- return false;
21
- }
22
5
  export function headlessFinalVerifyDisabledByEnv(env = hostEnv()) {
23
6
  return envFlagOff(env[HEADLESS_FINAL_VERIFY_ENV]);
24
7
  }
@@ -26,15 +9,15 @@ export function hasUserStopHook(wireHooks) {
26
9
  const groups = wireHooks?.['Stop'];
27
10
  return Array.isArray(groups) && groups.length > 0;
28
11
  }
29
- export function resolveHeadlessFinalVerify(argv, env = hostEnv(), wireHooks) {
30
- return resolveHeadlessFinalVerifyDetail(argv, env, wireHooks).on;
12
+ export function resolveHeadlessFinalVerify(flags, env = hostEnv(), wireHooks) {
13
+ return resolveHeadlessFinalVerifyDetail(flags, env, wireHooks).on;
31
14
  }
32
- export function resolveHeadlessFinalVerifyDetail(argv, env = hostEnv(), wireHooks) {
33
- if (parseNoFinalVerifyArgv(argv))
15
+ export function resolveHeadlessFinalVerifyDetail(flags, env = hostEnv(), wireHooks) {
16
+ if (flagTrue(flags, 'noFinalVerify'))
34
17
  return { on: false, offReason: 'flag' };
35
18
  if (headlessFinalVerifyDisabledByEnv(env))
36
19
  return { on: false, offReason: 'env' };
37
- const explicitOn = parseFinalVerifyArgv(argv) || envFlagOn(env[HEADLESS_FINAL_VERIFY_ENV]);
20
+ const explicitOn = flagTrue(flags, 'finalVerify') || envFlagOn(env[HEADLESS_FINAL_VERIFY_ENV]);
38
21
  if (explicitOn) {
39
22
  if (hasUserStopHook(wireHooks))
40
23
  return { on: false, offReason: 'stop-hook' };
@@ -0,0 +1,4 @@
1
+ export declare function flagObject(flags: object | null | undefined, key: string): object | undefined;
2
+ export declare function flagIsWronglyTyped(flags: object | null | undefined, key: string): boolean;
3
+ export declare function flagString(flags: object | null | undefined, key: string): string | undefined;
4
+ export declare function flagTrue(flags: object | null | undefined, key: string): boolean;