@valerypopoff/rivet2-core 2.13.0 → 2.15.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 (48) hide show
  1. package/dist/cjs/bundle.cjs +2485 -425
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/esm/api/createProcessor.js +5 -0
  4. package/dist/esm/api/processSettings.js +1 -0
  5. package/dist/esm/exports.js +4 -0
  6. package/dist/esm/model/GraphProcessor.js +10 -16
  7. package/dist/esm/model/MarkdownSanitizationPolicy.js +2 -0
  8. package/dist/esm/model/NodeImpl.js +1 -1
  9. package/dist/esm/model/Nodes.js +6 -0
  10. package/dist/esm/model/StreamingWatchTopology.js +98 -61
  11. package/dist/esm/model/classifier/credentials.js +81 -0
  12. package/dist/esm/model/classifier/migration.js +97 -0
  13. package/dist/esm/model/classifier/providers.js +347 -0
  14. package/dist/esm/model/classifier/questionHelpers.js +125 -0
  15. package/dist/esm/model/classifier/types.js +1 -0
  16. package/dist/esm/model/nodeBodyMarkdown.js +37 -0
  17. package/dist/esm/model/nodes/ClassifierEvaluateNode.js +392 -0
  18. package/dist/esm/model/nodes/ClassifierQuestionNode.js +569 -0
  19. package/dist/esm/model/nodes/CodeNewNode.js +33 -9
  20. package/dist/esm/model/nodes/LLMChatV2Node.js +3 -12
  21. package/dist/esm/model/nodes/LLMProfileNode.js +6 -12
  22. package/dist/esm/model/nodes/MatchCaseNode.js +76 -1
  23. package/dist/esm/model/nodes/MatchCaseNodeBase.js +24 -2
  24. package/dist/esm/model/nodes/ObjectNode.js +48 -41
  25. package/dist/esm/model/nodes/PassthroughNode.js +1 -1
  26. package/dist/esm/model/nodes/codeOutputInference.js +292 -0
  27. package/dist/esm/utils/serialization/serialization.js +4 -0
  28. package/dist/types/exports.d.ts +4 -0
  29. package/dist/types/model/EditorDefinition.d.ts +24 -0
  30. package/dist/types/model/MarkdownSanitizationPolicy.d.ts +1 -1
  31. package/dist/types/model/NodeImpl.d.ts +3 -1
  32. package/dist/types/model/Nodes.d.ts +6 -4
  33. package/dist/types/model/Settings.d.ts +4 -0
  34. package/dist/types/model/StreamingWatchTopology.d.ts +6 -0
  35. package/dist/types/model/classifier/credentials.d.ts +24 -0
  36. package/dist/types/model/classifier/migration.d.ts +18 -0
  37. package/dist/types/model/classifier/providers.d.ts +78 -0
  38. package/dist/types/model/classifier/questionHelpers.d.ts +31 -0
  39. package/dist/types/model/classifier/types.d.ts +58 -0
  40. package/dist/types/model/nodeBodyMarkdown.d.ts +19 -0
  41. package/dist/types/model/nodes/ClassifierEvaluateNode.d.ts +47 -0
  42. package/dist/types/model/nodes/ClassifierQuestionNode.d.ts +60 -0
  43. package/dist/types/model/nodes/CodeNewNode.d.ts +6 -0
  44. package/dist/types/model/nodes/MatchCaseNode.d.ts +8 -1
  45. package/dist/types/model/nodes/MatchCaseNodeBase.d.ts +13 -1
  46. package/dist/types/model/nodes/ObjectNode.d.ts +5 -0
  47. package/dist/types/model/nodes/codeOutputInference.d.ts +31 -0
  48. package/package.json +1 -1
@@ -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;
@@ -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;
@@ -7,6 +7,11 @@ export type ObjectNode = ChartNode<'object', ObjectNodeData>;
7
7
  export type ObjectNodeData = {
8
8
  jsonTemplate: string;
9
9
  };
10
+ /**
11
+ * Interpolates a JSON template without parsing it. Shared by Object and other
12
+ * first-party nodes which author structured EntryType values.
13
+ */
14
+ export declare function interpolateJsonTemplate(baseString: string, values: Record<string, unknown>, graphInputNodeValues?: Record<string, DataValue>, contextValues?: Record<string, DataValue>, globalValues?: Record<string, unknown>): string;
10
15
  export declare class ObjectNodeImpl extends NodeImpl<ObjectNode> {
11
16
  static create(): ObjectNode;
12
17
  getInputDefinitions(): NodeInputDefinition[];
@@ -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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valerypopoff/rivet2-core",
3
- "version": "2.13.0",
3
+ "version": "2.15.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/cjs/bundle.cjs",
6
6
  "module": "dist/esm/index.js",