@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
@@ -0,0 +1,105 @@
1
+ export type ConfigPath = readonly (string | number)[];
2
+ declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "UserPromptSubmit", "UserPromptExpansion", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded", "PreModelSwitch", "PostModelSwitch"];
3
+ type HookEventWord = (typeof HOOK_EVENTS)[number];
4
+ declare const HOOK_ENTRY_TYPES: readonly ["command", "prompt", "agent", "http", "mcp_tool"];
5
+ export type HookEntryType = (typeof HOOK_ENTRY_TYPES)[number];
6
+ declare const HOOK_SHELLS: readonly ["bash", "powershell"];
7
+ declare const HOOK_ENTRY_FIELDS: {
8
+ readonly command: {
9
+ readonly if: "string?";
10
+ readonly timeout: "seconds?";
11
+ readonly statusMessage: "string?";
12
+ readonly once: "boolean?";
13
+ readonly command: "text";
14
+ readonly shell: "shell?";
15
+ readonly async: "boolean?";
16
+ readonly asyncRewake: "boolean?";
17
+ };
18
+ readonly prompt: {
19
+ readonly if: "string?";
20
+ readonly timeout: "seconds?";
21
+ readonly statusMessage: "string?";
22
+ readonly once: "boolean?";
23
+ readonly prompt: "text";
24
+ readonly model: "string?";
25
+ };
26
+ readonly agent: {
27
+ readonly if: "string?";
28
+ readonly timeout: "seconds?";
29
+ readonly statusMessage: "string?";
30
+ readonly once: "boolean?";
31
+ readonly prompt: "text";
32
+ readonly model: "string?";
33
+ };
34
+ readonly http: {
35
+ readonly if: "string?";
36
+ readonly timeout: "seconds?";
37
+ readonly statusMessage: "string?";
38
+ readonly once: "boolean?";
39
+ readonly url: "text";
40
+ readonly headers: "stringRecord?";
41
+ readonly allowedEnvVars: "stringList?";
42
+ };
43
+ readonly mcp_tool: {
44
+ readonly if: "string?";
45
+ readonly timeout: "seconds?";
46
+ readonly statusMessage: "string?";
47
+ readonly once: "boolean?";
48
+ readonly server: "string";
49
+ readonly tool: "string";
50
+ readonly input: "record?";
51
+ };
52
+ };
53
+ type HookFieldBaseValue<B> = B extends "text" | "string" ? string : B extends "shell" ? (typeof HOOK_SHELLS)[number] : B extends "boolean" ? boolean : B extends "seconds" ? number : B extends "stringRecord" ? Record<string, string> : B extends "stringList" ? string[] : B extends "record" ? Record<string, unknown> : never;
54
+ type HookFieldValue<K> = K extends `${infer B}?` ? HookFieldBaseValue<B> : HookFieldBaseValue<K>;
55
+ type Flat<O> = {
56
+ [K in keyof O]: O[K];
57
+ };
58
+ type HookEntryOf<T extends HookEntryType, F = (typeof HOOK_ENTRY_FIELDS)[T]> = Flat<{
59
+ type: T;
60
+ } & {
61
+ -readonly [K in keyof F as F[K] extends `${string}?` ? never : K]: HookFieldValue<F[K]>;
62
+ } & {
63
+ -readonly [K in keyof F as F[K] extends `${string}?` ? K : never]?: HookFieldValue<F[K]>;
64
+ }>;
65
+ export type HookEntry = {
66
+ [T in HookEntryType]: HookEntryOf<T>;
67
+ }[HookEntryType];
68
+ export type HookMatcherEntry = {
69
+ matcher?: string;
70
+ hooks: HookEntry[];
71
+ };
72
+ export type HooksConfig = Partial<Record<HookEventWord, HookMatcherEntry[]>>;
73
+ declare const HOOKS_CLASSIFICATION_OUTCOMES: readonly ["loaded", "loaded-partial", "rejected"];
74
+ export type HooksClassificationOutcome = (typeof HOOKS_CLASSIFICATION_OUTCOMES)[number];
75
+ declare const HOOKS_DROPPED_PIECE_CODES: readonly ["hooks-not-object", "unknown-event", "event-not-array", "matcher-invalid", "entry-invalid"];
76
+ export type HooksDroppedPieceCode = (typeof HOOKS_DROPPED_PIECE_CODES)[number];
77
+ declare const HOOKS_REJECTION_CODES: readonly ["guard-outside-hooks", "hooks-is-matcher", "guard-under-unknown-event", "guard-event-not-array", "guard-matcher-invalid", "guard-entry-invalid"];
78
+ export type HooksRejectionCode = (typeof HOOKS_REJECTION_CODES)[number];
79
+ export interface HooksDroppedPiece {
80
+ readonly code: HooksDroppedPieceCode;
81
+ readonly path: ConfigPath;
82
+ readonly field?: string;
83
+ }
84
+ export interface HooksRejection {
85
+ readonly code: HooksRejectionCode;
86
+ readonly path: ConfigPath;
87
+ readonly field?: string;
88
+ }
89
+ export type HooksClassification = {
90
+ readonly outcome: "loaded";
91
+ readonly hooks: HooksConfig | undefined;
92
+ readonly dropped: readonly [];
93
+ readonly rejections: readonly [];
94
+ } | {
95
+ readonly outcome: "loaded-partial";
96
+ readonly hooks: HooksConfig | undefined;
97
+ readonly dropped: readonly HooksDroppedPiece[];
98
+ readonly rejections: readonly [];
99
+ } | {
100
+ readonly outcome: "rejected";
101
+ readonly hooks: undefined;
102
+ readonly dropped: readonly [];
103
+ readonly rejections: readonly HooksRejection[];
104
+ };
105
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
1
  export declare const CORE_PROTOCOL_PREFIXES: readonly ["mcp__", "a2a__"];
