@oxyhq/core 20.1.0 → 21.0.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.
Files changed (109) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/HttpService.js +47 -8
  3. package/dist/cjs/boot/sessionColdBoot.js +107 -8
  4. package/dist/cjs/i18n/locales/en-US.json +26 -4
  5. package/dist/cjs/i18n/locales/es-ES.json +26 -4
  6. package/dist/cjs/i18n/locales/locales/en-US.json +26 -4
  7. package/dist/cjs/i18n/locales/locales/es-ES.json +26 -4
  8. package/dist/cjs/index.js +57 -16
  9. package/dist/cjs/inference/OxyInferenceClient.js +330 -0
  10. package/dist/cjs/mixins/OxyServices.accounts.js +5 -72
  11. package/dist/cjs/mixins/OxyServices.auth.js +27 -3
  12. package/dist/cjs/mixins/OxyServices.inference.js +59 -0
  13. package/dist/cjs/mixins/OxyServices.utility.js +18 -6
  14. package/dist/cjs/mixins/index.js +6 -0
  15. package/dist/cjs/server/auth.js +76 -0
  16. package/dist/cjs/server/index.js +5 -1
  17. package/dist/cjs/session/SessionClient.js +361 -1
  18. package/dist/cjs/session/accountDialogController.js +121 -147
  19. package/dist/cjs/session/accountSwitchTargets.js +75 -0
  20. package/dist/cjs/session/deviceDirectory.js +143 -0
  21. package/dist/cjs/session/deviceSwitcherRows.js +76 -0
  22. package/dist/cjs/session/projectSessionState.js +8 -1
  23. package/dist/cjs/session/sharedDeviceCredential.js +247 -0
  24. package/dist/esm/.tsbuildinfo +1 -1
  25. package/dist/esm/HttpService.js +47 -8
  26. package/dist/esm/boot/sessionColdBoot.js +107 -8
  27. package/dist/esm/i18n/locales/en-US.json +26 -4
  28. package/dist/esm/i18n/locales/es-ES.json +26 -4
  29. package/dist/esm/i18n/locales/locales/en-US.json +26 -4
  30. package/dist/esm/i18n/locales/locales/es-ES.json +26 -4
  31. package/dist/esm/index.js +36 -10
  32. package/dist/esm/inference/OxyInferenceClient.js +325 -0
  33. package/dist/esm/mixins/OxyServices.accounts.js +5 -72
  34. package/dist/esm/mixins/OxyServices.auth.js +27 -3
  35. package/dist/esm/mixins/OxyServices.inference.js +56 -0
  36. package/dist/esm/mixins/OxyServices.utility.js +18 -6
  37. package/dist/esm/mixins/index.js +6 -0
  38. package/dist/esm/server/auth.js +72 -0
  39. package/dist/esm/server/index.js +1 -1
  40. package/dist/esm/session/SessionClient.js +362 -2
  41. package/dist/esm/session/accountDialogController.js +121 -147
  42. package/dist/esm/session/accountSwitchTargets.js +71 -0
  43. package/dist/esm/session/deviceDirectory.js +135 -0
  44. package/dist/esm/session/deviceSwitcherRows.js +72 -0
  45. package/dist/esm/session/projectSessionState.js +8 -2
  46. package/dist/esm/session/sharedDeviceCredential.js +239 -0
  47. package/dist/types/.tsbuildinfo +1 -1
  48. package/dist/types/HttpService.d.ts +39 -1
  49. package/dist/types/boot/sessionColdBoot.d.ts +24 -4
  50. package/dist/types/index.d.ts +11 -4
  51. package/dist/types/inference/OxyInferenceClient.d.ts +324 -0
  52. package/dist/types/mixins/OxyServices.accounts.d.ts +73 -95
  53. package/dist/types/mixins/OxyServices.auth.d.ts +75 -3
  54. package/dist/types/mixins/OxyServices.inference.d.ts +95 -0
  55. package/dist/types/mixins/OxyServices.utility.d.ts +44 -13
  56. package/dist/types/mixins/index.d.ts +2 -1
  57. package/dist/types/models/session.d.ts +11 -0
  58. package/dist/types/server/auth.d.ts +80 -0
  59. package/dist/types/server/index.d.ts +2 -2
  60. package/dist/types/session/SessionClient.d.ts +202 -1
  61. package/dist/types/session/accountDialogController.d.ts +76 -64
  62. package/dist/types/session/accountSwitchTargets.d.ts +64 -0
  63. package/dist/types/session/deviceDirectory.d.ts +182 -0
  64. package/dist/types/session/deviceSwitcherRows.d.ts +92 -0
  65. package/dist/types/session/projectSessionState.d.ts +29 -0
  66. package/dist/types/session/sharedDeviceCredential.d.ts +202 -0
  67. package/package.json +3 -3
  68. package/src/HttpService.ts +50 -10
  69. package/src/__tests__/httpServiceUnwrapEnvelope.test.ts +115 -0
  70. package/src/boot/__tests__/sessionColdBoot.sharedDevice.test.ts +325 -0
  71. package/src/boot/sessionColdBoot.ts +133 -9
  72. package/src/i18n/locales/en-US.json +26 -4
  73. package/src/i18n/locales/es-ES.json +26 -4
  74. package/src/index.ts +94 -25
  75. package/src/inference/OxyInferenceClient.ts +590 -0
  76. package/src/inference/__tests__/OxyInferenceClient.test.ts +383 -0
  77. package/src/mixins/OxyServices.accounts.ts +75 -176
  78. package/src/mixins/OxyServices.auth.ts +67 -5
  79. package/src/mixins/OxyServices.inference.ts +57 -0
  80. package/src/mixins/OxyServices.utility.ts +58 -14
  81. package/src/mixins/__tests__/accounts.test.ts +57 -102
  82. package/src/mixins/__tests__/inferenceFactory.test.ts +58 -0
  83. package/src/mixins/__tests__/preSessionSkipAuth.test.ts +54 -1
  84. package/src/mixins/__tests__/serviceAuth.test.ts +2 -0
  85. package/src/mixins/index.ts +8 -0
  86. package/src/models/session.ts +11 -0
  87. package/src/server/__tests__/serviceTokenAttribution.test.ts +396 -0
  88. package/src/server/auth.ts +118 -0
  89. package/src/server/index.ts +6 -0
  90. package/src/session/SessionClient.ts +386 -1
  91. package/src/session/__tests__/SessionClient.directory.test.ts +688 -0
  92. package/src/session/__tests__/accountDialogController.test.ts +411 -278
  93. package/src/session/__tests__/accountDialogShape.test.ts +118 -0
  94. package/src/session/__tests__/accountSwitchTargets.test.ts +132 -0
  95. package/src/session/__tests__/deviceDirectory.test.ts +422 -0
  96. package/src/session/__tests__/deviceSwitcherRows.test.ts +223 -0
  97. package/src/session/__tests__/projectSessionState.test.ts +17 -0
  98. package/src/session/__tests__/sharedDeviceCredential.test.ts +300 -0
  99. package/src/session/accountDialogController.ts +141 -179
  100. package/src/session/accountSwitchTargets.ts +87 -0
  101. package/src/session/deviceDirectory.ts +269 -0
  102. package/src/session/deviceSwitcherRows.ts +145 -0
  103. package/src/session/projectSessionState.ts +9 -3
  104. package/src/session/sharedDeviceCredential.ts +349 -0
  105. package/dist/cjs/session/accountProjection.js +0 -213
  106. package/dist/esm/session/accountProjection.js +0 -207
  107. package/dist/types/session/accountProjection.d.ts +0 -198
  108. package/src/session/__tests__/accountProjection.test.ts +0 -447
  109. package/src/session/accountProjection.ts +0 -354
