@axiom-lattice/core 2.1.17 → 2.1.19

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/index.mjs CHANGED
@@ -2074,6 +2074,9 @@ var DefaultSandboxManager = class {
2074
2074
  this.creatingSandboxes = /* @__PURE__ */ new Map();
2075
2075
  this.baseURL = baseURL;
2076
2076
  }
2077
+ getBaseURL() {
2078
+ return this.baseURL;
2079
+ }
2077
2080
  async createSandbox(sandboxName) {
2078
2081
  if (sandboxName === "global") {
2079
2082
  const client = new SandboxClient({ baseUrl: `${this.baseURL}/sandbox/global`, environment: "" });
@@ -2959,7 +2962,33 @@ registerToolLattice(
2959
2962
  if (!result.ok) {
2960
2963
  return `Error taking screenshot: ${JSON.stringify(result.error.content)}`;
2961
2964
  }
2962
- return result.body?.data?.content?.map((item) => item.text).join("\n") ?? "Screenshot taken successfully";
2965
+ const lines = [];
2966
+ for (const item of result.body?.data?.content ?? []) {
2967
+ if (item.type === "image") {
2968
+ const base64Data = item.data;
2969
+ const buffer = Buffer.from(base64Data, "base64");
2970
+ const screenshotPath = `/home/gem/screenshots/screenshot_${input.name}.png`;
2971
+ const uploadResult = await sandbox.file.uploadFile({
2972
+ file: buffer,
2973
+ path: screenshotPath
2974
+ });
2975
+ if (uploadResult.ok) {
2976
+ const screenshot_md = [
2977
+ "",
2978
+ "Screenshot saved!",
2979
+ "```attachments",
2980
+ JSON.stringify([{ id: screenshotPath, name: `screenshot_${input.name}.png` }]),
2981
+ "```"
2982
+ ].join("\n");
2983
+ lines.push(screenshot_md);
2984
+ } else {
2985
+ lines.push(`Failed to save screenshot: ${JSON.stringify(uploadResult.error)}`);
2986
+ }
2987
+ } else {
2988
+ lines.push(`${item.text}`);
2989
+ }
2990
+ }
2991
+ return lines.length > 0 ? lines.join("\n") : "No Content";
2963
2992
  } catch (e) {
2964
2993
  return `Error taking screenshot: ${e instanceof Error ? e.message : String(e)}`;
2965
2994
  }
@@ -3814,10 +3843,10 @@ function createLsTool(backend, options) {
3814
3843
  const lines = [];
3815
3844
  for (const info of infos) {
3816
3845
  if (info.is_dir) {
3817
- lines.push(`${info.path} (directory)`);
3846
+ lines.push(`<code>${info.path}</code> (directory)`);
3818
3847
  } else {
3819
3848
  const size = info.size ? ` (${info.size} bytes)` : "";
3820
- lines.push(`${info.path}${size}`);
3849
+ lines.push(`<code>${info.path}</code>${size}`);
3821
3850
  }
3822
3851
  }
3823
3852
  return lines.join("\n");
@@ -5651,18 +5680,17 @@ var DeepAgentGraphBuilder = class {
5651
5680
  if (!sandboxManager) {
5652
5681
  throw new Error("Sandbox manager not found");
5653
5682
  }
5654
- let sandboxName = "global";
5655
- if (params.connectedSandbox.isolatedLevel === "agent") {
5656
- sandboxName = agentLattice.config.key;
5657
- filesystemBackend = async (agentAndState) => new SandboxFilesystem({
5658
- sandboxInstance: await sandboxManager.createSandbox(sandboxName)
5659
- });
5660
- } else if (params.connectedSandbox.isolatedLevel === "thread") {
5661
- filesystemBackend = async (agentAndState) => new SandboxFilesystem({
5683
+ filesystemBackend = async (agentAndState) => {
5684
+ let sandboxName = "global";
5685
+ if (params.connectedSandbox?.isolatedLevel === "agent") {
5686
+ sandboxName = agentLattice.config.key;
5687
+ } else if (params.connectedSandbox?.isolatedLevel === "thread") {
5688
+ sandboxName = agentAndState.threadId ?? "global";
5689
+ }
5690
+ return new SandboxFilesystem({
5662
5691
  sandboxInstance: await sandboxManager.createSandbox(sandboxName)
5663
- //TODO: add threadId to sandbox
5664
5692
  });
5665
- }
5693
+ };
5666
5694
  }
5667
5695
  if (availabledModules.includes("code_eval")) {
5668
5696
  middlewares.push(createCodeEvalMiddleware());