@sema-agent/client-core 0.97.1 → 0.99.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 (353) hide show
  1. package/CHANGELOG.md +607 -0
  2. package/README.md +96 -46
  3. package/dist/adapt/arms.d.ts +1 -0
  4. package/dist/adapt/arms.js +188 -53
  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/panelTasks.d.ts +1 -1
  10. package/dist/adapt/panelTasks.js +2 -2
  11. package/dist/adapt/textStream.d.ts +1 -0
  12. package/dist/adapt/textStream.js +24 -7
  13. package/dist/adapt/toolCards.d.ts +27 -5
  14. package/dist/adapt/toolCards.js +39 -6
  15. package/dist/adapt/wireShapes.js +6 -2
  16. package/dist/adapt.d.ts +2 -0
  17. package/dist/adapt.js +8 -3
  18. package/dist/adapter/activeRunSelfHeal.d.ts +9 -3
  19. package/dist/adapter/activeRunSelfHeal.js +205 -313
  20. package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
  21. package/dist/adapter/downstream/eventToSdkMessage.js +77 -36
  22. package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
  23. package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
  24. package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
  25. package/dist/adapter/runStream.js +79 -48
  26. package/dist/adapter/types.d.ts +4 -4
  27. package/dist/adapter/types.js +2 -1
  28. package/dist/agentSession/backgroundView.js +2 -1
  29. package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
  30. package/dist/agentSession/engineAgentRegistryRead.js +12 -13
  31. package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
  32. package/dist/agentsWireCaps.d.ts +8 -11
  33. package/dist/agentsWireCaps.js +196 -194
  34. package/dist/approvalDecidedByCapability.d.ts +0 -4
  35. package/dist/approvalDecidedByCapability.js +0 -6
  36. package/dist/approvalsStreamLiveCapability.d.ts +0 -4
  37. package/dist/approvalsStreamLiveCapability.js +0 -6
  38. package/dist/assistantInbox.d.ts +34 -0
  39. package/dist/assistantInbox.js +118 -0
  40. package/dist/centerWiringCapability.js +9 -1
  41. package/dist/clientSlice.d.ts +0 -9
  42. package/dist/clientSlice.js +0 -3
  43. package/dist/cloudConfigWireCaps.d.ts +5 -3
  44. package/dist/cloudConfigWireCaps.js +106 -64
  45. package/dist/compensations.js +1 -1
  46. package/dist/connectorStatus.d.ts +21 -0
  47. package/dist/connectorStatus.js +112 -0
  48. package/dist/controlRouter.d.ts +18 -3
  49. package/dist/controlRouter.js +106 -67
  50. package/dist/coreValuePorts.d.ts +29 -4
  51. package/dist/coreValuePorts.js +10 -0
  52. package/dist/corruptSessionCopy.d.ts +2 -1
  53. package/dist/corruptSessionCopy.js +3 -3
  54. package/dist/decideReceipt.d.ts +2 -2
  55. package/dist/decideReceipt.js +5 -2
  56. package/dist/declared/supportFloorDeclared.js +3 -3
  57. package/dist/detachWire.js +3 -2
  58. package/dist/deviceExecutorManagementCapability.d.ts +0 -4
  59. package/dist/deviceExecutorManagementCapability.js +0 -6
  60. package/dist/deviceRebind.d.ts +49 -1
  61. package/dist/deviceRebind.js +221 -3
  62. package/dist/devicesFace.d.ts +34 -0
  63. package/dist/devicesFace.js +90 -0
  64. package/dist/displayUntrusted.d.ts +2 -0
  65. package/dist/displayUntrusted.js +253 -76
  66. package/dist/engineAgentAbsence.d.ts +1 -1
  67. package/dist/engineAgentPanelStore.d.ts +12 -4
  68. package/dist/engineAgentPanelStore.js +16 -11
  69. package/dist/engineCapReader.d.ts +2 -5
  70. package/dist/engineCapReader.js +8 -10
  71. package/dist/engineCapsCache.d.ts +12 -0
  72. package/dist/engineCapsCache.js +76 -18
  73. package/dist/engineCapsChange.d.ts +2 -0
  74. package/dist/engineCapsChange.js +9 -0
  75. package/dist/engineClosedSets.d.ts +1 -0
  76. package/dist/engineClosedSets.js +4 -1
  77. package/dist/engineErrorCodes.d.ts +11 -3
  78. package/dist/engineErrorCodes.js +11 -8
  79. package/dist/engineIdentity.d.ts +1 -0
  80. package/dist/engineIdentity.js +8 -0
  81. package/dist/engineRowRef.d.ts +28 -0
  82. package/dist/engineRowRef.js +114 -0
  83. package/dist/engineSessionMessages.d.ts +68 -0
  84. package/dist/engineSessionMessages.js +370 -0
  85. package/dist/engineTargetSeat.d.ts +27 -0
  86. package/dist/engineTargetSeat.js +199 -0
  87. package/dist/engineToolDirectory.d.ts +0 -9
  88. package/dist/engineToolDirectory.js +1 -94
  89. package/dist/engineUrl.d.ts +18 -0
  90. package/dist/engineUrl.js +52 -0
  91. package/dist/engineWireFor.js +3 -8
  92. package/dist/env/uiLanguage.d.ts +11 -1
  93. package/dist/env/uiLanguage.js +38 -2
  94. package/dist/eventLeg.d.ts +100 -0
  95. package/dist/eventLeg.js +305 -0
  96. package/dist/executionLaneCapability.d.ts +0 -4
  97. package/dist/executionLaneCapability.js +3 -16
  98. package/dist/fileHistoryCaptureCapability.d.ts +2 -5
  99. package/dist/fileHistoryCaptureCapability.js +13 -21
  100. package/dist/fileHistoryLegNotice.d.ts +2 -1
  101. package/dist/fileHistoryLegNotice.js +3 -3
  102. package/dist/fleet/fleetLedger.d.ts +0 -3
  103. package/dist/fleet/fleetLedger.js +21 -36
  104. package/dist/fleet/fleetProjection.d.ts +2 -2
  105. package/dist/fleet/fleetProjection.js +10 -8
  106. package/dist/frameBinding.d.ts +8 -0
  107. package/dist/frameBinding.js +35 -0
  108. package/dist/gateFailureCodes.d.ts +2 -0
  109. package/dist/gateFailureCodes.js +15 -0
  110. package/dist/gateOutcome.d.ts +3 -1
  111. package/dist/gateOutcome.js +41 -8
  112. package/dist/gateVocabulary.d.ts +10 -4
  113. package/dist/gateVocabulary.js +107 -47
  114. package/dist/generated/engineAskFaceTables.js +2 -2
  115. package/dist/generated/engineFactTables.d.ts +22 -3
  116. package/dist/generated/engineFactTables.js +51 -4
  117. package/dist/generated/engineNoticeTables.js +18 -3
  118. package/dist/generated/settingsSchemaFns.d.ts +6 -0
  119. package/dist/generated/settingsSchemaFns.js +57 -0
  120. package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
  121. package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
  122. package/dist/generated/settingsSchemaTables.d.ts +1 -0
  123. package/dist/generated/settingsSchemaTables.js +4 -0
  124. package/dist/generated/settingsSchemaTypes.d.ts +105 -0
  125. package/dist/generated/settingsSchemaTypes.js +1 -0
  126. package/dist/generated/toolNameTables.d.ts +1 -0
  127. package/dist/generated/toolNameTables.js +1 -0
  128. package/dist/hitl/allowRuleShadow.d.ts +8 -2
  129. package/dist/hitl/allowRuleShadow.js +36 -29
  130. package/dist/hitl/approvalCardReading.d.ts +15 -0
  131. package/dist/hitl/approvalCardReading.js +154 -0
  132. package/dist/hitl/approvalCardReasons.d.ts +14 -0
  133. package/dist/hitl/approvalCardReasons.js +119 -0
  134. package/dist/hitl/approvalHolds.d.ts +50 -15
  135. package/dist/hitl/approvalHolds.js +177 -27
  136. package/dist/hitl/approvalResolution.d.ts +51 -26
  137. package/dist/hitl/approvalResolution.js +86 -122
  138. package/dist/hitl/approvalsFeed.js +6 -18
  139. package/dist/hitl/askClassPair.d.ts +2 -0
  140. package/dist/hitl/askClassPair.js +17 -0
  141. package/dist/hitl/askGateWire.d.ts +20 -2
  142. package/dist/hitl/askGateWire.js +50 -1
  143. package/dist/hitl/askParkRowRouting.d.ts +5 -0
  144. package/dist/hitl/askParkRowRouting.js +32 -1
  145. package/dist/hitl/askSettlementLine.d.ts +28 -0
  146. package/dist/hitl/askSettlementLine.js +99 -0
  147. package/dist/hitl/automaticAnswerVerdict.d.ts +3 -2
  148. package/dist/hitl/automaticAnswerVerdict.js +29 -13
  149. package/dist/hitl/crashConverged.d.ts +11 -20
  150. package/dist/hitl/crashConverged.js +56 -0
  151. package/dist/hitl/crashConvergedNotice.d.ts +6 -3
  152. package/dist/hitl/crashConvergedNotice.js +48 -24
  153. package/dist/hitl/decisionConflict.js +3 -10
  154. package/dist/hitl/decisionRefusal.d.ts +40 -1
  155. package/dist/hitl/decisionRefusal.js +199 -42
  156. package/dist/hitl/frameRouter.d.ts +5 -2
  157. package/dist/hitl/frameRouter.js +27 -24
  158. package/dist/hitl/gateLedger.d.ts +2 -0
  159. package/dist/hitl/gateLedger.js +50 -13
  160. package/dist/hitl/hitlBridge.d.ts +2 -2
  161. package/dist/hitl/hitlBridge.js +13 -10
  162. package/dist/hitl/livePendingAsk.d.ts +3 -3
  163. package/dist/hitl/livePendingAsk.js +7 -18
  164. package/dist/hitl/parkResolver.d.ts +2 -24
  165. package/dist/hitl/parkResolver.js +61 -97
  166. package/dist/hitl/persistedRulesWire.d.ts +25 -0
  167. package/dist/hitl/persistedRulesWire.js +104 -2
  168. package/dist/hitl/planReviewWire.d.ts +31 -13
  169. package/dist/hitl/planReviewWire.js +120 -78
  170. package/dist/hitl/refusedToolNameProse.d.ts +0 -1
  171. package/dist/hitl/refusedToolNameProse.js +0 -3
  172. package/dist/hitl/replayedApproval.d.ts +4 -3
  173. package/dist/hitl/replayedApproval.js +7 -4
  174. package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
  175. package/dist/hitl/sessionPolicyDeliverable.js +48 -7
  176. package/dist/hitl/sessionPolicyWire.d.ts +34 -21
  177. package/dist/hitl/sessionPolicyWire.js +179 -70
  178. package/dist/hitl/standingRows.d.ts +20 -2
  179. package/dist/hitl/standingRows.js +69 -8
  180. package/dist/hitl/suspendedReopen.d.ts +2 -1
  181. package/dist/hitl/suspendedReopen.js +7 -10
  182. package/dist/hitl/toolApprovalWire.d.ts +103 -156
  183. package/dist/hitl/toolApprovalWire.js +661 -411
  184. package/dist/hookMatcherVerdict.d.ts +6 -1
  185. package/dist/hookMatcherVerdict.js +14 -7
  186. package/dist/hooksWireCaps.d.ts +2 -2
  187. package/dist/hooksWireCaps.js +174 -81
  188. package/dist/host.d.ts +21 -0
  189. package/dist/hostTurnSettings.d.ts +71 -0
  190. package/dist/hostTurnSettings.js +291 -0
  191. package/dist/humanTurn.d.ts +14 -1
  192. package/dist/humanTurn.js +100 -12
  193. package/dist/humanTurnRead.d.ts +2 -0
  194. package/dist/humanTurnRead.js +22 -1
  195. package/dist/i18n/messages.en.d.ts +703 -0
  196. package/dist/i18n/messages.en.js +701 -0
  197. package/dist/i18n/messages.zh.d.ts +3 -0
  198. package/dist/i18n/messages.zh.js +837 -0
  199. package/dist/i18n/translate.d.ts +25 -0
  200. package/dist/i18n/translate.js +127 -0
  201. package/dist/index.d.ts +78 -29
  202. package/dist/index.js +54 -18
  203. package/dist/inheritEnvCapability.d.ts +32 -0
  204. package/dist/inheritEnvCapability.js +104 -0
  205. package/dist/inheritEnvWire.d.ts +3 -2
  206. package/dist/inheritEnvWire.js +12 -14
  207. package/dist/interactiveHalt.js +17 -6
  208. package/dist/liveModelCatalog.d.ts +3 -3
  209. package/dist/liveModelCatalog.js +15 -13
  210. package/dist/liveQuestionStore.d.ts +2 -21
  211. package/dist/mcpLiveness.d.ts +2 -1
  212. package/dist/mcpPanel.d.ts +10 -1
  213. package/dist/mcpPanel.js +40 -13
  214. package/dist/mcpProbeCapability.d.ts +2 -1
  215. package/dist/mcpProbeCapability.js +7 -11
  216. package/dist/mcpProbeWire.d.ts +9 -2
  217. package/dist/mcpProbeWire.js +6 -1
  218. package/dist/mcpWireCaps.d.ts +47 -2
  219. package/dist/mcpWireCaps.js +164 -16
  220. package/dist/memoryEntriesWire.d.ts +4 -9
  221. package/dist/memoryEntriesWire.js +5 -10
  222. package/dist/model/modelSupplyRules.d.ts +0 -2
  223. package/dist/model/modelSupplyRules.js +3 -12
  224. package/dist/model/modelsPolicy.d.ts +0 -5
  225. package/dist/model/modelsPolicy.js +6 -36
  226. package/dist/model/onboardJudgement.d.ts +93 -0
  227. package/dist/model/onboardJudgement.js +415 -0
  228. package/dist/model/subagentModelWord.d.ts +31 -0
  229. package/dist/model/subagentModelWord.js +261 -0
  230. package/dist/model/tierVocabulary.d.ts +2 -0
  231. package/dist/model/tierVocabulary.js +17 -5
  232. package/dist/modelCapabilityProbe.d.ts +64 -0
  233. package/dist/modelCapabilityProbe.js +600 -0
  234. package/dist/modelIdentityResolvability.d.ts +3 -0
  235. package/dist/modelIdentityResolvability.js +26 -17
  236. package/dist/notifications.d.ts +6 -0
  237. package/dist/notifications.js +71 -23
  238. package/dist/outputStyleSeatCapability.d.ts +0 -3
  239. package/dist/outputStyleSeatCapability.js +0 -3
  240. package/dist/ownKey.d.ts +22 -0
  241. package/dist/ownKey.js +94 -3
  242. package/dist/panelReduce.d.ts +21 -10
  243. package/dist/panelReduce.js +728 -550
  244. package/dist/panelStateHolder.d.ts +3 -7
  245. package/dist/panelStateHolder.js +14 -130
  246. package/dist/peerLaneCapability.d.ts +0 -4
  247. package/dist/peerLaneCapability.js +0 -6
  248. package/dist/permissionRuleIssue.js +2 -0
  249. package/dist/permissionRulesWriteCapability.d.ts +2 -5
  250. package/dist/permissionRulesWriteCapability.js +8 -12
  251. package/dist/permissionWireCaps.d.ts +2 -2
  252. package/dist/permissionWireCaps.js +2 -0
  253. package/dist/permissionsAllowGrantCapability.d.ts +0 -4
  254. package/dist/permissionsAllowGrantCapability.js +0 -6
  255. package/dist/permissionsDeclaration.d.ts +0 -11
  256. package/dist/permissionsDeclaration.js +60 -53
  257. package/dist/pluginHooksWire.d.ts +46 -3
  258. package/dist/pluginHooksWire.js +219 -16
  259. package/dist/preemptWire.d.ts +44 -0
  260. package/dist/preemptWire.js +83 -0
  261. package/dist/printModelStatus.d.ts +63 -0
  262. package/dist/printModelStatus.js +155 -0
  263. package/dist/printToolResultFrame.js +15 -4
  264. package/dist/replayBody.d.ts +3 -0
  265. package/dist/replayBody.js +14 -0
  266. package/dist/request/taskRequest.d.ts +11 -6
  267. package/dist/request/taskRequest.js +112 -19
  268. package/dist/resumeRefusalCopy.d.ts +13 -9
  269. package/dist/resumeRefusalCopy.js +81 -118
  270. package/dist/retryStatus.d.ts +45 -0
  271. package/dist/retryStatus.js +185 -1
  272. package/dist/rewindArchiveCapability.d.ts +0 -4
  273. package/dist/rewindArchiveCapability.js +2 -10
  274. package/dist/rewindArchiveReading.d.ts +0 -1
  275. package/dist/rewindArchiveReading.js +0 -3
  276. package/dist/runCancelContext.d.ts +2 -1
  277. package/dist/runCancelContext.js +4 -2
  278. package/dist/runReattachPolicy.d.ts +31 -0
  279. package/dist/runReattachPolicy.js +46 -0
  280. package/dist/runTerminal.d.ts +3 -6
  281. package/dist/runTerminal.js +8 -9
  282. package/dist/sandboxWire.d.ts +3 -1
  283. package/dist/sandboxWire.js +76 -27
  284. package/dist/scenarioRefusal.d.ts +9 -0
  285. package/dist/scenarioRefusal.js +111 -0
  286. package/dist/scenarioWire.js +1 -1
  287. package/dist/seam.d.ts +48 -2
  288. package/dist/seam.js +25 -4
  289. package/dist/seatContract.d.ts +311 -18
  290. package/dist/seatContract.js +824 -100
  291. package/dist/selfOrchestrationDenial.js +7 -19
  292. package/dist/sessionIdSegment.d.ts +6 -0
  293. package/dist/sessionIdSegment.js +24 -0
  294. package/dist/sessionMemoryStatus.js +6 -11
  295. package/dist/sessionPolicyCapability.d.ts +2 -5
  296. package/dist/sessionPolicyCapability.js +8 -12
  297. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
  298. package/dist/sessionSyncFileHistoryCapability.js +0 -3
  299. package/dist/settingsHooksSalvage.d.ts +44 -0
  300. package/dist/settingsHooksSalvage.js +211 -0
  301. package/dist/skillToolListsCapability.d.ts +2 -4
  302. package/dist/skillToolListsCapability.js +8 -9
  303. package/dist/sqlEngineCapability.d.ts +0 -4
  304. package/dist/sqlEngineCapability.js +0 -6
  305. package/dist/sseIdleTriage.js +3 -2
  306. package/dist/steerPriorityCapability.d.ts +0 -3
  307. package/dist/steerPriorityCapability.js +0 -3
  308. package/dist/streamDrainingLegs.d.ts +4 -0
  309. package/dist/streamDrainingLegs.js +6 -1
  310. package/dist/subagent/engineCompactWire.d.ts +0 -1
  311. package/dist/subagent/engineCompactWire.js +7 -5
  312. package/dist/subagent/engineSubagentResume.js +15 -9
  313. package/dist/subagent/engineTaskHandleWire.js +4 -7
  314. package/dist/subagentContentStore.d.ts +3 -0
  315. package/dist/subagentContentStore.js +22 -10
  316. package/dist/submitReopen.d.ts +24 -0
  317. package/dist/submitReopen.js +75 -0
  318. package/dist/terminalStatuses.d.ts +3 -0
  319. package/dist/terminalStatuses.js +10 -2
  320. package/dist/toolHistoryMismatch.js +3 -2
  321. package/dist/toolResult.d.ts +10 -1
  322. package/dist/toolResult.js +34 -6
  323. package/dist/toolRoster.d.ts +3 -4
  324. package/dist/toolRoster.js +21 -22
  325. package/dist/turnFailurePresentation.d.ts +39 -0
  326. package/dist/turnFailurePresentation.js +402 -0
  327. package/dist/usageAnalytics.js +6 -11
  328. package/dist/userAttachmentEnvelope.d.ts +1 -0
  329. package/dist/userAttachmentEnvelope.js +37 -7
  330. package/dist/userAttachmentSeat.d.ts +21 -0
  331. package/dist/userAttachmentSeat.js +75 -0
  332. package/dist/userInvokedSkillsCapability.d.ts +11 -4
  333. package/dist/userInvokedSkillsCapability.js +31 -10
  334. package/dist/webSearchBackendCapability.d.ts +0 -4
  335. package/dist/webSearchBackendCapability.js +0 -6
  336. package/dist/wireErrorTriage.d.ts +7 -0
  337. package/dist/wireErrorTriage.js +26 -23
  338. package/dist/wireFailureShape.d.ts +62 -5
  339. package/dist/wireFailureShape.js +106 -5
  340. package/dist/wireRefusalCopy.d.ts +25 -3
  341. package/dist/wireRefusalCopy.js +74 -80
  342. package/dist/workflowsJournalCapability.d.ts +2 -5
  343. package/dist/workflowsJournalCapability.js +8 -12
  344. package/dist/writeProtectionCapability.d.ts +0 -4
  345. package/dist/writeProtectionCapability.js +0 -6
  346. package/docs/INTEGRATION-CLIENTS.md +1775 -56
  347. package/package.json +6 -5
  348. package/dist/attachmentSeatCapability.d.ts +0 -12
  349. package/dist/attachmentSeatCapability.js +0 -23
  350. package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
  351. package/dist/hitl/approvalOutcomeNote.js +0 -29
  352. package/dist/sessionReadRedactionCapability.d.ts +0 -13
  353. package/dist/sessionReadRedactionCapability.js +0 -35
