@undefineds.co/xpod 0.4.29 → 0.4.30
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/dist/api/ApiServer.js +4 -0
- package/dist/api/ai-gateway/AiGatewayService.d.ts +55 -0
- package/dist/api/ai-gateway/AiGatewayService.js +145 -6
- package/dist/api/ai-gateway/auth/AiConnectionsInvocationKeyIssuer.js +5 -3
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +16 -49
- package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +6 -71
- package/dist/api/ai-gateway/auth/InvocationTokenAuthenticator.js +1 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.d.ts +4 -0
- package/dist/api/ai-gateway/auth/InvocationTokenCodec.js +8 -1
- package/dist/api/ai-gateway/connect/FileSessionImportAdapter.d.ts +3 -0
- package/dist/api/ai-gateway/connect/FileSessionImportAdapter.js +23 -3
- package/dist/api/ai-gateway/connect/SessionImportProfiles.d.ts +9 -1
- package/dist/api/ai-gateway/connect/SessionImportProfiles.js +4 -3
- package/dist/api/ai-gateway/connect/index.d.ts +40 -0
- package/dist/api/ai-gateway/connect/index.js +194 -4
- package/dist/api/ai-gateway/models/PodModelSelectionRepository.js +1 -1
- package/dist/api/ai-gateway/pod/OwnerPodAccess.js +5 -0
- package/dist/api/ai-gateway/pod/PodBaseUrlResolver.d.ts +11 -2
- package/dist/api/ai-gateway/pod/PodBaseUrlResolver.js +72 -10
- package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js +1 -1
- package/dist/api/ai-gateway/routing/ModelRouter.d.ts +7 -0
- package/dist/api/ai-gateway/routing/ModelRouter.js +13 -10
- package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.d.ts +1 -5
- package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.js +8 -63
- package/dist/api/auth/AuthContext.d.ts +4 -0
- package/dist/api/auth/ClientCredentialsAuthenticator.js +11 -5
- package/dist/api/auth/SolidSessionFactory.d.ts +50 -4
- package/dist/api/auth/SolidSessionFactory.js +114 -4
- package/dist/api/chatkit/pod-store.d.ts +8 -1
- package/dist/api/chatkit/pod-store.js +54 -3
- package/dist/api/container/common.js +34 -60
- package/dist/api/container/index.js +0 -3
- package/dist/api/container/routes.js +1 -8
- package/dist/api/container/types.d.ts +2 -9
- package/dist/api/container/types.js +0 -5
- package/dist/api/handlers/AiGatewayManagementHandler.d.ts +4 -12
- package/dist/api/handlers/AiGatewayManagementHandler.js +18 -258
- package/dist/api/middleware/AuthMiddleware.js +29 -1
- package/dist/api/runs/PiAgentRuntimeDriver.js +6 -1
- package/dist/cli/index.js +2 -1
- package/dist/identity/oidc/PodOwnershipResolver.js +16 -6
- package/dist/runtime/ingress-port.d.ts +9 -2
- package/dist/runtime/ingress-port.js +7 -2
- package/dist/runtime/local-secret-file.d.ts +1 -1
- package/dist/runtime/runner/node/CommunitySolidServerCssRunner.d.ts +3 -1
- package/dist/runtime/runner/node/CommunitySolidServerCssRunner.js +31 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.d.ts +3 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.js +96 -67
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.d.ts +2 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.js +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.d.ts +1 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.js +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +81 -23
- package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.d.ts +2 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.js +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.d.ts +2 -1
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.js +2 -2
- package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.js +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/fingerprint.d.ts +1 -0
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/fingerprint.js +7 -0
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/normalize.d.ts +1 -2
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/normalize.js +0 -33
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/request.d.ts +1 -1
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/request.js +68 -22
- package/node_modules/@undefineds.co/ai-connections/dist/contract/client/types.d.ts +37 -10
- package/node_modules/@undefineds.co/ai-connections/dist/controller.js +5 -54
- package/node_modules/@undefineds.co/ai-connections/dist/error-wording.js +7 -2
- package/node_modules/@undefineds.co/ai-connections/dist/service-access-resources.cjs +405 -0
- package/node_modules/@undefineds.co/ai-connections/dist/service-access-resources.d.ts +14 -0
- package/node_modules/@undefineds.co/ai-connections/dist/service-access-resources.js +36 -0
- package/node_modules/@undefineds.co/ai-connections/dist/service-access.js +5 -26
- package/node_modules/@undefineds.co/ai-connections/package.json +10 -2
- package/node_modules/@undefineds.co/extension-sdk/dist/solid-permissions.js +131 -13
- package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +7 -1
- package/node_modules/@undefineds.co/extension-sdk/package.json +1 -1
- package/node_modules/@undefineds.co/pod-collections/dist/index.cjs +38 -5
- package/node_modules/@undefineds.co/pod-collections/dist/mapping.d.ts +8 -0
- package/node_modules/@undefineds.co/pod-collections/dist/mapping.js +34 -0
- package/node_modules/@undefineds.co/pod-collections/dist/mutations.d.ts +2 -1
- package/node_modules/@undefineds.co/pod-collections/dist/mutations.js +6 -4
- package/node_modules/@undefineds.co/pod-collections/dist/sync.js +4 -3
- package/node_modules/@undefineds.co/pod-collections/package.json +1 -1
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpChrome.d.ts +1 -1
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpChrome.js +2 -2
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/IdpViews.js +2 -2
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/PodSignInFrame.d.ts +3 -3
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/PodSignInFrame.js +5 -5
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/parts.d.ts +5 -5
- package/node_modules/@undefineds.co/shared-ui/dist/pod-sign-in/parts.js +5 -5
- package/node_modules/@undefineds.co/shared-ui/dist/theme.css +32 -5
- package/node_modules/@undefineds.co/shared-ui/package.json +1 -1
- package/package.json +2 -2
- package/static/app/assets/main.css +1 -1
- package/static/app/assets/main.js +18 -18
- package/static/dashboard/assets/{AccountAuthBoundary-Dv52SZc6.js → AccountAuthBoundary-CuqXFEW4.js} +1 -1
- package/static/dashboard/assets/{DesktopOidcCallback-DaT_Rumf.js → DesktopOidcCallback-7i-yOvPW.js} +1 -1
- package/static/dashboard/assets/DevicePages-D1m_BNtX.js +2 -0
- package/static/dashboard/assets/ModelsPage-0qWGa5Y6.js +12 -0
- package/static/dashboard/assets/{PaneListHeader-DtvnRmFq.js → PaneListHeader-uWdPgJ0E.js} +1 -1
- package/static/dashboard/assets/{PodDeletionAuthorizationPanel-BJk_8rJq.js → PodDeletionAuthorizationPanel-C22bhZeD.js} +3 -3
- package/static/dashboard/assets/{PodPage-C4gzEspV.js → PodPage-Dyo3yCb-.js} +1 -1
- package/static/dashboard/assets/{SystemSettingsPage-HaNrP1H1.js → SystemSettingsPage-CeX-oG_a.js} +1 -1
- package/static/dashboard/assets/{TasksPage-BdO5K2L7.js → TasksPage-B0EoyRYT.js} +1 -1
- package/static/dashboard/assets/{WebDesktopEntry-Cj9_ZfJU.js → WebDesktopEntry-DT44RrTa.js} +1 -1
- package/static/dashboard/assets/XpodAiConnectionsPodStore-EXCqZPmb.js +3 -0
- package/static/dashboard/assets/XpodShellApp-BEzi4f1j.css +1 -0
- package/static/dashboard/assets/XpodShellApp-DAFsxamX.js +4 -0
- package/static/dashboard/assets/{account-session-DlcKNG7k.js → account-session-rRAOF7nF.js} +1 -1
- package/static/dashboard/assets/{button-wslF55uZ.js → button-WVnQUNG-.js} +1 -1
- package/static/dashboard/assets/{collection-runtime-uxxgEu13.js → collection-runtime-BAJQ8Qub.js} +1 -1
- package/static/dashboard/assets/{createLucideIcon-BJQl82Qk.js → createLucideIcon-BWelSi3L.js} +1 -1
- package/static/dashboard/assets/dashboard-hSOBxPcP.css +1 -0
- package/static/dashboard/assets/{dashboard-Or0gnkou.js → dashboard-vmne1ZE0.js} +2 -2
- package/static/dashboard/assets/{index-BqFeOML9.js → index-HDQQ8asz.js} +1 -1
- package/static/dashboard/assets/{index-DgKn1twH.js → index-gtv-MAHl.js} +1 -1
- package/static/dashboard/assets/{label-CS6Sx6Zb.js → label-tKuCTJm2.js} +1 -1
- package/static/dashboard/assets/{list-UyhlCFKk.js → list-CKq3KHke.js} +1 -1
- package/static/dashboard/assets/{nav-item-style-CW1Nnorq.js → nav-item-style-B2gI7c52.js} +1 -1
- package/static/dashboard/assets/pod-collections-host-BqOAkacM.js +8 -0
- package/static/dashboard/assets/{safe-continuation-ClWAhcma.js → safe-continuation-BsKjDpAA.js} +1 -1
- package/static/dashboard/assets/{section-header-CEIEcco-.js → section-header-DM0JU-wk.js} +1 -1
- package/static/dashboard/assets/{setting-row-CaYv3dfF.js → setting-row-XiH7UjWy.js} +1 -1
- package/static/dashboard/assets/{xpod-remembered-login-BUF9fin1.js → xpod-remembered-login-nv1g1sfC.js} +4 -4
- package/static/dashboard/dashboard.html +2 -2
- package/static/settings/assets/{AccountAuthBoundary-Chqd38oU.js → AccountAuthBoundary-DAUR0omy.js} +1 -1
- package/static/settings/assets/{DesktopOidcCallback-VUrOSM_q.js → DesktopOidcCallback-BNZAZMWY.js} +1 -1
- package/static/settings/assets/DevicePages-BO9SrXRp.js +2 -0
- package/static/settings/assets/ModelsPage-DREEXdf3.js +12 -0
- package/static/settings/assets/{PaneListHeader-B5RkRqr4.js → PaneListHeader-CeUH0JjQ.js} +1 -1
- package/static/settings/assets/{PodDeletionAuthorizationPanel-DPM-5Izt.js → PodDeletionAuthorizationPanel-Ch4--l4b.js} +3 -3
- package/static/settings/assets/{PodPage-CxND6wwc.js → PodPage-CqJBj3GJ.js} +1 -1
- package/static/settings/assets/{SystemSettingsPage-C8EdMkW7.js → SystemSettingsPage-2LSjpqUa.js} +1 -1
- package/static/settings/assets/{TasksPage-DuqptEm8.js → TasksPage-DA5IRxlP.js} +1 -1
- package/static/settings/assets/{WebDesktopEntry-BRcyktkv.js → WebDesktopEntry-BVelF1q0.js} +1 -1
- package/static/settings/assets/XpodAiConnectionsPodStore-O5-2qBsx.js +3 -0
- package/static/settings/assets/XpodShellApp-BEzi4f1j.css +1 -0
- package/static/settings/assets/XpodShellApp-D1b3kqD0.js +4 -0
- package/static/settings/assets/XpodThemeProvider-hSOBxPcP.css +1 -0
- package/static/settings/assets/{XpodThemeProvider-DK3pIdRG.js → XpodThemeProvider-rUdAw66p.js} +2 -2
- package/static/settings/assets/{account-session-DJOZ03xr.js → account-session-BD1q8D_o.js} +1 -1
- package/static/settings/assets/auth-callback-PWS7okI8.js +1 -0
- package/static/settings/assets/{button-D3yW-2o1.js → button-ZJYFB218.js} +1 -1
- package/static/settings/assets/{collection-runtime-DfGo25mh.js → collection-runtime-C2FHCCXJ.js} +1 -1
- package/static/settings/assets/{createLucideIcon-CacwLsmB.js → createLucideIcon-B2wXvYTD.js} +1 -1
- package/static/settings/assets/{index-r5KRYsKC.js → index-JFAkaKZH.js} +1 -1
- package/static/settings/assets/{label-MJjUmvzG.js → label-BLrTAmGy.js} +1 -1
- package/static/settings/assets/{list-Ce-5k1MX.js → list-Cm96vvJO.js} +1 -1
- package/static/settings/assets/{nav-item-style-ZUbL8KOZ.js → nav-item-style-C2upI7sr.js} +1 -1
- package/static/settings/assets/pod-collections-host-BqOAkacM.js +8 -0
- package/static/settings/assets/{safe-continuation-vlBZFSlU.js → safe-continuation-CYaRj3rj.js} +1 -1
- package/static/settings/assets/{section-header-DGJdEvQw.js → section-header-BviL5H8E.js} +1 -1
- package/static/settings/assets/{setting-row-C7tuFiho.js → setting-row-BYikj0YO.js} +1 -1
- package/static/settings/assets/{settings-CyQPih1O.js → settings-CpoDG_Qr.js} +1 -1
- package/static/settings/assets/{xpod-remembered-login-D-TzzT5K.js → xpod-remembered-login-BJ4QUSXy.js} +4 -4
- package/static/settings/auth-callback.html +3 -3
- package/static/settings/settings.html +3 -3
- package/dist/api/ai-gateway/auth/GatewayApiKey.d.ts +0 -28
- package/dist/api/ai-gateway/auth/GatewayApiKey.js +0 -162
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.d.ts +0 -26
- package/dist/api/ai-gateway/auth/GatewayKeyLocatorCodec.js +0 -97
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +0 -67
- package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +0 -340
- package/dist/runtime/gateway-locator-secret.d.ts +0 -5
- package/dist/runtime/gateway-locator-secret.js +0 -30
- package/static/dashboard/assets/DevicePages-HjclpIVm.js +0 -2
- package/static/dashboard/assets/ModelsPage-Be2TPd-x.js +0 -11
- package/static/dashboard/assets/XpodAiConnectionsPodStore-B7gmXBmC.js +0 -3
- package/static/dashboard/assets/XpodShellApp-Bwom2xL3.css +0 -1
- package/static/dashboard/assets/XpodShellApp-D_KY4nCW.js +0 -4
- package/static/dashboard/assets/dashboard-CbJ-JkrI.css +0 -1
- package/static/dashboard/assets/pod-collections-host-DjK2xf-b.js +0 -8
- package/static/settings/assets/DevicePages-C6qwvWwu.js +0 -2
- package/static/settings/assets/ModelsPage-Ry_dObRQ.js +0 -11
- package/static/settings/assets/XpodAiConnectionsPodStore-CyA_BJVC.js +0 -3
- package/static/settings/assets/XpodShellApp-Bwom2xL3.css +0 -1
- package/static/settings/assets/XpodShellApp-CsivHJl0.js +0 -4
- package/static/settings/assets/XpodThemeProvider-CbJ-JkrI.css +0 -1
- package/static/settings/assets/auth-callback-GIBYEz_7.js +0 -1
- package/static/settings/assets/pod-collections-host-DjK2xf-b.js +0 -8
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/service-access-resources.ts
|
|
40
|
+
var exports_service_access_resources = {};
|
|
41
|
+
__export(exports_service_access_resources, {
|
|
42
|
+
AI_CONNECTIONS_SERVICE_RESOURCE_IDS: () => AI_CONNECTIONS_SERVICE_RESOURCE_IDS,
|
|
43
|
+
resolveAiConnectionsServiceResource: () => resolveAiConnectionsServiceResource
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(exports_service_access_resources);
|
|
46
|
+
var import_models = require("@undefineds.co/models");
|
|
47
|
+
|
|
48
|
+
// src/contract/client/types.ts
|
|
49
|
+
var AI_CONNECTIONS_PROVIDERS = [
|
|
50
|
+
"openai",
|
|
51
|
+
"anthropic",
|
|
52
|
+
"kimi",
|
|
53
|
+
"bailian",
|
|
54
|
+
"deepseek",
|
|
55
|
+
"zhipu",
|
|
56
|
+
"ollama",
|
|
57
|
+
"custom"
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
// src/contract/provider-catalog.ts
|
|
61
|
+
var DEFAULT_PROVIDER_OFFERINGS = [
|
|
62
|
+
{ id: "api-platform", label: "API Platform", kind: "api-platform", lifecycle: "active", authModes: ["apiKey"] }
|
|
63
|
+
];
|
|
64
|
+
var API_KEY_METHOD = {
|
|
65
|
+
id: "api-key",
|
|
66
|
+
authMode: "apiKey",
|
|
67
|
+
lifecycle: "active"
|
|
68
|
+
};
|
|
69
|
+
var BROWSER_LOGIN_METHOD = {
|
|
70
|
+
id: "browser-login",
|
|
71
|
+
authMode: "apiKey",
|
|
72
|
+
connectMode: "browserAssistedApiKey",
|
|
73
|
+
lifecycle: "active"
|
|
74
|
+
};
|
|
75
|
+
var API_KEY_METHODS = [API_KEY_METHOD, BROWSER_LOGIN_METHOD];
|
|
76
|
+
var CUSTOM_DEFAULT_OFFERINGS = [
|
|
77
|
+
{
|
|
78
|
+
id: "openai-compatible",
|
|
79
|
+
label: "OpenAI Compatible",
|
|
80
|
+
kind: "api-platform",
|
|
81
|
+
lifecycle: "active",
|
|
82
|
+
authModes: ["apiKey"],
|
|
83
|
+
runtimeProviderIds: ["custom"],
|
|
84
|
+
consoleUrl: "https://undefineds.co",
|
|
85
|
+
subscriptionUrl: "https://undefineds.co",
|
|
86
|
+
endpoints: [{ protocol: "chatCompletions", baseUrl: "https://example.invalid/v1" }],
|
|
87
|
+
modelDiscovery: { strategy: "openaiCompatible", path: "/models", endpointProtocol: "chatCompletions" },
|
|
88
|
+
quota: { strategy: "unsupported", url: "https://undefineds.co" }
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "anthropic-compatible",
|
|
92
|
+
label: "Anthropic Compatible",
|
|
93
|
+
kind: "api-platform",
|
|
94
|
+
lifecycle: "active",
|
|
95
|
+
authModes: ["apiKey"],
|
|
96
|
+
runtimeProviderIds: ["custom"],
|
|
97
|
+
consoleUrl: "https://undefineds.co",
|
|
98
|
+
subscriptionUrl: "https://undefineds.co",
|
|
99
|
+
endpoints: [{ protocol: "anthropic", baseUrl: "https://example.invalid/v1" }],
|
|
100
|
+
modelDiscovery: { strategy: "anthropic", path: "/models", endpointProtocol: "anthropic" },
|
|
101
|
+
quota: { strategy: "unsupported", url: "https://undefineds.co" }
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
var KIMI_SUBSCRIPTION_URL = "https://www.kimi.com/code";
|
|
105
|
+
var KIMI_SUBSCRIPTION_CONSOLE_URL = "https://www.kimi.com/code/console";
|
|
106
|
+
var KIMI_USAGE_POLICY_URL = "https://www.kimi.com/user/agreement";
|
|
107
|
+
var KIMI_CODING_BASE_URL = "https://api.kimi.com/coding/v1";
|
|
108
|
+
var KIMI_ANTHROPIC_BASE_URL = "https://api.kimi.com/coding/";
|
|
109
|
+
var MOONSHOT_CONSOLE_URL = "https://platform.moonshot.cn/console/api-keys";
|
|
110
|
+
var MOONSHOT_ACCOUNT_URL = "https://platform.moonshot.cn/console/account";
|
|
111
|
+
var MOONSHOT_USAGE_POLICY_URL = "https://platform.moonshot.cn/docs/intro";
|
|
112
|
+
var MOONSHOT_BASE_URL = "https://api.moonshot.ai/v1";
|
|
113
|
+
var BAILIAN_CONSOLE_URL = "https://bailian.console.aliyun.com/";
|
|
114
|
+
var BAILIAN_USAGE_POLICY_URL = "https://help.aliyun.com/zh/model-studio/";
|
|
115
|
+
var ZHIPU_CONSOLE_URL = "https://open.bigmodel.cn/usercenter/apikeys";
|
|
116
|
+
var ZHIPU_USAGE_POLICY_URL = "https://open.bigmodel.cn/";
|
|
117
|
+
var ZHIPU_API_BASE_URL = "https://open.bigmodel.cn/api/paas/v4";
|
|
118
|
+
var ZHIPU_CODING_BASE_URL = "https://open.bigmodel.cn/api/coding/paas/v4";
|
|
119
|
+
var PROVIDER_OFFERINGS = {
|
|
120
|
+
openai: [
|
|
121
|
+
{
|
|
122
|
+
id: "official-subscription",
|
|
123
|
+
label: "OpenAI Subscription",
|
|
124
|
+
kind: "oauth-subscription",
|
|
125
|
+
lifecycle: "unavailable",
|
|
126
|
+
authModes: ["oauth", "local"],
|
|
127
|
+
productLabel: "OpenAI",
|
|
128
|
+
runtimeProviderIds: ["openai"],
|
|
129
|
+
credentialPrefixHints: [],
|
|
130
|
+
consoleUrl: "https://chatgpt.com/codex",
|
|
131
|
+
subscriptionUrl: "https://chatgpt.com/codex",
|
|
132
|
+
endpoints: [{ protocol: "responses", baseUrl: "https://chatgpt.com/backend-api/codex" }],
|
|
133
|
+
modelDiscovery: { strategy: "unsupported", path: "/models", endpointProtocol: "responses" },
|
|
134
|
+
quota: { strategy: "subscription", url: "https://chatgpt.com/codex" },
|
|
135
|
+
usagePolicyUrl: "https://openai.com/policies/usage-policies/",
|
|
136
|
+
region: "global"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: "api-platform",
|
|
140
|
+
label: "API Platform",
|
|
141
|
+
kind: "api-platform",
|
|
142
|
+
lifecycle: "active",
|
|
143
|
+
authModes: ["apiKey"],
|
|
144
|
+
authorizationMethods: API_KEY_METHODS,
|
|
145
|
+
productLabel: "OpenAI",
|
|
146
|
+
runtimeProviderIds: ["openai"],
|
|
147
|
+
credentialPrefixHints: ["sk-"],
|
|
148
|
+
consoleUrl: "https://platform.openai.com/api-keys",
|
|
149
|
+
subscriptionUrl: "https://platform.openai.com/settings/organization/billing/overview",
|
|
150
|
+
endpoints: [
|
|
151
|
+
{ protocol: "responses", baseUrl: "https://api.openai.com/v1" },
|
|
152
|
+
{ protocol: "chatCompletions", baseUrl: "https://api.openai.com/v1" }
|
|
153
|
+
],
|
|
154
|
+
modelDiscovery: { strategy: "openaiCompatible", path: "/models", endpointProtocol: "responses" },
|
|
155
|
+
quota: { strategy: "providerApi", url: "https://platform.openai.com/usage" },
|
|
156
|
+
usagePolicyUrl: "https://openai.com/policies/usage-policies/",
|
|
157
|
+
region: "global"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
anthropic: [
|
|
161
|
+
{
|
|
162
|
+
id: "official-subscription",
|
|
163
|
+
label: "Claude Pro / Max",
|
|
164
|
+
kind: "oauth-subscription",
|
|
165
|
+
lifecycle: "unavailable",
|
|
166
|
+
authModes: ["oauth"],
|
|
167
|
+
authorizationMethods: [],
|
|
168
|
+
productLabel: "Claude Code",
|
|
169
|
+
runtimeProviderIds: ["anthropic"],
|
|
170
|
+
credentialPrefixHints: [],
|
|
171
|
+
consoleUrl: "https://claude.ai/",
|
|
172
|
+
subscriptionUrl: "https://claude.com/pricing",
|
|
173
|
+
endpoints: [],
|
|
174
|
+
modelDiscovery: { strategy: "unsupported", path: "/models", endpointProtocol: "anthropic" },
|
|
175
|
+
quota: { strategy: "subscription", url: "https://claude.ai/settings/usage" },
|
|
176
|
+
usagePolicyUrl: "https://www.anthropic.com/legal/aup",
|
|
177
|
+
region: "global"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: "api-platform",
|
|
181
|
+
label: "API Platform",
|
|
182
|
+
kind: "api-platform",
|
|
183
|
+
lifecycle: "active",
|
|
184
|
+
authModes: ["apiKey"],
|
|
185
|
+
authorizationMethods: API_KEY_METHODS,
|
|
186
|
+
productLabel: "Anthropic",
|
|
187
|
+
runtimeProviderIds: ["anthropic"],
|
|
188
|
+
credentialPrefixHints: ["sk-ant-"],
|
|
189
|
+
consoleUrl: "https://console.anthropic.com/settings/keys",
|
|
190
|
+
subscriptionUrl: "https://console.anthropic.com/settings/plans",
|
|
191
|
+
endpoints: [{ protocol: "anthropic", baseUrl: "https://api.anthropic.com/v1" }],
|
|
192
|
+
modelDiscovery: { strategy: "anthropic", path: "/models", endpointProtocol: "anthropic" },
|
|
193
|
+
quota: { strategy: "console", url: "https://console.anthropic.com/settings/limits" },
|
|
194
|
+
usagePolicyUrl: "https://www.anthropic.com/legal/aup",
|
|
195
|
+
region: "global"
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
kimi: [
|
|
199
|
+
kimiOffering({
|
|
200
|
+
id: "subscription-key",
|
|
201
|
+
label: "Token Plan",
|
|
202
|
+
kind: "token-plan",
|
|
203
|
+
authModes: ["apiKey"],
|
|
204
|
+
productLabel: "Kimi Coding",
|
|
205
|
+
runtimeProviderIds: ["kimi"],
|
|
206
|
+
credentialPrefixHints: ["sk-kimi-"],
|
|
207
|
+
baseUrl: KIMI_CODING_BASE_URL,
|
|
208
|
+
anthropicBaseUrl: KIMI_ANTHROPIC_BASE_URL,
|
|
209
|
+
quotaStrategy: "subscription",
|
|
210
|
+
quotaUrl: KIMI_SUBSCRIPTION_URL,
|
|
211
|
+
consoleUrl: KIMI_SUBSCRIPTION_CONSOLE_URL,
|
|
212
|
+
subscriptionUrl: KIMI_SUBSCRIPTION_URL,
|
|
213
|
+
usagePolicyUrl: KIMI_USAGE_POLICY_URL,
|
|
214
|
+
supportsDeveloperMessages: false
|
|
215
|
+
}),
|
|
216
|
+
kimiOffering({
|
|
217
|
+
id: "api-platform",
|
|
218
|
+
label: "API Platform",
|
|
219
|
+
kind: "api-platform",
|
|
220
|
+
authModes: ["apiKey"],
|
|
221
|
+
productLabel: "Moonshot AI",
|
|
222
|
+
runtimeProviderIds: ["kimi"],
|
|
223
|
+
credentialPrefixHints: ["sk-"],
|
|
224
|
+
baseUrl: MOONSHOT_BASE_URL,
|
|
225
|
+
quotaStrategy: "console",
|
|
226
|
+
quotaUrl: MOONSHOT_ACCOUNT_URL,
|
|
227
|
+
consoleUrl: MOONSHOT_CONSOLE_URL,
|
|
228
|
+
subscriptionUrl: MOONSHOT_ACCOUNT_URL,
|
|
229
|
+
usagePolicyUrl: MOONSHOT_USAGE_POLICY_URL
|
|
230
|
+
})
|
|
231
|
+
],
|
|
232
|
+
bailian: [
|
|
233
|
+
bailianOffering({ id: "pay-as-you-go", label: "Pay as You Go", kind: "api-platform", runtimeProviderIds: ["bailian"], credentialPrefixHints: ["sk-"], region: "cn", baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1", anthropicBaseUrl: "https://dashscope.aliyuncs.com/apps/anthropic", quotaStrategy: "console", consoleUrl: BAILIAN_CONSOLE_URL, usagePolicyUrl: BAILIAN_USAGE_POLICY_URL }),
|
|
234
|
+
bailianOffering({ id: "token-plan", label: "Token Plan Personal", kind: "token-plan", runtimeProviderIds: ["bailian-token-plan"], credentialPrefixHints: ["sk-"], region: "cn-beijing", baseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1", anthropicBaseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic", quotaStrategy: "subscription", consoleUrl: BAILIAN_CONSOLE_URL, usagePolicyUrl: BAILIAN_USAGE_POLICY_URL }),
|
|
235
|
+
bailianOffering({ id: "token-plan-team", label: "Token Plan Team", kind: "token-plan", runtimeProviderIds: ["bailian-token-plan"], credentialPrefixHints: ["sk-"], region: "cn-beijing", baseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1", anthropicBaseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic", quotaStrategy: "subscription", consoleUrl: BAILIAN_CONSOLE_URL, usagePolicyUrl: BAILIAN_USAGE_POLICY_URL }),
|
|
236
|
+
bailianOffering({ id: "coding-plan", label: "Coding Plan Pro", kind: "token-plan", runtimeProviderIds: ["bailian-coding-plan"], credentialPrefixHints: ["sk-sp-"], region: "cn", baseUrl: "https://coding.dashscope.aliyuncs.com/v1", anthropicBaseUrl: "https://coding.dashscope.aliyuncs.com/apps/anthropic", quotaStrategy: "subscription", consoleUrl: BAILIAN_CONSOLE_URL, usagePolicyUrl: BAILIAN_USAGE_POLICY_URL })
|
|
237
|
+
],
|
|
238
|
+
deepseek: [
|
|
239
|
+
{
|
|
240
|
+
id: "api-platform",
|
|
241
|
+
label: "API Platform",
|
|
242
|
+
kind: "api-platform",
|
|
243
|
+
lifecycle: "active",
|
|
244
|
+
authModes: ["apiKey"],
|
|
245
|
+
productLabel: "DeepSeek",
|
|
246
|
+
runtimeProviderIds: ["deepseek"],
|
|
247
|
+
credentialPrefixHints: ["sk-"],
|
|
248
|
+
consoleUrl: "https://platform.deepseek.com/api_keys",
|
|
249
|
+
subscriptionUrl: "https://platform.deepseek.com/usage",
|
|
250
|
+
endpoints: [{ protocol: "chatCompletions", baseUrl: "https://api.deepseek.com/v1" }],
|
|
251
|
+
modelDiscovery: { strategy: "openaiCompatible", path: "/models", endpointProtocol: "chatCompletions" },
|
|
252
|
+
quota: { strategy: "console", url: "https://platform.deepseek.com/usage" },
|
|
253
|
+
usagePolicyUrl: "https://cdn.deepseek.com/policies/en-US/deepseek-open-platform-terms-of-use.html",
|
|
254
|
+
region: "global"
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
ollama: [
|
|
258
|
+
{
|
|
259
|
+
id: "local",
|
|
260
|
+
label: "Local Ollama",
|
|
261
|
+
kind: "local",
|
|
262
|
+
lifecycle: "active",
|
|
263
|
+
authModes: ["local"],
|
|
264
|
+
productLabel: "Ollama",
|
|
265
|
+
runtimeProviderIds: ["ollama"],
|
|
266
|
+
credentialPrefixHints: [],
|
|
267
|
+
consoleUrl: "https://ollama.com",
|
|
268
|
+
subscriptionUrl: "https://ollama.com",
|
|
269
|
+
endpoints: [{ protocol: "chatCompletions", baseUrl: "http://localhost:11434/v1" }],
|
|
270
|
+
modelDiscovery: { strategy: "openaiCompatible", path: "/models", endpointProtocol: "chatCompletions" },
|
|
271
|
+
quota: { strategy: "unsupported", url: "https://ollama.com" },
|
|
272
|
+
usagePolicyUrl: "https://ollama.com",
|
|
273
|
+
region: "local"
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
zhipu: [
|
|
277
|
+
{
|
|
278
|
+
id: "api-platform",
|
|
279
|
+
label: "API Platform",
|
|
280
|
+
kind: "api-platform",
|
|
281
|
+
lifecycle: "active",
|
|
282
|
+
authModes: ["apiKey"],
|
|
283
|
+
authorizationMethods: API_KEY_METHODS,
|
|
284
|
+
productLabel: "智谱 AI",
|
|
285
|
+
runtimeProviderIds: ["zhipu"],
|
|
286
|
+
credentialPrefixHints: ["id."],
|
|
287
|
+
consoleUrl: ZHIPU_CONSOLE_URL,
|
|
288
|
+
subscriptionUrl: "https://open.bigmodel.cn/finance-center/expense-manage",
|
|
289
|
+
endpoints: [{ protocol: "chatCompletions", baseUrl: ZHIPU_API_BASE_URL, region: "cn" }],
|
|
290
|
+
modelDiscovery: { strategy: "openaiCompatible", path: "/models", endpointProtocol: "chatCompletions" },
|
|
291
|
+
quota: { strategy: "console", url: "https://open.bigmodel.cn/finance-center/expense-manage" },
|
|
292
|
+
usagePolicyUrl: ZHIPU_USAGE_POLICY_URL,
|
|
293
|
+
region: "cn"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
id: "coding-plan",
|
|
297
|
+
label: "GLM Coding Plan",
|
|
298
|
+
kind: "token-plan",
|
|
299
|
+
lifecycle: "active",
|
|
300
|
+
authModes: ["apiKey"],
|
|
301
|
+
authorizationMethods: API_KEY_METHODS,
|
|
302
|
+
productLabel: "智谱 AI",
|
|
303
|
+
runtimeProviderIds: ["zhipu"],
|
|
304
|
+
credentialPrefixHints: ["id."],
|
|
305
|
+
consoleUrl: ZHIPU_CONSOLE_URL,
|
|
306
|
+
subscriptionUrl: "https://bigmodel.cn/glm-coding",
|
|
307
|
+
endpoints: [{ protocol: "chatCompletions", baseUrl: ZHIPU_CODING_BASE_URL, region: "cn" }],
|
|
308
|
+
modelDiscovery: { strategy: "openaiCompatible", path: "/models", endpointProtocol: "chatCompletions" },
|
|
309
|
+
quota: { strategy: "subscription", url: "https://bigmodel.cn/glm-coding" },
|
|
310
|
+
usagePolicyUrl: ZHIPU_USAGE_POLICY_URL,
|
|
311
|
+
region: "cn"
|
|
312
|
+
}
|
|
313
|
+
]
|
|
314
|
+
};
|
|
315
|
+
function kimiOffering(input) {
|
|
316
|
+
return {
|
|
317
|
+
id: input.id,
|
|
318
|
+
label: input.label,
|
|
319
|
+
kind: input.kind,
|
|
320
|
+
lifecycle: "active",
|
|
321
|
+
authModes: input.authModes,
|
|
322
|
+
authorizationMethods: API_KEY_METHODS,
|
|
323
|
+
productLabel: input.productLabel,
|
|
324
|
+
runtimeProviderIds: input.runtimeProviderIds,
|
|
325
|
+
credentialPrefixHints: input.credentialPrefixHints,
|
|
326
|
+
consoleUrl: input.consoleUrl,
|
|
327
|
+
subscriptionUrl: input.subscriptionUrl,
|
|
328
|
+
endpoints: offeringEndpoints(input.baseUrl, input.anthropicBaseUrl, "cn", input.supportsDeveloperMessages),
|
|
329
|
+
modelDiscovery: { strategy: "openaiCompatible", path: "/models", endpointProtocol: "chatCompletions" },
|
|
330
|
+
quota: { strategy: input.quotaStrategy, url: input.quotaUrl },
|
|
331
|
+
usagePolicyUrl: input.usagePolicyUrl,
|
|
332
|
+
region: "cn"
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function bailianOffering(input) {
|
|
336
|
+
return {
|
|
337
|
+
id: input.id,
|
|
338
|
+
label: input.label,
|
|
339
|
+
lifecycle: "active",
|
|
340
|
+
productLabel: "Alibaba Bailian",
|
|
341
|
+
kind: input.kind,
|
|
342
|
+
authModes: ["apiKey"],
|
|
343
|
+
authorizationMethods: API_KEY_METHODS,
|
|
344
|
+
runtimeProviderIds: input.runtimeProviderIds,
|
|
345
|
+
credentialPrefixHints: input.credentialPrefixHints,
|
|
346
|
+
consoleUrl: input.consoleUrl,
|
|
347
|
+
subscriptionUrl: input.consoleUrl,
|
|
348
|
+
endpoints: offeringEndpoints(input.baseUrl, input.anthropicBaseUrl, input.region),
|
|
349
|
+
modelDiscovery: { strategy: "openaiCompatible", path: "/models", endpointProtocol: "chatCompletions" },
|
|
350
|
+
quota: { strategy: input.quotaStrategy, url: input.consoleUrl },
|
|
351
|
+
usagePolicyUrl: input.usagePolicyUrl,
|
|
352
|
+
region: input.region
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function offeringEndpoints(chatCompletionsBaseUrl, anthropicBaseUrl, region, supportsDeveloperMessages) {
|
|
356
|
+
return [
|
|
357
|
+
{
|
|
358
|
+
protocol: "chatCompletions",
|
|
359
|
+
baseUrl: chatCompletionsBaseUrl,
|
|
360
|
+
region,
|
|
361
|
+
...supportsDeveloperMessages === undefined ? {} : { supportsDeveloperMessages }
|
|
362
|
+
},
|
|
363
|
+
...anthropicBaseUrl ? [{ protocol: "anthropic", baseUrl: anthropicBaseUrl, region }] : []
|
|
364
|
+
];
|
|
365
|
+
}
|
|
366
|
+
var AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS = AI_CONNECTIONS_PROVIDERS.flatMap((provider) => [
|
|
367
|
+
provider,
|
|
368
|
+
...builtinOfferings(provider).map((offering) => `${provider}-${offering.id}`)
|
|
369
|
+
]);
|
|
370
|
+
function builtinOfferings(provider) {
|
|
371
|
+
if (provider === "custom")
|
|
372
|
+
return CUSTOM_DEFAULT_OFFERINGS;
|
|
373
|
+
return PROVIDER_OFFERINGS[provider] ?? DEFAULT_PROVIDER_OFFERINGS;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/service-access-resources.ts
|
|
377
|
+
function declaredDocumentPath(resource, id = "__service_access__") {
|
|
378
|
+
const base = resource.config?.base?.replace(/^\/+|\/+$/gu, "");
|
|
379
|
+
if (!base)
|
|
380
|
+
throw new Error("AI Connection resource is missing a declared base");
|
|
381
|
+
return `${base}/${resource.buildId({ id }).split("#")[0]}`.replace(/^\/+/u, "");
|
|
382
|
+
}
|
|
383
|
+
var RDF_RESOURCE_PATHS = Object.freeze({
|
|
384
|
+
providerCredentials: declaredDocumentPath(import_models.credentialResource),
|
|
385
|
+
providerDefinitions: declaredDocumentPath(import_models.aiProviderResource),
|
|
386
|
+
quotaSnapshots: declaredDocumentPath(import_models.quotaSnapshotResource)
|
|
387
|
+
});
|
|
388
|
+
var PROVIDER_DOCUMENT_PATHS = new Map(AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS.map((id) => [
|
|
389
|
+
`providerDocument:${id}`,
|
|
390
|
+
declaredDocumentPath(import_models.aiProviderResource, id)
|
|
391
|
+
]));
|
|
392
|
+
var AI_CONNECTIONS_SERVICE_RESOURCE_IDS = [
|
|
393
|
+
"providerCredentials",
|
|
394
|
+
"providerDefinitions",
|
|
395
|
+
"quotaSnapshots",
|
|
396
|
+
...[...PROVIDER_DOCUMENT_PATHS.keys()]
|
|
397
|
+
];
|
|
398
|
+
function resolveAiConnectionsServiceResource(id, podBaseUrl) {
|
|
399
|
+
const mediaType = "text/turtle";
|
|
400
|
+
const path = Object.prototype.hasOwnProperty.call(RDF_RESOURCE_PATHS, id) ? RDF_RESOURCE_PATHS[id] : PROVIDER_DOCUMENT_PATHS.get(id);
|
|
401
|
+
if (!path)
|
|
402
|
+
return;
|
|
403
|
+
const root = podBaseUrl.endsWith("/") ? podBaseUrl : `${podBaseUrl}/`;
|
|
404
|
+
return { url: new URL(path, root).href, mediaType };
|
|
405
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AiConnectionsServiceResourceLocation {
|
|
2
|
+
url: string;
|
|
3
|
+
mediaType: 'text/turtle' | 'application/json';
|
|
4
|
+
}
|
|
5
|
+
declare const RDF_RESOURCE_PATHS: Readonly<{
|
|
6
|
+
providerCredentials: string;
|
|
7
|
+
providerDefinitions: string;
|
|
8
|
+
quotaSnapshots: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type AiConnectionsServiceResourceId = keyof typeof RDF_RESOURCE_PATHS | `providerDocument:${string}`;
|
|
11
|
+
export declare const AI_CONNECTIONS_SERVICE_RESOURCE_IDS: readonly AiConnectionsServiceResourceId[];
|
|
12
|
+
/** Resolve only capability-declared documents inside an already verified Pod binding. */
|
|
13
|
+
export declare function resolveAiConnectionsServiceResource(id: string, podBaseUrl: string): AiConnectionsServiceResourceLocation | undefined;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { aiProviderResource, credentialResource, quotaSnapshotResource, } from '@undefineds.co/models';
|
|
2
|
+
import { AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS } from './contract/provider-catalog.js';
|
|
3
|
+
// Capture model declarations before a database hydrates their mutable runtime paths.
|
|
4
|
+
// Permissions target HTTP documents; RDF subject fragments remain model identities.
|
|
5
|
+
function declaredDocumentPath(resource, id = '__service_access__') {
|
|
6
|
+
const base = resource.config?.base?.replace(/^\/+|\/+$/gu, '');
|
|
7
|
+
if (!base)
|
|
8
|
+
throw new Error('AI Connection resource is missing a declared base');
|
|
9
|
+
return `${base}/${resource.buildId({ id }).split('#')[0]}`.replace(/^\/+/u, '');
|
|
10
|
+
}
|
|
11
|
+
const RDF_RESOURCE_PATHS = Object.freeze({
|
|
12
|
+
providerCredentials: declaredDocumentPath(credentialResource),
|
|
13
|
+
providerDefinitions: declaredDocumentPath(aiProviderResource),
|
|
14
|
+
quotaSnapshots: declaredDocumentPath(quotaSnapshotResource),
|
|
15
|
+
});
|
|
16
|
+
const PROVIDER_DOCUMENT_PATHS = new Map(AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS.map(id => [
|
|
17
|
+
`providerDocument:${id}`,
|
|
18
|
+
declaredDocumentPath(aiProviderResource, id),
|
|
19
|
+
]));
|
|
20
|
+
export const AI_CONNECTIONS_SERVICE_RESOURCE_IDS = [
|
|
21
|
+
'providerCredentials',
|
|
22
|
+
'providerDefinitions',
|
|
23
|
+
'quotaSnapshots',
|
|
24
|
+
...[...PROVIDER_DOCUMENT_PATHS.keys()],
|
|
25
|
+
];
|
|
26
|
+
/** Resolve only capability-declared documents inside an already verified Pod binding. */
|
|
27
|
+
export function resolveAiConnectionsServiceResource(id, podBaseUrl) {
|
|
28
|
+
const mediaType = 'text/turtle';
|
|
29
|
+
const path = Object.prototype.hasOwnProperty.call(RDF_RESOURCE_PATHS, id)
|
|
30
|
+
? RDF_RESOURCE_PATHS[id]
|
|
31
|
+
: PROVIDER_DOCUMENT_PATHS.get(id);
|
|
32
|
+
if (!path)
|
|
33
|
+
return undefined;
|
|
34
|
+
const root = podBaseUrl.endsWith('/') ? podBaseUrl : `${podBaseUrl}/`;
|
|
35
|
+
return { url: new URL(path, root).href, mediaType };
|
|
36
|
+
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveAiConnectionsServiceResource } from './service-access-resources.js';
|
|
2
2
|
export const AI_CONNECTIONS_APPLET_ID = 'co.undefineds.ai-connections';
|
|
3
|
-
const KNOWN_RESOURCE_PATHS = {
|
|
4
|
-
providerCredentials: 'settings/credentials.ttl',
|
|
5
|
-
providerDefinitions: 'settings/providers/__service_access__.ttl',
|
|
6
|
-
gatewayAccessKeys: '.data/ai/gateway/access-keys.ttl',
|
|
7
|
-
quotaSnapshots: '.data/ai/gateway/quota.ttl',
|
|
8
|
-
};
|
|
9
|
-
const PROVIDER_DOCUMENT_ID_SET = new Set(AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS);
|
|
10
3
|
export function parseAiConnectionsServiceAccess(value, currentPodUrl) {
|
|
11
4
|
if (!isRecord(value))
|
|
12
5
|
throw new Error('invalid_descriptor');
|
|
@@ -38,12 +31,11 @@ function parseResource(value, podRoot, ids) {
|
|
|
38
31
|
if (!isRecord(value)
|
|
39
32
|
|| typeof value.id !== 'string'
|
|
40
33
|
|| typeof value.url !== 'string'
|
|
41
|
-
|| value.mediaType !== 'text/turtle'
|
|
42
34
|
|| !isRecord(value.access)) {
|
|
43
35
|
throw new Error('invalid_resource');
|
|
44
36
|
}
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
37
|
+
const expectedResource = resolveAiConnectionsServiceResource(value.id, podRoot.href);
|
|
38
|
+
if (!expectedResource || value.mediaType !== expectedResource.mediaType || ids.has(value.id)) {
|
|
47
39
|
throw new Error('invalid_resource');
|
|
48
40
|
}
|
|
49
41
|
assertSafeResourceUrlString(value.url);
|
|
@@ -57,30 +49,17 @@ function parseResource(value, podRoot, ids) {
|
|
|
57
49
|
if (!isInsideContainer(url, podRoot)) {
|
|
58
50
|
throw new Error('invalid_resource');
|
|
59
51
|
}
|
|
60
|
-
if (url.href !==
|
|
52
|
+
if (url.href !== expectedResource.url) {
|
|
61
53
|
throw new Error('invalid_resource');
|
|
62
54
|
}
|
|
63
55
|
ids.add(value.id);
|
|
64
56
|
return {
|
|
65
57
|
id: value.id,
|
|
66
58
|
url: url.href,
|
|
67
|
-
mediaType:
|
|
59
|
+
mediaType: expectedResource.mediaType,
|
|
68
60
|
access: parseAccess(value.access),
|
|
69
61
|
};
|
|
70
62
|
}
|
|
71
|
-
function expectedResourceHref(id, podRoot) {
|
|
72
|
-
const knownPath = KNOWN_RESOURCE_PATHS[id];
|
|
73
|
-
if (knownPath) {
|
|
74
|
-
return new URL(knownPath, podRoot).href;
|
|
75
|
-
}
|
|
76
|
-
const providerDocumentId = id.startsWith('providerDocument:')
|
|
77
|
-
? id.slice('providerDocument:'.length)
|
|
78
|
-
: undefined;
|
|
79
|
-
if (providerDocumentId && PROVIDER_DOCUMENT_ID_SET.has(providerDocumentId)) {
|
|
80
|
-
return new URL(`settings/providers/${providerDocumentId}.ttl`, podRoot).href;
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
63
|
function assertSafeResourceUrlString(value) {
|
|
85
64
|
if (/%(?![0-9a-fA-F]{2})/.test(value)
|
|
86
65
|
|| /%(?:2f|5c)/i.test(value)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@undefineds.co/ai-connections",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -34,10 +34,15 @@
|
|
|
34
34
|
"./endpoint-urls": {
|
|
35
35
|
"types": "./dist/contract/endpoint-urls.d.ts",
|
|
36
36
|
"import": "./dist/contract/endpoint-urls.js"
|
|
37
|
+
},
|
|
38
|
+
"./service-access-resources": {
|
|
39
|
+
"types": "./dist/service-access-resources.d.ts",
|
|
40
|
+
"import": "./dist/service-access-resources.js",
|
|
41
|
+
"require": "./dist/service-access-resources.cjs"
|
|
37
42
|
}
|
|
38
43
|
},
|
|
39
44
|
"scripts": {
|
|
40
|
-
"build": "rm -rf dist && tsc -p tsconfig.json && bun ../../scripts/fix-dist-js-imports.mjs dist && bun build src/contract/client-config/index.ts --target=node --format=cjs --outfile=dist/contract/client-config/index.cjs && bun build src/contract/provider-catalog.ts --target=node --format=cjs --outfile=dist/contract/provider-catalog.cjs",
|
|
45
|
+
"build": "rm -rf dist && tsc -p tsconfig.json && bun ../../scripts/fix-dist-js-imports.mjs dist && bun build src/contract/client-config/index.ts --target=node --format=cjs --outfile=dist/contract/client-config/index.cjs && bun build src/contract/provider-catalog.ts --target=node --format=cjs --outfile=dist/contract/provider-catalog.cjs && bun build src/service-access-resources.ts --target=node --format=cjs --external @undefineds.co/models --outfile=dist/service-access-resources.cjs",
|
|
41
46
|
"test": "vitest run --config ../../vitest.packages.config.mts"
|
|
42
47
|
},
|
|
43
48
|
"dependencies": {
|
|
@@ -73,6 +78,9 @@
|
|
|
73
78
|
],
|
|
74
79
|
"endpoint-urls": [
|
|
75
80
|
"dist/contract/endpoint-urls.d.ts"
|
|
81
|
+
],
|
|
82
|
+
"service-access-resources": [
|
|
83
|
+
"dist/service-access-resources.d.ts"
|
|
76
84
|
]
|
|
77
85
|
}
|
|
78
86
|
}
|