@usenaive-sdk/cli 0.15.1 → 1.0.0

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 (281) hide show
  1. package/README.md +43 -402
  2. package/dist/index.js +51775 -502
  3. package/package.json +22 -18
  4. package/dist/client.d.ts +0 -108
  5. package/dist/client.js +0 -458
  6. package/dist/client.js.map +0 -1
  7. package/dist/commands/account-kits.d.ts +0 -2
  8. package/dist/commands/account-kits.js +0 -71
  9. package/dist/commands/account-kits.js.map +0 -1
  10. package/dist/commands/aeo.d.ts +0 -2
  11. package/dist/commands/aeo.js +0 -451
  12. package/dist/commands/aeo.js.map +0 -1
  13. package/dist/commands/agent-profiles.d.ts +0 -11
  14. package/dist/commands/agent-profiles.js +0 -120
  15. package/dist/commands/agent-profiles.js.map +0 -1
  16. package/dist/commands/agents.d.ts +0 -2
  17. package/dist/commands/agents.js +0 -916
  18. package/dist/commands/agents.js.map +0 -1
  19. package/dist/commands/app-data.d.ts +0 -2
  20. package/dist/commands/app-data.js +0 -445
  21. package/dist/commands/app-data.js.map +0 -1
  22. package/dist/commands/approvals.d.ts +0 -2
  23. package/dist/commands/approvals.js +0 -242
  24. package/dist/commands/approvals.js.map +0 -1
  25. package/dist/commands/apps.d.ts +0 -9
  26. package/dist/commands/apps.js +0 -844
  27. package/dist/commands/apps.js.map +0 -1
  28. package/dist/commands/audio.d.ts +0 -9
  29. package/dist/commands/audio.js +0 -391
  30. package/dist/commands/audio.js.map +0 -1
  31. package/dist/commands/auth.d.ts +0 -31
  32. package/dist/commands/auth.js +0 -428
  33. package/dist/commands/auth.js.map +0 -1
  34. package/dist/commands/billing.d.ts +0 -2
  35. package/dist/commands/billing.js +0 -250
  36. package/dist/commands/billing.js.map +0 -1
  37. package/dist/commands/brain.d.ts +0 -2
  38. package/dist/commands/brain.js +0 -1300
  39. package/dist/commands/brain.js.map +0 -1
  40. package/dist/commands/browser.d.ts +0 -2
  41. package/dist/commands/browser.js +0 -378
  42. package/dist/commands/browser.js.map +0 -1
  43. package/dist/commands/business.d.ts +0 -2
  44. package/dist/commands/business.js +0 -566
  45. package/dist/commands/business.js.map +0 -1
  46. package/dist/commands/cards.d.ts +0 -2
  47. package/dist/commands/cards.js +0 -419
  48. package/dist/commands/cards.js.map +0 -1
  49. package/dist/commands/ceo.d.ts +0 -2
  50. package/dist/commands/ceo.js +0 -369
  51. package/dist/commands/ceo.js.map +0 -1
  52. package/dist/commands/clone.d.ts +0 -2
  53. package/dist/commands/clone.js +0 -203
  54. package/dist/commands/clone.js.map +0 -1
  55. package/dist/commands/companies.d.ts +0 -10
  56. package/dist/commands/companies.js +0 -283
  57. package/dist/commands/companies.js.map +0 -1
  58. package/dist/commands/company-data.d.ts +0 -2
  59. package/dist/commands/company-data.js +0 -168
  60. package/dist/commands/company-data.js.map +0 -1
  61. package/dist/commands/compute.d.ts +0 -2
  62. package/dist/commands/compute.js +0 -498
  63. package/dist/commands/compute.js.map +0 -1
  64. package/dist/commands/config.d.ts +0 -2
  65. package/dist/commands/config.js +0 -36
  66. package/dist/commands/config.js.map +0 -1
  67. package/dist/commands/connections.d.ts +0 -8
  68. package/dist/commands/connections.js +0 -137
  69. package/dist/commands/connections.js.map +0 -1
  70. package/dist/commands/cron-jobs.d.ts +0 -2
  71. package/dist/commands/cron-jobs.js +0 -245
  72. package/dist/commands/cron-jobs.js.map +0 -1
  73. package/dist/commands/domains.d.ts +0 -2
  74. package/dist/commands/domains.js +0 -474
  75. package/dist/commands/domains.js.map +0 -1
  76. package/dist/commands/ecommerce.d.ts +0 -2
  77. package/dist/commands/ecommerce.js +0 -277
  78. package/dist/commands/ecommerce.js.map +0 -1
  79. package/dist/commands/email.d.ts +0 -2
  80. package/dist/commands/email.js +0 -336
  81. package/dist/commands/email.js.map +0 -1
  82. package/dist/commands/employees.d.ts +0 -2
  83. package/dist/commands/employees.js +0 -190
  84. package/dist/commands/employees.js.map +0 -1
  85. package/dist/commands/env.d.ts +0 -7
  86. package/dist/commands/env.js +0 -112
  87. package/dist/commands/env.js.map +0 -1
  88. package/dist/commands/formation.d.ts +0 -2
  89. package/dist/commands/formation.js +0 -273
  90. package/dist/commands/formation.js.map +0 -1
  91. package/dist/commands/identity.d.ts +0 -2
  92. package/dist/commands/identity.js +0 -110
  93. package/dist/commands/identity.js.map +0 -1
  94. package/dist/commands/images.d.ts +0 -2
  95. package/dist/commands/images.js +0 -371
  96. package/dist/commands/images.js.map +0 -1
  97. package/dist/commands/init.d.ts +0 -5
  98. package/dist/commands/init.js +0 -43
  99. package/dist/commands/init.js.map +0 -1
  100. package/dist/commands/jobs.d.ts +0 -2
  101. package/dist/commands/jobs.js +0 -144
  102. package/dist/commands/jobs.js.map +0 -1
  103. package/dist/commands/keys.d.ts +0 -2
  104. package/dist/commands/keys.js +0 -156
  105. package/dist/commands/keys.js.map +0 -1
  106. package/dist/commands/legacy-auth.d.ts +0 -27
  107. package/dist/commands/legacy-auth.js +0 -64
  108. package/dist/commands/legacy-auth.js.map +0 -1
  109. package/dist/commands/llm.d.ts +0 -2
  110. package/dist/commands/llm.js +0 -125
  111. package/dist/commands/llm.js.map +0 -1
  112. package/dist/commands/login.d.ts +0 -2
  113. package/dist/commands/login.js +0 -65
  114. package/dist/commands/login.js.map +0 -1
  115. package/dist/commands/logout.d.ts +0 -7
  116. package/dist/commands/logout.js +0 -55
  117. package/dist/commands/logout.js.map +0 -1
  118. package/dist/commands/logs.d.ts +0 -2
  119. package/dist/commands/logs.js +0 -42
  120. package/dist/commands/logs.js.map +0 -1
  121. package/dist/commands/loops.d.ts +0 -2
  122. package/dist/commands/loops.js +0 -260
  123. package/dist/commands/loops.js.map +0 -1
  124. package/dist/commands/media.d.ts +0 -2
  125. package/dist/commands/media.js +0 -183
  126. package/dist/commands/media.js.map +0 -1
  127. package/dist/commands/memory.d.ts +0 -2
  128. package/dist/commands/memory.js +0 -151
  129. package/dist/commands/memory.js.map +0 -1
  130. package/dist/commands/mobile.d.ts +0 -4
  131. package/dist/commands/mobile.js +0 -382
  132. package/dist/commands/mobile.js.map +0 -1
  133. package/dist/commands/module.d.ts +0 -8
  134. package/dist/commands/module.js +0 -48
  135. package/dist/commands/module.js.map +0 -1
  136. package/dist/commands/objectives.d.ts +0 -2
  137. package/dist/commands/objectives.js +0 -243
  138. package/dist/commands/objectives.js.map +0 -1
  139. package/dist/commands/payments.d.ts +0 -2
  140. package/dist/commands/payments.js +0 -131
  141. package/dist/commands/payments.js.map +0 -1
  142. package/dist/commands/people.d.ts +0 -2
  143. package/dist/commands/people.js +0 -197
  144. package/dist/commands/people.js.map +0 -1
  145. package/dist/commands/phone.d.ts +0 -2
  146. package/dist/commands/phone.js +0 -289
  147. package/dist/commands/phone.js.map +0 -1
  148. package/dist/commands/projects.d.ts +0 -13
  149. package/dist/commands/projects.js +0 -220
  150. package/dist/commands/projects.js.map +0 -1
  151. package/dist/commands/queue.d.ts +0 -2
  152. package/dist/commands/queue.js +0 -121
  153. package/dist/commands/queue.js.map +0 -1
  154. package/dist/commands/register.d.ts +0 -2
  155. package/dist/commands/register.js +0 -88
  156. package/dist/commands/register.js.map +0 -1
  157. package/dist/commands/report.d.ts +0 -17
  158. package/dist/commands/report.js +0 -109
  159. package/dist/commands/report.js.map +0 -1
  160. package/dist/commands/sandbox.d.ts +0 -2
  161. package/dist/commands/sandbox.js +0 -558
  162. package/dist/commands/sandbox.js.map +0 -1
  163. package/dist/commands/search.d.ts +0 -2
  164. package/dist/commands/search.js +0 -223
  165. package/dist/commands/search.js.map +0 -1
  166. package/dist/commands/seo.d.ts +0 -2
  167. package/dist/commands/seo.js +0 -528
  168. package/dist/commands/seo.js.map +0 -1
  169. package/dist/commands/sessions.d.ts +0 -6
  170. package/dist/commands/sessions.js +0 -109
  171. package/dist/commands/sessions.js.map +0 -1
  172. package/dist/commands/social-data.d.ts +0 -2
  173. package/dist/commands/social-data.js +0 -245
  174. package/dist/commands/social-data.js.map +0 -1
  175. package/dist/commands/social.d.ts +0 -2
  176. package/dist/commands/social.js +0 -407
  177. package/dist/commands/social.js.map +0 -1
  178. package/dist/commands/status.d.ts +0 -2
  179. package/dist/commands/status.js +0 -79
  180. package/dist/commands/status.js.map +0 -1
  181. package/dist/commands/support.d.ts +0 -2
  182. package/dist/commands/support.js +0 -134
  183. package/dist/commands/support.js.map +0 -1
  184. package/dist/commands/tasks.d.ts +0 -2
  185. package/dist/commands/tasks.js +0 -409
  186. package/dist/commands/tasks.js.map +0 -1
  187. package/dist/commands/teams.d.ts +0 -69
  188. package/dist/commands/teams.js +0 -503
  189. package/dist/commands/teams.js.map +0 -1
  190. package/dist/commands/trading.d.ts +0 -2
  191. package/dist/commands/trading.js +0 -333
  192. package/dist/commands/trading.js.map +0 -1
  193. package/dist/commands/up.d.ts +0 -551
  194. package/dist/commands/up.js +0 -1149
  195. package/dist/commands/up.js.map +0 -1
  196. package/dist/commands/usage.d.ts +0 -2
  197. package/dist/commands/usage.js +0 -73
  198. package/dist/commands/usage.js.map +0 -1
  199. package/dist/commands/use.d.ts +0 -12
  200. package/dist/commands/use.js +0 -96
  201. package/dist/commands/use.js.map +0 -1
  202. package/dist/commands/users.d.ts +0 -10
  203. package/dist/commands/users.js +0 -82
  204. package/dist/commands/users.js.map +0 -1
  205. package/dist/commands/vault.d.ts +0 -2
  206. package/dist/commands/vault.js +0 -101
  207. package/dist/commands/vault.js.map +0 -1
  208. package/dist/commands/verification.d.ts +0 -2
  209. package/dist/commands/verification.js +0 -152
  210. package/dist/commands/verification.js.map +0 -1
  211. package/dist/commands/verify-email.d.ts +0 -19
  212. package/dist/commands/verify-email.js +0 -130
  213. package/dist/commands/verify-email.js.map +0 -1
  214. package/dist/commands/video.d.ts +0 -2
  215. package/dist/commands/video.js +0 -417
  216. package/dist/commands/video.js.map +0 -1
  217. package/dist/commands/voice.d.ts +0 -2
  218. package/dist/commands/voice.js +0 -516
  219. package/dist/commands/voice.js.map +0 -1
  220. package/dist/commands/wallet.d.ts +0 -2
  221. package/dist/commands/wallet.js +0 -244
  222. package/dist/commands/wallet.js.map +0 -1
  223. package/dist/commands/webhooks.d.ts +0 -13
  224. package/dist/commands/webhooks.js +0 -119
  225. package/dist/commands/webhooks.js.map +0 -1
  226. package/dist/commands/whoami.d.ts +0 -2
  227. package/dist/commands/whoami.js +0 -53
  228. package/dist/commands/whoami.js.map +0 -1
  229. package/dist/config.d.ts +0 -42
  230. package/dist/config.js +0 -83
  231. package/dist/config.js.map +0 -1
  232. package/dist/index.d.ts +0 -3
  233. package/dist/index.js.map +0 -1
  234. package/dist/lib/brain-select.d.ts +0 -193
  235. package/dist/lib/brain-select.js +0 -403
  236. package/dist/lib/brain-select.js.map +0 -1
  237. package/dist/lib/cli-validation.d.ts +0 -12
  238. package/dist/lib/cli-validation.js +0 -46
  239. package/dist/lib/cli-validation.js.map +0 -1
  240. package/dist/lib/config-errors.d.ts +0 -4
  241. package/dist/lib/config-errors.js +0 -13
  242. package/dist/lib/config-errors.js.map +0 -1
  243. package/dist/lib/deprecation.d.ts +0 -158
  244. package/dist/lib/deprecation.js +0 -140
  245. package/dist/lib/deprecation.js.map +0 -1
  246. package/dist/lib/duration.d.ts +0 -8
  247. package/dist/lib/duration.js +0 -11
  248. package/dist/lib/duration.js.map +0 -1
  249. package/dist/lib/http-response.d.ts +0 -11
  250. package/dist/lib/http-response.js +0 -96
  251. package/dist/lib/http-response.js.map +0 -1
  252. package/dist/lib/llm-paywall.d.ts +0 -82
  253. package/dist/lib/llm-paywall.js +0 -231
  254. package/dist/lib/llm-paywall.js.map +0 -1
  255. package/dist/lib/pricing.d.ts +0 -132
  256. package/dist/lib/pricing.js +0 -148
  257. package/dist/lib/pricing.js.map +0 -1
  258. package/dist/lib/starter-config.d.ts +0 -13
  259. package/dist/lib/starter-config.js +0 -71
  260. package/dist/lib/starter-config.js.map +0 -1
  261. package/dist/lib/stream-frames.d.ts +0 -114
  262. package/dist/lib/stream-frames.js +0 -169
  263. package/dist/lib/stream-frames.js.map +0 -1
  264. package/dist/lib/teams-catalog.d.ts +0 -141
  265. package/dist/lib/teams-catalog.js +0 -841
  266. package/dist/lib/teams-catalog.js.map +0 -1
  267. package/dist/lib/unknown-command.d.ts +0 -71
  268. package/dist/lib/unknown-command.js +0 -132
  269. package/dist/lib/unknown-command.js.map +0 -1
  270. package/dist/lib/version-check.d.ts +0 -26
  271. package/dist/lib/version-check.js +0 -21
  272. package/dist/lib/version-check.js.map +0 -1
  273. package/dist/output.d.ts +0 -246
  274. package/dist/output.js +0 -539
  275. package/dist/output.js.map +0 -1
  276. package/dist/prompt.d.ts +0 -17
  277. package/dist/prompt.js +0 -70
  278. package/dist/prompt.js.map +0 -1
  279. package/dist/version.d.ts +0 -2
  280. package/dist/version.js +0 -14
  281. package/dist/version.js.map +0 -1