@@ -1,21 +1,15 @@
1
1
  import { hostEnv } from './hostEnv.js';
2
- import { ownDataField } from './ownKey.js';
3
2
  import { makeEngineWireClient } from './engineWireSdk.js';
4
3
  import { frozenSet } from './frozenSet.js';
5
4
  import { settleWithinDeadline } from './abortableSleep.js';
5
+ import { engineCapValue, engineCapValueVia, engineCapsGeneration, engineCapsLandingOf, engineCapsSettled, kickEngineCapsProbe } from './engineCapsCache.js';
6
6
  import { ruleToolNameVerdictOf } from './protocolSegment.js';
7
7
  import { CORE_PROTOCOL_PREFIXES } from './generated/toolNameTables.js';
8
8
  import { rosterMountedNames } from './rosterMountedNames.js';
9
9
  import { capForDisplay } from './fleetTaskDesc.js';
10
- import { deniedEntryToolName, mcpEntryReadingOf } from './engineToolDirectory.js';
10
+ import { deniedEntryToolName } from './engineToolDirectory.js';
11
+ import { assemblyRefusal, withAssemblyRefusal } from './wireFailureShape.js';
11
12
  export const MAX_TASK_AGENTS = 32;
12
- export const MAX_AGENT_NAME_CHARS = 64;
13
- export const MAX_AGENT_TEXT_CHARS = 4_096;
14
- export const MAX_AGENT_SYSTEM_PROMPT_CHARS = 65_536;
15
- export const MAX_AGENT_TOOLS = 64;
16
- export const MAX_AGENT_TOOL_NAME_CHARS = 128;
17
- export const MAX_AGENT_SKILL_CONTENT_CHARS = 1_048_576;
18
- export const MAX_AGENT_MAX_TURNS = 1_000;
19
13
  export const TASK_AGENT_WIRE_FIELDS = [
20
14
  'name',
21
15
  'whenToUse',
@@ -101,6 +95,24 @@ function toolListFlawPhrase(f) {
101
95
  return `${entry} could not be checked here, because the engine's tool-name check is not available in this client`;
102
96
  return `${entry} differs from the tool ${JSON.stringify(f.currentName ?? '')} only in letter case`;
103
97
  }
98
+ function listShapeWord(v) {
99
+ try {
100
+ if (v === null)
101
+ return 'null';
102
+ if (typeof v === 'string')
103
+ return 'a string';
104
+ if (typeof v === 'object')
105
+ return 'an object';
106
+ return `a ${typeof v}`;
107
+ }
108
+ catch {
109
+ return 'unreadable';
110
+ }
111
+ }
112
+ function toolListShapeRefusal(agent, key, v) {
113
+ return withAssemblyRefusal(new TypeError(`projectAgentsForWire: agent "${capForDisplay(agent, 80)}" has ${key} written as ${listShapeWord(v)}, but it must be an array of tool-name strings — ` +
114
+ 'refusing to assemble the agents list (a list dropped silently would give the agent every tool, or remove a deny rule). Fix the definition.'), 'input_malformed');
115
+ }
104
116
  export function projectAgentsForWire(defs, deps) {
105
117
  const warnings = [];
106
118
  const customs = defs
@@ -120,44 +132,31 @@ export function projectAgentsForWire(defs, deps) {
120
132
  const name = def.agentType;
121
133
  if (typeof name !== 'string' || name.length === 0)
122
134
  continue;
123
- if (name.length > MAX_AGENT_NAME_CHARS) {
124
- warnings.push(`agents wire: agent name "${name.slice(0, 40)}…" exceeds ${MAX_AGENT_NAME_CHARS} chars — definition skipped`);
125
- continue;
126
- }
127
135
  if (seen.has(name))
128
136
  continue;
129
137
  seen.add(name);
130
138
  const item = { name };
131
- if (typeof def.whenToUse === 'string' && def.whenToUse.length > 0) {
132
- item.whenToUse =
133
- def.whenToUse.length > MAX_AGENT_TEXT_CHARS
134
- ? def.whenToUse.slice(0, MAX_AGENT_TEXT_CHARS)
135
- : def.whenToUse;
136
- if (def.whenToUse.length > MAX_AGENT_TEXT_CHARS) {
137
- warnings.push(`agents wire: agent "${name}" description truncated to ${MAX_AGENT_TEXT_CHARS} chars`);
138
- }
139
- }
140
- const projectTools = (list, label) => {
141
- if (!Array.isArray(list) || list.length === 0)
142
- return undefined;
143
- const kept = list.filter(t => typeof t === 'string' && t.length > 0 && t.length <= MAX_AGENT_TOOL_NAME_CHARS);
144
- if (kept.length !== list.length) {
139
+ if (typeof def.whenToUse === 'string' && def.whenToUse.length > 0)
140
+ item.whenToUse = def.whenToUse;
141
+ const rawTools = def.tools;
142
+ const rawDeny = def.disallowedTools;
143
+ if (rawTools !== undefined && !Array.isArray(rawTools))
144
+ throw toolListShapeRefusal(name, 'tools', rawTools);
145
+ if (rawDeny !== undefined && !Array.isArray(rawDeny))
146
+ throw toolListShapeRefusal(name, 'disallowedTools', rawDeny);
147
+ const toolEntries = (list, label) => {
148
+ const entries = list.filter((t) => typeof t === 'string' && t.length > 0);
149
+ if (entries.length !== list.length)
145
150
  warnings.push(`agents wire: agent "${name}" ${label} had invalid entries — dropped`);
146
- }
147
- if (kept.length === 0)
148
- return undefined;
149
- if (kept.length > MAX_AGENT_TOOLS) {
150
- warnings.push(`agents wire: agent "${name}" ${label} truncated to ${MAX_AGENT_TOOLS} entries`);
151
- return kept.slice(0, MAX_AGENT_TOOLS);
152
- }
153
- return kept;
151
+ return entries;
154
152
  };
155
- const allowTools = projectTools(def.tools, 'tools');
156
- if (allowTools)
157
- item.allowTools = allowTools;
158
- const denyTools = projectTools(def.disallowedTools, 'disallowedTools');
159
- if (denyTools)
160
- item.denyTools = denyTools;
153
+ if (Array.isArray(rawTools))
154
+ item.allowTools = toolEntries(rawTools, 'tools');
155
+ if (Array.isArray(rawDeny)) {
156
+ const denyTools = toolEntries(rawDeny, 'disallowedTools');
157
+ if (denyTools.length > 0)
158
+ item.denyTools = denyTools;
159
+ }
161
160
  let whoMemo;
162
161
  const whoOf = () => {
163
162
  if (whoMemo !== undefined)
@@ -172,67 +171,29 @@ export function projectAgentsForWire(defs, deps) {
172
171
  whoMemo = `agent "${name}"${typeof source === 'string' && source.length > 0 ? ` (${capForDisplay(source, 120)})` : ''}`;
173
172
  return whoMemo;
174
173
  };
175
- const flaws = agentToolListFlaws([item], deps.toolRoster);
176
- const flawedEntries = new Set(flaws.map((f) => `${f.list}\u0000${f.entry}`));
177
- const omittedAllowFlaws = new Set(flaws.filter((f) => f.list === 'tools' && f.kind !== 'unjudged').map((f) => f.entry));
174
+ const rosterInHand = typeof rosterMountedNames(deps.toolRoster) === 'object';
175
+ const flaws = agentToolListFlaws([item], deps.toolRoster).map((f) => {
176
+ if (!rosterInHand || f.list !== 'disallowedTools' || f.kind !== 'retired' || f.currentName === undefined || f.toolName !== undefined)
177
+ return f;
178
+ const to = f.currentName;
179
+ if (item.denyTools !== undefined)
180
+ item.denyTools = item.denyTools.map((e) => (e === f.entry ? to : e));
181
+ return { ...f, rewritten: true };
182
+ });
178
183
  if (flaws.length > 0) {
179
184
  const who = whoOf();
180
185
  toolListFlaws.push(...flaws);
181
- const denyFlaws = flaws.filter(f => f.list === 'disallowedTools');
182
- const withhold = denyFlaws.length > 0 && deps.withholdRefusedDenyLists === true;
183
- if (denyFlaws.length > 0) {
184
- const what = `its disallowedTools ${denyFlaws.length === 1 ? 'entry' : 'entries'} ${denyFlaws.map(toolListFlawPhrase).join('; ')}`;
185
- warnings.push(withhold
186
- ? `agents wire: ${who} is not sent to the engine — ${what}, and this engine refuses to start a run whose agent definitions name a tool that way. Fix the entry in the agent definition; until then this agent is not available.`
187
- : `agents wire: ${who}: ${what} — tool names are matched exactly, so ${denyFlaws.length === 1 ? 'this entry hides' : 'these entries hide'} nothing from the agent, and newer engines refuse to start a run with it. Fix the entry in the agent definition.`);
188
- }
189
- if (!withhold) {
190
- for (const f of flaws) {
191
- if (f.list !== 'tools')
192
- continue;
193
- warnings.push(f.kind === 'unjudged'
194
- ? `agents wire: ${who}: its tools entry ${toolListFlawPhrase(f)} — tool names are matched exactly, so this entry does not give the agent that tool. Fix the entry in the agent definition.`
195
- : `agents wire: ${who}: its tools entry ${toolListFlawPhrase(f)} — tool names are matched exactly, so no tool answers to this entry; it is omitted (newer engines refuse a request whose agent definitions name it). Fix the entry in the agent definition.`);
196
- }
197
- }
198
- if (withhold)
199
- continue;
200
- }
201
- const filterList = (key, label) => {
202
- const entries = item[key];
203
- if (entries === undefined)
204
- return;
205
- const kept = [];
206
- for (const entry of entries) {
207
- if (label === 'tools' && omittedAllowFlaws.has(entry))
208
- continue;
209
- if (flawedEntries.has(`${label}\u0000${entry}`)) {
210
- kept.push(entry);
211
- continue;
212
- }
213
- const toolName = label === 'disallowedTools' ? deniedEntryToolName(entry) : entry;
214
- const reading = toolName === undefined ? 'outside' : mcpEntryReadingOf(toolName, deps.toolDirectory);
215
- if (reading === 'unanswered') {
216
- warnings.push(`agents wire: ${whoOf()} ${label} entry ${JSON.stringify(entry)} names no tool this deployment answers to — omitted: no MCP server of that name is declared for this session, so there is nothing to ${label === 'tools' ? 'give' : 'hide'}, and newer engines refuse a request whose agent definitions name such a tool. Remove the entry or configure the server.`);
186
+ for (const f of flaws) {
187
+ if (f.rewritten !== true)
217
188
  continue;
218
- }
219
- if (reading === 'unchecked') {
220
- warnings.push(`agents wire: ${whoOf()} ${label} entry ${JSON.stringify(entry)} could not be checked against the MCP servers this session declares — sent as written; if no such server is declared, newer engines refuse the whole request until the entry is removed.`);
221
- }
222
- kept.push(entry);
223
- }
224
- if (key === 'allowTools') {
225
- item.allowTools = kept;
189
+ warnings.push(`agents wire: ${who}: its disallowedTools entry ${toolListFlawPhrase(f)} — rewritten to ${JSON.stringify(f.currentName)} for this run (this run's tools include none named ${JSON.stringify(f.entry)}). Update the entry in the agent definition.`);
226
190
  }
227
- else if (kept.length > 0) {
228
- item.denyTools = kept;
229
- }
230
- else {
231
- delete item.denyTools;
191
+ for (const f of flaws) {
192
+ if (f.list !== 'tools')
193
+ continue;
194
+ warnings.push(`agents wire: ${who}: its tools entry ${toolListFlawPhrase(f)} — sent as written; tool names are matched exactly, so this entry gives the agent nothing unless this run has a tool with exactly that name. Fix the entry in the agent definition.`);
232
195
  }
233
- };
234
- filterList('denyTools', 'disallowedTools');
235
- filterList('allowTools', 'tools');
196
+ }
236
197
  if (def.memory !== undefined) {
237
198
  if (typeof def.memory === 'string' && AGENT_MEMORY_WORDS.has(def.memory)) {
238
199
  item.memory = { scopes: [`agent:${name}`], writeScope: `agent:${name}` };
@@ -252,7 +213,7 @@ export function projectAgentsForWire(defs, deps) {
252
213
  if (typeof skillName !== 'string' || skillName.length === 0)
253
214
  continue;
254
215
  const spec = byName.get(skillName.toLowerCase());
255
- if (spec && spec.content.length > 0 && spec.content.length <= MAX_AGENT_SKILL_CONTENT_CHARS) {
216
+ if (spec && spec.content.length > 0) {
256
217
  joined.push(spec);
257
218
  }
258
219
  else {
@@ -289,70 +250,61 @@ export function projectAgentsForWire(defs, deps) {
289
250
  catch {
290
251
  prompt = undefined;
291
252
  }
292
- if (typeof prompt === 'string' && prompt.length > 0) {
293
- if (prompt.length > MAX_AGENT_SYSTEM_PROMPT_CHARS) {
294
- warnings.push(`agents wire: agent "${name}" system prompt truncated to ${MAX_AGENT_SYSTEM_PROMPT_CHARS} chars`);
295
- prompt = prompt.slice(0, MAX_AGENT_SYSTEM_PROMPT_CHARS);
296
- }
253
+ if (typeof prompt === 'string' && prompt.length > 0)
297
254
  item.systemPrompt = prompt;
298
- }
299
- }
300
- if (def.maxTurns !== undefined) {
301
- if (typeof def.maxTurns === 'number' &&
302
- Number.isInteger(def.maxTurns) &&
303
- def.maxTurns >= 1 &&
304
- def.maxTurns <= MAX_AGENT_MAX_TURNS) {
305
- item.maxTurns = def.maxTurns;
306
- }
307
- else {
308
- warnings.push(`agents wire: agent "${name}" maxTurns ${String(def.maxTurns)} out of range (1..${MAX_AGENT_MAX_TURNS}) — dropped`);
309
- }
310
255
  }
256
+ if (def.maxTurns !== undefined)
257
+ item.maxTurns = def.maxTurns;
311
258
  out.push(item);
312
259
  }
313
260
  return { agents: out.length > 0 ? out : undefined, warnings, ...(toolListFlaws.length > 0 ? { toolListFlaws } : {}) };
314
261
  }
262
+ function taskAgentsVerdictOf(v) {
263
+ switch (v.kind) {
264
+ case 'value':
265
+ return v.value === true;
266
+ case 'unobserved':
267
+ case 'unreadable':
268
+ return undefined;
269
+ default:
270
+ return false;
271
+ }
272
+ }
273
+ const TASK_AGENTS_CAPS_SETTLE_MS = 3000;
315
274
  export async function engineSupportsTaskAgents(baseUrl, opts) {
275
+ const budget = opts?.timeoutMs ?? TASK_AGENTS_CAPS_SETTLE_MS;
316
276
  if (opts?.client !== undefined) {
317
277
  const injected = opts.client;
318
278
  if (typeof injected?.capabilities !== 'function')
319
279
  return undefined;
320
- const got = await settleWithinDeadline(opts.timeoutMs ?? 3000, (signal) => injected.capabilities({ signal }));
321
- return got.kind === 'value' ? taskAgentsOf(got.value) : undefined;
280
+ return taskAgentsVerdictOf(await engineCapValueVia(undefined, 'taskAgents', async () => {
281
+ const got = await settleWithinDeadline(budget, (signal) => injected.capabilities({ signal }));
282
+ if (got.kind !== 'value')
283
+ throw new Error('capabilities probe did not settle within its budget');
284
+ return got.value;
285
+ }));
322
286
  }
323
287
  const client = makeEngineWireClient({
324
288
  baseUrl,
325
289
  ...(opts?.authToken ? { token: opts.authToken } : {}),
326
290
  ...(opts?.principal ? { principal: opts.principal } : {}),
327
- timeoutMs: opts?.timeoutMs ?? 3000,
291
+ timeoutMs: budget,
328
292
  ...(opts?.fetchImpl ? { fetchImpl: opts.fetchImpl } : {}),
329
293
  });
330
294
  if (!client)
331
295
  return undefined;
332
- try {
333
- const caps = await client.capabilities();
334
- return taskAgentsOf(caps);
335
- }
336
- catch {
337
- return undefined;
338
- }
339
- }
340
- function taskAgentsOf(caps) {
341
- if (caps === null || typeof caps !== 'object')
342
- return false;
343
- try {
344
- return ownDataField(caps, 'taskAgents') === true;
345
- }
346
- catch {
347
- return undefined;
348
- }
296
+ return taskAgentsVerdictOf(await engineCapValueVia(undefined, 'taskAgents', () => client.capabilities()));
349
297
  }
350
298
  let activeProjector = null;
351
299
  let preparedKey = null;
300
+ let preparedCapsGen = null;
352
301
  let preparedPromise = null;
353
302
  let payload;
354
- let capsVerdict;
355
- let settleGeneration = null;
303
+ let currentGeneration = null;
304
+ function concludeGeneration(generation, outcome) {
305
+ if (generation !== null && preparedPromise === generation && currentGeneration !== null)
306
+ currentGeneration.outcome = outcome;
307
+ }
356
308
  const emittedWarnings = new Set();
357
309
  function warnOnce(msg) {
358
310
  if (emittedWarnings.has(msg))
@@ -360,45 +312,60 @@ function warnOnce(msg) {
360
312
  emittedWarnings.add(msg);
361
313
  console.error(`[sema] ${msg}`);
362
314
  }
315
+ function capsVerdictAt(baseUrl) {
316
+ return baseUrl === null ? undefined : taskAgentsVerdictOf(engineCapValue(baseUrl, 'taskAgents'));
317
+ }
318
+ function capsSettledAt(baseUrl) {
319
+ return baseUrl === null ? Promise.resolve() : engineCapsSettled(baseUrl, { withinMs: TASK_AGENTS_CAPS_SETTLE_MS });
320
+ }
321
+ function kickTaskAgentsCaps(cfg) {
322
+ if (engineCapsLandingOf(cfg.baseUrl).kind !== 'not_landed')
323
+ return;
324
+ const client = makeEngineWireClient({
325
+ baseUrl: cfg.baseUrl,
326
+ ...(cfg.authToken ? { token: cfg.authToken } : {}),
327
+ ...(cfg.principal ? { principal: cfg.principal } : {}),
328
+ timeoutMs: TASK_AGENTS_CAPS_SETTLE_MS,
329
+ });
330
+ if (!client)
331
+ return;
332
+ kickEngineCapsProbe(cfg.baseUrl, () => client.capabilities());
333
+ }
334
+ function watchCapsVerdict(baseUrl) {
335
+ void engineCapsSettled(baseUrl).then(() => {
336
+ if (preparedKey !== baseUrl || capsVerdictAt(baseUrl) !== false)
337
+ return;
338
+ payload = undefined;
339
+ concludeGeneration(preparedPromise, 'ok');
340
+ currentGeneration?.settle();
341
+ });
342
+ }
363
343
  function applyProjectionIfCurrent(generation, projected) {
364
344
  if (generation === null || preparedPromise !== generation)
365
345
  return false;
366
- const accepted = capsVerdict !== false;
346
+ const accepted = capsVerdictAt(preparedKey) !== false;
367
347
  if (accepted) {
368
348
  for (const w of projected.warnings)
369
349
  warnOnce(w);
370
350
  payload = projected.agents;
371
351
  }
372
- settleGeneration?.();
352
+ else {
353
+ payload = undefined;
354
+ }
355
+ concludeGeneration(generation, 'ok');
356
+ currentGeneration?.settle();
373
357
  return accepted;
374
358
  }
375
- function startCapsProbe(cfg) {
376
- const land = (verdict) => {
377
- if (capsVerdict !== probe)
378
- return verdict;
379
- capsVerdict = verdict;
380
- if (verdict === false) {
381
- payload = undefined;
382
- settleGeneration?.();
383
- }
384
- return verdict;
385
- };
386
- const probe = engineSupportsTaskAgents(cfg.baseUrl, {
387
- authToken: cfg.authToken,
388
- principal: cfg.principal,
389
- }).then(land, () => land(undefined));
390
- capsVerdict = probe;
391
- return probe;
392
- }
393
- function capsSettled() {
394
- return capsVerdict instanceof Promise ? capsVerdict : Promise.resolve();
395
- }
396
- async function runPrepare(cfg, projector, probe, generation) {
359
+ async function runPrepare(cfg, projector, generation) {
397
360
  try {
398
- const [caps, projected] = await Promise.all([probe, projector()]);
399
- if (caps === false) {
400
- if (projected.agents && preparedKey === cfg.baseUrl) {
401
- warnOnce(`agents wire: this engine does not support per-task custom agents (capabilities.taskAgents is not true: the engine does not report it, or this deployment turns it off, for example a multi-tenant one; this client cannot tell which) — ${projected.agents.length} custom agent definition(s) will NOT be sent`);
361
+ const [, projected] = await Promise.all([capsSettledAt(cfg.baseUrl), projector()]);
362
+ if (capsVerdictAt(cfg.baseUrl) === false) {
363
+ if (preparedKey === cfg.baseUrl) {
364
+ payload = undefined;
365
+ concludeGeneration(generation, 'ok');
366
+ if (projected.agents) {
367
+ warnOnce(`agents wire: this engine does not support per-task custom agents (capabilities.taskAgents is not true: the engine does not report it, or this deployment turns it off, for example a multi-tenant one; this client cannot tell which) — ${projected.agents.length} custom agent definition(s) will NOT be sent`);
368
+ }
402
369
  }
403
370
  return;
404
371
  }
@@ -411,29 +378,33 @@ async function runPrepare(cfg, projector, probe, generation) {
411
378
  catch (e) {
412
379
  if (preparedPromise === generation)
413
380
  payload = undefined;
381
+ concludeGeneration(generation, 'failed');
414
382
  if (hostEnv().SEMA_DEBUG) {
415
- console.error('[sema] agents wire prepare soft-failed (no agents stamped):', e);
383
+ console.error('[sema] agents wire prepare failed (the readiness gate refuses this turn):', e);
416
384
  }
417
385
  }
418
386
  }
419
387
  export function prepareTaskAgentsWireWith(cfg, projector) {
420
388
  const key = cfg.baseUrl;
421
- if (preparedPromise && preparedKey === key)
389
+ kickTaskAgentsCaps(cfg);
390
+ const capsGen = engineCapsGeneration(key);
391
+ if (preparedPromise && preparedKey === key && preparedCapsGen === capsGen)
422
392
  return preparedPromise;
423
393
  preparedKey = key;
394
+ preparedCapsGen = capsGen;
424
395
  activeProjector = projector;
425
- const probe = startCapsProbe(cfg);
426
- return startGeneration(generation => runPrepare(cfg, projector, probe, generation));
396
+ watchCapsVerdict(key);
397
+ return startGeneration(generation => runPrepare(cfg, projector, generation));
427
398
  }
428
399
  function startGeneration(run) {
429
400
  let settle;
430
401
  const generation = new Promise(resolve => {
431
402
  settle = resolve;
432
403
  });
433
- const superseded = settleGeneration;
404
+ const superseded = currentGeneration;
434
405
  preparedPromise = generation;
435
- settleGeneration = settle;
436
- superseded?.();
406
+ currentGeneration = { settle, outcome: undefined };
407
+ superseded?.settle();
437
408
  void run(generation).then(settle, settle);
438
409
  return generation;
439
410
  }
@@ -445,28 +416,36 @@ export function invalidateTaskAgentsWire() {
445
416
  return startGeneration(generation => runReproject(projector, generation));
446
417
  }
447
418
  async function runReproject(projector, generation) {
419
+ const base = preparedKey;
448
420
  try {
449
421
  let projected;
450
422
  try {
451
423
  projected = await projector();
452
424
  }
453
425
  catch (e) {
426
+ concludeGeneration(generation, 'failed');
454
427
  if (hostEnv().SEMA_DEBUG) {
455
- console.error('[sema] agents wire re-project soft-failed (no agents stamped until the next successful projection):', e);
428
+ console.error('[sema] agents wire re-project failed (the readiness gate refuses until a projection succeeds):', e);
456
429
  }
457
430
  return;
458
431
  }
459
- await capsSettled();
432
+ await capsSettledAt(base);
460
433
  applyProjectionIfCurrent(generation, projected);
461
434
  }
462
435
  catch {
436
+ concludeGeneration(generation, 'failed');
463
437
  }
464
438
  }
465
439
  export async function awaitTaskAgentsWire(timeoutMs = 4000) {
466
440
  if (!preparedPromise)
467
- return;
468
- if (capsVerdict === false)
469
- return;
441
+ return taskAgentsReady();
442
+ if (capsVerdictAt(preparedKey) === false)
443
+ return taskAgentsReady();
444
+ const projector = activeProjector;
445
+ if (currentGeneration?.outcome === 'failed' && projector !== null) {
446
+ payload = undefined;
447
+ void startGeneration(generation => runReproject(projector, generation));
448
+ }
470
449
  let timeoutHandle;
471
450
  let timedOut = false;
472
451
  const deadline = new Promise(resolve => {
@@ -486,33 +465,56 @@ export async function awaitTaskAgentsWire(timeoutMs = 4000) {
486
465
  if (timeoutHandle !== undefined)
487
466
  clearTimeout(timeoutHandle);
488
467
  }
468
+ if (preparedPromise === null || capsVerdictAt(preparedKey) === false)
469
+ return taskAgentsReady();
470
+ const outcome = currentGeneration?.outcome;
471
+ if (outcome === 'ok')
472
+ return taskAgentsReady();
473
+ if (outcome === 'failed')
474
+ return Object.freeze({ ok: false, refusal: assemblyRefusal('agents_projection_failed') });
475
+ kickTaskAgentsRefresh();
476
+ return Object.freeze({ ok: false, refusal: assemblyRefusal('agents_not_ready') });
477
+ }
478
+ function taskAgentsReady() {
479
+ return Object.freeze({ ok: true });
480
+ }
481
+ function kickTaskAgentsRefresh() {
482
+ const projector = activeProjector;
483
+ if (!preparedPromise || projector === null)
484
+ return false;
485
+ const generation = preparedPromise;
486
+ const base = preparedKey;
487
+ let refreshing;
488
+ try {
489
+ refreshing = projector();
490
+ }
491
+ catch {
492
+ return false;
493
+ }
494
+ void refreshing
495
+ .then(async (p) => {
496
+ await capsSettledAt(base);
497
+ applyProjectionIfCurrent(generation, p);
498
+ })
499
+ .catch(() => { });
500
+ return true;
489
501
  }
490
502
  export function taskAgentsField() {
491
- const current = payload;
492
- if (preparedPromise && capsVerdict !== false && activeProjector) {
493
- const generation = preparedPromise;
494
- let refreshing;
495
- try {
496
- refreshing = activeProjector();
497
- }
498
- catch {
499
- return current ? { agents: current } : {};
500
- }
501
- void refreshing
502
- .then(async (p) => {
503
- await capsSettled();
504
- applyProjectionIfCurrent(generation, p);
505
- })
506
- .catch(() => { });
503
+ const base = preparedKey;
504
+ if (capsVerdictAt(base) === false) {
505
+ payload = undefined;
506
+ return {};
507
507
  }
508
+ const current = payload;
509
+ kickTaskAgentsRefresh();
508
510
  return current ? { agents: current } : {};
509
511
  }
510
512
  export function _resetAgentsWireForTest() {
511
513
  activeProjector = null;
512
514
  preparedKey = null;
515
+ preparedCapsGen = null;
513
516
  preparedPromise = null;
514
- settleGeneration = null;
517
+ currentGeneration = null;
515
518
  payload = undefined;
516
- capsVerdict = undefined;
517
519
  emittedWarnings.clear();
518
520
  }
@@ -9,9 +9,5 @@ export type ApprovalDecidedByReading = {
9
9
  value: true;
10
10
  };
11
11
  export declare function projectApprovalDecidedByCapability(caps: unknown): ApprovalDecidedByReading | undefined;
12
- export declare function noteEngineCapsForApprovalDecidedBy(baseUrl: string, caps: unknown, opts?: {
13
- generation?: number;
14
- }): void;
15
12
  export declare function observedApprovalDecidedBy(baseUrl?: string | undefined): ApprovalDecidedByReading;
16
13
  export declare function approvalDecidedByAdmitted(reading: ApprovalDecidedByReading | undefined): boolean;
17
- export declare function __resetApprovalDecidedByReadingsForTests(): void;
@@ -18,9 +18,6 @@ const reader = createEngineCapReader({
18
18
  name: 'approvalDecidedBy',
19
19
  project: projectApprovalDecidedByCapability,
20
20
  });
21
- export function noteEngineCapsForApprovalDecidedBy(baseUrl, caps, opts) {
22
- reader.note(baseUrl, caps, opts);
23
- }
24
21
  export function observedApprovalDecidedBy(baseUrl = engineWireTarget()?.baseUrl) {
25
22
  return reader.observed(baseUrl);
26
23
  }
@@ -36,6 +33,3 @@ export function approvalDecidedByAdmitted(reading) {
36
33
  return false;
37
34
  }
38
35
  }
39
- export function __resetApprovalDecidedByReadingsForTests() {
40
- reader.__resetForTests();
41
- }
@@ -9,10 +9,6 @@ export type ApprovalsStreamLiveReading = {
9
9
  live: boolean;
10
10
  };
11
11
  export declare function projectApprovalsStreamLiveCapability(caps: unknown): ApprovalsStreamLiveReading | undefined;
12
- export declare function noteEngineCapsForApprovalsStreamLive(baseUrl: string, caps: unknown, opts?: {
13
- generation?: number;
14
- }): void;
15
12
  export declare function observedApprovalsStreamLive(baseUrl?: string | undefined): ApprovalsStreamLiveReading;
16
13
  export declare function livePendingNeedsReconcile(reading: ApprovalsStreamLiveReading): boolean;
17
14
  export declare function approvalsStreamLiveDoctorDetail(reading: ApprovalsStreamLiveReading): string;
18
- export declare function __resetApprovalsStreamLiveReadingsForTests(): void;
@@ -22,9 +22,6 @@ const reader = createEngineCapReader({
22
22
  name: 'approvalsStreamLive',
23
23
  project: projectApprovalsStreamLiveCapability,
24
24
  });
25
- export function noteEngineCapsForApprovalsStreamLive(baseUrl, caps, opts) {
26
- reader.note(baseUrl, caps, opts);
27
- }
28
25
  export function observedApprovalsStreamLive(baseUrl = engineWireTarget()?.baseUrl) {
29
26
  return reader.observed(baseUrl);
30
27
  }
@@ -45,6 +42,3 @@ export function approvalsStreamLiveDoctorDetail(reading) {
45
42
  : 'live approval push off on this deployment (no checkpoint store or tool approvals disabled; the engine reports one bit for both, so this client cannot tell which) — suspended asks are only visible through the reconcile cadence, so the client polls for them';
46
43
  }
47
44
  }
48
- export function __resetApprovalsStreamLiveReadingsForTests() {
49
- reader.__resetForTests();
50
- }
@@ -0,0 +1,34 @@
1
+ import type { AgentClient } from '@sema-agent/sdk';
2
+ export type AssistantInboxVerb = Pick<AgentClient['assistant'], 'inbox'>;
3
+ export interface AssistantInboxEntry {
4
+ readonly sessionId: string;
5
+ readonly scope?: string;
6
+ readonly gateKind?: string;
7
+ readonly severity?: 1 | 2 | 3 | 4 | 5;
8
+ readonly spentMicroUsd?: number;
9
+ readonly deadlineMs?: number;
10
+ readonly createdAtMs?: number;
11
+ readonly objective?: string;
12
+ readonly inputPreview?: string;
13
+ readonly requiresRealApproval?: true;
14
+ readonly mandated?: true;
15
+ readonly hasBidiControls?: true;
16
+ }
17
+ export type AssistantInboxUnavailableReason = 'unauthorized' | 'unreadable' | 'failed';
18
+ export type AssistantInboxReading = {
19
+ readonly kind: 'present';
20
+ readonly entries: readonly AssistantInboxEntry[];
21
+ readonly dropped: number;
22
+ } | {
23
+ readonly kind: 'unavailable';
24
+ readonly reason: AssistantInboxUnavailableReason;
25
+ readonly status?: number;
26
+ readonly errorCode?: string;
27
+ } | {
28
+ readonly kind: 'not-reported';
29
+ readonly via: 'lane-absent' | 'unarmed';
30
+ };
31
+ export declare function isAssistantLaneAbsent(err: {} | null | undefined): boolean;
32
+ export declare function readAssistantInbox(assistant: AssistantInboxVerb | null | undefined, opts?: {
33
+ readonly signal?: AbortSignal | undefined;
34
+ }): Promise<AssistantInboxReading>;