@sema-agent/client-core 0.94.0 → 0.96.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 (332) hide show
  1. package/CHANGELOG.md +521 -0
  2. package/README.md +104 -57
  3. package/dist/adapt/arms.js +12 -7
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.d.ts +1 -0
  6. package/dist/adapt/toolCards.js +18 -5
  7. package/dist/adapt/wireShapes.js +5 -24
  8. package/dist/adapter/activeRunSelfHeal.d.ts +12 -3
  9. package/dist/adapter/activeRunSelfHeal.js +50 -16
  10. package/dist/adapter/downstream/eventToSdkMessage.js +33 -18
  11. package/dist/adapter/downstream/terminalToSdkResult.js +19 -12
  12. package/dist/adapter/runStream.js +30 -46
  13. package/dist/adapter/types.d.ts +7 -0
  14. package/dist/adapter/types.js +15 -0
  15. package/dist/agentSession/backgroundView.js +5 -1
  16. package/dist/agentSession/engineAgentRegistryRead.js +7 -5
  17. package/dist/agentSession/engineSessionBackgroundStop.js +25 -17
  18. package/dist/agentsWireCaps.d.ts +2 -0
  19. package/dist/agentsWireCaps.js +13 -2
  20. package/dist/approvalDecidedByCapability.d.ts +0 -1
  21. package/dist/approvalDecidedByCapability.js +2 -7
  22. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  23. package/dist/approvalsStreamLiveCapability.js +2 -6
  24. package/dist/atMostOnce.d.ts +8 -0
  25. package/dist/atMostOnce.js +36 -0
  26. package/dist/attachmentSeatCapability.d.ts +0 -1
  27. package/dist/attachmentSeatCapability.js +0 -3
  28. package/dist/attachmentsWireCaps.js +11 -6
  29. package/dist/bashExitReading.d.ts +10 -0
  30. package/dist/bashExitReading.js +12 -0
  31. package/dist/callerCwdCapability.d.ts +0 -5
  32. package/dist/callerCwdCapability.js +2 -13
  33. package/dist/centerWiringCapability.d.ts +1 -7
  34. package/dist/centerWiringCapability.js +18 -27
  35. package/dist/classifierStatus.js +4 -4
  36. package/dist/classifierVerdictWire.js +4 -16
  37. package/dist/clientSlice.js +1 -1
  38. package/dist/cloudConfigWireCaps.d.ts +3 -3
  39. package/dist/cloudConfigWireCaps.js +85 -43
  40. package/dist/compensations.js +1 -1
  41. package/dist/coreValuePorts.d.ts +11 -7
  42. package/dist/coreValuePorts.js +5 -8
  43. package/dist/credentialProvenance.d.ts +28 -0
  44. package/dist/credentialProvenance.js +76 -0
  45. package/dist/cycleOrder.d.ts +15 -0
  46. package/dist/cycleOrder.js +45 -0
  47. package/dist/decideFailureNote.js +7 -2
  48. package/dist/decideReceipt.d.ts +2 -1
  49. package/dist/decideReceipt.js +39 -14
  50. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  51. package/dist/declared/supportFloorDeclared.js +5 -0
  52. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  53. package/dist/deviceExecutorManagementCapability.js +7 -16
  54. package/dist/deviceRebind.d.ts +88 -0
  55. package/dist/deviceRebind.js +242 -0
  56. package/dist/displayUntrusted.d.ts +8 -3
  57. package/dist/displayUntrusted.js +661 -63
  58. package/dist/engineAgentAbsence.d.ts +2 -2
  59. package/dist/engineAgentPanelStore.d.ts +8 -18
  60. package/dist/engineAgentPanelStore.js +19 -537
  61. package/dist/engineCapReader.d.ts +6 -6
  62. package/dist/engineCapReader.js +30 -43
  63. package/dist/engineCapsCache.d.ts +13 -2
  64. package/dist/engineCapsCache.js +276 -44
  65. package/dist/engineCredentialRequirement.d.ts +9 -0
  66. package/dist/engineCredentialRequirement.js +23 -0
  67. package/dist/engineDirectory.d.ts +79 -0
  68. package/dist/engineDirectory.js +186 -0
  69. package/dist/engineEnvSourcing.d.ts +53 -0
  70. package/dist/engineEnvSourcing.js +81 -0
  71. package/dist/engineErrorCodes.d.ts +28 -4
  72. package/dist/engineErrorCodes.js +68 -25
  73. package/dist/engineIdentity.js +2 -0
  74. package/dist/engineNoticeCodes.d.ts +17 -0
  75. package/dist/engineNoticeCodes.js +57 -3
  76. package/dist/engineWireSdk.js +2 -2
  77. package/dist/engineWordRenames.d.ts +8 -0
  78. package/dist/engineWordRenames.js +13 -0
  79. package/dist/executionLaneCapability.d.ts +2 -3
  80. package/dist/executionLaneCapability.js +18 -23
  81. package/dist/fileHistoryCaptureCapability.d.ts +14 -1
  82. package/dist/fileHistoryCaptureCapability.js +72 -6
  83. package/dist/fileHistoryLegNotice.d.ts +3 -2
  84. package/dist/fileHistoryLegNotice.js +51 -2
  85. package/dist/fleet/bgSubagentRow.d.ts +15 -0
  86. package/dist/fleet/bgSubagentRow.js +67 -0
  87. package/dist/fleet/fleetLedger.d.ts +3 -0
  88. package/dist/fleet/fleetLedger.js +153 -122
  89. package/dist/fleet/fleetProjection.d.ts +1 -3
  90. package/dist/fleet/fleetProjection.js +19 -19
  91. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  92. package/dist/fleetAgentPanelProjection.js +7 -197
  93. package/dist/fleetAgentRowLike.d.ts +16 -0
  94. package/dist/fleetAgentRowLike.js +1 -0
  95. package/dist/fleetTaskDesc.js +4 -17
  96. package/dist/gateOutcome.d.ts +12 -1
  97. package/dist/gateOutcome.js +87 -18
  98. package/dist/gateVocabulary.d.ts +7 -2
  99. package/dist/gateVocabulary.js +5 -1
  100. package/dist/generated/engineAskFaceTables.js +1 -1
  101. package/dist/generated/engineFactTables.d.ts +5 -3
  102. package/dist/generated/engineFactTables.js +17 -4
  103. package/dist/generated/engineNoticeTables.js +12 -3
  104. package/dist/generated/sdkFactTables.d.ts +2 -0
  105. package/dist/generated/sdkFactTables.js +17 -0
  106. package/dist/generated/settingsSchemaFns.d.ts +13 -0
  107. package/dist/generated/settingsSchemaFns.js +75 -0
  108. package/dist/generated/toolNameTables.d.ts +1 -0
  109. package/dist/generated/toolNameTables.js +1 -0
  110. package/dist/headlessPermissionModeWire.d.ts +1 -1
  111. package/dist/headlessPermissionModeWire.js +1 -1
  112. package/dist/headlessReconnectWire.js +49 -20
  113. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  114. package/dist/hitl/allowRuleShadow.js +49 -8
  115. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  116. package/dist/hitl/approvalCompleteParked.js +14 -0
  117. package/dist/hitl/approvalEndingCause.d.ts +7 -0
  118. package/dist/hitl/approvalEndingCause.js +71 -0
  119. package/dist/hitl/approvalHolds.d.ts +12 -2
  120. package/dist/hitl/approvalHolds.js +53 -2
  121. package/dist/hitl/approvalsFeed.js +23 -11
  122. package/dist/hitl/askGateWire.d.ts +2 -1
  123. package/dist/hitl/askGateWire.js +26 -1
  124. package/dist/hitl/askParkRowRouting.js +1 -1
  125. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  126. package/dist/hitl/automaticAnswerVerdict.js +15 -10
  127. package/dist/hitl/crashConverged.js +2 -0
  128. package/dist/hitl/decisionConflict.d.ts +3 -0
  129. package/dist/hitl/decisionConflict.js +41 -0
  130. package/dist/hitl/decisionRefusal.d.ts +12 -0
  131. package/dist/hitl/decisionRefusal.js +63 -4
  132. package/dist/hitl/frameRouter.d.ts +0 -1
  133. package/dist/hitl/frameRouter.js +32 -57
  134. package/dist/hitl/gateLedger.d.ts +5 -0
  135. package/dist/hitl/gateLedger.js +21 -0
  136. package/dist/hitl/hitlBridge.d.ts +17 -2
  137. package/dist/hitl/hitlBridge.js +91 -55
  138. package/dist/hitl/hitlHostSurface.js +3 -11
  139. package/dist/hitl/livePendingAsk.d.ts +16 -6
  140. package/dist/hitl/livePendingAsk.js +36 -4
  141. package/dist/hitl/localAllowRule.d.ts +1 -0
  142. package/dist/hitl/localAllowRule.js +2 -2
  143. package/dist/hitl/noAllowCause.d.ts +2 -1
  144. package/dist/hitl/noAllowCause.js +3 -2
  145. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  146. package/dist/hitl/parkExpiryJudgements.js +46 -0
  147. package/dist/hitl/parkResolver.d.ts +4 -7
  148. package/dist/hitl/parkResolver.js +12 -34
  149. package/dist/hitl/parkRowBirthWait.d.ts +1 -0
  150. package/dist/hitl/parkRowBirthWait.js +2 -2
  151. package/dist/hitl/persistedRulesWire.js +5 -1
  152. package/dist/hitl/planReviewWire.d.ts +3 -2
  153. package/dist/hitl/planReviewWire.js +154 -50
  154. package/dist/hitl/replayedApproval.d.ts +9 -0
  155. package/dist/hitl/replayedApproval.js +139 -10
  156. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  157. package/dist/hitl/resumeRunningCard.js +15 -4
  158. package/dist/hitl/sessionPolicyDeliverable.js +8 -6
  159. package/dist/hitl/standingRows.d.ts +18 -0
  160. package/dist/hitl/standingRows.js +127 -0
  161. package/dist/hitl/toolApprovalWire.d.ts +39 -7
  162. package/dist/hitl/toolApprovalWire.js +351 -61
  163. package/dist/hookMatcherVerdict.d.ts +1 -9
  164. package/dist/hookMatcherVerdict.js +21 -61
  165. package/dist/hooksWireCaps.js +40 -8
  166. package/dist/host.d.ts +5 -0
  167. package/dist/host.js +3 -1
  168. package/dist/hostCallbackGuard.d.ts +2 -0
  169. package/dist/hostCallbackGuard.js +31 -0
  170. package/dist/index.d.ts +48 -17
  171. package/dist/index.js +36 -15
  172. package/dist/interactiveInterrupt.d.ts +8 -0
  173. package/dist/interactiveInterrupt.js +54 -0
  174. package/dist/limitsWire.d.ts +5 -0
  175. package/dist/limitsWire.js +49 -3
  176. package/dist/liveModelCatalog.d.ts +95 -0
  177. package/dist/liveModelCatalog.js +297 -32
  178. package/dist/mcpEngineLeg.d.ts +25 -0
  179. package/dist/mcpEngineLeg.js +71 -15
  180. package/dist/mcpPanel.js +2 -1
  181. package/dist/mcpProbeCapability.d.ts +0 -5
  182. package/dist/mcpProbeCapability.js +2 -12
  183. package/dist/mcpReconnect.d.ts +1 -3
  184. package/dist/mcpReconnect.js +10 -5
  185. package/dist/memoryComplianceCapability.d.ts +0 -5
  186. package/dist/memoryComplianceCapability.js +2 -12
  187. package/dist/memoryOriginCapability.d.ts +0 -5
  188. package/dist/memoryOriginCapability.js +2 -12
  189. package/dist/memorySpecWire.js +2 -2
  190. package/dist/memoryVerbsWire.d.ts +1 -1
  191. package/dist/memoryVerbsWire.js +4 -0
  192. package/dist/model/liveCatalogShape.d.ts +14 -0
  193. package/dist/model/liveCatalogShape.js +71 -0
  194. package/dist/model/modelSupplyRules.d.ts +1 -0
  195. package/dist/model/modelSupplyRules.js +30 -9
  196. package/dist/model/modelsPolicy.d.ts +21 -0
  197. package/dist/model/modelsPolicy.js +90 -0
  198. package/dist/modelIdentityResolvability.d.ts +2 -2
  199. package/dist/modelIdentityResolvability.js +14 -12
  200. package/dist/modelSwitchFallback.d.ts +69 -0
  201. package/dist/modelSwitchFallback.js +206 -0
  202. package/dist/noticePresentation.d.ts +68 -0
  203. package/dist/noticePresentation.js +247 -0
  204. package/dist/notifications.js +12 -11
  205. package/dist/outputStyleSeatCapability.d.ts +0 -2
  206. package/dist/outputStyleSeatCapability.js +2 -10
  207. package/dist/ownKey.d.ts +8 -0
  208. package/dist/ownKey.js +66 -0
  209. package/dist/panelReduce.d.ts +114 -0
  210. package/dist/panelReduce.js +1135 -0
  211. package/dist/panelStateHolder.d.ts +17 -0
  212. package/dist/panelStateHolder.js +201 -0
  213. package/dist/peerFrames.js +13 -9
  214. package/dist/peerLaneCapability.d.ts +0 -1
  215. package/dist/peerLaneCapability.js +2 -6
  216. package/dist/permissionModesCapability.d.ts +0 -5
  217. package/dist/permissionModesCapability.js +5 -16
  218. package/dist/permissionRuleIssue.js +0 -3
  219. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  220. package/dist/permissionRulesWriteCapability.js +2 -6
  221. package/dist/permissionsAllowGrantCapability.d.ts +0 -1
  222. package/dist/permissionsAllowGrantCapability.js +3 -9
  223. package/dist/permissionsDeclaration.d.ts +8 -0
  224. package/dist/permissionsDeclaration.js +101 -41
  225. package/dist/printPermissionOutcome.d.ts +12 -0
  226. package/dist/printPermissionOutcome.js +50 -0
  227. package/dist/printToolResultFrame.d.ts +1 -0
  228. package/dist/printToolResultFrame.js +5 -17
  229. package/dist/promptBlockedCopy.d.ts +5 -0
  230. package/dist/promptBlockedCopy.js +35 -0
  231. package/dist/promptDelivery.js +0 -8
  232. package/dist/protocolSegment.d.ts +9 -6
  233. package/dist/protocolSegment.js +31 -21
  234. package/dist/providerRejection.d.ts +4 -0
  235. package/dist/providerRejection.js +75 -14
  236. package/dist/replayBody.d.ts +12 -0
  237. package/dist/replayBody.js +25 -0
  238. package/dist/resumeRefusalCopy.d.ts +18 -1
  239. package/dist/resumeRefusalCopy.js +127 -32
  240. package/dist/retryStatus.d.ts +9 -1
  241. package/dist/retryStatus.js +9 -2
  242. package/dist/rewindArchiveCapability.d.ts +5 -14
  243. package/dist/rewindArchiveCapability.js +18 -61
  244. package/dist/rewindArchiveReading.d.ts +15 -0
  245. package/dist/rewindArchiveReading.js +56 -0
  246. package/dist/rewindEngineAction.d.ts +21 -0
  247. package/dist/rewindEngineAction.js +36 -0
  248. package/dist/rewindWireCaps.d.ts +2 -1
  249. package/dist/rewindWireCaps.js +1 -0
  250. package/dist/ruleCompileVerdict.d.ts +9 -1
  251. package/dist/ruleCompileVerdict.js +29 -4
  252. package/dist/runTerminal.d.ts +15 -12
  253. package/dist/runTerminal.js +60 -35
  254. package/dist/sandboxWire.js +13 -0
  255. package/dist/sdkRegistryTransit.d.ts +2 -1
  256. package/dist/sdkRegistryTransit.js +1 -0
  257. package/dist/sealedKeyCapability.d.ts +0 -5
  258. package/dist/sealedKeyCapability.js +3 -15
  259. package/dist/seam.js +4 -2
  260. package/dist/seatContract.d.ts +125 -34
  261. package/dist/seatContract.js +583 -179
  262. package/dist/sessionIdSegment.d.ts +1 -0
  263. package/dist/sessionIdSegment.js +11 -0
  264. package/dist/sessionMemoryErase.d.ts +1 -1
  265. package/dist/sessionMemoryErase.js +6 -1
  266. package/dist/sessionMemoryStatus.js +3 -2
  267. package/dist/sessionPolicyCapability.d.ts +0 -1
  268. package/dist/sessionPolicyCapability.js +2 -6
  269. package/dist/sessionReadRedactionCapability.d.ts +0 -5
  270. package/dist/sessionReadRedactionCapability.js +2 -13
  271. package/dist/sessionSyncFileHistory.d.ts +4 -0
  272. package/dist/sessionSyncFileHistory.js +66 -0
  273. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -2
  274. package/dist/sessionSyncFileHistoryCapability.js +2 -9
  275. package/dist/skillToolListsCapability.d.ts +0 -2
  276. package/dist/skillToolListsCapability.js +2 -9
  277. package/dist/skillsWireCaps.d.ts +4 -0
  278. package/dist/skillsWireCaps.js +66 -1
  279. package/dist/sqlEngineCapability.d.ts +0 -1
  280. package/dist/sqlEngineCapability.js +9 -14
  281. package/dist/steerPriorityCapability.d.ts +0 -2
  282. package/dist/steerPriorityCapability.js +3 -12
  283. package/dist/storePostureCapability.d.ts +1 -5
  284. package/dist/storePostureCapability.js +16 -22
  285. package/dist/streamDrainingLegs.d.ts +6 -0
  286. package/dist/streamDrainingLegs.js +23 -0
  287. package/dist/subagent/engineCompactWire.js +13 -38
  288. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  289. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  290. package/dist/subagent/engineSubagentOutput.js +5 -20
  291. package/dist/subagent/engineSubagentSteer.js +7 -5
  292. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  293. package/dist/subagent/engineSubagentTail.js +7 -32
  294. package/dist/subagentContentStore.js +7 -18
  295. package/dist/supportFloor.d.ts +1 -0
  296. package/dist/supportFloor.js +15 -14
  297. package/dist/systemReminderTag.d.ts +1 -0
  298. package/dist/systemReminderTag.js +8 -0
  299. package/dist/terminalStatuses.d.ts +30 -0
  300. package/dist/terminalStatuses.js +67 -0
  301. package/dist/toolHistoryMismatch.d.ts +0 -3
  302. package/dist/toolHistoryMismatch.js +3 -7
  303. package/dist/toolResult.d.ts +6 -1
  304. package/dist/toolResult.js +90 -37
  305. package/dist/toolResultContent.d.ts +2 -0
  306. package/dist/toolResultContent.js +63 -0
  307. package/dist/types/engineState.d.ts +2 -1
  308. package/dist/usageAnalytics.d.ts +146 -0
  309. package/dist/usageAnalytics.js +335 -0
  310. package/dist/userInvokedSkillsCapability.d.ts +0 -2
  311. package/dist/userInvokedSkillsCapability.js +2 -9
  312. package/dist/webSearchBackendCapability.d.ts +0 -1
  313. package/dist/webSearchBackendCapability.js +3 -7
  314. package/dist/webSearchWireCaps.js +3 -11
  315. package/dist/wireErrorTriage.d.ts +2 -0
  316. package/dist/wireErrorTriage.js +34 -5
  317. package/dist/wireFailureShape.d.ts +23 -2
  318. package/dist/wireFailureShape.js +88 -43
  319. package/dist/wireRefusalCopy.js +2 -18
  320. package/dist/workflowClient.js +7 -11
  321. package/dist/workflowsJournalCapability.d.ts +0 -1
  322. package/dist/workflowsJournalCapability.js +2 -6
  323. package/dist/writeProtectionCapability.d.ts +0 -1
  324. package/dist/writeProtectionCapability.js +5 -10
  325. package/docs/INTEGRATION-CLIENTS.md +2279 -27
  326. package/package.json +5 -5
  327. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  328. package/dist/engineCapsGenerationGuard.js +0 -19
  329. package/dist/panelRunningHistory.d.ts +0 -22
  330. package/dist/panelRunningHistory.js +0 -82
  331. package/dist/registryConflict.d.ts +0 -3
  332. package/dist/registryConflict.js +0 -44
