forked from pingdotgg/t3code
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProviderAdapter.ts
More file actions
600 lines (563 loc) · 21 KB
/
Copy pathProviderAdapter.ts
File metadata and controls
600 lines (563 loc) · 21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
import type { OrchestrationV2HistoricalMessage } from "@t3tools/contracts";
import {
ChatAttachment,
CheckpointId,
MessageId,
ModelSelection,
NodeId,
OrchestrationV2AppThread,
OrchestrationV2ConversationMessage,
OrchestrationV2ExecutionNode,
OrchestrationV2ProviderSession,
OrchestrationV2PlanArtifact,
OrchestrationV2ProviderCapabilities,
OrchestrationV2ProviderFailure,
OrchestrationV2ProviderRetry,
OrchestrationV2ProviderThread,
OrchestrationV2ProviderTurn,
OrchestrationV2RuntimeRequest,
OrchestrationV2Subagent,
OrchestrationV2TurnItem,
ProviderApprovalDecision,
ProviderInteractionMode,
ProviderDriverKind,
ProviderInstanceId,
PositiveInt,
ProviderUserInputAnswers,
ProviderSessionId,
ProviderThreadId,
ProviderTurnId,
RuntimeMode,
RuntimeRequestId,
RunAttemptId,
RunId,
ThreadId,
} from "@t3tools/contracts";
import * as Context from "effect/Context";
import * as Schema from "effect/Schema";
import type * as Effect from "effect/Effect";
import type * as Scope from "effect/Scope";
import type * as Stream from "effect/Stream";
import type {
ProviderSelectionTransitionInput,
ProviderSelectionTransitionPlan,
} from "./ProviderSelectionTransition.ts";
export const ProviderAdapterV2RuntimePolicy = Schema.Struct({
runtimeMode: RuntimeMode,
interactionMode: ProviderInteractionMode,
cwd: Schema.NullOr(Schema.String),
approvalPolicy: Schema.optional(Schema.Unknown),
sandboxPolicy: Schema.optional(Schema.Unknown),
reasoningEffort: Schema.optional(Schema.String),
});
export type ProviderAdapterV2RuntimePolicy = typeof ProviderAdapterV2RuntimePolicy.Type;
export const ProviderAdapterV2TurnMessage = Schema.Struct({
messageId: MessageId,
text: Schema.String,
attachments: Schema.Array(ChatAttachment),
createdBy: OrchestrationV2ConversationMessage.fields.createdBy,
creationSource: OrchestrationV2ConversationMessage.fields.creationSource,
scheduledTaskId: OrchestrationV2ConversationMessage.fields.scheduledTaskId,
senderThreadId: OrchestrationV2ConversationMessage.fields.senderThreadId,
});
export type ProviderAdapterV2TurnMessage = typeof ProviderAdapterV2TurnMessage.Type;
export const ProviderAdapterV2SessionStatus = Schema.Literals([
"starting",
"ready",
"running",
"waiting",
"stopped",
"error",
]);
export type ProviderAdapterV2SessionStatus = typeof ProviderAdapterV2SessionStatus.Type;
export const ProviderAdapterV2Event = Schema.Union([
Schema.Struct({
type: Schema.Literal("app_thread.created"),
driver: ProviderDriverKind,
appThread: OrchestrationV2AppThread,
}),
Schema.Struct({
type: Schema.Literal("provider_session.updated"),
driver: ProviderDriverKind,
providerSession: OrchestrationV2ProviderSession,
}),
Schema.Struct({
type: Schema.Literal("provider_thread.updated"),
driver: ProviderDriverKind,
providerThread: OrchestrationV2ProviderThread,
}),
Schema.Struct({
type: Schema.Literal("provider_turn.updated"),
driver: ProviderDriverKind,
threadId: Schema.optional(ThreadId),
providerTurn: OrchestrationV2ProviderTurn,
}),
Schema.Struct({
type: Schema.Literal("node.updated"),
driver: ProviderDriverKind,
node: OrchestrationV2ExecutionNode,
}),
Schema.Struct({
type: Schema.Literal("subagent.updated"),
driver: ProviderDriverKind,
subagent: OrchestrationV2Subagent,
}),
Schema.Struct({
type: Schema.Literal("message.updated"),
driver: ProviderDriverKind,
message: OrchestrationV2ConversationMessage,
}),
Schema.Struct({
type: Schema.Literal("turn_item.updated"),
driver: ProviderDriverKind,
turnItem: OrchestrationV2TurnItem,
}),
Schema.Struct({
type: Schema.Literal("runtime_request.updated"),
driver: ProviderDriverKind,
threadId: Schema.optional(ThreadId),
runtimeRequest: OrchestrationV2RuntimeRequest,
}),
Schema.Struct({
type: Schema.Literal("plan.updated"),
driver: ProviderDriverKind,
plan: OrchestrationV2PlanArtifact,
}),
Schema.Struct({
type: Schema.Literal("turn.terminal"),
driver: ProviderDriverKind,
providerThreadId: ProviderThreadId,
providerTurnId: ProviderTurnId,
runOrdinal: PositiveInt,
status: Schema.Literals(["completed", "interrupted", "cancelled"]),
failure: Schema.Null,
threadDisposition: Schema.Literals(["reusable", "broken"]),
}),
Schema.Struct({
type: Schema.Literal("turn.terminal"),
driver: ProviderDriverKind,
providerThreadId: ProviderThreadId,
providerTurnId: ProviderTurnId,
runOrdinal: PositiveInt,
failureItemOrdinal: PositiveInt,
status: Schema.Literal("failed"),
failure: OrchestrationV2ProviderFailure,
retry: Schema.optional(OrchestrationV2ProviderRetry),
retryStartedAt: Schema.optional(Schema.DateTimeUtc),
threadDisposition: Schema.Literals(["reusable", "broken"]),
}),
]);
export type ProviderAdapterV2Event = typeof ProviderAdapterV2Event.Type;
export class ProviderAdapterCapabilitiesError extends Schema.TaggedError<ProviderAdapterCapabilitiesError>()(
"ProviderAdapterCapabilitiesError",
{
driver: ProviderDriverKind,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to read ${this.driver} provider capabilities.`;
}
}
export class ProviderAdapterOpenSessionError extends Schema.TaggedError<ProviderAdapterOpenSessionError>()(
"ProviderAdapterOpenSessionError",
{
driver: ProviderDriverKind,
providerSessionId: ProviderSessionId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to open ${this.driver} provider session ${this.providerSessionId}.`;
}
}
export class ProviderAdapterCloseSessionError extends Schema.TaggedError<ProviderAdapterCloseSessionError>()(
"ProviderAdapterCloseSessionError",
{
driver: ProviderDriverKind,
providerSessionId: ProviderSessionId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to close ${this.driver} provider session ${this.providerSessionId}.`;
}
}
export class ProviderAdapterResumeThreadError extends Schema.TaggedError<ProviderAdapterResumeThreadError>()(
"ProviderAdapterResumeThreadError",
{
driver: ProviderDriverKind,
providerSessionId: ProviderSessionId,
providerThreadId: ProviderThreadId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to resume ${this.driver} provider thread ${this.providerThreadId}.`;
}
}
export class ProviderAdapterEnsureThreadError extends Schema.TaggedError<ProviderAdapterEnsureThreadError>()(
"ProviderAdapterEnsureThreadError",
{
driver: ProviderDriverKind,
threadId: ThreadId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to ensure ${this.driver} provider thread for app thread ${this.threadId}.`;
}
}
export class ProviderAdapterReadThreadSnapshotError extends Schema.TaggedError<ProviderAdapterReadThreadSnapshotError>()(
"ProviderAdapterReadThreadSnapshotError",
{
driver: ProviderDriverKind,
providerThreadId: ProviderThreadId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to read ${this.driver} provider thread snapshot ${this.providerThreadId}.`;
}
}
export class ProviderAdapterRollbackThreadError extends Schema.TaggedError<ProviderAdapterRollbackThreadError>()(
"ProviderAdapterRollbackThreadError",
{
driver: ProviderDriverKind,
providerThreadId: ProviderThreadId,
checkpointId: Schema.optional(CheckpointId),
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to roll back ${this.driver} provider thread ${this.providerThreadId}.`;
}
}
export class ProviderAdapterForkThreadError extends Schema.TaggedError<ProviderAdapterForkThreadError>()(
"ProviderAdapterForkThreadError",
{
driver: ProviderDriverKind,
providerThreadId: ProviderThreadId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to fork ${this.driver} provider thread ${this.providerThreadId}.`;
}
}
export class ProviderAdapterTurnStartError extends Schema.TaggedError<ProviderAdapterTurnStartError>()(
"ProviderAdapterTurnStartError",
{
driver: ProviderDriverKind,
threadId: ThreadId,
providerThreadId: ProviderThreadId,
runId: RunId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to start run ${this.runId} on ${this.driver} provider thread ${this.providerThreadId}.`;
}
}
export class ProviderAdapterSteerRunUnsupportedError extends Schema.TaggedError<ProviderAdapterSteerRunUnsupportedError>()(
"ProviderAdapterSteerRunUnsupportedError",
{
driver: ProviderDriverKind,
providerThreadId: ProviderThreadId,
},
) {
override get message(): string {
return `${this.driver} provider thread ${this.providerThreadId} does not support active-run steering.`;
}
}
export class ProviderAdapterSteerRunError extends Schema.TaggedError<ProviderAdapterSteerRunError>()(
"ProviderAdapterSteerRunError",
{
driver: ProviderDriverKind,
providerThreadId: ProviderThreadId,
providerTurnId: ProviderTurnId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to steer active run ${this.providerTurnId} on ${this.driver} provider thread ${this.providerThreadId}.`;
}
}
export class ProviderAdapterInterruptError extends Schema.TaggedError<ProviderAdapterInterruptError>()(
"ProviderAdapterInterruptError",
{
driver: ProviderDriverKind,
providerThreadId: ProviderThreadId,
providerTurnId: ProviderTurnId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to interrupt ${this.driver} provider turn ${this.providerTurnId}.`;
}
}
export class ProviderAdapterRuntimeRequestResponseError extends Schema.TaggedError<ProviderAdapterRuntimeRequestResponseError>()(
"ProviderAdapterRuntimeRequestResponseError",
{
driver: ProviderDriverKind,
requestId: RuntimeRequestId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed to respond to ${this.driver} runtime request ${this.requestId}.`;
}
}
export class ProviderAdapterEventStreamError extends Schema.TaggedError<ProviderAdapterEventStreamError>()(
"ProviderAdapterEventStreamError",
{
driver: ProviderDriverKind,
providerSessionId: ProviderSessionId,
cause: Schema.optional(Schema.Defect()),
},
) {
override get message(): string {
return `Failed while streaming ${this.driver} provider session ${this.providerSessionId} events.`;
}
}
export class ProviderAdapterProtocolError extends Schema.TaggedError<ProviderAdapterProtocolError>()(
"ProviderAdapterProtocolError",
{
driver: ProviderDriverKind,
detail: Schema.String,
cause: Schema.optional(Schema.Defect()),
payload: Schema.optional(Schema.Unknown),
},
) {
override get message(): string {
return `${this.driver} provider protocol error: ${this.detail}.`;
}
}
export const ProviderAdapterV2Error = Schema.Union([
ProviderAdapterCapabilitiesError,
ProviderAdapterOpenSessionError,
ProviderAdapterCloseSessionError,
ProviderAdapterResumeThreadError,
ProviderAdapterEnsureThreadError,
ProviderAdapterReadThreadSnapshotError,
ProviderAdapterRollbackThreadError,
ProviderAdapterForkThreadError,
ProviderAdapterTurnStartError,
ProviderAdapterSteerRunUnsupportedError,
ProviderAdapterSteerRunError,
ProviderAdapterInterruptError,
ProviderAdapterRuntimeRequestResponseError,
ProviderAdapterEventStreamError,
ProviderAdapterProtocolError,
]);
export type ProviderAdapterV2Error = typeof ProviderAdapterV2Error.Type;
export interface ProviderAdapterV2OpenSessionInput {
readonly threadId: ThreadId;
readonly providerSessionId: ProviderSessionId;
readonly modelSelection: ModelSelection;
readonly runtimePolicy: ProviderAdapterV2RuntimePolicy;
readonly resumeFromSession?: OrchestrationV2ProviderSession;
/** Native thread to activate while an eager adapter opens its provider process. */
readonly initialNativeThreadId?: string;
/** Preserves provider item identity across eager activation of a persisted thread. */
readonly initialProviderItemIdentityVersion?: 2;
}
export interface ProviderAdapterV2EnsureThreadInput {
readonly threadId: ThreadId;
readonly modelSelection: ModelSelection;
readonly runtimePolicy: ProviderAdapterV2RuntimePolicy;
readonly providerSessionId?: ProviderSessionId;
readonly existingProviderThread?: OrchestrationV2ProviderThread;
}
export interface ProviderAdapterV2TurnInput {
readonly appThread: OrchestrationV2AppThread;
readonly threadId: ThreadId;
readonly runId: RunId;
readonly runOrdinal: number;
/** Whether the current native session has an accepted turn; omitted when unknown. */
readonly nativeThreadHasTurns?: boolean;
readonly providerTurnOrdinal: number;
readonly restartContinuationOfRunId?: RunId;
readonly attemptId: RunAttemptId;
readonly rootNodeId: NodeId;
readonly providerThread: OrchestrationV2ProviderThread;
readonly message: ProviderAdapterV2TurnMessage;
readonly modelSelection: ModelSelection;
readonly runtimePolicy: ProviderAdapterV2RuntimePolicy;
}
export interface ProviderAdapterV2SteerInput {
readonly threadId: ThreadId;
readonly runId: RunId;
readonly providerThread: OrchestrationV2ProviderThread;
readonly providerTurnId: ProviderTurnId;
readonly message: ProviderAdapterV2TurnMessage;
}
export interface ProviderAdapterV2InterruptInput {
readonly providerThread: OrchestrationV2ProviderThread;
readonly providerTurnId: ProviderTurnId;
/** When true, the next `startTurn` may respawn the provider runtime (Grok Stop recovery). */
readonly requestRuntimeRestart?: boolean;
}
export interface ProviderAdapterV2RuntimeRequestResponseInput {
readonly requestId: RuntimeRequestId;
readonly decision?: ProviderApprovalDecision;
readonly answers?: ProviderUserInputAnswers;
readonly response?: unknown;
}
export interface ProviderAdapterV2ThreadSnapshot {
readonly providerThread: OrchestrationV2ProviderThread;
readonly providerTurns: ReadonlyArray<OrchestrationV2ProviderTurn>;
readonly messages: ReadonlyArray<OrchestrationV2ConversationMessage>;
readonly runtimeRequests: ReadonlyArray<OrchestrationV2RuntimeRequest>;
readonly providerPayload?: unknown;
}
export interface ProviderAdapterV2ReadThreadSnapshotInput {
readonly providerThread: OrchestrationV2ProviderThread;
}
export type ProviderAdapterV2RollbackTarget =
| {
readonly type: "thread_start";
readonly checkpointId: CheckpointId;
readonly appRunOrdinal: 0;
}
| {
readonly type: "provider_turn";
readonly checkpointId: CheckpointId;
readonly appRunOrdinal: number;
readonly providerTurn: OrchestrationV2ProviderTurn;
};
export interface ProviderAdapterV2RollbackThreadInput {
readonly providerThread: OrchestrationV2ProviderThread;
readonly target: ProviderAdapterV2RollbackTarget;
readonly providerThreadTurns: ReadonlyArray<OrchestrationV2ProviderTurn>;
}
export interface ProviderAdapterV2ForkThreadInput {
readonly sourceProviderThread: OrchestrationV2ProviderThread;
readonly sourceProviderTurns?: ReadonlyArray<OrchestrationV2ProviderTurn>;
readonly providerTurnId?: ProviderTurnId;
readonly targetThreadId: ThreadId;
readonly ownerNodeId?: NodeId;
readonly modelSelection?: ModelSelection;
readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
}
export interface ProviderAdapterV2EventSubscription {
readonly events: Stream.Stream<ProviderAdapterV2Event, ProviderAdapterV2Error>;
readonly close: Effect.Effect<void>;
}
export interface ProviderAdapterV2HistoricalContext {
readonly messages: ReadonlyArray<OrchestrationV2HistoricalMessage>;
readonly context: string;
}
export interface ProviderAdapterV2SessionRuntime {
readonly instanceId: ProviderInstanceId;
readonly driver: ProviderDriverKind;
readonly providerSessionId: ProviderSessionId;
readonly providerSession: OrchestrationV2ProviderSession;
readonly events: Stream.Stream<ProviderAdapterV2Event, ProviderAdapterV2Error>;
/**
* Manager-owned runtimes expose a synchronous subscription so concurrent
* provider threads receive independent copies of the process event stream.
* Adapter runtimes may omit this and expose only their single-consumer event stream.
*/
readonly subscribeEvents?: Effect.Effect<ProviderAdapterV2EventSubscription>;
/**
* Adapters whose native runtime can hold pending work outside an active
* turn (for example Claude background tasks and their wake turns) report it
* here so the session manager defers idle release while it is pending.
*/
readonly hasPendingBackgroundWork?: Effect.Effect<boolean>;
/**
* Per-provider-thread pending work for root-run ingestion stop gates. When
* present, RunExecutionService uses only this probe (never the session-wide
* hasPendingBackgroundWork) so sibling native threads cannot pin an
* unrelated root subscription open.
*/
readonly hasPendingBackgroundWorkForThread?: (
providerThread: OrchestrationV2ProviderThread,
) => Effect.Effect<boolean>;
/**
* Capacity for the requested model/options, independent of native thread usage.
* `cwd` is the thread's working directory, for providers whose project config
* can change a model's limits.
*/
readonly getModelContextWindow?: (
modelSelection: ModelSelection,
cwd?: string | null,
) => number | undefined;
/** Whether an option-only change preserves measured native usage and capacity.
* Compaction thresholds are still discarded. Unknown transitions invalidate usage.
*/
readonly canReuseContextUsage?: (previous: ModelSelection, next: ModelSelection) => boolean;
readonly ensureThread: (
input: ProviderAdapterV2EnsureThreadInput,
) => Effect.Effect<OrchestrationV2ProviderThread, ProviderAdapterV2Error>;
readonly resumeThread: (input: {
readonly providerThread: OrchestrationV2ProviderThread;
readonly threadId?: ThreadId;
readonly modelSelection?: ModelSelection;
readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
}) => Effect.Effect<OrchestrationV2ProviderThread, ProviderAdapterV2Error>;
/** False means the native protocol explicitly does not support history injection. */
readonly injectHistory?: (
input: ProviderAdapterV2HistoricalContext & {
readonly providerThread: OrchestrationV2ProviderThread;
},
) => Effect.Effect<boolean, ProviderAdapterV2Error>;
readonly startTurn: (
input: ProviderAdapterV2TurnInput,
) => Effect.Effect<void, ProviderAdapterV2Error>;
readonly compactThread?: (
input: ProviderAdapterV2TurnInput,
) => Effect.Effect<void, ProviderAdapterV2Error>;
readonly steerTurn: (
input: ProviderAdapterV2SteerInput,
) => Effect.Effect<void, ProviderAdapterV2Error>;
readonly interruptTurn: (
input: ProviderAdapterV2InterruptInput,
) => Effect.Effect<void, ProviderAdapterV2Error>;
/**
* Lets a runtime shared by several app threads unload one provider thread's
* native state (and its MCP servers) when that app thread detaches, while
* the runtime keeps serving the others. A later resume reloads it.
*/
readonly unloadThread?: (input: {
readonly providerThread: OrchestrationV2ProviderThread;
}) => Effect.Effect<void, ProviderAdapterV2Error>;
readonly respondToRuntimeRequest: (
input: ProviderAdapterV2RuntimeRequestResponseInput,
) => Effect.Effect<void, ProviderAdapterV2Error>;
readonly readThreadSnapshot: (
input: ProviderAdapterV2ReadThreadSnapshotInput,
) => Effect.Effect<ProviderAdapterV2ThreadSnapshot, ProviderAdapterV2Error>;
/**
* Providers that accept product feedback for a thread (#7949, Codex → OpenAI)
* expose it here; absent means the driver has no feedback channel.
*/
readonly uploadFeedback?: (input: {
readonly providerThread: OrchestrationV2ProviderThread;
readonly reason?: string;
}) => Effect.Effect<{ readonly feedbackId: string }, ProviderAdapterV2Error>;
readonly rollbackThread: (
input: ProviderAdapterV2RollbackThreadInput,
) => Effect.Effect<ProviderAdapterV2ThreadSnapshot, ProviderAdapterV2Error>;
readonly forkThread: (
input: ProviderAdapterV2ForkThreadInput,
) => Effect.Effect<OrchestrationV2ProviderThread, ProviderAdapterV2Error>;
}
export interface ProviderAdapterV2Shape {
readonly instanceId: ProviderInstanceId;
readonly driver: ProviderDriverKind;
readonly getCapabilities: () => Effect.Effect<
OrchestrationV2ProviderCapabilities,
ProviderAdapterV2Error
>;
readonly planSelectionTransition: (
input: ProviderSelectionTransitionInput,
) => Effect.Effect<ProviderSelectionTransitionPlan, ProviderAdapterV2Error>;
readonly openSession: (
input: ProviderAdapterV2OpenSessionInput,
) => Effect.Effect<ProviderAdapterV2SessionRuntime, ProviderAdapterV2Error, Scope.Scope>;
}
export class ProviderAdapterV2 extends Context.Service<ProviderAdapterV2, ProviderAdapterV2Shape>()(
"t3/orchestration-v2/ProviderAdapter/ProviderAdapterV2",
) {}