@sema-agent/client-core 0.97.0 → 0.98.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 (281) hide show
  1. package/CHANGELOG.md +429 -0
  2. package/README.md +74 -36
  3. package/dist/adapt/arms.d.ts +1 -0
  4. package/dist/adapt/arms.js +128 -34
  5. package/dist/adapt/ids.d.ts +12 -1
  6. package/dist/adapt/ids.js +59 -8
  7. package/dist/adapt/instanceLedger.d.ts +50 -0
  8. package/dist/adapt/instanceLedger.js +147 -0
  9. package/dist/adapt/textStream.d.ts +1 -0
  10. package/dist/adapt/textStream.js +24 -7
  11. package/dist/adapt/toolCards.d.ts +27 -5
  12. package/dist/adapt/toolCards.js +39 -6
  13. package/dist/adapt/wireShapes.js +6 -2
  14. package/dist/adapt.d.ts +2 -0
  15. package/dist/adapt.js +8 -3
  16. package/dist/adapter/activeRunSelfHeal.d.ts +5 -0
  17. package/dist/adapter/activeRunSelfHeal.js +51 -28
  18. package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
  19. package/dist/adapter/downstream/eventToSdkMessage.js +27 -34
  20. package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
  21. package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
  22. package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
  23. package/dist/adapter/runStream.js +29 -13
  24. package/dist/adapter/types.d.ts +4 -4
  25. package/dist/agentSession/backgroundView.js +2 -1
  26. package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
  27. package/dist/agentSession/engineAgentRegistryRead.js +12 -13
  28. package/dist/agentsWireCaps.d.ts +8 -6
  29. package/dist/agentsWireCaps.js +177 -162
  30. package/dist/approvalDecidedByCapability.d.ts +0 -4
  31. package/dist/approvalDecidedByCapability.js +0 -6
  32. package/dist/approvalsStreamLiveCapability.d.ts +0 -4
  33. package/dist/approvalsStreamLiveCapability.js +0 -6
  34. package/dist/assistantInbox.d.ts +34 -0
  35. package/dist/assistantInbox.js +118 -0
  36. package/dist/centerWiringCapability.js +9 -1
  37. package/dist/clientSlice.d.ts +0 -9
  38. package/dist/clientSlice.js +0 -3
  39. package/dist/cloudConfigWireCaps.d.ts +4 -2
  40. package/dist/cloudConfigWireCaps.js +81 -61
  41. package/dist/compensations.js +1 -1
  42. package/dist/connectorStatus.d.ts +21 -0
  43. package/dist/connectorStatus.js +112 -0
  44. package/dist/controlRouter.d.ts +14 -1
  45. package/dist/controlRouter.js +68 -17
  46. package/dist/coreValuePorts.d.ts +3 -3
  47. package/dist/decideReceipt.d.ts +2 -2
  48. package/dist/decideReceipt.js +5 -2
  49. package/dist/declared/supportFloorDeclared.js +3 -3
  50. package/dist/deviceExecutorManagementCapability.d.ts +0 -4
  51. package/dist/deviceExecutorManagementCapability.js +0 -6
  52. package/dist/deviceRebind.d.ts +49 -1
  53. package/dist/deviceRebind.js +221 -3
  54. package/dist/displayUntrusted.d.ts +1 -0
  55. package/dist/displayUntrusted.js +250 -76
  56. package/dist/engineAgentAbsence.d.ts +1 -1
  57. package/dist/engineAgentPanelStore.d.ts +5 -4
  58. package/dist/engineAgentPanelStore.js +3 -12
  59. package/dist/engineCapReader.d.ts +0 -4
  60. package/dist/engineCapReader.js +1 -5
  61. package/dist/engineCapsCache.d.ts +4 -0
  62. package/dist/engineCapsCache.js +17 -12
  63. package/dist/engineClosedSets.d.ts +1 -0
  64. package/dist/engineClosedSets.js +4 -1
  65. package/dist/engineErrorCodes.d.ts +9 -2
  66. package/dist/engineErrorCodes.js +9 -1
  67. package/dist/engineIdentity.d.ts +1 -0
  68. package/dist/engineIdentity.js +8 -0
  69. package/dist/engineRowRef.d.ts +28 -0
  70. package/dist/engineRowRef.js +111 -0
  71. package/dist/engineSessionMessages.d.ts +67 -0
  72. package/dist/engineSessionMessages.js +364 -0
  73. package/dist/engineToolDirectory.d.ts +18 -0
  74. package/dist/engineToolDirectory.js +85 -0
  75. package/dist/engineUrl.d.ts +18 -0
  76. package/dist/engineUrl.js +52 -0
  77. package/dist/env/uiLanguage.d.ts +9 -0
  78. package/dist/env/uiLanguage.js +35 -0
  79. package/dist/eventLeg.d.ts +92 -0
  80. package/dist/eventLeg.js +285 -0
  81. package/dist/executionLaneCapability.d.ts +0 -4
  82. package/dist/executionLaneCapability.js +3 -16
  83. package/dist/fileHistoryCaptureCapability.d.ts +0 -4
  84. package/dist/fileHistoryCaptureCapability.js +5 -7
  85. package/dist/fleet/fleetLedger.d.ts +0 -3
  86. package/dist/fleet/fleetLedger.js +21 -36
  87. package/dist/fleet/fleetProjection.d.ts +2 -2
  88. package/dist/fleet/fleetProjection.js +10 -8
  89. package/dist/frameBinding.d.ts +5 -0
  90. package/dist/frameBinding.js +23 -0
  91. package/dist/gateFailureCodes.d.ts +2 -0
  92. package/dist/gateFailureCodes.js +15 -0
  93. package/dist/gateOutcome.d.ts +3 -1
  94. package/dist/gateOutcome.js +25 -6
  95. package/dist/gateVocabulary.d.ts +5 -0
  96. package/dist/gateVocabulary.js +64 -2
  97. package/dist/generated/engineAskFaceTables.js +2 -2
  98. package/dist/generated/engineFactTables.d.ts +6 -3
  99. package/dist/generated/engineFactTables.js +22 -4
  100. package/dist/generated/engineNoticeTables.js +9 -0
  101. package/dist/generated/toolNameTables.d.ts +1 -0
  102. package/dist/generated/toolNameTables.js +1 -0
  103. package/dist/hitl/allowRuleShadow.d.ts +6 -1
  104. package/dist/hitl/allowRuleShadow.js +21 -17
  105. package/dist/hitl/approvalCardReading.d.ts +15 -0
  106. package/dist/hitl/approvalCardReading.js +154 -0
  107. package/dist/hitl/approvalCardReasons.d.ts +13 -0
  108. package/dist/hitl/approvalCardReasons.js +120 -0
  109. package/dist/hitl/approvalHolds.d.ts +47 -15
  110. package/dist/hitl/approvalHolds.js +134 -28
  111. package/dist/hitl/approvalResolution.d.ts +51 -26
  112. package/dist/hitl/approvalResolution.js +86 -122
  113. package/dist/hitl/approvalsFeed.js +6 -18
  114. package/dist/hitl/askClassPair.d.ts +2 -0
  115. package/dist/hitl/askClassPair.js +1 -0
  116. package/dist/hitl/askGateWire.d.ts +20 -2
  117. package/dist/hitl/askGateWire.js +49 -1
  118. package/dist/hitl/askParkRowRouting.d.ts +5 -0
  119. package/dist/hitl/askParkRowRouting.js +32 -1
  120. package/dist/hitl/askSettlementLine.d.ts +18 -0
  121. package/dist/hitl/askSettlementLine.js +79 -0
  122. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  123. package/dist/hitl/automaticAnswerVerdict.js +21 -5
  124. package/dist/hitl/crashConverged.d.ts +11 -20
  125. package/dist/hitl/crashConverged.js +56 -0
  126. package/dist/hitl/crashConvergedNotice.d.ts +3 -1
  127. package/dist/hitl/crashConvergedNotice.js +48 -11
  128. package/dist/hitl/decisionConflict.js +3 -10
  129. package/dist/hitl/decisionRefusal.d.ts +40 -1
  130. package/dist/hitl/decisionRefusal.js +199 -42
  131. package/dist/hitl/frameRouter.d.ts +5 -2
  132. package/dist/hitl/frameRouter.js +20 -16
  133. package/dist/hitl/gateLedger.d.ts +2 -0
  134. package/dist/hitl/gateLedger.js +50 -13
  135. package/dist/hitl/hitlBridge.d.ts +1 -2
  136. package/dist/hitl/hitlBridge.js +10 -7
  137. package/dist/hitl/livePendingAsk.d.ts +3 -3
  138. package/dist/hitl/livePendingAsk.js +7 -18
  139. package/dist/hitl/parkResolver.d.ts +2 -24
  140. package/dist/hitl/parkResolver.js +61 -97
  141. package/dist/hitl/persistedRulesWire.d.ts +24 -0
  142. package/dist/hitl/persistedRulesWire.js +122 -2
  143. package/dist/hitl/planReviewWire.d.ts +26 -13
  144. package/dist/hitl/planReviewWire.js +112 -78
  145. package/dist/hitl/refusedToolNameProse.d.ts +0 -1
  146. package/dist/hitl/refusedToolNameProse.js +0 -3
  147. package/dist/hitl/replayedApproval.d.ts +4 -3
  148. package/dist/hitl/replayedApproval.js +7 -4
  149. package/dist/hitl/sessionPolicyDeliverable.js +2 -4
  150. package/dist/hitl/sessionPolicyWire.d.ts +32 -20
  151. package/dist/hitl/sessionPolicyWire.js +162 -52
  152. package/dist/hitl/standingRows.d.ts +20 -2
  153. package/dist/hitl/standingRows.js +69 -8
  154. package/dist/hitl/toolApprovalWire.d.ts +87 -152
  155. package/dist/hitl/toolApprovalWire.js +591 -380
  156. package/dist/hookMatcherVerdict.d.ts +6 -1
  157. package/dist/hookMatcherVerdict.js +14 -7
  158. package/dist/hooksWireCaps.d.ts +2 -2
  159. package/dist/hooksWireCaps.js +59 -55
  160. package/dist/i18n/messages.en.d.ts +121 -0
  161. package/dist/i18n/messages.en.js +119 -0
  162. package/dist/i18n/messages.zh.d.ts +3 -0
  163. package/dist/i18n/messages.zh.js +120 -0
  164. package/dist/i18n/translate.d.ts +25 -0
  165. package/dist/i18n/translate.js +127 -0
  166. package/dist/index.d.ts +53 -18
  167. package/dist/index.js +38 -10
  168. package/dist/inheritEnvCapability.d.ts +31 -0
  169. package/dist/inheritEnvCapability.js +104 -0
  170. package/dist/liveModelCatalog.d.ts +1 -2
  171. package/dist/liveModelCatalog.js +2 -6
  172. package/dist/liveQuestionStore.d.ts +2 -21
  173. package/dist/mcpLiveness.d.ts +2 -1
  174. package/dist/mcpProbeWire.d.ts +6 -1
  175. package/dist/mcpProbeWire.js +1 -1
  176. package/dist/mcpWireCaps.d.ts +13 -2
  177. package/dist/mcpWireCaps.js +48 -0
  178. package/dist/memoryEntriesWire.d.ts +4 -9
  179. package/dist/model/modelSupplyRules.d.ts +0 -2
  180. package/dist/model/modelSupplyRules.js +3 -12
  181. package/dist/model/modelsPolicy.d.ts +0 -5
  182. package/dist/model/modelsPolicy.js +6 -36
  183. package/dist/model/subagentModelWord.d.ts +31 -0
  184. package/dist/model/subagentModelWord.js +261 -0
  185. package/dist/notifications.d.ts +6 -0
  186. package/dist/notifications.js +71 -23
  187. package/dist/outputStyleSeatCapability.d.ts +0 -3
  188. package/dist/outputStyleSeatCapability.js +0 -3
  189. package/dist/ownKey.d.ts +15 -0
  190. package/dist/ownKey.js +60 -3
  191. package/dist/panelReduce.d.ts +15 -9
  192. package/dist/panelReduce.js +680 -549
  193. package/dist/panelStateHolder.d.ts +3 -7
  194. package/dist/panelStateHolder.js +14 -130
  195. package/dist/peerLaneCapability.d.ts +0 -4
  196. package/dist/peerLaneCapability.js +0 -6
  197. package/dist/permissionRulesWriteCapability.d.ts +0 -4
  198. package/dist/permissionRulesWriteCapability.js +0 -6
  199. package/dist/permissionWireCaps.d.ts +2 -2
  200. package/dist/permissionWireCaps.js +2 -0
  201. package/dist/permissionsAllowGrantCapability.d.ts +0 -4
  202. package/dist/permissionsAllowGrantCapability.js +0 -6
  203. package/dist/permissionsDeclaration.d.ts +0 -11
  204. package/dist/permissionsDeclaration.js +60 -53
  205. package/dist/pluginHooksWire.d.ts +1 -1
  206. package/dist/pluginHooksWire.js +3 -6
  207. package/dist/preemptWire.d.ts +44 -0
  208. package/dist/preemptWire.js +83 -0
  209. package/dist/printToolResultFrame.js +15 -4
  210. package/dist/replayBody.d.ts +3 -0
  211. package/dist/replayBody.js +14 -0
  212. package/dist/request/taskRequest.d.ts +0 -1
  213. package/dist/request/taskRequest.js +0 -3
  214. package/dist/resumeRefusalCopy.d.ts +2 -1
  215. package/dist/resumeRefusalCopy.js +38 -2
  216. package/dist/retryStatus.d.ts +8 -0
  217. package/dist/retryStatus.js +106 -1
  218. package/dist/rewindArchiveCapability.d.ts +0 -4
  219. package/dist/rewindArchiveCapability.js +2 -10
  220. package/dist/rewindArchiveReading.d.ts +0 -1
  221. package/dist/rewindArchiveReading.js +0 -3
  222. package/dist/runCancelContext.d.ts +2 -1
  223. package/dist/runCancelContext.js +4 -2
  224. package/dist/runReattachPolicy.d.ts +31 -0
  225. package/dist/runReattachPolicy.js +46 -0
  226. package/dist/runTerminal.d.ts +3 -6
  227. package/dist/runTerminal.js +8 -9
  228. package/dist/sandboxWire.d.ts +3 -1
  229. package/dist/sandboxWire.js +76 -27
  230. package/dist/scenarioWire.js +1 -1
  231. package/dist/seam.d.ts +24 -2
  232. package/dist/seam.js +15 -3
  233. package/dist/seatContract.d.ts +53 -10
  234. package/dist/seatContract.js +132 -81
  235. package/dist/sessionPolicyCapability.d.ts +0 -4
  236. package/dist/sessionPolicyCapability.js +0 -6
  237. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
  238. package/dist/sessionSyncFileHistoryCapability.js +0 -3
  239. package/dist/skillToolListsCapability.d.ts +0 -3
  240. package/dist/skillToolListsCapability.js +0 -3
  241. package/dist/sqlEngineCapability.d.ts +0 -4
  242. package/dist/sqlEngineCapability.js +0 -6
  243. package/dist/steerPriorityCapability.d.ts +0 -3
  244. package/dist/steerPriorityCapability.js +0 -3
  245. package/dist/streamDrainingLegs.d.ts +4 -0
  246. package/dist/streamDrainingLegs.js +6 -1
  247. package/dist/subagent/engineCompactWire.d.ts +0 -1
  248. package/dist/subagent/engineCompactWire.js +7 -5
  249. package/dist/subagent/engineTaskHandleWire.js +4 -7
  250. package/dist/subagentContentStore.js +1 -11
  251. package/dist/submitReopen.d.ts +24 -0
  252. package/dist/submitReopen.js +75 -0
  253. package/dist/terminalStatuses.d.ts +3 -0
  254. package/dist/terminalStatuses.js +10 -2
  255. package/dist/toolResult.d.ts +10 -1
  256. package/dist/toolResult.js +34 -6
  257. package/dist/toolRoster.d.ts +0 -2
  258. package/dist/toolRoster.js +0 -2
  259. package/dist/turnFailurePresentation.d.ts +28 -0
  260. package/dist/turnFailurePresentation.js +205 -0
  261. package/dist/userInvokedSkillsCapability.d.ts +0 -3
  262. package/dist/userInvokedSkillsCapability.js +0 -3
  263. package/dist/webSearchBackendCapability.d.ts +0 -4
  264. package/dist/webSearchBackendCapability.js +0 -6
  265. package/dist/wireErrorTriage.js +5 -24
  266. package/dist/wireFailureShape.d.ts +62 -5
  267. package/dist/wireFailureShape.js +105 -5
  268. package/dist/wireRefusalCopy.d.ts +12 -2
  269. package/dist/wireRefusalCopy.js +50 -52
  270. package/dist/workflowsJournalCapability.d.ts +0 -4
  271. package/dist/workflowsJournalCapability.js +0 -6
  272. package/dist/writeProtectionCapability.d.ts +0 -4
  273. package/dist/writeProtectionCapability.js +0 -6
  274. package/docs/INTEGRATION-CLIENTS.md +1305 -46
  275. package/package.json +5 -4
  276. package/dist/attachmentSeatCapability.d.ts +0 -12
  277. package/dist/attachmentSeatCapability.js +0 -23
  278. package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
  279. package/dist/hitl/approvalOutcomeNote.js +0 -29
  280. package/dist/sessionReadRedactionCapability.d.ts +0 -13
  281. package/dist/sessionReadRedactionCapability.js +0 -35
