@oalo-ai/cli 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/man/oalo.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH OALO 1 "" "oalo 0.3.0" "OALO CLI"
1
+ .TH OALO 1 "" "oalo 0.4.1" "OALO CLI"
2
2
  .SH NAME
3
3
  oalo \- wire a local app into your Oalo workspace
4
4
  .SH SYNOPSIS
@@ -1232,7 +1232,7 @@ Each file holds the editable object (\fBflow\fR or \fBloop\fR) plus the CLI's bo
1232
1232
  .IP \(bu 2
1233
1233
  A file you have edited is kept, not overwritten, unless you pass \-\-force.
1234
1234
  .IP \(bu 2
1235
- To create a flow or loop, write a file in the same shape without id or version, then push it.
1235
+ To create a flow or loop, write a file in the same shape without id or version, then push it. A new loop: {"kind": "loop", "name": "<name>", "loop": {"entry", "nodes", "edges", ...}, "triggers": [...]}. A new flow: {"kind": "flow", "bot": "<bot_ id>", "flow": {"name", "graph", ...}}. Run oalo pull once first for the node contracts in .oalo/catalog/.
1236
1236
  .IP \(bu 2
1237
1237
  Needs a CLI token.
1238
1238
  .PP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oalo-ai/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Wire a local app into your OALO workspace: link a token, generate typed bindings, and serve the build surface over MCP.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,6 +25,11 @@ oalo qa <bot> "hola" "..." --channel whatsapp # talk to the bot, read the tran
25
25
  oalo status # what changed locally and on the server
26
26
  ```
27
27
 
28
+ A new loop or flow is a file you write without `id` or `version`, then push.
29
+ A loop: `{"kind": "loop", "name": "<name>", "loop": {"entry", "nodes", "edges", ...}, "triggers": [...]}`.
30
+ A flow: `{"kind": "flow", "bot": "<bot_ id>", "flow": {"name", "graph", ...}}`. Run
31
+ `oalo pull` once first, for the node contracts in `.oalo/catalog/`.
32
+
28
33
  Over MCP the same steps are `oalo_node_catalog`, `oalo_get_flow` / `oalo_get_loop` /
29
34
  `oalo_get_tool_source`, `oalo_lint_flow` / `oalo_lint_loop`, `oalo_save_flow` /
30
35
  `oalo_save_loop` / `oalo_save_tool_source`, `oalo_test_conversation` and
@@ -134,7 +134,13 @@ export async function deploy(flags) {
134
134
  console.log(dim("After adding what it needs: commit, then `oalo deploy`. `oalo docs bring-your-repo` has the details."));
135
135
  } else {
136
136
  console.log(`created ${result.app} (${result.app_type}) from ${result.commit.slice(0, 8)}, its history kept: ${result.url}`);
137
- console.log(dim("Its preview is being set up (`oalo logs` shows it). Next deploys: `oalo deploy`; live: `oalo deploy --env prod`."));
137
+ // A server app's preview is checked as a deploy's is (newer Bases); the
138
+ // code is saved either way, but a preview that doesn't run exits 1.
139
+ if (result.preview === "ok") console.log(dim("Its preview answers. Next deploys: `oalo deploy`; live: `oalo deploy --env prod`."));
140
+ else if (result.preview === "failed") {
141
+ console.error(`its preview doesn't run: ${result.preview_error || "see `oalo logs`"}. Fix it, commit, then \`oalo deploy\`.`);
142
+ process.exitCode = 1;
143
+ } else console.log(dim("Its preview is being set up (`oalo logs` shows it). Next deploys: `oalo deploy`; live: `oalo deploy --env prod`."));
138
144
  storeBuildHint(result.app_type, result.app);
139
145
  }
140
146
  }
