@oalo-ai/cli 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/man/oalo.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH OALO 1 "" "oalo 0.7.0" "OALO CLI"
1
+ .TH OALO 1 "" "oalo 0.8.0" "OALO CLI"
2
2
  .SH NAME
3
3
  oalo \- wire a local app into your Oalo workspace
4
4
  .SH SYNOPSIS
@@ -452,32 +452,50 @@ Each one says what was seen: which process, how many restarts, a memory kill wit
452
452
  .PP
453
453
  Exit codes: 0 no open incident; 1 an incident is open, or the request failed; 2 bad arguments or no CLI token.
454
454
  .SS db
455
- Read an env's tables with SQL (your app's own included), dump all of an env's data as plain SQL to keep or take anywhere, or load an existing Postgres database into an env.
455
+ Read tables with SQL (including isolated app schemas), inspect schemas and cross\-app grants, share one app's tables with another app, dump an env as SQL, or restore an existing Postgres database.
456
456
  .PP
457
- \fBEnv:\fR query and tables: \-\-env dev|prod, else the project's env, else dev. dump: \-\-env, default prod, whatever the project's env is. restore: \-\-env is required.
457
+ \fBEnv:\fR query and tables: \-\-env dev|prod, else the project's env, else dev. dump: \-\-env, default prod, whatever the project's env is. restore: \-\-env is required. schemas, grant and revoke cover both dev and prod.
458
458
  .PP
459
- \fBoalo db query "<sql>" [\-\-env dev|prod] [\-\-limit <n>] [\-\-json]\fR
459
+ \fBoalo db query "<sql>" [\-\-env dev|prod] [\-\-app <slug>] [\-\-limit <n>] [\-\-json]\fR
460
460
  .br
461
- \fBoalo db tables [\-\-env dev|prod]\fR
461
+ \fBoalo db tables [\-\-env dev|prod] [\-\-app <slug>]\fR
462
462
  .br
463
- \fBoalo db dump [\-\-env dev|prod] [\-\-out <file.sql>] [\-\-force]\fR
463
+ \fBoalo db schemas [\-\-json]\fR
464
464
  .br
465
- \fBoalo db restore <file> \-\-env dev|prod [\-\-schema <name>] [\-\-check] [\-\-yes]\fR
465
+ \fBoalo db grant <owner\-app|workspace> \-\-to <grantee\-app> [\-\-read\-only]\fR
466
466
  .br
467
- \fBoalo db restore \-\-from\-env <VAR> \-\-env dev|prod [\-\-schema <name>] [\-\-check] [\-\-yes]\fR
467
+ \fBoalo db revoke <owner\-app|workspace> \-\-from <grantee\-app>\fR
468
+ .br
469
+ \fBoalo db dump [\-\-env dev|prod] [\-\-app <slug>] [\-\-out <file.sql>] [\-\-force]\fR
470
+ .br
471
+ \fBoalo db restore <file> \-\-env dev|prod [\-\-app <slug>] [\-\-schema <name>] [\-\-check] [\-\-yes]\fR
472
+ .br
473
+ \fBoalo db restore \-\-from\-env <VAR> \-\-env dev|prod [\-\-app <slug>] [\-\-schema <name>] [\-\-check] [\-\-yes]\fR
468
474
  .br
469
475
  .TP
470
476
  \fB\-\-env dev|prod\fR
471
477
  query, tables: which env. Default the project's, else dev. dump: which env's data. Default prod. restore: which env the data goes into, always on the command line.
472
478
  .TP
479
+ \fB\-\-app <slug>\fR
480
+ Target a specific server app's isolated schema (\fBapp_<slug>_dev\fR / \fBapp_<slug>_prod\fR) instead of the shared workspace schema (\fBdev\fR / \fBprod\fR).
481
+ .TP
482
+ \fB\-\-to <grantee\-app>\fR
483
+ grant: the app slug receiving SQL access to the owner's schema.
484
+ .TP
485
+ \fB\-\-from <grantee\-app>\fR
486
+ revoke: the app slug whose access to the owner's schema is removed.
487
+ .TP
488
+ \fB\-\-read\-only\fR
489
+ grant: allow SELECT only (default is read/write: SELECT, INSERT, UPDATE, DELETE).
490
+ .TP
473
491
  \fB\-\-limit <n>\fR
474
492
  query: rows to show. Default 100, at most 1000.
475
493
  .TP
476
494
  \fB\-\-json\fR
477
- query: {columns, rows, truncated} as JSON.
495
+ query, schemas, grant, revoke: structured JSON output.
478
496
  .TP
479
497
  \fB\-\-out <file.sql>\fR
480
- Where to write it. Default <workspace>\-<env>\-<date>.sql here.
498
+ Where to write it. Default <workspace>\-[<app>\-]<env>\-<date>.sql here.
481
499
  .TP
482
500
  \fB\-\-force\fR
483
501
  Replace the file if it exists.
@@ -494,17 +512,21 @@ restore: do everything but the write, and report what would happen. Nothing is w
494
512
  \fB\-\-yes\fR
495
513
  restore: go ahead with prod without asking. Needed for prod when there's no terminal to ask at.
