@valerypopoff/rivet2-core 2.13.0 → 2.17.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.
Files changed (134) hide show
  1. package/dist/cjs/bundle.cjs +28167 -23834
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/cjs/interpolationRuntime.cjs +22 -3
  4. package/dist/cjs/interpolationRuntime.cjs.map +3 -3
  5. package/dist/cjs/interpolationSyntax.cjs +9 -5
  6. package/dist/cjs/interpolationSyntax.cjs.map +2 -2
  7. package/dist/esm/api/createProcessor.js +10 -2
  8. package/dist/esm/api/processSettings.js +1 -0
  9. package/dist/esm/exports.js +6 -0
  10. package/dist/esm/model/GraphBoundaryCache.js +2 -1
  11. package/dist/esm/model/GraphProcessor.js +278 -22
  12. package/dist/esm/model/MarkdownSanitizationPolicy.js +2 -0
  13. package/dist/esm/model/NodeImpl.js +1 -1
  14. package/dist/esm/model/Nodes.js +16 -0
  15. package/dist/esm/model/ProjectBundle.js +235 -0
  16. package/dist/esm/model/SplitRunProcessor.js +28 -7
  17. package/dist/esm/model/StreamingWatchTopology.js +211 -64
  18. package/dist/esm/model/SubgraphProjectTarget.js +7 -0
  19. package/dist/esm/model/chat-v2/aiSdkBridge.js +7 -5
  20. package/dist/esm/model/chat-v2/chatV2Pipeline.js +13 -8
  21. package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +19 -1
  22. package/dist/esm/model/chat-v2/chatV2Shared.js +2 -1
  23. package/dist/esm/model/chat-v2/llmChatV2Body.js +11 -8
  24. package/dist/esm/model/chat-v2/llmChatV2NodeData.js +2 -0
  25. package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +15 -1
  26. package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +22 -2
  27. package/dist/esm/model/chat-v2/llmProfile.js +3 -0
  28. package/dist/esm/model/chat-v2/llmProfileBody.js +2 -2
  29. package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +1 -1
  30. package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +1 -1
  31. package/dist/esm/model/chat-v2/temperature.js +9 -0
  32. package/dist/esm/model/classifier/credentials.js +107 -0
  33. package/dist/esm/model/classifier/images.js +176 -0
  34. package/dist/esm/model/classifier/json.js +57 -0
  35. package/dist/esm/model/classifier/limits.js +270 -0
  36. package/dist/esm/model/classifier/migration.js +97 -0
  37. package/dist/esm/model/classifier/openai.js +118 -0
  38. package/dist/esm/model/classifier/preparation.js +74 -0
  39. package/dist/esm/model/classifier/providers.js +422 -0
  40. package/dist/esm/model/classifier/questionHelpers.js +109 -0
  41. package/dist/esm/model/classifier/questions.js +53 -0
  42. package/dist/esm/model/classifier/response.js +75 -0
  43. package/dist/esm/model/classifier/state.js +204 -0
  44. package/dist/esm/model/classifier/types.js +1 -0
  45. package/dist/esm/model/nodeBodyMarkdown.js +37 -0
  46. package/dist/esm/model/nodeRunFailure.js +47 -0
  47. package/dist/esm/model/nodes/CatchStreamingChunksNode.js +42 -0
  48. package/dist/esm/model/nodes/ClassifierEvaluateNode.js +432 -0
  49. package/dist/esm/model/nodes/ClassifierQuestionNode.js +613 -0
  50. package/dist/esm/model/nodes/CodeNewNode.js +33 -9
  51. package/dist/esm/model/nodes/GetGlobalNode.js +2 -2
  52. package/dist/esm/model/nodes/HttpCallNode.js +44 -75
  53. package/dist/esm/model/nodes/ImageNode.js +44 -3
  54. package/dist/esm/model/nodes/LLMChatV2Node.js +27 -15
  55. package/dist/esm/model/nodes/LLMProfileNode.js +6 -12
  56. package/dist/esm/model/nodes/MatchCaseNode.js +76 -1
  57. package/dist/esm/model/nodes/MatchCaseNodeBase.js +24 -2
  58. package/dist/esm/model/nodes/ObjectNode.js +68 -50
  59. package/dist/esm/model/nodes/PassthroughNode.js +1 -1
  60. package/dist/esm/model/nodes/PromptNode.js +2 -1
  61. package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +4 -1
  62. package/dist/esm/model/nodes/SetGlobalNode.js +5 -3
  63. package/dist/esm/model/nodes/StopWatchingStreamingOutputNode.js +8 -8
  64. package/dist/esm/model/nodes/StreamValueNode.js +38 -0
  65. package/dist/esm/model/nodes/SubGraphNode.js +196 -35
  66. package/dist/esm/model/nodes/ToBase64Node.js +106 -0
  67. package/dist/esm/model/nodes/WatchStreamingOutputNode.js +7 -7
  68. package/dist/esm/model/nodes/codeOutputInference.js +292 -0
  69. package/dist/esm/recording/ExecutionRecorder.js +26 -0
  70. package/dist/esm/utils/base64.js +18 -15
  71. package/dist/esm/utils/errors.js +41 -0
  72. package/dist/esm/utils/interpolation.js +44 -22
  73. package/dist/esm/utils/interpolationSyntax.js +15 -6
  74. package/dist/esm/utils/serialization/serialization.js +7 -2
  75. package/dist/esm/utils/serialization/serializationUtils.js +6 -0
  76. package/dist/esm/utils/serialization/serialization_v4.js +15 -3
  77. package/dist/types/api/createProcessor.d.ts +7 -1
  78. package/dist/types/exports.d.ts +6 -0
  79. package/dist/types/model/CycleDetector.d.ts +1 -2
  80. package/dist/types/model/EditorDefinition.d.ts +24 -0
  81. package/dist/types/model/ExecutorProtocol.d.ts +2 -0
  82. package/dist/types/model/GraphBoundaryCache.d.ts +2 -0
  83. package/dist/types/model/GraphProcessor.d.ts +1 -0
  84. package/dist/types/model/MarkdownSanitizationPolicy.d.ts +1 -1
  85. package/dist/types/model/NodeImpl.d.ts +3 -1
  86. package/dist/types/model/Nodes.d.ts +10 -4
  87. package/dist/types/model/ProcessContext.d.ts +12 -0
  88. package/dist/types/model/ProjectBundle.d.ts +54 -0
  89. package/dist/types/model/ProjectReferenceLoader.d.ts +3 -0
  90. package/dist/types/model/Settings.d.ts +4 -0
  91. package/dist/types/model/StreamingWatchTopology.d.ts +17 -1
  92. package/dist/types/model/SubgraphProjectTarget.d.ts +38 -0
  93. package/dist/types/model/chat-v2/chatV2Shared.d.ts +1 -1
  94. package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +3 -1
  95. package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +3 -1
  96. package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +6 -6
  97. package/dist/types/model/chat-v2/temperature.d.ts +2 -0
  98. package/dist/types/model/classifier/credentials.d.ts +26 -0
  99. package/dist/types/model/classifier/images.d.ts +18 -0
  100. package/dist/types/model/classifier/json.d.ts +19 -0
  101. package/dist/types/model/classifier/limits.d.ts +42 -0
  102. package/dist/types/model/classifier/migration.d.ts +18 -0
  103. package/dist/types/model/classifier/openai.d.ts +5 -0
  104. package/dist/types/model/classifier/preparation.d.ts +16 -0
  105. package/dist/types/model/classifier/providers.d.ts +136 -0
  106. package/dist/types/model/classifier/questionHelpers.d.ts +33 -0
  107. package/dist/types/model/classifier/questions.d.ts +4 -0
  108. package/dist/types/model/classifier/response.d.ts +4 -0
  109. package/dist/types/model/classifier/state.d.ts +37 -0
  110. package/dist/types/model/classifier/types.d.ts +60 -0
  111. package/dist/types/model/nodeBodyMarkdown.d.ts +19 -0
  112. package/dist/types/model/nodeRunFailure.d.ts +13 -0
  113. package/dist/types/model/nodes/CatchStreamingChunksNode.d.ts +20 -0
  114. package/dist/types/model/nodes/ClassifierEvaluateNode.d.ts +50 -0
  115. package/dist/types/model/nodes/ClassifierQuestionNode.d.ts +60 -0
  116. package/dist/types/model/nodes/CodeNewNode.d.ts +6 -0
  117. package/dist/types/model/nodes/GetGlobalNode.d.ts +7 -0
  118. package/dist/types/model/nodes/ImageNode.d.ts +4 -0
  119. package/dist/types/model/nodes/LLMChatV2Node.d.ts +1 -0
  120. package/dist/types/model/nodes/MatchCaseNode.d.ts +8 -1
  121. package/dist/types/model/nodes/MatchCaseNodeBase.d.ts +13 -1
  122. package/dist/types/model/nodes/ObjectNode.d.ts +6 -0
  123. package/dist/types/model/nodes/StreamValueNode.d.ts +14 -0
  124. package/dist/types/model/nodes/SubGraphNode.d.ts +21 -2
  125. package/dist/types/model/nodes/ToBase64Node.d.ts +12 -0
  126. package/dist/types/model/nodes/codeOutputInference.d.ts +31 -0
  127. package/dist/types/recording/ExecutionRecorder.d.ts +8 -2
  128. package/dist/types/utils/base64.d.ts +1 -1
  129. package/dist/types/utils/errors.d.ts +4 -0
  130. package/dist/types/utils/interpolation.d.ts +13 -2
  131. package/dist/types/utils/interpolationSyntax.d.ts +1 -1
  132. package/dist/types/utils/serialization/serialization.d.ts +3 -1
  133. package/dist/types/utils/serialization/serializationUtils.d.ts +1 -0
  134. package/package.json +1 -1
