Skip to content

Commit 0143ad7

Browse files
authored
Improve runtime design (#187)
1 parent 4f3c839 commit 0143ad7

306 files changed

Lines changed: 2884 additions & 1759 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/api/src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { JWTTokenPayload } from "@dafthunk/types";
22

3-
import { RuntimeParams } from "./runtime/runtime";
3+
import type { RuntimeParams } from "./runtime";
44
import { Session } from "./session/session";
55

66
export interface Bindings {

apps/api/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import typeRoutes from "./routes/types";
2424
import usageRoutes from "./routes/usage";
2525
import workflowRoutes from "./routes/workflows";
2626
import wsRoutes from "./routes/ws";
27-
import { Runtime } from "./runtime/runtime";
27+
import { Runtime } from "./runtime";
2828
import { Session } from "./session/session";
2929

3030
// Initialize Hono app with types

apps/api/src/nodes/3d/buffergeometry-to-gltf-node.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ describe("BufferGeometryToGltfNode", () => {
99
workflowId: "test-workflow",
1010
organizationId: "test-org",
1111
inputs,
12+
getIntegration: async () => {
13+
throw new Error("No integrations in test");
14+
},
1215
env: {} as any,
1316
});
1417

apps/api/src/nodes/3d/dem-to-buffergeometry-node.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ describe("DemToBufferGeometryNode", () => {
99
workflowId: "test-workflow",
1010
organizationId: "test-org",
1111
inputs,
12+
getIntegration: async () => {
13+
throw new Error("No integrations in test");
14+
},
1215
env: {} as any,
1316
});
1417

apps/api/src/nodes/3d/geotiff-dem-query-node.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ describe("GeoTiffDemQueryNode", () => {
5757
width: 256,
5858
height: 256,
5959
},
60+
getIntegration: async () => {
61+
throw new Error("No integrations in test");
62+
},
6063
env: {} as any,
6164
});
6265

@@ -75,6 +78,9 @@ describe("GeoTiffDemQueryNode", () => {
7578
width: 256,
7679
height: 256,
7780
},
81+
getIntegration: async () => {
82+
throw new Error("No integrations in test");
83+
},
7884
env: {} as any,
7985
});
8086

@@ -95,6 +101,9 @@ describe("GeoTiffDemQueryNode", () => {
95101
width: "256", // Invalid: string instead of number
96102
height: 256,
97103
},
104+
getIntegration: async () => {
105+
throw new Error("No integrations in test");
106+
},
98107
env: {} as any,
99108
});
100109

@@ -116,6 +125,9 @@ describe("GeoTiffDemQueryNode", () => {
116125
width: 256,
117126
height: 256,
118127
},
128+
getIntegration: async () => {
129+
throw new Error("No integrations in test");
130+
},
119131
env: {} as any,
120132
});
121133

@@ -156,6 +168,9 @@ describe("GeoTiffDemQueryNode", () => {
156168
width: 2,
157169
height: 2,
158170
},
171+
getIntegration: async () => {
172+
throw new Error("No integrations in test");
173+
},
159174
env: {} as any,
160175
});
161176

@@ -205,6 +220,9 @@ describe("GeoTiffDemQueryNode", () => {
205220
width: 256,
206221
height: 256,
207222
},
223+
getIntegration: async () => {
224+
throw new Error("No integrations in test");
225+
},
208226
env: {} as any,
209227
});
210228

@@ -247,6 +265,9 @@ describe("GeoTiffDemQueryNode", () => {
247265
width: 2,
248266
height: 2,
249267
},
268+
getIntegration: async () => {
269+
throw new Error("No integrations in test");
270+
},
250271
env: {} as any,
251272
});
252273

@@ -290,6 +311,9 @@ describe("GeoTiffDemQueryNode", () => {
290311
width: 2,
291312
height: 1,
292313
},
314+
getIntegration: async () => {
315+
throw new Error("No integrations in test");
316+
},
293317
env: {} as any,
294318
});
295319

apps/api/src/nodes/3d/geotiff-metadata-reader-node.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ describe("GeoTiffMetadataReaderNode", () => {
2525
workflowId: "test-workflow",
2626
organizationId: "test-org",
2727
inputs: {},
28+
getIntegration: async () => {
29+
throw new Error("No integrations in test");
30+
},
2831
env: {} as any,
2932
});
3033

@@ -38,6 +41,9 @@ describe("GeoTiffMetadataReaderNode", () => {
3841
workflowId: "test-workflow",
3942
organizationId: "test-org",
4043
inputs: { url: 123 },
44+
getIntegration: async () => {
45+
throw new Error("No integrations in test");
46+
},
4147
env: {} as any,
4248
});
4349

