clinkx 0.2.0 → 0.2.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/clinkx-workflows/dist/artifacts.d.ts +65 -0
- package/clinkx-workflows/dist/artifacts.js +268 -0
- package/clinkx-workflows/dist/artifacts.js.map +1 -0
- package/clinkx-workflows/dist/backend.d.ts +33 -0
- package/clinkx-workflows/dist/backend.js +9 -0
- package/clinkx-workflows/dist/backend.js.map +1 -0
- package/clinkx-workflows/dist/child-env.d.ts +23 -0
- package/clinkx-workflows/dist/child-env.js +53 -0
- package/clinkx-workflows/dist/child-env.js.map +1 -0
- package/clinkx-workflows/dist/clink-client.d.ts +51 -0
- package/clinkx-workflows/dist/clink-client.js +216 -0
- package/clinkx-workflows/dist/clink-client.js.map +1 -0
- package/clinkx-workflows/dist/config.d.ts +126 -0
- package/clinkx-workflows/dist/config.js +226 -0
- package/clinkx-workflows/dist/config.js.map +1 -0
- package/clinkx-workflows/dist/definition-normalizer.d.ts +59 -0
- package/clinkx-workflows/dist/definition-normalizer.js +75 -0
- package/clinkx-workflows/dist/definition-normalizer.js.map +1 -0
- package/clinkx-workflows/dist/engine.d.ts +235 -0
- package/clinkx-workflows/dist/engine.js +1044 -0
- package/clinkx-workflows/dist/engine.js.map +1 -0
- package/clinkx-workflows/dist/errors.d.ts +74 -0
- package/clinkx-workflows/dist/errors.js +84 -0
- package/clinkx-workflows/dist/errors.js.map +1 -0
- package/clinkx-workflows/dist/fidelity.d.ts +112 -0
- package/clinkx-workflows/dist/fidelity.js +140 -0
- package/clinkx-workflows/dist/fidelity.js.map +1 -0
- package/clinkx-workflows/dist/fingerprint.d.ts +69 -0
- package/clinkx-workflows/dist/fingerprint.js +143 -0
- package/clinkx-workflows/dist/fingerprint.js.map +1 -0
- package/clinkx-workflows/dist/index.d.ts +16 -0
- package/clinkx-workflows/dist/index.js +42 -0
- package/clinkx-workflows/dist/index.js.map +1 -0
- package/clinkx-workflows/dist/loader.d.ts +64 -0
- package/clinkx-workflows/dist/loader.js +371 -0
- package/clinkx-workflows/dist/loader.js.map +1 -0
- package/clinkx-workflows/dist/logger.d.ts +16 -0
- package/clinkx-workflows/dist/logger.js +31 -0
- package/clinkx-workflows/dist/logger.js.map +1 -0
- package/clinkx-workflows/dist/path-validation.d.ts +23 -0
- package/clinkx-workflows/dist/path-validation.js +73 -0
- package/clinkx-workflows/dist/path-validation.js.map +1 -0
- package/clinkx-workflows/dist/prompt-budget.d.ts +31 -0
- package/clinkx-workflows/dist/prompt-budget.js +78 -0
- package/clinkx-workflows/dist/prompt-budget.js.map +1 -0
- package/clinkx-workflows/dist/queue.d.ts +16 -0
- package/clinkx-workflows/dist/queue.js +46 -0
- package/clinkx-workflows/dist/queue.js.map +1 -0
- package/clinkx-workflows/dist/ranking-reducer.d.ts +11 -0
- package/clinkx-workflows/dist/ranking-reducer.js +245 -0
- package/clinkx-workflows/dist/ranking-reducer.js.map +1 -0
- package/clinkx-workflows/dist/reducers/index.d.ts +8 -0
- package/clinkx-workflows/dist/reducers/index.js +12 -0
- package/clinkx-workflows/dist/reducers/index.js.map +1 -0
- package/clinkx-workflows/dist/run-id.d.ts +17 -0
- package/clinkx-workflows/dist/run-id.js +26 -0
- package/clinkx-workflows/dist/run-id.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/council-answer.d.ts +8 -0
- package/clinkx-workflows/dist/run-summary/cards/council-answer.js +75 -0
- package/clinkx-workflows/dist/run-summary/cards/council-answer.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/council-code-review.d.ts +13 -0
- package/clinkx-workflows/dist/run-summary/cards/council-code-review.js +90 -0
- package/clinkx-workflows/dist/run-summary/cards/council-code-review.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/council-debug.d.ts +9 -0
- package/clinkx-workflows/dist/run-summary/cards/council-debug.js +79 -0
- package/clinkx-workflows/dist/run-summary/cards/council-debug.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/council-default.d.ts +11 -0
- package/clinkx-workflows/dist/run-summary/cards/council-default.js +57 -0
- package/clinkx-workflows/dist/run-summary/cards/council-default.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/council-discover.d.ts +10 -0
- package/clinkx-workflows/dist/run-summary/cards/council-discover.js +79 -0
- package/clinkx-workflows/dist/run-summary/cards/council-discover.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/generic.d.ts +2 -0
- package/clinkx-workflows/dist/run-summary/cards/generic.js +4 -0
- package/clinkx-workflows/dist/run-summary/cards/generic.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/cards/index.d.ts +6 -0
- package/clinkx-workflows/dist/run-summary/cards/index.js +17 -0
- package/clinkx-workflows/dist/run-summary/cards/index.js.map +1 -0
- package/clinkx-workflows/dist/run-summary/utils.d.ts +6 -0
- package/clinkx-workflows/dist/run-summary/utils.js +30 -0
- package/clinkx-workflows/dist/run-summary/utils.js.map +1 -0
- package/clinkx-workflows/dist/run-summary-derived.d.ts +19 -0
- package/clinkx-workflows/dist/run-summary-derived.js +100 -0
- package/clinkx-workflows/dist/run-summary-derived.js.map +1 -0
- package/clinkx-workflows/dist/run-summary.d.ts +70 -0
- package/clinkx-workflows/dist/run-summary.js +125 -0
- package/clinkx-workflows/dist/run-summary.js.map +1 -0
- package/clinkx-workflows/dist/schema.d.ts +609 -0
- package/clinkx-workflows/dist/schema.js +123 -0
- package/clinkx-workflows/dist/schema.js.map +1 -0
- package/clinkx-workflows/dist/server.d.ts +16 -0
- package/clinkx-workflows/dist/server.js +33 -0
- package/clinkx-workflows/dist/server.js.map +1 -0
- package/clinkx-workflows/dist/shutdown.d.ts +54 -0
- package/clinkx-workflows/dist/shutdown.js +120 -0
- package/clinkx-workflows/dist/shutdown.js.map +1 -0
- package/clinkx-workflows/dist/state-schema.d.ts +141 -0
- package/clinkx-workflows/dist/state-schema.js +21 -0
- package/clinkx-workflows/dist/state-schema.js.map +1 -0
- package/clinkx-workflows/dist/state.d.ts +37 -0
- package/clinkx-workflows/dist/state.js +838 -0
- package/clinkx-workflows/dist/state.js.map +1 -0
- package/clinkx-workflows/dist/template-loader.d.ts +30 -0
- package/clinkx-workflows/dist/template-loader.js +77 -0
- package/clinkx-workflows/dist/template-loader.js.map +1 -0
- package/clinkx-workflows/dist/template.d.ts +54 -0
- package/clinkx-workflows/dist/template.js +128 -0
- package/clinkx-workflows/dist/template.js.map +1 -0
- package/clinkx-workflows/dist/transport.d.ts +91 -0
- package/clinkx-workflows/dist/transport.js +249 -0
- package/clinkx-workflows/dist/transport.js.map +1 -0
- package/clinkx-workflows/dist/types.d.ts +137 -0
- package/clinkx-workflows/dist/types.js +11 -0
- package/clinkx-workflows/dist/types.js.map +1 -0
- package/clinkx-workflows/dist/validators/council.d.ts +1488 -0
- package/clinkx-workflows/dist/validators/council.js +509 -0
- package/clinkx-workflows/dist/validators/council.js.map +1 -0
- package/clinkx-workflows/dist/validators/index.d.ts +40 -0
- package/clinkx-workflows/dist/validators/index.js +43 -0
- package/clinkx-workflows/dist/validators/index.js.map +1 -0
- package/clinkx-workflows/dist/workflow-receipt.d.ts +4 -0
- package/clinkx-workflows/dist/workflow-receipt.js +177 -0
- package/clinkx-workflows/dist/workflow-receipt.js.map +1 -0
- package/clinkx-workflows/dist/workflow-tools.d.ts +77 -0
- package/clinkx-workflows/dist/workflow-tools.js +1131 -0
- package/clinkx-workflows/dist/workflow-tools.js.map +1 -0
- package/clinkx-workflows/dist/workflows/council-default.d.ts +123 -0
- package/clinkx-workflows/dist/workflows/council-default.js +141 -0
- package/clinkx-workflows/dist/workflows/council-default.js.map +1 -0
- package/clinkx-workflows/dist/workflows/index.d.ts +12 -0
- package/clinkx-workflows/dist/workflows/index.js +15 -0
- package/clinkx-workflows/dist/workflows/index.js.map +1 -0
- package/conf/adapters/codex.json +2 -2
- package/conf/adapters/hapi/codex.json +2 -2
- package/dist/config.d.ts +5 -0
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -1
- package/dist/parsers/extract.d.ts +2 -0
- package/dist/parsers/extract.js +29 -20
- package/dist/parsers/extract.js.map +1 -1
- package/dist/pipeline.d.ts +2 -4
- package/dist/pipeline.js +93 -8
- package/dist/pipeline.js.map +1 -1
- package/dist/result-contract.d.ts +6 -1
- package/dist/result-contract.js +10 -22
- package/dist/result-contract.js.map +1 -1
- package/dist/runner.js +43 -1
- package/dist/runner.js.map +1 -1
- package/package.json +11 -5
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot normalization for clinkx-workflows (2-10a).
|
|
3
|
+
*
|
|
4
|
+
* Normalizes a loaded workflow definition into snapshot-ready form:
|
|
5
|
+
* - Inlines template text (not just hashes) — hash-only snapshots can't reconstruct for resume
|
|
6
|
+
* - Includes template content hashes alongside inlined text
|
|
7
|
+
*/
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Normalization
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/**
|
|
13
|
+
* Normalize a workflow definition by inlining all template text.
|
|
14
|
+
*
|
|
15
|
+
* @param definition - Parsed and validated workflow definition
|
|
16
|
+
* @param templates - Map of template path → template content (from resolveAllTemplates)
|
|
17
|
+
* @returns Normalized definition with all prompts inlined
|
|
18
|
+
*/
|
|
19
|
+
export function normalizeDefinition(definition, templates) {
|
|
20
|
+
const normalizedStages = definition.stages.map((stage) => ({
|
|
21
|
+
id: stage.id,
|
|
22
|
+
...(stage.description != null ? { description: stage.description } : {}),
|
|
23
|
+
parallel: stage.parallel,
|
|
24
|
+
retry: stage.retry,
|
|
25
|
+
on_failure: stage.on_failure,
|
|
26
|
+
calls: stage.calls.map((call) => normalizeCall(call, templates)),
|
|
27
|
+
}));
|
|
28
|
+
return {
|
|
29
|
+
name: definition.name,
|
|
30
|
+
description: definition.description,
|
|
31
|
+
version: definition.version,
|
|
32
|
+
stages: normalizedStages,
|
|
33
|
+
variables: definition.variables,
|
|
34
|
+
settings: definition.settings,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Snapshot-facing alias used by the execution engine and future persistence work.
|
|
39
|
+
* The normalized definition is already snapshot-ready because template text is inlined.
|
|
40
|
+
*/
|
|
41
|
+
export function normalizeForSnapshot(definition, templates) {
|
|
42
|
+
return normalizeDefinition(definition, templates);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Normalize a single call by inlining template text if needed.
|
|
46
|
+
*/
|
|
47
|
+
function normalizeCall(call, templates) {
|
|
48
|
+
if (call.prompt != null) {
|
|
49
|
+
// Already has inline prompt — pass through, strip prompt_template
|
|
50
|
+
const { prompt_template: _, ...rest } = call;
|
|
51
|
+
return { ...rest, prompt: call.prompt };
|
|
52
|
+
}
|
|
53
|
+
// Must have prompt_template (XOR enforced by schema)
|
|
54
|
+
const templatePath = call.prompt_template;
|
|
55
|
+
const content = templates.get(templatePath);
|
|
56
|
+
if (content == null) {
|
|
57
|
+
throw new Error(`Template content not found for path "${templatePath}" ` +
|
|
58
|
+
`— resolveAllTemplates should have loaded this`);
|
|
59
|
+
}
|
|
60
|
+
const hash = hashContent(content);
|
|
61
|
+
const { prompt: _p, prompt_template: _t, ...rest } = call;
|
|
62
|
+
return {
|
|
63
|
+
...rest,
|
|
64
|
+
prompt: content,
|
|
65
|
+
template_hash: hash,
|
|
66
|
+
template_path: templatePath,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Compute a SHA-256 hash of template content for snapshot fingerprinting.
|
|
71
|
+
*/
|
|
72
|
+
function hashContent(content) {
|
|
73
|
+
return createHash("sha256").update(content, "utf-8").digest("hex");
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=definition-normalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition-normalizer.js","sourceRoot":"","sources":["../src/definition-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8CzC,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAA8B,EAC9B,SAAsC;IAEtC,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACzD,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;KACjE,CAAC,CAAC,CAAC;IAEJ,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,QAAQ,EAAE,UAAU,CAAC,QAAQ;KAC9B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAA8B,EAC9B,SAAsC;IAEtC,OAAO,mBAAmB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CACpB,IAAU,EACV,SAAsC;IAEtC,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QACxB,kEAAkE;QAClE,MAAM,EAAE,eAAe,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC7C,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAoB,CAAC;IAC5D,CAAC;IAED,qDAAqD;IACrD,MAAM,YAAY,GAAG,IAAI,CAAC,eAAgB,CAAC;IAC3C,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,wCAAwC,YAAY,IAAI;YACtD,+CAA+C,CAClD,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAC1D,OAAO;QACL,GAAG,IAAI;QACP,MAAM,EAAE,OAAO;QACf,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,YAAY;KACV,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,OAAe;IAClC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow execution engine for ordered linear stages.
|
|
3
|
+
*
|
|
4
|
+
* ## Timeout Ownership Model (3-8)
|
|
5
|
+
*
|
|
6
|
+
* Timeouts in clinkx-workflows operate at three distinct layers, each with
|
|
7
|
+
* clear ownership boundaries:
|
|
8
|
+
*
|
|
9
|
+
* ### Layer 1: Workflow-level deadline (engine-owned)
|
|
10
|
+
*
|
|
11
|
+
* The engine creates an AbortController with a deadline derived from
|
|
12
|
+
* `settings.timeout_seconds` (default: CLINKX_WORKFLOWS_TIMEOUT_SECONDS,
|
|
13
|
+
* 1800s). This is a hard wall clock ceiling for the entire workflow run.
|
|
14
|
+
* When exceeded, remaining stages are aborted and the run fails with
|
|
15
|
+
* a clear timeout error.
|
|
16
|
+
*
|
|
17
|
+
* Owner: WorkflowEngine.createDeadlineController()
|
|
18
|
+
* Config: CLINKX_WORKFLOWS_TIMEOUT_SECONDS (default: 1800)
|
|
19
|
+
* Scope: Entire workflow run
|
|
20
|
+
*
|
|
21
|
+
* ### Layer 2: Per-call parent-side timeout (engine-owned)
|
|
22
|
+
*
|
|
23
|
+
* Each tools/call RPC to the child has a parent-side timeout computed as:
|
|
24
|
+
* max(call.timeout_seconds * 1000 + CALL_TIMEOUT_BUFFER_MS, DEFAULT_PARENT_CALL_TIMEOUT_MS)
|
|
25
|
+
*
|
|
26
|
+
* This prevents individual calls from blocking indefinitely. The buffer
|
|
27
|
+
* (CALL_TIMEOUT_BUFFER_MS = 5s) accounts for child-side teardown latency.
|
|
28
|
+
* DEFAULT_PARENT_CALL_TIMEOUT_MS (600s = 10min) is the floor — even calls
|
|
29
|
+
* without explicit timeout_seconds get a parent-side deadline.
|
|
30
|
+
*
|
|
31
|
+
* Owner: WorkflowEngine.invokeCall()
|
|
32
|
+
* Config: Per-call timeout_seconds in workflow definition
|
|
33
|
+
* Scope: Single tools/call RPC round-trip
|
|
34
|
+
*
|
|
35
|
+
* ### Layer 3: Child-side timeout (adapter-owned, NOT engine-controlled)
|
|
36
|
+
*
|
|
37
|
+
* The ClinkX child's own timeout behavior is controlled by adapter JSON
|
|
38
|
+
* config (codex.json:9, claude.json:8 — both set timeout_seconds: 3600).
|
|
39
|
+
* The env vars CLINKX_TIMEOUT_SECONDS, CLINKX_IDLE_TIMEOUT_SECONDS, and
|
|
40
|
+
* CLINKX_IDLE_TIMEOUT_STARTUP_SECONDS are DEAD KNOBS with current shipped
|
|
41
|
+
* adapters — adapter JSON config wins (runner.ts:156-171).
|
|
42
|
+
*
|
|
43
|
+
* The workflow engine does NOT attempt to control child-side timeouts via
|
|
44
|
+
* env vars. Instead:
|
|
45
|
+
* - Per-call `timeout_seconds` in the workflow definition is passed as a
|
|
46
|
+
* hidden field in the ClinkInput payload, which the child uses for
|
|
47
|
+
* UPWARD EXTENSION ONLY (extends beyond adapter floor, never shortens).
|
|
48
|
+
* - If different child timeout/idle floors are needed, point the child at
|
|
49
|
+
* a workflow-specific adapter bundle via CLINKX_WORKFLOWS_CHILD_CONFIG_PATH.
|
|
50
|
+
*
|
|
51
|
+
* Owner: Adapter JSON config in the child's config path
|
|
52
|
+
* Config: CLINKX_WORKFLOWS_CHILD_CONFIG_PATH for custom adapter bundles
|
|
53
|
+
* Scope: Single subprocess spawn within the child
|
|
54
|
+
*
|
|
55
|
+
* ### Interaction between layers
|
|
56
|
+
*
|
|
57
|
+
* The workflow deadline (L1) takes precedence: if it fires, all in-flight
|
|
58
|
+
* calls are cancelled regardless of their per-call timeouts (L2). The
|
|
59
|
+
* per-call timeout (L2) prevents any single call from consuming the entire
|
|
60
|
+
* workflow budget. The child-side timeout (L3) is independently enforced
|
|
61
|
+
* by the child and may fire before L2 — in that case the child returns
|
|
62
|
+
* isError: true with termination_reason: "wall" or "idle", which the
|
|
63
|
+
* workflow engine treats as a transient failure eligible for retry.
|
|
64
|
+
*/
|
|
65
|
+
import type { NormalizedWorkflowDefinition } from "./definition-normalizer.js";
|
|
66
|
+
import { type ChildFailureMetadata } from "./errors.js";
|
|
67
|
+
import { type FidelityReport } from "./fidelity.js";
|
|
68
|
+
import type { CallState, FailureClass, RunStatus } from "./state-schema.js";
|
|
69
|
+
import type { ClinkBackend } from "./backend.js";
|
|
70
|
+
import type { ValidatorRegistry } from "./validators/index.js";
|
|
71
|
+
import { type ArtifactRecord } from "./artifacts.js";
|
|
72
|
+
export interface ExecutedCall {
|
|
73
|
+
readonly stageId: string;
|
|
74
|
+
readonly callId: string;
|
|
75
|
+
readonly ok: boolean;
|
|
76
|
+
readonly outputText?: string | undefined;
|
|
77
|
+
readonly error?: string | undefined;
|
|
78
|
+
readonly artifact?: ArtifactRecord | undefined;
|
|
79
|
+
readonly fidelity?: FidelityReport | undefined;
|
|
80
|
+
}
|
|
81
|
+
export interface ExecutedStage {
|
|
82
|
+
readonly stageId: string;
|
|
83
|
+
readonly ok: boolean;
|
|
84
|
+
readonly calls: readonly ExecutedCall[];
|
|
85
|
+
readonly aggregateArtifactPath?: string | undefined;
|
|
86
|
+
}
|
|
87
|
+
export interface WorkflowExecutionResult {
|
|
88
|
+
readonly outputText: string;
|
|
89
|
+
readonly stages: readonly ExecutedStage[];
|
|
90
|
+
readonly artifactsDir: string;
|
|
91
|
+
}
|
|
92
|
+
export interface EngineResumeState {
|
|
93
|
+
readonly completedCalls?: ReadonlyMap<string, ExecutedCall> | undefined;
|
|
94
|
+
readonly preparedInputs?: ReadonlyMap<string, Readonly<Record<string, unknown>>> | undefined;
|
|
95
|
+
readonly failedCalls?: ReadonlyMap<string, {
|
|
96
|
+
readonly stageId: string;
|
|
97
|
+
readonly callId: string;
|
|
98
|
+
readonly error: string;
|
|
99
|
+
}> | undefined;
|
|
100
|
+
}
|
|
101
|
+
type HookResult = Promise<void> | void;
|
|
102
|
+
export interface EngineRunStateChange {
|
|
103
|
+
readonly runId: string;
|
|
104
|
+
readonly workflowName: string;
|
|
105
|
+
readonly state: RunStatus;
|
|
106
|
+
readonly startedAt?: string | undefined;
|
|
107
|
+
readonly completedAt?: string | undefined;
|
|
108
|
+
readonly error?: string | undefined;
|
|
109
|
+
readonly failureClass?: FailureClass | undefined;
|
|
110
|
+
}
|
|
111
|
+
export interface EngineCallPreparedEvent {
|
|
112
|
+
readonly runId: string;
|
|
113
|
+
readonly workflowName: string;
|
|
114
|
+
readonly stageId: string;
|
|
115
|
+
readonly callId: string;
|
|
116
|
+
readonly attempt: number;
|
|
117
|
+
readonly retryCount: number;
|
|
118
|
+
readonly contextProducing: boolean;
|
|
119
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
120
|
+
}
|
|
121
|
+
export interface EngineCallStateChange {
|
|
122
|
+
readonly runId: string;
|
|
123
|
+
readonly workflowName: string;
|
|
124
|
+
readonly stageId: string;
|
|
125
|
+
readonly callId: string;
|
|
126
|
+
readonly state: Exclude<CallState, "pending">;
|
|
127
|
+
readonly attempt: number;
|
|
128
|
+
readonly retryCount: number;
|
|
129
|
+
readonly startedAt?: string | undefined;
|
|
130
|
+
readonly completedAt?: string | undefined;
|
|
131
|
+
readonly durationMs?: number | undefined;
|
|
132
|
+
readonly outputText?: string | undefined;
|
|
133
|
+
readonly error?: string | undefined;
|
|
134
|
+
readonly failureClass?: FailureClass | undefined;
|
|
135
|
+
readonly fidelity?: FidelityReport | undefined;
|
|
136
|
+
readonly artifact?: ArtifactRecord | undefined;
|
|
137
|
+
readonly childDebugMetadata?: ChildFailureMetadata | undefined;
|
|
138
|
+
}
|
|
139
|
+
export interface EngineRetryEvent {
|
|
140
|
+
readonly runId: string;
|
|
141
|
+
readonly workflowName: string;
|
|
142
|
+
readonly stageId: string;
|
|
143
|
+
readonly callId: string;
|
|
144
|
+
readonly attempt: number;
|
|
145
|
+
readonly retryCount: number;
|
|
146
|
+
readonly nextRetryCount: number;
|
|
147
|
+
readonly delayMs: number;
|
|
148
|
+
readonly error: string;
|
|
149
|
+
readonly failureClass: FailureClass;
|
|
150
|
+
}
|
|
151
|
+
export interface EngineProgressEvent {
|
|
152
|
+
readonly runId: string;
|
|
153
|
+
readonly workflowName: string;
|
|
154
|
+
readonly scope: "run" | "stage" | "call";
|
|
155
|
+
readonly state: Exclude<CallState, "pending">;
|
|
156
|
+
readonly message: string;
|
|
157
|
+
readonly stageId?: string | undefined;
|
|
158
|
+
readonly stageDescription?: string | undefined;
|
|
159
|
+
readonly callId?: string | undefined;
|
|
160
|
+
readonly attempt?: number | undefined;
|
|
161
|
+
readonly retryCount?: number | undefined;
|
|
162
|
+
}
|
|
163
|
+
export interface EngineHooks {
|
|
164
|
+
readonly onRunStateChange?: ((event: EngineRunStateChange) => HookResult) | undefined;
|
|
165
|
+
readonly onCallPrepared?: ((event: EngineCallPreparedEvent) => HookResult) | undefined;
|
|
166
|
+
readonly onCallStateChange?: ((event: EngineCallStateChange) => HookResult) | undefined;
|
|
167
|
+
readonly onRetryScheduled?: ((event: EngineRetryEvent) => HookResult) | undefined;
|
|
168
|
+
readonly onProgress?: ((event: EngineProgressEvent) => HookResult) | undefined;
|
|
169
|
+
}
|
|
170
|
+
export interface WorkflowEngineOptions {
|
|
171
|
+
readonly definition: NormalizedWorkflowDefinition;
|
|
172
|
+
readonly session: ClinkBackend;
|
|
173
|
+
readonly variables: Readonly<Record<string, unknown>>;
|
|
174
|
+
readonly validatorRegistry: ValidatorRegistry;
|
|
175
|
+
readonly runId: string;
|
|
176
|
+
readonly runDir: string;
|
|
177
|
+
readonly signal?: AbortSignal | undefined;
|
|
178
|
+
readonly maxParallel?: number | undefined;
|
|
179
|
+
readonly childMaxConcurrent?: number | undefined;
|
|
180
|
+
readonly maxPromptBytes?: number | undefined;
|
|
181
|
+
readonly promptReserveBytes?: number | undefined;
|
|
182
|
+
readonly allowedRoots?: readonly string[] | undefined;
|
|
183
|
+
readonly hooks?: EngineHooks | undefined;
|
|
184
|
+
readonly resume?: EngineResumeState | undefined;
|
|
185
|
+
}
|
|
186
|
+
export declare class WorkflowEngine {
|
|
187
|
+
private readonly definition;
|
|
188
|
+
private readonly session;
|
|
189
|
+
private readonly variables;
|
|
190
|
+
private readonly validatorRegistry;
|
|
191
|
+
private readonly runId;
|
|
192
|
+
private readonly runDir;
|
|
193
|
+
private readonly signal;
|
|
194
|
+
private readonly queueDepth;
|
|
195
|
+
private readonly maxPromptBytes;
|
|
196
|
+
private readonly promptReserveBytes;
|
|
197
|
+
private readonly allowedRoots;
|
|
198
|
+
private readonly hooks;
|
|
199
|
+
private readonly resumeCompletedCalls;
|
|
200
|
+
private readonly resumePreparedInputs;
|
|
201
|
+
private readonly resumeFailedCalls;
|
|
202
|
+
private readonly contextProducingCalls;
|
|
203
|
+
private readonly artifactStore;
|
|
204
|
+
constructor(options: WorkflowEngineOptions);
|
|
205
|
+
execute(): Promise<WorkflowExecutionResult>;
|
|
206
|
+
private executeParallelStage;
|
|
207
|
+
private executeSequentialStage;
|
|
208
|
+
private executeSingleCall;
|
|
209
|
+
private invokeCall;
|
|
210
|
+
private maybeWriteArtifact;
|
|
211
|
+
private resolveDynamicPaths;
|
|
212
|
+
private createDeadlineController;
|
|
213
|
+
private throwIfAborted;
|
|
214
|
+
private validateFinalStage;
|
|
215
|
+
private validateAdvertisedCliNames;
|
|
216
|
+
private defaultAllowedRoots;
|
|
217
|
+
private buildCallInput;
|
|
218
|
+
private materializeUnexpectedFailure;
|
|
219
|
+
private emitRunStateChange;
|
|
220
|
+
private emitCallPrepared;
|
|
221
|
+
private emitCallStateChange;
|
|
222
|
+
private emitRetryScheduled;
|
|
223
|
+
private emitProgress;
|
|
224
|
+
private seedResumedArtifacts;
|
|
225
|
+
/**
|
|
226
|
+
* Pre-flight validation: check that all user-supplied file/image paths exist
|
|
227
|
+
* before any stage executes. Skips already-completed calls on resume.
|
|
228
|
+
*
|
|
229
|
+
* - ENOENT → collect as missing (fail-fast after checking all)
|
|
230
|
+
* - EACCES/EIO → warn but don't fail (NFS/FUSE transient)
|
|
231
|
+
* - context_from artifacts are NOT validated (engine-generated)
|
|
232
|
+
*/
|
|
233
|
+
private validateInputPathsExist;
|
|
234
|
+
}
|
|
235
|
+
export {};
|