@sema-agent/client-core 0.97.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/CHANGELOG.md +429 -0
  2. package/README.md +74 -36
  3. package/dist/adapt/arms.d.ts +1 -0
  4. package/dist/adapt/arms.js +128 -34
  5. package/dist/adapt/ids.d.ts +12 -1
  6. package/dist/adapt/ids.js +59 -8
  7. package/dist/adapt/instanceLedger.d.ts +50 -0
  8. package/dist/adapt/instanceLedger.js +147 -0
  9. package/dist/adapt/textStream.d.ts +1 -0
  10. package/dist/adapt/textStream.js +24 -7
  11. package/dist/adapt/toolCards.d.ts +27 -5
  12. package/dist/adapt/toolCards.js +39 -6
  13. package/dist/adapt/wireShapes.js +6 -2
  14. package/dist/adapt.d.ts +2 -0
  15. package/dist/adapt.js +8 -3
  16. package/dist/adapter/activeRunSelfHeal.d.ts +5 -0
  17. package/dist/adapter/activeRunSelfHeal.js +51 -28
  18. package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
  19. package/dist/adapter/downstream/eventToSdkMessage.js +27 -34
  20. package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
  21. package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
  22. package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
  23. package/dist/adapter/runStream.js +29 -13
  24. package/dist/adapter/types.d.ts +4 -4
  25. package/dist/agentSession/backgroundView.js +2 -1
  26. package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
  27. package/dist/agentSession/engineAgentRegistryRead.js +12 -13
  28. package/dist/agentsWireCaps.d.ts +8 -6
  29. package/dist/agentsWireCaps.js +177 -162
  30. package/dist/approvalDecidedByCapability.d.ts +0 -4
  31. package/dist/approvalDecidedByCapability.js +0 -6
  32. package/dist/approvalsStreamLiveCapability.d.ts +0 -4
  33. package/dist/approvalsStreamLiveCapability.js +0 -6
  34. package/dist/assistantInbox.d.ts +34 -0
  35. package/dist/assistantInbox.js +118 -0
  36. package/dist/centerWiringCapability.js +9 -1
  37. package/dist/clientSlice.d.ts +0 -9
  38. package/dist/clientSlice.js +0 -3
  39. package/dist/cloudConfigWireCaps.d.ts +4 -2
  40. package/dist/cloudConfigWireCaps.js +81 -61
  41. package/dist/compensations.js +1 -1
  42. package/dist/connectorStatus.d.ts +21 -0
  43. package/dist/connectorStatus.js +112 -0
  44. package/dist/controlRouter.d.ts +14 -1
  45. package/dist/controlRouter.js +68 -17
  46. package/dist/coreValuePorts.d.ts +3 -3
  47. package/dist/decideReceipt.d.ts +2 -2
  48. package/dist/decideReceipt.js +5 -2
  49. package/dist/declared/supportFloorDeclared.js +3 -3
  50. package/dist/deviceExecutorManagementCapability.d.ts +0 -4
  51. package/dist/deviceExecutorManagementCapability.js +0 -6
  52. package/dist/deviceRebind.d.ts +49 -1
  53. package/dist/deviceRebind.js +221 -3
  54. package/dist/displayUntrusted.d.ts +1 -0
  55. package/dist/displayUntrusted.js +250 -76
  56. package/dist/engineAgentAbsence.d.ts +1 -1
  57. package/dist/engineAgentPanelStore.d.ts +5 -4
  58. package/dist/engineAgentPanelStore.js +3 -12
  59. package/dist/engineCapReader.d.ts +0 -4
  60. package/dist/engineCapReader.js +1 -5
  61. package/dist/engineCapsCache.d.ts +4 -0
  62. package/dist/engineCapsCache.js +17 -12
  63. package/dist/engineClosedSets.d.ts +1 -0
  64. package/dist/engineClosedSets.js +4 -1
  65. package/dist/engineErrorCodes.d.ts +9 -2
  66. package/dist/engineErrorCodes.js +9 -1
  67. package/dist/engineIdentity.d.ts +1 -0
  68. package/dist/engineIdentity.js +8 -0
  69. package/dist/engineRowRef.d.ts +28 -0
  70. package/dist/engineRowRef.js +111 -0
  71. package/dist/engineSessionMessages.d.ts +67 -0
  72. package/dist/engineSessionMessages.js +364 -0
  73. package/dist/engineToolDirectory.d.ts +18 -0
  74. package/dist/engineToolDirectory.js +85 -0
  75. package/dist/engineUrl.d.ts +18 -0
  76. package/dist/engineUrl.js +52 -0
  77. package/dist/env/uiLanguage.d.ts +9 -0
  78. package/dist/env/uiLanguage.js +35 -0
  79. package/dist/eventLeg.d.ts +92 -0
  80. package/dist/eventLeg.js +285 -0
  81. package/dist/executionLaneCapability.d.ts +0 -4
  82. package/dist/executionLaneCapability.js +3 -16
  83. package/dist/fileHistoryCaptureCapability.d.ts +0 -4
  84. package/dist/fileHistoryCaptureCapability.js +5 -7
  85. package/dist/fleet/fleetLedger.d.ts +0 -3
  86. package/dist/fleet/fleetLedger.js +21 -36
  87. package/dist/fleet/fleetProjection.d.ts +2 -2
  88. package/dist/fleet/fleetProjection.js +10 -8
  89. package/dist/frameBinding.d.ts +5 -0
  90. package/dist/frameBinding.js +23 -0
  91. package/dist/gateFailureCodes.d.ts +2 -0
  92. package/dist/gateFailureCodes.js +15 -0
  93. package/dist/gateOutcome.d.ts +3 -1
  94. package/dist/gateOutcome.js +25 -6
  95. package/dist/gateVocabulary.d.ts +5 -0
  96. package/dist/gateVocabulary.js +64 -2
  97. package/dist/generated/engineAskFaceTables.js +2 -2
  98. package/dist/generated/engineFactTables.d.ts +6 -3
  99. package/dist/generated/engineFactTables.js +22 -4
  100. package/dist/generated/engineNoticeTables.js +9 -0
  101. package/dist/generated/toolNameTables.d.ts +1 -0
  102. package/dist/generated/toolNameTables.js +1 -0
  103. package/dist/hitl/allowRuleShadow.d.ts +6 -1
  104. package/dist/hitl/allowRuleShadow.js +21 -17
  105. package/dist/hitl/approvalCardReading.d.ts +15 -0
  106. package/dist/hitl/approvalCardReading.js +154 -0
  107. package/dist/hitl/approvalCardReasons.d.ts +13 -0
  108. package/dist/hitl/approvalCardReasons.js +120 -0
  109. package/dist/hitl/approvalHolds.d.ts +47 -15
  110. package/dist/hitl/approvalHolds.js +134 -28
  111. package/dist/hitl/approvalResolution.d.ts +51 -26
  112. package/dist/hitl/approvalResolution.js +86 -122
  113. package/dist/hitl/approvalsFeed.js +6 -18
  114. package/dist/hitl/askClassPair.d.ts +2 -0
  115. package/dist/hitl/askClassPair.js +1 -0
  116. package/dist/hitl/askGateWire.d.ts +20 -2
  117. package/dist/hitl/askGateWire.js +49 -1
  118. package/dist/hitl/askParkRowRouting.d.ts +5 -0
  119. package/dist/hitl/askParkRowRouting.js +32 -1
  120. package/dist/hitl/askSettlementLine.d.ts +18 -0
  121. package/dist/hitl/askSettlementLine.js +79 -0
  122. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  123. package/dist/hitl/automaticAnswerVerdict.js +21 -5
  124. package/dist/hitl/crashConverged.d.ts +11 -20
  125. package/dist/hitl/crashConverged.js +56 -0
  126. package/dist/hitl/crashConvergedNotice.d.ts +3 -1
  127. package/dist/hitl/crashConvergedNotice.js +48 -11
  128. package/dist/hitl/decisionConflict.js +3 -10
  129. package/dist/hitl/decisionRefusal.d.ts +40 -1
  130. package/dist/hitl/decisionRefusal.js +199 -42
  131. package/dist/hitl/frameRouter.d.ts +5 -2
  132. package/dist/hitl/frameRouter.js +20 -16
  133. package/dist/hitl/gateLedger.d.ts +2 -0
  134. package/dist/hitl/gateLedger.js +50 -13
  135. package/dist/hitl/hitlBridge.d.ts +1 -2
  136. package/dist/hitl/hitlBridge.js +10 -7
  137. package/dist/hitl/livePendingAsk.d.ts +3 -3
  138. package/dist/hitl/livePendingAsk.js +7 -18
  139. package/dist/hitl/parkResolver.d.ts +2 -24
  140. package/dist/hitl/parkResolver.js +61 -97
  141. package/dist/hitl/persistedRulesWire.d.ts +24 -0
  142. package/dist/hitl/persistedRulesWire.js +122 -2
  143. package/dist/hitl/planReviewWire.d.ts +26 -13
  144. package/dist/hitl/planReviewWire.js +112 -78
  145. package/dist/hitl/refusedToolNameProse.d.ts +0 -1
  146. package/dist/hitl/refusedToolNameProse.js +0 -3
  147. package/dist/hitl/replayedApproval.d.ts +4 -3
  148. package/dist/hitl/replayedApproval.js +7 -4
  149. package/dist/hitl/sessionPolicyDeliverable.js +2 -4
  150. package/dist/hitl/sessionPolicyWire.d.ts +32 -20
  151. package/dist/hitl/sessionPolicyWire.js +162 -52
  152. package/dist/hitl/standingRows.d.ts +20 -2
  153. package/dist/hitl/standingRows.js +69 -8
  154. package/dist/hitl/toolApprovalWire.d.ts +87 -152
  155. package/dist/hitl/toolApprovalWire.js +591 -380
  156. package/dist/hookMatcherVerdict.d.ts +6 -1
  157. package/dist/hookMatcherVerdict.js +14 -7
  158. package/dist/hooksWireCaps.d.ts +2 -2
  159. package/dist/hooksWireCaps.js +59 -55
  160. package/dist/i18n/messages.en.d.ts +121 -0
  161. package/dist/i18n/messages.en.js +119 -0
  162. package/dist/i18n/messages.zh.d.ts +3 -0
  163. package/dist/i18n/messages.zh.js +120 -0
  164. package/dist/i18n/translate.d.ts +25 -0
  165. package/dist/i18n/translate.js +127 -0
  166. package/dist/index.d.ts +53 -18
  167. package/dist/index.js +38 -10
  168. package/dist/inheritEnvCapability.d.ts +31 -0
  169. package/dist/inheritEnvCapability.js +104 -0
  170. package/dist/liveModelCatalog.d.ts +1 -2
  171. package/dist/liveModelCatalog.js +2 -6
  172. package/dist/liveQuestionStore.d.ts +2 -21
  173. package/dist/mcpLiveness.d.ts +2 -1
  174. package/dist/mcpProbeWire.d.ts +6 -1
  175. package/dist/mcpProbeWire.js +1 -1
  176. package/dist/mcpWireCaps.d.ts +13 -2
  177. package/dist/mcpWireCaps.js +48 -0
  178. package/dist/memoryEntriesWire.d.ts +4 -9
  179. package/dist/model/modelSupplyRules.d.ts +0 -2
  180. package/dist/model/modelSupplyRules.js +3 -12
  181. package/dist/model/modelsPolicy.d.ts +0 -5
  182. package/dist/model/modelsPolicy.js +6 -36
  183. package/dist/model/subagentModelWord.d.ts +31 -0
  184. package/dist/model/subagentModelWord.js +261 -0
  185. package/dist/notifications.d.ts +6 -0
  186. package/dist/notifications.js +71 -23
  187. package/dist/outputStyleSeatCapability.d.ts +0 -3
  188. package/dist/outputStyleSeatCapability.js +0 -3
  189. package/dist/ownKey.d.ts +15 -0
  190. package/dist/ownKey.js +60 -3
  191. package/dist/panelReduce.d.ts +15 -9
  192. package/dist/panelReduce.js +680 -549
  193. package/dist/panelStateHolder.d.ts +3 -7
  194. package/dist/panelStateHolder.js +14 -130
  195. package/dist/peerLaneCapability.d.ts +0 -4
  196. package/dist/peerLaneCapability.js +0 -6
  197. package/dist/permissionRulesWriteCapability.d.ts +0 -4
  198. package/dist/permissionRulesWriteCapability.js +0 -6
  199. package/dist/permissionWireCaps.d.ts +2 -2
  200. package/dist/permissionWireCaps.js +2 -0
  201. package/dist/permissionsAllowGrantCapability.d.ts +0 -4
  202. package/dist/permissionsAllowGrantCapability.js +0 -6
  203. package/dist/permissionsDeclaration.d.ts +0 -11
  204. package/dist/permissionsDeclaration.js +60 -53
  205. package/dist/pluginHooksWire.d.ts +1 -1
  206. package/dist/pluginHooksWire.js +3 -6
  207. package/dist/preemptWire.d.ts +44 -0
  208. package/dist/preemptWire.js +83 -0
  209. package/dist/printToolResultFrame.js +15 -4
  210. package/dist/replayBody.d.ts +3 -0
  211. package/dist/replayBody.js +14 -0
  212. package/dist/request/taskRequest.d.ts +0 -1
  213. package/dist/request/taskRequest.js +0 -3
  214. package/dist/resumeRefusalCopy.d.ts +2 -1
  215. package/dist/resumeRefusalCopy.js +38 -2
  216. package/dist/retryStatus.d.ts +8 -0
  217. package/dist/retryStatus.js +106 -1
  218. package/dist/rewindArchiveCapability.d.ts +0 -4
  219. package/dist/rewindArchiveCapability.js +2 -10
  220. package/dist/rewindArchiveReading.d.ts +0 -1
  221. package/dist/rewindArchiveReading.js +0 -3
  222. package/dist/runCancelContext.d.ts +2 -1
  223. package/dist/runCancelContext.js +4 -2
  224. package/dist/runReattachPolicy.d.ts +31 -0
  225. package/dist/runReattachPolicy.js +46 -0
  226. package/dist/runTerminal.d.ts +3 -6
  227. package/dist/runTerminal.js +8 -9
  228. package/dist/sandboxWire.d.ts +3 -1
  229. package/dist/sandboxWire.js +76 -27
  230. package/dist/scenarioWire.js +1 -1
  231. package/dist/seam.d.ts +24 -2
  232. package/dist/seam.js +15 -3
  233. package/dist/seatContract.d.ts +53 -10
  234. package/dist/seatContract.js +132 -81
  235. package/dist/sessionPolicyCapability.d.ts +0 -4
  236. package/dist/sessionPolicyCapability.js +0 -6
  237. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
  238. package/dist/sessionSyncFileHistoryCapability.js +0 -3
  239. package/dist/skillToolListsCapability.d.ts +0 -3
  240. package/dist/skillToolListsCapability.js +0 -3
  241. package/dist/sqlEngineCapability.d.ts +0 -4
  242. package/dist/sqlEngineCapability.js +0 -6
  243. package/dist/steerPriorityCapability.d.ts +0 -3
  244. package/dist/steerPriorityCapability.js +0 -3
  245. package/dist/streamDrainingLegs.d.ts +4 -0
  246. package/dist/streamDrainingLegs.js +6 -1
  247. package/dist/subagent/engineCompactWire.d.ts +0 -1
  248. package/dist/subagent/engineCompactWire.js +7 -5
  249. package/dist/subagent/engineTaskHandleWire.js +4 -7
  250. package/dist/subagentContentStore.js +1 -11
  251. package/dist/submitReopen.d.ts +24 -0
  252. package/dist/submitReopen.js +75 -0
  253. package/dist/terminalStatuses.d.ts +3 -0
  254. package/dist/terminalStatuses.js +10 -2
  255. package/dist/toolResult.d.ts +10 -1
  256. package/dist/toolResult.js +34 -6
  257. package/dist/toolRoster.d.ts +0 -2
  258. package/dist/toolRoster.js +0 -2
  259. package/dist/turnFailurePresentation.d.ts +28 -0
  260. package/dist/turnFailurePresentation.js +205 -0
  261. package/dist/userInvokedSkillsCapability.d.ts +0 -3
  262. package/dist/userInvokedSkillsCapability.js +0 -3
  263. package/dist/webSearchBackendCapability.d.ts +0 -4
  264. package/dist/webSearchBackendCapability.js +0 -6
  265. package/dist/wireErrorTriage.js +5 -24
  266. package/dist/wireFailureShape.d.ts +62 -5
  267. package/dist/wireFailureShape.js +105 -5
  268. package/dist/wireRefusalCopy.d.ts +12 -2
  269. package/dist/wireRefusalCopy.js +50 -52
  270. package/dist/workflowsJournalCapability.d.ts +0 -4
  271. package/dist/workflowsJournalCapability.js +0 -6
  272. package/dist/writeProtectionCapability.d.ts +0 -4
  273. package/dist/writeProtectionCapability.js +0 -6
  274. package/docs/INTEGRATION-CLIENTS.md +1305 -46
  275. package/package.json +5 -4
  276. package/dist/attachmentSeatCapability.d.ts +0 -12
  277. package/dist/attachmentSeatCapability.js +0 -23
  278. package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
  279. package/dist/hitl/approvalOutcomeNote.js +0 -29
  280. package/dist/sessionReadRedactionCapability.d.ts +0 -13
  281. package/dist/sessionReadRedactionCapability.js +0 -35
