@koda-sl/baker-cli 0.124.0 → 0.128.0-dev.70bf43ce4

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.
@@ -15,6 +15,10 @@ 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>;
@@ -47,6 +51,19 @@ declare class BackendClient$1 {
47
51
  putUrl: string;
48
52
  publicUrl: string;
49
53
  }>;
54
+ /** Remote cache lookup. A miss (404) — or an old backend without the route — returns null. */
55
+ getCacheEntry<T>(cacheKey: string, signal?: AbortSignal): Promise<T | null>;
56
+ putCacheEntry(entry: {
57
+ cacheKey: string;
58
+ }, signal?: AbortSignal): Promise<void>;
59
+ /** Durable run-history record — POST /api/canvas/runs (idempotent server-side on runId). */
60
+ recordRun(payload: unknown, signal?: AbortSignal): Promise<void>;
61
+ /**
62
+ * Chat-scoped blueprint sync — POST /api/creatives/definition. Lets the
63
+ * dashboard draw a scaffolded creative's workflow graph BEFORE the first run.
64
+ * Additive on the backend (never archives siblings, never sets definitionPath).
65
+ */
66
+ syncCreativeDefinition(payload: unknown, signal?: AbortSignal): Promise<void>;
50
67
  getArtifact(kind: string, name: string, version?: string, signal?: AbortSignal): Promise<ArtifactResponse>;
51
68
  }
52
69
 
@@ -120,6 +137,7 @@ declare const CanvasSchema: z.ZodObject<{
120
137
  inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
121
138
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
122
139
  when: z.ZodOptional<z.ZodUnknown>;
140
+ regenerate: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
123
141
  }, z.core.$strict>>;
