@undefineds.co/xpod 0.4.3 → 0.4.5
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/config/cloud.json +1 -1
- package/config/main.json +36 -2
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +3 -0
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +1 -1
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +2 -1
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +101 -32
- package/dist/api/ai-gateway/connect/DeviceCodeProtocol.d.ts +80 -0
- package/dist/api/ai-gateway/connect/DeviceCodeProtocol.js +3 -0
- package/dist/api/ai-gateway/connect/FileSessionImportAdapter.d.ts +38 -0
- package/dist/api/ai-gateway/connect/FileSessionImportAdapter.js +63 -0
- package/dist/api/ai-gateway/connect/LoopbackAuthorizationCallbackReceiver.d.ts +24 -0
- package/dist/api/ai-gateway/connect/LoopbackAuthorizationCallbackReceiver.js +136 -0
- package/dist/api/ai-gateway/connect/OAuthConnectAdapter.d.ts +2 -0
- package/dist/api/ai-gateway/connect/OAuthConnectAdapter.js +2 -1
- package/dist/api/ai-gateway/connect/OAuthIntegrationRegistry.d.ts +17 -13
- package/dist/api/ai-gateway/connect/OAuthIntegrationRegistry.js +52 -19
- package/dist/api/ai-gateway/connect/OpenAiSubscriptionSessionImportAdapter.d.ts +4 -28
- package/dist/api/ai-gateway/connect/OpenAiSubscriptionSessionImportAdapter.js +7 -58
- package/dist/api/ai-gateway/connect/ProviderAuthorizationProfiles.d.ts +4 -0
- package/dist/api/ai-gateway/connect/ProviderAuthorizationProfiles.js +116 -0
- package/dist/api/ai-gateway/connect/SessionImportProfiles.d.ts +10 -0
- package/dist/api/ai-gateway/connect/SessionImportProfiles.js +112 -0
- package/dist/api/ai-gateway/connect/index.d.ts +125 -23
- package/dist/api/ai-gateway/connect/index.js +1277 -260
- package/dist/api/ai-gateway/models/PodModelSelectionRepository.d.ts +4 -1
- package/dist/api/ai-gateway/models/PodModelSelectionRepository.js +154 -19
- package/dist/api/ai-gateway/providers/DeepSeekRuntimeAdapter.js +10 -6
- package/dist/api/ai-gateway/providers/ModelsDevCatalog.d.ts +7 -0
- package/dist/api/ai-gateway/providers/ModelsDevCatalog.js +25 -1
- package/dist/api/ai-gateway/providers/OfferingAuthorization.d.ts +24 -0
- package/dist/api/ai-gateway/providers/OfferingAuthorization.js +37 -0
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.d.ts +1 -1
- package/dist/api/ai-gateway/providers/OpenAiRuntimeAdapter.js +5 -3
- package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +6 -3
- package/dist/api/ai-gateway/providers/ProviderRegistry.js +55 -16
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.d.ts +2 -0
- package/dist/api/ai-gateway/providers/ProviderRuntimeAdapter.js +37 -4
- package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +7 -0
- package/dist/api/ai-gateway/quota/SubscriptionQuotaAdapters.js +2 -1
- package/dist/api/ai-gateway/routing/ModelRouter.js +3 -1
- package/dist/api/container/common.js +30 -40
- package/dist/api/container/index.js +6 -2
- package/dist/api/container/routes.js +5 -22
- package/dist/api/handlers/AiClientConfigurationHandler.js +39 -1
- package/dist/api/handlers/AiGatewayManagementHandler.d.ts +3 -0
- package/dist/api/handlers/AiGatewayManagementHandler.js +173 -58
- package/dist/api/service/AiClientConfigurationService.d.ts +4 -15
- package/dist/api/service/AiClientConfigurationService.js +17 -64
- package/dist/cli/commands/start.js +2 -0
- package/dist/components/components.jsonld +1 -0
- package/dist/components/context.jsonld +80 -0
- package/dist/http/InternalPodDataHttpHandler.d.ts +3 -0
- package/dist/http/InternalPodDataHttpHandler.js +13 -2
- package/dist/http/InternalPodDataHttpHandler.jsonld +12 -0
- package/dist/identity/oidc/RememberedClientPromptFactory.d.ts +1 -1
- package/dist/identity/oidc/RememberedClientPromptFactory.js +5 -2
- package/dist/identity/oidc/RememberedConsentHandler.js +1 -1
- package/dist/identity/oidc/ScopedPickWebIdHandler.d.ts +1 -0
- package/dist/identity/oidc/ScopedPickWebIdHandler.js +26 -0
- package/dist/identity/oidc/ScopedPickWebIdHandler.jsonld +4 -0
- package/dist/identity/oidc/SessionBoundIdentityProviderFactory.d.ts +10 -0
- package/dist/identity/oidc/SessionBoundIdentityProviderFactory.js +21 -0
- package/dist/identity/oidc/SessionBoundIdentityProviderFactory.jsonld +172 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/runtime/component-parameter-keys.js +18 -2
- package/dist/storage/accessors/MixDataAccessor.js +6 -2
- package/dist/storage/rdf/PostgresRdfEngine.js +10 -2
- package/dist/storage/rdf/RdfContentTypes.js +4 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.d.ts +3 -0
- package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.js +13 -16
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsList.js +1 -3
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.d.ts +2 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.js +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.d.ts +4 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.js +127 -57
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.d.ts +6 -4
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.js +436 -83
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.d.ts +3 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +212 -76
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.d.ts +6 -4
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.js +58 -41
- package/node_modules/@undefineds.co/ai-connections/dist/AiQuotaCard.d.ts +4 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiQuotaCard.js +63 -4
- package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.d.ts +46 -6
- package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.js +143 -14
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/base-adapter.d.ts +19 -3
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/base-adapter.js +45 -7
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/codex.d.ts +7 -1
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/codex.js +305 -40
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/index.cjs +383 -50
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/json-env-adapter.js +3 -2
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/pi.js +12 -3
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/transaction.d.ts +2 -0
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/transaction.js +39 -4
- package/node_modules/@undefineds.co/ai-connections/dist/client-config/types.d.ts +8 -1
- package/node_modules/@undefineds.co/ai-connections/dist/client-visuals.d.ts +2 -0
- package/node_modules/@undefineds.co/ai-connections/dist/client-visuals.js +14 -0
- package/node_modules/@undefineds.co/ai-connections/dist/controller.d.ts +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/controller.js +216 -57
- package/node_modules/@undefineds.co/ai-connections/dist/index.d.ts +3 -1
- package/node_modules/@undefineds.co/ai-connections/dist/index.js +16 -2
- package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.js +6 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.js +27 -6
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-database.js +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.js +2 -2
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql/builder/update-builder.js +12 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/builder.js +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/array.js +8 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/default.js +9 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/inline.js +3 -3
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.js +27 -6
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-database.js +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.js +2 -2
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql/builder/update-builder.js +12 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/builder.js +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/array.js +8 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/default.js +9 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/inline.js +3 -3
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +31 -0
- package/package.json +2 -2
- package/static/app/assets/{index-BikOyGPu.js → index-BCZVzMpj.js} +44 -44
- package/static/app/assets/inrupt-smoke.js +2 -2
- package/static/app/assets/main.css +1 -1
- package/static/app/assets/main.js +10 -10
- package/static/auth-callback/assets/{AiConfigContext-DrCH6ckh.js → AiConfigContext-DVkh8Kg2.js} +1 -1
- package/static/auth-callback/assets/{AiConfigPage-DVrlSSdA.js → AiConfigPage-HWVWpe-P.js} +1 -1
- package/static/auth-callback/assets/{DocumentProcessingPanel-_Md-v2R2.js → DocumentProcessingPanel-DDq-mH17.js} +1 -1
- package/static/auth-callback/assets/{IndexLifecyclePanel-BbWwe23H.js → IndexLifecyclePanel-Cx4cjrdP.js} +1 -1
- package/static/auth-callback/assets/{IndexSubjectPanel-upH9MjU-.js → IndexSubjectPanel-DzSw8M9j.js} +1 -1
- package/static/auth-callback/assets/{ModelAssignmentsPanel-CVGH4t4g.js → ModelAssignmentsPanel-BsRxGc2p.js} +1 -1
- package/static/auth-callback/assets/ModelsPage-DEe1lo6Q.js +10 -0
- package/static/auth-callback/assets/{NetworkPage-Dcbrb1fd.js → NetworkPage-DBiEh1Oz.js} +1 -1
- package/static/auth-callback/assets/{PaneListHeader-DrY-1wBq.js → PaneListHeader-lEEgjyN9.js} +1 -1
- package/static/auth-callback/assets/{SearchIndexingPanel-Dw25y53v.js → SearchIndexingPanel-CZCUUGt6.js} +1 -1
- package/static/auth-callback/assets/{StatusSubjectPanel-BHlz9rNF.js → StatusSubjectPanel-21qdueMr.js} +1 -1
- package/static/auth-callback/assets/{StatusWorkspace-BH7exQP5.js → StatusWorkspace-R8RKsqVz.js} +1 -1
- package/static/auth-callback/assets/{SystemSettingsPage-BYLKnM9f.js → SystemSettingsPage-BQ4e-4Wy.js} +1 -1
- package/static/auth-callback/assets/{SystemSettingsSubjectPanel-DT34LKku.js → SystemSettingsSubjectPanel-BopXD7SE.js} +1 -1
- package/static/auth-callback/assets/{activity-DdULRcSI.js → activity-DSfmTGfY.js} +1 -1
- package/static/auth-callback/assets/ai-connections-C03UWyPh.js +1 -0
- package/static/auth-callback/assets/{auth-callback-D7l2P25I.js → auth-callback-DleaitAS.js} +91 -91
- package/static/auth-callback/assets/auth-callback-vPSC2d2F.css +1 -0
- package/static/auth-callback/assets/{badge-j4zjFnmg.js → badge-B0aLu1sl.js} +1 -1
- package/static/auth-callback/assets/{download-DGXoks01.js → download-D_bFwdYJ.js} +1 -1
- package/static/auth-callback/assets/{external-link-CvbgXXaI.js → external-link-DRfjTaQu.js} +1 -1
- package/static/auth-callback/assets/{index-LRWvKJ2i.js → index-CG23cLYQ.js} +1 -1
- package/static/auth-callback/assets/{index-BOK3j1dz.js → index-CyV9ejwx.js} +1 -1
- package/static/auth-callback/assets/{index-browser-C1Qpe0g4.js → index-browser-D70paxIg.js} +1 -1
- package/static/auth-callback/assets/{key-round-CmgS5UdQ.js → key-round-BjV_mVYH.js} +1 -1
- package/static/auth-callback/assets/{rotate-ccw-c4CSG6Rq.js → rotate-ccw-CKoOAfse.js} +1 -1
- package/static/auth-callback/assets/{skeleton-ZPMTiRSM.js → skeleton-BZNjZaHx.js} +1 -1
- package/static/auth-callback/assets/{waypoints-xjyBflU5.js → waypoints-DoaJVzZv.js} +1 -1
- package/static/auth-callback/assets/{workspace-layout-B9nj6F5J.js → workspace-layout-CaP46_ZR.js} +1 -1
- package/static/auth-callback/auth-callback.html +2 -2
- package/static/dashboard/assets/{AiConfigContext-BWOOSYNr.js → AiConfigContext-BSrR27yD.js} +1 -1
- package/static/dashboard/assets/{AiConfigPage-CG2kQ9Wy.js → AiConfigPage-D65Z2LET.js} +1 -1
- package/static/dashboard/assets/{DocumentProcessingPanel-B4VXajfj.js → DocumentProcessingPanel-DyTe7Nei.js} +1 -1
- package/static/dashboard/assets/{IndexLifecyclePanel-CWCy0CC8.js → IndexLifecyclePanel-fK8ZGlrL.js} +1 -1
- package/static/dashboard/assets/{IndexSubjectPanel-CSgyQnG_.js → IndexSubjectPanel-CZPGor7v.js} +1 -1
- package/static/dashboard/assets/{ModelAssignmentsPanel-CdGIGidT.js → ModelAssignmentsPanel-CfYn5LMQ.js} +1 -1
- package/static/dashboard/assets/ModelsPage-djlJsghe.js +25 -0
- package/static/dashboard/assets/{NetworkPage-COia9NCH.js → NetworkPage-Coj6GnPl.js} +1 -1
- package/static/dashboard/assets/{PaneListHeader-SZWyr602.js → PaneListHeader-CUuFNSsZ.js} +1 -1
- package/static/dashboard/assets/{SearchIndexingPanel-D6PZtG6k.js → SearchIndexingPanel-CyJLioXS.js} +1 -1
- package/static/dashboard/assets/{StatusSubjectPanel-CxRD4kv0.js → StatusSubjectPanel-Cv26GSVC.js} +1 -1
- package/static/dashboard/assets/{StatusWorkspace-D3PfmY9-.js → StatusWorkspace-CDjFrsmB.js} +1 -1
- package/static/dashboard/assets/{SystemSettingsPage-COg1MmMj.js → SystemSettingsPage-BuNOyNoa.js} +1 -1
- package/static/dashboard/assets/{SystemSettingsSubjectPanel-BSVVB9Ol.js → SystemSettingsSubjectPanel-B2dasdez.js} +1 -1
- package/static/dashboard/assets/{activity-BJJx5cN-.js → activity-D1d2j_4Z.js} +1 -1
- package/static/dashboard/assets/ai-connections-C03UWyPh.js +1 -0
- package/static/dashboard/assets/{badge-elmrFSCj.js → badge-BeAAv6sp.js} +1 -1
- package/static/dashboard/assets/{dashboard-IvQrNmru.js → dashboard-BnGrUGv8.js} +68 -68
- package/static/dashboard/assets/dashboard-vPSC2d2F.css +1 -0
- package/static/dashboard/assets/{download-C3FH2KzG.js → download-DfFGiZRn.js} +1 -1
- package/static/dashboard/assets/{external-link-Bx7F0uKb.js → external-link-IsjU_LC9.js} +1 -1
- package/static/dashboard/assets/{index-liRoRIP1.js → index-BWQTucPe.js} +1 -1
- package/static/dashboard/assets/{index-M4-kWiGz.js → index-Dj75OjnW.js} +1 -1
- package/static/dashboard/assets/{key-round-CXg0bKAj.js → key-round-BJ_9wmQ_.js} +1 -1
- package/static/dashboard/assets/{rotate-ccw-yxJKOBrX.js → rotate-ccw-D3JGiFbR.js} +1 -1
- package/static/dashboard/assets/{skeleton-x9jNGrQT.js → skeleton-CC4nc-z-.js} +1 -1
- package/static/dashboard/assets/{waypoints-CTKeRsGp.js → waypoints-h7sqFqiG.js} +1 -1
- package/static/dashboard/assets/{workspace-layout--YkgkS38.js → workspace-layout-ZAPTOHhs.js} +1 -1
- package/static/dashboard/dashboard.html +2 -2
- package/static/settings/assets/{AiConfigContext-CelxXFcQ.js → AiConfigContext-lGkWpvKP.js} +1 -1
- package/static/settings/assets/{AiConfigPage-BaP-EovM.js → AiConfigPage-BbZWIBZq.js} +1 -1
- package/static/settings/assets/{DocumentProcessingPanel-DzLZluFv.js → DocumentProcessingPanel-DvYdjT-V.js} +1 -1
- package/static/settings/assets/{IndexLifecyclePanel-Bzj1-_oI.js → IndexLifecyclePanel-W5OGQZj7.js} +1 -1
- package/static/settings/assets/{IndexSubjectPanel-B263QLUh.js → IndexSubjectPanel-g_Aa5soq.js} +1 -1
- package/static/settings/assets/{ModelAssignmentsPanel-BAdT4UR0.js → ModelAssignmentsPanel-COlMBKXj.js} +1 -1
- package/static/settings/assets/ModelsPage-mApKi-aw.js +10 -0
- package/static/settings/assets/{NetworkPage-BK6a7l4g.js → NetworkPage-BDT05JUq.js} +1 -1
- package/static/settings/assets/{PaneListHeader-BAS2ICPq.js → PaneListHeader-CByhNpMG.js} +1 -1
- package/static/settings/assets/{SearchIndexingPanel-Cb_p-NgW.js → SearchIndexingPanel-BFAyzXls.js} +1 -1
- package/static/settings/assets/{StatusSubjectPanel-CcjqUua6.js → StatusSubjectPanel-Bz_XZ3VU.js} +1 -1
- package/static/settings/assets/{StatusWorkspace-7Ibty3_k.js → StatusWorkspace-CeVypHcW.js} +1 -1
- package/static/settings/assets/{SystemSettingsPage-DPSz4dg4.js → SystemSettingsPage-Dh7cQIfx.js} +1 -1
- package/static/settings/assets/{SystemSettingsSubjectPanel-Cb4HkKT5.js → SystemSettingsSubjectPanel-CSnpciO0.js} +1 -1
- package/static/settings/assets/{activity-Qhsr5Pxu.js → activity-DXz3EfFN.js} +1 -1
- package/static/settings/assets/ai-connections-C03UWyPh.js +1 -0
- package/static/settings/assets/{badge-B1vf2qCl.js → badge-1ZA144i4.js} +1 -1
- package/static/settings/assets/{download-CYNt0aZ-.js → download-CUHimlYa.js} +1 -1
- package/static/settings/assets/{external-link-ClKb39NT.js → external-link-BYHSVj2Z.js} +1 -1
- package/static/settings/assets/{index-y8ew3MLM.js → index-DKPDMdW5.js} +1 -1
- package/static/settings/assets/{index-browser-DJhvgpNI.js → index-browser-BaEFz0e0.js} +1 -1
- package/static/settings/assets/{index-BgiIDSch.js → index-viSgSvbO.js} +1 -1
- package/static/settings/assets/{key-round-5d-DrJz-.js → key-round-COByPOg8.js} +1 -1
- package/static/settings/assets/{rotate-ccw-CHZY7kS5.js → rotate-ccw-BC2EN6cE.js} +1 -1
- package/static/settings/assets/{settings-D5VRWyx6.js → settings-DLH9XUoT.js} +86 -86
- package/static/settings/assets/settings-vPSC2d2F.css +1 -0
- package/static/settings/assets/{skeleton-FNabNxNE.js → skeleton-B0-FOhKL.js} +1 -1
- package/static/settings/assets/{waypoints-BnL_8ljo.js → waypoints-DGMsvqWo.js} +1 -1
- package/static/settings/assets/{workspace-layout-D5q3F59S.js → workspace-layout-B0SVrJIu.js} +1 -1
- package/static/settings/settings.html +2 -2
- package/static/auth-callback/assets/ModelsPage-BpkVFKbf.js +0 -10
- package/static/auth-callback/assets/ai-connections-Bm52UO7Y.js +0 -1
- package/static/auth-callback/assets/auth-callback-01yz-UDU.css +0 -1
- package/static/dashboard/assets/ModelsPage-Chd5UK0D.js +0 -25
- package/static/dashboard/assets/ai-connections-Bm52UO7Y.js +0 -1
- package/static/dashboard/assets/dashboard-01yz-UDU.css +0 -1
- package/static/settings/assets/ModelsPage-C0NFa1zq.js +0 -10
- package/static/settings/assets/ai-connections-Bm52UO7Y.js +0 -1
- package/static/settings/assets/settings-01yz-UDU.css +0 -1
|
@@ -22,7 +22,8 @@ export interface PodModelSelection {
|
|
|
22
22
|
export interface PodModelSelectionDb {
|
|
23
23
|
init?: (...resources: unknown[]) => Promise<void>;
|
|
24
24
|
select(): {
|
|
25
|
-
from(resource: typeof aiModelResource): {
|
|
25
|
+
from(resource: typeof aiProviderResource | typeof aiModelResource): {
|
|
26
|
+
execute?(): Promise<Record<string, unknown>[]>;
|
|
26
27
|
where(condition: unknown): {
|
|
27
28
|
execute(): Promise<Record<string, unknown>[]>;
|
|
28
29
|
};
|
|
@@ -91,6 +92,8 @@ export declare class PodModelSelectionRepository {
|
|
|
91
92
|
private replaceSelectionLocked;
|
|
92
93
|
reconcileAvailability(input: ReconcileAvailabilityInput): Promise<PodModelSelection>;
|
|
93
94
|
listActiveSelections(input: ListActiveSelectionsInput): Promise<PodModelSelection[]>;
|
|
95
|
+
private readActiveSelection;
|
|
96
|
+
private findSelectedModel;
|
|
94
97
|
private readSelection;
|
|
95
98
|
private findProvider;
|
|
96
99
|
private dbForOwner;
|
|
@@ -195,20 +195,66 @@ class PodModelSelectionRepository {
|
|
|
195
195
|
}
|
|
196
196
|
async listActiveSelections(input) {
|
|
197
197
|
const db = await this.dbForOwner(input.webId, input.auth);
|
|
198
|
-
// The shared drizzle-solid schema resources are rebound while a query is
|
|
199
|
-
// prepared. Keep provider reads sequential so one query cannot change the
|
|
200
|
-
// base/endpoint underneath another in-flight query.
|
|
201
198
|
const selections = [];
|
|
202
199
|
for (const provider of this.providerIds) {
|
|
203
|
-
selections.push(
|
|
200
|
+
selections.push(await this.readActiveSelection(db, input.webId, provider));
|
|
204
201
|
}
|
|
205
202
|
return selections
|
|
206
|
-
.map((selection) => ({
|
|
207
|
-
...selection,
|
|
208
|
-
models: selection.models.filter((model) => model.status === 'active'),
|
|
209
|
-
}))
|
|
210
203
|
.filter((selection) => selection.models.length > 0);
|
|
211
204
|
}
|
|
205
|
+
async readActiveSelection(db, webId, provider) {
|
|
206
|
+
const providerId = normalizeProvider(provider);
|
|
207
|
+
const providerResourceId = models_1.aiProviderResource.buildId({ id: providerId });
|
|
208
|
+
const providerIri = buildProviderResourceIri(webId, providerResourceId);
|
|
209
|
+
const providerRow = await this.findProvider(db, providerResourceId, webId);
|
|
210
|
+
const models = [];
|
|
211
|
+
for (const relation of relationList(providerRow?.hasModel)) {
|
|
212
|
+
const modelResourceId = selectedModelResourceIdFromRelation(relation, webId);
|
|
213
|
+
if (!modelResourceId || !resourceBelongsToProvider(modelResourceId, providerId)) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
const row = await this.findSelectedModel(db, modelResourceId, webId);
|
|
217
|
+
if (!row || row.status === REMOVED_MODEL_STATUS || row.status === 'inactive') {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (!modelProviderRelationMatches(row.isProvidedBy, modelResourceId, webId)) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
models.push(selectedLinkedModelFromRow(row, modelResourceId));
|
|
224
|
+
}
|
|
225
|
+
const activeModels = dedupeSelectedModels(models);
|
|
226
|
+
const configuredDefault = selectedModelResourceIdFromRelation(providerRow?.defaultModel, webId);
|
|
227
|
+
const defaultModel = configuredDefault && activeModels.some((model) => model.id === configuredDefault)
|
|
228
|
+
? configuredDefault
|
|
229
|
+
: undefined;
|
|
230
|
+
return {
|
|
231
|
+
provider: providerId,
|
|
232
|
+
models: activeModels,
|
|
233
|
+
...(defaultModel ? { defaultModel } : {}),
|
|
234
|
+
version: computeSelectionVersion(providerIri, defaultModel, activeModels),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
async findSelectedModel(db, modelResourceId, webId) {
|
|
238
|
+
try {
|
|
239
|
+
const row = await db.findById(models_1.aiModelResource, modelResourceId);
|
|
240
|
+
if (row)
|
|
241
|
+
return row;
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
if (!isMissingResourceError(error))
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
// A model uses a fragment IRI inside its offering document. Plain-LDP
|
|
248
|
+
// findById can fetch that document yet fail to select the fragment subject,
|
|
249
|
+
// so resolve it through the indexed isProvidedBy relation as a fallback.
|
|
250
|
+
const document = modelResourceId.split('#', 1)[0];
|
|
251
|
+
const offeringIri = buildProviderResourceIri(webId, `${document}#this`);
|
|
252
|
+
const rows = await db.select()
|
|
253
|
+
.from(models_1.aiModelResource)
|
|
254
|
+
.where((0, drizzle_solid_1.eq)(models_1.aiModelResource.isProvidedBy, offeringIri))
|
|
255
|
+
.execute();
|
|
256
|
+
return rows.find((row) => modelRowMatchesResourceId(row, modelResourceId, webId)) ?? null;
|
|
257
|
+
}
|
|
212
258
|
async readSelection(db, webId, provider) {
|
|
213
259
|
const providerId = normalizeProvider(provider);
|
|
214
260
|
const providerResourceId = models_1.aiProviderResource.buildId({ id: providerId });
|
|
@@ -227,7 +273,7 @@ class PodModelSelectionRepository {
|
|
|
227
273
|
const modelRows = rows
|
|
228
274
|
.filter((row) => row.status !== REMOVED_MODEL_STATUS)
|
|
229
275
|
.filter((row) => relationMatches(row.isProvidedBy, providerIri, webId));
|
|
230
|
-
const providerRow = await this.findProvider(db, providerResourceId);
|
|
276
|
+
const providerRow = await this.findProvider(db, providerResourceId, webId);
|
|
231
277
|
const models = modelRows
|
|
232
278
|
.map((row) => selectedModelFromRow(row, providerResourceId, webId))
|
|
233
279
|
.filter((model) => model !== undefined)
|
|
@@ -248,16 +294,21 @@ class PodModelSelectionRepository {
|
|
|
248
294
|
},
|
|
249
295
|
};
|
|
250
296
|
}
|
|
251
|
-
async findProvider(db, id) {
|
|
297
|
+
async findProvider(db, id, webId) {
|
|
252
298
|
try {
|
|
253
|
-
|
|
299
|
+
const row = await db.findById(models_1.aiProviderResource, id);
|
|
300
|
+
if (row)
|
|
301
|
+
return row;
|
|
254
302
|
}
|
|
255
303
|
catch (error) {
|
|
256
|
-
if (isMissingResourceError(error))
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
throw error;
|
|
304
|
+
if (!isMissingResourceError(error))
|
|
305
|
+
throw error;
|
|
260
306
|
}
|
|
307
|
+
const collection = db.select().from(models_1.aiProviderResource);
|
|
308
|
+
if (typeof collection.execute !== 'function')
|
|
309
|
+
return null;
|
|
310
|
+
const rows = await collection.execute();
|
|
311
|
+
return rows.find((row) => providerRowMatchesResourceId(row, id, webId)) ?? null;
|
|
261
312
|
}
|
|
262
313
|
async dbForOwner(owner, auth) {
|
|
263
314
|
assertOwnerWebId(owner);
|
|
@@ -443,6 +494,88 @@ function selectedModelFromRow(row, providerResourceId, webId) {
|
|
|
443
494
|
...(dateValue(row.updatedAt) ? { updatedAt: dateValue(row.updatedAt) } : {}),
|
|
444
495
|
};
|
|
445
496
|
}
|
|
497
|
+
function selectedLinkedModelFromRow(row, id) {
|
|
498
|
+
return {
|
|
499
|
+
id,
|
|
500
|
+
...(typeof row.displayName === 'string' && row.displayName ? { displayName: row.displayName } : {}),
|
|
501
|
+
modelType: normalizeModelType(row.modelType),
|
|
502
|
+
status: 'active',
|
|
503
|
+
...(dateValue(row.createdAt) ? { createdAt: dateValue(row.createdAt) } : {}),
|
|
504
|
+
...(dateValue(row.updatedAt) ? { updatedAt: dateValue(row.updatedAt) } : {}),
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function modelRowMatchesResourceId(row, modelResourceId, webId) {
|
|
508
|
+
const rawId = typeof row.id === 'string' ? row.id : row['@id'];
|
|
509
|
+
if (typeof rawId !== 'string' || !rawId.trim())
|
|
510
|
+
return false;
|
|
511
|
+
if (rawId === modelResourceId)
|
|
512
|
+
return true;
|
|
513
|
+
try {
|
|
514
|
+
return selectedModelResourceIdFromRelation(rawId, webId) === modelResourceId;
|
|
515
|
+
}
|
|
516
|
+
catch {
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function providerRowMatchesResourceId(row, providerResourceId, webId) {
|
|
521
|
+
const rawId = typeof row.id === 'string' ? row.id : row['@id'];
|
|
522
|
+
if (typeof rawId !== 'string' || !rawId.trim())
|
|
523
|
+
return false;
|
|
524
|
+
if (rawId === providerResourceId)
|
|
525
|
+
return true;
|
|
526
|
+
try {
|
|
527
|
+
const relative = toPodRelative(rawId, webId);
|
|
528
|
+
const prefix = 'settings/providers/';
|
|
529
|
+
const id = relative.startsWith(prefix) ? relative.slice(prefix.length) : relative;
|
|
530
|
+
return id === providerResourceId || id === `${providerResourceId}#this`;
|
|
531
|
+
}
|
|
532
|
+
catch {
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function relationList(value) {
|
|
537
|
+
if (typeof value === 'string')
|
|
538
|
+
return [value];
|
|
539
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === 'string') : [];
|
|
540
|
+
}
|
|
541
|
+
function selectedModelResourceIdFromRelation(value, webId) {
|
|
542
|
+
if (typeof value !== 'string' || !value.trim())
|
|
543
|
+
return undefined;
|
|
544
|
+
try {
|
|
545
|
+
const relative = toPodRelative(value, webId);
|
|
546
|
+
const prefix = 'settings/providers/';
|
|
547
|
+
const id = relative.startsWith(prefix) ? relative.slice(prefix.length) : relative;
|
|
548
|
+
const [document, fragment, extra] = id.split('#');
|
|
549
|
+
return document && fragment && extra === undefined && !document.includes('/') && document.endsWith('.ttl')
|
|
550
|
+
? `${document}#${fragment}`
|
|
551
|
+
: undefined;
|
|
552
|
+
}
|
|
553
|
+
catch {
|
|
554
|
+
return undefined;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function resourceBelongsToProvider(resourceId, providerId) {
|
|
558
|
+
const document = resourceId.split('#', 1)[0];
|
|
559
|
+
return document === `${providerId}.ttl` || document.startsWith(`${providerId}-`);
|
|
560
|
+
}
|
|
561
|
+
function modelProviderRelationMatches(value, modelResourceId, webId) {
|
|
562
|
+
if (typeof value !== 'string')
|
|
563
|
+
return false;
|
|
564
|
+
try {
|
|
565
|
+
const relative = toPodRelative(value, webId);
|
|
566
|
+
const prefix = 'settings/providers/';
|
|
567
|
+
const providerId = relative.startsWith(prefix) ? relative.slice(prefix.length) : relative;
|
|
568
|
+
const document = modelResourceId.split('#', 1)[0];
|
|
569
|
+
return providerId === document || providerId === `${document}#this`;
|
|
570
|
+
}
|
|
571
|
+
catch {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
function dedupeSelectedModels(models) {
|
|
576
|
+
return [...new Map(models.map((model) => [model.id, model])).values()]
|
|
577
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
578
|
+
}
|
|
446
579
|
function rowResourceId(row, providerResourceId, webId) {
|
|
447
580
|
const rawId = typeof row.id === 'string' ? row.id : row['@id'];
|
|
448
581
|
return typeof rawId === 'string' && rawId.trim()
|
|
@@ -720,14 +853,16 @@ function wrapModelSelectionDb(db, modelResource) {
|
|
|
720
853
|
return {
|
|
721
854
|
from: (resource) => {
|
|
722
855
|
const from = query.from(resource);
|
|
723
|
-
if (resource !== modelResource) {
|
|
724
|
-
return from;
|
|
725
|
-
}
|
|
726
856
|
return {
|
|
857
|
+
...(typeof from.execute === 'function'
|
|
858
|
+
? { execute: () => withModelEndpointLock(() => from.execute()) }
|
|
859
|
+
: {}),
|
|
727
860
|
where: (condition) => {
|
|
728
861
|
const where = from.where(condition);
|
|
729
862
|
return {
|
|
730
|
-
execute: () =>
|
|
863
|
+
execute: () => resource === modelResource
|
|
864
|
+
? withModelCollectionEndpoint(modelResource, () => where.execute())
|
|
865
|
+
: withModelEndpointLock(() => where.execute()),
|
|
731
866
|
};
|
|
732
867
|
},
|
|
733
868
|
};
|
|
@@ -24,6 +24,12 @@ class DeepSeekRuntimeAdapter extends ProviderRuntimeAdapter_1.OpenAiCompatibleRu
|
|
|
24
24
|
}
|
|
25
25
|
exports.DeepSeekRuntimeAdapter = DeepSeekRuntimeAdapter;
|
|
26
26
|
function mapDeepSeekReasoningEffort(effort, modelId, model) {
|
|
27
|
+
// Codex sends `none` for models whose catalog does not expose a reasoning
|
|
28
|
+
// control. This disables reasoning; it must not require the capability or be
|
|
29
|
+
// translated to DeepSeek's `high` setting.
|
|
30
|
+
if (effort === 'none') {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
27
33
|
if (model?.capabilities?.reasoningEffort !== true) {
|
|
28
34
|
throw new errors_1.GatewayProtocolError('DeepSeek reasoning effort is not registered for this model', {
|
|
29
35
|
code: 'invalid_request',
|
|
@@ -36,12 +42,10 @@ function mapDeepSeekReasoningEffort(effort, modelId, model) {
|
|
|
36
42
|
},
|
|
37
43
|
});
|
|
38
44
|
}
|
|
39
|
-
if (effort === '
|
|
40
|
-
return '
|
|
41
|
-
|
|
42
|
-
if (effort === 'xhigh') {
|
|
45
|
+
if (effort === 'minimal' || effort === 'low')
|
|
46
|
+
return 'low';
|
|
47
|
+
if (effort === 'max')
|
|
43
48
|
return 'max';
|
|
44
|
-
|
|
45
|
-
return effort === 'max' ? 'max' : 'high';
|
|
49
|
+
return 'high';
|
|
46
50
|
}
|
|
47
51
|
//# sourceMappingURL=DeepSeekRuntimeAdapter.js.map
|
|
@@ -46,5 +46,12 @@ export interface FetchModelsDevCatalogOptions {
|
|
|
46
46
|
export declare function resetModelsDevCatalogCache(): void;
|
|
47
47
|
export declare function fetchModelsDevCatalog(options?: FetchModelsDevCatalogOptions): Promise<ModelsDevCatalog | undefined>;
|
|
48
48
|
export declare function modelsDevModelDescriptors(provider: ModelsDevProvider): ProviderModelDescriptor[];
|
|
49
|
+
/**
|
|
50
|
+
* Synchronous lookup of a single model in the already-fetched models.dev cache.
|
|
51
|
+
* Returns undefined when the catalog has not been fetched or the model is unknown.
|
|
52
|
+
* Used to enrich gateway projections for models that are absent from the static registry
|
|
53
|
+
* (e.g. newly released models discovered via the provider's live /models endpoint).
|
|
54
|
+
*/
|
|
55
|
+
export declare function lookupModelsDevModelDescriptor(providerId: string, modelId: string, mapping?: Record<string, string>): ProviderModelDescriptor | undefined;
|
|
49
56
|
export declare function syncProviderRegistryWithModelsDev(registry: ProviderRegistry, catalog: ModelsDevCatalog, mapping?: Record<string, string>): string[];
|
|
50
57
|
export declare function syncProviderRegistryFromModelsDev(registry: ProviderRegistry, options?: FetchModelsDevCatalogOptions): Promise<string[]>;
|
|
@@ -4,6 +4,7 @@ exports.XPOD_PROVIDER_TO_MODELS_DEV = exports.MODELS_DEV_API_URL = void 0;
|
|
|
4
4
|
exports.resetModelsDevCatalogCache = resetModelsDevCatalogCache;
|
|
5
5
|
exports.fetchModelsDevCatalog = fetchModelsDevCatalog;
|
|
6
6
|
exports.modelsDevModelDescriptors = modelsDevModelDescriptors;
|
|
7
|
+
exports.lookupModelsDevModelDescriptor = lookupModelsDevModelDescriptor;
|
|
7
8
|
exports.syncProviderRegistryWithModelsDev = syncProviderRegistryWithModelsDev;
|
|
8
9
|
exports.syncProviderRegistryFromModelsDev = syncProviderRegistryFromModelsDev;
|
|
9
10
|
const global_logger_factory_1 = require("global-logger-factory");
|
|
@@ -16,6 +17,7 @@ exports.XPOD_PROVIDER_TO_MODELS_DEV = {
|
|
|
16
17
|
kimi: 'moonshotai',
|
|
17
18
|
bailian: 'alibaba-cn',
|
|
18
19
|
deepseek: 'deepseek',
|
|
20
|
+
zhipu: 'zhipuai',
|
|
19
21
|
};
|
|
20
22
|
let catalogCache;
|
|
21
23
|
function resetModelsDevCatalogCache() {
|
|
@@ -57,7 +59,10 @@ function modelsDevModelDescriptors(provider) {
|
|
|
57
59
|
inputModalities: model.modalities?.input,
|
|
58
60
|
capabilities: {
|
|
59
61
|
toolCalls: model.tool_call,
|
|
60
|
-
|
|
62
|
+
// The DeepSeek Flash offerings expose the same reasoning-effort control
|
|
63
|
+
// as Pro, although the shared catalog currently marks them as ordinary
|
|
64
|
+
// chat models. Preserve that provider contract in Gateway projections.
|
|
65
|
+
reasoningEffort: provider.id === 'deepseek' && /flash/iu.test(model.id) ? true : model.reasoning,
|
|
61
66
|
imageInput: model.modalities?.input?.includes('image') ?? undefined,
|
|
62
67
|
},
|
|
63
68
|
metadata: {
|
|
@@ -74,6 +79,25 @@ function modelsDevModelDescriptors(provider) {
|
|
|
74
79
|
},
|
|
75
80
|
}));
|
|
76
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Synchronous lookup of a single model in the already-fetched models.dev cache.
|
|
84
|
+
* Returns undefined when the catalog has not been fetched or the model is unknown.
|
|
85
|
+
* Used to enrich gateway projections for models that are absent from the static registry
|
|
86
|
+
* (e.g. newly released models discovered via the provider's live /models endpoint).
|
|
87
|
+
*/
|
|
88
|
+
function lookupModelsDevModelDescriptor(providerId, modelId, mapping = exports.XPOD_PROVIDER_TO_MODELS_DEV) {
|
|
89
|
+
const modelsDevId = mapping[providerId];
|
|
90
|
+
const models = modelsDevId ? catalogCache?.catalog[modelsDevId]?.models : undefined;
|
|
91
|
+
if (!models) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const key = Object.keys(models).find((candidate) => candidate.toLowerCase() === modelId.toLowerCase());
|
|
95
|
+
const model = key ? models[key] : undefined;
|
|
96
|
+
if (!model) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return modelsDevModelDescriptors({ id: modelsDevId, models: { [model.id]: model } })[0];
|
|
100
|
+
}
|
|
77
101
|
function syncProviderRegistryWithModelsDev(registry, catalog, mapping = exports.XPOD_PROVIDER_TO_MODELS_DEV) {
|
|
78
102
|
const synced = [];
|
|
79
103
|
for (const [providerId, modelsDevId] of Object.entries(mapping)) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Public entry points, separate from how the resulting credential authenticates. */
|
|
2
|
+
export interface OfferingAuthorizationMethod {
|
|
3
|
+
id: string;
|
|
4
|
+
authMode: 'oauth' | 'deviceCode' | 'local' | 'apiKey';
|
|
5
|
+
connectMode?: 'authorizationCodeOAuth' | 'deviceCodeOAuth' | 'browserAssistedApiKey';
|
|
6
|
+
label: string;
|
|
7
|
+
lifecycle: 'active' | 'unavailable';
|
|
8
|
+
reason?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Xpod integrations supplement the shared offering catalog with runtime capabilities. */
|
|
11
|
+
export declare const SUBSCRIPTION_AUTHORIZATION_BINDINGS: readonly [{
|
|
12
|
+
readonly provider: "openai";
|
|
13
|
+
readonly offeringId: "official-subscription";
|
|
14
|
+
readonly integrationId: "openai-codex-public";
|
|
15
|
+
readonly browserIntegrationId: "openai-codex-browser-public";
|
|
16
|
+
}, {
|
|
17
|
+
readonly provider: "kimi";
|
|
18
|
+
readonly offeringId: "subscription-key";
|
|
19
|
+
readonly integrationId: "kimi-code-public";
|
|
20
|
+
}];
|
|
21
|
+
export declare function subscriptionAuthorizationMethods(deployment: 'local' | 'cloud', binding?: {
|
|
22
|
+
integrationId: string;
|
|
23
|
+
browserIntegrationId?: string;
|
|
24
|
+
}): OfferingAuthorizationMethod[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_AUTHORIZATION_BINDINGS = void 0;
|
|
4
|
+
exports.subscriptionAuthorizationMethods = subscriptionAuthorizationMethods;
|
|
5
|
+
/** Xpod integrations supplement the shared offering catalog with runtime capabilities. */
|
|
6
|
+
exports.SUBSCRIPTION_AUTHORIZATION_BINDINGS = [
|
|
7
|
+
{ provider: 'openai', offeringId: 'official-subscription', integrationId: 'openai-codex-public', browserIntegrationId: 'openai-codex-browser-public' },
|
|
8
|
+
{ provider: 'kimi', offeringId: 'subscription-key', integrationId: 'kimi-code-public' },
|
|
9
|
+
];
|
|
10
|
+
function subscriptionAuthorizationMethods(deployment, binding) {
|
|
11
|
+
const browserMethods = binding?.browserIntegrationId ? [{
|
|
12
|
+
id: 'browser-oauth',
|
|
13
|
+
authMode: 'oauth',
|
|
14
|
+
connectMode: 'authorizationCodeOAuth',
|
|
15
|
+
label: '浏览器登录',
|
|
16
|
+
lifecycle: deployment === 'local' ? 'active' : 'unavailable',
|
|
17
|
+
...(deployment === 'local' ? {} : { reason: '浏览器登录需要本机回调,请在本机 Xpod 中使用,或选择设备码登录。' }),
|
|
18
|
+
}] : [];
|
|
19
|
+
return [
|
|
20
|
+
...browserMethods,
|
|
21
|
+
{
|
|
22
|
+
id: 'device-code',
|
|
23
|
+
authMode: 'deviceCode',
|
|
24
|
+
connectMode: 'deviceCodeOAuth',
|
|
25
|
+
label: '设备码登录',
|
|
26
|
+
lifecycle: 'active',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'local-session-import',
|
|
30
|
+
authMode: 'local',
|
|
31
|
+
label: '已有登录态',
|
|
32
|
+
lifecycle: deployment === 'local' ? 'active' : 'unavailable',
|
|
33
|
+
...(deployment === 'local' ? {} : { reason: '请在运行本机客户端的 Xpod 上导入登录态。' }),
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=OfferingAuthorization.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseProviderRuntimeAdapter, type ProviderRuntimeAdapterOptions, type ProviderRuntimeExecuteInput } from './ProviderRuntimeAdapter';
|
|
2
|
-
import type
|
|
2
|
+
import { type ProviderDescriptor } from './ProviderRegistry';
|
|
3
3
|
import type { GatewayEvent } from '../types';
|
|
4
4
|
export interface OpenAiRuntimeAdapterOptions extends ProviderRuntimeAdapterOptions {
|
|
5
5
|
provider?: ProviderDescriptor;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpenAiRuntimeAdapter = void 0;
|
|
4
4
|
const ProviderRuntimeAdapter_1 = require("./ProviderRuntimeAdapter");
|
|
5
|
+
const ProviderRegistry_1 = require("./ProviderRegistry");
|
|
5
6
|
const OPENAI_BASE_URL = 'https://api.openai.com/v1';
|
|
6
|
-
const OPENAI_SUBSCRIPTION_RESPONSES_URL = 'https://chatgpt.com/backend-api/codex/responses';
|
|
7
7
|
class OpenAiRuntimeAdapter extends ProviderRuntimeAdapter_1.BaseProviderRuntimeAdapter {
|
|
8
8
|
constructor(options = {}) {
|
|
9
9
|
super(options);
|
|
@@ -16,7 +16,9 @@ class OpenAiRuntimeAdapter extends ProviderRuntimeAdapter_1.BaseProviderRuntimeA
|
|
|
16
16
|
const baseUrl = this.resolveBaseUrl({
|
|
17
17
|
configuredBaseUrl: input.credential?.baseUrl,
|
|
18
18
|
defaultBaseUrl: this.defaultBaseUrl,
|
|
19
|
-
|
|
19
|
+
// Imported subscription credentials persist their canonical Codex endpoint.
|
|
20
|
+
// Keep that endpoint scoped to subscription credentials, not API keys.
|
|
21
|
+
safeBaseUrls: subscription ? [...this.safeBaseUrls, ProviderRegistry_1.OPENAI_SUBSCRIPTION_BASE_URL] : this.safeBaseUrls,
|
|
20
22
|
});
|
|
21
23
|
try {
|
|
22
24
|
const headers = new Headers();
|
|
@@ -34,7 +36,7 @@ class OpenAiRuntimeAdapter extends ProviderRuntimeAdapter_1.BaseProviderRuntimeA
|
|
|
34
36
|
delete responsesBody.max_output_tokens;
|
|
35
37
|
}
|
|
36
38
|
yield* (0, ProviderRuntimeAdapter_1.parseOpenAiResponsesSse)(this.transport.postSse({
|
|
37
|
-
url: subscription ?
|
|
39
|
+
url: subscription ? `${ProviderRegistry_1.OPENAI_SUBSCRIPTION_BASE_URL}/responses` : `${baseUrl}/responses`,
|
|
38
40
|
apiKey: input.apiKey,
|
|
39
41
|
body: {
|
|
40
42
|
...responsesBody,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { GatewayProtocol } from '../types';
|
|
2
|
+
import { type OfferingAuthorizationMethod } from './OfferingAuthorization';
|
|
3
|
+
export declare const OPENAI_SUBSCRIPTION_BASE_URL = "https://chatgpt.com/backend-api/codex";
|
|
2
4
|
export type ProviderId = 'openai' | 'anthropic' | 'kimi' | 'bailian' | 'deepseek' | string;
|
|
3
5
|
export type ProviderProductId = 'openai' | 'anthropic' | 'kimi' | 'bailian' | 'deepseek' | string;
|
|
4
|
-
export type ProviderAuthMode = 'browserAssistedApiKey' | 'deviceCodeOAuth' | 'apiKey' | 'local' | 'connectUnsupported';
|
|
5
|
-
export type ProviderConnectMode = 'browserAssistedApiKey' | 'deviceCodeOAuth' | 'connectUnsupported';
|
|
6
|
+
export type ProviderAuthMode = 'browserAssistedApiKey' | 'authorizationCodeOAuth' | 'deviceCodeOAuth' | 'apiKey' | 'local' | 'connectUnsupported';
|
|
7
|
+
export type ProviderConnectMode = 'browserAssistedApiKey' | 'authorizationCodeOAuth' | 'deviceCodeOAuth' | 'connectUnsupported';
|
|
6
8
|
export type OfferingAuthMode = 'oauth' | 'deviceCode' | 'apiKey' | 'local';
|
|
7
9
|
export type ProviderOfferingKind = 'oauth-subscription' | 'api-platform' | 'token-plan' | 'local';
|
|
8
10
|
export type ProviderOfferingLifecycle = 'active' | 'legacy' | 'unavailable';
|
|
9
|
-
export type ProviderAuthCapabilityProtocol = 'api-key' | 'subscription-key' | 'local-none' | 'oauth-device-code';
|
|
11
|
+
export type ProviderAuthCapabilityProtocol = 'api-key' | 'subscription-key' | 'local-none' | 'oauth-device-code' | 'oauth-authorization-code';
|
|
10
12
|
export interface ProviderAuthCapabilityDescriptor {
|
|
11
13
|
protocol: ProviderAuthCapabilityProtocol;
|
|
12
14
|
}
|
|
@@ -52,6 +54,7 @@ export interface ProviderOfferingDescriptor {
|
|
|
52
54
|
region: string;
|
|
53
55
|
lifecycle: ProviderOfferingLifecycle;
|
|
54
56
|
oauthIntegrationId?: string;
|
|
57
|
+
authorizationMethods?: OfferingAuthorizationMethod[];
|
|
55
58
|
}
|
|
56
59
|
export interface ProviderProductDescriptor {
|
|
57
60
|
id: ProviderProductId;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_PROVIDER_DESCRIPTORS = exports.DEFAULT_PROVIDER_PRODUCT_DESCRIPTORS = exports.ProviderRegistry = void 0;
|
|
3
|
+
exports.DEFAULT_PROVIDER_DESCRIPTORS = exports.DEFAULT_PROVIDER_PRODUCT_DESCRIPTORS = exports.ProviderRegistry = exports.OPENAI_SUBSCRIPTION_BASE_URL = void 0;
|
|
4
4
|
exports.createDefaultProviderRegistry = createDefaultProviderRegistry;
|
|
5
5
|
exports.providerProductsForDeployment = providerProductsForDeployment;
|
|
6
6
|
exports.normalizeProviderId = normalizeProviderId;
|
|
7
7
|
const models_1 = require("@undefineds.co/models");
|
|
8
|
+
const OfferingAuthorization_1 = require("./OfferingAuthorization");
|
|
9
|
+
exports.OPENAI_SUBSCRIPTION_BASE_URL = 'https://chatgpt.com/backend-api/codex';
|
|
8
10
|
const RESERVED_DISCOVERY_METADATA_KEYS = new Set([
|
|
9
11
|
'baseUrl',
|
|
10
12
|
'base_url',
|
|
@@ -132,21 +134,51 @@ function createDefaultProviderRegistry(options = {}) {
|
|
|
132
134
|
return new ProviderRegistry(exports.DEFAULT_PROVIDER_DESCRIPTORS, options);
|
|
133
135
|
}
|
|
134
136
|
function providerProductsForDeployment(deployment) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
return exports.DEFAULT_PROVIDER_PRODUCT_DESCRIPTORS.map((product) => ({
|
|
138
|
+
...product,
|
|
139
|
+
offerings: product.offerings.map((offering) => {
|
|
140
|
+
const binding = OfferingAuthorization_1.SUBSCRIPTION_AUTHORIZATION_BINDINGS.find((candidate) => candidate.provider === product.id && candidate.offeringId === offering.id);
|
|
141
|
+
const authorizationMethods = [];
|
|
142
|
+
if (offering.authModes.includes('apiKey')) {
|
|
143
|
+
authorizationMethods.push({
|
|
144
|
+
id: 'api-key', authMode: 'apiKey', label: '添加 API Key',
|
|
145
|
+
lifecycle: offering.lifecycle === 'unavailable' ? 'unavailable' : 'active',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (binding) {
|
|
149
|
+
authorizationMethods.push(...(0, OfferingAuthorization_1.subscriptionAuthorizationMethods)(deployment, binding));
|
|
150
|
+
}
|
|
151
|
+
else if (offering.kind === 'local') {
|
|
152
|
+
authorizationMethods.push({
|
|
153
|
+
id: 'local-service', authMode: 'local', label: '本地服务',
|
|
154
|
+
lifecycle: offering.lifecycle === 'unavailable' ? 'unavailable' : 'active',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else if (offering.authModes.some((mode) => mode === 'oauth' || mode === 'deviceCode')) {
|
|
158
|
+
authorizationMethods.push({
|
|
159
|
+
id: 'device-code', authMode: 'deviceCode', connectMode: 'deviceCodeOAuth',
|
|
160
|
+
label: '浏览器登录', lifecycle: 'unavailable', reason: '此授权方式尚未接入。',
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
...offering,
|
|
165
|
+
...(binding ? {
|
|
145
166
|
lifecycle: 'active',
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
167
|
+
oauthIntegrationId: binding.integrationId,
|
|
168
|
+
authModes: [...new Set([
|
|
169
|
+
...offering.authModes.filter((mode) => mode !== 'local'),
|
|
170
|
+
...authorizationMethods.filter((method) => method.lifecycle === 'active').map((method) => method.authMode),
|
|
171
|
+
...(deployment === 'local' ? ['local'] : []),
|
|
172
|
+
])],
|
|
173
|
+
auth: [...offering.auth.filter((capability) => capability.protocol !== 'local-none' && capability.protocol !== 'oauth-device-code'),
|
|
174
|
+
{ protocol: 'oauth-device-code' },
|
|
175
|
+
...(authorizationMethods.some((method) => method.connectMode === 'authorizationCodeOAuth' && method.lifecycle === 'active')
|
|
176
|
+
? [{ protocol: 'oauth-authorization-code' }] : [])],
|
|
177
|
+
} : {}),
|
|
178
|
+
authorizationMethods,
|
|
179
|
+
};
|
|
180
|
+
}),
|
|
181
|
+
}));
|
|
150
182
|
}
|
|
151
183
|
function catalogOffering(productLabel, input) {
|
|
152
184
|
const consoleUrl = input.consoleUrl ?? input.subscriptionUrl;
|
|
@@ -574,6 +606,7 @@ function normalizeOpenAiSubscriptionProduct(product) {
|
|
|
574
606
|
consoleUrl: 'https://chatgpt.com/',
|
|
575
607
|
subscriptionUrl: 'https://chatgpt.com/#pricing',
|
|
576
608
|
quota: { strategy: 'subscription', url: 'https://chatgpt.com/' },
|
|
609
|
+
endpoints: [{ protocol: 'responses', baseUrl: exports.OPENAI_SUBSCRIPTION_BASE_URL }],
|
|
577
610
|
lifecycle: 'unavailable',
|
|
578
611
|
}
|
|
579
612
|
: offering),
|
|
@@ -652,7 +685,7 @@ exports.DEFAULT_PROVIDER_DESCRIPTORS = [
|
|
|
652
685
|
configured: true,
|
|
653
686
|
requiresAuthenticatedManagementApi: true,
|
|
654
687
|
publicCallbackSupported: false,
|
|
655
|
-
notes: ['
|
|
688
|
+
notes: ['API keys use the official settings page; OAuth uses a trusted server-side client profile.'],
|
|
656
689
|
},
|
|
657
690
|
protocols: ['responses', 'chatCompletions'],
|
|
658
691
|
defaultBaseUrl: 'https://api.openai.com/v1',
|
|
@@ -772,6 +805,9 @@ exports.DEFAULT_PROVIDER_DESCRIPTORS = [
|
|
|
772
805
|
models: [
|
|
773
806
|
{ id: 'deepseek-chat', capabilities: { toolCalls: true } },
|
|
774
807
|
{ id: 'deepseek-reasoner', capabilities: { toolCalls: true, reasoningEffort: true } },
|
|
808
|
+
{ id: 'deepseek-flash', capabilities: { toolCalls: true, reasoningEffort: true } },
|
|
809
|
+
{ id: 'deepseek-v4-flash', capabilities: { toolCalls: true, reasoningEffort: true } },
|
|
810
|
+
{ id: 'deepseek-v4-pro', capabilities: { toolCalls: true, reasoningEffort: true } },
|
|
775
811
|
],
|
|
776
812
|
},
|
|
777
813
|
{
|
|
@@ -903,6 +939,9 @@ function freezeProviderProductDescriptor(product) {
|
|
|
903
939
|
runtimeProviderIds: offering.runtimeProviderIds.map(normalizeProviderId),
|
|
904
940
|
authModes: [...offering.authModes],
|
|
905
941
|
auth: offering.auth.map((capability) => ({ ...capability })),
|
|
942
|
+
...(offering.authorizationMethods ? {
|
|
943
|
+
authorizationMethods: offering.authorizationMethods.map((method) => ({ ...method })),
|
|
944
|
+
} : {}),
|
|
906
945
|
upstream: offering.upstream.map((capability) => ({
|
|
907
946
|
...capability,
|
|
908
947
|
options: capability.options ? { ...capability.options } : undefined,
|
|
@@ -26,6 +26,7 @@ export interface ProviderRuntimeAdapter {
|
|
|
26
26
|
export interface ProviderRuntimeAdapterOptions {
|
|
27
27
|
transport?: ProviderHttpTransport;
|
|
28
28
|
maxOutputTokensDefault?: number;
|
|
29
|
+
resolveModel?: (provider: string, model: string) => ProviderModelDescriptor | undefined;
|
|
29
30
|
}
|
|
30
31
|
export interface CompatibleChatAdapterOptions extends ProviderRuntimeAdapterOptions {
|
|
31
32
|
provider: string;
|
|
@@ -66,6 +67,7 @@ export declare class OpenAiCompatibleRuntimeAdapter extends BaseProviderRuntimeA
|
|
|
66
67
|
private readonly supportsDeveloperMessages;
|
|
67
68
|
private readonly allowToolChoiceRequired;
|
|
68
69
|
private readonly descriptor?;
|
|
70
|
+
private readonly resolveModel?;
|
|
69
71
|
private readonly reasoningEffortMapper?;
|
|
70
72
|
private readonly fallbackReasoningBody?;
|
|
71
73
|
private readonly preserveReasoningContent;
|