496
514
  .IP \(bu 2
497
- query reads only: one statement (SELECT, WITH, TABLE, VALUES, EXPLAIN or SHOW), run as your app's database login in a read\-only transaction that is rolled back, with a 10 second limit. It sees what your app sees at DATABASE_URL: the env's tables, not the platform's. \fBoalo data\fR is for Oalo models; this is for any table, your app's own included. Available to workspace admins and members with Developer access.
515
+ New imported/created server apps get isolated schemas (\fBapp_<slug>_dev\fR and \fBapp_<slug>_prod\fR) with their own Postgres login, so multiple apps can each keep their own \fBproducts\fR, \fBorders\fR, \fBusers\fR or ORM migrations without colliding. Existing shared apps stay in \fBdev\fR/\fBprod\fR.
516
+ .IP \(bu 2
517
+ Sharing data across apps without duplication: (1) for shared business data (users, CRM, commerce, Oalo models), have both apps call Oalo's Sync/platform APIs with their injected \fBOALO_URL\fR and \fBOALO_SYNC_TOKEN\fR; (2) when App B needs direct SQL read/write on App A's app\-specific tables, run \fBoalo db grant <app\-a> \-\-to <app\-b>\fR (or \fB\-\-read\-only\fR). Postgres grants privileges on current and future tables in both dev and prod, and App B receives \fBAPP_SCHEMA_<APP_A>\fR and \fBOALO_SHARED_SCHEMAS\fR in its environment so it can query \fB"${process.env.APP_SCHEMA_<APP_A>}".<table>\fR without hardcoding dev/prod. Pass \fBworkspace\fR as the owner to grant direct SQL access to the workspace's \fBdev\fR/\fBprod\fR schema.
498
518
  .IP \(bu 2
499
- dump is workspace admins only: it holds every member's data. Restore it into any Postgres with psql \-f.
519
+ query reads only: one statement (SELECT, WITH, TABLE, VALUES, EXPLAIN or SHOW), run as the env's (or \fB\-\-app\fR's) database login in a read\-only transaction that is rolled back, with a 10 second limit. \fBoalo data\fR is for Oalo models; this is for any table, your app's own included. Available to workspace admins and members with Developer access.
520
+ .IP \(bu 2
521
+ dump is workspace admins only: without \fB\-\-app\fR, it dumps the workspace schema plus every isolated app schema for that env; with \fB\-\-app <slug>\fR, it dumps only that app's schema. Restore it into any Postgres with psql \-f.
500
522
  .IP \(bu 2
501
523
  Your code is in git (oalo deploy \-\-pull); this is the data. Together they are everything you need to run your apps elsewhere.
502
524
  .IP \(bu 2
503
- restore loads a dump file made by pg_dump (like Heroku's latest.dump), up to 10 GB, or copies from a database URL. Admins only, and one restore at a time per Base.
525
+ restore loads a dump file made by pg_dump (like Heroku's latest.dump), up to 10 GB, or copies from a database URL. Admins only, and one restore at a time per Base. Pass \fB\-\-app <slug>\fR to restore directly into an isolated server app's schema.
504
526
  .IP \(bu 2
505
- The tables land in the env's schema, owned by the app's database login, so its Procfile \fBrelease:\fR migrations can alter them. Your app reads them at DATABASE_URL.
527
+ The tables land in the target schema, owned by the app's database login, so its Procfile \fBrelease:\fR migrations can alter them. Your app reads them at DATABASE_URL.
506
528
  .IP \(bu 2
507
- It's refused if a table name already exists there, and the names are listed. A failed restore leaves the env as it was.
529
+ It's refused if a table name already exists there, and the names are listed. A failed restore leaves the target schema as it was.
508
530
  .IP \(bu 2
509
531
  The URL is never a flag value, since that stays in your shell history. Put it in a variable and pass \-\-from\-env VAR.
510
532
  .IP \(bu 2
@@ -1001,7 +1023,9 @@ A source is a table made searchable with \fBoalo data vectorize <table> \-\-fiel
1001
1023
  .IP \(bu 2
1002
1024
  The same as ticking a table in the bot's Knowledge pane in the dashboard, with the same access as there.
1003
1025
  .IP \(bu 2
1004
- settings go through the dashboard's own actions, with the same checks and access. A change sets only the settings it names: the model without the provider keeps the provider, one limit keeps the others, one context.* key keeps the rest of the context config.
1026
+ settings go through the dashboard's own actions, with the same checks and access. A change sets only the settings it names: the model without the provider keeps the provider (except a provider/model id with a slash, which automatically sets provider=opencode), one limit keeps the others, one context.* key keeps the rest of the context config.
1027
+ .IP \(bu 2
1028
+ Pick a bot's model with \fBoalo bots settings <bot> set model=<tier\-or\-id>\fR, for example \fBbalanced\fR, \fBgoogle/gemini\-4\-argon\fR, \fBbedrock/us.amazon.ergo\-1.0\fR, \fBopenrouter/thinkingmachines/inkling\-2\-mini\fR, \fBopenrouter/deepseek/deepseek\-v4.1\-flash\fR, \fBclaude\-sonnet\-4\-6\fR, or a \fBbyo\-...\fR own model. Run \fBoalo docs ai\-steps\-and\-providers\fR for the full hosted model table.
1005
1029
  .IP \(bu 2
1006
1030
  Every setting is described in \fBman oalo\fR (BOT SETTINGS) and by \fBoalo bots settings \-\-explain\fR.
1007
1031
  .IP \(bu 2
@@ -2258,12 +2282,12 @@ Values: true or false. Default: false.
2258
2282
  .SS model
2259
2283
  .TP
2260
2284
  \fBmodel\fR
2261
- The AI model this bot answers with. default: the workspace's default model.
2285
+ The AI model this bot answers with: a tier (cheap, balanced, max), a hosted id (for example google/gemini\-4\-argon, bedrock/us.amazon.ergo\-1.0, openrouter/thinkingmachines/inkling\-2\-mini, openrouter/deepseek/deepseek\-v4\-pro, openrouter/deepseek/deepseek\-v4.1\-flash, claude\-sonnet\-4\-6), or an own model id (byo\-...). Any provider/model id with a slash automatically sets provider=opencode. default: the workspace's default model. See \fBoalo docs ai\-steps\-and\-providers\fR for the full list.
2262
2286
  .br
2263
2287
  Values: text, or default. Default: default.
2264
2288
  .TP
2265
2289
  \fBprovider\fR
2266
- How the model is reached: anthropic directly, or opencode (for models from other providers). default: anthropic.
2290
+ How the model is reached: opencode (Gemini, Amazon Bedrock, Thinking Machines, DeepSeek, Qwen, GLM, MiniMax, Llama, OpenAI, and own models; default) or anthropic (Claude directly). Setting a provider/model id automatically picks opencode.
2267
2291
  .br
2268
2292
  Values: anthropic | opencode, or default. Default: default.
2269
2293
  .TP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oalo-ai/cli",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Wire a local app into your OALO workspace: link a token, generate typed bindings, and serve the build surface over MCP.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oalo",
3
3
  "description": "Work on an Oalo workspace from Claude Code: edit chat flows, loops and code tools, deploy and migrate apps, inspect and self-heal runtime errors, and run test conversations with a bot.",
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "author": { "name": "Oalo" },
6
6
  "mcpServers": {
7
7
  "oalo": {
@@ -191,14 +191,17 @@ oalo data push orders_mirror orders.csv --id-field order_no --dry-run # chec
191
191
  oalo data push orders_mirror orders.csv --id-field order_no # upsert into dev
192
192
  oalo data list orders_mirror --limit 5 # look at what landed
193
193
  oalo data promote orders_mirror # copy dev rows to prod, when the person wants it live
194
- oalo db tables # every table in the env, your app's own included
195
- oalo db query "select * from quotes order by id desc limit 5" # read any of them (read-only; MCP: oalo_db_query)
194
+ oalo db schemas # list workspace + isolated app schemas and cross-app grants (MCP: oalo_db_schemas)
195
+ oalo db tables [--app <slug>] # tables in workspace dev/prod or an isolated app's schema
196
+ oalo db query "select * from quotes order by id desc limit 5" [--app <slug>] # read-only SQL (MCP: oalo_db_query)
197
+ oalo db grant <owner-app|workspace> --to <grantee-app> [--read-only] # let one server app read/write another app's tables
198
+ oalo db revoke <owner-app|workspace> --from <grantee-app> # remove cross-app SQL access
196
199
  oalo data routes # the Sync API's endpoints, scopes and limits
197
200
  ```
198
201
 
199
202
  Over MCP: `oalo_list_models`, `oalo_create_model`, `oalo_read_rows`,
200
203
  `oalo_write_rows` (env required; prod needs `confirm`), `oalo_promote_model`,
201
- `oalo_sync_routes`.
204
+ `oalo_db_schemas`, `oalo_db_query`, `oalo_sync_routes`.
202
205
 
203
206
  1. **Look before you create.** Reuse a model that exists (`oalo data models`).
204
207
  Use `--owned-by <field>` only when each app user owns their rows.
@@ -208,11 +211,21 @@ Over MCP: `oalo_list_models`, `oalo_create_model`, `oalo_read_rows`,
208
211
  at once, so writing there needs `--env prod` and the person's go-ahead. A
209
212
  draft bot reads dev and a published one prod, so load rows where the bot
210
213
  you're testing reads them (rule 9).
211
- 4. **For an app's own server** (mirroring its database into Oalo, reading data
212
- out): a server app hosted on Oalo already has `OALO_URL` and
213
- `OALO_SYNC_TOKEN` in its environment, locked to its own env's data. Use
214
- them: there is no token to make. For a server hosted elsewhere, the person
215
- runs `oalo tokens create --name <what> --scope write:<table>` themselves (it
214
+ 4. **Sharing data across apps without duplication:**
215
+ - **Shared business data** (users, CRM, commerce, Oalo models): both apps use
216
+ their injected `OALO_URL` and `OALO_SYNC_TOKEN` (already in every hosted
217
+ server app's env; no token to make). For a server hosted elsewhere, the
218
+ person runs `oalo tokens create --name <what> --scope write:<table>`.
219
+ - **App-specific Postgres tables:** new server apps get isolated schemas
220
+ (`app_<slug>_dev` / `app_<slug>_prod`) so table names like `products`,
221
+ `orders`, `users`, or `_prisma_migrations` never collide. Check
222
+ `oalo db schemas` first. When App B needs to read or modify App A's SQL
223
+ tables directly, run `oalo db grant <app-a> --to <app-b>` (add `--read-only`
224
+ for SELECT-only). App B automatically gets `APP_SCHEMA_<APP_A>` and
225
+ `OALO_SHARED_SCHEMAS` in its env so it can run schema-qualified SQL
226
+ (`"${process.env.APP_SCHEMA_<APP_A>}".<table>`) across dev and prod cleanly.
227
+ Oalo workflows and code tools (`db_query`) already have holistic access
228
+ across all app schemas and `workspace.*` in one query.
216
229
  prints the token once) and stores it in that host's secrets. Don't run it
217
230
  yourself: the token would land in your context. The app calls
218
231
  `/api/sync/v1`; `oalo docs sync-rest-api` explains it and `oalo data routes`
@@ -473,6 +486,8 @@ oalo bots knowledge bot_ABC --add products # let the bot search it
473
486
  oalo bots tools bot_ABC --add order_status # let it call a tool
474
487
  oalo bots graph bot_ABC [--build] [--search "<q>"] [--export f.json] [--import f.json] [--resync] [--reset --yes]
475
488
  oalo bots settings --explain model # what each setting does
489
+ oalo bots settings bot_ABC set model=bedrock/us.amazon.ergo-1.0 --dry-run
490
+ oalo bots settings bot_ABC set model=openrouter/thinkingmachines/inkling-2-mini --dry-run
476
491
  oalo bots settings bot_ABC set <key>=<value> --dry-run
477
492
  oalo channels # WhatsApp, Instagram, email, web chat: which bot answers
478
493
  ```
@@ -482,7 +497,13 @@ oalo channels # WhatsApp, Instagram, emai
482
497
  isn't searchable. The rows must be in the env the bot reads: dev while it's
483
498
  a draft, prod once published (`oalo bots` shows its status).
484
499
  2. **Read a setting with `--explain` before changing it.** Don't guess keys or
485
- values.
500
+ values. For AI models (bots, flow `agent_prompt`/`collect` nodes, and loop
501
+ definitions or `agent_prompt` nodes), pass a tier (`cheap`, `balanced`,
502
+ `max`) or a hosted model id such as `google/gemini-4-argon`,
503
+ `bedrock/us.amazon.ergo-1.0`, `openrouter/thinkingmachines/inkling-2-mini`,
504
+ `openrouter/deepseek/deepseek-v4.1-flash`, or `claude-sonnet-4-6` (any
505
+ `provider/model` id automatically routes through OpenCode). Run `oalo docs
506
+ ai-steps-and-providers` for the complete model table and vision support.
486
507
  3. **A published bot is live for customers.** `set` on one shows the change and
487
508
  saves nothing unless you pass `--yes`: show the person the `--dry-run` and
488
509
  use `--yes` only when they say so.
@@ -312,7 +312,7 @@
312
312
  {
313
313
  "clear_word": "default",
314
314
  "default": null,
315
- "doc": "The AI model this bot answers with. default: the workspace's default model.",
315
+ "doc": "The AI model this bot answers with: a tier (cheap, balanced, max), a hosted id (for example google/gemini-4-argon, bedrock/us.amazon.ergo-1.0, openrouter/thinkingmachines/inkling-2-mini, openrouter/deepseek/deepseek-v4-pro, openrouter/deepseek/deepseek-v4.1-flash, claude-sonnet-4-6), or an own model id (byo-...). Any provider/model id with a slash automatically sets provider=opencode. default: the workspace's default model. See `oalo docs ai-steps-and-providers` for the full list.",
316
316
  "effect": null,
317
317
  "group": "model",
318
318
  "key": "model",
@@ -322,7 +322,7 @@
322
322
  {
323
323
  "clear_word": "default",
324
324
  "default": null,
325
- "doc": "How the model is reached: anthropic directly, or opencode (for models from other providers). default: anthropic.",
325
+ "doc": "How the model is reached: opencode (Gemini, Amazon Bedrock, Thinking Machines, DeepSeek, Qwen, GLM, MiniMax, Llama, OpenAI, and own models; default) or anthropic (Claude directly). Setting a provider/model id automatically picks opencode.",
326
326
  "effect": null,
327
327
  "group": "model",
328
328
  "key": "provider",
@@ -7,22 +7,117 @@ import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "../confi
7
7
  import { dim } from "../events.js";
8
8
 
9
9
  const USAGE =
10
- "usage: oalo db query \"<sql>\" [--env dev|prod] [--limit <n>] [--json]\n" +
11
- " oalo db tables [--env dev|prod]\n" +
12
- " oalo db dump [--env dev|prod] [--out <file.sql>]\n" +
13
- " oalo db restore <file> --env dev|prod [--schema <name>] [--check] [--yes]\n" +
14
- " oalo db restore --from-env <VAR> --env dev|prod [--schema <name>] [--check] [--yes]";
15
-
16
- /** `oalo db dump` and `oalo db restore`. */
10
+ "usage: oalo db query \"<sql>\" [--env dev|prod] [--app <slug>] [--limit <n>] [--json]\n" +
11
+ " oalo db tables [--env dev|prod] [--app <slug>]\n" +
12
+ " oalo db schemas [--json]\n" +
13
+ " oalo db grant <owner-app|workspace> --to <grantee-app> [--read-only]\n" +
14
+ " oalo db revoke <owner-app|workspace> --from <grantee-app>\n" +
15
+ " oalo db dump [--env dev|prod] [--app <slug>] [--out <file.sql>]\n" +
16
+ " oalo db restore <file> --env dev|prod [--app <slug>] [--schema <name>] [--check] [--yes]\n" +
17
+ " oalo db restore --from-env <VAR> --env dev|prod [--app <slug>] [--schema <name>] [--check] [--yes]";
18
+
19
+ /** `oalo db dump`, `oalo db restore`, `oalo db query`, `oalo db tables`, `oalo db schemas`, `oalo db grant`, `oalo db revoke`. */
17
20
  export async function db(flags, rest, opts = {}) {
18
21
  const sub = rest[1];
19
22
  if (sub === "query") return query(flags, rest[2], opts);
20
23
  if (sub === "tables") return query(flags, TABLES_SQL, opts, { tables: true });
24
+ if (sub === "schemas") return schemas(flags, opts);
25
+ if (sub === "grant") return grant(flags, rest[2], opts);
26
+ if (sub === "revoke") return revoke(flags, rest[2], opts);
21
27
  if (sub === "dump") return dump(flags, opts);
22
28
  if (sub === "restore") return restore(flags, rest, opts);
23
29
  return fail(USAGE, 2);
24
30
  }
25
31
 
32
+ async function schemas(flags, opts) {
33
+ const { url, token } = controlPlane(resolveConfig(flags));
34
+ if (!url || !token) return fail(`oalo db schemas needs a CLI token.\n\n${HOW_TO_CONNECT}`, 2);
35
+
36
+ const doFetch = opts.fetch || fetch;
37
+ let res;
38
+ try {
39
+ res = await doFetch(`${url.replace(/\/$/, "")}/api/cli/v1/db/schemas`, {
40
+ headers: { authorization: `Bearer ${token}` },
41
+ });
42
+ } catch (e) {
43
+ return fail(`could not reach ${url} (${e.message})`, 1);
44
+ }
45
+ const body = await res.json().catch(() => ({}));
46
+ if (!res.ok) return fail(body?.error?.message || `could not list schemas (HTTP ${res.status})`, 1);
47
+ if (flags.json) return void console.log(JSON.stringify(body, null, 2));
48
+
49
+ const rows = [
50
+ ["workspace", "dev", "prod"],
51
+ ...(body.apps || []).map((a) => [a.slug, a.dev_schema, a.prod_schema]),
52
+ ];
53
+ printTable(["app", "dev_schema", "prod_schema"], rows);
54
+
55
+ const grants = body.grants || [];
56
+ if (grants.length > 0) {
57
+ console.log("");
58
+ printTable(
59
+ ["owner", "grantee", "access", "env_var"],
60
+ grants.map((g) => [g.owner, g.grantee, g.access, g.env_var || ""]),
61
+ );
62
+ }
63
+ }
64
+
65
+ async function grant(flags, owner, opts) {
66
+ const grantee = typeof flags.to === "string" ? flags.to.trim() : "";
67
+ if (typeof owner !== "string" || !owner.trim() || !grantee) {
68
+ return fail("usage: oalo db grant <owner-app|workspace> --to <grantee-app> [--read-only]", 2);
69
+ }
70
+ const { url, token } = controlPlane(resolveConfig(flags));
71
+ if (!url || !token) return fail(`oalo db grant needs a CLI token.\n\n${HOW_TO_CONNECT}`, 2);
72
+
73
+ const access = flags["read-only"] ? "read" : "write";
74
+ const doFetch = opts.fetch || fetch;
75
+ let res;
76
+ try {
77
+ res = await doFetch(`${url.replace(/\/$/, "")}/api/cli/v1/db/grants`, {
78
+ method: "POST",
79
+ headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
80
+ body: JSON.stringify({ owner: owner.trim(), grantee, access }),
81
+ });
82
+ } catch (e) {
83
+ return fail(`could not reach ${url} (${e.message})`, 1);
84
+ }
85
+ const body = await res.json().catch(() => ({}));
86
+ if (!res.ok) return fail(body?.error?.message || `could not grant schema access (HTTP ${res.status})`, 1);
87
+ if (flags.json) return void console.log(JSON.stringify(body, null, 2));
88
+
89
+ console.log(
90
+ `granted ${body.access} on ${body.owner} (${body.dev_schema} / ${body.prod_schema}) to ${body.grantee}. ` +
91
+ dim(`Restart or redeploy ${body.grantee} to receive ${body.env_var} in its environment.`),
92
+ );
93
+ }
94
+
95
+ async function revoke(flags, owner, opts) {
96
+ const grantee = typeof flags.from === "string" ? flags.from.trim() : "";
97
+ if (typeof owner !== "string" || !owner.trim() || !grantee) {
98
+ return fail("usage: oalo db revoke <owner-app|workspace> --from <grantee-app>", 2);
99
+ }
100
+ const { url, token } = controlPlane(resolveConfig(flags));
101
+ if (!url || !token) return fail(`oalo db revoke needs a CLI token.\n\n${HOW_TO_CONNECT}`, 2);
102
+
103
+ const doFetch = opts.fetch || fetch;
104
+ let res;
105
+ try {
106
+ res = await doFetch(`${url.replace(/\/$/, "")}/api/cli/v1/db/grants`, {
107
+ method: "DELETE",
108
+ headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
109
+ body: JSON.stringify({ owner: owner.trim(), grantee }),
110
+ });
111
+ } catch (e) {
112
+ return fail(`could not reach ${url} (${e.message})`, 1);
113
+ }
114
+ const body = await res.json().catch(() => ({}));
115
+ if (!res.ok) return fail(body?.error?.message || `could not revoke schema access (HTTP ${res.status})`, 1);
116
+ if (flags.json) return void console.log(JSON.stringify(body, null, 2));
117
+
118
+ console.log(`revoked ${body.owner} schema access from ${body.grantee}.`);
119
+ }
120
+
26
121
  // The env's tables: an app's own and the Oalo models', with Postgres's row
27
122
  // estimate (blank until it has counted; `select count(*)` for the exact number).
28
123
  const TABLES_SQL =
@@ -45,13 +140,14 @@ async function query(flags, sql, opts, { tables = false } = {}) {
45
140
  if (!url || !token) return fail(`oalo db ${tables ? "tables" : "query"} needs a CLI token.\n\n${HOW_TO_CONNECT}`, 2);
46
141
 
47
142
  const limit = tables ? 1000 : Number.parseInt(flags.limit, 10) || undefined;
143
+ const app = typeof flags.app === "string" && flags.app.trim() ? flags.app.trim() : undefined;
48
144
  const doFetch = opts.fetch || fetch;
49
145
  let res;
50
146
  try {
51
147
  res = await doFetch(`${url.replace(/\/$/, "")}/api/cli/v1/db/query`, {
52
148
  method: "POST",
53
149
  headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
54
- body: JSON.stringify({ env, sql, ...(limit ? { limit } : {}) }),
150
+ body: JSON.stringify({ env, sql, ...(app ? { app } : {}), ...(limit ? { limit } : {}) }),
55
151
  });
56
152
  } catch (e) {
57
153
  return fail(`could not reach ${url} (${e.message})`, 1);
@@ -94,13 +190,15 @@ async function dump(flags, opts) {
94
190
  if (!url || !token) return fail(`oalo db dump needs a CLI token.\n\n${HOW_TO_CONNECT}`, 2);
95
191
 
96
192
  const host = new URL(url).hostname.split(".")[0];
97
- const out = typeof flags.out === "string" ? flags.out : `${host}-${env}-${new Date().toISOString().slice(0, 10)}.sql`;
193
+ const app = typeof flags.app === "string" && flags.app.trim() ? flags.app.trim() : undefined;
194
+ const out = typeof flags.out === "string" ? flags.out : `${host}-${app ? `${app}-` : ""}${env}-${new Date().toISOString().slice(0, 10)}.sql`;
98
195
  if (existsSync(out) && !flags.force) return fail(`${out} exists. Choose another --out, or add --force to replace it.`, 2);
99
196
 
100
197
  const doFetch = opts.fetch || fetch;
198
+ const dumpQ = new URLSearchParams({ env, ...(app ? { app } : {}) });
101
199
  let res;
102
200
  try {
103
- res = await doFetch(`${url.replace(/\/$/, "")}/api/cli/v1/db/dump?env=${env}`, { headers: { authorization: `Bearer ${token}` } });
201
+ res = await doFetch(`${url.replace(/\/$/, "")}/api/cli/v1/db/dump?${dumpQ}`, { headers: { authorization: `Bearer ${token}` } });
104
202
  } catch (e) {
105
203
  return fail(`could not reach ${url} (${e.message})`, 1);
106
204
  }
@@ -188,7 +286,8 @@ async function restore(flags, rest, opts) {
188
286
  }
189
287
 
190
288
  const scrub = scrubber(source.url);
191
- const q = new URLSearchParams({ env, ...(typeof flags.schema === "string" ? { schema: flags.schema } : {}), ...(check ? { check: "true" } : {}) });
289
+ const app = typeof flags.app === "string" && flags.app.trim() ? flags.app.trim() : undefined;
290
+ const q = new URLSearchParams({ env, ...(app ? { app } : {}), ...(typeof flags.schema === "string" ? { schema: flags.schema } : {}), ...(check ? { check: "true" } : {}) });
192
291
  const endpoint = `${url.replace(/\/$/, "")}/api/cli/v1/db/restore?${q}`;
193
292
  console.error(dim(`${check ? "checking" : "restoring"} ${source.file ? `${source.file} (${size(source.bytes)})` : `the database at ${source.host}`} ${check ? "against" : "into"} ${env} on ${url}`));
194
293
 
@@ -1,25 +1,25 @@
1
1
  {
2
- "version": "0.7.0",
2
+ "version": "0.8.0",
3
3
  "targets": {
4
4
  "darwin-arm64": {
5
5
  "file": "oalo-coord-darwin-arm64.gz",
6
- "sha256": "e689f1a38178d13cc1a10f4d50ce15927da58ca7484e3e963d82bcb73e581893",
7
- "bytes": 24874385
6
+ "sha256": "63e9527d03eb8f6521a86078fb2083a2c4e1216737c95ab220e0eaac30ea4534",
7
+ "bytes": 24875224
8
8
  },
9
9
  "darwin-x64": {
10
10
  "file": "oalo-coord-darwin-x64.gz",
11
- "sha256": "c9d7a43b292de653526cd73139e97f5683b5f5cf4fb07392439fdbe32a2e5f81",
12
- "bytes": 27013652
11
+ "sha256": "5a8e3d4045d351c0e90d16d330dd39202db7c2219f6e1f4920aaee324a5665a5",
12
+ "bytes": 27014412
13
13
  },
14
14
  "linux-x64": {
15
15
  "file": "oalo-coord-linux-x64.gz",
16
- "sha256": "dad3c5e0dd9a794c200ec2824fbf7a3786700b96f9c46ad18a53b873db645983",
17
- "bytes": 36905376
16
+ "sha256": "7ddba63fb1e62579dcdc2359aec11ee2fd41de6adf651cafe91247afb169c677",
17
+ "bytes": 36906273
18
18
  },
19
19
  "linux-arm64": {
20
20
  "file": "oalo-coord-linux-arm64.gz",
21
- "sha256": "e58aeadf446af3d09806e6525e2edc29888337dd84592e863e82545ed96eb352",
22
- "bytes": 37145971
21
+ "sha256": "caea90592aabe555d8f6f3819d1afc36161aa250b4a21e2c9d8142e7b5ab538b",
22
+ "bytes": 37146886
23
23
  }
24
24
  }
25
25
  }
package/src/help.js CHANGED
@@ -284,20 +284,27 @@ export const COMMANDS = [
284
284
  },
285
285
  {
286
286
  name: "db",
287
- summary: "Read an env's tables with SQL (your app's own included), dump all of an env's data as plain SQL to keep or take anywhere, or load an existing Postgres database into an env.",
288
- env: "query and tables: --env dev|prod, else the project's env, else dev. dump: --env, default prod, whatever the project's env is. restore: --env is required.",
287
+ summary: "Read tables with SQL (including isolated app schemas), inspect schemas and cross-app grants, share one app's tables with another app, dump an env as SQL, or restore an existing Postgres database.",
288
+ env: "query and tables: --env dev|prod, else the project's env, else dev. dump: --env, default prod, whatever the project's env is. restore: --env is required. schemas, grant and revoke cover both dev and prod.",
289
289
  usage: [
290
- 'oalo db query "<sql>" [--env dev|prod] [--limit <n>] [--json]',
291
- "oalo db tables [--env dev|prod]",
292
- "oalo db dump [--env dev|prod] [--out <file.sql>] [--force]",
293
- "oalo db restore <file> --env dev|prod [--schema <name>] [--check] [--yes]",
294
- "oalo db restore --from-env <VAR> --env dev|prod [--schema <name>] [--check] [--yes]",
290
+ 'oalo db query "<sql>" [--env dev|prod] [--app <slug>] [--limit <n>] [--json]',
291
+ "oalo db tables [--env dev|prod] [--app <slug>]",
292
+ "oalo db schemas [--json]",
293
+ "oalo db grant <owner-app|workspace> --to <grantee-app> [--read-only]",
294
+ "oalo db revoke <owner-app|workspace> --from <grantee-app>",
295
+ "oalo db dump [--env dev|prod] [--app <slug>] [--out <file.sql>] [--force]",
296
+ "oalo db restore <file> --env dev|prod [--app <slug>] [--schema <name>] [--check] [--yes]",
297
+ "oalo db restore --from-env <VAR> --env dev|prod [--app <slug>] [--schema <name>] [--check] [--yes]",
295
298
  ],
296
299
  flags: [
297
300
  { flag: "--env dev|prod", desc: "query, tables: which env. Default the project's, else dev. dump: which env's data. Default prod. restore: which env the data goes into, always on the command line." },
301
+ { flag: "--app <slug>", desc: "Target a specific server app's isolated schema (`app_<slug>_dev` / `app_<slug>_prod`) instead of the shared workspace schema (`dev` / `prod`)." },
302
+ { flag: "--to <grantee-app>", desc: "grant: the app slug receiving SQL access to the owner's schema." },
303
+ { flag: "--from <grantee-app>", desc: "revoke: the app slug whose access to the owner's schema is removed." },
304
+ { flag: "--read-only", desc: "grant: allow SELECT only (default is read/write: SELECT, INSERT, UPDATE, DELETE)." },
298
305
  { flag: "--limit <n>", desc: "query: rows to show. Default 100, at most 1000." },
299
- { flag: "--json", desc: "query: {columns, rows, truncated} as JSON." },
300
- { flag: "--out <file.sql>", desc: "Where to write it. Default <workspace>-<env>-<date>.sql here." },
306
+ { flag: "--json", desc: "query, schemas, grant, revoke: structured JSON output." },
307
+ { flag: "--out <file.sql>", desc: "Where to write it. Default <workspace>-[<app>-]<env>-<date>.sql here." },
301
308
  { flag: "--force", desc: "Replace the file if it exists." },
302
309
  { flag: "--from-env <VAR>", desc: "restore: copy from a running database instead of a file. VAR is the environment variable that holds its postgres:// or postgresql:// URL. Only its host is ever shown." },
303
310
  { flag: "--schema <name>", desc: "restore: the source schema to load. Default public, or the only one when there's just one." },
@@ -305,12 +312,14 @@ export const COMMANDS = [
305
312
  { flag: "--yes", desc: "restore: go ahead with prod without asking. Needed for prod when there's no terminal to ask at." },
306
313
  ],
307
314
  notes: [
308
- "query reads only: one statement (SELECT, WITH, TABLE, VALUES, EXPLAIN or SHOW), run as your app's database login in a read-only transaction that is rolled back, with a 10 second limit. It sees what your app sees at DATABASE_URL: the env's tables, not the platform's. `oalo data` is for Oalo models; this is for any table, your app's own included. Available to workspace admins and members with Developer access.",
309
- "dump is workspace admins only: it holds every member's data. Restore it into any Postgres with psql -f.",
315
+ "New imported/created server apps get isolated schemas (`app_<slug>_dev` and `app_<slug>_prod`) with their own Postgres login, so multiple apps can each keep their own `products`, `orders`, `users` or ORM migrations without colliding. Existing shared apps stay in `dev`/`prod`.",
316
+ "Sharing data across apps without duplication: (1) for shared business data (users, CRM, commerce, Oalo models), have both apps call Oalo's Sync/platform APIs with their injected `OALO_URL` and `OALO_SYNC_TOKEN`; (2) when App B needs direct SQL read/write on App A's app-specific tables, run `oalo db grant <app-a> --to <app-b>` (or `--read-only`). Postgres grants privileges on current and future tables in both dev and prod, and App B receives `APP_SCHEMA_<APP_A>` and `OALO_SHARED_SCHEMAS` in its environment so it can query `\"${process.env.APP_SCHEMA_<APP_A>}\".<table>` without hardcoding dev/prod. Pass `workspace` as the owner to grant direct SQL access to the workspace's `dev`/`prod` schema.",
317
+ "query reads only: one statement (SELECT, WITH, TABLE, VALUES, EXPLAIN or SHOW), run as the env's (or `--app`'s) database login in a read-only transaction that is rolled back, with a 10 second limit. `oalo data` is for Oalo models; this is for any table, your app's own included. Available to workspace admins and members with Developer access.",
318
+ "dump is workspace admins only: without `--app`, it dumps the workspace schema plus every isolated app schema for that env; with `--app <slug>`, it dumps only that app's schema. Restore it into any Postgres with psql -f.",
310
319
  "Your code is in git (oalo deploy --pull); this is the data. Together they are everything you need to run your apps elsewhere.",
311
- "restore loads a dump file made by pg_dump (like Heroku's latest.dump), up to 10 GB, or copies from a database URL. Admins only, and one restore at a time per Base.",
312
- "The tables land in the env's schema, owned by the app's database login, so its Procfile `release:` migrations can alter them. Your app reads them at DATABASE_URL.",
313
- "It's refused if a table name already exists there, and the names are listed. A failed restore leaves the env as it was.",
320
+ "restore loads a dump file made by pg_dump (like Heroku's latest.dump), up to 10 GB, or copies from a database URL. Admins only, and one restore at a time per Base. Pass `--app <slug>` to restore directly into an isolated server app's schema.",
321
+ "The tables land in the target schema, owned by the app's database login, so its Procfile `release:` migrations can alter them. Your app reads them at DATABASE_URL.",
322
+ "It's refused if a table name already exists there, and the names are listed. A failed restore leaves the target schema as it was.",
314
323
  "The URL is never a flag value, since that stays in your shell history. Put it in a variable and pass --from-env VAR.",
315
324
  "Run it with --check first. prod asks before it writes; without a terminal it needs --yes. Stop writes to the old database before the copy: writes made after it starts are lost.",
316
325
  ],
@@ -588,7 +597,8 @@ export const COMMANDS = [
588
597
  "<bot> is the bot's public id (bot_...), as `oalo bots` prints it.",
589
598
  "A source is a table made searchable with `oalo data vectorize <table> --fields ...`. A bot always searches its own knowledge base (documents) too. knowledge lists those documents, and which have priority.",
590
599
  "The same as ticking a table in the bot's Knowledge pane in the dashboard, with the same access as there.",
591
- "settings go through the dashboard's own actions, with the same checks and access. A change sets only the settings it names: the model without the provider keeps the provider, one limit keeps the others, one context.* key keeps the rest of the context config.",
600
+ "settings go through the dashboard's own actions, with the same checks and access. A change sets only the settings it names: the model without the provider keeps the provider (except a provider/model id with a slash, which automatically sets provider=opencode), one limit keeps the others, one context.* key keeps the rest of the context config.",
601
+ "Pick a bot's model with `oalo bots settings <bot> set model=<tier-or-id>`, for example `balanced`, `google/gemini-4-argon`, `bedrock/us.amazon.ergo-1.0`, `openrouter/thinkingmachines/inkling-2-mini`, `openrouter/deepseek/deepseek-v4.1-flash`, `claude-sonnet-4-6`, or a `byo-...` own model. Run `oalo docs ai-steps-and-providers` for the full hosted model table.",
592
602
  "Every setting is described in `man oalo` (BOT SETTINGS) and by `oalo bots settings --explain`.",
593
603
  "The knowledge graph links a bot's passages: each document's sections, and the sections like each other, so a match can bring in related ones and the topics above it. A bot has none until `oalo bots graph <bot> --build`. graph shows its size and whether links are labeled; how answers use it is in settings (graph_retrieval, ancestor_preload_depth, graph_classify_edges). Markdown front matter's related: list links pages by name.",
594
604
  ],
@@ -17,7 +17,7 @@ export const TOOL_GROUPS = {
17
17
  "look around": ["oalo_describe", "oalo_list_apps", "oalo_list_bots", "oalo_get_bot", "oalo_list_loops", "oalo_docs", "oalo_jobs"],
18
18
  "chat flows": ["oalo_node_catalog", "oalo_list_flows", "oalo_get_flow", "oalo_lint_flow", "oalo_save_flow", "oalo_set_flow_enabled", "oalo_delete_flow", "oalo_test_conversation", "oalo_flow_runs", "oalo_get_conversation"],
19
19
  "loops (workflows)": ["oalo_get_loop", "oalo_lint_loop", "oalo_save_loop", "oalo_loop_triggers", "oalo_test_loop", "oalo_loop_runs", "oalo_set_loop_enabled", "oalo_run_loop_now", "oalo_delete_loop", "oalo_emit", "oalo_loop_docs"],
20
- "data": ["oalo_list_models", "oalo_create_model", "oalo_read_rows", "oalo_write_rows", "oalo_promote_model", "oalo_db_query", "oalo_query_metrics", "oalo_sync_routes", "oalo_list_dashboards", "oalo_save_dashboard_widget", "oalo_sources"],
20
+ "data": ["oalo_list_models", "oalo_create_model", "oalo_read_rows", "oalo_write_rows", "oalo_promote_model", "oalo_db_query", "oalo_db_schemas", "oalo_query_metrics", "oalo_sync_routes", "oalo_list_dashboards", "oalo_save_dashboard_widget", "oalo_sources"],
21
21
  "code tools": ["oalo_list_functions", "oalo_generate_tool", "oalo_get_tool_source", "oalo_save_tool_source", "oalo_tool_templates", "oalo_bot_tools"],
22
22
  "apps": ["oalo_app_logs", "oalo_releases", "oalo_incidents", "oalo_secrets"],
23
23
  "channels and sales": ["oalo_widgets", "oalo_wa_templates", "oalo_rehearse_inbound", "oalo_pipelines"],
package/src/mcp/tools.js CHANGED
@@ -204,8 +204,15 @@ export const TOOLS = [
204
204
  max_iterations: { type: "number" },
205
205
  max_cost_usd: { type: "number" },
206
206
  session_mode: { type: "string", enum: ["recursive", "persistent"] },
207
- provider: { type: "string", enum: ["anthropic", "opencode"] },
208
- model: { type: "string" },
207
+ provider: {
208
+ type: "string",
209
+ enum: ["anthropic", "opencode"],
210
+ description: "Default AI provider (opencode covers Gemini, Amazon Bedrock, OpenRouter/Thinking Machines/DeepSeek/Qwen/MiniMax/Llama, GLM, OpenAI, and own models; anthropic is Claude). Auto-selected when model contains '/'.",
211
+ },
212
+ model: {
213
+ type: "string",
214
+ description: "Default AI model tier (cheap, balanced, max) or concrete id (e.g. google/gemini-4-argon, bedrock/us.amazon.ergo-1.0, openrouter/thinkingmachines/inkling-2-mini, openrouter/deepseek/deepseek-v4-pro, claude-sonnet-4-6).",
215
+ },
209
216
  base_version: { type: "number", description: "The `version` from oalo_get_loop. Enables the conflict check." },
210
217
  strict: { type: "boolean", description: "Refuse the save on any error-level lint finding (default true)." },
211
218
  },
@@ -748,20 +755,26 @@ export const TOOLS = [
748
755
  {
749
756
  name: "oalo_db_query",
750
757
  description:
751
- "One read-only SQL statement against an env's tables, as the app's own database login sees them (the server apps' own tables and the Oalo models; not the platform's). Use it to check rows an app wrote to its own table, which oalo_read_rows can't see (it reads Oalo models only). SELECT, WITH, TABLE, VALUES, EXPLAIN or SHOW; run in a read-only transaction that is rolled back, 10 second limit. List the tables with: select relname from pg_class c join pg_namespace n on n.oid = c.relnamespace where n.nspname = current_schema() and relkind = 'r'. Workspace admins and members with Developer access. Rows can hold customers' details: never repeat those. Read-only.",
758
+ "One read-only SQL statement against an env's (or isolated app's) tables, as the app's own database login sees them (the server app's own tables and/or Oalo models; not the platform's). Pass `app` (slug) to target an isolated server app's dedicated schema (`app_<slug>_<env>`). Use it to check rows an app wrote to its own table, which oalo_read_rows can't see (it reads Oalo models only). SELECT, WITH, TABLE, VALUES, EXPLAIN or SHOW; run in a read-only transaction that is rolled back, 10 second limit. List the tables with: select relname from pg_class c join pg_namespace n on n.oid = c.relnamespace where n.nspname = current_schema() and relkind = 'r'. Workspace admins and members with Developer access. Rows can hold customers' details: never repeat those. Read-only.",
752
759
  inputSchema: S(
753
760
  {
754
761
  sql: { type: "string", description: "One statement" },
755
762
  env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live)" },
763
+ app: { type: "string", description: "Optional app slug for an isolated server app (`app_<slug>_<env>`)" },
756
764
  limit: { type: "integer", description: "Rows, default 100, at most 1000" },
757
765
  },
758
766
  ["sql"],
759
767
  ),
760
- run: async (_oalo, { sql, env, limit }, ctx) => {
768
+ run: async (_oalo, { sql, env, app, limit }, ctx) => {
761
769
  const res = await fetch(`${String(ctx.url).replace(/\/$/, "")}/api/cli/v1/db/query`, {
762
770
  method: "POST",
763
771
  headers: { authorization: `Bearer ${ctx.token}`, "content-type": "application/json" },
764
- body: JSON.stringify({ sql, env: env === "prod" ? "prod" : "dev", ...(limit ? { limit } : {}) }),
772
+ body: JSON.stringify({
773
+ sql,
774
+ env: env === "prod" ? "prod" : "dev",
775
+ ...(app ? { app } : {}),
776
+ ...(limit ? { limit } : {}),
777
+ }),
765
778
  });
766
779
  const body = await res.json().catch(() => ({}));
767
780
  if (res.status === 404) throw new Error("this workspace doesn't have db queries yet (it comes with a newer Base)");
@@ -769,6 +782,20 @@ export const TOOLS = [
769
782
  return body;
770
783
  },
771
784
  },
785
+ {
786
+ name: "oalo_db_schemas",
787
+ description:
788
+ "List the workspace's Postgres schemas (`dev`, `prod`), every isolated server app's dedicated schemas (`app_<slug>_dev`, `app_<slug>_prod`), and any active cross-app schema grants (`oalo db grant <owner> --to <grantee>`). Call this before `oalo_db_query` or before wiring one app to read/write another app's tables so you know the exact schema names and injected `APP_SCHEMA_<OWNER>` env vars. Read-only.",
789
+ inputSchema: S({}),
790
+ run: async (_oalo, _args, ctx) => {
791
+ const res = await fetch(`${String(ctx.url).replace(/\/$/, "")}/api/cli/v1/db/schemas`, {
792
+ headers: { authorization: `Bearer ${ctx.token}` },
793
+ });
794
+ const body = await res.json().catch(() => ({}));
795
+ if (!res.ok) throw new Error(body?.error?.message || `could not list schemas (HTTP ${res.status})`);
796
+ return body;
797
+ },
798
+ },
772
799
  {
773
800
  name: "oalo_query_metrics",
774
801
  description:
@@ -187,6 +187,7 @@ export class ModelRequests {
187
187
  method: "POST",
188
188
  headers: upstreamHeaders(h, this.env, stream ? "text/event-stream" : "application/json"),
189
189
  body: JSON.stringify(body),
190
+ redirect: "error",
190
191
  signal: controller.signal,
191
192
  });
192
193
  } catch (e) {
@@ -297,7 +298,12 @@ export async function discoverModels({ baseUrl, server, only, key, fetchImpl = g
297
298
  const headers = { accept: "application/json" };
298
299
  if (key) headers.authorization = `Bearer ${key}`;
299
300
  const get = async (url, init = {}) => {
300
- const r = await fetchImpl(url, { ...init, headers: { ...headers, ...(init.headers || {}) }, signal: AbortSignal.timeout(timeoutMs) });
301
+ const r = await fetchImpl(url, {
302
+ ...init,
303
+ redirect: "error",
304
+ headers: { ...headers, ...(init.headers || {}) },
305
+ signal: AbortSignal.timeout(timeoutMs),
306
+ });
301
307
  const text = await r.text();
302
308
  if (!r.ok) throw Object.assign(new Error(`${r.status}: ${text.slice(0, 200)}`), { status: r.status });
303
309
  return JSON.parse(text);