@@ -0,0 +1,60 @@
1
+ export type ClassifierQuestionType = 'choice' | 'score' | 'noul';
2
+ export type ClassifierEntryEditorType = 'text' | 'lines' | 'object';
3
+ export type ClassifierStructuredValue = string | number | boolean | null | {
4
+ [key: string]: ClassifierStructuredValue;
5
+ } | ClassifierStructuredValue[];
6
+ export type ClassifierEntry = string | null | {
7
+ [key: string]: ClassifierStructuredValue;
8
+ } | ClassifierStructuredValue[];
9
+ export type ClassifierScoreCriterionData = {
10
+ /** Editor-only stable identity; never leaves Rivet in the provider request. */
11
+ id?: string;
12
+ type: ClassifierEntryEditorType;
13
+ text: string;
14
+ lines: string[];
15
+ objectTemplate: string;
16
+ };
17
+ /**
18
+ * An authored Choice criterion keeps one value for each supported editor
19
+ * representation. Switching the shared criteria type is therefore
20
+ * non-destructive, just like the Question's Instructions type switch.
21
+ */
22
+ export type ClassifierChoiceCriterionData = {
23
+ /** Editor-only stable identity; never leaves Rivet in the provider request. */
24
+ id?: string;
25
+ key: string;
26
+ text: string;
27
+ lines: string[];
28
+ objectTemplate: string;
29
+ };
30
+ export type ClassifierQuestionDefinition = {
31
+ questionId: string;
32
+ type: ClassifierQuestionType;
33
+ instructions: ClassifierEntry;
34
+ criteria?: unknown;
35
+ };
36
+ export type ClassifierChoiceQuestionDefinition = ClassifierQuestionDefinition & {
37
+ type: 'choice';
38
+ criteria: Record<string, ClassifierEntry>;
39
+ };
40
+ export type ClassifierScoreQuestionDefinition = ClassifierQuestionDefinition & {
41
+ type: 'score';
42
+ criteria: ClassifierEntry[];
43
+ };
44
+ export type ClassifierNoulQuestionDefinition = ClassifierQuestionDefinition & {
45
+ type: 'noul';
46
+ criteria?: {
47
+ true: ClassifierEntry;
48
+ false: ClassifierEntry;
49
+ };
50
+ };
51
+ /** Internal contract after the untrusted public definition has been validated. */
52
+ export type PreparedClassifierQuestion = ClassifierChoiceQuestionDefinition | ClassifierScoreQuestionDefinition | ClassifierNoulQuestionDefinition;
53
+ export type ClassifierEvaluationResponse = {
54
+ model: string;
55
+ answers: Record<string, unknown>;
56
+ usage: {
57
+ input_tokens: number;
58
+ output_tokens: number;
59
+ };
60
+ };
@@ -0,0 +1,19 @@
1
+ export declare const NODE_BODY_FIELD_LABEL_CLASS = "rivet-node-body-field-label";
2
+ export declare const NODE_BODY_FIELD_VALUE_CLASS = "rivet-node-body-field-value";
3
+ export declare const NODE_BODY_FIELD_ROW_CLASS = "rivet-node-body-field-row";
4
+ export declare const NODE_BODY_TEXT_ROW_CLASS = "rivet-node-body-text-row";
5
+ export declare const NODE_BODY_SEPARATOR_CLASS = "rivet-node-body-separator";
6
+ /**
7
+ * Renders a label/value pair for a Markdown node body without letting authored
8
+ * values become Markdown. Class-based styling is deliberately used instead of
9
+ * inline styles because node-body Markdown is sanitized before it reaches DOM.
10
+ */
11
+ export declare function formatNodeBodyMarkdownField(label: string, value: unknown): string;
12
+ /** Renders a sanitized, styled field label without adding an empty value node. */
13
+ export declare function formatNodeBodyMarkdownLabel(label: string): string;
14
+ /** Wraps authored text in a raw HTML span so Markdown punctuation stays literal. */
15
+ export declare function formatNodeBodyMarkdownValue(value: unknown): string;
16
+ /** Renders unlabelled authored text as a standalone Markdown body row. */
17
+ export declare function formatNodeBodyMarkdownTextRow(value: unknown): string;
18
+ /** A block separator that does not cause Markdown to create empty paragraphs. */
19
+ export declare function formatNodeBodyMarkdownSeparator(): string;
@@ -0,0 +1,13 @@
1
+ import type { Outputs } from './GraphProcessor.js';
2
+ import type { NodeOutputDefinition } from './NodeBase.js';
3
+ export type NodeRunFailureSettings = {
4
+ /** Missing on legacy nodes preserves their existing throw behavior. */
5
+ errorOnNon200?: boolean;
6
+ catchRequestFailed?: boolean;
7
+ };
8
+ export declare function hasRunFailureOutputs(data: NodeRunFailureSettings): boolean;
9
+ export declare function getRunFailureOutputDefinitions(data: NodeRunFailureSettings): NodeOutputDefinition[];
10
+ export declare function shouldCatchRunFailure(data: NodeRunFailureSettings, error: unknown, signal: AbortSignal): boolean;
11
+ export declare function withRunSuccessOutputs(data: NodeRunFailureSettings, outputs: Outputs): Outputs;
12
+ /** Never route a partial model answer or fabricated usage through the success branch. */
13
+ export declare function createCaughtRunFailureOutputs(definitions: readonly NodeOutputDefinition[], error: unknown, evidence?: Outputs): Outputs;
@@ -0,0 +1,20 @@
1
+ import type { EditorDefinition } from '../EditorDefinition.js';
2
+ import type { Inputs, Outputs } from '../GraphProcessor.js';
3
+ import type { ChartNode, NodeInputDefinition, NodeOutputDefinition } from '../NodeBase.js';
4
+ import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
5
+ export declare const MAX_CAUGHT_STREAMING_CHUNKS = 1024;
6
+ export type CatchStreamingChunksNodeData = {
7
+ count: number;
8
+ };
9
+ export type CatchStreamingChunksNode = ChartNode<'catchStreamingChunks', CatchStreamingChunksNodeData>;
10
+ /** The processor owns this node's early, once-only output. */
11
+ export declare class CatchStreamingChunksNodeImpl extends NodeImpl<CatchStreamingChunksNode> {
12
+ static create(): CatchStreamingChunksNode;
13
+ getInputDefinitions(): NodeInputDefinition[];
14
+ getOutputDefinitions(): NodeOutputDefinition[];
15
+ static getUIData(): NodeUIData;
16
+ getEditors(): EditorDefinition<CatchStreamingChunksNode>[];
17
+ getBody(): string;
18
+ process(inputs: Inputs): Promise<Outputs>;
19
+ }
20
+ export declare const catchStreamingChunksNode: import("../NodeDefinition.js").NodeDefinition<CatchStreamingChunksNode>;
@@ -0,0 +1,50 @@
1
+ import type { EditorDefinition } from '../EditorDefinition.js';
2
+ import type { Inputs, Outputs } from '../GraphProcessor.js';
3
+ import type { NodeBodySpec } from '../NodeBodySpec.js';
4
+ import type { ChartNode, NodeConnection, NodeInputDefinition, NodeOutputDefinition } from '../NodeBase.js';
5
+ import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
6
+ import type { InternalProcessContext } from '../ProcessContext.js';
7
+ import { type ClassifierApiKeySource, type ClassifierCredentialNames } from '../classifier/credentials.js';
8
+ export type ClassifierEvaluateNodeData = {
9
+ provider?: string;
10
+ /** Empty or absent uses the selected provider's default model. */
11
+ model?: string;
12
+ useModelInput?: boolean;
13
+ /** Adds the exact JSON body sent to the provider, excluding its auth header. */
14
+ outputRequestBody?: boolean;
15
+ /** Adds the complete parsed JSON body returned by the provider. */
16
+ outputResponseBody?: boolean;
17
+ /** Adds calculated provider cost details to the existing Usage output. */
18
+ outputUsage?: boolean;
19
+ retryOnNon200?: boolean;
20
+ errorOnNon200?: boolean;
21
+ catchRequestFailed?: boolean;
22
+ retryOnNon200RepeatTimes?: number;
23
+ retryOnNon200CooldownMs?: number;
24
+ timeoutMs?: number;
25
+ apiKeySource?: ClassifierApiKeySource;
26
+ apiKeyNamesByProvider?: Record<string, ClassifierCredentialNames | undefined>;
27
+ /** @deprecated Migrated into apiKeyNamesByProvider. */
28
+ apiKeyNames?: ClassifierCredentialNames;
29
+ };
30
+ export type ClassifierEvaluateNode = ChartNode<'classifierEvaluate', ClassifierEvaluateNodeData>;
31
+ export type ClassifierEvaluateBodySection = Readonly<{
32
+ id: 'configuration' | 'error-behavior';
33
+ fields: readonly Readonly<{
34
+ label: string;
35
+ value: string;
36
+ }>[];
37
+ }>;
38
+ export declare class ClassifierEvaluateNodeImpl extends NodeImpl<ClassifierEvaluateNode> {
39
+ static create(): ClassifierEvaluateNode;
40
+ getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
41
+ getOutputDefinitions(): NodeOutputDefinition[];
42
+ getEditors(): EditorDefinition<ClassifierEvaluateNode>[];
43
+ getBody(): NodeBodySpec;
44
+ static getUIData(): NodeUIData;
45
+ process(inputs: Inputs, context: InternalProcessContext): Promise<Outputs>;
46
+ private processRun;
47
+ }
48
+ /** Shared presentation model for the app's Classifier Evaluate card. */
49
+ export declare function getClassifierEvaluateBodySections(data: ClassifierEvaluateNodeData): readonly ClassifierEvaluateBodySection[];
50
+ export declare const classifierEvaluateNode: import("../NodeDefinition.js").NodeDefinition<ClassifierEvaluateNode>;
@@ -0,0 +1,60 @@
1
+ import type { EditorDefinition } from '../EditorDefinition.js';
2
+ import type { Inputs, Outputs } from '../GraphProcessor.js';
3
+ import type { ChartNode, NodeInputDefinition, NodeOutputDefinition } from '../NodeBase.js';
4
+ import type { NodeBodySpec } from '../NodeBodySpec.js';
5
+ import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
6
+ import type { InternalProcessContext } from '../ProcessContext.js';
7
+ import { type ClassifierQuestionBaseData } from '../classifier/questionHelpers.js';
8
+ import type { ClassifierChoiceCriterionData, ClassifierEntryEditorType, ClassifierQuestionType, ClassifierScoreCriterionData } from '../classifier/types.js';
9
+ export type ClassifierQuestionNodeData = ClassifierQuestionBaseData & {
10
+ questionType: ClassifierQuestionType;
11
+ /** One representation shared by all authored criteria for the active question type. */
12
+ criteriaType?: ClassifierEntryEditorType;
13
+ options?: {
14
+ key: string;
15
+ value: string;
16
+ }[];
17
+ choiceCriteria?: ClassifierChoiceCriterionData[];
18
+ scoreCriteria?: ClassifierScoreCriterionData[];
19
+ /** @deprecated Compatibility for projects created before structured Score criteria. */
20
+ levels?: string[];
21
+ noulTrueCriteria?: string;
22
+ noulFalseCriteria?: string;
23
+ noulTrueCriteriaLines?: string[];
24
+ noulFalseCriteriaLines?: string[];
25
+ noulTrueCriteriaObjectTemplate?: string;
26
+ noulFalseCriteriaObjectTemplate?: string;
27
+ useNoulTrueCriteriaInput?: boolean;
28
+ useNoulFalseCriteriaInput?: boolean;
29
+ /** @deprecated Compatibility for projects created before named Noul criteria. */
30
+ yesMeans?: string;
31
+ /** @deprecated Compatibility for projects created before named Noul criteria. */
32
+ noMeans?: string;
33
+ /** Complete Choice/Score criteria input, plus legacy Noul object input. */
34
+ useCriteriaInput?: boolean;
35
+ };
36
+ export type ClassifierQuestionNode = ChartNode<'classifierQuestion', ClassifierQuestionNodeData>;
37
+ export type ClassifierQuestionBodySection = Readonly<{
38
+ id: 'identity' | 'instructions' | 'criteria';
39
+ fields: readonly Readonly<{
40
+ label: string;
41
+ value: string;
42
+ }>[];
43
+ summary?: string | undefined;
44
+ }>;
45
+ export declare class ClassifierQuestionNodeImpl extends NodeImpl<ClassifierQuestionNode> {
46
+ static create(): ClassifierQuestionNode;
47
+ getInputDefinitions(): NodeInputDefinition[];
48
+ getOutputDefinitions(): NodeOutputDefinition[];
49
+ getEditors(): EditorDefinition<ClassifierQuestionNode>[];
50
+ getBody(): NodeBodySpec;
51
+ static getUIData(): NodeUIData;
52
+ process(inputs: Inputs, context: InternalProcessContext): Promise<Outputs>;
53
+ }
54
+ /**
55
+ * Shared presentation model for the app's Classifier card. Keep this data-only
56
+ * so the Core Markdown fallback and the app's LLM-style React body cannot
57
+ * disagree about what a saved question represents.
58
+ */
59
+ export declare function getClassifierQuestionBodySections(data: ClassifierQuestionNodeData): readonly ClassifierQuestionBodySection[];
60
+ export declare const classifierQuestionNode: import("../NodeDefinition.js").NodeDefinition<ClassifierQuestionNode>;
@@ -4,9 +4,15 @@ import type { Inputs, Outputs } from '../GraphProcessor.js';
4
4
  import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