@@ -1,36 +1,61 @@
1
1
  import type { DecideReceiptView } from '../decideReceipt.js';
2
- import type { HitlSafetyCode } from './hitlBridge.js';
3
- import type { FsApprovalOutcome, ToolApprovalFrameOutcome, ToolApprovalRespondAckView, ToolApprovalRespondDecision, ToolApprovalRespondParkingView } from './toolApprovalWire.js';
4
- export declare const APPROVAL_NOT_SENT_CAUSES: readonly ["retracted", "edit_refused", "no_pending", "fetch_failed", "no_input", "card_unavailable"];
2
+ import { type HitlSafetyCode } from './hitlBridge.js';
3
+ import type { AskAnsweredOutput } from './gateLedger.js';
4
+ import type { ApprovalDenySettledBy, ToolApprovalRespondAckView, ToolApprovalRespondDecision, ToolApprovalRespondParkingView } from './toolApprovalWire.js';
5
+ import { type DecisionRefusalReading, type RefusalRouteContext } from './decisionRefusal.js';
6
+ export declare const APPROVAL_RESOLUTION_LANES: readonly ["respond", "decide", "ask"];
7
+ export type ApprovalResolutionLane = (typeof APPROVAL_RESOLUTION_LANES)[number];
8
+ export declare const APPROVAL_NOT_SENT_CAUSES: readonly ["retracted", "edit_refused", "no_pending", "wrong_gate", "fetch_failed", "no_input", "card_unavailable", "safety_stop"];
5
9
  export type ApprovalNotSentCause = (typeof APPROVAL_NOT_SENT_CAUSES)[number];