2
2
  export declare const CORE_SKILL_TOOL_NAME: "Skill";
3
+ export declare const CORE_BOUND_GRANT_ABSENCES: readonly ["not_bindable", "unreadable"];
@@ -1,2 +1,3 @@
1
1
  export const CORE_PROTOCOL_PREFIXES = ["mcp__", "a2a__"];
2
2
  export const CORE_SKILL_TOOL_NAME = "Skill";
3
+ export const CORE_BOUND_GRANT_ABSENCES = ["not_bindable", "unreadable"];
@@ -1,3 +1,4 @@
1
+ import type { UiLanguage } from '../env/uiLanguage.js';
1
2
  export interface ApprovalAllowRuleShadowMember {
2
3
  readonly member?: string;
3
4
  readonly known: boolean;
@@ -11,11 +12,16 @@ export interface AllowRuleShadowedWireMember {
11
12
  readonly omitted?: number;
12
13
  }
13
14
  export interface ApprovalAllowRuleShadow {
14
- readonly source: 'allow_rule_shadowed' | 'legacy_shadowed_rule';
15
+ readonly source: 'allow_rule_shadowed';
15
16
  readonly members: readonly ApprovalAllowRuleShadowMember[];
16
17
  readonly unreadable?: true;
17
18
  }
19
+ export declare const RETIRED_SHADOW_EVIDENCE_LABEL: Readonly<{
20
+ readonly frame: "persistedRuleShadowed";
21
+ readonly row: "riskDescriptor.shadowedRule";
22
+ }>;
23
+ export declare function retiredAllowRuleShadowKeyPresent(carrier: object | null | undefined, leg: 'frame' | 'row'): boolean;
18
24
  export declare function readAllowRuleShadowFromWire(carrier: object | null | undefined, leg: 'frame' | 'row'): ApprovalAllowRuleShadow | undefined;
19
25
  export declare function readApprovalAllowRuleShadow(card: object | null | undefined): ApprovalAllowRuleShadow | undefined;
20
26
  export declare function approvalAllowRuleShadowed(card: object | null | undefined): boolean;
21
- export declare function allowRuleShadowSentence(card: object | null | undefined): string | undefined;
27
+ export declare function allowRuleShadowSentence(card: object | null | undefined, lang?: UiLanguage): string | undefined;
@@ -1,5 +1,6 @@
1
1
  import { CORE_ALLOW_RULE_MEMBERS } from '../generated/engineFactTables.js';
2
2
  import { quoteUntrustedForSentence } from '../displayUntrusted.js';
3
+ import { msg, renderMessage } from '../i18n/translate.js';
3
4
  const KNOWN_MEMBERS = new Set(CORE_ALLOW_RULE_MEMBERS);
4
5
  function freezeMember(m) {
5
6
  return Object.freeze({ ...m });
@@ -76,20 +77,27 @@ function readNewKeyValue(raw) {
76
77
  return unreadable();
77
78
  return Object.freeze({ source: 'allow_rule_shadowed', members: Object.freeze(members) });
78
79
  }
79
- function readLegacyValue(raw) {
80
- if (typeof raw !== 'string' || raw.trim() === '')
81
- return undefined;
82
- return Object.freeze({
83
- source: 'legacy_shadowed_rule',
84
- members: Object.freeze([freezeMember({ member: 'persisted', known: true, entries: Object.freeze([raw]) })]),
85
- });
86
- }
87
80
  function ownValue(v, key) {
88
81
  return Object.hasOwn(v, key) ? v[key] : undefined;
89
82
  }
90
83
  function keyValue(v, key) {
91
84
  return v[key];
92
85
  }
86
+ const RETIRED_SHADOW_KEY = Object.freeze({ frame: 'persistedRuleShadowed', row: 'shadowedRule' });
87
+ export const RETIRED_SHADOW_EVIDENCE_LABEL = Object.freeze({ frame: 'persistedRuleShadowed', row: 'riskDescriptor.shadowedRule' });
88
+ export function retiredAllowRuleShadowKeyPresent(carrier, leg) {
89
+ try {
90
+ if (typeof carrier !== 'object' || carrier === null)
91
+ return false;
92
+ const host = leg === 'row' ? keyValue(carrier, 'riskDescriptor') : carrier;
93
+ if (typeof host !== 'object' || host === null)
94
+ return false;
95
+ return RETIRED_SHADOW_KEY[leg] in host;
96
+ }
97
+ catch {
98
+ return true;
99
+ }
100
+ }
93
101
  function readMemberAt(arr, i) {
94
102
  const d = Object.getOwnPropertyDescriptor(arr, i);
95
103
  return d !== undefined && 'value' in d ? readMemberRecord(d.value) : freezeMember({ known: false, malformed: true });
@@ -105,10 +113,7 @@ export function readAllowRuleShadowFromWire(carrier, leg) {
105
113
  }
106
114
  if (host === undefined)
107
115
  return undefined;
108
- const fresh = readNewKeyValue(keyValue(host, 'allowRuleShadowed'));
109
- if (fresh !== undefined)
110
- return fresh;
111
- return readLegacyValue(keyValue(host, leg === 'row' ? 'shadowedRule' : 'persistedRuleShadowed'));
116
+ return readNewKeyValue(keyValue(host, 'allowRuleShadowed'));
112
117
  }
113
118
  catch {
114
119
  return unreadable();
@@ -119,7 +124,7 @@ function readStampedValue(raw) {
119
124
  return unreadable();
120
125
  const source = ownValue(raw, 'source');
121
126
  const members = ownValue(raw, 'members');
122
- if ((source !== 'allow_rule_shadowed' && source !== 'legacy_shadowed_rule') || !Array.isArray(members))
127
+ if (source !== 'allow_rule_shadowed' || !Array.isArray(members))
123
128
  return unreadable();
124
129
  const length = members.length;
125
130
  if (typeof length !== 'number' || !Number.isSafeInteger(length))
@@ -158,8 +163,7 @@ export function approvalAllowRuleShadowed(card) {
158
163
  const ENTRY_MAX = 4096;
159
164
  const MEMBER_MAX = 64;
160
165
  const ENTRIES_SHOWN = 5;
161
- const UNREADABLE_LINE = 'An allow rule matched this call but cannot clear it; which rule could not be read, so this one is confirmed individually.';
162
- function legacySingleEntry(shadow) {
166
+ function singlePersistedEntry(shadow) {
163
167
  if (shadow.unreadable === true || shadow.members.length !== 1)
164
168
  return undefined;
165
169
  const m = shadow.members[0];
@@ -169,12 +173,12 @@ function legacySingleEntry(shadow) {
169
173
  return undefined;
170
174
  return quoteUntrustedForSentence(m.entries[0], ENTRY_MAX);
171
175
  }
172
- function memberPhrase(m) {
176
+ function memberPhrase(m, lang) {
173
177
  const memberWord = m.member === undefined ? undefined : KNOWN_MEMBERS.has(m.member) ? m.member : quoteUntrustedForSentence(m.member, MEMBER_MAX);
174
- const word = memberWord ?? 'an unrecognised source';
178
+ const word = memberWord ?? msg('approval.card.shadow.unrecognisedSource');
175
179
  const entries = m.entries ?? [];
176
180
  if (m.malformed === true && entries.length === 0)
177
- return `${word} (could not be read)`;
181
+ return renderMessage(msg('approval.card.shadow.memberUnreadable', { word }), lang);
178
182
  const listed = entries
179
183
  .map((e) => quoteUntrustedForSentence(e, ENTRY_MAX))
180
184
  .filter((e) => e !== undefined)
@@ -184,25 +188,28 @@ function memberPhrase(m) {
184
188
  if (listed.length > 0)
185
189
  parts.push(listed.join(', '));
186
190
  if (notListed > 0)
187
- parts.push(listed.length > 0 ? `and ${String(notListed)} more not listed` : `${String(notListed)} not listed`);
191
+ parts.push(renderMessage(listed.length > 0 ? msg('approval.card.shadow.moreNotListed', { count: notListed }) : msg('approval.card.shadow.notListed', { count: notListed }), lang));
188
192
  if (m.malformed === true)
189
- parts.push('part of it could not be read');
190
- return parts.length > 0 ? `${word}: ${parts.join('; ')}` : word;
193
+ parts.push(renderMessage(msg('approval.card.shadow.partUnreadable'), lang));
194
+ return parts.length > 0
195
+ ? renderMessage(msg('approval.card.shadow.memberWithParts', { word, parts: parts.join(renderMessage(msg('approval.card.shadow.partJoin'), lang)) }), lang)
196
+ : typeof word === 'string'
197
+ ? word
198
+ : renderMessage(word, lang);
191
199
  }
192
- export function allowRuleShadowSentence(card) {
200
+ export function allowRuleShadowSentence(card, lang) {
193
201
  const shadow = readApprovalAllowRuleShadow(card);
194
202
  if (shadow === undefined)
195
203
  return undefined;
196
204
  try {
197
205
  if (shadow.unreadable === true || shadow.members.length === 0)
198
- return UNREADABLE_LINE;
199
- const legacy = legacySingleEntry(shadow);
200
- if (legacy !== undefined) {
201
- return `Your saved permission rule ${legacy} still exists — it just cannot clear this particular call, so this one is confirmed individually.`;
202
- }
203
- return `Allow rules matched this call but cannot clear it, so this one is confirmed individually — ${shadow.members.map(memberPhrase).join(' · ')}.`;
206
+ return renderMessage(msg('approval.card.shadow.unreadable'), lang);
207
+ const single = singlePersistedEntry(shadow);
208
+ if (single !== undefined)
209
+ return renderMessage(msg('approval.card.shadow.single', { entry: single }), lang);
210
+ return renderMessage(msg('approval.card.shadow.several', { members: shadow.members.map((m) => memberPhrase(m, lang)).join(' · ') }), lang);
204
211
  }
205
212
  catch {
206
- return UNREADABLE_LINE;
213
+ return renderMessage(msg('approval.card.shadow.unreadable'), lang);
207
214
  }
208
215
  }
@@ -0,0 +1,15 @@
1
+ import type { ApprovalCardRequest } from './toolApprovalWire.js';
2
+ export declare function readRequiresRealApproval(carrier: object | null | undefined): boolean;
3
+ export interface ApprovalWindowKeys {
4
+ readonly expiresInMs?: number;
5
+ readonly expiresAtMs?: number;
6
+ readonly serverNowMs?: number;
7
+ readonly receivedAtMs?: number;
8
+ }
9
+ export interface ApprovalWindowReadOpts {
10
+ readonly windowIsCurrent?: boolean;
11
+ readonly receivedAtMs?: number;
12
+ readonly unknownShape?: boolean;
13
+ }
14
+ export declare function approvalWindowKeysOf(carrier: object | null | undefined, opts?: ApprovalWindowReadOpts | null): Readonly<ApprovalWindowKeys>;
15
+ export declare function probeCauseRowsOf(card: Pick<ApprovalCardRequest, 'probeCause'> | null | undefined): readonly string[] | undefined;
@@ -0,0 +1,154 @@
1
+ import { displayUntrusted } from '../displayUntrusted.js';
2
+ import { guardedRead, readOwnDataValue } from '../ownKey.js';
3
+ export function readRequiresRealApproval(carrier) {
4
+ if (typeof carrier !== 'object' || carrier === null)
5
+ return false;
6
+ let failed = false;
7
+ let failure;
8
+ try {
9
+ if (carrier.requiresRealApproval === true)
10
+ return true;
11
+ }
12
+ catch (e) {
13
+ failed = true;
14
+ failure = e;
15
+ }
16
+ try {
17
+ const risk = carrier.risk;
18
+ if (typeof risk === 'object' && risk !== null && risk.requiresRealApproval === true)
19
+ return true;
20
+ }
21
+ catch (e) {
22
+ if (!failed)
23
+ failure = e;
24
+ failed = true;
25
+ }
26
+ if (failed)
27
+ throw failure;
28
+ return false;
29
+ }
30
+ const EMPTY = Object.freeze({});
31
+ const UNKNOWN_SHAPE_COHERENCE_TOLERANCE_MS = 1_000;
32
+ function nonNegativeFinite(v) {
33
+ return typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : undefined;
34
+ }
35
+ export function approvalWindowKeysOf(carrier, opts) {
36
+ if (typeof carrier !== 'object' || carrier === null)
37
+ return EMPTY;
38
+ if (typeof opts !== 'object' || opts === null)
39
+ return EMPTY;
40
+ let current;
41
+ let anchor;
42
+ let unknownShape;
43
+ try {
44
+ current = opts.windowIsCurrent;
45
+ anchor = opts.receivedAtMs;
46
+ unknownShape = opts.unknownShape;
47
+ }
48
+ catch {
49
+ return EMPTY;
50
+ }
51
+ if (current !== true)
52
+ return EMPTY;
53
+ const read = (key) => {
54
+ try {
55
+ return nonNegativeFinite(carrier[key]);
56
+ }
57
+ catch {
58
+ return undefined;
59
+ }
60
+ };
61
+ const inMs = read('expiresInMs');
62
+ const atMs = read('expiresAtMs');
63
+ const nowMs = read('serverNowMs');
64
+ if (unknownShape === true) {
65
+ if (inMs === undefined || atMs === undefined || nowMs === undefined)
66
+ return EMPTY;
67
+ if (atMs <= 0 || nowMs <= 0)
68
+ return EMPTY;
69
+ if (Math.abs(inMs - Math.max(0, atMs - nowMs)) > UNKNOWN_SHAPE_COHERENCE_TOLERANCE_MS)
70
+ return EMPTY;
71
+ }
72
+ const receivedAtMs = nonNegativeFinite(anchor);
73
+ const out = {};
74
+ if (inMs !== undefined)
75
+ out.expiresInMs = inMs;
76
+ if (atMs !== undefined)
77
+ out.expiresAtMs = atMs;
78
+ if (nowMs !== undefined)
79
+ out.serverNowMs = nowMs;
80
+ if ((inMs !== undefined || atMs !== undefined) && receivedAtMs !== undefined)
81
+ out.receivedAtMs = receivedAtMs;
82
+ return Object.freeze(out);
83
+ }
84
+ const PROBE_CAUSE_SHOWN_MAX = 8;
85
+ const PROBE_CAUSE_ENTRY_MAX = 200;
86
+ function own(v, key) {
87
+ if (typeof v !== 'object' || v === null)
88
+ return undefined;
89
+ return guardedRead(() => readOwnDataValue(v, key));
90
+ }
91
+ function readOperands(v) {
92
+ if (typeof v !== 'object' || v === null)
93
+ return undefined;
94
+ const shown = own(v, 'shown');
95
+ const isList = guardedRead(() => Array.isArray(shown));
96
+ if (isList !== true)
97
+ return undefined;
98
+ const length = own(shown, 'length');
99
+ if (typeof length !== 'number' || !Number.isSafeInteger(length) || length < 0)
100
+ return undefined;
101
+ const items = [];
102
+ for (let i = 0; i < length; i++) {
103
+ const item = own(shown, String(i));
104
+ if (typeof item !== 'string')
105
+ return undefined;
106
+ items.push(item);
107
+ }
108
+ const total = own(v, 'total');
109
+ if (typeof total !== 'number' || !Number.isSafeInteger(total) || total < 0 || total < items.length)
110
+ return undefined;
111
+ return { shown: items, total };
112
+ }
113
+ function operandsText(label, o) {
114
+ const shown = o.shown.slice(0, PROBE_CAUSE_SHOWN_MAX).map((p) => displayUntrusted(p, { max: PROBE_CAUSE_ENTRY_MAX }));
115
+ if (shown.length === 0)
116
+ return `${label}: ${String(o.total)} total`;
117
+ const more = o.total - shown.length;
118
+ return more > 0 ? `${label}: ${shown.join(', ')} (+${String(more)} more)` : `${label}: ${shown.join(', ')}`;
119
+ }
120
+ export function probeCauseRowsOf(card) {
121
+ try {
122
+ if (typeof card !== 'object' || card === null)
123
+ return undefined;
124
+ const cause = own(card, 'probeCause');
125
+ if (typeof cause !== 'object' || cause === null)
126
+ return undefined;
127
+ if (guardedRead(() => Array.isArray(cause)) !== false)
128
+ return undefined;
129
+ const code = own(cause, 'code');
130
+ if (typeof code !== 'string' || code === '')
131
+ return undefined;
132
+ const roots = readOperands(own(cause, 'roots'));
133
+ if (roots === undefined)
134
+ return undefined;
135
+ let fd;
136
+ try {
137
+ fd = Object.getOwnPropertyDescriptor(cause, 'further');
138
+ }
139
+ catch {
140
+ return undefined;
141
+ }
142
+ if (fd === undefined || (Object.hasOwn(fd, 'value') && fd.value === undefined))
143
+ return Object.freeze([operandsText('roots', roots)]);
144
+ if (!Object.hasOwn(fd, 'value'))
145
+ return undefined;
146
+ const further = readOperands(fd.value);
147
+ if (further === undefined)
148
+ return undefined;
149
+ return Object.freeze([operandsText('roots', roots), operandsText('further', further)]);
150
+ }
151
+ catch {
152
+ return undefined;
153
+ }
154
+ }
@@ -0,0 +1,14 @@
1
+ import type { UiLanguage } from '../env/uiLanguage.js';
2
+ import { type DenialLimitFallback } from './toolApprovalWire.js';
3
+ export declare const APPROVAL_CARD_REASON_SOURCES: readonly ["payload_unreadable", "prior_cards", "message", "mandated", "mandate", "origin", "denial_limit", "probe", "allow_rule_shadow", "classifier_no_ruling", "bound_grants", "more"];
4
+ export type ApprovalCardReasonSource = (typeof APPROVAL_CARD_REASON_SOURCES)[number];
5
+ export interface ApprovalCardReasonLine {
6
+ readonly source: ApprovalCardReasonSource;
7
+ readonly text: string;
8
+ }
9
+ export interface ApprovalCardReasonsOptions {
10
+ readonly maxLines?: number;
11
+ }
12
+ export declare const APPROVAL_CARD_REASONS_DEFAULT_MAX_LINES = 4;
13
+ export declare function denialLimitFallbackDetail(v: DenialLimitFallback | null | undefined, lang?: UiLanguage): string | undefined;
14
+ export declare function approvalCardReasons(card: object | null | undefined, opts?: ApprovalCardReasonsOptions | null, lang?: UiLanguage): readonly ApprovalCardReasonLine[];
@@ -0,0 +1,119 @@
1
+ import { displayUntrusted } from '../displayUntrusted.js';
2
+ import { msg, renderMessage } from '../i18n/translate.js';
3
+ import { approvalMandateDetail, askOriginNoteOf } from '../gateVocabulary.js';
4
+ import { readAskOrigin, readOwnDataValue, guardedRead } from '../ownKey.js';
5
+ import { allowRuleShadowSentence } from './allowRuleShadow.js';
6
+ import { mandatedApprovalDetailOf } from './automaticAnswerVerdict.js';
7
+ import { approvalBoundGrantsDetail, approvalIsMandated, approvalPriorCardsDetail, askProbeReasonDetail, classifierNoRulingDetail, readApprovalBoundGrants, readApprovalClassifierNoRuling, readApprovalMandate, readDenialLimitFallback, } from './toolApprovalWire.js';
8
+ export const APPROVAL_CARD_REASON_SOURCES = Object.freeze([
9
+ 'payload_unreadable',
10
+ 'prior_cards',
11
+ 'message',
12
+ 'mandated',
13
+ 'mandate',
14
+ 'origin',
15
+ 'denial_limit',
16
+ 'probe',
17
+ 'allow_rule_shadow',
18
+ 'classifier_no_ruling',
19
+ 'bound_grants',
20
+ 'more',
21
+ ]);
22
+ export const APPROVAL_CARD_REASONS_DEFAULT_MAX_LINES = 4;
23
+ const MESSAGE_DISPLAY_MAX = 300;
24
+ function payloadUnreadableDetail(lang) {
25
+ return renderMessage(msg('approval.card.payloadUnreadable'), lang);
26
+ }
27
+ function moreDetail(n, lang) {
28
+ return renderMessage(n === 1 ? msg('approval.card.more.one') : msg('approval.card.more.other', { count: n }), lang);
29
+ }
30
+ export function denialLimitFallbackDetail(v, lang) {
31
+ const d = readDenialLimitFallback(v);
32
+ if (d === undefined)
33
+ return undefined;
34
+ const limit = displayUntrusted(d.limit, { max: 24 });
35
+ return renderMessage(d.autoDenyAfterMs > 0
36
+ ? msg('approval.card.denialLimit.withAutoDeny', { consecutive: d.consecutive, total: d.total, limit, seconds: Math.round(d.autoDenyAfterMs / 1000) })
37
+ : msg('approval.card.denialLimit.plain', { consecutive: d.consecutive, total: d.total, limit }), lang);
38
+ }
39
+ function ownData(card, key) {
40
+ return guardedRead(() => readOwnDataValue(card, key));
41
+ }
42
+ function readMaxLines(opts) {
43
+ const raw = typeof opts === 'object' && opts !== null ? guardedRead(() => readOwnDataValue(opts, 'maxLines')) : undefined;
44
+ return typeof raw === 'number' && Number.isSafeInteger(raw) && raw >= 1 ? raw : APPROVAL_CARD_REASONS_DEFAULT_MAX_LINES;
45
+ }
46
+ export function approvalCardReasons(card, opts, lang) {
47
+ if (typeof card !== 'object' || card === null)
48
+ return Object.freeze([]);
49
+ const raw = [];
50
+ const add = (source, read) => {
51
+ let text;
52
+ try {
53
+ text = read();
54
+ }
55
+ catch {
56
+ text = undefined;
57
+ }
58
+ raw.push({ source, text });
59
+ };
60
+ let denialLimitReadable = false;
61
+ try {
62
+ denialLimitReadable = readDenialLimitFallback(ownData(card, 'denialLimitFallback')) !== undefined;
63
+ }
64
+ catch {
65
+ denialLimitReadable = false;
66
+ }
67
+ add('payload_unreadable', () => (ownData(card, 'cardPayloadUnreadable') === true ? payloadUnreadableDetail(lang) : undefined));
68
+ add('prior_cards', () => approvalPriorCardsDetail(card, lang));
69
+ add('message', () => {
70
+ const engineMessage = ownData(card, 'message');
71
+ if (typeof engineMessage !== 'string' || engineMessage.trim() === '')
72
+ return undefined;
73
+ const tool = ownData(card, 'toolName');
74
+ if (typeof tool === 'string' && engineMessage.trim() === `approval required for "${tool}"`)
75
+ return undefined;
76
+ return displayUntrusted(engineMessage, { max: MESSAGE_DISPLAY_MAX });
77
+ });
78
+ add('mandated', () => (approvalIsMandated(card) ? mandatedApprovalDetailOf(card, lang) : undefined));
79
+ add('mandate', () => {
80
+ const word = readApprovalMandate(card);
81
+ return word !== undefined ? approvalMandateDetail(word, lang) : undefined;
82
+ });
83
+ add('origin', () => {
84
+ const origin = readAskOrigin(card);
85
+ if (origin === undefined)
86
+ return undefined;
87
+ if (origin === 'denial_limit_fallback' && denialLimitReadable)
88
+ return undefined;
89
+ return askOriginNoteOf(origin, lang);
90
+ });
91
+ add('denial_limit', () => denialLimitFallbackDetail(ownData(card, 'denialLimitFallback'), lang));
92
+ add('probe', () => askProbeReasonDetail(card, lang));
93
+ add('allow_rule_shadow', () => allowRuleShadowSentence(card, lang));
94
+ add('classifier_no_ruling', () => {
95
+ const word = readApprovalClassifierNoRuling(card);
96
+ return word !== undefined ? classifierNoRulingDetail(word, lang) : undefined;
97
+ });
98
+ add('bound_grants', () => {
99
+ const grants = readApprovalBoundGrants(card);
100
+ return grants !== undefined ? approvalBoundGrantsDetail(grants, lang) : undefined;
101
+ });
102
+ const seen = new Set();
103
+ const lines = [];
104
+ for (const r of raw) {
105
+ if (r.text === undefined)
106
+ continue;
107
+ const text = displayUntrusted(r.text);
108
+ if (text === '' || seen.has(text))
109
+ continue;
110
+ seen.add(text);
111
+ lines.push(Object.freeze({ source: r.source, text }));
112
+ }
113
+ const max = readMaxLines(opts);
114
+ if (lines.length <= max)
115
+ return Object.freeze(lines);
116
+ const kept = lines.slice(0, max - 1);
117
+ kept.push(Object.freeze({ source: 'more', text: moreDetail(lines.length - kept.length, lang) }));
118
+ return Object.freeze(kept);
119
+ }