@1claw/cli 0.1.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 (75) hide show
  1. package/LICENSE +133 -0
  2. package/README.md +215 -0
  3. package/dist/bin/1claw.d.ts +3 -0
  4. package/dist/bin/1claw.d.ts.map +1 -0
  5. package/dist/bin/1claw.js +8 -0
  6. package/dist/bin/1claw.js.map +1 -0
  7. package/dist/src/auth.d.ts +6 -0
  8. package/dist/src/auth.d.ts.map +1 -0
  9. package/dist/src/auth.js +151 -0
  10. package/dist/src/auth.js.map +1 -0
  11. package/dist/src/client.d.ts +18 -0
  12. package/dist/src/client.d.ts.map +1 -0
  13. package/dist/src/client.js +58 -0
  14. package/dist/src/client.js.map +1 -0
  15. package/dist/src/commands/agent.d.ts +3 -0
  16. package/dist/src/commands/agent.d.ts.map +1 -0
  17. package/dist/src/commands/agent.js +233 -0
  18. package/dist/src/commands/agent.js.map +1 -0
  19. package/dist/src/commands/audit.d.ts +3 -0
  20. package/dist/src/commands/audit.d.ts.map +1 -0
  21. package/dist/src/commands/audit.js +57 -0
  22. package/dist/src/commands/audit.js.map +1 -0
  23. package/dist/src/commands/billing.d.ts +3 -0
  24. package/dist/src/commands/billing.d.ts.map +1 -0
  25. package/dist/src/commands/billing.js +160 -0
  26. package/dist/src/commands/billing.js.map +1 -0
  27. package/dist/src/commands/config.d.ts +3 -0
  28. package/dist/src/commands/config.d.ts.map +1 -0
  29. package/dist/src/commands/config.js +65 -0
  30. package/dist/src/commands/config.js.map +1 -0
  31. package/dist/src/commands/env.d.ts +3 -0
  32. package/dist/src/commands/env.d.ts.map +1 -0
  33. package/dist/src/commands/env.js +164 -0
  34. package/dist/src/commands/env.js.map +1 -0
  35. package/dist/src/commands/login.d.ts +5 -0
  36. package/dist/src/commands/login.d.ts.map +1 -0
  37. package/dist/src/commands/login.js +88 -0
  38. package/dist/src/commands/login.js.map +1 -0
  39. package/dist/src/commands/mfa.d.ts +3 -0
  40. package/dist/src/commands/mfa.d.ts.map +1 -0
  41. package/dist/src/commands/mfa.js +123 -0
  42. package/dist/src/commands/mfa.js.map +1 -0
  43. package/dist/src/commands/policy.d.ts +3 -0
  44. package/dist/src/commands/policy.d.ts.map +1 -0
  45. package/dist/src/commands/policy.js +114 -0
  46. package/dist/src/commands/policy.js.map +1 -0
  47. package/dist/src/commands/secret.d.ts +3 -0
  48. package/dist/src/commands/secret.d.ts.map +1 -0
  49. package/dist/src/commands/secret.js +206 -0
  50. package/dist/src/commands/secret.js.map +1 -0
  51. package/dist/src/commands/share.d.ts +3 -0
  52. package/dist/src/commands/share.d.ts.map +1 -0
  53. package/dist/src/commands/share.js +145 -0
  54. package/dist/src/commands/share.js.map +1 -0
  55. package/dist/src/commands/vault.d.ts +3 -0
  56. package/dist/src/commands/vault.d.ts.map +1 -0
  57. package/dist/src/commands/vault.js +127 -0
  58. package/dist/src/commands/vault.js.map +1 -0
  59. package/dist/src/config.d.ts +25 -0
  60. package/dist/src/config.d.ts.map +1 -0
  61. package/dist/src/config.js +68 -0
  62. package/dist/src/config.js.map +1 -0
  63. package/dist/src/index.d.ts +3 -0
  64. package/dist/src/index.d.ts.map +1 -0
  65. package/dist/src/index.js +51 -0
  66. package/dist/src/index.js.map +1 -0
  67. package/dist/src/middleware.d.ts +6 -0
  68. package/dist/src/middleware.d.ts.map +1 -0
  69. package/dist/src/middleware.js +35 -0
  70. package/dist/src/middleware.js.map +1 -0
  71. package/dist/src/output.d.ts +12 -0
  72. package/dist/src/output.d.ts.map +1 -0
  73. package/dist/src/output.js +71 -0
  74. package/dist/src/output.js.map +1 -0
  75. package/package.json +57 -0
