@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.
- package/README.md +43 -402
- package/dist/index.js +51796 -502
- package/package.json +22 -18
- package/dist/client.d.ts +0 -108
- package/dist/client.js +0 -458
- package/dist/client.js.map +0 -1
- package/dist/commands/account-kits.d.ts +0 -2
- package/dist/commands/account-kits.js +0 -71
- package/dist/commands/account-kits.js.map +0 -1
- package/dist/commands/aeo.d.ts +0 -2
- package/dist/commands/aeo.js +0 -451
- package/dist/commands/aeo.js.map +0 -1
- package/dist/commands/agent-profiles.d.ts +0 -11
- package/dist/commands/agent-profiles.js +0 -120
- package/dist/commands/agent-profiles.js.map +0 -1
- package/dist/commands/agents.d.ts +0 -2
- package/dist/commands/agents.js +0 -916
- package/dist/commands/agents.js.map +0 -1
- package/dist/commands/app-data.d.ts +0 -2
- package/dist/commands/app-data.js +0 -445
- package/dist/commands/app-data.js.map +0 -1
- package/dist/commands/approvals.d.ts +0 -2
- package/dist/commands/approvals.js +0 -242
- package/dist/commands/approvals.js.map +0 -1
- package/dist/commands/apps.d.ts +0 -9
- package/dist/commands/apps.js +0 -844
- package/dist/commands/apps.js.map +0 -1
- package/dist/commands/audio.d.ts +0 -9
- package/dist/commands/audio.js +0 -391
- package/dist/commands/audio.js.map +0 -1
- package/dist/commands/auth.d.ts +0 -31
- package/dist/commands/auth.js +0 -428
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/billing.d.ts +0 -2
- package/dist/commands/billing.js +0 -250
- package/dist/commands/billing.js.map +0 -1
- package/dist/commands/brain.d.ts +0 -2
- package/dist/commands/brain.js +0 -1300
- package/dist/commands/brain.js.map +0 -1
- package/dist/commands/browser.d.ts +0 -2
- package/dist/commands/browser.js +0 -378
- package/dist/commands/browser.js.map +0 -1
- package/dist/commands/business.d.ts +0 -2
- package/dist/commands/business.js +0 -566
- package/dist/commands/business.js.map +0 -1
- package/dist/commands/cards.d.ts +0 -2
- package/dist/commands/cards.js +0 -419
- package/dist/commands/cards.js.map +0 -1
- package/dist/commands/ceo.d.ts +0 -2
- package/dist/commands/ceo.js +0 -369
- package/dist/commands/ceo.js.map +0 -1
- package/dist/commands/clone.d.ts +0 -2
- package/dist/commands/clone.js +0 -203
- package/dist/commands/clone.js.map +0 -1
- package/dist/commands/companies.d.ts +0 -10
- package/dist/commands/companies.js +0 -283
- package/dist/commands/companies.js.map +0 -1
- package/dist/commands/company-data.d.ts +0 -2
- package/dist/commands/company-data.js +0 -168
- package/dist/commands/company-data.js.map +0 -1
- package/dist/commands/compute.d.ts +0 -2
- package/dist/commands/compute.js +0 -498
- package/dist/commands/compute.js.map +0 -1
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/config.js +0 -36
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/connections.d.ts +0 -8
- package/dist/commands/connections.js +0 -137
- package/dist/commands/connections.js.map +0 -1
- package/dist/commands/cron-jobs.d.ts +0 -2
- package/dist/commands/cron-jobs.js +0 -245
- package/dist/commands/cron-jobs.js.map +0 -1
- package/dist/commands/domains.d.ts +0 -2
- package/dist/commands/domains.js +0 -474
- package/dist/commands/domains.js.map +0 -1
- package/dist/commands/ecommerce.d.ts +0 -2
- package/dist/commands/ecommerce.js +0 -277
- package/dist/commands/ecommerce.js.map +0 -1
- package/dist/commands/email.d.ts +0 -2
- package/dist/commands/email.js +0 -336
- package/dist/commands/email.js.map +0 -1
- package/dist/commands/employees.d.ts +0 -2
- package/dist/commands/employees.js +0 -190
- package/dist/commands/employees.js.map +0 -1
- package/dist/commands/env.d.ts +0 -7
- package/dist/commands/env.js +0 -112
- package/dist/commands/env.js.map +0 -1
- package/dist/commands/formation.d.ts +0 -2
- package/dist/commands/formation.js +0 -273
- package/dist/commands/formation.js.map +0 -1
- package/dist/commands/identity.d.ts +0 -2
- package/dist/commands/identity.js +0 -110
- package/dist/commands/identity.js.map +0 -1
- package/dist/commands/images.d.ts +0 -2
- package/dist/commands/images.js +0 -371
- package/dist/commands/images.js.map +0 -1
- package/dist/commands/init.d.ts +0 -5
- package/dist/commands/init.js +0 -43
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/jobs.d.ts +0 -2
- package/dist/commands/jobs.js +0 -144
- package/dist/commands/jobs.js.map +0 -1
- package/dist/commands/keys.d.ts +0 -2
- package/dist/commands/keys.js +0 -156
- package/dist/commands/keys.js.map +0 -1
- package/dist/commands/legacy-auth.d.ts +0 -27
- package/dist/commands/legacy-auth.js +0 -64
- package/dist/commands/legacy-auth.js.map +0 -1
- package/dist/commands/llm.d.ts +0 -2
- package/dist/commands/llm.js +0 -125
- package/dist/commands/llm.js.map +0 -1
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.js +0 -65
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -7
- package/dist/commands/logout.js +0 -55
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/logs.js +0 -42
- package/dist/commands/logs.js.map +0 -1
- package/dist/commands/loops.d.ts +0 -2
- package/dist/commands/loops.js +0 -260
- package/dist/commands/loops.js.map +0 -1
- package/dist/commands/media.d.ts +0 -2
- package/dist/commands/media.js +0 -183
- package/dist/commands/media.js.map +0 -1
- package/dist/commands/memory.d.ts +0 -2
- package/dist/commands/memory.js +0 -151
- package/dist/commands/memory.js.map +0 -1
- package/dist/commands/mobile.d.ts +0 -4
- package/dist/commands/mobile.js +0 -382
- package/dist/commands/mobile.js.map +0 -1
- package/dist/commands/module.d.ts +0 -8
- package/dist/commands/module.js +0 -48
- package/dist/commands/module.js.map +0 -1
- package/dist/commands/objectives.d.ts +0 -2
- package/dist/commands/objectives.js +0 -243
- package/dist/commands/objectives.js.map +0 -1
- package/dist/commands/payments.d.ts +0 -2
- package/dist/commands/payments.js +0 -131
- package/dist/commands/payments.js.map +0 -1
- package/dist/commands/people.d.ts +0 -2
- package/dist/commands/people.js +0 -197
- package/dist/commands/people.js.map +0 -1
- package/dist/commands/phone.d.ts +0 -2
- package/dist/commands/phone.js +0 -289
- package/dist/commands/phone.js.map +0 -1
- package/dist/commands/projects.d.ts +0 -13
- package/dist/commands/projects.js +0 -220
- package/dist/commands/projects.js.map +0 -1
- package/dist/commands/queue.d.ts +0 -2
- package/dist/commands/queue.js +0 -121
- package/dist/commands/queue.js.map +0 -1
- package/dist/commands/register.d.ts +0 -2
- package/dist/commands/register.js +0 -88
- package/dist/commands/register.js.map +0 -1
- package/dist/commands/report.d.ts +0 -17
- package/dist/commands/report.js +0 -109
- package/dist/commands/report.js.map +0 -1
- package/dist/commands/sandbox.d.ts +0 -2
- package/dist/commands/sandbox.js +0 -558
- package/dist/commands/sandbox.js.map +0 -1
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -223
- package/dist/commands/search.js.map +0 -1
- package/dist/commands/seo.d.ts +0 -2
- package/dist/commands/seo.js +0 -528
- package/dist/commands/seo.js.map +0 -1
- package/dist/commands/sessions.d.ts +0 -6
- package/dist/commands/sessions.js +0 -109
- package/dist/commands/sessions.js.map +0 -1
- package/dist/commands/social-data.d.ts +0 -2
- package/dist/commands/social-data.js +0 -245
- package/dist/commands/social-data.js.map +0 -1
- package/dist/commands/social.d.ts +0 -2
- package/dist/commands/social.js +0 -407
- package/dist/commands/social.js.map +0 -1
- package/dist/commands/status.d.ts +0 -2
- package/dist/commands/status.js +0 -79
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/support.d.ts +0 -2
- package/dist/commands/support.js +0 -134
- package/dist/commands/support.js.map +0 -1
- package/dist/commands/tasks.d.ts +0 -2
- package/dist/commands/tasks.js +0 -409
- package/dist/commands/tasks.js.map +0 -1
- package/dist/commands/teams.d.ts +0 -69
- package/dist/commands/teams.js +0 -503
- package/dist/commands/teams.js.map +0 -1
- package/dist/commands/trading.d.ts +0 -2
- package/dist/commands/trading.js +0 -333
- package/dist/commands/trading.js.map +0 -1
- package/dist/commands/up.d.ts +0 -551
- package/dist/commands/up.js +0 -1149
- package/dist/commands/up.js.map +0 -1
- package/dist/commands/usage.d.ts +0 -2
- package/dist/commands/usage.js +0 -73
- package/dist/commands/usage.js.map +0 -1
- package/dist/commands/use.d.ts +0 -12
- package/dist/commands/use.js +0 -96
- package/dist/commands/use.js.map +0 -1
- package/dist/commands/users.d.ts +0 -10
- package/dist/commands/users.js +0 -82
- package/dist/commands/users.js.map +0 -1
- package/dist/commands/vault.d.ts +0 -2
- package/dist/commands/vault.js +0 -101
- package/dist/commands/vault.js.map +0 -1
- package/dist/commands/verification.d.ts +0 -2
- package/dist/commands/verification.js +0 -152
- package/dist/commands/verification.js.map +0 -1
- package/dist/commands/verify-email.d.ts +0 -19
- package/dist/commands/verify-email.js +0 -130
- package/dist/commands/verify-email.js.map +0 -1
- package/dist/commands/video.d.ts +0 -2
- package/dist/commands/video.js +0 -417
- package/dist/commands/video.js.map +0 -1
- package/dist/commands/voice.d.ts +0 -2
- package/dist/commands/voice.js +0 -516
- package/dist/commands/voice.js.map +0 -1
- package/dist/commands/wallet.d.ts +0 -2
- package/dist/commands/wallet.js +0 -244
- package/dist/commands/wallet.js.map +0 -1
- package/dist/commands/webhooks.d.ts +0 -13
- package/dist/commands/webhooks.js +0 -119
- package/dist/commands/webhooks.js.map +0 -1
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/commands/whoami.js +0 -53
- package/dist/commands/whoami.js.map +0 -1
- package/dist/config.d.ts +0 -42
- package/dist/config.js +0 -83
- package/dist/config.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js.map +0 -1
- package/dist/lib/brain-select.d.ts +0 -193
- package/dist/lib/brain-select.js +0 -403
- package/dist/lib/brain-select.js.map +0 -1
- package/dist/lib/cli-validation.d.ts +0 -12
- package/dist/lib/cli-validation.js +0 -46
- package/dist/lib/cli-validation.js.map +0 -1
- package/dist/lib/config-errors.d.ts +0 -4
- package/dist/lib/config-errors.js +0 -13
- package/dist/lib/config-errors.js.map +0 -1
- package/dist/lib/deprecation.d.ts +0 -158
- package/dist/lib/deprecation.js +0 -140
- package/dist/lib/deprecation.js.map +0 -1
- package/dist/lib/duration.d.ts +0 -8
- package/dist/lib/duration.js +0 -11
- package/dist/lib/duration.js.map +0 -1
- package/dist/lib/http-response.d.ts +0 -11
- package/dist/lib/http-response.js +0 -96
- package/dist/lib/http-response.js.map +0 -1
- package/dist/lib/llm-paywall.d.ts +0 -82
- package/dist/lib/llm-paywall.js +0 -231
- package/dist/lib/llm-paywall.js.map +0 -1
- package/dist/lib/pricing.d.ts +0 -132
- package/dist/lib/pricing.js +0 -148
- package/dist/lib/pricing.js.map +0 -1
- package/dist/lib/starter-config.d.ts +0 -13
- package/dist/lib/starter-config.js +0 -71
- package/dist/lib/starter-config.js.map +0 -1
- package/dist/lib/stream-frames.d.ts +0 -114
- package/dist/lib/stream-frames.js +0 -169
- package/dist/lib/stream-frames.js.map +0 -1
- package/dist/lib/teams-catalog.d.ts +0 -141
- package/dist/lib/teams-catalog.js +0 -841
- package/dist/lib/teams-catalog.js.map +0 -1
- package/dist/lib/unknown-command.d.ts +0 -71
- package/dist/lib/unknown-command.js +0 -132
- package/dist/lib/unknown-command.js.map +0 -1
- package/dist/lib/version-check.d.ts +0 -26
- package/dist/lib/version-check.js +0 -21
- package/dist/lib/version-check.js.map +0 -1
- package/dist/output.d.ts +0 -246
- package/dist/output.js +0 -539
- package/dist/output.js.map +0 -1
- package/dist/prompt.d.ts +0 -17
- package/dist/prompt.js +0 -70
- package/dist/prompt.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -14
- 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;QAAE,6BAA6B,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,KAAa,EACb,IAAY,EACZ,GAAW,EACX,GAAG,GAAG,MAAM,CAAC,gBAAgB;IAE7B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;QAClE,MAAM,IAAI,oBAAoB,CAAC,GAAG,IAAI,+BAA+B,GAAG,QAAQ,GAAG,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAuB;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,yBAAyB,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAuB;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjF,OAAO,OAAO,CAAC,CAAC,CAAC,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;
|
package/dist/lib/deprecation.js
DELETED
|
@@ -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;;;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js
DELETED
|
@@ -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
|
package/dist/lib/duration.js.map
DELETED
|
@@ -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,CAAC;IACvC,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,oBAAoB,CAAC;IAChD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC;IAC1C,IAAI,MAAM,IAAI,GAA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ACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { type DecisionOption, type NextStep } from "../output.js";
|
|
2
|
-
/**
|
|
3
|
-
* The wire token for this refusal. It is BOTH `error.code` and
|
|
4
|
-
* `error.details.block_reason` — the API emits the same string in both places
|
|
5
|
-
* on purpose (platform/billing/src/llm-access.ts), so a consumer that switches
|
|
6
|
-
* on the reason needs no mapping from the code.
|
|
7
|
-
*
|
|
8
|
-
* Matching on either and never on the MESSAGE: prose is the thing most likely
|
|
9
|
-
* to be reworded, and a CLI that string-matches it goes silently generic the
|
|
10
|
-
* first time someone improves the sentence.
|
|
11
|
-
*
|
|
12
|
-
* The code is dedicated rather than a `billing_blocked` variant, and that
|
|
13
|
-
* distinction is the whole point: `billing_blocked` and `insufficient_credits`
|
|
14
|
-
* both mean "get more credit", which here is the one action that provably
|
|
15
|
-
* cannot work. Sharing a code would have made the two indistinguishable to
|
|
16
|
-
* exactly the population that has to distinguish them.
|
|
17
|
-
*/
|
|
18
|
-
export declare const LLM_ROUTING_ERROR_CODE = "llm_routing_requires_payment";
|
|
19
|
-
/** Alias kept because the same string is also the `details.block_reason` value. */
|
|
20
|
-
export declare const LLM_ROUTING_BLOCK_REASON = "llm_routing_requires_payment";
|
|
21
|
-
export interface LlmRoutingRefusal {
|
|
22
|
-
/** The server's canonical code, echoed rather than replaced. */
|
|
23
|
-
code?: string;
|
|
24
|
-
/** The server's own sentence, when it sent one. */
|
|
25
|
-
message?: string;
|
|
26
|
-
hint?: string;
|
|
27
|
-
docs?: string;
|
|
28
|
-
/**
|
|
29
|
-
* The balance the API saw, in credits. Present so the CLI can say the quiet
|
|
30
|
-
* part out loud — "you have credit, and it is the wrong kind" — which is the
|
|
31
|
-
* single most confusing thing about this refusal.
|
|
32
|
-
*/
|
|
33
|
-
balance?: number;
|
|
34
|
-
/** The API's own "the balance is not the problem" sentence, when it sent one. */
|
|
35
|
-
balance_note?: string;
|
|
36
|
-
/** `"trial"` — why the credit on the account does not qualify. */
|
|
37
|
-
credit_kind?: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Is this response the router's paid-account refusal? Returns the parts worth
|
|
41
|
-
* rendering, or null for every other body.
|
|
42
|
-
*
|
|
43
|
-
* `code` OR `block_reason` satisfies it, and `block_reason` is read from BOTH
|
|
44
|
-
* positions, because `NaiveError.toJSON()` emits `details` nested AND spread
|
|
45
|
-
* (platform/kernel/src/errors.ts) — a reader that picks one position is betting
|
|
46
|
-
* on which half gets retired first, and a reader that requires both is broken
|
|
47
|
-
* by whichever goes.
|
|
48
|
-
*/
|
|
49
|
-
export declare function llmRoutingRefusal(data: unknown): LlmRoutingRefusal | null;
|
|
50
|
-
/**
|
|
51
|
-
* The fallback sentence, used when the server sent no message of its own.
|
|
52
|
-
*
|
|
53
|
-
* It names what trial credit DOES buy. A refusal that only says "no" reads as a
|
|
54
|
-
* paywall on the product; this one is a control on one primitive, and a new
|
|
55
|
-
* account that has just been handed 20 credits deserves to hear that the other
|
|
56
|
-
* twenty-odd primitives still take them.
|
|
57
|
-
*/
|
|
58
|
-
export declare const LLM_PAYWALL_MESSAGE: string;
|
|
59
|
-
export declare const LLM_PAYWALL_QUESTION = "The LLM router needs paid credit on this account. Add a subscription, buy credits, or stop here?";
|
|
60
|
-
/** The ways out, in the order a first-time caller should weigh them. */
|
|
61
|
-
export declare function llmPaywallOptions(): DecisionOption[];
|
|
62
|
-
/**
|
|
63
|
-
* The `recovery_steps` array. It stays a LIST OF READS, not of purchases: the
|
|
64
|
-
* purchases live in `decision_required.options`, where the envelope is explicit
|
|
65
|
-
* that a human has to choose one. Putting `topup` in both places would let an
|
|
66
|
-
* agent that only reads `recovery_steps` — the habit every other error on this
|
|
67
|
-
* surface teaches — treat "buy something" as a step it is cleared to take.
|
|
68
|
-
*/
|
|
69
|
-
export declare function llmPaywallRecoverySteps(): NextStep[];
|
|
70
|
-
/**
|
|
71
|
-
* Intercept the router's paid-account refusal. Returns true when it handled the
|
|
72
|
-
* response, in which case the caller MUST return without calling
|
|
73
|
-
* `handleApiError` — that would emit a second envelope and exit 1 over the top
|
|
74
|
-
* of this one.
|
|
75
|
-
*
|
|
76
|
-
* Returns false for every other response, including a healthy one, so a call
|
|
77
|
-
* site reads as one line ahead of its normal error handling.
|
|
78
|
-
*/
|
|
79
|
-
export declare function handleLlmRoutingRefusal(action: string, resp: {
|
|
80
|
-
status: number;
|
|
81
|
-
data: unknown;
|
|
82
|
-
}): Promise<boolean>;
|