@@ -16,7 +16,9 @@ import { dim } from "../events.js";
16
16
  * notes.md` saves one; `--json` gives the structured form.
17
17
  */
18
18
  export async function docs(flags, rest) {
19
- const slug = rest[1];
19
+ // `oalo docs list` (and `ls`) is what people and agents type for the list:
20
+ // there is no page by either name.
21
+ const slug = ["list", "ls"].includes(rest[1]) ? undefined : rest[1];
20
22
  const cfg = resolveConfig(flags);
21
23
  const { url, token } = controlPlane(cfg);
22
24
  if (!url || !token) {
package/src/config.js CHANGED
@@ -119,15 +119,34 @@ export function forgetWorkspace(serverUrl) {
119
119
  * The control-plane URL and CLI token for a command. When this project (or
120
120
  * --server / OALO_URL) names a workspace, only that workspace's token is used;
121
121
  * a token saved for another workspace would just fail to authenticate. With
122
- * no workspace named, the most recently saved one is used.
122
+ * no workspace named, the one saved workspace is used. With several saved, it
123
+ * refuses (WhichWorkspace) rather than pick one: "the latest login" sent an
124
+ * unlinked folder's commands to another customer's live Base.
123
125
  */
124
126
  export function controlPlane(cfg) {
125
127
  if (cfg.cliToken) return { url: cfg.serverUrl, token: cfg.cliToken };
126
128
  const saved = listWorkspaces("cli");
129
+ if (!cfg.serverUrl) {
130
+ const urls = [...new Set(saved.map((w) => w.serverUrl))];
131
+ if (urls.length > 1) throw new WhichWorkspace(urls);
132
+ }
127
133
  const match = cfg.serverUrl ? saved.find((w) => w.serverUrl === cfg.serverUrl) : saved[0];
128
134
  return { url: cfg.serverUrl || match?.serverUrl || null, token: match?.token || null };
129
135
  }
130
136
 
137
+ /** Several workspaces are saved and nothing says which one a command is for. */
138
+ export class WhichWorkspace extends Error {
139
+ constructor(urls) {
140
+ super(
141
+ "This machine has more than one workspace saved, and nothing here says which one to use:\n" +
142
+ urls.map((u) => ` ${u}`).join("\n") +
143
+ "\n\nLink this folder to one with `oalo link --server <url>`, or pass --server <url>, or set OALO_URL."
144
+ );
145
+ this.code = "OALO_WHICH_WORKSPACE";
146
+ this.urls = urls;
147
+ }
148
+ }
149
+
131
150
  /** How to get a CLI token, for "needs a CLI token" messages. */
132
151
  export const HOW_TO_CONNECT =
133
152
  "Connect this machine with:\n oalo login <workspace> (your Base at <workspace>.oalo.ai)\n\n" +
@@ -1,25 +1,25 @@
1
1
  {
2
- "version": "0.4.0",
2
+ "version": "0.4.1",
3
3
  "targets": {
4
4
  "darwin-arm64": {
5
5
  "file": "oalo-coord-darwin-arm64.gz",
6
- "sha256": "da9c1663ffc673924b77fed8ad61b09c16ec61e2f738228e059b5b8fa38cdd29",
7
- "bytes": 24851871
6
+ "sha256": "83bca933ccbc22511fa1bf506dc7fe39731a46da59efb354f4a2e45bc80d6b3c",
7
+ "bytes": 24851980
8
8
  },
9
9
  "darwin-x64": {
10
10
  "file": "oalo-coord-darwin-x64.gz",
11
- "sha256": "8e3d36775180843d7e333f54321ed0310f7af126b8a2954b8bbf6afd06a09f32",
12
- "bytes": 26990220
11
+ "sha256": "6ba7d6b98f0ac541e6eca0f649c7c4110cbbf2bcc7fb0bcfa8fc9d708629c9d0",
12
+ "bytes": 26990319
13
13
  },
14
14
  "linux-x64": {
15
15
  "file": "oalo-coord-linux-x64.gz",
16
- "sha256": "222745d2249b43a0db546bddfcb0118d53cf4040a5e748f76c69834152ac3b05",
17
- "bytes": 36882875
16
+ "sha256": "43312caa34706ca12b502678936c12940c3d7495960841546e2935ec543b6117",
17
+ "bytes": 36882974
18
18
  },
19
19
  "linux-arm64": {
20
20
  "file": "oalo-coord-linux-arm64.gz",
21
- "sha256": "43b5c16359d9a864248798162e78f214ccfea0c5639ce479ab83d8be0c3b4803",
22
- "bytes": 37123621
21
+ "sha256": "64a426d6bfc9e646f12b9d6c1edd0b62f3830f33718b55e6232e92379255c9f8",
22
+ "bytes": 37123721
23
23
  }
24
24
  }
25
25
  }
package/src/graphfiles.js CHANGED
@@ -205,9 +205,19 @@ export function standing(file, remote) {
205
205
  return "clean";
206
206
  }
207
207
 
208
+ /**
209
+ * The smallest new file of each kind, for errors and help: a new loop or flow
210
+ * is often written from scratch, with no pulled file to copy.
211
+ */
212
+ export const NEW_FILE_SHAPE = {
213
+ loop: '{"kind": "loop", "name": "<name>", "loop": {"description": "...", "entry": "<first node id>", "nodes": [...], "edges": [...]}, "triggers": [{"type": "api", "description": "...", "input": {"x": "string"}, "output": {"y": "string"}}]}',
214
+ flow: '{"kind": "flow", "bot": "<bot_ public id>", "flow": {"name": "<name>", "description": "...", "graph": {...}}}',
215
+ };
216
+ const SHAPES = `A new loop file: ${NEW_FILE_SHAPE.loop}\nA new flow file: ${NEW_FILE_SHAPE.flow}\nNode settings: .oalo/catalog/loop.json and flow.json (oalo pull writes them).`;
217
+
208
218
  export function readGraphFile(path) {
209
219
  const file = JSON.parse(readFileSync(path, "utf8"));
210
- if (!["flow", "loop", "tool"].includes(file.kind)) throw new Error(`${path}: not an oalo flow, loop or tool file (kind is ${JSON.stringify(file.kind)})`);
220
+ if (!["flow", "loop", "tool"].includes(file.kind)) throw new Error(`${path}: not an oalo flow, loop or tool file (kind is ${JSON.stringify(file.kind)}).\n${SHAPES}`);
211
221
  if (file.kind === "tool") {
212
222
  if (!file.name || !file.tool) throw new Error(`${path}: a tool file needs \`name\` and \`tool\``);
