@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,11 @@
1
+ import type { RuntimePorts } from "../ports";
2
+ import type { ThreadControl } from "../domain/thread-collaboration";
3
+ export declare function readThreadTask(ports: RuntimePorts, control: ThreadControl, threadId: string, taskId: string): Promise<{
4
+ taskId: string;
5
+ message: import("../domain/thread-collaboration").ThreadMessage;
6
+ delivery: import("../domain/thread-collaboration").ThreadDelivery;
7
+ turnId: string | undefined;
8
+ turn: import("../domain").Turn | undefined;
9
+ } | undefined>;
10
+ export declare function currentThreadTaskId(ports: RuntimePorts, control: ThreadControl, threadId: string, turnId: string): Promise<string | undefined>;
11
+ export declare function threadTaskProgressKey(threadId: string, taskId: string): string;
@@ -0,0 +1,218 @@
1
+ import type { ModelRef, ReasoningEffort } from "../domain/model-ref";
2
+ import type { Session, TurnStatus } from "../domain";
3
+ import type { ThreadActor, ThreadHandoffInput, ThreadHandoffRef, ThreadMessage, ThreadProgressKind } from "../domain/thread-collaboration";
4
+ import type { RuntimePorts } from "../ports";
5
+ import type { ThreadsCapability } from "../protocol/threads-capability";
6
+ import type { WaitResult } from "./thread-service";
7
+ export interface AgentThreadMemberView {
8
+ threadId: string;
9
+ parentThreadId: string | null;
10
+ title?: string;
11
+ roleLabel?: string;
12
+ createdAt: number;
13
+ }
14
+ export interface AgentThreadMessageView {
15
+ messageId: string;
16
+ from: ThreadActor;
17
+ mode: ThreadMessage["mode"];
18
+ content: string;
19
+ replyTo?: string;
20
+ expectedTurnId?: string;
21
+ createdAt: number;
22
+ deliverySeq: number;
23
+ deliveryStatus: ThreadMessage["deliveryStatus"];
24
+ deliveryReason?: import("../domain/thread-collaboration").ThreadDeliveryReason;
25
+ inputId?: string;
26
+ turnId?: string;
27
+ inputState?: {
28
+ inputId: string;
29
+ turnId: string;
30
+ status: "pending" | "claimed" | "consumed" | "cancelled";
31
+ };
32
+ handoffRef?: ThreadHandoffRef;
33
+ }
34
+ export interface AgentThreadReadResult {
35
+ thread: {
36
+ threadId: string;
37
+ title?: string;
38
+ status: Session["status"];
39
+ activeTurnId?: string;
40
+ relativeLink?: string;
41
+ };
42
+ turn?: {
43
+ turnId: string;
44
+ status: TurnStatus;
45
+ };
46
+ latestMessages: Array<{
47
+ id: string;
48
+ role: "assistant";
49
+ content: string;
50
+ turnId?: string;
51
+ createdAt: number;
52
+ }>;
53
+ messages: AgentThreadMessageView[];
54
+ history: Array<{
55
+ seq: number;
56
+ turnId: string;
57
+ timestamp: string;
58
+ type: string;
59
+ content?: string;
60
+ }>;
61
+ nextCursor?: string;
62
+ }
63
+ export interface AgentThreadProgressPage {
64
+ items: Array<{
65
+ threadId: string;
66
+ taskId?: string;
67
+ turnId?: string;
68
+ kind: ThreadProgressKind;
69
+ summary: string;
70
+ progressSeq: number;
71
+ mergedCount: number;
72
+ createdAt: number;
73
+ evidence?: {
74
+ turnId?: string;
75
+ messageId?: string;
76
+ };
77
+ }>;
78
+ cursor: string;
79
+ compacted: number;
80
+ nextCursor?: string;
81
+ }
82
+ export interface AgentThreadsCapability {
83
+ presentationHost?: "web";
84
+ handoffPath(requestId: string): string;
85
+ create(input: {
86
+ groupId?: string;
87
+ requestId: string;
88
+ title?: string;
89
+ roleLabel?: string;
90
+ modelRef?: ModelRef;
91
+ reasoningEffort?: ReasoningEffort;
92
+ }): Promise<{
93
+ threadId: string;
94
+ groupId: string;
95
+ parentThreadId: string;
96
+ relativeLink: string;
97
+ }>;
98
+ list(input: {
99
+ groupId?: string;
100
+ cursor?: string;
101
+ limit?: number;
102
+ }): Promise<{
103
+ items: AgentThreadMemberView[];
104
+ nextCursor?: string;
105
+ }>;
106
+ read(input: {
107
+ groupId?: string;
108
+ threadId: string;
109
+ cursor?: string;
110
+ limit?: number;
111
+ }): Promise<AgentThreadReadResult>;
112
+ send(input: {
113
+ reportingAgreement?: {
114
+ taskId: string;
115
+ explicit: boolean;
116
+ };
117
+ groupId?: string;
118
+ requestId: string;
119
+ threadId: string;
120
+ mode?: ThreadMessage["mode"];
121
+ content: string;
122
+ replyTo?: string;
123
+ expectedTurnId?: string;
124
+ handoff?: ThreadHandoffInput;
125
+ }): Promise<{
126
+ messageId: string;
127
+ mode: ThreadMessage["mode"];
128
+ expectedTurnId?: string;
129
+ taskId?: string;
130
+ deliverySeq: number;
131
+ deliveryStatus: ThreadMessage["deliveryStatus"];
132
+ handoffRef?: ThreadHandoffRef;
133
+ }>;
134
+ wait(input: {
135
+ groupId?: string;
136
+ targets: Array<{
137
+ threadId: string;
138
+ taskId?: string;
139
+ cursor?: string;
140
+ }>;
141
+ timeoutMs: number;
142
+ signal?: AbortSignal;
143
+ }): Promise<WaitResult>;
144
+ readState(input?: {
145
+ groupId?: string;
146
+ }): Promise<{
147
+ value: Record<string, unknown>;
148
+ revision: number;
149
+ updatedAt: number;
150
+ updatedBy: ThreadActor;
151
+ }>;
152
+ updateState(input: {
153
+ groupId?: string;
154
+ requestId: string;
155
+ expectedRevision: number;
156
+ operations: Array<{
157
+ op: "set";
158
+ key: string;
159
+ value: unknown;
160
+ } | {
161
+ op: "remove";
162
+ key: string;
163
+ }>;
164
+ }): Promise<{
165
+ revision: number;
166
+ }>;
167
+ reportProgress(input: {
168
+ groupId?: string;
169
+ requestId: string;
170
+ kind: ThreadProgressKind;
171
+ summary: string;
172
+ evidence?: {
173
+ turnId?: string;
174
+ messageId?: string;
175
+ };
176
+ }): Promise<{
177
+ progressSeq: number;
178
+ taskId: string;
179
+ taskProgressSeq: number;
180
+ }>;
181
+ readProgress(input: {
182
+ groupId?: string;
183
+ threadId: string;
184
+ taskId?: string;
185
+ cursor?: string;
186
+ limit?: number;
187
+ kinds?: ThreadProgressKind[];
188
+ }): Promise<AgentThreadProgressPage>;
189
+ resumeConstraint(input: {
190
+ groupId?: string;
191
+ threadId: string;
192
+ expectedTurnId: string;
193
+ }): Promise<string>;
194
+ resume(input: {
195
+ groupId?: string;
196
+ requestId: string;
197
+ threadId: string;
198
+ expectedTurnId: string;
199
+ }): Promise<{
200
+ accepted: true;
201
+ controlId: string;
202
+ recoveryAction?: "open_target_continue";
203
+ }>;
204
+ interrupt(input: {
205
+ groupId?: string;
206
+ requestId: string;
207
+ threadId: string;
208
+ expectedTurnId: string;
209
+ }): Promise<{
210
+ accepted: true;
211
+ controlId: string;
212
+ hostOffline: boolean;
213
+ }>;
214
+ }
215
+ export declare function createThreadsToolBinding(ports: RuntimePorts, capability: ThreadsCapability, actor: {
216
+ threadId: string;
217
+ turnId: string;
218
+ }): AgentThreadsCapability;
@@ -8,6 +8,7 @@ import type { TurnLeaseCoordinator } from "./turn-lease-coordinator";
8
8
  import type { TurnRuntimeConfigResolver } from "./turn-runtime-config-resolver";
