langflower 0.2.2 → 0.4.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.
Files changed (68) hide show
  1. package/README.md +34 -29
  2. package/dist/{chunk-KOS7BXAM.js → chunk-32BC3YXC.js} +1 -1
  3. package/dist/{chunk-26UB55E5.js → chunk-5B3555QF.js} +2 -0
  4. package/dist/{chunk-X3FU465E.js → chunk-P3QJHZO7.js} +1 -1
  5. package/dist/{chunk-3Z7Q6SQ5.js → chunk-VVJLF47H.js} +93 -10
  6. package/dist/index.js +5743 -2626
  7. package/docs/{public → assets/public}/README.md +8 -1
  8. package/docs/{public → assets/public}/configuration.md +7 -0
  9. package/docs/{public → assets/public}/extending.md +9 -2
  10. package/docs/{public → assets/public}/getting-started.md +11 -4
  11. package/docs/{public → assets/public}/how-it-works.md +7 -0
  12. package/docs/{public → assets/public}/launcher.md +11 -2
  13. package/docs/{public → assets/public}/product.md +17 -3
  14. package/docs/{public → assets/public}/using-the-editor.md +7 -0
  15. package/docs/{public → assets/public}/workflows.md +7 -0
  16. package/package.json +2 -2
  17. package/ui-dist/assets/langflower-mark.svg +33 -0
  18. package/ui-dist/{chunk-IASSR2ON.js → chunk-33CXNPF2.js} +1 -1
  19. package/ui-dist/chunk-SNO65Y6K.js +4 -0
  20. package/ui-dist/index.html +2 -2
  21. package/ui-dist/main-GN43PQD5.js +323 -0
  22. package/ui-dist/styles-DMRPMU4V.css +1 -0
  23. package/vendor/node-sdk/dist/node-factory/define-llm-node/default-llm-ports.d.ts +11 -1
  24. package/vendor/node-sdk/dist/node-factory/define-llm-node/define-llm-node.d.ts +3 -1
  25. package/vendor/node-sdk/dist/node-factory/define-llm-node/define-llm-node.js +1 -0
  26. package/vendor/node-sdk/dist/node-factory/define-llm-node/steer-control.d.ts +5 -2
  27. package/vendor/node-sdk/dist/node-factory/define-llm-node/steer-control.js +3 -2
  28. package/vendor/node-sdk/dist/node-factory/define-node/define-node.d.ts +2 -1
  29. package/vendor/node-sdk/dist/node-factory/define-reactive-node/capabilities.d.ts +32 -1
  30. package/vendor/node-sdk/dist/node-factory/define-reactive-node/define-reactive-node.d.ts +3 -1
  31. package/vendor/node-sdk/dist/node-factory/define-reactive-node/define-reactive-node.js +4 -1
  32. package/vendor/node-sdk/dist/node-factory/define-reactive-node/hitl-config.d.ts +14 -0
  33. package/vendor/node-sdk/dist/node-factory/define-reactive-node/hitl-config.js +24 -1
  34. package/vendor/node-sdk/dist/node-factory/define-reactive-node/io-helpers.d.ts +13 -4
  35. package/vendor/node-sdk/dist/node-factory/define-reactive-node/port-meta.d.ts +12 -2
  36. package/vendor/node-sdk/dist/node-factory/define-reactive-node/types.d.ts +8 -0
  37. package/vendor/node-sdk/dist/node-factory/define-reactive-node/ui-schema-inference.d.ts +18 -0
  38. package/vendor/node-sdk/dist/node-state.d.ts +28 -0
  39. package/vendor/node-sdk/dist/node-state.js +1 -0
  40. package/vendor/node-sdk/package.json +1 -1
  41. package/vendor/runtime/dist/feed-log-fold.d.ts +26 -0
  42. package/vendor/runtime/dist/feed-log-fold.js +113 -0
  43. package/vendor/runtime/dist/runtime-editor.d.ts +6 -0
  44. package/vendor/runtime/dist/runtime-editor.js +95 -2
  45. package/vendor/runtime/dist/runtime-runner.d.ts +28 -3
  46. package/vendor/runtime/dist/runtime-runner.js +101 -9
  47. package/vendor/runtime/dist/runtime.d.ts +5 -1
  48. package/vendor/runtime/dist/runtime.js +2 -0
  49. package/vendor/runtime/dist/types.d.ts +91 -5
  50. package/vendor/runtime/dist/wire-type.d.ts +12 -0
  51. package/vendor/runtime/dist/wire-type.js +18 -0
  52. package/vendor/server/skeleton/instructions.md +3 -1
  53. package/vendor/server/skeleton/nodes/hello-embed/README.md +1 -1
  54. package/vendor/server/skeleton/nodes/hello-embed/package.json +1 -1
  55. package/vendor/server/skeleton/nodes/my-nodes/README.md +12 -0
  56. package/vendor/server/skeleton/nodes/my-nodes/package.json +1 -1
  57. package/vendor/server/skeleton/nodes/my-nodes/review-gate.ts +5 -0
  58. package/vendor/server/skeleton/skills/langflower-helper/SKILL.md +196 -57
  59. package/vendor/server/skeleton/skills/langflower-helper/architecture.md +50 -8
  60. package/vendor/server/skeleton/skills/langflower-helper/layout.md +33 -13
  61. package/vendor/server/skeleton/skills/langflower-node-writer/SKILL.md +25 -4
  62. package/vendor/server/skeleton/skills/langflower-workflow-writer/SKILL.md +21 -2
  63. package/vendor/server/skeleton/workflows/agents-dialog.json +1 -1
  64. package/vendor/server/skeleton/workflows/kb-rag.json +1 -1
  65. package/vendor/server/skeleton/workflows/starter.json +3 -3
  66. package/ui-dist/chunk-HEF6F5HN.js +0 -4
  67. package/ui-dist/main-66PVIOBC.js +0 -323
  68. package/ui-dist/styles-Y56BLXVS.css +0 -1
