mastra 0.1.57-unstable.57 → 0.1.57-unstable.88

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 (61) hide show
  1. package/dist/commands/create/create.d.ts +8 -0
  2. package/dist/commands/create/create.d.ts.map +1 -0
  3. package/dist/commands/create/create.js +35 -0
  4. package/dist/commands/create/utils.d.ts +4 -0
  5. package/dist/commands/create/utils.d.ts.map +1 -0
  6. package/dist/commands/create/utils.js +58 -0
  7. package/dist/commands/deploy/cloudflare/index.d.ts.map +1 -1
  8. package/dist/commands/deploy/cloudflare/index.js +2 -0
  9. package/dist/commands/deploy/netlify/index.d.ts.map +1 -1
  10. package/dist/commands/deploy/netlify/index.js +2 -0
  11. package/dist/commands/deploy/vercel/index.d.ts.map +1 -1
  12. package/dist/commands/deploy/vercel/index.js +2 -0
  13. package/dist/commands/dev.d.ts.map +1 -1
  14. package/dist/commands/dev.js +97 -10
  15. package/dist/commands/engine/down.d.ts +1 -1
  16. package/dist/commands/engine/down.d.ts.map +1 -1
  17. package/dist/commands/engine/down.js +3 -2
  18. package/dist/commands/engine/up.d.ts +1 -1
  19. package/dist/commands/engine/up.d.ts.map +1 -1
  20. package/dist/commands/engine/up.js +3 -2
  21. package/dist/commands/init/init.d.ts +2 -2
  22. package/dist/commands/init/init.d.ts.map +1 -1
  23. package/dist/commands/init/init.js +33 -9
  24. package/dist/commands/init/utils.d.ts +21 -9
  25. package/dist/commands/init/utils.d.ts.map +1 -1
  26. package/dist/commands/init/utils.js +64 -74
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +54 -56
  30. package/dist/services/service.deps.d.ts +1 -0
  31. package/dist/services/service.deps.d.ts.map +1 -1
  32. package/dist/services/service.deps.js +8 -0
  33. package/dist/services/service.docker.d.ts +1 -0
  34. package/dist/services/service.docker.d.ts.map +1 -1
  35. package/dist/services/service.docker.js +20 -0
  36. package/dist/src/starter-files/config.ts +28 -0
  37. package/dist/src/starter-files/mastra-pg.docker-compose.yaml +15 -0
  38. package/dist/src/starter-files/tools.ts +95 -0
  39. package/dist/src/starter-files/workflow.ts +173 -0
  40. package/dist/templates/express-server.d.ts.map +1 -1
  41. package/dist/templates/express-server.js +30 -31
  42. package/dist/templates/netlify.d.ts.map +1 -1
  43. package/dist/templates/netlify.js +199 -34
  44. package/dist/templates/worker.d.ts.map +1 -1
  45. package/dist/templates/worker.js +255 -35
  46. package/dist/utils/bundle.d.ts +1 -0
  47. package/dist/utils/bundle.d.ts.map +1 -1
  48. package/dist/utils/bundle.js +8 -8
  49. package/package.json +5 -3
  50. package/src/playground/dist/assets/{hcl-Cztwc-HH.js → hcl-_Zu0RE-q.js} +1 -1
  51. package/src/playground/dist/assets/index-BiEU7Tmg.js +389 -0
  52. package/src/playground/dist/assets/{index-Dx4A5Op9.js → index-Cke4BidO.js} +2 -2
  53. package/src/playground/dist/assets/{vue-html-x3hEOujm.js → vue-html-59TQSa_j.js} +1 -1
  54. package/src/playground/dist/assets/vue-srE0XGv_.js +1 -0
  55. package/src/playground/dist/index.html +1 -1
  56. package/src/starter-files/tools.ts +88 -14
  57. package/src/starter-files/workflow.ts +160 -21
  58. package/src/playground/dist/assets/index-DY22QVI1.js +0 -389
  59. package/src/playground/dist/assets/vue-xldAUJov.js +0 -1
  60. package/src/starter-files/api.ts +0 -11
  61. package/src/starter-files/framework-utils.ts +0 -33
@@ -1,8 +1,21 @@
1
1
  import { AutoRouter } from 'itty-router';
2
2
  import { join } from 'path';
3
3
  import { stringify } from 'superjson';
4
+ import { pathToFileURL } from 'url';
4
5
  import zodToJsonSchema from 'zod-to-json-schema';
5
6
  const { mastra } = await import(join(process.cwd(), 'mastra.mjs'));
7
+ const mastraToolsPaths = process.env.MASTRA_TOOLS_PATH;
8
+ const toolImports = mastraToolsPaths
9
+ ? await Promise.all(mastraToolsPaths.split(',').map(async (toolPath) => {
10
+ return import(pathToFileURL(toolPath).href);
11
+ }))
12
+ : [];
13
+ const tools = toolImports.reduce((acc, toolModule) => {
14
+ Object.entries(toolModule).forEach(([key, tool]) => {
15
+ acc[key] = tool;
16
+ });
17
+ return acc;
18
+ }, {});
6
19
  const router = AutoRouter();
