@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
@@ -0,0 +1,261 @@
1
+ import { CC_TIER_ALIASES, TIER_ORDER } from './tierVocabulary.js';
2
+ import { liveModelRowsOf } from '../liveModelCatalog.js';
3
+ import { quoteUntrustedForSentence } from '../displayUntrusted.js';
4
+ import { msg, renderMessage } from '../i18n/translate.js';
5
+ const STARTED_BY_THIS_PROCESS = 'started-by-this-process';
6
+ function ownData(v, key) {
7
+ if (v === null || typeof v !== 'object')
8
+ return undefined;
9
+ try {
10
+ const d = Object.getOwnPropertyDescriptor(v, key);
11
+ return d !== undefined && 'value' in d ? d.value : undefined;
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ }
17
+ const nonEmpty = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
18
+ function listOf(v) {
19
+ try {
20
+ if (!Array.isArray(v))
21
+ return undefined;
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ const n = ownData(v, 'length');
27
+ if (typeof n !== 'number' || !Number.isSafeInteger(n) || n < 0)
28
+ return undefined;
29
+ const out = [];
30
+ for (let i = 0; i < n; i += 1)
31
+ out.push(ownData(v, String(i)));
32
+ return out;
33
+ }
34
+ function catalogFrom(rows) {
35
+ const names = [];
36
+ const idToName = new Map();
37
+ for (const r of rows) {
38
+ if (!names.includes(r.name))
39
+ names.push(r.name);
40
+ if (r.id !== undefined && !idToName.has(r.id))
41
+ idToName.set(r.id, r.name);
42
+ }
43
+ return { names, nameSet: new Set(names), idToName };
44
+ }
45
+ function localOf(input) {
46
+ const local = ownData(input, 'local');
47
+ if (local === null || typeof local !== 'object')
48
+ return undefined;
49
+ return ownData(local, 'engine') === STARTED_BY_THIS_PROCESS ? local : undefined;
50
+ }
51
+ function catalogOf(input, local) {
52
+ const live = ownData(input, 'liveCatalog');
53
+ if (live !== undefined && live !== null) {
54
+ const rows = typeof live === 'object' ? liveModelRowsOf(live) : null;
55
+ return rows === null ? undefined : catalogFrom(rows.map((r) => ({ name: r.name, id: r.id })));
56
+ }
57
+ if (local === undefined)
58
+ return undefined;
59
+ const pool = listOf(ownData(local, 'pool'));
60
+ if (pool === undefined)
61
+ return undefined;
62
+ const rows = [];
63
+ for (const e of pool) {
64
+ const name = nonEmpty(ownData(e, 'name'));
65
+ if (name === undefined)
66
+ continue;
67
+ const id = nonEmpty(ownData(e, 'id'));
68
+ rows.push(id === undefined ? { name } : { name, id });
69
+ }
70
+ return catalogFrom(rows);
71
+ }
72
+ function ownSlot(v, key) {
73
+ try {
74
+ const d = Object.getOwnPropertyDescriptor(v, key);
75
+ if (d === undefined)
76
+ return { kind: 'absent' };
77
+ return 'value' in d ? { kind: 'value', value: d.value } : { kind: 'unreadable' };
78
+ }
79
+ catch {
80
+ return { kind: 'unreadable' };
81
+ }
82
+ }
83
+ function tiersOf(local) {
84
+ if (local === undefined)
85
+ return undefined;
86
+ const slot = ownSlot(local, 'tiers');
87
+ if (slot.kind !== 'value')
88
+ return undefined;
89
+ const raw = slot.value;
90
+ if (raw === undefined || raw === null)
91
+ return new Map();
92
+ if (typeof raw !== 'object')
93
+ return undefined;
94
+ try {
95
+ if (Array.isArray(raw))
96
+ return undefined;
97
+ }
98
+ catch {
99
+ return undefined;
100
+ }
101
+ const out = new Map();
102
+ let keys;
103
+ try {
104
+ keys = Object.keys(raw);
105
+ }
106
+ catch {
107
+ return undefined;
108
+ }
109
+ for (const k of keys) {
110
+ const b = ownSlot(raw, k);
111
+ if (b.kind !== 'value' || typeof b.value !== 'string')
112
+ return undefined;
113
+ if (b.value.length > 0)
114
+ out.set(k, b.value);
115
+ }
116
+ return out;
117
+ }
118
+ const BUILTIN_VOCAB = [...TIER_ORDER, ...Object.keys(CC_TIER_ALIASES), 'best'];
119
+ function builtinKindOf(w) {
120
+ if (TIER_ORDER.includes(w))
121
+ return 'tier';
122
+ if (Object.hasOwn(CC_TIER_ALIASES, w))
123
+ return 'cc-alias';
124
+ return w === 'best' ? 'best' : undefined;
125
+ }
126
+ class BrokenBinding {
127
+ }
128
+ function landingOf(word, kind, tiers, cat) {
129
+ const ownKey = (k) => cat.nameSet.has(k);
130
+ const bound = (t) => {
131
+ const b = tiers.get(t);
132
+ if (b === undefined)
133
+ return undefined;
134
+ if (!cat.nameSet.has(b))
135
+ throw new BrokenBinding();
136
+ return b;
137
+ };
138
+ const landing = (t, self) => {
139
+ const b = bound(t);
140
+ if (b === undefined)
141
+ return undefined;
142
+ return { name: b, via: [...(t !== self && !ownKey(t) ? [t] : []), b] };
143
+ };
144
+ const resolveTier = (name, self = name) => {
145
+ const direct = landing(name, self);
146
+ if (direct !== undefined)
147
+ return direct;
148
+ const at = TIER_ORDER.indexOf(name);
149
+ if (at === -1)
150
+ return undefined;
151
+ for (let i = at + 1; i < TIER_ORDER.length; i++) {
152
+ const next = landing(TIER_ORDER[i], self);
153
+ if (next !== undefined)
154
+ return { name: next.name, via: [...(name !== self && !ownKey(name) ? [name] : []), ...next.via] };
155
+ }
156
+ return undefined;
157
+ };
158
+ if (tiers.has(word) || kind === 'tier')
159
+ return resolveTier(word);
160
+ if (kind === 'cc-alias')
161
+ return resolveTier(CC_TIER_ALIASES[word], word);
162
+ for (const name of TIER_ORDER) {
163
+ const r = landing(name, 'best');
164
+ if (r !== undefined)
165
+ return r;
166
+ }
167
+ return undefined;
168
+ }
169
+ const tierLabelOf = (word, kind) => (kind === 'cc-alias' ? CC_TIER_ALIASES[word] ?? word : word);
170
+ function freezeReading(r) {
171
+ if (r.landing !== undefined) {
172
+ Object.freeze(r.landing.via);
173
+ Object.freeze(r.landing);
174
+ }
175
+ return Object.freeze(r);
176
+ }
177
+ function resolveIn(input) {
178
+ const rawWord = ownData(input, 'word');
179
+ const word = typeof rawWord === 'string' ? rawWord.trim() : '';
180
+ if (word === '' || word.toLowerCase() === 'inherit')
181
+ return freezeReading({ kind: 'inherit' });
182
+ const local = localOf(input);
183
+ const cat = catalogOf(input, local);
184
+ const tiers = tiersOf(local);
185
+ const customTierKeys = tiers === undefined ? [] : [...tiers.keys()];
186
+ const tierClass = (w, kind) => {
187
+ const label = tierLabelOf(w, kind);
188
+ if (tiers === undefined || cat === undefined)
189
+ return { kind, model: w, label };
190
+ if (tiers.size === 0)
191
+ return { kind: 'unbound', problem: 'tiers-inert', label };
192
+ let l;
193
+ try {
194
+ l = landingOf(w, kind, tiers, cat);
195
+ }
196
+ catch (e) {
197
+ if (e instanceof BrokenBinding)
198
+ return { kind: 'unbound', problem: 'binding-not-in-catalog', label };
199
+ throw e;
200
+ }
201
+ if (l === undefined)
202
+ return { kind: 'unbound', problem: 'chain-unbound', label };
203
+ return { kind, model: w, landing: { name: l.name, via: l.via, source: 'local-config' }, label: `${l.name} (${label})` };
204
+ };
205
+ const asCatalog = (name) => ({ kind: 'catalog', model: name, label: name });
206
+ const classify = (k) => {
207
+ if (cat?.nameSet.has(k))
208
+ return asCatalog(k);
209
+ const b = builtinKindOf(k);
210
+ return tierClass(k, b ?? 'tier');
211
+ };
212
+ if (cat?.nameSet.has(word))
213
+ return freezeReading(asCatalog(word));
214
+ const exact = builtinKindOf(word);
215
+ if (exact !== undefined)
216
+ return freezeReading(tierClass(word, exact));
217
+ if (tiers?.has(word))
218
+ return freezeReading(tierClass(word, 'tier'));
219
+ const lower = word.toLowerCase();
220
+ const space = new Set([...(cat?.names ?? []), ...BUILTIN_VOCAB, ...customTierKeys]);
221
+ const ciMatches = [...space].filter((k) => k.toLowerCase() === lower);
222
+ if (builtinKindOf(lower) !== undefined) {
223
+ return freezeReading(ciMatches.length === 1 ? classify(ciMatches[0]) : { kind: 'ambiguous' });
224
+ }
225
+ const byId = cat?.idToName.get(word);
226
+ if (byId !== undefined)
227
+ return freezeReading({ kind: 'model-id', model: byId, label: byId });
228
+ if (ciMatches.length === 1)
229
+ return freezeReading(classify(ciMatches[0]));
230
+ if (ciMatches.length > 1)
231
+ return freezeReading({ kind: 'ambiguous' });
232
+ return freezeReading({ kind: cat === undefined ? 'catalog-unknown' : 'passthrough', model: word, label: word });
233
+ }
234
+ export function resolveSubagentModelWord(input) {
235
+ try {
236
+ return resolveIn(input);
237
+ }
238
+ catch {
239
+ const w = ownData(input, 'word');
240
+ const word = typeof w === 'string' ? w.trim() : '';
241
+ return freezeReading(word === '' ? { kind: 'inherit' } : { kind: 'catalog-unknown', model: word, label: word });
242
+ }
243
+ }
244
+ export function subagentModelWordProblemLine(word, reading, lang) {
245
+ const ref = problemRefOf(word, reading);
246
+ return ref === undefined ? undefined : renderMessage(ref, lang);
247
+ }
248
+ function problemRefOf(word, reading) {
249
+ const kind = ownData(reading, 'kind');
250
+ if (kind !== 'unbound' && kind !== 'ambiguous')
251
+ return undefined;
252
+ const quoted = quoteUntrustedForSentence(typeof word === 'string' ? word.trim() : '', 80) ?? '""';
253
+ if (kind === 'ambiguous')
254
+ return msg('model.subagent.ambiguous', { word: quoted });
255
+ const problem = ownData(reading, 'problem');
256
+ if (problem === 'tiers-inert')
257
+ return msg('model.subagent.tiersInert', { word: quoted });
258
+ if (problem === 'binding-not-in-catalog')
259
+ return msg('model.subagent.bindingNotInCatalog', { word: quoted });
260
+ return msg('model.subagent.chainUnbound', { word: quoted });
261
+ }
@@ -1,10 +1,12 @@
1
1
  import { CORE_DEFAULT_TIER_ORDER } from '../generated/engineFactTables.js';
2
+ import type { UiLanguage } from '../env/uiLanguage.js';
2
3
  export type Tier = (typeof CORE_DEFAULT_TIER_ORDER)[number];
3
4
  export declare const TIER_ORDER: readonly Tier[];
4
5
  export declare const SURFACED_TIERS: readonly Tier[];
5
6
  export declare const CC_TIER_ALIASES: Readonly<Record<string, Tier>>;
6
7
  export declare const DEFAULT_TIER: Tier;
7
8
  export declare const TIER_BLURBS: Readonly<Record<Tier, string>>;
9
+ export declare function tierBlurb(tier: Tier, lang?: UiLanguage): string;
8
10
  export type TierGroupDef = {
9
11
  tiers: Partial<Record<Tier, string>>;
10
12
  defaultTier?: Tier;
@@ -1,15 +1,27 @@
1
1
  import { CORE_CC_MODEL_TIER_ALIASES, CORE_DEFAULT_TIER_ORDER } from '../generated/engineFactTables.js';
2
+ import { EN_MESSAGES } from '../i18n/messages.en.js';
3
+ import { msg, renderMessage } from '../i18n/translate.js';
2
4
  export const TIER_ORDER = CORE_DEFAULT_TIER_ORDER;
3
5
  export const SURFACED_TIERS = ['max', 'pro', 'flash', 'lite'];
4
6
  export const CC_TIER_ALIASES = CORE_CC_MODEL_TIER_ALIASES;
5
7
  export const DEFAULT_TIER = 'pro';
8
+ const TIER_BLURB_KEYS = Object.freeze({
9
+ ultra: 'model.tier.blurb.ultra',
10
+ max: 'model.tier.blurb.max',
11
+ pro: 'model.tier.blurb.pro',
12
+ flash: 'model.tier.blurb.flash',
13
+ lite: 'model.tier.blurb.lite',
14
+ });
6
15
  export const TIER_BLURBS = {
7
- ultra: 'reserved above max — binds when a stronger model lands',
8
- max: 'hardest problems — deep reasoning, big refactors',
9
- pro: 'everyday driving — the default tier',
10
- flash: 'fast + cheap — titles, recaps, volume work',
11
- lite: 'cheapest — bulk classification, simple lookups',
16
+ ultra: EN_MESSAGES[TIER_BLURB_KEYS.ultra],
17
+ max: EN_MESSAGES[TIER_BLURB_KEYS.max],
18
+ pro: EN_MESSAGES[TIER_BLURB_KEYS.pro],
19
+ flash: EN_MESSAGES[TIER_BLURB_KEYS.flash],
20
+ lite: EN_MESSAGES[TIER_BLURB_KEYS.lite],
12
21
  };
22
+ export function tierBlurb(tier, lang) {
23
+ return typeof tier === 'string' && Object.hasOwn(TIER_BLURB_KEYS, tier) ? renderMessage(msg(TIER_BLURB_KEYS[tier]), lang) : '';
24
+ }
13
25
  export const isTier = (v) => typeof v === 'string' && TIER_ORDER.includes(v);
14
26
  export function resolveTierBinding(def, tier) {
15
27
  const direct = def.tiers[tier];
@@ -1,3 +1,4 @@
1
+ import type { ModelApiWord } from './model/providerPresets.js';
1
2
  export interface OpenAICompletionsProbeBody {
2
3
  model: string;
3
4
  messages: ReadonlyArray<{
@@ -66,4 +67,67 @@ type ProbeWritableEntry = {
66
67
  compat?: unknown;
67
68
  };
68
69
  export declare function applyProbeToEntry<T extends ProbeWritableEntry>(entry: T, result: ModelProbeResult): T;
70
+ export declare const PROBE_VERDICTS: readonly ["ok", "auth", "unreachable", "model", "shape", "busy", "no_token", "other"];
71
+ export type ProbeVerdictWord = (typeof PROBE_VERDICTS)[number];
72
+ export type ProbeAnswerOutcome = 'error' | 'not_model' | 'ended';
73
+ export interface ProbeVerdict {
74
+ readonly verdict: ProbeVerdictWord;
75
+ readonly httpStatus?: number;
76
+ readonly waitedMs?: number;
77
+ readonly path?: string;
78
+ readonly apiError?: string;
79
+ readonly outcome?: ProbeAnswerOutcome;
80
+ readonly nearModelId?: string;
81
+ readonly cause?: string;
82
+ }
83
+ export interface LivenessFetchInit {
84
+ readonly method: 'GET' | 'POST';
85
+ readonly headers: Readonly<Record<string, string>>;
86
+ readonly body?: string;
87
+ readonly signal: AbortSignal;
88
+ }
89
+ export interface LivenessBodyReader {
90
+ read(): Promise<{
91
+ readonly done: boolean;
92
+ readonly value?: Uint8Array | undefined;
93
+ }>;
94
+ cancel(): Promise<void>;
95
+ }
96
+ export interface LivenessResponse {
97
+ readonly status: number;
98
+ readonly headers: {
99
+ get(name: string): string | null;
100
+ };
101
+ readonly body: {
102
+ getReader(): LivenessBodyReader;
103
+ } | null;
104
+ text(): Promise<string>;
105
+ }
106
+ export type LivenessFetch = (url: string, init: LivenessFetchInit) => Promise<LivenessResponse>;
107
+ export interface LivenessProbeInput {
108
+ readonly api: ModelApiWord;
109
+ readonly baseUrl: string;
110
+ readonly modelId?: string;
111
+ readonly fetch: LivenessFetch;
112
+ readonly firstTokenBudgetMs: number;
113
+ readonly catalogBudgetMs: number;
114
+ readonly signal?: AbortSignal;
115
+ readonly now?: () => number;
116
+ readonly redact?: (text: string) => string;
117
+ readonly requestUrl?: (path: string) => string;
118
+ }
119
+ export declare function probeModelLiveness(input: LivenessProbeInput): Promise<ProbeVerdict>;
120
+ export type ProbeVerdictRecourse = 'switch_model' | 'check_credentials';
121
+ export interface ProbeVerdictNotice {
122
+ readonly line: string;
123
+ readonly recourse?: ProbeVerdictRecourse;
124
+ }
125
+ export interface ProbeVerdictFacts {
126
+ readonly verdict?: string;
127
+ readonly httpStatus?: number;
128
+ readonly waitedMs?: number;
129
+ }
130
+ export declare function probeVerdictNotice(facts: ProbeVerdictFacts | null | undefined, ctx?: {
131
+ readonly modelName?: string;
132
+ }): ProbeVerdictNotice;
69
133
  export {};