@@ -1,6 +1,7 @@
1
1
  import type { ResponseDto, StatefulConnection, StatefulObservable } from '@rx-evo/stateful-observable';
2
2
  import type { Observable } from 'rxjs';
3
3
  import type { GraphCluster } from './runtime-helpers.js';
4
+ import type { WireTypeSpec } from './wire-type.js';
4
5
  export type RuntimeWireType = string & {
5
6
  __brand: 'RuntimeWireType';
6
7
  };
@@ -34,11 +35,16 @@ export type PortMeta = {
34
35
  /** Port id (e.g. `"value"`, `"lines"`). */
35
36
  readonly portId: string | symbol;
36
37
  /** Wire type (e.g. `"string"`, `"dynamic"`, `"any"`). */
37
- readonly wireType: string | symbol;
38
+ readonly wireType: WireTypeSpec | symbol;
38
39
  /** Input port cardinality — `undefined` for outputs. */
39
40
  readonly mode?: RuntimeInputPortMode;
40
41
  /** Passthrough source input port id — `undefined` for non-passthrough outputs. */
41
42
  readonly fromInput?: string;
43
+ /**
44
+ * Input port id this output continues when the node is deleted.
45
+ * Does not change wire-type inference (`fromInput` does).
46
+ */
47
+ readonly rewireFrom?: string;
42
48
  /**
43
49
  * Design-time default for an **unconnected** input. Applied by the runner at
44
50
  * `start` / `startNode` when no edge targets the port (see
@@ -159,6 +165,33 @@ export declare const isPortPendingTelemetry: (event: RuntimeRunnerEvent) => even
159
165
  };
160
166
  };
161
167
  export declare const isRuntimeDone: (event: RuntimeRunnerEvent) => event is RuntimeDoneTelemetry;
168
+ /**
169
+ * Structural twin of `@langflower/node-sdk` `NodeStateJson` (ADR-027).
170
+ * The author package owns the type; runtime does not import it.
171
+ */
172
+ export type NodeStateJson = null | boolean | number | string | readonly NodeStateJson[] | {
173
+ readonly [key: string]: NodeStateJson;
174
+ };
175
+ /**
176
+ * Structural twin of `@langflower/node-sdk` `NodeStateHook` (ADR-027).
177
+ * Optional on {@link RuntimeNode}. The runner restores it before wiring.
178
+ */
179
+ export type NodeStateHook = {
180
+ /** Full JSON-safe state after each committed unit of work. */
181
+ readonly persist$: Observable<NodeStateJson>;
182
+ /**
183
+ * Called by the runner before wiring. `null` starts fresh.
184
+ * `{ ok: false }` does not throw and does not abort the run.
185
+ */
186
+ readonly restore: (state: NodeStateJson | null) => {
187
+ readonly ok: true;
188
+ } | {
189
+ readonly ok: false;
190
+ readonly message: string;
191
+ };
192
+ };
193
+ /** `nodeId` → JSON state supplied to `restore` for one run. */
194
+ export type RuntimeNodeStates = Readonly<Record<string, NodeStateJson>>;
162
195
  /**
163
196
  * Seed value pushed into an input port slot on {@link RuntimeRunner.start}.
164
197
  * Plain values are wrapped in `of`; Observables are connected as the stream.
@@ -168,6 +201,11 @@ export type RuntimeSeedPortValue = {
168
201
  /** Multi-input slot index (`0` for single-slot ports). */
169
202
  readonly slotIndex: number;
170
203
  readonly value: unknown;
204
+ /**
205
+ * Deliver the value without a `runner.port` frame. A recovered run seeds an
206
+ * input whose value the work log already shows.
207
+ */
208
+ readonly silent?: boolean;
171
209
  };
