@1claw/sdk 0.2.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 (87) hide show
  1. package/LICENSE +133 -0
  2. package/README.md +246 -0
  3. package/dist/access.d.ts +35 -0
  4. package/dist/access.d.ts.map +1 -0
  5. package/dist/access.js +52 -0
  6. package/dist/access.js.map +1 -0
  7. package/dist/agents.d.ts +41 -0
  8. package/dist/agents.d.ts.map +1 -0
  9. package/dist/agents.js +61 -0
  10. package/dist/agents.js.map +1 -0
  11. package/dist/api-keys.d.ts +20 -0
  12. package/dist/api-keys.d.ts.map +1 -0
  13. package/dist/api-keys.js +25 -0
  14. package/dist/api-keys.js.map +1 -0
  15. package/dist/approvals.d.ts +45 -0
  16. package/dist/approvals.d.ts.map +1 -0
  17. package/dist/approvals.js +76 -0
  18. package/dist/approvals.js.map +1 -0
  19. package/dist/audit.d.ts +23 -0
  20. package/dist/audit.d.ts.map +1 -0
  21. package/dist/audit.js +41 -0
  22. package/dist/audit.js.map +1 -0
  23. package/dist/auth.d.ts +42 -0
  24. package/dist/auth.d.ts.map +1 -0
  25. package/dist/auth.js +79 -0
  26. package/dist/auth.js.map +1 -0
  27. package/dist/billing.d.ts +17 -0
  28. package/dist/billing.d.ts.map +1 -0
  29. package/dist/billing.js +22 -0
  30. package/dist/billing.js.map +1 -0
  31. package/dist/chains.d.ts +25 -0
  32. package/dist/chains.d.ts.map +1 -0
  33. package/dist/chains.js +39 -0
  34. package/dist/chains.js.map +1 -0
  35. package/dist/client.d.ts +99 -0
  36. package/dist/client.d.ts.map +1 -0
  37. package/dist/client.js +116 -0
  38. package/dist/client.js.map +1 -0
  39. package/dist/errors.d.ts +56 -0
  40. package/dist/errors.d.ts.map +1 -0
  41. package/dist/errors.js +115 -0
  42. package/dist/errors.js.map +1 -0
  43. package/dist/http.d.ts +42 -0
  44. package/dist/http.d.ts.map +1 -0
  45. package/dist/http.js +145 -0
  46. package/dist/http.js.map +1 -0
  47. package/dist/index.d.ts +17 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +19 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/mcp/handler.d.ts +40 -0
  52. package/dist/mcp/handler.d.ts.map +1 -0
  53. package/dist/mcp/handler.js +216 -0
  54. package/dist/mcp/handler.js.map +1 -0
  55. package/dist/mcp/index.d.ts +3 -0
  56. package/dist/mcp/index.d.ts.map +1 -0
  57. package/dist/mcp/index.js +3 -0
  58. package/dist/mcp/index.js.map +1 -0
  59. package/dist/mcp/tools.d.ts +29 -0
  60. package/dist/mcp/tools.d.ts.map +1 -0
  61. package/dist/mcp/tools.js +236 -0
  62. package/dist/mcp/tools.js.map +1 -0
  63. package/dist/org.d.ts +16 -0
  64. package/dist/org.d.ts.map +1 -0
  65. package/dist/org.js +21 -0
  66. package/dist/org.js.map +1 -0
  67. package/dist/secrets.d.ts +42 -0
  68. package/dist/secrets.d.ts.map +1 -0
  69. package/dist/secrets.js +48 -0
  70. package/dist/secrets.js.map +1 -0
  71. package/dist/sharing.d.ts +59 -0
  72. package/dist/sharing.d.ts.map +1 -0
  73. package/dist/sharing.js +69 -0
  74. package/dist/sharing.js.map +1 -0
  75. package/dist/types.d.ts +446 -0
  76. package/dist/types.d.ts.map +1 -0
  77. package/dist/types.js +5 -0
  78. package/dist/types.js.map +1 -0
  79. package/dist/vault.d.ts +18 -0
  80. package/dist/vault.d.ts.map +1 -0
  81. package/dist/vault.js +30 -0
  82. package/dist/vault.js.map +1 -0
  83. package/dist/x402.d.ts +40 -0
  84. package/dist/x402.d.ts.map +1 -0
  85. package/dist/x402.js +129 -0
  86. package/dist/x402.js.map +1 -0
  87. package/package.json +47 -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,246 @@
