@axiom-lattice/core 2.1.89 → 2.1.91

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
@@ -5991,6 +5991,17 @@ var SandboxLatticeManager = class _SandboxLatticeManager extends BaseLatticeMana
5991
5991
  }
5992
5992
  return provider;
5993
5993
  }
5994
+ /**
5995
+ * Returns the first registered (default) sandbox provider.
5996
+ *
5997
+ * Used by the resource sharing system for file resolution
5998
+ * when a specific provider key is not specified.
5999
+ *
6000
+ * @returns The default registered {@link SandboxProvider}.
6001
+ */
6002
+ getDefaultProvider() {
6003
+ return this._requireProvider();
6004
+ }
5994
6005
  };
5995
6006
  var sandboxLatticeManager = SandboxLatticeManager.getInstance();
5996
6007
  var getSandBoxManager = (key = "default") => {
@@ -22634,6 +22645,12 @@ var MicrosandboxServiceClient = class {
22634
22645
  }
22635
22646
  };
22636
22647
 
22648
+ // src/sandbox_lattice/resourceAddressUtils.ts
22649
+ function createResourceAddress(config) {
22650
+ const volume = buildNamedVolumeName("p", "project", config.tenantId, config.workspaceId, config.projectId);
22651
+ return { volume, resourcePath: config.resourcePath };
22652
+ }
22653
+
22637
22654
  // src/sandbox_lattice/providers/MicrosandboxRemoteProvider.ts
