@openfort/cli 0.1.7 → 0.1.9

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/dist/cli.js CHANGED
@@ -1,19 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CREDENTIALS_PATH,
4
- ensureConfigDir
5
- } from "./chunk-QJGHQ7ID.js";
4
+ ensureConfigDir,
5
+ loadEnvFile,
6
+ requireApiKey,
7
+ writeEnvKey
8
+ } from "./chunk-SVNLXGFY.js";
6
9
 
7
10
  // src/cli.ts
8
- import { readFileSync as readFileSync2 } from "fs";
9
- import { Cli as Cli13, z as z15, Errors as Errors4 } from "incur";
10
- import Openfort from "@openfort/openfort-node";
11
+ import { readFileSync } from "fs";
12
+ import { Cli as Cli14, z as z14 } from "incur";
11
13
 
12
- // src/vars.ts
13
- import { z } from "incur";
14
- var varsSchema = z.object({
15
- openfort: z.custom()
16
- });
14
+ // src/commands/login.ts
15
+ import { randomBytes } from "crypto";
16
+ import { createServer } from "http";
17
+ import open from "open";
18
+ import { Cli, z } from "incur";
17
19
 
18
20
  // src/constants.ts
19
21
  var API_BASE_URL = process.env.OPENFORT_BASE_URL || "https://api.openfort.io";
@@ -21,40 +23,6 @@ var OPENFORT_SHIELD_URL = process.env.OPENFORT_SHIELD_URL || "https://shield.ope
21
23
  var AUTH_PAGE_URL = process.env.OPENFORT_AUTH_PAGE_URL || "https://dashboard.openfort.io";
22
24
  var CLI_CALLBACK_PORT = Number(process.env.OPENFORT_CLI_CALLBACK_PORT) || 8271;
23
25
 
24
- // src/commands/login.ts
25
- import { randomBytes } from "crypto";
26
- import { createServer } from "http";
27
- import open from "open";
28
- import { z as z2 } from "incur";
29
-
30
- // src/env.ts
31
- import { readFileSync, writeFileSync, existsSync } from "fs";
32
- function loadEnvFile(envPath) {
33
- const entries = /* @__PURE__ */ new Map();
34
- if (!existsSync(envPath)) return entries;
35
- const content = readFileSync(envPath, "utf-8");
36
- for (const line of content.split("\n")) {
37
- const trimmed = line.trim();
38
- if (!trimmed || trimmed.startsWith("#")) continue;
39
- const eqIndex = trimmed.indexOf("=");
40
- if (eqIndex === -1) continue;
41
- const key = trimmed.slice(0, eqIndex).trim();
42
- const value = trimmed.slice(eqIndex + 1).trim();
43
- entries.set(key, value);
44
- }
45
- return entries;
46
- }
47
- function writeEnvKey(envPath, key, value) {
48
- const entries = loadEnvFile(envPath);
49
- entries.set(key, value);
50
- const lines = [];
51
- for (const [k, v] of entries) {
52
- lines.push(`${k}=${v}`);
53
- }
54
- writeFileSync(envPath, `${lines.join("\n")}
55
- `);
56
- }
57
-
58
26
  // src/commands/login.ts
59
27
  function base64url(buffer) {
60
28
  return buffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
@@ -151,7 +119,7 @@ function waitForCallback(port, state) {
151
119
  reject(new Error("Login timed out after 5 minutes. Please try again."));
152
120
  }, 5 * 60 * 1e3);