7
20
  const validateBody = async (body) => {
8
21
  const errorResponse = Object.entries(body).reduce((acc, [key, value]) => {
@@ -24,7 +37,24 @@ router.get('/', () => {
24
37
  router.get('/api/agents', async () => {
25
38
  try {
26
39
  const agents = mastra.getAgents();
27
- return new Response(JSON.stringify(agents), {
40
+ const serializedAgents = Object.entries(agents).reduce((acc, [_id, _agent]) => {
41
+ const agent = _agent;
42
+ const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc, [key, tool]) => {
43
+ const _tool = tool;
44
+ acc[key] = {
45
+ ..._tool,
46
+ inputSchema: _tool.inputSchema ? stringify(zodToJsonSchema(_tool.inputSchema)) : undefined,
47
+ outputSchema: _tool.outputSchema ? stringify(zodToJsonSchema(_tool.outputSchema)) : undefined,
48
+ };
49
+ return acc;
50
+ }, {});
51
+ acc[_id] = {
52
+ ...agent,
53
+ tools: serializedAgentTools,
54
+ };
55
+ return acc;
56
+ }, {});
57
+ return new Response(JSON.stringify(serializedAgents), {
28
58
  headers: {
29
59
  'Content-Type': 'application/json',
30
60
  },
@@ -45,8 +75,18 @@ router.get('/api/agents/:agentId', ({ params }) => {
45
75
  try {
46
76
  const agentId = decodeURIComponent(params.agentId);
47
77
  const agent = mastra.getAgent(agentId);
78
+ const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc, [key, tool]) => {
79
+ const _tool = tool;
80
+ acc[key] = {
81
+ ..._tool,
82
+ inputSchema: _tool.inputSchema ? stringify(zodToJsonSchema(_tool.inputSchema)) : undefined,
83
+ outputSchema: _tool.outputSchema ? stringify(zodToJsonSchema(_tool.outputSchema)) : undefined,
84
+ };
85
+ return acc;
86
+ }, {});
48
87
  return new Response(JSON.stringify({
49
88
  ...agent,
89
+ tools: serializedAgentTools,
50
90
  }), {
51
91
  headers: {
52
92
  'Content-Type': 'application/json',
@@ -64,12 +104,11 @@ router.get('/api/agents/:agentId', ({ params }) => {
64
104
  });
65
105
  }
66
106
  });
67
- router.post('/api/agents/:agentId/text', async ({ params, json }) => {
107
+ router.post('/api/agents/:agentId/generate', async ({ params, json }) => {
68
108
  try {
69
109
  const agentId = decodeURIComponent(params.agentId);
70
110
  const agent = mastra.getAgent(agentId);
71
- const body = await json();
72
- const messages = body.messages;
111
+ const { messages, threadId, resourceid } = await json();
73
112
  const { ok, errorResponse } = await validateBody({ messages });
74
113
  if (!ok) {
75
114
  return new Response(JSON.stringify({ error: errorResponse }), {
@@ -87,7 +126,7 @@ router.post('/api/agents/:agentId/text', async ({ params, json }) => {
87
126
  },
88
127
  });
89
128
  }
90
- const result = await agent.generate(messages);
129
+ const result = await agent.generate(messages, { threadId, resourceid });
91
130
  return new Response(JSON.stringify(result), {
92
131
  headers: {
93
132
  'Content-Type': 'application/json',
@@ -109,8 +148,7 @@ router.post('/api/agents/:agentId/stream', async ({ params, json }) => {
109
148
  try {
110
149
  const agentId = decodeURIComponent(params.agentId);
111
150
  const agent = mastra.getAgent(agentId);
112
- const body = await json();
113
- const messages = body.messages;
151
+ const { messages, threadId, resourceid } = await json();
114
152
  const { ok, errorResponse } = await validateBody({ messages });
115
153
  if (!ok) {
116
154
  return new Response(JSON.stringify({ error: errorResponse }), {
@@ -128,7 +166,7 @@ router.post('/api/agents/:agentId/stream', async ({ params, json }) => {
128
166
  },
129
167
  });
130
168
  }
131
- const streamResult = await agent.generate(messages, { stream: true });
169
+ const streamResult = await agent.stream(messages, { threadId, resourceid });
132
170
  return streamResult.toDataStreamResponse({
133
171
  headers: {
134
172
  'Content-Type': 'text/x-unknown',
@@ -152,9 +190,7 @@ router.post('/api/agents/:agentId/text-object', async ({ params, json }) => {
152
190
  try {
153
191
  const agentId = decodeURIComponent(params.agentId);
154
192
  const agent = mastra.getAgent(agentId);
155
- const body = await json();
156
- const messages = body.messages;
157
- const schema = body.schema;
193
+ const { messages, schema, threadId, resourceid } = await json();
158
194
  const { ok, errorResponse } = await validateBody({
159
195
  messages,
160
196
  schema,
@@ -175,7 +211,7 @@ router.post('/api/agents/:agentId/text-object', async ({ params, json }) => {
175
211
  },
176
212
  });
177
213
  }
178
- const result = await agent.generate(messages, { schema });
214
+ const result = await agent.generate(messages, { output: schema, threadId, resourceid });
179
215
  return new Response(JSON.stringify(result), {
180
216
  headers: {
181
217
  'Content-Type': 'application/json',
@@ -197,9 +233,7 @@ router.post('/api/agents/:agentId/stream-object', async ({ params, json }) => {
197
233
  try {
198
234
  const agentId = decodeURIComponent(params.agentId);
199
235
  const agent = mastra.getAgent(agentId);
200
- const body = await json();
201
- const messages = body.messages;
202
- const schema = body.schema;
236
+ const { messages, schema, threadId, resourceid } = await json();
203
237
  const { ok, errorResponse } = await validateBody({
204
238
  messages,
205
239
  schema,
@@ -220,7 +254,7 @@ router.post('/api/agents/:agentId/stream-object', async ({ params, json }) => {
220
254
  },
221
255
  });
222
256
  }
223
- const streamResult = await agent.generate(messages, { schema, stream: true });
257
+ const streamResult = await agent.stream(messages, { output: schema, threadId, resourceid });
224
258
  return streamResult.toTextStreamResponse({
225
259
  headers: {
226
260
  'Content-Type': 'text/x-unknown',
@@ -240,9 +274,40 @@ router.post('/api/agents/:agentId/stream-object', async ({ params, json }) => {
240
274
  });
241
275
  }
242
276
  });
277
+ router.post('/api/agents/:agentId/tools/:toolId/execute', async ({ params, json }) => {
278
+ try {
279
+ const agentId = decodeURIComponent(params.agentId);
280
+ const toolId = decodeURIComponent(params.toolId);
281
+ const agent = mastra.getAgent(agentId);
282
+ const tool = Object.values(agent?.tools || {}).find((tool) => tool.id === toolId);
283
+ const body = await json();
284
+ const result = await tool.execute({
285
+ context: {
286
+ ...body,
287
+ },
288
+ mastra,
289
+ runId: agentId,
290
+ });
291
+ return new Response(JSON.stringify(result), {
292
+ headers: {
293
+ 'Content-Type': 'application/json',
294
+ },
295
+ });
296
+ }
297
+ catch (error) {
298
+ const apiError = error;
299
+ console.error('Error executing tool', apiError);
300
+ return new Response(JSON.stringify({ error: apiError.message || 'Error executing tool' }), {
301
+ status: apiError.status || 500,
302
+ headers: {
303
+ 'Content-Type': 'application/json',
304
+ },
305
+ });
306
+ }
307
+ });
243
308
  router.get('/api/workflows', async () => {
244
309
  try {
245
- const workflows = mastra.getWorkflows();
310
+ const workflows = mastra.getWorkflows({ serialized: true });
246
311
  return new Response(JSON.stringify(workflows), {
247
312
  headers: {
248
313
  'Content-Type': 'application/json',
@@ -265,9 +330,23 @@ router.get('/api/workflows/:workflowId', async ({ params }) => {
265
330
  const workflowId = decodeURIComponent(params.workflowId);
266
331
  const workflow = mastra.getWorkflow(workflowId);
267
332
  const triggerSchema = workflow.triggerSchema;
333
+ const stepGraph = workflow.stepGraph;
334
+ const stepSubscriberGraph = workflow.stepSubscriberGraph;
335
+ const serializedSteps = Object.entries(workflow.steps).reduce((acc, [key, step]) => {
336
+ const _step = step;
337
+ acc[key] = {
338
+ ..._step,
339
+ inputSchema: _step.inputSchema ? stringify(zodToJsonSchema(_step.inputSchema)) : undefined,
340
+ outputSchema: _step.outputSchema ? stringify(zodToJsonSchema(_step.outputSchema)) : undefined,
341
+ };
342
+ return acc;
343
+ }, {});
268
344
  return new Response(JSON.stringify({
269
- ...workflow,
345
+ name: workflow.name,
270
346
  triggerSchema: triggerSchema ? stringify(zodToJsonSchema(triggerSchema)) : undefined,
347
+ steps: serializedSteps,
348
+ stepGraph,
349
+ stepSubscriberGraph,
271
350
  }), {
272
351
  headers: {
273
352
  'Content-Type': 'application/json',
@@ -288,9 +367,8 @@ router.get('/api/workflows/:workflowId', async ({ params }) => {
288
367
  router.post('/workflows/:workflowId/execute', async ({ params, json }) => {
289
368
  try {
290
369
  const workflowId = decodeURIComponent(params.workflowId);
291
- const workflow = mastra.workflows.get(workflowId);
370
+ const workflow = mastra.getWorkflow(workflowId);
292
371
  const body = await json();
293
- console.log('body', body);
294
372
  const result = await workflow.execute(body);
295
373
  return new Response(JSON.stringify(result), {
296
374
  headers: {
@@ -309,9 +387,36 @@ router.post('/workflows/:workflowId/execute', async ({ params, json }) => {
309
387
  });
310
388
  }
311
389
  });
312
- router.get('/api/memory/threads/get-by-resourceid/:resourceid', async ({ params }) => {
390
+ router.get('/api/memory/status', async () => {
313
391
  try {
314
- const resourceid = decodeURIComponent(params.resourceid);
392
+ const memory = mastra.memory;
393
+ if (!memory) {
394
+ return new Response(JSON.stringify({ result: false }), {
395
+ headers: {
396
+ 'Content-Type': 'application/json',
397
+ },
398
+ });
399
+ }
400
+ return new Response(JSON.stringify({ result: true }), {
401
+ headers: {
402
+ 'Content-Type': 'application/json',
403
+ },
404
+ });
405
+ }
406
+ catch (error) {
407
+ const apiError = error;
408
+ console.error('Error getting memory status', apiError);
409
+ return new Response(JSON.stringify({ error: apiError.message || 'Error getting memory status' }), {
410
+ status: apiError.status || 500,
411
+ headers: {
412
+ 'Content-Type': 'application/json',
413
+ },
414
+ });
415
+ }
416
+ });
417
+ router.get('/api/memory/threads', async ({ query }) => {
418
+ try {
419
+ const { resourceid } = query;
315
420
  const memory = mastra.memory;
316
421
  if (!memory) {
317
422
  return new Response(JSON.stringify({ error: 'Memory is not initialized' }), {
@@ -586,7 +691,7 @@ router.get('/api/memory/threads/:threadId/context-window', async ({ params, quer
586
691
  router.post('/api/memory/save-messages', async ({ json }) => {
587
692
  try {
588
693
  const memory = mastra.memory;
589
- const messages = await json();
694
+ const { messages } = await json();
590
695
  if (!memory) {
591
696
  return new Response(JSON.stringify({ error: 'Memory is not initialized' }), {
592
697
  status: 400,
@@ -725,18 +830,6 @@ router.post('/api/memory/validate-tool-call-args', async ({ json }) => {
725
830
  });
726
831
  }
727
832
  });
728
- /**
729
- * POST /syncs/{syncId}/execute
730
- * @summary Execute a sync operation
731
- * @tags Sync
732
- * @param {string} syncId.path.required - Sync identifier
733
- * @param {object} request.body.required - Sync parameters
734
- * @param {string} request.body.runId - Run identifier
735
- * @param {object} request.body.params - Sync parameters
736
- * @return {object} 200 - Sync execution result
737
- * @return {Error} 400 - Validation error
738
- * @return {Error} 500 - Server error
739
- */
740
833
  router.post('/api/syncs/:syncId/execute', async ({ params, json }) => {
741
834
  try {
742
835
  const syncId = decodeURIComponent(params.syncId);
@@ -768,6 +861,133 @@ router.post('/api/syncs/:syncId/execute', async ({ params, json }) => {
768
861
  });
769
862
  }
770
863
  });
864
+ router.get('/api/logs', async () => {
865
+ try {
866
+ const logs = await mastra.getLogs();
867
+ return new Response(JSON.stringify(logs), {
868
+ headers: {
869
+ 'Content-Type': 'application/json',
870
+ },
871
+ });
872
+ }
873
+ catch (error) {
874
+ const apiError = error;
875
+ console.error('Error getting logs', apiError);
876
+ return new Response(JSON.stringify({ error: apiError.message || 'Error getting logs' }), {
877
+ status: apiError.status || 500,
878
+ headers: {
879
+ 'Content-Type': 'application/json',
880
+ },
881
+ });
882
+ }
883
+ });
884
+ router.get('/api/logs/:runId', async ({ params }) => {
885
+ try {
886
+ const runId = decodeURIComponent(params.runId);
887
+ const logs = await mastra.getLogsByRunId(runId);
888
+ return new Response(JSON.stringify(logs), {
889
+ headers: {
890
+ 'Content-Type': 'application/json',
891
+ },
892
+ });
893
+ }
894
+ catch (error) {
895
+ const apiError = error;
896
+ console.error('Error getting logs', apiError);
897
+ return new Response(JSON.stringify({ error: apiError.message || 'Error getting logs' }), {
898
+ status: apiError.status || 500,
899
+ headers: {
900
+ 'Content-Type': 'application/json',
901
+ },
902
+ });
903
+ }
904
+ });
905
+ router.get('/api/tools', async () => {
906
+ if (tools) {
907
+ const serializedTools = Object.entries(tools).reduce((acc, [id, _tool]) => {
908
+ const tool = _tool;
909
+ acc[id] = {
910
+ ...tool,
911
+ inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,
912
+ outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,
913
+ };
914
+ return acc;
915
+ }, {});
916
+ return new Response(JSON.stringify(serializedTools), {
917
+ headers: {
918
+ 'Content-Type': 'application/json',
919
+ },
920
+ });
921
+ }
922
+ else {
923
+ return new Response(JSON.stringify({}), {
924
+ headers: {
925
+ 'Content-Type': 'application/json',
926
+ },
927
+ });
928
+ }
929
+ });
930
+ router.get('/api/tools/:toolId', async ({ params }) => {
931
+ const toolId = decodeURIComponent(params.toolId);
932
+ const tool = Object.values(tools || {}).find((tool) => tool.id === toolId);
933
+ if (tool) {
934
+ const serializedTool = {
935
+ ...tool,
936
+ inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,
937
+ outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,
938
+ };
939
+ return new Response(JSON.stringify(serializedTool), {
940
+ headers: {
941
+ 'Content-Type': 'application/json',
942
+ },
943
+ });
944
+ }
945
+ else {
946
+ return new Response(JSON.stringify({ error: 'Tool not found' }), {
947
+ status: 404,
948
+ headers: {
949
+ 'Content-Type': 'application/json',
950
+ },
951
+ });
952
+ }
953
+ });
954
+ router.post('/api/tools/:toolId/execute', async ({ params, json }) => {
955
+ try {
956
+ const toolId = decodeURIComponent(params.toolId);
957
+ const tool = Object.values(tools || {}).find((tool) => tool.id === toolId);
958
+ if (!tool) {
959
+ return new Response(JSON.stringify({ error: 'Tool not found' }), {
960
+ status: 404,
961
+ headers: {
962
+ 'Content-Type': 'application/json',
963
+ },
964
+ });
965
+ }
966
+ const { input } = await json();
967
+ const result = await tool.execute({
968
+ context: {
969
+ ...input,
970
+ },
971
+ mastra,
972
+ runId: mastra.runId,
973
+ });
974
+ return new Response(JSON.stringify(result), {
975
+ headers: {
976
+ 'Content-Type': 'application/json',
977
+ },
978
+ });
979
+ }
980
+ catch (error) {
981
+ const apiError = error;
982
+ console.error('Error executing tool', apiError);
983
+ return new Response(JSON.stringify({ error: apiError.message || 'Error executing tool' }), {
984
+ status: apiError.status || 500,
985
+ headers: {
986
+ 'Content-Type': 'application/json',
987
+ },
988
+ });
989
+ }
990
+ });
771
991
  // 404 handler
772
992
  router.all('*', () => new Response('Not Found', { status: 404 }));
773
993
  export default {
@@ -24,6 +24,7 @@ export declare function bundleServer(entryPoint: string): Promise<esbuild.BuildR
24
24
  export declare function bundle(dirPath: string, options?: {
25
25
  outfile?: string;
26
26
  entryFile?: string;
27
+ buildName?: string;
27
28
  }): Promise<esbuild.BuildResult<{
28
29
  entryPoints: string[];
29
30
  bundle: true;
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/utils/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAanC,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;IA0FpD;AAED,wBAAsB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;IAyG/F"}
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/utils/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAanC,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;IA6FpD;AAED,wBAAsB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;IAuGnH"}
@@ -1,7 +1,7 @@
1
1
  import * as esbuild from 'esbuild';
2
2
  import { join } from 'path';
3
3
  import path from 'path';
4
- import { fileURLToPath, pathToFileURL } from 'url';
4
+ import { fileURLToPath } from 'url';
5
5
  import { upsertMastraDir } from '../commands/deploy/utils.js';
6
6
  import { FileService } from '../services/service.file.js';
7
7
  import { logger } from './logger.js';
@@ -11,12 +11,14 @@ export async function bundleServer(entryPoint) {
11
11
  try {
12
12
  // Ensure .mastra directory exists
13
13
  upsertMastraDir();
14
- // Convert server entry point to file URL
15
- const serverEntryPoint = pathToFileURL(entryPoint).href;
16
14
  const outfile = join(process.cwd(), '.mastra', 'server.mjs');
17
15
  const cliNodeModules = join(path.dirname(path.dirname(__dirname)), 'node_modules');
16
+ if (!cliNodeModules) {
17
+ logger.error('Mastra CLI is not installed. Please run `npm install -g mastra` to install Mastra CLI.');
18
+ process.exit(1);
19
+ }
18
20
  const result = await esbuild.build({
19
- entryPoints: [serverEntryPoint],
21
+ entryPoints: [entryPoint],
20
22
  bundle: true,
21
23
  platform: 'node',
22
24
  format: 'esm',
@@ -100,9 +102,7 @@ export async function bundle(dirPath, options) {
100
102
  // Ensure .mastra directory exists
101
103
  upsertMastraDir();
102
104
  const fileService = new FileService();
103
- const entryPointPath = join(dirPath, `${options?.entryFile || 'index'}.ts`);
104
- // Convert to file URL for ESM imports
105
- const entryPoint = pathToFileURL(fileService.getFirstExistingFile([entryPointPath])).href;
105
+ const entryPoint = fileService.getFirstExistingFile([join(dirPath, `${options?.entryFile || 'index'}.ts`)]);
106
106
  const outfile = options?.outfile || join(process.cwd(), '.mastra', 'mastra.mjs');
107
107
  const result = await esbuild.build({
108
108
  entryPoints: [entryPoint],
@@ -180,7 +180,7 @@ export async function bundle(dirPath, options) {
180
180
  ],
181
181
  });
182
182
  // Log build results
183
- logger.success('Build completed successfully');
183
+ logger.success(`${options?.buildName} Build completed successfully`);
184
184
  // Output build metadata
185
185
  await esbuild.analyzeMetafile(result.metafile);
186
186
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastra",
3
- "version": "0.1.57-unstable.57",
3
+ "version": "0.1.57-unstable.88",
4
4
  "license": "MIT",
5
5
  "description": "cli for mastra",
6
6
  "type": "module",
@@ -44,6 +44,7 @@
44
44
  "@tanstack/react-virtual": "^3.10.4",
45
45
  "@types/figlet": "^1.7.0",
46
46
  "@xyflow/react": "^12.3.6",
47
+ "chokidar": "^4.0.3",
47
48
  "class-variance-authority": "^0.7.1",
48
49
  "clsx": "^2.1.1",
49
50
  "cmdk": "^1.0.0",
@@ -95,7 +96,7 @@
95
96
  "yocto-spinner": "^0.1.1",
96
97
  "zod": "^3.24.1",
97
98
  "zod-to-json-schema": "^3.24.1",
98
- "@mastra/core": "0.1.27-alpha.44"
99
+ "@mastra/core": "0.1.27-alpha.61"
99
100
  },
100
101
  "devDependencies": {
101
102
  "@types/express": "^5.0.0",
@@ -108,6 +109,7 @@
108
109
  "@types/tcp-port-used": "^1.0.4",
109
110
  "@vitejs/plugin-react": "^4.3.4",
110
111
  "autoprefixer": "^10.4.20",
112
+ "cpy-cli": "^5.0.0",
111
113
  "eslint-plugin-react-hooks": "^5.0.0",
112
114
  "eslint-plugin-react-refresh": "^0.4.14",
113
115
  "postcss": "^8.4.49",
@@ -119,7 +121,7 @@
119
121
  "build": "npm-run-all build:tsc copy-starter-files build:playground",
120
122
  "build:tsc": "tsc",
121
123
  "build:dev": "npx tsc --watch",
122
- "copy-starter-files": "cp -r src/starter-files dist/",
124
+ "copy-starter-files": "cpy src/starter-files dist/",
123
125
  "build:playground": "cd src/playground && vite build",
124
126
  "dev:playground": "cd src/playground && vite",
125
127
  "init": "npx tsx src/index.ts init",
@@ -1 +1 @@
1
- const e=Object.freeze(JSON.parse('{"displayName":"HashiCorp HCL","fileTypes":["hcl"],"name":"hcl","patterns":[{"include":"#comments"},{"include":"#attribute_definition"},{"include":"#block"},{"include":"#expressions"}],"repository":{"attribute_access":{"begin":"\\\\.(?!\\\\*)","beginCaptures":{"0":{"name":"keyword.operator.accessor.hcl"}},"comment":"Matches traversal attribute access such as .attr","end":"[A-Za-z][\\\\w-]*|\\\\d*","endCaptures":{"0":{"patterns":[{"comment":"Attribute name","match":"(?!null|false|true)[A-Za-z][\\\\w-]*","name":"variable.other.member.hcl"},{"comment":"Optional attribute index","match":"\\\\d+","name":"constant.numeric.integer.hcl"}]}}},"attribute_definition":{"captures":{"1":{"name":"punctuation.section.parens.begin.hcl"},"2":{"name":"variable.other.readwrite.hcl"},"3":{"name":"punctuation.section.parens.end.hcl"},"4":{"name":"keyword.operator.assignment.hcl"}},"comment":"Identifier \\"=\\" with optional parens","match":"(\\\\()?(\\\\b(?!null\\\\b|false\\\\b|true\\\\b)[A-Za-z][0-9A-Za-z_-]*)(\\\\))?\\\\s*(=(?!=|>))\\\\s*","name":"variable.declaration.hcl"},"attribute_splat":{"begin":"\\\\.","beginCaptures":{"0":{"name":"keyword.operator.accessor.hcl"}},"comment":"Legacy attribute-only splat","end":"\\\\*","endCaptures":{"0":{"name":"keyword.operator.splat.hcl"}}},"block":{"begin":"([\\\\w][\\\\-\\\\w]*)(([^\\\\S\\\\r\\\\n]*([\\\\w][\\\\-_\\\\w]*|\\\\\\"[^\\\\\\"\\\\r\\\\n]*\\\\\\"))*)[^\\\\S\\\\r\\\\n]*(\\\\{)","beginCaptures":{"1":{"patterns":[{"comment":"Block type","match":"\\\\b(?!null|false|true)[A-Za-z][0-9A-Za-z_-]*\\\\b","name":"entity.name.type.hcl"}]},"2":{"patterns":[{"comment":"Block label (String Literal)","match":"\\\\\\"[^\\\\\\"\\\\r\\\\n]*\\\\\\"","name":"variable.other.enummember.hcl"},{"comment":"Block label (Identifier)","match":"[A-Za-z][0-9A-Za-z_-]*","name":"variable.other.enummember.hcl"}]},"5":{"name":"punctuation.section.block.begin.hcl"}},"comment":"This will match HCL blocks like `thing1 \\"one\\" \\"two\\" {` or `thing2 {`","end":"\\\\}","endCaptures":{"0":{"name":"punctuation.section.block.end.hcl"}},"name":"meta.block.hcl","patterns":[{"include":"#comments"},{"include":"#attribute_definition"},{"include":"#expressions"},{"include":"#block"}]},"block_inline_comments":{"begin":"/\\\\*","captures":{"0":{"name":"punctuation.definition.comment.hcl"}},"comment":"Inline comments start with the /* sequence and end with the */ sequence, and may have any characters within except the ending sequence. An inline comment is considered equivalent to a whitespace sequence","end":"\\\\*/","name":"comment.block.hcl"},"brackets":{"begin":"\\\\[","beginCaptures":{"0":{"name":"punctuation.section.brackets.begin.hcl"}},"end":"\\\\]","endCaptures":{"0":{"name":"punctuation.section.brackets.end.hcl"}},"patterns":[{"comment":"Splat operator","match":"\\\\*","name":"keyword.operator.splat.hcl"},{"include":"#comma"},{"include":"#comments"},{"include":"#inline_for_expression"},{"include":"#inline_if_expression"},{"include":"#expressions"},{"include":"#local_identifiers"}]},"char_escapes":{"comment":"Character Escapes","match":"\\\\\\\\[nrt\\"\\\\\\\\]|\\\\\\\\u(\\\\h{8}|\\\\h{4})","name":"constant.character.escape.hcl"},"comma":{"comment":"Commas - used in certain expressions","match":"\\\\,","name":"punctuation.separator.hcl"},"comments":{"patterns":[{"include":"#hash_line_comments"},{"include":"#double_slash_line_comments"},{"include":"#block_inline_comments"}]},"double_slash_line_comments":{"begin":"//","captures":{"0":{"name":"punctuation.definition.comment.hcl"}},"comment":"Line comments start with // sequence and end with the next newline sequence. A line comment is considered equivalent to a newline sequence","end":"$\\\\n?","name":"comment.line.double-slash.hcl"},"expressions":{"patterns":[{"include":"#literal_values"},{"include":"#operators"},{"include":"#tuple_for_expression"},{"include":"#object_for_expression"},{"include":"#brackets"},{"include":"#objects"},{"include":"#attribute_access"},{"include":"#attribute_splat"},{"include":"#functions"},{"include":"#parens"}]},"for_expression_body":{"patterns":[{"comment":"in keyword","match":"\\\\bin\\\\b","name":"keyword.operator.word.hcl"},{"comment":"if keyword","match":"\\\\bif\\\\b","name":"keyword.control.conditional.hcl"},{"match":":","name":"keyword.operator.hcl"},{"include":"#expressions"},{"include":"#comments"},{"include":"#comma"},{"include":"#local_identifiers"}]},"functions":{"begin":"([:\\\\-\\\\w]+)(\\\\()","beginCaptures":{"1":{"patterns":[{"match":"\\\\b[A-Za-z][\\\\w_-]*::([A-Za-z][\\\\w_-]*::)?[A-Za-z][\\\\w_-]*\\\\b","name":"support.function.namespaced.hcl"},{"match":"\\\\b[A-Za-z][\\\\w_-]*\\\\b","name":"support.function.builtin.hcl"}]},"2":{"name":"punctuation.section.parens.begin.hcl"}},"comment":"Built-in function calls","end":"\\\\)","endCaptures":{"0":{"name":"punctuation.section.parens.end.hcl"}},"name":"meta.function-call.hcl","patterns":[{"include":"#comments"},{"include":"#expressions"},{"include":"#comma"}]},"hash_line_comments":{"begin":"#","captures":{"0":{"name":"punctuation.definition.comment.hcl"}},"comment":"Line comments start with # sequence and end with the next newline sequence. A line comment is considered equivalent to a newline sequence","end":"$\\\\n?","name":"comment.line.number-sign.hcl"},"hcl_type_keywords":{"comment":"Type keywords known to HCL.","match":"\\\\b(any|string|number|bool|list|set|map|tuple|object)\\\\b","name":"storage.type.hcl"},"heredoc":{"begin":"(<<-?)\\\\s*(\\\\w+)\\\\s*$","beginCaptures":{"1":{"name":"keyword.operator.heredoc.hcl"},"2":{"name":"keyword.control.heredoc.hcl"}},"comment":"String Heredoc","end":"^\\\\s*\\\\2\\\\s*$","endCaptures":{"0":{"name":"keyword.control.heredoc.hcl"}},"name":"string.unquoted.heredoc.hcl","patterns":[{"include":"#string_interpolation"}]},"inline_for_expression":{"captures":{"1":{"name":"keyword.control.hcl"},"2":{"patterns":[{"match":"=>","name":"storage.type.function.hcl"},{"include":"#for_expression_body"}]}},"match":"(for)\\\\b(.*)\\\\n"},"inline_if_expression":{"begin":"(if)\\\\b","beginCaptures":{"1":{"name":"keyword.control.conditional.hcl"}},"end":"\\\\n","patterns":[{"include":"#expressions"},{"include":"#comments"},{"include":"#comma"},{"include":"#local_identifiers"}]},"language_constants":{"comment":"Language Constants","match":"\\\\b(true|false|null)\\\\b","name":"constant.language.hcl"},"literal_values":{"patterns":[{"include":"#numeric_literals"},{"include":"#language_constants"},{"include":"#string_literals"},{"include":"#heredoc"},{"include":"#hcl_type_keywords"}]},"local_identifiers":{"comment":"Local Identifiers","match":"\\\\b(?!null|false|true)[A-Za-z][0-9A-Za-z_-]*\\\\b","name":"variable.other.readwrite.hcl"},"numeric_literals":{"patterns":[{"captures":{"1":{"name":"punctuation.separator.exponent.hcl"}},"comment":"Integer, no fraction, optional exponent","match":"\\\\b\\\\d+([Ee][+-]?)\\\\d+\\\\b","name":"constant.numeric.float.hcl"},{"captures":{"1":{"name":"punctuation.separator.decimal.hcl"},"2":{"name":"punctuation.separator.exponent.hcl"}},"comment":"Integer, fraction, optional exponent","match":"\\\\b\\\\d+(\\\\.)\\\\d+(?:([Ee][+-]?)\\\\d+)?\\\\b","name":"constant.numeric.float.hcl"},{"comment":"Integers","match":"\\\\b\\\\d+\\\\b","name":"constant.numeric.integer.hcl"}]},"object_for_expression":{"begin":"(\\\\{)\\\\s?(for)\\\\b","beginCaptures":{"1":{"name":"punctuation.section.braces.begin.hcl"},"2":{"name":"keyword.control.hcl"}},"end":"\\\\}","endCaptures":{"0":{"name":"punctuation.section.braces.end.hcl"}},"patterns":[{"match":"=>","name":"storage.type.function.hcl"},{"include":"#for_expression_body"}]},"object_key_values":{"patterns":[{"include":"#comments"},{"include":"#literal_values"},{"include":"#operators"},{"include":"#tuple_for_expression"},{"include":"#object_for_expression"},{"include":"#heredoc"},{"include":"#functions"}]},"objects":{"begin":"\\\\{","beginCaptures":{"0":{"name":"punctuation.section.braces.begin.hcl"}},"end":"\\\\}","endCaptures":{"0":{"name":"punctuation.section.braces.end.hcl"}},"name":"meta.braces.hcl","patterns":[{"include":"#comments"},{"include":"#objects"},{"include":"#inline_for_expression"},{"include":"#inline_if_expression"},{"captures":{"1":{"name":"meta.mapping.key.hcl variable.other.readwrite.hcl"},"2":{"name":"keyword.operator.assignment.hcl"}},"comment":"Literal, named object key","match":"\\\\b((?!null|false|true)[A-Za-z][0-9A-Za-z_-]*)\\\\s*(=(?!=))\\\\s*"},{"captures":{"1":{"name":"meta.mapping.key.hcl string.quoted.double.hcl"},"2":{"name":"punctuation.definition.string.begin.hcl"},"3":{"name":"punctuation.definition.string.end.hcl"},"4":{"name":"keyword.operator.hcl"}},"comment":"String object key","match":"^\\\\s*((\\").*(\\"))\\\\s*(=)\\\\s*"},{"begin":"^\\\\s*\\\\(","beginCaptures":{"0":{"name":"punctuation.section.parens.begin.hcl"}},"comment":"Computed object key (any expression between parens)","end":"(\\\\))\\\\s*(=|:)\\\\s*","endCaptures":{"1":{"name":"punctuation.section.parens.end.hcl"},"2":{"name":"keyword.operator.hcl"}},"name":"meta.mapping.key.hcl","patterns":[{"include":"#attribute_access"},{"include":"#attribute_splat"}]},{"include":"#object_key_values"}]},"operators":{"patterns":[{"match":">=","name":"keyword.operator.hcl"},{"match":"<=","name":"keyword.operator.hcl"},{"match":"==","name":"keyword.operator.hcl"},{"match":"!=","name":"keyword.operator.hcl"},{"match":"\\\\+","name":"keyword.operator.arithmetic.hcl"},{"match":"-","name":"keyword.operator.arithmetic.hcl"},{"match":"\\\\*","name":"keyword.operator.arithmetic.hcl"},{"match":"\\\\/","name":"keyword.operator.arithmetic.hcl"},{"match":"\\\\%","name":"keyword.operator.arithmetic.hcl"},{"match":"\\\\&\\\\&","name":"keyword.operator.logical.hcl"},{"match":"\\\\|\\\\|","name":"keyword.operator.logical.hcl"},{"match":"!","name":"keyword.operator.logical.hcl"},{"match":">","name":"keyword.operator.hcl"},{"match":"<","name":"keyword.operator.hcl"},{"match":"\\\\?","name":"keyword.operator.hcl"},{"match":"\\\\.\\\\.\\\\.","name":"keyword.operator.hcl"},{"match":":","name":"keyword.operator.hcl"},{"match":"=>","name":"keyword.operator.hcl"}]},"parens":{"begin":"\\\\(","beginCaptures":{"0":{"name":"punctuation.section.parens.begin.hcl"}},"comment":"Parens - matched *after* function syntax","end":"\\\\)","endCaptures":{"0":{"name":"punctuation.section.parens.end.hcl"}},"patterns":[{"include":"#comments"},{"include":"#expressions"}]},"string_interpolation":{"begin":"(?<![%$])([%$]{)","beginCaptures":{"1":{"name":"keyword.other.interpolation.begin.hcl"}},"comment":"String interpolation","end":"\\\\}","endCaptures":{"0":{"name":"keyword.other.interpolation.end.hcl"}},"name":"meta.interpolation.hcl","patterns":[{"comment":"Trim left whitespace","match":"\\\\~\\\\s","name":"keyword.operator.template.left.trim.hcl"},{"comment":"Trim right whitespace","match":"\\\\s\\\\~","name":"keyword.operator.template.right.trim.hcl"},{"comment":"if/else/endif and for/in/endfor directives","match":"\\\\b(if|else|endif|for|in|endfor)\\\\b","name":"keyword.control.hcl"},{"include":"#expressions"},{"include":"#local_identifiers"}]},"string_literals":{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.hcl"}},"comment":"Strings","end":"\\"","endCaptures":{"0":{"name":"punctuation.definition.string.end.hcl"}},"name":"string.quoted.double.hcl","patterns":[{"include":"#string_interpolation"},{"include":"#char_escapes"}]},"tuple_for_expression":{"begin":"(\\\\[)\\\\s?(for)\\\\b","beginCaptures":{"1":{"name":"punctuation.section.brackets.begin.hcl"},"2":{"name":"keyword.control.hcl"}},"end":"\\\\]","endCaptures":{"0":{"name":"punctuation.section.brackets.end.hcl"}},"patterns":[{"include":"#for_expression_body"}]}},"scopeName":"source.hcl"}')),n=[e];export{n as default};
1
+ const e=Object.freeze(JSON.parse('{"displayName":"HashiCorp HCL","fileTypes":["hcl"],"name":"hcl","patterns":[{"include":"#comments"},{"include":"#attribute_definition"},{"include":"#block"},{"include":"#expressions"}],"repository":{"attribute_access":{"begin":"\\\\.(?!\\\\*)","beginCaptures":{"0":{"name":"keyword.operator.accessor.hcl"}},"comment":"Matches traversal attribute access such as .attr","end":"[A-Za-z][\\\\w-]*|\\\\d*","endCaptures":{"0":{"patterns":[{"comment":"Attribute name","match":"(?!null|false|true)[A-Za-z][\\\\w-]*","name":"variable.other.member.hcl"},{"comment":"Optional attribute index","match":"\\\\d+","name":"constant.numeric.integer.hcl"}]}}},"attribute_definition":{"captures":{"1":{"name":"punctuation.section.parens.begin.hcl"},"2":{"name":"variable.other.readwrite.hcl"},"3":{"name":"punctuation.section.parens.end.hcl"},"4":{"name":"keyword.operator.assignment.hcl"}},"comment":"Identifier \\"=\\" with optional parens","match":"(\\\\()?(\\\\b(?!null\\\\b|false\\\\b|true\\\\b)[A-Za-z][0-9A-Za-z_-]*)(\\\\))?\\\\s*(=(?!=|>))\\\\s*","name":"variable.declaration.hcl"},"attribute_splat":{"begin":"\\\\.","beginCaptures":{"0":{"name":"keyword.operator.accessor.hcl"}},"comment":"Legacy attribute-only splat","end":"\\\\*","endCaptures":{"0":{"name":"keyword.operator.splat.hcl"}}},"block":{"begin":"([\\\\w][\\\\-\\\\w]*)(([^\\\\S\\\\r\\\\n]+([\\\\w][\\\\-_\\\\w]*|\\\\\\"[^\\\\\\"\\\\r\\\\n]*\\\\\\"))*)[^\\\\S\\\\r\\\\n]*(\\\\{)","beginCaptures":{"1":{"patterns":[{"comment":"Block type","match":"\\\\b(?!null|false|true)[A-Za-z][0-9A-Za-z_-]*\\\\b","name":"entity.name.type.hcl"}]},"2":{"patterns":[{"comment":"Block label (String Literal)","match":"\\\\\\"[^\\\\\\"\\\\r\\\\n]*\\\\\\"","name":"variable.other.enummember.hcl"},{"comment":"Block label (Identifier)","match":"[A-Za-z][0-9A-Za-z_-]*","name":"variable.other.enummember.hcl"}]},"5":{"name":"punctuation.section.block.begin.hcl"}},"comment":"This will match HCL blocks like `thing1 \\"one\\" \\"two\\" {` or `thing2 {`","end":"\\\\}","endCaptures":{"0":{"name":"punctuation.section.block.end.hcl"}},"name":"meta.block.hcl","patterns":[{"include":"#comments"},{"include":"#attribute_definition"},{"include":"#expressions"},{"include":"#block"}]},"block_inline_comments":{"begin":"/\\\\*","captures":{"0":{"name":"punctuation.definition.comment.hcl"}},"comment":"Inline comments start with the /* sequence and end with the */ sequence, and may have any characters within except the ending sequence. An inline comment is considered equivalent to a whitespace sequence","end":"\\\\*/","name":"comment.block.hcl"},"brackets":{"begin":"\\\\[","beginCaptures":{"0":{"name":"punctuation.section.brackets.begin.hcl"}},"end":"\\\\]","endCaptures":{"0":{"name":"punctuation.section.brackets.end.hcl"}},"patterns":[{"comment":"Splat operator","match":"\\\\*","name":"keyword.operator.splat.hcl"},{"include":"#comma"},{"include":"#comments"},{"include":"#inline_for_expression"},{"include":"#inline_if_expression"},{"include":"#expressions"},{"include":"#local_identifiers"}]},"char_escapes":{"comment":"Character Escapes","match":"\\\\\\\\[nrt\\"\\\\\\\\]|\\\\\\\\u(\\\\h{8}|\\\\h{4})","name":"constant.character.escape.hcl"},"comma":{"comment":"Commas - used in certain expressions","match":"\\\\,","name":"punctuation.separator.hcl"},"comments":{"patterns":[{"include":"#hash_line_comments"},{"include":"#double_slash_line_comments"},{"include":"#block_inline_comments"}]},"double_slash_line_comments":{"begin":"//","captures":{"0":{"name":"punctuation.definition.comment.hcl"}},"comment":"Line comments start with // sequence and end with the next newline sequence. A line comment is considered equivalent to a newline sequence","end":"$\\\\n?","name":"comment.line.double-slash.hcl"},"expressions":{"patterns":[{"include":"#literal_values"},{"include":"#operators"},{"include":"#tuple_for_expression"},{"include":"#object_for_expression"},{"include":"#brackets"},{"include":"#objects"},{"include":"#attribute_access"},{"include":"#attribute_splat"},{"include":"#functions"},{"include":"#parens"}]},"for_expression_body":{"patterns":[{"comment":"in keyword","match":"\\\\bin\\\\b","name":"keyword.operator.word.hcl"},{"comment":"if keyword","match":"\\\\bif\\\\b","name":"keyword.control.conditional.hcl"},{"match":":","name":"keyword.operator.hcl"},{"include":"#expressions"},{"include":"#comments"},{"include":"#comma"},{"include":"#local_identifiers"}]},"functions":{"begin":"([:\\\\-\\\\w]+)(\\\\()","beginCaptures":{"1":{"patterns":[{"match":"\\\\b[A-Za-z][\\\\w_-]*::([A-Za-z][\\\\w_-]*::)?[A-Za-z][\\\\w_-]*\\\\b","name":"support.function.namespaced.hcl"},{"match":"\\\\b[A-Za-z][\\\\w_-]*\\\\b","name":"support.function.builtin.hcl"}]},"2":{"name":"punctuation.section.parens.begin.hcl"}},"comment":"Built-in function calls","end":"\\\\)","endCaptures":{"0":{"name":"punctuation.section.parens.end.hcl"}},"name":"meta.function-call.hcl","patterns":[{"include":"#comments"},{"include":"#expressions"},{"include":"#comma"}]},"hash_line_comments":{"begin":"#","captures":{"0":{"name":"punctuation.definition.comment.hcl"}},"comment":"Line comments start with # sequence and end with the next newline sequence. A line comment is considered equivalent to a newline sequence","end":"$\\\\n?","name":"comment.line.number-sign.hcl"},"hcl_type_keywords":{"comment":"Type keywords known to HCL.","match":"\\\\b(any|string|number|bool|list|set|map|tuple|object)\\\\b","name":"storage.type.hcl"},"heredoc":{"begin":"(<<-?)\\\\s*(\\\\w+)\\\\s*$","beginCaptures":{"1":{"name":"keyword.operator.heredoc.hcl"},"2":{"name":"keyword.control.heredoc.hcl"}},"comment":"String Heredoc","end":"^\\\\s*\\\\2\\\\s*$","endCaptures":{"0":{"name":"keyword.control.heredoc.hcl"}},"name":"string.unquoted.heredoc.hcl","patterns":[{"include":"#string_interpolation"}]},"inline_for_expression":{"captures":{"1":{"name":"keyword.control.hcl"},"2":{"patterns":[{"match":"=>","name":"storage.type.function.hcl"},{"include":"#for_expression_body"}]}},"match":"(for)\\\\b(.*)\\\\n"},"inline_if_expression":{"begin":"(if)\\\\b","beginCaptures":{"1":{"name":"keyword.control.conditional.hcl"}},"end":"\\\\n","patterns":[{"include":"#expressions"},{"include":"#comments"},{"include":"#comma"},{"include":"#local_identifiers"}]},"language_constants":{"comment":"Language Constants","match":"\\\\b(true|false|null)\\\\b","name":"constant.language.hcl"},"literal_values":{"patterns":[{"include":"#numeric_literals"},{"include":"#language_constants"},{"include":"#string_literals"},{"include":"#heredoc"},{"include":"#hcl_type_keywords"}]},"local_identifiers":{"comment":"Local Identifiers","match":"\\\\b(?!null|false|true)[A-Za-z][0-9A-Za-z_-]*\\\\b","name":"variable.other.readwrite.hcl"},"numeric_literals":{"patterns":[{"captures":{"1":{"name":"punctuation.separator.exponent.hcl"}},"comment":"Integer, no fraction, optional exponent","match":"\\\\b\\\\d+([Ee][+-]?)\\\\d+\\\\b","name":"constant.numeric.float.hcl"},{"captures":{"1":{"name":"punctuation.separator.decimal.hcl"},"2":{"name":"punctuation.separator.exponent.hcl"}},"comment":"Integer, fraction, optional exponent","match":"\\\\b\\\\d+(\\\\.)\\\\d+(?:([Ee][+-]?)\\\\d+)?\\\\b","name":"constant.numeric.float.hcl"},{"comment":"Integers","match":"\\\\b\\\\d+\\\\b","name":"constant.numeric.integer.hcl"}]},"object_for_expression":{"begin":"(\\\\{)\\\\s?(for)\\\\b","beginCaptures":{"1":{"name":"punctuation.section.braces.begin.hcl"},"2":{"name":"keyword.control.hcl"}},"end":"\\\\}","endCaptures":{"0":{"name":"punctuation.section.braces.end.hcl"}},"patterns":[{"match":"=>","name":"storage.type.function.hcl"},{"include":"#for_expression_body"}]},"object_key_values":{"patterns":[{"include":"#comments"},{"include":"#literal_values"},{"include":"#operators"},{"include":"#tuple_for_expression"},{"include":"#object_for_expression"},{"include":"#heredoc"},{"include":"#functions"}]},"objects":{"begin":"\\\\{","beginCaptures":{"0":{"name":"punctuation.section.braces.begin.hcl"}},"end":"\\\\}","endCaptures":{"0":{"name":"punctuation.section.braces.end.hcl"}},"name":"meta.braces.hcl","patterns":[{"include":"#comments"},{"include":"#objects"},{"include":"#inline_for_expression"},{"include":"#inline_if_expression"},{"captures":{"1":{"name":"meta.mapping.key.hcl variable.other.readwrite.hcl"},"2":{"name":"keyword.operator.assignment.hcl"}},"comment":"Literal, named object key","match":"\\\\b((?!null|false|true)[A-Za-z][0-9A-Za-z_-]*)\\\\s*(=(?!=))\\\\s*"},{"captures":{"1":{"name":"meta.mapping.key.hcl string.quoted.double.hcl"},"2":{"name":"punctuation.definition.string.begin.hcl"},"3":{"name":"punctuation.definition.string.end.hcl"},"4":{"name":"keyword.operator.hcl"}},"comment":"String object key","match":"^\\\\s*((\\").*(\\"))\\\\s*(=)\\\\s*"},{"begin":"^\\\\s*\\\\(","beginCaptures":{"0":{"name":"punctuation.section.parens.begin.hcl"}},"comment":"Computed object key (any expression between parens)","end":"(\\\\))\\\\s*(=|:)\\\\s*","endCaptures":{"1":{"name":"punctuation.section.parens.end.hcl"},"2":{"name":"keyword.operator.hcl"}},"name":"meta.mapping.key.hcl","patterns":[{"include":"#attribute_access"},{"include":"#attribute_splat"}]},{"include":"#object_key_values"}]},"operators":{"patterns":[{"match":">=","name":"keyword.operator.hcl"},{"match":"<=","name":"keyword.operator.hcl"},{"match":"==","name":"keyword.operator.hcl"},{"match":"!=","name":"keyword.operator.hcl"},{"match":"\\\\+","name":"keyword.operator.arithmetic.hcl"},{"match":"-","name":"keyword.operator.arithmetic.hcl"},{"match":"\\\\*","name":"keyword.operator.arithmetic.hcl"},{"match":"\\\\/","name":"keyword.operator.arithmetic.hcl"},{"match":"\\\\%","name":"keyword.operator.arithmetic.hcl"},{"match":"\\\\&\\\\&","name":"keyword.operator.logical.hcl"},{"match":"\\\\|\\\\|","name":"keyword.operator.logical.hcl"},{"match":"!","name":"keyword.operator.logical.hcl"},{"match":">","name":"keyword.operator.hcl"},{"match":"<","name":"keyword.operator.hcl"},{"match":"\\\\?","name":"keyword.operator.hcl"},{"match":"\\\\.\\\\.\\\\.","name":"keyword.operator.hcl"},{"match":":","name":"keyword.operator.hcl"},{"match":"=>","name":"keyword.operator.hcl"}]},"parens":{"begin":"\\\\(","beginCaptures":{"0":{"name":"punctuation.section.parens.begin.hcl"}},"comment":"Parens - matched *after* function syntax","end":"\\\\)","endCaptures":{"0":{"name":"punctuation.section.parens.end.hcl"}},"patterns":[{"include":"#comments"},{"include":"#expressions"}]},"string_interpolation":{"begin":"(?<![%$])([%$]{)","beginCaptures":{"1":{"name":"keyword.other.interpolation.begin.hcl"}},"comment":"String interpolation","end":"\\\\}","endCaptures":{"0":{"name":"keyword.other.interpolation.end.hcl"}},"name":"meta.interpolation.hcl","patterns":[{"comment":"Trim left whitespace","match":"\\\\~\\\\s","name":"keyword.operator.template.left.trim.hcl"},{"comment":"Trim right whitespace","match":"\\\\s\\\\~","name":"keyword.operator.template.right.trim.hcl"},{"comment":"if/else/endif and for/in/endfor directives","match":"\\\\b(if|else|endif|for|in|endfor)\\\\b","name":"keyword.control.hcl"},{"include":"#expressions"},{"include":"#local_identifiers"}]},"string_literals":{"begin":"\\"","beginCaptures":{"0":{"name":"punctuation.definition.string.begin.hcl"}},"comment":"Strings","end":"\\"","endCaptures":{"0":{"name":"punctuation.definition.string.end.hcl"}},"name":"string.quoted.double.hcl","patterns":[{"include":"#string_interpolation"},{"include":"#char_escapes"}]},"tuple_for_expression":{"begin":"(\\\\[)\\\\s?(for)\\\\b","beginCaptures":{"1":{"name":"punctuation.section.brackets.begin.hcl"},"2":{"name":"keyword.control.hcl"}},"end":"\\\\]","endCaptures":{"0":{"name":"punctuation.section.brackets.end.hcl"}},"patterns":[{"include":"#for_expression_body"}]}},"scopeName":"source.hcl"}')),n=[e];export{n as default};