@evolvingmachines/sdk 0.0.21 → 0.0.23

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.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as zod from 'zod';
2
2
  import { z } from 'zod';
3
3
  import { EventEmitter } from 'events';
4
- export { E2BProvider } from '@evolvingmachines/e2b';
5
- export { DaytonaProvider } from '@evolvingmachines/daytona';
6
- export { ModalProvider } from '@evolvingmachines/modal';
4
+ export { E2BProvider, createE2BProvider } from '@evolvingmachines/e2b';
5
+ export { DaytonaProvider, createDaytonaProvider } from '@evolvingmachines/daytona';
6
+ export { ModalProvider, createModalProvider } from '@evolvingmachines/modal';
7
7
 
8
8
  /**
9
9
  * ACP-inspired output types for unified agent event streaming.
@@ -364,13 +364,15 @@ interface SandboxProvider {
364
364
  connect(sandboxId: string, timeoutMs?: number): Promise<SandboxInstance>;
365
365
  }
366
366
  /** Supported agent types (headless CLI agents only, no ACP) */
367
- type AgentType = "claude" | "codex" | "gemini" | "qwen";
367
+ type AgentType = "claude" | "codex" | "gemini" | "qwen" | "kimi" | "opencode";
368
368
  /** Agent type constants for use in code */
369
369
  declare const AGENT_TYPES: {
370
370
  readonly CLAUDE: "claude";
371
371
  readonly CODEX: "codex";
372
372
  readonly GEMINI: "gemini";
373
373
  readonly QWEN: "qwen";
374
+ readonly KIMI: "kimi";
375
+ readonly OPENCODE: "opencode";
374
376
  };
375
377
  /** Workspace mode determines folder structure and system prompt */
376
378
  type WorkspaceMode = "knowledge" | "swe";
@@ -532,6 +534,8 @@ interface AgentOptions {
532
534
  * Set via withComposio() - provides access to 1000+ tools
533
535
  */
534
536
  composio?: ComposioSetup;
537
+ /** Resolved storage configuration (set via Evolve.withStorage()) */
538
+ storage?: ResolvedStorageConfig;
535
539
  }
536
540
  /** Options for run() */
