@usenaive-sdk/cli 0.15.1 → 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 (281) hide show
  1. package/README.md +43 -402
  2. package/dist/index.js +51796 -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
@@ -1,231 +0,0 @@
1
- /**
2
- * THE LLM ROUTER REFUSES TRIAL CREDIT — how the CLI says so.
3
- *
4
- * ── WHAT CHANGED UPSTREAM ───────────────────────────────────────────────────
5
- *
6
- * The signup grant (20 credits, $1.00) is spendable on every primitive this
7
- * platform has except one: raw model routing. A company earns the router by
8
- * having paid for something — a subscription, or a credit pack — and never by
9
- * having been given credit. The API answers an unentitled router call with 402
10
- * `llm_routing_requires_payment`, the same string again in
11
- * `details.block_reason`.
12
- *
13
- * That is a NEW KIND of refusal for this CLI and it must not be rendered like
14
- * the old ones:
15
- *
16
- * - It is not `insufficient_credits`. The balance may be 20, or 20,000 of
17
- * comped credit; buying nothing and waiting changes nothing. Telling the
18
- * caller "you are low on credits" would be false and would send them to
19
- * `naive usage` to look at a number that is fine.
20
- * - It is not transient. Every existing 1-exit invites a retry, and an agent
21
- * with a retry budget will spend all of it here.
22
- * - It is not the CLI's to resolve. There are exactly two ways out, both of
23
- * them spend the operator's money, and they differ (recurring vs one-off).
24
- *
25
- * ── SO IT IS A DECISION, NOT AN ERROR ───────────────────────────────────────
26
- *
27
- * This module turns the 402 into a {@link DecisionRequired}: the question in the
28
- * human's words, the reason the CLI will not answer it, and the ways out as
29
- * stable ids plus the exact command that takes each. It exits
30
- * {@link EXIT_DECISION_REQUIRED} (4), not 1, so a harness can route the run to
31
- * its operator on the exit code alone.
32
- *
33
- * At a real interactive terminal it asks. Everywhere else — which is every
34
- * agent, because this CLI's output mode is opt-in human and machine mode is the
35
- * default (see the header of output.ts) — it prints the choice and stops. It
36
- * never picks. An agent that guesses here buys a subscription nobody asked for.
37
- *
38
- * ── WHY THE COMMANDS ARE ONLY PRINTED, NEVER RUN ────────────────────────────
39
- *
40
- * A chosen option is echoed, not executed, even after a human picked it at the
41
- * prompt. `naive billing subscribe` and `naive billing topup` open a Stripe
42
- * checkout; a "y" typed into a prompt that appeared unbidden in the middle of an
43
- * unrelated `naive llm chat` is not consent to start a payment flow. The human
44
- * chooses the ROUTE here and takes it themselves, on purpose, in one more
45
- * keystroke.
46
- */
47
- import { select } from "../prompt.js";
48
- import { agentDecisionRequired, isInteractive, serverRecoverySteps, } from "../output.js";
49
- /**
50
- * The wire token for this refusal. It is BOTH `error.code` and
51
- * `error.details.block_reason` — the API emits the same string in both places
52
- * on purpose (platform/billing/src/llm-access.ts), so a consumer that switches
53
- * on the reason needs no mapping from the code.
54
- *
55
- * Matching on either and never on the MESSAGE: prose is the thing most likely
56
- * to be reworded, and a CLI that string-matches it goes silently generic the
57
- * first time someone improves the sentence.
58
- *
59
- * The code is dedicated rather than a `billing_blocked` variant, and that
60
- * distinction is the whole point: `billing_blocked` and `insufficient_credits`
61
- * both mean "get more credit", which here is the one action that provably
62
- * cannot work. Sharing a code would have made the two indistinguishable to
63
- * exactly the population that has to distinguish them.
64
- */
65
- export const LLM_ROUTING_ERROR_CODE = "llm_routing_requires_payment";
66
- /** Alias kept because the same string is also the `details.block_reason` value. */
67
- export const LLM_ROUTING_BLOCK_REASON = LLM_ROUTING_ERROR_CODE;
68
- /**
69
- * Is this response the router's paid-account refusal? Returns the parts worth
70
- * rendering, or null for every other body.
71
- *
72
- * `code` OR `block_reason` satisfies it, and `block_reason` is read from BOTH
73
- * positions, because `NaiveError.toJSON()` emits `details` nested AND spread
74
- * (platform/kernel/src/errors.ts) — a reader that picks one position is betting
75
- * on which half gets retired first, and a reader that requires both is broken
76
- * by whichever goes.
77
- */
78
- export function llmRoutingRefusal(data) {
79
- if (typeof data !== "object" || data === null)
80
- return null;
81
- const err = data.error;
82
- if (typeof err !== "object" || err === null)
83
- return null;
84
- const e = err;
85
- const details = (typeof e.details === "object" && e.details !== null ? e.details : {});
86
- const matches = e.code === LLM_ROUTING_ERROR_CODE ||
87
- e.block_reason === LLM_ROUTING_BLOCK_REASON ||
88
- details.block_reason === LLM_ROUTING_BLOCK_REASON;
89
- if (!matches)
90
- return null;
91
- const str = (k) => {
92
- const v = e[k] ?? details[k];
93
- return typeof v === "string" && v ? v : undefined;
94
- };
95
- const rawBalance = typeof e.balance === "number" ? e.balance : details.balance;
96
- return {
97
- ...(str("code") && { code: str("code") }),
98
- ...(str("message") && { message: str("message") }),
99
- ...(str("hint") && { hint: str("hint") }),
100
- ...(str("docs") && { docs: str("docs") }),
101
- ...(str("balance_note") && { balance_note: str("balance_note") }),
102
- ...(str("credit_kind") && { credit_kind: str("credit_kind") }),
103
- ...(typeof rawBalance === "number" && Number.isFinite(rawBalance) && { balance: rawBalance }),
104
- };
105
- }
106
- /**
107
- * The fallback sentence, used when the server sent no message of its own.
108
- *
109
- * It names what trial credit DOES buy. A refusal that only says "no" reads as a
110
- * paywall on the product; this one is a control on one primitive, and a new
111
- * account that has just been handed 20 credits deserves to hear that the other
112
- * twenty-odd primitives still take them.
113
- */
114
- export const LLM_PAYWALL_MESSAGE = "The LLM router requires paid credit. Free signup credits spend on every other primitive — " +
115
- "email, search, images, brain, runtime — but not on raw model routing.";
116
- export const LLM_PAYWALL_QUESTION = "The LLM router needs paid credit on this account. Add a subscription, buy credits, or stop here?";
117
- const LLM_PAYWALL_BECAUSE = "Both ways out spend real money, and they are not the same deal — one is recurring, one is not. " +
118
- "The CLI will not choose that for you.";
119
- /** The ways out, in the order a first-time caller should weigh them. */
120
- export function llmPaywallOptions() {
121
- return [
122
- {
123
- id: "topup",
124
- label: "Buy credits once — 500 credits for $23",
125
- command: "naive billing topup --pack medium",
126
- description: "One-time purchase, no subscription. Unlocks the router permanently.",
127
- },
128
- {
129
- id: "subscribe",
130
- label: "Subscribe to Pro — $20/mo, 400 credits every month",
131
- command: "naive billing subscribe --plan pro",
132
- description: "Recurring. Unlocks the router and refills the balance monthly.",
133
- },
134
- {
135
- id: "not_now",
136
- label: "Neither — do not route this call",
137
- command: "# nothing to run; the model call did not happen and nothing was charged",
138
- description: "Every other primitive still works on the credits already on the account.",
139
- },
140
- ];
141
- }
142
- /**
143
- * The `recovery_steps` array. It stays a LIST OF READS, not of purchases: the
144
- * purchases live in `decision_required.options`, where the envelope is explicit
145
- * that a human has to choose one. Putting `topup` in both places would let an
146
- * agent that only reads `recovery_steps` — the habit every other error on this
147
- * surface teaches — treat "buy something" as a step it is cleared to take.
148
- */
149
- export function llmPaywallRecoverySteps() {
150
- return [
151
- {
152
- command: "# ask the operator: subscribe, buy credits, or drop the LLM call?",
153
- description: "This refusal needs a human decision — see decision_required.options",
154
- },
155
- { command: "naive billing packs", description: "Show the credit packs and their prices" },
156
- { command: "naive billing plans", description: "Show the subscription plans and the current one" },
157
- { command: "naive billing status", description: "Show the balance and the plan currently on this account" },
158
- ];
159
- }
160
- function decision(chosen) {
161
- return {
162
- question: LLM_PAYWALL_QUESTION,
163
- because: LLM_PAYWALL_BECAUSE,
164
- options: llmPaywallOptions(),
165
- chosen,
166
- };
167
- }
168
- /**
169
- * The `error` half of the envelope. The server's own code, sentence, hint and
170
- * docs are ECHOED, not replaced — it is the decision point, and a CLI that
171
- * substitutes its own copy makes the terminal and the API disagree about why a
172
- * call was refused. The fallbacks below only fire against an API build that
173
- * sent nothing.
174
- */
175
- function errorDetails(refusal) {
176
- return {
177
- code: refusal.code ?? LLM_ROUTING_ERROR_CODE,
178
- // Kept alongside the code even though they carry the same string: consumers
179
- // that switch on the reason (and older ones that only know `billing_blocked`)
180
- // read this field, and dropping it would break them for no gain.
181
- block_reason: LLM_ROUTING_BLOCK_REASON,
182
- message: refusal.message ?? LLM_PAYWALL_MESSAGE,
183
- ...(refusal.hint && { hint: refusal.hint }),
184
- ...(refusal.docs && { docs: refusal.docs }),
185
- ...(refusal.credit_kind && { credit_kind: refusal.credit_kind }),
186
- ...(refusal.balance !== undefined && {
187
- balance: refusal.balance,
188
- // Said explicitly because the number alone reads as a contradiction: the
189
- // account has credit and the call was still refused. The API sends this
190
- // sentence itself; the fallback is for a build that does not.
191
- balance_note: refusal.balance_note ??
192
- `The balance of ${refusal.balance} credit${refusal.balance === 1 ? "" : "s"} is not the problem — ` +
193
- "free and comped credit cannot pay for model routing, however much of it there is.",
194
- }),
195
- // 🔴 The field that stops the loop. Every other failure this CLI emits is
196
- // worth one more attempt; this one is worth none, ever, until a human buys
197
- // something.
198
- retryable: false,
199
- };
200
- }
201
- /**
202
- * Intercept the router's paid-account refusal. Returns true when it handled the
203
- * response, in which case the caller MUST return without calling
204
- * `handleApiError` — that would emit a second envelope and exit 1 over the top
205
- * of this one.
206
- *
207
- * Returns false for every other response, including a healthy one, so a call
208
- * site reads as one line ahead of its normal error handling.
209
- */
210
- export async function handleLlmRoutingRefusal(action, resp) {
211
- const refusal = llmRoutingRefusal(resp.data);
212
- if (!refusal)
213
- return false;
214
- // A real person, at a real terminal: ask. `isInteractive()` is human mode AND
215
- // a TTY stdin — a pty-wrapped agent harness reports isTTY true, which is
216
- // exactly why output mode is opt-in and why this predicate and not
217
- // `process.stdin.isTTY` is the gate.
218
- const chosen = isInteractive()
219
- ? await select(`\n${LLM_PAYWALL_QUESTION}\n`, llmPaywallOptions().map((o) => ({ value: o.id, label: `${o.label}\n ${o.command}` })))
220
- : null;
221
- agentDecisionRequired({
222
- action,
223
- error: errorDetails(refusal),
224
- // The server is the decision point and may know a recovery this table does
225
- // not (06 §1.8); its steps win when it supplied them under a verdict.
226
- decision: decision(chosen),
227
- recovery_steps: serverRecoverySteps(resp.data) ?? llmPaywallRecoverySteps(),
228
- });
229
- return true;
230
- }
231
- //# sourceMappingURL=llm-paywall.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"llm-paywall.js","sourceRoot":"","sources":["../../src/lib/llm-paywall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,mBAAmB,GAKpB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AAErE,mFAAmF;AACnF,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAqB/D;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC7C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,GAAG,GAAI,IAA4B,CAAC,KAAK,CAAC;IAChD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACzD,MAAM,CAAC,GAAG,GAA8B,CAAC;IACzC,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAA4B,CAAC;IAElH,MAAM,OAAO,GACX,CAAC,CAAC,IAAI,KAAK,sBAAsB;QACjC,CAAC,CAAC,YAAY,KAAK,wBAAwB;QAC3C,OAAO,CAAC,YAAY,KAAK,wBAAwB,CAAC;IACpD,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,MAAM,GAAG,GAAG,CAAC,C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AAU,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAC1F;QACH,CAAC,CAAC,IAAI,CAAC;IAET,qBAAqB,CAAC;QACpB,MAAM;QACN,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC;QAC5B,2EAA2E;QAC3E,sEAAsE;QACtE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC;QAC1B,cAAc,EAAE,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,uBAAuB,EAAE;KAC5E,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,132 +0,0 @@
1
- /**
2
- * Fixed public prices mirrored from the API meters, so CLI copy cannot silently
3
- * drift from billing. Keep dynamic model costs out of this table.
4
- *
5
- * The source of truth is `FIXED_CREDIT_COSTS` in platform/billing/src/pricing.ts
6
- * and `pricing-parity.test.ts` holds the two equal. This header used to name
7
- * packages/api/src/lib/pricing.ts — a path the #497 restructure deleted — and
8
- * to promise a "dogfood contract test" that no file in the repo implemented.
9
- */
10
- export declare const FIXED_CREDIT_COSTS: {
11
- readonly emailSend: 0.016;
12
- readonly webSearch: 0.2;
13
- readonly urlRead: 0.05;
14
- readonly researchQuick: 0.5;
15
- readonly researchThorough: 1;
16
- readonly researchExhaustive: 1.6;
17
- readonly brainQuery: 0.08;
18
- readonly brainIngestBase: 0.1;
19
- readonly brainIngestPerKb: 0.0002;
20
- readonly brainIngestMaxCredits: 10;
21
- readonly socialPost: 2.5;
22
- readonly socialXPost: 0.5;
23
- readonly socialXPostWithLink: 5;
24
- };
25
- /**
26
- * The DataForSEO-backed data primitives (seo / aeo / app-data / business /
27
- * ecommerce), mirrored from `DATA_API_CREDIT_COSTS` in
28
- * platform/billing/src/pricing.ts, which is where the reasoning, the vendor list
29
- * price behind each number and the market anchor live. Held equal to it by
30
- * packages/api/src/__tests__/credit-price-parity.test.ts.
31
- *
32
- * These are LIST prices. A charge is additionally floored at 1.2× what the call
33
- * cost us upstream, so a row-heavy response can settle above the figure quoted
34
- * here — which is why every CLI hint renders the response's own `credits_used`
35
- * and only the `--help` epilogues quote this table.
36
- */
37
- export declare const DATA_API_CREDIT_COSTS: {
38
- readonly seoKeywordsAdsLive: 2;
39
- readonly seoKeywordsAdsStandard: 1.5;
40
- readonly seoKeywordsTrendsLive: 0.25;
41
- readonly seoKeywordsTrendsStandard: 0.2;
42
- readonly seoBacklinksStandard: 1.8;
43
- readonly seoBacklinksBulk: 17;
44
- readonly seoLabsStandard: 0.75;
45
- readonly seoLabsBulk: 5.4;
46
- readonly seoLabsHistorical: 10;
47
- readonly aeoLlmResponsesLive: 1.2;
48
- readonly aeoLlmResponsesStandard: 1.2;
49
- readonly aeoLlmScraperLive: 0.16;
50
- readonly aeoLlmScraperStandard: 0.08;
51
- readonly appDataAppSearches: 0.85;
52
- readonly appDataAppList: 0.85;
53
- readonly appDataAppInfo: 0.05;
54
- readonly appDataAppReviews: 6;
55
- readonly businessGoogleInfoLive: 0.13;
56
- readonly businessGoogleInfoStandard: 0.09;
57
- readonly businessGoogleUpdatesStandard: 3;
58
- readonly businessGoogleReviewsStandard: 1.5;
59
- readonly businessGoogleQaLive: 0.3;
60
- readonly businessGoogleQaStandard: 0.18;
61
- readonly businessGoogleHotelLive: 0.1;
62
- readonly businessGoogleHotelStandard: 0.07;
63
- readonly businessTrustpilotSearchStandard: 0.34;
64
- readonly businessTrustpilotReviewsStandard: 0.85;
65
- readonly businessTripadvisorSearchStandard: 0.85;
66
- readonly businessTripadvisorReviewsStandard: 1.25;
67
- readonly businessSocialLive: 0.1;
68
- readonly ecommerceGoogleProducts: 0.15;
69
- readonly ecommerceGoogleProductInfo: 0.14;
70
- readonly ecommerceGoogleSellers: 0.24;
71
- readonly ecommerceGoogleReviews: 2.2;
72
- readonly ecommerceAmazonProducts: 0.14;
73
- readonly ecommerceAmazonAsin: 0.04;
74
- readonly ecommerceAmazonSellers: 0.14;
75
- };
76
- /**
77
- * The two row-metered families, whose price is a base plus a per-row rate rather
78
- * than a flat figure. Mirrored from the same module; `appListingsCredits` /
79
- * `aeoLlmMentionsCredits` there are the functions that bill.
80
- */
81
- export declare const METERED_DATA_API_CREDITS: {
82
- readonly llmMentionsBase: 2.4;
83
- readonly llmMentionsPerRow: 0.024;
84
- readonly llmMentionsMaxRows: 1000;
85
- readonly llmMentionsDefaultRows: 100;
86
- readonly appListingsBase: 2.4;
87
- readonly appListingsPerItem: 0.024;
88
- readonly aiKeywordsBase: 0.4;
89
- readonly aiKeywordsPerKeyword: 0.004;
90
- };
91
- /** `2.4 + 0.024 × rows`, the LLM Mentions price the API charges for `rows` rows. */
92
- export declare function llmMentionsCredits(rows: number): number;
93
- /** `2.4 + 0.024 × limit`, the live app-listings price for a given `--limit`. */
94
- export declare function appListingsCredits(limit: number): number;
95
- export declare function reportedCreditsUsed(data: unknown, fallback: number): number;
96
- export interface CreditPack {
97
- id: string;
98
- credits: number;
99
- priceInCents: number;
100
- badge?: string;
101
- }
102
- /**
103
- * The one-time credit packs, mirrored field-for-field from `CREDIT_PACKS` in
104
- * platform/billing/src/billing.ts — the table `createTopupCheckout` bills
105
- * Stripe from. The CLI ships to npm with five runtime dependencies and cannot
106
- * import the billing package, so this is a mirror; `pricing-parity.test.ts`
107
- * imports both and fails on any divergence.
108
- *
109
- * 🔴 EVERY pack figure the CLI prints must come from here. The `--help`
110
- * epilogue and the `--pack` option description used to carry two independent
111
- * hand-typed copies, and one of them drifted to a tenth of the real price.
112
- */
113
- export declare const CREDIT_PACKS: readonly CreditPack[];
114
- /** `$23` — whole dollars, matching how the API renders `getCreditPacks().price`. */
115
- export declare function packPrice(pack: CreditPack): string;
116
- /** `medium (500 credits, $23)` — the inline form for an option description. */
117
- export declare function packInline(pack: CreditPack): string;
118
- /** One column-aligned row of the pack table in `naive billing --help`. */
119
- export declare function packRow(pack: CreditPack): string;
120
- /**
121
- * The flat 9:16 vertical-reframe / face-tracking fee, in credits, mirrored from
122
- * `usdToBillableCredits(REFRAME_FEE_USD_PER_JOB)` in
123
- * platform/billing/src/pricing.ts — the value clipCost() adds to a reframed
124
- * job's subtotal. Charged once per job, not per clip.
125
- *
126
- * The CLI used to advertise this as "typically $0.05–$0.30 per job", which is
127
- * the band clip-job-cost-audit.md records the CLI advertising while the code
128
- * charged nothing at all. It is now a flat fee, billed in credits like every
129
- * other driver, and this constant is held equal to the meter by
130
- * packages/api/src/__tests__/credit-price-parity.test.ts.
131
- */
132
- export declare const REFRAME_FEE_CREDITS = 4;
@@ -1,148 +0,0 @@
1
- /**
2
- * Fixed public prices mirrored from the API meters, so CLI copy cannot silently
3
- * drift from billing. Keep dynamic model costs out of this table.
4
- *
5
- * The source of truth is `FIXED_CREDIT_COSTS` in platform/billing/src/pricing.ts
6
- * and `pricing-parity.test.ts` holds the two equal. This header used to name
7
- * packages/api/src/lib/pricing.ts — a path the #497 restructure deleted — and
8
- * to promise a "dogfood contract test" that no file in the repo implemented.
9
- */
10
- export const FIXED_CREDIT_COSTS = {
11
- emailSend: 0.016,
12
- webSearch: 0.2,
13
- urlRead: 0.05,
14
- researchQuick: 0.5,
15
- researchThorough: 1,
16
- researchExhaustive: 1.6,
17
- brainQuery: 0.08,
18
- brainIngestBase: 0.1,
19
- brainIngestPerKb: 0.0002,
20
- brainIngestMaxCredits: 10,
21
- socialPost: 2.5,
22
- socialXPost: 0.5,
23
- socialXPostWithLink: 5,
24
- };
25
- /**
26
- * The DataForSEO-backed data primitives (seo / aeo / app-data / business /
27
- * ecommerce), mirrored from `DATA_API_CREDIT_COSTS` in
28
- * platform/billing/src/pricing.ts, which is where the reasoning, the vendor list
29
- * price behind each number and the market anchor live. Held equal to it by
30
- * packages/api/src/__tests__/credit-price-parity.test.ts.
31
- *
32
- * These are LIST prices. A charge is additionally floored at 1.2× what the call
33
- * cost us upstream, so a row-heavy response can settle above the figure quoted
34
- * here — which is why every CLI hint renders the response's own `credits_used`
35
- * and only the `--help` epilogues quote this table.
36
- */
37
- export const DATA_API_CREDIT_COSTS = {
38
- seoKeywordsAdsLive: 2,
39
- seoKeywordsAdsStandard: 1.5,
40
- seoKeywordsTrendsLive: 0.25,
41
- seoKeywordsTrendsStandard: 0.2,
42
- seoBacklinksStandard: 1.8,
43
- seoBacklinksBulk: 17,
44
- seoLabsStandard: 0.75,
45
- seoLabsBulk: 5.4,
46
- seoLabsHistorical: 10,
47
- aeoLlmResponsesLive: 1.2,
48
- aeoLlmResponsesStandard: 1.2,
49
- aeoLlmScraperLive: 0.16,
50
- aeoLlmScraperStandard: 0.08,
51
- appDataAppSearches: 0.85,
52
- appDataAppList: 0.85,
53
- appDataAppInfo: 0.05,
54
- appDataAppReviews: 6,
55
- businessGoogleInfoLive: 0.13,
56
- businessGoogleInfoStandard: 0.09,
57
- businessGoogleUpdatesStandard: 3,
58
- businessGoogleReviewsStandard: 1.5,
59
- businessGoogleQaLive: 0.3,
60
- businessGoogleQaStandard: 0.18,
61
- businessGoogleHotelLive: 0.1,
62
- businessGoogleHotelStandard: 0.07,
63
- businessTrustpilotSearchStandard: 0.34,
64
- businessTrustpilotReviewsStandard: 0.85,
65
- businessTripadvisorSearchStandard: 0.85,
66
- businessTripadvisorReviewsStandard: 1.25,
67
- businessSocialLive: 0.1,
68
- ecommerceGoogleProducts: 0.15,
69
- ecommerceGoogleProductInfo: 0.14,
70
- ecommerceGoogleSellers: 0.24,
71
- ecommerceGoogleReviews: 2.2,
72
- ecommerceAmazonProducts: 0.14,
73
- ecommerceAmazonAsin: 0.04,
74
- ecommerceAmazonSellers: 0.14,
75
- };
76
- /**
77
- * The two row-metered families, whose price is a base plus a per-row rate rather
78
- * than a flat figure. Mirrored from the same module; `appListingsCredits` /
79
- * `aeoLlmMentionsCredits` there are the functions that bill.
80
- */
81
- export const METERED_DATA_API_CREDITS = {
82
- llmMentionsBase: 2.4,
83
- llmMentionsPerRow: 0.024,
84
- llmMentionsMaxRows: 1000,
85
- llmMentionsDefaultRows: 100,
86
- appListingsBase: 2.4,
87
- appListingsPerItem: 0.024,
88
- aiKeywordsBase: 0.4,
89
- aiKeywordsPerKeyword: 0.004,
90
- };
91
- /** `2.4 + 0.024 × rows`, the LLM Mentions price the API charges for `rows` rows. */
92
- export function llmMentionsCredits(rows) {
93
- const capped = Math.min(Math.max(rows, 1), METERED_DATA_API_CREDITS.llmMentionsMaxRows);
94
- return Math.ceil((METERED_DATA_API_CREDITS.llmMentionsBase + METERED_DATA_API_CREDITS.llmMentionsPerRow * capped) * 100) / 100;
95
- }
96
- /** `2.4 + 0.024 × limit`, the live app-listings price for a given `--limit`. */
97
- export function appListingsCredits(limit) {
98
- return Math.ceil((METERED_DATA_API_CREDITS.appListingsBase + METERED_DATA_API_CREDITS.appListingsPerItem * Math.max(limit, 1)) * 100) / 100;
99
- }
100
- export function reportedCreditsUsed(data, fallback) {
101
- const value = data?.credits_used;
102
- return typeof value === "number" && Number.isFinite(value) ? value : fallback;
103
- }
104
- /**
105
- * The one-time credit packs, mirrored field-for-field from `CREDIT_PACKS` in
106
- * platform/billing/src/billing.ts — the table `createTopupCheckout` bills
107
- * Stripe from. The CLI ships to npm with five runtime dependencies and cannot
108
- * import the billing package, so this is a mirror; `pricing-parity.test.ts`
109
- * imports both and fails on any divergence.
110
- *
111
- * 🔴 EVERY pack figure the CLI prints must come from here. The `--help`
112
- * epilogue and the `--pack` option description used to carry two independent
113
- * hand-typed copies, and one of them drifted to a tenth of the real price.
114
- */
115
- export const CREDIT_PACKS = [
116
- { id: "small", credits: 200, priceInCents: 1000 },
117
- { id: "medium", credits: 500, priceInCents: 2300, badge: "Popular" },
118
- { id: "large", credits: 1000, priceInCents: 4400, badge: "Best Value" },
119
- { id: "xl", credits: 2500, priceInCents: 10000 },
120
- ];
121
- /** `$23` — whole dollars, matching how the API renders `getCreditPacks().price`. */
122
- export function packPrice(pack) {
123
- return `$${(pack.priceInCents / 100).toFixed(0)}`;
124
- }
125
- /** `medium (500 credits, $23)` — the inline form for an option description. */
126
- export function packInline(pack) {
127
- return `${pack.id} (${pack.credits} credits, ${packPrice(pack)})`;
128
- }
129
- /** One column-aligned row of the pack table in `naive billing --help`. */
130
- export function packRow(pack) {
131
- const credits = `${pack.credits} credits`.padEnd(15);
132
- const price = pack.badge ? `${packPrice(pack).padEnd(6)}(${pack.badge})` : packPrice(pack);
133
- return ` ${pack.id.padEnd(10)}${credits}${price}`;
134
- }
135
- /**
136
- * The flat 9:16 vertical-reframe / face-tracking fee, in credits, mirrored from
137
- * `usdToBillableCredits(REFRAME_FEE_USD_PER_JOB)` in
138
- * platform/billing/src/pricing.ts — the value clipCost() adds to a reframed
139
- * job's subtotal. Charged once per job, not per clip.
140
- *
141
- * The CLI used to advertise this as "typically $0.05–$0.30 per job", which is
142
- * the band clip-job-cost-audit.md records the CLI advertising while the code
143
- * charged nothing at all. It is now a flat fee, billed in credits like every
144
- * other driver, and this constant is held equal to the meter by
145
- * packages/api/src/__tests__/credit-price-parity.test.ts.
146
- */
147
- export const REFRAME_FEE_CREDITS = 4;
148
- //# sourceMappingURL=pricing.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/lib/pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,GAAG;IACd,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,GAAG;IAClB,gBAAgB,EAAE,CAAC;IACnB,kBAAkB,EAAE,GAAG;IACvB,UAAU,EAAE,IAAI;IAChB,eAAe,EAAE,GAAG;IACpB,gBAAgB,EAAE,MAAM;IACxB,qBAAqB,EAAE,EAAE;IACzB,UAAU,EAAE,GAAG;IACf,WAAW,EAAE,GAAG;IAChB,mBAAmB,EAAE,CAAC;CACd,CAAC;AAEX;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,kBAAkB,EAAE,CAAC;IACrB,sBAAsB,EAAE,GAAG;IAC3B,qBAAqB,EAAE,IAAI;IAC3B,y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K,EAAE;CACjD,CAAC;AAEF,oFAAoF;AACpF,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,IAAgB;IACzC,OAAO,GAAG,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,OAAO,aAAa,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;AACpE,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,OAAO,CAAC,IAAgB;IACtC,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC3F,OAAO,KAAK,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO,GAAG,KAAK,EAAE,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * The `naive init` starter, extracted so the suite can compile it with the real
3
- * DSL instead of asserting on substrings of a template literal.
4
- *
5
- * CONTENT IS MAIN'S, NOT THIS BRANCH'S. The extraction is this branch's idea and
6
- * is kept; the template it originally carried scaffolded the RETIRED surface
7
- * (`defineConfig` + `system(...)` + `business`/`identity`). Landing that would
8
- * have made `naive init` — the first command a new user runs — emit a config
9
- * against a deprecated API, which is a worse regression than the refactor is an
10
- * improvement. The body below is the `defineProject`/`kit`/`team` starter from
11
- * main, verbatim.
12
- */
13
- export declare const STARTER_CONFIG = "import { defineProject, cloud, agent, kit, runtime, team, skills } from \"@usenaive-sdk/iac\";\n\n// Na\u00EFve gives every agent its own governed, real-world identity. Declare the\n// project's shared infrastructure ONCE, then your teams. Run `naive up` to\n// plan and apply. `defineProject` is STRICT: a field nothing consumes is a\n// named refusal at define time, never a green apply that enforces nothing.\nexport default defineProject({\n project: \"my-project\",\n\n // \u2500\u2500 infrastructure: set up ONCE for the whole project \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Cloud \u2014 one instance, shared by everyone. Na\u00EFve injects the secrets\n // (database URL, storage credentials\u2026) into your runtime automatically.\n infrastructure: {\n cloud: {\n website: cloud.web({ framework: \"nextjs\", dir: \".\" }),\n database: cloud.postgres({ size: \"serverless\" }),\n },\n },\n\n // \u2500\u2500 kits: roles declared now, instantiated later \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // `naive up` registers each kit; nothing runs until you stamp an instance\n // for one child project from your own code:\n // await naive.forProject(\"my-project\").forChild(childId).provision(\"sdr\");\n kits: {\n sdr: kit({\n instructions: \"Research prospects and draft outreach for one customer.\",\n can: [skills.search, skills.email],\n }),\n },\n\n // \u2500\u2500 teams: N agents behind one lead \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // `naive up` materializes each team's agents and places the team.\n // `runtime.durable()` is the current lane and it is LIVE: production has\n // VETTA_CONTROL_URL and both cutover prerequisites signed off, so this team\n // places for real. Export NAIVE_DURABLE_CREDENTIAL_SUPPORT before your first\n // `naive up` \u2014 without it the team alone comes back\n // `runtime_credential_required` while the rest of the config applies. The\n // line is written out even though `team()` defaults to the same value: you\n // should be able to read which runtime you are on without knowing the default.\n // On a deployment that has no durable runtime, change it to runtime.hermes().\n teams: {\n support: team({\n runtime: runtime.durable(),\n lead: agent({\n instructions: \"You run the support team. Triage incoming work and delegate.\",\n can: [skills.search, skills.llm],\n }),\n agents: {\n triage: agent({\n instructions: \"Answer support questions. Escalate anything you cannot resolve.\",\n can: [skills.search, skills.llm],\n }),\n },\n edges: [[\"lead\", \"triage\"]],\n }),\n },\n});\n";
@@ -1,71 +0,0 @@
1
- /**
2
- * The `naive init` starter, extracted so the suite can compile it with the real
3
- * DSL instead of asserting on substrings of a template literal.
4
- *
5
- * CONTENT IS MAIN'S, NOT THIS BRANCH'S. The extraction is this branch's idea and
6
- * is kept; the template it originally carried scaffolded the RETIRED surface
7
- * (`defineConfig` + `system(...)` + `business`/`identity`). Landing that would
8
- * have made `naive init` — the first command a new user runs — emit a config
9
- * against a deprecated API, which is a worse regression than the refactor is an
10
- * improvement. The body below is the `defineProject`/`kit`/`team` starter from
11
- * main, verbatim.
12
- */
13
- export const STARTER_CONFIG = `import { defineProject, cloud, agent, kit, runtime, team, skills } from "@usenaive-sdk/iac";
14
-
15
- // Naïve gives every agent its own governed, real-world identity. Declare the
16
- // project's shared infrastructure ONCE, then your teams. Run \`naive up\` to
17
- // plan and apply. \`defineProject\` is STRICT: a field nothing consumes is a
18
- // named refusal at define time, never a green apply that enforces nothing.
19
- export default defineProject({
20
- project: "my-project",
21
-
22
- // ── infrastructure: set up ONCE for the whole project ────────────────────
23
- // Cloud — one instance, shared by everyone. Naïve injects the secrets
24
- // (database URL, storage credentials…) into your runtime automatically.
25
- infrastructure: {
26
- cloud: {
27
- website: cloud.web({ framework: "nextjs", dir: "." }),
28
- database: cloud.postgres({ size: "serverless" }),
29
- },
30
- },
31
-
32
- // ── kits: roles declared now, instantiated later ──────────────────────────
33
- // \`naive up\` registers each kit; nothing runs until you stamp an instance
34
- // for one child project from your own code:
35
- // await naive.forProject("my-project").forChild(childId).provision("sdr");
36
- kits: {
37
- sdr: kit({
38
- instructions: "Research prospects and draft outreach for one customer.",
39
- can: [skills.search, skills.email],
40
- }),
41
- },
42
-
43
- // ── teams: N agents behind one lead ──────────────────────────────────────
44
- // \`naive up\` materializes each team's agents and places the team.
45
- // \`runtime.durable()\` is the current lane and it is LIVE: production has
46
- // VETTA_CONTROL_URL and both cutover prerequisites signed off, so this team
47
- // places for real. Export NAIVE_DURABLE_CREDENTIAL_SUPPORT before your first
48
- // \`naive up\` — without it the team alone comes back
49
- // \`runtime_credential_required\` while the rest of the config applies. The
50
- // line is written out even though \`team()\` defaults to the same value: you
51
- // should be able to read which runtime you are on without knowing the default.
52
- // On a deployment that has no durable runtime, change it to runtime.hermes().
53
- teams: {
54
- support: team({
55
- runtime: runtime.durable(),
56
- lead: agent({
57
- instructions: "You run the support team. Triage incoming work and delegate.",
58
- can: [skills.search, skills.llm],
59
- }),
60
- agents: {
61
- triage: agent({
62
- instructions: "Answer support questions. Escalate anything you cannot resolve.",
63
- can: [skills.search, skills.llm],
64
- }),
65
- },
66
- edges: [["lead", "triage"]],
67
- }),
68
- },
69
- });
70
- `;
71
- //# sourceMappingURL=starter-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"starter-config.js","sourceRoot":"","sources":["../../src/lib/starter-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyD7B,CAAC"}