@e4779/pi-fabric 0.92.24-fork.4 → 0.92.41-fork.6

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 (271) hide show
  1. package/README.md +2 -1
  2. package/dist/actors/host-event-payload.d.ts.map +1 -1
  3. package/dist/actors/types.d.ts +1 -1
  4. package/dist/actors/types.d.ts.map +1 -1
  5. package/dist/agents/completion-inbox.d.ts +15 -0
  6. package/dist/agents/completion-inbox.d.ts.map +1 -0
  7. package/dist/agents/handoff.d.ts.map +1 -1
  8. package/dist/agents/manager.d.ts +1 -0
  9. package/dist/agents/manager.d.ts.map +1 -1
  10. package/dist/agents/request.d.ts +4 -0
  11. package/dist/agents/request.d.ts.map +1 -1
  12. package/dist/agents/thinking-transfer.d.ts.map +1 -1
  13. package/dist/agents/transports/process-utils.d.ts.map +1 -1
  14. package/dist/agents.js +3 -2
  15. package/dist/agents.js.map +1 -1
  16. package/dist/build-identity.d.ts +21 -0
  17. package/dist/build-identity.d.ts.map +1 -0
  18. package/dist/chunks/{chunk-RERA6YWA.js → chunk-2A2NWQ36.js} +13 -5
  19. package/dist/chunks/chunk-2A2NWQ36.js.map +7 -0
  20. package/dist/chunks/{chunk-OTCASLY2.js → chunk-2QAOC3BO.js} +1 -1
  21. package/dist/chunks/chunk-2QAOC3BO.js.map +7 -0
  22. package/dist/chunks/{chunk-2PZWDVJB.js → chunk-2SWRVIYJ.js} +21 -9
  23. package/dist/chunks/chunk-2SWRVIYJ.js.map +7 -0
  24. package/dist/chunks/{chunk-4JETKRFE.js → chunk-36B4AIRT.js} +2 -2
  25. package/dist/chunks/{chunk-KFZYTGF5.js → chunk-3TXOQ5MG.js} +60 -46
  26. package/dist/chunks/chunk-3TXOQ5MG.js.map +7 -0
  27. package/dist/chunks/{chunk-VWSXAEX6.js → chunk-4NUTVNS2.js} +44 -202
  28. package/dist/chunks/chunk-4NUTVNS2.js.map +7 -0
  29. package/dist/chunks/{chunk-VYXFSUWU.js → chunk-77PDIBK2.js} +12 -1
  30. package/dist/chunks/{chunk-VYXFSUWU.js.map → chunk-77PDIBK2.js.map} +2 -2
  31. package/dist/chunks/{chunk-X7G62ZGH.js → chunk-7BG5COXB.js} +8 -3
  32. package/dist/chunks/{chunk-X7G62ZGH.js.map → chunk-7BG5COXB.js.map} +2 -2
  33. package/dist/chunks/{chunk-IYQ5MNCW.js → chunk-7VAZ4N43.js} +42 -24
  34. package/dist/chunks/chunk-7VAZ4N43.js.map +7 -0
  35. package/dist/chunks/chunk-A4VP7HDF.js +226 -0
  36. package/dist/chunks/chunk-A4VP7HDF.js.map +7 -0
  37. package/dist/chunks/chunk-B54Z662X.js +127 -0
  38. package/dist/chunks/chunk-B54Z662X.js.map +7 -0
  39. package/dist/chunks/{chunk-4SSMGBF4.js → chunk-CGL7QP4A.js} +58 -8
  40. package/dist/chunks/chunk-CGL7QP4A.js.map +7 -0
  41. package/dist/chunks/{chunk-32BNQ75J.js → chunk-FLKGJPCN.js} +99 -3
  42. package/dist/chunks/chunk-FLKGJPCN.js.map +7 -0
  43. package/dist/chunks/{chunk-QX3TUAWO.js → chunk-GGETIGM5.js} +487 -707
  44. package/dist/chunks/chunk-GGETIGM5.js.map +7 -0
  45. package/dist/chunks/{chunk-WVH324VF.js → chunk-IJL3QK3J.js} +3 -1
  46. package/dist/chunks/chunk-IJL3QK3J.js.map +7 -0
  47. package/dist/chunks/{chunk-3CPWRPCE.js → chunk-IK6PPFWG.js} +17 -6
  48. package/dist/chunks/chunk-IK6PPFWG.js.map +7 -0
  49. package/dist/chunks/{chunk-ZMIJ6AT4.js → chunk-IUCVOZRX.js} +3 -3
  50. package/dist/chunks/{chunk-3ZX76BVU.js → chunk-K6DHXXF5.js} +12 -10
  51. package/dist/chunks/chunk-K6DHXXF5.js.map +7 -0
  52. package/dist/chunks/{chunk-NPHCGLGH.js → chunk-MW5VI7IW.js} +135 -31
  53. package/dist/chunks/chunk-MW5VI7IW.js.map +7 -0
  54. package/dist/chunks/{chunk-BOTRGFQQ.js → chunk-NHMICIEU.js} +26 -19
  55. package/dist/chunks/chunk-NHMICIEU.js.map +7 -0
  56. package/dist/chunks/{chunk-Y7KNRAFL.js → chunk-PMSIZLV6.js} +29 -3
  57. package/dist/chunks/chunk-PMSIZLV6.js.map +7 -0
  58. package/dist/chunks/{chunk-7OH6DD3S.js → chunk-Q4XJ4PYL.js} +529 -168
  59. package/dist/chunks/chunk-Q4XJ4PYL.js.map +7 -0
  60. package/dist/chunks/chunk-RKRVOBVO.js +134 -0
  61. package/dist/chunks/chunk-RKRVOBVO.js.map +7 -0
  62. package/dist/chunks/{chunk-M3S7XITB.js → chunk-TGAVMUOS.js} +29 -13
  63. package/dist/chunks/chunk-TGAVMUOS.js.map +7 -0
  64. package/dist/chunks/chunk-TX6E5W7H.js +50 -0
  65. package/dist/chunks/chunk-TX6E5W7H.js.map +7 -0
  66. package/dist/chunks/{chunk-X3OD47CL.js → chunk-UR2K6WK6.js} +8 -11
  67. package/dist/chunks/chunk-UR2K6WK6.js.map +7 -0
  68. package/dist/chunks/{chunk-Z63R5GVN.js → chunk-WHBJDTCR.js} +6 -2
  69. package/dist/chunks/chunk-WHBJDTCR.js.map +7 -0
  70. package/dist/chunks/{chunk-RRGTKHXZ.js → chunk-X7XFT57O.js} +9 -140
  71. package/dist/chunks/{chunk-RRGTKHXZ.js.map → chunk-X7XFT57O.js.map} +4 -4
  72. package/dist/chunks/chunk-YV2PHCDB.js +108 -0
  73. package/dist/chunks/chunk-YV2PHCDB.js.map +7 -0
  74. package/dist/chunks/chunk-Z64PRP7A.js +156 -0
  75. package/dist/chunks/chunk-Z64PRP7A.js.map +7 -0
  76. package/dist/components/configuration.d.ts +42 -0
  77. package/dist/components/configuration.d.ts.map +1 -0
  78. package/dist/components/configuration.js +19 -0
  79. package/dist/components/configuration.js.map +7 -0
  80. package/dist/components/control.d.ts +76 -0
  81. package/dist/components/control.d.ts.map +1 -0
  82. package/dist/components/loader.d.ts +12 -0
  83. package/dist/components/loader.d.ts.map +1 -1
  84. package/dist/components/provider-component.d.ts +1 -1
  85. package/dist/components/provider-component.d.ts.map +1 -1
  86. package/dist/components/supervisor.d.ts.map +1 -1
  87. package/dist/components/types.d.ts +2 -0
  88. package/dist/components/types.d.ts.map +1 -1
  89. package/dist/components/validation.d.ts +6 -0
  90. package/dist/components/validation.d.ts.map +1 -0
  91. package/dist/config.d.ts +14 -2
  92. package/dist/config.d.ts.map +1 -1
  93. package/dist/core/action-registry.d.ts +9 -0
  94. package/dist/core/action-registry.d.ts.map +1 -1
  95. package/dist/core/action-registry.js +6 -4
  96. package/dist/core/approval-controller.d.ts +5 -1
  97. package/dist/core/approval-controller.d.ts.map +1 -1
  98. package/dist/core/auto-approval-classifier.d.ts +11 -0
  99. package/dist/core/auto-approval-classifier.d.ts.map +1 -1
  100. package/dist/core/compact-controller.d.ts.map +1 -1
  101. package/dist/core/fabric-state-paths.d.ts +2 -0
  102. package/dist/core/fabric-state-paths.d.ts.map +1 -0
  103. package/dist/core/media-sanitize.d.ts +46 -0
  104. package/dist/core/media-sanitize.d.ts.map +1 -0
  105. package/dist/core/model-resolution.d.ts +23 -5
  106. package/dist/core/model-resolution.d.ts.map +1 -1
  107. package/dist/core/semantic-search.d.ts +56 -0
  108. package/dist/core/semantic-search.d.ts.map +1 -0
  109. package/dist/core/shell-jobs.d.ts.map +1 -1
  110. package/dist/core/shell-middleware.d.ts +4 -0
  111. package/dist/core/shell-middleware.d.ts.map +1 -0
  112. package/dist/execution-service.d.ts +3 -1
  113. package/dist/execution-service.d.ts.map +1 -1
  114. package/dist/fabric-exec-tool.d.ts.map +1 -1
  115. package/dist/fabric-runtime-state.d.ts +2 -0
  116. package/dist/fabric-runtime-state.d.ts.map +1 -1
  117. package/dist/fabric-runtime-state.js +1595 -239
  118. package/dist/fabric-runtime-state.js.map +4 -4
  119. package/dist/fabric-state.d.ts +2 -0
  120. package/dist/fabric-state.d.ts.map +1 -1
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.js +284 -60
  123. package/dist/index.js.map +4 -4
  124. package/dist/jev/browser.d.ts.map +1 -1
  125. package/dist/jev/browser.js +1 -1
  126. package/dist/jev/client.d.ts +8 -2
  127. package/dist/jev/client.d.ts.map +1 -1
  128. package/dist/jev/client.js +3 -2
  129. package/dist/jev/config.d.ts.map +1 -1
  130. package/dist/jev/model-key.d.ts +9 -2
  131. package/dist/jev/model-key.d.ts.map +1 -1
  132. package/dist/jev/observation.js +4 -3
  133. package/dist/jev/routes.d.ts +69 -0
  134. package/dist/jev/routes.d.ts.map +1 -0
  135. package/dist/jev/validation.d.ts.map +1 -1
  136. package/dist/jev.d.ts +1 -0
  137. package/dist/jev.d.ts.map +1 -1
  138. package/dist/jev.js +35 -9
  139. package/dist/mcp.d.ts.map +1 -1
  140. package/dist/mcp.js +9 -2
  141. package/dist/mcp.js.map +2 -2
  142. package/dist/output-budget.d.ts.map +1 -1
  143. package/dist/prewalk/arm.d.ts.map +1 -1
  144. package/dist/prewalk/controller.d.ts +57 -6
  145. package/dist/prewalk/controller.d.ts.map +1 -1
  146. package/dist/prewalk/fs-drift.d.ts.map +1 -1
  147. package/dist/prewalk/handoff.d.ts +5 -25
  148. package/dist/prewalk/handoff.d.ts.map +1 -1
  149. package/dist/prewalk/messages.d.ts +24 -0
  150. package/dist/prewalk/messages.d.ts.map +1 -0
  151. package/dist/prewalk/model-switch.d.ts +3 -0
  152. package/dist/prewalk/model-switch.d.ts.map +1 -0
  153. package/dist/prewalk/plan.d.ts +46 -0
  154. package/dist/prewalk/plan.d.ts.map +1 -0
  155. package/dist/prewalk/return.d.ts +16 -0
  156. package/dist/prewalk/return.d.ts.map +1 -0
  157. package/dist/protocol.d.ts +11 -1
  158. package/dist/protocol.d.ts.map +1 -1
  159. package/dist/protocol.js +3 -1
  160. package/dist/providers/agents-actions.d.ts.map +1 -1
  161. package/dist/providers/agents-provider.d.ts.map +1 -1
  162. package/dist/providers/captured-tools-provider.d.ts.map +1 -1
  163. package/dist/providers/components-provider.d.ts +5 -3
  164. package/dist/providers/components-provider.d.ts.map +1 -1
  165. package/dist/providers/jev-provider.d.ts +2 -0
  166. package/dist/providers/jev-provider.d.ts.map +1 -1
  167. package/dist/providers/jev-provider.js +8 -7
  168. package/dist/providers/mcp-descriptor-cache.d.ts +2 -0
  169. package/dist/providers/mcp-descriptor-cache.d.ts.map +1 -1
  170. package/dist/providers/pi-tools-provider.d.ts.map +1 -1
  171. package/dist/providers/prewalk-provider.d.ts +19 -0
  172. package/dist/providers/prewalk-provider.d.ts.map +1 -0
  173. package/dist/repeat-guard.d.ts +4 -0
  174. package/dist/repeat-guard.d.ts.map +1 -1
  175. package/dist/residency/actor-client.d.ts +2 -2
  176. package/dist/residency/actor-client.d.ts.map +1 -1
  177. package/dist/residency/actor-client.js +2 -2
  178. package/dist/residency/client.d.ts +3 -0
  179. package/dist/residency/client.d.ts.map +1 -1
  180. package/dist/residency/host.d.ts.map +1 -1
  181. package/dist/residency/host.js +10 -8
  182. package/dist/residency/pi-entry.js +10 -8
  183. package/dist/residency/pi-entry.js.map +1 -1
  184. package/dist/residency/protocol.d.ts +15 -2
  185. package/dist/residency/protocol.d.ts.map +1 -1
  186. package/dist/runtime/core-override-guest-types.js +2 -2
  187. package/dist/runtime/cpython-runtime.d.ts +2 -0
  188. package/dist/runtime/cpython-runtime.d.ts.map +1 -1
  189. package/dist/runtime/cpython-runtime.js +7 -3
  190. package/dist/runtime/cpython-runtime.js.map +2 -2
  191. package/dist/runtime/guest-types.d.ts +1 -1
  192. package/dist/runtime/guest-types.d.ts.map +1 -1
  193. package/dist/runtime/guest-types.js +1 -1
  194. package/dist/runtime/monty-runtime.js +5 -3
  195. package/dist/runtime/monty-runtime.js.map +2 -2
  196. package/dist/runtime/node-process-runtime.d.ts.map +1 -1
  197. package/dist/runtime/node-process-runtime.js +3 -3
  198. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  199. package/dist/runtime/quickjs-runtime.js +1 -1
  200. package/dist/runtime/typescript-kernel.js +8 -8
  201. package/dist/runtime-state-builtins.d.ts.map +1 -1
  202. package/dist/schema/policy.d.ts.map +1 -1
  203. package/dist/ui/code-preview-shell.d.ts.map +1 -1
  204. package/dist/ui/controller.d.ts.map +1 -1
  205. package/dist/ui/conversation-native-reader.d.ts.map +1 -1
  206. package/dist/ui/conversation-native-reader.js.map +2 -2
  207. package/dist/ui/dashboard.js +2 -2
  208. package/dist/ui/settings-section-context.d.ts +1 -0
  209. package/dist/ui/settings-section-context.d.ts.map +1 -1
  210. package/dist/ui/settings-sections-agents.d.ts.map +1 -1
  211. package/dist/ui/settings-sections-execution.d.ts +1 -1
  212. package/dist/ui/settings-sections-execution.d.ts.map +1 -1
  213. package/dist/ui/settings-sections.d.ts +1 -0
  214. package/dist/ui/settings-sections.d.ts.map +1 -1
  215. package/dist/ui/settings-values.d.ts +1 -0
  216. package/dist/ui/settings-values.d.ts.map +1 -1
  217. package/dist/ui/settings.d.ts.map +1 -1
  218. package/dist/ui/settings.js +57 -17
  219. package/dist/ui/settings.js.map +2 -2
  220. package/dist/ui/spinner.d.ts +8 -1
  221. package/dist/ui/spinner.d.ts.map +1 -1
  222. package/dist/ui/widget.d.ts +12 -1
  223. package/dist/ui/widget.d.ts.map +1 -1
  224. package/dist/worker.js +1 -3
  225. package/dist/worker.js.map +2 -2
  226. package/docs/agents.md +35 -11
  227. package/docs/architecture.md +1 -1
  228. package/docs/components.md +30 -1
  229. package/docs/configuration.md +23 -15
  230. package/docs/foreman.md +65 -0
  231. package/docs/jev.md +77 -4
  232. package/docs/programmatic-compaction.md +12 -7
  233. package/docs/shell-middleware.md +61 -0
  234. package/docs/skills.md +2 -1
  235. package/package.json +5 -4
  236. package/skillsets/python/fabric-exec/SKILL.md +1 -1
  237. package/skillsets/python/fabric-exec/references/agents.md +1 -1
  238. package/skillsets/python/fabric-exec/references/mcp.md +1 -1
  239. package/skillsets/python/fabric-foreman/SKILL.md +249 -0
  240. package/skillsets/python/fabric-guide/SKILL.md +2 -1
  241. package/skillsets/python/fabric-jev/SKILL.md +2 -2
  242. package/skillsets/typescript/fabric-exec/SKILL.md +9 -3
  243. package/skillsets/typescript/fabric-exec/references/agents.md +5 -3
  244. package/skillsets/typescript/fabric-foreman/SKILL.md +240 -0
  245. package/skillsets/typescript/fabric-guide/SKILL.md +2 -1
  246. package/skillsets/typescript/fabric-jev/SKILL.md +2 -2
  247. package/dist/chunks/chunk-2IAVP4O2.js +0 -447
  248. package/dist/chunks/chunk-2IAVP4O2.js.map +0 -7
  249. package/dist/chunks/chunk-2PZWDVJB.js.map +0 -7
  250. package/dist/chunks/chunk-32BNQ75J.js.map +0 -7
  251. package/dist/chunks/chunk-3CPWRPCE.js.map +0 -7
  252. package/dist/chunks/chunk-3ZX76BVU.js.map +0 -7
  253. package/dist/chunks/chunk-4SSMGBF4.js.map +0 -7
  254. package/dist/chunks/chunk-7OH6DD3S.js.map +0 -7
  255. package/dist/chunks/chunk-BOTRGFQQ.js.map +0 -7
  256. package/dist/chunks/chunk-IYQ5MNCW.js.map +0 -7
  257. package/dist/chunks/chunk-KFZYTGF5.js.map +0 -7
  258. package/dist/chunks/chunk-M3S7XITB.js.map +0 -7
  259. package/dist/chunks/chunk-NPHCGLGH.js.map +0 -7
  260. package/dist/chunks/chunk-OTCASLY2.js.map +0 -7
  261. package/dist/chunks/chunk-QX3TUAWO.js.map +0 -7
  262. package/dist/chunks/chunk-RERA6YWA.js.map +0 -7
  263. package/dist/chunks/chunk-TSRKCXNI.js +0 -17
  264. package/dist/chunks/chunk-TSRKCXNI.js.map +0 -7
  265. package/dist/chunks/chunk-VWSXAEX6.js.map +0 -7
  266. package/dist/chunks/chunk-WVH324VF.js.map +0 -7
  267. package/dist/chunks/chunk-X3OD47CL.js.map +0 -7
  268. package/dist/chunks/chunk-Y7KNRAFL.js.map +0 -7
  269. package/dist/chunks/chunk-Z63R5GVN.js.map +0 -7
  270. /package/dist/chunks/{chunk-4JETKRFE.js.map → chunk-36B4AIRT.js.map} +0 -0
  271. /package/dist/chunks/{chunk-ZMIJ6AT4.js.map → chunk-IUCVOZRX.js.map} +0 -0