9
9
  export interface TurnCompactionRequest extends CompactTurnInput {
10
10
  sampler?: ModelSampler;
11
+ tools?: import("../../../internal/lib/llm").AgentModelToolDefinition[];
11
12
  }
12
13
  export interface ContextBudgetBounds {
13
14
  budgetWindowTokens: number | undefined;
@@ -17,7 +18,7 @@ export interface ContextBudgetBounds {
17
18
  }
18
19
  export declare function resolveContextBudgetBounds(providerConfig: FrozenProviderConfig | undefined): ContextBudgetBounds;
19
20
  export interface TurnCompactionCoordinator {
20
- buildContextCompactionManager(frozen: FrozenRunConfig, providerConfig: FrozenProviderConfig | undefined, sampler: ModelSampler): ContextCompactionManager | undefined;
21
+ buildContextCompactionManager(frozen: FrozenRunConfig, providerConfig: FrozenProviderConfig | undefined, sampler: ModelSampler, sessionId?: string): ContextCompactionManager | undefined;
21
22
  compact(input: TurnCompactionRequest): Promise<CompactTurnResult>;
22
23
  }
23
24
  export declare function createTurnCompactionCoordinator(ports: RuntimePorts, defaultRunConfig: RunConfig, leaseCoordinator: TurnLeaseCoordinator, runtimeConfigResolver: TurnRuntimeConfigResolver): TurnCompactionCoordinator;
@@ -5,9 +5,9 @@ import type { RuntimePorts } from "../../ports";
5
5
  export interface TurnConversationBuilder {
6
6
  buildInitialMessages(input: StartTurnInput): AgentMessage[];
7
7
  refreshContext(capabilities: RunConfig, content: string | undefined): Promise<void>;
8
- getLatestCompletedTurn(sessionId: string): Promise<Turn | undefined>;
9
- buildCanonicalSessionMessages(latestCompleted: Turn | undefined, initial: AgentMessage[]): Promise<AgentMessage[]>;
10
- inheritPreviousUsageAnchor(sessionId: string, latestCompleted: Turn | undefined, canonical: AgentMessage[], initial: AgentMessage[]): Promise<AgentCheckpoint["usageAnchor"]>;
8
+ getConversationBaselineTurn(sessionId: string): Promise<Turn | undefined>;
9
+ buildCanonicalSessionMessages(baseline: Turn | undefined, initial: AgentMessage[]): Promise<AgentMessage[]>;
10
+ inheritPreviousUsageAnchor(sessionId: string, baseline: Turn | undefined, canonical: AgentMessage[], initial: AgentMessage[]): Promise<AgentCheckpoint["usageAnchor"]>;
11
11
  injectTodoSnapshot(sessionId: string, todoChainId: string, messages: AgentMessage[]): Promise<AgentMessage[]>;
12
12
  }
13
13
  export declare function createTurnConversationBuilder(ports: RuntimePorts): TurnConversationBuilder;
@@ -7,6 +7,7 @@ export interface TurnEventRecordInput {
7
7
  turnId: string;
8
8
  isDurable: boolean;
9
9
  event: AgentLoopEvent;
10
+ onPersisted?(): Promise<void>;
10
11
  }
11
12
  export interface TurnEventRecorder {
12
13
  nextSeq(sessionId: string, turnId: string): Promise<number>;
@@ -0,0 +1,43 @@
1
+ import type { UserQuestionRequest } from "../../domain/user-question";
2
+ import { type ThreadControlIntent } from "../../domain/thread-collaboration";
3
+ import type { RuntimePorts } from "../../ports";
4
+ import type { Session } from "../../domain";
5
+ import type { AgentEventEnvelope } from "../../protocol";
6
+ export interface TurnExecutionView {
7
+ sessionId: string;
8
+ turnId: string;
9
+ status: Session["status"];
10
+ execution: "active" | "inactive" | "unconfirmed" | "lost";
11
+ executionHost?: string;
12
+ unconfirmedReason?: "snapshot_changed" | "checkpoint_missing" | "lease_mismatch" | "turn_summary_lag" | "boundary_unconfirmed";
13
+ continuation?: {
14
+ controlId: string;
15
+ state: ThreadControlIntent["status"];
16
+ requestId?: string;
17
+ approvalId?: string;
18
+ failureCode?: ThreadControlIntent["failureCode"];
19
+ failureDiagnostic?: ThreadControlIntent["failureDiagnostic"];
20
+ };
21
+ waiting?: "approval" | "user_input" | "threads";
22
+ result?: "completed" | "failed" | "interrupted" | "limit_reached";
23
+ warning?: "summary_lag";
24
+ interaction?: {
25
+ state: "pending" | "decided" | "expired" | "unconfirmed";
26
+ decision?: "approved" | "denied";
27
+ approval?: AgentEventEnvelope;
28
+ requestId?: string;
29
+ question?: UserQuestionRequest;
30
+ continuation?: {
31
+ controlId: string;
32
+ state: ThreadControlIntent["status"];
33
+ failureCode?: ThreadControlIntent["failureCode"];
34
+ failureDiagnostic?: ThreadControlIntent["failureDiagnostic"];
35
+ };
36
+ };
37
+ lastSeq: number;
38
+ }
39
+ export declare function readTurnExecutionView(ports: RuntimePorts, input: {
40
+ sessionId: string;
41
+ turnId?: string;
42
+ signal?: AbortSignal;
43
+ }): Promise<TurnExecutionView | null>;
@@ -1,4 +1,5 @@
1
1
  import { type ContextUsageView } from "../../../internal/kernel/context-budget";
2
+ import { type TurnUsageSummaryView } from "../../../internal/kernel/turn-usage";
2
3
  import type { AgentCheckpoint, AgentEventEnvelope, FrozenRunConfigView, PublicCheckpointView, RecoverableTurnView } from "../../protocol";
3
4
  import type { Turn } from "../../domain";
4
5
  import type { RuntimePorts } from "../../ports";
@@ -30,6 +31,17 @@ export interface TurnRecoveryService {
30
31
  sessionId: string;
31
32
  turnId?: string;
32
33
  }): Promise<ContextUsageView | null>;
34
+ getTurnUsageSummary(input: {
35
+ sessionId: string;
36
+ turnId?: string;
37
+ }): Promise<TurnUsageSummaryView | null>;
38
+ getUsageSnapshot(input: {
39
+ sessionId: string;
40
+ turnId?: string;
41
+ }): Promise<{
42
+ contextUsage: ContextUsageView | null;
43
+ turnUsage: TurnUsageSummaryView | null;
44
+ }>;
33
45
  getContinuation(sessionId: string, turnId: string | undefined): Promise<RecoverableContinuation>;
34
46
  }
