@autopilot-agent/core 0.1.0 → 0.2.0

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.
Files changed (58) hide show
  1. package/README.md +55 -3
  2. package/dist/experimental/index.js +62 -59
  3. package/dist/experimental/index.mjs +62 -59
  4. package/dist/index.d.ts +14 -6
  5. package/dist/index.js +202 -198
  6. package/dist/index.mjs +202 -198
  7. package/dist/internal/agent-runtime.d.ts +13 -1
  8. package/dist/internal/kernel/completion-policy.d.ts +4 -0
  9. package/dist/internal/kernel/run-context.d.ts +8 -0
  10. package/dist/internal/tool-scheduler.d.ts +1 -0
  11. package/dist/internal/tools/builtins/open-preview-tool.d.ts +18 -0
  12. package/dist/internal/tools/builtins/run-command-tool.d.ts +2 -2
  13. package/dist/internal/tools/builtins/start-background-job-tool.d.ts +9 -0
  14. package/dist/internal/tools/builtins/todo-write-tool.d.ts +14 -0
  15. package/dist/internal/tools/mcp-runtime.d.ts +5 -0
  16. package/dist/internal/tools/normalized-tool-input.d.ts +1 -0
  17. package/dist/internal/tools/permissions/command-policy.d.ts +11 -0
  18. package/dist/internal/tools/permissions/external-execution-policy.d.ts +14 -0
  19. package/dist/internal/tools/permissions/mutation-policy.d.ts +7 -0
  20. package/dist/internal/tools/permissions/path-access-policy.d.ts +13 -0
  21. package/dist/internal/tools/permissions/workspace-path.d.ts +5 -0
  22. package/dist/internal/tools/policy-engine.d.ts +1 -0
  23. package/dist/internal/tools/process-utils.d.ts +11 -0
  24. package/dist/internal/tools/sandbox-policy-resolver.d.ts +2 -0
  25. package/dist/internal/tools/tool-executor.d.ts +2 -1
  26. package/dist/internal/tools/types.d.ts +66 -2
  27. package/dist/runtime/adapters/memory/memory-approval-store.d.ts +39 -0
  28. package/dist/runtime/adapters/memory/memory-file-mutation-store.d.ts +1 -1
  29. package/dist/runtime/application/approval-service.d.ts +69 -3
  30. package/dist/runtime/application/job-execution-facts.d.ts +2 -0
  31. package/dist/runtime/application/job-service-ownership.d.ts +5 -0
  32. package/dist/runtime/application/job-service.d.ts +9 -0
  33. package/dist/runtime/application/turn/turn-conversation-builder.d.ts +3 -3
  34. package/dist/runtime/application/turn/turn-runtime-config-resolver.d.ts +2 -2
  35. package/dist/runtime/application/undo-service.d.ts +4 -0
  36. package/dist/runtime/bootstrap/runtime-bootstrap-service.d.ts +2 -1
  37. package/dist/runtime/config/autopilot-settings.d.ts +9 -0
  38. package/dist/runtime/config/runtime-limits.d.ts +2 -4
  39. package/dist/runtime/domain/approval.d.ts +18 -0
  40. package/dist/runtime/domain/external-execution.d.ts +42 -0
  41. package/dist/runtime/domain/external-permissions.d.ts +32 -0
  42. package/dist/runtime/domain/frozen-run-config.d.ts +2 -0
  43. package/dist/runtime/domain/index.d.ts +6 -2
  44. package/dist/runtime/domain/job-service-url.d.ts +3 -0
  45. package/dist/runtime/domain/job.d.ts +18 -0
  46. package/dist/runtime/domain/sandbox-policy.d.ts +30 -0
  47. package/dist/runtime/domain/todo.d.ts +4 -0
  48. package/dist/runtime/ports/approval-store.d.ts +39 -1
  49. package/dist/runtime/ports/external-permission-projector.d.ts +14 -0
  50. package/dist/runtime/ports/file-mutation-store.d.ts +1 -1
  51. package/dist/runtime/ports/host-mutation-protection.d.ts +7 -0
  52. package/dist/runtime/ports/index.d.ts +7 -1
  53. package/dist/runtime/ports/sandbox-port.d.ts +1 -0
  54. package/dist/runtime/protocol/index.d.ts +1 -0
  55. package/dist/runtime/protocol/recoverable-turn-view.d.ts +1 -1
  56. package/dist/runtime/protocol/run-config.d.ts +3 -0
  57. package/dist/runtime/protocol/work-preview-capability.d.ts +23 -0
  58. package/package.json +1 -1
