Skip to content

Commit e5ea201

Browse files
refactor(providers): namespace-import service modules in core, Muse, and Pi
Brings the already-merged provider packages in line with the stack: every import from ProviderHost, ProviderAdapter, ProviderEventLoggers, and IdAllocator is a namespace import. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6328746 commit e5ea201

14 files changed

Lines changed: 112 additions & 117 deletions

File tree

‎packages/provider-core/src/server/adapterDriver.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as Schema from "effect/Schema";
77
import type * as Effect from "effect/Effect";
88
import type * as Scope from "effect/Scope";
99

10-
import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
10+
import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
1111

1212
export class ProviderAdapterDriverCreateError extends Schema.TaggedError<ProviderAdapterDriverCreateError>()(
1313
"ProviderAdapterDriverCreateError",
@@ -38,7 +38,11 @@ export interface ProviderAdapterDriver<Config, R = never> {
3838
readonly defaultConfig: () => Config;
3939
readonly create: (
4040
input: ProviderAdapterDriverCreateInput<Config>,
41-
) => Effect.Effect<ProviderAdapterV2Shape, ProviderAdapterDriverCreateError, R | Scope.Scope>;
41+
) => Effect.Effect<
42+
ProviderAdapter.ProviderAdapterV2Shape,
43+
ProviderAdapterDriverCreateError,
44+
R | Scope.Scope
45+
>;
4246
}
4347

4448
export type AnyProviderAdapterDriver<R = never> = ProviderAdapterDriver<any, R>;

‎packages/provider-core/src/server/driver.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import type * as Effect from "effect/Effect";
3737
import type * as Schema from "effect/Schema";
3838
import type * as Scope from "effect/Scope";
3939

