@sema-agent/client-core 0.99.0 → 0.101.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 (374) hide show
  1. package/CHANGELOG.md +572 -0
  2. package/README.md +174 -114
  3. package/dist/adapt/arms.js +109 -50
  4. package/dist/adapt/panelTasks.d.ts +2 -1
  5. package/dist/adapt/panelTasks.js +32 -9
  6. package/dist/adapt/textStream.d.ts +1 -1
  7. package/dist/adapt/textStream.js +58 -32
  8. package/dist/adapt/toolCards.js +9 -8
  9. package/dist/adapt.js +7 -1
  10. package/dist/adapter/activeRunSelfHeal.d.ts +31 -2
  11. package/dist/adapter/activeRunSelfHeal.js +162 -13
  12. package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
  13. package/dist/adapter/downstream/eventToSdkMessage.js +157 -20
  14. package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
  15. package/dist/adapter/downstream/terminalToSdkResult.js +219 -39
  16. package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
  17. package/dist/adapter/downstream/wiringManifestView.js +1 -0
  18. package/dist/adapter/runStream.d.ts +4 -4
  19. package/dist/adapter/runStream.js +184 -42
  20. package/dist/adapter/types.d.ts +2 -0
  21. package/dist/agentsWireCaps.d.ts +9 -7
  22. package/dist/agentsWireCaps.js +101 -17
  23. package/dist/approvalDecidedByCapability.js +2 -2
  24. package/dist/approvalFrameFamilies.d.ts +33 -0
  25. package/dist/approvalFrameFamilies.js +120 -0
  26. package/dist/approvalsStreamLiveCapability.js +2 -2
  27. package/dist/attachmentsWireCaps.js +41 -13
  28. package/dist/callerCwdCapability.js +2 -2
  29. package/dist/centerWiringCapability.js +2 -2
  30. package/dist/clockReading.d.ts +2 -0
  31. package/dist/clockReading.js +4 -0
  32. package/dist/cloudConfigWireCaps.d.ts +28 -5
  33. package/dist/cloudConfigWireCaps.js +334 -103
  34. package/dist/compactionStatus.d.ts +34 -0
  35. package/dist/compactionStatus.js +196 -0
  36. package/dist/coreValuePorts.d.ts +12 -2
  37. package/dist/coreValuePorts.js +9 -0
  38. package/dist/decideFailureNote.js +8 -6
  39. package/dist/decideReceipt.js +2 -2
  40. package/dist/deviceExecutorManagementCapability.js +2 -2
  41. package/dist/deviceFlowPolling.js +1 -1
  42. package/dist/disableSkillsWire.d.ts +1 -1
  43. package/dist/disableSkillsWire.js +4 -3
  44. package/dist/displayUntrusted.d.ts +1 -0
  45. package/dist/displayUntrusted.js +215 -13
  46. package/dist/engineAgentPanelStore.d.ts +7 -4
  47. package/dist/engineCapReader.js +1 -1
  48. package/dist/engineConfigDrift.js +1 -1
  49. package/dist/engineErrorCodes.d.ts +23 -6
  50. package/dist/engineErrorCodes.js +36 -11
  51. package/dist/engineGenerationConvergence.d.ts +39 -0
  52. package/dist/engineGenerationConvergence.js +95 -0
  53. package/dist/engineGenerationPort.d.ts +61 -0
  54. package/dist/engineGenerationPort.js +144 -0
  55. package/dist/engineHealthFacts.d.ts +23 -0
  56. package/dist/engineHealthFacts.js +92 -0
  57. package/dist/engineIdentity.d.ts +4 -0
  58. package/dist/engineIdentity.js +11 -0
  59. package/dist/engineNoticeCodes.d.ts +2 -5
  60. package/dist/engineRowRef.js +4 -0
  61. package/dist/engineSessionMessages.js +2 -2
  62. package/dist/engineToolDirectory.d.ts +3 -0
  63. package/dist/engineToolDirectory.js +6 -4
  64. package/dist/engineWireFor.d.ts +99 -0
  65. package/dist/engineWireFor.js +248 -6
  66. package/dist/engineWireTarget.d.ts +1 -0
  67. package/dist/engineWireTarget.js +8 -0
  68. package/dist/env/uiLanguage.js +1 -1
  69. package/dist/errorSupplementRoles.d.ts +3 -0
  70. package/dist/errorSupplementRoles.js +37 -0
  71. package/dist/eventLeg.d.ts +1 -7
  72. package/dist/eventLeg.js +7 -8
  73. package/dist/executionLaneCapability.js +2 -2
  74. package/dist/fileHistoryCaptureCapability.d.ts +0 -3
  75. package/dist/fileHistoryCaptureCapability.js +3 -7
  76. package/dist/finalVerifyWire.d.ts +6 -3
  77. package/dist/finalVerifyWire.js +6 -23
  78. package/dist/flagInput.d.ts +4 -0
  79. package/dist/flagInput.js +24 -0
  80. package/dist/fleet/fleetLedger.js +5 -2
  81. package/dist/fleet/fleetProjection.d.ts +1 -0
  82. package/dist/fleet/fleetProjection.js +15 -2
  83. package/dist/gateVocabulary.js +3 -0
  84. package/dist/generated/engineFactTables.d.ts +7 -2
  85. package/dist/generated/engineFactTables.js +79 -0
  86. package/dist/generated/engineNoticeTables.js +15 -0
  87. package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
  88. package/dist/generated/settingsSchemaActiveTiers.js +14 -0
  89. package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
  90. package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
  91. package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
  92. package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
  93. package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
  94. package/dist/generated/settingsSchemaDefaultModel.js +25 -0
  95. package/dist/generated/settingsSchemaFns.d.ts +66 -0
  96. package/dist/generated/settingsSchemaFns.js +38 -0
  97. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
  98. package/dist/generated/settingsSchemaMcpRequestEntry.js +156 -0
  99. package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
  100. package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
  101. package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
  102. package/dist/generated/settingsSchemaSettingsSources.js +58 -0
  103. package/dist/generated/settingsSchemaTables.d.ts +3 -0
  104. package/dist/generated/settingsSchemaTables.js +18 -0
  105. package/dist/generated/settingsSchemaTypes.d.ts +28 -0
  106. package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
  107. package/dist/generated/settingsSchemaUrlPattern.js +183 -0
  108. package/dist/headlessPermissionModeWire.d.ts +18 -2
  109. package/dist/headlessPermissionModeWire.js +30 -19
  110. package/dist/hitl/allowRuleShadow.js +9 -7
  111. package/dist/hitl/approvalCardReading.d.ts +3 -0
  112. package/dist/hitl/approvalCardReading.js +17 -0
  113. package/dist/hitl/approvalCardReasons.js +2 -2
  114. package/dist/hitl/approvalCompleteParked.js +1 -1
  115. package/dist/hitl/approvalDelivery.d.ts +87 -0
  116. package/dist/hitl/approvalDelivery.js +193 -0
  117. package/dist/hitl/approvalHolds.d.ts +14 -0
  118. package/dist/hitl/approvalHolds.js +41 -0
  119. package/dist/hitl/approvalResolution.d.ts +11 -0
  120. package/dist/hitl/approvalResolution.js +50 -11
  121. package/dist/hitl/askClassPair.d.ts +8 -2
  122. package/dist/hitl/askClassPair.js +31 -4
  123. package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
  124. package/dist/hitl/askParkAutoReopenBlock.js +117 -0
  125. package/dist/hitl/askParkRowRouting.js +4 -1
  126. package/dist/hitl/attributionLadder.d.ts +62 -0
  127. package/dist/hitl/attributionLadder.js +138 -0
  128. package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
  129. package/dist/hitl/automaticAnswerVerdict.js +46 -11
  130. package/dist/hitl/crashConverged.js +2 -2
  131. package/dist/hitl/decisionConflict.d.ts +6 -2
  132. package/dist/hitl/decisionConflict.js +24 -9
  133. package/dist/hitl/decisionLedger.d.ts +55 -0
  134. package/dist/hitl/decisionLedger.js +156 -0
  135. package/dist/hitl/decisionRefusal.d.ts +21 -10
  136. package/dist/hitl/decisionRefusal.js +100 -55
  137. package/dist/hitl/decisionSend.d.ts +116 -0
  138. package/dist/hitl/decisionSend.js +563 -0
  139. package/dist/hitl/frameRouter.d.ts +1 -0
  140. package/dist/hitl/frameRouter.js +9 -2
  141. package/dist/hitl/hitlBridge.d.ts +18 -6
  142. package/dist/hitl/hitlBridge.js +59 -43
  143. package/dist/hitl/livePendingAsk.js +4 -3
  144. package/dist/hitl/noAllowCause.js +1 -1
  145. package/dist/hitl/parkResolver.js +3 -2
  146. package/dist/hitl/persistedRulesWire.js +1 -0
  147. package/dist/hitl/planReviewWire.d.ts +4 -0
  148. package/dist/hitl/planReviewWire.js +104 -106
  149. package/dist/hitl/resumeRunningCard.d.ts +3 -2
  150. package/dist/hitl/resumeRunningCard.js +17 -11
  151. package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
  152. package/dist/hitl/sessionPolicyDeliverable.js +65 -35
  153. package/dist/hitl/sessionPolicyWire.d.ts +13 -3
  154. package/dist/hitl/sessionPolicyWire.js +81 -16
  155. package/dist/hitl/standingRows.js +1 -1
  156. package/dist/hitl/toolApprovalWire.d.ts +9 -10
  157. package/dist/hitl/toolApprovalWire.js +103 -151
  158. package/dist/hookMatcherVerdict.d.ts +2 -0
  159. package/dist/hookMatcherVerdict.js +12 -0
  160. package/dist/hooksCompactTransition.d.ts +19 -0
  161. package/dist/hooksCompactTransition.js +41 -0
  162. package/dist/hooksWireCaps.d.ts +1 -1
  163. package/dist/hooksWireCaps.js +202 -203
  164. package/dist/host.d.ts +1 -14
  165. package/dist/host.js +0 -8
  166. package/dist/hostCallbackGuard.d.ts +1 -0
  167. package/dist/hostCallbackGuard.js +1 -1
  168. package/dist/hostSettingsSource.d.ts +172 -0
  169. package/dist/hostSettingsSource.js +675 -0
  170. package/dist/hostTurnSettings.d.ts +114 -19
  171. package/dist/hostTurnSettings.js +966 -68
  172. package/dist/httpHookPolicy.d.ts +37 -0
  173. package/dist/httpHookPolicy.js +176 -0
  174. package/dist/humanTurn.d.ts +4 -2
  175. package/dist/humanTurn.js +40 -10
  176. package/dist/humanTurnRead.js +4 -3
  177. package/dist/humanTurnSentences.d.ts +10 -0
  178. package/dist/humanTurnSentences.js +74 -0
  179. package/dist/i18n/messages.en.d.ts +313 -0
  180. package/dist/i18n/messages.en.js +326 -13
  181. package/dist/i18n/messages.zh.js +341 -13
  182. package/dist/i18n/translate.js +3 -3
  183. package/dist/index.d.ts +85 -15
  184. package/dist/index.js +53 -12
  185. package/dist/inheritEnvCapability.d.ts +4 -1
  186. package/dist/inheritEnvCapability.js +38 -17
  187. package/dist/inheritEnvWire.d.ts +2 -1
  188. package/dist/inheritEnvWire.js +11 -5
  189. package/dist/injectionLaneNotice.d.ts +5 -0
  190. package/dist/injectionLaneNotice.js +46 -0
  191. package/dist/interactiveToolsWire.d.ts +4 -2
  192. package/dist/interactiveToolsWire.js +5 -5
  193. package/dist/jsonFaithful.d.ts +20 -0
  194. package/dist/jsonFaithful.js +152 -0
  195. package/dist/limitsWire.d.ts +7 -2
  196. package/dist/limitsWire.js +19 -13
  197. package/dist/liveInitToolFace.d.ts +6 -1
  198. package/dist/liveInitToolFace.js +5 -3
  199. package/dist/liveModelCatalog.d.ts +22 -0
  200. package/dist/liveModelCatalog.js +132 -18
  201. package/dist/mcpPanel.js +3 -1
  202. package/dist/mcpProbeCapability.js +2 -2
  203. package/dist/mcpReconnect.js +2 -2
  204. package/dist/mcpStatusSupersetKeys.d.ts +24 -0
  205. package/dist/mcpStatusSupersetKeys.js +45 -0
  206. package/dist/mcpToolToggles.d.ts +6 -0
  207. package/dist/mcpToolToggles.js +47 -0
  208. package/dist/mcpWireCaps.d.ts +48 -4
  209. package/dist/mcpWireCaps.js +338 -99
  210. package/dist/mcpWireTransport.d.ts +4 -0
  211. package/dist/mcpWireTransport.js +18 -0
  212. package/dist/memoryComplianceCapability.js +2 -2
  213. package/dist/memoryOriginCapability.js +2 -2
  214. package/dist/model/catalogDefault.d.ts +24 -0
  215. package/dist/model/catalogDefault.js +4 -0
  216. package/dist/model/liveCatalogShape.js +5 -4
  217. package/dist/model/modelsPolicy.js +4 -3
  218. package/dist/model/onboardJudgement.d.ts +1 -0
  219. package/dist/model/onboardJudgement.js +1 -1
  220. package/dist/model/subagentModelWord.js +2 -2
  221. package/dist/modelCapabilityProbe.d.ts +2 -1
  222. package/dist/modelCapabilityProbe.js +16 -15
  223. package/dist/modelIdentityResolvability.d.ts +12 -1
  224. package/dist/modelIdentityResolvability.js +69 -28
  225. package/dist/modsKernelIdentity.d.ts +10 -0
  226. package/dist/modsKernelIdentity.js +103 -0
  227. package/dist/modsKernelTransit.d.ts +8 -0
  228. package/dist/modsKernelTransit.js +6 -0
  229. package/dist/notifications.d.ts +30 -12
  230. package/dist/notifications.js +241 -53
  231. package/dist/outputStyleSeatCapability.js +2 -2
  232. package/dist/ownKey.d.ts +37 -0
  233. package/dist/ownKey.js +238 -2
  234. package/dist/panelReduce.d.ts +5 -0
  235. package/dist/panelReduce.js +45 -13
  236. package/dist/panelStateHolder.d.ts +1 -0
  237. package/dist/panelStateHolder.js +10 -1
  238. package/dist/peerFrames.d.ts +1 -1
  239. package/dist/peerFrames.js +6 -2
  240. package/dist/peerLaneCapability.js +2 -2
  241. package/dist/permissionModesCapability.js +4 -4
  242. package/dist/permissionRuleIssue.d.ts +2 -1
  243. package/dist/permissionRuleIssue.js +24 -21
  244. package/dist/permissionRulesWriteCapability.js +2 -2
  245. package/dist/permissionsAllowGrantCapability.js +2 -2
  246. package/dist/permissionsDeclaration.d.ts +43 -4
  247. package/dist/permissionsDeclaration.js +102 -35
  248. package/dist/pluginHooksWire.d.ts +20 -4
  249. package/dist/pluginHooksWire.js +101 -60
  250. package/dist/prepareRefusal.d.ts +9 -0
  251. package/dist/prepareRefusal.js +90 -0
  252. package/dist/printInitToolFace.js +2 -2
  253. package/dist/printModelStatus.js +1 -1
  254. package/dist/projectMemory.d.ts +32 -0
  255. package/dist/projectMemory.js +70 -0
  256. package/dist/promptBlockedCopy.d.ts +2 -1
  257. package/dist/promptBlockedCopy.js +2 -1
  258. package/dist/promptDelivery.d.ts +23 -3
  259. package/dist/promptDelivery.js +169 -30
  260. package/dist/providerRejection.d.ts +19 -1
  261. package/dist/providerRejection.js +75 -4
  262. package/dist/queuedDelivery.d.ts +48 -0
  263. package/dist/queuedDelivery.js +233 -0
  264. package/dist/reattachWindow.d.ts +94 -0
  265. package/dist/reattachWindow.js +127 -0
  266. package/dist/request/printNotification.d.ts +1 -1
  267. package/dist/request/printNotification.js +5 -1
  268. package/dist/request/submissionIdentity.d.ts +37 -0
  269. package/dist/request/submissionIdentity.js +65 -0
  270. package/dist/request/taskRequest.d.ts +22 -14
  271. package/dist/request/taskRequest.js +312 -202
  272. package/dist/resultFrameKeys.d.ts +1 -0
  273. package/dist/resultFrameKeys.js +4 -1
  274. package/dist/resumeRefusalCopy.d.ts +3 -1
  275. package/dist/resumeRefusalCopy.js +22 -4
  276. package/dist/retryStatus.d.ts +26 -0
  277. package/dist/retryStatus.js +133 -28
  278. package/dist/rewindArchiveCapability.js +2 -2
  279. package/dist/rewindEngineAction.d.ts +2 -0
  280. package/dist/rewindEngineAction.js +23 -1
  281. package/dist/rowKind.d.ts +36 -0
  282. package/dist/rowKind.js +97 -0
  283. package/dist/ruleCompileVerdict.d.ts +18 -0
  284. package/dist/ruleCompileVerdict.js +67 -2
  285. package/dist/ruleReadings.d.ts +58 -0
  286. package/dist/ruleReadings.js +132 -0
  287. package/dist/ruleRefusalSentence.d.ts +8 -0
  288. package/dist/ruleRefusalSentence.js +64 -0
  289. package/dist/runCancelContext.d.ts +0 -1
  290. package/dist/runCancelContext.js +1 -2
  291. package/dist/runTerminal.d.ts +5 -0
  292. package/dist/runTerminal.js +52 -17
  293. package/dist/sandboxWire.d.ts +3 -2
  294. package/dist/sandboxWire.js +59 -27
  295. package/dist/scenarioRefusal.d.ts +2 -1
  296. package/dist/scenarioRefusal.js +6 -6
  297. package/dist/scenarioSkills.d.ts +20 -0
  298. package/dist/scenarioSkills.js +72 -0
  299. package/dist/scenarioWire.d.ts +5 -2
  300. package/dist/scenarioWire.js +9 -9
  301. package/dist/sealedKeyCapability.js +2 -2
  302. package/dist/seam.d.ts +26 -9
  303. package/dist/seam.js +44 -4
  304. package/dist/seatContract.d.ts +62 -9
  305. package/dist/seatContract.js +70 -25
  306. package/dist/selfOrchestrationDenial.js +1 -1
  307. package/dist/sessionPolicyCapability.js +2 -2
  308. package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
  309. package/dist/sessionRulesChildrenReadLive.js +5 -0
  310. package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
  311. package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
  312. package/dist/sessionSyncFileHistoryCapability.js +2 -2
  313. package/dist/settingsCredentialKeyPaths.d.ts +8 -0
  314. package/dist/settingsCredentialKeyPaths.js +274 -0
  315. package/dist/settingsHooksSalvage.d.ts +1 -0
  316. package/dist/settingsHooksSalvage.js +7 -1
  317. package/dist/settingsLayerAdmission.d.ts +4 -0
  318. package/dist/settingsLayerAdmission.js +16 -0
  319. package/dist/skillToolListsCapability.js +6 -5
  320. package/dist/skillsWireCaps.d.ts +14 -3
  321. package/dist/skillsWireCaps.js +48 -18
  322. package/dist/slashCommandGate.d.ts +24 -0
  323. package/dist/slashCommandGate.js +74 -0
  324. package/dist/slashCommandTable.d.ts +14 -0
  325. package/dist/slashCommandTable.js +99 -0
  326. package/dist/sqlEngineCapability.js +2 -2
  327. package/dist/steerPriorityCapability.js +2 -2
  328. package/dist/storePostureCapability.js +2 -2
  329. package/dist/subagent/agentStateDetail.js +1 -1
  330. package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
  331. package/dist/subagent/engineDelegatedPrompt.js +38 -7
  332. package/dist/subagent/engineRowStopGate.js +2 -2
  333. package/dist/subagent/engineSubagentResume.js +3 -3
  334. package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
  335. package/dist/subagent/engineTaskHandleWire.js +10 -0
  336. package/dist/subagentContentStore.d.ts +1 -0
  337. package/dist/subagentContentStore.js +135 -27
  338. package/dist/submitFailure.d.ts +8 -0
  339. package/dist/submitFailure.js +17 -0
  340. package/dist/supportFloor.d.ts +1 -0
  341. package/dist/supportFloor.js +7 -0
  342. package/dist/terminationIntent.d.ts +55 -0
  343. package/dist/terminationIntent.js +352 -0
  344. package/dist/toolHistoryMismatch.d.ts +8 -0
  345. package/dist/toolHistoryMismatch.js +37 -6
  346. package/dist/toolResult.d.ts +13 -3
  347. package/dist/toolResult.js +158 -9
  348. package/dist/toolResultContent.d.ts +13 -0
  349. package/dist/toolResultContent.js +82 -7
  350. package/dist/toolRoster.d.ts +18 -0
  351. package/dist/toolRoster.js +64 -0
  352. package/dist/toolsFlagNames.d.ts +8 -0
  353. package/dist/toolsFlagNames.js +110 -0
  354. package/dist/turnFailurePresentation.js +41 -96
  355. package/dist/usageLimitAutoResume.d.ts +74 -0
  356. package/dist/usageLimitAutoResume.js +227 -0
  357. package/dist/userAttachmentEnvelope.js +1 -1
  358. package/dist/userAttachmentSeat.js +5 -5
  359. package/dist/userInvokedSkillsCapability.js +2 -2
  360. package/dist/webSearchBackendCapability.js +2 -2
  361. package/dist/wireErrorTriage.js +99 -50
  362. package/dist/wireFailureShape.d.ts +25 -1
  363. package/dist/wireFailureShape.js +92 -5
  364. package/dist/wireRefusalCopy.d.ts +75 -18
  365. package/dist/wireRefusalCopy.js +532 -148
  366. package/dist/wiringFleetDoctor.d.ts +3 -0
  367. package/dist/wiringFleetDoctor.js +21 -0
  368. package/dist/workflow.d.ts +2 -1
  369. package/dist/workflow.js +38 -1
  370. package/dist/workflowClient.d.ts +2 -7
  371. package/dist/workflowsJournalCapability.js +2 -2
  372. package/dist/writeProtectionCapability.js +2 -2
  373. package/docs/INTEGRATION-CLIENTS.md +1013 -190
  374. package/package.json +15 -4
