@codelia/runtime 0.1.85 → 0.1.86

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.cts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore, AttachmentStore } from '@codelia/storage';
2
2
  export { AttachmentStore, StoredAttachment } from '@codelia/storage';
3
+ import { ChildProcessByStdio } from 'node:child_process';
4
+ import { Writable, Readable } from 'node:stream';
3
5
  import * as _codelia_config from '@codelia/config';
4
- import { PermissionsConfig, SubagentConfig, PermissionRule } from '@codelia/config';
6
+ import { PermissionsConfig, SubagentConfig } from '@codelia/config';
5
7
  import { SessionStateStore, RunEventStoreFactory, ToolOutputCacheStore, Tool } from '@codelia/core';
6
8
  import { RpcNotification } from '@codelia/protocol';
7
- import { ModelFastMode, TaskProgress, SubagentLineage, ApprovalMode, AgentMessage, ModelReasoningLevel } from '@codelia/shared-types';
9
+ import { ModelFastMode, TaskProgress, SubagentLineage, ApprovalMode, SandboxMode, AgentMessage, ModelReasoningLevel } from '@codelia/shared-types';
8
10
 
9
11
  declare const DEFAULT_LIMITS: {
10
12
  max_file_bytes: number;
@@ -20,6 +22,342 @@ declare const DEFAULT_LIMITS: {
20
22
  };
21
23
  type AttachmentUploadPolicy = typeof DEFAULT_LIMITS;
22
24
 
25
+ type ToolchainHomes = Readonly<{
26
+ CARGO_HOME?: string;
27
+ RUSTUP_HOME?: string;
28
+ }>;
29
+
30
+ type GitHookAlias = Readonly<{
31
+ path: string;
32
+ target: string;
33
+ }>;
34
+ type GitObjectDirectory = Readonly<{
35
+ path: string;
36
+ identity: string;
37
+ }>;
38
+
39
+ type ApprovalOrigin = "parent_agent" | "child_agent" | "operator" | "ui_bang" | "startup" | "mcp_service";
40
+ type ExecutionProfile = "investigation" | "development" | "full-access" | "host_managed";
41
+ type Resource = Readonly<{
42
+ operation: "read" | "write" | "network" | "invoke";
43
+ target: string;
44
+ scope?: "tree";
45
+ }>;
46
+ type ApprovalFacts = Readonly<{
47
+ valid: boolean;
48
+ owned: boolean;
49
+ registered: boolean;
50
+ explicitDeny?: string;
51
+ enforceable: boolean;
52
+ profile: ExecutionProfile;
53
+ requested: readonly Resource[];
54
+ ceiling: readonly Resource[];
55
+ granted: readonly Resource[];
56
+ opaque?: boolean;
57
+ opaqueReason?: "indirect_execution" | "interactive_stdin" | "unrestricted_program" | "unbound_working_directory";
58
+ requireAnalysis?: boolean;
59
+ humanOnly?: "destructive" | "external_mutation" | "policy_change";
60
+ launchRule?: string;
61
+ reviewCategory?: "local_test" | "local_shell" | "dependency_read";
62
+ /** A user selected Auto approve for this launch under an enforced local profile. */
63
+ confinedAutoLaunch?: boolean;
64
+ /** Confined TUI shell with user-enabled review and agent-facing fallbacks. */
65
+ autoReview?: boolean;
66
+ }>;
67
+ type ApprovalRoute = Readonly<{
68
+ kind: "deny" | "human" | "immediate" | "review" | "defer";
69
+ reason: string;
70
+ profile: ExecutionProfile;
71
+ resources: readonly Resource[];
72
+ additional: readonly Resource[];
73
+ }>;
74
+
75
+ type ShellInvocation = Readonly<{
76
+ kind: "source";
77
+ executable: string;
78
+ dialect: "bash" | "unsupported";
79
+ options: readonly string[];
80
+ source: string;
81
+ }> | Readonly<{
82
+ kind: "argv";
83
+ executable: string;
84
+ args: readonly string[];
85
+ }>;
86
+
87
+ type LegacyLaunchRule = Readonly<{
88
+ id: string;
89
+ template: "bun-test-file/v1" | "bun-typecheck/v1";
90
+ project: string;
91
+ executable: string;
92
+ executableIdentity: string;
93
+ origin: "parent_agent" | "operator";
94
+ profile: "development";
95
+ stdin: "closed";
96
+ }>;
97
+ type LaunchRuleCandidate = Readonly<{
98
+ rule: LegacyLaunchRule;
99
+ description: string;
100
+ target: string;
101
+ operand: string;
102
+ targetIdentity: string;
103
+ }>;
104
+ type ExactLaunchRule = Readonly<{
105
+ id: string;
106
+ template: "exact-argv/v2";
107
+ project: string;
108
+ cwd: string;
109
+ launchKind: ShellInvocation["kind"];
110
+ argv0: string;
111
+ source?: string;
112
+ executable: string;
113
+ executableIdentity: string;
114
+ args: readonly string[];
115
+ origin: "parent_agent" | "operator";
116
+ profile: "development" | "investigation";
117
+ stdin: "closed";
118
+ authority: string;
119
+ }>;
120
+ type PrefixLaunchRule = Omit<ExactLaunchRule, "template" | "source"> & Readonly<{
121
+ template: "argv-prefix/v1";
122
+ }>;
123
+ type LaunchRule = ExactLaunchRule | PrefixLaunchRule | LegacyLaunchRule;
124
+ type ExactLaunchCandidate = Readonly<{
125
+ rule: ExactLaunchRule;
126
+ invocation: ShellInvocation;
127
+ description: string;
128
+ }>;
129
+ declare class LaunchRuleStore {
130
+ readonly directory: string;
131
+ private readonly cached;
132
+ private readonly session;
133
+ constructor(directory?: string);
134
+ private projectDirectory;
135
+ private assertPrivate;
136
+ private read;
137
+ has(rule: LaunchRule, session: string): boolean;
138
+ hasLegacy(rule: LegacyLaunchRule, session: string): boolean;
139
+ private stored;
140
+ match(exact: ExactLaunchRule, session: string): ExactLaunchRule | PrefixLaunchRule | undefined;
141
+ save(rule: LaunchRule, scope: "session" | "project", session: string): void;
142
+ list(project: string, session: string): Array<LaunchRule & {
143
+ scope: "session" | "project";
144
+ }>;
145
+ remove(project: string, session: string, id: string, scope: "session" | "project"): boolean;
146
+ }
147
+
148
+ type ShellChild = ChildProcessByStdio<Writable | null, Readable, Readable>;
149
+ type ShellProtection = Readonly<{
150
+ profile: "investigation" | "development" | "full-access";
151
+ root: string;
152
+ cwd: string;
153
+ writeRoots: readonly string[];
154
+ protectedPaths: readonly string[];
155
+ /** Visible to readers, with writes denied independently of writeRoots. */
156
+ readOnlyPaths?: readonly string[];
157
+ /** Read-only names whose existing inode aliases also require validation. */
158
+ readOnlyAliasPaths?: readonly string[];
159
+ /** Local macOS admission only. Direct path restrictions still apply. */
160
+ sharedGitObjectDirectories?: readonly GitObjectDirectory[];
161
+ verifiedGitHooks?: readonly GitHookAlias[];
162
+ protectedAliasPaths?: readonly string[];
163
+ stdin: "closed" | "pipe";
164
+ /** Ordered native PATH components, including empty and relative entries. */
165
+ binPaths?: readonly string[];
166
+ toolchainHomes?: ToolchainHomes;
167
+ }>;
168
+ type ProtectedShellBackend = {
169
+ /** Explicit opt-in to enforcing readOnlyPaths, including their aliases. */
170
+ supportsReadOnlyPaths?: true;
171
+ /**
172
+ * Opt in only if direct argv uses the resolved executable and fixed Bash
173
+ * sources use protection.cwd and binPaths with host-equivalent executable
174
+ * lookup. Launch Bash without startup hooks, inherited functions or other
175
+ * changes to builtin or external command resolution.
176
+ */
177
+ supportsCommandBinding?: true;
178
+ /**
179
+ * Check the profile on the current host. The launcher must confine all
180
+ * descendants, hide protected objects, restrict writes to the selected
181
+ * roots and private scratch, and block outbound and host-local IPC.
182
+ * Never infer support from installation or OS identity alone.
183
+ */
184
+ supports: (protection: ShellProtection) => boolean;
185
+ /** Optional additional check for the resolved executable, argv or shell dialect. */
186
+ supportsInvocation?: (invocation: ShellInvocation, protection: ShellProtection) => boolean;
187
+ /** Legacy callback for the local_test reviewer scope. Never grants a saved launch. */
188
+ supportsLaunchBinding?: (candidate: LaunchRuleCandidate, protection: ShellProtection) => boolean;
189
+ /** Stable host/backend policy identity. Change it when the execution contract changes. */
190
+ exactLaunchBindingId?: string;
191
+ /** Opt in to executing candidate.invocation unchanged with this protection.
192
+ * Source candidates require fixed Bash lookup with no startup hooks or injected functions. */
193
+ supportsExactLaunchBinding?: (candidate: ExactLaunchCandidate, protection: ShellProtection) => boolean;
194
+ /** Return a managed child with private stdio. Setup failure must prevent payload execution. */
195
+ launch: (invocation: ShellInvocation, protection: ShellProtection) => ShellChild;
196
+ };
197
+ /** Explicit SDK opt-in for the qualified macOS arm64 helper. */
198
+ declare const createMacMxcShellBackend: () => ProtectedShellBackend;
199
+
200
+ declare const diagnosticMessages: {
201
+ readonly review_auth: "The review provider's authentication failed.";
202
+ readonly review_authority_changed: "The approval authority changed during review.";
203
+ readonly review_cancelled: "The review was cancelled.";
204
+ readonly review_evidence_credential: "The review evidence matches a credential detector.";
205
+ readonly review_evidence_extra_write: "Auto approve cannot review shell commands that request additional writable directories.";
206
+ readonly review_evidence_history_unavailable: "The runtime could not verify the referenced conversation history.";
207
+ readonly review_evidence_intent_unavailable: "The runtime could not find shareable text in the user intent.";
208
+ readonly review_evidence_interactive_stdin: "Auto approve requires closed stdin for shell commands.";
209
+ readonly review_evidence_invalid: "The runtime could not validate the shell review input.";
210
+ readonly review_evidence_operation_incomplete: "The runtime could not determine enough about the shell operation.";
211
+ readonly review_evidence_private_path: "The review evidence matches a private path.";
212
+ readonly review_evidence_scope: "The review scope extends beyond the workspace or does not match it.";
213
+ readonly review_evidence_sharing_restricted: "The review evidence contains a restriction on external sharing.";
214
+ readonly review_evidence_unsupported_characters: "The review evidence contains unsupported control or formatting characters.";
215
+ readonly review_evidence_too_large: "The review evidence exceeds the request size limit.";
216
+ readonly review_evidence_unavailable: "The runtime could not build shareable review evidence.";
217
+ readonly review_invalid_reply: "The reviewer returned an invalid decision.";
218
+ readonly review_media_type_missing: "The review provider omitted the response content type and did not return a recognizable event stream.";
219
+ readonly review_media_type_unexpected: "The review provider returned an unexpected content type.";
220
+ readonly review_preparation_failed: "The runtime could not prepare the review request.";
221
+ readonly review_provider_error: "The review provider returned an HTTP error.";
222
+ readonly review_provider_response_failed: "The provider reported a failed review response.";
223
+ readonly review_rate_limited: "The review provider rate-limited the request.";
224
+ readonly review_response_incomplete: "The review provider returned an incomplete response.";
225
+ readonly review_response_missing: "The review provider did not return a response body.";
226
+ readonly review_response_too_large: "The review response exceeds the size limit.";
227
+ readonly review_timeout: "The review request timed out.";
228
+ readonly review_transport_error: "The runtime could not reach the review provider.";
229
+ readonly review_unexpected_failure: "The review could not be completed.";
230
+ };
231
+ type ReviewDiagnosticCode = keyof typeof diagnosticMessages;
232
+ declare const evidenceLocations: {
233
+ readonly shell_request: "shell request";
234
+ readonly shell_analysis: "shell analysis";
235
+ readonly command_source: "shell command source";
236
+ readonly command_executable: "command executable";
237
+ readonly command_arguments: "command arguments";
238
+ readonly shell_options: "shell options";
239
+ readonly parsed_operation: "parsed shell operation";
240
+ readonly working_directory: "working directory";
241
+ readonly reviewed_directory: "reviewed directory";
242
+ readonly write_scope: "workspace write scope";
243
+ readonly user_intent: "user intent";
244
+ readonly user_correction: "user correction";
245
+ readonly earlier_goal_steer: "earlier goal steer";
246
+ readonly historical_user_message: "historical user message";
247
+ readonly historical_proposal: "historical proposal";
248
+ readonly conversation_history: "conversation history";
249
+ readonly reviewer_packet: "review request packet";
250
+ };
251
+ type ReviewEvidenceLocation = keyof typeof evidenceLocations;
252
+ type ReviewDiagnostic = Readonly<{
253
+ code: ReviewDiagnosticCode;
254
+ httpStatus?: number;
255
+ location?: ReviewEvidenceLocation;
256
+ position?: number;
257
+ }>;
258
+
259
+ type ApprovalRequest = Readonly<{
260
+ id: string;
261
+ owner: string;
262
+ origin: ApprovalOrigin;
263
+ subject: string;
264
+ registration: string;
265
+ /** Serialized validated input. Used for binding and the selected prompt only. */
266
+ input: string;
267
+ authorityVersion: string;
268
+ intentVersion: string;
269
+ connectionGeneration: string;
270
+ /** Owning run, when the request is associated with one. */
271
+ runId?: string;
272
+ }>;
273
+ type ApprovalChoice = "allow_once" | "deny_continue" | "deny_stop" | "save_session" | "save_project" | "grant_session" | "setup_allowance";
274
+ type ReviewFallback = "review_not_delegated" | "review_evidence_unavailable" | "review_unavailable" | "review_inconclusive" | "ask_user";
275
+ type Confirmation = Readonly<{
276
+ requestId: string;
277
+ subject: string;
278
+ origin: ApprovalOrigin;
279
+ preview: string;
280
+ route: ApprovalRoute;
281
+ expiresAt: number;
282
+ choices: readonly ApprovalChoice[];
283
+ saveDescription?: string;
284
+ grantDescription?: string;
285
+ reviewFallback?: ReviewFallback | "review_denied";
286
+ /** Transient, validated reviewer explanation for the local human prompt. */
287
+ reviewReason?: string;
288
+ shellStage?: "initial" | "rule" | "unavailable";
289
+ reviewDiagnostic?: ReviewDiagnostic;
290
+ reviewWithheldForPrivacy?: boolean;
291
+ }>;
292
+ type ApprovalService = {
293
+ available?: () => boolean;
294
+ confirm?: (request: Confirmation, signal: AbortSignal) => Promise<unknown>;
295
+ };
296
+ type ReviewAdapter = {
297
+ categories: readonly NonNullable<ApprovalFacts["reviewCategory"]>[];
298
+ /** The trusted host supplies and classifies current, user-authored evidence. */
299
+ buildEvidence: (request: ApprovalRequest, signal: AbortSignal) => Promise<string | Readonly<Record<string, unknown>> | null>;
300
+ /** Optional final local check and preparation before sending evidence. */
301
+ reserve?: (packet: string, signal: AbortSignal, request: ApprovalRequest) => boolean;
302
+ /** The local confirmation can display only a credential-safe version of the command. */
303
+ privacyConfirmationPreview?: (preview: string, request: ApprovalRequest, diagnostic: ReviewDiagnostic) => string | undefined;
304
+ review: (packet: string, signal: AbortSignal, request: ApprovalRequest) => Promise<unknown>;
305
+ /** Cancels this review if the active delegation is revoked. */
306
+ reviewSignal?: () => AbortSignal;
307
+ /** Bind cached denials and unconsumed permits to the current reviewer authority. */
308
+ reviewVersion?: (request: ApprovalRequest) => string | undefined;
309
+ stillApproved?: (request: ApprovalRequest) => boolean;
310
+ };
311
+ type ApprovalAudit = Readonly<{
312
+ requestId: string;
313
+ origin: ApprovalOrigin;
314
+ subject: string;
315
+ profile: ApprovalRoute["profile"];
316
+ actor: "rule" | "user" | "review" | "sandbox";
317
+ taskId?: string;
318
+ runId?: string;
319
+ route: ApprovalRoute["kind"];
320
+ reason: string;
321
+ reviewDiagnostic?: ReviewDiagnostic;
322
+ state: "dispatch" | "denied" | "expired" | "save_failed" | "review_failed";
323
+ at: number;
324
+ }>;
325
+
326
+ type ShellAuthority = Readonly<{
327
+ investigation: boolean;
328
+ workspaceWrite: "forbid" | "confirm" | "granted";
329
+ stdinPipe: "forbid" | "confirm" | "granted";
330
+ extraWriteCeiling?: readonly string[];
331
+ }>;
332
+
333
+ type ToolAuthority = Readonly<{
334
+ ceiling: readonly Resource[];
335
+ granted: readonly Resource[];
336
+ launchRule?: string;
337
+ }>;
338
+ type ToolEffect = Readonly<{
339
+ resources: readonly Resource[];
340
+ kind: "external_update" | "dependency_read";
341
+ }>;
342
+
343
+ type OAuthTokens = {
344
+ access_token: string;
345
+ refresh_token: string;
346
+ expires_at: number;
347
+ account_id?: string;
348
+ };
349
+ type ProviderAuth = {
350
+ method: "api_key";
351
+ api_key: string;
352
+ /** The built-in API base at credential acquisition, when known. */
353
+ api_base?: string;
354
+ } | {
355
+ method: "oauth";
356
+ oauth: OAuthTokens;
357
+ };
358
+
359
+ type SupportedProvider = string;
360
+
23
361
  type ResolvedModelConfig = {
24
362
  providers?: _codelia_config.CodeliaConfig["providers"];
25
363
  provider?: string;
@@ -86,22 +424,6 @@ type WriteTarget = {
86
424
  path: string;
87
425
  };
88
426
 
89
- type OAuthTokens = {
90
- access_token: string;
91
- refresh_token: string;
92
- expires_at: number;
93
- account_id?: string;
94
- };
95
- type ProviderAuth = {
96
- method: "api_key";
97
- api_key: string;
98
- } | {
99
- method: "oauth";
100
- oauth: OAuthTokens;
101
- };
102
-
103
- type SupportedProvider = string;
104
-
105
427
  type TerminalTaskState = Extract<TaskState, "completed" | "failed" | "cancelled">;
106
428
  type TaskSpawnInput = {
107
429
  subagent?: TaskRecord["subagent"];
@@ -163,24 +485,28 @@ type PreparedTaskExecution = TaskExecutionHandle & {
163
485
  }): Promise<void>;
164
486
  };
165
487
 
488
+ declare const FILE_READ_TOOLS: readonly ["read", "read_line", "list_files", "search_files"];
489
+ type SubagentFileRead = (typeof FILE_READ_TOOLS)[number];
166
490
  type SubagentLaunchInput = {
167
491
  version: 1;
168
492
  task_id: string;
169
493
  lineage: SubagentLineage;
170
494
  prompt: string;
171
495
  workspace_root: string;
496
+ protected_paths?: string[];
172
497
  model: ResolvedModelConfig;
173
498
  permission: {
174
499
  tool_allowlist: string[];
175
500
  workspace_access: "read-only" | "read-write";
176
- approval_mode: ApprovalMode;
501
+ approval_mode?: ApprovalMode;
502
+ sandbox_mode?: SandboxMode;
177
503
  parent_permissions?: PermissionsConfig;
178
504
  max_steps: number;
179
505
  timeout_seconds?: number;
180
506
  };
181
507
  };
182
508
  type SubagentChannel = {
183
- request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write", params: unknown, signal?: AbortSignal): Promise<unknown>;
509
+ request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write" | SubagentFileRead, params: unknown, signal?: AbortSignal): Promise<unknown>;
184
510
  };
185
511
  type SubagentExecutorFactory = {
186
512
  isAvailable(): boolean;
@@ -244,8 +570,13 @@ declare class TaskManager {
244
570
  /** Admit a prepared executor atomically with respect to shutdown and cancellation. */
245
571
  spawnPrepared(input: TaskSpawnInput, handle: PreparedTaskExecution, signal?: AbortSignal): Promise<TaskRecord>;
246
572
  appendMessage(taskId: string, message: AgentMessage): Promise<void>;
247
- list(): Promise<TaskRecord[]>;
248
- status(taskId: string): Promise<TaskRecord | null>;
573
+ ownsTask(task: TaskRecord, sessionId: string | null | undefined): boolean;
574
+ list(owner?: {
575
+ sessionId: string | null | undefined;
576
+ }): Promise<TaskRecord[]>;
577
+ status(taskId: string, owner?: {
578
+ sessionId: string | null | undefined;
579
+ }): Promise<TaskRecord | null>;
249
580
  result(taskId: string): Promise<TaskResult | null>;
250
581
  readOutput(taskId: string, stream: TaskExecutionOutputStream): Promise<string | null>;
251
582
  writeInput(taskId: string, input: {
@@ -290,6 +621,7 @@ type RuntimeEnvironmentContract = {
290
621
  root?: string;
291
622
  filesystem: "enabled" | "disabled";
292
623
  process: "runtime" | "disabled";
624
+ sandboxMode?: SandboxMode;
293
625
  };
294
626
  context: {
295
627
  systemPrompt: "runtime-default" | "host";
@@ -333,7 +665,6 @@ type RuntimeConfigProvider = {
333
665
  fast?: ModelFastMode;
334
666
  }) => Promise<WriteTarget>;
335
667
  updateTuiTheme?: (workingDir: string | undefined, theme: string) => Promise<WriteTarget>;
336
- appendPermissionAllowRules?: (workingDir: string | undefined, rules: PermissionRule[]) => Promise<void>;
337
668
  };
338
669
  type CredentialProvider = {
339
670
  hasAnyAvailableAuth?: () => boolean | Promise<boolean>;
@@ -350,7 +681,7 @@ type CredentialProvider = {
350
681
  type SystemPromptProvider = {
351
682
  loadSystemPrompt: (workingDir?: string) => Promise<string> | string;
352
683
  };
353
- type ApprovalService = unknown;
684
+
354
685
  type PromptService = unknown;
355
686
  type RuntimeEventSink = {
356
687
  emit: (notification: RpcNotification) => Promise<void> | void;
@@ -372,6 +703,27 @@ type RuntimeHostAdapters = {
372
703
  configProvider?: RuntimeConfigProvider;
373
704
  credentialProvider?: CredentialProvider;
374
705
  approvalService?: ApprovalService;
706
+ approvalAudit?: (entry: ApprovalAudit) => void;
707
+ approvalLaunchRuleStore?: LaunchRuleStore;
708
+ approvalPolicyRevision?: () => string;
709
+ approvalRequireAnalysis?: boolean;
710
+ approvalProtectedPaths?: readonly string[];
711
+ approvalToolEffect?: (registration: Readonly<{
712
+ id: string;
713
+ name: string;
714
+ kind: "builtin" | "mcp" | "host" | "client";
715
+ }>, args: Readonly<Record<string, unknown>>) => ToolEffect | undefined;
716
+ approvalToolAuthority?: (registration: Readonly<{
717
+ id: string;
718
+ name: string;
719
+ kind: "builtin" | "mcp" | "host" | "client";
720
+ }>) => ToolAuthority | undefined;
721
+ approvalShellSource?: (source: string) => ShellInvocation;
722
+ approvalShellAuthority?: ShellAuthority;
723
+ approvalReviewer?: ReviewAdapter;
724
+ /** Exact command PATH. Omit to use the launching process's PATH. */
725
+ shellPath?: string;
726
+ shellProtectionBackend?: ProtectedShellBackend;
375
727
  promptService?: PromptService;
376
728
  eventSink?: RuntimeEventSink;
377
729
  stores?: RuntimeStores;
@@ -382,6 +734,95 @@ type RuntimeOptions = {
382
734
  adapters?: RuntimeHostAdapters;
383
735
  };
384
736
 
737
+ type McpRequestOptions = {
738
+ timeoutMs: number;
739
+ signal?: AbortSignal;
740
+ };
741
+ type McpClient = {
742
+ request(method: string, params: unknown, options: McpRequestOptions): Promise<unknown>;
743
+ notify(method: string, params: unknown): Promise<void>;
744
+ close(): Promise<void>;
745
+ };
746
+
747
+ type StdioClientOptions = {
748
+ serverId: string;
749
+ command: string;
750
+ args: string[];
751
+ cwd?: string;
752
+ env?: Record<string, string>;
753
+ log: (message: string) => void;
754
+ };
755
+ declare class StdioMcpClient implements McpClient {
756
+ private readonly options;
757
+ private readonly child;
758
+ private readonly pending;
759
+ private closed;
760
+ private closePromise;
761
+ private sequence;
762
+ constructor(options: StdioClientOptions, protectedChild?: ShellChild);
763
+ private bindStreams;
764
+ private handleRpcResponse;
765
+ private failAllPending;
766
+ private nextRequestId;
767
+ private writeJsonRpc;
768
+ request(method: string, params: unknown, options: McpRequestOptions): Promise<unknown>;
769
+ notify(method: string, params: unknown): Promise<void>;
770
+ close(): Promise<void>;
771
+ }
772
+
773
+ type StdioConfig = {
774
+ command?: string;
775
+ args?: string[];
776
+ cwd?: string;
777
+ env?: Record<string, string>;
778
+ };
779
+ /** An explicit CLI probe grants only this configured service launch. */
780
+ declare function createLocalMcpStdioProbeClient(serverId: string, config: StdioConfig): Promise<StdioMcpClient>;
781
+
782
+ /** Frozen before sending. Resolution must use the same destination and condition. */
783
+ type BrokeredMutation = Readonly<{
784
+ requestId: string;
785
+ destination: string;
786
+ operation: string;
787
+ target: string;
788
+ value: string;
789
+ expectedValue: string | null;
790
+ }>;
791
+ type BrokeredMutationOutcome = "applied" | "rejected" | "unknown";
792
+ type BrokeredMutationAdapter = {
793
+ update: (request: BrokeredMutation, signal?: AbortSignal) => Promise<BrokeredMutationOutcome>;
794
+ observe: (request: BrokeredMutation, signal?: AbortSignal) => Promise<BrokeredMutationOutcome>;
795
+ };
796
+ /**
797
+ * Run after approval, using a trusted transport for one conditional update.
798
+ * If acknowledgement is lost, the observation is read-only and cannot replay
799
+ * the update. Cancellation after dispatch can leave an unknown result.
800
+ */
801
+ declare const runBrokeredMutation: (request: BrokeredMutation, adapter: BrokeredMutationAdapter, signal?: AbortSignal) => Promise<BrokeredMutationOutcome>;
802
+
803
+ type PublicApprovalReviewerOptions = {
804
+ purpose?: "rule_suggestion";
805
+ /** Existing API key for the selected public provider route. */
806
+ apiKey: string;
807
+ effort?: "low" | "medium";
808
+ /** General shell review requires the embedding host to opt in explicitly. */
809
+ categories?: ReviewAdapter["categories"];
810
+ /** Return locally vetted evidence, or null when required evidence cannot be shared. */
811
+ buildEvidence: ReviewAdapter["buildEvidence"];
812
+ organization?: string;
813
+ project?: string;
814
+ recordUsage?: (usage: {
815
+ model: string;
816
+ inputTokens: number;
817
+ outputTokens: number;
818
+ durationMs: number;
819
+ }) => void;
820
+ fetcher?: typeof fetch;
821
+ };
822
+
823
+ /** Standard public OpenAI reviewer for SDK hosts using an existing API key. */
824
+ declare const createPublicApprovalReviewer: (options: PublicApprovalReviewerOptions) => ReviewAdapter;
825
+
385
826
  declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
386
827
 
387
- export { type AttachmentUploadPolicy, type CredentialProvider, type PreparedTaskExecution, type RuntimeConfigProvider, type RuntimeEnvironmentContract, type RuntimeEnvironmentInput, type RuntimeEnvironmentPreset, type RuntimeEventSink, type RuntimeHostAdapters, type RuntimeOptions, type RuntimeStores, type SubagentChannel, type SubagentExecutorFactory, type SubagentLaunchInput, type SystemPromptProvider, type ToolProvider, startRuntime };
828
+ 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, createLocalMcpStdioProbeClient, createMacMxcShellBackend, createPublicApprovalReviewer, runBrokeredMutation, startRuntime };