@sema-agent/client-core 0.93.1 → 0.95.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 (321) hide show
  1. package/CHANGELOG.md +554 -0
  2. package/README.md +89 -55
  3. package/dist/adapt/arms.js +13 -11
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.js +2 -2
  6. package/dist/adapt/wireShapes.js +3 -8
  7. package/dist/adapter/activeRunSelfHeal.d.ts +8 -3
  8. package/dist/adapter/activeRunSelfHeal.js +20 -12
  9. package/dist/adapter/downstream/eventToSdkMessage.js +24 -17
  10. package/dist/adapter/downstream/terminalToSdkResult.js +13 -6
  11. package/dist/adapter/runStream.js +2 -1
  12. package/dist/adapter/types.d.ts +7 -0
  13. package/dist/adapter/types.js +15 -0
  14. package/dist/agentSession/backgroundView.js +5 -1
  15. package/dist/agentSession/engineAgentRegistryRead.js +2 -1
  16. package/dist/agentSession/engineSessionBackgroundStop.js +5 -3
  17. package/dist/agentsWireCaps.d.ts +17 -0
  18. package/dist/agentsWireCaps.js +111 -1
  19. package/dist/approvalDecidedByCapability.d.ts +0 -1
  20. package/dist/approvalDecidedByCapability.js +2 -7
  21. package/dist/approvalReachWire.d.ts +18 -0
  22. package/dist/approvalReachWire.js +58 -0
  23. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  24. package/dist/approvalsStreamLiveCapability.js +15 -14
  25. package/dist/atMostOnce.d.ts +8 -0
  26. package/dist/atMostOnce.js +36 -0
  27. package/dist/attachmentSeatCapability.d.ts +0 -1
  28. package/dist/attachmentSeatCapability.js +0 -3
  29. package/dist/attachmentsWireCaps.js +11 -6
  30. package/dist/bashExitReading.d.ts +10 -0
  31. package/dist/bashExitReading.js +12 -0
  32. package/dist/callerCwdCapability.d.ts +15 -0
  33. package/dist/callerCwdCapability.js +42 -0
  34. package/dist/centerWiringCapability.d.ts +1 -3
  35. package/dist/centerWiringCapability.js +18 -21
  36. package/dist/classifierStatus.js +4 -4
  37. package/dist/cloudConfigWireCaps.js +43 -21
  38. package/dist/compensations.js +1 -1
  39. package/dist/controlRouter.js +3 -10
  40. package/dist/coreValuePorts.d.ts +64 -1
  41. package/dist/coreValuePorts.js +30 -0
  42. package/dist/cycleOrder.d.ts +15 -0
  43. package/dist/cycleOrder.js +45 -0
  44. package/dist/decideFailureNote.js +4 -1
  45. package/dist/decideReceipt.d.ts +2 -1
  46. package/dist/decideReceipt.js +41 -13
  47. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  48. package/dist/declared/supportFloorDeclared.js +5 -0
  49. package/dist/detachWire.d.ts +1 -4
  50. package/dist/detachWire.js +1 -1
  51. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  52. package/dist/deviceExecutorManagementCapability.js +36 -40
  53. package/dist/deviceFlowPolling.d.ts +5 -0
  54. package/dist/deviceFlowPolling.js +28 -0
  55. package/dist/deviceRebind.d.ts +88 -0
  56. package/dist/deviceRebind.js +242 -0
  57. package/dist/displayUntrusted.d.ts +1 -0
  58. package/dist/displayUntrusted.js +963 -30
  59. package/dist/engineAgentAbsence.d.ts +2 -2
  60. package/dist/engineAgentPanelStore.d.ts +8 -18
  61. package/dist/engineAgentPanelStore.js +19 -537
  62. package/dist/engineCapReader.d.ts +6 -6
  63. package/dist/engineCapReader.js +30 -43
  64. package/dist/engineCapsCache.d.ts +7 -2
  65. package/dist/engineCapsCache.js +64 -26
  66. package/dist/engineCredentialRequirement.d.ts +9 -0
  67. package/dist/engineCredentialRequirement.js +23 -0
  68. package/dist/engineEnvSourcing.d.ts +53 -0
  69. package/dist/engineEnvSourcing.js +81 -0
  70. package/dist/engineErrorCodes.d.ts +19 -4
  71. package/dist/engineErrorCodes.js +39 -21
  72. package/dist/engineIdentity.js +2 -0
  73. package/dist/engineNoticeCodes.d.ts +22 -2
  74. package/dist/engineNoticeCodes.js +73 -6
  75. package/dist/engineRefusedToolName.d.ts +1 -0
  76. package/dist/engineRefusedToolName.js +8 -0
  77. package/dist/engineWireSdk.js +2 -2
  78. package/dist/executionLaneCapability.d.ts +2 -3
  79. package/dist/executionLaneCapability.js +28 -28
  80. package/dist/fileHistoryCaptureCapability.d.ts +0 -1
  81. package/dist/fileHistoryCaptureCapability.js +13 -12
  82. package/dist/fileHistoryLegNotice.d.ts +14 -2
  83. package/dist/fileHistoryLegNotice.js +101 -15
  84. package/dist/fleet/fleetLedger.d.ts +2 -0
  85. package/dist/fleet/fleetLedger.js +74 -52
  86. package/dist/fleet/fleetProjection.d.ts +0 -3
  87. package/dist/fleet/fleetProjection.js +9 -16
  88. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  89. package/dist/fleetAgentPanelProjection.js +7 -197
  90. package/dist/fleetAgentRowLike.d.ts +16 -0
  91. package/dist/fleetAgentRowLike.js +1 -0
  92. package/dist/gateOutcome.d.ts +2 -1
  93. package/dist/gateOutcome.js +33 -18
  94. package/dist/gateVocabulary.js +1 -1
  95. package/dist/generated/engineAskFaceTables.d.ts +3 -0
  96. package/dist/generated/engineAskFaceTables.js +12 -0
  97. package/dist/generated/engineFactTables.d.ts +4 -2
  98. package/dist/generated/engineFactTables.js +13 -0
  99. package/dist/generated/engineNoticeTables.d.ts +5 -0
  100. package/dist/generated/engineNoticeTables.js +7 -0
  101. package/dist/generated/sdkFactTables.d.ts +5 -0
  102. package/dist/generated/sdkFactTables.js +34 -0
  103. package/dist/generated/settingsSchemaFns.d.ts +10 -0
  104. package/dist/generated/settingsSchemaFns.js +22 -0
  105. package/dist/generated/settingsSchemaTables.d.ts +3 -0
  106. package/dist/generated/settingsSchemaTables.js +3 -0
  107. package/dist/headlessPermissionModeWire.d.ts +2 -2
  108. package/dist/headlessPermissionModeWire.js +11 -21
  109. package/dist/headlessReconnectWire.js +49 -20
  110. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  111. package/dist/hitl/allowRuleShadow.js +49 -8
  112. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  113. package/dist/hitl/approvalCompleteParked.js +14 -0
  114. package/dist/hitl/approvalEndingCause.d.ts +5 -0
  115. package/dist/hitl/approvalEndingCause.js +61 -0
  116. package/dist/hitl/approvalHolds.d.ts +46 -0
  117. package/dist/hitl/approvalHolds.js +140 -0
  118. package/dist/hitl/approvalOutcomeNote.js +2 -1
  119. package/dist/hitl/approvalResolution.js +9 -1
  120. package/dist/hitl/approvalsFeed.js +23 -6
  121. package/dist/hitl/askGateWire.d.ts +2 -1
  122. package/dist/hitl/askGateWire.js +29 -1
  123. package/dist/hitl/automaticAnswerVerdict.d.ts +8 -2
  124. package/dist/hitl/automaticAnswerVerdict.js +71 -23
  125. package/dist/hitl/crashConverged.js +2 -0
  126. package/dist/hitl/decisionConflict.d.ts +3 -0
  127. package/dist/hitl/decisionConflict.js +43 -0
  128. package/dist/hitl/decisionRefusal.d.ts +23 -0
  129. package/dist/hitl/decisionRefusal.js +88 -0
  130. package/dist/hitl/frameRouter.d.ts +10 -0
  131. package/dist/hitl/frameRouter.js +71 -32
  132. package/dist/hitl/gateLedger.d.ts +8 -0
  133. package/dist/hitl/gateLedger.js +38 -0
  134. package/dist/hitl/hitlBridge.d.ts +14 -3
  135. package/dist/hitl/hitlBridge.js +75 -62
  136. package/dist/hitl/hitlHostSurface.d.ts +3 -0
  137. package/dist/hitl/hitlHostSurface.js +17 -15
  138. package/dist/hitl/livePendingAsk.d.ts +16 -6
  139. package/dist/hitl/livePendingAsk.js +36 -4
  140. package/dist/hitl/localAllowRule.js +2 -1
  141. package/dist/hitl/noAllowCause.d.ts +9 -0
  142. package/dist/hitl/noAllowCause.js +26 -0
  143. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  144. package/dist/hitl/parkExpiryJudgements.js +46 -0
  145. package/dist/hitl/parkResolver.d.ts +3 -7
  146. package/dist/hitl/parkResolver.js +55 -28
  147. package/dist/hitl/parkRowBirthWait.js +2 -1
  148. package/dist/hitl/persistedRulesWire.d.ts +6 -1
  149. package/dist/hitl/persistedRulesWire.js +16 -4
  150. package/dist/hitl/planReviewWire.d.ts +2 -3
  151. package/dist/hitl/planReviewWire.js +86 -39
  152. package/dist/hitl/replayedApproval.d.ts +8 -0
  153. package/dist/hitl/replayedApproval.js +125 -10
  154. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  155. package/dist/hitl/resumeRunningCard.js +15 -4
  156. package/dist/hitl/sessionPolicyDeliverable.d.ts +1 -1
  157. package/dist/hitl/sessionPolicyDeliverable.js +3 -8
  158. package/dist/hitl/sessionPolicyWire.js +1 -1
  159. package/dist/hitl/toolApprovalWire.d.ts +50 -5
  160. package/dist/hitl/toolApprovalWire.js +368 -56
  161. package/dist/hooksWireCaps.js +38 -6
  162. package/dist/host.d.ts +5 -0
  163. package/dist/host.js +3 -1
  164. package/dist/hostCallbackGuard.d.ts +1 -0
  165. package/dist/hostCallbackGuard.js +25 -0
  166. package/dist/humanTurnRead.d.ts +15 -1
  167. package/dist/humanTurnRead.js +28 -2
  168. package/dist/index.d.ts +45 -14
  169. package/dist/index.js +33 -12
  170. package/dist/interactiveInterrupt.d.ts +8 -0
  171. package/dist/interactiveInterrupt.js +54 -0
  172. package/dist/limitsWire.d.ts +5 -1
  173. package/dist/limitsWire.js +51 -13
  174. package/dist/liveModelCatalog.d.ts +109 -0
  175. package/dist/liveModelCatalog.js +344 -18
  176. package/dist/mcpEngineLeg.d.ts +25 -0
  177. package/dist/mcpEngineLeg.js +71 -15
  178. package/dist/mcpPanel.js +2 -1
  179. package/dist/mcpProbeCapability.d.ts +0 -1
  180. package/dist/mcpProbeCapability.js +13 -12
  181. package/dist/mcpReconnect.d.ts +1 -3
  182. package/dist/mcpReconnect.js +20 -10
  183. package/dist/memoryComplianceCapability.d.ts +0 -1
  184. package/dist/memoryComplianceCapability.js +14 -13
  185. package/dist/memoryOriginCapability.d.ts +0 -1
  186. package/dist/memoryOriginCapability.js +14 -13
  187. package/dist/memoryVerbsWire.d.ts +1 -1
  188. package/dist/memoryVerbsWire.js +4 -0
  189. package/dist/model/liveCatalogShape.d.ts +14 -0
  190. package/dist/model/liveCatalogShape.js +71 -0
  191. package/dist/model/modelSupplyRules.d.ts +1 -0
  192. package/dist/model/modelSupplyRules.js +30 -9
  193. package/dist/model/modelsPolicy.d.ts +21 -0
  194. package/dist/model/modelsPolicy.js +90 -0
  195. package/dist/modelIdentityResolvability.d.ts +4 -2
  196. package/dist/modelIdentityResolvability.js +25 -5
  197. package/dist/modelSwitchFallback.d.ts +69 -0
  198. package/dist/modelSwitchFallback.js +206 -0
  199. package/dist/notifications.js +12 -11
  200. package/dist/outputStyleSeatCapability.d.ts +15 -0
  201. package/dist/outputStyleSeatCapability.js +42 -0
  202. package/dist/ownKey.d.ts +7 -0
  203. package/dist/ownKey.js +58 -0
  204. package/dist/panelReduce.d.ts +114 -0
  205. package/dist/panelReduce.js +1135 -0
  206. package/dist/panelStateHolder.d.ts +17 -0
  207. package/dist/panelStateHolder.js +201 -0
  208. package/dist/peerLaneCapability.d.ts +0 -1
  209. package/dist/peerLaneCapability.js +15 -14
  210. package/dist/permissionModesCapability.d.ts +0 -1
  211. package/dist/permissionModesCapability.js +5 -10
  212. package/dist/permissionRuleIssue.js +1 -1
  213. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  214. package/dist/permissionRulesWriteCapability.js +15 -14
  215. package/dist/permissionsAllowGrantCapability.d.ts +2 -1
  216. package/dist/permissionsAllowGrantCapability.js +35 -19
  217. package/dist/permissionsDeclaration.d.ts +16 -1
  218. package/dist/permissionsDeclaration.js +142 -15
  219. package/dist/printToolResultFrame.js +2 -10
  220. package/dist/promptDelivery.js +0 -8
  221. package/dist/protocolSegment.d.ts +1 -0
  222. package/dist/protocolSegment.js +13 -1
  223. package/dist/request/taskRequest.d.ts +11 -3
  224. package/dist/request/taskRequest.js +13 -1
  225. package/dist/resultFrameKeys.d.ts +4 -0
  226. package/dist/resultFrameKeys.js +13 -0
  227. package/dist/resumeRefusalCopy.d.ts +18 -1
  228. package/dist/resumeRefusalCopy.js +132 -31
  229. package/dist/retryStatus.js +6 -4
  230. package/dist/rewindArchiveCapability.d.ts +2 -1
  231. package/dist/rewindArchiveCapability.js +28 -15
  232. package/dist/rewindEngineAction.d.ts +21 -0
  233. package/dist/rewindEngineAction.js +36 -0
  234. package/dist/rewindWireCaps.d.ts +2 -1
  235. package/dist/rewindWireCaps.js +1 -0
  236. package/dist/{hitl/rosterMountedNames.d.ts → rosterMountedNames.d.ts} +1 -1
  237. package/dist/runCancelContext.js +2 -1
  238. package/dist/runTerminal.d.ts +0 -11
  239. package/dist/runTerminal.js +4 -27
  240. package/dist/sdkRegistryTransit.d.ts +2 -1
  241. package/dist/sdkRegistryTransit.js +1 -0
  242. package/dist/sealedKeyCapability.d.ts +0 -1
  243. package/dist/sealedKeyCapability.js +19 -20
  244. package/dist/seatContract.d.ts +85 -28
  245. package/dist/seatContract.js +512 -148
  246. package/dist/sessionIdSegment.d.ts +1 -0
  247. package/dist/sessionIdSegment.js +11 -0
  248. package/dist/sessionMemoryErase.d.ts +1 -1
  249. package/dist/sessionMemoryErase.js +6 -1
  250. package/dist/sessionMemoryStatus.js +3 -2
  251. package/dist/sessionPolicyCapability.d.ts +0 -1
  252. package/dist/sessionPolicyCapability.js +14 -13
  253. package/dist/sessionReadRedactionCapability.d.ts +15 -0
  254. package/dist/sessionReadRedactionCapability.js +42 -0
  255. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -1
  256. package/dist/sessionSyncFileHistoryCapability.js +13 -12
  257. package/dist/skillToolListsCapability.d.ts +0 -1
  258. package/dist/skillToolListsCapability.js +13 -12
  259. package/dist/skillsWireCaps.d.ts +4 -0
  260. package/dist/skillsWireCaps.js +66 -1
  261. package/dist/sqlEngineCapability.d.ts +0 -1
  262. package/dist/sqlEngineCapability.js +21 -21
  263. package/dist/steerPriorityCapability.d.ts +0 -1
  264. package/dist/steerPriorityCapability.js +18 -19
  265. package/dist/storePostureCapability.d.ts +1 -1
  266. package/dist/storePostureCapability.js +16 -16
  267. package/dist/streamDrainingLegs.d.ts +6 -0
  268. package/dist/streamDrainingLegs.js +23 -0
  269. package/dist/subagent/agentStateDetail.d.ts +1 -0
  270. package/dist/subagent/agentStateDetail.js +41 -0
  271. package/dist/subagent/engineCompactWire.d.ts +15 -0
  272. package/dist/subagent/engineCompactWire.js +82 -45
  273. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  274. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  275. package/dist/subagent/engineSubagentOutput.js +5 -20
  276. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  277. package/dist/subagent/engineSubagentTail.js +7 -32
  278. package/dist/subagentContentStore.js +3 -3
  279. package/dist/supportFloor.js +2 -5
  280. package/dist/taskRequestWords.d.ts +2 -4
  281. package/dist/taskRequestWords.js +3 -2
  282. package/dist/terminalStatuses.d.ts +30 -0
  283. package/dist/terminalStatuses.js +67 -0
  284. package/dist/toolResult.d.ts +5 -0
  285. package/dist/toolResult.js +88 -36
  286. package/dist/types/engineState.d.ts +2 -1
  287. package/dist/usageAnalytics.d.ts +146 -0
  288. package/dist/usageAnalytics.js +311 -0
  289. package/dist/userAttachmentEnvelope.d.ts +22 -1
  290. package/dist/userAttachmentEnvelope.js +90 -2
  291. package/dist/userInvokedSkillsCapability.d.ts +0 -1
  292. package/dist/userInvokedSkillsCapability.js +13 -12
  293. package/dist/webSearchBackendCapability.d.ts +0 -1
  294. package/dist/webSearchBackendCapability.js +20 -19
  295. package/dist/webSearchWireCaps.js +3 -11
  296. package/dist/wireErrorTriage.d.ts +11 -0
  297. package/dist/wireErrorTriage.js +35 -0
  298. package/dist/wireFailureShape.d.ts +10 -0
  299. package/dist/wireFailureShape.js +72 -5
  300. package/dist/wireRefusalCopy.d.ts +6 -1
  301. package/dist/wireRefusalCopy.js +23 -25
  302. package/dist/wiringInstructionsAttribution.d.ts +10 -0
  303. package/dist/wiringInstructionsAttribution.js +67 -0
  304. package/dist/workflowClient.js +19 -2
  305. package/dist/workflowsJournalCapability.d.ts +0 -1
  306. package/dist/workflowsJournalCapability.js +13 -12
  307. package/dist/writeProtectionCapability.d.ts +0 -1
  308. package/dist/writeProtectionCapability.js +26 -26
  309. package/docs/INTEGRATION-CLIENTS.md +1733 -52
  310. package/package.json +5 -5
  311. package/dist/askSurvivesStandingAnswer.d.ts +0 -13
  312. package/dist/askSurvivesStandingAnswer.js +0 -53
  313. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  314. package/dist/engineCapsGenerationGuard.js +0 -19
  315. package/dist/hitl/askSurvivesPosture.d.ts +0 -20
  316. package/dist/hitl/askSurvivesPosture.js +0 -48
  317. package/dist/panelRunningHistory.d.ts +0 -22
  318. package/dist/panelRunningHistory.js +0 -82
  319. package/dist/registryConflict.d.ts +0 -3
  320. package/dist/registryConflict.js +0 -44
  321. /package/dist/{hitl/rosterMountedNames.js → rosterMountedNames.js} +0 -0