package/LICENSE ADDED
@@ -0,0 +1,133 @@
1
+ # PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ Required Notice: Copyright (c) 2026 1Claw Contributors
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree
10
+ to them as both strict obligations and conditions to all
11
+ your licenses.
12
+
13
+ ## Copyright License
14
+
15
+ The licensor grants you a copyright license for the
16
+ software to do everything you might do with the software
17
+ that would otherwise infringe the licensor's copyright
18
+ in it for any permitted purpose. However, you may
19
+ only distribute the software according to [Distribution
20
+ License](#distribution-license) and make changes or new works
21
+ based on the software according to [Changes and New Works
22
+ License](#changes-and-new-works-license).
23
+
24
+ ## Distribution License
25
+
26
+ The licensor grants you an additional copyright license
27
+ to distribute copies of the software. Your license
28
+ to distribute covers distributing the software with
29
+ changes and new works permitted by [Changes and New Works
30
+ License](#changes-and-new-works-license).
31
+
32
+ ## Notices
33
+
34
+ You must ensure that anyone who gets a copy of any part of
35
+ the software from you also gets a copy of these terms or the
36
+ URL for them above, as well as copies of any plain-text lines
37
+ beginning with `Required Notice:` that the licensor provided
38
+ with the software. For example:
39
+
40
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
41
+
42
+ ## Changes and New Works License
43
+
44
+ The licensor grants you an additional copyright license to
45
+ make changes and new works based on the software for any
46
+ permitted purpose.
47
+
48
+ ## Patent License
49
+
50
+ The licensor grants you a patent license for the software that
51
+ covers patent claims the licensor can license, or becomes able
52
+ to license, that you would infringe by using the software.
53
+
54
+ ## Noncommercial Purposes
55
+
56
+ Any noncommercial purpose is a permitted purpose.
57
+
58
+ ## Personal Uses
59
+
60
+ Personal use for research, experiment, and testing for
61
+ the benefit of public knowledge, personal study, private
62
+ entertainment, hobby projects, amateur pursuits, or religious
63
+ observance, without any anticipated commercial application,
64
+ is use for a permitted purpose.
65
+
66
+ ## Noncommercial Organizations
67
+
68
+ Use by any charitable organization, educational institution,
69
+ public research organization, public safety or health
70
+ organization, environmental protection organization,
71
+ or government institution is use for a permitted purpose
72
+ regardless of the source of funding or obligations resulting
73
+ from the funding.
74
+
75
+ ## Fair Use
76
+
77
+ You may have "fair use" rights for the software under the
78
+ law. These terms do not limit them.
79
+
80
+ ## No Other Rights
81
+
82
+ These terms do not allow you to sublicense or transfer any of
83
+ your licenses to anyone else, or prevent the licensor from
84
+ granting licenses to anyone else. These terms do not imply
85
+ any other licenses.
86
+
87
+ ## Patent Defense
88
+
89
+ If you make any written claim that the software infringes or
90
+ contributes to infringement of any patent, your patent license
91
+ for the software granted under these terms ends immediately. If
92
+ your company makes such a claim, your patent license ends
93
+ immediately for work on behalf of your company.
94
+
95
+ ## Violations
96
+
97
+ The first time you are notified in writing that you have
98
+ violated any of these terms, or done anything with the software
99
+ not covered by your licenses, your licenses can nonetheless
100
+ continue if you come into full compliance with these terms,
101
+ and take practical steps to correct past violations, within
102
+ 32 days of receiving notice. Otherwise, all your licenses
103
+ end immediately.
104
+
105
+ ## No Liability
106
+
107
+ ***As far as the law allows, the software comes as is, without
108
+ any warranty or condition, and the licensor will not be liable
109
+ to you for any damages arising out of these terms or the use
110
+ or nature of the software, under any kind of legal claim.***
111
+
112
+ ## Definitions
113
+
114
+ The **licensor** is the individual or entity offering these
115
+ terms, and the **software** is the software the licensor makes
116
+ available under these terms.
117
+
118
+ **You** refers to the individual or entity agreeing to these
119
+ terms.
120
+
121
+ **Your company** is any legal entity, sole proprietorship,
122
+ or other kind of organization that you work for, plus all
123
+ organizations that have control over, are under the control of,
124
+ or are under common control with that organization. **Control**
125
+ means ownership of substantially all the assets of an entity,
126
+ or the power to direct its management and policies by vote,
127
+ contract, or otherwise. Control can be direct or indirect.
128
+
129
+ **Your licenses** are all the licenses granted to you for the
130
+ software under these terms.
131
+
132
+ **Use** means anything you do with the software requiring one
133
+ of your licenses.
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ # @1claw/cli
2
+
3
+ Command-line interface for [1Claw](https://1claw.xyz) — HSM-backed secret management for AI agents and humans.
4
+
5
+ Designed for CI/CD pipelines, DevOps workflows, and server environments.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g @1claw/cli
11
+ ```
12
+
13
+ Or use directly with npx:
14
+
15
+ ```bash
16
+ npx @1claw/cli login
17
+ ```
18
+
19
+ ## Authentication
20
+
21
+ ### Interactive login (recommended)
22
+
23
+ ```bash
24
+ 1claw login
25
+ ```
26
+
27
+ Opens your browser to `1claw.xyz/cli/verify` where you confirm the login code. The CLI polls for approval and stores the token locally in `~/.config/1claw/`.
28
+
29
+ ### Email/password login
30
+
31
+ ```bash
32
+ 1claw login --email
33
+ ```
34
+
35
+ Prompts for email and password. Supports MFA if enabled on your account.
36
+
37
+ ### CI/CD (non-interactive)
38
+
39
+ Set environment variables — no login command needed:
40
+
41
+ ```bash
42
+ export ONECLAW_TOKEN="your-jwt"
43
+ # or
44
+ export ONECLAW_API_KEY="1ck_..."
45
+ ```
46
+
47
+ ## Commands
48
+
49
+ ### Auth
50
+
51
+ ```bash
52
+ 1claw login # Browser-based login
53
+ 1claw login --email # Email/password login
54
+ 1claw logout # Clear stored credentials
55
+ 1claw whoami # Show current user info
56
+ ```
57
+
58
+ ### Vaults
59
+
60
+ ```bash
61
+ 1claw vault list # List all vaults
62
+ 1claw vault create my-vault # Create a vault
63
+ 1claw vault get <id> # Get vault details
64
+ 1claw vault delete <id> # Delete a vault
65
+ 1claw vault link <id> # Set default vault for this machine
66
+ 1claw vault unlink # Remove default vault
67
+ ```
68
+
69
+ ### Secrets
70
+
71
+ ```bash
72
+ 1claw secret list # List secrets (metadata only)
73
+ 1claw secret list --prefix api-keys/ # Filter by prefix
74
+ 1claw secret get <path> # Fetch decrypted value
75
+ 1claw secret get <path> --quiet # Raw value only (for piping)
76
+ 1claw secret set <path> <value> # Create/update a secret
77
+ 1claw secret set <path> --type password # With explicit type
78
+ echo "sk_live_..." | 1claw secret set <path> --stdin # From stdin
79
+ 1claw secret delete <path> # Soft-delete
80
+ 1claw secret rotate <path> <new-value> # New version
81
+ 1claw secret describe <path> # Metadata without value
82
+ ```
83
+
84
+ ### Environment (CI/CD)
85
+
86
+ ```bash
87
+ 1claw env pull # Pull secrets as .env format
88
+ 1claw env pull --format json # As JSON
89
+ 1claw env pull --format shell # As export statements
90
+ 1claw env pull -o .env.local # Write to file
91
+ 1claw env push .env # Push .env file to vault
92
+ 1claw env run -- npm start # Run with secrets injected
93
+ 1claw env run --prefix config/ -- ./deploy.sh # Only inject matching secrets
94
+ ```
95
+
96
+ ### Agents
97
+
98
+ ```bash
99
+ 1claw agent list # List agents
100
+ 1claw agent create my-agent # Create an agent
101
+ 1claw agent get <id> # Agent details
102
+ 1claw agent delete <id> # Delete an agent
103
+ 1claw agent token <id> # Generate agent JWT
104
+ 1claw agent token <id> --quiet # Raw token (for piping)
105
+ ```
106
+
107
+ ### Policies
108
+
109
+ ```bash
110
+ 1claw policy list # List policies for default vault
111
+ 1claw policy create \
112
+ --principal-type agent \
113
+ --principal-id <uuid> \
114
+ --path "api-keys/*" \
115
+ --permissions read,write # Create a policy
116
+ 1claw policy delete <id> # Remove a policy
117
+ ```
118
+
119
+ ### Sharing
120
+
121
+ ```bash
122
+ 1claw share create <secret-id> --link # Open share link
123
+ 1claw share create <secret-id> --to user:<id> # Share with a user
124
+ 1claw share create <secret-id> --to agent:<id> # Share with an agent
125
+ 1claw share list # List outbound shares
126
+ 1claw share list --inbound # List inbound shares
127
+ 1claw share accept <id> # Accept a share
128
+ 1claw share decline <id> # Decline a share
129
+ 1claw share revoke <id> # Revoke a share
130
+ ```
131
+
132
+ ### Billing
133
+
134
+ ```bash
135
+ 1claw billing status # Plan, usage, limits
136
+ 1claw billing credits # Credit balance
137
+ 1claw billing usage # Detailed usage table
138
+ 1claw billing ledger # Credit transaction history
139
+ ```
140
+
141
+ ### Audit
142
+
143
+ ```bash
144
+ 1claw audit list # Recent audit events
145
+ 1claw audit list --vault <id> # Filter by vault
146
+ 1claw audit list --action secret.read # Filter by action
147
+ ```
148
+
149
+ ### MFA
150
+
151
+ ```bash
152
+ 1claw mfa status # Check 2FA status
153
+ 1claw mfa enable # Set up TOTP 2FA
154
+ 1claw mfa disable # Turn off 2FA
155
+ ```
156
+
157
+ ### Configuration
158
+
159
+ ```bash
160
+ 1claw config list # Show all config
161
+ 1claw config get api-url # Get a value
162
+ 1claw config set output-format json # Set default output
163
+ ```
164
+
165
+ ## Global options
166
+
167
+ ```bash
168
+ --json # Force JSON output on any command
169
+ --api-url <url> # Override API URL for this invocation
170
+ --version # Print version
171
+ --help # Show help
172
+ ```
173
+
174
+ ## Configuration
175
+
176
+ Config is stored in `~/.config/1claw/config.json`. Keys:
177
+
178
+ | Key | Default | Description |
179
+ | --------------- | ----------------------- | ------------------------------------------- |
180
+ | `api-url` | `https://api.1claw.xyz` | API base URL |
181
+ | `output-format` | `table` | Default output: `table`, `json`, or `plain` |
182
+ | `default-vault` | (none) | Default vault ID for commands |
183
+
184
+ ## CI/CD examples
185
+
186
+ ### GitHub Actions
187
+
188
+ ```yaml
189
+ - name: Deploy with secrets
190
+ env:
191
+ ONECLAW_TOKEN: ${{ secrets.ONECLAW_TOKEN }}
192
+ ONECLAW_VAULT_ID: ${{ secrets.ONECLAW_VAULT_ID }}
193
+ run: |
194
+ npx @1claw/cli env pull -o .env.production
195
+ npm run deploy
196
+ ```
197
+
198
+ ### Docker
199
+
200
+ ```dockerfile
201
+ RUN npm install -g @1claw/cli
202
+ CMD ["1claw", "env", "run", "--", "node", "server.js"]
203
+ ```
204
+
205
+ ### Shell script
206
+
207
+ ```bash
208
+ #!/bin/bash
209
+ eval $(1claw env pull --format shell)
210
+ ./my-app
211
+ ```
212
+
213
+ ## License
214
+
215
+ [PolyForm Noncommercial 1.0.0](../../LICENSE)
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=1claw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1claw.d.ts","sourceRoot":"","sources":["../../bin/1claw.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { createProgram } from "../src/index.js";
3
+ const program = createProgram();
4
+ program.parseAsync(process.argv).catch((err) => {
5
+ console.error(err);
6
+ process.exit(1);
7
+ });
8
+ //# sourceMappingURL=1claw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1claw.js","sourceRoot":"","sources":["../../bin/1claw.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC3C,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type StoredAuth } from "./config.js";
2
+ export declare function loginWithDevice(): Promise<StoredAuth | null>;
3
+ export declare function loginWithCredentials(email: string, password: string): Promise<StoredAuth | null>;
4
+ export declare function completeMfaLogin(mfaToken: string, code: string): Promise<StoredAuth | null>;
5
+ export declare function requireAuth(): string;
6
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAUA,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAqB7E,wBAAsB,eAAe,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA6FlE;AAED,wBAAsB,oBAAoB,CACtC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAoC5B;AAED,wBAAsB,gBAAgB,CAClC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA8B5B;AAED,wBAAgB,WAAW,IAAI,MAAM,CAkBpC"}
@@ -0,0 +1,151 @@
1
+ import open from "open";
2
+ import ora from "ora";
3
+ import chalk from "chalk";
4
+ import { api, apiNoAuth } from "./client.js";
5
+ import { setAuth, getApiUrl } from "./config.js";
6
+ import { printError } from "./output.js";
7
+ export async function loginWithDevice() {
8
+ const spinner = ora("Requesting login code…").start();
9
+ let device;
10
+ try {
11
+ device = await apiNoAuth("/auth/device/code", {
12
+ method: "POST",
13
+ body: { client_id: "cli" },
14
+ });
15
+ }
16
+ catch (err) {
17
+ spinner.fail("Failed to request device code");
18
+ printError(err.message);
19
+ return null;
20
+ }
21
+ spinner.stop();
22
+ const dashboardUrl = getApiUrl().replace("api.", "");
23
+ const verifyUrl = `${dashboardUrl}/cli/verify?code=${device.user_code}`;
24
+ console.log();
25
+ console.log(chalk.bold(" Login to 1Claw"));
26
+ console.log();
27
+ console.log(` Your code: ${chalk.cyan.bold(device.user_code)}`);
28
+ console.log();
29
+ console.log(` Open this URL to authenticate:`);
30
+ console.log(` ${chalk.underline(verifyUrl)}`);
31
+ console.log();
32
+ try {
33
+ await open(verifyUrl);
34
+ console.log(chalk.dim(" Browser opened. Waiting for approval…"));
35
+ }
36
+ catch {
37
+ console.log(chalk.dim(" Open the URL above in your browser."));
38
+ }
39
+ console.log();
40
+ const pollSpinner = ora("Waiting for approval…").start();
41
+ const deadline = Date.now() + device.expires_in * 1000;
42
+ const interval = (device.interval ?? 5) * 1000;
43
+ while (Date.now() < deadline) {
44
+ await sleep(interval);
45
+ try {
46
+ const result = await apiNoAuth("/auth/device/token", {
47
+ method: "POST",
48
+ body: {
49
+ device_code: device.device_code,
50
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
51
+ },
52
+ });
53
+ if (result.access_token) {
54
+ pollSpinner.succeed("Authenticated!");
55
+ const auth = {
56
+ token: result.access_token,
57
+ email: result.email ?? "",
58
+ userId: result.user_id ?? "",
59
+ orgId: result.org_id ?? "",
60
+ expiresAt: result.expires_in
61
+ ? new Date(Date.now() + result.expires_in * 1000).toISOString()
62
+ : undefined,
63
+ };
64
+ setAuth(auth);
65
+ return auth;
66
+ }
67
+ if (result.error === "expired_token") {
68
+ pollSpinner.fail("Login code expired. Run `1claw login` again.");
69
+ return null;
70
+ }
71
+ if (result.error === "access_denied") {
72
+ pollSpinner.fail("Login was denied.");
73
+ return null;
74
+ }
75
+ }
76
+ catch {
77
+ // authorization_pending — keep polling
78
+ }
79
+ }
80
+ pollSpinner.fail("Login timed out. Run `1claw login` again.");
81
+ return null;
82
+ }
83
+ export async function loginWithCredentials(email, password) {
84
+ try {
85
+ const result = await apiNoAuth("/auth/token", {
86
+ method: "POST",
87
+ body: { email, password },
88
+ });
89
+ if (result.mfa_required && result.mfa_token) {
90
+ return { mfaToken: result.mfa_token };
91
+ }
92
+ const me = await api("/auth/me", { token: result.access_token });
93
+ const auth = {
94
+ token: result.access_token,
95
+ email: me.email,
96
+ userId: me.id,
97
+ orgId: me.org_id,
98
+ expiresAt: new Date(Date.now() + result.expires_in * 1000).toISOString(),
99
+ };
100
+ setAuth(auth);
101
+ return auth;
102
+ }
103
+ catch (err) {
104
+ printError(err.message);
105
+ return null;
106
+ }
107
+ }
108
+ export async function completeMfaLogin(mfaToken, code) {
109
+ try {
110
+ const result = await apiNoAuth("/auth/mfa/verify", {
111
+ method: "POST",
112
+ body: { mfa_token: mfaToken, code },
113
+ });
114
+ const me = await api("/auth/me", { token: result.access_token });
115
+ const auth = {
116
+ token: result.access_token,
117
+ email: me.email,
118
+ userId: me.id,
119
+ orgId: me.org_id,
120
+ expiresAt: new Date(Date.now() + result.expires_in * 1000).toISOString(),
121
+ };
122
+ setAuth(auth);
123
+ return auth;
124
+ }
125
+ catch (err) {
126
+ printError(err.message);
127
+ return null;
128
+ }
129
+ }
130
+ export function requireAuth() {
131
+ const token = process.env.ONECLAW_TOKEN ??
132
+ process.env.ONECLAW_API_KEY ??
133
+ (() => {
134
+ try {
135
+ const { getToken } = require("./config.js");
136
+ return getToken();
137
+ }
138
+ catch {
139
+ return null;
140
+ }
141
+ })();
142
+ if (!token) {
143
+ printError("Not authenticated. Run `1claw login` first.");
144
+ process.exit(1);
145
+ }
146
+ return token;
147
+ }
148
+ function sleep(ms) {
149
+ return new Promise((resolve) => setTimeout(resolve, ms));
150
+ }
151
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAMA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,SAAS,EAAiB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,SAAS,EAA8B,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAgB,MAAM,aAAa,CAAC;AAoBvD,MAAM,CAAC,KAAK,UAAU,eAAe;IACjC,MAAM,OAAO,GAAG,GAAG,CAAC,wBAAwB,CAAC,CAAC,KAAK,EAAE,CAAC;IAEtD,IAAI,MAA0B,CAAC;IAC/B,IAAI,CAAC;QACD,MAAM,GAAG,MAAM,SAAS,CAAqB,mBAAmB,EAAE;YAC9D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SAC7B,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QAC9C,UAAU,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,IAAI,EAAE,CAAC;IAEf,MAAM,YAAY,GAAG,SAAS,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,GAAG,YAAY,oBAAoB,MAAM,CAAC,SAAS,EAAE,CAAC;IAExE,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC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AK,EAAE,EAAE,CAAC,MAAM;YAChB,SAAS,EAAE,IAAI,IAAI,CACf,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CACxC,CAAC,WAAW,EAAE;SAClB,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,UAAU,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW;IACvB,MAAM,KAAK,GACP,OAAO,CAAC,GAAG,CAAC,aAAa;QACzB,OAAO,CAAC,GAAG,CAAC,eAAe;QAC3B,CAAC,GAAG,EAAE;YACF,IAAI,CAAC;gBACD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;gBAC5C,OAAO,QAAQ,EAAE,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC;gBACL,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC,CAAC,EAAE,CAAC;IAET,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,UAAU,CAAC,6CAA6C,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACrB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,18 @@
1
+ export declare class ApiError extends Error {
2
+ status: number;
3
+ detail: string;
4
+ code?: string | undefined;
5
+ constructor(status: number, detail: string, code?: string | undefined);
6
+ }
7
+ export declare function api<T = unknown>(path: string, options?: {
8
+ method?: string;
9
+ body?: unknown;
10
+ token?: string;
11
+ query?: Record<string, string | number | boolean | undefined>;
12
+ }): Promise<T>;
13
+ export declare function apiNoAuth<T = unknown>(path: string, options?: {
14
+ method?: string;
15
+ body?: unknown;
16
+ query?: Record<string, string | number | boolean | undefined>;
17
+ }): Promise<T>;
18
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAEA,qBAAa,QAAS,SAAQ,KAAK;IAEpB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,IAAI,CAAC,EAAE,MAAM;gBAFb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;CAK3B;AAgBD,wBAAsB,GAAG,CAAC,CAAC,GAAG,OAAO,EACjC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACL,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC5D,GACP,OAAO,CAAC,CAAC,CAAC,CA+BZ;AAED,wBAAsB,SAAS,CAAC,CAAC,GAAG,OAAO,EACvC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACL,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC5D,GACP,OAAO,CAAC,CAAC,CAAC,CAEZ"}
@@ -0,0 +1,58 @@
1
+ import { getApiUrl, getToken } from "./config.js";
2
+ export class ApiError extends Error {
3
+ status;
4
+ detail;
5
+ code;
6
+ constructor(status, detail, code) {
7
+ super(`${status}: ${detail}`);
8
+ this.status = status;
9
+ this.detail = detail;
10
+ this.code = code;
11
+ this.name = "ApiError";
12
+ }
13
+ }
14
+ async function parseErrorBody(res) {
15
+ try {
16
+ const body = (await res.json());
17
+ return {
18
+ detail: body.detail ?? body.message ?? body.error ?? res.statusText,
19
+ code: body.code,
20
+ };
21
+ }
22
+ catch {
23
+ return { detail: res.statusText };
24
+ }
25
+ }
26
+ export async function api(path, options = {}) {
27
+ const baseUrl = getApiUrl();
28
+ const token = options.token ?? getToken();
29
+ const url = new URL(`/v1${path}`, baseUrl);
30
+ if (options.query) {
31
+ for (const [k, v] of Object.entries(options.query)) {
32
+ if (v !== undefined)
33
+ url.searchParams.set(k, String(v));
34
+ }
35
+ }
36
+ const headers = {
37
+ "Content-Type": "application/json",
38
+ "User-Agent": "@1claw/cli",
39
+ };
40
+ if (token)
41
+ headers["Authorization"] = `Bearer ${token}`;
42
+ const res = await fetch(url.toString(), {
43
+ method: options.method ?? "GET",
44
+ headers,
45
+ body: options.body ? JSON.stringify(options.body) : undefined,
46
+ });
47
+ if (!res.ok) {
48
+ const err = await parseErrorBody(res);
49
+ throw new ApiError(res.status, err.detail, err.code);
50
+ }
51
+ if (res.status === 204)
52
+ return undefined;
53
+ return res.json();
54
+ }
55
+ export async function apiNoAuth(path, options = {}) {
56
+ return api(path, { ...options, token: "" });
57
+ }
58
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEpB;IACA;IACA;IAHX,YACW,MAAc,EACd,MAAc,EACd,IAAa;QAEpB,KAAK,CAAC,GAAG,MAAM,KAAK,MAAM,EAAE,CAAC,CAAC;QAJvB,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ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G,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;QACpC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;QAC/B,OAAO;QACP,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KAChE,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACV,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,SAAc,CAAC;IAE9C,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAC;AACpC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC3B,IAAY,EACZ,UAII,EAAE;IAEN,OAAO,GAAG,CAAI,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare const agentCommand: Command;
3
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/commands/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBpC,eAAO,MAAM,YAAY,SAAoD,CAAC"}