@sema-agent/client-core 0.110.0 → 0.112.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 (243) hide show
  1. package/CHANGELOG.md +244 -0
  2. package/README.md +59 -18
  3. package/dist/abortableSleep.d.ts +7 -0
  4. package/dist/abortableSleep.js +37 -0
  5. package/dist/adapt/arms.js +25 -4
  6. package/dist/adapt/toolCards.d.ts +3 -1
  7. package/dist/adapt/toolCards.js +4 -2
  8. package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
  9. package/dist/adapter/activeRunSelfHeal.js +171 -3
  10. package/dist/adapter/downstream/eventToSdkMessage.js +10 -10
  11. package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
  12. package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
  13. package/dist/adapter/runStream.d.ts +5 -0
  14. package/dist/adapter/runStream.js +15 -3
  15. package/dist/agentSession/engineSessionBackgroundStop.js +2 -2
  16. package/dist/attachmentRoute.d.ts +20 -0
  17. package/dist/attachmentRoute.js +39 -0
  18. package/dist/attachmentsWireCaps.js +1 -1
  19. package/dist/builtinOutputStyles.d.ts +12 -0
  20. package/dist/builtinOutputStyles.js +147 -0
  21. package/dist/checkpointRowVerdict.d.ts +3 -0
  22. package/dist/checkpointRowVerdict.js +14 -1
  23. package/dist/compactionStatus.d.ts +9 -0
  24. package/dist/compactionStatus.js +29 -5
  25. package/dist/consoleCaPin.d.ts +136 -0
  26. package/dist/consoleCaPin.js +827 -0
  27. package/dist/controlRouter.js +2 -1
  28. package/dist/coreValuePorts.d.ts +39 -1
  29. package/dist/coreValuePorts.js +10 -0
  30. package/dist/decideReceipt.d.ts +2 -1
  31. package/dist/deviceRebind.js +3 -3
  32. package/dist/displayUntrusted.d.ts +1 -0
  33. package/dist/displayUntrusted.js +6 -0
  34. package/dist/effectiveFacts.d.ts +9 -0
  35. package/dist/effectiveFacts.js +33 -0
  36. package/dist/engineAddress.d.ts +1 -0
  37. package/dist/engineAddress.js +4 -1
  38. package/dist/engineCredentialRelease.d.ts +54 -0
  39. package/dist/engineCredentialRelease.js +146 -0
  40. package/dist/engineErrorCodes.d.ts +1 -0
  41. package/dist/engineErrorCodes.js +1 -0
  42. package/dist/engineHealthProbeVerdict.d.ts +24 -0
  43. package/dist/engineHealthProbeVerdict.js +123 -0
  44. package/dist/engineNoticeCodes.js +5 -7
  45. package/dist/engineRepoint.d.ts +12 -5
  46. package/dist/engineRepoint.js +44 -19
  47. package/dist/engineRowRef.d.ts +3 -0
  48. package/dist/engineRowRef.js +11 -1
  49. package/dist/engineSwapCrossing.d.ts +57 -0
  50. package/dist/engineSwapCrossing.js +297 -0
  51. package/dist/engineUnavailable.d.ts +45 -0
  52. package/dist/engineUnavailable.js +496 -0
  53. package/dist/engineUrl.js +4 -2
  54. package/dist/eventLeg.js +3 -3
  55. package/dist/gateFailureCodes.js +2 -2
  56. package/dist/generated/sdkFactTables.d.ts +2 -1
  57. package/dist/generated/sdkFactTables.js +14 -0
  58. package/dist/generated/settingsSchemaFns.d.ts +1 -0
  59. package/dist/generated/settingsSchemaFns.js +3 -0
  60. package/dist/generated/settingsSchemaHooksClassifier.js +38 -9
  61. package/dist/generated/settingsSchemaTables.d.ts +56 -0
  62. package/dist/generated/settingsSchemaTables.js +19 -0
  63. package/dist/generated/settingsSchemaTypes.d.ts +23 -13
  64. package/dist/generated/settingsSchemaUrlShape.d.ts +1 -0
  65. package/dist/generated/settingsSchemaUrlShape.js +17 -0
  66. package/dist/hitl/approvalDelivery.d.ts +1 -0
  67. package/dist/hitl/approvalDelivery.js +1 -1
  68. package/dist/hitl/approvalResolution.d.ts +1 -1
  69. package/dist/hitl/approvalResolution.js +2 -1
  70. package/dist/hitl/askGateWire.js +5 -6
  71. package/dist/hitl/decisionRefusal.d.ts +6 -0
  72. package/dist/hitl/decisionRefusal.js +19 -10
  73. package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
  74. package/dist/hitl/decisionRefusalCarrier.js +348 -0
  75. package/dist/hitl/decisionSend.d.ts +7 -0
  76. package/dist/hitl/decisionSend.js +34 -12
  77. package/dist/hitl/editedApprovalAcceptance.js +1 -1
  78. package/dist/hitl/elicitationRefusal.d.ts +4 -0
  79. package/dist/hitl/elicitationRefusal.js +23 -0
  80. package/dist/hitl/frameRouter.d.ts +2 -2
  81. package/dist/hitl/frameRouter.js +8 -15
  82. package/dist/hitl/gateIdentity.d.ts +5 -0
  83. package/dist/hitl/gateIdentity.js +23 -0
  84. package/dist/hitl/hitlBridge.d.ts +6 -0
  85. package/dist/hitl/hitlBridge.js +10 -4
  86. package/dist/hitl/hitlHostSurface.d.ts +2 -1
  87. package/dist/hitl/hitlHostSurface.js +7 -2
  88. package/dist/hitl/localAllowRedemption.d.ts +70 -0
  89. package/dist/hitl/localAllowRedemption.js +276 -0
  90. package/dist/hitl/parkOwnership.js +2 -1
  91. package/dist/hitl/parkResolver.js +14 -4
  92. package/dist/hitl/persistedRulesWire.d.ts +16 -0
  93. package/dist/hitl/persistedRulesWire.js +70 -0
  94. package/dist/hitl/planReviewWire.d.ts +3 -0
  95. package/dist/hitl/planReviewWire.js +23 -6
  96. package/dist/hitl/policyDenyCause.d.ts +1 -1
  97. package/dist/hitl/policyDenyCause.js +1 -1
  98. package/dist/hitl/resumeRunningCard.d.ts +1 -0
  99. package/dist/hitl/resumeRunningCard.js +1 -0
  100. package/dist/hitl/screenCardCarriers.d.ts +15 -0
  101. package/dist/hitl/screenCardCarriers.js +41 -0
  102. package/dist/hitl/screenDecisionCards.d.ts +98 -0
  103. package/dist/hitl/screenDecisionCards.js +363 -0
  104. package/dist/hitl/sessionPolicyWire.js +2 -2
  105. package/dist/hitl/standingRows.d.ts +6 -2
  106. package/dist/hitl/standingRows.js +27 -2
  107. package/dist/hitl/toolApprovalWire.d.ts +30 -8
  108. package/dist/hitl/toolApprovalWire.js +264 -121
  109. package/dist/hooksReaderGenerations.js +1 -1
  110. package/dist/hooksWireCaps.js +3 -3
  111. package/dist/hostSettingNoticeArm.d.ts +3 -0
  112. package/dist/hostSettingNoticeArm.js +12 -0
  113. package/dist/hostTurnSettings.d.ts +3 -0
  114. package/dist/hostTurnSettings.js +38 -5
  115. package/dist/humanTurnRead.js +11 -1
  116. package/dist/i18n/messages.en.d.ts +292 -0
  117. package/dist/i18n/messages.en.js +298 -7
  118. package/dist/i18n/messages.zh.js +316 -6
  119. package/dist/i18n/translate.d.ts +3 -0
  120. package/dist/i18n/translate.js +78 -10
  121. package/dist/i18n/zh.d.ts +1 -0
  122. package/dist/i18n/zh.js +1 -0
  123. package/dist/index.d.ts +71 -20
  124. package/dist/index.js +44 -13
  125. package/dist/interactiveHalt.js +2 -1
  126. package/dist/interactiveInterrupt.js +20 -2
  127. package/dist/liveModelCatalog.d.ts +4 -0
  128. package/dist/liveModelCatalog.js +12 -3
  129. package/dist/localConfig/documents.d.ts +61 -0
  130. package/dist/localConfig/documents.js +51 -0
  131. package/dist/localConfig/kernel.d.ts +149 -0
  132. package/dist/localConfig/kernel.js +597 -0
  133. package/dist/localConfig/mcp/edit.d.ts +161 -0
  134. package/dist/localConfig/mcp/edit.js +846 -0
  135. package/dist/localConfig/mcp/servers.d.ts +165 -0
  136. package/dist/localConfig/mcp/servers.js +776 -0
  137. package/dist/localConfig/mcp/views.d.ts +170 -0
  138. package/dist/localConfig/mcp/views.js +429 -0
  139. package/dist/localConfig/modelPool.d.ts +262 -0
  140. package/dist/localConfig/modelPool.js +1489 -0
  141. package/dist/localConfig/modelPoolWords.d.ts +13 -0
  142. package/dist/localConfig/modelPoolWords.js +20 -0
  143. package/dist/localConfig/receiptShape.d.ts +7 -0
  144. package/dist/localConfig/receiptShape.js +135 -0
  145. package/dist/localConfig/settingsWrite.d.ts +127 -0
  146. package/dist/localConfig/settingsWrite.js +237 -0
  147. package/dist/localConfig/skills.d.ts +124 -0
  148. package/dist/localConfig/skills.js +397 -0
  149. package/dist/localConfig/skillsWords.d.ts +10 -0
  150. package/dist/localConfig/skillsWords.js +5 -0
  151. package/dist/localEngineSeatReading.d.ts +2 -2
  152. package/dist/localEngineSeatReading.js +5 -3
  153. package/dist/localEngineSpawn.d.ts +0 -7
  154. package/dist/localEngineSpawn.js +0 -92
  155. package/dist/localEngineStep.d.ts +2 -2
  156. package/dist/localEngineStep.js +2 -0
  157. package/dist/mcpProbeWire.js +2 -1
  158. package/dist/mcpReconnect.js +3 -3
  159. package/dist/mcpWireCaps.js +1 -1
  160. package/dist/memoryVerbsWire.js +3 -2
  161. package/dist/model/engineModelWords.d.ts +3 -0
  162. package/dist/model/engineModelWords.js +13 -0
  163. package/dist/model/onboardJudgement.d.ts +14 -4
  164. package/dist/model/onboardJudgement.js +91 -139
  165. package/dist/model/subagentModelWord.d.ts +21 -2
  166. package/dist/model/subagentModelWord.js +100 -29
  167. package/dist/modelCapabilityProbe.js +3 -40
  168. package/dist/modelConfigGapNotice.d.ts +20 -0
  169. package/dist/modelConfigGapNotice.js +102 -0
  170. package/dist/modsKernelIdentity.js +2 -47
  171. package/dist/notifications.d.ts +19 -0
  172. package/dist/notifications.js +114 -12
  173. package/dist/ownKey.d.ts +7 -0
  174. package/dist/ownKey.js +71 -8
  175. package/dist/pendingUserRow.d.ts +4 -0
  176. package/dist/pendingUserRow.js +16 -0
  177. package/dist/permissionsDeclaration.d.ts +3 -1
  178. package/dist/permissionsDeclaration.js +33 -9
  179. package/dist/planReviewCardFacts.d.ts +3 -0
  180. package/dist/planReviewCardFacts.js +52 -2
  181. package/dist/pluginHooksWire.d.ts +9 -1
  182. package/dist/pluginHooksWire.js +40 -6
  183. package/dist/printToolResultFrame.js +4 -2
  184. package/dist/promptBlockedCopy.js +12 -7
  185. package/dist/promptSuggestionBatch.d.ts +7 -0
  186. package/dist/promptSuggestionBatch.js +9 -0
  187. package/dist/promptSuggestionsTail.d.ts +39 -0
  188. package/dist/promptSuggestionsTail.js +116 -0
  189. package/dist/request/taskRequest.js +10 -6
  190. package/dist/requestCoordinate.d.ts +1 -0
  191. package/dist/requestCoordinate.js +13 -0
  192. package/dist/resumeRefusalCopy.d.ts +3 -1
  193. package/dist/resumeRefusalCopy.js +12 -4
  194. package/dist/rewindArchiveReading.js +4 -4
  195. package/dist/runCancelContext.d.ts +2 -1
  196. package/dist/runCancelContext.js +1 -0
  197. package/dist/runLedgerSnapshot.js +3 -3
  198. package/dist/runPermissionModeSwitch.js +3 -4
  199. package/dist/scenarioRefusal.js +11 -13
  200. package/dist/scenarioSkills.js +11 -6
  201. package/dist/seam.d.ts +16 -2
  202. package/dist/seam.js +10 -0
  203. package/dist/seatContract.d.ts +259 -9
  204. package/dist/seatContract.js +444 -15
  205. package/dist/sessionCostReading.d.ts +70 -0
  206. package/dist/sessionCostReading.js +150 -0
  207. package/dist/sessionHooksRoster.d.ts +4 -0
  208. package/dist/sessionHooksRoster.js +158 -0
  209. package/dist/sessionIdSegment.d.ts +1 -0
  210. package/dist/sessionIdSegment.js +4 -1
  211. package/dist/sessionMemoryErase.js +2 -1
  212. package/dist/sessionMemoryStatus.js +2 -2
  213. package/dist/sessionReadRedaction.d.ts +7 -0
  214. package/dist/sessionReadRedaction.js +26 -0
  215. package/dist/sessionSyncFileHistory.js +8 -9
  216. package/dist/settingsHooksSalvage.js +2 -1
  217. package/dist/sha256Bytes.d.ts +1 -0
  218. package/dist/sha256Bytes.js +46 -0
  219. package/dist/skillOverrideChain.d.ts +83 -0
  220. package/dist/skillOverrideChain.js +378 -0
  221. package/dist/skillsWireCaps.d.ts +3 -0
  222. package/dist/skillsWireCaps.js +16 -1
  223. package/dist/sseIdleTriage.js +2 -1
  224. package/dist/storeDurabilityWord.d.ts +15 -0
  225. package/dist/storeDurabilityWord.js +18 -0
  226. package/dist/storePostureCapability.d.ts +7 -3
  227. package/dist/storePostureCapability.js +69 -39
  228. package/dist/subagent/engineSubagentResume.js +2 -2
  229. package/dist/subagent/engineSubagentTail.js +2 -1
  230. package/dist/subagentContentStore.d.ts +11 -0
  231. package/dist/subagentContentStore.js +28 -2
  232. package/dist/toolResult.d.ts +1 -0
  233. package/dist/toolResult.js +2 -0
  234. package/dist/turnFailurePresentation.js +4 -10
  235. package/dist/userAttachmentEnvelope.d.ts +2 -1
  236. package/dist/userAttachmentEnvelope.js +10 -0
  237. package/dist/wireErrorTriage.js +2 -1
  238. package/dist/wireFailureShape.d.ts +4 -0
  239. package/dist/wireFailureShape.js +141 -19
  240. package/dist/wireRefusalCopy.d.ts +6 -5
  241. package/dist/wireRefusalCopy.js +49 -92
  242. package/docs/INTEGRATION-CLIENTS.md +2718 -17
  243. package/package.json +7 -3