40-
import type { ProviderAdapterV2Shape } from "./ProviderAdapter.ts";
40+
import type * as ProviderAdapter from "./ProviderAdapter.ts";
4141
import type { ProviderAuthController } from "./auth.ts";
4242
import type { ProviderDriverError } from "./errors.ts";
4343
import type { ServerProviderShape } from "./snapshot.ts";
@@ -101,7 +101,7 @@ export interface ProviderInstance {
101101
ProviderConsumeResetCreditOutcome,
102102
ProviderDriverError
103103
>;
104-
readonly orchestrationAdapter: ProviderAdapterV2Shape;
104+
readonly orchestrationAdapter: ProviderAdapter.ProviderAdapterV2Shape;
105105
readonly textGeneration: ProviderTextGeneration;
106106
readonly auth?: ProviderAuthController;
107107
readonly acpSessionManagement?: {

‎packages/provider-core/src/server/failure.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
ContextHandoffBudgetError,
2020
} from "./failure.ts";
2121
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";
2323

2424
it("redacts credentials and URL secrets from provider failures", () => {
2525
const failure = makeProviderFailure({
@@ -88,7 +88,7 @@ it("does not expose arbitrary cause messages and preserves explicit messages", (
8888
});
8989

9090
it("preserves actionable handoff errors wrapped by turn startup", () => {
91-
const cause = new ProviderAdapterTurnStartError({
91+
const cause = new ProviderAdapter.ProviderAdapterTurnStartError({
9292
driver: ProviderDriverKind.make("codex"),
9393
threadId: ThreadId.make("thread:handoff-error"),
9494
providerThreadId: ProviderThreadId.make("provider-thread:handoff-error"),

‎packages/provider-core/src/server/failure.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
import * as DateTime from "effect/DateTime";
1414
import * as Cause from "effect/Cause";
1515

16-
import type { IdAllocatorV2Shape } from "./IdAllocator.ts";
16+
import type * as IdAllocator from "./IdAllocator.ts";
1717
import * as Schema from "effect/Schema";
1818

1919
/** Raised when portable history does not fit the target provider's context window. */
@@ -172,7 +172,7 @@ export function makeProviderFailure(input: {
172172
}
173173

174174
export function makeProviderFailureTurnItem(input: {
175-
readonly idAllocator: IdAllocatorV2Shape;
175+
readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
176176
readonly driver: ProviderDriverKind;
177177
readonly threadId: ThreadId;
178178
readonly runId: RunId | null;
@@ -210,7 +210,7 @@ export function makeProviderFailureTurnItem(input: {
210210
}
211211

212212
export function makeProviderRetryTurnItem(input: {
213-
readonly idAllocator: IdAllocatorV2Shape;
213+
readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
214214
readonly driver: ProviderDriverKind;
215215
readonly threadId: ThreadId;
216216
readonly runId: RunId | null;

‎packages/provider-core/src/server/managedProvider.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import * as Ref from "effect/Ref";
1616
import * as Stream from "effect/Stream";
1717
import { TestClock } from "effect/testing";
1818

19-
import { ProviderHost, type ProviderHostShape } from "./ProviderHost.ts";
19+
import * as ProviderHost from "./ProviderHost.ts";
2020
import { makeManagedServerProvider } from "./managedProvider.ts";
2121

2222
const emptyCapabilities = createModelCapabilities({ optionDescriptors: [] });
@@ -99,11 +99,11 @@ const refreshedSnapshotSecond: ServerProvider = {
9999
/** A host whose settings never change and whose background demand is fixed. */
100100
function layerProviderHost(input: {
101101
readonly runBackgroundWork: boolean;
102-
readonly settings?: Pick<ProviderHostShape, "settings">["settings"];
102+
readonly settings?: Pick<ProviderHost.ProviderHostShape, "settings">["settings"];
103103
}) {
104104
return Layer.succeed(
105-
ProviderHost,
106-
ProviderHost.of({
105+
ProviderHost.ProviderHost,
106+
ProviderHost.ProviderHost.of({
107107
paths: {
108108
cwd: process.cwd(),
109109
baseDir: "/t3",
@@ -283,7 +283,7 @@ describe("makeManagedServerProvider", () => {
283283
};
284284
const serverSettingsRef = yield* Ref.make(initialServerSettings);
285285
const serverSettingsChanges = yield* PubSub.unbounded<typeof initialServerSettings>();
286-
const hostSettings: ProviderHostShape["settings"] = {
286+
const hostSettings: ProviderHost.ProviderHostShape["settings"] = {
287287
get: Ref.get(serverSettingsRef),
288288
changes: Stream.empty,
289289
subscribe: PubSub.subscribe(serverSettingsChanges).pipe(

‎packages/provider-core/src/server/managedProvider.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as Scope from "effect/Scope";
1515
import * as Stream from "effect/Stream";
1616
import * as Semaphore from "effect/Semaphore";
1717

18-
import { ProviderHost } from "./ProviderHost.ts";
18+
import * as ProviderHost from "./ProviderHost.ts";
1919
import { applyUsageLimitsUpdate, resolveUsageLimitsAfterProbe } from "./usageLimits.ts";
2020
import type { ServerProviderShape } from "./snapshot.ts";
2121

@@ -53,8 +53,12 @@ export const makeManagedServerProvider = Effect.fn("makeManagedServerProvider")(
5353
readonly refreshInterval?: Duration.Input;
5454
readonly refreshOnInterval?: boolean;
5555
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;
5862
const refreshSemaphore = yield* Semaphore.make(1);
5963
const changesPubSub = yield* Effect.acquireRelease(
6064
PubSub.unbounded<ServerProvider>(),

‎packages/provider-core/src/server/snapshotSettings.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
33
import * as Equal from "effect/Equal";
44
import * as Stream from "effect/Stream";
55

6-
import type { ProviderHostShape } from "./ProviderHost.ts";
6+
import type * as ProviderHost from "./ProviderHost.ts";
77

88
export interface ProviderSnapshotSettings<Settings> {
99
readonly provider: Settings;
@@ -29,7 +29,7 @@ export function haveProviderSnapshotSettingsChanged<Settings>(
2929

3030
export function makeProviderSnapshotSettingsSource<Settings>(
3131
provider: Settings,
32-
settings: ProviderHostShape["settings"],
32+
settings: ProviderHost.ProviderHostShape["settings"],
3333
): {
3434
readonly getSettings: Effect.Effect<ProviderSnapshotSettings<Settings>, ServerSettingsError>;
3535
readonly streamSettings: Stream.Stream<ProviderSnapshotSettings<Settings>>;

‎packages/provider-muse/src/server/adapter.test.ts‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,13 @@ import * as Queue from "effect/Queue";
3131
import * as Schema from "effect/Schema";
3232
import * as Stream from "effect/Stream";
3333

34-
import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
34+
import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
3535
import { layerTestProviderHost } from "@t3tools/provider-testing/host";
3636
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
3737
import type { MuseItem } from "./protocol.ts";
3838
import type { MuseSdkHost } from "./sdk.ts";
3939
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";
4541
import type { ProviderContinuationRequest } from "@t3tools/provider-core/server/continuationRequests";
4642
import { makeMuseAdapterV2, type MuseAdapterV2Options } from "./adapter.ts";
4743

@@ -55,7 +51,7 @@ const INSTANCE_ID = ProviderInstanceId.make("muse_work");
5551
const THREAD_ID = ThreadId.make("thread-muse-test");
5652
const MODEL = "muse-spark-1.3-contributor";
5753
const museSettings = Schema.decodeSync(MuseSettings)({ enabled: true });
58-
const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
54+
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
5955
runtimeMode: "full-access",
6056
interactionMode: "default",
6157
cwd: null,
@@ -204,7 +200,7 @@ const makeHarness = Effect.fnUntraced(function* (
204200
settings: museSettings,
205201
environment: { PATH: "/fake/bin" },
206202
idAllocator: yield* IdAllocator.IdAllocatorV2,
207-
host: yield* ProviderHost,
203+
host: yield* ProviderHost.ProviderHost,
208204
fileSystem: yield* FileSystem.FileSystem,
209205
createHost: async () => (hostCount++ === 0 ? fake.host : (replacement ?? fake).host),
210206
...overrides,
@@ -216,8 +212,8 @@ const makeHarness = Effect.fnUntraced(function* (
216212
runtimePolicy: policy,
217213
...(initialNativeThreadId ? { initialNativeThreadId } : {}),
218214
});
219-
const emitted = yield* Queue.unbounded<ProviderAdapterV2Event>();
220-
const allEvents: ProviderAdapterV2Event[] = [];
215+
const emitted = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
216+
const allEvents: ProviderAdapter.ProviderAdapterV2Event[] = [];
221217
const eventsEnded = yield* Deferred.make<Exit.Exit<void, Stream.Error<typeof runtime.events>>>();
222218
yield* runtime.events.pipe(
223219
Stream.runForEach((event) =>
@@ -236,14 +232,21 @@ const makeHarness = Effect.fnUntraced(function* (
236232
runtimePolicy: policy,
237233
...(existingProviderThread ? { existingProviderThread } : {}),
238234
});
239-
const takeEvent = Effect.fnUntraced(function* <T extends ProviderAdapterV2Event["type"]>(
235+
const takeEvent = Effect.fnUntraced(function* <
236+
T extends ProviderAdapter.ProviderAdapterV2Event["type"],
237+
>(
240238
type: T,
241-
predicate: (event: Extract<ProviderAdapterV2Event, { type: T }>) => boolean = () => true,
239+
predicate: (
240+
event: Extract<ProviderAdapter.ProviderAdapterV2Event, { type: T }>,
241+
) => boolean = () => true,
242242
) {
243243
while (true) {
244244
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 }>;
247250
}
248251
}
249252
});
@@ -275,7 +278,7 @@ const turnInput = Effect.fnUntraced(function* (
275278
providerThread: OrchestrationV2ProviderThread,
276279
runOrdinal = 1,
277280
policy = runtimePolicy,
278-
): Effect.fn.Return<ProviderAdapterV2TurnInput> {
281+
): Effect.fn.Return<ProviderAdapter.ProviderAdapterV2TurnInput> {
279282
const now = yield* DateTime.now;
280283
const threadId = providerThread.appThreadId ?? THREAD_ID;
281284
const selection = modelSelection(providerThread.providerInstanceId);
@@ -436,7 +439,7 @@ describe("MuseAdapterV2", () => {
436439
settings: museSettings,
437440
environment: { PATH: "/fake/bin" },
438441
idAllocator: yield* IdAllocator.IdAllocatorV2,
439-
host: yield* ProviderHost,
442+
host: yield* ProviderHost.ProviderHost,
440443
fileSystem: yield* FileSystem.FileSystem,
441444
createHost: async () => fake.host,
442445
});
@@ -833,7 +836,7 @@ describe("MuseAdapterV2", () => {
833836
it.effect("keeps a workflow child's approval pending for the user past the turn's end", () =>
834837
Effect.gen(function* () {
835838
const fake = yield* makeFakeMuse();
836-
const policy = ProviderAdapterV2RuntimePolicy.make({
839+
const policy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
837840
...runtimePolicy,
838841
runtimeMode: "approval-required",
839842
});

0 commit comments

Comments
 (0)