@oalo-ai/cli 0.5.0 → 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/man/oalo.1 +47 -7
- package/package.json +1 -1
- package/src/args.js +58 -7
- package/src/bot-settings.json +10 -0
- package/src/commands/bots.js +95 -5
- package/src/commands/call.js +16 -4
- package/src/commands/link.js +68 -46
- package/src/commands/login.js +1 -1
- package/src/commands/machines.js +21 -4
- package/src/commands/mcp.js +26 -2
- package/src/commands/run.js +12 -8
- package/src/coord-release.json +9 -9
- package/src/help.js +24 -7
- package/src/mcp/describe.js +2 -1
- package/src/mcp/fit.js +3 -1
- package/src/mcp/tools.js +85 -4
- package/src/serve/command.js +4 -1
- package/src/serve/config.js +2 -2
- package/src/serve/folder.js +5 -1
- package/src/serve/node.js +12 -4
package/man/oalo.1
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.TH OALO 1 "" "oalo 0.5.
|
|
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
|
|
@@ -949,7 +976,7 @@ The knowledge graph links a bot's passages: each document's sections, and the se
|
|
|
949
976
|
.PP
|
|
950
977
|
Exit codes: 0 done; 1 refused or failed; 2 bad arguments or no CLI token.
|
|
951
978
|
.SS machines
|
|
952
|
-
The computers that answer your bots from their own data, through oalo serve: list, add, revoke.
|
|
979
|
+
The computers that answer your bots from their own data, through oalo serve: list, add, revoke, allow.
|
|
953
980
|
.PP
|
|
954
981
|
\fBoalo machines [\-\-json]\fR
|
|
955
982
|
.br
|
|
@@ -957,6 +984,8 @@ The computers that answer your bots from their own data, through oalo serve: lis
|
|
|
957
984
|
.br
|
|
958
985
|
\fBoalo machines revoke <name> \-\-yes [\-\-json]\fR
|
|
959
986
|
.br
|
|
987
|
+
\fBoalo machines allow <byo\-endpoint/model> [\-\-off] [\-\-json]\fR
|
|
988
|
+
.br
|
|
960
989
|
.TP
|
|
961
990
|
\fBadd <name>\fR
|
|
962
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.
|
|
@@ -964,11 +993,17 @@ Make this computer a machine: lowercase letters, digits and hyphens, up to 40 (s
|
|
|
964
993
|
\fBrevoke <name>\fR
|
|
965
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.
|
|
966
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
|
|
967
1002
|
\fB\-\-yes\fR
|
|
968
1003
|
revoke: go ahead. Without it, revoke only says what it would do.
|
|
969
1004
|
.TP
|
|
970
1005
|
\fB\-\-json\fR
|
|
971
|
-
The machines, or what add and
|
|
1006
|
+
The machines, or what add, revoke, and allow did, as JSON.
|
|
972
1007
|
.IP \(bu 2
|
|
973
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.
|
|
974
1009
|
.IP \(bu 2
|
|
@@ -1007,7 +1042,7 @@ add: what the handler holds or answers. The bot reads it when deciding to call t
|
|
|
1007
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.
|
|
1008
1043
|
.TP
|
|
1009
1044
|
\fB\-\-timeout <seconds>\fR
|
|
1010
|
-
add command: how long the program may run, 1 to
|
|
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.
|
|
1011
1046
|
.TP
|
|
1012
1047
|
\fB\-\- <program> [args...]\fR
|
|
1013
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.
|
|
@@ -1775,6 +1810,11 @@ After each graph rebuild, a small AI model labels the links between similar pass
|
|
|
1775
1810
|
.br
|
|
1776
1811
|
Values: true or false. Default: false. Changing it uses AI credit at each graph rebuild, for the links whose pages changed.
|
|
1777
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
|
|
1778
1818
|
\fBcontext.strategy\fR
|
|
1779
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.
|
|
1780
1820
|
.br
|
package/package.json
CHANGED
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
|
|
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,12 +42,55 @@ 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
|
|
|
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
|
+
|
|
44
63
|
/**
|
|
45
|
-
* Tiny flag parser: --key value, --switch, -h. No dependency
|
|
46
|
-
* `--` ends the flags: every word after it is kept as is in
|
|
47
|
-
* (`oalo serve add command stock -- python3 stock.py --verbose`).
|
|
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`).
|
|
48
67
|
*/
|
|
49
|
-
export function parse(argv,
|
|
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
|
+
|
|
50
94
|
const flags = {};
|
|
51
95
|
const rest = [];
|
|
52
96
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -56,6 +100,13 @@ export function parse(argv, { switches = SWITCHES, valued = VALUED } = {}) {
|
|
|
56
100
|
break;
|
|
57
101
|
}
|
|
58
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
|
+
}
|
|
59
110
|
const key = a.slice(2);
|
|
60
111
|
const next = argv[i + 1];
|
|
61
112
|
const takes = valued.has(key) ? next !== undefined && !next.startsWith("--") : next && !next.startsWith("-");
|
package/src/bot-settings.json
CHANGED
|
@@ -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/commands/bots.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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;
|
package/src/commands/call.js
CHANGED
|
@@ -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
|
|
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.
|
package/src/commands/link.js
CHANGED
|
@@ -4,19 +4,20 @@ import { fetchManifest, ApiError } from "../api.js";
|
|
|
4
4
|
import { OaloChannel } from "../channel.js";
|
|
5
5
|
import { installSkill, installedSkillVersion } from "./skill.js";
|
|
6
6
|
|
|
7
|
-
export async function link(flags) {
|
|
8
|
-
if (flags.status) return status(flags);
|
|
7
|
+
export async function link(flags, opts = {}) {
|
|
8
|
+
if (flags.status) return status(flags, opts);
|
|
9
9
|
|
|
10
10
|
const serverUrl = (flags.server || process.env.OALO_URL || "").replace(/\/$/, "");
|
|
11
|
-
// After `oalo login`, the workspace's saved data token is used, so
|
|
12
|
-
// project needs only --server.
|
|
13
|
-
const token = flags.token || process.env.OALO_SYNC_TOKEN || (serverUrl && readToken({ serverUrl, appId: null }, "sync"));
|
|
11
|
+
// After `oalo login`, the workspace's saved data or CLI token is used, so
|
|
12
|
+
// linking a project needs only --server.
|
|
13
|
+
const token = flags.token || process.env.OALO_SYNC_TOKEN || (serverUrl && readToken({ serverUrl, appId: null }, "sync")) || null;
|
|
14
|
+
const cliToken = flags["cli-token"] || process.env.OALO_CLI_TOKEN || (serverUrl && readToken({ serverUrl, appId: null }, "cli")) || null;
|
|
14
15
|
|
|
15
|
-
if (!serverUrl || !token) {
|
|
16
|
+
if (!serverUrl || (!token && !cliToken)) {
|
|
16
17
|
console.error(
|
|
17
|
-
"usage: oalo link --server https://<workspace>.oalo.ai [--token <sync token>] [--app <id>] [--env dev|prod]\n\n" +
|
|
18
|
+
"usage: oalo link --server https://<workspace>.oalo.ai [--token <sync token>] [--cli-token <cli token>] [--app <id>] [--env dev|prod]\n\n" +
|
|
18
19
|
(serverUrl
|
|
19
|
-
? `No saved token for ${serverUrl}. Run \`oalo login --server ${serverUrl}\` first, or pass --token.`
|
|
20
|
+
? `No saved token for ${serverUrl}. Run \`oalo login --server ${serverUrl}\` first, or pass --token / --cli-token.`
|
|
20
21
|
: "Run `oalo login --server <url>` first, or create a connection in the dashboard under\nAccount -> CLI & agents and run the oalo link command it shows."),
|
|
21
22
|
);
|
|
22
23
|
process.exitCode = 2;
|
|
@@ -31,38 +32,38 @@ export async function link(flags) {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const config = { serverUrl: serverUrl.replace(/\/$/, ""), appId: flags.app || null, env };
|
|
35
|
+
const doManifest = opts.fetchManifest || fetchManifest;
|
|
36
|
+
const makeChannel = opts.channel || ((o) => new OaloChannel(o));
|
|
34
37
|
|
|
35
38
|
// Verify BEFORE saving anything. A link that reports success and then 403s on
|
|
36
39
|
// first real use is the worst outcome: the developer has no reason to suspect
|
|
37
40
|
// the credential and goes looking for the bug in their own code.
|
|
38
|
-
let manifest;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
let manifest = null;
|
|
42
|
+
if (token) {
|
|
43
|
+
try {
|
|
44
|
+
manifest = await doManifest({ ...config, token });
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(`link failed: ${e.message}`);
|
|
47
|
+
if (e instanceof ApiError && e.status === 403) {
|
|
48
|
+
console.error("\nThe token was accepted but lacks read scope. Mint one with read access.");
|
|
49
|
+
}
|
|
50
|
+
if (e instanceof ApiError && e.status === 401) {
|
|
51
|
+
console.error("\nThe token was rejected. It may be revoked, expired, or for another workspace.");
|
|
52
|
+
}
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
return;
|
|
48
55
|
}
|
|
49
|
-
process.exitCode = 1;
|
|
50
|
-
return;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
const models = Object.keys(manifest?.models || {});
|
|
58
|
+
const models = manifest ? Object.keys(manifest?.models || {}) : null;
|
|
54
59
|
config.schemaVersion = manifest?.schema_version ?? null;
|
|
55
60
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
// token kinds in play, pasting one where the other belongs is now the most
|
|
59
|
-
// likely mistake, and it should be caught here rather than surfacing later as
|
|
60
|
-
// a confusing channel auth failure.
|
|
61
|
-
const cliToken = flags["cli-token"] || null;
|
|
61
|
+
// Verify CLI token when explicitly passed, or when linking without a sync token.
|
|
62
|
+
const verifyCli = Boolean(cliToken && (flags["cli-token"] || !token));
|
|
62
63
|
let cliOk = null;
|
|
63
64
|
|
|
64
|
-
if (
|
|
65
|
-
const ch =
|
|
65
|
+
if (verifyCli) {
|
|
66
|
+
const ch = makeChannel({ url: config.serverUrl, token: cliToken, timeoutMs: 15000 });
|
|
66
67
|
try {
|
|
67
68
|
await ch.connect();
|
|
68
69
|
cliOk = true;
|
|
@@ -84,16 +85,21 @@ export async function link(flags) {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
writeConfig(config);
|
|
87
|
-
|
|
88
|
-
if (
|
|
88
|
+
let credPath = credentialsPath();
|
|
89
|
+
if (token) credPath = writeToken(config, token, "sync");
|
|
90
|
+
if (cliToken) credPath = writeToken(config, cliToken, "cli");
|
|
89
91
|
const addedRule = ensureGitignored();
|
|
90
92
|
|
|
91
93
|
console.log(`linked to ${config.serverUrl}`);
|
|
92
94
|
console.log(` env ${config.env}`);
|
|
93
95
|
if (config.appId) console.log(` app ${config.appId}`);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
if (manifest) {
|
|
97
|
+
console.log(` schema version ${config.schemaVersion}`);
|
|
98
|
+
console.log(` models visible ${models.length}`);
|
|
99
|
+
} else {
|
|
100
|
+
console.log(` sync token none (control-plane only; oalo pull, bots, deploy, and mcp are ready)`);
|
|
101
|
+
}
|
|
102
|
+
if (cliOk) console.log(` cli token verified (oalo mcp is ready)`);
|
|
97
103
|
console.log(`\n config .oalo/config.json (safe to commit)`);
|
|
98
104
|
console.log(` token ${credPath} (never committed)`);
|
|
99
105
|
if (addedRule) console.log(`\n added .oalo/credentials* to .gitignore`);
|
|
@@ -111,11 +117,13 @@ export async function link(flags) {
|
|
|
111
117
|
}
|
|
112
118
|
// A Flutter app from Oalo's template takes Dart, not TypeScript.
|
|
113
119
|
const flutter = existsSync("pubspec.yaml") && /^\s*flutter:/m.test(readFileSync("pubspec.yaml", "utf8"));
|
|
114
|
-
console.log(flutter ? `\nNext: oalo typegen --dart` : `\nNext: oalo typegen`);
|
|
120
|
+
console.log(!token ? `\nNext: oalo pull` : flutter ? `\nNext: oalo typegen --dart` : `\nNext: oalo typegen`);
|
|
115
121
|
}
|
|
116
122
|
|
|
117
|
-
async function status(flags) {
|
|
123
|
+
async function status(flags, opts = {}) {
|
|
118
124
|
const cfg = resolve(flags);
|
|
125
|
+
const doManifest = opts.fetchManifest || fetchManifest;
|
|
126
|
+
const makeChannel = opts.channel || ((o) => new OaloChannel(o));
|
|
119
127
|
|
|
120
128
|
if (!cfg.serverUrl) {
|
|
121
129
|
console.log("not linked. run: oalo link --server <url> --token <token>");
|
|
@@ -128,25 +136,39 @@ async function status(flags) {
|
|
|
128
136
|
if (cfg.configDir && cfg.configDir !== process.cwd()) console.log(`linked by ${cfg.configDir}/.oalo/config.json`);
|
|
129
137
|
console.log(`env ${cfg.env}`);
|
|
130
138
|
console.log(`app ${cfg.appId || "(none)"}`);
|
|
131
|
-
console.log(`sync token ${cfg.token ? "present" : "
|
|
139
|
+
console.log(`sync token ${cfg.token ? "present" : "absent"} (${credentialsPath()})`);
|
|
132
140
|
console.log(`cli token ${cfg.cliToken ? "present" : "absent (oalo mcp needs one)"}`);
|
|
133
141
|
|
|
134
|
-
if (!cfg.token) {
|
|
142
|
+
if (!cfg.token && !cfg.cliToken) {
|
|
135
143
|
process.exitCode = 1;
|
|
136
144
|
return;
|
|
137
145
|
}
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
if (cfg.token) {
|
|
148
|
+
try {
|
|
149
|
+
const m = await doManifest(cfg);
|
|
150
|
+
const models = Object.keys(m?.models || {}).length;
|
|
151
|
+
console.log(`reachable yes, schema version ${m?.schema_version}, ${models} models`);
|
|
152
|
+
if (cfg.schemaVersion != null && m?.schema_version !== cfg.schemaVersion) {
|
|
153
|
+
console.log(
|
|
154
|
+
`\nschema moved since link (${cfg.schemaVersion} -> ${m.schema_version}). re-run oalo typegen.`,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.log(`reachable NO: ${e.message}`);
|
|
159
|
+
process.exitCode = 1;
|
|
147
160
|
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const ch = makeChannel({ url: cfg.serverUrl, token: cfg.cliToken, timeoutMs: 15000 });
|
|
165
|
+
try {
|
|
166
|
+
await ch.connect();
|
|
167
|
+
console.log("reachable yes (control plane via CLI token)");
|
|
148
168
|
} catch (e) {
|
|
149
169
|
console.log(`reachable NO: ${e.message}`);
|
|
150
170
|
process.exitCode = 1;
|
|
171
|
+
} finally {
|
|
172
|
+
ch.close();
|
|
151
173
|
}
|
|
152
174
|
}
|
package/src/commands/login.js
CHANGED
|
@@ -121,7 +121,7 @@ export async function login(flags, rest = []) {
|
|
|
121
121
|
|
|
122
122
|
console.log(`\nConnected "${poll.json.name}" to ${serverUrl}.`);
|
|
123
123
|
console.log(` credentials ${path} (not in any project)`);
|
|
124
|
-
if (!poll.json.sync_token) console.log(" data token none: your access doesn't include the Sync API, so typegen and
|
|
124
|
+
if (!poll.json.sync_token) console.log(" data token none: your access doesn't include the Sync API, so typegen and data reads won't work");
|
|
125
125
|
console.log("\nNext: oalo pull (or oalo link --server ... in a project, then oalo typegen)");
|
|
126
126
|
return;
|
|
127
127
|
}
|
package/src/commands/machines.js
CHANGED
|
@@ -20,11 +20,14 @@ import { machineNameError, readMachine, writeMachine, localMachines } from "../s
|
|
|
20
20
|
export async function machines(flags, rest, opts = {}) {
|
|
21
21
|
const sub = rest[1] || "list";
|
|
22
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
|
|
23
|
+
if (!["list", "add", "revoke", "allow"].includes(sub)) return fail(`unknown machines command: ${sub}\n\n${USAGE}`, 2);
|
|
24
|
+
if (sub === "add" || sub === "revoke") {
|
|
25
25
|
const bad = machineNameError(name);
|
|
26
26
|
if (bad) return fail(`${bad}\n\n${USAGE}`, 2);
|
|
27
27
|
}
|
|
28
|
+
if (sub === "allow" && (!name || !name.startsWith("byo-"))) {
|
|
29
|
+
return fail(`expected a model id like byo-<endpoint>/<model> (from \`oalo machines\`)\n\n${USAGE}`, 2);
|
|
30
|
+
}
|
|
28
31
|
|
|
29
32
|
if (sub === "add") {
|
|
30
33
|
let local;
|
|
@@ -60,9 +63,10 @@ export async function machines(flags, rest, opts = {}) {
|
|
|
60
63
|
await ch.connect();
|
|
61
64
|
if (sub === "list") return await list(ch, url, flags);
|
|
62
65
|
if (sub === "add") return await add(ch, url, name, flags);
|
|
66
|
+
if (sub === "allow") return await allowModel(ch, name, flags);
|
|
63
67
|
return await revoke(ch, url, name, flags);
|
|
64
68
|
} catch (e) {
|
|
65
|
-
if (e.code === "admin_only") return fail(`only a workspace admin can ${sub === "add" ? "add" : "
|
|
69
|
+
if (e.code === "admin_only") return fail(`only a workspace admin can ${sub === "add" ? "add a machine" : sub === "allow" ? "override a model check" : "revoke a machine"}. Ask an admin to run it.`, 1);
|
|
66
70
|
return fail(e.message, 1);
|
|
67
71
|
} finally {
|
|
68
72
|
ch.close();
|
|
@@ -73,6 +77,7 @@ export const USAGE = [
|
|
|
73
77
|
"usage: oalo machines [--json]",
|
|
74
78
|
" oalo machines add <name>",
|
|
75
79
|
" oalo machines revoke <name> --yes",
|
|
80
|
+
" oalo machines allow <byo-endpoint/model> [--off]",
|
|
76
81
|
].join("\n");
|
|
77
82
|
|
|
78
83
|
const pathOf = (name) => `~/.oalo/serve/${name}.json`;
|
|
@@ -114,11 +119,23 @@ function printModels(models) {
|
|
|
114
119
|
const w = Math.max(...models.map((x) => x.model.length));
|
|
115
120
|
for (const x of models) {
|
|
116
121
|
const win = x.window ? `window ${Number(x.window).toLocaleString("en-US")}` : "";
|
|
117
|
-
const
|
|
122
|
+
const tag = x.allow_unverified && x.check !== "passed" ? " (override)" : "";
|
|
123
|
+
const tail = x.serving ? `bots can use: ${x.model_id}${tag}` : x.check === "running" ? "check running" : x.why || "";
|
|
118
124
|
console.log(` ${x.handler} ${x.model.padEnd(w)} ${String(x.check).padEnd(11)} ${dim([win, tail].filter(Boolean).join(", "))}`);
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
|
|
128
|
+
async function allowModel(ch, modelId, flags) {
|
|
129
|
+
const allow = !flags.off;
|
|
130
|
+
const r = await ch.call("machines:model_override", { model_id: modelId, allow });
|
|
131
|
+
if (flags.json) return void console.log(JSON.stringify(r, null, 2));
|
|
132
|
+
console.log(
|
|
133
|
+
allow
|
|
134
|
+
? `${modelId}: allowed for bots and workflows (ModelCheck override on).`
|
|
135
|
+
: `${modelId}: ModelCheck override turned off (requires passing ModelCheck to serve).`,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
122
139
|
async function add(ch, url, name, flags) {
|
|
123
140
|
const r = await ch.call("machines:add", { name });
|
|
124
141
|
const id = r?.machine?.id;
|
package/src/commands/mcp.js
CHANGED
|
@@ -40,8 +40,7 @@ export async function mcp(flags) {
|
|
|
40
40
|
|
|
41
41
|
// Connect lazily: a client may list tools without calling one, and a
|
|
42
42
|
// temporarily unreachable workspace should not stop the server from starting.
|
|
43
|
-
|
|
44
|
-
const ensureConnected = () => (connected ||= oalo.connect());
|
|
43
|
+
const ensureConnected = createLazyConnector(oalo);
|
|
45
44
|
|
|
46
45
|
const server = new Server({ name: "oalo", version: CLI_VERSION }, { capabilities: { tools: {} } });
|
|
47
46
|
|
|
@@ -106,3 +105,28 @@ export async function mcp(flags) {
|
|
|
106
105
|
await server.connect(new StdioServerTransport());
|
|
107
106
|
process.stderr.write(`oalo mcp: ready (${url})\n`);
|
|
108
107
|
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Lazy-connect helper for `oalo mcp`: caches the in-flight/resolved connect
|
|
111
|
+
* promise, and clears it + closes the failed socket on rejection so a transient
|
|
112
|
+
* outage never permanently wedges the MCP server.
|
|
113
|
+
*/
|
|
114
|
+
export function createLazyConnector(channel) {
|
|
115
|
+
let connected = null;
|
|
116
|
+
return () => {
|
|
117
|
+
if (!connected) {
|
|
118
|
+
connected = Promise.resolve()
|
|
119
|
+
.then(() => channel.connect())
|
|
120
|
+
.catch((err) => {
|
|
121
|
+
connected = null;
|
|
122
|
+
try {
|
|
123
|
+
channel.close?.();
|
|
124
|
+
} catch {
|
|
125
|
+
/* already closed */
|
|
126
|
+
}
|
|
127
|
+
throw err;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return connected;
|
|
131
|
+
};
|
|
132
|
+
}
|
package/src/commands/run.js
CHANGED
|
@@ -13,11 +13,10 @@ import { isInternal, NOISY, format, clock, dim } from "../events.js";
|
|
|
13
13
|
* chat:bots:test_message {"bot_id", "text"} -> replies stream back
|
|
14
14
|
*
|
|
15
15
|
* NOTE `run loop` fires the loop DIRECTLY. It does not exercise the loop's
|
|
16
|
-
* trigger binding
|
|
17
|
-
* submission, a real inbound message) which nothing exposes for simulation yet.
|
|
16
|
+
* trigger binding (use `oalo emit <event> --dry-run` to test trigger matching).
|
|
18
17
|
* So this proves the loop's BODY works, not that its trigger is wired.
|
|
19
18
|
*/
|
|
20
|
-
async function connect(flags) {
|
|
19
|
+
async function connect(flags, opts = {}) {
|
|
21
20
|
const cfg = resolveConfig(flags);
|
|
22
21
|
const { url, token } = controlPlane(cfg);
|
|
23
22
|
|
|
@@ -28,7 +27,8 @@ async function connect(flags) {
|
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
const make = opts.channel || ((o) => new OaloChannel(o));
|
|
31
|
+
return { ch: make({ url, token }), url, env: cfg.env };
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** Stream events for `seconds`, or until `done` says we have seen enough. */
|
|
@@ -48,7 +48,7 @@ function watch(ch, { seconds, done }) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export async function run(flags, rest) {
|
|
51
|
+
export async function run(flags, rest, opts = {}) {
|
|
52
52
|
const what = rest[1];
|
|
53
53
|
|
|
54
54
|
if (!what || !["loop", "bot"].includes(what)) {
|
|
@@ -57,7 +57,7 @@ export async function run(flags, rest) {
|
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const conn = await connect(flags);
|
|
60
|
+
const conn = await connect(flags, opts);
|
|
61
61
|
if (!conn) {
|
|
62
62
|
process.exitCode = 2;
|
|
63
63
|
return;
|
|
@@ -156,11 +156,15 @@ export async function run(flags, rest) {
|
|
|
156
156
|
|
|
157
157
|
// bot_id accepts an integer, a numeric string, or a public bot_ id — the
|
|
158
158
|
// server normalises all three at the channel boundary.
|
|
159
|
-
await ch.call("chat:bots:test_message", { bot_id: botId, text });
|
|
159
|
+
const reply = await ch.call("chat:bots:test_message", { bot_id: botId, text });
|
|
160
|
+
const convId = reply?.conversation_id ?? null;
|
|
160
161
|
console.error(dim(`sent to ${botId}; watching for ${seconds}s; ctrl-c stops`));
|
|
161
162
|
await watch(ch, {
|
|
162
163
|
seconds,
|
|
163
|
-
done: (event) =>
|
|
164
|
+
done: (event, p) => {
|
|
165
|
+
if (event !== "chat:msg:done") return false;
|
|
166
|
+
return convId == null || p?.conversation_id == null || p.conversation_id === convId;
|
|
167
|
+
},
|
|
164
168
|
});
|
|
165
169
|
} catch (e) {
|
|
166
170
|
console.error(`run failed: ${e.message}`);
|
package/src/coord-release.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.5.
|
|
2
|
+
"version": "0.5.1",
|
|
3
3
|
"targets": {
|
|
4
4
|
"darwin-arm64": {
|
|
5
5
|
"file": "oalo-coord-darwin-arm64.gz",
|
|
6
|
-
"sha256": "
|
|
7
|
-
"bytes":
|
|
6
|
+
"sha256": "d1ecd41a5d8196b0ae44ea6f4b044d966047d203f4d3d785af90c0d6bcb43777",
|
|
7
|
+
"bytes": 24859718
|
|
8
8
|
},
|
|
9
9
|
"darwin-x64": {
|
|
10
10
|
"file": "oalo-coord-darwin-x64.gz",
|
|
11
|
-
"sha256": "
|
|
12
|
-
"bytes":
|
|
11
|
+
"sha256": "d2a588a327bbbf146e65be5130b409bb457cae3a13a0cf14bbff544ff3783f7d",
|
|
12
|
+
"bytes": 26998986
|
|
13
13
|
},
|
|
14
14
|
"linux-x64": {
|
|
15
15
|
"file": "oalo-coord-linux-x64.gz",
|
|
16
|
-
"sha256": "
|
|
17
|
-
"bytes":
|
|
16
|
+
"sha256": "283db1e8de840a691616a1b0cb0392e86227d860812bb1ce061ecdb0a608ad6a",
|
|
17
|
+
"bytes": 36891347
|
|
18
18
|
},
|
|
19
19
|
"linux-arm64": {
|
|
20
20
|
"file": "oalo-coord-linux-arm64.gz",
|
|
21
|
-
"sha256": "
|
|
22
|
-
"bytes":
|
|
21
|
+
"sha256": "cfab2f2bc0347d983fc4d169b05072c790bad8a387418f54fefa5f0e8c19a908",
|
|
22
|
+
"bytes": 37131851
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
package/src/help.js
CHANGED
|
@@ -129,10 +129,11 @@ export const COMMANDS = [
|
|
|
129
129
|
name: "call",
|
|
130
130
|
summary: "Call any build-surface event directly. The escape hatch.",
|
|
131
131
|
env: "Doesn't add the project's env. An event that takes one reads only \"env\" in the params, with its own default: booking:* and metrics:query use prod, loops:run_now dev. For a draft bot's booking setup, pass \"env\": \"dev\".",
|
|
132
|
-
usage: ["oalo call <event> ['<json params>' | @file.json | -]", "oalo call --list [text] [--json]"],
|
|
132
|
+
usage: ["oalo call <event> ['<json params>' | @file.json | -] [--timeout <seconds>]", "oalo call --list [text] [--json]"],
|
|
133
133
|
flags: [
|
|
134
134
|
{ flag: "--list [text]", desc: "List the events you can call, from the workspace. With text, the matching events and the params each accepts." },
|
|
135
135
|
{ flag: "--namespaces", desc: "The events you may call, counted per namespace (what `--list` with no text shows)." },
|
|
136
|
+
{ flag: "--timeout <seconds>", desc: "How long to wait for the reply, 1 to 600. Default 30." },
|
|
136
137
|
{ flag: "--compact", desc: "Print the reply as one line of JSON." },
|
|
137
138
|
],
|
|
138
139
|
notes: [
|
|
@@ -532,20 +533,29 @@ export const COMMANDS = [
|
|
|
532
533
|
"oalo bots [--json]",
|
|
533
534
|
"oalo bots knowledge <bot> [--json]",
|
|
534
535
|
"oalo bots knowledge <bot> --add <source> [--add ...] [--remove <source>] [--json]",
|
|
536
|
+
"oalo bots knowledge <bot> --priority <document> [--no-priority <document>] [--json]",
|
|
535
537
|
"oalo bots tools <bot> [--add <tool>] [--remove <tool>] [--json]",
|
|
536
538
|
"oalo bots settings <bot> [--json]",
|
|
537
539
|
"oalo bots settings <bot> set key=value [key=value ...] [--yes] [--dry-run] [--json]",
|
|
538
540
|
"oalo bots settings --explain [<key> | <group>] [--json]",
|
|
539
|
-
"oalo bots graph <bot> [--build] [--json]",
|
|
541
|
+
"oalo bots graph <bot> [--build | --resync | --export] [--json]",
|
|
542
|
+
"oalo bots graph <bot> --search <query> [--json]",
|
|
543
|
+
"oalo bots graph <bot> --import <file.json> [--json]",
|
|
540
544
|
"oalo bots graph <bot> --reset --yes [--json]",
|
|
541
545
|
],
|
|
542
546
|
flags: [
|
|
543
547
|
{ flag: "tools --add <tool>", desc: "Let the bot call one of the workspace's tools, by name. Your server apps' own endpoints are listed once a deploy reads their .oalo/app.json (see `oalo docs app-tools`). --remove takes it away." },
|
|
544
548
|
{ flag: "--add <source>", desc: "knowledge: attach a searchable table: its handle (model:products, table:prod.faq) or just its name when that's unique. Repeat it, or comma-separate." },
|
|
545
549
|
{ flag: "--remove <source>", desc: "Detach one. The table stays searchable for other bots." },
|
|
550
|
+
{ flag: "--priority <document>", desc: "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." },
|
|
551
|
+
{ flag: "--no-priority <document>", desc: "knowledge: unmark a priority document." },
|
|
546
552
|
{ flag: "set key=value", desc: "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." },
|
|
547
553
|
{ flag: "--yes", desc: "settings set: apply to a published bot. Without it a published bot's change is shown and not saved. graph --reset: go ahead." },
|
|
548
554
|
{ flag: "--build", desc: "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." },
|
|
555
|
+
{ flag: "--search <query>", desc: "graph: keyword/substring search over the bot's knowledge graph nodes." },
|
|
556
|
+
{ flag: "--export", desc: "graph: print the bot's knowledge graph as import-compatible JSON ({nodes, edges})." },
|
|
557
|
+
{ flag: "--import <file>", desc: "graph: queue a bulk import from a JSON file with {nodes, edges?}." },
|
|
558
|
+
{ flag: "--resync", desc: "graph: queue a chunk resync to refresh retrieval embeddings from the current graph content." },
|
|
549
559
|
{ flag: "--reset", desc: "graph: delete the whole graph, links added by hand or imported included. Needs --yes." },
|
|
550
560
|
{ flag: "--dry-run", desc: "settings set: show what would change; save nothing." },
|
|
551
561
|
{ flag: "--explain [key]", desc: "settings: what each setting does, its values and default. A key, a group (knowledge, memory, model, replies, limits, data) or all." },
|
|
@@ -553,7 +563,7 @@ export const COMMANDS = [
|
|
|
553
563
|
],
|
|
554
564
|
notes: [
|
|
555
565
|
"<bot> is the bot's public id (bot_...), as `oalo bots` prints it.",
|
|
556
|
-
"A source is a table made searchable with `oalo data vectorize <table> --fields ...`. A bot always searches its own knowledge base (documents) too.",
|
|
566
|
+
"A source is a table made searchable with `oalo data vectorize <table> --fields ...`. A bot always searches its own knowledge base (documents) too. knowledge lists those documents, and which have priority.",
|
|
557
567
|
"The same as ticking a table in the bot's Knowledge pane in the dashboard, with the same access as there.",
|
|
558
568
|
"settings go through the dashboard's own actions, with the same checks and access. A change sets only the settings it names: the model without the provider keeps the provider, one limit keeps the others, one context.* key keeps the rest of the context config.",
|
|
559
569
|
"Every setting is described in `man oalo` (BOT SETTINGS) and by `oalo bots settings --explain`.",
|
|
@@ -563,13 +573,20 @@ export const COMMANDS = [
|
|
|
563
573
|
},
|
|
564
574
|
{
|
|
565
575
|
name: "machines",
|
|
566
|
-
summary: "The computers that answer your bots from their own data, through oalo serve: list, add, revoke.",
|
|
567
|
-
usage: [
|
|
576
|
+
summary: "The computers that answer your bots from their own data, through oalo serve: list, add, revoke, allow.",
|
|
577
|
+
usage: [
|
|
578
|
+
"oalo machines [--json]",
|
|
579
|
+
"oalo machines add <name> [--json]",
|
|
580
|
+
"oalo machines revoke <name> --yes [--json]",
|
|
581
|
+
"oalo machines allow <byo-endpoint/model> [--off] [--json]",
|
|
582
|
+
],
|
|
568
583
|
flags: [
|
|
569
584
|
{ flag: "add <name>", desc: "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." },
|
|
570
585
|
{ flag: "revoke <name>", desc: "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." },
|
|
586
|
+
{ flag: "allow <byo-endpoint/model>", desc: "Let bots and workflows use this own model without waiting for (or passing) ModelCheck. Admins only." },
|
|
587
|
+
{ flag: "--off", desc: "allow: turn the ModelCheck override back off for this model." },
|
|
571
588
|
{ flag: "--yes", desc: "revoke: go ahead. Without it, revoke only says what it would do." },
|
|
572
|
-
{ flag: "--json", desc: "The machines, or what add and
|
|
589
|
+
{ flag: "--json", desc: "The machines, or what add, revoke, and allow did, as JSON." },
|
|
573
590
|
],
|
|
574
591
|
notes: [
|
|
575
592
|
"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.",
|
|
@@ -595,7 +612,7 @@ export const COMMANDS = [
|
|
|
595
612
|
{ flag: "--machine <name>", desc: "Which machine, when this computer has more than one (`oalo machines add` made them). Every subcommand takes it." },
|
|
596
613
|
{ flag: "--describe <text>", desc: "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\"." },
|
|
597
614
|
{ flag: "--input <fields>", desc: "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." },
|
|
598
|
-
{ flag: "--timeout <seconds>", desc: "add command: how long the program may run, 1 to
|
|
615
|
+
{ flag: "--timeout <seconds>", desc: "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." },
|
|
599
616
|
{ flag: "-- <program> [args...]", desc: "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." },
|
|
600
617
|
{ flag: "--base-url <url>", desc: "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." },
|
|
601
618
|
{ flag: "--server <kind>", desc: "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." },
|
package/src/mcp/describe.js
CHANGED
|
@@ -20,7 +20,8 @@ export const TOOL_GROUPS = {
|
|
|
20
20
|
"data": ["oalo_list_models", "oalo_create_model", "oalo_read_rows", "oalo_write_rows", "oalo_promote_model", "oalo_db_query", "oalo_query_metrics", "oalo_sync_routes", "oalo_list_dashboards", "oalo_save_dashboard_widget"],
|
|
21
21
|
"code tools": ["oalo_list_functions", "oalo_generate_tool", "oalo_get_tool_source", "oalo_save_tool_source", "oalo_tool_templates", "oalo_bot_tools"],
|
|
22
22
|
"apps": ["oalo_app_logs", "oalo_releases"],
|
|
23
|
-
"channels and sales": ["oalo_widgets", "oalo_wa_templates", "oalo_rehearse_inbound", "oalo_pipelines"
|
|
23
|
+
"channels and sales": ["oalo_widgets", "oalo_wa_templates", "oalo_rehearse_inbound", "oalo_pipelines"],
|
|
24
|
+
"knowledge graph": ["oalo_knowledge_search", "oalo_knowledge_graph", "oalo_knowledge_edit"],
|
|
24
25
|
"anything else": ["oalo_call"],
|
|
25
26
|
};
|
|
26
27
|
|
package/src/mcp/fit.js
CHANGED
|
@@ -41,7 +41,9 @@ export function fitReply(result, { max = MAX_REPLY_CHARS, hint = "", offset = 0
|
|
|
41
41
|
if (lo > 0 && text.length <= max) return text;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
const note = `The whole reply is ${compact.length} characters, more than an MCP reply can hold.${hint ? ` ${hint}` : ""}`;
|
|
45
|
+
const budget = Math.max(200, max - note.length - 80);
|
|
46
|
+
return JSON.stringify({ _cut: note, total_chars: compact.length, preview: compact.slice(0, budget) });
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
/**
|
package/src/mcp/tools.js
CHANGED
|
@@ -576,13 +576,87 @@ export const TOOLS = [
|
|
|
576
576
|
},
|
|
577
577
|
{
|
|
578
578
|
name: "oalo_knowledge_search",
|
|
579
|
-
description:
|
|
580
|
-
|
|
579
|
+
description:
|
|
580
|
+
"Keyword/substring (ILIKE) search over a bot's knowledge graph node titles and summaries. Pass short keywords or topic names rather than full sentences.",
|
|
581
|
+
inputSchema: S({ bot_id: { type: "string" }, query: { type: "string", description: "Short keyword or substring to match" } }, [
|
|
581
582
|
"bot_id",
|
|
582
583
|
"query",
|
|
583
584
|
]),
|
|
584
585
|
event: "kg:search",
|
|
585
586
|
},
|
|
587
|
+
{
|
|
588
|
+
name: "oalo_knowledge_graph",
|
|
589
|
+
description:
|
|
590
|
+
"Inspect or maintain a bot's knowledge graph. Actions: counts (node/edge counts and config), roots (top-level nodes), focus (inspect node_id and its neighbors), export (full import-compatible {nodes, edges} JSON), import (queue bulk import of nodes and edges), resync (rebuild retrieval chunks from graph content), rebuild (re-derive auto graph from documents).",
|
|
591
|
+
inputSchema: S(
|
|
592
|
+
{
|
|
593
|
+
action: {
|
|
594
|
+
type: "string",
|
|
595
|
+
enum: ["counts", "roots", "focus", "export", "import", "resync", "rebuild"],
|
|
596
|
+
},
|
|
597
|
+
bot_id: { type: "string", description: "Bot public id (bot_...) or numeric id. Required for all actions except focus." },
|
|
598
|
+
node_id: { type: "string", description: "Node id for action=focus" },
|
|
599
|
+
limit: { type: "number", description: "Max neighbors for action=focus (1-100, default 40)" },
|
|
600
|
+
nodes: { type: "array", items: { type: "object" }, description: "Nodes array for action=import" },
|
|
601
|
+
edges: { type: "array", items: { type: "object" }, description: "Edges array for action=import" },
|
|
602
|
+
},
|
|
603
|
+
["action"],
|
|
604
|
+
),
|
|
605
|
+
run: async (oalo, { action, bot_id, node_id, limit, nodes, edges }) => {
|
|
606
|
+
if (action === "focus") {
|
|
607
|
+
if (!node_id) throw new Error("node_id is required for action=focus");
|
|
608
|
+
return oalo.call("kg:focus", { node_id, ...(limit != null ? { limit } : {}) });
|
|
609
|
+
}
|
|
610
|
+
if (!bot_id) throw new Error(`bot_id is required for action=${action}`);
|
|
611
|
+
if (action === "counts") {
|
|
612
|
+
const [cfg, counts] = await Promise.all([oalo.call("kg:config", { bot_id }), oalo.call("kg:counts", { bot_id })]);
|
|
613
|
+
return { ...cfg, ...counts };
|
|
614
|
+
}
|
|
615
|
+
if (action === "roots") return oalo.call("kg:roots", { bot_id });
|
|
616
|
+
if (action === "export") return oalo.call("kg:export", { bot_id }, 120_000);
|
|
617
|
+
if (action === "import") {
|
|
618
|
+
if (!Array.isArray(nodes)) throw new Error("nodes array is required for action=import");
|
|
619
|
+
return oalo.call("kg:import", { bot_id, nodes, edges: Array.isArray(edges) ? edges : [] }, 120_000);
|
|
620
|
+
}
|
|
621
|
+
if (action === "resync") return oalo.call("kg:resync_chunks", { bot_id });
|
|
622
|
+
if (action === "rebuild") return oalo.call("kg:rebuild", { bot_id });
|
|
623
|
+
throw new Error(`unknown action: ${action}`);
|
|
624
|
+
},
|
|
625
|
+
mutates: true,
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: "oalo_knowledge_edit",
|
|
629
|
+
description:
|
|
630
|
+
"Create, update, or delete curated nodes and edges in a bot's knowledge graph. Actions: create_node, update_node, delete_node, create_edge, delete_edge.",
|
|
631
|
+
inputSchema: S(
|
|
632
|
+
{
|
|
633
|
+
action: {
|
|
634
|
+
type: "string",
|
|
635
|
+
enum: ["create_node", "update_node", "delete_node", "create_edge", "delete_edge"],
|
|
636
|
+
},
|
|
637
|
+
bot_id: { type: "string", description: "Required for create_node and create_edge" },
|
|
638
|
+
node_id: { type: "string", description: "Required for update_node and delete_node" },
|
|
639
|
+
title: { type: "string", description: "Node title" },
|
|
640
|
+
summary: { type: "string", description: "Node summary" },
|
|
641
|
+
content: { type: "string", description: "Node full content/body" },
|
|
642
|
+
kind: { type: "string", description: "Node kind (topic, section, entity, fact, ...)" },
|
|
643
|
+
from: { type: "string", description: "Source node id for create_edge / delete_edge" },
|
|
644
|
+
to: { type: "string", description: "Target node id for create_edge / delete_edge" },
|
|
645
|
+
relation: { type: "string", description: "Edge relation name for create_edge / delete_edge" },
|
|
646
|
+
weight: { type: "number", description: "Optional edge weight (default 1.0)" },
|
|
647
|
+
},
|
|
648
|
+
["action"],
|
|
649
|
+
),
|
|
650
|
+
route: ({ action, ...rest }) => {
|
|
651
|
+
if (action === "create_node") return { event: "kg:node:create", params: rest };
|
|
652
|
+
if (action === "update_node") return { event: "kg:node:update", params: rest };
|
|
653
|
+
if (action === "delete_node") return { event: "kg:node:delete", params: { node_id: rest.node_id } };
|
|
654
|
+
if (action === "create_edge") return { event: "kg:edge:create", params: rest };
|
|
655
|
+
if (action === "delete_edge") return { event: "kg:edge:delete", params: { from: rest.from, to: rest.to, relation: rest.relation } };
|
|
656
|
+
throw new Error(`unknown action: ${action}`);
|
|
657
|
+
},
|
|
658
|
+
mutates: true,
|
|
659
|
+
},
|
|
586
660
|
{
|
|
587
661
|
name: "oalo_jobs",
|
|
588
662
|
description:
|
|
@@ -799,12 +873,19 @@ export const TOOLS = [
|
|
|
799
873
|
params: { type: "object", description: "Event params" },
|
|
800
874
|
match: { type: "string", description: "Keep only the items of the reply's longest list that mention this text (any field, any case), e.g. send_email." },
|
|
801
875
|
offset: { type: "number", description: "Skip this many items of the reply's longest list (after match), to page past a cut." },
|
|
876
|
+
timeout_ms: { type: "number", description: "Optional timeout in milliseconds (1000 to 600000, default 30000) for slow events like kg:import, loops:test, or chat:bots:qa_run." },
|
|
802
877
|
},
|
|
803
878
|
["event"],
|
|
804
879
|
),
|
|
805
|
-
run: async (oalo, { event, params, match, offset }) => {
|
|
880
|
+
run: async (oalo, { event, params, match, offset, timeout_ms }) => {
|
|
806
881
|
if (!event) throw new Error("event is required");
|
|
807
|
-
|
|
882
|
+
let ms;
|
|
883
|
+
if (timeout_ms !== undefined) {
|
|
884
|
+
const n = Number(timeout_ms);
|
|
885
|
+
if (!Number.isFinite(n) || n < 1000 || n > 600_000) throw new Error("timeout_ms must be between 1000 and 600000");
|
|
886
|
+
ms = Math.round(n);
|
|
887
|
+
}
|
|
888
|
+
const reply = ms ? await oalo.call(event, params || {}, ms) : await oalo.call(event, params || {});
|
|
808
889
|
return match || offset ? narrowList(reply, { match, offset }) : reply;
|
|
809
890
|
},
|
|
810
891
|
cutHint: "Pass match=<word> to keep only the items that mention it, or offset=<n> to skip the ones shown.",
|
package/src/serve/command.js
CHANGED
|
@@ -121,7 +121,10 @@ export function runCommand(handler, input, context, { timeoutMs, env = process.e
|
|
|
121
121
|
const tail = lastLine(err);
|
|
122
122
|
const withTail = (msg) => (tail ? `${msg}: ${tail}` : msg);
|
|
123
123
|
if (timedOut) return finish({ ok: false, error: `timed out after ${limit >= 1000 ? `${Math.round(limit / 1000)}s` : `${limit} ms`}` });
|
|
124
|
-
if (tooBig)
|
|
124
|
+
if (tooBig) {
|
|
125
|
+
const maxKb = Math.round(MAX_OUTPUT_BYTES / 1024);
|
|
126
|
+
return finish({ ok: false, error: `output too large (over ${maxKb} KB, max ${maxKb} KB)` });
|
|
127
|
+
}
|
|
125
128
|
if (signal) return finish({ ok: false, error: withTail(`stopped by ${signal}`) });
|
|
126
129
|
if (code !== 0) return finish({ ok: false, error: withTail(`exited with code ${code}`) });
|
|
127
130
|
const text = Buffer.concat(out).toString("utf8").trim();
|
package/src/serve/config.js
CHANGED
|
@@ -28,8 +28,8 @@ export const KINDS = ["folder", "command", "model"];
|
|
|
28
28
|
export const MODEL_SERVERS = ["ollama", "vllm", "openai"];
|
|
29
29
|
export const MAX_MODELS = 32;
|
|
30
30
|
export const DEFAULT_TIMEOUT_MS = 30000;
|
|
31
|
-
export const MAX_TIMEOUT_MS =
|
|
32
|
-
export const MAX_OUTPUT_BYTES =
|
|
31
|
+
export const MAX_TIMEOUT_MS = 3_600_000;
|
|
32
|
+
export const MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
33
33
|
|
|
34
34
|
/** The input every folder handler takes. Fixed: the bot only ever sends a query. */
|
|
35
35
|
export const FOLDER_SCHEMA = Object.freeze({
|
package/src/serve/folder.js
CHANGED
|
@@ -16,7 +16,11 @@ import { join, extname, sep } from "node:path";
|
|
|
16
16
|
* inside the folder.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export const EXTENSIONS = new Set([
|
|
19
|
+
export const EXTENSIONS = new Set([
|
|
20
|
+
".md", ".markdown", ".txt", ".csv", ".tsv", ".json", ".jsonl", ".html", ".htm",
|
|
21
|
+
".xml", ".yaml", ".yml", ".toml", ".ini", ".sql",
|
|
22
|
+
".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx", ".py", ".ex", ".exs", ".rb", ".go", ".rs", ".sh", ".css",
|
|
23
|
+
]);
|
|
20
24
|
const MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
21
25
|
const MAX_FILES = 20000;
|
|
22
26
|
const CHUNK = 800;
|
package/src/serve/node.js
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync, statSync } from "node:fs";
|
|
|
4
4
|
import { FolderIndex, runFolder } from "./folder.js";
|
|
5
5
|
import { runCommand } from "./command.js";
|
|
6
6
|
import { ModelRequests } from "./model.js";
|
|
7
|
-
import { declaration, inputError, clampTimeout, MAX_OUTPUT_BYTES, size } from "./config.js";
|
|
7
|
+
import { declaration, inputError, clampTimeout, MAX_OUTPUT_BYTES, MAX_TIMEOUT_MS, size } from "./config.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* `oalo serve`'s side of the node protocol. The machine opens an outbound
|
|
@@ -44,7 +44,12 @@ export class Handlers {
|
|
|
44
44
|
const schema = declaration(h).input_schema;
|
|
45
45
|
const bad = inputError(input, schema);
|
|
46
46
|
if (bad) return { ok: false, error: bad };
|
|
47
|
-
const
|
|
47
|
+
const isStep = context?.surface === "flow" || context?.surface === "loop";
|
|
48
|
+
const stepDeadline = Number(deadlineMs) > 0 ? Math.min(Number(deadlineMs), MAX_TIMEOUT_MS) : null;
|
|
49
|
+
const timeoutMs =
|
|
50
|
+
isStep && stepDeadline != null
|
|
51
|
+
? Math.max(clampTimeout(h.timeout_ms), stepDeadline)
|
|
52
|
+
: Math.min(clampTimeout(h.timeout_ms), stepDeadline ?? Infinity);
|
|
48
53
|
|
|
49
54
|
if (h.kind === "folder") {
|
|
50
55
|
const root = h.folder?.path;
|
|
@@ -58,11 +63,14 @@ export class Handlers {
|
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
/** The output as a result, or the size error when it's over
|
|
66
|
+
/** The output as a result, or the size error when it's over MAX_OUTPUT_BYTES. */
|
|
62
67
|
export function capOutput(r) {
|
|
63
68
|
if (!r.ok) return r;
|
|
64
69
|
const n = bytes(r.output);
|
|
65
|
-
if (n > MAX_OUTPUT_BYTES)
|
|
70
|
+
if (n > MAX_OUTPUT_BYTES) {
|
|
71
|
+
const maxKb = Math.round(MAX_OUTPUT_BYTES / 1024);
|
|
72
|
+
return { ok: false, error: `output too large (${Math.ceil(n / 1024)} KB, max ${maxKb} KB)` };
|
|
73
|
+
}
|
|
66
74
|
return r;
|
|
67
75
|
}
|
|
68
76
|
|