@wrenai/genbi 0.0.1

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 (286) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +141 -0
  3. package/bin/genbi.mjs +31 -0
  4. package/dist/assets/echarts-LTFC-ysd.js +40 -0
  5. package/dist/assets/index-Bo--QMUN.js +441 -0
  6. package/dist/assets/index-Xs4q7pNo.css +1 -0
  7. package/dist/index.html +14 -0
  8. package/dist/wrenai_logo.png +0 -0
  9. package/dist/wrenai_logo_white.png +0 -0
  10. package/dist-server/harness/auth/detect.d.ts +18 -0
  11. package/dist-server/harness/auth/detect.js +37 -0
  12. package/dist-server/harness/auth/index.d.ts +4 -0
  13. package/dist-server/harness/auth/index.js +2 -0
  14. package/dist-server/harness/auth/probe.d.ts +18 -0
  15. package/dist-server/harness/auth/probe.js +52 -0
  16. package/dist-server/harness/auth/types.d.ts +42 -0
  17. package/dist-server/harness/auth/types.js +9 -0
  18. package/dist-server/harness/bundle/loader.d.ts +32 -0
  19. package/dist-server/harness/bundle/loader.js +43 -0
  20. package/dist-server/harness/bundle/schema.d.ts +199 -0
  21. package/dist-server/harness/bundle/schema.js +127 -0
  22. package/dist-server/harness/bundle/version.d.ts +10 -0
  23. package/dist-server/harness/bundle/version.js +43 -0
  24. package/dist-server/harness/capability/gate.d.ts +6 -0
  25. package/dist-server/harness/capability/gate.js +29 -0
  26. package/dist-server/harness/capability/registry.d.ts +6 -0
  27. package/dist-server/harness/capability/registry.js +17 -0
  28. package/dist-server/harness/cli-args.d.ts +123 -0
  29. package/dist-server/harness/cli-args.js +247 -0
  30. package/dist-server/harness/cli.d.ts +2 -0
  31. package/dist-server/harness/cli.js +151 -0
  32. package/dist-server/harness/compile/cache.d.ts +23 -0
  33. package/dist-server/harness/compile/cache.js +109 -0
  34. package/dist-server/harness/compile/compose-profile.d.ts +34 -0
  35. package/dist-server/harness/compile/compose-profile.js +95 -0
  36. package/dist-server/harness/compile/errors.d.ts +22 -0
  37. package/dist-server/harness/compile/errors.js +41 -0
  38. package/dist-server/harness/compile/fingerprint.d.ts +22 -0
  39. package/dist-server/harness/compile/fingerprint.js +84 -0
  40. package/dist-server/harness/compile/index.d.ts +8 -0
  41. package/dist-server/harness/compile/index.js +7 -0
  42. package/dist-server/harness/compile/pipeline.d.ts +66 -0
  43. package/dist-server/harness/compile/pipeline.js +176 -0
  44. package/dist-server/harness/compile/resolve-binary.d.ts +55 -0
  45. package/dist-server/harness/compile/resolve-binary.js +133 -0
  46. package/dist-server/harness/compile/types.d.ts +107 -0
  47. package/dist-server/harness/compile/types.js +1 -0
  48. package/dist-server/harness/compile/warble-identity.d.ts +12 -0
  49. package/dist-server/harness/compile/warble-identity.js +33 -0
  50. package/dist-server/harness/compliance/gate.d.ts +35 -0
  51. package/dist-server/harness/compliance/gate.js +48 -0
  52. package/dist-server/harness/compliance/index.d.ts +2 -0
  53. package/dist-server/harness/compliance/index.js +1 -0
  54. package/dist-server/harness/compliance/types.d.ts +16 -0
  55. package/dist-server/harness/compliance/types.js +1 -0
  56. package/dist-server/harness/events/emitter.d.ts +34 -0
  57. package/dist-server/harness/events/emitter.js +25 -0
  58. package/dist-server/harness/events/index.d.ts +4 -0
  59. package/dist-server/harness/events/index.js +2 -0
  60. package/dist-server/harness/events/sse.d.ts +20 -0
  61. package/dist-server/harness/events/sse.js +48 -0
  62. package/dist-server/harness/events/types.d.ts +131 -0
  63. package/dist-server/harness/events/types.js +1 -0
  64. package/dist-server/harness/exec/errors.d.ts +16 -0
  65. package/dist-server/harness/exec/errors.js +29 -0
  66. package/dist-server/harness/exec/index.d.ts +5 -0
  67. package/dist-server/harness/exec/index.js +2 -0
  68. package/dist-server/harness/exec/local.d.ts +32 -0
  69. package/dist-server/harness/exec/local.js +134 -0
  70. package/dist-server/harness/exec/policy.d.ts +12 -0
  71. package/dist-server/harness/exec/policy.js +1 -0
  72. package/dist-server/harness/exec/types.d.ts +63 -0
  73. package/dist-server/harness/exec/types.js +1 -0
  74. package/dist-server/harness/guardrails/index.d.ts +2 -0
  75. package/dist-server/harness/guardrails/index.js +1 -0
  76. package/dist-server/harness/guardrails/policy.d.ts +45 -0
  77. package/dist-server/harness/guardrails/policy.js +57 -0
  78. package/dist-server/harness/index.d.ts +37 -0
  79. package/dist-server/harness/index.js +19 -0
  80. package/dist-server/harness/loop/errors.d.ts +53 -0
  81. package/dist-server/harness/loop/errors.js +72 -0
  82. package/dist-server/harness/loop/executor.d.ts +123 -0
  83. package/dist-server/harness/loop/executor.js +380 -0
  84. package/dist-server/harness/loop/guard.d.ts +16 -0
  85. package/dist-server/harness/loop/guard.js +1 -0
  86. package/dist-server/harness/loop/index.d.ts +5 -0
  87. package/dist-server/harness/loop/index.js +3 -0
  88. package/dist-server/harness/native-producer/index.d.ts +109 -0
  89. package/dist-server/harness/native-producer/index.js +302 -0
  90. package/dist-server/harness/npm-package-resolve.d.ts +28 -0
  91. package/dist-server/harness/npm-package-resolve.js +47 -0
  92. package/dist-server/harness/providers/adapters/anthropic.d.ts +7 -0
  93. package/dist-server/harness/providers/adapters/anthropic.js +6 -0
  94. package/dist-server/harness/providers/adapters/mock.d.ts +4 -0
  95. package/dist-server/harness/providers/adapters/mock.js +5 -0
  96. package/dist-server/harness/providers/adapters/openai-compatible.d.ts +10 -0
  97. package/dist-server/harness/providers/adapters/openai-compatible.js +10 -0
  98. package/dist-server/harness/providers/binding.d.ts +23 -0
  99. package/dist-server/harness/providers/binding.js +13 -0
  100. package/dist-server/harness/providers/errors.d.ts +6 -0
  101. package/dist-server/harness/providers/errors.js +12 -0
  102. package/dist-server/harness/providers/index.d.ts +18 -0
  103. package/dist-server/harness/providers/index.js +22 -0
  104. package/dist-server/harness/providers/registry.d.ts +16 -0
  105. package/dist-server/harness/providers/registry.js +24 -0
  106. package/dist-server/harness/render/envelope.d.ts +145 -0
  107. package/dist-server/harness/render/envelope.js +428 -0
  108. package/dist-server/harness/render/errors.d.ts +33 -0
  109. package/dist-server/harness/render/errors.js +46 -0
  110. package/dist-server/harness/render/index.d.ts +5 -0
  111. package/dist-server/harness/render/index.js +3 -0
  112. package/dist-server/harness/render/validate.d.ts +13 -0
  113. package/dist-server/harness/render/validate.js +88 -0
  114. package/dist-server/harness/route/adapter-spec.d.ts +40 -0
  115. package/dist-server/harness/route/adapter-spec.js +61 -0
  116. package/dist-server/harness/route/agent-sdk-cli.d.ts +30 -0
  117. package/dist-server/harness/route/agent-sdk-cli.js +86 -0
  118. package/dist-server/harness/route/agent-sdk-manifest.d.ts +31 -0
  119. package/dist-server/harness/route/agent-sdk-manifest.js +56 -0
  120. package/dist-server/harness/route/artifact-content.d.ts +53 -0
  121. package/dist-server/harness/route/artifact-content.js +83 -0
  122. package/dist-server/harness/route/chat-event-mapper.d.ts +95 -0
  123. package/dist-server/harness/route/chat-event-mapper.js +164 -0
  124. package/dist-server/harness/route/codex-ask-events.d.ts +25 -0
  125. package/dist-server/harness/route/codex-ask-events.js +395 -0
  126. package/dist-server/harness/route/codex-ask.d.ts +15 -0
  127. package/dist-server/harness/route/codex-ask.js +242 -0
  128. package/dist-server/harness/route/codex-local-cli.d.ts +20 -0
  129. package/dist-server/harness/route/codex-local-cli.js +78 -0
  130. package/dist-server/harness/route/codex-local-manifest.d.ts +22 -0
  131. package/dist-server/harness/route/codex-local-manifest.js +180 -0
  132. package/dist-server/harness/route/describe.d.ts +54 -0
  133. package/dist-server/harness/route/describe.js +84 -0
  134. package/dist-server/harness/route/dispatched.d.ts +138 -0
  135. package/dist-server/harness/route/dispatched.js +339 -0
  136. package/dist-server/harness/route/in-process.d.ts +43 -0
  137. package/dist-server/harness/route/in-process.js +106 -0
  138. package/dist-server/harness/route/index.d.ts +19 -0
  139. package/dist-server/harness/route/index.js +12 -0
  140. package/dist-server/harness/route/profile-source.d.ts +37 -0
  141. package/dist-server/harness/route/profile-source.js +76 -0
  142. package/dist-server/harness/route/route.d.ts +33 -0
  143. package/dist-server/harness/route/route.js +114 -0
  144. package/dist-server/harness/route/tier-binding.d.ts +36 -0
  145. package/dist-server/harness/route/tier-binding.js +63 -0
  146. package/dist-server/harness/route/types.d.ts +286 -0
  147. package/dist-server/harness/route/types.js +1 -0
  148. package/dist-server/harness/session/errors.d.ts +4 -0
  149. package/dist-server/harness/session/errors.js +7 -0
  150. package/dist-server/harness/session/gate.d.ts +11 -0
  151. package/dist-server/harness/session/gate.js +13 -0
  152. package/dist-server/harness/session/index.d.ts +5 -0
  153. package/dist-server/harness/session/index.js +3 -0
  154. package/dist-server/harness/session/run.d.ts +60 -0
  155. package/dist-server/harness/session/run.js +333 -0
  156. package/dist-server/harness/session/types.d.ts +29 -0
  157. package/dist-server/harness/session/types.js +1 -0
  158. package/dist-server/harness/setup/codex-events.d.ts +12 -0
  159. package/dist-server/harness/setup/codex-events.js +108 -0
  160. package/dist-server/harness/setup/runner.d.ts +497 -0
  161. package/dist-server/harness/setup/runner.js +1314 -0
  162. package/dist-server/harness/tools/errors.d.ts +107 -0
  163. package/dist-server/harness/tools/errors.js +141 -0
  164. package/dist-server/harness/tools/index.d.ts +13 -0
  165. package/dist-server/harness/tools/index.js +8 -0
  166. package/dist-server/harness/tools/mcp.d.ts +26 -0
  167. package/dist-server/harness/tools/mcp.js +15 -0
  168. package/dist-server/harness/tools/native.d.ts +179 -0
  169. package/dist-server/harness/tools/native.js +322 -0
  170. package/dist-server/harness/tools/parse.d.ts +14 -0
  171. package/dist-server/harness/tools/parse.js +18 -0
  172. package/dist-server/harness/tools/resolve-wren-binary.d.ts +12 -0
  173. package/dist-server/harness/tools/resolve-wren-binary.js +21 -0
  174. package/dist-server/harness/tools/resolve.d.ts +51 -0
  175. package/dist-server/harness/tools/resolve.js +79 -0
  176. package/dist-server/harness/tools/setup-native.d.ts +84 -0
  177. package/dist-server/harness/tools/setup-native.js +353 -0
  178. package/dist-server/harness/tools/wiring.d.ts +10 -0
  179. package/dist-server/harness/tools/wiring.js +16 -0
  180. package/dist-server/providers/setup.provider.yaml +31 -0
  181. package/dist-server/providers/wren.provider.yaml +33 -0
  182. package/dist-server/server/adopt.d.ts +87 -0
  183. package/dist-server/server/adopt.js +263 -0
  184. package/dist-server/server/app.d.ts +6 -0
  185. package/dist-server/server/app.js +2521 -0
  186. package/dist-server/server/auth-choice.d.ts +16 -0
  187. package/dist-server/server/auth-choice.js +36 -0
  188. package/dist-server/server/bin.d.ts +2 -0
  189. package/dist-server/server/bin.js +601 -0
  190. package/dist-server/server/bootstrap-project-binding.d.ts +31 -0
  191. package/dist-server/server/bootstrap-project-binding.js +71 -0
  192. package/dist-server/server/clarify.d.ts +10 -0
  193. package/dist-server/server/clarify.js +17 -0
  194. package/dist-server/server/codex-setup-mcp.d.ts +2 -0
  195. package/dist-server/server/codex-setup-mcp.js +147 -0
  196. package/dist-server/server/compose.d.ts +89 -0
  197. package/dist-server/server/compose.js +271 -0
  198. package/dist-server/server/conn-config.d.ts +30 -0
  199. package/dist-server/server/conn-config.js +253 -0
  200. package/dist-server/server/context-files.d.ts +12 -0
  201. package/dist-server/server/context-files.js +117 -0
  202. package/dist-server/server/context-map.d.ts +30 -0
  203. package/dist-server/server/context-map.js +95 -0
  204. package/dist-server/server/context-source.d.ts +68 -0
  205. package/dist-server/server/context-source.js +85 -0
  206. package/dist-server/server/db.d.ts +862 -0
  207. package/dist-server/server/db.js +1839 -0
  208. package/dist-server/server/enrichment-runner.d.ts +184 -0
  209. package/dist-server/server/enrichment-runner.js +213 -0
  210. package/dist-server/server/enrichment-verify.d.ts +73 -0
  211. package/dist-server/server/enrichment-verify.js +290 -0
  212. package/dist-server/server/enrichment.d.ts +232 -0
  213. package/dist-server/server/enrichment.js +199 -0
  214. package/dist-server/server/env-detect.d.ts +8 -0
  215. package/dist-server/server/env-detect.js +17 -0
  216. package/dist-server/server/env-field-hints.d.ts +46 -0
  217. package/dist-server/server/env-field-hints.js +48 -0
  218. package/dist-server/server/fold.d.ts +133 -0
  219. package/dist-server/server/fold.js +407 -0
  220. package/dist-server/server/harness-profile-sources.d.ts +3 -0
  221. package/dist-server/server/harness-profile-sources.js +24 -0
  222. package/dist-server/server/harness.d.ts +19 -0
  223. package/dist-server/server/harness.js +439 -0
  224. package/dist-server/server/impact.d.ts +18 -0
  225. package/dist-server/server/impact.js +85 -0
  226. package/dist-server/server/interactive-terminal.d.ts +175 -0
  227. package/dist-server/server/interactive-terminal.js +336 -0
  228. package/dist-server/server/native-artifacts.d.ts +1004 -0
  229. package/dist-server/server/native-artifacts.js +564 -0
  230. package/dist-server/server/native-dispatch-registry.d.ts +42 -0
  231. package/dist-server/server/native-dispatch-registry.js +45 -0
  232. package/dist-server/server/native-producer-fence.d.ts +14 -0
  233. package/dist-server/server/native-producer-fence.js +48 -0
  234. package/dist-server/server/native-session-resume.d.ts +6 -0
  235. package/dist-server/server/native-session-resume.js +103 -0
  236. package/dist-server/server/native-session-workspace.d.ts +40 -0
  237. package/dist-server/server/native-session-workspace.js +175 -0
  238. package/dist-server/server/native-sessions.d.ts +374 -0
  239. package/dist-server/server/native-sessions.js +1517 -0
  240. package/dist-server/server/native-wren-runtime.d.ts +20 -0
  241. package/dist-server/server/native-wren-runtime.js +259 -0
  242. package/dist-server/server/node-pty-host.d.ts +31 -0
  243. package/dist-server/server/node-pty-host.js +100 -0
  244. package/dist-server/server/route-intent.d.ts +40 -0
  245. package/dist-server/server/route-intent.js +23 -0
  246. package/dist-server/server/runtime-binding.d.ts +52 -0
  247. package/dist-server/server/runtime-binding.js +258 -0
  248. package/dist-server/server/source-catalog.d.ts +84 -0
  249. package/dist-server/server/source-catalog.js +221 -0
  250. package/dist-server/server/source-driver.d.ts +35 -0
  251. package/dist-server/server/source-driver.js +124 -0
  252. package/dist-server/server/spa.d.ts +2 -0
  253. package/dist-server/server/spa.js +51 -0
  254. package/dist-server/server/subscription-model-catalog.d.ts +27 -0
  255. package/dist-server/server/subscription-model-catalog.js +203 -0
  256. package/dist-server/server/turn.d.ts +249 -0
  257. package/dist-server/server/turn.js +1074 -0
  258. package/dist-server/server/wire-types.d.ts +799 -0
  259. package/dist-server/server/wire-types.js +1 -0
  260. package/dist-server/server/wren-home.d.ts +19 -0
  261. package/dist-server/server/wren-home.js +33 -0
  262. package/dist-server/server/wren-profiles.d.ts +43 -0
  263. package/dist-server/server/wren-profiles.js +123 -0
  264. package/package.json +93 -0
  265. package/profiles/genbi-default/context/binding.yml +9 -0
  266. package/profiles/genbi-default/ir.golden.json +506 -0
  267. package/profiles/genbi-default/profile.yml +16 -0
  268. package/profiles/genbi-enrich-context/components/apply_enrichment/component.yml +42 -0
  269. package/profiles/genbi-enrich-context/components/draft_enrichment/component.yml +30 -0
  270. package/profiles/genbi-enrich-context/components/draft_enrichment/steps/draft.md +34 -0
  271. package/profiles/genbi-enrich-context/components/inspect_context/component.yml +32 -0
  272. package/profiles/genbi-enrich-context/components/inspect_context/steps/inspect.md +13 -0
  273. package/profiles/genbi-enrich-context/context/binding.yml +4 -0
  274. package/profiles/genbi-enrich-context/ir.golden.json +302 -0
  275. package/profiles/genbi-enrich-context/profile.yml +15 -0
  276. package/profiles/genbi-monitor/context/binding.yml +7 -0
  277. package/profiles/genbi-monitor/ir.golden.json +188 -0
  278. package/profiles/genbi-monitor/profile.yml +27 -0
  279. package/profiles/genbi-setup/components/build_context/component.yml +44 -0
  280. package/profiles/genbi-setup/components/build_context/steps/build.md +14 -0
  281. package/profiles/genbi-setup/components/connect_source/component.yml +51 -0
  282. package/profiles/genbi-setup/components/connect_source/steps/connect.md +23 -0
  283. package/profiles/genbi-setup/context/binding.yml +8 -0
  284. package/profiles/genbi-setup/ir.golden.json +140 -0
  285. package/profiles/genbi-setup/profile.yml +18 -0
  286. package/profiles/genbi-setup/raw/schema.json +5 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { SetupMode } from "./wire-types.js";
