@usenaive-sdk/cli 0.15.0 → 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 (278) hide show
  1. package/README.md +43 -354
  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 -245
  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 -106
  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 -80
  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 -73
  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 -112
  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/pricing.d.ts +0 -132
  253. package/dist/lib/pricing.js +0 -148
  254. package/dist/lib/pricing.js.map +0 -1
  255. package/dist/lib/starter-config.d.ts +0 -13
  256. package/dist/lib/starter-config.js +0 -71
  257. package/dist/lib/starter-config.js.map +0 -1
  258. package/dist/lib/stream-frames.d.ts +0 -114
  259. package/dist/lib/stream-frames.js +0 -169
  260. package/dist/lib/stream-frames.js.map +0 -1
  261. package/dist/lib/teams-catalog.d.ts +0 -141
  262. package/dist/lib/teams-catalog.js +0 -841
  263. package/dist/lib/teams-catalog.js.map +0 -1
  264. package/dist/lib/unknown-command.d.ts +0 -71
  265. package/dist/lib/unknown-command.js +0 -132
  266. package/dist/lib/unknown-command.js.map +0 -1
  267. package/dist/lib/version-check.d.ts +0 -26
  268. package/dist/lib/version-check.js +0 -21
  269. package/dist/lib/version-check.js.map +0 -1
  270. package/dist/output.d.ts +0 -174
  271. package/dist/output.js +0 -435
  272. package/dist/output.js.map +0 -1
  273. package/dist/prompt.d.ts +0 -17
  274. package/dist/prompt.js +0 -70
  275. package/dist/prompt.js.map +0 -1
  276. package/dist/version.d.ts +0 -2
  277. package/dist/version.js +0 -14
  278. package/dist/version.js.map +0 -1
