@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/man/oalo.1 +115 -19
- package/package.json +1 -1
- package/plugin/skills/oalo/SKILL.md +34 -8
- package/src/commands/bots.js +3 -1
- package/src/commands/call.js +66 -16
- package/src/commands/data.js +1 -1
- package/src/commands/db.js +62 -1
- package/src/commands/graphs.js +39 -10
- package/src/commands/mcp.js +1 -1
- package/src/commands/switches.js +45 -10
- package/src/coord-release.json +9 -9
- package/src/data.js +11 -3
- package/src/graphfiles.js +60 -3
- package/src/help.js +79 -20
- package/src/mcp/tools.js +43 -18
- package/src/workspace.js +4 -3
package/man/oalo.1
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.TH OALO 1 "" "oalo 0.4.
|
|
1
|
+
.TH OALO 1 "" "oalo 0.4.3" "OALO CLI"
|
|
2
2
|
.SH NAME
|
|
3
3
|
oalo \- wire a local app into your Oalo workspace
|
|
4
4
|
.SH SYNOPSIS
|
|
@@ -7,6 +7,21 @@ oalo \- wire a local app into your Oalo workspace
|
|
|
7
7
|
[\fIargs\fR] [\fIflags\fR]
|
|
8
8
|
.SH DESCRIPTION
|
|
9
9
|
The OALO command line: link a local app to an OALO workspace, deploy it, read and write its data, make tables searchable by bots, change bot settings, and run workflows. \fBoalo help <command>\fR prints the same detail as this page for one command; \fBoalo help \-\-json\fR prints all of it for a program or an agent to read.
|
|
10
|
+
.SH DEV AND PROD
|
|
11
|
+
.IP \(bu 2
|
|
12
|
+
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.
|
|
13
|
+
.IP \(bu 2
|
|
14
|
+
The project's default env is \fBenv\fR in .oalo/config.json, set by \fBoalo link \-\-env dev|prod\fR (default dev; \fBoalo deploy \-\-new\fR sets dev). data, db query, db tables, deploy, env, logs, run loop and typegen follow it; \-\-env on the command line wins.
|
|
15
|
+
.IP \(bu 2
|
|
16
|
+
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.
|
|
17
|
+
.IP \(bu 2
|
|
18
|
+
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.
|
|
19
|
+
.IP \(bu 2
|
|
20
|
+
\fBoalo data promote <table>\fR 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).
|
|
21
|
+
.IP \(bu 2
|
|
22
|
+
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.
|
|
23
|
+
.IP \(bu 2
|
|
24
|
+
When it matters, pass \-\-env (MCP and \fBoalo call\fR: "env") every time instead of relying on a default.
|
|
10
25
|
.SH COMMANDS
|
|
11
26
|
.SS login
|
|
12
27
|
Connect this machine to a workspace by approving it in the browser.
|
|
@@ -61,6 +76,8 @@ Exit codes: 0 connected and both checks passed; 1 a token failed, or the workspa
|
|
|
61
76
|
.SS link
|
|
62
77
|
Point this project at a workspace and save credentials.
|
|
63
78
|
.PP
|
|
79
|
+
\fBEnv:\fR Sets the project's default env, \fBenv\fR 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.
|
|
80
|
+
.PP
|
|
64
81
|
\fBoalo link \-\-server <url> [\-\-token <sync token>] [\-\-cli\-token <token>] [\-\-app <slug>] [\-\-env dev|prod] [\-\-no\-skill]\fR
|
|
65
82
|
.br
|
|
66
83
|
\fBoalo link \-\-status\fR
|
|
@@ -79,7 +96,7 @@ CLI token (control plane), for tail and mcp. Optional.
|
|
|
79
96
|
The app that deploy, env, logs, secrets and dockerfile use when you don't pass \-\-app (\fBoalo apps\fR lists them). \fBoalo deploy \-\-new\fR sets it.
|
|
80
97
|
.TP
|
|
81
98
|
\fB\-\-env dev|prod\fR
|
|
82
|
-
|
|
99
|
+
The project's default env for the commands that read it. Default dev.
|
|
83
100
|
.TP
|
|
84
101
|
\fB\-\-status\fR
|
|
85
102
|
Show the current link and re\-check reachability.
|
|
@@ -97,11 +114,16 @@ Exit codes: 0 linked; 1 verification failed; 2 missing or invalid arguments.
|
|
|
97
114
|
.SS typegen
|
|
98
115
|
Generate TypeScript bindings from the workspace's own schema: its models, and the workflows apps can call.
|
|
99
116
|
.PP
|
|
100
|
-
\fBoalo
|
|
117
|
+
\fBEnv:\fR \-\-env dev|prod, else the project's env (\fBoalo link \-\-env\fR), else dev. It is stamped in the file's header, and \-\-dart writes it into .oalo/dart\-defines.json as OALO_ENV.
|
|
118
|
+
.PP
|
|
119
|
+
\fBoalo typegen [\-\-out <file>] [\-\-check] [\-\-env dev|prod]\fR
|
|
101
120
|
.br
|
|
102
|
-
\fBoalo typegen \-\-dart [\-\-out <project dir>] [\-\-check]\fR
|
|
121
|
+
\fBoalo typegen \-\-dart [\-\-out <project dir>] [\-\-check] [\-\-env dev|prod]\fR
|
|
103
122
|
.br
|
|
104
123
|
.TP
|
|
124
|
+
\fB\-\-env dev|prod\fR
|
|
125
|
+
Which env to read. Default: the project's, else dev.
|
|
126
|
+
.TP
|
|
105
127
|
\fB\-\-out <file>\fR
|
|
106
128
|
Output path. Default oalo.generated.ts. With \-\-dart, the Flutter project's root (default the current folder).
|
|
107
129
|
.TP
|
|
@@ -155,7 +177,9 @@ Exit codes: 0 stopped cleanly; 1 could not connect; 2 no CLI token.
|
|
|
155
177
|
.SS call
|
|
156
178
|
Call any build\-surface event directly. The escape hatch.
|
|
157
179
|
.PP
|
|
158
|
-
\
|
|
180
|
+
\fBEnv:\fR 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".
|
|
181
|
+
.PP
|
|
182
|
+
\fBoalo call <event> ['<json params>' | @file.json | \-]\fR
|
|
159
183
|
.br
|
|
160
184
|
\fBoalo call \-\-list [text] [\-\-json]\fR
|
|
161
185
|
.br
|
|
@@ -173,18 +197,24 @@ The build surface has ~500 events. First\-class commands cover the common ones;
|
|
|
173
197
|
.IP \(bu 2
|
|
174
198
|
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.
|
|
175
199
|
.IP \(bu 2
|
|
200
|
+
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.
|
|
201
|
+
.IP \(bu 2
|
|
176
202
|
\-\-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.
|
|
177
203
|
.IP \(bu 2
|
|
178
204
|
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.
|
|
179
205
|
.IP \(bu 2
|
|
180
206
|
Example: oalo call loops:run_now '{"name":"Nurture"}'
|
|
181
207
|
.IP \(bu 2
|
|
208
|
+
From a file: oalo call loops:get @params.json. From stdin: jq \-n '{name: "Nurture"}' | oalo call loops:get
|
|
209
|
+
.IP \(bu 2
|
|
182
210
|
Needs a CLI token.
|
|
183
211
|
.PP
|
|
184
212
|
Exit codes: 0 the call succeeded; 1 the call failed or was rejected; 2 bad arguments or no token.
|
|
185
213
|
.SS run
|
|
186
214
|
Fire a loop, or send a bot a test message, and watch what happens.
|
|
187
215
|
.PP
|
|
216
|
+
\fBEnv:\fR 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.
|
|
217
|
+
.PP
|
|
188
218
|
\fBoalo run loop <name> [\-\-env dev|prod] [\-\-watch]\fR
|
|
189
219
|
.br
|
|
190
220
|
\fBoalo run bot <id> "<message>"\fR
|
|
@@ -197,7 +227,7 @@ Stream events after firing. Default on for bots.
|
|
|
197
227
|
How long to watch. Default 30.
|
|
198
228
|
.TP
|
|
199
229
|
\fB\-\-env dev|prod\fR
|
|
200
|
-
|
|
230
|
+
loop: which env's data it runs on. Default: the project's, else dev.
|
|
201
231
|
.TP
|
|
202
232
|
\fB\-\-app <slug>\fR
|
|
203
233
|
Only for a loop pinned to one app: that app's slug (\fBoalo apps\fR) or id. Loops are org\-wide by default.
|
|
@@ -212,6 +242,8 @@ Exit codes: 0 ran, or watch window elapsed; 1 the run failed to start; 2 bad arg
|
|
|
212
242
|
.SS emit
|
|
213
243
|
Fire a domain event (form.submitted, order.created, ...) to test a loop's trigger.
|
|
214
244
|
.PP
|
|
245
|
+
\fBEnv:\fR 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 \fBoalo loops test\fR.
|
|
246
|
+
.PP
|
|
215
247
|
\fBoalo emit <event type> [\-\-payload '<json>'] [\-\-contact <id>] [\-\-dry\-run] [\-\-json]\fR
|
|
216
248
|
.br
|
|
217
249
|
\fBoalo emit \-\-list [\-\-json]\fR
|
|
@@ -244,6 +276,8 @@ Exit codes: 0 emitted (or dry run done); 1 refused or failed; 2 bad arguments or
|
|
|
244
276
|
.SS data
|
|
245
277
|
Models and rows in this workspace: list, read, push (bulk upsert), delete, watch, promote, and make tables searchable by bots.
|
|
246
278
|
.PP
|
|
279
|
+
\fBEnv:\fR \-\-env dev|prod, else the project's env (\fBoalo link \-\-env\fR), 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.
|
|
280
|
+
.PP
|
|
247
281
|
\fBoalo data models [\-\-json]\fR
|
|
248
282
|
.br
|
|
249
283
|
\fBoalo data models create <name> \-\-field name:type [\-\-field ...] [\-\-owned\-by <field>]\fR
|
|
@@ -328,10 +362,12 @@ events, vectorize: turn it off. keep\-from\-ai: take the named fields off the li
|
|
|
328
362
|
\fB\-\-json\fR
|
|
329
363
|
Print the reply as JSON.
|
|
330
364
|
.IP \(bu 2
|
|
331
|
-
dev is a sandbox; live apps read prod. Push to dev, check it, then \fBoalo data promote <table>\fR copies dev rows to prod.
|
|
365
|
+
dev is a sandbox; live apps and published bots read prod, draft bots read dev. Push to dev, check it, then \fBoalo data promote <table>\fR copies dev rows to prod.
|
|
332
366
|
.IP \(bu 2
|
|
333
367
|
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 (\fBoalo tokens list\fR shows it; it expires in 30 days).
|
|
334
368
|
.IP \(bu 2
|
|
369
|
+
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.
|
|
370
|
+
.IP \(bu 2
|
|
335
371
|
models create and promote run as you over the CLI token, so they follow your dashboard access.
|
|
336
372
|
.IP \(bu 2
|
|
337
373
|
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.
|
|
@@ -350,6 +386,8 @@ Exit codes: 0 done; 1 failed, or some rows were rejected; 2 bad arguments or no
|
|
|
350
386
|
.SS incidents
|
|
351
387
|
A live app's outages and restart bursts, as Oalo's uptime check saw them, newest first.
|
|
352
388
|
.PP
|
|
389
|
+
\fBEnv:\fR prod (the live app) only. The preview isn't checked; \fBoalo logs\fR shows it.
|
|
390
|
+
.PP
|
|
353
391
|
\fBoalo incidents [\-\-app <slug>] [\-\-all] [\-\-json]\fR
|
|
354
392
|
.br
|
|
355
393
|
.TP
|
|
@@ -368,8 +406,14 @@ Each one says what was seen: which process, how many restarts, a memory kill wit
|
|
|
368
406
|
.PP
|
|
369
407
|
Exit codes: 0 no open incident; 1 an incident is open, or the request failed; 2 bad arguments or no CLI token.
|
|
370
408
|
.SS db
|
|
371
|
-
|
|
409
|
+
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.
|
|
410
|
+
.PP
|
|
411
|
+
\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.
|
|
372
412
|
.PP
|
|
413
|
+
\fBoalo db query "<sql>" [\-\-env dev|prod] [\-\-limit <n>] [\-\-json]\fR
|
|
414
|
+
.br
|
|
415
|
+
\fBoalo db tables [\-\-env dev|prod]\fR
|
|
416
|
+
.br
|
|
373
417
|
\fBoalo db dump [\-\-env dev|prod] [\-\-out <file.sql>] [\-\-force]\fR
|
|
374
418
|
.br
|
|
375
419
|
\fBoalo db restore <file> \-\-env dev|prod [\-\-schema <name>] [\-\-check] [\-\-yes]\fR
|
|
@@ -378,7 +422,13 @@ All of an env's data as plain SQL (every app's own tables and the Oalo models),
|
|
|
378
422
|
.br
|
|
379
423
|
.TP
|
|
380
424
|
\fB\-\-env dev|prod\fR
|
|
381
|
-
dump: which env's data. Default prod. restore: which env the data goes into, always on the command line.
|
|
425
|
+
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.
|
|
426
|
+
.TP
|
|
427
|
+
\fB\-\-limit <n>\fR
|
|
428
|
+
query: rows to show. Default 100, at most 1000.
|
|
429
|
+
.TP
|
|
430
|
+
\fB\-\-json\fR
|
|
431
|
+
query: {columns, rows, truncated} as JSON.
|
|
382
432
|
.TP
|
|
383
433
|
\fB\-\-out <file.sql>\fR
|
|
384
434
|
Where to write it. Default <workspace>\-<env>\-<date>.sql here.
|
|
@@ -398,6 +448,8 @@ restore: do everything but the write, and report what would happen. Nothing is w
|
|
|
398
448
|
\fB\-\-yes\fR
|
|
399
449
|
restore: go ahead with prod without asking. Needed for prod when there's no terminal to ask at.
|
|
400
450
|
.IP \(bu 2
|
|
451
|
+
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.
|
|
452
|
+
.IP \(bu 2
|
|
401
453
|
Workspace admins only: it holds every member's data. Restore it into any Postgres with psql \-f.
|
|
402
454
|
.IP \(bu 2
|
|
403
455
|
Your code is in git (oalo deploy \-\-pull); this is the data. Together they are everything you need to run your apps elsewhere.
|
|
@@ -416,6 +468,8 @@ Exit codes: 0 a whole dump was written, or the restore (or check) passed; 1 refu
|
|
|
416
468
|
.SS metrics
|
|
417
469
|
A number from the workspace's data: count, sum or average over a model's rows, events or contacts, grouped or over time.
|
|
418
470
|
.PP
|
|
471
|
+
\fBEnv:\fR 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.
|
|
472
|
+
.PP
|
|
419
473
|
\fBoalo metrics <model | events | contacts> [\-\-sum|\-\-avg|\-\-min|\-\-max|\-\-distinct <field>] [\-\-by <field>] [\-\-every day|week|month] [\-\-days N] [\-\-where <filter>] [\-\-json]\fR
|
|
420
474
|
.br
|
|
421
475
|
.TP
|
|
@@ -456,7 +510,7 @@ A model row counts at when it was created (default), last changed, or one of its
|
|
|
456
510
|
Also the same over the window before (needs \-\-days).
|
|
457
511
|
.TP
|
|
458
512
|
\fB\-\-env dev|prod\fR
|
|
459
|
-
A model's live (default) or dev data.
|
|
513
|
+
A model's live (prod, the default) or dev data. To count rows a test or a draft bot wrote, pass \-\-env dev.
|
|
460
514
|
.TP
|
|
461
515
|
\fB\-\-json\fR
|
|
462
516
|
The answer as JSON.
|
|
@@ -469,6 +523,8 @@ Exit codes: 0 done; 1 the query failed; 2 bad arguments or no CLI token.
|
|
|
469
523
|
.SS dashboards
|
|
470
524
|
The workspace's dashboards, and a chart put on one (made when no dashboard has that name).
|
|
471
525
|
.PP
|
|
526
|
+
\fBEnv:\fR 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.
|
|
527
|
+
.PP
|
|
472
528
|
\fBoalo dashboards [\-\-json]\fR
|
|
473
529
|
.br
|
|
474
530
|
\fBoalo dashboards add <dashboard> <model | events | contacts> \-\-title "<title>" \-\-kind number|line|bars|table [metrics flags] [\-\-app <slug>] [\-\-width 1|2|3]\fR
|
|
@@ -496,12 +552,14 @@ The answer as JSON.
|
|
|
496
552
|
.IP \(bu 2
|
|
497
553
|
add runs the query first and refuses one that can't draw, then prints its numbers. It changes what everyone with access sees.
|
|
498
554
|
.IP \(bu 2
|
|
499
|
-
The flags after the model are the same as oalo metrics.
|
|
555
|
+
The flags after the model are the same as oalo metrics, \-\-env included.
|
|
500
556
|
.PP
|
|
501
557
|
Exit codes: 0 done; 1 the request failed; 2 bad arguments or no CLI token.
|
|
502
558
|
.SS products
|
|
503
559
|
What the workspace sells (Oalo commerce on its own Stripe account): list, create, rename, change a price, archive, and see orders.
|
|
504
560
|
.PP
|
|
561
|
+
\fBEnv:\fR Not dev or prod: a product is on your Stripe test key, or on the live key with \-\-live. \-\-env does nothing here.
|
|
562
|
+
.PP
|
|
505
563
|
\fBoalo products [\-\-all] [\-\-json]\fR
|
|
506
564
|
.br
|
|
507
565
|
\fBoalo products create <id> \-\-name "<name>" \-\-price <amount> \-\-once|\-\-monthly|\-\-yearly [\-\-trial <days>] [\-\-currency <code>] [\-\-description <text>] [\-\-live] [\-\-yes]\fR
|
|
@@ -682,6 +740,8 @@ Exit codes: 0 started, or (status, \-\-wait) built; 1 refused, the build failed,
|
|
|
682
740
|
.SS sources
|
|
683
741
|
Feeds that send Oalo rows from outside (another system, a webhook, an export), keeping only the fields you choose.
|
|
684
742
|
.PP
|
|
743
|
+
\fBEnv:\fR 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.
|
|
744
|
+
.PP
|
|
685
745
|
\fBoalo sources [list] [\-\-json]\fR
|
|
686
746
|
.br
|
|
687
747
|
\fBoalo sources create <name> \-\-from <sample.csv|.json|.jsonl> [\-\-table <new model>] [\-\-id\-field <field>] [\-\-mode upsert|snapshot] [\-\-auth bearer|hmac|url] [\-\-env dev|prod]\fR
|
|
@@ -748,7 +808,7 @@ create: each upload is the whole set, and rows it leaves out are deleted. Only f
|
|
|
748
808
|
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.
|
|
749
809
|
.TP
|
|
750
810
|
\fB\-\-env dev|prod\fR
|
|
751
|
-
create: which copy of the
|
|
811
|
+
create: which env's copy of the table the rows go to. Default prod, whatever the project's env is.
|
|
752
812
|
.TP
|
|
753
813
|
\fB\-\-every <minutes>\fR
|
|
754
814
|
fetch: how often Oalo fetches the address, 5 to 10080 minutes. Default 60.
|
|
@@ -803,6 +863,8 @@ Exit codes: 0 done; 1 refused, failed, or some records were rejected; 2 bad argu
|
|
|
803
863
|
.SS bots
|
|
804
864
|
The workspace's bots: the tables each can search, and every setting (knowledge, memory, model, replies, limits).
|
|
805
865
|
.PP
|
|
866
|
+
\fBEnv:\fR No \-\-env. A bot's status (shown by \fBoalo bots\fR) 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.
|
|
867
|
+
.PP
|
|
806
868
|
\fBoalo bots [\-\-json]\fR
|
|
807
869
|
.br
|
|
808
870
|
\fBoalo bots knowledge <bot> [\-\-json]\fR
|
|
@@ -856,6 +918,8 @@ Exit codes: 0 done; 1 refused or failed; 2 bad arguments or no CLI token.
|
|
|
856
918
|
.SS tokens
|
|
857
919
|
List, create and revoke the workspace's sync tokens, for an app's own server.
|
|
858
920
|
.PP
|
|
921
|
+
\fBEnv:\fR 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.
|
|
922
|
+
.PP
|
|
859
923
|
\fBoalo tokens list [\-\-json]\fR
|
|
860
924
|
.br
|
|
861
925
|
\fBoalo tokens create \-\-name <name> \-\-scope write:<table> [\-\-scope ...] [\-\-days N] [\-\-json]\fR
|
|
@@ -918,6 +982,8 @@ Exit codes: 0 done; 1 the workspace failed; 2 no CLI token.
|
|
|
918
982
|
.SS deploy
|
|
919
983
|
Send this repo's commits to an app and run them: the preview (dev) by default, the live release with \-\-env prod.
|
|
920
984
|
.PP
|
|
985
|
+
\fBEnv:\fR \-\-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.
|
|
986
|
+
.PP
|
|
921
987
|
\fBoalo deploy [\-\-app <slug>] [\-\-env dev|prod] [\-\-allow\-dirty] [\-\-json]\fR
|
|
922
988
|
.br
|
|
923
989
|
\fBoalo deploy \-\-new [<name>] [\-\-name "Display name"]\fR
|
|
@@ -990,6 +1056,8 @@ Exit codes: 0 deployed; 1 refused or failed; 2 bad arguments, no CLI token, or n
|
|
|
990
1056
|
.SS migrate
|
|
991
1057
|
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.
|
|
992
1058
|
.PP
|
|
1059
|
+
\fBEnv:\fR \-\-apply sets the variables on prod (the live app) only, whatever the project's env is. Set the preview's with \fBoalo env set ... \-\-env dev\fR.
|
|
1060
|
+
.PP
|
|
993
1061
|
\fBoalo migrate <heroku|railway|render|fly|primcloud> [\-\-from\-app <name>] [\-\-env\-file <file>] [\-\-json]\fR
|
|
994
1062
|
.br
|
|
995
1063
|
\fBoalo migrate <platform> \-\-apply [\-\-app <slug>]\fR
|
|
@@ -1025,6 +1093,8 @@ Exit codes: 0 the plan was shown, or applied; 1 a config file couldn't be read,
|
|
|
1025
1093
|
.SS env
|
|
1026
1094
|
An app's environment variables on Oalo (API keys, settings), per env: list, set, unset, rotate\-token.
|
|
1027
1095
|
.PP
|
|
1096
|
+
\fBEnv:\fR \-\-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.
|
|
1097
|
+
.PP
|
|
1028
1098
|
\fBoalo env [\-\-app <slug>] [\-\-env dev|prod] [\-\-json]\fR
|
|
1029
1099
|
.br
|
|
1030
1100
|
\fBoalo env set NAME=value [NAME=value ...] [\-\-secret | \-\-public] [\-\-no\-restart]\fR
|
|
@@ -1121,6 +1191,8 @@ Exit codes: 0 done; 1 refused or failed; 2 bad arguments or no CLI token.
|
|
|
1121
1191
|
.SS logs
|
|
1122
1192
|
What an app's own processes printed (server, workers, release command), per env.
|
|
1123
1193
|
.PP
|
|
1194
|
+
\fBEnv:\fR \-\-env dev (the preview) or prod (the live app), else the project's env, else dev.
|
|
1195
|
+
.PP
|
|
1124
1196
|
\fBoalo logs [\-\-app <slug>] [\-\-env dev|prod] [\-\-process web|<worker>] [\-\-limit N] [\-\-follow] [\-\-json]\fR
|
|
1125
1197
|
.br
|
|
1126
1198
|
.TP
|
|
@@ -1128,7 +1200,7 @@ What an app's own processes printed (server, workers, release command), per env.
|
|
|
1128
1200
|
The app (\fBoalo apps\fR lists them). Default: the app saved with \fBoalo link \-\-app\fR.
|
|
1129
1201
|
.TP
|
|
1130
1202
|
\fB\-\-env dev|prod\fR
|
|
1131
|
-
dev is the preview, prod the live app. Default dev.
|
|
1203
|
+
dev is the preview, prod the live app. Default: the project's, else dev.
|
|
1132
1204
|
.TP
|
|
1133
1205
|
\fB\-\-process <name>\fR
|
|
1134
1206
|
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).
|
|
@@ -1150,8 +1222,12 @@ Admins and members with Developer access only: an app can print secrets or custo
|
|
|
1150
1222
|
.PP
|
|
1151
1223
|
Exit codes: 0 done; 1 refused or failed; 2 bad arguments or no CLI token.
|
|
1152
1224
|
.SS loops
|
|
1153
|
-
|
|
1225
|
+
List the loops, test one (sends simulated), see its past runs, turn it on or off, or delete it, without pulling and pushing it.
|
|
1154
1226
|
.PP
|
|
1227
|
+
\fBEnv:\fR 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.
|
|
1228
|
+
.PP
|
|
1229
|
+
\fBoalo loops list [\-\-json]\fR
|
|
1230
|
+
.br
|
|
1155
1231
|
\fBoalo loops test <name> [\-\-sample latest|example] [\-\-input <json|@file.json>] [\-\-json]\fR
|
|
1156
1232
|
.br
|
|
1157
1233
|
\fBoalo loops on <name>\fR
|
|
@@ -1169,7 +1245,7 @@ Test a loop (sends simulated), see its past runs, turn it on or off, or delete i
|
|
|
1169
1245
|
Test with the loop's most recent real event, or one built from its trigger's fields.
|
|
1170
1246
|
.TP
|
|
1171
1247
|
\fB\-\-input <json|@file>\fR
|
|
1172
|
-
Test with this input instead: an event envelope {type, contact_id, payload}, or what a scheduled loop's first step reads.
|
|
1248
|
+
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.
|
|
1173
1249
|
.TP
|
|
1174
1250
|
\fB\-\-app <slug>\fR
|
|
1175
1251
|
Only for a loop pinned to one app: that app's slug (\fBoalo apps\fR) or id. Works with test, runs, on, off and delete.
|
|
@@ -1193,6 +1269,8 @@ Exit codes: 0 done (a test passed); 1 refused, failed, or the test run failed; 2
|
|
|
1193
1269
|
.SS flows
|
|
1194
1270
|
Turn a chat flow on or off, or delete it, by bot and flow name, without pulling and pushing it.
|
|
1195
1271
|
.PP
|
|
1272
|
+
\fBEnv:\fR No env: a flow has one copy. Its steps use the bot's env, dev while the bot is a draft, prod once published.
|
|
1273
|
+
.PP
|
|
1196
1274
|
\fBoalo flows on <bot> <flow>\fR
|
|
1197
1275
|
.br
|
|
1198
1276
|
\fBoalo flows off <bot> <flow>\fR
|
|
@@ -1210,7 +1288,7 @@ Exit codes: 0 done; 1 refused or failed; 2 bad arguments or no CLI token.
|
|
|
1210
1288
|
.SS pull
|
|
1211
1289
|
Fetch chat flows, loops and code tools into .oalo/ as files you can edit.
|
|
1212
1290
|
.PP
|
|
1213
|
-
\fBoalo pull [flows|loops|tools] [\-\-bot <id>] [\-\-name <name>] [\-\-force]\fR
|
|
1291
|
+
\fBoalo pull [flows|loops|tools|catalog] [\-\-bot <id>] [\-\-name <name>] [\-\-force]\fR
|
|
1214
1292
|
.br
|
|
1215
1293
|
.TP
|
|
1216
1294
|
\fB\-\-bot <id>\fR
|
|
@@ -1232,6 +1310,8 @@ Each file holds the editable object (\fBflow\fR or \fBloop\fR) plus the CLI's bo
|
|
|
1232
1310
|
.IP \(bu 2
|
|
1233
1311
|
A file you have edited is kept, not overwritten, unless you pass \-\-force.
|
|
1234
1312
|
.IP \(bu 2
|
|
1313
|
+
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. \fBoalo pull catalog\fR writes only the node catalogs.
|
|
1314
|
+
.IP \(bu 2
|
|
1235
1315
|
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/.
|
|
1236
1316
|
.IP \(bu 2
|
|
1237
1317
|
Needs a CLI token.
|
|
@@ -1254,25 +1334,31 @@ Exit codes: 0 nothing in conflict; 1 a conflict, an invalid file, or a failed ch
|
|
|
1254
1334
|
.SS lint
|
|
1255
1335
|
Check flow and loop files without saving anything.
|
|
1256
1336
|
.PP
|
|
1257
|
-
\fBoalo lint [<file>...] [\-\-verbose] [\-\-json]\fR
|
|
1337
|
+
\fBoalo lint [<file or folder>...] [\-\-verbose] [\-\-json]\fR
|
|
1258
1338
|
.br
|
|
1259
1339
|
.TP
|
|
1260
1340
|
\fB\-\-verbose\fR
|
|
1261
1341
|
Also show info\-level findings.
|
|
1262
1342
|
.TP
|
|
1263
1343
|
\fB\-\-json\fR
|
|
1264
|
-
One JSON object per file: {path, findings}.
|
|
1344
|
+
One JSON object per file: {path, findings}, plus a note for a tool file.
|
|
1265
1345
|
.IP \(bu 2
|
|
1266
1346
|
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.
|
|
1267
1347
|
.IP \(bu 2
|
|
1268
1348
|
Each finding names the node, what is wrong and how to fix it.
|
|
1269
1349
|
.IP \(bu 2
|
|
1350
|
+
A folder means every flow, loop and tool file inside it, e.g. oalo lint .oalo/loops.
|
|
1351
|
+
.IP \(bu 2
|
|
1352
|
+
A tool file isn't linted: its code is compiled and checked when you push it.
|
|
1353
|
+
.IP \(bu 2
|
|
1270
1354
|
Needs a CLI token.
|
|
1271
1355
|
.PP
|
|
1272
1356
|
Exit codes: 0 no errors (warnings allowed); 1 errors found; 2 no token.
|
|
1273
1357
|
.SS push
|
|
1274
1358
|
Lint and save edited flow, loop and tool files, guarded against concurrent edits.
|
|
1275
1359
|
.PP
|
|
1360
|
+
\fBEnv:\fR 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.
|
|
1361
|
+
.PP
|
|
1276
1362
|
\fBoalo push [<file>...] [\-\-dry\-run] [\-\-no\-strict] [\-\-force] [\-\-all] [\-\-verbose]\fR
|
|
1277
1363
|
.br
|
|
1278
1364
|
.TP
|
|
@@ -1305,6 +1391,8 @@ Exit codes: 0 every file saved; 1 a file was refused, in conflict, or failed; 2
|
|
|
1305
1391
|
.SS qa
|
|
1306
1392
|
Run a scripted test conversation with a bot and print the transcript.
|
|
1307
1393
|
.PP
|
|
1394
|
+
\fBEnv:\fR 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.
|
|
1395
|
+
.PP
|
|
1308
1396
|
\fBoalo qa <bot> "<message>" ["<message>" ...] [\-\-channel web|whatsapp|instagram|sms] [\-\-flow <name>] [\-\-timeout <s>] [\-\-json]\fR
|
|
1309
1397
|
.br
|
|
1310
1398
|
\fBoalo qa <bot> \-\-script <file.json>\fR
|
|
@@ -1330,7 +1418,11 @@ Print the whole run as JSON: turns (replies, flow state, ms, settled), flow_path
|
|
|
1330
1418
|
.IP \(bu 2
|
|
1331
1419
|
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.
|
|
1332
1420
|
.IP \(bu 2
|
|
1333
|
-
Everything else is real: the bot's tools and flows run
|
|
1421
|
+
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.
|
|
1422
|
+
.IP \(bu 2
|
|
1423
|
+
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.
|
|
1424
|
+
.IP \(bu 2
|
|
1425
|
+
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.
|
|
1334
1426
|
.IP \(bu 2
|
|
1335
1427
|
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.
|
|
1336
1428
|
.IP \(bu 2
|
|
@@ -1342,6 +1434,8 @@ Exit codes: 0 every turn settled; 1 a turn timed out or the run failed; 2 bad ar
|
|
|
1342
1434
|
.SS rehearse
|
|
1343
1435
|
Rehearse inbound WhatsApp conversations end to end: routing, triage and the bot's reply.
|
|
1344
1436
|
.PP
|
|
1437
|
+
\fBEnv:\fR No \-\-env. The bot that answers uses its own env: dev while it's a draft, prod once published.
|
|
1438
|
+
.PP
|
|
1345
1439
|
\fBoalo rehearse [\-\-number <phone_number_id>] [\-\-responder <bot_...>] [\-\-timeout <s>] [\-\-json]\fR
|
|
1346
1440
|
.br
|
|
1347
1441
|
\fBoalo rehearse \-\-script <file.json>\fR
|
|
@@ -1397,6 +1491,8 @@ Exit codes: 0 installed or printed.
|
|
|
1397
1491
|
.SS mcp
|
|
1398
1492
|
Serve the workspace over MCP on stdio, for Claude Code or Cursor.
|
|
1399
1493
|
.PP
|
|
1494
|
+
\fBEnv:\fR 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.
|
|
1495
|
+
.PP
|
|
1400
1496
|
\fBoalo mcp\fR
|
|
1401
1497
|
.br
|
|
1402
1498
|
.IP \(bu 2
|
package/package.json
CHANGED
|
@@ -8,7 +8,8 @@ description: Build and change an Oalo workspace (the person's Oalo Base) from th
|
|
|
8
8
|
Oalo runs chatbots, chat flows, loops (background automations) and code tools in
|
|
9
9
|
the cloud. You edit their definitions locally and push them; they run on the
|
|
10
10
|
server. A push is a deploy: a saved flow or loop is live for real customers the
|
|
11
|
-
moment it saves, with no staging copy. (Data and apps do have two
|
|
11
|
+
moment it saves, with no staging copy. (Data, booking data and apps do have two
|
|
12
|
+
envs: dev, which is staging, and prod, which is live. See rule 9.)
|
|
12
13
|
|
|
13
14
|
Don't guess a command, flag or endpoint: `oalo help <command>` has every flag,
|
|
14
15
|
`oalo docs --search "<words>"` finds Oalo's own pages, and `oalo call --list
|
|
@@ -17,7 +18,8 @@ Don't guess a command, flag or endpoint: `oalo help <command>` has every flag,
|
|
|
17
18
|
## The loop
|
|
18
19
|
|
|
19
20
|
```sh
|
|
20
|
-
oalo pull # flows, loops
|
|
21
|
+
oalo pull # the whole workspace: flows, loops, code tools, node catalogs
|
|
22
|
+
oalo pull loops --name x # just one (in an app's repo, pull what you work on); `oalo pull catalog`: catalogs only
|
|
21
23
|
# edit .oalo/flows/<bot>/<flow>.json, .oalo/loops/<loop>.json, .oalo/tools/<tool>.js
|
|
22
24
|
oalo lint # check every changed file; nothing is saved
|
|
23
25
|
oalo push # lint, then save with the version you pulled (strict)
|
|
@@ -65,8 +67,11 @@ Over MCP the same steps are `oalo_node_catalog`, `oalo_get_flow` / `oalo_get_loo
|
|
|
65
67
|
the first message even while it's off, so test a new flow before anyone
|
|
66
68
|
turns it on.
|
|
67
69
|
7. **Test conversations do real work.** They never reach a customer's phone,
|
|
68
|
-
but the bot's tools and flows run
|
|
69
|
-
|
|
70
|
+
but the bot's tools and flows run and handoffs happen. Use a test bot, or
|
|
71
|
+
flows whose side effects are fine to repeat. `oalo qa` only sends text: it
|
|
72
|
+
can't fill in a web form or tap a widget. Collected contact details reach a
|
|
73
|
+
contact only when the test chat has one linked, and a WhatsApp or SMS test
|
|
74
|
+
contact is removed when the run ends.
|
|
70
75
|
Test a loop with `oalo loops test <name>`: sends are simulated.
|
|
71
76
|
To test a loop's trigger, `oalo emit <event> --dry-run` (MCP: `oalo_emit`
|
|
72
77
|
with `dry_run`) lists the loops an event would fire. Without `--dry-run` it
|
|
@@ -75,13 +80,27 @@ Over MCP the same steps are `oalo_node_catalog`, `oalo_get_flow` / `oalo_get_loo
|
|
|
75
80
|
8. **Customer-facing words are product copy.** Keep the bot's language and
|
|
76
81
|
tone, and never show customers internal names: SKUs, codes, step ids, tool
|
|
77
82
|
names.
|
|
83
|
+
9. **Know which env each step uses: dev is staging, prod is live.** A draft
|
|
84
|
+
(unpublished) bot reads and writes dev: it searches dev tables and books
|
|
85
|
+
against dev booking data. A published bot uses prod, in a test conversation
|
|
86
|
+
too. So setup for a draft bot goes to dev: rows with `oalo data push ...
|
|
87
|
+
--env dev`, booking types and hours with `"env": "dev"` (the booking events
|
|
88
|
+
default to prod). `oalo loops test` runs on dev; loops fired by real
|
|
89
|
+
triggers, `oalo emit` included, run on prod. `oalo metrics`, `oalo
|
|
90
|
+
dashboards add`, `oalo sources create` and `oalo db dump` default to prod;
|
|
91
|
+
data, db query, deploy, env, logs and run loop use the project's env from
|
|
92
|
+
`oalo link --env` (default dev); MCP tools never read it. When it matters,
|
|
93
|
+
don't rely on a default: pass `--env` (MCP and `oalo call`: `"env"`) every
|
|
94
|
+
time. Each command's `Env:` line in `oalo help <command>` says what it uses.
|
|
95
|
+
`oalo data promote <table>` copies rows dev to prod, only when the person
|
|
96
|
+
wants them live.
|
|
78
97
|
|
|
79
98
|
## Flows and loops differ
|
|
80
99
|
|
|
81
100
|
| | Chat flow | Loop |
|
|
82
101
|
|---|---|---|
|
|
83
102
|
| First step | `graph.entry` (required) | `entry` if set, else the first node no edge points to |
|
|
84
|
-
| Reading an earlier step | `{{state.<id>.<field>}}` | `{{<id>.<field>}}`; the previous step is `{{input}}` |
|
|
103
|
+
| Reading an earlier step | `{{<id>.<field>}}` (`{{state.<id>.<field>}}` still works) | `{{<id>.<field>}}`; the previous step is `{{input}}` |
|
|
85
104
|
| Several conditions match | the first match wins | every match is followed |
|
|
86
105
|
| No condition matches, no default edge | the flow ends quietly | the run fails |
|
|
87
106
|
| Action settings | keys on the node | inside `params` |
|
|
@@ -172,6 +191,8 @@ oalo data push orders_mirror orders.csv --id-field order_no --dry-run # chec
|
|
|
172
191
|
oalo data push orders_mirror orders.csv --id-field order_no # upsert into dev
|
|
173
192
|
oalo data list orders_mirror --limit 5 # look at what landed
|
|
174
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)
|
|
175
196
|
oalo data routes # the Sync API's endpoints, scopes and limits
|
|
176
197
|
```
|
|
177
198
|
|
|
@@ -184,7 +205,9 @@ Over MCP: `oalo_list_models`, `oalo_create_model`, `oalo_read_rows`,
|
|
|
184
205
|
2. **Always give rows an id** (`--id-field`), usually the source system's own
|
|
185
206
|
key. Then sending a row again updates it instead of adding a copy.
|
|
186
207
|
3. **Write to dev, check, then promote.** Rows written to prod sync to live apps
|
|
187
|
-
at once, so writing there needs `--env prod` and the person's go-ahead.
|
|
208
|
+
at once, so writing there needs `--env prod` and the person's go-ahead. A
|
|
209
|
+
draft bot reads dev and a published one prod, so load rows where the bot
|
|
210
|
+
you're testing reads them (rule 9).
|
|
188
211
|
4. **For an app's own server** (mirroring its database into Oalo, reading data
|
|
189
212
|
out): a server app hosted on Oalo already has `OALO_URL` and
|
|
190
213
|
`OALO_SYNC_TOKEN` in its environment, locked to its own env's data. Use
|
|
@@ -386,7 +409,9 @@ oalo dashboards add Sales orders --title "Revenue by plan" --kind bars --sum tot
|
|
|
386
409
|
```
|
|
387
410
|
|
|
388
411
|
1. **A question about numbers** (how many, how much, per week): `oalo metrics`
|
|
389
|
-
(MCP `oalo_query_metrics`). Don't read rows and add them up.
|
|
412
|
+
(MCP `oalo_query_metrics`). Don't read rows and add them up. A model's rows
|
|
413
|
+
are counted in prod unless you pass `--env dev` (MCP `"env": "dev"`), so
|
|
414
|
+
rows from tests and draft bots need `--env dev`, on a chart too.
|
|
390
415
|
2. **A chart the person wants to keep** goes on a dashboard with `oalo
|
|
391
416
|
dashboards add` (MCP `oalo_save_dashboard_widget`); the dashboard is made
|
|
392
417
|
when none has that name. Check `oalo dashboards` first: the same title
|
|
@@ -409,7 +434,8 @@ oalo channels # WhatsApp, Instagram, emai
|
|
|
409
434
|
|
|
410
435
|
1. **To make a bot answer from a table,** vectorize the table, then attach it
|
|
411
436
|
with `oalo bots knowledge`. Attaching alone does nothing for a table that
|
|
412
|
-
isn't searchable.
|
|
437
|
+
isn't searchable. The rows must be in the env the bot reads: dev while it's
|
|
438
|
+
a draft, prod once published (`oalo bots` shows its status).
|
|
413
439
|
2. **Read a setting with `--explain` before changing it.** Don't guess keys or
|
|
414
440
|
values.
|
|
415
441
|
3. **A published bot is live for customers.** `set` on one shows the change and
|
package/src/commands/bots.js
CHANGED
|
@@ -171,7 +171,9 @@ async function settings(ch, args, flags) {
|
|
|
171
171
|
|
|
172
172
|
if (flags.explain) {
|
|
173
173
|
const { settings: spec } = await ch.call("chat:bots:settings", {});
|
|
174
|
-
const
|
|
174
|
+
const asked = typeof flags.explain === "string" ? flags.explain : botId;
|
|
175
|
+
// `all` (as the help offers) means every setting, like no key.
|
|
176
|
+
const key = asked === "all" ? undefined : asked;
|
|
175
177
|
const pick = key ? spec.filter((s) => s.key === key || s.key.startsWith(`${key}.`) || s.group === key) : spec;
|
|
176
178
|
if (!pick.length) return fail(`no setting ${key}. \`oalo bots settings --explain\` lists them all.`, 2);
|
|
177
179
|
if (flags.json) return void console.log(JSON.stringify(pick, null, 2));
|
package/src/commands/call.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync, fstatSync } from "node:fs";
|
|
1
2
|
import { OaloChannel } from "../channel.js";
|
|
2
3
|
import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "../config.js";
|
|
3
4
|
import { requireFeature } from "../server.js";
|
|
@@ -119,6 +120,63 @@ function printNamespaces() {
|
|
|
119
120
|
);
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
/**
|
|
124
|
+
* The params for a call: inline JSON, `@file.json` (that file), or `-` (stdin).
|
|
125
|
+
* With no argument, stdin is read only when something is piped or redirected
|
|
126
|
+
* into it (a FIFO or a file), so a bare call never waits on a terminal or on
|
|
127
|
+
* /dev/null. Errors name where the JSON came from.
|
|
128
|
+
*/
|
|
129
|
+
export async function readParams(raw, { stdin = process.stdin, piped = stdinPiped() } = {}) {
|
|
130
|
+
let text;
|
|
131
|
+
let from;
|
|
132
|
+
if (raw === "-" || (raw === undefined && piped)) {
|
|
133
|
+
from = "stdin";
|
|
134
|
+
text = await readAll(stdin);
|
|
135
|
+
if (raw === undefined && !text.trim()) return {};
|
|
136
|
+
} else if (typeof raw === "string" && raw.startsWith("@")) {
|
|
137
|
+
const path = raw.slice(1);
|
|
138
|
+
if (!path) throw new Error("@ needs a file name: oalo call <event> @params.json");
|
|
139
|
+
from = path;
|
|
140
|
+
try {
|
|
141
|
+
text = readFileSync(path, "utf8");
|
|
142
|
+
} catch (e) {
|
|
143
|
+
throw new Error(`can't read params file ${path}: ${e.code === "ENOENT" ? "no such file" : e.code || e.message}`);
|
|
144
|
+
}
|
|
145
|
+
} else if (raw === undefined || raw === "") {
|
|
146
|
+
return {};
|
|
147
|
+
} else {
|
|
148
|
+
from = null;
|
|
149
|
+
text = raw;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let params;
|
|
153
|
+
try {
|
|
154
|
+
params = JSON.parse(text);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
throw new Error(from ? `params in ${from} must be valid JSON: ${e.message}` : `params must be valid JSON: ${e.message}`);
|
|
157
|
+
}
|
|
158
|
+
if (params === null || typeof params !== "object" || Array.isArray(params)) {
|
|
159
|
+
throw new Error(from ? `params in ${from} must be a JSON object` : "params must be a JSON object");
|
|
160
|
+
}
|
|
161
|
+
return params;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function stdinPiped() {
|
|
165
|
+
try {
|
|
166
|
+
const s = fstatSync(0);
|
|
167
|
+
return s.isFIFO() || s.isFile();
|
|
168
|
+
} catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function readAll(stream) {
|
|
174
|
+
let text = "";
|
|
175
|
+
stream.setEncoding?.("utf8");
|
|
176
|
+
for await (const chunk of stream) text += chunk;
|
|
177
|
+
return text;
|
|
178
|
+
}
|
|
179
|
+
|
|
122
180
|
export async function call(flags, rest) {
|
|
123
181
|
if (flags.list || flags.namespaces) {
|
|
124
182
|
await list(flags, rest);
|
|
@@ -127,27 +185,19 @@ export async function call(flags, rest) {
|
|
|
127
185
|
|
|
128
186
|
const event = rest[1];
|
|
129
187
|
if (!event) {
|
|
130
|
-
console.error("usage: oalo call <event> ['<json params>']\n");
|
|
188
|
+
console.error("usage: oalo call <event> ['<json params>' | @file.json | -]\n");
|
|
131
189
|
console.error("Run `oalo call --list` to see the events you can call.");
|
|
132
190
|
process.exitCode = 2;
|
|
133
191
|
return;
|
|
134
192
|
}
|
|
135
193
|
|
|
136
|
-
let params
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
process.exitCode = 2;
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (params === null || typeof params !== "object" || Array.isArray(params)) {
|
|
147
|
-
console.error("params must be a JSON object");
|
|
148
|
-
process.exitCode = 2;
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
194
|
+
let params;
|
|
195
|
+
try {
|
|
196
|
+
params = await readParams(rest[2]);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
console.error(e.message);
|
|
199
|
+
process.exitCode = 2;
|
|
200
|
+
return;
|
|
151
201
|
}
|
|
152
202
|
|
|
153
203
|
const cfg = resolveConfig(flags);
|