@@ -965,19 +965,46 @@ class HttpService {
965
965
  return this.deviceSecretMintInFlight;
966
966
  }
967
967
  /**
968
- * Unwrap standardized API response format
968
+ * Unwrap the standardized API response envelope — EXCEPT when the envelope is
969
+ * a page, in which case it travels whole.
970
+ *
971
+ * `{ data: <payload> }` is the house success envelope (`sendSuccess`), and
972
+ * reducing it to `<payload>` is what every call site in the SDK expects. But
973
+ * the reduction DISCARDS every sibling key, silently, and a page's siblings
974
+ * are the only thing that says where the next page starts. That is how
975
+ * `GET /accounts/:id/audit` lost its `nextCursor`: the caller received a bare
976
+ * array, `getNextPageParam` read `undefined`, and pagination was dead past the
977
+ * first page with nothing to show that it was.
978
+ *
979
+ * ## Why the rule is narrow, and not "any sibling key survives"
980
+ *
981
+ * "An object carrying `data` plus anything else is not an envelope" is the
982
+ * tempting general rule, and it is wrong here: this API already answers
983
+ * `{ data, count }` on ~15 routes, plus `{ data, source }`, `{ data, reason }`
984
+ * and `{ data, secretDestroyed }`, and a dozen measured Console call sites
985
+ * type those as the bare payload (`Array<ProviderConnection>`,
986
+ * `AccountBillingState | null`, …). Preserving those envelopes would hand every
987
+ * one of them an object where it expects its payload — at runtime only, since
988
+ * the response type is a call-site assertion. So the rule names PAGINATION
989
+ * specifically: `data` beside {@link PAGE_ENVELOPE_KEYS} is a page.
990
+ *
991
+ * A route whose sibling key genuinely matters to its caller belongs in that
992
+ * list, or should not be a sibling of `data` at all — the cursor-paginated
993
+ * surfaces already in the SDK (`{ follows, nextCursor }`,
994
+ * `{ records, nextCursor }`) sidestep this by never using `data`.
969
995
  */
