@jini-ai/integrations 0.7.3-next.2 → 0.7.4
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 +7 -0
- package/README.md +1 -0
- package/dist/api-connections/bundled-client-namespace.d.ts +24 -0
- package/dist/api-connections/bundled-client-namespace.js +22 -0
- package/dist/api-connections/connect.d.ts +2 -10
- package/dist/api-connections/connect.js +1 -1
- package/dist/api-connections/contribution.d.ts +71 -0
- package/dist/api-connections/contribution.js +69 -0
- package/dist/api-connections/form-delivery-connection.d.ts +68 -0
- package/dist/api-connections/form-delivery-connection.js +73 -0
- package/dist/api-connections/hosted-mcp/contracts.d.ts +4 -171
- package/dist/api-connections/hosted-mcp/index.d.ts +2 -0
- package/dist/api-connections/hosted-mcp/oauth-row-writes.d.ts +3 -1
- package/dist/api-connections/hosted-mcp/oauth-row-writes.js +6 -3
- package/dist/api-connections/hosted-mcp/shared-sign-in.d.ts +2 -1
- package/dist/api-connections/hosted-mcp/sign-in-configuration.js +1 -1
- package/dist/api-connections/hosted-mcp/sign-in-discovery.js +1 -1
- package/dist/api-connections/hosted-mcp/sign-in-flow.d.ts +9 -3
- package/dist/api-connections/hosted-mcp/sign-in-flow.js +6 -6
- package/dist/api-connections/hosted-mcp/sign-in-provider.d.ts +16 -4
- package/dist/api-connections/hosted-mcp/sign-in-provider.js +3 -3
- package/dist/api-connections/hosted-mcp/sign-in-status.d.ts +13 -2
- package/dist/api-connections/hosted-mcp/sign-in-status.js +17 -4
- package/dist/api-connections/hosted-mcp/sign-in.d.ts +1 -1
- package/dist/api-connections/hosted-mcp/sign-in.js +28 -30
- package/dist/api-connections/shared-api.d.ts +87 -0
- package/dist/api-connections/shared-api.js +135 -0
- package/dist/api-connections/shared-oauth-disconnect.d.ts +73 -0
- package/dist/api-connections/shared-oauth-disconnect.js +41 -0
- package/dist/api-connections/shared-owner.d.ts +107 -0
- package/dist/api-connections/shared-owner.js +79 -0
- package/dist/api-connections/vault-stores.d.ts +110 -0
- package/dist/api-connections/vault-stores.js +202 -0
- package/dist/credentialed-http/auth-schemes.d.ts +2 -9
- package/dist/credentialed-http/tools/index.d.ts +30 -0
- package/dist/credentialed-http/tools/index.js +19 -0
- package/dist/credentialed-http/tools/tool-registrations.js +0 -1
- package/dist/custom-credentials/agent-tools.d.ts +79 -0
- package/dist/custom-credentials/agent-tools.js +98 -0
- package/dist/custom-credentials/card-token.d.ts +15 -0
- package/dist/custom-credentials/card-token.js +35 -0
- package/dist/custom-credentials/credential-ports.d.ts +70 -0
- package/dist/custom-credentials/credential-ports.js +41 -0
- package/dist/custom-credentials/credential-recovery.d.ts +20 -0
- package/dist/custom-credentials/credential-recovery.js +22 -0
- package/dist/custom-credentials/credentialed-request.d.ts +83 -0
- package/dist/custom-credentials/credentialed-request.js +93 -0
- package/dist/custom-credentials/custom-credential-create-ui.d.ts +106 -0
- package/dist/custom-credentials/custom-credential-create-ui.js +136 -0
- package/dist/custom-credentials/custom-credential-set-token-ui.d.ts +84 -0
- package/dist/custom-credentials/custom-credential-set-token-ui.js +104 -0
- package/dist/custom-credentials/delete-request-confirmation-ui.d.ts +33 -0
- package/dist/custom-credentials/delete-request-confirmation-ui.js +35 -0
- package/dist/custom-credentials/provider-settings-card.d.ts +109 -0
- package/dist/custom-credentials/provider-settings-card.js +166 -0
- package/dist/custom-credentials/write-files-validation.d.ts +102 -0
- package/dist/custom-credentials/write-files-validation.js +202 -0
- package/dist/media-providers/catalog-projection.d.ts +29 -0
- package/dist/media-providers/catalog-projection.js +45 -0
- package/dist/media-providers/catalog.d.ts +6 -3
- package/dist/media-providers/catalog.js +4 -3
- package/dist/media-providers/configurable-catalog.d.ts +9 -0
- package/dist/media-providers/configurable-catalog.js +70 -0
- package/dist/media-providers/dispatch/builtin-vendors.js +0 -2
- package/dist/media-providers/dispatch/credentials.d.ts +4 -1
- package/dist/media-providers/dispatch/credentials.js +3 -2
- package/dist/media-providers/dispatch/engine.d.ts +1 -1
- package/dist/media-providers/dispatch/engine.js +17 -5
- package/dist/media-providers/dispatch/index.d.ts +3 -2
- package/dist/media-providers/dispatch/index.js +2 -2
- package/dist/media-providers/dispatch/media-provider-registry.d.ts +23 -4
- package/dist/media-providers/dispatch/media-provider-registry.js +26 -11
- package/dist/media-providers/dispatch/media-wire.d.ts +14 -0
- package/dist/media-providers/dispatch/media-wire.js +22 -0
- package/dist/media-providers/dispatch/node.d.ts +5 -0
- package/dist/media-providers/dispatch/node.js +5 -1
- package/dist/media-providers/dispatch/openai-compatible.d.ts +3 -1
- package/dist/media-providers/dispatch/openai-compatible.js +1 -1
- package/dist/media-providers/dispatch/operation-runtime.js +5 -4
- package/dist/media-providers/dispatch/outbound.d.ts +28 -3
- package/dist/media-providers/dispatch/outbound.js +10 -3
- package/dist/media-providers/dispatch/providers/custom-image.js +1 -1
- package/dist/media-providers/dispatch/providers/imagerouter.js +1 -1
- package/dist/media-providers/dispatch/providers/nanobanana.js +1 -1
- package/dist/media-providers/dispatch/providers/openrouter.js +1 -1
- package/dist/media-providers/dispatch/ssrf-guard.js +2 -2
- package/dist/media-providers/dispatch/types.d.ts +13 -4
- package/dist/media-providers/dispatch/vendor-adapter.js +2 -2
- package/dist/media-providers/index.d.ts +2 -0
- package/dist/media-providers/providers.d.ts +9 -5
- package/dist/media-providers/providers.js +9 -12
- package/dist/media-providers/sqlite-task-store.d.ts +4 -4
- package/dist/media-providers/task-store.d.ts +1 -1
- package/dist/media-providers/task-store.js +1 -1
- package/dist/media-providers/types.d.ts +0 -36
- package/dist/media-providers/ui-defaults.js +0 -4
- package/dist/react/admin-credentials/AdminByokKeyPanel.d.ts +130 -0
- package/dist/react/admin-credentials/AdminByokKeyPanel.js +115 -0
- package/dist/react/admin-credentials/byok-footer-status.d.ts +37 -0
- package/dist/react/admin-credentials/byok-footer-status.js +25 -0
- package/dist/react/credentials/OtherCredentialsSection.d.ts +36 -0
- package/dist/react/credentials/OtherCredentialsSection.hooks.d.ts +55 -0
- package/dist/react/credentials/OtherCredentialsSection.hooks.js +26 -0
- package/dist/react/credentials/OtherCredentialsSection.js +120 -0
- package/dist/react/credentials/access-token-forms.d.ts +219 -0
- package/dist/react/credentials/access-token-forms.js +114 -0
- package/dist/react/credentials/credential-copy.d.ts +17 -0
- package/dist/react/credentials/credential-copy.js +7 -0
- package/dist/react/credentials/other-credential-stores.d.ts +115 -0
- package/dist/react/credentials/other-credential-stores.js +76 -0
- package/dist/react/site-key/SiteKeyRecoveryCard.d.ts +16 -0
- package/dist/react/site-key/SiteKeyRecoveryCard.js +36 -0
- package/dist/react/site-key/SiteKeyTab.d.ts +100 -0
- package/dist/react/site-key/SiteKeyTab.js +127 -0
- package/dist/react/site-key/hooks/use-site-key-recovery.hooks.d.ts +77 -0
- package/dist/react/site-key/hooks/use-site-key-recovery.hooks.js +126 -0
- package/dist/react/site-key/hooks/use-site-key.hooks.d.ts +120 -0
- package/dist/react/site-key/hooks/use-site-key.hooks.js +95 -0
- package/dist/react/webhooks/IntegrationDeliveries.d.ts +41 -0
- package/dist/react/webhooks/IntegrationDeliveries.js +24 -0
- package/dist/react/webhooks/Integrations.d.ts +73 -0
- package/dist/react/webhooks/Integrations.js +97 -0
- package/dist/react/webhooks/hooks/use-integration-deliveries.hooks.d.ts +59 -0
- package/dist/react/webhooks/hooks/use-integration-deliveries.hooks.js +11 -0
- package/dist/react/webhooks/hooks/use-integrations.hooks.d.ts +119 -0
- package/dist/react/webhooks/hooks/use-integrations.hooks.js +129 -0
- package/dist/react/webhooks/rules.d.ts +118 -0
- package/dist/react/webhooks/rules.js +103 -0
- package/dist/saved-requests/execute.js +2 -3
- package/dist/saved-requests/types.d.ts +4 -1
- package/dist/secrets/index.d.ts +3 -0
- package/dist/secrets/index.js +3 -0
- package/dist/secrets/ports.d.ts +25 -0
- package/dist/secrets/ports.js +2 -0
- package/dist/secrets/types.d.ts +10 -0
- package/dist/secrets/types.js +2 -0
- package/dist/vendor-credentials/abort-guarded-repo.d.ts +14 -0
- package/dist/vendor-credentials/abort-guarded-repo.js +41 -0
- package/dist/vendor-credentials/project-scope.d.ts +43 -0
- package/dist/vendor-credentials/project-scope.js +32 -0
- package/dist/vendor-credentials/vault-adapter.d.ts +157 -0
- package/dist/vendor-credentials/vault-adapter.js +220 -0
- package/dist/web-screenshot/capture-files.d.ts +44 -0
- package/dist/web-screenshot/capture-files.js +62 -0
- package/dist/web-screenshot/capture-retention.d.ts +157 -0
- package/dist/web-screenshot/capture-retention.js +134 -0
- package/dist/web-screenshot/capture-root-file-lock.d.ts +20 -0
- package/dist/web-screenshot/capture-root-file-lock.js +15 -0
- package/dist/web-screenshot/desktop-page-capture.d.ts +37 -0
- package/dist/web-screenshot/desktop-page-capture.js +62 -0
- package/dist/web-screenshot/own-site-opener.d.ts +40 -0
- package/dist/web-screenshot/own-site-opener.js +27 -0
- package/dist/web-screenshot/screenshot-image.d.ts +11 -0
- package/dist/web-screenshot/screenshot-image.js +12 -0
- package/dist/web-screenshot/web-screenshot.d.ts +188 -0
- package/dist/web-screenshot/web-screenshot.js +329 -0
- package/dist/webhooks/delivery.d.ts +16 -0
- package/dist/webhooks/delivery.js +41 -1
- package/dist/webhooks/ports.d.ts +1 -29
- package/dist/webhooks/signing.keyring.d.ts +1 -1
- package/dist/webhooks/site/delivery.d.ts +60 -0
- package/dist/webhooks/site/delivery.js +45 -0
- package/dist/webhooks/site/http.memory.d.ts +51 -0
- package/dist/webhooks/site/http.memory.js +28 -0
- package/dist/webhooks/site/repo.memory.d.ts +136 -0
- package/dist/webhooks/site/repo.memory.js +215 -0
- package/dist/webhooks/site/seal-aad-invariant.d.ts +26 -0
- package/dist/webhooks/site/seal-aad-invariant.js +61 -0
- package/dist/webhooks/site/seal-aad-invariant.node.d.ts +42 -0
- package/dist/webhooks/site/seal-aad-invariant.node.js +52 -0
- package/dist/webhooks/site/signing.d.ts +28 -0
- package/dist/webhooks/site/signing.js +27 -0
- package/dist/webhooks/site/signing.keyring.d.ts +29 -0
- package/dist/webhooks/site/signing.keyring.js +30 -0
- package/dist/webhooks/site/subscriptions.d.ts +118 -0
- package/dist/webhooks/site/subscriptions.js +98 -0
- package/dist/webhooks/sql/index.d.ts +4 -0
- package/dist/webhooks/sql/index.js +2 -0
- package/dist/webhooks/sql/repo.rows.d.ts +47 -0
- package/dist/webhooks/sql/repo.rows.js +2 -0
- package/dist/webhooks/sql/webhook-repo.d.ts +152 -0
- package/dist/webhooks/sql/webhook-repo.js +308 -0
- package/dist/webhooks/subscriptions.d.ts +3 -1
- package/dist/webhooks/subscriptions.js +4 -1
- package/dist/webhooks/tools/tool-handlers.js +2 -1
- package/dist/webhooks/types.d.ts +6 -10
- package/package.json +517 -12
- package/dist/media-providers/dispatch/providers/grok.d.ts +0 -55
- package/dist/media-providers/dispatch/providers/grok.js +0 -116
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MediaProviderOption } from "@jini-ai/core";
|
|
2
|
+
import { type MediaProviderRegistry } from "@jini-ai/integrations/media-providers";
|
|
3
|
+
/**
|
|
4
|
+
* @file The admin "External Providers" catalog, projected from the SAME live media-provider registry
|
|
5
|
+
* generation dispatches through (`RouteDeps.mediaProviderRegistry`), so a plugin-mounted vendor such
|
|
6
|
+
* as xAI Grok Imagine shows up as a card exactly when generation can route to it.
|
|
7
|
+
*
|
|
8
|
+
* The projection is an allow-list: only `id`, `label`, a credential-free `defaultBaseUrl` and model
|
|
9
|
+
* ids are copied. Contribution objects, registry refusals and anything else a plugin attaches never
|
|
10
|
+
* reach the API, so no key, token or raw provider error can ride along.
|
|
11
|
+
*/
|
|
12
|
+
/** The registry slice the projection reads. */
|
|
13
|
+
export type MediaProviderCatalogSource = Pick<MediaProviderRegistry, "providers">;
|
|
14
|
+
export interface MediaProviderCatalogOptions {
|
|
15
|
+
aliases: Readonly<Record<string, string>>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The configurable provider cards, one per public provider, in registry order.
|
|
19
|
+
*
|
|
20
|
+
* Why: public aliases can converge without making sealed credential identities interchangeable —
|
|
21
|
+
* `grok` and `xai-grok-imagine` publish ONE card under the canonical id here, while the credential
|
|
22
|
+
* store still opens a legacy `grok` envelope under its own stored id (`resolveMediaCredentialIds`).
|
|
23
|
+
*
|
|
24
|
+
* @complexity O(p + m) over registered providers and their models; no I/O, no credential reads.
|
|
25
|
+
*/
|
|
26
|
+
export declare function projectMediaProviderCatalog({ registry, aliases }: {
|
|
27
|
+
registry: MediaProviderCatalogSource;
|
|
28
|
+
} & MediaProviderCatalogOptions, _optional?: Record<string, never>): MediaProviderOption[];
|
|
29
|
+
//# sourceMappingURL=catalog-projection.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { canonicalMediaProviderId } from "@jini-ai/integrations/media-providers";
|
|
2
|
+
/** Vendors with no credential surface: `settingsVisible: false` entries and the local `stub`
|
|
3
|
+
* renderer — the same two exclusions the old static catalog made. @complexity O(1). */
|
|
4
|
+
function isConfigurable(provider) {
|
|
5
|
+
return provider.settingsVisible !== false && provider.id !== "stub";
|
|
6
|
+
}
|
|
7
|
+
/** A base URL only when it carries no credentials: no user info, query or fragment, since a plugin
|
|
8
|
+
* could ship a key in any of them. @complexity O(n) in URL length. */
|
|
9
|
+
function credentialFreeBaseUrl(value) {
|
|
10
|
+
if (typeof value !== "string" || value === "")
|
|
11
|
+
return undefined;
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(value);
|
|
14
|
+
return url.username || url.password || url.search || url.hash ? undefined : value;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** One card's safe fields, built field by field (never a spread of the contribution). @complexity O(m). */
|
|
21
|
+
function toOption({ id, provider, models }) {
|
|
22
|
+
const defaultBaseUrl = credentialFreeBaseUrl(provider.defaultBaseUrl);
|
|
23
|
+
const modelIds = [...new Set(models.map((model) => model.id))];
|
|
24
|
+
return { id, label: provider.label, ...(defaultBaseUrl ? { defaultBaseUrl } : {}), ...(modelIds.length > 0 ? { models: modelIds } : {}) };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The configurable provider cards, one per public provider, in registry order.
|
|
28
|
+
*
|
|
29
|
+
* Why: public aliases can converge without making sealed credential identities interchangeable —
|
|
30
|
+
* `grok` and `xai-grok-imagine` publish ONE card under the canonical id here, while the credential
|
|
31
|
+
* store still opens a legacy `grok` envelope under its own stored id (`resolveMediaCredentialIds`).
|
|
32
|
+
*
|
|
33
|
+
* @complexity O(p + m) over registered providers and their models; no I/O, no credential reads.
|
|
34
|
+
*/
|
|
35
|
+
export function projectMediaProviderCatalog({ registry, aliases }, _optional = {}) {
|
|
36
|
+
const seen = new Set();
|
|
37
|
+
return registry.providers.list().flatMap(({ provider: contribution }) => {
|
|
38
|
+
const id = canonicalMediaProviderId({ id: contribution.provider.id }, { aliases });
|
|
39
|
+
if (!isConfigurable(contribution.provider) || seen.has(id))
|
|
40
|
+
return [];
|
|
41
|
+
seen.add(id);
|
|
42
|
+
return [toOption({ id, provider: contribution.provider, models: contribution.models })];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=catalog-projection.js.map
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* — its barrel statically pulls in `node:crypto`/`node:fs`/`node:path` (`staging.ts`),
|
|
7
7
|
* `node:dns` (`dispatch/ssrf-guard.ts`), and `undici` (`dispatch/providers/openai.ts`). A host's
|
|
8
8
|
* browser bundle needs the provider list to render a credentials screen, but must not drag the
|
|
9
|
-
* dispatch engine in to get it. `providers.ts` imports only types from `types.ts
|
|
10
|
-
*
|
|
11
|
-
* `"universal"`.
|
|
9
|
+
* dispatch engine in to get it. `providers.ts` imports only types from `types.ts` and from
|
|
10
|
+
* `@jini-ai/core` (which owns `MediaModel`/`MediaProvider`), and `types.ts` imports nothing at all,
|
|
11
|
+
* so this pair is genuinely dependency-free and safe to mark `"universal"`.
|
|
12
12
|
*
|
|
13
13
|
* The constraint this file encodes: **runtime imports stay inside the pure catalog graph.**
|
|
14
14
|
* UI projections import only core types, erased before evaluation; no UI or React dependency exists.
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
* the import graph stays clean, so that mistake fails a test rather than a downstream bundle.
|
|
18
18
|
*/
|
|
19
19
|
export * from './types.js';
|
|
20
|
+
/** Deprecated re-export: import these from `@jini-ai/core/contracts/site/media-providers-catalog`; removed at the next major. */
|
|
21
|
+
export type { MediaModel, MediaProvider } from '@jini-ai/core/contracts/site/media-providers-catalog';
|
|
22
|
+
export { CONFIGURABLE_MEDIA_PROVIDER_CATALOG } from './configurable-catalog.js';
|
|
20
23
|
export * from './providers.js';
|
|
21
24
|
export * from './image-model-ids.js';
|
|
22
25
|
export { DEFAULT_MEDIA_PROVIDER_CATALOG, DEFAULT_PROVIDER_PRESETS } from './ui-defaults.js';
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* — its barrel statically pulls in `node:crypto`/`node:fs`/`node:path` (`staging.ts`),
|
|
7
7
|
* `node:dns` (`dispatch/ssrf-guard.ts`), and `undici` (`dispatch/providers/openai.ts`). A host's
|
|
8
8
|
* browser bundle needs the provider list to render a credentials screen, but must not drag the
|
|
9
|
-
* dispatch engine in to get it. `providers.ts` imports only types from `types.ts
|
|
10
|
-
*
|
|
11
|
-
* `"universal"`.
|
|
9
|
+
* dispatch engine in to get it. `providers.ts` imports only types from `types.ts` and from
|
|
10
|
+
* `@jini-ai/core` (which owns `MediaModel`/`MediaProvider`), and `types.ts` imports nothing at all,
|
|
11
|
+
* so this pair is genuinely dependency-free and safe to mark `"universal"`.
|
|
12
12
|
*
|
|
13
13
|
* The constraint this file encodes: **runtime imports stay inside the pure catalog graph.**
|
|
14
14
|
* UI projections import only core types, erased before evaluation; no UI or React dependency exists.
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* the import graph stays clean, so that mistake fails a test rather than a downstream bundle.
|
|
18
18
|
*/
|
|
19
19
|
export * from './types.js';
|
|
20
|
+
export { CONFIGURABLE_MEDIA_PROVIDER_CATALOG } from './configurable-catalog.js';
|
|
20
21
|
export * from './providers.js';
|
|
21
22
|
export * from './image-model-ids.js';
|
|
22
23
|
export { DEFAULT_MEDIA_PROVIDER_CATALOG, DEFAULT_PROVIDER_PRESETS } from './ui-defaults.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MediaProviderOption } from '@jini-ai/core';
|
|
2
|
+
/**
|
|
3
|
+
* The real vendor roster, in `MediaProvidersTab`'s own option shape (`MediaProviderOption`).
|
|
4
|
+
*
|
|
5
|
+
* Computed once at module load: `MEDIA_PROVIDERS` is a frozen `as const` literal, so there is
|
|
6
|
+
* nothing to recompute and a stable array identity keeps the tab from re-rendering on it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CONFIGURABLE_MEDIA_PROVIDER_CATALOG: readonly MediaProviderOption[];
|
|
9
|
+
//# sourceMappingURL=configurable-catalog.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { MEDIA_PROVIDERS, IMAGE_MODELS, VIDEO_MODELS, AUDIO_MODELS_BY_KIND } from './providers.js';
|
|
2
|
+
/**
|
|
3
|
+
* @file The provider roster a "Media providers" credentials screen renders, adapted from the real
|
|
4
|
+
* vendor catalogue in this package's `media-providers`.
|
|
5
|
+
*
|
|
6
|
+
* ## Why not `DEFAULT_MEDIA_PROVIDER_CATALOG`
|
|
7
|
+
*
|
|
8
|
+
* That one is a small curated starter sample, and it spells provider
|
|
9
|
+
* ids differently from the engine that will eventually consume these credentials:
|
|
10
|
+
* `xai-grok-imagine` vs `grok`, `nano-banana` vs `nanobanana`, `fal-ai` vs `fal`, `leonardo-ai` vs
|
|
11
|
+
* `leonardo`, `custom-image-api` vs `custom-image`, `volcengine-ark` vs `volcengine`. The dispatch
|
|
12
|
+
* engine and `PROVIDER_CREDENTIAL_ENV_VARS` both key off the LATTER, so a credential stored under a
|
|
13
|
+
* UI-spelled id would be saved successfully and then never resolve at generation time — a silent
|
|
14
|
+
* failure with no error anywhere. Keying the UI off the engine's own catalogue makes that
|
|
15
|
+
* divergence unrepresentable rather than merely documented; the server rejects the UI spellings
|
|
16
|
+
* too (the host's provider credential store), so both ends agree.
|
|
17
|
+
*
|
|
18
|
+
* ## Why the import is `/catalog` and not `/media-providers`
|
|
19
|
+
*
|
|
20
|
+
* The main this package's `media-providers` entry is a node-runtime barrel — it statically
|
|
21
|
+
* reaches `node:crypto`/`node:fs`/`node:path`, `node:dns`, and `undici` through the dispatch
|
|
22
|
+
* engine. `./media-providers/catalog` exists precisely so a browser bundle can take the vendor list
|
|
23
|
+
* without any of that. Importing from the main entry here would drag the whole generation engine
|
|
24
|
+
* into a browser bundle.
|
|
25
|
+
*/
|
|
26
|
+
/** Providers the operator can actually configure a credential for.
|
|
27
|
+
*
|
|
28
|
+
* Two exclusions, both deliberate:
|
|
29
|
+
* - `settingsVisible === false` — the vendor's own catalogue entry says it has no settings surface.
|
|
30
|
+
* `hyperframes` is the only entry with this set: it names a planned local HTML → MP4 renderer
|
|
31
|
+
* (`integrated: false`), not a working REST endpoint, so there is no API key to collect and no
|
|
32
|
+
* adapter anywhere in this package to route a credential to yet.
|
|
33
|
+
* - `stub` — the deterministic local placeholder renderer. It takes no credential and exists for
|
|
34
|
+
* tests; showing it as a configurable vendor would be noise.
|
|
35
|
+
*
|
|
36
|
+
* Everything else stays, INCLUDING vendors with `integrated: false`. Those are real services with
|
|
37
|
+
* real API keys whose request-shape this workspace has not ported yet; an operator can legitimately
|
|
38
|
+
* store the key ahead of that, and hiding them would misrepresent the catalogue as smaller than it
|
|
39
|
+
* is. */
|
|
40
|
+
function isConfigurable(provider) {
|
|
41
|
+
return provider.settingsVisible !== false && provider.id !== "stub";
|
|
42
|
+
}
|
|
43
|
+
/** Model ids this provider advertises across every surface, de-duplicated and stably ordered.
|
|
44
|
+
*
|
|
45
|
+
* `MediaProviderOption.models` is a flat list with no surface dimension, so image, video, and audio
|
|
46
|
+
* models for one vendor collapse into a single picker. That is the component's shape, not a lossy
|
|
47
|
+
* choice made here — and it is why the list is de-duplicated: a model offered on two surfaces would
|
|
48
|
+
* otherwise appear twice in the dropdown.
|
|
49
|
+
*
|
|
50
|
+
* @complexity O(m) over the catalogue's models, once per provider at module load. */
|
|
51
|
+
function modelIdsFor(providerId) {
|
|
52
|
+
const everyModel = [...IMAGE_MODELS, ...VIDEO_MODELS, ...Object.values(AUDIO_MODELS_BY_KIND).flat()];
|
|
53
|
+
return [...new Set(everyModel.filter((model) => model.provider === providerId).map((model) => model.id))];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The real vendor roster, in `MediaProvidersTab`'s own option shape (`MediaProviderOption`).
|
|
57
|
+
*
|
|
58
|
+
* Computed once at module load: `MEDIA_PROVIDERS` is a frozen `as const` literal, so there is
|
|
59
|
+
* nothing to recompute and a stable array identity keeps the tab from re-rendering on it.
|
|
60
|
+
*/
|
|
61
|
+
export const CONFIGURABLE_MEDIA_PROVIDER_CATALOG = MEDIA_PROVIDERS.filter(isConfigurable).map((provider) => {
|
|
62
|
+
const models = modelIdsFor(provider.id);
|
|
63
|
+
return {
|
|
64
|
+
id: provider.id,
|
|
65
|
+
label: provider.label,
|
|
66
|
+
...(provider.defaultBaseUrl ? { defaultBaseUrl: provider.defaultBaseUrl } : {}),
|
|
67
|
+
...(models.length > 0 ? { models } : {}),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=configurable-catalog.js.map
|
|
@@ -2,7 +2,6 @@ import { registerVendorAdapters as registerAihubmix } from './providers/aihubmix
|
|
|
2
2
|
import { registerVendorAdapters as registerCustomImage } from './providers/custom-image.js';
|
|
3
3
|
import { registerVendorAdapters as registerElevenLabs } from './providers/elevenlabs.js';
|
|
4
4
|
import { registerVendorAdapters as registerFishAudio } from './providers/fishaudio.js';
|
|
5
|
-
import { registerVendorAdapters as registerGrok } from './providers/grok.js';
|
|
6
5
|
import { registerVendorAdapters as registerImageRouter } from './providers/imagerouter.js';
|
|
7
6
|
import { registerVendorAdapters as registerMiniMax } from './providers/minimax.js';
|
|
8
7
|
import { registerVendorAdapters as registerNanoBanana } from './providers/nanobanana.js';
|
|
@@ -16,7 +15,6 @@ export function registerBuiltinVendorAdapters({ registry }, _optional = {}) {
|
|
|
16
15
|
registerCustomImage,
|
|
17
16
|
registerElevenLabs,
|
|
18
17
|
registerFishAudio,
|
|
19
|
-
registerGrok,
|
|
20
18
|
registerImageRouter,
|
|
21
19
|
registerMiniMax,
|
|
22
20
|
registerNanoBanana,
|
|
@@ -3,5 +3,8 @@ import type { ProviderCredentials } from './types.js';
|
|
|
3
3
|
export declare function resolveProviderCredentialsFromEnv({ providerId, env }: {
|
|
4
4
|
providerId: string;
|
|
5
5
|
env: NodeJS.ProcessEnv;
|
|
6
|
-
},
|
|
6
|
+
}, { envVars, aliases }?: {
|
|
7
|
+
envVars?: Readonly<Record<string, readonly string[]>>;
|
|
8
|
+
aliases?: Readonly<Record<string, string>>;
|
|
9
|
+
}): ProviderCredentials;
|
|
7
10
|
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { canonicalMediaProviderId, PROVIDER_CREDENTIAL_ENV_VARS } from '../providers.js';
|
|
12
12
|
/** Resolves `{ apiKey }` for `providerId` from the first set environment variable in its priority list, or `{}` if none are set / the provider has no known env vars. */
|
|
13
|
-
export function resolveProviderCredentialsFromEnv({ providerId, env },
|
|
14
|
-
|
|
13
|
+
export function resolveProviderCredentialsFromEnv({ providerId, env }, { envVars = PROVIDER_CREDENTIAL_ENV_VARS, aliases = {} } = {}) {
|
|
14
|
+
// `envVars` is the host's table: a plugin vendor's environment key arrives here, never as a built-in row.
|
|
15
|
+
const candidates = envVars[canonicalMediaProviderId({ id: providerId }, { aliases })];
|
|
15
16
|
if (!candidates)
|
|
16
17
|
return {};
|
|
17
18
|
for (const name of candidates) {
|
|
@@ -25,5 +25,5 @@ export declare function lookupRoute({ routes, providerId, routeKey }: {
|
|
|
25
25
|
/** Creates an engine over the host's registry; registration remains live between requests.
|
|
26
26
|
* @returns A generation service; validation, missing routes and provider failures reject generate.
|
|
27
27
|
*/
|
|
28
|
-
export declare function createMediaDispatchEngine({ registry, httpClient }: MediaDispatchEngineRequired, options?: MediaDispatchEngineOptions): MediaDispatchEngine;
|
|
28
|
+
export declare function createMediaDispatchEngine({ registry, httpClient, guardedFetch }: MediaDispatchEngineRequired, options?: MediaDispatchEngineOptions): MediaDispatchEngine;
|
|
29
29
|
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { requireMediaHttpClient } from './outbound.js';
|
|
1
|
+
import { requireMediaGuardedFetch, requireMediaHttpClient } from './outbound.js';
|
|
2
2
|
import { normalizeMediaProviderMap } from '../providers.js';
|
|
3
3
|
/** Media dispatch validates catalogue inputs, resolves live credentials and returns generated
|
|
4
4
|
* bytes. Registries belong to the host so embedded engines cannot alter each other's routes.
|
|
@@ -60,7 +60,7 @@ function clampWithWarning(value, allowed, flagName) {
|
|
|
60
60
|
* (`imagerouter`/`custom-image`/`grok`/`nanobanana`/`openrouter`/
|
|
61
61
|
* `volcengine`/`elevenlabs`/`aihubmix`) has migrated onto
|
|
62
62
|
* host-populated vendor registries (see `builtin-vendors.ts` and each vendor's
|
|
63
|
-
* explicit registration function) — joining `openai`/`minimax`/`senseaudio`/`fishaudio`, migrated the
|
|
63
|
+
* explicit registration function; `grok` moved on to a host-contributed xAI plugin contribution) — joining `openai`/`minimax`/`senseaudio`/`fishaudio`, migrated the
|
|
64
64
|
* pass before. Kept (not deleted) as `resolveRenderer`'s fallback path for
|
|
65
65
|
* the next vendor this engine wires up.
|
|
66
66
|
*/
|
|
@@ -97,22 +97,33 @@ function resolveRenderer({ registry, providerId, routeKey }) {
|
|
|
97
97
|
}
|
|
98
98
|
return lookupRoute({ routes: ROUTES, providerId, routeKey });
|
|
99
99
|
}
|
|
100
|
+
// A run's Stop signal can shorten the vendor deadline, never extend or replace it.
|
|
101
|
+
function bindMediaCallSignal({ guardedFetch, signal }, _optional = {}) {
|
|
102
|
+
return async (required, options) => {
|
|
103
|
+
signal.throwIfAborted();
|
|
104
|
+
return guardedFetch(required, { ...options, signal: options?.signal ? AbortSignal.any([signal, options.signal]) : signal });
|
|
105
|
+
};
|
|
106
|
+
}
|
|
100
107
|
/** Creates an engine over the host's registry; registration remains live between requests.
|
|
101
108
|
* @returns A generation service; validation, missing routes and provider failures reject generate.
|
|
102
109
|
*/
|
|
103
|
-
export function createMediaDispatchEngine({ registry, httpClient }, options = {}) {
|
|
110
|
+
export function createMediaDispatchEngine({ registry, httpClient, guardedFetch }, options = {}) {
|
|
104
111
|
requireMediaHttpClient({ httpClient });
|
|
112
|
+
// The host composes the transport: the engine never binds the node composer itself.
|
|
113
|
+
const boundGuardedFetch = requireMediaGuardedFetch({ guardedFetch });
|
|
105
114
|
const allowStubFallback = options.allowStubFallback === true;
|
|
106
115
|
const catalog = options.catalog ?? STATIC_CATALOG;
|
|
107
116
|
return {
|
|
108
117
|
async generate(required, optional = {}) {
|
|
109
118
|
// Credentials remain live: a host may rotate them between generation requests.
|
|
110
119
|
const configuredCredentials = options.credentials ? normalizeMediaProviderMap({ providers: options.credentials }) : {};
|
|
111
|
-
const
|
|
120
|
+
const { signal, ...optionalRequest } = optional;
|
|
121
|
+
const request = { ...required, ...optionalRequest };
|
|
122
|
+
signal?.throwIfAborted();
|
|
112
123
|
assertRequestShape(request);
|
|
113
124
|
const { def, resolvedAudioKind } = resolveCatalogModel(request, catalog);
|
|
114
125
|
const { length, duration, warnings } = clampRequestInputs(request);
|
|
115
|
-
const ctx = engineRenderContext({ request, resolvedAudioKind, length, duration, options: { ...options, httpClient } });
|
|
126
|
+
const ctx = engineRenderContext({ request, resolvedAudioKind, length, duration, options: { ...options, httpClient, guardedFetch: signal === undefined ? boundGuardedFetch : bindMediaCallSignal({ guardedFetch: boundGuardedFetch, signal }) } });
|
|
116
127
|
const { providerId, renderer, credentials } = selectRenderer({ registry, def, surface: request.surface, resolvedAudioKind, ctx, configuredCredentials });
|
|
117
128
|
if (!renderer) {
|
|
118
129
|
if (!allowStubFallback) {
|
|
@@ -175,6 +186,7 @@ function engineRenderContext(required) {
|
|
|
175
186
|
return {
|
|
176
187
|
...buildRenderContext({ request: request, resolvedAudioKind: resolvedAudioKind, length: length, duration: duration }),
|
|
177
188
|
httpClient: options.httpClient,
|
|
189
|
+
guardedFetch: options.guardedFetch,
|
|
178
190
|
...(options.allowPrivateNetwork === undefined ? {} : { allowPrivateNetwork: options.allowPrivateNetwork }),
|
|
179
191
|
...(options.outboundMessages === undefined ? {} : { outboundMessages: options.outboundMessages }),
|
|
180
192
|
};
|
|
@@ -5,7 +5,7 @@ export { renderAIHubMixImage, renderAIHubMixTTS } from './providers/aihubmix.js'
|
|
|
5
5
|
export { renderCustomOpenAIImage, customImageOverridesOpenAIModel, CUSTOM_IMAGE_MODEL_ID } from './providers/custom-image.js';
|
|
6
6
|
export { renderElevenLabsSfx, renderElevenLabsTTS } from './providers/elevenlabs.js';
|
|
7
7
|
export { renderFishAudioTTS } from './providers/fishaudio.js';
|
|
8
|
-
export {
|
|
8
|
+
export type { RenderContext, RenderResult } from './types.js';
|
|
9
9
|
export { renderImageRouterImage, renderImageRouterVideo, imageRouterSizeFor } from './providers/imagerouter.js';
|
|
10
10
|
export { renderMinimaxTTS } from './providers/minimax.js';
|
|
11
11
|
export { renderNanoBananaImage } from './providers/nanobanana.js';
|
|
@@ -21,8 +21,9 @@ export type { MediaDispatchEngine, MediaDispatchEngineOptions, MediaDispatchEngi
|
|
|
21
21
|
export { dispatchVendorRequest, requireApiKey } from './vendor-adapter.js';
|
|
22
22
|
export type { VendorAdapter, VendorCredentialGuard, VendorRequest, VendorRequestBuilder, VendorResponseParser } from './vendor-adapter.js';
|
|
23
23
|
export { createBuiltinVendorAdapterRegistry, createVendorAdapterRegistry, mediaVendorRegistry, VendorAdapterRegistry } from './vendor-registry.js';
|
|
24
|
-
export { builtinMediaProviderContributions, createMediaProviderRegistry, MEDIA_PROVIDER_CONTRACT, mediaProviderDefinition, mediaProviderRegistryId, } from './media-provider-registry.js';
|
|
24
|
+
export { builtinMediaProviderContributions, catalogMediaProviderContribution, createMediaProviderRegistry, MEDIA_PROVIDER_CONTRACT, mediaProviderDefinition, mediaProviderRegistryId, } from './media-provider-registry.js';
|
|
25
25
|
export type { MediaProviderContribution, MediaProviderModel, MediaProviderRegistry } from './media-provider-registry.js';
|
|
26
|
+
export { createMediaWire } from './media-wire.js';
|
|
26
27
|
export { createHexEnvelopeAudioParser, createRawBytesParser } from './response-parsers.js';
|
|
27
28
|
export { ASYNC_OPERATION_SCHEMA_VERSION, assertNoCredentialMaterial, createInMemoryAsyncOperationStore, CREDENTIAL_IN_STATE_MESSAGE, hydrateAsyncOperationRecord, } from './async-operation-store.js';
|
|
28
29
|
export type { AsyncOperationClaimOptions, AsyncOperationCreateInput, AsyncOperationError, AsyncOperationPatch, AsyncOperationReconcileResult, AsyncOperationRecord, AsyncOperationResult, AsyncOperationStatus, AsyncOperationStore, } from './async-operation-store.js';
|
|
@@ -5,7 +5,6 @@ export { renderAIHubMixImage, renderAIHubMixTTS } from './providers/aihubmix.js'
|
|
|
5
5
|
export { renderCustomOpenAIImage, customImageOverridesOpenAIModel, CUSTOM_IMAGE_MODEL_ID } from './providers/custom-image.js';
|
|
6
6
|
export { renderElevenLabsSfx, renderElevenLabsTTS } from './providers/elevenlabs.js';
|
|
7
7
|
export { renderFishAudioTTS } from './providers/fishaudio.js';
|
|
8
|
-
export { renderGrokImage, renderXAITTS, grokAspectFor } from './providers/grok.js';
|
|
9
8
|
export { renderImageRouterImage, renderImageRouterVideo, imageRouterSizeFor } from './providers/imagerouter.js';
|
|
10
9
|
export { renderMinimaxTTS } from './providers/minimax.js';
|
|
11
10
|
export { renderNanoBananaImage } from './providers/nanobanana.js';
|
|
@@ -22,7 +21,8 @@ export { isBlockedExternalApiHostname, isLoopbackApiHost } from '@jini-ai/core/n
|
|
|
22
21
|
export { dispatchVendorRequest, requireApiKey } from './vendor-adapter.js';
|
|
23
22
|
export { createBuiltinVendorAdapterRegistry, createVendorAdapterRegistry, mediaVendorRegistry, VendorAdapterRegistry } from './vendor-registry.js';
|
|
24
23
|
// Vendors as one-unit provider contributions on the shared keyed registry (2026-10-21).
|
|
25
|
-
export { builtinMediaProviderContributions, createMediaProviderRegistry, MEDIA_PROVIDER_CONTRACT, mediaProviderDefinition, mediaProviderRegistryId, } from './media-provider-registry.js';
|
|
24
|
+
export { builtinMediaProviderContributions, catalogMediaProviderContribution, createMediaProviderRegistry, MEDIA_PROVIDER_CONTRACT, mediaProviderDefinition, mediaProviderRegistryId, } from './media-provider-registry.js';
|
|
25
|
+
export { createMediaWire } from './media-wire.js';
|
|
26
26
|
export { createHexEnvelopeAudioParser, createRawBytesParser } from './response-parsers.js';
|
|
27
27
|
// The submit-then-poll tier (added 2026-09-02) — purely additive alongside `VendorAdapter`, for
|
|
28
28
|
// vendors that hand back a job handle instead of finishing inside one request/response. See
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* credentials, settings and env-var maps use — never changes.
|
|
12
12
|
*/
|
|
13
13
|
import { type ProviderDefinition, type ProviderRegistry } from '@jini-ai/core/provider-registry';
|
|
14
|
-
import type { AudioKind,
|
|
14
|
+
import type { AudioKind, MediaSurface } from '../types.js';
|
|
15
|
+
import type { MediaModel, MediaProvider } from '@jini-ai/core/contracts/site/media-providers-catalog';
|
|
15
16
|
import type { MediaModelCatalog, VendorAdapter, VendorAdapterLookup } from './types.js';
|
|
16
17
|
/** A catalogued model plus the surface (and audio kind) it is offered on. */
|
|
17
18
|
export interface MediaProviderModel extends MediaModel {
|
|
@@ -37,7 +38,9 @@ export declare const MEDIA_PROVIDER_CONTRACT = "media";
|
|
|
37
38
|
/** The registry key for a public media provider id (aliases resolved, `-` -> `_`). @complexity O(n) in id length. */
|
|
38
39
|
export declare function mediaProviderRegistryId({ id }: {
|
|
39
40
|
id: string;
|
|
40
|
-
},
|
|
41
|
+
}, { aliases }?: {
|
|
42
|
+
aliases?: Readonly<Record<string, string>>;
|
|
43
|
+
}): string;
|
|
41
44
|
/** Wraps one contribution as a shared-registry definition. @complexity O(1). */
|
|
42
45
|
export declare function mediaProviderDefinition({ contribution }: {
|
|
43
46
|
contribution: MediaProviderContribution;
|
|
@@ -46,15 +49,31 @@ export declare function mediaProviderDefinition({ contribution }: {
|
|
|
46
49
|
* Builds the media provider registry. Built-ins register with the throwing policy; plugins go through
|
|
47
50
|
* `providers.contribute` (or agent-plugins' `contributeProviders`) and are refused, never thrown.
|
|
48
51
|
* @param optional.contributions - Core contributions; defaults to {@link builtinMediaProviderContributions}.
|
|
52
|
+
* @param optional.aliases - Host-injected legacy provider ids (old id -> registered id) accepted on lookups.
|
|
49
53
|
* @throws {ProviderRegistryError} When a core contribution is malformed or duplicated.
|
|
50
54
|
* @complexity Lookups O(m) over registered models (tens), registration O(m).
|
|
51
55
|
*/
|
|
52
|
-
export declare function createMediaProviderRegistry(_required?: Record<string, never>, { contributions }?: {
|
|
56
|
+
export declare function createMediaProviderRegistry(_required?: Record<string, never>, { contributions, aliases }?: {
|
|
53
57
|
contributions?: readonly MediaProviderContribution[];
|
|
58
|
+
aliases?: Readonly<Record<string, string>>;
|
|
54
59
|
}): MediaProviderRegistry;
|
|
60
|
+
/**
|
|
61
|
+
* One catalogued provider as a contribution: its catalogue row, its catalogued models (with their
|
|
62
|
+
* catalogue order, so list order is the same whoever registers them) and the adapters the caller brings.
|
|
63
|
+
* Why: a vendor plugin ships only its adapters; the catalogue rows are generic reference data that stay here.
|
|
64
|
+
* @throws {Error} When `providerId` is not a catalogued provider.
|
|
65
|
+
* @complexity O(p + m) providers and models.
|
|
66
|
+
*/
|
|
67
|
+
export declare function catalogMediaProviderContribution({ providerId, adapters }: {
|
|
68
|
+
providerId: string;
|
|
69
|
+
adapters: Readonly<Record<string, VendorAdapter<never>>>;
|
|
70
|
+
}, _optional?: Record<string, never>): MediaProviderContribution;
|
|
55
71
|
/**
|
|
56
72
|
* Today's built-in vendors as the default contribution set: one unit per `MEDIA_PROVIDERS` entry, its
|
|
57
|
-
* catalogued models, and the adapters its `registerVendorAdapters` registers.
|
|
73
|
+
* catalogued models, and the adapters its `registerVendorAdapters` registers. An `integrated` row that
|
|
74
|
+
* has catalogued models but registers no built-in adapter is served by a vendor plugin the host
|
|
75
|
+
* contributes (see `catalogMediaProviderContribution`), so it is not built in; a row with no models
|
|
76
|
+
* (search or stub providers) has nothing to serve and stays.
|
|
58
77
|
* @returns Fresh contributions; adapters are the shared module-level adapter objects.
|
|
59
78
|
* @complexity O(p + m + a) providers, models and adapters.
|
|
60
79
|
*/
|
|
@@ -15,8 +15,8 @@ import { AUDIO_MODELS_BY_KIND, IMAGE_MODELS, MEDIA_PROVIDERS, VIDEO_MODELS, cano
|
|
|
15
15
|
import { registerBuiltinVendorAdapters } from './builtin-vendors.js';
|
|
16
16
|
export const MEDIA_PROVIDER_CONTRACT = 'media';
|
|
17
17
|
/** The registry key for a public media provider id (aliases resolved, `-` -> `_`). @complexity O(n) in id length. */
|
|
18
|
-
export function mediaProviderRegistryId({ id },
|
|
19
|
-
return canonicalMediaProviderId({ id }).replaceAll('-', '_');
|
|
18
|
+
export function mediaProviderRegistryId({ id }, { aliases = {} } = {}) {
|
|
19
|
+
return canonicalMediaProviderId({ id }, { aliases }).replaceAll('-', '_');
|
|
20
20
|
}
|
|
21
21
|
/** Wraps one contribution as a shared-registry definition. @complexity O(1). */
|
|
22
22
|
export function mediaProviderDefinition({ contribution }, _optional = {}) {
|
|
@@ -79,10 +79,11 @@ function asMediaModel(model) {
|
|
|
79
79
|
* Builds the media provider registry. Built-ins register with the throwing policy; plugins go through
|
|
80
80
|
* `providers.contribute` (or agent-plugins' `contributeProviders`) and are refused, never thrown.
|
|
81
81
|
* @param optional.contributions - Core contributions; defaults to {@link builtinMediaProviderContributions}.
|
|
82
|
+
* @param optional.aliases - Host-injected legacy provider ids (old id -> registered id) accepted on lookups.
|
|
82
83
|
* @throws {ProviderRegistryError} When a core contribution is malformed or duplicated.
|
|
83
84
|
* @complexity Lookups O(m) over registered models (tens), registration O(m).
|
|
84
85
|
*/
|
|
85
|
-
export function createMediaProviderRegistry(_required = {}, { contributions = builtinMediaProviderContributions() } = {}) {
|
|
86
|
+
export function createMediaProviderRegistry(_required = {}, { contributions = builtinMediaProviderContributions(), aliases = {} } = {}) {
|
|
86
87
|
let current;
|
|
87
88
|
const providers = createProviderRegistry({ contract: MEDIA_PROVIDER_CONTRACT }, {
|
|
88
89
|
// `current` is assigned before any registration below; validate only runs from register/contribute.
|
|
@@ -91,7 +92,7 @@ export function createMediaProviderRegistry(_required = {}, { contributions = bu
|
|
|
91
92
|
current = providers;
|
|
92
93
|
for (const contribution of contributions)
|
|
93
94
|
providers.register({ definition: mediaProviderDefinition({ contribution }) });
|
|
94
|
-
const entryFor = (id) => providers.get({ id: mediaProviderRegistryId({ id }) })?.provider;
|
|
95
|
+
const entryFor = (id) => providers.get({ id: mediaProviderRegistryId({ id }, { aliases }) })?.provider;
|
|
95
96
|
const allModels = () => providers.list().flatMap(entry => entry.provider.models).map((model, index) => ({ model, index })).sort(byOrder).map(({ model }) => model);
|
|
96
97
|
return {
|
|
97
98
|
providers,
|
|
@@ -118,9 +119,25 @@ function builtinModels() {
|
|
|
118
119
|
];
|
|
119
120
|
return all.map((model, order) => ({ ...model, order }));
|
|
120
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* One catalogued provider as a contribution: its catalogue row, its catalogued models (with their
|
|
124
|
+
* catalogue order, so list order is the same whoever registers them) and the adapters the caller brings.
|
|
125
|
+
* Why: a vendor plugin ships only its adapters; the catalogue rows are generic reference data that stay here.
|
|
126
|
+
* @throws {Error} When `providerId` is not a catalogued provider.
|
|
127
|
+
* @complexity O(p + m) providers and models.
|
|
128
|
+
*/
|
|
129
|
+
export function catalogMediaProviderContribution({ providerId, adapters }, _optional = {}) {
|
|
130
|
+
const provider = MEDIA_PROVIDERS.find(entry => entry.id === providerId);
|
|
131
|
+
if (provider === undefined)
|
|
132
|
+
throw new Error(`media provider '${providerId}' is not in the catalogue`);
|
|
133
|
+
return { provider, models: builtinModels().filter(model => model.provider === providerId), adapters };
|
|
134
|
+
}
|
|
121
135
|
/**
|
|
122
136
|
* Today's built-in vendors as the default contribution set: one unit per `MEDIA_PROVIDERS` entry, its
|
|
123
|
-
* catalogued models, and the adapters its `registerVendorAdapters` registers.
|
|
137
|
+
* catalogued models, and the adapters its `registerVendorAdapters` registers. An `integrated` row that
|
|
138
|
+
* has catalogued models but registers no built-in adapter is served by a vendor plugin the host
|
|
139
|
+
* contributes (see `catalogMediaProviderContribution`), so it is not built in; a row with no models
|
|
140
|
+
* (search or stub providers) has nothing to serve and stays.
|
|
124
141
|
* @returns Fresh contributions; adapters are the shared module-level adapter objects.
|
|
125
142
|
* @complexity O(p + m + a) providers, models and adapters.
|
|
126
143
|
*/
|
|
@@ -135,11 +152,9 @@ export function builtinMediaProviderContributions(_required = {}) {
|
|
|
135
152
|
},
|
|
136
153
|
},
|
|
137
154
|
});
|
|
138
|
-
const
|
|
139
|
-
return MEDIA_PROVIDERS
|
|
140
|
-
provider
|
|
141
|
-
|
|
142
|
-
adapters: adapters.get(provider.id) ?? {},
|
|
143
|
-
}));
|
|
155
|
+
const modeled = new Set(builtinModels().map(model => model.provider));
|
|
156
|
+
return MEDIA_PROVIDERS
|
|
157
|
+
.filter(provider => !provider.integrated || adapters.has(provider.id) || !modeled.has(provider.id))
|
|
158
|
+
.map(provider => catalogMediaProviderContribution({ providerId: provider.id, adapters: adapters.get(provider.id) ?? {} }));
|
|
144
159
|
}
|
|
145
160
|
//# sourceMappingURL=media-provider-registry.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generic wire helpers lent to a media provider plugin at initialize (`MediaWirePort`). Each entry
|
|
3
|
+
* wraps a helper this package already owns for its built-in vendors, so a plugin's request building,
|
|
4
|
+
* response parsing and safe download behave exactly like a built-in's without the plugin importing
|
|
5
|
+
* dispatch. Nothing here knows a vendor.
|
|
6
|
+
*/
|
|
7
|
+
import type { MediaWirePort } from '@jini-ai/core/contracts/site/media-provider-contribution';
|
|
8
|
+
/**
|
|
9
|
+
* Builds the port a host passes as `context.mediaWire` when it initializes a `media` provider.
|
|
10
|
+
* @returns A stateless port; reads no environment and holds no connection.
|
|
11
|
+
* @complexity O(1) time and space.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createMediaWire(_required?: Record<string, never>, _optional?: Record<string, never>): MediaWirePort;
|
|
14
|
+
//# sourceMappingURL=media-wire.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { buildOpenAIImageUrl, bytesFromOpenAICompatibleData, jsonPostInit, parseOpenAICompatibleJson, sniffImageExt, standardImageAspectFor, } from './openai-compatible.js';
|
|
2
|
+
import { createRawBytesParser } from './response-parsers.js';
|
|
3
|
+
import { requireApiKey } from './vendor-adapter.js';
|
|
4
|
+
/**
|
|
5
|
+
* Builds the port a host passes as `context.mediaWire` when it initializes a `media` provider.
|
|
6
|
+
* @returns A stateless port; reads no environment and holds no connection.
|
|
7
|
+
* @complexity O(1) time and space.
|
|
8
|
+
*/
|
|
9
|
+
export function createMediaWire(_required = {}, _optional = {}) {
|
|
10
|
+
return {
|
|
11
|
+
requireApiKey,
|
|
12
|
+
imageAspectFor: standardImageAspectFor,
|
|
13
|
+
imageGenerationUrl: ({ baseUrl }) => buildOpenAIImageUrl({ baseUrl, isAzure: false }),
|
|
14
|
+
jsonPostInit,
|
|
15
|
+
parseJson: parseOpenAICompatibleJson,
|
|
16
|
+
// The adapter's context IS the dispatch `RenderContext`, which carries the guarded outbound client a URL download needs.
|
|
17
|
+
imageBytesFromData: ({ data, providerTag, ctx }) => bytesFromOpenAICompatibleData({ data, providerTag }, ctx),
|
|
18
|
+
sniffImageExt: ({ bytes }) => sniffImageExt({ bytes }),
|
|
19
|
+
createRawBytesParser: (options) => createRawBytesParser(options),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=media-wire.js.map
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/** Explicit Node adapter entry. Hosts construct this once and inject it into media services. */
|
|
2
2
|
import type { HttpClientPort } from '@jini-ai/core/primitives';
|
|
3
3
|
import type { DnsResolver } from '@jini-ai/core/contracts/runtime';
|
|
4
|
+
import type { MediaGuardedFetch } from './outbound.js';
|
|
5
|
+
/** The composer binds the platform's guarded fetch adapter here; hosts inject it beside the client
|
|
6
|
+
* (`guardedFetch` on the engine options, render contexts and operation-runtime deps).
|
|
7
|
+
*/
|
|
8
|
+
export declare const nodeMediaGuardedFetch: MediaGuardedFetch;
|
|
4
9
|
export interface NodeMediaHttpClientOptions {
|
|
5
10
|
readonly allowPrivateNetwork?: boolean;
|
|
6
11
|
readonly dns?: DnsResolver;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { FETCH_TIMEOUT_MS } from '@jini-ai/core/net';
|
|
2
|
-
import { createHttpClient, createNodeGuardedHttpPorts } from '@jini-ai/platform/http/guarded';
|
|
2
|
+
import { createHttpClient, createNodeGuardedHttpPorts, guardedFetch } from '@jini-ai/platform/http/guarded';
|
|
3
|
+
/** The composer binds the platform's guarded fetch adapter here; hosts inject it beside the client
|
|
4
|
+
* (`guardedFetch` on the engine options, render contexts and operation-runtime deps).
|
|
5
|
+
*/
|
|
6
|
+
export const nodeMediaGuardedFetch = guardedFetch;
|
|
3
7
|
/** The default policy client: public http(s) peers only unless the caller explicitly opts into
|
|
4
8
|
* private-network development, never following redirects.
|
|
5
9
|
* @returns A DNS-pinned, bounded client; policy and transport failures reject send.
|
|
@@ -36,7 +36,9 @@ export declare function jsonPostInit({ ctx, body }: {
|
|
|
36
36
|
headers?: Readonly<Record<string, string>>;
|
|
37
37
|
}): RequestInit;
|
|
38
38
|
/** Sniffs an image byte buffer's format from its magic bytes (jpg/png/webp), defaulting to `.png`. */
|
|
39
|
-
export declare function sniffImageExt(bytes
|
|
39
|
+
export declare function sniffImageExt({ bytes }: {
|
|
40
|
+
bytes: Buffer;
|
|
41
|
+
}, _optional?: Record<string, never>): string;
|
|
40
42
|
export declare const AZURE_DEFAULT_API_VERSION = "2024-02-01";
|
|
41
43
|
/**
|
|
42
44
|
* Heuristic: does this base URL point at an Azure OpenAI deployment rather
|
|
@@ -73,7 +73,7 @@ function matchesSignature(bytes, signature) {
|
|
|
73
73
|
return signature.runs.every(([offset, magic]) => magic.every((byte, i) => bytes[offset + i] === byte));
|
|
74
74
|
}
|
|
75
75
|
/** Sniffs an image byte buffer's format from its magic bytes (jpg/png/webp), defaulting to `.png`. */
|
|
76
|
-
export function sniffImageExt(bytes) {
|
|
76
|
+
export function sniffImageExt({ bytes }, _optional = {}) {
|
|
77
77
|
return IMAGE_SIGNATURES.find((signature) => matchesSignature(bytes, signature))?.ext ?? '.png';
|
|
78
78
|
}
|
|
79
79
|
export const AZURE_DEFAULT_API_VERSION = '2024-02-01';
|
|
@@ -22,10 +22,10 @@ import { partitionArgs } from '../../args.js';
|
|
|
22
22
|
*
|
|
23
23
|
* No scheduler. `pollDueOperations` is a single leased tick a host drives from whatever timer or
|
|
24
24
|
* queue it already runs — this package performs no I/O of its own beyond the vendor calls it is
|
|
25
|
-
* handed a guarded `httpClient` for, a standing invariant across `@jini-ai/integrations/media-providers`.
|
|
25
|
+
* handed a guarded `httpClient` and `guardedFetch` for, a standing invariant across `@jini-ai/integrations/media-providers`.
|
|
26
26
|
*/
|
|
27
27
|
import { FETCH_TIMEOUT_MS } from '@jini-ai/core/net';
|
|
28
|
-
import { fetchMediaOutbound, requireMediaHttpClient } from './outbound.js';
|
|
28
|
+
import { fetchMediaOutbound, requireMediaGuardedFetch, requireMediaHttpClient } from './outbound.js';
|
|
29
29
|
/** Interactive budget for the inline attempt. Deliberately NOT `FETCH_TIMEOUT_MS.GENERATE` (10min) — that is the backstop for the *request*, this is the ceiling on making a human wait. */
|
|
30
30
|
export const DEFAULT_GRACE_MS = 4_000;
|
|
31
31
|
export const DEFAULT_MAX_ATTEMPTS = 60;
|
|
@@ -51,15 +51,16 @@ function toOperationError(error) {
|
|
|
51
51
|
}
|
|
52
52
|
async function performSigned(deps, request, timeoutMs) {
|
|
53
53
|
const signed = await deps.signer({ request: request });
|
|
54
|
-
return fetchMediaOutbound({ url: signed.url, timeoutMs, httpClient: requireMediaHttpClient(deps) }, { ...deps, init: signed.init });
|
|
54
|
+
return fetchMediaOutbound({ url: signed.url, timeoutMs, httpClient: requireMediaHttpClient(deps), guardedFetch: requireMediaGuardedFetch(deps) }, { ...deps, init: signed.init });
|
|
55
55
|
}
|
|
56
56
|
/** Thread only the outbound capability into parsers; stores and signers remain runtime-private.
|
|
57
57
|
* Both callers parse a response that `performSigned` just fetched through the client, so the client
|
|
58
|
-
*
|
|
58
|
+
* and guarded fetch are always present here; the `requireMedia*` helpers state that invariant instead of branching on it. */
|
|
59
59
|
function withRuntimeOutbound({ ctx, deps }) {
|
|
60
60
|
return {
|
|
61
61
|
...ctx,
|
|
62
62
|
httpClient: requireMediaHttpClient(deps),
|
|
63
|
+
guardedFetch: requireMediaGuardedFetch(deps),
|
|
63
64
|
...(deps.allowPrivateNetwork === undefined ? {} : { allowPrivateNetwork: deps.allowPrivateNetwork }),
|
|
64
65
|
...(deps.outboundMessages === undefined ? {} : { outboundMessages: deps.outboundMessages }),
|
|
65
66
|
};
|