@axiom-lattice/core 2.1.50 → 2.1.52

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.d.mts CHANGED
@@ -14,16 +14,16 @@ export { AgentConfig, AgentType, GraphBuildOptions, MemoryType } from '@axiom-la
14
14
  import * as langchain from 'langchain';
15
15
  import { ReactAgent, AgentMiddleware } from 'langchain';
16
16
  import z, { z as z$1 } from 'zod';
17
+ import { BaseStore, BaseCheckpointSaver } from '@langchain/langgraph-checkpoint';
17
18
  import * as _langchain_core_tools from '@langchain/core/tools';
18
19
  import { StructuredTool } from '@langchain/core/tools';
19
20
  import * as _langchain_langgraph from '@langchain/langgraph';
20
21
  import { CompiledStateGraph, CommandParams } from '@langchain/langgraph';
21
- import { BaseCheckpointSaver, BaseStore } from '@langchain/langgraph-checkpoint';
22
22
  import { ReplaySubject } from 'rxjs';
23
23
  import { Embeddings } from '@langchain/core/embeddings';
24
24
  import { VectorStore } from '@langchain/core/vectorstores';
25
25
  import { Connection, MultiServerMCPClient } from '@langchain/mcp-adapters';
26
- import { Sandbox } from 'microsandbox';
26
+ import { FsEntry, Sandbox } from 'microsandbox';
27
27
  import { SandboxClient } from '@agent-infra/sandbox';
28
28
  import { Sandbox as Sandbox$1 } from 'e2b';
29
29
  import { Sandbox as Sandbox$2 } from '@daytonaio/sdk';
