@valerypopoff/rivet2-core 2.12.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 (69) hide show
  1. package/dist/cjs/bundle.cjs +3188 -592
  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 +5 -0
  6. package/dist/esm/model/GraphInputStream.js +70 -0
  7. package/dist/esm/model/GraphProcessor.js +264 -29
  8. package/dist/esm/model/MarkdownSanitizationPolicy.js +2 -0
  9. package/dist/esm/model/NodeExecutionPlanner.js +4 -4
  10. package/dist/esm/model/NodeImpl.js +1 -1
  11. package/dist/esm/model/Nodes.js +9 -0
  12. package/dist/esm/model/ProcessContextBuilder.js +2 -1
  13. package/dist/esm/model/StreamingOutputWatch.js +5 -0
  14. package/dist/esm/model/StreamingWatchTopology.js +228 -0
  15. package/dist/esm/model/classifier/credentials.js +81 -0
  16. package/dist/esm/model/classifier/migration.js +97 -0
  17. package/dist/esm/model/classifier/providers.js +347 -0
  18. package/dist/esm/model/classifier/questionHelpers.js +125 -0
  19. package/dist/esm/model/classifier/types.js +1 -0
  20. package/dist/esm/model/nodeBodyMarkdown.js +37 -0
  21. package/dist/esm/model/nodes/AssembleMessageNode.js +2 -2
  22. package/dist/esm/model/nodes/AssemblePromptNode.js +46 -17
  23. package/dist/esm/model/nodes/ClassifierEvaluateNode.js +392 -0
  24. package/dist/esm/model/nodes/ClassifierQuestionNode.js +569 -0
  25. package/dist/esm/model/nodes/CodeNewNode.js +33 -9
  26. package/dist/esm/model/nodes/GraphInputNode.js +15 -19
  27. package/dist/esm/model/nodes/LLMChatV2Node.js +3 -12
  28. package/dist/esm/model/nodes/LLMProfileNode.js +6 -12
  29. package/dist/esm/model/nodes/MatchCaseNode.js +78 -3
  30. package/dist/esm/model/nodes/MatchCaseNodeBase.js +24 -2
  31. package/dist/esm/model/nodes/ObjectNode.js +48 -41
  32. package/dist/esm/model/nodes/PassthroughNode.js +1 -1
  33. package/dist/esm/model/nodes/ProjectNameNode.js +37 -0
  34. package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +1 -0
  35. package/dist/esm/model/nodes/SubGraphNode.js +1 -0
  36. package/dist/esm/model/nodes/codeOutputInference.js +292 -0
  37. package/dist/esm/model/nodes/variadicPortIndex.js +1 -1
  38. package/dist/esm/utils/serialization/serialization.js +4 -0
  39. package/dist/types/exports.d.ts +6 -0
  40. package/dist/types/model/EditorDefinition.d.ts +24 -0
  41. package/dist/types/model/GraphInputStream.d.ts +23 -0
  42. package/dist/types/model/GraphProcessor.d.ts +3 -0
  43. package/dist/types/model/MarkdownSanitizationPolicy.d.ts +1 -1
  44. package/dist/types/model/NodeExecutionPlanner.d.ts +1 -1
  45. package/dist/types/model/NodeImpl.d.ts +3 -1
  46. package/dist/types/model/Nodes.d.ts +7 -4
  47. package/dist/types/model/ProcessContext.d.ts +3 -0
  48. package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
  49. package/dist/types/model/Settings.d.ts +4 -0
  50. package/dist/types/model/StreamingOutputWatch.d.ts +2 -0
  51. package/dist/types/model/StreamingWatchTopology.d.ts +26 -0
  52. package/dist/types/model/classifier/credentials.d.ts +24 -0
  53. package/dist/types/model/classifier/migration.d.ts +18 -0
  54. package/dist/types/model/classifier/providers.d.ts +78 -0
  55. package/dist/types/model/classifier/questionHelpers.d.ts +31 -0
  56. package/dist/types/model/classifier/types.d.ts +58 -0
  57. package/dist/types/model/nodeBodyMarkdown.d.ts +19 -0
  58. package/dist/types/model/nodes/AssemblePromptNode.d.ts +4 -3
  59. package/dist/types/model/nodes/ClassifierEvaluateNode.d.ts +47 -0
  60. package/dist/types/model/nodes/ClassifierQuestionNode.d.ts +60 -0
  61. package/dist/types/model/nodes/CodeNewNode.d.ts +6 -0
  62. package/dist/types/model/nodes/GraphInputNode.d.ts +2 -0
  63. package/dist/types/model/nodes/MatchCaseNode.d.ts +9 -2
  64. package/dist/types/model/nodes/MatchCaseNodeBase.d.ts +13 -1
  65. package/dist/types/model/nodes/ObjectNode.d.ts +5 -0
  66. package/dist/types/model/nodes/ProjectNameNode.d.ts +12 -0
  67. package/dist/types/model/nodes/codeOutputInference.d.ts +31 -0
  68. package/dist/types/model/nodes/variadicPortIndex.d.ts +1 -0
  69. package/package.json +1 -1
