langflower 0.0.7 → 0.0.9

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 (189) hide show
  1. package/package.json +1 -1
  2. package/ui-dist/{chunk-Y6VMBLSJ.js → chunk-7UMVYN3A.js} +1 -1
  3. package/ui-dist/{chunk-6DQ2XSRW.js → chunk-MDGXX73Z.js} +3 -3
  4. package/ui-dist/index.html +1 -1
  5. package/ui-dist/main-2JJGCNTD.js +313 -0
  6. package/vendor/common-nodes/dist/ai/chat-completion-stream.d.ts +2 -0
  7. package/vendor/common-nodes/dist/ai/critique/node.d.ts +246 -0
  8. package/vendor/common-nodes/dist/ai/critique/node.js +2 -2
  9. package/vendor/common-nodes/dist/ai/fake-llm/node.d.ts +246 -0
  10. package/vendor/common-nodes/dist/ai/features/chat-completion-stream.d.ts +53 -0
  11. package/vendor/common-nodes/dist/ai/features/chat-completion-stream.js +1 -0
  12. package/vendor/common-nodes/dist/ai/features/llm-loop/autokick-recovery.d.ts +13 -0
  13. package/vendor/common-nodes/dist/ai/features/llm-loop/autokick-recovery.js +17 -0
  14. package/vendor/common-nodes/dist/ai/features/llm-loop/classify-llm-failure.d.ts +2 -0
  15. package/vendor/common-nodes/dist/ai/features/llm-loop/classify-llm-failure.js +113 -0
  16. package/vendor/common-nodes/dist/ai/features/llm-loop/dead-loop-detector.d.ts +28 -0
  17. package/vendor/common-nodes/dist/ai/features/llm-loop/dead-loop-detector.js +194 -0
  18. package/vendor/common-nodes/dist/ai/features/llm-loop/live-get-tools.d.ts +9 -0
  19. package/vendor/common-nodes/dist/ai/features/llm-loop/live-get-tools.js +21 -0
  20. package/vendor/common-nodes/dist/ai/features/llm-loop/llm-loop-reducer.d.ts +2 -0
  21. package/vendor/common-nodes/dist/ai/features/llm-loop/llm-loop-reducer.js +216 -0
  22. package/vendor/common-nodes/dist/ai/features/llm-loop/llm-loop-types.d.ts +125 -0
  23. package/vendor/common-nodes/dist/ai/features/llm-loop/llm-loop-types.js +39 -0
  24. package/vendor/common-nodes/dist/ai/features/llm-loop/normalize-llm-recovery-policy.d.ts +2 -0
  25. package/vendor/common-nodes/dist/ai/features/llm-loop/normalize-llm-recovery-policy.js +59 -0
  26. package/vendor/common-nodes/dist/ai/features/llm-loop/operators/normalize-tool-result.d.ts +1 -0
  27. package/vendor/common-nodes/dist/ai/features/llm-loop/operators/normalize-tool-result.js +7 -0
  28. package/vendor/common-nodes/dist/ai/features/llm-loop/operators/observe-provider-stream.d.ts +43 -0
  29. package/vendor/common-nodes/dist/ai/features/llm-loop/operators/observe-provider-stream.js +96 -0
  30. package/vendor/common-nodes/dist/ai/features/llm-loop/run-agent-loop.d.ts +32 -0
  31. package/vendor/common-nodes/dist/ai/features/llm-loop/run-agent-loop.js +58 -0
  32. package/vendor/common-nodes/dist/ai/features/llm-loop/run-llm-loop.d.ts +80 -0
  33. package/vendor/common-nodes/dist/ai/features/llm-loop/run-llm-loop.js +681 -0
  34. package/vendor/common-nodes/dist/ai/features/llm-role-preset.d.ts +69 -0
  35. package/vendor/common-nodes/dist/ai/features/llm-role-preset.js +265 -0
  36. package/vendor/common-nodes/dist/ai/features/llm-session/llm-session-shell.d.ts +148 -0
  37. package/vendor/common-nodes/dist/ai/features/llm-session/llm-session-shell.js +198 -0
  38. package/vendor/common-nodes/dist/ai/features/llm-session/run-session-machine.d.ts +21 -0
  39. package/vendor/common-nodes/dist/ai/features/llm-session/run-session-machine.js +118 -0
  40. package/vendor/common-nodes/dist/ai/features/openai/context-length-error.d.ts +14 -0
  41. package/vendor/common-nodes/dist/ai/features/openai/context-length-error.js +63 -0
  42. package/vendor/common-nodes/dist/ai/features/openai/create-chat-completion-stream.d.ts +19 -0
  43. package/vendor/common-nodes/dist/ai/features/openai/create-chat-completion-stream.js +182 -0
  44. package/vendor/common-nodes/dist/ai/features/openai/list-provider-models.d.ts +28 -0
  45. package/vendor/common-nodes/dist/ai/features/openai/list-provider-models.js +52 -0
  46. package/vendor/common-nodes/dist/ai/features/openai/llm-context-compaction.d.ts +31 -0
  47. package/vendor/common-nodes/dist/ai/features/openai/llm-context-compaction.js +326 -0
  48. package/vendor/common-nodes/dist/ai/features/openai/normalize-compaction-params.d.ts +14 -0
  49. package/vendor/common-nodes/dist/ai/features/openai/normalize-compaction-params.js +21 -0
  50. package/vendor/common-nodes/dist/ai/features/openai/prepare-chat-completion.d.ts +30 -0
  51. package/vendor/common-nodes/dist/ai/features/openai/prepare-chat-completion.js +132 -0
  52. package/vendor/common-nodes/dist/ai/features/path-choice/control-tools.d.ts +20 -0
  53. package/vendor/common-nodes/dist/ai/features/path-choice/control-tools.js +70 -0
  54. package/vendor/common-nodes/dist/ai/features/path-choice/run-reactive-path-choice-loop.d.ts +35 -0
  55. package/vendor/common-nodes/dist/ai/features/path-choice/run-reactive-path-choice-loop.js +106 -0
  56. package/vendor/common-nodes/dist/ai/features/prompt/build-effective-system-prompt.d.ts +9 -0
  57. package/vendor/common-nodes/dist/ai/features/prompt/build-effective-system-prompt.js +21 -0
  58. package/vendor/common-nodes/dist/ai/features/prompt/normalize-max-iterations.d.ts +13 -0
  59. package/vendor/common-nodes/dist/ai/features/prompt/normalize-max-iterations.js +23 -0
  60. package/vendor/common-nodes/dist/ai/features/prompt/resolve-chat-provider-model.d.ts +10 -0
  61. package/vendor/common-nodes/dist/ai/features/prompt/resolve-chat-provider-model.js +8 -0
  62. package/vendor/common-nodes/dist/ai/features/run-host-services.d.ts +54 -0
  63. package/vendor/common-nodes/dist/ai/features/run-host-services.js +29 -0
  64. package/vendor/common-nodes/dist/ai/features/scripted-chat-completion-stream.d.ts +17 -0
  65. package/vendor/common-nodes/dist/ai/features/scripted-chat-completion-stream.js +61 -0
  66. package/vendor/common-nodes/dist/ai/features/sub-agent-protocol.d.ts +39 -0
  67. package/vendor/common-nodes/dist/ai/features/sub-agent-protocol.js +43 -0
  68. package/vendor/common-nodes/dist/ai/features/ui-schema/llm-compaction-ui-schema.d.ts +14 -0
  69. package/vendor/common-nodes/dist/ai/features/ui-schema/llm-compaction-ui-schema.js +18 -0
  70. package/vendor/common-nodes/dist/ai/features/ui-schema/llm-panel-ui-schema.d.ts +80 -0
  71. package/vendor/common-nodes/dist/ai/features/ui-schema/llm-panel-ui-schema.js +76 -0
  72. package/vendor/common-nodes/dist/ai/features/ui-schema/llm-recovery-ui-schema.d.ts +113 -0
  73. package/vendor/common-nodes/dist/ai/features/ui-schema/llm-recovery-ui-schema.js +131 -0
  74. package/vendor/common-nodes/dist/ai/features/wait-for-subagent-result.d.ts +6 -0
  75. package/vendor/common-nodes/dist/ai/features/wait-for-subagent-result.js +30 -0
  76. package/vendor/common-nodes/dist/ai/llm-loop/autokick-recovery.d.ts +13 -0
  77. package/vendor/common-nodes/dist/ai/llm-loop/autokick-recovery.js +17 -0
  78. package/vendor/common-nodes/dist/ai/llm-loop/dead-loop-detector.d.ts +28 -0
  79. package/vendor/common-nodes/dist/ai/llm-loop/dead-loop-detector.js +194 -0
  80. package/vendor/common-nodes/dist/ai/llm-loop/llm-loop-reducer.js +36 -0
  81. package/vendor/common-nodes/dist/ai/llm-loop/llm-loop-types.d.ts +35 -0
  82. package/vendor/common-nodes/dist/ai/llm-loop/llm-loop-types.js +19 -0
  83. package/vendor/common-nodes/dist/ai/llm-loop/normalize-llm-recovery-policy.js +52 -9
  84. package/vendor/common-nodes/dist/ai/llm-loop/operators/observe-provider-stream.d.ts +8 -2
  85. package/vendor/common-nodes/dist/ai/llm-loop/operators/observe-provider-stream.js +43 -13
  86. package/vendor/common-nodes/dist/ai/llm-loop/run-llm-loop.d.ts +3 -5
  87. package/vendor/common-nodes/dist/ai/llm-loop/run-llm-loop.js +116 -1
  88. package/vendor/common-nodes/dist/ai/llm-recovery-ui-schema.d.ts +82 -0
  89. package/vendor/common-nodes/dist/ai/llm-recovery-ui-schema.js +95 -0
  90. package/vendor/common-nodes/dist/ai/llm-session-shell.d.ts +4 -9
  91. package/vendor/common-nodes/dist/ai/llm-session-shell.js +2 -4
  92. package/vendor/common-nodes/dist/ai/nodes/critique/node.d.ts +588 -0
  93. package/vendor/common-nodes/dist/ai/nodes/critique/node.js +240 -0
  94. package/vendor/common-nodes/dist/ai/nodes/fake-llm/node.d.ts +571 -0
  95. package/vendor/common-nodes/dist/ai/nodes/fake-llm/node.js +208 -0
  96. package/vendor/common-nodes/dist/ai/nodes/openai-llm/node.d.ts +587 -0
  97. package/vendor/common-nodes/dist/ai/nodes/openai-llm/node.js +91 -0
  98. package/vendor/common-nodes/dist/ai/nodes/review/node.d.ts +593 -0
  99. package/vendor/common-nodes/dist/ai/nodes/review/node.js +240 -0
  100. package/vendor/common-nodes/dist/ai/nodes/sub-agent/node.d.ts +630 -0
  101. package/vendor/common-nodes/dist/ai/nodes/sub-agent/node.js +302 -0
  102. package/vendor/common-nodes/dist/ai/openai/create-chat-completion-stream.js +6 -0
  103. package/vendor/common-nodes/dist/ai/openai/prepare-chat-completion.d.ts +2 -0
  104. package/vendor/common-nodes/dist/ai/openai/prepare-chat-completion.js +18 -0
  105. package/vendor/common-nodes/dist/ai/openai-llm/node.d.ts +246 -0
  106. package/vendor/common-nodes/dist/ai/review/node.d.ts +246 -0
  107. package/vendor/common-nodes/dist/ai/review/node.js +2 -2
  108. package/vendor/common-nodes/dist/ai/sub-agent/node.d.ts +246 -0
  109. package/vendor/common-nodes/dist/ai/sub-agent/node.js +2 -2
  110. package/vendor/common-nodes/dist/catalog.js +7 -5
  111. package/vendor/common-nodes/dist/compile-custom-nodes/node.d.ts +21 -0
  112. package/vendor/common-nodes/dist/compile-custom-nodes/node.js +45 -0
  113. package/vendor/common-nodes/dist/crawl/crawl/node.js +1 -1
  114. package/vendor/common-nodes/dist/crawl/fetch-url/node.js +1 -1
  115. package/vendor/common-nodes/dist/flow/repeat/node.js +6 -1
  116. package/vendor/common-nodes/dist/langflower-tools/emit-registration-tools.d.ts +18 -0
  117. package/vendor/common-nodes/dist/langflower-tools/emit-registration-tools.js +29 -0
  118. package/vendor/common-nodes/dist/langflower-tools/node.d.ts +20 -0
  119. package/vendor/common-nodes/dist/langflower-tools/node.js +77 -0
  120. package/vendor/common-nodes/dist/text/append-file/node.js +1 -1
  121. package/vendor/common-nodes/dist/text/read-file/node.js +1 -1
  122. package/vendor/common-nodes/dist/text/write-file/node.js +1 -1
  123. package/vendor/common-nodes/dist/tools/inventory-tool-round.d.ts +2 -2
  124. package/vendor/common-nodes/package.json +10 -10
  125. package/vendor/compiler/dist/compile-project-nodes.d.ts +2 -1
  126. package/vendor/compiler/dist/compile-project-nodes.js +35 -6
  127. package/vendor/compiler/dist/resolve-host-types.d.ts +0 -5
  128. package/vendor/compiler/dist/resolve-host-types.js +0 -8
  129. package/vendor/node-sdk/dist/node-factory/define-llm-node/define-llm-node.d.ts +1 -1
  130. package/vendor/node-sdk/dist/node-factory/define-llm-node/define-llm-node.js +1 -1
  131. package/vendor/node-sdk/dist/node-factory/define-llm-node/recovery-notice.d.ts +8 -0
  132. package/vendor/node-sdk/dist/node-factory/define-llm-node/recovery-notice.js +14 -0
  133. package/vendor/runtime/dist/runtime-editor.d.ts +5 -1
  134. package/vendor/runtime/dist/runtime-editor.js +19 -0
  135. package/vendor/runtime/dist/runtime-runner.js +17 -17
  136. package/vendor/runtime/dist/runtime.d.ts +2 -1
  137. package/vendor/runtime/dist/runtime.js +1 -0
  138. package/vendor/runtime/dist/testing/workflows/workflow-events.d.ts +8 -6
  139. package/vendor/runtime/dist/testing/workflows/workflow-events.js +19 -31
  140. package/vendor/runtime/dist/types.d.ts +33 -38
  141. package/vendor/runtime/dist/types.js +2 -1
  142. package/vendor/server/dist/bridge/attach-langflower-bridge.js +3 -2
  143. package/vendor/server/dist/bridge/bridge-event-log.js +17 -102
  144. package/vendor/server/dist/bridge/build-execution-context.d.ts +5 -2
  145. package/vendor/server/dist/bridge/build-execution-context.js +45 -5
  146. package/vendor/server/dist/bridge/forward-runner-event.d.ts +1 -1
  147. package/vendor/server/dist/bridge/forward-runner-event.js +7 -12
  148. package/vendor/server/dist/bridge/get-live-wired-tools.d.ts +12 -0
  149. package/vendor/server/dist/bridge/get-live-wired-tools.js +80 -0
  150. package/vendor/server/dist/bridge/langflower-tools-rpc.d.ts +7 -0
  151. package/vendor/server/dist/bridge/langflower-tools-rpc.js +29 -0
  152. package/vendor/server/dist/bridge/settings-draft-controller.js +26 -3
  153. package/vendor/server/dist/bridge/wire-custom-palette-handlers.d.ts +2 -1
  154. package/vendor/server/dist/bridge/wire-custom-palette-handlers.js +3 -5
  155. package/vendor/server/dist/bridge/wire-runner-handlers.js +15 -8
  156. package/vendor/server/dist/checkpoint/run-checkpoint-session.d.ts +1 -1
  157. package/vendor/server/dist/checkpoint/run-checkpoint-session.js +10 -9
  158. package/vendor/server/dist/palette/compile-and-hot-swap-custom-nodes.d.ts +10 -0
  159. package/vendor/server/dist/palette/compile-and-hot-swap-custom-nodes.js +23 -0
  160. package/vendor/server/dist/workflow/apply-editor-mutation.d.ts +5 -0
  161. package/vendor/server/dist/workflow/apply-editor-mutation.js +32 -0
  162. package/vendor/server/skeleton/instructions.md +9 -5
  163. package/vendor/server/skeleton/nodes/my-nodes/README.md +4 -3
  164. package/vendor/server/skeleton/schemas/langflower-config.schema.json +11 -1
  165. package/vendor/server/skeleton/skills/langflower-helper/SKILL.md +49 -19
  166. package/vendor/server/skeleton/skills/langflower-helper/architecture.md +22 -9
  167. package/vendor/server/skeleton/skills/langflower-helper/layout.md +15 -15
  168. package/vendor/server/skeleton/skills/langflower-node-writer/SKILL.md +19 -9
  169. package/vendor/server/skeleton/skills/langflower-workflow-writer/SKILL.md +14 -10
  170. package/vendor/server/skeleton/workflows/starter.json +30 -3
  171. package/vendor/shared/dist/execution/derive-run-settle-outcome.d.ts +1 -1
  172. package/vendor/shared/dist/execution/derive-run-settle-outcome.js +4 -3
  173. package/vendor/shared/dist/execution/derive-run-settle-outcome.test.js +9 -9
  174. package/vendor/shared/dist/langflower-bus-config.d.ts +6 -14
  175. package/vendor/shared/dist/langflower-bus-config.js +4 -12
  176. package/vendor/shared/dist/langflower-config/resolve-wired-tool-options.js +6 -0
  177. package/vendor/shared/dist/langflower-config/resolve-wired-tool-options.test.js +30 -0
  178. package/vendor/shared/dist/langflower-ws-waits.d.ts +7 -14
  179. package/vendor/shared/dist/langflower-ws-waits.js +14 -14
  180. package/vendor/websocket-bridge/dist/bridge-codec.d.ts +1 -0
  181. package/vendor/websocket-bridge/dist/bridge-codec.js +11 -11
  182. package/vendor/websocket-bridge/dist/bridge-frame.js +1 -1
  183. package/vendor/websocket-bridge/dist/bridge-subjects.d.ts +1 -1
  184. package/vendor/websocket-bridge/dist/bridge-subjects.js +2 -2
  185. package/vendor/websocket-bridge/dist/bridge-types.d.ts +13 -1
  186. package/vendor/websocket-bridge/dist/create-client.js +3 -3
  187. package/vendor/websocket-bridge/dist/create-server.js +12 -6
  188. package/vendor/websocket-bridge/package.json +8 -0
  189. package/ui-dist/main-SMO3L7U5.js +0 -311
