@independo/inderun-web 0.4.0 → 0.5.0-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.
- package/dist/core/artifacts.d.ts +110 -0
- package/dist/core/artifacts.d.ts.map +1 -0
- package/dist/core/artifacts.js +190 -0
- package/dist/core/engine.d.ts +28 -1
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/engine.js +232 -28
- package/dist/core/generated/inderun-api.d.ts +12 -4
- package/dist/core/generated/inderun-api.d.ts.map +1 -1
- package/dist/core/host.d.ts +1 -1
- package/dist/core/host.d.ts.map +1 -1
- package/dist/core/provenance.d.ts +5 -2
- package/dist/core/provenance.d.ts.map +1 -1
- package/dist/core/provenance.js +6 -2
- package/dist/core/provider.d.ts +50 -130
- package/dist/core/provider.d.ts.map +1 -1
- package/dist/core/route-planner.d.ts +5 -5
- package/dist/core/route-planner.d.ts.map +1 -1
- package/dist/core/route-planner.js +15 -29
- package/dist/core/router.d.ts +16 -0
- package/dist/core/router.d.ts.map +1 -1
- package/dist/core/router.js +14 -5
- package/dist/core/task-profiles.d.ts +54 -0
- package/dist/core/task-profiles.d.ts.map +1 -0
- package/dist/core/task-profiles.js +92 -0
- package/dist/facade/text.d.ts.map +1 -1
- package/dist/facade/text.js +5 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/providers/onnx/runtime.d.ts +2 -2
- package/dist/providers/onnx/runtime.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/core/artifacts.ts +280 -0
- package/src/core/engine.ts +281 -27
- package/src/core/generated/inderun-api.ts +12 -4
- package/src/core/host.ts +1 -0
- package/src/core/provenance.ts +7 -2
- package/src/core/provider.ts +64 -135
- package/src/core/route-planner.ts +20 -36
- package/src/core/router.ts +30 -7
- package/src/core/task-profiles.ts +145 -0
- package/src/facade/text.ts +5 -3
- package/src/index.ts +6 -1
- package/src/providers/onnx/runtime.ts +2 -2
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { ArtifactReadRequest, MediaArtifact } from "@independo/inderun-contracts";
|
|
2
|
+
/**
|
|
3
|
+
* Size limits of an engine's artifact store (ADR 017). Every limit is in bytes.
|
|
4
|
+
*/
|
|
5
|
+
export interface ArtifactLimits {
|
|
6
|
+
/** Largest single artifact a provider may write. Default 16 MiB. */
|
|
7
|
+
maxArtifactBytes?: number;
|
|
8
|
+
/** Most bytes the store holds across all undisposed artifacts. Default 64 MiB. */
|
|
9
|
+
maxStoreBytes?: number;
|
|
10
|
+
/** Most bytes one `readArtifact` call returns. Default 1 MiB. */
|
|
11
|
+
maxReadBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_ARTIFACT_LIMITS: Required<ArtifactLimits>;
|
|
14
|
+
/**
|
|
15
|
+
* One range of an artifact's bytes, as `IndeRun.readArtifact` returns it.
|
|
16
|
+
*/
|
|
17
|
+
export interface ArtifactChunk {
|
|
18
|
+
/** The artifact the bytes belong to. */
|
|
19
|
+
artifactId: string;
|
|
20
|
+
/** Byte offset of `bytes` within the artifact. */
|
|
21
|
+
offset: number;
|
|
22
|
+
/** The bytes of this range; empty when `offset` is the artifact's end. */
|
|
23
|
+
bytes: Uint8Array;
|
|
24
|
+
/** Size of the whole artifact in bytes. */
|
|
25
|
+
totalBytes: number;
|
|
26
|
+
/** Whether this range reaches the end of the artifact. */
|
|
27
|
+
done: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** What a provider declares when it starts writing an artifact. */
|
|
30
|
+
export interface ArtifactSpec {
|
|
31
|
+
/** IANA media type of the bytes, e.g. `audio/wav`; parameters ride on it. */
|
|
32
|
+
mediaType: string;
|
|
33
|
+
/** Duration of time-based media in milliseconds, where the provider knows it. */
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Writes one artifact into the engine's store. `finish()` hands it over: it commits the run
|
|
38
|
+
* to the provider and returns the reference the provider puts in its output. A provider that
|
|
39
|
+
* fails or stops before `finish()` calls `abort()`; the engine also discards any writer an
|
|
40
|
+
* attempt left open.
|
|
41
|
+
*/
|
|
42
|
+
export interface ArtifactWriter {
|
|
43
|
+
/**
|
|
44
|
+
* Appends bytes. Throws `Unavailable` (`details.code: "artifact_too_large"`) once the
|
|
45
|
+
* artifact would exceed the engine's per-artifact limit; the attempt has not committed, so
|
|
46
|
+
* the run may fall back.
|
|
47
|
+
*/
|
|
48
|
+
write(bytes: Uint8Array): void;
|
|
49
|
+
/**
|
|
50
|
+
* Hands the finished artifact to the engine and commits the run. Throws `Unavailable`
|
|
51
|
+
* (`artifact_store_full`) when the store has no room, and `Unavailable`
|
|
52
|
+
* (`run_not_active`) when the run was cancelled or has ended -- in both cases before
|
|
53
|
+
* committing.
|
|
54
|
+
*/
|
|
55
|
+
finish(): MediaArtifact;
|
|
56
|
+
/** Discards everything written. Idempotent. */
|
|
57
|
+
abort(): void;
|
|
58
|
+
}
|
|
59
|
+
/** Where a provider creates artifacts: `RunContext.artifacts`. */
|
|
60
|
+
export interface ArtifactSink {
|
|
61
|
+
create(spec: ArtifactSpec): ArtifactWriter;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The engine-owned, in-memory artifact store (ADR 017): one per `IndeRun` instance. It holds
|
|
65
|
+
* every finished artifact until the application disposes it; there are no temporary files,
|
|
66
|
+
* so nothing outlives the process. Reads are ranged and bounded by `maxReadBytes`.
|
|
67
|
+
*/
|
|
68
|
+
export declare class ArtifactStore {
|
|
69
|
+
private readonly limits;
|
|
70
|
+
private readonly artifacts;
|
|
71
|
+
private storedBytes;
|
|
72
|
+
constructor(limits?: ArtifactLimits);
|
|
73
|
+
/**
|
|
74
|
+
* Opens the artifacts of one attempt. `commit` is the attempt's commit hook; a writer's
|
|
75
|
+
* `finish()` calls it, and refuses the handoff when it returns `false`.
|
|
76
|
+
*/
|
|
77
|
+
attempt(commit: () => boolean): AttemptArtifacts;
|
|
78
|
+
/** Reads one range. See `IndeRunApi.readArtifact` for the contract. */
|
|
79
|
+
read(request: ArtifactReadRequest): ArtifactChunk;
|
|
80
|
+
/** Releases an artifact's bytes. Idempotent; unknown ids are ignored. */
|
|
81
|
+
dispose(artifactId: string): void;
|
|
82
|
+
/** The stored reference for `artifactId`, or `undefined` once it was disposed. */
|
|
83
|
+
reference(artifactId: string): MediaArtifact | undefined;
|
|
84
|
+
/** @internal Registers a finished artifact. */
|
|
85
|
+
store(spec: ArtifactSpec, bytes: Uint8Array): MediaArtifact;
|
|
86
|
+
/** @internal The whole artifact, for writing it to an application destination. */
|
|
87
|
+
bytes(artifactId: string): Uint8Array | undefined;
|
|
88
|
+
/** @internal */
|
|
89
|
+
get maxArtifactBytes(): number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The artifacts one attempt created. The engine keeps the one the attempt returned and
|
|
93
|
+
* releases the rest: everything from an attempt that failed, was cancelled or lost to
|
|
94
|
+
* fallback, and anything a winning attempt finished but did not return. A returned artifact
|
|
95
|
+
* is never released behind the application's back.
|
|
96
|
+
*/
|
|
97
|
+
export declare class AttemptArtifacts implements ArtifactSink {
|
|
98
|
+
private readonly store;
|
|
99
|
+
private readonly commit;
|
|
100
|
+
private readonly finished;
|
|
101
|
+
private readonly open;
|
|
102
|
+
private released;
|
|
103
|
+
constructor(store: ArtifactStore, commit: () => boolean);
|
|
104
|
+
create(spec: ArtifactSpec): ArtifactWriter;
|
|
105
|
+
/** Whether `artifactId` was finished by this attempt and is still held. */
|
|
106
|
+
owns(artifactId: string): boolean;
|
|
107
|
+
/** Releases every artifact of this attempt except `keep`, and closes open writers. */
|
|
108
|
+
release(keep?: string): void;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=artifacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../src/core/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAA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GAAG,gBAAgB;IAIhD,uEAAuE;IACvE,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,aAAa;IAkCjD,yEAAyE;IACzE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAOjC,kFAAkF;IAClF,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIxD,+CAA+C;IAC/C,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa;IAsB3D,kFAAkF;IAClF,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIjD,gBAAgB;IAChB,IAAI,gBAAgB,IAAI,MAAM,CAE7B;CACF;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IAMjD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAClD,OAAO,CAAC,QAAQ,CAAS;gBAGN,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,OAAO;IAGxC,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,cAAc;IAkD1C,2EAA2E;IAC3E,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIjC,sFAAsF;IACtF,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;CAQ7B"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { createInternal, createUnavailable } from "./errors.js";
|
|
2
|
+
export const DEFAULT_ARTIFACT_LIMITS = {
|
|
3
|
+
maxArtifactBytes: 16 * 1024 * 1024,
|
|
4
|
+
maxStoreBytes: 64 * 1024 * 1024,
|
|
5
|
+
maxReadBytes: 1024 * 1024
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The engine-owned, in-memory artifact store (ADR 017): one per `IndeRun` instance. It holds
|
|
9
|
+
* every finished artifact until the application disposes it; there are no temporary files,
|
|
10
|
+
* so nothing outlives the process. Reads are ranged and bounded by `maxReadBytes`.
|
|
11
|
+
*/
|
|
12
|
+
export class ArtifactStore {
|
|
13
|
+
limits;
|
|
14
|
+
artifacts = new Map();
|
|
15
|
+
storedBytes = 0;
|
|
16
|
+
constructor(limits = {}) {
|
|
17
|
+
this.limits = { ...DEFAULT_ARTIFACT_LIMITS, ...limits };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Opens the artifacts of one attempt. `commit` is the attempt's commit hook; a writer's
|
|
21
|
+
* `finish()` calls it, and refuses the handoff when it returns `false`.
|
|
22
|
+
*/
|
|
23
|
+
attempt(commit) {
|
|
24
|
+
return new AttemptArtifacts(this, commit);
|
|
25
|
+
}
|
|
26
|
+
/** Reads one range. See `IndeRunApi.readArtifact` for the contract. */
|
|
27
|
+
read(request) {
|
|
28
|
+
const stored = this.artifacts.get(request.artifactId);
|
|
29
|
+
if (stored === undefined) {
|
|
30
|
+
throw createUnavailable(`Artifact '${request.artifactId}' is not held by this engine.`, {
|
|
31
|
+
retryable: false,
|
|
32
|
+
details: { code: "artifact_not_found" }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const totalBytes = stored.bytes.byteLength;
|
|
36
|
+
const offset = request.offset ?? 0;
|
|
37
|
+
if (offset > totalBytes) {
|
|
38
|
+
const validationIssues = [
|
|
39
|
+
{
|
|
40
|
+
path: "/offset",
|
|
41
|
+
message: `offset ${offset} is beyond the artifact's ${totalBytes} bytes`
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
throw createInternal(`Validation failed for ArtifactReadRequest: /offset - ${validationIssues[0].message}`, { details: { validationIssues } });
|
|
45
|
+
}
|
|
46
|
+
const length = Math.min(request.maxBytes ?? this.limits.maxReadBytes, this.limits.maxReadBytes);
|
|
47
|
+
const end = Math.min(offset + length, totalBytes);
|
|
48
|
+
return {
|
|
49
|
+
artifactId: request.artifactId,
|
|
50
|
+
offset,
|
|
51
|
+
// A copy: the caller may keep or mutate it without touching the stored bytes.
|
|
52
|
+
bytes: stored.bytes.slice(offset, end),
|
|
53
|
+
totalBytes,
|
|
54
|
+
done: end === totalBytes
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Releases an artifact's bytes. Idempotent; unknown ids are ignored. */
|
|
58
|
+
dispose(artifactId) {
|
|
59
|
+
const stored = this.artifacts.get(artifactId);
|
|
60
|
+
if (stored === undefined)
|
|
61
|
+
return;
|
|
62
|
+
this.artifacts.delete(artifactId);
|
|
63
|
+
this.storedBytes -= stored.bytes.byteLength;
|
|
64
|
+
}
|
|
65
|
+
/** The stored reference for `artifactId`, or `undefined` once it was disposed. */
|
|
66
|
+
reference(artifactId) {
|
|
67
|
+
return this.artifacts.get(artifactId)?.reference;
|
|
68
|
+
}
|
|
69
|
+
/** @internal Registers a finished artifact. */
|
|
70
|
+
store(spec, bytes) {
|
|
71
|
+
if (this.storedBytes + bytes.byteLength > this.limits.maxStoreBytes) {
|
|
72
|
+
throw createUnavailable("The engine's artifact store is full; dispose artifacts to free it.", {
|
|
73
|
+
details: { code: "artifact_store_full" }
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const reference = {
|
|
77
|
+
id: `art_${randomId()}`,
|
|
78
|
+
mediaType: spec.mediaType,
|
|
79
|
+
owner: "engine",
|
|
80
|
+
lifetime: "until_disposed",
|
|
81
|
+
byteLength: bytes.byteLength,
|
|
82
|
+
...(spec.durationMs !== undefined ? { durationMs: spec.durationMs } : {})
|
|
83
|
+
};
|
|
84
|
+
this.artifacts.set(reference.id, { reference, bytes });
|
|
85
|
+
this.storedBytes += bytes.byteLength;
|
|
86
|
+
return reference;
|
|
87
|
+
}
|
|
88
|
+
/** @internal The whole artifact, for writing it to an application destination. */
|
|
89
|
+
bytes(artifactId) {
|
|
90
|
+
return this.artifacts.get(artifactId)?.bytes;
|
|
91
|
+
}
|
|
92
|
+
/** @internal */
|
|
93
|
+
get maxArtifactBytes() {
|
|
94
|
+
return this.limits.maxArtifactBytes;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The artifacts one attempt created. The engine keeps the one the attempt returned and
|
|
99
|
+
* releases the rest: everything from an attempt that failed, was cancelled or lost to
|
|
100
|
+
* fallback, and anything a winning attempt finished but did not return. A returned artifact
|
|
101
|
+
* is never released behind the application's back.
|
|
102
|
+
*/
|
|
103
|
+
export class AttemptArtifacts {
|
|
104
|
+
store;
|
|
105
|
+
commit;
|
|
106
|
+
finished = new Set();
|
|
107
|
+
open = new Set();
|
|
108
|
+
released = false;
|
|
109
|
+
constructor(store, commit) {
|
|
110
|
+
this.store = store;
|
|
111
|
+
this.commit = commit;
|
|
112
|
+
}
|
|
113
|
+
create(spec) {
|
|
114
|
+
const chunks = [];
|
|
115
|
+
let size = 0;
|
|
116
|
+
let closed = false;
|
|
117
|
+
const writer = {
|
|
118
|
+
write: (bytes) => {
|
|
119
|
+
if (closed)
|
|
120
|
+
throw createInternal("The artifact writer is already closed.");
|
|
121
|
+
if (size + bytes.byteLength > this.store.maxArtifactBytes) {
|
|
122
|
+
writer.abort();
|
|
123
|
+
throw createUnavailable(`The artifact exceeds the engine's ${this.store.maxArtifactBytes}-byte limit.`, { details: { code: "artifact_too_large" } });
|
|
124
|
+
}
|
|
125
|
+
chunks.push(bytes.slice());
|
|
126
|
+
size += bytes.byteLength;
|
|
127
|
+
},
|
|
128
|
+
finish: () => {
|
|
129
|
+
if (closed)
|
|
130
|
+
throw createInternal("The artifact writer is already closed.");
|
|
131
|
+
const bytes = concat(chunks, size);
|
|
132
|
+
writer.abort();
|
|
133
|
+
// A provider that keeps working after its attempt ended (a late callback, say) must
|
|
134
|
+
// not leave an artifact behind that nobody owns.
|
|
135
|
+
if (this.released) {
|
|
136
|
+
throw createUnavailable("The attempt has ended; the artifact was discarded.", {
|
|
137
|
+
details: { code: "run_not_active" }
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// Stored before the commit so a full store fails the attempt pre-commit; dropped
|
|
141
|
+
// again when the run refuses the commit.
|
|
142
|
+
const reference = this.store.store(spec, bytes);
|
|
143
|
+
if (!this.commit()) {
|
|
144
|
+
this.store.dispose(reference.id);
|
|
145
|
+
throw createUnavailable("The run is no longer active; the artifact was discarded.", {
|
|
146
|
+
details: { code: "run_not_active" }
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
this.finished.add(reference.id);
|
|
150
|
+
return reference;
|
|
151
|
+
},
|
|
152
|
+
abort: () => {
|
|
153
|
+
closed = true;
|
|
154
|
+
chunks.length = 0;
|
|
155
|
+
this.open.delete(writer);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
this.open.add(writer);
|
|
159
|
+
return writer;
|
|
160
|
+
}
|
|
161
|
+
/** Whether `artifactId` was finished by this attempt and is still held. */
|
|
162
|
+
owns(artifactId) {
|
|
163
|
+
return this.finished.has(artifactId) && this.store.reference(artifactId) !== undefined;
|
|
164
|
+
}
|
|
165
|
+
/** Releases every artifact of this attempt except `keep`, and closes open writers. */
|
|
166
|
+
release(keep) {
|
|
167
|
+
this.released = true;
|
|
168
|
+
for (const writer of [...this.open])
|
|
169
|
+
writer.abort();
|
|
170
|
+
for (const id of this.finished) {
|
|
171
|
+
if (id !== keep)
|
|
172
|
+
this.store.dispose(id);
|
|
173
|
+
}
|
|
174
|
+
this.finished.clear();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function concat(chunks, size) {
|
|
178
|
+
const bytes = new Uint8Array(size);
|
|
179
|
+
let offset = 0;
|
|
180
|
+
for (const chunk of chunks) {
|
|
181
|
+
bytes.set(chunk, offset);
|
|
182
|
+
offset += chunk.byteLength;
|
|
183
|
+
}
|
|
184
|
+
return bytes;
|
|
185
|
+
}
|
|
186
|
+
function randomId() {
|
|
187
|
+
const random = new Uint8Array(12);
|
|
188
|
+
globalThis.crypto.getRandomValues(random);
|
|
189
|
+
return Array.from(random, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
190
|
+
}
|
package/dist/core/engine.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { type TaskRequest, type TaskResult } from "@independo/inderun-contracts";
|
|
1
|
+
import { type ArtifactReadRequest, type MediaArtifact, type TaskRequest, type TaskResult } from "@independo/inderun-contracts";
|
|
2
2
|
import type { HostServices } from "./host.js";
|
|
3
3
|
import type { ProviderCapabilitySnapshot, StreamRun } from "./provider.js";
|
|
4
4
|
import type { IndeRunApi } from "./generated/inderun-api.js";
|
|
5
5
|
import { ProviderRegistry } from "./registry.js";
|
|
6
6
|
import { type TelemetryService } from "./telemetry.js";
|
|
7
7
|
import { type ModelProfiles } from "./model-profiles.js";
|
|
8
|
+
import { type ArtifactChunk, type ArtifactLimits } from "./artifacts.js";
|
|
8
9
|
/**
|
|
9
10
|
* @deprecated Renamed to `StreamRun`, which is the name the generated
|
|
10
11
|
* `IndeRunApi` surface and the Swift/Kotlin SDKs use. Kept as an alias so the
|
|
@@ -25,6 +26,11 @@ export interface IndeRunOptions {
|
|
|
25
26
|
* `"auto"` is built in and cannot be redefined. See `docs/architecture/api-layering.md`.
|
|
26
27
|
*/
|
|
27
28
|
modelProfiles?: ModelProfiles;
|
|
29
|
+
/**
|
|
30
|
+
* Size limits of the engine's in-memory artifact store (ADR 017). Defaults: 16 MiB per
|
|
31
|
+
* artifact, 64 MiB in total, 1 MiB per `readArtifact` call.
|
|
32
|
+
*/
|
|
33
|
+
artifacts?: ArtifactLimits;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* Main orchestrator SDK entrypoint class.
|
|
@@ -35,6 +41,7 @@ export declare class IndeRun implements IndeRunApi {
|
|
|
35
41
|
private registry;
|
|
36
42
|
private hostServices;
|
|
37
43
|
private router;
|
|
44
|
+
private readonly artifacts;
|
|
38
45
|
private telemetryService;
|
|
39
46
|
private modelProfiles;
|
|
40
47
|
/**
|
|
@@ -104,6 +111,26 @@ export declare class IndeRun implements IndeRunApi {
|
|
|
104
111
|
* Reports each registered provider's static descriptor and current dynamic capability check,
|
|
105
112
|
* without executing a task. Useful for UI that shows live provider availability before a run.
|
|
106
113
|
*/
|
|
114
|
+
readArtifact(request: ArtifactReadRequest): Promise<ArtifactChunk>;
|
|
115
|
+
disposeArtifact(artifact: MediaArtifact): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Refuses, before routing, an artifact request whose `destinationRef` this host cannot
|
|
118
|
+
* write to: there is no point running a provider whose result has nowhere to go.
|
|
119
|
+
*/
|
|
120
|
+
private checkDestination;
|
|
121
|
+
/**
|
|
122
|
+
* Writes a finished artifact to the request's application destination, if it names one,
|
|
123
|
+
* and drops the engine's copy: the result's artifact is then application-owned. The run
|
|
124
|
+
* has committed by now, so a failed write is the run's failure, never a fallback.
|
|
125
|
+
*/
|
|
126
|
+
private deliverToDestination;
|
|
127
|
+
/**
|
|
128
|
+
* Checks that an artifact in a provider's output is one this attempt produced, swaps in the
|
|
129
|
+
* reference the store holds, and only then checks the output against the requested delivery:
|
|
130
|
+
* the artifact's media type, size and ownership are the engine's record rather than the
|
|
131
|
+
* provider's claim.
|
|
132
|
+
*/
|
|
133
|
+
private normalizeOutput;
|
|
107
134
|
checkCapabilities(): Promise<ProviderCapabilitySnapshot[]>;
|
|
108
135
|
}
|
|
109
136
|
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAGxB,KAAK,aAAa,EAKlB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,W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