@nodetool-ai/execution 0.8.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/README.md +129 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/app-debug/app-spec.d.ts +94 -0
- package/dist/app-debug/app-spec.d.ts.map +1 -0
- package/dist/app-debug/app-spec.js +710 -0
- package/dist/app-debug/app-spec.js.map +1 -0
- package/dist/app-debug/application-target.d.ts +53 -0
- package/dist/app-debug/application-target.d.ts.map +1 -0
- package/dist/app-debug/application-target.js +126 -0
- package/dist/app-debug/application-target.js.map +1 -0
- package/dist/app-debug/bundle-target.d.ts +21 -0
- package/dist/app-debug/bundle-target.d.ts.map +1 -0
- package/dist/app-debug/bundle-target.js +51 -0
- package/dist/app-debug/bundle-target.js.map +1 -0
- package/dist/app-debug/graph-shape.d.ts +14 -0
- package/dist/app-debug/graph-shape.d.ts.map +1 -0
- package/dist/app-debug/graph-shape.js +23 -0
- package/dist/app-debug/graph-shape.js.map +1 -0
- package/dist/app-debug/index.d.ts +26 -0
- package/dist/app-debug/index.d.ts.map +1 -0
- package/dist/app-debug/index.js +19 -0
- package/dist/app-debug/index.js.map +1 -0
- package/dist/app-debug/markdown.d.ts +6 -0
- package/dist/app-debug/markdown.d.ts.map +1 -0
- package/dist/app-debug/markdown.js +133 -0
- package/dist/app-debug/markdown.js.map +1 -0
- package/dist/app-debug/runtime.d.ts +267 -0
- package/dist/app-debug/runtime.d.ts.map +1 -0
- package/dist/app-debug/runtime.js +633 -0
- package/dist/app-debug/runtime.js.map +1 -0
- package/dist/app-debug/script-operation.d.ts +58 -0
- package/dist/app-debug/script-operation.d.ts.map +1 -0
- package/dist/app-debug/script-operation.js +44 -0
- package/dist/app-debug/script-operation.js.map +1 -0
- package/dist/app-debug/simulate.d.ts +85 -0
- package/dist/app-debug/simulate.d.ts.map +1 -0
- package/dist/app-debug/simulate.js +991 -0
- package/dist/app-debug/simulate.js.map +1 -0
- package/dist/app-debug/summarize.d.ts +64 -0
- package/dist/app-debug/summarize.d.ts.map +1 -0
- package/dist/app-debug/summarize.js +65 -0
- package/dist/app-debug/summarize.js.map +1 -0
- package/dist/app-debug/types.d.ts +343 -0
- package/dist/app-debug/types.d.ts.map +1 -0
- package/dist/app-debug/types.js +2 -0
- package/dist/app-debug/types.js.map +1 -0
- package/dist/cost-ledger.d.ts +147 -0
- package/dist/cost-ledger.d.ts.map +1 -0
- package/dist/cost-ledger.js +288 -0
- package/dist/cost-ledger.js.map +1 -0
- package/dist/debug/collector.d.ts +28 -0
- package/dist/debug/collector.d.ts.map +1 -0
- package/dist/debug/collector.js +284 -0
- package/dist/debug/collector.js.map +1 -0
- package/dist/debug/index.d.ts +15 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +16 -0
- package/dist/debug/index.js.map +1 -0
- package/dist/debug/types.d.ts +179 -0
- package/dist/debug/types.d.ts.map +1 -0
- package/dist/debug/types.js +11 -0
- package/dist/debug/types.js.map +1 -0
- package/dist/debug/verdict.d.ts +27 -0
- package/dist/debug/verdict.d.ts.map +1 -0
- package/dist/debug/verdict.js +51 -0
- package/dist/debug/verdict.js.map +1 -0
- package/dist/executor-resolver.d.ts +13 -0
- package/dist/executor-resolver.d.ts.map +1 -0
- package/dist/executor-resolver.js +13 -0
- package/dist/executor-resolver.js.map +1 -0
- package/dist/fal-output-decoder.d.ts +36 -0
- package/dist/fal-output-decoder.d.ts.map +1 -0
- package/dist/fal-output-decoder.js +129 -0
- package/dist/fal-output-decoder.js.map +1 -0
- package/dist/generation-lifecycle.d.ts +54 -0
- package/dist/generation-lifecycle.d.ts.map +1 -0
- package/dist/generation-lifecycle.js +431 -0
- package/dist/generation-lifecycle.js.map +1 -0
- package/dist/generation-recovery-worker.d.ts +100 -0
- package/dist/generation-recovery-worker.d.ts.map +1 -0
- package/dist/generation-recovery-worker.js +995 -0
- package/dist/generation-recovery-worker.js.map +1 -0
- package/dist/generation-tracker.d.ts +83 -0
- package/dist/generation-tracker.d.ts.map +1 -0
- package/dist/generation-tracker.js +436 -0
- package/dist/generation-tracker.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/js-script-debug/index.d.ts +13 -0
- package/dist/js-script-debug/index.d.ts.map +1 -0
- package/dist/js-script-debug/index.js +12 -0
- package/dist/js-script-debug/index.js.map +1 -0
- package/dist/js-script-debug/markdown.d.ts +6 -0
- package/dist/js-script-debug/markdown.d.ts.map +1 -0
- package/dist/js-script-debug/markdown.js +62 -0
- package/dist/js-script-debug/markdown.js.map +1 -0
- package/dist/js-script-debug/outputs.d.ts +20 -0
- package/dist/js-script-debug/outputs.d.ts.map +1 -0
- package/dist/js-script-debug/outputs.js +30 -0
- package/dist/js-script-debug/outputs.js.map +1 -0
- package/dist/js-script-debug/report.d.ts +15 -0
- package/dist/js-script-debug/report.d.ts.map +1 -0
- package/dist/js-script-debug/report.js +90 -0
- package/dist/js-script-debug/report.js.map +1 -0
- package/dist/js-script-debug/types.d.ts +63 -0
- package/dist/js-script-debug/types.d.ts.map +1 -0
- package/dist/js-script-debug/types.js +10 -0
- package/dist/js-script-debug/types.js.map +1 -0
- package/dist/js-script-debug/validate.d.ts +38 -0
- package/dist/js-script-debug/validate.d.ts.map +1 -0
- package/dist/js-script-debug/validate.js +137 -0
- package/dist/js-script-debug/validate.js.map +1 -0
- package/dist/message-stream.d.ts +33 -0
- package/dist/message-stream.d.ts.map +1 -0
- package/dist/message-stream.js +58 -0
- package/dist/message-stream.js.map +1 -0
- package/dist/normalize-graph.d.ts +13 -0
- package/dist/normalize-graph.d.ts.map +1 -0
- package/dist/normalize-graph.js +63 -0
- package/dist/normalize-graph.js.map +1 -0
- package/dist/output-names.d.ts +13 -0
- package/dist/output-names.d.ts.map +1 -0
- package/dist/output-names.js +13 -0
- package/dist/output-names.js.map +1 -0
- package/dist/predicates.d.ts +6 -0
- package/dist/predicates.d.ts.map +1 -0
- package/dist/predicates.js +6 -0
- package/dist/predicates.js.map +1 -0
- package/dist/preflight.d.ts +87 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +139 -0
- package/dist/preflight.js.map +1 -0
- package/dist/provider-secret-key.d.ts +3 -0
- package/dist/provider-secret-key.d.ts.map +1 -0
- package/dist/provider-secret-key.js +7 -0
- package/dist/provider-secret-key.js.map +1 -0
- package/dist/service/app-debug-service.d.ts +78 -0
- package/dist/service/app-debug-service.d.ts.map +1 -0
- package/dist/service/app-debug-service.js +201 -0
- package/dist/service/app-debug-service.js.map +1 -0
- package/dist/service/app-run-server.d.ts +28 -0
- package/dist/service/app-run-server.d.ts.map +1 -0
- package/dist/service/app-run-server.js +104 -0
- package/dist/service/app-run-server.js.map +1 -0
- package/dist/service/debug-sessions.d.ts +158 -0
- package/dist/service/debug-sessions.d.ts.map +1 -0
- package/dist/service/debug-sessions.js +358 -0
- package/dist/service/debug-sessions.js.map +1 -0
- package/dist/service/index.d.ts +22 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +17 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/job-progress.d.ts +40 -0
- package/dist/service/job-progress.d.ts.map +1 -0
- package/dist/service/job-progress.js +53 -0
- package/dist/service/job-progress.js.map +1 -0
- package/dist/service/workflow-run.d.ts +279 -0
- package/dist/service/workflow-run.d.ts.map +1 -0
- package/dist/service/workflow-run.js +598 -0
- package/dist/service/workflow-run.js.map +1 -0
- package/dist/service/workflow-workspace.d.ts +89 -0
- package/dist/service/workflow-workspace.d.ts.map +1 -0
- package/dist/service/workflow-workspace.js +160 -0
- package/dist/service/workflow-workspace.js.map +1 -0
- package/dist/session.d.ts +62 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +353 -0
- package/dist/session.js.map +1 -0
- package/dist/sketch-debug/index.d.ts +11 -0
- package/dist/sketch-debug/index.d.ts.map +1 -0
- package/dist/sketch-debug/index.js +10 -0
- package/dist/sketch-debug/index.js.map +1 -0
- package/dist/sketch-debug/markdown.d.ts +6 -0
- package/dist/sketch-debug/markdown.d.ts.map +1 -0
- package/dist/sketch-debug/markdown.js +93 -0
- package/dist/sketch-debug/markdown.js.map +1 -0
- package/dist/sketch-debug/report.d.ts +15 -0
- package/dist/sketch-debug/report.d.ts.map +1 -0
- package/dist/sketch-debug/report.js +98 -0
- package/dist/sketch-debug/report.js.map +1 -0
- package/dist/sketch-debug/types.d.ts +62 -0
- package/dist/sketch-debug/types.d.ts.map +1 -0
- package/dist/sketch-debug/types.js +10 -0
- package/dist/sketch-debug/types.js.map +1 -0
- package/dist/sketch-debug/validate.d.ts +14 -0
- package/dist/sketch-debug/validate.d.ts.map +1 -0
- package/dist/sketch-debug/validate.js +478 -0
- package/dist/sketch-debug/validate.js.map +1 -0
- package/dist/supervisor.d.ts +45 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +97 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/timeline-debug/index.d.ts +11 -0
- package/dist/timeline-debug/index.d.ts.map +1 -0
- package/dist/timeline-debug/index.js +10 -0
- package/dist/timeline-debug/index.js.map +1 -0
- package/dist/timeline-debug/legibility.d.ts +23 -0
- package/dist/timeline-debug/legibility.d.ts.map +1 -0
- package/dist/timeline-debug/legibility.js +240 -0
- package/dist/timeline-debug/legibility.js.map +1 -0
- package/dist/timeline-debug/markdown.d.ts +6 -0
- package/dist/timeline-debug/markdown.d.ts.map +1 -0
- package/dist/timeline-debug/markdown.js +103 -0
- package/dist/timeline-debug/markdown.js.map +1 -0
- package/dist/timeline-debug/motion.d.ts +20 -0
- package/dist/timeline-debug/motion.d.ts.map +1 -0
- package/dist/timeline-debug/motion.js +362 -0
- package/dist/timeline-debug/motion.js.map +1 -0
- package/dist/timeline-debug/report.d.ts +16 -0
- package/dist/timeline-debug/report.d.ts.map +1 -0
- package/dist/timeline-debug/report.js +100 -0
- package/dist/timeline-debug/report.js.map +1 -0
- package/dist/timeline-debug/showcase.d.ts +7 -0
- package/dist/timeline-debug/showcase.d.ts.map +1 -0
- package/dist/timeline-debug/showcase.js +347 -0
- package/dist/timeline-debug/showcase.js.map +1 -0
- package/dist/timeline-debug/types.d.ts +64 -0
- package/dist/timeline-debug/types.d.ts.map +1 -0
- package/dist/timeline-debug/types.js +10 -0
- package/dist/timeline-debug/types.js.map +1 -0
- package/dist/timeline-debug/validate.d.ts +24 -0
- package/dist/timeline-debug/validate.d.ts.map +1 -0
- package/dist/timeline-debug/validate.js +1432 -0
- package/dist/timeline-debug/validate.js.map +1 -0
- package/dist/types.d.ts +211 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resolvePythonNodeExecutor } from "@nodetool-ai/runtime";
|
|
2
|
+
export function createExecutorResolver(registry, bridge) {
|
|
3
|
+
return (node) => {
|
|
4
|
+
if (registry.has(node.type)) {
|
|
5
|
+
return registry.resolve(node);
|
|
6
|
+
}
|
|
7
|
+
const py = resolvePythonNodeExecutor(bridge, node);
|
|
8
|
+
if (py)
|
|
9
|
+
return py;
|
|
10
|
+
throw new Error(`Unknown node type: ${node.type}`);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=executor-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor-resolver.js","sourceRoot":"","sources":["../src/executor-resolver.ts"],"names":[],"mappings":"AASA,OAAO,EACL,yBAAyB,EAE1B,MAAM,sBAAsB,CAAC;AAG9B,MAAM,UAAU,sBAAsB,CACpC,QAAsB,EACtB,MAA+B;IAE/B,OAAO,CAAC,IAAoB,EAAgB,EAAE;QAC5C,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QACD,MAAM,EAAE,GAAG,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACnD,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The subset of a fal result needed by the durable finalizer. The path is
|
|
3
|
+
* stable for a given model result, so it is also suitable for output identity
|
|
4
|
+
* and deterministic retry/storage keys.
|
|
5
|
+
*/
|
|
6
|
+
export interface FalOutputDescriptor {
|
|
7
|
+
readonly outputKey: string;
|
|
8
|
+
readonly outputIndex: number;
|
|
9
|
+
readonly outputType: "media" | "structured";
|
|
10
|
+
readonly providerRef: string | null;
|
|
11
|
+
readonly rawResult: Record<string, unknown>;
|
|
12
|
+
readonly storageKey?: string;
|
|
13
|
+
readonly existingStorageKey?: string | null;
|
|
14
|
+
readonly existingAssetId?: string | null;
|
|
15
|
+
}
|
|
16
|
+
/** Stable object-store locator for one output identity. */
|
|
17
|
+
export declare function deterministicFalStorageKey(generationId: string, attemptId: string, outputKey: string, outputIndex: number, extension?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Field names that carry a media URL inside one fal envelope. These are the
|
|
20
|
+
* same names the live provider extractors read (`extractImageUrls`,
|
|
21
|
+
* `extractVideoUrl`, `extractAudioUrl` in `@nodetool-ai/runtime`), so a
|
|
22
|
+
* response shape the live path saves is also a media output during recovery.
|
|
23
|
+
* `packages/execution/tests/fal-media-shape-parity.test.ts` holds them level.
|
|
24
|
+
*/
|
|
25
|
+
export declare const FAL_MEDIA_URL_FIELDS: readonly ["url", "uri", "image", "image_url", "video", "video_url", "audio", "audio_url"];
|
|
26
|
+
/** Keys whose value is a media envelope, or an array of them. */
|
|
27
|
+
export declare const FAL_MEDIA_ENVELOPE_KEYS: readonly ["image", "images", "video", "videos", "audio", "audio_file", "file", "files", "model_mesh", "model_glb", "mesh", "outputs", "results"];
|
|
28
|
+
/** Keys whose value is a bare media URL, or an array of them. */
|
|
29
|
+
export declare const FAL_MEDIA_URL_ALIAS_KEYS: readonly ["image_url", "image_urls", "video_url", "video_urls", "audio_url", "audio_urls"];
|
|
30
|
+
/**
|
|
31
|
+
* Decode common fal image/video/audio/file envelopes without throwing away
|
|
32
|
+
* structured fields. Unknown objects remain one structured output. Arrays are
|
|
33
|
+
* addressed by index, which keeps retries idempotent and preserves every file.
|
|
34
|
+
*/
|
|
35
|
+
export declare function decodeFalOutputs(payload: Record<string, unknown>): FalOutputDescriptor[];
|
|
36
|
+
//# sourceMappingURL=fal-output-decoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fal-output-decoder.d.ts","sourceRoot":"","sources":["../src/fal-output-decoder.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,YAAY,CAAC;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C;AAED,2DAA2D;AAC3D,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,SAAQ,GAChB,MAAM,CAMR;AAUD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,YAC/B,KAAK,EACL,KAAK,EACL,OAAO,EACP,WAAW,EACX,OAAO,EACP,WAAW,EACX,OAAO,EACP,WAAW,CACH,CAAC;AAyBX,iEAAiE;AACjE,eAAO,MAAM,uBAAuB,YAClC,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,MAAM,EACN,OAAO,EACP,YAAY,EACZ,WAAW,EACX,MAAM,EACN,SAAS,EACT,SAAS,CACD,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,YACnC,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,CACJ,CAAC;AAOX;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,mBAAmB,EAAE,CAkDvB"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/** Stable object-store locator for one output identity. */
|
|
3
|
+
export function deterministicFalStorageKey(generationId, attemptId, outputKey, outputIndex, extension = "bin") {
|
|
4
|
+
const identity = `${generationId}:${attemptId}:${outputKey}:${outputIndex}`;
|
|
5
|
+
const digest = createHash("sha256").update(identity).digest("hex");
|
|
6
|
+
const safeExtension = extension.replace(/[^a-z0-9]/giu, "").toLowerCase() || "bin";
|
|
7
|
+
return `generations/${generationId}/${digest}.${safeExtension}`;
|
|
8
|
+
}
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function isUrl(value) {
|
|
13
|
+
return typeof value === "string" && /^https?:\/\//u.test(value);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Field names that carry a media URL inside one fal envelope. These are the
|
|
17
|
+
* same names the live provider extractors read (`extractImageUrls`,
|
|
18
|
+
* `extractVideoUrl`, `extractAudioUrl` in `@nodetool-ai/runtime`), so a
|
|
19
|
+
* response shape the live path saves is also a media output during recovery.
|
|
20
|
+
* `packages/execution/tests/fal-media-shape-parity.test.ts` holds them level.
|
|
21
|
+
*/
|
|
22
|
+
export const FAL_MEDIA_URL_FIELDS = [
|
|
23
|
+
"url",
|
|
24
|
+
"uri",
|
|
25
|
+
"image",
|
|
26
|
+
"image_url",
|
|
27
|
+
"video",
|
|
28
|
+
"video_url",
|
|
29
|
+
"audio",
|
|
30
|
+
"audio_url"
|
|
31
|
+
];
|
|
32
|
+
function mediaUrl(value) {
|
|
33
|
+
for (const field of FAL_MEDIA_URL_FIELDS) {
|
|
34
|
+
const candidate = value[field];
|
|
35
|
+
if (isUrl(candidate))
|
|
36
|
+
return candidate;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function descriptor(outputKey, outputIndex, outputType, value) {
|
|
41
|
+
return {
|
|
42
|
+
outputKey,
|
|
43
|
+
outputIndex,
|
|
44
|
+
outputType,
|
|
45
|
+
providerRef: mediaUrl(value),
|
|
46
|
+
rawResult: value
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Keys whose value is a media envelope, or an array of them. */
|
|
50
|
+
export const FAL_MEDIA_ENVELOPE_KEYS = [
|
|
51
|
+
"image",
|
|
52
|
+
"images",
|
|
53
|
+
"video",
|
|
54
|
+
"videos",
|
|
55
|
+
"audio",
|
|
56
|
+
"audio_file",
|
|
57
|
+
"file",
|
|
58
|
+
"files",
|
|
59
|
+
"model_mesh",
|
|
60
|
+
"model_glb",
|
|
61
|
+
"mesh",
|
|
62
|
+
"outputs",
|
|
63
|
+
"results"
|
|
64
|
+
];
|
|
65
|
+
/** Keys whose value is a bare media URL, or an array of them. */
|
|
66
|
+
export const FAL_MEDIA_URL_ALIAS_KEYS = [
|
|
67
|
+
"image_url",
|
|
68
|
+
"image_urls",
|
|
69
|
+
"video_url",
|
|
70
|
+
"video_urls",
|
|
71
|
+
"audio_url",
|
|
72
|
+
"audio_urls"
|
|
73
|
+
];
|
|
74
|
+
const FAL_MEDIA_KEYS = new Set([
|
|
75
|
+
...FAL_MEDIA_ENVELOPE_KEYS,
|
|
76
|
+
...FAL_MEDIA_URL_ALIAS_KEYS
|
|
77
|
+
]);
|
|
78
|
+
/**
|
|
79
|
+
* Decode common fal image/video/audio/file envelopes without throwing away
|
|
80
|
+
* structured fields. Unknown objects remain one structured output. Arrays are
|
|
81
|
+
* addressed by index, which keeps retries idempotent and preserves every file.
|
|
82
|
+
*/
|
|
83
|
+
export function decodeFalOutputs(payload) {
|
|
84
|
+
const outputs = [];
|
|
85
|
+
const seen = new Set();
|
|
86
|
+
const add = (key, value, index = 0, dedupe = false) => {
|
|
87
|
+
if (isRecord(value)) {
|
|
88
|
+
const url = mediaUrl(value);
|
|
89
|
+
if (url && dedupe && seen.has(url))
|
|
90
|
+
return;
|
|
91
|
+
if (url)
|
|
92
|
+
seen.add(url);
|
|
93
|
+
outputs.push(descriptor(key, index, url ? "media" : "structured", value));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (isUrl(value)) {
|
|
97
|
+
if (dedupe && seen.has(value))
|
|
98
|
+
return;
|
|
99
|
+
seen.add(value);
|
|
100
|
+
outputs.push(descriptor(key, index, "media", { url: value }));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const collect = (keys, dedupe) => {
|
|
104
|
+
for (const key of keys) {
|
|
105
|
+
const value = payload[key];
|
|
106
|
+
if (Array.isArray(value)) {
|
|
107
|
+
value.forEach((item, index) => add(key, item, index, dedupe));
|
|
108
|
+
}
|
|
109
|
+
else if (value !== undefined) {
|
|
110
|
+
add(key, value, 0, dedupe);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
collect(FAL_MEDIA_ENVELOPE_KEYS, false);
|
|
115
|
+
// The flat aliases name the same file as the envelope above them, so a
|
|
116
|
+
// payload carrying both must not be downloaded and billed as two assets.
|
|
117
|
+
collect(FAL_MEDIA_URL_ALIAS_KEYS, true);
|
|
118
|
+
if (outputs.length > 0) {
|
|
119
|
+
const structured = Object.fromEntries(Object.entries(payload).filter(([key]) => !FAL_MEDIA_KEYS.has(key)));
|
|
120
|
+
if (Object.keys(structured).length > 0) {
|
|
121
|
+
outputs.push(descriptor("structured", 0, "structured", structured));
|
|
122
|
+
}
|
|
123
|
+
return outputs;
|
|
124
|
+
}
|
|
125
|
+
return [
|
|
126
|
+
descriptor("result", 0, mediaUrl(payload) ? "media" : "structured", payload)
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=fal-output-decoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fal-output-decoder.js","sourceRoot":"","sources":["../src/fal-output-decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkBzC,2DAA2D;AAC3D,MAAM,UAAU,0BAA0B,CACxC,YAAoB,EACpB,SAAiB,EACjB,SAAiB,EACjB,WAAmB,EACnB,SAAS,GAAG,KAAK;IAEjB,MAAM,QAAQ,GAAG,GAAG,YAAY,IAAI,SAAS,IAAI,SAAS,IAAI,WAAW,EAAE,CAAC;IAC5E,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnE,MAAM,aAAa,GACjB,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC;IAC/D,OAAO,eAAe,YAAY,IAAI,MAAM,IAAI,aAAa,EAAE,CAAC;AAClE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAA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I,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;YAChE,CAAC;iBAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC/B,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;IACxC,uEAAuE;IACvE,yEAAyE;IACzE,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;IAExC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CACnC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CACpE,CAAC;QACF,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO;QACL,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC;KAC7E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { GenerationAttempt, Prediction, type DurableAcceptance, type DurableGenerationInput, type DurableGenerationTransition, type GenerationAttemptObservation, type GenerationOutputSaveState, type GenerationAttachmentTransition, type GenerationAttemptLeaseFence, GenerationOutput, GenerationAttachment } from "@nodetool-ai/models";
|
|
2
|
+
import type { GenerationLifecycleHooks } from "@nodetool-ai/runtime";
|
|
3
|
+
export interface GenerationLeaseWindow {
|
|
4
|
+
now: string;
|
|
5
|
+
expiresAt: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DurableGenerationAcceptance extends DurableAcceptance {
|
|
8
|
+
attempt: GenerationAttempt;
|
|
9
|
+
}
|
|
10
|
+
export interface FalGenerationLifecycleHooksOptions {
|
|
11
|
+
readonly userId: string;
|
|
12
|
+
readonly jobId?: string | null;
|
|
13
|
+
readonly projectId?: string | null;
|
|
14
|
+
readonly providerAccountRef?: string | null;
|
|
15
|
+
/** Public HTTPS origin used for signed FAL callbacks. */
|
|
16
|
+
readonly publicUrl?: string | null;
|
|
17
|
+
/** Disable callback generation while retaining durable queue tracking. */
|
|
18
|
+
readonly callbacks?: boolean;
|
|
19
|
+
/** Encrypt callback tokens before they are persisted. */
|
|
20
|
+
readonly encryptCallbackToken?: (token: string, userId: string) => string | null | undefined;
|
|
21
|
+
/** Optional persistence seam for hosts that already own a lifecycle. */
|
|
22
|
+
readonly lifecycle?: DurableGenerationLifecycle;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build the durable hooks used by workflow ProcessingContexts.
|
|
26
|
+
*
|
|
27
|
+
* This factory lives in execution so runtime stays independent of models and
|
|
28
|
+
* persistence. It is intentionally FAL-only. Other providers continue to use
|
|
29
|
+
* the existing in-memory receipt and billing path until their submission and
|
|
30
|
+
* recovery contracts are verified.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createFalGenerationLifecycleHooks(options: FalGenerationLifecycleHooksOptions): GenerationLifecycleHooks;
|
|
33
|
+
/**
|
|
34
|
+
* Persistence/orchestration seam for provider workers. It deliberately has no
|
|
35
|
+
* provider or storage dependency: providers submit only after `accept()` and
|
|
36
|
+
* workers use the fenced version returned from `claim()` for every write.
|
|
37
|
+
*/
|
|
38
|
+
export declare class DurableGenerationLifecycle {
|
|
39
|
+
accept(input: DurableGenerationInput): Promise<DurableGenerationAcceptance>;
|
|
40
|
+
claim(generationId: string, workerId: string, window: GenerationLeaseWindow): Promise<Prediction | null>;
|
|
41
|
+
renew(generationId: string, workerId: string, leaseVersion: number, expiresAt: string): Promise<boolean>;
|
|
42
|
+
claimAttempt(attemptId: string, workerId: string, window: GenerationLeaseWindow): Promise<GenerationAttempt | null>;
|
|
43
|
+
renewAttempt(attemptId: string, workerId: string, leaseVersion: number, expiresAt: string): Promise<boolean>;
|
|
44
|
+
bindProviderRequest(generationId: string, workerId: string, leaseVersion: number, providerRequestId: string): Promise<boolean>;
|
|
45
|
+
bindAttemptProviderRequest(attemptId: string, workerId: string, leaseVersion: number, providerRequestId: string): Promise<boolean>;
|
|
46
|
+
transitionAttempt(attemptId: string, workerId: string, leaseVersion: number, update: GenerationAttemptObservation): Promise<GenerationAttempt | null>;
|
|
47
|
+
transition(generationId: string, workerId: string, leaseVersion: number, update: DurableGenerationTransition): Promise<Prediction | null>;
|
|
48
|
+
recordAttemptObservation(attemptId: string, workerId: string, leaseVersion: number, observation: GenerationAttemptObservation): Promise<GenerationAttempt | null>;
|
|
49
|
+
saveOutput(outputId: string, state: GenerationOutputSaveState, fence?: GenerationAttemptLeaseFence): Promise<GenerationOutput | null>;
|
|
50
|
+
attachOutput(attachmentId: string, change: GenerationAttachmentTransition): Promise<GenerationAttachment | null>;
|
|
51
|
+
recover(now: string, limit?: number): Promise<Prediction[]>;
|
|
52
|
+
}
|
|
53
|
+
export declare function createDurableGenerationLifecycle(): DurableGenerationLifecycle;
|
|
54
|
+
//# sourceMappingURL=generation-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-lifecycle.d.ts","sourceRoot":"","sources":["../src/generation-lifecycle.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,2BA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