@@ -1,14 +1,13 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
2
  import { createEngineCapReader } from './engineCapReader.js';
3
+ import { ownDataField } from './ownKey.js';
3
4
  export const MEMORY_ENGINE_REQUIRED_CODE = 'capability.memory_engine_required';
4
5
  export function projectMemoryComplianceCapability(caps) {
5
6
  try {
6
7
  if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
7
8
  return undefined;
8
9
  const c = caps;
9
- if (!Object.hasOwn(c, 'memoryCompliance'))
10
- return { kind: 'not_reported' };
11
- const v = c.memoryCompliance;
10
+ const v = ownDataField(c, 'memoryCompliance');
12
11
  if (v === undefined)
13
12
  return { kind: 'not_reported' };
14
13
  if (typeof v !== 'boolean')
@@ -24,9 +23,6 @@ const reader = createEngineCapReader({
24
23
  project: projectMemoryComplianceCapability,
25
24
  makeUnobserved: () => ({ kind: 'unobserved' }),
26
25
  });
27
- export function noteEngineCapsForMemoryCompliance(baseUrl, caps, opts) {
28
- reader.note(baseUrl, caps, opts);
29
- }
30
26
  export function observedMemoryCompliance(baseUrl = engineWireTarget()?.baseUrl) {
31
27
  return reader.observed(baseUrl);
32
28
  }
@@ -49,9 +45,3 @@ export function memoryComplianceDoctorDetail(reading) {
49
45
  return 'memory compliance face on — the entry-provenance and erasure endpoints are mounted and the operator roster is non-empty on this engine; this says the door opens, not that any one call succeeds (a damaged control-plane ledger is a runtime fact and arrives as a typed 500)';
50
46
  }
51
47
  }
52
- export function forgetMemoryComplianceReading(baseUrl) {
53
- reader.forget(baseUrl);
54
- }
55
- export function __resetMemoryComplianceReadingsForTests() {
56
- reader.__resetForTests();
57
- }
@@ -8,11 +8,6 @@ export type MemoryOriginReading = {
8
8
  kind: 'present';
9
9
  };
10
10
  export declare function projectMemoryOriginCapability(caps: unknown): MemoryOriginReading | undefined;
11
- export declare function noteEngineCapsForMemoryOrigin(baseUrl: string, caps: unknown, opts?: {
12
- generation?: number;
13
- }): void;
14
11
  export declare function observedMemoryOrigin(baseUrl?: string | undefined): MemoryOriginReading;
15
12
  export declare function memoryOriginVerbsAvailable(reading: MemoryOriginReading): 'yes' | 'no' | 'unknown';
16
13
  export declare function memoryOriginDoctorDetail(reading: MemoryOriginReading): string;
17
- export declare function forgetMemoryOriginReading(baseUrl: string | undefined): void;
18
- export declare function __resetMemoryOriginReadingsForTests(): void;
@@ -1,14 +1,13 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
2
  import { createEngineCapReader } from './engineCapReader.js';
3
+ import { ownDataField } from './ownKey.js';
3
4
  import { MEMORY_ENGINE_REQUIRED_CODE } from './memoryComplianceCapability.js';
4
5
  export function projectMemoryOriginCapability(caps) {
5
6
  try {
6
7
  if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
7
8
  return undefined;
8
9
  const c = caps;
9
- if (!Object.hasOwn(c, 'memoryOrigin'))
10
- return { kind: 'not_reported' };
11
- const v = c.memoryOrigin;
10
+ const v = ownDataField(c, 'memoryOrigin');
12
11
  if (v === undefined)
13
12
  return { kind: 'not_reported' };
14
13
  if (typeof v !== 'boolean')
@@ -24,9 +23,6 @@ const reader = createEngineCapReader({
24
23
  project: projectMemoryOriginCapability,
25
24
  makeUnobserved: () => ({ kind: 'unobserved' }),
26
25
  });
27
- export function noteEngineCapsForMemoryOrigin(baseUrl, caps, opts) {
28
- reader.note(baseUrl, caps, opts);
29
- }
30
26
  export function observedMemoryOrigin(baseUrl = engineWireTarget()?.baseUrl) {
31
27
  return reader.observed(baseUrl);
32
28
  }
@@ -49,9 +45,3 @@ export function memoryOriginDoctorDetail(reading) {
49
45
  return 'external-origin face on — the origin listing and clearance endpoints are mounted and the operator roster is non-empty on this engine; this says the door opens, not that any one call succeeds, and it says nothing about the listing being complete (the engine has no scope-enumeration read face, so an answer covers only the scopes the caller named and an empty one must never be read as a clean store)';
50
46
  }
51
47
  }
52
- export function forgetMemoryOriginReading(baseUrl) {
53
- reader.forget(baseUrl);
54
- }
55
- export function __resetMemoryOriginReadingsForTests() {
56
- reader.__resetForTests();
57
- }
@@ -1,5 +1,5 @@
1
1
  import { CONFIG_MEMORY_PROJECT_KEY_SPELLING, CONFIG_MEMORY_WRITE_SCOPE_MISMATCH } from './engineErrorCodes.js';
2
- import { capForDisplay } from './fleetTaskDesc.js';
2
+ import { escapeDisplayControlChars } from './fleetTaskDesc.js';
3
3
  export const KNOWN_AGENT_MEMORY_SPEC_KEYS = Object.freeze([
4
4
  'enabled',
5
5
  'scopeContract',
@@ -128,7 +128,7 @@ function quotedKeyForDisplay(key) {
128
128
  let out = '';
129
129
  let truncated = false;
130
130
  for (const ch of key) {
131
- const tok = ch === '\\' ? '\\\\' : ch === '"' ? '\\"' : capForDisplay(ch, 8);
131
+ const tok = ch === '\\' ? '\\\\' : ch === '"' ? '\\"' : escapeDisplayControlChars(ch);
132
132
  if (out.length + tok.length > MEMORY_SPEC_KEY_DISPLAY_MAX) {
133
133
  truncated = true;
134
134
  break;
@@ -21,7 +21,7 @@ export interface MemoryFacade {
21
21
  }
22
22
  export declare const MEMORY_VERB_REFUSAL_CAUSES: readonly ["face_absent", "client_too_old", "unreadable_request", "store_absent", "operator_only", "operators_unconfigured", "unauthorized", "service_token_required", "id_invalid", "request_id_required", "body_shape", "query_invalid", "selector_invalid", "evidence_unavailable", "selector_mismatch", "census_incomplete", "clear_unattributed", "clear_invalid", "clear_not_marked", "clear_challenged", "clear_conflict", "clear_pending"];
23
23
  export type MemoryVerbRefusalCause = (typeof MEMORY_VERB_REFUSAL_CAUSES)[number];
24
- export declare const MEMORY_VERB_UNKNOWN_WHYS: readonly ["no_verdict", "server_fault", "control_plane_corrupt", "clear_unknown", "clear_failed", "result_unreadable", "unsupported_version", "identity_mismatch", "unclassified"];
24
+ export declare const MEMORY_VERB_UNKNOWN_WHYS: readonly ["no_verdict", "server_fault", "control_plane_corrupt", "clear_unknown", "clear_failed", "result_unreadable", "unsupported_version", "identity_mismatch", "store_form_refused", "unclassified"];
25
25
  export type MemoryVerbUnknownWhy = (typeof MEMORY_VERB_UNKNOWN_WHYS)[number];
26
26
  export type MemoryVerbRefused = {
27
27
  status: 'refused';
@@ -35,6 +35,7 @@ export const MEMORY_VERB_UNKNOWN_WHYS = Object.freeze([
35
35
  'result_unreadable',
36
36
  'unsupported_version',
37
37
  'identity_mismatch',
38
+ 'store_form_refused',
38
39
  'unclassified',
39
40
  ]);
40
41
  function refusedBy(cause, message) {
@@ -90,6 +91,9 @@ export function classifyMemoryFailure(e) {
90
91
  return unknownBy('clear_unknown', message);
91
92
  case 'memory.origin_clear_failed':
92
93
  return unknownBy('clear_failed', message);
94
+ case 'memory.target_outside_store':
95
+ case 'memory.scope_home_not_directory':
96
+ return unknownBy('store_form_refused', message);
93
97
  case 'internal.memory_control_plane_corrupt':
94
98
  return unknownBy('control_plane_corrupt', message);
95
99
  default:
@@ -0,0 +1,14 @@
1
+ export type FrozenJsonValue = string | number | boolean | null | readonly FrozenJsonValue[] | {
2
+ readonly [k: string]: FrozenJsonValue;
3
+ };
4
+ export declare function frozenJsonCopyOf(v: unknown): FrozenJsonValue | undefined;
5
+ export declare function liveModelRowCopy(row: unknown): FrozenJsonRow | undefined;
6
+ export type FrozenJsonRow = {
7
+ readonly [k: string]: FrozenJsonValue;
8
+ } & {
9
+ readonly name: string;
10
+ };
11
+ export declare function liveDefaultModelCopy(v: unknown): {
12
+ readonly id: string;
13
+ readonly name?: string;
14
+ } | undefined;
@@ -0,0 +1,71 @@
1
+ const MAX_DEPTH = 16;
2
+ class Unreadable extends Error {
3
+ }
4
+ function frozenJsonCopy(v, depth) {
5
+ if (depth > MAX_DEPTH)
6
+ throw new Unreadable();
7
+ if (v === null || typeof v === 'string' || typeof v === 'boolean')
8
+ return v;
9
+ if (typeof v === 'number') {
10
+ if (!Number.isFinite(v))
11
+ throw new Unreadable();
12
+ return v;
13
+ }
14
+ if (typeof v !== 'object')
15
+ throw new Unreadable();
16
+ if (Array.isArray(v)) {
17
+ const n = Object.getOwnPropertyDescriptor(v, 'length')?.value;
18
+ if (typeof n !== 'number' || !Number.isSafeInteger(n) || n < 0)
19
+ throw new Unreadable();
20
+ const out = [];
21
+ for (let i = 0; i < n; i += 1) {
22
+ const d = Object.getOwnPropertyDescriptor(v, String(i));
23
+ if (d === undefined || !('value' in d))
24
+ throw new Unreadable();
25
+ out.push(frozenJsonCopy(d.value, depth + 1));
26
+ }
27
+ return Object.freeze(out);
28
+ }
29
+ const out = {};
30
+ for (const k of Object.keys(v)) {
31
+ const d = Object.getOwnPropertyDescriptor(v, k);
32
+ if (d === undefined || !('value' in d))
33
+ throw new Unreadable();
34
+ if (d.value === undefined)
35
+ continue;
36
+ Object.defineProperty(out, k, { value: frozenJsonCopy(d.value, depth + 1), enumerable: true, writable: true, configurable: true });
37
+ }
38
+ return Object.freeze(out);
39
+ }
40
+ export function frozenJsonCopyOf(v) {
41
+ try {
42
+ return frozenJsonCopy(v, 0);
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
48
+ export function liveModelRowCopy(row) {
49
+ if (row === null || typeof row !== 'object' || Array.isArray(row))
50
+ return undefined;
51
+ const copy = frozenJsonCopyOf(row);
52
+ if (!isFrozenJsonObject(copy))
53
+ return undefined;
54
+ const name = copy.name;
55
+ return typeof name === 'string' && name.length > 0 ? copy : undefined;
56
+ }
57
+ const isFrozenJsonObject = (v) => v !== undefined && v !== null && typeof v === 'object' && !Array.isArray(v);
58
+ export function liveDefaultModelCopy(v) {
59
+ if (v === null || typeof v !== 'object' || Array.isArray(v))
60
+ return undefined;
61
+ const c = frozenJsonCopyOf(v);
62
+ if (!isFrozenJsonObject(c))
63
+ return undefined;
64
+ const id = c.id;
65
+ const name = c.name;
66
+ if (typeof id !== 'string' || id.length === 0)
67
+ return undefined;
68
+ if (Object.hasOwn(c, 'name') && (typeof name !== 'string' || name.length === 0))
69
+ return undefined;
70
+ return c;
71
+ }
@@ -26,6 +26,7 @@ export interface DeleteWarningsInput {
26
26
  id: string;
27
27
  doc: {
28
28
  atModelAllowlist?: unknown;
29
+ atMention?: unknown;
29
30
  tierGroups?: unknown;
30
31
  } | null;
31
32
  tierGroups: TierGroupsView | null;
@@ -1,3 +1,5 @@
1
+ import { SETTINGS_NARROW_AT_MENTION } from '../generated/settingsSchemaFns.js';
2
+ import { modelsPolicyOf } from './modelsPolicy.js';
1
3
  import { inferFamily } from './providerPresets.js';
2
4
  function isPlainObject(v) {
3
5
  return typeof v === 'object' && v !== null && !Array.isArray(v);
@@ -13,15 +15,16 @@ export function resolveEntryVision(entry) {
13
15
  export function computeDeleteWarnings(input) {
14
16
  const { id, doc, tierGroups, survivingIds } = input;
15
17
  const out = [];
16
- const allow = doc?.atModelAllowlist;
17
- if (Array.isArray(allow)) {
18
- const declared = allow.filter((x) => typeof x === 'string');
19
- const effectiveBefore = declared.filter(n => n === id || survivingIds.includes(n));
20
- const effectiveAfter = declared.filter(n => n !== id && survivingIds.includes(n));
21
- if (effectiveBefore.length > 0 && effectiveAfter.length === 0) {
18
+ const am = modelsPolicyOf(doc).atMention;
19
+ if (am?.kind === 'read' && am.value.mode === 'only') {
20
+ const before = SETTINGS_NARROW_AT_MENTION(am.value, new Set([id, ...survivingIds]));
21
+ const after = SETTINGS_NARROW_AT_MENTION(am.value, new Set(survivingIds.filter((n) => n !== id)));
22
+ if (before.mode === 'only' && after.mode === 'none') {
22
23
  out.push({
23
24
  kind: 'allowlist-empties',
24
- consequence: 'it is the last usable model on your @-mention allowlist — deleting it empties the list, which means EVERY enabled model becomes @-mentionable',
25
+ consequence: am.from === 'atModelAllowlist'
26
+ ? 'it is the last usable model on your @-mention allowlist — deleting it empties the list, which means EVERY enabled model becomes @-mentionable'
27
+ : 'it is the last usable model on your @-mention allowlist — deleting it leaves no model that can be @-mentioned',
25
28
  });
26
29
  }
27
30
  }
@@ -47,15 +50,33 @@ export function computeDeleteWarnings(input) {
47
50
  export function computeDeleteBlockers(input) {
48
51
  const { id, doc, rosters } = input;
49
52
  const out = [];
50
- if (doc && typeof doc.default === 'string' && doc.default === id) {
53
+ const policy = modelsPolicyOf(doc);
54
+ if (policy.unreadable) {
55
+ out.push({
56
+ kind: 'unreadable',
57
+ where: 'models.json (the document could not be read)',
58
+ fix: 'fix or re-save models.json so it can be read, then delete this model',
59
+ });
60
+ }
61
+ if (policy.defaultUnreadable) {
62
+ out.push({
63
+ kind: 'unreadable',
64
+ where: 'models.json `default` (the default model could not be read)',
65
+ fix: 'fix or re-save models.json so its default model can be read, then delete this model',
66
+ });
67
+ }
68
+ const dm = policy.defaultModel;
69
+ if (dm !== undefined && dm.name === id) {
51
70
  out.push({
52
71
  kind: 'default',
53
- where: 'models.json `default`',
72
+ where: dm.from === 'default' ? 'models.json `default`' : 'models.json roles.default',
54
73
  fix: 'point another model at the default first (Model Hub: select it and press u), then delete this one',
55
74
  });
56
75
  }
57
76
  if (doc && isPlainObject(doc.roles)) {
58
77
  for (const [role, target] of Object.entries(doc.roles)) {
78
+ if (role === 'default' && dm?.from === 'roles.default')
79
+ continue;
59
80
  if (!isPlainObject(target) || typeof target.model !== 'string')
60
81
  continue;
61
82
  if (target.model !== id)
@@ -0,0 +1,21 @@
1
+ import { type SettingsAtMention } from '../generated/settingsSchemaFns.js';
2
+ export interface CanonicalDefaultModel {
3
+ readonly name: string;
4
+ readonly from: 'default' | 'roles.default';
5
+ }
6
+ export type CanonicalAtMention = {
7
+ readonly kind: 'read';
8
+ readonly value: SettingsAtMention;
9
+ readonly from: 'atMention' | 'atModelAllowlist';
10
+ readonly unreadableEntries: number;
11
+ } | {
12
+ readonly kind: 'unreadable';
13
+ readonly from: 'atMention' | 'atModelAllowlist';
14
+ };
15
+ export interface CanonicalModelsPolicy {
16
+ readonly defaultModel?: CanonicalDefaultModel;
17
+ readonly defaultUnreadable?: true;
18
+ readonly atMention?: CanonicalAtMention;
19
+ readonly unreadable?: true;
20
+ }
21
+ export declare function modelsPolicyOf(doc: unknown): CanonicalModelsPolicy;
@@ -0,0 +1,90 @@
1
+ import { SETTINGS_AT_MENTION_MODES } from '../generated/settingsSchemaFns.js';
2
+ function ownData(o, key) {
3
+ try {
4
+ const d = Object.getOwnPropertyDescriptor(o, key);
5
+ return d !== undefined && 'value' in d ? d.value : undefined;
6
+ }
7
+ catch {
8
+ return undefined;
9
+ }
10
+ }
11
+ const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
12
+ function atMentionOf(v) {
13
+ try {
14
+ if (!isRecord(v))
15
+ return undefined;
16
+ const mode = ownData(v, 'mode');
17
+ if (typeof mode !== 'string' || !SETTINGS_AT_MENTION_MODES.includes(mode))
18
+ return undefined;
19
+ if (mode !== 'only')
20
+ return { mode: mode };
21
+ const list = ownData(v, 'models');
22
+ if (!Array.isArray(list) || list.length === 0)
23
+ return undefined;
24
+ const out = [];
25
+ for (let i = 0; i < list.length; i += 1) {
26
+ const d = Object.getOwnPropertyDescriptor(list, i);
27
+ if (d === undefined || !('value' in d) || typeof d.value !== 'string' || d.value.length === 0)
28
+ return undefined;
29
+ out.push(d.value);
30
+ }
31
+ return { mode: 'only', models: out };
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
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
+ export function modelsPolicyOf(doc) {
54
+ try {
55
+ if (!isRecord(doc))
56
+ return {};
57
+ 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
+ }
73
+ let atMention;
74
+ if (Object.hasOwn(doc, 'atMention')) {
75
+ 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'));
80
+ }
81
+ return {
82
+ ...(defaultModel !== undefined ? { defaultModel } : {}),
83
+ ...(defaultUnreadable ? { defaultUnreadable: true } : {}),
84
+ ...(atMention !== undefined ? { atMention } : {}),
85
+ };
86
+ }
87
+ catch {
88
+ return { unreadable: true };
89
+ }
90
+ }
@@ -25,10 +25,10 @@ export interface RemoteEngineModelIdentityReading {
25
25
  }
26
26
  export type ModelIdentityReading = LocalEngineModelIdentityReading | RemoteEngineModelIdentityReading;
27
27
  export type ModelIdentityResolvability = 'resolvable' | 'not_resolvable' | 'unknown';
28
- export type ModelSetupDecision = 'offer_setup' | 'explain_unconfigured' | 'explain_route_gap' | 'proceed';
28
+ export type ModelSetupDecision = 'offer_setup' | 'offer_route_setup' | 'explain_unconfigured' | 'explain_route_gap' | 'explain_route_unconfigurable' | 'proceed';
29
29
  export declare function modelIdentityResolvability(reading: ModelIdentityReading): ModelIdentityResolvability;
30
30
  export declare function modelIdentityDetail(reading: ModelIdentityReading): string;
31
- export declare function modelSetupDecision(identity: ModelIdentityResolvability | ModelIdentityReading, hostCanConfigureModel: boolean): ModelSetupDecision;
31
+ export declare function modelSetupDecision(reading: ModelIdentityReading, hostCanConfigureModel: boolean, hostCanConfigureRoute?: boolean): ModelSetupDecision;
32
32
  export declare function modelSetupNotice(decision: ModelSetupDecision): string | null;
33
33
  export declare function observedEngineAnswer(baseUrl?: string | undefined): EngineAnswerObservation;
34
34
  export {};
@@ -178,18 +178,16 @@ export function modelIdentityDetail(reading) {
178
178
  return "this reading of the engine's model configuration could not be interpreted, so whether the engine has a model name is unknown";
179
179
  }
180
180
  }
181
- export function modelSetupDecision(identity, hostCanConfigureModel) {
182
- let verdict;
183
- if (typeof identity === 'string') {
184
- verdict = identity;
185
- }
186
- else {
187
- const a = analyse(identity);
188
- if (a.verdict === 'not_resolvable' && a.why === 'route_gap')
189
- return 'explain_route_gap';
190
- verdict = a.verdict;
181
+ export function modelSetupDecision(reading, hostCanConfigureModel, hostCanConfigureRoute) {
182
+ const a = analyse(reading);
183
+ if (a.verdict === 'not_resolvable' && a.why === 'route_gap') {
184
+ if (hostCanConfigureRoute === true)
185
+ return 'offer_route_setup';
186
+ if (hostCanConfigureRoute === false)
187
+ return 'explain_route_unconfigurable';
188
+ return 'explain_route_gap';
191
189
  }
192
- if (verdict !== 'not_resolvable')
190
+ if (a.verdict !== 'not_resolvable')
193
191
  return 'proceed';
194
192
  if (hostCanConfigureModel === true)
195
193
  return 'offer_setup';
@@ -203,8 +201,12 @@ export function modelSetupNotice(decision) {
203
201
  return 'no model name is configured for the engine, and it does not start without one — opening model setup';
204
202
  case 'explain_unconfigured':
205
203
  return 'this engine has no model configured, and it cannot be configured from this client — ask whoever runs the engine to set one up';
204
+ case 'offer_route_setup':
205
+ return 'a model name is configured, but the engine has no route to reach that model (a gateway address, or credentials for the channel it names), so it does not start — opening setup so the route can be set';
206
206
  case 'explain_route_gap':
207
- return 'a model name is configured, but the engine has no route to reach that model (a gateway address, or credentials for the channel it names), so it does not start — fix the route; model setup will not help';
207
+ return 'a model name is configured, but the engine has no route to reach that model (a gateway address, or credentials for the channel it names), so it does not start — the route has to be set before the engine can run';
208
+ case 'explain_route_unconfigurable':
209
+ return 'a model name is configured, but the engine has no route to reach that model (a gateway address, or credentials for the channel it names), so it does not start — the route cannot be set from this client; ask whoever runs the engine to set it';
208
210
  default:
209
211
  return null;
210
212
  }
@@ -0,0 +1,69 @@
1
+ export type ModelSwitchProbeLane = 'live' | 'mock' | 'engine_absent' | 'unwired';
2
+ export interface ModelSwitchProbeVerdict {
3
+ readonly valid: boolean;
4
+ readonly error?: string;
5
+ readonly unchecked?: true;
6
+ }
7
+ export interface ModelSwitchProbeInput {
8
+ readonly model: string;
9
+ readonly lane: ModelSwitchProbeLane;
10
+ readonly engineAbsentReason?: string;
11
+ readonly probe?: {
12
+ readonly kind: 'verdict';
13
+ readonly verdict: ModelSwitchProbeVerdict;
14
+ } | {
15
+ readonly kind: 'threw';
16
+ readonly error: unknown;
17
+ };
18
+ }
19
+ export type ModelSwitchProbeOutcome = {
20
+ readonly ok: true;
21
+ readonly probed: boolean;
22
+ } | {
23
+ readonly ok: false;
24
+ readonly kind: 'rejected';
25
+ readonly model: string;
26
+ readonly reason?: string;
27
+ } | {
28
+ readonly ok: false;
29
+ readonly kind: 'unavailable';
30
+ readonly cause: 'unwired' | 'probe_missing' | 'probe_threw' | 'unchecked';
31
+ readonly model: string;
32
+ readonly reason?: string;
33
+ };
34
+ export declare function modelSwitchProbeOutcomeOf(input: ModelSwitchProbeInput): ModelSwitchProbeOutcome;
35
+ export interface ModelSwitchProbePorts {
36
+ readonly lane: () => {
37
+ readonly lane: ModelSwitchProbeLane;
38
+ readonly engineAbsentReason?: string;
39
+ } | Promise<{
40
+ readonly lane: ModelSwitchProbeLane;
41
+ readonly engineAbsentReason?: string;
42
+ }>;
43
+ readonly validate: (model: string) => Promise<ModelSwitchProbeVerdict>;
44
+ }
45
+ export declare function runModelSwitchProbe(model: string, ports: ModelSwitchProbePorts): Promise<ModelSwitchProbeOutcome>;
46
+ export interface ModelSwitchFallbackRecord {
47
+ readonly previous: string;
48
+ readonly current: string;
49
+ readonly seq: number;
50
+ }
51
+ export interface ModelSwitchNote {
52
+ readonly sessionId: string;
53
+ readonly to: string | null | undefined;
54
+ readonly lastServed: string | null | undefined;
55
+ }
56
+ export interface ModelSwitchAdvisoryInput {
57
+ readonly frame: unknown;
58
+ readonly sessionId: string;
59
+ readonly streamModel: string | null | undefined;
60
+ readonly lastServed: string | null | undefined;
61
+ }
62
+ export interface ModelSwitchFallbackLedger {
63
+ noteSwitch(input: ModelSwitchNote): ModelSwitchFallbackRecord | undefined;
64
+ peek(sessionId: string): ModelSwitchFallbackRecord | undefined;
65
+ advisoryFor(input: ModelSwitchAdvisoryInput): ModelSwitchFallbackRecord | undefined;
66
+ release(sessionId: string, seq: number): boolean;
67
+ clear(sessionId: string): void;
68
+ }
69
+ export declare function createModelSwitchFallbackLedger(): ModelSwitchFallbackLedger;