213
223
  const src = join(dirname(path), file.source || `${slug(file.name)}.js`);
@@ -215,8 +225,8 @@ export function readGraphFile(path) {
215
225
  // Not written back: the .js file is the source of truth for the code.
216
226
  Object.defineProperty(file, "_source", { value: readFileSync(src, "utf8"), enumerable: false });
217
227
  }
218
- if (file.kind === "flow" && (!file.bot || !file.flow)) throw new Error(`${path}: a flow file needs \`bot\` and \`flow\``);
219
- if (file.kind === "loop" && (!file.name || !file.loop)) throw new Error(`${path}: a loop file needs \`name\` and \`loop\``);
228
+ if (file.kind === "flow" && (!file.bot || !file.flow)) throw new Error(`${path}: a flow file needs \`bot\` and \`flow\`.\nA new flow file: ${NEW_FILE_SHAPE.flow}`);
229
+ if (file.kind === "loop" && (!file.name || !file.loop)) throw new Error(`${path}: a loop file needs \`name\` and \`loop\`.\nA new loop file: ${NEW_FILE_SHAPE.loop}`);
220
230
  return file;
221
231
  }
222
232
 
package/src/help.js CHANGED
@@ -763,7 +763,7 @@ export const COMMANDS = [
763
763
  "A loop file also lists the loop's `triggers` (what starts it). Add or delete entries and push: push adds the new ones and removes the ones you deleted, and keeps any a teammate added since your pull. Set a trigger's `enabled` to turn it on or off.",
764
764
  "Each file holds the editable object (`flow` or `loop`) plus the CLI's bookkeeping: id, version (sent back as base_version on push) and base_hash (how the CLI knows you edited it). Edit the object; leave the bookkeeping alone.",
765
765
  "A file you have edited is kept, not overwritten, unless you pass --force.",
766
- "To create a flow or loop, write a file in the same shape without id or version, then push it.",
766
+ "To create a flow or loop, write a file in the same shape without id or version, then push it. A new loop: {\"kind\": \"loop\", \"name\": \"<name>\", \"loop\": {\"entry\", \"nodes\", \"edges\", ...}, \"triggers\": [...]}. A new flow: {\"kind\": \"flow\", \"bot\": \"<bot_ id>\", \"flow\": {\"name\", \"graph\", ...}}. Run oalo pull once first for the node contracts in .oalo/catalog/.",
767
767
  "Needs a CLI token.",
768
768
  ],
769
769
  exits: { 0: "pulled", 1: "pull failed", 2: "bad arguments or no token" },
package/src/index.js CHANGED
@@ -90,7 +90,13 @@ if ((flags.version || cmd === "version") && !flags.help) {
90
90
  }
91
91
  }
92
92
 
93
- await dispatch(cmd);
93
+ try {
94
+ await dispatch(cmd);
95
+ } catch (e) {
96
+ // controlPlane() refusing to guess between saved workspaces: a usage error.
97
+ if (e?.code === "OALO_WHICH_WORKSPACE") finish(e.message, 2, process.stderr);
98
+ else throw e;
99
+ }
94
100
  }
95
101
 
96
102
  async function dispatch(cmd) {