5
5
  import { type NodeBodySpec } from '../NodeBodySpec.js';
6
6
  import type { InternalProcessContext } from '../ProcessContext.js';
7
+ import { type CodeOutputField } from './codeOutputInference.js';
8
+ export { analyzeCodeOutputs, getCodeOutputFields, getCodeOutputKeys, prepareCodeOutputEdit, type CodeOutputField, } from './codeOutputInference.js';
7
9
  export type CodeNewNode = ChartNode<'codeNew', CodeNewNodeData>;
8
10
  export type CodeNewNodeData = {
9
11
  code: string;
12
+ inferredOutputFields?: CodeOutputField[];
13
+ inferredOutputKeys?: string[];
14
+ inferredOutputRetiredFields?: CodeOutputField[];
15
+ inferredOutputLastValidCode?: string;
10
16
  };
11
17
  export declare const CODE_NEW_OUTPUT_PORT_ID: PortId;
12
18
  export declare function interpolateCodeNewSource(code: string, inputs: Inputs): string;
@@ -9,6 +9,13 @@ export type GetGlobalNodeData = {
9
9
  id: string;
10
10
  useIdInput: boolean;
11
11
  dataType: ScalarOrArrayDataType;
12
+ /** Editor-only explanation of a type copied from a known variable declaration. */
13
+ typeSuggestion?: {
14
+ id: string;
15
+ type: ScalarOrArrayDataType;
16
+ source: string;
17
+ conflictingTypes: ScalarOrArrayDataType[];
18
+ };
12
19
  /**
13
20
  * Returns a fn<value> instead of a value, so that the variable is read when nodes need it, rather than when this node executes.
14
21
  * The only time you wouldn't want this is to read a global at the start of a subgraph.
@@ -3,8 +3,12 @@ import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
3
3
  import { type DataRef, type EditorDefinition, type Inputs, type InternalProcessContext, type Outputs } from '../../index.js';
4
4
  export type ImageNode = ChartNode<'image', ImageNodeData>;
5
5
  type ImageNodeData = {
6
+ /** Missing on older projects; treat it as binary for compatibility. */
7
+ sourceType?: 'binary' | 'base64';
6
8
  data?: DataRef;
7
9
  useDataInput: boolean;
10
+ base64?: string;
11
+ useBase64Input?: boolean;
8
12
  mediaType: 'image/png' | 'image/jpeg' | 'image/gif';
9
13
  useMediaTypeInput: boolean;
10
14
  };
