@decocms/runtime 0.28.1 → 1.0.0-alpha.2

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 (85) hide show
  1. package/package.json +15 -76
  2. package/scripts/generate-json-schema.ts +24 -0
  3. package/src/asset-server/dev-server-proxy.ts +16 -0
  4. package/src/asset-server/index.ts +44 -0
  5. package/src/bindings/README.md +1 -1
  6. package/src/bindings/binder.ts +1 -1
  7. package/src/bindings/channels.ts +1 -1
  8. package/src/bindings/deconfig/resources.ts +47 -17
  9. package/src/bindings/deconfig/types.ts +1 -1
  10. package/src/bindings/language-model/ai-sdk.ts +7 -4
  11. package/src/bindings/resources/bindings.ts +1 -1
  12. package/src/bindings/resources/schemas.ts +1 -1
  13. package/src/bindings/views.ts +1 -1
  14. package/src/bindings.ts +8 -7
  15. package/src/index.ts +5 -20
  16. package/src/mastra.ts +1 -229
  17. package/src/mcp.ts +7 -6
  18. package/src/proxy.ts +0 -8
  19. package/src/resources.ts +1 -1
  20. package/src/state.ts +1 -1
  21. package/src/views.ts +1 -1
  22. package/tsconfig.json +8 -0
  23. package/dist/admin.d.ts +0 -5
  24. package/dist/admin.js +0 -21
  25. package/dist/admin.js.map +0 -1
  26. package/dist/bindings/deconfig/index.d.ts +0 -12
  27. package/dist/bindings/deconfig/index.js +0 -10
  28. package/dist/bindings/deconfig/index.js.map +0 -1
  29. package/dist/bindings/index.d.ts +0 -2315
  30. package/dist/bindings/index.js +0 -156
  31. package/dist/bindings/index.js.map +0 -1
  32. package/dist/chunk-3AWMDSOH.js +0 -96
  33. package/dist/chunk-3AWMDSOH.js.map +0 -1
  34. package/dist/chunk-4XSQKJLU.js +0 -105
  35. package/dist/chunk-4XSQKJLU.js.map +0 -1
  36. package/dist/chunk-5EYZ2LVM.js +0 -158
  37. package/dist/chunk-5EYZ2LVM.js.map +0 -1
  38. package/dist/chunk-7ITSLORK.js +0 -128
  39. package/dist/chunk-7ITSLORK.js.map +0 -1
  40. package/dist/chunk-I7BWSAN6.js +0 -49
  41. package/dist/chunk-I7BWSAN6.js.map +0 -1
  42. package/dist/chunk-L4OT2YDO.js +0 -27
  43. package/dist/chunk-L4OT2YDO.js.map +0 -1
  44. package/dist/chunk-SHQSNOFL.js +0 -769
  45. package/dist/chunk-SHQSNOFL.js.map +0 -1
  46. package/dist/chunk-UHR3BLMF.js +0 -92
  47. package/dist/chunk-UHR3BLMF.js.map +0 -1
  48. package/dist/chunk-UIJGM3NV.js +0 -518
  49. package/dist/chunk-UIJGM3NV.js.map +0 -1
  50. package/dist/chunk-ZPUT6RN6.js +0 -32
  51. package/dist/chunk-ZPUT6RN6.js.map +0 -1
  52. package/dist/client.d.ts +0 -28
  53. package/dist/client.js +0 -5
  54. package/dist/client.js.map +0 -1
  55. package/dist/d1-store.d.ts +0 -9
  56. package/dist/d1-store.js +0 -4
  57. package/dist/d1-store.js.map +0 -1
  58. package/dist/drizzle.d.ts +0 -49
  59. package/dist/drizzle.js +0 -121
  60. package/dist/drizzle.js.map +0 -1
  61. package/dist/index-LOfgE9a_.d.ts +0 -471
  62. package/dist/index-xKtm7A7B.d.ts +0 -530
  63. package/dist/index.d.ts +0 -10
  64. package/dist/index.js +0 -637
  65. package/dist/index.js.map +0 -1
  66. package/dist/mastra.d.ts +0 -10
  67. package/dist/mastra.js +0 -6
  68. package/dist/mastra.js.map +0 -1
  69. package/dist/mcp-87iLaW9V.d.ts +0 -105
  70. package/dist/mcp-client.d.ts +0 -232
  71. package/dist/mcp-client.js +0 -4
  72. package/dist/mcp-client.js.map +0 -1
  73. package/dist/proxy.d.ts +0 -11
  74. package/dist/proxy.js +0 -5
  75. package/dist/proxy.js.map +0 -1
  76. package/dist/resources.d.ts +0 -362
  77. package/dist/resources.js +0 -4
  78. package/dist/resources.js.map +0 -1
  79. package/dist/views.d.ts +0 -72
  80. package/dist/views.js +0 -4
  81. package/dist/views.js.map +0 -1
  82. package/src/cf-imports.ts +0 -1
  83. package/src/d1-store.ts +0 -34
  84. package/src/deprecated.ts +0 -59
  85. package/src/workflow.ts +0 -193
