@codelia/runtime 0.1.93 → 0.1.94

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/sdk.d.ts CHANGED
@@ -1,12 +1,13 @@
1
- import { TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore, ProviderAuth, AttachmentStore, McpBoundServerAuth, McpServerAuthBinding } from '@codelia/storage';
1
+ import { AttachmentStore, StoredAttachment, TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore, ProviderAuth, McpBoundServerAuth, McpServerAuthBinding } from '@codelia/storage';
2
2
  export { AttachmentStore, StoredAttachment } from '@codelia/storage';
3
+ import { AttachmentUploadLimits, AttachmentUploadBeginParams, AttachmentUploadBeginResult, AttachmentUploadChunkParams, AttachmentUploadChunkResult, AttachmentUploadFinishResult, SkillsListResult, RunMetricsNotify, ToolTimingRecord, RuntimePerfPhase, TelemetrySummary, TaskSpawnParams, UiContextUpdateParams, UiCapabilities, SandboxGetResult, RpcResponse, RpcNotification, WorktreeErrorData } from '@codelia/protocol';
4
+ import * as _codelia_config from '@codelia/config';
5
+ import { WorktreeConfig, PermissionsConfig, SubagentConfig } from '@codelia/config';
6
+ import { ModelFastMode, TaskProgress, SubagentLineage, ApprovalMode, SandboxMode, SkillCatalog as SkillCatalog$1, AgentMessage, ModelReasoningLevel } from '@codelia/shared-types';
3
7
  import { ChildProcessByStdio } from 'node:child_process';
4
8
  import { Writable, Readable } from 'node:stream';
5
- import * as _codelia_config from '@codelia/config';
6
- import { PermissionsConfig, SubagentConfig } from '@codelia/config';
7
- import { SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, Tool } from '@codelia/core';
8
- import { RpcNotification } from '@codelia/protocol';
9
- import { ModelFastMode, TaskProgress, SubagentLineage, ApprovalMode, SandboxMode, AgentMessage, ModelReasoningLevel } from '@codelia/shared-types';
9
+ import { ToolContext, ConversationApprovalScope, ConversationApprovalContext, ToolDefinition, Tool, SessionRecord, Agent, ContentPart, SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, StoragePaths } from '@codelia/core';
10
+ import { z } from 'zod';
10
11
 