@@ -18,5 +18,6 @@ export declare class LLMChatV2NodeImpl extends NodeImpl<LLMChatV2Node> {
18
18
  getEditors(context: RivetUIContext): Promise<EditorDefinition<LLMChatV2Node>[]>;
19
19
  getBody(): NodeBodySpec;
20
20
  process(inputs: Inputs, context: InternalProcessContext): Promise<Outputs>;
21
+ private processRun;
21
22
  }
22
23
  export declare const llmChatV2Node: import("../NodeDefinition.js").NodeDefinition<LLMChatV2Node>;
@@ -1,6 +1,8 @@
1
1
  import { type NodeUIData } from '../NodeImpl.js';
2
- import { type ChartNode } from '../NodeBase.js';
2
+ import { type ChartNode, type NodeInputDefinition } from '../NodeBase.js';
3
3
  import { type EditorDefinition } from '../EditorDefinition.js';
4
+ import { type Inputs } from '../GraphProcessor.js';
5
+ import { type InternalProcessContext } from '../ProcessContext.js';
4
6
  import { MatchCaseNodeBase, type MatchCaseReturnValueMode, type MatchCaseRoutingData } from './MatchCaseNodeBase.js';
5
7
  export type MatchCaseMode = 'plainText' | 'regex';
6
8
  export type MatchCaseReturnValue = MatchCaseReturnValueMode;
