@codelia/runtime 0.1.85 → 0.1.89

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
- import { TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore, AttachmentStore } from '@codelia/storage';
1
+ import { TaskResult, TaskState, TaskRecord, TaskKind, TaskWorkspaceMode, TaskRegistryStore, ProviderAuth, AttachmentStore, McpBoundServerAuth, McpServerAuthBinding } 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,317 @@ 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
+ /** Deny writes to immediate hidden home entries and their descendants, including future names. */
158
+ homeDotDirectory?: string;
159
+ /** Read-only names whose existing inode aliases also require validation. */
160
+ readOnlyAliasPaths?: readonly string[];
161
+ /** Local macOS admission only. Direct path restrictions still apply. */
162
+ sharedGitObjectDirectories?: readonly GitObjectDirectory[];
163
+ verifiedGitHooks?: readonly GitHookAlias[];
164
+ protectedAliasPaths?: readonly string[];
165
+ stdin: "closed" | "pipe";
166
+ /** Ordered native PATH components, including empty and relative entries. */
167
+ binPaths?: readonly string[];
168
+ toolchainHomes?: ToolchainHomes;
169
+ }>;
170
+ type ProtectedShellBackend = {
171
+ /** Explicit opt-in to enforcing readOnlyPaths, including their aliases. */
172
+ supportsReadOnlyPaths?: true;
173
+ supportsHomeDotProtection?: true;
174
+ /**
175
+ * Opt in only if direct argv uses the resolved executable and fixed Bash
176
+ * sources use protection.cwd and binPaths with host-equivalent executable
177
+ * lookup. Launch Bash without startup hooks, inherited functions or other
178
+ * changes to builtin or external command resolution.
179
+ */
180
+ supportsCommandBinding?: true;
181
+ /**
182
+ * Check the profile on the current host. The launcher must confine all
183
+ * descendants, hide protected objects, restrict writes to the selected
184
+ * roots and private scratch, and block outbound and host-local IPC.
185
+ * Never infer support from installation or OS identity alone.
186
+ */
187
+ supports: (protection: ShellProtection) => boolean;
188
+ /** Optional additional check for the resolved executable, argv or shell dialect. */
189
+ supportsInvocation?: (invocation: ShellInvocation, protection: ShellProtection) => boolean;
190
+ /** Legacy callback for the local_test reviewer scope. Never grants a saved launch. */
191
+ supportsLaunchBinding?: (candidate: LaunchRuleCandidate, protection: ShellProtection) => boolean;
192
+ /** Stable host/backend policy identity. Change it when the execution contract changes. */
193
+ exactLaunchBindingId?: string;
194
+ /** Opt in to executing candidate.invocation unchanged with this protection.
195
+ * Source candidates require fixed Bash lookup with no startup hooks or injected functions. */
196
+ supportsExactLaunchBinding?: (candidate: ExactLaunchCandidate, protection: ShellProtection) => boolean;
197
+ /** Return a managed child with private stdio. Setup failure must prevent payload execution. */
198
+ launch: (invocation: ShellInvocation, protection: ShellProtection) => ShellChild;
199
+ };
200
+ /** Explicit SDK opt-in for the qualified macOS arm64 helper. */
201
+ declare const createMacMxcShellBackend: () => ProtectedShellBackend;
202
+
203
+ declare const diagnosticMessages: {
204
+ readonly review_auth: "The review provider's authentication failed.";
205
+ readonly review_authority_changed: "The approval authority changed during review.";
206
+ readonly review_cancelled: "The review was cancelled.";
207
+ readonly review_evidence_credential: "The review evidence matches a credential detector.";
208
+ readonly review_evidence_extra_write: "Auto approve cannot review shell commands that request additional writable directories.";
209
+ readonly review_evidence_history_unavailable: "The runtime could not verify the referenced conversation history.";
210
+ readonly review_evidence_intent_unavailable: "The runtime could not find shareable text in the user intent.";
211
+ readonly review_evidence_interactive_stdin: "Auto approve requires closed stdin for shell commands.";
212
+ readonly review_evidence_invalid: "The runtime could not validate the shell review input.";
213
+ readonly review_evidence_operation_incomplete: "The runtime could not determine enough about the shell operation.";
214
+ readonly review_evidence_private_path: "The review evidence matches a private path.";
215
+ readonly review_evidence_scope: "The review scope extends beyond the workspace or does not match it.";
216
+ readonly review_evidence_sharing_restricted: "The review evidence contains a restriction on external sharing.";
217
+ readonly review_evidence_unsupported_characters: "The review evidence contains unsupported control or formatting characters.";
218
+ readonly review_evidence_too_large: "The review evidence exceeds the request size limit.";
219
+ readonly review_evidence_unavailable: "The runtime could not build shareable review evidence.";
220
+ readonly review_invalid_reply: "The reviewer returned an invalid decision.";
221
+ readonly review_media_type_missing: "The review provider omitted the response content type and did not return a recognizable event stream.";
222
+ readonly review_media_type_unexpected: "The review provider returned an unexpected content type.";
223
+ readonly review_preparation_failed: "The runtime could not prepare the review request.";
224
+ readonly review_provider_error: "The review provider returned an HTTP error.";
225
+ readonly review_provider_response_failed: "The provider reported a failed review response.";
226
+ readonly review_rate_limited: "The review provider rate-limited the request.";
227
+ readonly review_response_incomplete: "The review provider returned an incomplete response.";
228
+ readonly review_response_missing: "The review provider did not return a response body.";
229
+ readonly review_response_too_large: "The review response exceeds the size limit.";
230
+ readonly review_timeout: "The review request timed out.";
231
+ readonly review_transport_error: "The runtime could not reach the review provider.";
232
+ readonly review_unexpected_failure: "The review could not be completed.";
233
+ };
234
+ type ReviewDiagnosticCode = keyof typeof diagnosticMessages;
235
+ declare const evidenceLocations: {
236
+ readonly shell_request: "shell request";
237
+ readonly shell_analysis: "shell analysis";
238
+ readonly command_source: "shell command source";
239
+ readonly command_executable: "command executable";
240
+ readonly command_arguments: "command arguments";
241
+ readonly shell_options: "shell options";
242
+ readonly parsed_operation: "parsed shell operation";
243
+ readonly working_directory: "working directory";
244
+ readonly reviewed_directory: "reviewed directory";
245
+ readonly write_scope: "workspace write scope";
246
+ readonly user_intent: "user intent";
247
+ readonly user_correction: "user correction";
248
+ readonly earlier_goal_steer: "earlier goal steer";
249
+ readonly historical_user_message: "historical user message";
250
+ readonly historical_proposal: "historical proposal";
251
+ readonly conversation_history: "conversation history";
252
+ readonly reviewer_packet: "review request packet";
253
+ };
254
+ type ReviewEvidenceLocation = keyof typeof evidenceLocations;
255
+ type ReviewDiagnostic = Readonly<{
256
+ code: ReviewDiagnosticCode;
257
+ httpStatus?: number;
258
+ location?: ReviewEvidenceLocation;
259
+ position?: number;
260
+ }>;
261
+
262
+ type ApprovalRequest = Readonly<{
263
+ id: string;
264
+ owner: string;
265
+ origin: ApprovalOrigin;
266
+ subject: string;
267
+ registration: string;
268
+ /** Serialized validated input. Used for binding and the selected prompt only. */
269
+ input: string;
270
+ authorityVersion: string;
271
+ intentVersion: string;
272
+ connectionGeneration: string;
273
+ /** Owning run, when the request is associated with one. */
274
+ runId?: string;
275
+ }>;
276
+ type ApprovalChoice = "allow_once" | "deny_continue" | "deny_stop" | "save_session" | "save_project" | "grant_session" | "setup_allowance";
277
+ type ReviewFallback = "review_not_delegated" | "review_evidence_unavailable" | "review_unavailable" | "review_inconclusive" | "ask_user";
278
+ type Confirmation = Readonly<{
279
+ requestId: string;
280
+ subject: string;
281
+ origin: ApprovalOrigin;
282
+ preview: string;
283
+ route: ApprovalRoute;
284
+ expiresAt: number;
285
+ choices: readonly ApprovalChoice[];
286
+ saveDescription?: string;
287
+ grantDescription?: string;
288
+ reviewFallback?: ReviewFallback | "review_denied";
289
+ /** Transient, validated reviewer explanation for the local human prompt. */
290
+ reviewReason?: string;
291
+ shellStage?: "initial" | "rule" | "unavailable";
292
+ reviewDiagnostic?: ReviewDiagnostic;
293
+ reviewWithheldForPrivacy?: boolean;
294
+ }>;
295
+ type ApprovalService = {
296
+ available?: () => boolean;
297
+ confirm?: (request: Confirmation, signal: AbortSignal) => Promise<unknown>;
298
+ };
299
+ type ReviewAdapter = {
300
+ categories: readonly NonNullable<ApprovalFacts["reviewCategory"]>[];
301
+ /** The trusted host supplies and classifies current, user-authored evidence. */
302
+ buildEvidence: (request: ApprovalRequest, signal: AbortSignal) => Promise<string | Readonly<Record<string, unknown>> | null>;
303
+ /** Optional final local check and preparation before sending evidence. */
304
+ reserve?: (packet: string, signal: AbortSignal, request: ApprovalRequest) => boolean;
305
+ /** The local confirmation can display only a credential-safe version of the command. */
306
+ privacyConfirmationPreview?: (preview: string, request: ApprovalRequest, diagnostic: ReviewDiagnostic) => string | undefined;
307
+ review: (packet: string, signal: AbortSignal, request: ApprovalRequest) => Promise<unknown>;
308
+ /** Cancels this review if the active delegation is revoked. */
309
+ reviewSignal?: () => AbortSignal;
310
+ /** Bind cached denials and unconsumed permits to the current reviewer authority. */
311
+ reviewVersion?: (request: ApprovalRequest) => string | undefined;
312
+ stillApproved?: (request: ApprovalRequest) => boolean;
313
+ };
314
+ type ApprovalAudit = Readonly<{
315
+ requestId: string;
316
+ origin: ApprovalOrigin;
317
+ subject: string;
318
+ profile: ApprovalRoute["profile"];
319
+ actor: "rule" | "user" | "review" | "sandbox";
320
+ taskId?: string;
321
+ runId?: string;
322
+ route: ApprovalRoute["kind"];
323
+ reason: string;
324
+ reviewDiagnostic?: ReviewDiagnostic;
325
+ state: "dispatch" | "denied" | "expired" | "save_failed" | "review_failed";
326
+ at: number;
327
+ }>;
328
+
329
+ type ShellAuthority = Readonly<{
330
+ investigation: boolean;
331
+ workspaceWrite: "forbid" | "confirm" | "granted";
332
+ stdinPipe: "forbid" | "confirm" | "granted";
333
+ extraWriteCeiling?: readonly string[];
334
+ }>;
335
+
23
336
  type ResolvedModelConfig = {
24
337
  providers?: _codelia_config.CodeliaConfig["providers"];
25
338
  provider?: string;
@@ -86,19 +399,15 @@ type WriteTarget = {
86
399
  path: string;
87
400
  };
88
401
 
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
- };
402
+ type ToolAuthority = Readonly<{
403
+ ceiling: readonly Resource[];
404
+ granted: readonly Resource[];
405
+ launchRule?: string;
406
+ }>;
407
+ type ToolEffect = Readonly<{
408
+ resources: readonly Resource[];
409
+ kind: "external_update" | "dependency_read";
410
+ }>;
102
411
 
