@blaxel/core 0.2.43-dev.199 → 0.2.43-preview.93

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.
Files changed (43) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/agents/index.js +2 -2
  3. package/dist/cjs/common/internal.js +0 -40
  4. package/dist/cjs/common/settings.js +2 -5
  5. package/dist/cjs/jobs/jobs.js +2 -2
  6. package/dist/cjs/sandbox/action.js +2 -1
  7. package/dist/cjs/sandbox/filesystem/filesystem.js +13 -12
  8. package/dist/cjs/sandbox/sandbox.js +2 -2
  9. package/dist/cjs/tools/mcpTool.js +2 -2
  10. package/dist/cjs/types/common/internal.d.ts +0 -2
  11. package/dist/cjs/types/common/settings.d.ts +0 -1
  12. package/dist/cjs/types/sandbox/filesystem/filesystem.d.ts +2 -6
  13. package/dist/cjs-browser/.tsbuildinfo +1 -1
  14. package/dist/cjs-browser/agents/index.js +2 -2
  15. package/dist/cjs-browser/common/internal.js +0 -40
  16. package/dist/cjs-browser/common/settings.js +2 -5
  17. package/dist/cjs-browser/jobs/jobs.js +2 -2
  18. package/dist/cjs-browser/sandbox/action.js +2 -1
  19. package/dist/cjs-browser/sandbox/filesystem/filesystem.js +13 -12
  20. package/dist/cjs-browser/sandbox/sandbox.js +2 -2
  21. package/dist/cjs-browser/tools/mcpTool.js +2 -2
  22. package/dist/cjs-browser/types/common/internal.d.ts +0 -2
  23. package/dist/cjs-browser/types/common/settings.d.ts +0 -1
  24. package/dist/cjs-browser/types/sandbox/filesystem/filesystem.d.ts +2 -6
  25. package/dist/esm/.tsbuildinfo +1 -1
  26. package/dist/esm/agents/index.js +3 -3
  27. package/dist/esm/common/internal.js +0 -38
  28. package/dist/esm/common/settings.js +2 -5
  29. package/dist/esm/jobs/jobs.js +3 -3
  30. package/dist/esm/sandbox/action.js +3 -2
  31. package/dist/esm/sandbox/filesystem/filesystem.js +14 -13
  32. package/dist/esm/sandbox/sandbox.js +2 -2
  33. package/dist/esm/tools/mcpTool.js +3 -3
  34. package/dist/esm-browser/.tsbuildinfo +1 -1
  35. package/dist/esm-browser/agents/index.js +3 -3
  36. package/dist/esm-browser/common/internal.js +0 -38
  37. package/dist/esm-browser/common/settings.js +2 -5
  38. package/dist/esm-browser/jobs/jobs.js +3 -3
  39. package/dist/esm-browser/sandbox/action.js +3 -2
  40. package/dist/esm-browser/sandbox/filesystem/filesystem.js +14 -13
  41. package/dist/esm-browser/sandbox/sandbox.js +2 -2
  42. package/dist/esm-browser/tools/mcpTool.js +3 -3
  43. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { generateInternalUrl, getForcedUrl } from "../common/internal.js";
1
+ import { getForcedUrl, getGlobalUniqueHash } from "../common/internal.js";
2
2
  import { logger } from "../common/logger.js";
3
3
  import { settings } from "../common/settings.js";
4
4
  import { startSpan } from '../telemetry/telemetry.js';
@@ -17,8 +17,8 @@ class BlJob {
17
17
  return new URL(`${settings.runUrl}/${settings.workspace}/jobs/${this.jobName}`);
18
18
  }
19
19
  get internalUrl() {
20
- const url = generateInternalUrl(settings.workspace, "job", this.jobName, settings.env, settings.runInternalProtocol, settings.runInternalHostname, settings.blCloud, settings.workspaceId);
21
- return new URL(url);
20
+ const hash = getGlobalUniqueHash(settings.workspace, "job", this.jobName);
21
+ return new URL(`${settings.runInternalProtocol}://bl-${settings.env}-${hash}.${settings.runInternalHostname}`);
22
22
  }
