@valerypopoff/rivet2-core 2.29.0 → 2.32.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 +273 -25
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/interpolationRuntime.cjs +1 -1
- package/dist/cjs/interpolationRuntime.cjs.map +2 -2
- package/dist/cjs/serialization.cjs +3 -1
- package/dist/cjs/serialization.cjs.map +2 -2
- package/dist/esm/exports.js +1 -0
- package/dist/esm/model/ExecutorSessionProtocol.js +233 -0
- package/dist/esm/model/NodePrefabResolver.js +13 -7
- package/dist/esm/model/classifier/providers.js +10 -5
- package/dist/esm/model/classifier/subq.js +5 -2
- package/dist/esm/model/nodes/AssemblePromptNode.js +18 -8
- package/dist/esm/utils/coerceType.js +1 -1
- package/dist/esm/utils/projectComparison/identity.js +10 -3
- package/dist/esm/utils/projectComparison.js +12 -2
- package/dist/esm/utils/serialization/serialization_v4.js +4 -0
- package/dist/types/exports.d.ts +1 -0
- package/dist/types/model/ExecutorProtocol.d.ts +3 -0
- package/dist/types/model/ExecutorSessionProtocol.d.ts +56 -0
- package/dist/types/model/NodeBase.d.ts +2 -0
- package/dist/types/model/classifier/providers.d.ts +1 -1
- package/dist/types/model/classifier/subq.d.ts +10 -2
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/bundle.cjs
CHANGED
|
@@ -94,9 +94,18 @@ __export(src_exports, {
|
|
|
94
94
|
DestructureNodeImpl: () => DestructureNodeImpl,
|
|
95
95
|
DidRunNodeImpl: () => DidRunNodeImpl,
|
|
96
96
|
DocumentNodeImpl: () => DocumentNodeImpl,
|
|
97
|
+
EXECUTOR_RELIABLE_MAX_BYTES: () => EXECUTOR_RELIABLE_MAX_BYTES,
|
|
98
|
+
EXECUTOR_RELIABLE_MAX_ITEMS: () => EXECUTOR_RELIABLE_MAX_ITEMS,
|
|
99
|
+
EXECUTOR_RELIABLE_PROCESS_BYTES: () => EXECUTOR_RELIABLE_PROCESS_BYTES,
|
|
100
|
+
EXECUTOR_RELIABLE_SESSION_BYTES: () => EXECUTOR_RELIABLE_SESSION_BYTES,
|
|
101
|
+
EXECUTOR_SESSION_V2: () => EXECUTOR_SESSION_V2,
|
|
102
|
+
EXECUTOR_TRANSFER_TIMEOUT_MS: () => EXECUTOR_TRANSFER_TIMEOUT_MS,
|
|
97
103
|
EXPRESSION_OUTPUT_PORT_ID: () => EXPRESSION_OUTPUT_PORT_ID,
|
|
98
104
|
EvaluateNodeImpl: () => EvaluateNodeImpl,
|
|
99
105
|
ExecutionRecorder: () => ExecutionRecorder,
|
|
106
|
+
ExecutorRecoveryError: () => ExecutorRecoveryError,
|
|
107
|
+
ExecutorReliableInbox: () => ExecutorReliableInbox,
|
|
108
|
+
ExecutorReliableOutbox: () => ExecutorReliableOutbox,
|
|
100
109
|
ExpressionNodeImpl: () => ExpressionNodeImpl,
|
|
101
110
|
ExternalCallNodeImpl: () => ExternalCallNodeImpl,
|
|
102
111
|
ExtractJsonNodeImpl: () => ExtractJsonNodeImpl,
|
|
@@ -400,6 +409,7 @@ __export(src_exports, {
|
|
|
400
409
|
evaluateJsonPath: () => evaluateJsonPath,
|
|
401
410
|
evaluateNode: () => evaluateNode,
|
|
402
411
|
executeLLMInvocation: () => executeLLMInvocation,
|
|
412
|
+
executorDeliveryPolicy: () => executorDeliveryPolicy,
|
|
403
413
|
expectType: () => expectType,
|
|
404
414
|
expectTypeOptional: () => expectTypeOptional,
|
|
405
415
|
exportGentraceEvaluationRun: () => exportGentraceEvaluationRun,
|
|
@@ -906,9 +916,18 @@ __export(exports_exports, {
|
|
|
906
916
|
DestructureNodeImpl: () => DestructureNodeImpl,
|
|
907
917
|
DidRunNodeImpl: () => DidRunNodeImpl,
|
|
908
918
|
DocumentNodeImpl: () => DocumentNodeImpl,
|
|
919
|
+
EXECUTOR_RELIABLE_MAX_BYTES: () => EXECUTOR_RELIABLE_MAX_BYTES,
|
|
920
|
+
EXECUTOR_RELIABLE_MAX_ITEMS: () => EXECUTOR_RELIABLE_MAX_ITEMS,
|
|
921
|
+
EXECUTOR_RELIABLE_PROCESS_BYTES: () => EXECUTOR_RELIABLE_PROCESS_BYTES,
|
|
922
|
+
EXECUTOR_RELIABLE_SESSION_BYTES: () => EXECUTOR_RELIABLE_SESSION_BYTES,
|
|
923
|
+
EXECUTOR_SESSION_V2: () => EXECUTOR_SESSION_V2,
|
|
924
|
+
EXECUTOR_TRANSFER_TIMEOUT_MS: () => EXECUTOR_TRANSFER_TIMEOUT_MS,
|
|
909
925
|
EXPRESSION_OUTPUT_PORT_ID: () => EXPRESSION_OUTPUT_PORT_ID,
|
|
910
926
|
EvaluateNodeImpl: () => EvaluateNodeImpl,
|
|
911
927
|
ExecutionRecorder: () => ExecutionRecorder,
|
|
928
|
+
ExecutorRecoveryError: () => ExecutorRecoveryError,
|
|
929
|
+
ExecutorReliableInbox: () => ExecutorReliableInbox,
|
|
930
|
+
ExecutorReliableOutbox: () => ExecutorReliableOutbox,
|
|
912
931
|
ExpressionNodeImpl: () => ExpressionNodeImpl,
|
|
913
932
|
ExternalCallNodeImpl: () => ExternalCallNodeImpl,
|
|
914
933
|
ExtractJsonNodeImpl: () => ExtractJsonNodeImpl,
|
|
@@ -1211,6 +1230,7 @@ __export(exports_exports, {
|
|
|
1211
1230
|
evaluateJsonPath: () => evaluateJsonPath,
|
|
1212
1231
|
evaluateNode: () => evaluateNode,
|
|
1213
1232
|
executeLLMInvocation: () => executeLLMInvocation,
|
|
1233
|
+
executorDeliveryPolicy: () => executorDeliveryPolicy,
|
|
1214
1234
|
expectType: () => expectType,
|
|
1215
1235
|
expectTypeOptional: () => expectTypeOptional,
|
|
1216
1236
|
exportGentraceEvaluationRun: () => exportGentraceEvaluationRun,
|
|
@@ -3864,7 +3884,7 @@ function coerceToChatMessageRaw(value) {
|
|
|
3864
3884
|
if (value.type === "string") {
|
|
3865
3885
|
return { type: "user", message: value.value };
|
|
3866
3886
|
}
|
|
3867
|
-
if (value.type === "object" && "type" in value.value && "message" in value.value && typeof value.value.type === "string" && typeof value.value.message === "string") {
|
|
3887
|
+
if (value.type === "object" && "type" in value.value && "message" in value.value && typeof value.value.type === "string" && (typeof value.value.message === "string" || Array.isArray(value.value.message))) {
|
|
3868
3888
|
return value.value;
|
|
3869
3889
|
}
|
|
3870
3890
|
if (value.type === "any") {
|
|
@@ -5647,6 +5667,7 @@ function toSerializedNode(node, allNodes, allConnections) {
|
|
|
5647
5667
|
return {
|
|
5648
5668
|
description: ((_a = node.description) == null ? void 0 : _a.trim()) ? node.description : void 0,
|
|
5649
5669
|
visualData: packVisualDataV4(node),
|
|
5670
|
+
dataBusChannelOrder: node.visualData.dataBusChannelOrder,
|
|
5650
5671
|
isSplitRun: node.isSplitRun ? true : void 0,
|
|
5651
5672
|
splitRunMax: node.isSplitRun ? node.splitRunMax : void 0,
|
|
5652
5673
|
splitRunConcurrency: node.isSplitRun ? node.splitRunConcurrency : void 0,
|
|
@@ -5682,7 +5703,8 @@ function fromSerializedNode2(serializedNode, serializedNodeInfo) {
|
|
|
5682
5703
|
y,
|
|
5683
5704
|
width,
|
|
5684
5705
|
zIndex,
|
|
5685
|
-
color
|
|
5706
|
+
color,
|
|
5707
|
+
...Array.isArray(serializedNode.dataBusChannelOrder) ? { dataBusChannelOrder: serializedNode.dataBusChannelOrder } : {}
|
|
5686
5708
|
},
|
|
5687
5709
|
data: serializedNode.data ?? {},
|
|
5688
5710
|
variants: serializedNode.variants ?? [],
|
|
@@ -6322,7 +6344,13 @@ function comparisonNodeIdentity(node, side, identity) {
|
|
|
6322
6344
|
const data = (value) => {
|
|
6323
6345
|
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
6324
6346
|
const record4 = value;
|
|
6325
|
-
|
|
6347
|
+
if (typeof record4[field2] !== "string") return value;
|
|
6348
|
+
const result = { ...record4, [field2]: comparisonProjectIdentity(record4[field2], side, identity) };
|
|
6349
|
+
if (node.type === "subGraph" && identity.pairs.some((p) => (side === "before" ? p.beforeProjectId : p.afterProjectId) === record4[field2])) {
|
|
6350
|
+
delete result.targetScope;
|
|
6351
|
+
result.targetVersion ??= "latest";
|
|
6352
|
+
}
|
|
6353
|
+
return result;
|
|
6326
6354
|
};
|
|
6327
6355
|
return {
|
|
6328
6356
|
...node,
|
|
@@ -6532,8 +6560,18 @@ function compareProjects(before, after, identity) {
|
|
|
6532
6560
|
beforeProjectId: before.metadata.id,
|
|
6533
6561
|
afterProjectId: after.metadata.id,
|
|
6534
6562
|
metadataChanged: !areComparisonValuesEqual(
|
|
6535
|
-
identity ? {
|
|
6536
|
-
|
|
6563
|
+
identity ? {
|
|
6564
|
+
...before.metadata,
|
|
6565
|
+
id: comparisonProjectIdentity(before.metadata.id, "before", identity),
|
|
6566
|
+
path: void 0,
|
|
6567
|
+
title: void 0
|
|
6568
|
+
} : before.metadata,
|
|
6569
|
+
identity ? {
|
|
6570
|
+
...after.metadata,
|
|
6571
|
+
id: comparisonProjectIdentity(after.metadata.id, "after", identity),
|
|
6572
|
+
path: void 0,
|
|
6573
|
+
title: void 0
|
|
6574
|
+
} : after.metadata
|
|
6537
6575
|
),
|
|
6538
6576
|
graphs,
|
|
6539
6577
|
nodePrefabs,
|
|
@@ -7530,16 +7568,20 @@ function resolveNodePrefabInstance(project, node) {
|
|
|
7530
7568
|
title: `Missing library node (${prefabId})`
|
|
7531
7569
|
};
|
|
7532
7570
|
}
|
|
7571
|
+
const visualData = {
|
|
7572
|
+
...structuredClone(sourceNode.visualData),
|
|
7573
|
+
x: node.visualData.x,
|
|
7574
|
+
y: node.visualData.y,
|
|
7575
|
+
width: node.visualData.width ?? sourceNode.visualData.width,
|
|
7576
|
+
zIndex: node.visualData.zIndex
|
|
7577
|
+
};
|
|
7578
|
+
if (Array.isArray(node.visualData.dataBusChannelOrder))
|
|
7579
|
+
visualData.dataBusChannelOrder = [...node.visualData.dataBusChannelOrder];
|
|
7580
|
+
else delete visualData.dataBusChannelOrder;
|
|
7533
7581
|
return {
|
|
7534
7582
|
...structuredClone(sourceNode),
|
|
7535
7583
|
id: node.id,
|
|
7536
|
-
visualData
|
|
7537
|
-
...structuredClone(sourceNode.visualData),
|
|
7538
|
-
x: node.visualData.x,
|
|
7539
|
-
y: node.visualData.y,
|
|
7540
|
-
width: node.visualData.width ?? sourceNode.visualData.width,
|
|
7541
|
-
zIndex: node.visualData.zIndex
|
|
7542
|
-
}
|
|
7584
|
+
visualData
|
|
7543
7585
|
};
|
|
7544
7586
|
}
|
|
7545
7587
|
function detachNodePrefabInstance(project, node) {
|
|
@@ -33702,11 +33744,11 @@ var import_non_secure34 = require("nanoid/non-secure");
|
|
|
33702
33744
|
var import_lodash_es10 = require("lodash");
|
|
33703
33745
|
var import_ts_dedent24 = require("ts-dedent");
|
|
33704
33746
|
function isEmptyPromptMessage(message2) {
|
|
33705
|
-
var _a;
|
|
33747
|
+
var _a, _b;
|
|
33706
33748
|
if (message2.type === "function") {
|
|
33707
33749
|
return false;
|
|
33708
33750
|
}
|
|
33709
|
-
if (message2.type === "assistant" && (message2.function_call != null || (((_a = message2.function_calls) == null ? void 0 : _a.length) ?? 0) > 0)) {
|
|
33751
|
+
if (message2.type === "assistant" && (message2.function_call != null || (((_a = message2.function_calls) == null ? void 0 : _a.length) ?? 0) > 0 || (((_b = message2.openRouterReasoningDetails) == null ? void 0 : _b.length) ?? 0) > 0)) {
|
|
33710
33752
|
return false;
|
|
33711
33753
|
}
|
|
33712
33754
|
const parts = Array.isArray(message2.message) ? message2.message : [message2.message];
|
|
@@ -33724,7 +33766,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33724
33766
|
width: 250
|
|
33725
33767
|
},
|
|
33726
33768
|
data: {
|
|
33727
|
-
filterEmptyPrompts:
|
|
33769
|
+
filterEmptyPrompts: true
|
|
33728
33770
|
}
|
|
33729
33771
|
};
|
|
33730
33772
|
return chartNode;
|
|
@@ -33777,6 +33819,8 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33777
33819
|
The number of inputs is dynamic based on the number of connections.
|
|
33778
33820
|
|
|
33779
33821
|
Strings are converted to User type chat messages.
|
|
33822
|
+
|
|
33823
|
+
Empty or whitespace-only text messages are filtered by default. Rich content, tool exchanges and reasoning continuity are preserved.
|
|
33780
33824
|
`,
|
|
33781
33825
|
infoBoxTitle: "Assemble Prompt Node",
|
|
33782
33826
|
contextMenuTitle: "Assemble Prompt",
|
|
@@ -33794,8 +33838,8 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33794
33838
|
type: "toggle",
|
|
33795
33839
|
label: "Filter empty prompts",
|
|
33796
33840
|
dataKey: "filterEmptyPrompts",
|
|
33797
|
-
defaultValue:
|
|
33798
|
-
helperMessage: "Removes text-only messages whose content is empty or whitespace. Rich
|
|
33841
|
+
defaultValue: true,
|
|
33842
|
+
helperMessage: "Removes text-only messages whose content is empty or whitespace. Rich content, tool exchanges and reasoning continuity are preserved."
|
|
33799
33843
|
},
|
|
33800
33844
|
{
|
|
33801
33845
|
type: "toggle",
|
|
@@ -33808,7 +33852,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33808
33852
|
}
|
|
33809
33853
|
getBody() {
|
|
33810
33854
|
return [
|
|
33811
|
-
this.data.filterEmptyPrompts ? "Filter empty prompts: Enabled" : "",
|
|
33855
|
+
this.data.filterEmptyPrompts !== false ? "Filter empty prompts: Enabled" : "",
|
|
33812
33856
|
this.data.useIsLastMessageCacheBreakpointInput ? "Last message cache breakpoint: From input" : this.data.isLastMessageCacheBreakpoint ? "Last message is cache breakpoint" : ""
|
|
33813
33857
|
].filter(Boolean).join("\n");
|
|
33814
33858
|
}
|
|
@@ -33825,10 +33869,13 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33825
33869
|
if (!inputMessage || inputMessage.type === "control-flow-excluded" || !inputMessage.value) {
|
|
33826
33870
|
continue;
|
|
33827
33871
|
}
|
|
33828
|
-
const
|
|
33872
|
+
const value = unwrapDataValue(inputMessage);
|
|
33873
|
+
if (value.value == null) continue;
|
|
33874
|
+
const inMessages = arrayizeDataValue(value);
|
|
33829
33875
|
for (const message2 of inMessages) {
|
|
33876
|
+
if (message2.value == null) continue;
|
|
33830
33877
|
const outMessage = message2.type === "chat-message" ? message2.value : coerceType(message2, "chat-message");
|
|
33831
|
-
if (this.data.filterEmptyPrompts && isEmptyPromptMessage(outMessage)) {
|
|
33878
|
+
if (this.data.filterEmptyPrompts !== false && isEmptyPromptMessage(outMessage)) {
|
|
33832
33879
|
continue;
|
|
33833
33880
|
}
|
|
33834
33881
|
outMessages.push(outMessage);
|
|
@@ -46174,7 +46221,10 @@ function createJevDecisionRequest({
|
|
|
46174
46221
|
}
|
|
46175
46222
|
|
|
46176
46223
|
// src/model/classifier/subq.ts
|
|
46177
|
-
var SUBQ_DECISION_MODELS = [
|
|
46224
|
+
var SUBQ_DECISION_MODELS = [
|
|
46225
|
+
{ value: "subq-snap-1.2", label: "Snap 1.2", aggregateTokenUsageOnly: true },
|
|
46226
|
+
{ value: "subq-snap-1.1", label: "Snap 1.1 (deprecated)", aggregateTokenUsageOnly: true }
|
|
46227
|
+
];
|
|
46178
46228
|
function subqDecisionState(state) {
|
|
46179
46229
|
if (state.kind === "json") return { state: state.value };
|
|
46180
46230
|
const wire = systemOneState({ state: "", stateMessages: state.messages });
|
|
@@ -46440,13 +46490,18 @@ var perplexityClassifierProvider = createClassifierProvider({
|
|
|
46440
46490
|
var subqClassifierProvider = createClassifierProvider({
|
|
46441
46491
|
id: "subq",
|
|
46442
46492
|
label: "SubQ",
|
|
46443
|
-
defaultModel:
|
|
46444
|
-
modelOptions: SUBQ_DECISION_MODELS
|
|
46493
|
+
defaultModel: SUBQ_DECISION_MODELS[0].value,
|
|
46494
|
+
modelOptions: SUBQ_DECISION_MODELS,
|
|
46445
46495
|
credentialNames: SUBQ_DEFAULT_CREDENTIAL_NAMES,
|
|
46446
46496
|
browserExecutionSupported: false,
|
|
46447
46497
|
endpoint: SUBQ_DECISIONS_ENDPOINT,
|
|
46448
|
-
supportsImages: (model) => SUBQ_DECISION_MODELS.
|
|
46449
|
-
modelPricing: [
|
|
46498
|
+
supportsImages: (model) => SUBQ_DECISION_MODELS.some(({ value }) => value === model),
|
|
46499
|
+
modelPricing: [
|
|
46500
|
+
{
|
|
46501
|
+
models: SUBQ_DECISION_MODELS.map(({ value }) => value),
|
|
46502
|
+
pricing: { inputPerMillionTokens: 0.04, outputPerMillionTokens: 0 }
|
|
46503
|
+
}
|
|
46504
|
+
],
|
|
46450
46505
|
maxRequestBytes: 13 * 1024 * 1024,
|
|
46451
46506
|
checkRequest: assertSubQDecisionLimits,
|
|
46452
46507
|
buildRequest: ({ model, state, questions }) => ({
|
|
@@ -56053,6 +56108,189 @@ function isLatestDebuggerScope(value) {
|
|
|
56053
56108
|
) && (scope.promptId === void 0 || typeof scope.promptId === "string" && scope.promptId.length > 0 && scope.promptId.length <= 200) && (scope.admittedAt === void 0 || Number.isSafeInteger(scope.admittedAt) && scope.admittedAt >= 0) && (scope.promptLifecycle === void 0 || scope.promptLifecycle === 1);
|
|
56054
56109
|
}
|
|
56055
56110
|
|
|
56111
|
+
// src/model/ExecutorSessionProtocol.ts
|
|
56112
|
+
var EXECUTOR_SESSION_V2 = "rivet-session-v2";
|
|
56113
|
+
var EXECUTOR_RELIABLE_MAX_BYTES = 100 * 1024 * 1024;
|
|
56114
|
+
var EXECUTOR_RELIABLE_SESSION_BYTES = 256 * 1024 * 1024;
|
|
56115
|
+
var EXECUTOR_RELIABLE_PROCESS_BYTES = 512 * 1024 * 1024;
|
|
56116
|
+
var EXECUTOR_RELIABLE_MAX_ITEMS = 4096;
|
|
56117
|
+
var EXECUTOR_TRANSFER_TIMEOUT_MS = 6e4;
|
|
56118
|
+
var deliveryPolicy = {
|
|
56119
|
+
start: "reliable",
|
|
56120
|
+
done: "reliable",
|
|
56121
|
+
error: "reliable",
|
|
56122
|
+
abort: "reliable",
|
|
56123
|
+
graphOutputsReady: "reliable",
|
|
56124
|
+
webAppStoragePatch: "reliable",
|
|
56125
|
+
userInput: "reliable",
|
|
56126
|
+
pause: "reliable",
|
|
56127
|
+
resume: "reliable",
|
|
56128
|
+
codeConsole: "diagnostic",
|
|
56129
|
+
nodeStart: "diagnostic",
|
|
56130
|
+
nodeFinish: "diagnostic",
|
|
56131
|
+
nodeError: "diagnostic",
|
|
56132
|
+
nodeExcluded: "diagnostic",
|
|
56133
|
+
graphAbort: "diagnostic",
|
|
56134
|
+
graphStart: "diagnostic",
|
|
56135
|
+
graphFinish: "diagnostic",
|
|
56136
|
+
partialOutput: "diagnostic",
|
|
56137
|
+
progress: "diagnostic",
|
|
56138
|
+
llmCallFinished: "diagnostic",
|
|
56139
|
+
llmChatOutputSnapshot: "diagnostic",
|
|
56140
|
+
llmProfileAttempt: "diagnostic",
|
|
56141
|
+
toolCallFinished: "diagnostic",
|
|
56142
|
+
nodeOutputsCleared: "diagnostic",
|
|
56143
|
+
streamingOutputWatchSummary: "diagnostic",
|
|
56144
|
+
graphError: "diagnostic",
|
|
56145
|
+
trace: "diagnostic"
|
|
56146
|
+
};
|
|
56147
|
+
var datasetMessages = {
|
|
56148
|
+
"datasets:get-metadata": true,
|
|
56149
|
+
"datasets:get-for-project": true,
|
|
56150
|
+
"datasets:get-data": true,
|
|
56151
|
+
"datasets:put-data": true,
|
|
56152
|
+
"datasets:put-row": true,
|
|
56153
|
+
"datasets:put-metadata": true,
|
|
56154
|
+
"datasets:clear-data": true,
|
|
56155
|
+
"datasets:delete": true,
|
|
56156
|
+
"datasets:knn": true,
|
|
56157
|
+
"datasets:export-for-project": true
|
|
56158
|
+
};
|
|
56159
|
+
function executorDeliveryPolicy(message2) {
|
|
56160
|
+
if (message2 === "graph-upload-allowed" || message2 === "executor-owner-retiring" || Object.hasOwn(datasetMessages, message2))
|
|
56161
|
+
return "reliable";
|
|
56162
|
+
if (Object.hasOwn(deliveryPolicy, message2)) return deliveryPolicy[message2];
|
|
56163
|
+
throw new ExecutorRecoveryError("invalid-transfer");
|
|
56164
|
+
}
|
|
56165
|
+
var CHUNK_CHARACTERS = 8192;
|
|
56166
|
+
var ExecutorRecoveryError = class extends Error {
|
|
56167
|
+
constructor(reason) {
|
|
56168
|
+
super(`Executor session could not be resumed (${reason}). Run outcome is unknown; it was not resubmitted.`);
|
|
56169
|
+
this.reason = reason;
|
|
56170
|
+
this.name = "ExecutorRecoveryError";
|
|
56171
|
+
}
|
|
56172
|
+
};
|
|
56173
|
+
var safeId = (value) => Number.isSafeInteger(value) && value > 0;
|
|
56174
|
+
var ExecutorReliableOutbox = class {
|
|
56175
|
+
constructor(maxBytes = EXECUTOR_RELIABLE_SESSION_BYTES, reservedBytes = 0) {
|
|
56176
|
+
this.maxBytes = maxBytes;
|
|
56177
|
+
this.reservedBytes = reservedBytes;
|
|
56178
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || !Number.isSafeInteger(reservedBytes) || reservedBytes < 0 || reservedBytes >= maxBytes)
|
|
56179
|
+
throw new Error("Invalid executor reliable retention limits");
|
|
56180
|
+
}
|
|
56181
|
+
#nextId = 0;
|
|
56182
|
+
#items = /* @__PURE__ */ new Map();
|
|
56183
|
+
bytes = 0;
|
|
56184
|
+
get size() {
|
|
56185
|
+
return this.#items.size;
|
|
56186
|
+
}
|
|
56187
|
+
add(text2, order, emergency = false) {
|
|
56188
|
+
const bytes = new TextEncoder().encode(text2).byteLength;
|
|
56189
|
+
if (bytes > EXECUTOR_RELIABLE_MAX_BYTES || this.bytes + bytes > this.maxBytes - (emergency ? 0 : this.reservedBytes) || this.size >= EXECUTOR_RELIABLE_MAX_ITEMS - (emergency || !this.reservedBytes ? 0 : 128))
|
|
56190
|
+
throw new ExecutorRecoveryError("retention-limit");
|
|
56191
|
+
const id = ++this.#nextId;
|
|
56192
|
+
this.#items.set(id, { text: text2, bytes, index: 0, order: order ?? id, sent: false });
|
|
56193
|
+
this.bytes += bytes;
|
|
56194
|
+
return id;
|
|
56195
|
+
}
|
|
56196
|
+
acknowledge(id) {
|
|
56197
|
+
if (!safeId(id) || id > this.#nextId) throw new ExecutorRecoveryError("invalid-transfer");
|
|
56198
|
+
const item = this.#items.get(id);
|
|
56199
|
+
if (!item) return false;
|
|
56200
|
+
if (!item.sent) throw new ExecutorRecoveryError("invalid-transfer");
|
|
56201
|
+
this.bytes -= item.bytes;
|
|
56202
|
+
this.#items.delete(id);
|
|
56203
|
+
return true;
|
|
56204
|
+
}
|
|
56205
|
+
replay() {
|
|
56206
|
+
for (const item of this.#items.values()) item.index = 0;
|
|
56207
|
+
}
|
|
56208
|
+
peekOrder() {
|
|
56209
|
+
for (const item of this.#items.values())
|
|
56210
|
+
if (item.index < Math.max(1, Math.ceil(item.text.length / CHUNK_CHARACTERS))) return item.order;
|
|
56211
|
+
return void 0;
|
|
56212
|
+
}
|
|
56213
|
+
next() {
|
|
56214
|
+
for (const [id, item] of this.#items) {
|
|
56215
|
+
const count = Math.max(1, Math.ceil(item.text.length / CHUNK_CHARACTERS));
|
|
56216
|
+
if (item.index >= count) continue;
|
|
56217
|
+
const index = item.index++;
|
|
56218
|
+
if (item.index === count) item.sent = true;
|
|
56219
|
+
const boundary = (offset) => offset > 0 && offset < item.text.length && /[\uD800-\uDBFF]/.test(item.text[offset - 1]) && /[\uDC00-\uDFFF]/.test(item.text[offset]) ? offset - 1 : offset;
|
|
56220
|
+
return {
|
|
56221
|
+
id,
|
|
56222
|
+
index,
|
|
56223
|
+
count,
|
|
56224
|
+
bytes: item.bytes,
|
|
56225
|
+
text: item.text.slice(
|
|
56226
|
+
boundary(index * CHUNK_CHARACTERS),
|
|
56227
|
+
boundary(Math.min(item.text.length, (index + 1) * CHUNK_CHARACTERS))
|
|
56228
|
+
)
|
|
56229
|
+
};
|
|
56230
|
+
}
|
|
56231
|
+
return void 0;
|
|
56232
|
+
}
|
|
56233
|
+
clear() {
|
|
56234
|
+
this.#items.clear();
|
|
56235
|
+
this.bytes = 0;
|
|
56236
|
+
}
|
|
56237
|
+
};
|
|
56238
|
+
var ExecutorReliableInbox = class {
|
|
56239
|
+
constructor(onExpiry, budget) {
|
|
56240
|
+
this.onExpiry = onExpiry;
|
|
56241
|
+
this.budget = budget;
|
|
56242
|
+
if (budget && (!Number.isSafeInteger(budget.bytes) || budget.bytes < 0 || !Number.isSafeInteger(budget.maxBytes ?? EXECUTOR_RELIABLE_PROCESS_BYTES) || (budget.maxBytes ?? EXECUTOR_RELIABLE_PROCESS_BYTES) < 1))
|
|
56243
|
+
throw new Error("Invalid executor receive budget");
|
|
56244
|
+
}
|
|
56245
|
+
#consumed = 0;
|
|
56246
|
+
#transfer;
|
|
56247
|
+
#timer;
|
|
56248
|
+
receive(value) {
|
|
56249
|
+
var _a, _b;
|
|
56250
|
+
if (!value || typeof value !== "object") throw new ExecutorRecoveryError("invalid-transfer");
|
|
56251
|
+
const part = value;
|
|
56252
|
+
if (!safeId(part.id) || !safeId(part.count) || part.count > Math.ceil(EXECUTOR_RELIABLE_MAX_BYTES / CHUNK_CHARACTERS) || !Number.isSafeInteger(part.index) || part.index < 0 || part.index >= part.count || !Number.isSafeInteger(part.bytes) || part.bytes < 0 || part.bytes > EXECUTOR_RELIABLE_MAX_BYTES || typeof part.text !== "string" || part.text.length > CHUNK_CHARACTERS + 1)
|
|
56253
|
+
throw new ExecutorRecoveryError("invalid-transfer");
|
|
56254
|
+
if (part.id <= this.#consumed) return { id: part.id };
|
|
56255
|
+
if (!this.#transfer) {
|
|
56256
|
+
if (this.budget) {
|
|
56257
|
+
if (this.budget.bytes + part.bytes > (this.budget.maxBytes ?? EXECUTOR_RELIABLE_PROCESS_BYTES))
|
|
56258
|
+
throw new ExecutorRecoveryError("retention-limit");
|
|
56259
|
+
this.budget.bytes += part.bytes;
|
|
56260
|
+
}
|
|
56261
|
+
this.#transfer = { id: part.id, count: part.count, total: part.bytes, parts: [], bytes: 0 };
|
|
56262
|
+
this.#timer = setTimeout(() => {
|
|
56263
|
+
var _a2;
|
|
56264
|
+
this.resetTransfer();
|
|
56265
|
+
(_a2 = this.onExpiry) == null ? void 0 : _a2.call(this);
|
|
56266
|
+
}, EXECUTOR_TRANSFER_TIMEOUT_MS);
|
|
56267
|
+
(_b = (_a = this.#timer).unref) == null ? void 0 : _b.call(_a);
|
|
56268
|
+
}
|
|
56269
|
+
const transfer = this.#transfer;
|
|
56270
|
+
if (transfer.id !== part.id || transfer.count !== part.count || transfer.total !== part.bytes || transfer.parts.length !== part.index)
|
|
56271
|
+
throw new ExecutorRecoveryError("invalid-transfer");
|
|
56272
|
+
transfer.bytes += new TextEncoder().encode(part.text).byteLength;
|
|
56273
|
+
if (transfer.bytes > transfer.total) throw new ExecutorRecoveryError("invalid-transfer");
|
|
56274
|
+
transfer.parts.push(part.text);
|
|
56275
|
+
if (transfer.parts.length !== transfer.count) return;
|
|
56276
|
+
if (transfer.bytes !== transfer.total) throw new ExecutorRecoveryError("invalid-transfer");
|
|
56277
|
+
const text2 = transfer.parts.join("");
|
|
56278
|
+
this.resetTransfer();
|
|
56279
|
+
this.#consumed = part.id;
|
|
56280
|
+
return { id: part.id, text: text2 };
|
|
56281
|
+
}
|
|
56282
|
+
resetTransfer() {
|
|
56283
|
+
if (this.#transfer && this.budget) this.budget.bytes -= this.#transfer.total;
|
|
56284
|
+
this.#transfer = void 0;
|
|
56285
|
+
clearTimeout(this.#timer);
|
|
56286
|
+
this.#timer = void 0;
|
|
56287
|
+
}
|
|
56288
|
+
clear() {
|
|
56289
|
+
this.#consumed = 0;
|
|
56290
|
+
this.resetTransfer();
|
|
56291
|
+
}
|
|
56292
|
+
};
|
|
56293
|
+
|
|
56056
56294
|
// src/index.ts
|
|
56057
56295
|
installCodeRunnerNamespace(exports_exports);
|
|
56058
56296
|
var Rivet = void 0;
|
|
@@ -56122,9 +56360,18 @@ var Rivet = void 0;
|
|
|
56122
56360
|
DestructureNodeImpl,
|
|
56123
56361
|
DidRunNodeImpl,
|
|
56124
56362
|
DocumentNodeImpl,
|
|
56363
|
+
EXECUTOR_RELIABLE_MAX_BYTES,
|
|
56364
|
+
EXECUTOR_RELIABLE_MAX_ITEMS,
|
|
56365
|
+
EXECUTOR_RELIABLE_PROCESS_BYTES,
|
|
56366
|
+
EXECUTOR_RELIABLE_SESSION_BYTES,
|
|
56367
|
+
EXECUTOR_SESSION_V2,
|
|
56368
|
+
EXECUTOR_TRANSFER_TIMEOUT_MS,
|
|
56125
56369
|
EXPRESSION_OUTPUT_PORT_ID,
|
|
56126
56370
|
EvaluateNodeImpl,
|
|
56127
56371
|
ExecutionRecorder,
|
|
56372
|
+
ExecutorRecoveryError,
|
|
56373
|
+
ExecutorReliableInbox,
|
|
56374
|
+
ExecutorReliableOutbox,
|
|
56128
56375
|
ExpressionNodeImpl,
|
|
56129
56376
|
ExternalCallNodeImpl,
|
|
56130
56377
|
ExtractJsonNodeImpl,
|
|
@@ -56428,6 +56675,7 @@ var Rivet = void 0;
|
|
|
56428
56675
|
evaluateJsonPath,
|
|
56429
56676
|
evaluateNode,
|
|
56430
56677
|
executeLLMInvocation,
|
|
56678
|
+
executorDeliveryPolicy,
|
|
56431
56679
|
expectType,
|
|
56432
56680
|
expectTypeOptional,
|
|
56433
56681
|
exportGentraceEvaluationRun,
|