@autopilot-agent/core 0.2.0 → 0.4.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 (99) hide show
  1. package/README.md +10 -4
  2. package/dist/experimental/index.js +159 -59
  3. package/dist/experimental/index.mjs +159 -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 +30 -5
  8. package/dist/index.js +346 -214
  9. package/dist/index.mjs +346 -214
  10. package/dist/internal/agent-runtime.d.ts +87 -2
  11. package/dist/internal/kernel/model-sampler.d.ts +5 -0
  12. package/dist/internal/kernel/run-context.d.ts +6 -0
  13. package/dist/internal/kernel/session-images.d.ts +21 -0
  14. package/dist/internal/kernel/turn-usage.d.ts +14 -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 +7 -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/browser-tool.d.ts +13 -0
  21. package/dist/internal/tools/builtins/open-preview-tool.d.ts +5 -1
  22. package/dist/internal/tools/builtins/read-output-budget.d.ts +5 -0
  23. package/dist/internal/tools/builtins/render-ui-tool.d.ts +11 -0
  24. package/dist/internal/tools/builtins/static-preview.d.ts +15 -0
  25. package/dist/internal/tools/builtins/thread-tools.d.ts +125 -0
  26. package/dist/internal/tools/builtins/vision-analyze-tool.d.ts +1 -0
  27. package/dist/internal/tools/mcp-images.d.ts +6 -0
  28. package/dist/internal/tools/mcp-runtime.d.ts +4 -0
  29. package/dist/internal/tools/permissions/command-policy.d.ts +2 -0
  30. package/dist/internal/tools/policy-engine.d.ts +1 -0
  31. package/dist/internal/tools/process-utils.d.ts +1 -0
  32. package/dist/internal/tools/thread-observation-display.d.ts +2 -0
  33. package/dist/internal/tools/types.d.ts +21 -0
  34. package/dist/internal/types/agent-message.d.ts +12 -2
  35. package/dist/internal/types/index.d.ts +1 -1
  36. package/dist/runtime/adapters/memory/memory-lease-store.d.ts +6 -0
  37. package/dist/runtime/adapters/memory/memory-session-store.d.ts +14 -0
  38. package/dist/runtime/adapters/memory/memory-thread-store.d.ts +24 -0
  39. package/dist/runtime/adapters/memory/memory-transcript-store.d.ts +9 -0
  40. package/dist/runtime/application/approval-service.d.ts +5 -0
  41. package/dist/runtime/application/input-inbox-service.d.ts +1 -1
  42. package/dist/runtime/application/runtime-facts.d.ts +54 -0
  43. package/dist/runtime/application/session-service.d.ts +9 -0
  44. package/dist/runtime/application/thread-delivery-service.d.ts +97 -0
  45. package/dist/runtime/application/thread-execution-host.d.ts +7 -0
  46. package/dist/runtime/application/thread-service.d.ts +1027 -0
  47. package/dist/runtime/application/thread-task.d.ts +11 -0
  48. package/dist/runtime/application/thread-tool-binding.d.ts +218 -0
  49. package/dist/runtime/application/turn/turn-capability-ceiling.d.ts +2 -0
  50. package/dist/runtime/application/turn/turn-compaction-coordinator.d.ts +2 -1
  51. package/dist/runtime/application/turn/turn-event-recorder.d.ts +1 -0
  52. package/dist/runtime/application/turn/turn-execution-view.d.ts +43 -0
  53. package/dist/runtime/application/turn/turn-recovery-service.d.ts +14 -0
  54. package/dist/runtime/application/turn-service.d.ts +28 -0
  55. package/dist/runtime/application/user-question-service.d.ts +1 -0
  56. package/dist/runtime/bootstrap/runtime-bootstrap-service.d.ts +2 -0
  57. package/dist/runtime/domain/frozen-run-config.d.ts +2 -0
  58. package/dist/runtime/domain/index.d.ts +16 -1
  59. package/dist/runtime/domain/input-inbox.d.ts +16 -0
  60. package/dist/runtime/domain/model-ref.d.ts +1 -1
  61. package/dist/runtime/domain/session-presentation.d.ts +9 -0
  62. package/dist/runtime/domain/thread-collaboration.d.ts +179 -0
  63. package/dist/runtime/domain/turn.d.ts +8 -0
  64. package/dist/runtime/ports/index.d.ts +6 -0
  65. package/dist/runtime/ports/lease-store.d.ts +4 -0
  66. package/dist/runtime/ports/session-image-store.d.ts +26 -0
  67. package/dist/runtime/ports/session-store.d.ts +16 -0
  68. package/dist/runtime/ports/thread-handoff.d.ts +14 -0
  69. package/dist/runtime/ports/thread-store.d.ts +15 -0
  70. package/dist/runtime/ports/transcript-store.d.ts +8 -0
  71. package/dist/runtime/protocol/browser-capability.d.ts +81 -0
  72. package/dist/runtime/protocol/browser-operation.d.ts +89 -0
  73. package/dist/runtime/protocol/chat-capability.d.ts +1 -0
  74. package/dist/runtime/protocol/error-code.d.ts +1 -1
  75. package/dist/runtime/protocol/frozen-run-config-view.d.ts +2 -1
  76. package/dist/runtime/protocol/index.d.ts +2 -1
  77. package/dist/runtime/protocol/recoverable-turn-view.d.ts +3 -0
  78. package/dist/runtime/protocol/run-config.d.ts +13 -0
  79. package/dist/runtime/protocol/threads-capability.d.ts +14 -0
  80. package/dist/runtime/protocol/web-capability.d.ts +5 -1
  81. package/dist/runtime/protocol/work-preview-capability.d.ts +1 -0
  82. package/dist/runtime/provider/anthropic-messages-adapter.d.ts +4 -2
  83. package/dist/runtime/provider/api-protocol.d.ts +16 -2
  84. package/dist/runtime/provider/compatibility-presets.d.ts +19 -0
  85. package/dist/runtime/provider/frozen-provider-config.d.ts +4 -1
  86. package/dist/runtime/provider/index.d.ts +4 -2
  87. package/dist/runtime/provider/model-capability-catalog.d.ts +7 -0
  88. package/dist/runtime/provider/model-sample-resolver.d.ts +3 -2
  89. package/dist/runtime/provider/openai-chat-completions-adapter.d.ts +5 -1
  90. package/dist/runtime/provider/openai-responses-adapter.d.ts +22 -0
  91. package/dist/runtime/provider/provider-failure-guidance.d.ts +4 -0
  92. package/dist/runtime/provider/provider-failure-normalization.d.ts +9 -0
  93. package/dist/runtime/public/agent-runtime.d.ts +5 -0
  94. package/dist/ui/catalog.d.ts +870 -0
  95. package/dist/ui/document.d.ts +580 -0
  96. package/dist/ui/index.d.ts +4 -0
  97. package/dist/ui/index.js +1 -0
  98. package/dist/ui/index.mjs +1 -0
  99. package/package.json +17 -3
