@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
@@ -3,23 +3,33 @@ export type { ModelRef, ReasoningEffort } from "./model-ref";
3
3
  export type { ReasoningProfile } from "./reasoning-profile";
4
4
  export type { SessionRunConfig } from "./session-run-config";
5
5
  export type { FrozenRunConfig } from "./frozen-run-config";
6
- export type { SandboxMode, SandboxEnforcement, SandboxPolicy, SandboxCapabilityReport, SandboxExecutionRequest, SandboxPreparedCommand, SandboxErrorCode } from "./sandbox-policy";
6
+ export type { SandboxMode, SandboxEnforcement, SandboxPolicy, SandboxCapabilityReport, SandboxExecutionRequest, SandboxPreparedCommand, SandboxErrorCode, ManagedExecutionControl, ManagedExecutionChannel } from "./sandbox-policy";
7
+ export type { ExternalExecutionTarget, ExternalExecutionApproval, ExternalExecutionAuthorization, ExternalWriteCapability } from "./external-execution";
7
8
  export { SANDBOX_ERROR_CODES, SANDBOX_POLICY_VERSION, isSandboxPolicyDenialCode, isSandboxAvailabilityFailureCode, resolveSandboxMode, computeSandboxPolicyDigest } from "./sandbox-policy";
8
9
  export type { Turn, TurnStatus } from "./turn";
9
10
  export { JOB_RECORD_VERSION } from "./job";
10
- export type { Job, JobStatus, JobOwner, JobOwnerLiveness, JobControlState, JobLastControl, JobView, JobListView, JobReadView, JobOutputSnapshot, JobSafeOutputSnapshot, JobSafeOutputStreamSnapshot, JobSafeOutputStreamView, JobOutputView, JobSandboxSummary, StartJobInput, PollJobInput, JobPollResult } from "./job";
11
+ export { normalizeJobServiceUrl, jobServicePort, sameServiceOrigin } from "./job-service-url";
12
+ export type { Job, JobStatus, JobOwner, JobOwnerLiveness, JobControlState, JobExecutionFacts, JobLastControl, JobView, JobListView, JobReadView, JobOutputSnapshot, JobSafeOutputSnapshot, JobSafeOutputStreamSnapshot, JobSafeOutputStreamView, JobOutputView, JobSandboxSummary, StartJobInput, PollJobInput, JobPollResult } from "./job";
11
13
  export type { FileMutation, FileMutationOperation, FileMutationStatus, PrepareFileMutationInput, UndoTransaction } from "./file-mutation";
12
14
  export type { Project, CreateProjectInput } from "./project";
15
+ export { EXTERNAL_FILE_CONSTRAINT_PREFIX, isExternalFileConstraint, externalFileConstraintTarget, formatExternalFileRule, parseExternalPermissionRule, isValidExternalPermissionRule, externalRuleCoversRule } from "./external-permissions";
16
+ export type { ExternalFileOperation, ParsedExternalPermissionRule, ExternalFileApproval } from "./external-permissions";
13
17
  export type { ApprovalDecision, PersistentGrant, SubmitApprovalInput, FindPersistentGrantInput, } from "./approval";
14
18
  export type { UserQuestionOption, UserQuestionItem, UserQuestionAnswerItem, UserQuestionRequest, UserQuestionAnswer, StoredUserQuestion, } from "./user-question";
15
19
  export type { TodoStatus, TodoItem, TodoCounts, TodoSnapshot, TodoWriteResult, } from "./todo";
16
- export type { InboxInput, InboxDelivery, InboxStatus, InboxBoundary, InboxAttachmentRef, InboxSkillRef, PostInboxInput, DrainInboxInput, ClaimNextInboxInput, ConsumeInboxInput, ListInboxInput, } from "./input-inbox";
20
+ export type { InboxInput, InboxDelivery, InboxStatus, InboxBoundary, InboxOrigin, InboxAttachmentRef, InboxSkillRef, PostInboxInput, DrainInboxInput, ClaimNextInboxInput, ConsumeInboxInput, ListInboxInput, } from "./input-inbox";
17
21
  export type SessionPersistenceMode = "durable" | "ephemeral";
18
22
  export type { SessionPresentation, SessionPresentationCompaction, SessionPresentationMessage, SessionPresentationPinnedSkill, } from "./session-presentation";