package/dist/output.js DELETED
@@ -1,539 +0,0 @@
1
- /**
2
- * Agent-native structured output for CLI responses.
3
- * Every tool call returns JSON with result data + contextual guidance
4
- * following the Meow/Lindy pattern for agentic CLI usage.
5
- *
6
- * Output mode is OPT-IN human (default machine JSON). Human mode is NEVER inferred from isTTY —
7
- * a pty-wrapped caller (Claude Code's Bash tool, script(1), tmux, ssh -t, CI runners) reports
8
- * isTTY===true with no human present, so auto-detect would hang agents in prompts and break their
9
- * JSON.parse. Machine overrides (--json / NAIVE_JSON / CI) always win.
10
- */
11
- import chalk from "chalk";
12
- import { loadConfig, saveConfig } from "./config.js";
13
- let _flagJson = false;
14
- let _flagHuman = false;
15
- /** Set by the global --json / --human options in index.ts, parsed before any action runs. */
16
- export function setOutputFlags(opts) {
17
- if (opts.json)
18
- _flagJson = true;
19
- if (opts.human)
20
- _flagHuman = true;
21
- }
22
- function machineForced() {
23
- return _flagJson || !!process.env.NAIVE_JSON || !!process.env.CI;
24
- }
25
- /** TRUE only on an explicit opt-in; default false. Controls OUTPUT FORMAT. */
26
- export function humanMode() {
27
- if (machineForced())
28
- return false;
29
- if (_flagHuman || process.env.NAIVE_HUMAN === "1")
30
- return true;
31
- try {
32
- return loadConfig().output === "human";
33
- }
34
- catch {
35
- return false;
36
- }
37
- }
38
- /** Prompts (wizard, destructive confirm) require human mode AND a real interactive stdin — a
39
- * separate predicate from output format, so a human piping stdout to `tee` still gets the confirm. */
40
- export function isInteractive() {
41
- return humanMode() && !!process.stdin.isTTY;
42
- }
43
- // One-time stderr nudge so a founder discovers human mode without polluting stdout (stays parseable JSON).
44
- function maybeDiscoveryHint() {
45
- if (!process.stdout.isTTY)
46
- return;
47
- if (_flagJson || _flagHuman || process.env.NAIVE_JSON || process.env.NAIVE_HUMAN || process.env.CI)
48
- return;
49
- let cfg;
50
- try {
51
- cfg = loadConfig();
52
- }
53
- catch {
54
- return;
55
- }
56
- if (cfg.output !== undefined || cfg.human_hint_shown)
57
- return;
58
- process.stderr.write(chalk.dim("\n💡 tip: run `naive config output human` for friendly, readable output.\n"));
59
- try {
60
- saveConfig({ human_hint_shown: true });
61
- }
62
- catch {
63
- /* best-effort */
64
- }
65
- }
66
- // Secret guard (security HIGH-2): a key must be shown ONCE, clearly labeled, and NEVER rendered as a
67
- // runnable/highlighted command (the copy-into-shell-history footgun).
68
- const SECRET_TOKEN_RE = /nv_sk_[A-Za-z0-9_]+/;
69
- function isSecretField(key) {
70
- return key === "api_key" || key === "session_token" || key === "token";
71
- }
72
- function fmtVal(v) {
73
- if (v === null || v === undefined)
74
- return chalk.dim("—");
75
- if (typeof v === "object")
76
- return chalk.dim(JSON.stringify(v));
77
- return String(v);
78
- }
79
- function renderHuman(o) {
80
- const w = (s) => process.stdout.write(s);
81
- w(chalk.green.bold(`✓ ${o.action}\n`));
82
- if (o.result && typeof o.result === "object") {
83
- for (const [k, v] of Object.entries(o.result)) {
84
- if (isSecretField(k) && typeof v === "string") {
85
- w("\n" + chalk.yellow.bold(` ⚠ ${k} — save this now, it won't be shown again:`) + "\n");
86
- w(" " + chalk.cyan(v) + "\n\n");
87
- }
88
- else {
89
- w(" " + chalk.dim(`${k}:`) + " " + fmtVal(v) + "\n");
90
- }
91
- }
92
- }
93
- else if (o.result !== null && o.result !== undefined) {
94
- w(" " + String(o.result) + "\n");
95
- }
96
- if (o.hints?.length) {
97
- w("\n");
98
- for (const h of o.hints)
99
- w(chalk.dim(` • ${h}`) + "\n");
100
- }
101
- // next_steps as suggested commands — but NEVER one carrying a raw key (secret guard).
102
- const safe = (o.next_steps ?? []).filter((s) => !SECRET_TOKEN_RE.test(s.command));
103
- if (safe.length) {
104
- w("\n" + chalk.dim(" Next:") + "\n");
105
- for (const s of safe)
106
- w(" " + chalk.cyan(s.command) + chalk.dim(` — ${s.description}`) + "\n");
107
- }
108
- // help_markdown is intentionally NOT rendered in human mode: it's verbose and (in keys create) the
109
- // place a raw secret would live. The JSON path keeps it for agents.
110
- }
111
- function renderHumanError(o) {
112
- const w = (s) => process.stderr.write(s);
113
- w(chalk.red.bold(`✗ ${o.action} failed`) + "\n");
114
- if (o.error.message)
115
- w(" " + o.error.message + "\n");
116
- if (o.error.hint)
117
- w(chalk.dim(" hint: " + o.error.hint) + "\n");
118
- }
119
- /**
120
- * The SINGLE derivation point for the human-readable "Cost:" hint (N7). Reads
121
- * the authoritative `credits_used` off a response/result object — the exact
122
- * number the API billed and dropped from the balance — and formats it so the
123
- * hint can NEVER drift from what was actually charged. Previously commands
124
- * hardcoded strings like "Cost: 1 credit" while the API charged 10; deriving
125
- * from the response is the only way to keep them in lockstep.
126
- *
127
- * Returns undefined when there is nothing (yet) to charge — the field is
128
- * absent, or a job is still queued/processing/failed (credits_used is null) —
129
- * so callers can spread it into a hints array and no line appears.
130
- */
131
- export function creditCostHint(result) {
132
- const raw = result?.credits_used;
133
- if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0)
134
- return undefined;
135
- // Trim binary float noise (e.g. 0.30000000000000004) without inventing precision.
136
- const credits = Math.round(raw * 10000) / 10000;
137
- return `Cost: ${credits} ${credits === 1 ? "credit" : "credits"}`;
138
- }
139
- /**
140
- * The submit-time counterpart of creditCostHint (N6). Reads a job-submission
141
- * response's `estimated_credits` — the API's pre-flight quote, derived from the
142
- * SAME getFalPrice() + usdToCredits() source that settles the final charge — so
143
- * a customer sees the spend before and at submit, and the echoed number tracks
144
- * what will actually be billed. Returns undefined when no estimate is present.
145
- */
146
- export function creditEstimateHint(result) {
147
- const raw = result?.estimated_credits;
148
- if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0)
149
- return undefined;
150
- const credits = Math.round(raw * 10000) / 10000;
151
- return `Estimated cost: ${credits} ${credits === 1 ? "credit" : "credits"} (charged only on successful completion)`;
152
- }
153
- /**
154
- * EXIT 4 — "a human has to decide this, and nothing was done."
155
- *
156
- * The ladder so far is 0 success · 1 error · 2 success-with-a-diff · 3
157
- * success-where-the-terminal-state-is-not-success (README, `naive teams`). All
158
- * four answer the question "did the work happen". None of them answers "the
159
- * work is BLOCKED on a choice only a person can make", and collapsing that into
160
- * 1 is what makes an agent retry: a generic failure looks transient, so it runs
161
- * the same command again, gets the same 402, and loops.
162
- *
163
- * 4 says the opposite — re-running changes nothing, and the next move belongs
164
- * to a human. A harness can branch on the code alone, without parsing the body,
165
- * and route the run to its operator instead of to its retry budget.
166
- */
167
- export const EXIT_DECISION_REQUIRED = 4;
168
- // A pending, non-fatal update notice discovered by the client layer (from the
169
- // server version handshake). It rides along on the next successful agentOutput
170
- // and is cleared once emitted, so it surfaces exactly once per command.
171
- let _pendingUpdate;
172
- /** Stash a pending update notice for the next agentOutput call (client layer → output). */
173
- export function setPendingUpdate(info) {
174
- _pendingUpdate = info;
175
- }
176
- // The same one-shot mechanism for a deprecation notice, set by lib/deprecation.ts
177
- // from a commander preAction hook. It rides the next successful envelope and is
178
- // cleared once emitted, so it appears exactly once per command.
179
- let _pendingDeprecation;
180
- /** Stash a pending deprecation notice for the next agentOutput call. */
181
- export function setPendingDeprecation(notice) {
182
- _pendingDeprecation = notice;
183
- }
184
- /** Test seam: read the pending notice without emitting it. */
185
- export function peekPendingDeprecation() {
186
- return _pendingDeprecation;
187
- }
188
- export function agentOutput(opts) {
189
- agentOutputExit(opts);
190
- }
191
- /**
192
- * `agentOutput` plus an explicit process exit code — the mechanism behind the
193
- * exit-code ladder of 06 §1.3. Exit 2 is "success, and a diff exists"
194
- * (terraform's `-detailed-exitcode`); exit 3 is "success, and the terminal state
195
- * is not success" — a CI script reading 0 as "the work is done" would otherwise
196
- * count an `unverified` task as a pass.
197
- *
198
- * It sets `process.exitCode` rather than calling `process.exit()`: the payload it
199
- * just wrote may still be buffered when stdout is a pipe, and `process.exit()`
200
- * truncates it. Setting the code lets Node drain and then exit with it.
201
- */
202
- export function agentOutputExit(opts) {
203
- // Consume any pending notices first (so they're cleared even in human mode),
204
- // then take the human-mode early return.
205
- const update = _pendingUpdate;
206
- _pendingUpdate = undefined;
207
- const deprecation = _pendingDeprecation;
208
- _pendingDeprecation = undefined;
209
- if (opts.exitCode)
210
- process.exitCode = opts.exitCode;
211
- if (humanMode()) {
212
- renderHuman(opts);
213
- return;
214
- }
215
- const output = {
216
- success: true,
217
- action: opts.action,
218
- result: opts.result,
219
- next_steps: opts.next_steps,
220
- ...(opts.hints && { hints: opts.hints }),
221
- ...(opts.related_commands && { related_commands: opts.related_commands }),
222
- ...(opts.help_markdown && { help_markdown: opts.help_markdown }),
223
- ...(update && { update }),
224
- ...(deprecation && { deprecation }),
225
- };
226
- console.log(JSON.stringify(output, null, 2));
227
- maybeDiscoveryHint();
228
- }
229
- /**
230
- * THE FAILURE ENVELOPE GOES TO STDOUT, on the same channel as the success one.
231
- *
232
- * This used to be `console.error`, and stdout was zero bytes on every failure —
233
- * so `naive <anything> --json | jq` and any agent reading stdout saw NOTHING when
234
- * a command failed, including the `recovery_steps` that are its only route out.
235
- *
236
- * That contradicted the split the rest of this CLI is built on: stdout is THE
237
- * machine document, stderr is human noise. update-notifier is stderr-only "so it
238
- * never pollutes the JSON on stdout" (index.ts); the human-mode tip above is
239
- * stderr "without polluting stdout (stays parseable JSON)"; a deprecation notice
240
- * rides "the STDOUT envelope so stdout stays JSON.parse-able and an agent can
241
- * branch on it without scraping stderr" (DeprecationNotice, above). The
242
- * `unhandledRejection` net in index.ts exists in so many words because "an agent
243
- * parsing stdout would get nothing it can act on" — and then emitted here, to
244
- * stderr, so it did not deliver the thing it was written to deliver.
245
- *
246
- * Written ONCE, not to both channels: `2>&1` is the common way an agent harness
247
- * merges these, and a second copy would put two JSON documents in one stream and
248
- * break the single-document invariant that makes stdout `JSON.parse`-able.
249
- *
250
- * `success: false` is in the envelope and the exit code is still 1, so nothing
251
- * downstream has to guess whether stdout is data — it must branch on `success`
252
- * either way, exactly as it already does for the success envelope.
253
- *
254
- * HUMAN mode is unchanged: a red ✗ line is a diagnostic for a person, and those
255
- * belong on stderr.
256
- */
257
- export function agentError(opts) {
258
- if (humanMode()) {
259
- renderHumanError(opts);
260
- process.exit(1);
261
- }
262
- const output = {
263
- success: false,
264
- action: opts.action,
265
- error: opts.error,
266
- recovery_steps: opts.recovery_steps,
267
- };
268
- console.log(JSON.stringify(output, null, 2));
269
- process.exit(1);
270
- }
271
- /**
272
- * THE REFUSAL THAT NEEDS A PERSON — `success:false`, exit {@link EXIT_DECISION_REQUIRED}.
273
- *
274
- * Shaped like `agentError` (same stdout channel, same `error` + `recovery_steps`
275
- * keys, so nothing downstream needs a new parser) with two deliberate
276
- * differences:
277
- *
278
- * 1. It carries `decision_required`, which names the question in the human's
279
- * own words and lists the ways out as ids + exact commands. An agent
280
- * relays that object to its operator; it does not pick from it.
281
- * 2. It sets `process.exitCode` instead of calling `process.exit()`. The same
282
- * reason as `agentOutputExit`: the payload may still be buffered when
283
- * stdout is a pipe, and a hard exit truncates the very JSON the caller
284
- * needs. Callers `return` after this; they must not keep working.
285
- *
286
- * HUMAN mode gets the same content as a readable block on stderr, including the
287
- * numbered options — a person who is not at an interactive terminal (output
288
- * piped to `tee`, a `--human` run in CI) still needs to see the choice rather
289
- * than a bare red line.
290
- */
291
- export function agentDecisionRequired(opts) {
292
- process.exitCode = EXIT_DECISION_REQUIRED;
293
- if (humanMode()) {
294
- const w = (s) => process.stderr.write(s);
295
- w(chalk.yellow.bold(`✗ ${opts.action} — a decision is needed`) + "\n");
296
- if (opts.error.message)
297
- w(" " + opts.error.message + "\n");
298
- if (opts.error.hint)
299
- w(chalk.dim(" hint: " + opts.error.hint) + "\n");
300
- // Already chosen at a prompt: the person has just read the menu, so echo the
301
- // one route they picked instead of reprinting the list under it.
302
- const picked = opts.decision.options.find((o) => o.id === opts.decision.chosen);
303
- if (picked) {
304
- w("\n " + chalk.bold(picked.label) + "\n");
305
- w(picked.command.startsWith("#")
306
- ? chalk.dim(` ${picked.description}`) + "\n"
307
- : " Run: " + chalk.cyan(picked.command) + "\n");
308
- return;
309
- }
310
- w("\n " + chalk.bold(opts.decision.question) + "\n");
311
- w(chalk.dim(" " + opts.decision.because) + "\n\n");
312
- opts.decision.options.forEach((o, i) => {
313
- w(` ${i + 1}) ${o.label}\n`);
314
- w(" " + chalk.cyan(o.command) + chalk.dim(` — ${o.description}`) + "\n");
315
- });
316
- return;
317
- }
318
- console.log(JSON.stringify({
319
- success: false,
320
- action: opts.action,
321
- error: opts.error,
322
- decision_required: opts.decision,
323
- recovery_steps: opts.recovery_steps,
324
- }, null, 2));
325
- }
326
- /**
327
- * 06 §1.8 — when a response body carries a governance `verdict`, the DECISION
328
- * POINT knows the recovery and the CLI's local `switch (code)` does not. The
329
- * whole point of the denial envelope is that a model recovers instead of
330
- * looping, and a hand-written table that overwrites the server's steps defeats
331
- * it. So: a body with a `verdict` and a well-formed `recovery[]` renders the
332
- * server's steps verbatim, and `getRecoverySteps` is not consulted.
333
- *
334
- * Both gates are required. `verdict` alone with no recovery falls back (the
335
- * server said nothing actionable); `recovery` alone with no verdict is ignored,
336
- * so this cannot become a way for any endpoint to rewrite the CLI's advice.
337
- * Each step is validated field by field — an entry that is not
338
- * `{command:string, description:string}` is dropped rather than printed as
339
- * `undefined`.
340
- */
341
- export function serverRecoverySteps(data) {
342
- if (typeof data !== "object" || data === null)
343
- return undefined;
344
- const body = data;
345
- const verdict = body.verdict ?? body.error?.verdict;
346
- if (typeof verdict !== "string" || verdict.length === 0)
347
- return undefined;
348
- const raw = body.recovery ?? body.error?.recovery;
349
- if (!Array.isArray(raw))
350
- return undefined;
351
- const steps = [];
352
- for (const entry of raw) {
353
- if (typeof entry !== "object" || entry === null)
354
- continue;
355
- const { command, description, when } = entry;
356
- if (typeof command !== "string" || typeof description !== "string")
357
- continue;
358
- steps.push({ command, description, ...(typeof when === "string" && { when }) });
359
- }
360
- return steps.length > 0 ? steps : undefined;
361
- }
362
- export function formatApiError(action, data) {
363
- // Accept Naive `{ error: { code, message } }`, proxy shapes where `error` is a
364
- // string (Supabase Storage), or a bare `{ message }` — never collapse to opaque
365
- // `unknown` when the upstream already said something useful.
366
- const payload = data && typeof data === "object" ? data : null;
367
- const rawError = payload?.error;
368
- let details;
369
- if (rawError && typeof rawError === "object" && !Array.isArray(rawError)) {
370
- details = rawError;
371
- }
372
- else if (typeof rawError === "string" && rawError) {
373
- const message = typeof payload?.message === "string" && payload.message ? payload.message : rawError;
374
- details = { code: "upstream_error", message };
375
- }
376
- else if (typeof payload?.message === "string" && payload.message) {
377
- details = { code: "upstream_error", message: payload.message };
378
- }
379
- if (details) {
380
- agentError({
381
- action,
382
- error: details,
383
- // A governance denial carries its own recovery — the DECISION POINT knows
384
- // the way out and this local table does not. Server steps win when both
385
- // gates in serverRecoverySteps() are satisfied.
386
- recovery_steps: serverRecoverySteps(data) ?? getRecoverySteps(details.code),
387
- });
388
- return;
389
- }
390
- agentError({
391
- action,
392
- error: {
393
- code: "unknown",
394
- message: "Unexpected error response",
395
- body_snippet: data == null ? undefined : JSON.stringify(data).slice(0, 300),
396
- },
397
- recovery_steps: getRecoverySteps("unknown"),
398
- });
399
- }
400
- /** Exported for the parity test that holds the `llm_routing_requires_payment`
401
- * case equal to `llmPaywallRecoverySteps()` in lib/llm-paywall.ts. */
402
- export function getRecoverySteps(code) {
403
- switch (code) {
404
- case "unauthorized":
405
- return [
406
- { command: "naive register --name <name> --email <email> --password <pw>", description: "Create a new account" },
407
- { command: "naive login --email <email> --password <pw>", description: "Log in to existing account" },
408
- ];
409
- case "insufficient_credits":
410
- // 🔴 NO `upgrade --plan pro` HERE. This table is keyed on the error code and
411
- // nothing else — it cannot see who is reading it — so the line it used to
412
- // carry ("Upgrade to Pro (400 credits/mo, $20/mo)") was handed to every
413
- // subscriber, including the grandfathered $149/2000 and $49/500 ones, for
414
- // whom it is a DOWNGRADE labelled an upgrade, one click from a real plan
415
- // switch: `/v1/billing/upgrade` sends an active subscriber straight to the
416
- // Stripe portal. `isUpgradeFrom()` exists to stop exactly that on the API
417
- // and dashboard surfaces, and it needs the caller's own allowance, which a
418
- // static table does not have.
419
- //
420
- // An empty wallet is a BALANCE problem anyway, not a subscription one: the
421
- // remedy is credits. `naive billing plans` is the plan-aware surface — GET
422
- // /v1/billing/plans answers with the reader's own terms and a hint that
423
- // knows whether anything on sale is more than they already have.
424
- return [
425
- { command: "naive billing topup --pack medium", description: "Buy 500 credits for $23 (Popular)" },
426
- { command: "naive billing topup --pack large", description: "Buy 1000 credits for $44 (Best Value)" },
427
- { command: "naive billing packs", description: "See all available credit packs" },
428
- { command: "naive billing plans", description: "See your plan's monthly credits and whether anything on sale includes more" },
429
- ];
430
- case "billing_blocked":
431
- // ONE plan. The Starter line is gone because Starter is retired: nothing new
432
- // may buy it, so `--plan starter` here would have handed a blocked customer a
433
- // recovery step that returns 400. Existing Starter subscriptions are
434
- // untouched — they recover through `naive billing portal`, which the
435
- // subscription_past_due path already offers, not by re-subscribing.
436
- //
437
- // TOPUP IS FIRST. `billing_blocked` used to mean only "your subscription is
438
- // in a bad state", for which subscribing is the whole answer. It now also
439
- // carries the LLM-router refusal (block_reason
440
- // `llm_routing_requires_payment`), whose cheapest door is a one-time credit
441
- // pack — a caller told only to subscribe would be pushed onto a $20/mo
442
- // recurring plan to make a $1 call. Both doors are listed for both cases
443
- // because this table is keyed on the code and cannot see which one it is;
444
- // the router refusal takes the `decision_required` path in
445
- // lib/llm-paywall.ts, which does know, and does not consult this table.
446
- return [
447
- { command: "naive billing topup --pack medium", description: "Buy 500 credits for $23 — one-time, no subscription" },
448
- { command: "naive billing subscribe --plan pro", description: "Subscribe to Pro ($20/mo, 400 credits)" },
449
- { command: "naive billing plans", description: "See the current plan and your own" },
450
- ];
451
- // The LLM router refusing free/comped credit. `naive llm chat` never reaches
452
- // this table — it intercepts the response first and emits the far richer
453
- // `decision_required` envelope with exit 4 (lib/llm-paywall.ts). This case
454
- // is the net for anything else that ever reaches the router, and the two
455
- // lists are held identical by llm-paywall.test.ts.
456
- //
457
- // 🔴 NO PURCHASE COMMAND HERE, deliberately, and unlike every other case in
458
- // this switch. `recovery_steps` is the array an agent is taught to just run;
459
- // `naive billing subscribe` sitting in it is an instruction to start a
460
- // payment nobody authorised. The purchases live in decision_required.options,
461
- // where the envelope is explicit that a human picks one.
462
- case "llm_routing_requires_payment":
463
- return [
464
- {
465
- command: "# ask the operator: subscribe, buy credits, or drop the LLM call?",
466
- description: "This refusal needs a human decision — see decision_required.options",
467
- },
468
- { command: "naive billing packs", description: "Show the credit packs and their prices" },
469
- { command: "naive billing plans", description: "Show the subscription plans and the current one" },
470
- { command: "naive billing status", description: "Show the balance and the plan currently on this account" },
471
- ];
472
- case "rate_limited":
473
- return [
474
- { command: "# wait 60 seconds then retry", description: "Rate limits reset after 60s" },
475
- ];
476
- case "resource_not_found":
477
- return [
478
- { command: "naive identity", description: "List available resources" },
479
- { command: "naive companies", description: "Check available companies" },
480
- ];
481
- case "invalid_input":
482
- return [
483
- { command: "naive <command> --help", description: "See required parameters and examples" },
484
- ];
485
- case "voice_revoked":
486
- return [
487
- { command: "naive voice list", description: "List voices that are still available" },
488
- { command: "# this voice's consent was revoked", description: "Pick another voice, or have an admin re-create it in the Studio UI" },
489
- ];
490
- case "voice_reclone_required":
491
- return [
492
- { command: "naive voice list", description: "Check the voice's tier/status" },
493
- { command: "# the requested tier has no clone", description: "Use the voice's native tier, or have an admin re-clone for that tier in Studio" },
494
- ];
495
- // Transport-level failure: the gateway returned a non-JSON body (502/503/504
496
- // HTML page). Idempotent GETs were already retried in the client; a failed POST
497
- // (e.g. llm chat) is NOT auto-retried to avoid a double-charge — the user retries.
498
- case "upstream_error":
499
- return [
500
- { command: "# retry — gateway timeouts (502/504) are usually transient", description: "Re-run your command in a moment" },
501
- { command: "naive status", description: "Check API connectivity" },
502
- {
503
- command: 'naive report "<what failed>" --command "<the command you ran>" --kind error',
504
- description: "Report it to the naive team if it persists",
505
- },
506
- ];
507
- // Genuinely-broken-on-our-side codes — these are worth reporting (unlike the
508
- // self-correctable cases above). Retry first (often transient), then report.
509
- case "provider_error":
510
- case "internal_error":
511
- return [
512
- { command: "# retry — provider/internal errors are often transient", description: "Retry once before reporting" },
513
- {
514
- command: 'naive report "<what failed>" --command "<the command you ran>" --kind error',
515
- description: "Report it to the naive team if it persists",
516
- },
517
- ];
518
- // Opaque / unexpected failures (non-JSON gateway body already mapped, or API
519
- // returned an untyped error). Agents only file tickets when recovery_steps
520
- // tell them to — without this, `unknown` silently becomes "check status".
521
- case "unknown":
522
- return [
523
- { command: "naive status", description: "Check API connectivity and auth status" },
524
- {
525
- command: 'naive report "<what failed — paste the error JSON>" --command "<the command you ran>" --kind error',
526
- description: "File a tracked report — unexpected errors are product bugs until proven otherwise",
527
- },
528
- ];
529
- default:
530
- return [
531
- { command: "naive status", description: "Check API connectivity and auth status" },
532
- {
533
- command: 'naive report "<what failed — paste the error JSON>" --command "<the command you ran>" --kind error',
534
- description: "If this is not a credits/auth/invalid-input issue you can fix yourself, report it",
535
- },
536
- ];
537
- }
538
- }
539
- //# sourceMappingURL=output.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,IAAI,SAAS,GA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AC;QACJ,KAAK,wBAAwB;YAC3B,OAAO;gBACL,EAAE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,+BAA+B,EAAE;gBAC7E,EAAE,OAAO,EAAE,mCAAmC,EAAE,WAAW,EAAE,gFAAgF,EAAE;aAChJ,CAAC;QACJ,6EAA6E;QAC7E,gFAAgF;QAChF,mFAAmF;QACnF,KAAK,gBAAgB;YACnB,OAAO;gBACL,EAAE,OAAO,EAAE,4DAA4D,EAAE,WAAW,EAAE,iCAAiC,EAAE;gBACzH,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wBAAwB,EAAE;gBAClE;oBACE,OAAO,EAAE,6EAA6E;oBACtF,WAAW,EAAE,4CAA4C;iBAC1D;aACF,CAAC;QACJ,6EAA6E;QAC7E,6EAA6E;QAC7E,KAAK,gBAAgB,CAAC;QACtB,KAAK,gBAAgB;YACnB,OAAO;gBACL,EAAE,OAAO,EAAE,wDAAwD,EAAE,WAAW,EAAE,6BAA6B,EAAE;gBACjH;oBACE,OAAO,EAAE,6EAA6E;oBACtF,WAAW,EAAE,4CAA4C;iBAC1D;aACF,CAAC;QACJ,6EAA6E;QAC7E,2EAA2E;QAC3E,0EAA0E;QAC1E,KAAK,SAAS;YACZ,OAAO;gBACL,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC,EAAE;gBAClF;oBACE,OAAO,EAAE,oGAAoG;oBAC7G,WAAW,EAAE,mFAAmF;iBACjG;aACF,CAAC;QACJ;YACE,OAAO;gBACL,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC,EAAE;gBAClF;oBACE,OAAO,EAAE,oGAAoG;oBAC7G,WAAW,EAAE,mFAAmF;iBACjG;aACF,CAAC;IACN,CAAC;AACH,CAAC"}
package/dist/prompt.d.ts DELETED
@@ -1,17 +0,0 @@
1
- /** Free-text answer. Returns null on timeout/abort. */
2
- export declare function ask(label: string, opts?: {
3
- default?: string;
4
- }): Promise<string | null>;
5
- /** Yes/No. Default NO (returns false on timeout, empty, or anything not starting with y). */
6
- export declare function confirm(label: string): Promise<boolean>;
7
- /** Affirmation: Enter (empty) OR 'y' = affirm; 'n'/anything else/timeout = cancel. For consent
8
- * disclosures where the user has read the terms and presses Enter to take responsibility. */
9
- export declare function affirm(label: string): Promise<boolean>;
10
- /** Type-to-confirm for irreversible actions (GitHub-delete pattern). True only if the typed text
11
- * matches `expected` exactly. Default-deny on timeout/mismatch. */
12
- export declare function confirmExact(label: string, expected: string): Promise<boolean>;
13
- /** Numbered single-select. Returns the chosen value, or null on timeout/invalid. */
14
- export declare function select(label: string, choices: {
15
- value: string;
16
- label: string;
17
- }[]): Promise<string | null>;
package/dist/prompt.js DELETED
@@ -1,70 +0,0 @@
1
- // Minimal interactive prompts built on Node's built-in readline/promises — NO new dependency
2
- // (deliberate: this is a credential-handling CLI; a prompt lib would run in the same process as the
3
- // session token + api_key). Every prompt has a hard timeout that resolves to a SAFE default, so a
4
- // pty-wrapped caller that somehow reaches a prompt times out into abort instead of hanging forever.
5
- // Callers MUST gate these on isInteractive() (human mode + interactive stdin) — these helpers do not
6
- // re-check that themselves.
7
- import * as readline from "node:readline/promises";
8
- const DEFAULT_TIMEOUT_MS = 30_000;
9
- async function question(q, timeoutMs = DEFAULT_TIMEOUT_MS) {
10
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
11
- let timer;
12
- try {
13
- const timeout = new Promise((resolve) => {
14
- timer = setTimeout(() => {
15
- process.stdout.write("\n(timed out — aborting)\n");
16
- resolve(null);
17
- }, timeoutMs);
18
- });
19
- const answer = rl.question(q).then((a) => a);
20
- const result = await Promise.race([answer, timeout]);
21
- return result;
22
- }
23
- finally {
24
- if (timer)
25
- clearTimeout(timer);
26
- rl.close();
27
- }
28
- }
29
- /** Free-text answer. Returns null on timeout/abort. */
30
- export async function ask(label, opts = {}) {
31
- const suffix = opts.default ? ` [${opts.default}]` : "";
32
- const a = await question(`${label}${suffix}: `);
33
- if (a === null)
34
- return null;
35
- const trimmed = a.trim();
36
- return trimmed === "" && opts.default !== undefined ? opts.default : trimmed;
37
- }
38
- /** Yes/No. Default NO (returns false on timeout, empty, or anything not starting with y). */
39
- export async function confirm(label) {
40
- const a = await question(`${label} (y/N): `);
41
- return a !== null && a.trim().toLowerCase().startsWith("y");
42
- }
43
- /** Affirmation: Enter (empty) OR 'y' = affirm; 'n'/anything else/timeout = cancel. For consent
44
- * disclosures where the user has read the terms and presses Enter to take responsibility. */
45
- export async function affirm(label) {
46
- const a = await question(`${label} [Enter to affirm, 'n' to cancel]: `);
47
- if (a === null)
48
- return false; // timeout = cancel (safe)
49
- const t = a.trim().toLowerCase();
50
- return t === "" || t.startsWith("y");
51
- }
52
- /** Type-to-confirm for irreversible actions (GitHub-delete pattern). True only if the typed text
53
- * matches `expected` exactly. Default-deny on timeout/mismatch. */
54
- export async function confirmExact(label, expected) {
55
- const a = await question(`${label}: `);
56
- return a !== null && a.trim() === expected;
57
- }
58
- /** Numbered single-select. Returns the chosen value, or null on timeout/invalid. */
59
- export async function select(label, choices) {
60
- process.stdout.write(`${label}\n`);
61
- choices.forEach((c, i) => process.stdout.write(` ${i + 1}) ${c.label}\n`));
62
- const a = await question(`Choose 1-${choices.length}: `);
63
- if (a === null)
64
- return null;
65
- const n = parseInt(a.trim(), 10);
66
- if (Number.isNaN(n) || n < 1 || n > choices.length)
67
- return null;
68
- return choices[n - 1].value;
69
- }
70
- //# sourceMappingURL=prompt.js.map