@evolvingmachines/sdk 0.0.51 → 0.0.52-project-sable.20260726.6e95f36

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,11 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import * as zod from 'zod';
3
- import { z } from 'zod';
3
+ import { ZodType, z } from 'zod';
4
4
  export { E2BConfig, E2BProvider, createE2BProvider } from '@evolvingmachines/e2b';
5
5
  export { DaytonaConfig, DaytonaProvider, createDaytonaProvider } from '@evolvingmachines/daytona';
6
6
  export { ModalConfig, ModalProvider, createModalProvider } from '@evolvingmachines/modal';
7
+ import { H as HostedClientConfig, B as BenchmarksClient, C as CustomHarnessesClient, J as JobsClient, a as CapabilityDocument, b as HostedErrorCode } from './types-BeJrn1lR.cjs';
8
+ export { k as ActiveBenchmark, A as Awaitable, j as Benchmark, Y as BenchmarkImport, a0 as BenchmarkImportFailure, Z as BenchmarkImportInput, f as BenchmarkImportList, g as BenchmarkImportPage, _ as BenchmarkImportSource, $ as BenchmarkImportStatus, l as BenchmarkVersion, m as BenchmarkVersionState, D as ComparisonAggregate, F as ComparisonCell, G as ComparisonCoverage, I as ComparisonTaskRow, a1 as CustomHarness, a2 as CustomHarnessInput, a3 as CustomHarnessSource, h as CustomHarnessUpsertInput, E as EvalSandboxProvider, af as ExportJobOptions, c as HOSTED_ERROR_CODES, d as HarnessCapability, e as HarnessModel, q as Job, o as JobAgent, K as JobComparison, y as JobEvent, p as JobInput, a6 as JobList, a5 as JobPage, r as JobStatus, z as JobWatch, L as ListImportsOptions, aa as ListJobsOptions, ab as ListTrialsOptions, M as ModelUsage, P as ProviderCapability, W as RegradeFilter, R as RegradeJob, Q as RegradeJobStatus, X as RegradeOptions, N as RegradeResult, O as RegradeStatus, a9 as RunJobOptions, a4 as SpendSource, S as StatusVocabulary, T as Task, n as TaskProviderVerdict, s as Trial, v as TrialCounts, t as TrialDetail, a8 as TrialList, a7 as TrialPage, u as TrialStatus, w as TrialTraceEvent, ac as TrialTraceOptions, x as TrialTracePage, U as UpstreamStatus, V as VerifierMode, ae as WatchImportOptions, ad as WatchJobOptions, i as isHostedErrorCode } from './types-BeJrn1lR.cjs';
7
9
 
8
10
  /**
9
11
  * ACP-inspired output types for unified agent event streaming.
@@ -141,7 +143,40 @@ interface PlanEntry {
141
143
  * All possible session update types.
142
144
  * Discriminated union on `sessionUpdate` field.
143
145
  */
144
- type SessionUpdate = AgentMessageChunk | AgentThoughtChunk | UserMessageChunk | ToolCall | ToolCallUpdate | Plan;
146
+ type SessionUpdate = AgentMessageChunk | AgentThoughtChunk | UserMessageChunk | ToolCall | ToolCallUpdate | Plan | AgentError;
147
+ /**
148
+ * A failure the HARNESS itself reported — not model output, not work.
149
+ *
150
+ * WHY THIS IS ITS OWN VARIANT AND NOT AN agent_message_chunk. Harnesses stream
151
+ * their failures on the same channel as their output: codex writes
152
+ * {"type":"error"} and {"type":"turn.failed"} to stdout as JSONL while its
153
+ * stderr says only "Reading prompt from stdin...". Dropping those left a run
154
+ * that could not reach the model looking identical to a run that produced
155
+ * nothing at all, which cost a full night of blind diagnosis. Folding them into
156
+ * agent_message_chunk would be worse than dropping them: a consumer counting
157
+ * "did the agent do any work" would count the error as work.
158
+ *
159
+ * So the transcript records the failure, and the discriminant says plainly that
160
+ * it is a failure. Anything deciding whether a harness RAN must exclude this
161
+ * variant — see isAgentWorkUpdate() below, and the eval runner's
162
+ * harnessNeverRan law, which must keep firing for an error-only run so an
163
+ * infrastructure failure is never scored as a zero.
164
+ */
165
+ interface AgentError {
166
+ sessionUpdate: "error";
167
+ /** The harness's own message, verbatim. */
168
+ message: string;
169
+ /** True when the harness treated it as terminal for the turn. */
170
+ fatal: boolean;
171
+ }
172
+ /**
173
+ * Is this update evidence the harness did WORK, as opposed to reporting a
174
+ * failure? The one predicate every "did it run" check should use, so the answer
175
+ * cannot drift between callers.
176
+ */
177
+ declare function isAgentWorkUpdate(update: {
178
+ sessionUpdate?: unknown;
179
+ } | null | undefined): boolean;
145
180
  /**
146
181
  * Streaming text/image from agent.
147
182
  * May arrive in multiple chunks - concatenate text.
@@ -285,6 +320,239 @@ interface OutputEvent {
285
320
  update: SessionUpdate;
286
321
  }
287
322
 
323
+ /**
324
+ * Agent Registry
325
+ *
326
+ * Single source of truth for agent-specific behavior.
327
+ * All differences between agents are data, not code.
328
+ */
329
+
330
+ /** Model configuration */
331
+ interface ModelInfo {
332
+ /** Model alias (short name used with --model) */
333
+ alias: string;
334
+ /** Full model ID */
335
+ modelId: string;
336
+ /** What this model is best for */
337
+ description: string;
338
+ }
339
+ /** MCP configuration for an agent */
340
+ interface McpConfigInfo {
341
+ /** Settings directory (e.g., "~/.claude") */
342
+ settingsDir: string;
343
+ /** Config filename (e.g., "settings.json" or "config.toml") */
344
+ filename: string;
345
+ /** Config format */
346
+ format: "json" | "toml";
347
+ /** Whether to use workingDir for project-level config (Claude only) */
348
+ projectConfig?: boolean;
349
+ }
350
+ /** Options for building agent commands */
351
+ interface BuildCommandOptions {
352
+ prompt: string;
353
+ model: string;
354
+ isResume: boolean;
355
+ sessionId?: string;
356
+ reasoningEffort?: string;
357
+ isDirectMode?: boolean;
358
+ /**
359
+ * External gateway mode (caller-minted credential + base URL). Direct-mode
360
+ * env injection applies, but CLIs that route via generated config (OpenCode
361
+ * inline config, Droid settings file) must use their GATEWAY command shape
362
+ * pointed at the caller's gateway — with the model passed VERBATIM (route
363
+ * names belong to the caller's gateway, never to Evolve's alias maps).
364
+ */
365
+ isExternalGateway?: boolean;
366
+ /** Skills enabled for this run */
367
+ skills?: string[];
368
+ /** Sandbox home directory (default: "/home/user") */
369
+ homeDir?: string;
370
+ }
371
+ interface AgentRegistryEntry {
372
+ /** Sandbox image/template identifier (provider maps to its own concept) */
373
+ image: string;
374
+ /** Environment variable name for API key */
375
+ apiKeyEnv: string;
376
+ /** Environment variable name for OAuth (file path or token depending on agent) */
377
+ oauthEnv?: string;
378
+ /** OAuth credentials filename (e.g., "auth.json" for Codex, "oauth_creds.json" for Gemini) */
379
+ oauthFileName?: string;
380
+ /** Environment variable to set when OAuth is active (e.g., GOOGLE_GENAI_USE_GCA=true for Gemini) */
381
+ oauthActivationEnv?: {
382
+ key: string;
383
+ value: string;
384
+ };
385
+ /** Environment variable name for base URL, if this CLI supports one */
386
+ baseUrlEnv?: string;
387
+ /** Default model alias */
388
+ defaultModel: string;
389
+ /** Available models for this agent */
390
+ models: ModelInfo[];
391
+ /** System prompt filename (e.g., "CLAUDE.md") */
392
+ systemPromptFile: string;
393
+ /** MCP configuration */
394
+ mcpConfig: McpConfigInfo;
395
+ /** Build the CLI command for this agent */
396
+ buildCommand: (opts: BuildCommandOptions) => string;
397
+ /** Extra setup step (e.g., codex login) */
398
+ setupCommand?: string;
399
+ /** Gateway path prefix for CLIs that use a provider-native passthrough endpoint */
400
+ gatewayPath?: string;
401
+ /** Default base URL for direct mode (only needed if provider requires specific endpoint, e.g., Qwen → Dashscope) */
402
+ defaultBaseUrl?: string;
403
+ /** Available beta headers for this agent (for reference) */
404
+ availableBetas?: Record<string, string>;
405
+ /** Skills configuration for this agent */
406
+ skillsConfig: SkillsConfig;
407
+ /** Multi-provider env mapping: model prefix → keyEnv (for CLIs like OpenCode that resolve provider from model string) */
408
+ providerEnvMap?: Record<string, {
409
+ keyEnv: string;
410
+ }>;
411
+ /** Env var for inline config (e.g., OPENCODE_CONFIG_CONTENT) — used in gateway mode to set provider base URLs */
412
+ gatewayConfigEnv?: string;
413
+ /** Gateway-only model aliases for CLIs whose native model IDs differ from the Evolve gateway's route names */
414
+ gatewayModelAliases?: Record<string, string>;
415
+ /** Direct-mode model aliases for CLIs whose public model names differ from CLI-native model IDs */
416
+ directModelAliases?: Record<string, string>;
417
+ /** Do not set provider API key env in gateway mode (used when routing via generated settings instead) */
418
+ skipApiKeyEnvInGateway?: boolean;
419
+ /** Dedicated Droid settings file for Evolve gateway custom model routing */
420
+ droidGatewaySettings?: {
421
+ settingsPath: string;
422
+ displayName: string;
423
+ provider: "generic-chat-completion-api" | "openai" | "anthropic";
424
+ maxOutputTokens?: number;
425
+ };
426
+ /** Environment variable that CLI reads for custom outbound HTTP headers */
427
+ customHeadersEnv?: string;
428
+ /** Format for custom headers env var: "newline" (Claude) or "comma" (Gemini). Default: "newline" */
429
+ customHeadersFormat?: "newline" | "comma";
430
+ /**
431
+ * Per-env-var spend tracking for CLIs that support env_http_headers in config
432
+ * (e.g., Codex TOML). Maps Evolve gateway header names to env var names that the CLI
433
+ * reads at request time. Alternative to customHeadersEnv for agents without a
434
+ * single custom-headers env var.
435
+ */
436
+ spendTrackingEnvs?: {
437
+ /** Env var name for x-litellm-customer-id value */
438
+ sessionTagEnv: string;
439
+ /** Env var name for x-litellm-tags value */
440
+ runTagEnv: string;
441
+ };
442
+ /**
443
+ * Config-file-based spend tracking for CLIs that read custom headers from a
444
+ * JSON settings file (e.g., Qwen settings.json → model.generationConfig.customHeaders).
445
+ * The SDK writes headers to this file before each run.
446
+ * Source-verified: Qwen reads customHeaders from settings.json, not env vars.
447
+ */
448
+ spendTrackingJsonConfig?: {
449
+ /** JSON path to the customHeaders object (dot-separated) */
450
+ headersPath: string;
451
+ };
452
+ /**
453
+ * TOML provider-based spend tracking for CLIs that read custom_headers from a
454
+ * provider entry in config.toml (e.g., Kimi Code).
455
+ * The SDK writes a provider+model entry with custom_headers before each run.
456
+ * Source-verified: Kimi Code reads custom_headers from
457
+ * providers[name].custom_headers in ~/.kimi-code/config.toml.
458
+ */
459
+ spendTrackingTomlProvider?: {
460
+ /** Config file path (e.g., "~/.kimi-code/config.toml") */
461
+ configPath: string;
462
+ /** Provider name in config (e.g., "evolve-gateway") */
463
+ providerName: string;
464
+ /** Model entry name (e.g., "evolve-default") */
465
+ modelName: string;
466
+ /** Max context size for the model entry */
467
+ maxContextSize: number;
468
+ };
469
+ /** Additional directories to include in checkpoint tar (beyond mcpConfig.settingsDir).
470
+ * Used for agents like OpenCode that spread state across XDG directories. */
471
+ checkpointDirs?: string[];
472
+ /** Additional relative paths to exclude from checkpoint tar. */
473
+ checkpointExcludes?: string[];
474
+ }
475
+ /**
476
+ * Registry of all supported agents.
477
+ *
478
+ * Each agent defines a buildCommand function that constructs the CLI command.
479
+ * This is type-safe and handles conditional logic cleanly.
480
+ */
481
+ declare const AGENT_REGISTRY: Record<AgentType, AgentRegistryEntry>;
482
+ /**
483
+ * Get registry entry for an agent type
484
+ */
485
+ declare function getAgentConfig(agentType: AgentType): AgentRegistryEntry;
486
+ /**
487
+ * Check if an agent type is valid
488
+ */
489
+ declare function isValidAgentType(type: string): type is AgentType;
490
+ /**
491
+ * Expand path with ~ to the sandbox home directory (default: /home/user)
492
+ */
493
+ declare function expandPath(path: string, homeDir?: string): string;
494
+ /**
495
+ * Get MCP settings path for an agent
496
+ */
497
+ declare function getMcpSettingsPath(agentType: AgentType, homeDir?: string): string;
498
+ /**
499
+ * Get MCP settings directory for an agent
500
+ */
501
+ declare function getMcpSettingsDir(agentType: AgentType, homeDir?: string): string;
502
+
503
+ interface ManagedSecretRef {
504
+ name: string;
505
+ as?: string;
506
+ }
507
+ interface ManagedSecretMetadata {
508
+ id: string;
509
+ name: string;
510
+ allowedHosts: string[];
511
+ allowedPathPrefixes: string[];
512
+ allowedMethods: string[];
513
+ createdAt: string;
514
+ updatedAt: string;
515
+ lastUsedAt: string | null;
516
+ }
517
+ interface ManagedSecretsClientConfig {
518
+ apiKey?: string;
519
+ dashboardUrl?: string;
520
+ }
521
+ interface ManagedSecretsClient {
522
+ list(): Promise<ManagedSecretMetadata[]>;
523
+ }
524
+ declare function managedSecrets(config?: ManagedSecretsClientConfig): ManagedSecretsClient;
525
+
526
+ interface EvolveEvents {
527
+ stdout: (chunk: string) => void;
528
+ stderr: (chunk: string) => void;
529
+ content: (event: OutputEvent) => void;
530
+ lifecycle: (event: LifecycleEvent) => void;
531
+ }
532
+ interface EvolveConfig {
533
+ agent?: AgentConfig;
534
+ sandbox?: SandboxProvider;
535
+ sandboxCreateOptions?: SandboxCreateOptions;
536
+ workingDirectory?: string;
537
+ workspaceMode?: WorkspaceMode;
538
+ secrets?: Record<string, string>;
539
+ managedSecrets?: ManagedSecretRef[];
540
+ sandboxId?: string;
541
+ systemPrompt?: string;
542
+ context?: FileMap;
543
+ files?: FileMap;
544
+ mcpServers?: Record<string, McpServerConfig>;
545
+ browser?: BrowserConfig;
546
+ browserCredentials?: BrowserCredentialsConfig;
547
+ plugins?: AgentPluginConfig[];
548
+ skills?: SkillName[];
549
+ schema?: ZodType<unknown> | JsonSchema;
550
+ schemaOptions?: SchemaValidationOptions;
551
+ sessionTagPrefix?: string;
552
+ observability?: Record<string, unknown>;
553
+ integrations?: IntegrationsSetup;
554
+ storage?: StorageConfig;
555
+ }
288
556
  /** Result of a completed sandbox command */
