@oalo-ai/cli 0.4.3 → 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 +77 -13
- package/package.json +1 -1
- package/src/bot-settings.json +62 -0
- package/src/commands/bots.js +37 -2
- 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/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 +40 -3
- package/src/commands/tokens.js +35 -1
- package/src/config.js +69 -6
- package/src/coord-release.json +9 -9
- package/src/data.js +3 -2
- package/src/help.js +28 -12
- package/src/mcp/describe.js +112 -0
- package/src/mcp/fit.js +94 -0
- package/src/mcp/tools.js +65 -14
package/src/help.js
CHANGED
|
@@ -80,6 +80,7 @@ export const COMMANDS = [
|
|
|
80
80
|
notes: [
|
|
81
81
|
"Every token is verified against the thing it is for BEFORE anything is saved, so a bad or mixed-up token fails here rather than later.",
|
|
82
82
|
"Writes .oalo/config.json (safe to commit) and ~/.oalo/credentials.json (mode 0600, never in the project). OALO_HOME relocates the credential store.",
|
|
83
|
+
"Commands in a subfolder use the nearest .oalo/config.json above them, up to the git repository's root (as git finds its own folder). A link outside the repository (a parent folder, or the repository holding a nested one) is never used, since it may be another workspace's; the \"which workspace\" error names it, and `oalo link` in the subfolder or --server settles it. `oalo link --status` says which file is used.",
|
|
83
84
|
"Also installs the Oalo skill for coding agents (.claude/skills/oalo/SKILL.md), or refreshes it, from this CLI version; an AGENTS.md section from `oalo skill --agents` is refreshed too.",
|
|
84
85
|
],
|
|
85
86
|
exits: { 0: "linked", 1: "verification failed", 2: "missing or invalid arguments" },
|
|
@@ -150,14 +151,17 @@ export const COMMANDS = [
|
|
|
150
151
|
name: "run",
|
|
151
152
|
summary: "Fire a loop, or send a bot a test message, and watch what happens.",
|
|
152
153
|
env: "loop: --env dev|prod, else the project's env, else dev (a loop fired by its real trigger or schedule runs on prod). bot: no --env; the bot uses its own env, dev while it's a draft, prod once published.",
|
|
153
|
-
usage: ['oalo run loop <name> [--env dev|prod] [--watch]', 'oalo run bot <id> "<message>"'],
|
|
154
|
+
usage: ['oalo run loop <name> [--env dev|prod] [--payload \'{"email": "..."}\' | --input \'{...}\'] [--watch]', 'oalo run bot <id> "<message>"'],
|
|
154
155
|
flags: [
|
|
156
|
+
{ flag: "--payload <json>", desc: "loop: the run starts as if its event came with this payload, read as {{trigger.payload.<field>}}." },
|
|
157
|
+
{ flag: "--input <json>", desc: "loop: the trigger's whole output, as is (for a loop that reads {{trigger.<field>}} directly)." },
|
|
155
158
|
{ flag: "--watch", desc: "Stream events after firing. Default on for bots." },
|
|
156
159
|
{ flag: "--timeout <s>", desc: "How long to watch. Default 30." },
|
|
157
160
|
{ flag: "--env dev|prod", desc: "loop: which env's data it runs on. Default: the project's, else dev." },
|
|
158
161
|
{ flag: "--app <slug>", desc: "Only for a loop pinned to one app: that app's slug (`oalo apps`) or id. Loops are org-wide by default." },
|
|
159
162
|
],
|
|
160
163
|
notes: [
|
|
164
|
+
"A loop that's off doesn't run for real: `oalo loops test <name>` tries it while it's off, with sends and record changes simulated.",
|
|
161
165
|
"IMPORTANT: `run loop` fires the loop DIRECTLY and does NOT exercise its trigger binding. Triggers come from the event bus (a real form submission, a real inbound message). So this proves the loop body works; to test that its trigger is wired, use `oalo emit`.",
|
|
162
166
|
"bot ids accept an integer, a numeric string, or a public bot_ id.",
|
|
163
167
|
"Needs a CLI token.",
|
|
@@ -172,7 +176,7 @@ export const COMMANDS = [
|
|
|
172
176
|
flags: [
|
|
173
177
|
{ flag: "--payload <json>", desc: "The event's payload, a JSON object. `oalo emit --list` shows each event's fields." },
|
|
174
178
|
{ flag: "--contact <id>", desc: "An existing contact the event is about. Never creates one." },
|
|
175
|
-
{ flag: "--dry-run", desc: "
|
|
179
|
+
{ flag: "--dry-run", desc: "Emit nothing. Lists the loops it would fire, the ones that would match but are off (the loop or its trigger), and the ones listening for the type whose filter doesn't match this payload, with the filter. So it checks a filter on a loop that is kept off, too. A bot_id in a filter matches the bot's public id (bot_...) or its number." },
|
|
176
180
|
{ flag: "--list", desc: "Every event a trigger can listen for, with its payload fields and the loops listening now." },
|
|
177
181
|
{ flag: "--json", desc: "Print the reply as JSON." },
|
|
178
182
|
],
|
|
@@ -463,14 +467,14 @@ export const COMMANDS = [
|
|
|
463
467
|
env: "create: rows go to prod (live) unless you pass --env dev, and the source keeps that env (list and show name it). The project's env is not read. A --bot source has no env: its documents are live at once.",
|
|
464
468
|
usage: [
|
|
465
469
|
"oalo sources [list] [--json]",
|
|
466
|
-
"oalo sources create <name> --from <sample.csv|.json|.jsonl> [--table <new model>] [--id-field <field>] [--mode upsert|snapshot] [--auth bearer|hmac|url] [--env dev|prod]",
|
|
470
|
+
"oalo sources create <name> --from <sample.csv|.json|.jsonl> [--table <new model>] [--id-field <field>] [--records-at <path>] [--mode upsert|snapshot] [--auth bearer|hmac|url] [--env dev|prod]",
|
|
467
471
|
"oalo sources create <name> --table <existing model or table> [--fields a,b] [--id-field <field>] [--auth bearer|hmac|url]",
|
|
468
|
-
" (either form) [--keep-from-ai a,b] [--retention <days>]",
|
|
472
|
+
" (either form) [--keep-from-ai a,b] [--retention <days>] [--hmac-header <name>] [--hmac-format sha256=hex|hex|base64]",
|
|
469
473
|
"oalo sources show <name> [--json]",
|
|
470
474
|
"oalo sources create <name> --bot <bot> [--auth bearer|hmac|url]",
|
|
471
475
|
"oalo sources create <name> --from-postgres <postgres url> --relation <schema.view> [--key <column>] [--cursor <column>] [--every <minutes>] [--table <new model>] [--now]",
|
|
472
476
|
"oalo sources push <name> <file.csv|.json|.jsonl> [--json]",
|
|
473
|
-
"oalo sources push <name> <doc.pdf|.docx|.md|.html|.txt> [more...] [--json]",
|
|
477
|
+
"oalo sources push <name> <doc.pdf|.docx|.md|.html|.txt> [more...] [--prune] [--json]",
|
|
474
478
|
"oalo sources remove <name> <document>",
|
|
475
479
|
"oalo sources fetch <name> <https url> [--every <minutes>] [--header <\"Name: value\">] [--records-at <path>] [--document <name>] [--now]",
|
|
476
480
|
"oalo sources fetch <name> <postgres url> --relation <schema.view> [--key <column>] [--cursor <column>] [--every <minutes>] [--now]",
|
|
@@ -494,7 +498,9 @@ export const COMMANDS = [
|
|
|
494
498
|
{ flag: "--env dev|prod", desc: "create: which env's copy of the table the rows go to. Default prod, whatever the project's env is." },
|
|
495
499
|
{ flag: "--every <minutes>", desc: "fetch: how often Oalo fetches the address, 5 to 10080 minutes. Default 60." },
|
|
496
500
|
{ flag: "--header <value>", desc: "fetch: a request header, \"Name: value\" (an API key, say: --header \"Authorization: Bearer $KEY\"). Repeat it for more, up to 10. Sealed on the server; show prints only the names. Left out, the ones set before stay; --header \"\" clears them." },
|
|
497
|
-
{ flag: "--records-at <path>", desc: "fetch, a table's source: the records are the list at this key of the JSON answer (data.items)." },
|
|
501
|
+
{ flag: "--records-at <path>", desc: "create: where each record sits in what a sender posts, for a webhook that wraps it ({\"event\": ..., \"delivery\": {...}} is --records-at delivery; an object there is one record, a list is several). The --from sample is read the same way, and --id-field and --fields name fields inside it. fetch, a table's source: the records are the list at this key of the JSON answer (data.items)." },
|
|
502
|
+
{ flag: "--hmac-header <name>", desc: "create, --auth hmac: the header that carries the signature. Default x-signature." },
|
|
503
|
+
{ flag: "--hmac-format <f>", desc: "create, --auth hmac: how the signature is written: sha256=hex (default, as GitHub and Shopify-style senders do), hex (the bare hex digest) or base64. A signature in another format is refused as not a sender of this source." },
|
|
498
504
|
{ flag: "--document <name>", desc: "fetch, a knowledge source: the document's name (default the address's last part)." },
|
|
499
505
|
{ flag: "--relation <name>", desc: "fetch, a postgres:// address: the view (or table) to read, like public.orders_for_oalo. Write a view of just the columns to share." },
|
|
500
506
|
{ flag: "--key <column>", desc: "fetch, a postgres:// address: the view's column that identifies a row. Default the source's id field." },
|
|
@@ -502,10 +508,12 @@ export const COMMANDS = [
|
|
|
502
508
|
{ flag: "--now", desc: "fetch: fetch once now, and say what was stored." },
|
|
503
509
|
{ flag: "--off", desc: "fetch: stop fetching." },
|
|
504
510
|
{ flag: "--wipe", desc: "delete: also delete the rows, when the source made the model." },
|
|
511
|
+
{ flag: "--prune", desc: "push, a knowledge source: the files sent are the whole set, so each document the source has and they don't is removed. Nothing is removed when a file fails. `oalo sources push help docs/*.md --prune` keeps the bot in step with a folder." },
|
|
505
512
|
{ flag: "--json", desc: "The reply as JSON." },
|
|
506
513
|
],
|
|
507
514
|
notes: [
|
|
508
515
|
"A sender posts JSON (an object or an array), NDJSON or CSV to the source's address. Keys and CSV headers are snake-cased as the CSV import does it, so \"Order ID\" and order_id are one field.",
|
|
516
|
+
"Only top-level fields are fields. A field that holds an object or a list is stored whole, everything inside it included, and --fields can't pick inside it, so a webhook that wraps its record (\"delivery\": {...}) needs --records-at, or a sensitive field inside the wrapper is stored. create warns when a sample has such a field.",
|
|
509
517
|
"The secret is shown when the source is made, and by rotate; it only writes. Each upload answers what it stored, rejected and dropped, is listed in show, and fires source.<name>.received for workflows.",
|
|
510
518
|
"Rows sync to your apps at once and fire the model's row events, as Sync API writes do. Up to 10,000 records a request, 120 requests a minute per source, 200,000 rows a day per workspace.",
|
|
511
519
|
"push sends a file from here, over your CLI token, in batches of 1,000; in snapshot mode the rows missing from the whole file are deleted after its last batch.",
|
|
@@ -528,13 +536,17 @@ export const COMMANDS = [
|
|
|
528
536
|
"oalo bots settings <bot> [--json]",
|
|
529
537
|
"oalo bots settings <bot> set key=value [key=value ...] [--yes] [--dry-run] [--json]",
|
|
530
538
|
"oalo bots settings --explain [<key> | <group>] [--json]",
|
|
539
|
+
"oalo bots graph <bot> [--build] [--json]",
|
|
540
|
+
"oalo bots graph <bot> --reset --yes [--json]",
|
|
531
541
|
],
|
|
532
542
|
flags: [
|
|
533
543
|
{ 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." },
|
|
534
544
|
{ 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." },
|
|
535
545
|
{ flag: "--remove <source>", desc: "Detach one. The table stays searchable for other bots." },
|
|
536
546
|
{ 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." },
|
|
537
|
-
{ flag: "--yes", desc: "settings set: apply to a published bot. Without it a published bot's change is shown and not saved." },
|
|
547
|
+
{ 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
|
+
{ 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." },
|
|
549
|
+
{ flag: "--reset", desc: "graph: delete the whole graph, links added by hand or imported included. Needs --yes." },
|
|
538
550
|
{ flag: "--dry-run", desc: "settings set: show what would change; save nothing." },
|
|
539
551
|
{ 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." },
|
|
540
552
|
{ flag: "--json", desc: "The bots, or the bot's sources and what else could be attached, as JSON." },
|
|
@@ -545,6 +557,7 @@ export const COMMANDS = [
|
|
|
545
557
|
"The same as ticking a table in the bot's Knowledge pane in the dashboard, with the same access as there.",
|
|
546
558
|
"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.",
|
|
547
559
|
"Every setting is described in `man oalo` (BOT SETTINGS) and by `oalo bots settings --explain`.",
|
|
560
|
+
"The knowledge graph links a bot's passages: each document's sections, and the sections like each other, so a match can bring in related ones and the topics above it. A bot has none until `oalo bots graph <bot> --build`. graph shows its size and whether links are labeled; how answers use it is in settings (graph_retrieval, ancestor_preload_depth, graph_classify_edges). Markdown front matter's related: list links pages by name.",
|
|
548
561
|
],
|
|
549
562
|
exits: { 0: "done", 1: "refused or failed", 2: "bad arguments or no CLI token" },
|
|
550
563
|
},
|
|
@@ -559,12 +572,13 @@ export const COMMANDS = [
|
|
|
559
572
|
],
|
|
560
573
|
flags: [
|
|
561
574
|
{ flag: "--name <name>", desc: "What the token is for, shown in the dashboard." },
|
|
562
|
-
{ flag: "--scope <scope>", desc: "read, write, read_manifest, read:<table>, write:<table>, events (send events to POST /api/events/v1), workflows (call workflows, POST /api/workflows/v1/<name>/run), chat (sign the chat widget in as your app's user, POST /api/chat/v1/sessions), or env:dev / env:prod (lock it to one env's data: env:dev makes events and workflow calls safe test runs, for running your app on your machine). Repeat it. Prefer the narrowest. An unknown scope is refused." },
|
|
575
|
+
{ flag: "--scope <scope>", desc: "read, write, read_manifest, read:<table>, write:<table>, events (send events to POST /api/events/v1), workflows (call workflows, POST /api/workflows/v1/<name>/run), chat (sign the chat widget in as your app's user, POST /api/chat/v1/sessions), or env:dev / env:prod (lock it to one env's data: env:dev makes events and workflow calls safe test runs, for running your app on your machine). Repeat it. Prefer the narrowest. An unknown scope is refused. A <table> is an Oalo data model, one `oalo data models` lists: a plain Postgres table (made by `oalo db restore` or by the app) can't be served by the Sync API, and create warns when a table scope names no model." },
|
|
563
576
|
{ flag: "--days N", desc: "Expiry in days (default 90; 0 for none)." },
|
|
564
577
|
],
|
|
565
578
|
notes: [
|
|
566
579
|
"A sync token reads or writes every row of its tables, for every member. It belongs in a server's secrets, never in a mobile or web app.",
|
|
567
580
|
"The token is printed once. Copy it into the app server's secrets right away.",
|
|
581
|
+
"Table scopes (read:<table>, write:<table>) are for Oalo data models, what `oalo data models` lists. They don't reach a plain table: an app's server reads its own tables over DATABASE_URL.",
|
|
568
582
|
],
|
|
569
583
|
exits: { 0: "done", 1: "refused or failed", 2: "bad arguments or no CLI token" },
|
|
570
584
|
},
|
|
@@ -608,7 +622,7 @@ export const COMMANDS = [
|
|
|
608
622
|
flags: [
|
|
609
623
|
{ flag: "--app <slug>", desc: "The app (`oalo apps` lists them). Default: the app saved with `oalo link --app`." },
|
|
610
624
|
{ flag: "--env dev|prod", desc: "dev updates the preview; prod builds and swaps the live release. prod must be on the command line." },
|
|
611
|
-
{ flag: "--new [<name>]", desc: "Make a new app from this repo: its type found from the files at the repo's root (no Dockerfile needed), its commits kept as the app's history, its preview set up. The name (default: the repo's folder) becomes its slug, and
|
|
625
|
+
{ flag: "--new [<name>]", desc: "Make a new app from this repo: its type found from the files at the repo's root (no Dockerfile needed), its commits kept as the app's history, its preview set up. The name (default: the repo's folder) becomes its slug: lowercase letters, digits and dashes, so `my_app` becomes `my-app`, and the deploy says so when it changed what you typed. This project is linked to it. When nothing at the root says what the app is (a monorepo, say), it is made as code only and the deploy says what to add: see `oalo docs bring-your-repo`." },
|
|
612
626
|
{ flag: "--name <display name>", desc: "With --new: the app's display name. Default: its slug." },
|
|
613
627
|
{ flag: "--from <https url>", desc: "With --new: make the app from a Git repository at this address instead of this folder (no local checkout needed). The Base clones one branch with its whole history (https to a public host only, up to 200 MB, 5 minutes), then makes the app as --new does. The name defaults to the repository's. Nothing is linked here." },
|
|
614
628
|
{ flag: "--branch <name>", desc: "With --from: the branch to import. Default: the repository's default branch." },
|
|
@@ -760,6 +774,7 @@ export const COMMANDS = [
|
|
|
760
774
|
],
|
|
761
775
|
notes: [
|
|
762
776
|
"A test runs every step. Steps that send messages or change records are simulated, and their output says what they would have done. Custom tools and AI steps run for real. It works on a loop that is off.",
|
|
777
|
+
"A message step (email, WhatsApp, SMS, team chat) shows its rendered text whole: subject, body, text. Other outputs show up to 2,000 characters on one line; --json has everything.",
|
|
763
778
|
"A loop that is on runs for real whenever its triggers fire. Starting a run now, for real: `oalo run loop <name>`.",
|
|
764
779
|
"Deleting can't be undone; turning a loop off keeps it.",
|
|
765
780
|
],
|
|
@@ -862,7 +877,7 @@ export const COMMANDS = [
|
|
|
862
877
|
{ flag: "--script <file>", desc: 'A JSON file: {"channel": "whatsapp", "flow": "<name>", "messages": ["...", "..."]}.' },
|
|
863
878
|
{ flag: "--timeout <s>", desc: "How long one turn may take to settle. Default 90, at most 300." },
|
|
864
879
|
{ flag: "--label <text>", desc: "Tag stored on the test conversation." },
|
|
865
|
-
{ flag: "--json", desc: "Print the whole run as JSON: turns (replies, flow state, ms, settled), flow_path, cost_usd." },
|
|
880
|
+
{ flag: "--json", desc: "Print the whole run as JSON: turns (replies, the tools called, flow state, ms, settled), flow_path, cost_usd." },
|
|
866
881
|
],
|
|
867
882
|
notes: [
|
|
868
883
|
"The conversation is a preview with no phone number or external id: the inbox leaves it out and nothing is sent to WhatsApp, Instagram or SMS.",
|
|
@@ -882,8 +897,8 @@ export const COMMANDS = [
|
|
|
882
897
|
usage: ["oalo rehearse [--number <phone_number_id>] [--responder <bot_...>] [--timeout <s>] [--json]", "oalo rehearse --script <file.json>"],
|
|
883
898
|
flags: [
|
|
884
899
|
{ flag: "--number <id>", desc: "The WhatsApp number (phone_number_id) the customer writes to. Default: the workspace's default number." },
|
|
885
|
-
{ flag: "--responder <bot_...>", desc: "The bot
|
|
886
|
-
{ flag: "--script <file>", desc: 'A JSON file: {"scenarios": [{"name", "messages", "known_contact", "opted_out", "open_thread": {"bot_id", "number", "hours_ago", "tags", "assigned", "deal"}, "expect": {"reply", "bot_id", "assigned"}}]}.' },
|
|
900
|
+
{ flag: "--responder <bot_...>", desc: "The bot the checks expect to end up answering, by its public id (`oalo bots` lists them). It's a check, not routing: messages still go where the number and its triage send them. To rehearse a bot that isn't on the number, give a --script scenario with an open_thread on that bot. Default: the bot an enabled triage loop hands threads to, else the number's bot." },
|
|
901
|
+
{ flag: "--script <file>", desc: 'A JSON file: {"scenarios": [{"name", "messages", "known_contact", "opted_out", "open_thread": {"bot_id", "number", "hours_ago", "tags", "assigned", "deal", "messages"}, "expect": {"reply", "bot_id", "assigned"}}]}. open_thread.bot_id is a public id (bot_...) or number. An open thread starts with one earlier exchange: open_thread.messages [customer, reply] when given, else a Spanish greeting ("Hola" / "¡Hola! ¿En qué te puedo ayudar?"), which can set the language the bot answers in.' },
|
|
887
902
|
{ flag: "--timeout <s>", desc: "How long one message may take to settle. Default 120, at most 300." },
|
|
888
903
|
{ flag: "--json", desc: "Print every scenario as JSON: turns (what was sent), threads, loop runs and their steps, checks, why_silent, cost_usd." },
|
|
889
904
|
],
|
|
@@ -920,6 +935,7 @@ export const COMMANDS = [
|
|
|
920
935
|
notes: [
|
|
921
936
|
"stdout is the MCP protocol stream. Diagnostics go to stderr.",
|
|
922
937
|
"Exposes a curated tool set plus an oalo_call passthrough; the build surface has ~442 events and mapping them all would wreck tool selection.",
|
|
938
|
+
"oalo_describe is a short summary (apps, bots and loops by name, the tool groups, how dev and prod work, the docs index); its section argument pages through the full records. A reply longer than about 60,000 characters has its longest list cut, with a `_cut` note saying how to get the rest (oalo_call takes match and offset; oalo_node_catalog takes node_type).",
|
|
923
939
|
"Reads OALO_URL and OALO_CLI_TOKEN, or falls back to what `oalo link --cli-token` saved.",
|
|
924
940
|
"Needs a CLI token.",
|
|
925
941
|
],
|
|
@@ -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",
|
|
@@ -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" },
|
|
@@ -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, on prod (live) data, 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" },
|
|
@@ -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. 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.",
|
|
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
|