@@ -50,6 +50,7 @@ export type OnboardWriteVerdict = {
50
50
  readonly refusal: 'probe_failed' | 'probe_unverified';
51
51
  };
52
52
  export declare function onboardWriteVerdict(verdict: OnboardProbeVerdict, acceptUnverified?: boolean): OnboardWriteVerdict;
53
+ export declare const KEY_SLOT_PREFIX = "SEMA_MODEL_KEY_";
53
54
  export declare function keyEnvNameForEntry(entryName: string): string;
54
55
  export declare function poolEntryNameOf(modelId: string, channel: string, taken: ReadonlySet<string>): string;
55
56
  export interface OnboardPlanEntry {
@@ -206,7 +206,7 @@ export function onboardWriteVerdict(verdict, acceptUnverified) {
206
206
  return Object.freeze({ write: false, refusal: 'probe_failed' });
207
207
  return acceptUnverified === true ? Object.freeze({ write: true, unverified: true }) : Object.freeze({ write: false, refusal: 'probe_unverified' });
208
208
  }
209
- const KEY_SLOT_PREFIX = 'SEMA_MODEL_KEY_';
209
+ export const KEY_SLOT_PREFIX = 'SEMA_MODEL_KEY_';
210
210
  export function keyEnvNameForEntry(entryName) {
211
211
  const base = String(entryName).toUpperCase().replace(/[^A-Z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'ENTRY';
212
212
  return `${KEY_SLOT_PREFIX}${base}`;
@@ -8,7 +8,7 @@ function ownData(v, key) {
8
8
  return undefined;
9
9
  try {
10
10
  const d = Object.getOwnPropertyDescriptor(v, key);
11
- return d !== undefined && 'value' in d ? d.value : undefined;
11
+ return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
12
12
  }
13
13
  catch {
14
14
  return undefined;
@@ -74,7 +74,7 @@ function ownSlot(v, key) {
74
74
  const d = Object.getOwnPropertyDescriptor(v, key);
75
75
  if (d === undefined)
76
76
  return { kind: 'absent' };
77
- return 'value' in d ? { kind: 'value', value: d.value } : { kind: 'unreadable' };
77
+ return Object.hasOwn(d, 'value') ? { kind: 'value', value: d.value } : { kind: 'unreadable' };
78
78
  }
79
79
  catch {
80
80
  return { kind: 'unreadable' };
@@ -1,4 +1,5 @@
1
1
  import type { ModelApiWord } from './model/providerPresets.js';
2
+ import type { UiLanguage } from './env/uiLanguage.js';
2
3
  export interface OpenAICompletionsProbeBody {
3
4
  model: string;
4
5
  messages: ReadonlyArray<{
@@ -129,5 +130,5 @@ export interface ProbeVerdictFacts {
129
130
  }
130
131
  export declare function probeVerdictNotice(facts: ProbeVerdictFacts | null | undefined, ctx?: {
131
132
  readonly modelName?: string;
132
- }): ProbeVerdictNotice;
133
+ }, lang?: UiLanguage): ProbeVerdictNotice;
133
134
  export {};
@@ -1,7 +1,9 @@
1
1
  import { displayUntrusted } from './displayUntrusted.js';
2
2
  import { abortableSleep } from './abortableSleep.js';
3
+ import { causeSlotProtected, walkCauseChain } from './engineWireFor.js';
3
4
  import { readThrownSlot } from './wireFailureShape.js';
4
5
  import { guardedRead, readOwnDataValue } from './ownKey.js';
6
+ import { msg, renderMessage } from './i18n/translate.js';
5
7
  export const THINKING_FORMATS = Object.freeze([
6
8
  'openai',
7
9
  'openrouter',
@@ -466,18 +468,17 @@ function nearestFromCatalogText(text, modelId) {
466
468
  }
467
469
  function unwrapFetchCause(e) {
468
470
  const parts = [];
469
- let cur = e;
470
- for (let i = 0; i < 4 && cur !== null && typeof cur === 'object'; i++) {
471
- const code = readThrownSlot(cur, 'code');
472
- const message = readThrownSlot(cur, 'message');
471
+ walkCauseChain(e, (layer) => {
472
+ const code = readThrownSlot(layer, 'code');
473
+ const message = readThrownSlot(layer, 'message');
473
474
  const c = typeof code === 'string' && code !== '' ? code : undefined;
474
475
  const m = typeof message === 'string' && message !== '' ? message : undefined;
475
476
  if (c !== undefined)
476
477
  parts.push(m !== undefined && m !== c ? `${c} ${m}` : c);
477
478
  else if (m !== undefined)
478
479
  parts.push(m);
479
- cur = readThrownSlot(cur, 'cause');
480
- }
480
+ return undefined;
481
+ }, causeSlotProtected);
481
482
  if (parts.length === 0 && typeof e === 'string')
482
483
  parts.push(e);
483
484
  return [...new Set(parts)].join(' ← ');
@@ -698,7 +699,7 @@ function probeSeconds(ms) {
698
699
  return `${Number.isInteger(sec) ? sec : sec.toFixed(1)}s`;
699
700
  }
700
701
  const readFacts = (o, key) => guardedRead(() => readOwnDataValue(o, key));
701
- export function probeVerdictNotice(facts, ctx) {
702
+ export function probeVerdictNotice(facts, ctx, lang) {
702
703
  const rawWord = readFacts(facts, 'verdict');
703
704
  const word = typeof rawWord === 'string' && PROBE_VERDICTS.includes(rawWord) ? rawWord : 'other';
704
705
  const rawStatus = readFacts(facts, 'httpStatus');
@@ -713,31 +714,31 @@ export function probeVerdictNotice(facts, ctx) {
713
714
  let recourse;
714
715
  switch (word) {
715
716
  case 'ok':
716
- line = `The model answered${waited === undefined ? '' : ` — first token after ${probeSeconds(waited)}`}`;
717
+ line = renderMessage(waited === undefined ? msg('model.probe.verdict.ok') : msg('model.probe.verdict.okWaited', { time: probeSeconds(waited) }), lang);
717
718
  break;
718
719
  case 'auth':
719
- line = `The model service rejected the API key${http}`;
720
+ line = renderMessage(msg('model.probe.verdict.auth', { http }), lang);
720
721
  recourse = 'check_credentials';
721
722
  break;
722
723
  case 'unreachable':
723
- line = `Could not reach the model service${waited === undefined ? '' : ` — no response within ${probeSeconds(waited)}`}`;
724
+ line = renderMessage(waited === undefined ? msg('model.probe.verdict.unreachable') : msg('model.probe.verdict.unreachableWaited', { time: probeSeconds(waited) }), lang);
724
725
  break;
725
726
  case 'model':
726
- line = `The model service does not recognise this model id${http}`;
727
+ line = renderMessage(msg('model.probe.verdict.model', { http }), lang);
727
728
  break;
728
729
  case 'shape':
729
- line = `This address does not offer the expected interface${http} — check the API shape`;
730
+ line = renderMessage(msg('model.probe.verdict.shape', { http }), lang);
730
731
  break;
731
732
  case 'busy':
732
- line = `The model service is busy right now${http} — retry later or switch model`;
733
+ line = renderMessage(msg('model.probe.verdict.busy', { http }), lang);
733
734
  recourse = 'switch_model';
734
735
  break;
735
736
  case 'no_token':
736
- line = `The model service answered but sent no token${waited === undefined ? '' : ` within ${probeSeconds(waited)}`} — it may be overloaded`;
737
+ line = renderMessage(waited === undefined ? msg('model.probe.verdict.noToken') : msg('model.probe.verdict.noTokenWaited', { time: probeSeconds(waited) }), lang);
737
738
  recourse = 'switch_model';
738
739
  break;
739
740
  case 'other':
740
- line = `The model service gave an unexpected answer${http}`;
741
+ line = renderMessage(msg('model.probe.verdict.other', { http }), lang);
741
742
  break;
742
743
  }
743
744
  return Object.freeze(recourse === undefined ? { line: `${prefix}${line}` } : { line: `${prefix}${line}`, recourse });
@@ -12,11 +12,16 @@ export type ModelIdentityLanes = {
12
12
  [L in ModelIdentityLane]: ModelIdentityLaneReading;
13
13
  };
14
14
  export type EngineAnswerObservation = 'answered' | 'not_observed' | 'unreachable';
15
+ export type EngineCatalogAdoptionReading = 'absent' | 'refused' | 'undetermined';
15
16
  export interface LocalEngineModelIdentityReading {
16
17
  engine: 'local';
17
18
  lanes: ModelIdentityLanes;
18
19
  engineAnswer?: EngineAnswerObservation;
19
- engineAcceptsCatalogDefault?: boolean;
20
+ catalogAdoption?: EngineCatalogAdoptionReading;
21
+ catalogFacts?: {
22
+ readonly listed?: number;
23
+ readonly shapeRefused?: boolean;
24
+ };
20
25
  routeGap?: ModelRouteGapReading;
21
26
  }
22
27
  export type ModelRouteGapReading = 'endpoint_missing' | 'lane_credential_missing' | 'none';
@@ -28,6 +33,12 @@ export type ModelIdentityReading = LocalEngineModelIdentityReading | RemoteEngin
28
33
  export type ModelIdentityResolvability = 'resolvable' | 'not_resolvable' | 'unknown';
29
34
  export type ModelSetupDecision = 'offer_setup' | 'offer_route_setup' | 'explain_unconfigured' | 'explain_route_gap' | 'explain_route_unconfigurable' | 'proceed';
30
35
  export declare function modelIdentityResolvability(reading: ModelIdentityReading): ModelIdentityResolvability;
36
+ export interface ModelIdentityCatalogDeviation {
37
+ readonly kind: 'catalog_lane_overridden_by_facts';
38
+ readonly reported: ModelIdentityLaneReading | 'unusable';
39
+ readonly derived: 'partial' | 'absent';
40
+ }
41
+ export declare function modelIdentityCatalogDeviationOf(reading: ModelIdentityReading): ModelIdentityCatalogDeviation | undefined;
31
42
  export declare function modelRouteGapSentence(lane: ModelIdentityLane, gap: ModelRouteGapReading, lang?: UiLanguage): string | undefined;
32
43
  export declare function modelRouteGapFact(gap: ModelRouteGapReading, lang?: UiLanguage): string | undefined;
33
44
  export declare function modelIdentityDetail(reading: ModelIdentityReading): string;
@@ -1,6 +1,7 @@
1
1
  import { engineCapsLandingOf } from './engineCapsCache.js';
2
- import { engineWireTarget } from './engineWireTarget.js';
2
+ import { engineWireTargetBaseUrl } from './engineWireTarget.js';
3
3
  import { msg, renderMessage } from './i18n/translate.js';
4
+ import { guardedRead, readOwnDataValue } from './ownKey.js';
4
5
  function laneOrder() {
5
6
  return ['processEnv', 'settingsEnv', 'modelCatalogFile', 'followedSettingsFile', 'followedProviderEnv'];
6
7
  }
@@ -22,15 +23,37 @@ function laneState(lanes, lane) {
22
23
  const v = hit.v;
23
24
  return v === 'complete' || v === 'partial' || v === 'absent' || v === 'unreadable' ? v : 'unusable';
24
25
  }
25
- function catalogDefaultEvidence(catalog, accepts) {
26
+ function catalogDefaultEvidence(catalog, adoption) {
26
27
  const _evidencePin = true;
27
28
  void _evidencePin;
28
- return catalog === 'complete' && accepts === true ? { catalog, engineAccepts: accepts } : undefined;
29
+ return catalog === 'complete' && adoption !== 'refused' ? { catalog, adoption: adoption ?? 'not_reported' } : undefined;
29
30
  }
30
31
  function routeGapOf(reading) {
31
32
  const v = own(reading, 'routeGap')?.v;
32
33
  return v === 'endpoint_missing' || v === 'lane_credential_missing' || v === 'none' ? v : undefined;
33
34
  }
35
+ function catalogAdoptionOf(reading) {
36
+ const v = own(reading, 'catalogAdoption')?.v;
37
+ return v === 'absent' || v === 'refused' || v === 'undetermined' ? v : undefined;
38
+ }
39
+ const ownDataValue = (o, key) => guardedRead(() => readOwnDataValue(o, key));
40
+ function isPlainObjectSafe(v) {
41
+ try {
42
+ return isPlainObject(v);
43
+ }
44
+ catch {
45
+ return false;
46
+ }
47
+ }
48
+ function catalogFactsDerivedOf(reading) {
49
+ const facts = ownDataValue(reading, 'catalogFacts');
50
+ if (!isPlainObjectSafe(facts) || ownDataValue(facts, 'shapeRefused') !== true)
51
+ return undefined;
52
+ if (catalogAdoptionOf(reading) !== 'refused')
53
+ return undefined;
54
+ const listed = ownDataValue(facts, 'listed');
55
+ return typeof listed === 'number' && Number.isSafeInteger(listed) && listed > 0 ? 'partial' : 'absent';
56
+ }
34
57
  function analyse(reading) {
35
58
  try {
36
59
  if (!isPlainObject(reading))
@@ -47,29 +70,32 @@ function analyse(reading) {
47
70
  const lanesHit = own(reading, 'lanes')?.v;
48
71
  const order = laneOrder();
49
72
  if (!isPlainObject(lanesHit)) {
50
- return { verdict: 'unknown', why: 'lanes', unreadable: [], unreported: [...order], unusable: [], catalogUnconfirmed: null, catalogRefused: false };
73
+ return { verdict: 'unknown', why: 'lanes', unreadable: [], unreported: [...order], unusable: [], catalogRefused: false };
51
74
  }
52
75
  const partial = [];
53
76
  const unreadable = [];
54
77
  const unreported = [];
55
78
  const unusable = [];
56
79
  let catalogRefused = false;
57
- let catalogUnconfirmed = null;
58
80
  for (const lane of order) {
81
+ if (lane === 'modelCatalogFile') {
82
+ const factsDerived = catalogFactsDerivedOf(reading);
83
+ if (factsDerived !== undefined) {
84
+ if (factsDerived === 'partial') {
85
+ partial.push(lane);
86
+ catalogRefused = true;
87
+ }
88
+ continue;
89
+ }
90
+ }
59
91
  const s = laneState(lanesHit, lane);
60
92
  if (lane === 'modelCatalogFile') {
61
93
  if (s === 'complete') {
62
- const bit = own(reading, 'engineAcceptsCatalogDefault');
63
- const evidence = catalogDefaultEvidence(s, bit?.v);
94
+ const evidence = catalogDefaultEvidence(s, catalogAdoptionOf(reading));
64
95
  if (evidence !== undefined)
65
96
  return { verdict: 'resolvable', why: 'catalog_default', evidence };
66
- if (bit !== undefined && bit.v === false) {
67
- partial.push(lane);
68
- catalogRefused = true;
69
- }
70
- else {
71
- catalogUnconfirmed = bit === undefined || bit.v === undefined ? 'not_reported' : 'unusable';
72
- }
97
+ partial.push(lane);
98
+ catalogRefused = true;
73
99
  continue;
74
100
  }
75
101
  }
@@ -88,8 +114,8 @@ function analyse(reading) {
88
114
  else if (s === 'unusable')
89
115
  unusable.push(lane);
90
116
  }
91
- if (unreadable.length > 0 || unreported.length > 0 || unusable.length > 0 || catalogUnconfirmed !== null) {
92
- return { verdict: 'unknown', why: 'lanes', unreadable, unreported, unusable, catalogUnconfirmed, catalogRefused };
117
+ if (unreadable.length > 0 || unreported.length > 0 || unusable.length > 0) {
118
+ return { verdict: 'unknown', why: 'lanes', unreadable, unreported, unusable, catalogRefused };
93
119
  }
94
120
  return { verdict: 'not_resolvable', why: 'lanes', partial, catalogRefused };
95
121
  }
@@ -100,6 +126,26 @@ function analyse(reading) {
100
126
  export function modelIdentityResolvability(reading) {
101
127
  return analyse(reading).verdict;
102
128
  }
129
+ export function modelIdentityCatalogDeviationOf(reading) {
130
+ try {
131
+ if (!isPlainObject(reading) || own(reading, 'engine')?.v !== 'local')
132
+ return undefined;
133
+ const lanesHit = own(reading, 'lanes')?.v;
134
+ if (!isPlainObject(lanesHit))
135
+ return undefined;
136
+ const derived = catalogFactsDerivedOf(reading);
137
+ if (derived === undefined)
138
+ return undefined;
139
+ const reported = laneState(lanesHit, 'modelCatalogFile');
140
+ if (reported === 'not_reported')
141
+ return undefined;
142
+ const withoutFacts = reported === 'complete' ? 'partial' : reported;
143
+ return withoutFacts === derived ? undefined : Object.freeze({ kind: 'catalog_lane_overridden_by_facts', reported, derived });
144
+ }
145
+ catch {
146
+ return undefined;
147
+ }
148
+ }
103
149
  const LANE_LABEL_KEYS = Object.freeze({
104
150
  processEnv: 'model.identity.lane.processEnv',
105
151
  settingsEnv: 'model.identity.lane.settingsEnv',
@@ -152,9 +198,10 @@ export function modelIdentityDetail(reading) {
152
198
  ? `${joinPhrases(others.map(laneLabel))} ${others.length > 1 ? 'carry' : 'carries'} part of a model configuration (such as a gateway address or a credential) but no model name`
153
199
  : '';
154
200
  if (a.catalogRefused) {
155
- return (`no model name is configured for the local engine to start with — ${laneLabel('modelCatalogFile')} names a default model, but the local engine is reported not to accept a catalog default in place of a startup model name` +
156
- (partialClause !== '' ? `, and ${partialClause}` : '') +
157
- ', and the engine does not start without one');
201
+ const clause = msg('model.identity.catalogAdoption.refused', { lane: msg(LANE_LABEL_KEYS.modelCatalogFile) });
202
+ return partialClause !== ''
203
+ ? renderMessage(msg('model.identity.catalogAdoption.notResolvableWithPartial', { clause, partial: partialClause }))
204
+ : renderMessage(msg('model.identity.catalogAdoption.notResolvable', { clause }));
158
205
  }
159
206
  if (others.length > 0) {
160
207
  return `no model name is configured for the local engine — ${partialClause}, and the engine does not start without one`;
@@ -173,14 +220,8 @@ export function modelIdentityDetail(reading) {
173
220
  ...a.unreported.map((l) => `${laneLabel(l)} was not reported`),
174
221
  ...a.unusable.map((l) => `${laneLabel(l)} gave no usable reading`),
175
222
  ];
176
- if (a.catalogUnconfirmed === 'not_reported') {
177
- parts.push(`${laneLabel('modelCatalogFile')} names a default model, but whether the local engine accepts a catalog default in place of a startup model name was not reported`);
178
- }
179
- else if (a.catalogUnconfirmed === 'unusable') {
180
- parts.push(`${laneLabel('modelCatalogFile')} names a default model, but the report of whether the local engine accepts a catalog default in place of a startup model name gave no usable reading`);
181
- }
182
- else if (a.catalogRefused) {
183
- parts.push(`${laneLabel('modelCatalogFile')} names a default model, but the local engine is reported not to accept a catalog default in place of a startup model name`);
223
+ if (a.catalogRefused) {
224
+ parts.push(renderMessage(msg('model.identity.catalogAdoption.refused', { lane: msg(LANE_LABEL_KEYS.modelCatalogFile) })));
184
225
  }
185
226
  return `whether the local engine has a model name is unknown — ${joinPhrases(parts)}, and no other place this client reads provides one`;
186
227
  }
@@ -220,6 +261,6 @@ export function modelSetupNotice(decision) {
220
261
  return null;
221
262
  }
222
263
  }
223
- export function observedEngineAnswer(baseUrl = engineWireTarget()?.baseUrl) {
264
+ export function observedEngineAnswer(baseUrl = engineWireTargetBaseUrl()) {
224
265
  return engineCapsLandingOf(baseUrl).kind === 'not_landed' ? 'not_observed' : 'answered';
225
266
  }
@@ -0,0 +1,10 @@
1
+ import type { ModEventRow } from '@sema-agent/mods-kernel';
2
+ export interface ModsKernelSource {
3
+ readonly KERNEL_CONTRACT_VERSION: number;
4
+ readonly MOD_EVENT_TABLE: Readonly<Record<string, ModEventRow>>;
5
+ }
6
+ export interface ModsKernelIdentity {
7
+ readonly contractVersion: number;
8
+ readonly tableDigest: string;
9
+ }
10
+ export declare function modsKernelIdentity(kernel?: ModsKernelSource): ModsKernelIdentity;
@@ -0,0 +1,103 @@
1
+ import { KERNEL_CONTRACT_VERSION, MOD_EVENT_TABLE } from '@sema-agent/mods-kernel';
2
+ const MAX_DEPTH = 16;
3
+ const MAX_NODES = 100_000;
4
+ function canonical(v, depth, budget) {
5
+ budget.nodes += 1;
6
+ if (budget.nodes > MAX_NODES)
7
+ throw new TypeError('modsKernelIdentity: the event table is larger than a data table is');
8
+ if (depth > MAX_DEPTH)
9
+ throw new TypeError('modsKernelIdentity: the event table nests deeper than a data table does');
10
+ if (v === null || typeof v === 'string' || typeof v === 'boolean')
11
+ return JSON.stringify(v);
12
+ if (typeof v === 'number') {
13
+ if (!Number.isFinite(v))
14
+ throw new TypeError('modsKernelIdentity: the event table holds a number that is not finite');
15
+ return JSON.stringify(v);
16
+ }
17
+ if (Array.isArray(v)) {
18
+ const parts = [];
19
+ for (let i = 0; i < v.length; i++) {
20
+ if (!(i in v))
21
+ throw new TypeError('modsKernelIdentity: the event table holds an array with a hole');
22
+ parts.push(canonical(v[i], depth + 1, budget));
23
+ }
24
+ return `[${parts.join(',')}]`;
25
+ }
26
+ if (typeof v === 'object') {
27
+ const proto = Object.getPrototypeOf(v);
28
+ if (proto !== Object.prototype && proto !== null)
29
+ throw new TypeError('modsKernelIdentity: the event table holds an object that is not a plain record');
30
+ const o = v;
31
+ return `{${Object.keys(o)
32
+ .sort()
33
+ .map((k) => `${JSON.stringify(k)}:${canonical(o[k], depth + 1, budget)}`)
34
+ .join(',')}}`;
35
+ }
36
+ throw new TypeError('modsKernelIdentity: the event table holds a value that is not plain data');
37
+ }
38
+ function sha256Hex(msg) {
39
+ const k = [
40
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
41
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
42
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
43
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
44
+ ];
45
+ const h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
46
+ const len = msg.length;
47
+ const padded = new Uint8Array(((len + 8) >>> 6) * 64 + 64);
48
+ padded.set(msg);
49
+ padded[len] = 0x80;
50
+ const view = new DataView(padded.buffer);
51
+ view.setUint32(padded.length - 8, Math.floor(len / 0x20000000));
52
+ view.setUint32(padded.length - 4, (len << 3) >>> 0);
53
+ const w = new Array(64).fill(0);
54
+ const rotr = (x, n) => (x >>> n) | (x << (32 - n));
55
+ for (let off = 0; off < padded.length; off += 64) {
56
+ for (let t = 0; t < 16; t++)
57
+ w[t] = view.getUint32(off + t * 4);
58
+ for (let t = 16; t < 64; t++) {
59
+ const x = w[t - 15] ?? 0;
60
+ const y = w[t - 2] ?? 0;
61
+ const s0 = rotr(x, 7) ^ rotr(x, 18) ^ (x >>> 3);
62
+ const s1 = rotr(y, 17) ^ rotr(y, 19) ^ (y >>> 10);
63
+ w[t] = ((w[t - 16] ?? 0) + s0 + (w[t - 7] ?? 0) + s1) | 0;
64
+ }
65
+ let [a, b, c, d, e, f, g, hh] = h;
66
+ for (let t = 0; t < 64; t++) {
67
+ const t1 = (hh + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + ((e & f) ^ (~e & g)) + (k[t] ?? 0) + (w[t] ?? 0)) | 0;
68
+ const t2 = ((rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
69
+ hh = g;
70
+ g = f;
71
+ f = e;
72
+ e = (d + t1) | 0;
73
+ d = c;
74
+ c = b;
75
+ b = a;
76
+ a = (t1 + t2) | 0;
77
+ }
78
+ const next = [a, b, c, d, e, f, g, hh];
79
+ for (let i = 0; i < 8; i++)
80
+ h[i] = ((h[i] ?? 0) + (next[i] ?? 0)) | 0;
81
+ }
82
+ return h.map((x) => (x >>> 0).toString(16).padStart(8, '0')).join('');
83
+ }
84
+ export function modsKernelIdentity(kernel = { KERNEL_CONTRACT_VERSION, MOD_EVENT_TABLE }) {
85
+ try {
86
+ if (typeof kernel !== 'object' || kernel === null)
87
+ throw new TypeError('modsKernelIdentity: the source is not a kernel module');
88
+ const contractVersion = kernel.KERNEL_CONTRACT_VERSION;
89
+ const table = kernel.MOD_EVENT_TABLE;
90
+ if (typeof contractVersion !== 'number' || !Number.isFinite(contractVersion)) {
91
+ throw new TypeError('modsKernelIdentity: the source carries no readable contract number');
92
+ }
93
+ if (typeof table !== 'object' || table === null || Array.isArray(table)) {
94
+ throw new TypeError('modsKernelIdentity: the source carries no readable event table');
95
+ }
96
+ return { contractVersion, tableDigest: sha256Hex(new TextEncoder().encode(canonical(table, 0, { nodes: 0 }))) };
97
+ }
98
+ catch (e) {
99
+ if (e instanceof TypeError)
100
+ throw e;
101
+ throw new TypeError('modsKernelIdentity: the source could not be read', { cause: e });
102
+ }
103
+ }
@@ -0,0 +1,8 @@
1
+ export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAILURE_ANSWERS, MOD_ABORT_POSTURES, NEXT_TO_TABLE, SEAT_TIER_TABLE, MOD_EVENT_TABLE, nextToRefusal, expandModPattern, isModEventName, stationOn, readOnSide, } from '@sema-agent/mods-kernel';
2
+ export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, resolveModBudgetMs, } from '@sema-agent/mods-kernel';
3
+ export { MOD_FAILURE_CAUSES } from '@sema-agent/mods-kernel';
4
+ export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES } from '@sema-agent/mods-kernel';
5
+ export { admitMods } from '@sema-agent/mods-kernel';
6
+ export type { ModTier, ModRegistrationTier, ModSeat, ModEventSide, ModBusSide, ModFailureAnswer, ModAbortPosture, ModStation, ModEventRow, ModEventName, ModBudgetReading, ModFailureCause, ModEventPayload, ModAnswerCheck, ModAnswerer, ModMatcher, ModSkip, ModTraceOutcome, ModUses, ModOrigin, ModPluginFacts, ModDollarBase, ModTraceEntry, ModCaughtError, ModNext, ModHandler, ModHandlerOptions, On, ModRegistration, ModAdmissionRecord, ModSeats, ModFrame, ModBottomContext, ModMethodBottom, ModMethodSeat, ModMethodBottoms, ModDispatchOutcome, ModDispatchOptions, ModBus, ModMountedHandler, ModBusInput, } from '@sema-agent/mods-kernel';
7
+ export { modsKernelIdentity } from './modsKernelIdentity.js';
8
+ export type { ModsKernelIdentity, ModsKernelSource } from './modsKernelIdentity.js';
@@ -0,0 +1,6 @@
1
+ export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAILURE_ANSWERS, MOD_ABORT_POSTURES, NEXT_TO_TABLE, SEAT_TIER_TABLE, MOD_EVENT_TABLE, nextToRefusal, expandModPattern, isModEventName, stationOn, readOnSide, } from '@sema-agent/mods-kernel';
2
+ export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, resolveModBudgetMs, } from '@sema-agent/mods-kernel';
3
+ export { MOD_FAILURE_CAUSES } from '@sema-agent/mods-kernel';
4
+ export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES } from '@sema-agent/mods-kernel';
5
+ export { admitMods } from '@sema-agent/mods-kernel';
6
+ export { modsKernelIdentity } from './modsKernelIdentity.js';
@@ -1,4 +1,5 @@
1
1
  import type { PlanReviewOutcomeMeta } from './hitl/planReviewWire.js';
2
+ import type { SubmissionKind } from './request/submissionIdentity.js';
2
3
  export interface TaskNotificationFields {
3
4
  taskId: string;
4
5
  status: string;
@@ -15,17 +16,33 @@ export interface TaskNotificationFields {
15
16
  recentSteps?: string[];
16
17
  resumable?: boolean;
17
18
  externalSource?: string;
19
+ completionId?: string;
20
+ seq?: number;
21
+ }
22
+ export declare const CORE_TASK_NOTIFICATION_TAGS: readonly string[];
23
+ export declare function renderTaskNotificationXml(raw: TaskNotificationFields): string;
24
+ export declare function freezeTaskNotificationFields(n: TaskNotificationFields): Readonly<TaskNotificationFields>;
25
+ export interface PendingNotificationCommand {
26
+ readonly value: string;
27
+ readonly mode: 'task-notification';
28
+ readonly _sema_task_notification?: Readonly<TaskNotificationFields>;
29
+ }
30
+ export interface TaskNotificationQueueCommand {
31
+ readonly value: string;
32
+ readonly mode: 'task-notification';
33
+ readonly _sema_task_notification: Readonly<TaskNotificationFields>;
18
34
  }
19
- export declare function renderTaskNotificationXml(n: TaskNotificationFields): string;
20
- export declare function deriveNotificationResidualLines(n: Record<string, unknown>): string[];
21
- export declare function normalizeTaskNotification(n: Record<string, unknown>): TaskNotificationFields | null;
35
+ export declare function taskNotificationQueueCommand(n: TaskNotificationFields): TaskNotificationQueueCommand;
36
+ export declare function taskNotificationOf(carrier: object | null | undefined): Readonly<TaskNotificationFields> | undefined;
37
+ export declare function deriveNotificationResidualLines(raw: Record<string, unknown>): string[];
38
+ export declare function normalizeTaskNotification(raw: Record<string, unknown>): TaskNotificationFields | null;
22
39
  export declare function taskNotificationDedupKey(n: {
23
40
  taskId: string;
24
41
  status: string;
25
42
  seq?: number | string;
26
43
  taskType?: string;
27
44
  }): string;
28
- export declare function taskNotificationDedupKeyFromWire(n: Record<string, unknown>): string;
45
+ export declare function taskNotificationDedupKeyFromWire(raw: Record<string, unknown>): string;
29
46
  export interface TranscriptNotificationSeeds {
30
47
  renderedKeys: string[];
31
48
  notifiedKeys: string[];
@@ -38,16 +55,15 @@ export interface TaskNotificationXmlRead {
38
55
  readonly external: boolean;
39
56
  }
40
57
  export declare function readTaskNotificationXml(xml: string): TaskNotificationXmlRead | undefined;
58
+ export declare const TASK_NOTIFICATION_TAG = "task-notification";
41
59
  export interface QueuedCommandLike {
42
60
  mode?: unknown;
43
61
  agentId?: unknown;
44
62
  value?: unknown;
63
+ _sema_task_notification?: {} | null;
45
64
  }
46
65
  export interface NotificationQueuePort {
47
- enqueuePendingNotification(command: {
48
- value: string;
49
- mode: 'task-notification';
50
- }): void;
66
+ enqueuePendingNotification(command: PendingNotificationCommand): void;
51
67
  removeByFilter(predicate: (cmd: QueuedCommandLike) => boolean): QueuedCommandLike[];
52
68
  enqueueMetaPrompt?(command: {
53
69
  value: string;
@@ -91,6 +107,7 @@ export declare function installWorkflowStatusProbe(probe: WorkflowStatusProbe):
91
107
  type BgTaskStatusProbe = (taskId: string) => Promise<{
92
108
  terminal: boolean;
93
109
  status: string;
110
+ completionId?: string;
94
111
  } | null>;
95
112
  export declare function outstandingBgTaskPrompt(taskId: string): string | undefined;
96
113
  export declare function installBgTaskStatusProbe(probe: BgTaskStatusProbe): void;
@@ -104,21 +121,22 @@ export interface EngineWorkflowCompletion {
104
121
  status: 'completed' | 'failed';
105
122
  summary: string;
106
123
  }
107
- export declare function enqueueBgChildNotification(n: {
124
+ export declare function enqueueBgChildNotification(raw: {
108
125
  taskId: string;
109
126
  status: string;
110
127
  seq?: number;
111
128
  summary?: string;
129
+ completionId?: string;
112
130
  }): void;
113
- export declare function enqueueEngineWorkflowNotification(c: EngineWorkflowCompletion): void;
131
+ export declare function enqueueEngineWorkflowNotification(raw: EngineWorkflowCompletion): void;
114
132
  export declare function _resetEngineTaskNotificationForTest(): void;
115
133
  export declare function _tickWatchOnceForTest(nowMs?: number): Promise<void>;
116
134
  export declare function _setWatcherTimingForTest(o: {
117
135
  probeTimeoutMs?: number;
118
136
  stuckTickResetMs?: number;
119
137
  } | null): void;
120
- export declare function isTaskNotificationObjective(objective: unknown): boolean;
121
- export declare function taskNotificationDeliverySupplement(objective: unknown): string | undefined;
138
+ export declare function isTaskNotificationObjective(objective: unknown, kind?: SubmissionKind): boolean;
139
+ export declare function taskNotificationDeliverySupplement(objective: unknown, kind?: SubmissionKind, notification?: Pick<TaskNotificationFields, 'status'>): string | undefined;
122
140
  export declare function splitApiErrorSupplement(text: string): {
123
141
  main: string;
124
142
  supplement?: string;