124
142
  output: z.ZodOptional<z.ZodObject<{
125
143
  node: z.ZodString;
@@ -249,6 +267,14 @@ type ExecCtx = {
249
267
  /** Content-addressed cache key for this node execution. Remote delegation
250
268
  * derives its idempotency key from it so backend retries never double-charge. */
251
269
  cacheKey?: string;
270
+ /**
271
+ * Whether this node's outputs must be downloaded to the local content store.
272
+ * False when NO downstream consumer is a local (ffmpeg/magick) node — the
273
+ * backend already persisted the bytes to R2 with a durable sha256 URL, so the
274
+ * redundant R2→sandbox transfer is skipped and the ref is kept URL-only.
275
+ * Absent/true means download (the safe default for older call sites).
276
+ */
277
+ downloadOutputs?: boolean;
252
278
  client: BackendClient$1;
253
279
  assets: AssetStore;
254
280
  log: LogFn;
@@ -339,6 +365,39 @@ type RunResult = {
339
365
  duration_ms: number;
340
366
  };
341
367
  outputs_dir: string;
368
+ node_runs: NodeRunRecord[];
369
+ };
370
+ type NodeRunRecord = {
371
+ node_id: string;
372
+ node_type: string;
373
+ cached: boolean;
374
+ duration_ms: number;
375
+ credits: number;
376
+ };
377
+ /**
378
+ * Live run telemetry: the plan (post-prune node list + dependency edges) fires
379
+ * once before any node executes, then start/settled/failed per node. Consumers
380
+ * stream these into run-history progress snapshots; a throwing consumer is
381
+ * swallowed — telemetry must never fail a paid run.
382
+ */
383
+ type RunProgressEvent = {
384
+ kind: "plan";
385
+ nodes: Array<{
386
+ node_id: string;
387
+ node_type: string;
388
+ deps: string[];
389
+ params: unknown;
390
+ }>;
391
+ } | {
392
+ kind: "node_start";
393
+ node_id: string;
394
+ } | {
395
+ kind: "node_settled";
396
+ run: NodeRunRecord;
397
+ outputs: Record<string, unknown>;
398
+ } | {
399
+ kind: "node_failed";
400
+ node_id: string;
342
401
  };
343
402
  type RunOptions = {
344
403
  signal?: AbortSignal;
@@ -346,6 +405,14 @@ type RunOptions = {
346
405
  cache_policy?: "read_write" | "bypass" | "read_only";
347
406
  /** Max nodes of one layer in flight at once; invalid or missing → 5. */
348
407
  concurrency?: number;
408
+ /**
409
+ * Node ids to force fresh for THIS run only (the `--regenerate` flag). Folds
410
+ * the run id into each named node's cache key so it re-renders regardless of
411
+ * the content cache, without editing the canvas. Persistent regeneration uses
412
+ * the per-node `regenerate` field instead.
413
+ */
414
+ regenerate?: ReadonlySet<string>;
415
+ onProgress?: (event: RunProgressEvent) => void;
349
416
  };
350
417
  type EngineOptions = {
351
418
  registry: NodeRegistry;
@@ -354,6 +421,13 @@ type EngineOptions = {
354
421
  cache: CacheStore;
355
422
  outputsDir: string;
356
423
  log?: LogFn;
424
+ /**
425
+ * Stamp durable canvas-assets URLs onto fresh node outputs before they are
426
+ * cached — the precondition for remote cache portability and run-history
427
+ * records. Best-effort: a failed upload logs a warning and keeps the entry
428
+ * local-only, never fails the node.
429
+ */
430
+ persistAssets?: boolean;
357
431
  };
358
432
  declare class Engine$1 {
359
433
  private readonly registry;
@@ -362,6 +436,7 @@ declare class Engine$1 {
362
436
  private readonly cache;
363
437
  private readonly outputsDir;
364
438
  private readonly log;
439
+ private readonly persistAssets;
365
440
  constructor(opts: EngineOptions);
366
441
  validate(canvas: unknown): {
367
442
  ok: true;
@@ -390,6 +465,8 @@ declare class Engine$1 {
390
465
  }>;
391
466
  run(input: unknown, opts?: RunOptions): Promise<RunResult>;
392
467
  private runLayers;
468
+ /** Progress consumers are observers only — an exception there must never fail the run. */
469
+ private emitProgress;
393
470
  /**
394
471
  * Dead-node elimination: when the canvas declares an `output`, execute only the
395
472
  * nodes that output transitively depends on. Orphaned nodes (left by an edit or
@@ -400,6 +477,13 @@ declare class Engine$1 {
400
477
  private writeFinal;
401
478
  private executeOne;
402
479
  private materializeNodeOutputs;
480
+ /**
481
+ * Download any URL-only asset ref reachable in a local node's inputs so the
482
+ * bytes are on disk before the local runner stages them. Returns a copy —
483
+ * refs are replaced, never mutated in place, so the producer's cached output
484
+ * (shared object) keeps its URL-only shape.
485
+ */
486
+ private materializeLocalInputs;
403
487
  }
404
488
 
405
489
  type ValidationResult = {
@@ -467,6 +551,13 @@ declare function createEngineFromEnv(opts?: {
467
551
  cacheDir?: string;
468
552
  outputsDir?: string;
469
553
  log?: (line: string) => void;
554
+ /**
555
+ * Layer the company-scoped remote cache over the local one (and stamp
556
+ * durable asset URLs onto fresh outputs) so a fresh sandbox re-runs an
557
+ * already-computed canvas at zero credits. Defaults to on; disable with
558
+ * `remoteCache: false` or env BAKER_CANVAS_REMOTE_CACHE=off.
559
+ */
560
+ remoteCache?: boolean;
470
561
  }): Engine$1;
471
562
 
472
563
  export { BackendClient, Engine, LocalAssetStore, LocalCacheStore, ValidationError, createEngineFromEnv, defaultRegistry, generateCatalog, validateCanvasDeep };
@@ -8,7 +8,7 @@ import {
8
8
  defaultRegistry,
9
9
  generateCatalog,
10
10
  validateCanvasDeep
11
- } from "../chunk-IWPAXJC3.js";
11
+ } from "../chunk-43KBQLP5.js";
12
12
  import "../chunk-5WRI5ZAA.js";
13
13
  export {
14
14
  BackendClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koda-sl/baker-cli",
3
- "version": "0.124.0",
3
+ "version": "0.128.0-dev.70bf43ce4",
4
4
  "description": "AI-agent-first CLI for interacting with Baker, including the Baker creative canvas.",
5
5
  "type": "module",
6
6
  "bin": {