freestyle-sandboxes 0.0.35 → 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 +7 -98
- package/dist/ai/index.d.cts +17 -7
- package/dist/ai/index.d.mts +17 -7
- package/dist/ai/index.mjs +3 -98
- package/dist/index-BBXyg0JQ.cjs +3253 -0
- package/dist/index-BQHqnjZK.mjs +3231 -0
- package/dist/index-CEEa9WHp.cjs +3238 -0
- package/dist/index-DCF70Xbq.mjs +3246 -0
- package/dist/index.d-CXx1AdyW.d.ts +4210 -0
- package/dist/langgraph/index.cjs +14484 -9
- package/dist/langgraph/index.d.cts +2155 -1
- package/dist/langgraph/index.d.mts +2155 -1
- package/dist/langgraph/index.mjs +14479 -4
- package/dist/mastra/index.cjs +22 -4
- package/dist/mastra/index.d.cts +2582 -5
- package/dist/mastra/index.d.mts +2582 -5
- package/dist/mastra/index.mjs +21 -3
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.mjs +2 -2
- package/package.json +6 -6
- package/src/ai/index.ts +31 -3
package/dist/mastra/index.mjs
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import { createTool } from '@mastra/core';
|
|
2
1
|
import { z } from 'zod';
|
|
3
|
-
import { executeCodeDescription, executeCodeSchema } from '../
|
|
2
|
+
import { e as executeCodeDescription, a as executeCodeSchema } from '../index-DCF70Xbq.mjs';
|
|
4
3
|
import { FreestyleSandboxes } from '../index.mjs';
|
|
5
|
-
import 'ai';
|
|
6
4
|
import '@hey-api/client-fetch';
|
|
7
5
|
|
|
6
|
+
var Tool = class {
|
|
7
|
+
id;
|
|
8
|
+
description;
|
|
9
|
+
inputSchema;
|
|
10
|
+
outputSchema;
|
|
11
|
+
execute;
|
|
12
|
+
mastra;
|
|
13
|
+
constructor(opts) {
|
|
14
|
+
this.id = opts.id;
|
|
15
|
+
this.description = opts.description;
|
|
16
|
+
this.inputSchema = opts.inputSchema;
|
|
17
|
+
this.outputSchema = opts.outputSchema;
|
|
18
|
+
this.execute = opts.execute;
|
|
19
|
+
this.mastra = opts.mastra;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function createTool(opts) {
|
|
23
|
+
return new Tool(opts);
|
|
24
|
+
}
|
|
25
|
+
|
|
8
26
|
const executeTool = (config) => {
|
|
9
27
|
const description = executeCodeDescription(
|
|
10
28
|
Object.keys(config.envVars ?? {}).join(", "),
|
package/dist/utils/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var glob = require('glob');
|
|
4
4
|
var fs = require('fs/promises');
|
|
5
|
-
var
|
|
5
|
+
var require$$0 = require('fs');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
@@ -23,7 +23,7 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
26
|
-
var
|
|
26
|
+
var require$$0__namespace = /*#__PURE__*/_interopNamespaceDefault(require$$0);
|
|
27
27
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
28
28
|
|
|
29
29
|
const prepareDirForDeployment = async (directory) => {
|
|
@@ -64,7 +64,7 @@ const prepareDirForDeploymentSync = (directory) => {
|
|
|
64
64
|
for (const relativePath of patterns) {
|
|
65
65
|
try {
|
|
66
66
|
const filePath = path__namespace.join(directory, relativePath);
|
|
67
|
-
const content =
|
|
67
|
+
const content = require$$0__namespace.readFileSync(filePath, "base64");
|
|
68
68
|
files[relativePath] = {
|
|
69
69
|
content,
|
|
70
70
|
encoding: "base64"
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { glob, globSync } from 'glob';
|
|
2
2
|
import * as fs from 'fs/promises';
|
|
3
|
-
import * as
|
|
3
|
+
import * as require$$0 from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
|
|
6
6
|
const prepareDirForDeployment = async (directory) => {
|
|
@@ -41,7 +41,7 @@ const prepareDirForDeploymentSync = (directory) => {
|
|
|
41
41
|
for (const relativePath of patterns) {
|
|
42
42
|
try {
|
|
43
43
|
const filePath = path.join(directory, relativePath);
|
|
44
|
-
const content =
|
|
44
|
+
const content = require$$0.readFileSync(filePath, "base64");
|
|
45
45
|
files[relativePath] = {
|
|
46
46
|
content,
|
|
47
47
|
encoding: "base64"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freestyle-sandboxes",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -67,16 +67,16 @@
|
|
|
67
67
|
"description": "",
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@hey-api/openapi-ts": "^0.60.1",
|
|
70
|
-
"pkgroll": "^2.6.0"
|
|
71
|
-
},
|
|
72
|
-
"dependencies": {
|
|
73
|
-
"@hey-api/client-fetch": "^0.5.7",
|
|
70
|
+
"pkgroll": "^2.6.0",
|
|
74
71
|
"@langchain/core": "^0.3.38",
|
|
75
72
|
"@langchain/langgraph": "^0.2.44",
|
|
76
73
|
"@mastra/core": "^0.6.0",
|
|
77
74
|
"ai": "^4.0.25",
|
|
75
|
+
"humanlayer": "^0.7.0"
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@hey-api/client-fetch": "^0.5.7",
|
|
78
79
|
"glob": "^11.0.1",
|
|
79
|
-
"humanlayer": "^0.7.0",
|
|
80
80
|
"openai": "^4.77.3",
|
|
81
81
|
"openapi": "^1.0.1",
|
|
82
82
|
"zod": "^3.24.1"
|
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);
|