codai-sdk 0.8.0 → 0.29.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/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
@@ -278,6 +278,8 @@ for await (const frame of codai.sessions.stream(session.id, { after: 0 })) {
278
278
  }
279
279
 
280
280
  await codai.sessions.dispatch(session.id, { device_id: phoneId, text: 'continue on the phone' });
281
+ // Handoff: just open the session on the phone, run nothing (`online` comes from devices.list()).
282
+ await codai.sessions.dispatch(session.id, { device_id: phoneId, mode: 'open' });
281
283
 
282
284
  // Host relay: run one op on a connected desktop
283
285
  const hosts = await codai.hosts.list();
@@ -299,6 +301,40 @@ const me = await codai.account.get();
299
301
  await codai.account.update({ training_opt_out: true });
300
302
  ```
301
303
 
304
+ ## Host apps: keys, overrides and subscriptions (`CodaiApps`)
305
+
306
+ Apps that resell codai to their own users (e.g. studiai.ro) manage keys through the mgmt API
307
+ (`https://api.codai.ro`) with an **app connection token** (`codai_app_…`, created at
308
+ `codai.ro/console/apps/<app>`), not a user key. `CodaiApps` unwraps the `{ ok, data }` envelope and
309
+ throws `CodaiError` (`status`, `code` such as `missing_scope:keys.mint` or `no_key_for_external_id`).
310
+ Default timeout 20 s, one retry on 429/5xx; `keys.mint` is never retried.
311
+
312
+ ```ts
313
+ import { CodaiApps } from 'codai-sdk';
314
+
315
+ const apps = new CodaiApps({
316
+ appToken: process.env.CODAI_APP_TOKEN, // /apps/* calls
317
+ validateToken: process.env.CODAI_VALIDATE_TOKEN, // optional, validateKey only
318
+ });
319
+
320
+ const minted = await apps.keys.mint({
321
+ email: 'ana@example.com',
322
+ endUserExternalId: 'uid:gh1',
323
+ tierSlug: 'pro',
324
+ });
325
+ const keys = await apps.keys.list({ endUserExternalId: 'uid:gh1' });
326
+ const usage = await apps.keys.usage(minted.id, 30);
327
+ await apps.keys.update(minted.id, { enabled: false });
328
+ await apps.keys.revokeAllFor('uid:gh1');
329
+
330
+ await apps.users.setOverride('uid:gh1', { tasksPerDay: 200, resetUsage: true });
331
+ const { override, effectiveLimits } = await apps.users.getOverride('uid:gh1');
332
+ await apps.users.clearOverride('uid:gh1');
333
+
334
+ await apps.subscriptions.sync({ email: 'ana@example.com', event: stripeEvent });
335
+ const check = await apps.validateKey(presentedKey); // { valid, key?, entitlements?, reason? }
336
+ ```
337
+
302
338
  ## Feedback
303
339
 
304
340
  ```ts