codai-sdk 0.13.0 → 0.54.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Dragos Catalin Vladulescu (codai)
3
+ Copyright (c) 2026 Interactive Media Solutions S.R.L. (codai)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -65,11 +65,30 @@ surface.
65
65
  | `receipt` | `get` | `GET /v1/receipt` |
66
66
  | `feedback` | `submit` | `POST /v1/feedback` |
67
67
  | `phoneModels` | `list` | `GET /v1/phone/models` |
68
- | `resolve` | `submit`, `get`, `accept`, `balance`, `attestation`, `keys`, `verifyAttestation`, `health`, `waitFor` | `https://resolve.codai.ro/v1/resolve/*` (own host) |
68
+ | `billing` | `get`, `invoices`, `watchBalance` (read-only) | `GET /v1/billing`, `GET /v1/billing/invoices` |
69
+ | `referrals` | `get`, `redeem`, `setConsent` | `GET /v1/referrals`, `PATCH /v1/account` |
70
+ | `resolve` | `submit`, `get`, `list`, `iterate`, `accept`, `balance`, `attestation`, `keys`, `verifyAttestation`, `health`, `waitFor` | `https://resolve.codai.ro/v1/resolve/*` (own host) |
69
71
 
70
72
  Every method takes an optional last argument `{ ext, signal }` where `ext` is a
71
73
  typed bag of `X-Codai-*` extension headers (see below).
72
74
 
75
+ ## Lists and the share sheet
76
+
77
+ `lists` covers `/v1/lists/*` and `POST /v1/share`: `list`, `create`, `reorder`,
78
+ `update`, `delete`, `items`, `add`, `updateItem`, `deleteItem`, `image`
79
+ (bytes + content type), `exportMarkdown` (string), `share` and `stream` (live
80
+ `list` events). `add` and `share` are idempotent on `client_id` / the canonical
81
+ URL: a duplicate answers 200 with `created: false`.
82
+
83
+ ```ts
84
+ const { item, list } = await client.lists.share({ url: 'https://example.com', auto: true });
85
+ const md = await client.lists.exportMarkdown(list.id);
86
+ for await (const ev of client.lists.stream()) console.log(ev.op, ev.listId, ev.itemId);
87
+ ```
88
+
89
+ `schedules.audit({ schedule_id?, limit? })` returns the scheduler audit log
90
+ (`GET /v1/schedules/audit`), newest first.
91
+
73
92
  ## Streaming
74
93
 
75
94
  ```ts
@@ -301,6 +320,40 @@ const me = await codai.account.get();
301
320
  await codai.account.update({ training_opt_out: true });
302
321
  ```
303
322
 
323
+ ## Host apps: keys, overrides and subscriptions (`CodaiApps`)
324
+
325
+ Apps that resell codai to their own users (e.g. studiai.ro) manage keys through the mgmt API
326
+ (`https://api.codai.ro`) with an **app connection token** (`codai_app_…`, created at
327
+ `codai.ro/console/apps/<app>`), not a user key. `CodaiApps` unwraps the `{ ok, data }` envelope and
328
+ throws `CodaiError` (`status`, `code` such as `missing_scope:keys.mint` or `no_key_for_external_id`).
329
+ Default timeout 20 s, one retry on 429/5xx; `keys.mint` is never retried.
330
+
331
+ ```ts
332
+ import { CodaiApps } from 'codai-sdk';
333
+
334
+ const apps = new CodaiApps({
335
+ appToken: process.env.CODAI_APP_TOKEN, // /apps/* calls
336
+ validateToken: process.env.CODAI_VALIDATE_TOKEN, // optional, validateKey only
337
+ });
338
+
339
+ const minted = await apps.keys.mint({
340
+ email: 'ana@example.com',
341
+ endUserExternalId: 'uid:gh1',
342
+ tierSlug: 'pro',
343
+ });
344
+ const keys = await apps.keys.list({ endUserExternalId: 'uid:gh1' });
345
+ const usage = await apps.keys.usage(minted.id, 30);
346
+ await apps.keys.update(minted.id, { enabled: false });
347
+ await apps.keys.revokeAllFor('uid:gh1');
348
+
349
+ await apps.users.setOverride('uid:gh1', { tasksPerDay: 200, resetUsage: true });
350
+ const { override, effectiveLimits } = await apps.users.getOverride('uid:gh1');
351
+ await apps.users.clearOverride('uid:gh1');
352
+
353
+ await apps.subscriptions.sync({ email: 'ana@example.com', event: stripeEvent });
354
+ const check = await apps.validateKey(presentedKey); // { valid, key?, entitlements?, reason? }
355
+ ```
356
+
304
357
  ## Feedback
305
358
 
306
359
  ```ts