@sema-agent/client-core 0.99.0 → 0.101.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 (374) hide show
  1. package/CHANGELOG.md +572 -0
  2. package/README.md +174 -114
  3. package/dist/adapt/arms.js +109 -50
  4. package/dist/adapt/panelTasks.d.ts +2 -1
  5. package/dist/adapt/panelTasks.js +32 -9
  6. package/dist/adapt/textStream.d.ts +1 -1
  7. package/dist/adapt/textStream.js +58 -32
  8. package/dist/adapt/toolCards.js +9 -8
  9. package/dist/adapt.js +7 -1
  10. package/dist/adapter/activeRunSelfHeal.d.ts +31 -2
  11. package/dist/adapter/activeRunSelfHeal.js +162 -13
  12. package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
  13. package/dist/adapter/downstream/eventToSdkMessage.js +157 -20
  14. package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
  15. package/dist/adapter/downstream/terminalToSdkResult.js +219 -39
  16. package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
  17. package/dist/adapter/downstream/wiringManifestView.js +1 -0
  18. package/dist/adapter/runStream.d.ts +4 -4
  19. package/dist/adapter/runStream.js +184 -42
  20. package/dist/adapter/types.d.ts +2 -0
  21. package/dist/agentsWireCaps.d.ts +9 -7
  22. package/dist/agentsWireCaps.js +101 -17
  23. package/dist/approvalDecidedByCapability.js +2 -2
  24. package/dist/approvalFrameFamilies.d.ts +33 -0
  25. package/dist/approvalFrameFamilies.js +120 -0
  26. package/dist/approvalsStreamLiveCapability.js +2 -2
  27. package/dist/attachmentsWireCaps.js +41 -13
  28. package/dist/callerCwdCapability.js +2 -2
  29. package/dist/centerWiringCapability.js +2 -2
  30. package/dist/clockReading.d.ts +2 -0
  31. package/dist/clockReading.js +4 -0
  32. package/dist/cloudConfigWireCaps.d.ts +28 -5
  33. package/dist/cloudConfigWireCaps.js +334 -103
  34. package/dist/compactionStatus.d.ts +34 -0
  35. package/dist/compactionStatus.js +196 -0
  36. package/dist/coreValuePorts.d.ts +12 -2
  37. package/dist/coreValuePorts.js +9 -0
  38. package/dist/decideFailureNote.js +8 -6
  39. package/dist/decideReceipt.js +2 -2
  40. package/dist/deviceExecutorManagementCapability.js +2 -2
  41. package/dist/deviceFlowPolling.js +1 -1
  42. package/dist/disableSkillsWire.d.ts +1 -1
  43. package/dist/disableSkillsWire.js +4 -3
  44. package/dist/displayUntrusted.d.ts +1 -0
  45. package/dist/displayUntrusted.js +215 -13
  46. package/dist/engineAgentPanelStore.d.ts +7 -4
  47. package/dist/engineCapReader.js +1 -1
  48. package/dist/engineConfigDrift.js +1 -1
  49. package/dist/engineErrorCodes.d.ts +23 -6
  50. package/dist/engineErrorCodes.js +36 -11
  51. package/dist/engineGenerationConvergence.d.ts +39 -0
  52. package/dist/engineGenerationConvergence.js +95 -0
  53. package/dist/engineGenerationPort.d.ts +61 -0
  54. package/dist/engineGenerationPort.js +144 -0
  55. package/dist/engineHealthFacts.d.ts +23 -0
  56. package/dist/engineHealthFacts.js +92 -0
  57. package/dist/engineIdentity.d.ts +4 -0
  58. package/dist/engineIdentity.js +11 -0
  59. package/dist/engineNoticeCodes.d.ts +2 -5
  60. package/dist/engineRowRef.js +4 -0
  61. package/dist/engineSessionMessages.js +2 -2
  62. package/dist/engineToolDirectory.d.ts +3 -0
  63. package/dist/engineToolDirectory.js +6 -4
  64. package/dist/engineWireFor.d.ts +99 -0
  65. package/dist/engineWireFor.js +248 -6
  66. package/dist/engineWireTarget.d.ts +1 -0
  67. package/dist/engineWireTarget.js +8 -0
  68. package/dist/env/uiLanguage.js +1 -1
  69. package/dist/errorSupplementRoles.d.ts +3 -0
  70. package/dist/errorSupplementRoles.js +37 -0
  71. package/dist/eventLeg.d.ts +1 -7
  72. package/dist/eventLeg.js +7 -8
  73. package/dist/executionLaneCapability.js +2 -2
  74. package/dist/fileHistoryCaptureCapability.d.ts +0 -3
  75. package/dist/fileHistoryCaptureCapability.js +3 -7
  76. package/dist/finalVerifyWire.d.ts +6 -3
  77. package/dist/finalVerifyWire.js +6 -23
  78. package/dist/flagInput.d.ts +4 -0
  79. package/dist/flagInput.js +24 -0
  80. package/dist/fleet/fleetLedger.js +5 -2
  81. package/dist/fleet/fleetProjection.d.ts +1 -0
  82. package/dist/fleet/fleetProjection.js +15 -2
  83. package/dist/gateVocabulary.js +3 -0
  84. package/dist/generated/engineFactTables.d.ts +7 -2
  85. package/dist/generated/engineFactTables.js +79 -0
  86. package/dist/generated/engineNoticeTables.js +15 -0
  87. package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
  88. package/dist/generated/settingsSchemaActiveTiers.js +14 -0
  89. package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
  90. package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
  91. package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
  92. package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
  93. package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
  94. package/dist/generated/settingsSchemaDefaultModel.js +25 -0
  95. package/dist/generated/settingsSchemaFns.d.ts +66 -0
  96. package/dist/generated/settingsSchemaFns.js +38 -0
  97. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
  98. package/dist/generated/settingsSchemaMcpRequestEntry.js +156 -0
  99. package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
  100. package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
  101. package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
  102. package/dist/generated/settingsSchemaSettingsSources.js +58 -0
  103. package/dist/generated/settingsSchemaTables.d.ts +3 -0
  104. package/dist/generated/settingsSchemaTables.js +18 -0
  105. package/dist/generated/settingsSchemaTypes.d.ts +28 -0
  106. package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
  107. package/dist/generated/settingsSchemaUrlPattern.js +183 -0
  108. package/dist/headlessPermissionModeWire.d.ts +18 -2
  109. package/dist/headlessPermissionModeWire.js +30 -19
  110. package/dist/hitl/allowRuleShadow.js +9 -7
  111. package/dist/hitl/approvalCardReading.d.ts +3 -0
  112. package/dist/hitl/approvalCardReading.js +17 -0
  113. package/dist/hitl/approvalCardReasons.js +2 -2
  114. package/dist/hitl/approvalCompleteParked.js +1 -1
  115. package/dist/hitl/approvalDelivery.d.ts +87 -0
  116. package/dist/hitl/approvalDelivery.js +193 -0
  117. package/dist/hitl/approvalHolds.d.ts +14 -0
  118. package/dist/hitl/approvalHolds.js +41 -0
  119. package/dist/hitl/approvalResolution.d.ts +11 -0
  120. package/dist/hitl/approvalResolution.js +50 -11
  121. package/dist/hitl/askClassPair.d.ts +8 -2
  122. package/dist/hitl/askClassPair.js +31 -4
  123. package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
  124. package/dist/hitl/askParkAutoReopenBlock.js +117 -0
  125. package/dist/hitl/askParkRowRouting.js +4 -1
  126. package/dist/hitl/attributionLadder.d.ts +62 -0
  127. package/dist/hitl/attributionLadder.js +138 -0
  128. package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
  129. package/dist/hitl/automaticAnswerVerdict.js +46 -11
  130. package/dist/hitl/crashConverged.js +2 -2
  131. package/dist/hitl/decisionConflict.d.ts +6 -2
  132. package/dist/hitl/decisionConflict.js +24 -9
  133. package/dist/hitl/decisionLedger.d.ts +55 -0
  134. package/dist/hitl/decisionLedger.js +156 -0
  135. package/dist/hitl/decisionRefusal.d.ts +21 -10
  136. package/dist/hitl/decisionRefusal.js +100 -55
  137. package/dist/hitl/decisionSend.d.ts +116 -0
  138. package/dist/hitl/decisionSend.js +563 -0
  139. package/dist/hitl/frameRouter.d.ts +1 -0
  140. package/dist/hitl/frameRouter.js +9 -2
  141. package/dist/hitl/hitlBridge.d.ts +18 -6
  142. package/dist/hitl/hitlBridge.js +59 -43
  143. package/dist/hitl/livePendingAsk.js +4 -3
  144. package/dist/hitl/noAllowCause.js +1 -1
  145. package/dist/hitl/parkResolver.js +3 -2
  146. package/dist/hitl/persistedRulesWire.js +1 -0
  147. package/dist/hitl/planReviewWire.d.ts +4 -0
  148. package/dist/hitl/planReviewWire.js +104 -106
  149. package/dist/hitl/resumeRunningCard.d.ts +3 -2
  150. package/dist/hitl/resumeRunningCard.js +17 -11
  151. package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
  152. package/dist/hitl/sessionPolicyDeliverable.js +65 -35
  153. package/dist/hitl/sessionPolicyWire.d.ts +13 -3
  154. package/dist/hitl/sessionPolicyWire.js +81 -16
  155. package/dist/hitl/standingRows.js +1 -1
  156. package/dist/hitl/toolApprovalWire.d.ts +9 -10
  157. package/dist/hitl/toolApprovalWire.js +103 -151
  158. package/dist/hookMatcherVerdict.d.ts +2 -0
  159. package/dist/hookMatcherVerdict.js +12 -0
  160. package/dist/hooksCompactTransition.d.ts +19 -0
  161. package/dist/hooksCompactTransition.js +41 -0
  162. package/dist/hooksWireCaps.d.ts +1 -1
  163. package/dist/hooksWireCaps.js +202 -203
  164. package/dist/host.d.ts +1 -14
  165. package/dist/host.js +0 -8
  166. package/dist/hostCallbackGuard.d.ts +1 -0
  167. package/dist/hostCallbackGuard.js +1 -1
  168. package/dist/hostSettingsSource.d.ts +172 -0
  169. package/dist/hostSettingsSource.js +675 -0
  170. package/dist/hostTurnSettings.d.ts +114 -19
  171. package/dist/hostTurnSettings.js +966 -68
  172. package/dist/httpHookPolicy.d.ts +37 -0
  173. package/dist/httpHookPolicy.js +176 -0
  174. package/dist/humanTurn.d.ts +4 -2
  175. package/dist/humanTurn.js +40 -10
  176. package/dist/humanTurnRead.js +4 -3
  177. package/dist/humanTurnSentences.d.ts +10 -0
  178. package/dist/humanTurnSentences.js +74 -0
  179. package/dist/i18n/messages.en.d.ts +313 -0
  180. package/dist/i18n/messages.en.js +326 -13
  181. package/dist/i18n/messages.zh.js +341 -13
  182. package/dist/i18n/translate.js +3 -3
  183. package/dist/index.d.ts +85 -15
  184. package/dist/index.js +53 -12
  185. package/dist/inheritEnvCapability.d.ts +4 -1
  186. package/dist/inheritEnvCapability.js +38 -17
  187. package/dist/inheritEnvWire.d.ts +2 -1
  188. package/dist/inheritEnvWire.js +11 -5
  189. package/dist/injectionLaneNotice.d.ts +5 -0
  190. package/dist/injectionLaneNotice.js +46 -0
  191. package/dist/interactiveToolsWire.d.ts +4 -2
  192. package/dist/interactiveToolsWire.js +5 -5
  193. package/dist/jsonFaithful.d.ts +20 -0
  194. package/dist/jsonFaithful.js +152 -0
  195. package/dist/limitsWire.d.ts +7 -2
  196. package/dist/limitsWire.js +19 -13
  197. package/dist/liveInitToolFace.d.ts +6 -1
  198. package/dist/liveInitToolFace.js +5 -3
  199. package/dist/liveModelCatalog.d.ts +22 -0
  200. package/dist/liveModelCatalog.js +132 -18
  201. package/dist/mcpPanel.js +3 -1
  202. package/dist/mcpProbeCapability.js +2 -2
  203. package/dist/mcpReconnect.js +2 -2
  204. package/dist/mcpStatusSupersetKeys.d.ts +24 -0
  205. package/dist/mcpStatusSupersetKeys.js +45 -0
  206. package/dist/mcpToolToggles.d.ts +6 -0
  207. package/dist/mcpToolToggles.js +47 -0
  208. package/dist/mcpWireCaps.d.ts +48 -4
  209. package/dist/mcpWireCaps.js +338 -99
  210. package/dist/mcpWireTransport.d.ts +4 -0
  211. package/dist/mcpWireTransport.js +18 -0
  212. package/dist/memoryComplianceCapability.js +2 -2
  213. package/dist/memoryOriginCapability.js +2 -2
  214. package/dist/model/catalogDefault.d.ts +24 -0
  215. package/dist/model/catalogDefault.js +4 -0
  216. package/dist/model/liveCatalogShape.js +5 -4
  217. package/dist/model/modelsPolicy.js +4 -3
  218. package/dist/model/onboardJudgement.d.ts +1 -0
  219. package/dist/model/onboardJudgement.js +1 -1
  220. package/dist/model/subagentModelWord.js +2 -2
  221. package/dist/modelCapabilityProbe.d.ts +2 -1
  222. package/dist/modelCapabilityProbe.js +16 -15
  223. package/dist/modelIdentityResolvability.d.ts +12 -1
  224. package/dist/modelIdentityResolvability.js +69 -28
  225. package/dist/modsKernelIdentity.d.ts +10 -0
  226. package/dist/modsKernelIdentity.js +103 -0
  227. package/dist/modsKernelTransit.d.ts +8 -0
  228. package/dist/modsKernelTransit.js +6 -0
  229. package/dist/notifications.d.ts +30 -12
  230. package/dist/notifications.js +241 -53
  231. package/dist/outputStyleSeatCapability.js +2 -2
  232. package/dist/ownKey.d.ts +37 -0
  233. package/dist/ownKey.js +238 -2
  234. package/dist/panelReduce.d.ts +5 -0
  235. package/dist/panelReduce.js +45 -13
  236. package/dist/panelStateHolder.d.ts +1 -0
  237. package/dist/panelStateHolder.js +10 -1
  238. package/dist/peerFrames.d.ts +1 -1
  239. package/dist/peerFrames.js +6 -2
  240. package/dist/peerLaneCapability.js +2 -2
  241. package/dist/permissionModesCapability.js +4 -4
  242. package/dist/permissionRuleIssue.d.ts +2 -1
  243. package/dist/permissionRuleIssue.js +24 -21
  244. package/dist/permissionRulesWriteCapability.js +2 -2
  245. package/dist/permissionsAllowGrantCapability.js +2 -2
  246. package/dist/permissionsDeclaration.d.ts +43 -4
  247. package/dist/permissionsDeclaration.js +102 -35
  248. package/dist/pluginHooksWire.d.ts +20 -4
  249. package/dist/pluginHooksWire.js +101 -60
  250. package/dist/prepareRefusal.d.ts +9 -0
  251. package/dist/prepareRefusal.js +90 -0
  252. package/dist/printInitToolFace.js +2 -2
  253. package/dist/printModelStatus.js +1 -1
  254. package/dist/projectMemory.d.ts +32 -0
  255. package/dist/projectMemory.js +70 -0
  256. package/dist/promptBlockedCopy.d.ts +2 -1
  257. package/dist/promptBlockedCopy.js +2 -1
  258. package/dist/promptDelivery.d.ts +23 -3
  259. package/dist/promptDelivery.js +169 -30
  260. package/dist/providerRejection.d.ts +19 -1
  261. package/dist/providerRejection.js +75 -4
  262. package/dist/queuedDelivery.d.ts +48 -0
  263. package/dist/queuedDelivery.js +233 -0
  264. package/dist/reattachWindow.d.ts +94 -0
  265. package/dist/reattachWindow.js +127 -0
  266. package/dist/request/printNotification.d.ts +1 -1
  267. package/dist/request/printNotification.js +5 -1
  268. package/dist/request/submissionIdentity.d.ts +37 -0
  269. package/dist/request/submissionIdentity.js +65 -0
  270. package/dist/request/taskRequest.d.ts +22 -14
  271. package/dist/request/taskRequest.js +312 -202
  272. package/dist/resultFrameKeys.d.ts +1 -0
  273. package/dist/resultFrameKeys.js +4 -1
  274. package/dist/resumeRefusalCopy.d.ts +3 -1
  275. package/dist/resumeRefusalCopy.js +22 -4
  276. package/dist/retryStatus.d.ts +26 -0
  277. package/dist/retryStatus.js +133 -28
  278. package/dist/rewindArchiveCapability.js +2 -2
  279. package/dist/rewindEngineAction.d.ts +2 -0
  280. package/dist/rewindEngineAction.js +23 -1
  281. package/dist/rowKind.d.ts +36 -0
  282. package/dist/rowKind.js +97 -0
  283. package/dist/ruleCompileVerdict.d.ts +18 -0
  284. package/dist/ruleCompileVerdict.js +67 -2
  285. package/dist/ruleReadings.d.ts +58 -0
  286. package/dist/ruleReadings.js +132 -0
  287. package/dist/ruleRefusalSentence.d.ts +8 -0
  288. package/dist/ruleRefusalSentence.js +64 -0
  289. package/dist/runCancelContext.d.ts +0 -1
  290. package/dist/runCancelContext.js +1 -2
  291. package/dist/runTerminal.d.ts +5 -0
  292. package/dist/runTerminal.js +52 -17
  293. package/dist/sandboxWire.d.ts +3 -2
  294. package/dist/sandboxWire.js +59 -27
  295. package/dist/scenarioRefusal.d.ts +2 -1
  296. package/dist/scenarioRefusal.js +6 -6
  297. package/dist/scenarioSkills.d.ts +20 -0
  298. package/dist/scenarioSkills.js +72 -0
  299. package/dist/scenarioWire.d.ts +5 -2
  300. package/dist/scenarioWire.js +9 -9
  301. package/dist/sealedKeyCapability.js +2 -2
  302. package/dist/seam.d.ts +26 -9
  303. package/dist/seam.js +44 -4
  304. package/dist/seatContract.d.ts +62 -9
  305. package/dist/seatContract.js +70 -25
  306. package/dist/selfOrchestrationDenial.js +1 -1
  307. package/dist/sessionPolicyCapability.js +2 -2
  308. package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
  309. package/dist/sessionRulesChildrenReadLive.js +5 -0
  310. package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
  311. package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
  312. package/dist/sessionSyncFileHistoryCapability.js +2 -2
  313. package/dist/settingsCredentialKeyPaths.d.ts +8 -0
  314. package/dist/settingsCredentialKeyPaths.js +274 -0
  315. package/dist/settingsHooksSalvage.d.ts +1 -0
  316. package/dist/settingsHooksSalvage.js +7 -1
  317. package/dist/settingsLayerAdmission.d.ts +4 -0
  318. package/dist/settingsLayerAdmission.js +16 -0
  319. package/dist/skillToolListsCapability.js +6 -5
  320. package/dist/skillsWireCaps.d.ts +14 -3
  321. package/dist/skillsWireCaps.js +48 -18
  322. package/dist/slashCommandGate.d.ts +24 -0
  323. package/dist/slashCommandGate.js +74 -0
  324. package/dist/slashCommandTable.d.ts +14 -0
  325. package/dist/slashCommandTable.js +99 -0
  326. package/dist/sqlEngineCapability.js +2 -2
  327. package/dist/steerPriorityCapability.js +2 -2
  328. package/dist/storePostureCapability.js +2 -2
  329. package/dist/subagent/agentStateDetail.js +1 -1
  330. package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
  331. package/dist/subagent/engineDelegatedPrompt.js +38 -7
  332. package/dist/subagent/engineRowStopGate.js +2 -2
  333. package/dist/subagent/engineSubagentResume.js +3 -3
  334. package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
  335. package/dist/subagent/engineTaskHandleWire.js +10 -0
  336. package/dist/subagentContentStore.d.ts +1 -0
  337. package/dist/subagentContentStore.js +135 -27
  338. package/dist/submitFailure.d.ts +8 -0
  339. package/dist/submitFailure.js +17 -0
  340. package/dist/supportFloor.d.ts +1 -0
  341. package/dist/supportFloor.js +7 -0
  342. package/dist/terminationIntent.d.ts +55 -0
  343. package/dist/terminationIntent.js +352 -0
  344. package/dist/toolHistoryMismatch.d.ts +8 -0
  345. package/dist/toolHistoryMismatch.js +37 -6
  346. package/dist/toolResult.d.ts +13 -3
  347. package/dist/toolResult.js +158 -9
  348. package/dist/toolResultContent.d.ts +13 -0
  349. package/dist/toolResultContent.js +82 -7
  350. package/dist/toolRoster.d.ts +18 -0
  351. package/dist/toolRoster.js +64 -0
  352. package/dist/toolsFlagNames.d.ts +8 -0
  353. package/dist/toolsFlagNames.js +110 -0
  354. package/dist/turnFailurePresentation.js +41 -96
  355. package/dist/usageLimitAutoResume.d.ts +74 -0
  356. package/dist/usageLimitAutoResume.js +227 -0
  357. package/dist/userAttachmentEnvelope.js +1 -1
  358. package/dist/userAttachmentSeat.js +5 -5
  359. package/dist/userInvokedSkillsCapability.js +2 -2
  360. package/dist/webSearchBackendCapability.js +2 -2
  361. package/dist/wireErrorTriage.js +99 -50
  362. package/dist/wireFailureShape.d.ts +25 -1
  363. package/dist/wireFailureShape.js +92 -5
  364. package/dist/wireRefusalCopy.d.ts +75 -18
  365. package/dist/wireRefusalCopy.js +532 -148
  366. package/dist/wiringFleetDoctor.d.ts +3 -0
  367. package/dist/wiringFleetDoctor.js +21 -0
  368. package/dist/workflow.d.ts +2 -1
  369. package/dist/workflow.js +38 -1
  370. package/dist/workflowClient.d.ts +2 -7
  371. package/dist/workflowsJournalCapability.js +2 -2
  372. package/dist/writeProtectionCapability.js +2 -2
  373. package/docs/INTEGRATION-CLIENTS.md +1013 -190
  374. package/package.json +15 -4
