@undefineds.co/xpod 0.2.24 → 0.2.26

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.
@@ -0,0 +1,8 @@
1
+ export type ChatExecutionRoute = 'ai-gateway' | 'provider';
2
+ export type ProviderProtocolRoute = 'native' | 'chat-fallback';
3
+ export declare function resolveChatExecutionRoute(input: {
4
+ model?: string;
5
+ shouldUseAiGateway(model?: string): Promise<boolean>;
6
+ }): Promise<ChatExecutionRoute>;
7
+ export declare function resolveResponsesProviderRoute(baseUrl: string): ProviderProtocolRoute;
8
+ export declare function resolveMessagesProviderRoute(baseUrl: string): ProviderProtocolRoute;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveChatExecutionRoute = resolveChatExecutionRoute;
4
+ exports.resolveResponsesProviderRoute = resolveResponsesProviderRoute;
5
+ exports.resolveMessagesProviderRoute = resolveMessagesProviderRoute;
6
+ const provider_registry_1 = require("./provider-registry");
7
+ async function resolveChatExecutionRoute(input) {
8
+ return await input.shouldUseAiGateway(input.model) ? 'ai-gateway' : 'provider';
9
+ }
10
+ function resolveResponsesProviderRoute(baseUrl) {
11
+ return (0, provider_registry_1.supportsResponsesApi)(baseUrl) ? 'native' : 'chat-fallback';
12
+ }
13
+ function resolveMessagesProviderRoute(baseUrl) {
14
+ return (0, provider_registry_1.supportsMessagesApi)(baseUrl) ? 'native' : 'chat-fallback';
15
+ }
16
+ //# sourceMappingURL=chat-routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-routing.js","sourceRoot":"","sources":["../../../src/api/service/chat-routing.ts"],"names":[],"mappings":";;AAQA,8DAKC;AAED,sEAEC;AAED,oEAEC;AArBD,2DAG6B;AAKtB,KAAK,UAAU,yBAAyB,CAAC,KAG/C;IACC,OAAO,MAAM,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC;AACjF,CAAC;AAED,SAAgB,6BAA6B,CAAC,OAAe;IAC3D,OAAO,IAAA,wCAAoB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC;AACpE,CAAC;AAED,SAAgB,4BAA4B,CAAC,OAAe;IAC1D,OAAO,IAAA,uCAAmB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC;AACnE,CAAC","sourcesContent":["import {\n supportsMessagesApi,\n supportsResponsesApi,\n} from './provider-registry';\n\nexport type ChatExecutionRoute = 'ai-gateway' | 'provider';\nexport type ProviderProtocolRoute = 'native' | 'chat-fallback';\n\nexport async function resolveChatExecutionRoute(input: {\n model?: string;\n shouldUseAiGateway(model?: string): Promise<boolean>;\n}): Promise<ChatExecutionRoute> {\n return await input.shouldUseAiGateway(input.model) ? 'ai-gateway' : 'provider';\n}\n\nexport function resolveResponsesProviderRoute(baseUrl: string): ProviderProtocolRoute {\n return supportsResponsesApi(baseUrl) ? 'native' : 'chat-fallback';\n}\n\nexport function resolveMessagesProviderRoute(baseUrl: string): ProviderProtocolRoute {\n return supportsMessagesApi(baseUrl) ? 'native' : 'chat-fallback';\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export declare class ProviderHttpTransport {
2
+ postJson(options: {
3
+ url: string;
4
+ apiKey: string;
5
+ body: any;
6
+ proxy?: string;
7
+ headers?: HeadersInit;
8
+ }): Promise<any>;
9
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProviderHttpTransport = void 0;
4
+ const undici_1 = require("undici");
5
+ function createProxyFetch(proxyUrl) {
6
+ const agent = new undici_1.ProxyAgent(proxyUrl);
7
+ return (url, init) => fetch(url, { ...init, dispatcher: agent });
8
+ }
9
+ class ProviderHttpTransport {
10
+ async postJson(options) {
11
+ const fetchFn = options.proxy ? createProxyFetch(options.proxy) : fetch;
12
+ const headers = new Headers(options.headers);
13
+ headers.set('Content-Type', 'application/json');
14
+ headers.set('Authorization', `Bearer ${options.apiKey}`);
15
+ const response = await fetchFn(options.url, {
16
+ method: 'POST',
17
+ headers,
18
+ body: JSON.stringify(options.body),
19
+ });
20
+ if (!response.ok) {
21
+ const errorText = await response.text();
22
+ const error = new Error(`Provider error: ${response.statusText}`);
23
+ error.status = response.status;
24
+ error.headers = response.headers;
25
+ error.body = errorText;
26
+ throw error;
27
+ }
28
+ return response.json();
29
+ }
30
+ }
31
+ exports.ProviderHttpTransport = ProviderHttpTransport;
32
+ //# sourceMappingURL=provider-http-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-http-transport.js","sourceRoot":"","sources":["../../../src/api/service/provider-http-transport.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,SAAS,gBAAgB,CAAC,QAAgB;IACxC,MAAM,KAAK,GAAG,IAAI,mBAAU,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,KAAK,EAAS,CAAC,CAAC;AAC1E,CAAC;AAED,MAAa,qBAAqB;IACzB,KAAK,CAAC,QAAQ,CAAC,OAMrB;QACC,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACxE,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAEzD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;YAC1C,MAAM,EAAE,MAAM;YACd,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;SACnC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,mBAAmB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YACjE,KAAa,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;YACvC,KAAa,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;YACzC,KAAa,CAAC,IAAI,GAAG,SAAS,CAAC;YAChC,MAAM,KAAK,CAAC;QACd,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;CACF;AA9BD,sDA8BC","sourcesContent":["import { ProxyAgent } from 'undici';\n\nfunction createProxyFetch(proxyUrl: string): typeof fetch {\n const agent = new ProxyAgent(proxyUrl);\n return (url, init) => fetch(url, { ...init, dispatcher: agent } as any);\n}\n\nexport class ProviderHttpTransport {\n public async postJson(options: {\n url: string;\n apiKey: string;\n body: any;\n proxy?: string;\n headers?: HeadersInit;\n }): Promise<any> {\n const fetchFn = options.proxy ? createProxyFetch(options.proxy) : fetch;\n const headers = new Headers(options.headers);\n headers.set('Content-Type', 'application/json');\n headers.set('Authorization', `Bearer ${options.apiKey}`);\n\n const response = await fetchFn(options.url, {\n method: 'POST',\n headers,\n body: JSON.stringify(options.body),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n const error = new Error(`Provider error: ${response.statusText}`);\n (error as any).status = response.status;\n (error as any).headers = response.headers;\n (error as any).body = errorText;\n throw error;\n }\n\n return response.json();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@undefineds.co/xpod",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "description": "Xpod is an extended Community Solid Server, offering rich-feature, production-level Solid Pod and identity management.",
5
5
  "repository": "https://github.com/undefinedsco/xpod",
6
6
  "author": "developer@undefineds.co",