@sema-agent/client-core 0.94.0 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/CHANGELOG.md +521 -0
  2. package/README.md +104 -57
  3. package/dist/adapt/arms.js +12 -7
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.d.ts +1 -0
  6. package/dist/adapt/toolCards.js +18 -5
  7. package/dist/adapt/wireShapes.js +5 -24
  8. package/dist/adapter/activeRunSelfHeal.d.ts +12 -3
  9. package/dist/adapter/activeRunSelfHeal.js +50 -16
  10. package/dist/adapter/downstream/eventToSdkMessage.js +33 -18
  11. package/dist/adapter/downstream/terminalToSdkResult.js +19 -12
  12. package/dist/adapter/runStream.js +30 -46
  13. package/dist/adapter/types.d.ts +7 -0
  14. package/dist/adapter/types.js +15 -0
  15. package/dist/agentSession/backgroundView.js +5 -1
  16. package/dist/agentSession/engineAgentRegistryRead.js +7 -5
  17. package/dist/agentSession/engineSessionBackgroundStop.js +25 -17
  18. package/dist/agentsWireCaps.d.ts +2 -0
  19. package/dist/agentsWireCaps.js +13 -2
  20. package/dist/approvalDecidedByCapability.d.ts +0 -1
  21. package/dist/approvalDecidedByCapability.js +2 -7
  22. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  23. package/dist/approvalsStreamLiveCapability.js +2 -6
  24. package/dist/atMostOnce.d.ts +8 -0
  25. package/dist/atMostOnce.js +36 -0
  26. package/dist/attachmentSeatCapability.d.ts +0 -1
  27. package/dist/attachmentSeatCapability.js +0 -3
  28. package/dist/attachmentsWireCaps.js +11 -6
  29. package/dist/bashExitReading.d.ts +10 -0
  30. package/dist/bashExitReading.js +12 -0
  31. package/dist/callerCwdCapability.d.ts +0 -5
  32. package/dist/callerCwdCapability.js +2 -13
  33. package/dist/centerWiringCapability.d.ts +1 -7
  34. package/dist/centerWiringCapability.js +18 -27
  35. package/dist/classifierStatus.js +4 -4
  36. package/dist/classifierVerdictWire.js +4 -16
  37. package/dist/clientSlice.js +1 -1
  38. package/dist/cloudConfigWireCaps.d.ts +3 -3
  39. package/dist/cloudConfigWireCaps.js +85 -43
  40. package/dist/compensations.js +1 -1
  41. package/dist/coreValuePorts.d.ts +11 -7
  42. package/dist/coreValuePorts.js +5 -8
  43. package/dist/credentialProvenance.d.ts +28 -0
  44. package/dist/credentialProvenance.js +76 -0
  45. package/dist/cycleOrder.d.ts +15 -0
  46. package/dist/cycleOrder.js +45 -0
  47. package/dist/decideFailureNote.js +7 -2
  48. package/dist/decideReceipt.d.ts +2 -1
  49. package/dist/decideReceipt.js +39 -14
  50. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  51. package/dist/declared/supportFloorDeclared.js +5 -0
  52. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  53. package/dist/deviceExecutorManagementCapability.js +7 -16
  54. package/dist/deviceRebind.d.ts +88 -0
  55. package/dist/deviceRebind.js +242 -0
  56. package/dist/displayUntrusted.d.ts +8 -3
  57. package/dist/displayUntrusted.js +661 -63
  58. package/dist/engineAgentAbsence.d.ts +2 -2
  59. package/dist/engineAgentPanelStore.d.ts +8 -18
  60. package/dist/engineAgentPanelStore.js +19 -537
  61. package/dist/engineCapReader.d.ts +6 -6
  62. package/dist/engineCapReader.js +30 -43
  63. package/dist/engineCapsCache.d.ts +13 -2
  64. package/dist/engineCapsCache.js +276 -44
  65. package/dist/engineCredentialRequirement.d.ts +9 -0
  66. package/dist/engineCredentialRequirement.js +23 -0
  67. package/dist/engineDirectory.d.ts +79 -0
  68. package/dist/engineDirectory.js +186 -0
  69. package/dist/engineEnvSourcing.d.ts +53 -0
  70. package/dist/engineEnvSourcing.js +81 -0
  71. package/dist/engineErrorCodes.d.ts +28 -4
  72. package/dist/engineErrorCodes.js +68 -25
  73. package/dist/engineIdentity.js +2 -0
  74. package/dist/engineNoticeCodes.d.ts +17 -0
  75. package/dist/engineNoticeCodes.js +57 -3
  76. package/dist/engineWireSdk.js +2 -2
  77. package/dist/engineWordRenames.d.ts +8 -0
  78. package/dist/engineWordRenames.js +13 -0
  79. package/dist/executionLaneCapability.d.ts +2 -3
  80. package/dist/executionLaneCapability.js +18 -23
  81. package/dist/fileHistoryCaptureCapability.d.ts +14 -1
  82. package/dist/fileHistoryCaptureCapability.js +72 -6
  83. package/dist/fileHistoryLegNotice.d.ts +3 -2
  84. package/dist/fileHistoryLegNotice.js +51 -2
  85. package/dist/fleet/bgSubagentRow.d.ts +15 -0
  86. package/dist/fleet/bgSubagentRow.js +67 -0
  87. package/dist/fleet/fleetLedger.d.ts +3 -0
  88. package/dist/fleet/fleetLedger.js +153 -122
  89. package/dist/fleet/fleetProjection.d.ts +1 -3
  90. package/dist/fleet/fleetProjection.js +19 -19
  91. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  92. package/dist/fleetAgentPanelProjection.js +7 -197
  93. package/dist/fleetAgentRowLike.d.ts +16 -0
  94. package/dist/fleetAgentRowLike.js +1 -0
  95. package/dist/fleetTaskDesc.js +4 -17
  96. package/dist/gateOutcome.d.ts +12 -1
  97. package/dist/gateOutcome.js +87 -18
  98. package/dist/gateVocabulary.d.ts +7 -2
  99. package/dist/gateVocabulary.js +5 -1
  100. package/dist/generated/engineAskFaceTables.js +1 -1
  101. package/dist/generated/engineFactTables.d.ts +5 -3
  102. package/dist/generated/engineFactTables.js +17 -4
  103. package/dist/generated/engineNoticeTables.js +12 -3
  104. package/dist/generated/sdkFactTables.d.ts +2 -0
  105. package/dist/generated/sdkFactTables.js +17 -0
  106. package/dist/generated/settingsSchemaFns.d.ts +13 -0
  107. package/dist/generated/settingsSchemaFns.js +75 -0
  108. package/dist/generated/toolNameTables.d.ts +1 -0
  109. package/dist/generated/toolNameTables.js +1 -0
  110. package/dist/headlessPermissionModeWire.d.ts +1 -1
  111. package/dist/headlessPermissionModeWire.js +1 -1
  112. package/dist/headlessReconnectWire.js +49 -20
  113. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  114. package/dist/hitl/allowRuleShadow.js +49 -8
  115. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  116. package/dist/hitl/approvalCompleteParked.js +14 -0
  117. package/dist/hitl/approvalEndingCause.d.ts +7 -0
  118. package/dist/hitl/approvalEndingCause.js +71 -0
  119. package/dist/hitl/approvalHolds.d.ts +12 -2
  120. package/dist/hitl/approvalHolds.js +53 -2
  121. package/dist/hitl/approvalsFeed.js +23 -11
  122. package/dist/hitl/askGateWire.d.ts +2 -1
  123. package/dist/hitl/askGateWire.js +26 -1
  124. package/dist/hitl/askParkRowRouting.js +1 -1
  125. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  126. package/dist/hitl/automaticAnswerVerdict.js +15 -10
  127. package/dist/hitl/crashConverged.js +2 -0
  128. package/dist/hitl/decisionConflict.d.ts +3 -0
  129. package/dist/hitl/decisionConflict.js +41 -0
  130. package/dist/hitl/decisionRefusal.d.ts +12 -0
  131. package/dist/hitl/decisionRefusal.js +63 -4
  132. package/dist/hitl/frameRouter.d.ts +0 -1
  133. package/dist/hitl/frameRouter.js +32 -57
  134. package/dist/hitl/gateLedger.d.ts +5 -0
  135. package/dist/hitl/gateLedger.js +21 -0
  136. package/dist/hitl/hitlBridge.d.ts +17 -2
  137. package/dist/hitl/hitlBridge.js +91 -55
  138. package/dist/hitl/hitlHostSurface.js +3 -11
  139. package/dist/hitl/livePendingAsk.d.ts +16 -6
  140. package/dist/hitl/livePendingAsk.js +36 -4
  141. package/dist/hitl/localAllowRule.d.ts +1 -0
  142. package/dist/hitl/localAllowRule.js +2 -2
  143. package/dist/hitl/noAllowCause.d.ts +2 -1
  144. package/dist/hitl/noAllowCause.js +3 -2
  145. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  146. package/dist/hitl/parkExpiryJudgements.js +46 -0
  147. package/dist/hitl/parkResolver.d.ts +4 -7
  148. package/dist/hitl/parkResolver.js +12 -34
  149. package/dist/hitl/parkRowBirthWait.d.ts +1 -0
  150. package/dist/hitl/parkRowBirthWait.js +2 -2
  151. package/dist/hitl/persistedRulesWire.js +5 -1
  152. package/dist/hitl/planReviewWire.d.ts +3 -2
  153. package/dist/hitl/planReviewWire.js +154 -50
  154. package/dist/hitl/replayedApproval.d.ts +9 -0
  155. package/dist/hitl/replayedApproval.js +139 -10
  156. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  157. package/dist/hitl/resumeRunningCard.js +15 -4
  158. package/dist/hitl/sessionPolicyDeliverable.js +8 -6
  159. package/dist/hitl/standingRows.d.ts +18 -0
  160. package/dist/hitl/standingRows.js +127 -0
  161. package/dist/hitl/toolApprovalWire.d.ts +39 -7
  162. package/dist/hitl/toolApprovalWire.js +351 -61
  163. package/dist/hookMatcherVerdict.d.ts +1 -9
  164. package/dist/hookMatcherVerdict.js +21 -61
  165. package/dist/hooksWireCaps.js +40 -8
  166. package/dist/host.d.ts +5 -0
  167. package/dist/host.js +3 -1
  168. package/dist/hostCallbackGuard.d.ts +2 -0
  169. package/dist/hostCallbackGuard.js +31 -0
  170. package/dist/index.d.ts +48 -17
  171. package/dist/index.js +36 -15
  172. package/dist/interactiveInterrupt.d.ts +8 -0
  173. package/dist/interactiveInterrupt.js +54 -0
  174. package/dist/limitsWire.d.ts +5 -0
  175. package/dist/limitsWire.js +49 -3
  176. package/dist/liveModelCatalog.d.ts +95 -0
  177. package/dist/liveModelCatalog.js +297 -32
  178. package/dist/mcpEngineLeg.d.ts +25 -0
  179. package/dist/mcpEngineLeg.js +71 -15
  180. package/dist/mcpPanel.js +2 -1
  181. package/dist/mcpProbeCapability.d.ts +0 -5
  182. package/dist/mcpProbeCapability.js +2 -12
  183. package/dist/mcpReconnect.d.ts +1 -3
  184. package/dist/mcpReconnect.js +10 -5
  185. package/dist/memoryComplianceCapability.d.ts +0 -5
  186. package/dist/memoryComplianceCapability.js +2 -12
  187. package/dist/memoryOriginCapability.d.ts +0 -5
  188. package/dist/memoryOriginCapability.js +2 -12
  189. package/dist/memorySpecWire.js +2 -2
  190. package/dist/memoryVerbsWire.d.ts +1 -1
  191. package/dist/memoryVerbsWire.js +4 -0
  192. package/dist/model/liveCatalogShape.d.ts +14 -0
  193. package/dist/model/liveCatalogShape.js +71 -0
  194. package/dist/model/modelSupplyRules.d.ts +1 -0
  195. package/dist/model/modelSupplyRules.js +30 -9
  196. package/dist/model/modelsPolicy.d.ts +21 -0
  197. package/dist/model/modelsPolicy.js +90 -0
  198. package/dist/modelIdentityResolvability.d.ts +2 -2
  199. package/dist/modelIdentityResolvability.js +14 -12
  200. package/dist/modelSwitchFallback.d.ts +69 -0
  201. package/dist/modelSwitchFallback.js +206 -0
  202. package/dist/noticePresentation.d.ts +68 -0
  203. package/dist/noticePresentation.js +247 -0
  204. package/dist/notifications.js +12 -11
  205. package/dist/outputStyleSeatCapability.d.ts +0 -2
  206. package/dist/outputStyleSeatCapability.js +2 -10
  207. package/dist/ownKey.d.ts +8 -0
  208. package/dist/ownKey.js +66 -0
  209. package/dist/panelReduce.d.ts +114 -0
  210. package/dist/panelReduce.js +1135 -0
  211. package/dist/panelStateHolder.d.ts +17 -0
  212. package/dist/panelStateHolder.js +201 -0
  213. package/dist/peerFrames.js +13 -9
  214. package/dist/peerLaneCapability.d.ts +0 -1
  215. package/dist/peerLaneCapability.js +2 -6
  216. package/dist/permissionModesCapability.d.ts +0 -5
  217. package/dist/permissionModesCapability.js +5 -16
  218. package/dist/permissionRuleIssue.js +0 -3
  219. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  220. package/dist/permissionRulesWriteCapability.js +2 -6
  221. package/dist/permissionsAllowGrantCapability.d.ts +0 -1
  222. package/dist/permissionsAllowGrantCapability.js +3 -9
  223. package/dist/permissionsDeclaration.d.ts +8 -0
  224. package/dist/permissionsDeclaration.js +101 -41
  225. package/dist/printPermissionOutcome.d.ts +12 -0
  226. package/dist/printPermissionOutcome.js +50 -0
  227. package/dist/printToolResultFrame.d.ts +1 -0
  228. package/dist/printToolResultFrame.js +5 -17
  229. package/dist/promptBlockedCopy.d.ts +5 -0
  230. package/dist/promptBlockedCopy.js +35 -0
  231. package/dist/promptDelivery.js +0 -8
  232. package/dist/protocolSegment.d.ts +9 -6
  233. package/dist/protocolSegment.js +31 -21
  234. package/dist/providerRejection.d.ts +4 -0
  235. package/dist/providerRejection.js +75 -14
  236. package/dist/replayBody.d.ts +12 -0
  237. package/dist/replayBody.js +25 -0
  238. package/dist/resumeRefusalCopy.d.ts +18 -1
  239. package/dist/resumeRefusalCopy.js +127 -32
  240. package/dist/retryStatus.d.ts +9 -1
  241. package/dist/retryStatus.js +9 -2
  242. package/dist/rewindArchiveCapability.d.ts +5 -14
  243. package/dist/rewindArchiveCapability.js +18 -61
  244. package/dist/rewindArchiveReading.d.ts +15 -0
  245. package/dist/rewindArchiveReading.js +56 -0
  246. package/dist/rewindEngineAction.d.ts +21 -0
  247. package/dist/rewindEngineAction.js +36 -0
  248. package/dist/rewindWireCaps.d.ts +2 -1
  249. package/dist/rewindWireCaps.js +1 -0
  250. package/dist/ruleCompileVerdict.d.ts +9 -1
  251. package/dist/ruleCompileVerdict.js +29 -4
  252. package/dist/runTerminal.d.ts +15 -12
  253. package/dist/runTerminal.js +60 -35
  254. package/dist/sandboxWire.js +13 -0
  255. package/dist/sdkRegistryTransit.d.ts +2 -1
  256. package/dist/sdkRegistryTransit.js +1 -0
  257. package/dist/sealedKeyCapability.d.ts +0 -5
  258. package/dist/sealedKeyCapability.js +3 -15
  259. package/dist/seam.js +4 -2
  260. package/dist/seatContract.d.ts +125 -34
  261. package/dist/seatContract.js +583 -179
  262. package/dist/sessionIdSegment.d.ts +1 -0
  263. package/dist/sessionIdSegment.js +11 -0
  264. package/dist/sessionMemoryErase.d.ts +1 -1
  265. package/dist/sessionMemoryErase.js +6 -1
  266. package/dist/sessionMemoryStatus.js +3 -2
  267. package/dist/sessionPolicyCapability.d.ts +0 -1
  268. package/dist/sessionPolicyCapability.js +2 -6
  269. package/dist/sessionReadRedactionCapability.d.ts +0 -5
  270. package/dist/sessionReadRedactionCapability.js +2 -13
  271. package/dist/sessionSyncFileHistory.d.ts +4 -0
  272. package/dist/sessionSyncFileHistory.js +66 -0
  273. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -2
  274. package/dist/sessionSyncFileHistoryCapability.js +2 -9
  275. package/dist/skillToolListsCapability.d.ts +0 -2
  276. package/dist/skillToolListsCapability.js +2 -9
  277. package/dist/skillsWireCaps.d.ts +4 -0
  278. package/dist/skillsWireCaps.js +66 -1
  279. package/dist/sqlEngineCapability.d.ts +0 -1
  280. package/dist/sqlEngineCapability.js +9 -14
  281. package/dist/steerPriorityCapability.d.ts +0 -2
  282. package/dist/steerPriorityCapability.js +3 -12
  283. package/dist/storePostureCapability.d.ts +1 -5
  284. package/dist/storePostureCapability.js +16 -22
  285. package/dist/streamDrainingLegs.d.ts +6 -0
  286. package/dist/streamDrainingLegs.js +23 -0
  287. package/dist/subagent/engineCompactWire.js +13 -38
  288. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  289. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  290. package/dist/subagent/engineSubagentOutput.js +5 -20
  291. package/dist/subagent/engineSubagentSteer.js +7 -5
  292. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  293. package/dist/subagent/engineSubagentTail.js +7 -32
  294. package/dist/subagentContentStore.js +7 -18
  295. package/dist/supportFloor.d.ts +1 -0
  296. package/dist/supportFloor.js +15 -14
  297. package/dist/systemReminderTag.d.ts +1 -0
  298. package/dist/systemReminderTag.js +8 -0
  299. package/dist/terminalStatuses.d.ts +30 -0
  300. package/dist/terminalStatuses.js +67 -0
  301. package/dist/toolHistoryMismatch.d.ts +0 -3
  302. package/dist/toolHistoryMismatch.js +3 -7
  303. package/dist/toolResult.d.ts +6 -1
  304. package/dist/toolResult.js +90 -37
  305. package/dist/toolResultContent.d.ts +2 -0
  306. package/dist/toolResultContent.js +63 -0
  307. package/dist/types/engineState.d.ts +2 -1
  308. package/dist/usageAnalytics.d.ts +146 -0
  309. package/dist/usageAnalytics.js +335 -0
  310. package/dist/userInvokedSkillsCapability.d.ts +0 -2
  311. package/dist/userInvokedSkillsCapability.js +2 -9
  312. package/dist/webSearchBackendCapability.d.ts +0 -1
  313. package/dist/webSearchBackendCapability.js +3 -7
  314. package/dist/webSearchWireCaps.js +3 -11
  315. package/dist/wireErrorTriage.d.ts +2 -0
  316. package/dist/wireErrorTriage.js +34 -5
  317. package/dist/wireFailureShape.d.ts +23 -2
  318. package/dist/wireFailureShape.js +88 -43
  319. package/dist/wireRefusalCopy.js +2 -18
  320. package/dist/workflowClient.js +7 -11
  321. package/dist/workflowsJournalCapability.d.ts +0 -1
  322. package/dist/workflowsJournalCapability.js +2 -6
  323. package/dist/writeProtectionCapability.d.ts +0 -1
  324. package/dist/writeProtectionCapability.js +5 -10
  325. package/docs/INTEGRATION-CLIENTS.md +2279 -27
  326. package/package.json +5 -5
  327. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  328. package/dist/engineCapsGenerationGuard.js +0 -19
  329. package/dist/panelRunningHistory.d.ts +0 -22
  330. package/dist/panelRunningHistory.js +0 -82
  331. package/dist/registryConflict.d.ts +0 -3
  332. package/dist/registryConflict.js +0 -44