@@ -4,7 +4,8 @@ import { parseWorkflowPollEnvelope, projectWorkflowTaskOutput } from './workflow
4
4
  import { asModelFallbackReason } from './engineErrorCodes.js';
5
5
  import { frozenSet } from './frozenSet.js';
6
6
  import { bashExitOf, bashExitReadingFailed } from './bashExitReading.js';
7
- import { readFrameTrueMark, readFrameTrueMarkReading } from './ownKey.js';
7
+ import { guardedRead, ownSnapshotWhenTyped, readFrameTrueMark, readFrameTrueMarkReading, readOwnDataFiniteNumber, readOwnDataNonEmptyString, readOwnDataValue, } from './ownKey.js';
8
+ import { displayUntrusted } from './displayUntrusted.js';
8
9
  import { isCoreSemaTaskTerminal } from './terminalStatuses.js';
9
10
  import { CORE_ENGINE_CARD_TYPES } from './generated/engineFactTables.js';
10
11
  export const STRUCTURED_DETAIL_TYPES = frozenSet(CORE_ENGINE_CARD_TYPES);
@@ -356,7 +357,8 @@ const killedBySignalSentence = (killCauseOf) => {
356
357
  }
357
358
  return TOOL_KILL_TEXT[isToolKillCause(cause) ? cause : 'unknown'];
