@sema-agent/client-core 0.97.1 → 0.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/CHANGELOG.md +607 -0
  2. package/README.md +96 -46
  3. package/dist/adapt/arms.d.ts +1 -0
  4. package/dist/adapt/arms.js +188 -53
  5. package/dist/adapt/ids.d.ts +12 -1
  6. package/dist/adapt/ids.js +59 -8
  7. package/dist/adapt/instanceLedger.d.ts +50 -0
  8. package/dist/adapt/instanceLedger.js +147 -0
  9. package/dist/adapt/panelTasks.d.ts +1 -1
  10. package/dist/adapt/panelTasks.js +2 -2
  11. package/dist/adapt/textStream.d.ts +1 -0
  12. package/dist/adapt/textStream.js +24 -7
  13. package/dist/adapt/toolCards.d.ts +27 -5
  14. package/dist/adapt/toolCards.js +39 -6
  15. package/dist/adapt/wireShapes.js +6 -2
  16. package/dist/adapt.d.ts +2 -0
  17. package/dist/adapt.js +8 -3
  18. package/dist/adapter/activeRunSelfHeal.d.ts +9 -3
  19. package/dist/adapter/activeRunSelfHeal.js +205 -313
  20. package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
  21. package/dist/adapter/downstream/eventToSdkMessage.js +77 -36
  22. package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
  23. package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
  24. package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
  25. package/dist/adapter/runStream.js +79 -48
  26. package/dist/adapter/types.d.ts +4 -4
  27. package/dist/adapter/types.js +2 -1
  28. package/dist/agentSession/backgroundView.js +2 -1
  29. package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
  30. package/dist/agentSession/engineAgentRegistryRead.js +12 -13
  31. package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
  32. package/dist/agentsWireCaps.d.ts +8 -11
  33. package/dist/agentsWireCaps.js +196 -194
  34. package/dist/approvalDecidedByCapability.d.ts +0 -4
  35. package/dist/approvalDecidedByCapability.js +0 -6
  36. package/dist/approvalsStreamLiveCapability.d.ts +0 -4
  37. package/dist/approvalsStreamLiveCapability.js +0 -6
  38. package/dist/assistantInbox.d.ts +34 -0
  39. package/dist/assistantInbox.js +118 -0
  40. package/dist/centerWiringCapability.js +9 -1
  41. package/dist/clientSlice.d.ts +0 -9
  42. package/dist/clientSlice.js +0 -3
  43. package/dist/cloudConfigWireCaps.d.ts +5 -3
  44. package/dist/cloudConfigWireCaps.js +106 -64
  45. package/dist/compensations.js +1 -1
  46. package/dist/connectorStatus.d.ts +21 -0
  47. package/dist/connectorStatus.js +112 -0
  48. package/dist/controlRouter.d.ts +18 -3
  49. package/dist/controlRouter.js +106 -67
  50. package/dist/coreValuePorts.d.ts +29 -4
  51. package/dist/coreValuePorts.js +10 -0
  52. package/dist/corruptSessionCopy.d.ts +2 -1
  53. package/dist/corruptSessionCopy.js +3 -3
  54. package/dist/decideReceipt.d.ts +2 -2
  55. package/dist/decideReceipt.js +5 -2
  56. package/dist/declared/supportFloorDeclared.js +3 -3
  57. package/dist/detachWire.js +3 -2
  58. package/dist/deviceExecutorManagementCapability.d.ts +0 -4
  59. package/dist/deviceExecutorManagementCapability.js +0 -6
  60. package/dist/deviceRebind.d.ts +49 -1
  61. package/dist/deviceRebind.js +221 -3
  62. package/dist/devicesFace.d.ts +34 -0
  63. package/dist/devicesFace.js +90 -0
  64. package/dist/displayUntrusted.d.ts +2 -0
  65. package/dist/displayUntrusted.js +253 -76
  66. package/dist/engineAgentAbsence.d.ts +1 -1
  67. package/dist/engineAgentPanelStore.d.ts +12 -4
  68. package/dist/engineAgentPanelStore.js +16 -11
  69. package/dist/engineCapReader.d.ts +2 -5
  70. package/dist/engineCapReader.js +8 -10
  71. package/dist/engineCapsCache.d.ts +12 -0
  72. package/dist/engineCapsCache.js +76 -18
  73. package/dist/engineCapsChange.d.ts +2 -0
  74. package/dist/engineCapsChange.js +9 -0
  75. package/dist/engineClosedSets.d.ts +1 -0
  76. package/dist/engineClosedSets.js +4 -1
  77. package/dist/engineErrorCodes.d.ts +11 -3
  78. package/dist/engineErrorCodes.js +11 -8
  79. package/dist/engineIdentity.d.ts +1 -0
  80. package/dist/engineIdentity.js +8 -0
  81. package/dist/engineRowRef.d.ts +28 -0
  82. package/dist/engineRowRef.js +114 -0
  83. package/dist/engineSessionMessages.d.ts +68 -0
  84. package/dist/engineSessionMessages.js +370 -0
  85. package/dist/engineTargetSeat.d.ts +27 -0
  86. package/dist/engineTargetSeat.js +199 -0
  87. package/dist/engineToolDirectory.d.ts +0 -9
  88. package/dist/engineToolDirectory.js +1 -94
  89. package/dist/engineUrl.d.ts +18 -0
  90. package/dist/engineUrl.js +52 -0
  91. package/dist/engineWireFor.js +3 -8
  92. package/dist/env/uiLanguage.d.ts +11 -1
  93. package/dist/env/uiLanguage.js +38 -2
  94. package/dist/eventLeg.d.ts +100 -0
  95. package/dist/eventLeg.js +305 -0
  96. package/dist/executionLaneCapability.d.ts +0 -4
  97. package/dist/executionLaneCapability.js +3 -16
  98. package/dist/fileHistoryCaptureCapability.d.ts +2 -5
  99. package/dist/fileHistoryCaptureCapability.js +13 -21
  100. package/dist/fileHistoryLegNotice.d.ts +2 -1
  101. package/dist/fileHistoryLegNotice.js +3 -3
  102. package/dist/fleet/fleetLedger.d.ts +0 -3
  103. package/dist/fleet/fleetLedger.js +21 -36
  104. package/dist/fleet/fleetProjection.d.ts +2 -2
  105. package/dist/fleet/fleetProjection.js +10 -8
  106. package/dist/frameBinding.d.ts +8 -0
  107. package/dist/frameBinding.js +35 -0
  108. package/dist/gateFailureCodes.d.ts +2 -0
  109. package/dist/gateFailureCodes.js +15 -0
  110. package/dist/gateOutcome.d.ts +3 -1
  111. package/dist/gateOutcome.js +41 -8
  112. package/dist/gateVocabulary.d.ts +10 -4
  113. package/dist/gateVocabulary.js +107 -47
  114. package/dist/generated/engineAskFaceTables.js +2 -2
  115. package/dist/generated/engineFactTables.d.ts +22 -3
  116. package/dist/generated/engineFactTables.js +51 -4
  117. package/dist/generated/engineNoticeTables.js +18 -3
  118. package/dist/generated/settingsSchemaFns.d.ts +6 -0
  119. package/dist/generated/settingsSchemaFns.js +57 -0
  120. package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
  121. package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
  122. package/dist/generated/settingsSchemaTables.d.ts +1 -0
  123. package/dist/generated/settingsSchemaTables.js +4 -0
  124. package/dist/generated/settingsSchemaTypes.d.ts +105 -0
  125. package/dist/generated/settingsSchemaTypes.js +1 -0
  126. package/dist/generated/toolNameTables.d.ts +1 -0
  127. package/dist/generated/toolNameTables.js +1 -0
  128. package/dist/hitl/allowRuleShadow.d.ts +8 -2
  129. package/dist/hitl/allowRuleShadow.js +36 -29
  130. package/dist/hitl/approvalCardReading.d.ts +15 -0
  131. package/dist/hitl/approvalCardReading.js +154 -0
  132. package/dist/hitl/approvalCardReasons.d.ts +14 -0
  133. package/dist/hitl/approvalCardReasons.js +119 -0
  134. package/dist/hitl/approvalHolds.d.ts +50 -15
  135. package/dist/hitl/approvalHolds.js +177 -27
  136. package/dist/hitl/approvalResolution.d.ts +51 -26
  137. package/dist/hitl/approvalResolution.js +86 -122
  138. package/dist/hitl/approvalsFeed.js +6 -18
  139. package/dist/hitl/askClassPair.d.ts +2 -0
  140. package/dist/hitl/askClassPair.js +17 -0
  141. package/dist/hitl/askGateWire.d.ts +20 -2
  142. package/dist/hitl/askGateWire.js +50 -1
  143. package/dist/hitl/askParkRowRouting.d.ts +5 -0
  144. package/dist/hitl/askParkRowRouting.js +32 -1
  145. package/dist/hitl/askSettlementLine.d.ts +28 -0
  146. package/dist/hitl/askSettlementLine.js +99 -0
  147. package/dist/hitl/automaticAnswerVerdict.d.ts +3 -2
  148. package/dist/hitl/automaticAnswerVerdict.js +29 -13
  149. package/dist/hitl/crashConverged.d.ts +11 -20
  150. package/dist/hitl/crashConverged.js +56 -0
  151. package/dist/hitl/crashConvergedNotice.d.ts +6 -3
  152. package/dist/hitl/crashConvergedNotice.js +48 -24
  153. package/dist/hitl/decisionConflict.js +3 -10
  154. package/dist/hitl/decisionRefusal.d.ts +40 -1
  155. package/dist/hitl/decisionRefusal.js +199 -42
  156. package/dist/hitl/frameRouter.d.ts +5 -2
  157. package/dist/hitl/frameRouter.js +27 -24
  158. package/dist/hitl/gateLedger.d.ts +2 -0
  159. package/dist/hitl/gateLedger.js +50 -13
  160. package/dist/hitl/hitlBridge.d.ts +2 -2
  161. package/dist/hitl/hitlBridge.js +13 -10
  162. package/dist/hitl/livePendingAsk.d.ts +3 -3
  163. package/dist/hitl/livePendingAsk.js +7 -18
  164. package/dist/hitl/parkResolver.d.ts +2 -24
  165. package/dist/hitl/parkResolver.js +61 -97
  166. package/dist/hitl/persistedRulesWire.d.ts +25 -0
  167. package/dist/hitl/persistedRulesWire.js +104 -2
  168. package/dist/hitl/planReviewWire.d.ts +31 -13
  169. package/dist/hitl/planReviewWire.js +120 -78
  170. package/dist/hitl/refusedToolNameProse.d.ts +0 -1
  171. package/dist/hitl/refusedToolNameProse.js +0 -3
  172. package/dist/hitl/replayedApproval.d.ts +4 -3
  173. package/dist/hitl/replayedApproval.js +7 -4
  174. package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
  175. package/dist/hitl/sessionPolicyDeliverable.js +48 -7
  176. package/dist/hitl/sessionPolicyWire.d.ts +34 -21
  177. package/dist/hitl/sessionPolicyWire.js +179 -70
  178. package/dist/hitl/standingRows.d.ts +20 -2
  179. package/dist/hitl/standingRows.js +69 -8
  180. package/dist/hitl/suspendedReopen.d.ts +2 -1
  181. package/dist/hitl/suspendedReopen.js +7 -10
  182. package/dist/hitl/toolApprovalWire.d.ts +103 -156
  183. package/dist/hitl/toolApprovalWire.js +661 -411
  184. package/dist/hookMatcherVerdict.d.ts +6 -1
  185. package/dist/hookMatcherVerdict.js +14 -7
  186. package/dist/hooksWireCaps.d.ts +2 -2
  187. package/dist/hooksWireCaps.js +174 -81
  188. package/dist/host.d.ts +21 -0
  189. package/dist/hostTurnSettings.d.ts +71 -0
  190. package/dist/hostTurnSettings.js +291 -0
  191. package/dist/humanTurn.d.ts +14 -1
  192. package/dist/humanTurn.js +100 -12
  193. package/dist/humanTurnRead.d.ts +2 -0
  194. package/dist/humanTurnRead.js +22 -1
  195. package/dist/i18n/messages.en.d.ts +703 -0
  196. package/dist/i18n/messages.en.js +701 -0
  197. package/dist/i18n/messages.zh.d.ts +3 -0
  198. package/dist/i18n/messages.zh.js +837 -0
  199. package/dist/i18n/translate.d.ts +25 -0
  200. package/dist/i18n/translate.js +127 -0
  201. package/dist/index.d.ts +78 -29
  202. package/dist/index.js +54 -18
  203. package/dist/inheritEnvCapability.d.ts +32 -0
  204. package/dist/inheritEnvCapability.js +104 -0
  205. package/dist/inheritEnvWire.d.ts +3 -2
  206. package/dist/inheritEnvWire.js +12 -14
  207. package/dist/interactiveHalt.js +17 -6
  208. package/dist/liveModelCatalog.d.ts +3 -3
  209. package/dist/liveModelCatalog.js +15 -13
  210. package/dist/liveQuestionStore.d.ts +2 -21
  211. package/dist/mcpLiveness.d.ts +2 -1
  212. package/dist/mcpPanel.d.ts +10 -1
  213. package/dist/mcpPanel.js +40 -13
  214. package/dist/mcpProbeCapability.d.ts +2 -1
  215. package/dist/mcpProbeCapability.js +7 -11
  216. package/dist/mcpProbeWire.d.ts +9 -2
  217. package/dist/mcpProbeWire.js +6 -1
  218. package/dist/mcpWireCaps.d.ts +47 -2
  219. package/dist/mcpWireCaps.js +164 -16
  220. package/dist/memoryEntriesWire.d.ts +4 -9
  221. package/dist/memoryEntriesWire.js +5 -10
  222. package/dist/model/modelSupplyRules.d.ts +0 -2
  223. package/dist/model/modelSupplyRules.js +3 -12
  224. package/dist/model/modelsPolicy.d.ts +0 -5
  225. package/dist/model/modelsPolicy.js +6 -36
  226. package/dist/model/onboardJudgement.d.ts +93 -0
  227. package/dist/model/onboardJudgement.js +415 -0
  228. package/dist/model/subagentModelWord.d.ts +31 -0
  229. package/dist/model/subagentModelWord.js +261 -0
  230. package/dist/model/tierVocabulary.d.ts +2 -0
  231. package/dist/model/tierVocabulary.js +17 -5
  232. package/dist/modelCapabilityProbe.d.ts +64 -0
  233. package/dist/modelCapabilityProbe.js +600 -0
  234. package/dist/modelIdentityResolvability.d.ts +3 -0
  235. package/dist/modelIdentityResolvability.js +26 -17
  236. package/dist/notifications.d.ts +6 -0
  237. package/dist/notifications.js +71 -23
  238. package/dist/outputStyleSeatCapability.d.ts +0 -3
  239. package/dist/outputStyleSeatCapability.js +0 -3
  240. package/dist/ownKey.d.ts +22 -0
  241. package/dist/ownKey.js +94 -3
  242. package/dist/panelReduce.d.ts +21 -10
  243. package/dist/panelReduce.js +728 -550
  244. package/dist/panelStateHolder.d.ts +3 -7
  245. package/dist/panelStateHolder.js +14 -130
  246. package/dist/peerLaneCapability.d.ts +0 -4
  247. package/dist/peerLaneCapability.js +0 -6
  248. package/dist/permissionRuleIssue.js +2 -0
  249. package/dist/permissionRulesWriteCapability.d.ts +2 -5
  250. package/dist/permissionRulesWriteCapability.js +8 -12
  251. package/dist/permissionWireCaps.d.ts +2 -2
  252. package/dist/permissionWireCaps.js +2 -0
  253. package/dist/permissionsAllowGrantCapability.d.ts +0 -4
  254. package/dist/permissionsAllowGrantCapability.js +0 -6
  255. package/dist/permissionsDeclaration.d.ts +0 -11
  256. package/dist/permissionsDeclaration.js +60 -53
  257. package/dist/pluginHooksWire.d.ts +46 -3
  258. package/dist/pluginHooksWire.js +219 -16
  259. package/dist/preemptWire.d.ts +44 -0
  260. package/dist/preemptWire.js +83 -0
  261. package/dist/printModelStatus.d.ts +63 -0
  262. package/dist/printModelStatus.js +155 -0
  263. package/dist/printToolResultFrame.js +15 -4
  264. package/dist/replayBody.d.ts +3 -0
  265. package/dist/replayBody.js +14 -0
  266. package/dist/request/taskRequest.d.ts +11 -6
  267. package/dist/request/taskRequest.js +112 -19
  268. package/dist/resumeRefusalCopy.d.ts +13 -9
  269. package/dist/resumeRefusalCopy.js +81 -118
  270. package/dist/retryStatus.d.ts +45 -0
  271. package/dist/retryStatus.js +185 -1
  272. package/dist/rewindArchiveCapability.d.ts +0 -4
  273. package/dist/rewindArchiveCapability.js +2 -10
  274. package/dist/rewindArchiveReading.d.ts +0 -1
  275. package/dist/rewindArchiveReading.js +0 -3
  276. package/dist/runCancelContext.d.ts +2 -1
  277. package/dist/runCancelContext.js +4 -2
  278. package/dist/runReattachPolicy.d.ts +31 -0
  279. package/dist/runReattachPolicy.js +46 -0
  280. package/dist/runTerminal.d.ts +3 -6
  281. package/dist/runTerminal.js +8 -9
  282. package/dist/sandboxWire.d.ts +3 -1
  283. package/dist/sandboxWire.js +76 -27
  284. package/dist/scenarioRefusal.d.ts +9 -0
  285. package/dist/scenarioRefusal.js +111 -0
  286. package/dist/scenarioWire.js +1 -1
  287. package/dist/seam.d.ts +48 -2
  288. package/dist/seam.js +25 -4
  289. package/dist/seatContract.d.ts +311 -18
  290. package/dist/seatContract.js +824 -100
  291. package/dist/selfOrchestrationDenial.js +7 -19
  292. package/dist/sessionIdSegment.d.ts +6 -0
  293. package/dist/sessionIdSegment.js +24 -0
  294. package/dist/sessionMemoryStatus.js +6 -11
  295. package/dist/sessionPolicyCapability.d.ts +2 -5
  296. package/dist/sessionPolicyCapability.js +8 -12
  297. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
  298. package/dist/sessionSyncFileHistoryCapability.js +0 -3
  299. package/dist/settingsHooksSalvage.d.ts +44 -0
  300. package/dist/settingsHooksSalvage.js +211 -0
  301. package/dist/skillToolListsCapability.d.ts +2 -4
  302. package/dist/skillToolListsCapability.js +8 -9
  303. package/dist/sqlEngineCapability.d.ts +0 -4
  304. package/dist/sqlEngineCapability.js +0 -6
  305. package/dist/sseIdleTriage.js +3 -2
  306. package/dist/steerPriorityCapability.d.ts +0 -3
  307. package/dist/steerPriorityCapability.js +0 -3
  308. package/dist/streamDrainingLegs.d.ts +4 -0
  309. package/dist/streamDrainingLegs.js +6 -1
  310. package/dist/subagent/engineCompactWire.d.ts +0 -1
  311. package/dist/subagent/engineCompactWire.js +7 -5
  312. package/dist/subagent/engineSubagentResume.js +15 -9
  313. package/dist/subagent/engineTaskHandleWire.js +4 -7
  314. package/dist/subagentContentStore.d.ts +3 -0
  315. package/dist/subagentContentStore.js +22 -10
  316. package/dist/submitReopen.d.ts +24 -0
  317. package/dist/submitReopen.js +75 -0
  318. package/dist/terminalStatuses.d.ts +3 -0
  319. package/dist/terminalStatuses.js +10 -2
  320. package/dist/toolHistoryMismatch.js +3 -2
  321. package/dist/toolResult.d.ts +10 -1
  322. package/dist/toolResult.js +34 -6
  323. package/dist/toolRoster.d.ts +3 -4
  324. package/dist/toolRoster.js +21 -22
  325. package/dist/turnFailurePresentation.d.ts +39 -0
  326. package/dist/turnFailurePresentation.js +402 -0
  327. package/dist/usageAnalytics.js +6 -11
  328. package/dist/userAttachmentEnvelope.d.ts +1 -0
  329. package/dist/userAttachmentEnvelope.js +37 -7
  330. package/dist/userAttachmentSeat.d.ts +21 -0
  331. package/dist/userAttachmentSeat.js +75 -0
  332. package/dist/userInvokedSkillsCapability.d.ts +11 -4
  333. package/dist/userInvokedSkillsCapability.js +31 -10
  334. package/dist/webSearchBackendCapability.d.ts +0 -4
  335. package/dist/webSearchBackendCapability.js +0 -6
  336. package/dist/wireErrorTriage.d.ts +7 -0
  337. package/dist/wireErrorTriage.js +26 -23
  338. package/dist/wireFailureShape.d.ts +62 -5
  339. package/dist/wireFailureShape.js +106 -5
  340. package/dist/wireRefusalCopy.d.ts +25 -3
  341. package/dist/wireRefusalCopy.js +74 -80
  342. package/dist/workflowsJournalCapability.d.ts +2 -5
  343. package/dist/workflowsJournalCapability.js +8 -12
  344. package/dist/writeProtectionCapability.d.ts +0 -4
  345. package/dist/writeProtectionCapability.js +0 -6
  346. package/docs/INTEGRATION-CLIENTS.md +1775 -56
  347. package/package.json +6 -5
  348. package/dist/attachmentSeatCapability.d.ts +0 -12
  349. package/dist/attachmentSeatCapability.js +0 -23
  350. package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
  351. package/dist/hitl/approvalOutcomeNote.js +0 -29
  352. package/dist/sessionReadRedactionCapability.d.ts +0 -13
  353. package/dist/sessionReadRedactionCapability.js +0 -35
