@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
@@ -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/src/index.ts CHANGED
@@ -49,7 +49,11 @@ export type {
49
49
  CommonsDeliveryPlatform,
50
50
  CommonsDeliveryRoute,
51
51
  } from './utils/commonsDelivery';
52
- export type { ServiceTokenResponse, OAuthUserInfoResponse } from './mixins/OxyServices.auth';
52
+ export type {
53
+ ServiceTokenResponse,
54
+ OAuthUserInfoResponse,
55
+ OAuthTokenExchangeResult,
56
+ } from './mixins/OxyServices.auth';
53
57
  // "Sign in with Oxy" — handoff (Workstream C)
54
58
  export type {
55
59
  CommonsSignInHandle,
@@ -152,12 +156,6 @@ export type {
152
156
  AccountMemberSource,
153
157
  AccountMember,
154
158
  AccountNode,
155
- AccountCredentialType,
156
- AccountCredentialEnvironment,
157
- AccountCredentialStatus,
158
- AccountCredential,
159
- AccountCredentialWithSecret,
160
- RotateAccountCredentialResult,
161
159
  ListAccountsOptions,
162
160
  CreateAccountInput,
163
161
  UpdateAccountInput,
@@ -167,7 +165,6 @@ export type {
167
165
  InviteAccountMemberInput,
168
166
  UpdateAccountMemberInput,
169
167
  TransferAccountOwnershipInput,
170
- CreateAccountCredentialInput,
171
168
  AccountSuccessResult,
172
169
  SwitchAccountResult,
173
170
  // Applications owned within the account graph (Application = OAuth client).
@@ -181,6 +178,7 @@ export type {
181
178
  CreateApplicationInput,
182
179
  UpdateApplicationInput,
183
180
  CreateApplicationCredentialInput,
181
+ RotateApplicationCredentialInput,
184
182
  ApplicationCredentialWithSecret,
185
183
  RotateApplicationCredentialResult,
186
184
  ApplicationUsagePeriod,
@@ -680,26 +678,55 @@ export {
680
678
  accountIdsOf,
681
679
  } from './session/projectSessionState';
682
680
 
683
- // Unified account-list projection (THE single source of truth for the account
684
- // chooser: device sign-ins account graph, deduped by accountId). Pure +
685
- // I/O-free the caller hydrates profiles via `getUsersByIds`. Shared by
686
- // `@oxyhq/services` and auth.oxy.so so the list can't diverge.
687
- // `isSwitchTargetAccount` is the structural half ("is this kind switchable at
688
- // all?"); `canSwitchIntoAccount` adds the caller's `account:act_as` permission.
689
- // Both are exported so surfaces that render `AccountNode`s rather than the
690
- // projection the Console workspace switcher, managed-accounts rows ask the
691
- // SAME questions instead of testing a kind literal.
681
+ // Pure projections over the device DIRECTORY (`GET /session/device/directory`,
682
+ // ADR 0002) the read model that keeps the actor (the human who authenticated)
683
+ // and the subject (the account being acted as) apart. The flat
684
+ // `DeviceSessionState` collapses them into one row, so it can neither tell
685
+ // "signed in as an org" from "a person operating that org" nor hold two people
686
+ // reaching the same org on one device.
687
+ // `canActivateContext` is the switchability question `available` alone, never
688
+ // composed with `onDevice`, which is a different fact in both directions.
689
+ // `projectDevicePrincipals` is the switcher's shape: people, each with what
690
+ // they may become. Grouped rather than flat because the same organization
691
+ // reached through two people is TWO rows under two humans, which a list keyed
692
+ // by account cannot say.
693
+ export {
694
+ canActivateContext,
695
+ directoryDisplayName,
696
+ directoryHandle,
697
+ projectDevicePrincipals,
698
+ resolveActiveContext,
699
+ resolveDeviceContext,
700
+ } from './session/deviceDirectory';
701
+ export type {
702
+ DeviceContext,
703
+ DeviceContextActor,
704
+ DeviceContextSubject,
705
+ DevicePrincipalGroup,
706
+ } from './session/deviceDirectory';
707
+
708
+ // The switcher's RENDER model over that projection — names, handles and avatar
709
+ // URLs resolved once. Shared by `@oxyhq/services`' account dialog and the
710
+ // auth.oxy.so chooser so the two cannot drift, the same reason the flat
711
+ // projection lived here before it.
712
+ export { buildSwitcherRows, showsPrincipalHeaders } from './session/deviceSwitcherRows';
713
+ export type {
714
+ ResolveAvatarUrl,
715
+ SwitcherContextRow,
716
+ SwitcherPrincipalRow,
717
+ } from './session/deviceSwitcherRows';
718
+
719
+ // The switch-target predicates over the account GRAPH — a list of accounts to
720
+ // manage, not the device's list of identities to become (that is the directory
721
+ // above). `isSwitchTargetAccount` is the structural half ("is this kind
722
+ // switchable at all?"); `canSwitchIntoAccount` adds the caller's
723
+ // `account:act_as` permission. Exported so the surfaces that render
724
+ // `AccountNode`s — the Console workspace switcher, managed-accounts rows — ask
725
+ // the SAME questions instead of testing a kind literal.
692
726
  export {
693
727
  isSwitchTargetAccount,
694
728
  canSwitchIntoAccount,
695
- projectSwitchableAccounts,
696
- switchableAccountIds,
697
- } from './session/accountProjection';
698
- export type {
699
- SwitchableAccount,
700
- SwitchableAccountUser,
701
- ProjectSwitchableAccountsInput,
702
- } from './session/accountProjection';
729
+ } from './session/accountSwitchTargets';
703
730
 
704
731
  // Headless controller for the unified account dialog. Framework-agnostic
705
732
  // state machine + subscribe/getSnapshot store (bind via `useSyncExternalStore`)
@@ -741,6 +768,30 @@ export type {
741
768
  NativeKeyValueStorage,
742
769
  } from './session/authStateStore';
743
770
 
771
+ // The shared NATIVE DeviceSession credential — how several official apps on one
772
+ // device end up on ONE `DeviceSession` and therefore one active context. It is an
773
+ // ordinary rotatable/revocable `deviceId` + `deviceSecret`, deliberately NOT the
774
+ // Commons private identity key: an app that only needs a session must never be
775
+ // handed the key that signs identity approvals.
776
+ export {
777
+ createSharedMirroringAuthStateStore,
778
+ decideSharedDeviceJoin,
779
+ decideSharedDevicePublish,
780
+ normalizeSharedDeviceSessionRead,
781
+ publishProvenDeviceCredential,
782
+ readLocalDeviceCredential,
783
+ } from './session/sharedDeviceCredential';
784
+ export type {
785
+ SharedDeviceCredential,
786
+ SharedDeviceCredentialRead,
787
+ SharedDeviceCredentialStore,
788
+ SharedDeviceJoinDecision,
789
+ SharedDeviceJoinSkipReason,
790
+ SharedDevicePublishDecision,
791
+ SharedDevicePublishOutcome,
792
+ SharedDevicePublishSkipReason,
793
+ } from './session/sharedDeviceCredential';
794
+
744
795
  // Identity-bound sessions (the identity vault). The pin is the durable
745
796
  // `{publicKey, accountId}` binding between this device's PRIMARY identity key
746
797
  // and the account it authenticates as; it is what keeps such a client from
@@ -777,6 +828,24 @@ export {
777
828
  } from './session/refresh';
778
829
  export type { RefreshDeps, TokenRefreshSchedulerHandle, DeviceSecretMintOutcome } from './session/refresh';
779
830
 
831
+ // The inference API. `oxyServices.inference()` binds the session bearer into
832
+ // the same client an external developer constructs with an `oxy_sk_…` machine
833
+ // key — one surface, two credential lanes. See `docs/inference/sdk.md`.
834
+ export {
835
+ OxyInferenceClient,
836
+ OxyInferenceError,
837
+ OXY_INFERENCE_BASE_URL,
838
+ } from './inference/OxyInferenceClient';
839
+ export type {
840
+ OxyInferenceClientOptions,
841
+ OxyInferenceCredential,
842
+ OxyInferenceFetch,
843
+ OxyInferenceRequestOptions,
844
+ OxyInferenceResponse,
845
+ OxyGenerationReceipt,
846
+ OxyResponsesRequest,
847
+ } from './inference/OxyInferenceClient';
848
+
780
849
  export { runSessionColdBoot } from './boot/sessionColdBoot';
781
850
  export type {
782
851
  RunSessionColdBootOptions,