@autopilot-agent/core 0.1.0 → 0.3.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 (119) hide show
  1. package/README.md +57 -3
  2. package/dist/experimental/index.js +67 -59
  3. package/dist/experimental/index.mjs +67 -59
  4. package/dist/failure.d.ts +3 -0
  5. package/dist/failure.js +1 -0
  6. package/dist/failure.mjs +1 -0
  7. package/dist/index.d.ts +35 -7
  8. package/dist/index.js +242 -211
  9. package/dist/index.mjs +242 -211
  10. package/dist/internal/agent-runtime.d.ts +92 -3
  11. package/dist/internal/kernel/completion-policy.d.ts +4 -0
  12. package/dist/internal/kernel/model-sampler.d.ts +5 -0
  13. package/dist/internal/kernel/run-context.d.ts +12 -0
  14. package/dist/internal/kernel/session-images.d.ts +21 -0
  15. package/dist/internal/kernel/turn-usage.d.ts +13 -0
  16. package/dist/internal/lib/document-parser.js +2 -2
  17. package/dist/internal/lib/image-normalization.d.ts +16 -0
  18. package/dist/internal/lib/llm.d.ts +6 -1
  19. package/dist/internal/lib/llm.js +3 -3
  20. package/dist/internal/lib/pdf-processor.js +1 -1
  21. package/dist/internal/tool-scheduler.d.ts +1 -0
  22. package/dist/internal/tools/builtins/open-preview-tool.d.ts +22 -0
  23. package/dist/internal/tools/builtins/read-output-budget.d.ts +5 -0
  24. package/dist/internal/tools/builtins/render-ui-tool.d.ts +11 -0
  25. package/dist/internal/tools/builtins/run-command-tool.d.ts +2 -2
  26. package/dist/internal/tools/builtins/start-background-job-tool.d.ts +9 -0
  27. package/dist/internal/tools/builtins/static-preview.d.ts +15 -0
  28. package/dist/internal/tools/builtins/thread-tools.d.ts +125 -0
  29. package/dist/internal/tools/builtins/todo-write-tool.d.ts +14 -0
  30. package/dist/internal/tools/builtins/vision-analyze-tool.d.ts +1 -0
  31. package/dist/internal/tools/mcp-images.d.ts +6 -0
  32. package/dist/internal/tools/mcp-runtime.d.ts +9 -0
  33. package/dist/internal/tools/normalized-tool-input.d.ts +1 -0
  34. package/dist/internal/tools/permissions/command-policy.d.ts +11 -0
  35. package/dist/internal/tools/permissions/external-execution-policy.d.ts +14 -0
  36. package/dist/internal/tools/permissions/mutation-policy.d.ts +7 -0
  37. package/dist/internal/tools/permissions/path-access-policy.d.ts +13 -0
  38. package/dist/internal/tools/permissions/workspace-path.d.ts +5 -0
  39. package/dist/internal/tools/policy-engine.d.ts +1 -0
  40. package/dist/internal/tools/process-utils.d.ts +12 -0
  41. package/dist/internal/tools/sandbox-policy-resolver.d.ts +2 -0
  42. package/dist/internal/tools/thread-observation-display.d.ts +2 -0
  43. package/dist/internal/tools/tool-executor.d.ts +2 -1
  44. package/dist/internal/tools/types.d.ts +84 -2
  45. package/dist/internal/types/agent-message.d.ts +11 -1
  46. package/dist/runtime/adapters/memory/memory-approval-store.d.ts +39 -0
  47. package/dist/runtime/adapters/memory/memory-file-mutation-store.d.ts +1 -1
  48. package/dist/runtime/adapters/memory/memory-lease-store.d.ts +6 -0
  49. package/dist/runtime/adapters/memory/memory-session-store.d.ts +14 -0
  50. package/dist/runtime/adapters/memory/memory-thread-store.d.ts +24 -0
  51. package/dist/runtime/adapters/memory/memory-transcript-store.d.ts +9 -0
  52. package/dist/runtime/application/approval-service.d.ts +74 -3
  53. package/dist/runtime/application/input-inbox-service.d.ts +1 -1
  54. package/dist/runtime/application/job-execution-facts.d.ts +2 -0
  55. package/dist/runtime/application/job-service-ownership.d.ts +5 -0
  56. package/dist/runtime/application/job-service.d.ts +9 -0
  57. package/dist/runtime/application/session-service.d.ts +8 -0
  58. package/dist/runtime/application/thread-delivery-service.d.ts +97 -0
  59. package/dist/runtime/application/thread-execution-host.d.ts +7 -0
  60. package/dist/runtime/application/thread-service.d.ts +1027 -0
  61. package/dist/runtime/application/thread-task.d.ts +11 -0
  62. package/dist/runtime/application/thread-tool-binding.d.ts +218 -0
  63. package/dist/runtime/application/turn/turn-compaction-coordinator.d.ts +2 -1
  64. package/dist/runtime/application/turn/turn-conversation-builder.d.ts +3 -3
  65. package/dist/runtime/application/turn/turn-event-recorder.d.ts +1 -0
  66. package/dist/runtime/application/turn/turn-execution-view.d.ts +43 -0
  67. package/dist/runtime/application/turn/turn-recovery-service.d.ts +12 -0
  68. package/dist/runtime/application/turn/turn-runtime-config-resolver.d.ts +2 -2
  69. package/dist/runtime/application/turn-service.d.ts +28 -0
  70. package/dist/runtime/application/undo-service.d.ts +4 -0
  71. package/dist/runtime/application/user-question-service.d.ts +1 -0
  72. package/dist/runtime/bootstrap/runtime-bootstrap-service.d.ts +2 -1
  73. package/dist/runtime/config/autopilot-settings.d.ts +9 -0
  74. package/dist/runtime/config/runtime-limits.d.ts +2 -4
  75. package/dist/runtime/domain/approval.d.ts +18 -0
  76. package/dist/runtime/domain/external-execution.d.ts +42 -0
  77. package/dist/runtime/domain/external-permissions.d.ts +32 -0
  78. package/dist/runtime/domain/frozen-run-config.d.ts +3 -0
  79. package/dist/runtime/domain/index.d.ts +13 -3
  80. package/dist/runtime/domain/input-inbox.d.ts +16 -0
  81. package/dist/runtime/domain/job-service-url.d.ts +3 -0
  82. package/dist/runtime/domain/job.d.ts +18 -0
  83. package/dist/runtime/domain/sandbox-policy.d.ts +30 -0
  84. package/dist/runtime/domain/session-presentation.d.ts +9 -0
  85. package/dist/runtime/domain/thread-collaboration.d.ts +179 -0
  86. package/dist/runtime/domain/todo.d.ts +4 -0
  87. package/dist/runtime/ports/approval-store.d.ts +39 -1
  88. package/dist/runtime/ports/external-permission-projector.d.ts +14 -0
  89. package/dist/runtime/ports/file-mutation-store.d.ts +1 -1
  90. package/dist/runtime/ports/host-mutation-protection.d.ts +7 -0
  91. package/dist/runtime/ports/index.d.ts +13 -1
  92. package/dist/runtime/ports/lease-store.d.ts +4 -0
  93. package/dist/runtime/ports/sandbox-port.d.ts +1 -0
  94. package/dist/runtime/ports/session-image-store.d.ts +26 -0
  95. package/dist/runtime/ports/session-store.d.ts +16 -0
  96. package/dist/runtime/ports/thread-handoff.d.ts +14 -0
  97. package/dist/runtime/ports/thread-store.d.ts +15 -0
  98. package/dist/runtime/ports/transcript-store.d.ts +8 -0
  99. package/dist/runtime/protocol/chat-capability.d.ts +1 -0
  100. package/dist/runtime/protocol/error-code.d.ts +1 -1
  101. package/dist/runtime/protocol/index.d.ts +1 -0
  102. package/dist/runtime/protocol/recoverable-turn-view.d.ts +4 -1
  103. package/dist/runtime/protocol/run-config.d.ts +4 -0
  104. package/dist/runtime/protocol/threads-capability.d.ts +14 -0
  105. package/dist/runtime/protocol/work-preview-capability.d.ts +24 -0
  106. package/dist/runtime/provider/anthropic-messages-adapter.d.ts +4 -2
  107. package/dist/runtime/provider/frozen-provider-config.d.ts +1 -0
  108. package/dist/runtime/provider/index.d.ts +1 -1
  109. package/dist/runtime/provider/model-capability-catalog.d.ts +2 -0
  110. package/dist/runtime/provider/openai-chat-completions-adapter.d.ts +2 -1
  111. package/dist/runtime/provider/provider-failure-guidance.d.ts +4 -0
  112. package/dist/runtime/provider/provider-failure-normalization.d.ts +9 -0
  113. package/dist/runtime/public/agent-runtime.d.ts +4 -0
  114. package/dist/ui/catalog.d.ts +870 -0
  115. package/dist/ui/document.d.ts +580 -0
  116. package/dist/ui/index.d.ts +4 -0
  117. package/dist/ui/index.js +1 -0
  118. package/dist/ui/index.mjs +1 -0
  119. package/package.json +17 -1
