freestyle-sandboxes 0.0.13 → 0.0.15

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.
package/dist/ai/index.cjs CHANGED
@@ -5,6 +5,29 @@ var ai = require('ai');
5
5
  var zod = require('zod');
6
6
  require('@hey-api/client-fetch');
7
7
 
8
+ const executeCodeSchema = zod.z.object({
9
+ script: zod.z.string().describe(`
10
+ The JavaScript or TypeScript script to execute, must be in the format of:
11
+
12
+ import { someModule } from "someModule";
13
+ export default () => {
14
+ ... your code here ...
15
+ return output;
16
+ }
17
+
18
+ or for async functions:
19
+
20
+ import { someModule } from "someModule";
21
+
22
+ export default async () => {
23
+ ... your code here ...
24
+ return output;
25
+ }
26
+ `)
27
+ });
28
+ const executeCodeDescription = (envVars, nodeModules) => `Execute a JavaScript or TypeScript script.
29
+ ${envVars.length > 0 ? `You can use the following environment variables: ${envVars}` : ""}
30
+ ${nodeModules.length > 0 ? `You can use the following node modules: ${nodeModules}` : "You cannot use any node modules."}`;
8
31
  const executeTool = (config) => {
9
32
  const api = new index.FreestyleSandboxes({
10
33
  ...config
@@ -12,29 +35,8 @@ const executeTool = (config) => {
12
35
  const envVars = Object.keys(config.envVars ?? {}).join(", ");
13
36
  const nodeModules = Object.keys(config.nodeModules ?? {}).join(", ");
14
37
  return ai.tool({
15
- description: `Execute a JavaScript or TypeScript script.
16
- ${envVars.length > 0 ? `You can use the following environment variables: ${envVars}` : ""}
17
- ${nodeModules.length > 0 ? `You can use the following node modules: ${nodeModules}` : "You cannot use any node modules."}`,
18
- parameters: zod.z.object({
19
- script: zod.z.string().describe(`
20
- The JavaScript or TypeScript script to execute, must be in the format of:
21
-
22
- import { someModule } from "someModule";
23
- export default () => {
24
- ... your code here ...
25
- return output;
26
- }
27
-
28
- or for async functions:
29
-
30
- import { someModule } from "someModule";
31
-
32
- export default async () => {
33
- ... your code here ...
34
- return output;
35
- }
36
- `)
37
- }),
38
+ description: executeCodeDescription(envVars, nodeModules),
39
+ parameters: executeCodeSchema,
38
40
  execute: async ({ script }) => {
39
41
  try {
40
42
  const res = await api.executeScript(script, config);
@@ -92,4 +94,6 @@ Error: ${e.message}`;
92
94
  };
93
95
 
94
96
  exports.deployWebTool = deployWebTool;
97
+ exports.executeCodeDescription = executeCodeDescription;
98
+ exports.executeCodeSchema = executeCodeSchema;
95
99
  exports.executeTool = executeTool;
@@ -1,7 +1,15 @@
1
1
  import * as ai from 'ai';
2
- import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-BtK6PMQy.js';
2
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-BaMKzqxQ.js';
3
3
  import { z } from 'zod';
4
4
 
5
+ declare const executeCodeSchema: z.ZodObject<{
6
+ script: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ script?: string;
9
+ }, {
10
+ script?: string;
11
+ }>;
12
+ declare const executeCodeDescription: (envVars: string, nodeModules: string) => string;
5
13
  /**
6
14
  * Execute a JavaScript or TypeScript script
7
15
  *
@@ -42,4 +50,4 @@ declare const deployWebTool: (config: FreestyleExecuteScriptParamsConfiguration
42
50
  }, options: ai.ToolExecutionOptions) => PromiseLike<string | FreestyleDeployWebSuccessResponse>;
43
51
  };
44
52
 
45
- export { deployWebTool, executeTool };
53
+ export { deployWebTool, executeCodeDescription, executeCodeSchema, executeTool };
@@ -1,7 +1,15 @@
1
1
  import * as ai from 'ai';
2
- import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-BtK6PMQy.js';
2
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-BaMKzqxQ.js';
3
3
  import { z } from 'zod';
4
4
 
5
+ declare const executeCodeSchema: z.ZodObject<{
6
+ script: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ script?: string;
9
+ }, {
10
+ script?: string;
11
+ }>;
12
+ declare const executeCodeDescription: (envVars: string, nodeModules: string) => string;
5
13
  /**
6
14
  * Execute a JavaScript or TypeScript script
7
15
  *
@@ -42,4 +50,4 @@ declare const deployWebTool: (config: FreestyleExecuteScriptParamsConfiguration
42
50
  }, options: ai.ToolExecutionOptions) => PromiseLike<string | FreestyleDeployWebSuccessResponse>;
43
51
  };
44
52
 
45
- export { deployWebTool, executeTool };
53
+ export { deployWebTool, executeCodeDescription, executeCodeSchema, executeTool };
package/dist/ai/index.mjs CHANGED
@@ -3,6 +3,29 @@ import { tool } from 'ai';
3
3
  import { z } from 'zod';
4
4
  import '@hey-api/client-fetch';
5
5
 
6
+ const executeCodeSchema = z.object({
7
+ script: z.string().describe(`
8
+ The JavaScript or TypeScript script to execute, must be in the format of:
9
+
10
+ import { someModule } from "someModule";
11
+ export default () => {
12
+ ... your code here ...
13
+ return output;
14
+ }
15
+
16
+ or for async functions:
17
+
18
+ import { someModule } from "someModule";
19
+
20
+ export default async () => {
21
+ ... your code here ...
22
+ return output;
23
+ }
24
+ `)
25
+ });
26
+ const executeCodeDescription = (envVars, nodeModules) => `Execute a JavaScript or TypeScript script.
27
+ ${envVars.length > 0 ? `You can use the following environment variables: ${envVars}` : ""}
28
+ ${nodeModules.length > 0 ? `You can use the following node modules: ${nodeModules}` : "You cannot use any node modules."}`;
6
29
  const executeTool = (config) => {
7
30
  const api = new FreestyleSandboxes({
8
31
  ...config
@@ -10,29 +33,8 @@ const executeTool = (config) => {
10
33
  const envVars = Object.keys(config.envVars ?? {}).join(", ");
11
34
  const nodeModules = Object.keys(config.nodeModules ?? {}).join(", ");
12
35
  return tool({
13
- description: `Execute a JavaScript or TypeScript script.
14
- ${envVars.length > 0 ? `You can use the following environment variables: ${envVars}` : ""}
15
- ${nodeModules.length > 0 ? `You can use the following node modules: ${nodeModules}` : "You cannot use any node modules."}`,
16
- parameters: z.object({
17
- script: z.string().describe(`
18
- The JavaScript or TypeScript script to execute, must be in the format of:
19
-
20
- import { someModule } from "someModule";
21
- export default () => {
22
- ... your code here ...
23
- return output;
24
- }
25
-
26
- or for async functions:
27
-
28
- import { someModule } from "someModule";
29
-
30
- export default async () => {
31
- ... your code here ...
32
- return output;
33
- }
34
- `)
35
- }),
36
+ description: executeCodeDescription(envVars, nodeModules),
37
+ parameters: executeCodeSchema,
36
38
  execute: async ({ script }) => {
37
39
  try {
38
40
  const res = await api.executeScript(script, config);
@@ -89,4 +91,4 @@ Error: ${e.message}`;
89
91
  });
90
92
  };
91
93
 
92
- export { deployWebTool, executeTool };
94
+ export { deployWebTool, executeCodeDescription, executeCodeSchema, executeTool };
package/dist/index.cjs CHANGED
@@ -21,6 +21,12 @@ const handleListDomains = (options) => {
21
21
  url: "/domains/v1/domains"
22
22
  });
23
23
  };
24
+ const handleListDomainVerificationRequests = (options) => {
25
+ return (options?.client ?? client).get({
26
+ ...options,
27
+ url: "/domains/v1/verifications"
28
+ });
29
+ };
24
30
  const handleVerifyDomain = (options) => {
25
31
  return (options?.client ?? client).put({
26
32
  ...options,
@@ -33,6 +39,12 @@ const handleCreateDomainVerification = (options) => {
33
39
  url: "/domains/v1/verifications"
34
40
  });
35
41
  };
42
+ const handleDeleteDomainVerification = (options) => {
43
+ return (options?.client ?? client).delete({
44
+ ...options,
45
+ url: "/domains/v1/verifications"
46
+ });
47
+ };
36
48
  const handleExecuteScript = (options) => {
37
49
  return (options?.client ?? client).post({
38
50
  ...options,
@@ -212,7 +224,37 @@ Message: ${response.error?.message}`
212
224
  if (response.data) {
213
225
  return response.data;
214
226
  } else {
215
- throw new Error("Failed to list domains");
227
+ throw new Error("Failed to list domains\n" + response.error.message);
228
+ }
229
+ }
230
+ async listDomainVerificationRequests() {
231
+ const response = await handleListDomainVerificationRequests(
232
+ {
233
+ client: this.client
234
+ }
235
+ );
236
+ if (response.data) {
237
+ return response.data;
238
+ } else {
239
+ throw new Error(
240
+ "Failed to list domain verification requests\n" + response.error.message
241
+ );
242
+ }
243
+ }
244
+ async deleteDomainVerificationRequest(domain, verificationCode) {
245
+ const response = await handleDeleteDomainVerification({
246
+ client: this.client,
247
+ body: {
248
+ domain,
249
+ verificationCode
250
+ }
251
+ });
252
+ if (response.data) {
253
+ return response.data;
254
+ } else {
255
+ throw new Error(
256
+ `Failed to delete domain verification request for domain ${domain}: ${response.error.message}`
257
+ );
216
258
  }
217
259
  }
218
260
  }
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleListDomainsResponse } from './types.gen-BtK6PMQy.js';
2
- export { j as FreestyleCloudstateDeployConfiguration, k as FreestyleCloudstateDeployErrorResponse, l as FreestyleDeployWebErrorResponse, m as FreestyleDeployWebPayload, n as FreestyleDomainVerificationRequest, o as FreestyleExecureScriptResultError, p as FreestyleExecuteScriptParams, q as FreestyleFile, r as FreestyleLogResponseObject, s as FreestyleVerifyDomainRequest, w as HandleBackupCloudstateData, x as HandleBackupCloudstateError, B as HandleCreateDomainVerificationData, C as HandleCreateDomainVerificationError, t as HandleDeployCloudstateData, v as HandleDeployCloudstateError, u as HandleDeployCloudstateResponse, I as HandleDeployWebData, L as HandleDeployWebError, K as HandleDeployWebResponse, D as HandleExecuteScriptData, G as HandleExecuteScriptError, E as HandleExecuteScriptResponse, M as HandleGetLogsData, N as HandleGetLogsError, y as HandleListDomainsError, z as HandleVerifyDomainData, A as HandleVerifyDomainError, J as JavaScriptLog } from './types.gen-BtK6PMQy.js';
1
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleListDomainsResponse, j as HandleListDomainVerificationRequestsResponse, k as HandleDeleteDomainVerificationResponse } from './types.gen-BaMKzqxQ.js';
2
+ export { l as FreestyleCloudstateDeployConfiguration, m as FreestyleCloudstateDeployErrorResponse, n as FreestyleDeleteDomainVerificationRequest, o as FreestyleDeployWebErrorResponse, p as FreestyleDeployWebPayload, q as FreestyleDomainVerificationRequest, r as FreestyleExecureScriptResultError, s as FreestyleExecuteScriptParams, t as FreestyleFile, u as FreestyleLogResponseObject, v as FreestyleVerifyDomainRequest, z as HandleBackupCloudstateData, A as HandleBackupCloudstateError, G as HandleCreateDomainVerificationData, I as HandleCreateDomainVerificationError, K as HandleDeleteDomainVerificationData, L as HandleDeleteDomainVerificationError, w as HandleDeployCloudstateData, y as HandleDeployCloudstateError, x as HandleDeployCloudstateResponse, P as HandleDeployWebData, R as HandleDeployWebError, Q as HandleDeployWebResponse, M as HandleExecuteScriptData, O as HandleExecuteScriptError, N as HandleExecuteScriptResponse, S as HandleGetLogsData, T as HandleGetLogsError, C as HandleListDomainVerificationRequestsError, B as HandleListDomainsError, D as HandleVerifyDomainData, E as HandleVerifyDomainError, J as JavaScriptLog } from './types.gen-BaMKzqxQ.js';
3
3
 
4
4
  declare class FreestyleSandboxes {
5
5
  private client;
@@ -59,6 +59,8 @@ declare class FreestyleSandboxes {
59
59
  */
60
60
  verifyDomain(domain: string): Promise<HandleVerifyDomainResponse>;
61
61
  listDomains(): Promise<HandleListDomainsResponse>;
62
+ listDomainVerificationRequests(): Promise<HandleListDomainVerificationRequestsResponse>;
63
+ deleteDomainVerificationRequest(domain: string, verificationCode: string): Promise<HandleDeleteDomainVerificationResponse>;
62
64
  }
63
65
 
64
- export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecureScriptResultSuccess, FreestyleExecuteScriptParamsConfiguration, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleGetLogsResponse, HandleListDomainsResponse, HandleVerifyDomainResponse };
66
+ export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecureScriptResultSuccess, FreestyleExecuteScriptParamsConfiguration, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleDeleteDomainVerificationResponse, HandleGetLogsResponse, HandleListDomainVerificationRequestsResponse, HandleListDomainsResponse, HandleVerifyDomainResponse };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleListDomainsResponse } from './types.gen-BtK6PMQy.js';
2
- export { j as FreestyleCloudstateDeployConfiguration, k as FreestyleCloudstateDeployErrorResponse, l as FreestyleDeployWebErrorResponse, m as FreestyleDeployWebPayload, n as FreestyleDomainVerificationRequest, o as FreestyleExecureScriptResultError, p as FreestyleExecuteScriptParams, q as FreestyleFile, r as FreestyleLogResponseObject, s as FreestyleVerifyDomainRequest, w as HandleBackupCloudstateData, x as HandleBackupCloudstateError, B as HandleCreateDomainVerificationData, C as HandleCreateDomainVerificationError, t as HandleDeployCloudstateData, v as HandleDeployCloudstateError, u as HandleDeployCloudstateResponse, I as HandleDeployWebData, L as HandleDeployWebError, K as HandleDeployWebResponse, D as HandleExecuteScriptData, G as HandleExecuteScriptError, E as HandleExecuteScriptResponse, M as HandleGetLogsData, N as HandleGetLogsError, y as HandleListDomainsError, z as HandleVerifyDomainData, A as HandleVerifyDomainError, J as JavaScriptLog } from './types.gen-BtK6PMQy.js';
1
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleListDomainsResponse, j as HandleListDomainVerificationRequestsResponse, k as HandleDeleteDomainVerificationResponse } from './types.gen-BaMKzqxQ.js';
2
+ export { l as FreestyleCloudstateDeployConfiguration, m as FreestyleCloudstateDeployErrorResponse, n as FreestyleDeleteDomainVerificationRequest, o as FreestyleDeployWebErrorResponse, p as FreestyleDeployWebPayload, q as FreestyleDomainVerificationRequest, r as FreestyleExecureScriptResultError, s as FreestyleExecuteScriptParams, t as FreestyleFile, u as FreestyleLogResponseObject, v as FreestyleVerifyDomainRequest, z as HandleBackupCloudstateData, A as HandleBackupCloudstateError, G as HandleCreateDomainVerificationData, I as HandleCreateDomainVerificationError, K as HandleDeleteDomainVerificationData, L as HandleDeleteDomainVerificationError, w as HandleDeployCloudstateData, y as HandleDeployCloudstateError, x as HandleDeployCloudstateResponse, P as HandleDeployWebData, R as HandleDeployWebError, Q as HandleDeployWebResponse, M as HandleExecuteScriptData, O as HandleExecuteScriptError, N as HandleExecuteScriptResponse, S as HandleGetLogsData, T as HandleGetLogsError, C as HandleListDomainVerificationRequestsError, B as HandleListDomainsError, D as HandleVerifyDomainData, E as HandleVerifyDomainError, J as JavaScriptLog } from './types.gen-BaMKzqxQ.js';
3
3
 
4
4
  declare class FreestyleSandboxes {
5
5
  private client;
@@ -59,6 +59,8 @@ declare class FreestyleSandboxes {
59
59
  */
60
60
  verifyDomain(domain: string): Promise<HandleVerifyDomainResponse>;
61
61
  listDomains(): Promise<HandleListDomainsResponse>;
62
+ listDomainVerificationRequests(): Promise<HandleListDomainVerificationRequestsResponse>;
63
+ deleteDomainVerificationRequest(domain: string, verificationCode: string): Promise<HandleDeleteDomainVerificationResponse>;
62
64
  }
63
65
 
64
- export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecureScriptResultSuccess, FreestyleExecuteScriptParamsConfiguration, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleGetLogsResponse, HandleListDomainsResponse, HandleVerifyDomainResponse };
66
+ export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecureScriptResultSuccess, FreestyleExecuteScriptParamsConfiguration, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleDeleteDomainVerificationResponse, HandleGetLogsResponse, HandleListDomainVerificationRequestsResponse, HandleListDomainsResponse, HandleVerifyDomainResponse };
package/dist/index.mjs CHANGED
@@ -19,6 +19,12 @@ const handleListDomains = (options) => {
19
19
  url: "/domains/v1/domains"
20
20
  });
21
21
  };
22
+ const handleListDomainVerificationRequests = (options) => {
23
+ return (options?.client ?? client).get({
24
+ ...options,
25
+ url: "/domains/v1/verifications"
26
+ });
27
+ };
22
28
  const handleVerifyDomain = (options) => {
23
29
  return (options?.client ?? client).put({
24
30
  ...options,
@@ -31,6 +37,12 @@ const handleCreateDomainVerification = (options) => {
31
37
  url: "/domains/v1/verifications"
32
38
  });
33
39
  };
40
+ const handleDeleteDomainVerification = (options) => {
41
+ return (options?.client ?? client).delete({
42
+ ...options,
43
+ url: "/domains/v1/verifications"
44
+ });
45
+ };
34
46
  const handleExecuteScript = (options) => {
35
47
  return (options?.client ?? client).post({
36
48
  ...options,
@@ -210,7 +222,37 @@ Message: ${response.error?.message}`
210
222
  if (response.data) {
211
223
  return response.data;
212
224
  } else {
213
- throw new Error("Failed to list domains");
225
+ throw new Error("Failed to list domains\n" + response.error.message);
226
+ }
227
+ }
228
+ async listDomainVerificationRequests() {
229
+ const response = await handleListDomainVerificationRequests(
230
+ {
231
+ client: this.client
232
+ }
233
+ );
234
+ if (response.data) {
235
+ return response.data;
236
+ } else {
237
+ throw new Error(
238
+ "Failed to list domain verification requests\n" + response.error.message
239
+ );
240
+ }
241
+ }
242
+ async deleteDomainVerificationRequest(domain, verificationCode) {
243
+ const response = await handleDeleteDomainVerification({
244
+ client: this.client,
245
+ body: {
246
+ domain,
247
+ verificationCode
248
+ }
249
+ });
250
+ if (response.data) {
251
+ return response.data;
252
+ } else {
253
+ throw new Error(
254
+ `Failed to delete domain verification request for domain ${domain}: ${response.error.message}`
255
+ );
214
256
  }
215
257
  }
216
258
  }
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var core = require('@mastra/core');
4
+ var zod = require('zod');
5
+ var index = require('../ai/index.cjs');
6
+ var index$1 = require('../index.cjs');
7
+ require('ai');
8
+ require('@hey-api/client-fetch');
9
+
10
+ const executeTool = (config) => {
11
+ const description = index.executeCodeDescription(
12
+ Object.keys(config.envVars ?? {}).join(", "),
13
+ Object.keys(config.nodeModules ?? {}).join(", ")
14
+ );
15
+ const client = new index$1.FreestyleSandboxes({
16
+ apiKey: config.apiKey
17
+ });
18
+ return core.createTool({
19
+ id: "Execute a TypeScript or JavaScript Script",
20
+ description,
21
+ inputSchema: index.executeCodeSchema,
22
+ execute: async ({ context: { script } }) => {
23
+ return await client.executeScript(script, config);
24
+ },
25
+ outputSchema: zod.z.object({
26
+ logs: zod.z.array(
27
+ zod.z.object({
28
+ message: zod.z.string(),
29
+ type: zod.z.string()
30
+ })
31
+ ),
32
+ result: zod.z.unknown()
33
+ })
34
+ });
35
+ };
36
+
37
+ exports.executeTool = executeTool;
@@ -0,0 +1,45 @@
1
+ import * as _mastra_core from '@mastra/core';
2
+ import { z } from 'zod';
3
+ import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-BaMKzqxQ.js';
4
+
5
+ declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration & {
6
+ apiKey: string;
7
+ }) => _mastra_core.Tool<"Execute a TypeScript or JavaScript Script", z.ZodObject<{
8
+ script: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ script?: string;
11
+ }, {
12
+ script?: string;
13
+ }>, z.ZodObject<{
14
+ logs: z.ZodArray<z.ZodObject<{
15
+ message: z.ZodString;
16
+ type: z.ZodString;
17
+ }, "strip", z.ZodTypeAny, {
18
+ message?: string;
19
+ type?: string;
20
+ }, {
21
+ message?: string;
22
+ type?: string;
23
+ }>, "many">;
24
+ result: z.ZodUnknown;
25
+ }, "strip", z.ZodTypeAny, {
26
+ logs?: {
27
+ message?: string;
28
+ type?: string;
29
+ }[];
30
+ result?: unknown;
31
+ }, {
32
+ logs?: {
33
+ message?: string;
34
+ type?: string;
35
+ }[];
36
+ result?: unknown;
37
+ }>, _mastra_core.ToolExecutionContext<z.ZodObject<{
38
+ script: z.ZodString;
39
+ }, "strip", z.ZodTypeAny, {
40
+ script?: string;
41
+ }, {
42
+ script?: string;
43
+ }>, _mastra_core.WorkflowContext<any>>>;
44
+
45
+ export { executeTool };
@@ -0,0 +1,45 @@
1
+ import * as _mastra_core from '@mastra/core';
2
+ import { z } from 'zod';
3
+ import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-BaMKzqxQ.js';
4
+
5
+ declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration & {
6
+ apiKey: string;
7
+ }) => _mastra_core.Tool<"Execute a TypeScript or JavaScript Script", z.ZodObject<{
8
+ script: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ script?: string;
11
+ }, {
12
+ script?: string;
13
+ }>, z.ZodObject<{
14
+ logs: z.ZodArray<z.ZodObject<{
15
+ message: z.ZodString;
16
+ type: z.ZodString;
17
+ }, "strip", z.ZodTypeAny, {
18
+ message?: string;
19
+ type?: string;
20
+ }, {
21
+ message?: string;
22
+ type?: string;
23
+ }>, "many">;
24
+ result: z.ZodUnknown;
25
+ }, "strip", z.ZodTypeAny, {
26
+ logs?: {
27
+ message?: string;
28
+ type?: string;
29
+ }[];
30
+ result?: unknown;
31
+ }, {
32
+ logs?: {
33
+ message?: string;
34
+ type?: string;
35
+ }[];
36
+ result?: unknown;
37
+ }>, _mastra_core.ToolExecutionContext<z.ZodObject<{
38
+ script: z.ZodString;
39
+ }, "strip", z.ZodTypeAny, {
40
+ script?: string;
41
+ }, {
42
+ script?: string;
43
+ }>, _mastra_core.WorkflowContext<any>>>;
44
+
45
+ export { executeTool };
@@ -0,0 +1,35 @@
1
+ import { createTool } from '@mastra/core';
2
+ import { z } from 'zod';
3
+ import { executeCodeDescription, executeCodeSchema } from '../ai/index.mjs';
4
+ import { FreestyleSandboxes } from '../index.mjs';
5
+ import 'ai';
6
+ import '@hey-api/client-fetch';
7
+
8
+ const executeTool = (config) => {
9
+ const description = executeCodeDescription(
10
+ Object.keys(config.envVars ?? {}).join(", "),
11
+ Object.keys(config.nodeModules ?? {}).join(", ")
12
+ );
13
+ const client = new FreestyleSandboxes({
14
+ apiKey: config.apiKey
15
+ });
16
+ return createTool({
17
+ id: "Execute a TypeScript or JavaScript Script",
18
+ description,
19
+ inputSchema: executeCodeSchema,
20
+ execute: async ({ context: { script } }) => {
21
+ return await client.executeScript(script, config);
22
+ },
23
+ outputSchema: z.object({
24
+ logs: z.array(
25
+ z.object({
26
+ message: z.string(),
27
+ type: z.string()
28
+ })
29
+ ),
30
+ result: z.unknown()
31
+ })
32
+ });
33
+ };
34
+
35
+ export { executeTool };
@@ -0,0 +1,233 @@
1
+ type FreestyleCloudstateDeployConfiguration = {
2
+ /**
3
+ * ID of the project to deploy, if not provided will create a new project
4
+ */
5
+ projectId?: (string) | null;
6
+ /**
7
+ * The environment variables that the cloudstate deploy can access
8
+ */
9
+ envVars?: {
10
+ [key: string]: (string);
11
+ };
12
+ };
13
+ type FreestyleCloudstateDeployErrorResponse = {
14
+ message: string;
15
+ };
16
+ type FreestyleCloudstateDeployRequest = {
17
+ classes: string;
18
+ config?: FreestyleCloudstateDeployConfiguration;
19
+ };
20
+ type FreestyleCloudstateDeploySuccessResponse = {
21
+ /**
22
+ * The id of the project deployed to
23
+ */
24
+ projectId: string;
25
+ };
26
+ type FreestyleDeleteDomainVerificationRequest = {
27
+ /**
28
+ * The domain to create a verification code for
29
+ */
30
+ domain: string;
31
+ /**
32
+ * The verification code
33
+ */
34
+ verificationCode: string;
35
+ };
36
+ type FreestyleDeployWebConfiguration = {
37
+ /**
38
+ * The entrypoint file for the website
39
+ */
40
+ entrypoint?: (string) | null;
41
+ /**
42
+ * The custom domains for the website, eg. [\"subdomain.yourwebsite.com\"]. You may include a single *.style.dev domain here.
43
+ */
44
+ domains?: Array<(string)> | null;
45
+ /**
46
+ * Project ID was our original way of tracking deployments together, it is now deprecated and will be removed in the future. Please use the domains field to specify the domains for your project.
47
+ * @deprecated
48
+ */
49
+ projectId?: (string) | null;
50
+ /**
51
+ * Node Modules to install for the website, a map of package names to versions, e.g. { \"express\": \"4.17.1\" }. If this and a package-lock.json are provided, the package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock is also provided, the versions here will override the versions in those lock files.
52
+ */
53
+ nodeModules?: {
54
+ [key: string]: (string);
55
+ } | null;
56
+ /**
57
+ * The environment variables that the website can access
58
+ * e.g. { \"RESEND_API_KEY\": \"re_123456789\" }
59
+ */
60
+ envVars?: {
61
+ [key: string]: (string);
62
+ } | null;
63
+ serverStartCheck?: boolean;
64
+ };
65
+ type FreestyleDeployWebErrorResponse = {
66
+ message: string;
67
+ };
68
+ type FreestyleDeployWebPayload = {
69
+ /**
70
+ * The files to deploy, a map of file paths to file contents, e.g. { \"index.js\": {\"content\": \"your main\", \"encoding\": \"utf-8\"}, \"file2.js\": {\"content\": \"your helper\" } }
71
+ *
72
+ * **Do not include node modules in this bundle, they will not work**. Instead, includes a package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock, the node modules for the project will be installed from that lock file, or use the node_modules field in the configuration to specify the node modules to install.
73
+ */
74
+ files: {
75
+ [key: string]: FreestyleFile;
76
+ };
77
+ config?: FreestyleDeployWebConfiguration;
78
+ };
79
+ type FreestyleDeployWebSuccessResponse = {
80
+ deploymentId: string;
81
+ domains?: Array<(string)> | null;
82
+ /**
83
+ * @deprecated
84
+ */
85
+ projectId?: (string) | null;
86
+ };
87
+ type FreestyleDomainVerificationRequest = {
88
+ /**
89
+ * The domain to create a verification code for
90
+ */
91
+ domain: string;
92
+ };
93
+ type FreestyleExecureScriptResultError = {
94
+ error: string;
95
+ };
96
+ type FreestyleExecureScriptResultSuccess = {
97
+ result: unknown;
98
+ logs: Array<JavaScriptLog>;
99
+ };
100
+ type FreestyleExecuteScriptParams = {
101
+ /**
102
+ * The JavaScript or TypeScript script to execute
103
+ */
104
+ script: string;
105
+ config?: FreestyleExecuteScriptParamsConfiguration;
106
+ };
107
+ type FreestyleExecuteScriptParamsConfiguration = {
108
+ /**
109
+ * The environment variables to set for the script
110
+ */
111
+ envVars?: {
112
+ [key: string]: (string);
113
+ };
114
+ /**
115
+ * The node modules to install for the script
116
+ */
117
+ nodeModules?: {
118
+ [key: string]: (string);
119
+ };
120
+ /**
121
+ * Tags for you to organize your scripts, useful for tracking what you're running
122
+ */
123
+ tags?: Array<(string)>;
124
+ /**
125
+ * The script timeout
126
+ */
127
+ timeout?: (string) | null;
128
+ /**
129
+ * If false, we'll not resolve peer dependencies for the packages given, this can speed up execute performance, but will break packages with peers unless the peers are manually specified.
130
+ */
131
+ peerDependencyResolution?: boolean;
132
+ };
133
+ type FreestyleFile = {
134
+ /**
135
+ * The content of the file
136
+ */
137
+ content: string;
138
+ /**
139
+ * The encoding of the file. Either **utf-8** or **base64**
140
+ */
141
+ encoding?: string;
142
+ };
143
+ type FreestyleLogResponseObject = {
144
+ message: string;
145
+ };
146
+ type FreestyleVerifyDomainRequest = {
147
+ domain: string;
148
+ };
149
+ type JavaScriptLog = {
150
+ /**
151
+ * The log message
152
+ */
153
+ message: string;
154
+ /**
155
+ * The log level
156
+ */
157
+ type: string;
158
+ };
159
+ type HandleDeployCloudstateData = {
160
+ body: FreestyleCloudstateDeployRequest;
161
+ };
162
+ type HandleDeployCloudstateResponse = (FreestyleCloudstateDeploySuccessResponse);
163
+ type HandleDeployCloudstateError = (FreestyleCloudstateDeployErrorResponse);
164
+ type HandleBackupCloudstateData = {
165
+ path: {
166
+ id: string;
167
+ };
168
+ };
169
+ type HandleBackupCloudstateResponse = (Array<(number)>);
170
+ type HandleBackupCloudstateError = (unknown);
171
+ type HandleListDomainsResponse = (Array<{
172
+ domain: string;
173
+ createdAt: number;
174
+ }>);
175
+ type HandleListDomainsError = ({
176
+ message: string;
177
+ });
178
+ type HandleListDomainVerificationRequestsResponse = (Array<{
179
+ verificationCode: string;
180
+ domain: string;
181
+ createdAt: number;
182
+ }>);
183
+ type HandleListDomainVerificationRequestsError = ({
184
+ message: string;
185
+ });
186
+ type HandleVerifyDomainData = {
187
+ body: FreestyleVerifyDomainRequest;
188
+ };
189
+ type HandleVerifyDomainResponse = ({
190
+ domain: string;
191
+ });
192
+ type HandleVerifyDomainError = ({
193
+ message: string;
194
+ });
195
+ type HandleCreateDomainVerificationData = {
196
+ body: FreestyleDomainVerificationRequest;
197
+ };
198
+ type HandleCreateDomainVerificationResponse = ({
199
+ verificationCode: string;
200
+ domain: string;
201
+ });
202
+ type HandleCreateDomainVerificationError = ({
203
+ message: string;
204
+ });
205
+ type HandleDeleteDomainVerificationData = {
206
+ body: FreestyleDeleteDomainVerificationRequest;
207
+ };
208
+ type HandleDeleteDomainVerificationResponse = ({
209
+ verificationCode: string;
210
+ domain: string;
211
+ });
212
+ type HandleDeleteDomainVerificationError = ({
213
+ message: string;
214
+ });
215
+ type HandleExecuteScriptData = {
216
+ body: FreestyleExecuteScriptParams;
217
+ };
218
+ type HandleExecuteScriptResponse = (FreestyleExecureScriptResultSuccess);
219
+ type HandleExecuteScriptError = (FreestyleExecureScriptResultError);
220
+ type HandleDeployWebData = {
221
+ body: FreestyleDeployWebPayload;
222
+ };
223
+ type HandleDeployWebResponse = (FreestyleDeployWebSuccessResponse);
224
+ type HandleDeployWebError = (FreestyleDeployWebErrorResponse);
225
+ type HandleGetLogsData = {
226
+ path: {
227
+ id: string;
228
+ };
229
+ };
230
+ type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
231
+ type HandleGetLogsError = unknown;
232
+
233
+ export type { HandleBackupCloudstateError as A, HandleListDomainsError as B, HandleListDomainVerificationRequestsError as C, HandleVerifyDomainData as D, HandleVerifyDomainError as E, FreestyleExecuteScriptParamsConfiguration as F, HandleCreateDomainVerificationData as G, HandleBackupCloudstateResponse as H, HandleCreateDomainVerificationError as I, JavaScriptLog as J, HandleDeleteDomainVerificationData as K, HandleDeleteDomainVerificationError as L, HandleExecuteScriptData as M, HandleExecuteScriptResponse as N, HandleExecuteScriptError as O, HandleDeployWebData as P, HandleDeployWebResponse as Q, HandleDeployWebError as R, HandleGetLogsData as S, HandleGetLogsError as T, FreestyleExecureScriptResultSuccess as a, FreestyleDeployWebConfiguration as b, FreestyleDeployWebSuccessResponse as c, FreestyleCloudstateDeployRequest as d, FreestyleCloudstateDeploySuccessResponse as e, HandleGetLogsResponse as f, HandleCreateDomainVerificationResponse as g, HandleVerifyDomainResponse as h, HandleListDomainsResponse as i, HandleListDomainVerificationRequestsResponse as j, HandleDeleteDomainVerificationResponse as k, FreestyleCloudstateDeployConfiguration as l, FreestyleCloudstateDeployErrorResponse as m, FreestyleDeleteDomainVerificationRequest as n, FreestyleDeployWebErrorResponse as o, FreestyleDeployWebPayload as p, FreestyleDomainVerificationRequest as q, FreestyleExecureScriptResultError as r, FreestyleExecuteScriptParams as s, FreestyleFile as t, FreestyleLogResponseObject as u, FreestyleVerifyDomainRequest as v, HandleDeployCloudstateData as w, HandleDeployCloudstateResponse as x, HandleDeployCloudstateError as y, HandleBackupCloudstateData as z };
@@ -1,7 +1,7 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
 
3
3
  import { createClient, createConfig, type OptionsLegacyParser } from '@hey-api/client-fetch';
4
- import type { HandleDeployCloudstateData, HandleDeployCloudstateError, HandleDeployCloudstateResponse, HandleBackupCloudstateData, HandleBackupCloudstateError, HandleBackupCloudstateResponse, HandleListDomainsError, HandleListDomainsResponse, HandleVerifyDomainData, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleCreateDomainVerificationData, HandleCreateDomainVerificationError, HandleCreateDomainVerificationResponse, HandleExecuteScriptData, HandleExecuteScriptError, HandleExecuteScriptResponse, HandleDeployWebData, HandleDeployWebError, HandleDeployWebResponse, HandleGetLogsData, HandleGetLogsError, HandleGetLogsResponse } from './types.gen';
4
+ import type { HandleDeployCloudstateData, HandleDeployCloudstateError, HandleDeployCloudstateResponse, HandleBackupCloudstateData, HandleBackupCloudstateError, HandleBackupCloudstateResponse, HandleListDomainsError, HandleListDomainsResponse, HandleListDomainVerificationRequestsError, HandleListDomainVerificationRequestsResponse, HandleVerifyDomainData, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleCreateDomainVerificationData, HandleCreateDomainVerificationError, HandleCreateDomainVerificationResponse, HandleDeleteDomainVerificationData, HandleDeleteDomainVerificationError, HandleDeleteDomainVerificationResponse, HandleExecuteScriptData, HandleExecuteScriptError, HandleExecuteScriptResponse, HandleDeployWebData, HandleDeployWebError, HandleDeployWebResponse, HandleGetLogsData, HandleGetLogsError, HandleGetLogsResponse } from './types.gen';
5
5
 
6
6
  export const client = createClient(createConfig());
7
7
 
@@ -38,6 +38,17 @@ export const handleListDomains = <ThrowOnError extends boolean = false>(options?
38
38
  });
39
39
  };
40
40
 
41
+ /**
42
+ * List domain verification requests for an account
43
+ * Lists domain verification requests for the current account.
44
+ */
45
+ export const handleListDomainVerificationRequests = <ThrowOnError extends boolean = false>(options?: OptionsLegacyParser<unknown, ThrowOnError>) => {
46
+ return (options?.client ?? client).get<HandleListDomainVerificationRequestsResponse, HandleListDomainVerificationRequestsError, ThrowOnError>({
47
+ ...options,
48
+ url: '/domains/v1/verifications'
49
+ });
50
+ };
51
+
41
52
  /**
42
53
  * Verify a domain
43
54
  * This checks a pre-existing verification request for a domain. To create a verification request, call the [create domain verification](/#tag/domains/POST/domains/v1/verifications) endpoint. This endpoint will check if the domain has a TXT record with the verification code. If it does, the domain will be verified.
@@ -60,6 +71,17 @@ export const handleCreateDomainVerification = <ThrowOnError extends boolean = fa
60
71
  });
61
72
  };
62
73
 
74
+ /**
75
+ * Delete a domain verification request
76
+ * This deletes a Freestyle Domain Verification Request. This does not remove the domain from the account if it has already been verified, however the verification code will no longer be valid.
77
+ */
78
+ export const handleDeleteDomainVerification = <ThrowOnError extends boolean = false>(options: OptionsLegacyParser<HandleDeleteDomainVerificationData, ThrowOnError>) => {
79
+ return (options?.client ?? client).delete<HandleDeleteDomainVerificationResponse, HandleDeleteDomainVerificationError, ThrowOnError>({
80
+ ...options,
81
+ url: '/domains/v1/verifications'
82
+ });
83
+ };
84
+
63
85
  /**
64
86
  * Execute Code
65
87
  * Send a TypeScript or JavaScript module, get the result
@@ -29,6 +29,17 @@ export type FreestyleCloudstateDeploySuccessResponse = {
29
29
  projectId: string;
30
30
  };
31
31
 
32
+ export type FreestyleDeleteDomainVerificationRequest = {
33
+ /**
34
+ * The domain to create a verification code for
35
+ */
36
+ domain: string;
37
+ /**
38
+ * The verification code
39
+ */
40
+ verificationCode: string;
41
+ };
42
+
32
43
  export type FreestyleDeployWebConfiguration = {
33
44
  /**
34
45
  * The entrypoint file for the website
@@ -56,6 +67,7 @@ export type FreestyleDeployWebConfiguration = {
56
67
  envVars?: {
57
68
  [key: string]: (string);
58
69
  } | null;
70
+ serverStartCheck?: boolean;
59
71
  };
60
72
 
61
73
  export type FreestyleDeployWebErrorResponse = {
@@ -76,6 +88,11 @@ export type FreestyleDeployWebPayload = {
76
88
 
77
89
  export type FreestyleDeployWebSuccessResponse = {
78
90
  deploymentId: string;
91
+ domains?: Array<(string)> | null;
92
+ /**
93
+ * @deprecated
94
+ */
95
+ projectId?: (string) | null;
79
96
  };