103
412
  type SupportedProvider = string;
104
413
 
@@ -163,24 +472,28 @@ type PreparedTaskExecution = TaskExecutionHandle & {
163
472
  }): Promise<void>;
164
473
  };
165
474
 
475
+ declare const FILE_READ_TOOLS: readonly ["read", "read_line", "list_files", "search_files"];
476
+ type SubagentFileRead = (typeof FILE_READ_TOOLS)[number];
166
477
  type SubagentLaunchInput = {
167
478
  version: 1;
168
479
  task_id: string;
169
480
  lineage: SubagentLineage;
170
481
  prompt: string;
171
482
  workspace_root: string;
483
+ protected_paths?: string[];
172
484
  model: ResolvedModelConfig;
173
485
  permission: {
174
486
  tool_allowlist: string[];
175
487
  workspace_access: "read-only" | "read-write";
176
- approval_mode: ApprovalMode;
488
+ approval_mode?: ApprovalMode;
489
+ sandbox_mode?: SandboxMode;
177
490
  parent_permissions?: PermissionsConfig;
178
491
  max_steps: number;
179
492
  timeout_seconds?: number;
180
493
  };
181
494
  };
182
495
  type SubagentChannel = {
183
- request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write", params: unknown, signal?: AbortSignal): Promise<unknown>;
496
+ request(operation: "send" | "receive" | "list" | "shell" | "edit" | "write" | SubagentFileRead, params: unknown, signal?: AbortSignal): Promise<unknown>;
184
497
  };
