@macaw-ai/client 0.9.11 → 0.9.13

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.
Files changed (2) hide show
  1. package/bin/install.js +55 -11
  2. package/package.json +2 -2
package/bin/install.js CHANGED
@@ -254,7 +254,24 @@ async function activate() {
254
254
 
255
255
  // ------------------------------------------------------------------ main ---
256
256
 
257
+ function usage() {
258
+ console.log("");
259
+ console.log(`${C.b} macaw-client${C.x} - the MACAW SDK and the secureAI adapters`);
260
+ console.log("");
261
+ console.log(" macaw-client install pick a Python, install the wheels,");
262
+ console.log(" lay down the examples");
263
+ console.log(" macaw-client install --activate the same, with a new workspace");
264
+ console.log(" macaw-client --check report what it would do, change nothing");
265
+ console.log("");
266
+ process.exit(1);
267
+ }
268
+
257
269
  async function main() {
270
+ // A verb, like `macaw-sidecar install`. Bare, this used to pip install into
271
+ // an interpreter and write a directory with nothing asked for.
272
+ const argv = process.argv.slice(2);
273
+ if (!argv.includes("--check") && !argv.includes("install")) usage();
274
+
258
275
  console.log("");
259
276
  console.log(`${C.b} MACAW${C.x}`);
260
277
  console.log("");
@@ -328,27 +345,54 @@ async function main() {
328
345
  console.log(` ${C.c}MACAW_PYTHON=${dflt.display} npx @macaw-ai/client install${C.x}`);
329
346
  }
330
347
 
331
- // 3 — a key, or a workspace
348
+ // 3 — the workspace. The same three choices, in the same words, as the
349
+ // coding-agents installer: the step that confused people was this one
350
+ // deciding for them and saying so afterwards.
332
351
  console.log("");
352
+ console.log(`${C.b} Workspace${C.x}`);
333
353
  const found = existingKey(dir);
334
354
  let workspace = found?.workspace || "";
335
355
  let key;
336
356
 
337
357
  if (found?.explicit) {
358
+ // Handed to us rather than discovered - nothing to confirm.
338
359
  key = found.key;
339
360
  ok(found.workspace ? `Same workspace: ${found.workspace}` : "Using the key passed in");
340
- } else if (found) {
341
- info(`A key is already on this machine: ${found.from}`);
342
- key = await ask(` API Key ${C.dim}[Enter joins that workspace]${C.x} `, found.key);
343
361
  } else if (!process.stdin.isTTY) {
344
- // Without this the default is "", which starts a device activation,
345
- // prints a link nobody is watching, and blocks for ten minutes.
346
- no("No key found, and nothing is attached to approve a new workspace.");
347
- info("Run this in a terminal, or pass a key: MACAW_API_KEY=mw_... npx @macaw-ai/client install");
348
- rl.close();
349
- process.exit(1);
362
+ if (!found) {
363
+ no("No key found, and nothing is attached to answer.");
364
+ info("Pass one: MACAW_API_KEY=mw_... npx @macaw-ai/client install");
365
+ rl.close();
366
+ process.exit(1);
367
+ }
368
+ key = found.key;
369
+ ok(found.from);
350
370
  } else {
351
- key = await ask(` API Key ${C.dim}[Enter creates a new workspace]${C.x} `, "");
371
+ console.log("");
372
+ console.log(" 1) Use a key already on this machine");
373
+ console.log(" 2) Paste an API key");
374
+ console.log(" 3) Create a new workspace");
375
+ console.log("");
376
+ const choice = (await ask(" Choose [1]: ", "1")) || "1";
377
+
378
+ if (choice === "1" && found) {
379
+ key = found.key;
380
+ ok(found.from);
381
+ } else if (choice === "1") {
382
+ console.log(` ${C.y}⚠${C.x} No key found.`);
383
+ console.log(" Looked in: $MACAW_API_KEY, $MACAW_HOME, this directory, ~/.macaw");
384
+ console.log(" Creating a new workspace instead.");
385
+ key = "";
386
+ } else if (choice === "2") {
387
+ key = await ask(" API Key: ", "");
388
+ if (!key) { no("Nothing entered."); rl.close(); process.exit(1); }
389
+ } else if (choice === "3") {
390
+ key = "";
391
+ } else {
392
+ no("Not a choice.");
393
+ rl.close();
394
+ process.exit(1);
395
+ }
352
396
  }
353
397
 
354
398
  if (key === "") {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@macaw-ai/client",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "description": "Set up the MACAW client for a Python project: installs the SDK and adapters, creates a workspace, leaves the examples ready to run.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "macaw-client-install": "bin/install.js"
7
+ "macaw-client": "bin/install.js"
8
8
  },
9
9
  "files": [
10
10
  "bin/install.js",