@axiom-lattice/core 2.1.89 → 2.1.90

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, `/project/${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,75 @@ 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
+ var TOKEN_BYTES = 24;
24003
+ function generateToken() {
24004
+ return randomBytes(TOKEN_BYTES).toString("base64url");
24005
+ }
24006
+ function createSharePayload(tenantId, workspaceId, projectId, userId, request) {
24007
+ return {
24008
+ address: createResourceAddress({
24009
+ tenantId,
24010
+ workspaceId,
24011
+ projectId,
24012
+ resourcePath: request.resourcePath
24013
+ }),
24014
+ tenantId,
24015
+ workspaceId,
24016
+ projectId,
24017
+ assistantId: request.assistantId ?? null,
24018
+ vmIsolation: "project",
24019
+ visibility: request.visibility ?? "public",
24020
+ passwordHash: request.visibility === "password" && request.password ? request.password : null,
24021
+ title: request.title ?? null,
24022
+ createdBy: userId,
24023
+ expiresAt: request.expiresAt ? new Date(request.expiresAt) : null,
24024
+ maxAccess: request.maxAccess ?? null,
24025
+ revoked: false
24026
+ };
24027
+ }
24028
+
23894
24029
  // src/channel/connectAllChannels.ts
23895
24030
  async function connectAllChannels(getAdapter, options = {}) {
23896
24031
  const store = getStoreLattice("default", "channelInstallation").store;
@@ -23931,7 +24066,7 @@ function getMenuRegistry() {
23931
24066
  import * as Protocols from "@axiom-lattice/protocols";
23932
24067
 
23933
24068
  // src/util/encryption.ts
23934
- import { createCipheriv, createDecipheriv, randomBytes, pbkdf2Sync } from "crypto";
24069
+ import { createCipheriv, createDecipheriv, randomBytes as randomBytes2, pbkdf2Sync } from "crypto";
23935
24070
  var ALGORITHM = "aes-256-gcm";
23936
24071
  var IV_LENGTH = 16;
23937
24072
  var SALT_LENGTH = 32;
@@ -23953,8 +24088,8 @@ function getEncryptionKey() {
23953
24088
  }
23954
24089
  function encrypt(plaintext, key) {
23955
24090
  const actualKey = key || getEncryptionKey();
23956
- const salt = randomBytes(SALT_LENGTH);
23957
- const iv = randomBytes(IV_LENGTH);
24091
+ const salt = randomBytes2(SALT_LENGTH);
24092
+ const iv = randomBytes2(IV_LENGTH);
23958
24093
  const derivedKey = pbkdf2Sync(actualKey, salt, ITERATIONS, 32, "sha256");
23959
24094
  const cipher = createCipheriv(ALGORITHM, derivedKey, iv);
23960
24095
  const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
@@ -24215,6 +24350,7 @@ export {
24215
24350
  TaskStatus,
24216
24351
  TeamAgentGraphBuilder,
24217
24352
  ThreadStatus2 as ThreadStatus,
24353
+ TokenCache,
24218
24354
  ToolLatticeManager,
24219
24355
  VectorStoreLatticeManager,
24220
24356
  VolumeFilesystem,
@@ -24252,8 +24388,10 @@ export {
24252
24388
  createQuerySqlTool,
24253
24389
  createQueryTableDefinitionTool,
24254
24390
  createQueryTablesListTool,
24391
+ createResourceAddress,
24255
24392
  createSandboxProvider,
24256
24393
  createSchedulerMiddleware,
24394
+ createSharePayload,
24257
24395
  createTaskMiddleware,
24258
24396
  createTeamMiddleware,
24259
24397
  createTeammateTools,
@@ -24273,6 +24411,7 @@ export {
24273
24411
  formatGrepMatches,
24274
24412
  formatGrepResults,
24275
24413
  formatReadResponse,
24414
+ generateToken,
24276
24415
  getAgentClient,
24277
24416
  getAgentConfig,
24278
24417
  getAllAgentConfigs,