@jini-ai/integrations 0.3.6 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/README.md +72 -24
- package/dist/args.d.ts +8 -0
- package/dist/args.js +10 -0
- package/dist/argument-error.d.ts +9 -0
- package/dist/argument-error.js +7 -0
- package/dist/credentialed-http/auth-schemes.d.ts +29 -0
- package/dist/credentialed-http/auth-schemes.js +60 -0
- package/dist/credentialed-http/credentialed-request.d.ts +132 -0
- package/dist/credentialed-http/credentialed-request.js +365 -0
- package/dist/credentialed-http/index.d.ts +4 -0
- package/dist/credentialed-http/index.js +4 -0
- package/dist/credentialed-http/ports.d.ts +42 -0
- package/dist/credentialed-http/ports.js +2 -0
- package/dist/media-providers/capability-registry.d.ts +13 -7
- package/dist/media-providers/capability-registry.js +6 -6
- package/dist/media-providers/dispatch/async-operation-store.d.ts +25 -8
- package/dist/media-providers/dispatch/async-operation-store.js +12 -32
- package/dist/media-providers/dispatch/builtin-vendors.d.ts +6 -0
- package/dist/media-providers/dispatch/builtin-vendors.js +30 -0
- package/dist/media-providers/dispatch/context.d.ts +7 -2
- package/dist/media-providers/dispatch/context.js +1 -1
- package/dist/media-providers/dispatch/credentials.d.ts +4 -1
- package/dist/media-providers/dispatch/credentials.js +1 -1
- package/dist/media-providers/dispatch/engine.d.ts +5 -13
- package/dist/media-providers/dispatch/engine.js +25 -26
- package/dist/media-providers/dispatch/index.d.ts +4 -1
- package/dist/media-providers/dispatch/index.js +4 -2
- package/dist/media-providers/dispatch/openai-compatible.d.ts +12 -2
- package/dist/media-providers/dispatch/openai-compatible.js +9 -5
- package/dist/media-providers/dispatch/operation-runtime.d.ts +16 -8
- package/dist/media-providers/dispatch/operation-runtime.js +93 -76
- package/dist/media-providers/dispatch/outbound.d.ts +31 -0
- package/dist/media-providers/dispatch/outbound.js +54 -0
- package/dist/media-providers/dispatch/polling-adapter.d.ts +26 -8
- package/dist/media-providers/dispatch/polling-adapter.js +2 -2
- package/dist/media-providers/dispatch/providers/aihubmix-shared.d.ts +2 -2
- package/dist/media-providers/dispatch/providers/aihubmix-shared.js +2 -2
- package/dist/media-providers/dispatch/providers/aihubmix.d.ts +13 -2
- package/dist/media-providers/dispatch/providers/aihubmix.js +18 -16
- package/dist/media-providers/dispatch/providers/custom-image.d.ts +16 -2
- package/dist/media-providers/dispatch/providers/custom-image.js +12 -9
- package/dist/media-providers/dispatch/providers/elevenlabs.d.ts +13 -2
- package/dist/media-providers/dispatch/providers/elevenlabs.js +16 -14
- package/dist/media-providers/dispatch/providers/fishaudio.d.ts +9 -1
- package/dist/media-providers/dispatch/providers/fishaudio.js +10 -8
- package/dist/media-providers/dispatch/providers/grok.d.ts +16 -3
- package/dist/media-providers/dispatch/providers/grok.js +19 -17
- package/dist/media-providers/dispatch/providers/imagerouter-video-async.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/imagerouter-video-async.js +23 -22
- package/dist/media-providers/dispatch/providers/imagerouter.d.ts +17 -3
- package/dist/media-providers/dispatch/providers/imagerouter.js +21 -19
- package/dist/media-providers/dispatch/providers/minimax.d.ts +9 -1
- package/dist/media-providers/dispatch/providers/minimax.js +9 -7
- package/dist/media-providers/dispatch/providers/nanobanana.d.ts +9 -1
- package/dist/media-providers/dispatch/providers/nanobanana.js +10 -8
- package/dist/media-providers/dispatch/providers/openai.d.ts +13 -2
- package/dist/media-providers/dispatch/providers/openai.js +23 -28
- package/dist/media-providers/dispatch/providers/openrouter.d.ts +12 -2
- package/dist/media-providers/dispatch/providers/openrouter.js +14 -12
- package/dist/media-providers/dispatch/providers/senseaudio.d.ts +13 -2
- package/dist/media-providers/dispatch/providers/senseaudio.js +16 -14
- package/dist/media-providers/dispatch/providers/volcengine.d.ts +9 -1
- package/dist/media-providers/dispatch/providers/volcengine.js +11 -9
- package/dist/media-providers/dispatch/response-parsers.d.ts +21 -7
- package/dist/media-providers/dispatch/response-parsers.js +15 -11
- package/dist/media-providers/dispatch/sqlite-async-operation-store.d.ts +3 -1
- package/dist/media-providers/dispatch/sqlite-async-operation-store.js +30 -28
- package/dist/media-providers/dispatch/ssrf-guard.d.ts +27 -14
- package/dist/media-providers/dispatch/ssrf-guard.js +46 -105
- package/dist/media-providers/dispatch/stub.d.ts +7 -2
- package/dist/media-providers/dispatch/stub.js +4 -3
- package/dist/media-providers/dispatch/types.d.ts +17 -13
- package/dist/media-providers/dispatch/vendor-adapter.d.ts +22 -5
- package/dist/media-providers/dispatch/vendor-adapter.js +13 -10
- package/dist/media-providers/dispatch/vendor-registry.d.ts +14 -11
- package/dist/media-providers/dispatch/vendor-registry.js +33 -4
- package/dist/media-providers/index.d.ts +1 -1
- package/dist/media-providers/index.js +1 -1
- package/dist/media-providers/policy.d.ts +3 -2
- package/dist/media-providers/policy.js +4 -2
- package/dist/media-providers/providers.d.ts +12 -4
- package/dist/media-providers/providers.js +3 -3
- package/dist/media-providers/staging.d.ts +8 -2
- package/dist/media-providers/staging.js +13 -4
- package/dist/media-providers/task-store.d.ts +2 -2
- package/dist/media-providers/task-store.js +2 -2
- package/dist/media-providers/tokens.js +3 -3
- package/dist/media-providers/types.d.ts +4 -4
- package/dist/media-providers/types.js +1 -1
- package/dist/media-providers/video-request.d.ts +35 -15
- package/dist/media-providers/video-request.js +15 -15
- package/dist/webhooks/delivery.d.ts +76 -0
- package/dist/webhooks/delivery.js +222 -0
- package/dist/webhooks/index.d.ts +7 -0
- package/dist/webhooks/index.js +7 -0
- package/dist/webhooks/ports.d.ts +113 -0
- package/dist/webhooks/ports.js +2 -0
- package/dist/webhooks/signing.d.ts +38 -0
- package/dist/webhooks/signing.js +83 -0
- package/dist/webhooks/signing.keyring.d.ts +8 -0
- package/dist/webhooks/signing.keyring.js +18 -0
- package/dist/webhooks/subscriptions.d.ts +78 -0
- package/dist/webhooks/subscriptions.js +139 -0
- package/dist/webhooks/types.d.ts +103 -0
- package/dist/webhooks/types.js +2 -0
- package/package.json +36 -22
- package/dist/composio/bounded-data.d.ts.map +0 -1
- package/dist/composio/bounded-data.js.map +0 -1
- package/dist/composio/catalog.d.ts.map +0 -1
- package/dist/composio/catalog.js.map +0 -1
- package/dist/composio/composio-config.d.ts.map +0 -1
- package/dist/composio/composio-config.js.map +0 -1
- package/dist/composio/composio-descriptions.d.ts.map +0 -1
- package/dist/composio/composio-descriptions.js.map +0 -1
- package/dist/composio/composio.d.ts.map +0 -1
- package/dist/composio/composio.js.map +0 -1
- package/dist/composio/errors.d.ts.map +0 -1
- package/dist/composio/errors.js.map +0 -1
- package/dist/composio/file-lock.d.ts.map +0 -1
- package/dist/composio/file-lock.js.map +0 -1
- package/dist/composio/index.d.ts.map +0 -1
- package/dist/composio/index.js.map +0 -1
- package/dist/composio/json-schema.d.ts.map +0 -1
- package/dist/composio/json-schema.js.map +0 -1
- package/dist/composio/output-protection.d.ts.map +0 -1
- package/dist/composio/output-protection.js.map +0 -1
- package/dist/composio/service.d.ts.map +0 -1
- package/dist/composio/service.js.map +0 -1
- package/dist/media-providers/capability-registry.d.ts.map +0 -1
- package/dist/media-providers/capability-registry.js.map +0 -1
- package/dist/media-providers/catalog.d.ts.map +0 -1
- package/dist/media-providers/catalog.js.map +0 -1
- package/dist/media-providers/dispatch/async-operation-store.d.ts.map +0 -1
- package/dist/media-providers/dispatch/async-operation-store.js.map +0 -1
- package/dist/media-providers/dispatch/context.d.ts.map +0 -1
- package/dist/media-providers/dispatch/context.js.map +0 -1
- package/dist/media-providers/dispatch/credentials.d.ts.map +0 -1
- package/dist/media-providers/dispatch/credentials.js.map +0 -1
- package/dist/media-providers/dispatch/engine.d.ts.map +0 -1
- package/dist/media-providers/dispatch/engine.js.map +0 -1
- package/dist/media-providers/dispatch/index.d.ts.map +0 -1
- package/dist/media-providers/dispatch/index.js.map +0 -1
- package/dist/media-providers/dispatch/openai-compatible.d.ts.map +0 -1
- package/dist/media-providers/dispatch/openai-compatible.js.map +0 -1
- package/dist/media-providers/dispatch/operation-runtime.d.ts.map +0 -1
- package/dist/media-providers/dispatch/operation-runtime.js.map +0 -1
- package/dist/media-providers/dispatch/polling-adapter.d.ts.map +0 -1
- package/dist/media-providers/dispatch/polling-adapter.js.map +0 -1
- package/dist/media-providers/dispatch/providers/aihubmix-shared.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/aihubmix-shared.js.map +0 -1
- package/dist/media-providers/dispatch/providers/aihubmix.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/aihubmix.js.map +0 -1
- package/dist/media-providers/dispatch/providers/custom-image.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/custom-image.js.map +0 -1
- package/dist/media-providers/dispatch/providers/elevenlabs.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/elevenlabs.js.map +0 -1
- package/dist/media-providers/dispatch/providers/fishaudio.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/fishaudio.js.map +0 -1
- package/dist/media-providers/dispatch/providers/grok.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/grok.js.map +0 -1
- package/dist/media-providers/dispatch/providers/imagerouter-video-async.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/imagerouter-video-async.js.map +0 -1
- package/dist/media-providers/dispatch/providers/imagerouter.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/imagerouter.js.map +0 -1
- package/dist/media-providers/dispatch/providers/minimax.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/minimax.js.map +0 -1
- package/dist/media-providers/dispatch/providers/nanobanana.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/nanobanana.js.map +0 -1
- package/dist/media-providers/dispatch/providers/openai.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/openai.js.map +0 -1
- package/dist/media-providers/dispatch/providers/openrouter.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/openrouter.js.map +0 -1
- package/dist/media-providers/dispatch/providers/senseaudio.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/senseaudio.js.map +0 -1
- package/dist/media-providers/dispatch/providers/volcengine.d.ts.map +0 -1
- package/dist/media-providers/dispatch/providers/volcengine.js.map +0 -1
- package/dist/media-providers/dispatch/response-parsers.d.ts.map +0 -1
- package/dist/media-providers/dispatch/response-parsers.js.map +0 -1
- package/dist/media-providers/dispatch/sqlite-async-operation-store.d.ts.map +0 -1
- package/dist/media-providers/dispatch/sqlite-async-operation-store.js.map +0 -1
- package/dist/media-providers/dispatch/ssrf-guard.d.ts.map +0 -1
- package/dist/media-providers/dispatch/ssrf-guard.js.map +0 -1
- package/dist/media-providers/dispatch/stub.d.ts.map +0 -1
- package/dist/media-providers/dispatch/stub.js.map +0 -1
- package/dist/media-providers/dispatch/types.d.ts.map +0 -1
- package/dist/media-providers/dispatch/types.js.map +0 -1
- package/dist/media-providers/dispatch/vendor-adapter.d.ts.map +0 -1
- package/dist/media-providers/dispatch/vendor-adapter.js.map +0 -1
- package/dist/media-providers/dispatch/vendor-registry.d.ts.map +0 -1
- package/dist/media-providers/dispatch/vendor-registry.js.map +0 -1
- package/dist/media-providers/index.d.ts.map +0 -1
- package/dist/media-providers/index.js.map +0 -1
- package/dist/media-providers/policy.d.ts.map +0 -1
- package/dist/media-providers/policy.js.map +0 -1
- package/dist/media-providers/providers.d.ts.map +0 -1
- package/dist/media-providers/providers.js.map +0 -1
- package/dist/media-providers/seed.d.ts.map +0 -1
- package/dist/media-providers/seed.js.map +0 -1
- package/dist/media-providers/sqlite-task-store.d.ts.map +0 -1
- package/dist/media-providers/sqlite-task-store.js.map +0 -1
- package/dist/media-providers/staging.d.ts.map +0 -1
- package/dist/media-providers/staging.js.map +0 -1
- package/dist/media-providers/task-store.d.ts.map +0 -1
- package/dist/media-providers/task-store.js.map +0 -1
- package/dist/media-providers/tokens.d.ts.map +0 -1
- package/dist/media-providers/tokens.js.map +0 -1
- package/dist/media-providers/types.d.ts.map +0 -1
- package/dist/media-providers/types.js.map +0 -1
- package/dist/media-providers/video-request.d.ts.map +0 -1
- package/dist/media-providers/video-request.js.map +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `/v1/images/generations` + `/v1/images/edits` endpoint. Ported
|
|
4
4
|
* near-verbatim from Open Design's `apps/daemon/src/media/index.ts`
|
|
5
5
|
* `renderCustomOpenAIImage`/`customImageOverridesOpenAIModel` — see
|
|
6
|
-
* `
|
|
6
|
+
* `archived provenance ledger`.
|
|
7
7
|
*
|
|
8
8
|
* 2026-07-21: migrated onto the generic vendor-adapter dispatch engine
|
|
9
9
|
* (`vendor-adapter.ts`/`vendor-registry.ts`). External behavior is
|
|
@@ -28,10 +28,9 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import { buildOpenAIImageEditUrl, buildOpenAIImageUrl, bytesFromOpenAICompatibleData, openaiSizeFor, parseOpenAICompatibleJson, sniffImageExt, withRequestInit } from '../openai-compatible.js';
|
|
30
30
|
import { dispatchVendorRequest } from '../vendor-adapter.js';
|
|
31
|
-
import { mediaVendorRegistry } from '../vendor-registry.js';
|
|
32
31
|
export const CUSTOM_IMAGE_MODEL_ID = 'custom-image';
|
|
33
32
|
const customImageAdapter = {
|
|
34
|
-
buildRequest(ctx, credentials) {
|
|
33
|
+
buildRequest({ ctx, credentials }) {
|
|
35
34
|
const baseUrl = (credentials.baseUrl || '').trim();
|
|
36
35
|
if (!baseUrl) {
|
|
37
36
|
throw new Error('Custom Image API base URL required — configure an OpenAI-compatible /v1/images/generations or /v1/images/edits endpoint');
|
|
@@ -69,9 +68,9 @@ const customImageAdapter = {
|
|
|
69
68
|
meta: { wireModel, size },
|
|
70
69
|
};
|
|
71
70
|
},
|
|
72
|
-
async parseResponse(resp, ctx, request) {
|
|
71
|
+
async parseResponse({ resp, ctx, request }) {
|
|
73
72
|
const data = await parseOpenAICompatibleJson(resp, 'custom image');
|
|
74
|
-
const bytes = await bytesFromOpenAICompatibleData(data, 'custom image', ctx
|
|
73
|
+
const bytes = await bytesFromOpenAICompatibleData({ data, providerTag: 'custom image' }, ctx);
|
|
75
74
|
return {
|
|
76
75
|
bytes,
|
|
77
76
|
providerNote: `custom-image/${request.meta.wireModel} · ${request.meta.size} · ${bytes.length} bytes`,
|
|
@@ -79,16 +78,20 @@ const customImageAdapter = {
|
|
|
79
78
|
};
|
|
80
79
|
},
|
|
81
80
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return dispatchVendorRequest(customImageAdapter, ctx, credentials);
|
|
81
|
+
export async function renderCustomOpenAIImage({ ctx, credentials }) {
|
|
82
|
+
return dispatchVendorRequest({ adapter: customImageAdapter, ctx: ctx, credentials: credentials });
|
|
85
83
|
}
|
|
86
84
|
/** Whether the caller's `custom-image` credentials should override an `openai`-provider request (same model configured on both). */
|
|
87
|
-
export function customImageOverridesOpenAIModel(
|
|
85
|
+
export function customImageOverridesOpenAIModel(required) {
|
|
86
|
+
const { ctx, credentials } = required;
|
|
88
87
|
const baseUrl = credentials?.baseUrl?.trim();
|
|
89
88
|
const model = credentials?.model?.trim();
|
|
90
89
|
if (!baseUrl || !model)
|
|
91
90
|
return false;
|
|
92
91
|
return model === ctx.model || model === ctx.wireModel;
|
|
93
92
|
}
|
|
93
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
94
|
+
export function registerVendorAdapters({ registry }, _optional = {}) {
|
|
95
|
+
registry.register({ providerId: 'custom-image', routeKey: 'image', adapter: customImageAdapter });
|
|
96
|
+
}
|
|
94
97
|
//# sourceMappingURL=custom-image.js.map
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
2
|
+
import type { VendorAdapterRegistry } from '../vendor-registry.js';
|
|
3
|
+
export declare function renderElevenLabsTTS({ ctx, credentials }: {
|
|
4
|
+
ctx: RenderContext;
|
|
5
|
+
credentials: ProviderCredentials;
|
|
6
|
+
}): Promise<RenderResult>;
|
|
7
|
+
export declare function renderElevenLabsSfx({ ctx, credentials }: {
|
|
8
|
+
ctx: RenderContext;
|
|
9
|
+
credentials: ProviderCredentials;
|
|
10
|
+
}): Promise<RenderResult>;
|
|
11
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
12
|
+
export declare function registerVendorAdapters({ registry }: {
|
|
13
|
+
registry: Pick<VendorAdapterRegistry, 'register'>;
|
|
14
|
+
}, _optional?: Record<string, never>): void;
|
|
4
15
|
//# sourceMappingURL=elevenlabs.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Provider: ElevenLabs — v3 text-to-speech (`renderElevenLabsTTS`) and
|
|
3
3
|
* text-to-sound-effect (`renderElevenLabsSfx`), both synchronous. Ported
|
|
4
4
|
* near-verbatim from Open Design's `apps/daemon/src/media/index.ts`
|
|
5
|
-
* `renderElevenLabsTTS`/`renderElevenLabsSfx` — see `
|
|
5
|
+
* `renderElevenLabsTTS`/`renderElevenLabsSfx` — see `archived provenance ledger`.
|
|
6
6
|
*
|
|
7
7
|
* Neither endpoint returns the OpenAI-images/audio wire shape (both are
|
|
8
8
|
* ElevenLabs-specific JSON-body-in, raw-audio-bytes-out POSTs), so this
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
import { withRequestInit } from '../openai-compatible.js';
|
|
41
41
|
import { createRawBytesParser } from '../response-parsers.js';
|
|
42
42
|
import { dispatchVendorRequest, requireApiKey } from '../vendor-adapter.js';
|
|
43
|
-
import { mediaVendorRegistry } from '../vendor-registry.js';
|
|
44
43
|
const ELEVENLABS_DEFAULT_BASE_URL = 'https://api.elevenlabs.io';
|
|
45
44
|
const ELEVENLABS_DEFAULT_VOICE_ID = '21m00Tcm4TlvDq8ikWAM';
|
|
46
45
|
const ELEVENLABS_TTS_MODEL_MAP = {
|
|
@@ -77,8 +76,8 @@ function assertElevenLabsSfxPromptLength(text) {
|
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
const elevenLabsTTSAdapter = {
|
|
80
|
-
requireCredential: requireApiKey(NO_CREDENTIAL_MESSAGE),
|
|
81
|
-
buildRequest(ctx, credentials) {
|
|
79
|
+
requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
|
|
80
|
+
buildRequest({ ctx, credentials }) {
|
|
82
81
|
const apiKey = credentials.apiKey; // requireCredential already validated this.
|
|
83
82
|
const baseUrl = (credentials.baseUrl || ELEVENLABS_DEFAULT_BASE_URL).replace(/\/$/, '');
|
|
84
83
|
const wireModel = ELEVENLABS_TTS_MODEL_MAP[ctx.model] || ctx.model;
|
|
@@ -111,17 +110,16 @@ const elevenLabsTTSAdapter = {
|
|
|
111
110
|
parseResponse: createRawBytesParser({
|
|
112
111
|
errorTag: 'elevenlabs tts',
|
|
113
112
|
zeroBytesMessage: 'elevenlabs tts returned zero bytes',
|
|
114
|
-
note: (bytes, meta) => `elevenlabs/${meta.wireModel} · ${meta.voiceId} · ${bytes.length} bytes`,
|
|
113
|
+
note: ({ bytes, meta }) => `elevenlabs/${meta.wireModel} · ${meta.voiceId} · ${bytes.length} bytes`,
|
|
115
114
|
suggestedExt: '.mp3',
|
|
116
115
|
}),
|
|
117
116
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return dispatchVendorRequest(elevenLabsTTSAdapter, ctx, credentials);
|
|
117
|
+
export async function renderElevenLabsTTS({ ctx, credentials }) {
|
|
118
|
+
return dispatchVendorRequest({ adapter: elevenLabsTTSAdapter, ctx: ctx, credentials: credentials });
|
|
121
119
|
}
|
|
122
120
|
const elevenLabsSfxAdapter = {
|
|
123
|
-
requireCredential: requireApiKey(NO_CREDENTIAL_MESSAGE),
|
|
124
|
-
buildRequest(ctx, credentials) {
|
|
121
|
+
requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
|
|
122
|
+
buildRequest({ ctx, credentials }) {
|
|
125
123
|
const apiKey = credentials.apiKey; // requireCredential already validated this.
|
|
126
124
|
const baseUrl = (credentials.baseUrl || ELEVENLABS_DEFAULT_BASE_URL).replace(/\/$/, '');
|
|
127
125
|
const wireModel = ELEVENLABS_SFX_MODEL_MAP[ctx.model] || ctx.model;
|
|
@@ -152,12 +150,16 @@ const elevenLabsSfxAdapter = {
|
|
|
152
150
|
parseResponse: createRawBytesParser({
|
|
153
151
|
errorTag: 'elevenlabs sfx',
|
|
154
152
|
zeroBytesMessage: 'elevenlabs sfx returned zero bytes',
|
|
155
|
-
note: (bytes, meta) => `elevenlabs/${meta.wireModel} · ${meta.durationSeconds}s${meta.loop ? ' · loop' : ''} · ${bytes.length} bytes`,
|
|
153
|
+
note: ({ bytes, meta }) => `elevenlabs/${meta.wireModel} · ${meta.durationSeconds}s${meta.loop ? ' · loop' : ''} · ${bytes.length} bytes`,
|
|
156
154
|
suggestedExt: '.mp3',
|
|
157
155
|
}),
|
|
158
156
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
export async function renderElevenLabsSfx({ ctx, credentials }) {
|
|
158
|
+
return dispatchVendorRequest({ adapter: elevenLabsSfxAdapter, ctx: ctx, credentials: credentials });
|
|
159
|
+
}
|
|
160
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
161
|
+
export function registerVendorAdapters({ registry }, _optional = {}) {
|
|
162
|
+
registry.register({ providerId: 'elevenlabs', routeKey: 'audio:speech', adapter: elevenLabsTTSAdapter });
|
|
163
|
+
registry.register({ providerId: 'elevenlabs', routeKey: 'audio:sfx', adapter: elevenLabsSfxAdapter });
|
|
162
164
|
}
|
|
163
165
|
//# sourceMappingURL=elevenlabs.js.map
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
|
|
2
|
-
|
|
2
|
+
import type { VendorAdapterRegistry } from '../vendor-registry.js';
|
|
3
|
+
export declare function renderFishAudioTTS({ ctx, credentials }: {
|
|
4
|
+
ctx: RenderContext;
|
|
5
|
+
credentials: ProviderCredentials;
|
|
6
|
+
}): Promise<RenderResult>;
|
|
7
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
8
|
+
export declare function registerVendorAdapters({ registry }: {
|
|
9
|
+
registry: Pick<VendorAdapterRegistry, 'register'>;
|
|
10
|
+
}, _optional?: Record<string, never>): void;
|
|
3
11
|
//# sourceMappingURL=fishaudio.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Provider: FishAudio — Speech-1.x family text-to-speech (synchronous,
|
|
3
3
|
* `POST /v1/tts`). Ported near-verbatim from Open Design's
|
|
4
4
|
* `apps/daemon/src/media/index.ts` `renderFishAudioTTS` — see
|
|
5
|
-
* `
|
|
5
|
+
* `archived provenance ledger`.
|
|
6
6
|
*
|
|
7
7
|
* 2026-07-21: migrated onto the generic vendor-adapter dispatch engine
|
|
8
8
|
* (`vendor-adapter.ts`/`vendor-registry.ts`). External behavior (URL,
|
|
@@ -25,15 +25,14 @@
|
|
|
25
25
|
import { withRequestInit } from '../openai-compatible.js';
|
|
26
26
|
import { createRawBytesParser } from '../response-parsers.js';
|
|
27
27
|
import { dispatchVendorRequest, requireApiKey } from '../vendor-adapter.js';
|
|
28
|
-
import { mediaVendorRegistry } from '../vendor-registry.js';
|
|
29
28
|
const FISHAUDIO_DEFAULT_BASE_URL = 'https://api.fish.audio';
|
|
30
29
|
const FISHAUDIO_TTS_MODEL_MAP = {
|
|
31
30
|
'fish-speech-2': 'speech-1.6',
|
|
32
31
|
};
|
|
33
32
|
const NO_CREDENTIAL_MESSAGE = 'no FishAudio credential — configure an API key or set FISH_AUDIO_API_KEY.';
|
|
34
33
|
const fishAudioTTSAdapter = {
|
|
35
|
-
requireCredential: requireApiKey(NO_CREDENTIAL_MESSAGE),
|
|
36
|
-
buildRequest(ctx, credentials) {
|
|
34
|
+
requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
|
|
35
|
+
buildRequest({ ctx, credentials }) {
|
|
37
36
|
const apiKey = credentials.apiKey; // requireCredential already validated this.
|
|
38
37
|
const baseUrl = (credentials.baseUrl || FISHAUDIO_DEFAULT_BASE_URL).replace(/\/$/, '');
|
|
39
38
|
// Same precedence as minimax.ts's renderMinimaxTTS: an explicit caller
|
|
@@ -72,12 +71,15 @@ const fishAudioTTSAdapter = {
|
|
|
72
71
|
parseResponse: createRawBytesParser({
|
|
73
72
|
errorTag: 'fishaudio tts',
|
|
74
73
|
zeroBytesMessage: 'fishaudio tts returned zero bytes',
|
|
75
|
-
note: (bytes, meta) => `fishaudio/${meta.wireModel} · ${bytes.length} bytes`,
|
|
74
|
+
note: ({ bytes, meta }) => `fishaudio/${meta.wireModel} · ${bytes.length} bytes`,
|
|
76
75
|
suggestedExt: '.mp3',
|
|
77
76
|
}),
|
|
78
77
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
export async function renderFishAudioTTS({ ctx, credentials }) {
|
|
79
|
+
return dispatchVendorRequest({ adapter: fishAudioTTSAdapter, ctx: ctx, credentials: credentials });
|
|
80
|
+
}
|
|
81
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
82
|
+
export function registerVendorAdapters({ registry }, _optional = {}) {
|
|
83
|
+
registry.register({ providerId: 'fishaudio', routeKey: 'audio:speech', adapter: fishAudioTTSAdapter });
|
|
82
84
|
}
|
|
83
85
|
//# sourceMappingURL=fishaudio.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
|
|
2
|
+
import type { VendorAdapterRegistry } from '../vendor-registry.js';
|
|
2
3
|
/**
|
|
3
4
|
* xAI's Imagine API accepts a wide list of aspect ratios (1:1, 16:9, 9:16,
|
|
4
5
|
* 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 19.5:9, 9:19.5, 20:9, 9:20, auto) —
|
|
@@ -9,7 +10,19 @@ import type { ProviderCredentials, RenderContext, RenderResult } from '../types.
|
|
|
9
10
|
* (see `imagerouter.ts`'s `imageRouterSizeFor`) — same input -> output
|
|
10
11
|
* mapping for every case, not a behavior change.
|
|
11
12
|
*/
|
|
12
|
-
export declare function grokAspectFor(aspect
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export declare function grokAspectFor({ aspect }: {
|
|
14
|
+
aspect: string | undefined;
|
|
15
|
+
}): string;
|
|
16
|
+
export declare function renderGrokImage({ ctx, credentials }: {
|
|
17
|
+
ctx: RenderContext;
|
|
18
|
+
credentials: ProviderCredentials;
|
|
19
|
+
}): Promise<RenderResult>;
|
|
20
|
+
export declare function renderXAITTS({ ctx, credentials }: {
|
|
21
|
+
ctx: RenderContext;
|
|
22
|
+
credentials: ProviderCredentials;
|
|
23
|
+
}): Promise<RenderResult>;
|
|
24
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
25
|
+
export declare function registerVendorAdapters({ registry }: {
|
|
26
|
+
registry: Pick<VendorAdapterRegistry, 'register'>;
|
|
27
|
+
}, _optional?: Record<string, never>): void;
|
|
15
28
|
//# sourceMappingURL=grok.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `/images/generations` endpoint (`renderGrokImage`), plus text-to-speech
|
|
4
4
|
* via a dedicated `/tts` endpoint (`renderXAITTS`). Ported near-verbatim
|
|
5
5
|
* from Open Design's `apps/daemon/src/media/index.ts` `renderGrokImage`/
|
|
6
|
-
* `renderXAITTS` — see `
|
|
6
|
+
* `renderXAITTS` — see `archived provenance ledger`.
|
|
7
7
|
*
|
|
8
8
|
* Image response shape (`{ data: [{ b64_json | url }] }`) is identical to
|
|
9
9
|
* OpenAI's images API, so `renderGrokImage` routes through
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
import { buildOpenAIImageUrl, bytesFromOpenAICompatibleData, parseOpenAICompatibleJson, sniffImageExt, withRequestInit } from '../openai-compatible.js';
|
|
40
40
|
import { createRawBytesParser } from '../response-parsers.js';
|
|
41
41
|
import { dispatchVendorRequest, requireApiKey } from '../vendor-adapter.js';
|
|
42
|
-
import { mediaVendorRegistry } from '../vendor-registry.js';
|
|
43
42
|
/**
|
|
44
43
|
* xAI's Imagine API accepts a wide list of aspect ratios (1:1, 16:9, 9:16,
|
|
45
44
|
* 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 19.5:9, 9:19.5, 20:9, 9:20, auto) —
|
|
@@ -50,7 +49,7 @@ import { mediaVendorRegistry } from '../vendor-registry.js';
|
|
|
50
49
|
* (see `imagerouter.ts`'s `imageRouterSizeFor`) — same input -> output
|
|
51
50
|
* mapping for every case, not a behavior change.
|
|
52
51
|
*/
|
|
53
|
-
export function grokAspectFor(aspect) {
|
|
52
|
+
export function grokAspectFor({ aspect }) {
|
|
54
53
|
if (aspect === '1:1')
|
|
55
54
|
return '1:1';
|
|
56
55
|
if (aspect === '16:9')
|
|
@@ -65,11 +64,11 @@ export function grokAspectFor(aspect) {
|
|
|
65
64
|
}
|
|
66
65
|
const NO_CREDENTIAL_MESSAGE = 'no xAI credential — configure an API key or set XAI_API_KEY.';
|
|
67
66
|
const grokImageAdapter = {
|
|
68
|
-
requireCredential: requireApiKey(NO_CREDENTIAL_MESSAGE),
|
|
69
|
-
buildRequest(ctx, credentials) {
|
|
67
|
+
requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
|
|
68
|
+
buildRequest({ ctx, credentials }) {
|
|
70
69
|
const apiKey = credentials.apiKey; // requireCredential already validated this.
|
|
71
70
|
const baseUrl = (credentials.baseUrl || 'https://api.x.ai/v1').replace(/\/$/, '');
|
|
72
|
-
const aspectRatio = grokAspectFor(ctx.aspect);
|
|
71
|
+
const aspectRatio = grokAspectFor({ aspect: ctx.aspect });
|
|
73
72
|
const body = {
|
|
74
73
|
model: ctx.wireModel,
|
|
75
74
|
prompt: ctx.prompt || 'A high-quality reference image.',
|
|
@@ -90,9 +89,9 @@ const grokImageAdapter = {
|
|
|
90
89
|
meta: { wireModel: ctx.wireModel, aspectRatio },
|
|
91
90
|
};
|
|
92
91
|
},
|
|
93
|
-
async parseResponse(resp, ctx, request) {
|
|
92
|
+
async parseResponse({ resp, ctx, request }) {
|
|
94
93
|
const data = await parseOpenAICompatibleJson(resp, 'grok image');
|
|
95
|
-
const bytes = await bytesFromOpenAICompatibleData(data, 'grok image', ctx
|
|
94
|
+
const bytes = await bytesFromOpenAICompatibleData({ data, providerTag: 'grok image' }, ctx);
|
|
96
95
|
return {
|
|
97
96
|
bytes,
|
|
98
97
|
providerNote: `grok/${request.meta.wireModel} · ${request.meta.aspectRatio} · ${bytes.length} bytes`,
|
|
@@ -100,9 +99,8 @@ const grokImageAdapter = {
|
|
|
100
99
|
};
|
|
101
100
|
},
|
|
102
101
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return dispatchVendorRequest(grokImageAdapter, ctx, credentials);
|
|
102
|
+
export async function renderGrokImage({ ctx, credentials }) {
|
|
103
|
+
return dispatchVendorRequest({ adapter: grokImageAdapter, ctx: ctx, credentials: credentials });
|
|
106
104
|
}
|
|
107
105
|
const XAI_TTS_DEFAULT_VOICE_ID = 'eve';
|
|
108
106
|
const XAI_TTS_DEFAULT_LANGUAGE = 'en';
|
|
@@ -115,8 +113,8 @@ const XAI_TTS_DEFAULT_LANGUAGE = 'en';
|
|
|
115
113
|
* set it with.
|
|
116
114
|
*/
|
|
117
115
|
const xaiTTSAdapter = {
|
|
118
|
-
requireCredential: requireApiKey(NO_CREDENTIAL_MESSAGE),
|
|
119
|
-
buildRequest(ctx, credentials) {
|
|
116
|
+
requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
|
|
117
|
+
buildRequest({ ctx, credentials }) {
|
|
120
118
|
const apiKey = credentials.apiKey; // requireCredential already validated this.
|
|
121
119
|
const baseUrl = (credentials.baseUrl || 'https://api.x.ai/v1').replace(/\/$/, '');
|
|
122
120
|
const text = (ctx.prompt && ctx.prompt.trim()) || 'This is a test.';
|
|
@@ -139,12 +137,16 @@ const xaiTTSAdapter = {
|
|
|
139
137
|
parseResponse: createRawBytesParser({
|
|
140
138
|
errorTag: 'xai tts',
|
|
141
139
|
zeroBytesMessage: 'xai tts response had zero bytes',
|
|
142
|
-
note: (bytes, meta) => `xai/${meta.wireModel} · voice=${meta.voiceId} · ${meta.language} · ${bytes.length} bytes`,
|
|
140
|
+
note: ({ bytes, meta }) => `xai/${meta.wireModel} · voice=${meta.voiceId} · ${meta.language} · ${bytes.length} bytes`,
|
|
143
141
|
suggestedExt: '.mp3',
|
|
144
142
|
}),
|
|
145
143
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
export async function renderXAITTS({ ctx, credentials }) {
|
|
145
|
+
return dispatchVendorRequest({ adapter: xaiTTSAdapter, ctx: ctx, credentials: credentials });
|
|
146
|
+
}
|
|
147
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
148
|
+
export function registerVendorAdapters({ registry }, _optional = {}) {
|
|
149
|
+
registry.register({ providerId: 'grok', routeKey: 'image', adapter: grokImageAdapter });
|
|
150
|
+
registry.register({ providerId: 'grok', routeKey: 'audio:speech', adapter: xaiTTSAdapter });
|
|
149
151
|
}
|
|
150
152
|
//# sourceMappingURL=grok.js.map
|
|
@@ -17,5 +17,5 @@ export interface ImageRouterVideoMeta {
|
|
|
17
17
|
* context's own `wireModel`.
|
|
18
18
|
* @complexity O(1) per built request; one vendor round trip per parse.
|
|
19
19
|
*/
|
|
20
|
-
export declare function createImageRouterVideoPollingAdapter(
|
|
20
|
+
export declare function createImageRouterVideoPollingAdapter(_required: Record<string, never>, optional?: ImageRouterVideoConfig): PollingVendorAdapter<ImageRouterVideoMeta>;
|
|
21
21
|
//# sourceMappingURL=imagerouter-video-async.d.ts.map
|
|
@@ -52,37 +52,38 @@ function retryAfterMsFrom(resp) {
|
|
|
52
52
|
* context's own `wireModel`.
|
|
53
53
|
* @complexity O(1) per built request; one vendor round trip per parse.
|
|
54
54
|
*/
|
|
55
|
-
export function createImageRouterVideoPollingAdapter(
|
|
55
|
+
export function createImageRouterVideoPollingAdapter(_required, optional = {}) {
|
|
56
|
+
const config = optional;
|
|
56
57
|
const baseUrl = trimTrailingSlash((config.baseUrl || DEFAULT_BASE_URL).trim());
|
|
57
58
|
return {
|
|
58
59
|
expectedLatencyClass: 'slow',
|
|
59
60
|
// ImageRouter's generation endpoint accepts no idempotency key, so a submit that may or may
|
|
60
61
|
// not have landed cannot be safely re-issued — a duplicate submit is a duplicate charge.
|
|
61
62
|
submitIsIdempotent: false,
|
|
62
|
-
buildSubmitRequest(ctx) {
|
|
63
|
+
buildSubmitRequest({ ctx }) {
|
|
63
64
|
const wireModel = (config.wireModel || ctx.wireModel).trim();
|
|
64
65
|
const seconds = typeof ctx.length === 'number' ? ctx.length : 'auto';
|
|
65
|
-
const size = imageRouterSizeFor(ctx.aspect, 'video');
|
|
66
|
+
const size = imageRouterSizeFor({ aspect: ctx.aspect, surface: 'video' });
|
|
66
67
|
return {
|
|
67
68
|
url: `${baseUrl}/videos/generations`,
|
|
68
|
-
init: withUnsignedRequestInit(ctx, {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
init: withUnsignedRequestInit({ ctx: ctx, init: {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'content-type': 'application/json' },
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
prompt: ctx.prompt || 'A short cinematic clip.',
|
|
74
|
+
model: wireModel,
|
|
75
|
+
size,
|
|
76
|
+
seconds,
|
|
77
|
+
response_format: 'b64_json',
|
|
78
|
+
}),
|
|
79
|
+
} }),
|
|
79
80
|
meta: { wireModel, size, seconds },
|
|
80
81
|
};
|
|
81
82
|
},
|
|
82
|
-
async parseSubmitResponse(resp, ctx, request) {
|
|
83
|
+
async parseSubmitResponse({ resp, ctx, request }) {
|
|
83
84
|
const data = (await parseOpenAICompatibleJson(resp, 'imagerouter video'));
|
|
84
85
|
if (Array.isArray(data.data)) {
|
|
85
|
-
const bytes = await bytesFromOpenAICompatibleData(data, 'imagerouter video', ctx
|
|
86
|
+
const bytes = await bytesFromOpenAICompatibleData({ data, providerTag: 'imagerouter video' }, ctx);
|
|
86
87
|
const { wireModel, size, seconds } = request.meta;
|
|
87
88
|
return {
|
|
88
89
|
kind: 'complete',
|
|
@@ -100,18 +101,18 @@ export function createImageRouterVideoPollingAdapter(config = {}) {
|
|
|
100
101
|
}
|
|
101
102
|
throw new Error('imagerouter video submit returned neither generated data nor a job id');
|
|
102
103
|
},
|
|
103
|
-
buildPollRequest(state, ctx) {
|
|
104
|
+
buildPollRequest({ state, ctx }) {
|
|
104
105
|
const jobId = state.jobId;
|
|
105
106
|
if (typeof jobId !== 'string' || !jobId) {
|
|
106
107
|
throw new Error('imagerouter video poll requires a persisted jobId');
|
|
107
108
|
}
|
|
108
109
|
return {
|
|
109
110
|
url: `${baseUrl}/videos/${encodeURIComponent(jobId)}`,
|
|
110
|
-
init: withUnsignedRequestInit(ctx, { method: 'GET', headers: { accept: 'application/json' } }),
|
|
111
|
-
meta: { wireModel: (config.wireModel || ctx.wireModel).trim(), size: imageRouterSizeFor(ctx.aspect, 'video'), seconds: typeof ctx.length === 'number' ? ctx.length : 'auto' },
|
|
111
|
+
init: withUnsignedRequestInit({ ctx: ctx, init: { method: 'GET', headers: { accept: 'application/json' } } }),
|
|
112
|
+
meta: { wireModel: (config.wireModel || ctx.wireModel).trim(), size: imageRouterSizeFor({ aspect: ctx.aspect, surface: 'video' }), seconds: typeof ctx.length === 'number' ? ctx.length : 'auto' },
|
|
112
113
|
};
|
|
113
114
|
},
|
|
114
|
-
async parsePollResponse(resp, ctx, _state) {
|
|
115
|
+
async parsePollResponse({ resp, ctx, state: _state }) {
|
|
115
116
|
const data = (await parseOpenAICompatibleJson(resp, 'imagerouter video'));
|
|
116
117
|
const status = typeof data.status === 'string' ? data.status.toLowerCase() : '';
|
|
117
118
|
if (TERMINAL_FAILED_STATUSES.has(status)) {
|
|
@@ -120,9 +121,9 @@ export function createImageRouterVideoPollingAdapter(config = {}) {
|
|
|
120
121
|
return { kind: 'failed', message: `imagerouter video job failed: ${detail}` };
|
|
121
122
|
}
|
|
122
123
|
if (Array.isArray(data.data)) {
|
|
123
|
-
const bytes = await bytesFromOpenAICompatibleData(data, 'imagerouter video', ctx
|
|
124
|
+
const bytes = await bytesFromOpenAICompatibleData({ data, providerTag: 'imagerouter video' }, ctx);
|
|
124
125
|
const wireModel = (config.wireModel || ctx.wireModel).trim();
|
|
125
|
-
const size = imageRouterSizeFor(ctx.aspect, 'video');
|
|
126
|
+
const size = imageRouterSizeFor({ aspect: ctx.aspect, surface: 'video' });
|
|
126
127
|
const seconds = typeof ctx.length === 'number' ? ctx.length : 'auto';
|
|
127
128
|
return {
|
|
128
129
|
kind: 'complete',
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
|
|
2
|
+
import type { VendorAdapterRegistry } from '../vendor-registry.js';
|
|
2
3
|
/** ImageRouter's image/video generation `size` string for a given aspect ratio. */
|
|
3
|
-
export declare function imageRouterSizeFor(aspect
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export declare function imageRouterSizeFor({ aspect, surface }: {
|
|
5
|
+
aspect: string | undefined;
|
|
6
|
+
surface: 'image' | 'video';
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function renderImageRouterImage({ ctx, credentials }: {
|
|
9
|
+
ctx: RenderContext;
|
|
10
|
+
credentials: ProviderCredentials;
|
|
11
|
+
}): Promise<RenderResult>;
|
|
12
|
+
export declare function renderImageRouterVideo({ ctx, credentials }: {
|
|
13
|
+
ctx: RenderContext;
|
|
14
|
+
credentials: ProviderCredentials;
|
|
15
|
+
}): Promise<RenderResult>;
|
|
16
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
17
|
+
export declare function registerVendorAdapters({ registry }: {
|
|
18
|
+
registry: Pick<VendorAdapterRegistry, 'register'>;
|
|
19
|
+
}, _optional?: Record<string, never>): void;
|
|
6
20
|
//# sourceMappingURL=imagerouter.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Provider: ImageRouter — OpenAI-compatible image + video generation
|
|
3
3
|
* routing (`https://api.imagerouter.io/v1/openai`). Ported near-verbatim
|
|
4
4
|
* from Open Design's `apps/daemon/src/media/index.ts`
|
|
5
|
-
* `renderImageRouterImage`/`renderImageRouterVideo` — see `
|
|
5
|
+
* `renderImageRouterImage`/`renderImageRouterVideo` — see `archived provenance ledger`.
|
|
6
6
|
*
|
|
7
7
|
* 2026-07-21: migrated onto the generic vendor-adapter dispatch engine
|
|
8
8
|
* (`vendor-adapter.ts`/`vendor-registry.ts`) — two adapters registered on
|
|
@@ -18,9 +18,8 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { buildOpenAIImageUrl, buildOpenAIVideoUrl, bytesFromOpenAICompatibleData, parseOpenAICompatibleJson, sniffImageExt, withRequestInit, } from '../openai-compatible.js';
|
|
20
20
|
import { dispatchVendorRequest, requireApiKey } from '../vendor-adapter.js';
|
|
21
|
-
import { mediaVendorRegistry } from '../vendor-registry.js';
|
|
22
21
|
/** ImageRouter's image/video generation `size` string for a given aspect ratio. */
|
|
23
|
-
export function imageRouterSizeFor(aspect, surface) {
|
|
22
|
+
export function imageRouterSizeFor({ aspect, surface }) {
|
|
24
23
|
if (surface === 'video') {
|
|
25
24
|
if (aspect === '1:1')
|
|
26
25
|
return '1024x1024';
|
|
@@ -44,12 +43,12 @@ export function imageRouterSizeFor(aspect, surface) {
|
|
|
44
43
|
}
|
|
45
44
|
const NO_CREDENTIAL_MESSAGE = 'no ImageRouter API key — configure it or set IMAGEROUTER_API_KEY';
|
|
46
45
|
const imageRouterImageAdapter = {
|
|
47
|
-
requireCredential: requireApiKey(NO_CREDENTIAL_MESSAGE),
|
|
48
|
-
buildRequest(ctx, credentials) {
|
|
46
|
+
requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
|
|
47
|
+
buildRequest({ ctx, credentials }) {
|
|
49
48
|
const apiKey = credentials.apiKey; // requireCredential already validated this.
|
|
50
49
|
const baseUrl = (credentials.baseUrl || 'https://api.imagerouter.io/v1/openai').trim();
|
|
51
50
|
const wireModel = (credentials.model || ctx.wireModel).trim();
|
|
52
|
-
const size = imageRouterSizeFor(ctx.aspect, 'image');
|
|
51
|
+
const size = imageRouterSizeFor({ aspect: ctx.aspect, surface: 'image' });
|
|
53
52
|
const body = {
|
|
54
53
|
prompt: ctx.prompt || 'A high-quality reference image.',
|
|
55
54
|
model: wireModel,
|
|
@@ -71,9 +70,9 @@ const imageRouterImageAdapter = {
|
|
|
71
70
|
meta: { wireModel, size },
|
|
72
71
|
};
|
|
73
72
|
},
|
|
74
|
-
async parseResponse(resp, ctx, request) {
|
|
73
|
+
async parseResponse({ resp, ctx, request }) {
|
|
75
74
|
const data = await parseOpenAICompatibleJson(resp, 'imagerouter image');
|
|
76
|
-
const bytes = await bytesFromOpenAICompatibleData(data, 'imagerouter image', ctx
|
|
75
|
+
const bytes = await bytesFromOpenAICompatibleData({ data, providerTag: 'imagerouter image' }, ctx);
|
|
77
76
|
return {
|
|
78
77
|
bytes,
|
|
79
78
|
providerNote: `imagerouter/${request.meta.wireModel} · ${request.meta.size} · ${bytes.length} bytes`,
|
|
@@ -81,18 +80,17 @@ const imageRouterImageAdapter = {
|
|
|
81
80
|
};
|
|
82
81
|
},
|
|
83
82
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return dispatchVendorRequest(imageRouterImageAdapter, ctx, credentials);
|
|
83
|
+
export async function renderImageRouterImage({ ctx, credentials }) {
|
|
84
|
+
return dispatchVendorRequest({ adapter: imageRouterImageAdapter, ctx: ctx, credentials: credentials });
|
|
87
85
|
}
|
|
88
86
|
const imageRouterVideoAdapter = {
|
|
89
|
-
requireCredential: requireApiKey(NO_CREDENTIAL_MESSAGE),
|
|
90
|
-
buildRequest(ctx, credentials) {
|
|
87
|
+
requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
|
|
88
|
+
buildRequest({ ctx, credentials }) {
|
|
91
89
|
const apiKey = credentials.apiKey; // requireCredential already validated this.
|
|
92
90
|
const baseUrl = (credentials.baseUrl || 'https://api.imagerouter.io/v1/openai').trim();
|
|
93
91
|
const wireModel = (credentials.model || ctx.wireModel).trim();
|
|
94
92
|
const seconds = typeof ctx.length === 'number' ? ctx.length : 'auto';
|
|
95
|
-
const size = imageRouterSizeFor(ctx.aspect, 'video');
|
|
93
|
+
const size = imageRouterSizeFor({ aspect: ctx.aspect, surface: 'video' });
|
|
96
94
|
const body = {
|
|
97
95
|
prompt: ctx.prompt || 'A short cinematic clip.',
|
|
98
96
|
model: wireModel,
|
|
@@ -113,9 +111,9 @@ const imageRouterVideoAdapter = {
|
|
|
113
111
|
meta: { wireModel, size, seconds },
|
|
114
112
|
};
|
|
115
113
|
},
|
|
116
|
-
async parseResponse(resp, ctx, request) {
|
|
114
|
+
async parseResponse({ resp, ctx, request }) {
|
|
117
115
|
const data = await parseOpenAICompatibleJson(resp, 'imagerouter video');
|
|
118
|
-
const bytes = await bytesFromOpenAICompatibleData(data, 'imagerouter video', ctx
|
|
116
|
+
const bytes = await bytesFromOpenAICompatibleData({ data, providerTag: 'imagerouter video' }, ctx);
|
|
119
117
|
const { wireModel, size, seconds } = request.meta;
|
|
120
118
|
return {
|
|
121
119
|
bytes,
|
|
@@ -124,8 +122,12 @@ const imageRouterVideoAdapter = {
|
|
|
124
122
|
};
|
|
125
123
|
},
|
|
126
124
|
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
export async function renderImageRouterVideo({ ctx, credentials }) {
|
|
126
|
+
return dispatchVendorRequest({ adapter: imageRouterVideoAdapter, ctx: ctx, credentials: credentials });
|
|
127
|
+
}
|
|
128
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
129
|
+
export function registerVendorAdapters({ registry }, _optional = {}) {
|
|
130
|
+
registry.register({ providerId: 'imagerouter', routeKey: 'image', adapter: imageRouterImageAdapter });
|
|
131
|
+
registry.register({ providerId: 'imagerouter', routeKey: 'video', adapter: imageRouterVideoAdapter });
|
|
130
132
|
}
|
|
131
133
|
//# sourceMappingURL=imagerouter.js.map
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
|
|
2
|
-
|
|
2
|
+
import type { VendorAdapterRegistry } from '../vendor-registry.js';
|
|
3
|
+
export declare function renderMinimaxTTS({ ctx, credentials }: {
|
|
4
|
+
ctx: RenderContext;
|
|
5
|
+
credentials: ProviderCredentials;
|
|
6
|
+
}): Promise<RenderResult>;
|
|
7
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
8
|
+
export declare function registerVendorAdapters({ registry }: {
|
|
9
|
+
registry: Pick<VendorAdapterRegistry, 'register'>;
|
|
10
|
+
}, _optional?: Record<string, never>): void;
|
|
3
11
|
//# sourceMappingURL=minimax.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Provider: MiniMax — Speech-02 family text-to-speech (synchronous,
|
|
3
3
|
* `POST /t2a_v2`). Ported near-verbatim from Open Design's
|
|
4
4
|
* `apps/daemon/src/media/index.ts` `renderMinimaxTTS` — see
|
|
5
|
-
* `
|
|
5
|
+
* `archived provenance ledger`.
|
|
6
6
|
*
|
|
7
7
|
* 2026-07-21: migrated onto the generic vendor-adapter dispatch engine
|
|
8
8
|
* (`vendor-adapter.ts`/`vendor-registry.ts`) — `renderMinimaxTTS`'s
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
import { withRequestInit } from '../openai-compatible.js';
|
|
38
38
|
import { createHexEnvelopeAudioParser } from '../response-parsers.js';
|
|
39
39
|
import { dispatchVendorRequest, requireApiKey } from '../vendor-adapter.js';
|
|
40
|
-
import { mediaVendorRegistry } from '../vendor-registry.js';
|
|
41
40
|
const MINIMAX_DEFAULT_BASE_URL = 'https://api.minimaxi.chat/v1';
|
|
42
41
|
const MINIMAX_DEFAULT_VOICE_ID = 'male-qn-qingse';
|
|
43
42
|
const MINIMAX_TTS_MODEL_MAP = {
|
|
@@ -45,8 +44,8 @@ const MINIMAX_TTS_MODEL_MAP = {
|
|
|
45
44
|
};
|
|
46
45
|
const NO_CREDENTIAL_MESSAGE = 'no MiniMax credential — configure an API key or set MINIMAX_API_KEY.';
|
|
47
46
|
const minimaxTTSAdapter = {
|
|
48
|
-
requireCredential: requireApiKey(NO_CREDENTIAL_MESSAGE),
|
|
49
|
-
buildRequest(ctx, credentials) {
|
|
47
|
+
requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
|
|
48
|
+
buildRequest({ ctx, credentials }) {
|
|
50
49
|
// Safe: `requireCredential` above already validated this is set before
|
|
51
50
|
// `dispatchVendorRequest` ever calls `buildRequest`.
|
|
52
51
|
const apiKey = credentials.apiKey;
|
|
@@ -89,8 +88,11 @@ const minimaxTTSAdapter = {
|
|
|
89
88
|
},
|
|
90
89
|
parseResponse: createHexEnvelopeAudioParser({ errorTag: 'minimax tts', providerId: 'minimax' }),
|
|
91
90
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
export async function renderMinimaxTTS({ ctx, credentials }) {
|
|
92
|
+
return dispatchVendorRequest({ adapter: minimaxTTSAdapter, ctx: ctx, credentials: credentials });
|
|
93
|
+
}
|
|
94
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
95
|
+
export function registerVendorAdapters({ registry }, _optional = {}) {
|
|
96
|
+
registry.register({ providerId: 'minimax', routeKey: 'audio:speech', adapter: minimaxTTSAdapter });
|
|
95
97
|
}
|
|
96
98
|
//# sourceMappingURL=minimax.js.map
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
|
|
2
|
-
|
|
2
|
+
import type { VendorAdapterRegistry } from '../vendor-registry.js';
|
|
3
|
+
export declare function renderNanoBananaImage({ ctx, credentials }: {
|
|
4
|
+
ctx: RenderContext;
|
|
5
|
+
credentials: ProviderCredentials;
|
|
6
|
+
}): Promise<RenderResult>;
|
|
7
|
+
/** Explicit composition: importing a renderer never changes another module's registry. */
|
|
8
|
+
export declare function registerVendorAdapters({ registry }: {
|
|
9
|
+
registry: Pick<VendorAdapterRegistry, 'register'>;
|
|
10
|
+
}, _optional?: Record<string, never>): void;
|
|
3
11
|
//# sourceMappingURL=nanobanana.d.ts.map
|