@@ -51,6 +57,9 @@ describe("GeoTiffMetadataReaderNode", () => {
5157
workflowId: "test-workflow",
5258
organizationId: "test-org",
5359
inputs: { url: "not-a-valid-url" },
60+
getIntegration: async () => {
61+
throw new Error("No integrations in test");
62+
},
5463
env: {} as any,
5564
});
5665

@@ -67,6 +76,9 @@ describe("GeoTiffMetadataReaderNode", () => {
6776
workflowId: "test-workflow",
6877
organizationId: "test-org",
6978
inputs: { url: "https://example.com/test.tif" },
79+
getIntegration: async () => {
80+
throw new Error("No integrations in test");
81+
},
7082
env: {} as any,
7183
});
7284

@@ -102,6 +114,9 @@ describe("GeoTiffMetadataReaderNode", () => {
102114
workflowId: "test-workflow",
103115
organizationId: "test-org",
104116
inputs: { url: "https://example.com/test.tif" },
117+
getIntegration: async () => {
118+
throw new Error("No integrations in test");
119+
},
105120
env: {} as any,
106121
});
107122

apps/api/src/nodes/3d/geotiff-query-node.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ describe("GeoTiffQueryNode", () => {
3333
width: 256,
3434
height: 256,
3535
},
36+
getIntegration: async () => {
37+
throw new Error("No integrations in test");
38+
},
3639
env: {} as any,
3740
});
3841

@@ -51,6 +54,9 @@ describe("GeoTiffQueryNode", () => {
5154
width: 256,
5255
height: 256,
5356
},
57+
getIntegration: async () => {
58+
throw new Error("No integrations in test");
59+
},
5460
env: {} as any,
5561
});
5662

@@ -71,6 +77,9 @@ describe("GeoTiffQueryNode", () => {
7177
width: "256", // Invalid: string instead of number
7278
height: 256,
7379
},
80+
getIntegration: async () => {
81+
throw new Error("No integrations in test");
82+
},
7483
env: {} as any,
7584
});
7685

@@ -92,6 +101,9 @@ describe("GeoTiffQueryNode", () => {
92101
width: 256,
93102
height: 256,
94103
},
104+
getIntegration: async () => {
105+
throw new Error("No integrations in test");
106+
},
95107
env: {} as any,
96108
});
97109

@@ -129,6 +141,9 @@ describe("GeoTiffQueryNode", () => {
129141
width: 2,
130142
height: 2,
131143
},
144+
getIntegration: async () => {
145+
throw new Error("No integrations in test");
146+
},
132147
env: {} as any,
133148
});
134149

apps/api/src/nodes/anthropic/claude-3-opus-node.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ export class Claude3OpusNode extends ExecutableNode {
5959
let anthropicApiKey: string | undefined;
6060

6161
if (integrationId && typeof integrationId === "string") {
62-
const integration = context.integrations?.[integrationId];
63-
if (integration?.provider === "anthropic") {
64-
anthropicApiKey = integration.token;
62+
try {
63+
const integration = await context.getIntegration(integrationId);
64+
if (integration.provider === "anthropic") {
65+
anthropicApiKey = integration.token;
66+
}
67+
} catch {
68+
// Integration not found, will fall back to env vars or error below
6569
}
6670
}
6771

apps/api/src/nodes/anthropic/claude-35-haiku-node.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ export class Claude35HaikuNode extends ExecutableNode {
5959
let anthropicApiKey: string | undefined;
6060

6161
if (integrationId && typeof integrationId === "string") {
62-
const integration = context.integrations?.[integrationId];
63-
if (integration?.provider === "anthropic") {
64-
anthropicApiKey = integration.token;
62+
try {
63+
const integration = await context.getIntegration(integrationId);
64+
if (integration.provider === "anthropic") {
65+
anthropicApiKey = integration.token;
66+
}
67+
} catch {
68+
// Integration not found, will fall back to env vars or error below
6569
}
6670
}
6771

apps/api/src/nodes/anthropic/claude-35-sonnet-node.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ export class Claude35SonnetNode extends ExecutableNode {
5959
let anthropicApiKey: string | undefined;
6060

6161
if (integrationId && typeof integrationId === "string") {
62-
const integration = context.integrations?.[integrationId];
63-
if (integration?.provider === "anthropic") {
64-
anthropicApiKey = integration.token;
62+
try {
63+
const integration = await context.getIntegration(integrationId);
64+
if (integration.provider === "anthropic") {
65+
anthropicApiKey = integration.token;
66+
}
67+
} catch {
68+
// Integration not found, will fall back to env vars or error below
6569
}
6670
}
6771

0 commit comments

Comments
 (0)