@oalo-ai/cli 0.4.2 → 0.4.4
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 +171 -27
- package/package.json +1 -1
- package/plugin/skills/oalo/SKILL.md +30 -7
- package/src/bot-settings.json +62 -0
- package/src/commands/bots.js +40 -3
- package/src/commands/call.js +66 -16
- package/src/commands/deploy.js +25 -2
- package/src/commands/docs.js +3 -1
- package/src/commands/emit.js +25 -6
- package/src/commands/env.js +5 -0
- package/src/commands/graphs.js +18 -7
- package/src/commands/incidents.js +24 -1
- package/src/commands/link.js +2 -0
- package/src/commands/login.js +2 -2
- package/src/commands/mcp.js +9 -26
- package/src/commands/qa.js +3 -0
- package/src/commands/run.js +19 -0
- package/src/commands/sources.js +30 -5
- package/src/commands/switches.js +68 -13
- package/src/commands/tokens.js +35 -1
- package/src/config.js +69 -6
- package/src/coord-release.json +9 -9
- package/src/data.js +14 -5
- package/src/graphfiles.js +44 -1
- package/src/help.js +96 -28
- package/src/mcp/describe.js +112 -0
- package/src/mcp/fit.js +94 -0
- package/src/mcp/tools.js +80 -29
- package/src/workspace.js +4 -3
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `oalo_describe`: orientation in one call, small enough to arrive.
|
|
3
|
+
*
|
|
4
|
+
* It used to return every app, bot (persona included) and loop (every node)
|
|
5
|
+
* whole: 97,000 characters on a real workspace, which Claude Code refused to
|
|
6
|
+
* show, so the agent got a file path instead of an answer. The default reply
|
|
7
|
+
* is now a summary (what is here, by id and name; which tool does what; how
|
|
8
|
+
* dev and prod work; what to call next; the docs index), and `section` pages
|
|
9
|
+
* through the full records of one part.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const SECTIONS = ["apps", "bots", "loops", "docs"];
|
|
13
|
+
const SUMMARY_CAP = 50;
|
|
14
|
+
const PAGE = 25;
|
|
15
|
+
|
|
16
|
+
export const TOOL_GROUPS = {
|
|
17
|
+
"look around": ["oalo_describe", "oalo_list_apps", "oalo_list_bots", "oalo_get_bot", "oalo_list_loops", "oalo_docs", "oalo_jobs"],
|
|
18
|
+
"chat flows": ["oalo_node_catalog", "oalo_list_flows", "oalo_get_flow", "oalo_lint_flow", "oalo_save_flow", "oalo_set_flow_enabled", "oalo_delete_flow", "oalo_test_conversation", "oalo_flow_runs", "oalo_get_conversation"],
|
|
19
|
+
"loops (workflows)": ["oalo_get_loop", "oalo_lint_loop", "oalo_save_loop", "oalo_loop_triggers", "oalo_test_loop", "oalo_loop_runs", "oalo_set_loop_enabled", "oalo_run_loop_now", "oalo_delete_loop", "oalo_emit", "oalo_loop_docs"],
|
|
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
|
+
"code tools": ["oalo_list_functions", "oalo_generate_tool", "oalo_get_tool_source", "oalo_save_tool_source", "oalo_tool_templates", "oalo_bot_tools"],
|
|
22
|
+
"apps": ["oalo_app_logs", "oalo_releases"],
|
|
23
|
+
"channels and sales": ["oalo_widgets", "oalo_wa_templates", "oalo_rehearse_inbound", "oalo_pipelines", "oalo_knowledge_search"],
|
|
24
|
+
"anything else": ["oalo_call"],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const ENVS =
|
|
28
|
+
"Every workspace keeps two copies of its data: dev (staging) and prod (live). A draft bot reads and writes dev, a published bot prod. " +
|
|
29
|
+
"oalo_test_loop always runs on dev; a loop's real runs (its triggers and schedules) and oalo_emit use prod. " +
|
|
30
|
+
"The data tools take env and never read the project's: oalo_read_rows, oalo_list_models and oalo_db_query default to dev, oalo_query_metrics to prod, and oalo_write_rows needs it. Pass env in every call.";
|
|
31
|
+
|
|
32
|
+
const NEXT = [
|
|
33
|
+
"Before writing a flow or loop graph: oalo_node_catalog (surface flow or loop) for the exact keys.",
|
|
34
|
+
"To change one: read it (oalo_get_flow / oalo_get_loop), lint it, save it with base_version, then test it (oalo_test_conversation / oalo_test_loop). New and changed ones stay off until the person says to turn them on.",
|
|
35
|
+
"For a feature you don't know: oalo_docs with q=<words>, then slug=<page> (the docs index is below).",
|
|
36
|
+
`The lists here are short forms. oalo_describe with section=${SECTIONS.join("|")} pages through the full records, ${PAGE} at a time (offset for the next page); oalo_get_bot and oalo_get_loop have one whole.`,
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const settle = async (p) => {
|
|
40
|
+
try {
|
|
41
|
+
return await p;
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return { error: err.message };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** `call(event, params)` is the channel's call. */
|
|
48
|
+
export async function describe(call, url, { section, offset = 0, limit = PAGE } = {}) {
|
|
49
|
+
if (section && !SECTIONS.includes(section)) throw new Error(`section is one of ${SECTIONS.join(", ")}, or none for the summary`);
|
|
50
|
+
if (section) return page(section, await fetchSection(call, section), offset, limit);
|
|
51
|
+
|
|
52
|
+
const [apps, bots, loops, docs] = await Promise.all([
|
|
53
|
+
settle(call("list_apps", {})),
|
|
54
|
+
settle(call("chat:bots:list", {})),
|
|
55
|
+
settle(call("loops:list_for_org", {})),
|
|
56
|
+
settle(call("docs:list", {})),
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
workspace: url,
|
|
61
|
+
...short("apps", apps, apps?.apps, (a) => pick({ slug: a.slug, id: a.id, name: a.name !== a.slug ? a.name : undefined, type: a.app_type, status: a.status })),
|
|
62
|
+
...short("bots", bots, bots?.bots, (b) => pick({ id: b.public_bot_id || b.id, name: b.name, status: b.status, data: b.status === "published" ? "prod" : "dev" })),
|
|
63
|
+
...short("loops", loops, loops?.entries, (l) =>
|
|
64
|
+
pick({
|
|
65
|
+
name: l.name,
|
|
66
|
+
on: l.enabled !== false,
|
|
67
|
+
app_id: l.app_id || undefined,
|
|
68
|
+
trigger: l.trigger_event || l.trigger_type || (l.cron ? `cron ${l.cron}` : undefined),
|
|
69
|
+
steps: Array.isArray(l.nodes) ? l.nodes.length : undefined,
|
|
70
|
+
last_run: l.last_status || undefined,
|
|
71
|
+
}),
|
|
72
|
+
),
|
|
73
|
+
envs: ENVS,
|
|
74
|
+
tools: TOOL_GROUPS,
|
|
75
|
+
next: NEXT,
|
|
76
|
+
docs: docs?.error ? { error: docs.error } : (docs?.docs || []).map((d) => (d.title ? `${d.slug}: ${d.title}` : d.slug)),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function fetchSection(call, section) {
|
|
81
|
+
if (section === "apps") return (await call("list_apps", {}))?.apps || [];
|
|
82
|
+
if (section === "bots") return (await call("chat:bots:list", {}))?.bots || [];
|
|
83
|
+
if (section === "loops") return (await call("loops:list_for_org", {}))?.entries || [];
|
|
84
|
+
return (await call("docs:list", {}))?.docs || [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function page(section, list, offset, limit) {
|
|
88
|
+
const from = Math.max(0, Number(offset) || 0);
|
|
89
|
+
const size = Math.min(100, Math.max(1, Number(limit) || PAGE));
|
|
90
|
+
const items = list.slice(from, from + size);
|
|
91
|
+
const next = from + items.length < list.length ? from + items.length : null;
|
|
92
|
+
return {
|
|
93
|
+
section,
|
|
94
|
+
total: list.length,
|
|
95
|
+
offset: from,
|
|
96
|
+
[section]: items,
|
|
97
|
+
...(next !== null ? { next_offset: next, more: `${list.length - next} more: call again with section=${section} offset=${next}.` } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A part of the summary: its short entries, at most SUMMARY_CAP, or the error that call gave. */
|
|
102
|
+
function short(key, reply, list, fn) {
|
|
103
|
+
if (reply?.error) return { [key]: { error: reply.error } };
|
|
104
|
+
const all = Array.isArray(list) ? list : [];
|
|
105
|
+
const out = { [key]: all.slice(0, SUMMARY_CAP).map(fn) };
|
|
106
|
+
if (all.length > SUMMARY_CAP) out[`${key}_more`] = `${all.length - SUMMARY_CAP} more: oalo_describe section=${key} offset=${SUMMARY_CAP}`;
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function pick(o) {
|
|
111
|
+
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined && v !== null && v !== ""));
|
|
112
|
+
}
|
package/src/mcp/fit.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeping MCP replies small enough to arrive.
|
|
3
|
+
*
|
|
4
|
+
* Claude Code refuses a tool result over its token limit (25,000 tokens by
|
|
5
|
+
* default) and hands the agent a file path instead of the answer. A reply
|
|
6
|
+
* that size is no use to an agent anyway, so every tool's reply goes through
|
|
7
|
+
* fitReply: pretty JSON when it fits, compact JSON when that fits, and
|
|
8
|
+
* otherwise the reply's longest list cut to as many whole items as fit, with
|
|
9
|
+
* a `_cut` note saying what was left out and how to ask for the rest. The
|
|
10
|
+
* JSON stays valid either way.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// About 15,000 tokens of JSON: well under the default limit, with room for
|
|
14
|
+
// the note and for clients that count tokens differently.
|
|
15
|
+
export const MAX_REPLY_CHARS = 60_000;
|
|
16
|
+
|
|
17
|
+
/** The reply as text an MCP client accepts. `offset` numbers the items of a list the caller already paged. */
|
|
18
|
+
export function fitReply(result, { max = MAX_REPLY_CHARS, hint = "", offset = 0 } = {}) {
|
|
19
|
+
const pretty = JSON.stringify(result, null, 2) ?? "null";
|
|
20
|
+
if (pretty.length <= max) return pretty;
|
|
21
|
+
const compact = JSON.stringify(result);
|
|
22
|
+
if (compact.length <= max) return compact;
|
|
23
|
+
|
|
24
|
+
const found = longestList(result);
|
|
25
|
+
if (found) {
|
|
26
|
+
const { path, list } = found;
|
|
27
|
+
const note = (n) =>
|
|
28
|
+
`The whole reply is ${compact.length} characters, more than an MCP reply can hold, so ${path.join(".") || "the list"} shows ${n} of its ${list.length} items` +
|
|
29
|
+
(offset ? ` (items ${offset + 1} to ${offset + n})` : "") +
|
|
30
|
+
`.${hint ? ` ${hint}` : ""}`;
|
|
31
|
+
const build = (n) => withList(result, path, list.slice(0, n), note(n));
|
|
32
|
+
// The most whole items that fit, found by halving.
|
|
33
|
+
let lo = 0;
|
|
34
|
+
let hi = list.length;
|
|
35
|
+
while (lo < hi) {
|
|
36
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
37
|
+
if (JSON.stringify(build(mid)).length <= max) lo = mid;
|
|
38
|
+
else hi = mid - 1;
|
|
39
|
+
}
|
|
40
|
+
const text = JSON.stringify(build(lo));
|
|
41
|
+
if (lo > 0 && text.length <= max) return text;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return `${compact.slice(0, max)}\n\n(cut here: the reply is ${compact.length} characters, more than an MCP reply can hold.${hint ? ` ${hint}` : ""})`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Keep only a list's items that mention `match` (any field, any case), then
|
|
49
|
+
* skip `offset` of them: oalo_call's filter for big list replies such as
|
|
50
|
+
* loops:list_tools. Returns the narrowed result, or the result as it came
|
|
51
|
+
* when it holds no list.
|
|
52
|
+
*/
|
|
53
|
+
export function narrowList(result, { match, offset = 0 } = {}) {
|
|
54
|
+
const found = longestList(result);
|
|
55
|
+
if (!found) return result;
|
|
56
|
+
const { path, list } = found;
|
|
57
|
+
const needle = typeof match === "string" && match.trim() ? match.trim().toLowerCase() : null;
|
|
58
|
+
const kept = needle ? list.filter((item) => JSON.stringify(item).toLowerCase().includes(needle)) : list;
|
|
59
|
+
const from = Math.max(0, Number(offset) || 0);
|
|
60
|
+
const page = kept.slice(from);
|
|
61
|
+
const where = path.join(".") || "the list";
|
|
62
|
+
const said = needle ? `${kept.length} of ${list.length} items in ${where} mention "${match.trim()}"` : `${where} has ${list.length} items`;
|
|
63
|
+
const note = `${said}${from ? `; these start after the first ${from}` : ""}.`;
|
|
64
|
+
return withList(result, path, page, note, "_narrowed");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The longest array at the top of a reply or one level down, by its JSON size. */
|
|
68
|
+
export function longestList(result) {
|
|
69
|
+
if (Array.isArray(result)) return { path: [], list: result };
|
|
70
|
+
if (!result || typeof result !== "object") return null;
|
|
71
|
+
let best = null;
|
|
72
|
+
let bestSize = 0;
|
|
73
|
+
const consider = (path, value) => {
|
|
74
|
+
if (!Array.isArray(value)) return;
|
|
75
|
+
const size = JSON.stringify(value).length;
|
|
76
|
+
if (size > bestSize) {
|
|
77
|
+
best = { path, list: value };
|
|
78
|
+
bestSize = size;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
for (const [k, v] of Object.entries(result)) {
|
|
82
|
+
consider([k], v);
|
|
83
|
+
if (v && typeof v === "object" && !Array.isArray(v)) for (const [k2, v2] of Object.entries(v)) consider([k, k2], v2);
|
|
84
|
+
}
|
|
85
|
+
return best;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function withList(result, path, list, note, key = "_cut") {
|
|
89
|
+
if (!path.length) return { items: list, [key]: note };
|
|
90
|
+
const copy = { ...result };
|
|
91
|
+
if (path.length === 1) copy[path[0]] = list;
|
|
92
|
+
else copy[path[0]] = { ...result[path[0]], [path[1]]: list };
|
|
93
|
+
return { [key]: note, ...copy };
|
|
94
|
+
}
|
package/src/mcp/tools.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { readToken } from "../config.js";
|
|
2
2
|
import { listModels, listRows, getRow, pushRows, deleteRows, routes, toRows, writeTokenFor, createModel, promoteModel, parseFields } from "../data.js";
|
|
3
|
+
import { describe, SECTIONS } from "./describe.js";
|
|
4
|
+
import { narrowList } from "./fit.js";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Curated MCP tools over BuilderChannel.
|
|
@@ -24,9 +26,14 @@ export const TOOLS = [
|
|
|
24
26
|
{
|
|
25
27
|
name: "oalo_describe",
|
|
26
28
|
description:
|
|
27
|
-
"
|
|
28
|
-
inputSchema: S({
|
|
29
|
-
|
|
29
|
+
"Start here. A short overview of this OALO workspace: its apps, chatbots and loops by id and name, which tool does what, how dev and prod data work, what to call next, and the docs index. With `section` (apps, bots, loops or docs): that part's full records, 25 at a time (`offset` for the next page).",
|
|
30
|
+
inputSchema: S({
|
|
31
|
+
section: { type: "string", enum: SECTIONS, description: "Omit for the summary. One part's full records, paged." },
|
|
32
|
+
offset: { type: "number", description: "With section: skip this many (next_offset of the previous page)." },
|
|
33
|
+
limit: { type: "number", description: "With section: records per page (default 25, at most 100)." },
|
|
34
|
+
}),
|
|
35
|
+
run: async (oalo, args, ctx) => describe((e, p) => oalo.call(e, p), ctx.url, args),
|
|
36
|
+
cutHint: "Pass a smaller limit, or read one whole with oalo_get_loop, oalo_get_bot or oalo_docs slug=<page>.",
|
|
30
37
|
},
|
|
31
38
|
{
|
|
32
39
|
name: "oalo_list_apps",
|
|
@@ -36,7 +43,7 @@ export const TOOLS = [
|
|
|
36
43
|
},
|
|
37
44
|
{
|
|
38
45
|
name: "oalo_list_bots",
|
|
39
|
-
description: "List the chatbots in this workspace, with their public ids.",
|
|
46
|
+
description: "List the chatbots in this workspace, with their public ids and status. A draft (unpublished) bot reads and writes dev (staging) data, a published one prod (live).",
|
|
40
47
|
inputSchema: S({}),
|
|
41
48
|
event: "chat:bots:list",
|
|
42
49
|
},
|
|
@@ -62,17 +69,20 @@ export const TOOLS = [
|
|
|
62
69
|
{
|
|
63
70
|
name: "oalo_node_catalog",
|
|
64
71
|
description:
|
|
65
|
-
"The exact JSON contract for a chat flow or a loop: every node type, the keys each one reads (required, defaults, allowed values), what each outputs, and the edge, condition and {{reference}} rules. Read this before writing or editing a flow or loop graph instead of guessing keys.",
|
|
66
|
-
inputSchema: S(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
"The exact JSON contract for a chat flow or a loop: every node type, the keys each one reads (required, defaults, allowed values), what each outputs, and the edge, condition and {{reference}} rules. Read this before writing or editing a flow or loop graph instead of guessing keys. When the whole catalog is too long for one reply, node_types comes as a list of type names and summaries: pass `node_type` (one type, or several separated by commas) for their full entries.",
|
|
73
|
+
inputSchema: S(
|
|
74
|
+
{
|
|
75
|
+
surface: { type: "string", enum: ["flow", "loop"] },
|
|
76
|
+
node_type: { type: "string", description: "Only these node types, e.g. send_email or agent_prompt,branch. Omit for the whole catalog." },
|
|
77
|
+
},
|
|
78
|
+
["surface"],
|
|
79
|
+
),
|
|
80
|
+
run: async (oalo, { surface, node_type }) => catalogPart(await oalo.call(surface === "loop" ? "loops:node_catalog" : "chat:flows:node_catalog", {}), node_type),
|
|
71
81
|
},
|
|
72
82
|
{
|
|
73
83
|
name: "oalo_save_flow",
|
|
74
84
|
description:
|
|
75
|
-
"Create or update a flow. MUTATES the live workspace. Call oalo_get_flow first: `graph` REPLACES the stored graph wholesale, so send every node and edge you want to keep, not a patch. Pass the `version` you read back as `base_version`. Without it a concurrent edit is silently overwritten; with it you get a `conflict` error and should re-read and merge. `strict` defaults to true here: the save is refused (code `invalid_graph`, with findings) while the graph has any error-level lint finding. Check with oalo_lint_flow first.",
|
|
85
|
+
"Create or update a flow. MUTATES the live workspace. Call oalo_get_flow first: `graph` REPLACES the stored graph wholesale, so send every node and edge you want to keep, not a patch. Pass the `version` you read back as `base_version`. Without it a concurrent edit is silently overwritten; with it you get a `conflict` error and should re-read and merge. `strict` defaults to true here: the save is refused (code `invalid_graph`, with findings) while the graph has any error-level lint finding. Check with oalo_lint_flow first. How the flow starts is `trigger` (with `trigger_instructions` for llm_tool) and what it is for is `goal`; each setting you leave out keeps its stored value.",
|
|
76
86
|
inputSchema: S(
|
|
77
87
|
{
|
|
78
88
|
bot_id: { type: "string", description: "Numeric id or public bot id (bot_...)" },
|
|
@@ -80,6 +90,17 @@ export const TOOLS = [
|
|
|
80
90
|
name: { type: "string" },
|
|
81
91
|
description: { type: "string" },
|
|
82
92
|
enabled: { type: "boolean", description: "Omit to keep an existing flow's state. A new flow saved without it starts off." },
|
|
93
|
+
// The names chat:bots:flows:upsert reads (@flow_save_keys). Each is
|
|
94
|
+
// written only when sent, so leaving one out keeps the stored value.
|
|
95
|
+
trigger: {
|
|
96
|
+
type: "string",
|
|
97
|
+
enum: ["llm_tool", "manual", "on_media_upload", "conversation_start"],
|
|
98
|
+
description: "How the flow starts. llm_tool (a new flow's default): the bot starts it when the conversation calls for it, as trigger_instructions say. on_media_upload: when a file arrives. manual: only from another flow (call_other_flow) or the API. conversation_start is legacy. Omit to keep an existing flow's.",
|
|
99
|
+
},
|
|
100
|
+
trigger_instructions: { type: "string", description: "For llm_tool: when the bot should start this flow, in plain words." },
|
|
101
|
+
goal: { type: "string", description: "What the flow is for, in one sentence. Every step that talks to the customer is told it." },
|
|
102
|
+
auto_start_on_open: { type: "boolean", description: "Start as soon as a web chat opens (one flow per bot). A new flow's default is false." },
|
|
103
|
+
max_cost_usd: { type: "number", description: "Spend cap per run (a new flow's default is 1.0). A run that goes over halts." },
|
|
83
104
|
// The server reads params["graph"], NOT top-level nodes/edges. Getting
|
|
84
105
|
// this wrong writes an EMPTY graph over a real flow without erroring.
|
|
85
106
|
graph: {
|
|
@@ -207,7 +228,7 @@ export const TOOLS = [
|
|
|
207
228
|
type: { type: "string", enum: ["event", "scheduled", "exit", "date_field", "widget_submit", "api"] },
|
|
208
229
|
event: { type: "string" },
|
|
209
230
|
cron: { type: "string" },
|
|
210
|
-
filter: { type: "object", description: "Top-level payload equality, e.g. {\"channel\": \"instagram\"}" },
|
|
231
|
+
filter: { type: "object", description: "Top-level payload equality, e.g. {\"channel\": \"instagram\"}. A bot_id value matches the bot's public id (bot_...) or its number. oalo_emit with dry_run=true checks it." },
|
|
211
232
|
batch_size: { type: "number" },
|
|
212
233
|
widget_id: { type: "string" },
|
|
213
234
|
description: { type: "string", description: "api: what the call does, for the app's developer" },
|
|
@@ -224,7 +245,7 @@ export const TOOLS = [
|
|
|
224
245
|
{
|
|
225
246
|
name: "oalo_test_loop",
|
|
226
247
|
description:
|
|
227
|
-
"Test a loop and get each step's output. Every step runs, but steps that send messages or change records (email, WhatsApp, SMS, CRM, bookings) are simulated: their output says what they would have done. Custom tools and AI steps run for real. Works on a loop that is off. Input: `sample` \"latest\" uses the loop's most recent real event, \"example\" builds one from its trigger's fields, or pass `input` yourself (an event envelope {type, contact_id, payload}, or the fields a scheduled loop's first step reads); none for a manual or scheduled loop. Waits for the run, up to 3 minutes. Test after every change, before turning a loop on.",
|
|
248
|
+
"Test a loop and get each step's output. Every step runs, but steps that send messages or change records (email, WhatsApp, SMS, CRM, bookings) are simulated: their output says what they would have done. Custom tools and AI steps run for real. Works on a loop that is off. Input: `sample` \"latest\" uses the loop's most recent real event, \"example\" builds one from its trigger's fields, or pass `input` yourself (an event envelope {type, contact_id, payload}, or the fields a scheduled loop's first step reads); none for a manual or scheduled loop. Waits for the run, up to 3 minutes. Test after every change, before turning a loop on. A test always runs on dev (staging) data; real runs from triggers and schedules use prod.",
|
|
228
249
|
inputSchema: S(
|
|
229
250
|
{
|
|
230
251
|
name: { type: "string" },
|
|
@@ -249,7 +270,7 @@ export const TOOLS = [
|
|
|
249
270
|
name: "oalo_run_loop_now",
|
|
250
271
|
description:
|
|
251
272
|
"Start a loop run now, for real, without waiting for its trigger. MUTATES: its steps send real messages and change real records. To check what a loop does, use oalo_test_loop instead; run one now only when the person asks.",
|
|
252
|
-
inputSchema: S({ name: { type: "string" }, app_id: { type: "string" }, env: { type: "string", enum: ["dev", "prod"] } }, ["name"]),
|
|
273
|
+
inputSchema: S({ name: { type: "string" }, app_id: { type: "string" }, env: { type: "string", enum: ["dev", "prod"], description: "Which env's data the run uses: dev (staging, the default) or prod (live). Pass it." } }, ["name"]),
|
|
253
274
|
event: "loops:run_now",
|
|
254
275
|
mutates: true,
|
|
255
276
|
},
|
|
@@ -412,7 +433,7 @@ export const TOOLS = [
|
|
|
412
433
|
inputSchema: S(
|
|
413
434
|
{
|
|
414
435
|
app: { type: "string", description: "The app's slug (oalo_list_apps)" },
|
|
415
|
-
env: { type: "string", enum: ["dev", "prod"] },
|
|
436
|
+
env: { type: "string", enum: ["dev", "prod"], description: "dev (the preview, the default) or prod (the live app)" },
|
|
416
437
|
process: { type: "string", description: "Only this process: web, a worker's name, release or oalo" },
|
|
417
438
|
limit: { type: "number", description: "Recent lines, default 200" },
|
|
418
439
|
},
|
|
@@ -468,7 +489,7 @@ export const TOOLS = [
|
|
|
468
489
|
{
|
|
469
490
|
name: "oalo_test_conversation",
|
|
470
491
|
description:
|
|
471
|
-
"Run a scripted test conversation with a bot and get the transcript: the bot's replies per message, flow state (where a flow is and what it waits for), the path of flow steps, every step with its status and output (`steps`), and the cost. Use it after saving a flow to check it behaves. `channel` makes the bot act as that channel (whatsapp/instagram/sms = text mode); on whatsapp and sms the test customer arrives with a fictional phone on file, as a real one does. With `flow`, the bot can also start that flow again on a later message, even while it is off. The conversation is a hidden preview and nothing is sent to customers, but the bot's tools and flows run for real
|
|
492
|
+
"Run a scripted test conversation with a bot and get the transcript: the bot's replies per message, flow state (where a flow is and what it waits for), the path of flow steps, every step with its status and output (`steps`), and the cost. Use it after saving a flow to check it behaves. `channel` makes the bot act as that channel (whatsapp/instagram/sms = text mode); on whatsapp and sms the test customer arrives with a fictional phone on file, as a real one does. With `flow`, the bot can also start that flow again on a later message, even while it is off. The conversation is a hidden preview and nothing is sent to customers, but the bot's tools and flows run for real and handoffs happen. It only sends text: it can't fill in or submit a web form or tap a widget. Collected contact details reach a contact only when the test chat has one linked; a whatsapp or sms test contact is removed when the run ends. The bot uses its own env in a test too: a draft bot reads and writes dev (staging) tables and booking data, a published bot prod (live), so set up a draft bot's data in dev. Takes a while: each message waits until the bot settles.",
|
|
472
493
|
inputSchema: S(
|
|
473
494
|
{
|
|
474
495
|
bot_id: { type: "string", description: "Numeric id or public bot id (bot_...)" },
|
|
@@ -485,7 +506,7 @@ export const TOOLS = [
|
|
|
485
506
|
{
|
|
486
507
|
name: "oalo_rehearse_inbound",
|
|
487
508
|
description:
|
|
488
|
-
"Rehearse inbound WhatsApp conversations end to end and get a report per scenario: what the customer was sent, which thread and bot it ended on, the triage loop runs and their steps, pass/fail checks and, when nothing was sent, why. A fictional 555-01XX customer writes to one of the workspace's numbers through the real inbound path (routing, triage, moves, the bot's reply). Nothing is sent to WhatsApp, the threads stay out of the Inbox and the team gets no notices; LLM calls are real. `suite: true` runs the standard scenarios (new customer, known contact with a thread open on another number, returning the same day, after 24 hours, deal won earlier, writes again after opting out, handed to a teammate, with a teammate writing from another number). Takes minutes.",
|
|
509
|
+
"Rehearse inbound WhatsApp conversations end to end and get a report per scenario: what the customer was sent, which thread and bot it ended on, the triage loop runs and their steps, pass/fail checks and, when nothing was sent, why. A fictional 555-01XX customer writes to one of the workspace's numbers through the real inbound path (routing, triage, moves, the bot's reply). Nothing is sent to WhatsApp, the threads stay out of the Inbox and the team gets no notices; LLM calls are real. The answering bot uses its own env (dev while a draft, prod once published). `suite: true` runs the standard scenarios (new customer, known contact with a thread open on another number, returning the same day, after 24 hours, deal won earlier, writes again after opting out, handed to a teammate, with a teammate writing from another number). Takes minutes.",
|
|
489
510
|
inputSchema: S(
|
|
490
511
|
{
|
|
491
512
|
suite: { type: "boolean", description: "Run the standard scenarios" },
|
|
@@ -572,7 +593,7 @@ export const TOOLS = [
|
|
|
572
593
|
{
|
|
573
594
|
name: "oalo_emit",
|
|
574
595
|
description:
|
|
575
|
-
"Fire a domain event (form.submitted, order.created, whatsapp.inbound, ...) through the real event bus, to test that a loop's trigger and payload filter are wired. Unlike running a loop directly, this goes through the trigger. The loops it fires run for real and can send email or WhatsApp to real contacts, so call with dry_run=true first: that returns
|
|
596
|
+
"Fire a domain event (form.submitted, order.created, whatsapp.inbound, ...) through the real event bus, to test that a loop's trigger and payload filter are wired. Unlike running a loop directly, this goes through the trigger. The loops it fires run for real, on prod (live) data, and can send email or WhatsApp to real contacts, so call with dry_run=true first: that changes nothing and returns `loops` (would fire), `off` (would match, but the loop or its trigger is off) and `filtered_out` (listening for the type, but the trigger's filter doesn't match this payload, with the filter), so it checks a filter on a loop that is off too. Event types and their payload fields: oalo_loop_triggers action=catalog. Admins and members with Developer access only. Events are tagged as coming from the CLI and posted to the team feed.",
|
|
576
597
|
inputSchema: S(
|
|
577
598
|
{
|
|
578
599
|
type: { type: "string", description: "Event type, e.g. form.submitted" },
|
|
@@ -603,8 +624,8 @@ export const TOOLS = [
|
|
|
603
624
|
{
|
|
604
625
|
name: "oalo_list_models",
|
|
605
626
|
description:
|
|
606
|
-
"The workspace's data models (tables): fields and types, whether rows are shared or owned per app user (owner_field). Call this before reading or writing rows, and before creating a model, to reuse one that exists. Every workspace has two schemas with the same models: dev (a sandbox) and prod (
|
|
607
|
-
inputSchema: S({ env: { type: "string", enum: ["dev", "prod"], description: "
|
|
627
|
+
"The workspace's data models (tables): fields and types, whether rows are shared or owned per app user (owner_field). Call this before reading or writing rows, and before creating a model, to reuse one that exists. Every workspace has two schemas with the same models: dev (staging, a sandbox; draft bots read it) and prod (live: live apps and published bots read it).",
|
|
628
|
+
inputSchema: S({ env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live). Models are the same in both." } }),
|
|
608
629
|
run: async (_oalo, { env }, ctx) => listModels(readSide(ctx, env)),
|
|
609
630
|
},
|
|
610
631
|
{
|
|
@@ -634,12 +655,12 @@ export const TOOLS = [
|
|
|
634
655
|
{
|
|
635
656
|
name: "oalo_read_rows",
|
|
636
657
|
description:
|
|
637
|
-
"Read rows from an Oalo model (a table an app made itself isn't one: use oalo_db_query). With id: one row. Otherwise a page in write order: pass since=<next_since> from the previous page to continue while has_more is true. Each row is {id, document, owner_id, availability, product_id, seqnum, ...}; the fields are in document. Read-only.",
|
|
658
|
+
"Read rows from an Oalo model (a table an app made itself isn't one: use oalo_db_query). With id: one row. Otherwise a page in write order: pass since=<next_since> from the previous page to continue while has_more is true. Each row is {id, document, owner_id, availability, product_id, seqnum, ...}; the fields are in document. Pass env: the project's env is not read, and the default is dev. Read-only.",
|
|
638
659
|
inputSchema: S(
|
|
639
660
|
{
|
|
640
661
|
table: { type: "string" },
|
|
641
662
|
id: { type: "string", description: "One row by id" },
|
|
642
|
-
env: { type: "string", enum: ["dev", "prod"], description: "
|
|
663
|
+
env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live). A draft bot's data is in dev, a published bot's in prod." },
|
|
643
664
|
since: { type: "integer", description: "Continue after this seqnum (next_since of the previous page)" },
|
|
644
665
|
limit: { type: "integer", description: "Rows per page (default 500, max 5000)" },
|
|
645
666
|
},
|
|
@@ -657,7 +678,7 @@ export const TOOLS = [
|
|
|
657
678
|
inputSchema: S(
|
|
658
679
|
{
|
|
659
680
|
sql: { type: "string", description: "One statement" },
|
|
660
|
-
env: { type: "string", enum: ["dev", "prod"], description: "
|
|
681
|
+
env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live)" },
|
|
661
682
|
limit: { type: "integer", description: "Rows, default 100, at most 1000" },
|
|
662
683
|
},
|
|
663
684
|
["sql"],
|
|
@@ -681,7 +702,7 @@ export const TOOLS = [
|
|
|
681
702
|
inputSchema: S({
|
|
682
703
|
source: { type: "string", enum: ["model", "event", "contact"], description: "Default model (give table)." },
|
|
683
704
|
table: { type: "string" },
|
|
684
|
-
env: { type: "string", enum: ["prod", "dev"], description: "A model's live
|
|
705
|
+
env: { type: "string", enum: ["prod", "dev"], description: "A model's rows: prod (live, the default) or dev (staging: what tests and draft bots wrote). Events and contacts have one copy." },
|
|
685
706
|
event: { type: "string", description: "An event type such as order.created; leave it out for every type." },
|
|
686
707
|
measure: { type: "string", enum: ["count", "sum", "avg", "min", "max", "distinct"], description: "Default count. sum, avg, min and max read field as a number." },
|
|
687
708
|
field: { type: "string" },
|
|
@@ -703,7 +724,7 @@ export const TOOLS = [
|
|
|
703
724
|
{
|
|
704
725
|
name: "oalo_save_dashboard_widget",
|
|
705
726
|
description:
|
|
706
|
-
"Put a chart on a dashboard so it stays and updates by itself: the way to answer \"add a chart\", \"track X\" or \"put Y on the dashboard\". Adds the widget, or replaces the one with the same title; the dashboard is made when none has that name (app attaches a new one to an app). The query runs first: one that fails is refused with the reason, a saved one returns its numbers. kind: number (compare adds the window before), line (query.every), bars (query.by), table, funnel (query.steps: event types in order, and days). MUTATES what everyone with access sees; say which dashboard you used.",
|
|
727
|
+
"Put a chart on a dashboard so it stays and updates by itself: the way to answer \"add a chart\", \"track X\" or \"put Y on the dashboard\". Adds the widget, or replaces the one with the same title; the dashboard is made when none has that name (app attaches a new one to an app). The query runs first: one that fails is refused with the reason, a saved one returns its numbers. kind: number (compare adds the window before), line (query.every), bars (query.by), table, funnel (query.steps: event types in order, and days). A chart over a model reads prod (live) unless query.env is \"dev\". MUTATES what everyone with access sees; say which dashboard you used.",
|
|
707
728
|
inputSchema: S(
|
|
708
729
|
{
|
|
709
730
|
dashboard: { type: "string", description: "The dashboard's name. Default Overview." },
|
|
@@ -723,11 +744,11 @@ export const TOOLS = [
|
|
|
723
744
|
{
|
|
724
745
|
name: "oalo_write_rows",
|
|
725
746
|
description:
|
|
726
|
-
"Upsert and/or soft-delete rows in a model. Upserts match by id: pass each row with an id (from id_field) so sending it again updates it instead of adding a copy. Fields go flat in the row ({\"id\":\"42\",\"total\":9.5}) or as {id, document:{...}}. Any number of rows; they are sent 1,000 at a time and the rate limit is waited out. Writes sync to every app on that schema at once. env is required: write to dev, check with oalo_read_rows, then oalo_promote_model copies dev to prod. Writing to prod needs confirm=true because live apps see it immediately. The first write to a table creates a write token limited to it, as the person. MUTATES data.",
|
|
747
|
+
"Upsert and/or soft-delete rows in a model. Upserts match by id: pass each row with an id (from id_field) so sending it again updates it instead of adding a copy. Fields go flat in the row ({\"id\":\"42\",\"total\":9.5}) or as {id, document:{...}}. Any number of rows; they are sent 1,000 at a time and the rate limit is waited out. Writes sync to every app on that schema at once. env is required: write to dev, check with oalo_read_rows, then oalo_promote_model copies dev to prod. Writing to prod needs confirm=true because live apps and published bots see it immediately. A draft bot reads dev. The first write to a table creates a write token limited to it, as the person. MUTATES data.",
|
|
727
748
|
inputSchema: S(
|
|
728
749
|
{
|
|
729
750
|
table: { type: "string" },
|
|
730
|
-
env: { type: "string", enum: ["dev", "prod"] },
|
|
751
|
+
env: { type: "string", enum: ["dev", "prod"], description: "Required, no default: dev (staging) or prod (live)" },
|
|
731
752
|
upsert: { type: "array", items: { type: "object" }, description: "Rows to create or update" },
|
|
732
753
|
id_field: { type: "string", description: "Which field holds each row's id (default id)" },
|
|
733
754
|
delete: { type: "array", items: { type: "string" }, description: "Ids to soft-delete (they leave synced apps)" },
|
|
@@ -771,20 +792,50 @@ export const TOOLS = [
|
|
|
771
792
|
{
|
|
772
793
|
name: "oalo_call",
|
|
773
794
|
description:
|
|
774
|
-
"Escape hatch: call any BuilderChannel event directly. The curated tools above cover normal work; use this only for something they do not reach. To find an event and its params, call event 'cli_api:events' with params {\"q\": \"<text>\"}: it lists the events you may call and the param shapes each accepts. May mutate, so check the event name before calling.",
|
|
795
|
+
"Escape hatch: call any BuilderChannel event directly. The curated tools above cover normal work; use this only for something they do not reach. To find an event and its params, call event 'cli_api:events' with params {\"q\": \"<text>\"}: it lists the events you may call and the param shapes each accepts. An event that takes \"env\" gets only what you pass: booking:* and metrics:query default to prod, so set up a draft bot's booking types and hours with \"env\": \"dev\". May mutate, so check the event name before calling. A reply too long for one answer (loops:list_tools lists every tool with its schemas) has its longest list cut, with a `_cut` note: pass `match` to keep only the items that mention a word, and `offset` to skip the ones you have seen.",
|
|
775
796
|
inputSchema: S(
|
|
776
797
|
{
|
|
777
798
|
event: { type: "string", description: "Channel event name" },
|
|
778
799
|
params: { type: "object", description: "Event params" },
|
|
800
|
+
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
|
+
offset: { type: "number", description: "Skip this many items of the reply's longest list (after match), to page past a cut." },
|
|
779
802
|
},
|
|
780
803
|
["event"],
|
|
781
804
|
),
|
|
782
|
-
|
|
805
|
+
run: async (oalo, { event, params, match, offset }) => {
|
|
806
|
+
if (!event) throw new Error("event is required");
|
|
807
|
+
const reply = await oalo.call(event, params || {});
|
|
808
|
+
return match || offset ? narrowList(reply, { match, offset }) : reply;
|
|
809
|
+
},
|
|
810
|
+
cutHint: "Pass match=<word> to keep only the items that mention it, or offset=<n> to skip the ones shown.",
|
|
783
811
|
},
|
|
784
812
|
];
|
|
785
813
|
|
|
786
814
|
export const BY_NAME = Object.fromEntries(TOOLS.map((t) => [t.name, t]));
|
|
787
815
|
|
|
816
|
+
/**
|
|
817
|
+
* The node catalog, or part of it. `node_type` keeps those types' full
|
|
818
|
+
* entries. Without it, a catalog too long for one MCP reply lists its node
|
|
819
|
+
* types by name and summary, so the agent asks for the ones it uses.
|
|
820
|
+
*/
|
|
821
|
+
export function catalogPart(reply, nodeType, max = 50_000) {
|
|
822
|
+
const catalog = reply?.catalog;
|
|
823
|
+
if (!catalog || !Array.isArray(catalog.node_types)) return reply;
|
|
824
|
+
const all = catalog.node_types;
|
|
825
|
+
if (typeof nodeType === "string" && nodeType.trim()) {
|
|
826
|
+
const want = nodeType.split(",").map((t) => t.trim()).filter(Boolean);
|
|
827
|
+
const found = all.filter((n) => want.includes(n.type));
|
|
828
|
+
const missing = want.filter((t) => !found.some((n) => n.type === t));
|
|
829
|
+
if (!found.length) throw new Error(`no node type ${want.join(", ")} in this catalog. Its types: ${all.map((n) => n.type).join(", ")}`);
|
|
830
|
+
return { catalog: { ...catalog, node_types: found }, ...(missing.length ? { unknown_types: missing } : {}) };
|
|
831
|
+
}
|
|
832
|
+
if (JSON.stringify(reply, null, 2).length <= max) return reply;
|
|
833
|
+
return {
|
|
834
|
+
_note: "The whole catalog is too long for one reply, so node_types lists each type's name and summary. Pass node_type=<type> (or several, comma separated) for their full entries: keys, defaults and outputs.",
|
|
835
|
+
catalog: { ...catalog, node_types: all.map((n) => ({ type: n.type, ...(n.category ? { category: n.category } : {}), summary: n.summary })) },
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
|
|
788
839
|
/** The read side for data tools: the saved data token, on one schema. */
|
|
789
840
|
function readSide(ctx, env = "dev") {
|
|
790
841
|
// The project may name no workspace; then the channel connected to the one
|
package/src/workspace.js
CHANGED
|
@@ -5,9 +5,10 @@ import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "./config
|
|
|
5
5
|
* Open the build-surface channel with the linked CLI token (control plane).
|
|
6
6
|
* Falls back to the most recently linked workspace when this project has none,
|
|
7
7
|
* like `oalo run`. Returns null after printing how to link when there is no
|
|
8
|
-
* token, so commands can exit 2 without a stack trace.
|
|
8
|
+
* token, so commands can exit 2 without a stack trace. `channel` makes the
|
|
9
|
+
* channel (tests pass a stub).
|
|
9
10
|
*/
|
|
10
|
-
export async function openWorkspace(flags, command) {
|
|
11
|
+
export async function openWorkspace(flags, command, { channel = (o) => new OaloChannel(o) } = {}) {
|
|
11
12
|
const cfg = resolveConfig(flags);
|
|
12
13
|
const { url, token } = controlPlane(cfg);
|
|
13
14
|
|
|
@@ -18,7 +19,7 @@ export async function openWorkspace(flags, command) {
|
|
|
18
19
|
return null;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const ch =
|
|
22
|
+
const ch = channel({ url, token });
|
|
22
23
|
await ch.connect();
|
|
23
24
|
return { ch, url, env: cfg.env };
|
|
24
25
|
}
|