@1claw/sdk 0.15.2 → 0.16.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 CHANGED
@@ -73,11 +73,11 @@ await client.auth.google({ id_token: "..." });
73
73
  | `client.vault` | `create`, `get`, `list`, `delete` |
74
74
  | `client.secrets` | `set`, `get`, `delete`, `list`, `rotate` |
75
75
  | `client.access` | `grantHuman`, `grantAgent`, `update`, `revoke`, `listGrants` |
76
- | `client.agents` | `create`, `getSelf`, `get`, `list`, `update`, `delete`, `rotateKey`, `submitTransaction`, `getTransaction`, `listTransactions`, `simulateTransaction`, `simulateBundle` |
76
+ | `client.agents` | `create`, `getSelf`, `get`, `list`, `update`, `delete`, `rotateKey`, `submitTransaction`, `signTransaction`, `getTransaction`, `listTransactions`, `simulateTransaction`, `simulateBundle` |
77
77
  | `client.chains` | `list`, `get`, `adminList`, `create`, `update`, `delete` |
78
78
  | `client.sharing` | `create`, `access`, `listOutbound`, `listInbound`, `accept`, `decline`, `revoke` |
79
79
  | `client.approvals` | `request`, `list`, `approve`, `deny`, `check`, `subscribe` |
80
- | `client.billing` | `usage`, `history` |
80
+ | `client.billing` | `usage`, `history`, `llmTokenBilling`, `subscribeLlmTokenBilling`, `disableLlmTokenBilling` (LLM token billing / Stripe AI Gateway) |
81
81
  | `client.audit` | `query` |
82
82
  | `client.org` | `listMembers`, `getAgentKeysVault`, `updateMemberRole`, `removeMember` |
83
83
  | `client.auth` | `login`, `signup`, `agentToken`, `apiKeyToken`, `google`, `changePassword`, `logout`, `getMe`, `updateMe`, `deleteMe` |
@@ -191,6 +191,26 @@ The backend fetches the signing key from the vault, signs the EIP-155 transactio
191
191
 
192
192
  The SDK automatically generates an `Idempotency-Key` header (UUID v4) on each `submitTransaction` call, providing replay protection. Duplicate requests within 24 hours return the cached response instead of re-signing.
193
193
 
194
+ ### Sign-only mode (BYORPC)
195
+
196
+ Use `signTransaction` when you want the server to sign but **not** broadcast — for example, to submit via your own RPC (Flashbots, MEV protection, custom relayers):
197
+
198
+ ```typescript
199
+ const signRes = await client.agents.signTransaction(agentId, {
200
+ to: "0x000000000000000000000000000000000000dEaD",
201
+ value: "0.01",
202
+ chain: "base",
203
+ });
204
+
205
+ console.log(signRes.data?.signed_tx); // raw signed tx hex
206
+ console.log(signRes.data?.tx_hash); // precomputed keccak hash
207
+ console.log(signRes.data?.from); // derived sender address
208
+
209
+ // Broadcast yourself via ethers, viem, or raw JSON-RPC
210
+ ```
211
+
212
+ All agent guardrails (allowlists, value caps, daily limits) are enforced exactly as for submit. The transaction is recorded for audit and daily-limit tracking with `status: "sign_only"`.
213
+
194
214
  Key properties:
195
215
 
196
216
  - **Disabled by default** — a human must explicitly enable per-agent
