@oalo-ai/cli 0.4.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/man/oalo.1 +120 -5
- package/package.json +1 -1
- package/src/args.js +9 -1
- package/src/channel.js +1 -1
- package/src/commands/data.js +9 -1
- package/src/commands/deploy.js +6 -2
- package/src/commands/graphs.js +28 -8
- package/src/commands/machines.js +165 -0
- package/src/commands/serve.js +562 -0
- package/src/commands/switches.js +10 -0
- package/src/commands/tokens.js +14 -6
- package/src/commands/typegen.js +2 -1
- package/src/coord-release.json +9 -9
- package/src/events.js +9 -4
- package/src/graphfiles.js +44 -1
- package/src/help.js +66 -4
- package/src/index.js +8 -0
- package/src/serve/command.js +142 -0
- package/src/serve/config.js +215 -0
- package/src/serve/folder.js +368 -0
- package/src/serve/install.js +107 -0
- package/src/serve/model.js +363 -0
- package/src/serve/node.js +292 -0
package/README.md
CHANGED
|
@@ -307,6 +307,26 @@ The conversation is a hidden preview with no phone number, so nothing reaches a
|
|
|
307
307
|
customer. Everything else is real: tools and flows run, contact details are
|
|
308
308
|
saved, handoffs happen.
|
|
309
309
|
|
|
310
|
+
## Answering from your own computer: `oalo machines` and `oalo serve`
|
|
311
|
+
|
|
312
|
+
```sh
|
|
313
|
+
oalo machines add shop-pc
|
|
314
|
+
oalo serve add folder handbook ~/Documents/Handbook --describe "Store policies, shipping and returns"
|
|
315
|
+
oalo serve add command stock --input 'sku:string' --describe "Stock and price for one product code" -- python3 ~/oalo/stock.py
|
|
316
|
+
oalo serve test handbook '{"query": "return policy"}'
|
|
317
|
+
oalo serve
|
|
318
|
+
oalo bots tools bot_xxx --add shop-pc/handbook --add shop-pc/stock
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
`oalo serve` connects out to your workspace and answers the bot's tool calls
|
|
322
|
+
from a folder or a script on this computer. Nothing listens here, and only the
|
|
323
|
+
handler's answer (64 KB at most) goes back. The machine's key is saved in
|
|
324
|
+
`~/.oalo/serve/<name>.json` (mode 0600) and can only answer requests. A command
|
|
325
|
+
handler gets `{"input", "context"}` on stdin and prints one JSON object;
|
|
326
|
+
`context.member` is the verified id of the person chatting. `oalo serve install`
|
|
327
|
+
writes a launchd or systemd unit and prints the command that starts it.
|
|
328
|
+
`oalo help serve` has the details.
|
|
329
|
+
|
|
310
330
|
## Teaching your coding agent: `oalo skill`
|
|
311
331
|
|
|
312
332
|
`oalo skill` installs `.claude/skills/oalo/SKILL.md`, which Claude Code loads on
|
package/man/oalo.1
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.TH OALO 1 "" "oalo 0.
|
|
1
|
+
.TH OALO 1 "" "oalo 0.5.0" "OALO CLI"
|
|
2
2
|
.SH NAME
|
|
3
3
|
oalo \- wire a local app into your Oalo workspace
|
|
4
4
|
.SH SYNOPSIS
|
|
@@ -948,6 +948,117 @@ Every setting is described in \fBman oalo\fR (BOT SETTINGS) and by \fBoalo bots
|
|
|
948
948
|
The knowledge graph links a bot's passages: each document's sections, and the sections like each other, so a match can bring in related ones and the topics above it. A bot has none until \fBoalo bots graph <bot> \-\-build\fR. graph shows its size and whether links are labeled; how answers use it is in settings (graph_retrieval, ancestor_preload_depth, graph_classify_edges). Markdown front matter's related: list links pages by name.
|
|
949
949
|
.PP
|
|
950
950
|
Exit codes: 0 done; 1 refused or failed; 2 bad arguments or no CLI token.
|
|
951
|
+
.SS machines
|
|
952
|
+
The computers that answer your bots from their own data, through oalo serve: list, add, revoke.
|
|
953
|
+
.PP
|
|
954
|
+
\fBoalo machines [\-\-json]\fR
|
|
955
|
+
.br
|
|
956
|
+
\fBoalo machines add <name> [\-\-json]\fR
|
|
957
|
+
.br
|
|
958
|
+
\fBoalo machines revoke <name> \-\-yes [\-\-json]\fR
|
|
959
|
+
.br
|
|
960
|
+
.TP
|
|
961
|
+
\fBadd <name>\fR
|
|
962
|
+
Make this computer a machine: lowercase letters, digits and hyphens, up to 40 (shop\-pc). Saves its key to ~/.oalo/serve/<name>.json, mode 0600. The key is never printed. Admins only.
|
|
963
|
+
.TP
|
|
964
|
+
\fBrevoke <name>\fR
|
|
965
|
+
Its key stops working at once: oalo serve on it can't connect, and the bot tools it serves stop answering. Removes the key from this computer's config too, keeping its handlers.
|
|
966
|
+
.TP
|
|
967
|
+
\fB\-\-yes\fR
|
|
968
|
+
revoke: go ahead. Without it, revoke only says what it would do.
|
|
969
|
+
.TP
|
|
970
|
+
\fB\-\-json\fR
|
|
971
|
+
The machines, or what add and revoke did, as JSON.
|
|
972
|
+
.IP \(bu 2
|
|
973
|
+
The list shows each machine online or offline, when it was last seen, the handlers it declared and which one is this computer. Under it, each model a model handler declared: its model check result (passed, failed, running or not checked), the window it really has, and the id a bot is set to (byo\-mep_.../qwen3:14b) once it passes, or why it can't be used yet.
|
|
974
|
+
.IP \(bu 2
|
|
975
|
+
A machine's key (a node token, oalo_node_...) can only answer the box's requests for that machine. It can't read data or change anything in the workspace, so it is safe to leave on a shop computer. It is still a credential: the file is readable only by you.
|
|
976
|
+
.IP \(bu 2
|
|
977
|
+
Then add handlers and start serving: see \fBoalo help serve\fR. In the dashboard, a flow or loop's "On your machine" step lists each machine's handlers and whether it's online.
|
|
978
|
+
.PP
|
|
979
|
+
Exit codes: 0 done; 1 refused or failed (only an admin can add or revoke); 2 bad arguments, revoke without \-\-yes, or no CLI token.
|
|
980
|
+
.SS serve
|
|
981
|
+
Answer your bots from this computer: a folder or a script here answers the bot's tool calls, and the data never leaves it. A model server here (Ollama, vLLM) can run the bots too.
|
|
982
|
+
.PP
|
|
983
|
+
\fBoalo serve [\-\-machine <name>]\fR
|
|
984
|
+
.br
|
|
985
|
+
\fBoalo serve add folder <name> <path> \-\-describe "<what's in it>"\fR
|
|
986
|
+
.br
|
|
987
|
+
\fBoalo serve add command <name> \-\-describe "<what it answers>" [\-\-input 'sku:string,qty:integer?'] [\-\-timeout <seconds>] \-\- <program> [args...]\fR
|
|
988
|
+
.br
|
|
989
|
+
\fBoalo serve add model <name> [\-\-base\-url <url>] [\-\-server ollama|vllm|openai] [\-\-models <id1,id2>] [\-\-key\-env <VAR>] [\-\-context <tokens>] [\-\-output <tokens>] [\-\-describe "..."]\fR
|
|
990
|
+
.br
|
|
991
|
+
\fBoalo serve remove <name>\fR
|
|
992
|
+
.br
|
|
993
|
+
\fBoalo serve list [\-\-json]\fR
|
|
994
|
+
.br
|
|
995
|
+
\fBoalo serve test <name> '<json input>'\fR
|
|
996
|
+
.br
|
|
997
|
+
\fBoalo serve install [\-\-dry\-run]\fR
|
|
998
|
+
.br
|
|
999
|
+
.TP
|
|
1000
|
+
\fB\-\-machine <name>\fR
|
|
1001
|
+
Which machine, when this computer has more than one (\fBoalo machines add\fR made them). Every subcommand takes it.
|
|
1002
|
+
.TP
|
|
1003
|
+
\fB\-\-describe <text>\fR
|
|
1004
|
+
add: what the handler holds or answers. The bot reads it when deciding to call the tool, so be specific: "Store policies, shipping and returns".
|
|
1005
|
+
.TP
|
|
1006
|
+
\fB\-\-input <fields>\fR
|
|
1007
|
+
add command: the fields the bot sends, name:type, comma\-separated: \-\-input 'sku:string,qty:integer?'. Types string, integer, number, boolean; a ? makes a field optional (keep the quotes, or zsh reads the ? as a file pattern). Left out, the tool takes no input.
|
|
1008
|
+
.TP
|
|
1009
|
+
\fB\-\-timeout <seconds>\fR
|
|
1010
|
+
add command: how long the program may run, 1 to 120. Default 30. Then it's stopped (SIGTERM, then SIGKILL 2 s later) and the bot sees a timeout.
|
|
1011
|
+
.TP
|
|
1012
|
+
\fB\-\- <program> [args...]\fR
|
|
1013
|
+
add command: the program to run and its arguments, after a bare \-\-. Run directly, never through a shell, from the folder you ran add in.
|
|
1014
|
+
.TP
|
|
1015
|
+
\fB\-\-base\-url <url>\fR
|
|
1016
|
+
add model: the model server's OpenAI\-style API root, http or https. Default Ollama's http://127.0.0.1:11434/v1. Every model call goes to <url>/chat/completions and nowhere else. A warning if it isn't this computer or a private network address.
|
|
1017
|
+
.TP
|
|
1018
|
+
\fB\-\-server <kind>\fR
|
|
1019
|
+
add model: ollama, vllm or openai (any other OpenAI\-compatible server, like LM Studio). Left out: ollama on port 11434, vllm when its model list says so, else openai. It decides how thinking is turned off.
|
|
1020
|
+
.TP
|
|
1021
|
+
\fB\-\-models <ids>\fR
|
|
1022
|
+
add model: which of the server's models to declare, comma\-separated, up to 32 (qwen3:14b,llama3.2:3b). Left out: all its chat models.
|
|
1023
|
+
.TP
|
|
1024
|
+
\fB\-\-key\-env <name>\fR
|
|
1025
|
+
add model: the NAME of an environment variable holding the model server's key, sent as Authorization: Bearer. The key isn't saved, printed or sent to the workspace; set the variable where oalo serve runs.
|
|
1026
|
+
.TP
|
|
1027
|
+
\fB\-\-context <tokens>\fR
|
|
1028
|
+
add model: the context window to declare for every model. Left out: Ollama's num_ctx if the model sets one, else the model's maximum; vLLM's max_model_len.
|
|
1029
|
+
.TP
|
|
1030
|
+
\fB\-\-output <tokens>\fR
|
|
1031
|
+
add model: the most tokens a reply may take, for every model. Default the smaller of 8192 and a quarter of the context.
|
|
1032
|
+
.TP
|
|
1033
|
+
\fB\-\-dry\-run\fR
|
|
1034
|
+
install: print the service file and the command to load it; write nothing.
|
|
1035
|
+
.TP
|
|
1036
|
+
\fB\-\-json\fR
|
|
1037
|
+
list: the machine's handlers as JSON.
|
|
1038
|
+
.IP \(bu 2
|
|
1039
|
+
Start with \fBoalo machines add <name>\fR, which saves this computer's key (step by step: \fBoalo docs answer\-from\-your\-own\-data\fR). Handlers live in that machine's config, ~/.oalo/serve/<name>.json, never in a project. OALO_HOME moves it.
|
|
1040
|
+
.IP \(bu 2
|
|
1041
|
+
oalo serve connects out to your workspace and declares the handlers; nothing listens on this computer and no port is opened. Each handler becomes a workspace tool with the handler's name: give it to a bot with \fBoalo bots tools <bot> \-\-add <handler>\fR. A name another tool already has is skipped, and oalo serve says so. A handler name is lowercase letters, digits and underscores, up to 48, starting with a letter.
|
|
1042
|
+
.IP \(bu 2
|
|
1043
|
+
It prints one line per request: the time, the handler, how long it took, ok or the error, and the sizes in and out. Never what was asked or answered, which can be customer data. If the connection drops it reconnects, waiting 1 s, then 2, 4, up to 30.
|
|
1044
|
+
.IP \(bu 2
|
|
1045
|
+
folder: keyword search over the folder's .md, .markdown, .txt, .csv, .tsv, .json, .html and .htm files. Hidden files and folders, node_modules, files over 2 MB and links that lead outside the folder are skipped; nothing outside it is read. Markdown is split by heading and paragraph, a CSV or TSV one row at a time with its header line. Accents don't matter: devolucion finds devolución. The bot sends {"query", "limit"} (limit 1 to 10, default 5) and gets back {"results": [{"file", "snippet", "score"}]}. Edits are picked up on the next request.
|
|
1046
|
+
.IP \(bu 2
|
|
1047
|
+
command: the program gets {"input": {...}, "context": {...}} on stdin and prints one JSON object on stdout, which is the answer. context has surface (chat, flow or loop), bot, conversation and member: the verified id of the person chatting, so a script can return only their own orders. A flow step adds the flow's name, a loop step the loop's name and the run's contact. Use it, never a name or id the person typed. A non\-zero exit or output that isn't a JSON object is an error the bot sees, with the last line the program wrote to stderr. Its environment is yours minus every OALO_ variable.
|
|
1048
|
+
.IP \(bu 2
|
|
1049
|
+
An answer is at most 64 KB; a bigger one is refused as "output too large". The answer goes into the bot's reply, so it passes through Oalo and the bot's model for that message. The folder or the program's data stays here.
|
|
1050
|
+
.IP \(bu 2
|
|
1051
|
+
test runs a handler here, with no connection, and prints exactly what the bot would get. Try every handler with it before a bot uses it.
|
|
1052
|
+
.IP \(bu 2
|
|
1053
|
+
install writes a launchd agent (macOS, ~/Library/LaunchAgents/ai.oalo.serve.<name>.plist) or a systemd user unit (Linux, ~/.config/systemd/user/oalo\-serve\-<name>.service) that runs oalo serve \-\-machine <name> at login and restarts it if it stops, then prints the one command that starts it. It never runs launchctl or systemctl itself.
|
|
1054
|
+
.IP \(bu 2
|
|
1055
|
+
model: runs your bots on a model server on this computer or your network (Ollama, vLLM, LM Studio, anything OpenAI\-compatible). It isn't a tool: the workspace sends a model id and a chat request, never an address, and this computer forwards it to the \-\-base\-url in its own config and streams the reply back. add reads the server's models (and, for Ollama, each model's window and whether it sees images); run it again with the same name to update them. Ollama serves a smaller window than a model's maximum unless OLLAMA_CONTEXT_LENGTH or num_ctx is raised, so add says so, and the workspace's model check finds the real one. test sends one message the way the workspace would, thinking off, and prints the reply, the time to the first token and tokens per second: oalo serve test <name> '{"model": "qwen3:14b", "message": "Say hi in five words"}'. Each model call is one line: the time, the handler, the model, how long, the first token, tokens in and out. Never the conversation. Before a bot can use a model, the workspace checks it through the same path a member's message takes: it must call a made\-up lookup tool and answer from it (6 of 6), pick the right one of three tools, refuse to run commands or read files, never reply with nothing, find facts far back in a long conversation, and return a form's fields as JSON. A model that can't call tools fails, and so does one whose server really reads fewer than 8,192 tokens (raise OLLAMA_CONTEXT_LENGTH or num_ctx, then add the model again with \-\-context so it's checked again). The check starts by itself when oalo serve first declares a model and takes a few minutes per model; \fBoalo machines\fR shows the result. Then set the bot to the model: oalo bots settings <bot> set provider=opencode model=<the id oalo machines shows>. If this computer is off when a bot needs the model, the member gets a short apology and the workspace an incident. The whole walkthrough: \fBoalo docs run\-your\-bot\-on\-your\-own\-model\fR.
|
|
1056
|
+
.IP \(bu 2
|
|
1057
|
+
After add or remove, restart oalo serve so the workspace sees the change.
|
|
1058
|
+
.IP \(bu 2
|
|
1059
|
+
Flows and loops can call a handler too, with a remote_step ("On your machine" in the editor). The step waits for the answer without holding anything open, and a step that started while this computer was off is sent when oalo serve connects. The handler's own \-\-timeout still limits each run.
|
|
1060
|
+
.PP
|
|
1061
|
+
Exit codes: 0 done, or stopped with Ctrl\-C; 1 a handler failed its test, the key was revoked, or a write failed; 2 bad arguments, no machine on this computer, or no handlers.
|
|
951
1062
|
.SS tokens
|
|
952
1063
|
List, create and revoke the workspace's sync tokens, for an app's own server.
|
|
953
1064
|
.PP
|
|
@@ -1420,7 +1531,9 @@ Each save sends the pulled version: if someone saved in between, the push is ref
|
|
|
1420
1531
|
.IP \(bu 2
|
|
1421
1532
|
Saves are strict: error\-level lint findings block them. Fix the findings (each says how) or pass \-\-no\-strict.
|
|
1422
1533
|
.IP \(bu 2
|
|
1423
|
-
After a save the file is rewritten from the server's copy with the new version.
|
|
1534
|
+
After a save the file is rewritten from the server's copy with the new version. A flow file pushed from outside .oalo/flows is kept as it is, and the saved copy goes to .oalo/flows/<bot>/<flow>.json.
|
|
1535
|
+
.IP \(bu 2
|
|
1536
|
+
Oalo keeps no older versions of a flow or loop. Keep the .oalo/ files in git to have them: to go back, restore the earlier file and run \fBoalo push <file> \-\-force\fR (it still carries the version it was pulled at, so without \-\-force it counts as unchanged).
|
|
1424
1537
|
.IP \(bu 2
|
|
1425
1538
|
Needs a CLI token.
|
|
1426
1539
|
.PP
|
|
@@ -1482,10 +1595,10 @@ Rehearse inbound WhatsApp conversations end to end: routing, triage and the bot'
|
|
|
1482
1595
|
The WhatsApp number (phone_number_id) the customer writes to. Default: the workspace's default number.
|
|
1483
1596
|
.TP
|
|
1484
1597
|
\fB\-\-responder <bot_...>\fR
|
|
1485
|
-
The bot the checks expect to end up answering, by its public id (\fBoalo bots\fR lists them). It's a check, not routing: messages still go where the number and its triage send them. To rehearse a bot that isn't on the number, give a \-\-script scenario with an open_thread on that bot. Default: the bot an enabled triage loop hands threads to, else the number's bot.
|
|
1598
|
+
The bot the checks expect to end up answering, by its public id (\fBoalo bots\fR lists them). It's a check, not routing: messages still go where the number and its triage send them. To rehearse a bot that isn't on the number, give a \-\-script scenario with an open_thread on that bot. Default: the bot an enabled triage loop hands threads to, counting only loops that fire for a WhatsApp message on that number (their channel and bot filters allow it), else the number's bot.
|
|
1486
1599
|
.TP
|
|
1487
1600
|
\fB\-\-script <file>\fR
|
|
1488
|
-
A JSON file: {"scenarios": [{"name", "messages", "known_contact", "opted_out", "open_thread": {"bot_id", "number", "hours_ago", "tags", "assigned", "deal", "messages"}, "expect": {"reply", "bot_id", "assigned"}}]}. open_thread.bot_id is a public id (bot_...) or number. An open thread starts with one earlier exchange: open_thread.messages [customer, reply] when given, else a Spanish greeting ("Hola" / "¡Hola! ¿En qué te puedo ayudar?"), which can set the language the bot answers in.
|
|
1601
|
+
A JSON file: {"scenarios": [{"name", "messages", "known_contact", "opted_out", "open_thread": {"bot_id", "number", "hours_ago", "tags", "assigned", "deal", "messages"}, "expect": {"reply", "bot_id", "assigned"}}]}. open_thread.bot_id is a public id (bot_...) or number. open_thread.number defaults to the number the scenario writes to. An open thread starts with one earlier exchange: open_thread.messages [customer, reply] when given, else a Spanish greeting ("Hola" / "¡Hola! ¿En qué te puedo ayudar?"), which can set the language the bot answers in.
|
|
1489
1602
|
.TP
|
|
1490
1603
|
\fB\-\-timeout <s>\fR
|
|
1491
1604
|
How long one message may take to settle. Default 120, at most 300.
|
|
@@ -1533,6 +1646,8 @@ Serve the workspace over MCP on stdio, for Claude Code or Cursor.
|
|
|
1533
1646
|
\fBoalo mcp\fR
|
|
1534
1647
|
.br
|
|
1535
1648
|
.IP \(bu 2
|
|
1649
|
+
Add it to Claude Code from the linked project folder: \fBclaude mcp add oalo \-\- oalo mcp\fR (or put {"mcpServers": {"oalo": {"command": "oalo", "args": ["mcp"]}}} in .mcp.json). Cursor: the same command and args in its MCP settings.
|
|
1650
|
+
.IP \(bu 2
|
|
1536
1651
|
stdout is the MCP protocol stream. Diagnostics go to stderr.
|
|
1537
1652
|
.IP \(bu 2
|
|
1538
1653
|
Exposes a curated tool set plus an oalo_call passthrough; the build surface has ~442 events and mapping them all would wreck tool selection.
|
|
@@ -1872,7 +1987,7 @@ data (/api/sync/v1). From \fBoalo login\fR (read\-only), dashboard \-> Account \
|
|
|
1872
1987
|
Server\-side only. Carries no end\-user identity, so it reads and writes EVERY member's rows. Never ship one inside a mobile or web app.
|
|
1873
1988
|
.TP
|
|
1874
1989
|
\fBcli\fR
|
|
1875
|
-
control (the build surface). From \fBoalo login\fR, or dashboard \-> Account \-> CLI & agents. Used by whoami, tail, call, run, emit, data, tokens, docs, apps, deploy, env, logs, secrets, loops, flows, pull, status, lint, push, qa, rehearse, bots, sources, mcp.
|
|
1990
|
+
control (the build surface). From \fBoalo login\fR, or dashboard \-> Account \-> CLI & agents. Used by whoami, tail, call, run, emit, data, tokens, docs, apps, deploy, env, logs, secrets, loops, flows, pull, status, lint, push, qa, rehearse, bots, sources, machines, mcp.
|
|
1876
1991
|
.br
|
|
1877
1992
|
Acts as you, with exactly your permissions. No read\-only mode. Treat it like a password.
|
|
1878
1993
|
.SH ENVIRONMENT
|
package/package.json
CHANGED
package/src/args.js
CHANGED
|
@@ -41,12 +41,20 @@ export const SWITCHES = new Set([...GLOBAL_SWITCHES, ...[...KINDS].filter(([, k]
|
|
|
41
41
|
// is still theirs. Only another `--flag` ends them.
|
|
42
42
|
export const VALUED = new Set([...KINDS].filter(([, k]) => k === "value").map(([n]) => n));
|
|
43
43
|
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Tiny flag parser: --key value, --switch, -h. No dependency needed. A bare
|
|
46
|
+
* `--` ends the flags: every word after it is kept as is in flags["--"]
|
|
47
|
+
* (`oalo serve add command stock -- python3 stock.py --verbose`).
|
|
48
|
+
*/
|
|
45
49
|
export function parse(argv, { switches = SWITCHES, valued = VALUED } = {}) {
|
|
46
50
|
const flags = {};
|
|
47
51
|
const rest = [];
|
|
48
52
|
for (let i = 0; i < argv.length; i++) {
|
|
49
53
|
const a = argv[i];
|
|
54
|
+
if (a === "--") {
|
|
55
|
+
flags["--"] = argv.slice(i + 1);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
50
58
|
if (a.startsWith("--")) {
|
|
51
59
|
const key = a.slice(2);
|
|
52
60
|
const next = argv[i + 1];
|
package/src/channel.js
CHANGED
|
@@ -51,7 +51,7 @@ export class OaloChannel {
|
|
|
51
51
|
// a token-rejected explanation during testing). OALO_DEBUG=1 brings it
|
|
52
52
|
// back, on stderr.
|
|
53
53
|
logger: this.verbose
|
|
54
|
-
? (kind, msg) => process.stderr.write(`[phoenix] ${kind}: ${msg}\n`)
|
|
54
|
+
? (kind, msg) => process.stderr.write(`[phoenix] ${kind}: ${String(msg).replace(/(node_token|cli_token)=[^&\s]+/g, "$1=***")}\n`)
|
|
55
55
|
: () => {},
|
|
56
56
|
});
|
|
57
57
|
|
package/src/commands/data.js
CHANGED
|
@@ -359,7 +359,7 @@ async function watch(flags, rest, cfg) {
|
|
|
359
359
|
signal: ac.signal,
|
|
360
360
|
onEvent: (event, d) => {
|
|
361
361
|
if (event === "heartbeat") return;
|
|
362
|
-
console.log(flags.json ? JSON.stringify({ event, data: d }) : `${event} ${
|
|
362
|
+
console.log(flags.json ? JSON.stringify({ event, data: d }) : `${event} ${watchLine(d)}`);
|
|
363
363
|
},
|
|
364
364
|
});
|
|
365
365
|
} catch (e) {
|
|
@@ -452,3 +452,11 @@ async function showRoutes(flags, cfg) {
|
|
|
452
452
|
if (r.rate_limits_per_minute) console.log(dim(`\nlimits per minute: ${Object.entries(r.rate_limits_per_minute).map(([k, v]) => `${k} ${v}`).join(", ")}`));
|
|
453
453
|
});
|
|
454
454
|
}
|
|
455
|
+
|
|
456
|
+
/** One row of `oalo data watch`: the row's id and fields. Stream events from
|
|
457
|
+
* sources and bulk writes wrap the row as `{table, operation, row_id, data:
|
|
458
|
+
* row, ...}`, which printed as one long raw line (2026-11-18). */
|
|
459
|
+
export function watchLine(d) {
|
|
460
|
+
const row = d?.data && (d.data.document || d.data.id) ? d.data : d;
|
|
461
|
+
return JSON.stringify(row?.id ? { id: row.id, ...row.document } : row);
|
|
462
|
+
}
|
package/src/commands/deploy.js
CHANGED
|
@@ -129,8 +129,12 @@ export async function deploy(flags) {
|
|
|
129
129
|
// A new app: this project now deploys to it (as `oalo link --app` saves).
|
|
130
130
|
if (result.created) {
|
|
131
131
|
writeConfig({ ...(readConfig(root) || {}), serverUrl: url, appId: result.app, env: "dev" }, root);
|
|
132
|
-
// As `oalo link` does: the link file stays out of the repo's commits.
|
|
133
|
-
|
|
132
|
+
// As `oalo link` does: the link file stays out of the repo's commits. Say
|
|
133
|
+
// so: the next `oalo deploy` refuses uncommitted changes, and this edit
|
|
134
|
+
// was one nobody saw (2026-11-18).
|
|
135
|
+
if (ensureGitignored(root)) {
|
|
136
|
+
console.log(dim("added .oalo/credentials* to .gitignore: commit it before your next `oalo deploy`."));
|
|
137
|
+
}
|
|
134
138
|
if (result.app_type === "code_only") {
|
|
135
139
|
// The server's progress line already said what to add.
|
|
136
140
|
console.log(`created ${result.app} from ${result.commit.slice(0, 8)}, its history kept. Nothing runs yet (see above).`);
|
package/src/commands/graphs.js
CHANGED
|
@@ -13,10 +13,12 @@ import {
|
|
|
13
13
|
readGraphFile,
|
|
14
14
|
writeGraphFile,
|
|
15
15
|
removeFile,
|
|
16
|
+
pushWriteBack,
|
|
16
17
|
listGraphFiles,
|
|
17
18
|
expandTargets,
|
|
18
19
|
locallyModified,
|
|
19
20
|
standing,
|
|
21
|
+
rollbackHint,
|
|
20
22
|
rel,
|
|
21
23
|
cleanTrigger,
|
|
22
24
|
triggerKey,
|
|
@@ -388,7 +390,21 @@ function saveParams(file, { force, strict }) {
|
|
|
388
390
|
return { event: file.version == null ? "loops:create" : "loops:update", params };
|
|
389
391
|
}
|
|
390
392
|
|
|
391
|
-
|
|
393
|
+
/**
|
|
394
|
+
* Write the server's copy after a save (see pushWriteBack): the pushed file,
|
|
395
|
+
* and the pulled copy under .oalo unless it has edits of its own. Returns the
|
|
396
|
+
* note to add to the push line.
|
|
397
|
+
*/
|
|
398
|
+
function writeBack(path, savedPath, next) {
|
|
399
|
+
const { file: saved } = existsSync(savedPath) ? load(savedPath) : {};
|
|
400
|
+
const plan = pushWriteBack(path, savedPath, !!saved && locallyModified(saved));
|
|
401
|
+
for (const p of plan.write) writeGraphFile(p, next);
|
|
402
|
+
if (plan.remove) removeFile(plan.remove);
|
|
403
|
+
if (plan.kept) return `. ${rel(plan.kept)} has edits of its own, so it was left as it is (now behind v${next.version})`;
|
|
404
|
+
return plan.write.length > 1 ? `, ${rel(plan.write[1])} updated too` : "";
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export async function pushOne(ch, path, file, flags) {
|
|
392
408
|
const strict = flags["no-strict"] !== true;
|
|
393
409
|
|
|
394
410
|
// Lint first, so the author sees every finding even when the save would
|
|
@@ -431,10 +447,7 @@ async function pushOne(ch, path, file, flags) {
|
|
|
431
447
|
|
|
432
448
|
if (file.kind === "flow") {
|
|
433
449
|
const next = flowFile(reply.flow, file.bot);
|
|
434
|
-
|
|
435
|
-
writeGraphFile(newPath, next);
|
|
436
|
-
if (resolvePath(newPath) !== resolvePath(path)) removeFile(path);
|
|
437
|
-
return { ok: true, state: "pushed", note: `v${next.version}` };
|
|
450
|
+
return { ok: true, state: "pushed", note: `v${next.version}${writeBack(path, flowPath(file.bot, next.flow.name), next)}` };
|
|
438
451
|
}
|
|
439
452
|
|
|
440
453
|
const triggerNotes = Array.isArray(file.triggers) && !file.app_id ? await syncTriggers(ch, file) : { notes: [], failed: [] };
|
|
@@ -442,7 +455,7 @@ async function pushOne(ch, path, file, flags) {
|
|
|
442
455
|
// Loop saves reply with a version only; read the stored copy back so the
|
|
443
456
|
// file matches what the server normalised (legacy edge keys, stale entry).
|
|
444
457
|
const remote = await getLoop(ch, file.name, file.app_id);
|
|
445
|
-
|
|
458
|
+
const written = remote ? writeBack(path, loopPath(file.name, file.app_id), loopFile(remote, await listTriggers(ch, file.name, file.app_id))) : "";
|
|
446
459
|
if (file.app_id) console.log(dim(" app-pinned loop: saved without the version guard or strict check"));
|
|
447
460
|
for (const n of triggerNotes.notes) console.log(dim(` ${n}`));
|
|
448
461
|
if (triggerNotes.failed.length) {
|
|
@@ -450,12 +463,16 @@ async function pushOne(ch, path, file, flags) {
|
|
|
450
463
|
}
|
|
451
464
|
// A new loop's first version is 0: say "created" rather than "v0".
|
|
452
465
|
const created = file.version == null;
|
|
453
|
-
return { ok: true, state: created ? "created" : "pushed", note: remote ? (created ? `v${remote.version}${remote.enabled === false ? `, off until \`oalo loops on ${file.name}\`` : ""}` : `v${remote.version}`) : "" };
|
|
466
|
+
return { ok: true, state: created ? "created" : "pushed", note: remote ? (created ? `v${remote.version}${remote.enabled === false ? `, off until \`oalo loops on ${file.name}\`` : ""}` : `v${remote.version}`) + written : "" };
|
|
454
467
|
} catch (e) {
|
|
455
468
|
if (e.code === "conflict") {
|
|
456
469
|
// Save the server's copy beside the file, so the merge is a file diff
|
|
457
470
|
// rather than a lost edit. It becomes the base for the next push.
|
|
458
471
|
const current = await remoteOf(ch, file).catch(() => null);
|
|
472
|
+
// A rollback (an unchanged earlier pull) has nothing to merge: say so
|
|
473
|
+
// before writing a server copy beside it.
|
|
474
|
+
const rollback = rollbackHint(file, current?.version ?? e.reply?.current?.version, rel(path));
|
|
475
|
+
if (rollback) return { ok: false, state: "behind", note: rollback };
|
|
459
476
|
const theirsPath = path.replace(/\.json$/, ".server.json");
|
|
460
477
|
let theirs = null;
|
|
461
478
|
if (current && file.kind === "tool") {
|
|
@@ -588,7 +605,10 @@ export async function push(flags, rest) {
|
|
|
588
605
|
else failed++;
|
|
589
606
|
}
|
|
590
607
|
|
|
591
|
-
if (pushed + failed === 0)
|
|
608
|
+
if (pushed + failed === 0) {
|
|
609
|
+
console.log("nothing to push: no file differs from what was pulled");
|
|
610
|
+
console.log(dim(" A file restored from git (an earlier version) counts as unchanged. To make it live again: oalo push <file> --force. `oalo status` shows files behind the server."));
|
|
611
|
+
}
|
|
592
612
|
if (failed > 0) process.exitCode = 1;
|
|
593
613
|
} catch (e) {
|
|
594
614
|
console.error(`push failed: ${e.message}`);
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { OaloChannel } from "../channel.js";
|
|
2
|
+
import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "../config.js";
|
|
3
|
+
import { requireFeature } from "../server.js";
|
|
4
|
+
import { dim } from "../events.js";
|
|
5
|
+
import { machineNameError, readMachine, writeMachine, localMachines } from "../serve/config.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `oalo machines`: the computers that answer this workspace's bots from their
|
|
9
|
+
* own data, through `oalo serve`.
|
|
10
|
+
*
|
|
11
|
+
* oalo machines list them, online or not
|
|
12
|
+
* oalo machines add <name> make this computer one; saves its key
|
|
13
|
+
* oalo machines revoke <name> --yes its key stops working
|
|
14
|
+
*
|
|
15
|
+
* `add` mints a node token and writes it straight into
|
|
16
|
+
* ~/.oalo/serve/<name>.json (mode 0600). It is never printed. A node token can
|
|
17
|
+
* only answer the box's requests for that machine; it can't read or change
|
|
18
|
+
* anything in the workspace.
|
|
19
|
+
*/
|
|
20
|
+
export async function machines(flags, rest, opts = {}) {
|
|
21
|
+
const sub = rest[1] || "list";
|
|
22
|
+
const name = rest[2];
|
|
23
|
+
if (!["list", "add", "revoke"].includes(sub)) return fail(`unknown machines command: ${sub}\n\n${USAGE}`, 2);
|
|
24
|
+
if (sub !== "list") {
|
|
25
|
+
const bad = machineNameError(name);
|
|
26
|
+
if (bad) return fail(`${bad}\n\n${USAGE}`, 2);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (sub === "add") {
|
|
30
|
+
let local;
|
|
31
|
+
try {
|
|
32
|
+
local = readMachine(name);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return fail(e.message, 1);
|
|
35
|
+
}
|
|
36
|
+
if (local?.token) return fail(`${name} is already set up on this computer (${pathOf(name)}). To start over, revoke it first: oalo machines revoke ${name} --yes`, 1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (sub === "revoke" && !flags.yes) {
|
|
40
|
+
return fail(
|
|
41
|
+
`This revokes ${name}'s key for good: oalo serve on it stops connecting, and the bot tools it serves stop answering. Run it again with --yes to go ahead.`,
|
|
42
|
+
2,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const cfg = resolveConfig(flags);
|
|
47
|
+
const { url, token } = controlPlane(cfg);
|
|
48
|
+
if (!url || !token) return fail(`oalo machines needs a CLI token.\n\n${HOW_TO_CONNECT}`, 2);
|
|
49
|
+
|
|
50
|
+
if (!opts.channel) {
|
|
51
|
+
try {
|
|
52
|
+
await requireFeature(url, "machines", "oalo machines");
|
|
53
|
+
} catch (e) {
|
|
54
|
+
return fail(e.message, 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const ch = (opts.channel || ((o) => new OaloChannel(o)))({ url, token });
|
|
59
|
+
try {
|
|
60
|
+
await ch.connect();
|
|
61
|
+
if (sub === "list") return await list(ch, url, flags);
|
|
62
|
+
if (sub === "add") return await add(ch, url, name, flags);
|
|
63
|
+
return await revoke(ch, url, name, flags);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
if (e.code === "admin_only") return fail(`only a workspace admin can ${sub === "add" ? "add" : "revoke"} a machine. Ask an admin to run it.`, 1);
|
|
66
|
+
return fail(e.message, 1);
|
|
67
|
+
} finally {
|
|
68
|
+
ch.close();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const USAGE = [
|
|
73
|
+
"usage: oalo machines [--json]",
|
|
74
|
+
" oalo machines add <name>",
|
|
75
|
+
" oalo machines revoke <name> --yes",
|
|
76
|
+
].join("\n");
|
|
77
|
+
|
|
78
|
+
const pathOf = (name) => `~/.oalo/serve/${name}.json`;
|
|
79
|
+
|
|
80
|
+
// Machines whose config on this computer points at this workspace.
|
|
81
|
+
function hereFor(url) {
|
|
82
|
+
const out = new Set();
|
|
83
|
+
for (const n of localMachines()) {
|
|
84
|
+
try {
|
|
85
|
+
const m = readMachine(n);
|
|
86
|
+
if (m?.url === url) out.add(n);
|
|
87
|
+
} catch {
|
|
88
|
+
/* a broken file isn't this command's problem */
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function list(ch, url, flags) {
|
|
95
|
+
const { machines: all = [] } = await ch.call("machines:list", {});
|
|
96
|
+
if (flags.json) return void console.log(JSON.stringify(all, null, 2));
|
|
97
|
+
if (!all.length) return void console.log(`no machines in ${url} yet. Make this computer one: oalo machines add <name>`);
|
|
98
|
+
const here = hereFor(url);
|
|
99
|
+
const w = Math.max(...all.map((m) => m.name.length));
|
|
100
|
+
for (const m of all) {
|
|
101
|
+
const status = m.online ? "online " : "offline";
|
|
102
|
+
const seen = !m.online && m.last_seen_at ? `last seen ${String(m.last_seen_at).slice(0, 16).replace("T", " ")}` : m.online ? "" : "never connected";
|
|
103
|
+
const handlers = (m.handlers || []).map((h) => h.name);
|
|
104
|
+
const tail = [seen, handlers.length ? `handlers: ${handlers.join(", ")}` : "no handlers yet", here.has(m.name) ? "this computer" : ""].filter(Boolean).join(", ");
|
|
105
|
+
console.log(`${m.name.padEnd(w)} ${status} ${dim(tail)}`);
|
|
106
|
+
printModels(m.models || []);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// A machine's own models: the check's result, the real window, and the id a
|
|
111
|
+
// bot is set to (or why it can't be used yet).
|
|
112
|
+
function printModels(models) {
|
|
113
|
+
if (!models.length) return;
|
|
114
|
+
const w = Math.max(...models.map((x) => x.model.length));
|
|
115
|
+
for (const x of models) {
|
|
116
|
+
const win = x.window ? `window ${Number(x.window).toLocaleString("en-US")}` : "";
|
|
117
|
+
const tail = x.serving ? `bots can use: ${x.model_id}` : x.check === "running" ? "check running" : x.why || "";
|
|
118
|
+
console.log(` ${x.handler} ${x.model.padEnd(w)} ${String(x.check).padEnd(11)} ${dim([win, tail].filter(Boolean).join(", "))}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function add(ch, url, name, flags) {
|
|
123
|
+
const r = await ch.call("machines:add", { name });
|
|
124
|
+
const id = r?.machine?.id;
|
|
125
|
+
if (typeof r?.token !== "string" || !r.token || !id) return fail("the box didn't send back a machine key. Nothing was saved.", 1);
|
|
126
|
+
// A config left by a revoked key keeps its handlers.
|
|
127
|
+
let handlers = [];
|
|
128
|
+
try {
|
|
129
|
+
handlers = readMachine(name)?.handlers || [];
|
|
130
|
+
} catch {
|
|
131
|
+
handlers = [];
|
|
132
|
+
}
|
|
133
|
+
const path = writeMachine({ name, node_id: id, url, token: r.token, handlers });
|
|
134
|
+
if (flags.json) return void console.log(JSON.stringify({ machine: { id, name: r.machine.name || name }, config: path }, null, 2));
|
|
135
|
+
console.log(`added ${name}. Its key is saved in ${path} (only you can read it).`);
|
|
136
|
+
console.log(dim("The key can only answer your bots' questions. It can't read or change anything in your workspace."));
|
|
137
|
+
console.log("");
|
|
138
|
+
console.log("Next, share a folder or a script, then start serving:");
|
|
139
|
+
console.log(` oalo serve add folder handbook ~/Documents/Handbook --describe "Store policies, shipping and returns"`);
|
|
140
|
+
console.log(` oalo serve add command stock --input sku:string --describe "Stock and price for one product code" -- python3 ~/oalo/stock.py`);
|
|
141
|
+
console.log(` oalo serve`);
|
|
142
|
+
if (handlers.length) console.log(dim(`(kept the ${handlers.length} handler${handlers.length === 1 ? "" : "s"} already set up for ${name}: oalo serve list)`));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function revoke(ch, url, name, flags) {
|
|
146
|
+
await ch.call("machines:revoke", { name });
|
|
147
|
+
// Drop the dead key from this computer's config; the handlers stay, so
|
|
148
|
+
// `oalo machines add <name>` sets it up again.
|
|
149
|
+
let local = null;
|
|
150
|
+
try {
|
|
151
|
+
local = readMachine(name);
|
|
152
|
+
} catch {
|
|
153
|
+
local = null;
|
|
154
|
+
}
|
|
155
|
+
const cleared = local?.token && local.url === url;
|
|
156
|
+
if (cleared) writeMachine({ ...local, token: null });
|
|
157
|
+
if (flags.json) return void console.log(JSON.stringify({ revoked: true, name, local_key_removed: !!cleared }, null, 2));
|
|
158
|
+
console.log(`revoked ${name}. Its key stops working now, and the bot tools it served stop answering.`);
|
|
159
|
+
if (cleared) console.log(dim(`Removed the key from ${pathOf(name)}. Its handlers are kept: oalo machines add ${name} sets it up again.`));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function fail(message, code) {
|
|
163
|
+
console.error(message);
|
|
164
|
+
process.exitCode = code;
|
|
165
|
+
}
|