@autopilot-agent/core 0.2.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 (81) hide show
  1. package/README.md +6 -4
  2. package/dist/experimental/index.js +64 -59
  3. package/dist/experimental/index.mjs +64 -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 +23 -3
  8. package/dist/index.js +241 -214
  9. package/dist/index.mjs +241 -214
  10. package/dist/internal/agent-runtime.d.ts +79 -2
  11. package/dist/internal/kernel/model-sampler.d.ts +5 -0
  12. package/dist/internal/kernel/run-context.d.ts +4 -0
  13. package/dist/internal/kernel/session-images.d.ts +21 -0
  14. package/dist/internal/kernel/turn-usage.d.ts +13 -0
  15. package/dist/internal/lib/document-parser.js +2 -2
  16. package/dist/internal/lib/image-normalization.d.ts +16 -0
  17. package/dist/internal/lib/llm.d.ts +6 -1
  18. package/dist/internal/lib/llm.js +3 -3
  19. package/dist/internal/lib/pdf-processor.js +1 -1
  20. package/dist/internal/tools/builtins/open-preview-tool.d.ts +5 -1
  21. package/dist/internal/tools/builtins/read-output-budget.d.ts +5 -0
  22. package/dist/internal/tools/builtins/render-ui-tool.d.ts +11 -0
  23. package/dist/internal/tools/builtins/static-preview.d.ts +15 -0
  24. package/dist/internal/tools/builtins/thread-tools.d.ts +125 -0
  25. package/dist/internal/tools/builtins/vision-analyze-tool.d.ts +1 -0
  26. package/dist/internal/tools/mcp-images.d.ts +6 -0
  27. package/dist/internal/tools/mcp-runtime.d.ts +4 -0
  28. package/dist/internal/tools/process-utils.d.ts +1 -0
  29. package/dist/internal/tools/thread-observation-display.d.ts +2 -0
  30. package/dist/internal/tools/types.d.ts +18 -0
  31. package/dist/internal/types/agent-message.d.ts +11 -1
  32. package/dist/runtime/adapters/memory/memory-lease-store.d.ts +6 -0
  33. package/dist/runtime/adapters/memory/memory-session-store.d.ts +14 -0
  34. package/dist/runtime/adapters/memory/memory-thread-store.d.ts +24 -0
  35. package/dist/runtime/adapters/memory/memory-transcript-store.d.ts +9 -0
  36. package/dist/runtime/application/approval-service.d.ts +5 -0
  37. package/dist/runtime/application/input-inbox-service.d.ts +1 -1
  38. package/dist/runtime/application/session-service.d.ts +8 -0
  39. package/dist/runtime/application/thread-delivery-service.d.ts +97 -0
  40. package/dist/runtime/application/thread-execution-host.d.ts +7 -0
  41. package/dist/runtime/application/thread-service.d.ts +1027 -0
  42. package/dist/runtime/application/thread-task.d.ts +11 -0
  43. package/dist/runtime/application/thread-tool-binding.d.ts +218 -0
  44. package/dist/runtime/application/turn/turn-compaction-coordinator.d.ts +2 -1
  45. package/dist/runtime/application/turn/turn-event-recorder.d.ts +1 -0
  46. package/dist/runtime/application/turn/turn-execution-view.d.ts +43 -0
  47. package/dist/runtime/application/turn/turn-recovery-service.d.ts +12 -0
  48. package/dist/runtime/application/turn-service.d.ts +28 -0
  49. package/dist/runtime/application/user-question-service.d.ts +1 -0
  50. package/dist/runtime/domain/frozen-run-config.d.ts +1 -0
  51. package/dist/runtime/domain/index.d.ts +7 -1
  52. package/dist/runtime/domain/input-inbox.d.ts +16 -0
  53. package/dist/runtime/domain/session-presentation.d.ts +9 -0
  54. package/dist/runtime/domain/thread-collaboration.d.ts +179 -0
  55. package/dist/runtime/ports/index.d.ts +6 -0
  56. package/dist/runtime/ports/lease-store.d.ts +4 -0
  57. package/dist/runtime/ports/session-image-store.d.ts +26 -0
  58. package/dist/runtime/ports/session-store.d.ts +16 -0
  59. package/dist/runtime/ports/thread-handoff.d.ts +14 -0
  60. package/dist/runtime/ports/thread-store.d.ts +15 -0
  61. package/dist/runtime/ports/transcript-store.d.ts +8 -0
  62. package/dist/runtime/protocol/chat-capability.d.ts +1 -0
  63. package/dist/runtime/protocol/error-code.d.ts +1 -1
  64. package/dist/runtime/protocol/recoverable-turn-view.d.ts +3 -0
  65. package/dist/runtime/protocol/run-config.d.ts +1 -0
  66. package/dist/runtime/protocol/threads-capability.d.ts +14 -0
  67. package/dist/runtime/protocol/work-preview-capability.d.ts +1 -0
  68. package/dist/runtime/provider/anthropic-messages-adapter.d.ts +4 -2
  69. package/dist/runtime/provider/frozen-provider-config.d.ts +1 -0
  70. package/dist/runtime/provider/index.d.ts +1 -1
  71. package/dist/runtime/provider/model-capability-catalog.d.ts +2 -0
  72. package/dist/runtime/provider/openai-chat-completions-adapter.d.ts +2 -1
  73. package/dist/runtime/provider/provider-failure-guidance.d.ts +4 -0
  74. package/dist/runtime/provider/provider-failure-normalization.d.ts +9 -0
  75. package/dist/runtime/public/agent-runtime.d.ts +4 -0
  76. package/dist/ui/catalog.d.ts +870 -0
  77. package/dist/ui/document.d.ts +580 -0
  78. package/dist/ui/index.d.ts +4 -0
  79. package/dist/ui/index.js +1 -0
  80. package/dist/ui/index.mjs +1 -0
  81. 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;
@@ -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;
@@ -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;
@@ -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[];
@@ -7,6 +7,7 @@ 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[];
@@ -17,13 +17,19 @@ export type { ExternalFileOperation, ParsedExternalPermissionRule, ExternalFileA
17
17
  export type { ApprovalDecision, PersistentGrant, SubmitApprovalInput, FindPersistentGrantInput, } from "./approval";
18
18
  export type { UserQuestionOption, UserQuestionItem, UserQuestionAnswerItem, UserQuestionRequest, UserQuestionAnswer, StoredUserQuestion, } from "./user-question";
19
19
  export type { TodoStatus, TodoItem, TodoCounts, TodoSnapshot, TodoWriteResult, } from "./todo";
20
- 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";
21
21
  export type SessionPersistenceMode = "durable" | "ephemeral";
22
22
  export type { SessionPresentation, SessionPresentationCompaction, SessionPresentationMessage, SessionPresentationPinnedSkill, } from "./session-presentation";
23
23
  export type SessionStatus = "idle" | "running" | "waiting_approval" | "waiting_user_input" | "interrupted" | "failed" | "completed";
24
24
  export interface Session {
25
25
  readonly workContextVersion?: 1;
26
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[];
27
33
  readonly productMode?: import("./product-mode").ProductMode;
28
34
  readonly chatRetrievalMode?: import("./product-mode").ChatRetrievalMode;
29
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;
@@ -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"];