@valerypopoff/rivet2-core 2.1.7 → 2.1.8
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 +3412 -1844
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/api/createProcessor.js +45 -4
- package/dist/esm/exports.js +2 -0
- package/dist/esm/integrations/KnowledgeStoreFieldPolicy.js +216 -0
- package/dist/esm/integrations/KnowledgeStoreProvider.js +14 -90
- package/dist/esm/integrations/ManagedKnowledgeStore.js +0 -8
- package/dist/esm/model/DataBusPorts.js +26 -0
- package/dist/esm/model/DataBusTopology.js +207 -0
- package/dist/esm/model/DataValue.js +22 -7
- package/dist/esm/model/GraphPreprocessor.js +9 -3
- package/dist/esm/model/GraphProcessor.js +163 -366
- package/dist/esm/model/NodeIO.js +1 -0
- package/dist/esm/model/NodePrefabResolver.js +16 -0
- package/dist/esm/model/Nodes.js +7 -0
- package/dist/esm/model/ToolCallContinuationBranchPlanner.js +165 -0
- package/dist/esm/model/ToolCallContinuationCoordinator.js +201 -0
- package/dist/esm/model/chat-v2/chatV2CallObserver.js +140 -0
- package/dist/esm/model/chat-v2/chatV2Errors.js +23 -6
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +47 -14
- package/dist/esm/model/chat-v2/chatV2ProviderTypes.js +1 -0
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +2 -2
- package/dist/esm/model/chat-v2/index.js +1 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +52 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +38 -13
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +42 -34
- package/dist/esm/model/chat-v2/llmProfile.js +191 -0
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +73 -0
- package/dist/esm/model/chat-v2/llmProfileTypes.js +45 -0
- package/dist/esm/model/nodes/DataBusNode.js +81 -0
- package/dist/esm/model/nodes/GetGlobalNode.js +7 -11
- package/dist/esm/model/nodes/GetKnowledgeSourceStatusNode.js +1 -1
- package/dist/esm/model/nodes/LLMChatV2Node.js +44 -10
- package/dist/esm/model/nodes/LLMProfileNode.js +132 -0
- package/dist/esm/model/nodes/PassthroughNode.js +1 -11
- package/dist/esm/model/nodes/SearchKnowledgeNode.js +1 -1
- package/dist/esm/model/nodes/SetGlobalNode.js +6 -6
- package/dist/esm/model/nodes/SyncKnowledgeSourceNode.js +0 -1
- package/dist/esm/model/nodes/toolCallDelegation.js +13 -2
- package/dist/esm/plugins/pinecone/PineconeKnowledgeStore.js +0 -4
- package/dist/esm/plugins/pinecone/plugin.js +1 -1
- package/dist/esm/utils/coerceType.js +84 -41
- package/dist/esm/utils/expectType.js +45 -8
- package/dist/esm/utils/fetchEventSource.js +18 -0
- package/dist/esm/utils/serialization/serialization.js +18 -7
- package/dist/esm/vendor/fnv1a.js +6 -3
- package/dist/types/api/createProcessor.d.ts +2 -0
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/integrations/KnowledgeStore.d.ts +0 -2
- package/dist/types/integrations/KnowledgeStoreFieldPolicy.d.ts +38 -0
- package/dist/types/integrations/KnowledgeStoreProvider.d.ts +6 -3
- package/dist/types/model/DataBusPorts.d.ts +6 -0
- package/dist/types/model/DataBusTopology.d.ts +16 -0
- package/dist/types/model/DataValue.d.ts +15 -5
- package/dist/types/model/GraphPreprocessor.d.ts +2 -1
- package/dist/types/model/GraphProcessor.d.ts +4 -3
- package/dist/types/model/NodeIO.d.ts +5 -0
- package/dist/types/model/NodePrefabResolver.d.ts +9 -0
- package/dist/types/model/Nodes.d.ts +5 -2
- package/dist/types/model/ProcessContext.d.ts +60 -0
- package/dist/types/model/ToolCallContinuationBranchPlanner.d.ts +43 -0
- package/dist/types/model/ToolCallContinuationCoordinator.d.ts +70 -0
- package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +10 -0
- package/dist/types/model/chat-v2/chatV2ProviderTypes.d.ts +1 -0
- package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +8 -0
- package/dist/types/model/chat-v2/chatV2Types.d.ts +3 -3
- package/dist/types/model/chat-v2/index.d.ts +1 -0
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +6 -0
- package/dist/types/model/chat-v2/llmChatV2NodeEditors.d.ts +5 -1
- package/dist/types/model/chat-v2/llmProfile.d.ts +3 -0
- package/dist/types/model/chat-v2/llmProfileNodeRuntime.d.ts +9 -0
- package/dist/types/model/chat-v2/llmProfileTypes.d.ts +18 -0
- package/dist/types/model/nodes/DataBusNode.d.ts +19 -0
- package/dist/types/model/nodes/LLMProfileNode.d.ts +20 -0
- package/dist/types/model/nodes/PassthroughNode.d.ts +2 -15
- package/dist/types/model/nodes/SetGlobalNode.d.ts +2 -2
- package/dist/types/model/nodes/toolCallDelegation.d.ts +9 -0
- package/dist/types/vendor/fnv1a.d.ts +5 -5
- package/package.json +1 -1
|
@@ -1,8 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getScalarTypeOf, isArrayDataType, isArrayDataValue, unwrapDataValue, } from '../model/DataValue.js';
|
|
1
|
+
import { getScalarTypeOf, isArrayDataType, isArrayDataValue, isFunctionDataType, isScalarDataType, unwrapDataValue, } from '../model/DataValue.js';
|
|
3
2
|
import { expectTypeOptional } from './expectType.js';
|
|
4
3
|
import { normalizeKnowledgeDocument, normalizeKnowledgeEvidence, normalizeKnowledgeSourceReference, } from '../integrations/KnowledgeStoreValidation.js';
|
|
4
|
+
import { normalizeLLMProfileValue } from '../model/chat-v2/llmProfile.js';
|
|
5
|
+
function isValidatedObjectValueType(type) {
|
|
6
|
+
return (type === 'knowledge-source' ||
|
|
7
|
+
type === 'knowledge-document' ||
|
|
8
|
+
type === 'knowledge-evidence' ||
|
|
9
|
+
type === 'llm-config');
|
|
10
|
+
}
|
|
11
|
+
function canAttemptGeneralCoercion(from, to) {
|
|
12
|
+
return !isValidatedObjectValueType(from) || to === 'object' || to === 'string';
|
|
13
|
+
}
|
|
14
|
+
function generalScalarRule(target, coerce) {
|
|
15
|
+
return {
|
|
16
|
+
...(coerce ? { coerce } : {}),
|
|
17
|
+
canAttempt: (from) => canAttemptGeneralCoercion(from, target),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function sameTypeOrObjectScalarRule(target, coerce) {
|
|
21
|
+
return {
|
|
22
|
+
...(coerce ? { coerce } : {}),
|
|
23
|
+
canAttempt: (from) => from === target || from === 'object',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The single scalar coercion policy used by both runtime conversion and
|
|
28
|
+
* type-level port compatibility. Array, function, and `any` wrappers are
|
|
29
|
+
* handled once around this registry because their behavior is structural.
|
|
30
|
+
*/
|
|
31
|
+
const scalarCoercionRules = {
|
|
32
|
+
any: {
|
|
33
|
+
canAttempt: () => true,
|
|
34
|
+
},
|
|
35
|
+
boolean: generalScalarRule('boolean', coerceToBoolean),
|
|
36
|
+
string: generalScalarRule('string', coerceToString),
|
|
37
|
+
number: generalScalarRule('number', coerceToNumber),
|
|
38
|
+
date: generalScalarRule('date'),
|
|
39
|
+
time: generalScalarRule('time'),
|
|
40
|
+
datetime: generalScalarRule('datetime'),
|
|
41
|
+
'chat-message': generalScalarRule('chat-message', coerceToChatMessage),
|
|
42
|
+
'control-flow-excluded': generalScalarRule('control-flow-excluded'),
|
|
43
|
+
object: generalScalarRule('object', coerceToObject),
|
|
44
|
+
'gpt-function': {
|
|
45
|
+
canAttempt: (from) => from === 'object',
|
|
46
|
+
},
|
|
47
|
+
vector: generalScalarRule('vector'),
|
|
48
|
+
image: sameTypeOrObjectScalarRule('image'),
|
|
49
|
+
binary: sameTypeOrObjectScalarRule('binary', coerceToBinary),
|
|
50
|
+
audio: sameTypeOrObjectScalarRule('audio'),
|
|
51
|
+
'graph-reference': generalScalarRule('graph-reference', coerceToGraphReference),
|
|
52
|
+
'knowledge-source': sameTypeOrObjectScalarRule('knowledge-source', (value) => coerceValidatedObjectValue(value, normalizeKnowledgeSourceReference)),
|
|
53
|
+
'knowledge-document': sameTypeOrObjectScalarRule('knowledge-document', (value) => coerceValidatedObjectValue(value, normalizeKnowledgeDocument)),
|
|
54
|
+
'knowledge-evidence': sameTypeOrObjectScalarRule('knowledge-evidence', (value) => coerceValidatedObjectValue(value, normalizeKnowledgeEvidence)),
|
|
55
|
+
'llm-config': sameTypeOrObjectScalarRule('llm-config', (value) => coerceValidatedObjectValue(value, normalizeLLMProfileValue)),
|
|
56
|
+
document: generalScalarRule('document'),
|
|
57
|
+
};
|
|
5
58
|
export function coerceTypeOptional(wrapped, type) {
|
|
59
|
+
if (wrapped && isFunctionDataType(type)) {
|
|
60
|
+
return expectTypeOptional(wrapped, type);
|
|
61
|
+
}
|
|
6
62
|
const value = wrapped ? unwrapDataValue(wrapped) : undefined;
|
|
7
63
|
// Coerce 'true' to [true] for example
|
|
8
64
|
if (isArrayDataType(type) && !isArrayDataValue(value)) {
|
|
@@ -14,34 +70,30 @@ export function coerceTypeOptional(wrapped, type) {
|
|
|
14
70
|
// @ts-expect-error Generic T is not narrowed to its array subtype within this runtime-guarded branch.
|
|
15
71
|
return coercedArray;
|
|
16
72
|
}
|
|
17
|
-
//
|
|
18
|
-
|
|
73
|
+
// Preserve arrays whose runtime shape is carried by an any/object wrapper,
|
|
74
|
+
// or coerce each item when the scalar families differ.
|
|
75
|
+
if (isArrayDataType(type) && isArrayDataValue(value)) {
|
|
76
|
+
if (getScalarTypeOf(type) === getScalarTypeOf(value.type)) {
|
|
77
|
+
// @ts-expect-error Generic T is not narrowed to its array subtype within this runtime-guarded branch.
|
|
78
|
+
return value.value;
|
|
79
|
+
}
|
|
19
80
|
const coercedArray = value.value.map((v) => coerceTypeOptional({ type: getScalarTypeOf(value.type), value: v }, getScalarTypeOf(type)));
|
|
20
81
|
// @ts-expect-error Generic T is not narrowed to its array subtype within this runtime-guarded branch.
|
|
21
82
|
return coercedArray;
|
|
22
83
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
.with('boolean', () => coerceToBoolean(value))
|
|
26
|
-
.with('chat-message', () => coerceToChatMessage(value))
|
|
27
|
-
.with('number', () => coerceToNumber(value))
|
|
28
|
-
.with('object', () => coerceToObject(value))
|
|
29
|
-
.with('binary', () => coerceToBinary(value))
|
|
30
|
-
.with('graph-reference', () => coerceToGraphReference(value))
|
|
31
|
-
.with('knowledge-source', () => coerceKnowledgeValue(value, normalizeKnowledgeSourceReference))
|
|
32
|
-
.with('knowledge-document', () => coerceKnowledgeValue(value, normalizeKnowledgeDocument))
|
|
33
|
-
.with('knowledge-evidence', () => coerceKnowledgeValue(value, normalizeKnowledgeEvidence))
|
|
34
|
-
.otherwise(() => {
|
|
35
|
-
if (!value) {
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
if (getScalarTypeOf(value.type) === 'any' || getScalarTypeOf(type) === 'any') {
|
|
39
|
-
return value.value;
|
|
40
|
-
}
|
|
41
|
-
return expectTypeOptional(value, type);
|
|
42
|
-
});
|
|
84
|
+
const scalarRule = isScalarDataType(type) ? scalarCoercionRules[type] : undefined;
|
|
85
|
+
const result = scalarRule?.coerce ? scalarRule.coerce(value) : coerceWithoutSpecializedRule(value, type);
|
|
43
86
|
return result;
|
|
44
87
|
}
|
|
88
|
+
function coerceWithoutSpecializedRule(value, type) {
|
|
89
|
+
if (!value) {
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
if (getScalarTypeOf(value.type) === 'any' || getScalarTypeOf(type) === 'any') {
|
|
93
|
+
return value.value;
|
|
94
|
+
}
|
|
95
|
+
return expectTypeOptional(value, type);
|
|
96
|
+
}
|
|
45
97
|
export function coerceType(value, type) {
|
|
46
98
|
const result = coerceTypeOptional(value, type);
|
|
47
99
|
if (result === undefined) {
|
|
@@ -299,7 +351,7 @@ function coerceToGraphReference(value) {
|
|
|
299
351
|
}
|
|
300
352
|
return undefined;
|
|
301
353
|
}
|
|
302
|
-
function
|
|
354
|
+
function coerceValidatedObjectValue(value, normalize) {
|
|
303
355
|
if (!value || value.value == null || isArrayDataValue(value))
|
|
304
356
|
return undefined;
|
|
305
357
|
try {
|
|
@@ -319,9 +371,11 @@ export function canBeCoercedAny(from, to) {
|
|
|
319
371
|
}
|
|
320
372
|
return false;
|
|
321
373
|
}
|
|
322
|
-
// TODO hard to keep in sync with coerceType
|
|
323
374
|
export function canBeCoerced(from, to) {
|
|
324
|
-
if (to === 'any'
|
|
375
|
+
if (to === 'any') {
|
|
376
|
+
return scalarCoercionRules.any.canAttempt(from);
|
|
377
|
+
}
|
|
378
|
+
if (from === 'any') {
|
|
325
379
|
return true;
|
|
326
380
|
}
|
|
327
381
|
if (isArrayDataType(to) && isArrayDataType(from)) {
|
|
@@ -333,19 +387,8 @@ export function canBeCoerced(from, to) {
|
|
|
333
387
|
if (isArrayDataType(from) && !isArrayDataType(to)) {
|
|
334
388
|
return to === 'string' || to === 'object';
|
|
335
389
|
}
|
|
336
|
-
if (to
|
|
337
|
-
return from
|
|
338
|
-
}
|
|
339
|
-
if (to === 'audio' ||
|
|
340
|
-
to === 'binary' ||
|
|
341
|
-
to === 'image' ||
|
|
342
|
-
to === 'knowledge-source' ||
|
|
343
|
-
to === 'knowledge-document' ||
|
|
344
|
-
to === 'knowledge-evidence') {
|
|
345
|
-
return from === to || from === 'object';
|
|
346
|
-
}
|
|
347
|
-
if (from === 'knowledge-source' || from === 'knowledge-document' || from === 'knowledge-evidence') {
|
|
348
|
-
return to === 'object' || to === 'string';
|
|
390
|
+
if (isScalarDataType(to)) {
|
|
391
|
+
return scalarCoercionRules[to].canAttempt(from);
|
|
349
392
|
}
|
|
350
|
-
return
|
|
393
|
+
return canAttemptGeneralCoercion(from, to);
|
|
351
394
|
}
|
|
@@ -1,28 +1,65 @@
|
|
|
1
|
-
import { getScalarTypeOf, isArrayDataType, isFunctionDataType, isScalarDataValue, unwrapDataValue, } from '../model/DataValue.js';
|
|
1
|
+
import { functionTypeToReturnType, getScalarTypeOf, isArrayDataType, isArrayDataValue, isFunctionDataType, isScalarDataValue, unwrapDataValue, } from '../model/DataValue.js';
|
|
2
|
+
function getDeferredValue(value, type) {
|
|
3
|
+
const targetReturnType = functionTypeToReturnType(type);
|
|
4
|
+
if (isFunctionDataType(value.type)) {
|
|
5
|
+
const sourceReturnType = functionTypeToReturnType(value.type);
|
|
6
|
+
return targetReturnType === 'any' || sourceReturnType === 'any' || sourceReturnType === targetReturnType
|
|
7
|
+
? value.value
|
|
8
|
+
: undefined;
|
|
9
|
+
}
|
|
10
|
+
if (value.type === 'any' && typeof value.value === 'function') {
|
|
11
|
+
return value.value;
|
|
12
|
+
}
|
|
13
|
+
if (targetReturnType === 'any' || value.type === 'any' || value.type === targetReturnType) {
|
|
14
|
+
return () => value.value;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
2
18
|
export function expectType(value, type) {
|
|
19
|
+
if (isArrayDataType(type) && isArrayDataValue(value) && getScalarTypeOf(type) === getScalarTypeOf(value.type)) {
|
|
20
|
+
return value.value;
|
|
21
|
+
}
|
|
3
22
|
// Allow a string to be expected for a string[], just return an array of one element
|
|
4
23
|
if (isArrayDataType(type) && isScalarDataValue(value) && getScalarTypeOf(type) === value.type) {
|
|
5
24
|
return [value.value];
|
|
6
25
|
}
|
|
7
|
-
if (
|
|
8
|
-
return value
|
|
26
|
+
if (value?.type === type) {
|
|
27
|
+
return value.value;
|
|
9
28
|
}
|
|
10
|
-
if (
|
|
11
|
-
|
|
29
|
+
if (value && isFunctionDataType(type)) {
|
|
30
|
+
const deferredValue = getDeferredValue(value, type);
|
|
31
|
+
if (deferredValue) {
|
|
32
|
+
return deferredValue;
|
|
33
|
+
}
|
|
12
34
|
}
|
|
13
|
-
if (value?.type
|
|
14
|
-
|
|
35
|
+
if (type === 'any' || type === 'any[]' || value?.type === 'any' || value?.type === 'any[]') {
|
|
36
|
+
return value?.value;
|
|
15
37
|
}
|
|
16
|
-
|
|
38
|
+
throw new Error(`Expected value of type ${type} but got ${value?.type}`);
|
|
17
39
|
}
|
|
18
40
|
export function expectTypeOptional(value, type) {
|
|
19
41
|
if (value === undefined) {
|
|
20
42
|
return undefined;
|
|
21
43
|
}
|
|
44
|
+
if (isArrayDataType(type) && isArrayDataValue(value) && getScalarTypeOf(type) === getScalarTypeOf(value.type)) {
|
|
45
|
+
// @ts-expect-error Generic T is not narrowed to its array subtype within this runtime-guarded branch.
|
|
46
|
+
return value.value;
|
|
47
|
+
}
|
|
22
48
|
// Allow a string to be expected for a string[], just return an array of one element
|
|
23
49
|
if (isArrayDataType(type) && isScalarDataValue(value) && getScalarTypeOf(type) === value.type) {
|
|
24
50
|
return [value.value];
|
|
25
51
|
}
|
|
52
|
+
if (value.type === type) {
|
|
53
|
+
// @ts-expect-error Generic T is not narrowed by comparing a DataValue's discriminant to T.
|
|
54
|
+
return value.value;
|
|
55
|
+
}
|
|
56
|
+
if (isFunctionDataType(type)) {
|
|
57
|
+
const deferredValue = getDeferredValue(value, type);
|
|
58
|
+
if (deferredValue) {
|
|
59
|
+
// @ts-expect-error Generic T is not narrowed to its function subtype within this runtime-guarded branch.
|
|
60
|
+
return deferredValue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
26
63
|
// We allow a fn<string> to be expected for a string, so unwrap it on demand
|
|
27
64
|
if (isFunctionDataType(value.type) && value.type === `fn<${type}>`) {
|
|
28
65
|
value = unwrapDataValue(value);
|
|
@@ -27,16 +27,34 @@ export class EventSourceResponse extends Response {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const reader = this.streams.eventStream.getReader();
|
|
30
|
+
let reachedEnd = false;
|
|
31
|
+
let emittedEvent = false;
|
|
32
|
+
let rawBranchCancellation;
|
|
33
|
+
const cancelRawBranch = () => {
|
|
34
|
+
rawBranchCancellation ??= this.body?.cancel();
|
|
35
|
+
return rawBranchCancellation;
|
|
36
|
+
};
|
|
30
37
|
try {
|
|
31
38
|
while (true) {
|
|
32
39
|
const { done, value } = await this.raceWithTimeout(reader.read(), this.timeout);
|
|
33
40
|
if (done) {
|
|
41
|
+
reachedEnd = true;
|
|
34
42
|
break;
|
|
35
43
|
}
|
|
44
|
+
if (!emittedEvent) {
|
|
45
|
+
emittedEvent = true;
|
|
46
|
+
// The raw branch only exists for non-SSE provider errors. Once the
|
|
47
|
+
// event branch produces output, retaining it would buffer the entire
|
|
48
|
+
// provider stream for a fallback that cannot be used.
|
|
49
|
+
void cancelRawBranch()?.catch(() => undefined);
|
|
50
|
+
}
|
|
36
51
|
yield value;
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
finally {
|
|
55
|
+
if (!reachedEnd) {
|
|
56
|
+
await Promise.allSettled([reader.cancel(), cancelRawBranch()]);
|
|
57
|
+
}
|
|
40
58
|
try {
|
|
41
59
|
reader.releaseLock();
|
|
42
60
|
}
|
|
@@ -16,7 +16,7 @@ export function deserializeProject(serializedProject, path = null) {
|
|
|
16
16
|
const { deserializerInput, version } = prepareSerializedInput(serializedProject);
|
|
17
17
|
try {
|
|
18
18
|
const result = deserializeProjectByVersion(deserializerInput, version);
|
|
19
|
-
|
|
19
|
+
normalizeDeserializedProject(result[0]);
|
|
20
20
|
if (path !== null) {
|
|
21
21
|
result[0].metadata.path = path;
|
|
22
22
|
}
|
|
@@ -43,7 +43,7 @@ export function deserializeGraph(serializedGraph) {
|
|
|
43
43
|
const { deserializerInput, version } = prepareSerializedInput(serializedGraph);
|
|
44
44
|
try {
|
|
45
45
|
const graph = deserializeGraphByVersion(deserializerInput, version);
|
|
46
|
-
|
|
46
|
+
normalizeDeserializedGraph(graph);
|
|
47
47
|
return graph;
|
|
48
48
|
}
|
|
49
49
|
catch (err) {
|
|
@@ -54,23 +54,34 @@ export function deserializeGraph(serializedGraph) {
|
|
|
54
54
|
throw new Error('Could not deserialize graph');
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function normalizeDeserializedProject(project) {
|
|
58
58
|
for (const graph of Object.values(project.graphs)) {
|
|
59
|
-
|
|
59
|
+
normalizeDeserializedGraph(graph);
|
|
60
|
+
}
|
|
61
|
+
for (const prefab of Object.values(project.nodePrefabs ?? {})) {
|
|
62
|
+
normalizeDeserializedNode(prefab.sourceNode);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
|
-
function
|
|
65
|
+
function normalizeDeserializedGraph(graph) {
|
|
63
66
|
for (const node of graph.nodes) {
|
|
64
|
-
|
|
67
|
+
normalizeDeserializedNode(node);
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
|
-
function
|
|
70
|
+
function hasLegacyDataBusFlag(node) {
|
|
71
|
+
const data = node.data;
|
|
72
|
+
return node.type === 'passthrough' && data != null && Object.hasOwn(data, 'renderAsDataBus');
|
|
73
|
+
}
|
|
74
|
+
function normalizeDeserializedNode(node) {
|
|
68
75
|
if (node.type === 'code' && node.title === 'Code') {
|
|
69
76
|
node.title = 'Code (legacy)';
|
|
70
77
|
}
|
|
71
78
|
else if (node.type === 'codeNew' && node.title === 'Code new') {
|
|
72
79
|
node.title = 'Code';
|
|
73
80
|
}
|
|
81
|
+
if (hasLegacyDataBusFlag(node)) {
|
|
82
|
+
const { renderAsDataBus: _legacyFlag, ...data } = node.data;
|
|
83
|
+
node.data = data;
|
|
84
|
+
}
|
|
74
85
|
}
|
|
75
86
|
function deserializeProjectByVersion(serializedProject, version) {
|
|
76
87
|
switch (version) {
|
package/dist/esm/vendor/fnv1a.js
CHANGED
|
@@ -53,6 +53,9 @@ function fnv1aEncodeInto(string, size, utf8Buffer) {
|
|
|
53
53
|
let remaining = string;
|
|
54
54
|
while (remaining.length > 0) {
|
|
55
55
|
const result = cachedEncoder.encodeInto(remaining, utf8Buffer);
|
|
56
|
+
if (result.read === 0) {
|
|
57
|
+
throw new Error('The `utf8Buffer` option is too small to encode the next character');
|
|
58
|
+
}
|
|
56
59
|
remaining = remaining.slice(result.read);
|
|
57
60
|
for (let index = 0; index < result.written; index++) {
|
|
58
61
|
hash ^= BigInt(utf8Buffer[index]);
|
|
@@ -62,9 +65,9 @@ function fnv1aEncodeInto(string, size, utf8Buffer) {
|
|
|
62
65
|
return hash;
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
65
|
-
* @param {string} value
|
|
66
|
-
* @param {{ size?: 32 | 64 | 128 | 256 | 512 | 1024, utf8Buffer?: Uint8Array }} options
|
|
67
|
-
* @returns {
|
|
68
|
+
* @param {string | Uint8Array} value
|
|
69
|
+
* @param {{ size?: 32 | 64 | 128 | 256 | 512 | 1024, utf8Buffer?: Uint8Array }} [options]
|
|
70
|
+
* @returns {bigint}
|
|
68
71
|
*/
|
|
69
72
|
export default function fnv1a(value, { size = 32, utf8Buffer } = {}) {
|
|
70
73
|
if (!FNV_PRIMES[size]) {
|
|
@@ -37,6 +37,7 @@ export type RunGraphOptions = {
|
|
|
37
37
|
includeTrace?: boolean;
|
|
38
38
|
concurrency?: GraphProcessorConcurrency;
|
|
39
39
|
getChatNodeEndpoint?: ProcessContext['getChatNodeEndpoint'];
|
|
40
|
+
onChatV2CallFinished?: ProcessContext['onChatV2CallFinished'];
|
|
40
41
|
tokenizer?: Tokenizer;
|
|
41
42
|
codeRunner?: ProcessContext['codeRunner'];
|
|
42
43
|
projectPath?: string;
|
|
@@ -63,6 +64,7 @@ export declare function coreCreateProcessor(project: Project, options: RunGraphO
|
|
|
63
64
|
getEvents: (spec: RivetEventStreamFilterSpec) => AsyncGenerator<import("./streaming.js").RivetEventStreamEventInfo, void, any>;
|
|
64
65
|
getSSEStream: (spec: RivetEventStreamFilterSpec) => ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
65
66
|
streamNode: (nodeIdOrTitle: string) => ReadableStream<string>;
|
|
67
|
+
dispose(): void;
|
|
66
68
|
run(): Promise<import("../model/GraphProcessor.js").GraphOutputs>;
|
|
67
69
|
};
|
|
68
70
|
export declare function coreRunGraph(project: Project, options: RunGraphOptions): Promise<Record<string, DataValue>>;
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export * from './integrations/integrations.js';
|
|
|
34
34
|
import './integrations/enableIntegrations.js';
|
|
35
35
|
export * from './integrations/VectorDatabase.js';
|
|
36
36
|
export * from './integrations/KnowledgeStore.js';
|
|
37
|
+
export * from './integrations/KnowledgeStoreFieldPolicy.js';
|
|
37
38
|
export * from './integrations/KnowledgeStoreProvider.js';
|
|
38
39
|
export * from './integrations/KnowledgeStoreValidation.js';
|
|
39
40
|
export * from './integrations/ManagedKnowledgeStore.js';
|
|
@@ -63,6 +64,7 @@ export * from './integrations/CodeRunner.js';
|
|
|
63
64
|
export * from './integrations/Tokenizer.js';
|
|
64
65
|
export * from './integrations/GptTokenizerTokenizer.js';
|
|
65
66
|
export { JS_LIST_CALLBACK_LOCAL_NAMES, interpolateJSListCallbackBody } from './model/nodes/jsListCallbackHelpers.js';
|
|
67
|
+
export { findAutoDelegateGraphCandidate } from './model/nodes/toolCallDelegation.js';
|
|
66
68
|
export { extractInterpolationVariables, findInterpolationTokenSpans, getInterpolationTokenName, interpolate, protectEscapedInterpolationTokens, restoreEscapedInterpolationTokens, } from './utils/interpolation.js';
|
|
67
69
|
export { WarningsPort } from './utils/symbols.js';
|
|
68
70
|
import * as openai from './utils/openai.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { GraphProgress } from '../model/GraphProgress.js';
|
|
2
1
|
export type KnowledgeStoreConnectionId = string;
|
|
3
2
|
export type KnowledgeMetadataScalar = null | boolean | number | string;
|
|
4
3
|
export type KnowledgeMetadataValue = KnowledgeMetadataScalar | boolean[] | number[] | string[];
|
|
@@ -44,7 +43,6 @@ export type RivetKnowledgeStoreCapabilities = {
|
|
|
44
43
|
};
|
|
45
44
|
export type KnowledgeOperationContext = {
|
|
46
45
|
signal: AbortSignal;
|
|
47
|
-
reportProgress?: (progress: GraphProgress) => void;
|
|
48
46
|
getTokenCount?: (text: string) => Promise<number>;
|
|
49
47
|
};
|
|
50
48
|
export type KnowledgeChunkingOptions = {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Settings } from '../model/Settings.js';
|
|
2
|
+
import type { KnowledgeStoreConnectionDefinition } from '../model/Project.js';
|
|
3
|
+
import type { KnowledgeMetadata } from './KnowledgeStore.js';
|
|
4
|
+
import type { KnowledgeStoreProviderConfigField, KnowledgeStoreProviderCredentialField, KnowledgeStoreProviderDefinition } from './KnowledgeStoreProvider.js';
|
|
5
|
+
export type KnowledgeStoreProviderFieldIssueCode = 'required' | 'expected-boolean' | 'expected-finite-number' | 'expected-string' | 'unsupported-select-value';
|
|
6
|
+
export type KnowledgeStoreProviderFieldIssue = Readonly<{
|
|
7
|
+
code: KnowledgeStoreProviderFieldIssueCode;
|
|
8
|
+
fieldKey: string;
|
|
9
|
+
fieldLabel: string;
|
|
10
|
+
}>;
|
|
11
|
+
export type KnowledgeStoreFieldNormalizationResult<T> = Readonly<{
|
|
12
|
+
ok: true;
|
|
13
|
+
value: T;
|
|
14
|
+
}> | Readonly<{
|
|
15
|
+
ok: false;
|
|
16
|
+
issue: KnowledgeStoreProviderFieldIssue;
|
|
17
|
+
}>;
|
|
18
|
+
export type KnowledgeStoreNormalizedProviderFieldValue = Readonly<{
|
|
19
|
+
present: false;
|
|
20
|
+
}> | Readonly<{
|
|
21
|
+
present: true;
|
|
22
|
+
value: string | number | boolean;
|
|
23
|
+
}>;
|
|
24
|
+
type ProviderConnectionPolicy = Pick<KnowledgeStoreProviderDefinition, 'id' | 'pluginId' | 'connectionConfigSpec'>;
|
|
25
|
+
type ProviderCredentialPolicy = Pick<KnowledgeStoreProviderDefinition, 'id' | 'credentialConfigSpec'>;
|
|
26
|
+
export type KnowledgeStoreProviderFieldNormalizationMode = 'connection-draft' | 'connection-runtime' | 'credential-draft' | 'credential-runtime';
|
|
27
|
+
export declare function createKnowledgeStoreFieldDraftDefaults(fields: ReadonlyArray<KnowledgeStoreProviderConfigField>): Record<string, unknown>;
|
|
28
|
+
/** Normalizes one declared provider field at an explicit editor or runtime boundary. */
|
|
29
|
+
export declare function normalizeKnowledgeStoreProviderFieldValue(field: KnowledgeStoreProviderConfigField, value: unknown, mode: KnowledgeStoreProviderFieldNormalizationMode): KnowledgeStoreFieldNormalizationResult<KnowledgeStoreNormalizedProviderFieldValue>;
|
|
30
|
+
export declare function isKnowledgeStoreProviderFieldDefaultValid(field: KnowledgeStoreProviderConfigField, value: unknown): boolean;
|
|
31
|
+
export declare function normalizeKnowledgeStoreConnectionDraftConfig(fields: ReadonlyArray<KnowledgeStoreProviderConfigField>, values: Readonly<Record<string, unknown>>): KnowledgeStoreFieldNormalizationResult<KnowledgeMetadata>;
|
|
32
|
+
export declare function normalizeKnowledgeStoreCredentialFields(fields: ReadonlyArray<KnowledgeStoreProviderCredentialField>, values: Readonly<Record<string, unknown>>): KnowledgeStoreFieldNormalizationResult<Record<string, string>>;
|
|
33
|
+
export declare function normalizeKnowledgeStoreConnectionDefinition(connectionId: string, definition: KnowledgeStoreConnectionDefinition, provider: ProviderConnectionPolicy): KnowledgeStoreConnectionDefinition;
|
|
34
|
+
export declare function readKnowledgeStoreConnectionCredentials(settings: Settings, provider: ProviderCredentialPolicy, connectionId: string): KnowledgeStoreFieldNormalizationResult<Record<string, string>>;
|
|
35
|
+
export declare function readKnowledgeStoreConnectionCredentialsDraft(settings: Settings, provider: ProviderCredentialPolicy, connectionId: string): Record<string, string>;
|
|
36
|
+
export declare function writeKnowledgeStoreConnectionCredentials(settings: Settings, providerId: string, connectionId: string, credentials: Readonly<Record<string, string>>): Settings;
|
|
37
|
+
export declare function removeKnowledgeStoreConnectionCredentials(settings: Settings, providerId: string, connectionId: string): Settings;
|
|
38
|
+
export {};
|
|
@@ -14,15 +14,18 @@ export type KnowledgeStoreProviderConfigField = {
|
|
|
14
14
|
value: string;
|
|
15
15
|
}>;
|
|
16
16
|
};
|
|
17
|
+
export type KnowledgeStoreProviderCredentialField = Omit<KnowledgeStoreProviderConfigField, 'type' | 'default' | 'options'> & {
|
|
18
|
+
type: 'string' | 'secret';
|
|
19
|
+
default?: string;
|
|
20
|
+
options?: never;
|
|
21
|
+
};
|
|
17
22
|
export type KnowledgeStoreProviderDefinition = {
|
|
18
23
|
id: string;
|
|
19
24
|
displayName: string;
|
|
20
25
|
/** Rivet plugin that owns this provider. Defaults to the provider ID. */
|
|
21
26
|
pluginId?: string;
|
|
22
27
|
connectionConfigSpec: KnowledgeStoreProviderConfigField[];
|
|
23
|
-
credentialConfigSpec?:
|
|
24
|
-
type: 'string' | 'secret';
|
|
25
|
-
}>;
|
|
28
|
+
credentialConfigSpec?: KnowledgeStoreProviderCredentialField[];
|
|
26
29
|
supportedExecutors: Array<'browser' | 'nodejs'>;
|
|
27
30
|
createStore(connectionId: KnowledgeStoreConnectionId, definition: KnowledgeStoreConnectionDefinition, context: KnowledgeStoreProviderContext): RivetKnowledgeStore | Promise<RivetKnowledgeStore>;
|
|
28
31
|
testConnection?(definition: KnowledgeStoreConnectionDefinition, credentials: Record<string, string>, signal: AbortSignal, context: KnowledgeStoreProviderTestContext): void | Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PortId } from './NodeBase.js';
|
|
2
|
+
/** Shared hard safety limit for the dynamic Data Bus channel port range. */
|
|
3
|
+
export declare const MAX_DATA_BUS_CHANNEL_INDEX = 10000;
|
|
4
|
+
export declare function parseDataBusChannelIndex(portId: string, input: boolean): number | undefined;
|
|
5
|
+
export declare function getDataBusInputPortId(channelIndex: number): PortId;
|
|
6
|
+
export declare function getDataBusOutputPortId(channelIndex: number): PortId;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DataBusNode } from './nodes/DataBusNode.js';
|
|
2
|
+
import type { ChartNode, NodeConnection, NodeId, PortId } from './NodeBase.js';
|
|
3
|
+
export type DataBusTopologyNode = DataBusNode;
|
|
4
|
+
export type CompiledDataBusTopology = {
|
|
5
|
+
connections: NodeConnection[];
|
|
6
|
+
executionNodes: ChartNode[];
|
|
7
|
+
};
|
|
8
|
+
export declare function isDataBusTopologyNode(node: ChartNode | undefined): node is DataBusTopologyNode;
|
|
9
|
+
export declare function canRenderDataBusNode(node: ChartNode | undefined): node is DataBusTopologyNode;
|
|
10
|
+
export declare function getDataBusChannelKey(busNodeId: NodeId, channelIndex: number): string;
|
|
11
|
+
export declare function getDataBusInputChannelIndex(portId: PortId): number | undefined;
|
|
12
|
+
export declare function getDataBusOutputChannelIndex(portId: PortId): number | undefined;
|
|
13
|
+
export declare function compileDataBusTopology(options: {
|
|
14
|
+
connections: readonly NodeConnection[];
|
|
15
|
+
graphNodes: readonly ChartNode[];
|
|
16
|
+
}): CompiledDataBusTopology;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GraphId } from '../index.js';
|
|
2
2
|
import type { DataId } from './Project.js';
|
|
3
3
|
import type { RivetKnowledgeDocument, RivetKnowledgeEvidence, RivetKnowledgeSourceReference } from '../integrations/KnowledgeStore.js';
|
|
4
|
+
import { type LLMProfileValue } from './chat-v2/llmProfileTypes.js';
|
|
4
5
|
export type DataValueDef<Type extends string, RuntimeType> = {
|
|
5
6
|
type: Type;
|
|
6
7
|
value: RuntimeType;
|
|
@@ -88,6 +89,7 @@ export type GraphReferenceValue = DataValueDef<'graph-reference', {
|
|
|
88
89
|
export type KnowledgeSourceDataValue = DataValueDef<'knowledge-source', RivetKnowledgeSourceReference>;
|
|
89
90
|
export type KnowledgeDocumentDataValue = DataValueDef<'knowledge-document', RivetKnowledgeDocument>;
|
|
90
91
|
export type KnowledgeEvidenceDataValue = DataValueDef<'knowledge-evidence', RivetKnowledgeEvidence>;
|
|
92
|
+
export type LLMProfileDataValue = DataValueDef<'llm-config', LLMProfileValue>;
|
|
91
93
|
export type DocumentDataValue = DataValueDef<'document', {
|
|
92
94
|
mediaType: SupportedDocumentMediaTypes;
|
|
93
95
|
data: Uint8Array;
|
|
@@ -108,7 +110,7 @@ export type GptFunction = {
|
|
|
108
110
|
};
|
|
109
111
|
export type GptFunctionDataValue = DataValueDef<'gpt-function', GptFunction>;
|
|
110
112
|
export type ControlFlowExcludedDataValue = DataValueDef<'control-flow-excluded', undefined | 'loop-not-broken'>;
|
|
111
|
-
export type ScalarDataValue = StringDataValue | NumberDataValue | DateDataValue | TimeDataValue | DateTimeDataValue | BoolDataValue | ChatMessageDataValue | ControlFlowExcludedDataValue | AnyDataValue | ObjectDataValue | GptFunctionDataValue | VectorDataValue | ImageDataValue | BinaryDataValue | AudioDataValue | GraphReferenceValue | KnowledgeSourceDataValue | KnowledgeDocumentDataValue | KnowledgeEvidenceDataValue | DocumentDataValue;
|
|
113
|
+
export type ScalarDataValue = StringDataValue | NumberDataValue | DateDataValue | TimeDataValue | DateTimeDataValue | BoolDataValue | ChatMessageDataValue | ControlFlowExcludedDataValue | AnyDataValue | ObjectDataValue | GptFunctionDataValue | VectorDataValue | ImageDataValue | BinaryDataValue | AudioDataValue | GraphReferenceValue | KnowledgeSourceDataValue | KnowledgeDocumentDataValue | KnowledgeEvidenceDataValue | LLMProfileDataValue | DocumentDataValue;
|
|
112
114
|
export type ScalarType = ScalarDataValue['type'];
|
|
113
115
|
export type ArrayDataValue<T extends ScalarDataValue> = DataValueDef<`${T['type']}[]`, T['value'][]>;
|
|
114
116
|
export type FunctionDataValue<T extends ScalarOrArrayDataValue> = DataValueDef<`fn<${T['type']}>`, () => T['value']>;
|
|
@@ -118,6 +120,11 @@ export type ArrayDataValues = {
|
|
|
118
120
|
type: P;
|
|
119
121
|
}>>;
|
|
120
122
|
}[ScalarDataValue['type']];
|
|
123
|
+
export type ArrayLikeDataValue = ArrayDataValues | (AnyDataValue & {
|
|
124
|
+
value: unknown[];
|
|
125
|
+
}) | (ObjectDataValue & {
|
|
126
|
+
value: unknown[];
|
|
127
|
+
});
|
|
121
128
|
export type ScalarOrArrayDataValue = ScalarDataValue | ArrayDataValues;
|
|
122
129
|
export type FunctionDataValues = {
|
|
123
130
|
[P in ScalarOrArrayDataValue['type']]: FunctionDataValue<Extract<ScalarOrArrayDataValue, {
|
|
@@ -137,16 +144,19 @@ export type GetDataValue<Type extends DataType> = Extract<DataValue, {
|
|
|
137
144
|
export type DataRef = {
|
|
138
145
|
refId: DataId;
|
|
139
146
|
};
|
|
140
|
-
export declare const dataTypes: ["any", "any[]", "boolean", "boolean[]", "string", "string[]", "number", "number[]", "date", "date[]", "time", "time[]", "datetime", "datetime[]", "chat-message", "chat-message[]", "control-flow-excluded", "control-flow-excluded[]", "object", "object[]", "fn<string>", "fn<number>", "fn<boolean>", "fn<date>", "fn<time>", "fn<datetime>", "fn<any>", "fn<object>", "fn<chat-message>", "fn<control-flow-excluded>", "fn<string[]>", "fn<number[]>", "fn<boolean[]>", "fn<date[]>", "fn<time[]>", "fn<datetime[]>", "fn<any[]>", "fn<object[]>", "fn<chat-message[]>", "fn<control-flow-excluded[]>", "gpt-function", "gpt-function[]", "fn<gpt-function[]>", "fn<gpt-function>", "vector", "vector[]", "fn<vector>", "fn<vector[]>", "image", "image[]", "fn<image>", "fn<image[]>", "binary", "binary[]", "fn<binary>", "fn<binary[]>", "audio", "audio[]", "fn<audio>", "fn<audio[]>", "graph-reference", "graph-reference[]", "fn<graph-reference>", "fn<graph-reference[]>", "knowledge-source", "knowledge-source[]", "fn<knowledge-source>", "fn<knowledge-source[]>", "knowledge-document", "knowledge-document[]", "fn<knowledge-document>", "fn<knowledge-document[]>", "knowledge-evidence", "knowledge-evidence[]", "fn<knowledge-evidence>", "fn<knowledge-evidence[]>", "document", "document[]", "fn<document>", "fn<document[]>"];
|
|
141
|
-
export declare const scalarTypes: ["any", "boolean", "string", "number", "date", "time", "datetime", "chat-message", "control-flow-excluded", "object", "gpt-function", "vector", "image", "binary", "audio", "graph-reference", "knowledge-source", "knowledge-document", "knowledge-evidence", "document"];
|
|
147
|
+
export declare const dataTypes: ["any", "any[]", "boolean", "boolean[]", "string", "string[]", "number", "number[]", "date", "date[]", "time", "time[]", "datetime", "datetime[]", "chat-message", "chat-message[]", "control-flow-excluded", "control-flow-excluded[]", "object", "object[]", "fn<string>", "fn<number>", "fn<boolean>", "fn<date>", "fn<time>", "fn<datetime>", "fn<any>", "fn<object>", "fn<chat-message>", "fn<control-flow-excluded>", "fn<string[]>", "fn<number[]>", "fn<boolean[]>", "fn<date[]>", "fn<time[]>", "fn<datetime[]>", "fn<any[]>", "fn<object[]>", "fn<chat-message[]>", "fn<control-flow-excluded[]>", "gpt-function", "gpt-function[]", "fn<gpt-function[]>", "fn<gpt-function>", "vector", "vector[]", "fn<vector>", "fn<vector[]>", "image", "image[]", "fn<image>", "fn<image[]>", "binary", "binary[]", "fn<binary>", "fn<binary[]>", "audio", "audio[]", "fn<audio>", "fn<audio[]>", "graph-reference", "graph-reference[]", "fn<graph-reference>", "fn<graph-reference[]>", "knowledge-source", "knowledge-source[]", "fn<knowledge-source>", "fn<knowledge-source[]>", "knowledge-document", "knowledge-document[]", "fn<knowledge-document>", "fn<knowledge-document[]>", "knowledge-evidence", "knowledge-evidence[]", "fn<knowledge-evidence>", "fn<knowledge-evidence[]>", "llm-config", "llm-config[]", "fn<llm-config>", "fn<llm-config[]>", "document", "document[]", "fn<document>", "fn<document[]>"];
|
|
148
|
+
export declare const scalarTypes: ["any", "boolean", "string", "number", "date", "time", "datetime", "chat-message", "control-flow-excluded", "object", "gpt-function", "vector", "image", "binary", "audio", "graph-reference", "knowledge-source", "knowledge-document", "knowledge-evidence", "llm-config", "document"];
|
|
142
149
|
export declare const dataTypeDisplayNames: Record<DataType, string>;
|
|
143
150
|
export declare function isScalarDataValue(value: DataValue | undefined): value is ScalarDataValue;
|
|
144
151
|
export declare function isScalarDataType(type: DataType): type is ScalarDataType;
|
|
145
|
-
export declare function isArrayDataValue(value: DataValue | undefined): value is
|
|
152
|
+
export declare function isArrayDataValue(value: DataValue | undefined): value is ArrayLikeDataValue;
|
|
146
153
|
export declare function isArrayDataType(type: DataType): type is ArrayDataType;
|
|
147
154
|
export declare function isFunctionDataType(type: DataType): type is FunctionDataType;
|
|
148
|
-
export declare function isFunctionDataValue(value: DataValue | undefined): value is FunctionDataValues
|
|
155
|
+
export declare function isFunctionDataValue(value: DataValue | undefined): value is FunctionDataValues | (AnyDataValue & {
|
|
156
|
+
value: () => unknown;
|
|
157
|
+
});
|
|
149
158
|
export declare function isNotFunctionDataValue(value: DataValue | undefined): value is ScalarOrArrayDataValue;
|
|
159
|
+
export declare function functionTypeToReturnType(functionType: FunctionDataType): ScalarOrArrayDataType;
|
|
150
160
|
export declare function functionTypeToScalarType(functionType: FunctionDataType): ScalarDataType;
|
|
151
161
|
export declare function arrayTypeToScalarType(arrayType: ArrayDataType): ScalarDataType;
|
|
152
162
|
export declare function getScalarTypeOf(type: DataType): ScalarDataType;
|
|
@@ -20,6 +20,8 @@ export type GraphOutputNodeResult = {
|
|
|
20
20
|
export type GraphPreprocessorResult = {
|
|
21
21
|
connections: Record<NodeId, NodeConnection[]>;
|
|
22
22
|
definitions: GraphNodeDefinitions;
|
|
23
|
+
/** Nodes participating in execution after topology-only nodes are compiled out. */
|
|
24
|
+
graphNodes: ChartNode[];
|
|
23
25
|
nodeInstances: Record<NodeId, NodeImpl<ChartNode>>;
|
|
24
26
|
nodesById: Record<NodeId, ChartNode>;
|
|
25
27
|
nodesNotInCycle: ChartNode[];
|
|
@@ -27,7 +29,6 @@ export type GraphPreprocessorResult = {
|
|
|
27
29
|
};
|
|
28
30
|
export type GraphExecutionPlan = Omit<GraphPreprocessorResult, 'nodeInstances'> & {
|
|
29
31
|
cycleIndexByNode: Record<NodeId, number>;
|
|
30
|
-
graphNodes: ChartNode[];
|
|
31
32
|
nodeIds: readonly NodeId[];
|
|
32
33
|
inputConnectionByNodeAndPort: GraphPortConnectionMap;
|
|
33
34
|
inputConnectionsByNode: Record<NodeId, NodeConnection[]>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DataValue, type StringArrayDataValue, type ScalarOrArrayDataValue } from './DataValue.js';
|
|
2
|
-
import
|
|
2
|
+
import type { NodeInputs, NodeOutputs } from './NodeIO.js';
|
|
3
|
+
import { type ChartNode, type NodeConnection, type NodeId } from './NodeBase.js';
|
|
3
4
|
import type { GraphId, NodeGraph } from './NodeGraph.js';
|
|
4
5
|
import Emittery from 'emittery';
|
|
5
6
|
import { type ProjectId, type Project } from './Project.js';
|
|
@@ -152,8 +153,8 @@ export type ProcessEvent = {
|
|
|
152
153
|
export type GraphOutputs = Record<string, DataValue>;
|
|
153
154
|
export type GraphInputs = Record<string, DataValue>;
|
|
154
155
|
export type NodeResults = Map<NodeId, Outputs>;
|
|
155
|
-
export type Inputs =
|
|
156
|
-
export type Outputs =
|
|
156
|
+
export type Inputs = NodeInputs;
|
|
157
|
+
export type Outputs = NodeOutputs;
|
|
157
158
|
export type FrozenNodeOutputsByGraph = Record<GraphId, Record<NodeId, Outputs[] | undefined> | undefined>;
|
|
158
159
|
export type FrozenNodeOutputResolverRequest = {
|
|
159
160
|
execution: GraphExecutionMetadata;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DataValue } from './DataValue.js';
|
|
2
|
+
import type { PortId } from './NodeBase.js';
|
|
3
|
+
/** Values accepted by and emitted from a node process invocation. */
|
|
4
|
+
export type NodeInputs = Record<PortId, DataValue | undefined>;
|
|
5
|
+
export type NodeOutputs = Record<PortId, DataValue | undefined>;
|
|
@@ -9,5 +9,14 @@ export declare function isNodePrefabInstanceNode(node: ChartNode | undefined): n
|
|
|
9
9
|
export declare function canUseNodeAsPrefabSource(node: ChartNode): boolean;
|
|
10
10
|
export declare function getNodePrefabInstancePrefabId(node: ChartNode | undefined): NodePrefabId | undefined;
|
|
11
11
|
export declare function resolveNodePrefabInstance(project: Project, node: ChartNode): ChartNode;
|
|
12
|
+
/**
|
|
13
|
+
* Turns a valid graph-local library link into its current effective node.
|
|
14
|
+
*
|
|
15
|
+
* The returned node keeps the link's id and graph-local geometry, so existing
|
|
16
|
+
* connections remain valid. All node behavior and settings are cloned from
|
|
17
|
+
* the library source. Missing or invalid sources cannot be detached because
|
|
18
|
+
* there is no concrete node definition to preserve.
|
|
19
|
+
*/
|
|
20
|
+
export declare function detachNodePrefabInstance(project: Project, node: ChartNode): ChartNode | undefined;
|
|
12
21
|
export declare function resolveNodePrefabInstances(project: Project, nodes: readonly ChartNode[]): ChartNode[];
|
|
13
22
|
export declare function getNodePrefabDisplayName(project: Project, prefabId: NodePrefabId | undefined): string;
|