@langwatch/server 3.2.0 → 3.2.1

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 (33) hide show
  1. package/langwatch/.env.example +7 -0
  2. package/langwatch/dist/client/assets/OptimizationStudio-vCR-uGTm.js +62 -0
  3. package/langwatch/dist/client/assets/_not-found-Dv8tdtNM.js +1 -0
  4. package/langwatch/dist/client/assets/_slug_-CMsn7wx1.js +2 -0
  5. package/langwatch/dist/client/assets/{_workflow_-TEGyCfw0.js → _workflow_-f70BEhXP.js} +2 -2
  6. package/langwatch/dist/client/assets/{index-C3Ph7QLU.js → index-dGagDk3A.js} +3 -3
  7. package/langwatch/dist/client/assets/{wizard-D-JZyqZ3.js → wizard-DG1p4X8m.js} +2 -2
  8. package/langwatch/dist/client/index.html +1 -1
  9. package/langwatch/ee/billing/nurturing/hooks/index.ts +1 -0
  10. package/langwatch/ee/billing/nurturing/hooks/inviteAcceptance.ts +55 -0
  11. package/langwatch/ee/billing/nurturing/types.ts +2 -1
  12. package/langwatch/package.json +4 -2
  13. package/langwatch/pnpm-lock.yaml +306 -333
  14. package/langwatch/scripts/check-feature-parity.ts +17 -0
  15. package/langwatch/src/optimization_studio/components/Publish.tsx +27 -75
  16. package/langwatch/src/optimization_studio/components/__tests__/Publish.gate-removed.integration.test.tsx +301 -0
  17. package/langwatch/src/optimization_studio/server/__tests__/loadDatasets.test.ts +164 -0
  18. package/langwatch/src/optimization_studio/server/loadDatasets.ts +9 -5
  19. package/langwatch/src/server/api/routers/__tests__/organization.acceptInvite.unit.test.ts +9 -0
  20. package/langwatch/src/server/api/routers/organization.ts +17 -0
  21. package/langwatch/src/server/auth0/__tests__/passwordService.integration.test.ts +1 -1
  22. package/langwatch/src/server/sdk-radar/sdk-versions.json +1 -1
  23. package/mcp-server/dist/{chunk-KRE2ON65.js → chunk-ZYZJY5W7.js} +6 -1
  24. package/mcp-server/dist/create-mcp-server.js +1 -1
  25. package/mcp-server/dist/{http-server-WUOH7ASX.js → http-server-C7HT6RPO.js} +2 -2
  26. package/mcp-server/dist/index.js +5 -0
  27. package/mcp-server/package.json +5 -0
  28. package/mcp-server/pnpm-lock.yaml +30 -21
  29. package/package.json +1 -1
  30. package/packages/server/dist/cli.cjs +146 -44
  31. package/langwatch/dist/client/assets/OptimizationStudio-CjZwjRfx.js +0 -62
  32. package/langwatch/dist/client/assets/_not-found-C5bT8cI3.js +0 -1
  33. package/langwatch/dist/client/assets/_slug_-Bk9ghwH9.js +0 -2
@@ -62,6 +62,23 @@ const LEGACY_UNBOUND: string[] = [
62
62
  // Drive this list to empty by binding scenarios, flagging
63
63
  // `@unimplemented`, or removing scenarios from feature files.
64
64
  // See dev/docs/TESTING_PHILOSOPHY.md for the migration direction.
65
+ //
66
+ // nlp-go workflow engine (introduced by #3483) — scenarios document the
67
+ // Go port of the NLP workflow engine. Tests live in services/aigateway
68
+ // and langwatch_nlp; bindings have not been backfilled yet.
69
+ "specs/nlp-go/code-block.feature",
70
+ "specs/nlp-go/dataset-block.feature",
71
+ "specs/nlp-go/engine.feature",
72
+ "specs/nlp-go/feature-flag.feature",
73
+ "specs/nlp-go/front-door.feature",
74
+ "specs/nlp-go/http-block.feature",
75
+ "specs/nlp-go/llm-block.feature",
76
+ "specs/nlp-go/parallel-deployment.feature",
77
+ "specs/nlp-go/proxy.feature",
78
+ "specs/nlp-go/telemetry.feature",
79
+ "specs/nlp-go/topic-clustering.feature",
80
+ "specs/nlp-go/tracing-parity.feature",
81
+ "specs/studio/dataset-creation-regression.feature",
65
82
  ];