@@ -1,46 +0,0 @@
1
- import { InvalidArgumentError } from "commander";
2
- /** Same shape the API accepts for `:user_id` / `--user` (uuid or default/me aliases). */
3
- const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4
- const USER_ALIASES = new Set(["default", "me"]);
5
- export function isTenantUserRef(value) {
6
- return USER_ALIASES.has(value) || UUID_RE.test(value);
7
- }
8
- /**
9
- * Fail-closed for malformed `--user` before any HTTP call.
10
- * Mirrors API subject-resolver: non-uuid ids never match → not_found (never a DB 500 / rate-limit burn).
11
- */
12
- export function assertTenantUserRef(user) {
13
- if (user === undefined || user === "")
14
- return;
15
- if (isTenantUserRef(user))
16
- return;
17
- throw Object.assign(new Error("User not found"), {
18
- code: "not_found",
19
- hint: "The user_id does not exist in your workspace.",
20
- });
21
- }
22
- export function configureStructuredValidation(command) {
23
- command.exitOverride();
24
- command.configureOutput({ writeErr: () => { } });
25
- for (const child of command.commands)
26
- configureStructuredValidation(child);
27
- }
28
- export function parseIntegerOption(value, name, min, max = Number.MAX_SAFE_INTEGER) {
29
- const parsed = Number(value);
30
- if (!Number.isSafeInteger(parsed) || parsed < min || parsed > max) {
31
- throw new InvalidArgumentError(`${name} must be an integer between ${min} and ${max}`);
32
- }
33
- return parsed;
34
- }
35
- export function commandAction(args) {
36
- const words = args.filter((arg) => !arg.startsWith("-")).slice(0, 2);
37
- return words.length > 0 ? words.join(".") : "cli.validation";
38
- }
39
- export function cleanCommanderMessage(message) {
40
- return message.replace(/^error:\s*/i, "").trim() || "Invalid command options";
41
- }
42
- export function helpCommand(args) {
43
- const command = args.filter((arg) => !arg.startsWith("-")).slice(0, 2).join(" ");
44
- return command ? `naive ${command} --help` : "naive --help";
45
- }
46
- //# sourceMappingURL=cli-validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli-validation.js","sourceRoot":"","sources":["../../src/lib/cli-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAgB,MAAM,WAAW,CAAC;AAE/D,yFAAyF;AACzF,MAAM,OAAO,GAAG,iEAAiE,CAAC;AAClF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;AAEhD,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAwB;IAC1D,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO;IAC9C,IAAI,eAAe,CAAC,IAAI,CAAC;QAAE,OAAO;IAClC,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,EAAE;QAC/C,IAAI,EAAE,WAAoB;QAC1B,IAAI,EAAE,+CAA+C;KACtD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,OAAgB;IAC5D,OAAO,CAAC,YAAY,EAAE,CAAC;IACvB,OAAO,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;IAChD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ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AAC,SAAS,OAAO,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC;AAC9D,CAAC"}
@@ -1,4 +0,0 @@
1
- /** True when jiti evaluation failed because the config itself is invalid (not
2
- * because @usenaive-sdk/iac / jiti is missing). Those must surface as
3
- * `invalid_input`, not the soft "install iac" fallback. */
4
- export declare function isConfigAuthoringError(err: unknown): boolean;
@@ -1,13 +0,0 @@
1
- /** True when jiti evaluation failed because the config itself is invalid (not
2
- * because @usenaive-sdk/iac / jiti is missing). Those must surface as
3
- * `invalid_input`, not the soft "install iac" fallback. */
4
- export function isConfigAuthoringError(err) {
5
- if (!err || typeof err !== "object")
6
- return false;
7
- const e = err;
8
- if (e.name === "IacConfigError" || e.code === "invalid_input")
9
- return true;
10
- const msg = typeof e.message === "string" ? e.message : "";
11
- return /root must be named|missing a root agent|system\.root/i.test(msg);
12
- }
13
- //# sourceMappingURL=config-errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-errors.js","sourceRoot":"","sources":["../../src/lib/config-errors.ts"],"names":[],"mappings":"AAAA;;4DAE4D;AAC5D,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAClD,MAAM,CAAC,GAAG,GAAyD,CAAC;IACpE,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB,IAAI,CAAC,CAAC,IAAI,KAAK,eAAe;QAAE,OAAO,IAAI,CAAC;IAC3E,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,OAAO,uDAAuD,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3E,CAAC"}
@@ -1,158 +0,0 @@
1
- /**
2
- * The one deprecation experience for the CLI (06 §1.9 / §1.10.1).
3
- *
4
- * THE RULE THIS FILE EXISTS TO KEEP: a deprecated command KEEPS WORKING. Nothing
5
- * here refuses, gates, or short-circuits — `markDeprecated` installs a commander
6
- * `preAction` hook that writes a banner to STDERR and then returns, and the
7
- * action runs exactly as it did before. Existing users must not break.
8
- *
9
- * WHY A preAction HOOK AND NOT A CALL INSIDE EACH HANDLER. A hook on the GROUP
10
- * fires for every subcommand of that group, including subcommands added later by
11
- * someone who has never read this file. A per-handler call is a convention, and a
12
- * convention is a thing that is true until the next PR.
13
- *
14
- * WHY STDERR. The CLI's contract is that stdout is `JSON.parse`-able. The banner
15
- * is for a human; the machine half is `deprecation` on the stdout envelope, set
16
- * here through `setPendingDeprecation` and consumed by `agentOutput` exactly the
17
- * way `update` already is.
18
- *
19
- * ── THE THREE LOAD-BEARING DETAILS OF THE TEXT ──────────────────────────────
20
- *
21
- * 1. THE `[dep.…]` ID is printed because it is the one word an operator can grep
22
- * across every rendering of the same fact — the CLI banner, the JSON
23
- * envelope, and (when they land) the openapi extension, the MCP tool
24
- * description and the dashboard notice. Renderings drift; an id does not.
25
- *
26
- * 2. THE "also called" LINE is not decoration. The legacy orchestration runtime
27
- * has EIGHT in-tree names. A notice that names one leaves seven ways to keep
28
- * talking about the thing it is retiring.
29
- *
30
- * 3. "frozen, no sunset date" is rendered from a CLOSED two-member `Sunset`
31
- * union. There is no "removal TBD", because a date nobody can keep is how a
32
- * banner becomes furniture.
33
- *
34
- * And `Replacement` is closed for the same reason: a capability that is simply
35
- * GONE renders as `{kind:"gap", because}`. It cannot be rendered as an empty
36
- * string, and the reason is required by the type rather than by review. A notice
37
- * that invents a replacement for a capability that no longer exists is worse than
38
- * no notice at all.
39
- */
40
- import type { Command } from "commander";
41
- import { type DeprecationNotice, type NextStep } from "../output.js";
42
- /** A replacement is a real symbol or an admitted gap. Closed on purpose (R-7). */
43
- export type Replacement = {
44
- readonly kind: "use";
45
- readonly what: string;
46
- } | {
47
- readonly kind: "gap";
48
- readonly because: string;
49
- };
50
- /** Frozen, or a date. There is no third member and no "TBD". */
51
- export type Sunset = {
52
- readonly kind: "frozen";
53
- } | {
54
- readonly kind: "on";
55
- readonly date: string;
56
- };
57
- /** One subcommand of a deprecated group whose capability has no replacement. */
58
- export interface SubcommandGap {
59
- readonly sub: string;
60
- readonly because: string;
61
- }
62
- export interface DeprecationSpec {
63
- /**
64
- * THE REGISTER'S id, not a derived one.
65
- *
66
- * This used to be computed as `dep.${cmd.name()}` — `dep.tasks`, `dep.ceo` —
67
- * while `packages/api/src/routes/deprecations.ts` mints `dep.primitive.tasks`
68
- * and emits it in the `X-Naive-Deprecation-Id` response header, whose own
69
- * comment calls it "the grep handle … the SAME id the openapi operation
70
- * carries". The dashboard uses the API's spelling too. So the one thing the
71
- * machine channel exists for — correlating a CLI warning with the HTTP header
72
- * for the same retirement — matched nothing.
73
- *
74
- * Declared rather than derived because the mapping is not a function of the
75
- * command name: a future group may retire to a `dep.surface.*` row.
76
- *
77
- * TWO NAMESPACES, and the difference is real:
78
- * `dep.primitive.*` / `dep.surface.*` the REST register's own ids. These
79
- * MUST exist there — `ci/docs-deprecation-parity.mjs` asserts it — so a
80
- * CLI warning and an `X-Naive-Deprecation-Id` header correlate.
81
- * `dep.cli.*` a retirement with no REST twin, because the endpoints are
82
- * gone rather than deprecated (`naive verify`). There is no operation to
83
- * mark and no header to match, and saying so in the id is better than
84
- * pointing at a register row that cannot exist.
85
- */
86
- readonly id: string;
87
- /** One sentence: what this command drives. Rendered after the header. */
88
- readonly drives: string;
89
- /** Every other in-tree name for the thing being retired (detail 2 above). */
90
- readonly alsoCalled: readonly string[];
91
- readonly replacement: Replacement;
92
- /** Why the replacement is better. Rendered on the "Why:" line. */
93
- readonly why: string;
94
- /** `YYYY-MM` — when the deprecation was declared. */
95
- readonly since: string;
96
- readonly sunset: Sunset;
97
- readonly guide: string;
98
- /** Subcommands of this group whose capability is gone, with the reason. */
99
- readonly gaps?: readonly SubcommandGap[];
100
- }
101
- export interface DeprecationRecord extends DeprecationSpec {
102
- /** `naive tasks` — derived from the commander command, never retyped. */
103
- readonly subject: string;
104
- }
105
- /**
106
- * The eight names the legacy orchestration runtime answers to in this tree.
107
- * Exported so a staleness check can hold it against the source rather than
108
- * against memory — a list like this becomes folklore the moment nothing reads it.
109
- */
110
- export declare const LEGACY_RUNTIME_ALIASES: readonly ["orchestration", "warm pool", "instance pool", "Hermes", "sidecar", "container runtime", "hosted runtime", "runtime.pool"];
111
- /** Build the full record from the commander command plus its spec. */
112
- export declare function deprecationRecord(cmd: Command, spec: DeprecationSpec): DeprecationRecord;
113
- /** The machine half — what rides the stdout envelope. */
114
- export declare function deprecationNotice(rec: DeprecationRecord, status: "deprecated" | "retired"): DeprecationNotice;
115
- /**
116
- * The banner, as a string. Pure, so the wording is a test rather than a habit.
117
- * The first line carries the two facts an operator needs before anything else:
118
- * it is deprecated, and it KEEPS WORKING.
119
- */
120
- export declare function renderDeprecationBanner(rec: DeprecationRecord): string;
121
- export declare function _resetDeprecationBannersForTest(): void;
122
- /**
123
- * Mark a command group deprecated. The group keeps working; every invocation
124
- * writes the banner to stderr (once per process) and attaches the machine notice
125
- * to the next stdout envelope.
126
- *
127
- * Returns the record so the caller can assert on it — the registry in index.ts is
128
- * built from the return values, which is what makes the set of deprecations a
129
- * value a test can read instead of a side effect it has to observe.
130
- */
131
- export declare function markDeprecated(cmd: Command, spec: DeprecationSpec): DeprecationRecord;
132
- /**
133
- * A RETIRED command: it no longer does anything, and saying so is the whole
134
- * behaviour. Distinct from `markDeprecated`, which never refuses.
135
- *
136
- * ── WHY THE CODE IS `deprecated_command` AND WHY IT IS NOT IN THE SERVER UNION ──
137
- *
138
- * `platform/kernel/src/errors.ts` holds a 25-member `ErrorCode` union typed as
139
- * `Record<ErrorCode, number>` in `STATUS_MAP` — it is the set of codes an HTTP
140
- * RESPONSE can carry, and every member owes a status. `deprecated_command` is
141
- * minted here, by the CLI, for a command that makes no request at all: there is
142
- * no response and therefore no status to map. Adding it to that union would put
143
- * a code the server can never emit into the type that says what the server emits.
144
- *
145
- * It is instead the fourth member of the CLI-LOCAL code namespace that already
146
- * exists in this package and is already relied on by callers:
147
- * `cli_outdated` and `unknown_subcommand` (lib/unknown-command.ts:8) and
148
- * `upstream_error` (client.ts:97). All three are minted client-side and none is
149
- * in the server union. `CLI_LOCAL_ERROR_CODES` below names the set so it stays a
150
- * declared four rather than a habit.
151
- */
152
- export declare const CLI_LOCAL_ERROR_CODES: readonly ["cli_outdated", "unknown_subcommand", "upstream_error", "deprecated_command"];
153
- export declare function retiredCommand(opts: {
154
- action: string;
155
- message: string;
156
- recovery_steps: NextStep[];
157
- notice?: DeprecationNotice;
158
- }): void;
@@ -1,140 +0,0 @@
1
- import { agentError, setPendingDeprecation } from "../output.js";
2
- /**
3
- * The eight names the legacy orchestration runtime answers to in this tree.
4
- * Exported so a staleness check can hold it against the source rather than
5
- * against memory — a list like this becomes folklore the moment nothing reads it.
6
- */
7
- export const LEGACY_RUNTIME_ALIASES = [
8
- "orchestration",
9
- "warm pool",
10
- "instance pool",
11
- "Hermes",
12
- "sidecar",
13
- "container runtime",
14
- "hosted runtime",
15
- "runtime.pool",
16
- ];
17
- const MIGRATION_GUIDE = "https://usenaive.ai/docs/migration-guides/legacy-orchestration-to-durable-teams";
18
- /** Build the full record from the commander command plus its spec. */
19
- export function deprecationRecord(cmd, spec) {
20
- return { ...spec, subject: `naive ${cmd.name()}` };
21
- }
22
- /** The machine half — what rides the stdout envelope. */
23
- export function deprecationNotice(rec, status) {
24
- return {
25
- id: rec.id,
26
- subject: rec.subject,
27
- status,
28
- replacement: rec.replacement,
29
- since: rec.since,
30
- sunset: rec.sunset.kind === "frozen" ? "frozen" : { on: rec.sunset.date },
31
- guide: rec.guide,
32
- };
33
- }
34
- function sunsetLine(rec) {
35
- return rec.sunset.kind === "frozen"
36
- ? "frozen, no sunset date"
37
- : `sunset ${rec.sunset.date}`;
38
- }
39
- function replacementLines(rec) {
40
- if (rec.replacement.kind === "use") {
41
- return [` Use instead: ${rec.replacement.what}`];
42
- }
43
- // The honest row. There is no replacement, and the reason is mandatory.
44
- return [
45
- " Use instead: nothing — this capability has no replacement.",
46
- ` Because: ${rec.replacement.because}`,
47
- ];
48
- }
49
- /**
50
- * The banner, as a string. Pure, so the wording is a test rather than a habit.
51
- * The first line carries the two facts an operator needs before anything else:
52
- * it is deprecated, and it KEEPS WORKING.
53
- */
54
- export function renderDeprecationBanner(rec) {
55
- const lines = [];
56
- lines.push(`⚠ \`${rec.subject}\` is DEPRECATED and will keep working. [${rec.id}]`);
57
- lines.push(` It drives ${rec.drives}`);
58
- if (rec.alsoCalled.length > 0) {
59
- lines.push(` (also called: ${rec.alsoCalled.join(", ")})`);
60
- }
61
- lines.push(...replacementLines(rec));
62
- lines.push(` Why: ${rec.why}`);
63
- for (const gap of rec.gaps ?? []) {
64
- lines.push(` No replacement for \`${rec.subject} ${gap.sub}\`: ${gap.because}`);
65
- }
66
- lines.push(` Since ${rec.since} · ${sunsetLine(rec)} · migration guide:`);
67
- lines.push(` ${rec.guide}`);
68
- return lines.join("\n") + "\n";
69
- }
70
- /**
71
- * Emitted ids, so the banner appears ONCE per process even when a group's hook
72
- * and a future subcommand's hook both fire. Exported for tests only.
73
- */
74
- const _emitted = new Set();
75
- export function _resetDeprecationBannersForTest() {
76
- _emitted.clear();
77
- }
78
- /**
79
- * Mark a command group deprecated. The group keeps working; every invocation
80
- * writes the banner to stderr (once per process) and attaches the machine notice
81
- * to the next stdout envelope.
82
- *
83
- * Returns the record so the caller can assert on it — the registry in index.ts is
84
- * built from the return values, which is what makes the set of deprecations a
85
- * value a test can read instead of a side effect it has to observe.
86
- */
87
- export function markDeprecated(cmd, spec) {
88
- const rec = deprecationRecord(cmd, spec);
89
- cmd.hook("preAction", () => {
90
- setPendingDeprecation(deprecationNotice(rec, "deprecated"));
91
- if (!_emitted.has(rec.id)) {
92
- _emitted.add(rec.id);
93
- process.stderr.write(renderDeprecationBanner(rec));
94
- }
95
- // and then nothing. The action runs.
96
- });
97
- return rec;
98
- }
99
- /**
100
- * A RETIRED command: it no longer does anything, and saying so is the whole
101
- * behaviour. Distinct from `markDeprecated`, which never refuses.
102
- *
103
- * ── WHY THE CODE IS `deprecated_command` AND WHY IT IS NOT IN THE SERVER UNION ──
104
- *
105
- * `platform/kernel/src/errors.ts` holds a 25-member `ErrorCode` union typed as
106
- * `Record<ErrorCode, number>` in `STATUS_MAP` — it is the set of codes an HTTP
107
- * RESPONSE can carry, and every member owes a status. `deprecated_command` is
108
- * minted here, by the CLI, for a command that makes no request at all: there is
109
- * no response and therefore no status to map. Adding it to that union would put
110
- * a code the server can never emit into the type that says what the server emits.
111
- *
112
- * It is instead the fourth member of the CLI-LOCAL code namespace that already
113
- * exists in this package and is already relied on by callers:
114
- * `cli_outdated` and `unknown_subcommand` (lib/unknown-command.ts:8) and
115
- * `upstream_error` (client.ts:97). All three are minted client-side and none is
116
- * in the server union. `CLI_LOCAL_ERROR_CODES` below names the set so it stays a
117
- * declared four rather than a habit.
118
- */
119
- export const CLI_LOCAL_ERROR_CODES = [
120
- "cli_outdated",
121
- "unknown_subcommand",
122
- "upstream_error",
123
- "deprecated_command",
124
- ];
125
- export function retiredCommand(opts) {
126
- if (opts.notice)
127
- setPendingDeprecation(opts.notice);
128
- // A retired command's notice cannot ride a success envelope — there isn't one —
129
- // so in machine mode the id travels on the error object instead.
130
- agentError({
131
- action: opts.action,
132
- error: {
133
- code: "deprecated_command",
134
- message: opts.message,
135
- ...(opts.notice && { deprecation: opts.notice }),
136
- },
137
- recovery_steps: opts.recovery_steps,
138
- });
139
- }
140
- //# sourceMappingURL=deprecation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecation.js","sourceRoot":"","sources":["../../src/lib/deprecation.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAyC,MAAM,cAAc,CAAC;AA6DxG;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,eAAe;IACf,WAAW;IACX,eAAe;IACf,QAAQ;IACR,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AY,EAAE,IAAqB;IAChE,MAAM,GAAG,GAAG,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,qBAAqB,CAAC,iBAAiB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAC1B,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,qCAAqC;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,cAAc;IACd,oBAAoB;IACpB,gBAAgB;IAChB,oBAAoB;CACZ,CAAC;AAEX,MAAM,UAAU,cAAc,CAAC,IAK9B;IACC,IAAI,IAAI,CAAC,MAAM;QAAE,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,gFAAgF;IAChF,iEAAiE;IACjE,UAAU,CAAC;QACT,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE;YACL,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;SACjD;QACD,cAAc,EAAE,IAAI,CAAC,cAAc;KACpC,CAAC,CAAC;AACL,CAAC"}
@@ -1,8 +0,0 @@
1
- export type DurationParse = {
2
- ok: true;
3
- value: number;
4
- } | {
5
- ok: false;
6
- message: string;
7
- };
8
- export declare function parseDurationArg(raw: string): DurationParse;
@@ -1,11 +0,0 @@
1
- export function parseDurationArg(raw) {
2
- const n = Number(raw);
3
- if (raw.trim() === "" || !Number.isFinite(n) || n <= 0) {
4
- return {
5
- ok: false,
6
- message: `--duration must be a positive number of seconds (e.g. 5 or 10); got "${raw}"`,
7
- };
8
- }
9
- return { ok: true, value: n };
10
- }
11
- //# sourceMappingURL=duration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/lib/duration.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,OAAO;YACL,EAAE,EAAE,KAAK;YACT,OAAO,EAAE,wEAAwE,GAAG,GAAG;SACxF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAChC,CAAC"}
@@ -1,11 +0,0 @@
1
- export interface ParsedHttpResponse {
2
- status: number;
3
- data: unknown;
4
- }
5
- /**
6
- * Parse an API response without assuming every proxy/error page is JSON.
7
- * Empty successful responses remain valid; every other non-JSON response is
8
- * converted to the same structured error shape the CLI already understands.
9
- */
10
- export declare function parseHttpResponse(response: Response): Promise<ParsedHttpResponse>;
11
- export declare function networkErrorResponse(error: unknown): ParsedHttpResponse;
@@ -1,96 +0,0 @@
1
- const MAX_RESPONSE_PREVIEW = 240;
2
- function redactSecrets(value) {
3
- return value
4
- .replace(/\b((?:nv|dr)_sk_)[A-Za-z0-9._-]+/gi, "$1[redacted]")
5
- .replace(/\b(Bearer\s+)[A-Za-z0-9._~-]+/gi, "$1[redacted]");
6
- }
7
- function safePreview(value) {
8
- const preview = redactSecrets(value)
9
- .replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, " ")
10
- .replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, " ")
11
- .replace(/<[^>]+>/g, " ")
12
- .replace(/[\u0000-\u001f\u007f]+/g, " ")
13
- .replace(/\s+/g, " ")
14
- .trim()
15
- .slice(0, MAX_RESPONSE_PREVIEW);
16
- return preview || undefined;
17
- }
18
- function codeForStatus(status) {
19
- if (status === 401)
20
- return "unauthorized";
21
- if (status === 403)
22
- return "forbidden";
23
- if (status === 404)
24
- return "resource_not_found";
25
- if (status === 429)
26
- return "rate_limited";
27
- if (status >= 500)
28
- return "internal_error";
29
- return "invalid_input";
30
- }
31
- /**
32
- * Parse an API response without assuming every proxy/error page is JSON.
33
- * Empty successful responses remain valid; every other non-JSON response is
34
- * converted to the same structured error shape the CLI already understands.
35
- */
36
- export async function parseHttpResponse(response) {
37
- const contentType = response.headers.get("content-type")?.split(";", 1)[0]?.trim() || undefined;
38
- const text = await response.text();
39
- const jsonText = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
40
- if (!text.trim()) {
41
- if (response.ok || response.status === 204)
42
- return { status: response.status, data: {} };
43
- return {
44
- status: response.status,
45
- data: {
46
- error: {
47
- code: codeForStatus(response.status),
48
- message: `Naive API returned an empty error response (HTTP ${response.status}).`,
49
- hint: "Retry once; if this persists, the API route or upstream proxy may be unavailable.",
50
- upstream_status: response.status,
51
- ...(contentType && { content_type: contentType }),
52
- },
53
- },
54
- };
55
- }
56
- const looksJson = /(?:^|[+/])json$/i.test(contentType ?? "") || /^[\[{]/.test(jsonText.trim());
57
- if (looksJson) {
58
- try {
59
- return { status: response.status, data: JSON.parse(jsonText) };
60
- }
61
- catch {
62
- // Fall through to the structured invalid-response envelope below.
63
- }
64
- }
65
- const normalizedStatus = response.ok ? 502 : response.status;
66
- const preview = safePreview(text);
67
- return {
68
- status: normalizedStatus,
69
- data: {
70
- error: {
71
- code: codeForStatus(normalizedStatus),
72
- message: `Naive API returned ${contentType ?? "a non-JSON response"} instead of JSON (HTTP ${response.status}).`,
73
- hint: response.status === 404
74
- ? "The requested API route may not be deployed yet. Check the target environment and retry."
75
- : "Retry once; if this persists, check API or upstream-provider health.",
76
- upstream_status: response.status,
77
- ...(contentType && { content_type: contentType }),
78
- ...(preview && { response_preview: preview }),
79
- },
80
- },
81
- };
82
- }
83
- export function networkErrorResponse(error) {
84
- return {
85
- status: 503,
86
- data: {
87
- error: {
88
- code: "network_error",
89
- message: "Could not reach the Naive API.",
90
- hint: "Check your connection and NAIVE_BASE_URL, then retry.",
91
- cause: error instanceof Error ? error.message : String(error),
92
- },
93
- },
94
- };
95
- }
96
- //# sourceMappingURL=http-response.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-response.js","sourceRoot":"","sources":["../../src/lib/http-response.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK;SACT,OAAO,CAAC,oCAAoC,EAAE,cAAc,CAAC;SAC7D,OAAO,CAAC,iCAAiC,EAAE,cAAc,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC;SACjC,OAAO,CAAC,qCAAqC,EAAE,GAAG,CAAC;SACnD,OAAO,CAAC,mCAAmC,EAAE,GAAG,CAAC;SACjD,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC;SACvC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE;SACN,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAClC,OAAO,OAAO,IAAI,SAAS,CAAC;AAC9B,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC;IAC1C,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,WAAW,C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AAI,EAAE,uDAAuD;gBAC7D,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D;SACF;KACF,CAAC;AACJ,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;