@evomap/evolver-core 2.0.0-beta.0 → 2.0.0-beta.10
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/assets/gep/genes.jsonl +5 -0
- package/dist/algo/candidateAssembly.js +23 -14
- package/dist/algo/capabilityCandidates.d.ts +2 -0
- package/dist/algo/capabilityCandidates.js +5 -0
- package/dist/algo/conversationSniffer.d.ts +18 -0
- package/dist/algo/conversationSniffer.js +149 -0
- package/dist/algo/cycleEngine.d.ts +11 -0
- package/dist/algo/cycleEngine.js +14 -6
- package/dist/algo/cycleFailureClassifier.d.ts +1 -1
- package/dist/algo/cycleFailureClassifier.js +13 -5
- package/dist/algo/geneIntake.d.ts +14 -4
- package/dist/algo/geneIntake.js +37 -9
- package/dist/algo/geneSelection.d.ts +18 -1
- package/dist/algo/geneSelection.js +42 -18
- package/dist/algo/index.d.ts +2 -0
- package/dist/algo/index.js +2 -0
- package/dist/algo/memoryGraph.d.ts +62 -0
- package/dist/algo/memoryGraph.js +86 -0
- package/dist/algo/orchestrator.d.ts +3 -0
- package/dist/algo/orchestrator.js +14 -2
- package/dist/assetstore/assetSidecarRecords.d.ts +28 -0
- package/dist/assetstore/assetSidecarRecords.js +376 -0
- package/dist/assetstore/assetSidecarRecovery.d.ts +48 -0
- package/dist/assetstore/assetSidecarRecovery.js +288 -0
- package/dist/assetstore/assetStoreHealth.d.ts +75 -0
- package/dist/assetstore/assetStoreHealth.js +277 -0
- package/dist/assetstore/assetStoreLayout.d.ts +2 -0
- package/dist/assetstore/assetStoreLayout.js +6 -0
- package/dist/assetstore/assetStoreStorage.d.ts +42 -0
- package/dist/assetstore/assetStoreStorage.js +327 -0
- package/dist/assetstore/assetSyncLedger.d.ts +118 -0
- package/dist/assetstore/assetSyncLedger.js +745 -0
- package/dist/assetstore/index.d.ts +5 -1
- package/dist/assetstore/index.js +5 -1
- package/dist/assetstore/localJsonl.d.ts +12 -3
- package/dist/assetstore/localJsonl.js +131 -39
- package/dist/assetstore/pendingSignals.js +3 -1
- package/dist/assetstore/provenance.d.ts +27 -4
- package/dist/assetstore/provenance.js +107 -56
- package/dist/assetstore/provider.d.ts +26 -0
- package/dist/assetstore/provider.js +50 -0
- package/dist/assetstore/reviewFilter.js +5 -2
- package/dist/assetstore/reviewLedger.d.ts +14 -2
- package/dist/assetstore/reviewLedger.js +78 -43
- package/dist/assetstore/seedGenes.d.ts +3 -0
- package/dist/assetstore/seedGenes.js +134 -0
- package/dist/benchmark/antiGeneBenchmark.d.ts +2 -0
- package/dist/benchmark/antiGeneBenchmark.js +11 -1
- package/dist/benchmark/antiGeneImpact.d.ts +16 -0
- package/dist/benchmark/antiGeneImpact.js +34 -0
- package/dist/benchmark/antiGeneRollout.d.ts +2 -0
- package/dist/benchmark/antiGeneRollout.js +13 -1
- package/dist/benchmark/index.d.ts +2 -1
- package/dist/benchmark/index.js +2 -1
- package/dist/benchmark/triggerShift.d.ts +62 -0
- package/dist/benchmark/triggerShift.js +106 -0
- package/dist/events/eventArchive.d.ts +65 -0
- package/dist/events/eventArchive.js +343 -0
- package/dist/events/eventStore.js +2 -12
- package/dist/events/ingest.d.ts +1 -1
- package/dist/events/ingest.js +9 -0
- package/dist/events/paths.d.ts +10 -10
- package/dist/events/paths.js +20 -20
- package/dist/events/public.d.ts +3 -1
- package/dist/events/public.js +2 -1
- package/dist/events/retention.d.ts +24 -1
- package/dist/events/retention.js +133 -37
- package/dist/exec/autoExec.d.ts +6 -1
- package/dist/exec/autoExec.js +34 -0
- package/dist/exec/autonomousCycle.d.ts +2 -0
- package/dist/exec/autonomousCycle.js +5 -0
- package/dist/exec/claudeBridge.d.ts +21 -3
- package/dist/exec/claudeBridge.js +413 -26
- package/dist/exec/openPrRegistry.d.ts +8 -2
- package/dist/exec/openPrRegistry.js +32 -22
- package/dist/exec/prompt.js +9 -0
- package/dist/exec/runnerRegistry.d.ts +90 -18
- package/dist/exec/runnerRegistry.js +603 -42
- package/dist/exec/selfPrObfuscation.d.ts +2 -1
- package/dist/exec/selfPrObfuscation.js +19 -6
- package/dist/hub/agentDirectory.d.ts +90 -0
- package/dist/hub/agentDirectory.js +104 -0
- package/dist/hub/bindings.js +23 -3
- package/dist/hub/capability.d.ts +14 -2
- package/dist/hub/fake.d.ts +4 -2
- package/dist/hub/fake.js +3 -2
- package/dist/hub/index.d.ts +1 -0
- package/dist/hub/index.js +1 -0
- package/dist/hub/sanitize.js +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/issueReporter/index.d.ts +156 -0
- package/dist/issueReporter/index.js +1688 -0
- package/dist/mailbox/catalog.js +3 -0
- package/dist/mailbox/ipcServer.js +2 -2
- package/dist/mailbox/store.d.ts +14 -0
- package/dist/mailbox/store.js +58 -6
- package/dist/material/consumer.js +9 -6
- package/dist/material/index.d.ts +1 -0
- package/dist/material/index.js +1 -0
- package/dist/material/materialArchive.d.ts +81 -0
- package/dist/material/materialArchive.js +466 -0
- package/dist/material/materialStore.d.ts +1 -0
- package/dist/material/materialStore.js +6 -13
- package/dist/ops/savingsCore.js +1 -2
- package/dist/ops/selfUpdate.d.ts +10 -1
- package/dist/ops/selfUpdate.js +64 -15
- package/dist/personality/schema.d.ts +12 -12
- package/dist/schema/common.d.ts +1 -1
- package/dist/schema/common.js +1 -1
- package/dist/schema/material.d.ts +5 -5
- package/dist/strategy/constraintAblation.d.ts +64 -0
- package/dist/strategy/constraintAblation.js +3074 -0
- package/dist/strategy/index.d.ts +2 -1
- package/dist/strategy/index.js +2 -1
- package/dist/trace/trajectoryExport.js +2 -2
- package/dist/util/fetchPort.d.ts +1 -0
- package/dist/util/fetchPort.js +11 -0
- package/dist/util/fileLock.d.ts +24 -5
- package/dist/util/fileLock.js +288 -72
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +1 -0
- package/dist/wire/geneHints.d.ts +42 -1
- package/dist/wire/geneHints.js +52 -1
- package/dist/wire/index.d.ts +14 -2
- package/dist/wire/index.js +1 -1
- package/dist/workflow/dsl.d.ts +24 -3
- package/dist/workflow/dsl.js +4 -0
- package/dist/workflow/engine.d.ts +5 -1
- package/dist/workflow/engine.js +3 -0
- package/dist/workflow/index.d.ts +3 -1
- package/dist/workflow/index.js +3 -1
- package/dist/workflow/runtime.d.ts +110 -0
- package/dist/workflow/runtime.js +1298 -0
- package/dist/workflow/stateStore.d.ts +172 -0
- package/dist/workflow/stateStore.js +1044 -0
- package/package.json +6 -1
package/dist/wire/geneHints.js
CHANGED
|
@@ -22,13 +22,22 @@
|
|
|
22
22
|
export const ROUTING_TIERS = ['cheap', 'mid', 'expensive'];
|
|
23
23
|
export const REASONING_LEVELS = ['off', 'low', 'medium', 'high'];
|
|
24
24
|
export const TOOL_POLICY_SEVERITIES = ['warn', 'block'];
|
|
25
|
+
/**
|
|
26
|
+
* Provenance classification (V1 #302 classifyProvenance, aligned with TaskGenome Bench §3.1): a Gene's value
|
|
27
|
+
* depends on WHERE it came from, not on being short. The three tiers:
|
|
28
|
+
* evolved -- distilled from a real solve -> fail -> mutate -> pass trajectory; beats Skills (+8.7..+15.5pp)
|
|
29
|
+
* distilled -- transcribed from reference/teacher text with no real failing trajectory; WORSE than Skills (-3.2..-11.2pp)
|
|
30
|
+
* manual -- pure human transcription, no execution evidence at all
|
|
31
|
+
* The high-value payload of an evolved Gene is the corrective_insight that flipped the outcome.
|
|
32
|
+
*/
|
|
33
|
+
export const GENERATION_SOURCES = ['evolved', 'distilled', 'manual'];
|
|
25
34
|
/**
|
|
26
35
|
* The v2-delta hint field names, in one place — the intake gate strips these before the gep-sdk schema check.
|
|
27
36
|
* IMPORTANT: when a gep-sdk gene-schema bump makes one of these first-class, REMOVE it from this list in the
|
|
28
37
|
* same change. Otherwise intakeGene keeps stripping a now-validated field before validateWire (fail-open — the
|
|
29
38
|
* field's new schema constraints go unchecked at intake) while asset_id still commits it.
|
|
30
39
|
*/
|
|
31
|
-
export const GENE_HINT_FIELDS = ['routing_hint', 'tool_policy'];
|
|
40
|
+
export const GENE_HINT_FIELDS = ['routing_hint', 'tool_policy', 'generation_meta'];
|
|
32
41
|
function includesEnum(set, v) {
|
|
33
42
|
return typeof v === 'string' && set.includes(v);
|
|
34
43
|
}
|
|
@@ -89,6 +98,48 @@ function cleanToolList(raw) {
|
|
|
89
98
|
const cleaned = raw.filter((x) => typeof x === 'string' && x.length > 0);
|
|
90
99
|
return cleaned.length > 0 ? cleaned : undefined;
|
|
91
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Normalize an arbitrary generation_meta fragment to a strict { source, quality_score?, quality_heuristics?,
|
|
103
|
+
* overcame_errors? } object, or null. Lossy (mirrors normalizeRoutingHint / normalizeToolPolicy): unknown source
|
|
104
|
+
* values are dropped (the whole block collapses to null — a generation_meta with no recognized source carries no
|
|
105
|
+
* usable provenance signal); quality_score is clamped to [0,1]; heuristics keeps only its numeric/boolean fields;
|
|
106
|
+
* overcame_errors keeps only non-empty strings. A block with a valid source but all-else-empty still survives (source
|
|
107
|
+
* alone is a meaningful provenance tag); only a missing/unknown source yields null.
|
|
108
|
+
*/
|
|
109
|
+
export function normalizeGenerationMeta(raw) {
|
|
110
|
+
if (!raw || typeof raw !== 'object')
|
|
111
|
+
return null;
|
|
112
|
+
const r = raw;
|
|
113
|
+
const source = r['source'];
|
|
114
|
+
if (!includesEnum(GENERATION_SOURCES, source))
|
|
115
|
+
return null;
|
|
116
|
+
const out = { source };
|
|
117
|
+
const qs = r['quality_score'];
|
|
118
|
+
if (typeof qs === 'number' && Number.isFinite(qs))
|
|
119
|
+
out.quality_score = Math.max(0, Math.min(1, qs));
|
|
120
|
+
const eh = r['quality_heuristics'];
|
|
121
|
+
if (eh && typeof eh === 'object') {
|
|
122
|
+
const h = eh;
|
|
123
|
+
const heuristics = {};
|
|
124
|
+
const numFields = [
|
|
125
|
+
'strategy_steps', 'avoid_count', 'validation_declared_count', 'validation_runnable_count',
|
|
126
|
+
'signals_extracted', 'preconditions_extracted', 'trajectory_depth',
|
|
127
|
+
];
|
|
128
|
+
for (const k of numFields) {
|
|
129
|
+
const v = h[k];
|
|
130
|
+
if (typeof v === 'number' && Number.isFinite(v))
|
|
131
|
+
heuristics[k] = v;
|
|
132
|
+
}
|
|
133
|
+
if (typeof h['has_corrective_insight'] === 'boolean')
|
|
134
|
+
heuristics.has_corrective_insight = h['has_corrective_insight'];
|
|
135
|
+
if (Object.keys(heuristics).length > 0)
|
|
136
|
+
out.quality_heuristics = heuristics;
|
|
137
|
+
}
|
|
138
|
+
const errs = cleanToolList(r['overcame_errors']);
|
|
139
|
+
if (errs)
|
|
140
|
+
out.overcame_errors = errs;
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
92
143
|
/** Strip the v2-delta hint fields from a gene-shaped object (used to validate the gep-sdk-known core). */
|
|
93
144
|
export function stripGeneHints(gene) {
|
|
94
145
|
const hidden = GENE_HINT_FIELDS;
|
package/dist/wire/index.d.ts
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
* 资产 wire 层. SSOT = @evomap/gep-sdk/schemas/*.schema.json (D19).
|
|
3
3
|
* 字段一律 snake_case 锁定 (asset_id 跨实现契约); 本仓不发明 wire 字段, 只镜像 + 重导出工具.
|
|
4
4
|
*/
|
|
5
|
-
import type { GeneRoutingHint, GeneToolPolicy } from './geneHints.js';
|
|
5
|
+
import type { GeneRoutingHint, GeneToolPolicy, GenerationMeta } from './geneHints.js';
|
|
6
6
|
export { SCHEMA_VERSION, canonicalize, computeAssetId, verifyAssetId } from '@evomap/gep-sdk';
|
|
7
7
|
export type GepCategory = typeof import('@evomap/gep-sdk').GEP_GENE_CATEGORIES[number];
|
|
8
8
|
export type OutcomeStatus = typeof import('@evomap/gep-sdk').GEP_OUTCOME_STATUSES[number];
|
|
9
9
|
export type SourceType = typeof import('@evomap/gep-sdk').GEP_SOURCE_TYPES[number];
|
|
10
10
|
export type RiskLevel = typeof import('@evomap/gep-sdk').GEP_RISK_LEVELS[number];
|
|
11
|
+
export type CapsuleVisibility = typeof import('@evomap/gep-sdk').GEP_CAPSULE_VISIBILITIES[number];
|
|
12
|
+
export type CapsuleCostTier = typeof import('@evomap/gep-sdk').GEP_CAPSULE_COST_TIERS[number];
|
|
13
|
+
export interface CapsuleAuthor {
|
|
14
|
+
handle: string;
|
|
15
|
+
evox_install_id: string;
|
|
16
|
+
}
|
|
11
17
|
/** Gene = 基因型/方法论 (gene.schema.json). */
|
|
12
18
|
export interface Gene {
|
|
13
19
|
type: 'Gene';
|
|
@@ -28,6 +34,7 @@ export interface Gene {
|
|
|
28
34
|
anti_patterns?: unknown[];
|
|
29
35
|
routing_hint?: GeneRoutingHint | null;
|
|
30
36
|
tool_policy?: GeneToolPolicy | null;
|
|
37
|
+
generation_meta?: GenerationMeta | null;
|
|
31
38
|
asset_id: string;
|
|
32
39
|
}
|
|
33
40
|
/** Capsule = 表现型/纯进化产物 (capsule.schema.json). */
|
|
@@ -49,6 +56,11 @@ export interface Capsule {
|
|
|
49
56
|
};
|
|
50
57
|
resolution_status?: 'pending' | 'suppressed_observationally' | 'resolved_by_evidence' | 'regressed' | 'inconclusive';
|
|
51
58
|
proof_of_work?: unknown;
|
|
59
|
+
visibility?: CapsuleVisibility | null;
|
|
60
|
+
scope?: string[] | null;
|
|
61
|
+
cost_tier?: CapsuleCostTier | null;
|
|
62
|
+
pack_of?: string[] | null;
|
|
63
|
+
author?: CapsuleAuthor | null;
|
|
52
64
|
execution_trace?: unknown[];
|
|
53
65
|
trigger_context?: unknown;
|
|
54
66
|
asset_id: string;
|
|
@@ -88,4 +100,4 @@ export interface Mutation {
|
|
|
88
100
|
risk_level: RiskLevel;
|
|
89
101
|
}
|
|
90
102
|
export { validateWire, schemaProperties, type WireValidation } from './schemaGate.js';
|
|
91
|
-
export { ROUTING_TIERS, REASONING_LEVELS, TOOL_POLICY_SEVERITIES, GENE_HINT_FIELDS, normalizeRoutingHint, normalizeToolPolicy, stripGeneHints, type RoutingTier, type ReasoningLevel, type ToolPolicySeverity, type GeneRoutingHint, type GeneToolPolicy, } from './geneHints.js';
|
|
103
|
+
export { ROUTING_TIERS, REASONING_LEVELS, TOOL_POLICY_SEVERITIES, GENERATION_SOURCES, GENE_HINT_FIELDS, normalizeRoutingHint, normalizeToolPolicy, normalizeGenerationMeta, stripGeneHints, type RoutingTier, type ReasoningLevel, type ToolPolicySeverity, type GenerationSource, type GeneRoutingHint, type GeneToolPolicy, type GeneGenerationHeuristics, type GenerationMeta, } from './geneHints.js';
|
package/dist/wire/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { SCHEMA_VERSION, canonicalize, computeAssetId, verifyAssetId } from '@evomap/gep-sdk';
|
|
2
2
|
export { validateWire, schemaProperties } from './schemaGate.js';
|
|
3
|
-
export { ROUTING_TIERS, REASONING_LEVELS, TOOL_POLICY_SEVERITIES, GENE_HINT_FIELDS, normalizeRoutingHint, normalizeToolPolicy, stripGeneHints, } from './geneHints.js';
|
|
3
|
+
export { ROUTING_TIERS, REASONING_LEVELS, TOOL_POLICY_SEVERITIES, GENERATION_SOURCES, GENE_HINT_FIELDS, normalizeRoutingHint, normalizeToolPolicy, normalizeGenerationMeta, stripGeneHints, } from './geneHints.js';
|
package/dist/workflow/dsl.d.ts
CHANGED
|
@@ -14,13 +14,26 @@ export interface CoreCall {
|
|
|
14
14
|
fn: string;
|
|
15
15
|
args: Value[];
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export type WorkflowErrorClass = 'transient' | 'permanent' | 'safety' | 'unknown';
|
|
18
|
+
export declare function containsWorkflowSensitiveText(value: string): boolean;
|
|
19
|
+
export interface WorkflowRetryPolicy {
|
|
20
|
+
maxAttempts: number;
|
|
21
|
+
initialDelayMs?: number;
|
|
22
|
+
maxDelayMs?: number;
|
|
23
|
+
multiplier?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface DurableStepOptions {
|
|
26
|
+
/** Agent steps default to non-idempotent; script steps default to idempotent. */
|
|
27
|
+
idempotency?: 'idempotent' | 'non_idempotent';
|
|
28
|
+
retry?: WorkflowRetryPolicy;
|
|
29
|
+
}
|
|
30
|
+
export interface ScriptStep extends DurableStepOptions {
|
|
18
31
|
id: string;
|
|
19
32
|
kind: 'script';
|
|
20
33
|
setOutput: string;
|
|
21
34
|
call: CoreCall;
|
|
22
35
|
}
|
|
23
|
-
export interface AgentStep {
|
|
36
|
+
export interface AgentStep extends DurableStepOptions {
|
|
24
37
|
id: string;
|
|
25
38
|
kind: 'agent';
|
|
26
39
|
prompt: string;
|
|
@@ -42,8 +55,16 @@ export interface IfStep {
|
|
|
42
55
|
then: WorkflowStep[];
|
|
43
56
|
else?: WorkflowStep[];
|
|
44
57
|
}
|
|
45
|
-
|
|
58
|
+
/** Durable human gate. Execution stops before subsequent steps until an operator approves or rejects it. */
|
|
59
|
+
export interface ApprovalStep {
|
|
60
|
+
id: string;
|
|
61
|
+
kind: 'approval';
|
|
62
|
+
label?: string;
|
|
63
|
+
}
|
|
64
|
+
export type WorkflowStep = ScriptStep | AgentStep | ForeachStep | IfStep | ApprovalStep;
|
|
46
65
|
export interface WorkflowSpec {
|
|
66
|
+
/** Stable caller-supplied identity. If omitted, the durable runtime derives one from the definition. */
|
|
67
|
+
workflowId?: string;
|
|
47
68
|
name: string;
|
|
48
69
|
input?: Record<string, unknown>;
|
|
49
70
|
steps: WorkflowStep[];
|
package/dist/workflow/dsl.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* 表达式表示为**结构化对象**(非字符串解析): 引用 Ref + 白名单 core 调用, 安全 by-construction.
|
|
4
4
|
*/
|
|
5
5
|
export function isRef(v) { return typeof v === 'object' && v !== null && 'ref' in v; }
|
|
6
|
+
const WORKFLOW_SENSITIVE_TEXT_RE = /(?:\bBearer\s+[A-Za-z0-9._~+/=-]{8,}|\bsk-[A-Za-z0-9_-]{12,}|\b(?:gh[oprsu]|npm)_[A-Za-z0-9_-]{8,}|\bgithub_pat_[A-Za-z0-9_]{8,}|\b(?:AKIA|ASIA)[0-9A-Z]{16}\b|\bAIza[0-9A-Za-z_-]{35}\b|-----BEGIN [A-Z ]*PRIVATE KEY-----|\b(?:password|passwd|secret|token|api[_-]?key|accountkey)\s*[:=]\s*\S+)/i;
|
|
7
|
+
export function containsWorkflowSensitiveText(value) {
|
|
8
|
+
return WORKFLOW_SENSITIVE_TEXT_RE.test(value);
|
|
9
|
+
}
|
|
6
10
|
export const CORE_WHITELIST = {
|
|
7
11
|
list_len: (a) => (Array.isArray(a) ? a.length : 0),
|
|
8
12
|
filter_by_mask: (items, mask) => (Array.isArray(items) && Array.isArray(mask) ? items.filter((_, i) => Boolean(mask[i])) : []),
|
|
@@ -4,8 +4,12 @@ export interface WorkflowContext {
|
|
|
4
4
|
steps: Record<string, unknown>;
|
|
5
5
|
item?: unknown;
|
|
6
6
|
}
|
|
7
|
+
export interface AgentBridgeOptions {
|
|
8
|
+
/** Cooperative cancellation for the current durable attempt. */
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
7
11
|
/** agent step 桥(注入 runtime; 孵化期可注 stub). */
|
|
8
|
-
export type AgentBridge = (prompt: string, ctx: WorkflowContext) => Promise<unknown> | unknown;
|
|
12
|
+
export type AgentBridge = (prompt: string, ctx: WorkflowContext, options?: AgentBridgeOptions) => Promise<unknown> | unknown;
|
|
9
13
|
export interface WorkflowEngineDeps {
|
|
10
14
|
core?: Record<string, CoreFn>;
|
|
11
15
|
agent: AgentBridge;
|
package/dist/workflow/engine.js
CHANGED
|
@@ -68,6 +68,9 @@ export class WorkflowEngine {
|
|
|
68
68
|
await this.runSteps(branch, ctx);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
+
case 'approval': {
|
|
72
|
+
throw new WorkflowError('approval steps require DurableWorkflowRuntime');
|
|
73
|
+
}
|
|
71
74
|
case 'foreach': {
|
|
72
75
|
const items = resolveRef(step.over.ref, ctx);
|
|
73
76
|
if (!Array.isArray(items))
|
package/dist/workflow/index.d.ts
CHANGED
package/dist/workflow/index.js
CHANGED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type CoreFn, type WorkflowErrorClass, type WorkflowSpec } from './dsl.js';
|
|
2
|
+
import type { AgentBridge, WorkflowContext } from './engine.js';
|
|
3
|
+
import { WorkflowStateError, WorkflowStateStore, type WorkflowControlState, type WorkflowOperatorOptions, type WorkflowRunState, type WorkflowStateStoreOptions, type WorkflowStepState } from './stateStore.js';
|
|
4
|
+
export declare const MAX_WORKFLOW_DEFINITION_STEPS = 256;
|
|
5
|
+
export declare const MAX_WORKFLOW_NESTING_DEPTH = 16;
|
|
6
|
+
export declare const MAX_WORKFLOW_FOREACH_ITEMS = 1000;
|
|
7
|
+
export interface WorkflowRuntimeDeps {
|
|
8
|
+
agent: AgentBridge;
|
|
9
|
+
stateDir?: string;
|
|
10
|
+
core?: Record<string, CoreFn>;
|
|
11
|
+
now?: () => number;
|
|
12
|
+
sleep?: (ms: number) => Promise<void>;
|
|
13
|
+
classifyError?: (error: unknown) => WorkflowErrorClass;
|
|
14
|
+
generateRunId?: () => string;
|
|
15
|
+
maxConcurrentRuns?: number;
|
|
16
|
+
maxQueuedRuns?: number;
|
|
17
|
+
maxStepExecutions?: number;
|
|
18
|
+
/** Test/embedding seam invoked only after a durable checkpoint has completed. */
|
|
19
|
+
afterCheckpoint?: (state: Readonly<WorkflowRunState>) => void | Promise<void>;
|
|
20
|
+
/** Synchronous fault-injection seam invoked under the commit lock; callbacks must not re-enter the store. */
|
|
21
|
+
onTransactionPhase?: WorkflowStateStoreOptions['onTransactionPhase'];
|
|
22
|
+
/** Bounded startup-recovery diagnostic; raw errors are never exposed. */
|
|
23
|
+
onRecoveryFailure?: (failure: WorkflowRecoveryFailure) => void;
|
|
24
|
+
lock?: {
|
|
25
|
+
maxTries?: number;
|
|
26
|
+
waitMs?: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface WorkflowRecoveryFailure {
|
|
30
|
+
runId: string;
|
|
31
|
+
code: WorkflowStateError['code'] | 'RUN_FAILED' | 'RECOVERY_FAILED';
|
|
32
|
+
}
|
|
33
|
+
export interface WorkflowRunResult {
|
|
34
|
+
runId: string;
|
|
35
|
+
workflowId: string;
|
|
36
|
+
status: WorkflowRunState['status'];
|
|
37
|
+
output: unknown;
|
|
38
|
+
ctx: WorkflowContext;
|
|
39
|
+
}
|
|
40
|
+
export declare class WorkflowRuntimeError extends Error {
|
|
41
|
+
readonly code: 'SENSITIVE_STATE' | 'INVALID_STATE' | 'UNSUPPORTED_PARALLELISM' | 'RUN_NOT_RESUMABLE' | 'INVALID_RETRY' | 'INVALID_CONCURRENCY' | 'RESOURCE_LIMIT';
|
|
42
|
+
constructor(message: string, code: 'SENSITIVE_STATE' | 'INVALID_STATE' | 'UNSUPPORTED_PARALLELISM' | 'RUN_NOT_RESUMABLE' | 'INVALID_RETRY' | 'INVALID_CONCURRENCY' | 'RESOURCE_LIMIT');
|
|
43
|
+
}
|
|
44
|
+
export declare class WorkflowRunFailedError extends Error {
|
|
45
|
+
readonly runId: string;
|
|
46
|
+
readonly status: 'failed' | 'unsafe_to_resume';
|
|
47
|
+
readonly errorClass: WorkflowStepState['lastErrorClass'];
|
|
48
|
+
constructor(runId: string, status: 'failed' | 'unsafe_to_resume', errorClass: WorkflowStepState['lastErrorClass']);
|
|
49
|
+
}
|
|
50
|
+
export declare class ClassifiedWorkflowError extends Error {
|
|
51
|
+
readonly errorClass: WorkflowErrorClass;
|
|
52
|
+
constructor(errorClass: WorkflowErrorClass, message?: string);
|
|
53
|
+
}
|
|
54
|
+
export declare function defaultWorkflowStateDir(): string;
|
|
55
|
+
export declare function deriveWorkflowId(spec: WorkflowSpec): string;
|
|
56
|
+
export declare function assertValidWorkflowSpec(value: unknown): asserts value is WorkflowSpec;
|
|
57
|
+
export declare class DurableWorkflowRuntime {
|
|
58
|
+
private readonly deps;
|
|
59
|
+
readonly store: WorkflowStateStore;
|
|
60
|
+
private readonly core;
|
|
61
|
+
private readonly now;
|
|
62
|
+
private readonly sleep;
|
|
63
|
+
private readonly classifyError;
|
|
64
|
+
private readonly generateRunId;
|
|
65
|
+
private readonly scheduler;
|
|
66
|
+
private readonly maxConcurrentRuns;
|
|
67
|
+
private readonly maxStepExecutions;
|
|
68
|
+
private readonly inFlight;
|
|
69
|
+
constructor(deps: WorkflowRuntimeDeps);
|
|
70
|
+
start(spec: WorkflowSpec, options?: {
|
|
71
|
+
runId?: string;
|
|
72
|
+
} | string): Promise<WorkflowRunResult>;
|
|
73
|
+
resume(runId: string, options?: WorkflowOperatorOptions): Promise<WorkflowRunResult>;
|
|
74
|
+
operatorResume(runId: string, options: WorkflowOperatorOptions): Promise<WorkflowRunResult>;
|
|
75
|
+
pause(runId: string, options: WorkflowOperatorOptions): Promise<WorkflowRunResult>;
|
|
76
|
+
cancel(runId: string, options: WorkflowOperatorOptions): Promise<WorkflowRunResult>;
|
|
77
|
+
approve(runId: string, gateId: string, options: WorkflowOperatorOptions): Promise<WorkflowRunResult>;
|
|
78
|
+
reject(runId: string, gateId: string, options: WorkflowOperatorOptions): Promise<WorkflowRunResult>;
|
|
79
|
+
status(runId: string): WorkflowRunState;
|
|
80
|
+
history(runId: string): ReturnType<WorkflowStateStore['readHistory']>;
|
|
81
|
+
recoverPending(): Promise<WorkflowRunResult[]>;
|
|
82
|
+
protected isRecoveryCandidate(state: WorkflowRunState, control: WorkflowControlState): boolean;
|
|
83
|
+
protected recoverRuns(shouldRecover: (runId: string) => boolean | Promise<boolean>, reportFailure: (runId: string, error: unknown) => void): Promise<WorkflowRunResult[]>;
|
|
84
|
+
private scheduleRecoveryRun;
|
|
85
|
+
private scheduleRun;
|
|
86
|
+
private resumeLocked;
|
|
87
|
+
private withLockedRun;
|
|
88
|
+
private withConcurrencySlot;
|
|
89
|
+
private validateResumeStateOrFail;
|
|
90
|
+
private execute;
|
|
91
|
+
private runSteps;
|
|
92
|
+
private runStep;
|
|
93
|
+
private lastStepOutput;
|
|
94
|
+
private failState;
|
|
95
|
+
private runApproval;
|
|
96
|
+
private runLeaf;
|
|
97
|
+
private runAgentAttempt;
|
|
98
|
+
private observeCancellation;
|
|
99
|
+
private checkpointCompletion;
|
|
100
|
+
private enforceControlBoundary;
|
|
101
|
+
private finalizeCancellation;
|
|
102
|
+
private checkpoint;
|
|
103
|
+
private safetyCheckpoint;
|
|
104
|
+
private ensureApprovalDecisionHistory;
|
|
105
|
+
private appendHistoryUnlessUnavailable;
|
|
106
|
+
private historyEvent;
|
|
107
|
+
private timestamp;
|
|
108
|
+
private result;
|
|
109
|
+
private reportRecoveryFailure;
|
|
110
|
+
}
|