@@ -1,29 +1,65 @@
1
- import { hasLedgerPositionKey } from './gateLedger.js';
1
+ import { APPROVAL_SETTLED_HOWS, hasLedgerPositionKey } from './gateLedger.js';
2
2
  import { readLivePendingRows } from './livePendingAsk.js';
3
3
  import { projectCrashConverged } from './crashConverged.js';
4
+ import { quoteUntrustedForSentence } from '../displayUntrusted.js';
5
+ import { readOwnDataValue } from '../ownKey.js';
4
6
  const live = (basis) => Object.freeze({ kind: 'live', basis });
5
7
  const unknown = (why) => Object.freeze({ kind: 'unknown', why });
6
- const decided = (cause) => Object.freeze(cause !== undefined ? { kind: 'decided', cause } : { kind: 'decided' });
8
+ const decided = (row) => Object.freeze(row === undefined
9
+ ? { kind: 'decided' }
10
+ : { kind: 'decided', cause: row.cause, ...(row.needsHumanReason !== undefined ? { needsHumanReason: row.needsHumanReason } : {}) });
11
+ const decidedSettled = (how) => Object.freeze({ kind: 'decided', settled: how });
7
12
  function approvalIdOf(frame) {
8
13
  const v = frame.approvalId;
9
14
  return typeof v === 'string' && v !== '' ? v : undefined;
10
15
  }