11
12
  declare const DEFAULT_LIMITS: {
12
13
  max_file_bytes: number;
@@ -21,6 +22,123 @@ declare const DEFAULT_LIMITS: {
21
22
  lease_ms: number;
22
23
  };
23
24
  type AttachmentUploadPolicy = typeof DEFAULT_LIMITS;
25
+ /** Connection-local draft and upload receipts with host-owned durable storage. */
26
+ declare class AttachmentTransferService {
27
+ private readonly store;
28
+ private readonly now;
29
+ private readonly getSessionId?;
30
+ readonly limits: Readonly<AttachmentUploadPolicy>;
31
+ private readonly uploads;
32
+ private stagedBytes;
33
+ private closed;
34
+ private operationActive;
35
+ private queued;
36
+ private readonly expirationTimer;
37
+ constructor(store: AttachmentStore, limits?: Partial<AttachmentUploadPolicy>, now?: () => number, getSessionId?: (() => string | null) | undefined);
38
+ get wireLimits(): AttachmentUploadLimits;
39
+ get resolveImage(): AttachmentStore["resolveImage"];
40
+ bindDraft(sessionId: string): void;
41
+ discardDraft(): void;
42
+ close(): Promise<void>;
43
+ begin(params: AttachmentUploadBeginParams, sessionId: string | null): Promise<AttachmentUploadBeginResult>;
44
+ chunk(params: AttachmentUploadChunkParams, sessionId: string | null): Promise<AttachmentUploadChunkResult>;
45
+ finish(uploadId: string, sessionId: string | null): Promise<AttachmentUploadFinishResult>;
46
+ cancel(uploadId: string, sessionId: string | null): Promise<void>;
47
+ resolveForAdmission(ids: readonly string[], sessionId: string, options?: {
48
+ allowDraft?: boolean;
49
+ }): Promise<StoredAttachment[]>;
50
+ claim(ids: readonly string[], sessionId: string, options?: {
51
+ allowDraft?: boolean;
52
+ }): Promise<void>;
53
+ pin(ids: readonly string[], sessionId: string): Promise<() => void>;
54
+ read(id: string, sessionId: string, offset: number, length: number): Promise<Uint8Array>;
55
+ private lookup;
56
+ private inspect;
57
+ private getUpload;
58
+ private checkBinding;
59
+ private eligibleUpload;
60
+ private touch;
61
+ private releaseBytes;
62
+ private discard;
63
+ private trimReceipts;
64
+ private sweep;
65
+ private serial;
66
+ }
67
+
68
+ type ResolvedWorktreeConfig = Pick<WorktreeConfig, "include_files" | "use_worktreeinclude"> & {
69
+ setup_command?: {
70
+ command: string;
71
+ source: "project" | "global";
72
+ };
73
+ ignoredProjectIncludePolicy?: true;
74
+ untrustedGlobalIncludePolicy?: true;
75
+ };
76
+ declare function resolveWorktreeConfig(workingDir: string): Promise<ResolvedWorktreeConfig>;
77
+ type ResolvedModelConfig = {
78
+ providers?: _codelia_config.CodeliaConfig["providers"];
79
+ provider?: string;
80
+ name?: string;
81
+ reasoning?: string;
82
+ verbosity?: string;
83
+ fast?: ModelFastMode;
84
+ experimental?: {
85
+ openai?: {
86
+ websocket_mode?: "off" | "auto" | "on";
87
+ };
88
+ };
89
+ };
90
+ type ResolvedSkillsConfig = {
91
+ enabled: boolean;
92
+ initial: {
93
+ maxEntries: number;
94
+ maxBytes: number;
95
+ };
96
+ search: {
97
+ defaultLimit: number;
98
+ maxLimit: number;
99
+ };
100
+ };
101
+ type ResolvedExecutionEnvironmentConfig = {
102
+ startupChecks: {
103
+ enabled: boolean;
104
+ commands: string[][];
105
+ timeoutMs: number;
106
+ };
107
+ };
108
+ type ResolvedSearchConfig = {
109
+ mode: "auto" | "native" | "local";
110
+ native: {
111
+ providers: string[];
112
+ searchContextSize?: "low" | "medium" | "high";
113
+ allowedDomains?: string[];
114
+ userLocation?: {
115
+ city?: string;
116
+ country?: string;
117
+ region?: string;
118
+ timezone?: string;
119
+ };
120
+ };
121
+ local: {
122
+ backend: "ddg" | "brave";
123
+ braveApiKeyEnv: string;
124
+ };
125
+ xai: {
126
+ xSearch: {
127
+ enabled: boolean;
128
+ allowedXHandles?: string[];
129
+ excludedXHandles?: string[];
130
+ fromDate?: string;
131
+ toDate?: string;
132
+ enableImageUnderstanding?: boolean;
133
+ enableVideoUnderstanding?: boolean;
134
+ };
135
+ };
136
+ };
137
+ type WriteScope = "global" | "project";
138
+ type WriteTarget = {
139
+ scope: WriteScope;
140
+ path: string;
141
+ };
24
142
 
25
143
  type ToolchainHomes = Readonly<{
26
144
  CARGO_HOME?: string;
@@ -220,6 +338,111 @@ declare const createMacMxcShellBackend: () => ProtectedShellBackend;
220
338
  /** Explicit SDK opt-in for the Linux MXC Bubblewrap helper. */
221
339
  declare const createLinuxMxcShellBackend: () => ProtectedShellBackend;
222
340
 
341
+ type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
342
+ type TaskSpawnInput = {
343
+ subagent?: TaskRecord["subagent"];
344
+ task_id?: string;
345
+ kind: TaskKind;
346
+ workspace_mode?: TaskWorkspaceMode;
347
+ key?: string;
348
+ label?: string;
349
+ title?: string;
350
+ working_directory?: string;
351
+ parent_session_id?: string;
352
+ parent_run_id?: string;
353
+ parent_tool_call_id?: string;
354
+ child_session_id?: string;
355
+ };
356
+ type TaskExecutionMetadata = {
357
+ usage?: TaskResult["usage"];
358
+ executor_identity?: string;
359
+ executor_pid?: number;
360
+ executor_pgid?: number;
361
+ child_session_id?: string;
362
+ worktree_path?: string;
363
+ };
364
+ type TaskExecutionOutputStream = "stdout" | "stderr";
365
+ type TaskExecutionInput = {
366
+ text: string;
367
+ close: boolean;
368
+ };
369
+ type TaskExecutionInputResult = {
370
+ bytes_written: number;
371
+ stdin_closed: boolean;
372
+ };
373
+ type WorktreeFinalization = Required<Pick<TaskResult, "worktree_path" | "branch" | "base_sha" | "head_sha" | "has_changes">>;
374
+ type RecordWorktreeFinalization = (result: WorktreeFinalization) => Promise<void>;
375
+ type TaskExecutionResult = {
376
+ state: TerminalTaskState;
377
+ result?: TaskResult;
378
+ failure_message?: string;
379
+ cancellation_reason?: string;
380
+ cleanup_reason?: string;
381
+ };
382
+ type TaskExecutionHandle = {
383
+ metadata?: TaskExecutionMetadata | Promise<TaskExecutionMetadata | null | undefined> | null;
384
+ wait: Promise<TaskExecutionResult>;
385
+ readOutput?: (stream: TaskExecutionOutputStream) => string | Promise<string>;
386
+ writeInput?: (input: TaskExecutionInput) => TaskExecutionInputResult | Promise<TaskExecutionInputResult>;
387
+ cancel?: (reason?: string) => Promise<void> | void;
388
+ };
389
+ type TaskExecutionStartContext = {
390
+ task: TaskRecord;
391
+ };
392
+
393
+ /** prepare must not start work; TaskManager registers this handle before start. */
394
+ type PreparedTaskExecution = TaskExecutionHandle & {
395
+ finalize?(outcome: TaskExecutionResult, recordWorktree: RecordWorktreeFinalization): Promise<TaskExecutionResult>;
396
+ cancel(reason?: string): Promise<void>;
397
+ start(control: {
398
+ persistExecutor(metadata: TaskExecutionMetadata): Promise<void>;
399
+ running(metadata: TaskExecutionMetadata): Promise<void>;
400
+ /** Optional in-memory progress for the parent UI (subagents). */
401
+ progress?(progress: TaskProgress): void;
402
+ }): Promise<void>;
403
+ };
404
+
405
+ declare const FILE_READ_TOOLS: readonly ["read", "read_line", "list_files", "search_files"];
406
+ type SubagentFileRead = (typeof FILE_READ_TOOLS)[number];
407
+ type ChildWorkspaceBinding = Readonly<{
408
+ taskId: string;
409
+ mode: "live_workspace" | "worktree";
410
+ canonicalRoot: string;
411
+ rootIdentity: string;
412
+ }>;
413
+ type SubagentLaunchInput = {
414
+ version: 1;
415
+ task_id: string;
416
+ lineage: SubagentLineage;
417
+ prompt: string;
418
+ workspace_root: string;
419
+ workspace_mode?: ChildWorkspaceBinding["mode"];
420
+ protected_paths?: string[];
421
+ model: ResolvedModelConfig;
422
+ permission: {
423
+ tool_allowlist: string[];
424
+ workspace_access: "read-only" | "read-write";
425
+ approval_mode?: ApprovalMode;
426
+ sandbox_mode?: SandboxMode;
427
+ parent_permissions?: PermissionsConfig;
428
+ max_steps: number;
429
+ timeout_seconds?: number;
430
+ };
431
+ };
432
+ type SubagentChannel = {
433
+ request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write" | SubagentFileRead, params: unknown, signal?: AbortSignal): Promise<unknown>;
434
+ };
435
+ type SubagentExecutorFactory = {
436
+ isAvailable(): boolean;
437
+ prepare(input: SubagentLaunchInput, channel?: SubagentChannel): PreparedTaskExecution;
438
+ };
439
+
440
+ type ApprovalReceiptScope = Readonly<{
441
+ generation: number;
442
+ connectionSignal: AbortSignal;
443
+ ownerSignal: AbortSignal;
444
+ }>;
445
+
223
446
  declare const diagnosticMessages: {
224
447
  readonly review_auth: "The review provider's authentication failed.";
225
448
  readonly review_authority_changed: "The approval authority changed during review.";
@@ -350,6 +573,16 @@ type ApprovalAudit = Readonly<{
350
573
  at: number;
351
574
  }>;
352
575
 
576
+ type ReviewUserText = string | Readonly<{
577
+ text: string;
578
+ attachmentsOmitted: true;
579
+ }>;
580
+ declare const reviewHistoryReferences: z.ZodObject<{
581
+ user_message_id: z.ZodString;
582
+ proposal_message_id: z.ZodOptional<z.ZodString>;
583
+ }, z.core.$strict>;
584
+ type ReviewHistoryReferences = z.infer<typeof reviewHistoryReferences>;
585
+
353
586
  type ShellAuthority = Readonly<{
354
587
  investigation: boolean;
355
588
  workspaceWrite: "forbid" | "confirm" | "granted";
@@ -357,71 +590,347 @@ type ShellAuthority = Readonly<{
357
590
  extraWriteCeiling?: readonly string[];
358
591
  }>;
359
592
 
360
- type ResolvedModelConfig = {
361
- providers?: _codelia_config.CodeliaConfig["providers"];
593
+ type ResourceReader = {
594
+ allows: (target: string) => boolean | Promise<boolean>;
595
+ readText: (target: string) => Promise<string>;
596
+ };
597
+
598
+ declare const AgentsConfigSchema: z.ZodObject<{
599
+ enabled: z.ZodOptional<z.ZodBoolean>;
600
+ root: z.ZodOptional<z.ZodObject<{
601
+ projectRootOverride: z.ZodOptional<z.ZodString>;
602
+ markers: z.ZodOptional<z.ZodArray<z.ZodString>>;
603
+ stopAtFsRoot: z.ZodOptional<z.ZodBoolean>;
604
+ }, z.core.$strip>>;
605
+ initial: z.ZodOptional<z.ZodObject<{
606
+ maxFiles: z.ZodOptional<z.ZodNumber>;
607
+ maxBytes: z.ZodOptional<z.ZodNumber>;
608
+ }, z.core.$strip>>;
609
+ resolver: z.ZodOptional<z.ZodObject<{
610
+ enabled: z.ZodOptional<z.ZodBoolean>;
611
+ maxFilesPerResolve: z.ZodOptional<z.ZodNumber>;
612
+ }, z.core.$strip>>;
613
+ }, z.core.$strict>;
614
+ type AgentsConfig = z.infer<typeof AgentsConfigSchema>;
615
+ declare const ResolvedAgentFileSchema: z.ZodObject<{
616
+ path: z.ZodString;
617
+ mtimeMs: z.ZodNumber;
618
+ sizeBytes: z.ZodNumber;
619
+ }, z.core.$strict>;
620
+ type ResolvedAgentFile = z.infer<typeof ResolvedAgentFileSchema>;
621
+ declare const AgentsResolveReasonSchema: z.ZodEnum<{
622
+ new: "new";
623
+ updated: "updated";
624
+ }>;
625
+ type AgentsResolveReason = z.infer<typeof AgentsResolveReasonSchema>;
626
+
627
+ type ResolvedAgentWithReason = ResolvedAgentFile & {
628
+ reason: AgentsResolveReason;
629
+ };
630
+ type AgentsResolverSnapshot = {
631
+ enabled: boolean;
632
+ rootDir: string;
633
+ workingDir: string;
634
+ coveredDirs: string[];
635
+ initialFiles: ResolvedAgentFile[];
636
+ loadedFiles: ResolvedAgentFile[];
637
+ };
638
+ declare class AgentsResolver {
639
+ private readonly config;
640
+ private readonly workingDir;
641
+ private readonly rootDir;
642
+ private readonly initialFiles;
643
+ private readonly reader?;
644
+ private readonly coveredDirs;
645
+ private readonly loadedFiles;
646
+ private constructor();
647
+ static create(workingDir: string, config?: AgentsConfig, env?: NodeJS.ProcessEnv, reader?: ResourceReader): Promise<AgentsResolver>;
648
+ private registerLoaded;
649
+ private getLoadedFile;
650
+ private loadInitialChain;
651
+ buildInitialContext(): string | null;
652
+ resolveForPath(targetPath: string): Promise<ResolvedAgentWithReason[]>;
653
+ getRootDir(): string;
654
+ getCoveredDirs(): string[];
655
+ getLoadedVersion(filePath: string): number | undefined;
656
+ getSnapshot(): AgentsResolverSnapshot;
657
+ }
658
+
659
+ type SkillMetadata = SkillsListResult["skills"][number];
660
+ type SkillLoadError = SkillsListResult["errors"][number];
661
+ type SkillSearchReason = "exact_name" | "exact_path" | "prefix" | "token_overlap";
662
+ type SkillSearchResult = {
663
+ skill: SkillMetadata;
664
+ score: number;
665
+ reason: SkillSearchReason;
666
+ };
667
+ type SkillCatalog = {
668
+ skills: SkillMetadata[];
669
+ errors: SkillLoadError[];
670
+ truncated: boolean;
671
+ };
672
+ type SkillLoadResult = {
673
+ ok: true;
674
+ skill: SkillMetadata;
675
+ already_loaded: boolean;
676
+ content: string;
677
+ files: string[];
678
+ files_truncated: boolean;
679
+ } | {
680
+ ok: false;
681
+ message: string;
682
+ ambiguous_paths?: string[];
683
+ };
684
+ type SkillsResolverSnapshot = {
685
+ enabled: boolean;
686
+ root_dir: string;
687
+ working_dir: string;
688
+ catalog: SkillCatalog;
689
+ loaded_versions: Array<{
690
+ path: string;
691
+ mtime_ms: number;
692
+ }>;
693
+ };
694
+ type SkillsResolverOptions = {
695
+ workingDir: string;
696
+ config: ResolvedSkillsConfig;
697
+ env?: NodeJS.ProcessEnv;
698
+ markers?: string[];
699
+ reader?: ResourceReader;
700
+ };
701
+ declare class SkillsResolver {
702
+ private readonly workingDir;
703
+ private readonly rootDir;
704
+ private readonly config;
705
+ private readonly userSkillsDir;
706
+ private readonly reader?;
707
+ private catalog;
708
+ private readonly loadedVersions;
709
+ private constructor();
710
+ static create(options: SkillsResolverOptions): Promise<SkillsResolver>;
711
+ private collectSkillFilesInTree;
712
+ private collectRepoSkillFiles;
713
+ private resolveSkillMetadata;
714
+ reloadCatalog(): Promise<SkillCatalog>;
715
+ getCatalog(options?: {
716
+ forceReload?: boolean;
717
+ }): Promise<SkillCatalog>;
718
+ buildInitialContext(): Promise<string | null>;
719
+ search(input: {
720
+ query: string;
721
+ limit?: number;
722
+ scope?: "repo" | "user";
723
+ }): Promise<{
724
+ results: SkillSearchResult[];
725
+ truncated: boolean;
726
+ }>;
727
+ private listSkillFiles;
728
+ private resolveByPath;
729
+ load(input: {
730
+ name?: string;
731
+ path?: string;
732
+ }, allowsSkill?: (name: string) => boolean): Promise<SkillLoadResult>;
733
+ getSnapshot(): SkillsResolverSnapshot;
734
+ }
735
+
736
+ /**
737
+ * Session-scoped in-memory telemetry & runtime perf store.
738
+ * Survives `invalidateAgentCache()` and resets only when switching sessions.
739
+ */
740
+ declare class RuntimeTelemetryStore {
741
+ private sessionSummary;
742
+ private currentRunId;
743
+ private currentRunSummary;
744
+ private readonly recentCalls;
745
+ private readonly recentTools;
746
+ private startupPhases;
747
+ private agentInitPhases;
748
+ resetSession(): void;
749
+ beginRun(runId: string): void;
750
+ recordLlmCall(call: RunMetricsNotify): void;
751
+ recordToolComplete(record: ToolTimingRecord): void;
752
+ recordRetry(runId: string, delayMs: number): void;
753
+ recordRetryWait(runId: string, waitMs: number): void;
754
+ recordCompaction(runId: string, durationMs: number): void;
755
+ recordStartupPhase(name: string, durationMs: number): void;
756
+ setAgentInitPhases(phases: RuntimePerfPhase[]): void;
757
+ getSessionSummary(): TelemetrySummary;
758
+ getRunSummary(): TelemetrySummary | null;
759
+ getRecentCalls(): RunMetricsNotify[];
760
+ getRecentTools(): ToolTimingRecord[];
761
+ getStartupPhases(): RuntimePerfPhase[];
762
+ getAgentInitPhases(): RuntimePerfPhase[];
763
+ }
764
+
765
+ type ApprovalScope = "session" | "workspace";
766
+
767
+ type RuntimeModelSource = "config" | "session";
768
+ type RuntimeChatRoute = {
769
+ kind: "builtin";
770
+ provider: string;
771
+ apiBase?: string;
772
+ metered?: boolean;
773
+ } | {
774
+ kind: "named";
775
+ metered?: false;
776
+ };
777
+ type RuntimeModelOverride = {
362
778
  provider?: string;
363
779
  name?: string;
364
780
  reasoning?: string;
365
- verbosity?: string;
366
781
  fast?: ModelFastMode;
367
- experimental?: {
368
- openai?: {
369
- websocket_mode?: "off" | "auto" | "on";
370
- };
371
- };
372
782
  };
373
- type ResolvedSkillsConfig = {
374
- enabled: boolean;
375
- initial: {
376
- maxEntries: number;
377
- maxBytes: number;
378
- };
379
- search: {
380
- defaultLimit: number;
381
- maxLimit: number;
382
- };
783
+ type PendingRunSteer = {
784
+ steer_id: string;
785
+ client_steer_id?: string;
786
+ content: string | ContentPart[];
383
787
  };
384
- type ResolvedExecutionEnvironmentConfig = {
385
- startupChecks: {
386
- enabled: boolean;
387
- commands: string[][];
388
- timeoutMs: number;
389
- };
390
- };
391
- type ResolvedSearchConfig = {
392
- mode: "auto" | "native" | "local";
393
- native: {
394
- providers: string[];
395
- searchContextSize?: "low" | "medium" | "high";
396
- allowedDomains?: string[];
397
- userLocation?: {
398
- city?: string;
399
- country?: string;
400
- region?: string;
401
- timezone?: string;
402
- };
403
- };
404
- local: {
405
- backend: "ddg" | "brave";
406
- braveApiKeyEnv: string;
407
- };
408
- xai: {
409
- xSearch: {
410
- enabled: boolean;
411
- allowedXHandles?: string[];
412
- excludedXHandles?: string[];
413
- fromDate?: string;
414
- toDate?: string;
415
- enableImageUnderstanding?: boolean;
416
- enableVideoUnderstanding?: boolean;
417
- };
788
+ type ReadApprovalHistory = (references: ReviewHistoryReferences, scope: ConversationApprovalScope) => Promise<ConversationApprovalContext | null>;
789
+ declare class RuntimeState {
790
+ attachments?: AttachmentTransferService;
791
+ canReadAttachment?: (attachmentId: string) => boolean;
792
+ subagentMessages?: (sessionId: string, signal?: AbortSignal) => Promise<string[]>;
793
+ subagentSpawn?: (params: TaskSpawnParams, ctx: ToolContext) => Promise<TaskRecord>;
794
+ effectiveEnvironment: EffectiveRuntimeEnvironment;
795
+ private runSeq;
796
+ private runSteerCounter;
797
+ private appliedApprovalSteers;
798
+ approvalConnectionGeneration: number;
799
+ approvalAuthorityGeneration: number;
800
+ private workspaceApprovalAuthorityGeneration;
801
+ private approvalChanges;
802
+ private workspaceApprovalChanges;
803
+ private receiptConnection;
804
+ private receiptOwner;
805
+ approvalReceiptScope(scope?: ApprovalScope): ApprovalReceiptScope;
806
+ private approvalIntent?;
807
+ approvalUserIntent(runId: string): {
808
+ earlierGoalSteers?: readonly ReviewUserText[] | undefined;
809
+ original: ReviewUserText;
810
+ corrections: ReviewUserText[];
811
+ } | null;
812
+ approvalUserHistory(runId: string, references: ReviewHistoryReferences, scope: ConversationApprovalScope): Promise<ConversationApprovalContext | null>;
813
+ approvalSteerText(runId: string, steerId: string): ReviewUserText | undefined;
814
+ confirmApprovalSteer(runId: string, steerId: string): void;
815
+ approvalSignal(signal?: AbortSignal, scope?: ApprovalScope): AbortSignal;
816
+ approvalAuthorityRevision(scope: ApprovalScope): number;
817
+ private signalApprovalChange;
818
+ reviseApprovalAuthority(scope?: ApprovalScope): void;
819
+ approvalContext(scope?: ApprovalScope): string;
820
+ private readonly acceptedSteerIds;
821
+ private readonly pendingSteersByRun;
822
+ private readonly steerClosedRuns;
823
+ private uiRequestCounter;
824
+ private readonly pendingUiRequests;
825
+ activeRunId: string | null;
826
+ activeRunSignal?: AbortSignal;
827
+ cancelRequested: boolean;
828
+ lastUiContext: UiContextUpdateParams | null;
829
+ lastContextLeftPercent: number | null;
830
+ lastClientInfo: {
831
+ name: string;
832
+ version: string;
833
+ } | null;
834
+ uiCapabilities: UiCapabilities | null;
835
+ systemPrompt: string | null;
836
+ executionEnvironmentContext: string | null;
837
+ executionEnvironmentDebugLogged: boolean;
838
+ toolDefinitions: ToolDefinition[] | null;
839
+ tools: Tool[] | null;
840
+ wrapClientTool?: (tool: Tool) => Tool;
841
+ wrapGoalTool?: (tool: Tool) => Tool;
842
+ private boundSessionId;
843
+ get sessionId(): string | null;
844
+ set sessionId(value: string | null);
845
+ sessionMeta: Record<string, unknown> | null;
846
+ sessionAppend: ((record: SessionRecord) => void) | null;
847
+ recordAutoReviewFailure(entry: ApprovalAudit): void;
848
+ private cachedAgent;
849
+ private cachedAgentSandboxMode?;
850
+ private activeSandboxMode?;
851
+ get agent(): Agent | null;
852
+ set agent(value: Agent | null);
853
+ get appliedSandboxMode(): SandboxGetResult["applied"];
854
+ private readonly agentChatRoutes;
855
+ private activeReviewChatRoute?;
856
+ recordAgentChatRoute(agent: Agent, route: RuntimeChatRoute): void;
857
+ get reviewChatRoute(): RuntimeChatRoute | undefined;
858
+ cachedAuthProviders: ReadonlySet<string>;
859
+ /** Set when a cache invalidation was requested during a run; applied at finishRun. */
860
+ pendingAgentInvalidation: boolean;
861
+ private admissionQueue;
862
+ prepareRunImages?: (input: string | ContentPart[]) => Promise<string | ContentPart[]>;
863
+ agentsResolver: AgentsResolver | null;
864
+ skillsResolver: SkillsResolver | null;
865
+ skillsCatalogByCwd: Map<string, {
866
+ skills: {
867
+ id: string;
868
+ name: string;
869
+ description: string;
870
+ path: string;
871
+ dir: string;
872
+ scope: "repo" | "user";
873
+ mtime_ms: number;
874
+ }[];
875
+ errors: {
876
+ path: string;
877
+ message: string;
878
+ }[];
879
+ truncated: boolean;
880
+ }>;
881
+ loadedSkillVersions: Map<string, number>;
882
+ runtimeWorkingDir: string | null;
883
+ runtimeSandboxRoot: string | null;
884
+ approvalMode: ApprovalMode | null;
885
+ sandboxMode: {
886
+ value: "full-access" | "readonly" | "workspace-write";
887
+ source: "default" | "fallback" | "project" | "env" | "sdk" | "cli";
888
+ legacy?: "minimal" | "trusted" | "full-access" | undefined;
418
889
  };
419
- };
420
- type WriteScope = "global" | "project";
421
- type WriteTarget = {
422
- scope: WriteScope;
423
- path: string;
424
- };
890
+ currentModelProvider: string | null;
891
+ currentModelName: string | null;
892
+ currentModelSource: RuntimeModelSource | null;
893
+ sessionModelOverride: RuntimeModelOverride | null;
894
+ readonly telemetry: RuntimeTelemetryStore;
895
+ setRuntimeEnvironment(options: RuntimeOptions): void;
896
+ nextRunId(): string;
897
+ nextSessionId(): string;
898
+ beginRun(runId: string, uiContext?: UiContextUpdateParams | null, approvalUserText?: ReviewUserText, agent?: Agent, readApprovalHistory?: ReadApprovalHistory, goalSteers?: {
899
+ beforeObjective: readonly ReviewUserText[];
900
+ afterObjective: readonly ReviewUserText[];
901
+ }): void;
902
+ finishRun(runId: string): void;
903
+ closeRunSteers(runId: string): void;
904
+ canSteerRun(runId: string): boolean;
905
+ acceptedRunSteerId(runId: string, clientSteerId: string): string | undefined;
906
+ enqueueRunSteer(runId: string, content: string | ContentPart[], clientSteerId?: string, approvalUserText?: ReviewUserText): string;
907
+ drainRunSteers(runId: string): PendingRunSteer[];
908
+ /**
909
+ * Serializes run admission (up to `beginRun`) with idle-only management
910
+ * writes, so a write that saw no active run finishes before a run is admitted.
911
+ */
912
+ withAdmissionLock<T>(fn: () => Promise<T>): Promise<T>;
913
+ /** Drops the cached agent/tools; the next run rebuilds them and restores the session. */
914
+ invalidateAgentCache(scope?: ApprovalScope): void;
915
+ /** Invalidates now when idle, otherwise after the active run finishes. */
916
+ requestAgentInvalidation(): void;
917
+ cancelRun(runId: string): boolean;
918
+ shouldSuppressEvent(runId: string): boolean;
919
+ nextSequence(runId: string): number;
920
+ updateUiContext(params: UiContextUpdateParams): void;
921
+ setUiCapabilities(capabilities?: UiCapabilities): void;
922
+ nextUiRequestId(): string;
923
+ waitForUiResponse<T>(id: string, timeoutMs?: number, onTimeout?: () => void): Promise<T>;
924
+ resolveUiResponse(message: RpcResponse): boolean;
925
+ updateContextLeftPercent(value: number | null): boolean;
926
+ updateSkillsSnapshot(cwd: string, snapshot: {
927
+ catalog: SkillCatalog$1;
928
+ loaded_versions: Array<{
929
+ path: string;
930
+ mtime_ms: number;
931
+ }>;
932
+ }): void;
933
+ }
425
934
 
426
935
  type ToolAuthority = Readonly<{
427
936
  ceiling: readonly Resource[];
@@ -435,103 +944,21 @@ type ToolEffect = Readonly<{
435
944
 
436
945
  type SupportedProvider = string;
437
946
 
438
- type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
439
- type TaskSpawnInput = {
440
- subagent?: TaskRecord["subagent"];
441
- task_id?: string;
442
- kind: TaskKind;
443
- workspace_mode?: TaskWorkspaceMode;
444
- key?: string;
445
- label?: string;
446
- title?: string;
447
- working_directory?: string;
448
- parent_session_id?: string;
449
- parent_run_id?: string;
450
- parent_tool_call_id?: string;
451
- child_session_id?: string;
452
- };
453
- type TaskExecutionMetadata = {
454
- usage?: TaskResult["usage"];
455
- executor_identity?: string;
456
- executor_pid?: number;
457
- executor_pgid?: number;
458
- child_session_id?: string;
459
- worktree_path?: string;
460
- };
461
- type TaskExecutionOutputStream = "stdout" | "stderr";
462
- type TaskExecutionInput = {
463
- text: string;
464
- close: boolean;
465
- };
466
- type TaskExecutionInputResult = {
467
- bytes_written: number;
468
- stdin_closed: boolean;
469
- };
470
- type TaskExecutionResult = {
471
- state: TerminalTaskState;
472
- result?: TaskResult;
473
- failure_message?: string;
474
- cancellation_reason?: string;
475
- cleanup_reason?: string;
476
- };
477
- type TaskExecutionHandle = {
478
- metadata?: TaskExecutionMetadata | Promise<TaskExecutionMetadata | null | undefined> | null;
479
- wait: Promise<TaskExecutionResult>;
480
- readOutput?: (stream: TaskExecutionOutputStream) => string | Promise<string>;
481
- writeInput?: (input: TaskExecutionInput) => TaskExecutionInputResult | Promise<TaskExecutionInputResult>;
482
- cancel?: (reason?: string) => Promise<void> | void;
483
- };
484
- type TaskExecutionStartContext = {
485
- task: TaskRecord;
486
- };
487
-
488
- /** prepare must not start work; TaskManager registers this handle before start. */
489
- type PreparedTaskExecution = TaskExecutionHandle & {
490
- cancel(reason?: string): Promise<void>;
491
- start(control: {
492
- persistExecutor(metadata: TaskExecutionMetadata): Promise<void>;
493
- running(metadata: TaskExecutionMetadata): Promise<void>;
494
- /** Optional in-memory progress for the parent UI (subagents). */
495
- progress?(progress: TaskProgress): void;
496
- }): Promise<void>;
497
- };
498
-
499
- declare const FILE_READ_TOOLS: readonly ["read", "read_line", "list_files", "search_files"];
500
- type SubagentFileRead = (typeof FILE_READ_TOOLS)[number];
501
- type SubagentLaunchInput = {
502
- version: 1;
503
- task_id: string;
504
- lineage: SubagentLineage;
505
- prompt: string;
506
- workspace_root: string;
507
- protected_paths?: string[];
508
- model: ResolvedModelConfig;
509
- permission: {
510
- tool_allowlist: string[];
511
- workspace_access: "read-only" | "read-write";
512
- approval_mode?: ApprovalMode;
513
- sandbox_mode?: SandboxMode;
514
- parent_permissions?: PermissionsConfig;
515
- max_steps: number;
516
- timeout_seconds?: number;
517
- };
518
- };
519
- type SubagentChannel = {
520
- request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write" | SubagentFileRead, params: unknown, signal?: AbortSignal): Promise<unknown>;
521
- };
522
- type SubagentExecutorFactory = {
523
- isAvailable(): boolean;
524
- prepare(input: SubagentLaunchInput, channel?: SubagentChannel): PreparedTaskExecution;
525
- };
526
-
527
947
  type TaskProcessSignal = "SIGTERM" | "SIGKILL";
528
948
  type TaskProcessController = {
949
+ isProcessGroupAlive?: (pgid: number) => Promise<boolean>;
529
950
  isProcessAlive: (pid: number) => Promise<boolean>;
530
951
  terminateProcess: (pid: number, signal: TaskProcessSignal) => Promise<void>;
531
952
  terminateProcessGroup: (pgid: number, signal: TaskProcessSignal) => Promise<void>;
532
953
  };
533
954
 
534
955
  type TaskManagerOptions = {
956
+ reconcileOrphanedWorktree?: (task: TaskRecord, recordWorktree: RecordWorktreeFinalization, options?: {
957
+ preserveReason?: string;
958
+ }) => Promise<{
959
+ result: Partial<TaskResult>;
960
+ cleanupReason?: string;
961
+ } | Partial<TaskResult> | undefined>;
535
962
  registry?: TaskRegistryStore;
536
963
  runtimeId?: string;
537
964
  ownerPid?: number;
@@ -552,6 +979,8 @@ declare class TaskManager {
552
979
  private readonly pollIntervalMs;
553
980
  private readonly gracePeriodMs;
554
981
  private readonly processController;
982
+ private readonly reconcileOrphanedWorktree;
983
+ private readonly orphanReconciliations;
555
984
  private readonly activeTasks;
556
985
  private mutationQueue;
557
986
  private shuttingDown;
@@ -569,17 +998,23 @@ declare class TaskManager {
569
998
  private enqueueMutation;
570
999
  private updateTask;
571
1000
  private finalizeTask;
1001
+ /** Save evidence before cleanup can remove the checkout, including across a runtime crash. */
1002
+ private worktreeRecorder;
572
1003
  private markRunning;
573
1004
  private applyMetadata;
574
1005
  private settleExecution;
1006
+ private reconcileOrphan;
575
1007
  private reconcileObservedTask;
576
1008
  private requireTask;
577
1009
  private terminatePersistedTask;
1010
+ private persistedExecutorIsAlive;
578
1011
  private forceTerminateIfStillAlive;
579
1012
  private cancelWithoutLocalHandle;
580
1013
  spawn(input: TaskSpawnInput, startExecution: (context: TaskExecutionStartContext) => TaskExecutionHandle | Promise<TaskExecutionHandle>): Promise<TaskRecord>;
581
1014
  /** Admit a prepared executor atomically with respect to shutdown and cancellation. */
582
- spawnPrepared(input: TaskSpawnInput, handle: PreparedTaskExecution, signal?: AbortSignal): Promise<TaskRecord>;
1015
+ spawnPrepared(input: TaskSpawnInput & {
1016
+ result?: TaskResult;
1017
+ }, handle: PreparedTaskExecution, signal?: AbortSignal): Promise<TaskRecord>;
583
1018
  appendMessage(taskId: string, message: AgentMessage): Promise<void>;
584
1019
  ownsTask(task: TaskRecord, sessionId: string | null | undefined): boolean;
585
1020
  list(owner?: {
@@ -612,6 +1047,8 @@ declare class TaskManager {
612
1047
  error: string;
613
1048
  }>;
614
1049
  }>;
1050
+ private listActiveOwnedTasks;
1051
+ activeOwnedTaskCount(): Promise<number>;
615
1052
  shutdown(): Promise<{
616
1053
  cancelled: number;
617
1054
  errors: Array<{
@@ -746,6 +1183,31 @@ type RuntimeOptions = {
746
1183
  environment?: RuntimeEnvironmentInput;
747
1184
  adapters?: RuntimeHostAdapters;
748
1185
  };
1186
+ type EffectiveEnvironmentSummary = {
1187
+ source_preset?: RuntimeEnvironmentPreset;
1188
+ workspace: RuntimeEnvironmentContract["workspace"];
1189
+ context: RuntimeEnvironmentContract["context"];
1190
+ auth: RuntimeEnvironmentContract["auth"];
1191
+ config: RuntimeEnvironmentContract["config"];
1192
+ tools: RuntimeEnvironmentContract["tools"] & {
1193
+ model_visible: string[];
1194
+ operator_only: string[];
1195
+ disabled: string[];
1196
+ };
1197
+ persistence: RuntimeEnvironmentContract["persistence"];
1198
+ events: RuntimeEnvironmentContract["events"];
1199
+ };
1200
+ type EffectiveRuntimeEnvironment = RuntimeEnvironmentContract & {
1201
+ sourcePreset?: RuntimeEnvironmentPreset;
1202
+ adapters: RuntimeHostAdapters;
1203
+ resolvedTools: {
1204
+ modelVisible: string[];
1205
+ operatorOnly: string[];
1206
+ disabled: string[];
1207
+ };
1208
+ summary: EffectiveEnvironmentSummary;
1209
+ };
1210
+ declare const resolveRuntimeEnvironment: (options?: RuntimeOptions) => EffectiveRuntimeEnvironment;
749
1211
 
750
1212
  type DiscoveredOAuthConfig = {
751
1213
  issuer?: string;
@@ -860,6 +1322,206 @@ type PublicApprovalReviewerOptions = {
860
1322
  /** Standard public OpenAI reviewer for SDK hosts using an existing API key. */
861
1323
  declare const createPublicApprovalReviewer: (options: PublicApprovalReviewerOptions) => ReviewAdapter;
862
1324
 
1325
+ declare function copyWorktreeIncludes({ parentRoot, worktreeRoot, config, storage, hostProtectedPaths, signal, }: {
1326
+ parentRoot: string;
1327
+ worktreeRoot: string;
1328
+ config: ResolvedWorktreeConfig;
1329
+ storage?: StoragePaths;
1330
+ hostProtectedPaths?: readonly string[];
1331
+ signal?: AbortSignal;
1332
+ }): Promise<{
1333
+ copied: string[];
1334
+ skipped: {
1335
+ path: string;
1336
+ reason: string;
1337
+ }[];
1338
+ }>;
1339
+
1340
+ type SetupConsent = Readonly<{
1341
+ command: string;
1342
+ baseSha: string;
1343
+ worktreeRoot: string;
1344
+ source: "project" | "global";
1345
+ }>;
1346
+ type SetupDecision = "cancel" | "run_confined" | "run_host";
1347
+ type ConfirmSetup = (request: SetupConsent, signal?: AbortSignal) => Promise<SetupDecision> | SetupDecision;
1348
+ type SetupOutput = {
1349
+ stdoutTail: string;
1350
+ stderrTail: string;
1351
+ };
1352
+ type SetupOutcome = {
1353
+ status: "skipped" | "cancelled";
1354
+ } | ({
1355
+ status: "cancelled";
1356
+ } & SetupOutput) | ({
1357
+ status: "completed";
1358
+ exitCode: number | null;
1359
+ signal: NodeJS.Signals | null;
1360
+ } & SetupOutput);
1361
+ declare function runWorktreeSetupCommand({ worktreeRoot, baseSha, setupCommand, confirm, backend, hostEscalationBackend, allowHostEscalation, shellPath, signal, readLocalPolicy, storage, hostProtectedPaths, hostReadOnlyPaths, }: {
1362
+ worktreeRoot: string;
1363
+ baseSha: string;
1364
+ setupCommand?: ResolvedWorktreeConfig["setup_command"];
1365
+ confirm: ConfirmSetup;
1366
+ hostEscalationBackend?: ProtectedShellBackend;
1367
+ allowHostEscalation?: boolean;
1368
+ shellPath?: string;
1369
+ signal?: AbortSignal;
1370
+ readLocalPolicy?: boolean;
1371
+ backend?: ProtectedShellBackend | null;
1372
+ storage?: StoragePaths;
1373
+ hostProtectedPaths?: readonly string[];
1374
+ hostReadOnlyPaths?: readonly string[];
1375
+ }): Promise<SetupOutcome>;
1376
+
1377
+ /**
1378
+ * One-command unsandboxed escalation runs as the login user. Only the local TUI
1379
+ * host without custom shell/approval adapters or operator protected paths
1380
+ * permits it.
1381
+ */
1382
+ declare const supportsRuntimeShellEscalation: (environment: RuntimeState["effectiveEnvironment"], service: boolean, hostProtectedPaths: readonly string[]) => boolean;
1383
+ /** Bind worktree setup to the same host configuration as ordinary runtime shell launches. */
1384
+ declare function runRuntimeWorktreeSetup(environment: RuntimeState["effectiveEnvironment"], options: Pick<Parameters<typeof runWorktreeSetupCommand>[0], "worktreeRoot" | "baseSha" | "setupCommand" | "confirm" | "storage" | "signal">): Promise<{
1385
+ status: "skipped" | "cancelled";
1386
+ } | ({
1387
+ status: "cancelled";
1388
+ } & {
1389
+ stdoutTail: string;
1390
+ stderrTail: string;
1391
+ }) | ({
1392
+ status: "completed";
1393
+ exitCode: number | null;
1394
+ signal: NodeJS.Signals | null;
1395
+ } & {
1396
+ stdoutTail: string;
1397
+ stderrTail: string;
1398
+ })>;
1399
+
863
1400
  declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
864
1401
 
865
- export { type ApprovalAudit, type ApprovalService, type AttachmentUploadPolicy, type BrokeredMutation, type BrokeredMutationAdapter, type BrokeredMutationOutcome, type Confirmation, type CredentialProvider, LaunchRuleStore, type PreparedTaskExecution, type ProtectedShellBackend, type PublicApprovalReviewerOptions, type ReviewAdapter, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type ShellAuthority, type ShellInvocation, type ShellProtection, type SubagentChannel, type SubagentExecutorFactory, type SubagentLaunchInput, type SystemPromptProvider, type ToolAuthority, type ToolEffect, type ToolProvider, createLinuxMxcShellBackend, createLocalMcpStdioProbeClient, createMacMxcShellBackend, createPublicApprovalReviewer, fetchDiscoveredOAuthConfig, mcpEntryMatchesServer, resolveMcpServerBinding, runBrokeredMutation, startRuntime };
1402
+ declare const metadataSchema: z.ZodObject<{
1403
+ version: z.ZodLiteral<1>;
1404
+ worktreePath: z.ZodString;
1405
+ baseSha: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
1406
+ createdBranch: z.ZodNullable<z.ZodString>;
1407
+ pid: z.ZodNullable<z.ZodNumber>;
1408
+ pidIdentity: z.ZodOptional<z.ZodString>;
1409
+ owners: z.ZodOptional<z.ZodArray<z.ZodObject<{
1410
+ pid: z.ZodNumber;
1411
+ pidIdentity: z.ZodOptional<z.ZodString>;
1412
+ }, z.core.$strict>>>;
1413
+ provisioning: z.ZodOptional<z.ZodBoolean>;
1414
+ subagentLease: z.ZodOptional<z.ZodLiteral<true>>;
1415
+ removalPending: z.ZodOptional<z.ZodLiteral<true>>;
1416
+ }, z.core.$strict>;
1417
+ type WorktreeMetadata = z.infer<typeof metadataSchema>;
1418
+
1419
+ type CreateInput = {
1420
+ workingDir: string;
1421
+ name?: string;
1422
+ baseRef?: string;
1423
+ detach?: boolean;
1424
+ pid?: number;
1425
+ provisioning?: boolean;
1426
+ subagentLease?: true;
1427
+ signal?: AbortSignal;
1428
+ };
1429
+
1430
+ declare function isManagedWorktreePath(worktreePath: string, worktreesDir?: string): boolean;
1431
+ /** Find the nearest physically enclosing checkout with verified managed Git linkage. */
1432
+ declare function findVerifiedManagedCheckoutRoot(cwd: string, storage?: StoragePaths): string | undefined;
1433
+ type WorktreeLinkage = Readonly<{
1434
+ candidateParentRoot?: string;
1435
+ restrictiveCandidateRoots?: readonly string[];
1436
+ checkoutRoot?: string;
1437
+ verifiedParentRoot?: string;
1438
+ commonDir?: string;
1439
+ gitDir?: string;
1440
+ revision?: string;
1441
+ }>;
1442
+ /** Filesystem inspection only. A candidate can tighten policy, even when verification fails. */
1443
+ declare function inspectWorktreeLinkage(workspaceRoot: string, storage?: StoragePaths): WorktreeLinkage;
1444
+
1445
+ type WorktreeCheckout = {
1446
+ worktreePath: string;
1447
+ head: string | null;
1448
+ branch: string | null;
1449
+ bare: boolean;
1450
+ detached: boolean;
1451
+ locked: boolean;
1452
+ lockReason?: string;
1453
+ prunable: boolean;
1454
+ };
1455
+ declare function readWorktreeHead(worktreePath: string, worktreesDir: string): Promise<{
1456
+ sha: string | null;
1457
+ branch: string | null;
1458
+ }>;
1459
+ declare function resolveWorktreeRepo(workingDir: string, worktreesDir?: string): Promise<{
1460
+ commonDir: string;
1461
+ parentRoot: string;
1462
+ repoKey: string;
1463
+ }>;
1464
+ type CleanInput = Pick<WorktreeMetadata, "worktreePath" | "baseSha" | "createdBranch">;
1465
+
1466
+ type RemoveInput = {
1467
+ workingDir: string;
1468
+ target: string;
1469
+ force?: boolean;
1470
+ excludePaths?: readonly string[];
1471
+ };
1472
+ type RemoveResult = {
1473
+ removedPath: string;
1474
+ deletedBranch: string | null;
1475
+ };
1476
+
1477
+ declare class WorktreeError extends Error {
1478
+ readonly code: WorktreeErrorData["reason"];
1479
+ constructor(code: WorktreeErrorData["reason"], message?: string, options?: ErrorOptions);
1480
+ }
1481
+
1482
+ type RepoInput = {
1483
+ workingDir: string;
1484
+ };
1485
+ declare class WorktreeService {
1486
+ private readonly storage;
1487
+ private readonly state;
1488
+ private readonly projects;
1489
+ private readonly removal;
1490
+ constructor(storage?: StoragePaths);
1491
+ create(input: CreateInput): Promise<WorktreeMetadata>;
1492
+ list({ workingDir }: RepoInput): Promise<{
1493
+ managed: boolean;
1494
+ baseSha: string | null;
1495
+ createdBranch: string | null;
1496
+ pid: number;
1497
+ active: boolean;
1498
+ clean: boolean | null;
1499
+ worktreePath: string;
1500
+ head: string | null;
1501
+ branch: string | null;
1502
+ bare: boolean;
1503
+ detached: boolean;
1504
+ locked: boolean;
1505
+ lockReason?: string;
1506
+ prunable: boolean;
1507
+ }[]>;
1508
+ isClean(checkout: CleanInput): Promise<boolean>;
1509
+ remove(input: RemoveInput): Promise<RemoveResult>;
1510
+ rollbackProvisioning(worktreePath: string, expectedPid: number): Promise<void>;
1511
+ prune({ workingDir }: RepoInput): Promise<{
1512
+ prunedStateCount: number;
1513
+ clearedPidCount: number;
1514
+ removedEmptyContainers: number;
1515
+ }>;
1516
+ setPid(worktreePath: string, pid: number, options?: {
1517
+ provisioning?: boolean;
1518
+ expectedPid?: number;
1519
+ }): Promise<void>;
1520
+ clearPid(worktreePath: string, expectedPid?: number): Promise<boolean>;
1521
+ private updatePid;
1522
+ hasLiveOwners(worktreePath: string): Promise<boolean>;
1523
+ }
1524
+
1525
+ declare function repositorySessionMatcher(workspaceRoot: string, storage: StoragePaths): (savedRoot: string) => string | undefined;
1526
+
1527
+ export { type ApprovalAudit, type ApprovalService, type AttachmentUploadPolicy, type BrokeredMutation, type BrokeredMutationAdapter, type BrokeredMutationOutcome, type Confirmation, type CredentialProvider, type EffectiveRuntimeEnvironment, LaunchRuleStore, type PreparedTaskExecution, type ProtectedShellBackend, type PublicApprovalReviewerOptions, type ResolvedWorktreeConfig, type ReviewAdapter, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type ShellAuthority, type ShellInvocation, type ShellProtection, type SubagentChannel, type SubagentExecutorFactory, type SubagentLaunchInput, type SystemPromptProvider, type ToolAuthority, type ToolEffect, type ToolProvider, type WorktreeCheckout, type CreateInput as WorktreeCreateInput, WorktreeError, type WorktreeLinkage, type WorktreeMetadata, WorktreeService, copyWorktreeIncludes, createLinuxMxcShellBackend, createLocalMcpStdioProbeClient, createMacMxcShellBackend, createPublicApprovalReviewer, fetchDiscoveredOAuthConfig, findVerifiedManagedCheckoutRoot, inspectWorktreeLinkage, isManagedWorktreePath, mcpEntryMatchesServer, readWorktreeHead, repositorySessionMatcher, resolveMcpServerBinding, resolveRuntimeEnvironment, resolveWorktreeConfig, resolveWorktreeRepo, runBrokeredMutation, runRuntimeWorktreeSetup, startRuntime, supportsRuntimeShellEscalation };