@@ -318,6 +338,11 @@ const { data } = await client.agents.create({
318
338
  pii_policy: "redact", // block | redact | warn | allow
319
339
  injection_threshold: 0.7,
320
340
 
341
+ // Model restrictions
342
+ allowed_models: ["gpt-4o-mini", "claude-sonnet-4"], // Whitelist specific models
343
+ denied_models: ["gpt-3.5-turbo"], // Blacklist models
344
+ allowed_providers: ["openai", "anthropic"], // Restrict providers
345
+
321
346
  // Threat detection
322
347
  unicode_normalization: {
323
348
  enabled: true,
@@ -351,10 +376,41 @@ await client.agents.update(agentId, {
351
376
  shroud_config: {
352
377
  command_injection_detection: { enabled: true, action: "block" },
353
378
  social_engineering_detection: { enabled: true, action: "block" },
379
+ allowed_models: ["gpt-4o-mini"], // Restrict to cost-effective models
354
380
  },
355
381
  });
356
382
  ```
357
383
 
384
+ ### Specifying Models in Requests
385
+
386
+ When making LLM requests to Shroud, specify the model in one of two ways:
387
+
388
+ **Option 1: Header**
389
+ ```typescript
390
+ const res = await fetch("https://shroud.1claw.xyz/v1/chat/completions", {
391
+ method: "POST",
392
+ headers: {
393
+ "X-Shroud-Agent-Key": `${agentId}:${agentApiKey}`,
394
+ "X-Shroud-Provider": "openai",
395
+ "X-Shroud-Model": "gpt-4o-mini", // ← Model in header
396
+ "Content-Type": "application/json",
397
+ },
398
+ body: JSON.stringify({
399
+ messages: [{ role: "user", content: "Hello" }],
400
+ }),
401
+ });
402
+ ```
403
+
404
+ **Option 2: Request Body** (for OpenAI-style providers)
405
+ ```typescript
406
+ body: JSON.stringify({
407
+ model: "gpt-4o-mini", // ← Model in body
408
+ messages: [{ role: "user", content: "Hello" }],
409
+ })
410
+ ```
411
+
412
+ Shroud enforces the agent's `allowed_models` and `denied_models` restrictions automatically — requests using unauthorized models return **403 Forbidden**.
413
+
358
414
  See the [Shroud Security Guide](https://docs.1claw.xyz/docs/guides/shroud) for full configuration options.
359
415
 
360
416
  ## OpenAPI Types
@@ -369,7 +425,7 @@ type Vault = ApiSchemas["VaultResponse"];
369
425
  type Agent = ApiSchemas["AgentResponse"];
370
426
  ```
371
427
 
372
- Regenerate types after spec changes: `npm run generate`
428
+ Regenerate types after spec changes (from the monorepo): `cd packages/sdk && npm run generate` — reads [`../openapi-spec/openapi.yaml`](../openapi-spec/openapi.yaml) via `openapi-typescript`.
373
429
 
374
430
  ## MCP Integration (AI Agents)
375
431
 
@@ -735,6 +735,32 @@ export interface paths {
735
735
  patch?: never;
736
736
  trace?: never;
737
737
  };
738
+ "/v1/agents/{agent_id}/transactions/sign": {
739
+ parameters: {
740
+ query?: never;
741
+ header?: never;
742
+ path?: never;
743
+ cookie?: never;
744
+ };
745
+ get?: never;
746
+ put?: never;
747
+ /**
748
+ * Sign a transaction without broadcasting
749
+ * @description Signs a transaction inside the server (or TEE when using Shroud) but does
750
+ * **not** broadcast it. The caller receives the raw `signed_tx` hex and
751
+ * `tx_hash` so it can submit to any RPC of its choosing.
752
+ *
753
+ * All agent guardrails (allowlists, value caps, daily limits) are enforced
754
+ * exactly as for the submit endpoint. The signed transaction is recorded for
755
+ * audit and daily-limit tracking with `status: "sign_only"`.
756
+ */
757
+ post: operations["signTransaction"];
758
+ delete?: never;
759
+ options?: never;
760
+ head?: never;
761
+ patch?: never;
762
+ trace?: never;
763
+ };
738
764
  "/v1/agents/{agent_id}/transactions/simulate": {
739
765
  parameters: {
740
766
  query?: never;
@@ -1150,6 +1176,66 @@ export interface paths {
1150
1176
  patch?: never;
1151
1177
  trace?: never;
1152
1178
  };
1179
+ "/v1/billing/llm-token-billing": {
1180
+ parameters: {
1181
+ query?: never;
1182
+ header?: never;
1183
+ path?: never;
1184
+ cookie?: never;
1185
+ };
1186
+ /**
1187
+ * Get LLM token billing status
1188
+ * @description Returns whether LLM token billing is enabled for the caller's org.
1189
+ */
1190
+ get: operations["getLlmTokenBilling"];
1191
+ put?: never;
1192
+ post?: never;
1193
+ delete?: never;
1194
+ options?: never;
1195
+ head?: never;
1196
+ patch?: never;
1197
+ trace?: never;
1198
+ };
1199
+ "/v1/billing/llm-token-billing/subscribe": {
1200
+ parameters: {
1201
+ query?: never;
1202
+ header?: never;
1203
+ path?: never;
1204
+ cookie?: never;
1205
+ };
1206
+ get?: never;
1207
+ put?: never;
1208
+ /**
1209
+ * Subscribe to LLM token billing
1210
+ * @description Creates a Stripe Checkout session for the LLM token billing pricing plan. Returns a checkout URL to redirect the user. After the user completes checkout, a webhook activates LLM billing for the org.
1211
+ */
1212
+ post: operations["subscribeLlmTokenBilling"];
1213
+ delete?: never;
1214
+ options?: never;
1215
+ head?: never;
1216
+ patch?: never;
1217
+ trace?: never;
1218
+ };
1219
+ "/v1/billing/llm-token-billing/disable": {
1220
+ parameters: {
1221
+ query?: never;
1222
+ header?: never;
1223
+ path?: never;
1224
+ cookie?: never;
1225
+ };
1226
+ get?: never;
1227
+ put?: never;
1228
+ /**
1229
+ * Disable LLM token billing
1230
+ * @description Disables LLM token billing for the org and cancels all active Stripe subscriptions for the LLM pricing plan. Agents will fall back to direct provider routing. You can re-enable it at any time.
1231
+ */
1232
+ post: operations["disableLlmTokenBilling"];
1233
+ delete?: never;
1234
+ options?: never;
1235
+ head?: never;
1236
+ patch?: never;
1237
+ trace?: never;
1238
+ };
1153
1239
  "/v1/billing/overage-method": {
1154
1240
  parameters: {
1155
1241
  query?: never;
@@ -1553,8 +1639,11 @@ export interface components {
1553
1639
  refresh_token?: string;
1554
1640
  };
1555
1641
  AgentTokenRequest: {
1556
- /** Format: uuid */
1557
- agent_id: string;
1642
+ /**
1643
+ * Format: uuid
1644
+ * @description Optional when using key-only auth (ocv_ keys auto-resolve agent)
1645
+ */
1646
+ agent_id?: string;
1558
1647
  api_key: string;
1559
1648
  };
1560
1649
  UserApiKeyTokenRequest: {
@@ -1603,6 +1692,11 @@ export interface components {
1603
1692
  };
1604
1693
  DeviceCodeRequest: {
1605
1694
  client_id: string;
1695
+ /**
1696
+ * Format: email
1697
+ * @description Account email; only that user may approve the code in the dashboard.
1698
+ */
1699
+ email: string;
1606
1700
  };
1607
1701
  DeviceCodeResponse: {
1608
1702
  device_code?: string;
@@ -2187,6 +2281,48 @@ export interface components {
2187
2281
  max_priority_fee_per_gas?: string;
2188
2282
  /** @default false */
2189
2283
  simulate_first: boolean;
2284
+ /**
2285
+ * @description Transaction mode
2286
+ * @default eoa
2287
+ * @enum {string}
2288
+ */
2289
+ mode: "eoa" | "smart_account";
2290
+ };
2291
+ SignTransactionRequest: {
2292
+ /** @description Destination address (0x-prefixed) */
2293
+ to: string;
2294
+ /** @description Value in ETH */
2295
+ value: string;
2296
+ /** @description Chain name or numeric ID */
2297
+ chain: string;
2298
+ /** @description Hex-encoded calldata */
2299
+ data?: string;
2300
+ signing_key_path?: string;
2301
+ nonce?: number;
2302
+ gas_price?: string;
2303
+ gas_limit?: number;
2304
+ max_fee_per_gas?: string;
2305
+ max_priority_fee_per_gas?: string;
2306
+ /** @default false */
2307
+ simulate_first: boolean;
2308
+ };
2309
+ SignTransactionResponse: {
2310
+ /** @description Raw signed transaction hex (always included) */
2311
+ signed_tx?: string;
2312
+ tx_hash?: string;
2313
+ /** @description Derived sender address */
2314
+ from?: string;
2315
+ to?: string;
2316
+ chain?: string;
2317
+ chain_id?: number;
2318
+ nonce?: number;
2319
+ value_wei?: string;
2320
+ /** @enum {string} */
2321
+ status?: "sign_only";
2322
+ simulation_id?: string;
2323
+ simulation_status?: string;
2324
+ max_fee_per_gas?: string;
2325
+ max_priority_fee_per_gas?: string;
2190
2326
  };
2191
2327
  SimulateTransactionRequest: {
2192
2328
  to: string;
@@ -2209,8 +2345,8 @@ export interface components {
2209
2345
  to?: string;
2210
2346
  value_wei?: string;
2211
2347
  /** @enum {string} */
2212
- status?: "pending" | "signed" | "broadcast" | "failed" | "simulation_failed";
2213
- /** @description Raw signed transaction hex. Omitted (null) by default to reduce exfiltration risk. Pass `include_signed_tx=true` query param on GET endpoints to include it. Always returned on the initial POST submission response. */
2348
+ status?: "pending" | "signed" | "sign_only" | "broadcast" | "failed" | "simulation_failed";
2349
+ /** @description Raw signed transaction hex. On GET list and GET by id, this property is omitted by default (absent from the response). Pass `include_signed_tx=true` on those endpoints to include it. Always present on the initial POST submit response. */
2214
2350
  signed_tx?: string | null;
2215
2351
  tx_hash?: string;
2216
2352
  error_message?: string;
@@ -2451,6 +2587,18 @@ export interface components {
2451
2587
  used?: number;
2452
2588
  limit?: number;
2453
2589
  };
2590
+ LlmTokenBillingStatus: {
2591
+ enabled?: boolean;
2592
+ /** @enum {string} */
2593
+ subscription_status?: "active" | "inactive";
2594
+ };
2595
+ LlmCheckoutResponse: {
2596
+ /** Format: uri */
2597
+ checkout_url?: string;
2598
+ };
2599
+ LlmDisableResponse: {
2600
+ enabled?: boolean;
2601
+ };
2454
2602
  CreditBalanceResponse: {
2455
2603
  balance_cents?: number;
2456
2604
  balance_usd?: string;
@@ -2721,7 +2869,7 @@ export interface components {
2721
2869
  SecretPath: string;
2722
2870
  AgentId: string;
2723
2871
  PolicyId: string;
2724
- /** @description Set to `true` or `1` to include the raw signed transaction hex in the response. Omitted by default to reduce key exfiltration risk. Only the literal values "true" or "1" enable inclusion; any other value or omission returns responses without signed_tx. */
2872
+ /** @description Set to `true` or `1` to include the raw signed transaction hex in the response. Omitted by default to reduce key exfiltration risk. Only the literal values "true" or "1" enable inclusion; any other value or omission returns responses without signed_tx. Applies to GET /v1/agents/{agent_id}/transactions and GET /v1/agents/{agent_id}/transactions/{tx_id}. */
2725
2873
  IncludeSignedTx: boolean;
2726
2874
  };
2727
2875
  requestBodies: never;
@@ -3986,7 +4134,7 @@ export interface operations {
3986
4134
  listTransactions: {
3987
4135
  parameters: {
3988
4136
  query?: {
3989
- /** @description Set to `true` or `1` to include the raw signed transaction hex in the response. Omitted by default to reduce key exfiltration risk. Only the literal values "true" or "1" enable inclusion; any other value or omission returns responses without signed_tx. */
4137
+ /** @description Set to `true` or `1` to include the raw signed transaction hex in the response. Omitted by default to reduce key exfiltration risk. Only the literal values "true" or "1" enable inclusion; any other value or omission returns responses without signed_tx. Applies to GET /v1/agents/{agent_id}/transactions and GET /v1/agents/{agent_id}/transactions/{tx_id}. */
3990
4138
  include_signed_tx?: components["parameters"]["IncludeSignedTx"];
3991
4139
  };
3992
4140
  header?: never;
@@ -4069,7 +4217,7 @@ export interface operations {
4069
4217
  getTransaction: {
4070
4218
  parameters: {
4071
4219
  query?: {
4072
- /** @description Set to `true` or `1` to include the raw signed transaction hex in the response. Omitted by default to reduce key exfiltration risk. Only the literal values "true" or "1" enable inclusion; any other value or omission returns responses without signed_tx. */
4220
+ /** @description Set to `true` or `1` to include the raw signed transaction hex in the response. Omitted by default to reduce key exfiltration risk. Only the literal values "true" or "1" enable inclusion; any other value or omission returns responses without signed_tx. Applies to GET /v1/agents/{agent_id}/transactions and GET /v1/agents/{agent_id}/transactions/{tx_id}. */
4073
4221
  include_signed_tx?: components["parameters"]["IncludeSignedTx"];
4074
4222
  };
4075
4223
  header?: never;
@@ -4093,6 +4241,35 @@ export interface operations {
4093
4241
  404: components["responses"]["NotFound"];
4094
4242
  };
4095
4243
  };
4244
+ signTransaction: {
4245
+ parameters: {
4246
+ query?: never;
4247
+ header?: never;
4248
+ path: {
4249
+ agent_id: components["parameters"]["AgentId"];
4250
+ };
4251
+ cookie?: never;
4252
+ };
4253
+ requestBody: {
4254
+ content: {
4255
+ "application/json": components["schemas"]["SignTransactionRequest"];
4256
+ };
4257
+ };
4258
+ responses: {
4259
+ /** @description Transaction signed successfully (not broadcast) */
4260
+ 200: {
4261
+ headers: {
4262
+ [name: string]: unknown;
4263
+ };
4264
+ content: {
4265
+ "application/json": components["schemas"]["SignTransactionResponse"];
4266
+ };
4267
+ };
4268
+ 400: components["responses"]["BadRequest"];
4269
+ 402: components["responses"]["PaymentRequired"];
4270
+ 403: components["responses"]["Forbidden"];
4271
+ };
4272
+ };
4096
4273
  simulateTransaction: {
4097
4274
  parameters: {
4098
4275
  query?: never;
@@ -4726,6 +4903,66 @@ export interface operations {
4726
4903
  };
4727
4904
  };
4728
4905
  };
4906
+ getLlmTokenBilling: {
4907
+ parameters: {
4908
+ query?: never;
4909
+ header?: never;
4910
+ path?: never;
4911
+ cookie?: never;
4912
+ };
4913
+ requestBody?: never;
4914
+ responses: {
4915
+ /** @description LLM token billing status */
4916
+ 200: {
4917
+ headers: {
4918
+ [name: string]: unknown;
4919
+ };
4920
+ content: {
4921
+ "application/json": components["schemas"]["LlmTokenBillingStatus"];
4922
+ };
4923
+ };
4924
+ };
4925
+ };
4926
+ subscribeLlmTokenBilling: {
4927
+ parameters: {
4928
+ query?: never;
4929
+ header?: never;
4930
+ path?: never;
4931
+ cookie?: never;
4932
+ };
4933
+ requestBody?: never;
4934
+ responses: {
4935
+ /** @description Stripe Checkout URL */
4936
+ 200: {
4937
+ headers: {
4938
+ [name: string]: unknown;
4939
+ };
4940
+ content: {
4941
+ "application/json": components["schemas"]["LlmCheckoutResponse"];
4942
+ };
4943
+ };
4944
+ };
4945
+ };
4946
+ disableLlmTokenBilling: {
4947
+ parameters: {
4948
+ query?: never;
4949
+ header?: never;
4950
+ path?: never;
4951
+ cookie?: never;
4952
+ };
4953
+ requestBody?: never;
4954
+ responses: {
4955
+ /** @description LLM billing disabled */
4956
+ 200: {
4957
+ headers: {
4958
+ [name: string]: unknown;
4959
+ };
4960
+ content: {
4961
+ "application/json": components["schemas"]["LlmDisableResponse"];
4962
+ };
4963
+ };
4964
+ };
4965
+ };
4729
4966
  billingOverageMethod: {
4730
4967
  parameters: {
4731
4968
  query?: never;