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,302 @@
1
+ import { defineLlmNode, isSteerControlPayload, toLlmRecoveryPortValue, } from '@langflower/node-sdk/llm';
2
+ import { concat, EMPTY, filter, mergeMap, Observable, of, } from 'rxjs';
3
+ import { llmPanelUiSchema } from '../../features/ui-schema/llm-panel-ui-schema.js';
4
+ import { llmCompactionUiSchema } from '../../features/ui-schema/llm-compaction-ui-schema.js';
5
+ import { llmRecoveryUiSchema } from '../../features/ui-schema/llm-recovery-ui-schema.js';
6
+ import { AGENT_MAX_ITERATIONS_CAP, DEFAULT_AGENT_MAX_ITERATIONS, normalizeMaxIterations, } from '../../features/prompt/normalize-max-iterations.js';
7
+ import { appendToolInventory, createLlmSessionCycle$, demuxByKind, } from '../../features/llm-session/llm-session-shell.js';
8
+ import { runAgentLoop, } from '../../features/llm-loop/run-agent-loop.js';
9
+ import { waitForSubagentResult } from '../../features/wait-for-subagent-result.js';
10
+ import { flattenSubAgentRegistrations, isSubAgentSpawnPayload, SUBAGENT_REGISTRATION_WIRE_TYPE, SUBAGENT_RESULT_WIRE_TYPE, SUBAGENT_SPAWN_WIRE_TYPE, } from '../../features/sub-agent-protocol.js';
11
+ import { collectAgentToolHandles } from '../../../tools/collect-agent-tool-handles.js';
12
+ import { parseLlmRolePreset, resolveEffectiveSkillId, } from '../../features/llm-role-preset.js';
13
+ import { resolveChatProviderModel } from '../../features/prompt/resolve-chat-provider-model.js';
14
+ import { getRunHostServices } from '../../features/run-host-services.js';
15
+ import { buildEffectiveSystemPrompt } from '../../features/prompt/build-effective-system-prompt.js';
16
+ import { normalizeCompactionConfig } from '../../features/openai/normalize-compaction-params.js';
17
+ import { normalizeLlmRecoveryPolicy } from '../../features/llm-loop/normalize-llm-recovery-policy.js';
18
+ import { createScriptedFactory, parseScriptedTurns, } from '../../features/scripted-chat-completion-stream.js';
19
+ const normalizeSkillIds = (raw) => {
20
+ if (!Array.isArray(raw)) {
21
+ return [];
22
+ }
23
+ return raw
24
+ .map((entry) => String(entry ?? '').trim())
25
+ .filter((entry) => entry.length > 0);
26
+ };
27
+ const acceptSpawn = (raw, nodeId, skillIds) => {
28
+ if (!isSubAgentSpawnPayload(raw)) {
29
+ return null;
30
+ }
31
+ if (raw.nodeId !== nodeId) {
32
+ return null;
33
+ }
34
+ if (raw.skillId.length > 0 && !skillIds.includes(raw.skillId)) {
35
+ return null;
36
+ }
37
+ return raw;
38
+ };
39
+ const formatSpawnUserContent = (spawn) => {
40
+ if (spawn.skillId.length === 0) {
41
+ return spawn.task;
42
+ }
43
+ return `[skill:${spawn.skillId}]\n${spawn.task}`;
44
+ };
45
+ const resolveTurnFactory = (context) => {
46
+ if (context.scriptedTurns !== undefined) {
47
+ return createScriptedFactory(context.scriptedTurns);
48
+ }
49
+ return context.factory;
50
+ };
51
+ const requireChatConfig = (providerId, model, scripted) => {
52
+ if (scripted) {
53
+ return;
54
+ }
55
+ if (providerId.trim().length === 0) {
56
+ throw new Error('Provider is required for Sub-Agent chat');
57
+ }
58
+ if (model.trim().length === 0) {
59
+ throw new Error('Model is required for Sub-Agent chat');
60
+ }
61
+ };
62
+ const runSubAgentTurn = (context, spawn, history, subagentResult$) => {
63
+ const scripted = context.scriptedTurns !== undefined;
64
+ const factory = resolveTurnFactory(context);
65
+ if (factory === undefined) {
66
+ return new Observable((subscriber) => {
67
+ subscriber.error(new Error('Sub-Agent chat is only available during server workflow runs'));
68
+ });
69
+ }
70
+ requireChatConfig(context.providerId, context.model, scripted);
71
+ return concat(of({
72
+ kind: 'historySync',
73
+ messages: [
74
+ ...history,
75
+ {
76
+ role: 'user',
77
+ content: formatSpawnUserContent(spawn),
78
+ },
79
+ ],
80
+ }), runAgentLoop({
81
+ factory,
82
+ providerId: scripted
83
+ ? context.providerId.trim() || 'scripted'
84
+ : context.providerId,
85
+ model: scripted
86
+ ? context.model.trim() || 'scripted'
87
+ : context.model,
88
+ messages: [
89
+ ...history,
90
+ { role: 'user', content: formatSpawnUserContent(spawn) },
91
+ ],
92
+ tools: context.tools,
93
+ toolCtx: context.toolCtx,
94
+ maxIterations: context.maxIterations,
95
+ compaction: context.compaction,
96
+ recovery: context.recovery,
97
+ subagentRegistrations: context.subagentRegistrations,
98
+ ...(context.requestPermission !== undefined
99
+ ? { requestPermission: context.requestPermission }
100
+ : {}),
101
+ ...(context.steerControl$ !== undefined
102
+ ? { steerControl$: context.steerControl$ }
103
+ : {}),
104
+ ...(context.subagentRegistrations.length > 0
105
+ ? {
106
+ waitForSubagentResult: (callId, signal) => waitForSubagentResult(subagentResult$, callId, signal, context.recovery.subagentTimeoutMs),
107
+ }
108
+ : {}),
109
+ }).pipe(mergeMap((chunk) => {
110
+ if (chunk.kind !== 'response') {
111
+ return of(chunk);
112
+ }
113
+ return of(chunk, {
114
+ kind: 'subagentResult',
115
+ payload: {
116
+ callId: spawn.callId,
117
+ result: chunk.text,
118
+ },
119
+ });
120
+ })));
121
+ };
122
+ /**
123
+ * Sub-Agent: ordinary OpenAI-compatible agent plus `registration` announce.
124
+ * Parent spawn arrives on `task`; final text returns on `result` with callId.
125
+ * @see docs/ADR.md ADR-021
126
+ */
127
+ export const subAgentNode = defineLlmNode({
128
+ type: 'common-sub-agent',
129
+ displayName: 'Sub-Agent',
130
+ category: 'AI',
131
+ description: 'OpenAI-compatible specialist agent that announces via registration and answers parent spawns on task → result.',
132
+ uiSchema: [
133
+ {
134
+ field: 'name',
135
+ type: 'string',
136
+ label: 'Name',
137
+ default: 'Sub-Agent',
138
+ },
139
+ {
140
+ field: 'description',
141
+ type: 'string',
142
+ label: 'Description',
143
+ default: '',
144
+ },
145
+ {
146
+ field: 'skillIds',
147
+ type: 'tool-id-list',
148
+ label: 'Skills',
149
+ optionsSource: 'langflower.skills',
150
+ },
151
+ ...llmPanelUiSchema,
152
+ ...llmCompactionUiSchema,
153
+ ...llmRecoveryUiSchema,
154
+ ],
155
+ bind(ctx, { makeInput, configureOutput, combineInputs }, inventory) {
156
+ const { tools, mcp, subagentRegistration, subagentResult, steerControl, } = inventory;
157
+ const systemPrompt = makeInput('systemPrompt', {
158
+ name: 'systemPrompt',
159
+ wireType: 'string',
160
+ inline: 'text-multiline',
161
+ defaultValue: '',
162
+ });
163
+ const task = makeInput('task', {
164
+ name: 'task',
165
+ wireType: SUBAGENT_SPAWN_WIRE_TYPE,
166
+ required: true,
167
+ });
168
+ const registration$ = combineInputs([ctx], ([ec]) => {
169
+ const skillIds = normalizeSkillIds(ec.params.skillIds);
170
+ const name = String(ec.params.name ?? 'Sub-Agent').trim();
171
+ const description = String(ec.params.description ?? '');
172
+ return {
173
+ targetNodeId: ec.nodeId,
174
+ name: name.length > 0 ? name : 'Sub-Agent',
175
+ description,
176
+ skills: skillIds.map((skillId) => ({
177
+ skillId,
178
+ description: skillId,
179
+ })),
180
+ };
181
+ });
182
+ const context$ = combineInputs([systemPrompt, tools, subagentRegistration, mcp, ctx], ([systemPromptValue, toolList, subagentList, mcpList, ec]) => {
183
+ const rolePreset = parseLlmRolePreset(ec.params.rolePreset);
184
+ const skillId = resolveEffectiveSkillId(rolePreset, ec.params.skillId);
185
+ const hostServices = getRunHostServices(ec);
186
+ const skillMarkdown = hostServices?.skillMarkdown ?? '';
187
+ const agentsMarkdown = hostServices?.agentsMarkdown ?? '';
188
+ return {
189
+ prompt: '',
190
+ tools: collectAgentToolHandles({
191
+ toolHandles: ec.toolHandles,
192
+ toolsPort: toolList,
193
+ mcpHandles: ec.mcpHandles,
194
+ mcpPort: mcpList,
195
+ }),
196
+ subagentRegistrations: flattenSubAgentRegistrations(subagentList),
197
+ ...resolveChatProviderModel(ec.params, hostServices),
198
+ skillId,
199
+ rolePreset,
200
+ skillMarkdown,
201
+ agentsMarkdown,
202
+ effectiveSystemPrompt: buildEffectiveSystemPrompt({
203
+ rolePreset,
204
+ systemPromptInput: String(systemPromptValue ?? ''),
205
+ agentsMarkdown,
206
+ skillMarkdown,
207
+ }),
208
+ toolCtx: {
209
+ projectDir: ec.projectDir,
210
+ runId: ec.runId,
211
+ ...(hostServices?.authorize !== undefined
212
+ ? { authorize: hostServices.authorize }
213
+ : {}),
214
+ ...(hostServices?.denyPaths !== undefined
215
+ ? { denyPaths: hostServices.denyPaths }
216
+ : {}),
217
+ ...(hostServices?.allowedHosts !== undefined
218
+ ? { allowedHosts: hostServices.allowedHosts }
219
+ : {}),
220
+ },
221
+ maxIterations: normalizeMaxIterations(ec.params.maxIterations, {
222
+ fallback: DEFAULT_AGENT_MAX_ITERATIONS,
223
+ maxCap: AGENT_MAX_ITERATIONS_CAP,
224
+ }),
225
+ maxFeedbackTurns: 0,
226
+ ...(hostServices?.requestPermission !== undefined
227
+ ? {
228
+ requestPermission: hostServices.requestPermission,
229
+ }
230
+ : {}),
231
+ compaction: normalizeCompactionConfig(ec.params),
232
+ recovery: normalizeLlmRecoveryPolicy(ec.params),
233
+ steerControl$: steerControl.value$.pipe(filter(isSteerControlPayload)),
234
+ factory: hostServices?.createChatCompletionStream,
235
+ scriptedTurns: parseScriptedTurns(ec.params['scriptedToolTurns']),
236
+ nodeId: ec.nodeId,
237
+ skillIds: normalizeSkillIds(ec.params.skillIds),
238
+ };
239
+ });
240
+ const cycle$ = createLlmSessionCycle$(context$, task.value$, (context) => ({
241
+ history: [
242
+ {
243
+ role: 'system',
244
+ content: appendToolInventory(context.effectiveSystemPrompt, context.tools),
245
+ },
246
+ ],
247
+ trackAssistantHistory: true,
248
+ appendUserFeedbackToHistory: false,
249
+ session: undefined,
250
+ }), (context, turnPayload, history, _session) => {
251
+ const spawn = acceptSpawn(turnPayload, context.nodeId, context.skillIds);
252
+ if (spawn === null) {
253
+ return EMPTY;
254
+ }
255
+ return runSubAgentTurn(context, spawn, history, subagentResult.value$);
256
+ }, { primeTurn0: false });
257
+ const reasoning$ = cycle$.pipeValue(demuxByKind('reasoning', (chunk) => chunk
258
+ .text));
259
+ const draftResponse$ = cycle$.pipeValue(demuxByKind('draftResponse', (chunk) => chunk
260
+ .text));
261
+ const toolLog$ = cycle$.pipeValue(demuxByKind('toolLog', (chunk) => chunk.text));
262
+ const recovery$ = cycle$.pipeValue(demuxByKind('recoveryNotice', (chunk) => {
263
+ const notice = chunk;
264
+ return toLlmRecoveryPortValue(notice);
265
+ }));
266
+ const response$ = cycle$.pipeValue(demuxByKind('response', (chunk) => chunk
267
+ .text));
268
+ const result$ = cycle$.pipeValue(demuxByKind('subagentResult', (chunk) => chunk.payload));
269
+ const nestedSubagent$ = cycle$.pipeValue(demuxByKind('subagentSpawn', (chunk) => chunk
270
+ .payload));
271
+ return {
272
+ inputs: [systemPrompt, task],
273
+ outputs: [
274
+ configureOutput('registration', registration$, {
275
+ wireType: SUBAGENT_REGISTRATION_WIRE_TYPE,
276
+ }),
277
+ configureOutput('reasoning', reasoning$, {
278
+ wireType: 'string',
279
+ feed: { role: 'reasoning', streaming: true },
280
+ }),
281
+ configureOutput('draftResponse', draftResponse$, {
282
+ wireType: 'string',
283
+ feed: { role: 'draft', streaming: true },
284
+ }),
285
+ configureOutput('response', response$, {
286
+ wireType: 'string',
287
+ feed: { role: 'result' },
288
+ }),
289
+ configureOutput('result', result$, {
290
+ wireType: SUBAGENT_RESULT_WIRE_TYPE,
291
+ // Protocol payload for parent wiring — not work-log content.
292
+ feed: { role: 'none' },
293
+ }),
294
+ ],
295
+ inventoryOutputs: {
296
+ toolLog$,
297
+ recovery$,
298
+ subagent$: nestedSubagent$,
299
+ },
300
+ };
301
+ },
302
+ });
@@ -124,6 +124,12 @@ export const createChatCompletionStream = (deps) => {
124
124
  messages: toOpenAiMessages(args.messages),
125
125
  stream: true,
126
126
  ...(tools !== undefined ? { tools } : {}),
127
+ ...(args.frequency_penalty !== undefined
128
+ ? { frequency_penalty: args.frequency_penalty }
129
+ : {}),
130
+ ...(args.presence_penalty !== undefined
131
+ ? { presence_penalty: args.presence_penalty }
132
+ : {}),
127
133
  }, {
128
134
  signal: args.signal,
129
135
  }));
