@jini-ai/integrations 0.4.1 → 0.4.2

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.
Files changed (36) hide show
  1. package/dist/media-providers/dispatch/credentials.d.ts +1 -1
  2. package/dist/media-providers/dispatch/credentials.js +3 -3
  3. package/dist/media-providers/dispatch/engine.js +5 -2
  4. package/dist/media-providers/dispatch/sqlite-async-operation-store.d.ts +35 -1
  5. package/dist/media-providers/dispatch/sqlite-async-operation-store.js +4 -3
  6. package/dist/media-providers/providers.d.ts +34 -0
  7. package/dist/media-providers/providers.js +48 -18
  8. package/dist/media-providers/sqlite-driver.adapter.d.ts +4 -0
  9. package/dist/media-providers/sqlite-driver.adapter.js +5 -0
  10. package/dist/media-providers/sqlite-task-store.d.ts +50 -2
  11. package/dist/media-providers/sqlite-task-store.js +8 -4
  12. package/dist/webhooks/subscriptions.d.ts +1 -1
  13. package/dist/webhooks/subscriptions.js +5 -1
  14. package/package.json +10 -5
  15. package/dist/composio/bounded-data.d.ts +0 -36
  16. package/dist/composio/bounded-data.js +0 -181
  17. package/dist/composio/catalog.d.ts +0 -147
  18. package/dist/composio/catalog.js +0 -126
  19. package/dist/composio/composio-config.d.ts +0 -42
  20. package/dist/composio/composio-config.js +0 -145
  21. package/dist/composio/composio-descriptions.d.ts +0 -16
  22. package/dist/composio/composio-descriptions.js +0 -766
  23. package/dist/composio/composio.d.ts +0 -364
  24. package/dist/composio/composio.js +0 -1902
  25. package/dist/composio/errors.d.ts +0 -15
  26. package/dist/composio/errors.js +0 -16
  27. package/dist/composio/file-lock.d.ts +0 -13
  28. package/dist/composio/file-lock.js +0 -92
  29. package/dist/composio/index.d.ts +0 -18
  30. package/dist/composio/index.js +0 -7
  31. package/dist/composio/json-schema.d.ts +0 -93
  32. package/dist/composio/json-schema.js +0 -498
  33. package/dist/composio/output-protection.d.ts +0 -32
  34. package/dist/composio/output-protection.js +0 -105
  35. package/dist/composio/service.d.ts +0 -181
  36. package/dist/composio/service.js +0 -758
@@ -3,5 +3,5 @@ import type { ProviderCredentials } from './types.js';
3
3
  export declare function resolveProviderCredentialsFromEnv({ providerId, env }: {
4
4
  providerId: string;
5
5
  env: NodeJS.ProcessEnv;
6
- }): ProviderCredentials;
6
+ }, _optional?: Record<string, never>): ProviderCredentials;
7
7
  //# sourceMappingURL=credentials.d.ts.map
@@ -8,10 +8,10 @@
8
8
  * layer (a config file, a vault, a project-scoped override var) should
9
9
  * build the credentials map itself instead of using this.
10
10
  */
