condukt 0.6.21 → 0.7.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/README.md CHANGED
@@ -140,9 +140,44 @@ condukt is split into sub-path exports so you only pull in what you need.
140
140
  - **Fan-out** — one node fans out to multiple parallel branches
141
141
  - **Fan-in** — multiple branches converge into a single node (waits for all)
142
142
  - **Loop-back** — edges that point backward with `maxIterations` bounds and `loopFallback` strategy
143
+ - **Loop regions** — bounded multi-node producer/critic/refinement loops with an explicit entry and decision node
143
144
  - **Per-node timeout** — individual deadline per node
144
145
  - **Abort / Resume** — stop mid-execution and pick up where you left off
145
146
 
147
+ ### Multi-node loop regions
148
+
149
+ Declare a `LoopRegion` alongside the graph. The decision node's `continueOn` action resets only the declared region and re-dispatches its entry. Its `exitOn` action follows the normal graph edge.
150
+
151
+ ```typescript
152
+ import type { FlowGraph, LoopRegion } from 'condukt';
153
+
154
+ const reviewLoop: LoopRegion = {
155
+ id: 'review-loop',
156
+ nodes: ['producer', 'critic', 'refine'],
157
+ entry: 'producer',
158
+ decision: 'refine',
159
+ continueOn: 'revise',
160
+ exitOn: 'accepted',
161
+ maxIterations: 3,
162
+ onExhausted: 'manualReview',
163
+ feedback: (decisionOutput, iteration) =>
164
+ `Round ${iteration}: ${decisionOutput ?? 'revise the prior output'}`,
165
+ };
166
+
167
+ const graph: FlowGraph = {
168
+ nodes: { producer, critic, refine, done, manualReview },
169
+ edges: {
170
+ producer: { default: 'critic' },
171
+ critic: { default: 'refine' },
172
+ refine: { revise: 'producer', accepted: 'done' },
173
+ },
174
+ start: ['producer'],
175
+ loops: [reviewLoop],
176
+ };
177
+ ```
178
+
179
+ External fan-in contributions to region nodes are preserved across resets. Fired contributions from predecessors inside the region are cleared and rebuilt by the next iteration.
180
+
146
181
  ## UI components
147
182
 
148
183
  The UI layer is a complete React component library with a warm charcoal dark theme.
@@ -7,39 +7,42 @@
7
7
  */
8
8
  import type { AgentRuntime, AgentSession, SessionConfig } from '../../src/types';