358
359
  };
359
- export function wireOutputToBody(toolName, output, isError, truncated, flatten, structured, leaderLedger = true, killCauseOf) {
360
+ export function wireOutputToBody(toolName, output, isError, truncated, flatten, structuredIn, leaderLedger = true, killCauseOf) {
361
+ const structured = ownSnapshotWhenTyped(structuredIn, 'task-output');
360
362
  const text = flatten(output);
361
363
  const name = (toolName || '').toLowerCase();
362
364
  const sType = structuredDetailType(structured);
@@ -473,9 +475,12 @@ export function wireOutputToBody(toolName, output, isError, truncated, flatten,
473
475
  return { content: truncated ? `${text}\n…(truncated)` : text, isError };
474
476
  }
475
477
  export function structuredToToolUseResult(structured, modelText, leaderLedger = true) {
476
- if (typeof structured !== 'object' || structured === null)
478
+ const sampled = ownSnapshotWhenTyped(structured, 'task-output');
479
+ if (typeof sampled !== 'object' || sampled === null)
477
480
  return null;
478
- const s = structured;
481
+ const s = sampled;
482
+ if (guardedRead(() => readOwnDataValue(s, 'type')) === 'web-search')
483
+ return webSearchToolUseResult(s);
479
484
  for (const k of ['originalFile', 'content', 'stdout', 'stderr']) {
480
485
  if (typeof s[k] === 'string' && s[k].length > MAX_STRUCTURED_FIELD_CHARS)
481
486
  return null;
@@ -748,6 +753,7 @@ export function structuredToToolUseResult(structured, modelText, leaderLedger =
748
753
  : (parsed?.status ?? (engineSaidNotReady ? 'running' : 'unknown'));
749
754
  const bodyText = hasContent ? s.content : parsed && parsed.kind !== 'unknown' ? parsed.output : undefined;
750
755
  const error = typeof s.error === 'string' ? s.error : undefined;
756
+ const completionId = terminalCardCompletionIdOf(s, engineSaidNotReady);
751
757
  if (taskType === 'background_bash') {
752
758
  const exitCode = typeof inner?.exitCode === 'number' ? inner.exitCode : undefined;
753
759
  return {
@@ -761,6 +767,7 @@ export function structuredToToolUseResult(structured, modelText, leaderLedger =
761
767
  output: bodyText ?? '',
762
768
  ...(exitCode !== undefined ? { exitCode } : {}),
763
769
  ...(error !== undefined ? { error } : {}),
770
+ ...(completionId !== undefined ? { _sema_completion_id: completionId } : {}),
764
771
  },
765
772
  },
766
773
  };
@@ -777,6 +784,7 @@ export function structuredToToolUseResult(structured, modelText, leaderLedger =
777
784
  output: bodyText ?? '',
778
785
  result: bodyText ?? '',
779
786
  ...(error !== undefined ? { error } : {}),
787
+ ...(completionId !== undefined ? { _sema_completion_id: completionId } : {}),
780
788
  },
781
789
  },
782
790
  };
@@ -801,6 +809,7 @@ export function structuredToToolUseResult(structured, modelText, leaderLedger =
801
809
  output,
802
810
  ...(error !== undefined ? { error } : {}),
803
811
  ...(runErrorCode !== undefined ? { _sema_error_code: runErrorCode } : {}),
812
+ ...(completionId !== undefined ? { _sema_completion_id: completionId } : {}),
804
813
  },
805
814
  },
806
815
  };
@@ -809,7 +818,143 @@ export function structuredToToolUseResult(structured, modelText, leaderLedger =
809
818
  return null;
810
819
  }
811
820
  }