11
- import { PROVIDER_CREDENTIAL_ENV_VARS } from '../providers.js';
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
- const candidates = PROVIDER_CREDENTIAL_ENV_VARS[providerId];
13
+ export function resolveProviderCredentialsFromEnv({ providerId, env }, _optional = {}) {
14
+ const candidates = PROVIDER_CREDENTIAL_ENV_VARS[canonicalMediaProviderId({ id: providerId })];
15
15
  if (!candidates)
16
16
  return {};
17
17
  for (const name of candidates) {
@@ -1,3 +1,4 @@
1
+ import { normalizeMediaProviderMap } from '../providers.js';
1
2
  /**
2
3
  * The media dispatch engine — validates a generation request against the
3
4
  * catalogue, clamps registry-bound numeric inputs, resolves per-provider
@@ -124,6 +125,8 @@ export function createMediaDispatchEngine(_required, optional = {}) {
124
125
  const allowStubFallback = options.allowStubFallback === true;
125
126
  return {
126
127
  async generate(required, optional = {}) {
128
+ // Credentials remain live: a host may rotate them between generation requests.
129
+ const configuredCredentials = options.credentials ? normalizeMediaProviderMap({ providers: options.credentials }) : {};
127
130
  const request = { ...required, ...optional };
128
131
  const { surface, model } = request;
129
132
  if (!SURFACES.has(surface)) {
@@ -173,7 +176,7 @@ export function createMediaDispatchEngine(_required, optional = {}) {
173
176
  ...(options.allowPrivateNetwork === undefined ? {} : { allowPrivateNetwork: options.allowPrivateNetwork }),
174
177
  ...(options.outboundMessages === undefined ? {} : { outboundMessages: options.outboundMessages }),
175
178
  };
176
- const credentials = options.credentials?.[def.provider] ?? {};
179
+ const credentials = configuredCredentials[def.provider] ?? {};
177
180
  // `openai` + image can be overridden by a caller-configured
178
181
  // `custom-image` credential that names the same model — mirrors the
179
182
  // origin's `customImageOverridesOpenAIModel` precedence.
@@ -181,7 +184,7 @@ export function createMediaDispatchEngine(_required, optional = {}) {
181
184
  let renderer;
182
185
  let effectiveCredentials = credentials;
183
186
  if (def.provider === 'openai' && surface === 'image') {
184
- const customImageCredentials = options.credentials?.['custom-image'] ?? null;
187
+ const customImageCredentials = configuredCredentials['custom-image'] ?? null;
185
188
  const override = { ctx, credentials: customImageCredentials };
186
189
  if (customImageOverridesOpenAIModel(override)) {
187
190
  providerId = 'custom-image';
@@ -1,3 +1,34 @@
1
+ /**
2
+ * `createSqliteAsyncOperationStore` — the durable `AsyncOperationStore` adapter.
3
+ *
4
+ * `async-operation-store.ts` ships only `createInMemoryAsyncOperationStore`, so a process restart
5
+ * loses every in-flight submit-then-poll operation despite the store's own module doc describing
6
+ * it as the row that makes crash safety "fall out for free" — that guarantee only holds once a
7
+ * real durable adapter exists. This follows `sqlite-task-store.ts`'s established convention in
8
+ * this same package exactly, rather than inventing a parallel one: `new Database(dbPath)`,
9
+ * `db.pragma('journal_mode = WAL')`, `CREATE TABLE IF NOT EXISTS` (idempotent — reopening the same
10
+ * file resumes from whatever was durably committed), `db.transaction()` for atomic multi-statement
11
+ * writes, every public method still `Promise`-returning despite `better-sqlite3` being fully
12
+ * synchronous under the hood, a `close(): Promise<void>` addition beyond the port interface, and
13
+ * `better-sqlite3` dynamically imported (never at module scope) so a consumer wanting only the
14
+ * in-memory reference store never pays for loading the native binary.
15
+ *
16
+ * One deliberate departure from `sqlite-task-store.ts`'s own precedent: that file hand-copies its
17
+ * source port's transition table into a local `ALLOWED_TRANSITIONS` constant. This file instead
18
+ * imports `TERMINAL_STATUSES` and `assertTransition` from `async-operation-store.ts` — a second
19
+ * hand-maintained copy of this store's lease/terminal-status machinery is exactly the kind of
20
+ * mirror that drifts silently the next time the source of truth changes, and this store's lifecycle
21
+ * (five statuses, a `never leaves 'unknown'`/`'succeeded'`/`'failed'` terminal set, lease fencing)
22
+ * is materially more failure-sensitive than `MediaTaskStore`'s.
23
+ *
24
+ * `claimDue` is the one place this adapter is NOT a row-by-row translation of the in-memory
25
+ * reference: it is a single `UPDATE ... WHERE id IN (SELECT ... ORDER BY ... LIMIT ?) RETURNING *`
26
+ * statement — exactly the "single conditional UPDATE ... RETURNING" the in-memory store's own doc
27
+ * comment already promises a durable adapter would be. `RETURNING` needs the bundled
28
+ * `better-sqlite3` to embed SQLite >= 3.35; verified against this repo's pinned version before
29
+ * writing this file.
30
+ */
31
+ import type { SqliteSyncOpener } from '@jini-ai/db/sqlite';
1
32
  import type { AsyncOperationStore } from './async-operation-store.js';
2
33
  /** An `AsyncOperationStore` backed by a `better-sqlite3` database, plus a `close()` to release the file handle. */
3
34
  export interface SqliteAsyncOperationStore extends AsyncOperationStore {
@@ -12,7 +43,10 @@ export interface SqliteAsyncOperationStore extends AsyncOperationStore {
12
43
  * operation exactly as it was left, and `recoverAfterRestart`/`reconcileOnBoot` can then release
13
44
  * dead leases and expire blown deadlines.
14
45
  */
15
- export declare function createSqliteAsyncOperationStore({ dbPath }: {
46
+ export declare function createSqliteAsyncOperationStore({ dbPath, open: injectedOpen }: {
16
47
  dbPath: string;
48
+ open?: SqliteSyncOpener;
49
+ }, options?: {
50
+ open?: SqliteSyncOpener;
17
51
  }): Promise<SqliteAsyncOperationStore>;
18
52
  //# sourceMappingURL=sqlite-async-operation-store.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { loadMediaSqliteOpener } from '../sqlite-driver.adapter.js';
1
2
  import { ASYNC_OPERATION_SCHEMA_VERSION, ASYNC_OPERATION_STATUSES, assertNoCredentialMaterial, assertTransition, hydrateAsyncOperationRecord, TERMINAL_STATUSES, } from './async-operation-store.js';
2
3
  /**
3
4
  * The non-terminal ("live") status values — `ASYNC_OPERATION_STATUSES` minus `TERMINAL_STATUSES`,
@@ -44,9 +45,9 @@ function rowToOperation(row) {
44
45
  * operation exactly as it was left, and `recoverAfterRestart`/`reconcileOnBoot` can then release
45
46
  * dead leases and expire blown deadlines.
46
47
  */
47
- export async function createSqliteAsyncOperationStore({ dbPath }) {
48
- const { default: Database } = await import('better-sqlite3');
49
- const db = new Database(dbPath);
48
+ export async function createSqliteAsyncOperationStore({ dbPath, open: injectedOpen }, options = {}) {
49
+ const open = injectedOpen ?? options.open ?? await loadMediaSqliteOpener({});
50
+ const db = open(dbPath, {});
50
51
  db.pragma('journal_mode = WAL');
51
52
  db.exec(`
52
53
  CREATE TABLE IF NOT EXISTS jini_async_operations (
@@ -7,6 +7,40 @@
7
7
  * it ports as data. See `archived provenance ledger` for exactly what was dropped.
8
8
  */
9
9
  import type { AudioKind, MediaModel, MediaProvider, MediaSurface } from './types.js';
10
+ /** One adapter-owned endpoint catalog; protocols and UI presets project this data. */
11
+ export declare const VENDOR_API_BASE_URLS: {
12
+ readonly anthropic: "https://api.anthropic.com";
13
+ readonly openai: "https://api.openai.com/v1";
14
+ readonly azure: "";
15
+ readonly google: "https://generativelanguage.googleapis.com";
16
+ readonly openrouter: "https://openrouter.ai/api/v1";
17
+ readonly ollama: "http://localhost:11434/v1";
18
+ readonly volcengine: "https://ark.cn-beijing.volces.com/api/v3";
19
+ readonly grok: "https://api.x.ai/v1";
20
+ readonly imagerouter: "https://api.imagerouter.io/v1/openai";
21
+ readonly comfyui: "http://127.0.0.1:8188";
22
+ readonly bfl: "https://api.bfl.ai";
23
+ readonly fal: "https://fal.run";
24
+ readonly leonardo: "https://cloud.leonardo.ai/api/rest/v1";
25
+ readonly replicate: "https://api.replicate.com";
26
+ readonly minimax: "https://api.minimaxi.chat/v1";
27
+ readonly elevenlabs: "https://api.elevenlabs.io";
28
+ readonly fishaudio: "https://api.fish.audio";
29
+ readonly senseaudio: "https://api.senseaudio.cn";
30
+ readonly aihubmix: "https://aihubmix.com/v1";
31
+ readonly tavily: "https://api.tavily.com";
32
+ };
33
+ /** Old UI ids remain accepted at boundaries; canonical ids match the existing dispatch catalog. */
34
+ export declare const MEDIA_PROVIDER_ID_ALIASES: Readonly<Record<string, string>>;
35
+ /** Resolve legacy aliases without changing unknown extension IDs. @complexity O(1). */
36
+ export declare function canonicalMediaProviderId({ id }: {
37
+ id: string;
38
+ }, _optional?: Record<string, never>): string;
39
+ /** Canonical entries win conflicts, so an old alias can never replace a newer explicit edit.
40
+ * Returns a copy without changing supplied values or reading credentials. @complexity O(n) entries. */
41
+ export declare function normalizeMediaProviderMap<T>({ providers }: {
42
+ providers: Readonly<Record<string, T>>;
43
+ }, _optional?: Record<string, never>): Record<string, T>;
10
44
  export declare const MEDIA_PROVIDERS: readonly MediaProvider[];
11
45
  export declare const IMAGE_MODELS: readonly MediaModel[];
12
46
  export declare const VIDEO_MODELS: readonly MediaModel[];
@@ -1,26 +1,56 @@
1
+ /** One adapter-owned endpoint catalog; protocols and UI presets project this data. */
2
+ export const VENDOR_API_BASE_URLS = {
3
+ anthropic: 'https://api.anthropic.com', openai: 'https://api.openai.com/v1', azure: '',
4
+ google: 'https://generativelanguage.googleapis.com', openrouter: 'https://openrouter.ai/api/v1',
5
+ ollama: 'http://localhost:11434/v1', volcengine: 'https://ark.cn-beijing.volces.com/api/v3',
6
+ grok: 'https://api.x.ai/v1',
7
+ imagerouter: 'https://api.imagerouter.io/v1/openai', comfyui: 'http://127.0.0.1:8188',
8
+ bfl: 'https://api.bfl.ai', fal: 'https://fal.run', leonardo: 'https://cloud.leonardo.ai/api/rest/v1',
9
+ replicate: 'https://api.replicate.com', minimax: 'https://api.minimaxi.chat/v1',
10
+ elevenlabs: 'https://api.elevenlabs.io', fishaudio: 'https://api.fish.audio',
11
+ senseaudio: 'https://api.senseaudio.cn', aihubmix: 'https://aihubmix.com/v1', tavily: 'https://api.tavily.com',
12
+ };
13
+ /** Old UI ids remain accepted at boundaries; canonical ids match the existing dispatch catalog. */
14
+ export const MEDIA_PROVIDER_ID_ALIASES = {
15
+ 'nano-banana': 'nanobanana', 'custom-image-api': 'custom-image', 'fal-ai': 'fal',
16
+ 'leonardo-ai': 'leonardo', 'tavily-search': 'tavily', 'volcengine-ark': 'volcengine', 'xai-grok-imagine': 'grok',
17
+ };
18
+ /** Resolve legacy aliases without changing unknown extension IDs. @complexity O(1). */
19
+ export function canonicalMediaProviderId({ id }, _optional = {}) {
20
+ return Object.prototype.hasOwnProperty.call(MEDIA_PROVIDER_ID_ALIASES, id) ? MEDIA_PROVIDER_ID_ALIASES[id] : id;
21
+ }
22
+ /** Canonical entries win conflicts, so an old alias can never replace a newer explicit edit.
23
+ * Returns a copy without changing supplied values or reading credentials. @complexity O(n) entries. */
24
+ export function normalizeMediaProviderMap({ providers }, _optional = {}) {
25
+ const entries = Object.entries(providers);
26
+ return Object.fromEntries([
27
+ ...entries.filter(([id]) => canonicalMediaProviderId({ id }) !== id).map(([id, value]) => [canonicalMediaProviderId({ id }), value]),
28
+ ...entries.filter(([id]) => canonicalMediaProviderId({ id }) === id),
29
+ ]);
30
+ }
1
31
  export const MEDIA_PROVIDERS = [
2
- { id: 'openai', label: 'OpenAI', hint: 'gpt-image-2 / dall-e-3', integrated: true, defaultBaseUrl: 'https://api.openai.com/v1' },
3
- { id: 'volcengine', label: 'Volcengine Ark (Doubao)', hint: 'Seedance 2.0 / Seedream', integrated: true, defaultBaseUrl: 'https://ark.cn-beijing.volces.com/api/v3' },
4
- { id: 'grok', label: 'xAI Grok Imagine', hint: 'grok-imagine — image + video with native audio', integrated: true, defaultBaseUrl: 'https://api.x.ai/v1' },
32
+ { id: 'openai', label: 'OpenAI', hint: 'gpt-image-2 / dall-e-3', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.openai },
33
+ { id: 'volcengine', label: 'Volcengine Ark (Doubao)', hint: 'Seedance 2.0 / Seedream', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.volcengine },
34
+ { id: 'grok', label: 'xAI Grok Imagine', hint: 'grok-imagine — image + video with native audio', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.grok },
5
35
  { id: 'hyperframes', label: 'HyperFrames', hint: 'Local HTML -> MP4 renderer', integrated: false, credentialsRequired: false, settingsVisible: false },
6
- { id: 'nanobanana', label: 'Nano Banana', hint: 'Google official by default; custom gateway configurable', integrated: true, defaultBaseUrl: 'https://generativelanguage.googleapis.com', supportsCustomModel: true },
7
- { id: 'imagerouter', label: 'ImageRouter', hint: 'OpenAI-compatible image + video routing', integrated: true, defaultBaseUrl: 'https://api.imagerouter.io/v1/openai', docsUrl: 'https://docs.imagerouter.io/api-reference/image-generation/', supportsCustomModel: true, customModelPlaceholder: 'openai/gpt-image-2 or xAI/grok-imagine-video' },
8
- { id: 'openrouter', label: 'OpenRouter', hint: 'Unified gateway for image + video models', integrated: true, credentialsRequired: true, settingsVisible: true, defaultBaseUrl: 'https://openrouter.ai/api/v1', docsUrl: 'https://openrouter.ai/settings/keys' },
36
+ { id: 'nanobanana', label: 'Nano Banana', hint: 'Google official by default; custom gateway configurable', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.google, supportsCustomModel: true },
37
+ { id: 'imagerouter', label: 'ImageRouter', hint: 'OpenAI-compatible image + video routing', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.imagerouter, docsUrl: 'https://docs.imagerouter.io/api-reference/image-generation/', supportsCustomModel: true, customModelPlaceholder: 'openai/gpt-image-2 or xAI/grok-imagine-video' },
38
+ { id: 'openrouter', label: 'OpenRouter', hint: 'Unified gateway for image + video models', integrated: true, credentialsRequired: true, settingsVisible: true, defaultBaseUrl: VENDOR_API_BASE_URLS.openrouter, docsUrl: 'https://openrouter.ai/settings/keys' },
9
39
  { id: 'custom-image', label: 'Custom Media API', hint: 'OpenAI-compatible images/generations + images/edits (local or cloud)', integrated: true, docsUrl: 'https://platform.openai.com/docs/api-reference/images', supportsCustomModel: true, customModelPlaceholder: 'my-image-model' },
10
- { id: 'comfyui', label: 'ComfyUI', hint: 'Local JSON workflow server (planned adapter)', integrated: false, defaultBaseUrl: 'http://127.0.0.1:8188', docsUrl: 'https://docs.comfy.org/development/core-concepts/workflow' },
11
- { id: 'bfl', label: 'Black Forest Labs', hint: 'FLUX 1.1 Pro / FLUX Pro / Dev', integrated: false, defaultBaseUrl: 'https://api.bfl.ai' },
12
- { id: 'fal', label: 'Fal.ai', hint: 'FLUX / Sora / Veo / Wan / Ideogram / Recraft and any fal-ai/* model', integrated: false, defaultBaseUrl: 'https://fal.run', supportsCustomModel: true },
13
- { id: 'leonardo', label: 'Leonardo.ai', hint: 'Phoenix / Kino XL / FLUX', integrated: false, credentialsRequired: true, settingsVisible: true, defaultBaseUrl: 'https://cloud.leonardo.ai/api/rest/v1' },
14
- { id: 'replicate', label: 'Replicate', hint: 'FLUX / SDXL / Ideogram', integrated: false, defaultBaseUrl: 'https://api.replicate.com' },
40
+ { id: 'comfyui', label: 'ComfyUI', hint: 'Local JSON workflow server (planned adapter)', integrated: false, defaultBaseUrl: VENDOR_API_BASE_URLS.comfyui, docsUrl: 'https://docs.comfy.org/development/core-concepts/workflow' },
41
+ { id: 'bfl', label: 'Black Forest Labs', hint: 'FLUX 1.1 Pro / FLUX Pro / Dev', integrated: false, defaultBaseUrl: VENDOR_API_BASE_URLS.bfl },
42
+ { id: 'fal', label: 'Fal.ai', hint: 'FLUX / Sora / Veo / Wan / Ideogram / Recraft and any fal-ai/* model', integrated: false, defaultBaseUrl: VENDOR_API_BASE_URLS.fal, supportsCustomModel: true },
43
+ { id: 'leonardo', label: 'Leonardo.ai', hint: 'Phoenix / Kino XL / FLUX', integrated: false, credentialsRequired: true, settingsVisible: true, defaultBaseUrl: VENDOR_API_BASE_URLS.leonardo },
44
+ { id: 'replicate', label: 'Replicate', hint: 'FLUX / SDXL / Ideogram', integrated: false, defaultBaseUrl: VENDOR_API_BASE_URLS.replicate },
15
45
  { id: 'google', label: 'Google AI / Vertex', hint: 'Imagen 4 / Veo 3 / Lyria', integrated: false },
16
46
  { id: 'kling', label: 'Kuaishou Kling', hint: 'Kling 1.6 / 2.0 video', integrated: false },
17
47
  { id: 'midjourney', label: 'Midjourney (proxy)', hint: 'midjourney-v7', integrated: false },
18
- { id: 'minimax', label: 'MiniMax', hint: 'TTS / video-01', integrated: true, defaultBaseUrl: 'https://api.minimaxi.chat/v1' },
48
+ { id: 'minimax', label: 'MiniMax', hint: 'TTS / video-01', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.minimax },
19
49
  { id: 'suno', label: 'Suno', hint: 'Music generation', integrated: false },
20
50
  { id: 'udio', label: 'Udio', hint: 'Music generation', integrated: false },
21
- { id: 'elevenlabs', label: 'ElevenLabs', hint: 'Voice / SFX', integrated: true, defaultBaseUrl: 'https://api.elevenlabs.io', docsUrl: 'https://elevenlabs.io/app/settings/api-keys' },
22
- { id: 'fishaudio', label: 'FishAudio', hint: 'Speech / voice clone', integrated: true, defaultBaseUrl: 'https://api.fish.audio' },
23
- { id: 'senseaudio', label: 'SenseAudio', hint: '', integrated: true, defaultBaseUrl: 'https://api.senseaudio.cn', docsUrl: 'https://docs.senseaudio.cn' },
51
+ { id: 'elevenlabs', label: 'ElevenLabs', hint: 'Voice / SFX', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.elevenlabs, docsUrl: 'https://elevenlabs.io/app/settings/api-keys' },
52
+ { id: 'fishaudio', label: 'FishAudio', hint: 'Speech / voice clone', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.fishaudio },
53
+ { id: 'senseaudio', label: 'SenseAudio', hint: '', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.senseaudio, docsUrl: 'https://docs.senseaudio.cn' },
24
54
  {
25
55
  id: 'aihubmix',
26
56
  label: 'AIHubMix',
@@ -28,12 +58,12 @@ export const MEDIA_PROVIDERS = [
28
58
  integrated: true,
29
59
  credentialsRequired: true,
30
60
  settingsVisible: true,
31
- defaultBaseUrl: 'https://aihubmix.com/v1',
61
+ defaultBaseUrl: VENDOR_API_BASE_URLS.aihubmix,
32
62
  docsUrl: 'https://docs.aihubmix.com',
33
63
  supportsCustomModel: true,
34
64
  customModelPlaceholder: 'gpt-image-2 or dall-e-3',
35
65
  },
36
- { id: 'tavily', label: 'Tavily Search', hint: 'Agent-callable web research', integrated: true, defaultBaseUrl: 'https://api.tavily.com' },
66
+ { id: 'tavily', label: 'Tavily Search', hint: 'Agent-callable web research', integrated: true, defaultBaseUrl: VENDOR_API_BASE_URLS.tavily },
37
67
  { id: 'stub', label: 'Stub (placeholder)', hint: 'Deterministic local placeholder bytes', integrated: true },
38
68
  ];
39
69
  export const IMAGE_MODELS = [
@@ -152,7 +182,7 @@ export function findMediaModel({ id }) {
152
182
  }
153
183
  /** Finds a provider by id in `MEDIA_PROVIDERS`. */
154
184
  export function findProvider({ id }) {
155
- return MEDIA_PROVIDERS.find((p) => p.id === id) ?? null;
185
+ return MEDIA_PROVIDERS.find((p) => p.id === canonicalMediaProviderId({ id })) ?? null;
156
186
  }
157
187
  /** Returns the model list for a surface; `audioKind` selects which audio sub-list (defaults to `'music'`). */
158
188
  export function modelsForSurface({ surface }, { audioKind } = {}) {
@@ -0,0 +1,4 @@
1
+ /** Native compatibility adapter, loaded only when a host did not inject its own SQLite opener. */
2
+ import type { SqliteSyncOpener } from '@jini-ai/db/sqlite';
3
+ export declare function loadMediaSqliteOpener(_required: Record<string, never>, _optional?: Record<string, never>): Promise<SqliteSyncOpener>;
4
+ //# sourceMappingURL=sqlite-driver.adapter.d.ts.map
@@ -0,0 +1,5 @@
1
+ export async function loadMediaSqliteOpener(_required, _optional = {}) {
2
+ const { default: Database } = await import('better-sqlite3');
3
+ return (file, options) => new Database(file, options);
4
+ }
5
+ //# sourceMappingURL=sqlite-driver.adapter.js.map
@@ -1,3 +1,45 @@
1
+ /**
2
+ * `createSqliteMediaTaskStore` — the durable `MediaTaskStore` adapter
3
+ * (added 2026-07-21, per the task brief's "durable task adapter" ask: many
4
+ * ported vendors are async submit-then-poll jobs, so a job's state must
5
+ * survive a process restart).
6
+ *
7
+ * Reuses this repo's existing durability pattern exactly —
8
+ * `packages/sqlite/src/event-log.ts`'s `createSqliteEventLog`, the durable
9
+ * adapter for `@jini-ai/daemon`'s `EventLog` port — rather than inventing a
10
+ * parallel one: `new Database(dbPath)`, `db.pragma('journal_mode = WAL')`,
11
+ * `CREATE TABLE IF NOT EXISTS` (idempotent — reopening the same file
12
+ * resumes from whatever was durably committed), `db.transaction()` for
13
+ * atomic multi-statement writes, every public method still `Promise`-
14
+ * returning despite `better-sqlite3` being fully synchronous under the
15
+ * hood (extraction-plan.md §2.6: "ports are async-only from day one... a
16
+ * real persistent adapter is a drop-in swap"), and a `close(): Promise<void>`
17
+ * addition beyond the port interface to release the file handle — the same
18
+ * shape `SqliteEventLog extends EventLog` already established.
19
+ *
20
+ * **Why this lives in `@jini-ai/media` itself, not `@jini-ai/sqlite-chat`** (the
21
+ * "natural" home per the `EventLog` precedent, where the durable adapter
22
+ * lives in a separate package from the port it implements): `@jini-ai/sqlite-chat`
23
+ * is one of `scripts/check-engine-boundaries.ts`'s 14 *locked* packages;
24
+ * `@jini-ai/media` is listed in `UNLOCKED.md` with `status: "incubating"`.
25
+ * `check-engine-boundaries.ts`'s R7 rule forbids a locked package from
26
+ * importing an unlocked, non-`"stable"` one — `@jini-ai/sqlite-chat` depending on
27
+ * `@jini-ai/media` for `MediaTaskStore`'s types would fail `pnpm guard`
28
+ * outright. Implementing the adapter inside `@jini-ai/media` (itself
29
+ * unlocked, so unrestricted in what it may depend on) keeps the exact same
30
+ * schema/transaction/WAL/`close()` conventions without a guard violation.
31
+ * See `ADS-memory/reports/proposals/PROP-media-durable-tasks-2026-07-21.md`
32
+ * for the open question of whether this should move to `@jini-ai/sqlite-chat` once
33
+ * `@jini-ai/media` is promoted to `"stable"`.
34
+ *
35
+ * Implements `task-store.ts`'s `MediaTaskStore` port exactly: same
36
+ * `queued -> running -> done|failed|interrupted` transition legality
37
+ * (`ALLOWED_TRANSITIONS`), same duplicate-id rejection, same
38
+ * `listByOwner` terminal-status filtering, same `reconcileOnBoot`
39
+ * two-phase boot reconciliation. See `createInMemoryMediaTaskStore` in
40
+ * `task-store.ts` for the reference behavior this mirrors.
41
+ */
42
+ import type { SqliteSyncOpener } from '@jini-ai/db/sqlite';
1
43
  import type { MediaTaskStore } from './task-store.js';
2
44
  /** A `MediaTaskStore` backed by a `better-sqlite3` database, plus a `close()` to release the file handle. */
3
45
  export interface SqliteMediaTaskStore extends MediaTaskStore {
@@ -15,7 +57,8 @@ export interface SqliteMediaTaskStore extends MediaTaskStore {
15
57
  * `reconcileOnBoot` can then mark anything still `queued`/`running` as
16
58
  * `interrupted`.
17
59
  *
18
- * `better-sqlite3` (a native compiled addon) is dynamically imported here
60
+ * `better-sqlite3` (a native compiled addon) is dynamically imported by the default
61
+ * adapter only when no host opener is supplied
19
62
  * rather than statically at module scope (mirroring `@jini-ai/daemon`'s
20
63
  * `loadRealSpawnPty`/`node-pty` pattern) — this package's root barrel
21
64
  * re-exports this module unconditionally, so a static top-level import would
@@ -25,5 +68,10 @@ export interface SqliteMediaTaskStore extends MediaTaskStore {
25
68
  * fails cleanly (a rejected promise) rather than crashing unrelated imports
26
69
  * if the platform/environment lacks a usable prebuild.
27
70
  */
28
- export declare function createSqliteMediaTaskStore(dbPath: string): Promise<SqliteMediaTaskStore>;
71
+ export declare function createSqliteMediaTaskStore(required: {
72
+ dbPath: string;
73
+ open?: SqliteSyncOpener;
74
+ } | string, options?: {
75
+ open?: SqliteSyncOpener;
76
+ }): Promise<SqliteMediaTaskStore>;
29
77
  //# sourceMappingURL=sqlite-task-store.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { loadMediaSqliteOpener } from './sqlite-driver.adapter.js';
1
2
  const VALID_STATUSES = new Set([
2
3
  'queued',
3
4
  'running',
@@ -60,7 +61,8 @@ function rowToTask(row) {
60
61
  * `reconcileOnBoot` can then mark anything still `queued`/`running` as
61
62
  * `interrupted`.
62
63
  *
63
- * `better-sqlite3` (a native compiled addon) is dynamically imported here
64
+ * `better-sqlite3` (a native compiled addon) is dynamically imported by the default
65
+ * adapter only when no host opener is supplied
64
66
  * rather than statically at module scope (mirroring `@jini-ai/daemon`'s
65
67
  * `loadRealSpawnPty`/`node-pty` pattern) — this package's root barrel
66
68
  * re-exports this module unconditionally, so a static top-level import would
@@ -70,9 +72,11 @@ function rowToTask(row) {
70
72
  * fails cleanly (a rejected promise) rather than crashing unrelated imports
71
73
  * if the platform/environment lacks a usable prebuild.
72
74
  */
73
- export async function createSqliteMediaTaskStore(dbPath) {
74
- const { default: Database } = await import('better-sqlite3');
75
- const db = new Database(dbPath);
75
+ export async function createSqliteMediaTaskStore(required, options = {}) {
76
+ // The string overload remains for published callers; new hosts supply an argument object.
77
+ const dbPath = typeof required === 'string' ? required : required.dbPath;
78
+ const open = (typeof required === 'string' ? undefined : required.open) ?? options.open ?? await loadMediaSqliteOpener({});
79
+ const db = open(dbPath, {});
76
80
  db.pragma('journal_mode = WAL');
77
81
  db.exec(`
78
82
  CREATE TABLE IF NOT EXISTS jini_media_tasks (
@@ -44,7 +44,7 @@ export interface UpdateSubscriptionRequired {
44
44
  deps: WebhookSubscriptionDeps;
45
45
  input: UpdateSubscriptionInput;
46
46
  }
47
- /** Validate a replacement before saving; missing workspace-scoped rows throw. */
47
+ /** Validate a replacement before saving; missing or soft-deleted workspace-scoped rows throw. */
48
48
  export declare function updateSubscription(required: UpdateSubscriptionRequired, _optional?: WebhookSubscriptionOptional): Promise<{
49
49
  subscription: WebhookSubscriptionRecord;
50
50
  }>;
@@ -39,13 +39,17 @@ export async function createSubscription(required, optional = {}) {
39
39
  await deps.repo.insert(subscription);
40
40
  return { subscription };
41
41
  }
42
- /** Validate a replacement before saving; missing workspace-scoped rows throw. */
42
+ /** Validate a replacement before saving; missing or soft-deleted workspace-scoped rows throw. */
43
43
  export async function updateSubscription(required, _optional = {}) {
44
44
  const { deps, input } = required;
45
45
  const existing = await deps.repo.findById({ workspaceId: input.workspaceId, id: input.id });
46
46
  if (!existing) {
47
47
  throw new WebhookSubscriptionNotFoundError({ message: `webhook subscription '${input.id}' was not found` });
48
48
  }
49
+ // Soft deletion is terminal: an update must preserve the disabled row's audit history.
50
+ if (existing.status === "disabled") {
51
+ throw new WebhookSubscriptionValidationError({ message: `webhook subscription '${input.id}' is disabled (deleted) and cannot be updated` });
52
+ }
49
53
  const label = input.label.trim();
50
54
  if (!label)
51
55
  throw new WebhookSubscriptionValidationError({ message: "label is required" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/integrations",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Third-party vendor integrations and outbound services, each independently importable: media generation, credentialed HTTP and webhooks.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -76,13 +76,17 @@
76
76
  "registry": "https://registry.npmjs.org"
77
77
  },
78
78
  "dependencies": {
79
- "@jini-ai/core": "^0.4.2"
79
+ "@jini-ai/core": "^0.4.3"
80
80
  },
81
81
  "peerDependencies": {
82
+ "@jini-ai/db": "^0.3.0",
82
83
  "better-sqlite3": "^13.0.0",
83
84
  "@jini-ai/platform": "^0.5.1"
84
85
  },
85
86
  "peerDependenciesMeta": {
87
+ "@jini-ai/db": {
88
+ "optional": true
89
+ },
86
90
  "better-sqlite3": {
87
91
  "optional": true
88
92
  },
@@ -94,9 +98,10 @@
94
98
  "@types/better-sqlite3": "^7.6.11",
95
99
  "better-sqlite3": "^13.0.0",
96
100
  "@vitest/coverage-v8": "^2.1.9",
97
- "@jini-ai/core": "0.4.2",
98
- "@jini-ai/platform": "0.5.2",
99
- "@jini-ai/agent-plugins": "0.4.2"
101
+ "@jini-ai/db": "^0.3.2",
102
+ "@jini-ai/core": "0.4.3",
103
+ "@jini-ai/agent-plugins": "0.4.3",
104
+ "@jini-ai/platform": "0.5.3"
100
105
  },
101
106
  "scripts": {
102
107
  "build": "tsc -p tsconfig.json",
@@ -1,36 +0,0 @@
1
- import type { JsonValue } from '@jini-ai/protocol';
2
- export declare const COMPOSIO_MAX_RESPONSE_BYTES: number;
3
- export declare const COMPOSIO_MAX_ERROR_RESPONSE_BYTES: number;
4
- export declare const COMPOSIO_MAX_CACHE_BYTES: number;
5
- export declare const COMPOSIO_MAX_SECRET_STORE_BYTES: number;
6
- export interface JsonStructureLimits {
7
- maxDepth: number;
8
- maxNodes: number;
9
- maxArrayItems: number;
10
- maxObjectKeys: number;
11
- maxStringBytes: number;
12
- }
13
- export declare const COMPOSIO_REMOTE_JSON_LIMITS: JsonStructureLimits;
14
- export declare class BoundedDataError extends Error {
15
- constructor(message: string);
16
- }
17
- /** Reads at most `maxBytes` from a response body before allocating/decoding it. */
18
- export declare function readBoundedResponseText(response: Response, maxBytes: number, label?: string): Promise<string>;
19
- /** Reads and parses a response body only after its byte size is bounded. */
20
- export declare function readBoundedResponseJson(response: Response, maxBytes?: number, label?: string): Promise<unknown>;
21
- /** Reads a local UTF-8 file without allowing it to grow past `maxBytes`. */
22
- export declare function readBoundedUtf8File(filePath: string, maxBytes: number): string;
23
- /**
24
- * Opens a secret-bearing regular file without following its final symlink,
25
- * enforces owner-only mode on the opened inode, and reads it within a byte cap.
26
- *
27
- * @complexity Time: O(n). Space: O(n), where n is capped by `maxBytes`.
28
- * @overallScore 100/100
29
- */
30
- export declare function readPrivateBoundedUtf8File(filePath: string, maxBytes: number): string;
31
- /**
32
- * Converts an unknown value into JSON while enforcing depth, node, collection,
33
- * and string bounds before recursive copies are allocated.
34
- */
35
- export declare function toStructurallyBoundedJsonValue(value: unknown, limits?: JsonStructureLimits): JsonValue;
36
- //# sourceMappingURL=bounded-data.d.ts.map