66
83
 
67
84
  const TEST_FILE_RE = /\.test\.tsx?$/;
@@ -3,25 +3,21 @@ import {
3
3
  Box,
4
4
  Button,
5
5
  HStack,
6
- type MenuItemProps,
7
6
  Separator,
8
7
  Skeleton,
9
8
  Spacer,
10
- Spinner,
11
9
  Text,
12
10
  useDisclosure,
13
11
  VStack,
14
12
  } from "@chakra-ui/react";
15
13
  import type { Dataset, DatasetRecord, Project } from "@prisma/client";
16
14
  import type { Edge } from "@xyflow/react";
17
- import { useRouter } from "~/utils/compat/next-router";
18
15
  import { useCallback, useState } from "react";
19
16
  import {
20
17
  ArrowUp,
21
18
  ArrowUpCircle,
22
19
  ChevronDown,
23
20
  Code,
24
- Lock,
25
21
  Play,
26
22
  Share2,
27
23
  XCircle,
@@ -37,8 +33,6 @@ import { toaster } from "../../components/ui/toaster";
37
33
  import { Tooltip } from "../../components/ui/tooltip";
38
34
  import { useOrganizationTeamProject } from "../../hooks/useOrganizationTeamProject";
39
35
  import { api } from "../../utils/api";
40
- import { trackEvent } from "../../utils/tracking";
41
- import { usePlanManagementUrl } from "../../hooks/usePlanManagementUrl";
42
36
  import { useModelProviderKeys } from "../hooks/useModelProviderKeys";
43
37
  import { useWorkflowStore } from "../hooks/useWorkflowStore";
44
38
  import type { Workflow } from "../types/dsl";
@@ -240,7 +234,6 @@ function PublishMenu({
240
234
  project,
241
235
  allowSaveIfAutoSaveIsCurrentButNotLatest: false,
242
236
  });
243
- const router = useRouter();
244
237
  const trpc = api.useContext();
245
238
 
246
239
  const publishedWorkflow = api.optimization.getPublishedWorkflow.useQuery(
@@ -325,56 +318,10 @@ function PublishMenu({
325
318
  });
326
319
  };
327
320
 
328
- const { organization } = useOrganizationTeamProject();
329
- const { url: planManagementUrl } = usePlanManagementUrl();
330
- const usage = api.limits.getUsage.useQuery(
331
- { organizationId: organization?.id ?? "" },
332
- {
333
- enabled: !!organization,
334
- },
335
- );
336
-
337
- const planAllowsToPublish = usage.data?.activePlan.canPublish;
338
321
  const publishDisabledLabel = !publishedWorkflow.data?.version
339
322
  ? "Publish a version to enable this option"
340
323
  : undefined;
341
324
 
342
- const SubscriptionMenuItem = (
343
- props: MenuItemProps & {
344
- tooltip?: string;
345
- },
346
- ) => {
347
- if (!planAllowsToPublish) {
348
- return (
349
- <Tooltip
350
- content="Subscribe to unlock publishing, click to continue"
351
- positioning={{ placement: "right" }}
352
- >
353
- <Menu.Item
354
- {...props}
355
- disabled={false}
356
- color="fg.subtle"
357
- onClick={() => {
358
- trackEvent("subscription_hook_click", {
359
- projectId: project?.id,
360
- hook: "studio_click_subscribe_to_publish",
361
- });
362
- void router.push(planManagementUrl);
363
- }}
364
- >
365
- {usage.data ? <Lock size={16} /> : <Spinner size="sm" />}
366
- {props.children}
367
- </Menu.Item>
368
- </Tooltip>
369
- );
370
- }
371
- return (
372
- <Tooltip content={props.tooltip} positioning={{ placement: "right" }}>
373
- <Menu.Item {...props} />
374
- </Tooltip>
375
- );
376
- };
377
-
378
325
  const handleExportWorkflow = async () => {
379
326
  await exportWorkflow(workflow, datasetRecords.data ?? undefined);
380
327
  };
@@ -390,16 +337,17 @@ function PublishMenu({
390
337
  <Separator />
391
338
  </>
392
339
  )}
393
- <SubscriptionMenuItem
394
- tooltip={canPublish}
395
- onClick={onTogglePublish}
396
- disabled={!!canPublish}
397
- value="publish"
398
- >
399
- <ArrowUp size={16} />{" "}
400
- <Text textTransform="capitalize">{`Publish ${workflow_type}`}</Text>
401
- </SubscriptionMenuItem>
402
- <SubscriptionMenuItem
340
+ <Tooltip content={canPublish} positioning={{ placement: "right" }}>
341
+ <Menu.Item
342
+ onClick={onTogglePublish}
343
+ disabled={!!canPublish}
344
+ value="publish"
345
+ >
346
+ <ArrowUp size={16} />{" "}
347
+ <Text textTransform="capitalize">{`Publish ${workflow_type}`}</Text>
348
+ </Menu.Item>
349
+ </Tooltip>
350
+ <Menu.Item
403
351
  hidden={
404
352
  workflow_type === "workflow" || !publishedWorkflow.data?.isEvaluator
405
353
  }
@@ -407,9 +355,9 @@ function PublishMenu({
407
355
  value="evaluator"
408
356
  >
409
357
  <XCircle size={16} /> Unpublish Evaluator
410
- </SubscriptionMenuItem>
358
+ </Menu.Item>
411
359
 
412
- <SubscriptionMenuItem
360
+ <Menu.Item
413
361
  hidden={
414
362
  workflow_type === "workflow" || !publishedWorkflow.data?.isComponent
415
363
  }
@@ -417,22 +365,26 @@ function PublishMenu({
417
365
  onClick={disableAsComponent}
418
366
  >
419
367
  <XCircle size={16} /> Unpublish Component
420
- </SubscriptionMenuItem>
368
+ </Menu.Item>
421
369
 
422
- <SubscriptionMenuItem
423
- tooltip={publishDisabledLabel}
424
- onClick={onToggleApi}
425
- disabled={!!publishDisabledLabel}
426
- value="api-reference"
370
+ <Tooltip
371
+ content={publishDisabledLabel}
372
+ positioning={{ placement: "right" }}
427
373
  >
428
- <Code size={16} /> View API Reference
429
- </SubscriptionMenuItem>
430
- <SubscriptionMenuItem
374
+ <Menu.Item
375
+ onClick={onToggleApi}
376
+ disabled={!!publishDisabledLabel}
377
+ value="api-reference"
378
+ >
379
+ <Code size={16} /> View API Reference
380
+ </Menu.Item>
381
+ </Tooltip>
382
+ <Menu.Item
431
383
  onClick={() => void handleExportWorkflow()}
432
384
  value="export-workflow"
433
385
  >
434
386
  <Share2 size={16} /> Export Workflow
435
- </SubscriptionMenuItem>
387
+ </Menu.Item>
436
388
  </>
437
389
  );
438
390
  }
@@ -0,0 +1,301 @@
1
+ /**
2
+ * @vitest-environment jsdom
3
+ *
4
+ * Integration test for the Publish menu in the optimization studio.
5
+ *
6
+ * Pins the regression: the studio Publish menu must NOT be gated by
7
+ * `usage.activePlan.canPublish`. No Lock icon, no "Subscribe to unlock"
8
+ * tooltip, no redirect to plan management — even when the active plan
9
+ * has canPublish=false.
10
+ *
11
+ * See specs/studio/publish-not-gated.feature.
12
+ */
13
+ import { cleanup, fireEvent, render, screen } from "@testing-library/react";
14
+ import { ChakraProvider, defaultSystem } from "@chakra-ui/react";
15
+ import type { ReactNode } from "react";
16
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
17
+
18
+ const { mockCanPublish, mockRouterPush, mockTrackEvent } = vi.hoisted(() => ({
19
+ mockCanPublish: { current: false as boolean },
20
+ mockRouterPush: vi.fn(),
21
+ mockTrackEvent: vi.fn(),
22
+ }));
23
+
24
+ vi.mock("~/utils/compat/next-router", () => ({
25
+ useRouter: () => ({
26
+ query: {},
27
+ push: mockRouterPush,
28
+ back: vi.fn(),
29
+ }),
30
+ }));
31
+
32
+ vi.mock("~/hooks/useOrganizationTeamProject", () => ({
33
+ useOrganizationTeamProject: () => ({
34
+ organization: { id: "org-1" },
35
+ project: { id: "proj-1", slug: "test-project", apiKey: "test-key" },
36
+ }),
37
+ }));
38
+
39
+ vi.mock("~/hooks/usePlanManagementUrl", () => ({
40
+ usePlanManagementUrl: () => ({ url: "/settings/subscription" }),
41
+ }));
42
+
43
+ vi.mock("~/utils/tracking", () => ({
44
+ trackEvent: mockTrackEvent,
45
+ }));
46
+
47
+ vi.mock("~/utils/api", () => {
48
+ const queryStub = (data: unknown) => ({
49
+ useQuery: () => ({ data, isLoading: false, refetch: vi.fn() }),
50
+ });
51
+ const mutationStub = () => ({
52
+ useMutation: () => ({
53
+ mutate: vi.fn(),
54
+ mutateAsync: vi.fn(),
55
+ isLoading: false,
56
+ isPending: false,
57
+ }),
58
+ });
59
+ return {
60
+ api: {
61
+ useContext: () => ({
62
+ optimization: { getComponents: { invalidate: vi.fn() } },
63
+ }),
64
+ limits: {
65
+ getUsage: {
66
+ useQuery: () => ({
67
+ data: {
68
+ activePlan: { canPublish: mockCanPublish.current },
69
+ },
70
+ isLoading: false,
71
+ refetch: vi.fn(),
72
+ }),
73
+ },
74
+ },
75
+ optimization: {
76
+ getPublishedWorkflow: queryStub({
77
+ version: "1.0.0",
78
+ dsl: { nodes: [], edges: [], name: "Test", workflow_id: "wf-1" },
79
+ isComponent: false,
80
+ isEvaluator: false,
81
+ }),
82
+ toggleSaveAsComponent: mutationStub(),
83
+ toggleSaveAsEvaluator: mutationStub(),
84
+ disableAsComponent: mutationStub(),
85
+ disableAsEvaluator: mutationStub(),
86
+ getComponents: { invalidate: vi.fn() },
87
+ },
88
+ datasetRecord: {
89
+ getAll: queryStub([]),
90
+ },
91
+ workflow: {
92
+ publish: mutationStub(),
93
+ commitVersion: mutationStub(),
94
+ },
95
+ },
96
+ };
97
+ });
98
+
99
+ vi.mock("../../hooks/useWorkflowStore", () => ({
100
+ useWorkflowStore: (selector: (s: any) => any) =>
101
+ selector({
102
+ workflow_id: "wf-1",
103
+ workflow_type: "workflow",
104
+ getWorkflow: () => ({
105
+ workflow_id: "wf-1",
106
+ name: "Test Workflow",
107
+ nodes: [],
108
+ edges: [],
109
+ state: {},
110
+ }),
111
+ setLastCommittedWorkflow: vi.fn(),
112
+ setCurrentVersionId: vi.fn(),
113
+ currentVersionId: "v-1",
114
+ checkCanCommitNewVersion: () => false,
115
+ }),
116
+ }));
117
+
118
+ vi.mock("../../hooks/useModelProviderKeys", () => ({
119
+ useModelProviderKeys: () => ({
120
+ hasProvidersWithoutCustomKeys: false,
121
+ nodeProvidersWithoutCustomKeys: [],
122
+ }),
123
+ }));
124
+
125
+ vi.mock("../History", () => ({
126
+ useVersionState: () => ({
127
+ canSaveNewVersion: false,
128
+ versionToBeEvaluated: { version: "1.0.0" },
129
+ versions: { data: [], refetch: vi.fn() },
130
+ }),
131
+ }));
132
+
133
+ vi.mock("../VersionToBeUsed", () => ({
134
+ VersionToBeUsed: () => null,
135
+ }));
136
+
137
+ vi.mock("../AddModelProviderKey", () => ({
138
+ AddModelProviderKey: () => null,
139
+ }));
140
+
141
+ vi.mock("~/components/ui/menu", () => ({
142
+ Menu: {
143
+ Root: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
144
+ Trigger: ({ children }: { children?: ReactNode }) => (
145
+ <div>{children}</div>
146
+ ),
147
+ Content: ({ children }: { children?: ReactNode }) => (
148
+ <div>{children}</div>
149
+ ),
150
+ Item: ({
151
+ children,
152
+ onClick,
153
+ hidden,
154
+ ...props
155
+ }: {
156
+ children?: ReactNode;
157
+ onClick?: () => void;
158
+ hidden?: boolean;
159
+ [key: string]: any;
160
+ }) =>
161
+ hidden ? null : (
162
+ <button type="button" onClick={onClick} {...props}>
163
+ {children}
164
+ </button>
165
+ ),
166
+ },
167
+ }));
168
+
169
+ vi.mock("~/components/ui/dialog", () => ({
170
+ Dialog: {
171
+ Root: ({ children, open }: { children?: ReactNode; open?: boolean }) =>
172
+ open ? <div>{children}</div> : null,
173
+ Content: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
174
+ Header: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
175
+ Title: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
176
+ CloseTrigger: () => <div />,
177
+ Body: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
178
+ Footer: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
179
+ },
180
+ }));
181
+
182
+ vi.mock("~/components/ui/tooltip", () => ({
183
+ Tooltip: ({
184
+ content,
185
+ children,
186
+ }: {
187
+ content?: ReactNode;
188
+ children?: ReactNode;
189
+ }) => (
190
+ <span data-tooltip-content={typeof content === "string" ? content : ""}>
191
+ {children}
192
+ </span>
193
+ ),
194
+ }));
195
+
196
+ vi.mock("~/components/ui/link", () => ({
197
+ Link: ({
198
+ children,
199
+ href,
200
+ ...props
201
+ }: {
202
+ children?: ReactNode;
203
+ href?: string;
204
+ [key: string]: any;
205
+ }) => (
206
+ <a href={href} {...props}>
207
+ {children}
208
+ </a>
209
+ ),
210
+ }));
211
+
212
+ const { Publish } = await import("../Publish");
213
+
214
+ function renderPublish() {
215
+ return render(
216
+ <ChakraProvider value={defaultSystem}>
217
+ <Publish isDisabled={false} />
218
+ </ChakraProvider>,
219
+ );
220
+ }
221
+
222
+ describe("given the studio Publish menu is rendered", () => {
223
+ afterEach(() => {
224
+ cleanup();
225
+ vi.clearAllMocks();
226
+ });
227
+
228
+ beforeEach(() => {
229
+ mockCanPublish.current = false;
230
+ });
231
+
232
+ describe("when the active plan does NOT allow publishing", () => {
233
+ beforeEach(() => {
234
+ mockCanPublish.current = false;
235
+ });
236
+
237
+ /** @scenario Free SaaS user can open the publish menu without a paywall */
238
+ /** @scenario Self-hosted user without a paid license can open the publish menu without a paywall */
239
+ it("does not render a 'Subscribe to unlock publishing' tooltip", () => {
240
+ renderPublish();
241
+ const tooltips = document.querySelectorAll("[data-tooltip-content]");
242
+ const lockTooltips = Array.from(tooltips).filter((el) =>
243
+ (el.getAttribute("data-tooltip-content") ?? "").includes(
244
+ "Subscribe to unlock publishing",
245
+ ),
246
+ );
247
+ expect(lockTooltips).toHaveLength(0);
248
+ });
249
+
250
+ it("renders the Publish workflow menu item with no lock", () => {
251
+ renderPublish();
252
+ const publishItem = screen.getByText(/Publish workflow/i);
253
+ expect(publishItem).toBeDefined();
254
+ // react-feather renders <Lock /> as <svg class="feather feather-lock">,
255
+ // which the paywall used to inject next to the menu item children.
256
+ // Asserting it's absent guards against regressing the icon on its own.
257
+ const lockIcons = document.querySelectorAll(".feather-lock");
258
+ expect(lockIcons).toHaveLength(0);
259
+ });
260
+
261
+ /** @scenario Publish.tsx does not query plan.canPublish to gate the menu */
262
+ it("does not redirect to plan management or fire subscription tracking when Publish is clicked", () => {
263
+ renderPublish();
264
+ const publishButton = screen.getByText(/Publish workflow/i)
265
+ .closest("button");
266
+ expect(publishButton).not.toBeNull();
267
+ fireEvent.click(publishButton!);
268
+
269
+ expect(mockRouterPush).not.toHaveBeenCalledWith("/settings/subscription");
270
+ expect(mockTrackEvent).not.toHaveBeenCalledWith(
271
+ "subscription_hook_click",
272
+ expect.anything(),
273
+ );
274
+ });
275
+
276
+ it("renders View API Reference and Export Workflow without paywall", () => {
277
+ renderPublish();
278
+ expect(screen.getByText(/View API Reference/i)).toBeDefined();
279
+ expect(screen.getByText(/Export Workflow/i)).toBeDefined();
280
+ });
281
+ });
282
+
283
+ describe("when the active plan allows publishing", () => {
284
+ beforeEach(() => {
285
+ mockCanPublish.current = true;
286
+ });
287
+
288
+ /** @scenario Paid SaaS user can publish without a paywall (regression) */
289
+ it("still renders the Publish menu without paywall (regression)", () => {
290
+ renderPublish();
291
+ expect(screen.getByText(/Publish workflow/i)).toBeDefined();
292
+ const tooltips = document.querySelectorAll("[data-tooltip-content]");
293
+ const lockTooltips = Array.from(tooltips).filter((el) =>
294
+ (el.getAttribute("data-tooltip-content") ?? "").includes(
295
+ "Subscribe to unlock publishing",
296
+ ),
297
+ );
298
+ expect(lockTooltips).toHaveLength(0);
299
+ });
300
+ });
301
+ });
@@ -0,0 +1,164 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+ import type { StudioClientEvent } from "../../types/events";
3
+
4
+ vi.mock("../../../server/api/routers/datasetRecord.utils", () => ({
5
+ getFullDataset: vi.fn(),
6
+ }));
7
+
8
+ vi.mock("../../utils/datasetUtils", async () => {
9
+ const actual = await vi.importActual<typeof import("../../utils/datasetUtils")>(
10
+ "../../utils/datasetUtils",
11
+ );
12
+ return actual;
13
+ });
14
+
15
+ import { getFullDataset } from "../../../server/api/routers/datasetRecord.utils";
16
+ import { loadDatasets } from "../loadDatasets";
17
+
18
+ const PROJECT_ID = "project-123";
19
+
20
+ const makeEntryNode = (dataset: any) => ({
21
+ id: "entry",
22
+ type: "entry",
23
+ data: {
24
+ name: "Entry",
25
+ dataset,
26
+ outputs: [{ identifier: "question", type: "str" }],
27
+ },
28
+ });
29
+
30
+ const makeEvent = (
31
+ type: StudioClientEvent["type"],
32
+ entryDataset: any,
33
+ extraPayload: Record<string, any> = {},
34
+ ): StudioClientEvent =>
35
+ ({
36
+ type,
37
+ payload: {
38
+ trace_id: "trace-1",
39
+ workflow: {
40
+ workflow_id: "wf-1",
41
+ api_key: "k",
42
+ spec_version: "1.4",
43
+ name: "Test",
44
+ icon: "x",
45
+ description: "x",
46
+ version: "x",
47
+ template_adapter: "default",
48
+ default_llm: { model: "openai/gpt-4o" },
49
+ nodes: [makeEntryNode(entryDataset)],
50
+ edges: [],
51
+ state: { execution: { status: "idle" as const } },
52
+ },
53
+ ...extraPayload,
54
+ },
55
+ }) as unknown as StudioClientEvent;
56
+
57
+ describe("loadDatasets", () => {
58
+ beforeEach(() => {
59
+ vi.clearAllMocks();
60
+ });
61
+
62
+ // Regression pin for the 3.2.0 prod break (a customer saw
63
+ // "entry node has no inline dataset (remote datasets not yet
64
+ // supported on Go path)" on a saved-dataset Evaluate run). Pre-fix,
65
+ // execute_evaluation forced entrySelection="all" then short-circuited
66
+ // the database-dataset branch with `if (entrySelection == "all") return
67
+ // node;`, so the Go engine received a dataset_id-only payload and
68
+ // rejected it. Now loadDatasets always fetches + inlines on the
69
+ // database path, regardless of evaluate_on/entry_selection mode.
70
+ it("inlines saved (database) datasets on execute_evaluation when entry_selection is all", async () => {
71
+ (getFullDataset as ReturnType<typeof vi.fn>).mockResolvedValue({
72
+ id: "ds_xyz",
73
+ name: "Saved",
74
+ datasetRecords: [
75
+ { id: "r1", entry: { question: "q1" }, createdAt: new Date(), updatedAt: new Date() },
76
+ { id: "r2", entry: { question: "q2" }, createdAt: new Date(), updatedAt: new Date() },
77
+ ],
78
+ count: 2,
79
+ truncated: false,
80
+ columnTypes: [{ name: "question", type: "string" }],
81
+ });
82
+
83
+ const event = makeEvent(
84
+ "execute_evaluation",
85
+ { id: "ds_xyz", name: "Saved" },
86
+ {
87
+ run_id: "run_1",
88
+ workflow_version_id: "v1",
89
+ evaluate_on: "full",
90
+ },
91
+ );
92
+
93
+ const enriched = await loadDatasets(event, PROJECT_ID);
94
+
95
+ expect(getFullDataset).toHaveBeenCalledWith({
96
+ datasetId: "ds_xyz",
97
+ projectId: PROJECT_ID,
98
+ entrySelection: "all",
99
+ });
100
+
101
+ if (!("workflow" in enriched.payload)) {
102
+ throw new Error("expected workflow in payload");
103
+ }
104
+ const entry = enriched.payload.workflow.nodes.find(
105
+ (n: any) => n.id === "entry",
106
+ );
107
+ expect(entry).toBeDefined();
108
+ expect((entry as any).data.dataset.inline).toBeDefined();
109
+ expect((entry as any).data.dataset.inline.records).toBeDefined();
110
+ expect((entry as any).data.dataset.inline.records.question).toEqual([
111
+ "q1",
112
+ "q2",
113
+ ]);
114
+ });
115
+
116
+ it("preserves inline datasets without fetching", async () => {
117
+ const event = makeEvent(
118
+ "execute_evaluation",
119
+ {
120
+ inline: {
121
+ records: { question: ["a", "b"] },
122
+ },
123
+ },
124
+ {
125
+ run_id: "run_2",
126
+ workflow_version_id: "v1",
127
+ evaluate_on: "full",
128
+ },
129
+ );
130
+
131
+ const enriched = await loadDatasets(event, PROJECT_ID);
132
+
133
+ expect(getFullDataset).not.toHaveBeenCalled();
134
+ if (!("workflow" in enriched.payload)) {
135
+ throw new Error("expected workflow in payload");
136
+ }
137
+ const entry = enriched.payload.workflow.nodes.find(
138
+ (n: any) => n.id === "entry",
139
+ );
140
+ expect((entry as any).data.dataset.inline.records.question).toEqual([
141
+ "a",
142
+ "b",
143
+ ]);
144
+ });
145
+
146
+ it("strips dataset on execute_component to keep the engine focused on the named node", async () => {
147
+ const event = makeEvent(
148
+ "execute_component",
149
+ { id: "ds_xyz", name: "Saved" },
150
+ { node_id: "some_node", inputs: { foo: "bar" } },
151
+ );
152
+
153
+ const enriched = await loadDatasets(event, PROJECT_ID);
154
+
155
+ expect(getFullDataset).not.toHaveBeenCalled();
156
+ if (!("workflow" in enriched.payload)) {
157
+ throw new Error("expected workflow in payload");
158
+ }
159
+ const entry = enriched.payload.workflow.nodes.find(
160
+ (n: any) => n.id === "entry",
161
+ );
162
+ expect((entry as any).data.dataset).toBeUndefined();
163
+ });
164
+ });
@@ -73,15 +73,19 @@ export const loadDatasets = async (
73
73
  };
74
74
  }
75
75
 
76
- // For database datasets, we'll just pass the ID and let the Python SDK fetch it
76
+ // Inline the database dataset server-side. Python's path used to
77
+ // tolerate a dataset_id-only payload and fetch via
78
+ // langwatch.dataset.get_dataset; the Go engine has no equivalent
79
+ // fetch port and rejects with "entry node has no inline dataset"
80
+ // (services/nlpgo/app/engine/evaluation.go). Inlining here keeps
81
+ // both engines on a single uniform shape — Python's Pydantic
82
+ // dataset path tolerates inline records, so this is a no-op for
83
+ // the legacy engine. (3.2.0 prod regression: a customer saw
84
+ // the Go-only error on a saved-dataset Evaluate run.)
77
85
  if (!node.data.dataset.id) {
78
86
  throw new Error("Dataset ID is required");
79
87
  }
80
88
 
81
- if (entrySelection == "all") {
82
- return node;
83
- }
84
-
85
89
  const dataset = await getFullDataset({
86
90
  datasetId: node.data.dataset.id,
87
91
  projectId,