condukt 0.1.0
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/dist/bridge/bridge.d.ts +34 -0
- package/dist/bridge/bridge.d.ts.map +1 -0
- package/dist/bridge/bridge.js +365 -0
- package/dist/bridge/bridge.js.map +1 -0
- package/dist/bridge/index.d.ts +3 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +6 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/runtimes/copilot/copilot-adapter.d.ts +28 -0
- package/dist/runtimes/copilot/copilot-adapter.d.ts.map +1 -0
- package/dist/runtimes/copilot/copilot-adapter.js +50 -0
- package/dist/runtimes/copilot/copilot-adapter.js.map +1 -0
- package/dist/runtimes/copilot/copilot-backend.d.ts +49 -0
- package/dist/runtimes/copilot/copilot-backend.d.ts.map +1 -0
- package/dist/runtimes/copilot/copilot-backend.js +13 -0
- package/dist/runtimes/copilot/copilot-backend.js.map +1 -0
- package/dist/runtimes/copilot/index.d.ts +5 -0
- package/dist/runtimes/copilot/index.d.ts.map +1 -0
- package/dist/runtimes/copilot/index.js +11 -0
- package/dist/runtimes/copilot/index.js.map +1 -0
- package/dist/runtimes/copilot/process-killer.d.ts +13 -0
- package/dist/runtimes/copilot/process-killer.d.ts.map +1 -0
- package/dist/runtimes/copilot/process-killer.js +77 -0
- package/dist/runtimes/copilot/process-killer.js.map +1 -0
- package/dist/runtimes/copilot/subprocess-backend.d.ts +26 -0
- package/dist/runtimes/copilot/subprocess-backend.d.ts.map +1 -0
- package/dist/runtimes/copilot/subprocess-backend.js +308 -0
- package/dist/runtimes/copilot/subprocess-backend.js.map +1 -0
- package/dist/runtimes/mock/index.d.ts +3 -0
- package/dist/runtimes/mock/index.d.ts.map +1 -0
- package/dist/runtimes/mock/index.js +6 -0
- package/dist/runtimes/mock/index.js.map +1 -0
- package/dist/runtimes/mock/mock-runtime.d.ts +43 -0
- package/dist/runtimes/mock/mock-runtime.d.ts.map +1 -0
- package/dist/runtimes/mock/mock-runtime.js +153 -0
- package/dist/runtimes/mock/mock-runtime.js.map +1 -0
- package/dist/src/agent.d.ts +35 -0
- package/dist/src/agent.d.ts.map +1 -0
- package/dist/src/agent.js +257 -0
- package/dist/src/agent.js.map +1 -0
- package/dist/src/events.d.ts +153 -0
- package/dist/src/events.d.ts.map +1 -0
- package/dist/src/events.js +11 -0
- package/dist/src/events.js.map +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +24 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/nodes.d.ts +63 -0
- package/dist/src/nodes.d.ts.map +1 -0
- package/dist/src/nodes.js +120 -0
- package/dist/src/nodes.js.map +1 -0
- package/dist/src/scheduler.d.ts +11 -0
- package/dist/src/scheduler.d.ts.map +1 -0
- package/dist/src/scheduler.js +478 -0
- package/dist/src/scheduler.js.map +1 -0
- package/dist/src/types.d.ts +201 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +38 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/verify.d.ts +51 -0
- package/dist/src/verify.d.ts.map +1 -0
- package/dist/src/verify.js +126 -0
- package/dist/src/verify.js.map +1 -0
- package/dist/state/index.d.ts +5 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +14 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/reducer.d.ts +11 -0
- package/dist/state/reducer.d.ts.map +1 -0
- package/dist/state/reducer.js +223 -0
- package/dist/state/reducer.js.map +1 -0
- package/dist/state/state-runtime.d.ts +30 -0
- package/dist/state/state-runtime.d.ts.map +1 -0
- package/dist/state/state-runtime.js +131 -0
- package/dist/state/state-runtime.js.map +1 -0
- package/dist/state/storage-memory.d.ts +24 -0
- package/dist/state/storage-memory.d.ts.map +1 -0
- package/dist/state/storage-memory.js +91 -0
- package/dist/state/storage-memory.js.map +1 -0
- package/dist/state/storage.d.ts +29 -0
- package/dist/state/storage.d.ts.map +1 -0
- package/dist/state/storage.js +175 -0
- package/dist/state/storage.js.map +1 -0
- package/dist/theme/index.d.ts +128 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +59 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/ui/ansi.d.ts +9 -0
- package/dist/ui/ansi.d.ts.map +1 -0
- package/dist/ui/ansi.js +78 -0
- package/dist/ui/ansi.js.map +1 -0
- package/dist/ui/components/FlowEdge.d.ts +5 -0
- package/dist/ui/components/FlowEdge.d.ts.map +1 -0
- package/dist/ui/components/FlowEdge.js +33 -0
- package/dist/ui/components/FlowEdge.js.map +1 -0
- package/dist/ui/components/FlowGraph.d.ts +10 -0
- package/dist/ui/components/FlowGraph.d.ts.map +1 -0
- package/dist/ui/components/FlowGraph.js +124 -0
- package/dist/ui/components/FlowGraph.js.map +1 -0
- package/dist/ui/components/FlowStatusBar.d.ts +7 -0
- package/dist/ui/components/FlowStatusBar.d.ts.map +1 -0
- package/dist/ui/components/FlowStatusBar.js +27 -0
- package/dist/ui/components/FlowStatusBar.js.map +1 -0
- package/dist/ui/components/MiniPipeline.d.ts +10 -0
- package/dist/ui/components/MiniPipeline.d.ts.map +1 -0
- package/dist/ui/components/MiniPipeline.js +155 -0
- package/dist/ui/components/MiniPipeline.js.map +1 -0
- package/dist/ui/components/NodeCard.d.ts +5 -0
- package/dist/ui/components/NodeCard.d.ts.map +1 -0
- package/dist/ui/components/NodeCard.js +39 -0
- package/dist/ui/components/NodeCard.js.map +1 -0
- package/dist/ui/components/NodeDetailPanel.d.ts +10 -0
- package/dist/ui/components/NodeDetailPanel.d.ts.map +1 -0
- package/dist/ui/components/NodeDetailPanel.js +38 -0
- package/dist/ui/components/NodeDetailPanel.js.map +1 -0
- package/dist/ui/components/node-panel/Controls.d.ts +16 -0
- package/dist/ui/components/node-panel/Controls.d.ts.map +1 -0
- package/dist/ui/components/node-panel/Controls.js +28 -0
- package/dist/ui/components/node-panel/Controls.js.map +1 -0
- package/dist/ui/components/node-panel/ErrorBar.d.ts +6 -0
- package/dist/ui/components/node-panel/ErrorBar.d.ts.map +1 -0
- package/dist/ui/components/node-panel/ErrorBar.js +14 -0
- package/dist/ui/components/node-panel/ErrorBar.js.map +1 -0
- package/dist/ui/components/node-panel/Gate.d.ts +13 -0
- package/dist/ui/components/node-panel/Gate.d.ts.map +1 -0
- package/dist/ui/components/node-panel/Gate.js +40 -0
- package/dist/ui/components/node-panel/Gate.js.map +1 -0
- package/dist/ui/components/node-panel/Header.d.ts +10 -0
- package/dist/ui/components/node-panel/Header.d.ts.map +1 -0
- package/dist/ui/components/node-panel/Header.js +19 -0
- package/dist/ui/components/node-panel/Header.js.map +1 -0
- package/dist/ui/components/node-panel/Info.d.ts +7 -0
- package/dist/ui/components/node-panel/Info.d.ts.map +1 -0
- package/dist/ui/components/node-panel/Info.js +23 -0
- package/dist/ui/components/node-panel/Info.js.map +1 -0
- package/dist/ui/components/node-panel/Output.d.ts +27 -0
- package/dist/ui/components/node-panel/Output.d.ts.map +1 -0
- package/dist/ui/components/node-panel/Output.js +66 -0
- package/dist/ui/components/node-panel/Output.js.map +1 -0
- package/dist/ui/components/node-panel/index.d.ts +47 -0
- package/dist/ui/components/node-panel/index.d.ts.map +1 -0
- package/dist/ui/components/node-panel/index.js +54 -0
- package/dist/ui/components/node-panel/index.js.map +1 -0
- package/dist/ui/components/node-panel/types.d.ts +23 -0
- package/dist/ui/components/node-panel/types.d.ts.map +1 -0
- package/dist/ui/components/node-panel/types.js +24 -0
- package/dist/ui/components/node-panel/types.js.map +1 -0
- package/dist/ui/core/components/Badge.d.ts +6 -0
- package/dist/ui/core/components/Badge.d.ts.map +1 -0
- package/dist/ui/core/components/Badge.js +11 -0
- package/dist/ui/core/components/Badge.js.map +1 -0
- package/dist/ui/core/components/Button.d.ts +9 -0
- package/dist/ui/core/components/Button.d.ts.map +1 -0
- package/dist/ui/core/components/Button.js +18 -0
- package/dist/ui/core/components/Button.js.map +1 -0
- package/dist/ui/core/components/ConfirmDialog.d.ts +11 -0
- package/dist/ui/core/components/ConfirmDialog.d.ts.map +1 -0
- package/dist/ui/core/components/ConfirmDialog.js +23 -0
- package/dist/ui/core/components/ConfirmDialog.js.map +1 -0
- package/dist/ui/core/components/ExecutionCard.d.ts +12 -0
- package/dist/ui/core/components/ExecutionCard.d.ts.map +1 -0
- package/dist/ui/core/components/ExecutionCard.js +15 -0
- package/dist/ui/core/components/ExecutionCard.js.map +1 -0
- package/dist/ui/core/components/NodeListItem.d.ts +10 -0
- package/dist/ui/core/components/NodeListItem.d.ts.map +1 -0
- package/dist/ui/core/components/NodeListItem.js +27 -0
- package/dist/ui/core/components/NodeListItem.js.map +1 -0
- package/dist/ui/core/components/PageHeader.d.ts +10 -0
- package/dist/ui/core/components/PageHeader.d.ts.map +1 -0
- package/dist/ui/core/components/PageHeader.js +9 -0
- package/dist/ui/core/components/PageHeader.js.map +1 -0
- package/dist/ui/core/components/SectionLabel.d.ts +6 -0
- package/dist/ui/core/components/SectionLabel.d.ts.map +1 -0
- package/dist/ui/core/components/SectionLabel.js +9 -0
- package/dist/ui/core/components/SectionLabel.js.map +1 -0
- package/dist/ui/core/components/Skeleton.d.ts +7 -0
- package/dist/ui/core/components/Skeleton.d.ts.map +1 -0
- package/dist/ui/core/components/Skeleton.js +26 -0
- package/dist/ui/core/components/Skeleton.js.map +1 -0
- package/dist/ui/core/components/Stat.d.ts +8 -0
- package/dist/ui/core/components/Stat.d.ts.map +1 -0
- package/dist/ui/core/components/Stat.js +9 -0
- package/dist/ui/core/components/Stat.js.map +1 -0
- package/dist/ui/core/components/Toast.d.ts +7 -0
- package/dist/ui/core/components/Toast.d.ts.map +1 -0
- package/dist/ui/core/components/Toast.js +28 -0
- package/dist/ui/core/components/Toast.js.map +1 -0
- package/dist/ui/core/components/__tests__/primitives.test.d.ts +2 -0
- package/dist/ui/core/components/__tests__/primitives.test.d.ts.map +1 -0
- package/dist/ui/core/components/__tests__/primitives.test.js +3 -0
- package/dist/ui/core/components/__tests__/primitives.test.js.map +1 -0
- package/dist/ui/core/components/index.d.ts +21 -0
- package/dist/ui/core/components/index.d.ts.map +1 -0
- package/dist/ui/core/components/index.js +24 -0
- package/dist/ui/core/components/index.js.map +1 -0
- package/dist/ui/core/index.d.ts +17 -0
- package/dist/ui/core/index.d.ts.map +1 -0
- package/dist/ui/core/index.js +56 -0
- package/dist/ui/core/index.js.map +1 -0
- package/dist/ui/core/utils.d.ts +6 -0
- package/dist/ui/core/utils.d.ts.map +1 -0
- package/dist/ui/core/utils.js +32 -0
- package/dist/ui/core/utils.js.map +1 -0
- package/dist/ui/graph/index.d.ts +4 -0
- package/dist/ui/graph/index.d.ts.map +1 -0
- package/dist/ui/graph/index.js +11 -0
- package/dist/ui/graph/index.js.map +1 -0
- package/dist/ui/hooks/useAutoSelectNode.d.ts +3 -0
- package/dist/ui/hooks/useAutoSelectNode.d.ts.map +1 -0
- package/dist/ui/hooks/useAutoSelectNode.js +36 -0
- package/dist/ui/hooks/useAutoSelectNode.js.map +1 -0
- package/dist/ui/hooks/useFlowExecution.d.ts +32 -0
- package/dist/ui/hooks/useFlowExecution.d.ts.map +1 -0
- package/dist/ui/hooks/useFlowExecution.js +113 -0
- package/dist/ui/hooks/useFlowExecution.js.map +1 -0
- package/dist/ui/hooks/useNodeNavigation.d.ts +3 -0
- package/dist/ui/hooks/useNodeNavigation.d.ts.map +1 -0
- package/dist/ui/hooks/useNodeNavigation.js +38 -0
- package/dist/ui/hooks/useNodeNavigation.js.map +1 -0
- package/dist/ui/hooks/useNodeOutput.d.ts +21 -0
- package/dist/ui/hooks/useNodeOutput.d.ts.map +1 -0
- package/dist/ui/hooks/useNodeOutput.js +75 -0
- package/dist/ui/hooks/useNodeOutput.js.map +1 -0
- package/dist/ui/index.d.ts +16 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +37 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/utils.d.ts +3 -0
- package/dist/ui/utils.d.ts.map +1 -0
- package/dist/ui/utils.js +9 -0
- package/dist/ui/utils.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent node factory — wraps an AgentRuntime session as a NodeFn.
|
|
3
|
+
*
|
|
4
|
+
* Lifecycle: delete stale artifact → setup → build prompt → create session →
|
|
5
|
+
* wire events → send prompt → await idle/error → read artifact → teardown.
|
|
6
|
+
*
|
|
7
|
+
* Implements GT-3 dual-condition crash recovery: if a session errors out but
|
|
8
|
+
* both a completion indicator was seen in output AND the artifact file exists
|
|
9
|
+
* on disk with real content, treat the run as successful.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentConfig, NodeFn } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Checks both conditions required to treat a crashed session as successful:
|
|
14
|
+
* 1. At least one completion indicator string appears in the output lines
|
|
15
|
+
* 2. The artifact file exists on disk with non-trivial content (> 10 chars)
|
|
16
|
+
*
|
|
17
|
+
* Both conditions must hold. Either alone produces false positives (GT-3).
|
|
18
|
+
*/
|
|
19
|
+
export declare function wasCompletedBeforeCrash(dir: string, outputFile: string, outputLines: readonly string[], indicators?: readonly string[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a NodeFn that manages a full agent session lifecycle.
|
|
22
|
+
*
|
|
23
|
+
* The returned function:
|
|
24
|
+
* 1. Deletes any stale artifact from a prior run
|
|
25
|
+
* 2. Calls config.setup(input) if provided (R5, R10)
|
|
26
|
+
* 3. Builds the prompt via config.promptBuilder(input)
|
|
27
|
+
* 4. Creates a session via ctx.runtime.createSession()
|
|
28
|
+
* 5. Wires session events to ctx.emitOutput for streaming
|
|
29
|
+
* 6. Sends the prompt and awaits completion (idle) or error
|
|
30
|
+
* 7. On error: attempts GT-3 crash recovery
|
|
31
|
+
* 8. On success: reads artifact, parses action
|
|
32
|
+
* 9. Calls config.teardown(input) in finally block
|
|
33
|
+
*/
|
|
34
|
+
export declare function agent(config: AgentConfig): NodeFn;
|
|
35
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,WAAW,EAGX,MAAM,EAIP,MAAM,SAAS,CAAC;AAcjB;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,GAC7B,OAAO,CAsBT;AAkBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAoKjD"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent node factory — wraps an AgentRuntime session as a NodeFn.
|
|
4
|
+
*
|
|
5
|
+
* Lifecycle: delete stale artifact → setup → build prompt → create session →
|
|
6
|
+
* wire events → send prompt → await idle/error → read artifact → teardown.
|
|
7
|
+
*
|
|
8
|
+
* Implements GT-3 dual-condition crash recovery: if a session errors out but
|
|
9
|
+
* both a completion indicator was seen in output AND the artifact file exists
|
|
10
|
+
* on disk with real content, treat the run as successful.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.wasCompletedBeforeCrash = wasCompletedBeforeCrash;
|
|
47
|
+
exports.agent = agent;
|
|
48
|
+
const fs = __importStar(require("node:fs"));
|
|
49
|
+
const path = __importStar(require("node:path"));
|
|
50
|
+
const types_1 = require("./types");
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// GT-3 dual-condition crash recovery helper
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
const DEFAULT_COMPLETION_INDICATORS = [
|
|
55
|
+
'Done.',
|
|
56
|
+
'completed',
|
|
57
|
+
'CONFIRMED',
|
|
58
|
+
'finished',
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* Checks both conditions required to treat a crashed session as successful:
|
|
62
|
+
* 1. At least one completion indicator string appears in the output lines
|
|
63
|
+
* 2. The artifact file exists on disk with non-trivial content (> 10 chars)
|
|
64
|
+
*
|
|
65
|
+
* Both conditions must hold. Either alone produces false positives (GT-3).
|
|
66
|
+
*/
|
|
67
|
+
function wasCompletedBeforeCrash(dir, outputFile, outputLines, indicators) {
|
|
68
|
+
const indicatorList = indicators ?? DEFAULT_COMPLETION_INDICATORS;
|
|
69
|
+
// Condition 1: any indicator found in any output line
|
|
70
|
+
const hasIndicator = outputLines.some((line) => indicatorList.some((ind) => line.includes(ind)));
|
|
71
|
+
// Condition 2: artifact exists with real content
|
|
72
|
+
let hasArtifact = false;
|
|
73
|
+
try {
|
|
74
|
+
const artifactPath = path.join(dir, outputFile);
|
|
75
|
+
if (fs.existsSync(artifactPath)) {
|
|
76
|
+
const content = fs.readFileSync(artifactPath, 'utf-8');
|
|
77
|
+
hasArtifact = content.trim().length > 10;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// File doesn't exist or can't be read
|
|
82
|
+
hasArtifact = false;
|
|
83
|
+
}
|
|
84
|
+
return hasIndicator && hasArtifact;
|
|
85
|
+
}
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
// Prompt formatting
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
function formatPrompt(promptOutput) {
|
|
90
|
+
if (typeof promptOutput === 'string') {
|
|
91
|
+
return promptOutput;
|
|
92
|
+
}
|
|
93
|
+
// Structured prompt: combine system + user with clear delimiters
|
|
94
|
+
return `${promptOutput.system}\n\n${promptOutput.user}`;
|
|
95
|
+
}
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Agent factory
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
/**
|
|
100
|
+
* Creates a NodeFn that manages a full agent session lifecycle.
|
|
101
|
+
*
|
|
102
|
+
* The returned function:
|
|
103
|
+
* 1. Deletes any stale artifact from a prior run
|
|
104
|
+
* 2. Calls config.setup(input) if provided (R5, R10)
|
|
105
|
+
* 3. Builds the prompt via config.promptBuilder(input)
|
|
106
|
+
* 4. Creates a session via ctx.runtime.createSession()
|
|
107
|
+
* 5. Wires session events to ctx.emitOutput for streaming
|
|
108
|
+
* 6. Sends the prompt and awaits completion (idle) or error
|
|
109
|
+
* 7. On error: attempts GT-3 crash recovery
|
|
110
|
+
* 8. On success: reads artifact, parses action
|
|
111
|
+
* 9. Calls config.teardown(input) in finally block
|
|
112
|
+
*/
|
|
113
|
+
function agent(config) {
|
|
114
|
+
return async (input, ctx) => {
|
|
115
|
+
// Abort check: bail early if already aborted
|
|
116
|
+
if (ctx.signal.aborted) {
|
|
117
|
+
throw new types_1.FlowAbortedError('Aborted before agent start');
|
|
118
|
+
}
|
|
119
|
+
// Step 1: Delete stale artifact
|
|
120
|
+
if (config.output) {
|
|
121
|
+
const artifactPath = path.join(input.dir, config.output);
|
|
122
|
+
try {
|
|
123
|
+
if (fs.existsSync(artifactPath)) {
|
|
124
|
+
fs.unlinkSync(artifactPath);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Ignore — may not exist
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// Step 2: Call setup hook (R5: runs before EVERY agent execution, R10: receives full NodeInput)
|
|
132
|
+
if (config.setup) {
|
|
133
|
+
await config.setup(input);
|
|
134
|
+
}
|
|
135
|
+
let session = null;
|
|
136
|
+
const outputLines = [];
|
|
137
|
+
try {
|
|
138
|
+
// Step 3: Build prompt
|
|
139
|
+
const promptOutput = config.promptBuilder(input);
|
|
140
|
+
const promptStr = formatPrompt(promptOutput);
|
|
141
|
+
// Step 4: Create session (COMP-3: cwdResolver overrides cwd for repo access)
|
|
142
|
+
const sessionCwd = config.cwdResolver ? config.cwdResolver(input) : input.dir;
|
|
143
|
+
session = await ctx.runtime.createSession({
|
|
144
|
+
model: config.model ?? 'claude-opus-4.6',
|
|
145
|
+
cwd: sessionCwd,
|
|
146
|
+
addDirs: config.isolation ? [] : [input.dir],
|
|
147
|
+
timeout: config.timeout ?? 3600,
|
|
148
|
+
heartbeatTimeout: config.heartbeatTimeout ?? 120,
|
|
149
|
+
});
|
|
150
|
+
// Abort check after session creation
|
|
151
|
+
if (ctx.signal.aborted) {
|
|
152
|
+
await session.abort();
|
|
153
|
+
throw new types_1.FlowAbortedError('Aborted after session creation');
|
|
154
|
+
}
|
|
155
|
+
// Step 5: Wire session events to emitOutput
|
|
156
|
+
session.on('text', (text) => {
|
|
157
|
+
outputLines.push(text);
|
|
158
|
+
ctx.emitOutput({
|
|
159
|
+
type: 'node:output',
|
|
160
|
+
executionId: ctx.executionId,
|
|
161
|
+
nodeId: ctx.nodeId,
|
|
162
|
+
content: text,
|
|
163
|
+
ts: Date.now(),
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
session.on('tool_start', (tool, toolInput) => {
|
|
167
|
+
ctx.emitOutput({
|
|
168
|
+
type: 'node:tool',
|
|
169
|
+
executionId: ctx.executionId,
|
|
170
|
+
nodeId: ctx.nodeId,
|
|
171
|
+
tool,
|
|
172
|
+
phase: 'start',
|
|
173
|
+
summary: toolInput.substring(0, 200),
|
|
174
|
+
ts: Date.now(),
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
session.on('tool_complete', (tool, output) => {
|
|
178
|
+
ctx.emitOutput({
|
|
179
|
+
type: 'node:tool',
|
|
180
|
+
executionId: ctx.executionId,
|
|
181
|
+
nodeId: ctx.nodeId,
|
|
182
|
+
tool,
|
|
183
|
+
phase: 'complete',
|
|
184
|
+
summary: output.substring(0, 200),
|
|
185
|
+
ts: Date.now(),
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
// Step 6: Send prompt
|
|
189
|
+
session.send(promptStr);
|
|
190
|
+
// Step 7: Wait for completion — wrap in a Promise that resolves on idle, rejects on error
|
|
191
|
+
const result = await new Promise((resolve, reject) => {
|
|
192
|
+
// Listen for abort signal during session execution
|
|
193
|
+
const onAbort = () => {
|
|
194
|
+
session.abort().then(() => reject(new types_1.FlowAbortedError('Aborted during session execution')), () => reject(new types_1.FlowAbortedError('Aborted during session execution')));
|
|
195
|
+
};
|
|
196
|
+
ctx.signal.addEventListener('abort', onAbort, { once: true });
|
|
197
|
+
session.on('idle', () => {
|
|
198
|
+
ctx.signal.removeEventListener('abort', onAbort);
|
|
199
|
+
resolve('idle');
|
|
200
|
+
});
|
|
201
|
+
session.on('error', (err) => {
|
|
202
|
+
ctx.signal.removeEventListener('abort', onAbort);
|
|
203
|
+
reject(err);
|
|
204
|
+
});
|
|
205
|
+
}).catch((err) => {
|
|
206
|
+
// AI-4: Don't attempt GT-3 recovery on aborted sessions
|
|
207
|
+
if (ctx.signal.aborted) {
|
|
208
|
+
throw err;
|
|
209
|
+
}
|
|
210
|
+
// Step 8: GT-3 dual-condition crash recovery
|
|
211
|
+
if (config.output &&
|
|
212
|
+
wasCompletedBeforeCrash(input.dir, config.output, outputLines, config.completionIndicators)) {
|
|
213
|
+
// Treat as success — artifact was written before crash
|
|
214
|
+
return 'recovered';
|
|
215
|
+
}
|
|
216
|
+
throw err;
|
|
217
|
+
});
|
|
218
|
+
// Step 9: Handle success (idle or recovered)
|
|
219
|
+
let content;
|
|
220
|
+
if (config.output) {
|
|
221
|
+
const artifactPath = path.join(input.dir, config.output);
|
|
222
|
+
try {
|
|
223
|
+
content = fs.readFileSync(artifactPath, 'utf-8');
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Artifact not written — that's fine for nodes that don't always produce output
|
|
227
|
+
content = undefined;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const action = config.actionParser && content
|
|
231
|
+
? config.actionParser(content)
|
|
232
|
+
: 'default';
|
|
233
|
+
return { action, artifact: content };
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
// AI-1: Close session on all paths (abort is idempotent)
|
|
237
|
+
if (session) {
|
|
238
|
+
try {
|
|
239
|
+
await session.abort();
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
// Session may already be closed — ignore
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// Step 10: Teardown (always runs, R10: receives full NodeInput)
|
|
246
|
+
if (config.teardown) {
|
|
247
|
+
try {
|
|
248
|
+
await config.teardown(input);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
// Teardown errors should not mask the primary error
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCH,0DA2BC;AAgCD,sBAoKC;AA9PD,4CAA8B;AAC9B,gDAAkC;AAUlC,mCAA2C;AAE3C,8EAA8E;AAC9E,4CAA4C;AAC5C,8EAA8E;AAE9E,MAAM,6BAA6B,GAAsB;IACvD,OAAO;IACP,WAAW;IACX,WAAW;IACX,UAAU;CACX,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,GAAW,EACX,UAAkB,EAClB,WAA8B,EAC9B,UAA8B;IAE9B,MAAM,aAAa,GAAG,UAAU,IAAI,6BAA6B,CAAC;IAElE,sDAAsD;IACtD,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAC7C,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAChD,CAAC;IAEF,iDAAiD;IACjD,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAChD,IAAI,EAAE,CAAC,UAAU,CAAC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AM,EAAE,CAAC;gBAClB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACzD,IAAI,CAAC;oBACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;gBACnD,CAAC;gBAAC,MAAM,CAAC;oBACP,gFAAgF;oBAChF,OAAO,GAAG,SAAS,CAAC;gBACtB,CAAC;YACH,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,IAAI,OAAO;gBAC3C,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC;gBAC9B,CAAC,CAAC,SAAS,CAAC;YAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;QACvC,CAAC;gBAAS,CAAC;YACT,yDAAyD;YACzD,IAAI,OAAO,EAAE,CAAC;gBACZ,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,yCAAyC;gBAC3C,CAAC;YACH,CAAC;YACD,gEAAgE;YAChE,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACpB,IAAI,CAAC;oBACH,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAC/B,CAAC;gBAAC,MAAM,CAAC;oBACP,oDAAoD;gBACtD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow framework events — the complete event contract.
|
|
3
|
+
*
|
|
4
|
+
* 15 execution events (persisted to JSONL event log).
|
|
5
|
+
* 2 output events (streamed, not persisted in event log).
|
|
6
|
+
*
|
|
7
|
+
* All events carry executionId + ts. Zero domain types.
|
|
8
|
+
*/
|
|
9
|
+
export interface GraphNodeSkeleton {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly displayName: string;
|
|
12
|
+
readonly nodeType: string;
|
|
13
|
+
readonly model?: string;
|
|
14
|
+
readonly output?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface GraphEdgeSkeleton {
|
|
17
|
+
readonly source: string;
|
|
18
|
+
readonly action: string;
|
|
19
|
+
readonly target: string;
|
|
20
|
+
}
|
|
21
|
+
export interface RunStartedEvent {
|
|
22
|
+
readonly type: 'run:started';
|
|
23
|
+
readonly executionId: string;
|
|
24
|
+
readonly flowId: string;
|
|
25
|
+
readonly params: Record<string, unknown>;
|
|
26
|
+
readonly graph: {
|
|
27
|
+
readonly nodes: readonly GraphNodeSkeleton[];
|
|
28
|
+
readonly edges: readonly GraphEdgeSkeleton[];
|
|
29
|
+
};
|
|
30
|
+
readonly ts: number;
|
|
31
|
+
}
|
|
32
|
+
export interface RunCompletedEvent {
|
|
33
|
+
readonly type: 'run:completed';
|
|
34
|
+
readonly executionId: string;
|
|
35
|
+
readonly status: 'completed' | 'failed' | 'stopped' | 'crashed';
|
|
36
|
+
readonly ts: number;
|
|
37
|
+
}
|
|
38
|
+
export interface RunResumedEvent {
|
|
39
|
+
readonly type: 'run:resumed';
|
|
40
|
+
readonly executionId: string;
|
|
41
|
+
readonly resumingFrom: readonly string[];
|
|
42
|
+
readonly ts: number;
|
|
43
|
+
}
|
|
44
|
+
export interface NodeStartedEvent {
|
|
45
|
+
readonly type: 'node:started';
|
|
46
|
+
readonly executionId: string;
|
|
47
|
+
readonly nodeId: string;
|
|
48
|
+
readonly ts: number;
|
|
49
|
+
}
|
|
50
|
+
export interface NodeCompletedEvent {
|
|
51
|
+
readonly type: 'node:completed';
|
|
52
|
+
readonly executionId: string;
|
|
53
|
+
readonly nodeId: string;
|
|
54
|
+
readonly action: string;
|
|
55
|
+
readonly elapsedMs: number;
|
|
56
|
+
readonly ts: number;
|
|
57
|
+
}
|
|
58
|
+
export interface NodeFailedEvent {
|
|
59
|
+
readonly type: 'node:failed';
|
|
60
|
+
readonly executionId: string;
|
|
61
|
+
readonly nodeId: string;
|
|
62
|
+
readonly error: string;
|
|
63
|
+
readonly ts: number;
|
|
64
|
+
}
|
|
65
|
+
export interface NodeKilledEvent {
|
|
66
|
+
readonly type: 'node:killed';
|
|
67
|
+
readonly executionId: string;
|
|
68
|
+
readonly nodeId: string;
|
|
69
|
+
readonly ts: number;
|
|
70
|
+
}
|
|
71
|
+
export interface NodeSkippedEvent {
|
|
72
|
+
readonly type: 'node:skipped';
|
|
73
|
+
readonly executionId: string;
|
|
74
|
+
readonly nodeId: string;
|
|
75
|
+
readonly ts: number;
|
|
76
|
+
}
|
|
77
|
+
export interface NodeGatedEvent {
|
|
78
|
+
readonly type: 'node:gated';
|
|
79
|
+
readonly executionId: string;
|
|
80
|
+
readonly nodeId: string;
|
|
81
|
+
readonly gateType: string;
|
|
82
|
+
readonly gateData?: Record<string, unknown>;
|
|
83
|
+
readonly ts: number;
|
|
84
|
+
}
|
|
85
|
+
export interface GateResolvedEvent {
|
|
86
|
+
readonly type: 'gate:resolved';
|
|
87
|
+
readonly executionId: string;
|
|
88
|
+
readonly nodeId: string;
|
|
89
|
+
readonly resolution: string;
|
|
90
|
+
readonly reason?: string;
|
|
91
|
+
readonly ts: number;
|
|
92
|
+
}
|
|
93
|
+
export interface NodeRetryingEvent {
|
|
94
|
+
readonly type: 'node:retrying';
|
|
95
|
+
readonly executionId: string;
|
|
96
|
+
readonly nodeId: string;
|
|
97
|
+
readonly attempt: number;
|
|
98
|
+
readonly override?: string;
|
|
99
|
+
readonly ts: number;
|
|
100
|
+
}
|
|
101
|
+
export interface EdgeTraversedEvent {
|
|
102
|
+
readonly type: 'edge:traversed';
|
|
103
|
+
readonly executionId: string;
|
|
104
|
+
readonly source: string;
|
|
105
|
+
readonly target: string;
|
|
106
|
+
readonly action: string;
|
|
107
|
+
readonly ts: number;
|
|
108
|
+
}
|
|
109
|
+
export interface ArtifactWrittenEvent {
|
|
110
|
+
readonly type: 'artifact:written';
|
|
111
|
+
readonly executionId: string;
|
|
112
|
+
readonly nodeId: string;
|
|
113
|
+
readonly path: string;
|
|
114
|
+
readonly size: number;
|
|
115
|
+
readonly ts: number;
|
|
116
|
+
}
|
|
117
|
+
export interface CostRecordedEvent {
|
|
118
|
+
readonly type: 'cost:recorded';
|
|
119
|
+
readonly executionId: string;
|
|
120
|
+
readonly nodeId: string;
|
|
121
|
+
readonly tokens: number;
|
|
122
|
+
readonly model: string;
|
|
123
|
+
readonly cost: number;
|
|
124
|
+
readonly ts: number;
|
|
125
|
+
}
|
|
126
|
+
export interface MetadataEvent {
|
|
127
|
+
readonly type: 'metadata';
|
|
128
|
+
readonly executionId: string;
|
|
129
|
+
readonly key: string;
|
|
130
|
+
readonly value: unknown;
|
|
131
|
+
readonly ts: number;
|
|
132
|
+
}
|
|
133
|
+
/** Discriminated union of all execution events (persisted to JSONL). */
|
|
134
|
+
export type ExecutionEvent = RunStartedEvent | RunCompletedEvent | RunResumedEvent | NodeStartedEvent | NodeCompletedEvent | NodeFailedEvent | NodeKilledEvent | NodeSkippedEvent | NodeGatedEvent | GateResolvedEvent | NodeRetryingEvent | EdgeTraversedEvent | ArtifactWrittenEvent | CostRecordedEvent | MetadataEvent;
|
|
135
|
+
export interface NodeOutputEvent {
|
|
136
|
+
readonly type: 'node:output';
|
|
137
|
+
readonly executionId: string;
|
|
138
|
+
readonly nodeId: string;
|
|
139
|
+
readonly content: string;
|
|
140
|
+
readonly ts: number;
|
|
141
|
+
}
|
|
142
|
+
export interface NodeToolEvent {
|
|
143
|
+
readonly type: 'node:tool';
|
|
144
|
+
readonly executionId: string;
|
|
145
|
+
readonly nodeId: string;
|
|
146
|
+
readonly tool: string;
|
|
147
|
+
readonly phase: 'start' | 'complete';
|
|
148
|
+
readonly summary: string;
|
|
149
|
+
readonly ts: number;
|
|
150
|
+
}
|
|
151
|
+
/** Discriminated union of output events (streamed, not persisted). */
|
|
152
|
+
export type OutputEvent = NodeOutputEvent | NodeToolEvent;
|
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BAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GACjB,aAAa,CAAC;AAMlB,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,sEAAsE;AACtE,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Flow framework events — the complete event contract.
|
|
4
|
+
*
|
|
5
|
+
* 15 execution events (persisted to JSONL event log).
|
|
6
|
+
* 2 output events (streamed, not persisted in event log).
|
|
7
|
+
*
|
|
8
|
+
* All events carry executionId + ts. Zero domain types.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { run, computeFrontier, validateGraph } from './scheduler';
|
|
2
|
+
export { agent, wasCompletedBeforeCrash } from './agent';
|
|
3
|
+
export { deterministic, gate, resolveGate, _getGateRegistryForTesting } from './nodes';
|
|
4
|
+
export { verify, property } from './verify';
|
|
5
|
+
export type { NodeFn, NodeInput, NodeOutput, RetryContext, ExecutionContext, FlowGraph, NodeEntry, RunOptions, RunResult, ResumeState, AgentRuntime, AgentSession, SessionConfig, ToolRef, AgentConfig, PromptOutput, ExecutionProjection, ProjectionNode, ProjectionEdge, StorageEngine, OutputPage, ExecutionId, } from './types';
|
|
6
|
+
export { getParams, FlowAbortedError, FlowValidationError } from './types';
|
|
7
|
+
export type { ExecutionEvent, OutputEvent, RunStartedEvent, RunCompletedEvent, RunResumedEvent, NodeStartedEvent, NodeCompletedEvent, NodeFailedEvent, NodeKilledEvent, NodeSkippedEvent, NodeGatedEvent, GateResolvedEvent, NodeRetryingEvent, EdgeTraversedEvent, ArtifactWrittenEvent, CostRecordedEvent, MetadataEvent, NodeOutputEvent, NodeToolEvent, GraphNodeSkeleton, GraphEdgeSkeleton, } from './events';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAG5C,YAAY,EACV,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAC7D,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,SAAS,EAAE,WAAW,EAClC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAC7E,mBAAmB,EAAE,cAAc,EAAE,cAAc,EACnD,aAAa,EAAE,UAAU,EACzB,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAG3E,YAAY,EACV,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,iBAAiB,EAAE,eAAe,EACnD,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EACrD,eAAe,EAAE,gBAAgB,EAAE,cAAc,EACjD,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EACxD,oBAAoB,EAAE,iBAAiB,EAAE,aAAa,EACtD,eAAe,EAAE,aAAa,EAC9B,iBAAiB,EAAE,iBAAiB,GACrC,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowValidationError = exports.FlowAbortedError = exports.getParams = exports.property = exports.verify = exports._getGateRegistryForTesting = exports.resolveGate = exports.gate = exports.deterministic = exports.wasCompletedBeforeCrash = exports.agent = exports.validateGraph = exports.computeFrontier = exports.run = void 0;
|
|
4
|
+
// Execution (scheduler + node factories)
|
|
5
|
+
var scheduler_1 = require("./scheduler");
|
|
6
|
+
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return scheduler_1.run; } });
|
|
7
|
+
Object.defineProperty(exports, "computeFrontier", { enumerable: true, get: function () { return scheduler_1.computeFrontier; } });
|
|
8
|
+
Object.defineProperty(exports, "validateGraph", { enumerable: true, get: function () { return scheduler_1.validateGraph; } });
|
|
9
|
+
var agent_1 = require("./agent");
|
|
10
|
+
Object.defineProperty(exports, "agent", { enumerable: true, get: function () { return agent_1.agent; } });
|
|
11
|
+
Object.defineProperty(exports, "wasCompletedBeforeCrash", { enumerable: true, get: function () { return agent_1.wasCompletedBeforeCrash; } });
|
|
12
|
+
var nodes_1 = require("./nodes");
|
|
13
|
+
Object.defineProperty(exports, "deterministic", { enumerable: true, get: function () { return nodes_1.deterministic; } });
|
|
14
|
+
Object.defineProperty(exports, "gate", { enumerable: true, get: function () { return nodes_1.gate; } });
|
|
15
|
+
Object.defineProperty(exports, "resolveGate", { enumerable: true, get: function () { return nodes_1.resolveGate; } });
|
|
16
|
+
Object.defineProperty(exports, "_getGateRegistryForTesting", { enumerable: true, get: function () { return nodes_1._getGateRegistryForTesting; } });
|
|
17
|
+
var verify_1 = require("./verify");
|
|
18
|
+
Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return verify_1.verify; } });
|
|
19
|
+
Object.defineProperty(exports, "property", { enumerable: true, get: function () { return verify_1.property; } });
|
|
20
|
+
var types_1 = require("./types");
|
|
21
|
+
Object.defineProperty(exports, "getParams", { enumerable: true, get: function () { return types_1.getParams; } });
|
|
22
|
+
Object.defineProperty(exports, "FlowAbortedError", { enumerable: true, get: function () { return types_1.FlowAbortedError; } });
|
|
23
|
+
Object.defineProperty(exports, "FlowValidationError", { enumerable: true, get: function () { return types_1.FlowValidationError; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,yCAAkE;AAAzD,gGAAA,GAAG,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,0GAAA,aAAa,OAAA;AAC5C,iCAAyD;AAAhD,8FAAA,KAAK,OAAA;AAAE,gHAAA,uBAAuB,OAAA;AACvC,iCAAuF;AAA9E,sGAAA,aAAa,OAAA;AAAE,6FAAA,IAAI,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,mHAAA,0BAA0B,OAAA;AACrE,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAazB,iCAA2E;AAAlE,kGAAA,SAAS,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,4GAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-agent node factories: deterministic() and gate().
|
|
3
|
+
*
|
|
4
|
+
* deterministic() — wraps a pure function as a NodeFn (ignores ExecutionContext).
|
|
5
|
+
* gate() — returns a blocking NodeFn resolved externally via resolveGate().
|
|
6
|
+
*
|
|
7
|
+
* Gate mechanism:
|
|
8
|
+
* 1. gate() creates a Promise + resolver, stores in module-level gateRegistry
|
|
9
|
+
* 2. The scheduler dispatches the gate node; it blocks on the Promise
|
|
10
|
+
* 3. External code (bridge/API) calls resolveGate() to unblock
|
|
11
|
+
* 4. The scheduler sees the gate complete normally and proceeds
|
|
12
|
+
*
|
|
13
|
+
* Gate nodes listen for abort signals so they can be cleanly cancelled.
|
|
14
|
+
* The gate registry is module-level (survives across requests but not restarts).
|
|
15
|
+
* Restart recovery: the scheduler re-dispatches gate nodes, creating fresh resolvers (CR4).
|
|
16
|
+
*/
|
|
17
|
+
import type { NodeFn, NodeInput, NodeOutput } from './types';
|
|
18
|
+
/**
|
|
19
|
+
* Wraps a pure async function as a NodeFn.
|
|
20
|
+
* The ExecutionContext is available but typically unused — deterministic nodes
|
|
21
|
+
* don't need runtime services or streaming output.
|
|
22
|
+
*
|
|
23
|
+
* @param _name - Display name (used for logging/debugging, not stored here)
|
|
24
|
+
* @param fn - The computation. Receives NodeInput, returns NodeOutput.
|
|
25
|
+
*/
|
|
26
|
+
export declare function deterministic(_name: string, fn: (input: NodeInput) => Promise<NodeOutput>): NodeFn;
|
|
27
|
+
interface GateEntry {
|
|
28
|
+
resolve: (output: NodeOutput) => void;
|
|
29
|
+
reject: (err: Error) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Expose the registry for testing purposes only.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function _getGateRegistryForTesting(): Map<string, GateEntry>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a NodeFn that blocks until externally resolved via resolveGate().
|
|
38
|
+
*
|
|
39
|
+
* The gate:
|
|
40
|
+
* - Registers a Promise resolver in the module-level gateRegistry
|
|
41
|
+
* - Blocks (awaits the Promise) until resolveGate() is called
|
|
42
|
+
* - Listens for abort signal to clean up on cancellation
|
|
43
|
+
* - Returns { action: resolution } when resolved (e.g., 'approved', 'rejected')
|
|
44
|
+
*
|
|
45
|
+
* The scheduler emits node:gated after dispatching gate-type nodes.
|
|
46
|
+
* The bridge emits gate:resolved when calling resolveGate().
|
|
47
|
+
*
|
|
48
|
+
* @param name - Optional gate type name (e.g., 'approval', 'quality-review').
|
|
49
|
+
* Used by the scheduler for the node:gated event's gateType field.
|
|
50
|
+
*/
|
|
51
|
+
export declare function gate(name?: string): NodeFn;
|
|
52
|
+
/**
|
|
53
|
+
* Resolves a waiting gate node, unblocking the scheduler.
|
|
54
|
+
*
|
|
55
|
+
* @param executionId - The execution containing the gate
|
|
56
|
+
* @param nodeId - The gate node's ID
|
|
57
|
+
* @param resolution - The action string (e.g., 'approved', 'rejected')
|
|
58
|
+
* @param _reason - Optional human-readable reason (for audit, not used in output)
|
|
59
|
+
* @returns true if the gate was found and resolved, false otherwise
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveGate(executionId: string, nodeId: string, resolution: string, _reason?: string): boolean;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAEV,MAAM,EACN,SAAS,EACT,UAAU,EACX,MAAM,SAAS,CAAC;AAOjB;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,UAAU,CAAC,GAC5C,MAAM,CAIR;AAMD,UAAU,SAAS;IACjB,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;CAC9B;AAaD;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAEnE;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CA0B1C;AAMD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAWT"}
|