@@ -17,6 +19,9 @@ export type MatchCaseNode = ChartNode<'matchCase', MatchCaseNodeData>;
17
19
  export declare class MatchCaseNodeImpl extends MatchCaseNodeBase<MatchCaseNode> {
18
20
  protected readonly caseEditorLabel = "Cases";
19
21
  protected readonly caseEditorPlaceholder = "Case";
22
+ protected readonly caseEditorHighlightsInterpolation = true;
23
+ protected readonly caseEditorInputFontFamily: "monospace";
24
+ protected readonly caseEditorBoxed = true;
20
25
  protected readonly casesEditorPlacement = "before-trigger";
21
26
  protected readonly customCaseValuesEditorLabel = "";
22
27
  protected readonly defaultExclusive = true;
@@ -35,6 +40,8 @@ export declare class MatchCaseNodeImpl extends MatchCaseNodeBase<MatchCaseNode>
35
40
  protected getReturnValueMode(): MatchCaseReturnValue;
36
41
  protected getEditorsAfterTrigger(): EditorDefinition<MatchCaseNode>[];
37
42
  protected shouldHideCustomCaseValues(data: MatchCaseNodeData): boolean;
43
+ protected getInterpolationInputDefinitions(): NodeInputDefinition[];
44
+ protected resolveCaseValues(inputs: Inputs, context?: InternalProcessContext): readonly string[];
38
45
  getEditors(): EditorDefinition<MatchCaseNode>[];
39
46
  static getUIData(): NodeUIData;
40
47
  private getMatchMode;
@@ -1,5 +1,6 @@
1
1
  import { type EditorDefinition } from '../EditorDefinition.js';
2
2
  import { type Inputs, type Outputs } from '../GraphProcessor.js';
3
+ import { type InternalProcessContext } from '../ProcessContext.js';
3
4
  import { NodeImpl } from '../NodeImpl.js';
4
5
  import { type ChartNode, type NodeInputDefinition, type NodeOutputDefinition } from '../NodeBase.js';
5
6
  /** Shared saved routing and custom-value settings for Match case node variants. */
@@ -20,6 +21,10 @@ export type MatchCaseReturnValueMode = 'true' | 'testValue' | 'custom';
20
21
  export declare abstract class MatchCaseNodeBase<T extends ChartNode<string, MatchCaseRoutingData>> extends NodeImpl<T> {
21
22
  protected abstract readonly caseEditorLabel: string;
22
23
  protected abstract readonly caseEditorPlaceholder: string;
24
+ protected readonly caseEditorHelperMessage: string | undefined;
25
+ protected readonly caseEditorHighlightsInterpolation: boolean;
26
+ protected readonly caseEditorInputFontFamily: 'monospace' | undefined;
27
+ protected readonly caseEditorBoxed: boolean;
23
28
  protected readonly casesEditorPlacement: 'before-trigger' | 'after-custom-values';
24
29
  protected readonly customCaseValuesEditorLabel: string;
25
30
  protected readonly defaultExclusive: boolean;
@@ -37,11 +42,18 @@ export declare abstract class MatchCaseNodeBase<T extends ChartNode<string, Matc
37
42
  protected getReturnValueMode(): MatchCaseReturnValueMode;
38
43
  protected getEditorsAfterTrigger(): EditorDefinition<T>[];
39
44
  protected shouldHideCustomCaseValues(_data: T['data']): boolean;
45
+ /**
46
+ * Current Match case resolves its saved case templates at execution time.
47
+ * The legacy Regex Match node deliberately leaves its saved expressions raw.
48
+ */
49
+ protected resolveCaseValues(_inputs: Inputs, _context?: InternalProcessContext): readonly string[];
50
+ /** Additional inputs that sit between the tested value and custom return values. */
51
+ protected getInterpolationInputDefinitions(): NodeInputDefinition[];
40
52
  getInputDefinitions(): NodeInputDefinition[];
41
53
  getOutputDefinitions(): NodeOutputDefinition[];
42
54
  getBody(): string;
43
55
  getEditors(): EditorDefinition<T>[];
44
- process(inputs: Inputs): Promise<Outputs>;
56
+ process(inputs: Inputs, context?: InternalProcessContext): Promise<Outputs>;
45
57
  protected getValueInputMode(): 'shared' | 'per-output';
46
58
  protected getExclusive(): boolean;
47
59
  private getMatchingOutputDescription;
@@ -3,10 +3,16 @@ import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
3
3
  import { type DataValue } from '../DataValue.js';
4
4
  import { type EditorDefinition } from '../EditorDefinition.js';
5
5
  import type { InternalProcessContext } from '../ProcessContext.js';
6
+ import { type InterpolationGuard } from '../../utils/interpolation.js';
6
7
  export type ObjectNode = ChartNode<'object', ObjectNodeData>;
7
8
  export type ObjectNodeData = {
8
9
  jsonTemplate: string;
9
10
  };
11
+ /**
12
+ * Interpolates a JSON template without parsing it. Shared by Object and other
13
+ * first-party nodes which author structured EntryType values.
14
+ */
15
+ export declare function interpolateJsonTemplate(baseString: string, values: Record<string, unknown>, graphInputNodeValues?: Record<string, DataValue>, contextValues?: Record<string, DataValue>, globalValues?: Record<string, unknown>, guard?: InterpolationGuard, unwrapVariableDataValues?: boolean): string;
10
16
  export declare class ObjectNodeImpl extends NodeImpl<ObjectNode> {
11
17
  static create(): ObjectNode;
12
18
  getInputDefinitions(): NodeInputDefinition[];
@@ -0,0 +1,14 @@
1
+ import type { Inputs, Outputs } from '../GraphProcessor.js';
2
+ import type { ChartNode, NodeInputDefinition, NodeOutputDefinition } from '../NodeBase.js';
3
+ import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
4
+ import type { InternalProcessContext } from '../ProcessContext.js';
5
+ export type StreamValueNode = ChartNode<'streamValue', Record<string, never>>;
6
+ /** Emits one partial snapshot without changing the ordinary final value. */
7
+ export declare class StreamValueNodeImpl extends NodeImpl<StreamValueNode> {
8
+ static create(): StreamValueNode;
9
+ getInputDefinitions(): NodeInputDefinition[];
10
+ getOutputDefinitions(): NodeOutputDefinition[];
11
+ static getUIData(): NodeUIData;
12
+ process(inputs: Inputs, context: InternalProcessContext): Promise<Outputs>;
13
+ }
14
+ export declare const streamValueNode: import("../NodeDefinition.js").NodeDefinition<StreamValueNode>;
@@ -6,11 +6,20 @@ import { type Project, type ProjectId } from '../Project.js';
6
6
  import { type DataValue } from '../DataValue.js';
7
7
  import { type InternalProcessContext } from '../ProcessContext.js';
8
8
  import { type EditorDefinition } from '../../index.js';
9
+ import { type SubgraphProjectVersion } from '../SubgraphProjectTarget.js';
9
10
  import type { RivetUIContext } from '../RivetUIContext.js';
11
+ import { type GraphBoundary } from '../GraphBoundaryCache.js';
10
12
  export type SubGraphNode = ChartNode & {
11
13
  type: 'subGraph';
12
14
  data: {
13
15
  graphId: GraphId;
16
+ /** Saved project target resolved by a host or portable bundle loader. Absent means the current project. */
17
+ targetProjectId?: ProjectId;
18
+ /** Retains the hosted picker mode before an external project is selected. */
19
+ targetScope?: 'other-projects';
20
+ targetVersion?: SubgraphProjectVersion;
21
+ /** Last selected boundary keeps existing wires visible while a hosted preview reloads. */
22
+ targetBoundary?: GraphBoundary;
14
23
  useErrorOutput?: boolean;
15
24
  useAsGraphPartialOutput?: boolean;
16
25
  /** Only execute child branches needed by actively connected output ports. */
@@ -21,12 +30,22 @@ export type SubGraphNode = ChartNode & {
21
30
  outputPortOrder?: string[];
22
31
  };
23
32
  };
33
+ /** A saved cross-project boundary is the wire contract until the user explicitly selects a new target. */
34
+ export declare function getSubgraphTargetBoundaryChange(expected: GraphBoundary | undefined, actual: GraphBoundary): {
35
+ side: 'input' | 'output';
36
+ id: string;
37
+ } | null;
38
+ /** Keep the caller's saved wire IDs while adopting current target names and metadata. */
39
+ export declare function reconcileSubgraphTargetBoundary(expected: GraphBoundary | undefined, actual: GraphBoundary): GraphBoundary;
40
+ export declare function getSubgraphTargetBoundaryIssue(expected: GraphBoundary | undefined, actual: GraphBoundary): string | null;
24
41
  export declare class SubGraphNodeImpl extends NodeImpl<SubGraphNode> {
25
42
  static create(): SubGraphNode;
26
- getInputDefinitions(_connections: NodeConnection[], _nodes: Record<NodeId, ChartNode>, project: Project, _referencedProjects: Record<ProjectId, Project>, definitionContext?: NodeDefinitionContext): NodeInputDefinition[];
43
+ getInputDefinitions(_connections: NodeConnection[], _nodes: Record<NodeId, ChartNode>, project: Project, referencedProjects: Record<ProjectId, Project>, definitionContext?: NodeDefinitionContext): NodeInputDefinition[];
27
44
  getGraphOutputs(project: Project, definitionContext?: NodeDefinitionContext): NodeOutputDefinition[];
28
- getOutputDefinitions(_connections: NodeConnection[], _nodes: Record<NodeId, ChartNode>, project: Project, _referencedProjects: Record<ProjectId, Project>, definitionContext?: NodeDefinitionContext): NodeOutputDefinition[];
45
+ getOutputDefinitions(_connections: NodeConnection[], _nodes: Record<NodeId, ChartNode>, project: Project, referencedProjects: Record<ProjectId, Project>, definitionContext?: NodeDefinitionContext): NodeOutputDefinition[];
29
46
  private getBoundary;
47
+ private getTargetProject;
48
+ private getTargetBoundary;
30
49
  getEditors(context: RivetUIContext): EditorDefinition<SubGraphNode>[];
31
50
  static getUIData(): NodeUIData;
32
51
  process(inputs: Inputs, context: InternalProcessContext): Promise<Outputs>;
@@ -0,0 +1,12 @@
1
+ import type { ChartNode, NodeInputDefinition, NodeOutputDefinition } from '../NodeBase.js';
2
+ import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
3
+ import type { Inputs, Outputs } from '../GraphProcessor.js';
4
+ export type ToBase64Node = ChartNode<'toBase64', Record<string, never>>;
5
+ export declare class ToBase64NodeImpl extends NodeImpl<ToBase64Node> {
6
+ static create(): ToBase64Node;
7
+ getInputDefinitions(): NodeInputDefinition[];
8
+ getOutputDefinitions(): NodeOutputDefinition[];
9
+ static getUIData(): NodeUIData;
10
+ process(inputs: Inputs): Promise<Outputs>;
11
+ }
12
+ export declare const toBase64Node: import("../NodeDefinition.js").NodeDefinition<ToBase64Node>;
@@ -0,0 +1,31 @@
1
+ export type CodeOutputAnalysis = {
2
+ readonly valid: true;
3
+ readonly keys: readonly string[];
4
+ } | {
5
+ readonly valid: false;
6
+ };
7
+ /** A persisted output-port identity and the returned object property it currently reads. */
8
+ export type CodeOutputField = {
9
+ id: string;
10
+ key: string;
11
+ };
12
+ type CodeOutputData = {
13
+ code: string;
14
+ inferredOutputFields?: CodeOutputField[];
15
+ inferredOutputKeys?: string[];
16
+ inferredOutputRetiredFields?: CodeOutputField[];
17
+ /** Last valid source while the current edit is syntactically incomplete. */
18
+ inferredOutputLastValidCode?: string;
19
+ };
20
+ /** Syntax-only analysis of explicit object returns in the authored function. */
21
+ export declare function analyzeCodeOutputs(code: string): CodeOutputAnalysis;
22
+ /** Resolves the displayed fields and their stable port identities without mutating node data. */
23
+ export declare function getCodeOutputFields(data: CodeOutputData): readonly CodeOutputField[];
24
+ export declare function getCodeOutputKeys(data: CodeOutputData): readonly string[];
25
+ /**
26
+ * Prepares persisted output identities as part of an editor transaction.
27
+ * Valid source owns the visible fields. Invalid source retains the last valid
28
+ * identities and source so a completed key-only rename can still be proved.
29
+ */
30
+ export declare function prepareCodeOutputEdit(previous: CodeOutputData, patch: Partial<CodeOutputData>): CodeOutputData;
31
+ export {};
@@ -1,4 +1,4 @@
1
- import { type GraphProcessor, type RecordedEvents, type Recording, type RecordingId } from '../index.js';
1
+ import { type GraphProcessor, type ProcessEvents, type RecordedEvents, type Recording, type RecordingId } from '../index.js';
2
2
  import Emittery from 'emittery';
3
3
  export type ExecutionRecorderEvents = {
4
4
  finish: {
@@ -28,7 +28,13 @@ export declare class ExecutionRecorder {
28
28
  off: Emittery<ExecutionRecorderEvents>['off'];
29
29
  once: Emittery<ExecutionRecorderEvents>['once'];
30
30
  recordSocket(channel: WebSocket, options?: SocketRecordingOptions): Promise<void>;
31
- record(processor: GraphProcessor): void;
31
+ record(processor: GraphProcessor): (terminal?: {
32
+ type: 'done';
33
+ results: ProcessEvents['done']['results'];
34
+ } | {
35
+ type: 'error';
36
+ error: ProcessEvents['error']['error'];
37
+ }) => void;
32
38
  getRecording(): Recording;
33
39
  get events(): RecordedEvents[];
34
40
  static deserializeFromString(serialized: string): ExecutionRecorder;
@@ -1,3 +1,3 @@
1
- export declare function uint8ArrayToBase64(uint8Array: Uint8Array): Promise<string | undefined>;
1
+ export declare function uint8ArrayToBase64(uint8Array: Uint8Array): Promise<string>;
2
2
  export declare function uint8ArrayToBase64Sync(uint8Array: Uint8Array): string;
3
3
  export declare function base64ToUint8Array(base64: string): Uint8Array<ArrayBuffer>;
@@ -1,2 +1,6 @@
1
1
  /** Gets an Error from an unknown error object (strict unknown errors is enabled, helper util). */
2
2
  export declare function getError(error: unknown): Error;
3
+ /** Full failure text for graph error outputs, including nested causes. */
4
+ export declare function formatCaughtRunError(error: unknown, seen?: Set<unknown>): string;
5
+ /** Caller cancellation wins over provider failure, including cross-realm errors. */
6
+ export declare function isAbortError(error: unknown, signal: AbortSignal): boolean;
@@ -37,8 +37,18 @@ export type InterpolationTokenReplacementInfo = {
37
37
  };
38
38
  export type ReplaceInterpolationTokensOptions = {
39
39
  trim?: boolean;
40
+ guard?: InterpolationGuard;
41
+ };
42
+ /** Optional caller-owned preparation limits; ordinary interpolation is unchanged. */
43
+ export type InterpolationGuard = {
44
+ tokenLimit: number;
45
+ check: () => void;
46
+ prepareValue: (value: unknown) => unknown;
47
+ output: (fragment: string, previousLength: number) => void;
48
+ processing: (input: string, name: string, parameter: number | undefined) => void;
40
49
  };
41
50
  export type InterpolateOptions = {
51
+ guard?: InterpolationGuard;
42
52
  /** A snapshot of the globals referenced by this template. */
43
53
  globalValues?: Record<string, unknown>;
44
54
  /** Set false when ordinary interpolation variables are raw JSON. */
@@ -50,6 +60,7 @@ export type InterpolateOptions = {
50
60
  coerceBareVariableDataValues?: boolean;
51
61
  };
52
62
  export type InterpolationValueSources = {
63
+ guard?: InterpolationGuard;
53
64
  variables?: Record<string, unknown>;
54
65
  graphInputValues?: Record<string, unknown>;
55
66
  contextValues?: Record<string, unknown>;
@@ -79,7 +90,7 @@ export declare function parseInterpolationExpression(expression: string): Parsed
79
90
  /** Splits an interpolation token into its expression, processor chain, and parsed reference. */
80
91
  export declare function parseInterpolationToken(rawInner: string): Omit<ParsedInterpolationToken, 'span'>;
81
92
  /** Returns an immutable, cached syntax representation. It never evaluates values. */
82
- export declare function parseInterpolationTemplate(template: string): ParsedInterpolationTemplate;
93
+ export declare function parseInterpolationTemplate(template: string, check?: () => void, tokenLimit?: number): ParsedInterpolationTemplate;
83
94
  export declare function protectEscapedInterpolationTokens(template: string): string;
84
95
  export declare function restoreEscapedInterpolationTokens(template: string): string;
85
96
  export declare function findInterpolationTokenSpans(template: string): InterpolationTokenSpan[];
@@ -97,7 +108,7 @@ export declare function extractInterpolationVariableReferences(template: string)
97
108
  * are intentionally snapshotted at node execution: interpolation neither
98
109
  * waits for a writer nor creates an execution dependency.
99
110
  */
100
- export declare function getInterpolationGlobalValues<T>(template: string, getGlobal: ((id: string) => T | undefined) | undefined): Record<string, T>;
111
+ export declare function getInterpolationGlobalValues<T>(template: string, getGlobal: ((id: string) => T | undefined) | undefined, check?: () => void, tokenLimit?: number): Record<string, T>;
101
112
  /** Extracts base port names only. Prefer `extractInterpolationVariableReferences` when type selection matters. */
102
113
  export declare function extractInterpolationVariables(template: string): string[];
103
114
  /**
@@ -18,4 +18,4 @@ export declare function isInterpolationRegexLiteralStart(value: string, index: n
18
18
  * the rest of the execution runtime. The returned spans are fresh data and
19
19
  * exclude escaped triple-brace tokens.
20
20
  */
21
- export declare function scanInterpolationTokenSpans(template: string): InterpolationTokenSpan[];
21
+ export declare function scanInterpolationTokenSpans(template: string, check?: () => void, tokenLimit?: number): InterpolationTokenSpan[];
@@ -1,7 +1,9 @@
1
1
  import type { Project, NodeGraph, Dataset, DatasetMetadata } from '../../index.js';
2
2
  import { type AttachedData } from './serializationUtils.js';
3
3
  export declare function serializeProject(project: Project, attachedData?: AttachedData): unknown;
4
- export declare function deserializeProject(serializedProject: unknown, path?: string | null): [Project, AttachedData];
4
+ export declare function deserializeProject(serializedProject: unknown, path?: string | null, options?: {
5
+ logErrors?: boolean;
6
+ }): [Project, AttachedData];
5
7
  export declare function serializeGraph(graph: NodeGraph): unknown;
6
8
  export declare function deserializeGraph(serializedGraph: unknown): NodeGraph;
7
9
  export type CombinedDataset = {
@@ -13,6 +13,7 @@ export declare class ProjectValidationError extends Error {
13
13
  }
14
14
  /** Validates a deserialized project structure. Returns errors for structural problems. */
15
15
  export declare function validateProject(project: unknown): ProjectValidationResult;
16
+ export declare function isValidProjectStaticData(value: unknown): boolean;
16
17
  /** Quick structural check - throws on invalid project. */
17
18
  export declare function doubleCheckProject(project: Project): void;
18
19
  export declare function yamlProblem(err: yaml.YAMLError): never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerypopoff/rivet2-core",
3
- "version": "2.13.0",
3
+ "version": "2.17.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/cjs/bundle.cjs",
6
6
  "module": "dist/esm/index.js",