22638
22655
  function parseOptionalNumberEnv(name, fallback) {
22639
22656
  const rawValue = process.env[name];
@@ -22659,6 +22676,7 @@ var MicrosandboxRemoteProvider = class {
22659
22676
  constructor(config) {
22660
22677
  this.config = config;
22661
22678
  this.creating = /* @__PURE__ */ new Map();
22679
+ this.createResourceAddress = createResourceAddress;
22662
22680
  this.client = config.client ?? new MicrosandboxServiceClient({
22663
22681
  baseURL: config.baseURL,
22664
22682
  apiKey: config.apiKey ?? process.env.MICROSANDBOX_API_KEY
@@ -22709,6 +22727,13 @@ var MicrosandboxRemoteProvider = class {
22709
22727
  async listSandboxes() {
22710
22728
  return [];
22711
22729
  }
22730
+ getResourceResolver() {
22731
+ return {
22732
+ resolve: async (address) => {
22733
+ return this.client.volumeFsDownload(address.volume, address.resourcePath);
22734
+ }
22735
+ };
22736
+ }
22712
22737
  buildEnsureInput(config) {
22713
22738
  const defaultMicrosandboxRemoteConfig = getDefaultMicrosandboxRemoteConfig();
22714
22739
  const image = this.config.image ?? defaultMicrosandboxRemoteConfig.image;
@@ -22944,6 +22969,7 @@ var RemoteSandboxProvider = class {
22944
22969
  this.creating = /* @__PURE__ */ new Map();
22945
22970
  this.workspace = DEFAULT_WORKSPACE;
22946
22971
  this.workspaceResolved = false;
22972
+ this.createResourceAddress = createResourceAddress;
22947
22973
  this.client = new SandboxClient23({
22948
22974
  baseUrl: config.baseURL,
22949
22975
  environment: ""
@@ -23005,6 +23031,14 @@ var RemoteSandboxProvider = class {
23005
23031
  async listSandboxes() {
23006
23032
  return Array.from(this.instances.values());
23007
23033
  }
23034
+ getResourceResolver() {
23035
+ return {
23036
+ resolve: async (address) => {
23037
+ const client = this.createVolumeFsClient(address.volume, `/project`);
23038
+ return client.readRaw(address.resourcePath);
23039
+ }
23040
+ };
23041
+ }
23008
23042
  createVolumeFsClient(_volumeName, pathPrefix) {
23009
23043
  const workspace = this.workspace;
23010
23044
  const resolve4 = (p) => {
@@ -23196,6 +23230,7 @@ var E2BProvider = class {
23196
23230
  this.config = config;
23197
23231
  this.instances = /* @__PURE__ */ new Map();
23198
23232
  this.creating = /* @__PURE__ */ new Map();
23233
+ this.createResourceAddress = createResourceAddress;
23199
23234
  }
23200
23235
  async createSandbox(name, _config) {
23201
23236
  const existing = this.instances.get(name);
@@ -23253,6 +23288,16 @@ var E2BProvider = class {
23253
23288
  async listSandboxes() {
23254
23289
  return Array.from(this.instances.values());
23255
23290
  }
23291
+ getResourceResolver() {
23292
+ const instances = this.instances;
23293
+ return {
23294
+ resolve: async (address) => {
23295
+ const entry = Array.from(instances.values())[0];
23296
+ if (!entry) throw new Error("No sandbox instance available to resolve resource");
23297
+ return entry.file.downloadFile({ file: `/project/${address.resourcePath}` });
23298
+ }
23299
+ };
23300
+ }
23256
23301
  };
23257
23302
 
23258
23303
  // src/sandbox_lattice/providers/DaytonaProvider.ts
@@ -23380,6 +23425,7 @@ var DaytonaProvider = class {
23380
23425
  this.instances = /* @__PURE__ */ new Map();
23381
23426
  this.creating = /* @__PURE__ */ new Map();
23382
23427
  this.volumeId = null;
23428
+ this.createResourceAddress = createResourceAddress;
23383
23429
  this.daytona = new Daytona({
23384
23430
  apiKey: config.apiKey,
23385
23431
  apiUrl: config.apiUrl,
@@ -23564,11 +23610,22 @@ var DaytonaProvider = class {
23564
23610
  async listSandboxes() {
23565
23611
  return Array.from(this.instances.values());
23566
23612
  }
23613
+ getResourceResolver() {
23614
+ const instances = this.instances;
23615
+ return {
23616
+ resolve: async (address) => {
23617
+ const entry = Array.from(instances.values())[0];
23618
+ if (!entry) throw new Error("No sandbox instance available to resolve resource");
23619
+ return entry.file.downloadFile({ file: `/project/${address.resourcePath}` });
23620
+ }
23621
+ };
23622
+ }
23567
23623
  };
23568
23624
 
23569
23625
  // src/sandbox_lattice/providers/LocalSandboxProvider.ts
23570
23626
  import * as path4 from "path";
23571
23627
  import * as os from "os";
23628
+ import * as fs4 from "fs/promises";
23572
23629
 
23573
23630
  // src/sandbox_lattice/LocalSandboxInstance.ts
23574
23631
  import { execFile } from "child_process";
@@ -23783,6 +23840,7 @@ var LocalSandboxProvider = class {
23783
23840
  constructor(config = {}) {
23784
23841
  this.instances = /* @__PURE__ */ new Map();
23785
23842
  this.creating = /* @__PURE__ */ new Map();
23843
+ this.createResourceAddress = createResourceAddress;
23786
23844
  this.basePath = config.basePath ?? path4.join(os.homedir(), ".axiom-local-sandbox");
23787
23845
  }
23788
23846
  async createSandbox(name, _config) {
@@ -23835,6 +23893,14 @@ var LocalSandboxProvider = class {
23835
23893
  async listSandboxes() {
23836
23894
  return Array.from(this.instances.values());
23837
23895
  }
23896
+ getResourceResolver() {
23897
+ return {
23898
+ resolve: async (address) => {
23899
+ const hostPath = path4.join(this.basePath, "project", address.resourcePath);
23900
+ return fs4.readFile(hostPath);
23901
+ }
23902
+ };
23903
+ }
23838
23904
  };
23839
23905
 
23840
23906
  // src/sandbox_lattice/SandboxProviderFactory.ts
@@ -23891,6 +23957,77 @@ function createSandboxProvider(config) {
23891
23957
  }
23892
23958
  }
23893
23959
 
23960
+ // src/sandbox_lattice/TokenCache.ts
23961
+ var TokenCache = class {
23962
+ constructor() {
23963
+ this.cache = /* @__PURE__ */ new Map();
23964
+ this.ttlMs = 6e4;
23965
+ }
23966
+ /**
23967
+ * Look up a token in the cache.
23968
+ *
23969
+ * @param token - The share token.
23970
+ * @returns The cached entry, or `null` if the token is absent or expired.
23971
+ */
23972
+ get(token) {
23973
+ const item = this.cache.get(token);
23974
+ if (!item) return null;
23975
+ if (Date.now() > item.expires) {
23976
+ this.cache.delete(token);
23977
+ return null;
23978
+ }
23979
+ return item.entry;
23980
+ }
23981
+ /**
23982
+ * Store a token → address mapping.
23983
+ *
23984
+ * @param token - The share token.
23985
+ * @param entry - The cache entry to associate with the token.
23986
+ */
23987
+ set(token, entry) {
23988
+ this.cache.set(token, { entry, expires: Date.now() + this.ttlMs });
23989
+ }
23990
+ /**
23991
+ * Remove a cached entry (e.g. on revocation).
23992
+ *
23993
+ * @param token - The share token to invalidate.
23994
+ */
23995
+ invalidate(token) {
23996
+ this.cache.delete(token);
23997
+ }
23998
+ };
23999
+
24000
+ // src/sandbox_lattice/ShareService.ts
24001
+ import { randomBytes } from "crypto";
24002
+ import bcrypt from "bcryptjs";
24003
+ var TOKEN_BYTES = 24;
24004
+ function generateToken() {
24005
+ return randomBytes(TOKEN_BYTES).toString("base64url");
24006
+ }
24007
+ function createSharePayload(tenantId, workspaceId, projectId, userId, request) {
24008
+ const resourcePath = (request.resourcePath || "").replace(/^\/?project\//, "");
24009
+ return {
24010
+ address: createResourceAddress({
24011
+ tenantId,
24012
+ workspaceId,
24013
+ projectId,
24014
+ resourcePath
24015
+ }),
24016
+ tenantId,
24017
+ workspaceId,
24018
+ projectId,
24019
+ assistantId: request.assistantId ?? null,
24020
+ vmIsolation: "project",
24021
+ visibility: request.visibility ?? "public",
24022
+ passwordHash: request.visibility === "password" && request.password ? bcrypt.hashSync(request.password, 10) : null,
24023
+ title: request.title ?? null,
24024
+ createdBy: userId,
24025
+ expiresAt: request.expiresAt ? new Date(request.expiresAt) : null,
24026
+ maxAccess: request.maxAccess ?? null,
24027
+ revoked: false
24028
+ };
24029
+ }
24030
+
23894
24031
  // src/channel/connectAllChannels.ts
23895
24032
  async function connectAllChannels(getAdapter, options = {}) {
23896
24033
  const store = getStoreLattice("default", "channelInstallation").store;
@@ -23931,7 +24068,7 @@ function getMenuRegistry() {
23931
24068
  import * as Protocols from "@axiom-lattice/protocols";
23932
24069
 
23933
24070
  // src/util/encryption.ts
23934
- import { createCipheriv, createDecipheriv, randomBytes, pbkdf2Sync } from "crypto";
24071
+ import { createCipheriv, createDecipheriv, randomBytes as randomBytes2, pbkdf2Sync } from "crypto";
23935
24072
  var ALGORITHM = "aes-256-gcm";
23936
24073
  var IV_LENGTH = 16;
23937
24074
  var SALT_LENGTH = 32;
@@ -23953,8 +24090,8 @@ function getEncryptionKey() {
23953
24090
  }
23954
24091
  function encrypt(plaintext, key) {
23955
24092
  const actualKey = key || getEncryptionKey();
23956
- const salt = randomBytes(SALT_LENGTH);
23957
- const iv = randomBytes(IV_LENGTH);
24093
+ const salt = randomBytes2(SALT_LENGTH);
24094
+ const iv = randomBytes2(IV_LENGTH);
23958
24095
  const derivedKey = pbkdf2Sync(actualKey, salt, ITERATIONS, 32, "sha256");
23959
24096
  const cipher = createCipheriv(ALGORITHM, derivedKey, iv);
23960
24097
  const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
@@ -24215,6 +24352,7 @@ export {
24215
24352
  TaskStatus,
24216
24353
  TeamAgentGraphBuilder,
24217
24354
  ThreadStatus2 as ThreadStatus,
24355
+ TokenCache,
24218
24356
  ToolLatticeManager,
24219
24357
  VectorStoreLatticeManager,
24220
24358
  VolumeFilesystem,
@@ -24252,8 +24390,10 @@ export {
24252
24390
  createQuerySqlTool,
24253
24391
  createQueryTableDefinitionTool,
24254
24392
  createQueryTablesListTool,
24393
+ createResourceAddress,
24255
24394
  createSandboxProvider,
24256
24395
  createSchedulerMiddleware,
24396
+ createSharePayload,
24257
24397
  createTaskMiddleware,
24258
24398
  createTeamMiddleware,
24259
24399
  createTeammateTools,
@@ -24273,6 +24413,7 @@ export {
24273
24413
  formatGrepMatches,
24274
24414
  formatGrepResults,
24275
24415
  formatReadResponse,
24416
+ generateToken,
24276
24417
  getAgentClient,
24277
24418
  getAgentConfig,
24278
24419
  getAllAgentConfigs,