@@ -0,0 +1,134 @@
1
+ import {
2
+ writeJsonAtomic
3
+ } from "./chunk-4NUTVNS2.js";
4
+ import {
5
+ stableJsonHash
6
+ } from "./chunk-3YZUQESG.js";
7
+
8
+ // src/components/configuration.ts
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+
12
+ // src/components/validation.ts
13
+ import { Value } from "typebox/value";
14
+ var COMPONENT_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
15
+ function componentEntries(value) {
16
+ if (!Array.isArray(value) || value.length > 256) {
17
+ throw new Error("Fabric components must be an array of at most 256 entries");
18
+ }
19
+ const ids = /* @__PURE__ */ new Set();
20
+ return value.map((raw) => {
21
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Error("Invalid Fabric component entry");
22
+ const entry = raw;
23
+ if (typeof entry.id !== "string" || !COMPONENT_ID_PATTERN.test(entry.id)) throw new Error("Invalid Fabric component id");
24
+ if (typeof entry.component !== "string" || !COMPONENT_ID_PATTERN.test(entry.component)) throw new Error(`Invalid component definition name for ${entry.id}`);
25
+ if (entry.disabled !== void 0 && typeof entry.disabled !== "boolean") throw new Error(`Invalid disabled flag for ${entry.id}`);
26
+ if (Object.keys(entry).some((key) => !["id", "component", "config", "disabled"].includes(key))) throw new Error(`Unknown component entry field for ${entry.id}`);
27
+ if (ids.has(entry.id)) throw new Error(`Duplicate Fabric component entry id: ${entry.id}`);
28
+ ids.add(entry.id);
29
+ return structuredClone(entry);
30
+ });
31
+ }
32
+ function validateComponentConfig(entry, definition) {
33
+ if (entry.disabled || !definition.configSchema) return;
34
+ let detail;
35
+ try {
36
+ if (Value.Check(definition.configSchema, entry.config)) return;
37
+ detail = [...Value.Errors(definition.configSchema, entry.config)].slice(0, 5).map((error) => `${error.path || "/"}: ${error.message}`).join("; ").slice(0, 2e3);
38
+ } catch {
39
+ detail = "configuration schema validation failed";
40
+ }
41
+ throw new Error(`Invalid config for component ${entry.id} (${entry.component}): ${detail}`);
42
+ }
43
+
44
+ // src/components/configuration.ts
45
+ function readDocument(file) {
46
+ let source;
47
+ try {
48
+ if (fs.statSync(file).size > 1024 * 1024) throw new Error(`Fabric configuration exceeds 1 MiB: ${file}`);
49
+ source = fs.readFileSync(file, "utf8");
50
+ } catch (error) {
51
+ if (error.code === "ENOENT") return { source: null, value: {} };
52
+ throw error;
53
+ }
54
+ let value;
55
+ try {
56
+ value = JSON.parse(source);
57
+ } catch {
58
+ throw new Error(`Invalid JSON in ${file}; live components were not changed`);
59
+ }
60
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Expected an object in ${file}`);
61
+ return { source, value };
62
+ }
63
+ var FabricComponentConfiguration = class {
64
+ constructor(options) {
65
+ this.options = options;
66
+ this.paths = [path.join(options.agentDir, "fabric.json"), path.join(options.cwd, ".pi", "fabric.json")];
67
+ }
68
+ paths;
69
+ #read() {
70
+ const trusted = this.options.projectTrusted();
71
+ return { global: readDocument(this.paths[0]), project: trusted ? readDocument(this.paths[1]) : void 0, trusted };
72
+ }
73
+ #snapshot(documents) {
74
+ const { global, project, trusted } = documents;
75
+ const globalEntries = Object.hasOwn(global.value, "components") ? componentEntries(global.value.components) : [];
76
+ const projectEntries = project && Object.hasOwn(project.value, "components") ? componentEntries(project.value.components) : void 0;
77
+ const projectPresent = project ? project.source !== null : fs.existsSync(this.paths[1]);
78
+ return {
79
+ revision: stableJsonHash({ global: global.source, project: project?.source, trusted }),
80
+ entries: structuredClone(projectEntries ?? globalEntries),
81
+ layers: { global: globalEntries, ...projectEntries ? { project: projectEntries } : {} },
82
+ sources: [
83
+ { scope: "global", path: this.paths[0], trusted: true, present: global.source !== null, selected: projectEntries === void 0 },
84
+ { scope: "project", path: this.paths[1], trusted, present: projectPresent, selected: projectEntries !== void 0 }
85
+ ],
86
+ warnings: !trusted && projectPresent ? [`Project configuration ${this.paths[1]} is ignored because the project is not trusted; use session scope or explicitly select global scope.`] : []
87
+ };
88
+ }
89
+ read() {
90
+ return this.#snapshot(this.#read());
91
+ }
92
+ write(scope, entries, expectedRevision) {
93
+ const documents = this.#read();
94
+ const snapshot = this.#snapshot(documents);
95
+ if (snapshot.revision !== expectedRevision) throw new Error("Component configuration changed; plan again before applying");
96
+ if (scope === "project" && !documents.trusted) throw new Error("Cannot write project components in an untrusted project");
97
+ const document = scope === "project" ? documents.project : documents.global;
98
+ const value = { ...document.value, components: componentEntries(entries) };
99
+ const source = `${JSON.stringify(value, null, 2)}
100
+ `;
101
+ if (Buffer.byteLength(source) > 1024 * 1024) throw new Error("Fabric configuration exceeds 1 MiB");
102
+ writeJsonAtomic(this.paths[scope === "global" ? 0 : 1], value, document.source);
103
+ documents[scope] = { source, value };
104
+ return this.#snapshot(documents);
105
+ }
106
+ };
107
+ function watchComponentConfiguration(paths, changed) {
108
+ let timer;
109
+ let closed = false;
110
+ const listener = (current, previous) => {
111
+ if (closed || current.mtimeMs === previous.mtimeMs && current.ctimeMs === previous.ctimeMs && current.size === previous.size && current.ino === previous.ino) return;
112
+ clearTimeout(timer);
113
+ timer = setTimeout(() => {
114
+ timer = void 0;
115
+ if (!closed) changed();
116
+ }, 50);
117
+ timer.unref();
118
+ };
119
+ for (const file of paths) fs.watchFile(file, { persistent: false, interval: 250 }, listener);
120
+ return () => {
121
+ closed = true;
122
+ clearTimeout(timer);
123
+ for (const file of paths) fs.unwatchFile(file, listener);
124
+ };
125
+ }
126
+
127
+ export {
128
+ COMPONENT_ID_PATTERN,
129
+ componentEntries,
130
+ validateComponentConfig,
131
+ FabricComponentConfiguration,
132
+ watchComponentConfiguration
133
+ };
134
+ //# sourceMappingURL=chunk-RKRVOBVO.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/components/configuration.ts", "../../src/components/validation.ts"],
4
+ "sourcesContent": ["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { writeJsonAtomic } from \"../config.js\";\nimport { stableJsonHash } from \"../core/stable-hash.js\";\nimport type { FabricComponentEntry } from \"./types.js\";\nimport { componentEntries } from \"./validation.js\";\n\nexport type ComponentConfigScope = \"session\" | \"global\" | \"project\";\nexport interface ComponentConfigSource {\n scope: \"global\" | \"project\";\n path: string;\n trusted: boolean;\n present: boolean;\n selected: boolean;\n}\nexport interface ComponentConfigSnapshot {\n revision: string;\n entries: FabricComponentEntry[];\n layers: { global: FabricComponentEntry[]; project?: FabricComponentEntry[] };\n sources: ComponentConfigSource[];\n warnings: string[];\n}\nexport interface ComponentConfigurationStore {\n read(): ComponentConfigSnapshot;\n write(scope: \"global\" | \"project\", entries: FabricComponentEntry[], expectedRevision: string): ComponentConfigSnapshot;\n}\ninterface Document {\n source: string | null;\n value: Record<string, unknown>;\n}\ninterface Documents { global: Document; project: Document | undefined; trusted: boolean }\n\n/** Unlike startup recovery, a live read never repairs, renames, or drops damaged data. */\nfunction readDocument(file: string): Document {\n let source: string;\n try {\n if (fs.statSync(file).size > 1024 * 1024) throw new Error(`Fabric configuration exceeds 1 MiB: ${file}`);\n source = fs.readFileSync(file, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return { source: null, value: {} };\n throw error;\n }\n let value: unknown;\n try { value = JSON.parse(source); } catch { throw new Error(`Invalid JSON in ${file}; live components were not changed`); }\n if (!value || typeof value !== \"object\" || Array.isArray(value)) throw new Error(`Expected an object in ${file}`);\n return { source, value: value as Record<string, unknown> };\n}\n\nexport class FabricComponentConfiguration implements ComponentConfigurationStore {\n readonly paths: readonly string[];\n constructor(readonly options: { cwd: string; agentDir: string; projectTrusted: () => boolean }) {\n this.paths = [path.join(options.agentDir, \"fabric.json\"), path.join(options.cwd, \".pi\", \"fabric.json\")];\n }\n\n #read() {\n const trusted = this.options.projectTrusted();\n return { global: readDocument(this.paths[0]!), project: trusted ? readDocument(this.paths[1]!) : undefined, trusted };\n }\n\n #snapshot(documents: Documents): ComponentConfigSnapshot {\n const { global, project, trusted } = documents;\n const globalEntries = Object.hasOwn(global.value, \"components\") ? componentEntries(global.value.components) : [];\n const projectEntries = project && Object.hasOwn(project.value, \"components\") ? componentEntries(project.value.components) : undefined;\n const projectPresent = project ? project.source !== null : fs.existsSync(this.paths[1]!);\n return {\n revision: stableJsonHash({ global: global.source, project: project?.source, trusted }),\n entries: structuredClone(projectEntries ?? globalEntries),\n layers: { global: globalEntries, ...(projectEntries ? { project: projectEntries } : {}) },\n sources: [\n { scope: \"global\", path: this.paths[0]!, trusted: true, present: global.source !== null, selected: projectEntries === undefined },\n { scope: \"project\", path: this.paths[1]!, trusted, present: projectPresent, selected: projectEntries !== undefined },\n ],\n warnings: !trusted && projectPresent ? [`Project configuration ${this.paths[1]} is ignored because the project is not trusted; use session scope or explicitly select global scope.`] : [],\n };\n }\n\n read(): ComponentConfigSnapshot { return this.#snapshot(this.#read()); }\n\n write(scope: \"global\" | \"project\", entries: FabricComponentEntry[], expectedRevision: string): ComponentConfigSnapshot {\n const documents = this.#read();\n const snapshot = this.#snapshot(documents);\n if (snapshot.revision !== expectedRevision) throw new Error(\"Component configuration changed; plan again before applying\");\n if (scope === \"project\" && !documents.trusted) throw new Error(\"Cannot write project components in an untrusted project\");\n const document = scope === \"project\" ? documents.project! : documents.global;\n const value = { ...document.value, components: componentEntries(entries) };\n const source = `${JSON.stringify(value, null, 2)}\\n`;\n if (Buffer.byteLength(source) > 1024 * 1024) throw new Error(\"Fabric configuration exceeds 1 MiB\");\n writeJsonAtomic(this.paths[scope === \"global\" ? 0 : 1]!, value, document.source);\n documents[scope] = { source, value };\n return this.#snapshot(documents);\n }\n}\n\n/** Stat watching handles missing files and atomic replacement on all supported hosts. */\nexport function watchComponentConfiguration(paths: readonly string[], changed: () => void): () => void {\n let timer: ReturnType<typeof setTimeout> | undefined;\n let closed = false;\n const listener = (current: fs.Stats, previous: fs.Stats) => {\n if (closed || (current.mtimeMs === previous.mtimeMs && current.ctimeMs === previous.ctimeMs && current.size === previous.size && current.ino === previous.ino)) return;\n clearTimeout(timer);\n timer = setTimeout(() => { timer = undefined; if (!closed) changed(); }, 50);\n timer.unref();\n };\n for (const file of paths) fs.watchFile(file, { persistent: false, interval: 250 }, listener);\n return () => {\n closed = true;\n clearTimeout(timer);\n for (const file of paths) fs.unwatchFile(file, listener);\n };\n}\n", "import { Value } from \"typebox/value\";\nimport type { FabricComponentDefinition, FabricComponentEntry } from \"./types.js\";\n\nexport const COMPONENT_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;\n\n/** Strict at the live-control boundary: malformed edits must never become removals. */\nexport function componentEntries(value: unknown): FabricComponentEntry[] {\n if (!Array.isArray(value) || value.length > 256) {\n throw new Error(\"Fabric components must be an array of at most 256 entries\");\n }\n const ids = new Set<string>();\n return value.map(raw => {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) throw new Error(\"Invalid Fabric component entry\");\n const entry = raw as Record<string, unknown>;\n if (typeof entry.id !== \"string\" || !COMPONENT_ID_PATTERN.test(entry.id)) throw new Error(\"Invalid Fabric component id\");\n if (typeof entry.component !== \"string\" || !COMPONENT_ID_PATTERN.test(entry.component)) throw new Error(`Invalid component definition name for ${entry.id}`);\n if (entry.disabled !== undefined && typeof entry.disabled !== \"boolean\") throw new Error(`Invalid disabled flag for ${entry.id}`);\n if (Object.keys(entry).some(key => ![\"id\", \"component\", \"config\", \"disabled\"].includes(key))) throw new Error(`Unknown component entry field for ${entry.id}`);\n if (ids.has(entry.id)) throw new Error(`Duplicate Fabric component entry id: ${entry.id}`);\n ids.add(entry.id);\n return structuredClone(entry) as unknown as FabricComponentEntry;\n });\n}\n\nexport function validateComponentConfig(entry: FabricComponentEntry, definition: FabricComponentDefinition): void {\n if (entry.disabled || !definition.configSchema) return;\n let detail: string;\n try {\n if (Value.Check(definition.configSchema, entry.config)) return;\n detail = [...Value.Errors(definition.configSchema, entry.config)].slice(0, 5)\n .map(error => `${(error as { path?: string }).path || \"/\"}: ${error.message}`).join(\"; \").slice(0, 2000);\n } catch {\n detail = \"configuration schema validation failed\";\n }\n throw new Error(`Invalid config for component ${entry.id} (${entry.component}): ${detail}`);\n}\n"],
5
+ "mappings": ";;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;;;ACDjB,SAAS,aAAa;AAGf,IAAM,uBAAuB;AAG7B,SAAS,iBAAiB,OAAwC;AACvE,MAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,KAAK;AAC/C,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,QAAM,MAAM,oBAAI,IAAY;AAC5B,SAAO,MAAM,IAAI,SAAO;AACtB,QAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,EAAG,OAAM,IAAI,MAAM,gCAAgC;AAC3G,UAAM,QAAQ;AACd,QAAI,OAAO,MAAM,OAAO,YAAY,CAAC,qBAAqB,KAAK,MAAM,EAAE,EAAG,OAAM,IAAI,MAAM,6BAA6B;AACvH,QAAI,OAAO,MAAM,cAAc,YAAY,CAAC,qBAAqB,KAAK,MAAM,SAAS,EAAG,OAAM,IAAI,MAAM,yCAAyC,MAAM,EAAE,EAAE;AAC3J,QAAI,MAAM,aAAa,UAAa,OAAO,MAAM,aAAa,UAAW,OAAM,IAAI,MAAM,6BAA6B,MAAM,EAAE,EAAE;AAChI,QAAI,OAAO,KAAK,KAAK,EAAE,KAAK,SAAO,CAAC,CAAC,MAAM,aAAa,UAAU,UAAU,EAAE,SAAS,GAAG,CAAC,EAAG,OAAM,IAAI,MAAM,qCAAqC,MAAM,EAAE,EAAE;AAC7J,QAAI,IAAI,IAAI,MAAM,EAAE,EAAG,OAAM,IAAI,MAAM,wCAAwC,MAAM,EAAE,EAAE;AACzF,QAAI,IAAI,MAAM,EAAE;AAChB,WAAO,gBAAgB,KAAK;AAAA,EAC9B,CAAC;AACH;AAEO,SAAS,wBAAwB,OAA6B,YAA6C;AAChH,MAAI,MAAM,YA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  checkResponse,
4
4
  jsonText
5
- } from "./chunk-Z63R5GVN.js";
5
+ } from "./chunk-WHBJDTCR.js";
6
6
  import {
7
7
  runAbortable
8
8
  } from "./chunk-7TB7NXSL.js";