@@ -0,0 +1,106 @@
1
+ import { buildSpawnSubagentChatTool, parseToolArgs, previewToolLogText, toChatToolDefinitions, } from '../../../tools/inventory-tool-round.js';
2
+ import { DISABLED_COMPACTION_CONFIG } from '../openai/normalize-compaction-params.js';
3
+ import { DEFAULT_LLM_RECOVERY_POLICY, } from '../llm-loop/llm-loop-types.js';
4
+ import { runLlmLoop, } from '../llm-loop/run-llm-loop.js';
5
+ import { findControlToolCall, isReviewControlToolName, notesFromControlToolArgs, REVIEW_CHAT_TOOLS, REVIEW_TOOL_REMINDER, } from './control-tools.js';
6
+ const PATH_CHOICE_POLICY = {
7
+ decideCompletion: ({ state, text, toolCalls }) => {
8
+ // Pre-tool base — never mid-scan committedMessages (orphan tool_calls).
9
+ const base = state.roundCheckpoint;
10
+ const control = findControlToolCall(toolCalls);
11
+ if (control !== undefined) {
12
+ const notes = notesFromControlToolArgs(parseToolArgs(control.call.arguments));
13
+ const messages = [
14
+ ...base,
15
+ {
16
+ role: 'assistant',
17
+ content: text,
18
+ tool_calls: [control.call],
19
+ },
20
+ {
21
+ role: 'tool',
22
+ tool_call_id: control.call.id,
23
+ content: notes,
24
+ },
25
+ ];
26
+ return {
27
+ kind: 'complete',
28
+ chunks: [
29
+ { kind: 'historySync', messages },
30
+ {
31
+ kind: 'toolLog',
32
+ text: `→ ${control.call.name}(${previewToolLogText(control.call.arguments)})`,
33
+ },
34
+ control.kind === 'accept'
35
+ ? { kind: 'accept', notes }
36
+ : { kind: 'feedback', notes },
37
+ ],
38
+ };
39
+ }
40
+ const inventoryCalls = toolCalls.filter((call) => !isReviewControlToolName(call.name));
41
+ if (inventoryCalls.length > 0) {
42
+ return { kind: 'run-tools', calls: inventoryCalls };
43
+ }
44
+ const assistantContent = text.trim().length > 0
45
+ ? text
46
+ : '(no text; missing accept/feedback tool call)';
47
+ return {
48
+ kind: 'continue',
49
+ messages: [
50
+ ...base,
51
+ { role: 'assistant', content: assistantContent },
52
+ { role: 'user', content: REVIEW_TOOL_REMINDER },
53
+ ],
54
+ chunks: [
55
+ { kind: 'reminder', text: REVIEW_TOOL_REMINDER },
56
+ {
57
+ kind: 'toolLog',
58
+ text: `⚠ ${REVIEW_TOOL_REMINDER}`,
59
+ },
60
+ ],
61
+ };
62
+ },
63
+ toolNotAllowedText: (toolName) => `Tool «${toolName}» is not in the Review tools allowlist.`,
64
+ maxIterationsFailure: (maxIterations) => ({
65
+ kind: 'fail',
66
+ failure: {
67
+ kind: 'protocol',
68
+ message: `Review failed after ${maxIterations} completions ` +
69
+ 'without accept or feedback (forced tool use).',
70
+ recoverable: false,
71
+ },
72
+ }),
73
+ };
74
+ export const runPathChoiceToolLoop = (args) => {
75
+ const inventory = args.tools ?? [];
76
+ const subagentRegistrations = args.subagentRegistrations ?? [];
77
+ return runLlmLoop({
78
+ factory: args.factory,
79
+ providerId: args.providerId,
80
+ model: args.model,
81
+ messages: args.messages,
82
+ maxIterations: args.maxIterations,
83
+ inventoryTools: inventory,
84
+ chatTools: [
85
+ ...REVIEW_CHAT_TOOLS,
86
+ ...toChatToolDefinitions(inventory),
87
+ ...(subagentRegistrations.length > 0
88
+ ? [buildSpawnSubagentChatTool(subagentRegistrations)]
89
+ : []),
90
+ ],
91
+ compaction: args.compaction ?? DISABLED_COMPACTION_CONFIG,
92
+ recovery: args.recovery ?? DEFAULT_LLM_RECOVERY_POLICY,
93
+ policy: PATH_CHOICE_POLICY,
94
+ subagentRegistrations,
95
+ ...(args.harness !== undefined ? { harness: args.harness } : {}),
96
+ ...(args.toolCtx !== undefined ? { toolCtx: args.toolCtx } : {}),
97
+ ...(args.steerControl$ !== undefined
98
+ ? { steerControl$: args.steerControl$ }
99
+ : {}),
100
+ ...(args.waitForSubagentResult !== undefined
101
+ ? {
102
+ waitForSubagentResult: args.waitForSubagentResult,
103
+ }
104
+ : {}),
105
+ });
106
+ };
@@ -0,0 +1,9 @@
1
+ import { type LlmRolePreset } from '../llm-role-preset.js';
2
+ export type BuildEffectiveSystemPromptInput = {
3
+ readonly rolePreset: LlmRolePreset;
4
+ readonly systemPromptInput: string;
5
+ readonly agentsMarkdown: string;
6
+ readonly skillMarkdown: string;
7
+ };
8
+ /** Merges panel/input system text with optional AGENTS.md + skill markdown (no FS). */
9
+ export declare const buildEffectiveSystemPrompt: (input: BuildEffectiveSystemPromptInput) => string;
@@ -0,0 +1,21 @@
1
+ import { LLM_ROLE_PRESET_DEFAULTS, } from '../llm-role-preset.js';
2
+ /** Merges panel/input system text with optional AGENTS.md + skill markdown (no FS). */
3
+ export const buildEffectiveSystemPrompt = (input) => {
4
+ const preset = LLM_ROLE_PRESET_DEFAULTS[input.rolePreset];
5
+ const base = input.systemPromptInput.trim() !== ''
6
+ ? input.systemPromptInput.trim()
7
+ : preset.systemPrompt.trim();
8
+ const parts = [];
9
+ if (base !== '') {
10
+ parts.push(base);
11
+ }
12
+ const agents = input.agentsMarkdown.trim();
13
+ if (agents !== '') {
14
+ parts.push(agents);
15
+ }
16
+ const skill = input.skillMarkdown.trim();
17
+ if (skill !== '') {
18
+ parts.push(skill);
19
+ }
20
+ return parts.join('\n\n---\n\n');
21
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Normalize Inspector / param `maxIterations`.
3
+ * `0` = unlimited; invalid / negative → `fallback`; positive → floor + `maxCap`.
4
+ */
5
+ export declare const normalizeMaxIterations: (value: unknown, options: {
6
+ readonly fallback: number;
7
+ readonly maxCap: number;
8
+ }) => number;
9
+ /** Soft upper bound only — Inspector lets users raise freely. */
10
+ export declare const AGENT_MAX_ITERATIONS_CAP: number;
11
+ export declare const PATH_CHOICE_MAX_ITERATIONS_CAP: number;
12
+ export declare const DEFAULT_AGENT_MAX_ITERATIONS = 100;
13
+ export declare const DEFAULT_PATH_CHOICE_MAX_ITERATIONS = 5;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Normalize Inspector / param `maxIterations`.
3
+ * `0` = unlimited; invalid / negative → `fallback`; positive → floor + `maxCap`.
4
+ */
5
+ export const normalizeMaxIterations = (value, options) => {
6
+ const n = typeof value === 'number' ? value : Number(value);
7
+ if (!Number.isFinite(n) || n < 0) {
8
+ return options.fallback;
9
+ }
10
+ if (n === 0) {
11
+ return 0;
12
+ }
13
+ const floored = Math.floor(n);
14
+ if (floored < 1) {
15
+ return options.fallback;
16
+ }
17
+ return Math.min(options.maxCap, floored);
18
+ };
19
+ /** Soft upper bound only — Inspector lets users raise freely. */
20
+ export const AGENT_MAX_ITERATIONS_CAP = Number.MAX_SAFE_INTEGER;
21
+ export const PATH_CHOICE_MAX_ITERATIONS_CAP = Number.MAX_SAFE_INTEGER;
22
+ export const DEFAULT_AGENT_MAX_ITERATIONS = 100;
23
+ export const DEFAULT_PATH_CHOICE_MAX_ITERATIONS = 5;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Resolve chat provider/model from node params with optional host default
3
+ * (`LangflowerConfig.model` parsed into {@link RunHostServices.defaultChat}).
4
+ */
5
+ import type { RunHostServices } from '../run-host-services.js';
6
+ export type ResolvedChatProviderModel = {
7
+ readonly providerId: string;
8
+ readonly model: string;
9
+ };
10
+ export declare const resolveChatProviderModel: (params: Readonly<Record<string, unknown>>, host: RunHostServices | undefined) => ResolvedChatProviderModel;
@@ -0,0 +1,8 @@
1
+ export const resolveChatProviderModel = (params, host) => {
2
+ const fromParamsProvider = String(params['providerId'] ?? '').trim();
3
+ const fromParamsModel = String(params['model'] ?? '').trim();
4
+ return {
5
+ providerId: fromParamsProvider || host?.defaultChat?.providerId || '',
6
+ model: fromParamsModel || host?.defaultChat?.model || '',
7
+ };
8
+ };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Server/runtime-only bag attached via {@link runHostServicesSymbol}.
3
+ * Not part of public ExecutionContext — specialized LLM wiring closes over
4
+ * this, not author Caps.
5
+ */
6
+ import type { ToolHandle } from '@langflower/node-sdk';
7
+ import type { ToolInvokeCall } from '@langflower/tools/create-project-harness';
8
+ import type { ToolHandlerContext } from '@langflower/tools/domain-tool-configs';
9
+ import type { PermissionAskRequest } from '@langflower/tools/permission';
10
+ import type { CreateChatCompletionStream } from './chat-completion-stream.js';
11
+ export declare const runHostServicesSymbol: unique symbol;
12
+ export type LangflowerBusRequest = (intent: string, payload: unknown) => Promise<unknown>;
13
+ export type RunHostServices = {
14
+ readonly createChatCompletionStream?: CreateChatCompletionStream;
15
+ readonly skillMarkdown?: string;
16
+ readonly agentsMarkdown?: string;
17
+ /**
18
+ * Parsed effective `LangflowerConfig.model` (`providerId/modelId`).
19
+ * Empty node `providerId` / `model` params fall back to these at run time.
20
+ */
21
+ readonly defaultChat?: {
22
+ readonly providerId: string;
23
+ readonly model: string;
24
+ };
25
+ readonly authorize?: (call: ToolInvokeCall) => Promise<'allow' | 'deny'>;
26
+ /**
27
+ * Direct HITL ask (tool gates + agent limit continue). Bypasses permission
28
+ * config / grant cache — always surfaces `runner.permission.ask`.
29
+ */
30
+ readonly requestPermission?: (request: PermissionAskRequest) => Promise<'allow' | 'deny'>;
31
+ readonly denyPaths?: readonly string[];
32
+ readonly allowedHosts?: readonly string[];
33
+ /**
34
+ * In-process bus RPC for Langflower Tools only (compile / later editor
35
+ * intents). Missing on LLM and other catalog nodes.
36
+ */
37
+ readonly requestLangflowerBus?: LangflowerBusRequest;
38
+ /**
39
+ * Read current editor source `tools` outputs for this agent (post-swap).
40
+ * Missing outside a Langflower server run.
41
+ */
42
+ readonly getLiveWiredTools?: (agentNodeId: string) => readonly ToolHandle[];
43
+ };
44
+ export declare const attachRunHostServices: <T extends object>(ctx: T, services: RunHostServices) => T;
45
+ export declare const getRunHostServices: (ctx: object) => RunHostServices | undefined;
46
+ /**
47
+ * LLM `toolCtx`: identity + permission/path fields only.
48
+ * Does **not** attach {@link RunHostServices} — bus RPC and live inventory
49
+ * stay on the tools / LLM node ExecutionContext, not on agent invoke ctx.
50
+ */
51
+ export declare const buildAgentToolCtx: (identity: {
52
+ readonly projectDir: string;
53
+ readonly runId: string;
54
+ }, hostServices: RunHostServices | undefined) => ToolHandlerContext;
@@ -0,0 +1,29 @@
1
+ export const runHostServicesSymbol = Symbol('langflower.runHostServices');
2
+ export const attachRunHostServices = (ctx, services) => Object.assign(ctx, {
3
+ [runHostServicesSymbol]: services,
4
+ });
5
+ export const getRunHostServices = (ctx) => {
6
+ const bag = ctx[runHostServicesSymbol];
7
+ if (bag === undefined || typeof bag !== 'object' || bag === null) {
8
+ return undefined;
9
+ }
10
+ return bag;
11
+ };
12
+ /**
13
+ * LLM `toolCtx`: identity + permission/path fields only.
14
+ * Does **not** attach {@link RunHostServices} — bus RPC and live inventory
15
+ * stay on the tools / LLM node ExecutionContext, not on agent invoke ctx.
16
+ */
17
+ export const buildAgentToolCtx = (identity, hostServices) => ({
18
+ projectDir: identity.projectDir,
19
+ runId: identity.runId,
20
+ ...(hostServices?.authorize !== undefined
21
+ ? { authorize: hostServices.authorize }
22
+ : {}),
23
+ ...(hostServices?.denyPaths !== undefined
24
+ ? { denyPaths: hostServices.denyPaths }
25
+ : {}),
26
+ ...(hostServices?.allowedHosts !== undefined
27
+ ? { allowedHosts: hostServices.allowedHosts }
28
+ : {}),
29
+ });
@@ -0,0 +1,17 @@
1
+ import type { CreateChatCompletionStream } from './chat-completion-stream.js';
2
+ type ScriptedToolCall = {
3
+ readonly name: string;
4
+ readonly arguments?: unknown;
5
+ };
6
+ export type ScriptedTurn = {
7
+ readonly toolCalls: readonly ScriptedToolCall[];
8
+ } | {
9
+ readonly text: string;
10
+ };
11
+ export declare const parseScriptedTurns: (value: unknown) => readonly ScriptedTurn[] | undefined;
12
+ /**
13
+ * Deterministic `CreateChatCompletionStream` for CI / demos. Cursor advances
14
+ * across calls so multi-turn scripts keep working in one session.
15
+ */
16
+ export declare const createScriptedFactory: (turns: readonly ScriptedTurn[]) => CreateChatCompletionStream;
17
+ export {};
@@ -0,0 +1,61 @@
1
+ export const parseScriptedTurns = (value) => {
2
+ if (!Array.isArray(value) || value.length === 0) {
3
+ return undefined;
4
+ }
5
+ const turns = [];
6
+ for (const item of value) {
7
+ if (item === null || typeof item !== 'object') {
8
+ continue;
9
+ }
10
+ const record = item;
11
+ if (Array.isArray(record.toolCalls)) {
12
+ const toolCalls = record.toolCalls
13
+ .filter((call) => call !== null &&
14
+ typeof call === 'object' &&
15
+ typeof call.name === 'string')
16
+ .map((call) => ({
17
+ name: call.name,
18
+ ...(call.arguments !== undefined
19
+ ? { arguments: call.arguments }
20
+ : {}),
21
+ }));
22
+ turns.push({ toolCalls });
23
+ continue;
24
+ }
25
+ if (typeof record.text === 'string') {
26
+ turns.push({ text: record.text });
27
+ }
28
+ }
29
+ return turns.length > 0 ? turns : undefined;
30
+ };
31
+ /**
32
+ * Deterministic `CreateChatCompletionStream` for CI / demos. Cursor advances
33
+ * across calls so multi-turn scripts keep working in one session.
34
+ */
35
+ export const createScriptedFactory = (turns) => {
36
+ let index = 0;
37
+ return async () => {
38
+ const turn = turns[index] ?? { text: '' };
39
+ index += 1;
40
+ return (async function* () {
41
+ if ('toolCalls' in turn) {
42
+ yield {
43
+ kind: 'done',
44
+ text: '',
45
+ tool_calls: turn.toolCalls.map((call, callIndex) => ({
46
+ id: `script_${index}_${callIndex}`,
47
+ name: call.name,
48
+ arguments: typeof call.arguments === 'string'
49
+ ? call.arguments
50
+ : JSON.stringify(call.arguments ?? {}),
51
+ })),
52
+ };
53
+ return;
54
+ }
55
+ if (turn.text.length > 0) {
56
+ yield { kind: 'draft', text: turn.text };
57
+ }
58
+ yield { kind: 'done', text: turn.text };
59
+ })();
60
+ };
61
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Sub-Agent registration / spawn / result wire contracts (ADR-021 L0).
3
+ * Separate from `ToolHandle` — never part of agent tool inventory.
4
+ *
5
+ * Named wire types (not `json`) so RuntimeEditor connection checks reject
6
+ * unrelated structured payloads. Custom nodes:
7
+ * `import { SUBAGENT_RESULT_WIRE_TYPE, type SubAgentResultPayload } from
8
+ * '@langflower/common-nodes/ai/sub-agent-protocol'`.
9
+ */
10
+ /** Wire type strings owned by `@langflower/node-sdk` (`defineLlmNode`). */
11
+ export { SUBAGENT_REGISTRATION_WIRE_TYPE, SUBAGENT_RESULT_WIRE_TYPE, SUBAGENT_SPAWN_WIRE_TYPE, } from '@langflower/node-sdk/llm';
12
+ type SubAgentSkillAnnounce = {
13
+ readonly skillId: string;
14
+ readonly description: string;
15
+ };
16
+ /** On Sub-Agent `registration` out → main `subagentRegistration` in (combine). */
17
+ export type SubAgentRegistration = {
18
+ readonly targetNodeId: string;
19
+ readonly name: string;
20
+ readonly description: string;
21
+ readonly skills: readonly SubAgentSkillAnnounce[];
22
+ };
23
+ /** Main `subagent` out → Sub-Agent `task` in (fan-out; filter by nodeId). */
24
+ export type SubAgentSpawnPayload = {
25
+ readonly callId: string;
26
+ readonly nodeId: string;
27
+ /** Empty string when the main agent chose no skill. */
28
+ readonly skillId: string;
29
+ readonly task: string;
30
+ };
31
+ /** Sub-Agent `result` out → main `subagentResult` in (merge; router by callId). */
32
+ export type SubAgentResultPayload = {
33
+ readonly callId: string;
34
+ readonly result: string;
35
+ };
36
+ export declare const isSubAgentSpawnPayload: (value: unknown) => value is SubAgentSpawnPayload;
37
+ export declare const isSubAgentResultPayload: (value: unknown) => value is SubAgentResultPayload;
38
+ /** Flatten multi-wire combine values (single reg or arrays). */
39
+ export declare const flattenSubAgentRegistrations: (wired: unknown) => readonly SubAgentRegistration[];
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Sub-Agent registration / spawn / result wire contracts (ADR-021 L0).
3
+ * Separate from `ToolHandle` — never part of agent tool inventory.
4
+ *
5
+ * Named wire types (not `json`) so RuntimeEditor connection checks reject
6
+ * unrelated structured payloads. Custom nodes:
7
+ * `import { SUBAGENT_RESULT_WIRE_TYPE, type SubAgentResultPayload } from
8
+ * '@langflower/common-nodes/ai/sub-agent-protocol'`.
9
+ */
10
+ /** Wire type strings owned by `@langflower/node-sdk` (`defineLlmNode`). */
11
+ export { SUBAGENT_REGISTRATION_WIRE_TYPE, SUBAGENT_RESULT_WIRE_TYPE, SUBAGENT_SPAWN_WIRE_TYPE, } from '@langflower/node-sdk/llm';
12
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
13
+ const isSkillAnnounce = (value) => isRecord(value) &&
14
+ typeof value.skillId === 'string' &&
15
+ typeof value.description === 'string';
16
+ const isSubAgentRegistration = (value) => isRecord(value) &&
17
+ typeof value.targetNodeId === 'string' &&
18
+ typeof value.name === 'string' &&
19
+ typeof value.description === 'string' &&
20
+ Array.isArray(value.skills) &&
21
+ value.skills.every(isSkillAnnounce);
22
+ export const isSubAgentSpawnPayload = (value) => isRecord(value) &&
23
+ typeof value.callId === 'string' &&
24
+ typeof value.nodeId === 'string' &&
25
+ typeof value.skillId === 'string' &&
26
+ typeof value.task === 'string';
27
+ export const isSubAgentResultPayload = (value) => isRecord(value) &&
28
+ typeof value.callId === 'string' &&
29
+ typeof value.result === 'string';
30
+ /** Flatten multi-wire combine values (single reg or arrays). */
31
+ export const flattenSubAgentRegistrations = (wired) => {
32
+ const root = wired ?? [];
33
+ const list = Array.isArray(root) ? root : [root];
34
+ return list.flatMap((item) => {
35
+ if (Array.isArray(item)) {
36
+ return item.filter(isSubAgentRegistration);
37
+ }
38
+ if (isSubAgentRegistration(item)) {
39
+ return [item];
40
+ }
41
+ return [];
42
+ });
43
+ };
@@ -0,0 +1,14 @@
1
+ /** Shared Inspector fields for OpenAI-compatible chat compaction. */
2
+ export declare const llmCompactionUiSchema: readonly [{
3
+ readonly field: "contextSize";
4
+ readonly type: "number";
5
+ readonly label: "Context size (approx tokens)";
6
+ readonly default: 200000;
7
+ readonly min: 0;
8
+ readonly step: 1;
9
+ }, {
10
+ readonly field: "compactOnError";
11
+ readonly type: "boolean";
12
+ readonly label: "Compact on context error";
13
+ readonly default: false;
14
+ }];
@@ -0,0 +1,18 @@
1
+ import { DEFAULT_CONTEXT_SIZE } from '../openai/normalize-compaction-params.js';
2
+ /** Shared Inspector fields for OpenAI-compatible chat compaction. */
3
+ export const llmCompactionUiSchema = [
4
+ {
5
+ field: 'contextSize',
6
+ type: 'number',
7
+ label: 'Context size (approx tokens)',
8
+ default: DEFAULT_CONTEXT_SIZE,
9
+ min: 0,
10
+ step: 1,
11
+ },
12
+ {
13
+ field: 'compactOnError',
14
+ type: 'boolean',
15
+ label: 'Compact on context error',
16
+ default: false,
17
+ },
18
+ ];
@@ -0,0 +1,80 @@
1
+ export declare const llmMaxIterationsUiField: (defaultValue: number, maxCap: number) => {
2
+ readonly field: "maxIterations";
3
+ readonly type: "number";
4
+ readonly label: "Tool-loop max iterations per feedback turn (0 = unlimited)";
5
+ readonly default: number;
6
+ readonly min: 0;
7
+ readonly max: number;
8
+ readonly step: 1;
9
+ };
10
+ /**
11
+ * Shared Inspector panel floor for all LLM-family nodes (OpenAI, Fake,
12
+ * Sub-Agent, Review, Critique). Nodes may expand after this list; they must
13
+ * not omit these fields.
14
+ */
15
+ export declare const llmPanelUiSchema: readonly [{
16
+ readonly field: "rolePreset";
17
+ readonly type: "select";
18
+ readonly label: "Role preset";
19
+ readonly default: "custom";
20
+ readonly options: readonly [{
21
+ readonly value: "custom";
22
+ readonly title: "Custom";
23
+ }, {
24
+ readonly value: "plan";
25
+ readonly title: "Plan";
26
+ }, {
27
+ readonly value: "coder";
28
+ readonly title: "Coder";
29
+ }, {
30
+ readonly value: "explorer";
31
+ readonly title: "Explorer";
32
+ }];
33
+ }, {
34
+ readonly field: "providerId";
35
+ readonly type: "select";
36
+ readonly label: "Provider";
37
+ readonly optionsSource: "langflower.providers";
38
+ }, {
39
+ readonly field: "model";
40
+ readonly type: "select";
41
+ readonly label: "Model";
42
+ readonly optionsSource: "langflower.models";
43
+ readonly dependsOn: "providerId";
44
+ }, {
45
+ readonly field: "skillId";
46
+ readonly type: "select";
47
+ readonly label: "Skill";
48
+ readonly optionsSource: "langflower.skills";
49
+ }, {
50
+ readonly field: "includeAgentsMd";
51
+ readonly type: "boolean";
52
+ readonly label: "Include root AGENTS.md";
53
+ readonly default: false;
54
+ }, {
55
+ readonly field: "toolPermissions";
56
+ readonly type: "tool-permission-table";
57
+ readonly label: "Tool permissions";
58
+ readonly optionsSource: "node.wiredTools";
59
+ }, {
60
+ readonly field: "enabledMcpIds";
61
+ readonly type: "tool-id-list";
62
+ readonly label: "Enabled MCP";
63
+ readonly optionsSource: "langflower.mcpServers";
64
+ }, {
65
+ readonly field: "maxIterations";
66
+ readonly type: "number";
67
+ readonly label: "Tool-loop max iterations per feedback turn (0 = unlimited)";
68
+ readonly default: number;
69
+ readonly min: 0;
70
+ readonly max: number;
71
+ readonly step: 1;
72
+ }, {
73
+ readonly field: "maxFeedbackTurns";
74
+ readonly type: "number";
75
+ readonly label: "Max feedback turns (0 = unlimited)";
76
+ readonly default: 50;
77
+ readonly min: 0;
78
+ readonly max: number;
79
+ readonly step: 1;
80
+ }];
@@ -0,0 +1,76 @@
1
+ import { LLM_ROLE_PRESET_OPTIONS } from '../llm-role-preset.js';
2
+ import { AGENT_MAX_ITERATIONS_CAP, DEFAULT_AGENT_MAX_ITERATIONS, } from '../prompt/normalize-max-iterations.js';
3
+ /** Provider / Model / Skill — folded into {@link llmPanelUiSchema}. */
4
+ const llmProviderModelSkillUiSchema = [
5
+ {
6
+ field: 'providerId',
7
+ type: 'select',
8
+ label: 'Provider',
9
+ optionsSource: 'langflower.providers',
10
+ },
11
+ {
12
+ field: 'model',
13
+ type: 'select',
14
+ label: 'Model',
15
+ optionsSource: 'langflower.models',
16
+ dependsOn: 'providerId',
17
+ },
18
+ {
19
+ field: 'skillId',
20
+ type: 'select',
21
+ label: 'Skill',
22
+ optionsSource: 'langflower.skills',
23
+ },
24
+ ];
25
+ export const llmMaxIterationsUiField = (defaultValue, maxCap) => ({
26
+ field: 'maxIterations',
27
+ type: 'number',
28
+ label: 'Tool-loop max iterations per feedback turn (0 = unlimited)',
29
+ default: defaultValue,
30
+ min: 0,
31
+ max: maxCap,
32
+ step: 1,
33
+ });
34
+ /**
35
+ * Shared Inspector panel floor for all LLM-family nodes (OpenAI, Fake,
36
+ * Sub-Agent, Review, Critique). Nodes may expand after this list; they must
37
+ * not omit these fields.
38
+ */
39
+ export const llmPanelUiSchema = [
40
+ {
41
+ field: 'rolePreset',
42
+ type: 'select',
43
+ label: 'Role preset',
44
+ default: 'custom',
45
+ options: LLM_ROLE_PRESET_OPTIONS,
46
+ },
47
+ ...llmProviderModelSkillUiSchema,
48
+ {
49
+ field: 'includeAgentsMd',
50
+ type: 'boolean',
51
+ label: 'Include root AGENTS.md',
52
+ default: false,
53
+ },
54
+ {
55
+ field: 'toolPermissions',
56
+ type: 'tool-permission-table',
57
+ label: 'Tool permissions',
58
+ optionsSource: 'node.wiredTools',
59
+ },
60
+ {
61
+ field: 'enabledMcpIds',
62
+ type: 'tool-id-list',
63
+ label: 'Enabled MCP',
64
+ optionsSource: 'langflower.mcpServers',
65
+ },
66
+ llmMaxIterationsUiField(DEFAULT_AGENT_MAX_ITERATIONS, AGENT_MAX_ITERATIONS_CAP),
67
+ {
68
+ field: 'maxFeedbackTurns',
69
+ type: 'number',
70
+ label: 'Max feedback turns (0 = unlimited)',
71
+ default: 50,
72
+ min: 0,
73
+ max: AGENT_MAX_ITERATIONS_CAP,
74
+ step: 1,
75
+ },
76
+ ];