@jini-ai/integrations 0.6.15-rc.1 → 0.6.15-rc.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.
@@ -4,6 +4,20 @@ import type { MediaGenerationRequestInit, MediaSpeechFormat, RenderContext } fro
4
4
  export declare const OPENAI_TTS_VOICES: ReadonlySet<string>;
5
5
  /** Validates a caller-requested speech format, defaulting to `'mp3'` for anything unrecognized. */
6
6
  export declare function resolveSpeechFormat(requested: MediaSpeechFormat | undefined): MediaSpeechFormat;
7
+ /**
8
+ * OpenRouter normalizes aspect ratios across the providers it fronts;
9
+ * `providers.ts`'s `MEDIA_ASPECTS` are all natively supported. xAI's Imagine
10
+ * API accepts a wider list (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2,
11
+ * 19.5:9, 9:19.5, 20:9, 9:20, auto), of which `MEDIA_ASPECTS` is a strict
12
+ * subset. Both mappings pass through the same five values and default to 16:9.
13
+ * Written as independent `if` returns (rather than the origin's one
14
+ * `||`-chained condition) to match the established aspect-mapping style
15
+ * (see `providers/imagerouter.ts`'s `imageRouterSizeFor`) — same input ->
16
+ * output mapping for every case, not a behavior change.
17
+ */
18
+ export declare function standardImageAspectFor({ aspect }: {
19
+ aspect: string | undefined;
20
+ }, _options?: Record<string, never>): string;
7
21
  /** Truncates a string for inclusion in an error message, appending an ellipsis when truncated. */
8
22
  export declare function truncate(s: unknown, n: number): string;
9
23
  /** Merges a per-request `requestInit` (e.g. a caller-supplied `dispatcher`) under an explicit `init`, so per-call overrides win. */