@@ -0,0 +1,397 @@
1
+ import { SETTINGS_IS_RESERVED_MEMBER_NAME } from '../generated/settingsSchemaFns.js';
2
+ import { readOwnDataValue, appendOwnElement } from '../ownKey.js';
3
+ import { SKILL_OVERRIDE_STATES, effectiveOfShaped, lockOfShaped, lowerTierOf, ownValueIn, secondaryNamesOf, bareNameOf, shapeSkillLayers, shapeSkillSubject, stateAt, withLayerDoc, } from '../skillOverrideChain.js';
4
+ import { settingsWritePlan } from './settingsWrite.js';
5
+ import { isDotSegment } from '../sessionIdSegment.js';
6
+ import { slotReadOf } from '../wireFailureShape.js';
7
+ import { SKILL_ROOT_LAYERS, SKILL_ROOT_KINDS, SKILL_OVERRIDE_SCOPES } from './skillsWords.js';
8
+ function own(v, key) {
9
+ if (typeof v !== 'object' || v === null)
10
+ return undefined;
11
+ try {
12
+ return readOwnDataValue(v, key);
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ }
18
+ const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
19
+ const LIST_BUDGET = 4096;
20
+ function listOf(v) {
21
+ if (!Array.isArray(v))
22
+ return [];
23
+ const n = own(v, 'length');
24
+ if (typeof n !== 'number' || !Number.isSafeInteger(n) || n < 0 || n > LIST_BUDGET)
25
+ return [];
26
+ const out = [];
27
+ for (let i = 0; i < n; i++)
28
+ out.push(own(v, String(i)));
29
+ return out;
30
+ }
31
+ const TRUST_LAYERS = ['project', 'additional'];
32
+ function pathFormOf(raw) {
33
+ if (typeof raw !== 'string' || raw === '' || raw.length > 4096 || raw.includes('\u0000'))
34
+ return undefined;
35
+ const sep = raw.includes('\\') && !raw.includes('/') ? '\\' : '/';
36
+ let floor;
37
+ if (raw.startsWith('/'))
38
+ floor = '/';
39
+ else if (/^[A-Za-z]:[\\/]/.test(raw))
40
+ floor = raw.slice(0, 3);
41
+ else if (/^\\\\[^\\/]+[\\/][^\\/]+/.test(raw))
42
+ floor = raw.match(/^\\\\[^\\/]+[\\/][^\\/]+/)[0];
43
+ else
44
+ return undefined;
45
+ let path = raw;
46
+ while (path.length > floor.length && (path.endsWith('/') || path.endsWith('\\')))
47
+ path = path.slice(0, -1);
48
+ const rest = path.slice(floor.length);
49
+ if (rest !== '' && rest.split(/[\\/]/).some((seg) => seg === '' || isDotSegment(seg)))
50
+ return undefined;
51
+ return { sep, path, floor };
52
+ }
53
+ const joinPath = (f, ...segs) => (f.path === f.floor && /[\\/]$/.test(f.floor) ? f.path + segs.join(f.sep) : [f.path, ...segs].join(f.sep));
54
+ function parentOf(f) {
55
+ if (f.path.length <= f.floor.length)
56
+ return undefined;
57
+ const i = Math.max(f.path.lastIndexOf('/'), f.path.lastIndexOf('\\'));
58
+ if (i < f.floor.length - 1)
59
+ return undefined;
60
+ const up = i < f.floor.length ? f.floor : f.path.slice(0, i);
61
+ return { sep: f.sep, path: up, floor: f.floor };
62
+ }
63
+ export function skillRootsOf(cwd, hostFacts) {
64
+ try {
65
+ const here = pathFormOf(cwd);
66
+ const home = pathFormOf(own(hostFacts, 'configHome'));
67
+ if (here === undefined || home === undefined)
68
+ return undefined;
69
+ const levels = [here];
70
+ const gitRaw = own(hostFacts, 'gitRoot');
71
+ const git = gitRaw === null || gitRaw === undefined ? undefined : pathFormOf(gitRaw);
72
+ if (git !== undefined) {
73
+ const chain = [];
74
+ let at = here;
75
+ while (at !== undefined) {
76
+ chain.push(at);
77
+ if (at.path === git.path)
78
+ break;
79
+ at = parentOf(at);
80
+ }
81
+ if (at !== undefined && at.path === git.path)
82
+ levels.splice(0, levels.length, ...chain);
83
+ }
84
+ const managed = pathFormOf(own(hostFacts, 'managedDir'));
85
+ const extra = listOf(own(hostFacts, 'additionalDirectories')).map(pathFormOf).filter((f) => f !== undefined);
86
+ const plugins = [];
87
+ for (const p of listOf(own(hostFacts, 'plugins'))) {
88
+ const name = own(p, 'name');
89
+ const root = pathFormOf(own(p, 'root'));
90
+ if (typeof name === 'string' && name !== '' && root !== undefined)
91
+ plugins.push({ name, root });
92
+ }
93
+ const column = (kind) => {
94
+ const out = [];
95
+ const add = (layer, base, dir, plugin) => {
96
+ if (out.some((r) => r.dir === dir))
97
+ return;
98
+ appendOwnElement(out, Object.freeze({ layer, kind, dir, base: base.path, ...(plugin === undefined ? {} : { plugin }) }));
99
+ };
100
+ if (managed !== undefined)
101
+ add('managed', managed, joinPath(managed, kind));
102
+ add('user', home, joinPath(home, kind));
103
+ for (const lv of levels)
104
+ add('project', lv, joinPath(lv, '.sema', kind));
105
+ for (const d of extra)
106
+ add('additional', d, joinPath(d, '.sema', kind));
107
+ for (const p of plugins)
108
+ add('plugin', p.root, joinPath(p.root, kind), p.name);
109
+ return Object.freeze(out);
110
+ };
111
+ return Object.freeze({ skills: column('skills'), commands: column('commands'), agents: column('agents') });
112
+ }
113
+ catch {
114
+ return undefined;
115
+ }
116
+ }
117
+ const LAYER_RANK = { managed: 0, user: 1, project: 2, additional: 3, plugin: 4, synced: 5, mcp: 6, builtin: 7 };
118
+ function rootOf(v) {
119
+ if (!isRecord(v))
120
+ return undefined;
121
+ const layer = SKILL_ROOT_LAYERS.find((w) => w === own(v, 'layer'));
122
+ const kind = SKILL_ROOT_KINDS.find((w) => w === own(v, 'kind'));
123
+ const dir = own(v, 'dir');
124
+ const base = own(v, 'base');
125
+ if (layer === undefined || kind === undefined || typeof dir !== 'string' || dir === '' || typeof base !== 'string')
126
+ return undefined;
127
+ return { layer, kind, dir, base };
128
+ }
129
+ function rootTrust(trust, root) {
130
+ if (!TRUST_LAYERS.includes(root.layer))
131
+ return 'ok';
132
+ if (!isRecord(trust) || own(trust, 'state') !== 'judged')
133
+ return 'unconfirmed';
134
+ for (const r of listOf(own(trust, 'roots'))) {
135
+ if (own(r, 'dir') !== root.dir)
136
+ continue;
137
+ const t = own(r, 'trusted');
138
+ if (t === true)
139
+ return 'ok';
140
+ if (t !== false)
141
+ return 'unconfirmed';
142
+ const why = own(own(r, 'why'), 'kind');
143
+ return why === 'not_trusted' || why === 'ineligible' ? 'untrusted' : 'unconfirmed';
144
+ }
145
+ return 'unconfirmed';
146
+ }
147
+ const truthy = (v) => v === true || v === 'true';
148
+ export function skillsViewOf(listings, layers, trust) {
149
+ const untrusted = new Set();
150
+ const unconfirmed = new Set();
151
+ try {
152
+ const L = shapeSkillLayers(layers);
153
+ const rows = [];
154
+ const raw = listOf(listings);
155
+ for (let i = 0; i < raw.length; i++) {
156
+ const e = raw[i];
157
+ const fm = own(e, 'frontmatter');
158
+ const dmi = truthy(own(fm, 'disable-model-invocation'));
159
+ const s = shapeSkillSubject(isRecord(e) ? { ...snapshotSubject(e), disableModelInvocation: dmi } : undefined);
160
+ if (s === undefined)
161
+ continue;
162
+ const rootRaw = own(e, 'root');
163
+ const root = rootRaw === undefined ? undefined : rootOf(rootRaw);
164
+ if (rootRaw !== undefined && root === undefined)
165
+ continue;
166
+ const layer = root !== undefined ? root.layer : s.origin === 'mcp' ? 'mcp' : s.origin === 'synced' ? 'synced' : s.origin === 'plugin' ? 'plugin' : 'builtin';
167
+ const trustWord = root === undefined ? 'ok' : rootTrust(trust, root);
168
+ if (root !== undefined && trustWord === 'untrusted')
169
+ untrusted.add(root.dir);
170
+ if (root !== undefined && trustWord === 'unconfirmed')
171
+ unconfirmed.add(root.dir);
172
+ const d = own(fm, 'description');
173
+ rows.push({ s, layer, order: i, trustWord, description: typeof d === 'string' && d.trim() !== '' ? d.trim() : undefined });
174
+ }
175
+ const winner = new Map();
176
+ for (const r of [...rows].sort((a, b) => { const d = LAYER_RANK[a.layer] - LAYER_RANK[b.layer]; return d !== 0 ? d : a.order - b.order; })) {
177
+ if (r.trustWord !== 'ok')
178
+ continue;
179
+ if (!winner.has(r.s.name))
180
+ winner.set(r.s.name, r);
181
+ }
182
+ const entries = [];
183
+ for (const r of rows) {
184
+ const effective = effectiveOfShaped(L, r.s);
185
+ const lock = lockOfShaped(L, r.s);
186
+ const editable = lock === undefined ? Object.freeze({ ok: true }) : Object.freeze({ ok: false, lockedBy: lock.source });
187
+ const base = { name: r.s.name, layer: r.layer, effective, editable };
188
+ const excluded = (reason) => {
189
+ const e = { ...base, status: 'excluded', reason };
190
+ return Object.freeze(e);
191
+ };
192
+ const applied = (extra) => {
193
+ const e = { ...base, status: 'applied', ...extra };
194
+ return Object.freeze(e);
195
+ };
196
+ if (r.trustWord !== 'ok')
197
+ appendOwnElement(entries, excluded(r.trustWord));
198
+ else if (winner.get(r.s.name) !== r)
199
+ appendOwnElement(entries, excluded('shadowed'));
200
+ else if (r.s.disableModelInvocation)
201
+ appendOwnElement(entries, excluded('model_invocation_off'));
202
+ else if (effective.value === 'off' || effective.value === 'user-invocable-only')
203
+ appendOwnElement(entries, excluded('overridden'));
204
+ else if (effective.value === 'name-only')
205
+ appendOwnElement(entries, applied({ nameOnly: true }));
206
+ else
207
+ appendOwnElement(entries, applied(r.description === undefined ? {} : { description: r.description }));
208
+ }
209
+ return Object.freeze({ entries: Object.freeze(entries), withheldRoots: Object.freeze({ untrusted: untrusted.size, unconfirmed: unconfirmed.size }) });
210
+ }
211
+ catch {
212
+ return Object.freeze({ entries: Object.freeze([]), withheldRoots: Object.freeze({ untrusted: untrusted.size, unconfirmed: unconfirmed.size }) });
213
+ }
214
+ }
215
+ function snapshotSubject(e) {
216
+ const out = {};
217
+ for (const k of ['name', 'origin', 'unqualifiedName', 'bareNameReserved', 'aliases', 'mcpLabels', 'reservedLabels', 'syncedNames', 'followsSyncedSkillState', 'hiddenBehindPlugin']) {
218
+ const v = own(e, k);
219
+ if (v !== undefined)
220
+ out[k] = v;
221
+ }
222
+ return out;
223
+ }
224
+ export function skillsSetEditOf(entry, state, scope) {
225
+ return Object.freeze({ kind: 'set_override', name: entry.name, state, scope });
226
+ }
227
+ export function skillsClearEditOf(entry) {
228
+ const by = own(own(entry, 'effective'), 'decidedBy');
229
+ const name = own(entry, 'name');
230
+ if (typeof name !== 'string' || name === '')
231
+ return undefined;
232
+ const editable = slotReadOf(entry, 'editable');
233
+ if (editable.presence === 'unreadable')
234
+ return undefined;
235
+ if (editable.presence === 'present' && editable.value !== undefined && own(editable.value, 'ok') !== true)
236
+ return undefined;
237
+ if (by === 'localSettings')
238
+ return Object.freeze({ kind: 'clear_override', name, scope: 'local' });
239
+ if (by === 'userSettings')
240
+ return Object.freeze({ kind: 'clear_override', name, scope: 'user' });
241
+ return undefined;
242
+ }
243
+ const LOCK_REFUSAL = {
244
+ policy: 'skill_locked_by_higher_layer',
245
+ flag: 'skill_locked_by_higher_layer',
246
+ plugin: 'skill_managed_by_plugin',
247
+ 'skill-author': 'skill_locked_by_author',
248
+ 'reserved-name': 'skill_name_unstorable',
249
+ };
250
+ const DOC_DECIDERS = ['policySettings', 'localSettings', 'projectSettings', 'userSettings'];
251
+ function docOf(r) {
252
+ if (r === undefined)
253
+ return undefined;
254
+ if (r.status === 'loaded')
255
+ return r.doc;
256
+ if (r.status === 'absent' || r.status === 'outside_fence')
257
+ return null;
258
+ return undefined;
259
+ }
260
+ function overrideDiff(L, target, r, desiredState, subjects) {
261
+ const m = new Map();
262
+ const ov = L.docs[target];
263
+ const lower = (s) => lowerTierOf(L, s, target, false);
264
+ const desired = (s) => s.name === r.name ? desiredState : (lockOfShaped(L, s)?.value ?? ownValueIn(ov, s) ?? lower(s) ?? 'on');
265
+ const u = desiredState;
266
+ const O = lower(r) ?? 'on';
267
+ const v = ownValueIn(ov, r) ?? O;
268
+ if (r.origin === 'mcp') {
269
+ if (u === v)
270
+ return m;
271
+ const k = u === O ? undefined : u;
272
+ if (k !== stateAt(ov, r.name) || m.has(r.name))
273
+ m.set(r.name, k);
274
+ for (const c of secondaryNamesOf(r)) {
275
+ if (stateAt(ov, c) === undefined)
276
+ continue;
277
+ for (const s of subjects) {
278
+ if (s.name === r.name || s.origin !== 'mcp' || !secondaryNamesOf(s).includes(c) || m.has(s.name))
279
+ continue;
280
+ const h = ownValueIn(ov, s);
281
+ if ((lockOfShaped(L, s) !== undefined || desired(s) === (h ?? lower(s) ?? 'on')) && h !== undefined)
282
+ m.set(s.name, h);
283
+ }
284
+ m.set(c, undefined);
285
+ }
286
+ return m;
287
+ }
288
+ const bare = r.origin === 'synced' ? bareNameOf(r) : undefined;
289
+ if (bare !== undefined && stateAt(ov, bare) !== undefined && u !== v) {
290
+ const p = lowerTierOf(L, r, target, true) ?? 'on';
291
+ const k = u === p ? undefined : u;
292
+ if (k !== stateAt(ov, r.name))
293
+ m.set(r.name, k);
294
+ m.set(bare, undefined);
295
+ return m;
296
+ }
297
+ if (r.origin === 'synced' && u === v)
298
+ return m;
299
+ const d = u === O ? undefined : u;
300
+ if (d !== stateAt(ov, r.name))
301
+ m.set(r.name, d);
302
+ return m;
303
+ }
304
+ function clearDiff(L, target, r, subjects) {
305
+ const m = new Map();
306
+ const ov = L.docs[target];
307
+ if (stateAt(ov, r.name) !== undefined)
308
+ m.set(r.name, undefined);
309
+ for (const c of secondaryNamesOf(r)) {
310
+ if (stateAt(ov, c) === undefined)
311
+ continue;
312
+ if (r.origin === 'mcp') {
313
+ for (const s of subjects) {
314
+ if (s.name === r.name || s.origin !== 'mcp' || !secondaryNamesOf(s).includes(c) || m.has(s.name))
315
+ continue;
316
+ const h = ownValueIn(ov, s);
317
+ if (h !== undefined)
318
+ m.set(s.name, h);
319
+ }
320
+ }
321
+ m.set(c, undefined);
322
+ }
323
+ return m;
324
+ }
325
+ export function skillOverrideWritePlan(edit, context) {
326
+ try {
327
+ if (!isRecord(edit))
328
+ return Object.freeze({ ok: false, reason: 'invalid_request' });
329
+ const kind = own(edit, 'kind');
330
+ const name = own(edit, 'name');
331
+ const scope = SKILL_OVERRIDE_SCOPES.find((w) => w === own(edit, 'scope'));
332
+ const stateRaw = own(edit, 'state');
333
+ const state = SKILL_OVERRIDE_STATES.find((w) => w === stateRaw);
334
+ if ((kind !== 'set_override' && kind !== 'clear_override') || typeof name !== 'string' || name === '' || name.length > 512 || scope === undefined)
335
+ return Object.freeze({ ok: false, reason: 'invalid_request' });
336
+ if (kind === 'set_override' ? state === undefined : stateRaw !== undefined)
337
+ return Object.freeze({ ok: false, reason: 'invalid_request' });
338
+ if (SETTINGS_IS_RESERVED_MEMBER_NAME(name))
339
+ return Object.freeze({ ok: false, reason: 'skill_name_unstorable' });
340
+ const target = scope === 'local' ? 'localSettings' : 'userSettings';
341
+ const snapshot = ['policySettings', 'projectSettings', 'localSettings', 'userSettings'].filter((d) => d !== target);
342
+ const subjects = listOf(own(context, 'subjects'))
343
+ .map((v) => shapeSkillSubject(v))
344
+ .filter((s) => s !== undefined);
345
+ const flag = own(context, 'flagSettings');
346
+ const session = own(context, 'session');
347
+ const disabledSources = own(context, 'disabledSources');
348
+ const envOff = own(context, 'bundledSkillsDisabledByEnv') === true;
349
+ const plan = ({ fresh }) => {
350
+ const docs = {};
351
+ for (const d of [target, ...snapshot]) {
352
+ const doc = docOf(fresh[d]);
353
+ if (doc === undefined)
354
+ return { kind: 'refuse', reason: 'scope_unreadable' };
355
+ docs[d] = doc;
356
+ }
357
+ const L = shapeSkillLayers({ ...docs, flagSettings: flag, session, disabledSources, bundledSkillsDisabledByEnv: envOff });
358
+ const r = subjects.find((s) => s.name === name);
359
+ if (r === undefined)
360
+ return { kind: 'refuse', reason: 'not_found' };
361
+ const lock = lockOfShaped(L, r);
362
+ if (lock !== undefined)
363
+ return { kind: 'refuse', reason: LOCK_REFUSAL[lock.source] };
364
+ const diff = kind === 'set_override' ? overrideDiff(L, target, r, state, subjects) : clearDiff(L, target, r, subjects);
365
+ const current = docs[target] ?? null;
366
+ let next = null;
367
+ if (diff.size > 0) {
368
+ const edits = [...diff].map(([member, value]) => value === undefined ? { intent: 'skillOverride', member, op: 'delete' } : { intent: 'skillOverride', member, op: 'set', value });
369
+ const w = settingsWritePlan({ doc: target, current, trust: 'unreadable', edits });
370
+ if (!w.ok)
371
+ return { kind: 'refuse', reason: w.reason, ...(w.detail === undefined ? {} : { detail: w.detail }) };
372
+ if (w.changed)
373
+ next = w.next;
374
+ }
375
+ const after = effectiveOfShaped(next === null ? L : withLayerDoc(L, target, next), r);
376
+ const layer = DOC_DECIDERS.find((d) => d === after.decidedBy);
377
+ const wanted = kind === 'set_override' ? state : undefined;
378
+ const disclose = layer === undefined ? [] : [{ kind: wanted === undefined || after.value === wanted ? 'decided_by' : 'shadowed_by', layer }];
379
+ return next === null ? { kind: 'unchanged', disclose } : { kind: 'write', next, disclose };
380
+ };
381
+ const intent = Object.freeze({
382
+ appliesOn: 'next_turn',
383
+ steps: Object.freeze([Object.freeze({ doc: target, role: 'effect', snapshot: Object.freeze([...snapshot]), plan })]),
384
+ });
385
+ return Object.freeze({ ok: true, intent });
386
+ }
387
+ catch {
388
+ return Object.freeze({ ok: false, reason: 'invalid_request' });
389
+ }
390
+ }
391
+ const PENDING = Object.freeze({ kind: 'pending' });
392
+ export function skillCreatePlan(_intent) {
393
+ return PENDING;
394
+ }
395
+ export function skillRemovePlan(_intent) {
396
+ return PENDING;
397
+ }
@@ -0,0 +1,10 @@
1
+ export declare const SKILL_ROOT_LAYERS: readonly ["managed", "user", "project", "additional", "plugin"];
2
+ export type SkillRootLayer = (typeof SKILL_ROOT_LAYERS)[number];
3
+ export declare const SKILL_ROOT_KINDS: readonly ["skills", "commands", "agents"];
4
+ export type SkillRootKind = (typeof SKILL_ROOT_KINDS)[number];
5
+ export declare const SKILLS_VIEW_EXCLUDED_REASONS: readonly ["overridden", "model_invocation_off", "untrusted", "unconfirmed", "shadowed"];
6
+ export type SkillsViewExcludedReason = (typeof SKILLS_VIEW_EXCLUDED_REASONS)[number];
7
+ export declare const SKILLS_VIEW_LAYERS: readonly ["managed", "user", "project", "additional", "plugin", "mcp", "builtin", "synced"];
8
+ export type SkillsViewLayer = (typeof SKILLS_VIEW_LAYERS)[number];
9
+ export declare const SKILL_OVERRIDE_SCOPES: readonly ["local", "user"];
10
+ export type SkillOverrideScope = (typeof SKILL_OVERRIDE_SCOPES)[number];
@@ -0,0 +1,5 @@
1
+ export const SKILL_ROOT_LAYERS = Object.freeze(['managed', 'user', 'project', 'additional', 'plugin']);
2
+ export const SKILL_ROOT_KINDS = Object.freeze(['skills', 'commands', 'agents']);
3
+ export const SKILLS_VIEW_EXCLUDED_REASONS = Object.freeze(['overridden', 'model_invocation_off', 'untrusted', 'unconfirmed', 'shadowed']);
4
+ export const SKILLS_VIEW_LAYERS = Object.freeze([...SKILL_ROOT_LAYERS, 'mcp', 'builtin', 'synced']);
5
+ export const SKILL_OVERRIDE_SCOPES = Object.freeze(['local', 'user']);
@@ -14,9 +14,9 @@ export declare function localEngineSeatSentence(reading: LocalEngineSeatReading,
14
14
  export declare function localEngineNoticeText(notice: LocalEngineNotice, lang?: UiLanguage): string | undefined;
15
15
  export declare function localEngineFailText(code: LocalEngineFailCode, lang?: UiLanguage): string | undefined;
16
16
  export declare function engineTargetLocalOf(input: {
17
- readonly lifecycle: LocalEngineSeatReading;
17
+ readonly lifecycle: LocalEngineSeatReading | undefined;
18
18
  readonly mcp?: SeatLocalMcpReading;
19
- }, lang?: UiLanguage): EngineTargetLocal;
19
+ }, lang?: UiLanguage): EngineTargetLocal | undefined;
20
20
  export interface EngineRestartOperation {
21
21
  readonly before: LocalEngineState;
22
22
  readonly after: LocalEngineState;
@@ -95,7 +95,7 @@ export function localEngineSeatReadingOf(state, host) {
95
95
  return undefined;
96
96
  }
97
97
  }