@@ -105,28 +105,24 @@ export class GraphInputNodeImpl extends NodeImpl {
105
105
  };
106
106
  }
107
107
  async process(inputs, context) {
108
- let inputValue = context.graphInputs[this.data.id] == null
109
- ? undefined
110
- : coerceTypeOptional(context.graphInputs[this.data.id], this.data.dataType);
111
- if (inputValue == null && this.data.useDefaultValueInput) {
112
- inputValue = coerceTypeOptional(inputs['default'], this.data.dataType);
113
- }
114
- if (inputValue == null) {
115
- inputValue =
116
- coerceTypeOptional(inferType(this.data.defaultValue), this.data.dataType) ||
117
- getDefaultValue(this.data.dataType);
118
- }
119
- // Resolve undefined for array inputs to empty array
120
- if (inputValue == null && isArrayDataType(this.data.dataType)) {
121
- inputValue = { type: this.data.dataType, value: [] };
122
- }
123
- const value = {
124
- type: this.data.dataType,
125
- value: inputValue,
126
- };
108
+ const value = resolveGraphInputValue(this.data, context.graphInputs[this.data.id], inputs);
127
109
  // Store the resolved value in the context for access by other nodes
128
110
  context.graphInputNodeValues[this.data.id] = value;
129
111
  return { ['data']: value };
130
112
  }
131
113
  }
114
+ /** One coercion/default policy for ordinary and live graph inputs. */
115
+ export function resolveGraphInputValue(data, input, inputs = {}) {
116
+ let inputValue = input == null ? undefined : coerceTypeOptional(input, data.dataType);
117
+ if (inputValue == null && data.useDefaultValueInput) {
118
+ inputValue = coerceTypeOptional(inputs['default'], data.dataType);
119
+ }
120
+ if (inputValue == null) {
121
+ inputValue = coerceTypeOptional(inferType(data.defaultValue), data.dataType) || getDefaultValue(data.dataType);
122
+ }
123
+ if (inputValue == null && isArrayDataType(data.dataType)) {
124
+ inputValue = { type: data.dataType, value: [] };
125
+ }
126
+ return { type: data.dataType, value: inputValue };
127
+ }
132
128
  export const graphInputNode = nodeDefinition(GraphInputNodeImpl, 'Graph Input');
@@ -2,6 +2,7 @@ import { nanoid } from 'nanoid/non-secure';
2
2
  import { dedent } from 'ts-dedent';
3
3
  import { nodeDefinition } from '../NodeDefinition.js';
4
4
  import { NodeImpl } from '../NodeImpl.js';
5
+ import { formatNodeBodyMarkdownField, formatNodeBodyMarkdownLabel } from '../nodeBodyMarkdown.js';
5
6
  import { getCommonChatV2Inputs, getCommonChatV2Outputs } from '../chat-v2/chatV2Shared.js';
6
7
  import { getLLMChatV2Editors } from '../chat-v2/llmChatV2NodeEditors.js';
