@oalo-ai/cli 0.4.5 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.4.5" "OALO CLI"
1
+ .TH OALO 1 "" "oalo 0.5.1" "OALO CLI"
2
2
  .SH NAME
3
3
  oalo \- wire a local app into your Oalo workspace
4
4
  .SH SYNOPSIS
@@ -181,7 +181,7 @@ Call any build\-surface event directly. The escape hatch.
181
181
  .PP
182
182
  \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".
183
183
  .PP
184
- \fBoalo call <event> ['<json params>' | @file.json | \-]\fR
184
+ \fBoalo call <event> ['<json params>' | @file.json | \-] [\-\-timeout <seconds>]\fR
185
185
  .br
186
186
  \fBoalo call \-\-list [text] [\-\-json]\fR
187
187
  .br
@@ -192,6 +192,9 @@ List the events you can call, from the workspace. With text, the matching events
192
192
  \fB\-\-namespaces\fR
193
193
  The events you may call, counted per namespace (what \fB\-\-list\fR with no text shows).
194
194
  .TP
195
+ \fB\-\-timeout <seconds>\fR
196
+ How long to wait for the reply, 1 to 600. Default 30.
197
+ .TP
195
198
  \fB\-\-compact\fR
196
199
  Print the reply as one line of JSON.
197
200
  .IP \(bu 2
@@ -892,6 +895,8 @@ The workspace's bots: the tables each can search, and every setting (knowledge,
892
895
  .br
893
896
  \fBoalo bots knowledge <bot> \-\-add <source> [\-\-add ...] [\-\-remove <source>] [\-\-json]\fR
894
897
  .br
898
+ \fBoalo bots knowledge <bot> \-\-priority <document> [\-\-no\-priority <document>] [\-\-json]\fR
899
+ .br
895
900
  \fBoalo bots tools <bot> [\-\-add <tool>] [\-\-remove <tool>] [\-\-json]\fR
896
901
  .br
897
902
  \fBoalo bots settings <bot> [\-\-json]\fR
@@ -900,7 +905,11 @@ The workspace's bots: the tables each can search, and every setting (knowledge,
900
905
  .br
901
906
  \fBoalo bots settings \-\-explain [<key> | <group>] [\-\-json]\fR
902
907
  .br
903
- \fBoalo bots graph <bot> [\-\-build] [\-\-json]\fR
908
+ \fBoalo bots graph <bot> [\-\-build | \-\-resync | \-\-export] [\-\-json]\fR
909
+ .br
910
+ \fBoalo bots graph <bot> \-\-search <query> [\-\-json]\fR
911
+ .br
912
+ \fBoalo bots graph <bot> \-\-import <file.json> [\-\-json]\fR
904
913
  .br
905
914
  \fBoalo bots graph <bot> \-\-reset \-\-yes [\-\-json]\fR
906
915
  .br
@@ -914,6 +923,12 @@ knowledge: attach a searchable table: its handle (model:products, table:prod.faq
914
923
  \fB\-\-remove <source>\fR
915
924
  Detach one. The table stays searchable for other bots.
916
925
  .TP
926
+ \fB\-\-priority <document>\fR
927
+ knowledge: mark one of the bot's documents priority, by its id or name as knowledge lists it. Every section of it is the last related section cut when space runs out, and comes with a longer excerpt. \-\-no\-priority unmarks it. Repeat it, or comma\-separate. Sections of other documents get priority from the priority_words setting.
928
+ .TP
929
+ \fB\-\-no\-priority <document>\fR
930
+ knowledge: unmark a priority document.
931
+ .TP
917
932
  \fBset key=value\fR
918
933
  settings: change one or more. A value starting with @ is read from that file (for the frame). none, default or an empty value clears a setting where its help says so.
919
934
  .TP
@@ -923,6 +938,18 @@ settings set: apply to a published bot. Without it a published bot's change is s
923
938
  \fB\-\-build\fR
924
939
  graph: build the bot's knowledge graph from its documents, in the background (a minute or two). After that, each new document keeps it current. Run it again to rebuild it whole.
925
940
  .TP
941
+ \fB\-\-search <query>\fR
942
+ graph: keyword/substring search over the bot's knowledge graph nodes.
943
+ .TP
944
+ \fB\-\-export\fR
945
+ graph: print the bot's knowledge graph as import\-compatible JSON ({nodes, edges}).
946
+ .TP
947
+ \fB\-\-import <file>\fR
948
+ graph: queue a bulk import from a JSON file with {nodes, edges?}.
949
+ .TP
950
+ \fB\-\-resync\fR
951
+ graph: queue a chunk resync to refresh retrieval embeddings from the current graph content.
952
+ .TP
926
953
  \fB\-\-reset\fR
927
954
  graph: delete the whole graph, links added by hand or imported included. Needs \-\-yes.
928
955
  .TP
@@ -937,7 +964,7 @@ The bots, or the bot's sources and what else could be attached, as JSON.
937
964
  .IP \(bu 2
938
965
  <bot> is the bot's public id (bot_...), as \fBoalo bots\fR prints it.
939
966
  .IP \(bu 2
940
- A source is a table made searchable with \fBoalo data vectorize <table> \-\-fields ...\fR. A bot always searches its own knowledge base (documents) too.
967
+ A source is a table made searchable with \fBoalo data vectorize <table> \-\-fields ...\fR. A bot always searches its own knowledge base (documents) too. knowledge lists those documents, and which have priority.
941
968
  .IP \(bu 2
942
969
  The same as ticking a table in the bot's Knowledge pane in the dashboard, with the same access as there.
943
970
  .IP \(bu 2
@@ -948,6 +975,125 @@ Every setting is described in \fBman oalo\fR (BOT SETTINGS) and by \fBoalo bots
948
975
  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
976
  .PP
950
977
  Exit codes: 0 done; 1 refused or failed; 2 bad arguments or no CLI token.
978
+ .SS machines
979
+ The computers that answer your bots from their own data, through oalo serve: list, add, revoke, allow.
980
+ .PP
981
+ \fBoalo machines [\-\-json]\fR
982
+ .br
983
+ \fBoalo machines add <name> [\-\-json]\fR
984
+ .br
985
+ \fBoalo machines revoke <name> \-\-yes [\-\-json]\fR
986
+ .br
987
+ \fBoalo machines allow <byo\-endpoint/model> [\-\-off] [\-\-json]\fR
988
+ .br
989
+ .TP
990
+ \fBadd <name>\fR
991
+ 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.
992
+ .TP
993
+ \fBrevoke <name>\fR
994
+ 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.
995
+ .TP
996
+ \fBallow <byo\-endpoint/model>\fR
997
+ Let bots and workflows use this own model without waiting for (or passing) ModelCheck. Admins only.
998
+ .TP
999
+ \fB\-\-off\fR
1000
+ allow: turn the ModelCheck override back off for this model.
1001
+ .TP
1002
+ \fB\-\-yes\fR
1003
+ revoke: go ahead. Without it, revoke only says what it would do.
1004
+ .TP
1005
+ \fB\-\-json\fR
1006
+ The machines, or what add, revoke, and allow did, as JSON.
1007
+ .IP \(bu 2
1008
+ 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.
1009
+ .IP \(bu 2
1010
+ 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.
1011
+ .IP \(bu 2
1012
+ 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.
1013
+ .PP
1014
+ 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.
1015
+ .SS serve
1016
+ 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.
1017
+ .PP
1018
+ \fBoalo serve [\-\-machine <name>]\fR
1019
+ .br
1020
+ \fBoalo serve add folder <name> <path> \-\-describe "<what's in it>"\fR
1021
+ .br
1022
+ \fBoalo serve add command <name> \-\-describe "<what it answers>" [\-\-input 'sku:string,qty:integer?'] [\-\-timeout <seconds>] \-\- <program> [args...]\fR
1023
+ .br
1024
+ \fBoalo serve add model <name> [\-\-base\-url <url>] [\-\-server ollama|vllm|openai] [\-\-models <id1,id2>] [\-\-key\-env <VAR>] [\-\-context <tokens>] [\-\-output <tokens>] [\-\-describe "..."]\fR
1025
+ .br
1026
+ \fBoalo serve remove <name>\fR
1027
+ .br
1028
+ \fBoalo serve list [\-\-json]\fR
1029
+ .br
1030
+ \fBoalo serve test <name> '<json input>'\fR
1031
+ .br
1032
+ \fBoalo serve install [\-\-dry\-run]\fR
1033
+ .br
1034
+ .TP
1035
+ \fB\-\-machine <name>\fR
1036
+ Which machine, when this computer has more than one (\fBoalo machines add\fR made them). Every subcommand takes it.
1037
+ .TP
1038
+ \fB\-\-describe <text>\fR
1039
+ 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".
1040
+ .TP
1041
+ \fB\-\-input <fields>\fR
1042
+ 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.
1043
+ .TP
1044
+ \fB\-\-timeout <seconds>\fR
1045
+ add command: how long the program may run, 1 to 3600. Default 30 (chat tool calls are still capped at 120s on the box; workflow remote steps can run up to 1 hour). Then it's stopped (SIGTERM, then SIGKILL 2 s later) and the caller sees a timeout.
1046
+ .TP
1047
+ \fB\-\- <program> [args...]\fR
1048
+ 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.
1049
+ .TP
1050
+ \fB\-\-base\-url <url>\fR
1051
+ 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.
1052
+ .TP
1053
+ \fB\-\-server <kind>\fR
1054
+ 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.
1055
+ .TP
1056
+ \fB\-\-models <ids>\fR
1057
+ 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.
1058
+ .TP
1059
+ \fB\-\-key\-env <name>\fR
1060
+ 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.
1061
+ .TP
1062
+ \fB\-\-context <tokens>\fR
1063
+ 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.
1064
+ .TP
1065
+ \fB\-\-output <tokens>\fR
1066
+ add model: the most tokens a reply may take, for every model. Default the smaller of 8192 and a quarter of the context.
1067
+ .TP
1068
+ \fB\-\-dry\-run\fR
1069
+ install: print the service file and the command to load it; write nothing.
1070
+ .TP
1071
+ \fB\-\-json\fR
1072
+ list: the machine's handlers as JSON.
1073
+ .IP \(bu 2
1074
+ 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.
1075
+ .IP \(bu 2
1076
+ 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.
1077
+ .IP \(bu 2
1078
+ 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.
1079
+ .IP \(bu 2
1080
+ 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.
1081
+ .IP \(bu 2
1082
+ 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.
1083
+ .IP \(bu 2
1084
+ 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.
1085
+ .IP \(bu 2
1086
+ 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.
1087
+ .IP \(bu 2
1088
+ 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.
1089
+ .IP \(bu 2
1090
+ 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.
1091
+ .IP \(bu 2
1092
+ After add or remove, restart oalo serve so the workspace sees the change.
1093
+ .IP \(bu 2
1094
+ 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.
1095
+ .PP
1096
+ 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
1097
  .SS tokens
952
1098
  List, create and revoke the workspace's sync tokens, for an app's own server.
953
1099
  .PP
@@ -1420,7 +1566,9 @@ Each save sends the pulled version: if someone saved in between, the push is ref
1420
1566
  .IP \(bu 2
1421
1567
  Saves are strict: error\-level lint findings block them. Fix the findings (each says how) or pass \-\-no\-strict.
1422
1568
  .IP \(bu 2
1423
- After a save the file is rewritten from the server's copy with the new version.
1569
+ 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.
1570
+ .IP \(bu 2
1571
+ 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
1572
  .IP \(bu 2
1425
1573
  Needs a CLI token.
1426
1574
  .PP
@@ -1482,10 +1630,10 @@ Rehearse inbound WhatsApp conversations end to end: routing, triage and the bot'
1482
1630
  The WhatsApp number (phone_number_id) the customer writes to. Default: the workspace's default number.
1483
1631
  .TP
1484
1632
  \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.
1633
+ 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
1634
  .TP
1487
1635
  \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.
1636
+ 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
1637
  .TP
1490
1638
  \fB\-\-timeout <s>\fR
1491
1639
  How long one message may take to settle. Default 120, at most 300.
@@ -1533,6 +1681,8 @@ Serve the workspace over MCP on stdio, for Claude Code or Cursor.
1533
1681
  \fBoalo mcp\fR
1534
1682
  .br
1535
1683
  .IP \(bu 2
1684
+ 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.
1685
+ .IP \(bu 2
1536
1686
  stdout is the MCP protocol stream. Diagnostics go to stderr.
1537
1687
  .IP \(bu 2
1538
1688
  Exposes a curated tool set plus an oalo_call passthrough; the build surface has ~442 events and mapping them all would wreck tool selection.
@@ -1660,6 +1810,11 @@ After each graph rebuild, a small AI model labels the links between similar pass
1660
1810
  .br
1661
1811
  Values: true or false. Default: false. Changing it uses AI credit at each graph rebuild, for the links whose pages changed.
1662
1812
  .TP
1813
+ \fBpriority_words\fR
1814
+ Words that give a knowledge section priority when one is in its title or opening words, as a whole word (case aside). A priority section is the last related section cut when space runs out, and comes with a longer excerpt. Write each form you use (Rule, Rules). Whole documents can be marked priority too: \fBoalo bots knowledge <bot> \-\-priority <document>\fR. Comma\-separated; empty is none.
1815
+ .br
1816
+ Values: list. Default: none. Changing it rebuilds the knowledge graph, if the bot has one.
1817
+ .TP
1663
1818
  \fBcontext.strategy\fR
1664
1819
  How each turn's context is put together. retrieval: the frame, the persona and what search finds. graph_resolver: everything the member's tier unlocks in the knowledge graph, whole (high recall, more tokens). graph_focused: the same unlocking, but only the unlocked topics' own text, plus a search over the graph for this turn (token\-bounded). The context.* settings below are read by the graph strategies.
1665
1820
  .br
@@ -1872,7 +2027,7 @@ data (/api/sync/v1). From \fBoalo login\fR (read\-only), dashboard \-> Account \
1872
2027
  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
2028
  .TP
1874
2029
  \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.
2030
+ 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
2031
  .br
1877
2032
  Acts as you, with exactly your permissions. No read\-only mode. Treat it like a password.
1878
2033
  .SH ENVIRONMENT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oalo-ai/cli",
3
- "version": "0.4.5",
3
+ "version": "0.5.1",
4
4
  "description": "Wire a local app into your OALO workspace: link a token, generate typed bindings, and serve the build surface over MCP.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/args.js CHANGED
@@ -9,9 +9,9 @@ import { COMMANDS } from "./help.js";
9
9
  * another flag. A flag the registry doesn't list is read like an optional one.
10
10
  */
11
11
 
12
- // `--field`, `--scope`, `--add`, `--remove` and `--header` may repeat; every
13
- // other flag keeps its last value.
14
- const REPEATABLE = new Set(["field", "scope", "add", "remove", "header"]);
12
+ // `--field`, `--scope`, `--add`, `--remove`, `--header`, `--priority` and
13
+ // `--no-priority` may repeat; every other flag keeps its last value.
14
+ const REPEATABLE = new Set(["field", "scope", "add", "remove", "header", "priority", "no-priority"]);
15
15
 
16
16
  // Switches the registry doesn't list per command (global ones).
17
17
  const GLOBAL_SWITCHES = ["version", "help"];
@@ -34,6 +34,7 @@ export function flagKinds(commands = COMMANDS) {
34
34
  }
35
35
 
36
36
  const KINDS = flagKinds();
37
+ const BY_COMMAND = new Map(COMMANDS.map((c) => [c.name, flagKinds([c])]));
37
38
 
38
39
  export const SWITCHES = new Set([...GLOBAL_SWITCHES, ...[...KINDS].filter(([, k]) => k === "switch").map(([n]) => n)]);
39
40
 
@@ -41,13 +42,71 @@ export const SWITCHES = new Set([...GLOBAL_SWITCHES, ...[...KINDS].filter(([, k]
41
42
  // is still theirs. Only another `--flag` ends them.
42
43
  export const VALUED = new Set([...KINDS].filter(([, k]) => k === "value").map(([n]) => n));
43
44
 
44
- /** Tiny flag parser: --key value, --switch, -h. No dependency needed. */
45
- export function parse(argv, { switches = SWITCHES, valued = VALUED } = {}) {
45
+ // Find the command name so per-command flag kinds (e.g. `--build` is a switch
46
+ // on `bots` and a value on `build`) win over the global merged table.
47
+ function detectCommand(argv) {
48
+ for (let i = 0; i < argv.length; i++) {
49
+ const a = argv[i];
50
+ if (a === "--") break;
51
+ if (a.startsWith("-")) {
52
+ if (a.startsWith("--") && !a.includes("=")) {
53
+ const key = a.slice(2);
54
+ if (VALUED.has(key) && argv[i + 1] !== undefined && !argv[i + 1].startsWith("--")) i++;
55
+ }
56
+ continue;
57
+ }
58
+ return BY_COMMAND.has(a) ? a : null;
59
+ }
60
+ return null;
61
+ }
62
+
63
+ /**
64
+ * Tiny flag parser: --key value, --key=value, --switch, -h. No dependency
65
+ * needed. A bare `--` ends the flags: every word after it is kept as is in
66
+ * flags["--"] (`oalo serve add command stock -- python3 stock.py --verbose`).
67
+ */
68
+ export function parse(argv, opts = {}) {
69
+ const custom = opts.switches !== undefined || opts.valued !== undefined;
70
+ let switches = opts.switches ?? SWITCHES;
71
+ let valued = opts.valued ?? VALUED;
72
+
73
+ if (!custom) {
74
+ const cmd = detectCommand(argv);
75
+ const cmdKinds = cmd ? BY_COMMAND.get(cmd) : null;
76
+ if (cmdKinds && cmdKinds.size > 0) {
77
+ switches = new Set(SWITCHES);
78
+ valued = new Set(VALUED);
79
+ for (const [name, kind] of cmdKinds) {
80
+ if (kind === "switch") {
81
+ switches.add(name);
82
+ valued.delete(name);
83
+ } else if (kind === "value") {
84
+ valued.add(name);
85
+ switches.delete(name);
86
+ } else {
87
+ switches.delete(name);
88
+ valued.delete(name);
89
+ }
90
+ }
91
+ }
92
+ }
93
+
46
94
  const flags = {};
47
95
  const rest = [];
48
96
  for (let i = 0; i < argv.length; i++) {
49
97
  const a = argv[i];
98
+ if (a === "--") {
99
+ flags["--"] = argv.slice(i + 1);
100
+ break;
101
+ }
50
102
  if (a.startsWith("--")) {
103
+ const eq = a.indexOf("=");
104
+ if (eq > 2) {
105
+ const key = a.slice(2, eq);
106
+ const val = a.slice(eq + 1);
107
+ flags[key] = REPEATABLE.has(key) ? [...(flags[key] || []), val] : val;
108
+ continue;
109
+ }
51
110
  const key = a.slice(2);
52
111
  const next = argv[i + 1];
53
112
  const takes = valued.has(key) ? next !== undefined && !next.startsWith("--") : next && !next.startsWith("-");
@@ -74,6 +74,16 @@
74
74
  "type": "true or false",
75
75
  "values": null
76
76
  },
77
+ {
78
+ "clear_word": null,
79
+ "default": [],
80
+ "doc": "Words that give a knowledge section priority when one is in its title or opening words, as a whole word (case aside). A priority section is the last related section cut when space runs out, and comes with a longer excerpt. Write each form you use (Rule, Rules). Whole documents can be marked priority too: `oalo bots knowledge <bot> --priority <document>`. Comma-separated; empty is none.",
81
+ "effect": "rebuilds the knowledge graph, if the bot has one",
82
+ "group": "knowledge",
83
+ "key": "priority_words",
84
+ "type": "list",
85
+ "values": null
86
+ },
77
87
  {
78
88
  "clear_word": null,
79
89
  "default": "retrieval",
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
 
@@ -10,6 +10,7 @@ import { dim } from "../events.js";
10
10
  * oalo bots list them
11
11
  * oalo bots knowledge <bot> what it can search, and what else could be attached
12
12
  * oalo bots knowledge <bot> --add <source> [--remove <source>]
13
+ * oalo bots knowledge <bot> --priority <document> [--no-priority <document>]
13
14
  * oalo bots tools <bot> [--add <tool>] [--remove <tool>] the tools it may call
14
15
  * oalo bots settings <bot> every setting and its value
15
16
  * oalo bots settings <bot> set key=value ... [--yes] [--dry-run]
@@ -57,7 +58,7 @@ export async function bots(flags, rest, opts = {}) {
57
58
 
58
59
  const USAGE = [
59
60
  "usage: oalo bots [--json]",
60
- " oalo bots knowledge <bot> [--add <source>] [--remove <source>] [--json]",
61
+ " oalo bots knowledge <bot> [--add <source>] [--remove <source>] [--priority <document>] [--no-priority <document>] [--json]",
61
62
  " oalo bots tools <bot> [--add <tool>] [--remove <tool>] [--json]",
62
63
  " oalo bots settings <bot> [--json]",
63
64
  " oalo bots settings <bot> set key=value [key=value ...] [--yes] [--dry-run]",
@@ -83,10 +84,18 @@ const searches = (list) => (list.length ? `${list.join(", ")}, and its own knowl
83
84
  async function knowledge(ch, botId, flags) {
84
85
  if (!/^bot_[A-Za-z0-9_-]+$/.test(botId)) return fail(`name the bot by its public id (bot_...), as \`oalo bots\` prints it (got ${botId})`, 2);
85
86
 
86
- const [{ bot }, { sources: available = [] }] = await Promise.all([
87
+ const [{ bot }, { sources: available = [] }, docsReply] = await Promise.all([
87
88
  ch.call("chat:bots:get", { id: botId }),
88
89
  ch.call("chat:bots:search_sources_available", {}),
90
+ ch.call("chat:bots:knowledge:list", { bot_id: botId }),
89
91
  ]);
92
+ let docs = docsReply?.sources || [];
93
+
94
+ // Priority documents, by id or name. Resolved before anything changes, so a
95
+ // name that doesn't match changes nothing.
96
+ const marks = [...values(flags.priority).map((n) => [n, true]), ...values(flags["no-priority"]).map((n) => [n, false])];
97
+ const marked = marks.map(([n, on]) => [findDoc(n, docs), on]);
98
+
90
99
  const attached = Array.isArray(bot.search_sources) ? bot.search_sources : [];
91
100
  const adds = values(flags.add), removes = values(flags.remove);
92
101
 
@@ -104,7 +113,25 @@ async function knowledge(ch, botId, flags) {
104
113
  }
105
114
  }
106
115
 
107
- if (flags.json) return void console.log(JSON.stringify({ bot: botId, name: bot.name, search_sources: now, available }, null, 2));
116
+ const priorityNotes = [];
117
+ for (const [doc, on] of marked) {
118
+ if (doc.priority === on) {
119
+ priorityNotes.push(`${docName(doc)} ${on ? "already has" : "already doesn't have"} priority`);
120
+ continue;
121
+ }
122
+ const r = await ch.call("chat:bots:knowledge:set_priority", { source_id: doc.id, priority: on });
123
+ const saved = r?.source || { ...doc, priority: on };
124
+ docs = docs.map((d) => (d.id === doc.id ? { ...d, ...saved } : d));
125
+ priorityNotes.push(`${on ? "marked" : "unmarked"} ${docName(doc)} ${on ? "priority" : "(no priority)"}`);
126
+ }
127
+
128
+ const words = Array.isArray(bot.priority_words) ? bot.priority_words : [];
129
+ if (flags.json) {
130
+ const documents = docs.map((d) => ({ id: d.id, name: docName(d), status: d.status, priority: d.priority === true }));
131
+ return void console.log(JSON.stringify({ bot: botId, name: bot.name, search_sources: now, available, documents, priority_words: words }, null, 2));
132
+ }
133
+ for (const n of priorityNotes) console.log(n);
134
+ if (priorityNotes.length) console.log("");
108
135
 
109
136
  const added = now.filter((h) => !attached.includes(h)), removed = attached.filter((h) => !now.includes(h));
110
137
  for (const h of added) console.log(`attached ${h} to ${bot.name}`);
@@ -119,6 +146,12 @@ async function knowledge(ch, botId, flags) {
119
146
  console.log(`${bot.name} (${botId}) searches its own knowledge base${now.length ? ", and:" : " only."}`);
120
147
  for (const h of now) console.log(` ${h}${about.get(h) ? dim(` ${about.get(h)}`) : about.has(h) ? "" : dim(" (no longer vectorized: searched as nothing)")}`);
121
148
 
149
+ if (docs.length) {
150
+ console.log(`\nDocuments (${docs.length}):`);
151
+ for (const d of docs) console.log(` ${d.id} ${docName(d)}${d.priority ? " priority" : ""}${d.status && d.status !== "ready" ? dim(` ${d.status}`) : ""}`);
152
+ console.log(dim(`Priority words: ${words.length ? words.join(", ") : "none"} (oalo bots settings ${botId} set priority_words=...). Mark a document: --priority <id or name>.`));
153
+ }
154
+
122
155
  const others = available.filter((s) => !now.includes(s.handle));
123
156
  if (others.length) {
124
157
  console.log(dim(`\nCan also attach (--add):`));
@@ -135,7 +168,47 @@ async function knowledge(ch, botId, flags) {
135
168
  // document keeps it current. How answers use it is in `oalo bots settings`.
136
169
  async function graph(ch, botId, flags) {
137
170
  if (!/^bot_[A-Za-z0-9_-]+$/.test(botId)) return fail(`name the bot by its public id (bot_...), as \`oalo bots\` prints it (got ${botId})`, 2);
138
- if (flags.build && flags.reset) return fail("--build or --reset, not both", 2);
171
+ const modes = ["build", "reset", "search", "export", "import", "resync"].filter((k) => flags[k] !== undefined && flags[k] !== false);
172
+ if (modes.length > 1) return fail(`use one graph action at a time (got --${modes.join(", --")})`, 2);
173
+
174
+ if (flags.search !== undefined) {
175
+ if (typeof flags.search !== "string" || !flags.search.trim()) return fail("--search needs a keyword query", 2);
176
+ const r = await ch.call("kg:search", { bot_id: botId, query: flags.search.trim() });
177
+ const results = r.results || [];
178
+ if (flags.json) return void console.log(JSON.stringify(results, null, 2));
179
+ if (!results.length) return void console.log(`${botId}: no graph nodes matched "${flags.search.trim()}"`);
180
+ for (const n of results) {
181
+ const kind = n.kind ? ` [${n.kind}]` : "";
182
+ const summary = n.summary ? ` ${dim(String(n.summary).replace(/\s+/g, " ").slice(0, 120))}` : "";
183
+ console.log(`${n.id} ${n.title || "(untitled)"}${kind}${summary}`);
184
+ }
185
+ return;
186
+ }
187
+
188
+ if (flags.export) {
189
+ const r = await ch.call("kg:export", { bot_id: botId }, 120_000);
190
+ return void console.log(JSON.stringify(r, null, 2));
191
+ }
192
+
193
+ if (flags.import !== undefined) {
194
+ if (typeof flags.import !== "string" || !flags.import.trim()) return fail("--import needs a JSON file path", 2);
195
+ let payload;
196
+ try {
197
+ payload = JSON.parse(readFileSync(flags.import, "utf8"));
198
+ } catch (e) {
199
+ return fail(`can't read ${flags.import}: ${e.message}`, 2);
200
+ }
201
+ if (!payload || !Array.isArray(payload.nodes)) return fail(`${flags.import} must be a JSON object with a "nodes" array`, 2);
202
+ const r = await ch.call("kg:import", { bot_id: botId, nodes: payload.nodes, edges: Array.isArray(payload.edges) ? payload.edges : [] }, 120_000);
203
+ if (flags.json) return void console.log(JSON.stringify(r, null, 2));
204
+ return void console.log(`${botId}: queued graph import (${r.nodes ?? payload.nodes.length} nodes, ${r.edges ?? (payload.edges?.length || 0)} edges, job ${r.job_id ?? "?"}).`);
205
+ }
206
+
207
+ if (flags.resync) {
208
+ const r = await ch.call("kg:resync_chunks", { bot_id: botId });
209
+ if (flags.json) return void console.log(JSON.stringify(r, null, 2));
210
+ return void console.log(`${botId}: queued knowledge graph chunk resync (job ${r.job_id ?? "?"}).`);
211
+ }
139
212
 
140
213
  if (flags.reset) {
141
214
  if (!flags.yes) return fail(`--reset deletes ${botId}'s whole graph, links added by hand or imported included. Add --yes to go ahead.`, 2);
@@ -162,7 +235,7 @@ async function graph(ch, botId, flags) {
162
235
 
163
236
  // ── tools ────────────────────────────────────────────────────────────────
164
237
 
165
- const TRANSPORTS = { app: "your app", http_webhook: "webhook", builtin: "built in", wasm: "code", container_mcp: "action" };
238
+ const TRANSPORTS = { app: "your app", http_webhook: "webhook", builtin: "built in", wasm: "code", container_mcp: "action", remote_node: "machine" };
166
239
 
167
240
  // The same change as a toggle in the bot's Tools tab: the allowlist is every
168
241
  // tool on now, plus or minus these.
@@ -297,6 +370,23 @@ function format(v, s) {
297
370
  // `--add` may repeat or be comma-separated.
298
371
  const values = (v) => (v === undefined || v === true ? [] : [].concat(v).flatMap((x) => String(x).split(",")).map((s) => s.trim()).filter(Boolean));
299
372
 
373
+ // A document's name as the dashboard shows it, without its leading icon.
374
+ const docName = (d) => String(d.label || d.id).replace(/^[^\p{L}\p{N}]+\s*/u, "") || String(d.id);
375
+
376
+ // One of the bot's documents: its id, its exact name, or the one name that
377
+ // contains the words (case aside).
378
+ function findDoc(name, docs) {
379
+ const byId = docs.find((d) => String(d.id) === name);
380
+ if (byId) return byId;
381
+ const low = name.toLowerCase();
382
+ const exact = docs.filter((d) => docName(d).toLowerCase() === low);
383
+ if (exact.length === 1) return exact[0];
384
+ const some = docs.filter((d) => docName(d).toLowerCase().includes(low));
385
+ if (some.length === 1) return some[0];
386
+ if (some.length > 1) throw new Error(`${name} could be ${some.map((d) => `${d.id} (${docName(d)})`).join(" or ")}: say which by id`);
387
+ throw new Error(`${name} isn't one of this bot's documents (oalo bots knowledge <bot> lists them)`);
388
+ }
389
+
300
390
  // A handle, or a bare name when exactly one handle ends in it.
301
391
  function resolve(name, handles, what) {
302
392
  if (handles.includes(name)) return name;
@@ -177,7 +177,7 @@ async function readAll(stream) {
177
177
  return text;
178
178
  }
179
179
 
180
- export async function call(flags, rest) {
180
+ export async function call(flags, rest, opts = {}) {
181
181
  if (flags.list || flags.namespaces) {
182
182
  await list(flags, rest);
183
183
  return;
@@ -185,12 +185,23 @@ export async function call(flags, rest) {
185
185
 
186
186
  const event = rest[1];
187
187
  if (!event) {
188
- console.error("usage: oalo call <event> ['<json params>' | @file.json | -]\n");
188
+ console.error("usage: oalo call <event> ['<json params>' | @file.json | -] [--timeout <seconds>]\n");
189
189
  console.error("Run `oalo call --list` to see the events you can call.");
190
190
  process.exitCode = 2;
191
191
  return;
192
192
  }
193
193
 
194
+ let timeoutMs;
195
+ if (flags.timeout !== undefined) {
196
+ const s = Number(flags.timeout);
197
+ if (!Number.isFinite(s) || s < 1 || s > 600) {
198
+ console.error("--timeout must be a number of seconds from 1 to 600");
199
+ process.exitCode = 2;
200
+ return;
201
+ }
202
+ timeoutMs = Math.round(s * 1000);
203
+ }
204
+
194
205
  let params;
195
206
  try {
196
207
  params = await readParams(rest[2]);
@@ -211,10 +222,11 @@ export async function call(flags, rest) {
211
222
  return;
212
223
  }
213
224
 
214
- const ch = new OaloChannel({ url, token });
225
+ const make = opts.channel || ((o) => new OaloChannel(o));
226
+ const ch = make({ url, token });
215
227
  try {
216
228
  await ch.connect();
217
- const reply = await ch.call(event, params);
229
+ const reply = timeoutMs ? await ch.call(event, params, timeoutMs) : await ch.call(event, params);
218
230
  console.log(JSON.stringify(reply, null, flags.compact ? 0 : 2));
219
231
  } catch (e) {
220
232
  // The server often names the event itself ("loops:get failed: ..."); don't say it twice.