35
47
  export declare function createTurnRecoveryService(ports: RuntimePorts, leaseCoordinator: TurnLeaseCoordinator): TurnRecoveryService;
@@ -2,7 +2,7 @@ import type { AgentOptions } from "../../../internal/agent-runtime";
2
2
  import type { ModelSampler } from "../../../internal/kernel/model-sampler";
3
3
  import type { ResolvedCredential, FrozenRunConfig } from "../../domain";
4
4
  import type { RuntimePorts } from "../../ports";
5
- import type { ApprovalService } from "../approval-service";
5
+ import type { ApprovalService, InternalApprovalService } from "../approval-service";
6
6
  import type { InputInboxService } from "../input-inbox-service";
7
7
  import type { JobService } from "../job-service";
8
8
  import type { RunConfig } from "../../protocol";
@@ -11,7 +11,7 @@ import type { UserQuestionService } from "../user-question-service";
11
11
  export interface TurnRuntimeConfigResolverDependencies {
12
12
  ports: RuntimePorts;
13
13
  defaultRunConfig: RunConfig;
14
- approvalService?: ApprovalService;
14
+ approvalService?: ApprovalService & Partial<InternalApprovalService>;
15
15
  inputInboxService?: InputInboxService;
16
16
  jobService?: JobService;
17
17
  userQuestionService?: UserQuestionService;
@@ -1,10 +1,12 @@
1
1
  import type { ContextUsageView } from "../../internal/kernel/context-budget";
2
+ import type { TurnUsageSummaryView } from "../../internal/kernel/turn-usage";
2
3
  import type { RuntimePorts } from "../ports";
3
4
  import type { AgentEvent, StartTurnInput, ContinueTurnInput, CancelTurnInput, SteerTurnInput, RunConfig, CompactTurnInput, CompactTurnResult, FrozenRunConfigView, RecoverableTurnView } from "../protocol";
4
5
  import type { InboxInput } from "../domain";
5
6
  import type { ApprovalService } from "./approval-service";
6
7
  import type { InputInboxService } from "./input-inbox-service";
7
8
  import type { JobService } from "./job-service";
9
+ import { type TurnExecutionView } from "./turn/turn-execution-view";
8
10
  import type { TurnState } from "./turn/turn-recovery-service";
9
11
  import type { UserQuestionService } from "./user-question-service";
10
12
  export { STALE_AGENT_LEASE_MS } from "./turn/turn-lease-coordinator";
@@ -12,7 +14,17 @@ export type { TurnState } from "./turn/turn-recovery-service";
12
14
  export interface TurnService {
13
15
  start(input: StartTurnInput): AsyncIterable<AgentEvent>;
14
16
  continue(input: ContinueTurnInput): AsyncIterable<AgentEvent>;
17
+ requestInteractionContinuation?(input: {
18
+ sessionId: string;
19
+ turnId: string;
20
+ approvalId?: string;
21
+ requestId?: string;
22
+ }): Promise<{
23
+ queued: boolean;
24
+ controlId?: string;
25
+ }>;
15
26
  cancel(input: CancelTurnInput): Promise<void>;
27
+ cancelLocalExecution?(input: CancelTurnInput): Promise<boolean>;
16
28
  steer(input: SteerTurnInput): Promise<InboxInput>;
17
29
  compact(input: CompactTurnInput): Promise<CompactTurnResult>;
18
30
  getState(input: {
@@ -23,6 +35,11 @@ export interface TurnService {
23
35
  sessionId: string;
24
36
  turnId?: string;
25
37
  }): Promise<RecoverableTurnView | null>;
38
+ getExecutionState(input: {
39
+ sessionId: string;
40
+ turnId?: string;
41
+ signal?: AbortSignal;
42
+ }): Promise<TurnExecutionView | null>;
26
43
  getFrozenRunConfig(input: {
27
44
  sessionId: string;
28
45
  turnId?: string;
@@ -31,5 +48,16 @@ export interface TurnService {
31
48
  sessionId: string;
32
49
  turnId?: string;
33
50
  }): Promise<ContextUsageView | null>;
51
+ getTurnUsageSummary(input: {
52
+ sessionId: string;
53
+ turnId?: string;
54
+ }): Promise<TurnUsageSummaryView | null>;
55
+ getUsageSnapshot(input: {
56
+ sessionId: string;
57
+ turnId?: string;
58
+ }): Promise<{
59
+ contextUsage: ContextUsageView | null;
60
+ turnUsage: TurnUsageSummaryView | null;
61
+ }>;
34
62
  }
35
63
  export declare function createTurnService(ports: RuntimePorts, defaultRunConfig?: RunConfig, approvalService?: ApprovalService, inputInboxService?: InputInboxService, jobService?: JobService, userQuestionService?: UserQuestionService, enableUserQuestions?: boolean): TurnService;
@@ -1,5 +1,9 @@
1
1
  import type { FileMutation } from "../domain";
2
2
  import type { RuntimePorts } from "../ports";
3
+ export declare function resolveFileMutationTarget(workspaceRoot: string, mutationPath: string): Promise<{
4
+ absolutePath: string;
5
+ exists: boolean;
6
+ }>;
3
7
  export interface UndoPreview {
4
8
  status: "available" | "unavailable";
5
9
  turnId?: string;
@@ -34,3 +34,4 @@ export declare function createUserQuestionService(dependencies: {
34
34
  turnStore: TurnStore;
35
35
  clock: Clock;
36
36
  }): UserQuestionService;
37
+ export declare function normalizeQuestions(questions: UserQuestionItem[]): UserQuestionItem[];
@@ -1,7 +1,7 @@
1
1
  import type { AgentRuntime } from "../public";
2
2
  import type { RuntimePorts } from "../ports";
3
3
  import type { WorkspaceAdapter } from "../ports/workspace-adapter";
4
- import type { RunConfig, McpCapability, WebCapability } from "../protocol";
4
+ import type { RunConfig, McpCapability, WebCapability, WorkPreviewCapability } from "../protocol";
5
5
  import type { AgentContextSnapshot } from "../../internal/agent-context";
6
6
  import type { AgentSkillsCapability } from "../../internal/tools/builtins/skill-tool";
7
7
  import type { AgentInputInboxCapability } from "../../internal/agent-runtime";
@@ -17,6 +17,7 @@ export interface CapabilityLoader {
17
17
  loadSkills?(workspaceRoot: string): Promise<AgentSkillsCapability | undefined> | AgentSkillsCapability | undefined;
18
18
  loadContext?(workspaceRoot: string, query?: string): Promise<AgentContextSnapshot> | AgentContextSnapshot;
19
19
  loadInputInbox?(workspaceRoot: string): Promise<AgentInputInboxCapability> | AgentInputInboxCapability;
20
+ loadWorkPreview?(workspaceRoot: string): Promise<WorkPreviewCapability | undefined> | WorkPreviewCapability | undefined;
20
21
  }
21
22
  export interface BootstrapEvent {
22
23
  phase: "safe" | "trust" | "runtime" | "ready" | "error";
@@ -43,7 +43,14 @@ export interface ResolvedSandboxSettings {
43
43
  deniedRead: readonly string[];
44
44
  deniedWrite: readonly string[];
45
45
  }
46
+ export interface ResolvedExternalPermissionSettings {
47
+ allow: readonly string[];
48
+ deny: readonly string[];
49
+ ask: readonly string[];
50
+ readonly restricted?: boolean;
51
+ }
46
52
  export interface ResolvedAutopilotSettings {
53
+ maxTurns?: number;
47
54
  modelRef?: ModelRef;
48
55
  visionModelRef?: ModelRef | false;
49
56
  modelSource?: "environment" | "settings";
@@ -58,7 +65,9 @@ export interface ResolvedAutopilotSettings {
58
65
  webSearchDisabled?: boolean;
59
66
  rag: ResolvedRagSettings;
60
67
  sandbox: ResolvedSandboxSettings;
68
+ permissions: ResolvedExternalPermissionSettings;
61
69
  diagnostics: readonly SettingsDiagnostic[];
62
70
  }
63
71
  export declare function normalizeProviderBaseUrl(value: unknown): string | undefined;
72
+ export declare function isExternalPermissionDiagnostic(diagnostic: SettingsDiagnostic): boolean;
64
73
  export declare function resolveAutopilotSettings(sources: readonly AutopilotSettingsSource[]): ResolvedAutopilotSettings;
@@ -1,6 +1,6 @@
1
1
  export interface LimitConfig {
2
2
  defaultValue?: number;
3
- hardLimit: number;
3
+ hardLimit?: number;
4
4
  requestOverride?: number;
5
5
  }
6
6
  export interface ResolvedAgentRuntimeLimits {
@@ -8,11 +8,10 @@ export interface ResolvedAgentRuntimeLimits {
8
8
  maxToolRetries: number;
9
9
  }
10
10
  export interface AgentRuntimeSafetyLimits {
11
- maxDurationMs: number;
11
+ maxDurationMs?: number;
12
12
  maxTotalTokens?: number;
13
13
  }
14
14
  export interface AgentRuntimeSafetyHardLimits {
15
- maxDurationMs: number;
16
15
  maxTotalTokens: number;
17
16
  }
18
17
  export declare function resolveLimitConfig(config: LimitConfig & {
@@ -24,7 +23,6 @@ export declare const AGENT_RUNTIME_LIMIT_DEFAULTS: {
24
23
  readonly maxToolRetries: number;
25
24
  };
26
25
  export declare const AGENT_RUNTIME_LIMIT_HARD_LIMITS: {
27
- readonly maxSteps: 100;
28
26
  readonly maxToolRetries: 10;
29
27
  };
30
28
  export declare const AGENT_RUNTIME_SAFETY_DEFAULTS: AgentRuntimeSafetyLimits;
@@ -1,4 +1,5 @@
1
1
  import type { ToolApprovalDecision, ToolRisk } from "../../internal/tools/types";
2
+ import type { ExternalExecutionTarget } from "./external-execution";
2
3
  export interface ApprovalDecision {
3
4
  approvalId: string;
4
5
  turnId: string;
@@ -6,9 +7,21 @@ export interface ApprovalDecision {
6
7
  callId: string;
7
8
  toolName: string;
8
9
  normalizedInputHash: string;
10
+ constraint?: string;
11
+ expiresAt?: string;
9
12
  decision: ToolApprovalDecision;
13
+ projection?: "synced" | "pending";
10
14
  createdAt: string;
11
15
  }
16
+ export interface TaskFileTarget {
17
+ path: string;
18
+ operation: "create" | "edit";
19
+ }
20
+ export declare const TASK_FILE_SET_CONSTRAINT = "task-files:v1";
21
+ export declare const TASK_EXTERNAL_FILE_SET_CONSTRAINT = "task-ext-files:v1";
22
+ export declare function isTaskFileSetConstraint(constraint: string | undefined): boolean;
23
+ export declare function isExternalTaskFileSetConstraint(constraint: string | undefined): boolean;
24
+ export declare function isTaskFileSetDeclarationConstraint(constraint: string | undefined): boolean;
12
25
  export interface PersistentGrant {
13
26
  scope: "allow_session" | "allow_workspace";
14
27
  workspaceRoot?: string;
@@ -16,6 +29,11 @@ export interface PersistentGrant {
16
29
  toolName: string;
17
30
  constraint: string;
18
31
  risk?: ToolRisk;
32
+ externalRule?: string;
33
+ executionTarget?: ExternalExecutionTarget;
34
+ projection?: "synced" | "pending";
35
+ turnId?: string;
36
+ taskFiles?: TaskFileTarget[];
19
37
  createdAt: string;
20
38
  }
21
39
  export interface SubmitApprovalInput {
@@ -0,0 +1,42 @@
1
+ export declare const EXTERNAL_EXECUTION_CONSTRAINT_PREFIX = "ext-exec-file:v1:";
2
+ export interface ExternalExecutionTarget {
3
+ schemaVersion: 1;
4
+ canonicalTarget: string;
5
+ canonicalWorkspace: string;
6
+ scope: "file";
7
+ operation: "write";
8
+ commandDigest: string;
9
+ }
10
+ export interface ExternalExecutionApproval {
11
+ recordType: "external_execution_request";
12
+ sessionId: string;
13
+ turnId: string;
14
+ approvalId: string;
15
+ callId: string;
16
+ toolName: string;
17
+ normalizedInputHash: string;
18
+ constraint: string;
19
+ expiresAt: string;
20
+ target: ExternalExecutionTarget;
21
+ }
22
+ export interface ExternalExecutionAuthorization {
23
+ lifetime: "allow_once" | "allow_session" | "allow_workspace";
24
+ sessionId: string;
25
+ canonicalWorkspace: string;
26
+ approvalId?: string;
27
+ expiresAt?: string;
28
+ }
29
+ export interface ExternalWriteCapability extends ExternalExecutionAuthorization {
30
+ schemaVersion: 1;
31
+ target: ExternalExecutionTarget;
32
+ toolName: string;
33
+ callId: string;
34
+ normalizedInputHash: string;
35
+ executionId: string;
36
+ constraint: string;
37
+ capabilityDigest: string;
38
+ }
39
+ export declare function comparablePath(value: string): string;
40
+ export declare function computeExternalExecutionConstraint(toolName: string, target: ExternalExecutionTarget): string;
41
+ export declare function isExternalExecutionConstraint(value: string | undefined): boolean;
42
+ export declare function matchesExternalExecutionTarget(toolName: string, constraint: string, target: ExternalExecutionTarget | undefined): boolean;
@@ -0,0 +1,32 @@
1
+ export declare const EXTERNAL_FILE_CONSTRAINT_PREFIX = "ext-file:";
2
+ export type ExternalFileOperation = "Read" | "Write" | "Edit";
3
+ export interface ParsedExternalPermissionRule {
4
+ operation: ExternalFileOperation;
5
+ target: string;
6
+ recursive: boolean;
7
+ }
8
+ export declare function isExternalFileConstraint(constraint: string | undefined): boolean;
9
+ export declare function externalFileConstraintTarget(constraint: string | undefined): string | undefined;
10
+ export declare function formatExternalFileRule(toolName: string, constraint: string): string;
11
+ export interface ExternalFileApproval {
12
+ recordType: "external_file_request";
13
+ sessionId: string;
14
+ turnId: string;
15
+ approvalId: string;
16
+ callId: string;
17
+ toolName: string;
18
+ normalizedInputHash: string;
19
+ constraint: string;
20
+ expiresAt: string;
21
+ }
22
+ export declare function normalizeComparablePath(target: string): string;
23
+ export declare function parseExternalPermissionRule(rule: string): ParsedExternalPermissionRule | null;
24
+ export declare function isValidExternalPermissionRule(rule: string): boolean;
25
+ export declare function externalRuleCoversRule(denyRule: string, grantRule: string): boolean;
26
+ export interface ExternalRestrictionSnapshot {
27
+ allow: readonly string[];
28
+ deny: readonly string[];
29
+ ask?: readonly string[];
30
+ restricted?: boolean;
31
+ }
32
+ export declare function classifyExternalRestriction(snapshot: ExternalRestrictionSnapshot, toolName: string, constraint: string): "allow" | "ask" | "deny";
@@ -7,9 +7,11 @@ import type { DatabaseSearchPolicy, RagSourcePolicy } from "../../internal/datab
7
7
  import type { RerankPolicy } from "../../internal/lib/rerank";
8
8
  import type { SandboxMode } from "./sandbox-policy";
9
9
  export interface FrozenRunConfig {
10
+ threadsEnabled?: boolean;
10
11
  workContextVersion?: 1;
11
12
  capabilityCeiling?: import("./product-mode").CapabilityCeiling;
12
13
  chatAttachmentGrants?: readonly import("../protocol/chat-capability").ChatAttachmentGrant[];
14
+ workPreviewEnabled?: boolean;
13
15
  modelRef?: ModelRef;
14
16
  reasoningProfile?: ReasoningProfile;
15
17
  credentialRef?: CredentialRef;
@@ -29,4 +31,5 @@ export interface FrozenRunConfig {
29
31
  sandboxTempRoot?: string;
30
32
  sandboxPolicyDigest?: string;
31
33
  sandboxPolicyVersion?: 1;
34
+ processExecution?: "sandbox" | "host";
32
35
  }