23
23
  get forcedUrl() {
24
24
  return getForcedUrl('job', this.jobName);
@@ -1,5 +1,5 @@
1
1
  import { createClient } from "@hey-api/client-fetch";
2
- import { generateInternalUrl, getForcedUrl } from "../common/internal.js";
2
+ import { getForcedUrl, getGlobalUniqueHash } from "../common/internal.js";
3
3
  import { settings } from "../common/settings.js";
4
4
  import { client as defaultClient } from "./client/client.gen.js";
5
5
  export class ResponseError extends Error {
@@ -44,7 +44,8 @@ export class SandboxAction {
44
44
  return this.sandbox.metadata?.url ?? `${settings.runUrl}/${settings.workspace}/sandboxes/${this.name}`;
45
45
  }
46
46
  get internalUrl() {
47
- return generateInternalUrl(settings.workspace, "sandbox", this.name, settings.env, settings.runInternalProtocol, settings.runInternalHostname, settings.blCloud, settings.workspaceId);
47
+ const hash = getGlobalUniqueHash(settings.workspace, "sandbox", this.name);
48
+ return `${settings.runInternalProtocol}://bl-${settings.env}-${hash}.${settings.runInternalHostname}`;
48
49
  }
49
50
  get client() {
50
51
  if (this.sandbox.forceUrl) {
@@ -1,12 +1,9 @@
1
1
  import { settings } from "../../common/settings.js";
2
2
  import { SandboxAction } from "../action.js";
3
- import { deleteFilesystemByPath, getFilesystemByPath, getWatchFilesystemByPath, putFilesystemByPath } from "../client/index.js";
3
+ import { deleteFilesystemByPath, getFilesystemByPath, getWatchFilesystemByPath, putFilesystemByPath, postProcess } from "../client/index.js";
4
4
  export class SandboxFileSystem extends SandboxAction {
5
- process;
6
- constructor(sandbox, process) {
5
+ constructor(sandbox) {
7
6
  super(sandbox);
8
- this.process = process;
9
- this.process = process;
10
7
  }
11
8
  async mkdir(path, permissions = "0755") {
12
9
  path = this.formatPath(path);
@@ -83,7 +80,7 @@ export class SandboxFileSystem extends SandboxAction {
83
80
  baseUrl: this.url,
84
81
  client: this.client,
85
82
  };
86
- const path = this.formatPath(destinationPath ?? "");
83
+ const path = destinationPath ?? "";
87
84
  const { response, data, error } = await this.client.put({
88
85
  url: `/filesystem/tree/${path}`,
89
86
  ...options,
@@ -131,14 +128,18 @@ export class SandboxFileSystem extends SandboxAction {
131
128
  }
132
129
  return data;
133
130
  }
134
- async cp(source, destination, { maxWait = 1000 * 60 * 60 } = {}) {
135
- let process = await this.process.exec({
136
- command: `cp -r ${source} ${destination}`,
131
+ async cp(source, destination) {
132
+ source = this.formatPath(source);
133
+ destination = this.formatPath(destination);
134
+ const process = {
135
+ command: `cp -r ${source} ${destination}`
136
+ };
137
+ const { response, data, error } = await postProcess({
138
+ body: process,
139
+ baseUrl: this.url,
140
+ client: this.client,
137
141
  });
138
- process = await this.process.wait(process.pid, { maxWait, interval: 100 });
139
- if (process.status === "failed") {
140
- throw new Error(`Could not copy ${source} to ${destination} cause: ${process.logs}`);
141
- }
142
+ this.handleResponseError(response, data, error);
142
143
  return {
143
144
  message: "Files copied",
144
145
  source,
@@ -17,9 +17,9 @@ export class SandboxInstance {
17
17
  sessions;
18
18
  constructor(sandbox) {
19
19
  this.sandbox = sandbox;
20
- this.process = new SandboxProcess(sandbox);
21
- this.fs = new SandboxFileSystem(sandbox, this.process);
20
+ this.fs = new SandboxFileSystem(sandbox);
22
21
  this.network = new SandboxNetwork(sandbox);
22
+ this.process = new SandboxProcess(sandbox);
23
23
  this.previews = new SandboxPreviews(sandbox);
24
24
  this.sessions = new SandboxSessions(sandbox);
25
25
  }
@@ -1,6 +1,6 @@
1
1
  import { Client as ModelContextProtocolClient } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { env } from "../common/env.js";
3
- import { generateInternalUrl, getForcedUrl } from "../common/internal.js";
3
+ import { getForcedUrl, getGlobalUniqueHash } from "../common/internal.js";
4
4
  import { logger } from "../common/logger.js";
5
5
  import { settings } from "../common/settings.js";
6
6
  import { authenticate } from "../index.js";
@@ -55,8 +55,8 @@ export class McpTool {
55
55
  return new URL(`${settings.runUrl}/${settings.workspace}/${this.pluralType}/${this.name}`);
56
56
  }
57
57
  get internalUrl() {
58
- const url = generateInternalUrl(settings.workspace, this.type, this.name, settings.env, settings.runInternalProtocol, settings.runInternalHostname, settings.blCloud, settings.workspaceId);
59
- return new URL(url);
58
+ const hash = getGlobalUniqueHash(settings.workspace, this.type, this.name);
59
+ return new URL(`${settings.runInternalProtocol}://bl-${settings.env}-${hash}.${settings.runInternalHostname}`);
60
60
  }
61
61
  get forcedUrl() {
62
62
  return getForcedUrl(this.type, this.name);