2
+ /**
3
+ * Builds the `setWrenHomeForSetupMode` function wired onto `TurnDeps` by `server/bin.ts` (see
4
+ * `TurnDeps.setWrenHomeForSetupMode`'s doc comment in `server/turn.ts` for the full call-site
5
+ * rationale). Pulled out of `bin.ts`'s closure into its own module so the exact logic that runs
6
+ * in production is directly unit-testable, instead of only reachable through a mocked
7
+ * `TurnDeps` in a route-level test.
8
+ *
9
+ * `workspaceRoot` and `originalWrenHome` are captured once at BFF boot (bootstrap-mode boots
10
+ * only — a bound-mode boot has no `workspaceRoot` and never runs the setup wizard, so the
11
+ * returned function is a no-op for it). `"create"` anchors `process.env.WREN_HOME` to
12
+ * `<workspaceRoot>/.wren` so a scaffolded project's `wren profile add` writes into a fresh,
13
+ * workspace-scoped `profiles.yml` instead of the operator's real `~/.wren/profiles.yml`.
14
+ * `"adopt"` or `undefined` (e.g. after "Reset setup") restores `originalWrenHome`
15
+ * exactly — deleting the env var entirely if the process never had it set, rather than forcing
16
+ * some other default — since adopt is strictly read-only against global state and must keep
17
+ * resolving the operator's own profiles.
18
+ */
19
+ export declare function createSetWrenHomeForSetupMode(workspaceRoot: string | undefined, originalWrenHome: string | undefined): (mode: SetupMode | undefined) => void;
@@ -0,0 +1,33 @@
1
+ import path from "node:path";
2
+ /**
3
+ * Builds the `setWrenHomeForSetupMode` function wired onto `TurnDeps` by `server/bin.ts` (see
4
+ * `TurnDeps.setWrenHomeForSetupMode`'s doc comment in `server/turn.ts` for the full call-site
5
+ * rationale). Pulled out of `bin.ts`'s closure into its own module so the exact logic that runs
6
+ * in production is directly unit-testable, instead of only reachable through a mocked
7
+ * `TurnDeps` in a route-level test.
8
+ *
9
+ * `workspaceRoot` and `originalWrenHome` are captured once at BFF boot (bootstrap-mode boots
10
+ * only — a bound-mode boot has no `workspaceRoot` and never runs the setup wizard, so the
11
+ * returned function is a no-op for it). `"create"` anchors `process.env.WREN_HOME` to
12
+ * `<workspaceRoot>/.wren` so a scaffolded project's `wren profile add` writes into a fresh,
13
+ * workspace-scoped `profiles.yml` instead of the operator's real `~/.wren/profiles.yml`.
14
+ * `"adopt"` or `undefined` (e.g. after "Reset setup") restores `originalWrenHome`
15
+ * exactly — deleting the env var entirely if the process never had it set, rather than forcing
16
+ * some other default — since adopt is strictly read-only against global state and must keep
17
+ * resolving the operator's own profiles.
18
+ */
19
+ export function createSetWrenHomeForSetupMode(workspaceRoot, originalWrenHome) {
20
+ return function setWrenHomeForSetupMode(mode) {
21
+ if (workspaceRoot === undefined)
22
+ return; // only bootstrap-mode boots ever run the setup wizard
23
+ if (mode === "create") {
24
+ process.env["WREN_HOME"] = path.join(workspaceRoot, ".wren");
25
+ }
26
+ else if (originalWrenHome === undefined) {
27
+ delete process.env["WREN_HOME"];
28
+ }
29
+ else {
30
+ process.env["WREN_HOME"] = originalWrenHome;
31
+ }
32
+ };
33
+ }
@@ -0,0 +1,43 @@
1
+ /** One profile's raw field map, as declared in profiles.yml (values still `${VAR}`-templated — this module never expands or otherwise touches secret material, it only reads structure). */
2
+ export type ProfileFields = ReadonlyMap<string, string>;
3
+ export interface ProfileStore {
4
+ /** The store's global `active:` profile name, or `undefined` if unset/null. */
5
+ readonly active: string | undefined;
6
+ readonly profiles: ReadonlyMap<string, ProfileFields>;
7
+ }
8
+ /** The only shape ever allowed to cross the wire to the frontend — see `listCandidateProfiles`. */
9
+ export interface ProfileCandidate {
10
+ readonly name: string;
11
+ readonly datasource: string;
12
+ }
13
+ /** Absolute path to the profiles store this process would read — exported so callers (and tests) can point elsewhere via `WREN_HOME` without guessing the join. */
14
+ export declare function profilesFilePath(): string;
15
+ /**
16
+ * Parses profiles.yml's known two-level shape:
17
+ * ```yaml
18
+ * active: <name>
19
+ * profiles:
20
+ * <name>:
21
+ * <field>: <value>
22
+ * ...
23
+ * ```
24
+ * Never throws on malformed content — returns as much as it could confidently
25
+ * parse (an empty profiles map in the worst case), mirroring this module's
26
+ * "profile discovery degrades to nothing found" philosophy: a broken
27
+ * profiles.yml should surface as "no candidates" to callers, not crash them.
28
+ */
29
+ export declare function parseProfileStore(content: string): ProfileStore;
30
+ /** Reads and parses profiles.yml off disk. Returns an empty store (never throws) when the file is missing or unreadable — same "degrade to nothing found" contract as `parseProfileStore`. */
31
+ export declare function loadProfileStore(): ProfileStore;
32
+ /**
33
+ * Candidate profiles for the adopt flow's profile-select checkpoint: every
34
+ * profile whose `datasource:` field equals the project's `data_source`,
35
+ * ranked with the profile named after the project directory first, then the
36
+ * store's global `active` profile, then the rest in `profiles.yml`'s own
37
+ * declaration order (stable sort). Returns ONLY `{name, datasource}` — never
38
+ * crosses the wire with anything else in a profile's field map (hosts, ports,
39
+ * credential material) per the adopt route's hard "no credentials to the
40
+ * frontend" rule; callers that need more of a profile's fields should read
41
+ * `store.profiles` directly, in-process, rather than widening this type.
42
+ */
43
+ export declare function listCandidateProfiles(store: ProfileStore, sourceType: string, projectDirName: string): readonly ProfileCandidate[];
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Reads the wren CLI's global connection-profile store (`profiles.yml`, at
3
+ * `$WREN_HOME/profiles.yml`, defaulting to `~/.wren/profiles.yml` — mirrors
4
+ * `core/wren/src/wren/profile.py`'s own `WREN_HOME` resolution so this reads
5
+ * the exact same file the CLI would) into an in-process shape other BFF
6
+ * modules can query.
7
+ *
8
+ * Deliberately NOT narrowed to any one caller's needs: `server/adopt.ts`'s
9
+ * adopt flow only ever needs `{name, datasource}` candidates — and must never
10
+ * let credentials cross the wire, see `listCandidateProfiles`'s doc comment —
11
+ * but another module resolves a project's pinned profile into a non-secret
12
+ * connection summary for display and needs the rest of a profile's fields
13
+ * (host/port/database/url/...). Both read through this one parser so there is
14
+ * exactly one YAML-shape understanding of profiles.yml in this repo, not two
15
+ * that can silently drift apart.
16
+ *
17
+ * Hand-rolled indentation-aware scan, not a general YAML parser dependency —
18
+ * matches this repo's existing convention (see `server/adopt.ts`'s
19
+ * `readYamlScalarField`) of small single-purpose parsers over pulling in a
20
+ * YAML dependency just to read a handful of known fields: profiles.yml is
21
+ * exactly two levels deep (`profiles.<name>.<field>`) plus one top-level
22
+ * `active:` scalar, so a generic multi-document YAML parser would be most of
23
+ * a new dependency spent reading a shape this constrained.
24
+ */
25
+ import { existsSync, readFileSync } from "node:fs";
26
+ import os from "node:os";
27
+ import path from "node:path";
28
+ function wrenHomeDir() {
29
+ const override = process.env.WREN_HOME?.trim();
30
+ return override ? override : path.join(os.homedir(), ".wren");
31
+ }
32
+ /** Absolute path to the profiles store this process would read — exported so callers (and tests) can point elsewhere via `WREN_HOME` without guessing the join. */
33
+ export function profilesFilePath() {
34
+ return path.join(wrenHomeDir(), "profiles.yml");
35
+ }
36
+ /** Strips one layer of matching quotes — same convention as `server/adopt.ts`'s `readYamlScalarField`. */
37
+ function unquote(raw) {
38
+ const match = /^(['"])(.*)\1$/.exec(raw);
39
+ return match ? match[2] : raw;
40
+ }
41
+ /**
42
+ * Parses profiles.yml's known two-level shape:
43
+ * ```yaml
44
+ * active: <name>
45
+ * profiles:
46
+ * <name>:
47
+ * <field>: <value>
48
+ * ...
49
+ * ```
50
+ * Never throws on malformed content — returns as much as it could confidently
51
+ * parse (an empty profiles map in the worst case), mirroring this module's
52
+ * "profile discovery degrades to nothing found" philosophy: a broken
53
+ * profiles.yml should surface as "no candidates" to callers, not crash them.
54
+ */
55
+ export function parseProfileStore(content) {
56
+ const lines = content.split(/\r?\n/);
57
+ const activeMatch = /^active:\s*(.*)$/m.exec(content);
58
+ const activeRaw = activeMatch ? activeMatch[1].trim() : "";
59
+ const active = activeRaw && activeRaw !== "null" && activeRaw !== "~" ? unquote(activeRaw) : undefined;
60
+ const profiles = new Map();
61
+ const profilesLineIdx = lines.findIndex((line) => /^profiles:\s*$/.test(line));
62
+ if (profilesLineIdx === -1)
63
+ return { active, profiles };
64
+ // `nameIndent` is established from the first profile-name line seen (a bare `<name>:` key with
65
+ // no value) and used to tell a new profile name apart from that profile's own nested fields —
66
+ // real profiles.yml files use 2-space name indent / 4-space field indent, but this doesn't
67
+ // hardcode that, it just requires field lines to be indented deeper than their profile's name.
68
+ let nameIndent;
69
+ let current;
70
+ for (let i = profilesLineIdx + 1; i < lines.length; i++) {
71
+ const line = lines[i];
72
+ if (!line.trim() || line.trim().startsWith("#"))
73
+ continue;
74
+ const indent = line.length - line.trimStart().length;
75
+ if (indent === 0)
76
+ break; // back to a top-level key — the profiles block ended
77
+ const nameMatch = /^(\s+)([\w.-]+):\s*$/.exec(line);
78
+ if (nameMatch && (nameIndent === undefined || indent === nameIndent)) {
79
+ nameIndent = indent;
80
+ current = new Map();
81
+ profiles.set(nameMatch[2], current);
82
+ continue;
83
+ }
84
+ if (current === undefined || nameIndent === undefined || indent <= nameIndent)
85
+ continue;
86
+ const fieldMatch = /^\s+([\w.-]+):\s*(.*)$/.exec(line);
87
+ if (fieldMatch) {
88
+ current.set(fieldMatch[1], unquote(fieldMatch[2].trim()));
89
+ }
90
+ }
91
+ return { active, profiles };
92
+ }
93
+ /** Reads and parses profiles.yml off disk. Returns an empty store (never throws) when the file is missing or unreadable — same "degrade to nothing found" contract as `parseProfileStore`. */
94
+ export function loadProfileStore() {
95
+ const file = profilesFilePath();
96
+ if (!existsSync(file))
97
+ return { active: undefined, profiles: new Map() };
98
+ try {
99
+ return parseProfileStore(readFileSync(file, "utf-8"));
100
+ }
101
+ catch {
102
+ return { active: undefined, profiles: new Map() };
103
+ }
104
+ }
105
+ /**
106
+ * Candidate profiles for the adopt flow's profile-select checkpoint: every
107
+ * profile whose `datasource:` field equals the project's `data_source`,
108
+ * ranked with the profile named after the project directory first, then the
109
+ * store's global `active` profile, then the rest in `profiles.yml`'s own
110
+ * declaration order (stable sort). Returns ONLY `{name, datasource}` — never
111
+ * crosses the wire with anything else in a profile's field map (hosts, ports,
112
+ * credential material) per the adopt route's hard "no credentials to the
113
+ * frontend" rule; callers that need more of a profile's fields should read
114
+ * `store.profiles` directly, in-process, rather than widening this type.
115
+ */
116
+ export function listCandidateProfiles(store, sourceType, projectDirName) {
117
+ const rank = (name) => (name === projectDirName ? 0 : name === store.active ? 1 : 2);
118
+ return [...store.profiles.entries()]
119
+ .map(([name, fields], index) => ({ name, datasource: fields.get("datasource"), index }))
120
+ .filter((c) => c.datasource === sourceType)
121
+ .sort((a, b) => rank(a.name) - rank(b.name) || a.index - b.index)
122
+ .map(({ name, datasource }) => ({ name, datasource }));
123
+ }
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@wrenai/genbi",
3
+ "version": "0.0.1",
4
+ "description": "Wren GenBI — the web UI for WrenAI: ask questions of your data and get dashboards back",
5
+ "license": "Apache-2.0",
6
+ "keywords": [
7
+ "wrenai",
8
+ "genbi",
9
+ "bi",
10
+ "analytics",
11
+ "dashboard",
12
+ "semantic-layer",
13
+ "text-to-sql",
14
+ "ai-agent"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/Canner/WrenAI.git",
19
+ "directory": "apps/genbi"
20
+ },
21
+ "homepage": "https://github.com/Canner/WrenAI/tree/main/apps/genbi#readme",
22
+ "engines": {
23
+ "node": ">=20"
24
+ },
25
+ "bin": {
26
+ "genbi": "bin/genbi.mjs"
27
+ },
28
+ "type": "module",
29
+ "dependencies": {
30
+ "@ai-sdk/anthropic": "~4.0.15",
31
+ "@ai-sdk/mcp": "~2.0.13",
32
+ "@ai-sdk/openai-compatible": "~3.0.10",
33
+ "@ai-sdk/provider": "~4.0.3",
34
+ "@ant-design/icons": "^6.3.2",
35
+ "@hono/node-server": "^2.0.10",
36
+ "@warble/claude-agent-sdk": "0.9.0",
37
+ "@warble/cli": "0.9.0",
38
+ "@warble/codex-local": "0.9.0",
39
+ "@warble/ir-spec": "0.6.0",
40
+ "@xterm/addon-fit": "^0.11.0",
41
+ "@xterm/xterm": "^6.0.0",
42
+ "ai": "~7.0.28",
43
+ "antd": "^6.5.1",
44
+ "echarts": "^6.1.0",
45
+ "hono": "^4.12.30",
46
+ "node-pty": "^1.1.0",
47
+ "react": "^19.2.7",
48
+ "react-dom": "^19.2.7",
49
+ "react-router-dom": "^7.18.1",
50
+ "ws": "^8.21.3",
51
+ "zod": "^4.4.3",
52
+ "zustand": "^5.0.14"
53
+ },
54
+ "devDependencies": {
55
+ "@playwright/test": "1.59.1",
56
+ "@testing-library/jest-dom": "^6.9.1",
57
+ "@testing-library/react": "^16.3.2",
58
+ "@testing-library/user-event": "^14.6.1",
59
+ "@types/node": "^26.1.1",
60
+ "@types/react": "^19.2.17",
61
+ "@types/react-dom": "^19.2.3",
62
+ "@types/ws": "^8.18.1",
63
+ "@vitejs/plugin-react": "^6.0.3",
64
+ "jsdom": "^29.1.1",
65
+ "typescript": "^7.0.2",
66
+ "vite": "^8.1.5",
67
+ "vitest": "^4.1.10"
68
+ },
69
+ "files": [
70
+ "bin",
71
+ "dist",
72
+ "!dist/**/*.map",
73
+ "dist-server/server",
74
+ "dist-server/harness",
75
+ "dist-server/providers",
76
+ "profiles"
77
+ ],
78
+ "publishConfig": {
79
+ "access": "public"
80
+ },
81
+ "scripts": {
82
+ "dev": "vite",
83
+ "build": "tsc -b && vite build && tsc -p tsconfig.server.json && node scripts/copy-providers.js",
84
+ "start:bff": "node dist-server/server/bin.js",
85
+ "check:contracts": "node scripts/verify-local-launch.mjs",
86
+ "check:warble-peers": "pnpm peers check",
87
+ "preview": "vite preview",
88
+ "test": "vitest run",
89
+ "test:browser": "playwright test",
90
+ "test:watch": "vitest",
91
+ "typecheck": "tsc -b --noEmit && tsc -p tsconfig.server.json --noEmit"
92
+ }
93
+ }
@@ -0,0 +1,9 @@
1
+ # Coarse context binding: the whole v5-jaffle semantic layer. Since IR v0.3 the Warble front-end
2
+ # builds a real MdlContext over the bound project and evaluates context_precondition predicates
3
+ # against it — it does introspect MDL. The binding stays "coarse" in a different sense: it names the
4
+ # whole project, not a specific metric/grain.
5
+ #
6
+ # The host rewrites this `project:` line to the user's own wren project at bind time; the committed
7
+ # value pins this repo's own v5 example so the profile compiles standalone for CI/dev.
8
+ # Path is relative to this profile directory.
9
+ project: ../../../../examples/v5-jaffle