The best way to control Claude Code, Codex and more from any computer or phone
refactor(providers): namespace-import service modules in core, Muse, Pi, and testing (#17375)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 8, 2026 at 18:05 UTC
2c7a446e657e705c257db28540819f4c0115b2fc
14 files changed
+112
-117
packages/provider-core/src/server/adapterDriver.ts
+6
-2
@@ -7,7 +7,7 @@ import * as Schema from "effect/Schema";
7
import type * as Effect from "effect/Effect";
8
import type * as Scope from "effect/Scope";
9
10
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
10
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
11
12
export class ProviderAdapterDriverCreateError extends Schema.TaggedError<ProviderAdapterDriverCreateError>()(
13
"ProviderAdapterDriverCreateError",
@@ -38,7 +38,11 @@ export interface ProviderAdapterDriver<Config, R = never> {
38
readonly defaultConfig: () => Config;
39
readonly create: (
40
input: ProviderAdapterDriverCreateInput<Config>,
41
- ) => Effect.Effect<ProviderAdapterV2Shape, ProviderAdapterDriverCreateError, R | Scope.Scope>;
41
+ ) => Effect.Effect<
42
+ ProviderAdapter.ProviderAdapterV2Shape,
43
+ ProviderAdapterDriverCreateError,
44
+ R | Scope.Scope
45
+ >;
46
}
47
48
export type AnyProviderAdapterDriver<R = never> = ProviderAdapterDriver<any, R>;
packages/provider-core/src/server/driver.ts
+2
-2
@@ -37,7 +37,7 @@ import type * as Effect from "effect/Effect";
37
import type * as Schema from "effect/Schema";
38
import type * as Scope from "effect/Scope";
39
40
-import type { ProviderAdapterV2Shape } from "./ProviderAdapter.ts";
40
+import type * as ProviderAdapter from "./ProviderAdapter.ts";
41
import type { ProviderAuthController } from "./auth.ts";
42
import type { ProviderDriverError } from "./errors.ts";
43
import type { ServerProviderShape } from "./snapshot.ts";
@@ -101,7 +101,7 @@ export interface ProviderInstance {
101
ProviderConsumeResetCreditOutcome,
102
ProviderDriverError
103
>;
104
- readonly orchestrationAdapter: ProviderAdapterV2Shape;
104
+ readonly orchestrationAdapter: ProviderAdapter.ProviderAdapterV2Shape;
105
readonly textGeneration: ProviderTextGeneration;
106
readonly auth?: ProviderAuthController;
107
readonly acpSessionManagement?: {
packages/provider-core/src/server/failure.test.ts
+2
-2
@@ -19,7 +19,7 @@ import {
19
ContextHandoffBudgetError,
20
} from "./failure.ts";
21
import * as IdAllocator from "./IdAllocator.ts";
22
-import { ProviderAdapterTurnStartError } from "@t3tools/provider-core/server/ProviderAdapter";
22
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
23
24
it("redacts credentials and URL secrets from provider failures", () => {
25
const failure = makeProviderFailure({
@@ -88,7 +88,7 @@ it("does not expose arbitrary cause messages and preserves explicit messages", (
88
});
89
90
it("preserves actionable handoff errors wrapped by turn startup", () => {
91
- const cause = new ProviderAdapterTurnStartError({
91
+ const cause = new ProviderAdapter.ProviderAdapterTurnStartError({
92
driver: ProviderDriverKind.make("codex"),
93
threadId: ThreadId.make("thread:handoff-error"),
94
providerThreadId: ProviderThreadId.make("provider-thread:handoff-error"),
packages/provider-core/src/server/failure.ts
+3
-3
@@ -13,7 +13,7 @@ import type {
13
import * as DateTime from "effect/DateTime";
14
import * as Cause from "effect/Cause";
15
16
-import type { IdAllocatorV2Shape } from "./IdAllocator.ts";
16
+import type * as IdAllocator from "./IdAllocator.ts";
17
import * as Schema from "effect/Schema";
18
19
/** Raised when portable history does not fit the target provider's context window. */
@@ -172,7 +172,7 @@ export function makeProviderFailure(input: {
172
}
173
174
export function makeProviderFailureTurnItem(input: {
175
- readonly idAllocator: IdAllocatorV2Shape;
175
+ readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
176
readonly driver: ProviderDriverKind;
177
readonly threadId: ThreadId;
178
readonly runId: RunId | null;
@@ -210,7 +210,7 @@ export function makeProviderFailureTurnItem(input: {
210
}
211
212
export function makeProviderRetryTurnItem(input: {
213
- readonly idAllocator: IdAllocatorV2Shape;
213
+ readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
214
readonly driver: ProviderDriverKind;
215
readonly threadId: ThreadId;
216
readonly runId: RunId | null;
packages/provider-core/src/server/managedProvider.test.ts
+5
-5
@@ -16,7 +16,7 @@ import * as Ref from "effect/Ref";
16
import * as Stream from "effect/Stream";
17
import { TestClock } from "effect/testing";
18
19
-import { ProviderHost, type ProviderHostShape } from "./ProviderHost.ts";
19
+import * as ProviderHost from "./ProviderHost.ts";
20
import { makeManagedServerProvider } from "./managedProvider.ts";
21
22
const emptyCapabilities = createModelCapabilities({ optionDescriptors: [] });
@@ -99,11 +99,11 @@ const refreshedSnapshotSecond: ServerProvider = {
99
/** A host whose settings never change and whose background demand is fixed. */
100
function layerProviderHost(input: {
101
readonly runBackgroundWork: boolean;
102
- readonly settings?: Pick<ProviderHostShape, "settings">["settings"];
102
+ readonly settings?: Pick<ProviderHost.ProviderHostShape, "settings">["settings"];
103
}) {
104
return Layer.succeed(
105
- ProviderHost,
106
- ProviderHost.of({
105
+ ProviderHost.ProviderHost,
106
+ ProviderHost.ProviderHost.of({
107
paths: {
108
cwd: process.cwd(),
109
baseDir: "/t3",
@@ -281,7 +281,7 @@ describe("makeManagedServerProvider", () => {
281
};
282
const serverSettingsRef = yield* Ref.make(initialServerSettings);
283
const serverSettingsChanges = yield* PubSub.unbounded<typeof initialServerSettings>();
284
- const hostSettings: ProviderHostShape["settings"] = {
284
+ const hostSettings: ProviderHost.ProviderHostShape["settings"] = {
285
get: Ref.get(serverSettingsRef),
286
changes: Stream.empty,
287
subscribe: PubSub.subscribe(serverSettingsChanges).pipe(
packages/provider-core/src/server/managedProvider.ts
+7
-3
@@ -15,7 +15,7 @@ import * as Scope from "effect/Scope";
15
import * as Stream from "effect/Stream";
16
import * as Semaphore from "effect/Semaphore";
17
18
-import { ProviderHost } from "./ProviderHost.ts";
18
+import * as ProviderHost from "./ProviderHost.ts";
19
import { applyUsageLimitsUpdate, resolveUsageLimitsAfterProbe } from "./usageLimits.ts";
20
import type { ServerProviderShape } from "./snapshot.ts";
21
@@ -53,8 +53,12 @@ export const makeManagedServerProvider = Effect.fn("makeManagedServerProvider")(
53
readonly refreshInterval?: Duration.Input;
54
readonly refreshOnInterval?: boolean;
55
readonly checkProviderOnSettingsChange?: (previous: Settings, next: Settings) => boolean;
56
-}): Effect.fn.Return<ServerProviderShape, ServerSettingsError, Scope.Scope | ProviderHost> {
57
- const host = yield* ProviderHost;
56
+}): Effect.fn.Return<
57
+ ServerProviderShape,
58
+ ServerSettingsError,
59
+ Scope.Scope | ProviderHost.ProviderHost
60
+> {
61
+ const host = yield* ProviderHost.ProviderHost;
62
const refreshSemaphore = yield* Semaphore.make(1);
63
const changesPubSub = yield* Effect.acquireRelease(
64
PubSub.unbounded<ServerProvider>(),
packages/provider-core/src/server/snapshotSettings.ts
+2
-2
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
3
import * as Equal from "effect/Equal";
4
import * as Stream from "effect/Stream";
5
6
-import type { ProviderHostShape } from "./ProviderHost.ts";
6
+import type * as ProviderHost from "./ProviderHost.ts";
7
8
export interface ProviderSnapshotSettings<Settings> {
9
readonly provider: Settings;
@@ -29,7 +29,7 @@ export function haveProviderSnapshotSettingsChanged<Settings>(
29
30
export function makeProviderSnapshotSettingsSource<Settings>(
31
provider: Settings,
32
- settings: ProviderHostShape["settings"],
32
+ settings: ProviderHost.ProviderHostShape["settings"],
33
): {
34
readonly getSettings: Effect.Effect<ProviderSnapshotSettings<Settings>, ServerSettingsError>;
35
readonly streamSettings: Stream.Stream<ProviderSnapshotSettings<Settings>>;
packages/provider-muse/src/server/adapter.test.ts
+20
-17
@@ -31,17 +31,13 @@ import * as Queue from "effect/Queue";
31
import * as Schema from "effect/Schema";
32
import * as Stream from "effect/Stream";
33
34
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
34
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
35
import { layerTestProviderHost } from "@t3tools/provider-testing/host";
36
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
37
import type { MuseItem } from "./protocol.ts";
38
import type { MuseSdkHost } from "./sdk.ts";
39
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
40
-import {
41
- ProviderAdapterV2RuntimePolicy,
42
- type ProviderAdapterV2Event,
43
- type ProviderAdapterV2TurnInput,
44
-} from "@t3tools/provider-core/server/ProviderAdapter";
40
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
41
import type { ProviderContinuationRequest } from "@t3tools/provider-core/server/continuationRequests";
42
import { makeMuseAdapterV2, type MuseAdapterV2Options } from "./adapter.ts";
43
@@ -55,7 +51,7 @@ const INSTANCE_ID = ProviderInstanceId.make("muse_work");
51
const THREAD_ID = ThreadId.make("thread-muse-test");
52
const MODEL = "muse-spark-1.3-contributor";
53
const museSettings = Schema.decodeSync(MuseSettings)({ enabled: true });
58
-const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
54
+const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
55
runtimeMode: "full-access",
56
interactionMode: "default",
57
cwd: null,
@@ -204,7 +200,7 @@ const makeHarness = Effect.fnUntraced(function* (
200
settings: museSettings,
201
environment: { PATH: "/fake/bin" },
202
idAllocator: yield* IdAllocator.IdAllocatorV2,
207
- host: yield* ProviderHost,
203
+ host: yield* ProviderHost.ProviderHost,
204
fileSystem: yield* FileSystem.FileSystem,
205
createHost: async () => (hostCount++ === 0 ? fake.host : (replacement ?? fake).host),
206
...overrides,
@@ -216,8 +212,8 @@ const makeHarness = Effect.fnUntraced(function* (
212
runtimePolicy: policy,
213
...(initialNativeThreadId ? { initialNativeThreadId } : {}),
214
});
219
- const emitted = yield* Queue.unbounded<ProviderAdapterV2Event>();
220
- const allEvents: ProviderAdapterV2Event[] = [];
215
+ const emitted = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
216
+ const allEvents: ProviderAdapter.ProviderAdapterV2Event[] = [];
217
const eventsEnded = yield* Deferred.make<Exit.Exit<void, Stream.Error<typeof runtime.events>>>();
218
yield* runtime.events.pipe(
219
Stream.runForEach((event) =>
@@ -236,14 +232,21 @@ const makeHarness = Effect.fnUntraced(function* (
232
runtimePolicy: policy,
233
...(existingProviderThread ? { existingProviderThread } : {}),
234
});
239
- const takeEvent = Effect.fnUntraced(function* <T extends ProviderAdapterV2Event["type"]>(
235
+ const takeEvent = Effect.fnUntraced(function* <
236
+ T extends ProviderAdapter.ProviderAdapterV2Event["type"],
237
+ >(
238
type: T,
241
- predicate: (event: Extract<ProviderAdapterV2Event, { type: T }>) => boolean = () => true,
239
+ predicate: (
240
+ event: Extract<ProviderAdapter.ProviderAdapterV2Event, { type: T }>,
241
+ ) => boolean = () => true,
242
) {
243
while (true) {
244
const event = yield* Queue.take(emitted);
245
- if (event.type === type && predicate(event as Extract<ProviderAdapterV2Event, { type: T }>)) {
246
- return event as Extract<ProviderAdapterV2Event, { type: T }>;
245
+ if (
246
+ event.type === type &&
247
+ predicate(event as Extract<ProviderAdapter.ProviderAdapterV2Event, { type: T }>)
248
+ ) {
249
+ return event as Extract<ProviderAdapter.ProviderAdapterV2Event, { type: T }>;
250
}
251
}
252
});
@@ -275,7 +278,7 @@ const turnInput = Effect.fnUntraced(function* (
278
providerThread: OrchestrationV2ProviderThread,
279
runOrdinal = 1,
280
policy = runtimePolicy,
278
-): Effect.fn.Return<ProviderAdapterV2TurnInput> {
281
+): Effect.fn.Return<ProviderAdapter.ProviderAdapterV2TurnInput> {
282
const now = yield* DateTime.now;
283
const threadId = providerThread.appThreadId ?? THREAD_ID;
284
const selection = modelSelection(providerThread.providerInstanceId);
@@ -436,7 +439,7 @@ describe("MuseAdapterV2", () => {
439
settings: museSettings,
440
environment: { PATH: "/fake/bin" },
441
idAllocator: yield* IdAllocator.IdAllocatorV2,
439
- host: yield* ProviderHost,
442
+ host: yield* ProviderHost.ProviderHost,
443
fileSystem: yield* FileSystem.FileSystem,
444
createHost: async () => fake.host,
445
});
@@ -833,7 +836,7 @@ describe("MuseAdapterV2", () => {
836
it.effect("keeps a workflow child's approval pending for the user past the turn's end", () =>
837
Effect.gen(function* () {
838
const fake = yield* makeFakeMuse();
836
- const policy = ProviderAdapterV2RuntimePolicy.make({
839
+ const policy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
840
...runtimePolicy,
841
runtimeMode: "approval-required",
842
});
packages/provider-muse/src/server/adapter.ts
+39
-52
@@ -35,7 +35,7 @@ import * as Semaphore from "effect/Semaphore";
35
import * as Scope from "effect/Scope";
36
import * as Stream from "effect/Stream";
37
38
-import type { ProviderHostShape } from "@t3tools/provider-core/server/ProviderHost";
38
+import type * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
39
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
40
import { buildRuntimeInstructions } from "@t3tools/provider-core/server/runtimeInstructions";
41
import { museModelCapabilities, resolveMuseReasoningEffort } from "./modelCatalog.ts";
@@ -63,35 +63,13 @@ import {
63
type createMuseSdkHost,
64
type MuseSdkHost,
65
} from "./sdk.ts";
66
-import type { EventNdjsonLogger } from "@t3tools/provider-core/server/ProviderEventLoggers";
66
+import type * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
67
import {
68
providerMessageTextWithAttachmentPaths,
69
isProviderNativeImageAttachment,
70
} from "@t3tools/provider-core/server/attachmentPrompt";
71
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
72
-import {
73
- ProviderAdapterEnsureThreadError,
74
- ProviderAdapterForkThreadError,
75
- ProviderAdapterInterruptError,
76
- ProviderAdapterOpenSessionError,
77
- ProviderAdapterProtocolError,
78
- ProviderAdapterReadThreadSnapshotError,
79
- ProviderAdapterResumeThreadError,
80
- ProviderAdapterRollbackThreadError,
81
- ProviderAdapterRuntimeRequestResponseError,
82
- ProviderAdapterSteerRunError,
83
- ProviderAdapterTurnStartError,
84
- ProviderAdapterV2,
85
- type ProviderAdapterV2Error,
86
- type ProviderAdapterV2Event,
87
- type ProviderAdapterV2EnsureThreadInput,
88
- type ProviderAdapterV2OpenSessionInput,
89
- type ProviderAdapterV2SessionRuntime,
90
- type ProviderAdapterV2Shape,
91
- type ProviderAdapterV2ThreadSnapshot,
92
- type ProviderAdapterV2TurnInput,
93
- type ProviderAdapterV2TurnMessage,
94
-} from "@t3tools/provider-core/server/ProviderAdapter";
72
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
73
import {
74
backgroundWorkNotification,
75
type BackgroundWorkReport,
@@ -102,8 +80,8 @@ import { turnScopedSelectionTransition } from "@t3tools/provider-core/server/sel
80
import { museItemStatus, museToolPresentation } from "./itemPresentation.ts";
81
82
const MUSE_PROVIDER = ProviderDriverKind.make("muse");
105
-const isOpenSessionError = Schema.is(ProviderAdapterOpenSessionError);
106
-const isProtocolError = Schema.is(ProviderAdapterProtocolError);
83
+const isOpenSessionError = Schema.is(ProviderAdapter.ProviderAdapterOpenSessionError);
84
+const isProtocolError = Schema.is(ProviderAdapter.ProviderAdapterProtocolError);
85
86
const MuseProviderCapabilitiesV2 = {
87
runtimePolicy: { enforcement: "native" },
@@ -204,12 +182,12 @@ export interface MuseAdapterV2Options {
182
readonly settings: MuseSettings;
183
readonly environment: NodeJS.ProcessEnv;
184
readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
207
- readonly host: ProviderHostShape;
185
+ readonly host: ProviderHost.ProviderHostShape;
186
readonly fileSystem: FileSystem.FileSystem;
187
readonly modelCatalog?: Effect.Effect<ReadonlyArray<ServerProviderModel>>;
188
readonly createHost?: typeof createMuseSdkHost;
189
readonly requestTimeoutMs?: number;
212
- readonly nativeEventLogger?: EventNdjsonLogger;
190
+ readonly nativeEventLogger?: ProviderEventLoggers.EventNdjsonLogger;
191
/** Where a turn Muse starts on its own (a finished workflow's report) asks for its run. */
192
readonly continuationRequests?: {
193
readonly offer: (
@@ -219,7 +197,7 @@ export interface MuseAdapterV2Options {
197
}
198
199
interface ActiveTurn {
222
- readonly input: ProviderAdapterV2TurnInput;
200
+ readonly input: ProviderAdapter.ProviderAdapterV2TurnInput;
201
providerTurn: OrchestrationV2ProviderTurn;
202
readonly nativeId: string;
203
/** Turns Muse started on its own while this run was active, which this run shows. */
@@ -267,21 +245,23 @@ const TOOLS_WITH_NATIVE_ROWS = new Set(["write_todos", "request_user_input", "wo
245
const responseAnswerSchema = Schema.Union([Schema.String, Schema.Array(Schema.String)]);
246
247
/** One scoped Muse host owns one native session; the orchestrator owns app runs and queuing. */
270
-export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapterV2Shape {
248
+export function makeMuseAdapterV2(
249
+ options: MuseAdapterV2Options,
250
+): ProviderAdapter.ProviderAdapterV2Shape {
251
const { idAllocator } = options;
252
const protocolError = (detail: string, payload?: unknown) =>
273
- new ProviderAdapterProtocolError({
253
+ new ProviderAdapter.ProviderAdapterProtocolError({
254
driver: MUSE_PROVIDER,
255
detail,
256
...(payload === undefined ? {} : { payload }),
257
});
278
- return ProviderAdapterV2.of({
258
+ return ProviderAdapter.ProviderAdapterV2.of({
259
instanceId: options.instanceId,
260
driver: MUSE_PROVIDER,
261
getCapabilities: () => Effect.succeed(MuseProviderCapabilitiesV2),
262
planSelectionTransition: () => Effect.succeed(turnScopedSelectionTransition()),
263
openSession: Effect.fn("MuseAdapterV2.openSession")(function* (
284
- input: ProviderAdapterV2OpenSessionInput,
264
+ input: ProviderAdapter.ProviderAdapterV2OpenSessionInput,
265
) {
266
if (!options.settings.enabled) return yield* protocolError("Muse Code is disabled");
267
if (input.runtimePolicy.interactionMode === "plan")
@@ -307,8 +287,8 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
287
lastError: null,
288
};
289
const events = yield* Queue.unbounded<
310
- ProviderAdapterV2Event,
311
- ProviderAdapterV2Error | Cause.Done
290
+ ProviderAdapter.ProviderAdapterV2Event,
291
+ ProviderAdapter.ProviderAdapterV2Error | Cause.Done
292
>();
293
type Inbox =
294
| { type: "notification"; method: string; params: unknown; epoch: number }
@@ -344,7 +324,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
324
let wake:
325
| { readonly nativeId: string; readonly events: Array<[string, unknown]> }
326
| undefined;
347
- const emit = (event: ProviderAdapterV2Event) =>
327
+ const emit = (event: ProviderAdapter.ProviderAdapterV2Event) =>
328
Queue.offer(events, event).pipe(Effect.asVoid);
329
const decode = <A, I>(schema: Schema.Codec<A, I>, data: unknown) =>
330
Schema.decodeUnknownEffect(schema)(data).pipe(
@@ -1400,7 +1380,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1380
).pipe(
1381
Effect.mapError(
1382
(error) =>
1403
- new ProviderAdapterOpenSessionError({
1383
+ new ProviderAdapter.ProviderAdapterOpenSessionError({
1384
driver: MUSE_PROVIDER,
1385
providerSessionId: input.providerSessionId,
1386
cause: error.cause,
@@ -1472,7 +1452,9 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1452
);
1453
yield* launchHost();
1454
1475
- const register = Effect.fnUntraced(function* (args: ProviderAdapterV2EnsureThreadInput) {
1455
+ const register = Effect.fnUntraced(function* (
1456
+ args: ProviderAdapter.ProviderAdapterV2EnsureThreadInput,
1457
+ ) {
1458
if (broken || closed)
1459
return yield* protocolError("Muse host is unavailable; reopen the session");
1460
if (active)
@@ -1592,7 +1574,9 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1574
),
1575
);
1576
});
1595
- const prompt = Effect.fnUntraced(function* (message: ProviderAdapterV2TurnMessage) {
1577
+ const prompt = Effect.fnUntraced(function* (
1578
+ message: ProviderAdapter.ProviderAdapterV2TurnMessage,
1579
+ ) {
1580
const parts: SendUserTurnOptions<unknown>["input"] = [];
1581
const text = providerMessageTextWithAttachmentPaths({
1582
text: message.text,
@@ -1635,7 +1619,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1619
);
1620
});
1621
const start = Effect.fnUntraced(function* (
1638
- turnInput: ProviderAdapterV2TurnInput,
1622
+ turnInput: ProviderAdapter.ProviderAdapterV2TurnInput,
1623
compact = false,
1624
) {
1625
if (!validateThread(turnInput.providerThread) || broken || closed)
@@ -1783,7 +1767,10 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1767
// Only messages are read back; T3 owns turn and item history.
1768
const snapshot = Effect.fnUntraced(function* (
1769
current: OrchestrationV2ProviderThread,
1786
- ): Effect.fn.Return<ProviderAdapterV2ThreadSnapshot, ProviderAdapterV2Error> {
1770
+ ): Effect.fn.Return<
1771
+ ProviderAdapter.ProviderAdapterV2ThreadSnapshot,
1772
+ ProviderAdapter.ProviderAdapterV2Error
1773
+ > {
1774
const result = yield* request("session/read", { excludeItems: false }, false).pipe(
1775
Effect.flatMap((value) => decode(MuseSessionResult, value)),
1776
);
@@ -1821,7 +1808,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1808
providerPayload: items,
1809
};
1810
});
1824
- const runtime: ProviderAdapterV2SessionRuntime = {
1811
+ const runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime = {
1812
instanceId: options.instanceId,
1813
driver: MUSE_PROVIDER,
1814
providerSessionId: input.providerSessionId,
@@ -1836,7 +1823,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1823
commands.withPermits(1),
1824
Effect.mapError(
1825
(cause) =>
1839
- new ProviderAdapterEnsureThreadError({
1826
+ new ProviderAdapter.ProviderAdapterEnsureThreadError({
1827
driver: MUSE_PROVIDER,
1828
threadId: args.threadId,
1829
cause,
@@ -1853,7 +1840,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1840
commands.withPermits(1),
1841
Effect.mapError(
1842
(cause) =>
1856
- new ProviderAdapterResumeThreadError({
1843
+ new ProviderAdapter.ProviderAdapterResumeThreadError({
1844
driver: MUSE_PROVIDER,
1845
providerSessionId: input.providerSessionId,
1846
providerThreadId: args.providerThread.id,
@@ -1866,7 +1853,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1853
commands.withPermits(1),
1854
Effect.mapError(
1855
(cause) =>
1869
- new ProviderAdapterTurnStartError({
1856
+ new ProviderAdapter.ProviderAdapterTurnStartError({
1857
driver: MUSE_PROVIDER,
1858
threadId: args.threadId,
1859
providerThreadId: args.providerThread.id,
@@ -1897,7 +1884,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1884
commands.withPermits(1),
1885
Effect.mapError(
1886
(cause) =>
1900
- new ProviderAdapterSteerRunError({
1887
+ new ProviderAdapter.ProviderAdapterSteerRunError({
1888
driver: MUSE_PROVIDER,
1889
providerThreadId: args.providerThread.id,
1890
providerTurnId: args.providerTurnId,
@@ -1946,7 +1933,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1933
commands.withPermits(1),
1934
Effect.mapError(
1935
(cause) =>
1949
- new ProviderAdapterInterruptError({
1936
+ new ProviderAdapter.ProviderAdapterInterruptError({
1937
driver: MUSE_PROVIDER,
1938
providerThreadId: args.providerThread.id,
1939
providerTurnId: args.providerTurnId,
@@ -1999,7 +1986,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
1986
}).pipe(
1987
Effect.mapError(
1988
(cause) =>
2002
- new ProviderAdapterRuntimeRequestResponseError({
1989
+ new ProviderAdapter.ProviderAdapterRuntimeRequestResponseError({
1990
driver: MUSE_PROVIDER,
1991
requestId: args.requestId,
1992
cause,
@@ -2014,7 +2001,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
2001
commands.withPermits(1),
2002
Effect.mapError(
2003
(cause) =>
2017
- new ProviderAdapterReadThreadSnapshotError({
2004
+ new ProviderAdapter.ProviderAdapterReadThreadSnapshotError({
2005
driver: MUSE_PROVIDER,
2006
providerThreadId: args.providerThread.id,
2007
cause,
@@ -2025,7 +2012,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
2012
// portable context handoff for forks and does not rewind Muse conversations.
2013
rollbackThread: (args) =>
2014
Effect.fail(
2028
- new ProviderAdapterRollbackThreadError({
2015
+ new ProviderAdapter.ProviderAdapterRollbackThreadError({
2016
driver: MUSE_PROVIDER,
2017
providerThreadId: args.providerThread.id,
2018
checkpointId: args.target.checkpointId,
@@ -2034,7 +2021,7 @@ export function makeMuseAdapterV2(options: MuseAdapterV2Options): ProviderAdapte
2021
),
2022
forkThread: (args) =>
2023
Effect.fail(
2037
- new ProviderAdapterForkThreadError({
2024
+ new ProviderAdapter.ProviderAdapterForkThreadError({
2025
driver: MUSE_PROVIDER,
2026
providerThreadId: args.sourceProviderThread.id,
2027
cause: "Muse Code does not support native forks in T3 Code.",
packages/provider-muse/src/server/driver.ts
+3
-3
@@ -8,7 +8,7 @@ import * as Schema from "effect/Schema";
8
import { HttpClient } from "effect/http";
9
import { ChildProcessSpawner } from "effect/process";
10
11
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
11
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
12
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
13
import { makeMuseTextGeneration } from "./textGeneration.ts";
14
import { ProviderDriverError } from "@t3tools/provider-core/server/errors";
@@ -42,7 +42,7 @@ const decodeMuseSettings = Schema.decodeSync(MuseSettings);
42
43
export type MuseDriverEnv =
44
| IdAllocator.IdAllocatorV2
45
- | ProviderHost
45
+ | ProviderHost.ProviderHost
46
| ChildProcessSpawner.ChildProcessSpawner
47
| FileSystem.FileSystem
48
| HttpClient.HttpClient
@@ -60,7 +60,7 @@ export const MuseDriver: ProviderDriver<MuseSettings, MuseDriverEnv> = {
60
const fileSystem = yield* FileSystem.FileSystem;
61
const path = yield* Path.Path;
62
const httpClient = yield* HttpClient.HttpClient;
63
- const host = yield* ProviderHost;
63
+ const host = yield* ProviderHost.ProviderHost;
64
const eventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers;
65
const { cwd } = host.paths;
66
const idAllocator = yield* IdAllocator.IdAllocatorV2;
packages/provider-pi/src/server/adapter.test.ts
+10
-13
@@ -33,16 +33,12 @@ import * as TestClock from "effect/testing/TestClock";
33
import { ChildProcess, ChildProcessSpawner } from "effect/process";
34
import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";
35
36
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
36
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
37
import { layerTestProviderHost } from "@t3tools/provider-testing/host";
38
import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
39
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
40
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
41
-import {
42
- ProviderAdapterV2RuntimePolicy,
43
- type ProviderAdapterV2Event,
44
- type ProviderAdapterV2SessionRuntime,
45
-} from "@t3tools/provider-core/server/ProviderAdapter";
41
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
42
import { handoffBudget } from "@t3tools/provider-core/server/handoffBudget";
43
import {
44
makePiAdapterV2,
@@ -68,7 +64,7 @@ const FAKE_SESSION_FILE = "/fake/.pi/agent/sessions/--workspace--/0001_abc.jsonl
64
/** Deliberately outside the valid pid range so a group-kill can never land. */
65
const FAKE_PID = 999_999_999;
66
71
-const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
67
+const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
68
runtimeMode: "full-access",
69
interactionMode: "default",
70
cwd: null,
@@ -331,7 +327,7 @@ const makeAdapter = Effect.fnUntraced(function* (
327
continuationRequests?: PiAdapterV2Options["continuationRequests"],
328
) {
329
const idAllocator = yield* IdAllocator.IdAllocatorV2;
334
- const host = yield* ProviderHost;
330
+ const host = yield* ProviderHost.ProviderHost;
331
const fileSystem = yield* FileSystem.FileSystem;
332
const spawner =
333
forkFake === undefined
@@ -383,12 +379,12 @@ const openRuntime = Effect.fnUntraced(function* (
379
modelSelection: modelSelection(model),
380
runtimePolicy,
381
});
386
- const emitted = yield* Queue.unbounded<ProviderAdapterV2Event>();
382
+ const emitted = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
383
yield* runtime.events.pipe(
384
Stream.runForEach((event) => Queue.offer(emitted, event)),
385
Effect.forkScoped,
386
);
391
- const takeEvent = (predicate: (event: ProviderAdapterV2Event) => boolean) =>
387
+ const takeEvent = (predicate: (event: ProviderAdapter.ProviderAdapterV2Event) => boolean) =>
388
Effect.gen(function* () {
389
while (true) {
390
const event = yield* Queue.take(emitted);
@@ -426,7 +422,7 @@ const makeAppThread = Effect.fnUntraced(function* (model: string, threadId = THR
422
});
423
424
const startTurn = Effect.fnUntraced(function* (
429
- runtime: ProviderAdapterV2SessionRuntime,
425
+ runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime,
426
providerThread: OrchestrationV2ProviderThread,
427
model = "default",
428
attachments: ReadonlyArray<ChatAttachment> = [],
@@ -832,8 +828,9 @@ describe("PiAdapterV2", () => {
828
});
829
yield* fake.emit({ type: "agent_start" });
830
yield* Queue.take(offers);
835
- const requests: Array<Extract<ProviderAdapterV2Event, { type: "runtime_request.updated" }>> =
836
- [];
831
+ const requests: Array<
832
+ Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "runtime_request.updated" }>
833
+ > = [];
834
fake.deferNextModelSelection();
835
const starting = yield* startTurn(
836
runtime,
packages/provider-pi/src/server/adapter.ts
+5
-5
@@ -60,7 +60,7 @@ import * as Semaphore from "effect/Semaphore";
60
import * as Stream from "effect/Stream";
61
import { ChildProcessSpawner } from "effect/process";
62
63
-import { ProviderHost, type ProviderHostShape } from "@t3tools/provider-core/server/ProviderHost";
63
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
64
import { mcpToolPresentation } from "@t3tools/provider-core/server/mcpToolPresentation";
65
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
66
import {
@@ -231,7 +231,7 @@ export interface PiAdapterV2Options {
231
readonly spawner: ChildProcessSpawner.ChildProcessSpawner["Service"];
232
readonly fileSystem: FileSystem.FileSystem;
233
readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
234
- readonly host: ProviderHostShape;
234
+ readonly host: ProviderHost.ProviderHostShape;
235
readonly continuationRequests?: {
236
readonly offer: (
237
request: ProviderContinuationRequests.ProviderContinuationRequest,
@@ -3201,7 +3201,7 @@ export type PiAdapterV2DriverEnv =
3201
| ChildProcessSpawner.ChildProcessSpawner
3202
| FileSystem.FileSystem
3203
| IdAllocator.IdAllocatorV2
3204
- | ProviderHost;
3204
+ | ProviderHost.ProviderHost;
3205
3206
export const PiAdapterV2Driver: ProviderAdapterDriver<PiSettings, PiAdapterV2DriverEnv> = {
3207
driverKind: PI_DRIVER_KIND,
@@ -3213,7 +3213,7 @@ export const PiAdapterV2Driver: ProviderAdapterDriver<PiSettings, PiAdapterV2Dri
3213
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3214
const fileSystem = yield* FileSystem.FileSystem;
3215
const idAllocator = yield* IdAllocator.IdAllocatorV2;
3216
- const host = yield* ProviderHost;
3216
+ const host = yield* ProviderHost.ProviderHost;
3217
const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
3218
return makePiAdapterV2({
3219
instanceId: input.instanceId,
@@ -3249,7 +3249,7 @@ const layer: Layer.Layer<ProviderAdapter.ProviderAdapterV2, never, PiAdapterV2Dr
3249
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3250
const fileSystem = yield* FileSystem.FileSystem;
3251
const idAllocator = yield* IdAllocator.IdAllocatorV2;
3252
- const host = yield* ProviderHost;
3252
+ const host = yield* ProviderHost.ProviderHost;
3253
const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
3254
return makePiAdapterV2({
3255
instanceId: PI_DEFAULT_INSTANCE_ID,
packages/provider-pi/src/server/driver.ts
+3
-3
@@ -15,7 +15,7 @@ import * as Schema from "effect/Schema";
15
import { HttpClient } from "effect/http";
16
import { ChildProcessSpawner } from "effect/process";
17
18
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
18
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
19
import { makePiTextGeneration } from "./textGeneration.ts";
20
import { PiAdapterV2Driver, type PiAdapterV2DriverEnv } from "./adapter.ts";
21
import { ProviderDriverError } from "@t3tools/provider-core/server/errors";
@@ -56,7 +56,7 @@ const UPDATE = makePackageManagedProviderMaintenanceResolver({
56
57
export type PiDriverEnv =
58
| PiAdapterV2DriverEnv
59
- | ProviderHost
59
+ | ProviderHost.ProviderHost
60
| ChildProcessSpawner.ChildProcessSpawner
61
| FileSystem.FileSystem
62
| HttpClient.HttpClient
@@ -92,7 +92,7 @@ export const PiDriver: ProviderDriver<PiSettings, PiDriverEnv> = {
92
const fileSystem = yield* FileSystem.FileSystem;
93
const pathService = yield* Path.Path;
94
const httpClient = yield* HttpClient.HttpClient;
95
- const host = yield* ProviderHost;
95
+ const host = yield* ProviderHost.ProviderHost;
96
const { cwd } = host.paths;
97
const processEnv = mergeProviderInstanceEnvironment(environment);
98
const continuationIdentity = defaultProviderContinuationIdentity({
packages/provider-testing/src/host.ts
+5
-5
@@ -1,12 +1,12 @@
1
/**
2
- * A `ProviderHost` for driver and adapter tests. Its directories live in a
2
+ * A `ProviderHost.ProviderHost` for driver and adapter tests. Its directories live in a
3
* scoped temp directory, settings are fixed, and background work always runs
4
* unless the test says otherwise.
5
*
6
* @module provider-testing/host
7
*/
8
import { DEFAULT_SERVER_SETTINGS, type ServerSettings } from "@t3tools/contracts";
9
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
9
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
10
import * as Effect from "effect/Effect";
11
import * as FileSystem from "effect/FileSystem";
12
import * as Layer from "effect/Layer";
@@ -23,9 +23,9 @@ export interface TestProviderHostOptions {
23
24
export const layerTestProviderHost = (
25
options: TestProviderHostOptions = {},
26
-): Layer.Layer<ProviderHost, never, FileSystem.FileSystem | Path.Path> =>
26
+): Layer.Layer<ProviderHost.ProviderHost, never, FileSystem.FileSystem | Path.Path> =>
27
Layer.effect(
28
- ProviderHost,
28
+ ProviderHost.ProviderHost,
29
Effect.gen(function* () {
30
const fileSystem = yield* FileSystem.FileSystem;
31
const path = yield* Path.Path;
@@ -39,7 +39,7 @@ export const layerTestProviderHost = (
39
yield* fileSystem.makeDirectory(directory, { recursive: true }).pipe(Effect.orDie);
40
}
41
const settings = options.settings ?? DEFAULT_SERVER_SETTINGS;
42
- return ProviderHost.of({
42
+ return ProviderHost.ProviderHost.of({
43
paths: { cwd: options.cwd ?? process.cwd(), baseDir, stateDir, providerStatusCacheDir },
44
settings: {
45
get: Effect.succeed(settings),