@jini-ai/integrations 0.7.1 → 0.7.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +1 -0
- package/dist/api-connections/access-token.js +4 -4
- package/dist/api-connections/account-actions.d.ts +10 -4
- package/dist/api-connections/account-actions.js +13 -13
- package/dist/api-connections/attempt-state.d.ts +11 -5
- package/dist/api-connections/attempt-state.js +4 -4
- package/dist/api-connections/authorization.d.ts +7 -3
- package/dist/api-connections/authorization.js +18 -18
- package/dist/api-connections/finish-authorization.d.ts +8 -4
- package/dist/api-connections/finish-authorization.js +9 -9
- package/dist/api-connections/host.d.ts +30 -32
- package/dist/api-connections/host.js +232 -205
- package/dist/api-connections/hosted-mcp/contracts.d.ts +1 -1
- package/dist/api-connections/hosted-mcp/oauth-row-writes.d.ts +50 -0
- package/dist/api-connections/hosted-mcp/oauth-row-writes.js +38 -0
- package/dist/api-connections/hosted-mcp/shared-sign-in.d.ts +40 -40
- package/dist/api-connections/hosted-mcp/shared-sign-in.js +98 -22
- package/dist/api-connections/hosted-mcp/sign-in-configuration.d.ts +29 -0
- package/dist/api-connections/hosted-mcp/sign-in-configuration.js +127 -0
- package/dist/api-connections/hosted-mcp/sign-in-discovery.d.ts +72 -0
- package/dist/api-connections/hosted-mcp/sign-in-discovery.js +131 -0
- package/dist/api-connections/hosted-mcp/sign-in-flow.d.ts +42 -0
- package/dist/api-connections/hosted-mcp/sign-in-flow.js +50 -0
- package/dist/api-connections/hosted-mcp/sign-in-provider.d.ts +103 -0
- package/dist/api-connections/hosted-mcp/sign-in-provider.js +142 -0
- package/dist/api-connections/hosted-mcp/sign-in-status.d.ts +19 -0
- package/dist/api-connections/hosted-mcp/sign-in-status.js +143 -0
- package/dist/api-connections/hosted-mcp/sign-in.d.ts +2 -9
- package/dist/api-connections/hosted-mcp/sign-in.js +219 -770
- package/dist/api-connections/index.js +1 -1
- package/dist/api-connections/install-credential.d.ts +4 -2
- package/dist/api-connections/install-credential.js +7 -7
- package/dist/api-connections/records.d.ts +17 -5
- package/dist/api-connections/records.js +5 -5
- package/dist/api-connections/request-checks.d.ts +29 -9
- package/dist/api-connections/request-checks.js +13 -13
- package/dist/api-connections/service.d.ts +1 -1
- package/dist/api-connections/service.js +6 -6
- package/dist/api-connections/status.d.ts +3 -1
- package/dist/api-connections/status.js +3 -3
- package/dist/api-connections/token-store/errors.d.ts +3 -1
- package/dist/api-connections/token-store/errors.js +1 -1
- package/dist/api-connections/token-store/vault-token-store.js +186 -173
- package/dist/args.d.ts +4 -1
- package/dist/args.js +1 -1
- package/dist/credentialed-http/credentialed-request.d.ts +5 -5
- package/dist/credentialed-http/credentialed-request.js +8 -8
- package/dist/credentialed-http/response-redaction.d.ts +18 -4
- package/dist/credentialed-http/response-redaction.js +7 -7
- package/dist/credentialed-http/sets/vault-repo.js +5 -1
- package/dist/credentialed-http/tools/credential-copy-tool.js +20 -15
- package/dist/credentialed-http/tools/tool-registrations.js +272 -249
- package/dist/media-providers/catalog.d.ts +1 -0
- package/dist/media-providers/catalog.js +1 -0
- package/dist/media-providers/dispatch/async-operation-store.d.ts +6 -4
- package/dist/media-providers/dispatch/async-operation-store.js +100 -88
- package/dist/media-providers/dispatch/context.js +1 -1
- package/dist/media-providers/dispatch/engine.d.ts +5 -1
- package/dist/media-providers/dispatch/engine.js +2 -2
- package/dist/media-providers/dispatch/index.d.ts +1 -1
- package/dist/media-providers/dispatch/index.js +1 -1
- package/dist/media-providers/dispatch/node.d.ts +1 -1
- package/dist/media-providers/dispatch/node.js +1 -1
- package/dist/media-providers/dispatch/openai-compatible.d.ts +50 -11
- package/dist/media-providers/dispatch/openai-compatible.js +21 -17
- package/dist/media-providers/dispatch/operation-runtime.js +18 -18
- package/dist/media-providers/dispatch/outbound.d.ts +2 -2
- package/dist/media-providers/dispatch/outbound.js +1 -1
- package/dist/media-providers/dispatch/polling-adapter.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/aihubmix-shared.d.ts +20 -6
- package/dist/media-providers/dispatch/providers/aihubmix-shared.js +8 -8
- package/dist/media-providers/dispatch/providers/aihubmix.js +12 -12
- package/dist/media-providers/dispatch/providers/custom-image.js +4 -4
- package/dist/media-providers/dispatch/providers/fishaudio.js +2 -9
- package/dist/media-providers/dispatch/providers/grok.js +5 -19
- package/dist/media-providers/dispatch/providers/imagerouter-video-async.js +22 -20
- package/dist/media-providers/dispatch/providers/imagerouter.js +7 -21
- package/dist/media-providers/dispatch/providers/minimax.js +2 -9
- package/dist/media-providers/dispatch/providers/nanobanana.js +2 -2
- package/dist/media-providers/dispatch/providers/openai.js +6 -6
- package/dist/media-providers/dispatch/providers/openrouter.js +4 -4
- package/dist/media-providers/dispatch/providers/senseaudio.js +5 -19
- package/dist/media-providers/dispatch/providers/volcengine.js +5 -12
- package/dist/media-providers/dispatch/response-parsers.js +3 -3
- package/dist/media-providers/dispatch/sqlite-async-operation-store.d.ts +1 -1
- package/dist/media-providers/dispatch/sqlite-async-operation-store.js +31 -5
- package/dist/media-providers/dispatch/ssrf-guard.js +5 -12
- package/dist/media-providers/dispatch/stub.js +2 -2
- package/dist/media-providers/dispatch/vendor-adapter.js +2 -2
- package/dist/media-providers/image-model-ids.d.ts +36 -0
- package/dist/media-providers/image-model-ids.js +24 -0
- package/dist/media-providers/sqlite-driver.adapter.d.ts +1 -1
- package/dist/media-providers/sqlite-task-store.d.ts +2 -2
- package/dist/media-providers/sqlite-task-store.js +31 -4
- package/dist/media-providers/task-lifecycle.d.ts +17 -4
- package/dist/media-providers/task-lifecycle.js +4 -4
- package/dist/media-providers/task-store.js +28 -24
- package/dist/media-providers/ui-defaults.d.ts +7 -0
- package/dist/media-providers/ui-defaults.js +11 -17
- package/dist/saved-requests/types.d.ts +1 -1
- package/dist/webhooks/delivery.js +31 -27
- package/dist/webhooks/ports.d.ts +4 -1
- package/dist/webhooks/subscriptions.d.ts +7 -2
- package/dist/webhooks/subscriptions.js +30 -37
- package/dist/webhooks/tools/agent-tools.d.ts +82 -0
- package/dist/webhooks/tools/agent-tools.js +120 -0
- package/dist/webhooks/tools/index.d.ts +7 -0
- package/dist/webhooks/tools/index.js +5 -0
- package/dist/webhooks/tools/tool-handlers.d.ts +22 -0
- package/dist/webhooks/tools/tool-handlers.js +154 -0
- package/dist/webhooks/tools/tool-handlers.types.d.ts +64 -0
- package/dist/webhooks/tools/tool-handlers.types.js +2 -0
- package/dist/webhooks/tools/tool-registrations.d.ts +35 -0
- package/dist/webhooks/tools/tool-registrations.js +95 -0
- package/dist/webhooks/tools/tool-views.d.ts +62 -0
- package/dist/webhooks/tools/tool-views.js +50 -0
- package/dist/webhooks/types.d.ts +2 -0
- package/dist/webhooks/worker.d.ts +7 -4
- package/dist/webhooks/worker.js +22 -20
- package/package.json +16 -18
|
@@ -45,7 +45,7 @@ export function createRawBytesParser(options) {
|
|
|
45
45
|
if (!resp.ok) {
|
|
46
46
|
const text = await resp.text();
|
|
47
47
|
const tag = resolve(options.errorTag, { meta: request.meta });
|
|
48
|
-
throw new Error(`${tag} ${resp.status}: ${truncate(text, 240)}`);
|
|
48
|
+
throw new Error(`${tag} ${resp.status}: ${truncate({ s: text, n: 240 })}`);
|
|
49
49
|
}
|
|
50
50
|
const bytes = Buffer.from(await resp.arrayBuffer());
|
|
51
51
|
if (bytes.length === 0) {
|
|
@@ -76,7 +76,7 @@ export function createHexEnvelopeAudioParser(options) {
|
|
|
76
76
|
return async ({ resp, request }) => {
|
|
77
77
|
const respText = await resp.text();
|
|
78
78
|
if (!resp.ok) {
|
|
79
|
-
throw new Error(`${errorTag} ${resp.status}: ${truncate(respText, 240)}`);
|
|
79
|
+
throw new Error(`${errorTag} ${resp.status}: ${truncate({ s: respText, n: 240 })}`);
|
|
80
80
|
}
|
|
81
81
|
const data = parseHexEnvelopeBody({ respText, errorTag });
|
|
82
82
|
const bytes = decodeHexEnvelopeAudio({ data, errorTag });
|
|
@@ -96,7 +96,7 @@ function parseHexEnvelopeBody(required) {
|
|
|
96
96
|
data = JSON.parse(respText);
|
|
97
97
|
}
|
|
98
98
|
catch {
|
|
99
|
-
throw new Error(`${errorTag} non-JSON: ${truncate(respText, 200)}`);
|
|
99
|
+
throw new Error(`${errorTag} non-JSON: ${truncate({ s: respText, n: 200 })}`);
|
|
100
100
|
}
|
|
101
101
|
if (data.base_resp && data.base_resp.status_code !== 0) {
|
|
102
102
|
throw new Error(`${errorTag} api error ${data.base_resp.status_code}: ${data.base_resp.status_msg || 'unknown'}`);
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* `better-sqlite3` to embed SQLite >= 3.35; verified against this repo's pinned version before
|
|
29
29
|
* writing this file.
|
|
30
30
|
*/
|
|
31
|
-
import type { SqliteSyncOpener } from '@jini-ai/
|
|
31
|
+
import type { SqliteSyncOpener } from '@jini-ai/core/contracts/storage';
|
|
32
32
|
import type { AsyncOperationStore } from './async-operation-store.js';
|
|
33
33
|
/** An `AsyncOperationStore` backed by a `better-sqlite3` database, plus a `close()` to release the file handle. */
|
|
34
34
|
export interface SqliteAsyncOperationStore extends AsyncOperationStore {
|
|
@@ -49,6 +49,14 @@ export async function createSqliteAsyncOperationStore({ dbPath, open: injectedOp
|
|
|
49
49
|
const open = injectedOpen ?? options.open ?? await loadMediaSqliteOpener({});
|
|
50
50
|
const db = open(dbPath, {});
|
|
51
51
|
db.pragma('journal_mode = WAL');
|
|
52
|
+
initializeAsyncOperationSchema(db);
|
|
53
|
+
const statements = prepareAsyncOperationStatements(db);
|
|
54
|
+
const leases = prepareAsyncOperationLeaseStatements(db);
|
|
55
|
+
const writes = createAsyncOperationWriteTransactions(db, statements);
|
|
56
|
+
const polling = createAsyncOperationPollingTransactions(db, leases);
|
|
57
|
+
return createAsyncOperationMethods(db, { ...statements, ...leases }, { ...writes, ...polling });
|
|
58
|
+
}
|
|
59
|
+
function initializeAsyncOperationSchema(db) {
|
|
52
60
|
db.exec(`
|
|
53
61
|
CREATE TABLE IF NOT EXISTS jini_async_operations (
|
|
54
62
|
id TEXT PRIMARY KEY,
|
|
@@ -73,6 +81,8 @@ export async function createSqliteAsyncOperationStore({ dbPath, open: injectedOp
|
|
|
73
81
|
CREATE INDEX IF NOT EXISTS idx_jini_async_operations_owner ON jini_async_operations (owner_ref);
|
|
74
82
|
CREATE INDEX IF NOT EXISTS idx_jini_async_operations_claim ON jini_async_operations (status, next_poll_at);
|
|
75
83
|
`);
|
|
84
|
+
}
|
|
85
|
+
function prepareAsyncOperationStatements(db) {
|
|
76
86
|
const getStmt = db.prepare('SELECT * FROM jini_async_operations WHERE id = ?');
|
|
77
87
|
const insertStmt = db.prepare(`
|
|
78
88
|
INSERT INTO jini_async_operations
|
|
@@ -86,6 +96,9 @@ export async function createSqliteAsyncOperationStore({ dbPath, open: injectedOp
|
|
|
86
96
|
`);
|
|
87
97
|
const listByOwnerStmt = db.prepare('SELECT * FROM jini_async_operations WHERE owner_ref = ? ORDER BY created_at ASC');
|
|
88
98
|
const releaseLeaseStmt = db.prepare('UPDATE jini_async_operations SET lease_owner = NULL, lease_expires_at = NULL, updated_at = ? WHERE id = ? AND lease_owner = ?');
|
|
99
|
+
return { getStmt, insertStmt, updateStmt, listByOwnerStmt, releaseLeaseStmt };
|
|
100
|
+
}
|
|
101
|
+
function prepareAsyncOperationLeaseStatements(db) {
|
|
89
102
|
// Variadic bind params (a `now`/`limit` mix plus a spread of `LIVE_LIST`) don't fit a fixed
|
|
90
103
|
// tuple type — `better-sqlite3`'s `Statement` defaults to `unknown[]` when left unspecified.
|
|
91
104
|
const claimDueStmt = db.prepare(`
|
|
@@ -113,10 +126,14 @@ export async function createSqliteAsyncOperationStore({ dbPath, open: injectedOp
|
|
|
113
126
|
WHERE status IN (${LIVE_PLACEHOLDERS}) AND lease_owner IS NOT NULL AND (lease_expires_at IS NULL OR lease_expires_at <= ?)
|
|
114
127
|
RETURNING *
|
|
115
128
|
`);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
return { claimDueStmt, deadlineExpireStmt, releaseDeadLeasesStmt };
|
|
130
|
+
}
|
|
131
|
+
/** A nullable JSON column: `null`/`undefined` store SQL NULL, anything else its JSON text. */
|
|
132
|
+
function jsonOrNull(value) {
|
|
133
|
+
return value == null ? null : JSON.stringify(value);
|
|
134
|
+
}
|
|
135
|
+
function createAsyncOperationWriteTransactions(db, statements) {
|
|
136
|
+
const { getStmt, insertStmt, updateStmt } = statements;
|
|
120
137
|
const createTxn = db.transaction((input) => {
|
|
121
138
|
if (getStmt.get(input.id)) {
|
|
122
139
|
throw new Error(`async operation "${input.id}" already exists`);
|
|
@@ -136,10 +153,14 @@ export async function createSqliteAsyncOperationStore({ dbPath, open: injectedOp
|
|
|
136
153
|
// lease it no longer holds gets the row back unchanged, not an overwrite.
|
|
137
154
|
if (isFencedOut({ existing, options }))
|
|
138
155
|
return existing;
|
|
139
|
-
const next = mergeAsyncOperationPatch({ existing, patch
|
|
156
|
+
const next = mergeAsyncOperationPatch({ existing, patch, now: Date.now() });
|
|
140
157
|
updateStmt.run(next.status, next.attempts, next.nextPollAt, jsonOrNull(next.state), jsonOrNull(next.result), jsonOrNull(next.error), next.leaseOwner, next.leaseExpiresAt, next.updatedAt, id);
|
|
141
158
|
return rowToOperation(getStmt.get(id));
|
|
142
159
|
});
|
|
160
|
+
return { createTxn, updateTxn };
|
|
161
|
+
}
|
|
162
|
+
function createAsyncOperationPollingTransactions(db, statements) {
|
|
163
|
+
const { claimDueStmt, deadlineExpireStmt, releaseDeadLeasesStmt } = statements;
|
|
143
164
|
const claimDueTxn = db.transaction((options) => {
|
|
144
165
|
const { now, leaseOwner, leaseMs } = options;
|
|
145
166
|
const limit = options.limit ?? 10;
|
|
@@ -156,6 +177,11 @@ export async function createSqliteAsyncOperationStore({ dbPath, open: injectedOp
|
|
|
156
177
|
const leasesReleased = releaseDeadLeasesStmt.all(now, ...LIVE_LIST, now).length;
|
|
157
178
|
return { leasesReleased, deadlineExpired };
|
|
158
179
|
});
|
|
180
|
+
return { claimDueTxn, reconcileTxn };
|
|
181
|
+
}
|
|
182
|
+
function createAsyncOperationMethods(db, statements, transactions) {
|
|
183
|
+
const { getStmt, listByOwnerStmt, releaseLeaseStmt } = statements;
|
|
184
|
+
const { createTxn, updateTxn, claimDueTxn, reconcileTxn } = transactions;
|
|
159
185
|
return {
|
|
160
186
|
async create(required, optional = {}) {
|
|
161
187
|
const input = { ...required, ...optional };
|
|
@@ -37,22 +37,15 @@
|
|
|
37
37
|
* RFC1918/CGNAT/link-local/multicast addresses. Platform's parser validates both hex groups
|
|
38
38
|
* before its non-null assertions; this module no longer maintains another parser copy.
|
|
39
39
|
*/
|
|
40
|
-
import { isLoopbackApiHost, isBlockedExternalApiHostname } from '@jini-ai/
|
|
40
|
+
import { isLoopbackApiHost, isBlockedExternalApiHostname, FETCH_TIMEOUT_MS } from '@jini-ai/core/net';
|
|
41
41
|
import { promises as dnsPromises } from 'node:dns';
|
|
42
|
+
import { isIpLiteralHostname } from '@jini-ai/core';
|
|
42
43
|
import { trimCharsEnd } from '@jini-ai/core/primitives';
|
|
43
|
-
import { FETCH_TIMEOUT_MS } from '@jini-ai/platform/fetch-with-timeout';
|
|
44
44
|
import { defaultMediaOutboundMessages, fetchMediaOutbound, requireMediaHttpClient } from './outbound.js';
|
|
45
45
|
const defaultDnsLookup = async ({ hostname }) => {
|
|
46
46
|
const result = await dnsPromises.lookup(hostname, { all: true, family: 0 });
|
|
47
47
|
return result.map(({ address, family }) => ({ address, family }));
|
|
48
48
|
};
|
|
49
|
-
/** Whether `hostname` is already a literal IPv4/IPv6 address (as opposed to a DNS name) — skips the DNS-resolve step in `validateBaseUrlResolved` since there's nothing further to resolve. */
|
|
50
|
-
function looksLikeIpLiteral(hostname) {
|
|
51
|
-
const host = hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;
|
|
52
|
-
if (/^\d{1,3}(?:\.\d{1,3}){3}$/.test(host))
|
|
53
|
-
return true;
|
|
54
|
-
return host.includes(':');
|
|
55
|
-
}
|
|
56
49
|
function validateBaseUrlSync(baseUrl) {
|
|
57
50
|
let parsed;
|
|
58
51
|
try {
|
|
@@ -87,7 +80,8 @@ export async function validateBaseUrlResolved({ baseUrl }, { lookup = defaultDns
|
|
|
87
80
|
if (!sync.ok)
|
|
88
81
|
return sync;
|
|
89
82
|
const hostname = sync.parsed.hostname.toLowerCase();
|
|
90
|
-
|
|
83
|
+
// A literal IPv4/IPv6 address needs no DNS-resolve step since there is nothing further to resolve.
|
|
84
|
+
if (isIpLiteralHostname({ hostname })) {
|
|
91
85
|
return { ok: true };
|
|
92
86
|
}
|
|
93
87
|
let addresses;
|
|
@@ -149,9 +143,8 @@ export async function assertAndFetchExternalAsset({ url }, { init = {}, lookup:
|
|
|
149
143
|
throw new Error(`blocked download url (${check.error})`);
|
|
150
144
|
}
|
|
151
145
|
// Downloading an already-generated asset, not waiting on generation — UPLOAD-class (2min).
|
|
152
|
-
return fetchMediaOutbound({ url, timeoutMs: FETCH_TIMEOUT_MS.UPLOAD }, {
|
|
146
|
+
return fetchMediaOutbound({ url, timeoutMs: FETCH_TIMEOUT_MS.UPLOAD, httpClient: requireMediaHttpClient(outbound) }, {
|
|
153
147
|
...outbound,
|
|
154
|
-
httpClient: requireMediaHttpClient(outbound),
|
|
155
148
|
init: { ...init, redirect: 'error' },
|
|
156
149
|
});
|
|
157
150
|
}
|
|
@@ -20,7 +20,7 @@ export async function renderStub({ ctx, providerId, integrated }) {
|
|
|
20
20
|
]);
|
|
21
21
|
return {
|
|
22
22
|
bytes: png,
|
|
23
|
-
providerNote: `${note} · aspect=${ctx.aspect} · prompt=${truncate(ctx.prompt, 60)}`,
|
|
23
|
+
providerNote: `${note} · aspect=${ctx.aspect} · prompt=${truncate({ s: ctx.prompt, n: 60 })}`,
|
|
24
24
|
suggestedExt: '.png',
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -32,7 +32,7 @@ export async function renderStub({ ctx, providerId, integrated }) {
|
|
|
32
32
|
const mdat = Buffer.from([0x00, 0x00, 0x00, 0x08, 0x6d, 0x64, 0x61, 0x74]);
|
|
33
33
|
return {
|
|
34
34
|
bytes: Buffer.concat([ftyp, mdat]),
|
|
35
|
-
providerNote: `${note} · aspect=${ctx.aspect} · length=${ctx.length ?? '?'}s · prompt=${truncate(ctx.prompt, 60)}`,
|
|
35
|
+
providerNote: `${note} · aspect=${ctx.aspect} · length=${ctx.length ?? '?'}s · prompt=${truncate({ s: ctx.prompt, n: 60 })}`,
|
|
36
36
|
suggestedExt: '.mp4',
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* `response-parsers.ts`'s `createHexEnvelopeAudioParser` for the shared,
|
|
27
27
|
* reusable piece.
|
|
28
28
|
*/
|
|
29
|
-
import { FETCH_TIMEOUT_MS } from '@jini-ai/
|
|
29
|
+
import { FETCH_TIMEOUT_MS } from '@jini-ai/core/net';
|
|
30
30
|
import { fetchMediaOutbound, requireMediaHttpClient } from './outbound.js';
|
|
31
31
|
/**
|
|
32
32
|
* The generic dispatch core: `requireCredential` -> `buildRequest` -> one
|
|
@@ -51,7 +51,7 @@ export async function dispatchVendorRequest({ adapter, ctx, credentials }) {
|
|
|
51
51
|
// still applies unchanged; `GENERATE` (10min) matches what those two vendors already picked
|
|
52
52
|
// deliberately for the same reason — media generation genuinely finishes on that order, not in
|
|
53
53
|
// seconds, so anything shorter would abort a legitimately still-generating request.
|
|
54
|
-
const resp = await fetchMediaOutbound({ url: request.url, timeoutMs: FETCH_TIMEOUT_MS.GENERATE
|
|
54
|
+
const resp = await fetchMediaOutbound({ url: request.url, timeoutMs: FETCH_TIMEOUT_MS.GENERATE, httpClient: requireMediaHttpClient(ctx) }, { ...ctx, init: request.init });
|
|
55
55
|
return adapter.parseResponse({ resp: resp, ctx: ctx, request: request });
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** The two catalogue reads the image-model rule needs: structurally a `MediaModelCatalog` /
|
|
2
|
+
* `MediaProviderRegistry`, declared here so this file stays inside the dependency-free catalog graph. */
|
|
3
|
+
export interface ImageModelCatalog {
|
|
4
|
+
modelsForSurface(required: {
|
|
5
|
+
surface: "image";
|
|
6
|
+
}): readonly {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly provider: string;
|
|
9
|
+
}[];
|
|
10
|
+
findProvider(required: {
|
|
11
|
+
id: string;
|
|
12
|
+
}): {
|
|
13
|
+
readonly integrated: boolean;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Every image model in `catalog` whose vendor the catalogue itself marks `integrated` (a real vendor,
|
|
18
|
+
* not a planned/placeholder entry). A host advertising an image tool uses this as the `model` enum AND
|
|
19
|
+
* re-checks the caller's `model` against it in the handler: a tool schema's `enum` is descriptive only
|
|
20
|
+
* (the kernel neither parses nor validates a tool's schema), so a model outside this set must be
|
|
21
|
+
* rejected there. Catalogue order is kept: it is the default-model resolution order. Pass the live
|
|
22
|
+
* provider registry so plugin-contributed vendors' image models are included.
|
|
23
|
+
* @complexity O(m) image models.
|
|
24
|
+
*/
|
|
25
|
+
export declare function imageModelIdsFrom({ catalog }: {
|
|
26
|
+
catalog: ImageModelCatalog;
|
|
27
|
+
}, _optional?: Record<string, never>): string[];
|
|
28
|
+
/**
|
|
29
|
+
* {@link imageModelIdsFrom} over the built-in catalogue, computed at import time. `integrated` is a
|
|
30
|
+
* reliable proxy for "the dispatch engine has a real adapter": every image-surface provider marked
|
|
31
|
+
* `integrated: true` has an adapter registered in the dispatch engine's vendor registry (which this
|
|
32
|
+
* dependency-free subpath deliberately does not import), and the `providers.test.ts` adapter-coverage
|
|
33
|
+
* assertion fails if the catalogue claims a vendor the engine cannot render.
|
|
34
|
+
*/
|
|
35
|
+
export declare const IMAGE_MODEL_IDS: readonly string[];
|
|
36
|
+
//# sourceMappingURL=image-model-ids.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IMAGE_MODELS, findProvider } from './providers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every image model in `catalog` whose vendor the catalogue itself marks `integrated` (a real vendor,
|
|
4
|
+
* not a planned/placeholder entry). A host advertising an image tool uses this as the `model` enum AND
|
|
5
|
+
* re-checks the caller's `model` against it in the handler: a tool schema's `enum` is descriptive only
|
|
6
|
+
* (the kernel neither parses nor validates a tool's schema), so a model outside this set must be
|
|
7
|
+
* rejected there. Catalogue order is kept: it is the default-model resolution order. Pass the live
|
|
8
|
+
* provider registry so plugin-contributed vendors' image models are included.
|
|
9
|
+
* @complexity O(m) image models.
|
|
10
|
+
*/
|
|
11
|
+
export function imageModelIdsFrom({ catalog }, _optional = {}) {
|
|
12
|
+
return catalog.modelsForSurface({ surface: "image" })
|
|
13
|
+
.filter((model) => catalog.findProvider({ id: model.provider })?.integrated === true)
|
|
14
|
+
.map((model) => model.id);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* {@link imageModelIdsFrom} over the built-in catalogue, computed at import time. `integrated` is a
|
|
18
|
+
* reliable proxy for "the dispatch engine has a real adapter": every image-surface provider marked
|
|
19
|
+
* `integrated: true` has an adapter registered in the dispatch engine's vendor registry (which this
|
|
20
|
+
* dependency-free subpath deliberately does not import), and the `providers.test.ts` adapter-coverage
|
|
21
|
+
* assertion fails if the catalogue claims a vendor the engine cannot render.
|
|
22
|
+
*/
|
|
23
|
+
export const IMAGE_MODEL_IDS = imageModelIdsFrom({ catalog: { modelsForSurface: () => IMAGE_MODELS, findProvider } });
|
|
24
|
+
//# sourceMappingURL=image-model-ids.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SqliteSyncOpener } from '@jini-ai/
|
|
1
|
+
import type { SqliteSyncOpener } from '@jini-ai/core/contracts/storage';
|
|
2
2
|
export declare function loadMediaSqliteOpener(_required: Record<string, never>, _optional?: Record<string, never>): Promise<SqliteSyncOpener>;
|
|
3
3
|
//# sourceMappingURL=sqlite-driver.adapter.d.ts.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* survive a process restart).
|
|
6
6
|
*
|
|
7
7
|
* Reuses this repo's existing durability pattern exactly —
|
|
8
|
-
* `packages/
|
|
8
|
+
* `packages/daemon/src/store/event-log/sqlite.ts`'s `createSqliteEventLog`, the durable
|
|
9
9
|
* adapter for `@jini-ai/daemon`'s `EventLog` port — rather than inventing a
|
|
10
10
|
* parallel one: `new Database(dbPath)`, `db.pragma('journal_mode = WAL')`,
|
|
11
11
|
* `CREATE TABLE IF NOT EXISTS` (idempotent — reopening the same file
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* two-phase boot reconciliation. See `createInMemoryMediaTaskStore` in
|
|
40
40
|
* `task-store.ts` for the reference behavior this mirrors.
|
|
41
41
|
*/
|
|
42
|
-
import type { SqliteSyncOpener } from '@jini-ai/
|
|
42
|
+
import type { SqliteSyncOpener } from '@jini-ai/core/contracts/storage';
|
|
43
43
|
import type { MediaTaskStore } from './task-store.js';
|
|
44
44
|
/** A `MediaTaskStore` backed by a `better-sqlite3` database, plus a `close()` to release the file handle. */
|
|
45
45
|
export interface SqliteMediaTaskStore extends MediaTaskStore {
|
|
@@ -57,6 +57,14 @@ export async function createSqliteMediaTaskStore(required, options = {}) {
|
|
|
57
57
|
const open = (typeof required === 'string' ? undefined : required.open) ?? options.open ?? await loadMediaSqliteOpener({});
|
|
58
58
|
const db = open(dbPath, {});
|
|
59
59
|
db.pragma('journal_mode = WAL');
|
|
60
|
+
initializeMediaTaskSchema(db);
|
|
61
|
+
const statements = prepareMediaTaskStatements(db);
|
|
62
|
+
const writeRow = createMediaTaskRowWriter(statements);
|
|
63
|
+
const transactions = createMediaTaskWriteTransactions(db, statements, writeRow);
|
|
64
|
+
const reconcileTxn = createMediaTaskReconcileTransaction(db, statements, writeRow);
|
|
65
|
+
return createMediaTaskMethods(db, statements, { ...transactions, reconcileTxn });
|
|
66
|
+
}
|
|
67
|
+
function initializeMediaTaskSchema(db) {
|
|
60
68
|
db.exec(`
|
|
61
69
|
CREATE TABLE IF NOT EXISTS jini_media_tasks (
|
|
62
70
|
id TEXT PRIMARY KEY,
|
|
@@ -76,6 +84,8 @@ export async function createSqliteMediaTaskStore(required, options = {}) {
|
|
|
76
84
|
CREATE INDEX IF NOT EXISTS idx_jini_media_tasks_owner
|
|
77
85
|
ON jini_media_tasks (owner_ref, status);
|
|
78
86
|
`);
|
|
87
|
+
}
|
|
88
|
+
function prepareMediaTaskStatements(db) {
|
|
79
89
|
const getStmt = db.prepare('SELECT * FROM jini_media_tasks WHERE id = ?');
|
|
80
90
|
const insertStmt = db.prepare(`
|
|
81
91
|
INSERT INTO jini_media_tasks
|
|
@@ -91,6 +101,10 @@ export async function createSqliteMediaTaskStore(required, options = {}) {
|
|
|
91
101
|
const listAllForOwnerStmt = db.prepare('SELECT * FROM jini_media_tasks WHERE owner_ref = ? ORDER BY started_at DESC');
|
|
92
102
|
const listInFlightForOwnerStmt = db.prepare(`SELECT * FROM jini_media_tasks WHERE owner_ref = ? AND status NOT IN ('done', 'failed', 'interrupted') ORDER BY started_at DESC`);
|
|
93
103
|
const selectAllStmt = db.prepare('SELECT * FROM jini_media_tasks');
|
|
104
|
+
return { getStmt, insertStmt, updateStmt, deleteStmt, listAllForOwnerStmt, listInFlightForOwnerStmt, selectAllStmt };
|
|
105
|
+
}
|
|
106
|
+
function createMediaTaskRowWriter(statements) {
|
|
107
|
+
const { insertStmt, updateStmt } = statements;
|
|
94
108
|
function writeRow(task, isInsert) {
|
|
95
109
|
const progressJson = JSON.stringify(task.progress);
|
|
96
110
|
const fileJson = task.file == null ? null : JSON.stringify(task.file);
|
|
@@ -104,11 +118,15 @@ export async function createSqliteMediaTaskStore(required, options = {}) {
|
|
|
104
118
|
updateStmt.run(task.status, surface, model, progressJson, fileJson, errorJson, task.endedAt, task.updatedAt, task.id);
|
|
105
119
|
}
|
|
106
120
|
}
|
|
121
|
+
return writeRow;
|
|
122
|
+
}
|
|
123
|
+
function createMediaTaskWriteTransactions(db, statements, writeRow) {
|
|
124
|
+
const { getStmt } = statements;
|
|
107
125
|
const createTxn = db.transaction((input) => {
|
|
108
126
|
if (getStmt.get(input.id)) {
|
|
109
127
|
throw new Error(`media task "${input.id}" already exists`);
|
|
110
128
|
}
|
|
111
|
-
const task = buildNewTask(input, Date.now());
|
|
129
|
+
const task = buildNewTask({ input, now: Date.now() });
|
|
112
130
|
writeRow(task, true);
|
|
113
131
|
return task;
|
|
114
132
|
});
|
|
@@ -116,10 +134,14 @@ export async function createSqliteMediaTaskStore(required, options = {}) {
|
|
|
116
134
|
const row = getStmt.get(id);
|
|
117
135
|
if (!row)
|
|
118
136
|
return null;
|
|
119
|
-
const next = applyTaskPatch(rowToTask(row), patch, Date.now());
|
|
137
|
+
const next = applyTaskPatch({ existing: rowToTask(row), patch, now: Date.now() });
|
|
120
138
|
writeRow(next, false);
|
|
121
139
|
return next;
|
|
122
140
|
});
|
|
141
|
+
return { createTxn, updateTxn };
|
|
142
|
+
}
|
|
143
|
+
function createMediaTaskReconcileTransaction(db, statements, writeRow) {
|
|
144
|
+
const { selectAllStmt, deleteStmt } = statements;
|
|
123
145
|
const reconcileTxn = db.transaction((options) => {
|
|
124
146
|
const now = options.now ?? Date.now();
|
|
125
147
|
const cutoff = now - options.terminalTtlMs;
|
|
@@ -127,7 +149,7 @@ export async function createSqliteMediaTaskStore(required, options = {}) {
|
|
|
127
149
|
let deleted = 0;
|
|
128
150
|
for (const row of selectAllStmt.all()) {
|
|
129
151
|
const task = rowToTask(row);
|
|
130
|
-
const action = reconcileAction(task, now, cutoff);
|
|
152
|
+
const action = reconcileAction({ task, now, cutoff });
|
|
131
153
|
switch (action.kind) {
|
|
132
154
|
case 'interrupt':
|
|
133
155
|
writeRow(action.next, false);
|
|
@@ -144,6 +166,11 @@ export async function createSqliteMediaTaskStore(required, options = {}) {
|
|
|
144
166
|
}
|
|
145
167
|
return { interrupted, deleted };
|
|
146
168
|
});
|
|
169
|
+
return reconcileTxn;
|
|
170
|
+
}
|
|
171
|
+
function createMediaTaskMethods(db, statements, transactions) {
|
|
172
|
+
const { getStmt, listAllForOwnerStmt, listInFlightForOwnerStmt, deleteStmt } = statements;
|
|
173
|
+
const { createTxn, updateTxn, reconcileTxn } = transactions;
|
|
147
174
|
return {
|
|
148
175
|
async create(input) {
|
|
149
176
|
return createTxn(input);
|
|
@@ -164,7 +191,7 @@ export async function createSqliteMediaTaskStore(required, options = {}) {
|
|
|
164
191
|
deleteStmt.run(id);
|
|
165
192
|
},
|
|
166
193
|
async reconcileOnBoot(options) {
|
|
167
|
-
assertValidTerminalTtl(options.terminalTtlMs);
|
|
194
|
+
assertValidTerminalTtl({ terminalTtlMs: options.terminalTtlMs });
|
|
168
195
|
return reconcileTxn(options);
|
|
169
196
|
},
|
|
170
197
|
async close() {
|
|
@@ -10,10 +10,19 @@
|
|
|
10
10
|
import type { MediaTask, MediaTaskCreateInput, MediaTaskPatch, MediaTaskStatus } from './task-store.js';
|
|
11
11
|
export declare const TERMINAL_STATUSES: ReadonlySet<MediaTaskStatus>;
|
|
12
12
|
/** Builds the stored row for `create()`; the caller checks for a duplicate id first. */
|
|
13
|
-
export declare function buildNewTask(input
|
|
13
|
+
export declare function buildNewTask({ input, now }: {
|
|
14
|
+
input: MediaTaskCreateInput;
|
|
15
|
+
now: number;
|
|
16
|
+
}, _optional?: Record<string, never>): MediaTask;
|
|
14
17
|
/** Validates `patch` against `existing` (status enum, then transition graph) and returns the next stored row. */
|
|
15
|
-
export declare function applyTaskPatch(existing
|
|
16
|
-
|
|
18
|
+
export declare function applyTaskPatch({ existing, patch, now }: {
|
|
19
|
+
existing: MediaTask;
|
|
20
|
+
patch: MediaTaskPatch;
|
|
21
|
+
now: number;
|
|
22
|
+
}, _optional?: Record<string, never>): MediaTask;
|
|
23
|
+
export declare function assertValidTerminalTtl({ terminalTtlMs }: {
|
|
24
|
+
terminalTtlMs: number;
|
|
25
|
+
}, _optional?: Record<string, never>): void;
|
|
17
26
|
/** What boot-time reconciliation does to one stored task. */
|
|
18
27
|
export type ReconcileAction = {
|
|
19
28
|
readonly kind: 'interrupt';
|
|
@@ -29,5 +38,9 @@ export type ReconcileAction = {
|
|
|
29
38
|
* whose `endedAt` (or, failing that, `updatedAt`) is older than `cutoff` is
|
|
30
39
|
* deleted. A task interrupted in this pass is never also deleted in it.
|
|
31
40
|
*/
|
|
32
|
-
export declare function reconcileAction(task
|
|
41
|
+
export declare function reconcileAction({ task, now, cutoff }: {
|
|
42
|
+
task: MediaTask;
|
|
43
|
+
now: number;
|
|
44
|
+
cutoff: number;
|
|
45
|
+
}, _optional?: Record<string, never>): ReconcileAction;
|
|
33
46
|
//# sourceMappingURL=task-lifecycle.d.ts.map
|
|
@@ -43,7 +43,7 @@ function labelFields(surface, model) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
/** Builds the stored row for `create()`; the caller checks for a duplicate id first. */
|
|
46
|
-
export function buildNewTask(input, now) {
|
|
46
|
+
export function buildNewTask({ input, now }, _optional = {}) {
|
|
47
47
|
const status = input.status ?? 'queued';
|
|
48
48
|
assertValidStatus(status);
|
|
49
49
|
return {
|
|
@@ -75,7 +75,7 @@ function patchedPayload(existing, patch) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
/** Validates `patch` against `existing` (status enum, then transition graph) and returns the next stored row. */
|
|
78
|
-
export function applyTaskPatch(existing, patch, now) {
|
|
78
|
+
export function applyTaskPatch({ existing, patch, now }, _optional = {}) {
|
|
79
79
|
const status = patch.status ?? existing.status;
|
|
80
80
|
assertValidStatus(status);
|
|
81
81
|
// CR-013: enum membership alone doesn't prove the transition is legal
|
|
@@ -98,7 +98,7 @@ export function applyTaskPatch(existing, patch, now) {
|
|
|
98
98
|
...patchedLabels(existing, patch),
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
export function assertValidTerminalTtl(terminalTtlMs) {
|
|
101
|
+
export function assertValidTerminalTtl({ terminalTtlMs }, _optional = {}) {
|
|
102
102
|
if (!Number.isFinite(terminalTtlMs) || terminalTtlMs < 0) {
|
|
103
103
|
throw new RangeError(`Invalid terminalTtlMs: ${terminalTtlMs} must be a non-negative finite number`);
|
|
104
104
|
}
|
|
@@ -109,7 +109,7 @@ export function assertValidTerminalTtl(terminalTtlMs) {
|
|
|
109
109
|
* whose `endedAt` (or, failing that, `updatedAt`) is older than `cutoff` is
|
|
110
110
|
* deleted. A task interrupted in this pass is never also deleted in it.
|
|
111
111
|
*/
|
|
112
|
-
export function reconcileAction(task, now, cutoff) {
|
|
112
|
+
export function reconcileAction({ task, now, cutoff }, _optional = {}) {
|
|
113
113
|
if (task.status === 'queued' || task.status === 'running') {
|
|
114
114
|
return {
|
|
115
115
|
kind: 'interrupt',
|
|
@@ -23,6 +23,31 @@ function cloneTask(task) {
|
|
|
23
23
|
error: task.error == null ? null : { ...task.error },
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
/** Boot reconciliation over the live map: interrupt in-flight tasks and drop terminal ones past the TTL. */
|
|
27
|
+
function reconcileTasks({ tasks, options }) {
|
|
28
|
+
assertValidTerminalTtl({ terminalTtlMs: options.terminalTtlMs });
|
|
29
|
+
const now = options.now ?? Date.now();
|
|
30
|
+
const cutoff = now - options.terminalTtlMs;
|
|
31
|
+
let interrupted = 0;
|
|
32
|
+
let deleted = 0;
|
|
33
|
+
for (const task of [...tasks.values()]) {
|
|
34
|
+
const action = reconcileAction({ task, now, cutoff });
|
|
35
|
+
switch (action.kind) {
|
|
36
|
+
case 'interrupt':
|
|
37
|
+
tasks.set(task.id, action.next);
|
|
38
|
+
interrupted += 1;
|
|
39
|
+
break;
|
|
40
|
+
case 'delete':
|
|
41
|
+
tasks.delete(task.id);
|
|
42
|
+
deleted += 1;
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
// 'keep': the task stays as it is.
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { interrupted, deleted };
|
|
50
|
+
}
|
|
26
51
|
/** Creates the in-memory reference `MediaTaskStore`. No persistence — state is lost on process exit. */
|
|
27
52
|
export function createInMemoryMediaTaskStore() {
|
|
28
53
|
const tasks = new Map();
|
|
@@ -31,7 +56,7 @@ export function createInMemoryMediaTaskStore() {
|
|
|
31
56
|
if (tasks.has(input.id)) {
|
|
32
57
|
throw new Error(`media task "${input.id}" already exists`);
|
|
33
58
|
}
|
|
34
|
-
const task = buildNewTask(input, Date.now());
|
|
59
|
+
const task = buildNewTask({ input, now: Date.now() });
|
|
35
60
|
tasks.set(task.id, task);
|
|
36
61
|
return cloneTask(task);
|
|
37
62
|
},
|
|
@@ -43,7 +68,7 @@ export function createInMemoryMediaTaskStore() {
|
|
|
43
68
|
const existing = tasks.get(id);
|
|
44
69
|
if (!existing)
|
|
45
70
|
return null;
|
|
46
|
-
const next = applyTaskPatch(existing, patch, Date.now());
|
|
71
|
+
const next = applyTaskPatch({ existing, patch, now: Date.now() });
|
|
47
72
|
tasks.set(id, next);
|
|
48
73
|
return cloneTask(next);
|
|
49
74
|
},
|
|
@@ -59,28 +84,7 @@ export function createInMemoryMediaTaskStore() {
|
|
|
59
84
|
tasks.delete(id);
|
|
60
85
|
},
|
|
61
86
|
async reconcileOnBoot(options) {
|
|
62
|
-
|
|
63
|
-
const now = options.now ?? Date.now();
|
|
64
|
-
const cutoff = now - options.terminalTtlMs;
|
|
65
|
-
let interrupted = 0;
|
|
66
|
-
let deleted = 0;
|
|
67
|
-
for (const task of [...tasks.values()]) {
|
|
68
|
-
const action = reconcileAction(task, now, cutoff);
|
|
69
|
-
switch (action.kind) {
|
|
70
|
-
case 'interrupt':
|
|
71
|
-
tasks.set(task.id, action.next);
|
|
72
|
-
interrupted += 1;
|
|
73
|
-
break;
|
|
74
|
-
case 'delete':
|
|
75
|
-
tasks.delete(task.id);
|
|
76
|
-
deleted += 1;
|
|
77
|
-
break;
|
|
78
|
-
default:
|
|
79
|
-
// 'keep': the task stays as it is.
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return { interrupted, deleted };
|
|
87
|
+
return reconcileTasks({ tasks, options });
|
|
84
88
|
},
|
|
85
89
|
};
|
|
86
90
|
}
|
|
@@ -5,6 +5,13 @@ export declare const DEFAULT_MEDIA_PROVIDER_CATALOG: readonly MediaProviderOptio
|
|
|
5
5
|
* ~30-entry list: that list is hand-curated product content that goes stale,
|
|
6
6
|
* and this package's rule for tables like this (see `LanguageTab`) is that the
|
|
7
7
|
* host owns them. Pass these explicitly as `presets` to the UI.
|
|
8
|
+
*
|
|
9
|
+
* `preferredModels` stay empty: models are discovered at runtime (live `listModels`) and the
|
|
10
|
+
* user's saved choice is used, never a hard-coded id. Two reasons, both seen live: a hard-coded
|
|
11
|
+
* first entry goes stale and silently pins new users to an old model generation (the Gemini
|
|
12
|
+
* field once defaulted to an older flash model than the one the operator was running), and a
|
|
13
|
+
* code-picked newer, pricier flagship as the silent default would jump an existing user's cost
|
|
14
|
+
* without them choosing it.
|
|
8
15
|
*/
|
|
9
16
|
export declare const DEFAULT_PROVIDER_PRESETS: readonly ProviderPreset<'anthropic' | 'openai' | 'azure' | 'google'>[];
|
|
10
17
|
//# sourceMappingURL=ui-defaults.d.ts.map
|
|
@@ -86,6 +86,13 @@ export const DEFAULT_MEDIA_PROVIDER_CATALOG = starterCatalog.map((entry) => {
|
|
|
86
86
|
* ~30-entry list: that list is hand-curated product content that goes stale,
|
|
87
87
|
* and this package's rule for tables like this (see `LanguageTab`) is that the
|
|
88
88
|
* host owns them. Pass these explicitly as `presets` to the UI.
|
|
89
|
+
*
|
|
90
|
+
* `preferredModels` stay empty: models are discovered at runtime (live `listModels`) and the
|
|
91
|
+
* user's saved choice is used, never a hard-coded id. Two reasons, both seen live: a hard-coded
|
|
92
|
+
* first entry goes stale and silently pins new users to an old model generation (the Gemini
|
|
93
|
+
* field once defaulted to an older flash model than the one the operator was running), and a
|
|
94
|
+
* code-picked newer, pricier flagship as the silent default would jump an existing user's cost
|
|
95
|
+
* without them choosing it.
|
|
89
96
|
*/
|
|
90
97
|
export const DEFAULT_PROVIDER_PRESETS = [
|
|
91
98
|
{
|
|
@@ -93,7 +100,7 @@ export const DEFAULT_PROVIDER_PRESETS = [
|
|
|
93
100
|
title: 'Anthropic',
|
|
94
101
|
protocol: 'anthropic',
|
|
95
102
|
baseUrl: VENDOR_API_BASE_URLS.anthropic,
|
|
96
|
-
preferredModels: [
|
|
103
|
+
preferredModels: [],
|
|
97
104
|
kind: 'protocol',
|
|
98
105
|
apiKeyPrefix: 'sk-ant-',
|
|
99
106
|
},
|
|
@@ -102,15 +109,7 @@ export const DEFAULT_PROVIDER_PRESETS = [
|
|
|
102
109
|
title: 'OpenAI',
|
|
103
110
|
protocol: 'openai',
|
|
104
111
|
baseUrl: VENDOR_API_BASE_URLS.openai,
|
|
105
|
-
|
|
106
|
-
// (released 2026-07-09, per the API changelog) replaced the old
|
|
107
|
-
// flagship/mini/nano naming with named tiers — sol/terra/luna. `sol` is
|
|
108
|
-
// the one the changelog and pricing docs call out as "recommended for
|
|
109
|
-
// production API usage", so it leads (see `preferredModels[0]` default
|
|
110
|
-
// in `rules.ts`) rather than the newer, pricier `gpt-6-astra` flagship
|
|
111
|
-
// (released 2026-09-03) — picking that as the silent default would jump
|
|
112
|
-
// an existing user's cost without them choosing it.
|
|
113
|
-
preferredModels: ['gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.6-luna'],
|
|
112
|
+
preferredModels: [],
|
|
114
113
|
kind: 'protocol',
|
|
115
114
|
apiKeyPrefix: 'sk-',
|
|
116
115
|
},
|
|
@@ -132,12 +131,7 @@ export const DEFAULT_PROVIDER_PRESETS = [
|
|
|
132
131
|
title: 'Google Gemini',
|
|
133
132
|
protocol: 'google',
|
|
134
133
|
baseUrl: VENDOR_API_BASE_URLS.google,
|
|
135
|
-
|
|
136
|
-
// the default for anyone who has never picked a model, so a stale head silently pins new users
|
|
137
|
-
// to an old generation. Reported live: the field defaulted to `gemini-2.5-flash` while the
|
|
138
|
-
// operator was actually running `gemini-3.6-flash`. This list is only a FALLBACK — the form
|
|
139
|
-
// prefers live `listModels` discovery and drops back here when that call fails.
|
|
140
|
-
preferredModels: ['gemini-3.6-flash', 'gemini-2.5-flash', 'gemini-2.5-pro'],
|
|
134
|
+
preferredModels: [],
|
|
141
135
|
kind: 'protocol',
|
|
142
136
|
// `AIza` + 35 characters is the classic Google key shape, and it is recorded here so a key of
|
|
143
137
|
// this shape is recognised as GOOGLE'S when it turns up in some other provider's field.
|
|
@@ -150,7 +144,7 @@ export const DEFAULT_PROVIDER_PRESETS = [
|
|
|
150
144
|
title: 'OpenRouter',
|
|
151
145
|
protocol: 'openai',
|
|
152
146
|
baseUrl: VENDOR_API_BASE_URLS.openrouter,
|
|
153
|
-
preferredModels: [
|
|
147
|
+
preferredModels: [],
|
|
154
148
|
kind: 'gateway',
|
|
155
149
|
// Longer than OpenAI's `sk-`, and deliberately so: `apiKeyFormatWarning` resolves a key to the
|
|
156
150
|
// MOST specific prefix that claims it, so `sk-or-v1-…` is attributed here rather than to OpenAI.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CredentialedRequestAuditPort, makeCredentialedRequest } from "../credentialed-http/credentialed-request.js";
|
|
2
2
|
import type { CredentialSchemeRegistryPort, ResolvedCredential } from "../credentialed-http/ports.js";
|
|
3
|
-
import type { DnsResolver, GuardedClock, PinnedHttpTransport } from "@jini-ai/
|
|
3
|
+
import type { DnsResolver, GuardedClock, PinnedHttpTransport } from "@jini-ai/core/contracts/runtime";
|
|
4
4
|
/** Persisted data only. Identity, policy, consent and quotas belong to the calling host. */
|
|
5
5
|
export interface SavedRequestDefinition {
|
|
6
6
|
readonly version: 1;
|