@fbp/examples 0.2.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.
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Fan-out as a graph: a list of checks → the failures → one keyed shard each.
3
+ *
4
+ * `flow:filter` narrows the collection by the same declared predicate a branch
5
+ * uses, applied to a field of each row (`conclusion eq failure`), and
6
+ * `flow:for_each` turns what survived into an ordered plan — one
7
+ * `{ index, total, item, key }` descriptor per failure, keyed by the check's
8
+ * name so a re-run addresses the same shard rather than a position in a list
9
+ * that may have moved.
10
+ *
11
+ * The point of the wiring is which node does *not* run: `flow:filter` emits
12
+ * `items` only when something survived and `empty` only when nothing did, so on
13
+ * an all-green batch the fan-out arm never becomes runnable and the graph
14
+ * reconverges through `flow:merge` on the `empty` arm instead. A graph that
15
+ * emitted an empty collection would have run the whole downstream arm to
16
+ * discover there was nothing in it.
17
+ *
18
+ * Every node here is inline, so the editor's local preview runs the whole thing
19
+ * with no platform.
20
+ */
21
+ export const failedCheckFanout = {
22
+ id: 'failed-check-fanout',
23
+ name: 'Fan out over failed checks (filter → for_each)',
24
+ description: 'Narrow a batch of checks to the failures and plan one keyed shard each — and take the empty path when every check passed.',
25
+ runtime: 'local',
26
+ requiresFunctions: [],
27
+ graph: {
28
+ name: 'failed-check-fanout',
29
+ nodes: [
30
+ {
31
+ name: 'graphInput1',
32
+ type: 'graphInput',
33
+ meta: { x: 80, y: 200 },
34
+ props: [{ name: 'portName', type: 'string', value: 'checks' }],
35
+ },
36
+ {
37
+ name: 'filter1',
38
+ type: 'flow:filter',
39
+ meta: { x: 440, y: 200 },
40
+ props: [
41
+ { name: 'path', type: 'string', value: 'conclusion' },
42
+ { name: 'operator', type: 'string', value: 'eq' },
43
+ { name: 'expected', type: 'string', value: 'failure' },
44
+ ],
45
+ },
46
+ {
47
+ name: 'foreach1',
48
+ type: 'flow:for_each',
49
+ meta: { x: 800, y: 100 },
50
+ props: [{ name: 'key', type: 'string', value: 'name' }],
51
+ },
52
+ { name: 'merge1', type: 'flow:merge', meta: { x: 1160, y: 220 } },
53
+ { name: 'object1', type: 'json:object', meta: { x: 1500, y: 220 } },
54
+ {
55
+ name: 'graphOutput1',
56
+ type: 'graphOutput',
57
+ meta: { x: 1840, y: 220 },
58
+ props: [{ name: 'portName', type: 'string', value: 'plan' }],
59
+ },
60
+ ],
61
+ edges: [
62
+ { src: { node: 'graphInput1', port: 'value' }, dst: { node: 'filter1', port: 'items' } },
63
+ // Something failed: plan a shard per failure, and that plan is the result.
64
+ { src: { node: 'filter1', port: 'items' }, dst: { node: 'foreach1', port: 'items' } },
65
+ { src: { node: 'foreach1', port: 'shards' }, dst: { node: 'merge1', port: 'a' } },
66
+ // Everything passed: the fan-out arm never runs, and `empty` carries the graph.
67
+ { src: { node: 'filter1', port: 'empty' }, dst: { node: 'merge1', port: 'b' } },
68
+ // One output either way, with the counts alongside it.
69
+ { src: { node: 'merge1', port: 'value' }, dst: { node: 'object1', port: 'shards' } },
70
+ { src: { node: 'merge1', port: 'source' }, dst: { node: 'object1', port: 'arm' } },
71
+ { src: { node: 'filter1', port: 'kept_count' }, dst: { node: 'object1', port: 'failed' } },
72
+ { src: { node: 'filter1', port: 'dropped_count' }, dst: { node: 'object1', port: 'passed' } },
73
+ { src: { node: 'object1', port: 'value' }, dst: { node: 'graphOutput1', port: 'value' } },
74
+ ],
75
+ inputs: [{ name: 'checks', type: 'json' }],
76
+ outputs: [{ name: 'plan', type: 'json' }],
77
+ },
78
+ };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The smallest graph that produces a value: two constants into a template,
3
+ * the template into the graph's output. Every node is inline, so it evaluates
4
+ * in the browser — the example to reach for when checking that the editor,
5
+ * the evaluator and the output selector are wired to each other at all.
6
+ */
7
+ export const helloString = {
8
+ id: 'hello-string',
9
+ name: 'Hello (string template)',
10
+ description: 'Two constants into a string template — runs entirely in the local preview.',
11
+ runtime: 'local',
12
+ requiresFunctions: [],
13
+ graph: {
14
+ name: 'hello-string',
15
+ nodes: [
16
+ {
17
+ name: 'string1',
18
+ type: 'const:string',
19
+ meta: { x: 80, y: 120 },
20
+ props: [{ name: 'value', type: 'string', value: 'Constructive' }],
21
+ },
22
+ {
23
+ name: 'string2',
24
+ type: 'const:string',
25
+ meta: { x: 80, y: 260 },
26
+ props: [{ name: 'value', type: 'string', value: 'flows' }],
27
+ },
28
+ {
29
+ name: 'template1',
30
+ type: 'string:template',
31
+ meta: { x: 400, y: 180 },
32
+ props: [{ name: 'template', type: 'string', value: 'hello {{who}}, welcome to {{what}}' }],
33
+ },
34
+ {
35
+ name: 'graphOutput1',
36
+ type: 'graphOutput',
37
+ meta: { x: 720, y: 180 },
38
+ props: [{ name: 'portName', type: 'string', value: 'greeting' }],
39
+ },
40
+ ],
41
+ edges: [
42
+ { src: { node: 'string1', port: 'value' }, dst: { node: 'template1', port: 'who' } },
43
+ { src: { node: 'string2', port: 'value' }, dst: { node: 'template1', port: 'what' } },
44
+ { src: { node: 'template1', port: 'value' }, dst: { node: 'graphOutput1', port: 'value' } },
45
+ ],
46
+ outputs: [{ name: 'greeting', type: 'string' }],
47
+ },
48
+ };
49
+ /** What `graphOutput1.value` holds once the graph is evaluated. */
50
+ export const helloStringExpectedOutput = 'hello Constructive, welcome to flows';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * (2 + 3) * 4 — a two-stage inline pipeline. Small enough to assert on
3
+ * exactly, so it is the graph a suite uses to prove that loading an example
4
+ * and evaluating it end to end produces the one right number.
5
+ */
6
+ export const mathPipeline = {
7
+ id: 'math-pipeline',
8
+ name: 'Math pipeline (2 + 3) × 4',
9
+ description: 'Add then multiply with inline math nodes — runs entirely in the local preview.',
10
+ runtime: 'local',
11
+ requiresFunctions: [],
12
+ graph: {
13
+ name: 'math-pipeline',
14
+ nodes: [
15
+ {
16
+ name: 'number1',
17
+ type: 'const:number',
18
+ meta: { x: 80, y: 100 },
19
+ props: [{ name: 'value', type: 'number', value: 2 }],
20
+ },
21
+ {
22
+ name: 'number2',
23
+ type: 'const:number',
24
+ meta: { x: 80, y: 240 },
25
+ props: [{ name: 'value', type: 'number', value: 3 }],
26
+ },
27
+ {
28
+ name: 'number3',
29
+ type: 'const:number',
30
+ meta: { x: 80, y: 380 },
31
+ props: [{ name: 'value', type: 'number', value: 4 }],
32
+ },
33
+ { name: 'add1', type: 'math:add', meta: { x: 400, y: 160 } },
34
+ { name: 'multiply1', type: 'math:multiply', meta: { x: 700, y: 260 } },
35
+ {
36
+ name: 'graphOutput1',
37
+ type: 'graphOutput',
38
+ meta: { x: 1000, y: 260 },
39
+ props: [{ name: 'portName', type: 'string', value: 'total' }],
40
+ },
41
+ ],
42
+ edges: [
43
+ { src: { node: 'number1', port: 'value' }, dst: { node: 'add1', port: 'a' } },
44
+ { src: { node: 'number2', port: 'value' }, dst: { node: 'add1', port: 'b' } },
45
+ { src: { node: 'add1', port: 'sum' }, dst: { node: 'multiply1', port: 'a' } },
46
+ { src: { node: 'number3', port: 'value' }, dst: { node: 'multiply1', port: 'b' } },
47
+ { src: { node: 'multiply1', port: 'product' }, dst: { node: 'graphOutput1', port: 'value' } },
48
+ ],
49
+ outputs: [{ name: 'total', type: 'number' }],
50
+ },
51
+ };
52
+ /** What `graphOutput1.value` holds once the graph is evaluated. */
53
+ export const mathPipelineExpectedOutput = 20;
package/esm/index.js ADDED
@@ -0,0 +1,47 @@
1
+ import { agentReviewLoop } from './graphs/agent-review-loop';
2
+ import { agenticEmbed } from './graphs/agentic-embed';
3
+ import { agenticKit } from './graphs/agentic-kit';
4
+ import { codingAgent } from './graphs/coding-agent';
5
+ import { codingSession } from './graphs/coding-session';
6
+ import { emailSend } from './graphs/email-send';
7
+ import { failedCheckFanout } from './graphs/failed-check-fanout';
8
+ import { helloString } from './graphs/hello-string';
9
+ import { mathPipeline } from './graphs/math-pipeline';
10
+ export { agentReviewLoop } from './graphs/agent-review-loop';
11
+ export { agenticEmbed } from './graphs/agentic-embed';
12
+ export { agenticKit } from './graphs/agentic-kit';
13
+ export { codingAgent } from './graphs/coding-agent';
14
+ export { codingSession } from './graphs/coding-session';
15
+ export { emailSend } from './graphs/email-send';
16
+ export { failedCheckFanout } from './graphs/failed-check-fanout';
17
+ export { helloString, helloStringExpectedOutput } from './graphs/hello-string';
18
+ export { mathPipeline, mathPipelineExpectedOutput } from './graphs/math-pipeline';
19
+ /**
20
+ * Every example flow, in the order the Flows panel offers them: the two that
21
+ * run with no platform first, then the ones that address registered functions.
22
+ */
23
+ export const exampleFlows = [
24
+ helloString,
25
+ mathPipeline,
26
+ failedCheckFanout,
27
+ agenticEmbed,
28
+ agenticKit,
29
+ emailSend,
30
+ codingAgent,
31
+ codingSession,
32
+ agentReviewLoop,
33
+ ];
34
+ /** The example with this id, or undefined. */
35
+ export const findExampleFlow = (id) => exampleFlows.find((example) => example.id === id);
36
+ /**
37
+ * The example with this id. Throws when it does not exist: a caller naming an
38
+ * example by id has a graph in mind, and silently handing back an empty one
39
+ * turns a typo into a green run over nothing.
40
+ */
41
+ export const getExampleFlow = (id) => {
42
+ const found = findExampleFlow(id);
43
+ if (!found) {
44
+ throw new Error(`Unknown example flow "${id}" — known ids: ${exampleFlows.map((e) => e.id).join(', ')}`);
45
+ }
46
+ return found;
47
+ };
package/esm/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { ExampleFlow } from '../types';
2
+ /**
3
+ * A review loop as a graph: code → review → branch → fix → re-review → merge.
4
+ *
5
+ * This is the graph the flow nodes exist for. `agent:code_task` makes the
6
+ * change, `agent:chat` reviews the run's own summary, and `flow:branch` decides
7
+ * what happens next by a declared predicate — approved goes straight to the
8
+ * output, anything else goes to a second coding run that continues the *same*
9
+ * `agent_run` (its `run_id` is an edge), followed by a second review.
10
+ *
11
+ * `flow:merge` is what makes the two arms one graph again. A branch emits only
12
+ * the port it took, so the arm not taken never completes and every edge out of
13
+ * it is unsatisfiable forever; the merge node declares both of its inputs
14
+ * optional, which is the graph saying "run me on whichever arm arrives". The
15
+ * result is a diamond rather than two graphs: one output port, and `source`
16
+ * recording which path produced it — `a` when the first review approved, `b`
17
+ * when it took a fix and a re-review to get there.
18
+ *
19
+ * The predicate is `contains 'approved'` rather than an exact match because the
20
+ * value being judged is a sentence from a model; asking for equality against
21
+ * prose is how a loop like this silently always takes the same arm.
22
+ */
23
+ export declare const agentReviewLoop: ExampleFlow;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.agentReviewLoop = void 0;
4
+ /**
5
+ * A review loop as a graph: code → review → branch → fix → re-review → merge.
6
+ *
7
+ * This is the graph the flow nodes exist for. `agent:code_task` makes the
8
+ * change, `agent:chat` reviews the run's own summary, and `flow:branch` decides
9
+ * what happens next by a declared predicate — approved goes straight to the
10
+ * output, anything else goes to a second coding run that continues the *same*
11
+ * `agent_run` (its `run_id` is an edge), followed by a second review.
12
+ *
13
+ * `flow:merge` is what makes the two arms one graph again. A branch emits only
14
+ * the port it took, so the arm not taken never completes and every edge out of
15
+ * it is unsatisfiable forever; the merge node declares both of its inputs
16
+ * optional, which is the graph saying "run me on whichever arm arrives". The
17
+ * result is a diamond rather than two graphs: one output port, and `source`
18
+ * recording which path produced it — `a` when the first review approved, `b`
19
+ * when it took a fix and a re-review to get there.
20
+ *
21
+ * The predicate is `contains 'approved'` rather than an exact match because the
22
+ * value being judged is a sentence from a model; asking for equality against
23
+ * prose is how a loop like this silently always takes the same arm.
24
+ */
25
+ exports.agentReviewLoop = {
26
+ id: 'agent-review-loop',
27
+ name: 'Agent review loop (code → review → fix → re-review)',
28
+ description: 'Let an agent make a change, review it, and only fix and re-review when the review asked for changes.',
29
+ runtime: 'server',
30
+ requiresFunctions: ['agent:chat', 'agent:code_task'],
31
+ graph: {
32
+ name: 'agent-review-loop',
33
+ nodes: [
34
+ {
35
+ name: 'graphInput1',
36
+ type: 'graphInput',
37
+ meta: { x: 80, y: 240 },
38
+ props: [{ name: 'portName', type: 'string', value: 'request' }],
39
+ },
40
+ {
41
+ name: 'string1',
42
+ type: 'const:string',
43
+ meta: { x: 80, y: 360 },
44
+ props: [{ name: 'value', type: 'string', value: 'constructive-io/constructive-db' }],
45
+ },
46
+ {
47
+ name: 'string2',
48
+ type: 'const:string',
49
+ meta: { x: 80, y: 60 },
50
+ props: [
51
+ {
52
+ name: 'value',
53
+ type: 'string',
54
+ value: 'You are reviewing a coding agent\'s account of a change it just made. Answer with one word — "approved" if the change is sound and complete, "changes_requested" if it is not — then one paragraph saying why, and what to change.',
55
+ },
56
+ ],
57
+ },
58
+ { name: 'code1', type: 'agent:code_task', meta: { x: 470, y: 280 } },
59
+ { name: 'review1', type: 'agent:chat', meta: { x: 860, y: 140 } },
60
+ {
61
+ name: 'branch1',
62
+ type: 'flow:branch',
63
+ meta: { x: 1220, y: 140 },
64
+ props: [
65
+ { name: 'operator', type: 'string', value: 'contains' },
66
+ { name: 'expected', type: 'string', value: 'approved' },
67
+ ],
68
+ },
69
+ {
70
+ name: 'template1',
71
+ type: 'string:template',
72
+ meta: { x: 1220, y: 420 },
73
+ props: [
74
+ {
75
+ name: 'template',
76
+ type: 'string',
77
+ value: 'The review asked for changes. Address this feedback in the same run:\n\n{{review}}',
78
+ },
79
+ ],
80
+ },
81
+ { name: 'fix1', type: 'agent:code_task', meta: { x: 1560, y: 420 } },
82
+ { name: 'review2', type: 'agent:chat', meta: { x: 1900, y: 420 } },
83
+ { name: 'merge1', type: 'flow:merge', meta: { x: 2240, y: 260 } },
84
+ { name: 'object1', type: 'json:object', meta: { x: 2560, y: 260 } },
85
+ {
86
+ name: 'graphOutput1',
87
+ type: 'graphOutput',
88
+ meta: { x: 2880, y: 260 },
89
+ props: [{ name: 'portName', type: 'string', value: 'result' }],
90
+ },
91
+ ],
92
+ edges: [
93
+ { src: { node: 'graphInput1', port: 'value' }, dst: { node: 'code1', port: 'prompt' } },
94
+ { src: { node: 'string1', port: 'value' }, dst: { node: 'code1', port: 'repo' } },
95
+ // The review judges the run's own account of what it did.
96
+ { src: { node: 'string2', port: 'value' }, dst: { node: 'review1', port: 'system' } },
97
+ { src: { node: 'code1', port: 'summary' }, dst: { node: 'review1', port: 'prompt' } },
98
+ { src: { node: 'review1', port: 'content' }, dst: { node: 'branch1', port: 'value' } },
99
+ // Approved: the review text is the result, and the fix arm never runs.
100
+ { src: { node: 'branch1', port: 'true' }, dst: { node: 'merge1', port: 'a' } },
101
+ // Changes requested: the review text becomes the next run's prompt, and
102
+ // `run_id` continues the same session rather than starting a new one.
103
+ { src: { node: 'branch1', port: 'false' }, dst: { node: 'template1', port: 'review' } },
104
+ { src: { node: 'template1', port: 'value' }, dst: { node: 'fix1', port: 'prompt' } },
105
+ { src: { node: 'string1', port: 'value' }, dst: { node: 'fix1', port: 'repo' } },
106
+ { src: { node: 'code1', port: 'run_id' }, dst: { node: 'fix1', port: 'run_id' } },
107
+ { src: { node: 'string2', port: 'value' }, dst: { node: 'review2', port: 'system' } },
108
+ { src: { node: 'fix1', port: 'summary' }, dst: { node: 'review2', port: 'prompt' } },
109
+ { src: { node: 'review2', port: 'content' }, dst: { node: 'merge1', port: 'b' } },
110
+ // One output either way, and `source` says which arm produced it.
111
+ { src: { node: 'merge1', port: 'value' }, dst: { node: 'object1', port: 'review' } },
112
+ { src: { node: 'merge1', port: 'source' }, dst: { node: 'object1', port: 'arm' } },
113
+ { src: { node: 'code1', port: 'pull_request_url' }, dst: { node: 'object1', port: 'pullRequest' } },
114
+ { src: { node: 'code1', port: 'branch' }, dst: { node: 'object1', port: 'branch' } },
115
+ { src: { node: 'object1', port: 'value' }, dst: { node: 'graphOutput1', port: 'value' } },
116
+ ],
117
+ inputs: [{ name: 'request', type: 'string' }],
118
+ outputs: [{ name: 'result', type: 'json' }],
119
+ },
120
+ };
@@ -0,0 +1,13 @@
1
+ import type { ExampleFlow } from '../types';
2
+ /**
3
+ * Embeddings only, on the one model the suites already run locally
4
+ * (`nomic-embed-text` on Ollama). It reports the vector's width rather than the
5
+ * vector, so a run has a small deterministic assertion — 768 dimensions — that
6
+ * says the whole path worked: worker → knative → runtime `ctx.agent` → agentic
7
+ * server → local provider.
8
+ *
9
+ * The node is the embedding feature's own function, published by
10
+ * constructive-functions — the platform provides `ctx.agent`, features provide
11
+ * the nodes that call it.
12
+ */
13
+ export declare const agenticEmbed: ExampleFlow;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.agenticEmbed = void 0;
4
+ /**
5
+ * Embeddings only, on the one model the suites already run locally
6
+ * (`nomic-embed-text` on Ollama). It reports the vector's width rather than the
7
+ * vector, so a run has a small deterministic assertion — 768 dimensions — that
8
+ * says the whole path worked: worker → knative → runtime `ctx.agent` → agentic
9
+ * server → local provider.
10
+ *
11
+ * The node is the embedding feature's own function, published by
12
+ * constructive-functions — the platform provides `ctx.agent`, features provide
13
+ * the nodes that call it.
14
+ */
15
+ exports.agenticEmbed = {
16
+ id: 'agentic-embed',
17
+ name: 'Agentic embed (nomic-embed-text)',
18
+ description: 'Embed a passage locally and report the vector width — the CI-safe agentic flow.',
19
+ runtime: 'server',
20
+ requiresFunctions: ['embedding:generate_embedding'],
21
+ graph: {
22
+ name: 'agentic-embed',
23
+ nodes: [
24
+ {
25
+ name: 'string1',
26
+ type: 'const:string',
27
+ meta: { x: 80, y: 140 },
28
+ props: [
29
+ {
30
+ name: 'value',
31
+ type: 'string',
32
+ value: 'A flow graph is a set of nodes wired port to port.',
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ name: 'string2',
38
+ type: 'const:string',
39
+ meta: { x: 80, y: 320 },
40
+ props: [{ name: 'value', type: 'string', value: 'nomic-embed-text' }],
41
+ },
42
+ { name: 'embed1', type: 'embedding:generate_embedding', meta: { x: 460, y: 200 } },
43
+ { name: 'object1', type: 'json:object', meta: { x: 820, y: 200 } },
44
+ {
45
+ name: 'graphOutput1',
46
+ type: 'graphOutput',
47
+ meta: { x: 1140, y: 200 },
48
+ props: [{ name: 'portName', type: 'string', value: 'result' }],
49
+ },
50
+ ],
51
+ edges: [
52
+ { src: { node: 'string1', port: 'value' }, dst: { node: 'embed1', port: 'text' } },
53
+ { src: { node: 'string2', port: 'value' }, dst: { node: 'embed1', port: 'model' } },
54
+ { src: { node: 'embed1', port: 'dimensions' }, dst: { node: 'object1', port: 'dimensions' } },
55
+ { src: { node: 'embed1', port: 'model' }, dst: { node: 'object1', port: 'model' } },
56
+ { src: { node: 'object1', port: 'value' }, dst: { node: 'graphOutput1', port: 'value' } },
57
+ ],
58
+ outputs: [{ name: 'result', type: 'json' }],
59
+ },
60
+ };
@@ -0,0 +1,20 @@
1
+ import type { ExampleFlow } from '../types';
2
+ /**
3
+ * The agentic-kit round trip as a graph: one piece of text fans out to an
4
+ * embedding call and a chat call, and both results land in a single JSON object
5
+ * so one output node carries the whole answer.
6
+ *
7
+ * Both nodes reach the agentic server through the runtime's `ctx.agent`, so what
8
+ * this really exercises is the identity-carrying path from the worker to the
9
+ * gateway to the local provider — with `nomic-embed-text` on Ollama as the
10
+ * embedding model that is already proven in CI.
11
+ *
12
+ * Both nodes are features' own functions, published by constructive-functions:
13
+ * the platform provides `ctx.agent`, features provide the nodes that call it.
14
+ *
15
+ * Both models are named explicitly rather than left to the gateway's default,
16
+ * because that default is an embedding model (`DEFAULT_MODEL` in
17
+ * `compute/docker-compose.yml`) and would refuse the chat call. The chat model
18
+ * is the small one the local stack pulls, so this graph runs where CI runs.
19
+ */
20
+ export declare const agenticKit: ExampleFlow;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.agenticKit = void 0;
4
+ /**
5
+ * The agentic-kit round trip as a graph: one piece of text fans out to an
6
+ * embedding call and a chat call, and both results land in a single JSON object
7
+ * so one output node carries the whole answer.
8
+ *
9
+ * Both nodes reach the agentic server through the runtime's `ctx.agent`, so what
10
+ * this really exercises is the identity-carrying path from the worker to the
11
+ * gateway to the local provider — with `nomic-embed-text` on Ollama as the
12
+ * embedding model that is already proven in CI.
13
+ *
14
+ * Both nodes are features' own functions, published by constructive-functions:
15
+ * the platform provides `ctx.agent`, features provide the nodes that call it.
16
+ *
17
+ * Both models are named explicitly rather than left to the gateway's default,
18
+ * because that default is an embedding model (`DEFAULT_MODEL` in
19
+ * `compute/docker-compose.yml`) and would refuse the chat call. The chat model
20
+ * is the small one the local stack pulls, so this graph runs where CI runs.
21
+ */
22
+ exports.agenticKit = {
23
+ id: 'agentic-kit',
24
+ name: 'Agentic kit (embed + chat)',
25
+ description: 'Embed a passage and ask a model about it, merging both into one output.',
26
+ runtime: 'server',
27
+ requiresFunctions: ['agent:chat', 'embedding:generate_embedding'],
28
+ graph: {
29
+ name: 'agentic-kit',
30
+ nodes: [
31
+ {
32
+ name: 'string1',
33
+ type: 'const:string',
34
+ meta: { x: 80, y: 120 },
35
+ props: [
36
+ {
37
+ name: 'value',
38
+ type: 'string',
39
+ value: 'Constructive turns database metadata into provisioned schemas, row level security policies and typed SDKs.',
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ name: 'string2',
45
+ type: 'const:string',
46
+ meta: { x: 80, y: 300 },
47
+ props: [{ name: 'value', type: 'string', value: 'nomic-embed-text' }],
48
+ },
49
+ {
50
+ name: 'string3',
51
+ type: 'const:string',
52
+ meta: { x: 80, y: 440 },
53
+ props: [
54
+ {
55
+ name: 'value',
56
+ type: 'string',
57
+ value: 'Answer in one short sentence.',
58
+ },
59
+ ],
60
+ },
61
+ {
62
+ name: 'string4',
63
+ type: 'const:string',
64
+ meta: { x: 80, y: 560 },
65
+ props: [{ name: 'value', type: 'string', value: 'qwen2.5:0.5b' }],
66
+ },
67
+ { name: 'embed1', type: 'embedding:generate_embedding', meta: { x: 460, y: 140 } },
68
+ { name: 'chat1', type: 'agent:chat', meta: { x: 460, y: 420 } },
69
+ {
70
+ name: 'select1',
71
+ type: 'json:select',
72
+ meta: { x: 800, y: 60 },
73
+ props: [{ name: 'path', type: 'string', value: '0' }],
74
+ },
75
+ { name: 'object1', type: 'json:object', meta: { x: 1100, y: 300 } },
76
+ {
77
+ name: 'graphOutput1',
78
+ type: 'graphOutput',
79
+ meta: { x: 1420, y: 300 },
80
+ props: [{ name: 'portName', type: 'string', value: 'result' }],
81
+ },
82
+ ],
83
+ edges: [
84
+ { src: { node: 'string1', port: 'value' }, dst: { node: 'embed1', port: 'text' } },
85
+ { src: { node: 'string2', port: 'value' }, dst: { node: 'embed1', port: 'model' } },
86
+ { src: { node: 'string1', port: 'value' }, dst: { node: 'chat1', port: 'prompt' } },
87
+ { src: { node: 'string3', port: 'value' }, dst: { node: 'chat1', port: 'system' } },
88
+ { src: { node: 'string4', port: 'value' }, dst: { node: 'chat1', port: 'model' } },
89
+ { src: { node: 'embed1', port: 'embedding' }, dst: { node: 'select1', port: 'obj' } },
90
+ { src: { node: 'select1', port: 'value' }, dst: { node: 'object1', port: 'firstDimension' } },
91
+ { src: { node: 'embed1', port: 'dimensions' }, dst: { node: 'object1', port: 'dimensions' } },
92
+ { src: { node: 'chat1', port: 'content' }, dst: { node: 'object1', port: 'answer' } },
93
+ { src: { node: 'object1', port: 'value' }, dst: { node: 'graphOutput1', port: 'value' } },
94
+ ],
95
+ outputs: [{ name: 'result', type: 'json' }],
96
+ },
97
+ };
@@ -0,0 +1,17 @@
1
+ import type { ExampleFlow } from '../types';
2
+ /**
3
+ * A coding agent as one node.
4
+ *
5
+ * `agent:chat` plans first — it turns the graph's one input into the instruction
6
+ * the coding run is given — and `agent:code_task` is the resource node that does
7
+ * the work: it clones the repository, runs the agent inside the clone with the
8
+ * thread as its UI, then commits, pushes and opens a pull request. The plan step
9
+ * is optional in the sense that the coding node accepts the raw request just as
10
+ * well; it is here because it is what makes the graph legible — the prompt the
11
+ * agent was actually given is a value on an edge, not something buried in a Job.
12
+ *
13
+ * The resource node is long-running: the worker creates a Kubernetes Job and the
14
+ * graph waits for the node gateway to be settled, so the run may pause for a
15
+ * human approval in the thread without the execution timing out.
16
+ */
17
+ export declare const codingAgent: ExampleFlow;