@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.js CHANGED
@@ -1612,6 +1612,7 @@ __export(index_exports, {
1612
1612
  TaskStatus: () => TaskStatus,
1613
1613
  TeamAgentGraphBuilder: () => TeamAgentGraphBuilder,
1614
1614
  ThreadStatus: () => ThreadStatus2,
1615
+ TokenCache: () => TokenCache,
1615
1616
  ToolLatticeManager: () => ToolLatticeManager,
1616
1617
  VectorStoreLatticeManager: () => VectorStoreLatticeManager,
1617
1618
  VolumeFilesystem: () => VolumeFilesystem,
@@ -1649,8 +1650,10 @@ __export(index_exports, {
1649
1650
  createQuerySqlTool: () => createQuerySqlTool,
1650
1651
  createQueryTableDefinitionTool: () => createQueryTableDefinitionTool,
1651
1652
  createQueryTablesListTool: () => createQueryTablesListTool,
1653
+ createResourceAddress: () => createResourceAddress,
1652
1654
  createSandboxProvider: () => createSandboxProvider,
1653
1655
  createSchedulerMiddleware: () => createSchedulerMiddleware,
1656
+ createSharePayload: () => createSharePayload,
1654
1657
  createTaskMiddleware: () => createTaskMiddleware,
1655
1658
  createTeamMiddleware: () => createTeamMiddleware,
1656
1659
  createTeammateTools: () => createTeammateTools,
@@ -1670,6 +1673,7 @@ __export(index_exports, {
1670
1673
  formatGrepMatches: () => formatGrepMatches,
1671
1674
  formatGrepResults: () => formatGrepResults,
1672
1675
  formatReadResponse: () => formatReadResponse,
1676
+ generateToken: () => generateToken,
1673
1677
  getAgentClient: () => getAgentClient,
1674
1678
  getAgentConfig: () => getAgentConfig,
1675
1679
  getAllAgentConfigs: () => getAllAgentConfigs,
@@ -7732,6 +7736,17 @@ var SandboxLatticeManager = class _SandboxLatticeManager extends BaseLatticeMana
7732
7736
  }
7733
7737
  return provider;
7734
7738
  }
7739
+ /**
7740
+ * Returns the first registered (default) sandbox provider.
7741
+ *
7742
+ * Used by the resource sharing system for file resolution
7743
+ * when a specific provider key is not specified.
7744
+ *
7745
+ * @returns The default registered {@link SandboxProvider}.
7746
+ */
7747
+ getDefaultProvider() {
7748
+ return this._requireProvider();
7749
+ }
7735
7750
  };
7736
7751
  var sandboxLatticeManager = SandboxLatticeManager.getInstance();
7737
7752
  var getSandBoxManager = (key = "default") => {
@@ -24348,6 +24363,12 @@ var MicrosandboxServiceClient = class {
24348
24363
  }
24349
24364
  };
24350
24365
 
24366
+ // src/sandbox_lattice/resourceAddressUtils.ts
24367
+ function createResourceAddress(config) {
24368
+ const volume = buildNamedVolumeName("p", "project", config.tenantId, config.workspaceId, config.projectId);
24369
+ return { volume, resourcePath: config.resourcePath };
24370
+ }
24371
+
24351
24372
  // src/sandbox_lattice/providers/MicrosandboxRemoteProvider.ts
24352
24373
  function parseOptionalNumberEnv(name, fallback) {
24353
24374
  const rawValue = process.env[name];
@@ -24373,6 +24394,7 @@ var MicrosandboxRemoteProvider = class {
24373
24394
  constructor(config) {
24374
24395
  this.config = config;
24375
24396
  this.creating = /* @__PURE__ */ new Map();
24397
+ this.createResourceAddress = createResourceAddress;
24376
24398
  this.client = config.client ?? new MicrosandboxServiceClient({
24377
24399
  baseURL: config.baseURL,
24378
24400
  apiKey: config.apiKey ?? process.env.MICROSANDBOX_API_KEY
@@ -24423,6 +24445,13 @@ var MicrosandboxRemoteProvider = class {
24423
24445
  async listSandboxes() {
24424
24446
  return [];
24425
24447
  }
24448
+ getResourceResolver() {
24449
+ return {
24450
+ resolve: async (address) => {
24451
+ return this.client.volumeFsDownload(address.volume, address.resourcePath);
24452
+ }
24453
+ };
24454
+ }
24426
24455
  buildEnsureInput(config) {
24427
24456
  const defaultMicrosandboxRemoteConfig = getDefaultMicrosandboxRemoteConfig();
24428
24457
  const image = this.config.image ?? defaultMicrosandboxRemoteConfig.image;
@@ -24658,6 +24687,7 @@ var RemoteSandboxProvider = class {
24658
24687
  this.creating = /* @__PURE__ */ new Map();
24659
24688
  this.workspace = DEFAULT_WORKSPACE;
24660
24689
  this.workspaceResolved = false;
24690
+ this.createResourceAddress = createResourceAddress;
24661
24691
  this.client = new import_sandbox23.SandboxClient({
24662
24692
  baseUrl: config.baseURL,
24663
24693
  environment: ""
@@ -24719,6 +24749,14 @@ var RemoteSandboxProvider = class {
24719
24749
  async listSandboxes() {
24720
24750
  return Array.from(this.instances.values());
24721
24751
  }
24752
+ getResourceResolver() {
24753
+ return {
24754
+ resolve: async (address) => {
24755
+ const client = this.createVolumeFsClient(address.volume, `/project`);
24756
+ return client.readRaw(address.resourcePath);
24757
+ }
24758
+ };
24759
+ }
24722
24760
  createVolumeFsClient(_volumeName, pathPrefix) {
24723
24761
  const workspace = this.workspace;
24724
24762
  const resolve4 = (p) => {
@@ -24910,6 +24948,7 @@ var E2BProvider = class {
24910
24948
  this.config = config;
24911
24949
  this.instances = /* @__PURE__ */ new Map();
24912
24950
  this.creating = /* @__PURE__ */ new Map();
24951
+ this.createResourceAddress = createResourceAddress;
24913
24952
  }
24914
24953
  async createSandbox(name, _config) {
24915
24954
  const existing = this.instances.get(name);
@@ -24967,6 +25006,16 @@ var E2BProvider = class {
24967
25006
  async listSandboxes() {
24968
25007
  return Array.from(this.instances.values());
24969
25008
  }
25009
+ getResourceResolver() {
25010
+ const instances = this.instances;
25011
+ return {
25012
+ resolve: async (address) => {
25013
+ const entry = Array.from(instances.values())[0];
25014
+ if (!entry) throw new Error("No sandbox instance available to resolve resource");
25015
+ return entry.file.downloadFile({ file: `/project/${address.resourcePath}` });
25016
+ }
25017
+ };
25018
+ }
24970
25019
  };
24971
25020
 
24972
25021
  // src/sandbox_lattice/providers/DaytonaProvider.ts
@@ -25094,6 +25143,7 @@ var DaytonaProvider = class {
25094
25143
  this.instances = /* @__PURE__ */ new Map();
25095
25144
  this.creating = /* @__PURE__ */ new Map();
25096
25145
  this.volumeId = null;
25146
+ this.createResourceAddress = createResourceAddress;
25097
25147
  this.daytona = new import_sdk.Daytona({
25098
25148
  apiKey: config.apiKey,
25099
25149
  apiUrl: config.apiUrl,
@@ -25278,11 +25328,22 @@ var DaytonaProvider = class {
25278
25328
  async listSandboxes() {
25279
25329
  return Array.from(this.instances.values());
25280
25330
  }
25331
+ getResourceResolver() {
25332
+ const instances = this.instances;
25333
+ return {
25334
+ resolve: async (address) => {
25335
+ const entry = Array.from(instances.values())[0];
25336
+ if (!entry) throw new Error("No sandbox instance available to resolve resource");
25337
+ return entry.file.downloadFile({ file: `/project/${address.resourcePath}` });
25338
+ }
25339
+ };
25340
+ }
25281
25341
  };
25282
25342
 
25283
25343
  // src/sandbox_lattice/providers/LocalSandboxProvider.ts
25284
25344
  var path4 = __toESM(require("path"));
25285
25345
  var os = __toESM(require("os"));
25346
+ var fs4 = __toESM(require("fs/promises"));
25286
25347
 
25287
25348
  // src/sandbox_lattice/LocalSandboxInstance.ts
25288
25349
  var import_node_child_process = require("child_process");
@@ -25497,6 +25558,7 @@ var LocalSandboxProvider = class {
25497
25558
  constructor(config = {}) {
25498
25559
  this.instances = /* @__PURE__ */ new Map();
25499
25560
  this.creating = /* @__PURE__ */ new Map();
25561
+ this.createResourceAddress = createResourceAddress;
25500
25562
  this.basePath = config.basePath ?? path4.join(os.homedir(), ".axiom-local-sandbox");
25501
25563
  }
25502
25564
  async createSandbox(name, _config) {
@@ -25549,6 +25611,14 @@ var LocalSandboxProvider = class {
25549
25611
  async listSandboxes() {
25550
25612
  return Array.from(this.instances.values());
25551
25613
  }
25614
+ getResourceResolver() {
25615
+ return {
25616
+ resolve: async (address) => {
25617
+ const hostPath = path4.join(this.basePath, "project", address.resourcePath);
25618
+ return fs4.readFile(hostPath);
25619
+ }
25620
+ };
25621
+ }
25552
25622
  };
25553
25623
 
25554
25624
  // src/sandbox_lattice/SandboxProviderFactory.ts
@@ -25605,6 +25675,77 @@ function createSandboxProvider(config) {
25605
25675
  }
25606
25676
  }
25607
25677
 
25678
+ // src/sandbox_lattice/TokenCache.ts
25679
+ var TokenCache = class {
25680
+ constructor() {
25681
+ this.cache = /* @__PURE__ */ new Map();
25682
+ this.ttlMs = 6e4;
25683
+ }
25684
+ /**
25685
+ * Look up a token in the cache.
25686
+ *
25687
+ * @param token - The share token.
25688
+ * @returns The cached entry, or `null` if the token is absent or expired.
25689
+ */
25690
+ get(token) {
25691
+ const item = this.cache.get(token);
25692
+ if (!item) return null;
25693
+ if (Date.now() > item.expires) {
25694
+ this.cache.delete(token);
25695
+ return null;
25696
+ }
25697
+ return item.entry;
25698
+ }
25699
+ /**
25700
+ * Store a token → address mapping.
25701
+ *
25702
+ * @param token - The share token.
25703
+ * @param entry - The cache entry to associate with the token.
25704
+ */
25705
+ set(token, entry) {
25706
+ this.cache.set(token, { entry, expires: Date.now() + this.ttlMs });
25707
+ }
25708
+ /**
25709
+ * Remove a cached entry (e.g. on revocation).
25710
+ *
25711
+ * @param token - The share token to invalidate.
25712
+ */
25713
+ invalidate(token) {
25714
+ this.cache.delete(token);
25715
+ }
25716
+ };
25717
+
25718
+ // src/sandbox_lattice/ShareService.ts
25719
+ var import_crypto4 = require("crypto");
25720
+ var import_bcryptjs = __toESM(require("bcryptjs"));
25721
+ var TOKEN_BYTES = 24;
25722
+ function generateToken() {
25723
+ return (0, import_crypto4.randomBytes)(TOKEN_BYTES).toString("base64url");
25724
+ }
25725
+ function createSharePayload(tenantId, workspaceId, projectId, userId, request) {
25726
+ const resourcePath = (request.resourcePath || "").replace(/^\/?project\//, "");
25727
+ return {
25728
+ address: createResourceAddress({
25729
+ tenantId,
25730
+ workspaceId,
25731
+ projectId,
25732
+ resourcePath
25733
+ }),
25734
+ tenantId,
25735
+ workspaceId,
25736
+ projectId,
25737
+ assistantId: request.assistantId ?? null,
25738
+ vmIsolation: "project",
25739
+ visibility: request.visibility ?? "public",
25740
+ passwordHash: request.visibility === "password" && request.password ? import_bcryptjs.default.hashSync(request.password, 10) : null,
25741
+ title: request.title ?? null,
25742
+ createdBy: userId,
25743
+ expiresAt: request.expiresAt ? new Date(request.expiresAt) : null,
25744
+ maxAccess: request.maxAccess ?? null,
25745
+ revoked: false
25746
+ };
25747
+ }
25748
+
25608
25749
  // src/channel/connectAllChannels.ts
25609
25750
  async function connectAllChannels(getAdapter, options = {}) {
25610
25751
  const store = getStoreLattice("default", "channelInstallation").store;
@@ -25645,7 +25786,7 @@ function getMenuRegistry() {
25645
25786
  var Protocols = __toESM(require("@axiom-lattice/protocols"));
25646
25787
 
25647
25788
  // src/util/encryption.ts
25648
- var import_crypto4 = require("crypto");
25789
+ var import_crypto5 = require("crypto");
25649
25790
  var ALGORITHM = "aes-256-gcm";
25650
25791
  var IV_LENGTH = 16;
25651
25792
  var SALT_LENGTH = 32;
@@ -25658,7 +25799,7 @@ function getEncryptionKey() {
25658
25799
  return cachedKey;
25659
25800
  }
25660
25801
  const key = process.env.LATTICE_ENCRYPTION_KEY || DEFAULT_ENCRYPTION_KEY;
25661
- cachedKey = (0, import_crypto4.pbkdf2Sync)(key, "lattice-encryption-salt", ITERATIONS, 32, "sha256");
25802
+ cachedKey = (0, import_crypto5.pbkdf2Sync)(key, "lattice-encryption-salt", ITERATIONS, 32, "sha256");
25662
25803
  if (!keyValidated) {
25663
25804
  keyValidated = true;
25664
25805
  validateEncryptionKey();
@@ -25667,10 +25808,10 @@ function getEncryptionKey() {
25667
25808
  }
25668
25809
  function encrypt(plaintext, key) {
25669
25810
  const actualKey = key || getEncryptionKey();
25670
- const salt = (0, import_crypto4.randomBytes)(SALT_LENGTH);
25671
- const iv = (0, import_crypto4.randomBytes)(IV_LENGTH);
25672
- const derivedKey = (0, import_crypto4.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
25673
- const cipher = (0, import_crypto4.createCipheriv)(ALGORITHM, derivedKey, iv);
25811
+ const salt = (0, import_crypto5.randomBytes)(SALT_LENGTH);
25812
+ const iv = (0, import_crypto5.randomBytes)(IV_LENGTH);
25813
+ const derivedKey = (0, import_crypto5.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
25814
+ const cipher = (0, import_crypto5.createCipheriv)(ALGORITHM, derivedKey, iv);
25674
25815
  const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
25675
25816
  const authTag = cipher.getAuthTag();
25676
25817
  return Buffer.concat([salt, iv, encrypted, authTag]).toString("base64");
@@ -25682,8 +25823,8 @@ function decrypt(encrypted, key) {
25682
25823
  const iv = data.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);
25683
25824
  const authTag = data.subarray(-16);
25684
25825
  const ciphertext = data.subarray(SALT_LENGTH + IV_LENGTH, -16);
25685
- const derivedKey = (0, import_crypto4.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
25686
- const decipher = (0, import_crypto4.createDecipheriv)(ALGORITHM, derivedKey, iv);
25826
+ const derivedKey = (0, import_crypto5.pbkdf2Sync)(actualKey, salt, ITERATIONS, 32, "sha256");
25827
+ const decipher = (0, import_crypto5.createDecipheriv)(ALGORITHM, derivedKey, iv);
25687
25828
  decipher.setAuthTag(authTag);
25688
25829
  return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
25689
25830
  }
@@ -25936,6 +26077,7 @@ PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
25936
26077
  TaskStatus,
25937
26078
  TeamAgentGraphBuilder,
25938
26079
  ThreadStatus,
26080
+ TokenCache,
25939
26081
  ToolLatticeManager,
25940
26082
  VectorStoreLatticeManager,
25941
26083
  VolumeFilesystem,
@@ -25973,8 +26115,10 @@ PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
25973
26115
  createQuerySqlTool,
25974
26116
  createQueryTableDefinitionTool,
25975
26117
  createQueryTablesListTool,
26118
+ createResourceAddress,
25976
26119
  createSandboxProvider,
25977
26120
  createSchedulerMiddleware,
26121
+ createSharePayload,
25978
26122
  createTaskMiddleware,
25979
26123
  createTeamMiddleware,
25980
26124
  createTeammateTools,
@@ -25994,6 +26138,7 @@ PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
25994
26138
  formatGrepMatches,
25995
26139
  formatGrepResults,
25996
26140
  formatReadResponse,
26141
+ generateToken,
25997
26142
  getAgentClient,
25998
26143
  getAgentConfig,
25999
26144
  getAllAgentConfigs,