run402 1.40.0 → 1.40.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/lib/sdk.mjs +1 -1
  2. package/package.json +4 -3
  3. package/sdk/core-dist/allowance-auth.js +129 -0
  4. package/sdk/core-dist/allowance.js +25 -0
  5. package/sdk/core-dist/client.js +42 -0
  6. package/sdk/core-dist/config.js +26 -0
  7. package/sdk/core-dist/keystore.js +97 -0
  8. package/sdk/core-dist/wallet-auth.js +62 -0
  9. package/sdk/core-dist/wallet.js +25 -0
  10. package/sdk/dist/credentials.d.ts +70 -0
  11. package/sdk/dist/credentials.d.ts.map +1 -0
  12. package/sdk/dist/credentials.js +19 -0
  13. package/sdk/dist/credentials.js.map +1 -0
  14. package/sdk/dist/errors.d.ts +34 -0
  15. package/sdk/dist/errors.d.ts.map +1 -0
  16. package/sdk/dist/errors.js +46 -0
  17. package/sdk/dist/errors.js.map +1 -0
  18. package/sdk/dist/index.d.ts +68 -0
  19. package/sdk/dist/index.d.ts.map +1 -0
  20. package/sdk/dist/index.js +81 -0
  21. package/sdk/dist/index.js.map +1 -0
  22. package/sdk/dist/kernel.d.ts +47 -0
  23. package/sdk/dist/kernel.d.ts.map +1 -0
  24. package/sdk/dist/kernel.js +76 -0
  25. package/sdk/dist/kernel.js.map +1 -0
  26. package/sdk/dist/namespaces/admin.d.ts +30 -0
  27. package/sdk/dist/namespaces/admin.d.ts.map +1 -0
  28. package/sdk/dist/namespaces/admin.js +36 -0
  29. package/sdk/dist/namespaces/admin.js.map +1 -0
  30. package/sdk/dist/namespaces/ai.d.ts +57 -0
  31. package/sdk/dist/namespaces/ai.d.ts.map +1 -0
  32. package/sdk/dist/namespaces/ai.js +62 -0
  33. package/sdk/dist/namespaces/ai.js.map +1 -0
  34. package/sdk/dist/namespaces/allowance.d.ts +51 -0
  35. package/sdk/dist/namespaces/allowance.d.ts.map +1 -0
  36. package/sdk/dist/namespaces/allowance.js +116 -0
  37. package/sdk/dist/namespaces/allowance.js.map +1 -0
  38. package/sdk/dist/namespaces/apps.d.ts +158 -0
  39. package/sdk/dist/namespaces/apps.d.ts.map +1 -0
  40. package/sdk/dist/namespaces/apps.js +150 -0
  41. package/sdk/dist/namespaces/apps.js.map +1 -0
  42. package/sdk/dist/namespaces/auth.d.ts +53 -0
  43. package/sdk/dist/namespaces/auth.d.ts.map +1 -0
  44. package/sdk/dist/namespaces/auth.js +106 -0
  45. package/sdk/dist/namespaces/auth.js.map +1 -0
  46. package/sdk/dist/namespaces/billing.d.ts +64 -0
  47. package/sdk/dist/namespaces/billing.d.ts.map +1 -0
  48. package/sdk/dist/namespaces/billing.js +105 -0
  49. package/sdk/dist/namespaces/billing.js.map +1 -0
  50. package/sdk/dist/namespaces/blobs.d.ts +41 -0
  51. package/sdk/dist/namespaces/blobs.d.ts.map +1 -0
  52. package/sdk/dist/namespaces/blobs.js +202 -0
  53. package/sdk/dist/namespaces/blobs.js.map +1 -0
  54. package/sdk/dist/namespaces/blobs.types.d.ts +58 -0
  55. package/sdk/dist/namespaces/blobs.types.d.ts.map +1 -0
  56. package/sdk/dist/namespaces/blobs.types.js +9 -0
  57. package/sdk/dist/namespaces/blobs.types.js.map +1 -0
  58. package/sdk/dist/namespaces/contracts.d.ts +65 -0
  59. package/sdk/dist/namespaces/contracts.d.ts.map +1 -0
  60. package/sdk/dist/namespaces/contracts.js +163 -0
  61. package/sdk/dist/namespaces/contracts.js.map +1 -0
  62. package/sdk/dist/namespaces/domains.d.ts +57 -0
  63. package/sdk/dist/namespaces/domains.d.ts.map +1 -0
  64. package/sdk/dist/namespaces/domains.js +60 -0
  65. package/sdk/dist/namespaces/domains.js.map +1 -0
  66. package/sdk/dist/namespaces/email.d.ts +131 -0
  67. package/sdk/dist/namespaces/email.d.ts.map +1 -0
  68. package/sdk/dist/namespaces/email.js +318 -0
  69. package/sdk/dist/namespaces/email.js.map +1 -0
  70. package/sdk/dist/namespaces/functions.d.ts +43 -0
  71. package/sdk/dist/namespaces/functions.d.ts.map +1 -0
  72. package/sdk/dist/namespaces/functions.js +146 -0
  73. package/sdk/dist/namespaces/functions.js.map +1 -0
  74. package/sdk/dist/namespaces/functions.types.d.ts +96 -0
  75. package/sdk/dist/namespaces/functions.types.d.ts.map +1 -0
  76. package/sdk/dist/namespaces/functions.types.js +6 -0
  77. package/sdk/dist/namespaces/functions.types.js.map +1 -0
  78. package/sdk/dist/namespaces/projects.d.ts +97 -0
  79. package/sdk/dist/namespaces/projects.d.ts.map +1 -0
  80. package/sdk/dist/namespaces/projects.js +214 -0
  81. package/sdk/dist/namespaces/projects.js.map +1 -0
  82. package/sdk/dist/namespaces/projects.types.d.ts +112 -0
  83. package/sdk/dist/namespaces/projects.types.d.ts.map +1 -0
  84. package/sdk/dist/namespaces/projects.types.js +9 -0
  85. package/sdk/dist/namespaces/projects.types.js.map +1 -0
  86. package/sdk/dist/namespaces/secrets.d.ts +23 -0
  87. package/sdk/dist/namespaces/secrets.d.ts.map +1 -0
  88. package/sdk/dist/namespaces/secrets.js +45 -0
  89. package/sdk/dist/namespaces/secrets.js.map +1 -0
  90. package/sdk/dist/namespaces/sender-domain.d.ts +40 -0
  91. package/sdk/dist/namespaces/sender-domain.d.ts.map +1 -0
  92. package/sdk/dist/namespaces/sender-domain.js +69 -0
  93. package/sdk/dist/namespaces/sender-domain.js.map +1 -0
  94. package/sdk/dist/namespaces/service.d.ts +51 -0
  95. package/sdk/dist/namespaces/service.d.ts.map +1 -0
  96. package/sdk/dist/namespaces/service.js +25 -0
  97. package/sdk/dist/namespaces/service.js.map +1 -0
  98. package/sdk/dist/namespaces/sites.d.ts +50 -0
  99. package/sdk/dist/namespaces/sites.d.ts.map +1 -0
  100. package/sdk/dist/namespaces/sites.js +38 -0
  101. package/sdk/dist/namespaces/sites.js.map +1 -0
  102. package/sdk/dist/namespaces/subdomains.d.ts +36 -0
  103. package/sdk/dist/namespaces/subdomains.d.ts.map +1 -0
  104. package/sdk/dist/namespaces/subdomains.js +54 -0
  105. package/sdk/dist/namespaces/subdomains.js.map +1 -0
  106. package/sdk/dist/namespaces/tier.d.ts +36 -0
  107. package/sdk/dist/namespaces/tier.d.ts.map +1 -0
  108. package/sdk/dist/namespaces/tier.js +31 -0
  109. package/sdk/dist/namespaces/tier.js.map +1 -0
  110. package/sdk/dist/node/credentials.d.ts +26 -0
  111. package/sdk/dist/node/credentials.d.ts.map +1 -0
  112. package/sdk/dist/node/credentials.js +69 -0
  113. package/sdk/dist/node/credentials.js.map +1 -0
  114. package/sdk/dist/node/index.d.ts +44 -0
  115. package/sdk/dist/node/index.d.ts.map +1 -0
  116. package/sdk/dist/node/index.js +43 -0
  117. package/sdk/dist/node/index.js.map +1 -0
  118. package/sdk/dist/node/paid-fetch.d.ts +22 -0
  119. package/sdk/dist/node/paid-fetch.d.ts.map +1 -0
  120. package/sdk/dist/node/paid-fetch.js +116 -0
  121. package/sdk/dist/node/paid-fetch.js.map +1 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @run402/sdk — typed TypeScript client for the Run402 API.