7
8
  import { createLLMChatV2NodeData, shouldIncludeLLMChatV2ToolCalls, } from '../chat-v2/llmChatV2NodeData.js';
@@ -19,18 +20,8 @@ export { buildLLMChatV2EditorCacheKey, resolveLLMChatV2RuntimeProviderOptions };
19
20
  function usesBaseURLInput(data) {
20
21
  return data.provider === 'custom' && data.useCustomProviderBaseURLInput;
21
22
  }
22
- function escapeMarkdownInline(value) {
23
- return value
24
- .replace(/\r/g, '\\r')
25
- .replace(/\n/g, '\\n')
26
- .replace(/&/g, '&')
27
- .replace(/</g, '&lt;')
28
- .replace(/>/g, '&gt;')
29
- .replace(/"/g, '&quot;')
30
- .replace(/([\\`*_[\]{}()#+\-.!|])/g, '\\$1');
31
- }
32
23
  function getBodyLine(label, value) {
33
- return `<span style="opacity: 0.55">${label}:</span> ${escapeMarkdownInline(value)}`;
24
+ return formatNodeBodyMarkdownField(label, value);
34
25
  }
35
26
  function escapeMarkdownPreformatted(value) {
36
27
  return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
@@ -40,7 +31,7 @@ function getBodySectionText(section) {
40
31
  ...section.fields.map((field) => getBodyLine(field.label, field.value)),
41
32
  ...(section.snippet
42
33
  ? [
43
- `<span style="opacity: 0.55">${section.snippet.label}:</span>`,
34
+ formatNodeBodyMarkdownLabel(section.snippet.label),
44
35
  `<pre>${escapeMarkdownPreformatted(section.snippet.text)}</pre>`,
45
36
  ]
46
37
  : []),
@@ -1,22 +1,13 @@
1
1
  import { nanoid } from 'nanoid/non-secure';
2
2
  import { nodeDefinition } from '../NodeDefinition.js';
3
3
  import { NodeImpl } from '../NodeImpl.js';
4
+ import { formatNodeBodyMarkdownField, formatNodeBodyMarkdownLabel } from '../nodeBodyMarkdown.js';
4
5
  import { getLLMProfileEditors } from '../chat-v2/llmChatV2NodeEditors.js';
5
6
  import { getLLMProfileBodySections } from '../chat-v2/llmProfileBody.js';
6
7
  import { resolveLLMProfileNodeValue } from '../chat-v2/llmProfileNodeRuntime.js';
7
8
  import { createLLMProfileNodeData } from '../chat-v2/llmProfileTypes.js';
8
- function escapeMarkdownInline(value) {
9
- return String(value)
10
- .replace(/\r/g, '\\r')
11
- .replace(/\n/g, '\\n')
12
- .replace(/&/g, '&amp;')
13
- .replace(/</g, '&lt;')
14
- .replace(/>/g, '&gt;')
15
- .replace(/"/g, '&quot;')
16
- .replace(/([\\`*_[\]{}()#+\-.!|])/g, '\\$1');
17
- }
18
9
  function getBodyLine(label, value) {
19
- return `<span style="opacity: 0.55">${label}:</span> ${escapeMarkdownInline(value)}`;
10
+ return formatNodeBodyMarkdownField(label, value);
20
11
  }
21
12
  export class LLMProfileNodeImpl extends NodeImpl {
22
13
  static create() {
@@ -120,7 +111,7 @@ export class LLMProfileNodeImpl extends NodeImpl {
120
111
  .map((section) => {
121
112
  const fields = section.fields.map((field) => getBodyLine(field.label, field.value));
122
113
  const snippet = section.snippet
123
- ? `${getBodyLine(section.snippet.label, '')}\n${escapeMarkdownInline(section.snippet.text)}`
114
+ ? `${formatNodeBodyMarkdownLabel(section.snippet.label)}\n<pre>${escapeHtml(section.snippet.text)}</pre>`
124
115
  : undefined;
125
116
  return [...fields, ...(snippet ? [snippet] : [])].join('\n');
126
117
  })
@@ -148,4 +139,7 @@ export class LLMProfileNodeImpl extends NodeImpl {
148
139
  };
149
140
  }
150
141
  }
142
+ function escapeHtml(value) {
143
+ return String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
144
+ }
151
145
  export const llmProfileNode = nodeDefinition(LLMProfileNodeImpl, 'LLM Profile');
@@ -4,11 +4,45 @@ import { nodeDefinition } from '../NodeDefinition.js';
4
4
  import {} from '../NodeImpl.js';
5
5
  import {} from '../NodeBase.js';
6
6
  import {} from '../EditorDefinition.js';
7
+ import {} from '../GraphProcessor.js';
8
+ import {} from '../ProcessContext.js';
9
+ import {} from '../DataValue.js';
10
+ import { extractInterpolationVariableReferences, getInterpolationGlobalValues, interpolate, } from '../../utils/interpolation.js';
11
+ import { createInterpolationInputDefinition } from '../interpolationInputDefinition.js';
7
12
  import { MatchCaseNodeBase, } from './MatchCaseNodeBase.js';
13
+ const MATCH_CASE_INTERPOLATION_INPUT_PREFIX = 'input-';
14
+ /**
15
+ * Discovers case-template inputs without joining case strings, so an incomplete
16
+ * token at one row boundary can never become a token in a neighboring row.
17
+ */
18
+ function getMatchCaseInterpolationVariableReferences(cases) {
19
+ const references = new Map();
20
+ for (const caseValue of cases) {
21
+ for (const reference of extractInterpolationVariableReferences(caseValue)) {
22
+ const existing = references.get(reference.baseName);
23
+ if (existing) {
24
+ existing.hasPath ||= reference.hasPath;
25
+ }
26
+ else {
27
+ references.set(reference.baseName, { ...reference });
28
+ }
29
+ }
30
+ }
31
+ return Array.from(references.values(), (reference) => ({ ...reference }));
32
+ }
33
+ function getMatchCaseInterpolationInputId(name) {
34
+ return `${MATCH_CASE_INTERPOLATION_INPUT_PREFIX}${name}`;
35
+ }
36
+ function getMatchCaseInterpolationInputs(references, inputs) {
37
+ return Object.fromEntries(references.map(({ baseName }) => [baseName, inputs[getMatchCaseInterpolationInputId(baseName)]]));
38
+ }
8
39
  /** Match case is the current routing node; legacy `match` remains regex-only. */
9
40
  export class MatchCaseNodeImpl extends MatchCaseNodeBase {
10
41
  caseEditorLabel = 'Cases';
11
42
  caseEditorPlaceholder = 'Case';
43
+ caseEditorHighlightsInterpolation = true;
44
+ caseEditorInputFontFamily = 'monospace';
45
+ caseEditorBoxed = true;
12
46
  casesEditorPlacement = 'before-trigger';
13
47
  customCaseValuesEditorLabel = '';
14
48
  defaultExclusive = true;
@@ -18,7 +52,7 @@ export class MatchCaseNodeImpl extends MatchCaseNodeBase {
18
52
  { value: true, label: 'First matching case' },
19
53
  { value: false, label: 'All matching cases' },
20
54
  ];
21
- sharedCustomValueInputTitle = 'Return value';
55
+ sharedCustomValueInputTitle = 'Output value';
22
56
  triggerEditorLabel = 'Trigger';
23
57
  static create() {
24
58
  return {
@@ -88,12 +122,52 @@ export class MatchCaseNodeImpl extends MatchCaseNodeBase {
88
122
  shouldHideCustomCaseValues(data) {
89
123
  return (data.returnValue ?? 'true') !== 'custom';
90
124
  }
125
+ getInterpolationInputDefinitions() {
126
+ return getMatchCaseInterpolationVariableReferences(this.data.cases).map(({ baseName, hasPath }) => createInterpolationInputDefinition({
127
+ id: getMatchCaseInterpolationInputId(baseName),
128
+ interpolationName: baseName,
129
+ dataType: hasPath ? 'any' : 'string',
130
+ required: false,
131
+ description: `The value substituted for {{${baseName}}} in Cases.`,
132
+ }));
133
+ }
134
+ resolveCaseValues(inputs, context) {
135
+ const references = getMatchCaseInterpolationVariableReferences(this.data.cases);
136
+ if (references.length === 0 && !this.data.cases.some((caseValue) => caseValue.includes('{{'))) {
137
+ return this.data.cases;
138
+ }
139
+ const globalValueCache = new Map();
140
+ const missingGlobalIds = new Set();
141
+ const getCachedGlobal = (id) => {
142
+ if (globalValueCache.has(id)) {
143
+ return globalValueCache.get(id);
144
+ }
145
+ if (missingGlobalIds.has(id)) {
146
+ return undefined;
147
+ }
148
+ const value = context?.getGlobal?.(id);
149
+ if (value === undefined) {
150
+ missingGlobalIds.add(id);
151
+ }
152
+ else {
153
+ globalValueCache.set(id, value);
154
+ }
155
+ return value;
156
+ };
157
+ const interpolationInputs = getMatchCaseInterpolationInputs(references, inputs);
158
+ return this.data.cases.map((caseValue) => interpolate(caseValue, interpolationInputs, context?.graphInputNodeValues, context?.contextValues, {
159
+ coerceBareVariableDataValues: true,
160
+ globalValues: getInterpolationGlobalValues(caseValue, getCachedGlobal),
161
+ }));
162
+ }
91
163
  getEditors() {
92
164
  return [
93
165
  {
94
166
  type: 'segmented',
95
167
  label: 'Match mode',
96
168
  dataKey: 'matchMode',
169
+ layout: 'inline',
170
+ allowOptionWrap: false,
97
171
  defaultValue: 'plainText',
98
172
  options: [
99
173
  { value: 'plainText', label: 'Plain text' },
@@ -104,6 +178,7 @@ export class MatchCaseNodeImpl extends MatchCaseNodeBase {
104
178
  type: 'toggle',
105
179
  label: 'Case sensitive',
106
180
  dataKey: 'caseSensitive',
181
+ layout: 'inline',
107
182
  defaultValue: true,
108
183
  hideIf: (data) => data.matchMode === 'regex',
109
184
  },
@@ -113,9 +188,9 @@ export class MatchCaseNodeImpl extends MatchCaseNodeBase {
113
188
  static getUIData() {
114
189
  return {
115
190
  infoBoxBody: dedent `
116
- Routes an Input value to matching case outputs. Plain text cases use exact, case-sensitive equality by default; turn off Case sensitive to ignore letter case. Choose Regular expression to use the existing JavaScript RegExp pattern behavior; the Case sensitive switch does not apply in that mode.
191
+ Routes an Input value to matching case outputs. Plain text cases use exact, case-sensitive equality by default; turn off Case sensitive to ignore letter case. Choose Regular expression to use the existing JavaScript RegExp pattern behavior; the Case sensitive switch does not apply in that mode. Cases support {{variable}} interpolation, JSONPath, and the @graphInputs, @context, and @globals runtime roots; ordinary variables create optional inputs.
117
192
 
118
- Choose First matching case to trigger only the first matching output, or All matching cases to trigger every matching output. Active outputs return True by default. They can instead return the Input value, or a custom value supplied through one shared Return value input or separate Return values inputs for every case and Unmatched.
193
+ Choose First matching case to trigger only the first matching output, or All matching cases to trigger every matching output. Active outputs return True by default. They can instead return the Input value, or a custom value supplied through one shared Output value input or separate Output values inputs for every case and Unmatched.
119
194
  `,
120
195
  infoBoxTitle: 'Match case Node',
121
196
  contextMenuTitle: 'Match case',
@@ -1,6 +1,7 @@
1
1
  import {} from '../DataValue.js';
2
2
  import {} from '../EditorDefinition.js';
3
3
  import {} from '../GraphProcessor.js';
4
+ import {} from '../ProcessContext.js';
4
5
  import { NodeImpl } from '../NodeImpl.js';
5
6
  import {} from '../NodeBase.js';
6
7
  import { coerceType } from '../../utils/coerceType.js';
@@ -11,6 +12,10 @@ import { resolveStoredOrderedPortIds } from '../../utils/orderedStringPortIds.js
11
12
  * only its matching semantics and editor wording.
12
13
  */
13
14
  export class MatchCaseNodeBase extends NodeImpl {
15
+ caseEditorHelperMessage = undefined;
16
+ caseEditorHighlightsInterpolation = false;
17
+ caseEditorInputFontFamily = undefined;
18
+ caseEditorBoxed = false;
14
19
  casesEditorPlacement = 'after-custom-values';
15
20
  customCaseValuesEditorLabel = 'Custom case values';
16
21
  defaultExclusive = false;
@@ -31,6 +36,17 @@ export class MatchCaseNodeBase extends NodeImpl {
31
36
  shouldHideCustomCaseValues(_data) {
32
37
  return false;
33
38
  }
39
+ /**
40
+ * Current Match case resolves its saved case templates at execution time.
41
+ * The legacy Regex Match node deliberately leaves its saved expressions raw.
42
+ */
43
+ resolveCaseValues(_inputs, _context) {
44
+ return this.data.cases;
45
+ }
46
+ /** Additional inputs that sit between the tested value and custom return values. */
47
+ getInterpolationInputDefinitions() {
48
+ return [];
49
+ }
34
50
  getInputDefinitions() {
35
51
  const inputs = [
36
52
  {
@@ -41,6 +57,7 @@ export class MatchCaseNodeBase extends NodeImpl {
41
57
  description: `The ${this.inputTitle} value tested against each case.`,
42
58
  },
43
59
  ];
60
+ inputs.push(...this.getInterpolationInputDefinitions());
44
61
  if (this.getReturnValueMode() !== 'custom') {
45
62
  return inputs;
46
63
  }
@@ -103,6 +120,10 @@ export class MatchCaseNodeBase extends NodeImpl {
103
120
  dataKey: 'cases',
104
121
  label: this.caseEditorLabel,
105
122
  placeholder: this.caseEditorPlaceholder,
123
+ helperMessage: this.caseEditorHelperMessage,
124
+ highlightInterpolationTokens: this.caseEditorHighlightsInterpolation,
125
+ inputFontFamily: this.caseEditorInputFontFamily,
126
+ boxed: this.caseEditorBoxed,
106
127
  reorderable: true,
107
128
  portBinding: {
108
129
  side: 'output',
@@ -141,12 +162,13 @@ export class MatchCaseNodeBase extends NodeImpl {
141
162
  ...(this.casesEditorPlacement === 'after-custom-values' ? [casesEditor] : []),
142
163
  ];
143
164
  }
144
- async process(inputs) {
165
+ async process(inputs, context) {
145
166
  const inputValue = inputs['input'];
146
167
  const inputString = inputValue?.value == null ? undefined : coerceType(inputValue, 'string');
147
168
  const portIds = this.getCasePortIds();
148
169
  const sharedValue = inputs['value'];
149
170
  const returnValueMode = this.getReturnValueMode();
171
+ const resolvedCaseValues = this.resolveCaseValues(inputs, context);
150
172
  const getInputOutputValue = () => ({
151
173
  type: 'string',
152
174
  value: inputString,
@@ -168,7 +190,7 @@ export class MatchCaseNodeBase extends NodeImpl {
168
190
  let matched = false;
169
191
  const output = {};
170
192
  for (let index = 0; index < this.data.cases.length; index++) {
171
- const caseValue = this.data.cases[index];
193
+ const caseValue = resolvedCaseValues[index] ?? this.data.cases[index];
172
194
  const matches = inputString !== undefined && this.matchesCase(inputString, caseValue);
173
195
  const canMatch = !this.getExclusive() || !matched;
174
196
  const portId = portIds[index];
@@ -48,6 +48,53 @@ function stringifyEmbeddedJsonStringFragment(value) {
48
48
  const fragment = value == null ? 'null' : typeof value === 'string' ? value : JSON.stringify(value) ?? 'null';
49
49
  return JSON.stringify(fragment).slice(1, -1);
50
50
  }
51
+ /**
52
+ * Interpolates a JSON template without parsing it. Shared by Object and other
53
+ * first-party nodes which author structured EntryType values.
54
+ */
55
+ export function interpolateJsonTemplate(baseString, values, graphInputNodeValues, contextValues, globalValues) {
56
+ const protectedBaseString = protectEscapedInterpolationTokens(baseString);
57
+ const parsedTemplate = parseInterpolationTemplate(protectedBaseString);
58
+ if (parsedTemplate.tokens.length === 0) {
59
+ return restoreEscapedInterpolationTokens(protectedBaseString);
60
+ }
61
+ let result = '';
62
+ let cursor = 0;
63
+ for (const token of parsedTemplate.tokens) {
64
+ const tokenSpan = token.span;
65
+ const isInsideString = isInsideJsonString(protectedBaseString, tokenSpan.start);
66
+ const isWholeQuotedToken = isInsideString &&
67
+ isUnescapedQuoteAt(protectedBaseString, tokenSpan.start - 1) &&
68
+ isUnescapedQuoteAt(protectedBaseString, tokenSpan.end);
69
+ const replacementStart = isWholeQuotedToken ? tokenSpan.start - 1 : tokenSpan.start;
70
+ const replacementEnd = isWholeQuotedToken ? tokenSpan.end + 1 : tokenSpan.end;
71
+ const value = token.reference
72
+ ? resolveInterpolationExpressionRawValue(token.reference, {
73
+ variables: values,
74
+ graphInputValues: graphInputNodeValues,
75
+ contextValues,
76
+ globalValues,
77
+ unwrapVariableDataValues: false,
78
+ })
79
+ : undefined;
80
+ // Restore escaped delimiters only from the authored JSON template. An
81
+ // interpolated string may itself contain literal interpolation syntax and
82
+ // must not be processed again while the final JSON is assembled.
83
+ result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor, replacementStart));
84
+ if (isInsideString && !isWholeQuotedToken) {
85
+ result += stringifyEmbeddedJsonStringFragment(value);
86
+ }
87
+ else if (isWholeQuotedToken) {
88
+ result += stringifyWholeQuotedJsonValue(value);
89
+ }
90
+ else {
91
+ result += stringifyJsonValue(value);
92
+ }
93
+ cursor = replacementEnd;
94
+ }
95
+ result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor));
96
+ return result;
97
+ }
51
98
  export class ObjectNodeImpl extends NodeImpl {
52
99
  static create() {
53
100
  const chartNode = {
@@ -117,47 +164,7 @@ export class ObjectNodeImpl extends NodeImpl {
117
164
  };
118
165
  }
119
166
  interpolate(baseString, values, graphInputNodeValues, contextValues, globalValues) {
120
- const protectedBaseString = protectEscapedInterpolationTokens(baseString);
121
- const parsedTemplate = parseInterpolationTemplate(protectedBaseString);
122
- if (parsedTemplate.tokens.length === 0) {
123
- return restoreEscapedInterpolationTokens(protectedBaseString);
124
- }
125
- let result = '';
126
- let cursor = 0;
127
- for (const token of parsedTemplate.tokens) {
128
- const tokenSpan = token.span;
129
- const isInsideString = isInsideJsonString(protectedBaseString, tokenSpan.start);
130
- const isWholeQuotedToken = isInsideString &&
131
- isUnescapedQuoteAt(protectedBaseString, tokenSpan.start - 1) &&
132
- isUnescapedQuoteAt(protectedBaseString, tokenSpan.end);
133
- const replacementStart = isWholeQuotedToken ? tokenSpan.start - 1 : tokenSpan.start;
134
- const replacementEnd = isWholeQuotedToken ? tokenSpan.end + 1 : tokenSpan.end;
135
- const value = token.reference
136
- ? resolveInterpolationExpressionRawValue(token.reference, {
137
- variables: values,
138
- graphInputValues: graphInputNodeValues,
139
- contextValues,
140
- globalValues,
141
- unwrapVariableDataValues: false,
142
- })
143
- : undefined;
144
- // Restore escaped delimiters only from the authored JSON template. An
145
- // interpolated string may itself contain literal interpolation syntax and
146
- // must not be processed again while the final JSON is assembled.
147
- result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor, replacementStart));
148
- if (isInsideString && !isWholeQuotedToken) {
149
- result += stringifyEmbeddedJsonStringFragment(value);
150
- }
151
- else if (isWholeQuotedToken) {
152
- result += stringifyWholeQuotedJsonValue(value);
153
- }
154
- else {
155
- result += stringifyJsonValue(value);
156
- }
157
- cursor = replacementEnd;
158
- }
159
- result += restoreEscapedInterpolationTokens(protectedBaseString.slice(cursor));
160
- return result;
167
+ return interpolateJsonTemplate(baseString, values, graphInputNodeValues, contextValues, globalValues);
161
168
  }
162
169
  async process(inputs, context) {
163
170
  const inputMap = Object.keys(inputs).reduce((acc, key) => {
@@ -32,7 +32,7 @@ export class PassthroughNodeImpl extends NodeImpl {
32
32
  visualData: {
33
33
  x: 0,
34
34
  y: 0,
35
- width: 175,
35
+ width: 190,
36
36
  },
37
37
  };
38
38
  return chartNode;
@@ -0,0 +1,37 @@
1
+ import { newId } from '../../utils/index.js';
2
+ import { nodeDefinition } from '../NodeDefinition.js';
3
+ import { NodeImpl } from '../NodeImpl.js';
4
+ export class ProjectNameNodeImpl extends NodeImpl {
5
+ static create() {
6
+ return {
7
+ id: newId(),
8
+ type: 'projectName',
9
+ title: 'Project Name',
10
+ visualData: { x: 0, y: 0, width: 250 },
11
+ data: {},
12
+ };
13
+ }
14
+ getInputDefinitions() {
15
+ return [];
16
+ }
17
+ getOutputDefinitions() {
18
+ return [{ id: 'projectName', title: 'Project Name', dataType: 'string' }];
19
+ }
20
+ getEditors() {
21
+ return [];
22
+ }
23
+ static getUIData() {
24
+ return {
25
+ contextMenuTitle: 'Project Name',
26
+ infoBoxTitle: 'Project Name',
27
+ infoBoxBody: "Returns the name of the project that owns the graph currently being executed. A graph called from a referenced project returns that referenced project's name.",
28
+ group: ['Debug'],
29
+ };
30
+ }
31
+ async process(_inputs, context) {
32
+ return {
33
+ ['projectName']: { type: 'string', value: context.project.metadata.title },
34
+ };
35
+ }
36
+ }
37
+ export const projectNameNode = nodeDefinition(ProjectNameNodeImpl, 'Project Name');
@@ -125,6 +125,7 @@ export class ReferencedGraphAliasNodeImpl extends NodeImpl {
125
125
  try {
126
126
  const startTime = Date.now();
127
127
  const outputs = await subGraphProcessor.processGraph(context, inputData, context.contextValues, {
128
+ graphInputStreams: context.graphInputStreams,
128
129
  // This node preserves the referenced graph's named boundary ports,
129
130
  // so it may relay their direct producer partials to a parent Watch.
130
131
  // An Error-output alias can replace normal ports with exclusions,
@@ -127,6 +127,7 @@ export class SubGraphNodeImpl extends NodeImpl {
127
127
  const startTime = Date.now();
128
128
  const graphOutputs = await subGraphProcessor.processGraph(context, inputData, context.contextValues, {
129
129
  ...(requestedGraphOutputIds ? { requestedGraphOutputIds } : {}),
130
+ graphInputStreams: context.graphInputStreams,
130
131
  // A child Graph Output can relay a direct producer's partial value
131
132
  // under the public boundary port ID. An Error-output Subgraph may
132
133
  // later replace that same normal output with an exclusion, so it is