@@ -0,0 +1,1027 @@
1
+ import { AgentRuntimeError } from "../protocol/error-code";
2
+ import type { AgentErrorCode } from "../protocol/error-code";
3
+ import type { RuntimePorts } from "../ports";
4
+ import type { ThreadStore } from "../ports/thread-store";
5
+ import type { ThreadActor, ThreadControl, ThreadDelivery, ThreadGroup, ThreadHandoffInput, ThreadHandoffRef, ThreadMessage, ThreadEvent, ThreadProgressKind } from "../domain/thread-collaboration";
6
+ import type { ThreadHandoffWriter } from "../ports/thread-handoff";
7
+ import type { InboxInput } from "../domain/input-inbox";
8
+ export interface ThreadHostContext {
9
+ workspaceId: string;
10
+ executionHost?: string;
11
+ stateRootId: string;
12
+ projectId: string;
13
+ allowedTools: readonly string[];
14
+ humanPrincipalId?: string;
15
+ allowRootGroupBootstrap?: boolean;
16
+ modelCatalog: readonly import("../domain/model-ref").ModelRef[];
17
+ hostOnline?: boolean;
18
+ handoff?: ThreadHandoffWriter;
19
+ actor: ThreadActor;
20
+ }
21
+ export declare class ThreadServiceError extends AgentRuntimeError {
22
+ constructor(code: AgentErrorCode);
23
+ }
24
+ export declare function interactionCheckpointDigest(checkpoint: import("../protocol").AgentCheckpoint): string;
25
+ export declare function threadHandoffPath(workspaceId: string, actor: ThreadActor, requestId: string): string;
26
+ export declare function createThreadService(ports: RuntimePorts, store: ThreadStore, context: ThreadHostContext): {
27
+ enable: (input: {
28
+ requestId: string;
29
+ rootThreadId: string;
30
+ groupId?: string;
31
+ }) => Promise<ThreadControl>;
32
+ disable: (input: {
33
+ requestId: string;
34
+ groupId: string;
35
+ }) => Promise<{
36
+ groupId: string;
37
+ enabled: false;
38
+ }>;
39
+ groups: (input?: {
40
+ cursor?: string;
41
+ limit?: number;
42
+ }) => Promise<{
43
+ nextCursor?: string | undefined;
44
+ items: {
45
+ groupId: string;
46
+ revision: number;
47
+ rootThreadId: string;
48
+ enabled: boolean;
49
+ createdAt: number;
50
+ allowedTools: string[];
51
+ members: {
52
+ threadId: string;
53
+ parentThreadId: string | null;
54
+ title: string | undefined;
55
+ roleLabel: string | undefined;
56
+ createdAt: number;
57
+ }[];
58
+ }[];
59
+ }>;
60
+ groupOf: (input: {
61
+ threadId: string;
62
+ groupId?: string;
63
+ }) => Promise<{
64
+ group: ReturnType<(control: ThreadControl) => {
65
+ groupId: string;
66
+ revision: number;
67
+ rootThreadId: string;
68
+ enabled: boolean;
69
+ createdAt: number;
70
+ allowedTools: string[];
71
+ members: {
72
+ threadId: string;
73
+ parentThreadId: string | null;
74
+ title: string | undefined;
75
+ roleLabel: string | undefined;
76
+ createdAt: number;
77
+ }[];
78
+ }> | null;
79
+ }>;
80
+ associate: (input: {
81
+ groupId: string;
82
+ threadId: string;
83
+ requestId: string;
84
+ }) => Promise<{
85
+ groupId: string;
86
+ threadId: string;
87
+ }>;
88
+ bindExecutionHost: (input: {
89
+ groupId: string;
90
+ threadId: string;
91
+ expectedRevision: number;
92
+ executionHost: "cli-work-v1" | "web-work-v1";
93
+ }) => Promise<{
94
+ groupId: string;
95
+ threadId: string;
96
+ executionHost: string;
97
+ }>;
98
+ continueInteraction: (input: {
99
+ groupId: string;
100
+ threadId: string;
101
+ turnId: string;
102
+ approvalId?: string;
103
+ requestId?: string;
104
+ }) => Promise<{
105
+ controlId: string;
106
+ }>;
107
+ resolveGroup: (input?: {
108
+ groupId?: string;
109
+ threadIds?: readonly string[];
110
+ readOnly?: boolean;
111
+ }) => Promise<string | null>;
112
+ create: (input: {
113
+ groupId: string;
114
+ requestId: string;
115
+ parentThreadId: string;
116
+ title?: string;
117
+ roleLabel?: string;
118
+ modelRef?: import("../domain/model-ref").ModelRef;
119
+ reasoningEffort?: import("../domain/model-ref").ReasoningEffort;
120
+ }) => Promise<{
121
+ threadId: string;
122
+ groupId: string;
123
+ parentThreadId: string;
124
+ }>;
125
+ currentGroupId: () => Promise<string>;
126
+ currentGroupIdOrNull: () => Promise<string | null>;
127
+ ensureCurrentGroupForCreate: (selectedGroupId?: string) => Promise<string>;
128
+ listThreads: (input: {
129
+ groupId: string;
130
+ cursor?: string;
131
+ limit?: number;
132
+ }) => Promise<{
133
+ nextCursor?: string | undefined;
134
+ revision: number;
135
+ items: {
136
+ title?: string;
137
+ executionHost?: string;
138
+ threadId: string;
139
+ groupId: string;
140
+ parentThreadId: string | null;
141
+ roleLabel?: string;
142
+ createdAt: number;
143
+ }[];
144
+ }>;
145
+ readState: (groupId: string) => Promise<{
146
+ value: Record<string, unknown>;
147
+ revision: number;
148
+ updatedAt: number;
149
+ updatedBy: ThreadActor;
150
+ }>;
151
+ updateState: (input: {
152
+ groupId: string;
153
+ requestId: string;
154
+ expectedRevision: number;
155
+ operations: Array<{
156
+ op: "set";
157
+ key: string;
158
+ value: unknown;
159
+ } | {
160
+ op: "remove";
161
+ key: string;
162
+ }>;
163
+ }) => Promise<{
164
+ revision: number;
165
+ }>;
166
+ recordProgress: (input: {
167
+ groupId: string;
168
+ requestId: string;
169
+ kind: ThreadProgressKind;
170
+ summary: string;
171
+ evidence?: {
172
+ turnId?: string;
173
+ messageId?: string;
174
+ };
175
+ }) => Promise<{
176
+ progressSeq: number;
177
+ taskId: string;
178
+ taskProgressSeq: number;
179
+ }>;
180
+ readProgress: (input: {
181
+ groupId: string;
182
+ threadId: string;
183
+ taskId?: string;
184
+ cursor?: string;
185
+ limit?: number;
186
+ kinds?: ThreadProgressKind[];
187
+ }) => Promise<{
188
+ nextCursor?: string | undefined;
189
+ items: ThreadProgressView[];
190
+ cursor: string;
191
+ compacted: number;
192
+ }>;
193
+ send: (input: {
194
+ reportingAgreement?: {
195
+ taskId: string;
196
+ explicit: boolean;
197
+ };
198
+ groupId: string;
199
+ threadId: string;
200
+ requestId: string;
201
+ mode?: "notify" | "run" | "steer";
202
+ content: string;
203
+ replyTo?: string;
204
+ expectedTurnId?: string;
205
+ handoff?: ThreadHandoffInput;
206
+ }) => Promise<{
207
+ messageId: string;
208
+ mode: ThreadMessage["mode"];
209
+ expectedTurnId?: string;
210
+ taskId?: string;
211
+ deliverySeq: number;
212
+ deliveryStatus: "pending";
213
+ handoffRef?: ThreadHandoffRef;
214
+ }>;
215
+ messageStatus: (input: {
216
+ groupId: string;
217
+ threadId: string;
218
+ messageId: string;
219
+ }) => Promise<{
220
+ inputState?: {
221
+ inputId: string;
222
+ turnId: string;
223
+ status: InboxInput["status"];
224
+ } | undefined;
225
+ execution?: {
226
+ turnId: string;
227
+ status: import("../domain").TurnStatus;
228
+ } | undefined;
229
+ turnId?: string | undefined;
230
+ inputId?: string | undefined;
231
+ messageId: string;
232
+ deliverySeq: number;
233
+ deliveryStatus: "failed" | "cancelled" | "pending" | "claimed" | "delivered" | "blocked" | "accepted";
234
+ }>;
235
+ interrupt: (input: {
236
+ groupId: string;
237
+ requestId: string;
238
+ threadId: string;
239
+ expectedTurnId: string;
240
+ }) => Promise<{
241
+ accepted: true;
242
+ controlId: string;
243
+ hostOffline: boolean;
244
+ }>;
245
+ resume: (input: {
246
+ groupId: string;
247
+ requestId: string;
248
+ threadId: string;
249
+ expectedTurnId: string;
250
+ }) => Promise<{
251
+ accepted: true;
252
+ controlId: string;
253
+ recoveryAction?: "open_target_continue";
254
+ }>;
255
+ wait: (input: {
256
+ groupId: string;
257
+ targets: Array<{
258
+ threadId: string;
259
+ taskId?: string;
260
+ cursor?: string;
261
+ }>;
262
+ timeoutMs: number;
263
+ signal?: AbortSignal;
264
+ }) => Promise<WaitResult>;
265
+ tasks: (input: {
266
+ groupId: string;
267
+ threadId: string;
268
+ }) => Promise<{
269
+ items: {
270
+ turnId?: string | undefined;
271
+ turnStatus?: import("../domain").TurnStatus | undefined;
272
+ taskId: string;
273
+ threadId: string;
274
+ title: string;
275
+ createdAt: number;
276
+ deliveryStatus: "failed" | "cancelled" | "pending" | "claimed" | "delivered" | "blocked";
277
+ }[];
278
+ }>;
279
+ listMessages: (input: {
280
+ groupId: string;
281
+ threadId: string;
282
+ cursor?: string;
283
+ limit?: number;
284
+ }) => Promise<{
285
+ nextCursor?: string | undefined;
286
+ items: (ThreadMessage & {
287
+ deliveryReason?: import("../domain/thread-collaboration").ThreadDeliveryReason;
288
+ inputState?: ReturnType<(message: ThreadMessage, delivery: ThreadDelivery | undefined, inputs: readonly InboxInput[]) => {
289
+ inputId: string;
290
+ turnId: string;
291
+ status: InboxInput["status"];
292
+ } | undefined>;
293
+ })[];
294
+ cursor: string;
295
+ }>;
296
+ readThread: (input: {
297
+ groupId: string;
298
+ threadId: string;
299
+ cursor?: string;
300
+ limit?: number;
301
+ }) => Promise<{
302
+ nextCursor?: string | undefined;
303
+ latestMessages: {
304
+ id: string;
305
+ role: "assistant";
306
+ content: string;
307
+ turnId: string | undefined;
308
+ createdAt: number;
309
+ }[];
310
+ history: {
311
+ content?: string | undefined;
312
+ seq: number;
313
+ turnId: string;
314
+ timestamp: string;
315
+ type: "turn_failed" | "turn_interrupted" | "turn_limit_reached" | "turn_started" | "thread_wait" | "reasoning_summary" | "reasoning_delta" | "answer_delta" | "answer_reset" | "answer_discard" | "tool_started" | "tool_progress" | "tool_result" | "ui_document" | "approval_required" | "question_required" | "question_answered" | "todo_updated" | "input_queued" | "input_joined" | "input_consumed" | "model_recovery" | "context_overflow" | "context_compact_started" | "context_compacted" | "context_compact_failed" | "context_compact_circuit_open" | "context_usage_updated" | "undo_completed" | "undo_failed" | "turn_paused" | "turn_completed";
316
+ }[];
317
+ turn?: {
318
+ turnId: string;
319
+ status: import("../domain").TurnStatus;
320
+ } | undefined;
321
+ thread: {
322
+ threadId: string;
323
+ title: string | undefined;
324
+ status: import("../domain").SessionStatus;
325
+ activeTurnId: string | undefined;
326
+ };
327
+ }>;
328
+ listEvents: (input: {
329
+ groupId: string;
330
+ cursor?: string;
331
+ limit?: number;
332
+ }) => Promise<{
333
+ nextCursor?: string | undefined;
334
+ items: ThreadEvent[];
335
+ cursor: string;
336
+ }>;
337
+ capabilities: () => {
338
+ protocolVersion: 1;
339
+ operations: string[];
340
+ deliveryModes: string[];
341
+ handoff: {
342
+ available: boolean;
343
+ modes: string[];
344
+ titleMax: number;
345
+ markdownBytes: number;
346
+ relativePath: string;
347
+ };
348
+ limits: {
349
+ pageDefault: number;
350
+ pageMax: number;
351
+ messageBytes: number;
352
+ stateBytes: number;
353
+ stateDepth: number;
354
+ controlBytes: number;
355
+ admissionBytes: number;
356
+ completionReservePerIntent: number;
357
+ waitTargets: number;
358
+ waitTimeoutMs: number;
359
+ progressBytes: number;
360
+ progressEntriesPerThread: number;
361
+ progressPageMax: number;
362
+ progressKinds: ThreadProgressKind[];
363
+ };
364
+ };
365
+ };
366
+ export type ThreadService = ReturnType<typeof createThreadService>;
367
+ export interface WaitTargetResult {
368
+ threadId: string;
369
+ taskId?: string;
370
+ reason: "snapshot" | "changed" | "progress" | "attention" | "terminal" | "timeout" | "aborted";
371
+ cursor: string;
372
+ pendingProgress: number;
373
+ summary: Record<string, unknown>;
374
+ }
375
+ export interface WaitResult {
376
+ results: WaitTargetResult[];
377
+ timedOut: boolean;
378
+ }
379
+ export interface ThreadProgressView {
380
+ threadId: string;
381
+ taskId?: string;
382
+ turnId?: string;
383
+ kind: ThreadProgressKind;
384
+ summary: string;
385
+ progressSeq: number;
386
+ mergedCount: number;
387
+ createdAt: number;
388
+ evidence?: {
389
+ turnId?: string;
390
+ messageId?: string;
391
+ };
392
+ }
393
+ export declare function hasEnabledThreadMembership(ports: RuntimePorts, capability: {
394
+ workspaceId: string;
395
+ projectId: string;
396
+ }, threadId: string): Promise<boolean>;
397
+ export declare function createThreadFacade(ports: RuntimePorts, context: ThreadHostContext, service?: {
398
+ enable: (input: {
399
+ requestId: string;
400
+ rootThreadId: string;
401
+ groupId?: string;
402
+ }) => Promise<ThreadControl>;
403
+ disable: (input: {
404
+ requestId: string;
405
+ groupId: string;
406
+ }) => Promise<{
407
+ groupId: string;
408
+ enabled: false;
409
+ }>;
410
+ groups: (input?: {
411
+ cursor?: string;
412
+ limit?: number;
413
+ }) => Promise<{
414
+ nextCursor?: string | undefined;
415
+ items: {
416
+ groupId: string;
417
+ revision: number;
418
+ rootThreadId: string;
419
+ enabled: boolean;
420
+ createdAt: number;
421
+ allowedTools: string[];
422
+ members: {
423
+ threadId: string;
424
+ parentThreadId: string | null;
425
+ title: string | undefined;
426
+ roleLabel: string | undefined;
427
+ createdAt: number;
428
+ }[];
429
+ }[];
430
+ }>;
431
+ groupOf: (input: {
432
+ threadId: string;
433
+ groupId?: string;
434
+ }) => Promise<{
435
+ group: ReturnType<(control: ThreadControl) => {
436
+ groupId: string;
437
+ revision: number;
438
+ rootThreadId: string;
439
+ enabled: boolean;
440
+ createdAt: number;
441
+ allowedTools: string[];
442
+ members: {
443
+ threadId: string;
444
+ parentThreadId: string | null;
445
+ title: string | undefined;
446
+ roleLabel: string | undefined;
447
+ createdAt: number;
448
+ }[];
449
+ }> | null;
450
+ }>;
451
+ associate: (input: {
452
+ groupId: string;
453
+ threadId: string;
454
+ requestId: string;
455
+ }) => Promise<{
456
+ groupId: string;
457
+ threadId: string;
458
+ }>;
459
+ bindExecutionHost: (input: {
460
+ groupId: string;
461
+ threadId: string;
462
+ expectedRevision: number;
463
+ executionHost: "cli-work-v1" | "web-work-v1";
464
+ }) => Promise<{
465
+ groupId: string;
466
+ threadId: string;
467
+ executionHost: string;
468
+ }>;
469
+ continueInteraction: (input: {
470
+ groupId: string;
471
+ threadId: string;
472
+ turnId: string;
473
+ approvalId?: string;
474
+ requestId?: string;
475
+ }) => Promise<{
476
+ controlId: string;
477
+ }>;
478
+ resolveGroup: (input?: {
479
+ groupId?: string;
480
+ threadIds?: readonly string[];
481
+ readOnly?: boolean;
482
+ }) => Promise<string | null>;
483
+ create: (input: {
484
+ groupId: string;
485
+ requestId: string;
486
+ parentThreadId: string;
487
+ title?: string;
488
+ roleLabel?: string;
489
+ modelRef?: import("../domain/model-ref").ModelRef;
490
+ reasoningEffort?: import("../domain/model-ref").ReasoningEffort;
491
+ }) => Promise<{
492
+ threadId: string;
493
+ groupId: string;
494
+ parentThreadId: string;
495
+ }>;
496
+ currentGroupId: () => Promise<string>;
497
+ currentGroupIdOrNull: () => Promise<string | null>;
498
+ ensureCurrentGroupForCreate: (selectedGroupId?: string) => Promise<string>;
499
+ listThreads: (input: {
500
+ groupId: string;
501
+ cursor?: string;
502
+ limit?: number;
503
+ }) => Promise<{
504
+ nextCursor?: string | undefined;
505
+ revision: number;
506
+ items: {
507
+ title?: string;
508
+ executionHost?: string;
509
+ threadId: string;
510
+ groupId: string;
511
+ parentThreadId: string | null;
512
+ roleLabel?: string;
513
+ createdAt: number;
514
+ }[];
515
+ }>;
516
+ readState: (groupId: string) => Promise<{
517
+ value: Record<string, unknown>;
518
+ revision: number;
519
+ updatedAt: number;
520
+ updatedBy: ThreadActor;
521
+ }>;
522
+ updateState: (input: {
523
+ groupId: string;
524
+ requestId: string;
525
+ expectedRevision: number;
526
+ operations: Array<{
527
+ op: "set";
528
+ key: string;
529
+ value: unknown;
530
+ } | {
531
+ op: "remove";
532
+ key: string;
533
+ }>;
534
+ }) => Promise<{
535
+ revision: number;
536
+ }>;
537
+ recordProgress: (input: {
538
+ groupId: string;
539
+ requestId: string;
540
+ kind: ThreadProgressKind;
541
+ summary: string;
542
+ evidence?: {
543
+ turnId?: string;
544
+ messageId?: string;
545
+ };
546
+ }) => Promise<{
547
+ progressSeq: number;
548
+ taskId: string;
549
+ taskProgressSeq: number;
550
+ }>;
551
+ readProgress: (input: {
552
+ groupId: string;
553
+ threadId: string;
554
+ taskId?: string;
555
+ cursor?: string;
556
+ limit?: number;
557
+ kinds?: ThreadProgressKind[];
558
+ }) => Promise<{
559
+ nextCursor?: string | undefined;
560
+ items: ThreadProgressView[];
561
+ cursor: string;
562
+ compacted: number;
563
+ }>;
564
+ send: (input: {
565
+ reportingAgreement?: {
566
+ taskId: string;
567
+ explicit: boolean;
568
+ };
569
+ groupId: string;
570
+ threadId: string;
571
+ requestId: string;
572
+ mode?: "notify" | "run" | "steer";
573
+ content: string;
574
+ replyTo?: string;
575
+ expectedTurnId?: string;
576
+ handoff?: ThreadHandoffInput;
577
+ }) => Promise<{
578
+ messageId: string;
579
+ mode: ThreadMessage["mode"];
580
+ expectedTurnId?: string;
581
+ taskId?: string;
582
+ deliverySeq: number;
583
+ deliveryStatus: "pending";
584
+ handoffRef?: ThreadHandoffRef;
585
+ }>;
586
+ messageStatus: (input: {
587
+ groupId: string;
588
+ threadId: string;
589
+ messageId: string;
590
+ }) => Promise<{
591
+ inputState?: {
592
+ inputId: string;
593
+ turnId: string;
594
+ status: InboxInput["status"];
595
+ } | undefined;
596
+ execution?: {
597
+ turnId: string;
598
+ status: import("../domain").TurnStatus;
599
+ } | undefined;
600
+ turnId?: string | undefined;
601
+ inputId?: string | undefined;
602
+ messageId: string;
603
+ deliverySeq: number;
604
+ deliveryStatus: "failed" | "cancelled" | "pending" | "claimed" | "delivered" | "blocked" | "accepted";
605
+ }>;
606
+ interrupt: (input: {
607
+ groupId: string;
608
+ requestId: string;
609
+ threadId: string;
610
+ expectedTurnId: string;
611
+ }) => Promise<{
612
+ accepted: true;
613
+ controlId: string;
614
+ hostOffline: boolean;
615
+ }>;
616
+ resume: (input: {
617
+ groupId: string;
618
+ requestId: string;
619
+ threadId: string;
620
+ expectedTurnId: string;
621
+ }) => Promise<{
622
+ accepted: true;
623
+ controlId: string;
624
+ recoveryAction?: "open_target_continue";
625
+ }>;
626
+ wait: (input: {
627
+ groupId: string;
628
+ targets: Array<{
629
+ threadId: string;
630
+ taskId?: string;
631
+ cursor?: string;
632
+ }>;
633
+ timeoutMs: number;
634
+ signal?: AbortSignal;
635
+ }) => Promise<WaitResult>;
636
+ tasks: (input: {
637
+ groupId: string;
638
+ threadId: string;
639
+ }) => Promise<{
640
+ items: {
641
+ turnId?: string | undefined;
642
+ turnStatus?: import("../domain").TurnStatus | undefined;
643
+ taskId: string;
644
+ threadId: string;
645
+ title: string;
646
+ createdAt: number;
647
+ deliveryStatus: "failed" | "cancelled" | "pending" | "claimed" | "delivered" | "blocked";
648
+ }[];
649
+ }>;
650
+ listMessages: (input: {
651
+ groupId: string;
652
+ threadId: string;
653
+ cursor?: string;
654
+ limit?: number;
655
+ }) => Promise<{
656
+ nextCursor?: string | undefined;
657
+ items: (ThreadMessage & {
658
+ deliveryReason?: import("../domain/thread-collaboration").ThreadDeliveryReason;
659
+ inputState?: ReturnType<(message: ThreadMessage, delivery: ThreadDelivery | undefined, inputs: readonly InboxInput[]) => {
660
+ inputId: string;
661
+ turnId: string;
662
+ status: InboxInput["status"];
663
+ } | undefined>;
664
+ })[];
665
+ cursor: string;
666
+ }>;
667
+ readThread: (input: {
668
+ groupId: string;
669
+ threadId: string;
670
+ cursor?: string;
671
+ limit?: number;
672
+ }) => Promise<{
673
+ nextCursor?: string | undefined;
674
+ latestMessages: {
675
+ id: string;
676
+ role: "assistant";
677
+ content: string;
678
+ turnId: string | undefined;
679
+ createdAt: number;
680
+ }[];
681
+ history: {
682
+ content?: string | undefined;
683
+ seq: number;
684
+ turnId: string;
685
+ timestamp: string;
686
+ type: "turn_failed" | "turn_interrupted" | "turn_limit_reached" | "turn_started" | "thread_wait" | "reasoning_summary" | "reasoning_delta" | "answer_delta" | "answer_reset" | "answer_discard" | "tool_started" | "tool_progress" | "tool_result" | "ui_document" | "approval_required" | "question_required" | "question_answered" | "todo_updated" | "input_queued" | "input_joined" | "input_consumed" | "model_recovery" | "context_overflow" | "context_compact_started" | "context_compacted" | "context_compact_failed" | "context_compact_circuit_open" | "context_usage_updated" | "undo_completed" | "undo_failed" | "turn_paused" | "turn_completed";
687
+ }[];
688
+ turn?: {
689
+ turnId: string;
690
+ status: import("../domain").TurnStatus;
691
+ } | undefined;
692
+ thread: {
693
+ threadId: string;
694
+ title: string | undefined;
695
+ status: import("../domain").SessionStatus;
696
+ activeTurnId: string | undefined;
697
+ };
698
+ }>;
699
+ listEvents: (input: {
700
+ groupId: string;
701
+ cursor?: string;
702
+ limit?: number;
703
+ }) => Promise<{
704
+ nextCursor?: string | undefined;
705
+ items: ThreadEvent[];
706
+ cursor: string;
707
+ }>;
708
+ capabilities: () => {
709
+ protocolVersion: 1;
710
+ operations: string[];
711
+ deliveryModes: string[];
712
+ handoff: {
713
+ available: boolean;
714
+ modes: string[];
715
+ titleMax: number;
716
+ markdownBytes: number;
717
+ relativePath: string;
718
+ };
719
+ limits: {
720
+ pageDefault: number;
721
+ pageMax: number;
722
+ messageBytes: number;
723
+ stateBytes: number;
724
+ stateDepth: number;
725
+ controlBytes: number;
726
+ admissionBytes: number;
727
+ completionReservePerIntent: number;
728
+ waitTargets: number;
729
+ waitTimeoutMs: number;
730
+ progressBytes: number;
731
+ progressEntriesPerThread: number;
732
+ progressPageMax: number;
733
+ progressKinds: ThreadProgressKind[];
734
+ };
735
+ };
736
+ }): {
737
+ enable(input: Parameters<typeof service.enable>[0] & {
738
+ protocolVersion: number;
739
+ }): Promise<{
740
+ protocolVersion: 1;
741
+ group: ThreadGroup;
742
+ }>;
743
+ disable(input: Parameters<typeof service.disable>[0] & {
744
+ protocolVersion: number;
745
+ }): Promise<{
746
+ groupId: string;
747
+ enabled: false;
748
+ protocolVersion: 1;
749
+ }>;
750
+ groups(input: Parameters<typeof service.groups>[0] & {
751
+ protocolVersion: number;
752
+ }): Promise<{
753
+ nextCursor?: string | undefined;
754
+ items: {
755
+ groupId: string;
756
+ revision: number;
757
+ rootThreadId: string;
758
+ enabled: boolean;
759
+ createdAt: number;
760
+ allowedTools: string[];
761
+ members: {
762
+ threadId: string;
763
+ parentThreadId: string | null;
764
+ title: string | undefined;
765
+ roleLabel: string | undefined;
766
+ createdAt: number;
767
+ }[];
768
+ }[];
769
+ protocolVersion: 1;
770
+ }>;
771
+ groupOf(input: Parameters<typeof service.groupOf>[0] & {
772
+ protocolVersion: number;
773
+ }): Promise<{
774
+ group: ReturnType<(control: ThreadControl) => {
775
+ groupId: string;
776
+ revision: number;
777
+ rootThreadId: string;
778
+ enabled: boolean;
779
+ createdAt: number;
780
+ allowedTools: string[];
781
+ members: {
782
+ threadId: string;
783
+ parentThreadId: string | null;
784
+ title: string | undefined;
785
+ roleLabel: string | undefined;
786
+ createdAt: number;
787
+ }[];
788
+ }> | null;
789
+ protocolVersion: 1;
790
+ }>;
791
+ bindExecutionHost(input: Parameters<typeof service.bindExecutionHost>[0] & {
792
+ protocolVersion: number;
793
+ }): Promise<{
794
+ groupId: string;
795
+ threadId: string;
796
+ executionHost: string;
797
+ protocolVersion: 1;
798
+ }>;
799
+ associate(input: Parameters<typeof service.associate>[0] & {
800
+ protocolVersion: number;
801
+ }): Promise<{
802
+ groupId: string;
803
+ threadId: string;
804
+ protocolVersion: 1;
805
+ }>;
806
+ create(input: Parameters<typeof service.create>[0] & {
807
+ protocolVersion: number;
808
+ }): Promise<{
809
+ relativeLink: string;
810
+ threadId: string;
811
+ groupId: string;
812
+ parentThreadId: string;
813
+ protocolVersion: 1;
814
+ }>;
815
+ list(input: Parameters<typeof service.listThreads>[0] & {
816
+ protocolVersion: number;
817
+ }): Promise<{
818
+ nextCursor?: string | undefined;
819
+ revision: number;
820
+ items: {
821
+ title?: string;
822
+ executionHost?: string;
823
+ threadId: string;
824
+ groupId: string;
825
+ parentThreadId: string | null;
826
+ roleLabel?: string;
827
+ createdAt: number;
828
+ }[];
829
+ protocolVersion: 1;
830
+ }>;
831
+ read(input: Parameters<typeof service.readThread>[0] & {
832
+ protocolVersion: number;
833
+ }): Promise<{
834
+ nextCursor?: string | undefined;
835
+ latestMessages: {
836
+ id: string;
837
+ role: "assistant";
838
+ content: string;
839
+ turnId: string | undefined;
840
+ createdAt: number;
841
+ }[];
842
+ history: {
843
+ content?: string | undefined;
844
+ seq: number;
845
+ turnId: string;
846
+ timestamp: string;
847
+ type: "turn_failed" | "turn_interrupted" | "turn_limit_reached" | "turn_started" | "thread_wait" | "reasoning_summary" | "reasoning_delta" | "answer_delta" | "answer_reset" | "answer_discard" | "tool_started" | "tool_progress" | "tool_result" | "ui_document" | "approval_required" | "question_required" | "question_answered" | "todo_updated" | "input_queued" | "input_joined" | "input_consumed" | "model_recovery" | "context_overflow" | "context_compact_started" | "context_compacted" | "context_compact_failed" | "context_compact_circuit_open" | "context_usage_updated" | "undo_completed" | "undo_failed" | "turn_paused" | "turn_completed";
848
+ }[];
849
+ turn?: {
850
+ turnId: string;
851
+ status: import("../domain").TurnStatus;
852
+ } | undefined;
853
+ thread: {
854
+ threadId: string;
855
+ title: string | undefined;
856
+ status: import("../domain").SessionStatus;
857
+ activeTurnId: string | undefined;
858
+ };
859
+ protocolVersion: 1;
860
+ }>;
861
+ send(input: Omit<Parameters<typeof service.send>[0], "reportingAgreement"> & {
862
+ protocolVersion: number;
863
+ }): Promise<{
864
+ hostOffline: true;
865
+ messageId: string;
866
+ mode: ThreadMessage["mode"];
867
+ expectedTurnId?: string;
868
+ taskId?: string;
869
+ deliverySeq: number;
870
+ deliveryStatus: "pending";
871
+ handoffRef?: ThreadHandoffRef;
872
+ protocolVersion: 1;
873
+ } | {
874
+ hostOffline?: undefined;
875
+ messageId: string;
876
+ mode: ThreadMessage["mode"];
877
+ expectedTurnId?: string;
878
+ taskId?: string;
879
+ deliverySeq: number;
880
+ deliveryStatus: "pending";
881
+ handoffRef?: ThreadHandoffRef;
882
+ protocolVersion: 1;
883
+ }>;
884
+ messageStatus(input: Parameters<typeof service.messageStatus>[0] & {
885
+ protocolVersion: number;
886
+ }): Promise<{
887
+ inputState?: {
888
+ inputId: string;
889
+ turnId: string;
890
+ status: InboxInput["status"];
891
+ } | undefined;
892
+ execution?: {
893
+ turnId: string;
894
+ status: import("../domain").TurnStatus;
895
+ } | undefined;
896
+ turnId?: string | undefined;
897
+ inputId?: string | undefined;
898
+ messageId: string;
899
+ deliverySeq: number;
900
+ deliveryStatus: "failed" | "cancelled" | "pending" | "claimed" | "delivered" | "blocked" | "accepted";
901
+ protocolVersion: 1;
902
+ }>;
903
+ interrupt(input: Parameters<typeof service.interrupt>[0] & {
904
+ protocolVersion: number;
905
+ }): Promise<{
906
+ accepted: true;
907
+ controlId: string;
908
+ hostOffline: boolean;
909
+ protocolVersion: 1;
910
+ }>;
911
+ resume(input: Parameters<typeof service.resume>[0] & {
912
+ protocolVersion: number;
913
+ }): Promise<{
914
+ accepted: true;
915
+ controlId: string;
916
+ recoveryAction?: "open_target_continue";
917
+ protocolVersion: 1;
918
+ }>;
919
+ tasks(input: Parameters<typeof service.tasks>[0] & {
920
+ protocolVersion: number;
921
+ }): Promise<{
922
+ items: {
923
+ turnId?: string | undefined;
924
+ turnStatus?: import("../domain").TurnStatus | undefined;
925
+ taskId: string;
926
+ threadId: string;
927
+ title: string;
928
+ createdAt: number;
929
+ deliveryStatus: "failed" | "cancelled" | "pending" | "claimed" | "delivered" | "blocked";
930
+ }[];
931
+ protocolVersion: 1;
932
+ }>;
933
+ wait(input: Parameters<typeof service.wait>[0] & {
934
+ protocolVersion: number;
935
+ }): Promise<{
936
+ results: WaitTargetResult[];
937
+ timedOut: boolean;
938
+ protocolVersion: 1;
939
+ }>;
940
+ messages(input: Parameters<typeof service.listMessages>[0] & {
941
+ protocolVersion: number;
942
+ }): Promise<{
943
+ nextCursor?: string | undefined;
944
+ items: (ThreadMessage & {
945
+ deliveryReason?: import("../domain/thread-collaboration").ThreadDeliveryReason;
946
+ inputState?: ReturnType<(message: ThreadMessage, delivery: ThreadDelivery | undefined, inputs: readonly InboxInput[]) => {
947
+ inputId: string;
948
+ turnId: string;
949
+ status: InboxInput["status"];
950
+ } | undefined>;
951
+ })[];
952
+ cursor: string;
953
+ protocolVersion: 1;
954
+ }>;
955
+ readState(input: {
956
+ protocolVersion: number;
957
+ groupId: string;
958
+ }): Promise<{
959
+ value: Record<string, unknown>;
960
+ revision: number;
961
+ updatedAt: number;
962
+ updatedBy: ThreadActor;
963
+ protocolVersion: 1;
964
+ }>;
965
+ updateState(input: Parameters<typeof service.updateState>[0] & {
966
+ protocolVersion: number;
967
+ }): Promise<{
968
+ revision: number;
969
+ protocolVersion: 1;
970
+ }>;
971
+ reportProgress(input: Parameters<typeof service.recordProgress>[0] & {
972
+ protocolVersion: number;
973
+ }): Promise<{
974
+ progressSeq: number;
975
+ taskId: string;
976
+ taskProgressSeq: number;
977
+ protocolVersion: 1;
978
+ }>;
979
+ readProgress(input: Parameters<typeof service.readProgress>[0] & {
980
+ protocolVersion: number;
981
+ }): Promise<{
982
+ nextCursor?: string | undefined;
983
+ items: ThreadProgressView[];
984
+ cursor: string;
985
+ compacted: number;
986
+ protocolVersion: 1;
987
+ }>;
988
+ events(input: Parameters<typeof service.listEvents>[0] & {
989
+ protocolVersion: number;
990
+ }): Promise<{
991
+ nextCursor?: string | undefined;
992
+ items: ThreadEvent[];
993
+ cursor: string;
994
+ protocolVersion: 1;
995
+ }>;
996
+ capabilities(input: {
997
+ protocolVersion: number;
998
+ }): {
999
+ protocolVersion: 1;
1000
+ operations: string[];
1001
+ deliveryModes: string[];
1002
+ handoff: {
1003
+ available: boolean;
1004
+ modes: string[];
1005
+ titleMax: number;
1006
+ markdownBytes: number;
1007
+ relativePath: string;
1008
+ };
1009
+ limits: {
1010
+ pageDefault: number;
1011
+ pageMax: number;
1012
+ messageBytes: number;
1013
+ stateBytes: number;
1014
+ stateDepth: number;
1015
+ controlBytes: number;
1016
+ admissionBytes: number;
1017
+ completionReservePerIntent: number;
1018
+ waitTargets: number;
1019
+ waitTimeoutMs: number;
1020
+ progressBytes: number;
1021
+ progressEntriesPerThread: number;
1022
+ progressPageMax: number;
1023
+ progressKinds: ThreadProgressKind[];
1024
+ };
1025
+ };
1026
+ };
1027
+ export type ThreadFacade = ReturnType<typeof createThreadFacade>;