3
+ *
4
+ * This is the isomorphic entry point. Works in Node 22, Deno, Bun, and V8
5
+ * isolates with no filesystem. For Node consumers that want zero-config
6
+ * defaults (keystore + allowance + x402), use `@run402/sdk/node` instead.
7
+ */
8
+ import type { CredentialsProvider } from "./credentials.js";
9
+ import { Projects } from "./namespaces/projects.js";
10
+ import { Blobs } from "./namespaces/blobs.js";
11
+ import { Functions } from "./namespaces/functions.js";
12
+ import { Secrets } from "./namespaces/secrets.js";
13
+ import { Subdomains } from "./namespaces/subdomains.js";
14
+ import { Domains } from "./namespaces/domains.js";
15
+ import { Sites } from "./namespaces/sites.js";
16
+ import { Service } from "./namespaces/service.js";
17
+ import { Tier } from "./namespaces/tier.js";
18
+ import { Allowance } from "./namespaces/allowance.js";
19
+ import { Ai } from "./namespaces/ai.js";
20
+ import { Auth } from "./namespaces/auth.js";
21
+ import { SenderDomain } from "./namespaces/sender-domain.js";
22
+ import { Billing } from "./namespaces/billing.js";
23
+ import { Apps } from "./namespaces/apps.js";
24
+ import { Email } from "./namespaces/email.js";
25
+ import { Contracts } from "./namespaces/contracts.js";
26
+ import { Admin } from "./namespaces/admin.js";
27
+ export interface Run402Options {
28
+ /** API base URL, e.g. `https://api.run402.com`. */
29
+ apiBase: string;
30
+ /** Credential provider. Required — there is no default in the isomorphic entry. */
31
+ credentials: CredentialsProvider;
32
+ /**
33
+ * Custom fetch implementation. Defaults to `globalThis.fetch`. Node consumers
34
+ * typically pass an x402-wrapped fetch; sandbox consumers may pass a
35
+ * session-bound fetch provided by their supervisor.
36
+ */
37
+ fetch?: typeof globalThis.fetch;
38
+ }
39
+ export declare class Run402 {
40
+ readonly projects: Projects;
41
+ readonly blobs: Blobs;
42
+ readonly functions: Functions;
43
+ readonly secrets: Secrets;
44
+ readonly subdomains: Subdomains;
45
+ readonly domains: Domains;
46
+ readonly sites: Sites;
47
+ readonly service: Service;
48
+ readonly tier: Tier;
49
+ readonly allowance: Allowance;
50
+ readonly ai: Ai;
51
+ readonly auth: Auth;
52
+ readonly senderDomain: SenderDomain;
53
+ readonly billing: Billing;
54
+ readonly apps: Apps;
55
+ readonly email: Email;
56
+ readonly contracts: Contracts;
57
+ readonly admin: Admin;
58
+ constructor(opts: Run402Options);
59
+ }
60
+ /**
61
+ * Factory wrapper equivalent to `new Run402(opts)`. Reads better in code-mode
62
+ * sandbox examples: `const r = run402({ ... })`.
63
+ */
64
+ export declare function run402(opts: Run402Options): Run402;
65
+ export { Run402Error, PaymentRequired, ProjectNotFound, Unauthorized, ApiError, NetworkError, } from "./errors.js";
66
+ export type { CredentialsProvider, ProjectKeys } from "./credentials.js";
67
+ export type { RequestOptions, Client } from "./kernel.js";
68
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,mBAA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,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;gBAEV,IAAI,EAAE,aAAa;CA0BhC;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAElD;AAED,OAAO,EACL,WAAW,EACX,eAAe,EACf,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @run402/sdk — typed TypeScript client for the Run402 API.
3
+ *
4
+ * This is the isomorphic entry point. Works in Node 22, Deno, Bun, and V8
5
+ * isolates with no filesystem. For Node consumers that want zero-config
6
+ * defaults (keystore + allowance + x402), use `@run402/sdk/node` instead.
7
+ */
8
+ import { buildClient } from "./kernel.js";
9
+ import { Projects } from "./namespaces/projects.js";
10
+ import { Blobs } from "./namespaces/blobs.js";
11
+ import { Functions } from "./namespaces/functions.js";
12
+ import { Secrets } from "./namespaces/secrets.js";
13
+ import { Subdomains } from "./namespaces/subdomains.js";
14
+ import { Domains } from "./namespaces/domains.js";
15
+ import { Sites } from "./namespaces/sites.js";
16
+ import { Service } from "./namespaces/service.js";
17
+ import { Tier } from "./namespaces/tier.js";
18
+ import { Allowance } from "./namespaces/allowance.js";
19
+ import { Ai } from "./namespaces/ai.js";
20
+ import { Auth } from "./namespaces/auth.js";
21
+ import { SenderDomain } from "./namespaces/sender-domain.js";
22
+ import { Billing } from "./namespaces/billing.js";
23
+ import { Apps } from "./namespaces/apps.js";
24
+ import { Email } from "./namespaces/email.js";
25
+ import { Contracts } from "./namespaces/contracts.js";
26
+ import { Admin } from "./namespaces/admin.js";
27
+ export class Run402 {
28
+ projects;
29
+ blobs;
30
+ functions;
31
+ secrets;
32
+ subdomains;
33
+ domains;
34
+ sites;
35
+ service;
36
+ tier;
37
+ allowance;
38
+ ai;
39
+ auth;
40
+ senderDomain;
41
+ billing;
42
+ apps;
43
+ email;
44
+ contracts;
45
+ admin;
46
+ constructor(opts) {
47
+ const kernel = {
48
+ apiBase: opts.apiBase,
49
+ fetch: opts.fetch ?? globalThis.fetch.bind(globalThis),
50
+ credentials: opts.credentials,
51
+ };
52
+ const client = buildClient(kernel);
53
+ this.projects = new Projects(client);
54
+ this.blobs = new Blobs(client);
55
+ this.functions = new Functions(client);
56
+ this.secrets = new Secrets(client);
57
+ this.subdomains = new Subdomains(client);
58
+ this.domains = new Domains(client);
59
+ this.sites = new Sites(client);
60
+ this.service = new Service(client);
61
+ this.tier = new Tier(client);
62
+ this.allowance = new Allowance(client);
63
+ this.ai = new Ai(client);
64
+ this.auth = new Auth(client);
65
+ this.senderDomain = new SenderDomain(client);
66
+ this.billing = new Billing(client);
67
+ this.apps = new Apps(client);
68
+ this.email = new Email(client);
69
+ this.contracts = new Contracts(client);
70
+ this.admin = new Admin(client);
71
+ }
72
+ }
73
+ /**
74
+ * Factory wrapper equivalent to `new Run402(opts)`. Reads better in code-mode
75
+ * sandbox examples: `const r = run402({ ... })`.
76
+ */
77
+ export function run402(opts) {
78
+ return new Run402(opts);
79
+ }
80
+ export { Run402Error, PaymentRequired, ProjectNotFound, Unauthorized, ApiError, NetworkError, } from "./errors.js";
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAkC,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AA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CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,IAAmB;IACxC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,OAAO,EACL,WAAW,EACX,eAAe,EACf,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,YAAY,GACb,MAAM,aAAa,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Request kernel — the one place in the SDK that touches `fetch`.
3
+ *
4
+ * Isomorphic: uses only platform globals, no Node-only APIs. The kernel is
5
+ * safe to execute inside a V8 isolate where `fs`, `child_process`, and
6
+ * `process` are absent.
7
+ *
8
+ * Failure translation: maps HTTP status codes and network errors to the
9
+ * appropriate {@link Run402Error} subclass. Callers never see `undefined`
10
+ * or a response-shaped error value — they either get the parsed body as T
11
+ * or an exception.
12
+ */
13
+ import type { CredentialsProvider, ProjectKeys } from "./credentials.js";
14
+ export interface KernelConfig {
15
+ apiBase: string;
16
+ fetch: typeof globalThis.fetch;
17
+ credentials: CredentialsProvider;
18
+ }
19
+ export interface RequestOptions {
20
+ method?: string;
21
+ headers?: Record<string, string>;
22
+ body?: unknown;
23
+ /** Send body as a raw string (e.g. `text/plain` SQL) or bytes, skipping JSON.stringify. */
24
+ rawBody?: string | Uint8Array;
25
+ /** Include credential headers from `credentials.getAuth(path)`. Default: true. */
26
+ withAuth?: boolean;
27
+ /** Short verb phrase attached to thrown errors (e.g. "provisioning project"). */
28
+ context: string;
29
+ }
30
+ /** Internal client surface passed to each namespace. */
31
+ export interface Client {
32
+ /** API base URL, e.g. `https://api.run402.com`. Exposed for namespaces that need to compute derived URLs (e.g. REST endpoints). */
33
+ readonly apiBase: string;
34
+ request<T>(path: string, opts: RequestOptions): Promise<T>;
35
+ getProject(id: string): Promise<ProjectKeys | null>;
36
+ /** The underlying credentials provider. Namespaces use this to access optional methods (saveProject, setActiveProject, ...). */
37
+ readonly credentials: CredentialsProvider;
38
+ /**
39
+ * The injected fetch (or default `globalThis.fetch`). Namespaces use this
40
+ * when they need to hit a non-gateway URL — e.g. an S3 presigned URL from
41
+ * a multipart upload, where auth + apiBase injection would be wrong.
42
+ */
43
+ readonly fetch: typeof globalThis.fetch;
44
+ }
45
+ export declare function request<T>(kernel: KernelConfig, path: string, opts: RequestOptions): Promise<T>;
46
+ export declare function buildClient(kernel: KernelConfig): Client;
47
+ //# sourceMappingURL=kernel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEzE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC/B,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wDAAwD;AACxD,MAAM,WAAW,MAAM;IACrB,mIAAmI;IACnI,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACpD,gIAAgI;IAChI,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACzC;AAED,wBAAsB,OAAO,CAAC,CAAC,EAC7B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,CAAC,CAAC,CA0EZ;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAQxD"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Request kernel — the one place in the SDK that touches `fetch`.
3
+ *
4
+ * Isomorphic: uses only platform globals, no Node-only APIs. The kernel is
5
+ * safe to execute inside a V8 isolate where `fs`, `child_process`, and
6
+ * `process` are absent.
7
+ *
8
+ * Failure translation: maps HTTP status codes and network errors to the
9
+ * appropriate {@link Run402Error} subclass. Callers never see `undefined`
10
+ * or a response-shaped error value — they either get the parsed body as T
11
+ * or an exception.
12
+ */
13
+ import { ApiError, NetworkError, PaymentRequired, Unauthorized, } from "./errors.js";
14
+ export async function request(kernel, path, opts) {
15
+ const { apiBase, fetch, credentials } = kernel;
16
+ const { method = "GET", headers = {}, body, rawBody, withAuth = true, context } = opts;
17
+ const url = `${apiBase}${path}`;
18
+ const fetchHeaders = { ...headers };
19
+ if (withAuth) {
20
+ const auth = await credentials.getAuth(path);
21
+ if (auth) {
22
+ for (const [k, v] of Object.entries(auth)) {
23
+ if (!(k in fetchHeaders))
24
+ fetchHeaders[k] = v;
25
+ }
26
+ }
27
+ }
28
+ let fetchBody;
29
+ if (rawBody !== undefined) {
30
+ fetchBody = rawBody;
31
+ }
32
+ else if (body !== undefined) {
33
+ if (!("Content-Type" in fetchHeaders) && !("content-type" in fetchHeaders)) {
34
+ fetchHeaders["Content-Type"] = "application/json";
35
+ }
36
+ fetchBody = JSON.stringify(body);
37
+ }
38
+ let res;
39
+ try {
40
+ res = await fetch(url, {
41
+ method,
42
+ headers: fetchHeaders,
43
+ body: fetchBody,
44
+ });
45
+ }
46
+ catch (err) {
47
+ throw new NetworkError(`Network error while ${context}: ${err.message}`, err, context);
48
+ }
49
+ const ct = res.headers.get("content-type") ?? "";
50
+ let resBody;
51
+ if (ct.includes("application/json")) {
52
+ resBody = await res.json().catch(() => null);
53
+ }
54
+ else {
55
+ resBody = await res.text();
56
+ }
57
+ if (res.ok)
58
+ return resBody;
59
+ if (res.status === 402) {
60
+ throw new PaymentRequired(`Payment required while ${context}`, 402, resBody, context);
61
+ }
62
+ if (res.status === 401 || res.status === 403) {
63
+ throw new Unauthorized(`Unauthorized while ${context} (HTTP ${res.status})`, res.status, resBody, context);
64
+ }
65
+ throw new ApiError(`API error while ${context} (HTTP ${res.status})`, res.status, resBody, context);
66
+ }
67
+ export function buildClient(kernel) {
68
+ return {
69
+ apiBase: kernel.apiBase,
70
+ request: (path, opts) => request(kernel, path, opts),
71
+ getProject: (id) => kernel.credentials.getProject(id),
72
+ credentials: kernel.credentials,
73
+ fetch: kernel.fetch,
74
+ };
75
+ }
76
+ //# sourceMappingURL=kernel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel.js","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAC;AAqCrB,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,MAAoB,EACpB,IAAY,EACZ,IAAoB;IAEpB,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAC/C,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACvF,MAAM,GAAG,GAAG,GAAG,OAAO,GAAG,IAAI,EAAE,CAAC;IAEhC,MAAM,YAAY,GAA2B,EAAE,GAAG,OAAO,EAAE,CAAC;IAE5D,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,IAAI,EAAE,CAAC;YACT,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1C,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC;oBAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,SAA0C,CAAC;IAC/C,IAAI,OAAO,KAAK,SAAS,EAAE,CAA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,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC7C,MAAM,IAAI,YAAY,CACpB,sBAAsB,OAAO,UAAU,GAAG,CAAC,MAAM,GAAG,EACpD,GAAG,CAAC,MAAM,EACV,OAAO,EACP,OAAO,CACR,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,QAAQ,CAChB,mBAAmB,OAAO,UAAU,GAAG,CAAC,MAAM,GAAG,EACjD,GAAG,CAAC,MAAM,EACV,OAAO,EACP,OAAO,CACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAoB;IAC9C,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE,CAAI,IAAY,EAAE,IAAoB,EAAE,EAAE,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC;QAClF,UAAU,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7D,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `admin` namespace — account-level operations that don't belong to any
3
+ * single resource: sending messages to the operators, registering agent
4
+ * contact info.
5
+ *
6
+ * (The compound `init` and `status` flows live at the MCP/CLI edge because
7
+ * they stitch together multiple SDK namespaces + local state.)
8
+ */
9
+ import type { Client } from "../kernel.js";
10
+ export interface AgentContact {
11
+ name: string;
12
+ email?: string;
13
+ webhook?: string;
14
+ }
15
+ export interface AgentContactResult {
16
+ wallet: string;
17
+ name: string;
18
+ email?: string;
19
+ webhook?: string;
20
+ updated_at: string;
21
+ }
22
+ export declare class Admin {
23
+ private readonly client;
24
+ constructor(client: Client);
25
+ /** Send a message to the Run402 developers. Requires an active tier. */
26
+ sendMessage(message: string): Promise<void>;
27
+ /** Register agent contact info (name, email, webhook). */
28
+ setAgentContact(contact: AgentContact): Promise<AgentContactResult>;
29
+ }
30
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/namespaces/admin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,KAAK;IACJ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C,wEAAwE;IAClE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjD,0DAA0D;IACpD,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAW1E"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * `admin` namespace — account-level operations that don't belong to any
3
+ * single resource: sending messages to the operators, registering agent
4
+ * contact info.
5
+ *
6
+ * (The compound `init` and `status` flows live at the MCP/CLI edge because
7
+ * they stitch together multiple SDK namespaces + local state.)
8
+ */
9
+ export class Admin {
10
+ client;
11
+ constructor(client) {
12
+ this.client = client;
13
+ }
14
+ /** Send a message to the Run402 developers. Requires an active tier. */
15
+ async sendMessage(message) {
16
+ await this.client.request("/message/v1", {
17
+ method: "POST",
18
+ body: { message },
19
+ context: "sending message",
20
+ });
21
+ }
22
+ /** Register agent contact info (name, email, webhook). */
23
+ async setAgentContact(contact) {
24
+ const body = { name: contact.name };
25
+ if (contact.email)
26
+ body.email = contact.email;
27
+ if (contact.webhook)
28
+ body.webhook = contact.webhook;
29
+ return this.client.request("/agent/v1/contact", {
30
+ method: "POST",
31
+ body,
32
+ context: "setting agent contact",
33
+ });
34
+ }
35
+ }
36
+ //# sourceMappingURL=admin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/namespaces/admin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,MAAM,OAAO,KAAK;IACa;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,wEAAwE;IACxE,KAAK,CAAC,WAAW,CAAC,OAAe;QAC/B,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAU,aAAa,EAAE;YAChD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE,OAAO,EAAE;YACjB,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,0DAA0D;IAC1D,KAAK,CAAC,eAAe,CAAC,OAAqB;QACzC,MAAM,IAAI,GAA2B,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;QAC5D,IAAI,OAAO,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC9C,IAAI,OAAO,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAEpD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAqB,mBAAmB,EAAE;YAClE,MAAM,EAAE,MAAM;YACd,IAAI;YACJ,OAAO,EAAE,uBAAuB;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * `ai` namespace — project-scoped AI add-ons (translation, moderation) and
3
+ * wallet-scoped image generation.
4
+ */
5
+ import type { Client } from "../kernel.js";
6
+ export interface TranslateOptions {
7
+ text: string;
8
+ to: string;
9
+ from?: string;
10
+ context?: string;
11
+ }
12
+ export interface TranslateResult {
13
+ text: string;
14
+ from: string;
15
+ to: string;
16
+ }
17
+ export interface ModerateResult {
18
+ flagged: boolean;
19
+ categories: Record<string, boolean>;
20
+ category_scores: Record<string, number>;
21
+ }
22
+ export interface AiUsageResult {
23
+ translation: {
24
+ active: boolean;
25
+ used_words: number;
26
+ included_words: number;
27
+ remaining_words: number;
28
+ billing_cycle_start: string;
29
+ };
30
+ }
31
+ export type ImageAspect = "square" | "landscape" | "portrait";
32
+ export interface GenerateImageOptions {
33
+ prompt: string;
34
+ aspect?: ImageAspect;
35
+ }
36
+ export interface GenerateImageResult {
37
+ /** Base64-encoded bytes. */
38
+ image: string;
39
+ content_type: string;
40
+ aspect: string;
41
+ }
42
+ export declare class Ai {
43
+ private readonly client;
44
+ constructor(client: Client);
45
+ /** Translate text. Requires the AI Translation add-on on the project. */
46
+ translate(projectId: string, opts: TranslateOptions): Promise<TranslateResult>;
47
+ /** Run content moderation on text. Free for all projects; requires service key. */
48
+ moderate(projectId: string, text: string): Promise<ModerateResult>;
49
+ /** Get AI translation usage for the current billing cycle. */
50
+ usage(projectId: string): Promise<AiUsageResult>;
51
+ /**
52
+ * Generate an image from a text prompt. Costs $0.03 USDC via x402.
53
+ * No project scope — payment flows through the allowance-based fetch.
54
+ */
55
+ generateImage(opts: GenerateImageOptions): Promise<GenerateImageResult>;
56
+ }
57
+ //# sourceMappingURL=ai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/namespaces/ai.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAA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,OAAO,CAAC,aAAa,CAAC;IAUtD;;;OAGG;IACG,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAO9E"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * `ai` namespace — project-scoped AI add-ons (translation, moderation) and
3
+ * wallet-scoped image generation.
4
+ */
5
+ import { ProjectNotFound } from "../errors.js";
6
+ export class Ai {
7
+ client;
8
+ constructor(client) {
9
+ this.client = client;
10
+ }
11
+ /** Translate text. Requires the AI Translation add-on on the project. */
12
+ async translate(projectId, opts) {
13
+ const project = await this.client.getProject(projectId);
14
+ if (!project)
15
+ throw new ProjectNotFound(projectId, "translating text");
16
+ const body = { text: opts.text, to: opts.to };
17
+ if (opts.from)
18
+ body.from = opts.from;
19
+ if (opts.context)
20
+ body.context = opts.context;
21
+ return this.client.request("/ai/v1/translate", {
22
+ method: "POST",
23
+ headers: { Authorization: `Bearer ${project.service_key}` },
24
+ body,
25
+ context: "translating text",
26
+ });
27
+ }
28
+ /** Run content moderation on text. Free for all projects; requires service key. */
29
+ async moderate(projectId, text) {
30
+ const project = await this.client.getProject(projectId);
31
+ if (!project)
32
+ throw new ProjectNotFound(projectId, "moderating content");
33
+ return this.client.request("/ai/v1/moderate", {
34
+ method: "POST",
35
+ headers: { Authorization: `Bearer ${project.service_key}` },
36
+ body: { text },
37
+ context: "moderating content",
38
+ });
39
+ }
40
+ /** Get AI translation usage for the current billing cycle. */
41
+ async usage(projectId) {
42
+ const project = await this.client.getProject(projectId);
43
+ if (!project)
44
+ throw new ProjectNotFound(projectId, "fetching AI usage");
45
+ return this.client.request("/ai/v1/usage", {
46
+ headers: { Authorization: `Bearer ${project.service_key}` },
47
+ context: "fetching AI usage",
48
+ });
49
+ }
50
+ /**
51
+ * Generate an image from a text prompt. Costs $0.03 USDC via x402.
52
+ * No project scope — payment flows through the allowance-based fetch.
53
+ */
54
+ async generateImage(opts) {
55
+ return this.client.request("/generate-image/v1", {
56
+ method: "POST",
57
+ body: { prompt: opts.prompt, aspect: opts.aspect ?? "square" },
58
+ context: "generating image",
59
+ });
60
+ }
61
+ }
62
+ //# sourceMappingURL=ai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/namespaces/ai.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA6C/C,MAAM,OAAO,EAAE;IACgB;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,yEAAyE;IACzE,KAAK,CAAC,SAAS,CAAC,SAAiB,EAAE,IAAsB;QACvD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACxD,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,eAAe,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;QAEvE,MAAM,IAAI,GAA2B,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;QACtE,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrC,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE9C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAkB,kBAAkB,EAAE;YAC9D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,OAAO,CAAC,WAAW,EAAE,EAAE;YAC3D,IAAI;YACJ,OAAO,EAAE,kBAAkB;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,mFAAmF;IACnF,KAAK,CAAC,QAAQ,CAAC,SAAiB,EAAE,IAAY;QAC5C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACxD,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,eAAe,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAEzE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAiB,iBAAiB,EAAE;YAC5D,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,OAAO,CAAC,WAAW,EAAE,EAAE;YAC3D,IAAI,EAAE,EAAE,IAAI,EAAE;YACd,OAAO,EAAE,oBAAoB;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,8DAA8D;IAC9D,KAAK,CAAC,KAAK,CAAC,SAAiB;QAC3B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACxD,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,eAAe,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAExE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAgB,cAAc,EAAE;YACxD,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,OAAO,CAAC,WAAW,EAAE,EAAE;YAC3D,OAAO,EAAE,mBAAmB;SAC7B,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAC,IAA0B;QAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB,oBAAoB,EAAE;YACpE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE;YAC9D,OAAO,EAAE,kBAAkB;SAC5B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * `allowance` namespace — the agent's local wallet.
3
+ *
4
+ * `status`, `create`, `export` touch the local allowance file via optional
5
+ * provider methods. Sandbox providers that don't implement those throw a
6
+ * descriptive error at runtime.
7
+ *
8
+ * `faucet` is an API call (request testnet USDC) and works in any environment.
9
+ */
10
+ import type { Client } from "../kernel.js";
11
+ export interface AllowanceStatusResult {
12
+ address: string;
13
+ created?: string;
14
+ funded?: boolean;
15
+ lastFaucet?: string;
16
+ path?: string;
17
+ /** true when the local provider holds an allowance, false otherwise. */
18
+ configured: boolean;
19
+ }
20
+ export interface AllowanceCreateResult {
21
+ address: string;
22
+ created: string;
23
+ path?: string;
24
+ }
25
+ export interface FaucetResult {
26
+ transactionHash: string;
27
+ amount: string;
28
+ token: string;
29
+ network: string;
30
+ }
31
+ export declare class Allowance {
32
+ private readonly client;
33
+ constructor(client: Client);
34
+ /** Inspect the local allowance. Returns `{configured: false}` when absent. */
35
+ status(): Promise<AllowanceStatusResult>;
36
+ /**
37
+ * Generate a new allowance keypair and persist it. Throws when the
38
+ * provider already holds an allowance (don't overwrite silently) or
39
+ * when the provider doesn't support local allowance management.
40
+ */
41
+ create(): Promise<AllowanceCreateResult>;
42
+ /** Return the allowance address (safe to share). Throws if none is configured. */
43
+ export(): Promise<string>;
44
+ /**
45
+ * Request testnet USDC from the Run402 faucet. When `address` is omitted,
46
+ * the SDK uses the provider's local allowance address. Updates the
47
+ * allowance's `funded` flag on success.
48
+ */
49
+ faucet(address?: string): Promise<FaucetResult>;
50
+ }
51
+ //# sourceMappingURL=allowance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowance.d.ts","sourceRoot":"","sources":["../../src/namespaces/allowance.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C,8EAA8E;IACxE,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAiB9C;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC;IA4B9C,kFAAkF;IAC5E,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAY/B;;;;OAIG;IACG,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAyCtD"}