freestyle-sandboxes 0.0.36 → 0.0.37
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 +1 -1
- package/dist/ai/index.d.cts +10 -2
- package/dist/ai/index.d.mts +10 -2
- package/dist/ai/index.mjs +1 -1
- package/dist/index-BBXyg0JQ.cjs +3253 -0
- package/dist/index-DCF70Xbq.mjs +3246 -0
- package/dist/langgraph/index.cjs +1 -1
- package/dist/langgraph/index.mjs +1 -1
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.mjs +1 -1
- package/package.json +1 -1
- package/src/ai/index.ts +31 -3
package/dist/langgraph/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var index$1 = require('../index.cjs');
|
|
4
4
|
var zod = require('zod');
|
|
5
|
-
var index = require('../index-
|
|
5
|
+
var index = require('../index-BBXyg0JQ.cjs');
|
|
6
6
|
require('@hey-api/client-fetch');
|
|
7
7
|
|
|
8
8
|
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
package/dist/langgraph/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FreestyleSandboxes } from '../index.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { g as getDefaultExportFromCjs, z as zodToJsonSchema, a as executeCodeSchema, e as executeCodeDescription } from '../index-
|
|
3
|
+
import { g as getDefaultExportFromCjs, z as zodToJsonSchema, a as executeCodeSchema, e as executeCodeDescription } from '../index-DCF70Xbq.mjs';
|
|
4
4
|
import '@hey-api/client-fetch';
|
|
5
5
|
|
|
6
6
|
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
package/dist/mastra/index.cjs
CHANGED
package/dist/mastra/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { e as executeCodeDescription, a as executeCodeSchema } from '../index-
|
|
2
|
+
import { e as executeCodeDescription, a as executeCodeSchema } from '../index-DCF70Xbq.mjs';
|
|
3
3
|
import { FreestyleSandboxes } from '../index.mjs';
|
|
4
4
|
import '@hey-api/client-fetch';
|
|
5
5
|
|
package/package.json
CHANGED
package/src/ai/index.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FreestyleExecuteScriptParamsConfiguration,
|
|
3
|
+
FreestyleExecuteScriptResultSuccess,
|
|
4
|
+
HandleExecuteScriptError,
|
|
5
|
+
} from "../../openapi";
|
|
2
6
|
import { FreestyleSandboxes } from "..";
|
|
3
7
|
import { tool } from "ai";
|
|
4
8
|
import { z } from "zod";
|
|
9
|
+
import { P } from "../../dist/types.gen-BuhQ5LpB";
|
|
5
10
|
|
|
6
11
|
export const executeCodeSchema = z.object({
|
|
7
12
|
script: z.string().describe(`
|
|
@@ -40,11 +45,19 @@ export const executeCodeDescription = (envVars: string, nodeModules: string) =>
|
|
|
40
45
|
*
|
|
41
46
|
* @param config - Configuration for the tool
|
|
42
47
|
* @param config.apiKey - The API key to use
|
|
43
|
-
*
|
|
48
|
+
* @param {Function} [config.onResult] - Optional callback function to handle the result.
|
|
49
|
+
* @param {boolean} [config.truncateOutput=false] - Whether to truncate the result to 1000 characters and truncate individual logs to the first 250 characters; useful to prevent long outputs from filling the context window.
|
|
44
50
|
*/
|
|
45
51
|
export const executeTool = (
|
|
46
52
|
config: FreestyleExecuteScriptParamsConfiguration & {
|
|
47
53
|
apiKey: string;
|
|
54
|
+
onResult?: (_v: {
|
|
55
|
+
input: {
|
|
56
|
+
script: string;
|
|
57
|
+
} & Record<string, unknown>;
|
|
58
|
+
result: FreestyleExecuteScriptResultSuccess | HandleExecuteScriptError;
|
|
59
|
+
}) => void | Promise<void>;
|
|
60
|
+
truncateOutput?: boolean;
|
|
48
61
|
}
|
|
49
62
|
) => {
|
|
50
63
|
const api = new FreestyleSandboxes({
|
|
@@ -56,9 +69,24 @@ export const executeTool = (
|
|
|
56
69
|
return tool({
|
|
57
70
|
description: executeCodeDescription(envVars, nodeModules),
|
|
58
71
|
parameters: executeCodeSchema,
|
|
59
|
-
execute: async ({ script }) => {
|
|
72
|
+
execute: async ({ script, ...otherParams }) => {
|
|
60
73
|
try {
|
|
61
74
|
const res = await api.executeScript(script, config);
|
|
75
|
+
if (config.onResult) {
|
|
76
|
+
await config.onResult({
|
|
77
|
+
result: res,
|
|
78
|
+
input: {
|
|
79
|
+
script,
|
|
80
|
+
...otherParams,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (config.truncateOutput) {
|
|
85
|
+
if ("output" in res) {
|
|
86
|
+
res.result = JSON.stringify(res.result).slice(0, 1000);
|
|
87
|
+
res.logs = res.logs.slice(0, 1000);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
62
90
|
return res;
|
|
63
91
|
} catch (e) {
|
|
64
92
|
console.log("ERROR: ", e.message);
|