6
- export declare const APPROVAL_UNSETTLED_CAUSES: readonly ["engine_refused", "decide_failed", "transport_exhausted", "safety_stop", "respond_failed", "parking_in_progress", "interrupted", "orchestration", "unreadable"];
10
+ export declare const APPROVAL_UNSETTLED_CAUSES: readonly ["engine_refused", "engine_error", "no_answer", "transport_exhausted", "parking_in_progress", "interrupted", "orchestration", "unreadable"];
7
11
  export type ApprovalUnsettledCause = (typeof APPROVAL_UNSETTLED_CAUSES)[number];
8
- export interface ApprovalResolutionDecided {
9
- kind: 'decided';
10
- decision: ToolApprovalRespondDecision;
11
- gatedCallId?: string;
12
- receipt?: DecideReceiptView;
13
- ack?: ToolApprovalRespondAckView;
12
+ export interface ApprovalDenyFacts {
13
+ readonly settledBy?: ApprovalDenySettledBy;
14
+ readonly reason?: string;
15
+ readonly attributionKey?: 'dropped' | 'renamed';
14
16
  }
15
- export interface ApprovalResolutionNotSent {
16
- kind: 'not_sent';
17
- cause: ApprovalNotSentCause;
18
- gatedCallId?: string;
19
- detail?: string;
17
+ interface ApprovalResolutionBase {
18
+ readonly lane: ApprovalResolutionLane;
19
+ readonly gatedCallId?: string;
20
+ readonly joinedInFlight?: true;
20
21
  }
21
- export interface ApprovalResolutionUnsettled {
22
- kind: 'unsettled';
23
- cause: ApprovalUnsettledCause;
24
- gatedCallId?: string;
25
- safetyCode?: HitlSafetyCode;
26
- errorCode?: string;
27
- status?: number;
28
- detail?: string;
29
- parking?: ToolApprovalRespondParkingView;
22
+ export interface ApprovalResolutionDecided extends ApprovalResolutionBase {
23
+ readonly kind: 'decided';
24
+ readonly decision: ToolApprovalRespondDecision;
25
+ readonly deny?: ApprovalDenyFacts;
26
+ readonly receipt?: DecideReceiptView;
27
+ readonly ack?: ToolApprovalRespondAckView;
28
+ readonly answered?: AskAnsweredOutput;
29
+ }
30
+ export interface ApprovalResolutionNotSent extends ApprovalResolutionBase {
31
+ readonly kind: 'not_sent';
32
+ readonly cause: ApprovalNotSentCause;
33
+ readonly safetyCode?: Exclude<HitlSafetyCode, 'binding_mismatch' | 'no_pending' | 'wrong_gate'>;
34
+ readonly detail?: string;
35
+ }
36
+ export interface ApprovalResolutionUnsettled extends ApprovalResolutionBase {
37
+ readonly kind: 'unsettled';
38
+ readonly cause: ApprovalUnsettledCause;
39
+ readonly safetyCode?: 'binding_mismatch';
40
+ readonly refusal?: DecisionRefusalReading;
41
+ readonly parking?: ToolApprovalRespondParkingView;
42
+ readonly detail?: string;
30
43
  }
31
44
  export type ApprovalResolution = ApprovalResolutionDecided | ApprovalResolutionNotSent | ApprovalResolutionUnsettled;
32
- export type ApprovalLegOutcome = FsApprovalOutcome | ToolApprovalFrameOutcome;
33
- export declare function approvalResolutionOf(outcome: ApprovalLegOutcome): ApprovalResolution;
34
45
  export declare function isApprovalDecided(r: ApprovalResolution): r is ApprovalResolutionDecided;
35
46
  export declare function approvalNotSentCause(r: ApprovalResolution): ApprovalNotSentCause | undefined;
36
47
  export declare function approvalUnsettledCause(r: ApprovalResolution): ApprovalUnsettledCause | undefined;
48
+ export declare const APPROVAL_NOTE_RETRACTED_DETAIL = "the card was retracted (this host no longer has a decision port for it)";
49
+ export declare const APPROVAL_NOTE_EDIT_REFUSED_DETAIL = "edits are not accepted on this card";
50
+ export declare function approvalResolutionDetail(r: ApprovalResolution): string | undefined;
51
+ export declare function unsettledCauseOfReading(reading: DecisionRefusalReading): 'engine_refused' | 'engine_error' | 'no_answer';
52
+ export interface DecisionFailureMint {
53
+ readonly lane: ApprovalResolutionLane;
54
+ readonly route: NonNullable<RefusalRouteContext['route']>;
55
+ readonly gatedCallId?: string | undefined;
56
+ readonly detail?: string | undefined;
57
+ readonly attributionCarried?: boolean | undefined;
58
+ }
59
+ export declare function resolutionOfDecisionFailure(e: {} | null | undefined, m: DecisionFailureMint): ApprovalResolution;
60
+ export declare function joinedResolution(r: ApprovalResolution, gatedCallId?: string): ApprovalResolution;
61
+ export {};
@@ -1,156 +1,120 @@
1
+ import { DecideTransportRetryExhaustedError } from './hitlBridge.js';
2
+ import { mintDecisionRefusalReading, refusalCarrierOf } from './decisionRefusal.js';
3
+ import { thrownIsInstanceOf } from '../wireFailureShape.js';
4
+ export const APPROVAL_RESOLUTION_LANES = Object.freeze(['respond', 'decide', 'ask']);
1
5
  export const APPROVAL_NOT_SENT_CAUSES = Object.freeze([
2
6
  'retracted',
3
7
  'edit_refused',
4
8
  'no_pending',
9
+ 'wrong_gate',
5
10
  'fetch_failed',
6
11
  'no_input',
7
12
  'card_unavailable',
13
+ 'safety_stop',
8
14
  ]);
9
15
  export const APPROVAL_UNSETTLED_CAUSES = Object.freeze([
10
16
  'engine_refused',
11
- 'decide_failed',
17
+ 'engine_error',
18
+ 'no_answer',
12
19
  'transport_exhausted',
13
- 'safety_stop',
14
- 'respond_failed',
15
20
  'parking_in_progress',
16
21
  'interrupted',
17
22
  'orchestration',
18
23
  'unreadable',
19
24
  ]);
20
- const FS_OUTCOME_KINDS = Object.freeze(['decided', 'aborted', 'retracted', 'failed']);
21
- function str(v) {
22
- return typeof v === 'string' && v.length > 0 ? v : undefined;
25
+ export function isApprovalDecided(r) {
26
+ return typeof r === 'object' && r !== null && r.kind === 'decided';
23
27
  }
24
- function num(v) {
25
- return typeof v === 'number' && Number.isFinite(v) ? v : undefined;
28
+ export function approvalNotSentCause(r) {
29
+ if (typeof r !== 'object' || r === null || r.kind !== 'not_sent')
30
+ return undefined;
31
+ return r.cause;
26
32
  }
27
- function pick(o, key) {
33
+ export function approvalUnsettledCause(r) {
34
+ if (typeof r !== 'object' || r === null || r.kind !== 'unsettled')
35
+ return undefined;
36
+ return r.cause;
37
+ }
38
+ export const APPROVAL_NOTE_RETRACTED_DETAIL = 'the card was retracted (this host no longer has a decision port for it)';
39
+ export const APPROVAL_NOTE_EDIT_REFUSED_DETAIL = 'edits are not accepted on this card';
40
+ const NOT_SENT_SENTENCES = Object.freeze({
41
+ retracted: APPROVAL_NOTE_RETRACTED_DETAIL,
42
+ edit_refused: APPROVAL_NOTE_EDIT_REFUSED_DETAIL,
43
+ no_pending: 'there was no pending approval to decide for this run (it may already have been decided or expired); nothing was sent',
44
+ wrong_gate: 'the pending approval is waiting at a different kind of gate than this card; nothing was sent',
45
+ fetch_failed: 'the pending approval could not be fetched; nothing was sent',
46
+ no_input: 'the approval has no tool input or question to show, so no card was shown; nothing was sent',
47
+ card_unavailable: 'no approval card could be shown on this host; nothing was sent',
48
+ safety_stop: 'the decision was stopped by a local safety check before it was sent; nothing was sent',
49
+ });
50
+ function nonEmpty(v) {
51
+ return typeof v === 'string' && v.length > 0 ? v : undefined;
52
+ }
53
+ function ownStr(o, key) {
28
54
  try {
29
- return o?.[key];
55
+ if (typeof o !== 'object' || o === null)
56
+ return undefined;
57
+ const d = Object.getOwnPropertyDescriptor(o, key);
58
+ return d !== undefined && Object.hasOwn(d, 'value') ? nonEmpty(d.value) : undefined;
30
59
  }
31
60
  catch {
32
61
  return undefined;
33
62
  }
34
63
  }
35
- function opt(key, v) {
36
- return v === undefined ? {} : { [key]: v };
37
- }
38
- export function approvalResolutionOf(outcome) {
39
- if (typeof outcome !== 'object' || outcome === null || Array.isArray(outcome)) {
40
- return { kind: 'unsettled', cause: 'unreadable' };
64
+ export function approvalResolutionDetail(r) {
65
+ let kind;
66
+ try {
67
+ kind = typeof r === 'object' && r !== null ? r.kind : undefined;
41
68
  }
42
- const kind = pick(outcome, 'kind');
43
- if (typeof kind === 'string' && FS_OUTCOME_KINDS.includes(kind)) {
44
- return fsLegResolution(outcome, kind);
69
+ catch {
70
+ return undefined;
45
71
  }
46
- if (typeof pick(outcome, 'decision') === 'string') {
47
- return frameLegResolution(outcome);
72
+ if (kind === 'not_sent') {
73
+ const cause = ownStr(r, 'cause');
74
+ if (cause === undefined || !Object.hasOwn(NOT_SENT_SENTENCES, cause))
75
+ return undefined;
76
+ const sentence = NOT_SENT_SENTENCES[cause];
77
+ const code = cause === 'safety_stop' ? ownStr(r, 'safetyCode') : undefined;
78
+ return code !== undefined ? `${sentence} (${code})` : sentence;
48
79
  }
49
- return { kind: 'unsettled', cause: 'unreadable' };
50
- }
51
- function fsLegResolution(outcome, kind) {
52
- const gatedCallId = str(pick(outcome, 'gatedCallId'));
53
- const call = opt('gatedCallId', gatedCallId);
54
- if (kind === 'decided') {
55
- return {
56
- kind: 'decided',
57
- decision: pick(outcome, 'denied') === true ? 'deny' : 'allow',
58
- ...call,
59
- ...opt('receipt', pick(outcome, 'receipt')),
60
- };
61
- }
62
- if (kind === 'retracted')
63
- return { kind: 'not_sent', cause: 'retracted', ...call };
64
- if (kind === 'aborted')
65
- return { kind: 'unsettled', cause: 'interrupted', ...call };
66
- const detail = opt('detail', str(pick(outcome, 'reason')));
67
- const stage = pick(outcome, 'stage');
68
- if (stage === 'fetch') {
69
- const cause = pick(outcome, 'code') === 'no_pending' ? 'no_pending' : 'fetch_failed';
70
- return { kind: 'not_sent', cause, ...call, ...detail };
80
+ if (kind !== 'unsettled')
81
+ return undefined;
82
+ let refusal;
83
+ try {
84
+ const d = Object.getOwnPropertyDescriptor(r, 'refusal');
85
+ refusal = d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
71
86
  }
72
- if (stage === 'input')
73
- return { kind: 'not_sent', cause: 'no_input', ...call, ...detail };
74
- if (stage === 'card' && pick(outcome, 'editRefused') === true)
75
- return { kind: 'not_sent', cause: 'edit_refused', ...call, ...detail };
76
- if (stage === 'card')
77
- return { kind: 'not_sent', cause: 'card_unavailable', ...call, ...detail };
78
- if (stage === 'decide') {
79
- const safetyCode = str(pick(outcome, 'safetyCode'));
80
- const errorCode = str(pick(outcome, 'errorCode'));
81
- const engineAnswered = errorCode !== undefined || pick(outcome, 'currentPending') !== undefined;
82
- const cause = safetyCode !== undefined
83
- ? 'safety_stop'
84
- : pick(outcome, 'retryExhausted') === true
85
- ? 'transport_exhausted'
86
- : engineAnswered
87
- ? 'engine_refused'
88
- : 'decide_failed';
89
- return {
90
- kind: 'unsettled',
91
- cause,
92
- ...call,
93
- ...opt('safetyCode', safetyCode),
94
- ...opt('errorCode', errorCode),
95
- ...detail,
96
- };
87
+ catch {
88
+ refusal = undefined;
97
89
  }
98
- if (stage === 'orchestration')
99
- return { kind: 'unsettled', cause: 'orchestration', ...call, ...detail };
100
- return { kind: 'unsettled', cause: 'unreadable', ...call, ...detail };
90
+ const parts = [ownStr(refusal, 'errorCode'), ownStr(r, 'detail') ?? ownStr(refusal, 'message')].filter((x) => x !== undefined);
91
+ return parts.length > 0 ? parts.join(' · ') : undefined;
101
92
  }
102
- function parkingViewOf(v) {
103
- const approvalId = str(pick(v, 'approvalId'));
104
- if (approvalId === undefined)
105
- return undefined;
106
- const hint = pick(v, 'retryAfterMs');
107
- const retryAfterMs = typeof hint === 'number' && Number.isFinite(hint) && hint >= 0 ? hint : undefined;
108
- const decidePath = str(pick(v, 'decidePath'));
109
- const message = str(pick(v, 'message'));
110
- return {
111
- approvalId,
112
- ...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
113
- ...(decidePath !== undefined ? { decidePath } : {}),
114
- ...(message !== undefined ? { message } : {}),
115
- };
93
+ export function unsettledCauseOfReading(reading) {
94
+ if (reading.standing === 'ambiguous')
95
+ return 'engine_error';
96
+ return reading.standing === undefined ? 'no_answer' : 'engine_refused';
116
97
  }
117
- function frameLegResolution(outcome) {
118
- if (pick(outcome, 'retracted') === true)
119
- return { kind: 'not_sent', cause: 'retracted' };
120
- if (pick(outcome, 'editRefused') === true)
121
- return { kind: 'not_sent', cause: 'edit_refused' };
122
- if (pick(outcome, 'aborted') === true)
123
- return { kind: 'unsettled', cause: 'interrupted' };
124
- const parking = parkingViewOf(pick(outcome, 'parking'));
125
- if (parking !== undefined)
126
- return { kind: 'unsettled', cause: 'parking_in_progress', parking };
127
- if (pick(outcome, 'decision') === 'unresolved') {
128
- const refusal = pick(outcome, 'respondRefusal');
129
- return {
130
- kind: 'unsettled',
131
- cause: 'respond_failed',
132
- ...opt('status', num(pick(refusal, 'status'))),
133
- ...opt('errorCode', str(pick(refusal, 'errorCode'))),
134
- ...opt('detail', str(pick(refusal, 'message'))),
135
- };
136
- }
137
- const ack = pick(outcome, 'ack');
138
- return {
139
- kind: 'decided',
140
- decision: pick(outcome, 'decision'),
141
- ...(typeof ack === 'object' && ack !== null ? { ack: ack } : {}),
98
+ export function resolutionOfDecisionFailure(e, m) {
99
+ const base = {
100
+ lane: m.lane,
101
+ ...(m.gatedCallId !== undefined ? { gatedCallId: m.gatedCallId } : {}),
142
102
  };
103
+ const detail = m.detail !== undefined && m.detail.length > 0 ? { detail: m.detail } : {};
104
+ const { local } = refusalCarrierOf(e);
105
+ if (local !== undefined && local !== 'binding_mismatch') {
106
+ if (local === 'no_pending' || local === 'wrong_gate')
107
+ return { kind: 'not_sent', ...base, cause: local, ...detail };
108
+ return { kind: 'not_sent', ...base, cause: 'safety_stop', safetyCode: local, ...detail };
109
+ }
110
+ const refusal = mintDecisionRefusalReading(e, { route: m.route }, m.attributionCarried);
111
+ if (local === 'binding_mismatch')
112
+ return { kind: 'unsettled', ...base, cause: 'engine_refused', safetyCode: 'binding_mismatch', refusal, ...detail };
113
+ if (thrownIsInstanceOf(e, DecideTransportRetryExhaustedError))
114
+ return { kind: 'unsettled', ...base, cause: 'transport_exhausted', refusal, ...detail };
115
+ return { kind: 'unsettled', ...base, cause: unsettledCauseOfReading(refusal), refusal, ...detail };
143
116
  }
144
- export function isApprovalDecided(r) {
145
- return typeof r === 'object' && r !== null && r.kind === 'decided';
146
- }
147
- export function approvalNotSentCause(r) {
148
- if (typeof r !== 'object' || r === null || r.kind !== 'not_sent')
149
- return undefined;
150
- return r.cause;
151
- }
152
- export function approvalUnsettledCause(r) {
153
- if (typeof r !== 'object' || r === null || r.kind !== 'unsettled')
154
- return undefined;
155
- return r.cause;
117
+ export function joinedResolution(r, gatedCallId) {
118
+ const carry = r.gatedCallId === undefined && gatedCallId !== undefined && gatedCallId !== '' ? { gatedCallId } : {};
119
+ return { ...r, ...carry, joinedInFlight: true };
156
120
  }
@@ -24,15 +24,6 @@ function readDurablePendingRows(raw) {
24
24
  return { kind: 'malformed' };
25
25
  return { kind: 'present', rows, dropped };
26
26
  }
27
- function baselineDurableDigestThrows(raw) {
28
- try {
29
- durableDigestOf(raw);
30
- return false;
31
- }
32
- catch {
33
- return true;
34
- }
35
- }
36
27
  function durableDigestOf(rows) {
37
28
  return rows
38
29
  .map(r => [r.sessionId ?? '', r.taskId ?? '', r.toolCallId ?? '', r.boundCallId ?? '', r.boundInputHash ?? '', r.toolName ?? '']
@@ -214,17 +205,11 @@ export function startApprovalsFeed(client, onSnapshot, opts) {
214
205
  catch {
215
206
  durableRead = { kind: 'malformed' };
216
207
  }
217
- const badDurable = durableRead.kind === 'malformed' || durableRead.dropped > 0;
218
- const escapes = badDurable && baselineDurableDigestThrows(rawPending);
219
- if (durableRead.kind === 'malformed' || escapes) {
208
+ if (durableRead.kind === 'malformed') {
220
209
  hostLog('debug', `approvalsFeed: list() body has an unreadable pending section (${via} leg) — snapshot not committed`);
221
- if (!escapes)
222
- stats.listErrors++;
223
210
  noteTakeMissed(via, seq);
224
211
  publishUnknown('unreadable_payload', via, seq);
225
- if (escapes)
226
- throw new TypeError('approvalsFeed: unreadable pending section (baseline digest would have thrown)');
227
- return;
212
+ throw new TypeError('approvalsFeed: unreadable pending section');
228
213
  }
229
214
  rows = durableRead.rows;
230
215
  droppedDurable = durableRead.dropped;
@@ -246,7 +231,10 @@ export function startApprovalsFeed(client, onSnapshot, opts) {
246
231
  hostLog('debug', `approvalsFeed: dropping stale poll snapshot from leg ${leg} (current ${pollLeg}) — debt untouched`);
247
232
  return;
248
233
  }
249
- noteTakeLooked(seq);
234
+ if (dropped > 0 || droppedDurable > 0)
235
+ noteTakeMissed(via, seq);
236
+ else
237
+ noteTakeLooked(seq);
250
238
  if (seq < lastObservedSeq) {
251
239
  hostLog('debug', `approvalsFeed: dropping out-of-order take #${seq} (newest observed #${lastObservedSeq})`);
252
240
  return;
@@ -1,3 +1,5 @@
1
+ import type { CORE_MODE_ARBITRATION } from '../generated/engineFactTables.js';
2
+ export declare const DEPLOYMENT_LIST_ASK_CLASSES: readonly (keyof typeof CORE_MODE_ARBITRATION)[];
1
3
  export type AskClassPairReading = {
2
4
  readonly state: 'pair';
3
5
  readonly askClass: string;
@@ -1,3 +1,4 @@
1
+ export const DEPLOYMENT_LIST_ASK_CLASSES = Object.freeze(['ask_rule']);
1
2
  const ABSENT = Object.freeze({ state: 'absent' });
2
3
  const MALFORMED = Object.freeze({ state: 'malformed' });
3
4
  export function readAskClassPairState(v) {
@@ -8,11 +8,29 @@ export type { AskAnsweredOutput } from './gateLedger.js';
8
8
  export { SEMA_COLLATERAL_ABORT_KEY } from './gateLedger.js';
9
9
  export { SEMA_DENIAL_KIND_KEY } from './gateLedger.js';
10
10
  export type { GateDenyAttribution } from './gateLedger.js';
11
- export { toAnsweredOutput, isAlreadyResolvedFailure, isAlreadyResolvedGateReason, isGateStandingErrorCode, isCodeClassifiedGateFailure, nextHopBudget, MAX_GATE_HOPS, MAX_TOTAL_PARKS } from './parkResolver.js';
11
+ export { toAnsweredOutput, isAlreadyResolvedFailure, nextHopBudget, MAX_GATE_HOPS, MAX_TOTAL_PARKS } from './parkResolver.js';
12
12
  export type { HopBudget, HopRound } from './parkResolver.js';
13
- export type { GateOutcome, GateFailureCode } from './parkResolver.js';
13
+ export type { GateFailureCode } from './parkResolver.js';
14
14
  export { GATE_FAILURE_CODES } from './hitlBridge.js';
15
15
  export declare function bridgeAskUserQuestionGates(source: AsyncGenerator<AgentEvent>, deps: AskGateWireDeps, opts?: {
16
16
  signal?: AbortSignal;
17
17
  taskId?: string;
18
18
  }): AsyncGenerator<AgentEvent>;
19
+ export declare const LATE_DECIDE_OUTCOMES: readonly ["accepted-not-resolved", "resumed", "expired-reaped", "settled-elsewhere", "unknown"];
20
+ export type LateDecideOutcome = (typeof LATE_DECIDE_OUTCOMES)[number];
21
+ export interface LateDecideOutcomeReading {
22
+ readonly kind: LateDecideOutcome;
23
+ readonly taskId?: string;
24
+ readonly executed?: 'allowed' | 'denied';
25
+ readonly probeWorthy?: true;
26
+ }
27
+ export type LateDecideReply = {
28
+ readonly ok: true;
29
+ readonly body: object | null | undefined;
30
+ } | {
31
+ readonly ok: false;
32
+ readonly error: object | null | undefined;
33
+ };
34
+ export declare function lateDecideOutcomeOf(reply: LateDecideReply, opts?: {
35
+ readonly lane?: 'decide' | 'respond';
36
+ }): LateDecideOutcomeReading;
@@ -4,12 +4,19 @@ import { resolvePark, nextHopBudget, stalledTerminal, MAX_GATE_HOPS } from './pa
4
4
  import { createStreamDrainingLegs } from '../streamDrainingLegs.js';
5
5
  import { abortableSleep } from '../abortableSleep.js';
6
6
  import { hostLog } from '../host.js';
7
+ import { decideAcceptedNotResolved, readDecideReceipt } from '../decideReceipt.js';
8
+ import { APPROVAL_EXPIRED } from '../engineErrorCodes.js';
9
+ import { readDecisionRefusalAsk } from './decisionRefusal.js';
10
+ import { resumeReopenFromError } from './suspendedReopen.js';
11
+ import { refusedParkFromError, resumeRefusalFromError } from '../resumeRefusalCopy.js';
12
+ import { guardedRead, readOwnDataValue } from '../ownKey.js';
13
+ import { readToolApprovalRespondParking } from './toolApprovalWire.js';
7
14
  export { HITL_REJECT_MESSAGE, ENGINE_ABORT_TOOL_RESULT } from './frameRouter.js';
8
15
  export { HITL_INTERRUPT_MESSAGE_FOR_TOOL_USE } from './frameRouter.js';
9
16
  export { HITL_POLICY_DENY_MESSAGE } from './frameRouter.js';
10
17
  export { SEMA_COLLATERAL_ABORT_KEY } from './gateLedger.js';
11
18
  export { SEMA_DENIAL_KIND_KEY } from './gateLedger.js';
12
- export { toAnsweredOutput, isAlreadyResolvedFailure, isAlreadyResolvedGateReason, isGateStandingErrorCode, isCodeClassifiedGateFailure, nextHopBudget, MAX_GATE_HOPS, MAX_TOTAL_PARKS } from './parkResolver.js';
19
+ export { toAnsweredOutput, isAlreadyResolvedFailure, nextHopBudget, MAX_GATE_HOPS, MAX_TOTAL_PARKS } from './parkResolver.js';
13
20
  export { GATE_FAILURE_CODES } from './hitlBridge.js';
14
21
  export async function* bridgeAskUserQuestionGates(source, deps, opts) {
15
22
  const led = createGateLedger();
@@ -58,6 +65,7 @@ export async function* bridgeAskUserQuestionGates(source, deps, opts) {
58
65
  }
59
66
  park = {
60
67
  gate: action.gate,
68
+ parkFrame: action.parkFrame,
61
69
  ...(action.pendingDone !== undefined ? { pendingDone: action.pendingDone } : {}),
62
70
  ...(action.gatedCallId !== undefined ? { gatedCallId: action.gatedCallId } : {}),
63
71
  ...(action.toolName !== undefined ? { toolName: action.toolName } : {}),
@@ -152,3 +160,43 @@ export async function* bridgeAskUserQuestionGates(source, deps, opts) {
152
160
  });
153
161
  }
154
162
  }
163
+ export const LATE_DECIDE_OUTCOMES = Object.freeze(['accepted-not-resolved', 'resumed', 'expired-reaped', 'settled-elsewhere', 'unknown']);
164
+ const LATE_DECIDE_TASK_ID_MAX = 64;
165
+ export function lateDecideOutcomeOf(reply, opts) {
166
+ try {
167
+ if (reply.ok === true) {
168
+ const body = reply.body;
169
+ if (guardedRead(() => readToolApprovalRespondParking(body)) !== undefined)
170
+ return LATE_UNKNOWN;
171
+ const receipt = guardedRead(() => readDecideReceipt(body));
172
+ const handoff = receipt?.handoffTaskId;
173
+ const rawTask = typeof handoff === 'string' && handoff !== '' ? handoff : guardedRead(() => readOwnDataValue(body, 'taskId'));
174
+ const taskId = typeof rawTask === 'string' && rawTask !== '' ? rawTask.slice(0, LATE_DECIDE_TASK_ID_MAX) : undefined;
175
+ const replayed = guardedRead(() => readOwnDataValue(body, 'idempotent')) === true;
176
+ if (opts?.lane === 'respond' && replayed)
177
+ return Object.freeze({ kind: 'settled-elsewhere' });
178
+ const kind = opts?.lane === 'respond' && !decideAcceptedNotResolved(receipt) ? 'resumed' : 'accepted-not-resolved';
179
+ const disposition = receipt?.executionOutcome?.disposition?.kind;
180
+ const executed = disposition === 'allowed' || disposition === 'denied' ? disposition : undefined;
181
+ return Object.freeze({ kind, ...(taskId !== undefined ? { taskId } : {}), ...(executed !== undefined ? { executed } : {}) });
182
+ }
183
+ const e = reply.error;
184
+ if (typeof e !== 'object' || e === null)
185
+ return LATE_UNKNOWN;
186
+ const code = guardedRead(() => readOwnDataValue(e, 'errorCode'));
187
+ const status = guardedRead(() => readOwnDataValue(e, 'status'));
188
+ if (code === APPROVAL_EXPIRED)
189
+ return Object.freeze({ kind: 'expired-reaped' });
190
+ if (resumeReopenFromError(e) !== null || resumeRefusalFromError(e)?.waitable === true || refusedParkFromError(e)?.stillPending === true)
191
+ return LATE_UNKNOWN;
192
+ const r = readDecisionRefusalAsk(e);
193
+ if (r.reading !== 'settled' && !(r.reading === 'not_settled' && r.gateMoved))
194
+ return LATE_UNKNOWN;
195
+ const probeWorthy = status === 404 || status === 410 || (typeof code === 'string' && code.startsWith('not_found.'));
196
+ return Object.freeze(probeWorthy ? { kind: 'settled-elsewhere', probeWorthy: true } : { kind: 'settled-elsewhere' });
197
+ }
198
+ catch {
199
+ return LATE_UNKNOWN;
200
+ }
201
+ }
202
+ const LATE_UNKNOWN = Object.freeze({ kind: 'unknown' });
@@ -27,3 +27,8 @@ export interface RowArmSingleFlight<T> {
27
27
  clear: () => void;
28
28
  }
29
29
  export declare function createRowArmSingleFlight<T>(): RowArmSingleFlight<T>;
30
+ export declare function pendingRowIsOwnedAndDecidable(row: PendingCheckpoint, deps?: ParkOwnershipDeps): boolean;
31
+ export interface OwnedPendingListView {
32
+ readonly pending?: readonly PendingCheckpoint[] | null;
33
+ }
34
+ export declare function countOwnedPendingRows(listed: OwnedPendingListView | null | undefined, deps?: ParkOwnershipDeps): number;
@@ -1,4 +1,4 @@
1
- import { askParkForeignGateKind } from '../adapter/activeRunSelfHeal.js';
1
+ import { askParkForeignGateKind, durableDecideLegOf } from '../adapter/activeRunSelfHeal.js';
2
2
  import { isAskTool } from './frameRouter.js';
3
3
  import { approvalCallKey } from './gateIdentity.js';
4
4
  import { askQuestionsFromPending, pendingRowIsOwnedByThisSession } from './parkOwnership.js';
@@ -108,3 +108,34 @@ export function createRowArmSingleFlight() {
108
108
  },
109
109
  };
110
110
  }
111
+ export function pendingRowIsOwnedAndDecidable(row, deps) {
112
+ if (typeof row !== 'object' || row === null)
113
+ throw new TypeError('pending row is not an object — ownership cannot be judged');
114
+ if (!pendingRowIsOwnedByThisSession(row, deps))
115
+ return false;
116
+ void row.gateKind;
117
+ const leg = durableDecideLegOf(row);
118
+ if (leg === 'plan_review')
119
+ return true;
120
+ if (leg !== 'approval' && leg !== 'absent')
121
+ return false;
122
+ return askParkRowArm(row) === 'question' ? askQuestionsFromPending(row) !== null : true;
123
+ }
124
+ export function countOwnedPendingRows(listed, deps) {
125
+ if (typeof listed !== 'object' || listed === null || Array.isArray(listed)) {
126
+ throw new Error('approvals.list answered without a readable body — the owned pending count is unknown');
127
+ }
128
+ const pending = listed?.pending;
129
+ if (!Array.isArray(pending)) {
130
+ throw new Error('approvals.list answered without a readable `pending` array — the owned pending count is unknown');
131
+ }
132
+ let n = 0;
133
+ for (const row of pending) {
134
+ if (typeof row !== 'object' || row === null) {
135
+ throw new Error('approvals.list answered with a pending row that is not an object — the owned pending count is unknown');
136
+ }
137
+ if (pendingRowIsOwnedAndDecidable(row, deps))
138
+ n++;
139
+ }
140
+ return n;
141
+ }
@@ -0,0 +1,18 @@
1
+ export declare function askEndingCauseClause(cause: string | undefined): string | undefined;
2
+ export interface AskSettlementInput {
3
+ readonly cause?: string | undefined;
4
+ readonly toolName?: string | undefined;
5
+ readonly parked?: boolean | undefined;
6
+ }
7
+ export declare function askSettlementLine(settled: AskSettlementInput): string | undefined;
8
+ export type AskAcceptedFollow = 'following' | 'already-following' | 'not-following';
9
+ export interface AskAcceptedInput {
10
+ readonly decision?: string | undefined;
11
+ readonly taskId?: string | undefined;
12
+ readonly late?: boolean | undefined;
13
+ readonly follow?: AskAcceptedFollow | undefined;
14
+ readonly executed?: string | undefined;
15
+ }
16
+ export declare function askAcceptedLine(accepted: AskAcceptedInput): string;
17
+ export type AskParkedCardForm = 'approval' | 'question' | 'queue_no_deadline';
18
+ export declare function askParkedCardNote(form?: string | undefined, toolName?: string | undefined): string;