freestyle-sandboxes 0.0.36 → 0.0.38

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.
@@ -3167,9 +3167,25 @@ const executeTool = (config) => {
3167
3167
  return tool({
3168
3168
  description: executeCodeDescription(envVars, nodeModules),
3169
3169
  parameters: executeCodeSchema,
3170
- execute: async ({ script }) => {
3170
+ execute: async ({ script, ...otherParams }, { toolCallId }) => {
3171
3171
  try {
3172
3172
  const res = await api.executeScript(script, config);
3173
+ if (config.onResult) {
3174
+ await config.onResult({
3175
+ toolCallId,
3176
+ result: res,
3177
+ input: {
3178
+ script,
3179
+ ...otherParams
3180
+ }
3181
+ });
3182
+ }
3183
+ if (config.truncateOutput) {
3184
+ if ("output" in res) {
3185
+ res.result = JSON.stringify(res.result).slice(0, 1e3);
3186
+ res.logs = res.logs.slice(0, 1e3);
3187
+ }
3188
+ }
3173
3189
  return res;
3174
3190
  } catch (e) {
3175
3191
  console.log("ERROR: ", e.message);
@@ -3169,9 +3169,25 @@ const executeTool = (config) => {
3169
3169
  return tool({
3170
3170
  description: executeCodeDescription(envVars, nodeModules),
3171
3171
  parameters: executeCodeSchema,
3172
- execute: async ({ script }) => {
3172
+ execute: async ({ script, ...otherParams }, { toolCallId }) => {
3173
3173
  try {
3174
3174
  const res = await api.executeScript(script, config);
3175
+ if (config.onResult) {
3176
+ await config.onResult({
3177
+ toolCallId,
3178
+ result: res,
3179
+ input: {
3180
+ script,
3181
+ ...otherParams
3182
+ }
3183
+ });
3184
+ }
3185
+ if (config.truncateOutput) {
3186
+ if ("output" in res) {
3187
+ res.result = JSON.stringify(res.result).slice(0, 1e3);
3188
+ res.logs = res.logs.slice(0, 1e3);
3189
+ }
3190
+ }
3175
3191
  return res;
3176
3192
  } catch (e) {
3177
3193
  console.log("ERROR: ", e.message);