289
557
  interface SandboxCommandResult {
290
558
  exitCode: number;
@@ -318,6 +586,13 @@ interface SandboxRunOptions {
318
586
  interface SandboxSpawnOptions extends SandboxRunOptions {
319
587
  stdin?: boolean;
320
588
  }
589
+ /** Provider-neutral outbound network policy applied when the sandbox boots. */
590
+ interface SandboxNetworkPolicy {
591
+ /** Allow all outbound traffic, or deny it except for allowedDestinations. */
592
+ outbound: "open" | "blocked";
593
+ /** Hostnames, IP addresses, or CIDR ranges that remain reachable when blocked. */
594
+ allowedDestinations?: string[];
595
+ }
321
596
  /** Options for creating a sandbox */
322
597
  interface SandboxCreateOptions {
323
598
  /** Sandbox image/template ID. Provider uses its default if not specified. */
@@ -326,6 +601,59 @@ interface SandboxCreateOptions {
326
601
  metadata?: Record<string, string>;
327
602
  timeoutMs?: number;
328
603
  workingDirectory?: string;
604
+ /**
605
+ * Per-sandbox compute sizing: cpu in cores, memory and disk in GiB.
606
+ * Providers must reject entries they cannot enforce at create time, never
607
+ * silently ignore them (modal sizes cpu/memory at create but cannot size
608
+ * disk; e2b sizes at template build only; daytona sizes at snapshot build,
609
+ * so an existing snapshot cannot be resized at create).
610
+ */
611
+ resources?: {
612
+ cpu?: number;
613
+ memory?: number;
614
+ disk?: number;
615
+ };
616
+ /** Providers must reject policies they cannot enforce; never silently ignore them. */
617
+ network?: SandboxNetworkPolicy;
618
+ /**
619
+ * Run all commands and file operations as this user.
620
+ * Providers must reject it if they cannot enforce it, never silently ignore it.
621
+ */
622
+ user?: string;
623
+ /**
624
+ * Home directory used for agent config paths inside the sandbox.
625
+ * Default: "/root" when user is "root", "/home/<user>" for other users,
626
+ * "/home/user" when no user is given.
627
+ */
628
+ homeDir?: string;
629
+ }
630
+ /** Options for listing sandboxes (capability: SandboxProvider.list). */
631
+ interface SandboxListOptions {
632
+ /**
633
+ * Provider-neutral states. Providers map them onto their own vocabulary and
634
+ * must not invent matches for a state they do not have (Modal has no paused
635
+ * state, so a filter excluding "running" matches nothing there).
636
+ */
637
+ state?: ("running" | "paused")[];
638
+ metadata?: Record<string, string>;
639
+ limit?: number;
640
+ }
641
+ /** File or directory entry (capability: SandboxFiles.list). */
642
+ interface FileInfo {
643
+ name: string;
644
+ path: string;
645
+ type: "file" | "dir";
646
+ }
647
+ /** Sandbox metadata and lifecycle info (capability: SandboxProvider.list, SandboxInstance.getInfo). */
648
+ interface SandboxInfo {
649
+ sandboxId: string;
650
+ /** The provider-neutral image/template the sandbox booted from. */
651
+ image: string;
652
+ name?: string;
653
+ metadata: Record<string, string>;
654
+ startedAt: string;
655
+ /** End time (undefined for running sandboxes). */
656
+ endAt?: string;
329
657
  }
330
658
  /** Command execution capabilities */
331
659
  interface SandboxCommands {
@@ -343,6 +671,27 @@ interface SandboxFiles {
343
671
  data: string | Buffer | ArrayBuffer | Uint8Array;
344
672
  }>): Promise<void>;
345
673
  makeDir(path: string): Promise<void>;
674
+ /**
675
+ * Upload a LOCAL file by path, without loading it into the process heap.
676
+ *
677
+ * write()/writeBatch() take the bytes as a value, so uploading a large
678
+ * artifact costs one full-size Buffer per concurrent upload — a caller doing
679
+ * many uploads at once pays that in RSS. This takes the path instead and lets
680
+ * the provider move the bytes its own cheapest way (a request body streamed
681
+ * off disk, or the vendor SDK's own path upload).
682
+ *
683
+ * OPTIONAL: a provider that has no cheaper path than "read it and send it"
684
+ * omits this, and uploadFileFromPath() falls back to write().
685
+ */
686
+ writeFromPath?(sandboxPath: string, localPath: string): Promise<void>;
687
+ /** Check whether a file or directory exists. */
688
+ exists?(path: string): Promise<boolean>;
689
+ /** List directory contents. */
690
+ list?(path: string): Promise<FileInfo[]>;
691
+ /** Delete a file or directory. */
692
+ remove?(path: string): Promise<void>;
693
+ /** Rename or move a file or directory. */
694
+ rename?(oldPath: string, newPath: string): Promise<void>;
346
695
  }
347
696
  /** Sandbox instance */
348
697
  interface SandboxInstance {
@@ -353,15 +702,28 @@ interface SandboxInstance {
353
702
  getHost(port: number): Promise<string>;
354
703
  kill(): Promise<void>;
355
704
  pause(): Promise<void>;
705
+ /** Whether the sandbox is currently running. */
706
+ isRunning?(): Promise<boolean>;
707
+ /** Sandbox metadata and timing. */
708
+ getInfo?(): Promise<SandboxInfo>;
356
709
  }
357
710
  /** Sandbox lifecycle management - providers implement this */
358
711
  interface SandboxProvider {
359
712
  /** Provider type identifier (e.g., "e2b") */
360
713
  readonly providerType: string;
361
- /** Human-readable provider name for logging */
714
+ /** Human-readable provider name for logging (e.g., "E2B") */
362
715
  readonly name?: string;
363
716
  create(options: SandboxCreateOptions): Promise<SandboxInstance>;
364
717
  connect(sandboxId: string, timeoutMs?: number): Promise<SandboxInstance>;
718
+ /**
719
+ * List sandboxes (first page only, up to `limit`).
720
+ *
721
+ * OPTIONAL: all three first-party providers implement it, but the SDK never
722
+ * calls it, so requiring it would break third-party providers passed to
723
+ * .withSandbox() for no gain. Declared here so every provider that offers it
724
+ * offers the SAME signature.
725
+ */
726
+ list?(options?: SandboxListOptions): Promise<SandboxInfo[]>;
365
727
  }
366
728
  /** Supported agent types (headless CLI agents only, no ACP) */
367
729
  type AgentType = "claude" | "codex" | "gemini" | "qwen" | "kimi" | "opencode" | "droid";
@@ -376,7 +738,7 @@ declare const AGENT_TYPES: {
376
738
  readonly DROID: "droid";
377
739
  };
378
740
  /** Workspace mode determines folder structure and system prompt */
379
- type WorkspaceMode = "knowledge" | "swe";
741
+ type WorkspaceMode = "knowledge" | "swe" | "task";
380
742
  /** Available skills that can be enabled */
381
743
  type SkillName = "pdf" | "dev-browser" | (string & {});
382
744
  /** Browser automation providers that can be enabled explicitly */
@@ -520,6 +882,21 @@ interface SchemaValidationOptions {
520
882
  * Validation mode preset definitions
521
883
  */
522
884
  declare const VALIDATION_PRESETS: Record<ValidationMode, Required<Omit<SchemaValidationOptions, "mode">>>;
885
+ /**
886
+ * Caller-minted gateway credential for external gateway mode.
887
+ *
888
+ * For callers that mint their own spend-capped key on an OpenAI-compatible
889
+ * gateway. The credential is injected like direct mode and sealCredentials()
890
+ * calls revoke() — sealing fails if revocation fails.
891
+ */
892
+ interface ExternalGatewayConfig {
893
+ /** Spend-capped gateway API key minted by the caller */
894
+ apiKey: string;
895
+ /** OpenAI-compatible gateway base URL */
896
+ baseUrl: string;
897
+ /** Revoke the minted credential. Called by sealCredentials(); seal fails if this throws. */
898
+ revoke: () => Promise<void>;
899
+ }
523
900
  /** Configuration passed to withAgent() */
524
901
  interface AgentConfig {
525
902
  /** Agent type (default: "claude") */
@@ -532,10 +909,27 @@ interface AgentConfig {
532
909
  oauthToken?: string;
533
910
  /** Provider base URL for direct mode (default: provider env var or registry default) */
534
911
  providerBaseUrl?: string;
912
+ /**
913
+ * Caller-minted revocable gateway credential. Mutually exclusive with
914
+ * apiKey (gateway mode) and providerApiKey/providerBaseUrl (direct mode).
915
+ */
916
+ externalGateway?: ExternalGatewayConfig;
535
917
  /** Model to use (optional, uses agent's default if omitted) */
536
918
  model?: string;
537
919
  /** Reasoning effort for models that support it */
538
920
  reasoningEffort?: ReasoningEffort;
921
+ /**
922
+ * Context/completion ceiling for CLIs that must be told one (Kimi Code reads
923
+ * it as `max_context_size` and sends it as the request's `max_tokens`).
924
+ *
925
+ * Set it to the model's real ceiling when driving a harness against a model
926
+ * from another family — e.g. Kimi Code against `gpt-5.5` through an
927
+ * OpenAI-compatible gateway, where an oversized `max_tokens` is rejected with
928
+ * a 400. When set it is used verbatim. When omitted, the harness's own models
929
+ * keep their registry value and any other model falls back to a conservative
930
+ * 128000. Harnesses that never send a ceiling ignore it.
931
+ */
932
+ maxContextSize?: number;
539
933
  }
540
934
  /** Resolved agent config (output of resolution, not an extension of input) */
541
935
  interface ResolvedAgentConfig {
@@ -546,15 +940,29 @@ interface ResolvedAgentConfig {
546
940
  isOAuth?: boolean;
547
941
  /** File content for file-based OAuth (Codex) */
548
942
  oauthFileContent?: string;
943
+ /** External gateway mode: caller-minted revocable credential */
944
+ externalGateway?: {
945
+ revoke: () => Promise<void>;
946
+ };
549
947
  model?: string;
550
948
  reasoningEffort?: ReasoningEffort;
949
+ /** Caller-pinned context/completion ceiling; used verbatim when present */
950
+ maxContextSize?: number;
551
951
  }
552
952
  /** Options for Agent constructor */
553
953
  interface AgentOptions {
554
954
  /** Sandbox provider (e.g., E2B) */
555
955
  sandboxProvider?: SandboxProvider;
956
+ /** Provider-neutral sandbox creation options forwarded on fresh creates. */
957
+ sandboxCreateOptions?: SandboxCreateOptions;
556
958
  /** Additional environment secrets */
557
959
  secrets?: Record<string, string>;
960
+ /** Dashboard-stored managed secrets exposed through opaque env vars. */
961
+ managedSecrets?: {
962
+ secrets: ManagedSecretRef[];
963
+ apiKey: string;
964
+ dashboardUrl?: string;
965
+ };
558
966
  /** Existing sandbox ID to connect to */
559
967
  sandboxId?: string;
560
968
  /** Working directory path */
@@ -706,7 +1114,7 @@ interface RunCost {
706
1114
  runId: string;
707
1115
  /** 1-based chronological position in session */
708
1116
  index: number;
709
- /** Total cost in USD (includes platform margin) */
1117
+ /** Total cost in USD as billed to your Evolve account */
710
1118
  cost: number;
711
1119
  /** Token counts */
712
1120
  tokens: {
@@ -986,8 +1394,6 @@ interface IntegrationAccountDeleteResult {
986
1394
  *
987
1395
  * Single Agent class that uses registry lookup for agent-specific behavior.
988
1396
  * All agent differences are data (in registry), not code.
989
- *
990
- * Evidence: sdk-rewrite-v3.md Design Decisions section
991
1397
  */
992
1398
 
993
1399
  /**
@@ -1002,9 +1408,10 @@ declare class Agent {
1002
1408
  private sandbox?;
1003
1409
  private hasRun;
1004
1410
  private readonly workingDir;
1411
+ private readonly homeDir;
1005
1412
  private lastRunTimestamp?;
1006
1413
  private readonly registry;
1007
- /** Unified session ID — used for both observability (SessionLogger) and spend tracking (LiteLLM customer-id) */
1414
+ /** Unified session ID — used for both observability (SessionLogger) and spend tracking (gateway customer-id) */
1008
1415
  private sessionTag;
1009
1416
  /** Previous session tag — preserved across kill()/setSession() so cost queries still work */
1010
1417
  private previousSessionTag?;
@@ -1020,6 +1427,9 @@ declare class Agent {
1020
1427
  private droidSessionId?;
1021
1428
  private managedBrowserSession?;
1022
1429
  private providerRuntimeToken?;
1430
+ private managedSecretRuntimeToken?;
1431
+ private managedSecretProxy?;
1432
+ private credentialsSealed;
1023
1433
  private readonly skills?;
1024
1434
  private readonly storage?;
1025
1435
  private lastCheckpointId?;
@@ -1044,9 +1454,32 @@ declare class Agent {
1044
1454
  */
1045
1455
  getSandbox(callbacks?: StreamCallbacks): Promise<SandboxInstance>;
1046
1456
  /**
1047
- * Build environment variables for sandbox
1457
+ * The `max_context_size` Kimi Code is told, which it sends as the request's
1458
+ * `max_tokens`. Three cases, in order:
1459
+ *
1460
+ * 1. `maxContextSize` on the agent config wins verbatim — the caller knows
1461
+ * the model's real ceiling.
1462
+ * 2. A model the kimi registry entry itself declares keeps that entry's
1463
+ * value (262144).
1464
+ * 3. Any other model — e.g. driving Kimi Code against `gpt-5.5` through an
1465
+ * OpenAI-compatible gateway — gets the conservative constant, because
1466
+ * 262144 is above that model's ceiling and the gateway answers 400.
1467
+ *
1468
+ * Both kimi wiring paths (KIMI_MODEL_MAX_CONTEXT_SIZE and the config.toml
1469
+ * `max_context_size`) resolve it here, so they can never disagree.
1048
1470
  */
1049
- private buildEnvironmentVariables;
1471
+ private resolveKimiMaxContextSize;
1472
+ /**
1473
+ * Kimi Code model envs for direct-style credential injection (direct mode
1474
+ * and externalGateway mode). Kimi Code reads KIMI_MODEL_* — the registry's
1475
+ * KIMI_API_KEY/KIMI_BASE_URL are SDK-facing inputs the CLI never reads.
1476
+ */
1477
+ private buildKimiDirectModelEnvs;
1478
+ /**
1479
+ * Build environment variables for sandbox
1480
+ */
1481
+ private buildEnvironmentVariables;
1482
+ private buildSandboxCreateOptions;
1050
1483
  private validatedUserSecretsForEnvironment;
1051
1484
  private ensureManagedBrowserSession;
1052
1485
  private ensureProviderRuntimeToken;
@@ -1054,6 +1487,10 @@ declare class Agent {
1054
1487
  private setupManagedBrowser;
1055
1488
  private closeManagedBrowserSession;
1056
1489
  private closeProviderRuntimeToken;
1490
+ private ensureManagedSecretRuntimeToken;
1491
+ private bindManagedSecretRuntimeToken;
1492
+ private setupManagedSecretEgress;
1493
+ private closeManagedSecretRuntimeToken;
1057
1494
  /**
1058
1495
  * Build the inline gateway config JSON for agents using gatewayConfigEnv
1059
1496
  * (e.g., OpenCode OPENCODE_CONFIG_CONTENT). Centralizes the provider config
@@ -1067,9 +1504,12 @@ declare class Agent {
1067
1504
  */
1068
1505
  private buildGatewayConfigJson;
1069
1506
  private activeProviderRuntimeToken;
1507
+ private requireActiveProviderRuntimeToken;
1070
1508
  private ensureSessionLogger;
1071
1509
  private flushSessionLoggerWithTimeout;
1510
+ private requiresPreRunDashboardIngest;
1072
1511
  private providerRuntimeHeaderUpdates;
1512
+ private shouldExposeProviderRuntimeTokenEnv;
1073
1513
  private buildProviderRuntimeProcessEnvs;
1074
1514
  /**
1075
1515
  * Build per-run env overrides for spend tracking.
@@ -1082,6 +1522,7 @@ declare class Agent {
1082
1522
  private captureDroidSession;
1083
1523
  private extractDroidSessionId;
1084
1524
  private findDroidSessionId;
1525
+ private droidSessionStatePath;
1085
1526
  private loadDroidSessionState;
1086
1527
  private writeDroidSessionState;
1087
1528
  private resolveGatewayModel;
@@ -1090,6 +1531,7 @@ declare class Agent {
1090
1531
  * Agent-specific authentication setup
1091
1532
  */
1092
1533
  private setupAgentAuth;
1534
+ private writeGeminiGatewayAuthSettings;
1093
1535
  private setupAgentPlugins;
1094
1536
  private assertProviderRuntimeDoesNotExposeGatewayKey;
1095
1537
  /**
@@ -1128,6 +1570,16 @@ declare class Agent {
1128
1570
  * Execute arbitrary command in sandbox
1129
1571
  */
1130
1572
  executeCommand(command: string, options?: ExecuteCommandOptions, callbacks?: StreamCallbacks): Promise<AgentResponse>;
1573
+ /**
1574
+ * Permanently revoke the model capability attached to this sandbox.
1575
+ * This is intentionally fail-closed: configurations that may have placed
1576
+ * other credentials in the sandbox cannot claim to be sealed.
1577
+ */
1578
+ sealCredentials(): Promise<void>;
1579
+ /** Whether sealCredentials() has completed — the sandbox holds no revocable model credential. */
1580
+ isSealed(): boolean;
1581
+ /** Collect caller-declared files or directories after the credential boundary. */
1582
+ collectArtifacts(paths: string[]): Promise<FileMap>;
1131
1583
  /**
1132
1584
  * Upload context files (to context/ folder)
1133
1585
  */
@@ -1136,6 +1588,24 @@ declare class Agent {
1136
1588
  * Upload files to working directory
1137
1589
  */
1138
1590
  uploadFiles(files: FileMap): Promise<void>;
1591
+ /**
1592
+ * Upload one LOCAL file into the sandbox by path, without holding its bytes
1593
+ * in the process heap.
1594
+ *
1595
+ * uploadFiles() takes a FileMap — the bytes as a value — so a caller
1596
+ * uploading a large artifact pays one full-size Buffer per concurrent
1597
+ * upload. This takes the local path instead: the provider streams it off
1598
+ * disk (or hands its own SDK the path), so peak memory is a chunk rather
1599
+ * than the file. Use it for anything big enough that N concurrent uploads
1600
+ * would matter; uploadFiles() stays the right call for small content.
1601
+ *
1602
+ * `sandboxPath` follows the uploadFiles() convention: absolute paths are
1603
+ * used as-is, relative paths resolve under the working directory.
1604
+ *
1605
+ * Providers that expose no cheaper path than a plain write fall back to
1606
+ * reading the file — correct everywhere, cheap where the provider helps.
1607
+ */
1608
+ uploadFileFromPath(sandboxPath: string, localPath: string): Promise<void>;
1139
1609
  /**
1140
1610
  * Get output files from output/ folder with optional schema validation
1141
1611
  *
@@ -1198,7 +1668,7 @@ declare class Agent {
1198
1668
  /**
1199
1669
  * Get current session tag.
1200
1670
  * Returns null if no active session (before sandbox creation or after kill()).
1201
- * Used for both observability (dashboard traces) and spend tracking (LiteLLM customer-id).
1671
+ * Used for both observability (dashboard traces) and spend tracking (gateway customer-id).
1202
1672
  */
1203
1673
  getSessionTag(): string | null;
1204
1674
  /**
@@ -1243,8 +1713,7 @@ declare class Agent {
1243
1713
  /**
1244
1714
  * Get cost breakdown for the current session (all runs).
1245
1715
  *
1246
- * Queries the dashboard API which proxies to LiteLLM spend logs.
1247
- * Cost data has ~60s latency due to gateway batch writes.
1716
+ * Cost data can lag live usage by about a minute.
1248
1717
  * Also works after kill() for the most recent session only.
1249
1718
  *
1250
1719
  * Requires gateway mode (EVOLVE_API_KEY).
@@ -1265,149 +1734,6 @@ declare class Agent {
1265
1734
  }): Promise<RunCost>;
1266
1735
  }
1267
1736
 
1268
- /**
1269
- * Claude JSONL → ACP-style events parser.
1270
- *
1271
- * Native schema source (@anthropic-ai/claude-agent-sdk):
1272
- * MANUS-API/KNOWLEDGE/claude-agent-sdk/cc_sdk_typescript.md
1273
- * (SDKMessage, SDKAssistantMessage, SDKPartialAssistantMessage, Tool Input/Output types)
1274
- *
1275
- * Conversion logic reference:
1276
- * MANUS-API/KNOWLEDGE/claude-code-acp/src/tools.ts
1277
- * (toolInfoFromToolUse, toolUpdateFromToolResult)
1278
- *
1279
- * ACP output schema:
1280
- * MANUS-API/KNOWLEDGE/acp-typescript-sdk/src/schema/types.gen.ts
1281
- */
1282
-
1283
- /**
1284
- * Create a Claude parser instance with its own isolated cache.
1285
- * Each Evolve instance should create its own parser for proper isolation.
1286
- */
1287
- declare function createClaudeParser(): (jsonLine: string) => OutputEvent[] | null;
1288
-
1289
- /**
1290
- * Codex JSONL → ACP-style events parser.
1291
- *
1292
- * Native schema: codex-rs/exec/src/exec_events.rs
1293
- * - ThreadEvent: thread.started, turn.started, turn.completed, item.started, item.updated, item.completed
1294
- * - ThreadItemDetails: AgentMessage, Reasoning, CommandExecution, FileChange, McpToolCall, WebSearch, TodoList, Error
1295
- *
1296
- * ACP output: acp-typescript-sdk/src/schema/types.gen.ts
1297
- * - SessionUpdate: agent_message_chunk, agent_thought_chunk, tool_call, tool_call_update, plan
1298
- *
1299
- * Event mapping:
1300
- * reasoning → agent_thought_chunk (exec_events.rs:134 ReasoningItem { text })
1301
- * agent_message → agent_message_chunk (exec_events.rs:129 AgentMessageItem { text })
1302
- * mcp_tool_call → tool_call/update (exec_events.rs:215 McpToolCallItem)
1303
- * command_execution → tool_call/update (exec_events.rs:151 CommandExecutionItem)
1304
- * file_change → tool_call (exec_events.rs:176 FileChangeItem)
1305
- * todo_list → plan (exec_events.rs:245 TodoListItem { items: TodoItem[] })
1306
- * web_search → tool_call (exec_events.rs:227 WebSearchItem { query })
1307
- */
1308
-
1309
- /**
1310
- * Create a Codex parser instance.
1311
- */
1312
- declare function createCodexParser(): (jsonLine: string) => OutputEvent[] | null;
1313
-
1314
- /**
1315
- * Droid exec parser.
1316
- *
1317
- * Supports the documented headless `--output-format stream-json` lines and the
1318
- * raw `stream-jsonrpc` notification envelope used by Droid's low-level SDK.
1319
- */
1320
-
1321
- declare function createDroidParser(): (jsonLine: string) => OutputEvent[] | null;
1322
-
1323
- /**
1324
- * Gemini JSONL → ACP-style events parser.
1325
- *
1326
- * Native schema (gemini --output-format stream-json):
1327
- * gemini-cli/packages/core/src/output/types.ts
1328
- *
1329
- * Gemini events (types.ts:29-36 JsonStreamEventType):
1330
- * - "init" → types.ts:43-47 InitEvent { session_id, model }
1331
- * - "message" → types.ts:49-54 MessageEvent { role, content, delta? }
1332
- * - "tool_use" → types.ts:56-61 ToolUseEvent { tool_name, tool_id, parameters }
1333
- * - "tool_result" → types.ts:63-72 ToolResultEvent { tool_id, status, output?, error? }
1334
- * - "error" → types.ts:74-78 ErrorEvent { severity, message }
1335
- * - "result" → types.ts:91-99 ResultEvent { status, error?, stats? }
1336
- *
1337
- * ACP output: acp-typescript-sdk/src/schema/types.gen.ts:2449-2464
1338
- */
1339
-
1340
- /**
1341
- * Create a Gemini parser instance.
1342
- */
1343
- declare function createGeminiParser(): (jsonLine: string) => OutputEvent[] | null;
1344
-
1345
- /**
1346
- * Qwen NDJSON → ACP-style events parser.
1347
- *
1348
- * Native schema: KNOWLEDGE/qwen-code/packages/sdk-typescript/src/types/protocol.ts
1349
- * ACP schema: KNOWLEDGE/acp-typescript-sdk/src/schema/types.gen.ts
1350
- *
1351
- * Qwen NDJSON message types (protocol.ts:428-433):
1352
- * - type: "assistant" → SDKAssistantMessage (protocol.ts:102-108)
1353
- * - type: "stream_event" → SDKPartialAssistantMessage (protocol.ts:225-231)
1354
- * - type: "user" → SDKUserMessage (protocol.ts:93-100)
1355
- * - type: "system" → SDKSystemMessage (skipped)
1356
- * - type: "result" → SDKResultMessage (skipped)
1357
- *
1358
- * ContentBlock types (protocol.ts:72-76):
1359
- * - TextBlock (protocol.ts:43-48): { type: 'text', text: string }
1360
- * - ThinkingBlock (protocol.ts:49-54): { type: 'thinking', thinking: string }
1361
- * - ToolUseBlock (protocol.ts:56-62): { type: 'tool_use', id, name, input }
1362
- * - ToolResultBlock (protocol.ts:64-70): { type: 'tool_result', tool_use_id, content?, is_error? }
1363
- *
1364
- * StreamEvent types (protocol.ts:218-223):
1365
- * - message_start, content_block_start, content_block_delta, content_block_stop, message_stop
1366
- */
1367
-
1368
- /**
1369
- * Stateless parser function (creates new parser per call).
1370
- * Use createQwenParser() for stateful streaming parsing.
1371
- *
1372
- * @param line - Single line of NDJSON from qwen CLI
1373
- * @returns Array of OutputEvent objects, or null if line couldn't be parsed
1374
- */
1375
- declare function parseQwenOutput(line: string): OutputEvent[] | null;
1376
-
1377
- /**
1378
- * Unified Parser Entry Point
1379
- *
1380
- * Routes NDJSON lines to the appropriate agent-specific parser.
1381
- * Simple line-based parsing - no buffering needed since CLIs output complete JSON per line.
1382
- */
1383
-
1384
- /** Parser function type */
1385
- type AgentParser = (jsonLine: string) => OutputEvent[] | null;
1386
- /**
1387
- * Create a parser instance for the given agent type.
1388
- * Each Evolve instance should create its own parser for proper isolation.
1389
- *
1390
- * @param agentType - The agent type to create a parser for
1391
- * @returns Parser function that takes NDJSON lines and returns OutputEvents
1392
- */
1393
- declare function createAgentParser(agentType: AgentType): AgentParser;
1394
- /**
1395
- * Parse a single NDJSON line from any agent (creates new parser per call - use createAgentParser for efficiency)
1396
- *
1397
- * @param agentType - The agent type to parse for
1398
- * @param line - Single line of NDJSON output
1399
- * @returns Array of OutputEvent objects, or null if line couldn't be parsed
1400
- */
1401
- declare function parseNdjsonLine(agentType: AgentType, line: string): OutputEvent[] | null;
1402
- /**
1403
- * Parse multiple NDJSON lines (convenience wrapper)
1404
- *
1405
- * @param agentType - The agent type to parse for
1406
- * @param output - Multi-line NDJSON output
1407
- * @returns Array of all parsed OutputEvent objects
1408
- */
1409
- declare function parseNdjsonOutput(agentType: AgentType, output: string): OutputEvent[];
1410
-
1411
1737
  declare const BROWSER_LOGIN_MCP_SERVER_NAME = "browser-login";
1412
1738
  interface BrowserCredentialMetadata {
1413
1739
  id: string;
@@ -1489,52 +1815,6 @@ declare class BrowserProfilesClient {
1489
1815
  }
1490
1816
  declare function browserProfiles(config?: BrowserProfilesClientConfig): BrowserProfilesClient;
1491
1817
 
1492
- /**
1493
- * Evolve events
1494
- *
1495
- * Runtime streams:
1496
- * - stdout: Raw NDJSON lines
1497
- * - stderr: Process stderr
1498
- * - content: Parsed OutputEvent
1499
- * - lifecycle: Sandbox/agent lifecycle transitions
1500
- */
1501
- interface EvolveEvents {
1502
- stdout: (chunk: string) => void;
1503
- stderr: (chunk: string) => void;
1504
- content: (event: OutputEvent) => void;
1505
- lifecycle: (event: LifecycleEvent) => void;
1506
- }
1507
- interface EvolveConfig {
1508
- agent?: AgentConfig;
1509
- sandbox?: SandboxProvider;
1510
- workingDirectory?: string;
1511
- workspaceMode?: WorkspaceMode;
1512
- secrets?: Record<string, string>;
1513
- sandboxId?: string;
1514
- systemPrompt?: string;
1515
- context?: FileMap;
1516
- files?: FileMap;
1517
- mcpServers?: Record<string, McpServerConfig>;
1518
- /** Browser automation provider to enable explicitly */
1519
- browser?: BrowserConfig;
1520
- /** Browser login MCP setup for managed remote agent-browser runs */
1521
- browserCredentials?: BrowserCredentialsConfig;
1522
- /** Agent plugins/extensions to install before first run */
1523
- plugins?: AgentPluginConfig[];
1524
- /** Skills to enable (e.g., ["pdf", "dev-browser"]) */
1525
- skills?: SkillName[];
1526
- /** Schema for structured output (Zod or JSON Schema, auto-detected) */
1527
- schema?: z.ZodType<unknown> | JsonSchema;
1528
- /** Validation options for JSON Schema (ignored for Zod) */
1529
- schemaOptions?: SchemaValidationOptions;
1530
- sessionTagPrefix?: string;
1531
- /** Observability metadata for trace grouping (generic key-value, domain-agnostic) */
1532
- observability?: Record<string, unknown>;
1533
- /** Managed integrations config */
1534
- integrations?: IntegrationsSetup;
1535
- /** Storage configuration for checkpointing */
1536
- storage?: StorageConfig;
1537
- }
1538
1818
  /**
1539
1819
  * Evolve orchestrator with builder pattern
1540
1820
  *
@@ -1568,6 +1848,11 @@ declare class Evolve extends EventEmitter {
1568
1848
  * Configure sandbox provider
1569
1849
  */
1570
1850
  withSandbox(provider?: SandboxProvider): this;
1851
+ /**
1852
+ * Configure provider-neutral options used whenever Evolve creates a sandbox.
1853
+ * Evolve-owned runtime variables override conflicting env entries.
1854
+ */
1855
+ withSandboxCreateOptions(options: SandboxCreateOptions): this;
1571
1856
  /**
1572
1857
  * Set working directory path
1573
1858
  */
@@ -1576,12 +1861,19 @@ declare class Evolve extends EventEmitter {
1576
1861
  * Set workspace mode
1577
1862
  * - "knowledge": Creates context/, scripts/, temp/, output/ folders
1578
1863
  * - "swe": Same as knowledge + repo/ folder for code repositories
1864
+ * - "task": Leaves the task-owned working directory untouched
1579
1865
  */
1580
1866
  withWorkspaceMode(mode: WorkspaceMode): this;
1581
1867
  /**
1582
1868
  * Add environment secrets
1583
1869
  */
1584
1870
  withSecrets(secrets: Record<string, string>): this;
1871
+ /**
1872
+ * Attach Dashboard-stored managed secrets to the sandbox.
1873
+ *
1874
+ * The sandbox receives opaque env var values; raw secret values stay server-side.
1875
+ */
1876
+ withManagedSecrets(secrets: ManagedSecretRef[]): this;
1585
1877
  /**
1586
1878
  * Connect to existing session
1587
1879
  */
@@ -1710,6 +2002,8 @@ declare class Evolve extends EventEmitter {
1710
2002
  static browserCredentials: typeof browserCredentials;
1711
2003
  /** Static browser profile client for listing and deleting reusable browser profiles. */
1712
2004
  static browserProfiles: typeof browserProfiles;
2005
+ /** Static managed secrets client for listing Dashboard-stored secret metadata. */
2006
+ static managedSecrets: typeof managedSecrets;
1713
2007
  /**
1714
2008
  * Initialize agent on first use
1715
2009
  */
@@ -1738,6 +2032,21 @@ declare class Evolve extends EventEmitter {
1738
2032
  timeoutMs?: number;
1739
2033
  background?: boolean;
1740
2034
  }): Promise<AgentResponse>;
2035
+ /**
2036
+ * Create and fully initialize the configured sandbox without starting an
2037
+ * agent command. Durable orchestrators use this to persist the sandbox ID
2038
+ * before handing execution to the agent.
2039
+ */
2040
+ prepareSandbox(): Promise<string>;
2041
+ /**
2042
+ * Irreversibly revoke Evolve-managed runtime credentials for this sandbox.
2043
+ * Agent runs are disabled afterward; credential-free commands remain available.
2044
+ */
2045
+ sealCredentials(): Promise<void>;
2046
+ /** Whether sealCredentials() has completed for the active sandbox. */
2047
+ isSealed(): boolean;
2048
+ /** Collect files or directories from the working directory after credentials are sealed. */
2049
+ collectArtifacts(paths: string[]): Promise<FileMap>;
1741
2050
  /**
1742
2051
  * Interrupt active process without killing sandbox.
1743
2052
  */
@@ -1750,6 +2059,15 @@ declare class Evolve extends EventEmitter {
1750
2059
  * Upload files to workspace (runtime - immediate upload)
1751
2060
  */
1752
2061
  uploadFiles(files: FileMap): Promise<void>;
2062
+ /**
2063
+ * Upload one LOCAL file into the sandbox by path, streaming rather than
2064
+ * buffering it (runtime - immediate upload).
2065
+ *
2066
+ * The memory-bounded counterpart to uploadFiles(): use it when the file is
2067
+ * large enough that holding it in the heap — once per concurrent upload —
2068
+ * would matter.
2069
+ */
2070
+ uploadFileFromPath(sandboxPath: string, localPath: string): Promise<void>;
1753
2071
  /**
1754
2072
  * Get output files from output/ folder with optional schema validation
1755
2073
  *
@@ -1941,7 +2259,7 @@ interface SwarmConfig {
1941
2259
  /** Per-worker timeout in ms (default: 1 hour) */
1942
2260
  timeoutMs?: number;
1943
2261
  /** Workspace mode (default: SDK default 'knowledge') */
1944
- workspaceMode?: WorkspaceMode;
2262
+ workspaceMode?: Exclude<WorkspaceMode, "task">;
1945
2263
  /** Default retry configuration for all operations (per-operation config takes precedence) */
1946
2264
  retry?: RetryConfig;
1947
2265
  /** Default MCP servers for all operations (per-operation config takes precedence) */
@@ -2685,176 +3003,179 @@ declare class TerminalPipeline<T> extends Pipeline<T> {
2685
3003
  }
2686
3004
 
2687
3005
  /**
2688
- * Agent Registry
3006
+ * Sandbox providers the Dashboard runs on the customer's behalf.
2689
3007
  *
2690
- * Single source of truth for agent-specific behavior.
2691
- * All differences between agents are data, not code.
3008
+ * Managed mode means the customer holds one Evolve API key and no provider
3009
+ * credential at all: the Dashboard authenticates the key, records ownership,
3010
+ * and makes the provider call with platform credentials. Each provider has its
3011
+ * own door under /api/managed/<provider>.
3012
+ */
3013
+ declare const MANAGED_SANDBOX_PROVIDERS: readonly ["e2b", "daytona", "modal"];
3014
+ type ManagedSandboxProviderName = (typeof MANAGED_SANDBOX_PROVIDERS)[number];
3015
+
3016
+ /**
3017
+ * Sandbox Provider Resolution
2692
3018
  *
2693
- * Evidence: sdk-rewrite-v3.md Agent Registry section
3019
+ * Resolves default sandbox provider from environment.
3020
+ * Supports E2B, Daytona, and Modal providers.
2694
3021
  */
2695
3022
 
2696
- /** Model configuration */
2697
- interface ModelInfo {
2698
- /** Model alias (short name used with --model) */
2699
- alias: string;
2700
- /** Full model ID */
2701
- modelId: string;
2702
- /** What this model is best for */
2703
- description: string;
2704
- }
2705
- /** MCP configuration for an agent */
2706
- interface McpConfigInfo {
2707
- /** Settings directory (e.g., "~/.claude") */
2708
- settingsDir: string;
2709
- /** Config filename (e.g., "settings.json" or "config.toml") */
2710
- filename: string;
2711
- /** Config format */
2712
- format: "json" | "toml";
2713
- /** Whether to use workingDir for project-level config (Claude only) */
2714
- projectConfig?: boolean;
2715
- }
2716
- /** Options for building agent commands */
2717
- interface BuildCommandOptions {
2718
- prompt: string;
2719
- model: string;
2720
- isResume: boolean;
2721
- sessionId?: string;
2722
- reasoningEffort?: string;
2723
- isDirectMode?: boolean;
2724
- /** Skills enabled for this run */
2725
- skills?: string[];
2726
- }
2727
- interface AgentRegistryEntry {
2728
- /** Sandbox image/template identifier (provider maps to its own concept) */
2729
- image: string;
2730
- /** Environment variable name for API key */
2731
- apiKeyEnv: string;
2732
- /** Environment variable name for OAuth (file path or token depending on agent) */
2733
- oauthEnv?: string;
2734
- /** OAuth credentials filename (e.g., "auth.json" for Codex, "oauth_creds.json" for Gemini) */
2735
- oauthFileName?: string;
2736
- /** Environment variable to set when OAuth is active (e.g., GOOGLE_GENAI_USE_GCA=true for Gemini) */
2737
- oauthActivationEnv?: {
2738
- key: string;
2739
- value: string;
2740
- };
2741
- /** Environment variable name for base URL, if this CLI supports one */
2742
- baseUrlEnv?: string;
2743
- /** Default model alias */
2744
- defaultModel: string;
2745
- /** Available models for this agent */
2746
- models: ModelInfo[];
2747
- /** System prompt filename (e.g., "CLAUDE.md") */
2748
- systemPromptFile: string;
2749
- /** MCP configuration */
2750
- mcpConfig: McpConfigInfo;
2751
- /** Build the CLI command for this agent */
2752
- buildCommand: (opts: BuildCommandOptions) => string;
2753
- /** Extra setup step (e.g., codex login) */
2754
- setupCommand?: string;
2755
- /** Gateway path prefix for CLIs that use a provider-native passthrough endpoint */
2756
- gatewayPath?: string;
2757
- /** Default base URL for direct mode (only needed if provider requires specific endpoint, e.g., Qwen → Dashscope) */
2758
- defaultBaseUrl?: string;
2759
- /** Available beta headers for this agent (for reference) */
2760
- availableBetas?: Record<string, string>;
2761
- /** Skills configuration for this agent */
2762
- skillsConfig: SkillsConfig;
2763
- /** Multi-provider env mapping: model prefix → keyEnv (for CLIs like OpenCode that resolve provider from model string) */
2764
- providerEnvMap?: Record<string, {
2765
- keyEnv: string;
2766
- }>;
2767
- /** Env var for inline config (e.g., OPENCODE_CONFIG_CONTENT) — used in gateway mode to set provider base URLs */
2768
- gatewayConfigEnv?: string;
2769
- /** Gateway-only model aliases for CLIs whose native model IDs differ from LiteLLM route names */
2770
- gatewayModelAliases?: Record<string, string>;
2771
- /** Direct-mode model aliases for CLIs whose public model names differ from CLI-native model IDs */
2772
- directModelAliases?: Record<string, string>;
2773
- /** Do not set provider API key env in gateway mode (used when routing via generated settings instead) */
2774
- skipApiKeyEnvInGateway?: boolean;
2775
- /** Dedicated Droid settings file for Evolve gateway custom model routing */
2776
- droidGatewaySettings?: {
2777
- settingsPath: string;
2778
- displayName: string;
2779
- provider: "generic-chat-completion-api" | "openai" | "anthropic";
2780
- maxOutputTokens?: number;
2781
- };
2782
- /** Environment variable that CLI reads for custom outbound HTTP headers */
2783
- customHeadersEnv?: string;
2784
- /** Format for custom headers env var: "newline" (Claude) or "comma" (Gemini). Default: "newline" */
2785
- customHeadersFormat?: "newline" | "comma";
2786
- /**
2787
- * Per-env-var spend tracking for CLIs that support env_http_headers in config
2788
- * (e.g., Codex TOML). Maps LiteLLM header names to env var names that the CLI
2789
- * reads at request time. Alternative to customHeadersEnv for agents without a
2790
- * single custom-headers env var.
2791
- */
2792
- spendTrackingEnvs?: {
2793
- /** Env var name for x-litellm-customer-id value */
2794
- sessionTagEnv: string;
2795
- /** Env var name for x-litellm-tags value */
2796
- runTagEnv: string;
2797
- };
2798
- /**
2799
- * Config-file-based spend tracking for CLIs that read custom headers from a
2800
- * JSON settings file (e.g., Qwen settings.json → model.generationConfig.customHeaders).
2801
- * The SDK writes headers to this file before each run.
2802
- * Source-verified: Qwen reads customHeaders from settings.json, not env vars.
2803
- */
2804
- spendTrackingJsonConfig?: {
2805
- /** JSON path to the customHeaders object (dot-separated) */
2806
- headersPath: string;
2807
- };
2808
- /**
2809
- * TOML provider-based spend tracking for CLIs that read custom_headers from a
2810
- * provider entry in config.toml (e.g., Kimi Code).
2811
- * The SDK writes a provider+model entry with custom_headers before each run.
2812
- * Source-verified: Kimi Code reads custom_headers from
2813
- * providers[name].custom_headers in ~/.kimi-code/config.toml.
2814
- */
2815
- spendTrackingTomlProvider?: {
2816
- /** Config file path (e.g., "~/.kimi-code/config.toml") */
2817
- configPath: string;
2818
- /** Provider name in config (e.g., "evolve-gateway") */
2819
- providerName: string;
2820
- /** Model entry name (e.g., "evolve-default") */
2821
- modelName: string;
2822
- /** Max context size for the model entry */
2823
- maxContextSize: number;
2824
- };
2825
- /** Additional directories to include in checkpoint tar (beyond mcpConfig.settingsDir).
2826
- * Used for agents like OpenCode that spread state across XDG directories. */
2827
- checkpointDirs?: string[];
2828
- /** Additional relative paths to exclude from checkpoint tar. */
2829
- checkpointExcludes?: string[];
2830
- }
2831
3023
  /**
2832
- * Registry of all supported agents.
3024
+ * A sandbox the platform runs for you.
2833
3025
  *
2834
- * Each agent defines a buildCommand function that constructs the CLI command.
2835
- * This is type-safe and handles conditional logic cleanly.
3026
+ * ```ts
3027
+ * const kit = new Evolve()
3028
+ * .withAgent({ agentType: "claude" })
3029
+ * .withSandbox(await managedSandbox("daytona"));
3030
+ * ```
3031
+ *
3032
+ * Requires an Evolve API key and no provider credential of any kind. Omit the
3033
+ * provider to take the platform default (E2B).
2836
3034
  */
2837
- declare const AGENT_REGISTRY: Record<AgentType, AgentRegistryEntry>;
3035
+ declare function managedSandbox(provider?: ManagedSandboxProviderName, evolveKey?: string): Promise<SandboxProvider>;
3036
+
2838
3037
  /**
2839
- * Get registry entry for an agent type
3038
+ * Claude JSONL → ACP-style events parser.
3039
+ *
3040
+ * Native schema source (@anthropic-ai/claude-agent-sdk):
3041
+ * MANUS-API/KNOWLEDGE/claude-agent-sdk/cc_sdk_typescript.md
3042
+ * (SDKMessage, SDKAssistantMessage, SDKPartialAssistantMessage, Tool Input/Output types)
3043
+ *
3044
+ * Conversion logic reference:
3045
+ * MANUS-API/KNOWLEDGE/claude-code-acp/src/tools.ts
3046
+ * (toolInfoFromToolUse, toolUpdateFromToolResult)
3047
+ *
3048
+ * ACP output schema:
3049
+ * MANUS-API/KNOWLEDGE/acp-typescript-sdk/src/schema/types.gen.ts
2840
3050
  */
2841
- declare function getAgentConfig(agentType: AgentType): AgentRegistryEntry;
3051
+
2842
3052
  /**
2843
- * Check if an agent type is valid
3053
+ * Create a Claude parser instance with its own isolated cache.
3054
+ * Each Evolve instance should create its own parser for proper isolation.
2844
3055
  */
2845
- declare function isValidAgentType(type: string): type is AgentType;
3056
+ declare function createClaudeParser(): (jsonLine: string) => OutputEvent[] | null;
3057
+
2846
3058
  /**
2847
- * Expand path with ~ to /home/user
3059
+ * Codex JSONL → ACP-style events parser.
3060
+ *
3061
+ * Native schema: codex-rs/exec/src/exec_events.rs
3062
+ * - ThreadEvent: thread.started, turn.started, turn.completed, item.started, item.updated, item.completed
3063
+ * - ThreadItemDetails: AgentMessage, Reasoning, CommandExecution, FileChange, McpToolCall, WebSearch, TodoList, Error
3064
+ *
3065
+ * ACP output: acp-typescript-sdk/src/schema/types.gen.ts
3066
+ * - SessionUpdate: agent_message_chunk, agent_thought_chunk, tool_call, tool_call_update, plan
3067
+ *
3068
+ * Event mapping:
3069
+ * reasoning → agent_thought_chunk (exec_events.rs:134 ReasoningItem { text })
3070
+ * agent_message → agent_message_chunk (exec_events.rs:129 AgentMessageItem { text })
3071
+ * mcp_tool_call → tool_call/update (exec_events.rs:215 McpToolCallItem)
3072
+ * command_execution → tool_call/update (exec_events.rs:151 CommandExecutionItem)
3073
+ * file_change → tool_call (exec_events.rs:176 FileChangeItem)
3074
+ * todo_list → plan (exec_events.rs:245 TodoListItem { items: TodoItem[] })
3075
+ * web_search → tool_call (exec_events.rs:227 WebSearchItem { query })
2848
3076
  */
2849
- declare function expandPath(path: string): string;
3077
+
2850
3078
  /**
2851
- * Get MCP settings path for an agent
3079
+ * Create a Codex parser instance.
2852
3080
  */
2853
- declare function getMcpSettingsPath(agentType: AgentType): string;
3081
+ declare function createCodexParser(): (jsonLine: string) => OutputEvent[] | null;
3082
+
2854
3083
  /**
2855
- * Get MCP settings directory for an agent
3084
+ * Droid exec parser.
3085
+ *
3086
+ * Supports the documented headless `--output-format stream-json` lines and the
3087
+ * raw `stream-jsonrpc` notification envelope used by Droid's low-level SDK.
2856
3088
  */
2857
- declare function getMcpSettingsDir(agentType: AgentType): string;
3089
+
3090
+ declare function createDroidParser(): (jsonLine: string) => OutputEvent[] | null;
3091
+
3092
+ /**
3093
+ * Gemini JSONL → ACP-style events parser.
3094
+ *
3095
+ * Native schema (gemini --output-format stream-json):
3096
+ * gemini-cli/packages/core/src/output/types.ts
3097
+ *
3098
+ * Gemini events (types.ts:29-36 JsonStreamEventType):
3099
+ * - "init" → types.ts:43-47 InitEvent { session_id, model }
3100
+ * - "message" → types.ts:49-54 MessageEvent { role, content, delta? }
3101
+ * - "tool_use" → types.ts:56-61 ToolUseEvent { tool_name, tool_id, parameters }
3102
+ * - "tool_result" → types.ts:63-72 ToolResultEvent { tool_id, status, output?, error? }
3103
+ * - "error" → types.ts:74-78 ErrorEvent { severity, message }
3104
+ * - "result" → types.ts:91-99 ResultEvent { status, error?, stats? }
3105
+ *
3106
+ * ACP output: acp-typescript-sdk/src/schema/types.gen.ts:2449-2464
3107
+ */
3108
+
3109
+ /**
3110
+ * Create a Gemini parser instance.
3111
+ */
3112
+ declare function createGeminiParser(): (jsonLine: string) => OutputEvent[] | null;
3113
+
3114
+ /**
3115
+ * Qwen NDJSON → ACP-style events parser.
3116
+ *
3117
+ * Native schema: KNOWLEDGE/qwen-code/packages/sdk-typescript/src/types/protocol.ts
3118
+ * ACP schema: KNOWLEDGE/acp-typescript-sdk/src/schema/types.gen.ts
3119
+ *
3120
+ * Qwen NDJSON message types (protocol.ts:428-433):
3121
+ * - type: "assistant" → SDKAssistantMessage (protocol.ts:102-108)
3122
+ * - type: "stream_event" → SDKPartialAssistantMessage (protocol.ts:225-231)
3123
+ * - type: "user" → SDKUserMessage (protocol.ts:93-100)
3124
+ * - type: "system" → SDKSystemMessage (skipped)
3125
+ * - type: "result" → SDKResultMessage (skipped)
3126
+ *
3127
+ * ContentBlock types (protocol.ts:72-76):
3128
+ * - TextBlock (protocol.ts:43-48): { type: 'text', text: string }
3129
+ * - ThinkingBlock (protocol.ts:49-54): { type: 'thinking', thinking: string }
3130
+ * - ToolUseBlock (protocol.ts:56-62): { type: 'tool_use', id, name, input }
3131
+ * - ToolResultBlock (protocol.ts:64-70): { type: 'tool_result', tool_use_id, content?, is_error? }
3132
+ *
3133
+ * StreamEvent types (protocol.ts:218-223):
3134
+ * - message_start, content_block_start, content_block_delta, content_block_stop, message_stop
3135
+ */
3136
+
3137
+ /**
3138
+ * Stateless parser function (creates new parser per call).
3139
+ * Use createQwenParser() for stateful streaming parsing.
3140
+ *
3141
+ * @param line - Single line of NDJSON from qwen CLI
3142
+ * @returns Array of OutputEvent objects, or null if line couldn't be parsed
3143
+ */
3144
+ declare function parseQwenOutput(line: string): OutputEvent[] | null;
3145
+
3146
+ /**
3147
+ * Unified Parser Entry Point
3148
+ *
3149
+ * Routes NDJSON lines to the appropriate agent-specific parser.
3150
+ * Simple line-based parsing - no buffering needed since CLIs output complete JSON per line.
3151
+ */
3152
+
3153
+ /** Parser function type */
3154
+ type AgentParser = (jsonLine: string) => OutputEvent[] | null;
3155
+ /**
3156
+ * Create a parser instance for the given agent type.
3157
+ * Each Evolve instance should create its own parser for proper isolation.
3158
+ *
3159
+ * @param agentType - The agent type to create a parser for
3160
+ * @returns Parser function that takes NDJSON lines and returns OutputEvents
3161
+ */
3162
+ declare function createAgentParser(agentType: AgentType): AgentParser;
3163
+ /**
3164
+ * Parse a single NDJSON line from any agent (creates new parser per call - use createAgentParser for efficiency)
3165
+ *
3166
+ * @param agentType - The agent type to parse for
3167
+ * @param line - Single line of NDJSON output
3168
+ * @returns Array of OutputEvent objects, or null if line couldn't be parsed
3169
+ */
3170
+ declare function parseNdjsonLine(agentType: AgentType, line: string): OutputEvent[] | null;
3171
+ /**
3172
+ * Parse multiple NDJSON lines (convenience wrapper)
3173
+ *
3174
+ * @param agentType - The agent type to parse for
3175
+ * @param output - Multi-line NDJSON output
3176
+ * @returns Array of all parsed OutputEvent objects
3177
+ */
3178
+ declare function parseNdjsonOutput(agentType: AgentType, output: string): OutputEvent[];
2858
3179
 
2859
3180
  /**
2860
3181
  * MCP JSON Configuration Writer
@@ -2876,11 +3197,11 @@ declare function getMcpSettingsDir(agentType: AgentType): string;
2876
3197
  * 1. ${workingDir}/.mcp.json - project-level MCP servers
2877
3198
  * 2. ~/.claude/settings.json - enable project MCP servers
2878
3199
  */
2879
- declare function writeClaudeMcpConfig(sandbox: SandboxInstance, workingDir: string, servers: Record<string, McpServerConfig>): Promise<void>;
3200
+ declare function writeClaudeMcpConfig(sandbox: SandboxInstance, workingDir: string, servers: Record<string, McpServerConfig>, homeDir?: string): Promise<void>;
2880
3201
  /** Write MCP config for Gemini agent */
2881
- declare function writeGeminiMcpConfig(sandbox: SandboxInstance, servers: Record<string, McpServerConfig>): Promise<void>;
3202
+ declare function writeGeminiMcpConfig(sandbox: SandboxInstance, servers: Record<string, McpServerConfig>, homeDir?: string): Promise<void>;
2882
3203
  /** Write MCP config for Qwen agent */
2883
- declare function writeQwenMcpConfig(sandbox: SandboxInstance, servers: Record<string, McpServerConfig>): Promise<void>;
3204
+ declare function writeQwenMcpConfig(sandbox: SandboxInstance, servers: Record<string, McpServerConfig>, homeDir?: string): Promise<void>;
2884
3205
  /**
2885
3206
  * Write MCP config for Droid agent
2886
3207
  *
@@ -2903,7 +3224,7 @@ interface DroidGatewaySettingsConfig {
2903
3224
  * The command passes this file with `droid --settings`, so it does not alter the
2904
3225
  * user's normal ~/.factory/settings.json inside the sandbox.
2905
3226
  */
2906
- declare function writeDroidGatewaySettings(sandbox: SandboxInstance, config: DroidGatewaySettingsConfig, headers: Record<string, string>): Promise<void>;
3227
+ declare function writeDroidGatewaySettings(sandbox: SandboxInstance, config: DroidGatewaySettingsConfig, headers: Record<string, string>, homeDir?: string): Promise<void>;
2907
3228
 
2908
3229
  /**
2909
3230
  * MCP TOML Configuration Writer
@@ -2918,7 +3239,7 @@ declare function writeDroidGatewaySettings(sandbox: SandboxInstance, config: Dro
2918
3239
  * Codex stores MCP config in ~/.codex/config.toml using TOML format.
2919
3240
  * Format: [mcp_servers.server_name] sections
2920
3241
  */
2921
- declare function writeCodexMcpConfig(sandbox: SandboxInstance, servers: Record<string, McpServerConfig>): Promise<void>;
3242
+ declare function writeCodexMcpConfig(sandbox: SandboxInstance, servers: Record<string, McpServerConfig>, homeDir?: string): Promise<void>;
2922
3243
 
2923
3244
  /**
2924
3245
  * MCP Configuration Module
@@ -2938,7 +3259,7 @@ declare function writeCodexMcpConfig(sandbox: SandboxInstance, servers: Record<s
2938
3259
  * - Droid: JSON to ${workingDir}/.factory/mcp.json
2939
3260
  * - OpenCode: JSON to ${workingDir}/opencode.json (mcp key)
2940
3261
  */
2941
- declare function writeMcpConfig(agentType: AgentType, sandbox: SandboxInstance, workingDir: string, servers: Record<string, McpServerConfig>): Promise<void>;
3262
+ declare function writeMcpConfig(agentType: AgentType, sandbox: SandboxInstance, workingDir: string, servers: Record<string, McpServerConfig>, homeDir?: string): Promise<void>;
2942
3263
 
2943
3264
  /**
2944
3265
  * Prompt Templates
@@ -3086,8 +3407,6 @@ declare function saveLocalDir(localPath: string, files: FileMap): void;
3086
3407
  *
3087
3408
  * Provides durable persistence for agent workspaces beyond sandbox lifetime.
3088
3409
  * Supports BYOK (user's S3 bucket) and Gateway (Evolve-managed) modes.
3089
- *
3090
- * Evidence: storage-checkpointing plan v2.2
3091
3410
  */
3092
3411
 
3093
3412
  /**
@@ -3206,4 +3525,200 @@ interface SessionsClient {
3206
3525
  */
3207
3526
  declare function sessions(config?: SessionsConfig): SessionsClient;
3208
3527
 
3209
- export { AGENT_REGISTRY, AGENT_TYPES, type ActionbookBrowserConfig, Agent, type AgentBrowserConfig, type AgentConfig, type AgentOptions, type AgentOverride, type AgentParser, type AgentPluginConfig, type AgentRegistryEntry, type AgentResponse, type AgentRuntimeState, type AgentType, BROWSER_ACTIONBOOK_PROMPT, BROWSER_LOGIN_MCP_SERVER_NAME, type BaseMeta, type BestOfConfig, type BestOfParams, type BestOfResult, type BrowserConfig, type BrowserCredentialCreateInput, type BrowserCredentialDeleteInput, type BrowserCredentialListOptions, type BrowserCredentialMetadata, type BrowserCredentialScopeEntry, BrowserCredentialsClient, type BrowserCredentialsClientConfig, type BrowserCredentialsConfig, type BrowserProfileDeleteInput, type BrowserProfileMetadata, BrowserProfilesClient, type BrowserProfilesClientConfig, type BrowserProvider, type BrowserReplay, type BrowserReplayOptions, type BrowserRuntimeInfo, type CandidateCompleteEvent, type CheckpointInfo, type CodexAgentPluginConfig, type DefaultBrowserConfig, type DownloadCheckpointOptions, type DownloadFilesOptions, type DownloadSessionOptions, type EmitOption, type EventHandler, type EventName, Evolve, type EvolveConfig, type EvolveEvents, type ExecuteCommandOptions, type FileMap, type FilterConfig, type FilterParams, type GeminiAgentPluginConfig, type GetEventsOptions, type IndexedMeta, type IntegrationAccount, type IntegrationAccountDeleteParams, type IntegrationAccountDeleteResult, type IntegrationAccountListParams, type IntegrationAccountUpdateParams, type IntegrationAccountUpdateResult, type IntegrationAuthParams, type IntegrationAuthResult, type IntegrationToolsFilter, type IntegrationsConfig, type IntegrationsSetup, type ItemInput, type ItemRetryEvent, JUDGE_PROMPT, type JsonSchema, type JudgeCompleteEvent, type JudgeDecision, type JudgeMeta, type LifecycleEvent, type LifecycleReason, type ListSessionsOptions, type ManagedBrowserProvider, type MapConfig, type MapParams, type MarketplaceAgentPluginConfig, 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 RunCost, 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 SessionCost, type SessionEvent, type SessionInfo, type SessionPage, type SessionStatus, type SessionsClient, type SessionsConfig, type SkillName, type SkillsConfig, type StepCompleteEvent, type StepErrorEvent, type StepEvent, type StepResult, type StepStartEvent, type StorageClient, type StorageConfig, type StreamCallbacks, Swarm, type SwarmConfig, type SwarmResult, SwarmResultList, TerminalPipeline, 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, browserCredentials, browserProfiles, buildWorkerSystemPrompt, createAgentParser, createClaudeParser, createCodexParser, createDroidParser, createGeminiParser, executeWithRetry, expandPath, getAgentConfig, getMcpSettingsDir, getMcpSettingsPath, isValidAgentType, isZodSchema, jsonSchemaToString, parseNdjsonLine, parseNdjsonOutput, parseQwenOutput, readLocalDir, resolveStorageConfig, saveLocalDir, sessions, storage, writeClaudeMcpConfig, writeCodexMcpConfig, writeDroidGatewaySettings, writeDroidMcpConfig, writeGeminiMcpConfig, writeMcpConfig, writeQwenMcpConfig, zodSchemaToJson };
3528
+ /**
3529
+ * A typed failure from the hosted evals API.
3530
+ *
3531
+ * `message` is the server's own product sentence and `code` is the stable
3532
+ * machine-readable identifier, so callers branch on codes and never on English.
3533
+ * `code` is typed as the closed HostedErrorCode union (widened to string for
3534
+ * forward compatibility with a newer server), which is what makes a typo like
3535
+ * `insufficient_creidts` a compile error instead of a branch that never runs.
3536
+ *
3537
+ * `param` and `details` are the machine-readable half of the refusal:
3538
+ *
3539
+ * catch (err) {
3540
+ * if (err instanceof EvolveApiError && err.code === "provider_unsupported") {
3541
+ * // every refused task WITH its reason — not a sentence to regex
3542
+ * const refused = err.details?.refusedTasks as { taskKey: string }[];
3543
+ * }
3544
+ * }
3545
+ *
3546
+ * The server truncates the MESSAGE when a list is long and never truncates
3547
+ * `details`, so the data is always complete even when the sentence says
3548
+ * "and 8 more".
3549
+ */
3550
+ declare class EvolveApiError extends Error {
3551
+ /** HTTP status of the failed response */
3552
+ readonly status: number;
3553
+ /** Stable snake_case error code from the API ("unknown_error" when absent) */
3554
+ readonly code: HostedErrorCode | "unknown_error" | (string & {});
3555
+ /**
3556
+ * The input field this refusal is about — a body path ("agents[0].harness"),
3557
+ * a query parameter ("limit"), or a multipart part name ("runCommand").
3558
+ * Undefined when the failure is not about a particular field.
3559
+ */
3560
+ readonly param?: string;
3561
+ /** The complete machine-readable data behind the message. Never truncated. */
3562
+ readonly details?: Record<string, unknown>;
3563
+ /**
3564
+ * Seconds to wait before retrying (429/503). Read from the body first and the
3565
+ * Retry-After header second, because a browser fetch cannot always see the
3566
+ * header on a cross-origin response.
3567
+ */
3568
+ readonly retryAfterSec?: number;
3569
+ /** Server-side id for this failure; the string to quote in a support thread. */
3570
+ readonly requestId?: string;
3571
+ constructor(status: number, code: string, message: string, extra?: {
3572
+ param?: string;
3573
+ details?: Record<string, unknown>;
3574
+ retryAfterSec?: number;
3575
+ requestId?: string;
3576
+ });
3577
+ /** True when this code is one this SDK version knows about. */
3578
+ isKnownCode(): boolean;
3579
+ }
3580
+ /**
3581
+ * Thrown by benchmarks().getActive() when the named benchmark exists but has no
3582
+ * active version, so there is no runnable version to resolve. Use get() to
3583
+ * inspect a benchmark that may not have an active version yet.
3584
+ */
3585
+ declare class NoActiveVersionError extends Error {
3586
+ /** The benchmark name that had no active version */
3587
+ readonly benchmark: string;
3588
+ constructor(benchmark: string);
3589
+ }
3590
+ /**
3591
+ * Create a BenchmarksClient for the shared benchmark catalog.
3592
+ *
3593
+ * Requires EVOLVE_API_KEY (or { apiKey } in config).
3594
+ *
3595
+ * @example
3596
+ * ```ts
3597
+ * import { benchmarks } from "@evolvingmachines/sdk";
3598
+ *
3599
+ * const b = benchmarks();
3600
+ * const catalog = await b.list();
3601
+ * const deepSwe = await b.get("deep-swe@1.1");
3602
+ * ```
3603
+ */
3604
+ declare function benchmarks(config?: HostedClientConfig): BenchmarksClient;
3605
+ /**
3606
+ * Create a CustomHarnessesClient for the caller's own private harnesses.
3607
+ *
3608
+ * Register a harness once, then name it in `agents[].harness` exactly
3609
+ * like a built-in. Requires EVOLVE_API_KEY (or { apiKey } in config).
3610
+ *
3611
+ * @example
3612
+ * ```ts
3613
+ * import { customHarnesses, jobs } from "@evolvingmachines/sdk";
3614
+ *
3615
+ * const harnesses = customHarnesses();
3616
+ * await harnesses.create({
3617
+ * name: "acme-cli",
3618
+ * installScript: "curl -fsSL https://acme.dev/install.sh | sh",
3619
+ * runCommand: "acme-cli --headless",
3620
+ * });
3621
+ *
3622
+ * await jobs().run({
3623
+ * benchmark: "deep-swe",
3624
+ * agents: [{ harness: "acme-cli", model: "gpt-5.5" }],
3625
+ * maxTrialSpendUsd: 25,
3626
+ * });
3627
+ * ```
3628
+ */
3629
+ declare function customHarnesses(config?: HostedClientConfig): CustomHarnessesClient;
3630
+ /**
3631
+ * Create a JobsClient for hosted jobs.
3632
+ *
3633
+ * Requires EVOLVE_API_KEY (or { apiKey } in config).
3634
+ *
3635
+ * @example
3636
+ * ```ts
3637
+ * import { jobs } from "@evolvingmachines/sdk";
3638
+ *
3639
+ * const client = jobs();
3640
+ * // benchmark: bare name = active version; "name@version" pins a version
3641
+ * const job = await client.run({
3642
+ * benchmark: "deep-swe",
3643
+ * agents: [{ harness: "codex", model: "gpt-5.5" }],
3644
+ * runsPerTask: 1,
3645
+ * concurrency: 4,
3646
+ * maxTrialSpendUsd: 25,
3647
+ * });
3648
+ * const final = await client.watch(job.id, {
3649
+ * onEvent: (event) => console.log(event.type, event.data),
3650
+ * });
3651
+ * ```
3652
+ */
3653
+ declare function jobs(config?: HostedClientConfig): JobsClient;
3654
+ /**
3655
+ * The hosted surface, configured once.
3656
+ *
3657
+ * The three factories are the right decomposition — a benchmark catalog, your
3658
+ * own harness registrations, and jobs are three genuinely different lifetimes —
3659
+ * but they made you say the same thing three times:
3660
+ *
3661
+ * const b = benchmarks({ apiKey, baseUrl });
3662
+ * const h = customHarnesses({ apiKey, baseUrl }); // again
3663
+ * const j = jobs({ apiKey, baseUrl }); // and again
3664
+ *
3665
+ * and any one of those going out of sync with the others is a bug that looks
3666
+ * like a permissions problem. One door, one config:
3667
+ *
3668
+ * const evolve = hosted({ apiKey });
3669
+ * const catalog = await evolve.benchmarks.list();
3670
+ * const job = await evolve.jobs.run({ ... });
3671
+ *
3672
+ * The three clients are built LAZILY, on first access. That matters because
3673
+ * they throw when no API key is present, and `meta()` needs no key at all — so
3674
+ * `hosted().meta()` works on a signed-out page, while `hosted().jobs` still
3675
+ * fails loudly and immediately the moment you reach for something that does
3676
+ * need credentials.
3677
+ */
3678
+ interface HostedEvolve {
3679
+ /** The benchmark catalog: list, get, import, delete. */
3680
+ readonly benchmarks: BenchmarksClient;
3681
+ /** Your own bring-your-own harness registrations. */
3682
+ readonly customHarnesses: CustomHarnessesClient;
3683
+ /** Jobs: run, watch, compare, regrade, export. */
3684
+ readonly jobs: JobsClient;
3685
+ /**
3686
+ * The capability document — every harness, provider, status, limit, and
3687
+ * error code the platform supports. Public: no API key required.
3688
+ *
3689
+ * Fetch it once and stop hardcoding. It is what tells you the legal harness
3690
+ * names without having to send a bad one and read the 400.
3691
+ */
3692
+ meta(): Promise<CapabilityDocument>;
3693
+ }
3694
+ /**
3695
+ * Open the hosted surface with one configuration.
3696
+ *
3697
+ * Named `hosted()` rather than `evolve()` deliberately: `Evolve` is already the
3698
+ * local-sandbox SDK class in this same package, and two exports one shift key
3699
+ * apart that do completely different things is a trap. `hosted()` says which
3700
+ * half of the SDK you are reaching for.
3701
+ *
3702
+ * @example
3703
+ * ```ts
3704
+ * import { hosted } from "@evolvingmachines/sdk";
3705
+ *
3706
+ * const evolve = hosted(); // EVOLVE_API_KEY from env
3707
+ * const { harnesses } = await evolve.meta(); // no key needed for this one
3708
+ * const job = await evolve.jobs.run({
3709
+ * benchmark: "deep-swe",
3710
+ * agents: [{ harness: "claude", model: harnesses[0].defaultModel! }],
3711
+ * });
3712
+ * ```
3713
+ */
3714
+ declare function hosted(config?: HostedClientConfig): HostedEvolve;
3715
+ /**
3716
+ * Fetch the capability document.
3717
+ *
3718
+ * NO API KEY. The document is the same information the docs publish, and
3719
+ * requiring credentials would mean a signed-out page could not populate its own
3720
+ * harness picker — so this is the one hosted call that takes only a base URL.
3721
+ */
3722
+ declare function meta(config?: HostedClientConfig): Promise<CapabilityDocument>;
3723
+
3724
+ export { AGENT_REGISTRY, AGENT_TYPES, type ActionbookBrowserConfig, Agent, type AgentBrowserConfig, type AgentConfig, type AgentError, type AgentOptions, type AgentOverride, type AgentParser, type AgentPluginConfig, type AgentRegistryEntry, type AgentResponse, type AgentRuntimeState, type AgentType, BROWSER_ACTIONBOOK_PROMPT, BROWSER_LOGIN_MCP_SERVER_NAME, type BaseMeta, BenchmarksClient, type BestOfConfig, type BestOfParams, type BestOfResult, type BrowserConfig, type BrowserCredentialCreateInput, type BrowserCredentialDeleteInput, type BrowserCredentialListOptions, type BrowserCredentialMetadata, type BrowserCredentialScopeEntry, BrowserCredentialsClient, type BrowserCredentialsClientConfig, type BrowserCredentialsConfig, type BrowserProfileDeleteInput, type BrowserProfileMetadata, BrowserProfilesClient, type BrowserProfilesClientConfig, type BrowserProvider, type BrowserReplay, type BrowserReplayOptions, type BrowserRuntimeInfo, type CandidateCompleteEvent, CapabilityDocument, type CheckpointInfo, type CodexAgentPluginConfig, CustomHarnessesClient, type DefaultBrowserConfig, type DownloadCheckpointOptions, type DownloadFilesOptions, type DownloadSessionOptions, type EmitOption, type EventHandler, type EventName, Evolve, EvolveApiError, type EvolveConfig, type EvolveEvents, type ExecuteCommandOptions, type ExternalGatewayConfig, type FileMap, type FilterConfig, type FilterParams, type GeminiAgentPluginConfig, type GetEventsOptions, HostedClientConfig, HostedErrorCode, type HostedEvolve, type IndexedMeta, type IntegrationAccount, type IntegrationAccountDeleteParams, type IntegrationAccountDeleteResult, type IntegrationAccountListParams, type IntegrationAccountUpdateParams, type IntegrationAccountUpdateResult, type IntegrationAuthParams, type IntegrationAuthResult, type IntegrationToolsFilter, type IntegrationsConfig, type IntegrationsSetup, type ItemInput, type ItemRetryEvent, JUDGE_PROMPT, JobsClient, type JsonSchema, type JudgeCompleteEvent, type JudgeDecision, type JudgeMeta, type LifecycleEvent, type LifecycleReason, type ListSessionsOptions, MANAGED_SANDBOX_PROVIDERS, type ManagedBrowserProvider, type ManagedSandboxProviderName, type ManagedSecretMetadata, type ManagedSecretRef, type ManagedSecretsClient, type ManagedSecretsClientConfig, type MapConfig, type MapParams, type MarketplaceAgentPluginConfig, type McpConfigInfo, type McpServerConfig, type ModelInfo, NoActiveVersionError, 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 RunCost, type RunOptions, SCHEMA_PROMPT, SWARM_RESULT_BRAND, SYSTEM_PROMPT, type SandboxCommandHandle, type SandboxCommandResult, type SandboxCommands, type SandboxCreateOptions, type SandboxFiles, type SandboxInstance, type SandboxLifecycleState, type SandboxNetworkPolicy, type SandboxProvider, type SandboxRunOptions, type SandboxSpawnOptions, type SchemaValidationOptions, Semaphore, type SessionCost, type SessionEvent, type SessionInfo, type SessionPage, type SessionStatus, type SessionUpdate, type SessionsClient, type SessionsConfig, type SkillName, type SkillsConfig, type StepCompleteEvent, type StepErrorEvent, type StepEvent, type StepResult, type StepStartEvent, type StorageClient, type StorageConfig, type StreamCallbacks, Swarm, type SwarmConfig, type SwarmResult, SwarmResultList, TerminalPipeline, 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, benchmarks, browserCredentials, browserProfiles, buildWorkerSystemPrompt, createAgentParser, createClaudeParser, createCodexParser, createDroidParser, createGeminiParser, customHarnesses, executeWithRetry, expandPath, getAgentConfig, getMcpSettingsDir, getMcpSettingsPath, hosted, isAgentWorkUpdate, isValidAgentType, isZodSchema, jobs, jsonSchemaToString, managedSandbox, managedSecrets, meta, parseNdjsonLine, parseNdjsonOutput, parseQwenOutput, readLocalDir, resolveStorageConfig, saveLocalDir, sessions, storage, writeClaudeMcpConfig, writeCodexMcpConfig, writeDroidGatewaySettings, writeDroidMcpConfig, writeGeminiMcpConfig, writeMcpConfig, writeQwenMcpConfig, zodSchemaToJson };