@koda-sl/baker-cli 0.123.0 → 0.124.0-dev.2ddde71d7
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/README.md +366 -77
- package/dist/{chunk-IWPAXJC3.js → chunk-TKL2CJ6G.js} +930 -431
- package/dist/chunk-TKL2CJ6G.js.map +1 -0
- package/dist/cli.js +3798 -2758
- package/dist/cli.js.map +1 -1
- package/dist/engine/index.d.ts +137 -1
- package/dist/engine/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-IWPAXJC3.js.map +0 -1
package/dist/engine/index.d.ts
CHANGED
|
@@ -15,12 +15,33 @@ type ExecRequest = {
|
|
|
15
15
|
/** Run-scoped dedupe key: the backend replays the stored response for a
|
|
16
16
|
* repeated key instead of re-dispatching to the provider (and re-charging). */
|
|
17
17
|
idempotency_key?: string;
|
|
18
|
+
/** Run + node identity, so a completed async job can be mapped back to its
|
|
19
|
+
* frozen run's node by the backend stale-run reconciliation sweep. */
|
|
20
|
+
canvas_run_id?: string;
|
|
21
|
+
node_id?: string;
|
|
18
22
|
};
|
|
19
23
|
type ExecResponse = {
|
|
20
24
|
outputs: Record<string, RawAssetOutput | RawAssetOutput[] | unknown>;
|
|
21
25
|
credits_charged?: number;
|
|
22
26
|
duration_ms?: number;
|
|
23
27
|
};
|
|
28
|
+
/** A resumable run as reported by `GET /api/canvas/runs/active`. */
|
|
29
|
+
type ActiveRunInfo = {
|
|
30
|
+
runId: string;
|
|
31
|
+
status: "running" | "completed" | "failed";
|
|
32
|
+
interrupted?: boolean;
|
|
33
|
+
updatedAt?: number;
|
|
34
|
+
canvasSha?: string;
|
|
35
|
+
canvasSnapshotUrl?: string;
|
|
36
|
+
};
|
|
37
|
+
/** The newest snapshot-bearing run for a creative — `GET /api/canvas/runs/latest`. */
|
|
38
|
+
type SnapshotRunInfo = {
|
|
39
|
+
runId: string;
|
|
40
|
+
status: "running" | "completed" | "failed";
|
|
41
|
+
interrupted?: boolean;
|
|
42
|
+
canvasSha?: string;
|
|
43
|
+
canvasSnapshotUrl: string;
|
|
44
|
+
};
|
|
24
45
|
type ArtifactResponse = {
|
|
25
46
|
artifact: {
|
|
26
47
|
kind: string;
|
|
@@ -43,10 +64,37 @@ declare class BackendClient$1 {
|
|
|
43
64
|
});
|
|
44
65
|
exec(req: ExecRequest, signal?: AbortSignal): Promise<ExecResponse>;
|
|
45
66
|
private pollJob;
|
|
46
|
-
presignAssetUpload(sha256: string, mime: string, signal?: AbortSignal): Promise<{
|
|
67
|
+
presignAssetUpload(sha256: string, mime: string, signal?: AbortSignal, purpose?: "output" | "source" | "blueprint"): Promise<{
|
|
47
68
|
putUrl: string;
|
|
48
69
|
publicUrl: string;
|
|
49
70
|
}>;
|
|
71
|
+
/** Remote cache lookup. A miss (404) — or an old backend without the route — returns null. */
|
|
72
|
+
getCacheEntry<T>(cacheKey: string, signal?: AbortSignal): Promise<T | null>;
|
|
73
|
+
putCacheEntry(entry: {
|
|
74
|
+
cacheKey: string;
|
|
75
|
+
}, signal?: AbortSignal): Promise<void>;
|
|
76
|
+
/** Durable run-history record — POST /api/canvas/runs (idempotent server-side on runId). */
|
|
77
|
+
recordRun(payload: unknown, signal?: AbortSignal): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Resumable-run lookup — GET /api/canvas/runs/active. Returns the newest
|
|
80
|
+
* still-running/interrupted run for the creative (pinned to the exact canvas
|
|
81
|
+
* sha), so a fresh sandbox can adopt its run id and re-attach billed
|
|
82
|
+
* in-flight jobs. Null on no active run — or an older backend without the
|
|
83
|
+
* route (both 404).
|
|
84
|
+
*/
|
|
85
|
+
getActiveRun(creativeSlug: string, canvasSha?: string, signal?: AbortSignal): Promise<ActiveRunInfo | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Portable-rerun lookup — GET /api/canvas/runs/latest. The newest run for
|
|
88
|
+
* the creative that recorded a canvas snapshot manifest; null when none
|
|
89
|
+
* exists (or the backend predates the route — both 404).
|
|
90
|
+
*/
|
|
91
|
+
getLatestSnapshotRun(creativeSlug: string, signal?: AbortSignal): Promise<SnapshotRunInfo | null>;
|
|
92
|
+
/**
|
|
93
|
+
* Chat-scoped blueprint sync — POST /api/creatives/definition. Lets the
|
|
94
|
+
* dashboard draw a scaffolded creative's workflow graph BEFORE the first run.
|
|
95
|
+
* Additive on the backend (never archives siblings, never sets definitionPath).
|
|
96
|
+
*/
|
|
97
|
+
syncCreativeDefinition(payload: unknown, signal?: AbortSignal): Promise<void>;
|
|
50
98
|
getArtifact(kind: string, name: string, version?: string, signal?: AbortSignal): Promise<ArtifactResponse>;
|
|
51
99
|
}
|
|
52
100
|
|
|
@@ -120,6 +168,7 @@ declare const CanvasSchema: z.ZodObject<{
|
|
|
120
168
|
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
121
169
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
122
170
|
when: z.ZodOptional<z.ZodUnknown>;
|
|
171
|
+
regenerate: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
123
172
|
}, z.core.$strict>>;
|
|
124
173
|
output: z.ZodOptional<z.ZodObject<{
|
|
125
174
|
node: z.ZodString;
|
|
@@ -249,6 +298,14 @@ type ExecCtx = {
|
|
|
249
298
|
/** Content-addressed cache key for this node execution. Remote delegation
|
|
250
299
|
* derives its idempotency key from it so backend retries never double-charge. */
|
|
251
300
|
cacheKey?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Whether this node's outputs must be downloaded to the local content store.
|
|
303
|
+
* False when NO downstream consumer is a local (ffmpeg/magick) node — the
|
|
304
|
+
* backend already persisted the bytes to R2 with a durable sha256 URL, so the
|
|
305
|
+
* redundant R2→sandbox transfer is skipped and the ref is kept URL-only.
|
|
306
|
+
* Absent/true means download (the safe default for older call sites).
|
|
307
|
+
*/
|
|
308
|
+
downloadOutputs?: boolean;
|
|
252
309
|
client: BackendClient$1;
|
|
253
310
|
assets: AssetStore;
|
|
254
311
|
log: LogFn;
|
|
@@ -311,6 +368,12 @@ type NodeDefinition<I = unknown, P = unknown, O = unknown> = {
|
|
|
311
368
|
outputs: z.ZodType<O>;
|
|
312
369
|
/** "local" runs in-process; "remote" delegates to Convex via ctx.client */
|
|
313
370
|
location: "local" | "remote";
|
|
371
|
+
/**
|
|
372
|
+
* Local node that only forwards asset refs and never reads their bytes
|
|
373
|
+
* (e.g. `collect`). Exempts its upstream producers from the forced R2→disk
|
|
374
|
+
* download local consumers otherwise trigger.
|
|
375
|
+
*/
|
|
376
|
+
passthroughRefs?: true;
|
|
314
377
|
cost?: CostFn<P>;
|
|
315
378
|
validateExtra?: ValidateExtraFn;
|
|
316
379
|
cacheKeyExtras?: CacheKeyExtrasFn;
|
|
@@ -339,6 +402,39 @@ type RunResult = {
|
|
|
339
402
|
duration_ms: number;
|
|
340
403
|
};
|
|
341
404
|
outputs_dir: string;
|
|
405
|
+
node_runs: NodeRunRecord[];
|
|
406
|
+
};
|
|
407
|
+
type NodeRunRecord = {
|
|
408
|
+
node_id: string;
|
|
409
|
+
node_type: string;
|
|
410
|
+
cached: boolean;
|
|
411
|
+
duration_ms: number;
|
|
412
|
+
credits: number;
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
415
|
+
* Live run telemetry: the plan (post-prune node list + dependency edges) fires
|
|
416
|
+
* once before any node executes, then start/settled/failed per node. Consumers
|
|
417
|
+
* stream these into run-history progress snapshots; a throwing consumer is
|
|
418
|
+
* swallowed — telemetry must never fail a paid run.
|
|
419
|
+
*/
|
|
420
|
+
type RunProgressEvent = {
|
|
421
|
+
kind: "plan";
|
|
422
|
+
nodes: Array<{
|
|
423
|
+
node_id: string;
|
|
424
|
+
node_type: string;
|
|
425
|
+
deps: string[];
|
|
426
|
+
params: unknown;
|
|
427
|
+
}>;
|
|
428
|
+
} | {
|
|
429
|
+
kind: "node_start";
|
|
430
|
+
node_id: string;
|
|
431
|
+
} | {
|
|
432
|
+
kind: "node_settled";
|
|
433
|
+
run: NodeRunRecord;
|
|
434
|
+
outputs: Record<string, unknown>;
|
|
435
|
+
} | {
|
|
436
|
+
kind: "node_failed";
|
|
437
|
+
node_id: string;
|
|
342
438
|
};
|
|
343
439
|
type RunOptions = {
|
|
344
440
|
signal?: AbortSignal;
|
|
@@ -346,6 +442,22 @@ type RunOptions = {
|
|
|
346
442
|
cache_policy?: "read_write" | "bypass" | "read_only";
|
|
347
443
|
/** Max nodes of one layer in flight at once; invalid or missing → 5. */
|
|
348
444
|
concurrency?: number;
|
|
445
|
+
/**
|
|
446
|
+
* Credit ceiling (`--max-credits`). Enforced pre-flight against the deep
|
|
447
|
+
* validator's estimate (nothing billed) and at layer boundaries against
|
|
448
|
+
* actual spend — a boundary is the only point with no async job in flight,
|
|
449
|
+
* so aborting there strands nothing. Cached nodes cost 0, so a capped run
|
|
450
|
+
* retried with a higher cap loses no completed work.
|
|
451
|
+
*/
|
|
452
|
+
max_credits?: number;
|
|
453
|
+
/**
|
|
454
|
+
* Node ids to force fresh for THIS run only (the `--regenerate` flag). Folds
|
|
455
|
+
* the run id into each named node's cache key so it re-renders regardless of
|
|
456
|
+
* the content cache, without editing the canvas. Persistent regeneration uses
|
|
457
|
+
* the per-node `regenerate` field instead.
|
|
458
|
+
*/
|
|
459
|
+
regenerate?: ReadonlySet<string>;
|
|
460
|
+
onProgress?: (event: RunProgressEvent) => void;
|
|
349
461
|
};
|
|
350
462
|
type EngineOptions = {
|
|
351
463
|
registry: NodeRegistry;
|
|
@@ -354,6 +466,13 @@ type EngineOptions = {
|
|
|
354
466
|
cache: CacheStore;
|
|
355
467
|
outputsDir: string;
|
|
356
468
|
log?: LogFn;
|
|
469
|
+
/**
|
|
470
|
+
* Stamp durable canvas-assets URLs onto fresh node outputs before they are
|
|
471
|
+
* cached — the precondition for remote cache portability and run-history
|
|
472
|
+
* records. Best-effort: a failed upload logs a warning and keeps the entry
|
|
473
|
+
* local-only, never fails the node.
|
|
474
|
+
*/
|
|
475
|
+
persistAssets?: boolean;
|
|
357
476
|
};
|
|
358
477
|
declare class Engine$1 {
|
|
359
478
|
private readonly registry;
|
|
@@ -362,6 +481,7 @@ declare class Engine$1 {
|
|
|
362
481
|
private readonly cache;
|
|
363
482
|
private readonly outputsDir;
|
|
364
483
|
private readonly log;
|
|
484
|
+
private readonly persistAssets;
|
|
365
485
|
constructor(opts: EngineOptions);
|
|
366
486
|
validate(canvas: unknown): {
|
|
367
487
|
ok: true;
|
|
@@ -390,6 +510,8 @@ declare class Engine$1 {
|
|
|
390
510
|
}>;
|
|
391
511
|
run(input: unknown, opts?: RunOptions): Promise<RunResult>;
|
|
392
512
|
private runLayers;
|
|
513
|
+
/** Progress consumers are observers only — an exception there must never fail the run. */
|
|
514
|
+
private emitProgress;
|
|
393
515
|
/**
|
|
394
516
|
* Dead-node elimination: when the canvas declares an `output`, execute only the
|
|
395
517
|
* nodes that output transitively depends on. Orphaned nodes (left by an edit or
|
|
@@ -400,6 +522,13 @@ declare class Engine$1 {
|
|
|
400
522
|
private writeFinal;
|
|
401
523
|
private executeOne;
|
|
402
524
|
private materializeNodeOutputs;
|
|
525
|
+
/**
|
|
526
|
+
* Download any URL-only asset ref reachable in a local node's inputs so the
|
|
527
|
+
* bytes are on disk before the local runner stages them. Returns a copy —
|
|
528
|
+
* refs are replaced, never mutated in place, so the producer's cached output
|
|
529
|
+
* (shared object) keeps its URL-only shape.
|
|
530
|
+
*/
|
|
531
|
+
private materializeLocalInputs;
|
|
403
532
|
}
|
|
404
533
|
|
|
405
534
|
type ValidationResult = {
|
|
@@ -467,6 +596,13 @@ declare function createEngineFromEnv(opts?: {
|
|
|
467
596
|
cacheDir?: string;
|
|
468
597
|
outputsDir?: string;
|
|
469
598
|
log?: (line: string) => void;
|
|
599
|
+
/**
|
|
600
|
+
* Layer the company-scoped remote cache over the local one (and stamp
|
|
601
|
+
* durable asset URLs onto fresh outputs) so a fresh sandbox re-runs an
|
|
602
|
+
* already-computed canvas at zero credits. Defaults to on; disable with
|
|
603
|
+
* `remoteCache: false` or env BAKER_CANVAS_REMOTE_CACHE=off.
|
|
604
|
+
*/
|
|
605
|
+
remoteCache?: boolean;
|
|
470
606
|
}): Engine$1;
|
|
471
607
|
|
|
472
608
|
export { BackendClient, Engine, LocalAssetStore, LocalCacheStore, ValidationError, createEngineFromEnv, defaultRegistry, generateCatalog, validateCanvasDeep };
|
package/dist/engine/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BackendClient,
|
|
2
|
+
BackendClient2 as BackendClient,
|
|
3
3
|
Engine,
|
|
4
4
|
LocalAssetStore,
|
|
5
5
|
LocalCacheStore,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
defaultRegistry,
|
|
9
9
|
generateCatalog,
|
|
10
10
|
validateCanvasDeep
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-TKL2CJ6G.js";
|
|
12
12
|
import "../chunk-5WRI5ZAA.js";
|
|
13
13
|
export {
|
|
14
14
|
BackendClient,
|