@@ -1,30 +1,18 @@
1
1
  import { CAPABILITY_SELF_ORCHESTRATION_REQUIRED } from './engineErrorCodes.js';
2
+ import { readThrownSlot, THROWN_SLOT_UNREADABLE } from './wireFailureShape.js';
2
3
  const ENTITLEMENT_RESOLVER_ABSENT = 'entitlement_resolver_absent';
3
4
  export const SELF_ORCHESTRATION_RETRY_WITHOUT = Object.freeze(['selfOrchestration', 'settings.ultracode']);
4
5
  export function classifySelfOrchestrationRefusal(e) {
5
- let status;
6
- let code;
7
- try {
8
- const o = e;
9
- const rawStatus = o?.status;
10
- const rawCode = o?.errorCode;
11
- status = typeof rawStatus === 'number' ? rawStatus : undefined;
12
- code = typeof rawCode === 'string' ? rawCode : undefined;
13
- }
14
- catch {
15
- return null;
16
- }
6
+ const rawStatus = readThrownSlot(e, 'status', 'data');
7
+ const rawCode = readThrownSlot(e, 'errorCode', 'data');
8
+ const status = typeof rawStatus === 'number' ? rawStatus : undefined;
9
+ const code = typeof rawCode === 'string' ? rawCode : undefined;
17
10
  if (status !== 501)
18
11
  return null;
19
12
  if (code !== CAPABILITY_SELF_ORCHESTRATION_REQUIRED)
20
13
  return null;
21
- let denial;
22
- try {
23
- denial = e?.denial;
24
- }
25
- catch {
26
- denial = undefined;
27
- }
14
+ const rawDenial = readThrownSlot(e, 'denial', 'data');
15
+ const denial = rawDenial === THROWN_SLOT_UNREADABLE ? undefined : rawDenial;
28
16
  return {
29
17
  kind: 'self-orchestration-denied',
30
18
  retryWithout: SELF_ORCHESTRATION_RETRY_WITHOUT,
@@ -1 +1,7 @@
1
1
  export declare function isSessionIdPathSegment(id: unknown): id is string;
2
+ export type SessionIdRefusalWhy = 'not_string' | 'bad_shape' | 'bad_version' | 'bad_variant';
3
+ export interface SessionIdRefusal {
4
+ readonly why: SessionIdRefusalWhy;
5
+ }
6
+ export declare function canonicalSessionIdOf(raw: {} | null | undefined): string | null;
7
+ export declare function sessionIdRefusalOf(raw: {} | null | undefined): SessionIdRefusal | null;
@@ -9,3 +9,27 @@ export function isSessionIdPathSegment(id) {
9
9
  return false;
10
10
  }
11
11
  }
12
+ const UUID_ANY_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
13
+ function sessionIdReadingOf(raw) {
14
+ if (typeof raw !== 'string')
15
+ return { id: null, why: 'not_string' };
16
+ const folded = raw.replace(/[A-F]/g, (c) => c.toLowerCase());
17
+ if (UUID_ANY_RE.test(folded))
18
+ return { id: folded, why: null };
19
+ const version = folded.charAt(14);
20
+ const variant = folded.charAt(19);
21
+ const hex = '0123456789abcdef';
22
+ if (folded.length !== 36 || !hex.includes(version) || !hex.includes(variant))
23
+ return { id: null, why: 'bad_shape' };
24
+ const probe = `${folded.slice(0, 14)}4${folded.slice(15, 19)}8${folded.slice(20)}`;
25
+ if (!UUID_ANY_RE.test(probe))
26
+ return { id: null, why: 'bad_shape' };
27
+ return { id: null, why: '12345678'.includes(version) ? 'bad_variant' : 'bad_version' };
28
+ }
29
+ export function canonicalSessionIdOf(raw) {
30
+ return sessionIdReadingOf(raw).id;
31
+ }
32
+ export function sessionIdRefusalOf(raw) {
33
+ const r = sessionIdReadingOf(raw);
34
+ return r.why === null ? null : Object.freeze({ why: r.why });
35
+ }
@@ -1,17 +1,12 @@
1
1
  import { isSessionIdPathSegment } from './sessionIdSegment.js';
2
+ import { readThrownSlot, THROWN_SLOT_UNREADABLE } from './wireFailureShape.js';
2
3
  export function classifyMemoryStatusFailure(e) {
3
- let code;
4
- let status;
5
- try {
6
- const o = e;
7
- const rawCode = o?.errorCode;
8
- const rawStatus = o?.status;
9
- code = typeof rawCode === 'string' ? rawCode : undefined;
10
- status = typeof rawStatus === 'number' ? rawStatus : undefined;
11
- }
12
- catch {
4
+ const rawCode = readThrownSlot(e, 'errorCode', 'data');
5
+ const rawStatus = readThrownSlot(e, 'status', 'data');
6
+ if (rawCode === THROWN_SLOT_UNREADABLE || rawStatus === THROWN_SLOT_UNREADABLE)
13
7
  return { kind: 'failed', error: e };
14
- }
8
+ const code = typeof rawCode === 'string' ? rawCode : undefined;
9
+ const status = typeof rawStatus === 'number' ? rawStatus : undefined;
15
10
  if (code !== undefined) {
16
11
  if (code.startsWith('capability.'))
17
12
  return { kind: 'unsupported', reason: 'capability' };
@@ -1,3 +1,4 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
1
2
  export type SessionPolicyReading = {
2
3
  kind: 'unobserved';
3
4
  } | {
@@ -10,10 +11,6 @@ export type SessionPolicyReading = {
10
11
  kind: 'present';
11
12
  };
12
13
  export declare function projectSessionPolicyCapability(caps: unknown): SessionPolicyReading | undefined;
13
- export declare function noteEngineCapsForSessionPolicy(baseUrl: string, caps: unknown, opts?: {
14
- generation?: number;
15
- }): void;
16
14
  export declare function observedSessionPolicy(baseUrl?: string | undefined): SessionPolicyReading;
17
15
  export declare function sessionPolicyFaceAvailable(reading: SessionPolicyReading): 'yes' | 'no' | 'unknown';
18
- export declare function sessionPolicyDoctorDetail(reading: SessionPolicyReading): string;
19
- export declare function __resetSessionPolicyReadingsForTests(): void;
16
+ export declare function sessionPolicyDoctorDetail(reading: SessionPolicyReading, lang?: UiLanguage): string;
@@ -1,5 +1,6 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
2
  import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
3
+ import { msg, renderMessage } from './i18n/translate.js';
3
4
  import { ownDataField } from './ownKey.js';
4
5
  export function projectSessionPolicyCapability(caps) {
5
6
  try {
@@ -21,9 +22,6 @@ const reader = createEngineCapReader({
21
22
  name: 'sessionPolicy',
22
23
  project: projectSessionPolicyCapability,
23
24
  });
24
- export function noteEngineCapsForSessionPolicy(baseUrl, caps, opts) {
25
- reader.note(baseUrl, caps, opts);
26
- }
27
25
  export function observedSessionPolicy(baseUrl = engineWireTarget()?.baseUrl) {
28
26
  return reader.observed(baseUrl);
29
27
  }
@@ -34,20 +32,18 @@ export function sessionPolicyFaceAvailable(reading) {
34
32
  return 'no';
35
33
  return 'unknown';
36
34
  }
37
- export function sessionPolicyDoctorDetail(reading) {
35
+ export function sessionPolicyDoctorDetail(reading, lang) {
36
+ const subject = msg('notice.capability.subject.sessionPolicy');
38
37
  switch (reading.kind) {
39
38
  case 'unreadable':
40
- return unreadableReadingDetail('per-session rule face');
39
+ return unreadableReadingDetail(renderMessage(subject, lang), lang);
41
40
  case 'unobserved':
42
- return 'per-session rule face not observed — the engine reports it on /v1/capabilities (sessionPolicy); this process has no usable capabilities reading cached for it (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which)';
41
+ return renderMessage(msg('notice.capability.unobserved', { subject, key: 'sessionPolicy' }), lang);
43
42
  case 'not_reported':
44
- return 'per-session rule face not reported by this engine — this binary predates the position itself; it says nothing about whether the face exists, so read the rules rather than writing them blind';
43
+ return renderMessage(msg('notice.capability.sessionPolicy.notReported'), lang);
45
44
  case 'absent':
46
- return 'no per-session rule store on this deployment — reading and writing this session’s tool rules is unavailable here';
45
+ return renderMessage(msg('notice.capability.sessionPolicy.absent'), lang);
47
46
  case 'present':
48
- return 'per-session rule face on — this session’s tool rules can be read, and a tightening write is accepted or refused by the engine call by call';
47
+ return renderMessage(msg('notice.capability.sessionPolicy.present'), lang);
49
48
  }
50
49
  }
51
- export function __resetSessionPolicyReadingsForTests() {
52
- reader.__resetForTests();
53
- }
@@ -10,9 +10,6 @@ export type SessionSyncFileHistoryReading = {
10
10
  kind: 'present';
11
11
  };
12
12
  export declare function projectSessionSyncFileHistoryCapability(caps: unknown): SessionSyncFileHistoryReading | undefined;
13
- export declare function noteEngineCapsForSessionSyncFileHistory(baseUrl: string, caps: unknown, opts?: {
14
- generation?: number;
15
- }): void;
16
13
  export declare function observedSessionSyncFileHistory(baseUrl?: string | undefined): SessionSyncFileHistoryReading;
17
14
  export declare function sessionSyncFileHistoryAvailable(reading: SessionSyncFileHistoryReading): 'yes' | 'no' | 'unknown';
18
15
  export declare function sessionSyncFileHistoryDoctorDetail(reading: SessionSyncFileHistoryReading): string;
@@ -20,9 +20,6 @@ const reader = createEngineCapReader({
20
20
  name: 'sessionSyncFileHistory',
21
21
  project: projectSessionSyncFileHistoryCapability,
22
22
  });
23
- export function noteEngineCapsForSessionSyncFileHistory(baseUrl, caps, opts) {
24
- reader.note(baseUrl, caps, opts);
25
- }
26
23
  export function observedSessionSyncFileHistory(baseUrl = engineWireTarget()?.baseUrl) {
27
24
  return reader.observed(baseUrl);
28
25
  }
@@ -0,0 +1,44 @@
1
+ import type { WireHooksConfig } from './finalVerifyWire.js';
2
+ import type { SettingsDocument } from './host.js';
3
+ import type { HookSettingsSource } from './pluginHooksWire.js';
4
+ export type HooksSalvageOutcome = 'loaded' | 'loaded-partial' | 'rejected';
5
+ export type HooksSalvageDropCode = 'hooks-not-object' | 'unknown-event' | 'event-not-array' | 'matcher-invalid' | 'entry-invalid';
6
+ export type HooksSalvageRejectionCode = 'guard-outside-hooks' | 'hooks-is-matcher' | 'guard-under-unknown-event' | 'guard-event-not-array' | 'guard-matcher-invalid' | 'guard-entry-invalid';
7
+ export interface HooksSalvageDrop {
8
+ readonly code: HooksSalvageDropCode;
9
+ readonly path: readonly (string | number)[];
10
+ readonly field?: string;
11
+ }
12
+ export interface HooksSalvageRejection {
13
+ readonly code: HooksSalvageRejectionCode;
14
+ readonly path: readonly (string | number)[];
15
+ readonly field?: string;
16
+ }
17
+ export type HooksSalvage = {
18
+ readonly outcome: 'loaded';
19
+ readonly hooks: WireHooksConfig | undefined;
20
+ readonly dropped: readonly [];
21
+ readonly rejections: readonly [];
22
+ } | {
23
+ readonly outcome: 'loaded-partial';
24
+ readonly hooks: WireHooksConfig | undefined;
25
+ readonly dropped: readonly HooksSalvageDrop[];
26
+ readonly rejections: readonly [];
27
+ } | {
28
+ readonly outcome: 'rejected';
29
+ readonly hooks: undefined;
30
+ readonly dropped: readonly [];
31
+ readonly rejections: readonly HooksSalvageRejection[];
32
+ };
33
+ export interface HooksSalvageMask {
34
+ readonly hooksDropped: boolean;
35
+ eventDropped(event: string): boolean;
36
+ groupDropped(event: string, groupIndex: number): boolean;
37
+ entryDropped(event: string, groupIndex: number, hookIndex: number): boolean;
38
+ }
39
+ export declare function hooksSalvageMaskOf(dropped: readonly {
40
+ readonly path: readonly (string | number)[];
41
+ }[]): HooksSalvageMask;
42
+ export declare function salvageSettingsHooksEntries(doc: SettingsDocument | null | undefined): HooksSalvage;
43
+ export declare const HOOK_SETTINGS_SOURCE_TEXT: Readonly<Record<HookSettingsSource, string>>;
44
+ export declare function settingsHooksSalvageNotice(salvage: HooksSalvage, source: HookSettingsSource, doc?: SettingsDocument | null): string | undefined;
@@ -0,0 +1,211 @@
1
+ import { displayUntrusted } from './displayUntrusted.js';
2
+ import { SETTINGS_CLASSIFY_HOOKS_CONFIG, } from './generated/settingsSchemaFns.js';
3
+ const _tuplePins = [true, true, true, true, true, true];
4
+ void _tuplePins;
5
+ const _classifierPins = [true, true, true, true, true, true];
6
+ void _classifierPins;
7
+ const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
8
+ const own = (o, k) => (Object.hasOwn(o, k) ? o[k] : undefined);
9
+ const freezeRow = (row) => Object.freeze(row);
10
+ function pieceOf(p) {
11
+ return freezeRow({ code: p.code, path: Object.freeze([...p.path]), ...(typeof p.field === 'string' ? { field: p.field } : {}) });
12
+ }
13
+ const EMPTY_MASK = Object.freeze({
14
+ hooksDropped: false,
15
+ eventDropped: () => false,
16
+ groupDropped: () => false,
17
+ entryDropped: () => false,
18
+ });
19
+ export function hooksSalvageMaskOf(dropped) {
20
+ if (dropped.length === 0)
21
+ return EMPTY_MASK;
22
+ let all = false;
23
+ const events = new Set();
24
+ const groups = new Set();
25
+ const entries = new Set();
26
+ for (const d of dropped) {
27
+ const p = d.path;
28
+ if (p[0] !== 'hooks') {
29
+ all = true;
30
+ continue;
31
+ }
32
+ if (p.length === 1)
33
+ all = true;
34
+ else if (p.length === 2 && typeof p[1] === 'string')
35
+ events.add(p[1]);
36
+ else if (p.length === 3 && typeof p[1] === 'string' && typeof p[2] === 'number')
37
+ groups.add(`${p[1]}\u0000${p[2]}`);
38
+ else if (p.length === 5 && typeof p[1] === 'string' && typeof p[2] === 'number' && p[3] === 'hooks' && typeof p[4] === 'number')
39
+ entries.add(`${p[1]}\u0000${p[2]}\u0000${p[4]}`);
40
+ else
41
+ all = true;
42
+ }
43
+ return Object.freeze({
44
+ hooksDropped: all,
45
+ eventDropped: (event) => all || events.has(event),
46
+ groupDropped: (event, gi) => all || events.has(event) || groups.has(`${event}\u0000${gi}`),
47
+ entryDropped: (event, gi, hi) => all || events.has(event) || groups.has(`${event}\u0000${gi}`) || entries.has(`${event}\u0000${gi}\u0000${hi}`),
48
+ });
49
+ }
50
+ function pruneHooks(hooks, mask) {
51
+ if (mask.hooksDropped || !isRecord(hooks))
52
+ return undefined;
53
+ const out = [];
54
+ for (const event of Object.keys(hooks)) {
55
+ if (mask.eventDropped(event))
56
+ continue;
57
+ const groups = own(hooks, event);
58
+ if (!Array.isArray(groups)) {
59
+ out.push([event, groups]);
60
+ continue;
61
+ }
62
+ const keptGroups = [];
63
+ let changed = false;
64
+ groups.forEach((group, gi) => {
65
+ if (mask.groupDropped(event, gi)) {
66
+ changed = true;
67
+ return;
68
+ }
69
+ const entries = isRecord(group) ? own(group, 'hooks') : undefined;
70
+ if (!isRecord(group) || !Array.isArray(entries)) {
71
+ keptGroups.push(group);
72
+ return;
73
+ }
74
+ const keptEntries = entries.filter((_e, hi) => !mask.entryDropped(event, gi, hi));
75
+ if (keptEntries.length === entries.length) {
76
+ keptGroups.push(group);
77
+ return;
78
+ }
79
+ changed = true;
80
+ if (keptEntries.length > 0)
81
+ keptGroups.push({ ...group, hooks: keptEntries });
82
+ });
83
+ if (!changed)
84
+ out.push([event, groups]);
85
+ else if (keptGroups.length > 0)
86
+ out.push([event, keptGroups]);
87
+ }
88
+ return out.length > 0 ? Object.fromEntries(out) : undefined;
89
+ }
90
+ export function salvageSettingsHooksEntries(doc) {
91
+ const r = SETTINGS_CLASSIFY_HOOKS_CONFIG(doc);
92
+ if (r.outcome === 'rejected') {
93
+ return Object.freeze({ outcome: 'rejected', hooks: undefined, dropped: Object.freeze([]), rejections: Object.freeze(r.rejections.map(pieceOf)) });
94
+ }
95
+ const original = isRecord(doc) ? own(doc, 'hooks') : undefined;
96
+ if (r.outcome === 'loaded') {
97
+ return Object.freeze({
98
+ outcome: 'loaded',
99
+ hooks: isRecord(original) ? original : undefined,
100
+ dropped: Object.freeze([]),
101
+ rejections: Object.freeze([]),
102
+ });
103
+ }
104
+ const dropped = Object.freeze(r.dropped.map(pieceOf));
105
+ return Object.freeze({
106
+ outcome: 'loaded-partial',
107
+ hooks: pruneHooks(original, hooksSalvageMaskOf(dropped)),
108
+ dropped,
109
+ rejections: Object.freeze([]),
110
+ });
111
+ }
112
+ export const HOOK_SETTINGS_SOURCE_TEXT = Object.freeze({
113
+ policySettings: 'Managed settings',
114
+ userSettings: 'User settings',
115
+ projectSettings: 'Project settings',
116
+ localSettings: 'Local settings',
117
+ flagSettings: 'Flag settings',
118
+ });
119
+ const SALVAGE_LABEL_MAX = 80;
120
+ const SALVAGE_PIECES_SHOWN = 3;
121
+ const labelOf = (s) => (typeof s === 'number' ? String(s) : displayUntrusted(s, { max: SALVAGE_LABEL_MAX }));
122
+ function receivedOf(v) {
123
+ if (v === null)
124
+ return 'null';
125
+ if (Array.isArray(v))
126
+ return 'array';
127
+ return typeof v === 'object' ? 'object' : typeof v;
128
+ }
129
+ function valueAt(doc, path) {
130
+ let cur = doc;
131
+ for (const seg of path) {
132
+ if (typeof seg === 'number')
133
+ cur = Array.isArray(cur) ? cur[seg] : undefined;
134
+ else
135
+ cur = isRecord(cur) ? own(cur, seg) : undefined;
136
+ }
137
+ return cur;
138
+ }
139
+ function whereOf(path) {
140
+ const ev = path[1];
141
+ const gi = path[2];
142
+ const hi = path[4];
143
+ const evText = ev === undefined ? '' : `"${labelOf(ev)}"`;
144
+ if (typeof gi !== 'number')
145
+ return evText;
146
+ return typeof hi === 'number' ? `${evText} (matcher ${gi + 1}, hook ${hi + 1})` : `${evText} (matcher ${gi + 1})`;
147
+ }
148
+ const fieldTail = (field) => (field !== undefined ? ` (field "${labelOf(field)}")` : '');
149
+ function dropPhrase(d, doc) {
150
+ switch (d.code) {
151
+ case 'hooks-not-object':
152
+ return `"hooks" must be an object mapping event names to matcher arrays; received ${receivedOf(valueAt(doc, d.path))}. This field was ignored`;
153
+ case 'unknown-event':
154
+ return `Unknown hook event ${whereOf(d.path)} was ignored`;
155
+ case 'event-not-array':
156
+ return `Hook event ${whereOf(d.path)} must be an array of matchers; received ${receivedOf(valueAt(doc, d.path))}. This entry was ignored`;
157
+ case 'matcher-invalid':
158
+ return `an invalid matcher under hook event ${whereOf(d.path)}${fieldTail(d.field)} was ignored`;
159
+ case 'entry-invalid':
160
+ return `an invalid hook under hook event ${whereOf(d.path)}${fieldTail(d.field)} was ignored`;
161
+ }
162
+ }
163
+ function rejectionPhrase(r) {
164
+ switch (r.code) {
165
+ case 'guard-outside-hooks':
166
+ return `a PreToolUse or PermissionRequest hook is written outside "hooks" (at ${r.path.map(labelOf).join('.') || 'the top level'})`;
167
+ case 'hooks-is-matcher':
168
+ return '"hooks" is written as a matcher or a single hook instead of an object of hook events';
169
+ case 'guard-under-unknown-event':
170
+ return `${whereOf(r.path)} is not a hook event, but it holds PreToolUse or PermissionRequest hooks`;
171
+ case 'guard-event-not-array':
172
+ return `hook event ${whereOf(r.path)} is not an array of matchers`;
173
+ case 'guard-matcher-invalid':
174
+ return `a matcher under hook event ${whereOf(r.path)}${fieldTail(r.field)} is invalid or holds a misplaced hook`;
175
+ case 'guard-entry-invalid':
176
+ return `a hook under hook event ${whereOf(r.path)}${fieldTail(r.field)} is invalid or holds a misplaced hook`;
177
+ }
178
+ }
179
+ function joinPhrases(phrases) {
180
+ const seen = new Set();
181
+ const uniq = [];
182
+ for (const p of phrases) {
183
+ if (seen.has(p.key))
184
+ continue;
185
+ seen.add(p.key);
186
+ uniq.push(p.text);
187
+ }
188
+ const shown = uniq.slice(0, SALVAGE_PIECES_SHOWN).join('; ');
189
+ return uniq.length > SALVAGE_PIECES_SHOWN ? `${shown}; and ${uniq.length - SALVAGE_PIECES_SHOWN} more` : shown;
190
+ }
191
+ const GUARD_RISK_TAIL = 'a PreToolUse or PermissionRequest hook that cannot be loaded may be what guards the permissions declared beside it, so none of the hooks in this file are applied until it is fixed';
192
+ export function settingsHooksSalvageNotice(salvage, source, doc) {
193
+ const layer = HOOK_SETTINGS_SOURCE_TEXT[source] ?? 'Settings';
194
+ try {
195
+ if (salvage.outcome === 'loaded-partial') {
196
+ const what = joinPhrases(salvage.dropped.map((d) => ({ key: d.path.join('\u0000'), text: dropPhrase(d, doc) })));
197
+ return `${layer}: ${what}. The rest of this file's hooks are applied.`;
198
+ }
199
+ if (salvage.outcome === 'rejected') {
200
+ const why = joinPhrases(salvage.rejections.map((r) => ({ key: r.path.join('\u0000'), text: rejectionPhrase(r) })));
201
+ if (source === 'policySettings') {
202
+ return `${layer}: hooks could not be loaded — ${why}. Requests are not sent while the managed hooks cannot be applied; ask your administrator to fix the managed settings.`;
203
+ }
204
+ return `${layer}: hooks were not loaded — ${why}; ${GUARD_RISK_TAIL}.`;
205
+ }
206
+ return undefined;
207
+ }
208
+ catch {
209
+ return salvage.outcome === 'loaded' ? undefined : `${layer}: some hooks in this file could not be loaded.`;
210
+ }
211
+ }
@@ -1,3 +1,4 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
1
2
  export type SkillToolListsReading = {
2
3
  kind: 'unobserved';
3
4
  } | {
@@ -10,9 +11,6 @@ export type SkillToolListsReading = {
10
11
  kind: 'present';
11
12
  };
12
13
  export declare function projectSkillToolListsCapability(caps: unknown): SkillToolListsReading | undefined;
13
- export declare function noteEngineCapsForSkillToolLists(baseUrl: string, caps: unknown, opts?: {
14
- generation?: number;
15
- }): void;
16
14
  export declare function observedSkillToolLists(baseUrl?: string | undefined): SkillToolListsReading;
17
15
  export declare function skillToolListsAvailable(reading: SkillToolListsReading): 'yes' | 'no' | 'unknown';
18
- export declare function skillToolListsDoctorDetail(reading: SkillToolListsReading): string;
16
+ export declare function skillToolListsDoctorDetail(reading: SkillToolListsReading, lang?: UiLanguage): string;
@@ -1,5 +1,6 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
2
  import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
3
+ import { msg, renderMessage } from './i18n/translate.js';
3
4
  import { ownDataField } from './ownKey.js';
4
5
  export function projectSkillToolListsCapability(caps) {
5
6
  try {
@@ -20,9 +21,6 @@ const reader = createEngineCapReader({
20
21
  name: 'skillToolLists',
21
22
  project: projectSkillToolListsCapability,
22
23
  });
23
- export function noteEngineCapsForSkillToolLists(baseUrl, caps, opts) {
24
- reader.note(baseUrl, caps, opts);
25
- }
26
24
  export function observedSkillToolLists(baseUrl = engineWireTarget()?.baseUrl) {
27
25
  return reader.observed(baseUrl);
28
26
  }
@@ -33,17 +31,18 @@ export function skillToolListsAvailable(reading) {
33
31
  return 'no';
34
32
  return 'unknown';
35
33
  }
36
- export function skillToolListsDoctorDetail(reading) {
34
+ export function skillToolListsDoctorDetail(reading, lang) {
35
+ const subject = msg('notice.capability.subject.skillToolLists');
37
36
  switch (reading.kind) {
38
37
  case 'unreadable':
39
- return unreadableReadingDetail('skill tool lists');
38
+ return unreadableReadingDetail(renderMessage(subject, lang), lang);
40
39
  case 'unobserved':
41
- return 'skill tool lists not observed — the engine reports it on /v1/capabilities (skillToolLists); this process has no usable capabilities reading cached for it (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which)';
40
+ return renderMessage(msg('notice.capability.unobserved', { subject, key: 'skillToolLists' }), lang);
42
41
  case 'not_reported':
43
- return 'skill tool lists not reported by this engine — the engine predates them: tool lists on request skills are not read, so they do not limit any tool';
42
+ return renderMessage(msg('notice.capability.skillToolLists.notReported'), lang);
44
43
  case 'absent':
45
- return 'skill tool lists off on this deployment — tool lists on request skills are not read';
44
+ return renderMessage(msg('notice.capability.skillToolLists.absent'), lang);
46
45
  case 'present':
47
- return 'skill tool lists on — a request skill’s allowed and disallowed tool lists are read as this run’s rules';
46
+ return renderMessage(msg('notice.capability.skillToolLists.present'), lang);
48
47
  }
49
48
  }
@@ -16,9 +16,5 @@ export type SqlEngineReading = {
16
16
  view: SqlEngineCapabilityView;
17
17
  };
18
18
  export declare function projectSqlEngineCapability(caps: unknown): SqlEngineReading | undefined;
19
- export declare function noteEngineCapsForSqlEngine(baseUrl: string, caps: unknown, opts?: {
20
- generation?: number;
21
- }): void;
22
19
  export declare function observedSqlEngine(baseUrl?: string | undefined): SqlEngineReading;
23
20
  export declare function sqlEngineDoctorDetail(reading: SqlEngineReading): string;
24
- export declare function __resetSqlEngineReadingsForTests(): void;
@@ -40,9 +40,6 @@ const reader = createEngineCapReader({
40
40
  name: 'sql',
41
41
  project: projectSqlEngineCapability,
42
42
  });
43
- export function noteEngineCapsForSqlEngine(baseUrl, caps, opts) {
44
- reader.note(baseUrl, caps, opts);
45
- }
46
43
  export function observedSqlEngine(baseUrl = engineWireTarget()?.baseUrl) {
47
44
  return reader.observed(baseUrl);
48
45
  }
@@ -72,6 +69,3 @@ export function sqlEngineDoctorDetail(reading) {
72
69
  }
73
70
  }
74
71
  }
75
- export function __resetSqlEngineReadingsForTests() {
76
- reader.__resetForTests();
77
- }
@@ -1,5 +1,6 @@
1
1
  import { hostEnv } from './hostEnv.js';
2
2
  import { SseIdleError, probeHealth as sdkProbeHealth } from '@sema-agent/sdk';
3
+ import { readThrownSlot, thrownIsInstanceOf } from './wireFailureShape.js';
3
4
  export const SSE_HEARTBEAT_GRACE_ENV = 'SEMA_SSE_HEARTBEAT_GRACE_MS';
4
5
  export const SSE_GRACE_MIN_MS = 5_000;
5
6
  export const SSE_GRACE_MAX_MS = 600_000;
@@ -27,9 +28,9 @@ export function engineAliveIdleElapsedMs(err) {
27
28
  return typeof e.elapsedMs === 'number' && Number.isFinite(e.elapsedMs) ? e.elapsedMs : 0;
28
29
  }
29
30
  export function isSseIdleError(err) {
30
- if (err instanceof SseIdleError)
31
+ if (thrownIsInstanceOf(err, SseIdleError))
31
32
  return true;
32
- return err?.name === 'SseIdleError';
33
+ return readThrownSlot(err, 'name', 'data') === 'SseIdleError';
33
34
  }
34
35
  export async function probeEngineAlive(baseUrl, timeoutMs = 2_000) {
35
36
  return (await sdkProbeHealth(baseUrl, timeoutMs)).alive;
@@ -10,9 +10,6 @@ export type SteerPriorityReading = {
10
10
  };
11
11
  export type SteerPriorityMode = 'engine' | 'advisory' | 'unknown';
12
12
  export declare function projectSteerPriorityCapability(caps: unknown): SteerPriorityReading | undefined;
13
- export declare function noteEngineCapsForSteerPriority(baseUrl: string, caps: unknown, opts?: {
14
- generation?: number;
15
- }): void;
16
13
  export declare function observedSteerPriority(baseUrl?: string | undefined): SteerPriorityReading;
17
14
  export declare function steerPriorityMode(reading: SteerPriorityReading): SteerPriorityMode;
18
15
  export declare function steerPriorityDoctorDetail(reading: SteerPriorityReading): string;
@@ -26,9 +26,6 @@ const reader = createEngineCapReader({
26
26
  name: 'fleet.steerPriority',
27
27
  project: projectSteerPriorityCapability,
28
28
  });
29
- export function noteEngineCapsForSteerPriority(baseUrl, caps, opts) {
30
- reader.note(baseUrl, caps, opts);
31
- }
32
29
  export function observedSteerPriority(baseUrl = engineWireTarget()?.baseUrl) {
33
30
  return reader.observed(baseUrl);
34
31
  }
@@ -1,4 +1,8 @@
1
1
  import { type StreamDrainingDecision } from './wireErrorTriage.js';
2
+ export declare function drainingLegStep<F>(streak: number, frame: F): {
3
+ readonly decision: StreamDrainingDecision;
4
+ readonly streak: number;
5
+ };
2
6
  export interface StreamDrainingLegs<F> {
3
7
  see(frame: F): boolean;
4
8
  legEnded(how: 'returned' | 'threw'): StreamDrainingDecision | undefined;
@@ -1,4 +1,7 @@
1
1
  import { isInStreamDrainingEnd, streamDrainingDecision } from './wireErrorTriage.js';
2
+ export function drainingLegStep(streak, frame) {
3
+ return { decision: streamDrainingDecision(frame, streak), streak: streak + 1 };
4
+ }
2
5
  export function createStreamDrainingLegs() {
3
6
  let consecutive = 0;
4
7
  let drainEnd;
@@ -17,7 +20,9 @@ export function createStreamDrainingLegs() {
17
20
  drainEnd = undefined;
18
21
  if (how !== 'returned' || ended === undefined)
19
22
  return undefined;
20
- return streamDrainingDecision(ended.frame, consecutive++);
23
+ const step = drainingLegStep(consecutive, ended.frame);
24
+ consecutive = step.streak;
25
+ return step.decision;
21
26
  },
22
27
  };
23
28
  }
@@ -20,7 +20,6 @@ export type EngineCompactOutcome = {
20
20
  readonly kind: 'offline';
21
21
  };
22
22
  export declare function isEngineCompactPending(sessionKey?: string): boolean;
23
- export declare function resetManualCompactCapability(): void;
24
23
  export declare function __resetEngineCompactArmForTests(): void;
25
24
  export declare function requestEngineCompact(sessionKey?: string, opts?: {
26
25
  wire?: EngineCompactWire;
@@ -1,6 +1,7 @@
1
1
  import { hostLog, hostTimersFor } from '../host.js';
2
2
  import { invokeHostCallbackIsolated } from '../hostCallbackGuard.js';
3
- import { COMPACT_NOT_RUNNING, isUnavailableFaceCode } from '../engineErrorCodes.js';
3
+ import { COMPACT_NOT_RUNNING } from '../engineErrorCodes.js';
4
+ import { refusalDeliveryOf } from '../hitl/decisionRefusal.js';
4
5
  import { surfaceCompactNotRunning } from '../hitl/hitlHostSurface.js';
5
6
  import { wireFailureShapeOf, wireFailureTextsOf } from '../wireFailureShape.js';
6
7
  import { clientHasVerbs, engineWireFor, INJECTED_WIRE_SETTLE_MS, noAnswerDetailFrom, settleInjected, } from '../engineWireFor.js';
@@ -30,7 +31,6 @@ function probeManualCompactCapability(wire) {
30
31
  return;
31
32
  kickEngineCapsProbe(base, () => client.capabilities());
32
33
  }
33
- export function resetManualCompactCapability() { }
34
34
  export function __resetEngineCompactArmForTests() {
35
35
  pendingCompactKeys.clear();
36
36
  pendingCompactSinks.clear();
@@ -86,9 +86,11 @@ function compactFailureOutcomeOf(e) {
86
86
  const status = typeof shape.status === 'number' && Number.isFinite(shape.status) ? shape.status : undefined;
87
87
  const code = shape.errorCode !== undefined && shape.errorCode !== '' ? shape.errorCode : undefined;
88
88
  if (status !== undefined) {
89
- if ((status >= 400 && status < 500) || isUnavailableFaceCode(code)) {
90
- return { kind: 'refused', status, ...(code !== undefined ? { errorCode: code } : {}) };
91
- }
89
+ const d = refusalDeliveryOf(e, { route: 'compact' });
90
+ if (d.delivery === 'refused')
91
+ return { kind: 'refused', status: d.status ?? status, ...(code !== undefined ? { errorCode: code } : {}) };
92
+ if (d.delivery === 'ambiguous')
93
+ return { kind: 'failed', status: d.status ?? status, detail: wireFailureTextsOf(e).reason, unconfirmed: true };
92
94
  return { kind: 'failed', status, detail: wireFailureTextsOf(e).reason };
93
95
  }
94
96
  const noAnswer = typeof e === 'object' && e !== null ? noAnswerDetailFrom(e) : null;