19
23
  export type SessionStatus = "idle" | "running" | "waiting_approval" | "waiting_user_input" | "interrupted" | "failed" | "completed";
20
24
  export interface Session {
21
25
  readonly workContextVersion?: 1;
22
26
  id: string;
27
+ readonly collaborationCreationId?: string;
28
+ readonly creationSource?: {
29
+ actor: import("./thread-collaboration").ThreadActor;
30
+ requestId: string;
31
+ };
32
+ readonly collaborationAllowedTools?: readonly string[];
23
33
  readonly productMode?: import("./product-mode").ProductMode;
24
34
  readonly chatRetrievalMode?: import("./product-mode").ChatRetrievalMode;
25
35
  projectId?: string;
@@ -1,6 +1,16 @@
1
1
  export type InboxDelivery = "steer" | "queue";
2
2
  export type InboxStatus = "pending" | "claimed" | "consumed" | "cancelled";
3
3
  export type InboxBoundary = "before_sample" | "after_sample" | "after_tools" | "before_complete";
4
+ export type InboxOrigin = {
5
+ kind: "human";
6
+ principalId?: string;
7
+ } | {
8
+ kind: "thread";
9
+ threadId: string;
10
+ turnId?: string;
11
+ purpose?: "reporting_agreement";
12
+ };
13
+ export declare function inboxOriginKey(origin?: InboxOrigin): string;
4
14
  export interface InboxInput {
5
15
  inputId: string;
6
16
  sessionId: string;
@@ -11,6 +21,7 @@ export interface InboxInput {
11
21
  clientMessageId?: string;
12
22
  attachments: InboxAttachmentRef[];
13
23
  selectedSkills: InboxSkillRef[];
24
+ origin?: InboxOrigin;
14
25
  createdAt: string;
15
26
  }
16
27
  export interface InboxAttachmentRef {
@@ -18,6 +29,10 @@ export interface InboxAttachmentRef {
18
29
  name: string;
19
30
  mimeType: string;
20
31
  relativePath?: string;
32
+ sha256?: string;
33
+ width?: number;
34
+ height?: number;
35
+ bytes?: number;
21
36
  }
22
37
  export interface InboxSkillRef {
23
38
  skillRef: string;
@@ -34,6 +49,7 @@ export interface PostInboxInput {
34
49
  content: string;
35
50
  attachments?: InboxAttachmentRef[];
36
51
  selectedSkills?: InboxSkillRef[];
52
+ origin?: InboxOrigin;
37
53
  }
38
54
  export interface DrainInboxInput {
39
55
  sessionId: string;
@@ -0,0 +1,3 @@
1
+ export declare function normalizeJobServiceUrl(value: string): string | undefined;
2
+ export declare function jobServicePort(serviceUrl: string): number | undefined;
3
+ export declare function sameServiceOrigin(left: string, right: string): boolean;
@@ -32,6 +32,12 @@ export interface JobOutputView {
32
32
  stderr: JobSafeOutputStreamView;
33
33
  }
34
34
  export type JobControlState = "owned" | "foreign_owner" | "owner_unknown" | "terminal";
35
+ export interface JobExecutionFacts {
36
+ phase: "wrapper_spawn_failed" | "wrapper_running" | "wrapper_exit" | "target_spawn_error_reported" | "host_spawn_failed" | "host_running";
37
+ targetState: "unknown" | "not_started";
38
+ signal?: string;
39
+ win32Code?: string;
40
+ }
35
41
  export interface JobLastControl {
36
42
  action: "stop";
37
43
  source: "agent" | "host" | "legacy_api";
@@ -47,11 +53,13 @@ export interface JobView {
47
53
  updatedAt: number;
48
54
  finishedAt?: number;
49
55
  exitCode?: number;
56
+ execution?: JobExecutionFacts;
50
57
  failureCode?: Job["failureCode"];
51
58
  stdoutBytes: number;
52
59
  stderrBytes: number;
53
60
  outputTruncated: boolean;
54
61
  lastControl?: JobLastControl;
62
+ serviceUrl?: string;
55
63
  }
56
64
  export interface JobListView {
57
65
  jobs: JobView[];
@@ -80,6 +88,7 @@ export interface JobSandboxSummary {
80
88
  mode: SandboxMode;
81
89
  policyDigest: string;
82
90
  policyVersion: number;
91
+ execution?: "host";
83
92
  }
84
93
  export interface Job {
85
94
  jobRecordVersion?: typeof JOB_RECORD_VERSION;
@@ -97,13 +106,17 @@ export interface Job {
97
106
  updatedAt: number;
98
107
  finishedAt?: number;
99
108
  exitCode?: number;
109
+ execution?: JobExecutionFacts;
100
110
  failureCode?: "JOB_SPAWN_FAILED" | "JOB_STOP_FAILED" | "JOB_STOP_TIMEOUT" | "JOB_STORAGE_FAILED";
101
111
  lastControl?: JobLastControl;
102
112
  output: JobOutputSnapshot;
103
113
  safeOutput?: JobSafeOutputSnapshot;
104
114
  sandbox?: JobSandboxSummary;
115
+ serviceUrl?: string;
105
116
  }
106
117
  export interface StartJobInput {
118
+ externalWriteTarget?: string;
119
+ toolCallId?: string;
107
120
  signal?: AbortSignal;
108
121
  workspaceId: string;
109
122
  workspaceRoot: string;
@@ -112,9 +125,14 @@ export interface StartJobInput {
112
125
  program: string;
113
126
  args: string[];
114
127
  cwd: string;
128
+ serviceUrl?: string;
115
129
  sandbox: {
130
+ execution?: "sandboxed";
116
131
  port: SandboxPort;
117
132
  policy: SandboxPolicy;
133
+ } | {
134
+ execution: "host";
135
+ policy: SandboxPolicy;
118
136
  };
119
137
  }
120
138
  export interface PollJobInput {
@@ -1,3 +1,4 @@
1
+ import type { ExternalWriteCapability } from "./external-execution";
1
2
  export type SandboxMode = "read-only" | "workspace-write" | "danger-full-access";
2
3
  export type SandboxEnforcement = "full" | "partial" | "unavailable";
3
4
  export interface SandboxPolicy {
@@ -7,6 +8,7 @@ export interface SandboxPolicy {
7
8
  allowedDomains: readonly string[];
8
9
  deniedRead: readonly string[];
9
10
  deniedWrite: readonly string[];
11
+ externalWriteCapability?: ExternalWriteCapability;
10
12
  }
11
13
  export interface SandboxCapabilityReport {
12
14
  platform: "macos" | "windows" | "linux" | "unknown";
@@ -23,6 +25,19 @@ export interface SandboxExecutionRequest {
23
25
  args: readonly string[];
24
26
  cwd: string;
25
27
  policy: SandboxPolicy;
28
+ managed?: boolean;
29
+ }
30
+ export interface ManagedExecutionChannel {
31
+ incoming: AsyncIterable<Uint8Array>;
32
+ send(bytes: Uint8Array): void;
33
+ close(): void;
34
+ }
35
+ export interface ManagedExecutionControl {
36
+ protocolVersion: 1;
37
+ bind(channel: ManagedExecutionChannel): void;
38
+ stop(): Promise<{
39
+ evidence: "container_empty";
40
+ }>;
26
41
  }
27
42
  export interface SandboxPreparedCommand {
28
43
  executionId: string;
@@ -30,6 +45,7 @@ export interface SandboxPreparedCommand {
30
45
  args: readonly string[];
31
46
  env: Record<string, string>;
32
47
  enforcement: SandboxEnforcement;
48
+ control?: ManagedExecutionControl;
33
49
  }
34
50
  export declare const SANDBOX_ERROR_CODES: {
35
51
  readonly UNAVAILABLE: "SANDBOX_UNAVAILABLE";
@@ -43,9 +59,23 @@ export type SandboxErrorCode = (typeof SANDBOX_ERROR_CODES)[keyof typeof SANDBOX
43
59
  export declare function isSandboxPolicyDenialCode(code: string): boolean;
44
60
  export declare function isSandboxAvailabilityFailureCode(code: string): boolean;
45
61
  export declare const SANDBOX_POLICY_VERSION = 1;
62
+ export declare const NO_SANDBOX_EXEC_CONSTRAINT = "no-sandbox-exec:v1";
63
+ export declare function isNoSandboxExecConstraint(constraint: string | undefined): boolean;
64
+ export interface SandboxDegradeApproval {
65
+ recordType: "sandbox_degrade_request";
66
+ sessionId: string;
67
+ turnId: string;
68
+ approvalId: string;
69
+ callId: string;
70
+ toolName: string;
71
+ normalizedInputHash: string;
72
+ constraint: string;
73
+ expiresAt: string;
74
+ }
46
75
  export declare function resolveSandboxMode(value: unknown): SandboxMode;
47
76
  export declare function computeSandboxPolicyDigest(input: {
48
77
  mode: SandboxMode;
49
78
  workspaceRoot?: string;
50
79
  tempRoot?: string;
80
+ externalWriteCapability?: ExternalWriteCapability;
51
81
  }): string;
@@ -39,6 +39,15 @@ export interface SessionPresentationMessage {
39
39
  message: string;
40
40
  }>;
41
41
  }>;
42
+ origin?: {
43
+ kind: "thread";
44
+ threadId: string;
45
+ };
46
+ handoffDisplay?: {
47
+ title: string;
48
+ instruction: string;
49
+ summary: string;
50
+ };
42
51
  createdAt: number;
43
52
  }
44
53
  export interface SessionPresentationCompaction {
@@ -0,0 +1,179 @@
1
+ export type ThreadActor = {
2
+ kind: "human";
3
+ principalId: string;
4
+ } | {
5
+ kind: "thread";
6
+ threadId: string;
7
+ turnId: string;
8
+ };
9
+ export interface ThreadMember {
10
+ executionHost?: string;
11
+ threadId: string;
12
+ groupId: string;
13
+ parentThreadId: string | null;
14
+ title?: string;
15
+ roleLabel?: string;
16
+ createdAt: number;
17
+ }
18
+ export interface ThreadGroup {
19
+ groupId: string;
20
+ workspaceId: string;
21
+ projectId: string;
22
+ rootThreadId: string;
23
+ enabled: boolean;
24
+ createdAt: number;
25
+ createdBy: ThreadActor;
26
+ ownerPrincipalId?: string;
27
+ allowedTools: readonly string[];
28
+ }
29
+ export interface ThreadReceipt {
30
+ actorKey: string;
31
+ operation: string;
32
+ requestId: string;
33
+ payloadDigest: string;
34
+ result: unknown;
35
+ }
36
+ export interface ThreadCreateIntent {
37
+ requestId: string;
38
+ actorKey: string;
39
+ from: ThreadActor;
40
+ payloadDigest: string;
41
+ threadId: string;
42
+ parentThreadId: string;
43
+ title?: string;
44
+ roleLabel?: string;
45
+ modelRef?: import("./model-ref").ModelRef;
46
+ reasoningEffort?: import("./model-ref").ReasoningEffort;
47
+ permissionMode?: import("./session-run-config").SessionRunConfig["permissionMode"];
48
+ executionHost?: string;
49
+ status: "creating" | "created" | "recovery_required";
50
+ }
51
+ export type ThreadDeliveryReason = "target_running" | "target_waiting_approval" | "target_waiting_user_input" | "target_interrupted" | "turn_failed" | "turn_interrupted" | "turn_not_running" | "start_failed" | "host_offline" | "recovery_required";
52
+ export interface ThreadDelivery {
53
+ executionHost?: string;
54
+ messageId: string;
55
+ threadId: string;
56
+ deliverySeq: number;
57
+ mode: "notify" | "run" | "steer";
58
+ status: "pending" | "claimed" | "delivered" | "blocked" | "failed" | "cancelled";
59
+ attempts: number;
60
+ updatedAt: number;
61
+ reservedTurnId?: string;
62
+ inputId?: string;
63
+ turnId?: string;
64
+ ownerId?: string;
65
+ ownerHeartbeatAt?: number;
66
+ reason?: ThreadDeliveryReason;
67
+ }
68
+ export interface ThreadControlIntent {
69
+ controlId: string;
70
+ kind: "interrupt" | "resume" | "continue_interaction";
71
+ approvalId?: string;
72
+ requestId?: string;
73
+ failureCode?: "BOUNDARY_CHANGED" | "CONTINUE_FAILED";
74
+ failureDiagnostic?: {
75
+ stage: "read_decision" | "continue" | "after_started";
76
+ category: "storage" | "runtime" | "os" | "unknown";
77
+ code: string;
78
+ started: boolean;
79
+ filePhase?: "lock" | "temporary_write" | "rename" | "cleanup";
80
+ };
81
+ checkpointDigest?: string;
82
+ pauseSeq?: number;
83
+ threadId: string;
84
+ expectedTurnId: string;
85
+ status: "pending" | "applied" | "rejected" | "claimed" | "executing" | "completed" | "failed";
86
+ createdAt: number;
87
+ updatedAt: number;
88
+ ownerId?: string;
89
+ }
90
+ export type ThreadProgressKind = "progress" | "milestone" | "blocked" | "completed" | "failed";
91
+ export interface ThreadProgressEntry {
92
+ taskId?: string;
93
+ turnId?: string;
94
+ taskProgressSeq?: number;
95
+ threadId: string;
96
+ progressSeq: number;
97
+ kind: ThreadProgressKind;
98
+ summary: string;
99
+ createdAt: number;
100
+ evidence?: {
101
+ turnId?: string;
102
+ messageId?: string;
103
+ };
104
+ }
105
+ export interface ThreadControl {
106
+ group: ThreadGroup;
107
+ revision: number;
108
+ members: ThreadMember[];
109
+ receipts: ThreadReceipt[];
110
+ creates: ThreadCreateIntent[];
111
+ sharedState: Record<string, unknown>;
112
+ stateRevision: number;
113
+ stateUpdatedAt: number;
114
+ stateUpdatedBy: ThreadActor;
115
+ nextGroupSeq: number;
116
+ eventIntents: ThreadEvent[];
117
+ nextDeliverySeq: Record<string, number>;
118
+ messageIntents: Array<{
119
+ actorKey: string;
120
+ payloadDigest: string;
121
+ message: ThreadMessage;
122
+ committed: boolean;
123
+ }>;
124
+ deliveries: ThreadDelivery[];
125
+ controls: ThreadControlIntent[];
126
+ progress?: ThreadProgressEntry[];
127
+ nextProgressSeq?: Record<string, number>;
128
+ }
129
+ export interface ThreadHandoffInput {
130
+ title: string;
131
+ markdown: string;
132
+ }
133
+ export interface ThreadHandoffRef {
134
+ handoffId: string;
135
+ relativePath: string;
136
+ sha256: string;
137
+ }
138
+ export interface ThreadMessage {
139
+ purpose?: {
140
+ kind: "reporting_agreement";
141
+ taskId: string;
142
+ };
143
+ messageId: string;
144
+ requestId: string;
145
+ groupId: string;
146
+ from: ThreadActor;
147
+ toThreadId: string;
148
+ mode: "notify" | "run" | "steer";
149
+ content: string;
150
+ replyTo?: string;
151
+ expectedTurnId?: string;
152
+ handoff?: ThreadHandoffRef;
153
+ handoffDisplay?: {
154
+ title: string;
155
+ instruction: string;
156
+ summary: string;
157
+ };
158
+ createdAt: number;
159
+ deliverySeq: number;
160
+ deliveryStatus: "accepted" | "pending" | "claimed" | "delivered" | "blocked" | "cancelled" | "failed";
161
+ inputId?: string;
162
+ turnId?: string;
163
+ }
164
+ export type ThreadEventActor = ThreadActor | {
165
+ kind: "host";
166
+ hostId: string;
167
+ };
168
+ export interface ThreadEvent {
169
+ groupId: string;
170
+ groupSeq: number;
171
+ actor: ThreadEventActor;
172
+ kind: "member_created" | "group_enabled" | "group_disabled" | "message_accepted" | "message_delivered" | "message_blocked" | "shared_state_changed" | "turn_attention" | "turn_terminal" | "host_offline" | "recovery_required";
173
+ createdAt: number;
174
+ threadId?: string;
175
+ messageId?: string;
176
+ turnId?: string;
177
+ stateRevision?: number;
178
+ }
179
+ export declare function sanitizeContinuationFailure(value: ThreadControlIntent["failureDiagnostic"]): ThreadControlIntent["failureDiagnostic"];
@@ -17,4 +17,8 @@ export interface TodoSnapshot {
17
17
  export interface TodoWriteResult {
18
18
  todos: TodoItem[];
19
19
  counts: TodoCounts;
20
+ fileTargets?: Array<{
21
+ path: string;
22
+ operation: "create" | "edit";
23
+ }>;
20
24
  }
@@ -1,5 +1,8 @@
1
1
  import type { ToolRisk } from "../../internal/tools/types";
2
- import type { ApprovalDecision, PersistentGrant } from "../domain/approval";
2
+ import type { ApprovalDecision, PersistentGrant, TaskFileTarget } from "../domain/approval";
3
+ import type { ExternalExecutionApproval, ExternalExecutionTarget } from "../domain/external-execution";
4
+ import type { ExternalFileApproval } from "../domain/external-permissions";
5
+ import type { SandboxDegradeApproval } from "../domain/sandbox-policy";
3
6
  export interface GetApprovalDecisionInput {
4
7
  sessionId: string;
5
8
  turnId: string;
@@ -18,8 +21,36 @@ export interface SavePersistentGrantInput {
18
21
  toolName: string;
19
22
  constraint: string;
20
23
  risk?: ToolRisk;
24
+ externalRule?: string;
25
+ executionTarget?: ExternalExecutionTarget;
26
+ turnId?: string;
27
+ taskFiles?: TaskFileTarget[];
28
+ projection?: "synced" | "pending";
21
29
  }
22
30
  export interface ApprovalStore {
31
+ saveExecutionApproval?(request: ExternalExecutionApproval): Promise<boolean>;
32
+ getExecutionApproval?(input: GetApprovalDecisionInput): Promise<ExternalExecutionApproval | null>;
33
+ consumeExecutionApproval?(input: GetApprovalDecisionInput & {
34
+ constraint: string;
35
+ callId: string;
36
+ normalizedInputHash: string;
37
+ now: string;
38
+ }): Promise<boolean>;
39
+ saveFileApproval?(request: ExternalFileApproval): Promise<boolean>;
40
+ getFileApproval?(input: GetApprovalDecisionInput): Promise<ExternalFileApproval | null>;
41
+ consumeFileApproval?(input: GetApprovalDecisionInput & {
42
+ constraint: string;
43
+ callId: string;
44
+ normalizedInputHash: string;
45
+ now: string;
46
+ }): Promise<boolean>;
47
+ saveDegradeApproval?(request: SandboxDegradeApproval): Promise<boolean>;
48
+ consumeDegradeApproval?(input: GetApprovalDecisionInput & {
49
+ constraint: string;
50
+ callId: string;
51
+ normalizedInputHash: string;
52
+ now: string;
53
+ }): Promise<boolean>;
23
54
  getDecision(input: GetApprovalDecisionInput): Promise<ApprovalDecision | null>;
24
55
  saveDecision(decision: ApprovalDecision): Promise<boolean>;
25
56
  getPersistentGrant(input: GetPersistentGrantInput): Promise<PersistentGrant | null>;
@@ -28,4 +59,11 @@ export interface ApprovalStore {
28
59
  }): Promise<PersistentGrant>;
29
60
  deletePersistentGrant(input: GetPersistentGrantInput): Promise<boolean>;
30
61
  deleteBySession(sessionId: string): Promise<void>;
62
+ listPersistentGrants(input: {
63
+ workspaceRoot?: string;
64
+ sessionId?: string;
65
+ }): Promise<PersistentGrant[]>;
66
+ setGrantProjection(input: GetPersistentGrantInput & {
67
+ projection: "synced" | "pending";
68
+ }): Promise<PersistentGrant | null>;
31
69
  }
@@ -0,0 +1,14 @@
1
+ export interface ExternalPermissionSnapshot {
2
+ allow: readonly string[];
3
+ deny: readonly string[];
4
+ ask?: readonly string[];
5
+ restricted?: boolean;
6
+ }
7
+ export interface ExternalPermissionProjector {
8
+ project(input: {
9
+ workspaceRoot: string;
10
+ rule: string;
11
+ action: "add" | "remove";
12
+ }): Promise<void>;
13
+ read(workspaceRoot: string): Promise<ExternalPermissionSnapshot>;
14
+ }
@@ -7,5 +7,5 @@ export interface FileMutationStore {
7
7
  saveUndoTransaction(transaction: UndoTransaction): Promise<void>;
8
8
  listUndoTransactions(sessionId: string): Promise<UndoTransaction[]>;
9
9
  deleteBySession(sessionId: string): Promise<void>;
10
- withWorkspaceLock<T>(workspaceRoot: string, operation: () => Promise<T>): Promise<T>;
10
+ withWorkspaceLock<T>(workspaceRoot: string, operation: () => Promise<T>, canonicalTargets?: readonly string[]): Promise<T>;
11
11
  }
@@ -0,0 +1,7 @@
1
+ export interface ProtectedMutationTarget {
2
+ path: string;
3
+ scope: "file" | "directory";
4
+ }
5
+ export interface HostMutationProtection {
6
+ getProtectedTargets(workspaceRoot: string): Promise<readonly ProtectedMutationTarget[]>;
7
+ }
@@ -1,3 +1,4 @@
1
+ import type { ThreadStore } from "./thread-store";
1
2
  import type { SessionStore } from "./session-store";
2
3
  import type { CheckpointStore } from "./checkpoint-store";
3
4
  import type { TranscriptStore } from "./transcript-store";
@@ -14,15 +15,24 @@ import type { JobStore } from "./job-store";
14
15
  import type { JobOwnerProbe } from "./job-owner-probe";
15
16
  import type { FileMutationStore } from "./file-mutation-store";
16
17
  import type { SessionResourceStore } from "./session-resource-store";
18
+ import type { SessionImageStore } from "./session-image-store";
19
+ export type { SessionImageStore, SessionImageRef } from "./session-image-store";
17
20
  import type { UserQuestionStore } from "./user-question-store";
18
21
  import type { SandboxPort } from "./sandbox-port";
19
- export type { SessionStore, CheckpointStore, TranscriptStore, CredentialStore, ProjectStore, EventSink, Clock, WorkspaceAdapter, WorkspaceInfo, TurnStore, ApprovalStore, InputInbox, LeaseStore, JobStore, JobOwnerProbe, FileMutationStore, SessionResourceStore, UserQuestionStore };
22
+ import type { ExternalPermissionProjector } from "./external-permission-projector";
23
+ import type { HostMutationProtection } from "./host-mutation-protection";
24
+ export type { HostMutationProtection, ProtectedMutationTarget } from "./host-mutation-protection";
25
+ export type { SessionStore, CheckpointStore, TranscriptStore, CredentialStore, ProjectStore, EventSink, Clock, WorkspaceAdapter, WorkspaceInfo, TurnStore, ApprovalStore, InputInbox, LeaseStore, JobStore, JobOwnerProbe, FileMutationStore, SessionResourceStore, UserQuestionStore, ExternalPermissionProjector };
26
+ export type { SessionDirectoryPage, SessionDirectoryQuery, SessionDirectoryEntry } from "./session-store";
27
+ export type { ExternalPermissionSnapshot } from "./external-permission-projector";
20
28
  export type { JobStoreWriteCondition } from "./job-store";
21
29
  export type { GetUserQuestionInput, SaveUserQuestionAnswerInput, SaveUserQuestionAnswerResult } from "./user-question-store";
22
30
  export type { SandboxPort } from "./sandbox-port";
23
31
  export { SandboxPortError, createUnavailableSandboxPort } from "./sandbox-port";
24
32
  export interface RuntimePorts {
33
+ hostMutationProtection?: HostMutationProtection;
25
34
  sessionStore: SessionStore;
35
+ threadStore: ThreadStore;
26
36
  checkpointStore: CheckpointStore;
27
37
  transcriptStore: TranscriptStore;
28
38
  credentialStore: CredentialStore;
@@ -38,6 +48,8 @@ export interface RuntimePorts {
38
48
  jobOwnerProbe: JobOwnerProbe;
39
49
  fileMutationStore: FileMutationStore;
40
50
  sessionResourceStore: SessionResourceStore;
51
+ sessionImageStore?: SessionImageStore;
41
52
  userQuestionStore: UserQuestionStore;
42
53
  sandboxPort: SandboxPort;
54
+ externalPermissionProjector?: ExternalPermissionProjector;
43
55
  }
@@ -1,5 +1,9 @@
1
1
  import type { AgentLease } from "../../internal/agent-runtime";
2
2
  export interface LeaseStore {
3
+ readCurrent?(sessionId: string): Promise<{
4
+ turnId: string;
5
+ lease: AgentLease;
6
+ } | null>;
3
7
  acquire(input: {
4
8
  sessionId: string;
5
9
  turnId: string;
@@ -4,6 +4,7 @@ export declare class SandboxPortError extends Error {
4
4
  constructor(code: string, message: string);
5
5
  }
6
6
  export interface SandboxPort {
7
+ readonly execution?: "host";
7
8
  status(): Promise<SandboxCapabilityReport>;
8
9
  setup(): Promise<SandboxCapabilityReport>;
9
10
  prepare(request: SandboxExecutionRequest): Promise<SandboxPreparedCommand>;
@@ -0,0 +1,26 @@
1
+ export interface SessionImageRef {
2
+ id: string;
3
+ name: string;
4
+ mimeType: string;
5
+ relativePath: string;
6
+ sha256: string;
7
+ width: number;
8
+ height: number;
9
+ bytes: number;
10
+ gifFirstFrame: boolean;
11
+ }
12
+ export interface SessionImageStore {
13
+ put(input: {
14
+ sessionId: string;
15
+ name: string;
16
+ mimeType?: string;
17
+ bytes: Uint8Array;
18
+ }): Promise<SessionImageRef>;
19
+ read(input: {
20
+ sessionId: string;
21
+ id: string;
22
+ }): Promise<{
23
+ image: SessionImageRef;
24
+ bytes: Uint8Array;
25
+ }>;
26
+ }
@@ -1,7 +1,23 @@
1
1
  import type { Session } from "../domain";
2
+ export interface SessionDirectoryPage {
3
+ items: Array<{
4
+ id: string;
5
+ title?: string;
6
+ }>;
7
+ nextCursor?: string;
8
+ }
9
+ export interface SessionDirectoryQuery {
10
+ projectId: string;
11
+ limit: number;
12
+ cursor?: string;
13
+ }
14
+ export type SessionDirectoryEntry = Pick<Session, "id" | "title" | "productMode" | "projectId" | "chatRetrievalMode" | "status" | "activeTurnId" | "createdAt" | "updatedAt">;
2
15
  export interface SessionStore {
3
16
  get(id: string): Promise<Session | null>;
4
17
  list(): Promise<Session[]>;
18
+ listDirectoryPage?(query: SessionDirectoryQuery): Promise<SessionDirectoryPage>;
19
+ getDirectoryEntry?(id: string): Promise<SessionDirectoryEntry | null>;
20
+ createIfAbsent(session: Session): Promise<boolean>;
5
21
  save(session: Session): Promise<void>;
6
22
  delete(id: string): Promise<boolean>;
7
23
  }
@@ -0,0 +1,14 @@
1
+ export interface ThreadHandoffDocumentInput {
2
+ workspaceId: string;
3
+ handoffId: string;
4
+ title: string;
5
+ markdown: string;
6
+ }
7
+ export interface ThreadHandoffDocument {
8
+ handoffId: string;
9
+ relativePath: string;
10
+ sha256: string;
11
+ }
12
+ export interface ThreadHandoffWriter {
13
+ write(input: ThreadHandoffDocumentInput): Promise<ThreadHandoffDocument>;
14
+ }
@@ -0,0 +1,15 @@
1
+ import type { ThreadControl, ThreadMessage, ThreadEvent } from "../domain/thread-collaboration";
2
+ export interface ThreadStore {
3
+ verifyRequest(id: string, groupId: string, payloadDigest: string): Promise<void>;
4
+ reserveRequest(id: string, groupId: string, payloadDigest: string): Promise<void>;
5
+ withSessionLock<T>(threadId: string, operation: () => Promise<T>): Promise<T>;
6
+ hasMembership(threadId: string): Promise<boolean>;
7
+ readControl(groupId: string): Promise<ThreadControl | null>;
8
+ writeEvent(event: ThreadEvent): Promise<void>;
9
+ readEvent(groupId: string, seq: number): Promise<ThreadEvent | null>;
10
+ writeMessage(message: ThreadMessage): Promise<void>;
11
+ readMessage(groupId: string, threadId: string, seq: number): Promise<ThreadMessage | null>;
12
+ compareAndSetControl(groupId: string, expectedRevision: number | null, value: ThreadControl): Promise<boolean>;
13
+ listGroups(): Promise<string[]>;
14
+ subscribe?(groupId: string, listener: () => void): () => void;
15
+ }