172
210
  /**
173
211
  * Durable-resume overlay for {@link RuntimeRunnerApi.resume}.
@@ -184,6 +222,11 @@ export type RuntimeResumeOptions = {
184
222
  */
185
223
  readonly outputSnapshots: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
186
224
  readonly initialPayload?: Readonly<Record<string, ReadonlyArray<RuntimeSeedPortValue>>>;
225
+ /**
226
+ * JSON state passed to each hooked node's `restore`. A missing id
227
+ * restores `null` so a stale pending restore cannot survive the run.
228
+ */
229
+ readonly nodeStates?: RuntimeNodeStates;
187
230
  };
188
231
  export type RuntimeNode = {
189
232
  readonly nodeId: NodeId;
@@ -245,6 +288,12 @@ export type RuntimeNode = {
245
288
  * metadata for factories and tests.
246
289
  */
247
290
  readonly emitOncePerActivation?: boolean;
291
+ /**
292
+ * Optional JSON state hook. The runner calls `restore` before wiring
293
+ * and merges `persist$` into {@link RuntimeRunnerApi.nodeState$} while
294
+ * this node is in the active run scope.
295
+ */
296
+ readonly state?: NodeStateHook;
248
297
  };
249
298
  export type RuntimeEdge = {
250
299
  readonly edgeId: EdgeId;
@@ -307,9 +356,12 @@ export type RuntimeEditorApi = {
307
356
  * {@link removeNode}. Returns `false` when disposed or `nodeId` is missing.
308
357
  */
309
358
  swapNode(nodeId: NodeId, next: Omit<RuntimeNode, 'nodeId'>): SwapNodeResult | false;
310
- /** Must fail while runner status is `'running'`.
359
+ /**
360
+ * Must fail while runner status is `'running'`.
311
361
  *
312
- * return false while running or node not found
362
+ * Returns `false` while running or when `nodeId` is missing.
363
+ * On success, splices edges across outputs that declare `fromInput` or
364
+ * `rewireFrom` before dropping wires the removal made incompatible.
313
365
  */
314
366
  removeNode(nodeId: NodeId): RuntimeNode | false;
315
367
  /** Must fail while runner status is `'running'`.
@@ -346,10 +398,15 @@ export type RuntimeRunnerApi = {
346
398
  *
347
399
  * Throws if status is already `'running'`.
348
400
  *
401
+ * Optional `options.nodeStates` is restored onto hooked in-scope nodes
402
+ * before wiring. A missing entry restores `null`.
403
+ *
349
404
  * @returns runId — correlates {@link RuntimeRunnerEvent} for the server
350
405
  * adapter; runtime does not persist runs.
351
406
  */
352
- start(initialPayload?: Readonly<Record<string, ReadonlyArray<RuntimeSeedPortValue>>>, runId?: RunId): RunId | false;
407
+ start(initialPayload?: Readonly<Record<string, ReadonlyArray<RuntimeSeedPortValue>>>, runId?: RunId, options?: {
408
+ readonly nodeStates?: RuntimeNodeStates;
409
+ }): RunId | false;
353
410
  /**
354
411
  * Run-from-node: wire the weakly connected cluster containing `nodeId`
355
412
  * (orphan nodes elsewhere on the canvas are not wired). Same runId /
@@ -363,9 +420,14 @@ export type RuntimeRunnerApi = {
363
420
  * Flow: `RuntimeEditorApi.getClusterByNodeId(nodeId)` -> internal runner
364
421
  * `runScope` (cluster node/edge sets).
365
422
  *
423
+ * Optional `options.nodeStates` is restored onto hooked nodes in this
424
+ * cluster only. Nodes outside the cluster are left untouched.
425
+ *
366
426
  * @returns runId — same semantics as {@link RuntimeRunnerApi.start}.
367
427
  */
368
- startNode(nodeId: NodeId, initialPayload?: Readonly<Record<string, ReadonlyArray<RuntimeSeedPortValue>>>, runId?: RunId): RunId | false;
428
+ startNode(nodeId: NodeId, initialPayload?: Readonly<Record<string, ReadonlyArray<RuntimeSeedPortValue>>>, runId?: RunId, options?: {
429
+ readonly nodeStates?: RuntimeNodeStates;
430
+ }): RunId | false;
369
431
  /**
370
432
  * Resume a stopped run: wire the full graph, skip completed nodes, and
371
433
  * replay their output snapshots into downstream edges.
@@ -408,6 +470,12 @@ export type RuntimeRunnerApi = {
408
470
  * is never mutated).
409
471
  */
410
472
  clearEventLog(): void;
473
+ /**
474
+ * Replace {@link eventLog} with `events`. No-op unless status is
475
+ * `'idle'` and the runner was constructed with `{ log: true }`.
476
+ * Does not throw when the runner is not idle.
477
+ */
478
+ seedEventLog(events: readonly RuntimeRunnerEvent[]): void;
411
479
  dispose(): void;
412
480
  /**
413
481
  * `'idle'` — no active run, or natural completion (`done`); edits allowed.
@@ -426,6 +494,24 @@ export type RuntimeRunnerApi = {
426
494
  * execution events.
427
495
  */
428
496
  readonly events$: Observable<RuntimeRunnerEvent>;
497
+ /**
498
+ * Server-internal fact stream. Emits `{ nodeId, state }` when a hooked
499
+ * in-scope node's `persist$` emits during the active run. Quiet when
500
+ * the scope has no state hook. Not a WebSocket event.
501
+ */
502
+ readonly nodeState$: Observable<{
503
+ readonly nodeId: string;
504
+ readonly state: NodeStateJson;
505
+ }>;
506
+ /**
507
+ * Nodes whose `restore` returned `{ ok: false }` on the latest
508
+ * `start` / `startNode` / `resume`. Cleared when that run begins.
509
+ * Does not abort the run.
510
+ */
511
+ readonly lastRestoreFailures: readonly {
512
+ readonly nodeId: string;
513
+ readonly message: string;
514
+ }[];
429
515
  /**
430
516
  * In-memory run event log when {@link RuntimeRunner} is constructed with
431
517
  * `{ log: true }`. Used by `@langflower/server` for feed replay.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Port wire type. A scalar names one type (`'string'`). A list is a union:
3
+ * an edge connects when the two sides share a member. `'any'` matches
4
+ * everything. `'dynamic'` is scalar-only and never appears in a list.
5
+ */
6
+ export type WireTypeSpec = string | readonly string[];
7
+ export declare const wireTypeList: (spec: WireTypeSpec) => readonly string[];
8
+ /** Scalar and one-element list both mean "exactly this type". */
9
+ export declare const wireTypeIs: (spec: WireTypeSpec | symbol | undefined, name: string) => boolean;
10
+ export declare const wireTypesCompatible: (source: WireTypeSpec, input: WireTypeSpec) => boolean;
11
+ /** `string | user-turn` for a union, the bare name for a scalar. */
12
+ export declare const formatWireType: (spec: WireTypeSpec | symbol) => string;
@@ -0,0 +1,18 @@
1
+ export const wireTypeList = (spec) => typeof spec === 'string' ? [spec] : spec;
2
+ /** Scalar and one-element list both mean "exactly this type". */
3
+ export const wireTypeIs = (spec, name) => {
4
+ if (spec === undefined || typeof spec === 'symbol') {
5
+ return false;
6
+ }
7
+ const list = wireTypeList(spec);
8
+ return list.length === 1 && list[0] === name;
9
+ };
10
+ export const wireTypesCompatible = (source, input) => {
11
+ const sourceList = wireTypeList(source);
12
+ const inputList = wireTypeList(input);
13
+ return (sourceList.includes('any') ||
14
+ inputList.includes('any') ||
15
+ sourceList.some((type) => inputList.includes(type)));
16
+ };
17
+ /** `string | user-turn` for a union, the bare name for a scalar. */
18
+ export const formatWireType = (spec) => typeof spec === 'symbol' ? String(spec) : wireTypeList(spec).join(' | ');
@@ -38,7 +38,9 @@ contract.
38
38
  - `my-nodes/git-diff-tool.ts` — `defineToolRegistrations`; emits `git_diff`
39
39
  ToolHandle for agent `tools` ports (on demand).
40
40
  - `my-nodes/review-gate.ts` — `defineReactiveNode`; runs `npm run test`,
41
- emits on **`ok`** or **`fail`** independently.
41
+ emits on **`ok`** or **`fail`** independently. `fail` text that feeds
42
+ an agent must be filtered to failures (failing names, diffs, formatter
43
+ errors), not the raw test or formatter log.
42
44
 
43
45
  `git-diff` / `git-diff-tool` use `child_process` until a shell Cap exists on
44
46
  `ExecutionContext`.
@@ -141,7 +141,7 @@ For comparison, **KB manual search** stops after showing retrieved hits.
141
141
  ### Not in this sample
142
142
 
143
143
  - **Reranking** with a second model to remove weak results before building
144
- Context (TBD-009 in `docs/TBD.md`).
144
+ Context (TBD-009 in `docs/_work/TBD.md`).
145
145
  - **HyDE or query rewriting** to improve retrieval for vague questions.
146
146
  - **Overlapping or token-window chunks** for documents that do not divide
147
147
  cleanly at headings.
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "peerDependencies": {
7
- "@langflower/node-sdk": "0.1.0",
7
+ "@langflower/node-sdk": "0.2.0",
8
8
  "@rx-evo/stateful-observable": "^0.6.0",
9
9
  "rxjs": "^7.8.1"
10
10
  }
@@ -200,6 +200,18 @@ export default defineReactiveNode({
200
200
  If the product needs independent `ok` and `fail` wires, **always** choose
201
201
  `defineReactiveNode`. Do not “simplify” to `defineNode`.
202
202
 
203
+ ### `fail` is agent feedback — failures only
204
+
205
+ `fail` is usually wired to an LLM `feedback` port. Raw test and formatter
206
+ output does not belong there. Filter it to failures before emit:
207
+
208
+ - keep failing test names, assertion diffs, and formatter error lines
209
+ - drop passing suites, progress, and full file dumps
210
+ - a green formatter or a passing test emits nothing on `fail`
211
+
212
+ A length cap on the raw log is not a filter. The kept text is still
213
+ mostly noise and bloats the next agent turn.
214
+
203
215
  ## Why TypeScript
204
216
 
205
217
  TypeScript is your friend: it catches many mistakes in the **IDE** and at
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "peerDependencies": {
7
- "@langflower/node-sdk": "0.1.0",
7
+ "@langflower/node-sdk": "0.2.0",
8
8
  "@rx-evo/stateful-observable": "^0.6.0",
9
9
  "rxjs": "^7.8.1"
10
10
  }
@@ -37,6 +37,11 @@ type GateResult =
37
37
  * Hard QA gate: runs `npm run test` in `ctx.projectDir`.
38
38
  * Pass → emit on `ok`. Fail → emit on `fail` (independent ports).
39
39
  *
40
+ * `fail` is agent feedback. Filter test and formatter output to
41
+ * failures (names, diffs, error lines) before it is emitted. Passing
42
+ * suites and progress bloat the next turn. A length cap is not that
43
+ * filter.
44
+ *
40
45
  * `defineReactiveNode` is required here: `defineNode` cannot emit on one
41
46
  * output and stay silent on the other.
42
47
  *