@@ -1,20 +1,15 @@
1
1
  import { type SettingsAtMention } from '../generated/settingsSchemaFns.js';
2
2
  export interface CanonicalDefaultModel {
3
3
  readonly name: string;
4
- readonly from: 'default' | 'roles.default';
5
4
  }
6
5
  export type CanonicalAtMention = {
7
6
  readonly kind: 'read';
8
7
  readonly value: SettingsAtMention;
9
- readonly from: 'atMention' | 'atModelAllowlist';
10
- readonly unreadableEntries: number;
11
8
  } | {
12
9
  readonly kind: 'unreadable';
13
- readonly from: 'atMention' | 'atModelAllowlist';
14
10
  };
15
11
  export interface CanonicalModelsPolicy {
16
12
  readonly defaultModel?: CanonicalDefaultModel;
17
- readonly defaultUnreadable?: true;
18
13
  readonly atMention?: CanonicalAtMention;
19
14
  readonly unreadable?: true;
20
15
  }
@@ -34,53 +34,23 @@ function atMentionOf(v) {
34
34
  return undefined;
35
35
  }
36
36
  }
37
- function atModelAllowlistOf(v) {
38
- if (!Array.isArray(v))
39
- return { kind: 'unreadable', from: 'atModelAllowlist' };
40
- const names = [];
41
- let bad = 0;
42
- for (let i = 0; i < v.length; i += 1) {
43
- const d = Object.getOwnPropertyDescriptor(v, i);
44
- const x = d !== undefined && 'value' in d ? d.value : undefined;
45
- if (typeof x === 'string' && x.length > 0)
46
- names.push(x);
47
- else
48
- bad += 1;
49
- }
50
- const value = names.length > 0 ? { mode: 'only', models: names } : { mode: 'all' };
51
- return { kind: 'read', value, from: 'atModelAllowlist', unreadableEntries: bad };
52
- }
53
37
  export function modelsPolicyOf(doc) {
54
38
  try {
55
39
  if (!isRecord(doc))
56
40
  return {};
57
41
  let defaultModel;
58
- let defaultUnreadable = false;
59
- if (Object.hasOwn(doc, 'default')) {
60
- const d = ownData(doc, 'default');
61
- if (typeof d === 'string' && d.length > 0)
62
- defaultModel = { name: d, from: 'default' };
63
- else
64
- defaultUnreadable = true;
65
- }
66
- if (defaultModel === undefined && !defaultUnreadable) {
67
- const roles = ownData(doc, 'roles');
68
- const rd = isRecord(roles) ? ownData(roles, 'default') : undefined;
69
- const model = isRecord(rd) ? ownData(rd, 'model') : undefined;
70
- if (typeof model === 'string' && model.length > 0)
71
- defaultModel = { name: model, from: 'roles.default' };
72
- }
42
+ const roles = ownData(doc, 'roles');
43
+ const rd = isRecord(roles) ? ownData(roles, 'default') : undefined;
44
+ const model = isRecord(rd) ? ownData(rd, 'model') : undefined;
45
+ if (typeof model === 'string' && model.length > 0)
46
+ defaultModel = { name: model };
73
47
  let atMention;
74
48
  if (Object.hasOwn(doc, 'atMention')) {
75
49
  const am = atMentionOf(ownData(doc, 'atMention'));
76
- atMention = am === undefined ? { kind: 'unreadable', from: 'atMention' } : { kind: 'read', value: am, from: 'atMention', unreadableEntries: 0 };
77
- }
78
- else if (Object.hasOwn(doc, 'atModelAllowlist')) {
79
- atMention = atModelAllowlistOf(ownData(doc, 'atModelAllowlist'));
50
+ atMention = am === undefined ? { kind: 'unreadable' } : { kind: 'read', value: am };
80
51
  }
81
52
  return {
82
53
  ...(defaultModel !== undefined ? { defaultModel } : {}),
83
- ...(defaultUnreadable ? { defaultUnreadable: true } : {}),
84
54
  ...(atMention !== undefined ? { atMention } : {}),
85
55
  };
86
56
  }
@@ -0,0 +1,31 @@
1
+ import { type LiveModelCatalog } from '../liveModelCatalog.js';
2
+ import type { UiLanguage } from '../env/uiLanguage.js';
3
+ export type SubagentModelWordKind = 'inherit' | 'catalog' | 'tier' | 'cc-alias' | 'best' | 'model-id' | 'passthrough' | 'catalog-unknown' | 'ambiguous' | 'unbound';
4
+ export type SubagentModelWordProblem = 'tiers-inert' | 'chain-unbound' | 'binding-not-in-catalog';
5
+ export interface SubagentModelLocalEngine {
6
+ readonly engine: 'started-by-this-process';
7
+ readonly tiers: Readonly<Record<string, string>> | undefined;
8
+ readonly pool?: readonly {
9
+ readonly name: string;
10
+ readonly id?: string;
11
+ }[];
12
+ }
13
+ export interface SubagentModelWordInput {
14
+ readonly word?: string | null | undefined;
15
+ readonly liveCatalog?: LiveModelCatalog | null | undefined;
16
+ readonly local?: SubagentModelLocalEngine | null | undefined;
17
+ }
18
+ export interface SubagentModelLanding {
19
+ readonly name: string;
20
+ readonly via: readonly string[];
21
+ readonly source: 'local-config';
22
+ }
23
+ export interface SubagentModelWordReading {
24
+ readonly kind: SubagentModelWordKind;
25
+ readonly model?: string;
26
+ readonly landing?: SubagentModelLanding;
27
+ readonly problem?: SubagentModelWordProblem;
28
+ readonly label?: string;
29
+ }
30
+ export declare function resolveSubagentModelWord(input: SubagentModelWordInput | null | undefined): SubagentModelWordReading;
31
+ export declare function subagentModelWordProblemLine(word: string, reading: SubagentModelWordReading, lang?: UiLanguage): string | undefined;
@@ -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
+ }
@@ -32,6 +32,12 @@ export interface TranscriptNotificationSeeds {
32
32
  seeded: number;
33
33
  }