11
- function crashConvergedCauseOf(body, approvalId) {
16
+ function crashConvergedFactsOf(body, approvalId) {
12
17
  const projection = projectCrashConverged(body);
13
18
  if (projection === undefined)
14
19
  return undefined;
15
20
  for (const row of [...projection.resumeSafe, ...projection.needsHuman]) {
16
21
  if (row.approvalId === approvalId)
17
- return row.cause;
22
+ return { cause: row.cause, ...(row.needsHumanReason !== undefined ? { needsHumanReason: row.needsHumanReason } : {}) };
18
23
  }
19
24
  return undefined;
20
25
  }
26
+ export function settledApprovalDisposition(frame, settled) {
27
+ try {
28
+ if (typeof settled !== 'object' || settled === null || typeof settled.get !== 'function')
29
+ return undefined;
30
+ const id = approvalIdOf(frame);
31
+ if (id === undefined)
32
+ return undefined;
33
+ const how = settled.get(id);
34
+ return typeof how === 'string' && APPROVAL_SETTLED_HOWS.includes(how) ? decidedSettled(how) : undefined;
35
+ }
36
+ catch {
37
+ return undefined;
38
+ }
39
+ }
21
40
  export function replayedApprovalDisposition(frame, basis) {
22
41
  let approvalId;
42
+ let positioned;
23
43
  try {
24
44
  if (typeof frame !== 'object' || frame === null)
25
45
  return unknown('unreadable_frame');
26
- if (!hasLedgerPositionKey(frame))
46
+ positioned = hasLedgerPositionKey(frame);
47
+ }
48
+ catch {
49
+ return unknown('unreadable_frame');
50
+ }
51
+ let settledBasis;
52
+ try {
53
+ settledBasis = typeof basis === 'object' && basis !== null ? basis.settled : undefined;
54
+ }
55
+ catch {
56
+ settledBasis = undefined;
57
+ }
58
+ const early = settledApprovalDisposition(frame, settledBasis);
59
+ if (early !== undefined)
60
+ return early;
61
+ try {
62
+ if (!positioned)
27
63
  return live('live_leg');
28
64
  approvalId = approvalIdOf(frame);
29
65
  }
@@ -70,15 +106,15 @@ export function replayedApprovalDisposition(frame, basis) {
70
106
  }
71
107
  if (reading.kind === 'present' && reading.rows.some((r) => r.approvalId === approvalId))
72
108
  return live('pending_list');
73
- let cause;
109
+ let facts;
74
110
  try {
75
- cause = crashConvergedCauseOf(body, approvalId);
111
+ facts = crashConvergedFactsOf(body, approvalId);
76
112
  }
77
113
  catch {
78
- cause = undefined;
114
+ facts = undefined;
79
115
  }
80
- if (cause !== undefined)
81
- return decided(cause);
116
+ if (facts !== undefined)
117
+ return decided(facts);
82
118
  if (reading.kind === 'not_reported')
83
119
  return unknown('list_not_reported');
84
120
  if (reading.kind === 'malformed')
@@ -87,3 +123,96 @@ export function replayedApprovalDisposition(frame, basis) {
87
123
  return unknown('list_incomplete');
88
124
  return decided();
89
125
  }
126
+ const TOOL_NAME_MAX = 80;
127
+ const THIS_REQUEST = 'this approval request';
128
+ const sentenceInitial = (s) => s.charAt(0).toUpperCase() + s.slice(1);
129
+ const TOOL_STATE_NOT_SHOWN = 'Whether the tool had started is not shown here.';
130
+ const STOPPED_BY_CAUSE = Object.freeze({
131
+ crashed_before_park: 'the engine stopped unexpectedly',
132
+ shutdown_before_park: 'the engine was shut down in an orderly way',
133
+ });
134
+ const STATE_BY_REASON = Object.freeze({
135
+ pending_unsafe: 'waiting',
136
+ approved_then_interrupted: 'approved',
137
+ contradictory: 'unclear',
138
+ unstable_row: 'unclear',
139
+ });
140
+ const CRASH_CONVERGED_SENTENCE = Object.freeze({
141
+ waiting: (what, stopped) => `${sentenceInitial(what)} was still waiting when ${stopped}, so the engine denied it automatically; no decision was sent for it from here. ${TOOL_STATE_NOT_SHOWN}`,
142
+ approved: (what, stopped) => `${sentenceInitial(what)} had already been approved and may have been running when ${stopped}, so a side effect may have partly landed; the engine then marked it denied, and no decision was sent for it from here.`,
143
+ unclear: (what, stopped) => `${sentenceInitial(what)} was denied automatically when ${stopped}, but its record does not show reliably whether it had been approved or whether the tool had started; no decision was sent for it from here.`,
144
+ });
145
+ function crashConvergedStateOf(disposition) {
146
+ let reason;
147
+ try {
148
+ if (typeof disposition !== 'object' || disposition === null || !('needsHumanReason' in disposition))
149
+ return 'waiting';
150
+ reason = disposition.needsHumanReason;
151
+ }
152
+ catch {
153
+ return 'unclear';
154
+ }
155
+ if (reason === undefined)
156
+ return 'waiting';
157
+ return typeof reason === 'string' && Object.hasOwn(STATE_BY_REASON, reason) ? STATE_BY_REASON[reason] : 'unclear';
158
+ }
159
+ const SETTLED_PHRASE = Object.freeze({
160
+ answered: 'answered',
161
+ interrupted: 'dismissed',
162
+ closed_by_engine: 'closed by the engine',
163
+ });
164
+ const settledRepeat = (what, how) => `${sentenceInitial(what)} was ${SETTLED_PHRASE[how]} earlier, so this repeated copy of it was not raised as a new question and no decision was sent for it.`;
165
+ const decidedPlain = (what) => `${sentenceInitial(what)} is no longer listed by the engine as waiting for a decision, so no decision was sent for it.`;
166
+ export function replayedApprovalClosesCardFrame(disposition) {
167
+ try {
168
+ if (typeof disposition !== 'object' || disposition === null)
169
+ return false;
170
+ if (readOwnDataValue(disposition, 'kind') !== 'decided')
171
+ return false;
172
+ const cause = readOwnDataValue(disposition, 'cause');
173
+ return typeof cause === 'string' && Object.hasOwn(STOPPED_BY_CAUSE, cause);
174
+ }
175
+ catch {
176
+ return false;
177
+ }
178
+ }
179
+ const unconfirmed = (what) => `Whether ${what} is still waiting for a decision could not be confirmed, so no decision was sent for it.`;
180
+ function guardedGet(o, key) {
181
+ try {
182
+ if (typeof o !== 'object' || o === null)
183
+ return undefined;
184
+ return o[key];
185
+ }
186
+ catch {
187
+ return undefined;
188
+ }
189
+ }
190
+ function subjectOf(opts) {
191
+ const raw = guardedGet(opts, 'toolName');
192
+ if (typeof raw !== 'string')
193
+ return THIS_REQUEST;
194
+ let quoted;
195
+ try {
196
+ quoted = quoteUntrustedForSentence(raw, TOOL_NAME_MAX);
197
+ }
198
+ catch {
199
+ return THIS_REQUEST;
200
+ }
201
+ return quoted === undefined ? THIS_REQUEST : `the approval request for ${quoted}`;
202
+ }
203
+ export function replayedApprovalSentence(disposition, opts) {
204
+ const kind = guardedGet(disposition, 'kind');
205
+ if (kind === 'unknown')
206
+ return unconfirmed(subjectOf(opts));
207
+ if (kind !== 'decided')
208
+ return undefined;
209
+ const what = subjectOf(opts);
210
+ const cause = guardedGet(disposition, 'cause');
211
+ if (typeof cause === 'string' && Object.hasOwn(STOPPED_BY_CAUSE, cause)) {
212
+ return CRASH_CONVERGED_SENTENCE[crashConvergedStateOf(disposition)](what, STOPPED_BY_CAUSE[cause]);
213
+ }
214
+ const settled = guardedGet(disposition, 'settled');
215
+ if (typeof settled === 'string' && Object.hasOwn(SETTLED_PHRASE, settled))
216
+ return settledRepeat(what, settled);
217
+ return decidedPlain(what);
218
+ }
@@ -17,6 +17,7 @@ export interface ResumeRunningCardOption {
17
17
  }
18
18
  export declare function resumeRunningLivenessRow(msSinceLastActivity: number | null | undefined): string | null;
19
19
  export declare function resumeRunningQuestionText(i: ResumeRunningCardInput): string;
20
+ export declare function runningAttachOffered(canAttach: boolean | undefined): boolean;
20
21
  export declare function resumeRunningOptions(i: ResumeRunningCardInput): ResumeRunningCardOption[];
21
22
  export declare function resumeChoiceFromLabels(selected: readonly string[] | null | undefined): ResumeRunningChoice;
22
23
  export declare const RESUME_RUNNING_NO_UI_EXIT_CODE = 75;
@@ -26,4 +27,5 @@ export declare function resumeRunningNoUiGuidance(i: {
26
27
  sessionId?: string | null;
27
28
  }): string;
28
29
  export declare function resumeAttachReplayDisclosure(taskId: string): string;
30
+ export declare function resumeRunningCancelConfirmedRow(taskId: string): string;
29
31
  export declare function resumeRunningCancelUnconfirmedRow(taskId: string): string;
@@ -14,6 +14,9 @@ export function resumeRunningQuestionText(i) {
14
14
  const liveness = resumeRunningLivenessRow(i.msSinceLastActivity);
15
15
  return liveness === null ? head : `${head}\n${liveness}`;
16
16
  }
17
+ export function runningAttachOffered(canAttach) {
18
+ return canAttach === true;
19
+ }
17
20
  export function resumeRunningOptions(i) {
18
21
  const options = [
19
22
  {
@@ -21,7 +24,7 @@ export function resumeRunningOptions(i) {
21
24
  description: 'Leaves the run alone. It keeps executing on the engine, but this screen will not show it and it will not be listed here — your next message runs into it again, and sema asks you then.',
22
25
  },
23
26
  ];
24
- if (i.canAttach) {
27
+ if (runningAttachOffered(i.canAttach)) {
25
28
  options.push({
26
29
  label: RESUME_CHOICE_ATTACH_LABEL,
27
30
  description: 'Follows that run from here: sema replays it from the engine ledger and keeps streaming it into this conversation. ' +
@@ -65,8 +68,16 @@ export function resumeAttachReplayDisclosure(taskId) {
65
68
  `The replayed turns are not billed into this session's cost again either — the engine's own record ` +
66
69
  `(GET /v1/runs/${taskId}) is the authority on what that run really spent.`);
67
70
  }
71
+ function cancelRow(taskId, confirmed) {
72
+ return confirmed
73
+ ? `The engine accepted the cancel for run ${taskId} on your request. A cancel finishes on the engine's side, so that run may need a moment to stop.`
74
+ : `sema: the cancel for run ${taskId} did not come back confirmed, so that run may still be executing. ` +
75
+ `This screen does not list it — read its real state on the engine (GET /v1/runs/${taskId}) before ` +
76
+ `assuming this session is free.`;
77
+ }
78
+ export function resumeRunningCancelConfirmedRow(taskId) {
79
+ return cancelRow(taskId, true);
80
+ }
68
81
  export function resumeRunningCancelUnconfirmedRow(taskId) {
69
- return (`sema: the cancel for run ${taskId} did not come back confirmed, so that run may still be executing. ` +
70
- `This screen does not list it — read its real state on the engine (GET /v1/runs/${taskId}) before ` +
71
- `assuming this session is free.`);
82
+ return cancelRow(taskId, false);
72
83
  }
@@ -1,7 +1,7 @@
1
1
  import { CONFIG_LEGACY_TOOL_NAME, RULES_LEGACY_TOOL_NAME } from '../engineErrorCodes.js';
2
2
  import { rosterMountedNames } from '../rosterMountedNames.js';
3
3
  import { ruleCompileVerdict } from '../ruleCompileVerdict.js';
4
- import { protocolSegmentOf } from '../protocolSegment.js';
4
+ import { ruleToolNameVerdictOf } from '../protocolSegment.js';
5
5
  import { PREFIXES_IN_PROSE, REFUSED_NAME_CLASSES, REFUSED_NAME_FIX, RULES_LEGACY_TOOL_NAME_WRITE_NOTE } from './refusedToolNameProse.js';
6
6
  import { CORE_PROTOCOL_PREFIXES, CORE_RETIRED_TOOL_CURRENT_NAMES } from '../generated/toolNameTables.js';
7
7
  import { isEngineRefusedToolName } from '../engineRefusedToolName.js';
@@ -96,18 +96,20 @@ export function sessionPolicyDeliverable(behavior, rules, opts) {
96
96
  }
97
97
  let why = withheldWhyOf(r);
98
98
  if (why === undefined) {
99
- const grammar = ruleCompileVerdict(r, 'deny');
99
+ const grammar = ruleCompileVerdict(r, 'deny').kind;
100
100
  if (grammar === 'unknown')
101
101
  return unreadable();
102
102
  if (grammar === 'refused')
103
103
  why = 'not_a_tool_name';
104
104
  }
105
105
  if (why === undefined && COVERING_NAMESPACE_PREFIXES.some((p) => r.startsWith(p))) {
106
- const segment = protocolSegmentOf(r);
107
- if (segment.kind === 'empty' || segment.kind === 'unminted')
108
- why = 'not_a_tool_name';
109
- else if (segment.kind === 'unknown')
106
+ const verdict = ruleToolNameVerdictOf(r);
107
+ if (verdict.kind === 'unknown')
110
108
  return unreadable();
109
+ if (verdict.kind === 'unmintable_segment')
110
+ why = 'not_a_tool_name';
111
+ else if (verdict.kind === 'retired' || verdict.kind === 'unprefixed_namespace')
112
+ why = 'legacy_tool_name';
111
113
  }
112
114
  if (why === undefined && mounted !== undefined && !mounted.has(r))
113
115
  why = 'not_in_roster';
@@ -0,0 +1,18 @@
1
+ export type StandingRowWhy = 'given' | 'card_unreadable' | 'remember_refused' | 'remember_unreadable' | 'route_cannot_carry' | 'classes_unreadable' | 'not_deployment_list_question' | 'evidence_unreadable' | 'offers_unreadable' | 'engine_lane_closed' | 'args_unavailable' | 'grant_binding' | 'tool_name_unreadable' | 'rule_cannot_clear' | 'host_fact_missing' | 'face_not_generic' | 'rule_not_sent';
2
+ export type StandingPersistentRow = 'engine_offer' | 'local_whole_tool' | 'none';
3
+ export interface StandingRowsWhy {
4
+ readonly session: StandingRowWhy;
5
+ readonly persistent: StandingRowWhy;
6
+ readonly deploymentList: StandingRowWhy;
7
+ }
8
+ export interface StandingRows {
9
+ readonly sessionRow: boolean;
10
+ readonly persistentRow: StandingPersistentRow;
11
+ readonly deploymentListSessionRow: boolean;
12
+ readonly why: StandingRowsWhy;
13
+ }
14
+ export interface StandingRowsHostFacts {
15
+ readonly cardFace?: string;
16
+ readonly wholeToolRuleSent?: boolean;
17
+ }
18
+ export declare function standingRowsOf(card: object | null | undefined, host?: StandingRowsHostFacts | null): StandingRows;
@@ -0,0 +1,127 @@
1
+ import { readAskClassPairState } from './askClassPair.js';
2
+ import { automaticAnswerVerdict } from './automaticAnswerVerdict.js';
3
+ import { readRuleOffers } from './toolApprovalWire.js';
4
+ const DEPLOYMENT_LIST_ASK_CLASSES = Object.freeze(['ask_rule']);
5
+ const UNREADABLE = Symbol('unreadable');
6
+ function ownData(v, key) {
7
+ try {
8
+ const d = Object.getOwnPropertyDescriptor(v, key);
9
+ return d !== undefined && 'value' in d ? d.value : undefined;
10
+ }
11
+ catch {
12
+ return undefined;
13
+ }
14
+ }
15
+ function hasKey(v, key) {
16
+ try {
17
+ return { inCard: key in v };
18
+ }
19
+ catch {
20
+ return UNREADABLE;
21
+ }
22
+ }
23
+ function present(v, key) {
24
+ try {
25
+ const inCard = key in v;
26
+ return { inCard, value: inCard ? v[key] : undefined };
27
+ }
28
+ catch {
29
+ return UNREADABLE;
30
+ }
31
+ }
32
+ function freezeRows(sessionRow, persistentRow, deploymentListSessionRow, why) {
33
+ return Object.freeze({ sessionRow, persistentRow, deploymentListSessionRow, why: Object.freeze({ ...why }) });
34
+ }
35
+ function allClosed(why) {
36
+ return freezeRows(false, 'none', false, { session: why, persistent: why, deploymentList: why });
37
+ }
38
+ function persistentRowOf(card, host, evidenceUnreadable) {
39
+ if (evidenceUnreadable)
40
+ return { row: 'none', why: 'evidence_unreadable' };
41
+ for (const key of ['ruleOffers', 'ruleOffersReadOnly']) {
42
+ const p = hasKey(card, key);
43
+ if (p === UNREADABLE)
44
+ return UNREADABLE;
45
+ if (!p.inCard)
46
+ continue;
47
+ const offers = readRuleOffers(ownData(card, key));
48
+ if (offers === undefined || offers.length === 0)
49
+ return { row: 'none', why: 'offers_unreadable' };
50
+ return { row: 'engine_offer', why: 'given' };
51
+ }
52
+ const absence = present(card, 'ruleOffersAbsence');
53
+ if (absence === UNREADABLE)
54
+ return UNREADABLE;
55
+ if (absence.inCard)
56
+ return { row: 'none', why: 'engine_lane_closed' };
57
+ const blind = present(card, 'argsUnavailable');
58
+ if (blind === UNREADABLE)
59
+ return UNREADABLE;
60
+ if (blind.inCard)
61
+ return { row: 'none', why: 'args_unavailable' };
62
+ if (ownData(card, 'grantBinding') !== 'none')
63
+ return { row: 'none', why: 'grant_binding' };
64
+ const tool = ownData(card, 'toolName');
65
+ if (typeof tool !== 'string' || tool.length === 0)
66
+ return { row: 'none', why: 'tool_name_unreadable' };
67
+ if (automaticAnswerVerdict(card, 'standing_rule').kind !== 'may_answer')
68
+ return { row: 'none', why: 'rule_cannot_clear' };
69
+ if (typeof host !== 'object' || host === null)
70
+ return { row: 'none', why: 'host_fact_missing' };
71
+ const face = ownData(host, 'cardFace');
72
+ if (typeof face !== 'string')
73
+ return { row: 'none', why: 'host_fact_missing' };
74
+ if (face !== 'generic')
75
+ return { row: 'none', why: 'face_not_generic' };
76
+ const sent = ownData(host, 'wholeToolRuleSent');
77
+ if (typeof sent !== 'boolean')
78
+ return { row: 'none', why: 'host_fact_missing' };
79
+ if (!sent)
80
+ return { row: 'none', why: 'rule_not_sent' };
81
+ return { row: 'local_whole_tool', why: 'given' };
82
+ }
83
+ export function standingRowsOf(card, host) {
84
+ if (typeof card !== 'object' || card === null)
85
+ return allClosed('card_unreadable');
86
+ try {
87
+ const refused = present(card, 'rememberRefused');
88
+ if (refused === UNREADABLE)
89
+ return allClosed('card_unreadable');
90
+ if (refused.inCard)
91
+ return allClosed(refused.value === true ? 'remember_refused' : 'remember_unreadable');
92
+ const evidence = present(card, 'unreadableEvidence');
93
+ if (evidence === UNREADABLE)
94
+ return allClosed('card_unreadable');
95
+ let evidenceUnreadable = false;
96
+ if (evidence.inCard) {
97
+ const list = ownData(card, 'unreadableEvidence');
98
+ if (!Array.isArray(list) || !list.every((k) => typeof k === 'string'))
99
+ return allClosed('card_unreadable');
100
+ if (list.includes('rememberRefused'))
101
+ return allClosed('remember_unreadable');
102
+ evidenceUnreadable = list.length > 0;
103
+ }
104
+ const sessionRow = ownData(card, 'allowSessionCarried') === true;
105
+ const sessionWhy = sessionRow ? 'given' : 'route_cannot_carry';
106
+ let deploymentList;
107
+ if (!sessionRow) {
108
+ deploymentList = 'route_cannot_carry';
109
+ }
110
+ else {
111
+ const pair = readAskClassPairState(card);
112
+ deploymentList =
113
+ pair.state !== 'pair'
114
+ ? 'classes_unreadable'
115
+ : pair.classes.every((c) => DEPLOYMENT_LIST_ASK_CLASSES.includes(c))
116
+ ? 'given'
117
+ : 'not_deployment_list_question';
118
+ }
119
+ const persistent = persistentRowOf(card, host, evidenceUnreadable);
120
+ if (persistent === UNREADABLE)
121
+ return allClosed('card_unreadable');
122
+ return freezeRows(sessionRow, persistent.row, deploymentList === 'given', { session: sessionWhy, persistent: persistent.why, deploymentList });
123
+ }
124
+ catch {
125
+ return allClosed('card_unreadable');
126
+ }
127
+ }
@@ -6,7 +6,7 @@ import { type DenyAttributionRefusalDetail } from '../wireRefusalCopy.js';
6
6
  import { type ApprovalDecidedByReading } from '../approvalDecidedByCapability.js';
7
7
  import { type DecideReceiptView } from '../decideReceipt.js';
8
8
  import { RULE_OFFER_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_UNCOVERED_REASONS, RULE_OFFERS_ABSENCE_REASONS } from '@sema-agent/sdk';
9
- import type { ApprovalDecidedBy, ToolApprovalRespondAck, PersistedRuleAnchor as SdkPersistedRuleAnchor, RuleOfferMatch as SdkRuleOfferMatch, RuleOfferBatchMember as SdkRuleOfferBatchMember, RuleOfferUncoveredDetail as SdkRuleOfferUncoveredDetail, RuleOfferUncoveredReason as SdkRuleOfferUncoveredReason, AskOrigin as SdkAskOrigin, RuleOffersAbsence as SdkRuleOffersAbsence, DenialLimitKind as SdkDenialLimitKind, DenialLimitFallback as SdkDenialLimitFallback } from '@sema-agent/sdk';
9
+ import type { ApprovalDecidedBy, ApprovalSettleCause, ToolApprovalRespondAck, PersistedRuleAnchor as SdkPersistedRuleAnchor, RuleOfferMatch as SdkRuleOfferMatch, RuleOfferBatchMember as SdkRuleOfferBatchMember, RuleOfferUncoveredDetail as SdkRuleOfferUncoveredDetail, RuleOfferUncoveredReason as SdkRuleOfferUncoveredReason, AskOrigin as SdkAskOrigin, RuleOffersAbsence as SdkRuleOffersAbsence, DenialLimitKind as SdkDenialLimitKind, DenialLimitFallback as SdkDenialLimitFallback } from '@sema-agent/sdk';
10
10
  export declare function isFsApprovalGate(gate: {
11
11
  kind?: unknown;
12
12
  toolName?: unknown;
@@ -40,8 +40,9 @@ export type FsApprovalOutcome = {
40
40
  stage: HitlFailureStage;
41
41
  gatedCallId?: string | undefined;
42
42
  reason: string;
43
- code?: 'no_pending' | undefined;
43
+ code?: 'no_pending' | 'wrong_gate' | undefined;
44
44
  errorCode?: string | undefined;
45
+ blockedBy?: string | undefined;
45
46
  retriable?: true;
46
47
  safetyCode?: HitlSafetyCode | undefined;
47
48
  retryExhausted?: true;
@@ -68,7 +69,6 @@ export type DenialLimitKind = SdkDenialLimitKind;
68
69
  export type DenialLimitFallback = SdkDenialLimitFallback;
69
70
  export { RULE_OFFERS_ABSENCE_REASONS };
70
71
  export declare const ASK_ORIGIN_WORDS: readonly string[];
71
- export declare const APPROVAL_MANDATE_WORDS: readonly ["operator_always", "tool_marks", "probe_mandate", "probe_unanswered", "write_protection", "write_protection_unresolved"];
72
72
  export type WireRuleOffer = {
73
73
  kind: 'single';
74
74
  rule: string;
@@ -137,11 +137,11 @@ export interface ApprovalCardRequest {
137
137
  ruleOffersReadOnly?: RuleOffer[];
138
138
  inputHasBidi?: true;
139
139
  hasBidiControls?: true;
140
- persistedRuleShadowed?: string;
141
140
  allowRuleShadow?: ApprovalAllowRuleShadow;
142
141
  probeCause?: unknown;
143
142
  probeReason?: string;
144
143
  rememberRefused?: true;
144
+ allowSessionCarried?: true;
145
145
  ruleEvidence?: unknown;
146
146
  requiresRealApproval?: true;
147
147
  irreversibleParkGate?: true;
@@ -158,6 +158,8 @@ export interface ApprovalCardRequest {
158
158
  askClass?: string;
159
159
  classes?: readonly string[];
160
160
  boundGrants?: BoundSkillGrantsWire;
161
+ grantBinding?: ApprovalGrantBinding;
162
+ unreadableEvidence?: readonly string[];
161
163
  classifierNoRuling?: string;
162
164
  priorCardsForCall?: readonly ApprovalPriorCard[];
163
165
  }
@@ -177,6 +179,9 @@ export declare function hasApprovalCardPortFor(sessionKey: string): boolean;
177
179
  export declare function approvalCardPortFor(sessionKey: string): ApprovalCardPort | null;
178
180
  export declare function _resetApprovalCardPortForTest(): void;
179
181
  export declare function surfaceApprovalCard(req: ApprovalCardRequest): Promise<ApprovalCardDecision>;
182
+ declare const REMEMBER_REFUSAL_CODES: readonly ["remember_not_in_proof", "remember_requires_binding", "capability.store_required", "decide.workflow_remember_unsupported", "decide.parked_remember_unsupported"];
183
+ export type RememberRefusalCode = (typeof REMEMBER_REFUSAL_CODES)[number];
184
+ export declare function rememberRefusalOf(error: unknown): RememberRefusalCode | undefined;
180
185
  export declare function surfaceFsApprovalAndDecide(deps: FsApprovalWireDeps, taskId: string, argsByCall: Map<string, unknown>, signal?: AbortSignal, parkGatedCallId?: string): Promise<FsApprovalOutcome>;
181
186
  export interface BoundSkillGrantsWire {
182
187
  readonly skill: string | null;
@@ -192,6 +197,7 @@ export interface ToolApprovalFrame {
192
197
  args?: unknown;
193
198
  argsOmitted?: boolean;
194
199
  outcome?: 'allowed' | 'denied' | 'expired';
200
+ cause?: ApprovalSettleCause;
195
201
  sourceTaskId?: string;
196
202
  fromSubagent?: true;
197
203
  sourceAgentName?: string;
@@ -232,7 +238,7 @@ export interface ToolApprovalDelegation {
232
238
  depth: number;
233
239
  agentName?: string;
234
240
  }
235
- export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "readRootCandidate", "mandated", "mandate", "origin", "askClass", "classes", "inputHasBidi", "parked", "persistedRuleShadowed", "allowRuleShadowed", "probeCause", "probeReason", "rememberRefused", "boundGrantDigest", "boundGrants", "classifierNoRuling", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome"];
241
+ export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "readRootCandidate", "mandated", "mandate", "origin", "askClass", "classes", "inputHasBidi", "parked", "persistedRuleShadowed", "allowRuleShadowed", "probeCause", "probeReason", "rememberRefused", "boundGrantDigest", "boundGrants", "classifierNoRuling", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome", "cause"];
236
242
  export interface ApprovalMandatedFacts {
237
243
  readonly mandated?: true;
238
244
  readonly ruleOffersAbsence?: string;
@@ -242,7 +248,7 @@ export declare function approvalIsMandated(v: ApprovalMandatedFacts | undefined
242
248
  export declare function readApprovalMandate(v: {
243
249
  readonly mandate?: string;
244
250
  } | undefined | null): ApprovalMandateWord | undefined;
245
- export declare function toolPermissionRequestAskBits(card: object | null | undefined): Pick<ToolPermissionRequest, 'mandated' | 'mandate' | 'origin' | 'ruleOffersAbsence' | 'askClass' | 'classes'>;
251
+ export declare function toolPermissionRequestAskBits(card: object | null | undefined): Pick<ToolPermissionRequest, 'mandated' | 'mandate' | 'origin' | 'ruleOffersAbsence' | 'askClass' | 'classes' | 'rememberRefused'>;
246
252
  export declare function isFromSubagent(frame: ToolApprovalFrame): boolean;
247
253
  export type ToolApprovalRespondDecision = 'allow' | 'allow_session' | 'deny';
248
254
  export interface RespondToolApprovalOpts {
@@ -296,6 +302,12 @@ interface ToolApprovalRespondRefusalFields {
296
302
  status?: number;
297
303
  errorCode?: string;
298
304
  message?: string;
305
+ retriable?: true;
306
+ extra?: {
307
+ readonly cause?: string;
308
+ readonly field?: string;
309
+ };
310
+ unreadable?: true;
299
311
  }
300
312
  export type ToolApprovalRespondRefusal = (ToolApprovalRespondRefusalFields & {
301
313
  status: number;
@@ -307,7 +319,9 @@ export type ToolApprovalRespondRefusal = (ToolApprovalRespondRefusalFields & {
307
319
  export declare function readToolApprovalRespondRefusal(err: unknown): ToolApprovalRespondRefusal | undefined;
308
320
  export declare function isToolApprovalFrame(ev: unknown): ev is ToolApprovalFrame;
309
321
  export declare function askProbeReasonDetail(card: Pick<ApprovalCardRequest, 'probeReason' | 'probeCause'> | null | undefined): string | undefined;
322
+ export declare function readApprovalRememberRefused(v: unknown): boolean;
310
323
  export declare function readApprovalBoundGrants(v: unknown): BoundSkillGrantsWire | undefined;
324
+ export type ApprovalGrantBinding = 'bound' | 'none' | 'unreadable';
311
325
  export declare function readApprovalClassifierNoRuling(v: unknown): string | undefined;
312
326
  export declare function classifierNoRulingDetail(word: string | undefined): string;
313
327
  export declare function approvalBoundGrantsDetail(grants: BoundSkillGrantsWire | null | undefined): string | undefined;
@@ -315,6 +329,8 @@ export declare function approvalPriorCardsDetail(card: Pick<ApprovalCardRequest,
315
329
  export declare function readDenialLimitFallback(v: unknown): DenialLimitFallback | undefined;
316
330
  export declare function readRuleOffers(v: unknown): RuleOffer[] | undefined;
317
331
  export declare function readRuleOfferSupply(offers: unknown): RuleOffer[] | undefined;
332
+ export type ApprovalCardV1Facts = Pick<ApprovalCardRequest, 'toolName' | 'args'> & Pick<ApprovalCardRequest, 'toolCallId' | 'workerBadge' | 'wireNote' | 'argsUnavailable' | 'governanceForced' | 'delegation' | 'ruleOffersReadOnly' | 'inputHasBidi' | 'allowRuleShadow' | 'probeCause' | 'rememberRefused' | 'ruleEvidence' | 'requiresRealApproval' | 'ruleOffersAbsence' | 'denialLimitFallback' | 'askClass' | 'classes' | 'grantBinding' | 'unreadableEvidence'>;
333
+ export declare function approvalCardFactsOfV1(card: object | null | undefined): Readonly<ApprovalCardV1Facts> | undefined;
318
334
  export interface ToolApprovalFrameLaneOpts {
319
335
  approvalDecisionNoteCapable?: boolean;
320
336
  respondFreeFormRulesCapable?: boolean;
@@ -323,4 +339,20 @@ export interface ToolApprovalFrameLaneOpts {
323
339
  windowIsCurrent?: boolean;
324
340
  argsUnavailable?: true;
325
341
  }
326
- export declare function surfaceToolApprovalFrameAndRespond(frame: ToolApprovalFrame, respond: RespondToolApprovalFn, streamArgs: unknown | undefined, signal?: AbortSignal, lane?: ToolApprovalFrameLaneOpts): Promise<ToolApprovalFrameOutcome>;
342
+ export declare function surfaceToolApprovalFrameAndRespond(frame: ToolApprovalFrame, respond: RespondToolApprovalFn, streamArgs: unknown | undefined, signal?: AbortSignal, lane?: ToolApprovalFrameLaneOpts, run?: {
343
+ readonly taskId?: string;
344
+ readonly sessionId?: string;
345
+ }): Promise<ToolApprovalFrameOutcome>;
346
+ export interface ApprovalHolderIdentity {
347
+ readonly approvalId?: string;
348
+ readonly taskId?: string;
349
+ readonly toolCallId?: string;
350
+ readonly sessionId?: string;
351
+ }
352
+ export type ApprovalHolderJoin = {
353
+ readonly kind: 'joined';
354
+ readonly outcome: ToolApprovalFrameOutcome;
355
+ } | {
356
+ readonly kind: 'free';
357
+ };
358
+ export declare function joinApprovalHolder(identity: ApprovalHolderIdentity, signal?: AbortSignal): Promise<ApprovalHolderJoin>;