9
9
  export interface MockNodeConfig {
10
- /** Text lines to emit (each becomes a 'text' event). */
11
- text?: string[];
10
+ /** Text lines to emit, or one text value per send. */
11
+ readonly text?: readonly string[] | readonly (readonly string[])[];
12
12
  /** Reasoning lines to emit (each becomes a 'reasoning' event, emitted before text). */
13
- reasoning?: string[];
13
+ readonly reasoning?: readonly string[];
14
14
  /** Tool call sequence to emit as tool_start / tool_complete pairs. */
15
- tools?: Array<{
16
- name: string;
17
- input: string;
18
- output: string;
15
+ readonly tools?: ReadonlyArray<{
16
+ readonly name: string;
17
+ readonly input: string;
18
+ readonly output: string;
19
19
  }>;
20
- /** Artifact content to write to `<cwd>/<artifactFilename>` (if provided). */
21
- artifact?: string;
20
+ /** Artifact content to write, or one artifact value per send. */
21
+ readonly artifact?: string | readonly string[];
22
+ /** Override the SessionConfig-derived artifact filename. */
23
+ readonly artifactFilename?: string;
22
24
  /** If provided, emit this error instead of idle. */
23
- error?: Error;
25
+ readonly error?: Error;
24
26
  /** Delay in milliseconds before emitting events (simulates work). */
25
- delay?: number;
27
+ readonly delay?: number;
26
28
  }
27
29
  /**
28
30
  * A deterministic mock runtime that replays configured events per node.
29
31
  *
30
- * The node is identified by the `cwd` basename of the SessionConfig —
31
- * this maps to how the scheduler sets `cwd` to include the node directory.
32
- * Alternatively, callers can provide a `nodeResolver` function to map
33
- * SessionConfig to a config key.
32
+ * The node is identified by `SessionConfig.nodeId` when provided, falling back
33
+ * to the `cwd` basename for callers that create sessions directly. Callers can
34
+ * also provide a `nodeResolver` function to map SessionConfig to a config key.
34
35
  */
35
36
  export declare class MockRuntime implements AgentRuntime {
36
37
  readonly name = "mock";
37
38
  private readonly configs;
38
39
  private readonly nodeResolver;
39
- constructor(configs: Record<string, MockNodeConfig>, options?: {
40
- nodeResolver?: (config: SessionConfig) => string;
40
+ private readonly responseIndexes;
41
+ constructor(configs: Readonly<Record<string, MockNodeConfig>>, options?: {
42
+ readonly nodeResolver?: (config: SessionConfig) => string;
41
43
  });
42
44
  isAvailable(): Promise<boolean>;
43
45
  createSession(config: SessionConfig): Promise<AgentSession>;
46
+ private claimResponseIndex;
44
47
  }
45
48
  //# sourceMappingURL=mock-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock-runtime.d.ts","sourceRoot":"","sources":["../../../runtimes/mock/mock-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIjF,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,sEAAsE;IACtE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/D,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAWD;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,YAAY;IAC9C,QAAQ,CAAC,IAAI,UAAU;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoC;gBAG/D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EACvC,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM,CAAA;KAAE;IAM1D,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;C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EAAE;QAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM,CAAA;KAAE;IAOnE,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAkBjE,OAAO,CAAC,kBAAkB;CAK3B"}
@@ -43,21 +43,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.MockRuntime = void 0;
44
44
  const fs = __importStar(require("fs"));
45
45
  const path = __importStar(require("path"));
46
+ function sequenceValue(values, index) {
47
+ if (values.length === 0)
48
+ return undefined;
49
+ return values[Math.min(index, values.length - 1)];
50
+ }
51
+ function resolveText(configured, responseIndex) {
52
+ if (!configured)
53
+ return [];
54
+ const arrayCount = configured.filter((value) => Array.isArray(value)).length;
55
+ if (arrayCount > 0 && arrayCount < configured.length) {
56
+ throw new Error('MockNodeConfig.text must be string[] (one response) or string[][] (per-send), not mixed');
57
+ }
58
+ if (arrayCount === configured.length && configured.length > 0) {
59
+ return sequenceValue(configured, responseIndex) ?? [];
60
+ }
61
+ return configured;
62
+ }
63
+ function resolveArtifact(configured, responseIndex) {
64
+ if (configured === undefined || typeof configured === 'string')
65
+ return configured;
66
+ return sequenceValue(configured, responseIndex);
67
+ }
46
68
  /**
47
69
  * A deterministic mock runtime that replays configured events per node.
48
70
  *
49
- * The node is identified by the `cwd` basename of the SessionConfig —
50
- * this maps to how the scheduler sets `cwd` to include the node directory.
51
- * Alternatively, callers can provide a `nodeResolver` function to map
52
- * SessionConfig to a config key.
71
+ * The node is identified by `SessionConfig.nodeId` when provided, falling back
72
+ * to the `cwd` basename for callers that create sessions directly. Callers can
73
+ * also provide a `nodeResolver` function to map SessionConfig to a config key.
53
74
  */
54
75
  class MockRuntime {
55
76
  name = 'mock';
56
77
  configs;
57
78
  nodeResolver;
79
+ responseIndexes = new Map();
58
80
  constructor(configs, options) {
59
81
  this.configs = configs;
60
- this.nodeResolver = options?.nodeResolver ?? ((config) => path.basename(config.cwd));
82
+ this.nodeResolver = options?.nodeResolver
83
+ ?? ((config) => config.nodeId ?? path.basename(config.cwd));
61
84
  }
62
85
  async isAvailable() {
63
86
  return true;
@@ -65,7 +88,19 @@ class MockRuntime {
65
88
  async createSession(config) {
66
89
  const nodeKey = this.nodeResolver(config);
67
90
  const nodeConfig = this.configs[nodeKey] ?? {};
68
- return new MockAgentSession(nodeConfig, config.cwd);
91
+ // Parity: the node's real configured output (SessionConfig.artifactFilename,
92
+ // set by agent() from config.output) wins so the mock writes where the node
93
+ // actually reads. nodeConfig.artifactFilename is only an override for tests
94
+ // driving MockRuntime directly (no SessionConfig filename present).
95
+ const artifactFilename = config.artifactFilename
96
+ ?? nodeConfig.artifactFilename
97
+ ?? 'output.md';
98
+ return new MockAgentSession(nodeConfig, config.cwd, artifactFilename, () => this.claimResponseIndex(nodeKey));
99
+ }
100
+ claimResponseIndex(nodeKey) {
101
+ const index = this.responseIndexes.get(nodeKey) ?? 0;
102
+ this.responseIndexes.set(nodeKey, index + 1);
103
+ return index;
69
104
  }
70
105
  }
71
106
  exports.MockRuntime = MockRuntime;
@@ -74,14 +109,19 @@ class MockAgentSession {
74
109
  handlers = [];
75
110
  nodeConfig;
76
111
  cwd;
112
+ artifactFilename;
113
+ claimResponseIndex;
77
114
  aborted = false;
78
115
  timer = null;
79
- constructor(nodeConfig, cwd) {
116
+ constructor(nodeConfig, cwd, artifactFilename, claimResponseIndex) {
80
117
  this.nodeConfig = nodeConfig;
81
118
  this.cwd = cwd;
119
+ this.artifactFilename = artifactFilename;
120
+ this.claimResponseIndex = claimResponseIndex;
82
121
  }
83
122
  send(_prompt) {
84
123
  const delay = this.nodeConfig.delay ?? 0;
124
+ const responseIndex = this.claimResponseIndex();
85
125
  const execute = () => {
86
126
  if (this.aborted)
87
127
  return;
@@ -94,12 +134,11 @@ class MockAgentSession {
94
134
  }
95
135
  }
96
136
  // Emit text events
97
- if (this.nodeConfig.text) {
98
- for (const line of this.nodeConfig.text) {
99
- if (this.aborted)
100
- return;
101
- this.emit('text', line);
102
- }
137
+ const text = resolveText(this.nodeConfig.text, responseIndex);
138
+ for (const line of text) {
139
+ if (this.aborted)
140
+ return;
141
+ this.emit('text', line);
103
142
  }
104
143
  // Emit tool events
105
144
  if (this.nodeConfig.tools) {
@@ -111,15 +150,16 @@ class MockAgentSession {
111
150
  }
112
151
  }
113
152
  // Write artifact if configured
114
- if (this.nodeConfig.artifact !== undefined) {
153
+ const artifact = resolveArtifact(this.nodeConfig.artifact, responseIndex);
154
+ if (artifact !== undefined) {
115
155
  try {
116
- // Write the artifact content to a file named 'output.md' in cwd
117
- const artifactPath = path.join(this.cwd, 'output.md');
118
- fs.mkdirSync(this.cwd, { recursive: true });
119
- fs.writeFileSync(artifactPath, this.nodeConfig.artifact, 'utf-8');
156
+ const artifactPath = path.join(this.cwd, this.artifactFilename);
157
+ fs.mkdirSync(path.dirname(artifactPath), { recursive: true });
158
+ fs.writeFileSync(artifactPath, artifact, 'utf-8');
120
159
  }
121
- catch {
122
- // Best effort test may not have a writable cwd
160
+ catch (error) {
161
+ this.emit('error', error instanceof Error ? error : new Error(String(error)));
162
+ return;
123
163
  }
124
164
  }
125
165
  if (this.aborted)
@@ -1 +1 @@
1
- {"version":3,"file":"mock-runtime.js","sourceRoot":"","sources":["../../../runtimes/mock/mock-runtime.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,uCAAyB;AACzB,2CAA6B;AA0B7B;;;;;;;GAOG;AACH,MAAa,WAAW;IACb,IAAI,GAAG,MAAM,CAAC;IACN,OAAO,CAAiC;IACxC,YAAY,CAAoC;IAEjE,YACE,OAAuC,EACvC,OAA8D;QAE9D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE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,CAAC,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,kDAAkD;YAClD,cAAc,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAkBD,EAAE,CAAC,KAAa,EAAE,OAAmC;QACnD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAkB,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,KAAa,EAAE,GAAG,IAAe;QAC5C,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACrB,CAAC,CAAC,OAAqC,CAAC,GAAG,IAAI,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,84 @@
1
+ import type { ExecutionContext, NodeEntry, NodeInput, ThinkingBudget, ToolRef } from './types';
2
+ export type SchemaValidationResult<T> = {
3
+ readonly ok: true;
4
+ readonly value: T;
5
+ } | {
6
+ readonly ok: false;
7
+ readonly issues: readonly string[];
8
+ };
9
+ /** Minimal validation contract used by agentNode(). */
10
+ export interface SchemaValidator<T> {
11
+ readonly validate: (value: unknown) => SchemaValidationResult<T> | Promise<SchemaValidationResult<T>>;
12
+ }
13
+ export type SchemaValidationFunction<T> = (value: unknown) => T | undefined;
14
+ interface StandardSchemaIssue {
15
+ readonly message: string;
16
+ readonly path?: readonly unknown[];
17
+ }
18
+ type StandardSchemaResult<T> = {
19
+ readonly value: T;
20
+ readonly issues?: undefined;
21
+ } | {
22
+ readonly issues: readonly StandardSchemaIssue[];
23
+ };
24
+ /** Structural subset of Standard Schema, kept local to avoid a runtime dependency. */
25
+ export interface StandardSchemaValidator<T> {
26
+ readonly '~standard': {
27
+ readonly validate: (value: unknown) => StandardSchemaResult<T> | PromiseLike<StandardSchemaResult<T>>;
28
+ };
29
+ }
30
+ export type AgentNodeSchema<T> = SchemaValidator<T> | SchemaValidationFunction<T> | StandardSchemaValidator<T>;
31
+ export interface AgentNodeConfig<T> {
32
+ readonly prompt: string | ((input: NodeInput, reads: Readonly<Record<string, unknown>>) => string);
33
+ readonly model: string;
34
+ readonly schema?: AgentNodeSchema<T>;
35
+ readonly system?: string;
36
+ readonly output?: string;
37
+ readonly reads?: readonly string[];
38
+ readonly displayName?: string;
39
+ readonly thinkingBudget?: ThinkingBudget;
40
+ readonly timeout?: number;
41
+ readonly isolation?: boolean;
42
+ readonly tools?: readonly ToolRef[] | readonly string[];
43
+ readonly route?: (result: T) => string;
44
+ readonly fallback?: (raw: string, error: Error) => T;
45
+ readonly structuredRetry?: number;
46
+ }
47
+ /** Normalize condukt, function, and Standard Schema validators. */
48
+ export declare function toValidator<T>(schema: AgentNodeSchema<T>): SchemaValidator<T>;
49
+ /**
50
+ * Yield every parseable JSON value in `text`, best first: the whole trimmed
51
+ * string, then each balanced object/array span in start order (so a top-level
52
+ * value is tried before a nested one). The caller validates candidates in order
53
+ * and takes the first that satisfies the schema — so an example snippet that
54
+ * precedes the real answer, or a span that parses but fails validation, does not
55
+ * mask a later valid value.
56
+ */
57
+ export declare function extractJsonCandidates(text: string): Generator<unknown>;
58
+ export declare function loadReads(input: NodeInput, names: readonly string[] | undefined): Readonly<Record<string, unknown>>;
59
+ export declare function repairPrompt(prompt: string, raw: string, error: Error): string;
60
+ export declare function validationError(issues: readonly string[]): Error;
61
+ export declare function validateCandidate<T>(validator: SchemaValidator<T>, value: unknown): Promise<SchemaValidationResult<T>>;
62
+ export declare function serialize(value: unknown): string;
63
+ export declare function writeOutput(input: NodeInput, output: string | undefined, content: string): void;
64
+ export declare function removeInvalidOutput(input: NodeInput, output: string | undefined): void;
65
+ export declare function retryCount(value: number | undefined): number;
66
+ export interface ProducerResult {
67
+ readonly artifact?: string;
68
+ readonly text: string;
69
+ readonly metadata?: Record<string, unknown>;
70
+ }
71
+ interface RawCandidate {
72
+ readonly label: string;
73
+ readonly raw: string;
74
+ }
75
+ export declare function rawCandidates(result: ProducerResult): readonly RawCandidate[];
76
+ export declare function produce<T>(config: AgentNodeConfig<T>, prompt: string, input: NodeInput, ctx: ExecutionContext): Promise<ProducerResult>;
77
+ /**
78
+ * Create a batteries-included agent NodeEntry with optional validated structured output.
79
+ *
80
+ * @experimental Experimental — API may change before it stabilizes into condukt core.
81
+ */
82
+ export declare function agentNode<T = string>(config: AgentNodeConfig<T>): NodeEntry;
83
+ export {};
84
+ //# sourceMappingURL=agent-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-node.d.ts","sourceRoot":"","sources":["../../src/agent-node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,SAAS,EAET,cAAc,EACd,OAAO,EACR,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAChC;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/D,uDAAuD;AACvD,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,OAAO,KACX,sBAAsB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;CACrE;AAED,MAAM,MAA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