9
+ import {
10
+ JEV_TYPESAFE_ROUTE,
11
+ resolveJevUpstreamModel
12
+ } from "./chunk-B54Z662X.js";
9
13
 
10
14
  // src/jev/client.ts
11
15
  import { execFile } from "node:child_process";
12
16
  var JevCredentials = class {
13
- constructor(command, env = process.env, providerAuth) {
17
+ constructor(command, env = process.env, providerAuth, envKeys = JEV_TYPESAFE_ROUTE.envKeys) {
14
18
  this.command = command;
15
19
  this.env = env;
16
20
  this.providerAuth = providerAuth;
21
+ this.envKeys = envKeys;
17
22
  }
18
23
  #cached;
24
+ #envCredential() {
25
+ for (const key of this.envKeys) {
26
+ const value = this.env[key]?.trim();
27
+ if (value) return value;
28
+ }
29
+ return void 0;
30
+ }
19
31
  status() {
20
- const source = this.providerAuth?.configured() ? "pi" : this.env.TYPESAFE_API_KEY?.trim() ? "environment" : this.command.length ? "command" : "missing";
32
+ const source = this.providerAuth?.configured() ? "pi" : this.#envCredential() ? "environment" : this.command.length ? "command" : "missing";
21
33
  return { configured: source !== "missing", source, verified: false };
22
34
  }
23
35
  async resolve(signal) {
@@ -31,11 +43,11 @@ var JevCredentials = class {
31
43
  throw new Error("Jev Pi credential resolution failed");
32
44
  }
33
45
  }
34
- const env = this.env.TYPESAFE_API_KEY?.trim();
46
+ const env = this.#envCredential();
35
47
  if (env) return env;
36
48
  if (this.#cached) return this.#cached;
37
49
  const [file, ...args] = this.command;
38
- if (!file) throw new Error("Jev credentials unavailable: set TYPESAFE_API_KEY or configure jev.credentialCommand");
50
+ if (!file) throw new Error(`Jev credentials unavailable: set ${this.envKeys.join(" or ")} or configure jev.credentialCommand`);
39
51
  const secret = await new Promise((resolve, reject) => {
40
52
  execFile(file, args, { encoding: "utf8", timeout: 5e3, maxBuffer: 16384, signal, windowsHide: true }, (error, stdout) => {
41
53
  if (error) reject(new Error("Jev credential resolver failed"));
@@ -52,20 +64,24 @@ var JevCredentials = class {
52
64
  }
53
65
  };
54
66
  var JevClient = class {
55
- constructor(config, fetcher = fetch, credentials) {
67
+ constructor(config, fetcher = fetch, credentials, route = JEV_TYPESAFE_ROUTE) {
56
68
  this.config = config;
57
69
  this.fetcher = fetcher;
58
- this.credentials = credentials ?? new JevCredentials(config.credentialCommand);
70
+ this.route = route;
71
+ this.credentials = credentials ?? new JevCredentials(config.credentialCommand, process.env, void 0, route.envKeys);
59
72
  }
60
73
  credentials;
61
74
  async evaluate(request, signal) {
62
75
  checkRequest(request, this.config.maxRequestBytes);
76
+ const requestedModel = request.model ?? this.config.model;
77
+ const model = resolveJevUpstreamModel(this.route, requestedModel);
78
+ if (!model) throw new Error(`Jev model "${requestedModel}" is not available on the ${this.route.label} route`);
63
79
  const timedSignal = AbortSignal.any([signal, AbortSignal.timeout(this.config.requestTimeoutMs)]);
64
80
  const key = await runAbortable(timedSignal, () => this.credentials.resolve(timedSignal));
65
- const body = jsonText({ ...request, model: request.model ?? this.config.model }, this.config.maxRequestBytes, "Jev request");
81
+ const body = jsonText({ ...request, model }, this.config.maxRequestBytes, "Jev request");
66
82
  let response;
67
83
  try {
68
- response = await runAbortable(timedSignal, () => this.fetcher("https://api.typesafe.ai/v1/systemone", {
84
+ response = await runAbortable(timedSignal, () => this.fetcher(this.route.endpoint, {
69
85
  method: "POST",
70
86
  redirect: "error",
71
87
  signal: timedSignal,
@@ -77,10 +93,10 @@ var JevClient = class {
77
93
  }
78
94
  if (!response.ok) {
79
95
  await response.body?.cancel();
80
- throw new Error(`TypeSafe HTTP ${response.status}${[429, 529].includes(response.status) ? ": rate limited; back off before retrying" : ""}`);
96
+ throw new Error(`${this.route.label} HTTP ${response.status}${[429, 529].includes(response.status) ? ": rate limited; back off before retrying" : ""}`);
81
97
  }
82
98
  const reader = response.body?.getReader();
83
- if (!reader) throw new Error("TypeSafe returned an empty response");
99
+ if (!reader) throw new Error(`${this.route.label} returned an empty response`);
84
100
  const chunks = [];
85
101
  let bytes = 0;
86
102
  try {
@@ -93,7 +109,7 @@ var JevClient = class {
93
109
  }
94
110
  return checkResponse(JSON.parse(Buffer.concat(chunks).toString("utf8")), request);
95
111
  } catch {
96
- throw new Error(timedSignal.aborted ? "Jev response cancelled or timed out" : "TypeSafe returned an invalid or oversized typed response");
112
+ throw new Error(timedSignal.aborted ? "Jev response cancelled or timed out" : `${this.route.label} returned an invalid or oversized typed response`);
97
113
  } finally {
98
114
  await reader.cancel().catch(() => void 0);
99
115
  }
@@ -107,4 +123,4 @@ export {
107
123
  JevCredentials,
108
124
  JevClient
109
125
  };
110
- //# sourceMappingURL=chunk-M3S7XITB.js.map
126
+ //# sourceMappingURL=chunk-TGAVMUOS.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/jev/client.ts"],
4
+ "sourcesContent": ["import { execFile } from \"node:child_process\";\nimport { runAbortable } from \"../async-settlement.js\";\nimport type { FabricJevConfig } from \"./config.js\";\nimport type { JevRequest, JevResponse } from \"./types.js\";\nimport { JEV_TYPESAFE_ROUTE, resolveJevUpstreamModel, type JevRoute } from \"./routes.js\";\nimport { checkRequest, checkResponse, jsonText } from \"./validation.js\";\n\nexport interface JevCredentialSource {\n configured(): boolean;\n resolve(signal: AbortSignal): Promise<string | undefined>;\n}\nexport class JevCredentials {\n #cached: string | undefined;\n constructor(\n readonly command: readonly string[],\n private readonly env: NodeJS.ProcessEnv = process.env,\n private readonly providerAuth?: JevCredentialSource,\n /** Route-specific environment fallbacks, in order. */\n private readonly envKeys: readonly string[] = JEV_TYPESAFE_ROUTE.envKeys,\n ) {}\n #envCredential(): string | undefined {\n for (const key of this.envKeys) {\n const value = this.env[key]?.trim();\n if (value) return value;\n }\n return undefined;\n }\n status() {\n const source = this.providerAuth?.configured() ? \"pi\" : this.#envCredential() ? \"environment\" : this.command.length ? \"command\" : \"missing\";\n return { configured: source !== \"missing\", source, verified: false };\n }\n async resolve(signal: AbortSignal): Promise<string> {\n signal.throwIfAborted();\n if (this.providerAuth) {\n try {\n const key = await this.providerAuth.resolve(signal);\n signal.throwIfAborted();\n if (key?.trim()) return key.trim();\n } catch { throw new Error(\"Jev Pi credential resolution failed\"); }\n }\n const env = this.#envCredential();\n if (env) return env;\n if (this.#cached) return this.#cached;\n const [file, ...args] = this.command;\n if (!file) throw new Error(`Jev credentials unavailable: set ${this.envKeys.join(\" or \")} or configure jev.credentialCommand`);\n const secret = await new Promise<string>((resolve, reject) => {\n execFile(file, args, { encoding: \"utf8\", timeout: 5_000, maxBuffer: 16_384, signal, windowsHide: true }, (error, stdout) => {\n // Never propagate subprocess errors: they can contain stdout/stderr secrets.\n if (error) reject(new Error(\"Jev credential resolver failed\"));\n else resolve(stdout.trim());\n });\n });\n signal.throwIfAborted();\n if (!secret || /[\\r\\n]/.test(secret)) throw new Error(\"Jev credential resolver returned an invalid credential\");\n this.#cached = secret;\n return secret;\n }\n clear(): void { this.#cached = undefined; }\n}\nexport class JevClient {\n readonly credentials: JevCredentials;\n constructor(\n readonly config: FabricJevConfig,\n private readonly fetcher: typeof fetch = fetch,\n credentials?: JevCredentials,\n readonly route: JevRoute = JEV_TYPESAFE_ROUTE,\n ) {\n this.credentials = credentials ?? new JevCredentials(config.credentialCommand, process.env, undefined, route.envKeys);\n }\n async evaluate(request: JevRequest, signal: AbortSignal): Promise<JevResponse> {\n checkRequest(request, this.config.maxRequestBytes);\n const requestedModel = request.model ?? this.config.model;\n const model = resolveJevUpstreamModel(this.route, requestedModel);\n if (!model) throw new Error(`Jev model \"${requestedModel}\" is not available on the ${this.route.label} route`);\n const timedSignal = AbortSignal.any([signal, AbortSignal.timeout(this.config.requestTimeoutMs)]);\n const key = await runAbortable(timedSignal, () => this.credentials.resolve(timedSignal));\n const body = jsonText({ ...request, model }, this.config.maxRequestBytes, \"Jev request\");\n let response: Response;\n try {\n response = await runAbortable(timedSignal, () => this.fetcher(this.route.endpoint, {\n method: \"POST\", redirect: \"error\", signal: timedSignal,\n headers: { \"Content-Type\": \"application/json\", Authorization: `Bearer ${key}` }, body,\n }));\n } catch {\n throw new Error(timedSignal.aborted ? \"Jev request cancelled or timed out\" : \"Jev network request failed\");\n }\n if (!response.ok) {\n await response.body?.cancel();\n // No automatic retry: the controller decides whether a delayed decision is still useful.\n throw new Error(`${this.route.label} HTTP ${response.status}${[429, 529].includes(response.status) ? \": rate limited; back off before retrying\" : \"\"}`);\n }\n const reader = response.body?.getReader();\n if (!reader) throw new Error(`${this.route.label} returned an empty response`);\n const chunks: Uint8Array[] = [];\n let bytes = 0;\n try {\n for (;;) {\n const { value, done } = await runAbortable(timedSignal, () => reader.read());\n if (done) break;\n bytes += value.byteLength;\n if (bytes > 1_048_576) throw new Error(\"oversize\");\n chunks.push(value);\n }\n return checkResponse(JSON.parse(Buffer.concat(chunks).toString(\"utf8\")), request);\n } catch {\n throw new Error(timedSignal.aborted ? \"Jev response cancelled or timed out\" : `${this.route.label} returned an invalid or oversized typed response`);\n } finally { await reader.cancel().catch(() => undefined); }\n }\n close(): void { this.credentials.clear(); }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AAWlB,IAAM,iBAAN,MAAqB;AAAA,EAE1B,YACW,SACQ,MAAyB,QAAQ,KACjC,cAEA,UAA6B,mBAAmB,SACjE;AALS;AACQ;AACA;AAEA;AAAA,EAChB;AAAA,EAPH;AAAA,EAQA,iBAAqC;AACnC,eAAW,OAAO,KAAK,SAAS;AAC9B,YAAM,QAAQ,KAAK,IAAI,GAAG,GAAG,KAAK;AAClC,UAAI,MAAO,QAAO;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAAA,EACA,SAAS;AACP,UAAM,SAAS,KAAK,cAAc,WAAW,IAAI,OAAO,KAAK,eAAe,IAAI,gBAAgB,KAAK,QAAQ,SAAS,YAAY;AAClI,WAAO,EAAE,YAAY,WAAW,WAAW,QAAQ,UAAU,MAAM;AAAA,EAC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aAAa,aAAa,MAAM,OAAO,KAAK,CAAC;AAC3E,YAAI,KAAM;AACV,iBAAS,MAAM;AACf,YAAI,QAAQ,QAAW,OAAM,IAAI,MAAM,UAAU;AACjD,eAAO,KAAK,KAAK;AAAA,MACnB;AACA,aAAO,cAAc,KAAK,MAAM,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,GAAG,OAAO;AAAA,IAClF,QAAQ;AACN,YAAM,IAAI,MAAM,YAAY,UAAU,wCAAwC,GAAG,KAAK,MAAM,KAAK,kDAAkD;AAAA,IACrJ,UAAE;AAAU,YAAM,OAAO,OAAO,EAAE,MAAM,MAAM,MAAS;AAAA,IAAG;AAAA,EAC5D;AAAA,EACA,QAAc;AAAE,SAAK,YAAY,MAAM;AAAA,EAAG;AAC5C;",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ // src/residency/protocol.ts
2
+ import { createHash } from "node:crypto";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ var sleepUnlessAborted = (ms, signal) => (
6
+ // Executor form: the configured lib is ES2022, which has no
7
+ // Promise.withResolvers, and an abort listener plus a timer need shared
8
+ // completion control.
9
+ new Promise((resolve, reject) => {
10
+ const aborted = () => signal?.reason instanceof Error ? signal.reason : new Error("Fabric residency request was aborted");
11
+ if (signal?.aborted) {
12
+ reject(aborted());
13
+ return;
14
+ }
15
+ const timer = setTimeout(() => {
16
+ signal?.removeEventListener("abort", onAbort);
17
+ resolve();
18
+ }, Math.max(0, ms));
19
+ timer.unref?.();
20
+ const onAbort = () => {
21
+ clearTimeout(timer);
22
+ reject(aborted());
23
+ };
24
+ signal?.addEventListener("abort", onAbort, { once: true });
25
+ })
26
+ );
27
+ var abandonResidentRequest = (requestsPath, responsesPath, requestId) => {
28
+ for (const directory of [requestsPath, responsesPath]) {
29
+ try {
30
+ fs.rmSync(path.join(directory, `${requestId}.json`), { force: true });
31
+ } catch {
32
+ }
33
+ }
34
+ };
35
+ var RESIDENT_HOST_FORMAT = 1;
36
+ var RESIDENT_DELIVERY_PREFIX = "residency/deliveries/";
37
+ var digest = (value) => createHash("sha256").update(value).digest("hex");
38
+ var residentHostId = (rootId) => `resident:${digest(rootId).slice(0, 24)}`;
39
+ var residentRoot = (meshRoot, rootId) => path.join(meshRoot, "residency", digest(rootId));
40
+ var residentDeliveryPrefix = (rootId) => `${RESIDENT_DELIVERY_PREFIX}${digest(rootId).slice(0, 32)}/`;
41
+
42
+ export {
43
+ sleepUnlessAborted,
44
+ abandonResidentRequest,
45
+ RESIDENT_HOST_FORMAT,
46
+ residentHostId,
47
+ residentRoot,
48
+ residentDeliveryPrefix
49
+ };
50
+ //# sourceMappingURL=chunk-TX6E5W7H.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/residency/protocol.ts"],
4
+ "sourcesContent": ["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { FabricOwnedModelGuidance } from \"../components/model-guidance.js\";\nimport type { FabricModelAliases, FabricModelCandidate } from \"../core/model-resolution.js\";\nimport type { FabricAgentConfig, FabricMeshConfig, FabricRetentionConfig } from \"../config.js\";\nimport type { FabricActorInfo, FabricActorRequest } from \"../actors/types.js\";\nimport type { AgentHandleInfo, AgentRunRequest } from \"../agents/types.js\";\nimport type { FabricKernel } from \"../runtime/kernel.js\";\nimport type { MeshIdentity } from \"../mesh/store.js\";\nexport const sleepUnlessAborted = (ms: number, signal?: AbortSignal): Promise<void> =>\n // Executor form: the configured lib is ES2022, which has no\n // Promise.withResolvers, and an abort listener plus a timer need shared\n // completion control.\n new Promise<void>((resolve, reject) => {\n const aborted = (): Error =>\n signal?.reason instanceof Error ? signal.reason : new Error(\"Fabric residency request was aborted\");\n if (signal?.aborted) {\n reject(aborted());\n return;\n }\n const timer = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n }, Math.max(0, ms));\n timer.unref?.();\n const onAbort = (): void => {\n clearTimeout(timer);\n reject(aborted());\n };\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n\n/**\n * Remove an abandoned file-exchange request. The resident host renames\n * unstarted requests out of `requests/` before running them, so deleting our\n * file cancels work the host has not picked up yet; a late host response is\n * removed as well. Deleting a request the host already moved is a no-op, and\n * in-flight work still runs to completion. Best effort: never throws.\n */\nexport const abandonResidentRequest = (\n requestsPath: string,\n responsesPath: string,\n requestId: string,\n): void => {\n for (const directory of [requestsPath, responsesPath]) {\n try {\n fs.rmSync(path.join(directory, `${requestId}.json`), { force: true });\n } catch { /* best effort: an abandoned request must not raise a second error */ }\n }\n};\n\nexport const RESIDENT_HOST_FORMAT = 1 as const;\nconst RESIDENT_DELIVERY_PREFIX = \"residency/deliveries/\";\n\nconst digest = (value: string): string =>\n createHash(\"sha256\").update(value).digest(\"hex\");\n\nexport const residentHostId = (rootId: string): string =>\n `resident:${digest(rootId).slice(0, 24)}`;\n\nexport const residentRoot = (meshRoot: string, rootId: string): string =>\n path.join(meshRoot, \"residency\", digest(rootId));\n\nexport const residentDeliveryPrefix = (rootId: string): string =>\n `${RESIDENT_DELIVERY_PREFIX}${digest(rootId).slice(0, 32)}/`;\n\nexport interface ResidentPiModelState {\n available: FabricModelCandidate[];\n aliases: FabricModelAliases;\n defaultModel?: string;\n}\n\nexport interface ResidentHostConfig {\n format: typeof RESIDENT_HOST_FORMAT;\n rootId: string;\n sessionId: string;\n cwd: string;\n projectRoot: string;\n meshRoot: string;\n actorRoot: string;\n sessionActorRoot?: string;\n residencyRoot: string;\n fullCodeMode: boolean;\n kernel?: FabricKernel;\n pythonRuntime?: \"cpython\" | \"monty\";\n agents: FabricAgentConfig;\n mesh: FabricMeshConfig;\n retention: FabricRetentionConfig;\n workerPath: string;\n fabricExtensionPath: string;\n piBinary: string;\n claudeBinary: string;\n vedaBinary: string;\n piModels?: ResidentPiModelState;\n modelGuidance?: FabricOwnedModelGuidance[];\n}\n\nexport interface ResidentHostOwner {\n format: typeof RESIDENT_HOST_FORMAT;\n hostId: string;\n pid: number;\n token: string;\n startedAt: number;\n readyAt: number;\n}\n\ninterface ResidentSpawnCommand {\n format: typeof RESIDENT_HOST_FORMAT;\n operation: \"spawn\";\n requestId: string;\n rootId: string;\n request: AgentRunRequest;\n createdAt: number;\n}\n\ninterface ResidentCleanupCommand {\n format: typeof RESIDENT_HOST_FORMAT;\n operation: \"cleanup\";\n requestId: string;\n rootId: string;\n id: string;\n deleteBranch: boolean;\n createdAt: number;\n}\n\ninterface ResidentForegroundCommand {\n format: typeof RESIDENT_HOST_FORMAT;\n operation: \"foreground\";\n requestId: string;\n rootId: string;\n id: string;\n createdAt: number;\n}\n\ninterface ResidentRemoveActorCommand {\n format: typeof RESIDENT_HOST_FORMAT;\n operation: \"removeActor\";\n requestId: string;\n rootId: string;\n id: string;\n createdAt: number;\n}\n\ninterface ResidentCreateActorCommand {\n format: typeof RESIDENT_HOST_FORMAT;\n operation: \"createActor\";\n requestId: string;\n rootId: string;\n request: FabricActorRequest;\n createdAt: number;\n}\n\nexport type ResidentCommand =\n | ResidentSpawnCommand\n | ResidentCleanupCommand\n | ResidentForegroundCommand\n | ResidentRemoveActorCommand\n | ResidentCreateActorCommand;\n\nexport interface ResidentCommandResponse {\n format: typeof RESIDENT_HOST_FORMAT;\n requestId: string;\n ok: boolean;\n handle?: AgentHandleInfo;\n actor?: FabricActorInfo;\n error?: string;\n completedAt: number;\n}\n\nexport interface ResidentAgentMetadata {\n format: typeof RESIDENT_HOST_FORMAT;\n rootId: string;\n id: string;\n runDirectory: string;\n handle: AgentHandleInfo;\n worktreeGitRoot?: string;\n /** Main consumed this terminal result; suppress queued delivery across reconnects. */\n completionConsumedAt?: number;\n createdAt: number;\n updatedAt: number;\n}\n\nexport interface ResidentDeliveryRecord {\n format: typeof RESIDENT_HOST_FORMAT;\n /** Survives payload truncation; lets Main read the authoritative terminal result. */\n agentCompletionId?: string;\n id: string;\n rootId: string;\n from: MeshIdentity;\n delivery: \"steer\" | \"followUp\";\n triggerTurn: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AAM,EAAE,MAAM,GAAG,EAAE,CAAC;",
6
+ "names": []
7
+ }
@@ -1,3 +1,7 @@
1
+ import {
2
+ isJevModelId
3
+ } from "./chunk-B54Z662X.js";
4
+
1
5
  // src/jev/config.ts
2
6
  var DEFAULT_JEV_CONFIG = {
3
7
  enabled: true,
@@ -22,7 +26,8 @@ function normalizeJevConfig(value) {
22
26
  const command = input.credentialCommand;
23
27
  return {
24
28
  enabled: typeof input.enabled === "boolean" ? input.enabled : true,
25
- model: typeof input.model === "string" && /^[a-zA-Z0-9._-]{1,128}$/.test(input.model) ? input.model : DEFAULT_JEV_CONFIG.model,
29
+ // Bare aliases use the direct route; `~typesafe/...` and `typesafe/...` select OpenRouter decisions.
30
+ model: typeof input.model === "string" && isJevModelId(input.model) ? input.model : DEFAULT_JEV_CONFIG.model,
26
31
  autoApprovalThreshold: typeof input.autoApprovalThreshold === "number" && Number.isFinite(input.autoApprovalThreshold) && input.autoApprovalThreshold >= 0 && input.autoApprovalThreshold <= 1 ? input.autoApprovalThreshold : DEFAULT_JEV_CONFIG.autoApprovalThreshold,
27
32
  credentialCommand: Array.isArray(command) && command.length <= 16 && command.every((v) => typeof v === "string" && v.length > 0 && v.length <= 4096 && !v.includes("\0")) ? [...command] : [],
28
33
  requestTimeoutMs: integer("requestTimeoutMs", 12e4, 100),
@@ -36,16 +41,8 @@ function normalizeJevConfig(value) {
36
41
  };
37
42
  }
38
43
 
39
- // src/jev/model-key.ts
40
- var JEV_APPROVAL_MODEL_PREFIX = "pi-fabric/typesafe/";
41
- var normalizeJevApprovalModel = (key) => key?.startsWith("jev/") ? `${JEV_APPROVAL_MODEL_PREFIX}${key.slice(4)}` : key;
42
- var isJevApprovalModel = (key) => normalizeJevApprovalModel(key)?.startsWith(JEV_APPROVAL_MODEL_PREFIX) ?? false;
43
-
44
44
  export {
45
45
  DEFAULT_JEV_CONFIG,
46
- normalizeJevConfig,
47
- JEV_APPROVAL_MODEL_PREFIX,
48
- normalizeJevApprovalModel,
49
- isJevApprovalModel
46
+ normalizeJevConfig
50
47
  };
51
- //# sourceMappingURL=chunk-X3OD47CL.js.map
48
+ //# sourceMappingURL=chunk-UR2K6WK6.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/jev/config.ts"],
4
+ "sourcesContent": ["import { isJevModelId } from \"./routes.js\";\n\nexport interface FabricJevConfig {\n enabled: boolean;\n model: string;\n /** Minimum Noul safety probability for Jev auto approvals (0\u20131). */\n autoApprovalThreshold: number;\n /** Trusted host configuration only; argv, never a shell expression. */\n credentialCommand: string[];\n requestTimeoutMs: number;\n maxRequestBytes: number;\n maxConcurrentRuns: number;\n maxRetainedRuns: number;\n maxDurationMs: number;\n maxEvaluations: number;\n maxToolCalls: number;\n maxTokens: number;\n}\nexport const DEFAULT_JEV_CONFIG: FabricJevConfig = {\n enabled: true,\n model: \"jev-latest\",\n autoApprovalThreshold: 0.5,\n credentialCommand: [],\n requestTimeoutMs: 15_000,\n maxRequestBytes: 131_072,\n maxConcurrentRuns: 4,\n maxRetainedRuns: 64,\n maxDurationMs: 900_000,\n maxEvaluations: 1_000,\n maxToolCalls: 10_000,\n maxTokens: 1_000_000,\n};\nexport function normalizeJevConfig(value: unknown): FabricJevConfig {\n const input = value && typeof value === \"object\" && !Array.isArray(value)\n ? value as Record<string, unknown> : {};\n const integer = (key: keyof FabricJevConfig, max: number, min = 1): number => {\n const v = input[key];\n return typeof v === \"number\" && Number.isFinite(v)\n ? Math.max(min, Math.min(max, Math.floor(v))) : DEFAULT_JEV_CONFIG[key] as number;\n };\n const command = input.credentialCommand;\n return {\n enabled: typeof input.enabled === \"boolean\" ? input.enabled : true,\n // Bare aliases use the direct route; `~typesafe/...` and `typesafe/...` select OpenRouter decisions.\n model: typeof input.model === \"string\" && isJevModelId(input.model)\n ? input.model : DEFAULT_JEV_CONFIG.model,\n autoApprovalThreshold: typeof input.autoApprovalThreshold === \"number\" &&\n Number.isFinite(input.autoApprovalThreshold) && input.autoApprovalThreshold >= 0 && input.autoApprovalThreshold <= 1\n ? input.autoApprovalThreshold : DEFAULT_JEV_CONFIG.autoApprovalThreshold,\n credentialCommand: Array.isArray(command) && command.length <= 16 &&\n command.every(v => typeof v === \"string\" && v.length > 0 && v.length <= 4096 && !v.includes(\"\\0\"))\n ? [...command] as string[] : [],\n requestTimeoutMs: integer(\"requestTimeoutMs\", 120_000, 100),\n maxRequestBytes: integer(\"maxRequestBytes\", 1_048_576, 1024),\n maxConcurrentRuns: integer(\"maxConcurrentRuns\", 16),\n maxRetainedRuns: integer(\"maxRetainedRuns\", 256),\n maxDurationMs: integer(\"maxDurationMs\", 86_400_000, 100),\n maxEvaluations: integer(\"maxEvaluations\", 100_000),\n maxToolCalls: integer(\"maxToolCalls\", 1_000_000),\n maxTokens: integer(\"maxTokens\", 100_000_000),\n };\n}\n"],
5
+ "mappings": ";;;;;AAkBO,IAAM,qBAAsC;AAAA,EACjD,SAAS;AAAA,EACT,OAAO;AAAA,EACP,uBAAuB;AAAA,EACvB,mBAAmB,CAAC;AAAA,EACpB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,WAAW;AACb;AACO,SAAS,mBAAmB,OAAiC;AAClE,QAAM,QAAQ,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IACpE,QAAmC,CAAC;AACxC,QAAM,UAAU,CAAC,KAA4B,KAAa,MAAM,MAAc;AAC5E,UAAM,IAAI,MAAM,GAAG;AACnB,WAAO,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAC7C,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,mBAAmB,GAAG;AAAA,EAC1E;AACA,QAAM,UAAU,MAAM;AACtB,SAAO;AAAA,IACL,SAAS,OAAO,MAAM,YAAY,YAAY,MAAM,UAAU;AAAA;AAAA,IAE9D,OAAO,OAAO,MAAM,UAAU,YAAY,aAAa,MAAM,KAAK,IAC9D,MAAM,QAAQ,mBAAmB;AAAA,IACrC,uBAAuB,OAAO,MAAM,0BAA0B,YAC5D,OAAO,SAAS,MAAM,qBAAqB,KAAK,MAAM,yBAAyB,KAAK,MAAM,yBAAyB,IACjH,MAAM,wBAAwB,mBAAmB;AAAA,IACrD,mBAAmB,MAAM,QAAQ,OAAO,KAAK,QAAQ,UAAU,MAC7D,QAAQ,MAAM,OAAK,OAAO,MAAM,YAAY,EAAE,SAAS,KAAK,EAAE,UAAU,QAAQ,CAAC,EAAE,SAAS,IAAI,CAAC,IAC/F,CAAC,GAAG,OAAO,IAAgB,CAAC;AAAA,IAChC,kBAAkB,QAAQ,oBAAoB,MAAS,GAAG;AAAA,IAC1D,iBAAiB,QAAQ,mBAAmB,SAAW,IAAI;AAAA,IAC3D,mBAAmB,QAAQ,qBAAqB,EAAE;AAAA,IAClD,iBAAiB,QAAQ,mBAAmB,GAAG;AAAA,IAC/C,eAAe,QAAQ,iBAAiB,OAAY,GAAG;AAAA,IACvD,gBAAgB,QAAQ,kBAAkB,GAAO;AAAA,IACjD,cAAc,QAAQ,gBAAgB,GAAS;AAAA,IAC/C,WAAW,QAAQ,aAAa,GAAW;AAAA,EAC7C;AACF;",
6
+ "names": []
7
+ }
@@ -1,3 +1,7 @@
1
+ import {
2
+ isJevModelId
3
+ } from "./chunk-B54Z662X.js";
4
+
1
5
  // src/jev/validation.ts
2
6
  import { Value } from "typebox/value";
3
7
  function jsonText(value, maxBytes, label) {
@@ -26,7 +30,7 @@ var description = (v) => typeof v === "string" || object(v) || Array.isArray(v);
26
30
  var keysOnly = (v, keys) => Object.keys(v).every((k) => keys.includes(k));
27
31
  function checkRequest(value, maxBytes) {
28
32
  jsonText(value, maxBytes, "Jev request");
29
- if (!object(value) || !keysOnly(value, ["state", "questions", "model"]) || !description(value.state) || !object(value.questions) || Object.keys(value.questions).length < 1 || Object.keys(value.questions).length > 128 || value.model !== void 0 && (typeof value.model !== "string" || !/^[a-zA-Z0-9._-]{1,128}$/.test(value.model))) {
33
+ if (!object(value) || !keysOnly(value, ["state", "questions", "model"]) || !description(value.state) || !object(value.questions) || Object.keys(value.questions).length < 1 || Object.keys(value.questions).length > 128 || value.model !== void 0 && (typeof value.model !== "string" || !isJevModelId(value.model))) {
30
34
  throw new Error("Invalid Jev request: provide state, 1\u2013128 questions, and an optional model ID");
31
35
  }
32
36
  for (const [id, q] of Object.entries(value.questions)) {
@@ -118,4 +122,4 @@ export {
118
122
  checkSchema,
119
123
  checkValue
120
124
  };
121
- //# sourceMappingURL=chunk-Z63R5GVN.js.map
125
+ //# sourceMappingURL=chunk-WHBJDTCR.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/jev/validation.ts"],
4
+ "sourcesContent": ["import { Value } from \"typebox/value\";\nimport { isJevModelId } from \"./routes.js\";\nimport type { JevJson, JevRequest, JevResponse, JevAnswer } from \"./types.js\";\n\nexport function jsonText(value: unknown, maxBytes: number, label: string): string {\n let nodes = 0;\n const visit = (v: unknown, depth: number): void => {\n if (++nodes > 100_000 || depth > 32) throw new Error(`${label} exceeds JSON complexity limits`);\n if (v === null || typeof v === \"string\" || typeof v === \"boolean\") return;\n if (typeof v === \"number\" && Number.isFinite(v)) return;\n if (Array.isArray(v)) { for (const item of v) visit(item, depth + 1); return; }\n if (typeof v === \"object\" && v !== null && Object.getPrototypeOf(v) === Object.prototype) {\n for (const item of Object.values(v)) visit(item, depth + 1);\n return;\n }\n throw new Error(`${label} must contain only finite JSON values`);\n };\n visit(value, 0);\n const text = JSON.stringify(value);\n if (Buffer.byteLength(text) > maxBytes) throw new Error(`${label} exceeds ${maxBytes} bytes`);\n return text;\n}\nexport const object = (v: unknown): v is Record<string, unknown> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\nconst description = (v: unknown): boolean => typeof v === \"string\" || object(v) || Array.isArray(v);\nconst keysOnly = (v: Record<string, unknown>, keys: string[]) => Object.keys(v).every(k => keys.includes(k));\n\nexport function checkRequest(value: unknown, maxBytes: number): asserts value is JevRequest {\n jsonText(value, maxBytes, \"Jev request\");\n if (!object(value) || !keysOnly(value, [\"state\", \"questions\", \"model\"]) || !description(value.state) ||\n !object(value.questions) || Object.keys(value.questions).length < 1 || Object.keys(value.questions).length > 128 ||\n (value.model !== undefined && (typeof value.model !== \"string\" || !isJevModelId(value.model)))) {\n throw new Error(\"Invalid Jev request: provide state, 1\u2013128 questions, and an optional model ID\");\n }\n for (const [id, q] of Object.entries(value.questions)) {\n if (!id || id.length > 128 || !object(q) || !keysOnly(q, [\"type\", \"instructions\", \"criteria\"]) || !description(q.instructions))\n throw new Error(\"Invalid Jev question: each question needs a type and complete instructions\");\n if (q.type === \"choice\") {\n if (!object(q.criteria) || Object.keys(q.criteria).length < 1 || Object.keys(q.criteria).length > 255 ||\n !Object.entries(q.criteria).every(([key, v]) => key.length > 0 && key.length <= 256 && (v === null || description(v))))\n throw new Error(\"Choice requires 1\u2013255 named options with descriptions or null\");\n } else if (q.type === \"score\") {\n if (!Array.isArray(q.criteria) || q.criteria.length < 2 || q.criteria.length > 10 || !q.criteria.every(description))\n throw new Error(\"Score requires 2\u201310 ordered descriptive levels\");\n } else if (q.type === \"noul\") {\n if (q.criteria !== undefined && (!object(q.criteria) || !keysOnly(q.criteria, [\"true\", \"false\"]) || !Object.values(q.criteria).every(description)))\n throw new Error(\"Noul criteria may describe true and false only\");\n } else throw new Error(\"Jev supports choice, score, and noul\u2014not free-text generation\");\n }\n}\nconst probability = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v) && v >= 0 && v <= 1;\nexport function checkResponse(value: unknown, request: JevRequest): JevResponse {\n const invalid = (): never => { throw new Error(\"TypeSafe returned an invalid typed response\"); };\n if (!object(value) || typeof value.model !== \"string\" || value.model.length > 128 || !object(value.answers) || !object(value.usage)) return invalid();\n const usage = value.usage;\n if (![usage.input_tokens, usage.output_tokens].every(v => Number.isSafeInteger(v) && (v as number) >= 0)) return invalid();\n if (Object.keys(value.answers).length !== Object.keys(request.questions).length) return invalid();\n const entries: Array<[string, JevAnswer]> = [];\n for (const [id, question] of Object.entries(request.questions)) {\n const a = Object.hasOwn(value.answers, id) ? value.answers[id] : undefined;\n if (!object(a) || a.type !== question.type) return invalid();\n if (question.type === \"noul\") {\n if (!probability(a.noul)) return invalid();\n entries.push([id, { type: \"noul\", noul: a.noul }]);\n continue;\n }\n const keys = question.type === \"choice\" ? Object.keys(question.criteria) : question.criteria.map((_, i) => String(i));\n const p = a.probabilities;\n if (!probability(a.confidence) || !object(p) || Object.keys(p).length !== keys.length ||\n !keys.every(k => Object.hasOwn(p, k) && probability(p[k])) ||\n Math.abs(Object.values(p).reduce<number>((sum, v) => sum + (v as number), 0) - 1) > 0.02) return invalid();\n const probabilities = Object.fromEntries(keys.map(k => [k, p[k] as number]));\n if (question.type === \"choice\") {\n if (typeof a.choice !== \"string\" || !Object.hasOwn(question.criteria, a.choice)) return invalid();\n entries.push([id, { type: \"choice\", choice: a.choice, confidence: a.confidence, probabilities }]);\n } else {\n if (typeof a.score !== \"number\" || !Number.isFinite(a.score) || a.score < 0 || a.score > keys.length - 1) return invalid();\n // Rubrics come from the request, not arbitrary server-produced content.\n const legend = Object.fromEntries(question.criteria.map((level, i) => [String(i), level]));\n entries.push([id, { type: \"score\", score: a.score, confidence: a.confidence, probabilities, legend }]);\n }\n }\n return { model: value.model, answers: Object.fromEntries(entries), usage: {\n input_tokens: usage.input_tokens as number, output_tokens: usage.output_tokens as number,\n } };\n}\n\nconst schemaKeys = new Set([\"type\", \"properties\", \"required\", \"additionalProperties\", \"items\", \"enum\", \"const\", \"anyOf\", \"oneOf\", \"allOf\", \"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"minItems\", \"maxItems\", \"minProperties\", \"maxProperties\", \"description\", \"title\"]);\nexport function checkSchema(schema: unknown): asserts schema is Record<string, unknown> {\n jsonText(schema, 16_384, \"Program schema\");\n let nodes = 0;\n const visit = (s: unknown, depth: number): void => {\n if (!object(s) || ++nodes > 128 || depth > 12 || Object.keys(s).some(k => !schemaKeys.has(k)))\n throw new Error(\"Unsupported program schema; use the documented bounded JSON Schema subset (no references or regexes)\");\n if (s.type !== undefined && ![\"object\", \"array\", \"string\", \"number\", \"integer\", \"boolean\", \"null\"].includes(s.type as string)) throw new Error(\"Invalid schema type\");\n if (s.properties !== undefined) {\n if (!object(s.properties)) throw new Error(\"Schema properties must be an object\");\n Object.values(s.properties).forEach(v => visit(v, depth + 1));\n }\n if (s.required !== undefined && (!Array.isArray(s.required) || !s.required.every(v => typeof v === \"string\"))) throw new Error(\"Schema required must be a string array\");\n if (s.additionalProperties !== undefined && typeof s.additionalProperties !== \"boolean\") visit(s.additionalProperties, depth + 1);\n if (s.items !== undefined) visit(s.items, depth + 1);\n for (const k of [\"anyOf\", \"oneOf\", \"allOf\"]) if (s[k] !== undefined) {\n if (!Array.isArray(s[k]) || s[k].length < 1 || s[k].length > 16) throw new Error(\"Invalid schema alternatives\");\n s[k].forEach(v => visit(v, depth + 1));\n }\n for (const k of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"minItems\", \"maxItems\", \"minProperties\", \"maxProperties\"])\n if (s[k] !== undefined && (typeof s[k] !== \"number\" || !Number.isFinite(s[k]) || (!['minimum', 'maximum'].includes(k) && (!Number.isSafeInteger(s[k]) || s[k] < 0)))) throw new Error(\"Invalid schema bound\");\n if (s.enum !== undefined && (!Array.isArray(s.enum) || s.enum.length === 0 || s.enum.length > 256)) throw new Error(\"Invalid schema enum\");\n };\n visit(schema, 0);\n}\nexport function checkValue(schema: Record<string, unknown>, value: unknown, label: string): asserts value is JevJson {\n jsonText(value, 32_768, label);\n if (!Value.Check(schema, value)) throw new Error(`${label} does not match its declared schema`);\n}\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,aAAa;AAIf,SAAS,SAAS,OAAgB,UAAkB,OAAuB;AAChF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