80
97
 
81
98
  export type FreestyleDomainVerificationRequest = {
@@ -123,6 +140,10 @@ export type FreestyleExecuteScriptParamsConfiguration = {
123
140
  * The script timeout
124
141
  */
125
142
  timeout?: (string) | null;
143
+ /**
144
+ * If false, we'll not resolve peer dependencies for the packages given, this can speed up execute performance, but will break packages with peers unless the peers are manually specified.
145
+ */
146
+ peerDependencyResolution?: boolean;
126
147
  };
127
148
 
128
149
  export type FreestyleFile = {
@@ -182,6 +203,16 @@ export type HandleListDomainsError = ({
182
203
  message: string;
183
204
  });
184
205
 
206
+ export type HandleListDomainVerificationRequestsResponse = (Array<{
207
+ verificationCode: string;
208
+ domain: string;
209
+ createdAt: number;
210
+ }>);
211
+
212
+ export type HandleListDomainVerificationRequestsError = ({
213
+ message: string;
214
+ });
215
+
185
216
  export type HandleVerifyDomainData = {
186
217
  body: FreestyleVerifyDomainRequest;
187
218
  };
@@ -207,6 +238,19 @@ export type HandleCreateDomainVerificationError = ({
207
238
  message: string;
208
239
  });
209
240
 
241
+ export type HandleDeleteDomainVerificationData = {
242
+ body: FreestyleDeleteDomainVerificationRequest;
243
+ };
244
+
245
+ export type HandleDeleteDomainVerificationResponse = ({
246
+ verificationCode: string;
247
+ domain: string;
248
+ });
249
+
250
+ export type HandleDeleteDomainVerificationError = ({
251
+ message: string;
252
+ });
253
+
210
254
  export type HandleExecuteScriptData = {
211
255
  body: FreestyleExecuteScriptParams;
212
256
  };
package/openapi.json CHANGED
@@ -1 +1 @@
1
- {"openapi":"3.1.0","info":{"title":"Freestyle Sandboxes","description":"\nFreestyle Sandboxes lets you deploy your users or AIs code. **Get your API Key at [admin.freestyle.sh](https://admin.freestyle.sh)**\n\nThey are broken up into 4 categories: [Web](#tag/web), [Execute](#tag/execute) [Cloudstate](#tag/cloudstate), and [Domains](#tag/domains).\n\n[Web](#tag/web): Send us the code for the website, we'll provision the certificates and get it hosted\n\n[Execute](#tag/execute): Send us a function, we'll run it and send you the output\n\n[Cloudstate](#tag/cloudstate): Our Opensource JavaScript Runtime used for cloud functions with persistent state\n\n[Domains](#tag/domains): Manage your domains, including verification and listing\n","contact":{"name":"Ben","email":"ben@freestyle.sh"},"license":{"name":""},"version":"0.1.0"},"servers":[{"url":"https://api.freestyle.sh","description":"Production"}],"paths":{"/cloudstate/v1/deploy":{"post":{"tags":["Cloudstate"],"summary":"Deploy Cloudstate Project","description":"Deploy a cloudstate project","operationId":"handle_deploy_cloudstate","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeployRequest"}}},"required":true},"responses":{"200":{"description":"successfully deployed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeploySuccessResponse"}}}},"500":{"description":"failed to deploy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeployErrorResponse"}}}}}}},"/cloudstate/v1/projects/{id}/backup":{"get":{"tags":["Cloudstate"],"summary":"Get Backup of Cloudstate Project","description":"Get a backup of a cloudstate project","operationId":"handle_backup_cloudstate","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"successfully backed up","content":{"application/octet-stream":{"schema":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}}}}},"500":{"description":"failed to backup"}}}},"/domains/v1/domains":{"get":{"tags":["Domains"],"summary":"List domains for an account","description":"This lists the domains that an account has verified ownership of. This includes the *.style.dev domains the account has claimed.","operationId":"handle_list_domains","responses":{"200":{"description":"List of domains","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","required":["domain","createdAt"],"properties":{"domain":{"type":"string","example":"example.yourdomain.com"},"createdAt":{"type":"integer","format":"int64"}}}}}}},"400":{"description":"Failed to get domains","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst sandboxes = new FreestyleSandboxes({\n apiKey: 'your-api-key',\n});\n\nsandboxes.listDomains().then((response) => {\n console.log(response);\n});"}]}},"/domains/v1/verifications":{"put":{"tags":["Domains"],"summary":"Verify a domain","description":"This checks a pre-existing verification request for a domain. To create a verification request, call the [create domain verification](/#tag/domains/POST/domains/v1/verifications) endpoint. This endpoint will check if the domain has a TXT record with the verification code. If it does, the domain will be verified.","operationId":"handle_verify_domain","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleVerifyDomainRequest"}}},"required":true},"responses":{"200":{"description":"Domain verified","content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to verify domain","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi\n .verifyDomain('example.com')\n .then((result) => {\n console.log('Successfully Verified Domain!');\n })\n .catch((error) => {\n console.error('Failed to verify domain: ', error);\n });"}]},"post":{"tags":["Domains"],"summary":"Create a domain verification request","description":"This creates a Freestyle Domain Verification Request. It returns a `verificationCode` for your domain. You need to place this code in a TXT record at `_freestyle_custom_hostname.thedomain.com`, then call the [verify domain](/#tag/domains/PUT/domains/v1/verifications) endpoint with the domain to verify it.","operationId":"handle_create_domain_verification","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDomainVerificationRequest"}}},"required":true},"responses":{"200":{"description":"Verification code created","content":{"application/json":{"schema":{"type":"object","required":["verificationCode","domain"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to create verification code","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi.createDomainVerificationRequest('example.com').then((result) => {\n const verificationCode = result.verificationCode;\n // put this at a TXT record at _freestyle_custom_hostname.example.com\n});"}]}},"/execute/v1/script":{"post":{"tags":["Execute"],"summary":"Execute Code","description":"Send a TypeScript or JavaScript module, get the result","operationId":"handle_execute_script","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecuteScriptParams"}}},"required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultSuccess"}}}},"400":{"description":"Error in your Script","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultError"}}}},"500":{"description":"Internal Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultError"}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst sandboxes = new FreestyleSandboxes({\n apiKey: 'your-api-key',\n});\n\nsandboxes.executeScript(\n `export default () => {\n let set1 = [1, 2, 3, 4, 5];\n let set2 = [4, 5, 6, 7, 8];\n\n // find the sum of every value of each set multiplied by every value of the other set\n\n let sum = 0;\n for (let i = 0; i < set1.length; i++) {\n for (let j = 0; j < set2.length; j++) {\n sum += set1[i] * set2[j];\n }\n }\n\n return sum;\n};`\n);"},{"label":"AI SDK","lang":"JavaScript","source":"import { executeTool } from 'freestyle-sandboxes/ai';\nimport { generateText } from 'ai';\n\nconst codeExecutor = executeTool({\n apiKey: 'your-api-key',\n});\n\nconst { text, steps } = await generateText({\n model: yourModel,\n tools: {\n codeExecutor,\n },\n maxSteps: 2,\n prompt:\n 'What is the sum of every number between 1 and 12 multiplied by itself?',\n});"}]}},"/web/v1/deploy":{"post":{"tags":["Web"],"summary":"Deploy a Website","description":"Deploy a website. Files is a map of file paths to file contents. Configuration is optional and contains additional information about the deployment.","operationId":"handle_deploy_web","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebPayload"}}},"required":true},"responses":{"200":{"description":"successfully deployed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebSuccessResponse"}}}},"400":{"description":"failed to deploy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebErrorResponse"}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\nimport 'dotenv/config';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi\n .deployWeb({\n 'index.js': {\n content:`\n import http from 'node:http';\n console.log('starting server');\n\n const server = http.createServer(async(req, res) => {\n // wait 5 seconds before responding\n // await new Promise((resolve) => setTimeout(resolve, 5000));\n res.writeHead(200, { 'Content-Type': 'text/plain' });\n res.end('Welcome to New York its been waiting for you');\n });\n\n server.listen(3000, () => {\n console.log('Server is running at http://localhost:3000');\n });`,\n })\n .then((result) => {\n console.log('Deployed website @ ', result.projectId);\n });\n"},{"label":"AI SDK","lang":"JavaScript","source":"import { deployWebTool } from 'freestyle-sandboxes/ai';\nimport { generateText } from 'ai';\n\nconst deployer = deployWebTool({\n apiKey: 'your-api-key',\n});\n\nconst { text, steps } = await generateText({\n model: yourModel,\n tools: {\n deployer,\n },\n maxSteps: 2,\n prompt:\n 'Deploy a website to subdomain.yourdomain.com that has all the lyrics to Sandstorm by Darude on the homepage',\n});"}]}},"/web/v1/projects/{id}/logs":{"get":{"tags":["Web"],"summary":"Get Website Logs","description":"Get the logs for a project","operationId":"handle_get_logs","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FreestyleLogResponseObject"}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\nimport 'dotenv/config';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi.getWebLogs('1234abcd-5678-efgh-ijkl-9012mnop3456').then((logs) => {\n console.log('Logs for project 1234abcd-5678-efgh-ijkl-9012mnop3456: ', logs);\n});"}]}}},"components":{"schemas":{"FreestyleCloudstateDeployConfiguration":{"type":"object","properties":{"projectId":{"type":["string","null"],"description":"ID of the project to deploy, if not provided will create a new project","default":null},"envVars":{"type":"object","description":"The environment variables that the cloudstate deploy can access","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"}}}},"FreestyleCloudstateDeployErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleCloudstateDeployRequest":{"type":"object","required":["classes"],"properties":{"classes":{"type":"string"},"config":{"$ref":"#/components/schemas/FreestyleCloudstateDeployConfiguration"}}},"FreestyleCloudstateDeploySuccessResponse":{"type":"object","required":["projectId"],"properties":{"projectId":{"type":"string","description":"The id of the project deployed to"}}},"FreestyleDeployWebConfiguration":{"type":"object","properties":{"entrypoint":{"type":["string","null"],"description":"The entrypoint file for the website","default":"index.js"},"domains":{"type":["array","null"],"items":{"type":"string"},"description":"The custom domains for the website, eg. [\\\"subdomain.yourwebsite.com\\\"]. You may include a single *.style.dev domain here.","example":["subdomain.yourdomain.com"],"default":null},"projectId":{"type":["string","null"],"description":"Project ID was our original way of tracking deployments together, it is now deprecated and will be removed in the future. Please use the domains field to specify the domains for your project.","default":null,"deprecated":true},"nodeModules":{"type":["object","null"],"description":"Node Modules to install for the website, a map of package names to versions, e.g. { \\\"express\\\": \\\"4.17.1\\\" }. If this and a package-lock.json are provided, the package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock is also provided, the versions here will override the versions in those lock files.","default":null,"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"resend":"4.0.1"}},"envVars":{"type":["object","null"],"description":"The environment variables that the website can access\ne.g. { \\\"RESEND_API_KEY\\\": \\\"re_123456789\\\" }","default":null,"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"RESEND_API_KEY":"re_123456789"}}}},"FreestyleDeployWebErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleDeployWebPayload":{"type":"object","required":["files"],"properties":{"files":{"type":"object","description":"The files to deploy, a map of file paths to file contents, e.g. { \\\"index.js\\\": {\\\"content\\\": \\\"your main\\\", \\\"encoding\\\": \\\"utf-8\\\"}, \\\"file2.js\\\": {\\\"content\\\": \\\"your helper\\\" } }\n\n**Do not include node modules in this bundle, they will not work**. Instead, includes a package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock, the node modules for the project will be installed from that lock file, or use the node_modules field in the configuration to specify the node modules to install.","additionalProperties":{"$ref":"#/components/schemas/FreestyleFile"},"propertyNames":{"type":"string"},"example":{"index.js":{"content":"import http from 'node:http';\\n// import { resolver } from './file2.js';\\n\\nconsole.log('starting server');\\n\\nconst server = http.createServer(async(req, res) => {\\n // wait 5 seconds before responding\\n // await new Promise((resolve) => setTimeout(resolve, 5000));\\n res.writeHead(200, { 'Content-Type': 'text/plain' });\\n res.end('Welcome to New York its been waiting for you');\\n});\\n\\nserver.listen(3000, () => {\\n console.log('Server is running at http://localhost:3000');\\n});"}}},"config":{"$ref":"#/components/schemas/FreestyleDeployWebConfiguration"}}},"FreestyleDeployWebSuccessResponse":{"type":"object","required":["deploymentId"],"properties":{"deploymentId":{"type":"string"}}},"FreestyleDomainVerificationRequest":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"The domain to create a verification code for","example":"example.com"}}},"FreestyleExecureScriptResultError":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"FreestyleExecureScriptResultSuccess":{"type":"object","required":["result","logs"],"properties":{"result":{},"logs":{"type":"array","items":{"$ref":"#/components/schemas/JavaScriptLog"}}}},"FreestyleExecuteScriptParams":{"type":"object","required":["script"],"properties":{"script":{"type":"string","description":"The JavaScript or TypeScript script to execute","example":"export default () => {\n // get the value of the factorials of the numbers from 1 to 10 combined\n const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\n function factorial(n) {\n if (n === 0) {\n return 1;\n }\n return n * factorial(n - 1);\n }\n\n const b = a.map(factorial);\n\n return b.reduce((a, b) => a + b);\n};\n"},"config":{"$ref":"#/components/schemas/FreestyleExecuteScriptParamsConfiguration"}}},"FreestyleExecuteScriptParamsConfiguration":{"type":"object","properties":{"envVars":{"type":"object","description":"The environment variables to set for the script","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"RESEND_API_KEY":"re_123456789"}},"nodeModules":{"type":"object","description":"The node modules to install for the script","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"resend":"4.0.1"}},"tags":{"type":"array","items":{"type":"string"},"description":"Tags for you to organize your scripts, useful for tracking what you're running","example":["email"],"default":[]},"timeout":{"type":["string","null"],"description":"The script timeout","default":null}}},"FreestyleFile":{"type":"object","required":["content"],"properties":{"content":{"type":"string","description":"The content of the file"},"encoding":{"type":"string","description":"The encoding of the file. Either **utf-8** or **base64**"}}},"FreestyleLogResponseObject":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleVerifyDomainRequest":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}},"JavaScriptLog":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"The log message"},"type":{"type":"string","description":"The log level"}}}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"tags":[{"name":"Web","description":"APIs for deploying websites. We handle node modules caching, scaling, certificates and the whole end to end process. Send the code using the [deploy](#tag/web/POST/web/v1/deploy) endpoint, and you'll get a full hosted website back. Works with any TypeScript or JavaScript codebase."},{"name":"Execute","description":"APIs for running code. Send the code using the [execute](#tag/execute/POST/execute/v1/execute) endpoint, and you'll get the output back. Works with any TypeScript or JavaScript code + handles any node modules and environment variables you want."},{"name":"Cloudstate","description":"APIs for running cloud functions with persistent state. [Cloudstate](https://github.com/freestyle-sh/cloudstate/) is an opensource, durable JavaScript runtime maintained by the Freestyle Team."},{"name":"Domains","description":"APIs for managing domains. This is only relevant when you want to start to deploy to custom domains."}]}
1
+ {"openapi":"3.1.0","info":{"title":"Freestyle Sandboxes","description":"\nFreestyle Sandboxes lets you deploy your users or AIs code. **Get your API Key at [admin.freestyle.sh](https://admin.freestyle.sh)**\n\nThey are broken up into 4 categories: [Web](#tag/web), [Execute](#tag/execute), [Cloudstate](#tag/cloudstate), and [Domains](#tag/domains).\n\n[Web](#tag/web): Send us the code for the website, we'll provision the certificates and get it hosted\n\n[Execute](#tag/execute): Send us a function, we'll run it and send you the output\n\n[Cloudstate](#tag/cloudstate): Our Opensource JavaScript Runtime used for cloud functions with persistent state\n\n[Domains](#tag/domains): Manage your domains, including verification and listing\n","contact":{"name":"Ben","email":"ben@freestyle.sh"},"license":{"name":""},"version":"0.1.0"},"servers":[{"url":"https://api.freestyle.sh","description":"Production"}],"paths":{"/cloudstate/v1/deploy":{"post":{"tags":["Cloudstate"],"summary":"Deploy Cloudstate Project","description":"Deploy a cloudstate project","operationId":"handle_deploy_cloudstate","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeployRequest"}}},"required":true},"responses":{"200":{"description":"successfully deployed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeploySuccessResponse"}}}},"500":{"description":"failed to deploy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeployErrorResponse"}}}}}}},"/cloudstate/v1/projects/{id}/backup":{"get":{"tags":["Cloudstate"],"summary":"Get Backup of Cloudstate Project","description":"Get a backup of a cloudstate project","operationId":"handle_backup_cloudstate","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"successfully backed up","content":{"application/octet-stream":{"schema":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}}}}},"500":{"description":"failed to backup"}}}},"/domains/v1/domains":{"get":{"tags":["Domains"],"summary":"List domains for an account","description":"This lists the domains that an account has verified ownership of. This includes the *.style.dev domains the account has claimed.","operationId":"handle_list_domains","responses":{"200":{"description":"List of domains","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","required":["domain","createdAt"],"properties":{"domain":{"type":"string","example":"example.yourdomain.com"},"createdAt":{"type":"integer","format":"int64"}}}}}}},"400":{"description":"Failed to get domains","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst sandboxes = new FreestyleSandboxes({\n apiKey: 'your-api-key',\n});\n\nsandboxes.listDomains().then((response) => {\n console.log(response);\n});"}]}},"/domains/v1/verifications":{"get":{"tags":["Domains"],"summary":"List domain verification requests for an account","description":"Lists domain verification requests for the current account.","operationId":"handle_list_domain_verification_requests","responses":{"200":{"description":"List of verification codes","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","required":["verificationCode","domain","createdAt"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string"},"createdAt":{"type":"integer","format":"int64"}}}}}}},"400":{"description":"Failed to get verification codes","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}},"put":{"tags":["Domains"],"summary":"Verify a domain","description":"This checks a pre-existing verification request for a domain. To create a verification request, call the [create domain verification](/#tag/domains/POST/domains/v1/verifications) endpoint. This endpoint will check if the domain has a TXT record with the verification code. If it does, the domain will be verified.","operationId":"handle_verify_domain","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleVerifyDomainRequest"}}},"required":true},"responses":{"200":{"description":"Domain verified","content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to verify domain","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi\n .verifyDomain('example.com')\n .then((result) => {\n console.log('Successfully Verified Domain!');\n })\n .catch((error) => {\n console.error('Failed to verify domain: ', error);\n });"}]},"post":{"tags":["Domains"],"summary":"Create a domain verification request","description":"This creates a Freestyle Domain Verification Request. It returns a `verificationCode` for your domain. You need to place this code in a TXT record at `_freestyle_custom_hostname.thedomain.com`, then call the [verify domain](/#tag/domains/PUT/domains/v1/verifications) endpoint with the domain to verify it.","operationId":"handle_create_domain_verification","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDomainVerificationRequest"}}},"required":true},"responses":{"200":{"description":"Verification code created","content":{"application/json":{"schema":{"type":"object","required":["verificationCode","domain"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to create verification code","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi.createDomainVerificationRequest('example.com').then((result) => {\n const verificationCode = result.verificationCode;\n // put this at a TXT record at _freestyle_custom_hostname.example.com\n});"}]},"delete":{"tags":["Domains"],"summary":"Delete a domain verification request","description":"This deletes a Freestyle Domain Verification Request. This does not remove the domain from the account if it has already been verified, however the verification code will no longer be valid.","operationId":"handle_delete_domain_verification","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeleteDomainVerificationRequest"}}},"required":true},"responses":{"200":{"description":"Verification code created","content":{"application/json":{"schema":{"type":"object","required":["verificationCode","domain"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to create verification code","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"/execute/v1/script":{"post":{"tags":["Execute"],"summary":"Execute Code","description":"Send a TypeScript or JavaScript module, get the result","operationId":"handle_execute_script","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecuteScriptParams"}}},"required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultSuccess"}}}},"400":{"description":"Error in your Script","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultError"}}}},"500":{"description":"Internal Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultError"}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst sandboxes = new FreestyleSandboxes({\n apiKey: 'your-api-key',\n});\n\nsandboxes.executeScript(\n `export default () => {\n let set1 = [1, 2, 3, 4, 5];\n let set2 = [4, 5, 6, 7, 8];\n\n // find the sum of every value of each set multiplied by every value of the other set\n\n let sum = 0;\n for (let i = 0; i < set1.length; i++) {\n for (let j = 0; j < set2.length; j++) {\n sum += set1[i] * set2[j];\n }\n }\n\n return sum;\n};`\n);"},{"label":"Vercel AI SDK","lang":"JavaScript","source":"import { executeTool } from 'freestyle-sandboxes/ai';\nimport { generateText } from 'ai';\n\nconst codeExecutor = executeTool({\n apiKey: 'your-api-key',\n});\n\nconst { text, steps } = await generateText({\n model: yourModel,\n tools: {\n codeExecutor,\n },\n maxSteps: 2,\n prompt:\n 'What is the sum of every number between 1 and 12 multiplied by itself?',\n});"},{"label":"Mastra AI SDK","lang":"JavaScript","source":"import { executeTool } from 'freestyle-sandboxes/mastra';\n\nconst mastra = new Mastra();\n\nconst modelConfig: ModelConfig = {\n provider: 'OPEN_AI',\n name: 'gpt-4',\n};\n\nconst llm = mastra.LLM(modelConfig);\n\nconst response = await llm.generate(\n 'Calculate the sum of every number between 13 and 19 divided by the sum of every number between 8 and 13',\n {\n tools: {\n executor: executeTool({\n apiKey: process.env.FREESTYLE_API_KEY!,\n }),\n },\n }\n);\n\nconsole.log('Response Steps:', response.steps);\nconsole.log('Response:', response.text);"}]}},"/web/v1/deploy":{"post":{"tags":["Web"],"summary":"Deploy a Website","description":"Deploy a website. Files is a map of file paths to file contents. Configuration is optional and contains additional information about the deployment.","operationId":"handle_deploy_web","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebPayload"}}},"required":true},"responses":{"200":{"description":"successfully deployed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebSuccessResponse"}}}},"400":{"description":"failed to deploy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebErrorResponse"}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\nimport 'dotenv/config';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi\n .deployWeb({\n 'index.js': {\n content:`\n import http from 'node:http';\n console.log('starting server');\n\n const server = http.createServer(async(req, res) => {\n // wait 5 seconds before responding\n // await new Promise((resolve) => setTimeout(resolve, 5000));\n res.writeHead(200, { 'Content-Type': 'text/plain' });\n res.end('Welcome to New York its been waiting for you');\n });\n\n server.listen(3000, () => {\n console.log('Server is running at http://localhost:3000');\n });`,\n })\n .then((result) => {\n console.log('Deployed website @ ', result.deploymentId);\n });\n"},{"label":"Vercel AI SDK","lang":"JavaScript","source":"import { deployWebTool } from 'freestyle-sandboxes/ai';\nimport { generateText } from 'ai';\n\nconst deployer = deployWebTool({\n apiKey: 'your-api-key',\n});\n\nconst { text, steps } = await generateText({\n model: yourModel,\n tools: {\n deployer,\n },\n maxSteps: 2,\n prompt:\n 'Deploy a website to subdomain.yourdomain.com that has all the lyrics to Sandstorm by Darude on the homepage',\n});"}]}},"/web/v1/projects/{id}/logs":{"get":{"tags":["Web"],"summary":"Get Website Logs","description":"Get the logs for a project","operationId":"handle_get_logs","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FreestyleLogResponseObject"}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\nimport 'dotenv/config';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi.getWebLogs('1234abcd-5678-efgh-ijkl-9012mnop3456').then((logs) => {\n console.log('Logs for project 1234abcd-5678-efgh-ijkl-9012mnop3456: ', logs);\n});"}]}}},"components":{"schemas":{"FreestyleCloudstateDeployConfiguration":{"type":"object","properties":{"projectId":{"type":["string","null"],"description":"ID of the project to deploy, if not provided will create a new project","default":null},"envVars":{"type":"object","description":"The environment variables that the cloudstate deploy can access","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"}}}},"FreestyleCloudstateDeployErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleCloudstateDeployRequest":{"type":"object","required":["classes"],"properties":{"classes":{"type":"string"},"config":{"$ref":"#/components/schemas/FreestyleCloudstateDeployConfiguration"}}},"FreestyleCloudstateDeploySuccessResponse":{"type":"object","required":["projectId"],"properties":{"projectId":{"type":"string","description":"The id of the project deployed to"}}},"FreestyleDeleteDomainVerificationRequest":{"type":"object","required":["domain","verificationCode"],"properties":{"domain":{"type":"string","description":"The domain to create a verification code for","example":"example.com"},"verificationCode":{"type":"string","description":"The verification code"}}},"FreestyleDeployWebConfiguration":{"type":"object","properties":{"entrypoint":{"type":["string","null"],"description":"The entrypoint file for the website","default":"index.js"},"domains":{"type":["array","null"],"items":{"type":"string"},"description":"The custom domains for the website, eg. [\\\"subdomain.yourwebsite.com\\\"]. You may include a single *.style.dev domain here.","example":["subdomain.yourdomain.com"],"default":null},"projectId":{"type":["string","null"],"description":"Project ID was our original way of tracking deployments together, it is now deprecated and will be removed in the future. Please use the domains field to specify the domains for your project.","default":null,"deprecated":true},"nodeModules":{"type":["object","null"],"description":"Node Modules to install for the website, a map of package names to versions, e.g. { \\\"express\\\": \\\"4.17.1\\\" }. If this and a package-lock.json are provided, the package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock is also provided, the versions here will override the versions in those lock files.","default":null,"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"resend":"4.0.1"}},"envVars":{"type":["object","null"],"description":"The environment variables that the website can access\ne.g. { \\\"RESEND_API_KEY\\\": \\\"re_123456789\\\" }","default":null,"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"RESEND_API_KEY":"re_123456789"}},"serverStartCheck":{"type":"boolean","default":false}}},"FreestyleDeployWebErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleDeployWebPayload":{"type":"object","required":["files"],"properties":{"files":{"type":"object","description":"The files to deploy, a map of file paths to file contents, e.g. { \\\"index.js\\\": {\\\"content\\\": \\\"your main\\\", \\\"encoding\\\": \\\"utf-8\\\"}, \\\"file2.js\\\": {\\\"content\\\": \\\"your helper\\\" } }\n\n**Do not include node modules in this bundle, they will not work**. Instead, includes a package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock, the node modules for the project will be installed from that lock file, or use the node_modules field in the configuration to specify the node modules to install.","additionalProperties":{"$ref":"#/components/schemas/FreestyleFile"},"propertyNames":{"type":"string"},"example":{"index.js":{"content":"import http from 'node:http';\\n// import { resolver } from './file2.js';\\n\\nconsole.log('starting server');\\n\\nconst server = http.createServer(async(req, res) => {\\n // wait 5 seconds before responding\\n // await new Promise((resolve) => setTimeout(resolve, 5000));\\n res.writeHead(200, { 'Content-Type': 'text/plain' });\\n res.end('Welcome to New York its been waiting for you');\\n});\\n\\nserver.listen(3000, () => {\\n console.log('Server is running at http://localhost:3000');\\n});"}}},"config":{"$ref":"#/components/schemas/FreestyleDeployWebConfiguration"}}},"FreestyleDeployWebSuccessResponse":{"type":"object","required":["deploymentId"],"properties":{"deploymentId":{"type":"string"},"domains":{"type":["array","null"],"items":{"type":"string"}},"projectId":{"type":["string","null"],"deprecated":true}}},"FreestyleDomainVerificationRequest":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"The domain to create a verification code for","example":"example.com"}}},"FreestyleExecureScriptResultError":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"FreestyleExecureScriptResultSuccess":{"type":"object","required":["result","logs"],"properties":{"result":{},"logs":{"type":"array","items":{"$ref":"#/components/schemas/JavaScriptLog"}}}},"FreestyleExecuteScriptParams":{"type":"object","required":["script"],"properties":{"script":{"type":"string","description":"The JavaScript or TypeScript script to execute","example":"export default () => {\n // get the value of the factorials of the numbers from 1 to 10 combined\n const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\n function factorial(n) {\n if (n === 0) {\n return 1;\n }\n return n * factorial(n - 1);\n }\n\n const b = a.map(factorial);\n\n return b.reduce((a, b) => a + b);\n};\n"},"config":{"$ref":"#/components/schemas/FreestyleExecuteScriptParamsConfiguration"}}},"FreestyleExecuteScriptParamsConfiguration":{"type":"object","properties":{"envVars":{"type":"object","description":"The environment variables to set for the script","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"RESEND_API_KEY":"re_123456789"}},"nodeModules":{"type":"object","description":"The node modules to install for the script","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"resend":"4.0.1"}},"tags":{"type":"array","items":{"type":"string"},"description":"Tags for you to organize your scripts, useful for tracking what you're running","example":["email"],"default":[]},"timeout":{"type":["string","null"],"description":"The script timeout","default":null},"peerDependencyResolution":{"type":"boolean","description":"If false, we'll not resolve peer dependencies for the packages given, this can speed up execute performance, but will break packages with peers unless the peers are manually specified.","default":"true"}}},"FreestyleFile":{"type":"object","required":["content"],"properties":{"content":{"type":"string","description":"The content of the file"},"encoding":{"type":"string","description":"The encoding of the file. Either **utf-8** or **base64**"}}},"FreestyleLogResponseObject":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleVerifyDomainRequest":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}},"JavaScriptLog":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"The log message"},"type":{"type":"string","description":"The log level"}}}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"tags":[{"name":"Web","description":"APIs for deploying websites. We handle node modules caching, scaling, certificates and the whole end to end process. Send the code using the [deploy](#tag/web/POST/web/v1/deploy) endpoint, and you'll get a full hosted website back. Works with any TypeScript or JavaScript codebase."},{"name":"Execute","description":"APIs for running code. Send the code using the [execute](#tag/execute/POST/execute/v1/execute) endpoint, and you'll get the output back. Works with any TypeScript or JavaScript code + handles any node modules and environment variables you want."},{"name":"Cloudstate","description":"APIs for running cloud functions with persistent state. [Cloudstate](https://github.com/freestyle-sh/cloudstate/) is an opensource, durable JavaScript runtime maintained by the Freestyle Team."},{"name":"Domains","description":"APIs for managing domains. This is only relevant when you want to start to deploy to custom domains."}]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -25,6 +25,16 @@
25
25
  "types": "./dist/ai/index.d.mts",
26
26
  "default": "./dist/ai/index.mjs"
27
27
  }
28
+ },
29
+ "./mastra": {
30
+ "require": {
31
+ "types": "./dist/mastra/index.d.cts",
32
+ "default": "./dist/mastra/index.cjs"
33
+ },
34
+ "import": {
35
+ "types": "./dist/mastra/index.d.mts",
36
+ "default": "./dist/mastra/index.mjs"
37
+ }
28
38
  }