@@ -0,0 +1,15 @@
1
+ import type { JobService } from "../../../runtime/application/job-service";
2
+ import type { ToolExecutionContext } from "../types";
3
+ export declare const STATIC_PREVIEW_SCRIPT = "const http=require('node:http'),fs=require('node:fs'),path=require('node:path');const file=process.argv[1],port=Number(process.argv[2]);const route='/'+encodeURIComponent(path.basename(file));const server=http.createServer(function serve(req,res){if(!['GET','HEAD'].includes(req.method)||req.url!==route){res.writeHead(404);return res.end();}fs.realpath(file,function resolved(err,actual){if(err||actual!==file){res.writeHead(404);return res.end();}res.writeHead(200,{'Content-Type':'text/html; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'});if(req.method==='HEAD')return res.end();const stream=fs.createReadStream(file);stream.on('error',function failed(){res.destroy();});stream.pipe(res);});});server.listen(port,'127.0.0.1');";
4
+ export declare function resolveStaticPreviewFile(workspaceRoot: string | undefined, staticPath: string): Promise<string>;
5
+ export declare function prepareStaticPreview(input: {
6
+ jobs: JobService;
7
+ workspaceId: string;
8
+ workspaceRoot: string;
9
+ sessionId: string;
10
+ turnId: string;
11
+ staticPath: string;
12
+ }, context: ToolExecutionContext): Promise<{
13
+ url: string;
14
+ jobId: string;
15
+ }>;
@@ -0,0 +1,125 @@
1
+ import type { AgentThreadsCapability } from "../../../runtime/application/thread-tool-binding";
2
+ import type { AgentToolDefinition } from "../types";
3
+ export declare function createThreadTools(capability: AgentThreadsCapability): {
4
+ resumeThread: AgentToolDefinition<{
5
+ threadId: string;
6
+ expectedTurnId: string;
7
+ groupId?: string | undefined;
8
+ }, {
9
+ accepted: true;
10
+ controlId: string;
11
+ recoveryAction?: "open_target_continue";
12
+ }>;
13
+ createThread: AgentToolDefinition<{
14
+ groupId?: string | undefined;
15
+ title?: string | undefined;
16
+ roleLabel?: string | undefined;
17
+ modelRef?: {
18
+ provider: string;
19
+ modelId: string;
20
+ } | undefined;
21
+ reasoningEffort?: "low" | "medium" | "high" | "max" | "none" | undefined;
22
+ }, {
23
+ threadId: string;
24
+ groupId: string;
25
+ parentThreadId: string;
26
+ relativeLink: string;
27
+ }>;
28
+ listThreads: AgentToolDefinition<{
29
+ groupId?: string | undefined;
30
+ cursor?: string | undefined;
31
+ limit?: number | undefined;
32
+ }, {
33
+ items: import("../../../runtime/application/thread-tool-binding").AgentThreadMemberView[];
34
+ nextCursor?: string;
35
+ }>;
36
+ readThread: AgentToolDefinition<{
37
+ threadId: string;
38
+ groupId?: string | undefined;
39
+ cursor?: string | undefined;
40
+ limit?: number | undefined;
41
+ }, import("../../../runtime/application/thread-tool-binding").AgentThreadReadResult>;
42
+ sendThread: AgentToolDefinition<{
43
+ threadId: string;
44
+ content: string;
45
+ groupId?: string | undefined;
46
+ mode?: "notify" | "run" | "steer" | undefined;
47
+ replyTo?: string | undefined;
48
+ expectedTurnId?: string | undefined;
49
+ handoff?: {
50
+ title: string;
51
+ markdown: string;
52
+ } | undefined;
53
+ }, {
54
+ messageId: string;
55
+ mode: import("../../..").ThreadMessage["mode"];
56
+ expectedTurnId?: string;
57
+ taskId?: string;
58
+ deliverySeq: number;
59
+ deliveryStatus: import("../../..").ThreadMessage["deliveryStatus"];
60
+ handoffRef?: import("../../..").ThreadHandoffRef;
61
+ }>;
62
+ waitThreads: AgentToolDefinition<{
63
+ targets: {
64
+ threadId: string;
65
+ taskId?: string | undefined;
66
+ cursor?: string | undefined;
67
+ }[];
68
+ timeoutMs: number;
69
+ groupId?: string | undefined;
70
+ followUntilTerminal?: boolean | undefined;
71
+ reportingInstructions?: string | undefined;
72
+ }, import("../../..").WaitResult>;
73
+ readSharedState: AgentToolDefinition<{
74
+ groupId?: string | undefined;
75
+ }, {
76
+ value: Record<string, unknown>;
77
+ revision: number;
78
+ updatedAt: number;
79
+ updatedBy: import("../../..").ThreadActor;
80
+ }>;
81
+ updateSharedState: AgentToolDefinition<{
82
+ expectedRevision: number;
83
+ operations: ({
84
+ op: "set";
85
+ key: string;
86
+ value: string | number | boolean | Record<string, unknown> | unknown[] | null;
87
+ } | {
88
+ op: "remove";
89
+ key: string;
90
+ })[];
91
+ groupId?: string | undefined;
92
+ }, {
93
+ revision: number;
94
+ }>;
95
+ reportProgress: AgentToolDefinition<{
96
+ kind: "completed" | "failed" | "blocked" | "progress" | "milestone";
97
+ summary: string;
98
+ groupId?: string | undefined;
99
+ evidence?: {
100
+ turnId?: string | undefined;
101
+ messageId?: string | undefined;
102
+ } | undefined;
103
+ }, {
104
+ progressSeq: number;
105
+ taskId: string;
106
+ taskProgressSeq: number;
107
+ }>;
108
+ readProgress: AgentToolDefinition<{
109
+ threadId: string;
110
+ groupId?: string | undefined;
111
+ taskId?: string | undefined;
112
+ cursor?: string | undefined;
113
+ limit?: number | undefined;
114
+ kinds?: ("completed" | "failed" | "blocked" | "progress" | "milestone")[] | undefined;
115
+ }, import("../../../runtime/application/thread-tool-binding").AgentThreadProgressPage>;
116
+ interruptThread: AgentToolDefinition<{
117
+ threadId: string;
118
+ expectedTurnId: string;
119
+ groupId?: string | undefined;
120
+ }, {
121
+ accepted: true;
122
+ controlId: string;
123
+ hostOffline: boolean;
124
+ }>;
125
+ };
@@ -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>;
@@ -3,6 +3,7 @@ import type { AgentToolDefinition } from "../types";
3
3
  declare const visionAnalyzeSchema: z.ZodObject<{
4
4
  path: z.ZodString;
5
5
  prompt: z.ZodString;
6
+ expectedSha256: z.ZodOptional<z.ZodString>;
6
7
  }, z.core.$strict>;