@@ -1,29 +1,64 @@
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';
4
5
  const live = (basis) => Object.freeze({ kind: 'live', basis });
5
6
  const unknown = (why) => Object.freeze({ kind: 'unknown', why });
6
- const decided = (cause) => Object.freeze(cause !== undefined ? { kind: 'decided', cause } : { kind: 'decided' });
7
+ const decided = (row) => Object.freeze(row === undefined
8
+ ? { kind: 'decided' }
9
+ : { kind: 'decided', cause: row.cause, ...(row.needsHumanReason !== undefined ? { needsHumanReason: row.needsHumanReason } : {}) });
10
+ const decidedSettled = (how) => Object.freeze({ kind: 'decided', settled: how });
7
11
  function approvalIdOf(frame) {
8
12
  const v = frame.approvalId;
9
13
  return typeof v === 'string' && v !== '' ? v : undefined;
10
14
  }
11
- function crashConvergedCauseOf(body, approvalId) {
15
+ function crashConvergedFactsOf(body, approvalId) {
12
16
  const projection = projectCrashConverged(body);
13
17
  if (projection === undefined)
14
18
  return undefined;
15
19
  for (const row of [...projection.resumeSafe, ...projection.needsHuman]) {
16
20
  if (row.approvalId === approvalId)
17
- return row.cause;
21
+ return { cause: row.cause, ...(row.needsHumanReason !== undefined ? { needsHumanReason: row.needsHumanReason } : {}) };
18
22
  }
19
23
  return undefined;
20
24
  }
25
+ export function settledApprovalDisposition(frame, settled) {
26
+ try {
27
+ if (typeof settled !== 'object' || settled === null || typeof settled.get !== 'function')
28
+ return undefined;
29
+ const id = approvalIdOf(frame);
30
+ if (id === undefined)
31
+ return undefined;
32
+ const how = settled.get(id);
33
+ return typeof how === 'string' && APPROVAL_SETTLED_HOWS.includes(how) ? decidedSettled(how) : undefined;
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
21
39
  export function replayedApprovalDisposition(frame, basis) {
22
40
  let approvalId;
41
+ let positioned;
23
42
  try {
24
43
  if (typeof frame !== 'object' || frame === null)
25
44
  return unknown('unreadable_frame');
26
- if (!hasLedgerPositionKey(frame))
45
+ positioned = hasLedgerPositionKey(frame);
46
+ }
47
+ catch {
48
+ return unknown('unreadable_frame');
49
+ }
50
+ let settledBasis;
51
+ try {
52
+ settledBasis = typeof basis === 'object' && basis !== null ? basis.settled : undefined;
53
+ }
54
+ catch {
55
+ settledBasis = undefined;
56
+ }
57
+ const early = settledApprovalDisposition(frame, settledBasis);
58
+ if (early !== undefined)
59
+ return early;
60
+ try {
61
+ if (!positioned)
27
62
  return live('live_leg');
28
63
  approvalId = approvalIdOf(frame);
29
64
  }
@@ -70,15 +105,15 @@ export function replayedApprovalDisposition(frame, basis) {
70
105
  }
71
106
  if (reading.kind === 'present' && reading.rows.some((r) => r.approvalId === approvalId))
72
107
  return live('pending_list');
73
- let cause;
108
+ let facts;
74
109
  try {
75
- cause = crashConvergedCauseOf(body, approvalId);
110
+ facts = crashConvergedFactsOf(body, approvalId);
76
111
  }
77
112
  catch {
78
- cause = undefined;
113
+ facts = undefined;
79
114
  }
80
- if (cause !== undefined)
81
- return decided(cause);
115
+ if (facts !== undefined)
116
+ return decided(facts);
82
117
  if (reading.kind === 'not_reported')
83
118
  return unknown('list_not_reported');
84
119
  if (reading.kind === 'malformed')
@@ -87,3 +122,83 @@ export function replayedApprovalDisposition(frame, basis) {
87
122
  return unknown('list_incomplete');
88
123
  return decided();
89
124
  }
125
+ const TOOL_NAME_MAX = 80;
126
+ const THIS_REQUEST = 'this approval request';
127
+ const sentenceInitial = (s) => s.charAt(0).toUpperCase() + s.slice(1);
128
+ const TOOL_STATE_NOT_SHOWN = 'Whether the tool had started is not shown here.';
129
+ const STOPPED_BY_CAUSE = Object.freeze({
130
+ crashed_before_park: 'the engine stopped unexpectedly',
131
+ shutdown_before_park: 'the engine was shut down in an orderly way',
132
+ });
133
+ const STATE_BY_REASON = Object.freeze({
134
+ pending_unsafe: 'waiting',
135
+ approved_then_interrupted: 'approved',
136
+ contradictory: 'unclear',
137
+ unstable_row: 'unclear',
138
+ });
139
+ const CRASH_CONVERGED_SENTENCE = Object.freeze({
140
+ 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}`,
141
+ 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.`,
142
+ 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.`,
143
+ });
144
+ function crashConvergedStateOf(disposition) {
145
+ let reason;
146
+ try {
147
+ if (typeof disposition !== 'object' || disposition === null || !('needsHumanReason' in disposition))
148
+ return 'waiting';
149
+ reason = disposition.needsHumanReason;
150
+ }
151
+ catch {
152
+ return 'unclear';
153
+ }
154
+ if (reason === undefined)
155
+ return 'waiting';
156
+ return typeof reason === 'string' && Object.hasOwn(STATE_BY_REASON, reason) ? STATE_BY_REASON[reason] : 'unclear';
157
+ }
158
+ const SETTLED_PHRASE = Object.freeze({
159
+ answered: 'answered',
160
+ interrupted: 'dismissed',
161
+ closed_by_engine: 'closed by the engine',
162
+ });
163
+ 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.`;
164
+ const decidedPlain = (what) => `${sentenceInitial(what)} is no longer listed by the engine as waiting for a decision, so no decision was sent for it.`;
165
+ const unconfirmed = (what) => `Whether ${what} is still waiting for a decision could not be confirmed, so no decision was sent for it.`;
166
+ function guardedGet(o, key) {
167
+ try {
168
+ if (typeof o !== 'object' || o === null)
169
+ return undefined;
170
+ return o[key];
171
+ }
172
+ catch {
173
+ return undefined;
174
+ }
175
+ }
176
+ function subjectOf(opts) {
177
+ const raw = guardedGet(opts, 'toolName');
178
+ if (typeof raw !== 'string')
179
+ return THIS_REQUEST;
180
+ let quoted;
181
+ try {
182
+ quoted = quoteUntrustedForSentence(raw, TOOL_NAME_MAX);
183
+ }
184
+ catch {
185
+ return THIS_REQUEST;
186
+ }
187
+ return quoted === undefined ? THIS_REQUEST : `the approval request for ${quoted}`;
188
+ }
189
+ export function replayedApprovalSentence(disposition, opts) {
190
+ const kind = guardedGet(disposition, 'kind');
191
+ if (kind === 'unknown')
192
+ return unconfirmed(subjectOf(opts));
193
+ if (kind !== 'decided')
194
+ return undefined;
195
+ const what = subjectOf(opts);
196
+ const cause = guardedGet(disposition, 'cause');
197
+ if (typeof cause === 'string' && Object.hasOwn(STOPPED_BY_CAUSE, cause)) {
198
+ return CRASH_CONVERGED_SENTENCE[crashConvergedStateOf(disposition)](what, STOPPED_BY_CAUSE[cause]);
199
+ }
200
+ const settled = guardedGet(disposition, 'settled');
201
+ if (typeof settled === 'string' && Object.hasOwn(SETTLED_PHRASE, settled))
202
+ return settledRepeat(what, settled);
203
+ return decidedPlain(what);
204
+ }
@@ -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
  }
@@ -15,7 +15,7 @@ export interface SessionPolicyDeliverability {
15
15
  export interface SessionPolicyDeliverableOptions {
16
16
  readonly roster?: ToolRosterView;
17
17
  }
18
- export declare function isEngineRefusedToolName(name: string): boolean;
18
+ export { isEngineRefusedToolName } from '../engineRefusedToolName.js';
19
19
  export declare function sessionPolicyDeliverable(behavior: 'deny' | 'ask', rules: readonly string[], opts?: SessionPolicyDeliverableOptions): SessionPolicyDeliverability;
20
20
  export declare function sessionPolicyWithheldNotice(why: SessionPolicyWithheldWhy): string;
21
21
  export declare function legacyToolNameFailureNoteOf(code: string | undefined): string | undefined;
@@ -1,9 +1,10 @@
1
1
  import { CONFIG_LEGACY_TOOL_NAME, RULES_LEGACY_TOOL_NAME } from '../engineErrorCodes.js';
2
- import { rosterMountedNames } from './rosterMountedNames.js';
2
+ import { rosterMountedNames } from '../rosterMountedNames.js';
3
3
  import { ruleCompileVerdict } from '../ruleCompileVerdict.js';
4
4
  import { protocolSegmentOf } 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
+ import { isEngineRefusedToolName } from '../engineRefusedToolName.js';
7
8
  const COVERING_NAMESPACE_PREFIXES = CORE_PROTOCOL_PREFIXES;
8
9
  const ENGINE_RETIRED_TOOL_NAMES = CORE_RETIRED_TOOL_CURRENT_NAMES;
9
10
  const WITHHELD_NOTICE = {
@@ -40,13 +41,7 @@ function withheldWhyOf(rule) {
40
41
  return 'legacy_tool_name';
41
42
  return undefined;
42
43
  }
43
- export function isEngineRefusedToolName(name) {
44
- if (typeof name !== 'string')
45
- return false;
46
- if (ENGINE_RETIRED_TOOL_NAMES.has(name))
47
- return true;
48
- return name.includes('__') && !COVERING_NAMESPACE_PREFIXES.some((prefix) => name.startsWith(prefix));
49
- }
44
+ export { isEngineRefusedToolName } from '../engineRefusedToolName.js';
50
45
  function suppliedRosterNames(opts) {
51
46
  if (opts === undefined || opts === null)
52
47
  return 'absent';
@@ -3,7 +3,7 @@ import { hostLog } from '../host.js';
3
3
  import { isEngineRefusedToolName } from './sessionPolicyDeliverable.js';
4
4
  import { RULES_LEGACY_TOOL_NAME_WRITE_NOTE } from './refusedToolNameProse.js';
5
5
  import { RULES_LEGACY_TOOL_NAME, isRulesRefusalCode } from '../engineErrorCodes.js';
6
- import { rosterMountedNames } from './rosterMountedNames.js';
6
+ import { rosterMountedNames } from '../rosterMountedNames.js';
7
7
  import { CORE_RULE_TOOL_NAME_VERDICTS } from '../generated/engineFactTables.js';
8
8
  function isLegacyToolNameVerdict(v) {
9
9
  return typeof v === 'string' && v !== 'current' && CORE_RULE_TOOL_NAME_VERDICTS.includes(v);
@@ -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 { 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;
@@ -137,7 +137,6 @@ 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;
@@ -157,6 +156,15 @@ export interface ApprovalCardRequest {
157
156
  origin?: string;
158
157
  askClass?: string;
159
158
  classes?: readonly string[];
159
+ boundGrants?: BoundSkillGrantsWire;
160
+ classifierNoRuling?: string;
161
+ priorCardsForCall?: readonly ApprovalPriorCard[];
162
+ }
163
+ export interface ApprovalPriorCard {
164
+ readonly approvalId?: string;
165
+ readonly origin?: string;
166
+ readonly mandate?: ApprovalMandateWord;
167
+ readonly outcome?: 'allowed' | 'denied';
160
168
  }
161
169
  export type ApprovalCardPort = (req: ApprovalCardRequest) => Promise<ApprovalCardDecision>;
162
170
  export declare function installApprovalCardPort(port: ApprovalCardPort | null): () => void;
@@ -168,6 +176,9 @@ export declare function hasApprovalCardPortFor(sessionKey: string): boolean;
168
176
  export declare function approvalCardPortFor(sessionKey: string): ApprovalCardPort | null;
169
177
  export declare function _resetApprovalCardPortForTest(): void;
170
178
  export declare function surfaceApprovalCard(req: ApprovalCardRequest): Promise<ApprovalCardDecision>;
179
+ declare const REMEMBER_REFUSAL_CODES: readonly ["remember_not_in_proof", "remember_requires_binding", "capability.store_required", "decide.workflow_remember_unsupported", "decide.parked_remember_unsupported"];
180
+ export type RememberRefusalCode = (typeof REMEMBER_REFUSAL_CODES)[number];
181
+ export declare function rememberRefusalOf(error: unknown): RememberRefusalCode | undefined;
171
182
  export declare function surfaceFsApprovalAndDecide(deps: FsApprovalWireDeps, taskId: string, argsByCall: Map<string, unknown>, signal?: AbortSignal, parkGatedCallId?: string): Promise<FsApprovalOutcome>;
172
183
  export interface BoundSkillGrantsWire {
173
184
  readonly skill: string | null;
@@ -183,6 +194,7 @@ export interface ToolApprovalFrame {
183
194
  args?: unknown;
184
195
  argsOmitted?: boolean;
185
196
  outcome?: 'allowed' | 'denied' | 'expired';
197
+ cause?: ApprovalSettleCause;
186
198
  sourceTaskId?: string;
187
199
  fromSubagent?: true;
188
200
  sourceAgentName?: string;
@@ -223,7 +235,7 @@ export interface ToolApprovalDelegation {
223
235
  depth: number;
224
236
  agentName?: string;
225
237
  }
226
- 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"];
238
+ 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"];
227
239
  export interface ApprovalMandatedFacts {
228
240
  readonly mandated?: true;
229
241
  readonly ruleOffersAbsence?: string;
@@ -244,7 +256,7 @@ export interface RespondToolApprovalOpts {
244
256
  persistRuleBatchOfferIndex?: number;
245
257
  note?: string;
246
258
  settledBy?: 'policy';
247
- decidedBy?: 'policy';
259
+ decidedBy?: Extract<ApprovalDecidedBy, 'policy'>;
248
260
  }
249
261
  export type RespondToolApprovalFn = (approvalId: string, decision: ToolApprovalRespondDecision, opts?: RespondToolApprovalOpts) => Promise<ToolApprovalRespondAck | void>;
250
262
  export type ToolApprovalRespondAckView = ToolApprovalRespondAck;
@@ -254,7 +266,15 @@ export interface ToolApprovalRespondParkingView {
254
266
  readonly approvalId: string;
255
267
  readonly retryAfterMs?: number;
256
268
  readonly decidePath?: string;
269
+ readonly message?: string;
257
270
  }
271
+ export type ToolApprovalParkingBodyReading = {
272
+ readonly kind: 'parking';
273
+ readonly view: ToolApprovalRespondParkingView;
274
+ } | {
275
+ readonly kind: 'claimed_unreadable';
276
+ };
277
+ export declare function readToolApprovalRespondParking(v: unknown): ToolApprovalParkingBodyReading | undefined;
258
278
  export declare function decisionAttributionKeyOf(reading: ApprovalDecidedByReading | undefined, denySettledBy: ApprovalDenySettledBy | undefined): {
259
279
  decidedBy: 'policy';
260
280
  } | {
@@ -266,6 +286,8 @@ export interface ToolApprovalFrameOutcome {
266
286
  respondRefusal?: ToolApprovalRespondRefusal;
267
287
  editRefused?: true;
268
288
  retracted?: true;
289
+ aborted?: true;
290
+ joinedInFlight?: true;
269
291
  denySettledBy?: ApprovalDenySettledBy;
270
292
  denyReason?: string;
271
293
  denyAttributionRefusal?: DenyAttributionRefusalDetail;
@@ -287,6 +309,13 @@ export type ToolApprovalRespondRefusal = (ToolApprovalRespondRefusalFields & {
287
309
  });
288
310
  export declare function readToolApprovalRespondRefusal(err: unknown): ToolApprovalRespondRefusal | undefined;
289
311
  export declare function isToolApprovalFrame(ev: unknown): ev is ToolApprovalFrame;
312
+ export declare function askProbeReasonDetail(card: Pick<ApprovalCardRequest, 'probeReason' | 'probeCause'> | null | undefined): string | undefined;
313
+ export declare function readApprovalRememberRefused(v: unknown): boolean;
314
+ export declare function readApprovalBoundGrants(v: unknown): BoundSkillGrantsWire | undefined;
315
+ export declare function readApprovalClassifierNoRuling(v: unknown): string | undefined;
316
+ export declare function classifierNoRulingDetail(word: string | undefined): string;
317
+ export declare function approvalBoundGrantsDetail(grants: BoundSkillGrantsWire | null | undefined): string | undefined;
318
+ export declare function approvalPriorCardsDetail(card: Pick<ApprovalCardRequest, 'priorCardsForCall' | 'origin'> | null | undefined): string | undefined;
290
319
  export declare function readDenialLimitFallback(v: unknown): DenialLimitFallback | undefined;
291
320
  export declare function readRuleOffers(v: unknown): RuleOffer[] | undefined;
292
321
  export declare function readRuleOfferSupply(offers: unknown): RuleOffer[] | undefined;
@@ -298,4 +327,20 @@ export interface ToolApprovalFrameLaneOpts {
298
327
  windowIsCurrent?: boolean;
299
328
  argsUnavailable?: true;
300
329
  }
301
- export declare function surfaceToolApprovalFrameAndRespond(frame: ToolApprovalFrame, respond: RespondToolApprovalFn, streamArgs: unknown | undefined, signal?: AbortSignal, lane?: ToolApprovalFrameLaneOpts): Promise<ToolApprovalFrameOutcome>;
330
+ export declare function surfaceToolApprovalFrameAndRespond(frame: ToolApprovalFrame, respond: RespondToolApprovalFn, streamArgs: unknown | undefined, signal?: AbortSignal, lane?: ToolApprovalFrameLaneOpts, run?: {
331
+ readonly taskId?: string;
332
+ readonly sessionId?: string;
333
+ }): Promise<ToolApprovalFrameOutcome>;
334
+ export interface ApprovalHolderIdentity {
335
+ readonly approvalId?: string;
336
+ readonly taskId?: string;
337
+ readonly toolCallId?: string;
338
+ readonly sessionId?: string;
339
+ }
340
+ export type ApprovalHolderJoin = {
341
+ readonly kind: 'joined';
342
+ readonly outcome: ToolApprovalFrameOutcome;
343
+ } | {
344
+ readonly kind: 'free';
345
+ };
346
+ export declare function joinApprovalHolder(identity: ApprovalHolderIdentity, signal?: AbortSignal): Promise<ApprovalHolderJoin>;