@@ -14,6 +14,30 @@ export const OPENAI_TTS_VOICES = new Set(['alloy', 'ash', 'ballad', 'coral', 'ec
14
14
  export function resolveSpeechFormat(requested) {
15
15
  return requested && VALID_SPEECH_FORMATS.has(requested) ? requested : 'mp3';
16
16
  }
17
+ /**
18
+ * OpenRouter normalizes aspect ratios across the providers it fronts;
19
+ * `providers.ts`'s `MEDIA_ASPECTS` are all natively supported. xAI's Imagine
20
+ * API accepts a wider list (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2,
21
+ * 19.5:9, 9:19.5, 20:9, 9:20, auto), of which `MEDIA_ASPECTS` is a strict
22
+ * subset. Both mappings pass through the same five values and default to 16:9.
23
+ * Written as independent `if` returns (rather than the origin's one
24
+ * `||`-chained condition) to match the established aspect-mapping style
25
+ * (see `providers/imagerouter.ts`'s `imageRouterSizeFor`) — same input ->
26
+ * output mapping for every case, not a behavior change.
27
+ */
28
+ export function standardImageAspectFor({ aspect }, _options = {}) {
29
+ if (aspect === '1:1')
30
+ return '1:1';
31
+ if (aspect === '16:9')
32
+ return '16:9';
33
+ if (aspect === '9:16')
34
+ return '9:16';
35
+ if (aspect === '4:3')
36
+ return '4:3';
37
+ if (aspect === '3:4')
38
+ return '3:4';
39
+ return '16:9';
40
+ }
17
41
  /** Truncates a string for inclusion in an error message, appending an ellipsis when truncated. */
18
42
  export function truncate(s, n) {
19
43
  const v = String(s || '');
@@ -1,18 +1,45 @@
1
- import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
2
- import type { VendorAdapterRegistry } from '../vendor-registry-core.js';
3
1
  /**
4
- * xAI's Imagine API accepts a wide list of aspect ratios (1:1, 16:9, 9:16,
5
- * 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 19.5:9, 9:19.5, 20:9, 9:20, auto) —
6
- * `providers.ts`'s `MEDIA_ASPECTS` is a strict subset, so a recognized
7
- * value passes through and anything else defaults to 16:9. Written as
8
- * independent `if` returns (rather than the origin's one `||`-chained
9
- * condition) to match this package's established aspect-mapping style
10
- * (see `imagerouter.ts`'s `imageRouterSizeFor`) — same input -> output
11
- * mapping for every case, not a behavior change.
2
+ * Provider: xAI Grok — image generation via an OpenAI-images-compatible
3
+ * `/images/generations` endpoint (`renderGrokImage`), plus text-to-speech
4
+ * via a dedicated `/tts` endpoint (`renderXAITTS`). Ported near-verbatim
5
+ * from Open Design's `apps/daemon/src/media/index.ts` `renderGrokImage`/
6
+ * `renderXAITTS` — see `archived provenance ledger`.
7
+ *
8
+ * Image response shape (`{ data: [{ b64_json | url }] }`) is identical to
9
+ * OpenAI's images API, so `renderGrokImage` routes through
10
+ * `openai-compatible.ts`'s already-ported JSON-parsing/byte-extraction/
11
+ * URL-building helpers rather than re-implementing them. `/tts` is xAI's
12
+ * own dedicated endpoint (not the OpenAI `/audio/speech` shape) — it
13
+ * returns raw audio bytes directly from a plain JSON POST, with no
14
+ * per-request format negotiation the caller can control, so `renderXAITTS`
15
+ * doesn't route through `openai-compatible.ts` at all (only the generic
16
+ * `truncate`/`withRequestInit` helpers are shared).
17
+ *
18
+ * Dropped from the origin's no-credential error messages (both
19
+ * functions): the OD-specific "sign in with your SuperGrok subscription
20
+ * (in OD or via `hermes auth add xai-oauth`)" OAuth guidance — this
21
+ * package has no OAuth chain or local-CLI-login concept; credentials are
22
+ * always host-injected (see `types.ts`'s `ProviderCredentials`), matching
23
+ * every other ported provider's error-message style (e.g. `openai.ts`'s
24
+ * `OPENAI_IMAGE_NO_CREDENTIAL_MESSAGE`).
25
+ *
26
+ * 2026-07-21: migrated onto the generic vendor-adapter dispatch engine
27
+ * (`vendor-adapter.ts`/`vendor-registry.ts`) — two adapters registered on
28
+ * the same `grok` provider id (`image`/`audio:speech`). External behavior
29
+ * is unchanged (verified against `grok.test.ts`, which asserts URL/body/
30
+ * header/error-message/providerNote shape and passes unmodified) — only
31
+ * the internal implementation moved. The image adapter is not routed
32
+ * through `response-parsers.ts`'s factories (reuses
33
+ * `openai-compatible.ts`'s JSON-parsing helpers directly, same as before —
34
+ * see `imagerouter.ts`'s module doc for the identical reasoning); the TTS
35
+ * adapter's response (raw bytes, no envelope) is the same shape
36
+ * `fishaudio.ts`/`openai.ts`'s speech renderer return, so it now shares
37
+ * `response-parsers.ts`'s `createRawBytesParser`.
12
38
  */
13
- export declare function grokAspectFor({ aspect }: {
14
- aspect: string | undefined;
15
- }): string;
39
+ import { standardImageAspectFor as grokAspectFor } from '../openai-compatible.js';
40
+ import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
41
+ import type { VendorAdapterRegistry } from '../vendor-registry-core.js';
42
+ export { grokAspectFor };
16
43
  export declare function renderGrokImage({ ctx, credentials }: {
17
44
  ctx: RenderContext;
18
45
  credentials: ProviderCredentials;
@@ -36,32 +36,10 @@
36
36
  * `fishaudio.ts`/`openai.ts`'s speech renderer return, so it now shares
37
37
  * `response-parsers.ts`'s `createRawBytesParser`.
38
38
  */
39
- import { buildOpenAIImageUrl, bytesFromOpenAICompatibleData, parseOpenAICompatibleJson, sniffImageExt, withRequestInit } from '../openai-compatible.js';
39
+ import { buildOpenAIImageUrl, bytesFromOpenAICompatibleData, parseOpenAICompatibleJson, sniffImageExt, standardImageAspectFor as grokAspectFor, withRequestInit } from '../openai-compatible.js';
40
40
  import { createRawBytesParser } from '../response-parsers.js';
41
41
  import { dispatchVendorRequest, requireApiKey } from '../vendor-adapter.js';
42
- /**
43
- * xAI's Imagine API accepts a wide list of aspect ratios (1:1, 16:9, 9:16,
44
- * 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 19.5:9, 9:19.5, 20:9, 9:20, auto) —
45
- * `providers.ts`'s `MEDIA_ASPECTS` is a strict subset, so a recognized
46
- * value passes through and anything else defaults to 16:9. Written as
47
- * independent `if` returns (rather than the origin's one `||`-chained
48
- * condition) to match this package's established aspect-mapping style
49
- * (see `imagerouter.ts`'s `imageRouterSizeFor`) — same input -> output
50
- * mapping for every case, not a behavior change.
51
- */
52
- export function grokAspectFor({ aspect }) {
53
- if (aspect === '1:1')
54
- return '1:1';
55
- if (aspect === '16:9')
56
- return '16:9';
57
- if (aspect === '9:16')
58
- return '9:16';
59
- if (aspect === '4:3')
60
- return '4:3';
61
- if (aspect === '3:4')
62
- return '3:4';
63
- return '16:9';
64
- }
42
+ export { grokAspectFor };
65
43
  const NO_CREDENTIAL_MESSAGE = 'no xAI credential — configure an API key or set XAI_API_KEY.';
66
44
  const grokImageAdapter = {
67
45
  requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
@@ -1,17 +1,7 @@
1
+ import { standardImageAspectFor as openRouterAspectFor } from '../openai-compatible.js';
1
2
  import type { ProviderCredentials, RenderContext, RenderResult } from '../types.js';
2
3
  import type { VendorAdapterRegistry } from '../vendor-registry-core.js';
3
- /**
4
- * OpenRouter normalizes aspect ratios across the providers it fronts;
5
- * `providers.ts`'s `MEDIA_ASPECTS` are all natively supported, default to
6
- * 16:9 for anything else. Written as independent `if` returns (rather than
7
- * the origin's one `||`-chained condition) to match this package's
8
- * established aspect-mapping style (see `imagerouter.ts`'s
9
- * `imageRouterSizeFor`) — same input -> output mapping for every case, not
10
- * a behavior change.
11
- */
12
- export declare function openRouterAspectFor({ aspect }: {
13
- aspect: string | undefined;
14
- }): string;
4
+ export { openRouterAspectFor };
15
5
  export declare function renderOpenRouterImage({ ctx, credentials }: {
16
6
  ctx: RenderContext;
17
7
  credentials: ProviderCredentials;
@@ -31,35 +31,14 @@
31
31
  * `parseResponse`.
32
32
  */
33
33
  import { assertAndFetchExternalAsset } from '../ssrf-guard.js';
34
- import { sniffImageExt, truncate, withRequestInit } from '../openai-compatible.js';
34
+ import { sniffImageExt, standardImageAspectFor as openRouterAspectFor, truncate, withRequestInit } from '../openai-compatible.js';
35
35
  import { dispatchVendorRequest, requireApiKey } from '../vendor-adapter.js';
36
36
  // Chat-completions image generation can take a while for some routed
37
37
  // models; matches the same 10-minute ceiling `openai.ts`'s image dispatcher
38
38
  // uses for the same reason (see `OPENAI_IMAGE_TIMEOUT_MS` there — a single
39
39
  // `AbortSignal.timeout` covers the whole request for both vendors).
40
40
  const OPENROUTER_IMAGE_TIMEOUT_MS = 10 * 60 * 1000;
41
- /**
42
- * OpenRouter normalizes aspect ratios across the providers it fronts;
43
- * `providers.ts`'s `MEDIA_ASPECTS` are all natively supported, default to
44
- * 16:9 for anything else. Written as independent `if` returns (rather than
45
- * the origin's one `||`-chained condition) to match this package's
46
- * established aspect-mapping style (see `imagerouter.ts`'s
47
- * `imageRouterSizeFor`) — same input -> output mapping for every case, not
48
- * a behavior change.
49
- */
50
- export function openRouterAspectFor({ aspect }) {
51
- if (aspect === '1:1')
52
- return '1:1';
53
- if (aspect === '16:9')
54
- return '16:9';
55
- if (aspect === '9:16')
56
- return '9:16';
57
- if (aspect === '4:3')
58
- return '4:3';
59
- if (aspect === '3:4')
60
- return '3:4';
61
- return '16:9';
62
- }
41
+ export { openRouterAspectFor };
63
42
  const NO_CREDENTIAL_MESSAGE = 'no OpenRouter API key — configure it or set OPENROUTER_API_KEY';
64
43
  const openRouterImageAdapter = {
65
44
  requireCredential: requireApiKey({ message: NO_CREDENTIAL_MESSAGE }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/integrations",
3
- "version": "0.6.15-rc.1",
3
+ "version": "0.6.15-rc.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": {
@@ -103,13 +103,13 @@
103
103
  "registry": "https://registry.npmjs.org"
104
104
  },
105
105
  "dependencies": {
106
- "@jini-ai/core": "^0.6.15-rc.1"
106
+ "@jini-ai/core": "^0.6.15-rc.2"
107
107
  },
108
108
  "peerDependencies": {
109
- "@jini-ai/db": "^0.6.15-rc.1",
109
+ "@jini-ai/db": "^0.6.15-rc.2",
110
110
  "better-sqlite3": "^13.0.0",
111
- "@jini-ai/platform": "^0.6.15-rc.1",
112
- "@jini-ai/oauth": "^0.6.15-rc.1",
111
+ "@jini-ai/platform": "^0.6.15-rc.2",
112
+ "@jini-ai/oauth": "^0.6.15-rc.2",
113
113
  "@cfworker/json-schema": "^4.1.1"
114
114
  },
115
115
  "peerDependenciesMeta": {
@@ -134,11 +134,11 @@
134
134
  "better-sqlite3": "^13.0.0",
135
135
  "@vitest/coverage-v8": "^2.1.9",
136
136
  "@cfworker/json-schema": "^4.1.1",
137
- "@jini-ai/core": "0.6.15-rc.1",
138
- "@jini-ai/platform": "0.6.15-rc.1",
139
- "@jini-ai/oauth": "0.6.15-rc.1",
140
- "@jini-ai/agent-plugins": "0.6.15-rc.1",
141
- "@jini-ai/db": "^0.6.15-rc.1"
137
+ "@jini-ai/core": "0.6.15-rc.2",
138
+ "@jini-ai/db": "^0.6.15-rc.2",
139
+ "@jini-ai/platform": "0.6.15-rc.2",
140
+ "@jini-ai/agent-plugins": "0.6.15-rc.2",
141
+ "@jini-ai/oauth": "0.6.15-rc.2"
142
142
  },
143
143
  "scripts": {
144
144
  "build": "tsc -p tsconfig.json",