@techis/ai-runtime 0.4.1 → 0.6.0
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/API.md +2 -2
- package/NATIVE-IMAGES.md +52 -0
- package/PYTHON.md +46 -0
- package/README.md +9 -4
- package/dist/adapters/image.d.ts +5 -0
- package/dist/adapters/image.d.ts.map +1 -0
- package/dist/adapters/image.js +105 -0
- package/dist/adapters/image.js.map +1 -0
- package/dist/adapters/registry.d.ts.map +1 -1
- package/dist/adapters/registry.js +8 -2
- package/dist/adapters/registry.js.map +1 -1
- package/dist/adapters/types.d.ts +6 -0
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/validation.d.ts.map +1 -1
- package/dist/adapters/validation.js +11 -2
- package/dist/adapters/validation.js.map +1 -1
- package/dist/bridge-worker.d.ts +3 -0
- package/dist/bridge-worker.d.ts.map +1 -0
- package/dist/bridge-worker.js +48 -0
- package/dist/bridge-worker.js.map +1 -0
- package/dist/bridge.d.ts +33 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +46 -0
- package/dist/bridge.js.map +1 -0
- package/dist/bundle-source.d.ts +1 -2
- package/dist/bundle-source.d.ts.map +1 -1
- package/dist/bundle-source.js +1 -1
- package/dist/bundle-source.js.map +1 -1
- package/dist/compatibility-execution.d.ts +1 -0
- package/dist/compatibility-execution.d.ts.map +1 -1
- package/dist/image-generation.d.ts +25 -0
- package/dist/image-generation.d.ts.map +1 -0
- package/dist/image-generation.js +59 -0
- package/dist/image-generation.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/route-client.d.ts +3 -0
- package/dist/route-client.d.ts.map +1 -1
- package/dist/route-client.js +4 -1
- package/dist/route-client.js.map +1 -1
- package/dist/route-readiness.d.ts.map +1 -1
- package/dist/route-readiness.js +23 -6
- package/dist/route-readiness.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +96 -25
- package/dist/run.js.map +1 -1
- package/dist/scoped-source.d.ts +1 -1
- package/dist/scoped-source.js +2 -2
- package/dist/scoped-source.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -4
- package/python/model_routes/__init__.py +141 -0
- package/python/pyproject.toml +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-readiness.js","sourceRoot":"","sources":["../src/route-readiness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"route-readiness.js","sourceRoot":"","sources":["../src/route-readiness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,wBAAwB,EAE5F,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,+BAA+B,EAA+B,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAGtE,oHAAoH;AACpH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAM3C;IACC,MAAM,QAAQ,GAAG,wBAAwB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,+BAA+B,CAAC,OAAO,CAAC,CAAC;IACjH,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAmB,EAAE,MAAM,GAA0B,EAAE,CAAC;IACnI,MAAM,CAAC,IAAI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,MAAM,EAAE,QAAQ,IAAI,YAAY,KAAK,WAAW,IAAI,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;QAChH,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,WAAW,EAAE,KAAK,EAAE,QAAQ,GAAG,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;YAC/H,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC,wEAAwE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;gBAClH,kCAAkC,CAAC,CAAC,CAAC,4CAA4C,EAAE,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;AAChG,CAAC"}
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAGA,OAAO,EAOL,gBAAgB,EAShB,KAAK,gBAAgB,EAKrB,KAAK,iBAAiB,EAKvB,MAAM,sBAAsB,CAAC;AAqB9B,OAAO,KAAK,EAAE,eAAe,EAAmC,MAAM,qBAAqB,CAAC;AAE5F,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,eAAe,EAEpB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AACpB,OAA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oBAAoB,EAAE,IAAI,EAAE,0BAA0B,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC;AAi4BpK,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,EAAE,KAAK,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI,CAsB3G;AA8TD,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
package/dist/run.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { withDeadline } from "./deadline.js";
|
|
2
|
+
import { IMAGE_REQUEST, imageOutputEvidence, validateImageRequest, validateImageTransport } from "./image-generation.js";
|
|
2
3
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { compileSchema, deriveReceiptId, deriveNativeReceiptId, deriveModelReceiptId, deriveProfileReceiptId, deriveDirectModelReceiptId, hashInstructions, hashDocumentV2, validateReasoningForModel, reasoningSupportWarnings, isNativeReasoningControl, modelEndpointConflict } from "@techis/ai-contracts";
|
|
4
|
+
import { compileSchema, deriveReceiptId, deriveNativeReceiptId, deriveModelReceiptId, deriveProfileReceiptId, deriveDirectModelReceiptId, hashInstructions, hashDocumentV2, validateReasoningForModel, reasoningSupportWarnings, isNativeReasoningControl, modelEndpointConflict, resolveCatalogSlot } from "@techis/ai-contracts";
|
|
4
5
|
import { AISubsystemError, attachProviderErrorContext, AttemptsExhaustedError, BudgetExceededError, CancellationError, ConfigurationInvalidError, CredentialInvalidError, CredentialUnavailableError, InputLimitExceededError, ProviderCallError, ProviderOutputTruncatedError, InvalidOutputError, UnsupportedAdapterError, UnsupportedCapabilityError } from "./errors.js";
|
|
5
6
|
import { applyReportedCostContext, costContextForRequest, costPricing, costFromUsage, estimateInputTokens, measuredCostContext, mergeReportedUsage, preflightCostCeiling, priceForModel } from "./cost.js";
|
|
6
7
|
import { resolveEffectiveReasoning } from "./reasoning-resolution.js";
|
|
@@ -44,6 +45,14 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
44
45
|
const systemInstructions = "model" in token || "directModel" in token ? token.systemInstructions : token.instructionProjection?.systemInstructions ?? token.persona.systemInstructions;
|
|
45
46
|
const outputRequirements = "model" in token || "directModel" in token ? undefined : token.persona.outputRequirements;
|
|
46
47
|
const models = new Map(snapshot.catalog.models.map((model) => [model.catalogId, model]));
|
|
48
|
+
const resolveSlot = (slot) => {
|
|
49
|
+
try {
|
|
50
|
+
return resolveCatalogSlot(snapshot.catalog, slot);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new ConfigurationInvalidError(error.message);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
47
56
|
const runId = randomUUID();
|
|
48
57
|
async function execute(options, invocation) {
|
|
49
58
|
const startedAt = invocation?.admittedAt ?? performance.now(), admittedAt = startedAt;
|
|
@@ -51,6 +60,7 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
51
60
|
if (!validOptions)
|
|
52
61
|
options = { operationId: "", input: "" };
|
|
53
62
|
let richRequest;
|
|
63
|
+
let imageRequest;
|
|
54
64
|
let effectiveInstructions = systemInstructions;
|
|
55
65
|
const requestId = typeof options.requestId === "string" && REQUEST_ID_PATTERN.test(options.requestId)
|
|
56
66
|
? options.requestId
|
|
@@ -97,6 +107,18 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
97
107
|
try {
|
|
98
108
|
if (!validOptions)
|
|
99
109
|
throw new ConfigurationInvalidError("Generation options must be an object");
|
|
110
|
+
if (Object.hasOwn(options, "imageRequest"))
|
|
111
|
+
throw new ConfigurationInvalidError("Use images.generate for native image output.");
|
|
112
|
+
if (Object.hasOwn(options, IMAGE_REQUEST)) {
|
|
113
|
+
try {
|
|
114
|
+
imageRequest = structuredClone(options[IMAGE_REQUEST]);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
throw new ConfigurationInvalidError("Image request must be serializable.");
|
|
118
|
+
}
|
|
119
|
+
validateImageRequest(imageRequest);
|
|
120
|
+
options = { ...options, input: imageRequest.prompt };
|
|
121
|
+
}
|
|
100
122
|
if (typeof options.operationId !== "string" || !OPERATION_ID_PATTERN.test(options.operationId)) {
|
|
101
123
|
throw new ConfigurationInvalidError("GenerateOptions.operationId is required and must be a bounded logical identifier (letters, digits, '.', '_', '-'; max 128 characters)");
|
|
102
124
|
}
|
|
@@ -112,9 +134,18 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
112
134
|
if (signal?.aborted)
|
|
113
135
|
throw new CancellationError();
|
|
114
136
|
const profile = executionConfiguration(token);
|
|
137
|
+
if (imageRequest !== undefined) {
|
|
138
|
+
validateImageRequest(imageRequest);
|
|
139
|
+
if (invocation || systemInstructions.length || outputRequirements?.kind === "structured" || options.outputSchema || options.operation ||
|
|
140
|
+
options.maxOutputTokens !== undefined || options.effortHint !== undefined || options.effortByModel !== undefined ||
|
|
141
|
+
profile.defaults?.maxOutputTokens !== undefined || profile.effortPolicy?.enabled || profile.requiredCapabilities.structuredOutput ||
|
|
142
|
+
profile.requiredCapabilities.providerTools?.length || profile.caps?.maxOutputTokens !== undefined ||
|
|
143
|
+
deps.clientCaps?.maxOutputTokens !== undefined || options.caps?.maxOutputTokens !== undefined)
|
|
144
|
+
throw new UnsupportedCapabilityError("Image generation cannot silently discard text, reasoning, schema or tool controls.");
|
|
145
|
+
}
|
|
115
146
|
if (invocation) {
|
|
116
147
|
richRequest = invocation.map().request;
|
|
117
|
-
const primary =
|
|
148
|
+
const primary = resolveSlot(profile.primary);
|
|
118
149
|
if (richRequest.model !== undefined && richRequest.model !== primary?.catalogId && richRequest.model !== primary?.providerModelId)
|
|
119
150
|
throw new ConfigurationInvalidError("Request model differs from the pinned primary model");
|
|
120
151
|
effectiveInstructions = richRequest.instructions === undefined ? systemInstructions : systemInstructions + "\n\n" + richRequest.instructions;
|
|
@@ -146,9 +177,12 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
146
177
|
if (searchCount !== undefined && (!Number.isSafeInteger(searchCount) || searchCount < 1 || searchCount > 50)) {
|
|
147
178
|
throw new ConfigurationInvalidError("ZAI searchResultCount must be an integer from 1 to 50");
|
|
148
179
|
}
|
|
149
|
-
const
|
|
180
|
+
const routePass = provenance.kind === "route-set" || provenance.kind === "standalone-route";
|
|
181
|
+
const forward = routePass || profile.execution.fallbackPolicy === "forward-only";
|
|
150
182
|
const slotLimit = forward ? 1 + profile.fallbacks.length : Infinity;
|
|
151
|
-
|
|
183
|
+
// A Route ends at the last configured slot. The retained execution paths keep their original attempt rules.
|
|
184
|
+
const maxAttempts = routePass ? Infinity :
|
|
185
|
+
Math.min(slotLimit, profile.execution.maxAttempts ?? (forward ? slotLimit : 3), options.execution?.maxAttempts ?? Infinity);
|
|
152
186
|
const callerTiming = "directModel" in token || options.execution?.timingPolicy === "caller";
|
|
153
187
|
const clock = () => performance.now();
|
|
154
188
|
const deadlineMs = Math.min(nativeOperation?.timeoutMs ?? Infinity, callerTiming ? options.execution?.deadlineMs ?? Infinity
|
|
@@ -236,11 +270,10 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
236
270
|
provenance.modelConfigurationDigest : provenance.revision,
|
|
237
271
|
supportsResponseId: adapter?.supportsResponseId === true };
|
|
238
272
|
};
|
|
239
|
-
const primaryTarget = models.has(profile.primary.catalogId) ? targetFor(
|
|
273
|
+
const primaryTarget = models.has(profile.primary.catalogId) ? targetFor(resolveSlot(profile.primary)) : undefined;
|
|
240
274
|
for (const [index, slot] of slots.entries()) {
|
|
241
|
-
const role = index === 0 ? "primary" : "fallback"
|
|
242
|
-
|
|
243
|
-
throw new ConfigurationInvalidError(`${role} ${slot.catalogId}: missing from the pinned catalog`);
|
|
275
|
+
const role = index === 0 ? "primary" : "fallback";
|
|
276
|
+
const model = resolveSlot(slot);
|
|
244
277
|
if (profile.catalogCompatibility?.excludedCatalogIds?.includes(slot.catalogId))
|
|
245
278
|
throw new ConfigurationInvalidError(`${role} ${slot.catalogId}: excluded by the pinned profile`);
|
|
246
279
|
// An invalid extension is still invalid even if its slot is never reached.
|
|
@@ -253,13 +286,23 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
253
286
|
: modelEndpointConflict(snapshot.catalog, model) ? "model-unavailable"
|
|
254
287
|
: !adapter ? "adapter-missing" : !adapter.providers.includes(model.provider) ? "adapter-provider"
|
|
255
288
|
: minVersion && !satisfiesMin(routeVersion, minVersion) ? "adapter-version"
|
|
256
|
-
: !model.capabilities.outputModalities.includes("
|
|
289
|
+
: imageRequest ? !model.capabilities.outputModalities.includes("image") || !adapter.supportsImageOutput || !adapter.executeImage
|
|
290
|
+
? "image-output" : undefined
|
|
291
|
+
: !model.capabilities.outputModalities.includes("text") ? "text-output" : undefined;
|
|
257
292
|
if (unavailableReason) {
|
|
258
293
|
unavailable.push(`${role} ${slot.catalogId} (${model.provider}): ${unavailableReason}; skipped.`);
|
|
259
294
|
skippedSlots.push({ slot: index, catalogId: slot.catalogId, providerModelId: model.providerModelId, role,
|
|
260
295
|
reason: unavailableReason, phase: "preflight", providerRequestStarted: false });
|
|
261
296
|
continue;
|
|
262
297
|
}
|
|
298
|
+
if (imageRequest) {
|
|
299
|
+
validateImageTransport(imageRequest, adapter.id);
|
|
300
|
+
if (!model.capabilities.inputModalities.includes("text") || !adapter.supportedInputModalities.includes("text"))
|
|
301
|
+
throw new UnsupportedCapabilityError("Image generation requires text prompt input support.");
|
|
302
|
+
if (Object.keys(slot.settings).some(key => key !== "reasoning") ||
|
|
303
|
+
slot.settings.reasoning && slot.settings.reasoning.mode !== "provider-default")
|
|
304
|
+
throw new UnsupportedCapabilityError("Image generation cannot silently discard saved text-generation controls.");
|
|
305
|
+
}
|
|
263
306
|
const generation = richRequest ? structuredClone(richRequest) : { items: [{ type: "message", role: "user", content: [
|
|
264
307
|
{ type: "text", text: typeof options.input === "string" ? options.input : options.input.text ?? "" },
|
|
265
308
|
...(typeof options.input === "string" ? [] : (options.input.images ?? []).map(image => ({ type: "image",
|
|
@@ -280,11 +323,13 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
280
323
|
reason: "continuation-not-portable", phase: "preflight", providerRequestStarted: false });
|
|
281
324
|
continue;
|
|
282
325
|
}
|
|
283
|
-
const features =
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
326
|
+
const features = imageRequest ? { request: generation, buffered: false, warnings: [],
|
|
327
|
+
features: [{ feature: "image-output", requested: true, effective: "sent" }] } :
|
|
328
|
+
planGenerationFeatures({ request: continuation?.request ?? generation, model, adapter: adapter, role,
|
|
329
|
+
stream: Boolean(invocation?.stream),
|
|
330
|
+
requiredInputModalities: profile.requiredCapabilities.inputModalities,
|
|
331
|
+
requiredProviderTools: profile.requiredCapabilities.providerTools, slotProviderOptions: slot.settings.providerOptions,
|
|
332
|
+
reasoningControl: slot.settings.reasoning });
|
|
288
333
|
const blocks = features.request.items.flatMap(item => item.type === "message" ? item.content ?? [] : []);
|
|
289
334
|
if (continuation) {
|
|
290
335
|
features.features.push(...continuation.features);
|
|
@@ -395,7 +440,9 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
395
440
|
const effectiveEstimate = plan.estimatedInputTokens;
|
|
396
441
|
const pricing = costPricing(snapshot.catalog, snapshot.manifest, plan.slot.catalogId, plan.costContext, effectiveEstimate);
|
|
397
442
|
const ceiling = preflightCostCeiling(pricing.price, effectiveEstimate, output.effective ?? knownOutputCeiling(plan.model, effectiveEstimate), pricing.context);
|
|
398
|
-
return [{ plan, effort, nativeSettings, output, preflightCost:
|
|
443
|
+
return [{ plan, effort, nativeSettings, output, preflightCost: imageRequest
|
|
444
|
+
? { currency: "USD", priceKnown: false, uncertainties: ["price-conditions"], basis: "preflight-estimate" }
|
|
445
|
+
: toCostEstimate(ceiling, "preflight-estimate") }];
|
|
399
446
|
});
|
|
400
447
|
// The applicable cost-ceiling policy: profile, client, and invocation caps intersect.
|
|
401
448
|
const budget = intersectCostCaps(profile.caps?.maxEstimatedCost, deps.clientCaps?.maxEstimatedCost, options.caps?.maxEstimatedCost);
|
|
@@ -404,12 +451,12 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
404
451
|
let attemptIndex = 0;
|
|
405
452
|
let slotCursor = 0, visitIndex = 0;
|
|
406
453
|
const unavailableSlots = new Set();
|
|
407
|
-
const hasNextPlan = () =>
|
|
408
|
-
!unavailableSlots.has(evidence.plan.slotIndex));
|
|
454
|
+
const hasNextPlan = () => forward ? slotCursor < preparedPlans.length :
|
|
455
|
+
preparedPlans.some(evidence => !unavailableSlots.has(evidence.plan.slotIndex));
|
|
409
456
|
const nextPlan = () => {
|
|
457
|
+
if (forward)
|
|
458
|
+
return preparedPlans[slotCursor++];
|
|
410
459
|
for (let scanned = 0; scanned < preparedPlans.length; scanned++) {
|
|
411
|
-
if (forward && slotCursor >= preparedPlans.length)
|
|
412
|
-
return undefined;
|
|
413
460
|
const candidate = preparedPlans[slotCursor++ % preparedPlans.length];
|
|
414
461
|
if (!unavailableSlots.has(candidate.plan.slotIndex))
|
|
415
462
|
return candidate;
|
|
@@ -471,6 +518,8 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
471
518
|
: Math.min(remaining, profile.execution.attemptTimeoutMs ?? 60_000, options.execution?.attemptTimeoutMs ?? Infinity);
|
|
472
519
|
let providerRequestStarted = false;
|
|
473
520
|
let response;
|
|
521
|
+
let providerReportedModelId;
|
|
522
|
+
let reportedIdentityCaptured = false;
|
|
474
523
|
let streamStarted = false, streamResponseId;
|
|
475
524
|
try {
|
|
476
525
|
const adapter = deps.registry.get(plan.model.adapterId);
|
|
@@ -550,6 +599,7 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
550
599
|
reserveBudget();
|
|
551
600
|
providerRequestStarted = true;
|
|
552
601
|
const adapterRequest = {
|
|
602
|
+
...(imageRequest ? { imageRequest: imageRequest } : {}),
|
|
553
603
|
model: plan.model,
|
|
554
604
|
systemInstructions: effectiveInstructions,
|
|
555
605
|
input: plan.input,
|
|
@@ -610,7 +660,8 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
610
660
|
}
|
|
611
661
|
}
|
|
612
662
|
else
|
|
613
|
-
result = await adapter.
|
|
663
|
+
result = imageRequest ? await adapter.executeImage(adapterRequest, guardedFetch)
|
|
664
|
+
: await adapter.execute(adapterRequest, guardedFetch);
|
|
614
665
|
assertDispatchAllowed();
|
|
615
666
|
return result;
|
|
616
667
|
}, admittedTimeout, () => new ProviderCallError("provider-timeout", "Attempt deadline exceeded", true), queueSignal);
|
|
@@ -635,7 +686,11 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
635
686
|
throw new CancellationError();
|
|
636
687
|
if (clock() >= deadlineAt)
|
|
637
688
|
throw deadlineError();
|
|
689
|
+
providerReportedModelId = reportedModelId(response);
|
|
690
|
+
reportedIdentityCaptured = true;
|
|
638
691
|
response = validateAdapterResponse(response);
|
|
692
|
+
if (imageRequest && !response.images?.length || !imageRequest && response.images)
|
|
693
|
+
throw new InvalidOutputError("Adapter output does not match the requested operation.");
|
|
639
694
|
response.usage = mergeReportedUsage(response.generation?.usage, response.usage);
|
|
640
695
|
let generation;
|
|
641
696
|
if (invocation) {
|
|
@@ -695,7 +750,7 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
695
750
|
if (options.signal?.aborted)
|
|
696
751
|
throw new CancellationError();
|
|
697
752
|
}
|
|
698
|
-
const cost = response.usage ? measuredCost(response.usage, response.generation)
|
|
753
|
+
const cost = imageRequest ? { ...evidence.preflightCost } : response.usage ? measuredCost(response.usage, response.generation)
|
|
699
754
|
: toCostEstimate(applyReportedCostContext(evidence.preflightCost, response.generation?.costContext), "preflight-estimate");
|
|
700
755
|
// Search is not uniformly metered across providers; token costs alone are not the total.
|
|
701
756
|
if (effectiveSearch) {
|
|
@@ -716,6 +771,8 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
716
771
|
role: plan.role,
|
|
717
772
|
latencyMs: elapsedSince(attemptStartedAt),
|
|
718
773
|
outcome: "succeeded",
|
|
774
|
+
...(providerReportedModelId ? { providerReportedModelId } : {}),
|
|
775
|
+
...(response.images ? { imageOutput: imageOutputEvidence(response.images) } : {}),
|
|
719
776
|
providerRequestStarted,
|
|
720
777
|
effective: effectiveControls(executionConfiguration(token), evidence),
|
|
721
778
|
usage: response.usage,
|
|
@@ -742,16 +799,23 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
742
799
|
startedAt
|
|
743
800
|
}));
|
|
744
801
|
return {
|
|
802
|
+
...(response.images ? { images: response.images } : {}),
|
|
745
803
|
output: validateStructured ? { kind: "structured", value } : { kind: "text", text: generation?.text ??
|
|
746
804
|
(response.output.kind === "structured" ? JSON.stringify(response.output.value) : response.output.kind === "text" ? response.output.text : "") },
|
|
747
805
|
executionReceipt: receipt, ...(generation ? { generation, requestId, providerModelId: plan.model.providerModelId } : {})
|
|
748
806
|
};
|
|
749
807
|
}
|
|
750
808
|
catch (error) {
|
|
751
|
-
|
|
809
|
+
let aiError = error instanceof AISubsystemError ? error : new AISubsystemError("network-error", "Provider adapter failed unexpectedly", true);
|
|
810
|
+
// The total deadline wins if an inner provider/attempt timer settles at the same boundary.
|
|
811
|
+
// Otherwise the bridge can mistake whole-call exhaustion for a retryable per-attempt timeout.
|
|
812
|
+
if (!options.signal?.aborted && clock() >= deadlineAt)
|
|
813
|
+
aiError = attachProviderErrorContext(deadlineError(), aiError);
|
|
752
814
|
if (!response && aiError.partialResult)
|
|
753
815
|
response = { output: { kind: "text", text: aiError.partialResult.text },
|
|
754
816
|
generation: aiError.partialResult, usage: aiError.partialResult.usage };
|
|
817
|
+
if (!reportedIdentityCaptured)
|
|
818
|
+
providerReportedModelId = reportedModelId(response);
|
|
755
819
|
if (response?.usage !== undefined) {
|
|
756
820
|
try {
|
|
757
821
|
response.usage = validateUsage(response.usage);
|
|
@@ -799,11 +863,12 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
799
863
|
role: plan.role,
|
|
800
864
|
latencyMs: elapsedSince(attemptStartedAt),
|
|
801
865
|
outcome: "cancelled",
|
|
866
|
+
...(providerReportedModelId ? { providerReportedModelId } : {}),
|
|
802
867
|
providerRequestStarted,
|
|
803
868
|
effective: effectiveControls(executionConfiguration(token), evidence),
|
|
804
869
|
errorClass: "cancelled",
|
|
805
870
|
usage: response?.usage,
|
|
806
|
-
costEstimate: response?.usage ? measuredCost(response.usage, response.generation)
|
|
871
|
+
costEstimate: imageRequest ? { ...evidence.preflightCost } : response?.usage ? measuredCost(response.usage, response.generation)
|
|
807
872
|
: toCostEstimate(applyReportedCostContext(evidence.preflightCost, response?.generation?.costContext), "preflight-estimate")
|
|
808
873
|
});
|
|
809
874
|
throw attachProviderErrorContext(new CancellationError(), aiError);
|
|
@@ -832,12 +897,13 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
832
897
|
role: plan.role,
|
|
833
898
|
latencyMs: elapsedSince(attemptStartedAt),
|
|
834
899
|
outcome: "failed",
|
|
900
|
+
...(providerReportedModelId ? { providerReportedModelId } : {}),
|
|
835
901
|
providerRequestStarted,
|
|
836
902
|
effective: effectiveControls(executionConfiguration(token), evidence),
|
|
837
903
|
errorClass: aiError.code,
|
|
838
904
|
errorMessage: receiptErrorMessage(aiError),
|
|
839
905
|
usage: response?.usage,
|
|
840
|
-
costEstimate: response?.usage ? measuredCost(response.usage, response.generation)
|
|
906
|
+
costEstimate: imageRequest ? { ...evidence.preflightCost } : response?.usage ? measuredCost(response.usage, response.generation)
|
|
841
907
|
: toCostEstimate(applyReportedCostContext(evidence.preflightCost, response?.generation?.costContext), "preflight-estimate")
|
|
842
908
|
});
|
|
843
909
|
if (!eligible || invocation?.stream?.context.outputExposed)
|
|
@@ -849,7 +915,8 @@ export function createRun(token, snapshot, deps, resolutionWarnings = []) {
|
|
|
849
915
|
await retryDelay(delay, deadlineAt - clock(), deadlineError, options.signal);
|
|
850
916
|
}
|
|
851
917
|
}
|
|
852
|
-
throw attachProviderErrorContext(new AttemptsExhaustedError(`
|
|
918
|
+
throw attachProviderErrorContext(new AttemptsExhaustedError(routePass ? `Route finished without a successful response (${attemptIndex} attempts).` :
|
|
919
|
+
`Attempts exhausted or all remaining slots unavailable (${attemptIndex}/${maxAttempts} attempts consumed).`, { attempts: attempts.length, lastError: lastError?.code }), lastError ?? {});
|
|
853
920
|
}
|
|
854
921
|
catch (error) {
|
|
855
922
|
const aiError = error instanceof AISubsystemError
|
|
@@ -935,6 +1002,10 @@ function validateInvocationControls(options) {
|
|
|
935
1002
|
}
|
|
936
1003
|
}
|
|
937
1004
|
}
|
|
1005
|
+
function reportedModelId(response) {
|
|
1006
|
+
const value = response?.providerReportedModelId ?? response?.generation?.providerModelId;
|
|
1007
|
+
return typeof value === "string" && value.length > 0 && value.length <= 256 && /^[A-Za-z0-9_.:/@+-]+$/.test(value) ? value : undefined;
|
|
1008
|
+
}
|
|
938
1009
|
function validateGenerateInput(input) {
|
|
939
1010
|
if (typeof input === "string")
|
|
940
1011
|
return;
|