@sema-agent/client-core 0.110.0 → 0.112.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 (243) hide show
  1. package/CHANGELOG.md +244 -0
  2. package/README.md +59 -18
  3. package/dist/abortableSleep.d.ts +7 -0
  4. package/dist/abortableSleep.js +37 -0
  5. package/dist/adapt/arms.js +25 -4
  6. package/dist/adapt/toolCards.d.ts +3 -1
  7. package/dist/adapt/toolCards.js +4 -2
  8. package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
  9. package/dist/adapter/activeRunSelfHeal.js +171 -3
  10. package/dist/adapter/downstream/eventToSdkMessage.js +10 -10
  11. package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
  12. package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
  13. package/dist/adapter/runStream.d.ts +5 -0
  14. package/dist/adapter/runStream.js +15 -3
  15. package/dist/agentSession/engineSessionBackgroundStop.js +2 -2
  16. package/dist/attachmentRoute.d.ts +20 -0
  17. package/dist/attachmentRoute.js +39 -0
  18. package/dist/attachmentsWireCaps.js +1 -1
  19. package/dist/builtinOutputStyles.d.ts +12 -0
  20. package/dist/builtinOutputStyles.js +147 -0
  21. package/dist/checkpointRowVerdict.d.ts +3 -0
  22. package/dist/checkpointRowVerdict.js +14 -1
  23. package/dist/compactionStatus.d.ts +9 -0
  24. package/dist/compactionStatus.js +29 -5
  25. package/dist/consoleCaPin.d.ts +136 -0
  26. package/dist/consoleCaPin.js +827 -0
  27. package/dist/controlRouter.js +2 -1
  28. package/dist/coreValuePorts.d.ts +39 -1
  29. package/dist/coreValuePorts.js +10 -0
  30. package/dist/decideReceipt.d.ts +2 -1
  31. package/dist/deviceRebind.js +3 -3
  32. package/dist/displayUntrusted.d.ts +1 -0
  33. package/dist/displayUntrusted.js +6 -0
  34. package/dist/effectiveFacts.d.ts +9 -0
  35. package/dist/effectiveFacts.js +33 -0
  36. package/dist/engineAddress.d.ts +1 -0
  37. package/dist/engineAddress.js +4 -1
  38. package/dist/engineCredentialRelease.d.ts +54 -0
  39. package/dist/engineCredentialRelease.js +146 -0
  40. package/dist/engineErrorCodes.d.ts +1 -0
  41. package/dist/engineErrorCodes.js +1 -0
  42. package/dist/engineHealthProbeVerdict.d.ts +24 -0
  43. package/dist/engineHealthProbeVerdict.js +123 -0
  44. package/dist/engineNoticeCodes.js +5 -7
  45. package/dist/engineRepoint.d.ts +12 -5
  46. package/dist/engineRepoint.js +44 -19
  47. package/dist/engineRowRef.d.ts +3 -0
  48. package/dist/engineRowRef.js +11 -1
  49. package/dist/engineSwapCrossing.d.ts +57 -0
  50. package/dist/engineSwapCrossing.js +297 -0
  51. package/dist/engineUnavailable.d.ts +45 -0
  52. package/dist/engineUnavailable.js +496 -0
  53. package/dist/engineUrl.js +4 -2
  54. package/dist/eventLeg.js +3 -3
  55. package/dist/gateFailureCodes.js +2 -2
  56. package/dist/generated/sdkFactTables.d.ts +2 -1
  57. package/dist/generated/sdkFactTables.js +14 -0
  58. package/dist/generated/settingsSchemaFns.d.ts +1 -0
  59. package/dist/generated/settingsSchemaFns.js +3 -0
  60. package/dist/generated/settingsSchemaHooksClassifier.js +38 -9
  61. package/dist/generated/settingsSchemaTables.d.ts +56 -0
  62. package/dist/generated/settingsSchemaTables.js +19 -0
  63. package/dist/generated/settingsSchemaTypes.d.ts +23 -13
  64. package/dist/generated/settingsSchemaUrlShape.d.ts +1 -0
  65. package/dist/generated/settingsSchemaUrlShape.js +17 -0
  66. package/dist/hitl/approvalDelivery.d.ts +1 -0
  67. package/dist/hitl/approvalDelivery.js +1 -1
  68. package/dist/hitl/approvalResolution.d.ts +1 -1
  69. package/dist/hitl/approvalResolution.js +2 -1
  70. package/dist/hitl/askGateWire.js +5 -6
  71. package/dist/hitl/decisionRefusal.d.ts +6 -0
  72. package/dist/hitl/decisionRefusal.js +19 -10
  73. package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
  74. package/dist/hitl/decisionRefusalCarrier.js +348 -0
  75. package/dist/hitl/decisionSend.d.ts +7 -0
  76. package/dist/hitl/decisionSend.js +34 -12
  77. package/dist/hitl/editedApprovalAcceptance.js +1 -1
  78. package/dist/hitl/elicitationRefusal.d.ts +4 -0
  79. package/dist/hitl/elicitationRefusal.js +23 -0
  80. package/dist/hitl/frameRouter.d.ts +2 -2
  81. package/dist/hitl/frameRouter.js +8 -15
  82. package/dist/hitl/gateIdentity.d.ts +5 -0
  83. package/dist/hitl/gateIdentity.js +23 -0
  84. package/dist/hitl/hitlBridge.d.ts +6 -0
  85. package/dist/hitl/hitlBridge.js +10 -4
  86. package/dist/hitl/hitlHostSurface.d.ts +2 -1
  87. package/dist/hitl/hitlHostSurface.js +7 -2
  88. package/dist/hitl/localAllowRedemption.d.ts +70 -0
  89. package/dist/hitl/localAllowRedemption.js +276 -0
  90. package/dist/hitl/parkOwnership.js +2 -1
  91. package/dist/hitl/parkResolver.js +14 -4
  92. package/dist/hitl/persistedRulesWire.d.ts +16 -0
  93. package/dist/hitl/persistedRulesWire.js +70 -0
  94. package/dist/hitl/planReviewWire.d.ts +3 -0
  95. package/dist/hitl/planReviewWire.js +23 -6
  96. package/dist/hitl/policyDenyCause.d.ts +1 -1
  97. package/dist/hitl/policyDenyCause.js +1 -1
  98. package/dist/hitl/resumeRunningCard.d.ts +1 -0
  99. package/dist/hitl/resumeRunningCard.js +1 -0
  100. package/dist/hitl/screenCardCarriers.d.ts +15 -0
  101. package/dist/hitl/screenCardCarriers.js +41 -0
  102. package/dist/hitl/screenDecisionCards.d.ts +98 -0
  103. package/dist/hitl/screenDecisionCards.js +363 -0
  104. package/dist/hitl/sessionPolicyWire.js +2 -2
  105. package/dist/hitl/standingRows.d.ts +6 -2
  106. package/dist/hitl/standingRows.js +27 -2
  107. package/dist/hitl/toolApprovalWire.d.ts +30 -8
  108. package/dist/hitl/toolApprovalWire.js +264 -121
  109. package/dist/hooksReaderGenerations.js +1 -1
  110. package/dist/hooksWireCaps.js +3 -3
  111. package/dist/hostSettingNoticeArm.d.ts +3 -0
  112. package/dist/hostSettingNoticeArm.js +12 -0
  113. package/dist/hostTurnSettings.d.ts +3 -0
  114. package/dist/hostTurnSettings.js +38 -5
  115. package/dist/humanTurnRead.js +11 -1
  116. package/dist/i18n/messages.en.d.ts +292 -0
  117. package/dist/i18n/messages.en.js +298 -7
  118. package/dist/i18n/messages.zh.js +316 -6
  119. package/dist/i18n/translate.d.ts +3 -0
  120. package/dist/i18n/translate.js +78 -10
  121. package/dist/i18n/zh.d.ts +1 -0
  122. package/dist/i18n/zh.js +1 -0
  123. package/dist/index.d.ts +71 -20
  124. package/dist/index.js +44 -13
  125. package/dist/interactiveHalt.js +2 -1
  126. package/dist/interactiveInterrupt.js +20 -2
  127. package/dist/liveModelCatalog.d.ts +4 -0
  128. package/dist/liveModelCatalog.js +12 -3
  129. package/dist/localConfig/documents.d.ts +61 -0
  130. package/dist/localConfig/documents.js +51 -0
  131. package/dist/localConfig/kernel.d.ts +149 -0
  132. package/dist/localConfig/kernel.js +597 -0
  133. package/dist/localConfig/mcp/edit.d.ts +161 -0
  134. package/dist/localConfig/mcp/edit.js +846 -0
  135. package/dist/localConfig/mcp/servers.d.ts +165 -0
  136. package/dist/localConfig/mcp/servers.js +776 -0
  137. package/dist/localConfig/mcp/views.d.ts +170 -0
  138. package/dist/localConfig/mcp/views.js +429 -0
  139. package/dist/localConfig/modelPool.d.ts +262 -0
  140. package/dist/localConfig/modelPool.js +1489 -0
  141. package/dist/localConfig/modelPoolWords.d.ts +13 -0
  142. package/dist/localConfig/modelPoolWords.js +20 -0
  143. package/dist/localConfig/receiptShape.d.ts +7 -0
  144. package/dist/localConfig/receiptShape.js +135 -0
  145. package/dist/localConfig/settingsWrite.d.ts +127 -0
  146. package/dist/localConfig/settingsWrite.js +237 -0
  147. package/dist/localConfig/skills.d.ts +124 -0
  148. package/dist/localConfig/skills.js +397 -0
  149. package/dist/localConfig/skillsWords.d.ts +10 -0
  150. package/dist/localConfig/skillsWords.js +5 -0
  151. package/dist/localEngineSeatReading.d.ts +2 -2
  152. package/dist/localEngineSeatReading.js +5 -3
  153. package/dist/localEngineSpawn.d.ts +0 -7
  154. package/dist/localEngineSpawn.js +0 -92
  155. package/dist/localEngineStep.d.ts +2 -2
  156. package/dist/localEngineStep.js +2 -0
  157. package/dist/mcpProbeWire.js +2 -1
  158. package/dist/mcpReconnect.js +3 -3
  159. package/dist/mcpWireCaps.js +1 -1
  160. package/dist/memoryVerbsWire.js +3 -2
  161. package/dist/model/engineModelWords.d.ts +3 -0
  162. package/dist/model/engineModelWords.js +13 -0
  163. package/dist/model/onboardJudgement.d.ts +14 -4
  164. package/dist/model/onboardJudgement.js +91 -139
  165. package/dist/model/subagentModelWord.d.ts +21 -2
  166. package/dist/model/subagentModelWord.js +100 -29
  167. package/dist/modelCapabilityProbe.js +3 -40
  168. package/dist/modelConfigGapNotice.d.ts +20 -0
  169. package/dist/modelConfigGapNotice.js +102 -0
  170. package/dist/modsKernelIdentity.js +2 -47
  171. package/dist/notifications.d.ts +19 -0
  172. package/dist/notifications.js +114 -12
  173. package/dist/ownKey.d.ts +7 -0
  174. package/dist/ownKey.js +71 -8
  175. package/dist/pendingUserRow.d.ts +4 -0
  176. package/dist/pendingUserRow.js +16 -0
  177. package/dist/permissionsDeclaration.d.ts +3 -1
  178. package/dist/permissionsDeclaration.js +33 -9
  179. package/dist/planReviewCardFacts.d.ts +3 -0
  180. package/dist/planReviewCardFacts.js +52 -2
  181. package/dist/pluginHooksWire.d.ts +9 -1
  182. package/dist/pluginHooksWire.js +40 -6
  183. package/dist/printToolResultFrame.js +4 -2
  184. package/dist/promptBlockedCopy.js +12 -7
  185. package/dist/promptSuggestionBatch.d.ts +7 -0
  186. package/dist/promptSuggestionBatch.js +9 -0
  187. package/dist/promptSuggestionsTail.d.ts +39 -0
  188. package/dist/promptSuggestionsTail.js +116 -0
  189. package/dist/request/taskRequest.js +10 -6
  190. package/dist/requestCoordinate.d.ts +1 -0
  191. package/dist/requestCoordinate.js +13 -0
  192. package/dist/resumeRefusalCopy.d.ts +3 -1
  193. package/dist/resumeRefusalCopy.js +12 -4
  194. package/dist/rewindArchiveReading.js +4 -4
  195. package/dist/runCancelContext.d.ts +2 -1
  196. package/dist/runCancelContext.js +1 -0
  197. package/dist/runLedgerSnapshot.js +3 -3
  198. package/dist/runPermissionModeSwitch.js +3 -4
  199. package/dist/scenarioRefusal.js +11 -13
  200. package/dist/scenarioSkills.js +11 -6
  201. package/dist/seam.d.ts +16 -2
  202. package/dist/seam.js +10 -0
  203. package/dist/seatContract.d.ts +259 -9
  204. package/dist/seatContract.js +444 -15
  205. package/dist/sessionCostReading.d.ts +70 -0
  206. package/dist/sessionCostReading.js +150 -0
  207. package/dist/sessionHooksRoster.d.ts +4 -0
  208. package/dist/sessionHooksRoster.js +158 -0
  209. package/dist/sessionIdSegment.d.ts +1 -0
  210. package/dist/sessionIdSegment.js +4 -1
  211. package/dist/sessionMemoryErase.js +2 -1
  212. package/dist/sessionMemoryStatus.js +2 -2
  213. package/dist/sessionReadRedaction.d.ts +7 -0
  214. package/dist/sessionReadRedaction.js +26 -0
  215. package/dist/sessionSyncFileHistory.js +8 -9
  216. package/dist/settingsHooksSalvage.js +2 -1
  217. package/dist/sha256Bytes.d.ts +1 -0
  218. package/dist/sha256Bytes.js +46 -0
  219. package/dist/skillOverrideChain.d.ts +83 -0
  220. package/dist/skillOverrideChain.js +378 -0
  221. package/dist/skillsWireCaps.d.ts +3 -0
  222. package/dist/skillsWireCaps.js +16 -1
  223. package/dist/sseIdleTriage.js +2 -1
  224. package/dist/storeDurabilityWord.d.ts +15 -0
  225. package/dist/storeDurabilityWord.js +18 -0
  226. package/dist/storePostureCapability.d.ts +7 -3
  227. package/dist/storePostureCapability.js +69 -39
  228. package/dist/subagent/engineSubagentResume.js +2 -2
  229. package/dist/subagent/engineSubagentTail.js +2 -1
  230. package/dist/subagentContentStore.d.ts +11 -0
  231. package/dist/subagentContentStore.js +28 -2
  232. package/dist/toolResult.d.ts +1 -0
  233. package/dist/toolResult.js +2 -0
  234. package/dist/turnFailurePresentation.js +4 -10
  235. package/dist/userAttachmentEnvelope.d.ts +2 -1
  236. package/dist/userAttachmentEnvelope.js +10 -0
  237. package/dist/wireErrorTriage.js +2 -1
  238. package/dist/wireFailureShape.d.ts +4 -0
  239. package/dist/wireFailureShape.js +141 -19
  240. package/dist/wireRefusalCopy.d.ts +6 -5
  241. package/dist/wireRefusalCopy.js +49 -92
  242. package/docs/INTEGRATION-CLIENTS.md +2718 -17
  243. package/package.json +7 -3