29
39
  },
30
40
  "scripts": {
@@ -41,6 +51,7 @@
41
51
  },
42
52
  "dependencies": {
43
53
  "@hey-api/client-fetch": "^0.5.7",
54
+ "@mastra/core": "^0.1.27-alpha.66",
44
55
  "ai": "^4.0.25",
45
56
  "humanlayer": "^0.7.0",
46
57
  "openai": "^4.77.3",
package/src/ai/index.ts CHANGED
@@ -3,6 +3,37 @@ import { FreestyleSandboxes } from "..";
3
3
  import { tool } from "ai";
4
4
  import { z } from "zod";
5
5
 
6
+ export const executeCodeSchema = z.object({
7
+ script: z.string().describe(`
8
+ The JavaScript or TypeScript script to execute, must be in the format of:
9
+
10
+ import { someModule } from "someModule";
11
+ export default () => {
12
+ ... your code here ...
13
+ return output;
14
+ }
15
+
16
+ or for async functions:
17
+
18
+ import { someModule } from "someModule";
19
+
20
+ export default async () => {
21
+ ... your code here ...
22
+ return output;
23
+ }
24
+ `),
25
+ });
26
+
27
+ export const executeCodeDescription = (envVars: string, nodeModules: string) =>
28
+ `Execute a JavaScript or TypeScript script.\n${
29
+ envVars.length > 0
30
+ ? `You can use the following environment variables: ${envVars}`
31
+ : ""
32
+ }\n${
33
+ nodeModules.length > 0
34
+ ? `You can use the following node modules: ${nodeModules}`
35
+ : "You cannot use any node modules."
36
+ }`;
6
37
  /**
7
38
  * Execute a JavaScript or TypeScript script
8
39
  *
@@ -23,35 +54,8 @@ export const executeTool = (
23
54
  const envVars = Object.keys(config.envVars ?? {}).join(", ");
24
55
  const nodeModules = Object.keys(config.nodeModules ?? {}).join(", ");
25
56
  return tool({
26
- description: `Execute a JavaScript or TypeScript script.\n${
27
- envVars.length > 0
28
- ? `You can use the following environment variables: ${envVars}`
29
- : ""
30
- }\n${
31
- nodeModules.length > 0
32
- ? `You can use the following node modules: ${nodeModules}`
33
- : "You cannot use any node modules."
34
- }`,
35
- parameters: z.object({
36
- script: z.string().describe(`
37
- The JavaScript or TypeScript script to execute, must be in the format of:
38
-
39
- import { someModule } from "someModule";
40
- export default () => {
41
- ... your code here ...
42
- return output;
43
- }
44
-
45
- or for async functions:
46
-
47
- import { someModule } from "someModule";
48
-
49
- export default async () => {
50
- ... your code here ...
51
- return output;
52
- }
53
- `),
54
- }),
57
+ description: executeCodeDescription(envVars, nodeModules),
58
+ parameters: executeCodeSchema,
55
59
  execute: async ({ script }) => {
56
60
  try {
57
61
  const res = await api.executeScript(script, config);
package/src/index.ts CHANGED
@@ -192,7 +192,42 @@ export class FreestyleSandboxes {
192
192
  if (response.data) {
193
193
  return response.data;
194
194
  } else {
195
- throw new Error("Failed to list domains");
195
+ throw new Error("Failed to list domains\n" + response.error.message);
196
+ }
197
+ }
198
+
199
+ async listDomainVerificationRequests(): Promise<sandbox_openapi.HandleListDomainVerificationRequestsResponse> {
200
+ const response = await sandbox_openapi.handleListDomainVerificationRequests(
201
+ {
202
+ client: this.client,
203
+ }
204
+ );
205
+ if (response.data) {
206
+ return response.data;
207
+ } else {
208
+ throw new Error(
209
+ "Failed to list domain verification requests\n" + response.error.message
210
+ );
211
+ }
212
+ }
213
+
214
+ async deleteDomainVerificationRequest(
215
+ domain: string,
216
+ verificationCode: string
217
+ ): Promise<sandbox_openapi.HandleDeleteDomainVerificationResponse> {
218
+ const response = await sandbox_openapi.handleDeleteDomainVerification({
219
+ client: this.client,
220
+ body: {
221
+ domain: domain,
222
+ verificationCode: verificationCode,
223
+ },
224
+ });
225
+ if (response.data) {
226
+ return response.data;
227
+ } else {
228
+ throw new Error(
229
+ `Failed to delete domain verification request for domain ${domain}: ${response.error.message}`
230
+ );
196
231
  }
197
232
  }
198
233
  }
@@ -0,0 +1,38 @@
1
+ import { createTool } from "@mastra/core";
2
+ import { z } from "zod";
3
+ import { executeCodeDescription, executeCodeSchema } from "../ai";
4
+ import { FreestyleExecuteScriptParamsConfiguration } from "../../openapi";
5
+ import { FreestyleSandboxes } from "..";
6
+
7
+ export const executeTool = (
8
+ config: FreestyleExecuteScriptParamsConfiguration & {
9
+ apiKey: string;
10
+ }
11
+ ) => {
12
+ const description = executeCodeDescription(
13
+ Object.keys(config.envVars ?? {}).join(", "),
14
+ Object.keys(config.nodeModules ?? {}).join(", ")
15
+ );
16
+
17
+ const client = new FreestyleSandboxes({
18
+ apiKey: config.apiKey,
19
+ });
20
+
21
+ return createTool({
22
+ id: "Execute a TypeScript or JavaScript Script",
23
+ description,
24
+ inputSchema: executeCodeSchema,
25
+ execute: async ({ context: { script } }) => {
26
+ return await client.executeScript(script, config);
27
+ },
28
+ outputSchema: z.object({
29
+ logs: z.array(
30
+ z.object({
31
+ message: z.string(),
32
+ type: z.string(),
33
+ })
34
+ ),
35
+ result: z.unknown(),
36
+ }),
37
+ });
38
+ };