@@ -25,4 +25,6 @@ export declare const prepareChatCompletion: (args: {
25
25
  readonly tools?: readonly ChatCompletionToolDefinition[];
26
26
  readonly signal?: AbortSignal;
27
27
  readonly compaction?: LlmCompactionConfig;
28
+ readonly frequency_penalty?: number;
29
+ readonly presence_penalty?: number;
28
30
  }) => Promise<PreparedChatCompletion>;
@@ -7,6 +7,12 @@ const createMainStream = async (args) => args.factory({
7
7
  messages: args.messages,
8
8
  ...(args.tools.length > 0 ? { tools: args.tools } : {}),
9
9
  ...(args.signal !== undefined ? { signal: args.signal } : {}),
10
+ ...(args.frequency_penalty !== undefined
11
+ ? { frequency_penalty: args.frequency_penalty }
12
+ : {}),
13
+ ...(args.presence_penalty !== undefined
14
+ ? { presence_penalty: args.presence_penalty }
15
+ : {}),
10
16
  });
11
17
  /**
12
18
  * Proactive + compact-on-error gate before consuming a chat stream.
@@ -49,6 +55,12 @@ export const prepareChatCompletion = async (args) => {
49
55
  messages,
50
56
  tools,
51
57
  ...(args.signal !== undefined ? { signal: args.signal } : {}),
58
+ ...(args.frequency_penalty !== undefined
59
+ ? { frequency_penalty: args.frequency_penalty }
60
+ : {}),
61
+ ...(args.presence_penalty !== undefined
62
+ ? { presence_penalty: args.presence_penalty }
63
+ : {}),
52
64
  });
53
65
  return {
54
66
  ok: true,
@@ -96,6 +108,12 @@ export const prepareChatCompletion = async (args) => {
96
108
  messages,
97
109
  tools,
98
110
  ...(args.signal !== undefined ? { signal: args.signal } : {}),
111
+ ...(args.frequency_penalty !== undefined
112
+ ? { frequency_penalty: args.frequency_penalty }
113
+ : {}),
114
+ ...(args.presence_penalty !== undefined
115
+ ? { presence_penalty: args.presence_penalty }
116
+ : {}),
99
117
  });
100
118
  return {
101
119
  ok: true,
@@ -115,6 +115,88 @@ export declare const openAiLlmNode: {
115
115
  readonly min: 0;
116
116
  readonly max: 32;
117
117
  readonly step: 1;
118
+ }, {
119
+ readonly field: "autokickOnIdle";
120
+ readonly type: "boolean";
121
+ readonly label: "Autokick on idle and dead-loop";
122
+ readonly default: boolean;
123
+ }, {
124
+ readonly field: "deadLoopEnabled";
125
+ readonly type: "boolean";
126
+ readonly label: "Detect repetition dead loops";
127
+ readonly default: boolean;
128
+ }, {
129
+ readonly field: "maxAutokickAttempts";
130
+ readonly type: "number";
131
+ readonly label: "Max autokick reconnects (0 = unlimited)";
132
+ readonly default: number;
133
+ readonly min: 0;
134
+ readonly max: 1000;
135
+ readonly step: 1;
136
+ }, {
137
+ readonly field: "autokickBackoffMs";
138
+ readonly type: "number";
139
+ readonly label: "Autokick backoff base (ms)";
140
+ readonly default: number;
141
+ readonly min: 1000;
142
+ readonly step: 1000;
143
+ }, {
144
+ readonly field: "autokickMaxBackoffMs";
145
+ readonly type: "number";
146
+ readonly label: "Autokick backoff clamp (ms)";
147
+ readonly default: number;
148
+ readonly min: 1000;
149
+ readonly step: 1000;
150
+ }, {
151
+ readonly field: "autokickUserMessage";
152
+ readonly type: "string";
153
+ readonly label: "Autokick kick message";
154
+ readonly default: string;
155
+ }, {
156
+ readonly field: "autokickPenaltyFrequency";
157
+ readonly type: "number";
158
+ readonly label: "Autokick frequency_penalty delta";
159
+ readonly default: number;
160
+ readonly min: -2;
161
+ readonly max: 2;
162
+ readonly step: 0.1;
163
+ }, {
164
+ readonly field: "autokickPenaltyPresence";
165
+ readonly type: "number";
166
+ readonly label: "Autokick presence_penalty delta";
167
+ readonly default: number;
168
+ readonly min: -2;
169
+ readonly max: 2;
170
+ readonly step: 0.1;
171
+ }, {
172
+ readonly field: "deadLoopMaxWindowTokens";
173
+ readonly type: "number";
174
+ readonly label: "Dead-loop window (tokens)";
175
+ readonly default: number;
176
+ readonly min: 10;
177
+ readonly max: 8000;
178
+ readonly step: 1;
179
+ }, {
180
+ readonly field: "deadLoopConsecutiveThreshold";
181
+ readonly type: "number";
182
+ readonly label: "Dead-loop consecutive identical deltas";
183
+ readonly default: number;
184
+ readonly min: 1;
185
+ readonly step: 1;
186
+ }, {
187
+ readonly field: "deadLoopMinRepetitions";
188
+ readonly type: "number";
189
+ readonly label: "Dead-loop cyclic repetitions";
190
+ readonly default: number;
191
+ readonly min: 1;
192
+ readonly step: 1;
193
+ }, {
194
+ readonly field: "deadLoopMinPatternTokens";
195
+ readonly type: "number";
196
+ readonly label: "Dead-loop min pattern tokens";
197
+ readonly default: number;
198
+ readonly min: 1;
199
+ readonly step: 1;
118
200
  }];
119
201
  readonly bypassPorts: Record<string, import("@langflower/node-sdk").WireType>;
120
202
  readonly inputsConfigs: readonly [import("@langflower/node-sdk").InputPortMeta<import("@langflower/node-sdk").ExecutionContext<readonly [{
@@ -223,6 +305,88 @@ export declare const openAiLlmNode: {
223
305
  readonly min: 0;
224
306
  readonly max: 32;
225
307
  readonly step: 1;
308
+ }, {
309
+ readonly field: "autokickOnIdle";
310
+ readonly type: "boolean";
311
+ readonly label: "Autokick on idle and dead-loop";
312
+ readonly default: boolean;
313
+ }, {
314
+ readonly field: "deadLoopEnabled";
315
+ readonly type: "boolean";
316
+ readonly label: "Detect repetition dead loops";
317
+ readonly default: boolean;
318
+ }, {
319
+ readonly field: "maxAutokickAttempts";
320
+ readonly type: "number";
321
+ readonly label: "Max autokick reconnects (0 = unlimited)";
322
+ readonly default: number;
323
+ readonly min: 0;
324
+ readonly max: 1000;
325
+ readonly step: 1;
326
+ }, {
327
+ readonly field: "autokickBackoffMs";
328
+ readonly type: "number";
329
+ readonly label: "Autokick backoff base (ms)";
330
+ readonly default: number;
331
+ readonly min: 1000;
332
+ readonly step: 1000;
333
+ }, {
334
+ readonly field: "autokickMaxBackoffMs";
335
+ readonly type: "number";
336
+ readonly label: "Autokick backoff clamp (ms)";
337
+ readonly default: number;
338
+ readonly min: 1000;
339
+ readonly step: 1000;
340
+ }, {
341
+ readonly field: "autokickUserMessage";
342
+ readonly type: "string";
343
+ readonly label: "Autokick kick message";
344
+ readonly default: string;
345
+ }, {
346
+ readonly field: "autokickPenaltyFrequency";
347
+ readonly type: "number";
348
+ readonly label: "Autokick frequency_penalty delta";
349
+ readonly default: number;
350
+ readonly min: -2;
351
+ readonly max: 2;
352
+ readonly step: 0.1;
353
+ }, {
354
+ readonly field: "autokickPenaltyPresence";
355
+ readonly type: "number";
356
+ readonly label: "Autokick presence_penalty delta";
357
+ readonly default: number;
358
+ readonly min: -2;
359
+ readonly max: 2;
360
+ readonly step: 0.1;
361
+ }, {
362
+ readonly field: "deadLoopMaxWindowTokens";
363
+ readonly type: "number";
364
+ readonly label: "Dead-loop window (tokens)";
365
+ readonly default: number;
366
+ readonly min: 10;
367
+ readonly max: 8000;
368
+ readonly step: 1;
369
+ }, {
370
+ readonly field: "deadLoopConsecutiveThreshold";
371
+ readonly type: "number";
372
+ readonly label: "Dead-loop consecutive identical deltas";
373
+ readonly default: number;
374
+ readonly min: 1;
375
+ readonly step: 1;
376
+ }, {
377
+ readonly field: "deadLoopMinRepetitions";
378
+ readonly type: "number";
379
+ readonly label: "Dead-loop cyclic repetitions";
380
+ readonly default: number;
381
+ readonly min: 1;
382
+ readonly step: 1;
383
+ }, {
384
+ readonly field: "deadLoopMinPatternTokens";
385
+ readonly type: "number";
386
+ readonly label: "Dead-loop min pattern tokens";
387
+ readonly default: number;
388
+ readonly min: 1;
389
+ readonly step: 1;
226
390
  }], import("@langflower/node-sdk/llm").LlmExecutionCaps>>, ...import("@langflower/node-sdk").InputPortMeta<unknown>[]];
227
391
  readonly outputsConfigs: (import("@langflower/node-sdk").OutputParams & import("@langflower/node-sdk").PortMeta)[];
228
392
  readonly getInstance: () => import("@langflower/node-sdk").ReactiveNodeInstance<readonly [{
@@ -331,6 +495,88 @@ export declare const openAiLlmNode: {
331
495
  readonly min: 0;
332
496
  readonly max: 32;
333
497
  readonly step: 1;
498
+ }, {
499
+ readonly field: "autokickOnIdle";
500
+ readonly type: "boolean";
501
+ readonly label: "Autokick on idle and dead-loop";
502
+ readonly default: boolean;
503
+ }, {
504
+ readonly field: "deadLoopEnabled";
505
+ readonly type: "boolean";
506
+ readonly label: "Detect repetition dead loops";
507
+ readonly default: boolean;
508
+ }, {
509
+ readonly field: "maxAutokickAttempts";
510
+ readonly type: "number";
511
+ readonly label: "Max autokick reconnects (0 = unlimited)";
512
+ readonly default: number;
513
+ readonly min: 0;
514
+ readonly max: 1000;
515
+ readonly step: 1;
516
+ }, {
517
+ readonly field: "autokickBackoffMs";
518
+ readonly type: "number";
519
+ readonly label: "Autokick backoff base (ms)";
520
+ readonly default: number;
521
+ readonly min: 1000;
522
+ readonly step: 1000;
523
+ }, {
524
+ readonly field: "autokickMaxBackoffMs";
525
+ readonly type: "number";
526
+ readonly label: "Autokick backoff clamp (ms)";
527
+ readonly default: number;
528
+ readonly min: 1000;
529
+ readonly step: 1000;
530
+ }, {
531
+ readonly field: "autokickUserMessage";
532
+ readonly type: "string";
533
+ readonly label: "Autokick kick message";
534
+ readonly default: string;
535
+ }, {
536
+ readonly field: "autokickPenaltyFrequency";
537
+ readonly type: "number";
538
+ readonly label: "Autokick frequency_penalty delta";
539
+ readonly default: number;
540
+ readonly min: -2;
541
+ readonly max: 2;
542
+ readonly step: 0.1;
543
+ }, {
544
+ readonly field: "autokickPenaltyPresence";
545
+ readonly type: "number";
546
+ readonly label: "Autokick presence_penalty delta";
547
+ readonly default: number;
548
+ readonly min: -2;
549
+ readonly max: 2;
550
+ readonly step: 0.1;
551
+ }, {
552
+ readonly field: "deadLoopMaxWindowTokens";
553
+ readonly type: "number";
554
+ readonly label: "Dead-loop window (tokens)";
555
+ readonly default: number;
556
+ readonly min: 10;
557
+ readonly max: 8000;
558
+ readonly step: 1;
559
+ }, {
560
+ readonly field: "deadLoopConsecutiveThreshold";
561
+ readonly type: "number";
562
+ readonly label: "Dead-loop consecutive identical deltas";
563
+ readonly default: number;
564
+ readonly min: 1;
565
+ readonly step: 1;
566
+ }, {
567
+ readonly field: "deadLoopMinRepetitions";
568
+ readonly type: "number";
569
+ readonly label: "Dead-loop cyclic repetitions";
570
+ readonly default: number;
571
+ readonly min: 1;
572
+ readonly step: 1;
573
+ }, {
574
+ readonly field: "deadLoopMinPatternTokens";
575
+ readonly type: "number";
576
+ readonly label: "Dead-loop min pattern tokens";
577
+ readonly default: number;
578
+ readonly min: 1;
579
+ readonly step: 1;
334
580
  }], import("@langflower/node-sdk/llm").LlmExecutionCaps>;
335
581
  readonly paletteSecondary?: true;
336
582
  readonly description?: string;