@@ -0,0 +1,348 @@
1
+ import { isSecretKeyName } from '../seatContract.js';
2
+ import { placeThrownExtraOnCopy, wireFailureCoreOf, wireFailureTextsOf } from '../wireFailureShape.js';
3
+ import { decideFailureNote } from '../decideFailureNote.js';
4
+ import { REFUSAL_ROUTES, classifyDecisionRefusal, decisionRefusalAskReading, decisionRefusalSaysAskGone, mintDecisionRefusalReading, readDecisionRefusalReading, } from './decisionRefusal.js';
5
+ import { decisionConflictOf } from './decisionConflict.js';
6
+ import { resumeReopenFromError } from './suspendedReopen.js';
7
+ import { askGoneFromError, decideParkMovedFromError, decideRefusalFromError, decideRequiresBindingFromError } from '../decideReceipt.js';
8
+ import { corruptStoredRowWhere, resumeRetryLaterFromError, scenarioDenyFromError } from '../wireErrorTriage.js';
9
+ import { checkpointUnsupportedVersionFromError, parkedResumeStartupFromError, refusedParkFromError, requireExistingSessionRefusalFromError, resumeContextUnavailableFromError, resumePolicyBlockFromError, resumeRefusalFromError, } from '../resumeRefusalCopy.js';
10
+ import { admissionWallRefusalFromError, autonomyLaneRefusalFromError, bodyShapeRefusalFromError, cancelConflictFromError, denyAttributionRefusalFromError, envCredentialRefusalFromError, fieldLimitRefusalFromError, fleetLeaseUnavailableFromError, hostPostureRefusalFromError, quotaExhaustedFromError, runConcurrencyCapFromError, sessionArchiveStampedFromError, sessionDeleteConflictFromError, sessionIdRetiredFromError, settingsHooksRefusalFromError, toolDeclarationRefusalFromError, unreadRequestMembersFromError, unsupportedRuleRefusalFromError, usageWindowExhaustedFromError, userAttachmentRefusalFromError, userInvokedSkillRefusalFromError, } from '../wireRefusalCopy.js';
11
+ import { scenarioRefusalFromError } from '../scenarioRefusal.js';
12
+ import { inheritEnvRefusalFromError } from '../inheritEnvWire.js';
13
+ const DECISION_WORDS = { approve: true, deny: true };
14
+ const DECISIONS = Object.freeze([undefined, ...Object.keys(DECISION_WORDS)]);
15
+ const CONTEXTS = Object.freeze([undefined, ...REFUSAL_ROUTES.map((route) => Object.freeze({ route }))]);
16
+ const READERS = Object.freeze({
17
+ classifyDecisionRefusal: (e) => CONTEXTS.map((c) => classifyDecisionRefusal(e, c)),
18
+ readDecisionRefusalReading: (e) => CONTEXTS.map((c) => readDecisionRefusalReading(e, c)),
19
+ mintDecisionRefusalReading: (e) => [mintDecisionRefusalReading(e, undefined, true), mintDecisionRefusalReading(e, undefined, false)],
20
+ decisionRefusalAskReading: (e) => decisionRefusalAskReading(e),
21
+ decisionRefusalSaysAskGone: (e) => decisionRefusalSaysAskGone(e),
22
+ decideFailureNote: (e) => DECISIONS.map((d) => decideFailureNote(e, d)),
23
+ decisionConflictOf: (e) => decisionConflictOf(e),
24
+ corruptStoredRowWhere: (e) => corruptStoredRowWhere(e),
25
+ wireFailureCoreOf: (e) => wireFailureCoreOf(e),
26
+ wireFailureTextsOf: (e) => wireFailureTextsOf(e).reason,
27
+ admissionWallRefusalFromError: (e) => admissionWallRefusalFromError(e),
28
+ askGoneFromError: (e) => askGoneFromError(e),
29
+ autonomyLaneRefusalFromError: (e) => autonomyLaneRefusalFromError(e),
30
+ bodyShapeRefusalFromError: (e) => bodyShapeRefusalFromError(e),
31
+ cancelConflictFromError: (e) => cancelConflictFromError(e),
32
+ checkpointUnsupportedVersionFromError: (e) => checkpointUnsupportedVersionFromError(e),
33
+ decideParkMovedFromError: (e) => decideParkMovedFromError(e),
34
+ decideRefusalFromError: (e) => decideRefusalFromError(e),
35
+ decideRequiresBindingFromError: (e) => decideRequiresBindingFromError(e),
36
+ denyAttributionRefusalFromError: (e) => [denyAttributionRefusalFromError(e, true), denyAttributionRefusalFromError(e, false)],
37
+ envCredentialRefusalFromError: (e) => envCredentialRefusalFromError(e),
38
+ fieldLimitRefusalFromError: (e) => fieldLimitRefusalFromError(e),
39
+ fleetLeaseUnavailableFromError: (e) => fleetLeaseUnavailableFromError(e),
40
+ hostPostureRefusalFromError: (e) => hostPostureRefusalFromError(e, undefined),
41
+ inheritEnvRefusalFromError: (e) => inheritEnvRefusalFromError(e, undefined),
42
+ parkedResumeStartupFromError: (e) => DECISIONS.map((d) => parkedResumeStartupFromError(e, d)),
43
+ quotaExhaustedFromError: (e) => quotaExhaustedFromError(e),
44
+ refusedParkFromError: (e) => refusedParkFromError(e),
45
+ requireExistingSessionRefusalFromError: (e) => requireExistingSessionRefusalFromError(e),
46
+ resumeContextUnavailableFromError: (e) => resumeContextUnavailableFromError(e),
47
+ resumePolicyBlockFromError: (e) => resumePolicyBlockFromError(e),
48
+ resumeRefusalFromError: (e) => resumeRefusalFromError(e),
49
+ resumeReopenFromError: (e) => resumeReopenFromError(e),
50
+ resumeRetryLaterFromError: (e) => resumeRetryLaterFromError(e),
51
+ runConcurrencyCapFromError: (e) => runConcurrencyCapFromError(e),
52
+ scenarioDenyFromError: (e) => scenarioDenyFromError(e),
53
+ scenarioRefusalFromError: (e) => scenarioRefusalFromError(e),
54
+ sessionArchiveStampedFromError: (e) => sessionArchiveStampedFromError(e),
55
+ sessionDeleteConflictFromError: (e) => sessionDeleteConflictFromError(e),
56
+ sessionIdRetiredFromError: (e) => sessionIdRetiredFromError(e),
57
+ settingsHooksRefusalFromError: (e) => settingsHooksRefusalFromError(e),
58
+ toolDeclarationRefusalFromError: (e) => toolDeclarationRefusalFromError(e),
59
+ unreadRequestMembersFromError: (e) => unreadRequestMembersFromError(e),
60
+ unsupportedRuleRefusalFromError: (e) => unsupportedRuleRefusalFromError(e),
61
+ usageWindowExhaustedFromError: (e) => usageWindowExhaustedFromError(e),
62
+ userAttachmentRefusalFromError: (e) => userAttachmentRefusalFromError(e),
63
+ userInvokedSkillRefusalFromError: (e) => userInvokedSkillRefusalFromError(e),
64
+ });
65
+ export function decisionRefusalCarrierReaderNames() {
66
+ return Object.freeze(Object.keys(READERS));
67
+ }
68
+ const COPY_DEPTH_MAX = 16;
69
+ const COPY_NODES_MAX = 4096;
70
+ const COPY_KEYS_MAX = 1024;
71
+ const SKIP = Symbol('carrier-skip');
72
+ function ownDataDescriptor(o, k) {
73
+ try {
74
+ const d = Reflect.getOwnPropertyDescriptor(o, k);
75
+ return d !== undefined && Object.hasOwn(d, 'value') ? { value: d.value } : undefined;
76
+ }
77
+ catch {
78
+ return undefined;
79
+ }
80
+ }
81
+ function copyOf(v, depth, run) {
82
+ if (v === null || v === undefined || typeof v === 'string' || typeof v === 'boolean' || typeof v === 'number')
83
+ return v;
84
+ if (typeof v !== 'object' && typeof v !== 'function')
85
+ return SKIP;
86
+ const o = v;
87
+ if (depth > COPY_DEPTH_MAX || run.nodes >= COPY_NODES_MAX || run.path.has(o))
88
+ return SKIP;
89
+ run.nodes += 1;
90
+ run.path.add(o);
91
+ try {
92
+ let isArray;
93
+ try {
94
+ isArray = Array.isArray(o);
95
+ }
96
+ catch {
97
+ return SKIP;
98
+ }
99
+ if (isArray) {
100
+ const len = ownDataDescriptor(o, 'length')?.value;
101
+ if (typeof len !== 'number' || !Number.isInteger(len) || len < 0 || len > COPY_KEYS_MAX)
102
+ return SKIP;
103
+ const out = new Array(len);
104
+ for (let i = 0; i < len; i += 1) {
105
+ const d = ownDataDescriptor(o, String(i));
106
+ if (d === undefined)
107
+ continue;
108
+ const c = copyOf(d.value, depth + 1, run);
109
+ if (c !== SKIP)
110
+ out[i] = c;
111
+ }
112
+ return out;
113
+ }
114
+ let keys;
115
+ try {
116
+ keys = Reflect.ownKeys(o);
117
+ }
118
+ catch {
119
+ return SKIP;
120
+ }
121
+ const out = {};
122
+ let taken = 0;
123
+ for (let i = 0; i < keys.length; i += 1) {
124
+ const k = keys[i];
125
+ if (typeof k !== 'string')
126
+ continue;
127
+ if (taken >= COPY_KEYS_MAX)
128
+ break;
129
+ const d = ownDataDescriptor(o, k);
130
+ if (d === undefined)
131
+ continue;
132
+ const c = copyOf(d.value, depth + 1, run);
133
+ if (c === SKIP)
134
+ continue;
135
+ Object.defineProperty(out, k, { value: c, writable: true, enumerable: true, configurable: true });
136
+ taken += 1;
137
+ }
138
+ placeThrownExtraOnCopy(o, out, (bag) => {
139
+ const c = copyOf(bag, depth + 1, run);
140
+ return c === SKIP ? undefined : c;
141
+ });
142
+ return out;
143
+ }
144
+ finally {
145
+ run.path.delete(o);
146
+ }
147
+ }
148
+ const newWatch = (node) => ({ node, touched: new Set(), kids: new Map(), enumerated: false, whole: false });
149
+ function viewOf(w, watches) {
150
+ if (w.view !== undefined)
151
+ return w.view;
152
+ const kid = (k, v) => {
153
+ if (typeof v !== 'object' || v === null)
154
+ return v;
155
+ let c = w.kids.get(k);
156
+ if (c === undefined || c.node !== v) {
157
+ c = newWatch(v);
158
+ w.kids.set(k, c);
159
+ }
160
+ return viewOf(c, watches);
161
+ };
162
+ const view = new Proxy(w.node, {
163
+ getOwnPropertyDescriptor(t, k) {
164
+ const d = Reflect.getOwnPropertyDescriptor(t, k);
165
+ if (typeof k !== 'string')
166
+ return d;
167
+ w.touched.add(k);
168
+ return d !== undefined && Object.hasOwn(d, 'value') ? { ...d, value: kid(k, d.value) } : d;
169
+ },
170
+ get(t, k, receiver) {
171
+ if (typeof k !== 'string')
172
+ return Reflect.get(t, k, receiver);
173
+ w.touched.add(k);
174
+ return Object.hasOwn(t, k) ? kid(k, t[k]) : Reflect.get(t, k, receiver);
175
+ },
176
+ has(t, k) {
177
+ if (typeof k === 'string')
178
+ w.touched.add(k);
179
+ return Reflect.has(t, k);
180
+ },
181
+ ownKeys(t) {
182
+ w.enumerated = true;
183
+ return Reflect.ownKeys(t);
184
+ },
185
+ });
186
+ w.view = view;
187
+ watches.set(view, w);
188
+ return view;
189
+ }
190
+ function ownKeysReading(o) {
191
+ try {
192
+ return { kind: 'listed', keys: Reflect.ownKeys(o) };
193
+ }
194
+ catch {
195
+ return { kind: 'unreadable' };
196
+ }
197
+ }
198
+ function consumeOutput(out, watches, seen, depth) {
199
+ if ((typeof out !== 'object' && typeof out !== 'function') || out === null || depth > COPY_DEPTH_MAX || seen.has(out))
200
+ return;
201
+ const w = watches.get(out);
202
+ if (w !== undefined) {
203
+ w.whole = true;
204
+ return;
205
+ }
206
+ seen.add(out);
207
+ const listed = ownKeysReading(out);
208
+ if (listed.kind === 'unreadable')
209
+ return;
210
+ for (let i = 0; i < listed.keys.length; i += 1) {
211
+ const k = listed.keys[i];
212
+ if (typeof k !== 'string')
213
+ continue;
214
+ const d = ownDataDescriptor(out, k);
215
+ if (d !== undefined)
216
+ consumeOutput(d.value, watches, seen, depth + 1);
217
+ }
218
+ }
219
+ function wholeOf(v) {
220
+ if (typeof v !== 'object' || v === null)
221
+ return v;
222
+ if (Array.isArray(v)) {
223
+ const out = new Array(v.length);
224
+ for (let i = 0; i < v.length; i += 1)
225
+ if (Object.hasOwn(v, i))
226
+ out[i] = wholeOf(v[i]);
227
+ return out;
228
+ }
229
+ const out = {};
230
+ const names = Object.keys(v);
231
+ for (let i = 0; i < names.length; i += 1) {
232
+ const k = names[i];
233
+ if (isSecretKeyName(k))
234
+ continue;
235
+ Object.defineProperty(out, k, { value: wholeOf(v[k]), writable: true, enumerable: true, configurable: true });
236
+ }
237
+ return out;
238
+ }
239
+ function carried(w, k, v) {
240
+ if (typeof v !== 'object' || v === null)
241
+ return v;
242
+ if (w.whole)
243
+ return wholeOf(v);
244
+ const c = w.kids.get(k);
245
+ if (c !== undefined && c.node === v)
246
+ return pruned(c);
247
+ return Array.isArray(v) ? [] : {};
248
+ }
249
+ function pruned(w) {
250
+ if (w.whole)
251
+ return wholeOf(w.node);
252
+ const src = w.node;
253
+ if (Array.isArray(src)) {
254
+ const out = new Array(src.length);
255
+ for (let i = 0; i < src.length; i += 1) {
256
+ const k = String(i);
257
+ if (!Object.hasOwn(src, k))
258
+ continue;
259
+ if (w.touched.has(k))
260
+ out[i] = carried(w, k, src[k]);
261
+ else if (w.enumerated)
262
+ out[i] = null;
263
+ }
264
+ return out;
265
+ }
266
+ const out = {};
267
+ const names = Object.keys(src);
268
+ for (let i = 0; i < names.length; i += 1) {
269
+ const k = names[i];
270
+ if (isSecretKeyName(k))
271
+ continue;
272
+ const value = w.touched.has(k) ? carried(w, k, src[k]) : w.enumerated ? null : SKIP;
273
+ if (value !== SKIP)
274
+ Object.defineProperty(out, k, { value, writable: true, enumerable: true, configurable: true });
275
+ }
276
+ return out;
277
+ }
278
+ function deepFreeze(v) {
279
+ if (typeof v === 'object' && v !== null && !Object.isFrozen(v)) {
280
+ Object.freeze(v);
281
+ const names = Object.keys(v);
282
+ for (let i = 0; i < names.length; i += 1)
283
+ deepFreeze(v[names[i]]);
284
+ }
285
+ return v;
286
+ }
287
+ function sameReading(a, b, depth) {
288
+ if (Object.is(a, b))
289
+ return true;
290
+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null || depth > COPY_DEPTH_MAX * 2)
291
+ return false;
292
+ if (Array.isArray(a) !== Array.isArray(b))
293
+ return false;
294
+ const ka = Object.keys(a);
295
+ const kb = Object.keys(b);
296
+ if (ka.length !== kb.length)
297
+ return false;
298
+ for (let i = 0; i < ka.length; i += 1) {
299
+ const k = ka[i];
300
+ if (k !== kb[i] || !sameReading(a[k], b[k], depth + 1))
301
+ return false;
302
+ }
303
+ return true;
304
+ }
305
+ function readAll(e) {
306
+ return Object.values(READERS).map((read) => {
307
+ try {
308
+ return read(e);
309
+ }
310
+ catch {
311
+ return Symbol('reader-threw');
312
+ }
313
+ });
314
+ }
315
+ export function decisionRefusalCarrierOf(err) {
316
+ try {
317
+ if ((typeof err !== 'object' && typeof err !== 'function') || err === null)
318
+ return undefined;
319
+ const copy = copyOf(err, 0, { nodes: 0, path: new Set() });
320
+ if (typeof copy !== 'object' || copy === null || Array.isArray(copy))
321
+ return undefined;
322
+ const root = newWatch(copy);
323
+ const watches = new WeakMap();
324
+ const view = viewOf(root, watches);
325
+ const readers = Object.values(READERS);
326
+ for (let i = 0; i < readers.length; i += 1) {
327
+ const read = readers[i];
328
+ let out;
329
+ try {
330
+ out = read(view);
331
+ }
332
+ catch {
333
+ return undefined;
334
+ }
335
+ consumeOutput(out, watches, new Set(), 0);
336
+ }
337
+ const carrier = deepFreeze(pruned(root));
338
+ const original = readAll(err);
339
+ const fromCarrier = readAll(carrier);
340
+ for (let i = 0; i < original.length; i += 1)
341
+ if (!sameReading(original[i], fromCarrier[i], 0))
342
+ return undefined;
343
+ return carrier;
344
+ }
345
+ catch {
346
+ return undefined;
347
+ }
348
+ }
@@ -1,6 +1,7 @@
1
1
  import type { AgentClient, ElicitResponse } from '@sema-agent/sdk';