@@ -1265,6 +1265,213 @@ declare const createExecuteSqlQueryTool: ({ serverKeys, serverDescriptions, getT
1265
1265
  datasourceId?: string | undefined;
1266
1266
  }, string, "execute_sql_query">;
1267
1267
 
1268
+ /**
1269
+ * Protocol definition for pluggable memory backends.
1270
+ *
1271
+ * This module defines the BackendProtocol that all backend implementations
1272
+ * must follow. Backends can store files in different locations (state, filesystem,
1273
+ * database, etc.) and provide a uniform interface for file operations.
1274
+ */
1275
+
1276
+ type MaybePromise<T> = T | Promise<T>;
1277
+ /**
1278
+ * Structured file listing info.
1279
+ *
1280
+ * Minimal contract used across backends. Only "path" is required.
1281
+ * Other fields are best-effort and may be absent depending on backend.
1282
+ */
1283
+ interface FileInfo {
1284
+ /** File path */
1285
+ path: string;
1286
+ /** Whether this is a directory */
1287
+ is_dir?: boolean;
1288
+ /** File size in bytes (approximate) */
1289
+ size?: number;
1290
+ /** ISO 8601 timestamp of last modification */
1291
+ modified_at?: string;
1292
+ }
1293
+ /**
1294
+ * Structured grep match entry.
1295
+ */
1296
+ interface GrepMatch {
1297
+ /** File path where match was found */
1298
+ path: string;
1299
+ /** Line number (1-indexed) */
1300
+ line: number;
1301
+ /** The matching line text */
1302
+ text: string;
1303
+ }
1304
+ /**
1305
+ * File data structure used by backends.
1306
+ *
1307
+ * All file data is represented as objects with this structure:
1308
+ */
1309
+ interface FileData {
1310
+ /** Lines of text content */
1311
+ content: string[];
1312
+ /** ISO format timestamp of creation */
1313
+ created_at: string;
1314
+ /** ISO format timestamp of last modification */
1315
+ modified_at: string;
1316
+ }
1317
+ /**
1318
+ * Result from backend write operations.
1319
+ *
1320
+ * Checkpoint backends populate filesUpdate with {file_path: file_data} for LangGraph state.
1321
+ * External backends set filesUpdate to null (already persisted to disk/S3/database/etc).
1322
+ */
1323
+ interface WriteResult {
1324
+ /** Error message on failure, undefined on success */
1325
+ error?: string;
1326
+ /** File path of written file, undefined on failure */
1327
+ path?: string;
1328
+ /**
1329
+ * State update dict for checkpoint backends, null for external storage.
1330
+ * Checkpoint backends populate this with {file_path: file_data} for LangGraph state.
1331
+ * External backends set null (already persisted to disk/S3/database/etc).
1332
+ */
1333
+ filesUpdate?: Record<string, FileData> | null;
1334
+ /** Metadata for the write operation, attached to the ToolMessage */
1335
+ metadata?: Record<string, unknown>;
1336
+ }
1337
+ /**
1338
+ * Result from backend edit operations.
1339
+ *
1340
+ * Checkpoint backends populate filesUpdate with {file_path: file_data} for LangGraph state.
1341
+ * External backends set filesUpdate to null (already persisted to disk/S3/database/etc).
1342
+ */
1343
+ interface EditResult {
1344
+ /** Error message on failure, undefined on success */
1345
+ error?: string;
1346
+ /** File path of edited file, undefined on failure */
1347
+ path?: string;
1348
+ /**
1349
+ * State update dict for checkpoint backends, null for external storage.
1350
+ * Checkpoint backends populate this with {file_path: file_data} for LangGraph state.
1351
+ * External backends set null (already persisted to disk/S3/database/etc).
1352
+ */
1353
+ filesUpdate?: Record<string, FileData> | null;
1354
+ /** Number of replacements made, undefined on failure */
1355
+ occurrences?: number;
1356
+ /** Metadata for the edit operation, attached to the ToolMessage */
1357
+ metadata?: Record<string, unknown>;
1358
+ }
1359
+ /**
1360
+ * Protocol for pluggable memory backends (single, unified).
1361
+ *
1362
+ * Backends can store files in different locations (state, filesystem, database, etc.)
1363
+ * and provide a uniform interface for file operations.
1364
+ *
1365
+ * All file data is represented as objects with the FileData structure.
1366
+ *
1367
+ * Methods can return either direct values or Promises, allowing both
1368
+ * synchronous and asynchronous implementations.
1369
+ */
1370
+ interface BackendProtocol {
1371
+ /**
1372
+ * Structured listing with file metadata.
1373
+ *
1374
+ * Lists files and directories in the specified directory (non-recursive).
1375
+ * Directories have a trailing / in their path and is_dir=true.
1376
+ *
1377
+ * @param path - Absolute path to directory
1378
+ * @returns List of FileInfo objects for files and directories directly in the directory
1379
+ */
1380
+ lsInfo(path: string): MaybePromise<FileInfo[]>;
1381
+ /**
1382
+ * Read file content with line numbers or an error string.
1383
+ *
1384
+ * @param filePath - Absolute file path
1385
+ * @param offset - Line offset to start reading from (0-indexed), default 0
1386
+ * @param limit - Maximum number of lines to read, default 2000
1387
+ * @returns Formatted file content with line numbers, or error message
1388
+ */
1389
+ read(filePath: string, offset?: number, limit?: number): MaybePromise<string>;
1390
+ /**
1391
+ * Read file content as raw FileData.
1392
+ *
1393
+ * @param filePath - Absolute file path
1394
+ * @returns Raw file content as FileData
1395
+ */
1396
+ readRaw(filePath: string): MaybePromise<FileData>;
1397
+ /**
1398
+ * Structured search results or error string for invalid input.
1399
+ *
1400
+ * Searches file contents for a regex pattern.
1401
+ *
1402
+ * @param pattern - Regex pattern to search for
1403
+ * @param path - Base path to search from (default: null)
1404
+ * @param glob - Optional glob pattern to filter files (e.g., "*.py")
1405
+ * @returns List of GrepMatch objects or error string for invalid regex
1406
+ */
1407
+ grepRaw(pattern: string, path?: string | null, glob?: string | null): MaybePromise<GrepMatch[] | string>;
1408
+ /**
1409
+ * Structured glob matching returning FileInfo objects.
1410
+ *
1411
+ * @param pattern - Glob pattern (e.g., `*.py`, `**\/*.ts`)
1412
+ * @param path - Base path to search from (default: "/")
1413
+ * @returns List of FileInfo objects matching the pattern
1414
+ */
1415
+ globInfo(pattern: string, path?: string): MaybePromise<FileInfo[]>;
1416
+ /**
1417
+ * Create a new file.
1418
+ *
1419
+ * @param filePath - Absolute file path
1420
+ * @param content - File content as string
1421
+ * @returns WriteResult with error populated on failure
1422
+ */
1423
+ write(filePath: string, content: string): MaybePromise<WriteResult>;
1424
+ /**
1425
+ * Edit a file by replacing string occurrences.
1426
+ *
1427
+ * @param filePath - Absolute file path
1428
+ * @param oldString - String to find and replace
1429
+ * @param newString - Replacement string
1430
+ * @param replaceAll - If true, replace all occurrences (default: false)
1431
+ * @returns EditResult with error, path, filesUpdate, and occurrences
1432
+ */
1433
+ edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): MaybePromise<EditResult>;
1434
+ }
1435
+ /**
1436
+ * State and store container for backend initialization.
1437
+ *
1438
+ * This provides a clean interface for what backends need to access:
1439
+ * - state: Current agent state (with files, messages, etc.)
1440
+ * - store: Optional persistent store for cross-conversation data
1441
+ *
1442
+ * Different contexts build this differently:
1443
+ * - Tools: Extract state via getCurrentTaskInput(config)
1444
+ * - Middleware: Use request.state directly
1445
+ */
1446
+ interface StateAndStore {
1447
+ /** Current agent state with files, messages, etc. */
1448
+ state: unknown;
1449
+ /** Optional BaseStore for persistent cross-conversation storage */
1450
+ store?: BaseStore;
1451
+ /** Optional assistant ID for per-assistant isolation in store */
1452
+ assistantId?: string;
1453
+ assistant_id?: string;
1454
+ threadId?: string;
1455
+ tenantId?: string;
1456
+ workspaceId?: string;
1457
+ projectId?: string;
1458
+ }
1459
+ /**
1460
+ * Factory function type for creating backend instances.
1461
+ *
1462
+ * Backends receive StateAndStore which contains the current state
1463
+ * and optional store, extracted from the execution context.
1464
+ *
1465
+ * @example
1466
+ * ```typescript
1467
+ * // Using in middleware
1468
+ * const middleware = createFilesystemMiddleware({
1469
+ * backend: (stateAndStore) => new StateBackend(stateAndStore)
1470
+ * });
1471
+ * ```
1472
+ */
1473
+ type BackendFactory = (stateAndStore: StateAndStore) => Promise<BackendProtocol>;
1474
+
1268
1475
  interface SandboxFileInfo {
1269
1476
  path: string;
1270
1477
  is_dir: boolean;
@@ -1356,6 +1563,7 @@ interface SandboxManagerProtocol {
1356
1563
  stopSandbox(name: string): Promise<void>;
1357
1564
  deleteSandbox(name: string): Promise<void>;
1358
1565
  listSandboxes(): Promise<SandboxInstance[]>;
1566
+ getVolumeBackend(config: RunSandboxConfig): Promise<BackendProtocol | null>;
1359
1567
  }
1360
1568
 
1361
1569
  type ToolDefinition = ToolConfig;
@@ -3514,12 +3722,21 @@ declare class McpLatticeManager extends BaseLatticeManager<McpLatticeInterface>
3514
3722
  }