34
34
  export declare function parseTranscriptNotificationSeeds(messages: ReadonlyArray<unknown>): TranscriptNotificationSeeds;
35
+ export interface TaskNotificationXmlRead {
36
+ readonly taskId?: string;
37
+ readonly status?: string;
38
+ readonly external: boolean;
39
+ }
40
+ export declare function readTaskNotificationXml(xml: string): TaskNotificationXmlRead | undefined;
35
41
  export interface QueuedCommandLike {
36
42
  mode?: unknown;
37
43
  agentId?: unknown;
@@ -91,12 +91,6 @@ export function taskNotificationDedupKeyFromWire(n) {
91
91
  });
92
92
  }
93
93
  export function parseTranscriptNotificationSeeds(messages) {
94
- const unescape = (s) => s
95
- .replace(/&lt;/g, '<')
96
- .replace(/&gt;/g, '>')
97
- .replace(/&quot;/g, '"')
98
- .replace(/&#39;/g, "'")
99
- .replace(/&amp;/g, '&');
100
94
  const renderedKeys = [];
101
95
  const notifiedKeys = [];
102
96
  let seeded = 0;
@@ -116,24 +110,13 @@ export function parseTranscriptNotificationSeeds(messages) {
116
110
  }
117
111
  }
118
112
  for (const text of texts) {
119
- if (!text.includes(`<${TASK_NOTIFICATION_TAG}`))
120
- continue;
121
- const blockRe = new RegExp(`<${TASK_NOTIFICATION_TAG}(\\s[^>]*)?>([\\s\\S]*?)</${TASK_NOTIFICATION_TAG}>`, 'g');
122
- for (const bm of text.matchAll(blockRe)) {
123
- const attrs = bm[1] ?? '';
124
- const body = bm[2] ?? '';
125
- const idM = body.match(new RegExp(`<${TASK_ID_TAG}>([\\s\\S]*?)</${TASK_ID_TAG}>`));
126
- const stM = body.match(new RegExp(`<${STATUS_TAG}>([\\s\\S]*?)</${STATUS_TAG}>`));
127
- if (!idM || !stM)
128
- continue;
129
- const taskId = unescape(idM[1] ?? '');
130
- const status = unescape(stM[1] ?? '');
131
- if (taskId.length === 0 || status.length === 0)
113
+ for (const block of scanTaskNotificationBlocks(text)) {
114
+ const read = readTaskNotificationBlock(block);
115
+ if (read.taskId === undefined || read.status === undefined)
132
116
  continue;
133
- const external = /\btype="external"/.test(attrs);
134
- renderedKeys.push(`${external ? 'external:' : ''}${taskId}:${status}`);
135
- if (!external && isCoreTaskNotificationTerminal(status)) {
136
- notifiedKeys.push(taskId);
117
+ renderedKeys.push(`${read.external ? 'external:' : ''}${read.taskId}:${read.status}`);
118
+ if (!read.external && isCoreTaskNotificationTerminal(read.status)) {
119
+ notifiedKeys.push(read.taskId);
137
120
  }
138
121
  seeded++;
139
122
  }
@@ -141,6 +124,71 @@ export function parseTranscriptNotificationSeeds(messages) {
141
124
  }
142
125
  return { renderedKeys, notifiedKeys, seeded };
143
126
  }
127
+ export function readTaskNotificationXml(xml) {
128
+ if (typeof xml !== 'string')
129
+ return undefined;
130
+ for (const block of scanTaskNotificationBlocks(xml))
131
+ return readTaskNotificationBlock(block);
132
+ return undefined;
133
+ }
134
+ function unescapeNotificationXml(s) {
135
+ return s
136
+ .replace(/&lt;/g, '<')
137
+ .replace(/&gt;/g, '>')
138
+ .replace(/&quot;/g, '"')
139
+ .replace(/&#39;/g, "'")
140
+ .replace(/&amp;/g, '&');
141
+ }
142
+ function* scanTaskNotificationBlocks(text) {
143
+ const open = `<${TASK_NOTIFICATION_TAG}`;
144
+ const close = `</${TASK_NOTIFICATION_TAG}>`;
145
+ let from = 0;
146
+ for (;;) {
147
+ const i = text.indexOf(open, from);
148
+ if (i < 0)
149
+ return;
150
+ const after = i + open.length;
151
+ const c = text.charAt(after);
152
+ let gt;
153
+ if (c === '>') {
154
+ gt = after;
155
+ }
156
+ else if (c !== '' && /\s/.test(c)) {
157
+ gt = text.indexOf('>', after + 1);
158
+ if (gt < 0)
159
+ return;
160
+ }
161
+ else {
162
+ from = i + 1;
163
+ continue;
164
+ }
165
+ const end = text.indexOf(close, gt + 1);
166
+ if (end < 0)
167
+ return;
168
+ yield { attrs: c === '>' ? '' : text.slice(after, gt), body: text.slice(gt + 1, end) };
169
+ from = end + close.length;
170
+ }
171
+ }
172
+ function firstTagBodyOf(body, tag) {
173
+ const open = `<${tag}>`;
174
+ const i = body.indexOf(open);
175
+ if (i < 0)
176
+ return undefined;
177
+ const start = i + open.length;
178
+ const end = body.indexOf(`</${tag}>`, start);
179
+ return end < 0 ? undefined : body.slice(start, end);
180
+ }
181
+ function readTaskNotificationBlock(block) {
182
+ const idRaw = firstTagBodyOf(block.body, TASK_ID_TAG);
183
+ const statusRaw = firstTagBodyOf(block.body, STATUS_TAG);
184
+ const taskId = idRaw === undefined ? '' : unescapeNotificationXml(idRaw);
185
+ const status = statusRaw === undefined ? '' : unescapeNotificationXml(statusRaw);
186
+ return {
187
+ ...(taskId.length > 0 ? { taskId } : {}),
188
+ ...(status.length > 0 ? { status } : {}),
189
+ external: /\btype="external"/.test(block.attrs),
190
+ };
191
+ }
144
192
  const TASK_NOTIFICATION_TAG = 'task-notification';
145
193
  const TASK_ID_TAG = 'task-id';
146
194
  const STATUS_TAG = 'status';
@@ -9,8 +9,5 @@ export type OutputStyleSeatReading = {
9
9
  value: true;
10
10
  };
11
11
  export declare function projectOutputStyleSeatCapability(caps: unknown): OutputStyleSeatReading | undefined;
12
- export declare function noteEngineCapsForOutputStyleSeat(baseUrl: string, caps: unknown, opts?: {
13
- generation?: number;
14
- }): void;
15
12
  export declare function observedOutputStyleSeat(baseUrl?: string | undefined): OutputStyleSeatReading;
16
13
  export declare function outputStyleSeatAdmitted(reading: OutputStyleSeatReading | undefined): boolean;
@@ -18,9 +18,6 @@ const reader = createEngineCapReader({
18
18
  name: 'outputStyleSeat',
19
19
  project: projectOutputStyleSeatCapability,
20
20
  });
21
- export function noteEngineCapsForOutputStyleSeat(baseUrl, caps, opts) {
22
- reader.note(baseUrl, caps, opts);
23
- }
24
21
  export function observedOutputStyleSeat(baseUrl = engineWireTarget()?.baseUrl) {
25
22
  return reader.observed(baseUrl);
26
23
  }
package/dist/ownKey.d.ts CHANGED
@@ -2,6 +2,7 @@ export declare function putOwnKey<T>(table: Record<string, T>, key: string, valu
2
2
  export declare function readOwnNonEmptyString(v: object | null | undefined, key: string): string | undefined;
3
3
  export declare function readAskOrigin(carrier: object | null | undefined): string | undefined;
4
4
  export declare function readOwnDataNonEmptyString(v: object | null | undefined, key: string): string | undefined;
5
+ export declare function readOwnDataFiniteNumber(v: object | null | undefined, key: string): number | undefined;
5
6
  export declare function readOwnDataValue<T>(v: object | null | undefined, key: string): T | undefined;
6
7
  export declare function guardedRead<T>(read: () => T | undefined): T | undefined;
7
8
  export declare function ownDataField(v: object, key: string): unknown;
@@ -9,5 +10,19 @@ export declare function ownSendableField(v: object, key: string): unknown;
9
10
  export declare function ownDataRefusalKeyOf(e: unknown): string | undefined;
10
11
  export declare function readFrameStringKey(frame: unknown, key: string): string | undefined;
11
12
  export declare function readFrameTrueMark(frame: object | null | undefined, key: string): boolean;
13
+ export type FrameTrueMarkReading = 'marked' | 'absent' | 'unreadable';
14
+ export declare function readFrameTrueMarkReading(frame: object | null | undefined, key: string): FrameTrueMarkReading;
15
+ export interface ContextUsageSectionRow {
16
+ id: string;
17
+ tokens: number;
18
+ kind?: string;
19
+ }
20
+ export interface ContextUsageReading {
21
+ usedTokens?: number;
22
+ windowTokens?: number;
23
+ compactAtTokens?: number;
24
+ sections?: readonly ContextUsageSectionRow[];
25
+ }
26
+ export declare function contextUsageReadingOf(payload: {} | null | undefined): ContextUsageReading | undefined;
12
27
  export declare function markMcpSectionDroppedNamedRows(rows: object, dropped: ReadonlyMap<string, number>): void;
13
28
  export declare function mcpSectionDroppedNamedRowsOf(rows: object | null | undefined, name: string): number;
package/dist/ownKey.js CHANGED
@@ -19,6 +19,15 @@ export function readOwnDataNonEmptyString(v, key) {
19
19
  const raw = d.value;
20
20
  return typeof raw === 'string' && raw !== '' ? raw : undefined;
21
21
  }
22
+ export function readOwnDataFiniteNumber(v, key) {
23
+ if (typeof v !== 'object' || v === null)
24
+ return undefined;
25
+ const d = Object.getOwnPropertyDescriptor(v, key);
26
+ if (d === undefined || !Object.hasOwn(d, 'value'))
27
+ return undefined;
28
+ const raw = d.value;
29
+ return typeof raw === 'number' && Number.isFinite(raw) ? raw : undefined;
30
+ }
22
31
  export function readOwnDataValue(v, key) {
23
32
  if (typeof v !== 'object' || v === null)
24
33
  return undefined;
@@ -65,13 +74,61 @@ export function readFrameStringKey(frame, key) {
65
74
  }
66
75
  }
67
76
  export function readFrameTrueMark(frame, key) {
77
+ return readFrameTrueMarkReading(frame, key) === 'marked';
78
+ }
79
+ export function readFrameTrueMarkReading(frame, key) {
68
80
  try {
69
81
  if (frame === null || frame === undefined || typeof frame !== 'object' || Array.isArray(frame))
70
- return false;
71
- return ownDataField(frame, key) === true;
82
+ return 'absent';
83
+ return ownDataField(frame, key) === true ? 'marked' : 'absent';
84
+ }
85
+ catch {
86
+ return 'unreadable';
87
+ }
88
+ }
89
+ const CONTEXT_USAGE_SECTION_ROWS_MAX = 1024;
90
+ function contextUsageSectionRowOf(raw, i) {
91
+ const row = readOwnDataValue(raw, String(i));
92
+ if (typeof row !== 'object' || row === null || Array.isArray(row))
93
+ return undefined;
94
+ const id = readOwnDataNonEmptyString(row, 'id');
95
+ const tokens = readOwnDataFiniteNumber(row, 'tokens');
96
+ if (id === undefined || tokens === undefined)
97
+ return undefined;
98
+ const kind = readOwnDataNonEmptyString(row, 'kind');
99
+ return { id, tokens, ...(kind !== undefined ? { kind } : {}) };
100
+ }
101
+ function contextUsageSectionRowsOf(raw) {
102
+ if (!Array.isArray(raw))
103
+ return undefined;
104
+ const n = Math.min(raw.length, CONTEXT_USAGE_SECTION_ROWS_MAX);
105
+ const rows = [];
106
+ for (let i = 0; i < n; i++) {
107
+ const row = guardedRead(() => contextUsageSectionRowOf(raw, i));
108
+ if (row !== undefined)
109
+ rows.push(row);
110
+ }
111
+ return rows.length > 0 ? rows : undefined;
112
+ }
113
+ export function contextUsageReadingOf(payload) {
114
+ try {
115
+ if (typeof payload !== 'object' || payload === null || Array.isArray(payload))
116
+ return undefined;
117
+ const usedTokens = guardedRead(() => readOwnDataFiniteNumber(payload, 'usedTokens'));
118
+ const windowTokens = guardedRead(() => readOwnDataFiniteNumber(payload, 'windowTokens'));
119
+ const compactAtTokens = guardedRead(() => readOwnDataFiniteNumber(payload, 'compactAtTokens'));
120
+ const sections = guardedRead(() => contextUsageSectionRowsOf(readOwnDataValue(payload, 'sections')));
121
+ if (usedTokens === undefined && windowTokens === undefined && compactAtTokens === undefined && sections === undefined)
122
+ return undefined;
123
+ return {
124
+ ...(usedTokens !== undefined ? { usedTokens } : {}),
125
+ ...(windowTokens !== undefined ? { windowTokens } : {}),
126
+ ...(compactAtTokens !== undefined ? { compactAtTokens } : {}),
127
+ ...(sections !== undefined ? { sections } : {}),
128
+ };
72
129
  }
73
130
  catch {
74
- return false;
131
+ return undefined;
75
132
  }
76
133
  }
77
134
  const DROPPED_NAMED_ROWS = Symbol.for('@sema-agent/client-core/mcpSectionDroppedNamedRows');