185
498
  type SubagentExecutorFactory = {
186
499
  isAvailable(): boolean;
@@ -244,8 +557,13 @@ declare class TaskManager {
244
557
  /** Admit a prepared executor atomically with respect to shutdown and cancellation. */
245
558
  spawnPrepared(input: TaskSpawnInput, handle: PreparedTaskExecution, signal?: AbortSignal): Promise<TaskRecord>;
246
559
  appendMessage(taskId: string, message: AgentMessage): Promise<void>;
247
- list(): Promise<TaskRecord[]>;
248
- status(taskId: string): Promise<TaskRecord | null>;
560
+ ownsTask(task: TaskRecord, sessionId: string | null | undefined): boolean;
561
+ list(owner?: {
562
+ sessionId: string | null | undefined;
563
+ }): Promise<TaskRecord[]>;
564
+ status(taskId: string, owner?: {
565
+ sessionId: string | null | undefined;
566
+ }): Promise<TaskRecord | null>;
249
567
  result(taskId: string): Promise<TaskResult | null>;
250
568
  readOutput(taskId: string, stream: TaskExecutionOutputStream): Promise<string | null>;
251
569
  writeInput(taskId: string, input: {
@@ -290,6 +608,7 @@ type RuntimeEnvironmentContract = {
290
608
  root?: string;
291
609
  filesystem: "enabled" | "disabled";
292
610
  process: "runtime" | "disabled";
611
+ sandboxMode?: SandboxMode;
293
612
  };
294
613
  context: {
295
614
  systemPrompt: "runtime-default" | "host";
@@ -333,7 +652,6 @@ type RuntimeConfigProvider = {
333
652
  fast?: ModelFastMode;
334
653
  }) => Promise<WriteTarget>;
335
654
  updateTuiTheme?: (workingDir: string | undefined, theme: string) => Promise<WriteTarget>;
336
- appendPermissionAllowRules?: (workingDir: string | undefined, rules: PermissionRule[]) => Promise<void>;
337
655
  };
338
656
  type CredentialProvider = {
339
657
  hasAnyAvailableAuth?: () => boolean | Promise<boolean>;
@@ -350,7 +668,7 @@ type CredentialProvider = {
350
668
  type SystemPromptProvider = {
351
669
  loadSystemPrompt: (workingDir?: string) => Promise<string> | string;
352
670
  };
353
- type ApprovalService = unknown;
671
+
354
672
  type PromptService = unknown;
355
673
  type RuntimeEventSink = {
356
674
  emit: (notification: RpcNotification) => Promise<void> | void;
@@ -372,6 +690,27 @@ type RuntimeHostAdapters = {
372
690
  configProvider?: RuntimeConfigProvider;
373
691
  credentialProvider?: CredentialProvider;
374
692
  approvalService?: ApprovalService;
693
+ approvalAudit?: (entry: ApprovalAudit) => void;
694
+ approvalLaunchRuleStore?: LaunchRuleStore;
695
+ approvalPolicyRevision?: () => string;
696
+ approvalRequireAnalysis?: boolean;
697
+ approvalProtectedPaths?: readonly string[];
698
+ approvalToolEffect?: (registration: Readonly<{
699
+ id: string;
700
+ name: string;
701
+ kind: "builtin" | "mcp" | "host" | "client";
702
+ }>, args: Readonly<Record<string, unknown>>) => ToolEffect | undefined;
703
+ approvalToolAuthority?: (registration: Readonly<{
704
+ id: string;
705
+ name: string;
706
+ kind: "builtin" | "mcp" | "host" | "client";
707
+ }>) => ToolAuthority | undefined;
708
+ approvalShellSource?: (source: string) => ShellInvocation;
709
+ approvalShellAuthority?: ShellAuthority;
710
+ approvalReviewer?: ReviewAdapter;
711
+ /** Exact command PATH. Omit to use the launching process's PATH. */
712
+ shellPath?: string;
713
+ shellProtectionBackend?: ProtectedShellBackend;
375
714
  promptService?: PromptService;
376
715
  eventSink?: RuntimeEventSink;
377
716
  stores?: RuntimeStores;
@@ -382,6 +721,116 @@ type RuntimeOptions = {
382
721
  adapters?: RuntimeHostAdapters;
383
722
  };
384
723
 
724
+ type DiscoveredOAuthConfig = {
725
+ issuer?: string;
726
+ authorization_url?: string;
727
+ token_url?: string;
728
+ registration_url?: string;
729
+ resource?: string;
730
+ scope?: string;
731
+ code_challenge_methods_supported?: string[];
732
+ };
733
+ declare const fetchDiscoveredOAuthConfig: (serverUrl: string, signal?: AbortSignal) => Promise<DiscoveredOAuthConfig>;
734
+ type BindingOAuth = Pick<DiscoveredOAuthConfig, "issuer" | "authorization_url" | "token_url"> & {
735
+ client_id?: string;
736
+ };
737
+ type BindingServer = {
738
+ url?: string;
739
+ oauth?: BindingOAuth;
740
+ };
741
+ /** The HTTP destination owns the credential. The advertised OAuth resource is a grant parameter. */
742
+ declare const resolveMcpServerBinding: (server: BindingServer, oauth?: BindingOAuth) => McpServerAuthBinding | null;
743
+ declare const mcpEntryMatchesServer: (entry: McpBoundServerAuth, server: BindingServer, oauth?: BindingOAuth) => boolean;
744
+
745
+ type McpRequestOptions = {
746
+ timeoutMs: number;
747
+ signal?: AbortSignal;
748
+ };
749
+ type McpClient = {
750
+ request(method: string, params: unknown, options: McpRequestOptions): Promise<unknown>;
751
+ notify(method: string, params: unknown): Promise<void>;
752
+ close(): Promise<void>;
753
+ };
754
+
755
+ type StdioClientOptions = {
756
+ serverId: string;
757
+ command: string;
758
+ args: string[];
759
+ cwd?: string;
760
+ env?: Record<string, string>;
761
+ log: (message: string) => void;
762
+ };
763
+ declare class StdioMcpClient implements McpClient {
764
+ private readonly options;
765
+ private readonly child;
766
+ private readonly pending;
767
+ private closed;
768
+ private closePromise;
769
+ private sequence;
770
+ constructor(options: StdioClientOptions, protectedChild?: ShellChild);
771
+ private bindStreams;
772
+ private handleRpcResponse;
773
+ private failAllPending;
774
+ private nextRequestId;
775
+ private writeJsonRpc;
776
+ request(method: string, params: unknown, options: McpRequestOptions): Promise<unknown>;
777
+ notify(method: string, params: unknown): Promise<void>;
778
+ close(): Promise<void>;
779
+ }
780
+
781
+ type StdioConfig = {
782
+ command?: string;
783
+ args?: string[];
784
+ cwd?: string;
785
+ env?: Record<string, string>;
786
+ };
787
+ /** An explicit CLI probe grants only this configured service launch. */
788
+ declare function createLocalMcpStdioProbeClient(serverId: string, config: StdioConfig): Promise<StdioMcpClient>;
789
+
790
+ /** Frozen before sending. Resolution must use the same destination and condition. */
791
+ type BrokeredMutation = Readonly<{
792
+ requestId: string;
793
+ destination: string;
794
+ operation: string;
795
+ target: string;
796
+ value: string;
797
+ expectedValue: string | null;
798
+ }>;
799
+ type BrokeredMutationOutcome = "applied" | "rejected" | "unknown";
800
+ type BrokeredMutationAdapter = {
801
+ update: (request: BrokeredMutation, signal?: AbortSignal) => Promise<BrokeredMutationOutcome>;
802
+ observe: (request: BrokeredMutation, signal?: AbortSignal) => Promise<BrokeredMutationOutcome>;
803
+ };
804
+ /**
805
+ * Run after approval, using a trusted transport for one conditional update.
806
+ * If acknowledgement is lost, the observation is read-only and cannot replay
807
+ * the update. Cancellation after dispatch can leave an unknown result.
808
+ */
809
+ declare const runBrokeredMutation: (request: BrokeredMutation, adapter: BrokeredMutationAdapter, signal?: AbortSignal) => Promise<BrokeredMutationOutcome>;
810
+
811
+ type PublicApprovalReviewerOptions = {
812
+ purpose?: "rule_suggestion";
813
+ /** Existing API key for the selected public provider route. */
814
+ apiKey: string;
815
+ effort?: "low" | "medium";
816
+ /** General shell review requires the embedding host to opt in explicitly. */
817
+ categories?: ReviewAdapter["categories"];
818
+ /** Return locally vetted evidence, or null when required evidence cannot be shared. */
819
+ buildEvidence: ReviewAdapter["buildEvidence"];
820
+ organization?: string;
821
+ project?: string;
822
+ recordUsage?: (usage: {
823
+ model: string;
824
+ inputTokens: number;
825
+ outputTokens: number;
826
+ durationMs: number;
827
+ }) => void;
828
+ fetcher?: typeof fetch;
829
+ };
830
+
831
+ /** Standard public OpenAI reviewer for SDK hosts using an existing API key. */
832
+ declare const createPublicApprovalReviewer: (options: PublicApprovalReviewerOptions) => ReviewAdapter;
833
+
385
834
  declare const startRuntime: (options?: RuntimeOptions) => Promise<void>;
386
835
 
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 };
836
+ 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, fetchDiscoveredOAuthConfig, mcpEntryMatchesServer, resolveMcpServerBinding, runBrokeredMutation, startRuntime };