1
+ # @1claw/sdk
2
+
3
+ TypeScript SDK for **1Claw Vault** — HSM-backed secret management for AI agents and humans.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @1claw/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { createClient } from "@1claw/sdk";
15
+
16
+ const client = createClient({
17
+ baseUrl: "https://api.1claw.xyz",
18
+ apiKey: "ocv_...", // auto-exchanges for a JWT
19
+ });
20
+
21
+ // List vaults
22
+ const { data } = await client.vault.list();
23
+ console.log(data?.vaults);
24
+
25
+ // Store a secret
26
+ await client.secrets.set("vault-id", "OPENAI_KEY", "sk-...", {
27
+ type: "api_key",
28
+ });
29
+
30
+ // Retrieve a secret
31
+ const secret = await client.secrets.get("vault-id", "OPENAI_KEY");
32
+ console.log(secret.data?.value);
33
+ ```
34
+
35
+ ## Authentication
36
+
37
+ The SDK supports three authentication modes:
38
+
39
+ ```typescript
40
+ // 1. User API key (auto-authenticates)
41
+ const client = createClient({
42
+ baseUrl: "https://api.1claw.xyz",
43
+ apiKey: "ocv_...",
44
+ });
45
+
46
+ // 2. Agent with API key (auto-authenticates as agent)
47
+ const agent = createClient({
48
+ baseUrl: "https://api.1claw.xyz",
49
+ apiKey: "ocv_...",
50
+ agentId: "agent-uuid",
51
+ });
52
+
53
+ // 3. Pre-authenticated JWT
54
+ const authed = createClient({
55
+ baseUrl: "https://api.1claw.xyz",
56
+ token: "eyJ...",
57
+ });
58
+
59
+ // Or authenticate manually:
60
+ await client.auth.login({ email: "...", password: "..." });
61
+ await client.auth.agentToken({ agent_id: "...", api_key: "..." });
62
+ await client.auth.google({ id_token: "..." });
63
+ ```
64
+
65
+ ## API Resources
66
+
67
+ | Resource | Methods |
68
+ | ------------------ | ---------------------------------------------------------------------------------------------------------- |
69
+ | `client.vault` | `create`, `get`, `list`, `delete` |
70
+ | `client.secrets` | `set`, `get`, `delete`, `list`, `rotate` |
71
+ | `client.access` | `grantHuman`, `grantAgent`, `update`, `revoke`, `listGrants` |
72
+ | `client.agents` | `create`, `get`, `list`, `update`, `delete`, `rotateKey`, `submitTransaction`, `getTransaction`, `listTransactions` |
73
+ | `client.chains` | `list`, `get`, `adminList`, `create`, `update`, `delete` |
74
+ | `client.sharing` | `create`, `access`, `listOutbound`, `listInbound`, `accept`, `decline`, `revoke` |
75
+ | `client.approvals` | `request`, `list`, `approve`, `deny`, `check`, `subscribe` |
76
+ | `client.billing` | `usage`, `history` |
77
+ | `client.audit` | `query` |
78
+ | `client.org` | `listMembers`, `updateMemberRole`, `removeMember` |
79
+ | `client.auth` | `login`, `agentToken`, `apiKeyToken`, `google`, `changePassword`, `logout` |
80
+ | `client.apiKeys` | `create`, `list`, `revoke` |
81
+ | `client.x402` | `getPaymentRequirement`, `pay`, `verifyReceipt`, `withPayment` |
82
+
83
+ ## Response Envelope
84
+
85
+ All methods return a typed envelope:
86
+
87
+ ```typescript
88
+ interface OneclawResponse<T> {
89
+ data: T | null;
90
+ error: { type: string; message: string; detail?: string } | null;
91
+ meta?: { status: number };
92
+ }
93
+ ```
94
+
95
+ Check `error` before accessing `data`:
96
+
97
+ ```typescript
98
+ const res = await client.secrets.get("vault-id", "key");
99
+ if (res.error) {
100
+ console.error(res.error.type, res.error.message);
101
+ } else {
102
+ console.log(res.data.value);
103
+ }
104
+ ```
105
+
106
+ ## Error Types
107
+
108
+ The SDK exports a typed error hierarchy for catch-based flows:
109
+
110
+ | Error | HTTP Status | Description |
111
+ | ----------------------- | ----------- | ----------------------------------------------------- |
112
+ | `OneclawError` | any | Base error class |
113
+ | `AuthError` | 401, 403 | Authentication/authorization failure |
114
+ | `PaymentRequiredError` | 402 | x402 payment required (includes `paymentRequirement`) |
115
+ | `ApprovalRequiredError` | 403 | Human approval gate triggered |
116
+ | `NotFoundError` | 404 | Resource not found |
117
+ | `RateLimitError` | 429 | Rate limit exceeded |
118
+ | `ValidationError` | 400 | Invalid request body |
119
+ | `ServerError` | 500+ | Server-side failure |
120
+
121
+ ## Crypto Transaction Proxy
122
+
123
+ Agents can be granted the ability to sign and broadcast on-chain transactions through a controlled signing proxy. Private keys stay in the HSM — the agent submits intent, the proxy signs and broadcasts.
124
+
125
+ Toggle `crypto_proxy_enabled` when creating or updating an agent:
126
+
127
+ ```typescript
128
+ // Register an agent with crypto proxy access
129
+ const { data } = await client.agents.create({
130
+ name: "defi-bot",
131
+ auth_method: "api_key",
132
+ scopes: ["vault:read", "tx:sign"],
133
+ crypto_proxy_enabled: true,
134
+ });
135
+
136
+ // Or enable it later
137
+ await client.agents.update(agentId, {
138
+ crypto_proxy_enabled: true,
139
+ });
140
+
141
+ // Check an agent's proxy status
142
+ const agent = await client.agents.get(agentId);
143
+ console.log(agent.data?.crypto_proxy_enabled); // true
144
+ ```
145
+
146
+ ### Submitting a transaction
147
+
148
+ Once `crypto_proxy_enabled` is true and the agent has a signing key stored in an accessible vault, the agent can submit transaction intents:
149
+
150
+ ```typescript
151
+ const txRes = await client.agents.submitTransaction(agentId, {
152
+ to: "0x000000000000000000000000000000000000dEaD",
153
+ value: "0.01", // ETH
154
+ chain: "base",
155
+ // Optional: data, signing_key_path, nonce, gas_price, gas_limit
156
+ });
157
+
158
+ console.log(txRes.data?.status); // "signed"
159
+ console.log(txRes.data?.tx_hash); // "0x..."
160
+ console.log(txRes.data?.signed_tx); // signed raw transaction hex
161
+ ```
162
+
163
+ The backend fetches the signing key from the vault, signs the EIP-155 transaction, and returns the signed transaction hex. The signing key is decrypted in-memory, used, and immediately zeroized — it never leaves the server.
164
+
165
+ Key properties:
166
+
167
+ - **Disabled by default** — a human must explicitly enable per-agent
168
+ - **Signing keys never leave the HSM** — same envelope encryption as secrets
169
+ - **Every transaction is audit-logged** with full calldata
170
+ - **Revocable instantly** — set `crypto_proxy_enabled: false` to cut off access
171
+
172
+ ## x402 Payment Protocol
173
+
174
+ When free-tier limits are exceeded, the API returns `402 Payment Required`. The SDK can automatically handle payments if you provide a signer:
175
+
176
+ ```typescript
177
+ import { createClient, type X402Signer } from "@1claw/sdk";
178
+
179
+ const signer: X402Signer = {
180
+ getAddress: async () => "0x...",
181
+ signPayment: async (accept) => {
182
+ // Sign EIP-712 payment with your wallet library (ethers, viem, etc.)
183
+ return signedPayloadHex;
184
+ },
185
+ };
186
+
187
+ const client = createClient({
188
+ baseUrl: "https://api.1claw.xyz",
189
+ apiKey: "ocv_...",
190
+ x402Signer: signer,
191
+ maxAutoPayUsd: 0.01, // auto-pay up to $0.01 per request
192
+ });
193
+
194
+ // Or use the explicit pay-and-fetch flow:
195
+ const secret = await client.x402.withPayment("vault-id", "key", signer);
196
+ ```
197
+
198
+ ## MCP Integration (AI Agents)
199
+
200
+ The SDK exposes MCP-compatible tool definitions for AI agents:
201
+
202
+ ```typescript
203
+ import { getMcpToolDefinitions, McpHandler } from "@1claw/sdk/mcp";
204
+ import { createClient } from "@1claw/sdk";
205
+
206
+ // Get tool definitions for your agent's tool registry
207
+ const tools = getMcpToolDefinitions();
208
+ // → 1claw_get_secret, 1claw_set_secret, 1claw_list_secret_keys, etc.
209
+
210
+ // Dispatch tool calls from your agent
211
+ const client = createClient({ baseUrl: "...", token: "..." });
212
+ const handler = new McpHandler(client);
213
+ const result = await handler.handle("1claw_get_secret", {
214
+ vault_id: "...",
215
+ key: "OPENAI_KEY",
216
+ });
217
+ ```
218
+
219
+ ### With Vercel AI SDK
220
+
221
+ ```typescript
222
+ import { tool } from "ai";
223
+ import { z } from "zod";
224
+ import { createClient } from "@1claw/sdk";
225
+
226
+ const client = createClient({ baseUrl: "...", apiKey: "..." });
227
+
228
+ export const oneclawTools = {
229
+ getSecret: tool({
230
+ description: "Fetch a secret from the 1claw vault",
231
+ parameters: z.object({
232
+ vaultId: z.string(),
233
+ key: z.string(),
234
+ }),
235
+ execute: async ({ vaultId, key }) => {
236
+ const res = await client.secrets.get(vaultId, key);
237
+ if (res.error) return { error: res.error.message };
238
+ return { status: "available", hint: `Secret retrieved (${key})` };
239
+ },
240
+ }),
241
+ };
242
+ ```
243
+
244
+ ## License
245
+
246
+ PolyForm Noncommercial 1.0.0
@@ -0,0 +1,35 @@
1
+ import type { HttpClient } from "./http";
2
+ import type { UpdatePolicyRequest, PolicyResponse, PolicyListResponse, OneclawResponse } from "./types";
3
+ export interface GrantOptions {
4
+ /** Glob pattern for which secret paths the grant covers (default: "**"). */
5
+ secretPathPattern?: string;
6
+ /** Additional conditions (e.g. IP allow-list, time windows). */
7
+ conditions?: Record<string, unknown>;
8
+ /** ISO-8601 expiry for the grant. */
9
+ expires_at?: string;
10
+ }
11
+ /**
12
+ * Access resource — manage vault access policies (grants) for
13
+ * humans and agents.
14
+ */
15
+ export declare class AccessResource {
16
+ private readonly http;
17
+ constructor(http: HttpClient);
18
+ /**
19
+ * Grant a human user access to a vault.
20
+ * @param permissions - e.g. ["read"], ["read", "write"]
21
+ */
22
+ grantHuman(vaultId: string, userId: string, permissions: string[], options?: GrantOptions): Promise<OneclawResponse<PolicyResponse>>;
23
+ /**
24
+ * Grant an agent access to a vault.
25
+ * @param permissions - e.g. ["read"], ["read", "write"]
26
+ */
27
+ grantAgent(vaultId: string, agentId: string, permissions: string[], options?: GrantOptions): Promise<OneclawResponse<PolicyResponse>>;
28
+ /** Update an existing policy's permissions and/or conditions. */
29
+ update(vaultId: string, policyId: string, update: UpdatePolicyRequest): Promise<OneclawResponse<PolicyResponse>>;
30
+ /** Revoke a specific access policy by its ID. */
31
+ revoke(vaultId: string, policyId: string): Promise<OneclawResponse<void>>;
32
+ /** List all access grants (policies) on a vault. */
33
+ listGrants(vaultId: string): Promise<OneclawResponse<PolicyListResponse>>;
34
+ }
35
+ //# sourceMappingURL=access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAER,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,YAAY;IACzB,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,cAAc;IACX,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACG,UAAU,CACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,GAAE,YAAiB,GAC3B,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAgB3C;;;OAGG;IACG,UAAU,CACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,GAAE,YAAiB,GAC3B,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAgB3C,iEAAiE;IAC3D,MAAM,CACR,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,mBAAmB,GAC5B,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAQ3C,iDAAiD;IAC3C,MAAM,CACR,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAOjC,oDAAoD;IAC9C,UAAU,CACZ,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAMlD"}
package/dist/access.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Access resource — manage vault access policies (grants) for
3
+ * humans and agents.
4
+ */
5
+ export class AccessResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ /**
10
+ * Grant a human user access to a vault.
11
+ * @param permissions - e.g. ["read"], ["read", "write"]
12
+ */
13
+ async grantHuman(vaultId, userId, permissions, options = {}) {
14
+ const body = {
15
+ secret_path_pattern: options.secretPathPattern ?? "**",
16
+ principal_type: "user",
17
+ principal_id: userId,
18
+ permissions,
19
+ conditions: options.conditions,
20
+ expires_at: options.expires_at,
21
+ };
22
+ return this.http.request("POST", `/v1/vaults/${vaultId}/policies`, { body });
23
+ }
24
+ /**
25
+ * Grant an agent access to a vault.
26
+ * @param permissions - e.g. ["read"], ["read", "write"]
27
+ */
28
+ async grantAgent(vaultId, agentId, permissions, options = {}) {
29
+ const body = {
30
+ secret_path_pattern: options.secretPathPattern ?? "**",
31
+ principal_type: "agent",
32
+ principal_id: agentId,
33
+ permissions,
34
+ conditions: options.conditions,
35
+ expires_at: options.expires_at,
36
+ };
37
+ return this.http.request("POST", `/v1/vaults/${vaultId}/policies`, { body });
38
+ }
39
+ /** Update an existing policy's permissions and/or conditions. */
40
+ async update(vaultId, policyId, update) {
41
+ return this.http.request("PUT", `/v1/vaults/${vaultId}/policies/${policyId}`, { body: update });
42
+ }
43
+ /** Revoke a specific access policy by its ID. */
44
+ async revoke(vaultId, policyId) {
45
+ return this.http.request("DELETE", `/v1/vaults/${vaultId}/policies/${policyId}`);
46
+ }
47
+ /** List all access grants (policies) on a vault. */
48
+ async listGrants(vaultId) {
49
+ return this.http.request("GET", `/v1/vaults/${vaultId}/policies`);
50
+ }
51
+ }
52
+ //# sourceMappingURL=access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.js","sourceRoot":"","sources":["../src/access.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,MAAM,OAAO,cAAc;IACvB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,UAAU,CACZ,OAAe,EACf,MAAc,EACd,WAAqB,EACrB,UAAwB,EAAE;QAE1B,MAAM,IAAI,GAAwB;YAC9B,mBAAmB,EAAE,OAAO,CAAC,iBAAiB,IAAI,IAAI;YACtD,cAAc,EAAE,MAAM;YACtB,YAAY,EAAE,MAAM;YACpB,WAAW;YACX,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,UAAU,EAAE,OAAO,CAAC,UAAU;SACjC,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,MAAM,EACN,cAAc,OAAO,WAAW,EAChC,EAAE,IAAI,EAAE,CACX,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CACZ,OAAe,EACf,OAAe,EACf,WAAqB,EACrB,UAAwB,EAAE;QAE1B,MAAM,IAAI,GAAwB;YAC9B,mBAAmB,EAAE,OAAO,CAAC,iBAAiB,IAAI,IAAI;YACtD,cAAc,EAAE,OAAO;YACvB,YAAY,EAAE,OAAO;YACrB,WAAW;YACX,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,UAAU,EAAE,OAAO,CAAC,UAAU;SACjC,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,MAAM,EACN,cAAc,OAAO,WAAW,EAChC,EAAE,IAAI,EAAE,CACX,CAAC;IACN,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,MAAM,CACR,OAAe,EACf,QAAgB,EAChB,MAA2B;QAE3B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,cAAc,OAAO,aAAa,QAAQ,EAAE,EAC5C,EAAE,IAAI,EAAE,MAAM,EAAE,CACnB,CAAC;IACN,CAAC;IAED,iDAAiD;IACjD,KAAK,CAAC,MAAM,CACR,OAAe,EACf,QAAgB;QAEhB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,QAAQ,EACR,cAAc,OAAO,aAAa,QAAQ,EAAE,CAC/C,CAAC;IACN,CAAC;IAED,oDAAoD;IACpD,KAAK,CAAC,UAAU,CACZ,OAAe;QAEf,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,cAAc,OAAO,WAAW,CACnC,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,41 @@
1
+ import type { HttpClient } from "./http";
2
+ import type { CreateAgentRequest, UpdateAgentRequest, AgentResponse, AgentCreatedResponse, AgentListResponse, AgentKeyRotatedResponse, SubmitTransactionRequest, TransactionResponse, TransactionListResponse, OneclawResponse } from "./types";
3
+ /**
4
+ * Agents resource — register, manage, and rotate keys for AI agents
5
+ * that interact with the vault programmatically.
6
+ */
7
+ export declare class AgentsResource {
8
+ private readonly http;
9
+ constructor(http: HttpClient);
10
+ /**
11
+ * Register a new agent. Returns the agent record and a one-time API key.
12
+ * Store the API key securely — it cannot be retrieved again.
13
+ */
14
+ create(options: CreateAgentRequest): Promise<OneclawResponse<AgentCreatedResponse>>;
15
+ /** Fetch a single agent by ID. */
16
+ get(agentId: string): Promise<OneclawResponse<AgentResponse>>;
17
+ /** List all agents in the current organization. */
18
+ list(): Promise<OneclawResponse<AgentListResponse>>;
19
+ /** Update agent name, scopes, active status, expiry, or crypto proxy setting. */
20
+ update(agentId: string, update: UpdateAgentRequest): Promise<OneclawResponse<AgentResponse>>;
21
+ /** Delete an agent permanently. */
22
+ delete(agentId: string): Promise<OneclawResponse<void>>;
23
+ /**
24
+ * Rotate an agent's API key. Returns the new key — store it securely.
25
+ * The old key is immediately invalidated.
26
+ */
27
+ rotateKey(agentId: string): Promise<OneclawResponse<AgentKeyRotatedResponse>>;
28
+ /**
29
+ * Submit a transaction intent to be signed by the crypto proxy.
30
+ * The agent must have `crypto_proxy_enabled: true` and a valid
31
+ * signing key stored in an accessible vault.
32
+ *
33
+ * Returns the signed transaction hex and keccak tx hash.
34
+ */
35
+ submitTransaction(agentId: string, tx: SubmitTransactionRequest): Promise<OneclawResponse<TransactionResponse>>;
36
+ /** Fetch a single transaction by ID. */
37
+ getTransaction(agentId: string, txId: string): Promise<OneclawResponse<TransactionResponse>>;
38
+ /** List recent transactions for an agent. */
39
+ listTransactions(agentId: string): Promise<OneclawResponse<TransactionListResponse>>;
40
+ }
41
+ //# sourceMappingURL=agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EACR,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,cAAc;IACX,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACG,MAAM,CACR,OAAO,EAAE,kBAAkB,GAC5B,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAMjD,kCAAkC;IAC5B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAInE,mDAAmD;IAC7C,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAIzD,iFAAiF;IAC3E,MAAM,CACR,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,GAC3B,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAQ1C,mCAAmC;IAC7B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAI7D;;;OAGG;IACG,SAAS,CACX,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;IASpD;;;;;;OAMG;IACG,iBAAiB,CACnB,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,wBAAwB,GAC7B,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAQhD,wCAAwC;IAClC,cAAc,CAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAOhD,6CAA6C;IACvC,gBAAgB,CAClB,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC;CAMvD"}
package/dist/agents.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Agents resource — register, manage, and rotate keys for AI agents
3
+ * that interact with the vault programmatically.
4
+ */
5
+ export class AgentsResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ /**
10
+ * Register a new agent. Returns the agent record and a one-time API key.
11
+ * Store the API key securely — it cannot be retrieved again.
12
+ */
13
+ async create(options) {
14
+ return this.http.request("POST", "/v1/agents", {
15
+ body: options,
16
+ });
17
+ }
18
+ /** Fetch a single agent by ID. */
19
+ async get(agentId) {
20
+ return this.http.request("GET", `/v1/agents/${agentId}`);
21
+ }
22
+ /** List all agents in the current organization. */
23
+ async list() {
24
+ return this.http.request("GET", "/v1/agents");
25
+ }
26
+ /** Update agent name, scopes, active status, expiry, or crypto proxy setting. */
27
+ async update(agentId, update) {
28
+ return this.http.request("PATCH", `/v1/agents/${agentId}`, { body: update });
29
+ }
30
+ /** Delete an agent permanently. */
31
+ async delete(agentId) {
32
+ return this.http.request("DELETE", `/v1/agents/${agentId}`);
33
+ }
34
+ /**
35
+ * Rotate an agent's API key. Returns the new key — store it securely.
36
+ * The old key is immediately invalidated.
37
+ */
38
+ async rotateKey(agentId) {
39
+ return this.http.request("POST", `/v1/agents/${agentId}/rotate-key`);
40
+ }
41
+ // ── Crypto Transaction Proxy ───────────────────────────────────────
42
+ /**
43
+ * Submit a transaction intent to be signed by the crypto proxy.
44
+ * The agent must have `crypto_proxy_enabled: true` and a valid
45
+ * signing key stored in an accessible vault.
46
+ *
47
+ * Returns the signed transaction hex and keccak tx hash.
48
+ */
49
+ async submitTransaction(agentId, tx) {
50
+ return this.http.request("POST", `/v1/agents/${agentId}/transactions`, { body: tx });
51
+ }
52
+ /** Fetch a single transaction by ID. */
53
+ async getTransaction(agentId, txId) {
54
+ return this.http.request("GET", `/v1/agents/${agentId}/transactions/${txId}`);
55
+ }
56
+ /** List recent transactions for an agent. */
57
+ async listTransactions(agentId) {
58
+ return this.http.request("GET", `/v1/agents/${agentId}/transactions`);
59
+ }
60
+ }
61
+ //# sourceMappingURL=agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,OAAO,cAAc;IACvB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,MAAM,CACR,OAA2B;QAE3B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAuB,MAAM,EAAE,YAAY,EAAE;YACjE,IAAI,EAAE,OAAO;SAChB,CAAC,CAAC;IACP,CAAC;IAED,kCAAkC;IAClC,KAAK,CAAC,GAAG,CAAC,OAAe;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAgB,KAAK,EAAE,cAAc,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB,KAAK,EAAE,YAAY,CAAC,CAAC;IACrE,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,MAAM,CACR,OAAe,EACf,MAA0B;QAE1B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,OAAO,EACP,cAAc,OAAO,EAAE,EACvB,EAAE,IAAI,EAAE,MAAM,EAAE,CACnB,CAAC;IACN,CAAC;IAED,mCAAmC;IACnC,KAAK,CAAC,MAAM,CAAC,OAAe;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,cAAc,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS,CACX,OAAe;QAEf,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,MAAM,EACN,cAAc,OAAO,aAAa,CACrC,CAAC;IACN,CAAC;IAED,sEAAsE;IAEtE;;;;;;OAMG;IACH,KAAK,CAAC,iBAAiB,CACnB,OAAe,EACf,EAA4B;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,MAAM,EACN,cAAc,OAAO,eAAe,EACpC,EAAE,IAAI,EAAE,EAAE,EAAE,CACf,CAAC;IACN,CAAC;IAED,wCAAwC;IACxC,KAAK,CAAC,cAAc,CAChB,OAAe,EACf,IAAY;QAEZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,cAAc,OAAO,iBAAiB,IAAI,EAAE,CAC/C,CAAC;IACN,CAAC;IAED,6CAA6C;IAC7C,KAAK,CAAC,gBAAgB,CAClB,OAAe;QAEf,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,cAAc,OAAO,eAAe,CACvC,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,20 @@
1
+ import type { HttpClient } from "./http";
2
+ import type { CreateApiKeyRequest, ApiKeyCreatedResponse, ApiKeyListResponse, OneclawResponse } from "./types";
3
+ /**
4
+ * ApiKeys resource — create, list, and revoke personal API keys
5
+ * for human users.
6
+ */
7
+ export declare class ApiKeysResource {
8
+ private readonly http;
9
+ constructor(http: HttpClient);
10
+ /**
11
+ * Create a new API key. Returns the full key string once — store it
12
+ * securely as it cannot be retrieved again.
13
+ */
14
+ create(options: CreateApiKeyRequest): Promise<OneclawResponse<ApiKeyCreatedResponse>>;
15
+ /** List all API keys for the current user (keys are masked). */
16
+ list(): Promise<OneclawResponse<ApiKeyListResponse>>;
17
+ /** Revoke (deactivate) an API key by its ID. */
18
+ revoke(keyId: string): Promise<OneclawResponse<void>>;
19
+ }
20
+ //# sourceMappingURL=api-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EACR,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,eAAe;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACG,MAAM,CACR,OAAO,EAAE,mBAAmB,GAC7B,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAQlD,gEAAgE;IAC1D,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAO1D,gDAAgD;IAC1C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;CAG9D"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * ApiKeys resource — create, list, and revoke personal API keys
3
+ * for human users.
4
+ */
5
+ export class ApiKeysResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ /**
10
+ * Create a new API key. Returns the full key string once — store it
11
+ * securely as it cannot be retrieved again.
12
+ */
13
+ async create(options) {
14
+ return this.http.request("POST", "/v1/auth/api-keys", { body: options });
15
+ }
16
+ /** List all API keys for the current user (keys are masked). */
17
+ async list() {
18
+ return this.http.request("GET", "/v1/auth/api-keys");
19
+ }
20
+ /** Revoke (deactivate) an API key by its ID. */
21
+ async revoke(keyId) {
22
+ return this.http.request("DELETE", `/v1/auth/api-keys/${keyId}`);
23
+ }
24
+ }
25
+ //# sourceMappingURL=api-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,OAAO,eAAe;IACxB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,MAAM,CACR,OAA4B;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,MAAM,EACN,mBAAmB,EACnB,EAAE,IAAI,EAAE,OAAO,EAAE,CACpB,CAAC;IACN,CAAC;IAED,gEAAgE;IAChE,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,mBAAmB,CACtB,CAAC;IACN,CAAC;IAED,gDAAgD;IAChD,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,qBAAqB,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;CACJ"}