@usenaive-sdk/cli 0.15.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -402
- package/dist/index.js +51775 -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
package/package.json
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usenaive-sdk/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "Naïve CLI — provision and govern a real-world agent profile per agent (identity, card, comms, runtime). Formerly @usenaive/cli.",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Naive Managed Agents command line — create agents, run sessions, watch events, see cost.",
|
|
6
5
|
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"
|
|
8
|
+
"vetta": "./dist/index.js",
|
|
9
|
+
"naive": "./dist/index.js"
|
|
9
10
|
},
|
|
11
|
+
"//exports": "Deliberately absent. This is a bin-only package: `files` ships `dist` alone, so the old `\"exports\": { \".\": \"./src/cli.ts\" }` named a path the tarball does not contain and every `import \"@usenaive-sdk/cli\"` would have thrown. Nothing in the workspace imported it by name.",
|
|
10
12
|
"files": [
|
|
11
|
-
"dist"
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
12
15
|
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20"
|
|
18
|
+
},
|
|
13
19
|
"publishConfig": {
|
|
14
20
|
"access": "public"
|
|
15
21
|
},
|
|
16
22
|
"dependencies": {
|
|
17
|
-
"
|
|
18
|
-
"commander": "^13.1.0",
|
|
19
|
-
"jiti": "^2.4.2",
|
|
20
|
-
"semver": "^7.6.3",
|
|
21
|
-
"update-notifier": "^7.3.1"
|
|
23
|
+
"jiti": "^2.7.0"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
|
-
"@types/node": "
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"@types/node": "22.20.1",
|
|
27
|
+
"esbuild": "0.28.2",
|
|
28
|
+
"yaml": "^2.9.0",
|
|
29
|
+
"@vetta/core": "0.0.0",
|
|
30
|
+
"@usenaive-sdk/managed-agents": "0.12.0",
|
|
31
|
+
"@usenaive-sdk/blueprints": "0.18.0"
|
|
29
32
|
},
|
|
30
33
|
"scripts": {
|
|
31
|
-
"
|
|
32
|
-
"build": "tsc",
|
|
34
|
+
"build": "node build.mjs",
|
|
33
35
|
"typecheck": "tsc --noEmit",
|
|
34
|
-
"test": "vitest run"
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:local": "vitest run",
|
|
38
|
+
"test:staging": "vitest run test/staging.e2e.ts"
|
|
35
39
|
}
|
|
36
40
|
}
|
package/dist/client.d.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/** True when `data` is our synthetic non-JSON marker (so handleApiError fires even
|
|
2
|
-
* on the rare non-JSON body carrying a 2xx status). */
|
|
3
|
-
export declare function isUpstreamError(data: unknown): boolean;
|
|
4
|
-
/**
|
|
5
|
-
* Read a fetch Response body as JSON without ever throwing. Real API bodies are
|
|
6
|
-
* always JSON (the fast path). A non-JSON body (HTML gateway page, proxy text,
|
|
7
|
-
* empty body) is turned into a synthetic `{ error: { code: "upstream_error", … } }`
|
|
8
|
-
* envelope — the same shape formatApiError already understands — carrying the HTTP
|
|
9
|
-
* status and a bounded snippet, so the caller emits a clean error instead of crashing.
|
|
10
|
-
*/
|
|
11
|
-
export declare function parseJsonOrUpstreamError(resp: Response): Promise<unknown>;
|
|
12
|
-
export declare function setActiveUserOverride(userId?: string): void;
|
|
13
|
-
/**
|
|
14
|
-
* Resolve the active subject user id (override > env > config).
|
|
15
|
-
*
|
|
16
|
-
* NAIVE_ACTIVE_USER_ID is how a containerized agent gets a subject: its Hermes
|
|
17
|
-
* profile's .env carries its own sealed key plus its tenant_user id, so the CLI
|
|
18
|
-
* it runs scopes calls to /v1/users/<that id>/... and the agent's AccountKit
|
|
19
|
-
* (its declared `can:` / `limits:`) is actually enforced. There is no
|
|
20
|
-
* ~/.naive/config.json in a profile's home to hold `active_user_id`.
|
|
21
|
-
*/
|
|
22
|
-
export declare function activeUserId(): string | undefined;
|
|
23
|
-
export declare function setActiveProjectOverride(projectId?: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* The `--project` flag as parsed off the ROOT program, if it was given.
|
|
26
|
-
*
|
|
27
|
-
* `naive use <child> --project <id>` writes the flag after the subcommand, but
|
|
28
|
-
* commander binds it to the root program's identically-named option, leaving the
|
|
29
|
-
* subcommand's own `opts.project` undefined. `use` reads it back through here.
|
|
30
|
-
*/
|
|
31
|
-
export declare function activeProjectOverride(): string | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Resolve the active project id (override > env > config).
|
|
34
|
-
*
|
|
35
|
-
* Undefined is a MEANINGFUL answer, not a missing one: the server resolves the
|
|
36
|
-
* organization's default project, which is where `naive` acted before projects
|
|
37
|
-
* existed and where migration 059 backfilled every row. So the header is sent
|
|
38
|
-
* only when a project was actually chosen, and a CLI that never mentions one
|
|
39
|
-
* keeps producing byte-identical requests.
|
|
40
|
-
*/
|
|
41
|
-
export declare function activeProjectId(): string | undefined;
|
|
42
|
-
export declare function scopePathToUser(path: string, subject: string | undefined): string;
|
|
43
|
-
export declare function apiRequest(method: string, rawPath: string, body?: Record<string, unknown>, opts?: {
|
|
44
|
-
noAuth?: boolean;
|
|
45
|
-
userId?: string;
|
|
46
|
-
headers?: Record<string, string>;
|
|
47
|
-
}): Promise<{
|
|
48
|
-
status: number;
|
|
49
|
-
data: unknown;
|
|
50
|
-
}>;
|
|
51
|
-
/**
|
|
52
|
-
* Like {@link apiRequest} but for endpoints that return a BINARY body (e.g.
|
|
53
|
-
* synthesized speech). Sends the same JSON request and auth/subject handling,
|
|
54
|
-
* and on success returns the raw bytes plus the response headers, so callers
|
|
55
|
-
* can read ids like `x-audio-request-id` off the response.
|
|
56
|
-
*
|
|
57
|
-
* An error response is still JSON, so it is parsed into the usual `{ status,
|
|
58
|
-
* data }` shape — `handleApiError` works unchanged.
|
|
59
|
-
*/
|
|
60
|
-
export declare function apiRequestBinary(method: string, rawPath: string, body?: Record<string, unknown>, opts?: {
|
|
61
|
-
userId?: string;
|
|
62
|
-
headers?: Record<string, string>;
|
|
63
|
-
}): Promise<{
|
|
64
|
-
status: number;
|
|
65
|
-
data: unknown;
|
|
66
|
-
headers?: Record<string, string>;
|
|
67
|
-
}>;
|
|
68
|
-
/**
|
|
69
|
-
* Upload a raw gzipped payload (e.g. a project tarball for direct app deploys).
|
|
70
|
-
* Same auth + subject handling as apiRequest, but with a binary body.
|
|
71
|
-
*/
|
|
72
|
-
export declare function apiUploadGzip(rawPath: string, payload: Buffer, opts?: {
|
|
73
|
-
userId?: string;
|
|
74
|
-
}): Promise<{
|
|
75
|
-
status: number;
|
|
76
|
-
data: unknown;
|
|
77
|
-
}>;
|
|
78
|
-
export declare function handleApiError(action: string, resp: {
|
|
79
|
-
status: number;
|
|
80
|
-
data: unknown;
|
|
81
|
-
}): void;
|
|
82
|
-
/** Exchange email+password for a session token, captured from Set-Cookie (the token is
|
|
83
|
-
* not in the response body). Returns the token + the login payload. Exits on API error. */
|
|
84
|
-
export declare function sessionLogin(email: string, password: string): Promise<{
|
|
85
|
-
token: string;
|
|
86
|
-
data: Record<string, unknown>;
|
|
87
|
-
}>;
|
|
88
|
-
/** HTTP for human-only routes. Sends the session cookie, NEVER the agent api_key.
|
|
89
|
-
* Supports JSON and multipart (native FormData) bodies, with an upload timeout. */
|
|
90
|
-
export declare function sessionRequest(method: string, path: string, opts?: {
|
|
91
|
-
body?: Record<string, unknown>;
|
|
92
|
-
multipart?: FormData;
|
|
93
|
-
headers?: Record<string, string>;
|
|
94
|
-
timeoutMs?: number;
|
|
95
|
-
}): Promise<{
|
|
96
|
-
status: number;
|
|
97
|
-
data: unknown;
|
|
98
|
-
}>;
|
|
99
|
-
/**
|
|
100
|
-
* Governance: a sensitive action may be deferred for human approval (HTTP 202
|
|
101
|
-
* with `status: "pending_approval"`). When that happens, emit a structured
|
|
102
|
-
* pending result (NOT an error — it's a successful deferral) and return true so
|
|
103
|
-
* the caller can stop. Returns false for a normal response.
|
|
104
|
-
*/
|
|
105
|
-
export declare function handlePendingApproval(action: string, resp: {
|
|
106
|
-
status: number;
|
|
107
|
-
data: unknown;
|
|
108
|
-
}): boolean;
|
package/dist/client.js
DELETED
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import { loadConfig, getApiKey, getSessionToken } from "./config.js";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { formatApiError, agentOutput, agentError, setPendingUpdate } from "./output.js";
|
|
4
|
-
import { readVersion } from "./version.js";
|
|
5
|
-
import { evaluateCliVersion } from "./lib/version-check.js";
|
|
6
|
-
import { networkErrorResponse, parseHttpResponse } from "./lib/http-response.js";
|
|
7
|
-
const UPDATE_COMMAND = "npm i -g @usenaive-sdk/cli@latest";
|
|
8
|
-
/**
|
|
9
|
-
* Server-driven version handshake. The API stamps `x-naive-cli-latest` and
|
|
10
|
-
* `x-naive-cli-min` on every response; we compare them against this CLI's own
|
|
11
|
-
* version. Below-minimum is a hard block (exits via agentError); below-latest
|
|
12
|
-
* queues a non-fatal update notice for the next agentOutput. Missing/unparseable
|
|
13
|
-
* headers are a no-op (evaluateCliVersion returns "ok").
|
|
14
|
-
*/
|
|
15
|
-
function checkCliVersion(resp) {
|
|
16
|
-
const latest = resp.headers.get("x-naive-cli-latest") ?? undefined;
|
|
17
|
-
const min = resp.headers.get("x-naive-cli-min") ?? undefined;
|
|
18
|
-
if (!latest && !min)
|
|
19
|
-
return;
|
|
20
|
-
// Best-effort: the version check must never break the user's command. The only
|
|
21
|
-
// intended non-return exit is the `cli_outdated` hard block; any unexpected
|
|
22
|
-
// throw is swallowed to a no-op.
|
|
23
|
-
try {
|
|
24
|
-
const current = readVersion();
|
|
25
|
-
const decision = evaluateCliVersion(current, min, latest);
|
|
26
|
-
if (decision.kind === "block") {
|
|
27
|
-
agentError({
|
|
28
|
-
action: "version_check",
|
|
29
|
-
error: {
|
|
30
|
-
code: "cli_outdated",
|
|
31
|
-
message: `Your naive CLI (v${decision.current}) is older than the minimum supported version (v${decision.min}). Update to continue.`,
|
|
32
|
-
},
|
|
33
|
-
recovery_steps: [
|
|
34
|
-
{ command: UPDATE_COMMAND, description: "Update to the latest naive CLI, then re-run your command" },
|
|
35
|
-
],
|
|
36
|
-
});
|
|
37
|
-
return; // unreachable — agentError calls process.exit(1)
|
|
38
|
-
}
|
|
39
|
-
if (decision.kind === "notice") {
|
|
40
|
-
setPendingUpdate({
|
|
41
|
-
current: decision.current,
|
|
42
|
-
latest: decision.latest,
|
|
43
|
-
update_command: UPDATE_COMMAND,
|
|
44
|
-
note: `A newer naive CLI is available (v${decision.current} → v${decision.latest}). Update with: ${UPDATE_COMMAND}`,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// Version check is advisory; on any unexpected failure, do nothing.
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// ── Non-JSON body handling (standalone helper) ──────────────────────────────
|
|
53
|
-
//
|
|
54
|
-
// The main request paths (apiRequest / apiUploadGzip / sessionLogin /
|
|
55
|
-
// sessionRequest) go through requestResponse() + lib/http-response.ts, which is
|
|
56
|
-
// content-type-aware, redacts secrets, and does the idempotent GET/HEAD retry.
|
|
57
|
-
// Callers that run their OWN fetch for a media/binary path (commands/media.ts,
|
|
58
|
-
// commands/clone.ts) use parseJsonOrUpstreamError() below to read a JSON body
|
|
59
|
-
// without ever throwing on a non-JSON gateway page.
|
|
60
|
-
const BODY_SNIPPET_MAX = 200;
|
|
61
|
-
/** Collapse whitespace and hard-truncate a response body so we never dump a full
|
|
62
|
-
* HTML page into the error envelope. */
|
|
63
|
-
function bodySnippet(text) {
|
|
64
|
-
return text.replace(/\s+/g, " ").trim().slice(0, BODY_SNIPPET_MAX);
|
|
65
|
-
}
|
|
66
|
-
/** True when `data` is our synthetic non-JSON marker (so handleApiError fires even
|
|
67
|
-
* on the rare non-JSON body carrying a 2xx status). */
|
|
68
|
-
export function isUpstreamError(data) {
|
|
69
|
-
return (typeof data === "object" &&
|
|
70
|
-
data !== null &&
|
|
71
|
-
data.error?.code === "upstream_error");
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Read a fetch Response body as JSON without ever throwing. Real API bodies are
|
|
75
|
-
* always JSON (the fast path). A non-JSON body (HTML gateway page, proxy text,
|
|
76
|
-
* empty body) is turned into a synthetic `{ error: { code: "upstream_error", … } }`
|
|
77
|
-
* envelope — the same shape formatApiError already understands — carrying the HTTP
|
|
78
|
-
* status and a bounded snippet, so the caller emits a clean error instead of crashing.
|
|
79
|
-
*/
|
|
80
|
-
export async function parseJsonOrUpstreamError(resp) {
|
|
81
|
-
const raw = await resp.text();
|
|
82
|
-
try {
|
|
83
|
-
return JSON.parse(raw);
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return {
|
|
87
|
-
error: {
|
|
88
|
-
code: "upstream_error",
|
|
89
|
-
message: `The API returned a non-JSON response (HTTP ${resp.status}). This is usually a transient gateway timeout — retry in a moment.`,
|
|
90
|
-
http_status: resp.status,
|
|
91
|
-
body_snippet: bodySnippet(raw),
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// Per-invocation override for the active subject user (set by a global --user
|
|
97
|
-
// flag). Falls back to config.active_user_id, then the api key's default.
|
|
98
|
-
let _userOverride;
|
|
99
|
-
export function setActiveUserOverride(userId) {
|
|
100
|
-
_userOverride = userId;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Resolve the active subject user id (override > env > config).
|
|
104
|
-
*
|
|
105
|
-
* NAIVE_ACTIVE_USER_ID is how a containerized agent gets a subject: its Hermes
|
|
106
|
-
* profile's .env carries its own sealed key plus its tenant_user id, so the CLI
|
|
107
|
-
* it runs scopes calls to /v1/users/<that id>/... and the agent's AccountKit
|
|
108
|
-
* (its declared `can:` / `limits:`) is actually enforced. There is no
|
|
109
|
-
* ~/.naive/config.json in a profile's home to hold `active_user_id`.
|
|
110
|
-
*/
|
|
111
|
-
export function activeUserId() {
|
|
112
|
-
const fromEnv = process.env.NAIVE_ACTIVE_USER_ID?.trim();
|
|
113
|
-
return _userOverride ?? (fromEnv || undefined) ?? loadConfig().active_user_id;
|
|
114
|
-
}
|
|
115
|
-
// Per-invocation override for the active project (set by a global --project flag).
|
|
116
|
-
let _projectOverride;
|
|
117
|
-
export function setActiveProjectOverride(projectId) {
|
|
118
|
-
_projectOverride = projectId;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* The `--project` flag as parsed off the ROOT program, if it was given.
|
|
122
|
-
*
|
|
123
|
-
* `naive use <child> --project <id>` writes the flag after the subcommand, but
|
|
124
|
-
* commander binds it to the root program's identically-named option, leaving the
|
|
125
|
-
* subcommand's own `opts.project` undefined. `use` reads it back through here.
|
|
126
|
-
*/
|
|
127
|
-
export function activeProjectOverride() {
|
|
128
|
-
return _projectOverride;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Resolve the active project id (override > env > config).
|
|
132
|
-
*
|
|
133
|
-
* Undefined is a MEANINGFUL answer, not a missing one: the server resolves the
|
|
134
|
-
* organization's default project, which is where `naive` acted before projects
|
|
135
|
-
* existed and where migration 059 backfilled every row. So the header is sent
|
|
136
|
-
* only when a project was actually chosen, and a CLI that never mentions one
|
|
137
|
-
* keeps producing byte-identical requests.
|
|
138
|
-
*/
|
|
139
|
-
export function activeProjectId() {
|
|
140
|
-
const fromEnv = process.env.NAIVE_ACTIVE_PROJECT_ID?.trim();
|
|
141
|
-
return _projectOverride ?? (fromEnv || undefined) ?? loadConfig().active_project_id;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Native primitives that have per-user path routes (/v1/users/:id/<prim>).
|
|
145
|
-
* When an active subject user is set, legacy company-level calls
|
|
146
|
-
* (/v1/<prim>/...) are rewritten to the path-scoped form so the CLI's
|
|
147
|
-
* `use`/`--user` selection actually isolates data and enforces the
|
|
148
|
-
* AccountKit — matching the SDK and dashboard. The legacy routes don't run
|
|
149
|
-
* the subject middleware, so without this the header was silently ignored.
|
|
150
|
-
*/
|
|
151
|
-
// NOTE: unlike the others, `wallet` and `payments` have NO legacy company-level
|
|
152
|
-
// mount. The default subject sentinel below is therefore required even when the
|
|
153
|
-
// caller has not explicitly selected a tenant user.
|
|
154
|
-
// `agents` is here because omitting it sends every CLI call to the
|
|
155
|
-
// COMPANY-scoped mount, which silently loses the child-project scope the
|
|
156
|
-
// per-agent budget and the vault boundary both hang off. It is not cosmetic:
|
|
157
|
-
// the company mount resolves no subject, so the strict kit gate goes inert and
|
|
158
|
-
// `list` would return another team's roster.
|
|
159
|
-
const PER_USER_PRIMITIVES = new Set(["agents", "cards", "phone", "trading", "email", "domains", "verification", "formation", "social", "compute", "queue", "mobile", "wallet", "payments"]);
|
|
160
|
-
const USER_PATH_ONLY_PRIMITIVES = new Set(["wallet", "payments"]);
|
|
161
|
-
/**
|
|
162
|
-
* The wallet's OPERATOR verbs: fund / sweep / setPolicy, plus POST /wallet
|
|
163
|
-
* (create) and /transfer, which are operator verbs too since they
|
|
164
|
-
* provision the float and move it out respectively. All of them move or
|
|
165
|
-
* re-govern the float. Reads (GET /wallet, /wallet/balances) and the agent's own
|
|
166
|
-
* /payments surface are NOT admin.
|
|
167
|
-
*/
|
|
168
|
-
const WALLET_ADMIN_PATH = /^\/v1\/(?:users\/[^/]+\/)?wallet(?:\/(?:fund|transfer|policy|sweep))?(?:\?|$)/;
|
|
169
|
-
function isWalletAdminCall(method, rawPath) {
|
|
170
|
-
return method.toUpperCase() === "POST" && WALLET_ADMIN_PATH.test(rawPath);
|
|
171
|
-
}
|
|
172
|
-
export function scopePathToUser(path, subject) {
|
|
173
|
-
if (path.startsWith("/v1/users/"))
|
|
174
|
-
return path; // already user-scoped
|
|
175
|
-
const m = path.match(/^\/v1\/([^/?]+)(.*)$/);
|
|
176
|
-
if (!m)
|
|
177
|
-
return path;
|
|
178
|
-
if (!PER_USER_PRIMITIVES.has(m[1]))
|
|
179
|
-
return path;
|
|
180
|
-
const resolvedSubject = subject ?? (USER_PATH_ONLY_PRIMITIVES.has(m[1]) ? "default" : undefined);
|
|
181
|
-
if (!resolvedSubject)
|
|
182
|
-
return path;
|
|
183
|
-
return `/v1/users/${resolvedSubject}/${m[1]}${m[2]}`;
|
|
184
|
-
}
|
|
185
|
-
const TRANSIENT_READ_STATUSES = new Set([500, 502, 503, 504]);
|
|
186
|
-
async function requestResponse(url, init) {
|
|
187
|
-
const method = String(init.method ?? "GET").toUpperCase();
|
|
188
|
-
const mayRetry = method === "GET" || method === "HEAD";
|
|
189
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
190
|
-
let response;
|
|
191
|
-
try {
|
|
192
|
-
response = await fetch(url, init);
|
|
193
|
-
}
|
|
194
|
-
catch (error) {
|
|
195
|
-
if (mayRetry && attempt === 0) {
|
|
196
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
return networkErrorResponse(error);
|
|
200
|
-
}
|
|
201
|
-
if (mayRetry && attempt === 0 && TRANSIENT_READ_STATUSES.has(response.status)) {
|
|
202
|
-
await response.body?.cancel().catch(() => { });
|
|
203
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
try {
|
|
207
|
-
return { ...(await parseHttpResponse(response)), response };
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
return { ...networkErrorResponse(error), response };
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return networkErrorResponse(new Error("Request failed after retry"));
|
|
214
|
-
}
|
|
215
|
-
export async function apiRequest(method, rawPath, body, opts) {
|
|
216
|
-
// Invariant guard: the human-only admin surface must NEVER be reached with an agent
|
|
217
|
-
// key. apiRequest sends the agent bearer, so it must refuse these paths outright.
|
|
218
|
-
if (rawPath.startsWith("/v1/voice-admin")) {
|
|
219
|
-
throw new Error("Internal error: /v1/voice-admin is human-only and must be called via sessionRequest, not apiRequest.");
|
|
220
|
-
}
|
|
221
|
-
// Same invariant for the wallet's operator verbs: an agent must
|
|
222
|
-
// never be able to fund, transfer, sweep or re-policy the float it spends
|
|
223
|
-
// from. The server enforces this too (enforceWalletAdmin); this is the
|
|
224
|
-
// client-side half, so a mistake surfaces at the call site, not as a 403.
|
|
225
|
-
if (isWalletAdminCall(method, rawPath)) {
|
|
226
|
-
throw new Error(`Internal error: ${rawPath} is an operator-only wallet verb and must be called via sessionRequest, not apiRequest.`);
|
|
227
|
-
}
|
|
228
|
-
const config = loadConfig();
|
|
229
|
-
const headers = {
|
|
230
|
-
"Content-Type": "application/json",
|
|
231
|
-
"X-Request-Id": randomUUID(),
|
|
232
|
-
...(opts?.headers ?? {}),
|
|
233
|
-
};
|
|
234
|
-
let path = rawPath;
|
|
235
|
-
if (!opts?.noAuth) {
|
|
236
|
-
headers["Authorization"] = `Bearer ${getApiKey()}`;
|
|
237
|
-
// Scope to a specific tenant_user when set. The server validates the id
|
|
238
|
-
// against the api key's company (cross-tenant guard).
|
|
239
|
-
const subject = opts?.userId ?? activeUserId();
|
|
240
|
-
if (subject)
|
|
241
|
-
headers["X-Naive-User-Id"] = subject;
|
|
242
|
-
// Select the project the same way: a header, so no route has to change.
|
|
243
|
-
const project = activeProjectId();
|
|
244
|
-
if (project)
|
|
245
|
-
headers["X-Naive-Project-Id"] = project;
|
|
246
|
-
// Native primitives only isolate via their per-user path routes, so rewrite
|
|
247
|
-
// legacy paths to the path-scoped form. "default" asks the API to resolve
|
|
248
|
-
// the key/company default when the CLI has no explicit `naive use` value.
|
|
249
|
-
path = scopePathToUser(path, subject);
|
|
250
|
-
}
|
|
251
|
-
const url = `${config.base_url}${path}`;
|
|
252
|
-
const parsed = await requestResponse(url, {
|
|
253
|
-
method,
|
|
254
|
-
headers,
|
|
255
|
-
...(body && { body: JSON.stringify(body) }),
|
|
256
|
-
});
|
|
257
|
-
if (parsed.response)
|
|
258
|
-
checkCliVersion(parsed.response);
|
|
259
|
-
return { status: parsed.status, data: parsed.data };
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Like {@link apiRequest} but for endpoints that return a BINARY body (e.g.
|
|
263
|
-
* synthesized speech). Sends the same JSON request and auth/subject handling,
|
|
264
|
-
* and on success returns the raw bytes plus the response headers, so callers
|
|
265
|
-
* can read ids like `x-audio-request-id` off the response.
|
|
266
|
-
*
|
|
267
|
-
* An error response is still JSON, so it is parsed into the usual `{ status,
|
|
268
|
-
* data }` shape — `handleApiError` works unchanged.
|
|
269
|
-
*/
|
|
270
|
-
export async function apiRequestBinary(method, rawPath, body, opts) {
|
|
271
|
-
const config = loadConfig();
|
|
272
|
-
const headers = {
|
|
273
|
-
"Content-Type": "application/json",
|
|
274
|
-
"X-Request-Id": randomUUID(),
|
|
275
|
-
...(opts?.headers ?? {}),
|
|
276
|
-
Authorization: `Bearer ${getApiKey()}`,
|
|
277
|
-
};
|
|
278
|
-
const subject = opts?.userId ?? activeUserId();
|
|
279
|
-
if (subject)
|
|
280
|
-
headers["X-Naive-User-Id"] = subject;
|
|
281
|
-
const binaryProject = activeProjectId();
|
|
282
|
-
if (binaryProject)
|
|
283
|
-
headers["X-Naive-Project-Id"] = binaryProject;
|
|
284
|
-
const path = scopePathToUser(rawPath, subject);
|
|
285
|
-
let response;
|
|
286
|
-
try {
|
|
287
|
-
response = await fetch(`${config.base_url}${path}`, {
|
|
288
|
-
method,
|
|
289
|
-
headers,
|
|
290
|
-
...(body && { body: JSON.stringify(body) }),
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
catch (error) {
|
|
294
|
-
return networkErrorResponse(error);
|
|
295
|
-
}
|
|
296
|
-
checkCliVersion(response);
|
|
297
|
-
if (!response.ok) {
|
|
298
|
-
// Errors come back as the standard JSON envelope even on a binary route.
|
|
299
|
-
const text = await response.text().catch(() => "");
|
|
300
|
-
let data = {};
|
|
301
|
-
try {
|
|
302
|
-
data = text ? JSON.parse(text) : {};
|
|
303
|
-
}
|
|
304
|
-
catch {
|
|
305
|
-
data = { error: { code: "upstream_error", message: text.slice(0, 500) || response.statusText } };
|
|
306
|
-
}
|
|
307
|
-
return { status: response.status, data };
|
|
308
|
-
}
|
|
309
|
-
const flatHeaders = {};
|
|
310
|
-
response.headers.forEach((value, key) => {
|
|
311
|
-
flatHeaders[key.toLowerCase()] = value;
|
|
312
|
-
});
|
|
313
|
-
return { status: response.status, data: await response.arrayBuffer(), headers: flatHeaders };
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Upload a raw gzipped payload (e.g. a project tarball for direct app deploys).
|
|
317
|
-
* Same auth + subject handling as apiRequest, but with a binary body.
|
|
318
|
-
*/
|
|
319
|
-
export async function apiUploadGzip(rawPath, payload, opts) {
|
|
320
|
-
const config = loadConfig();
|
|
321
|
-
const headers = {
|
|
322
|
-
"Content-Type": "application/gzip",
|
|
323
|
-
"X-Request-Id": randomUUID(),
|
|
324
|
-
Authorization: `Bearer ${getApiKey()}`,
|
|
325
|
-
};
|
|
326
|
-
const subject = opts?.userId ?? activeUserId();
|
|
327
|
-
if (subject)
|
|
328
|
-
headers["X-Naive-User-Id"] = subject;
|
|
329
|
-
const uploadProject = activeProjectId();
|
|
330
|
-
if (uploadProject)
|
|
331
|
-
headers["X-Naive-Project-Id"] = uploadProject;
|
|
332
|
-
const path = scopePathToUser(rawPath, subject);
|
|
333
|
-
const parsed = await requestResponse(`${config.base_url}${path}`, {
|
|
334
|
-
method: "POST",
|
|
335
|
-
headers,
|
|
336
|
-
body: new Uint8Array(payload),
|
|
337
|
-
});
|
|
338
|
-
if (parsed.response)
|
|
339
|
-
checkCliVersion(parsed.response);
|
|
340
|
-
return { status: parsed.status, data: parsed.data };
|
|
341
|
-
}
|
|
342
|
-
export function handleApiError(action, resp) {
|
|
343
|
-
// Fires on any 4xx/5xx, and also on a synthetic upstream_error carrying a 2xx
|
|
344
|
-
// status (a non-JSON body from a proxy) so a malformed success never slips through.
|
|
345
|
-
if (resp.status >= 400 || isUpstreamError(resp.data)) {
|
|
346
|
-
formatApiError(action, resp.data);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
// ── Human session auth (for human-only operations: voice clone/revoke) ──────────────
|
|
350
|
-
//
|
|
351
|
-
// A session cookie is materially more powerful than the agent key on the voice surface
|
|
352
|
-
// (it can clone AND revoke), so it gets stricter handling: never sent over plaintext to a
|
|
353
|
-
// remote host, and the agent api_key is never read in this path.
|
|
354
|
-
/** Refuse to put a session cookie on the wire over plaintext http to a non-local host —
|
|
355
|
-
* the server only marks the cookie `secure` in prod, so we protect it client-side. */
|
|
356
|
-
function assertSecureBaseUrl(baseUrl) {
|
|
357
|
-
let u;
|
|
358
|
-
try {
|
|
359
|
-
u = new URL(baseUrl);
|
|
360
|
-
}
|
|
361
|
-
catch {
|
|
362
|
-
throw new Error(`Invalid base_url: ${baseUrl}`);
|
|
363
|
-
}
|
|
364
|
-
const isLocal = u.hostname === "localhost" || u.hostname === "127.0.0.1" || u.hostname === "::1";
|
|
365
|
-
if (u.protocol === "http:" && !isLocal) {
|
|
366
|
-
throw new Error(`Refusing to send a session cookie over plaintext http to ${u.hostname}. Use https, or a localhost base_url for dev.`);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
/** Exchange email+password for a session token, captured from Set-Cookie (the token is
|
|
370
|
-
* not in the response body). Returns the token + the login payload. Exits on API error. */
|
|
371
|
-
export async function sessionLogin(email, password) {
|
|
372
|
-
const config = loadConfig();
|
|
373
|
-
assertSecureBaseUrl(config.base_url);
|
|
374
|
-
const parsed = await requestResponse(`${config.base_url}/v1/auth/session/login`, {
|
|
375
|
-
method: "POST",
|
|
376
|
-
headers: { "Content-Type": "application/json", "X-Request-Id": randomUUID() },
|
|
377
|
-
body: JSON.stringify({ email, password }),
|
|
378
|
-
});
|
|
379
|
-
const data = parsed.data;
|
|
380
|
-
if (parsed.status >= 400 || isUpstreamError(data)) {
|
|
381
|
-
formatApiError("auth.session-login", data); // exits the process
|
|
382
|
-
}
|
|
383
|
-
// Parse by name, not by index — the server may set more than one cookie.
|
|
384
|
-
const cookie = parsed.response?.headers.getSetCookie().find((c) => c.startsWith("naive_session="));
|
|
385
|
-
if (!cookie) {
|
|
386
|
-
throw new Error("Login succeeded but no naive_session cookie was returned.");
|
|
387
|
-
}
|
|
388
|
-
const token = cookie.slice("naive_session=".length).split(";")[0];
|
|
389
|
-
return { token, data };
|
|
390
|
-
}
|
|
391
|
-
/** HTTP for human-only routes. Sends the session cookie, NEVER the agent api_key.
|
|
392
|
-
* Supports JSON and multipart (native FormData) bodies, with an upload timeout. */
|
|
393
|
-
export async function sessionRequest(method, path, opts) {
|
|
394
|
-
const config = loadConfig();
|
|
395
|
-
assertSecureBaseUrl(config.base_url);
|
|
396
|
-
const url = `${config.base_url}${path}`;
|
|
397
|
-
const headers = {
|
|
398
|
-
// getSessionToken() never falls back to the agent key.
|
|
399
|
-
Cookie: `naive_session=${getSessionToken()}`,
|
|
400
|
-
"X-Request-Id": randomUUID(),
|
|
401
|
-
...(opts?.headers ?? {}),
|
|
402
|
-
};
|
|
403
|
-
let payload;
|
|
404
|
-
if (opts?.multipart) {
|
|
405
|
-
payload = opts.multipart; // fetch sets the multipart Content-Type + boundary
|
|
406
|
-
}
|
|
407
|
-
else if (opts?.body) {
|
|
408
|
-
headers["Content-Type"] = "application/json";
|
|
409
|
-
payload = JSON.stringify(opts.body);
|
|
410
|
-
}
|
|
411
|
-
// Bound the request so a stalled (large) upload can't hang the CLI forever.
|
|
412
|
-
const controller = new AbortController();
|
|
413
|
-
const timeout = setTimeout(() => controller.abort(), opts?.timeoutMs ?? 120_000);
|
|
414
|
-
try {
|
|
415
|
-
const parsed = await requestResponse(url, {
|
|
416
|
-
method,
|
|
417
|
-
headers,
|
|
418
|
-
...(payload !== undefined && { body: payload }),
|
|
419
|
-
signal: controller.signal,
|
|
420
|
-
});
|
|
421
|
-
return { status: parsed.status, data: parsed.data };
|
|
422
|
-
}
|
|
423
|
-
finally {
|
|
424
|
-
clearTimeout(timeout);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Governance: a sensitive action may be deferred for human approval (HTTP 202
|
|
429
|
-
* with `status: "pending_approval"`). When that happens, emit a structured
|
|
430
|
-
* pending result (NOT an error — it's a successful deferral) and return true so
|
|
431
|
-
* the caller can stop. Returns false for a normal response.
|
|
432
|
-
*/
|
|
433
|
-
export function handlePendingApproval(action, resp) {
|
|
434
|
-
const d = resp.data;
|
|
435
|
-
if (resp.status === 202 || d?.status === "pending_approval") {
|
|
436
|
-
agentOutput({
|
|
437
|
-
action,
|
|
438
|
-
result: resp.data,
|
|
439
|
-
next_steps: [
|
|
440
|
-
{
|
|
441
|
-
command: `naive approvals approve ${d.approval_id ?? "<approval_id>"}`,
|
|
442
|
-
description: "Approve & execute this action (agentProfile/owner)",
|
|
443
|
-
},
|
|
444
|
-
{
|
|
445
|
-
command: `naive approvals get ${d.approval_id ?? "<approval_id>"}`,
|
|
446
|
-
description: "Check whether it's been approved yet",
|
|
447
|
-
},
|
|
448
|
-
],
|
|
449
|
-
hints: [
|
|
450
|
-
d.message ?? "This action requires human approval before it executes.",
|
|
451
|
-
"It has been added to the approval queue (HTTP 202).",
|
|
452
|
-
],
|
|
453
|
-
});
|
|
454
|
-
return true;
|
|
455
|
-
}
|
|
456
|
-
return false;
|
|
457
|
-
}
|
|
458
|
-
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAC;AAE1G,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAE3D;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,IA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