@valerypopoff/rivet2-core 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bundle.cjs +1800 -753
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/interpolationRuntime.cjs +1578 -0
- package/dist/cjs/interpolationRuntime.cjs.map +7 -0
- package/dist/cjs/interpolationSyntax.cjs +186 -0
- package/dist/cjs/interpolationSyntax.cjs.map +7 -0
- package/dist/cjs/webAppRuntime.cjs.map +2 -2
- package/dist/esm/exports.js +2 -1
- package/dist/esm/integrations/CodeRunner.js +5 -0
- package/dist/esm/integrations/mcp/MCPBase.js +16 -6
- package/dist/esm/interpolationRuntime.js +5 -0
- package/dist/esm/model/AgentResponseTrace.js +8 -3
- package/dist/esm/model/GraphBoundaryCache.js +0 -6
- package/dist/esm/model/GraphBoundaryEffects.js +5 -1
- package/dist/esm/model/GraphOutputSelection.js +34 -0
- package/dist/esm/model/GraphProcessor.js +177 -50
- package/dist/esm/model/ProcessContextBuilder.js +4 -1
- package/dist/esm/model/RecordingPlayer.js +46 -14
- package/dist/esm/model/SplitRunProcessor.js +37 -16
- package/dist/esm/model/StoredValueStore.js +4 -3
- package/dist/esm/model/UiGraphRendererStyles.js +20 -0
- package/dist/esm/model/chat/aiSdkStreaming.js +3 -2
- package/dist/esm/model/chat-v2/aiSdkBridge.js +63 -5
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +66 -3
- package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +20 -7
- package/dist/esm/model/chat-v2/llmProfileFallback.js +12 -4
- package/dist/esm/model/nodes/CodeNewNode.js +16 -16
- package/dist/esm/model/nodes/DestructureNode.js +2 -2
- package/dist/esm/model/nodes/ExpressionNode.js +16 -16
- package/dist/esm/model/nodes/ExtractObjectPathNode.js +2 -2
- package/dist/esm/model/nodes/ExtractYamlNode.js +5 -5
- package/dist/esm/model/nodes/JSFilterNode.js +3 -1
- package/dist/esm/model/nodes/JSMapNode.js +3 -1
- package/dist/esm/model/nodes/LLMChatV2Node.js +30 -4
- package/dist/esm/model/nodes/MCPGetPromptNode.js +6 -2
- package/dist/esm/model/nodes/MCPToolCallNode.js +6 -2
- package/dist/esm/model/nodes/ObjectNode.js +19 -20
- package/dist/esm/model/nodes/PromptNode.js +10 -11
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +2 -40
- package/dist/esm/model/nodes/SubGraphNode.js +40 -26
- package/dist/esm/model/nodes/TextNode.js +11 -32
- package/dist/esm/model/nodes/ToTreeNode.js +6 -13
- package/dist/esm/model/nodes/ToolNode.js +33 -16
- package/dist/esm/model/nodes/jsListCallbackHelpers.js +19 -15
- package/dist/esm/model/nodes/jsValueInterpolation.js +83 -30
- package/dist/esm/model/nodes/nodeBodyPreview.js +23 -0
- package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +14 -11
- package/dist/esm/recording/ExecutionRecorder.js +55 -23
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/interpolation.js +478 -221
- package/dist/esm/utils/interpolationSyntax.js +175 -0
- package/dist/esm/utils/jsonPath.js +129 -0
- package/dist/types/exports.d.ts +3 -1
- package/dist/types/integrations/CodeRunnerOptions.d.ts +9 -0
- package/dist/types/integrations/mcp/MCPBase.d.ts +3 -1
- package/dist/types/interpolationRuntime.d.ts +5 -0
- package/dist/types/model/AgentResponseTrace.d.ts +2 -0
- package/dist/types/model/ExecutorProtocol.d.ts +4 -0
- package/dist/types/model/GraphBoundaryCache.d.ts +0 -2
- package/dist/types/model/GraphOutputSelection.d.ts +8 -0
- package/dist/types/model/GraphProcessor.d.ts +12 -3
- package/dist/types/model/ProcessContext.d.ts +9 -2
- package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
- package/dist/types/model/SplitRunProcessor.d.ts +2 -1
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/chat/aiSdkStreaming.d.ts +1 -1
- package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +1 -1
- package/dist/types/model/chat-v2/chatV2Types.d.ts +29 -0
- package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +5 -1
- package/dist/types/model/nodes/ObjectNode.d.ts +1 -1
- package/dist/types/model/nodes/SubGraphNode.d.ts +2 -0
- package/dist/types/model/nodes/ToTreeNode.d.ts +5 -2
- package/dist/types/model/nodes/ToolNode.d.ts +13 -1
- package/dist/types/model/nodes/jsValueInterpolation.d.ts +16 -8
- package/dist/types/model/nodes/nodeBodyPreview.d.ts +7 -0
- package/dist/types/recording/ExecutionRecorder.d.ts +6 -1
- package/dist/types/recording/RecordedEvents.d.ts +2 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/interpolation.d.ts +93 -8
- package/dist/types/utils/interpolationSyntax.d.ts +21 -0
- package/dist/types/utils/jsonPath.d.ts +15 -0
- package/package.json +11 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {} from '../../../index.js';
|
|
2
|
-
import { newId, coerceTypeOptional, getInputOrData
|
|
3
|
-
import {
|
|
2
|
+
import { newId, coerceTypeOptional, getInputOrData } from '../../../utils/index.js';
|
|
3
|
+
import { extractInterpolationVariableReferences, interpolate } from '../../../utils/interpolation.js';
|
|
4
4
|
import { pluginNodeDefinition } from '../../../model/NodeDefinition.js';
|
|
5
|
-
import { mapValues } from 'lodash-es';
|
|
6
5
|
import { createInterpolationInputDefinition } from '../../../model/interpolationInputDefinition.js';
|
|
7
6
|
export const ThreadMessageNodeImpl = {
|
|
8
7
|
create() {
|
|
@@ -56,16 +55,19 @@ export const ThreadMessageNodeImpl = {
|
|
|
56
55
|
required: false,
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
|
-
const
|
|
58
|
+
const inputReferences = extractInterpolationVariableReferences(data.text);
|
|
59
|
+
const fixedInputIds = new Set(inputs.map((input) => input.id));
|
|
60
60
|
inputs = [
|
|
61
61
|
...inputs,
|
|
62
|
-
...
|
|
62
|
+
...inputReferences
|
|
63
|
+
.filter(({ baseName }) => !fixedInputIds.has(baseName))
|
|
64
|
+
.map(({ baseName, hasPath }) => {
|
|
63
65
|
return createInterpolationInputDefinition({
|
|
64
|
-
interpolationName:
|
|
65
|
-
dataType: 'string',
|
|
66
|
+
interpolationName: baseName,
|
|
67
|
+
dataType: hasPath ? 'any' : 'string',
|
|
66
68
|
required: false,
|
|
67
69
|
});
|
|
68
|
-
})
|
|
70
|
+
}),
|
|
69
71
|
];
|
|
70
72
|
return inputs;
|
|
71
73
|
},
|
|
@@ -113,7 +115,7 @@ export const ThreadMessageNodeImpl = {
|
|
|
113
115
|
theme: 'prompt-interpolation',
|
|
114
116
|
};
|
|
115
117
|
},
|
|
116
|
-
async process(data, inputData) {
|
|
118
|
+
async process(data, inputData, context) {
|
|
117
119
|
const text = getInputOrData(data, inputData, 'text', 'string');
|
|
118
120
|
const fileIds = getInputOrData(data, inputData, 'fileIds', 'string[]') ?? [];
|
|
119
121
|
let metadata = data.metadata.reduce((acc, { key, value }) => {
|
|
@@ -123,8 +125,9 @@ export const ThreadMessageNodeImpl = {
|
|
|
123
125
|
if (data.useMetadataInput && inputData['metadata']) {
|
|
124
126
|
metadata = coerceTypeOptional(inputData['metadata'], 'object');
|
|
125
127
|
}
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
+
const interpolated = interpolate(text, inputData, context?.graphInputNodeValues, context?.contextValues, {
|
|
129
|
+
coerceBareVariableDataValues: true,
|
|
130
|
+
});
|
|
128
131
|
// Here you would typically make a call to an API to create the message
|
|
129
132
|
// For the sake of this example, we'll just return the data as is
|
|
130
133
|
return {
|
|
@@ -37,13 +37,22 @@ const toRecordedEventMap = {
|
|
|
37
37
|
processId,
|
|
38
38
|
...(resultOrigin === undefined ? {} : { resultOrigin }),
|
|
39
39
|
}, durationMs, splitRunDurationMs), execution),
|
|
40
|
-
nodeError: ({ node, error, processId, resultOrigin, durationMs, splitRunDurationMs, execution }) => withExecution(withDuration({
|
|
40
|
+
nodeError: ({ node, error, processId, outputs, splitOutputs, resultOrigin, durationMs, splitRunDurationMs, execution }) => withExecution(withDuration({
|
|
41
41
|
nodeId: node.id,
|
|
42
42
|
error: typeof error === 'string' ? error : error.stack,
|
|
43
43
|
processId,
|
|
44
|
+
...(outputs === undefined ? {} : { outputs }),
|
|
45
|
+
...(splitOutputs === undefined ? {} : { splitOutputs }),
|
|
44
46
|
...(resultOrigin === undefined ? {} : { resultOrigin }),
|
|
45
47
|
}, durationMs, splitRunDurationMs), execution),
|
|
46
|
-
|
|
48
|
+
// Older debugger servers sent a null abort payload. Preserve that evidence
|
|
49
|
+
// instead of letting a malformed legacy transport message abort the whole
|
|
50
|
+
// recording. An unknown payload is deliberately treated as unsuccessful;
|
|
51
|
+
// it must never be mistaken for a completed graph run during replay.
|
|
52
|
+
abort: (data) => {
|
|
53
|
+
const { successful, error } = data ?? {};
|
|
54
|
+
return { successful: successful === true, error: typeof error === 'string' ? error : error?.stack };
|
|
55
|
+
},
|
|
47
56
|
graphAbort: ({ successful, error, graph, execution }) => withExecution({
|
|
48
57
|
successful,
|
|
49
58
|
error: typeof error === 'string' ? error : error?.stack,
|
|
@@ -140,6 +149,10 @@ function omitReplayRecordedAt(data) {
|
|
|
140
149
|
function isRecordableProcessEvent(message) {
|
|
141
150
|
return message in toRecordedEventMap || isPrefix(message, 'globalSet:') || isPrefix(message, 'userEvent:');
|
|
142
151
|
}
|
|
152
|
+
// WebSocket.OPEN/CLOSED are static browser constants. Core is also used by
|
|
153
|
+
// Node transports that can supply a compatible socket without installing that
|
|
154
|
+
// browser global, so compare the standardized ready-state value directly.
|
|
155
|
+
const CLOSED_WEBSOCKET_READY_STATE = 3;
|
|
143
156
|
function mapValuesDeep(obj, fn) {
|
|
144
157
|
if (Array.isArray(obj)) {
|
|
145
158
|
return obj.map((value) => {
|
|
@@ -233,14 +246,22 @@ export class ExecutionRecorder {
|
|
|
233
246
|
return new Promise((resolve) => {
|
|
234
247
|
this.recordingId = nanoid();
|
|
235
248
|
let settled = false;
|
|
236
|
-
const finish = () => {
|
|
249
|
+
const finish = (emitFinishedRecording) => {
|
|
237
250
|
if (settled)
|
|
238
251
|
return;
|
|
239
252
|
settled = true;
|
|
240
253
|
channel.removeEventListener('message', listener);
|
|
241
|
-
|
|
254
|
+
channel.removeEventListener('close', onClose);
|
|
255
|
+
options.signal?.removeEventListener('abort', onOwnerDisposed);
|
|
256
|
+
if (emitFinishedRecording) {
|
|
257
|
+
emitDetached(this.#emitter, 'finish', {
|
|
258
|
+
recording: this.getRecording(),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
242
261
|
resolve();
|
|
243
262
|
};
|
|
263
|
+
const onClose = () => finish(false);
|
|
264
|
+
const onOwnerDisposed = () => finish(false);
|
|
244
265
|
const listener = (event) => {
|
|
245
266
|
let payload;
|
|
246
267
|
try {
|
|
@@ -265,24 +286,39 @@ export class ExecutionRecorder {
|
|
|
265
286
|
return;
|
|
266
287
|
}
|
|
267
288
|
this.#events.push(toRecordedEvent(message, data));
|
|
268
|
-
if (
|
|
269
|
-
|
|
270
|
-
recording: this.getRecording(),
|
|
271
|
-
});
|
|
272
|
-
finish();
|
|
289
|
+
if (isSocketRecordingTerminalEvent(message)) {
|
|
290
|
+
finish(true);
|
|
273
291
|
}
|
|
274
292
|
};
|
|
275
293
|
if (options.signal?.aborted) {
|
|
276
|
-
|
|
294
|
+
onOwnerDisposed();
|
|
277
295
|
return;
|
|
278
296
|
}
|
|
279
297
|
channel.addEventListener('message', listener);
|
|
280
|
-
|
|
298
|
+
channel.addEventListener('close', onClose, { once: true });
|
|
299
|
+
options.signal?.addEventListener('abort', onOwnerDisposed, { once: true });
|
|
300
|
+
if (channel.readyState === CLOSED_WEBSOCKET_READY_STATE) {
|
|
301
|
+
onClose();
|
|
302
|
+
}
|
|
281
303
|
});
|
|
282
304
|
}
|
|
283
305
|
record(processor) {
|
|
284
306
|
this.recordingId = nanoid();
|
|
285
|
-
|
|
307
|
+
let settled = false;
|
|
308
|
+
const finish = () => {
|
|
309
|
+
if (settled)
|
|
310
|
+
return;
|
|
311
|
+
settled = true;
|
|
312
|
+
unsubscribeAny();
|
|
313
|
+
unsubscribeFinish();
|
|
314
|
+
emitDetached(this.#emitter, 'finish', {
|
|
315
|
+
recording: this.getRecording(),
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
const unsubscribeAny = processor.onAny((event, data) => {
|
|
319
|
+
if (settled || event === 'finish') {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
286
322
|
if (this.#includePartialOutputs === false && event === 'partialOutput') {
|
|
287
323
|
return;
|
|
288
324
|
}
|
|
@@ -290,17 +326,16 @@ export class ExecutionRecorder {
|
|
|
290
326
|
return;
|
|
291
327
|
}
|
|
292
328
|
this.#events.push(toRecordedEvent(event, data));
|
|
293
|
-
if (isRecordingTerminalEvent(event, data)) {
|
|
294
|
-
emitDetached(this.#emitter, 'finish', {
|
|
295
|
-
recording: this.getRecording(),
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
329
|
});
|
|
330
|
+
const unsubscribeFinish = processor.on('finish', finish);
|
|
299
331
|
}
|
|
300
332
|
getRecording() {
|
|
301
333
|
return {
|
|
302
334
|
recordingId: this.recordingId,
|
|
303
|
-
|
|
335
|
+
// Callers persist and replay recordings asynchronously. Returning the
|
|
336
|
+
// live backing array would let a later event mutate an already-finished
|
|
337
|
+
// recording snapshot.
|
|
338
|
+
events: [...this.#events],
|
|
304
339
|
startTs: this.#events[0]?.ts ?? 0,
|
|
305
340
|
finishTs: this.#events[this.#events.length - 1]?.ts ?? 0,
|
|
306
341
|
};
|
|
@@ -334,9 +369,6 @@ export class ExecutionRecorder {
|
|
|
334
369
|
return stringifyJsonStream(serializeToObject(this.getRecording()));
|
|
335
370
|
}
|
|
336
371
|
}
|
|
337
|
-
function
|
|
338
|
-
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
return event === 'abort' && data.successful !== true;
|
|
372
|
+
function isSocketRecordingTerminalEvent(event) {
|
|
373
|
+
return event === 'done' || event === 'error';
|
|
342
374
|
}
|
package/dist/esm/utils/index.js
CHANGED