@valerypopoff/rivet2-core 2.29.0 → 2.31.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 +259 -17
- 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/esm/exports.js +1 -0
- package/dist/esm/model/ExecutorSessionProtocol.js +233 -0
- 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/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/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") {
|
|
@@ -6322,7 +6342,13 @@ function comparisonNodeIdentity(node, side, identity) {
|
|
|
6322
6342
|
const data = (value) => {
|
|
6323
6343
|
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
6324
6344
|
const record4 = value;
|
|
6325
|
-
|
|
6345
|
+
if (typeof record4[field2] !== "string") return value;
|
|
6346
|
+
const result = { ...record4, [field2]: comparisonProjectIdentity(record4[field2], side, identity) };
|
|
6347
|
+
if (node.type === "subGraph" && identity.pairs.some((p) => (side === "before" ? p.beforeProjectId : p.afterProjectId) === record4[field2])) {
|
|
6348
|
+
delete result.targetScope;
|
|
6349
|
+
result.targetVersion ??= "latest";
|
|
6350
|
+
}
|
|
6351
|
+
return result;
|
|
6326
6352
|
};
|
|
6327
6353
|
return {
|
|
6328
6354
|
...node,
|
|
@@ -6532,8 +6558,18 @@ function compareProjects(before, after, identity) {
|
|
|
6532
6558
|
beforeProjectId: before.metadata.id,
|
|
6533
6559
|
afterProjectId: after.metadata.id,
|
|
6534
6560
|
metadataChanged: !areComparisonValuesEqual(
|
|
6535
|
-
identity ? {
|
|
6536
|
-
|
|
6561
|
+
identity ? {
|
|
6562
|
+
...before.metadata,
|
|
6563
|
+
id: comparisonProjectIdentity(before.metadata.id, "before", identity),
|
|
6564
|
+
path: void 0,
|
|
6565
|
+
title: void 0
|
|
6566
|
+
} : before.metadata,
|
|
6567
|
+
identity ? {
|
|
6568
|
+
...after.metadata,
|
|
6569
|
+
id: comparisonProjectIdentity(after.metadata.id, "after", identity),
|
|
6570
|
+
path: void 0,
|
|
6571
|
+
title: void 0
|
|
6572
|
+
} : after.metadata
|
|
6537
6573
|
),
|
|
6538
6574
|
graphs,
|
|
6539
6575
|
nodePrefabs,
|
|
@@ -33702,11 +33738,11 @@ var import_non_secure34 = require("nanoid/non-secure");
|
|
|
33702
33738
|
var import_lodash_es10 = require("lodash");
|
|
33703
33739
|
var import_ts_dedent24 = require("ts-dedent");
|
|
33704
33740
|
function isEmptyPromptMessage(message2) {
|
|
33705
|
-
var _a;
|
|
33741
|
+
var _a, _b;
|
|
33706
33742
|
if (message2.type === "function") {
|
|
33707
33743
|
return false;
|
|
33708
33744
|
}
|
|
33709
|
-
if (message2.type === "assistant" && (message2.function_call != null || (((_a = message2.function_calls) == null ? void 0 : _a.length) ?? 0) > 0)) {
|
|
33745
|
+
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
33746
|
return false;
|
|
33711
33747
|
}
|
|
33712
33748
|
const parts = Array.isArray(message2.message) ? message2.message : [message2.message];
|
|
@@ -33724,7 +33760,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33724
33760
|
width: 250
|
|
33725
33761
|
},
|
|
33726
33762
|
data: {
|
|
33727
|
-
filterEmptyPrompts:
|
|
33763
|
+
filterEmptyPrompts: true
|
|
33728
33764
|
}
|
|
33729
33765
|
};
|
|
33730
33766
|
return chartNode;
|
|
@@ -33777,6 +33813,8 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33777
33813
|
The number of inputs is dynamic based on the number of connections.
|
|
33778
33814
|
|
|
33779
33815
|
Strings are converted to User type chat messages.
|
|
33816
|
+
|
|
33817
|
+
Empty or whitespace-only text messages are filtered by default. Rich content, tool exchanges and reasoning continuity are preserved.
|
|
33780
33818
|
`,
|
|
33781
33819
|
infoBoxTitle: "Assemble Prompt Node",
|
|
33782
33820
|
contextMenuTitle: "Assemble Prompt",
|
|
@@ -33794,8 +33832,8 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33794
33832
|
type: "toggle",
|
|
33795
33833
|
label: "Filter empty prompts",
|
|
33796
33834
|
dataKey: "filterEmptyPrompts",
|
|
33797
|
-
defaultValue:
|
|
33798
|
-
helperMessage: "Removes text-only messages whose content is empty or whitespace. Rich
|
|
33835
|
+
defaultValue: true,
|
|
33836
|
+
helperMessage: "Removes text-only messages whose content is empty or whitespace. Rich content, tool exchanges and reasoning continuity are preserved."
|
|
33799
33837
|
},
|
|
33800
33838
|
{
|
|
33801
33839
|
type: "toggle",
|
|
@@ -33808,7 +33846,7 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33808
33846
|
}
|
|
33809
33847
|
getBody() {
|
|
33810
33848
|
return [
|
|
33811
|
-
this.data.filterEmptyPrompts ? "Filter empty prompts: Enabled" : "",
|
|
33849
|
+
this.data.filterEmptyPrompts !== false ? "Filter empty prompts: Enabled" : "",
|
|
33812
33850
|
this.data.useIsLastMessageCacheBreakpointInput ? "Last message cache breakpoint: From input" : this.data.isLastMessageCacheBreakpoint ? "Last message is cache breakpoint" : ""
|
|
33813
33851
|
].filter(Boolean).join("\n");
|
|
33814
33852
|
}
|
|
@@ -33825,10 +33863,13 @@ var AssemblePromptNodeImpl = class extends NodeImpl {
|
|
|
33825
33863
|
if (!inputMessage || inputMessage.type === "control-flow-excluded" || !inputMessage.value) {
|
|
33826
33864
|
continue;
|
|
33827
33865
|
}
|
|
33828
|
-
const
|
|
33866
|
+
const value = unwrapDataValue(inputMessage);
|
|
33867
|
+
if (value.value == null) continue;
|
|
33868
|
+
const inMessages = arrayizeDataValue(value);
|
|
33829
33869
|
for (const message2 of inMessages) {
|
|
33870
|
+
if (message2.value == null) continue;
|
|
33830
33871
|
const outMessage = message2.type === "chat-message" ? message2.value : coerceType(message2, "chat-message");
|
|
33831
|
-
if (this.data.filterEmptyPrompts && isEmptyPromptMessage(outMessage)) {
|
|
33872
|
+
if (this.data.filterEmptyPrompts !== false && isEmptyPromptMessage(outMessage)) {
|
|
33832
33873
|
continue;
|
|
33833
33874
|
}
|
|
33834
33875
|
outMessages.push(outMessage);
|
|
@@ -46174,7 +46215,10 @@ function createJevDecisionRequest({
|
|
|
46174
46215
|
}
|
|
46175
46216
|
|
|
46176
46217
|
// src/model/classifier/subq.ts
|
|
46177
|
-
var SUBQ_DECISION_MODELS = [
|
|
46218
|
+
var SUBQ_DECISION_MODELS = [
|
|
46219
|
+
{ value: "subq-snap-1.2", label: "Snap 1.2", aggregateTokenUsageOnly: true },
|
|
46220
|
+
{ value: "subq-snap-1.1", label: "Snap 1.1 (deprecated)", aggregateTokenUsageOnly: true }
|
|
46221
|
+
];
|
|
46178
46222
|
function subqDecisionState(state) {
|
|
46179
46223
|
if (state.kind === "json") return { state: state.value };
|
|
46180
46224
|
const wire = systemOneState({ state: "", stateMessages: state.messages });
|
|
@@ -46440,13 +46484,18 @@ var perplexityClassifierProvider = createClassifierProvider({
|
|
|
46440
46484
|
var subqClassifierProvider = createClassifierProvider({
|
|
46441
46485
|
id: "subq",
|
|
46442
46486
|
label: "SubQ",
|
|
46443
|
-
defaultModel:
|
|
46444
|
-
modelOptions: SUBQ_DECISION_MODELS
|
|
46487
|
+
defaultModel: SUBQ_DECISION_MODELS[0].value,
|
|
46488
|
+
modelOptions: SUBQ_DECISION_MODELS,
|
|
46445
46489
|
credentialNames: SUBQ_DEFAULT_CREDENTIAL_NAMES,
|
|
46446
46490
|
browserExecutionSupported: false,
|
|
46447
46491
|
endpoint: SUBQ_DECISIONS_ENDPOINT,
|
|
46448
|
-
supportsImages: (model) => SUBQ_DECISION_MODELS.
|
|
46449
|
-
modelPricing: [
|
|
46492
|
+
supportsImages: (model) => SUBQ_DECISION_MODELS.some(({ value }) => value === model),
|
|
46493
|
+
modelPricing: [
|
|
46494
|
+
{
|
|
46495
|
+
models: SUBQ_DECISION_MODELS.map(({ value }) => value),
|
|
46496
|
+
pricing: { inputPerMillionTokens: 0.04, outputPerMillionTokens: 0 }
|
|
46497
|
+
}
|
|
46498
|
+
],
|
|
46450
46499
|
maxRequestBytes: 13 * 1024 * 1024,
|
|
46451
46500
|
checkRequest: assertSubQDecisionLimits,
|
|
46452
46501
|
buildRequest: ({ model, state, questions }) => ({
|
|
@@ -56053,6 +56102,189 @@ function isLatestDebuggerScope(value) {
|
|
|
56053
56102
|
) && (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
56103
|
}
|
|
56055
56104
|
|
|
56105
|
+
// src/model/ExecutorSessionProtocol.ts
|
|
56106
|
+
var EXECUTOR_SESSION_V2 = "rivet-session-v2";
|
|
56107
|
+
var EXECUTOR_RELIABLE_MAX_BYTES = 100 * 1024 * 1024;
|
|
56108
|
+
var EXECUTOR_RELIABLE_SESSION_BYTES = 256 * 1024 * 1024;
|
|
56109
|
+
var EXECUTOR_RELIABLE_PROCESS_BYTES = 512 * 1024 * 1024;
|
|
56110
|
+
var EXECUTOR_RELIABLE_MAX_ITEMS = 4096;
|
|
56111
|
+
var EXECUTOR_TRANSFER_TIMEOUT_MS = 6e4;
|
|
56112
|
+
var deliveryPolicy = {
|
|
56113
|
+
start: "reliable",
|
|
56114
|
+
done: "reliable",
|
|
56115
|
+
error: "reliable",
|
|
56116
|
+
abort: "reliable",
|
|
56117
|
+
graphOutputsReady: "reliable",
|
|
56118
|
+
webAppStoragePatch: "reliable",
|
|
56119
|
+
userInput: "reliable",
|
|
56120
|
+
pause: "reliable",
|
|
56121
|
+
resume: "reliable",
|
|
56122
|
+
codeConsole: "diagnostic",
|
|
56123
|
+
nodeStart: "diagnostic",
|
|
56124
|
+
nodeFinish: "diagnostic",
|
|
56125
|
+
nodeError: "diagnostic",
|
|
56126
|
+
nodeExcluded: "diagnostic",
|
|
56127
|
+
graphAbort: "diagnostic",
|
|
56128
|
+
graphStart: "diagnostic",
|
|
56129
|
+
graphFinish: "diagnostic",
|
|
56130
|
+
partialOutput: "diagnostic",
|
|
56131
|
+
progress: "diagnostic",
|
|
56132
|
+
llmCallFinished: "diagnostic",
|
|
56133
|
+
llmChatOutputSnapshot: "diagnostic",
|
|
56134
|
+
llmProfileAttempt: "diagnostic",
|
|
56135
|
+
toolCallFinished: "diagnostic",
|
|
56136
|
+
nodeOutputsCleared: "diagnostic",
|
|
56137
|
+
streamingOutputWatchSummary: "diagnostic",
|
|
56138
|
+
graphError: "diagnostic",
|
|
56139
|
+
trace: "diagnostic"
|
|
56140
|
+
};
|
|
56141
|
+
var datasetMessages = {
|
|
56142
|
+
"datasets:get-metadata": true,
|
|
56143
|
+
"datasets:get-for-project": true,
|
|
56144
|
+
"datasets:get-data": true,
|
|
56145
|
+
"datasets:put-data": true,
|
|
56146
|
+
"datasets:put-row": true,
|
|
56147
|
+
"datasets:put-metadata": true,
|
|
56148
|
+
"datasets:clear-data": true,
|
|
56149
|
+
"datasets:delete": true,
|
|
56150
|
+
"datasets:knn": true,
|
|
56151
|
+
"datasets:export-for-project": true
|
|
56152
|
+
};
|
|
56153
|
+
function executorDeliveryPolicy(message2) {
|
|
56154
|
+
if (message2 === "graph-upload-allowed" || message2 === "executor-owner-retiring" || Object.hasOwn(datasetMessages, message2))
|
|
56155
|
+
return "reliable";
|
|
56156
|
+
if (Object.hasOwn(deliveryPolicy, message2)) return deliveryPolicy[message2];
|
|
56157
|
+
throw new ExecutorRecoveryError("invalid-transfer");
|
|
56158
|
+
}
|
|
56159
|
+
var CHUNK_CHARACTERS = 8192;
|
|
56160
|
+
var ExecutorRecoveryError = class extends Error {
|
|
56161
|
+
constructor(reason) {
|
|
56162
|
+
super(`Executor session could not be resumed (${reason}). Run outcome is unknown; it was not resubmitted.`);
|
|
56163
|
+
this.reason = reason;
|
|
56164
|
+
this.name = "ExecutorRecoveryError";
|
|
56165
|
+
}
|
|
56166
|
+
};
|
|
56167
|
+
var safeId = (value) => Number.isSafeInteger(value) && value > 0;
|
|
56168
|
+
var ExecutorReliableOutbox = class {
|
|
56169
|
+
constructor(maxBytes = EXECUTOR_RELIABLE_SESSION_BYTES, reservedBytes = 0) {
|
|
56170
|
+
this.maxBytes = maxBytes;
|
|
56171
|
+
this.reservedBytes = reservedBytes;
|
|
56172
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || !Number.isSafeInteger(reservedBytes) || reservedBytes < 0 || reservedBytes >= maxBytes)
|
|
56173
|
+
throw new Error("Invalid executor reliable retention limits");
|
|
56174
|
+
}
|
|
56175
|
+
#nextId = 0;
|
|
56176
|
+
#items = /* @__PURE__ */ new Map();
|
|
56177
|
+
bytes = 0;
|
|
56178
|
+
get size() {
|
|
56179
|
+
return this.#items.size;
|
|
56180
|
+
}
|
|
56181
|
+
add(text2, order, emergency = false) {
|
|
56182
|
+
const bytes = new TextEncoder().encode(text2).byteLength;
|
|
56183
|
+
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))
|
|
56184
|
+
throw new ExecutorRecoveryError("retention-limit");
|
|
56185
|
+
const id = ++this.#nextId;
|
|
56186
|
+
this.#items.set(id, { text: text2, bytes, index: 0, order: order ?? id, sent: false });
|
|
56187
|
+
this.bytes += bytes;
|
|
56188
|
+
return id;
|
|
56189
|
+
}
|
|
56190
|
+
acknowledge(id) {
|
|
56191
|
+
if (!safeId(id) || id > this.#nextId) throw new ExecutorRecoveryError("invalid-transfer");
|
|
56192
|
+
const item = this.#items.get(id);
|
|
56193
|
+
if (!item) return false;
|
|
56194
|
+
if (!item.sent) throw new ExecutorRecoveryError("invalid-transfer");
|
|
56195
|
+
this.bytes -= item.bytes;
|
|
56196
|
+
this.#items.delete(id);
|
|
56197
|
+
return true;
|
|
56198
|
+
}
|
|
56199
|
+
replay() {
|
|
56200
|
+
for (const item of this.#items.values()) item.index = 0;
|
|
56201
|
+
}
|
|
56202
|
+
peekOrder() {
|
|
56203
|
+
for (const item of this.#items.values())
|
|
56204
|
+
if (item.index < Math.max(1, Math.ceil(item.text.length / CHUNK_CHARACTERS))) return item.order;
|
|
56205
|
+
return void 0;
|
|
56206
|
+
}
|
|
56207
|
+
next() {
|
|
56208
|
+
for (const [id, item] of this.#items) {
|
|
56209
|
+
const count = Math.max(1, Math.ceil(item.text.length / CHUNK_CHARACTERS));
|
|
56210
|
+
if (item.index >= count) continue;
|
|
56211
|
+
const index = item.index++;
|
|
56212
|
+
if (item.index === count) item.sent = true;
|
|
56213
|
+
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;
|
|
56214
|
+
return {
|
|
56215
|
+
id,
|
|
56216
|
+
index,
|
|
56217
|
+
count,
|
|
56218
|
+
bytes: item.bytes,
|
|
56219
|
+
text: item.text.slice(
|
|
56220
|
+
boundary(index * CHUNK_CHARACTERS),
|
|
56221
|
+
boundary(Math.min(item.text.length, (index + 1) * CHUNK_CHARACTERS))
|
|
56222
|
+
)
|
|
56223
|
+
};
|
|
56224
|
+
}
|
|
56225
|
+
return void 0;
|
|
56226
|
+
}
|
|
56227
|
+
clear() {
|
|
56228
|
+
this.#items.clear();
|
|
56229
|
+
this.bytes = 0;
|
|
56230
|
+
}
|
|
56231
|
+
};
|
|
56232
|
+
var ExecutorReliableInbox = class {
|
|
56233
|
+
constructor(onExpiry, budget) {
|
|
56234
|
+
this.onExpiry = onExpiry;
|
|
56235
|
+
this.budget = budget;
|
|
56236
|
+
if (budget && (!Number.isSafeInteger(budget.bytes) || budget.bytes < 0 || !Number.isSafeInteger(budget.maxBytes ?? EXECUTOR_RELIABLE_PROCESS_BYTES) || (budget.maxBytes ?? EXECUTOR_RELIABLE_PROCESS_BYTES) < 1))
|
|
56237
|
+
throw new Error("Invalid executor receive budget");
|
|
56238
|
+
}
|
|
56239
|
+
#consumed = 0;
|
|
56240
|
+
#transfer;
|
|
56241
|
+
#timer;
|
|
56242
|
+
receive(value) {
|
|
56243
|
+
var _a, _b;
|
|
56244
|
+
if (!value || typeof value !== "object") throw new ExecutorRecoveryError("invalid-transfer");
|
|
56245
|
+
const part = value;
|
|
56246
|
+
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)
|
|
56247
|
+
throw new ExecutorRecoveryError("invalid-transfer");
|
|
56248
|
+
if (part.id <= this.#consumed) return { id: part.id };
|
|
56249
|
+
if (!this.#transfer) {
|
|
56250
|
+
if (this.budget) {
|
|
56251
|
+
if (this.budget.bytes + part.bytes > (this.budget.maxBytes ?? EXECUTOR_RELIABLE_PROCESS_BYTES))
|
|
56252
|
+
throw new ExecutorRecoveryError("retention-limit");
|
|
56253
|
+
this.budget.bytes += part.bytes;
|
|
56254
|
+
}
|
|
56255
|
+
this.#transfer = { id: part.id, count: part.count, total: part.bytes, parts: [], bytes: 0 };
|
|
56256
|
+
this.#timer = setTimeout(() => {
|
|
56257
|
+
var _a2;
|
|
56258
|
+
this.resetTransfer();
|
|
56259
|
+
(_a2 = this.onExpiry) == null ? void 0 : _a2.call(this);
|
|
56260
|
+
}, EXECUTOR_TRANSFER_TIMEOUT_MS);
|
|
56261
|
+
(_b = (_a = this.#timer).unref) == null ? void 0 : _b.call(_a);
|
|
56262
|
+
}
|
|
56263
|
+
const transfer = this.#transfer;
|
|
56264
|
+
if (transfer.id !== part.id || transfer.count !== part.count || transfer.total !== part.bytes || transfer.parts.length !== part.index)
|
|
56265
|
+
throw new ExecutorRecoveryError("invalid-transfer");
|
|
56266
|
+
transfer.bytes += new TextEncoder().encode(part.text).byteLength;
|
|
56267
|
+
if (transfer.bytes > transfer.total) throw new ExecutorRecoveryError("invalid-transfer");
|
|
56268
|
+
transfer.parts.push(part.text);
|
|
56269
|
+
if (transfer.parts.length !== transfer.count) return;
|
|
56270
|
+
if (transfer.bytes !== transfer.total) throw new ExecutorRecoveryError("invalid-transfer");
|
|
56271
|
+
const text2 = transfer.parts.join("");
|
|
56272
|
+
this.resetTransfer();
|
|
56273
|
+
this.#consumed = part.id;
|
|
56274
|
+
return { id: part.id, text: text2 };
|
|
56275
|
+
}
|
|
56276
|
+
resetTransfer() {
|
|
56277
|
+
if (this.#transfer && this.budget) this.budget.bytes -= this.#transfer.total;
|
|
56278
|
+
this.#transfer = void 0;
|
|
56279
|
+
clearTimeout(this.#timer);
|
|
56280
|
+
this.#timer = void 0;
|
|
56281
|
+
}
|
|
56282
|
+
clear() {
|
|
56283
|
+
this.#consumed = 0;
|
|
56284
|
+
this.resetTransfer();
|
|
56285
|
+
}
|
|
56286
|
+
};
|
|
56287
|
+
|
|
56056
56288
|
// src/index.ts
|
|
56057
56289
|
installCodeRunnerNamespace(exports_exports);
|
|
56058
56290
|
var Rivet = void 0;
|
|
@@ -56122,9 +56354,18 @@ var Rivet = void 0;
|
|
|
56122
56354
|
DestructureNodeImpl,
|
|
56123
56355
|
DidRunNodeImpl,
|
|
56124
56356
|
DocumentNodeImpl,
|
|
56357
|
+
EXECUTOR_RELIABLE_MAX_BYTES,
|
|
56358
|
+
EXECUTOR_RELIABLE_MAX_ITEMS,
|
|
56359
|
+
EXECUTOR_RELIABLE_PROCESS_BYTES,
|
|
56360
|
+
EXECUTOR_RELIABLE_SESSION_BYTES,
|
|
56361
|
+
EXECUTOR_SESSION_V2,
|
|
56362
|
+
EXECUTOR_TRANSFER_TIMEOUT_MS,
|
|
56125
56363
|
EXPRESSION_OUTPUT_PORT_ID,
|
|
56126
56364
|
EvaluateNodeImpl,
|
|
56127
56365
|
ExecutionRecorder,
|
|
56366
|
+
ExecutorRecoveryError,
|
|
56367
|
+
ExecutorReliableInbox,
|
|
56368
|
+
ExecutorReliableOutbox,
|
|
56128
56369
|
ExpressionNodeImpl,
|
|
56129
56370
|
ExternalCallNodeImpl,
|
|
56130
56371
|
ExtractJsonNodeImpl,
|
|
@@ -56428,6 +56669,7 @@ var Rivet = void 0;
|
|
|
56428
56669
|
evaluateJsonPath,
|
|
56429
56670
|
evaluateNode,
|
|
56430
56671
|
executeLLMInvocation,
|
|
56672
|
+
executorDeliveryPolicy,
|
|
56431
56673
|
expectType,
|
|
56432
56674
|
expectTypeOptional,
|
|
56433
56675
|
exportGentraceEvaluationRun,
|