@mastra/deployer-cloudflare 0.0.0-message-ordering-20250415215612 → 0.0.0-remove-cloud-span-transform-20250425214156

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.
@@ -29,8 +29,8 @@ export declare class CloudflareDeployer extends Deployer {
29
29
  writeFiles(outputDirectory: string): Promise<void>;
30
30
  private getEntry;
31
31
  prepare(outputDirectory: string): Promise<void>;
32
- getBundlerOptions(serverFile: string, mastraEntryFile: string, analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>): Promise<InputOptions>;
33
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
32
+ getBundlerOptions(serverFile: string, mastraEntryFile: string, analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>, toolsPaths: string[]): Promise<InputOptions>;
33
+ bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
34
34
  deploy(outputDirectory: string): Promise<void>;
35
35
  tagWorker({ workerName, namespace, tags, scope, }: {
36
36
  scope: string;
@@ -29,8 +29,8 @@ export declare class CloudflareDeployer extends Deployer {
29
29
  writeFiles(outputDirectory: string): Promise<void>;
30
30
  private getEntry;
31
31
  prepare(outputDirectory: string): Promise<void>;
32
- getBundlerOptions(serverFile: string, mastraEntryFile: string, analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>): Promise<InputOptions>;
33
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
32
+ getBundlerOptions(serverFile: string, mastraEntryFile: string, analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>, toolsPaths: string[]): Promise<InputOptions>;
33
+ bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
34
34
  deploy(outputDirectory: string): Promise<void>;
35
35
  tagWorker({ workerName, namespace, tags, scope, }: {
36
36
  scope: string;
package/dist/index.cjs CHANGED
@@ -59,24 +59,71 @@ var CloudflareDeployer = class extends deployer.Deployer {
59
59
  }
60
60
  getEntry() {
61
61
  return `
62
- import '#polyfills';
63
- import { mastra } from '#mastra';
64
- import { createHonoServer } from '#server';
62
+ import '#polyfills';
63
+ import { mastra } from '#mastra';
64
+ import { createHonoServer } from '#server';
65
+ import { evaluate } from '@mastra/core/eval';
66
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
67
+ import { TABLE_EVALS } from '@mastra/core/storage';
68
+ import { checkEvalStorageFields } from '@mastra/core/utils';
65
69
 
66
- export default {
67
- fetch: async (request, env, context) => {
68
- const app = await createHonoServer(mastra)
69
- return app.fetch(request, env, context);
70
- }
71
- }
70
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
71
+ evaluate({
72
+ agentName,
73
+ input,
74
+ metric,
75
+ output,
76
+ runId,
77
+ globalRunId: runId,
78
+ instructions,
79
+ });
80
+ });
81
+
82
+ if (mastra.getStorage()) {
83
+ // start storage init in the background
84
+ mastra.getStorage().init();
85
+ }
86
+
87
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
88
+ const storage = mastra.getStorage();
89
+ if (storage) {
90
+ // Check for required fields
91
+ const logger = mastra?.getLogger();
92
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
93
+ if (!areFieldsValid) return;
94
+
95
+ await storage.insert({
96
+ tableName: TABLE_EVALS,
97
+ record: {
98
+ input: traceObject.input,
99
+ output: traceObject.output,
100
+ result: JSON.stringify(traceObject.result || {}),
101
+ agent_name: traceObject.agentName,
102
+ metric_name: traceObject.metricName,
103
+ instructions: traceObject.instructions,
104
+ test_info: null,
105
+ global_run_id: traceObject.globalRunId,
106
+ run_id: traceObject.runId,
107
+ created_at: new Date().toISOString(),
108
+ },
109
+ });
110
+ }
111
+ });
112
+
113
+ export default {
114
+ fetch: async (request, env, context) => {
115
+ const app = await createHonoServer(mastra)
116
+ return app.fetch(request, env, context);
117
+ }
118
+ }
72
119
  `;
73
120
  }
74
121
  async prepare(outputDirectory) {
75
122
  await super.prepare(outputDirectory);
76
123
  await this.writeFiles(outputDirectory);
77
124
  }
78
- async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo) {
79
- const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo);
125
+ async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths) {
126
+ const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths);
80
127
  if (Array.isArray(inputOptions.plugins)) {
81
128
  inputOptions.plugins = [
82
129
  virtual__default.default({
@@ -90,8 +137,8 @@ process.versions.node = '${process.versions.node}';
90
137
  }
91
138
  return inputOptions;
92
139
  }
93
- async bundle(entryFile, outputDirectory) {
94
- return this._bundle(this.getEntry(), entryFile, outputDirectory);
140
+ async bundle(entryFile, outputDirectory, toolsPaths) {
141
+ return this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
95
142
  }
96
143
  async deploy(outputDirectory) {
97
144
  const cmd = this.workerNamespace ? `npm exec -- wrangler@latest deploy --dispatch-namespace ${this.workerNamespace}` : "npm exec -- wrangler@latest deploy";
package/dist/index.js CHANGED
@@ -53,24 +53,71 @@ var CloudflareDeployer = class extends Deployer {
53
53
  }
54
54
  getEntry() {
55
55
  return `
56
- import '#polyfills';
57
- import { mastra } from '#mastra';
58
- import { createHonoServer } from '#server';
56
+ import '#polyfills';
57
+ import { mastra } from '#mastra';
58
+ import { createHonoServer } from '#server';
59
+ import { evaluate } from '@mastra/core/eval';
60
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
61
+ import { TABLE_EVALS } from '@mastra/core/storage';
62
+ import { checkEvalStorageFields } from '@mastra/core/utils';
59
63
 
60
- export default {
61
- fetch: async (request, env, context) => {
62
- const app = await createHonoServer(mastra)
63
- return app.fetch(request, env, context);
64
- }
65
- }
64
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
65
+ evaluate({
66
+ agentName,
67
+ input,
68
+ metric,
69
+ output,
70
+ runId,
71
+ globalRunId: runId,
72
+ instructions,
73
+ });
74
+ });
75
+
76
+ if (mastra.getStorage()) {
77
+ // start storage init in the background
78
+ mastra.getStorage().init();
79
+ }
80
+
81
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
82
+ const storage = mastra.getStorage();
83
+ if (storage) {
84
+ // Check for required fields
85
+ const logger = mastra?.getLogger();
86
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
87
+ if (!areFieldsValid) return;
88
+
89
+ await storage.insert({
90
+ tableName: TABLE_EVALS,
91
+ record: {
92
+ input: traceObject.input,
93
+ output: traceObject.output,
94
+ result: JSON.stringify(traceObject.result || {}),
95
+ agent_name: traceObject.agentName,
96
+ metric_name: traceObject.metricName,
97
+ instructions: traceObject.instructions,
98
+ test_info: null,
99
+ global_run_id: traceObject.globalRunId,
100
+ run_id: traceObject.runId,
101
+ created_at: new Date().toISOString(),
102
+ },
103
+ });
104
+ }
105
+ });
106
+
107
+ export default {
108
+ fetch: async (request, env, context) => {
109
+ const app = await createHonoServer(mastra)
110
+ return app.fetch(request, env, context);
111
+ }
112
+ }
66
113
  `;
67
114
  }
68
115
  async prepare(outputDirectory) {
69
116
  await super.prepare(outputDirectory);
70
117
  await this.writeFiles(outputDirectory);
71
118
  }
72
- async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo) {
73
- const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo);
119
+ async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths) {
120
+ const inputOptions = await super.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths);
74
121
  if (Array.isArray(inputOptions.plugins)) {
75
122
  inputOptions.plugins = [
76
123
  virtual({
@@ -84,8 +131,8 @@ process.versions.node = '${process.versions.node}';
84
131
  }
85
132
  return inputOptions;
86
133
  }
87
- async bundle(entryFile, outputDirectory) {
88
- return this._bundle(this.getEntry(), entryFile, outputDirectory);
134
+ async bundle(entryFile, outputDirectory, toolsPaths) {
135
+ return this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
89
136
  }
90
137
  async deploy(outputDirectory) {
91
138
  const cmd = this.workerNamespace ? `npm exec -- wrangler@latest deploy --dispatch-namespace ${this.workerNamespace}` : "npm exec -- wrangler@latest deploy";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-cloudflare",
3
- "version": "0.0.0-message-ordering-20250415215612",
3
+ "version": "0.0.0-remove-cloud-span-transform-20250425214156",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -35,16 +35,14 @@
35
35
  "author": "",
36
36
  "license": "Elastic-2.0",
37
37
  "dependencies": {
38
+ "@babel/core": "^7.26.10",
38
39
  "@rollup/plugin-virtual": "^3.0.2",
39
40
  "cloudflare": "^4.1.0",
40
- "date-fns": "^4.1.0",
41
- "execa": "^9.5.2",
42
- "rollup-plugin-polyfill-node": "^0.13.0",
43
- "rollup-plugin-shim": "^1.0.0",
41
+ "rollup": "^4.35.0",
44
42
  "wrangler": "^4.4.0",
45
43
  "zod": "^3.24.2",
46
- "@mastra/deployer": "0.0.0-message-ordering-20250415215612",
47
- "@mastra/core": "0.0.0-message-ordering-20250415215612"
44
+ "@mastra/deployer": "0.0.0-remove-cloud-span-transform-20250425214156",
45
+ "@mastra/core": "0.0.0-remove-cloud-span-transform-20250425214156"
48
46
  },
49
47
  "devDependencies": {
50
48
  "@microsoft/api-extractor": "^7.52.1",