@@ -20,6 +20,7 @@ import type { CompletionPolicy } from "./kernel/completion-policy";
20
20
  import { type ModelBehaviorProfile } from "../runtime/provider/model-behavior-profile";
21
21
  import type { McpCapability } from "../runtime/protocol";
22
22
  import type { CredentialStore, FileMutationStore } from "../runtime/ports";
23
+ import type { WorkPreviewCapability } from "../runtime/protocol/work-preview-capability";
23
24
  import type { JobService } from "../runtime/application/job-service";
24
25
  import type { AgentUserQuestionCapability } from "../runtime/application/user-question-service";
25
26
  export interface RagCapability {
@@ -42,6 +43,7 @@ export interface AgentOptions {
42
43
  workspaceTrusted?: boolean;
43
44
  rag?: RagCapability;
44
45
  web?: WebCapability;
46
+ workPreview?: WorkPreviewCapability;
45
47
  databaseSearch?: DatabaseSearchCapability;
46
48
  focusedPdfFileName?: string;
47
49
  focusedResourceId?: string;
@@ -59,7 +61,15 @@ export interface AgentOptions {
59
61
  callId: string;
60
62
  toolName: string;
61
63
  inputHash: string;
64
+ constraint?: string;
62
65
  }) => Promise<boolean>;
66
+ resolveExternalRestriction?: (request: {
67
+ workspaceRoot: string;
68
+ toolName: string;
69
+ constraint: string;
70
+ }) => Promise<"allow" | "ask" | "deny">;
71
+ externalExecutionAuthority?: import("./tools/types").ExternalExecutionAuthority;
72
+ hostMutationProtection?: import("../runtime/ports/host-mutation-protection").HostMutationProtection;
63
73
  context?: AgentContextSnapshot;
64
74
  skills?: AgentSkillsCapability;
65
75
  inputInbox?: AgentInputInboxCapability;
@@ -113,7 +123,7 @@ export interface AgentCheckpoint {
113
123
  stepCount: number;
114
124
  messages: AgentMessage[];
115
125
  lease?: AgentLease;
116
- interruptionReason?: "stale_lease" | "repeated_tool_calls" | "runtime_budget" | "token_budget";
126
+ interruptionReason?: "stale_lease" | "repeated_tool_calls" | "runtime_budget" | "token_budget" | "write_verification";
117
127
  pendingCalls?: AgentToolCall[];
118
128
  pendingUserQuestion?: {
119
129
  callId: string;
@@ -132,6 +142,7 @@ export interface AgentCheckpoint {
132
142
  changedPaths: string[];
133
143
  verifiedPaths: string[];
134
144
  recoveryAttempts: number;
145
+ verificationOnly?: boolean;
135
146
  };
136
147
  fileReadStates?: Array<{
137
148
  path: string;
@@ -360,6 +371,7 @@ export type AgentLoopEvent = {
360
371
  turnId: string;
361
372
  checkpoint: AgentCheckpoint;
362
373
  error?: string;
374
+ errorCode?: string;
363
375
  termination?: {
364
376
  reason?: AgentTerminationReason;
365
377
  budget?: AgentTerminationBudget;
@@ -19,6 +19,10 @@ export type CompletionDecision = {
19
19
  } | {
20
20
  action: "fail";
21
21
  reason: string;
22
+ } | {
23
+ action: "pause";
24
+ reason: string;
25
+ message: string;
22
26
  };
23
27
  export interface CompletionPolicy {
24
28
  initialSignal(messages: readonly AgentMessage[]): CompletionIntentSignal;
@@ -30,6 +30,7 @@ export interface ContextCompactionManager {
30
30
  }): Promise<AgentCompactionResult>;
31
31
  }
32
32
  export interface PermissionContext {
33
+ externalExecutionAuthority?: import("../tools/types").ExternalExecutionAuthority;
33
34
  mode: ToolPermissionMode;
34
35
  workspaceTrusted?: boolean;
35
36
  resolvePersistentGrant?: (request: {
@@ -45,9 +46,16 @@ export interface PermissionContext {
45
46
  callId: string;
46
47
  toolName: string;
47
48
  inputHash: string;
49
+ constraint?: string;
48
50
  }) => Promise<boolean>;
51
+ resolveExternalRestriction?: (request: {
52
+ workspaceRoot: string;
53
+ toolName: string;
54
+ constraint: string;
55
+ }) => Promise<"allow" | "ask" | "deny">;
49
56
  }
50
57
  export interface RunContext {
58
+ hostMutationProtection?: import("../../runtime/ports/host-mutation-protection").HostMutationProtection;
51
59
  capabilityCeiling?: import("../../runtime/domain/product-mode").CapabilityCeiling;
52
60
  chat?: import("../tools/chat-tool-runtime").ChatToolRuntime;
53
61
  turnId: string;
@@ -10,6 +10,7 @@ export interface ToolSchedulerOptions {
10
10
  signal?: AbortSignal;
11
11
  maxRetries?: number;
12
12
  onProgress?: (callId: string, chunk: string) => void;
13
+ onResult?: (result: ScheduledToolResult) => void;
13
14
  }
14
15
  export declare function serializeToolResultForModel(result: ToolExecutionResult): string;
15
16
  export declare function createToolScheduler(registry: ToolRegistry, execute: (request: ToolExecutionRequest, options?: ToolExecutionOptions) => Promise<ToolExecutionResult>): {
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ import type { AgentToolDefinition } from "../types";
3
+ import type { WorkPreviewCapability, WorkPreviewPrepareResult } from "../../../runtime/protocol/work-preview-capability";
4
+ declare const schema: z.ZodObject<{
5
+ url: z.ZodString;
6
+ jobId: z.ZodOptional<z.ZodString>;
7
+ openWhen: z.ZodOptional<z.ZodEnum<{
8
+ now: "now";
9
+ after_turn: "after_turn";
10
+ }>>;
11
+ }, z.core.$strict>;
12
+ export declare function createOpenPreviewTool(input: {
13
+ capability: WorkPreviewCapability;
14
+ workspaceId: string;
15
+ sessionId: string;
16
+ turnId: string;
17
+ }): AgentToolDefinition<z.infer<typeof schema>, WorkPreviewPrepareResult>;
18
+ export {};
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import type { AgentToolDefinition } from "../types";
3
- declare const runCommandSchema: z.ZodObject<{
3
+ export declare const runCommandSchema: z.ZodObject<{
4
4
  program: z.ZodString;
5
5
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
6
6
  cwd: z.ZodDefault<z.ZodString>;
7
7
  timeoutMs: z.ZodDefault<z.ZodNumber>;
8
+ externalWriteTarget: z.ZodOptional<z.ZodString>;
8
9
  }, z.core.$strict>;
9
10
  export declare function createRunCommandTool(): AgentToolDefinition<z.infer<typeof runCommandSchema>, Record<string, unknown>>;
10
- export {};
@@ -5,6 +5,15 @@ declare const schema: z.ZodObject<{
5
5
  program: z.ZodString;
6
6
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
7
7
  cwd: z.ZodDefault<z.ZodString>;
8
+ externalWriteTarget: z.ZodOptional<z.ZodString>;
9
+ serviceUrl: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strict>;
11
+ export declare const startBackgroundJobSchema: z.ZodObject<{
12
+ program: z.ZodString;
13
+ args: z.ZodDefault<z.ZodArray<z.ZodString>>;
14
+ cwd: z.ZodDefault<z.ZodString>;
15
+ externalWriteTarget: z.ZodOptional<z.ZodString>;
16
+ serviceUrl: z.ZodOptional<z.ZodString>;
8
17
  }, z.core.$strict>;
9
18
  export declare function createStartBackgroundJobTool(input: {
10
19
  jobs: JobService;
@@ -11,6 +11,20 @@ declare const inputSchema: z.ZodObject<{
11
11
  in_progress: "in_progress";
12
12
  }>;
13
13
  }, z.core.$strict>>;
14
+ fileTargets: z.ZodOptional<z.ZodArray<z.ZodObject<{
15
+ path: z.ZodString;
16
+ operation: z.ZodEnum<{
17
+ create: "create";
18
+ edit: "edit";
19
+ }>;
20
+ }, z.core.$strict>>>;
21
+ externalFileTargets: z.ZodOptional<z.ZodArray<z.ZodObject<{
22
+ path: z.ZodString;
23
+ operation: z.ZodEnum<{
24
+ create: "create";
25
+ edit: "edit";
26
+ }>;
27
+ }, z.core.$strict>>>;
14
28
  }, z.core.$strict>;
15
29
  type TodoWriteInput = z.infer<typeof inputSchema>;
16
30
  export declare function createTodoWriteTool(): AgentToolDefinition<TodoWriteInput, TodoWriteResult>;
@@ -45,5 +45,10 @@ export declare class McpStdioRuntime {
45
45
  private handleLine;
46
46
  private failServer;
47
47
  private resolveSandboxScope;
48
+ private isHostExecutionPlatform;
48
49
  private releaseSandbox;
49
50
  }
51
+ export declare function resolveHostServerCommand(command: string, args: readonly string[]): {
52
+ executable: string;
53
+ args: string[];
54
+ };
@@ -0,0 +1 @@
1
+ export declare function hashNormalizedToolInput(input: unknown): string;
@@ -13,3 +13,14 @@ export interface CommandPolicyResult {
13
13
  export declare const defaultCommandRules: CommandRule[];
14
14
  export declare function normalizeProgramName(program: string): string;
15
15
  export declare function decideCommandPermission(program: string, args: string[], rules?: CommandRule[]): CommandPolicyResult;
16
+ export declare function resolveCommandAuthorizationIdentity(program: string, platform?: NodeJS.Platform): string;
17
+ export declare const WORKSPACE_COMMAND_CONSTRAINT_PREFIX = "cmd:v2:";
18
+ export declare const LEGACY_WORKSPACE_COMMAND_CONSTRAINT_PREFIX = "cmd:v1:";
19
+ export declare function computeWorkspaceCommandConstraint(input: {
20
+ workspaceRoot: string;
21
+ cwd: string;
22
+ program: string;
23
+ args: string[];
24
+ platform?: NodeJS.Platform;
25
+ }): string;
26
+ export declare function isWorkspaceCommandConstraint(value: string | undefined): boolean;
@@ -0,0 +1,14 @@
1
+ import { type ExternalExecutionAuthorization, type ExternalExecutionTarget, type ExternalWriteCapability } from "../../../runtime/domain/external-execution";
2
+ import type { ToolExecutionContext } from "../types";
3
+ export declare function sealExternalExecutionAuthorization(value: ExternalExecutionAuthorization): ExternalExecutionAuthorization;
4
+ export declare function resolveExternalExecutionTarget(workspaceRoot: string | undefined, input: unknown): Promise<ExternalExecutionTarget | undefined>;
5
+ export declare function externalExecutionTargetLabel(target: ExternalExecutionTarget): string;
6
+ export declare function issueExternalWriteCapability(input: {
7
+ target: ExternalExecutionTarget;
8
+ toolName: string;
9
+ callId: string;
10
+ inputHash: string;
11
+ authorization: ExternalExecutionAuthorization;
12
+ }): ExternalWriteCapability;
13
+ export declare function claimExternalWriteCapability(toolName: string, input: unknown, context: ToolExecutionContext): Promise<void>;
14
+ export declare function assertExternalJobDispatch(input: unknown, context: ToolExecutionContext): Promise<void>;
@@ -1,2 +1,9 @@
1
1
  import type { ToolExecutionContext } from "../types";
2
+ import type { ResolvedFileTarget } from "./path-access-policy";
3
+ import type { HostMutationProtection } from "../../../runtime/ports/host-mutation-protection";
4
+ export declare function assertHostMutationTargetAllowed(context: {
5
+ workspaceRoot?: string;
6
+ hostMutationProtection?: HostMutationProtection;
7
+ }, inputPath: string): Promise<void>;
2
8
  export declare function assertFileMutationAllowed(context: ToolExecutionContext): void;
9
+ export declare function assertFileMutationAuthorized(context: Pick<ToolExecutionContext, "fileMutationAuthorization">, target: Pick<ResolvedFileTarget, "isExternal" | "canonicalTarget" | "canonicalWorkspace">, operation: string): void;
@@ -0,0 +1,13 @@
1
+ import type { ToolExecutionContext } from "../types";
2
+ export interface ResolvedFileTarget {
3
+ absolutePath: string;
4
+ canonicalWorkspace: string;
5
+ canonicalTarget: string;
6
+ isExternal: boolean;
7
+ exists: boolean;
8
+ relativePath?: string;
9
+ }
10
+ export declare function resolveFileTarget(workspaceRoot: string | undefined, inputPath: string): Promise<ResolvedFileTarget>;
11
+ export declare function getReadStateKey(target: Pick<ResolvedFileTarget, "isExternal" | "canonicalTarget" | "relativePath">): string;
12
+ export declare function buildExternalConstraint(canonicalTarget: string): string;
13
+ export declare function resolveExternalTargetRestriction(context: Pick<ToolExecutionContext, "resolveExternalRestriction">, target: ResolvedFileTarget, toolName: string): Promise<"allow" | "ask" | "deny">;
@@ -3,6 +3,11 @@ export interface WorkspacePath {
3
3
  relativePath: string;
4
4
  exists: boolean;
5
5
  }
6
+ export declare function isInsideRoot(rootPath: string, targetPath: string): boolean;
7
+ export declare function findExistingRealpath(targetPath: string): Promise<{
8
+ realPath: string;
9
+ exists: boolean;
10
+ }>;
6
11
  export declare function resolveWorkspacePath(workspaceRoot: string | undefined, inputPath: string): Promise<WorkspacePath>;
7
12
  export declare function assertRegularFile(targetPath: string): Promise<void>;
8
13
  export declare function assertDirectory(targetPath: string): Promise<void>;
@@ -7,6 +7,7 @@ export interface PolicyEvaluationInput {
7
7
  sandbox?: {
8
8
  available: boolean;
9
9
  };
10
+ hostExecution?: boolean;
10
11
  }
11
12
  export declare class PolicyEngine {
12
13
  canUsePersistentGrant(context: ToolExecutionContext, facts: ToolActionFacts): boolean;
@@ -3,6 +3,13 @@ export declare class ProcessTreeTerminationError extends Error {
3
3
  readonly code: "FAILED" | "TIMEOUT";
4
4
  constructor(code: "FAILED" | "TIMEOUT");
5
5
  }
6
+ export declare const SANDBOX_START_MAX_ATTEMPTS = 3;
7
+ export declare function isSandboxAvailabilityFailureCode(code: string): boolean;
8
+ export declare class SandboxPrepareExhaustedError extends Error {
9
+ readonly code: string;
10
+ readonly diagnostics: readonly string[];
11
+ constructor(diagnostics: readonly string[]);
12
+ }
6
13
  export declare class BoundedOutputBuffer {
7
14
  private readonly outputLimit;
8
15
  private readonly head;
@@ -33,6 +40,10 @@ export declare function terminateManagedProcessTree(child: ChildProcess, options
33
40
  timeoutMs?: number;
34
41
  }): Promise<void>;
35
42
  export declare function getPlatformExecutable(program: string): string;
43
+ export declare function resolveWindowsPackageManagerCommand(program: string, args: readonly string[]): {
44
+ executable: string;
45
+ args: string[];
46
+ } | null;
36
47
  export declare function resolveManagedCommand(program: string, args: readonly string[]): {
37
48
  executable: string;
38
49
  args: string[];
@@ -1,6 +1,8 @@
1
1
  import type { SandboxCapabilityReport, SandboxEnforcement, SandboxMode, SandboxPolicy } from "../../runtime/domain/sandbox-policy";
2
2
  import type { ToolPermissionMode } from "./types";
3
+ import type { ExternalWriteCapability } from "../../runtime/domain/external-execution";
3
4
  export interface SandboxResolverInput {
5
+ externalWriteCapability?: ExternalWriteCapability;
4
6
  mode: SandboxMode;
5
7
  workspaceRoot?: string;
6
8
  tempRoot?: string;
@@ -10,6 +10,7 @@ export declare class ToolExecutor {
10
10
  status: "error";
11
11
  }> | undefined>;
12
12
  execute(request: ToolExecutionRequest, options?: ToolExecutionOptions): Promise<ToolExecutionResult>;
13
- private resolveSandboxScope;
13
+ private resolveSandboxProbe;
14
14
  private consumeApproval;
15
+ private assertLatestExternalRestrictionAllowed;
15
16
  }
@@ -3,15 +3,37 @@ import type { VisionAnalyzer } from "../../runtime/provider/vision-analyzer";
3
3
  import type { FileMutationStore, SandboxPort } from "../../runtime/ports";
4
4
  import type { SandboxMode, SandboxPolicy } from "../../runtime/domain/sandbox-policy";
5
5
  import type { UserQuestionRequest } from "../../runtime/domain";
6
+ import type { ExternalExecutionAuthorization, ExternalExecutionTarget } from "../../runtime/domain/external-execution";
7
+ export interface ExternalExecutionAuthority {
8
+ freeze(input: {
9
+ approval: ToolApprovalRequest;
10
+ input: unknown;
11
+ }): Promise<void>;
12
+ authorize(input: {
13
+ toolName: string;
14
+ input: unknown;
15
+ callId: string;
16
+ inputHash: string;
17
+ constraint: string;
18
+ approval?: {
19
+ approvalId: string;
20
+ decision: ToolApprovalDecision;
21
+ };
22
+ }): Promise<ExternalExecutionAuthorization | null>;
23
+ }
6
24
  export interface SandboxExecutionBinding {
7
25
  port: SandboxPort;
8
26
  mode: SandboxMode;
9
27
  tempRoot?: string;
10
28
  }
11
- export interface SandboxExecutionScope {
29
+ export type SandboxExecutionScope = {
30
+ execution?: "sandboxed";
12
31
  port: SandboxPort;
13
32
  policy: SandboxPolicy;
14
- }
33
+ } | {
34
+ execution: "host";
35
+ policy: SandboxPolicy;
36
+ };
15
37
  export type ToolPermissionDecision = "allow" | "approval_required" | "deny";
16
38
  export type ToolApprovalDecision = "allow_once" | "allow_session" | "allow_workspace" | "deny";
17
39
  export type ToolPermissionMode = "ask" | "auto_approve" | "full_access";
@@ -89,6 +111,15 @@ export type ToolDisplayDetail = {
89
111
  host: string;
90
112
  contentType: string;
91
113
  truncated: boolean;
114
+ } | {
115
+ kind: "open_preview";
116
+ previewId: string;
117
+ hostLabel: string;
118
+ copyUrl: string;
119
+ openWhen: import("../../runtime/protocol/work-preview-capability").WorkPreviewOpenWhen;
120
+ state: "prepared";
121
+ jobId?: string;
122
+ autoOpen?: boolean;
92
123
  };
93
124
  export interface ToolJobDisplayFacts {
94
125
  action: "start" | "list" | "read" | "stop";
@@ -113,6 +144,8 @@ export interface ToolDisplayFacts {
113
144
  removed?: number;
114
145
  truncated?: boolean;
115
146
  };
147
+ executionMode?: "sandboxed" | "unisolated" | "unavailable";
148
+ diagnostics?: string[];
116
149
  }
117
150
  export interface ApprovalDisplayFacts {
118
151
  operation: string;
@@ -121,6 +154,10 @@ export interface ApprovalDisplayFacts {
121
154
  resource?: string;
122
155
  risk?: string;
123
156
  actionPreview?: string;
157
+ cwd?: string;
158
+ unknownScope?: boolean;
159
+ executionMode?: ToolDisplayFacts["executionMode"];
160
+ hostExecution?: true;
124
161
  allowedDecisions: ToolApprovalDecision[];
125
162
  }
126
163
  export interface ToolApprovalRequest {
@@ -134,6 +171,7 @@ export interface ToolApprovalRequest {
134
171
  preview: Record<string, unknown>;
135
172
  expiresAt: string;
136
173
  allowedDecisions?: ToolApprovalDecision[];
174
+ taskFileSet?: import("../../runtime/domain/approval").TaskFileTarget[];
137
175
  display?: ApprovalDisplayFacts;
138
176
  }
139
177
  export interface ToolExecutionRequest {
@@ -205,10 +243,19 @@ export interface ToolActionFacts {
205
243
  stableConstraint?: string;
206
244
  hardDenyReason?: string;
207
245
  requiresApproval?: boolean;
246
+ externalMutation?: boolean;
247
+ externalTarget?: {
248
+ canonicalTarget: string;
249
+ canonicalWorkspace: string;
250
+ };
251
+ externalRestriction?: "allow" | "ask" | "deny";
252
+ externalExecutionTarget?: ExternalExecutionTarget;
208
253
  approval?: {
209
254
  reason: string;
210
255
  preview?: Record<string, unknown>;
211
256
  };
257
+ taskFileSet?: import("../../runtime/domain/approval").TaskFileTarget[];
258
+ commandCwd?: string;
212
259
  }
213
260
  export interface ToolPolicyResult {
214
261
  decision: ToolPermissionDecision;
@@ -233,6 +280,10 @@ export interface ToolEvent {
233
280
  errorCode?: string;
234
281
  }
235
282
  export interface ToolExecutionContext {
283
+ hostMutationProtection?: import("../../runtime/ports/host-mutation-protection").HostMutationProtection;
284
+ executionSessionId?: string;
285
+ externalExecutionAuthority?: ExternalExecutionAuthority;
286
+ sandboxExecutionOverride?: "direct";
236
287
  capabilityCeiling?: import("../../runtime/domain/product-mode").CapabilityCeiling;
237
288
  workspaceRoot?: string;
238
289
  permissionMode: ToolPermissionMode;
@@ -279,7 +330,19 @@ export interface ToolExecutionContext {
279
330
  callId: string;
280
331
  toolName: string;
281
332
  inputHash: string;
333
+ constraint?: string;
282
334
  }) => Promise<boolean>;
335
+ resolveExternalRestriction?: (request: {
336
+ workspaceRoot: string;
337
+ toolName: string;
338
+ constraint: string;
339
+ }) => Promise<"allow" | "ask" | "deny">;
340
+ fileMutationAuthorization?: {
341
+ canonicalTarget: string;
342
+ canonicalWorkspace: string;
343
+ operation: string;
344
+ constraint: string;
345
+ };
283
346
  visionAnalyzer?: VisionAnalyzer;
284
347
  allowedTools?: string[];
285
348
  sandbox?: SandboxExecutionBinding;
@@ -311,6 +374,7 @@ export interface AgentToolDefinition<TInput, TOutput> {
311
374
  createActionFacts(input: TInput, context: ToolExecutionContext): ToolActionFacts | Promise<ToolActionFacts>;
312
375
  execute(input: TInput, context: ToolExecutionContext): Promise<TOutput>;
313
376
  serializeOutput(output: TOutput): unknown;
377
+ projectDisplayDetail?(output: TOutput): ToolDisplayDetail | undefined;
314
378
  createExecutionResult?(input: TInput, output: TOutput, context: {
315
379
  callId: string;
316
380
  toolName: string;
@@ -1,8 +1,40 @@
1
1
  import type { ApprovalStore, GetApprovalDecisionInput, GetPersistentGrantInput } from "../../ports/approval-store";
2
2
  import type { ApprovalDecision, PersistentGrant } from "../../domain/approval";
3
+ import type { ExternalExecutionApproval } from "../../domain/external-execution";
4
+ import type { ExternalFileApproval } from "../../domain/external-permissions";
5
+ import type { SandboxDegradeApproval } from "../../domain/sandbox-policy";
3
6
  export declare class MemoryApprovalStore implements ApprovalStore {
4
7
  private decisions;
5
8
  private grants;
9
+ private executionApprovals;
10
+ private consumedExecutions;
11
+ private fileApprovals;
12
+ private consumedFiles;
13
+ private degradeApprovals;
14
+ private consumedDegrades;
15
+ saveExecutionApproval(request: ExternalExecutionApproval): Promise<boolean>;
16
+ getExecutionApproval(input: GetApprovalDecisionInput): Promise<ExternalExecutionApproval | null>;
17
+ consumeExecutionApproval(input: GetApprovalDecisionInput & {
18
+ constraint: string;
19
+ callId: string;
20
+ normalizedInputHash: string;
21
+ now: string;
22
+ }): Promise<boolean>;
23
+ saveFileApproval(request: ExternalFileApproval): Promise<boolean>;
24
+ getFileApproval(input: GetApprovalDecisionInput): Promise<ExternalFileApproval | null>;
25
+ consumeFileApproval(input: GetApprovalDecisionInput & {
26
+ constraint: string;
27
+ callId: string;
28
+ normalizedInputHash: string;
29
+ now: string;
30
+ }): Promise<boolean>;
31
+ saveDegradeApproval(request: SandboxDegradeApproval): Promise<boolean>;
32
+ consumeDegradeApproval(input: GetApprovalDecisionInput & {
33
+ constraint: string;
34
+ callId: string;
35
+ normalizedInputHash: string;
36
+ now: string;
37
+ }): Promise<boolean>;
6
38
  getDecision(input: GetApprovalDecisionInput): Promise<ApprovalDecision | null>;
7
39
  saveDecision(decision: ApprovalDecision): Promise<boolean>;
8
40
  getPersistentGrant(input: GetPersistentGrantInput): Promise<PersistentGrant | null>;
@@ -11,6 +43,13 @@ export declare class MemoryApprovalStore implements ApprovalStore {
11
43
  }): Promise<PersistentGrant>;
12
44
  deletePersistentGrant(input: GetPersistentGrantInput): Promise<boolean>;
13
45
  deleteBySession(sessionId: string): Promise<void>;
46
+ listPersistentGrants(input: {
47
+ workspaceRoot?: string;
48
+ sessionId?: string;
49
+ }): Promise<PersistentGrant[]>;
50
+ setGrantProjection(input: GetPersistentGrantInput & {
51
+ projection: "synced" | "pending";
52
+ }): Promise<PersistentGrant | null>;
14
53
  private decisionKey;
15
54
  private grantKey;
16
55
  }
@@ -12,5 +12,5 @@ export declare class MemoryFileMutationStore implements FileMutationStore {
12
12
  saveUndoTransaction(transaction: UndoTransaction): Promise<void>;
13
13
  listUndoTransactions(sessionId: string): Promise<UndoTransaction[]>;
14
14
  deleteBySession(sessionId: string): Promise<void>;
15
- withWorkspaceLock<T>(_workspaceRoot: string, operation: () => Promise<T>): Promise<T>;
15
+ withWorkspaceLock<T>(_workspaceRoot: string, operation: () => Promise<T>, canonicalTargets?: readonly string[]): Promise<T>;
16
16
  }
@@ -1,11 +1,18 @@
1
- import type { ApprovalStore, CheckpointStore, Clock, TranscriptStore, TurnStore } from "../ports";
2
- import type { ApprovalDecision, SubmitApprovalInput } from "../domain/approval";
1
+ import type { ApprovalStore, CheckpointStore, Clock, ExternalPermissionProjector, TranscriptStore, TurnStore } from "../ports";
2
+ import { type ApprovalDecision, type PersistentGrant, type SubmitApprovalInput } from "../domain/approval";
3
+ import { type ExternalExecutionAuthorization } from "../domain/external-execution";
4
+ import type { ExternalExecutionAuthority } from "../../internal/tools/types";
3
5
  export interface ApprovalServiceDependencies {
4
6
  approvalStore: ApprovalStore;
5
7
  checkpointStore: CheckpointStore;
6
8
  transcriptStore: TranscriptStore;
7
9
  turnStore: TurnStore;
8
10
  clock: Clock;
11
+ externalRuleProjector?: ExternalPermissionProjector;
12
+ }
13
+ export interface RevokePersistentGrantResult {
14
+ deleted: boolean;
15
+ ruleRemoved: boolean;
9
16
  }
10
17
  export interface ApprovalService {
11
18
  submit(input: SubmitApprovalInput): Promise<ApprovalDecision>;
@@ -20,5 +27,64 @@ export interface ApprovalService {
20
27
  toolName: string;
21
28
  constraint: string;
22
29
  }): Promise<boolean>;
30
+ listPersistentGrants(input?: {
31
+ workspaceRoot?: string;
32
+ sessionId?: string;
33
+ }): Promise<PersistentGrant[]>;
34
+ revokePersistentGrant(input: {
35
+ workspaceRoot: string;
36
+ sessionId: string;
37
+ toolName: string;
38
+ constraint: string;
39
+ }): Promise<RevokePersistentGrantResult>;
40
+ }
41
+ export interface InternalApprovalService extends ApprovalService {
42
+ freezeExecutionApproval(input: {
43
+ sessionId: string;
44
+ turnId: string;
45
+ workspaceRoot: string;
46
+ } & Parameters<ExternalExecutionAuthority["freeze"]>[0]): Promise<void>;
47
+ authorizeExecution(input: {
48
+ sessionId: string;
49
+ turnId: string;
50
+ workspaceRoot: string;
51
+ } & Parameters<ExternalExecutionAuthority["authorize"]>[0]): Promise<ExternalExecutionAuthorization | null>;
52
+ resolveExternalRestriction(input: {
53
+ workspaceRoot: string;
54
+ toolName: string;
55
+ constraint: string;
56
+ }): Promise<"allow" | "ask" | "deny">;
57
+ consumeFileApproval(input: {
58
+ sessionId: string;
59
+ turnId: string;
60
+ approvalId: string;
61
+ constraint: string;
62
+ callId: string;
63
+ normalizedInputHash: string;
64
+ now: string;
65
+ }): Promise<boolean>;
66
+ consumeDegradeApproval(input: {
67
+ sessionId: string;
68
+ turnId: string;
69
+ approvalId: string;
70
+ constraint: string;
71
+ callId: string;
72
+ normalizedInputHash: string;
73
+ now: string;
74
+ }): Promise<boolean>;
75
+ hasTaskFileSetGrant(input: {
76
+ sessionId: string;
77
+ turnId: string;
78
+ workspaceRoot: string;
79
+ path: string;
80
+ operation: "create" | "edit";
81
+ }): Promise<boolean>;
82
+ hasExternalTaskFileSetGrant(input: {
83
+ sessionId: string;
84
+ turnId: string;
85
+ workspaceRoot: string;
86
+ canonicalTarget: string;
87
+ operation: "create" | "edit";
88
+ }): Promise<boolean>;
23
89
  }
24
- export declare function createApprovalService(dependencies: ApprovalServiceDependencies): ApprovalService;
90
+ export declare function createApprovalService(dependencies: ApprovalServiceDependencies): InternalApprovalService;
@@ -0,0 +1,2 @@
1
+ import type { JobExecutionFacts } from "../domain/job";
2
+ export declare function projectJobCloseFacts(stderr: string, signal?: NodeJS.Signals | null): JobExecutionFacts;
@@ -0,0 +1,5 @@
1
+ export interface JobServiceOwnershipProbe {
2
+ listenerPids(port: number): Promise<readonly number[] | undefined>;
3
+ ancestry(pid: number): Promise<readonly number[] | undefined>;
4
+ }
5
+ export declare function createDefaultJobServiceOwnershipProbe(): JobServiceOwnershipProbe;