package/package.json CHANGED
@@ -1,101 +1,40 @@
1
1
  {
2
2
  "name": "@decocms/runtime",
3
- "version": "0.28.1",
3
+ "version": "1.0.0-alpha.2",
4
4
  "type": "module",
5
- "scripts": {
6
- "build": "tsup",
7
- "prepublishOnly": "npm run build"
8
- },
9
5
  "dependencies": {
10
6
  "@cloudflare/workers-types": "^4.20250617.0",
11
7
  "@deco/mcp": "npm:@jsr/deco__mcp@0.5.5",
12
8
  "@decocms/bindings": "*",
13
- "@mastra/cloudflare-d1": "^0.13.4",
14
9
  "@mastra/core": "^0.20.2",
15
10
  "@modelcontextprotocol/sdk": "^1.19.1",
16
11
  "@ai-sdk/provider": "^2.0.0",
17
12
  "bidc": "0.0.3",
18
13
  "drizzle-orm": "^0.44.5",
14
+ "hono": "^4.10.7",
19
15
  "jose": "^6.0.11",
20
16
  "mime-db": "1.52.0",
21
17
  "zod": "^3.25.76",
22
18
  "zod-from-json-schema": "^0.0.5",
23
19
  "zod-to-json-schema": "3.25.0"
24
20
  },
25
- "main": "./dist/index.js",
26
- "types": "./dist/index.d.ts",
27
- "files": [
28
- "dist/**/*",
29
- "src/**/*",
30
- "config-schema.json"
31
- ],
32
21
  "exports": {
33
- ".": {
34
- "source": "./src/index.ts",
35
- "types": "./dist/index.d.ts",
36
- "default": "./dist/index.js"
37
- },
38
- "./proxy": {
39
- "source": "./src/proxy.ts",
40
- "types": "./dist/proxy.d.ts",
41
- "default": "./dist/proxy.js"
42
- },
43
- "./admin": {
44
- "source": "./src/admin.ts",
45
- "types": "./dist/admin.d.ts",
46
- "default": "./dist/admin.js"
47
- },
48
- "./client": {
49
- "source": "./src/client.ts",
50
- "types": "./dist/client.d.ts",
51
- "default": "./dist/client.js"
52
- },
53
- "./mastra": {
54
- "source": "./src/mastra.ts",
55
- "types": "./dist/mastra.d.ts",
56
- "default": "./dist/mastra.js"
57
- },
58
- "./drizzle": {
59
- "source": "./src/drizzle.ts",
60
- "types": "./dist/drizzle.d.ts",
61
- "default": "./dist/drizzle.js"
62
- },
63
- "./d1": {
64
- "source": "./src/d1-store.ts",
65
- "types": "./dist/d1-store.d.ts",
66
- "default": "./dist/d1-store.js"
67
- },
68
- "./resources": {
69
- "source": "./src/resources.ts",
70
- "types": "./dist/resources.d.ts",
71
- "default": "./dist/resources.js"
72
- },
73
- "./views": {
74
- "source": "./src/views.ts",
75
- "types": "./dist/views.d.ts",
76
- "default": "./dist/views.js"
77
- },
78
- "./mcp-client": {
79
- "source": "./src/mcp-client.ts",
80
- "types": "./dist/mcp-client.d.ts",
81
- "default": "./dist/mcp-client.js"
82
- },
83
- "./bindings": {
84
- "source": "./src/bindings/index.ts",
85
- "types": "./dist/bindings/index.d.ts",
86
- "default": "./dist/bindings/index.js"
87
- },
88
- "./deconfig": {
89
- "source": "./src/bindings/deconfig/index.ts",
90
- "types": "./dist/bindings/deconfig/index.d.ts",
91
- "default": "./dist/bindings/deconfig/index.js"
92
- }
22
+ ".": "./src/index.ts",
23
+ "./proxy": "./src/proxy.ts",
24
+ "./admin": "./src/admin.ts",
25
+ "./client": "./src/client.ts",
26
+ "./mastra": "./src/mastra.ts",
27
+ "./drizzle": "./src/drizzle.ts",
28
+ "./resources": "./src/resources.ts",
29
+ "./views": "./src/views.ts",
30
+ "./mcp-client": "./src/mcp-client.ts",
31
+ "./bindings": "./src/bindings/index.ts",
32
+ "./deconfig": "./src/bindings/deconfig/index.ts",
33
+ "./asset-server": "./src/asset-server/index.ts"
93
34
  },
94
35
  "devDependencies": {
95
36
  "@types/mime-db": "^1.43.6",
96
- "ts-json-schema-generator": "^2.4.0",
97
- "tsup": "^8.5.0",
98
- "typescript": "^5.9.3"
37
+ "ts-json-schema-generator": "^2.4.0"
99
38
  },
100
39
  "engines": {
101
40
  "node": ">=24.0.0"
@@ -0,0 +1,24 @@
1
+ // heavily inspired by https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/scripts/generate-json-schema.ts
2
+ import { writeFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { createGenerator } from "ts-json-schema-generator";
5
+ import type { Config, Schema } from "ts-json-schema-generator";
6
+
7
+ const config: Config = {
8
+ path: join(import.meta.dirname!, "../src/wrangler.ts"),
9
+ type: "WranglerConfig",
10
+ skipTypeCheck: true,
11
+ };
12
+
13
+ const applyFormattingRules = (schema: Schema) => {
14
+ return { ...schema, allowTrailingCommas: true };
15
+ };
16
+
17
+ const schema = applyFormattingRules(
18
+ createGenerator(config).createSchema(config.type),
19
+ );
20
+
21
+ writeFileSync(
22
+ join(import.meta.dirname!, "../config-schema.json"),
23
+ JSON.stringify(schema, null, 2),
24
+ );
@@ -0,0 +1,16 @@
1
+ import { proxy } from "hono/proxy";
2
+ import { Context } from "hono";
3
+
4
+ export const devServerProxy = (url: string | URL) => (c: Context) => {
5
+ const incomingUrl = new URL(c.req.raw.url);
6
+ const target = new URL(url);
7
+ target.pathname = incomingUrl.pathname;
8
+ target.search = incomingUrl.search;
9
+
10
+ return proxy(target, {
11
+ raw: c.req.raw,
12
+ headers: {
13
+ ...c.req.raw.headers,
14
+ },
15
+ });
16
+ };
@@ -0,0 +1,44 @@
1
+ import { serveStatic } from "hono/bun";
2
+ import { Hono } from "hono";
3
+ import { devServerProxy } from "./dev-server-proxy";
4
+ import { Handler } from "hono/types";
5
+
6
+ interface AssetServerConfig {
7
+ env: "development" | "production" | "test";
8
+ localDevProxyUrl?: string | URL;
9
+ assetsDirectory?: string;
10
+ }
11
+
12
+ const DEFAULT_LOCAL_DEV_PROXY_URL = "http://localhost:4000";
13
+ const DEFAULT_ASSETS_DIRECTORY = "./dist/client";
14
+
15
+ interface HonoApp {
16
+ use: (path: string, handler: Handler) => void;
17
+ get: (path: string, handler: Handler) => void;
18
+ }
19
+
20
+ export const applyAssetServerRoutes = (
21
+ app: HonoApp,
22
+ config: AssetServerConfig,
23
+ ) => {
24
+ const environment = config.env;
25
+ const localDevProxyUrl =
26
+ config.localDevProxyUrl ?? DEFAULT_LOCAL_DEV_PROXY_URL;
27
+ const assetsDirectory = config.assetsDirectory ?? DEFAULT_ASSETS_DIRECTORY;
28
+
29
+ if (environment === "development") {
30
+ app.use("*", devServerProxy(localDevProxyUrl));
31
+ } else if (environment === "production") {
32
+ app.use("/assets/*", serveStatic({ root: assetsDirectory }));
33
+ app.get("*", serveStatic({ path: `${assetsDirectory}/index.html` }));
34
+ }
35
+ };
36
+
37
+ export const createAssetServer = (config: AssetServerConfig) => {
38
+ const app = new Hono();
39
+ applyAssetServerRoutes(app, config);
40
+ return app;
41
+ };
42
+
43
+ export const createAssetServerFetcher = (config: AssetServerConfig) =>
44
+ createAssetServer(config).fetch;
@@ -78,7 +78,7 @@ To create a new binding:
78
78
  input/output:
79
79
 
80
80
  ```ts
81
- import { z } from "zod/v3";
81
+ import { z } from "zod";
82
82
  import type { Binder } from "../index.ts";
83
83
 
84
84
  const myInputSchema = z.object({ ... });
@@ -1,5 +1,5 @@
1
1
  /* oxlint-disable no-explicit-any */
2
- import { z } from "zod/v3";
2
+ import { z } from "zod";
3
3
  import type { MCPConnection } from "../connection.ts";
4
4
  import { createPrivateTool, createStreamableTool } from "../mastra.ts";
5
5
  import {
@@ -1,4 +1,4 @@
1
- import { z } from "zod/v3";
1
+ import { z } from "zod";
2
2
  import type { ToolBinder } from "../mcp.ts";
3
3
 
4
4
  const callbacksSchema = z.object({
@@ -103,7 +103,9 @@ export const createDeconfigResource = <
103
103
  });
104
104
 
105
105
  // Filter files that end with .json
106
- const allFiles = Object.entries(filesList.files)
106
+ const allFiles = Object.entries(
107
+ (filesList as { files: Record<string, unknown> }).files,
108
+ )
107
109
  .filter(([path]) => path.endsWith(".json"))
108
110
  .map(([path, metadata]) => ({
109
111
  path,
@@ -189,8 +191,20 @@ export const createDeconfigResource = <
189
191
  aValue = getMetadataString(a.metadata, "description") || "";
190
192
  bValue = getMetadataString(b.metadata, "description") || "";
191
193
  } else {
192
- aValue = a.metadata.mtime;
193
- bValue = b.metadata.mtime;
194
+ aValue =
195
+ typeof a.metadata === "object" &&
196
+ a.metadata &&
197
+ "mtime" in a.metadata &&
198
+ typeof a.metadata.mtime === "number"
199
+ ? a.metadata.mtime
200
+ : 0;
201
+ bValue =
202
+ typeof b.metadata === "object" &&
203
+ b.metadata &&
204
+ "mtime" in b.metadata &&
205
+ typeof b.metadata.mtime === "number"
206
+ ? b.metadata.mtime
207
+ : 0;
194
208
  }
195
209
 
196
210
  if (sortOrder === "desc") {
@@ -226,11 +240,17 @@ export const createDeconfigResource = <
226
240
  uri,
227
241
  data: { name, description },
228
242
  created_at:
229
- "ctime" in metadata && typeof metadata.ctime === "number"
243
+ typeof metadata === "object" &&
244
+ metadata &&
245
+ "ctime" in metadata &&
246
+ typeof metadata.ctime === "number"
230
247
  ? new Date(metadata.ctime).toISOString()
231
248
  : undefined,
232
249
  updated_at:
233
- "mtime" in metadata && typeof metadata.mtime === "number"
250
+ typeof metadata === "object" &&
251
+ metadata &&
252
+ "mtime" in metadata &&
253
+ typeof metadata.mtime === "number"
234
254
  ? new Date(metadata.mtime).toISOString()
235
255
  : undefined,
236
256
  created_by: getMetadataString(metadata, "createdBy"),
@@ -264,12 +284,16 @@ export const createDeconfigResource = <
264
284
  const filePath = ResourcePath.build(directory, resourceId);
265
285
 
266
286
  try {
267
- const fileData = await deconfig.READ_FILE({
287
+ const fileData = (await deconfig.READ_FILE({
268
288
  path: filePath,
269
289
  format: "plainString",
270
- });
290
+ })) as {
291
+ content: string;
292
+ ctime: number;
293
+ mtime: number;
294
+ };
271
295
 
272
- const content = fileData.content as string;
296
+ const content = fileData.content;
273
297
 
274
298
  // Parse the JSON content
275
299
  let parsedData: Record<string, unknown> = {};
@@ -285,8 +309,14 @@ export const createDeconfigResource = <
285
309
  return {
286
310
  uri,
287
311
  data: validatedData,
288
- created_at: new Date(fileData.ctime).toISOString(),
289
- updated_at: new Date(fileData.mtime).toISOString(),
312
+ created_at:
313
+ typeof fileData.ctime === "number"
314
+ ? new Date(fileData.ctime).toISOString()
315
+ : new Date().toISOString(),
316
+ updated_at:
317
+ typeof fileData.mtime === "number"
318
+ ? new Date(fileData.mtime).toISOString()
319
+ : new Date().toISOString(),
290
320
  created_by:
291
321
  parsedData &&
292
322
  "created_by" in parsedData &&
@@ -347,7 +377,7 @@ export const createDeconfigResource = <
347
377
  };
348
378
 
349
379
  const fileContent = JSON.stringify(resourceData, null, 2);
350
- const putResult = await deconfig.PUT_FILE({
380
+ const putResult = (await deconfig.PUT_FILE({
351
381
  path: filePath,
352
382
  content: fileContent,
353
383
  metadata: {
@@ -357,7 +387,7 @@ export const createDeconfigResource = <
357
387
  name: validatedData.name || resourceId,
358
388
  description: validatedData.description || "",
359
389
  },
360
- });
390
+ })) as { conflict?: boolean };
361
391
 
362
392
  if (putResult.conflict) {
363
393
  throw new UserInputError(
@@ -393,11 +423,11 @@ export const createDeconfigResource = <
393
423
  // Read existing file to get current data
394
424
  let existingData: Record<string, unknown> = {};
395
425
  try {
396
- const fileData = await deconfig.READ_FILE({
426
+ const fileData = (await deconfig.READ_FILE({
397
427
  path: filePath,
398
428
  format: "plainString",
399
- });
400
- existingData = JSON.parse(fileData.content as string);
429
+ })) as { content: string };
430
+ existingData = JSON.parse(fileData.content);
401
431
  } catch {
402
432
  throw new NotFoundError(`Resource not found: ${uri}`);
403
433
  }
@@ -429,7 +459,7 @@ export const createDeconfigResource = <
429
459
 
430
460
  const fileContent = JSON.stringify(updatedData, null, 2);
431
461
 
432
- const putResult = await deconfig.PUT_FILE({
462
+ const putResult = (await deconfig.PUT_FILE({
433
463
  path: filePath,
434
464
  content: fileContent,
435
465
  metadata: {
@@ -439,7 +469,7 @@ export const createDeconfigResource = <
439
469
  name: validatedData.name || resourceId,
440
470
  description: validatedData.description || "",
441
471
  },
442
- });
472
+ })) as { conflict?: boolean };
443
473
 
444
474
  if (putResult.conflict) {
445
475
  throw new UserInputError(
@@ -1,5 +1,5 @@
1
1
  // Types for DeconfigResource
2
- import { z } from "zod/v3";
2
+ import { z } from "zod";
3
3
  import type { DefaultEnv } from "../../index.ts";
4
4
  import type { MCPClientFetchStub, ToolBinder } from "../../mcp.ts";
5
5
  import type { BaseResourceDataSchema } from "../resources/bindings.ts";
@@ -42,10 +42,13 @@ export const createProvider = (binding: LLMBindingClient): Provider => {
42
42
  return await binding.COLLECTION_LLM_LIST({});
43
43
  },
44
44
  languageModel: (modelId: string): LanguageModelV2 => {
45
- const supportedUrls = lazy(() =>
46
- binding
47
- .LLM_METADATA({ modelId })
48
- .then((metadata) => toRegExp(metadata.supportedUrls)),
45
+ const supportedUrls = lazy(
46
+ (): Promise<Record<string, RegExp[]>> =>
47
+ binding
48
+ .LLM_METADATA({ modelId })
49
+ .then((metadata: { supportedUrls: Record<string, string[]> }) =>
50
+ toRegExp(metadata.supportedUrls),
51
+ ),
49
52
  );
50
53
 
51
54
  return {
@@ -1,4 +1,4 @@
1
- import { z } from "zod/v3";
1
+ import { z } from "zod";
2
2
  import type { ToolBinder } from "../../mcp.ts";
3
3
  import {
4
4
  createCreateInputSchema,
@@ -1,4 +1,4 @@
1
- import { z } from "zod/v3";
1
+ import { z } from "zod";
2
2
 
3
3
  /**
4
4
  * Resources 2.0 Schemas
@@ -1,5 +1,5 @@
1
1
  import { ViewsListOutputSchema } from "../views.ts";
2
- import { z } from "zod/v3";
2
+ import { z } from "zod";
3
3
  import type { ToolBinder } from "../mcp.ts";
4
4
 
5
5
  export const VIEW_BINDING = [
package/src/bindings.ts CHANGED
@@ -63,8 +63,9 @@ type WorkspaceClientContext = Omit<
63
63
  >;
64
64
  export const workspaceClient = (
65
65
  ctx: WorkspaceClientContext,
66
+ decocmsApiUrl?: string,
66
67
  ): ReturnType<(typeof MCPClient)["forWorkspace"]> => {
67
- return MCPClient.forWorkspace(ctx.workspace, ctx.token);
68
+ return MCPClient.forWorkspace(ctx.workspace, ctx.token, decocmsApiUrl);
68
69
  };
69
70
 
70
71
  const mcpClientForAppName = (appName: string, decoChatApiUrl?: string) => {
@@ -76,7 +77,7 @@ const mcpClientForAppName = (appName: string, decoChatApiUrl?: string) => {
76
77
  }),
77
78
  };
78
79
 
79
- return MCPClient.forConnection(mcpConnection);
80
+ return MCPClient.forConnection(mcpConnection, decoChatApiUrl);
80
81
  };
81
82
 
82
83
  export const proxyConnectionForId = (
@@ -85,7 +86,7 @@ export const proxyConnectionForId = (
85
86
  token?: string;
86
87
  cookie?: string;
87
88
  },
88
- decoChatApiUrl?: string,
89
+ decocmsApiUrl?: string,
89
90
  appName?: string,
90
91
  ): MCPConnection => {
91
92
  let headers: Record<string, string> | undefined = appName
@@ -100,7 +101,7 @@ export const proxyConnectionForId = (
100
101
  url: createIntegrationsUrl({
101
102
  integrationId,
102
103
  workspace: ctx.workspace,
103
- decoCmsApiUrl: decoChatApiUrl,
104
+ decoCmsApiUrl: decocmsApiUrl,
104
105
  branch: ctx.branch,
105
106
  }),
106
107
  token: ctx.token,
@@ -110,18 +111,18 @@ export const proxyConnectionForId = (
110
111
  const mcpClientForIntegrationId = (
111
112
  integrationId: string,
112
113
  ctx: WorkspaceClientContext,
113
- decoChatApiUrl?: string,
114
+ decocmsApiUrl?: string,
114
115
  appName?: string,
115
116
  ) => {
116
117
  const mcpConnection = proxyConnectionForId(
117
118
  integrationId,
118
119
  ctx,
119
- decoChatApiUrl,
120
+ decocmsApiUrl,
120
121
  appName,
121
122
  );
122
123
 
123
124
  // TODO(@igorbrasileiro): Switch this proxy to be a proxy that call MCP Client.toolCall from @modelcontextprotocol
124
- return MCPClient.forConnection(mcpConnection);
125
+ return MCPClient.forConnection(mcpConnection, decocmsApiUrl);
125
126
  };
126
127
 
127
128
  function mcpClientFromState(
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /* oxlint-disable no-explicit-any */
2
2
  import type { ExecutionContext } from "@cloudflare/workers-types";
3
3
  import { decodeJwt } from "jose";
4
- import type { z } from "zod/v3";
4
+ import type { z } from "zod";
5
5
  import {
6
6
  getReqToken,
7
7
  handleAuthCallback,
@@ -15,7 +15,6 @@ import {
15
15
  } from "./bindings.ts";
16
16
  import { DeconfigResource } from "./bindings/deconfig/index.ts";
17
17
  import { DECO_MCP_CLIENT_HEADER } from "./client.ts";
18
- import { DeprecatedEnv } from "./deprecated.ts";
19
18
  import {
20
19
  createMCPServer,
21
20
  type CreateMCPServerOptions,
@@ -23,8 +22,6 @@ import {
23
22
  } from "./mastra.ts";
24
23
  import { MCPClient, type QueryResult } from "./mcp.ts";
25
24
  import { State } from "./state.ts";
26
- import type { WorkflowDO } from "./workflow.ts";
27
- import { Workflow } from "./workflow.ts";
28
25
  import type { Binding, ContractBinding, MCPBinding } from "./wrangler.ts";
29
26
  export { proxyConnectionForId } from "./bindings.ts";
30
27
  export {
@@ -39,8 +36,7 @@ export interface WorkspaceDB {
39
36
  }) => Promise<{ result: QueryResult[] }>;
40
37
  }
41
38
 
42
- export interface DefaultEnv<TSchema extends z.ZodTypeAny = any>
43
- extends DeprecatedEnv<TSchema> {
39
+ export interface DefaultEnv<TSchema extends z.ZodTypeAny = any> {
44
40
  DECO_REQUEST_CONTEXT: RequestContext<TSchema>;
45
41
  DECO_APP_NAME: string;
46
42
  DECO_APP_SLUG: string;
@@ -51,7 +47,6 @@ export interface DefaultEnv<TSchema extends z.ZodTypeAny = any>
51
47
  DECO_APP_DEPLOYMENT_ID: string;
52
48
  DECO_BINDINGS: string;
53
49
  DECO_API_TOKEN: string;
54
- DECO_WORKFLOW_DO: DurableObjectNamespace<WorkflowDO>;
55
50
  DECO_WORKSPACE_DB: WorkspaceDB & {
56
51
  forContext: (ctx: RequestContext) => WorkspaceDB;
57
52
  };
@@ -144,9 +139,9 @@ const withDefaultBindings = ({
144
139
  ctx: RequestContext;
145
140
  url?: string;
146
141
  }) => {
147
- const client = workspaceClient(ctx);
142
+ const client = workspaceClient(ctx, env.DECO_API_URL);
148
143
  const createWorkspaceDB = (ctx: RequestContext): WorkspaceDB => {
149
- const client = workspaceClient(ctx);
144
+ const client = workspaceClient(ctx, env.DECO_API_URL);
150
145
  return {
151
146
  query: ({ sql, params }) => {
152
147
  return client.DATABASES_RUN_SQL({
@@ -183,11 +178,6 @@ const withDefaultBindings = ({
183
178
  env["DECO_WORKSPACE_API"] = client;
184
179
  env["DECO_WORKSPACE_DB"] = workspaceDbBinding;
185
180
 
186
- // Backwards compatibility
187
- env["DECO_CHAT_API"] = MCPClient;
188
- env["DECO_CHAT_WORKSPACE_API"] = client;
189
- env["DECO_CHAT_WORKSPACE_DB"] = workspaceDbBinding;
190
-
191
181
  env["IS_LOCAL"] =
192
182
  (url?.startsWith("http://localhost") ||
193
183
  url?.startsWith("http://127.0.0.1")) ??
@@ -277,8 +267,6 @@ export const withBindings = <TEnv>({
277
267
  }
278
268
 
279
269
  env.DECO_REQUEST_CONTEXT = context;
280
- // Backwards compatibility
281
- env.DECO_CHAT_REQUEST_CONTEXT = context;
282
270
  const bindings = WorkersMCPBindings.parse(env.DECO_BINDINGS);
283
271
 
284
272
  for (const binding of bindings) {
@@ -297,9 +285,7 @@ export const withBindings = <TEnv>({
297
285
 
298
286
  export const withRuntime = <TEnv, TSchema extends z.ZodTypeAny = never>(
299
287
  userFns: UserDefaultExport<TEnv, TSchema>,
300
- ): ExportedHandler<TEnv & DefaultEnv<TSchema>> & {
301
- Workflow: ReturnType<typeof Workflow>;
302
- } => {
288
+ ): ExportedHandler<TEnv & DefaultEnv<TSchema>> => {
303
289
  const server = createMCPServer<TEnv, TSchema>(userFns);
304
290
  const fetcher = async (
305
291
  req: Request,
@@ -357,7 +343,6 @@ export const withRuntime = <TEnv, TSchema extends z.ZodTypeAny = never>(
357
343
  );
358
344
  };
359
345
  return {
360
- Workflow: Workflow(server, userFns.workflows),
361
346
  fetch: async (
362
347
  req: Request,
363
348
  env: TEnv & DefaultEnv<TSchema>,