@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,16 +1,12 @@
1
- import type { EngineAgentPanelAbsence, EngineAgentPanelEvent } from './engineAgentPanelStore.js';
2
- import { type PanelDelta, type PanelFrame, type PanelReduceState } from './panelReduce.js';
1
+ import { type PanelDelta, type PanelFact, type PanelFrame, type PanelReduceState } from './panelReduce.js';
3
2
  export declare function panelStateNow(): PanelReduceState;
4
3
  export declare function stepEnginePanel(frame: PanelFrame): void;
5
4
  export declare function replaceEnginePanelState(fn: (s: PanelReduceState) => PanelReduceState): void;
6
5
  export declare function clearEnginePanelIdentity(): void;
7
6
  export declare function clearEnginePanelAnchors(): void;
8
7
  export declare function resetEnginePanelHolder(): void;
9
- type Listener = (ev: EngineAgentPanelEvent) => void;
10
- export declare function subscribeLegacyEvents(fn: Listener): () => void;
11
- type AbsenceListener = (ev: EngineAgentPanelAbsence) => void;
12
- export declare function subscribeAbsence(fn: AbsenceListener): () => void;
13
- export declare function resetAbsenceChannel(): void;
8
+ type FactTap = (f: PanelFact) => void;
9
+ export declare function __tapEnginePanelFactsForTests(fn: FactTap): () => void;
14
10
  type RowListener = (d: PanelDelta) => void;
15
11
  export declare function subscribeRows(fn: RowListener): () => void;
16
12
  export declare function clearEnginePanelRows(): void;
@@ -1,4 +1,4 @@
1
- import { createPanelReduceState, isNewEngineAgentPanelCycle, panelClearAnchors, panelClearIdentity, panelClearRows, panelRowSnapshot, stepPanelFrame, } from './panelReduce.js';
1
+ import { createPanelReduceState, panelClearAnchors, panelClearIdentity, panelClearRows, panelRowSnapshot, stepPanelFrame, } from './panelReduce.js';
2
2
  let state = createPanelReduceState();