2
2
  import type { UiLanguage } from '../env/uiLanguage.js';
3
3
  import type { ToolPermissionSettledElsewhere } from './approvalResolution.js';
4
+ import { type ToolPermissionAck } from '../seatContract.js';
4
5
  import { type AskGoneDetail } from '../decideReceipt.js';
5
6
  import type { ApprovalDecidedByReading } from '../approvalDecidedByCapability.js';
6
7
  import { type DecisionNoteAudit } from './approvalDecisionNoteAudit.js';
@@ -13,6 +14,10 @@ export declare const HITL_DECISION_NOT_APPLIED_CAUSES: readonly ["gone", "parked
13
14
  export type HitlDecisionNotAppliedCause = (typeof HITL_DECISION_NOT_APPLIED_CAUSES)[number];
14
15
  export declare const HITL_DECISION_UNCONFIRMED_CAUSES: readonly ["transport", "server_error", "local_error", "aborted", "gone_after_retry"];
15
16
  export type HitlDecisionUnconfirmedCause = (typeof HITL_DECISION_UNCONFIRMED_CAUSES)[number];
17
+ export type ToolPermissionUnconfirmedCause = HitlDecisionUnconfirmedCause | 'registry_unreadable';
18
+ export interface ToolPermissionUnconfirmed {
19
+ readonly cause: ToolPermissionUnconfirmedCause;
20
+ }
16
21
  export declare const HITL_DECISION_NOT_SENT_CAUSES: readonly ["aborted", "duplicate_in_flight", "invalid_request", "no_verb", "not_an_answer"];
17
22
  export type HitlDecisionNotSentCause = (typeof HITL_DECISION_NOT_SENT_CAUSES)[number];
18
23
  export interface HitlApprovalDecisionRequest {
@@ -118,5 +123,7 @@ export declare function __setHitlDecisionSendTimingForTests(t?: HitlDecisionSend
118
123
  export declare function hitlAskIdempotencyKey(askId: string, verdict: 'approve' | 'deny'): string;
119
124
  export declare function sendHitlDecision(request: HitlDecisionSendRequest, deps: HitlDecisionSendDeps): Promise<HitlDecisionSendOutcome>;
120
125
  export declare function toolPermissionSettledLine(fact: ToolPermissionSettledElsewhere | null | undefined, lang?: UiLanguage): string | undefined;
126
+ export declare function toolPermissionUnconfirmedLine(ack: ToolPermissionAck | null | undefined, lang?: UiLanguage): string | undefined;
127
+ export declare function toolPermissionUnconfirmedOf(thrown: {} | null | undefined, signal?: AbortSignal): ToolPermissionUnconfirmed | undefined;
121
128
  export declare function hitlDecisionOutcomeContent(outcome: HitlDecisionSendOutcome, lang?: UiLanguage): string | undefined;
122
129
  export {};
@@ -1,6 +1,7 @@
1
1
  import { settleWithinDeadline } from '../abortableSleep.js';
2
2
  import { hostLog } from '../host.js';
3
3
  import { invokeHostCallbackIsolated } from '../hostCallbackGuard.js';
4
+ import { readToolPermissionAckState } from '../seatContract.js';
4
5
  import { msg, renderMessage } from '../i18n/translate.js';
5
6
  import { askGoneFromError } from '../decideReceipt.js';
6
7
  import { appendOwnElement, guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from '../ownKey.js';
@@ -14,7 +15,7 @@ import { ASK_DECIDED_CODE, classifyDeliveredDecisionRefusal, decisionRefusalClos
14
15
  import { sessionAllowEligible } from './sessionAllowRoute.js';
15
16
  import { addDecisionOpKeys, closeDecisionOp, decisionLedgerKeysOf, decisionOpsWithKey, openDecisionOp } from './decisionLedger.js';
16
17
  import { hostHoldIsActive, takeHostHoldLedgerOp, tryHoldApprovalNow } from './approvalHolds.js';
17
- import { allowNoteReadingOf, answerPayloadFor, decisionAttributionKeyOf, readApprovalDenySettledBy, readToolApprovalRespondAck, readToolApprovalRespondParking, replayedFirstDecisionOf, settlementAckOf, } from './toolApprovalWire.js';
18
+ import { allowNoteReadingOf, answerPayloadFor, decisionAttributionKeyOf, readApprovalDenySettledBy, readToolApprovalRespondAck, readToolApprovalRespondParking, replayVerdictFrom, settlementAckOf, } from './toolApprovalWire.js';
18
19
  export const HITL_DECISION_FAMILIES = Object.freeze(['approval', 'ask', 'elicitation']);
19
20
  export const HITL_DECISION_NOT_APPLIED_CAUSES = Object.freeze(['gone', 'parked', 'parking', 'lane_disabled', 'refused', 'idempotency_crossed']);
20
21
  export const HITL_DECISION_UNCONFIRMED_CAUSES = Object.freeze(['transport', 'server_error', 'local_error', 'aborted', 'gone_after_retry']);
@@ -164,9 +165,9 @@ async function sendApprovalFamily(respond, approvalId, answer, ctx) {
164
165
  return { ...base, kind: 'not_applied', cause: 'parking', ...(view !== undefined ? { parking: view, ...(hint !== undefined ? { retryAfterMs: hint } : {}) } : {}) };
165
166
  }
166
167
  const parsed = settlementAckOf(readToolApprovalRespondAck(raw));
167
- const replayWord = replayedFirstDecisionOf(parsed);
168
- if (parsed !== undefined && replayWord !== undefined) {
169
- const first = parsed.approvalId === approvalId ? verdictOf(replayWord) : undefined;
168
+ const replay = replayVerdictFrom(raw, parsed, approvalId);
169
+ if (replay.kind === 'replayed') {
170
+ const first = verdictOf(replay.firstDecision);
170
171
  return {
171
172
  ...base,
172
173
  kind: 'settled_elsewhere',
@@ -174,8 +175,8 @@ async function sendApprovalFamily(respond, approvalId, answer, ctx) {
174
175
  ...(first !== undefined && ours !== undefined && first !== ours ? { contrary: true } : {}),
175
176
  };
176
177
  }
177
- if (ownTrue(raw, 'idempotent'))
178
- return { ...base, kind: 'settled_elsewhere' };
178
+ if (replay.kind === 'unreadable')
179
+ return { ...base, kind: 'unconfirmed', cause: 'local_error' };
179
180
  const ack = parsed !== undefined && parsed.approvalId === approvalId ? parsed : undefined;
180
181
  return { ...base, kind: 'applied', ...(ack !== undefined ? { ack } : {}), ...(ctx.noteCapable ? { noteAudit: readDecisionNoteAudit(raw) } : {}) };
181
182
  }
@@ -190,9 +191,6 @@ function bodyFacts(answer, payload, rememberUnsupported) {
190
191
  function answerGateCannotTake(out) {
191
192
  return out.kind === 'not_applied' && (out.cause === 'gone' || out.cause === 'parking' || out.cause === 'lane_disabled');
192
193
  }
193
- function ownTrue(raw, key) {
194
- return typeof raw === 'object' && raw !== null && guardedRead(() => readOwnDataValue(raw, key)) === true;
195
- }
196
194
  async function sendAskFamily(respondForFallback, decideAsk, req, ctx) {
197
195
  const payload = answerPayloadFor(req.answer, 'respond', { approvalDecisionNoteCapable: ctx.noteCapable });
198
196
  if (payload === undefined)
@@ -363,8 +361,8 @@ function snapshotAnswer(raw) {
363
361
  if (kind === 'allow') {
364
362
  const allowSession = guardedRead(() => readOwnDataValue(raw, 'allowSession')) === true;
365
363
  const edited = guardedRead(() => readOwnDataValue(raw, 'updatedInput'));
366
- const noteRaw = guardedRead(() => readOwnDataValue(raw, 'note'));
367
- const note = typeof noteRaw === 'string' && noteRaw.trim() !== '' ? noteRaw : undefined;
364
+ const noteReading = guardedRead(() => allowNoteReadingOf(raw));
365
+ const note = noteReading?.kind === 'text' ? noteReading.text : undefined;
368
366
  if (edited === undefined)
369
367
  return Object.freeze({ kind: 'allow', allowSession, ...(note !== undefined ? { note } : {}) });
370
368
  let copy;
@@ -582,6 +580,30 @@ export function toolPermissionSettledLine(fact, lang) {
582
580
  return undefined;
583
581
  }
584
582
  }
583
+ function unconfirmedDecisionContent(cause, lang) {
584
+ return cause === 'gone_after_retry' ? renderMessage(msg('approval.decision.unconfirmedAfterRetry'), lang) : renderMessage(msg('approval.decideAck.unconfirmed'), lang);
585
+ }
586
+ export function toolPermissionUnconfirmedLine(ack, lang) {
587
+ try {
588
+ const state = readToolPermissionAckState(ack);
589
+ return state !== undefined && state.kind === 'unconfirmed' ? unconfirmedDecisionContent(state.cause, lang) : undefined;
590
+ }
591
+ catch {
592
+ return undefined;
593
+ }
594
+ }
595
+ export function toolPermissionUnconfirmedOf(thrown, signal) {
596
+ try {
597
+ const out = outcomeOfThrown(thrown, 'approval', undefined, signal, newSendTally(), false);
598
+ if (out.kind !== 'unconfirmed')
599
+ return undefined;
600
+ const cause = HITL_DECISION_UNCONFIRMED_CAUSES.find((w) => w === out.cause);
601
+ return cause === undefined ? undefined : Object.freeze({ cause });
602
+ }
603
+ catch {
604
+ return Object.freeze({ cause: 'local_error' });
605
+ }
606
+ }
585
607
  export function hitlDecisionOutcomeContent(outcome, lang) {
586
608
  try {
587
609
  if (typeof outcome !== 'object' || outcome === null)
@@ -594,7 +616,7 @@ export function hitlDecisionOutcomeContent(outcome, lang) {
594
616
  return first === 'deny' || first === 'approve' ? settledElsewhereContraryContent(first, lang) : undefined;
595
617
  }
596
618
  if (kind === 'unconfirmed' && readOwnDataValue(outcome, 'cause') === 'gone_after_retry')
597
- return renderMessage(msg('approval.decision.unconfirmedAfterRetry'), lang);
619
+ return unconfirmedDecisionContent('gone_after_retry', lang);
598
620
  return undefined;
599
621
  }
600
622
  catch {
@@ -22,5 +22,5 @@ export function editedApprovalAcceptanceOf(card) {
22
22
  return read.value === true ? REFUSES : UNKNOWN_MALFORMED;
23
23
  }
24
24
  export function editedApprovalRefusedLine(lang) {
25
- return renderMessage(msg('approval.editRefusal.line'), lang);
25
+ return renderMessage(msg('approval.editRefusal.line', { stem: msg('approval.editRefusal.stem') }), lang);
26
26
  }
@@ -0,0 +1,4 @@
1
+ import type { EventLegElicitationFrame } from '../eventLeg.js';
2
+ import type { UiLanguage } from '../env/uiLanguage.js';
3
+ import type { HitlDecisionSendOutcome } from './decisionSend.js';
4
+ export declare function elicitationRefusedLine(frame: EventLegElicitationFrame, outcome: HitlDecisionSendOutcome, lang?: UiLanguage): string | undefined;
@@ -0,0 +1,23 @@
1
+ import { capForDisplay } from '../fleetTaskDesc.js';
2
+ import { msg, renderMessage } from '../i18n/translate.js';
3
+ import { guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from '../ownKey.js';
4
+ const SERVER_NAME_SHOWN_MAX = 40;
5
+ export function elicitationRefusedLine(frame, outcome, lang) {
6
+ try {
7
+ if (typeof frame !== 'object' || frame === null || typeof outcome !== 'object' || outcome === null)
8
+ return undefined;
9
+ if (guardedRead(() => readOwnDataValue(frame, 'type')) !== 'elicitation')
10
+ return undefined;
11
+ if (guardedRead(() => readOwnDataValue(outcome, 'family')) !== 'elicitation')
12
+ return undefined;
13
+ if (guardedRead(() => readOwnDataValue(outcome, 'kind')) !== 'applied')
14
+ return undefined;
15
+ const name = guardedRead(() => readOwnDataNonEmptyString(frame, 'mcpServerName'));
16
+ return name === undefined
17
+ ? renderMessage(msg('mcp.elicitation.refused.unnamed'), lang)
18
+ : renderMessage(msg('mcp.elicitation.refused.named', { server: capForDisplay(name, SERVER_NAME_SHOWN_MAX) }), lang);
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
@@ -38,9 +38,8 @@ export interface AskGateWireDeps {
38
38
  onToolApprovalOutcome?: (frame: ToolApprovalFrame, resolution: ApprovalResolution) => void | Promise<void>;
39
39
  onDecideOperation?: DecideOperationObserver;
40
40
  onReplayedApproval?: (frame: ToolApprovalFrame, disposition: ReplayedApprovalDisposition) => void | Promise<void>;
41
+ engineGeneration?: () => number;
41
42
  }
42
- export declare function setBridgeRunHandleFallback(deps: object, read: () => string | undefined): void;
43
- export declare function bridgeRunHandleFallbackOf(deps: object): string | undefined;
44
43
  type GateKind = 'ask' | 'fs';
45
44
  export interface GatePark {
46
45
  gate: GateKind;
@@ -73,6 +72,7 @@ export interface FrameRouterCtx {
73
72
  deps: AskGateWireDeps;
74
73
  taskId: TaskIdRef;
75
74
  signal?: AbortSignal | undefined;
75
+ streamGeneration?: number | undefined;
76
76
  }
77
77
  export declare function isAskTool(toolName: string | undefined): boolean;
78
78
  export declare function questionCardVerdict(carrier: object | null | undefined): boolean | undefined;
@@ -89,6 +89,8 @@ function policyDenyHeadFor(cause) {
89
89
  return renderMessage(msg('approval.policyDeny.denyRule', { tail }));
90
90
  case 'engine_floor':
91
91
  return renderMessage(msg('approval.policyDeny.engineFloor', { tail }));
92
+ case 'hook':
93
+ return renderMessage(msg('approval.policyDeny.hook'));
92
94
  case 'no_approval_ui':
93
95
  case undefined:
94
96
  return HITL_POLICY_DENY_MESSAGE;
@@ -117,20 +119,6 @@ function denyStampedEnd(ev, attribution) {
117
119
  export const HITL_INTERRUPT_MESSAGE_FOR_TOOL_USE = '[Request interrupted by user for tool use]';
118
120
  const RUN_CANCELLED_ERROR_CODE = RUN_CANCELLED_CODE;
119
121
  export const ENGINE_ABORT_TOOL_RESULT = 'Operation aborted';
120
- const bridgeRunHandleFallbacks = new WeakMap();
121
- export function setBridgeRunHandleFallback(deps, read) {
122
- bridgeRunHandleFallbacks.set(deps, read);
123
- }
124
- export function bridgeRunHandleFallbackOf(deps) {
125
- try {
126
- const read = bridgeRunHandleFallbacks.get(deps);
127
- const v = read?.();
128
- return typeof v === 'string' && v !== '' ? v : undefined;
129
- }
130
- catch {
131
- return undefined;
132
- }
133
- }
134
122
  function isAskToolLoose(name) {
135
123
  return typeof name === 'string' && name.replace(/[\s_-]+/g, '').toLowerCase() === 'askuserquestion';
136
124
  }
@@ -371,7 +359,12 @@ async function routeToolApprovalFrame(ev, ctx) {
371
359
  const gatedCallId = fromSubagent ? undefined : frameCallId ?? led.lastPendingFsCall();
372
360
  const argsCallId = frameCallId === undefined ? gatedCallId : typeof ev.toolName === 'string' && toolNameIsFsWrite(ev.toolName) ? frameCallId : undefined;
373
361
  const runTaskId = ctx.taskId.current;
374
- const launched = surfaceToolApprovalFrameAndRespond(ev, deps.respondToolApproval, argsOfGatedStart(led, argsCallId), ctx.signal, deps.approvalLane, typeof runTaskId === 'string' && runTaskId !== '' ? { taskId: runTaskId } : undefined);
362
+ const streamGeneration = ctx.streamGeneration;
363
+ const runFacts = {
364
+ ...(typeof runTaskId === 'string' && runTaskId !== '' ? { taskId: runTaskId } : {}),
365
+ ...(streamGeneration !== undefined ? { sourceGeneration: streamGeneration } : {}),
366
+ };
367
+ const launched = surfaceToolApprovalFrameAndRespond(ev, deps.respondToolApproval, argsOfGatedStart(led, argsCallId), ctx.signal, deps.approvalLane, Object.keys(runFacts).length > 0 ? runFacts : undefined);
375
368
  const hold = liveCardHoldOf(liveFrameCallKey(ev.approvalId));
376
369
  const handled = launched.then((outcome) => settleLiveCardOutcome(ev, outcome, ctx, fromSubagent, gatedCallId), (e) => {
377
370
  hostLog('debug', `liveHitlAskWire: tool_approval card for ${ev.approvalId} failed: ${String(e).slice(0, 160)}`);
@@ -1,9 +1,14 @@
1
1
  export declare const PLAN_REVIEW_QUESTION_ID_PREFIX = "plan-review:";
2
2
  export declare const REOPEN_ID_TAIL = "#reopen-";
3
+ export declare const SCREEN_CARD_ORIGINS: readonly ["live-approval", "park-approval", "park-question", "plan-review", "host-reopen-question", "host-choice", "local-permission"];
4
+ export type ScreenCardOrigin = (typeof SCREEN_CARD_ORIGINS)[number];
3
5
  export declare function approvalCallKey(gatedCallId: string | undefined, taskId: string): string;
4
6
  export declare function askGateQuestionId(callKey: string): string;
5
7
  export declare function planReviewQuestionId(taskId: string): string;
6
8
  export declare function freshPlanReviewQuestionId(taskId: string, suffix: string): string;
9
+ export declare function hostReopenQuestionId(rowTaskId: string, suffix: string): string;
10
+ export declare function hostRunChoiceQuestionId(taskId: string, suffix: string): string;
11
+ export declare function questionCardOriginOf(questionId: {} | null | undefined): Extract<ScreenCardOrigin, 'park-question' | 'plan-review' | 'host-reopen-question' | 'host-choice'> | undefined;
7
12
  export declare function liveFrameCallKey(approvalId: string): string;
8
13
  export declare function taskIdFromPlanReviewQuestionId(questionId: string): string | undefined;
9
14
  export declare function armedKeyFromQuestionId(questionId: string): string;
@@ -2,6 +2,9 @@ const HITL_ASK_QUESTION_ID_PREFIX = 'hitl-ask:';
2
2
  export const PLAN_REVIEW_QUESTION_ID_PREFIX = 'plan-review:';
3
3
  const HITL_FRAME_CALL_KEY_PREFIX = 'hitl-frame:';
4
4
  export const REOPEN_ID_TAIL = '#reopen-';
5
+ const HOST_REOPEN_QUESTION_ID_PREFIX = 'ask-park:';
6
+ const HOST_RUN_CHOICE_QUESTION_ID_PREFIX = 'active-run:';
7
+ export const SCREEN_CARD_ORIGINS = Object.freeze(['live-approval', 'park-approval', 'park-question', 'plan-review', 'host-reopen-question', 'host-choice', 'local-permission']);
5
8
  export function approvalCallKey(gatedCallId, taskId) {
6
9
  return gatedCallId ?? taskId;
7
10
  }
@@ -14,6 +17,26 @@ export function planReviewQuestionId(taskId) {
14
17
  export function freshPlanReviewQuestionId(taskId, suffix) {
15
18
  return `${planReviewQuestionId(taskId)}${REOPEN_ID_TAIL}${suffix}`;
16
19
  }
20
+ export function hostReopenQuestionId(rowTaskId, suffix) {
21
+ return `${HOST_REOPEN_QUESTION_ID_PREFIX}${rowTaskId}${REOPEN_ID_TAIL}${suffix}`;
22
+ }
23
+ export function hostRunChoiceQuestionId(taskId, suffix) {
24
+ return `${HOST_RUN_CHOICE_QUESTION_ID_PREFIX}${taskId}${REOPEN_ID_TAIL}${suffix}`;
25
+ }
26
+ export function questionCardOriginOf(questionId) {
27
+ if (typeof questionId !== 'string')
28
+ return undefined;
29
+ const has = (prefix) => questionId.startsWith(prefix) && questionId.length > prefix.length;
30
+ if (has(HITL_ASK_QUESTION_ID_PREFIX))
31
+ return 'park-question';
32
+ if (has(PLAN_REVIEW_QUESTION_ID_PREFIX))
33
+ return 'plan-review';
34
+ if (has(HOST_REOPEN_QUESTION_ID_PREFIX))
35
+ return 'host-reopen-question';
36
+ if (has(HOST_RUN_CHOICE_QUESTION_ID_PREFIX))
37
+ return 'host-choice';
38
+ return undefined;
39
+ }
17
40
  export function liveFrameCallKey(approvalId) {
18
41
  return `${HITL_FRAME_CALL_KEY_PREFIX}${approvalId}`;
19
42
  }
@@ -138,6 +138,12 @@ export type FindPendingOutcome = {
138
138
  readonly kind: 'ok';
139
139
  }>;
140
140
  };
141
+ export interface PendingRowCallIdentity {
142
+ readonly taskId?: string | null;
143
+ readonly toolCallId?: string | null;
144
+ readonly boundCallId?: string | null;
145
+ }
146
+ export declare function pendingRowAnswersCall(row: PendingRowCallIdentity, taskId: string, callId: string): boolean;
141
147
  export declare function findPendingForTask(client: HitlClientLike, taskId: string, matches: (toolName: string | undefined) => boolean, opts?: {
142
148
  signal?: AbortSignal;
143
149
  }, callId?: string, identityAccepts?: (row: PendingCheckpoint) => boolean): Promise<FindPendingOutcome>;