freestyle-sandboxes 0.0.1-1 → 0.0.1-3

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
@@ -7,7 +7,7 @@ require('@hey-api/client-fetch');
7
7
 
8
8
  const executeTool = (config) => {
9
9
  const api = new index.FreestyleSandboxes({
10
- apiKey: config.apiKey
10
+ ...config
11
11
  });
12
12
  return ai.tool({
13
13
  description: "Execute a JavaScript or TypeScript script",
@@ -29,7 +29,15 @@ const executeTool = (config) => {
29
29
  `)
30
30
  }),
31
31
  execute: async ({ script }) => {
32
- return api.executeScript(script, config);
32
+ try {
33
+ return api.executeScript(script, config);
34
+ } catch (e) {
35
+ return `Error executing script:
36
+
37
+ ${script}
38
+
39
+ ${JSON.stringify(e)}`;
40
+ }
33
41
  }
34
42
  });
35
43
  };
@@ -20,10 +20,10 @@ declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration &
20
20
  script?: string;
21
21
  }, {
22
22
  script?: string;
23
- }>, FreestyleExecureScriptResultSuccess> & {
23
+ }>, string | FreestyleExecureScriptResultSuccess> & {
24
24
  execute: (args: {
25
25
  script?: string;
26
- }, options: ai.ToolExecutionOptions) => PromiseLike<FreestyleExecureScriptResultSuccess>;
26
+ }, options: ai.ToolExecutionOptions) => PromiseLike<string | FreestyleExecureScriptResultSuccess>;
27
27
  };
28
28
 
29
29
  export { executeTool };
@@ -20,10 +20,10 @@ declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration &
20
20
  script?: string;
21
21
  }, {
22
22
  script?: string;
23
- }>, FreestyleExecureScriptResultSuccess> & {
23
+ }>, string | FreestyleExecureScriptResultSuccess> & {
24
24
  execute: (args: {
25
25
  script?: string;
26
- }, options: ai.ToolExecutionOptions) => PromiseLike<FreestyleExecureScriptResultSuccess>;
26
+ }, options: ai.ToolExecutionOptions) => PromiseLike<string | FreestyleExecureScriptResultSuccess>;
27
27
  };
28
28
 
29
29
  export { executeTool };
package/dist/ai/index.mjs CHANGED
@@ -5,7 +5,7 @@ import '@hey-api/client-fetch';
5
5
 
6
6
  const executeTool = (config) => {
7
7
  const api = new FreestyleSandboxes({
8
- apiKey: config.apiKey
8
+ ...config
9
9
  });
10
10
  return tool({
11
11
  description: "Execute a JavaScript or TypeScript script",
@@ -27,7 +27,15 @@ const executeTool = (config) => {
27
27
  `)
28
28
  }),
29
29
  execute: async ({ script }) => {
30
- return api.executeScript(script, config);
30
+ try {
31
+ return api.executeScript(script, config);
32
+ } catch (e) {
33
+ return `Error executing script:
34
+
35
+ ${script}
36
+
37
+ ${JSON.stringify(e)}`;
38
+ }
31
39
  }
32
40
  });
33
41
  };
package/dist/index.cjs CHANGED
@@ -58,7 +58,7 @@ class FreestyleSandboxes {
58
58
  if (response.data) {
59
59
  return response.data;
60
60
  } else {
61
- throw new Error("Failed to execute script");
61
+ throw new Error("Failed to execute script: " + response.error);
62
62
  }
63
63
  }
64
64
  /**
package/dist/index.mjs CHANGED
@@ -56,7 +56,7 @@ class FreestyleSandboxes {
56
56
  if (response.data) {
57
57
  return response.data;
58
58
  } else {
59
- throw new Error("Failed to execute script");
59
+ throw new Error("Failed to execute script: " + response.error);
60
60
  }
61
61
  }
62
62
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.1-1",
3
+ "version": "0.0.1-3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/src/ai/index.ts CHANGED
@@ -19,7 +19,7 @@ export const executeTool = (
19
19
  }
20
20
  ) => {
21
21
  const api = new FreestyleSandboxes({
22
- apiKey: config.apiKey,
22
+ ...config,
23
23
  });
24
24
  return tool({
25
25
  description: "Execute a JavaScript or TypeScript script",
@@ -41,7 +41,11 @@ export const executeTool = (
41
41
  `),
42
42
  }),
43
43
  execute: async ({ script }) => {
44
- return api.executeScript(script, config);
44
+ try {
45
+ return api.executeScript(script, config);
46
+ } catch (e) {
47
+ return `Error executing script:\n\n${script}\n\n${JSON.stringify(e)}`;
48
+ }
45
49
  },
46
50
  });
47
51
  };
package/src/index.ts CHANGED
@@ -34,10 +34,11 @@ export class FreestyleSandboxes {
34
34
  config: config,
35
35
  },
36
36
  });
37
+
37
38
  if (response.data) {
38
39
  return response.data;
39
40
  } else {
40
- throw new Error("Failed to execute script");
41
+ throw new Error("Failed to execute script: " + response.error);
41
42
  }
42
43
  }
43
44