7
8
  export declare function createVisionAnalyzeTool(): AgentToolDefinition<z.infer<typeof visionAnalyzeSchema>, Record<string, unknown>>;
8
9
  export {};
@@ -0,0 +1,6 @@
1
+ import type { SessionImageStore } from "../../runtime/ports/session-image-store";
2
+ import type { AgentImageReference } from "../types/agent-message";
3
+ export declare function prepareMcpImages(output: unknown, store: SessionImageStore | undefined, sessionId: string | undefined, signal?: AbortSignal): Promise<{
4
+ output: unknown;
5
+ images: AgentImageReference[];
6
+ }>;
@@ -1,6 +1,7 @@
1
1
  import type { CredentialStore } from "../../runtime/ports";
2
2
  import { type McpCapability, type McpServerConfig } from "../../runtime/protocol";
3
3
  import type { AgentToolDefinition, SandboxExecutionBinding, ToolActionFacts, ToolExecutionContext, ToolPermissionMode } from "./types";
4
+ import type { SessionImageStore } from "../../runtime/ports/session-image-store";
4
5
  export type McpServerState = "configured" | "starting" | "ready" | "degraded" | "failed" | "stopped";
5
6
  export interface McpRuntimeDiagnostic {
6
7
  serverName: string;
@@ -8,6 +9,8 @@ export interface McpRuntimeDiagnostic {
8
9
  }
9
10
  export interface McpRuntimeOptions {
10
11
  capability: McpCapability;
12
+ sessionId?: string;
13
+ sessionImageStore?: SessionImageStore;
11
14
  workspaceRoot?: string;
12
15
  workspaceTrusted?: boolean;
13
16
  resolvePersistentGrant?: ToolExecutionContext["resolvePersistentGrant"];
@@ -18,6 +21,7 @@ export interface McpRuntimeOptions {
18
21
  export declare function createMcpServerStartActionFacts(server: McpServerConfig): ToolActionFacts;
19
22
  export declare class McpStdioRuntime {
20
23
  private readonly options;
24
+ private readonly imageReferences;
21
25
  private readonly policyEngine;
22
26
  private readonly servers;
23
27
  private readonly tools;
@@ -45,5 +49,10 @@ export declare class McpStdioRuntime {
45
49
  private handleLine;
46
50
  private failServer;
47
51
  private resolveSandboxScope;
52
+ private isHostExecutionPlatform;
48
53
  private releaseSandbox;
49
54
  }
55
+ export declare function resolveHostServerCommand(command: string, args: readonly string[]): {
56
+ executable: string;
57
+ args: string[];
58
+ };
@@ -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;
@@ -18,6 +25,7 @@ export declare class BoundedOutputBuffer {
18
25
  get truncated(): boolean;
19
26
  get byteLength(): number;
20
27
  get retainedStartCursor(): number;
28
+ toBuffer(): Buffer;
21
29
  toString(): string;
22
30
  readSince(cursor?: number): {
23
31
  output: string;
@@ -33,6 +41,10 @@ export declare function terminateManagedProcessTree(child: ChildProcess, options
33
41
  timeoutMs?: number;
34
42
  }): Promise<void>;
35
43
  export declare function getPlatformExecutable(program: string): string;
44
+ export declare function resolveWindowsPackageManagerCommand(program: string, args: readonly string[]): {
45
+ executable: string;
46
+ args: string[];
47
+ } | null;
36
48
  export declare function resolveManagedCommand(program: string, args: readonly string[]): {
37
49
  executable: string;
38
50
  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;
@@ -0,0 +1,2 @@
1
+ import type { ToolDisplayFacts } from "./types";
2
+ export declare function createThreadObservationDisplay(toolName: string, input: unknown, output?: unknown): ToolDisplayFacts["observation"];
@@ -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";
@@ -100,6 +131,12 @@ export interface ToolJobDisplayFacts {
100
131
  waitOutcome?: import("../../runtime/domain").JobReadView["waitOutcome"];
101
132
  }
102
133
  export interface ToolDisplayFacts {
134
+ observation?: {
135
+ key: string;
136
+ phase: string;
137
+ lines: string[];
138
+ approvalTargets?: string[];
139
+ };
103
140
  titleKey: string;
104
141
  target?: string;
105
142
  summary?: string;
@@ -113,6 +150,8 @@ export interface ToolDisplayFacts {
113
150
  removed?: number;
114
151
  truncated?: boolean;
115
152
  };
153
+ executionMode?: "sandboxed" | "unisolated" | "unavailable";
154
+ diagnostics?: string[];
116
155
  }
117
156
  export interface ApprovalDisplayFacts {
118
157
  operation: string;
@@ -121,6 +160,10 @@ export interface ApprovalDisplayFacts {
121
160
  resource?: string;
122
161
  risk?: string;
123
162
  actionPreview?: string;
163
+ cwd?: string;
164
+ unknownScope?: boolean;
165
+ executionMode?: ToolDisplayFacts["executionMode"];
166
+ hostExecution?: true;
124
167
  allowedDecisions: ToolApprovalDecision[];
125
168
  }
126
169
  export interface ToolApprovalRequest {
@@ -134,6 +177,7 @@ export interface ToolApprovalRequest {
134
177
  preview: Record<string, unknown>;
135
178
  expiresAt: string;
136
179
  allowedDecisions?: ToolApprovalDecision[];
180
+ taskFileSet?: import("../../runtime/domain/approval").TaskFileTarget[];
137
181
  display?: ApprovalDisplayFacts;
138
182
  }
139
183
  export interface ToolExecutionRequest {
@@ -152,6 +196,7 @@ export type ToolExecutionResult = {
152
196
  output: unknown;
153
197
  meta: ToolExecutionMeta;
154
198
  display?: ToolDisplayFacts;
199
+ images?: import("../types/agent-message").AgentImageReference[];
155
200
  } | {
156
201
  status: "question_required";
157
202
  callId: string;
@@ -205,10 +250,19 @@ export interface ToolActionFacts {
205
250
  stableConstraint?: string;
206
251
  hardDenyReason?: string;
207
252
  requiresApproval?: boolean;
253
+ externalMutation?: boolean;
254
+ externalTarget?: {
255
+ canonicalTarget: string;
256
+ canonicalWorkspace: string;
257
+ };
258
+ externalRestriction?: "allow" | "ask" | "deny";
259
+ externalExecutionTarget?: ExternalExecutionTarget;
208
260
  approval?: {
209
261
  reason: string;
210
262
  preview?: Record<string, unknown>;
211
263
  };
264
+ taskFileSet?: import("../../runtime/domain/approval").TaskFileTarget[];
265
+ commandCwd?: string;
212
266
  }
213
267
  export interface ToolPolicyResult {
214
268
  decision: ToolPermissionDecision;
@@ -233,6 +287,14 @@ export interface ToolEvent {
233
287
  errorCode?: string;
234
288
  }
235
289
  export interface ToolExecutionContext {
290
+ reportingAgreement?: {
291
+ taskId: string;
292
+ explicit: boolean;
293
+ };
294
+ hostMutationProtection?: import("../../runtime/ports/host-mutation-protection").HostMutationProtection;
295
+ executionSessionId?: string;
296
+ externalExecutionAuthority?: ExternalExecutionAuthority;
297
+ sandboxExecutionOverride?: "direct";
236
298
  capabilityCeiling?: import("../../runtime/domain/product-mode").CapabilityCeiling;
237
299
  workspaceRoot?: string;
238
300
  permissionMode: ToolPermissionMode;
@@ -256,6 +318,7 @@ export interface ToolExecutionContext {
256
318
  mimeType: string;
257
319
  }>;
258
320
  };
321
+ getVisibleMessages?: () => readonly import("../types/agent-message").AgentMessage[];
259
322
  fileReadStates?: Map<string, {
260
323
  sha256: string;
261
324
  mtimeMs: number;
@@ -279,7 +342,19 @@ export interface ToolExecutionContext {
279
342
  callId: string;
280
343
  toolName: string;
281
344
  inputHash: string;
345
+ constraint?: string;
282
346
  }) => Promise<boolean>;
347
+ resolveExternalRestriction?: (request: {
348
+ workspaceRoot: string;
349
+ toolName: string;
350
+ constraint: string;
351
+ }) => Promise<"allow" | "ask" | "deny">;
352
+ fileMutationAuthorization?: {
353
+ canonicalTarget: string;
354
+ canonicalWorkspace: string;
355
+ operation: string;
356
+ constraint: string;
357
+ };
283
358
  visionAnalyzer?: VisionAnalyzer;
284
359
  allowedTools?: string[];
285
360
  sandbox?: SandboxExecutionBinding;
@@ -311,6 +386,8 @@ export interface AgentToolDefinition<TInput, TOutput> {
311
386
  createActionFacts(input: TInput, context: ToolExecutionContext): ToolActionFacts | Promise<ToolActionFacts>;
312
387
  execute(input: TInput, context: ToolExecutionContext): Promise<TOutput>;
313
388
  serializeOutput(output: TOutput): unknown;
389
+ getImageReferences?(output: TOutput): import("../types/agent-message").AgentImageReference[];
390
+ projectDisplayDetail?(output: TOutput): ToolDisplayDetail | undefined;
314
391
  createExecutionResult?(input: TInput, output: TOutput, context: {
315
392
  callId: string;
316
393
  toolName: string;
@@ -324,7 +401,12 @@ export interface ToolModelDefinition {
324
401
  inputSchema: Record<string, unknown>;
325
402
  }
326
403
  export interface ToolExecutionOptions {
404
+ reportingAgreement?: {
405
+ taskId: string;
406
+ explicit: boolean;
407
+ };
327
408
  signal?: AbortSignal;
409
+ approvalOnly?: boolean;
328
410
  timeoutMs?: number;
329
411
  onProgress?: (callId: string, chunk: string) => void;
330
412
  }
@@ -1,9 +1,16 @@
1
1
  export type AgentMessageRole = "system" | "user" | "assistant";
2
2
  export type AgentJsonObject = Record<string, unknown>;
3
+ export interface AgentImageReference {
4
+ type: "image-ref";
5
+ id: string;
6
+ sha256: string;
7
+ width: number;
8
+ height: number;
9
+ }
3
10
  export type AgentContentBlock = {
4
11
  type: "text";
5
12
  text: string;
6
- } | {
13
+ } | AgentImageReference | {
7
14
  type: "reasoning";
8
15
  text: string;
9
16
  } | {
@@ -19,6 +26,7 @@ export type AgentContentBlock = {
19
26
  text: string;
20
27
  }>;
21
28
  isError: boolean;
29
+ images?: AgentImageReference[];
22
30
  };
23
31
  export interface AgentMessage {
24
32
  role: AgentMessageRole;
@@ -39,11 +47,13 @@ export declare function getAgentToolCalls(message: AgentMessage): Array<{
39
47
  input: AgentJsonObject;
40
48
  }>;
41
49
  export declare function getAgentMessageText(message: AgentMessage): string;
50
+ export declare function getAgentImageReferences(message: AgentMessage): AgentImageReference[];
42
51
  export declare function createAgentTextMessage(role: AgentMessageRole, text: string): AgentMessage;
43
52
  export declare function createAgentToolResultMessage(input: {
44
53
  toolCallId: string;
45
54
  text: string;
46
55
  isError: boolean;
56
+ images?: AgentImageReference[];
47
57
  }): AgentMessage;
48
58
  export interface AgentToolPairingScan {
49
59
  messages: AgentMessage[];
@@ -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,7 +1,12 @@
1
1
  import type { AgentLease } from "../../../internal/agent-runtime";
2
2
  import type { LeaseStore } from "../../ports";
3
+ interface MemoryLeaseRecord {
4
+ turnId: string;
5
+ lease: AgentLease;
6
+ }
3
7
  export declare class MemoryLeaseStore implements LeaseStore {
4
8
  private leases;
9
+ readCurrent(sessionId: string): Promise<MemoryLeaseRecord | null>;
5
10
  acquire(input: {
6
11
  sessionId: string;
7
12
  turnId: string;
@@ -20,3 +25,4 @@ export declare class MemoryLeaseStore implements LeaseStore {
20
25
  }): Promise<boolean>;
21
26
  deleteBySession(sessionId: string): Promise<void>;
22
27
  }
28
+ export {};