537
541
  interface RunOptions {
@@ -541,6 +545,10 @@ interface RunOptions {
541
545
  timeoutMs?: number;
542
546
  /** Run in background (returns immediately, process continues) */
543
547
  background?: boolean;
548
+ /** Restore from checkpoint ID or "latest" before running (requires .withStorage()) */
549
+ from?: string;
550
+ /** Optional comment for the auto-checkpoint created after this run */
551
+ checkpointComment?: string;
544
552
  }
545
553
  /** Options for executeCommand() */
546
554
  interface ExecuteCommandOptions {
@@ -582,6 +590,8 @@ interface AgentResponse {
582
590
  stdout: string;
583
591
  /** Standard error */
584
592
  stderr: string;
593
+ /** Checkpoint info if storage configured and run succeeded (undefined otherwise) */
594
+ checkpoint?: CheckpointInfo;
585
595
  }
586
596
  /** Result from getOutputFiles() with optional schema validation */
587
597
  interface OutputResult<T = unknown> {
@@ -666,6 +676,80 @@ interface ComposioSetup {
666
676
  /** Optional Composio configuration */
667
677
  config?: ComposioConfig;
668
678
  }
679
+ /**
680
+ * Storage configuration for .withStorage()
681
+ *
682
+ * BYOK mode: provide url (e.g., "s3://my-bucket/prefix/")
683
+ * Gateway mode: omit url (uses Evolve-managed storage)
684
+ *
685
+ * @example
686
+ * // BYOK — user's own S3 bucket
687
+ * .withStorage({ url: "s3://my-bucket/agent-snapshots/" })
688
+ *
689
+ * // BYOK — Cloudflare R2
690
+ * .withStorage({ url: "s3://my-bucket/prefix/", endpoint: "https://acct.r2.cloudflarestorage.com" })
691
+ *
692
+ * // Gateway — Evolve-managed storage
693
+ * .withStorage()
694
+ */
695
+ interface StorageConfig {
696
+ /** S3 URL: "s3://bucket/prefix" or "https://endpoint/bucket/prefix" */
697
+ url?: string;
698
+ /** Explicit bucket name (overrides URL parsing) */
699
+ bucket?: string;
700
+ /** Key prefix (overrides URL parsing) */
701
+ prefix?: string;
702
+ /** AWS region (default from env or us-east-1) */
703
+ region?: string;
704
+ /** Custom S3 endpoint (R2, MinIO, GCS) */
705
+ endpoint?: string;
706
+ /** Explicit credentials (default: AWS SDK credential chain) */
707
+ credentials?: {
708
+ accessKeyId: string;
709
+ secretAccessKey: string;
710
+ };
711
+ }
712
+ /** Resolved storage configuration (internal) */
713
+ interface ResolvedStorageConfig {
714
+ bucket: string;
715
+ prefix: string;
716
+ region: string;
717
+ endpoint?: string;
718
+ credentials?: {
719
+ accessKeyId: string;
720
+ secretAccessKey: string;
721
+ };
722
+ mode: "byok" | "gateway";
723
+ gatewayUrl?: string;
724
+ gatewayApiKey?: string;
725
+ }
726
+ /**
727
+ * Checkpoint info returned after a successful run
728
+ *
729
+ * Pass `checkpoint.id` as `from` to restore into a fresh sandbox.
730
+ */
731
+ interface CheckpointInfo {
732
+ /** Checkpoint ID — pass as `from` to restore */
733
+ id: string;
734
+ /** SHA-256 of tar.gz — integrity verification */
735
+ hash: string;
736
+ /** Session tag at checkpoint time — lineage tracking */
737
+ tag: string;
738
+ /** ISO 8601 timestamp */
739
+ timestamp: string;
740
+ /** Archive size in bytes */
741
+ sizeBytes?: number;
742
+ /** Agent type that produced this checkpoint */
743
+ agentType?: string;
744
+ /** Model that produced this checkpoint */
745
+ model?: string;
746
+ /** Workspace mode used when checkpoint was created */
747
+ workspaceMode?: string;
748
+ /** Parent checkpoint ID — the checkpoint this was restored from (lineage tracking) */
749
+ parentId?: string;
750
+ /** User-provided label for this checkpoint */
751
+ comment?: string;
752
+ }
669
753
 
670
754
  /**
671
755
  * Composio Auth Helpers
@@ -774,6 +858,8 @@ declare class Agent {
774
858
  private sandboxState;
775
859
  private agentState;
776
860
  private readonly skills?;
861
+ private readonly storage?;
862
+ private lastCheckpointId?;
777
863
  private readonly zodSchema?;
778
864
  private readonly jsonSchema?;
779
865
  private readonly schemaOptions?;
@@ -802,6 +888,9 @@ declare class Agent {
802
888
  private setupAgentAuth;
803
889
  /**
804
890
  * Setup workspace structure and files
891
+ *
892
+ * @param opts.skipSystemPrompt - When true, skip writing the system prompt file.
893
+ * Used on restore from checkpoint: the tar already contains the correct file.
805
894
  */
806
895
  private setupWorkspace;
807
896
  /**
@@ -850,6 +939,16 @@ declare class Agent {
850
939
  * @param recursive - Include files in subdirectories (default: false)
851
940
  */
852
941
  getOutputFiles<T = unknown>(recursive?: boolean): Promise<OutputResult<T>>;
942
+ /**
943
+ * Create an explicit checkpoint of the current sandbox state.
944
+ *
945
+ * Requires an active sandbox (call run() first).
946
+ *
947
+ * @param options.comment - Optional label for this checkpoint
948
+ */
949
+ checkpoint(options?: {
950
+ comment?: string;
951
+ }): Promise<CheckpointInfo>;
853
952
  /**
854
953
  * Get current session (sandbox ID)
855
954
  */
@@ -1075,6 +1174,8 @@ interface EvolveConfig {
1075
1174
  observability?: Record<string, unknown>;
1076
1175
  /** Composio user ID and config */
1077
1176
  composio?: ComposioSetup;
1177
+ /** Storage configuration for checkpointing */
1178
+ storage?: StorageConfig;
1078
1179
  }
1079
1180
  /**
1080
1181
  * Evolve orchestrator with builder pattern
@@ -1218,6 +1319,23 @@ declare class Evolve extends EventEmitter {
1218
1319
  * })
1219
1320
  */
1220
1321
  withComposio(userId: string, config?: ComposioConfig): this;
1322
+ /**
1323
+ * Configure storage for checkpoint persistence
1324
+ *
1325
+ * BYOK mode: provide URL to your S3-compatible bucket.
1326
+ * Gateway mode: omit config (uses Evolve-managed storage, requires EVOLVE_API_KEY).
1327
+ *
1328
+ * @example
1329
+ * // BYOK — user's own S3 bucket
1330
+ * kit.withStorage({ url: "s3://my-bucket/agent-snapshots/" })
1331
+ *
1332
+ * // BYOK — Cloudflare R2
1333
+ * kit.withStorage({ url: "s3://my-bucket/prefix/", endpoint: "https://acct.r2.cloudflarestorage.com" })
1334
+ *
1335
+ * // Gateway — Evolve-managed storage
1336
+ * kit.withStorage()
1337
+ */
1338
+ withStorage(config?: StorageConfig): this;
1221
1339
  /**
1222
1340
  * Static helpers for Composio auth management
1223
1341
  *
@@ -1255,11 +1373,15 @@ declare class Evolve extends EventEmitter {
1255
1373
  private emitLifecycleFromStatus;
1256
1374
  /**
1257
1375
  * Run agent with prompt
1376
+ *
1377
+ * @param from - Restore from checkpoint ID before running (requires .withStorage())
1258
1378
  */
1259
- run({ prompt, timeoutMs, background, }: {
1379
+ run({ prompt, timeoutMs, background, from, checkpointComment, }: {
1260
1380
  prompt: string;
1261
1381
  timeoutMs?: number;
1262
1382
  background?: boolean;
1383
+ from?: string;
1384
+ checkpointComment?: string;
1263
1385
  }): Promise<AgentResponse>;
1264
1386
  /**
1265
1387
  * Execute arbitrary command in sandbox
@@ -1286,6 +1408,28 @@ declare class Evolve extends EventEmitter {
1286
1408
  * @param recursive - Include files in subdirectories (default: false)
1287
1409
  */
1288
1410
  getOutputFiles<T = unknown>(recursive?: boolean): Promise<OutputResult<T>>;
1411
+ /**
1412
+ * Create an explicit checkpoint of the current sandbox state.
1413
+ *
1414
+ * Requires a prior run() call (needs an active sandbox to snapshot).
1415
+ *
1416
+ * @param options.comment - Optional label for this checkpoint
1417
+ */
1418
+ checkpoint(options?: {
1419
+ comment?: string;
1420
+ }): Promise<CheckpointInfo>;
1421
+ /**
1422
+ * List checkpoints (requires .withStorage()).
1423
+ *
1424
+ * Does not require an agent or sandbox — only storage configuration.
1425
+ *
1426
+ * @param options.limit - Maximum number of checkpoints to return
1427
+ * @param options.tag - Filter by session tag (gateway mode: server-side, BYOK: post-filter)
1428
+ */
1429
+ listCheckpoints(options?: {
1430
+ limit?: number;
1431
+ tag?: string;
1432
+ }): Promise<CheckpointInfo[]>;
1289
1433
  /**
1290
1434
  * Get current session (sandbox ID)
1291
1435
  */
@@ -2239,6 +2383,15 @@ interface AgentRegistryEntry {
2239
2383
  availableBetas?: Record<string, string>;
2240
2384
  /** Skills configuration for this agent */
2241
2385
  skillsConfig: SkillsConfig;
2386
+ /** Multi-provider env mapping: model prefix → keyEnv (for CLIs like OpenCode that resolve provider from model string) */
2387
+ providerEnvMap?: Record<string, {
2388
+ keyEnv: string;
2389
+ }>;
2390
+ /** Env var for inline config (e.g., OPENCODE_CONFIG_CONTENT) — used in gateway mode to set provider base URLs */
2391
+ gatewayConfigEnv?: string;
2392
+ /** Additional directories to include in checkpoint tar (beyond mcpConfig.settingsDir).
2393
+ * Used for agents like OpenCode that spread state across XDG directories. */
2394
+ checkpointDirs?: string[];
2242
2395
  }
2243
2396
  /**
2244
2397
  * Registry of all supported agents.
@@ -2323,6 +2476,7 @@ declare function writeCodexMcpConfig(sandbox: SandboxInstance, servers: Record<s
2323
2476
  * - Codex: TOML to ~/.codex/config.toml
2324
2477
  * - Gemini: JSON to ~/.gemini/settings.json
2325
2478
  * - Qwen: JSON to ~/.qwen/settings.json
2479
+ * - OpenCode: JSON to ${workingDir}/opencode.json (mcp key)
2326
2480
  */
2327
2481
  declare function writeMcpConfig(agentType: AgentType, sandbox: SandboxInstance, workingDir: string, servers: Record<string, McpServerConfig>): Promise<void>;
2328
2482
 
@@ -2462,4 +2616,38 @@ declare function readLocalDir(localPath: string, recursive?: boolean): FileMap;
2462
2616
  */
2463
2617
  declare function saveLocalDir(localPath: string, files: FileMap): void;
2464
2618
 
2465
- export { AGENT_REGISTRY, AGENT_TYPES, Agent, type AgentConfig, type AgentOptions, type AgentOverride, type AgentParser, type AgentRegistryEntry, type AgentResponse, type AgentRuntimeState, type AgentType, type BaseMeta, type BestOfConfig, type BestOfParams, type BestOfResult, type CandidateCompleteEvent, type ComposioAuthResult, type ComposioConfig, type ComposioConnectionStatus, type ComposioSetup, type EmitOption, type EventHandler, type EventName, Evolve, type EvolveConfig, type EvolveEvents, type ExecuteCommandOptions, type FileMap, type FilterConfig, type FilterParams, type IndexedMeta, type ItemInput, type ItemRetryEvent, JUDGE_PROMPT, type JsonSchema, type JudgeCompleteEvent, type JudgeDecision, type JudgeMeta, type LifecycleEvent, type LifecycleReason, type MapConfig, type MapParams, type McpConfigInfo, type McpServerConfig, type ModelInfo, type OnCandidateCompleteCallback, type OnItemRetryCallback, type OnJudgeCompleteCallback, type OnVerifierCompleteCallback, type OnWorkerCompleteCallback, type OperationType, type OutputEvent, type OutputResult, Pipeline, type PipelineContext, type PipelineEventMap, type PipelineEvents, type PipelineResult, type ProcessInfo, type Prompt, type PromptFn, RETRY_FEEDBACK_PROMPT, type ReasoningEffort, type ReduceConfig, type ReduceMeta, type ReduceParams, type ReduceResult, type RetryConfig, type RunOptions, SCHEMA_PROMPT, SWARM_RESULT_BRAND, SYSTEM_PROMPT, type SandboxCommandHandle, type SandboxCommandResult, type SandboxCommands, type SandboxCreateOptions, type SandboxFiles, type SandboxInstance, type SandboxLifecycleState, type SandboxProvider, type SandboxRunOptions, type SandboxSpawnOptions, type SchemaValidationOptions, Semaphore, type SessionStatus, type SkillName, type SkillsConfig, type StepCompleteEvent, type StepErrorEvent, type StepEvent, type StepResult, type StepStartEvent, type StreamCallbacks, Swarm, type SwarmConfig, type SwarmResult, SwarmResultList, TerminalPipeline, type ToolsFilter, VALIDATION_PRESETS, VERIFY_PROMPT, type ValidationMode, type VerifierCompleteEvent, type VerifyConfig, type VerifyDecision, type VerifyInfo, type VerifyMeta, WORKSPACE_PROMPT, WORKSPACE_SWE_PROMPT, type WorkerCompleteEvent, type WorkspaceMode, applyTemplate, buildWorkerSystemPrompt, createAgentParser, createClaudeParser, createCodexParser, createGeminiParser, executeWithRetry, expandPath, getAgentConfig, getMcpSettingsDir, getMcpSettingsPath, isValidAgentType, isZodSchema, jsonSchemaToString, parseNdjsonLine, parseNdjsonOutput, parseQwenOutput, readLocalDir, saveLocalDir, writeClaudeMcpConfig, writeCodexMcpConfig, writeGeminiMcpConfig, writeMcpConfig, writeQwenMcpConfig, zodSchemaToJson };
2619
+ /**
2620
+ * Storage & Checkpointing Module
2621
+ *
2622
+ * Provides durable persistence for agent workspaces beyond sandbox lifetime.
2623
+ * Supports BYOK (user's S3 bucket) and Gateway (Evolve-managed) modes.
2624
+ *
2625
+ * Evidence: storage-checkpointing plan v2.2
2626
+ */
2627
+
2628
+ /**
2629
+ * Resolve storage configuration from user input.
2630
+ *
2631
+ * BYOK mode: URL provided → parse into bucket/prefix, use S3 client directly
2632
+ * Gateway mode: no URL → use dashboard API endpoints
2633
+ */
2634
+ declare function resolveStorageConfig(config: StorageConfig | undefined, isGateway: boolean, gatewayUrl?: string, gatewayApiKey?: string): ResolvedStorageConfig;
2635
+ /**
2636
+ * List checkpoints (standalone — no Evolve instance needed).
2637
+ *
2638
+ * BYOK mode: reads directly from S3.
2639
+ * Gateway mode: reads EVOLVE_API_KEY from env, calls dashboard API.
2640
+ *
2641
+ * @example
2642
+ * // BYOK
2643
+ * const all = await listCheckpoints({ url: "s3://my-bucket/project/" });
2644
+ *
2645
+ * // Gateway
2646
+ * const all = await listCheckpoints({});
2647
+ */
2648
+ declare function listCheckpoints(config: StorageConfig, options?: {
2649
+ limit?: number;
2650
+ tag?: string;
2651
+ }): Promise<CheckpointInfo[]>;
2652
+
2653
+ export { AGENT_REGISTRY, AGENT_TYPES, Agent, type AgentConfig, type AgentOptions, type AgentOverride, type AgentParser, type AgentRegistryEntry, type AgentResponse, type AgentRuntimeState, type AgentType, type BaseMeta, type BestOfConfig, type BestOfParams, type BestOfResult, type CandidateCompleteEvent, type CheckpointInfo, type ComposioAuthResult, type ComposioConfig, type ComposioConnectionStatus, type ComposioSetup, type EmitOption, type EventHandler, type EventName, Evolve, type EvolveConfig, type EvolveEvents, type ExecuteCommandOptions, type FileMap, type FilterConfig, type FilterParams, type IndexedMeta, type ItemInput, type ItemRetryEvent, JUDGE_PROMPT, type JsonSchema, type JudgeCompleteEvent, type JudgeDecision, type JudgeMeta, type LifecycleEvent, type LifecycleReason, type MapConfig, type MapParams, type McpConfigInfo, type McpServerConfig, type ModelInfo, type OnCandidateCompleteCallback, type OnItemRetryCallback, type OnJudgeCompleteCallback, type OnVerifierCompleteCallback, type OnWorkerCompleteCallback, type OperationType, type OutputEvent, type OutputResult, Pipeline, type PipelineContext, type PipelineEventMap, type PipelineEvents, type PipelineResult, type ProcessInfo, type Prompt, type PromptFn, RETRY_FEEDBACK_PROMPT, type ReasoningEffort, type ReduceConfig, type ReduceMeta, type ReduceParams, type ReduceResult, type ResolvedStorageConfig, type RetryConfig, type RunOptions, SCHEMA_PROMPT, SWARM_RESULT_BRAND, SYSTEM_PROMPT, type SandboxCommandHandle, type SandboxCommandResult, type SandboxCommands, type SandboxCreateOptions, type SandboxFiles, type SandboxInstance, type SandboxLifecycleState, type SandboxProvider, type SandboxRunOptions, type SandboxSpawnOptions, type SchemaValidationOptions, Semaphore, type SessionStatus, type SkillName, type SkillsConfig, type StepCompleteEvent, type StepErrorEvent, type StepEvent, type StepResult, type StepStartEvent, type StorageConfig, type StreamCallbacks, Swarm, type SwarmConfig, type SwarmResult, SwarmResultList, TerminalPipeline, type ToolsFilter, VALIDATION_PRESETS, VERIFY_PROMPT, type ValidationMode, type VerifierCompleteEvent, type VerifyConfig, type VerifyDecision, type VerifyInfo, type VerifyMeta, WORKSPACE_PROMPT, WORKSPACE_SWE_PROMPT, type WorkerCompleteEvent, type WorkspaceMode, applyTemplate, buildWorkerSystemPrompt, createAgentParser, createClaudeParser, createCodexParser, createGeminiParser, executeWithRetry, expandPath, getAgentConfig, getMcpSettingsDir, getMcpSettingsPath, isValidAgentType, isZodSchema, jsonSchemaToString, listCheckpoints, parseNdjsonLine, parseNdjsonOutput, parseQwenOutput, readLocalDir, resolveStorageConfig, saveLocalDir, writeClaudeMcpConfig, writeCodexMcpConfig, writeGeminiMcpConfig, writeMcpConfig, writeQwenMcpConfig, zodSchemaToJson };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as zod from 'zod';
2
2
  import { z } from 'zod';
3
3
  import { EventEmitter } from 'events';
4
- export { E2BProvider } from '@evolvingmachines/e2b';
5
- export { DaytonaProvider } from '@evolvingmachines/daytona';
6
- export { ModalProvider } from '@evolvingmachines/modal';
4
+ export { E2BProvider, createE2BProvider } from '@evolvingmachines/e2b';
5
+ export { DaytonaProvider, createDaytonaProvider } from '@evolvingmachines/daytona';
6
+ export { ModalProvider, createModalProvider } from '@evolvingmachines/modal';
7
7
 
8
8
  /**
9
9
  * ACP-inspired output types for unified agent event streaming.
@@ -364,13 +364,15 @@ interface SandboxProvider {
364
364
  connect(sandboxId: string, timeoutMs?: number): Promise<SandboxInstance>;
365
365
  }
366
366
  /** Supported agent types (headless CLI agents only, no ACP) */
367
- type AgentType = "claude" | "codex" | "gemini" | "qwen";
367
+ type AgentType = "claude" | "codex" | "gemini" | "qwen" | "kimi" | "opencode";
368
368
  /** Agent type constants for use in code */
369
369
  declare const AGENT_TYPES: {
370
370
  readonly CLAUDE: "claude";
371
371
  readonly CODEX: "codex";
372
372
  readonly GEMINI: "gemini";
373
373
  readonly QWEN: "qwen";
374
+ readonly KIMI: "kimi";
375
+ readonly OPENCODE: "opencode";
374
376
  };
375
377
  /** Workspace mode determines folder structure and system prompt */
376
378
  type WorkspaceMode = "knowledge" | "swe";
@@ -532,6 +534,8 @@ interface AgentOptions {
532
534
  * Set via withComposio() - provides access to 1000+ tools
533
535
  */
534
536
  composio?: ComposioSetup;
537
+ /** Resolved storage configuration (set via Evolve.withStorage()) */
538
+ storage?: ResolvedStorageConfig;
535
539
  }
536
540
  /** Options for run() */
537
541
  interface RunOptions {
@@ -541,6 +545,10 @@ interface RunOptions {
541
545
  timeoutMs?: number;
542
546
  /** Run in background (returns immediately, process continues) */
543
547
  background?: boolean;
548
+ /** Restore from checkpoint ID or "latest" before running (requires .withStorage()) */
549
+ from?: string;
550
+ /** Optional comment for the auto-checkpoint created after this run */
551
+ checkpointComment?: string;
544
552
  }
545
553
  /** Options for executeCommand() */
546
554
  interface ExecuteCommandOptions {
@@ -582,6 +590,8 @@ interface AgentResponse {
582
590
  stdout: string;
583
591
  /** Standard error */
584
592
  stderr: string;
593
+ /** Checkpoint info if storage configured and run succeeded (undefined otherwise) */
594
+ checkpoint?: CheckpointInfo;
585
595
  }
586
596
  /** Result from getOutputFiles() with optional schema validation */
587
597
  interface OutputResult<T = unknown> {
@@ -666,6 +676,80 @@ interface ComposioSetup {
666
676
  /** Optional Composio configuration */
667
677
  config?: ComposioConfig;
668
678
  }
679
+ /**
680
+ * Storage configuration for .withStorage()
681
+ *
682
+ * BYOK mode: provide url (e.g., "s3://my-bucket/prefix/")
683
+ * Gateway mode: omit url (uses Evolve-managed storage)
684
+ *
685
+ * @example
686
+ * // BYOK — user's own S3 bucket
687
+ * .withStorage({ url: "s3://my-bucket/agent-snapshots/" })
688
+ *
689
+ * // BYOK — Cloudflare R2
690
+ * .withStorage({ url: "s3://my-bucket/prefix/", endpoint: "https://acct.r2.cloudflarestorage.com" })
691
+ *
692
+ * // Gateway — Evolve-managed storage
693
+ * .withStorage()
694
+ */
695
+ interface StorageConfig {
696
+ /** S3 URL: "s3://bucket/prefix" or "https://endpoint/bucket/prefix" */
697
+ url?: string;
698
+ /** Explicit bucket name (overrides URL parsing) */
699
+ bucket?: string;
700
+ /** Key prefix (overrides URL parsing) */
701
+ prefix?: string;
702
+ /** AWS region (default from env or us-east-1) */
703
+ region?: string;
704
+ /** Custom S3 endpoint (R2, MinIO, GCS) */
705
+ endpoint?: string;
706
+ /** Explicit credentials (default: AWS SDK credential chain) */
707
+ credentials?: {
708
+ accessKeyId: string;
709
+ secretAccessKey: string;
710
+ };
711
+ }
712
+ /** Resolved storage configuration (internal) */
713
+ interface ResolvedStorageConfig {
714
+ bucket: string;
715
+ prefix: string;
716
+ region: string;
717
+ endpoint?: string;
718
+ credentials?: {
719
+ accessKeyId: string;
720
+ secretAccessKey: string;
721
+ };
722
+ mode: "byok" | "gateway";
723
+ gatewayUrl?: string;
724
+ gatewayApiKey?: string;
725
+ }
726
+ /**
727
+ * Checkpoint info returned after a successful run
728
+ *
729
+ * Pass `checkpoint.id` as `from` to restore into a fresh sandbox.
730
+ */
731
+ interface CheckpointInfo {
732
+ /** Checkpoint ID — pass as `from` to restore */
733
+ id: string;
734
+ /** SHA-256 of tar.gz — integrity verification */
735
+ hash: string;
736
+ /** Session tag at checkpoint time — lineage tracking */
737
+ tag: string;
738
+ /** ISO 8601 timestamp */
739
+ timestamp: string;
740
+ /** Archive size in bytes */
741
+ sizeBytes?: number;
742
+ /** Agent type that produced this checkpoint */
743
+ agentType?: string;
744
+ /** Model that produced this checkpoint */
745
+ model?: string;
746
+ /** Workspace mode used when checkpoint was created */
747
+ workspaceMode?: string;
748
+ /** Parent checkpoint ID — the checkpoint this was restored from (lineage tracking) */
749
+ parentId?: string;
750
+ /** User-provided label for this checkpoint */
751
+ comment?: string;
752
+ }
669
753
 
670
754
  /**
671
755
  * Composio Auth Helpers
@@ -774,6 +858,8 @@ declare class Agent {
774
858
  private sandboxState;
775
859
  private agentState;
776
860
  private readonly skills?;
861
+ private readonly storage?;
862
+ private lastCheckpointId?;
777
863
  private readonly zodSchema?;
778
864
  private readonly jsonSchema?;
779
865
  private readonly schemaOptions?;
@@ -802,6 +888,9 @@ declare class Agent {
802
888
  private setupAgentAuth;
803
889
  /**
804
890
  * Setup workspace structure and files
891
+ *
892
+ * @param opts.skipSystemPrompt - When true, skip writing the system prompt file.
893
+ * Used on restore from checkpoint: the tar already contains the correct file.
805
894
  */
806
895
  private setupWorkspace;
807
896
  /**
@@ -850,6 +939,16 @@ declare class Agent {
850
939
  * @param recursive - Include files in subdirectories (default: false)
851
940
  */
852
941
  getOutputFiles<T = unknown>(recursive?: boolean): Promise<OutputResult<T>>;
942
+ /**
943
+ * Create an explicit checkpoint of the current sandbox state.
944
+ *
945
+ * Requires an active sandbox (call run() first).
946
+ *
947
+ * @param options.comment - Optional label for this checkpoint
948
+ */
949
+ checkpoint(options?: {
950
+ comment?: string;
951
+ }): Promise<CheckpointInfo>;
853
952
  /**
854
953
  * Get current session (sandbox ID)
855
954
  */
@@ -1075,6 +1174,8 @@ interface EvolveConfig {
1075
1174
  observability?: Record<string, unknown>;
1076
1175
  /** Composio user ID and config */
1077
1176
  composio?: ComposioSetup;
1177
+ /** Storage configuration for checkpointing */
1178
+ storage?: StorageConfig;
1078
1179
  }
1079
1180
  /**
1080
1181
  * Evolve orchestrator with builder pattern
@@ -1218,6 +1319,23 @@ declare class Evolve extends EventEmitter {
1218
1319
  * })
1219
1320
  */
1220
1321
  withComposio(userId: string, config?: ComposioConfig): this;
1322
+ /**
1323
+ * Configure storage for checkpoint persistence
1324
+ *
1325
+ * BYOK mode: provide URL to your S3-compatible bucket.
1326
+ * Gateway mode: omit config (uses Evolve-managed storage, requires EVOLVE_API_KEY).
1327
+ *
1328
+ * @example
1329
+ * // BYOK — user's own S3 bucket
1330
+ * kit.withStorage({ url: "s3://my-bucket/agent-snapshots/" })
1331
+ *
1332
+ * // BYOK — Cloudflare R2
1333
+ * kit.withStorage({ url: "s3://my-bucket/prefix/", endpoint: "https://acct.r2.cloudflarestorage.com" })
1334
+ *
1335
+ * // Gateway — Evolve-managed storage
1336
+ * kit.withStorage()
1337
+ */
1338
+ withStorage(config?: StorageConfig): this;
1221
1339
  /**
1222
1340
  * Static helpers for Composio auth management
1223
1341
  *
@@ -1255,11 +1373,15 @@ declare class Evolve extends EventEmitter {
1255
1373
  private emitLifecycleFromStatus;
1256
1374
  /**
1257
1375
  * Run agent with prompt
1376
+ *
1377
+ * @param from - Restore from checkpoint ID before running (requires .withStorage())
1258
1378
  */
1259
- run({ prompt, timeoutMs, background, }: {
1379
+ run({ prompt, timeoutMs, background, from, checkpointComment, }: {
1260
1380
  prompt: string;
1261
1381
  timeoutMs?: number;
1262
1382
  background?: boolean;
1383
+ from?: string;
1384
+ checkpointComment?: string;
1263
1385
  }): Promise<AgentResponse>;
1264
1386
  /**
1265
1387
  * Execute arbitrary command in sandbox
@@ -1286,6 +1408,28 @@ declare class Evolve extends EventEmitter {
1286
1408
  * @param recursive - Include files in subdirectories (default: false)
1287
1409
  */
1288
1410
  getOutputFiles<T = unknown>(recursive?: boolean): Promise<OutputResult<T>>;
1411
+ /**
1412
+ * Create an explicit checkpoint of the current sandbox state.
1413
+ *
1414
+ * Requires a prior run() call (needs an active sandbox to snapshot).
1415
+ *
1416
+ * @param options.comment - Optional label for this checkpoint
1417
+ */
1418
+ checkpoint(options?: {
1419
+ comment?: string;
1420
+ }): Promise<CheckpointInfo>;
1421
+ /**
1422
+ * List checkpoints (requires .withStorage()).
1423
+ *
1424
+ * Does not require an agent or sandbox — only storage configuration.
1425
+ *
1426
+ * @param options.limit - Maximum number of checkpoints to return
1427
+ * @param options.tag - Filter by session tag (gateway mode: server-side, BYOK: post-filter)
1428
+ */
1429
+ listCheckpoints(options?: {
1430
+ limit?: number;
1431
+ tag?: string;
1432
+ }): Promise<CheckpointInfo[]>;
1289
1433
  /**
1290
1434
  * Get current session (sandbox ID)
1291
1435
  */
@@ -2239,6 +2383,15 @@ interface AgentRegistryEntry {
2239
2383
  availableBetas?: Record<string, string>;
2240
2384
  /** Skills configuration for this agent */
2241
2385
  skillsConfig: SkillsConfig;
2386
+ /** Multi-provider env mapping: model prefix → keyEnv (for CLIs like OpenCode that resolve provider from model string) */
2387
+ providerEnvMap?: Record<string, {
2388
+ keyEnv: string;
2389
+ }>;
2390
+ /** Env var for inline config (e.g., OPENCODE_CONFIG_CONTENT) — used in gateway mode to set provider base URLs */
2391
+ gatewayConfigEnv?: string;
2392
+ /** Additional directories to include in checkpoint tar (beyond mcpConfig.settingsDir).
2393
+ * Used for agents like OpenCode that spread state across XDG directories. */
2394
+ checkpointDirs?: string[];
2242
2395
  }
2243
2396
  /**
2244
2397
  * Registry of all supported agents.
@@ -2323,6 +2476,7 @@ declare function writeCodexMcpConfig(sandbox: SandboxInstance, servers: Record<s
2323
2476
  * - Codex: TOML to ~/.codex/config.toml
2324
2477
  * - Gemini: JSON to ~/.gemini/settings.json
2325
2478
  * - Qwen: JSON to ~/.qwen/settings.json
2479
+ * - OpenCode: JSON to ${workingDir}/opencode.json (mcp key)
2326
2480
  */
2327
2481
  declare function writeMcpConfig(agentType: AgentType, sandbox: SandboxInstance, workingDir: string, servers: Record<string, McpServerConfig>): Promise<void>;
2328
2482
 
@@ -2462,4 +2616,38 @@ declare function readLocalDir(localPath: string, recursive?: boolean): FileMap;
2462
2616
  */
2463
2617
  declare function saveLocalDir(localPath: string, files: FileMap): void;
2464
2618
 
2465
- export { AGENT_REGISTRY, AGENT_TYPES, Agent, type AgentConfig, type AgentOptions, type AgentOverride, type AgentParser, type AgentRegistryEntry, type AgentResponse, type AgentRuntimeState, type AgentType, type BaseMeta, type BestOfConfig, type BestOfParams, type BestOfResult, type CandidateCompleteEvent, type ComposioAuthResult, type ComposioConfig, type ComposioConnectionStatus, type ComposioSetup, type EmitOption, type EventHandler, type EventName, Evolve, type EvolveConfig, type EvolveEvents, type ExecuteCommandOptions, type FileMap, type FilterConfig, type FilterParams, type IndexedMeta, type ItemInput, type ItemRetryEvent, JUDGE_PROMPT, type JsonSchema, type JudgeCompleteEvent, type JudgeDecision, type JudgeMeta, type LifecycleEvent, type LifecycleReason, type MapConfig, type MapParams, type McpConfigInfo, type McpServerConfig, type ModelInfo, type OnCandidateCompleteCallback, type OnItemRetryCallback, type OnJudgeCompleteCallback, type OnVerifierCompleteCallback, type OnWorkerCompleteCallback, type OperationType, type OutputEvent, type OutputResult, Pipeline, type PipelineContext, type PipelineEventMap, type PipelineEvents, type PipelineResult, type ProcessInfo, type Prompt, type PromptFn, RETRY_FEEDBACK_PROMPT, type ReasoningEffort, type ReduceConfig, type ReduceMeta, type ReduceParams, type ReduceResult, type RetryConfig, type RunOptions, SCHEMA_PROMPT, SWARM_RESULT_BRAND, SYSTEM_PROMPT, type SandboxCommandHandle, type SandboxCommandResult, type SandboxCommands, type SandboxCreateOptions, type SandboxFiles, type SandboxInstance, type SandboxLifecycleState, type SandboxProvider, type SandboxRunOptions, type SandboxSpawnOptions, type SchemaValidationOptions, Semaphore, type SessionStatus, type SkillName, type SkillsConfig, type StepCompleteEvent, type StepErrorEvent, type StepEvent, type StepResult, type StepStartEvent, type StreamCallbacks, Swarm, type SwarmConfig, type SwarmResult, SwarmResultList, TerminalPipeline, type ToolsFilter, VALIDATION_PRESETS, VERIFY_PROMPT, type ValidationMode, type VerifierCompleteEvent, type VerifyConfig, type VerifyDecision, type VerifyInfo, type VerifyMeta, WORKSPACE_PROMPT, WORKSPACE_SWE_PROMPT, type WorkerCompleteEvent, type WorkspaceMode, applyTemplate, buildWorkerSystemPrompt, createAgentParser, createClaudeParser, createCodexParser, createGeminiParser, executeWithRetry, expandPath, getAgentConfig, getMcpSettingsDir, getMcpSettingsPath, isValidAgentType, isZodSchema, jsonSchemaToString, parseNdjsonLine, parseNdjsonOutput, parseQwenOutput, readLocalDir, saveLocalDir, writeClaudeMcpConfig, writeCodexMcpConfig, writeGeminiMcpConfig, writeMcpConfig, writeQwenMcpConfig, zodSchemaToJson };
2619
+ /**
2620
+ * Storage & Checkpointing Module
2621
+ *
2622
+ * Provides durable persistence for agent workspaces beyond sandbox lifetime.
2623
+ * Supports BYOK (user's S3 bucket) and Gateway (Evolve-managed) modes.
2624
+ *
2625
+ * Evidence: storage-checkpointing plan v2.2
2626
+ */
2627
+
2628
+ /**
2629
+ * Resolve storage configuration from user input.
2630
+ *
2631
+ * BYOK mode: URL provided → parse into bucket/prefix, use S3 client directly
2632
+ * Gateway mode: no URL → use dashboard API endpoints
2633
+ */
2634
+ declare function resolveStorageConfig(config: StorageConfig | undefined, isGateway: boolean, gatewayUrl?: string, gatewayApiKey?: string): ResolvedStorageConfig;
2635
+ /**
2636
+ * List checkpoints (standalone — no Evolve instance needed).
2637
+ *
2638
+ * BYOK mode: reads directly from S3.
2639
+ * Gateway mode: reads EVOLVE_API_KEY from env, calls dashboard API.
2640
+ *
2641
+ * @example
2642
+ * // BYOK
2643
+ * const all = await listCheckpoints({ url: "s3://my-bucket/project/" });
2644
+ *
2645
+ * // Gateway
2646
+ * const all = await listCheckpoints({});
2647
+ */
2648
+ declare function listCheckpoints(config: StorageConfig, options?: {
2649
+ limit?: number;
2650
+ tag?: string;
2651
+ }): Promise<CheckpointInfo[]>;
2652
+
2653
+ export { AGENT_REGISTRY, AGENT_TYPES, Agent, type AgentConfig, type AgentOptions, type AgentOverride, type AgentParser, type AgentRegistryEntry, type AgentResponse, type AgentRuntimeState, type AgentType, type BaseMeta, type BestOfConfig, type BestOfParams, type BestOfResult, type CandidateCompleteEvent, type CheckpointInfo, type ComposioAuthResult, type ComposioConfig, type ComposioConnectionStatus, type ComposioSetup, type EmitOption, type EventHandler, type EventName, Evolve, type EvolveConfig, type EvolveEvents, type ExecuteCommandOptions, type FileMap, type FilterConfig, type FilterParams, type IndexedMeta, type ItemInput, type ItemRetryEvent, JUDGE_PROMPT, type JsonSchema, type JudgeCompleteEvent, type JudgeDecision, type JudgeMeta, type LifecycleEvent, type LifecycleReason, type MapConfig, type MapParams, type McpConfigInfo, type McpServerConfig, type ModelInfo, type OnCandidateCompleteCallback, type OnItemRetryCallback, type OnJudgeCompleteCallback, type OnVerifierCompleteCallback, type OnWorkerCompleteCallback, type OperationType, type OutputEvent, type OutputResult, Pipeline, type PipelineContext, type PipelineEventMap, type PipelineEvents, type PipelineResult, type ProcessInfo, type Prompt, type PromptFn, RETRY_FEEDBACK_PROMPT, type ReasoningEffort, type ReduceConfig, type ReduceMeta, type ReduceParams, type ReduceResult, type ResolvedStorageConfig, type RetryConfig, type RunOptions, SCHEMA_PROMPT, SWARM_RESULT_BRAND, SYSTEM_PROMPT, type SandboxCommandHandle, type SandboxCommandResult, type SandboxCommands, type SandboxCreateOptions, type SandboxFiles, type SandboxInstance, type SandboxLifecycleState, type SandboxProvider, type SandboxRunOptions, type SandboxSpawnOptions, type SchemaValidationOptions, Semaphore, type SessionStatus, type SkillName, type SkillsConfig, type StepCompleteEvent, type StepErrorEvent, type StepEvent, type StepResult, type StepStartEvent, type StorageConfig, type StreamCallbacks, Swarm, type SwarmConfig, type SwarmResult, SwarmResultList, TerminalPipeline, type ToolsFilter, VALIDATION_PRESETS, VERIFY_PROMPT, type ValidationMode, type VerifierCompleteEvent, type VerifyConfig, type VerifyDecision, type VerifyInfo, type VerifyMeta, WORKSPACE_PROMPT, WORKSPACE_SWE_PROMPT, type WorkerCompleteEvent, type WorkspaceMode, applyTemplate, buildWorkerSystemPrompt, createAgentParser, createClaudeParser, createCodexParser, createGeminiParser, executeWithRetry, expandPath, getAgentConfig, getMcpSettingsDir, getMcpSettingsPath, isValidAgentType, isZodSchema, jsonSchemaToString, listCheckpoints, parseNdjsonLine, parseNdjsonOutput, parseQwenOutput, readLocalDir, resolveStorageConfig, saveLocalDir, writeClaudeMcpConfig, writeCodexMcpConfig, writeGeminiMcpConfig, writeMcpConfig, writeQwenMcpConfig, zodSchemaToJson };