3515
3723
  declare const mcpManager: McpLatticeManager;
3516
3724
 
3725
+ interface VolumeFsClient {
3726
+ read(path: string): Promise<string>;
3727
+ write(path: string, content: string): Promise<void>;
3728
+ list(path: string): Promise<FsEntry[]>;
3729
+ readRaw(path: string): Promise<Buffer>;
3730
+ writeRaw(path: string, data: Buffer): Promise<void>;
3731
+ }
3732
+
3517
3733
  interface SandboxProvider {
3518
3734
  createSandbox(name: string, config?: RunSandboxConfig): Promise<SandboxInstance>;
3519
3735
  getSandbox(name: string): Promise<SandboxInstance>;
3520
3736
  stopSandbox(name: string): Promise<void>;
3521
3737
  deleteSandbox(name: string): Promise<void>;
3522
3738
  listSandboxes(): Promise<SandboxInstance[]>;
3739
+ createVolumeFsClient?(volumeName: string): VolumeFsClient;
3523
3740
  }
3524
3741
 
3525
3742
  interface MicrosandboxProviderConfig {
@@ -3534,7 +3751,7 @@ declare class MicrosandboxProvider implements SandboxProvider {
3534
3751
  private instances;
3535
3752
  private creating;
3536
3753
  constructor(config?: MicrosandboxProviderConfig);
3537
- createSandbox(name: string): Promise<SandboxInstance>;
3754
+ createSandbox(name: string, config?: RunSandboxConfig): Promise<SandboxInstance>;
3538
3755
  getSandbox(name: string): Promise<SandboxInstance>;
3539
3756
  stopSandbox(name: string): Promise<void>;
3540
3757
  deleteSandbox(name: string): Promise<void>;
@@ -3580,6 +3797,15 @@ type ExecCommandResponse = {
3580
3797
  stderr: string;
3581
3798
  exitCode: number;
3582
3799
  };
3800
+ type VolumeFsListResponse = {
3801
+ entries: Array<{
3802
+ path: string;
3803
+ kind: string;
3804
+ size: number;
3805
+ mode: number;
3806
+ modified: string | null;
3807
+ }>;
3808
+ };
3583
3809
  interface EnsureMicrosandboxInput {
3584
3810
  image?: string;
3585
3811
  cpus?: number;
@@ -3595,9 +3821,11 @@ interface MicrosandboxShellExecInput {
3595
3821
  }
3596
3822
  interface MicrosandboxServiceClientConfig {
3597
3823
  baseURL: string;
3824
+ apiKey?: string;
3598
3825
  }
3599
3826
  declare class MicrosandboxServiceClient {
3600
3827
  private readonly baseURL;
3828
+ private readonly apiKey?;
3601
3829
  constructor(config: MicrosandboxServiceClientConfig);
3602
3830
  ensureSandbox(name: string, input: EnsureMicrosandboxInput): Promise<SandboxLifecycleResponse>;
3603
3831
  startSandbox(name: string): Promise<SandboxLifecycleResponse>;
@@ -3618,11 +3846,17 @@ declare class MicrosandboxServiceClient {
3618
3846
  uploadFile(sandboxName: string, path: string, content: Buffer): Promise<WriteFileResponse>;
3619
3847
  downloadFile(sandboxName: string, path: string): Promise<DownloadFileResponse>;
3620
3848
  execCommand(input: MicrosandboxShellExecInput): Promise<ExecCommandResponse>;
3849
+ volumeFsRead(volumeName: string, path: string): Promise<string>;
3850
+ volumeFsWrite(volumeName: string, path: string, content: string): Promise<void>;
3851
+ volumeFsList(volumeName: string, path: string): Promise<VolumeFsListResponse["entries"]>;
3852
+ volumeFsDownload(volumeName: string, path: string): Promise<Buffer>;
3853
+ volumeFsUpload(volumeName: string, path: string, data: Buffer): Promise<void>;
3621
3854
  private request;
3622
3855
  }
3623
3856
 
3857
+ type MicrosandboxRemoteProviderClient = Pick<MicrosandboxServiceClient, "ensureSandbox" | "startSandbox" | "stopSandbox" | "killSandbox" | "deleteSandbox" | "getStatus" | "readFile" | "writeFile" | "listPath" | "findFiles" | "searchInFile" | "replaceInFile" | "uploadFile" | "downloadFile" | "execCommand" | "volumeFsRead" | "volumeFsWrite" | "volumeFsList" | "volumeFsDownload" | "volumeFsUpload">;
3624
3858
  interface MicrosandboxRemoteProviderConfig extends MicrosandboxServiceClientConfig {
3625
- client?: Pick<MicrosandboxServiceClient, "ensureSandbox"> & Partial<MicrosandboxServiceClient>;
3859
+ client?: MicrosandboxRemoteProviderClient;
3626
3860
  image?: string;
3627
3861
  cpus?: number;
3628
3862
  memoryMib?: number;
@@ -3638,6 +3872,7 @@ declare class MicrosandboxRemoteProvider implements SandboxProvider {
3638
3872
  getSandbox(name: string): Promise<SandboxInstance>;
3639
3873
  stopSandbox(name: string): Promise<void>;
3640
3874
  deleteSandbox(name: string): Promise<void>;
3875
+ createVolumeFsClient(volumeName: string): VolumeFsClient;
3641
3876
  listSandboxes(): Promise<SandboxInstance[]>;
3642
3877
  private buildEnsureInput;
3643
3878
  private buildDefaultVolumes;
@@ -3828,15 +4063,6 @@ declare class DaytonaInstance implements SandboxInstance {
3828
4063
  private native;
3829
4064
  readonly name: string;
3830
4065
  constructor(name: string, native: Sandbox$2);
3831
- /**
3832
- * All sandbox file operations live under the user's home directory (~).
3833
- * The AI uses virtual paths like "~/agent/file.txt". Daytona SDK expects
3834
- * relative paths for file operations (they are resolved against ~ automatically),
3835
- * so we strip the leading "~/" or "/" here.
3836
- *
3837
- * Handles edge cases like "~/~/agent/file.txt" by repeatedly stripping prefixes.
3838
- */
3839
- private toSandboxHomePath;
3840
4066
  start(): Promise<void>;
3841
4067
  stop(): Promise<void>;
3842
4068
  kill(): Promise<void>;
@@ -3868,6 +4094,7 @@ declare class SandboxLatticeManager extends BaseLatticeManager<SandboxProvider>
3868
4094
  vmIsolation: SandboxIsolationLevel;
3869
4095
  };
3870
4096
  getSandboxFromConfig(config: RunSandboxConfig): Promise<SandboxInstance>;
4097
+ getVolumeBackend(config: RunSandboxConfig): Promise<BackendProtocol | null>;
3871
4098
  createSandbox(name: string, config?: RunSandboxConfig): Promise<SandboxInstance>;
3872
4099
  getSandbox(name: string): Promise<SandboxInstance>;
3873
4100
  stopSandbox(name: string): Promise<void>;
@@ -3879,24 +4106,16 @@ declare const sandboxLatticeManager: SandboxLatticeManager;
3879
4106
  declare const getSandBoxManager: (key?: string) => SandboxManagerProtocol;
3880
4107
 
3881
4108
  /**
3882
- * Sandbox name normalization utility
3883
- *
3884
- * Normalizes sandbox names to comply with RFC 1123 subdomain naming requirements:
3885
- * - Only lowercase alphanumeric characters, '-' or '.'
3886
- * - Must start and end with an alphanumeric character
3887
- * - No underscores or other special characters
3888
- */
3889
- /**
3890
- * Normalize a sandbox name to be RFC 1123 compliant
4109
+ * Generate a sandbox name from meaningful identifiers.
3891
4110
  *
3892
- * @param name - The sandbox name to normalize
3893
- * @returns Normalized sandbox name that complies with RFC 1123 subdomain rules
4111
+ * All sandbox names are hashed (like buildNamedVolumeName) producing a
4112
+ * fixed 17-char "n<hash>" format. This avoids Unix domain socket path
4113
+ * length limits (SUN_LEN = 104 on macOS, 108 on Linux) regardless of
4114
+ * how long the input identifiers are.
3894
4115
  *
3895
- * @example
3896
- * normalizeSandboxName("sandbox_agent") // returns "sandbox-agent"
3897
- * normalizeSandboxName("My-Sandbox") // returns "my-sandbox"
3898
- * normalizeSandboxName("test.sandbox") // returns "test.sandbox"
3899
- * normalizeSandboxName("_invalid_") // returns "invalid"
4116
+ * Original identity metadata (tenant, assistant, project, etc.) should
4117
+ * be passed via sandbox env so operational tooling can still map names
4118
+ * back to their source.
3900
4119
  */
3901
4120
  declare function normalizeSandboxName(name: string): string;
3902
4121
  /**
@@ -3906,6 +4125,14 @@ declare function normalizeSandboxName(name: string): string;
3906
4125
  * @returns true if the name is valid, false otherwise
3907
4126
  */
3908
4127
  declare function isValidSandboxName(name: string): boolean;
4128
+ /**
4129
+ * Build env vars mapping a hashed sandbox name back to its source metadata.
4130
+ * Injected into every sandbox so operational tooling can correlate
4131
+ * opaque "n<hash>" names to the original tenant/assistant/project/workspace.
4132
+ */
4133
+ declare function buildSandboxMetadataEnv(config?: RunSandboxConfig): Record<string, string>;
4134
+
4135
+ declare function buildNamedVolumeName(prefix: "s" | "a" | "p", ...parts: Array<string | undefined>): string;
3909
4136
 
3910
4137
  /**
3911
4138
  * Agent Team - Store Protocols
@@ -4475,213 +4702,6 @@ declare class TeamAgentGraphBuilder implements AgentGraphBuilder {
4475
4702
  */
4476
4703
  declare function createAgentTeam(config: TeamConfig): ReactAgent<any, any, any, any>;
4477
4704
 
4478
- /**
4479
- * Protocol definition for pluggable memory backends.
4480
- *
4481
- * This module defines the BackendProtocol that all backend implementations
4482
- * must follow. Backends can store files in different locations (state, filesystem,
4483
- * database, etc.) and provide a uniform interface for file operations.
4484
- */
4485
-
4486
- type MaybePromise<T> = T | Promise<T>;
4487
- /**
4488
- * Structured file listing info.
4489
- *
4490
- * Minimal contract used across backends. Only "path" is required.
4491
- * Other fields are best-effort and may be absent depending on backend.
4492
- */
4493
- interface FileInfo {
4494
- /** File path */
4495
- path: string;
4496
- /** Whether this is a directory */
4497
- is_dir?: boolean;
4498
- /** File size in bytes (approximate) */
4499
- size?: number;
4500
- /** ISO 8601 timestamp of last modification */
4501
- modified_at?: string;
4502
- }
4503
- /**
4504
- * Structured grep match entry.
4505
- */
4506
- interface GrepMatch {
4507
- /** File path where match was found */
4508
- path: string;
4509
- /** Line number (1-indexed) */
4510
- line: number;
4511
- /** The matching line text */
4512
- text: string;
4513
- }
4514
- /**
4515
- * File data structure used by backends.
4516
- *
4517
- * All file data is represented as objects with this structure:
4518
- */
4519
- interface FileData {
4520
- /** Lines of text content */
4521
- content: string[];
4522
- /** ISO format timestamp of creation */
4523
- created_at: string;
4524
- /** ISO format timestamp of last modification */
4525
- modified_at: string;
4526
- }
4527
- /**
4528
- * Result from backend write operations.
4529
- *
4530
- * Checkpoint backends populate filesUpdate with {file_path: file_data} for LangGraph state.
4531
- * External backends set filesUpdate to null (already persisted to disk/S3/database/etc).
4532
- */
4533
- interface WriteResult {
4534
- /** Error message on failure, undefined on success */
4535
- error?: string;
4536
- /** File path of written file, undefined on failure */
4537
- path?: string;
4538
- /**
4539
- * State update dict for checkpoint backends, null for external storage.
4540
- * Checkpoint backends populate this with {file_path: file_data} for LangGraph state.
4541
- * External backends set null (already persisted to disk/S3/database/etc).
4542
- */
4543
- filesUpdate?: Record<string, FileData> | null;
4544
- /** Metadata for the write operation, attached to the ToolMessage */
4545
- metadata?: Record<string, unknown>;
4546
- }
4547
- /**
4548
- * Result from backend edit operations.
4549
- *
4550
- * Checkpoint backends populate filesUpdate with {file_path: file_data} for LangGraph state.
4551
- * External backends set filesUpdate to null (already persisted to disk/S3/database/etc).
4552
- */
4553
- interface EditResult {
4554
- /** Error message on failure, undefined on success */
4555
- error?: string;
4556
- /** File path of edited file, undefined on failure */
4557
- path?: string;
4558
- /**
4559
- * State update dict for checkpoint backends, null for external storage.
4560
- * Checkpoint backends populate this with {file_path: file_data} for LangGraph state.
4561
- * External backends set null (already persisted to disk/S3/database/etc).
4562
- */
4563
- filesUpdate?: Record<string, FileData> | null;
4564
- /** Number of replacements made, undefined on failure */
4565
- occurrences?: number;
4566
- /** Metadata for the edit operation, attached to the ToolMessage */
4567
- metadata?: Record<string, unknown>;
4568
- }
4569
- /**
4570
- * Protocol for pluggable memory backends (single, unified).
4571
- *
4572
- * Backends can store files in different locations (state, filesystem, database, etc.)
4573
- * and provide a uniform interface for file operations.
4574
- *
4575
- * All file data is represented as objects with the FileData structure.
4576
- *
4577
- * Methods can return either direct values or Promises, allowing both
4578
- * synchronous and asynchronous implementations.
4579
- */
4580
- interface BackendProtocol {
4581
- /**
4582
- * Structured listing with file metadata.
4583
- *
4584
- * Lists files and directories in the specified directory (non-recursive).
4585
- * Directories have a trailing / in their path and is_dir=true.
4586
- *
4587
- * @param path - Absolute path to directory
4588
- * @returns List of FileInfo objects for files and directories directly in the directory
4589
- */
4590
- lsInfo(path: string): MaybePromise<FileInfo[]>;
4591
- /**
4592
- * Read file content with line numbers or an error string.
4593
- *
4594
- * @param filePath - Absolute file path
4595
- * @param offset - Line offset to start reading from (0-indexed), default 0
4596
- * @param limit - Maximum number of lines to read, default 2000
4597
- * @returns Formatted file content with line numbers, or error message
4598
- */
4599
- read(filePath: string, offset?: number, limit?: number): MaybePromise<string>;
4600
- /**
4601
- * Read file content as raw FileData.
4602
- *
4603
- * @param filePath - Absolute file path
4604
- * @returns Raw file content as FileData
4605
- */
4606
- readRaw(filePath: string): MaybePromise<FileData>;
4607
- /**
4608
- * Structured search results or error string for invalid input.
4609
- *
4610
- * Searches file contents for a regex pattern.
4611
- *
4612
- * @param pattern - Regex pattern to search for
4613
- * @param path - Base path to search from (default: null)
4614
- * @param glob - Optional glob pattern to filter files (e.g., "*.py")
4615
- * @returns List of GrepMatch objects or error string for invalid regex
4616
- */
4617
- grepRaw(pattern: string, path?: string | null, glob?: string | null): MaybePromise<GrepMatch[] | string>;
4618
- /**
4619
- * Structured glob matching returning FileInfo objects.
4620
- *
4621
- * @param pattern - Glob pattern (e.g., `*.py`, `**\/*.ts`)
4622
- * @param path - Base path to search from (default: "/")
4623
- * @returns List of FileInfo objects matching the pattern
4624
- */
4625
- globInfo(pattern: string, path?: string): MaybePromise<FileInfo[]>;
4626
- /**
4627
- * Create a new file.
4628
- *
4629
- * @param filePath - Absolute file path
4630
- * @param content - File content as string
4631
- * @returns WriteResult with error populated on failure
4632
- */
4633
- write(filePath: string, content: string): MaybePromise<WriteResult>;
4634
- /**
4635
- * Edit a file by replacing string occurrences.
4636
- *
4637
- * @param filePath - Absolute file path
4638
- * @param oldString - String to find and replace
4639
- * @param newString - Replacement string
4640
- * @param replaceAll - If true, replace all occurrences (default: false)
4641
- * @returns EditResult with error, path, filesUpdate, and occurrences
4642
- */
4643
- edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): MaybePromise<EditResult>;
4644
- }
4645
- /**
4646
- * State and store container for backend initialization.
4647
- *
4648
- * This provides a clean interface for what backends need to access:
4649
- * - state: Current agent state (with files, messages, etc.)
4650
- * - store: Optional persistent store for cross-conversation data
4651
- *
4652
- * Different contexts build this differently:
4653
- * - Tools: Extract state via getCurrentTaskInput(config)
4654
- * - Middleware: Use request.state directly
4655
- */
4656
- interface StateAndStore {
4657
- /** Current agent state with files, messages, etc. */
4658
- state: unknown;
4659
- /** Optional BaseStore for persistent cross-conversation storage */
4660
- store?: BaseStore;
4661
- /** Optional assistant ID for per-assistant isolation in store */
4662
- assistantId?: string;
4663
- assistant_id?: string;
4664
- threadId?: string;
4665
- tenantId?: string;
4666
- workspaceId?: string;
4667
- projectId?: string;
4668
- }
4669
- /**
4670
- * Factory function type for creating backend instances.
4671
- *
4672
- * Backends receive StateAndStore which contains the current state
4673
- * and optional store, extracted from the execution context.
4674
- *
4675
- * @example
4676
- * ```typescript
4677
- * // Using in middleware
4678
- * const middleware = createFilesystemMiddleware({
4679
- * backend: (stateAndStore) => new StateBackend(stateAndStore)
4680
- * });
4681
- * ```
4682
- */
4683
- type BackendFactory = (stateAndStore: StateAndStore) => Promise<BackendProtocol>;
4684
-
4685
4705
  /**
4686
4706
  * StateBackend: Store files in LangGraph agent state (ephemeral).
4687
4707
  */
@@ -5062,6 +5082,18 @@ declare class SandboxFilesystem implements BackendProtocol {
5062
5082
  globInfo(pattern: string, searchPath?: string): Promise<FileInfo[]>;
5063
5083
  }
5064
5084
 
5085
+ declare class VolumeFilesystem implements BackendProtocol {
5086
+ private readonly client;
5087
+ constructor(client: VolumeFsClient);
5088
+ lsInfo(path: string): Promise<FileInfo[]>;
5089
+ read(filePath: string, offset?: number, limit?: number): Promise<string>;
5090
+ readRaw(filePath: string): Promise<FileData>;
5091
+ grepRaw(_pattern: string, _path?: string | null, _glob?: string | null): string | GrepMatch[];
5092
+ globInfo(_pattern: string, _path?: string): FileInfo[];
5093
+ write(filePath: string, content: string): Promise<WriteResult>;
5094
+ edit(_filePath: string, _oldString: string, _newString: string, _replaceAll?: boolean): EditResult;
5095
+ }
5096
+
5065
5097
  /**
5066
5098
  * Shared utility functions for memory backend implementations.
5067
5099
  *
@@ -5661,4 +5693,4 @@ interface SchedulerMiddlewareOptions {
5661
5693
  }
5662
5694
  declare function createSchedulerMiddleware(options?: SchedulerMiddlewareOptions): AgentMiddleware;
5663
5695
 
5664
- export { AGENT_TASK_EVENT, type AddMessageParams, Agent, type AgentClient, type AgentExecutor, AgentInstanceManager, type AgentLattice, AgentLatticeManager, type AgentLifecycleEventName, AgentManager, type AgentStreamExecutor, type AgentThreadInterface, type BackendFactory, type BackendProtocol, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, CompositeBackend, ConsoleLoggerClient, type CreateSandboxProviderConfig, type CronFields, CustomMetricsClient, type DatabaseConfig, type DatabaseType, DaytonaInstance, DaytonaProvider, type DaytonaProviderConfig, DefaultScheduleClient, E2BInstance, E2BProvider, type E2BProviderConfig, EMPTY_CONTENT_WARNING, type EditResult, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type EnsureMicrosandboxInput, type FileData, type FileInfo, FileSystemSkillStore, type FileSystemSkillStoreOptions, FilesystemBackend, type GrepMatch, type IMessageQueueStore, type IMetricsServerClient, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryDatabaseConfigStore, InMemoryMailboxStore, InMemoryTaskListStore, InMemoryTenantStore, InMemoryThreadMessageQueueStore, InMemoryThreadStore, InMemoryUserStore, InMemoryUserTenantLinkStore, LINE_NUMBER_WIDTH, type LangGraphStateChecker, type LoggerLattice, LoggerLatticeManager, MAX_LINE_LENGTH, type MailboxMessage, type MailboxStore, type McpLatticeInterface, McpLatticeManager, type McpServerInfo, MemoryBackend, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, type MessageCompletedEvent, type MessageFailedEvent, type MessageStartedEvent, MessageType, MetricsServerManager, MicrosandboxInstance, MicrosandboxProvider, type MicrosandboxProviderConfig, MicrosandboxRemoteInstance, MicrosandboxRemoteProvider, type MicrosandboxRemoteProviderConfig, MicrosandboxServiceClient, type MicrosandboxServiceClientConfig, type MicrosandboxShellExecInput, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type PendingMessage, PinoLoggerClient, PostgresDatabase, PrometheusClient, type QueryResult, type QueueLattice, QueueLatticeManager, QueueMode, type QueuePendingEvent, RemoteSandboxInstance, RemoteSandboxProvider, type RemoteSandboxProviderConfig, type RunSandboxConfig, type RuntimeModelConfig, type SandboxFileInfo, type SandboxFileService, SandboxFilesystem, type SandboxInstance, type SandboxIsolationLevel, SandboxLatticeManager, type SandboxManagerProtocol, type SandboxProvider, type SandboxShellService, SandboxSkillStore, type SandboxSkillStoreOptions, type SandboxVolumeDefinition, type ScheduleLattice, ScheduleLatticeManager, type SchedulerMiddlewareOptions, SemanticMetricsClient, type SkillLattice, SkillLatticeManager, type SkillMeta, type SkillResource, SqlDatabaseManager, type StateAndStore, StateBackend, StoreBackend, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, TOOL_RESULT_TOKEN_LIMIT, TRUNCATION_GUIDANCE, type TableInfo, type TableSchema, type TaskEvent, type TaskListStore, type TaskSpec, TaskStatus, type TaskUpdatable, TeamAgentGraphBuilder, type TeamConfig, type TeamMiddlewareOptions, type TeamTask, type TeammateSpec, type TeammateToolsOptions, type ThreadBuffer, type ThreadBufferConfig, type ThreadBusyEvent, type ThreadIdleEvent, type ThreadInfo, type ThreadQueueConfig, type ThreadState, ThreadStatus, type ThreadStatusChangedEvent, type ToolDefinition, type ToolLattice, ToolLatticeManager, type UnknownToolHandlerConfig, type VectorStoreLatticeInterface, VectorStoreLatticeManager, type WriteResult, agentInstanceManager, agentLatticeManager, buildGrepResultsDict, buildSkillFile, checkEmptyContent, clearEncryptionKeyCache, computeSandboxName, createAgentTeam, createExecuteSqlQueryTool, createFileData, createInfoSqlTool, createListMetricsDataSourcesTool, createListMetricsServersTool, createListTablesSqlTool, createModelSelectorMiddleware, createQueryCheckerSqlTool, createQueryMetricDefinitionTool, createQueryMetricsListTool, createQuerySemanticMetricDataTool, createQuerySqlTool, createQueryTableDefinitionTool, createQueryTablesListTool, createSandboxProvider, createSchedulerMiddleware, createTeamMiddleware, createTeammateTools, createUnknownToolHandlerMiddleware, createWidgetMiddleware, decrypt, defaultMicrosandboxConfig, describeCronExpression, embeddingsLatticeManager, encrypt, eventBus, eventBus as eventBusDefault, fileDataToString, formatContentWithLineNumbers, formatGrepMatches, formatGrepResults, formatReadResponse, getAgentClient, getAgentConfig, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getEncryptionKey, getLoggerLattice, getModelLattice, getNextCronTime, getQueueLattice, getSandBoxManager, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, globSearchFiles, grepMatchesFromFiles, grepSearchFiles, hasChunkBuffer, isUsingDefaultKey, isValidCronExpression, isValidSandboxName, isValidSkillName, loggerLatticeManager, mcpManager, metricsServerManager, modelLatticeManager, normalizeSandboxName, parseCronExpression, parseSkillFrontmatter, performStringReplacement, queueLatticeManager, registerAgentLattice, registerAgentLatticeWithTenant, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerExistingTool, registerLoggerLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerTeammateAgent, registerToolLattice, registerVectorStoreLattice, sandboxLatticeManager, sanitizeToolCallId, scheduleLatticeManager, skillLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, truncateIfTooLong, unregisterTeammateAgent, updateFileData, validateAgentInput, validateEncryptionKey, validatePath, validateSkillName, validateToolInput, vectorStoreLatticeManager };
5696
+ export { AGENT_TASK_EVENT, type AddMessageParams, Agent, type AgentClient, type AgentExecutor, AgentInstanceManager, type AgentLattice, AgentLatticeManager, type AgentLifecycleEventName, AgentManager, type AgentStreamExecutor, type AgentThreadInterface, type BackendFactory, type BackendProtocol, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, CompositeBackend, ConsoleLoggerClient, type CreateSandboxProviderConfig, type CronFields, CustomMetricsClient, type DatabaseConfig, type DatabaseType, DaytonaInstance, DaytonaProvider, type DaytonaProviderConfig, DefaultScheduleClient, E2BInstance, E2BProvider, type E2BProviderConfig, EMPTY_CONTENT_WARNING, type EditResult, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type EnsureMicrosandboxInput, type FileData, type FileInfo, FileSystemSkillStore, type FileSystemSkillStoreOptions, FilesystemBackend, type GrepMatch, type IMessageQueueStore, type IMetricsServerClient, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryDatabaseConfigStore, InMemoryMailboxStore, InMemoryTaskListStore, InMemoryTenantStore, InMemoryThreadMessageQueueStore, InMemoryThreadStore, InMemoryUserStore, InMemoryUserTenantLinkStore, LINE_NUMBER_WIDTH, type LangGraphStateChecker, type LoggerLattice, LoggerLatticeManager, MAX_LINE_LENGTH, type MailboxMessage, type MailboxStore, type McpLatticeInterface, McpLatticeManager, type McpServerInfo, MemoryBackend, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, type MessageCompletedEvent, type MessageFailedEvent, type MessageStartedEvent, MessageType, MetricsServerManager, MicrosandboxInstance, MicrosandboxProvider, type MicrosandboxProviderConfig, MicrosandboxRemoteInstance, MicrosandboxRemoteProvider, type MicrosandboxRemoteProviderClient, type MicrosandboxRemoteProviderConfig, MicrosandboxServiceClient, type MicrosandboxServiceClientConfig, type MicrosandboxShellExecInput, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type PendingMessage, PinoLoggerClient, PostgresDatabase, PrometheusClient, type QueryResult, type QueueLattice, QueueLatticeManager, QueueMode, type QueuePendingEvent, RemoteSandboxInstance, RemoteSandboxProvider, type RemoteSandboxProviderConfig, type RunSandboxConfig, type RuntimeModelConfig, type SandboxFileInfo, type SandboxFileService, SandboxFilesystem, type SandboxInstance, type SandboxIsolationLevel, SandboxLatticeManager, type SandboxManagerProtocol, type SandboxProvider, type SandboxShellService, SandboxSkillStore, type SandboxSkillStoreOptions, type SandboxVolumeDefinition, type ScheduleLattice, ScheduleLatticeManager, type SchedulerMiddlewareOptions, SemanticMetricsClient, type SkillLattice, SkillLatticeManager, type SkillMeta, type SkillResource, SqlDatabaseManager, type StateAndStore, StateBackend, StoreBackend, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, TOOL_RESULT_TOKEN_LIMIT, TRUNCATION_GUIDANCE, type TableInfo, type TableSchema, type TaskEvent, type TaskListStore, type TaskSpec, TaskStatus, type TaskUpdatable, TeamAgentGraphBuilder, type TeamConfig, type TeamMiddlewareOptions, type TeamTask, type TeammateSpec, type TeammateToolsOptions, type ThreadBuffer, type ThreadBufferConfig, type ThreadBusyEvent, type ThreadIdleEvent, type ThreadInfo, type ThreadQueueConfig, type ThreadState, ThreadStatus, type ThreadStatusChangedEvent, type ToolDefinition, type ToolLattice, ToolLatticeManager, type UnknownToolHandlerConfig, type VectorStoreLatticeInterface, VectorStoreLatticeManager, VolumeFilesystem, type VolumeFsClient, type WriteResult, agentInstanceManager, agentLatticeManager, buildGrepResultsDict, buildNamedVolumeName, buildSandboxMetadataEnv, buildSkillFile, checkEmptyContent, clearEncryptionKeyCache, computeSandboxName, createAgentTeam, createExecuteSqlQueryTool, createFileData, createInfoSqlTool, createListMetricsDataSourcesTool, createListMetricsServersTool, createListTablesSqlTool, createModelSelectorMiddleware, createQueryCheckerSqlTool, createQueryMetricDefinitionTool, createQueryMetricsListTool, createQuerySemanticMetricDataTool, createQuerySqlTool, createQueryTableDefinitionTool, createQueryTablesListTool, createSandboxProvider, createSchedulerMiddleware, createTeamMiddleware, createTeammateTools, createUnknownToolHandlerMiddleware, createWidgetMiddleware, decrypt, defaultMicrosandboxConfig, describeCronExpression, embeddingsLatticeManager, encrypt, eventBus, eventBus as eventBusDefault, fileDataToString, formatContentWithLineNumbers, formatGrepMatches, formatGrepResults, formatReadResponse, getAgentClient, getAgentConfig, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getEncryptionKey, getLoggerLattice, getModelLattice, getNextCronTime, getQueueLattice, getSandBoxManager, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, globSearchFiles, grepMatchesFromFiles, grepSearchFiles, hasChunkBuffer, isUsingDefaultKey, isValidCronExpression, isValidSandboxName, isValidSkillName, loggerLatticeManager, mcpManager, metricsServerManager, modelLatticeManager, normalizeSandboxName, parseCronExpression, parseSkillFrontmatter, performStringReplacement, queueLatticeManager, registerAgentLattice, registerAgentLatticeWithTenant, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerExistingTool, registerLoggerLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerTeammateAgent, registerToolLattice, registerVectorStoreLattice, sandboxLatticeManager, sanitizeToolCallId, scheduleLatticeManager, skillLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, truncateIfTooLong, unregisterTeammateAgent, updateFileData, validateAgentInput, validateEncryptionKey, validatePath, validateSkillName, validateToolInput, vectorStoreLatticeManager };