970
996
  unwrapResponse(responseData) {
971
- // Handle paginated responses: { data: [...], pagination: {...} }
972
- if (responseData && typeof responseData === 'object' && 'data' in responseData && 'pagination' in responseData) {
997
+ if (!responseData || typeof responseData !== 'object' || !('data' in responseData)) {
998
+ // Not the success envelope (or not an object at all) as-is.
973
999
  return responseData;
974
1000
  }
975
- // Handle regular success responses: { data: ... }
976
- if (responseData && typeof responseData === 'object' && 'data' in responseData && !Array.isArray(responseData)) {
977
- return responseData.data;
1001
+ // A page travels whole: its cursor/pagination sibling is unrecoverable
1002
+ // information, not decoration.
1003
+ if (HttpService.PAGE_ENVELOPE_KEYS.some((key) => key in responseData)) {
1004
+ return responseData;
978
1005
  }
979
- // Return as-is for responses that don't use sendSuccess wrapper
980
- return responseData;
1006
+ // Regular success envelope: `{ data: ... }` -> the payload.
1007
+ return Array.isArray(responseData) ? responseData : responseData.data;
981
1008
  }
982
1009
  /**
983
1010
  * Update request metrics
@@ -1155,3 +1182,15 @@ exports.HttpService = HttpService;
1155
1182
  * ambiguous with a serialized request body.
1156
1183
  */
1157
1184
  HttpService.CACHE_IDENTITY_DELIM = ' id=';
1185
+ /**
1186
+ * The keys whose presence beside `data` makes a body a PAGE rather than a
1187
+ * payload — see {@link unwrapResponse} for why this list is narrow.
1188
+ *
1189
+ * - `pagination` — the offset-paginated house envelope (`sendPaginated`).
1190
+ * - `nextCursor` — the keyset-paginated one (the account audit trails).
1191
+ *
1192
+ * Membership is decided by key PRESENCE, never by value: the last page sends
1193
+ * `nextCursor: null`, and an envelope that collapsed into a bare payload
1194
+ * exactly when the stream ended would be a worse bug than the one this fixes.
1195
+ */
1196
+ HttpService.PAGE_ENVELOPE_KEYS = ['pagination', 'nextCursor'];
@@ -18,10 +18,17 @@ exports.runSessionColdBoot = runSessionColdBoot;
18
18
  * origin persisted a `deviceId` + `deviceSecret`, mint a short access token
19
19
  * with a single bearer-less POST to `/session/device/token` (no cookie, no
20
20
  * navigation) and rotate the secret in-use.
21
- * 3. `shared-key-signin` (native, ACCOUNT mode) — re-mint from the
22
- * shared-keychain identity OR `identity-key-signin` (IDENTITY mode)
23
- * re-mint from THIS device's primary identity key.
24
- * 4. Signed out.
21
+ * 3. `shared-device-adopt` (native, ACCOUNT mode) — this app has no credential
22
+ * of its own but a sibling official app already put one in the shared native
23
+ * slot: adopt it and mint. This is how a newly installed official app joins
24
+ * the device's existing session WITHOUT another QR and without ever touching
25
+ * the Commons private key.
26
+ * 4. `shared-key-signin` (native, ACCOUNT mode) — the legacy lane: re-mint by
27
+ * signing with the shared-keychain IDENTITY key. Retained as a recovery /
28
+ * compatibility path for devices whose apps have not yet published a shared
29
+ * device credential — OR `identity-key-signin` (IDENTITY mode) — re-mint
30
+ * from THIS device's primary identity key.
31
+ * 5. Signed out.
25
32
  *
26
33
  * Two session modes (see {@link RunSessionColdBootOptions.sessionMode}):
27
34
  * - `account` (default) — the device's ACTIVE account owns the session. Every
@@ -40,6 +47,7 @@ const logger_1 = require("../logger");
40
47
  const cacheKey_1 = require("../utils/cacheKey");
41
48
  const refresh_1 = require("../session/refresh");
42
49
  const identitySession_1 = require("../session/identitySession");
50
+ const sharedDeviceCredential_1 = require("../session/sharedDeviceCredential");
43
51
  /**
44
52
  * Run the device-first cold boot. Resolves to the `runColdBoot` outcome and, as
45
53
  * a side effect, invokes `onSession` (winning session, token already planted) or
@@ -239,10 +247,101 @@ async function runSessionColdBoot(opts) {
239
247
  },
240
248
  });
241
249
  }
242
- else {
243
- // 3. shared-key-signin (native) — re-mint from the shared identity. Native
244
- // AND online: it is a network step (challenge + verify round-trips), so it
245
- // is gated by the same offline hint as the mint lane. `{ retry: false }`
250
+ else if (opts.sharedDeviceCredential) {
251
+ // 3. shared-device-adopt (native, ACCOUNT mode) — join the device's existing
252
+ // session through the shared native credential slot.
253
+ //
254
+ // This is the lane that separates identity from session transport. What it
255
+ // reads is an ordinary, individually revocable `deviceId` + `deviceSecret`
256
+ // put there by a sibling official app — never the Commons private key. It
257
+ // is what lets a freshly installed official app land signed in with no QR,
258
+ // and it is why an ordinary app never needs identity-key access at all.
259
+ //
260
+ // `decideSharedDeviceJoin` gates it: an app that already holds its own
261
+ // credential is never moved, and an UNREADABLE slot is never mistaken for
262
+ // an empty one. The lane therefore cannot sign anyone out, in either
263
+ // upgrade order.
264
+ const sharedSlot = opts.sharedDeviceCredential;
265
+ steps.push({
266
+ id: 'shared-device-adopt',
267
+ // The adoption itself is local, but it is only worth committing alongside
268
+ // a mint that proves the credential — so the whole lane is online-gated
269
+ // like every other network step.
270
+ enabled: () => isNative && !isOffline(),
271
+ run: async () => {
272
+ const before = await store.load();
273
+ const decision = (0, sharedDeviceCredential_1.decideSharedDeviceJoin)(before, await sharedSlot.read());
274
+ if (decision.action === 'skip') {
275
+ logger_1.logger.debug(`shared device credential not adopted (${decision.reason})`, { component: 'sessionColdBoot', method: 'shared-device-adopt' });
276
+ return { kind: 'skip' };
277
+ }
278
+ // Restore the store to exactly what it held before this lane touched it.
279
+ // A credential we adopted and could not prove must not be left behind for
280
+ // the next boot's mint lane to keep retrying.
281
+ const revert = async () => {
282
+ if (before) {
283
+ await store.save(before);
284
+ }
285
+ else {
286
+ await store.clear();
287
+ }
288
+ };
289
+ const adopted = {
290
+ // The mint fills both in from the device's live state; carrying the
291
+ // previous session's ids into a different device session would be a
292
+ // lie for however long the mint takes.
293
+ sessionId: '',
294
+ userId: '',
295
+ deviceId: decision.credential.deviceId,
296
+ deviceSecret: decision.credential.deviceSecret,
297
+ };
298
+ if (!(await store.save(adopted))) {
299
+ logger_1.logger.error('adopted the shared device credential but it could not be durably persisted — reverting', undefined, { component: 'sessionColdBoot', method: 'shared-device-adopt' });
300
+ await revert();
301
+ return { kind: 'skip' };
302
+ }
303
+ const result = await (0, refresh_1.refreshDeviceSecretArm)({ oxy, store, pin: null });
304
+ if (result.status === 'ok') {
305
+ return {
306
+ kind: 'session',
307
+ session: {
308
+ sessionId: result.sessionId,
309
+ userId: result.userId,
310
+ accessToken: result.token,
311
+ },
312
+ };
313
+ }
314
+ if (result.status === 'invalid-secret') {
315
+ // The one place we hold POSITIVE proof that the exact bytes in the
316
+ // shared slot are dead — the server rejected them by name. Clearing it
317
+ // signs nobody out (a credential the server does not recognise cannot
318
+ // be minting for anyone) and it is what stops a dead credential from
319
+ // blocking every future install: a stale slot owned by a different
320
+ // `deviceId` is otherwise never overwritten, by design.
321
+ await sharedSlot.clear();
322
+ }
323
+ else if (result.status === 'no-session') {
324
+ signedOutReason = 'no_session';
325
+ }
326
+ await revert();
327
+ return { kind: 'skip' };
328
+ },
329
+ });
330
+ }
331
+ if (identityBinding === null) {
332
+ // 4. shared-key-signin (native) — the RECOVERY / COMPATIBILITY lane: sign a
333
+ // challenge with the shared-keychain IDENTITY key to re-mint a session.
334
+ //
335
+ // It runs LAST on purpose. Using the self-custody key to obtain an ordinary
336
+ // session is the over-sharing #937 sets out to end, so it is now reachable
337
+ // only on a device where no sibling app has published a shared device
338
+ // credential yet — an install that predates this lane, or one where the
339
+ // shared slot is unreadable. Its own `store.save` below feeds the shared
340
+ // slot through the mirroring store, so the FIRST boot that takes this lane
341
+ // is also the last one that needs to: every later app joins by credential.
342
+ //
343
+ // Native AND online: it is a network step (challenge + verify round-trips),
344
+ // so it is gated by the same offline hint as the mint lane. `{ retry: false }`
246
345
  // keeps the two round-trips as single attempts — the refresh scheduler /
247
346
  // 401 lane own later retries — so this step cannot multiply boot latency.
248
347
  steps.push({
@@ -396,13 +396,22 @@
396
396
  "remoteSignOutFailed": "There was a problem signing out from the device. Please try again.",
397
397
  "noOtherDeviceSessions": "No other device sessions found to sign out from.",
398
398
  "signOutOthersSuccess": "Signed out from all other devices successfully!",
399
- "signOutOthersFailed": "There was a problem signing out from other devices. Please try again."
399
+ "signOutOthersFailed": "There was a problem signing out from other devices. Please try again.",
400
+ "contextRemoved": "Removed {{account}}",
401
+ "contextRemoveFailed": "There was a problem removing that account. Please try again.",
402
+ "principalRemoved": "Signed {{name}} out of this device",
403
+ "principalRemoveFailed": "There was a problem signing that person out. Please try again.",
404
+ "activateFailed": "There was a problem switching accounts. Please try again."
400
405
  },
401
406
  "confirms": {
402
407
  "remove": "Are you sure you want to remove {{displayName}} from this device? You'll need to sign in again to access this account.",
403
408
  "logoutAll": "Are you sure you want to sign out of all accounts? This will remove all saved accounts from this device.",
404
409
  "remoteLogout": "Are you sure you want to sign out from \"{{deviceName}}\"? This will end the session on that device.",
405
- "logoutOthers": "Are you sure you want to sign out from all {{count}} other device(s)? This will end sessions on all other devices except this one."
410
+ "logoutOthers": "Are you sure you want to sign out from all {{count}} other device(s)? This will end sessions on all other devices except this one.",
411
+ "removeContextTitle": "Remove this account?",
412
+ "removeContext": "Stop {{person}} acting as {{account}} on this device? Anyone else who reaches {{account}} here keeps their access.",
413
+ "removePrincipalTitle": "Sign out of this device?",
414
+ "removePrincipal": "Sign {{name}} out of this device? Every account they reach here is removed. Nobody else is affected."
406
415
  },
407
416
  "device": {
408
417
  "loadingTitle": "Loading device sessions...",
@@ -439,6 +448,14 @@
439
448
  "openedInCommons": "Opened in Commons",
440
449
  "confirming": "Confirming identity",
441
450
  "confirmed": "Identity confirmed"
451
+ },
452
+ "context": {
453
+ "unavailable": "Unavailable right now",
454
+ "operatedBy": "Operated by {{name}}",
455
+ "remove": "Remove {{account}} from {{person}}"
456
+ },
457
+ "principal": {
458
+ "signOut": "Sign {{name}} out of this device"
442
459
  }
443
460
  },
444
461
  "reputation": {
@@ -2119,8 +2136,13 @@
2119
2136
  "filesWrite": "Upload and modify your files",
2120
2137
  "filesDelete": "Delete your files",
2121
2138
  "webhooksReceive": "Receive webhooks",
2122
- "chatCompletions": "Use AI chat on your behalf",
2123
- "modelsRead": "List available AI models",
2139
+ "inferenceInvoke": "Run AI requests on your behalf",
2140
+ "inferenceModelsRead": "List available AI models",
2141
+ "inferenceUsageRead": "Read its AI usage and costs",
2142
+ "inferenceRoutingRead": "Read how AI requests are routed",
2143
+ "inferenceRoutingWrite": "Change how AI requests are routed",
2144
+ "inferenceProvidersRead": "Read its connected AI providers",
2145
+ "inferenceProvidersWrite": "Manage its connected AI providers",
2124
2146
  "federationWrite": "Act across federated services"
2125
2147
  },
2126
2148
  "account": {
@@ -636,13 +636,22 @@
636
636
  "remoteSignOutFailed": "Hubo un problema al cerrar sesión en el dispositivo. Inténtalo de nuevo.",
637
637
  "noOtherDeviceSessions": "No se encontraron otras sesiones de dispositivo para cerrar.",
638
638
  "signOutOthersSuccess": "¡Sesiones cerradas correctamente en los demás dispositivos!",
639
- "signOutOthersFailed": "Hubo un problema al cerrar sesión en otros dispositivos. Inténtalo de nuevo."
639
+ "signOutOthersFailed": "Hubo un problema al cerrar sesión en otros dispositivos. Inténtalo de nuevo.",
640
+ "contextRemoved": "Se quitó {{account}}",
641
+ "contextRemoveFailed": "Hubo un problema al quitar esa cuenta. Inténtalo de nuevo.",
642
+ "principalRemoved": "Se cerró la sesión de {{name}} en este dispositivo",
643
+ "principalRemoveFailed": "Hubo un problema al cerrar esa sesión. Inténtalo de nuevo.",
644
+ "activateFailed": "Hubo un problema al cambiar de cuenta. Inténtalo de nuevo."
640
645
  },
641
646
  "confirms": {
642
647
  "remove": "¿Seguro que quieres eliminar a {{displayName}} de este dispositivo? Tendrás que iniciar sesión de nuevo para acceder a esta cuenta.",
643
648
  "logoutAll": "¿Seguro que quieres cerrar sesión en todas las cuentas? Esto eliminará todas las cuentas guardadas de este dispositivo.",
644
649
  "remoteLogout": "¿Seguro que quieres cerrar sesión en \"{{deviceName}}\"? Esto finalizará la sesión en ese dispositivo.",
645
- "logoutOthers": "¿Seguro que quieres cerrar sesión en los otros {{count}} dispositivo(s)? Esto finalizará las sesiones en todos los demás dispositivos excepto en este."
650
+ "logoutOthers": "¿Seguro que quieres cerrar sesión en los otros {{count}} dispositivo(s)? Esto finalizará las sesiones en todos los demás dispositivos excepto en este.",
651
+ "removeContextTitle": "¿Quitar esta cuenta?",
652
+ "removeContext": "¿Dejar de usar {{account}} como {{person}} en este dispositivo? Quien más acceda a {{account}} aquí lo conserva.",
653
+ "removePrincipalTitle": "¿Cerrar sesión en este dispositivo?",
654
+ "removePrincipal": "¿Cerrar la sesión de {{name}} en este dispositivo? Se quitan todas las cuentas a las que llega desde aquí. No afecta a nadie más."
646
655
  },
647
656
  "device": {
648
657
  "loadingTitle": "Cargando sesiones de dispositivo...",
@@ -679,6 +688,14 @@
679
688
  "openedInCommons": "Abierto en Commons",
680
689
  "confirming": "Confirmando identidad",
681
690
  "confirmed": "Identidad confirmada"
691
+ },
692
+ "context": {
693
+ "unavailable": "No disponible ahora mismo",
694
+ "operatedBy": "Gestionada por {{name}}",
695
+ "remove": "Quitar {{account}} de {{person}}"
696
+ },
697
+ "principal": {
698
+ "signOut": "Cerrar la sesión de {{name}} en este dispositivo"
682
699
  }
683
700
  },
684
701
  "feedback": {
@@ -2119,8 +2136,13 @@
2119
2136
  "filesWrite": "Subir y modificar tus archivos",
2120
2137
  "filesDelete": "Eliminar tus archivos",
2121
2138
  "webhooksReceive": "Recibir webhooks",
2122
- "chatCompletions": "Usar el chat con IA en tu nombre",
2123
- "modelsRead": "Ver los modelos de IA disponibles",
2139
+ "inferenceInvoke": "Ejecutar peticiones de IA en tu nombre",
2140
+ "inferenceModelsRead": "Ver los modelos de IA disponibles",
2141
+ "inferenceUsageRead": "Ver su consumo y costes de IA",
2142
+ "inferenceRoutingRead": "Ver cómo se enrutan las peticiones de IA",
2143
+ "inferenceRoutingWrite": "Cambiar cómo se enrutan las peticiones de IA",
2144
+ "inferenceProvidersRead": "Ver sus proveedores de IA conectados",
2145
+ "inferenceProvidersWrite": "Gestionar sus proveedores de IA conectados",
2124
2146
  "federationWrite": "Actuar en servicios federados"
2125
2147
  },
2126
2148
  "account": {
@@ -396,13 +396,22 @@
396
396
  "remoteSignOutFailed": "There was a problem signing out from the device. Please try again.",
397
397
  "noOtherDeviceSessions": "No other device sessions found to sign out from.",
398
398
  "signOutOthersSuccess": "Signed out from all other devices successfully!",
399
- "signOutOthersFailed": "There was a problem signing out from other devices. Please try again."
399
+ "signOutOthersFailed": "There was a problem signing out from other devices. Please try again.",
400
+ "contextRemoved": "Removed {{account}}",
401
+ "contextRemoveFailed": "There was a problem removing that account. Please try again.",
402
+ "principalRemoved": "Signed {{name}} out of this device",
403
+ "principalRemoveFailed": "There was a problem signing that person out. Please try again.",
404
+ "activateFailed": "There was a problem switching accounts. Please try again."
400
405
  },
401
406
  "confirms": {
402
407
  "remove": "Are you sure you want to remove {{displayName}} from this device? You'll need to sign in again to access this account.",
403
408
  "logoutAll": "Are you sure you want to sign out of all accounts? This will remove all saved accounts from this device.",
404
409
  "remoteLogout": "Are you sure you want to sign out from \"{{deviceName}}\"? This will end the session on that device.",
405
- "logoutOthers": "Are you sure you want to sign out from all {{count}} other device(s)? This will end sessions on all other devices except this one."
410
+ "logoutOthers": "Are you sure you want to sign out from all {{count}} other device(s)? This will end sessions on all other devices except this one.",
411
+ "removeContextTitle": "Remove this account?",
412
+ "removeContext": "Stop {{person}} acting as {{account}} on this device? Anyone else who reaches {{account}} here keeps their access.",
413
+ "removePrincipalTitle": "Sign out of this device?",
414
+ "removePrincipal": "Sign {{name}} out of this device? Every account they reach here is removed. Nobody else is affected."
406
415
  },
407
416
  "device": {
408
417
  "loadingTitle": "Loading device sessions...",
@@ -439,6 +448,14 @@
439
448
  "openedInCommons": "Opened in Commons",
440
449
  "confirming": "Confirming identity",
441
450
  "confirmed": "Identity confirmed"
451
+ },
452
+ "context": {
453
+ "unavailable": "Unavailable right now",
454
+ "operatedBy": "Operated by {{name}}",
455
+ "remove": "Remove {{account}} from {{person}}"
456
+ },
457
+ "principal": {
458
+ "signOut": "Sign {{name}} out of this device"
442
459
  }
443
460
  },
444
461
  "reputation": {
@@ -2119,8 +2136,13 @@
2119
2136
  "filesWrite": "Upload and modify your files",
2120
2137
  "filesDelete": "Delete your files",
2121
2138
  "webhooksReceive": "Receive webhooks",
2122
- "chatCompletions": "Use AI chat on your behalf",
2123
- "modelsRead": "List available AI models",
2139
+ "inferenceInvoke": "Run AI requests on your behalf",
2140
+ "inferenceModelsRead": "List available AI models",
2141
+ "inferenceUsageRead": "Read its AI usage and costs",
2142
+ "inferenceRoutingRead": "Read how AI requests are routed",
2143
+ "inferenceRoutingWrite": "Change how AI requests are routed",
2144
+ "inferenceProvidersRead": "Read its connected AI providers",
2145
+ "inferenceProvidersWrite": "Manage its connected AI providers",
2124
2146
  "federationWrite": "Act across federated services"
2125
2147
  },
2126
2148
  "account": {
@@ -636,13 +636,22 @@
636
636
  "remoteSignOutFailed": "Hubo un problema al cerrar sesión en el dispositivo. Inténtalo de nuevo.",
637
637
  "noOtherDeviceSessions": "No se encontraron otras sesiones de dispositivo para cerrar.",
638
638
  "signOutOthersSuccess": "¡Sesiones cerradas correctamente en los demás dispositivos!",
639
- "signOutOthersFailed": "Hubo un problema al cerrar sesión en otros dispositivos. Inténtalo de nuevo."
639
+ "signOutOthersFailed": "Hubo un problema al cerrar sesión en otros dispositivos. Inténtalo de nuevo.",
640
+ "contextRemoved": "Se quitó {{account}}",
641
+ "contextRemoveFailed": "Hubo un problema al quitar esa cuenta. Inténtalo de nuevo.",
642
+ "principalRemoved": "Se cerró la sesión de {{name}} en este dispositivo",
643
+ "principalRemoveFailed": "Hubo un problema al cerrar esa sesión. Inténtalo de nuevo.",
644
+ "activateFailed": "Hubo un problema al cambiar de cuenta. Inténtalo de nuevo."
640
645
  },
641
646
  "confirms": {
642
647
  "remove": "¿Seguro que quieres eliminar a {{displayName}} de este dispositivo? Tendrás que iniciar sesión de nuevo para acceder a esta cuenta.",
643
648
  "logoutAll": "¿Seguro que quieres cerrar sesión en todas las cuentas? Esto eliminará todas las cuentas guardadas de este dispositivo.",
644
649
  "remoteLogout": "¿Seguro que quieres cerrar sesión en \"{{deviceName}}\"? Esto finalizará la sesión en ese dispositivo.",
645
- "logoutOthers": "¿Seguro que quieres cerrar sesión en los otros {{count}} dispositivo(s)? Esto finalizará las sesiones en todos los demás dispositivos excepto en este."
650
+ "logoutOthers": "¿Seguro que quieres cerrar sesión en los otros {{count}} dispositivo(s)? Esto finalizará las sesiones en todos los demás dispositivos excepto en este.",
651
+ "removeContextTitle": "¿Quitar esta cuenta?",
652
+ "removeContext": "¿Dejar de usar {{account}} como {{person}} en este dispositivo? Quien más acceda a {{account}} aquí lo conserva.",
653
+ "removePrincipalTitle": "¿Cerrar sesión en este dispositivo?",
654
+ "removePrincipal": "¿Cerrar la sesión de {{name}} en este dispositivo? Se quitan todas las cuentas a las que llega desde aquí. No afecta a nadie más."
646
655
  },
647
656
  "device": {
648
657
  "loadingTitle": "Cargando sesiones de dispositivo...",
@@ -679,6 +688,14 @@
679
688
  "openedInCommons": "Abierto en Commons",
680
689
  "confirming": "Confirmando identidad",
681
690
  "confirmed": "Identidad confirmada"
691
+ },
692
+ "context": {
693
+ "unavailable": "No disponible ahora mismo",
694
+ "operatedBy": "Gestionada por {{name}}",
695
+ "remove": "Quitar {{account}} de {{person}}"
696
+ },
697
+ "principal": {
698
+ "signOut": "Cerrar la sesión de {{name}} en este dispositivo"
682
699
  }
683
700
  },
684
701
  "feedback": {
@@ -2119,8 +2136,13 @@
2119
2136
  "filesWrite": "Subir y modificar tus archivos",
2120
2137
  "filesDelete": "Eliminar tus archivos",
2121
2138
  "webhooksReceive": "Recibir webhooks",
2122
- "chatCompletions": "Usar el chat con IA en tu nombre",
2123
- "modelsRead": "Ver los modelos de IA disponibles",
2139
+ "inferenceInvoke": "Ejecutar peticiones de IA en tu nombre",
2140
+ "inferenceModelsRead": "Ver los modelos de IA disponibles",
2141
+ "inferenceUsageRead": "Ver su consumo y costes de IA",
2142
+ "inferenceRoutingRead": "Ver cómo se enrutan las peticiones de IA",
2143
+ "inferenceRoutingWrite": "Cambiar cómo se enrutan las peticiones de IA",
2144
+ "inferenceProvidersRead": "Ver sus proveedores de IA conectados",
2145
+ "inferenceProvidersWrite": "Gestionar sus proveedores de IA conectados",
2124
2146
  "federationWrite": "Actuar en servicios federados"
2125
2147
  },
2126
2148
  "account": {
package/dist/cjs/index.js CHANGED
@@ -21,8 +21,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.AEAD_KEY_LENGTH = exports.decryptAead = exports.encryptAead = exports.hkdfSha256 = exports.RecoveryPhraseService = exports.SignatureService = exports.updateIdentityMarker = exports.readIdentityMarker = exports.IdentityUnavailableError = exports.IdentityPersistError = exports.IdentityAlreadyExistsError = exports.KeyManager = exports.sessionsArraysEqual = exports.normalizeAndSortSessions = exports.mergeSessions = exports.authenticatedApiCall = exports.withAuthErrorHandling = exports.isAuthenticationError = exports.ensureValidToken = exports.AuthenticationFailedError = exports.SessionSyncRequiredError = exports.verifyPublicCardAttestation = exports.parseAttestPayload = exports.parseIdPayload = exports.buildUserDid = exports.kindAcceptsAccountCategories = exports.isSelectableAccountCategoryId = exports.SELECTABLE_ACCOUNT_CATEGORY_IDS = exports.MAX_ACCOUNT_CATEGORIES = exports.ACCOUNT_CATEGORY_IDS = exports.normalizeProfileLinks = exports.getNormalizedUserHandle = exports.getCanonicalUserHandle = exports.normalizeUserIdentityOrNull = exports.normalizeUserIdentity = exports.getNormalizedUserId = exports.OxyAppDataIdentifierError = exports.commonsDeliveryPlatform = exports.pushTargetsFromDelivery = exports.selectCommonsDelivery = exports.parseCommonsApprovalExpiresAt = exports.getCommonsApprovalBlockingReason = exports.ServiceCredentialMismatchError = exports.oxyClient = exports.OXY_CLOUD_URL = exports.ServiceAssetMetadataError = exports.OxyAuthenticationTimeoutError = exports.OxyAuthenticationError = exports.AssetUrlResolutionError = exports.OxyServices = void 0;
22
22
  exports.calculateBackoffInterval = exports.createCircuitBreakerState = exports.DEFAULT_CIRCUIT_BREAKER_CONFIG = exports.isRetryableError = exports.isNetworkError = exports.isServerError = exports.isRateLimitError = exports.isNotFoundError = exports.isForbiddenError = exports.isUnauthorizedError = exports.isAlreadyRegisteredError = exports.getErrorMessage = exports.getErrorStatus = exports.HttpStatus = exports.getSystemColorScheme = exports.systemPrefersDarkMode = exports.getOppositeTheme = exports.normalizeColorScheme = exports.normalizeTheme = exports.getContrastTextColor = exports.isLightColor = exports.withOpacity = exports.rgbToHex = exports.hexToRgb = exports.lightenColor = exports.darkenColor = exports.isWebBrowser = exports.isAndroid = exports.isIOS = exports.isNative = exports.isWeb = exports.setPlatformOS = exports.getPlatformOS = exports.getPrimaryLanguage = exports.getUserLanguages = exports.isRTLLocale = exports.getNativeLanguageName = exports.getLanguageName = exports.getLanguageMetadata = exports.isSupportedLocale = exports.normalizeLocale = exports.getBaseLanguage = exports.FALLBACK_LOCALE = exports.SUPPORTED_LANGUAGES = exports.TopicSource = exports.TopicType = exports.SECURITY_EVENT_SEVERITY_MAP = exports.DeviceManager = exports.deriveSharedSecret = exports.AEAD_NONCE_LENGTH = void 0;
23
23
  exports.normalizeInlineText = exports.validateAndSanitizeUserInput = exports.isValidObjectId = exports.sanitizeHTML = exports.sanitizeString = exports.isValidFileType = exports.isValidFileSize = exports.isValidDate = exports.isValidURL = exports.isValidUUID = exports.isValidObject = exports.isValidArray = exports.isRequiredBoolean = exports.isRequiredNumber = exports.isRequiredString = exports.DISPLAY_NAME_UNFLANKED_SEPARATOR_SOURCE = exports.DISPLAY_NAME_ORPHANED_MARK_SOURCE = exports.DISPLAY_NAME_DISALLOWED_SOURCE = exports.DISPLAY_NAME_ALLOWED_SCRIPTS = exports.isValidDisplayName = exports.isValidPassword = exports.isValidUsername = exports.isValidEmail = exports.DISPLAY_NAME_INVALID_MESSAGE = exports.MAX_DISPLAY_NAME_LENGTH = exports.PASSWORD_REGEX = exports.USERNAME_REGEX = exports.EMAIL_REGEX = exports.retryAsync = exports.validateRequiredFields = exports.parseHttpErrorBody = exports.isHttpRequestError = exports.handleHttpError = exports.createApiError = exports.ErrorCodes = exports.safeJsonParse = exports.buildPaginationParams = exports.buildUrl = exports.buildSearchParams = exports.buildQueryParams = exports.trustTierLabel = exports.reputationCategoryLabel = exports.accountRoleLabel = exports.accountCategoryLabel = exports.translate = exports.withRetry = exports.delay = exports.shouldAllowRequest = exports.recordSuccess = exports.recordFailure = void 0;
24
- exports.switchableAccountIds = exports.projectSwitchableAccounts = exports.canSwitchIntoAccount = exports.isSwitchTargetAccount = exports.accountIdsOf = exports.activeUserOf = exports.activeSessionIdOf = exports.deviceStateToClientSessions = exports.createSessionClient = exports.createSessionClientHost = exports.SessionClient = exports.isAllowedDeviceJoinOrigin = exports.isOfficialWebOrigin = exports.isLoopbackOrigin = exports.consumeOAuthReturnPath = exports.persistOAuthReturnPath = exports.clearOAuthHandshake = exports.readOAuthHandshake = exports.persistOAuthHandshake = exports.canonicalizeOAuthRedirectUri = exports.normalizeOAuthRedirectUri = exports.OXY_OAUTH_RETURN_PATH_STORAGE_KEY = exports.OXY_OAUTH_REDIRECT_URI_STORAGE_KEY = exports.OXY_OAUTH_CODE_VERIFIER_STORAGE_KEY = exports.OXY_OAUTH_STATE_STORAGE_KEY = exports.OXY_AUTHORIZE_URL = exports.DEFAULT_OAUTH_SCOPE = exports.generatePkcePair = exports.generateOAuthState = exports.computeCodeChallenge = exports.buildOAuthAuthorizeUrl = exports.runColdBoot = exports.isOxyRpOrigin = exports.CENTRAL_IDP_APEX = exports.registrableApex = exports.getAccountColor = exports.formatPublicKeyHandle = exports.getAccountFallbackHandle = exports.getAccountDisplayName = exports.createQuickAccount = exports.buildAccountsArray = exports.updateAvatarVisibility = exports.isDev = exports.consoleSink = exports.resetLoggerConfig = exports.getLoggerConfig = exports.configureLogger = exports.createLogger = exports.logger = exports.normalizeMultilineText = void 0;
25
- exports.packageInfo = exports.runSessionColdBoot = exports.TOKEN_REFRESH_LEAD_MS = exports.startTokenRefreshScheduler = exports.installAuthRefreshHandler = exports.createAuthRefreshHandler = exports.refreshDeviceSecretArm = exports.refreshPersistedSession = exports.AccountNotOnDeviceError = exports.establishIdentitySession = exports.resolveIdentityPin = exports.IDENTITY_PIN_STORAGE_KEY = exports.identityPinMatches = exports.createMemoryIdentityPinStore = exports.createNativeIdentityPinStore = exports.createWebIdentityPinStore = exports.AUTH_STATE_STORAGE_KEY = exports.createMemoryAuthStateStore = exports.createNativeAuthStateStore = exports.createWebAuthStateStore = exports.createAccountDialogController = exports.AccountDialogController = void 0;
24
+ exports.projectDevicePrincipals = exports.directoryHandle = exports.directoryDisplayName = exports.canActivateContext = exports.accountIdsOf = exports.activeUserOf = exports.activeSessionIdOf = exports.deviceStateToClientSessions = exports.createSessionClient = exports.createSessionClientHost = exports.SessionClient = exports.isAllowedDeviceJoinOrigin = exports.isOfficialWebOrigin = exports.isLoopbackOrigin = exports.consumeOAuthReturnPath = exports.persistOAuthReturnPath = exports.clearOAuthHandshake = exports.readOAuthHandshake = exports.persistOAuthHandshake = exports.canonicalizeOAuthRedirectUri = exports.normalizeOAuthRedirectUri = exports.OXY_OAUTH_RETURN_PATH_STORAGE_KEY = exports.OXY_OAUTH_REDIRECT_URI_STORAGE_KEY = exports.OXY_OAUTH_CODE_VERIFIER_STORAGE_KEY = exports.OXY_OAUTH_STATE_STORAGE_KEY = exports.OXY_AUTHORIZE_URL = exports.DEFAULT_OAUTH_SCOPE = exports.generatePkcePair = exports.generateOAuthState = exports.computeCodeChallenge = exports.buildOAuthAuthorizeUrl = exports.runColdBoot = exports.isOxyRpOrigin = exports.CENTRAL_IDP_APEX = exports.registrableApex = exports.getAccountColor = exports.formatPublicKeyHandle = exports.getAccountFallbackHandle = exports.getAccountDisplayName = exports.createQuickAccount = exports.buildAccountsArray = exports.updateAvatarVisibility = exports.isDev = exports.consoleSink = exports.resetLoggerConfig = exports.getLoggerConfig = exports.configureLogger = exports.createLogger = exports.logger = exports.normalizeMultilineText = void 0;
25
+ exports.packageInfo = exports.runSessionColdBoot = exports.OXY_INFERENCE_BASE_URL = exports.OxyInferenceError = exports.OxyInferenceClient = exports.TOKEN_REFRESH_LEAD_MS = exports.startTokenRefreshScheduler = exports.installAuthRefreshHandler = exports.createAuthRefreshHandler = exports.refreshDeviceSecretArm = exports.refreshPersistedSession = exports.AccountNotOnDeviceError = exports.establishIdentitySession = exports.resolveIdentityPin = exports.IDENTITY_PIN_STORAGE_KEY = exports.identityPinMatches = exports.createMemoryIdentityPinStore = exports.createNativeIdentityPinStore = exports.createWebIdentityPinStore = exports.readLocalDeviceCredential = exports.publishProvenDeviceCredential = exports.normalizeSharedDeviceSessionRead = exports.decideSharedDevicePublish = exports.decideSharedDeviceJoin = exports.createSharedMirroringAuthStateStore = exports.AUTH_STATE_STORAGE_KEY = exports.createMemoryAuthStateStore = exports.createNativeAuthStateStore = exports.createWebAuthStateStore = exports.createAccountDialogController = exports.AccountDialogController = exports.canSwitchIntoAccount = exports.isSwitchTargetAccount = exports.showsPrincipalHeaders = exports.buildSwitcherRows = exports.resolveDeviceContext = exports.resolveActiveContext = void 0;
26
26
  // Ensure crypto polyfills are loaded before anything else
27
27
  require("./crypto/polyfill");
28
28
  // ---------------------------------------------------------------------------
@@ -376,20 +376,42 @@ Object.defineProperty(exports, "deviceStateToClientSessions", { enumerable: true
376
376
  Object.defineProperty(exports, "activeSessionIdOf", { enumerable: true, get: function () { return projectSessionState_1.activeSessionIdOf; } });
377
377
  Object.defineProperty(exports, "activeUserOf", { enumerable: true, get: function () { return projectSessionState_1.activeUserOf; } });
378
378
  Object.defineProperty(exports, "accountIdsOf", { enumerable: true, get: function () { return projectSessionState_1.accountIdsOf; } });
379
- // Unified account-list projection (THE single source of truth for the account
380
- // chooser: device sign-ins account graph, deduped by accountId). Pure +
381
- // I/O-free the caller hydrates profiles via `getUsersByIds`. Shared by
382
- // `@oxyhq/services` and auth.oxy.so so the list can't diverge.
383
- // `isSwitchTargetAccount` is the structural half ("is this kind switchable at
384
- // all?"); `canSwitchIntoAccount` adds the caller's `account:act_as` permission.
385
- // Both are exported so surfaces that render `AccountNode`s rather than the
386
- // projection the Console workspace switcher, managed-accounts rows ask the
387
- // SAME questions instead of testing a kind literal.
388
- var accountProjection_1 = require("./session/accountProjection");
389
- Object.defineProperty(exports, "isSwitchTargetAccount", { enumerable: true, get: function () { return accountProjection_1.isSwitchTargetAccount; } });
390
- Object.defineProperty(exports, "canSwitchIntoAccount", { enumerable: true, get: function () { return accountProjection_1.canSwitchIntoAccount; } });
391
- Object.defineProperty(exports, "projectSwitchableAccounts", { enumerable: true, get: function () { return accountProjection_1.projectSwitchableAccounts; } });
392
- Object.defineProperty(exports, "switchableAccountIds", { enumerable: true, get: function () { return accountProjection_1.switchableAccountIds; } });
379
+ // Pure projections over the device DIRECTORY (`GET /session/device/directory`,
380
+ // ADR 0002) the read model that keeps the actor (the human who authenticated)
381
+ // and the subject (the account being acted as) apart. The flat
382
+ // `DeviceSessionState` collapses them into one row, so it can neither tell
383
+ // "signed in as an org" from "a person operating that org" nor hold two people
384
+ // reaching the same org on one device.
385
+ // `canActivateContext` is the switchability question `available` alone, never
386
+ // composed with `onDevice`, which is a different fact in both directions.
387
+ // `projectDevicePrincipals` is the switcher's shape: people, each with what
388
+ // they may become. Grouped rather than flat because the same organization
389
+ // reached through two people is TWO rows under two humans, which a list keyed
390
+ // by account cannot say.
391
+ var deviceDirectory_1 = require("./session/deviceDirectory");
392
+ Object.defineProperty(exports, "canActivateContext", { enumerable: true, get: function () { return deviceDirectory_1.canActivateContext; } });
393
+ Object.defineProperty(exports, "directoryDisplayName", { enumerable: true, get: function () { return deviceDirectory_1.directoryDisplayName; } });
394
+ Object.defineProperty(exports, "directoryHandle", { enumerable: true, get: function () { return deviceDirectory_1.directoryHandle; } });
395
+ Object.defineProperty(exports, "projectDevicePrincipals", { enumerable: true, get: function () { return deviceDirectory_1.projectDevicePrincipals; } });
396
+ Object.defineProperty(exports, "resolveActiveContext", { enumerable: true, get: function () { return deviceDirectory_1.resolveActiveContext; } });
397
+ Object.defineProperty(exports, "resolveDeviceContext", { enumerable: true, get: function () { return deviceDirectory_1.resolveDeviceContext; } });
398
+ // The switcher's RENDER model over that projection — names, handles and avatar
399
+ // URLs resolved once. Shared by `@oxyhq/services`' account dialog and the
400
+ // auth.oxy.so chooser so the two cannot drift, the same reason the flat
401
+ // projection lived here before it.
402
+ var deviceSwitcherRows_1 = require("./session/deviceSwitcherRows");
403
+ Object.defineProperty(exports, "buildSwitcherRows", { enumerable: true, get: function () { return deviceSwitcherRows_1.buildSwitcherRows; } });
404
+ Object.defineProperty(exports, "showsPrincipalHeaders", { enumerable: true, get: function () { return deviceSwitcherRows_1.showsPrincipalHeaders; } });
405
+ // The switch-target predicates over the account GRAPH — a list of accounts to
406
+ // manage, not the device's list of identities to become (that is the directory
407
+ // above). `isSwitchTargetAccount` is the structural half ("is this kind
408
+ // switchable at all?"); `canSwitchIntoAccount` adds the caller's
409
+ // `account:act_as` permission. Exported so the surfaces that render
410
+ // `AccountNode`s — the Console workspace switcher, managed-accounts rows — ask
411
+ // the SAME questions instead of testing a kind literal.
412
+ var accountSwitchTargets_1 = require("./session/accountSwitchTargets");
413
+ Object.defineProperty(exports, "isSwitchTargetAccount", { enumerable: true, get: function () { return accountSwitchTargets_1.isSwitchTargetAccount; } });
414
+ Object.defineProperty(exports, "canSwitchIntoAccount", { enumerable: true, get: function () { return accountSwitchTargets_1.canSwitchIntoAccount; } });
393
415
  // Headless controller for the unified account dialog. Framework-agnostic
394
416
  // state machine + subscribe/getSnapshot store (bind via `useSyncExternalStore`)
395
417
  // — sign-in is passkey (WebAuthn) or the Commons QR / shared-keychain handoff;
@@ -411,6 +433,18 @@ Object.defineProperty(exports, "createWebAuthStateStore", { enumerable: true, ge
411
433
  Object.defineProperty(exports, "createNativeAuthStateStore", { enumerable: true, get: function () { return authStateStore_1.createNativeAuthStateStore; } });
412
434
  Object.defineProperty(exports, "createMemoryAuthStateStore", { enumerable: true, get: function () { return authStateStore_1.createMemoryAuthStateStore; } });
413
435
  Object.defineProperty(exports, "AUTH_STATE_STORAGE_KEY", { enumerable: true, get: function () { return authStateStore_1.AUTH_STATE_STORAGE_KEY; } });
436
+ // The shared NATIVE DeviceSession credential — how several official apps on one
437
+ // device end up on ONE `DeviceSession` and therefore one active context. It is an
438
+ // ordinary rotatable/revocable `deviceId` + `deviceSecret`, deliberately NOT the
439
+ // Commons private identity key: an app that only needs a session must never be
440
+ // handed the key that signs identity approvals.
441
+ var sharedDeviceCredential_1 = require("./session/sharedDeviceCredential");
442
+ Object.defineProperty(exports, "createSharedMirroringAuthStateStore", { enumerable: true, get: function () { return sharedDeviceCredential_1.createSharedMirroringAuthStateStore; } });
443
+ Object.defineProperty(exports, "decideSharedDeviceJoin", { enumerable: true, get: function () { return sharedDeviceCredential_1.decideSharedDeviceJoin; } });
444
+ Object.defineProperty(exports, "decideSharedDevicePublish", { enumerable: true, get: function () { return sharedDeviceCredential_1.decideSharedDevicePublish; } });
445
+ Object.defineProperty(exports, "normalizeSharedDeviceSessionRead", { enumerable: true, get: function () { return sharedDeviceCredential_1.normalizeSharedDeviceSessionRead; } });
446
+ Object.defineProperty(exports, "publishProvenDeviceCredential", { enumerable: true, get: function () { return sharedDeviceCredential_1.publishProvenDeviceCredential; } });
447
+ Object.defineProperty(exports, "readLocalDeviceCredential", { enumerable: true, get: function () { return sharedDeviceCredential_1.readLocalDeviceCredential; } });
414
448
  // Identity-bound sessions (the identity vault). The pin is the durable
415
449
  // `{publicKey, accountId}` binding between this device's PRIMARY identity key
416
450
  // and the account it authenticates as; it is what keeps such a client from
@@ -436,6 +470,13 @@ Object.defineProperty(exports, "createAuthRefreshHandler", { enumerable: true, g
436
470
  Object.defineProperty(exports, "installAuthRefreshHandler", { enumerable: true, get: function () { return refresh_1.installAuthRefreshHandler; } });
437
471
  Object.defineProperty(exports, "startTokenRefreshScheduler", { enumerable: true, get: function () { return refresh_1.startTokenRefreshScheduler; } });
438
472
  Object.defineProperty(exports, "TOKEN_REFRESH_LEAD_MS", { enumerable: true, get: function () { return refresh_1.TOKEN_REFRESH_LEAD_MS; } });
473
+ // The inference API. `oxyServices.inference()` binds the session bearer into
474
+ // the same client an external developer constructs with an `oxy_sk_…` machine
475
+ // key — one surface, two credential lanes. See `docs/inference/sdk.md`.
476
+ var OxyInferenceClient_1 = require("./inference/OxyInferenceClient");
477
+ Object.defineProperty(exports, "OxyInferenceClient", { enumerable: true, get: function () { return OxyInferenceClient_1.OxyInferenceClient; } });
478
+ Object.defineProperty(exports, "OxyInferenceError", { enumerable: true, get: function () { return OxyInferenceClient_1.OxyInferenceError; } });
479
+ Object.defineProperty(exports, "OXY_INFERENCE_BASE_URL", { enumerable: true, get: function () { return OxyInferenceClient_1.OXY_INFERENCE_BASE_URL; } });
439
480
  var sessionColdBoot_1 = require("./boot/sessionColdBoot");
440
481
  Object.defineProperty(exports, "runSessionColdBoot", { enumerable: true, get: function () { return sessionColdBoot_1.runSessionColdBoot; } });
441
482
  // API response contracts (request/response Zod schemas + inferred types) live in