98
- const STATE_DOWN = Object.freeze(['lock-unavailable', 'spawn-failed', 'spawn-refused', 'stop-failed', 'crash-loop', 'high-water-unreadable']);
98
+ const STATE_DOWN = Object.freeze(['lock-unavailable', 'spawn-failed', 'spawn-refused', 'stop-failed', 'crash-loop', 'high-water-unreadable', 'exited-once']);
99
99
  const DOWN_KEYS = Object.freeze({
100
100
  'lock-unavailable': 'localEngine.down.lockUnavailable',
101
101
  'spawn-failed': 'localEngine.down.spawnFailed',
@@ -103,6 +103,7 @@ const DOWN_KEYS = Object.freeze({
103
103
  'stop-failed': 'localEngine.down.stopFailed',
104
104
  'crash-loop': 'localEngine.down.crashLoop',
105
105
  'high-water-unreadable': 'localEngine.down.highWaterUnreadable',
106
+ 'exited-once': 'localEngine.down.exitedOnce',
106
107
  });
107
108
  function downSentence(reason, lang) {
108
109
  if (reason === 'principal-unknown')
@@ -207,6 +208,7 @@ const FAIL_KEYS = Object.freeze({
207
208
  'local_engine.stop_failed': 'localEngine.down.stopFailed',
208
209
  'local_engine.crash_loop': 'localEngine.down.crashLoop',
209
210
  'local_engine.high_water_unreadable': 'localEngine.down.highWaterUnreadable',
211
+ 'local_engine.exited_once': 'localEngine.down.exitedOnce',
210
212
  });
211
213
  export function localEngineFailText(code, lang) {
212
214
  try {
@@ -224,7 +226,7 @@ export function engineTargetLocalOf(input, lang) {
224
226
  const lifecycle = raw === undefined ? undefined : ownSnapshotTyped(raw);
225
227
  const phase = own(lifecycle, 'phase');
226
228
  if (lifecycle === undefined || typeof phase !== 'string')
227
- return Object.freeze({});
229
+ return undefined;
228
230
  const out = { lifecycle };
229
231
  if (phase === 'down') {
230
232
  const line = downSentence(own(lifecycle, 'reason'), lang);
@@ -238,7 +240,7 @@ export function engineTargetLocalOf(input, lang) {
238
240
  return deepFreeze(out);
239
241
  }
240
242
  catch {
241
- return Object.freeze({});
243
+ return undefined;
242
244
  }
243
245
  }
244
246
  function attachedId(s) {
@@ -103,11 +103,4 @@ export interface LocalEnginePrincipalView {
103
103
  }
104
104
  export declare function localEnginePrincipalOf(view: LocalEnginePrincipalView): LocalEnginePrincipal;
105
105
  export declare function localEnginePrincipalSentence(p: LocalEnginePrincipal, lang?: UiLanguage): string | undefined;
106
- export interface LocalEngineBootRefusal {
107
- readonly code?: string;
108
- readonly hint?: string;
109
- readonly text: string;
110
- }
111
- export declare function engineBootRefusalOf(lines: readonly string[], scrub: (s: string) => string): LocalEngineBootRefusal | undefined;
112
- export declare function engineBootRefusalSentence(refusal: LocalEngineBootRefusal, lang?: UiLanguage): string | undefined;
113
106
  export declare function localEngineFirstShareSentence(lang?: UiLanguage): string;
@@ -61,14 +61,6 @@ function stringOf(x) {
61
61
  return undefined;
62
62
  }
63
63
  }
64
- function parseJsonLine(t) {
65
- try {
66
- return JSON.parse(t);
67
- }
68
- catch {
69
- return undefined;
70
- }
71
- }
72
64
  function freezeRecord(rows) {
73
65
  const out = {};
74
66
  for (const [k, v] of rows)
@@ -397,90 +389,6 @@ export function localEnginePrincipalSentence(p, lang) {
397
389
  return undefined;
398
390
  }
399
391
  }
400
- const BOOT_REFUSAL_MAX_CHARS = 800;
401
- const BOOT_REFUSAL_MAX_HINTS = 2;
402
- const CONFIG_CODE = /^config\.[A-Za-z0-9_.-]+$/;
403
- function capSentence(s) {
404
- const t = s.trim();
405
- return t.length > BOOT_REFUSAL_MAX_CHARS ? `${t.slice(0, BOOT_REFUSAL_MAX_CHARS)}…` : t;
406
- }
407
- export function engineBootRefusalOf(lines, scrub) {
408
- try {
409
- const clean = (s) => {
410
- try {
411
- const out = scrub(s);
412
- return typeof out === 'string' ? out : undefined;
413
- }
414
- catch {
415
- return undefined;
416
- }
417
- };
418
- const hints = [];
419
- let code;
420
- let hint;
421
- let fatal;
422
- const list = Array.isArray(lines) ? [...lines] : [];
423
- for (const raw of list) {
424
- if (typeof raw !== 'string')
425
- continue;
426
- const line = clean(raw);
427
- if (line === undefined)
428
- continue;
429
- const t = line.trim();
430
- if (!t.startsWith('{'))
431
- continue;
432
- const o = parseJsonLine(t);
433
- if (!isRecord(o))
434
- continue;
435
- const m = own(o, 'msg');
436
- const err = own(o, 'err');
437
- if (m === 'fatal' && typeof err === 'string' && err.trim() !== '') {
438
- const full = clean(err);
439
- const s = full === undefined ? undefined : full.replace(/^\s*Error:\s*/, '');
440
- if (s !== undefined && s.trim() !== '')
441
- fatal = capSentence(s);
442
- continue;
443
- }
444
- const c = own(o, 'code');
445
- const h = own(o, 'hint');
446
- if (typeof c === 'string' && CONFIG_CODE.test(c) && typeof h === 'string' && h.trim() !== '') {
447
- const model = own(o, 'model');
448
- const who = typeof model === 'string' && model !== '' ? `"${model}": ` : '';
449
- const s = clean(`${who}${h}`);
450
- const cc = clean(c);
451
- if (s === undefined || cc === undefined || !CONFIG_CODE.test(cc))
452
- continue;
453
- const sentence = capSentence(s);
454
- code = cc;
455
- const ch = clean(h);
456
- hint = ch === undefined ? undefined : capSentence(ch);
457
- if (hints.includes(sentence))
458
- continue;
459
- hints.push(sentence);
460
- if (hints.length > BOOT_REFUSAL_MAX_HINTS)
461
- hints.shift();
462
- }
463
- }
464
- const parts = [...hints, ...(fatal !== undefined ? [fatal] : [])];
465
- if (parts.length === 0)
466
- return undefined;
467
- return Object.freeze({ ...(code !== undefined ? { code } : {}), ...(hint !== undefined ? { hint } : {}), text: parts.join('\n') });
468
- }
469
- catch {
470
- return undefined;
471
- }
472
- }
473
- export function engineBootRefusalSentence(refusal, lang) {
474
- try {
475
- const text = own(refusal, 'text');
476
- if (typeof text !== 'string' || text.trim() === '')
477
- return undefined;
478
- return renderMessage(msg('localEngine.bootRefusal', { reason: text }), lang);
479
- }
480
- catch {
481
- return undefined;
482
- }
483
- }
484
392
  export function localEngineFirstShareSentence(lang) {
485
393
  return renderMessage(msg('localEngine.firstShare'), lang);
486
394
  }
@@ -14,7 +14,7 @@ export interface LocalEngineStepOccupancy extends LocalEngineOccupancy {
14
14
  readonly bgIds: readonly string[] | null;
15
15
  }
16
16
  export type LocalEngineTarget = EngineSwapCardTarget;
17
- export type LocalEngineStateDownReason = 'lock-unavailable' | 'spawn-failed' | 'spawn-refused' | 'stop-failed' | 'crash-loop' | 'high-water-unreadable';
17
+ export type LocalEngineStateDownReason = 'lock-unavailable' | 'spawn-failed' | 'spawn-refused' | 'stop-failed' | 'crash-loop' | 'high-water-unreadable' | 'exited-once';
18
18
  export interface LocalEngineCauseEntry {
19
19
  readonly cause: LocalEngineSwapCause;
20
20
  readonly fingerprint: string;
@@ -189,7 +189,7 @@ export type LocalEngineEvent = {
189
189
  readonly clean: boolean | 'unknown';
190
190
  readonly nowMs: number;
191
191
  };
192
- export declare const LOCAL_ENGINE_FAIL_CODES: readonly ["local_engine.behind", "local_engine.legacy_below_floor", "local_engine.unresponsive", "local_engine.swap_pending", "local_engine.drain_overdue", "local_engine.unanswered_unverifiable", "local_engine.lock_unavailable", "local_engine.spawn_failed", "local_engine.spawn_refused", "local_engine.stop_failed", "local_engine.crash_loop", "local_engine.high_water_unreadable", "local_engine.principal_unknown"];
192
+ export declare const LOCAL_ENGINE_FAIL_CODES: readonly ["local_engine.behind", "local_engine.legacy_below_floor", "local_engine.unresponsive", "local_engine.swap_pending", "local_engine.drain_overdue", "local_engine.unanswered_unverifiable", "local_engine.lock_unavailable", "local_engine.spawn_failed", "local_engine.spawn_refused", "local_engine.stop_failed", "local_engine.crash_loop", "local_engine.high_water_unreadable", "local_engine.exited_once", "local_engine.principal_unknown"];
193
193
  export type LocalEngineFailCode = (typeof LOCAL_ENGINE_FAIL_CODES)[number];
194
194
  export type LocalEngineNotice = {
195
195
  readonly key: 'versionUnknown';
@@ -18,6 +18,7 @@ export const LOCAL_ENGINE_FAIL_CODES = Object.freeze([
18
18
  'local_engine.stop_failed',
19
19
  'local_engine.crash_loop',
20
20
  'local_engine.high_water_unreadable',
21
+ 'local_engine.exited_once',
21
22
  'local_engine.principal_unknown',
22
23
  ]);
23
24
  function isRecord(v) {
@@ -210,6 +211,7 @@ const DOWN_FAIL = Object.freeze({
210
211
  'stop-failed': 'local_engine.stop_failed',
211
212
  'crash-loop': 'local_engine.crash_loop',
212
213
  'high-water-unreadable': 'local_engine.high_water_unreadable',
214
+ 'exited-once': 'local_engine.exited_once',
213
215
  });
214
216
  function showCard(p, hold, occ, fx, policy) {
215
217
  if (headless(policy)) {
@@ -1,5 +1,6 @@
1
1
  import { projectMcpSection } from './adapter/downstream/eventToSdkMessage.js';
2
2
  import { wireFailureShapeOf } from './wireFailureShape.js';
3
+ import { LIMIT_RATE_EXCEEDED } from './engineErrorCodes.js';
3
4
  import { mcpProbeAvailable } from './mcpProbeCapability.js';
4
5
  import { scenarioRefusalFromError } from './scenarioRefusal.js';
5
6
  export const MCP_PROBE_REFUSAL_CAUSES = Object.freeze([
@@ -50,7 +51,7 @@ export function classifyMcpProbeFailure(e) {
50
51
  return refusedBy('body_unparseable', message);
51
52
  case 'request.payload_too_large':
52
53
  return refusedBy('payload_too_large', message);
53
- case 'limit.rate_exceeded':
54
+ case LIMIT_RATE_EXCEEDED:
54
55
  return refusedBy('rate_limited', message, retryAfterSec);
55
56
  case 'auth.unauthorized':
56
57
  return refusedBy('unauthorized', message);
@@ -1,12 +1,12 @@
1
1
  import { capForDisplay } from './fleetTaskDesc.js';
2
+ import { STEERING_NOT_RUNNING } from './engineErrorCodes.js';
2
3
  import { ownDataField } from './ownKey.js';
3
4
  import { isSessionIdPathSegment } from './sessionIdSegment.js';
4
5
  import { inSlotReadOf, inValueOf, slotReadOf } from './wireFailureShape.js';
5
6
  import { readMcpAuthorization } from './mcpLiveness.js';
6
7
  import { msg, renderMessage } from './i18n/translate.js';
7
8
  export const MCP_RECONNECT_OUTCOMES = Object.freeze(['accepted', 'refused', 'unsupported']);
8
- export const MCP_RECONNECT_TRANSACTION_NOTICE = 'Reconnecting closes the current connection before dialing again. On a healthy server this is a transaction, ' +
9
- 'not a refresh: a failed re-dial leaves the server down and withdraws its tools from the model until a later re-dial succeeds.';
9
+ export const MCP_RECONNECT_TRANSACTION_NOTICE = renderMessage(msg('session.mcpReconnect.transaction'));
10
10
  export const MCP_RECONNECT_UNSETTLED_NOTICE = renderMessage(msg('session.mcpReconnect.unsettled'));
11
11
  const UNSETTLED_CODE = 'state.mcp_reconnect_unsettled';
12
12
  const _sdkClientIsAnInjection = [true];
@@ -141,7 +141,7 @@ export function classifyMcpReconnectFailure(e) {
141
141
  return unsettledVerdict(e);
142
142
  if (code === 'steering.invalid_content')
143
143
  return { kind: 'invalid' };
144
- if (code === 'steering.not_running')
144
+ if (code === STEERING_NOT_RUNNING)
145
145
  return { kind: 'not_running' };
146
146
  if (typeof code === 'string' && code.startsWith('capability.'))
147
147
  return { kind: 'unsupported', reason: 'capability' };