@oalo-ai/cli 0.4.2 → 0.4.3

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/src/mcp/tools.js CHANGED
@@ -36,7 +36,7 @@ export const TOOLS = [
36
36
  },
37
37
  {
38
38
  name: "oalo_list_bots",
39
- description: "List the chatbots in this workspace, with their public ids.",
39
+ 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
40
  inputSchema: S({}),
41
41
  event: "chat:bots:list",
42
42
  },
@@ -224,7 +224,7 @@ export const TOOLS = [
224
224
  {
225
225
  name: "oalo_test_loop",
226
226
  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.",
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. A test always runs on dev (staging) data; real runs from triggers and schedules use prod.",
228
228
  inputSchema: S(
229
229
  {
230
230
  name: { type: "string" },
@@ -249,7 +249,7 @@ export const TOOLS = [
249
249
  name: "oalo_run_loop_now",
250
250
  description:
251
251
  "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"]),
252
+ 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
253
  event: "loops:run_now",
254
254
  mutates: true,
255
255
  },
@@ -412,7 +412,7 @@ export const TOOLS = [
412
412
  inputSchema: S(
413
413
  {
414
414
  app: { type: "string", description: "The app's slug (oalo_list_apps)" },
415
- env: { type: "string", enum: ["dev", "prod"] },
415
+ env: { type: "string", enum: ["dev", "prod"], description: "dev (the preview, the default) or prod (the live app)" },
416
416
  process: { type: "string", description: "Only this process: web, a worker's name, release or oalo" },
417
417
  limit: { type: "number", description: "Recent lines, default 200" },
418
418
  },
@@ -468,7 +468,7 @@ export const TOOLS = [
468
468
  {
469
469
  name: "oalo_test_conversation",
470
470
  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 (contact details are saved, handoffs happen). Takes a while: each message waits until the bot settles.",
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 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
472
  inputSchema: S(
473
473
  {
474
474
  bot_id: { type: "string", description: "Numeric id or public bot id (bot_...)" },
@@ -485,7 +485,7 @@ export const TOOLS = [
485
485
  {
486
486
  name: "oalo_rehearse_inbound",
487
487
  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.",
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. 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
489
  inputSchema: S(
490
490
  {
491
491
  suite: { type: "boolean", description: "Run the standard scenarios" },
@@ -572,7 +572,7 @@ export const TOOLS = [
572
572
  {
573
573
  name: "oalo_emit",
574
574
  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 the loops that would fire and changes nothing. 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.",
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 the loops that would fire and changes nothing. 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
576
  inputSchema: S(
577
577
  {
578
578
  type: { type: "string", description: "Event type, e.g. form.submitted" },
@@ -603,8 +603,8 @@ export const TOOLS = [
603
603
  {
604
604
  name: "oalo_list_models",
605
605
  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 (what live apps read).",
607
- inputSchema: S({ env: { type: "string", enum: ["dev", "prod"], description: "Which schema (default dev). Models are the same in both." } }),
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 (staging, a sandbox; draft bots read it) and prod (live: live apps and published bots read it).",
607
+ inputSchema: S({ env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live). Models are the same in both." } }),
608
608
  run: async (_oalo, { env }, ctx) => listModels(readSide(ctx, env)),
609
609
  },
610
610
  {
@@ -634,12 +634,12 @@ export const TOOLS = [
634
634
  {
635
635
  name: "oalo_read_rows",
636
636
  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.",
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. Pass env: the project's env is not read, and the default is dev. Read-only.",
638
638
  inputSchema: S(
639
639
  {
640
640
  table: { type: "string" },
641
641
  id: { type: "string", description: "One row by id" },
642
- env: { type: "string", enum: ["dev", "prod"], description: "Which schema (default dev)" },
642
+ 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
643
  since: { type: "integer", description: "Continue after this seqnum (next_since of the previous page)" },
644
644
  limit: { type: "integer", description: "Rows per page (default 500, max 5000)" },
645
645
  },
@@ -657,7 +657,7 @@ export const TOOLS = [
657
657
  inputSchema: S(
658
658
  {
659
659
  sql: { type: "string", description: "One statement" },
660
- env: { type: "string", enum: ["dev", "prod"], description: "Default dev" },
660
+ env: { type: "string", enum: ["dev", "prod"], description: "dev (staging, the default) or prod (live)" },
661
661
  limit: { type: "integer", description: "Rows, default 100, at most 1000" },
662
662
  },
663
663
  ["sql"],
@@ -681,7 +681,7 @@ export const TOOLS = [
681
681
  inputSchema: S({
682
682
  source: { type: "string", enum: ["model", "event", "contact"], description: "Default model (give table)." },
683
683
  table: { type: "string" },
684
- env: { type: "string", enum: ["prod", "dev"], description: "A model's live (default) or dev data." },
684
+ 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
685
  event: { type: "string", description: "An event type such as order.created; leave it out for every type." },
686
686
  measure: { type: "string", enum: ["count", "sum", "avg", "min", "max", "distinct"], description: "Default count. sum, avg, min and max read field as a number." },
687
687
  field: { type: "string" },
@@ -703,7 +703,7 @@ export const TOOLS = [
703
703
  {
704
704
  name: "oalo_save_dashboard_widget",
705
705
  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.",
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). 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
707
  inputSchema: S(
708
708
  {
709
709
  dashboard: { type: "string", description: "The dashboard's name. Default Overview." },
@@ -723,11 +723,11 @@ export const TOOLS = [
723
723
  {
724
724
  name: "oalo_write_rows",
725
725
  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.",
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 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
727
  inputSchema: S(
728
728
  {
729
729
  table: { type: "string" },
730
- env: { type: "string", enum: ["dev", "prod"] },
730
+ env: { type: "string", enum: ["dev", "prod"], description: "Required, no default: dev (staging) or prod (live)" },
731
731
  upsert: { type: "array", items: { type: "object" }, description: "Rows to create or update" },
732
732
  id_field: { type: "string", description: "Which field holds each row's id (default id)" },
733
733
  delete: { type: "array", items: { type: "string" }, description: "Ids to soft-delete (they leave synced apps)" },
@@ -771,7 +771,7 @@ export const TOOLS = [
771
771
  {
772
772
  name: "oalo_call",
773
773
  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.",
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.",
775
775
  inputSchema: S(
776
776
  {
777
777
  event: { type: "string", description: "Channel event name" },
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 = new OaloChannel({ url, token });
22
+ const ch = channel({ url, token });
22
23
  await ch.connect();
23
24
  return { ch, url, env: cfg.env };
24
25
  }