@usenaive-sdk/cli 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +24 -3
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -37148,6 +37148,7 @@ var CODE_BY_STATUS = {
37148
37148
  var BLOCKED_AT_EDGE = "the request was blocked before it reached the API (HTTP 403); this can happen when a request body looks like SQL";
37149
37149
  function unreadableMessage(status4) {
37150
37150
  if (status4 === 403) return BLOCKED_AT_EDGE;
37151
+ if (status4 === 401) return "HTTP 401: the API key was rejected and the response had no readable details; check the API key and that baseUrl points at the API";
37151
37152
  return `HTTP ${status4}: the error response had no readable details`;
37152
37153
  }
37153
37154
  function apiErrorFrom(response, text32) {
@@ -39289,9 +39290,11 @@ function withTool(tools3, name6, settings) {
39289
39290
  }
39290
39291
  };
39291
39292
  }
39293
+ var DEFAULT_BASE_URL = "https://api.vetta.sh";
39292
39294
  function createClient(options) {
39293
39295
  const config2 = {
39294
39296
  ...options,
39297
+ baseUrl: (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "").replace(/\/v1$/, ""),
39295
39298
  fetch: options.fetch ?? ((input, init) => globalThis.fetch(input, init)),
39296
39299
  idempotencyKey: options.idempotencyKey ?? (() => crypto.randomUUID())
39297
39300
  };
@@ -49404,6 +49407,7 @@ export default defineProject({
49404
49407
  });
49405
49408
  `;
49406
49409
  var TEMPLATE_KEY = /(\btemplate:\s*)(["'])[^"']*\2/;
49410
+ var TEMPLATE_ENV = /process\.env\[["']NAIVE_TEMPLATE["']\](?!\s*\?\?)/;
49407
49411
  function setTemplate(cmd, dir, template6) {
49408
49412
  const path = `${dir}/naive.config.ts`;
49409
49413
  let text4;
@@ -49413,6 +49417,17 @@ function setTemplate(cmd, dir, template6) {
49413
49417
  throw new UsageError(`cloned ${dir}, but could not read ${path} to set the template: ${message3(error51)}`);
49414
49418
  }
49415
49419
  if (!TEMPLATE_KEY.test(text4)) {
49420
+ const index = `${dir}/templates/index.ts`;
49421
+ let picker;
49422
+ try {
49423
+ picker = cmd.readFile(index);
49424
+ } catch {
49425
+ picker = void 0;
49426
+ }
49427
+ if (picker !== void 0 && TEMPLATE_ENV.test(picker)) {
49428
+ cmd.writeFile(index, picker.replace(TEMPLATE_ENV, `(process.env["NAIVE_TEMPLATE"] ?? "${template6}")`));
49429
+ return;
49430
+ }
49416
49431
  throw new UsageError(`cloned ${dir}, but ${path} has no \`template:\` to set \u2014 this blueprint takes no template`);
49417
49432
  }
49418
49433
  cmd.writeFile(path, text4.replace(TEMPLATE_KEY, `$1"${template6}"`));
@@ -50250,7 +50265,8 @@ async function createBody4(cmd) {
50250
50265
  const outcome2 = args.str("outcome");
50251
50266
  return {
50252
50267
  agent_id: args.need("agent"),
50253
- message: args.str("message") ?? args.positionals[0] ?? "",
50268
+ // The API refuses an empty first message, so a missing one is a usage error here, not a 400.
50269
+ message: args.str("message") ?? args.positionals[0] ?? args.need("message"),
50254
50270
  // `naive session create --agent Concierge --identity ava-sales` (`docs/identity/personas.mdx`).
50255
50271
  ...identity3 === void 0 ? {} : { identity: identity3 },
50256
50272
  ...window === void 0 ? {} : { window: parseWindow(window) },
@@ -50265,10 +50281,14 @@ async function watch(cmd, sessionId, afterSeq) {
50265
50281
  let cursor = afterSeq;
50266
50282
  for (; ; ) {
50267
50283
  let parkedIdle = false;
50284
+ let idleOutput = null;
50268
50285
  for await (const event of cmd.client.stream(sessionId, { afterSeq: cursor })) {
50269
50286
  printEvent(cmd.io, event, cmd.human);
50270
50287
  cursor = event.seq;
50271
- if (event.type === "session.idle") parkedIdle = event.data["stop_reason"] === "awaiting_delegation";
50288
+ if (event.type === "session.idle") {
50289
+ parkedIdle = event.data["stop_reason"] === "awaiting_delegation";
50290
+ idleOutput = event.data["structured_output"] ?? null;
50291
+ }
50272
50292
  }
50273
50293
  let final = await cmd.client.sessions.get(sessionId);
50274
50294
  for (let attempt2 = 0; final.stop_reason === null && attempt2 < SETTLE_ATTEMPTS; attempt2 += 1) {
@@ -50276,6 +50296,7 @@ async function watch(cmd, sessionId, afterSeq) {
50276
50296
  final = await cmd.client.sessions.get(sessionId);
50277
50297
  }
50278
50298
  if (parkedIdle && gradeOut(final)) continue;
50299
+ if (final.structured_output == null && idleOutput !== null) final = { ...final, structured_output: idleOutput };
50279
50300
  return { out: final, code: exitForStopReason(final.stop_reason) };
50280
50301
  }
50281
50302
  }
@@ -51595,7 +51616,7 @@ var ALIASES = {
51595
51616
  };
51596
51617
 
51597
51618
  // src/cli.ts
51598
- var VERSION = true ? "1.0.0" : "0.0.0-dev";
51619
+ var VERSION = true ? "1.0.1" : "0.0.0-dev";
51599
51620
  var GLOBAL_FLAGS_HELP = "global flags: --json (default) --human --profile <name> --api-key <key> --org <org_id> --api-base-url <url>";
51600
51621
  function usage() {
51601
51622
  const groups = [...Object.keys(GROUPS), ...Object.keys(ALIASES)].sort().join(", ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usenaive-sdk/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Naive Managed Agents command line — create agents, run sessions, watch events, see cost.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,8 +27,8 @@
27
27
  "esbuild": "0.28.2",
28
28
  "yaml": "^2.9.0",
29
29
  "@vetta/core": "0.0.0",
30
- "@usenaive-sdk/managed-agents": "0.12.0",
31
- "@usenaive-sdk/blueprints": "0.18.0"
30
+ "@usenaive-sdk/blueprints": "0.18.0",
31
+ "@usenaive-sdk/managed-agents": "0.12.1"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "node build.mjs",