153
121
  const server = createServer((req, res) => {
154
- const url = new URL(req.url, `http://localhost:${port}`);
122
+ const url = new URL(req.url ?? "/", `http://localhost:${port}`);
155
123
  if (url.pathname === "/callback") {
156
124
  const apiKey = url.searchParams.get("api_key");
157
125
  const publishableKey = url.searchParams.get("publishable_key");
@@ -186,12 +154,12 @@ function waitForCallback(port, state) {
186
154
  server.listen(port);
187
155
  });
188
156
  }
189
- var loginConfig = {
157
+ var login = Cli.create("login", {
190
158
  description: "Log in to Openfort via browser and save your API key.",
191
- output: z2.object({
192
- apiKey: z2.string().describe("The API key saved to credentials"),
193
- project: z2.string().describe("The project name"),
194
- credentialsPath: z2.string().describe("Path to the credentials file")
159
+ output: z.object({
160
+ apiKey: z.string().describe("The API key saved to credentials"),
161
+ project: z.string().describe("The project name"),
162
+ credentialsPath: z.string().describe("Path to the credentials file")
195
163
  }),
196
164
  async run(c) {
197
165
  const state = generateState();
@@ -236,10 +204,40 @@ var loginConfig = {
236
204
  }
237
205
  );
238
206
  }
239
- };
207
+ });
208
+
209
+ // src/commands/accounts.ts
210
+ import { Cli as Cli2, z as z2, middleware } from "incur";
211
+
212
+ // src/client.ts
213
+ import Openfort from "@openfort/openfort-node";
214
+ var cached;
215
+ function getOpenfort() {
216
+ if (cached) return cached;
217
+ let apiKey = process.env.OPENFORT_API_KEY;
218
+ if (!apiKey) {
219
+ const creds = loadEnvFile(CREDENTIALS_PATH);
220
+ apiKey = creds.get("OPENFORT_API_KEY");
221
+ if (apiKey) {
222
+ process.env.OPENFORT_API_KEY = apiKey;
223
+ const pk = creds.get("OPENFORT_PUBLISHABLE_KEY");
224
+ if (pk && !process.env.OPENFORT_PUBLISHABLE_KEY) process.env.OPENFORT_PUBLISHABLE_KEY = pk;
225
+ const ws = creds.get("OPENFORT_WALLET_SECRET");
226
+ if (ws && !process.env.OPENFORT_WALLET_SECRET) process.env.OPENFORT_WALLET_SECRET = ws;
227
+ }
228
+ }
229
+ if (!apiKey) {
230
+ throw new Error("OPENFORT_API_KEY is required. Run: openfort login");
231
+ }
232
+ cached = new Openfort(apiKey, {
233
+ walletSecret: process.env.OPENFORT_WALLET_SECRET,
234
+ publishableKey: process.env.OPENFORT_PUBLISHABLE_KEY,
235
+ basePath: API_BASE_URL
236
+ });
237
+ return cached;
238
+ }
240
239
 
241
240
  // src/commands/accounts.ts
242
- import { Cli, z as z3, middleware } from "incur";
243
241
  var requireWallet = middleware((c, next) => {
244
242
  const missing = [];
245
243
  if (!process.env.OPENFORT_WALLET_SECRET) missing.push("OPENFORT_WALLET_SECRET");
@@ -256,9 +254,8 @@ var requireWallet = middleware((c, next) => {
256
254
  }
257
255
  return next();
258
256
  });
259
- var evm = Cli.create("evm", {
260
- description: "EVM wallet management.",
261
- vars: varsSchema
257
+ var evm = Cli2.create("evm", {
258
+ description: "EVM wallet management."
262
259
  });
263
260
  evm.command("create", {
264
261
  description: "Create a new EVM backend wallet.",
@@ -267,13 +264,13 @@ evm.command("create", {
267
264
  ],
268
265
  hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
269
266
  middleware: [requireWallet],
270
- output: z3.object({
271
- id: z3.string().describe("Account ID"),
272
- address: z3.string().describe("Wallet address"),
273
- custody: z3.string().describe("Custody type")
267
+ output: z2.object({
268
+ id: z2.string().describe("Account ID"),
269
+ address: z2.string().describe("Wallet address"),
270
+ custody: z2.string().describe("Custody type")
274
271
  }),
275
272
  async run(c) {
276
- const account = await c.var.openfort.accounts.evm.backend.create();
273
+ const account = await getOpenfort().accounts.evm.backend.create();
277
274
  return c.ok(
278
275
  { id: account.id, address: account.address, custody: account.custody },
279
276
  {
@@ -290,25 +287,25 @@ evm.command("create", {
290
287
  });
291
288
  evm.command("list", {
292
289
  description: "List EVM backend wallets.",
293
- options: z3.object({
294
- limit: z3.number().optional().describe("Max results"),
295
- skip: z3.number().optional().describe("Offset")
290
+ options: z2.object({
291
+ limit: z2.number().optional().describe("Max results"),
292
+ skip: z2.number().optional().describe("Offset")
296
293
  }),
297
294
  alias: { limit: "l" },
298
295
  examples: [
299
296
  { description: "List all EVM backend wallets" },
300
297
  { options: { limit: 5 }, description: "Show first 5 wallets" }
301
298
  ],
302
- output: z3.object({
303
- accounts: z3.array(z3.object({
304
- id: z3.string(),
305
- address: z3.string(),
306
- custody: z3.string()
299
+ output: z2.object({
300
+ accounts: z2.array(z2.object({
301
+ id: z2.string(),
302
+ address: z2.string(),
303
+ custody: z2.string()
307
304
  })),
308
- total: z3.number().optional()
305
+ total: z2.number().optional()
309
306
  }),
310
307
  async run(c) {
311
- const res = await c.var.openfort.accounts.evm.backend.list({
308
+ const res = await getOpenfort().accounts.evm.backend.list({
312
309
  limit: c.options.limit,
313
310
  skip: c.options.skip
314
311
  });
@@ -324,25 +321,25 @@ evm.command("list", {
324
321
  });
325
322
  evm.command("list-delegated", {
326
323
  description: "List EVM delegated accounts.",
327
- options: z3.object({
328
- limit: z3.number().optional().describe("Max results"),
329
- skip: z3.number().optional().describe("Offset")
324
+ options: z2.object({
325
+ limit: z2.number().optional().describe("Max results"),
326
+ skip: z2.number().optional().describe("Offset")
330
327
  }),
331
328
  alias: { limit: "l" },
332
329
  examples: [
333
330
  { description: "List all EVM delegated accounts" },
334
331
  { options: { limit: 5 }, description: "Show first 5 accounts" }
335
332
  ],
336
- output: z3.object({
337
- accounts: z3.array(z3.object({
338
- id: z3.string(),
339
- address: z3.string(),
340
- custody: z3.string()
333
+ output: z2.object({
334
+ accounts: z2.array(z2.object({
335
+ id: z2.string(),
336
+ address: z2.string(),
337
+ custody: z2.string()
341
338
  })),
342
- total: z3.number().optional()
339
+ total: z2.number().optional()
343
340
  }),
344
341
  async run(c) {
345
- const res = await c.var.openfort.accounts.evm.list({
342
+ const res = await getOpenfort().accounts.evm.list({
346
343
  accountType: "Delegated Account",
347
344
  limit: c.options.limit,
348
345
  skip: c.options.skip
@@ -359,25 +356,25 @@ evm.command("list-delegated", {
359
356
  });
360
357
  evm.command("list-smart", {
361
358
  description: "List EVM smart accounts.",
362
- options: z3.object({
363
- limit: z3.number().optional().describe("Max results"),
364
- skip: z3.number().optional().describe("Offset")
359
+ options: z2.object({
360
+ limit: z2.number().optional().describe("Max results"),
361
+ skip: z2.number().optional().describe("Offset")
365
362
  }),
366
363
  alias: { limit: "l" },
367
364
  examples: [
368
365
  { description: "List all EVM smart accounts" },
369
366
  { options: { limit: 5 }, description: "Show first 5 accounts" }
370
367
  ],
371
- output: z3.object({
372
- accounts: z3.array(z3.object({
373
- id: z3.string(),
374
- address: z3.string(),
375
- custody: z3.string()
368
+ output: z2.object({
369
+ accounts: z2.array(z2.object({
370
+ id: z2.string(),
371
+ address: z2.string(),
372
+ custody: z2.string()
376
373
  })),
377
- total: z3.number().optional()
374
+ total: z2.number().optional()
378
375
  }),
379
376
  async run(c) {
380
- const res = await c.var.openfort.accounts.evm.list({
377
+ const res = await getOpenfort().accounts.evm.list({
381
378
  accountType: "Smart Account",
382
379
  limit: c.options.limit,
383
380
  skip: c.options.skip
@@ -394,19 +391,19 @@ evm.command("list-smart", {
394
391
  });
395
392
  evm.command("get", {
396
393
  description: "Get an EVM backend wallet by ID or address.",
397
- args: z3.object({
398
- id: z3.string().describe("Account ID or address")
394
+ args: z2.object({
395
+ id: z2.string().describe("Account ID or address")
399
396
  }),
400
397
  examples: [
401
398
  { args: { id: "acc_1a2b3c4d" }, description: "Get wallet by ID" }
402
399
  ],
403
- output: z3.object({
404
- id: z3.string(),
405
- address: z3.string(),
406
- custody: z3.string()
400
+ output: z2.object({
401
+ id: z2.string(),
402
+ address: z2.string(),
403
+ custody: z2.string()
407
404
  }),
408
405
  async run(c) {
409
- const a = await c.var.openfort.accounts.evm.backend.get({ id: c.args.id });
406
+ const a = await getOpenfort().accounts.evm.backend.get({ id: c.args.id });
410
407
  return c.ok({
411
408
  id: a.id,
412
409
  address: a.address,
@@ -416,43 +413,43 @@ evm.command("get", {
416
413
  });
417
414
  evm.command("delete", {
418
415
  description: "Delete an EVM backend wallet.",
419
- args: z3.object({
420
- id: z3.string().describe("Account ID (acc_...)")
416
+ args: z2.object({
417
+ id: z2.string().describe("Account ID (acc_...)")
421
418
  }),
422
419
  examples: [
423
420
  { args: { id: "acc_1a2b3c4d" }, description: "Delete a wallet" }
424
421
  ],
425
- output: z3.object({
426
- id: z3.string(),
427
- deleted: z3.boolean()
422
+ output: z2.object({
423
+ id: z2.string(),
424
+ deleted: z2.boolean()
428
425
  }),
429
426
  async run(c) {
430
- const res = await c.var.openfort.accounts.evm.backend.delete(c.args.id);
427
+ const res = await getOpenfort().accounts.evm.backend.delete(c.args.id);
431
428
  return c.ok({ id: res.id, deleted: res.deleted });
432
429
  }
433
430
  });
434
431
  evm.command("update", {
435
432
  description: "Upgrade an EVM backend wallet to a delegated account (EIP-7702).",
436
- args: z3.object({
437
- id: z3.string().describe("Account ID (acc_...)")
433
+ args: z2.object({
434
+ id: z2.string().describe("Account ID (acc_...)")
438
435
  }),
439
- options: z3.object({
440
- chainId: z3.number().describe("Chain ID to deploy on"),
441
- implementationType: z3.string().describe("Target implementation type (e.g. CaliburV9)")
436
+ options: z2.object({
437
+ chainId: z2.number().describe("Chain ID to deploy on"),
438
+ implementationType: z2.string().describe("Target implementation type (e.g. CaliburV9)")
442
439
  }),
443
440
  examples: [
444
441
  { args: { id: "acc_1a2b3c4d" }, options: { chainId: 8453, implementationType: "CaliburV9" }, description: "Upgrade to delegated account on Base" }
445
442
  ],
446
- output: z3.object({
447
- id: z3.string(),
448
- address: z3.string(),
449
- accountType: z3.string(),
450
- chainId: z3.number().optional(),
451
- chainType: z3.string()
443
+ output: z2.object({
444
+ id: z2.string(),
445
+ address: z2.string(),
446
+ accountType: z2.string(),
447
+ chainId: z2.number().optional(),
448
+ chainType: z2.string()
452
449
  }),
453
450
  async run(c) {
454
- const account = await c.var.openfort.accounts.evm.backend.get({ id: c.args.id });
455
- const res = await c.var.openfort.accounts.evm.backend.update({
451
+ const account = await getOpenfort().accounts.evm.backend.get({ id: c.args.id });
452
+ const res = await getOpenfort().accounts.evm.backend.update({
456
453
  walletId: account.walletId,
457
454
  chainId: c.options.chainId,
458
455
  accountId: account.id,
@@ -479,22 +476,22 @@ evm.command("update", {
479
476
  });
480
477
  evm.command("sign", {
481
478
  description: "Sign data with an EVM backend wallet.",
482
- args: z3.object({
483
- id: z3.string().describe("Account ID (acc_...)")
479
+ args: z2.object({
480
+ id: z2.string().describe("Account ID (acc_...)")
484
481
  }),
485
- options: z3.object({
486
- data: z3.string().describe("Hex-encoded data to sign")
482
+ options: z2.object({
483
+ data: z2.string().describe("Hex-encoded data to sign")
487
484
  }),
488
485
  examples: [
489
486
  { args: { id: "acc_1a2b3c4d" }, options: { data: "0xdeadbeef" }, description: "Sign a message hash" }
490
487
  ],
491
488
  hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
492
489
  middleware: [requireWallet],
493
- output: z3.object({
494
- signature: z3.string()
490
+ output: z2.object({
491
+ signature: z2.string()
495
492
  }),
496
493
  async run(c) {
497
- const signature = await c.var.openfort.accounts.evm.backend.sign({
494
+ const signature = await getOpenfort().accounts.evm.backend.sign({
498
495
  id: c.args.id,
499
496
  data: c.options.data
500
497
  });
@@ -503,21 +500,21 @@ evm.command("sign", {
503
500
  });
504
501
  evm.command("import", {
505
502
  description: "Import a private key as an EVM backend wallet.",
506
- options: z3.object({
507
- privateKey: z3.string().describe("Private key (hex string)")
503
+ options: z2.object({
504
+ privateKey: z2.string().describe("Private key (hex string)")
508
505
  }),
509
506
  examples: [
510
507
  { options: { privateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" }, description: "Import a private key" }
511
508
  ],
512
509
  hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
513
510
  middleware: [requireWallet],
514
- output: z3.object({
515
- id: z3.string(),
516
- address: z3.string(),
517
- custody: z3.string()
511
+ output: z2.object({
512
+ id: z2.string(),
513
+ address: z2.string(),
514
+ custody: z2.string()
518
515
  }),
519
516
  async run(c) {
520
- const account = await c.var.openfort.accounts.evm.backend.import({
517
+ const account = await getOpenfort().accounts.evm.backend.import({
521
518
  privateKey: c.options.privateKey
522
519
  });
523
520
  return c.ok({
@@ -529,18 +526,18 @@ evm.command("import", {
529
526
  });
530
527
  evm.command("export", {
531
528
  description: "Export an EVM backend wallet private key.",
532
- args: z3.object({
533
- id: z3.string().describe("Account ID (acc_...)")
529
+ args: z2.object({
530
+ id: z2.string().describe("Account ID (acc_...)")
534
531
  }),
535
532
  examples: [
536
533
  { args: { id: "acc_1a2b3c4d" }, description: "Export private key" }
537
534
  ],
538
535
  middleware: [requireWallet],
539
- output: z3.object({
540
- privateKey: z3.string()
536
+ output: z2.object({
537
+ privateKey: z2.string()
541
538
  }),
542
539
  async run(c) {
543
- const privateKey = await c.var.openfort.accounts.evm.backend.export({
540
+ const privateKey = await getOpenfort().accounts.evm.backend.export({
544
541
  id: c.args.id
545
542
  });
546
543
  return c.ok({ privateKey });
@@ -548,13 +545,13 @@ evm.command("export", {
548
545
  });
549
546
  evm.command("send-transaction", {
550
547
  description: "Send a gasless EVM transaction (auto-delegates via EIP-7702 if needed).",
551
- args: z3.object({
552
- id: z3.string().describe("Account ID (acc_...)")
548
+ args: z2.object({
549
+ id: z2.string().describe("Account ID (acc_...)")
553
550
  }),
554
- options: z3.object({
555
- chainId: z3.number().describe("Chain ID"),
556
- interactions: z3.string().describe('Interactions as JSON: [{"to":"0x...","data":"0x...","value":"0"}]'),
557
- policy: z3.string().optional().describe("Fee sponsorship ID (pol_...)")
551
+ options: z2.object({
552
+ chainId: z2.number().describe("Chain ID"),
553
+ interactions: z2.string().describe('Interactions as JSON: [{"to":"0x...","data":"0x...","value":"0"}]'),
554
+ policy: z2.string().optional().describe("Fee sponsorship ID (pol_...)")
558
555
  }),
559
556
  examples: [
560
557
  {
@@ -567,15 +564,15 @@ evm.command("send-transaction", {
567
564
  }
568
565
  ],
569
566
  middleware: [requireWallet],
570
- output: z3.object({
571
- id: z3.string(),
572
- chainId: z3.number(),
573
- transactionHash: z3.string().optional()
567
+ output: z2.object({
568
+ id: z2.string(),
569
+ chainId: z2.number(),
570
+ transactionHash: z2.string().optional()
574
571
  }),
575
572
  async run(c) {
576
- const account = await c.var.openfort.accounts.evm.backend.get({ id: c.args.id });
573
+ const account = await getOpenfort().accounts.evm.backend.get({ id: c.args.id });
577
574
  const interactions = JSON.parse(c.options.interactions);
578
- const res = await c.var.openfort.accounts.evm.backend.sendTransaction({
575
+ const res = await getOpenfort().accounts.evm.backend.sendTransaction({
579
576
  account,
580
577
  chainId: c.options.chainId,
581
578
  interactions,
@@ -588,9 +585,8 @@ evm.command("send-transaction", {
588
585
  });
589
586
  }
590
587
  });
591
- var solana = Cli.create("solana", {
592
- description: "Solana wallet management.",
593
- vars: varsSchema
588
+ var solana = Cli2.create("solana", {
589
+ description: "Solana wallet management."
594
590
  });
595
591
  solana.command("create", {
596
592
  description: "Create a new Solana backend wallet.",
@@ -599,13 +595,13 @@ solana.command("create", {
599
595
  ],
600
596
  hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
601
597
  middleware: [requireWallet],
602
- output: z3.object({
603
- id: z3.string().describe("Account ID"),
604
- address: z3.string().describe("Wallet address"),
605
- custody: z3.string().describe("Custody type")
598
+ output: z2.object({
599
+ id: z2.string().describe("Account ID"),
600
+ address: z2.string().describe("Wallet address"),
601
+ custody: z2.string().describe("Custody type")
606
602
  }),
607
603
  async run(c) {
608
- const account = await c.var.openfort.accounts.solana.backend.create();
604
+ const account = await getOpenfort().accounts.solana.backend.create();
609
605
  return c.ok(
610
606
  { id: account.id, address: account.address, custody: account.custody },
611
607
  {
@@ -621,24 +617,24 @@ solana.command("create", {
621
617
  });
622
618
  solana.command("list", {
623
619
  description: "List Solana backend wallets.",
624
- options: z3.object({
625
- limit: z3.number().optional().describe("Max results"),
626
- skip: z3.number().optional().describe("Offset")
620
+ options: z2.object({
621
+ limit: z2.number().optional().describe("Max results"),
622
+ skip: z2.number().optional().describe("Offset")
627
623
  }),
628
624
  alias: { limit: "l" },
629
625
  examples: [
630
626
  { description: "List all Solana wallets" }
631
627
  ],
632
- output: z3.object({
633
- accounts: z3.array(z3.object({
634
- id: z3.string(),
635
- address: z3.string(),
636
- custody: z3.string()
628
+ output: z2.object({
629
+ accounts: z2.array(z2.object({
630
+ id: z2.string(),
631
+ address: z2.string(),
632
+ custody: z2.string()
637
633
  })),
638
- total: z3.number().optional()
634
+ total: z2.number().optional()
639
635
  }),
640
636
  async run(c) {
641
- const res = await c.var.openfort.accounts.solana.backend.list({
637
+ const res = await getOpenfort().accounts.solana.backend.list({
642
638
  limit: c.options.limit,
643
639
  skip: c.options.skip
644
640
  });
@@ -654,19 +650,19 @@ solana.command("list", {
654
650
  });
655
651
  solana.command("get", {
656
652
  description: "Get a Solana backend wallet by ID or address.",
657
- args: z3.object({
658
- id: z3.string().describe("Account ID or address")
653
+ args: z2.object({
654
+ id: z2.string().describe("Account ID or address")
659
655
  }),
660
656
  examples: [
661
657
  { args: { id: "acc_1a2b3c4d" }, description: "Get wallet by ID" }
662
658
  ],
663
- output: z3.object({
664
- id: z3.string(),
665
- address: z3.string(),
666
- custody: z3.string()
659
+ output: z2.object({
660
+ id: z2.string(),
661
+ address: z2.string(),
662
+ custody: z2.string()
667
663
  }),
668
664
  async run(c) {
669
- const a = await c.var.openfort.accounts.solana.backend.get({ id: c.args.id });
665
+ const a = await getOpenfort().accounts.solana.backend.get({ id: c.args.id });
670
666
  return c.ok({
671
667
  id: a.id,
672
668
  address: a.address,
@@ -676,18 +672,18 @@ solana.command("get", {
676
672
  });
677
673
  solana.command("sign", {
678
674
  description: "Sign data with a Solana backend wallet.",
679
- args: z3.object({
680
- id: z3.string().describe("Account ID (acc_...)")
675
+ args: z2.object({
676
+ id: z2.string().describe("Account ID (acc_...)")
681
677
  }),
682
- options: z3.object({
683
- data: z3.string().describe("Data to sign (base64-encoded)")
678
+ options: z2.object({
679
+ data: z2.string().describe("Data to sign (base64-encoded)")
684
680
  }),
685
681
  alias: { data: "d" },
686
682
  hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
687
683
  middleware: [requireWallet],
688
- output: z3.object({
689
- account: z3.string(),
690
- signature: z3.string()
684
+ output: z2.object({
685
+ account: z2.string(),
686
+ signature: z2.string()
691
687
  }),
692
688
  examples: [
693
689
  {
@@ -697,44 +693,44 @@ solana.command("sign", {
697
693
  }
698
694
  ],
699
695
  async run(c) {
700
- const signature = await c.var.openfort.accounts.solana.backend.sign(c.args.id, c.options.data);
696
+ const signature = await getOpenfort().accounts.solana.backend.sign(c.args.id, c.options.data);
701
697
  return c.ok({ account: c.args.id, signature });
702
698
  }
703
699
  });
704
700
  solana.command("delete", {
705
701
  description: "Delete a Solana backend wallet.",
706
- args: z3.object({
707
- id: z3.string().describe("Account ID (acc_...)")
702
+ args: z2.object({
703
+ id: z2.string().describe("Account ID (acc_...)")
708
704
  }),
709
705
  examples: [
710
706
  { args: { id: "acc_1a2b3c4d" }, description: "Delete a wallet" }
711
707
  ],
712
- output: z3.object({
713
- id: z3.string(),
714
- deleted: z3.boolean()
708
+ output: z2.object({
709
+ id: z2.string(),
710
+ deleted: z2.boolean()
715
711
  }),
716
712
  async run(c) {
717
- const res = await c.var.openfort.accounts.solana.backend.delete(c.args.id);
713
+ const res = await getOpenfort().accounts.solana.backend.delete(c.args.id);
718
714
  return c.ok({ id: res.id, deleted: res.deleted });
719
715
  }
720
716
  });
721
717
  solana.command("import", {
722
718
  description: "Import a private key as a Solana backend wallet.",
723
- options: z3.object({
724
- privateKey: z3.string().describe("Private key (hex-encoded 32 bytes or base58)")
719
+ options: z2.object({
720
+ privateKey: z2.string().describe("Private key (hex-encoded 32 bytes or base58)")
725
721
  }),
726
722
  examples: [
727
723
  { options: { privateKey: "abc123..." }, description: "Import a Solana private key" }
728
724
  ],
729
725
  hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
730
726
  middleware: [requireWallet],
731
- output: z3.object({
732
- id: z3.string(),
733
- address: z3.string(),
734
- custody: z3.string()
727
+ output: z2.object({
728
+ id: z2.string(),
729
+ address: z2.string(),
730
+ custody: z2.string()
735
731
  }),
736
732
  async run(c) {
737
- const account = await c.var.openfort.accounts.solana.backend.import({
733
+ const account = await getOpenfort().accounts.solana.backend.import({
738
734
  privateKey: c.options.privateKey
739
735
  });
740
736
  return c.ok({
@@ -746,18 +742,18 @@ solana.command("import", {
746
742
  });
747
743
  solana.command("export", {
748
744
  description: "Export a Solana backend wallet private key.",
749
- args: z3.object({
750
- id: z3.string().describe("Account ID (acc_...)")
745
+ args: z2.object({
746
+ id: z2.string().describe("Account ID (acc_...)")
751
747
  }),
752
748
  examples: [
753
749
  { args: { id: "acc_1a2b3c4d" }, description: "Export private key" }
754
750
  ],
755
751
  middleware: [requireWallet],
756
- output: z3.object({
757
- privateKey: z3.string()
752
+ output: z2.object({
753
+ privateKey: z2.string()
758
754
  }),
759
755
  async run(c) {
760
- const privateKey = await c.var.openfort.accounts.solana.backend.export({
756
+ const privateKey = await getOpenfort().accounts.solana.backend.export({
761
757
  id: c.args.id
762
758
  });
763
759
  return c.ok({ privateKey });
@@ -765,14 +761,14 @@ solana.command("export", {
765
761
  });
766
762
  solana.command("transfer", {
767
763
  description: "Transfer SOL or SPL tokens.",
768
- args: z3.object({
769
- id: z3.string().describe("Account ID (acc_...)")
764
+ args: z2.object({
765
+ id: z2.string().describe("Account ID (acc_...)")
770
766
  }),
771
- options: z3.object({
772
- to: z3.string().describe("Destination address (base58)"),
773
- amount: z3.string().describe("Amount in base units (lamports for SOL)"),
774
- token: z3.string().optional().describe('Token: "sol" (default), "usdc", or mint address'),
775
- cluster: z3.enum(["devnet", "mainnet-beta"]).default("mainnet-beta").describe("Cluster: devnet or mainnet-beta")
767
+ options: z2.object({
768
+ to: z2.string().describe("Destination address (base58)"),
769
+ amount: z2.string().describe("Amount in base units (lamports for SOL)"),
770
+ token: z2.string().optional().describe('Token: "sol" (default), "usdc", or mint address'),
771
+ cluster: z2.enum(["devnet", "mainnet-beta"]).default("mainnet-beta").describe("Cluster: devnet or mainnet-beta")
776
772
  }),
777
773
  examples: [
778
774
  {
@@ -787,12 +783,12 @@ solana.command("transfer", {
787
783
  }
788
784
  ],
789
785
  middleware: [requireWallet],
790
- output: z3.object({
791
- signature: z3.string()
786
+ output: z2.object({
787
+ signature: z2.string()
792
788
  }),
793
789
  async run(c) {
794
- const account = await c.var.openfort.accounts.solana.backend.get({ id: c.args.id });
795
- const res = await c.var.openfort.accounts.solana.backend.transfer({
790
+ const account = await getOpenfort().accounts.solana.backend.get({ id: c.args.id });
791
+ const res = await getOpenfort().accounts.solana.backend.transfer({
796
792
  account,
797
793
  to: c.options.to,
798
794
  amount: BigInt(c.options.amount),
@@ -802,17 +798,16 @@ solana.command("transfer", {
802
798
  return c.ok({ signature: res.signature });
803
799
  }
804
800
  });
805
- var accounts = Cli.create("accounts", {
806
- description: "Manage wallets and accounts.",
807
- vars: varsSchema
801
+ var accounts = Cli2.create("accounts", {
802
+ description: "Manage wallets and accounts."
808
803
  });
809
804
  accounts.command("list", {
810
805
  description: "List all accounts across chains.",
811
- options: z3.object({
812
- limit: z3.number().optional().describe("Max results"),
813
- skip: z3.number().optional().describe("Offset"),
814
- chainType: z3.enum(["EVM", "SVM"]).optional().describe("Filter by chain type"),
815
- custody: z3.enum(["Developer", "User"]).optional().describe("Filter by custody")
806
+ options: z2.object({
807
+ limit: z2.number().optional().describe("Max results"),
808
+ skip: z2.number().optional().describe("Offset"),
809
+ chainType: z2.enum(["EVM", "SVM"]).optional().describe("Filter by chain type"),
810
+ custody: z2.enum(["Developer", "User"]).optional().describe("Filter by custody")
816
811
  }),
817
812
  alias: { limit: "l" },
818
813
  examples: [
@@ -820,23 +815,23 @@ accounts.command("list", {
820
815
  { options: { chainType: "EVM" }, description: "Filter to EVM accounts only" },
821
816
  { options: { custody: "Developer", limit: 10 }, description: "List developer-custody wallets" }
822
817
  ],
823
- output: z3.object({
824
- data: z3.array(z3.object({
825
- id: z3.string(),
826
- wallet: z3.string().describe("Wallet ID"),
827
- accountType: z3.string().describe("Account type"),
828
- address: z3.string(),
829
- ownerAddress: z3.string().optional(),
830
- chainType: z3.string(),
831
- chainId: z3.number().optional(),
832
- custody: z3.string(),
833
- createdAt: z3.number(),
834
- updatedAt: z3.number()
818
+ output: z2.object({
819
+ data: z2.array(z2.object({
820
+ id: z2.string(),
821
+ wallet: z2.string().describe("Wallet ID"),
822
+ accountType: z2.string().describe("Account type"),
823
+ address: z2.string(),
824
+ ownerAddress: z2.string().optional(),
825
+ chainType: z2.string(),
826
+ chainId: z2.number().optional(),
827
+ custody: z2.string(),
828
+ createdAt: z2.number(),
829
+ updatedAt: z2.number()
835
830
  })),
836
- total: z3.number()
831
+ total: z2.number()
837
832
  }),
838
833
  async run(c) {
839
- const res = await c.var.openfort.accounts.list({
834
+ const res = await getOpenfort().accounts.list({
840
835
  limit: c.options.limit,
841
836
  skip: c.options.skip,
842
837
  chainType: c.options.chainType,
@@ -863,38 +858,37 @@ accounts.command(evm);
863
858
  accounts.command(solana);
864
859
 
865
860
  // src/commands/contracts.ts
866
- import { Cli as Cli2, z as z4 } from "incur";
867
- var contractItem = z4.object({
868
- id: z4.string(),
869
- createdAt: z4.number(),
870
- name: z4.string().nullable(),
871
- chainId: z4.number(),
872
- address: z4.string(),
873
- deleted: z4.boolean(),
874
- abi: z4.array(z4.any()),
875
- publicVerification: z4.boolean()
876
- });
877
- var contracts = Cli2.create("contracts", {
878
- description: "Manage smart contracts.",
879
- vars: varsSchema
861
+ import { Cli as Cli3, z as z3 } from "incur";
862
+ var contractItem = z3.object({
863
+ id: z3.string(),
864
+ createdAt: z3.number(),
865
+ name: z3.string().nullable(),
866
+ chainId: z3.number(),
867
+ address: z3.string(),
868
+ deleted: z3.boolean(),
869
+ abi: z3.array(z3.record(z3.string(), z3.unknown())),
870
+ publicVerification: z3.boolean()
871
+ });
872
+ var contracts = Cli3.create("contracts", {
873
+ description: "Manage smart contracts."
880
874
  });
881
875
  contracts.command("list", {
882
876
  description: "List registered contracts.",
883
- options: z4.object({
884
- limit: z4.number().optional().describe("Max results"),
885
- skip: z4.number().optional().describe("Offset")
877
+ options: z3.object({
878
+ limit: z3.number().optional().describe("Max results"),
879
+ skip: z3.number().optional().describe("Offset")
886
880
  }),
887
881
  alias: { limit: "l" },
888
882
  examples: [
889
883
  { description: "List all contracts" },
890
884
  { options: { limit: 5 }, description: "List first 5 contracts" }
891
885
  ],
892
- output: z4.object({
893
- data: z4.array(contractItem),
894
- total: z4.number()
886
+ output: z3.object({
887
+ data: z3.array(contractItem),
888
+ total: z3.number()
895
889
  }),
896
890
  async run(c) {
897
- const res = await c.var.openfort.contracts.list({
891
+ const res = await getOpenfort().contracts.list({
898
892
  limit: c.options.limit,
899
893
  skip: c.options.skip
900
894
  });
@@ -915,11 +909,11 @@ contracts.command("list", {
915
909
  });
916
910
  contracts.command("create", {
917
911
  description: "Register a smart contract.",
918
- options: z4.object({
919
- name: z4.string().describe("Contract name"),
920
- address: z4.string().describe("Contract address"),
921
- chainId: z4.number().describe("Chain ID"),
922
- abi: z4.string().optional().describe("Contract ABI as JSON string")
912
+ options: z3.object({
913
+ name: z3.string().describe("Contract name"),
914
+ address: z3.string().describe("Contract address"),
915
+ chainId: z3.number().describe("Chain ID"),
916
+ abi: z3.string().optional().describe("Contract ABI as JSON string")
923
917
  }),
924
918
  output: contractItem,
925
919
  examples: [
@@ -933,7 +927,7 @@ contracts.command("create", {
933
927
  }
934
928
  ],
935
929
  async run(c) {
936
- const res = await c.var.openfort.contracts.create({
930
+ const res = await getOpenfort().contracts.create({
937
931
  name: c.options.name,
938
932
  address: c.options.address,
939
933
  chainId: c.options.chainId,
@@ -964,15 +958,15 @@ contracts.command("create", {
964
958
  });
965
959
  contracts.command("get", {
966
960
  description: "Get a contract by ID.",
967
- args: z4.object({
968
- id: z4.string().describe("Contract ID (con_...)")
961
+ args: z3.object({
962
+ id: z3.string().describe("Contract ID (con_...)")
969
963
  }),
970
964
  examples: [
971
965
  { args: { id: "con_1a2b3c4d" }, description: "Get contract details" }
972
966
  ],
973
967
  output: contractItem,
974
968
  async run(c) {
975
- const ct = await c.var.openfort.contracts.get(c.args.id);
969
+ const ct = await getOpenfort().contracts.get(c.args.id);
976
970
  return c.ok({
977
971
  id: ct.id,
978
972
  createdAt: ct.createdAt,
@@ -987,21 +981,21 @@ contracts.command("get", {
987
981
  });
988
982
  contracts.command("update", {
989
983
  description: "Update a contract.",
990
- args: z4.object({
991
- id: z4.string().describe("Contract ID (con_...)")
984
+ args: z3.object({
985
+ id: z3.string().describe("Contract ID (con_...)")
992
986
  }),
993
- options: z4.object({
994
- name: z4.string().optional().describe("New name"),
995
- address: z4.string().optional().describe("New address"),
996
- chainId: z4.number().optional().describe("New chain ID"),
997
- abi: z4.string().optional().describe("New ABI as JSON string")
987
+ options: z3.object({
988
+ name: z3.string().optional().describe("New name"),
989
+ address: z3.string().optional().describe("New address"),
990
+ chainId: z3.number().optional().describe("New chain ID"),
991
+ abi: z3.string().optional().describe("New ABI as JSON string")
998
992
  }),
999
993
  examples: [
1000
994
  { args: { id: "con_1a2b3c4d" }, options: { name: "USDC v2" }, description: "Rename a contract" }
1001
995
  ],
1002
996
  output: contractItem,
1003
997
  async run(c) {
1004
- const res = await c.var.openfort.contracts.update(c.args.id, {
998
+ const res = await getOpenfort().contracts.update(c.args.id, {
1005
999
  name: c.options.name,
1006
1000
  address: c.options.address,
1007
1001
  chainId: c.options.chainId,
@@ -1021,48 +1015,47 @@ contracts.command("update", {
1021
1015
  });
1022
1016
  contracts.command("delete", {
1023
1017
  description: "Delete a contract.",
1024
- args: z4.object({
1025
- id: z4.string().describe("Contract ID (con_...)")
1018
+ args: z3.object({
1019
+ id: z3.string().describe("Contract ID (con_...)")
1026
1020
  }),
1027
1021
  examples: [
1028
1022
  { args: { id: "con_1a2b3c4d" }, description: "Delete a contract" }
1029
1023
  ],
1030
- output: z4.object({
1031
- id: z4.string(),
1032
- deleted: z4.boolean()
1024
+ output: z3.object({
1025
+ id: z3.string(),
1026
+ deleted: z3.boolean()
1033
1027
  }),
1034
1028
  async run(c) {
1035
- const res = await c.var.openfort.contracts.delete(c.args.id);
1029
+ const res = await getOpenfort().contracts.delete(c.args.id);
1036
1030
  return c.ok({ id: res.id, deleted: res.deleted });
1037
1031
  }
1038
1032
  });
1039
1033
 
1040
1034
  // src/commands/paymasters.ts
1041
- import { Cli as Cli3, z as z5 } from "incur";
1042
- var paymasterItem = z5.object({
1043
- id: z5.string(),
1044
- createdAt: z5.number(),
1045
- address: z5.string(),
1046
- url: z5.string().optional(),
1047
- context: z5.record(z5.string(), z5.unknown()).optional()
1048
- });
1049
- var paymasters = Cli3.create("paymasters", {
1050
- description: "Manage ERC-4337 paymasters.",
1051
- vars: varsSchema
1035
+ import { Cli as Cli4, z as z4 } from "incur";
1036
+ var paymasterItem = z4.object({
1037
+ id: z4.string(),
1038
+ createdAt: z4.number(),
1039
+ address: z4.string(),
1040
+ url: z4.string().optional(),
1041
+ context: z4.record(z4.string(), z4.unknown()).optional()
1042
+ });
1043
+ var paymasters = Cli4.create("paymasters", {
1044
+ description: "Manage ERC-4337 paymasters."
1052
1045
  });
1053
1046
  paymasters.command("create", {
1054
1047
  description: "Create a paymaster.",
1055
- options: z5.object({
1056
- address: z5.string().describe("Paymaster contract address"),
1057
- name: z5.string().optional().describe("Paymaster name"),
1058
- url: z5.string().optional().describe("Paymaster URL")
1048
+ options: z4.object({
1049
+ address: z4.string().describe("Paymaster contract address"),
1050
+ name: z4.string().optional().describe("Paymaster name"),
1051
+ url: z4.string().optional().describe("Paymaster URL")
1059
1052
  }),
1060
1053
  examples: [
1061
1054
  { options: { address: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", name: "EntryPoint v0.6 Paymaster" }, description: "Create a paymaster for ERC-4337 v0.6" }
1062
1055
  ],
1063
1056
  output: paymasterItem,
1064
1057
  async run(c) {
1065
- const res = await c.var.openfort.paymasters.create({
1058
+ const res = await getOpenfort().paymasters.create({
1066
1059
  address: c.options.address,
1067
1060
  name: c.options.name,
1068
1061
  url: c.options.url
@@ -1089,15 +1082,15 @@ paymasters.command("create", {
1089
1082
  });
1090
1083
  paymasters.command("get", {
1091
1084
  description: "Get a paymaster by ID.",
1092
- args: z5.object({
1093
- id: z5.string().describe("Paymaster ID (pay_...)")
1085
+ args: z4.object({
1086
+ id: z4.string().describe("Paymaster ID (pay_...)")
1094
1087
  }),
1095
1088
  examples: [
1096
1089
  { args: { id: "pay_1a2b3c4d" }, description: "Get paymaster details" }
1097
1090
  ],
1098
1091
  output: paymasterItem,
1099
1092
  async run(c) {
1100
- const p = await c.var.openfort.paymasters.get(c.args.id);
1093
+ const p = await getOpenfort().paymasters.get(c.args.id);
1101
1094
  return c.ok({
1102
1095
  id: p.id,
1103
1096
  createdAt: p.createdAt,
@@ -1109,20 +1102,20 @@ paymasters.command("get", {
1109
1102
  });
1110
1103
  paymasters.command("update", {
1111
1104
  description: "Update a paymaster.",
1112
- args: z5.object({
1113
- id: z5.string().describe("Paymaster ID (pay_...)")
1105
+ args: z4.object({
1106
+ id: z4.string().describe("Paymaster ID (pay_...)")
1114
1107
  }),
1115
- options: z5.object({
1116
- address: z5.string().optional().describe("Paymaster address"),
1117
- name: z5.string().optional().describe("New name"),
1118
- url: z5.string().optional().describe("New URL")
1108
+ options: z4.object({
1109
+ address: z4.string().describe("Paymaster address"),
1110
+ name: z4.string().optional().describe("New name"),
1111
+ url: z4.string().optional().describe("New URL")
1119
1112
  }),
1120
1113
  examples: [
1121
1114
  { args: { id: "pay_1a2b3c4d" }, options: { address: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", name: "Updated Paymaster" }, description: "Update paymaster name" }
1122
1115
  ],
1123
1116
  output: paymasterItem,
1124
1117
  async run(c) {
1125
- const res = await c.var.openfort.paymasters.update(c.args.id, {
1118
+ const res = await getOpenfort().paymasters.update(c.args.id, {
1126
1119
  address: c.options.address,
1127
1120
  name: c.options.name,
1128
1121
  url: c.options.url
@@ -1138,57 +1131,56 @@ paymasters.command("update", {
1138
1131
  });
1139
1132
  paymasters.command("delete", {
1140
1133
  description: "Delete a paymaster.",
1141
- args: z5.object({
1142
- id: z5.string().describe("Paymaster ID (pay_...)")
1134
+ args: z4.object({
1135
+ id: z4.string().describe("Paymaster ID (pay_...)")
1143
1136
  }),
1144
1137
  examples: [
1145
1138
  { args: { id: "pay_1a2b3c4d" }, description: "Delete a paymaster" }
1146
1139
  ],
1147
- output: z5.object({
1148
- id: z5.string(),
1149
- deleted: z5.boolean()
1140
+ output: z4.object({
1141
+ id: z4.string(),
1142
+ deleted: z4.boolean()
1150
1143
  }),
1151
1144
  async run(c) {
1152
- const res = await c.var.openfort.paymasters.delete(c.args.id);
1145
+ const res = await getOpenfort().paymasters.delete(c.args.id);
1153
1146
  return c.ok({ id: res.id, deleted: res.deleted });
1154
1147
  }
1155
1148
  });
1156
1149
 
1157
1150
  // src/commands/policies.ts
1158
- import { Cli as Cli4, z as z6 } from "incur";
1151
+ import { Cli as Cli5, z as z5 } from "incur";
1159
1152
  var policyScopes = ["project", "account", "transaction"];
1160
- var policies = Cli4.create("policies", {
1161
- description: "Manage rules and conditions for backend wallets and fee sponsorship.",
1162
- vars: varsSchema
1153
+ var policies = Cli5.create("policies", {
1154
+ description: "Manage rules and conditions for backend wallets and fee sponsorship."
1163
1155
  });
1164
1156
  policies.command("list", {
1165
1157
  description: "List policies.",
1166
- options: z6.object({
1167
- limit: z6.number().optional().describe("Max results"),
1168
- skip: z6.number().optional().describe("Offset"),
1169
- scope: z6.enum(policyScopes).optional().describe("Filter by scope"),
1170
- enabled: z6.boolean().optional().describe("Filter by enabled status")
1158
+ options: z5.object({
1159
+ limit: z5.number().optional().describe("Max results"),
1160
+ skip: z5.number().optional().describe("Offset"),
1161
+ scope: z5.enum(policyScopes).optional().describe("Filter by scope"),
1162
+ enabled: z5.boolean().optional().describe("Filter by enabled status")
1171
1163
  }),
1172
1164
  alias: { limit: "l" },
1173
1165
  examples: [
1174
1166
  { description: "List all policies" },
1175
1167
  { options: { scope: "project", enabled: true }, description: "List enabled project-scope policies" }
1176
1168
  ],
1177
- output: z6.object({
1178
- data: z6.array(z6.object({
1179
- id: z6.string(),
1180
- createdAt: z6.number(),
1181
- scope: z6.string(),
1182
- description: z6.string().nullable(),
1183
- accountId: z6.string().nullable(),
1184
- enabled: z6.boolean(),
1185
- priority: z6.number()
1169
+ output: z5.object({
1170
+ data: z5.array(z5.object({
1171
+ id: z5.string(),
1172
+ createdAt: z5.number(),
1173
+ scope: z5.string(),
1174
+ description: z5.string().nullable(),
1175
+ accountId: z5.string().nullable(),
1176
+ enabled: z5.boolean(),
1177
+ priority: z5.number()
1186
1178
  })),
1187
- total: z6.number()
1179
+ total: z5.number()
1188
1180
  }),
1189
1181
  async run(c) {
1190
1182
  const scopeFilter = c.options.scope ? [c.options.scope] : void 0;
1191
- const res = await c.var.openfort.policies.list({
1183
+ const res = await getOpenfort().policies.list({
1192
1184
  limit: c.options.limit,
1193
1185
  skip: c.options.skip,
1194
1186
  scope: scopeFilter,
@@ -1210,19 +1202,19 @@ policies.command("list", {
1210
1202
  });
1211
1203
  policies.command("create", {
1212
1204
  description: "Create a policy with criteria-based rules.",
1213
- options: z6.object({
1214
- scope: z6.enum(policyScopes).describe("Policy scope"),
1215
- description: z6.string().optional().describe("Policy description"),
1216
- priority: z6.number().optional().describe("Priority (higher = evaluated first)"),
1217
- rules: z6.string().describe("Rules as JSON string")
1205
+ options: z5.object({
1206
+ scope: z5.enum(policyScopes).describe("Policy scope"),
1207
+ description: z5.string().optional().describe("Policy description"),
1208
+ priority: z5.number().optional().describe("Priority (higher = evaluated first)"),
1209
+ rules: z5.string().describe("Rules as JSON string")
1218
1210
  }),
1219
- output: z6.object({
1220
- id: z6.string(),
1221
- createdAt: z6.number(),
1222
- scope: z6.string(),
1223
- description: z6.string().nullable(),
1224
- enabled: z6.boolean(),
1225
- priority: z6.number()
1211
+ output: z5.object({
1212
+ id: z5.string(),
1213
+ createdAt: z5.number(),
1214
+ scope: z5.string(),
1215
+ description: z5.string().nullable(),
1216
+ enabled: z5.boolean(),
1217
+ priority: z5.number()
1226
1218
  }),
1227
1219
  examples: [
1228
1220
  {
@@ -1244,7 +1236,7 @@ policies.command("create", {
1244
1236
  async run(c) {
1245
1237
  const rules = JSON.parse(c.options.rules);
1246
1238
  const scope = c.options.scope;
1247
- const res = await c.var.openfort.policies.create({
1239
+ const res = await getOpenfort().policies.create({
1248
1240
  scope,
1249
1241
  description: c.options.description,
1250
1242
  priority: c.options.priority,
@@ -1273,24 +1265,24 @@ policies.command("create", {
1273
1265
  });
1274
1266
  policies.command("get", {
1275
1267
  description: "Get a policy by ID.",
1276
- args: z6.object({
1277
- id: z6.string().describe("Policy ID (ply_...)")
1268
+ args: z5.object({
1269
+ id: z5.string().describe("Policy ID (ply_...)")
1278
1270
  }),
1279
1271
  examples: [
1280
1272
  { args: { id: "ply_1a2b3c4d" }, description: "Get policy details with rules" }
1281
1273
  ],
1282
- output: z6.object({
1283
- id: z6.string(),
1284
- createdAt: z6.number(),
1285
- scope: z6.string(),
1286
- description: z6.string().nullable(),
1287
- accountId: z6.string().nullable(),
1288
- enabled: z6.boolean(),
1289
- priority: z6.number(),
1290
- rules: z6.array(z6.any())
1274
+ output: z5.object({
1275
+ id: z5.string(),
1276
+ createdAt: z5.number(),
1277
+ scope: z5.string(),
1278
+ description: z5.string().nullable(),
1279
+ accountId: z5.string().nullable(),
1280
+ enabled: z5.boolean(),
1281
+ priority: z5.number(),
1282
+ rules: z5.array(z5.record(z5.string(), z5.unknown()))
1291
1283
  }),
1292
1284
  async run(c) {
1293
- const p = await c.var.openfort.policies.get(c.args.id);
1285
+ const p = await getOpenfort().policies.get(c.args.id);
1294
1286
  return c.ok({
1295
1287
  id: p.id,
1296
1288
  createdAt: p.createdAt,
@@ -1305,29 +1297,29 @@ policies.command("get", {
1305
1297
  });
1306
1298
  policies.command("update", {
1307
1299
  description: "Update a policy.",
1308
- args: z6.object({
1309
- id: z6.string().describe("Policy ID (ply_...)")
1300
+ args: z5.object({
1301
+ id: z5.string().describe("Policy ID (ply_...)")
1310
1302
  }),
1311
- options: z6.object({
1312
- description: z6.string().optional().describe("New description"),
1313
- enabled: z6.boolean().optional().describe("Enable or disable"),
1314
- priority: z6.number().optional().describe("New priority"),
1315
- rules: z6.string().optional().describe("New rules as JSON string")
1303
+ options: z5.object({
1304
+ description: z5.string().optional().describe("New description"),
1305
+ enabled: z5.boolean().optional().describe("Enable or disable"),
1306
+ priority: z5.number().optional().describe("New priority"),
1307
+ rules: z5.string().optional().describe("New rules as JSON string")
1316
1308
  }),
1317
1309
  examples: [
1318
1310
  { args: { id: "ply_1a2b3c4d" }, options: { enabled: false }, description: "Disable a policy" },
1319
1311
  { args: { id: "ply_1a2b3c4d" }, options: { priority: 10 }, description: "Change policy priority" }
1320
1312
  ],
1321
- output: z6.object({
1322
- id: z6.string(),
1323
- createdAt: z6.number(),
1324
- scope: z6.string(),
1325
- description: z6.string().nullable(),
1326
- enabled: z6.boolean(),
1327
- priority: z6.number()
1313
+ output: z5.object({
1314
+ id: z5.string(),
1315
+ createdAt: z5.number(),
1316
+ scope: z5.string(),
1317
+ description: z5.string().nullable(),
1318
+ enabled: z5.boolean(),
1319
+ priority: z5.number()
1328
1320
  }),
1329
1321
  async run(c) {
1330
- const res = await c.var.openfort.policies.update(c.args.id, {
1322
+ const res = await getOpenfort().policies.update(c.args.id, {
1331
1323
  description: c.options.description,
1332
1324
  enabled: c.options.enabled,
1333
1325
  priority: c.options.priority,
@@ -1345,41 +1337,41 @@ policies.command("update", {
1345
1337
  });
1346
1338
  policies.command("delete", {
1347
1339
  description: "Delete a policy.",
1348
- args: z6.object({
1349
- id: z6.string().describe("Policy ID (ply_...)")
1340
+ args: z5.object({
1341
+ id: z5.string().describe("Policy ID (ply_...)")
1350
1342
  }),
1351
1343
  examples: [
1352
1344
  { args: { id: "ply_1a2b3c4d" }, description: "Delete a policy" }
1353
1345
  ],
1354
- output: z6.object({
1355
- id: z6.string(),
1356
- deleted: z6.boolean()
1346
+ output: z5.object({
1347
+ id: z5.string(),
1348
+ deleted: z5.boolean()
1357
1349
  }),
1358
1350
  async run(c) {
1359
- const res = await c.var.openfort.policies.delete(c.args.id);
1351
+ const res = await getOpenfort().policies.delete(c.args.id);
1360
1352
  return c.ok({ id: res.id, deleted: res.deleted });
1361
1353
  }
1362
1354
  });
1363
1355
  policies.command("evaluate", {
1364
1356
  description: "Pre-flight check if an operation would be allowed.",
1365
- options: z6.object({
1366
- operation: z6.string().describe("Operation to evaluate (e.g. signEvmTransaction)"),
1367
- accountId: z6.string().optional().describe("Account ID")
1357
+ options: z5.object({
1358
+ operation: z5.string().describe("Operation to evaluate (e.g. signEvmTransaction)"),
1359
+ accountId: z5.string().optional().describe("Account ID")
1368
1360
  }),
1369
1361
  examples: [
1370
1362
  { options: { operation: "signEvmTransaction", accountId: "acc_1a2b3c4d" }, description: "Check if EVM signing is allowed" },
1371
1363
  { options: { operation: "sponsorEvmTransaction" }, description: "Check if gas sponsorship is allowed" }
1372
1364
  ],
1373
- output: z6.object({
1374
- allowed: z6.boolean(),
1375
- reason: z6.string(),
1376
- operation: z6.string(),
1377
- accountId: z6.string().optional(),
1378
- matchedPolicyId: z6.string().optional(),
1379
- matchedRuleId: z6.string().optional()
1365
+ output: z5.object({
1366
+ allowed: z5.boolean(),
1367
+ reason: z5.string(),
1368
+ operation: z5.string(),
1369
+ accountId: z5.string().optional(),
1370
+ matchedPolicyId: z5.string().optional(),
1371
+ matchedRuleId: z5.string().optional()
1380
1372
  }),
1381
1373
  async run(c) {
1382
- const res = await c.var.openfort.policies.evaluate({
1374
+ const res = await getOpenfort().policies.evaluate({
1383
1375
  operation: c.options.operation,
1384
1376
  accountId: c.options.accountId
1385
1377
  });
@@ -1395,45 +1387,44 @@ policies.command("evaluate", {
1395
1387
  });
1396
1388
 
1397
1389
  // src/commands/sponsorship.ts
1398
- import { Cli as Cli5, z as z7 } from "incur";
1390
+ import { Cli as Cli6, z as z6 } from "incur";
1399
1391
  var sponsorSchemas = ["pay_for_user", "charge_custom_tokens", "fixed_rate"];
1400
- var sponsorshipItem = z7.object({
1401
- id: z7.string(),
1402
- createdAt: z7.number(),
1403
- name: z7.string().nullable(),
1404
- chainId: z7.number().nullable(),
1405
- enabled: z7.boolean(),
1406
- strategy: z7.object({
1407
- sponsorSchema: z7.string(),
1408
- tokenContract: z7.string().optional(),
1409
- tokenContractAmount: z7.string().optional(),
1410
- dynamicExchangeRate: z7.boolean().optional()
1411
- }),
1412
- paymasterId: z7.string().nullable(),
1413
- policyId: z7.string().nullable()
1414
- });
1415
- var sponsorship = Cli5.create("sponsorship", {
1416
- description: "Manage fee sponsorship strategies linked to policies.",
1417
- vars: varsSchema
1392
+ var sponsorshipItem = z6.object({
1393
+ id: z6.string(),
1394
+ createdAt: z6.number(),
1395
+ name: z6.string().nullable(),
1396
+ chainId: z6.number().nullable(),
1397
+ enabled: z6.boolean(),
1398
+ strategy: z6.object({
1399
+ sponsorSchema: z6.string(),
1400
+ tokenContract: z6.string().optional(),
1401
+ tokenContractAmount: z6.string().optional(),
1402
+ dynamicExchangeRate: z6.boolean().optional()
1403
+ }),
1404
+ paymasterId: z6.string().nullable(),
1405
+ policyId: z6.string().nullable()
1406
+ });
1407
+ var sponsorship = Cli6.create("sponsorship", {
1408
+ description: "Manage fee sponsorship strategies linked to policies."
1418
1409
  });
1419
1410
  sponsorship.command("list", {
1420
1411
  description: "List fee sponsorships.",
1421
- options: z7.object({
1422
- limit: z7.number().optional().describe("Max results"),
1423
- skip: z7.number().optional().describe("Offset"),
1424
- enabled: z7.boolean().optional().describe("Filter by enabled status")
1412
+ options: z6.object({
1413
+ limit: z6.number().optional().describe("Max results"),
1414
+ skip: z6.number().optional().describe("Offset"),
1415
+ enabled: z6.boolean().optional().describe("Filter by enabled status")
1425
1416
  }),
1426
1417
  alias: { limit: "l" },
1427
1418
  examples: [
1428
1419
  { description: "List all sponsorships" },
1429
1420
  { options: { enabled: true }, description: "List active sponsorships only" }
1430
1421
  ],
1431
- output: z7.object({
1432
- data: z7.array(sponsorshipItem),
1433
- total: z7.number()
1422
+ output: z6.object({
1423
+ data: z6.array(sponsorshipItem),
1424
+ total: z6.number()
1434
1425
  }),
1435
1426
  async run(c) {
1436
- const res = await c.var.openfort.feeSponsorship.list({
1427
+ const res = await getOpenfort().feeSponsorship.list({
1437
1428
  limit: c.options.limit,
1438
1429
  skip: c.options.skip,
1439
1430
  enabled: c.options.enabled
@@ -1455,11 +1446,11 @@ sponsorship.command("list", {
1455
1446
  });
1456
1447
  sponsorship.command("create", {
1457
1448
  description: "Create a fee sponsorship linked to a policy.",
1458
- options: z7.object({
1459
- policyId: z7.string().describe("Policy ID to link (ply_...)"),
1460
- name: z7.string().optional().describe("Sponsorship name"),
1461
- strategy: z7.enum(sponsorSchemas).default("pay_for_user").describe("Sponsorship strategy"),
1462
- chainId: z7.number().optional().describe("Chain ID")
1449
+ options: z6.object({
1450
+ policyId: z6.string().describe("Policy ID to link (ply_...)"),
1451
+ name: z6.string().optional().describe("Sponsorship name"),
1452
+ strategy: z6.enum(sponsorSchemas).default("pay_for_user").describe("Sponsorship strategy"),
1453
+ chainId: z6.number().optional().describe("Chain ID")
1463
1454
  }),
1464
1455
  output: sponsorshipItem,
1465
1456
  examples: [
@@ -1474,7 +1465,7 @@ sponsorship.command("create", {
1474
1465
  ],
1475
1466
  async run(c) {
1476
1467
  const strategy = { sponsorSchema: c.options.strategy };
1477
- const res = await c.var.openfort.feeSponsorship.create({
1468
+ const res = await getOpenfort().feeSponsorship.create({
1478
1469
  policyId: c.options.policyId,
1479
1470
  name: c.options.name,
1480
1471
  strategy,
@@ -1505,15 +1496,15 @@ sponsorship.command("create", {
1505
1496
  });
1506
1497
  sponsorship.command("get", {
1507
1498
  description: "Get a fee sponsorship by ID.",
1508
- args: z7.object({
1509
- id: z7.string().describe("Fee sponsorship ID (pol_...)")
1499
+ args: z6.object({
1500
+ id: z6.string().describe("Fee sponsorship ID (pol_...)")
1510
1501
  }),
1511
1502
  examples: [
1512
1503
  { args: { id: "pol_1a2b3c4d" }, description: "Get sponsorship details" }
1513
1504
  ],
1514
1505
  output: sponsorshipItem,
1515
1506
  async run(c) {
1516
- const s = await c.var.openfort.feeSponsorship.get(c.args.id);
1507
+ const s = await getOpenfort().feeSponsorship.get(c.args.id);
1517
1508
  return c.ok({
1518
1509
  id: s.id,
1519
1510
  createdAt: s.createdAt,
@@ -1528,13 +1519,13 @@ sponsorship.command("get", {
1528
1519
  });
1529
1520
  sponsorship.command("update", {
1530
1521
  description: "Update a fee sponsorship.",
1531
- args: z7.object({
1532
- id: z7.string().describe("Fee sponsorship ID (pol_...)")
1522
+ args: z6.object({
1523
+ id: z6.string().describe("Fee sponsorship ID (pol_...)")
1533
1524
  }),
1534
- options: z7.object({
1535
- name: z7.string().optional().describe("New name"),
1536
- strategy: z7.enum(sponsorSchemas).optional().describe("New strategy"),
1537
- policyId: z7.string().optional().describe("New policy ID")
1525
+ options: z6.object({
1526
+ name: z6.string().optional().describe("New name"),
1527
+ strategy: z6.enum(sponsorSchemas).optional().describe("New strategy"),
1528
+ policyId: z6.string().optional().describe("New policy ID")
1538
1529
  }),
1539
1530
  examples: [
1540
1531
  { args: { id: "pol_1a2b3c4d" }, options: { name: "Mainnet Gas Sponsor" }, description: "Rename a sponsorship" }
@@ -1542,7 +1533,7 @@ sponsorship.command("update", {
1542
1533
  output: sponsorshipItem,
1543
1534
  async run(c) {
1544
1535
  const strategy = c.options.strategy ? { sponsorSchema: c.options.strategy } : void 0;
1545
- const res = await c.var.openfort.feeSponsorship.update(c.args.id, {
1536
+ const res = await getOpenfort().feeSponsorship.update(c.args.id, {
1546
1537
  name: c.options.name,
1547
1538
  strategy,
1548
1539
  policyId: c.options.policyId
@@ -1561,15 +1552,15 @@ sponsorship.command("update", {
1561
1552
  });
1562
1553
  sponsorship.command("enable", {
1563
1554
  description: "Enable a fee sponsorship.",
1564
- args: z7.object({
1565
- id: z7.string().describe("Fee sponsorship ID (pol_...)")
1555
+ args: z6.object({
1556
+ id: z6.string().describe("Fee sponsorship ID (pol_...)")
1566
1557
  }),
1567
1558
  examples: [
1568
1559
  { args: { id: "pol_1a2b3c4d" }, description: "Enable a sponsorship" }
1569
1560
  ],
1570
1561
  output: sponsorshipItem,
1571
1562
  async run(c) {
1572
- const res = await c.var.openfort.feeSponsorship.enable(c.args.id);
1563
+ const res = await getOpenfort().feeSponsorship.enable(c.args.id);
1573
1564
  return c.ok({
1574
1565
  id: res.id,
1575
1566
  createdAt: res.createdAt,
@@ -1584,15 +1575,15 @@ sponsorship.command("enable", {
1584
1575
  });
1585
1576
  sponsorship.command("disable", {
1586
1577
  description: "Disable a fee sponsorship.",
1587
- args: z7.object({
1588
- id: z7.string().describe("Fee sponsorship ID (pol_...)")
1578
+ args: z6.object({
1579
+ id: z6.string().describe("Fee sponsorship ID (pol_...)")
1589
1580
  }),
1590
1581
  examples: [
1591
1582
  { args: { id: "pol_1a2b3c4d" }, description: "Disable a sponsorship" }
1592
1583
  ],
1593
1584
  output: sponsorshipItem,
1594
1585
  async run(c) {
1595
- const res = await c.var.openfort.feeSponsorship.disable(c.args.id);
1586
+ const res = await getOpenfort().feeSponsorship.disable(c.args.id);
1596
1587
  return c.ok({
1597
1588
  id: res.id,
1598
1589
  createdAt: res.createdAt,
@@ -1607,24 +1598,24 @@ sponsorship.command("disable", {
1607
1598
  });
1608
1599
  sponsorship.command("delete", {
1609
1600
  description: "Delete a fee sponsorship.",
1610
- args: z7.object({
1611
- id: z7.string().describe("Fee sponsorship ID (pol_...)")
1601
+ args: z6.object({
1602
+ id: z6.string().describe("Fee sponsorship ID (pol_...)")
1612
1603
  }),
1613
1604
  examples: [
1614
1605
  { args: { id: "pol_1a2b3c4d" }, description: "Delete a sponsorship" }
1615
1606
  ],
1616
- output: z7.object({
1617
- id: z7.string(),
1618
- deleted: z7.boolean()
1607
+ output: z6.object({
1608
+ id: z6.string(),
1609
+ deleted: z6.boolean()
1619
1610
  }),
1620
1611
  async run(c) {
1621
- const res = await c.var.openfort.feeSponsorship.delete(c.args.id);
1612
+ const res = await getOpenfort().feeSponsorship.delete(c.args.id);
1622
1613
  return c.ok({ id: res.id, deleted: res.deleted });
1623
1614
  }
1624
1615
  });
1625
1616
 
1626
1617
  // src/commands/subscriptions.ts
1627
- import { Cli as Cli6, z as z8 } from "incur";
1618
+ import { Cli as Cli7, z as z7 } from "incur";
1628
1619
  var apiTopics = [
1629
1620
  "transaction_intent.broadcast",
1630
1621
  "transaction_intent.successful",
@@ -1640,28 +1631,27 @@ var apiTopics = [
1640
1631
  "account.created"
1641
1632
  ];
1642
1633
  var apiTriggerTypes = ["webhook", "email"];
1643
- var triggers = Cli6.create("triggers", {
1644
- description: "Manage subscription triggers.",
1645
- vars: varsSchema
1634
+ var triggers = Cli7.create("triggers", {
1635
+ description: "Manage subscription triggers."
1646
1636
  });
1647
1637
  triggers.command("list", {
1648
1638
  description: "List triggers for a subscription.",
1649
- args: z8.object({
1650
- subscriptionId: z8.string().describe("Subscription ID (sub_...)")
1639
+ args: z7.object({
1640
+ subscriptionId: z7.string().describe("Subscription ID (sub_...)")
1651
1641
  }),
1652
1642
  examples: [
1653
1643
  { args: { subscriptionId: "sub_1a2b3c4d" }, description: "List triggers" }
1654
1644
  ],
1655
- output: z8.object({
1656
- data: z8.array(z8.object({
1657
- id: z8.string(),
1658
- createdAt: z8.number(),
1659
- target: z8.string(),
1660
- type: z8.string()
1645
+ output: z7.object({
1646
+ data: z7.array(z7.object({
1647
+ id: z7.string(),
1648
+ createdAt: z7.number(),
1649
+ target: z7.string(),
1650
+ type: z7.string()
1661
1651
  }))
1662
1652
  }),
1663
1653
  async run(c) {
1664
- const res = await c.var.openfort.triggers.list(c.args.subscriptionId);
1654
+ const res = await getOpenfort().triggers.list(c.args.subscriptionId);
1665
1655
  return c.ok({
1666
1656
  data: res.data.map((t) => ({
1667
1657
  id: t.id,
@@ -1674,12 +1664,12 @@ triggers.command("list", {
1674
1664
  });
1675
1665
  triggers.command("create", {
1676
1666
  description: "Create a trigger for a subscription.",
1677
- args: z8.object({
1678
- subscriptionId: z8.string().describe("Subscription ID (sub_...)")
1667
+ args: z7.object({
1668
+ subscriptionId: z7.string().describe("Subscription ID (sub_...)")
1679
1669
  }),
1680
- options: z8.object({
1681
- target: z8.string().describe("Webhook URL or email address"),
1682
- type: z8.enum(apiTriggerTypes).default("webhook").describe("Trigger type: webhook or email")
1670
+ options: z7.object({
1671
+ target: z7.string().describe("Webhook URL or email address"),
1672
+ type: z7.enum(apiTriggerTypes).default("webhook").describe("Trigger type: webhook or email")
1683
1673
  }),
1684
1674
  examples: [
1685
1675
  {
@@ -1688,14 +1678,14 @@ triggers.command("create", {
1688
1678
  description: "Create a webhook trigger"
1689
1679
  }
1690
1680
  ],
1691
- output: z8.object({
1692
- id: z8.string(),
1693
- createdAt: z8.number(),
1694
- target: z8.string(),
1695
- type: z8.string()
1681
+ output: z7.object({
1682
+ id: z7.string(),
1683
+ createdAt: z7.number(),
1684
+ target: z7.string(),
1685
+ type: z7.string()
1696
1686
  }),
1697
1687
  async run(c) {
1698
- const res = await c.var.openfort.triggers.create(c.args.subscriptionId, {
1688
+ const res = await getOpenfort().triggers.create(c.args.subscriptionId, {
1699
1689
  target: c.options.target,
1700
1690
  type: c.options.type
1701
1691
  });
@@ -1709,21 +1699,21 @@ triggers.command("create", {
1709
1699
  });
1710
1700
  triggers.command("get", {
1711
1701
  description: "Get a trigger by ID.",
1712
- args: z8.object({
1713
- subscriptionId: z8.string().describe("Subscription ID (sub_...)"),
1714
- triggerId: z8.string().describe("Trigger ID (tri_...)")
1702
+ args: z7.object({
1703
+ subscriptionId: z7.string().describe("Subscription ID (sub_...)"),
1704
+ triggerId: z7.string().describe("Trigger ID (tri_...)")
1715
1705
  }),
1716
1706
  examples: [
1717
1707
  { args: { subscriptionId: "sub_1a2b3c4d", triggerId: "tri_1a2b3c4d" }, description: "Get trigger details" }
1718
1708
  ],
1719
- output: z8.object({
1720
- id: z8.string(),
1721
- createdAt: z8.number(),
1722
- target: z8.string(),
1723
- type: z8.string()
1709
+ output: z7.object({
1710
+ id: z7.string(),
1711
+ createdAt: z7.number(),
1712
+ target: z7.string(),
1713
+ type: z7.string()
1724
1714
  }),
1725
1715
  async run(c) {
1726
- const t = await c.var.openfort.triggers.get(c.args.subscriptionId, c.args.triggerId);
1716
+ const t = await getOpenfort().triggers.get(c.args.subscriptionId, c.args.triggerId);
1727
1717
  return c.ok({
1728
1718
  id: t.id,
1729
1719
  createdAt: t.createdAt,
@@ -1734,46 +1724,45 @@ triggers.command("get", {
1734
1724
  });
1735
1725
  triggers.command("delete", {
1736
1726
  description: "Delete a trigger.",
1737
- args: z8.object({
1738
- subscriptionId: z8.string().describe("Subscription ID (sub_...)"),
1739
- triggerId: z8.string().describe("Trigger ID (tri_...)")
1727
+ args: z7.object({
1728
+ subscriptionId: z7.string().describe("Subscription ID (sub_...)"),
1729
+ triggerId: z7.string().describe("Trigger ID (tri_...)")
1740
1730
  }),
1741
1731
  examples: [
1742
1732
  { args: { subscriptionId: "sub_1a2b3c4d", triggerId: "tri_1a2b3c4d" }, description: "Delete a trigger" }
1743
1733
  ],
1744
- output: z8.object({
1745
- id: z8.string(),
1746
- deleted: z8.boolean()
1734
+ output: z7.object({
1735
+ id: z7.string(),
1736
+ deleted: z7.boolean()
1747
1737
  }),
1748
1738
  async run(c) {
1749
- const res = await c.var.openfort.triggers.delete(c.args.subscriptionId, c.args.triggerId);
1739
+ const res = await getOpenfort().triggers.delete(c.args.subscriptionId, c.args.triggerId);
1750
1740
  return c.ok({ id: res.id, deleted: res.deleted });
1751
1741
  }
1752
1742
  });
1753
- var subscriptions = Cli6.create("subscriptions", {
1754
- description: "Manage webhook subscriptions.",
1755
- vars: varsSchema
1743
+ var subscriptions = Cli7.create("subscriptions", {
1744
+ description: "Manage webhook subscriptions."
1756
1745
  });
1757
1746
  subscriptions.command("list", {
1758
1747
  description: "List webhook subscriptions.",
1759
1748
  examples: [
1760
1749
  { description: "List all subscriptions" }
1761
1750
  ],
1762
- output: z8.object({
1763
- data: z8.array(z8.object({
1764
- id: z8.string(),
1765
- createdAt: z8.number(),
1766
- topic: z8.string(),
1767
- triggers: z8.array(z8.object({
1768
- id: z8.string(),
1769
- target: z8.string(),
1770
- type: z8.string()
1751
+ output: z7.object({
1752
+ data: z7.array(z7.object({
1753
+ id: z7.string(),
1754
+ createdAt: z7.number(),
1755
+ topic: z7.string(),
1756
+ triggers: z7.array(z7.object({
1757
+ id: z7.string(),
1758
+ target: z7.string(),
1759
+ type: z7.string()
1771
1760
  }))
1772
1761
  })),
1773
- total: z8.number()
1762
+ total: z7.number()
1774
1763
  }),
1775
1764
  async run(c) {
1776
- const res = await c.var.openfort.subscriptions.list();
1765
+ const res = await getOpenfort().subscriptions.list();
1777
1766
  return c.ok({
1778
1767
  data: res.data.map((s) => ({
1779
1768
  id: s.id,
@@ -1787,9 +1776,9 @@ subscriptions.command("list", {
1787
1776
  });
1788
1777
  subscriptions.command("create", {
1789
1778
  description: "Create a webhook subscription.",
1790
- options: z8.object({
1791
- topic: z8.enum(apiTopics).describe("Event topic (e.g. transaction_intent.successful, user.created)"),
1792
- triggers: z8.string().describe('Triggers as JSON: [{"type":"webhook","target":"https://..."}]')
1779
+ options: z7.object({
1780
+ topic: z7.enum(apiTopics).describe("Event topic (e.g. transaction_intent.successful, user.created)"),
1781
+ triggers: z7.string().describe('Triggers as JSON: [{"type":"webhook","target":"https://..."}]')
1793
1782
  }),
1794
1783
  examples: [
1795
1784
  {
@@ -1800,19 +1789,19 @@ subscriptions.command("create", {
1800
1789
  description: "Get notified when transactions succeed"
1801
1790
  }
1802
1791
  ],
1803
- output: z8.object({
1804
- id: z8.string(),
1805
- createdAt: z8.number(),
1806
- topic: z8.string(),
1807
- triggers: z8.array(z8.object({
1808
- id: z8.string(),
1809
- target: z8.string(),
1810
- type: z8.string()
1792
+ output: z7.object({
1793
+ id: z7.string(),
1794
+ createdAt: z7.number(),
1795
+ topic: z7.string(),
1796
+ triggers: z7.array(z7.object({
1797
+ id: z7.string(),
1798
+ target: z7.string(),
1799
+ type: z7.string()
1811
1800
  }))
1812
1801
  }),
1813
1802
  async run(c) {
1814
1803
  const parsedTriggers = JSON.parse(c.options.triggers);
1815
- const res = await c.var.openfort.subscriptions.create({
1804
+ const res = await getOpenfort().subscriptions.create({
1816
1805
  topic: c.options.topic,
1817
1806
  triggers: parsedTriggers
1818
1807
  });
@@ -1837,24 +1826,24 @@ subscriptions.command("create", {
1837
1826
  });
1838
1827
  subscriptions.command("get", {
1839
1828
  description: "Get a subscription by ID.",
1840
- args: z8.object({
1841
- id: z8.string().describe("Subscription ID (sub_...)")
1829
+ args: z7.object({
1830
+ id: z7.string().describe("Subscription ID (sub_...)")
1842
1831
  }),
1843
1832
  examples: [
1844
1833
  { args: { id: "sub_1a2b3c4d" }, description: "Get subscription details" }
1845
1834
  ],
1846
- output: z8.object({
1847
- id: z8.string(),
1848
- createdAt: z8.number(),
1849
- topic: z8.string(),
1850
- triggers: z8.array(z8.object({
1851
- id: z8.string(),
1852
- target: z8.string(),
1853
- type: z8.string()
1835
+ output: z7.object({
1836
+ id: z7.string(),
1837
+ createdAt: z7.number(),
1838
+ topic: z7.string(),
1839
+ triggers: z7.array(z7.object({
1840
+ id: z7.string(),
1841
+ target: z7.string(),
1842
+ type: z7.string()
1854
1843
  }))
1855
1844
  }),
1856
1845
  async run(c) {
1857
- const s = await c.var.openfort.subscriptions.get(c.args.id);
1846
+ const s = await getOpenfort().subscriptions.get(c.args.id);
1858
1847
  return c.ok({
1859
1848
  id: s.id,
1860
1849
  createdAt: s.createdAt,
@@ -1865,65 +1854,64 @@ subscriptions.command("get", {
1865
1854
  });
1866
1855
  subscriptions.command("delete", {
1867
1856
  description: "Delete a subscription.",
1868
- args: z8.object({
1869
- id: z8.string().describe("Subscription ID (sub_...)")
1857
+ args: z7.object({
1858
+ id: z7.string().describe("Subscription ID (sub_...)")
1870
1859
  }),
1871
1860
  examples: [
1872
1861
  { args: { id: "sub_1a2b3c4d" }, description: "Delete a subscription" }
1873
1862
  ],
1874
- output: z8.object({
1875
- id: z8.string(),
1876
- deleted: z8.boolean()
1863
+ output: z7.object({
1864
+ id: z7.string(),
1865
+ deleted: z7.boolean()
1877
1866
  }),
1878
1867
  async run(c) {
1879
- const res = await c.var.openfort.subscriptions.delete(c.args.id);
1868
+ const res = await getOpenfort().subscriptions.delete(c.args.id);
1880
1869
  return c.ok({ id: res.id, deleted: res.deleted });
1881
1870
  }
1882
1871
  });
1883
1872
  subscriptions.command(triggers);
1884
1873
 
1885
1874
  // src/commands/sessions.ts
1886
- import { Cli as Cli7, z as z9 } from "incur";
1887
- var sessionItem = z9.object({
1888
- id: z9.string(),
1889
- createdAt: z9.number(),
1890
- updatedAt: z9.number(),
1891
- address: z9.string(),
1892
- validAfter: z9.string(),
1893
- validUntil: z9.string(),
1894
- whitelist: z9.array(z9.string()).optional(),
1895
- isActive: z9.boolean(),
1896
- nextAction: z9.object({
1897
- type: z9.string(),
1898
- payload: z9.any().optional()
1875
+ import { Cli as Cli8, z as z8 } from "incur";
1876
+ var sessionItem = z8.object({
1877
+ id: z8.string(),
1878
+ createdAt: z8.number(),
1879
+ updatedAt: z8.number(),
1880
+ address: z8.string(),
1881
+ validAfter: z8.string(),
1882
+ validUntil: z8.string(),
1883
+ whitelist: z8.array(z8.string()).optional(),
1884
+ isActive: z8.boolean(),
1885
+ nextAction: z8.object({
1886
+ type: z8.string(),
1887
+ payload: z8.record(z8.string(), z8.unknown()).optional()
1899
1888
  }).optional()
1900
1889
  });
1901
- var sessions = Cli7.create("sessions", {
1902
- description: "Manage session keys.",
1903
- vars: varsSchema
1890
+ var sessions = Cli8.create("sessions", {
1891
+ description: "Manage session keys."
1904
1892
  });
1905
1893
  sessions.command("list", {
1906
1894
  description: "List session keys for a player.",
1907
- options: z9.object({
1908
- player: z9.string().describe("Player ID (pla_...)"),
1909
- limit: z9.number().optional().describe("Max results"),
1910
- skip: z9.number().optional().describe("Offset")
1895
+ options: z8.object({
1896
+ player: z8.string().describe("Player ID (pla_...)"),
1897
+ limit: z8.number().optional().describe("Max results"),
1898
+ skip: z8.number().optional().describe("Offset")
1911
1899
  }),
1912
1900
  alias: { limit: "l" },
1913
1901
  examples: [
1914
1902
  { options: { player: "pla_1a2b3c4d" }, description: "List sessions for a player" }
1915
1903
  ],
1916
- output: z9.object({
1917
- data: z9.array(z9.object({
1918
- id: z9.string(),
1919
- createdAt: z9.number(),
1920
- address: z9.string(),
1921
- isActive: z9.boolean()
1904
+ output: z8.object({
1905
+ data: z8.array(z8.object({
1906
+ id: z8.string(),
1907
+ createdAt: z8.number(),
1908
+ address: z8.string(),
1909
+ isActive: z8.boolean()
1922
1910
  })),
1923
- total: z9.number()
1911
+ total: z8.number()
1924
1912
  }),
1925
1913
  async run(c) {
1926
- const res = await c.var.openfort.sessions.list({
1914
+ const res = await getOpenfort().sessions.list({
1927
1915
  player: c.options.player,
1928
1916
  limit: c.options.limit,
1929
1917
  skip: c.options.skip
@@ -1941,16 +1929,16 @@ sessions.command("list", {
1941
1929
  });
1942
1930
  sessions.command("create", {
1943
1931
  description: "Create a session key.",
1944
- options: z9.object({
1945
- address: z9.string().describe("Session key address"),
1946
- chainId: z9.number().describe("Chain ID"),
1947
- validAfter: z9.number().describe("Valid after (unix timestamp in seconds)"),
1948
- validUntil: z9.number().describe("Valid until (unix timestamp in seconds)"),
1949
- player: z9.string().optional().describe("Player ID (pla_...)"),
1950
- account: z9.string().optional().describe("Account ID (acc_...)"),
1951
- limit: z9.number().optional().describe("Max session uses"),
1952
- policy: z9.string().optional().describe("Fee sponsorship ID (pol_...)"),
1953
- whitelist: z9.string().optional().describe("Whitelisted contract addresses as JSON array")
1932
+ options: z8.object({
1933
+ address: z8.string().describe("Session key address"),
1934
+ chainId: z8.number().describe("Chain ID"),
1935
+ validAfter: z8.number().describe("Valid after (unix timestamp in seconds)"),
1936
+ validUntil: z8.number().describe("Valid until (unix timestamp in seconds)"),
1937
+ player: z8.string().optional().describe("Player ID (pla_...)"),
1938
+ account: z8.string().optional().describe("Account ID (acc_...)"),
1939
+ limit: z8.number().optional().describe("Max session uses"),
1940
+ policy: z8.string().optional().describe("Fee sponsorship ID (pol_...)"),
1941
+ whitelist: z8.string().optional().describe("Whitelisted contract addresses as JSON array")
1954
1942
  }),
1955
1943
  examples: [
1956
1944
  {
@@ -1966,7 +1954,7 @@ sessions.command("create", {
1966
1954
  ],
1967
1955
  output: sessionItem,
1968
1956
  async run(c) {
1969
- const res = await c.var.openfort.sessions.create({
1957
+ const res = await getOpenfort().sessions.create({
1970
1958
  address: c.options.address,
1971
1959
  chainId: c.options.chainId,
1972
1960
  validAfter: c.options.validAfter,
@@ -2002,15 +1990,15 @@ sessions.command("create", {
2002
1990
  });
2003
1991
  sessions.command("get", {
2004
1992
  description: "Get a session key by ID.",
2005
- args: z9.object({
2006
- id: z9.string().describe("Session ID (ses_...)")
1993
+ args: z8.object({
1994
+ id: z8.string().describe("Session ID (ses_...)")
2007
1995
  }),
2008
1996
  examples: [
2009
1997
  { args: { id: "ses_1a2b3c4d" }, description: "Get session details" }
2010
1998
  ],
2011
1999
  output: sessionItem,
2012
2000
  async run(c) {
2013
- const s = await c.var.openfort.sessions.get(c.args.id);
2001
+ const s = await getOpenfort().sessions.get(c.args.id);
2014
2002
  return c.ok({
2015
2003
  id: s.id,
2016
2004
  createdAt: s.createdAt,
@@ -2026,18 +2014,18 @@ sessions.command("get", {
2026
2014
  });
2027
2015
  sessions.command("revoke", {
2028
2016
  description: "Revoke a session key.",
2029
- options: z9.object({
2030
- address: z9.string().describe("Session key address to revoke"),
2031
- chainId: z9.number().describe("Chain ID"),
2032
- player: z9.string().optional().describe("Player ID (pla_...)"),
2033
- policy: z9.string().optional().describe("Fee sponsorship ID (pol_...)")
2017
+ options: z8.object({
2018
+ address: z8.string().describe("Session key address to revoke"),
2019
+ chainId: z8.number().describe("Chain ID"),
2020
+ player: z8.string().optional().describe("Player ID (pla_...)"),
2021
+ policy: z8.string().optional().describe("Fee sponsorship ID (pol_...)")
2034
2022
  }),
2035
2023
  examples: [
2036
2024
  { options: { address: "0x1234...", chainId: 137 }, description: "Revoke a session key" }
2037
2025
  ],
2038
2026
  output: sessionItem,
2039
2027
  async run(c) {
2040
- const res = await c.var.openfort.sessions.revoke({
2028
+ const res = await getOpenfort().sessions.revoke({
2041
2029
  address: c.options.address,
2042
2030
  chainId: c.options.chainId,
2043
2031
  player: c.options.player,
@@ -2058,19 +2046,19 @@ sessions.command("revoke", {
2058
2046
  });
2059
2047
  sessions.command("sign", {
2060
2048
  description: "Sign and broadcast a session userOperationHash.",
2061
- args: z9.object({
2062
- id: z9.string().describe("Session ID (ses_...)")
2049
+ args: z8.object({
2050
+ id: z8.string().describe("Session ID (ses_...)")
2063
2051
  }),
2064
- options: z9.object({
2065
- signature: z9.string().describe("Hex signature"),
2066
- optimistic: z9.boolean().optional().describe("Return before on-chain confirmation")
2052
+ options: z8.object({
2053
+ signature: z8.string().describe("Hex signature"),
2054
+ optimistic: z8.boolean().optional().describe("Return before on-chain confirmation")
2067
2055
  }),
2068
2056
  examples: [
2069
2057
  { args: { id: "ses_1a2b3c4d" }, options: { signature: "0xabcd1234..." }, description: "Sign a session" }
2070
2058
  ],
2071
2059
  output: sessionItem,
2072
2060
  async run(c) {
2073
- const res = await c.var.openfort.sessions.signature(c.args.id, {
2061
+ const res = await getOpenfort().sessions.signature(c.args.id, {
2074
2062
  signature: c.options.signature,
2075
2063
  optimistic: c.options.optimistic
2076
2064
  });
@@ -2089,61 +2077,60 @@ sessions.command("sign", {
2089
2077
  });
2090
2078
 
2091
2079
  // src/commands/transactions.ts
2092
- import { Cli as Cli8, z as z10 } from "incur";
2093
- var transactionIntentItem = z10.object({
2094
- id: z10.string(),
2095
- createdAt: z10.number(),
2096
- updatedAt: z10.number(),
2097
- chainId: z10.number(),
2098
- abstractionType: z10.string().describe("e.g. accountAbstractionV6, standard"),
2099
- userOperationHash: z10.string().optional(),
2100
- response: z10.object({
2101
- createdAt: z10.number(),
2102
- blockNumber: z10.number().optional(),
2103
- transactionHash: z10.string().optional(),
2104
- gasUsed: z10.string().optional(),
2105
- gasFee: z10.string().optional(),
2106
- status: z10.number().optional(),
2107
- to: z10.string().optional(),
2108
- error: z10.any().optional()
2080
+ import { Cli as Cli9, z as z9 } from "incur";
2081
+ var transactionIntentItem = z9.object({
2082
+ id: z9.string(),
2083
+ createdAt: z9.number(),
2084
+ updatedAt: z9.number(),
2085
+ chainId: z9.number(),
2086
+ abstractionType: z9.string().describe("e.g. accountAbstractionV6, standard"),
2087
+ userOperationHash: z9.string().optional(),
2088
+ response: z9.object({
2089
+ createdAt: z9.number(),
2090
+ blockNumber: z9.number().optional(),
2091
+ transactionHash: z9.string().optional(),
2092
+ gasUsed: z9.string().optional(),
2093
+ gasFee: z9.string().optional(),
2094
+ status: z9.number().optional(),
2095
+ to: z9.string().optional(),
2096
+ error: z9.record(z9.string(), z9.unknown()).optional()
2109
2097
  }).optional(),
2110
- interactions: z10.array(z10.object({
2111
- to: z10.string().optional(),
2112
- data: z10.string().optional(),
2113
- value: z10.string().optional()
2098
+ interactions: z9.array(z9.object({
2099
+ to: z9.string().optional(),
2100
+ data: z9.string().optional(),
2101
+ value: z9.string().optional()
2114
2102
  })).optional(),
2115
- nextAction: z10.object({
2116
- type: z10.string(),
2117
- payload: z10.any().optional()
2103
+ nextAction: z9.object({
2104
+ type: z9.string(),
2105
+ payload: z9.record(z9.string(), z9.unknown()).optional()
2118
2106
  }).optional()
2119
2107
  });
2120
- var transactions = Cli8.create("transactions", {
2121
- description: "Manage transaction intents.",
2122
- vars: varsSchema
2108
+ var transactions = Cli9.create("transactions", {
2109
+ description: "Manage transaction intents."
2123
2110
  });
2124
2111
  transactions.command("list", {
2125
2112
  description: "List transaction intents.",
2126
- options: z10.object({
2127
- limit: z10.number().optional().describe("Max results"),
2128
- skip: z10.number().optional().describe("Offset")
2113
+ options: z9.object({
2114
+ limit: z9.number().optional().describe("Max results"),
2115
+ skip: z9.number().optional().describe("Offset")
2129
2116
  }),
2130
2117
  alias: { limit: "l" },
2131
2118
  examples: [
2132
2119
  { description: "List all transactions" },
2133
2120
  { options: { limit: 10 }, description: "List last 10 transactions" }
2134
2121
  ],
2135
- output: z10.object({
2136
- data: z10.array(z10.object({
2137
- id: z10.string(),
2138
- createdAt: z10.number(),
2139
- updatedAt: z10.number(),
2140
- chainId: z10.number(),
2141
- abstractionType: z10.string()
2122
+ output: z9.object({
2123
+ data: z9.array(z9.object({
2124
+ id: z9.string(),
2125
+ createdAt: z9.number(),
2126
+ updatedAt: z9.number(),
2127
+ chainId: z9.number(),
2128
+ abstractionType: z9.string()
2142
2129
  })),
2143
- total: z10.number()
2130
+ total: z9.number()
2144
2131
  }),
2145
2132
  async run(c) {
2146
- const res = await c.var.openfort.transactionIntents.list({
2133
+ const res = await getOpenfort().transactionIntents.list({
2147
2134
  limit: c.options.limit,
2148
2135
  skip: c.options.skip
2149
2136
  });
@@ -2161,12 +2148,12 @@ transactions.command("list", {
2161
2148
  });
2162
2149
  transactions.command("create", {
2163
2150
  description: "Create a transaction intent.",
2164
- options: z10.object({
2165
- account: z10.string().describe("Account ID (acc_...)"),
2166
- chainId: z10.number().describe("Chain ID"),
2167
- interactions: z10.string().describe('Interactions as JSON: [{"to":"0x...","data":"0x...","value":"0"}]'),
2168
- policy: z10.string().optional().describe("Fee sponsorship ID (pol_...)."),
2169
- signedAuthorization: z10.string().optional().describe("Signed EIP-7702 authorization hex (for delegated accounts)")
2151
+ options: z9.object({
2152
+ account: z9.string().describe("Account ID (acc_...)"),
2153
+ chainId: z9.number().describe("Chain ID"),
2154
+ interactions: z9.string().describe('Interactions as JSON: [{"to":"0x...","data":"0x...","value":"0"}]'),
2155
+ policy: z9.string().optional().describe("Fee sponsorship ID (pol_...)."),
2156
+ signedAuthorization: z9.string().optional().describe("Signed EIP-7702 authorization hex (for delegated accounts)")
2170
2157
  }),
2171
2158
  output: transactionIntentItem,
2172
2159
  examples: [
@@ -2190,7 +2177,7 @@ transactions.command("create", {
2190
2177
  ],
2191
2178
  async run(c) {
2192
2179
  const interactions = JSON.parse(c.options.interactions);
2193
- const res = await c.var.openfort.transactionIntents.create({
2180
+ const res = await getOpenfort().transactionIntents.create({
2194
2181
  account: c.options.account,
2195
2182
  chainId: c.options.chainId,
2196
2183
  interactions,
@@ -2222,15 +2209,15 @@ transactions.command("create", {
2222
2209
  });
2223
2210
  transactions.command("get", {
2224
2211
  description: "Get a transaction intent by ID.",
2225
- args: z10.object({
2226
- id: z10.string().describe("Transaction intent ID (tin_...)")
2212
+ args: z9.object({
2213
+ id: z9.string().describe("Transaction intent ID (tin_...)")
2227
2214
  }),
2228
2215
  examples: [
2229
2216
  { args: { id: "tin_1a2b3c4d" }, description: "Get transaction status and receipt" }
2230
2217
  ],
2231
2218
  output: transactionIntentItem,
2232
2219
  async run(c) {
2233
- const t = await c.var.openfort.transactionIntents.get(c.args.id);
2220
+ const t = await getOpenfort().transactionIntents.get(c.args.id);
2234
2221
  return c.ok({
2235
2222
  id: t.id,
2236
2223
  createdAt: t.createdAt,
@@ -2246,12 +2233,12 @@ transactions.command("get", {
2246
2233
  });
2247
2234
  transactions.command("sign", {
2248
2235
  description: "Sign and broadcast a transaction intent.",
2249
- args: z10.object({
2250
- id: z10.string().describe("Transaction intent ID (tin_...)")
2236
+ args: z9.object({
2237
+ id: z9.string().describe("Transaction intent ID (tin_...)")
2251
2238
  }),
2252
- options: z10.object({
2253
- signature: z10.string().describe("Hex signature"),
2254
- optimistic: z10.boolean().optional().describe("Return before on-chain confirmation")
2239
+ options: z9.object({
2240
+ signature: z9.string().describe("Hex signature"),
2241
+ optimistic: z9.boolean().optional().describe("Return before on-chain confirmation")
2255
2242
  }),
2256
2243
  examples: [
2257
2244
  { args: { id: "tin_1a2b3c4d" }, options: { signature: "0xabcd1234..." }, description: "Sign and broadcast a transaction" },
@@ -2259,7 +2246,7 @@ transactions.command("sign", {
2259
2246
  ],
2260
2247
  output: transactionIntentItem,
2261
2248
  async run(c) {
2262
- const res = await c.var.openfort.transactionIntents.signature(c.args.id, {
2249
+ const res = await getOpenfort().transactionIntents.signature(c.args.id, {
2263
2250
  signature: c.options.signature,
2264
2251
  optimistic: c.options.optimistic
2265
2252
  });
@@ -2288,11 +2275,11 @@ transactions.command("sign", {
2288
2275
  });
2289
2276
  transactions.command("estimate", {
2290
2277
  description: "Estimate gas cost for a transaction.",
2291
- options: z10.object({
2292
- account: z10.string().describe("Account ID (acc_...)"),
2293
- chainId: z10.number().describe("Chain ID"),
2294
- interactions: z10.string().describe("Interactions as JSON"),
2295
- policy: z10.string().optional().describe("Fee sponsorship ID (pol_...)")
2278
+ options: z9.object({
2279
+ account: z9.string().describe("Account ID (acc_...)"),
2280
+ chainId: z9.number().describe("Chain ID"),
2281
+ interactions: z9.string().describe("Interactions as JSON"),
2282
+ policy: z9.string().optional().describe("Fee sponsorship ID (pol_...)")
2296
2283
  }),
2297
2284
  examples: [
2298
2285
  {
@@ -2300,16 +2287,16 @@ transactions.command("estimate", {
2300
2287
  description: "Estimate gas for a USDC transfer on Polygon"
2301
2288
  }
2302
2289
  ],
2303
- output: z10.object({
2304
- estimatedTXGas: z10.string(),
2305
- estimatedTXGasFee: z10.string(),
2306
- estimatedTXGasFeeUSD: z10.string(),
2307
- estimatedTXGasFeeToken: z10.string().optional(),
2308
- gasPrice: z10.string()
2290
+ output: z9.object({
2291
+ estimatedTXGas: z9.string(),
2292
+ estimatedTXGasFee: z9.string(),
2293
+ estimatedTXGasFeeUSD: z9.string(),
2294
+ estimatedTXGasFeeToken: z9.string().optional(),
2295
+ gasPrice: z9.string()
2309
2296
  }),
2310
2297
  async run(c) {
2311
2298
  const interactions = JSON.parse(c.options.interactions);
2312
- const res = await c.var.openfort.transactionIntents.estimateCost({
2299
+ const res = await getOpenfort().transactionIntents.estimateCost({
2313
2300
  account: c.options.account,
2314
2301
  chainId: c.options.chainId,
2315
2302
  interactions,
@@ -2326,21 +2313,19 @@ transactions.command("estimate", {
2326
2313
  });
2327
2314
 
2328
2315
  // src/commands/embedded-wallet.ts
2329
- import { Cli as Cli9, z as z11, Errors as Errors2 } from "incur";
2330
- var SHIELD_API_URL = OPENFORT_SHIELD_URL;
2331
- var embeddedWallet = Cli9.create("embedded-wallet", {
2332
- description: "Configure embedded wallet (Shield) API keys.",
2333
- vars: varsSchema
2316
+ import { Cli as Cli10, z as z10, Errors } from "incur";
2317
+ var embeddedWallet = Cli10.create("embedded-wallet", {
2318
+ description: "Configure embedded wallet (Shield) API keys."
2334
2319
  });
2335
2320
  embeddedWallet.command("setup", {
2336
2321
  description: "Generate and register embedded wallet (Shield) API keys.",
2337
- options: z11.object({
2338
- project: z11.string().optional().describe("Project ID (pro_...). Defaults to OPENFORT_PROJECT_ID env var.")
2322
+ options: z10.object({
2323
+ project: z10.string().optional().describe("Project ID (pro_...). Defaults to OPENFORT_PROJECT_ID env var.")
2339
2324
  }),
2340
2325
  alias: { project: "p" },
2341
- output: z11.object({
2342
- message: z11.string(),
2343
- credentialsPath: z11.string()
2326
+ output: z10.object({
2327
+ message: z10.string(),
2328
+ credentialsPath: z10.string()
2344
2329
  }),
2345
2330
  examples: [
2346
2331
  {
@@ -2352,23 +2337,23 @@ embeddedWallet.command("setup", {
2352
2337
  async run(c) {
2353
2338
  const publishableKey = process.env.OPENFORT_PUBLISHABLE_KEY;
2354
2339
  if (!publishableKey) {
2355
- throw new Errors2.IncurError({
2340
+ throw new Errors.IncurError({
2356
2341
  code: "MISSING_PUBLISHABLE_KEY",
2357
2342
  message: "OPENFORT_PUBLISHABLE_KEY environment variable is required to create Shield keys.",
2358
2343
  hint: "Run: openfort login"
2359
2344
  });
2360
2345
  }
2361
- const apiKey = process.env.OPENFORT_API_KEY;
2346
+ const apiKey = requireApiKey();
2362
2347
  const environment = apiKey.startsWith("sk_live_") ? "live" : "test";
2363
2348
  const projectId = c.options.project || process.env.OPENFORT_PROJECT_ID;
2364
2349
  if (!projectId) {
2365
- throw new Errors2.IncurError({
2350
+ throw new Errors.IncurError({
2366
2351
  code: "MISSING_PROJECT_ID",
2367
2352
  message: "Project ID is required. Pass --project or set OPENFORT_PROJECT_ID.",
2368
2353
  hint: "Run: openfort login"
2369
2354
  });
2370
2355
  }
2371
- const registerRes = await fetch(`${SHIELD_API_URL}/register`, {
2356
+ const registerRes = await fetch(`${OPENFORT_SHIELD_URL}/register`, {
2372
2357
  method: "POST",
2373
2358
  headers: {
2374
2359
  "Content-Type": "application/json",
@@ -2382,7 +2367,7 @@ embeddedWallet.command("setup", {
2382
2367
  });
2383
2368
  if (!registerRes.ok) {
2384
2369
  const text = await registerRes.text();
2385
- throw new Errors2.IncurError({
2370
+ throw new Errors.IncurError({
2386
2371
  code: "SHIELD_REGISTER_FAILED",
2387
2372
  message: `Shield registration failed: ${text}`,
2388
2373
  retryable: true
@@ -2390,7 +2375,7 @@ embeddedWallet.command("setup", {
2390
2375
  }
2391
2376
  const shieldData = await registerRes.json();
2392
2377
  if (shieldData.error) {
2393
- throw new Errors2.IncurError({
2378
+ throw new Errors.IncurError({
2394
2379
  code: "SHIELD_REGISTER_ERROR",
2395
2380
  message: `Shield registration error: ${shieldData.error}`
2396
2381
  });
@@ -2406,7 +2391,7 @@ embeddedWallet.command("setup", {
2406
2391
  });
2407
2392
  if (!res.ok) {
2408
2393
  const text = await res.text();
2409
- throw new Errors2.IncurError({
2394
+ throw new Errors.IncurError({
2410
2395
  code: "PERSIST_KEY_FAILED",
2411
2396
  message: `Failed to persist ${type} key: ${text}`,
2412
2397
  retryable: true
@@ -2417,7 +2402,7 @@ embeddedWallet.command("setup", {
2417
2402
  persistKey("pk_shield", shieldData.api_key),
2418
2403
  persistKey("sk_shield", shieldData.api_secret)
2419
2404
  ]);
2420
- const linkRes = await fetch(`${SHIELD_API_URL}/project/providers`, {
2405
+ const linkRes = await fetch(`${OPENFORT_SHIELD_URL}/project/providers`, {
2421
2406
  method: "POST",
2422
2407
  headers: {
2423
2408
  "Content-Type": "application/json",
@@ -2434,7 +2419,7 @@ embeddedWallet.command("setup", {
2434
2419
  });
2435
2420
  if (!linkRes.ok) {
2436
2421
  const text = await linkRes.text();
2437
- throw new Errors2.IncurError({
2422
+ throw new Errors.IncurError({
2438
2423
  code: "SHIELD_LINK_FAILED",
2439
2424
  message: `Failed to link Openfort provider to Shield: ${text}`,
2440
2425
  retryable: true
@@ -2461,49 +2446,48 @@ embeddedWallet.command("setup", {
2461
2446
  });
2462
2447
 
2463
2448
  // src/commands/users.ts
2464
- import { Cli as Cli10, z as z12 } from "incur";
2465
- var userItem = z12.object({
2466
- id: z12.string(),
2467
- createdAt: z12.number(),
2468
- name: z12.string(),
2469
- email: z12.string().nullable(),
2470
- emailVerified: z12.boolean(),
2471
- phoneNumber: z12.string().nullable(),
2472
- phoneNumberVerified: z12.boolean(),
2473
- isAnonymous: z12.boolean().optional(),
2474
- linkedAccounts: z12.array(z12.object({
2475
- provider: z12.string(),
2476
- createdAt: z12.number(),
2477
- updatedAt: z12.number(),
2478
- accountId: z12.string().optional(),
2479
- chainType: z12.string().optional(),
2480
- connectorType: z12.string().optional(),
2481
- walletClientType: z12.string().optional()
2449
+ import { Cli as Cli11, z as z11 } from "incur";
2450
+ var userItem = z11.object({
2451
+ id: z11.string(),
2452
+ createdAt: z11.number(),
2453
+ name: z11.string(),
2454
+ email: z11.string().nullable(),
2455
+ emailVerified: z11.boolean(),
2456
+ phoneNumber: z11.string().nullable(),
2457
+ phoneNumberVerified: z11.boolean(),
2458
+ isAnonymous: z11.boolean().optional(),
2459
+ linkedAccounts: z11.array(z11.object({
2460
+ provider: z11.string(),
2461
+ createdAt: z11.number(),
2462
+ updatedAt: z11.number(),
2463
+ accountId: z11.string().optional(),
2464
+ chainType: z11.string().optional(),
2465
+ connectorType: z11.string().optional(),
2466
+ walletClientType: z11.string().optional()
2482
2467
  }))
2483
2468
  });
2484
- var users = Cli10.create("users", {
2485
- description: "Manage authenticated users.",
2486
- vars: varsSchema
2469
+ var users = Cli11.create("users", {
2470
+ description: "Manage authenticated users."
2487
2471
  });
2488
2472
  users.command("list", {
2489
2473
  description: "List users.",
2490
- options: z12.object({
2491
- limit: z12.number().optional().describe("Max results"),
2492
- skip: z12.number().optional().describe("Offset"),
2493
- email: z12.string().optional().describe("Filter by email"),
2494
- name: z12.string().optional().describe("Filter by name")
2474
+ options: z11.object({
2475
+ limit: z11.number().optional().describe("Max results"),
2476
+ skip: z11.number().optional().describe("Offset"),
2477
+ email: z11.string().optional().describe("Filter by email"),
2478
+ name: z11.string().optional().describe("Filter by name")
2495
2479
  }),
2496
2480
  alias: { limit: "l" },
2497
2481
  examples: [
2498
2482
  { description: "List all users" },
2499
2483
  { options: { email: "user@example.com" }, description: "Find user by email" }
2500
2484
  ],
2501
- output: z12.object({
2502
- data: z12.array(userItem),
2503
- total: z12.number()
2485
+ output: z11.object({
2486
+ data: z11.array(userItem),
2487
+ total: z11.number()
2504
2488
  }),
2505
2489
  async run(c) {
2506
- const res = await c.var.openfort.iam.users.list({
2490
+ const res = await getOpenfort().iam.users.list({
2507
2491
  limit: c.options.limit,
2508
2492
  skip: c.options.skip,
2509
2493
  email: c.options.email,
@@ -2527,15 +2511,15 @@ users.command("list", {
2527
2511
  });
2528
2512
  users.command("get", {
2529
2513
  description: "Get a user by ID.",
2530
- args: z12.object({
2531
- id: z12.string().describe("User ID (usr_...)")
2514
+ args: z11.object({
2515
+ id: z11.string().describe("User ID (usr_...)")
2532
2516
  }),
2533
2517
  examples: [
2534
2518
  { args: { id: "usr_1a2b3c4d" }, description: "Get user profile and linked accounts" }
2535
2519
  ],
2536
2520
  output: userItem,
2537
2521
  async run(c) {
2538
- const u = await c.var.openfort.iam.users.get(c.args.id);
2522
+ const u = await getOpenfort().iam.users.get(c.args.id);
2539
2523
  return c.ok({
2540
2524
  id: u.id,
2541
2525
  createdAt: u.createdAt,
@@ -2551,25 +2535,25 @@ users.command("get", {
2551
2535
  });
2552
2536
  users.command("delete", {
2553
2537
  description: "Delete a user.",
2554
- args: z12.object({
2555
- id: z12.string().describe("User ID (usr_...)")
2538
+ args: z11.object({
2539
+ id: z11.string().describe("User ID (usr_...)")
2556
2540
  }),
2557
2541
  examples: [
2558
2542
  { args: { id: "usr_1a2b3c4d" }, description: "Delete a user and their accounts" }
2559
2543
  ],
2560
- output: z12.object({
2561
- id: z12.string(),
2562
- deleted: z12.boolean()
2544
+ output: z11.object({
2545
+ id: z11.string(),
2546
+ deleted: z11.boolean()
2563
2547
  }),
2564
2548
  async run(c) {
2565
- const res = await c.var.openfort.iam.users.delete(c.args.id);
2549
+ const res = await getOpenfort().iam.users.delete(c.args.id);
2566
2550
  return c.ok({ id: res.id, deleted: res.deleted });
2567
2551
  }
2568
2552
  });
2569
2553
 
2570
2554
  // src/commands/backend-wallet.ts
2571
2555
  import { randomBytes as randomBytes2, subtle } from "crypto";
2572
- import { Cli as Cli11, z as z13, Errors as Errors3 } from "incur";
2556
+ import { Cli as Cli12, z as z12, Errors as Errors2 } from "incur";
2573
2557
  function arrayBufferToBase64(buffer) {
2574
2558
  return Buffer.from(buffer).toString("base64");
2575
2559
  }
@@ -2577,7 +2561,7 @@ function arrayBufferToBase64Url(buffer) {
2577
2561
  return Buffer.from(buffer).toString("base64url");
2578
2562
  }
2579
2563
  function stringToArrayBuffer(str) {
2580
- return new TextEncoder().encode(str).buffer;
2564
+ return new TextEncoder().encode(str);
2581
2565
  }
2582
2566
  function formatPEMBody(base64) {
2583
2567
  return base64.match(/.{1,64}/g)?.join("\n") || base64;
@@ -2585,9 +2569,10 @@ function formatPEMBody(base64) {
2585
2569
  function sortObjectKeys(obj) {
2586
2570
  if (obj === null || typeof obj !== "object") return obj;
2587
2571
  if (Array.isArray(obj)) return obj.map(sortObjectKeys);
2572
+ const record = obj;
2588
2573
  const sorted = {};
2589
- for (const key of Object.keys(obj).sort()) {
2590
- sorted[key] = sortObjectKeys(obj[key]);
2574
+ for (const key of Object.keys(record).sort()) {
2575
+ sorted[key] = sortObjectKeys(record[key]);
2591
2576
  }
2592
2577
  return sorted;
2593
2578
  }
@@ -2639,15 +2624,14 @@ async function signWalletAuthJwt(privateKey, method, path, body) {
2639
2624
  );
2640
2625
  return `${signingInput}.${arrayBufferToBase64Url(signature)}`;
2641
2626
  }
2642
- var backendWallet = Cli11.create("backend-wallet", {
2643
- description: "Configure backend wallet signing keys.",
2644
- vars: varsSchema
2627
+ var backendWallet = Cli12.create("backend-wallet", {
2628
+ description: "Configure backend wallet signing keys."
2645
2629
  });
2646
2630
  backendWallet.command("setup", {
2647
2631
  description: "Generate and register backend wallet signing keys (ECDSA P-256).",
2648
- output: z13.object({
2649
- message: z13.string(),
2650
- credentialsPath: z13.string()
2632
+ output: z12.object({
2633
+ message: z12.string(),
2634
+ credentialsPath: z12.string()
2651
2635
  }),
2652
2636
  examples: [
2653
2637
  {
@@ -2656,7 +2640,7 @@ backendWallet.command("setup", {
2656
2640
  ],
2657
2641
  hint: 'Requires OPENFORT_API_KEY. Run "openfort login" first.',
2658
2642
  async run(c) {
2659
- const apiKey = process.env.OPENFORT_API_KEY;
2643
+ const apiKey = requireApiKey();
2660
2644
  const { publicKey, privateKey, privateKeyCrypto } = await generateKeyPair();
2661
2645
  const publicKeyPEM = `-----BEGIN PUBLIC KEY-----
2662
2646
  ${publicKey}
@@ -2678,7 +2662,7 @@ ${publicKey}
2678
2662
  });
2679
2663
  if (!registerRes.ok) {
2680
2664
  const text = await registerRes.text();
2681
- throw new Errors3.IncurError({
2665
+ throw new Errors2.IncurError({
2682
2666
  code: "REGISTER_SECRET_FAILED",
2683
2667
  message: `Failed to register wallet secret: ${text}`,
2684
2668
  retryable: true
@@ -2694,7 +2678,7 @@ ${publicKey}
2694
2678
  });
2695
2679
  if (!storeRes.ok) {
2696
2680
  const text = await storeRes.text();
2697
- throw new Errors3.IncurError({
2681
+ throw new Errors2.IncurError({
2698
2682
  code: "STORE_KEY_FAILED",
2699
2683
  message: `Failed to store wallet key reference: ${text}`,
2700
2684
  retryable: true
@@ -2719,10 +2703,10 @@ ${publicKey}
2719
2703
  });
2720
2704
  backendWallet.command("revoke", {
2721
2705
  description: "Revoke the current backend wallet signing secret.",
2722
- output: z13.object({
2723
- keyId: z13.string(),
2724
- revoked: z13.boolean(),
2725
- revokedAt: z13.number()
2706
+ output: z12.object({
2707
+ keyId: z12.string(),
2708
+ revoked: z12.boolean(),
2709
+ revokedAt: z12.number()
2726
2710
  }),
2727
2711
  examples: [
2728
2712
  {
@@ -2731,11 +2715,11 @@ backendWallet.command("revoke", {
2731
2715
  ],
2732
2716
  hint: 'Requires OPENFORT_WALLET_KEY_ID and OPENFORT_WALLET_SECRET. Run "openfort backend-wallet setup" first.',
2733
2717
  async run(c) {
2734
- const apiKey = process.env.OPENFORT_API_KEY;
2718
+ const apiKey = requireApiKey();
2735
2719
  const keyId = process.env.OPENFORT_WALLET_KEY_ID;
2736
2720
  const privateKeyBase64 = process.env.OPENFORT_WALLET_SECRET;
2737
2721
  if (!keyId || !privateKeyBase64) {
2738
- throw new Errors3.IncurError({
2722
+ throw new Errors2.IncurError({
2739
2723
  code: "MISSING_WALLET_KEY",
2740
2724
  message: "OPENFORT_WALLET_KEY_ID and OPENFORT_WALLET_SECRET must be set. Run `backend-wallet setup` first.",
2741
2725
  hint: "Run: openfort backend-wallet setup"
@@ -2756,7 +2740,7 @@ backendWallet.command("revoke", {
2756
2740
  });
2757
2741
  if (!res.ok) {
2758
2742
  const text = await res.text();
2759
- throw new Errors3.IncurError({
2743
+ throw new Errors2.IncurError({
2760
2744
  code: "REVOKE_SECRET_FAILED",
2761
2745
  message: `Failed to revoke wallet secret: ${text}`,
2762
2746
  retryable: true
@@ -2768,9 +2752,9 @@ backendWallet.command("revoke", {
2768
2752
  });
2769
2753
  backendWallet.command("rotate", {
2770
2754
  description: "Rotate backend wallet signing secret (generates new ECDSA P-256 key pair).",
2771
- output: z13.object({
2772
- message: z13.string(),
2773
- credentialsPath: z13.string()
2755
+ output: z12.object({
2756
+ message: z12.string(),
2757
+ credentialsPath: z12.string()
2774
2758
  }),
2775
2759
  examples: [
2776
2760
  {
@@ -2779,7 +2763,7 @@ backendWallet.command("rotate", {
2779
2763
  ],
2780
2764
  hint: 'Requires OPENFORT_API_KEY. Run "openfort login" first.',
2781
2765
  async run(c) {
2782
- const apiKey = process.env.OPENFORT_API_KEY;
2766
+ const apiKey = requireApiKey();
2783
2767
  const { publicKey, privateKey, privateKeyCrypto } = await generateKeyPair();
2784
2768
  const newPublicKeyPEM = `-----BEGIN PUBLIC KEY-----
2785
2769
  ${publicKey}
@@ -2801,7 +2785,7 @@ ${publicKey}
2801
2785
  });
2802
2786
  if (!rotateRes.ok) {
2803
2787
  const text = await rotateRes.text();
2804
- throw new Errors3.IncurError({
2788
+ throw new Errors2.IncurError({
2805
2789
  code: "ROTATE_SECRET_FAILED",
2806
2790
  message: `Failed to rotate wallet secret: ${text}`,
2807
2791
  retryable: true
@@ -2817,7 +2801,7 @@ ${publicKey}
2817
2801
  });
2818
2802
  if (!storeRes.ok) {
2819
2803
  const text = await storeRes.text();
2820
- throw new Errors3.IncurError({
2804
+ throw new Errors2.IncurError({
2821
2805
  code: "STORE_KEY_FAILED",
2822
2806
  message: `Failed to store rotated wallet key reference: ${text}`,
2823
2807
  retryable: true
@@ -2832,22 +2816,21 @@ ${publicKey}
2832
2816
  });
2833
2817
 
2834
2818
  // src/commands/message.ts
2835
- import { Cli as Cli12, z as z14 } from "incur";
2819
+ import { Cli as Cli13, z as z13 } from "incur";
2836
2820
  import { keccak256, toBytes } from "viem";
2837
- var message = Cli12.create("message", {
2838
- description: "Message utilities.",
2839
- vars: varsSchema
2821
+ var message = Cli13.create("message", {
2822
+ description: "Message utilities."
2840
2823
  });
2841
2824
  message.command("hash", {
2842
2825
  description: "Hash a message using keccak256.",
2843
- args: z14.object({
2844
- message: z14.string().describe("The message to hash")
2826
+ args: z13.object({
2827
+ message: z13.string().describe("The message to hash")
2845
2828
  }),
2846
2829
  examples: [
2847
2830
  { args: { message: "Hello World" }, description: "Hash a message" }
2848
2831
  ],
2849
- output: z14.object({
2850
- hash: z14.string()
2832
+ output: z13.object({
2833
+ hash: z13.string()
2851
2834
  }),
2852
2835
  async run(c) {
2853
2836
  const hash = keccak256(toBytes(c.args.message));
@@ -2856,17 +2839,15 @@ message.command("hash", {
2856
2839
  });
2857
2840
 
2858
2841
  // src/cli.ts
2859
- var pkg = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf-8"));
2860
- var cli = Cli13.create("openfort", {
2842
+ var pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
2843
+ var cli = Cli14.create("openfort", {
2861
2844
  version: pkg.version,
2862
- aliases: ["of"],
2863
2845
  description: "Openfort CLI \u2014 manage wallets, policies, and transactions from the terminal.",
2864
- vars: varsSchema,
2865
- env: z15.object({
2866
- OPENFORT_API_KEY: z15.string().optional().describe("Openfort secret API key (sk_test_... or sk_live_...)"),
2867
- OPENFORT_WALLET_SECRET: z15.string().optional().describe("Wallet encryption secret"),
2868
- OPENFORT_PUBLISHABLE_KEY: z15.string().optional().describe("Publishable key for client-side ops"),
2869
- OPENFORT_BASE_URL: z15.string().optional().describe("Custom API base URL")
2846
+ env: z14.object({
2847
+ OPENFORT_API_KEY: z14.string().optional().describe("Openfort secret API key (sk_test_... or sk_live_...)"),
2848
+ OPENFORT_WALLET_SECRET: z14.string().optional().describe("Wallet encryption secret"),
2849
+ OPENFORT_PUBLISHABLE_KEY: z14.string().optional().describe("Publishable key for client-side ops"),
2850
+ OPENFORT_BASE_URL: z14.string().optional().describe("Custom API base URL")
2870
2851
  }),
2871
2852
  sync: {
2872
2853
  depth: 2,
@@ -2883,28 +2864,7 @@ var cli = Cli13.create("openfort", {
2883
2864
  agents: ["claude-code", "cursor", "amp"]
2884
2865
  }
2885
2866
  });
2886
- cli.command("login", loginConfig);
2887
- cli.use(async (c, next) => {
2888
- const isLoginCommand = process.argv.slice(2).some((arg) => arg === "login");
2889
- if (isLoginCommand) {
2890
- await next();
2891
- return;
2892
- }
2893
- const apiKey = process.env.OPENFORT_API_KEY;
2894
- if (!apiKey) {
2895
- throw new Errors4.IncurError({
2896
- code: "MISSING_API_KEY",
2897
- message: "OPENFORT_API_KEY environment variable is required.",
2898
- hint: "Run: openfort login"
2899
- });
2900
- }
2901
- c.set("openfort", new Openfort(apiKey, {
2902
- walletSecret: process.env.OPENFORT_WALLET_SECRET,
2903
- publishableKey: process.env.OPENFORT_PUBLISHABLE_KEY,
2904
- basePath: API_BASE_URL
2905
- }));
2906
- await next();
2907
- });
2867
+ cli.command(login);
2908
2868
  cli.command(accounts).command(contracts).command(paymasters).command(policies).command(embeddedWallet).command(sponsorship).command(sessions).command(subscriptions).command(transactions).command(users).command(backendWallet).command(message);
2909
2869
  var cli_default = cli;
2910
2870
  export {