@oalo-ai/cli 0.4.1 → 0.4.3

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/src/help.js CHANGED
@@ -63,6 +63,7 @@ export const COMMANDS = [
63
63
  {
64
64
  name: "link",
65
65
  summary: "Point this project at a workspace and save credentials.",
66
+ env: "Sets the project's default env, `env` in .oalo/config.json: --env dev (staging, the default) or prod (live). Running link again without --env sets it back to dev. Only data, db query, db tables, deploy, env, logs, run loop and typegen read it.",
66
67
  usage: [
67
68
  "oalo link --server <url> [--token <sync token>] [--cli-token <token>] [--app <slug>] [--env dev|prod] [--no-skill]",
68
69
  "oalo link --status",
@@ -72,7 +73,7 @@ export const COMMANDS = [
72
73
  { flag: "--token <token>", desc: "Sync token (data plane). Not needed after oalo login, which saved one." },
73
74
  { flag: "--cli-token <token>", desc: "CLI token (control plane), for tail and mcp. Optional." },
74
75
  { flag: "--app <slug>", desc: "The app that deploy, env, logs, secrets and dockerfile use when you don't pass --app (`oalo apps` lists them). `oalo deploy --new` sets it." },
75
- { flag: "--env dev|prod", desc: "Which schema later commands touch. Default dev." },
76
+ { flag: "--env dev|prod", desc: "The project's default env for the commands that read it. Default dev." },
76
77
  { flag: "--status", desc: "Show the current link and re-check reachability." },
77
78
  { flag: "--no-skill", desc: "Don't install or refresh the Oalo skill for coding agents (see `oalo skill`)." },
78
79
  ],
@@ -86,8 +87,10 @@ export const COMMANDS = [
86
87
  {
87
88
  name: "typegen",
88
89
  summary: "Generate TypeScript bindings from the workspace's own schema: its models, and the workflows apps can call.",
89
- usage: ["oalo typegen [--out <file>] [--check]", "oalo typegen --dart [--out <project dir>] [--check]"],
90
+ env: "--env dev|prod, else the project's env (`oalo link --env`), else dev. It is stamped in the file's header, and --dart writes it into .oalo/dart-defines.json as OALO_ENV.",
91
+ usage: ["oalo typegen [--out <file>] [--check] [--env dev|prod]", "oalo typegen --dart [--out <project dir>] [--check] [--env dev|prod]"],
90
92
  flags: [
93
+ { flag: "--env dev|prod", desc: "Which env to read. Default: the project's, else dev." },
91
94
  { flag: "--out <file>", desc: "Output path. Default oalo.generated.ts. With --dart, the Flutter project's root (default the current folder)." },
92
95
  { flag: "--dart", desc: "For a Flutter app from Oalo's template: write lib/sync/generated and lib/models (the Base's own Dart generator, the one the box uses), and .oalo/dart-defines.json with the Base's address, the linked app's slug and the env, for `flutter run --dart-define-from-file=.oalo/dart-defines.json`." },
93
96
  { flag: "--check", desc: "Do not write; exit non-zero if the file is stale or missing. For CI." },
@@ -124,7 +127,8 @@ export const COMMANDS = [
124
127
  {
125
128
  name: "call",
126
129
  summary: "Call any build-surface event directly. The escape hatch.",
127
- usage: ["oalo call <event> ['<json params>']", "oalo call --list [text] [--json]"],
130
+ env: "Doesn't add the project's env. An event that takes one reads only \"env\" in the params, with its own default: booking:* and metrics:query use prod, loops:run_now dev. For a draft bot's booking setup, pass \"env\": \"dev\".",
131
+ usage: ["oalo call <event> ['<json params>' | @file.json | -]", "oalo call --list [text] [--json]"],
128
132
  flags: [
129
133
  { flag: "--list [text]", desc: "List the events you can call, from the workspace. With text, the matching events and the params each accepts." },
130
134
  { flag: "--namespaces", desc: "The events you may call, counted per namespace (what `--list` with no text shows)." },
@@ -133,9 +137,11 @@ export const COMMANDS = [
133
137
  notes: [
134
138
  "The build surface has ~500 events. First-class commands cover the common ones; this reaches the rest without a command per feature.",
135
139
  "Params are a JSON object. Org and user identity come from your token, never the params, so a call cannot exceed what you can do.",
140
+ "Params can be inline JSON, @file.json to read that file, or - to read stdin. With no params and input piped in, stdin is read.",
136
141
  "--list comes from the server's own handlers and is filtered to what you may call, so it never goes stale. On an older workspace it falls back to a list of namespaces.",
137
142
  "An unknown event returns a clean error naming what you sent. An event that exists but gets the wrong params says which params it takes.",
138
143
  "Example: oalo call loops:run_now '{\"name\":\"Nurture\"}'",
144
+ "From a file: oalo call loops:get @params.json. From stdin: jq -n '{name: \"Nurture\"}' | oalo call loops:get",
139
145
  "Needs a CLI token.",
140
146
  ],
141
147
  exits: { 0: "the call succeeded", 1: "the call failed or was rejected", 2: "bad arguments or no token" },
@@ -143,11 +149,12 @@ export const COMMANDS = [
143
149
  {
144
150
  name: "run",
145
151
  summary: "Fire a loop, or send a bot a test message, and watch what happens.",
152
+ env: "loop: --env dev|prod, else the project's env, else dev (a loop fired by its real trigger or schedule runs on prod). bot: no --env; the bot uses its own env, dev while it's a draft, prod once published.",
146
153
  usage: ['oalo run loop <name> [--env dev|prod] [--watch]', 'oalo run bot <id> "<message>"'],
147
154
  flags: [
148
155
  { flag: "--watch", desc: "Stream events after firing. Default on for bots." },
149
156
  { flag: "--timeout <s>", desc: "How long to watch. Default 30." },
150
- { flag: "--env dev|prod", desc: "Which schema the loop runs against." },
157
+ { flag: "--env dev|prod", desc: "loop: which env's data it runs on. Default: the project's, else dev." },
151
158
  { flag: "--app <slug>", desc: "Only for a loop pinned to one app: that app's slug (`oalo apps`) or id. Loops are org-wide by default." },
152
159
  ],
153
160
  notes: [
@@ -160,6 +167,7 @@ export const COMMANDS = [
160
167
  {
161
168
  name: "emit",
162
169
  summary: "Fire a domain event (form.submitted, order.created, ...) to test a loop's trigger.",
170
+ env: "No --env. The loops it fires run on prod (live data), as they do for a real event. To try a loop on dev data, use `oalo loops test`.",
163
171
  usage: ["oalo emit <event type> [--payload '<json>'] [--contact <id>] [--dry-run] [--json]", "oalo emit --list [--json]"],
164
172
  flags: [
165
173
  { flag: "--payload <json>", desc: "The event's payload, a JSON object. `oalo emit --list` shows each event's fields." },
@@ -179,6 +187,7 @@ export const COMMANDS = [
179
187
  {
180
188
  name: "data",
181
189
  summary: "Models and rows in this workspace: list, read, push (bulk upsert), delete, watch, promote, and make tables searchable by bots.",
190
+ env: "--env dev|prod, else the project's env (`oalo link --env`), else dev. push and delete write prod only with --env prod typed out. models create makes the model in both; promote copies its rows dev to prod; events fire on prod rows only; vectorize and keep-from-ai cover both envs of a model, and only the --env copy of a plain table.",
182
191
  usage: [
183
192
  "oalo data models [--json]",
184
193
  "oalo data models create <name> --field name:type [--field ...] [--owned-by <field>]",
@@ -216,8 +225,9 @@ export const COMMANDS = [
216
225
  { flag: "--json", desc: "Print the reply as JSON." },
217
226
  ],
218
227
  notes: [
219
- "dev is a sandbox; live apps read prod. Push to dev, check it, then `oalo data promote <table>` copies dev rows to prod.",
228
+ "dev is a sandbox; live apps and published bots read prod, draft bots read dev. Push to dev, check it, then `oalo data promote <table>` copies dev rows to prod.",
220
229
  "Reads use the saved data token (read-only). Row writes use a write token limited to the tables written, made as you over the CLI token the first time you write a table and saved beside it (`oalo tokens list` shows it; it expires in 30 days).",
230
+ "That write token is shared by every project on this machine for the workspace: writing a new table widens it to cover that table too. push and delete print the tables it covers.",
221
231
  "models create and promote run as you over the CLI token, so they follow your dashboard access.",
222
232
  "push sends up to 1,000 rows per request, waits out the rate limit (120 writes a minute), retries network errors, and lists rows the server rejected.",
223
233
  "Every write syncs to apps on that schema at once. A delete marks the row deleted; it leaves synced apps.",
@@ -231,6 +241,7 @@ export const COMMANDS = [
231
241
  {
232
242
  name: "incidents",
233
243
  summary: "A live app's outages and restart bursts, as Oalo's uptime check saw them, newest first.",
244
+ env: "prod (the live app) only. The preview isn't checked; `oalo logs` shows it.",
234
245
  usage: ["oalo incidents [--app <slug>] [--all] [--json]"],
235
246
  flags: [
236
247
  { flag: "--app <slug>", desc: "The app. Default: the one saved with `oalo link --app`." },
@@ -245,14 +256,19 @@ export const COMMANDS = [
245
256
  },
246
257
  {
247
258
  name: "db",
248
- summary: "All of an env's data as plain SQL (every app's own tables and the Oalo models), to keep a copy or take it anywhere. Or load an existing Postgres database into an env.",
259
+ 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.",
260
+ 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.",
249
261
  usage: [
262
+ 'oalo db query "<sql>" [--env dev|prod] [--limit <n>] [--json]',
263
+ "oalo db tables [--env dev|prod]",
250
264
  "oalo db dump [--env dev|prod] [--out <file.sql>] [--force]",
251
265
  "oalo db restore <file> --env dev|prod [--schema <name>] [--check] [--yes]",
252
266
  "oalo db restore --from-env <VAR> --env dev|prod [--schema <name>] [--check] [--yes]",
253
267
  ],
254
268
  flags: [
255
- { flag: "--env dev|prod", desc: "dump: which env's data. Default prod. restore: which env the data goes into, always on the command line." },
269
+ { 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." },
270
+ { flag: "--limit <n>", desc: "query: rows to show. Default 100, at most 1000." },
271
+ { flag: "--json", desc: "query: {columns, rows, truncated} as JSON." },
256
272
  { flag: "--out <file.sql>", desc: "Where to write it. Default <workspace>-<env>-<date>.sql here." },
257
273
  { flag: "--force", desc: "Replace the file if it exists." },
258
274
  { 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." },
@@ -261,6 +277,7 @@ export const COMMANDS = [
261
277
  { flag: "--yes", desc: "restore: go ahead with prod without asking. Needed for prod when there's no terminal to ask at." },
262
278
  ],
263
279
  notes: [
280
+ "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.",
264
281
  "Workspace admins only: it holds every member's data. Restore it into any Postgres with psql -f.",
265
282
  "Your code is in git (oalo deploy --pull); this is the data. Together they are everything you need to run your apps elsewhere.",
266
283
  "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.",
@@ -278,6 +295,7 @@ export const COMMANDS = [
278
295
  {
279
296
  name: "metrics",
280
297
  summary: "A number from the workspace's data: count, sum or average over a model's rows, events or contacts, grouped or over time.",
298
+ env: "A model's rows: prod (live) unless you pass --env dev. The project's env is not read. Events and contacts have one copy, not one per env.",
281
299
  usage: [
282
300
  "oalo metrics <model | events | contacts> [--sum|--avg|--min|--max|--distinct <field>] [--by <field>] [--every day|week|month] [--days N] [--where <filter>] [--json]",
283
301
  ],
@@ -294,7 +312,7 @@ export const COMMANDS = [
294
312
  { flag: "--event <type>", desc: "events: one type, like order.created. Default: every type." },
295
313
  { flag: "--time <created|changed|field>", desc: "A model row counts at when it was created (default), last changed, or one of its date fields." },
296
314
  { flag: "--compare", desc: "Also the same over the window before (needs --days)." },
297
- { flag: "--env dev|prod", desc: "A model's live (default) or dev data." },
315
+ { flag: "--env dev|prod", desc: "A model's live (prod, the default) or dev data. To count rows a test or a draft bot wrote, pass --env dev." },
298
316
  { flag: "--json", desc: "The answer as JSON." },
299
317
  ],
300
318
  notes: [
@@ -306,6 +324,7 @@ export const COMMANDS = [
306
324
  {
307
325
  name: "dashboards",
308
326
  summary: "The workspace's dashboards, and a chart put on one (made when no dashboard has that name).",
327
+ env: "add: a chart over a model reads prod (live) unless you pass --env dev, and keeps reading that env. The project's env is not read. Event, contact and funnel charts have one copy.",
309
328
  usage: [
310
329
  "oalo dashboards [--json]",
311
330
  'oalo dashboards add <dashboard> <model | events | contacts> --title "<title>" --kind number|line|bars|table [metrics flags] [--app <slug>] [--width 1|2|3]',
@@ -321,13 +340,14 @@ export const COMMANDS = [
321
340
  ],
322
341
  notes: [
323
342
  "add runs the query first and refuses one that can't draw, then prints its numbers. It changes what everyone with access sees.",
324
- "The flags after the model are the same as oalo metrics.",
343
+ "The flags after the model are the same as oalo metrics, --env included.",
325
344
  ],
326
345
  exits: { 0: "done", 1: "the request failed", 2: "bad arguments or no CLI token" },
327
346
  },
328
347
  {
329
348
  name: "products",
330
349
  summary: "What the workspace sells (Oalo commerce on its own Stripe account): list, create, rename, change a price, archive, and see orders.",
350
+ env: "Not dev or prod: a product is on your Stripe test key, or on the live key with --live. --env does nothing here.",
331
351
  usage: [
332
352
  "oalo products [--all] [--json]",
333
353
  'oalo products create <id> --name "<name>" --price <amount> --once|--monthly|--yearly [--trial <days>] [--currency <code>] [--description <text>] [--live] [--yes]',
@@ -440,6 +460,7 @@ export const COMMANDS = [
440
460
  {
441
461
  name: "sources",
442
462
  summary: "Feeds that send Oalo rows from outside (another system, a webhook, an export), keeping only the fields you choose.",
463
+ env: "create: rows go to prod (live) unless you pass --env dev, and the source keeps that env (list and show name it). The project's env is not read. A --bot source has no env: its documents are live at once.",
443
464
  usage: [
444
465
  "oalo sources [list] [--json]",
445
466
  "oalo sources create <name> --from <sample.csv|.json|.jsonl> [--table <new model>] [--id-field <field>] [--mode upsert|snapshot] [--auth bearer|hmac|url] [--env dev|prod]",
@@ -470,7 +491,7 @@ export const COMMANDS = [
470
491
  { flag: "--id-field <field>", desc: "create: the field that identifies a record (default id). A record sent again updates its row." },
471
492
  { flag: "--mode snapshot", desc: "create: each upload is the whole set, and rows it leaves out are deleted. Only for a model the source makes. Default upsert." },
472
493
  { flag: "--auth bearer|hmac|url", desc: "create: how a sender proves it's allowed. bearer (default): Authorization: Bearer <secret>. hmac: a signature header over the raw body (--hmac-header, default x-signature; --hmac-format sha256=hex, hex or base64), for tools that sign their webhooks. url: the secret is the last part of the address, for tools that can only send to an address." },
473
- { flag: "--env dev|prod", desc: "create: which copy of the model the rows go to. Default prod." },
494
+ { flag: "--env dev|prod", desc: "create: which env's copy of the table the rows go to. Default prod, whatever the project's env is." },
474
495
  { flag: "--every <minutes>", desc: "fetch: how often Oalo fetches the address, 5 to 10080 minutes. Default 60." },
475
496
  { flag: "--header <value>", desc: "fetch: a request header, \"Name: value\" (an API key, say: --header \"Authorization: Bearer $KEY\"). Repeat it for more, up to 10. Sealed on the server; show prints only the names. Left out, the ones set before stay; --header \"\" clears them." },
476
497
  { flag: "--records-at <path>", desc: "fetch, a table's source: the records are the list at this key of the JSON answer (data.items)." },
@@ -498,6 +519,7 @@ export const COMMANDS = [
498
519
  {
499
520
  name: "bots",
500
521
  summary: "The workspace's bots: the tables each can search, and every setting (knowledge, memory, model, replies, limits).",
522
+ env: "No --env. A bot's status (shown by `oalo bots`) picks its env: a draft searches dev tables and books against dev booking data, a published bot uses prod. Load a draft bot's data in dev.",
501
523
  usage: [
502
524
  "oalo bots [--json]",
503
525
  "oalo bots knowledge <bot> [--json]",
@@ -529,6 +551,7 @@ export const COMMANDS = [
529
551
  {
530
552
  name: "tokens",
531
553
  summary: "List, create and revoke the workspace's sync tokens, for an app's own server.",
554
+ env: "A token with env:dev or env:prod is locked to that env. Without one it can use either, and a Sync API request that doesn't pass ?env= gets prod.",
532
555
  usage: [
533
556
  "oalo tokens list [--json]",
534
557
  "oalo tokens create --name <name> --scope write:<table> [--scope ...] [--days N] [--json]",
@@ -572,6 +595,7 @@ export const COMMANDS = [
572
595
  {
573
596
  name: "deploy",
574
597
  summary: "Send this repo's commits to an app and run them: the preview (dev) by default, the live release with --env prod.",
598
+ env: "--env dev (the preview, the default) or prod (the live release). It follows the project's env, but prod must be typed as --env prod. --new always starts on dev and sets the project's env to dev.",
575
599
  usage: [
576
600
  "oalo deploy [--app <slug>] [--env dev|prod] [--allow-dirty] [--json]",
577
601
  "oalo deploy --new [<name>] [--name \"Display name\"]",
@@ -610,6 +634,7 @@ export const COMMANDS = [
610
634
  {
611
635
  name: "migrate",
612
636
  summary: "Move an app from Heroku, Railway, Render, Fly.io or Primcloud: its Procfile, sizes, health path and variables, worked out from its files and that platform's CLI.",
637
+ env: "--apply sets the variables on prod (the live app) only, whatever the project's env is. Set the preview's with `oalo env set ... --env dev`.",
613
638
  usage: [
614
639
  "oalo migrate <heroku|railway|render|fly|primcloud> [--from-app <name>] [--env-file <file>] [--json]",
615
640
  "oalo migrate <platform> --apply [--app <slug>]",
@@ -633,6 +658,7 @@ export const COMMANDS = [
633
658
  {
634
659
  name: "env",
635
660
  summary: "An app's environment variables on Oalo (API keys, settings), per env: list, set, unset, rotate-token.",
661
+ env: "--env dev (the preview) or prod (the live app), else the project's env, else dev. Changing prod needs --env prod typed out; listing it doesn't.",
636
662
  usage: [
637
663
  "oalo env [--app <slug>] [--env dev|prod] [--json]",
638
664
  "oalo env set NAME=value [NAME=value ...] [--secret | --public] [--no-restart]",
@@ -694,10 +720,11 @@ export const COMMANDS = [
694
720
  {
695
721
  name: "logs",
696
722
  summary: "What an app's own processes printed (server, workers, release command), per env.",
723
+ env: "--env dev (the preview) or prod (the live app), else the project's env, else dev.",
697
724
  usage: ["oalo logs [--app <slug>] [--env dev|prod] [--process web|<worker>] [--limit N] [--follow] [--json]"],
698
725
  flags: [
699
726
  { flag: "--app <slug>", desc: "The app (`oalo apps` lists them). Default: the app saved with `oalo link --app`." },
700
- { flag: "--env dev|prod", desc: "dev is the preview, prod the live app. Default dev." },
727
+ { flag: "--env dev|prod", desc: "dev is the preview, prod the live app. Default: the project's, else dev." },
701
728
  { flag: "--process <name>", desc: "Only this process: web, a Procfile worker's name, release, build (a live build's output, with --env prod), or oalo (Oalo's own notes)." },
702
729
  { flag: "--limit N", desc: "How many recent lines (default 200, at most 2000)." },
703
730
  { flag: "--follow", desc: "Keep printing new lines as they come, until Ctrl-C." },
@@ -712,8 +739,10 @@ export const COMMANDS = [
712
739
  },
713
740
  {
714
741
  name: "loops",
715
- summary: "Test a loop (sends simulated), see its past runs, turn it on or off, or delete it, without pulling and pushing it.",
742
+ summary: "List the loops, test one (sends simulated), see its past runs, turn it on or off, or delete it, without pulling and pushing it.",
743
+ env: "test always runs on dev (staging) data, whatever the project's env is. A loop has one copy, so on, off and delete take no env, and its real runs (triggers, schedules) use prod.",
716
744
  usage: [
745
+ "oalo loops list [--json]",
717
746
  "oalo loops test <name> [--sample latest|example] [--input <json|@file.json>] [--json]",
718
747
  "oalo loops on <name>",
719
748
  "oalo loops off <name>",
@@ -723,7 +752,7 @@ export const COMMANDS = [
723
752
  ],
724
753
  flags: [
725
754
  { flag: "--sample latest|example", desc: "Test with the loop's most recent real event, or one built from its trigger's fields." },
726
- { flag: "--input <json|@file>", desc: "Test with this input instead: an event envelope {type, contact_id, payload}, or what a scheduled loop's first step reads." },
755
+ { flag: "--input <json|@file>", desc: "Test with this input instead: an event envelope {type, contact_id, payload}; for a loop an app calls (an api trigger), {\"type\": \"api\", \"payload\": {<its input fields>}}; or what a scheduled loop's first step reads." },
727
756
  { flag: "--app <slug>", desc: "Only for a loop pinned to one app: that app's slug (`oalo apps`) or id. Works with test, runs, on, off and delete." },
728
757
  { flag: "--id <run>", desc: "runs: one run step by step, with each step's output." },
729
758
  { flag: "--limit N", desc: "runs: at most this many (default 20)." },
@@ -739,6 +768,7 @@ export const COMMANDS = [
739
768
  {
740
769
  name: "flows",
741
770
  summary: "Turn a chat flow on or off, or delete it, by bot and flow name, without pulling and pushing it.",
771
+ env: "No env: a flow has one copy. Its steps use the bot's env, dev while the bot is a draft, prod once published.",
742
772
  usage: ["oalo flows on <bot> <flow>", "oalo flows off <bot> <flow>", "oalo flows delete <bot> <flow>"],
743
773
  flags: [],
744
774
  notes: [
@@ -751,7 +781,7 @@ export const COMMANDS = [
751
781
  {
752
782
  name: "pull",
753
783
  summary: "Fetch chat flows, loops and code tools into .oalo/ as files you can edit.",
754
- usage: ["oalo pull [flows|loops|tools] [--bot <id>] [--name <name>] [--force]"],
784
+ usage: ["oalo pull [flows|loops|tools|catalog] [--bot <id>] [--name <name>] [--force]"],
755
785
  flags: [
756
786
  { flag: "--bot <id>", desc: "Only this bot's flows (numeric or public bot_ id)." },
757
787
  { flag: "--name <name>", desc: "Only the flow or loop with this name." },
@@ -763,6 +793,7 @@ export const COMMANDS = [
763
793
  "A loop file also lists the loop's `triggers` (what starts it). Add or delete entries and push: push adds the new ones and removes the ones you deleted, and keeps any a teammate added since your pull. Set a trigger's `enabled` to turn it on or off.",
764
794
  "Each file holds the editable object (`flow` or `loop`) plus the CLI's bookkeeping: id, version (sent back as base_version on push) and base_hash (how the CLI knows you edited it). Edit the object; leave the bookkeeping alone.",
765
795
  "A file you have edited is kept, not overwritten, unless you pass --force.",
796
+ "With no name, pull copies the whole workspace (every bot's flows, every loop) into .oalo/. In an app's repo, pull what you work on by name, and gitignore the rest. `oalo pull catalog` writes only the node catalogs.",
766
797
  "To create a flow or loop, write a file in the same shape without id or version, then push it. A new loop: {\"kind\": \"loop\", \"name\": \"<name>\", \"loop\": {\"entry\", \"nodes\", \"edges\", ...}, \"triggers\": [...]}. A new flow: {\"kind\": \"flow\", \"bot\": \"<bot_ id>\", \"flow\": {\"name\", \"graph\", ...}}. Run oalo pull once first for the node contracts in .oalo/catalog/.",
767
798
  "Needs a CLI token.",
768
799
  ],
@@ -782,14 +813,16 @@ export const COMMANDS = [
782
813
  {
783
814
  name: "lint",
784
815
  summary: "Check flow and loop files without saving anything.",
785
- usage: ["oalo lint [<file>...] [--verbose] [--json]"],
816
+ usage: ["oalo lint [<file or folder>...] [--verbose] [--json]"],
786
817
  flags: [
787
818
  { flag: "--verbose", desc: "Also show info-level findings." },
788
- { flag: "--json", desc: "One JSON object per file: {path, findings}." },
819
+ { flag: "--json", desc: "One JSON object per file: {path, findings}, plus a note for a tool file." },
789
820
  ],
790
821
  notes: [
791
822
  "The same checks the server runs before a strict save: node types and keys against the catalog, required settings, edges and conditions, references between steps, and tools the flow or loop calls.",
792
823
  "Each finding names the node, what is wrong and how to fix it.",
824
+ "A folder means every flow, loop and tool file inside it, e.g. oalo lint .oalo/loops.",
825
+ "A tool file isn't linted: its code is compiled and checked when you push it.",
793
826
  "Needs a CLI token.",
794
827
  ],
795
828
  exits: { 0: "no errors (warnings allowed)", 1: "errors found", 2: "no token" },
@@ -797,6 +830,7 @@ export const COMMANDS = [
797
830
  {
798
831
  name: "push",
799
832
  summary: "Lint and save edited flow, loop and tool files, guarded against concurrent edits.",
833
+ env: "No env: flows, loops and tools have one copy, and a save is live at once. There is no dev copy to push to first.",
800
834
  usage: ["oalo push [<file>...] [--dry-run] [--no-strict] [--force] [--all] [--verbose]"],
801
835
  flags: [
802
836
  { flag: "--dry-run", desc: "Lint only; save nothing." },
@@ -817,6 +851,7 @@ export const COMMANDS = [
817
851
  {
818
852
  name: "qa",
819
853
  summary: "Run a scripted test conversation with a bot and print the transcript.",
854
+ env: "No --env. The bot uses its own env: a draft reads and writes dev (tables, bookings), a published bot prod, in a test too. Set up a draft bot's data in dev before testing it.",
820
855
  usage: [
821
856
  'oalo qa <bot> "<message>" ["<message>" ...] [--channel web|whatsapp|instagram|sms] [--flow <name>] [--timeout <s>] [--json]',
822
857
  "oalo qa <bot> --script <file.json>",
@@ -831,7 +866,9 @@ export const COMMANDS = [
831
866
  ],
832
867
  notes: [
833
868
  "The conversation is a preview with no phone number or external id: the inbox leaves it out and nothing is sent to WhatsApp, Instagram or SMS.",
834
- "Everything else is real: the bot's tools and flows run, collected contact details are saved, handoffs happen. Use a test bot, or flows whose side effects you are fine repeating.",
869
+ "Everything else is real: the bot's tools and flows run and handoffs happen. Use a test bot, or flows whose side effects you are fine repeating.",
870
+ "qa only sends text. It can't fill in or submit a web form or tap a widget, so test those steps in the dashboard's chat preview.",
871
+ "Contact details the bot collects reach a contact only when the test chat has one linked. On whatsapp and sms the test contact is removed when the run ends.",
835
872
  "Each message waits until the bot settles (no new message and no running flow), then the next is sent. Any flow still active at the end is cancelled and the conversation is closed.",
836
873
  "At most 20 messages per run. bot accepts a numeric id or a public bot_ id.",
837
874
  "Needs a CLI token.",
@@ -841,6 +878,7 @@ export const COMMANDS = [
841
878
  {
842
879
  name: "rehearse",
843
880
  summary: "Rehearse inbound WhatsApp conversations end to end: routing, triage and the bot's reply.",
881
+ env: "No --env. The bot that answers uses its own env: dev while it's a draft, prod once published.",
844
882
  usage: ["oalo rehearse [--number <phone_number_id>] [--responder <bot_...>] [--timeout <s>] [--json]", "oalo rehearse --script <file.json>"],
845
883
  flags: [
846
884
  { flag: "--number <id>", desc: "The WhatsApp number (phone_number_id) the customer writes to. Default: the workspace's default number." },
@@ -876,6 +914,7 @@ export const COMMANDS = [
876
914
  {
877
915
  name: "mcp",
878
916
  summary: "Serve the workspace over MCP on stdio, for Claude Code or Cursor.",
917
+ env: "The tools never read the project's env. oalo_read_rows, oalo_list_models and oalo_db_query default to dev; oalo_query_metrics and dashboard widgets to prod; oalo_write_rows needs env. Pass env in each call.",
879
918
  usage: ["oalo mcp"],
880
919
  flags: [],
881
920
  notes: [
@@ -941,6 +980,22 @@ export const COMMANDS = [
941
980
  },
942
981
  ];
943
982
 
983
+ /**
984
+ * dev and prod, in plain lines, for `oalo help`, `help --json` and the man
985
+ * page. Agents in the CLI trial wrote setup to one env and tested in the
986
+ * other, so this says which surface uses which. A command's own `env` line
987
+ * says what that command does.
988
+ */
989
+ export const ENVIRONMENTS = [
990
+ "Every workspace has two envs: dev (staging, a sandbox) and prod (live: what customers and live apps see). Tables and their rows, booking data, an app's variables, logs and releases are kept per env.",
991
+ "The project's default env is `env` in .oalo/config.json, set by `oalo link --env dev|prod` (default dev; `oalo deploy --new` sets dev). data, db query, db tables, deploy, env, logs, run loop and typegen follow it; --env on the command line wins.",
992
+ "Other commands don't read it: metrics, dashboards add, sources create and db dump default to prod; loops test always runs on dev; migrate --apply writes prod; db restore needs --env. MCP tools never read it: pass env in each call.",
993
+ "A draft (unpublished) bot reads and writes dev: it searches dev tables and books against dev booking data. A published bot uses prod. A test conversation (qa, run bot) uses the bot's env too, so set up a draft bot's tables and booking data in dev, and a published bot's in prod.",
994
+ "`oalo data promote <table>` copies a table's rows from dev to prod. Writing prod by hand needs --env prod typed out (data push and delete, deploy, env changes).",
995
+ "Flows, loops and code tools have one copy, not one per env: a saved one is live. Loops fired by real triggers and schedules run on prod. Contacts and events have one copy too.",
996
+ "When it matters, pass --env (MCP and `oalo call`: \"env\") every time instead of relying on a default.",
997
+ ];
998
+
944
999
  export const ENV_VARS = [
945
1000
  { name: "OALO_URL", desc: "Workspace URL; overrides the linked config." },
946
1001
  { name: "OALO_SYNC_TOKEN", desc: "Sync token; overrides the stored one." },
@@ -963,8 +1018,10 @@ export function overview() {
963
1018
  `Run \`oalo help <command>\` for detail, or \`oalo help --json\` for a`,
964
1019
  `machine-readable description of every command, flag and exit code.`,
965
1020
  ``,
966
- `Two token kinds, NOT interchangeable:`,
1021
+ `Environments (dev = staging, prod = live):`,
967
1022
  );
1023
+ for (const e of ENVIRONMENTS) lines.push(` - ${e}`);
1024
+ lines.push(``, `Two token kinds, NOT interchangeable:`);
968
1025
  for (const t of TOKENS) {
969
1026
  lines.push(` ${pad(t.kind, 5)} ${t.plane}`);
970
1027
  lines.push(` from ${t.where}`);
@@ -977,7 +1034,9 @@ export function commandHelp(name) {
977
1034
  const c = COMMANDS.find((x) => x.name === name);
978
1035
  if (!c) return null;
979
1036
 
980
- const lines = [`oalo ${c.name}: ${c.summary}`, ``, `Usage:`];
1037
+ const lines = [`oalo ${c.name}: ${c.summary}`, ``];
1038
+ if (c.env) lines.push(`Env: ${c.env}`, ``);
1039
+ lines.push(`Usage:`);
981
1040
  for (const u of c.usage) lines.push(` ${u}`);
982
1041
 
983
1042
  if (c.flags.length) {
@@ -999,7 +1058,7 @@ export function commandHelp(name) {
999
1058
  /** Machine-readable. Intended for an agent deciding how to drive the CLI. */
1000
1059
  export function helpJson() {
1001
1060
  return JSON.stringify(
1002
- { name: "oalo", tagline: TAGLINE, commands: PUBLIC, tokens: TOKENS, env: ENV_VARS },
1061
+ { name: "oalo", tagline: TAGLINE, environments: ENVIRONMENTS, commands: PUBLIC, tokens: TOKENS, env: ENV_VARS },
1003
1062
  null,
1004
1063
  2,
1005
1064
  );
package/src/mcp/tools.js CHANGED
@@ -36,7 +36,7 @@ export const TOOLS = [
36
36
  },
37
37
  {
38
38
  name: "oalo_list_bots",
39
- description: "List the chatbots in this workspace, with their public ids.",
39
+ description: "List the chatbots in this workspace, with their public ids and status. A draft (unpublished) bot reads and writes dev (staging) data, a published one prod (live).",
40
40
  inputSchema: S({}),
41
41
  event: "chat:bots:list",
42
42
  },
@@ -224,7 +224,7 @@ export const TOOLS = [
224
224
  {
225
225
  name: "oalo_test_loop",
226
226
  description:
227
- "Test a loop and get each step's output. Every step runs, but steps that send messages or change records (email, WhatsApp, SMS, CRM, bookings) are simulated: their output says what they would have done. Custom tools and AI steps run for real. Works on a loop that is off. Input: `sample` \"latest\" uses the loop's most recent real event, \"example\" builds one from its trigger's fields, or pass `input` yourself (an event envelope {type, contact_id, payload}, or the fields a scheduled loop's first step reads); none for a manual or scheduled loop. Waits for the run, up to 3 minutes. Test after every change, before turning a loop on.",
227
+ "Test a loop and get each step's output. Every step runs, but steps that send messages or change records (email, WhatsApp, SMS, CRM, bookings) are simulated: their output says what they would have done. Custom tools and AI steps run for real. Works on a loop that is off. Input: `sample` \"latest\" uses the loop's most recent real event, \"example\" builds one from its trigger's fields, or pass `input` yourself (an event envelope {type, contact_id, payload}, or the fields a scheduled loop's first step reads); none for a manual or scheduled loop. Waits for the run, up to 3 minutes. Test after every change, before turning a loop on. A test always runs on dev (staging) data; real runs from triggers and schedules use prod.",
228
228
  inputSchema: S(
229
229
  {
230
230
  name: { type: "string" },
@@ -249,7 +249,7 @@ export const TOOLS = [
249
249
  name: "oalo_run_loop_now",
250
250
  description:
251
251
  "Start a loop run now, for real, without waiting for its trigger. MUTATES: its steps send real messages and change real records. To check what a loop does, use oalo_test_loop instead; run one now only when the person asks.",
252
- inputSchema: S({ name: { type: "string" }, app_id: { type: "string" }, env: { type: "string", enum: ["dev", "prod"] } }, ["name"]),
252
+ inputSchema: S({ name: { type: "string" }, app_id: { type: "string" }, env: { type: "string", enum: ["dev", "prod"], description: "Which env's data the run uses: dev (staging, the default) or prod (live). Pass it." } }, ["name"]),
253
253
  event: "loops:run_now",
254
254
  mutates: true,
255
255
  },
@@ -412,7 +412,7 @@ export const TOOLS = [
412
412
  inputSchema: S(
413
413
  {
414
414
  app: { type: "string", description: "The app's slug (oalo_list_apps)" },
415
- env: { type: "string", enum: ["dev", "prod"] },
415
+ env: { type: "string", enum: ["dev", "prod"], description: "dev (the preview, the default) or prod (the live app)" },
416
416
  process: { type: "string", description: "Only this process: web, a worker's name, release or oalo" },
417
417
  limit: { type: "number", description: "Recent lines, default 200" },
418
418
  },
@@ -468,7 +468,7 @@ export const TOOLS = [
468
468
  {
469
469
  name: "oalo_test_conversation",
470
470
  description:
471
- "Run a scripted test conversation with a bot and get the transcript: the bot's replies per message, flow state (where a flow is and what it waits for), the path of flow steps, every step with its status and output (`steps`), and the cost. Use it after saving a flow to check it behaves. `channel` makes the bot act as that channel (whatsapp/instagram/sms = text mode); on whatsapp and sms the test customer arrives with a fictional phone on file, as a real one does. With `flow`, the bot can also start that flow again on a later message, even while it is off. The conversation is a hidden preview and nothing is sent to customers, but the bot's tools and flows run for real (contact details are saved, handoffs happen). Takes a while: each message waits until the bot settles.",
471
+ "Run a scripted test conversation with a bot and get the transcript: the bot's replies per message, flow state (where a flow is and what it waits for), the path of flow steps, every step with its status and output (`steps`), and the cost. Use it after saving a flow to check it behaves. `channel` makes the bot act as that channel (whatsapp/instagram/sms = text mode); on whatsapp and sms the test customer arrives with a fictional phone on file, as a real one does. With `flow`, the bot can also start that flow again on a later message, even while it is off. The conversation is a hidden preview and nothing is sent to customers, but the bot's tools and flows run for real and handoffs happen. It only sends text: it can't fill in or submit a web form or tap a widget. Collected contact details reach a contact only when the test chat has one linked; a whatsapp or sms test contact is removed when the run ends. The bot uses its own env in a test too: a draft bot reads and writes dev (staging) tables and booking data, a published bot prod (live), so set up a draft bot's data in dev. Takes a while: each message waits until the bot settles.",
472
472
  inputSchema: S(
473
473
  {
474
474
  bot_id: { type: "string", description: "Numeric id or public bot id (bot_...)" },
@@ -485,7 +485,7 @@ export const TOOLS = [
485
485
  {
486
486
  name: "oalo_rehearse_inbound",
487
487
  description:
488
- "Rehearse inbound WhatsApp conversations end to end and get a report per scenario: what the customer was sent, which thread and bot it ended on, the triage loop runs and their steps, pass/fail checks and, when nothing was sent, why. A fictional 555-01XX customer writes to one of the workspace's numbers through the real inbound path (routing, triage, moves, the bot's reply). Nothing is sent to WhatsApp, the threads stay out of the Inbox and the team gets no notices; LLM calls are real. `suite: true` runs the standard scenarios (new customer, known contact with a thread open on another number, returning the same day, after 24 hours, deal won earlier, writes again after opting out, handed to a teammate, with a teammate writing from another number). Takes minutes.",
488
+ "Rehearse inbound WhatsApp conversations end to end and get a report per scenario: what the customer was sent, which thread and bot it ended on, the triage loop runs and their steps, pass/fail checks and, when nothing was sent, why. A fictional 555-01XX customer writes to one of the workspace's numbers through the real inbound path (routing, triage, moves, the bot's reply). Nothing is sent to WhatsApp, the threads stay out of the Inbox and the team gets no notices; LLM calls are real. The answering bot uses its own env (dev while a draft, prod once published). `suite: true` runs the standard scenarios (new customer, known contact with a thread open on another number, returning the same day, after 24 hours, deal won earlier, writes again after opting out, handed to a teammate, with a teammate writing from another number). Takes minutes.",
489
489
  inputSchema: S(
490
490
  {
491
491
  suite: { type: "boolean", description: "Run the standard scenarios" },
@@ -572,7 +572,7 @@ export const TOOLS = [
572
572
  {
573
573
  name: "oalo_emit",
574
574
  description:
575
- "Fire a domain event (form.submitted, order.created, whatsapp.inbound, ...) through the real event bus, to test that a loop's trigger and payload filter are wired. Unlike running a loop directly, this goes through the trigger. The loops it fires run for real and can send email or WhatsApp to real contacts, so call with dry_run=true first: that returns the loops that would fire and changes nothing. Event types and their payload fields: oalo_loop_triggers action=catalog. Admins and members with Developer access only. Events are tagged as coming from the CLI and posted to the team feed.",
575
+ "Fire a domain event (form.submitted, order.created, whatsapp.inbound, ...) through the real event bus, to test that a loop's trigger and payload filter are wired. Unlike running a loop directly, this goes through the trigger. The loops it fires run for real, on prod (live) data, and can send email or WhatsApp to real contacts, so call with dry_run=true first: that returns the loops that would fire and changes nothing. Event types and their payload fields: oalo_loop_triggers action=catalog. Admins and members with Developer access only. Events are tagged as coming from the CLI and posted to the team feed.",
576
576
  inputSchema: S(
577
577
  {
578
578
  type: { type: "string", description: "Event type, e.g. form.submitted" },
@@ -603,8 +603,8 @@ export const TOOLS = [
603
603
  {
604
604
  name: "oalo_list_models",
605
605
  description:
606
- "The workspace's data models (tables): fields and types, whether rows are shared or owned per app user (owner_field). Call this before reading or writing rows, and before creating a model, to reuse one that exists. Every workspace has two schemas with the same models: dev (a sandbox) and prod (what live apps read).",
607
- inputSchema: S({ env: { type: "string", enum: ["dev", "prod"], description: "Which schema (default dev). Models are the same in both." } }),
606
+ "The workspace's data models (tables): fields and types, whether rows are shared or owned per app user (owner_field). Call this before reading or writing rows, and before creating a model, to reuse one that exists. Every workspace has two schemas with the same models: dev (staging, a sandbox; draft bots read it) and prod (live: live apps and published bots read it).",
607
+ inputSchema: S({ env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live). Models are the same in both." } }),
608
608
  run: async (_oalo, { env }, ctx) => listModels(readSide(ctx, env)),
609
609
  },
610
610
  {
@@ -634,12 +634,12 @@ export const TOOLS = [
634
634
  {
635
635
  name: "oalo_read_rows",
636
636
  description:
637
- "Read rows from a model. With id: one row. Otherwise a page in write order: pass since=<next_since> from the previous page to continue while has_more is true. Each row is {id, document, owner_id, availability, product_id, seqnum, ...}; the fields are in document. Read-only.",
637
+ "Read rows from an Oalo model (a table an app made itself isn't one: use oalo_db_query). With id: one row. Otherwise a page in write order: pass since=<next_since> from the previous page to continue while has_more is true. Each row is {id, document, owner_id, availability, product_id, seqnum, ...}; the fields are in document. Pass env: the project's env is not read, and the default is dev. Read-only.",
638
638
  inputSchema: S(
639
639
  {
640
640
  table: { type: "string" },
641
641
  id: { type: "string", description: "One row by id" },
642
- env: { type: "string", enum: ["dev", "prod"], description: "Which schema (default dev)" },
642
+ env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live). A draft bot's data is in dev, a published bot's in prod." },
643
643
  since: { type: "integer", description: "Continue after this seqnum (next_since of the previous page)" },
644
644
  limit: { type: "integer", description: "Rows per page (default 500, max 5000)" },
645
645
  },
@@ -650,6 +650,30 @@ export const TOOLS = [
650
650
  return id ? getRow(c, table, id) : listRows(c, table, { since, limit });
651
651
  },
652
652
  },
653
+ {
654
+ name: "oalo_db_query",
655
+ description:
656
+ "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 only. Rows can hold customers' details: never repeat those. Read-only.",
657
+ inputSchema: S(
658
+ {
659
+ sql: { type: "string", description: "One statement" },
660
+ env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live)" },
661
+ limit: { type: "integer", description: "Rows, default 100, at most 1000" },
662
+ },
663
+ ["sql"],
664
+ ),
665
+ run: async (_oalo, { sql, env, limit }, ctx) => {
666
+ const res = await fetch(`${String(ctx.url).replace(/\/$/, "")}/api/cli/v1/db/query`, {
667
+ method: "POST",
668
+ headers: { authorization: `Bearer ${ctx.token}`, "content-type": "application/json" },
669
+ body: JSON.stringify({ sql, env: env === "prod" ? "prod" : "dev", ...(limit ? { limit } : {}) }),
670
+ });
671
+ const body = await res.json().catch(() => ({}));
672
+ if (res.status === 404) throw new Error("this workspace doesn't have db queries yet (it comes with a newer Base)");
673
+ if (!res.ok) throw new Error(body?.error?.message || `the query was refused (HTTP ${res.status})`);
674
+ return body;
675
+ },
676
+ },
653
677
  {
654
678
  name: "oalo_query_metrics",
655
679
  description:
@@ -657,7 +681,7 @@ export const TOOLS = [
657
681
  inputSchema: S({
658
682
  source: { type: "string", enum: ["model", "event", "contact"], description: "Default model (give table)." },
659
683
  table: { type: "string" },
660
- env: { type: "string", enum: ["prod", "dev"], description: "A model's live (default) or dev data." },
684
+ env: { type: "string", enum: ["prod", "dev"], description: "A model's rows: prod (live, the default) or dev (staging: what tests and draft bots wrote). Events and contacts have one copy." },
661
685
  event: { type: "string", description: "An event type such as order.created; leave it out for every type." },
662
686
  measure: { type: "string", enum: ["count", "sum", "avg", "min", "max", "distinct"], description: "Default count. sum, avg, min and max read field as a number." },
663
687
  field: { type: "string" },
@@ -679,7 +703,7 @@ export const TOOLS = [
679
703
  {
680
704
  name: "oalo_save_dashboard_widget",
681
705
  description:
682
- "Put a chart on a dashboard so it stays and updates by itself: the way to answer \"add a chart\", \"track X\" or \"put Y on the dashboard\". Adds the widget, or replaces the one with the same title; the dashboard is made when none has that name (app attaches a new one to an app). The query runs first: one that fails is refused with the reason, a saved one returns its numbers. kind: number (compare adds the window before), line (query.every), bars (query.by), table, funnel (query.steps: event types in order, and days). MUTATES what everyone with access sees; say which dashboard you used.",
706
+ "Put a chart on a dashboard so it stays and updates by itself: the way to answer \"add a chart\", \"track X\" or \"put Y on the dashboard\". Adds the widget, or replaces the one with the same title; the dashboard is made when none has that name (app attaches a new one to an app). The query runs first: one that fails is refused with the reason, a saved one returns its numbers. kind: number (compare adds the window before), line (query.every), bars (query.by), table, funnel (query.steps: event types in order, and days). A chart over a model reads prod (live) unless query.env is \"dev\". MUTATES what everyone with access sees; say which dashboard you used.",
683
707
  inputSchema: S(
684
708
  {
685
709
  dashboard: { type: "string", description: "The dashboard's name. Default Overview." },
@@ -699,11 +723,11 @@ export const TOOLS = [
699
723
  {
700
724
  name: "oalo_write_rows",
701
725
  description:
702
- "Upsert and/or soft-delete rows in a model. Upserts match by id: pass each row with an id (from id_field) so sending it again updates it instead of adding a copy. Fields go flat in the row ({\"id\":\"42\",\"total\":9.5}) or as {id, document:{...}}. Any number of rows; they are sent 1,000 at a time and the rate limit is waited out. Writes sync to every app on that schema at once. env is required: write to dev, check with oalo_read_rows, then oalo_promote_model copies dev to prod. Writing to prod needs confirm=true because live apps see it immediately. The first write to a table creates a write token limited to it, as the person. MUTATES data.",
726
+ "Upsert and/or soft-delete rows in a model. Upserts match by id: pass each row with an id (from id_field) so sending it again updates it instead of adding a copy. Fields go flat in the row ({\"id\":\"42\",\"total\":9.5}) or as {id, document:{...}}. Any number of rows; they are sent 1,000 at a time and the rate limit is waited out. Writes sync to every app on that schema at once. env is required: write to dev, check with oalo_read_rows, then oalo_promote_model copies dev to prod. Writing to prod needs confirm=true because live apps and published bots see it immediately. A draft bot reads dev. The first write to a table creates a write token limited to it, as the person. MUTATES data.",
703
727
  inputSchema: S(
704
728
  {
705
729
  table: { type: "string" },
706
- env: { type: "string", enum: ["dev", "prod"] },
730
+ env: { type: "string", enum: ["dev", "prod"], description: "Required, no default: dev (staging) or prod (live)" },
707
731
  upsert: { type: "array", items: { type: "object" }, description: "Rows to create or update" },
708
732
  id_field: { type: "string", description: "Which field holds each row's id (default id)" },
709
733
  delete: { type: "array", items: { type: "string" }, description: "Ids to soft-delete (they leave synced apps)" },
@@ -747,7 +771,7 @@ export const TOOLS = [
747
771
  {
748
772
  name: "oalo_call",
749
773
  description:
750
- "Escape hatch: call any BuilderChannel event directly. The curated tools above cover normal work; use this only for something they do not reach. To find an event and its params, call event 'cli_api:events' with params {\"q\": \"<text>\"}: it lists the events you may call and the param shapes each accepts. May mutate, so check the event name before calling.",
774
+ "Escape hatch: call any BuilderChannel event directly. The curated tools above cover normal work; use this only for something they do not reach. To find an event and its params, call event 'cli_api:events' with params {\"q\": \"<text>\"}: it lists the events you may call and the param shapes each accepts. An event that takes \"env\" gets only what you pass: booking:* and metrics:query default to prod, so set up a draft bot's booking types and hours with \"env\": \"dev\". May mutate, so check the event name before calling.",
751
775
  inputSchema: S(
752
776
  {
753
777
  event: { type: "string", description: "Channel event name" },
@@ -763,8 +787,9 @@ export const BY_NAME = Object.fromEntries(TOOLS.map((t) => [t.name, t]));
763
787
 
764
788
  /** The read side for data tools: the saved data token, on one schema. */
765
789
  function readSide(ctx, env = "dev") {
766
- // The project may name no workspace; then the channel connected to the most
767
- // recently saved one, and its data token is the one to use.
790
+ // The project may name no workspace; then the channel connected to the one
791
+ // saved workspace (several saved and none named is refused), and its data
792
+ // token is the one to use.
768
793
  const token = ctx?.cfg?.token || (ctx?.url && readToken({ serverUrl: ctx.url, appId: null }, "sync"));
769
794
  if (!token) {
770
795
  throw new Error("no data token saved for this workspace. Ask the person to run `oalo login --server <workspace url>`.");
package/src/workspace.js CHANGED
@@ -5,9 +5,10 @@ import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "./config
5
5
  * Open the build-surface channel with the linked CLI token (control plane).
6
6
  * Falls back to the most recently linked workspace when this project has none,
7
7
  * like `oalo run`. Returns null after printing how to link when there is no
8
- * token, so commands can exit 2 without a stack trace.
8
+ * token, so commands can exit 2 without a stack trace. `channel` makes the
9
+ * channel (tests pass a stub).
9
10
  */
10
- export async function openWorkspace(flags, command) {
11
+ export async function openWorkspace(flags, command, { channel = (o) => new OaloChannel(o) } = {}) {
11
12
  const cfg = resolveConfig(flags);
12
13
  const { url, token } = controlPlane(cfg);
13
14
 
@@ -18,7 +19,7 @@ export async function openWorkspace(flags, command) {
18
19
  return null;
19
20
  }
20
21
 
21
- const ch = new OaloChannel({ url, token });
22
+ const ch = channel({ url, token });
22
23
  await ch.connect();
23
24
  return { ch, url, env: cfg.env };
24
25
  }