@gamma23/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,275 @@
1
+ # @gamma23/sdk
2
+
3
+ Official TypeScript SDK for the **Gamma23** agent payments API. Give your AI agents the ability to spend money safely — with budgets, policy guardrails, and full auditability.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @gamma23/sdk
9
+ ```
10
+
11
+ ```bash
12
+ pnpm add @gamma23/sdk
13
+ ```
14
+
15
+ ```bash
16
+ yarn add @gamma23/sdk
17
+ ```
18
+
19
+ > **Requirements:** Node.js 18+ (uses native `fetch`)
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { Gamma23 } from '@gamma23/sdk';
25
+
26
+ const gamma23 = new Gamma23({
27
+ apiKey: process.env.GAMMA23_API_KEY!, // gm23_...
28
+ });
29
+
30
+ // 1. Create a spend intent
31
+ const intent = await gamma23.spendIntents.create({
32
+ goal: 'Purchase cloud compute credits',
33
+ budget: 50.00,
34
+ currency: 'USD',
35
+ merchant: 'AWS',
36
+ category: 'cloud_compute',
37
+ });
38
+
39
+ console.log(`Intent ${intent.id}: ${intent.status}`);
40
+ // Intent si_abc123: APPROVED
41
+
42
+ // 2. Execute the approved intent
43
+ if (intent.spendToken) {
44
+ const result = await gamma23.spendIntents.execute(intent.id, {
45
+ spendToken: intent.spendToken,
46
+ mode: 'LIVE',
47
+ });
48
+
49
+ console.log(`Transaction ${result.transactionId}: $${result.amount}`);
50
+ }
51
+ ```
52
+
53
+ ## Configuration
54
+
55
+ ```typescript
56
+ const gamma23 = new Gamma23({
57
+ apiKey: 'gm23_...', // Required — your API key
58
+ baseUrl: 'https://...', // Optional — defaults to GAMMA23_API_URL env var or https://gamma23.app
59
+ timeout: 30_000, // Optional — request timeout in ms (default: 30s)
60
+ maxRetries: 3, // Optional — retry count for 429/5xx (default: 3)
61
+ });
62
+ ```
63
+
64
+ ## API Reference
65
+
66
+ ### Spend Intents
67
+
68
+ Spend intents are the core primitive — they represent an agent's *intent* to spend money, subject to policy evaluation.
69
+
70
+ #### `spendIntents.create(params)`
71
+
72
+ Create a new spend intent for policy evaluation.
73
+
74
+ ```typescript
75
+ const intent = await gamma23.spendIntents.create({
76
+ goal: 'Book a flight to SF',
77
+ budget: 500,
78
+ currency: 'USD', // optional, defaults to USD
79
+ merchant: 'United', // optional
80
+ category: 'travel', // optional
81
+ domain: 'united.com', // optional
82
+ metadata: { trip: 'Q1' }, // optional, arbitrary metadata
83
+ idempotencyKey: 'uniq-1', // optional, prevents duplicate creation
84
+ });
85
+ ```
86
+
87
+ **Returns:** `SpendIntent`
88
+
89
+ | Field | Type | Description |
90
+ |-------|------|-------------|
91
+ | `id` | `string` | Unique intent identifier |
92
+ | `status` | `SpendIntentStatus` | `PENDING`, `APPROVED`, `DENIED`, `EXECUTED`, `CANCELLED`, `EXPIRED` |
93
+ | `goal` | `string` | What the agent wants to buy |
94
+ | `budget` | `number` | Maximum spend amount |
95
+ | `currency` | `string` | ISO 4217 currency code |
96
+ | `selectedRail` | `string \| null` | Payment rail selected by policy |
97
+ | `policyDecision` | `string \| null` | Policy engine decision details |
98
+ | `spendToken` | `string` | Token required to execute (present when approved) |
99
+ | `executeUrl` | `string` | URL to execute the intent |
100
+ | `tokenExpiresInSeconds` | `number` | Time until token expires |
101
+ | `spendRequestId` | `string` | Associated spend request ID |
102
+
103
+ #### `spendIntents.get(id)`
104
+
105
+ Retrieve a spend intent by ID.
106
+
107
+ ```typescript
108
+ const intent = await gamma23.spendIntents.get('si_abc123');
109
+ ```
110
+
111
+ #### `spendIntents.cancel(id)`
112
+
113
+ Cancel a pending or approved spend intent.
114
+
115
+ ```typescript
116
+ const cancelled = await gamma23.spendIntents.cancel('si_abc123');
117
+ ```
118
+
119
+ #### `spendIntents.execute(id, params)`
120
+
121
+ Execute an approved spend intent.
122
+
123
+ ```typescript
124
+ const result = await gamma23.spendIntents.execute('si_abc123', {
125
+ spendToken: intent.spendToken!,
126
+ mode: 'LIVE', // MANUAL | MOCK | SIMULATED | LIVE
127
+ });
128
+ ```
129
+
130
+ **Returns:** `ExecuteResult`
131
+
132
+ | Field | Type | Description |
133
+ |-------|------|-------------|
134
+ | `intentId` | `string` | The intent that was executed |
135
+ | `transactionId` | `string` | Unique transaction identifier |
136
+ | `status` | `string` | Transaction status |
137
+ | `amount` | `number` | Amount charged |
138
+ | `currency` | `string` | Currency of the charge |
139
+ | `riskFlags` | `string[]` | Any risk flags raised |
140
+ | `isSimulated` | `boolean` | Whether this was a simulation |
141
+ | `stripeIntentId` | `string` | Stripe PaymentIntent ID (if applicable) |
142
+ | `instructions` | `string` | Manual execution instructions (if MANUAL mode) |
143
+ | `message` | `string` | Human-readable status message |
144
+
145
+ ---
146
+
147
+ ### Payments
148
+
149
+ Direct payment requests, bypassing the intent flow.
150
+
151
+ #### `payments.create(params)`
152
+
153
+ ```typescript
154
+ const payment = await gamma23.payments.create({
155
+ amount: 25.00,
156
+ merchant: 'Stripe',
157
+ domain: 'stripe.com',
158
+ category: 'saas',
159
+ reason: 'Monthly subscription',
160
+ evidenceLinks: ['https://example.com/invoice.pdf'],
161
+ idempotencyKey: 'pay-001',
162
+ });
163
+ ```
164
+
165
+ #### `payments.execute(id, params)`
166
+
167
+ ```typescript
168
+ const result = await gamma23.payments.execute(payment.id, {
169
+ spendToken: '...',
170
+ mode: 'LIVE',
171
+ });
172
+ ```
173
+
174
+ ---
175
+
176
+ ### Agents
177
+
178
+ #### `agents.getBudget(agentId)`
179
+
180
+ Get the current budget status for an agent.
181
+
182
+ ```typescript
183
+ const budget = await gamma23.agents.getBudget('agent_abc');
184
+
185
+ console.log(`Remaining: $${budget.remainingBudget}`);
186
+ console.log(`Utilization: ${budget.budgetUtilizationPct}%`);
187
+ console.log(`Can spend: ${budget.canSpend}`);
188
+ ```
189
+
190
+ **Returns:** `AgentBudget`
191
+
192
+ | Field | Type | Description |
193
+ |-------|------|-------------|
194
+ | `agentId` | `string` | Agent identifier |
195
+ | `agentName` | `string` | Human-readable agent name |
196
+ | `monthlyBudget` | `number` | Total monthly budget |
197
+ | `currentSpend` | `number` | Amount spent this period |
198
+ | `remainingBudget` | `number` | Budget remaining |
199
+ | `budgetUtilizationPct` | `number` | Percentage of budget used |
200
+ | `canSpend` | `boolean` | Whether the agent can still spend |
201
+
202
+ ---
203
+
204
+ ## Error Handling
205
+
206
+ All API errors throw a `Gamma23Error` with structured fields:
207
+
208
+ ```typescript
209
+ import { Gamma23, Gamma23Error, Gamma23TimeoutError } from '@gamma23/sdk';
210
+
211
+ try {
212
+ await gamma23.spendIntents.create({ goal: '...', budget: 100 });
213
+ } catch (err) {
214
+ if (err instanceof Gamma23Error) {
215
+ console.error(`Status: ${err.status}`); // HTTP status code
216
+ console.error(`Code: ${err.code}`); // API error code
217
+ console.error(`Message: ${err.message}`); // Human-readable message
218
+ console.error(`Request ID: ${err.requestId}`); // For support tickets
219
+ }
220
+
221
+ if (err instanceof Gamma23TimeoutError) {
222
+ console.error('Request timed out — try increasing the timeout');
223
+ }
224
+ }
225
+ ```
226
+
227
+ ### Error Types
228
+
229
+ | Class | When |
230
+ |-------|------|
231
+ | `Gamma23Error` | Any non-2xx API response |
232
+ | `Gamma23TimeoutError` | Request exceeded timeout |
233
+ | `Gamma23ConnectionError` | Network / DNS failure |
234
+
235
+ ---
236
+
237
+ ## Retry Behavior
238
+
239
+ The SDK automatically retries on transient failures (HTTP 429, 5xx) with exponential backoff:
240
+
241
+ | Attempt | Delay |
242
+ |---------|-------|
243
+ | 1st retry | ~1s + jitter |
244
+ | 2nd retry | ~2s + jitter |
245
+ | 3rd retry | ~4s + jitter |
246
+
247
+ Customize via `maxRetries`:
248
+
249
+ ```typescript
250
+ const gamma23 = new Gamma23({
251
+ apiKey: '...',
252
+ maxRetries: 5, // up to 5 retries
253
+ });
254
+ ```
255
+
256
+ Set `maxRetries: 0` to disable retries entirely.
257
+
258
+ ---
259
+
260
+ ## TypeScript
261
+
262
+ This SDK is written in TypeScript and ships with full type declarations. All request params and response types are exported:
263
+
264
+ ```typescript
265
+ import type {
266
+ CreateSpendIntentParams,
267
+ SpendIntent,
268
+ ExecuteResult,
269
+ AgentBudget,
270
+ } from '@gamma23/sdk';
271
+ ```
272
+
273
+ ## License
274
+
275
+ MIT
@@ -0,0 +1,25 @@
1
+ import { SpendIntentsResource } from './resources/spend-intents';
2
+ import { PaymentsResource } from './resources/payments';
3
+ import { AgentsResource } from './resources/agents';
4
+ import type { RequestOptions } from './types';
5
+ export interface Gamma23Config {
6
+ apiKey: string;
7
+ baseUrl?: string;
8
+ timeout?: number;
9
+ maxRetries?: number;
10
+ }
11
+ export declare class Gamma23 {
12
+ readonly spendIntents: SpendIntentsResource;
13
+ readonly payments: PaymentsResource;
14
+ readonly agents: AgentsResource;
15
+ private readonly apiKey;
16
+ private readonly baseUrl;
17
+ private readonly timeout;
18
+ private readonly maxRetries;
19
+ constructor(config: Gamma23Config);
20
+ /** @internal */
21
+ _request<T>(options: RequestOptions): Promise<T>;
22
+ }
23
+ /** Recursively convert camelCase keys to snake_case for outgoing requests. */
24
+ export declare function toSnakeCase(obj: unknown): unknown;
25
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAOD,qBAAa,OAAO;IAClB,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,MAAM,EAAE,aAAa;IAoBjC,gBAAgB;IACV,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;CAoFvD;AA8BD,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAWjD"}
package/dist/client.js ADDED
@@ -0,0 +1,134 @@
1
+ import { Gamma23Error, Gamma23TimeoutError, Gamma23ConnectionError } from './errors';
2
+ import { SpendIntentsResource } from './resources/spend-intents';
3
+ import { PaymentsResource } from './resources/payments';
4
+ import { AgentsResource } from './resources/agents';
5
+ const DEFAULT_BASE_URL = 'https://gamma23.app';
6
+ const DEFAULT_TIMEOUT_MS = 30000;
7
+ const DEFAULT_MAX_RETRIES = 3;
8
+ const RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503, 504]);
9
+ export class Gamma23 {
10
+ constructor(config) {
11
+ if (!config.apiKey) {
12
+ throw new Error('Missing required apiKey. Pass it via new Gamma23({ apiKey: "gm23_..." })');
13
+ }
14
+ this.apiKey = config.apiKey;
15
+ this.baseUrl =
16
+ config.baseUrl ??
17
+ (typeof process !== 'undefined' ? process.env?.GAMMA23_API_URL : undefined) ??
18
+ DEFAULT_BASE_URL;
19
+ this.timeout = config.timeout ?? DEFAULT_TIMEOUT_MS;
20
+ this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
21
+ this.spendIntents = new SpendIntentsResource(this);
22
+ this.payments = new PaymentsResource(this);
23
+ this.agents = new AgentsResource(this);
24
+ }
25
+ /** @internal */
26
+ async _request(options) {
27
+ const url = `${this.baseUrl}${options.path}`;
28
+ const headers = {
29
+ Authorization: `Bearer ${this.apiKey}`,
30
+ 'Content-Type': 'application/json',
31
+ Accept: 'application/json',
32
+ 'User-Agent': '@gamma23/sdk/0.1.0',
33
+ ...options.headers,
34
+ };
35
+ if (options.idempotencyKey) {
36
+ headers['Idempotency-Key'] = options.idempotencyKey;
37
+ }
38
+ let lastError;
39
+ for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
40
+ if (attempt > 0) {
41
+ const backoff = Math.min(1000 * 2 ** (attempt - 1), 10000);
42
+ const jitter = Math.random() * backoff * 0.5;
43
+ await sleep(backoff + jitter);
44
+ }
45
+ const controller = new AbortController();
46
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
47
+ try {
48
+ const response = await fetch(url, {
49
+ method: options.method,
50
+ headers,
51
+ body: options.body != null ? JSON.stringify(options.body) : undefined,
52
+ signal: controller.signal,
53
+ });
54
+ clearTimeout(timeoutId);
55
+ if (response.ok) {
56
+ const json = await response.json();
57
+ return toCamelCase(json);
58
+ }
59
+ const requestId = response.headers.get('x-request-id') ??
60
+ response.headers.get('x-gamma23-request-id');
61
+ let errorBody = {};
62
+ try {
63
+ errorBody = await response.json();
64
+ }
65
+ catch {
66
+ // non-JSON error body
67
+ }
68
+ const message = errorBody.message ??
69
+ errorBody.error ??
70
+ `Request failed with status ${response.status}`;
71
+ const code = errorBody.code ?? null;
72
+ const error = new Gamma23Error(message, response.status, code, requestId);
73
+ if (!RETRYABLE_STATUS_CODES.has(response.status)) {
74
+ throw error;
75
+ }
76
+ lastError = error;
77
+ }
78
+ catch (err) {
79
+ clearTimeout(timeoutId);
80
+ if (err instanceof Gamma23Error) {
81
+ if (!RETRYABLE_STATUS_CODES.has(err.status))
82
+ throw err;
83
+ lastError = err;
84
+ }
85
+ else if (err instanceof DOMException && err.name === 'AbortError') {
86
+ lastError = new Gamma23TimeoutError(this.timeout);
87
+ if (attempt === this.maxRetries)
88
+ throw lastError;
89
+ }
90
+ else {
91
+ lastError = new Gamma23ConnectionError(err);
92
+ if (attempt === this.maxRetries)
93
+ throw lastError;
94
+ }
95
+ }
96
+ }
97
+ throw lastError;
98
+ }
99
+ }
100
+ function sleep(ms) {
101
+ return new Promise((resolve) => setTimeout(resolve, ms));
102
+ }
103
+ // ── Case conversion helpers ────────────────────────────────────────────
104
+ function snakeToCamel(str) {
105
+ return str.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
106
+ }
107
+ function camelToSnake(str) {
108
+ return str.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
109
+ }
110
+ /** Recursively convert snake_case keys to camelCase. */
111
+ function toCamelCase(obj) {
112
+ if (Array.isArray(obj))
113
+ return obj.map(toCamelCase);
114
+ if (obj !== null && typeof obj === 'object') {
115
+ return Object.fromEntries(Object.entries(obj).map(([key, value]) => [
116
+ snakeToCamel(key),
117
+ toCamelCase(value),
118
+ ]));
119
+ }
120
+ return obj;
121
+ }
122
+ /** Recursively convert camelCase keys to snake_case for outgoing requests. */
123
+ export function toSnakeCase(obj) {
124
+ if (Array.isArray(obj))
125
+ return obj.map(toSnakeCase);
126
+ if (obj !== null && typeof obj === 'object') {
127
+ return Object.fromEntries(Object.entries(obj).map(([key, value]) => [
128
+ camelToSnake(key),
129
+ toSnakeCase(value),
130
+ ]));
131
+ }
132
+ return obj;
133
+ }
134
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAA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AAE,EAAE,CAAC;YACnE,YAAY,CAAC,GAAG,CAAC;YACjB,WAAW,CAAC,KAAK,CAAC;SACnB,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAA8B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YACnE,YAAY,CAAC,GAAG,CAAC;YACjB,WAAW,CAAC,KAAK,CAAC;SACnB,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare class Gamma23Error extends Error {
2
+ readonly status: number;
3
+ readonly code: string | null;
4
+ readonly requestId: string | null;
5
+ constructor(message: string, status: number, code?: string | null, requestId?: string | null);
6
+ toString(): string;
7
+ }
8
+ export declare class Gamma23TimeoutError extends Gamma23Error {
9
+ constructor(timeoutMs: number);
10
+ }
11
+ export declare class Gamma23ConnectionError extends Gamma23Error {
12
+ constructor(cause: unknown);
13
+ }
14
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;gBAGhC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAM,GAAG,IAAW,EAC1B,SAAS,GAAE,MAAM,GAAG,IAAW;IAWjC,QAAQ,IAAI,MAAM;CAOnB;AAED,qBAAa,mBAAoB,SAAQ,YAAY;gBACvC,SAAS,EAAE,MAAM;CAK9B;AAED,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,KAAK,EAAE,OAAO;CAO3B"}
package/dist/errors.js ADDED
@@ -0,0 +1,35 @@
1
+ export class Gamma23Error extends Error {
2
+ constructor(message, status, code = null, requestId = null) {
3
+ super(message);
4
+ this.name = 'Gamma23Error';
5
+ this.status = status;
6
+ this.code = code;
7
+ this.requestId = requestId;
8
+ Object.setPrototypeOf(this, Gamma23Error.prototype);
9
+ }
10
+ toString() {
11
+ const parts = [`Gamma23Error [${this.status}]`];
12
+ if (this.code)
13
+ parts.push(`(${this.code})`);
14
+ parts.push(`: ${this.message}`);
15
+ if (this.requestId)
16
+ parts.push(` (request_id: ${this.requestId})`);
17
+ return parts.join('');
18
+ }
19
+ }
20
+ export class Gamma23TimeoutError extends Gamma23Error {
21
+ constructor(timeoutMs) {
22
+ super(`Request timed out after ${timeoutMs}ms`, 0, 'TIMEOUT');
23
+ this.name = 'Gamma23TimeoutError';
24
+ Object.setPrototypeOf(this, Gamma23TimeoutError.prototype);
25
+ }
26
+ }
27
+ export class Gamma23ConnectionError extends Gamma23Error {
28
+ constructor(cause) {
29
+ const message = cause instanceof Error ? cause.message : 'Connection failed';
30
+ super(message, 0, 'CONNECTION_ERROR');
31
+ this.name = 'Gamma23ConnectionError';
32
+ Object.setPrototypeOf(this, Gamma23ConnectionError.prototype);
33
+ }
34
+ }
35
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAKrC,YACE,OAA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AAC,OAAO,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ export { Gamma23 } from './client';
2
+ export type { Gamma23Config } from './client';
3
+ export { Gamma23Error, Gamma23TimeoutError, Gamma23ConnectionError } from './errors';
4
+ export { SpendIntentsResource } from './resources/spend-intents';
5
+ export { PaymentsResource } from './resources/payments';
6
+ export { AgentsResource } from './resources/agents';
7
+ export type { CreateSpendIntentParams, SpendIntent, SpendIntentStatus, ExecuteSpendIntentParams, ExecuteResult, CreatePaymentParams, PaymentRequest, ExecutePaymentParams, AgentBudget, RequestOptions, } from './types';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAErF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,YAAY,EACV,uBAAuB,EACvB,WAAW,EACX,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,cAAc,GACf,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { Gamma23 } from './client';
2
+ export { Gamma23Error, Gamma23TimeoutError, Gamma23ConnectionError } from './errors';
3
+ export { SpendIntentsResource } from './resources/spend-intents';
4
+ export { PaymentsResource } from './resources/payments';
5
+ export { AgentsResource } from './resources/agents';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAErF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Gamma23 } from '../client';
2
+ import type { AgentBudget } from '../types';
3
+ export declare class AgentsResource {
4
+ private readonly client;
5
+ constructor(client: Gamma23);
6
+ getBudget(agentId: string): Promise<AgentBudget>;
7
+ }
8
+ //# sourceMappingURL=agents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/resources/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,OAAO;IAEtC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAMvD"}
@@ -0,0 +1,12 @@
1
+ export class AgentsResource {
2
+ constructor(client) {
3
+ this.client = client;
4
+ }
5
+ async getBudget(agentId) {
6
+ return this.client._request({
7
+ method: 'GET',
8
+ path: `/api/v1/agents/${encodeURIComponent(agentId)}/budget`,
9
+ });
10
+ }
11
+ }
12
+ //# sourceMappingURL=agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/resources/agents.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IACzB,YAA6B,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;IAEhD,KAAK,CAAC,SAAS,CAAC,OAAe;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAc;YACvC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,OAAO,CAAC,SAAS;SAC7D,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { SpendIntentsResource } from './spend-intents';
2
+ export { PaymentsResource } from './payments';
3
+ export { AgentsResource } from './agents';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { SpendIntentsResource } from './spend-intents';
2
+ export { PaymentsResource } from './payments';
3
+ export { AgentsResource } from './agents';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Gamma23 } from '../client';
2
+ import type { CreatePaymentParams, PaymentRequest, ExecutePaymentParams, ExecuteResult } from '../types';
3
+ export declare class PaymentsResource {
4
+ private readonly client;
5
+ constructor(client: Gamma23);
6
+ create(params: CreatePaymentParams): Promise<PaymentRequest>;
7
+ execute(id: string, params: ExecutePaymentParams): Promise<ExecuteResult>;
8
+ }
9
+ //# sourceMappingURL=payments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../../src/resources/payments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,OAAO;IAEtC,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAU5D,OAAO,CACX,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,aAAa,CAAC;CAO1B"}
@@ -0,0 +1,23 @@
1
+ import { toSnakeCase } from '../client';
2
+ export class PaymentsResource {
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ async create(params) {
7
+ const { idempotencyKey, ...body } = params;
8
+ return this.client._request({
9
+ method: 'POST',
10
+ path: '/api/v1/payments',
11
+ body: toSnakeCase(body),
12
+ idempotencyKey,
13
+ });
14
+ }
15
+ async execute(id, params) {
16
+ return this.client._request({
17
+ method: 'POST',
18
+ path: `/api/v1/payments/${encodeURIComponent(id)}/execute`,
19
+ body: toSnakeCase(params),
20
+ });
21
+ }
22
+ }
23
+ //# sourceMappingURL=payments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments.js","sourceRoot":"","sources":["../../src/resources/payments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQxC,MAAM,OAAO,gBAAgB;IAC3B,YAA6B,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;IAEhD,KAAK,CAAC,MAAM,CAAC,MAA2B;QACtC,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAiB;YAC1C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;YACvB,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CACX,EAAU,EACV,MAA4B;QAE5B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAgB;YACzC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,oBAAoB,kBAAkB,CAAC,EAAE,CAAC,UAAU;YAC1D,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import type { Gamma23 } from '../client';
2
+ import type { CreateSpendIntentParams, SpendIntent, ExecuteSpendIntentParams, ExecuteResult } from '../types';
3
+ export declare class SpendIntentsResource {
4
+ private readonly client;
5
+ constructor(client: Gamma23);
6
+ create(params: CreateSpendIntentParams): Promise<SpendIntent>;
7
+ get(id: string): Promise<SpendIntent>;
8
+ cancel(id: string): Promise<SpendIntent>;
9
+ execute(id: string, params: ExecuteSpendIntentParams): Promise<ExecuteResult>;
10
+ }
11
+ //# sourceMappingURL=spend-intents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spend-intents.d.ts","sourceRoot":"","sources":["../../src/resources/spend-intents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EACV,uBAAuB,EACvB,WAAW,EACX,wBAAwB,EACxB,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,OAAO;IAEtC,MAAM,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC;IAU7D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOrC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOxC,OAAO,CACX,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,aAAa,CAAC;CAO1B"}
@@ -0,0 +1,35 @@
1
+ import { toSnakeCase } from '../client';
2
+ export class SpendIntentsResource {
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ async create(params) {
7
+ const { idempotencyKey, ...body } = params;
8
+ return this.client._request({
9
+ method: 'POST',
10
+ path: '/api/v1/spend-intents',
11
+ body: toSnakeCase(body),
12
+ idempotencyKey,
13
+ });
14
+ }
15
+ async get(id) {
16
+ return this.client._request({
17
+ method: 'GET',
18
+ path: `/api/v1/spend-intents/${encodeURIComponent(id)}`,
19
+ });
20
+ }
21
+ async cancel(id) {
22
+ return this.client._request({
23
+ method: 'POST',
24
+ path: `/api/v1/spend-intents/${encodeURIComponent(id)}/cancel`,
25
+ });
26
+ }
27
+ async execute(id, params) {
28
+ return this.client._request({
29
+ method: 'POST',
30
+ path: `/api/v1/spend-intents/${encodeURIComponent(id)}/execute`,
31
+ body: toSnakeCase(params),
32
+ });
33
+ }
34
+ }
35
+ //# sourceMappingURL=spend-intents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spend-intents.js","sourceRoot":"","sources":["../../src/resources/spend-intents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQxC,MAAM,OAAO,oBAAoB;IAC/B,YAA6B,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;IAEhD,KAAK,CAAC,MAAM,CAAC,MAA+B;QAC1C,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAc;YACvC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,uBAAuB;YAC7B,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;YACvB,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAc;YACvC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,yBAAyB,kBAAkB,CAAC,EAAE,CAAC,EAAE;SACxD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAc;YACvC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,yBAAyB,kBAAkB,CAAC,EAAE,CAAC,SAAS;SAC/D,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CACX,EAAU,EACV,MAAgC;QAEhC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAgB;YACzC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,yBAAyB,kBAAkB,CAAC,EAAE,CAAC,UAAU;YAC/D,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,80 @@
1
+ export interface CreateSpendIntentParams {
2
+ goal: string;
3
+ budget: number;
4
+ currency?: string;
5
+ merchant?: string;
6
+ category?: string;
7
+ domain?: string;
8
+ metadata?: Record<string, unknown>;
9
+ idempotencyKey?: string;
10
+ }
11
+ export type SpendIntentStatus = 'PENDING' | 'APPROVED' | 'DENIED' | 'EXECUTED' | 'CANCELLED' | 'EXPIRED';
12
+ export interface SpendIntent {
13
+ id: string;
14
+ status: SpendIntentStatus;
15
+ goal: string;
16
+ budget: number;
17
+ currency: string;
18
+ selectedRail: string | null;
19
+ policyDecision: string | null;
20
+ spendToken?: string;
21
+ executeUrl?: string;
22
+ tokenExpiresInSeconds?: number;
23
+ spendRequestId?: string;
24
+ }
25
+ export interface ExecuteSpendIntentParams {
26
+ spendToken: string;
27
+ mode?: 'MANUAL' | 'MOCK' | 'SIMULATED' | 'LIVE';
28
+ }
29
+ export interface ExecuteResult {
30
+ intentId: string;
31
+ transactionId: string;
32
+ status: string;
33
+ amount: number;
34
+ currency: string;
35
+ riskFlags: string[];
36
+ isSimulated?: boolean;
37
+ stripeIntentId?: string;
38
+ instructions?: string;
39
+ message?: string;
40
+ }
41
+ export interface CreatePaymentParams {
42
+ amount: number;
43
+ merchant: string;
44
+ domain?: string;
45
+ category?: string;
46
+ reason?: string;
47
+ evidenceLinks?: string[];
48
+ idempotencyKey?: string;
49
+ }
50
+ export interface PaymentRequest {
51
+ id: string;
52
+ status: string;
53
+ amount: number;
54
+ merchant: string;
55
+ domain?: string;
56
+ category?: string;
57
+ reason?: string;
58
+ evidenceLinks?: string[];
59
+ }
60
+ export interface ExecutePaymentParams {
61
+ spendToken: string;
62
+ mode?: 'MANUAL' | 'MOCK' | 'SIMULATED' | 'LIVE';
63
+ }
64
+ export interface AgentBudget {
65
+ agentId: string;
66
+ agentName: string;
67
+ monthlyBudget: number;
68
+ currentSpend: number;
69
+ remainingBudget: number;
70
+ budgetUtilizationPct: number;
71
+ canSpend: boolean;
72
+ }
73
+ export interface RequestOptions {
74
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
75
+ path: string;
76
+ body?: unknown;
77
+ headers?: Record<string, string>;
78
+ idempotencyKey?: string;
79
+ }
80
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ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CAAC,EAAE,MAAM,CAAC;CACzB"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ // ── Spend Intents ──────────────────────────────────────────────────────
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0EAA0E"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@gamma23/sdk",
3
+ "version": "0.1.0",
4
+ "description": "Official TypeScript SDK for the Gamma23 agent payments API",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc",
27
+ "clean": "rm -rf dist",
28
+ "prepublishOnly": "npm run clean && npm run build",
29
+ "typecheck": "tsc --noEmit"
30
+ },
31
+ "keywords": [
32
+ "gamma23",
33
+ "payments",
34
+ "ai-agents",
35
+ "spend-intents",
36
+ "sdk",
37
+ "typescript"
38
+ ],
39
+ "author": "Gamma23",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/gamma23/sdk-typescript"
44
+ },
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "typescript": "^5.3.0"
50
+ }
51
+ }