812
- export function detectEngineBgShellReceipt(toolName, rawInput, outputText, structured) {
821
+ const WEB_SEARCH_ENTRIES_MAX = 1024;
822
+ const WEB_SEARCH_HITS_MAX = 4096;
823
+ const WEB_SEARCH_FIELD_CHARS_MAX = 8192;
824
+ function isArrayLength(n) {
825
+ return Number.isInteger(n) && n >= 0 && n <= 4_294_967_295;
826
+ }
827
+ function isWebSearchRecord(v) {
828
+ return typeof v === 'object' && v !== null && guardedRead(() => !Array.isArray(v)) === true;
829
+ }
830
+ function readWebSearchHit(raw) {
831
+ if (!isWebSearchRecord(raw))
832
+ return undefined;
833
+ const title = readOwnDataValue(raw, 'title');
834
+ const url = readOwnDataValue(raw, 'url');
835
+ if (typeof title !== 'string' || typeof url !== 'string' || url === '')
836
+ return undefined;
837
+ if (title.length > WEB_SEARCH_FIELD_CHARS_MAX || url.length > WEB_SEARCH_FIELD_CHARS_MAX)
838
+ return undefined;
839
+ return { title, url };
840
+ }
841
+ function readWebSearchEntry(raw, hitBudget) {
842
+ if (!isWebSearchRecord(raw))
843
+ return undefined;
844
+ const toolUseId = readOwnDataValue(raw, 'tool_use_id');
845
+ const content = readOwnDataValue(raw, 'content');
846
+ if (typeof toolUseId !== 'string' || typeof content !== 'object' || content === null || !Array.isArray(content))
847
+ return undefined;
848
+ const n = readOwnDataFiniteNumber(content, 'length');
849
+ if (n === undefined || !isArrayLength(n))
850
+ return undefined;
851
+ const limit = Math.min(n, Math.max(0, hitBudget));
852
+ const hits = [];
853
+ let dropped = n - limit;
854
+ for (let j = 0; j < limit; j++) {
855
+ const hit = guardedRead(() => readWebSearchHit(readOwnDataValue(content, String(j))));
856
+ if (hit === undefined)
857
+ dropped++;
858
+ else
859
+ hits.push(hit);
860
+ }
861
+ return { entry: { tool_use_id: toolUseId, content: hits }, visited: limit, dropped };
862
+ }
863
+ function readWebSearchEntries(card) {
864
+ const results = guardedRead(() => readOwnDataValue(card, 'results'));
865
+ if (typeof results !== 'object' || results === null || guardedRead(() => Array.isArray(results)) !== true)
866
+ return undefined;
867
+ const length = guardedRead(() => readOwnDataFiniteNumber(results, 'length'));
868
+ if (length === undefined || !isArrayLength(length))
869
+ return undefined;
870
+ const entries = [];
871
+ let dropped = Math.max(0, length - WEB_SEARCH_ENTRIES_MAX);
872
+ let hitsLeft = WEB_SEARCH_HITS_MAX;
873
+ for (let i = 0; i < Math.min(length, WEB_SEARCH_ENTRIES_MAX); i++) {
874
+ const raw = guardedRead(() => readOwnDataValue(results, String(i)));
875
+ if (typeof raw === 'string') {
876
+ entries.push(raw);
877
+ continue;
878
+ }
879
+ const one = guardedRead(() => readWebSearchEntry(raw, hitsLeft));
880
+ if (one === undefined) {
881
+ dropped++;
882
+ continue;
883
+ }
884
+ entries.push(one.entry);
885
+ hitsLeft -= one.visited;
886
+ dropped += one.dropped;
887
+ }
888
+ const usable = entries.some(e => typeof e !== 'string' && e.content.length > 0);
889
+ if (dropped > 0 && !usable)
890
+ return undefined;
891
+ return { entries, dropped };
892
+ }
893
+ function webSearchToolUseResult(card) {
894
+ try {
895
+ const query = readOwnDataValue(card, 'query');
896
+ const durationSeconds = readOwnDataFiniteNumber(card, 'durationSeconds');
897
+ if (typeof query !== 'string' || durationSeconds === undefined || durationSeconds < 0)
898
+ return null;
899
+ const read = readWebSearchEntries(card);
900
+ if (read === undefined)
901
+ return null;
902
+ const searchCount = readOwnDataFiniteNumber(card, 'searchCount');
903
+ return {
904
+ toolUseResult: {
905
+ query,
906
+ results: read.entries.map(e => (typeof e === 'string' ? e : { tool_use_id: e.tool_use_id, content: e.content.map(h => ({ title: h.title, url: h.url })) })),
907
+ durationSeconds,
908
+ ...(searchCount !== undefined && Number.isInteger(searchCount) && searchCount >= 0 ? { searchCount } : {}),
909
+ },
910
+ };
911
+ }
912
+ catch {
913
+ return null;
914
+ }
915
+ }
916
+ export function webSearchSourcesOf(toolEnd) {
917
+ try {
918
+ if (!isWebSearchRecord(toolEnd))
919
+ return undefined;
920
+ const structured = readOwnDataValue(toolEnd, 'structured');
921
+ if (!isWebSearchRecord(structured) || readOwnDataValue(structured, 'type') !== 'web-search')
922
+ return undefined;
923
+ const read = readWebSearchEntries(structured);
924
+ if (read === undefined)
925
+ return undefined;
926
+ let dropped = read.dropped;
927
+ const out = [];
928
+ for (const e of read.entries) {
929
+ if (typeof e === 'string')
930
+ continue;
931
+ for (const h of e.content) {
932
+ const url = guardedRead(() => displayUntrusted(h.url));
933
+ const title = guardedRead(() => displayUntrusted(h.title));
934
+ if (url === undefined || url === '' || title === undefined)
935
+ dropped++;
936
+ else
937
+ out.push(Object.freeze({ title, url }));
938
+ }
939
+ }
940
+ if (out.length === 0 && dropped > 0)
941
+ return undefined;
942
+ Object.defineProperty(out, 'droppedCount', { value: dropped, enumerable: false });
943
+ return Object.freeze(out);
944
+ }
945
+ catch {
946
+ return undefined;
947
+ }
948
+ }
949
+ function terminalCardCompletionIdOf(s, engineSaidNotReady) {
950
+ if (engineSaidNotReady)
951
+ return undefined;
952
+ const status = guardedRead(() => readOwnDataNonEmptyString(s, 'status'));
953
+ if (!isCoreSemaTaskTerminal(status))
954
+ return undefined;
955
+ return guardedRead(() => readOwnDataNonEmptyString(s, 'completionId'));
956
+ }
957
+ export function detectEngineBgShellReceipt(toolName, rawInput, outputText, structured, toolUseId) {
813
958
  if (typeof outputText !== 'string')
814
959
  return null;
815
960
  const input = (rawInput ?? {});
@@ -832,28 +977,30 @@ export function detectEngineBgShellReceipt(toolName, rawInput, outputText, struc
832
977
  }
833
978
  if (!m?.[1])
834
979
  return null;
835
- return engineBgShellRegistrationBody(m[1], input, outputText, source);
980
+ return engineBgShellRegistrationBody(m[1], input, outputText, source, toolUseId, undefined);
836
981
  }
837
- function engineBgShellRegistrationBody(taskId, rawInput, receipt, source) {
982
+ function engineBgShellRegistrationBody(taskId, rawInput, receipt, source, toolUseId, outputFile) {
838
983
  const input = (rawInput ?? {});
839
984
  const command = typeof input.command === 'string' ? input.command : '(engine bash)';
840
985
  const description = typeof input.description === 'string' ? input.description : undefined;
841
986
  return {
842
987
  kind: 'register',
843
988
  taskId,
989
+ ...(typeof toolUseId === 'string' && toolUseId.length > 0 ? { toolUseId } : {}),
844
990
  command,
845
991
  ...(description !== undefined ? { description } : {}),
846
992
  receipt,
993
+ ...(typeof outputFile === 'string' && outputFile.length > 0 ? { outputFile } : {}),
847
994
  source,
848
995
  };
849
996
  }
850
- export function detectEngineBgShellDetach(toolName, rawInput, structured, outputText) {
997
+ export function detectEngineBgShellDetach(toolName, rawInput, structured, outputText, toolUseId) {
851
998
  if (toolName !== 'Bash')
852
999
  return null;
853
1000
  const view = readBashDetachView(structured);
854
1001
  if (view === null || view.registerFailed || view.handoffTaskId === undefined)
855
1002
  return null;
856
- return engineBgShellRegistrationBody(view.handoffTaskId, rawInput, typeof outputText === 'string' ? outputText : '', 'bash');
1003
+ return engineBgShellRegistrationBody(view.handoffTaskId, rawInput, typeof outputText === 'string' ? outputText : '', 'bash', toolUseId, view.outputFile);
857
1004
  }
858
1005
  function readBashDetachView(structured) {
859
1006
  if (typeof structured !== 'object' || structured === null)
@@ -865,9 +1012,11 @@ function readBashDetachView(structured) {
865
1012
  const detached = s.detached;
866
1013
  const registerFailed = s.registerFailed;
867
1014
  const taskId = s.task_id;
1015
+ const outputFile = s.output_file;
868
1016
  return {
869
1017
  handoffTaskId: detached === true && typeof taskId === 'string' && taskId.length > 0 ? taskId : undefined,
870
1018
  registerFailed: registerFailed === true,
1019
+ outputFile: typeof outputFile === 'string' && outputFile.length > 0 ? outputFile : undefined,
871
1020
  };
872
1021
  }
873
1022
  export function todoWriteToolUseResult(rawInput, oldTodos, isError) {
@@ -1,2 +1,15 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ export type ToolOutputMediaAbsence = {
3
+ readonly kind: 'descriptor';
4
+ readonly mediaType: 'image' | 'document';
5
+ readonly mimeType?: string;
6
+ readonly bytes: number;
7
+ } | {
8
+ readonly kind: 'omitted';
9
+ readonly blocks: number;
10
+ readonly bytes: number;
11
+ };
12
+ export declare function toolOutputMediaAbsenceOf(block: object | null | undefined): ToolOutputMediaAbsence | undefined;
13
+ export declare function toolOutputMediaAbsenceSentence(view: ToolOutputMediaAbsence | null | undefined, lang?: UiLanguage): string;
1
14
  export declare function toolResultBlocksOf(output: unknown, truncated: boolean): unknown[] | undefined;
2
15
  export declare function toolEndOutputText(output: unknown): string | undefined;
@@ -1,12 +1,78 @@
1
+ import { msg, renderMessage } from './i18n/translate.js';
2
+ import { readOwnDataValue } from './ownKey.js';
1
3
  const IMAGE_MEDIA_TYPES = Object.freeze(['image/jpeg', 'image/png', 'image/gif', 'image/webp']);
2
4
  const OMITTED_CONTENT_NOTE = '[unsupported content omitted]';
3
5
  const IMAGE_TEXT_PLACEHOLDER = '[image]';
6
+ const ECHOABLE_MIME_TYPE = /^[\x21-\x7e][\x20-\x7e]{0,254}$/;
7
+ function countOf(v, min) {
8
+ return typeof v === 'number' && Number.isSafeInteger(v) && v >= min ? (v === 0 ? 0 : v) : undefined;
9
+ }
10
+ function mimeTypeSlot(o) {
11
+ return Object.hasOwn(o, 'mimeType') ? (readOwnDataValue(o, 'mimeType') ?? null) : undefined;
12
+ }
13
+ function mintAbsence(kind, mediaType, mimeType, blocks, bytes) {
14
+ const size = countOf(bytes, 0);
15
+ if (size === undefined)
16
+ return undefined;
17
+ if (kind === 'omitted') {
18
+ const n = countOf(blocks, 1);
19
+ return n === undefined ? undefined : Object.freeze({ kind: 'omitted', blocks: n, bytes: size });
20
+ }
21
+ if (kind !== 'descriptor' || (mediaType !== 'image' && mediaType !== 'document'))
22
+ return undefined;
23
+ if (mimeType !== undefined && typeof mimeType !== 'string')
24
+ return undefined;
25
+ return Object.freeze(typeof mimeType === 'string' && ECHOABLE_MIME_TYPE.test(mimeType) ? { kind, mediaType, mimeType, bytes: size } : { kind, mediaType, bytes: size });
26
+ }
27
+ export function toolOutputMediaAbsenceOf(block) {
28
+ try {
29
+ if (typeof block !== 'object' || block === null || Array.isArray(block))
30
+ return undefined;
31
+ if (readOwnDataValue(block, 'truncated') !== true)
32
+ return undefined;
33
+ const type = readOwnDataValue(block, 'type');
34
+ const bytes = readOwnDataValue(block, 'bytes');
35
+ if (type === 'omitted')
36
+ return mintAbsence('omitted', undefined, undefined, readOwnDataValue(block, 'blocks'), bytes);
37
+ if (type !== 'image' && type !== 'document')
38
+ return undefined;
39
+ if ('data' in block)
40
+ return undefined;
41
+ return mintAbsence('descriptor', type, mimeTypeSlot(block), undefined, bytes);
42
+ }
43
+ catch {
44
+ return undefined;
45
+ }
46
+ }
47
+ function absenceRefOf(a) {
48
+ if (a.kind === 'omitted') {
49
+ return msg(a.blocks === 1 ? 'session.toolResult.media.notDelivered.omitted.one' : 'session.toolResult.media.notDelivered.omitted.other', { blocks: a.blocks, bytes: a.bytes });
50
+ }
51
+ const kind = msg(a.mediaType === 'image' ? 'session.toolResult.media.kind.image' : 'session.toolResult.media.kind.document');
52
+ return a.mimeType === undefined
53
+ ? msg('session.toolResult.media.notDelivered.descriptorNoMime', { kind, bytes: a.bytes })
54
+ : msg('session.toolResult.media.notDelivered.descriptor', { kind, mimeType: a.mimeType, bytes: a.bytes });
55
+ }
56
+ export function toolOutputMediaAbsenceSentence(view, lang) {
57
+ try {
58
+ if (typeof view !== 'object' || view === null || Array.isArray(view))
59
+ return '';
60
+ const a = mintAbsence(readOwnDataValue(view, 'kind'), readOwnDataValue(view, 'mediaType'), mimeTypeSlot(view), readOwnDataValue(view, 'blocks'), readOwnDataValue(view, 'bytes'));
61
+ return a === undefined ? '' : renderMessage(absenceRefOf(a), lang);
62
+ }
63
+ catch {
64
+ return '';
65
+ }
66
+ }
4
67
  function blockOf(raw) {
5
68
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
6
69
  return null;
7
70
  const b = raw;
8
71
  if (b.type === 'text')
9
- return typeof b.text === 'string' ? { type: 'text', text: b.text } : null;
72
+ return typeof b.text === 'string' ? { block: { type: 'text', text: b.text }, undelivered: false } : null;
73
+ const absence = toolOutputMediaAbsenceOf(b);
74
+ if (absence !== undefined)
75
+ return { block: { type: 'text', text: renderMessage(absenceRefOf(absence)) }, undelivered: true };
10
76
  if (b.type !== 'image')
11
77
  return null;
12
78
  const data = b.data;
@@ -15,7 +81,7 @@ function blockOf(raw) {
15
81
  return null;
16
82
  if (typeof mediaType !== 'string' || !IMAGE_MEDIA_TYPES.includes(mediaType))
17
83
  return null;
18
- return { type: 'image', source: { type: 'base64', media_type: mediaType, data } };
84
+ return { block: { type: 'image', source: { type: 'base64', media_type: mediaType, data } }, undelivered: false };
19
85
  }
20
86
  const TRUNCATED_NOTE = '…(truncated)';
21
87
  function toolResultContentOf(output) {
@@ -26,17 +92,26 @@ function toolResultContentOf(output) {
26
92
  const blocks = [];
27
93
  let omitted = 0;
28
94
  let images = 0;
95
+ let undelivered = 0;
29
96
  for (const raw of output) {
30
- const block = blockOf(raw);
31
- if (block === null)
97
+ let read = null;
98
+ try {
99
+ read = blockOf(raw);
100
+ }
101
+ catch {
102
+ read = null;
103
+ }
104
+ if (read === null)
32
105
  omitted++;
33
106
  else {
34
- if (block.type === 'image')
107
+ if (read.block.type === 'image')
35
108
  images++;
36
- blocks.push(block);
109
+ if (read.undelivered)
110
+ undelivered++;
111
+ blocks.push(read.block);
37
112
  }
38
113
  }
39
- if (images === 0 && omitted === 0)
114
+ if (images === 0 && omitted === 0 && undelivered === 0)
40
115
  return blocks.map((b) => b.text).join('');
41
116
  if (omitted > 0)
42
117
  blocks.push({ type: 'text', text: OMITTED_CONTENT_NOTE });
@@ -83,6 +83,7 @@ export declare function handsMountedDetail(reading: HandsMountedReading, lang?:
83
83
  export declare function toolRosterNames(roster: ToolRosterView | undefined): readonly string[];
84
84
  export interface ToolShim {
85
85
  name: string;
86
+ aliases?: readonly string[];
86
87
  source: string;
87
88
  family?: string;
88
89
  userFacingName?: string;
@@ -97,6 +98,23 @@ export interface ToolShim {
97
98
  capabilityId?: string;
98
99
  }
99
100
  export declare function toolShimFromRoster(entry: unknown): ToolShim | undefined;
101
+ export interface EngineRosterPeerTool {
102
+ name: string;
103
+ aliases?: readonly string[];
104
+ cardId?: string;
105
+ }
106
+ export interface EngineRosterPeerGroup {
107
+ peer: string;
108
+ declaredBy?: readonly string[];
109
+ tools: readonly EngineRosterPeerTool[];
110
+ count: number;
111
+ }
112
+ export interface EngineRosterPeersView {
113
+ groups: readonly EngineRosterPeerGroup[];
114
+ unattributed: readonly EngineRosterPeerTool[];
115
+ }
116
+ export declare function projectEngineRosterPeers(roster: ToolRosterView | undefined, source: string): EngineRosterPeersView | undefined;
117
+ export declare function projectEngineA2aPeers(roster: ToolRosterView | undefined): EngineRosterPeersView | undefined;
100
118
  export interface ToolRosterDeltaApplication {
101
119
  roster: ToolRosterView | undefined;
102
120
  applied: boolean;
@@ -205,6 +205,7 @@ export function toolShimFromRoster(entry) {
205
205
  return {
206
206
  name: e.name,
207
207
  source: e.source,
208
+ ...(e.aliases !== undefined ? { aliases: copyStrings(e.aliases) } : {}),
208
209
  ...(e.family !== undefined ? { family: e.family } : {}),
209
210
  ...(e.renderHints?.userFacingName !== undefined ? { userFacingName: e.renderHints.userFacingName } : {}),
210
211
  ...(e.renderHints?.activity !== undefined ? { activity: e.renderHints.activity } : {}),
@@ -218,6 +219,69 @@ export function toolShimFromRoster(entry) {
218
219
  ...(e.capabilityId !== undefined ? { capabilityId: e.capabilityId } : {}),
219
220
  };
220
221
  }
222
+ const compareCodeUnits = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
223
+ function copyStrings(src) {
224
+ const out = [];
225
+ const n = src.length;
226
+ for (let i = 0; i < n; i++) {
227
+ const v = src[i];
228
+ if (typeof v === 'string')
229
+ out.push(v);
230
+ }
231
+ return out;
232
+ }
233
+ function rosterPeerToolOf(e) {
234
+ return {
235
+ name: e.name,
236
+ ...(e.aliases !== undefined ? { aliases: copyStrings(e.aliases) } : {}),
237
+ ...(e.cardId !== undefined ? { cardId: e.cardId } : {}),
238
+ };
239
+ }
240
+ export function projectEngineRosterPeers(roster, source) {
241
+ if (typeof roster !== 'object' || roster === null)
242
+ return undefined;
243
+ if (typeof source !== 'string' || source.length === 0)
244
+ return undefined;
245
+ try {
246
+ const view = readRoster(roster);
247
+ if (view === undefined || view.entries.length !== view.count)
248
+ return undefined;
249
+ const slots = new Map();
250
+ const unattributed = [];
251
+ for (const e of view.entries) {
252
+ if (e.source !== source)
253
+ continue;
254
+ const peer = e.origin?.peer;
255
+ if (peer === undefined) {
256
+ unattributed.push(rosterPeerToolOf(e));
257
+ continue;
258
+ }
259
+ let slot = slots.get(peer);
260
+ if (slot === undefined) {
261
+ slot = { tools: [], declaredBy: new Set() };
262
+ slots.set(peer, slot);
263
+ }
264
+ slot.tools.push(rosterPeerToolOf(e));
265
+ if (e.origin?.declaredBy !== undefined)
266
+ slot.declaredBy.add(e.origin.declaredBy);
267
+ }
268
+ const groups = [...slots.entries()]
269
+ .sort((a, b) => compareCodeUnits(a[0], b[0]))
270
+ .map(([peer, slot]) => ({
271
+ peer,
272
+ ...(slot.declaredBy.size > 0 ? { declaredBy: [...slot.declaredBy].sort(compareCodeUnits) } : {}),
273
+ tools: slot.tools,
274
+ count: slot.tools.length,
275
+ }));
276
+ return { groups, unattributed };
277
+ }
278
+ catch {
279
+ return undefined;
280
+ }
281
+ }
282
+ export function projectEngineA2aPeers(roster) {
283
+ return projectEngineRosterPeers(roster, 'a2a');
284
+ }
221
285
  function readSummary(raw) {
222
286
  const o = obj(raw);
223
287
  if (o === undefined)
@@ -0,0 +1,8 @@
1
+ export interface ToolsFlagNames {
2
+ readonly kept: readonly string[];
3
+ readonly excluded: readonly string[];
4
+ readonly bare: boolean;
5
+ readonly detached: readonly string[];
6
+ readonly scoped: readonly string[];
7
+ }
8
+ export declare function parseToolsFlagNames(values: readonly string[]): ToolsFlagNames;
@@ -0,0 +1,110 @@
1
+ function readableStrings(values) {
2
+ const out = [];
3
+ try {
4
+ if (!Array.isArray(values))
5
+ return out;
6
+ const n = values.length;
7
+ for (let i = 0; i < n; i++) {
8
+ try {
9
+ const v = values[i];
10
+ if (typeof v === 'string')
11
+ out.push(v);
12
+ }
13
+ catch {
14
+ continue;
15
+ }
16
+ }
17
+ }
18
+ catch {
19
+ return out;
20
+ }
21
+ return out;
22
+ }
23
+ function splitToolsFlagTokens(values) {
24
+ const out = [];
25
+ for (const value of values) {
26
+ if (value === '')
27
+ continue;
28
+ let cur = '';
29
+ let inParen = false;
30
+ for (const ch of value) {
31
+ if (ch === '(') {
32
+ inParen = true;
33
+ cur += ch;
34
+ }
35
+ else if (ch === ')') {
36
+ inParen = false;
37
+ cur += ch;
38
+ }
39
+ else if (ch === ',') {
40
+ if (inParen)
41
+ cur += ch;
42
+ else {
43
+ if (cur.trim() !== '')
44
+ out.push(cur.trim());
45
+ cur = '';
46
+ }
47
+ }
48
+ else if (ch === ' ') {
49
+ if (inParen)
50
+ cur += ch;
51
+ else if (cur.trim() !== '') {
52
+ out.push(cur.trim());
53
+ cur = '';
54
+ }
55
+ }
56
+ else if (cur !== '' || ch.trim() !== '') {
57
+ cur += ch;
58
+ }
59
+ }
60
+ if (cur.trim() !== '')
61
+ out.push(cur.trim());
62
+ }
63
+ return out;
64
+ }
65
+ export function parseToolsFlagNames(values) {
66
+ const tokens = splitToolsFlagTokens(readableStrings(values));
67
+ const kept = [];
68
+ const excluded = new Set();
69
+ const detached = [];
70
+ const scoped = [];
71
+ let bare = false;
72
+ for (let i = 0; i < tokens.length; i++) {
73
+ let token = tokens[i];
74
+ if (token === undefined)
75
+ continue;
76
+ if (!token.startsWith('!')) {
77
+ kept.push(token);
78
+ continue;
79
+ }
80
+ let name = token.slice(1);
81
+ if (name === '') {
82
+ const next = tokens[i + 1];
83
+ if (next === undefined || next.startsWith('!') || next.startsWith('(')) {
84
+ bare = true;
85
+ continue;
86
+ }
87
+ i++;
88
+ detached.push(next);
89
+ token = `!${next}`;
90
+ name = next;
91
+ }
92
+ const paren = name.indexOf('(');
93
+ if (paren === 0) {
94
+ bare = true;
95
+ continue;
96
+ }
97
+ if (paren > 0) {
98
+ name = name.slice(0, paren);
99
+ scoped.push(token);
100
+ }
101
+ excluded.add(name);
102
+ }
103
+ return Object.freeze({
104
+ kept: Object.freeze(kept),
105
+ excluded: Object.freeze([...excluded]),
106
+ bare,
107
+ detached: Object.freeze(detached),
108
+ scoped: Object.freeze(scoped),
109
+ });
110
+ }