3
3
  export function panelStateNow() {
4
4
  return state;
@@ -8,13 +8,14 @@ export function stepEnginePanel(frame) {
8
8
  state = r.state;
9
9
  if (rowListener !== null)
10
10
  rowQueue.push(...r.deltas);
11
- for (const f of r.facts) {
12
- if (f.ch === 'event')
13
- deliverLegacyEvent(f.ev);
14
- else
15
- deliverAbsence(f.absence);
11
+ try {
12
+ if (factTap !== null)
13
+ for (const f of r.facts)
14
+ factTap(f);
15
+ }
16
+ finally {
17
+ drainRows();
16
18
  }
17
- drainRows();
18
19
  }
19
20
  export function replaceEnginePanelState(fn) {
20
21
  state = fn(state);
@@ -27,135 +28,18 @@ export function clearEnginePanelAnchors() {
27
28
  }
28
29
  export function resetEnginePanelHolder() {
29
30
  state = createPanelReduceState();
30
- listener = null;
31
- buffer.length = 0;
32
- absenceListener = null;
33
- absenceBuffer.clear();
34
31
  rowListener = null;
35
32
  rowQueue.length = 0;
33
+ factTap = null;
36
34
  }
37
- const MAX_BUFFER = 200;
38
- let listener = null;
39
- const buffer = [];
40
- function launchAnchorChanged(prev, next) {
41
- if (prev.kind !== 'fleet-row' || next.kind !== 'fleet-row')
42
- return false;
43
- return isNewEngineAgentPanelCycle(prev, next);
44
- }
45
- function deliverLegacyEvent(ev) {
46
- if (ev.kind !== 'sweep')
47
- absenceBuffer.delete(ev.taskId);
48
- if (listener) {
49
- try {
50
- listener(ev);
51
- }
52
- catch {
53
- }
54
- return;
55
- }
56
- if (ev.kind === 'sweep' && buffer.length > 0 && buffer[buffer.length - 1]?.kind === 'sweep')
57
- return;
58
- const progress = ev.kind === 'tick' || ev.kind === 'fleet-row';
59
- if (progress) {
60
- const kind = ev.kind;
61
- const taskId = ev.taskId;
62
- let i = -1;
63
- for (let at = buffer.length - 1; at >= 0; at--) {
64
- const b = buffer[at];
65
- if (b === undefined)
66
- continue;
67
- if (b.kind === 'sweep')
68
- break;
69
- if (b.kind === 'end') {
70
- if (b.taskId === taskId)
71
- break;
72
- continue;
73
- }
74
- if (b.taskId !== taskId)
75
- continue;
76
- if (b.kind === kind && !launchAnchorChanged(b, ev))
77
- i = at;
78
- break;
79
- }
80
- if (i >= 0) {
81
- const merged = { ...buffer[i], ...ev };
82
- buffer.splice(i, 1);
83
- buffer.push(merged);
84
- return;
85
- }
86
- }
87
- if (buffer.length < MAX_BUFFER) {
88
- buffer.push(ev);
89
- return;
90
- }
91
- const evictAt = buffer.findIndex(b => b.kind === 'tick' || b.kind === 'fleet-row');
92
- if (evictAt >= 0) {
93
- buffer.splice(evictAt, 1);
94
- buffer.push(ev);
95
- return;
96
- }
97
- buffer.shift();
98
- buffer.push(ev);
99
- }
100
- export function subscribeLegacyEvents(fn) {
101
- listener = fn;
102
- if (buffer.length > 0) {
103
- const pending = buffer.splice(0, buffer.length);
104
- for (const ev of pending) {
105
- try {
106
- fn(ev);
107
- }
108
- catch {
109
- }
110
- }
111
- }
112
- return () => {
113
- if (listener === fn)
114
- listener = null;
115
- };
116
- }
117
- const MAX_ABSENCE_BUFFER = 200;
118
- let absenceListener = null;
119
- const absenceBuffer = new Map();
120
- function deliverAbsence(ev) {
121
- if (absenceListener) {
122
- try {
123
- absenceListener(ev);
124
- }
125
- catch {
126
- }
127
- return;
128
- }
129
- absenceBuffer.delete(ev.taskId);
130
- absenceBuffer.set(ev.taskId, ev);
131
- if (absenceBuffer.size > MAX_ABSENCE_BUFFER) {
132
- const oldest = absenceBuffer.keys().next().value;
133
- if (oldest !== undefined)
134
- absenceBuffer.delete(oldest);
135
- }
136
- }
137
- export function subscribeAbsence(fn) {
138
- absenceListener = fn;
139
- if (absenceBuffer.size > 0) {
140
- const pending = [...absenceBuffer.values()];
141
- absenceBuffer.clear();
142
- for (const ev of pending) {
143
- try {
144
- fn(ev);
145
- }
146
- catch {
147
- }
148
- }
149
- }
35
+ let factTap = null;
36
+ export function __tapEnginePanelFactsForTests(fn) {
37
+ factTap = fn;
150
38
  return () => {
151
- if (absenceListener === fn)
152
- absenceListener = null;
39
+ if (factTap === fn)
40
+ factTap = null;
153
41
  };
154
42
  }
155
- export function resetAbsenceChannel() {
156
- absenceListener = null;
157
- absenceBuffer.clear();
158
- }
159
43
  let rowListener = null;
160
44
  const rowQueue = [];
161
45
  let rowDraining = false;
@@ -10,10 +10,6 @@ export type PeerLaneReading = {
10
10
  kind: 'present';
11
11
  };
12
12
  export declare function projectPeerLaneCapability(caps: unknown): PeerLaneReading | undefined;
13
- export declare function noteEngineCapsForPeerLane(baseUrl: string, caps: unknown, opts?: {
14
- generation?: number;
15
- }): void;
16
13
  export declare function observedPeerLane(baseUrl?: string | undefined): PeerLaneReading;
17
14
  export declare function peerLaneAvailable(reading: PeerLaneReading): 'yes' | 'no' | 'unknown';
18
15
  export declare function peerLaneDoctorDetail(reading: PeerLaneReading): string;
19
- export declare function __resetPeerLaneReadingsForTests(): void;
@@ -22,9 +22,6 @@ const reader = createEngineCapReader({
22
22
  name: 'peerLane',
23
23
  project: projectPeerLaneCapability,
24
24
  });
25
- export function noteEngineCapsForPeerLane(baseUrl, caps, opts) {
26
- reader.note(baseUrl, caps, opts);
27
- }
28
25
  export function observedPeerLane(baseUrl = engineWireTarget()?.baseUrl) {
29
26
  return reader.observed(baseUrl);
30
27
  }
@@ -49,6 +46,3 @@ export function peerLaneDoctorDetail(reading) {
49
46
  return 'cross-session lane on — this engine can discover and deliver across sessions for the same caller';
50
47
  }
51
48
  }
52
- export function __resetPeerLaneReadingsForTests() {
53
- reader.__resetForTests();
54
- }
@@ -10,10 +10,6 @@ export type PermissionRulesWriteReading = {
10
10
  kind: 'present';
11
11
  };
12
12
  export declare function projectPermissionRulesWriteCapability(caps: unknown): PermissionRulesWriteReading | undefined;
13
- export declare function noteEngineCapsForPermissionRulesWrite(baseUrl: string, caps: unknown, opts?: {
14
- generation?: number;
15
- }): void;
16
13
  export declare function observedPermissionRulesWrite(baseUrl?: string | undefined): PermissionRulesWriteReading;
17
14
  export declare function permissionRulesWriteAvailable(reading: PermissionRulesWriteReading): boolean;
18
15
  export declare function permissionRulesWriteDoctorDetail(reading: PermissionRulesWriteReading): string;
19
- export declare function __resetPermissionRulesWriteReadingsForTests(): void;
@@ -22,9 +22,6 @@ const reader = createEngineCapReader({
22
22
  name: 'permissionRulesWrite',
23
23
  project: projectPermissionRulesWriteCapability,
24
24
  });
25
- export function noteEngineCapsForPermissionRulesWrite(baseUrl, caps, opts) {
26
- reader.note(baseUrl, caps, opts);
27
- }
28
25
  export function observedPermissionRulesWrite(baseUrl = engineWireTarget()?.baseUrl) {
29
26
  return reader.observed(baseUrl);
30
27
  }
@@ -45,6 +42,3 @@ export function permissionRulesWriteDoctorDetail(reading) {
45
42
  return 'permission-rule write entry reachable for this call — a per-call attempt still answers for itself whether the direction, text, and scope are accepted';
46
43
  }
47
44
  }
48
- export function __resetPermissionRulesWriteReadingsForTests() {
49
- reader.__resetForTests();
50
- }
@@ -1,6 +1,6 @@
1
- import { type TaskRequestPermissionMode } from './taskRequestWords.js';
1
+ import type { PermissionMode } from '@sema-agent/sdk';
2
2
  import { type PermissionModesReading } from './permissionModesCapability.js';
3
- export type PermissionMode = TaskRequestPermissionMode;
3
+ export type { PermissionMode };
4
4
  export interface PermissionModeField {
5
5
  permissionMode?: PermissionMode;
6
6
  }
@@ -1,5 +1,7 @@
1
1
  import { PERMISSION_MODE_WORDS } from './taskRequestWords.js';
2
2
  import { permissionModeAdmitted } from './permissionModesCapability.js';
3
+ const _permissionModePin = true;
4
+ void _permissionModePin;
3
5
  const BIT_GATED_MODE = 'dontAsk';
4
6
  const KNOWN = new Set(PERMISSION_MODE_WORDS.filter((w) => w !== BIT_GATED_MODE));
5
7
  export function permissionModeField(mode, opts) {
@@ -10,12 +10,8 @@ export type PermissionsAllowGrantReading = {
10
10
  layer?: boolean;
11
11
  };
12
12
  export declare function projectPermissionsAllowGrantCapability(caps: unknown): PermissionsAllowGrantReading | undefined;
13
- export declare function noteEngineCapsForPermissionsAllowGrant(baseUrl: string, caps: unknown, opts?: {
14
- generation?: number;
15
- }): void;
16
13
  export declare function observedPermissionsAllowGrant(baseUrl?: string | undefined): PermissionsAllowGrantReading;
17
14
  export declare function permissionsAllowGrantAvailable(reading: PermissionsAllowGrantReading): boolean;
18
15
  export declare function allowWireForm(reading: PermissionsAllowGrantReading): 'layer' | 'grant' | 'off';
19
16
  export declare function allowRulesGate(reading: PermissionsAllowGrantReading, settingsRead: 'clean' | 'partial' | 'unreadable' | undefined): 'open' | 'capability_off' | 'settings_read_not_clean';
20
17
  export declare function permissionsAllowGrantDoctorDetail(reading: PermissionsAllowGrantReading, settingsRead?: 'clean' | 'partial' | 'unreadable'): string;
21
- export declare function __resetPermissionsAllowGrantReadingsForTests(): void;
@@ -36,9 +36,6 @@ const reader = createEngineCapReader({
36
36
  name: ALLOW_GRANT_CAP_PATH.join('.'),
37
37
  project: projectPermissionsAllowGrantCapability,
38
38
  });
39
- export function noteEngineCapsForPermissionsAllowGrant(baseUrl, caps, opts) {
40
- reader.note(baseUrl, caps, opts);
41
- }
42
39
  export function observedPermissionsAllowGrant(baseUrl = engineWireTarget()?.baseUrl) {
43
40
  return reader.observed(baseUrl);
44
41
  }
@@ -102,6 +99,3 @@ export function permissionsAllowGrantDoctorDetail(reading, settingsRead) {
102
99
  }
103
100
  return 'allow rules kept on this side — no usable capabilities reading is cached for this engine (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which), so allow rules are not sent and matching approvals are still answered here';
104
101
  }
105
- export function __resetPermissionsAllowGrantReadingsForTests() {
106
- reader.__resetForTests();
107
- }
@@ -38,20 +38,9 @@ export interface PermissionsRewrittenRule {
38
38
  to: string;
39
39
  bucket: 'deny' | 'ask' | 'allow';
40
40
  }
41
- export interface PermissionsUncheckedRule {
42
- rule: string;
43
- bucket: 'deny' | 'ask';
44
- }
45
- export interface PermissionsUnreachableRule {
46
- rule: string;
47
- bucket: 'deny' | 'ask';
48
- mintedPrefix?: string;
49
- }
50
41
  export interface PermissionsDeclarationReport extends PermissionsDeclaration {
51
42
  kept: PermissionsKeptRule[];
52
43
  rewritten: PermissionsRewrittenRule[];
53
- unchecked: PermissionsUncheckedRule[];
54
- unreachable: PermissionsUnreachableRule[];
55
44
  clientOwned?: PermissionsClientOwnedStatement[];
56
45
  }
57
46
  export interface PermissionsClientOwnedStatement {
@@ -1,8 +1,8 @@
1
1
  import { compileAllowList, hasCoreValuePort, protocolOf, ruleToolGrammarOf } from './coreValuePorts.js';
2
- import { clientOwnedServerPrefix, mintedPrefixOf, ruleToolNameVerdictOf } from './protocolSegment.js';
2
+ import { clientOwnedServerPrefix, ruleToolNameVerdictOf } from './protocolSegment.js';
3
3
  import { ruleCompileVerdict } from './ruleCompileVerdict.js';
4
4
  import { allowRulesGate, allowWireForm } from './permissionsAllowGrantCapability.js';
5
- import { THROWN_SLOT_UNREADABLE, readThrownSlot } from './wireFailureShape.js';
5
+ import { THROWN_SLOT_UNREADABLE, asAssemblyRefusal, readThrownSlot, withAssemblyRefusal } from './wireFailureShape.js';
6
6
  export const WIRE_RULE_TRUST_ORDER = Object.freeze([
7
7
  'policySettings',
8
8
  'cliArg',
@@ -65,16 +65,16 @@ function requireRulePorts() {
65
65
  const missing = required.filter((p) => !hasCoreValuePort(p));
66
66
  if (missing.length === 0)
67
67
  return;
68
- throw new Error(`permissionsDeclaration: 规则判据端口缺席(${missing.join(' / ')})—— 先用 installCoreValuePorts 装上 core 的同名实现。` +
69
- '缺席不等于全部合格:不判就发会让整份请求被引擎拒收,不判就删会静默丢掉 deny 规则,所以这里拒绝装配。');
68
+ throw withAssemblyRefusal(new Error(`permissionsDeclaration: 规则判据端口缺席(${missing.join(' / ')})—— 先用 installCoreValuePorts 装上 core 的同名实现。` +
69
+ '缺席不等于全部合格:不判就发会让整份请求被引擎拒收,不判就删会静默丢掉 deny 规则,所以这里拒绝装配。'), 'ports_missing');
70
70
  }
71
71
  function nameCheck(name) {
72
72
  if (name.includes('('))
73
73
  return { issue: 'paren_in_tool_name' };
74
74
  const verdict = ruleToolNameVerdictOf(name);
75
75
  if (verdict.kind === 'unknown') {
76
- throw new Error('permissionsDeclaration: 规则工具名判官(judgeRuleToolName)答不上来(抛 / 回的不是 current · retired · unprefixed_namespace · unmintable_segment 之一)—— ' +
77
- '装的必须是 core 的同名实现、原样装。判不出不等于够得着:不判就发会让整份请求被引擎拒收,不判就删会静默丢掉 deny 规则,所以这里拒绝装配。');
76
+ throw withAssemblyRefusal(new Error('permissionsDeclaration: 规则工具名判官(judgeRuleToolName)答不上来(抛 / 回的不是 current · retired · unprefixed_namespace · unmintable_segment 之一)—— ' +
77
+ '装的必须是 core 的同名实现、原样装。判不出不等于够得着:不判就发会让整份请求被引擎拒收,不判就删会静默丢掉 deny 规则,所以这里拒绝装配。'), 'judge_unanswerable');
78
78
  }
79
79
  if (verdict.kind === 'retired')
80
80
  return { retired: verdict.currentName !== undefined ? { currentName: verdict.currentName } : {} };
@@ -83,10 +83,8 @@ function nameCheck(name) {
83
83
  const ns = protocolOf(name);
84
84
  if (ns !== undefined && ns.parse(name) === undefined)
85
85
  return { issue: 'incomplete_protocol_name' };
86
- if (verdict.kind === 'unmintable_segment') {
87
- const minted = mintedPrefixOf(name);
88
- return { unminted: minted !== undefined ? { minted } : {} };
89
- }
86
+ if (verdict.kind === 'unmintable_segment')
87
+ return { unminted: true };
90
88
  return { ok: true };
91
89
  }
92
90
  function wholeServerRuleName(name) {
@@ -107,8 +105,14 @@ function compileRefused(verdict) {
107
105
  ...(verdict.message !== undefined ? { message: verdict.message } : {}),
108
106
  };
109
107
  }
110
- function sentFate(wire, check, unchecked) {
111
- return 'unminted' in check ? { sent: true, wire, unchecked, unreachable: check.unminted } : { sent: true, wire, unchecked };
108
+ function tighteningWholeName(name, check) {
109
+ if (!('retired' in check))
110
+ return name;
111
+ const successor = check.retired.currentName;
112
+ if (successor === undefined)
113
+ return name;
114
+ const next = nameCheck(successor);
115
+ return 'retired' in next || 'issue' in next ? name : successor;
112
116
  }
113
117
  function judgeList(rules, behavior, allowForm = 'grant') {
114
118
  let portsChecked = false;
@@ -121,46 +125,37 @@ function judgeList(rules, behavior, allowForm = 'grant') {
121
125
  }
122
126
  const parsed = parseRule(rule);
123
127
  if (parsed.ruleContent === undefined) {
124
- let name = wholeServerRuleName(parsed.toolName);
125
- let check = nameCheck(name);
126
- if ('retired' in check) {
127
- const successor = check.retired.currentName;
128
- if (behavior === 'allow' || successor === undefined)
129
- return kept('retired_tool_name');
130
- name = successor;
131
- check = nameCheck(name);
132
- if ('retired' in check)
133
- return kept('retired_tool_name');
134
- }
128
+ const name = wholeServerRuleName(parsed.toolName);
129
+ const check = nameCheck(name);
130
+ if (behavior !== 'allow')
131
+ return { sent: true, wire: tighteningWholeName(name, check) };
132
+ if ('retired' in check)
133
+ return kept('retired_tool_name');
135
134
  if ('issue' in check)
136
135
  return kept(check.issue);
137
- if (behavior === 'allow' && 'unminted' in check)
136
+ if ('unminted' in check)
138
137
  return kept('unminted_protocol_segment');
139
- const verdict = compileVerdict(name, behavior === 'ask' ? 'ask' : 'deny');
138
+ const verdict = compileVerdict(name, 'deny');
140
139
  if (verdict.kind === 'refused')
141
140
  return compileRefused(verdict);
142
- if (verdict.kind === 'unknown' && behavior === 'allow')
141
+ if (verdict.kind === 'unknown')
143
142
  return kept('judge_failed');
144
- return behavior === 'allow' ? { sent: true, wire: name, unchecked: false } : sentFate(name, check, verdict.kind === 'unknown');
143
+ return { sent: true, wire: name };
145
144
  }
146
145
  const check = nameCheck(parsed.toolName);
146
+ if (behavior !== 'allow')
147
+ return { sent: true, wire: rule };
147
148
  if ('retired' in check)
148
149
  return kept('retired_tool_name');
149
150
  if ('issue' in check)
150
151
  return kept(check.issue);
151
152
  if (ruleToolGrammarOf(parsed.toolName) === 'path' && parsed.ruleContent.startsWith('~/'))
152
153
  return kept('home_relative_path');
153
- if (behavior === 'allow') {
154
- if (allowForm !== 'layer')
155
- return kept('content_form_not_grantable');
156
- if ('unminted' in check)
157
- return kept('unminted_protocol_segment');
158
- return { sent: true, wire: rule, unchecked: false };
159
- }
160
- const verdict = compileVerdict(rule, behavior);
161
- if (verdict.kind === 'refused')
162
- return compileRefused(verdict);
163
- return sentFate(rule, check, verdict.kind === 'unknown');
154
+ if (allowForm !== 'layer')
155
+ return kept('content_form_not_grantable');
156
+ if ('unminted' in check)
157
+ return kept('unminted_protocol_segment');
158
+ return { sent: true, wire: rule };
164
159
  });
165
160
  }
166
161
  function outsideSettingsFiles(origin) {
@@ -269,24 +264,25 @@ function clientOwnedFate(server) {
269
264
  return judgeList([`${prefix}*`], 'allow')[0];
270
265
  }
271
266
  const WHO = 'permissionsDeclaration';
267
+ const malformed = (sentence) => withAssemblyRefusal(new TypeError(sentence), 'input_malformed');
272
268
  function ownField(obj, key, where) {
273
269
  if (Object.hasOwn(obj, key))
274
270
  return obj[key];
275
271
  if (key in obj)
276
- throw new TypeError(`${WHO}: ${where}${key} 只在原型链上,不是自有字段 —— 拒绝读取(请交普通对象)。`);
272
+ throw malformed(`${WHO}: ${where}${key} 只在原型链上,不是自有字段 —— 拒绝读取(请交普通对象)。`);
277
273
  return undefined;
278
274
  }
279
275
  function ruleList(v, key) {
280
276
  if (v === undefined || v === null)
281
277
  return undefined;
282
278
  if (!Array.isArray(v))
283
- throw new TypeError(`${WHO}: ${key} 必须是规则串数组或缺席 —— 收到 typeof=${typeof v}。`);
279
+ throw malformed(`${WHO}: ${key} 必须是规则串数组或缺席 —— 收到 typeof=${typeof v}。`);
284
280
  const out = [];
285
281
  const n = v.length;
286
282
  for (let i = 0; i < n; i++) {
287
283
  if (!Object.hasOwn(v, i)) {
288
284
  if (i in v)
289
- throw new TypeError(`${WHO}: ${key}[${i}] 是空洞,而原型链上在这个下标有值 —— 拒绝读取(请交不带空洞的普通数组)。`);
285
+ throw malformed(`${WHO}: ${key}[${i}] 是空洞,而原型链上在这个下标有值 —— 拒绝读取(请交不带空洞的普通数组)。`);
290
286
  continue;
291
287
  }
292
288
  const r = v[i];
@@ -302,7 +298,7 @@ function originMap(v, key) {
302
298
  typeof v.get === 'function' &&
303
299
  typeof v[Symbol.iterator] === 'function';
304
300
  if (!ok)
305
- throw new TypeError(`${WHO}: origins.${key} 必须是 Map(规则原串 → 来源)或缺席 —— 收到 typeof=${typeof v}。`);
301
+ throw malformed(`${WHO}: origins.${key} 必须是 Map(规则原串 → 来源)或缺席 —— 收到 typeof=${typeof v}。`);
306
302
  const snap = new Map();
307
303
  for (const entry of v) {
308
304
  const [r, origin] = entry;
@@ -313,8 +309,23 @@ function originMap(v, key) {
313
309
  }
314
310
  const slotsOf = (list, name) => (list ?? []).map((rule, at) => ({ rule, list: name, at }));
315
311
  function assemble(input, caps) {
312
+ let read;
313
+ try {
314
+ read = readAssemblyInput(input, caps);
315
+ }
316
+ catch (e) {
317
+ throw asAssemblyRefusal(e, 'input_malformed', WHO);
318
+ }
319
+ try {
320
+ return judgeAssembly(read, caps);
321
+ }
322
+ catch (e) {
323
+ throw asAssemblyRefusal(e, 'judge_unanswerable', WHO);
324
+ }
325
+ }
326
+ function readAssemblyInput(input, caps) {
316
327
  if (input === null || typeof input !== 'object' || Array.isArray(input)) {
317
- throw new TypeError(`${WHO}: 入参必须是对象 —— 收到 ${input === null ? 'null' : Array.isArray(input) ? 'array' : `typeof=${typeof input}`}。`);
328
+ throw malformed(`${WHO}: 入参必须是对象 —— 收到 ${input === null ? 'null' : Array.isArray(input) ? 'array' : `typeof=${typeof input}`}。`);
318
329
  }
319
330
  const deny = ruleList(ownField(input, 'deny', ''), 'deny');
320
331
  const ask = ruleList(ownField(input, 'ask', ''), 'ask');
@@ -325,7 +336,7 @@ function assemble(input, caps) {
325
336
  let origins = {};
326
337
  if (originsRaw !== undefined && originsRaw !== null) {
327
338
  if (typeof originsRaw !== 'object' || Array.isArray(originsRaw)) {
328
- throw new TypeError(`${WHO}: origins 必须是 { deny?, ask?, allow? } 对象或缺席 —— 收到 typeof=${typeof originsRaw}。`);
339
+ throw malformed(`${WHO}: origins 必须是 { deny?, ask?, allow? } 对象或缺席 —— 收到 typeof=${typeof originsRaw}。`);
329
340
  }
330
341
  const od = originMap(ownField(originsRaw, 'deny', 'origins.'), 'deny');
331
342
  const oa = originMap(ownField(originsRaw, 'ask', 'origins.'), 'ask');
@@ -333,6 +344,10 @@ function assemble(input, caps) {
333
344
  origins = { ...(od ? { deny: od } : {}), ...(oa ? { ask: oa } : {}), ...(ol ? { allow: ol } : {}) };
334
345
  }
335
346
  const gate = allowRulesGate(caps, ownField(input, 'settingsRead', ''));
347
+ return { deny, ask, allow, cliDeny, ownedServers, origins, gate };
348
+ }
349
+ function judgeAssembly(read, caps) {
350
+ const { deny, ask, allow, cliDeny, ownedServers, origins, gate } = read;
336
351
  const cliSlots = slotsOf(cliDeny, 'cliDeny');
337
352
  const cli = cliDeny === undefined ? undefined : { slots: cliSlots, fates: judgeList(cliDeny, 'deny') };
338
353
  const denySlots = slotsOf(deny, 'deny');
@@ -361,8 +376,6 @@ function assemble(input, caps) {
361
376
  buckets.allow = [...allowJ.sent];
362
377
  const keptRows = [];
363
378
  const rewritten = [];
364
- const unchecked = [];
365
- const unreachable = [];
366
379
  const rows = [
367
380
  ['deny', [...denySlots, ...cliSlots], denyJ],
368
381
  ['ask', askSlots, askJ],
@@ -392,15 +405,9 @@ function assemble(input, caps) {
392
405
  continue;
393
406
  if (winner.rule !== wire)
394
407
  rewritten.push({ from: winner.rule, to: wire, bucket });
395
- const f = (winner.list === 'cliDeny' ? j.fates[denySlots.length + winner.at] : j.fates[winner.at]);
396
- if (f.sent && f.unchecked && bucket !== 'allow')
397
- unchecked.push({ rule: wire, bucket });
398
- if (f.sent && f.unreachable !== undefined && bucket !== 'allow') {
399
- unreachable.push({ rule: wire, bucket, ...(f.unreachable.minted !== undefined ? { mintedPrefix: f.unreachable.minted } : {}) });
400
- }
401
408
  }
402
409
  }
403
- return { buckets, report: { kept: keptRows, rewritten, unchecked, unreachable, ...(clientOwned.length > 0 ? { clientOwned } : {}) } };
410
+ return { buckets, report: { kept: keptRows, rewritten, ...(clientOwned.length > 0 ? { clientOwned } : {}) } };
404
411
  }
405
412
  export function permissionsDeclaration(input, caps) {
406
413
  const { buckets } = assemble(input, caps);
@@ -110,7 +110,7 @@ export interface PluginHookDecision {
110
110
  readonly unreadable: number;
111
111
  }
112
112
  export declare function decidePluginHooks(input: PluginHookDecisionInput): PluginHookDecision;
113
- export declare function filterSettingsHookGroups(source: HookSettingsSource, event: string, groups: readonly WireHookGroup[], execFormCapable: boolean, shellRunsType: (type: string | undefined) => boolean, failLoudMcpTool: boolean, judge?: SettingsHookJudge): SettingsHookFilterResult;
113
+ export declare function filterSettingsHookGroups(source: HookSettingsSource, event: string, groups: readonly WireHookGroup[], execFormCapable: boolean, shellRunsType: (type: string | undefined) => boolean, judge: SettingsHookJudge): SettingsHookFilterResult;
114
114
  export interface SettingsHookFilterResult {
115
115
  readonly groups: WireHookGroup[];
116
116
  readonly drops: SettingsHookDrop[];
@@ -312,14 +312,13 @@ function carriesArgs(entry) {
312
312
  }
313
313
  return true;
314
314
  }
315
- export function filterSettingsHookGroups(source, event, groups, execFormCapable, shellRunsType, failLoudMcpTool, judge) {
315
+ export function filterSettingsHookGroups(source, event, groups, execFormCapable, shellRunsType, judge) {
316
316
  const drops = [];
317
317
  const verdicts = [];
318
318
  const excluded = [];
319
319
  const out = [];
320
320
  let stripped = 0;
321
321
  const engineEvent = ENGINE_EVENTS.has(event);
322
- const keepMcpTool = failLoudMcpTool && engineEvent;
323
322
  groups.forEach((group, groupIndex) => {
324
323
  if (!isRecord(group) || !Array.isArray(group.hooks)) {
325
324
  out.push(group);
@@ -331,9 +330,7 @@ export function filterSettingsHookGroups(source, event, groups, execFormCapable,
331
330
  const reason = !isRecord(entry)
332
331
  ? undefined
333
332
  : entry.type === 'mcp_tool'
334
- ? keepMcpTool
335
- ? undefined
336
- : 'mcp_tool_unsupported'
333
+ ? 'mcp_tool_unsupported'
337
334
  : entry.type === 'command' && carriesArgs(entry) && !execFormCapable
338
335
  ? 'exec_form_unsupported'
339
336
  : undefined;
@@ -342,7 +339,7 @@ export function filterSettingsHookGroups(source, event, groups, execFormCapable,
342
339
  changed = true;
343
340
  return;
344
341
  }
345
- if (judge !== undefined && engineEvent && isRecord(entry) && judgeableSettingsEntry(entry)) {
342
+ if (engineEvent && isRecord(entry) && judgeableSettingsEntry(entry)) {
346
343
  const ex = judge(event, group, entry);
347
344
  if (ex.kind === 'excluded') {
348
345
  excluded.push({ source, event, groupIndex, hookIndex, reason: ex.reason });
@@ -0,0 +1,44 @@
1
+ import type { AssistantTaskStatus, CancelAck } from '@sema-agent/sdk';
2
+ import { type SdkRunTerminalStatus } from './terminalStatuses.js';
3
+ export type PreemptParkedStatus = 'suspended' | 'needs_review';
4
+ export type PreemptOutcome = {
5
+ readonly kind: 'yield-requested';
6
+ readonly taskId: string;
7
+ } | {
8
+ readonly kind: 'not-eligible';
9
+ readonly taskId: string;
10
+ } | {
11
+ readonly kind: 'already-ended';
12
+ readonly taskId: string;
13
+ readonly status: SdkRunTerminalStatus;
14
+ } | {
15
+ readonly kind: 'already-parked';
16
+ readonly status?: PreemptParkedStatus;
17
+ } | {
18
+ readonly kind: 'approval-settled';
19
+ } | {
20
+ readonly kind: 'not-found';
21
+ } | {
22
+ readonly kind: 'unconfirmed';
23
+ readonly why: 'transport' | 'server-error' | 'unreadable-answer';
24
+ readonly status?: number;
25
+ } | {
26
+ readonly kind: 'refused';
27
+ readonly status: number;
28
+ readonly errorCode?: string;
29
+ } | {
30
+ readonly kind: 'no-run';
31
+ } | {
32
+ readonly kind: 'cancelled-instead';
33
+ readonly ack: CancelAck;
34
+ } | {
35
+ readonly kind: 'unavailable';
36
+ };
37
+ export type PreemptReading = Exclude<PreemptOutcome, {
38
+ readonly kind: 'no-run' | 'cancelled-instead' | 'unavailable';
39
+ }> | {
40
+ readonly kind: 'lane-absent';
41
+ };
42
+ export declare function preemptReadingOfAck(taskId: string, ack: AssistantTaskStatus): PreemptReading;
43
+ export declare function preemptReadingOfError(e: {} | null | undefined): PreemptReading;
44
+ export declare function preemptReceiptLine(outcome: PreemptOutcome): string;