@evolvingmachines/sdk 0.0.50 → 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 */
@@ -589,6 +997,11 @@ interface AgentOptions {
589
997
  apiKey: string;
590
998
  dashboardUrl?: string;
591
999
  };
1000
+ /** Evolve-managed provider routing tokens for dashboard-stored BYOK provider keys. */
1001
+ providerRouting?: {
1002
+ apiKey: string;
1003
+ dashboardUrl?: string;
1004
+ };
592
1005
  /** Plugins/extensions to install in the sandbox user profile before first run */
593
1006
  plugins?: AgentPluginConfig[];
594
1007
  /** Skills to enable (e.g., ["pdf", "dev-browser"]) */
@@ -701,7 +1114,7 @@ interface RunCost {
701
1114
  runId: string;
702
1115
  /** 1-based chronological position in session */
703
1116
  index: number;
704
- /** Total cost in USD (includes platform margin) */
1117
+ /** Total cost in USD as billed to your Evolve account */
705
1118
  cost: number;
706
1119
  /** Token counts */
707
1120
  tokens: {
@@ -981,8 +1394,6 @@ interface IntegrationAccountDeleteResult {
981
1394
  *
982
1395
  * Single Agent class that uses registry lookup for agent-specific behavior.
983
1396
  * All agent differences are data (in registry), not code.
984
- *
985
- * Evidence: sdk-rewrite-v3.md Design Decisions section
986
1397
  */
987
1398
 
988
1399
  /**
@@ -997,9 +1408,10 @@ declare class Agent {
997
1408
  private sandbox?;
998
1409
  private hasRun;
999
1410
  private readonly workingDir;
1411
+ private readonly homeDir;
1000
1412
  private lastRunTimestamp?;
1001
1413
  private readonly registry;
1002
- /** 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) */
1003
1415
  private sessionTag;
1004
1416
  /** Previous session tag — preserved across kill()/setSession() so cost queries still work */
1005
1417
  private previousSessionTag?;
@@ -1014,6 +1426,10 @@ declare class Agent {
1014
1426
  private agentState;
1015
1427
  private droidSessionId?;
1016
1428
  private managedBrowserSession?;
1429
+ private providerRuntimeToken?;
1430
+ private managedSecretRuntimeToken?;
1431
+ private managedSecretProxy?;
1432
+ private credentialsSealed;
1017
1433
  private readonly skills?;
1018
1434
  private readonly storage?;
1019
1435
  private lastCheckpointId?;
@@ -1038,12 +1454,43 @@ declare class Agent {
1038
1454
  */
1039
1455
  getSandbox(callbacks?: StreamCallbacks): Promise<SandboxInstance>;
1040
1456
  /**
1041
- * 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.
1470
+ */
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
1042
1480
  */
1043
1481
  private buildEnvironmentVariables;
1482
+ private buildSandboxCreateOptions;
1483
+ private validatedUserSecretsForEnvironment;
1044
1484
  private ensureManagedBrowserSession;
1485
+ private ensureProviderRuntimeToken;
1486
+ private bindProviderRuntimeToken;
1045
1487
  private setupManagedBrowser;
1046
1488
  private closeManagedBrowserSession;
1489
+ private closeProviderRuntimeToken;
1490
+ private ensureManagedSecretRuntimeToken;
1491
+ private bindManagedSecretRuntimeToken;
1492
+ private setupManagedSecretEgress;
1493
+ private closeManagedSecretRuntimeToken;
1047
1494
  /**
1048
1495
  * Build the inline gateway config JSON for agents using gatewayConfigEnv
1049
1496
  * (e.g., OpenCode OPENCODE_CONFIG_CONTENT). Centralizes the provider config
@@ -1056,6 +1503,14 @@ declare class Agent {
1056
1503
  * Source-verified: model.headers → provider.ts:1061 → llm.ts:221 → HTTP request.
1057
1504
  */
1058
1505
  private buildGatewayConfigJson;
1506
+ private activeProviderRuntimeToken;
1507
+ private requireActiveProviderRuntimeToken;
1508
+ private ensureSessionLogger;
1509
+ private flushSessionLoggerWithTimeout;
1510
+ private requiresPreRunDashboardIngest;
1511
+ private providerRuntimeHeaderUpdates;
1512
+ private shouldExposeProviderRuntimeTokenEnv;
1513
+ private buildProviderRuntimeProcessEnvs;
1059
1514
  /**
1060
1515
  * Build per-run env overrides for spend tracking.
1061
1516
  * Merges session + run headers into the custom headers env var,
@@ -1063,9 +1518,11 @@ declare class Agent {
1063
1518
  * Passed to spawn() so each .run() gets a unique run tag.
1064
1519
  */
1065
1520
  private buildRunEnvs;
1521
+ private writeCodexGatewayProviderConfig;
1066
1522
  private captureDroidSession;
1067
1523
  private extractDroidSessionId;
1068
1524
  private findDroidSessionId;
1525
+ private droidSessionStatePath;
1069
1526
  private loadDroidSessionState;
1070
1527
  private writeDroidSessionState;
1071
1528
  private resolveGatewayModel;
@@ -1074,7 +1531,9 @@ declare class Agent {
1074
1531
  * Agent-specific authentication setup
1075
1532
  */
1076
1533
  private setupAgentAuth;
1534
+ private writeGeminiGatewayAuthSettings;
1077
1535
  private setupAgentPlugins;
1536
+ private assertProviderRuntimeDoesNotExposeGatewayKey;
1078
1537
  /**
1079
1538
  * Setup workspace structure and files
1080
1539
  *
@@ -1111,6 +1570,16 @@ declare class Agent {
1111
1570
  * Execute arbitrary command in sandbox
1112
1571
  */
1113
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>;
1114
1583
  /**
1115
1584
  * Upload context files (to context/ folder)
1116
1585
  */
@@ -1119,6 +1588,24 @@ declare class Agent {
1119
1588
  * Upload files to working directory
1120
1589
  */
1121
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>;
1122
1609
  /**
1123
1610
  * Get output files from output/ folder with optional schema validation
1124
1611
  *
@@ -1181,7 +1668,7 @@ declare class Agent {
1181
1668
  /**
1182
1669
  * Get current session tag.
1183
1670
  * Returns null if no active session (before sandbox creation or after kill()).
1184
- * 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).
1185
1672
  */
1186
1673
  getSessionTag(): string | null;
1187
1674
  /**
@@ -1226,8 +1713,7 @@ declare class Agent {
1226
1713
  /**
1227
1714
  * Get cost breakdown for the current session (all runs).
1228
1715
  *
1229
- * Queries the dashboard API which proxies to LiteLLM spend logs.
1230
- * Cost data has ~60s latency due to gateway batch writes.
1716
+ * Cost data can lag live usage by about a minute.
1231
1717
  * Also works after kill() for the most recent session only.
1232
1718
  *
1233
1719
  * Requires gateway mode (EVOLVE_API_KEY).
@@ -1248,149 +1734,6 @@ declare class Agent {
1248
1734
  }): Promise<RunCost>;
1249
1735
  }
1250
1736
 
1251
- /**
1252
- * Claude JSONL → ACP-style events parser.
1253
- *
1254
- * Native schema source (@anthropic-ai/claude-agent-sdk):
1255
- * MANUS-API/KNOWLEDGE/claude-agent-sdk/cc_sdk_typescript.md
1256
- * (SDKMessage, SDKAssistantMessage, SDKPartialAssistantMessage, Tool Input/Output types)
1257
- *
1258
- * Conversion logic reference:
1259
- * MANUS-API/KNOWLEDGE/claude-code-acp/src/tools.ts
1260
- * (toolInfoFromToolUse, toolUpdateFromToolResult)
1261
- *
1262
- * ACP output schema:
1263
- * MANUS-API/KNOWLEDGE/acp-typescript-sdk/src/schema/types.gen.ts
1264
- */
1265
-
1266
- /**
1267
- * Create a Claude parser instance with its own isolated cache.
1268
- * Each Evolve instance should create its own parser for proper isolation.
1269
- */
1270
- declare function createClaudeParser(): (jsonLine: string) => OutputEvent[] | null;
1271
-
1272
- /**
1273
- * Codex JSONL → ACP-style events parser.
1274
- *
1275
- * Native schema: codex-rs/exec/src/exec_events.rs
1276
- * - ThreadEvent: thread.started, turn.started, turn.completed, item.started, item.updated, item.completed
1277
- * - ThreadItemDetails: AgentMessage, Reasoning, CommandExecution, FileChange, McpToolCall, WebSearch, TodoList, Error
1278
- *
1279
- * ACP output: acp-typescript-sdk/src/schema/types.gen.ts
1280
- * - SessionUpdate: agent_message_chunk, agent_thought_chunk, tool_call, tool_call_update, plan
1281
- *
1282
- * Event mapping:
1283
- * reasoning → agent_thought_chunk (exec_events.rs:134 ReasoningItem { text })
1284
- * agent_message → agent_message_chunk (exec_events.rs:129 AgentMessageItem { text })
1285
- * mcp_tool_call → tool_call/update (exec_events.rs:215 McpToolCallItem)
1286
- * command_execution → tool_call/update (exec_events.rs:151 CommandExecutionItem)
1287
- * file_change → tool_call (exec_events.rs:176 FileChangeItem)
1288
- * todo_list → plan (exec_events.rs:245 TodoListItem { items: TodoItem[] })
1289
- * web_search → tool_call (exec_events.rs:227 WebSearchItem { query })
1290
- */
1291
-
1292
- /**
1293
- * Create a Codex parser instance.
1294
- */
1295
- declare function createCodexParser(): (jsonLine: string) => OutputEvent[] | null;
1296
-
1297
- /**
1298
- * Droid exec parser.
1299
- *
1300
- * Supports the documented headless `--output-format stream-json` lines and the
1301
- * raw `stream-jsonrpc` notification envelope used by Droid's low-level SDK.
1302
- */
1303
-
1304
- declare function createDroidParser(): (jsonLine: string) => OutputEvent[] | null;
1305
-
1306
- /**
1307
- * Gemini JSONL → ACP-style events parser.
1308
- *
1309
- * Native schema (gemini --output-format stream-json):
1310
- * gemini-cli/packages/core/src/output/types.ts
1311
- *
1312
- * Gemini events (types.ts:29-36 JsonStreamEventType):
1313
- * - "init" → types.ts:43-47 InitEvent { session_id, model }
1314
- * - "message" → types.ts:49-54 MessageEvent { role, content, delta? }
1315
- * - "tool_use" → types.ts:56-61 ToolUseEvent { tool_name, tool_id, parameters }
1316
- * - "tool_result" → types.ts:63-72 ToolResultEvent { tool_id, status, output?, error? }
1317
- * - "error" → types.ts:74-78 ErrorEvent { severity, message }
1318
- * - "result" → types.ts:91-99 ResultEvent { status, error?, stats? }
1319
- *
1320
- * ACP output: acp-typescript-sdk/src/schema/types.gen.ts:2449-2464
1321
- */
1322
-
1323
- /**
1324
- * Create a Gemini parser instance.
1325
- */
1326
- declare function createGeminiParser(): (jsonLine: string) => OutputEvent[] | null;
1327
-
1328
- /**
1329
- * Qwen NDJSON → ACP-style events parser.
1330
- *
1331
- * Native schema: KNOWLEDGE/qwen-code/packages/sdk-typescript/src/types/protocol.ts
1332
- * ACP schema: KNOWLEDGE/acp-typescript-sdk/src/schema/types.gen.ts
1333
- *
1334
- * Qwen NDJSON message types (protocol.ts:428-433):
1335
- * - type: "assistant" → SDKAssistantMessage (protocol.ts:102-108)
1336
- * - type: "stream_event" → SDKPartialAssistantMessage (protocol.ts:225-231)
1337
- * - type: "user" → SDKUserMessage (protocol.ts:93-100)
1338
- * - type: "system" → SDKSystemMessage (skipped)
1339
- * - type: "result" → SDKResultMessage (skipped)
1340
- *
1341
- * ContentBlock types (protocol.ts:72-76):
1342
- * - TextBlock (protocol.ts:43-48): { type: 'text', text: string }
1343
- * - ThinkingBlock (protocol.ts:49-54): { type: 'thinking', thinking: string }
1344
- * - ToolUseBlock (protocol.ts:56-62): { type: 'tool_use', id, name, input }
1345
- * - ToolResultBlock (protocol.ts:64-70): { type: 'tool_result', tool_use_id, content?, is_error? }
1346
- *
1347
- * StreamEvent types (protocol.ts:218-223):
1348
- * - message_start, content_block_start, content_block_delta, content_block_stop, message_stop
1349
- */
1350
-
1351
- /**
1352
- * Stateless parser function (creates new parser per call).
1353
- * Use createQwenParser() for stateful streaming parsing.
1354
- *
1355
- * @param line - Single line of NDJSON from qwen CLI
1356
- * @returns Array of OutputEvent objects, or null if line couldn't be parsed
1357
- */
1358
- declare function parseQwenOutput(line: string): OutputEvent[] | null;
1359
-
1360
- /**
1361
- * Unified Parser Entry Point
1362
- *
1363
- * Routes NDJSON lines to the appropriate agent-specific parser.
1364
- * Simple line-based parsing - no buffering needed since CLIs output complete JSON per line.
1365
- */
1366
-
1367
- /** Parser function type */
1368
- type AgentParser = (jsonLine: string) => OutputEvent[] | null;
1369
- /**
1370
- * Create a parser instance for the given agent type.
1371
- * Each Evolve instance should create its own parser for proper isolation.
1372
- *
1373
- * @param agentType - The agent type to create a parser for
1374
- * @returns Parser function that takes NDJSON lines and returns OutputEvents
1375
- */
1376
- declare function createAgentParser(agentType: AgentType): AgentParser;
1377
- /**
1378
- * Parse a single NDJSON line from any agent (creates new parser per call - use createAgentParser for efficiency)
1379
- *
1380
- * @param agentType - The agent type to parse for
1381
- * @param line - Single line of NDJSON output
1382
- * @returns Array of OutputEvent objects, or null if line couldn't be parsed
1383
- */
1384
- declare function parseNdjsonLine(agentType: AgentType, line: string): OutputEvent[] | null;
1385
- /**
1386
- * Parse multiple NDJSON lines (convenience wrapper)
1387
- *
1388
- * @param agentType - The agent type to parse for
1389
- * @param output - Multi-line NDJSON output
1390
- * @returns Array of all parsed OutputEvent objects
1391
- */
1392
- declare function parseNdjsonOutput(agentType: AgentType, output: string): OutputEvent[];
1393
-
1394
1737
  declare const BROWSER_LOGIN_MCP_SERVER_NAME = "browser-login";
1395
1738
  interface BrowserCredentialMetadata {
1396
1739
  id: string;
@@ -1472,52 +1815,6 @@ declare class BrowserProfilesClient {
1472
1815
  }
1473
1816
  declare function browserProfiles(config?: BrowserProfilesClientConfig): BrowserProfilesClient;
1474
1817
 
1475
- /**
1476
- * Evolve events
1477
- *
1478
- * Runtime streams:
1479
- * - stdout: Raw NDJSON lines
1480
- * - stderr: Process stderr
1481
- * - content: Parsed OutputEvent
1482
- * - lifecycle: Sandbox/agent lifecycle transitions
1483
- */
1484
- interface EvolveEvents {
1485
- stdout: (chunk: string) => void;
1486
- stderr: (chunk: string) => void;
1487
- content: (event: OutputEvent) => void;
1488
- lifecycle: (event: LifecycleEvent) => void;
1489
- }
1490
- interface EvolveConfig {
1491
- agent?: AgentConfig;
1492
- sandbox?: SandboxProvider;
1493
- workingDirectory?: string;
1494
- workspaceMode?: WorkspaceMode;
1495
- secrets?: Record<string, string>;
1496
- sandboxId?: string;
1497
- systemPrompt?: string;
1498
- context?: FileMap;
1499
- files?: FileMap;
1500
- mcpServers?: Record<string, McpServerConfig>;
1501
- /** Browser automation provider to enable explicitly */
1502
- browser?: BrowserConfig;
1503
- /** Browser login MCP setup for managed remote agent-browser runs */
1504
- browserCredentials?: BrowserCredentialsConfig;
1505
- /** Agent plugins/extensions to install before first run */
1506
- plugins?: AgentPluginConfig[];
1507
- /** Skills to enable (e.g., ["pdf", "dev-browser"]) */
1508
- skills?: SkillName[];
1509
- /** Schema for structured output (Zod or JSON Schema, auto-detected) */
1510
- schema?: z.ZodType<unknown> | JsonSchema;
1511
- /** Validation options for JSON Schema (ignored for Zod) */
1512
- schemaOptions?: SchemaValidationOptions;
1513
- sessionTagPrefix?: string;
1514
- /** Observability metadata for trace grouping (generic key-value, domain-agnostic) */
1515
- observability?: Record<string, unknown>;
1516
- /** Managed integrations config */
1517
- integrations?: IntegrationsSetup;
1518
- /** Storage configuration for checkpointing */
1519
- storage?: StorageConfig;
1520
- }
1521
1818
  /**
1522
1819
  * Evolve orchestrator with builder pattern
1523
1820
  *
@@ -1551,6 +1848,11 @@ declare class Evolve extends EventEmitter {
1551
1848
  * Configure sandbox provider
1552
1849
  */
1553
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;
1554
1856
  /**
1555
1857
  * Set working directory path
1556
1858
  */
@@ -1559,12 +1861,19 @@ declare class Evolve extends EventEmitter {
1559
1861
  * Set workspace mode
1560
1862
  * - "knowledge": Creates context/, scripts/, temp/, output/ folders
1561
1863
  * - "swe": Same as knowledge + repo/ folder for code repositories
1864
+ * - "task": Leaves the task-owned working directory untouched
1562
1865
  */
1563
1866
  withWorkspaceMode(mode: WorkspaceMode): this;
1564
1867
  /**
1565
1868
  * Add environment secrets
1566
1869
  */
1567
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;
1568
1877
  /**
1569
1878
  * Connect to existing session
1570
1879
  */
@@ -1693,6 +2002,8 @@ declare class Evolve extends EventEmitter {
1693
2002
  static browserCredentials: typeof browserCredentials;
1694
2003
  /** Static browser profile client for listing and deleting reusable browser profiles. */
1695
2004
  static browserProfiles: typeof browserProfiles;
2005
+ /** Static managed secrets client for listing Dashboard-stored secret metadata. */
2006
+ static managedSecrets: typeof managedSecrets;
1696
2007
  /**
1697
2008
  * Initialize agent on first use
1698
2009
  */
@@ -1721,6 +2032,21 @@ declare class Evolve extends EventEmitter {
1721
2032
  timeoutMs?: number;
1722
2033
  background?: boolean;
1723
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>;
1724
2050
  /**
1725
2051
  * Interrupt active process without killing sandbox.
1726
2052
  */
@@ -1733,6 +2059,15 @@ declare class Evolve extends EventEmitter {
1733
2059
  * Upload files to workspace (runtime - immediate upload)
1734
2060
  */
1735
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>;
1736
2071
  /**
1737
2072
  * Get output files from output/ folder with optional schema validation
1738
2073
  *
@@ -1924,7 +2259,7 @@ interface SwarmConfig {
1924
2259
  /** Per-worker timeout in ms (default: 1 hour) */
1925
2260
  timeoutMs?: number;
1926
2261
  /** Workspace mode (default: SDK default 'knowledge') */
1927
- workspaceMode?: WorkspaceMode;
2262
+ workspaceMode?: Exclude<WorkspaceMode, "task">;
1928
2263
  /** Default retry configuration for all operations (per-operation config takes precedence) */
1929
2264
  retry?: RetryConfig;
1930
2265
  /** Default MCP servers for all operations (per-operation config takes precedence) */
@@ -2668,176 +3003,179 @@ declare class TerminalPipeline<T> extends Pipeline<T> {
2668
3003
  }
2669
3004
 
2670
3005
  /**
2671
- * Agent Registry
3006
+ * Sandbox providers the Dashboard runs on the customer's behalf.
2672
3007
  *
2673
- * Single source of truth for agent-specific behavior.
2674
- * 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
2675
3018
  *
2676
- * Evidence: sdk-rewrite-v3.md Agent Registry section
3019
+ * Resolves default sandbox provider from environment.
3020
+ * Supports E2B, Daytona, and Modal providers.
2677
3021
  */
2678
3022
 
2679
- /** Model configuration */
2680
- interface ModelInfo {
2681
- /** Model alias (short name used with --model) */
2682
- alias: string;
2683
- /** Full model ID */
2684
- modelId: string;
2685
- /** What this model is best for */
2686
- description: string;
2687
- }
2688
- /** MCP configuration for an agent */
2689
- interface McpConfigInfo {
2690
- /** Settings directory (e.g., "~/.claude") */
2691
- settingsDir: string;
2692
- /** Config filename (e.g., "settings.json" or "config.toml") */
2693
- filename: string;
2694
- /** Config format */
2695
- format: "json" | "toml";
2696
- /** Whether to use workingDir for project-level config (Claude only) */
2697
- projectConfig?: boolean;
2698
- }
2699
- /** Options for building agent commands */
2700
- interface BuildCommandOptions {
2701
- prompt: string;
2702
- model: string;
2703
- isResume: boolean;
2704
- sessionId?: string;
2705
- reasoningEffort?: string;
2706
- isDirectMode?: boolean;
2707
- /** Skills enabled for this run */
2708
- skills?: string[];
2709
- }
2710
- interface AgentRegistryEntry {
2711
- /** Sandbox image/template identifier (provider maps to its own concept) */
2712
- image: string;
2713
- /** Environment variable name for API key */
2714
- apiKeyEnv: string;
2715
- /** Environment variable name for OAuth (file path or token depending on agent) */
2716
- oauthEnv?: string;
2717
- /** OAuth credentials filename (e.g., "auth.json" for Codex, "oauth_creds.json" for Gemini) */
2718
- oauthFileName?: string;
2719
- /** Environment variable to set when OAuth is active (e.g., GOOGLE_GENAI_USE_GCA=true for Gemini) */
2720
- oauthActivationEnv?: {
2721
- key: string;
2722
- value: string;
2723
- };
2724
- /** Environment variable name for base URL, if this CLI supports one */
2725
- baseUrlEnv?: string;
2726
- /** Default model alias */
2727
- defaultModel: string;
2728
- /** Available models for this agent */
2729
- models: ModelInfo[];
2730
- /** System prompt filename (e.g., "CLAUDE.md") */
2731
- systemPromptFile: string;
2732
- /** MCP configuration */
2733
- mcpConfig: McpConfigInfo;
2734
- /** Build the CLI command for this agent */
2735
- buildCommand: (opts: BuildCommandOptions) => string;
2736
- /** Extra setup step (e.g., codex login) */
2737
- setupCommand?: string;
2738
- /** Gateway path prefix for CLIs that use a provider-native passthrough endpoint */
2739
- gatewayPath?: string;
2740
- /** Default base URL for direct mode (only needed if provider requires specific endpoint, e.g., Qwen → Dashscope) */
2741
- defaultBaseUrl?: string;
2742
- /** Available beta headers for this agent (for reference) */
2743
- availableBetas?: Record<string, string>;
2744
- /** Skills configuration for this agent */
2745
- skillsConfig: SkillsConfig;
2746
- /** Multi-provider env mapping: model prefix → keyEnv (for CLIs like OpenCode that resolve provider from model string) */
2747
- providerEnvMap?: Record<string, {
2748
- keyEnv: string;
2749
- }>;
2750
- /** Env var for inline config (e.g., OPENCODE_CONFIG_CONTENT) — used in gateway mode to set provider base URLs */
2751
- gatewayConfigEnv?: string;
2752
- /** Gateway-only model aliases for CLIs whose native model IDs differ from LiteLLM route names */
2753
- gatewayModelAliases?: Record<string, string>;
2754
- /** Direct-mode model aliases for CLIs whose public model names differ from CLI-native model IDs */
2755
- directModelAliases?: Record<string, string>;
2756
- /** Do not set provider API key env in gateway mode (used when routing via generated settings instead) */
2757
- skipApiKeyEnvInGateway?: boolean;
2758
- /** Dedicated Droid settings file for Evolve gateway custom model routing */
2759
- droidGatewaySettings?: {
2760
- settingsPath: string;
2761
- displayName: string;
2762
- provider: "generic-chat-completion-api" | "openai" | "anthropic";
2763
- maxOutputTokens?: number;
2764
- };
2765
- /** Environment variable that CLI reads for custom outbound HTTP headers */
2766
- customHeadersEnv?: string;
2767
- /** Format for custom headers env var: "newline" (Claude) or "comma" (Gemini). Default: "newline" */
2768
- customHeadersFormat?: "newline" | "comma";
2769
- /**
2770
- * Per-env-var spend tracking for CLIs that support env_http_headers in config
2771
- * (e.g., Codex TOML). Maps LiteLLM header names to env var names that the CLI
2772
- * reads at request time. Alternative to customHeadersEnv for agents without a
2773
- * single custom-headers env var.
2774
- */
2775
- spendTrackingEnvs?: {
2776
- /** Env var name for x-litellm-customer-id value */
2777
- sessionTagEnv: string;
2778
- /** Env var name for x-litellm-tags value */
2779
- runTagEnv: string;
2780
- };
2781
- /**
2782
- * Config-file-based spend tracking for CLIs that read custom headers from a
2783
- * JSON settings file (e.g., Qwen settings.json → model.generationConfig.customHeaders).
2784
- * The SDK writes headers to this file before each run.
2785
- * Source-verified: Qwen reads customHeaders from settings.json, not env vars.
2786
- */
2787
- spendTrackingJsonConfig?: {
2788
- /** JSON path to the customHeaders object (dot-separated) */
2789
- headersPath: string;
2790
- };
2791
- /**
2792
- * TOML provider-based spend tracking for CLIs that read custom_headers from a
2793
- * provider entry in config.toml (e.g., Kimi Code).
2794
- * The SDK writes a provider+model entry with custom_headers before each run.
2795
- * Source-verified: Kimi Code reads custom_headers from
2796
- * providers[name].custom_headers in ~/.kimi-code/config.toml.
2797
- */
2798
- spendTrackingTomlProvider?: {
2799
- /** Config file path (e.g., "~/.kimi-code/config.toml") */
2800
- configPath: string;
2801
- /** Provider name in config (e.g., "evolve-gateway") */
2802
- providerName: string;
2803
- /** Model entry name (e.g., "evolve-default") */
2804
- modelName: string;
2805
- /** Max context size for the model entry */
2806
- maxContextSize: number;
2807
- };
2808
- /** Additional directories to include in checkpoint tar (beyond mcpConfig.settingsDir).
2809
- * Used for agents like OpenCode that spread state across XDG directories. */
2810
- checkpointDirs?: string[];
2811
- /** Additional relative paths to exclude from checkpoint tar. */
2812
- checkpointExcludes?: string[];
2813
- }
2814
3023
  /**
2815
- * Registry of all supported agents.
3024
+ * A sandbox the platform runs for you.
2816
3025
  *
2817
- * Each agent defines a buildCommand function that constructs the CLI command.
2818
- * 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).
2819
3034
  */
2820
- declare const AGENT_REGISTRY: Record<AgentType, AgentRegistryEntry>;
3035
+ declare function managedSandbox(provider?: ManagedSandboxProviderName, evolveKey?: string): Promise<SandboxProvider>;
3036
+
2821
3037
  /**
2822
- * 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
2823
3050
  */
2824
- declare function getAgentConfig(agentType: AgentType): AgentRegistryEntry;
3051
+
2825
3052
  /**
2826
- * 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.
2827
3055
  */
2828
- declare function isValidAgentType(type: string): type is AgentType;
3056
+ declare function createClaudeParser(): (jsonLine: string) => OutputEvent[] | null;
3057
+
2829
3058
  /**
2830
- * 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 })
2831
3076
  */
2832
- declare function expandPath(path: string): string;
3077
+
2833
3078
  /**
2834
- * Get MCP settings path for an agent
3079
+ * Create a Codex parser instance.
2835
3080
  */
2836
- declare function getMcpSettingsPath(agentType: AgentType): string;
3081
+ declare function createCodexParser(): (jsonLine: string) => OutputEvent[] | null;
3082
+
2837
3083
  /**
2838
- * 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.
3088
+ */
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
2839
3143
  */
2840
- declare function getMcpSettingsDir(agentType: AgentType): string;
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[];
2841
3179
 
2842
3180
  /**
2843
3181
  * MCP JSON Configuration Writer
@@ -2859,11 +3197,11 @@ declare function getMcpSettingsDir(agentType: AgentType): string;
2859
3197
  * 1. ${workingDir}/.mcp.json - project-level MCP servers
2860
3198
  * 2. ~/.claude/settings.json - enable project MCP servers
2861
3199
  */
2862
- 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>;
2863
3201
  /** Write MCP config for Gemini agent */
2864
- 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>;
2865
3203
  /** Write MCP config for Qwen agent */
2866
- 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>;
2867
3205
  /**
2868
3206
  * Write MCP config for Droid agent
2869
3207
  *
@@ -2886,7 +3224,7 @@ interface DroidGatewaySettingsConfig {
2886
3224
  * The command passes this file with `droid --settings`, so it does not alter the
2887
3225
  * user's normal ~/.factory/settings.json inside the sandbox.
2888
3226
  */
2889
- 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>;
2890
3228
 
2891
3229
  /**
2892
3230
  * MCP TOML Configuration Writer
@@ -2901,7 +3239,7 @@ declare function writeDroidGatewaySettings(sandbox: SandboxInstance, config: Dro
2901
3239
  * Codex stores MCP config in ~/.codex/config.toml using TOML format.
2902
3240
  * Format: [mcp_servers.server_name] sections
2903
3241
  */
2904
- 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>;
2905
3243
 
2906
3244
  /**
2907
3245
  * MCP Configuration Module
@@ -2921,7 +3259,7 @@ declare function writeCodexMcpConfig(sandbox: SandboxInstance, servers: Record<s
2921
3259
  * - Droid: JSON to ${workingDir}/.factory/mcp.json
2922
3260
  * - OpenCode: JSON to ${workingDir}/opencode.json (mcp key)
2923
3261
  */
2924
- 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>;
2925
3263
 
2926
3264
  /**
2927
3265
  * Prompt Templates
@@ -3069,8 +3407,6 @@ declare function saveLocalDir(localPath: string, files: FileMap): void;
3069
3407
  *
3070
3408
  * Provides durable persistence for agent workspaces beyond sandbox lifetime.
3071
3409
  * Supports BYOK (user's S3 bucket) and Gateway (Evolve-managed) modes.
3072
- *
3073
- * Evidence: storage-checkpointing plan v2.2
3074
3410
  */
3075
3411
 
3076
3412
  /**
@@ -3189,4 +3525,200 @@ interface SessionsClient {
3189
3525
  */
3190
3526
  declare function sessions(config?: SessionsConfig): SessionsClient;
3191
3527
 
3192
- 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 };