Skip to content
TypeScript

refactor(provider-core): follow the Effect service conventions throughout (#17427)

Julius Marmingeb66dd402e868
diff --git a/apps/server/scripts/record-claude-agent-sdk-replay-fixture.ts b/apps/server/scripts/record-claude-agent-sdk-replay-fixture.ts
index 970c1faf1e1..a509ed8c88d 100644
--- a/apps/server/scripts/record-claude-agent-sdk-replay-fixture.ts
+++ b/apps/server/scripts/record-claude-agent-sdk-replay-fixture.ts
@@ -10,10 +10,7 @@ import {
CLAUDE_AGENT_SDK_REPLAY_PROTOCOL,
} from "../src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.ts";
import { claudeRuntimeQueryPolicyForRuntimePolicy } from "../src/orchestration-v2/Adapters/ClaudeAdapterV2.ts";
-import {
- ProviderAdapterV2RuntimePolicy,
- type ProviderAdapterV2RuntimePolicy as ProviderAdapterV2RuntimePolicyType,
-} from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import type { RuntimePolicyV2Override } from "../src/orchestration-v2/RuntimePolicy.ts";
import { makeCheckpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import { CLAUDE_MODEL_SELECTION } from "../src/orchestration-v2/testkit/fixtures/shared.ts";
@@ -440,8 +437,8 @@ validateClaudeReplayRecordingSelection({
function runtimePolicyForRecording(input: {
readonly cwd: string;
readonly override?: RuntimePolicyV2Override;
-}): ProviderAdapterV2RuntimePolicyType {
- return ProviderAdapterV2RuntimePolicy.make({
+}): ProviderAdapter.ProviderAdapterV2RuntimePolicy {
+ return ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: input.override?.cwd ?? input.cwd,
diff --git a/apps/server/scripts/record-grok-acp-replay-fixture.ts b/apps/server/scripts/record-grok-acp-replay-fixture.ts
index fbf381f5053..da8b17fec56 100644
--- a/apps/server/scripts/record-grok-acp-replay-fixture.ts
+++ b/apps/server/scripts/record-grok-acp-replay-fixture.ts
@@ -33,8 +33,8 @@ import {
} from "@t3tools/provider-grok/testing";
import { ACP_PROTOCOL } from "@t3tools/provider-acp/server/adapter";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import type { ProviderAdapterV2SessionRuntime } from "@t3tools/provider-core/server/ProviderAdapter";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as ProviderAdapterRegistry from "../src/orchestration-v2/ProviderAdapterRegistry.ts";
import { provideDeterministicTestRuntime } from "../src/orchestration-v2/testkit/DeterministicRuntime.ts";
import { ORCHESTRATOR_REPLAY_FIXTURES } from "../src/orchestration-v2/testkit/fixtures/index.ts";
@@ -474,7 +474,7 @@ const recordScenario = Effect.fn("recordGrokScenario")(function* (fixtureName: s
...adapter,
openSession: (input) =>
adapter.openSession(input).pipe(
- Effect.map((session): ProviderAdapterV2SessionRuntime => ({
+ Effect.map((session): ProviderAdapter.ProviderAdapterV2SessionRuntime => ({
...session,
startTurn: (turnInput) => onWallClock(session.startTurn(turnInput)),
steerTurn: (turnInput) => onWallClock(session.steerTurn(turnInput)),
diff --git a/apps/server/src/mcp/McpToolAccess.race.test.ts b/apps/server/src/mcp/McpToolAccess.race.test.ts
index 52458c8401e..46522810f70 100644
--- a/apps/server/src/mcp/McpToolAccess.race.test.ts
+++ b/apps/server/src/mcp/McpToolAccess.race.test.ts
@@ -19,13 +19,13 @@ import { DispatchModeLimit } from "../orchestration-v2/DispatchModeLimit.ts";
import { CodexProviderCapabilitiesV2 } from "../orchestration-v2/Adapters/CodexAdapterV2.ts";
import * as Orchestrator from "../orchestration-v2/Orchestrator.ts";
import * as ProjectionStore from "../orchestration-v2/ProjectionStore.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "../orchestration-v2/ProviderAdapterRegistry.ts";
import * as ThreadManagement from "../orchestration-v2/ThreadManagementService.ts";
import * as ProviderReplayHarness from "../orchestration-v2/testkit/ProviderReplayHarness.ts";
import * as McpHttpServer from "./McpHttpServer.ts";
import * as McpInvocationContext from "./McpInvocationContext.ts";
import * as McpToolAccess from "./McpToolAccess.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
// A Supervised outside agent renames a thread through a `writesThreads` tool.
// The thread's user raises it to full access after the tool's check but
@@ -38,7 +38,7 @@ const adapter = {
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" as const }),
openSession: () => Effect.die("No provider process needed for metadata commands"),
-} as ProviderAdapterV2Shape;
+} as ProviderAdapter.ProviderAdapterV2["Service"];
const layerDatabase = SqlitePersistence.layerMemory;
const layerOrchestrator = Layer.mergeAll(
layerDatabase,
diff --git a/apps/server/src/mcp/OrchestratorMcpService.test.ts b/apps/server/src/mcp/OrchestratorMcpService.test.ts
index eaa776173af..2b2033779f2 100644
--- a/apps/server/src/mcp/OrchestratorMcpService.test.ts
+++ b/apps/server/src/mcp/OrchestratorMcpService.test.ts
@@ -28,7 +28,6 @@ import {
OrchestratorProjectionError,
OrchestratorThreadAboveModeLimitError,
} from "../orchestration-v2/Orchestrator.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "../orchestration-v2/ProviderAdapterRegistry.ts";
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
import * as ProviderRegistry from "../provider/ProviderRegistry.ts";
@@ -39,6 +38,7 @@ import * as SecretRequests from "../secrets/SecretRequests.ts";
import type { McpInvocationScope } from "./McpInvocationContext.ts";
import { idleThreadProjection, liveThreadShell } from "./McpToolAccess.testkit.ts";
import * as OrchestratorMcpService from "./OrchestratorMcpService.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
describe("OrchestratorMcpService", () => {
it.effect("retries terminal acknowledgement with a fresh command id", () =>
@@ -810,7 +810,9 @@ describe("OrchestratorMcpService provider resolution", () => {
list: () => Effect.succeed(instanceIds),
get: (instanceId) =>
instanceIds.includes(instanceId)
- ? Effect.succeed({ instanceId } as unknown as ProviderAdapterV2Shape)
+ ? Effect.succeed({
+ instanceId,
+ } as unknown as ProviderAdapter.ProviderAdapterV2["Service"])
: Effect.fail(
new ProviderAdapterRegistry.ProviderAdapterRegistryLookupError({ instanceId }),
),
diff --git a/apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts b/apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
index f4aa8bafbe6..02c780b3594 100644
--- a/apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
+++ b/apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
@@ -57,14 +57,8 @@ import { threadShellFromProjection } from "../orchestration-v2/ProjectionStore.t
import * as EventSink from "../orchestration-v2/EventSink.ts";
import * as Orchestrator from "../orchestration-v2/Orchestrator.ts";
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
-import {
- type ProviderAdapterV2Event,
- ProviderAdapterProtocolError,
- type ProviderAdapterV2Shape,
- type ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "../orchestration-v2/ProviderAdapterRegistry.ts";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import * as ProviderReplayHarness from "../orchestration-v2/testkit/ProviderReplayHarness.ts";
import {
@@ -79,6 +73,7 @@ import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
import * as McpHttpServer from "./McpHttpServer.ts";
import * as McpInvocationContext from "./McpInvocationContext.ts";
import { delegatedTaskRun, hasPendingChildRuns } from "./OrchestratorMcpService.ts";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
// Effect returns a declared tool failure as `isError` with its encoded payload
// as JSON text, never as `structuredContent`.
@@ -146,7 +141,7 @@ interface CapturedTurn {
}
function unsupported(driver: ProviderDriverKind, detail: string) {
- return Effect.fail(new ProviderAdapterProtocolError({ driver, detail }));
+ return Effect.fail(new ProviderAdapter.ProviderAdapterProtocolError({ driver, detail }));
}
function makeProviderSnapshot(input: {
@@ -185,10 +180,12 @@ function makeDeterministicAdapter(input: {
readonly driver: ProviderDriverKind;
readonly capabilities: OrchestrationV2ProviderCapabilities;
readonly capturedTurns: Ref.Ref<ReadonlyArray<CapturedTurn>>;
- readonly shouldComplete: (turn: ProviderAdapterV2TurnInput) => boolean;
- readonly terminalGate?: (turn: ProviderAdapterV2TurnInput) => Deferred.Deferred<void> | undefined;
- readonly response: (turn: ProviderAdapterV2TurnInput) => string;
-}): ProviderAdapterV2Shape {
+ readonly shouldComplete: (turn: ProviderAdapter.ProviderAdapterV2TurnInput) => boolean;
+ readonly terminalGate?: (
+ turn: ProviderAdapter.ProviderAdapterV2TurnInput,
+ ) => Deferred.Deferred<void> | undefined;
+ readonly response: (turn: ProviderAdapter.ProviderAdapterV2TurnInput) => string;
+}): ProviderAdapter.ProviderAdapterV2["Service"] {
return {
instanceId: input.instanceId,
driver: input.driver,
@@ -196,7 +193,7 @@ function makeDeterministicAdapter(input: {
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
openSession: (sessionInput) =>
Effect.gen(function* () {
- const events = yield* PubSub.unbounded<ProviderAdapterV2Event>();
+ const events = yield* PubSub.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
const now = yield* DateTime.now;
const providerSession: OrchestrationV2ProviderSession = {
id: sessionInput.providerSessionId,
@@ -211,12 +208,12 @@ function makeDeterministicAdapter(input: {
lastError: null,
};
- const publish = (providerEvents: ReadonlyArray<ProviderAdapterV2Event>) =>
+ const publish = (providerEvents: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>) =>
Effect.forEach(providerEvents, (event) => PubSub.publish(events, event), {
discard: true,
});
const runOrdinals = new Map<ProviderTurnId, number>();
- const turnInputs = new Map<ProviderTurnId, ProviderAdapterV2TurnInput>();
+ const turnInputs = new Map<ProviderTurnId, ProviderAdapter.ProviderAdapterV2TurnInput>();
return {
instanceId: input.instanceId,
diff --git a/apps/server/src/mcpApps/McpAppRequests.test.ts b/apps/server/src/mcpApps/McpAppRequests.test.ts
index ce2d6428091..dfd01ad27da 100644
--- a/apps/server/src/mcpApps/McpAppRequests.test.ts
+++ b/apps/server/src/mcpApps/McpAppRequests.test.ts
@@ -14,10 +14,7 @@ import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
import * as Orchestrator from "../orchestration-v2/Orchestrator.ts";
-import type {
- ProviderAdapterV2McpApps,
- ProviderAdapterV2SessionRuntime,
-} from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderSessionManager from "../orchestration-v2/ProviderSessionManager.ts";
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
import * as McpAppModelContext from "./McpAppModelContext.ts";
@@ -71,7 +68,7 @@ const storedContext = new Map<string, string>();
function makeLayer(input: {
readonly item: OrchestrationV2TurnItem | null;
- readonly mcpApps?: ProviderAdapterV2McpApps;
+ readonly mcpApps?: ProviderAdapter.ProviderAdapterV2McpApps;
readonly live?: boolean;
}) {
return McpAppRequests.layer.pipe(
@@ -121,7 +118,9 @@ function makeLayer(input: {
: Option.some(
(input.mcpApps === undefined
? {}
- : { mcpApps: input.mcpApps }) as ProviderAdapterV2SessionRuntime,
+ : {
+ mcpApps: input.mcpApps,
+ }) as ProviderAdapter.ProviderAdapterV2SessionRuntime,
),
),
}),
@@ -138,7 +137,7 @@ const reason = <A, R>(effect: Effect.Effect<A, McpAppRequestError, R>) =>
describe("McpAppRequests", () => {
const calls: Array<{ server: string; tool: string }> = [];
- const mcpApps: ProviderAdapterV2McpApps = {
+ const mcpApps: ProviderAdapter.ProviderAdapterV2McpApps = {
listTools: () =>
Effect.succeed([
{ name: "refresh", annotations: { readOnlyHint: true } },
diff --git a/apps/server/src/mcpApps/McpAppRequests.ts b/apps/server/src/mcpApps/McpAppRequests.ts
index 41902c528ae..ee8f6d52132 100644
--- a/apps/server/src/mcpApps/McpAppRequests.ts
+++ b/apps/server/src/mcpApps/McpAppRequests.ts
@@ -21,10 +21,7 @@ import * as Predicate from "effect/Predicate";
import * as Schema from "effect/Schema";
import * as Orchestrator from "../orchestration-v2/Orchestrator.ts";
-import type {
- ProviderAdapterV2McpApps,
- ProviderAdapterV2McpTool,
-} from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderSessionManager from "../orchestration-v2/ProviderSessionManager.ts";
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
import * as McpAppModelContext from "./McpAppModelContext.ts";
@@ -57,10 +54,10 @@ export class McpAppRequests extends Context.Service<
const encodeJson = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
const utf8 = new TextEncoder();
-const readOnlyHint = (tool: ProviderAdapterV2McpTool) =>
+const readOnlyHint = (tool: ProviderAdapter.ProviderAdapterV2McpTool) =>
Predicate.isObject(tool.annotations) && tool.annotations.readOnlyHint === true;
-const toolTitle = (tool: ProviderAdapterV2McpTool) =>
+const toolTitle = (tool: ProviderAdapter.ProviderAdapterV2McpTool) =>
Predicate.isObject(tool.annotations) && typeof tool.annotations.title === "string"
? tool.annotations.title
: undefined;
@@ -112,7 +109,7 @@ const make = Effect.gen(function* () {
.pipe(Effect.mapError((cause) => fail(input.threadId, "request-failed", cause))),
);
if (runtime === undefined) return yield* fail(input.threadId, "session-stopped");
- const mcpApps: ProviderAdapterV2McpApps | undefined = runtime.mcpApps;
+ const mcpApps: ProviderAdapter.ProviderAdapterV2McpApps | undefined = runtime.mcpApps;
if (mcpApps === undefined) return yield* fail(input.threadId, "provider-unsupported");
return { app, providerThread, mcpApps };
});
diff --git a/apps/server/src/orchestration-v2/AcpRegistryOrchestratorV2.live.test.ts b/apps/server/src/orchestration-v2/AcpRegistryOrchestratorV2.live.test.ts
index 4f2ea3e2f3d..f39c1c21153 100644
--- a/apps/server/src/orchestration-v2/AcpRegistryOrchestratorV2.live.test.ts
+++ b/apps/server/src/orchestration-v2/AcpRegistryOrchestratorV2.live.test.ts
@@ -29,7 +29,7 @@ import * as CodexInstallation from "../provider/CodexInstallation.ts";
import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
import * as ModelManifest from "../provider/ModelManifest.ts";
import * as ProviderInstanceRegistryHydration from "../provider/ProviderInstanceRegistryHydration.ts";
-import * as ProviderEventLoggers from "../provider/ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as OpenCodeRuntime from "@t3tools/provider-opencode/server/OpenCodeRuntime";
import * as OpenCodeServerLedger from "@t3tools/provider-opencode/server/OpenCodeServerLedger";
import * as ServerSettings from "../serverSettings.ts";
diff --git a/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
index bda7b91e735..f1f33d43233 100644
--- a/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
@@ -64,13 +64,8 @@ import {
registerXAiBackgroundTaskTracking,
} from "@t3tools/provider-grok/testing";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import {
- ProviderAdapterProtocolError,
- ProviderAdapterV2RuntimePolicy,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
-import type { ProviderContinuationRequest } from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import {
AcpProviderCapabilitiesV2,
acpProviderItemNativeId,
@@ -540,7 +535,7 @@ function makeTurnInput(input: {
readonly threadId: ThreadId;
readonly providerThread: OrchestrationV2ProviderThread;
readonly instanceId: ProviderInstanceId;
- readonly runtimePolicy: ProviderAdapterV2RuntimePolicy;
+ readonly runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
readonly now: DateTime.Utc;
readonly ordinal?: number;
readonly modelSelection?: ModelSelection;
@@ -548,7 +543,7 @@ function makeTurnInput(input: {
readonly messageCreatedBy?: "user" | "agent";
readonly messageCreationSource?: "web" | "mobile" | "mcp" | "provider" | "server";
readonly messageText?: string;
-}): ProviderAdapterV2TurnInput {
+}): ProviderAdapter.ProviderAdapterV2TurnInput {
const ordinal = input.ordinal ?? 1;
const suffix = `${input.threadId}:${ordinal}`;
const modelSelection =
@@ -625,7 +620,7 @@ describe("AcpAdapterV2", () => {
}),
},
});
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -742,7 +737,7 @@ describe("AcpAdapterV2", () => {
},
selfInvocation,
});
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -799,7 +794,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const policy = (interactionMode: "default" | "plan") =>
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode,
cwd: process.cwd(),
@@ -820,7 +815,7 @@ describe("AcpAdapterV2", () => {
const now = yield* DateTime.now;
const runTurn = Effect.fnUntraced(function* (
ordinal: number,
- runtimePolicy: ProviderAdapterV2RuntimePolicy,
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy,
messageText: string,
) {
yield* runtime.startTurn(
@@ -917,7 +912,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-v2-plan-replay-boundary");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -1091,7 +1086,7 @@ describe("AcpAdapterV2", () => {
});
const threadId = ThreadId.make("devin-streamed-write");
const modelSelection = { instanceId, model: "default" };
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -1342,7 +1337,7 @@ describe("AcpAdapterV2", () => {
});
const threadId = ThreadId.make("devin-replay-parent");
const modelSelection = { instanceId, model: "default" };
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -1504,7 +1499,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-v2-fidelity");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -1684,7 +1679,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-eager-resume");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -1765,7 +1760,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-stale-eager-resume");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -1910,7 +1905,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-unexpected-termination");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -1993,7 +1988,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-provider-exit-running-command");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -2065,7 +2060,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-cgroup-unavailable");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -2130,7 +2125,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-cgroup-join-failure");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -2226,7 +2221,7 @@ describe("AcpAdapterV2", () => {
McpProviderSession.clearMcpProviderSession(targetThreadId);
}),
);
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -2392,7 +2387,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-no-client-fs");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: workspace,
@@ -2493,7 +2488,7 @@ describe("AcpAdapterV2", () => {
clientTerminals: { childProcessSpawner },
});
const threadId = ThreadId.make("thread-acp-unknown-permission-grant");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -2598,7 +2593,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-missing-native-thread");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -2629,7 +2624,7 @@ describe("AcpAdapterV2", () => {
.pipe(Effect.flip);
assert.equal(error._tag, "ProviderAdapterTurnStartError");
- assert.instanceOf(error.cause, ProviderAdapterProtocolError);
+ assert.instanceOf(error.cause, ProviderAdapter.ProviderAdapterProtocolError);
assert.include(String(error.cause), "missing its ACP session id");
}).pipe(Effect.provide(layerTest), Effect.scoped),
);
@@ -2676,7 +2671,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-rollback-session");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -2689,7 +2684,7 @@ describe("AcpAdapterV2", () => {
runtimePolicy,
});
assert.isTrue(runtime.providerSession.capabilities.threads.canRollbackThread);
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -2883,7 +2878,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-rollback-retry-generation");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -2899,7 +2894,7 @@ describe("AcpAdapterV2", () => {
return yield* Effect.die("ACP runtime must expose background work state");
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -2995,7 +2990,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-rollback-failure-compensation");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3009,7 +3004,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -3079,7 +3074,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-idle-finalizer");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3129,7 +3124,7 @@ describe("AcpAdapterV2", () => {
threadId: ThreadId.make(`grok-model-${model}`),
providerSessionId: ProviderSessionId.make(`grok-model-${model}`),
modelSelection: { instanceId, model },
- runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3173,7 +3168,7 @@ describe("AcpAdapterV2", () => {
),
});
const threadId = ThreadId.make("grok-model-switch-back");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3242,7 +3237,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-unsupported-option");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3286,7 +3281,7 @@ describe("AcpAdapterV2", () => {
});
const firstThreadId = ThreadId.make("thread-acp-active-setup:first");
const secondThreadId = ThreadId.make("thread-acp-active-setup:second");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3400,7 +3395,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-empty-successful-bash");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3412,7 +3407,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -3540,7 +3535,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-native-cancel");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3642,7 +3637,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-cancel-permission");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -3741,7 +3736,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-response-wins-permission");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -3833,7 +3828,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-reordered-elicitation");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -3908,7 +3903,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-mcp-approval-elicitation");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -3983,7 +3978,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-normal-close-held-response");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -4089,7 +4084,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-close-wins-registration");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -4208,7 +4203,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-pending-response-timeout");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -4333,7 +4328,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-pending-response-cancel");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -4442,7 +4437,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make(`thread-acp-immediate-permission-${name}`);
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
approvalPolicy: "never",
@@ -4535,7 +4530,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-immediate-url-elicitation");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -4626,7 +4621,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-missing-response-ack");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
approvalPolicy: "never",
@@ -4708,7 +4703,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-teardown-wins-elicitation");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -4802,7 +4797,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-cancel-timeout");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -4903,7 +4898,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-double-stop");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -4915,7 +4910,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -5007,7 +5002,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-interrupt-background-hold");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -5019,7 +5014,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -5111,7 +5106,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-subagent-carryover");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -5123,7 +5118,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -5252,7 +5247,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-carryover-pending-pin");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -5270,7 +5265,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -5416,7 +5411,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-active-carryover-pending-pin");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -5436,7 +5431,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -5661,7 +5656,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-subagent-finalize-window");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -5681,7 +5676,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -5796,7 +5791,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const promptSettled = yield* Deferred.make<void>();
const instanceId = ProviderInstanceId.make("acp-test");
const childSessionId = "mock-child-session-post-settle";
@@ -5859,7 +5855,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-carryover-child-session-post-settle");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -5879,7 +5875,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -6046,7 +6042,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-carryover-subagent-finished");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -6062,7 +6058,7 @@ describe("AcpAdapterV2", () => {
return yield* Effect.die("post-settle continuation must expose hasPendingBackgroundWork");
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -6151,7 +6147,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const instanceId = ProviderInstanceId.make("acp-test");
const childSessionId = "019f44a6-4820-7402-925d-bc862ee711dd";
let subagentPhase: "spawn" | "complete" = "spawn";
@@ -6210,7 +6207,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-completed-root-eager-carryover");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -6230,7 +6227,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -6396,7 +6393,8 @@ describe("AcpAdapterV2", () => {
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const bufferedAssistantText = "BUFFERED_WAKE_AFTER_USER_ATTACH";
const instanceId = ProviderInstanceId.make("acp-test");
let subagentPhase: "spawn" | "complete" = "spawn";
@@ -6458,7 +6456,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-carryover-root-session-continuation");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -6478,7 +6476,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -6678,7 +6676,8 @@ describe("AcpAdapterV2", () => {
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const promptWireReturned = yield* Deferred.make<void>();
const releasePromptCompletion = yield* Deferred.make<void>();
const instanceId = ProviderInstanceId.make("acp-test");
@@ -6750,7 +6749,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-carryover-already-handled-re-report");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -6770,7 +6769,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -6914,7 +6913,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const promptSettled = yield* Deferred.make<void>();
const instanceId = ProviderInstanceId.make("acp-test");
const childSessionId = "019f5470-bf92-7a90-afb3-5a6cea5b34a3";
@@ -6988,7 +6988,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-carryover-root-end-notice");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -7006,7 +7006,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -7136,7 +7136,8 @@ describe("AcpAdapterV2", () => {
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const instanceId = ProviderInstanceId.make("acp-test");
const childSessionId = "mock-child-session-pending-continuation";
const bufferedAssistantText = "POST_SETTLE_BUFFERED_ASSISTANT_TEXT";
@@ -7199,7 +7200,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-carryover-child-pending-continuation");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -7219,7 +7220,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -7401,7 +7402,8 @@ describe("AcpAdapterV2", () => {
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const instanceId = ProviderInstanceId.make("acp-test");
const childSessionId = "mock-child-session-root-then-child";
let subagentPhase: "spawn" | "complete" = "spawn";
@@ -7463,7 +7465,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-carryover-root-then-child");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -7483,7 +7485,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -7701,7 +7703,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-settled-soft-steer");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -7713,7 +7715,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -7834,7 +7836,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-unsettled-steer-stays-hard");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -7892,7 +7894,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const instanceId = ProviderInstanceId.make("acp-test");
let cancelCalled = false;
let runtimeOrdinalSeen = 0;
@@ -7940,7 +7943,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-soft-mid-prompt-steer");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -7958,7 +7961,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -8115,7 +8118,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-stop-quarantine-late-task");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -8133,7 +8136,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -8255,7 +8258,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-production-stop-hard-kill");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -8267,7 +8270,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -8417,7 +8420,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-stop-after-soft-steer-orphan");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -8431,7 +8434,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -8700,7 +8703,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-direct-stop-deferred-terminal");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -8720,7 +8723,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -8904,7 +8907,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-settled-soft-admission-race");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -8918,7 +8921,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -8999,7 +9002,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const instanceId = ProviderInstanceId.make("acp-test");
const adapter = yield* makeAcpAdapterV2({
instanceId,
@@ -9037,7 +9041,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-already-handled-wake-pin");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -9057,7 +9061,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -9123,7 +9127,8 @@ describe("AcpAdapterV2", () => {
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const instanceId = ProviderInstanceId.make("acp-test");
@@ -9154,7 +9159,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-sticky-continuation-dispatch");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -9168,7 +9173,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -9237,7 +9242,8 @@ describe("AcpAdapterV2", () => {
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const userPromptStarted = yield* Deferred.make<void>();
const releaseUserPrompt = yield* Deferred.make<void>();
const bufferedAssistantText = "BUFFERED_WAKE_QUEUED_AFTER_USER";
@@ -9284,7 +9290,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-buffered-continuation-user-race");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -9304,7 +9310,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -9480,7 +9486,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-injected-report-hold");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -9492,7 +9498,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -9515,7 +9521,7 @@ describe("AcpAdapterV2", () => {
// hydration are ingested: the hydrated monitor card carries the
// fetched listing.
let reportSeen = false;
- const trackReport = (event: ProviderAdapterV2Event): void => {
+ const trackReport = (event: ProviderAdapter.ProviderAdapterV2Event): void => {
if (
event.type === "turn_item.updated" &&
event.turnItem.type === "assistant_message" &&
@@ -9605,7 +9611,8 @@ describe("AcpAdapterV2", () => {
const triggerDir = yield* fileSystem.makeTempDirectoryScoped();
const triggerPath = path.join(triggerDir, "report-trigger");
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const capturedMutation: {
current:
| ((mutation: {
@@ -9662,7 +9669,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-settle-hold-ext-complete-no-wake");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -9676,7 +9683,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -9696,7 +9703,7 @@ describe("AcpAdapterV2", () => {
});
let reportSeen = false;
- const trackReport = (event: ProviderAdapterV2Event): void => {
+ const trackReport = (event: ProviderAdapter.ProviderAdapterV2Event): void => {
if (
event.type === "turn_item.updated" &&
event.turnItem.type === "assistant_message" &&
@@ -9799,7 +9806,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptGate = yield* Deferred.make<EffectAcpSchema.PromptResponse>();
@@ -9854,7 +9862,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-pre-settle-arm-cleared-by-report");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -9868,7 +9876,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -9965,7 +9973,7 @@ describe("AcpAdapterV2", () => {
yield* Effect.yieldNow;
let reportSeen = false;
- const trackReport = (event: ProviderAdapterV2Event): void => {
+ const trackReport = (event: ProviderAdapter.ProviderAdapterV2Event): void => {
if (
event.type === "turn_item.updated" &&
event.turnItem.type === "assistant_message" &&
@@ -10033,7 +10041,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptGate = yield* Deferred.make<EffectAcpSchema.PromptResponse>();
@@ -10095,7 +10104,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-staggered-midturn-keep-until-last");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -10109,7 +10118,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -10246,7 +10255,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptGate = yield* Deferred.make<EffectAcpSchema.PromptResponse>();
@@ -10312,7 +10322,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-staggered-midturn-clear-on-interrupt");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -10326,7 +10336,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -10455,7 +10465,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptGates: Array<Deferred.Deferred<EffectAcpSchema.PromptResponse, never>> = [];
@@ -10543,7 +10554,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-multiturn-in-turn-monitor-no-wake");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -10563,7 +10574,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -10820,7 +10831,8 @@ describe("AcpAdapterV2", () => {
const mockAgentPath = yield* path.fromFileUrl(
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
let applyMutation: AcpAdapterV2ExtensionContext["applyBackgroundTaskMutation"] | undefined;
@@ -10860,7 +10872,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-wake-report-while-queued");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -10872,7 +10884,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -10969,7 +10981,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptGates: Array<Deferred.Deferred<EffectAcpSchema.PromptResponse, never>> = [];
@@ -11038,7 +11051,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-mid-turn-dirty-wake-buffer");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -11058,7 +11071,7 @@ describe("AcpAdapterV2", () => {
);
}
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -11294,7 +11307,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptGate = yield* Deferred.make<EffectAcpSchema.PromptResponse>();
@@ -11344,7 +11358,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-mid-turn-unhandled-offers-after-finalize");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -11358,7 +11372,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -11446,7 +11460,7 @@ describe("AcpAdapterV2", () => {
content: { type: "text", text: " \n\t " },
},
});
- const lateEvents: Array<ProviderAdapterV2Event> = [];
+ const lateEvents: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
let lateEvent = yield* Queue.poll(events);
while (Option.isSome(lateEvent)) {
lateEvents.push(lateEvent.value);
@@ -11475,7 +11489,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptGate = yield* Deferred.make<EffectAcpSchema.PromptResponse>();
@@ -11529,7 +11544,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-empty-drain-continuation-quiet");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -11543,7 +11558,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -11713,7 +11728,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
const promptGate = yield* Deferred.make<EffectAcpSchema.PromptResponse>();
@@ -11765,7 +11781,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-empty-drain-continuation-no-wedge");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -11779,7 +11795,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -11913,7 +11929,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-restart-after-interrupt");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -12144,7 +12160,8 @@ describe("AcpAdapterV2", () => {
const residualCallbackResponseLogPath = path.join(residualCallbackDir, "responses.log");
const residualCallbackTriggerPath = path.join(residualCallbackDir, "trigger");
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const teardownStarted = yield* Deferred.make<void>();
const releaseTeardown = yield* Deferred.make<void>();
let terminatorCallCount = 0;
@@ -12187,7 +12204,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-failed-hard-teardown");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -12202,7 +12219,7 @@ describe("AcpAdapterV2", () => {
runtimePolicy,
})
.pipe(Effect.provideService(Scope.Scope, sessionScope));
- const adapterEvents = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const adapterEvents = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(adapterEvents, event)),
Effect.forkIn(sessionScope),
@@ -12368,7 +12385,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-missing-hard-teardown");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -12464,7 +12481,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-concurrent-hard-teardown");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -12540,7 +12557,8 @@ describe("AcpAdapterV2", () => {
new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
);
const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const responseLifecycle: Array<string> = [];
type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
type HandlerRecord = {
@@ -12633,7 +12651,7 @@ describe("AcpAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-successful-teardown-callback-quarantine");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -12647,7 +12665,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const adapterEvents = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const adapterEvents = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(adapterEvents, event)),
Effect.forkScoped,
@@ -12849,7 +12867,7 @@ describe("AcpAdapterV2", () => {
method: "_x.ai/ask_user_question",
},
).pipe(Effect.forkScoped);
- let replacementRequest: ProviderAdapterV2Event | undefined;
+ let replacementRequest: ProviderAdapter.ProviderAdapterV2Event | undefined;
while (replacementRequest === undefined) {
const event = yield* Queue.take(adapterEvents);
if (event.type === "runtime_request.updated" && event.runtimeRequest.status === "pending") {
@@ -12916,7 +12934,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-stale-deferred-cleanup");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: process.cwd(),
@@ -12928,7 +12946,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -12975,7 +12993,7 @@ describe("AcpAdapterV2", () => {
yield* runtime.startTurn(
makeTurnInput({ threadId, providerThread, instanceId, runtimePolicy, now, ordinal: 2 }),
);
- let replacementPending: ProviderAdapterV2Event | undefined;
+ let replacementPending: ProviderAdapter.ProviderAdapterV2Event | undefined;
while (replacementPending === undefined) {
const event = yield* Queue.take(events);
if (event.type === "runtime_request.updated" && event.runtimeRequest.status === "pending") {
@@ -13045,7 +13063,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-concurrent-resume-teardown");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -13192,7 +13210,7 @@ describe("AcpAdapterV2", () => {
continuationRequests: { offer: () => Effect.void },
});
const threadId = ThreadId.make("thread-acp-direct-stop-running-command");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -13206,7 +13224,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -13458,7 +13476,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-direct-stop-subagent-hold");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -13472,7 +13490,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
@@ -13602,7 +13620,7 @@ describe("AcpAdapterV2", () => {
selfInvocation,
});
const threadId = ThreadId.make("thread-acp-restart-active-in-process");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -13614,7 +13632,7 @@ describe("AcpAdapterV2", () => {
modelSelection,
runtimePolicy,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
yield* runtime.events.pipe(
Stream.runForEach((event) => Queue.offer(events, event)),
Effect.forkScoped,
diff --git a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
index 728e8bc4c91..c640ae35491 100644
--- a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
@@ -29,7 +29,7 @@ import {
makeAcpReplayCompletenessAssertion,
makeAcpReplayRuntime,
} from "./AcpAdapterV2.testkit.ts";
-import { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import { BUILT_IN_PROVIDER_ADAPTER_DRIVER_KINDS_V2 } from "../builtInProviderAdapterDrivers.ts";
import { AcpRegistryAdapterV2Driver } from "@t3tools/provider-acp-registry/server";
import {
@@ -216,7 +216,7 @@ describe("AcpRegistryAdapterV2", () => {
model: "default",
options: [{ id: ACP_SESSION_MODE_OPTION_ID, value: input.storedModePick }],
},
- runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: replayDir,
@@ -304,7 +304,7 @@ describe("AcpRegistryAdapterV2", () => {
);
}),
});
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
@@ -413,7 +413,7 @@ describe("AcpRegistryAdapterV2", () => {
},
});
const threadId = ThreadId.make("thread-acp-registry-fixture");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
diff --git a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
index f997751f2fd..9579da1fa91 100644
--- a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
@@ -27,7 +27,7 @@ import { layerTestProviderHost } from "@t3tools/provider-testing/host";
import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
import { makeAntigravityAcpRuntime } from "../../provider/acp/AntigravityAcpSupport.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import {
makeAntigravityAcpAdapterFlavor,
makeAntigravityAdapterV2,
@@ -74,7 +74,7 @@ describe("AntigravityAdapterV2 flavor", () => {
it("maps runtime modes to the agent's native permission modes", () => {
const mode = (runtimeMode: "approval-required" | "auto-accept-edits" | "full-access") =>
flavor.sessionModeForPolicy?.(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode,
interactionMode: "default",
cwd: "/workspace",
@@ -190,7 +190,7 @@ describe("AntigravityAdapterV2 client file system", () => {
yield* fileSystem.writeFileString(attachment, "pasted");
const threadId = ThreadId.make("thread-antigravity-containment");
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: workspace,
@@ -325,7 +325,7 @@ describe("AntigravityAdapterV2 workspace changes", () => {
yield* fileSystem.writeFileString(path.join(workspaceA, "a.txt"), "from a");
yield* fileSystem.writeFileString(path.join(workspaceB, "b.txt"), "from b");
const policyFor = (cwd: string) =>
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd,
@@ -476,7 +476,7 @@ describe("AntigravityAdapterV2 client file system under restrictive policies", (
});
yield* fileSystem.writeFileString(path.join(workspace, "existing.ts"), "existing");
const threadId = ThreadId.make(`thread-antigravity-restrictive-${policy.runtimeMode}`);
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
...policy,
interactionMode: "default",
cwd: workspace,
diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
index bfef7f9e9a1..eed58e1aa41 100644
--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
@@ -61,13 +61,9 @@ import { WorktreeToolkit } from "../../mcp/toolkits/worktree/tools.ts";
import { ThreadToolkit } from "../../mcp/toolkits/thread/tools.ts";
import { OrchestratorToolkit } from "../../mcp/toolkits/orchestrator/tools.ts";
import { ClaudeExecutableFileCheck } from "../../provider/Drivers/ClaudeExecutable.ts";
-import type { EventNdjsonLogger } from "../../provider/EventNdjsonLogger.ts";
-import {
- ProviderAdapterV2RuntimePolicy,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
-import type { ProviderContinuationRequest } from "@t3tools/provider-core/server/continuationRequests";
+import type * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
import * as ClaudeAdapterV2 from "./ClaudeAdapterV2.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
@@ -81,7 +77,7 @@ const CLAUDE_TEST_MODEL_SELECTION = {
model: "claude-sonnet-4-6",
options: [{ id: "effort", value: "ultrathink" }],
} satisfies ModelSelection;
-const CLAUDE_TEST_RUNTIME_POLICY = ProviderAdapterV2RuntimePolicy.make({
+const CLAUDE_TEST_RUNTIME_POLICY = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -127,14 +123,14 @@ function makeClaudeTestTurnInput(input: {
readonly now: DateTime.Utc;
readonly attemptId: RunAttemptId;
readonly text: string;
- readonly attachments: ProviderAdapterV2TurnInput["message"]["attachments"];
+ readonly attachments: ProviderAdapter.ProviderAdapterV2TurnInput["message"]["attachments"];
readonly providerTurnOrdinal?: number;
readonly nativeThreadHasTurns?: boolean;
- readonly messageCreatedBy?: ProviderAdapterV2TurnInput["message"]["createdBy"];
- readonly messageCreationSource?: ProviderAdapterV2TurnInput["message"]["creationSource"];
+ readonly messageCreatedBy?: ProviderAdapter.ProviderAdapterV2TurnInput["message"]["createdBy"];
+ readonly messageCreationSource?: ProviderAdapter.ProviderAdapterV2TurnInput["message"]["creationSource"];
readonly modelSelection?: ModelSelection;
- readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
-}): ProviderAdapterV2TurnInput {
+ readonly runtimePolicy?: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
+}): ProviderAdapter.ProviderAdapterV2TurnInput {
return {
appThread: makeClaudeTestAppThread(input),
threadId: input.threadId,
@@ -298,7 +294,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("maps canonical read-only never policy to Claude dontAsk with read-only tools", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -321,7 +317,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("maps canonical read-only on-request policy to Claude default with callbacks", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -344,7 +340,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("does not auto-allow reads for canonical restricted read-only never policy", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -370,7 +366,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("maps default full-access policy to Claude bypass permissions", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -386,7 +382,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("maps Auto runtime mode to Claude's AI-reviewed permission mode", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "auto",
interactionMode: "default",
cwd: "/workspace",
@@ -401,7 +397,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("keeps approval-required mode interactive with danger-full-access sandboxing", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: "/workspace",
@@ -419,7 +415,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("installs the permission callback for approval-required plan mode", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "plan",
cwd: "/workspace",
@@ -434,7 +430,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("honors never approvals for approval-required workspace-write policy", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: "/workspace",
@@ -453,7 +449,7 @@ describe("ClaudeAdapterV2 runtime query policy", () => {
it("honors never approvals for externally sandboxed policy", () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: "/workspace",
@@ -595,7 +591,7 @@ describe("ClaudeAdapterV2 MCP query overrides", () => {
const threadId = ThreadId.make("thread-claude-mcp-query-key");
withMcpSession(threadId, () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -627,7 +623,7 @@ describe("ClaudeAdapterV2 MCP query overrides", () => {
const threadId = ThreadId.make("thread-claude-mcp-credential-rotation");
withMcpSession(threadId, () => {
const queryPolicy = ClaudeAdapterV2.claudeRuntimeQueryPolicyForRuntimePolicy(
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: "/workspace",
@@ -750,7 +746,7 @@ describe("ClaudeAdapterV2 native protocol logging", () => {
readonly event: unknown;
readonly threadId: ThreadId | null;
}> = [];
- const logger: EventNdjsonLogger = {
+ const logger: ProviderEventLoggers.EventNdjsonLogger = {
filePath: "/tmp/events.log",
write: (event, threadId) =>
Effect.sync(() => {
@@ -993,7 +989,7 @@ describe("ClaudeAdapterV2 Auto-accept edits", () => {
assertComplete: Effect.void,
},
});
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "auto-accept-edits",
interactionMode: "default",
cwd: "/workspace",
@@ -1701,7 +1697,7 @@ describe("ClaudeAdapterV2 native fork", () => {
instanceId: ProviderInstanceId.make(ClaudeAdapterV2.CLAUDE_PROVIDER),
model: "claude-sonnet-4-6",
},
- runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -1713,7 +1709,7 @@ describe("ClaudeAdapterV2 native fork", () => {
instanceId: ProviderInstanceId.make(ClaudeAdapterV2.CLAUDE_PROVIDER),
model: "claude-sonnet-4-6",
},
- runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -1808,7 +1804,7 @@ describe("ClaudeAdapterV2 native fork", () => {
instanceId: ProviderInstanceId.make(ClaudeAdapterV2.CLAUDE_PROVIDER),
model: "claude-sonnet-4-6",
},
- runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -2120,11 +2116,16 @@ describe("ClaudeAdapterV2 background wake turns", () => {
});
const offeredMessages: Array<SDKUserMessage> = [];
const permissionModeChanges: Array<string> = [];
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const terminalReceipts =
- yield* Queue.unbounded<Extract<ProviderAdapterV2Event, { type: "turn.terminal" }>>();
+ yield* Queue.unbounded<
+ Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }>
+ >();
const systemNoticeReceipts =
- yield* Queue.unbounded<Extract<ProviderAdapterV2Event, { type: "turn_item.updated" }>>();
+ yield* Queue.unbounded<
+ Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn_item.updated" }>
+ >();
let openedOptions: ClaudeAdapterV2.ClaudeAgentSdkQueryOptions | undefined;
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
@@ -2210,7 +2211,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
});
- const events: Array<ProviderAdapterV2Event> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
yield* runtime.events.pipe(
Stream.runForEach((event) =>
Effect.gen(function* () {
@@ -2231,7 +2232,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
const terminalEvents = () =>
events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn.terminal" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }> =>
event.type === "turn.terminal",
);
return {
@@ -2817,7 +2820,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
attemptId: RunAttemptId.make("attempt-claude-auth-failure"),
text: "Continue.",
attachments: [],
- runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd,
@@ -3633,10 +3636,16 @@ describe("ClaudeAdapterV2 background wake turns", () => {
),
);
- const providerThreadRosterEvents = (events: ReadonlyArray<ProviderAdapterV2Event>) =>
+ const providerThreadRosterEvents = (
+ events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>,
+ ) =>
events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_thread.updated" }> =>
- event.type === "provider_thread.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_thread.updated" }
+ > => event.type === "provider_thread.updated",
);
it.effect(
@@ -3932,8 +3941,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
});
const processQueues: Array<Queue.Queue<SDKMessage>> = [];
const firstCloseRequested = yield* Deferred.make<void>();
- const events: Array<ProviderAdapterV2Event> = [];
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -4179,7 +4189,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
readonly nativeThreadId: string;
readonly queue: Queue.Queue<SDKMessage>;
}> = [];
- const events: Array<ProviderAdapterV2Event> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -4430,7 +4440,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
Effect.gen(function* () {
const harness = yield* makeWakeHarness;
const now = yield* DateTime.now;
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode,
interactionMode: "default",
cwd: "/workspace",
@@ -4731,7 +4741,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
Effect.gen(function* () {
const harness = yield* makeWakeHarness;
const now = yield* DateTime.now;
- const approvalPolicy = ProviderAdapterV2RuntimePolicy.make({
+ const approvalPolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: "/workspace",
@@ -5972,7 +5982,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
session_id: WAKE_NATIVE_SESSION,
});
const subagentRouting = (
- events: ReadonlyArray<ProviderAdapterV2Event>,
+ events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>,
nativeToolIds: ReadonlyArray<string>,
) => {
const childThreadId =
@@ -6090,7 +6100,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
const userTurn = (
attempt: string,
providerTurnOrdinal: number,
- attachments: ProviderAdapterV2TurnInput["message"]["attachments"] = [],
+ attachments: ProviderAdapter.ProviderAdapterV2TurnInput["message"]["attachments"] = [],
) =>
harness.runtime.startTurn(
makeClaudeTestTurnInput({
@@ -7838,8 +7848,12 @@ describe("ClaudeAdapterV2 background wake turns", () => {
const now = yield* DateTime.now;
const subagentEvents = () =>
harness.events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "subagent.updated" }> =>
- event.type === "subagent.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "subagent.updated" }
+ > => event.type === "subagent.updated",
);
yield* harness.runtime.startTurn(
@@ -7942,8 +7956,12 @@ describe("ClaudeAdapterV2 background wake turns", () => {
const now = yield* DateTime.now;
const subagentEvents = () =>
harness.events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "subagent.updated" }> =>
- event.type === "subagent.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "subagent.updated" }
+ > => event.type === "subagent.updated",
);
yield* harness.runtime.startTurn(
@@ -8059,8 +8077,12 @@ describe("ClaudeAdapterV2 background wake turns", () => {
const now = yield* DateTime.now;
const subagentEvents = () =>
harness.events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "subagent.updated" }> =>
- event.type === "subagent.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "subagent.updated" }
+ > => event.type === "subagent.updated",
);
yield* harness.runtime.startTurn(
@@ -8249,7 +8271,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
// already pre-opened by the wake buffer before the drain replay.
const nodeStatuses = harness.events
.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "node.updated" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "node.updated" }> =>
event.type === "node.updated" &&
event.node.kind === "subagent" &&
event.node.nativeItemRef?.nativeId === SUBAGENT_TASK_ID,
@@ -8288,8 +8312,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
prefix: "t3-claude-v2-process-reset-",
});
const processQueues: Array<Queue.Queue<SDKMessage>> = [];
- const events: Array<ProviderAdapterV2Event> = [];
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -8472,8 +8497,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
prefix: "t3-claude-v2-buffer-replace-",
});
const processQueues: Array<Queue.Queue<SDKMessage>> = [];
- const events: Array<ProviderAdapterV2Event> = [];
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -8708,8 +8734,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
prefix: "t3-claude-v2-subagent-buffer-replace-",
});
const processQueues: Array<Queue.Queue<SDKMessage>> = [];
- const events: Array<ProviderAdapterV2Event> = [];
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -8775,8 +8802,12 @@ describe("ClaudeAdapterV2 background wake turns", () => {
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
const subagentEvents = () =>
events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "subagent.updated" }> =>
- event.type === "subagent.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "subagent.updated" }
+ > => event.type === "subagent.updated",
);
const now = yield* DateTime.now;
@@ -8880,7 +8911,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
assert.equal(finalSubagent?.result, SUBAGENT_SUMMARY);
assert.equal(finalSubagent?.runId, subagentEvents()[0]?.subagent.runId);
const subagentNodeEvents = events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "node.updated" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "node.updated" }> =>
event.type === "node.updated" &&
event.node.kind === "subagent" &&
event.node.nativeItemRef?.nativeId === SUBAGENT_TASK_ID,
@@ -8902,7 +8935,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
prefix: "t3-claude-v2-model-change-running-subagent-",
});
const processQueues: Array<Queue.Queue<SDKMessage>> = [];
- const events: Array<ProviderAdapterV2Event> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -9069,7 +9102,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
});
let openCount = 0;
const processQueues: Array<Queue.Queue<SDKMessage>> = [];
- const events: Array<ProviderAdapterV2Event> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -9198,8 +9231,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
});
let openCount = 0;
const processQueues: Array<Queue.Queue<SDKMessage>> = [];
- const events: Array<ProviderAdapterV2Event> = [];
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -9394,7 +9428,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
const attachmentsDir = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-claude-v2-first-open-fail-",
});
- const events: Array<ProviderAdapterV2Event> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
const adapter = ClaudeAdapterV2.makeClaudeAdapterV2({
instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
settings: DEFAULT_CLAUDE_SETTINGS,
@@ -9496,7 +9530,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
uuid,
session_id: WAKE_NATIVE_SESSION,
});
- const goalStatuses = (events: ReadonlyArray<ProviderAdapterV2Event>) =>
+ const goalStatuses = (events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>) =>
events.flatMap((event) =>
event.type === "provider_thread.updated" && event.providerThread.goal != null
? [event.providerThread.goal]
diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
index de747802d34..0eb2dff9bfe 100644
--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
@@ -101,10 +101,9 @@ import {
} from "../../provider/ClaudeModelCatalog.ts";
import {
boundProviderEventForLogging,
- type EventNdjsonLogger,
shouldPersistProviderEvent,
} from "../../provider/EventNdjsonLogger.ts";
-import * as ProviderEventLoggers from "../../provider/ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import {
claudeRateLimitEventToUpdate,
type ClaudeScopedLimitNames,
@@ -135,7 +134,7 @@ import {
type BackgroundWorkReport,
backgroundWorkNotification,
} from "@t3tools/provider-core/server/notification";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import {
makeSubagentChildThread,
makeSubagentConversationArtifacts,
@@ -570,7 +569,7 @@ export function loggedClaudeQueryOptions(
}
export function makeClaudeAgentSdkProtocolLogger(input: {
- readonly nativeEventLogger: EventNdjsonLogger | undefined;
+ readonly nativeEventLogger: ProviderEventLoggers.EventNdjsonLogger | undefined;
readonly threadId: ThreadId;
readonly providerSessionId: OrchestrationV2ProviderSession["id"];
}): ClaudeAgentSdkProtocolLogger | undefined {
@@ -1118,7 +1117,7 @@ function resultTextFromSdkMessage(
}
function makeProviderThread(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly providerInstanceId: ProviderInstanceId;
readonly appThreadId: OrchestrationV2ProviderThread["appThreadId"];
readonly ownerNodeId?: OrchestrationV2ProviderThread["ownerNodeId"];
@@ -2581,7 +2580,7 @@ function providerFailureFromApiRetry(message: SDKAPIRetryMessage): Orchestration
}
function buildAssistantArtifacts(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly turnInput: ProviderAdapter.ProviderAdapterV2TurnInput;
readonly providerTurnId: OrchestrationV2ProviderTurn["id"];
readonly nativeItemId: string;
@@ -3015,7 +3014,7 @@ export interface ClaudeAdapterV2Options {
readonly fileSystem: FileSystem.FileSystem;
readonly path: Path.Path;
readonly crypto: Crypto.Crypto;
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly queryRunner: ClaudeAgentSdkQueryRunnerShape;
readonly scopedLimitNames?: Ref.Ref<ClaudeScopedLimitNames>;
readonly onUsageLimits?: ServerProviderShape["applyUsageLimits"];
@@ -3029,7 +3028,7 @@ export interface ClaudeAdapterV2Options {
export function makeClaudeAdapterV2(
adapterOptions: ClaudeAdapterV2Options,
-): ProviderAdapter.ProviderAdapterV2Shape {
+): ProviderAdapter.ProviderAdapterV2["Service"] {
const { attachmentsDir, fileSystem, path, crypto, idAllocator, queryRunner } = adapterOptions;
const continuationRequests = adapterOptions.continuationRequests ?? {
offer: () => Effect.void,
@@ -3356,7 +3355,6 @@ export function makeClaudeAdapterV2(
type: "turn_item.updated",
driver: CLAUDE_PROVIDER,
turnItem: makeProviderRetryTurnItem({
- idAllocator,
driver: CLAUDE_PROVIDER,
threadId: context.input.threadId,
runId: context.input.runId,
@@ -5083,7 +5081,6 @@ export function makeClaudeAdapterV2(
type: "turn_item.updated",
driver: CLAUDE_PROVIDER,
turnItem: makeProviderRetryTurnItem({
- idAllocator,
driver: CLAUDE_PROVIDER,
threadId: input.context.input.threadId,
runId: input.context.input.runId,
@@ -6089,7 +6086,6 @@ export function makeClaudeAdapterV2(
type: "turn_item.updated",
driver: CLAUDE_PROVIDER,
turnItem: makeProviderRetryTurnItem({
- idAllocator,
driver: CLAUDE_PROVIDER,
threadId: context.input.threadId,
runId: context.input.runId,
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
index 4188c3248a5..ef884b9c3ab 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
@@ -1,7 +1,6 @@
import * as NodeOS from "node:os";
import { historyResponseItems } from "@t3tools/provider-core/server/handoffBudget";
-import type { ProviderAdapterV2HistoricalContext } from "@t3tools/provider-core/server/ProviderAdapter";
import {
makeProviderTextDeltaCoalescer,
type ProviderTextDeltaUpdate,
@@ -56,21 +55,13 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
import packageJson from "../../../package.json" with { type: "json" };
import * as ServerConfig from "../../config.ts";
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
-import type { EventNdjsonLogger } from "../../provider/EventNdjsonLogger.ts";
-import * as ProviderEventLoggers from "../../provider/ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as EffectWorker from "../EffectWorker.ts";
import * as Orchestrator from "../Orchestrator.ts";
import * as ProviderReplayHarness from "../testkit/ProviderReplayHarness.ts";
-import {
- ProviderAdapterForkThreadError,
- ProviderAdapterOpenSessionError,
- ProviderAdapterRollbackThreadError,
- ProviderAdapterV2RuntimePolicy,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
-import type { ProviderContinuationRequest } from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as CodexAdapterV2 from "./CodexAdapterV2.ts";
import { makeReplayServerConfig, withCodexReplayChildMetadata } from "./CodexAdapterV2.testkit.ts";
import * as CodexAdapterV2Testkit from "./CodexAdapterV2.testkit.ts";
@@ -767,7 +758,7 @@ describe("CodexAdapterV2 process spawning", () => {
instanceId: CodexAdapterV2.CODEX_DEFAULT_INSTANCE_ID,
threadId: ThreadId.make("thread-launch-args"),
providerSessionId: ProviderSessionId.make("provider-session-launch-args"),
- runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -1036,7 +1027,7 @@ describe("CodexAdapterV2 native protocol logging", () => {
readonly event: unknown;
readonly threadId: ThreadId | null;
}> = [];
- const logger: EventNdjsonLogger = {
+ const logger: ProviderEventLoggers.EventNdjsonLogger = {
filePath: "/tmp/events.log",
write: (event, threadId) =>
Effect.sync(() => {
@@ -1410,7 +1401,7 @@ describe("CodexAdapterV2 fork boundary", () => {
}),
);
- assert.instanceOf(error, ProviderAdapterForkThreadError);
+ assert.instanceOf(error, ProviderAdapter.ProviderAdapterForkThreadError);
assert.include(String(error.cause), "provider-turn-missing");
}),
);
@@ -1478,7 +1469,7 @@ const CODEX_TEST_MODEL_SELECTION = {
instanceId: CodexAdapterV2.CODEX_DEFAULT_INSTANCE_ID,
model: "gpt-5.4",
} satisfies ModelSelection;
-const CODEX_TEST_RUNTIME_POLICY = ProviderAdapterV2RuntimePolicy.make({
+const CODEX_TEST_RUNTIME_POLICY = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
@@ -1524,7 +1515,7 @@ function makeCodexTestTurnInput(input: {
readonly now: DateTime.Utc;
readonly attemptId: RunAttemptId;
readonly text: string;
-}): ProviderAdapterV2TurnInput {
+}): ProviderAdapter.ProviderAdapterV2TurnInput {
return {
appThread: makeCodexTestAppThread(input),
threadId: input.threadId,
@@ -1747,7 +1738,7 @@ describe("CodexAdapterV2 session initialize", () => {
),
Effect.mapError(
(cause) =>
- new ProviderAdapterOpenSessionError({
+ new ProviderAdapter.ProviderAdapterOpenSessionError({
driver: CodexAdapterV2.CODEX_DRIVER_KIND,
providerSessionId: openInput.providerSessionId,
cause,
@@ -1907,7 +1898,8 @@ describe("CodexAdapterV2 post-settle continuation", () => {
const makeCodexReplayHarness = (
transcript: CodexReplay.CodexAppServerReplayTranscript,
- onEvent: (event: ProviderAdapterV2Event) => Effect.Effect<unknown> = () => Effect.void,
+ onEvent: (event: ProviderAdapter.ProviderAdapterV2Event) => Effect.Effect<unknown> = () =>
+ Effect.void,
onRequest: (method: string, params: unknown) => Effect.Effect<void> = () => Effect.void,
readChildMetadata?: Parameters<typeof withCodexReplayChildMetadata>[2],
) =>
@@ -1915,13 +1907,14 @@ describe("CodexAdapterV2 post-settle continuation", () => {
const fileSystem = yield* FileSystem.FileSystem;
const idAllocator = yield* IdAllocator.IdAllocatorV2;
const serverConfig = yield* makeReplayServerConfig(transcript.scenario).pipe(Effect.orDie);
- const continuationRequests: Array<ProviderContinuationRequest> = [];
+ const continuationRequests: Array<ProviderContinuationRequests.ProviderContinuationRequest> =
+ [];
const clientFactory: CodexAdapterV2.CodexAppServerClientFactoryShape = {
open: (openInput) =>
Layer.build(CodexReplay.layerReplay(transcript)).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterOpenSessionError({
+ new ProviderAdapter.ProviderAdapterOpenSessionError({
driver: CodexAdapterV2.CODEX_DRIVER_KIND,
providerSessionId: openInput.providerSessionId,
cause,
@@ -1975,7 +1968,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
modelSelection: CODEX_TEST_MODEL_SELECTION,
runtimePolicy: CODEX_TEST_RUNTIME_POLICY,
});
- const events: Array<ProviderAdapterV2Event> = [];
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
const firstTerminal = yield* Deferred.make<void>();
yield* runtime.events.pipe(
Stream.runForEach((event) =>
@@ -1998,13 +1991,19 @@ describe("CodexAdapterV2 post-settle continuation", () => {
const hasPendingBackgroundWork = runtime.hasPendingBackgroundWork;
const terminalEvents = () =>
events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn.terminal" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }> =>
event.type === "turn.terminal",
);
const subagentUpdates = () =>
events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "subagent.updated" }> =>
- event.type === "subagent.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "subagent.updated" }
+ > => event.type === "subagent.updated",
);
return {
runtime,
@@ -2026,7 +2025,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
Effect.gen(function* () {
const nativeThreadId = `inject-${response}`;
const prompt = "Only the current request";
- const history: ProviderAdapterV2HistoricalContext = {
+ const history: ProviderAdapter.ProviderAdapterV2HistoricalContext = {
context: "Historical conversation",
messages: (["user", "assistant"] as const).map((role) => ({
role,
@@ -2528,12 +2527,14 @@ describe("CodexAdapterV2 post-settle continuation", () => {
}).pipe(Effect.scoped, Effect.provide(Layer.merge(IdAllocator.layer, NodeServices.layer))),
);
- const assistantMessages = (events: ReadonlyArray<ProviderAdapterV2Event>) =>
+ const assistantMessages = (events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>) =>
events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "message.updated" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "message.updated" }> =>
event.type === "message.updated" && event.message.role === "assistant",
);
- const assistantTurnItems = (events: ReadonlyArray<ProviderAdapterV2Event>) =>
+ const assistantTurnItems = (events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>) =>
events.flatMap((event) =>
event.type === "turn_item.updated" && event.turnItem.type === "assistant_message"
? [event.turnItem]
@@ -4914,8 +4915,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
);
const providerTurnId = harness.events.find(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
- event.type === "provider_turn.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > => event.type === "provider_turn.updated",
)?.providerTurn.id;
assert.isDefined(providerTurnId);
@@ -4931,7 +4936,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
assert.isAtLeast(terminalIndex, 0);
let lastCommandBeforeTerminal:
- | Extract<ProviderAdapterV2Event, { type: "turn_item.updated" }>
+ | Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn_item.updated" }>
| undefined;
for (let index = 0; index < terminalIndex; index++) {
const event = harness.events[index];
@@ -4997,8 +5002,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
);
const commandUpdates = harness.events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn_item.updated" }> =>
- event.type === "turn_item.updated" && event.turnItem.type === "command_execution",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "turn_item.updated" }
+ > => event.type === "turn_item.updated" && event.turnItem.type === "command_execution",
);
assert.isAtLeast(commandUpdates.length, 2, "start + interrupt terminalization");
assert.equal(commandUpdates[commandUpdates.length - 1]?.turnItem.status, "interrupted");
@@ -5142,7 +5151,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
});
const assertChildProviderTerminalBeforeRoot = (
- events: ReadonlyArray<ProviderAdapterV2Event>,
+ events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>,
rootThreadId: ThreadId,
) => {
const terminalIndex = events.findIndex((event) => event.type === "turn.terminal");
@@ -5199,8 +5208,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
"running child command item",
);
const providerTurnId = harness.events.find(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
- event.type === "provider_turn.updated" && event.threadId === harness.threadId,
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > => event.type === "provider_turn.updated" && event.threadId === harness.threadId,
)?.providerTurn.id;
assert.isDefined(providerTurnId);
@@ -5212,7 +5225,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
yield* awaitUntil(() => harness.terminalEvents().length === 1, "interrupted root terminal");
assert.equal(harness.terminalEvents()[0]?.status, "interrupted");
const childCommandUpdates = harness.events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn_item.updated" }> =>
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "turn_item.updated" }
+ > =>
event.type === "turn_item.updated" &&
event.turnItem.type === "command_execution" &&
event.turnItem.nativeItemRef?.nativeId === INTERRUPT_CHILD_COMMAND_ITEM,
@@ -5289,8 +5307,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
"running child command item",
);
const providerTurnId = harness.events.find(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
- event.type === "provider_turn.updated" && event.threadId === harness.threadId,
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > => event.type === "provider_turn.updated" && event.threadId === harness.threadId,
)?.providerTurn.id;
assert.isDefined(providerTurnId);
@@ -5361,8 +5383,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
"running child command item",
);
const providerTurnId = harness.events.find(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
- event.type === "provider_turn.updated" && event.threadId === harness.threadId,
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > => event.type === "provider_turn.updated" && event.threadId === harness.threadId,
)?.providerTurn.id;
assert.isDefined(providerTurnId);
@@ -5460,8 +5486,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
"running child command item",
);
const providerTurnId = harness.events.find(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
- event.type === "provider_turn.updated" && event.threadId === harness.threadId,
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > => event.type === "provider_turn.updated" && event.threadId === harness.threadId,
)?.providerTurn.id;
assert.isDefined(providerTurnId);
@@ -5481,7 +5511,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
yield* awaitUntil(() => harness.terminalEvents().length === 1, "interrupted root terminal");
const lateChildUpdates = harness.events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > =>
event.type === "provider_turn.updated" &&
event.providerTurn.nativeTurnRef?.nativeId === INTERRUPT_LATE_CHILD_NATIVE_TURN,
);
@@ -5589,8 +5624,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
"running child command item",
);
const providerTurnId = harness.events.find(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
- event.type === "provider_turn.updated" && event.threadId === harness.threadId,
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > => event.type === "provider_turn.updated" && event.threadId === harness.threadId,
)?.providerTurn.id;
assert.isDefined(providerTurnId);
@@ -5835,8 +5874,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
"running command item",
);
const providerTurnId = harness.events.find(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
- event.type === "provider_turn.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > => event.type === "provider_turn.updated",
)?.providerTurn.id;
assert.isDefined(providerTurnId);
@@ -5868,8 +5911,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
assert.lengthOf(terminalProviderTurnsBeforeLateEvents, 1);
const commandUpdatesBeforeLateEvents = harness.events.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn_item.updated" }> =>
- event.type === "turn_item.updated" && event.turnItem.type === "command_execution",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "turn_item.updated" }
+ > => event.type === "turn_item.updated" && event.turnItem.type === "command_execution",
);
const terminalCommands = commandUpdatesBeforeLateEvents.filter(
(event) =>
@@ -5993,8 +6040,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
"running command item",
);
const providerTurnId = harness.events.find(
- (event): event is Extract<ProviderAdapterV2Event, { type: "provider_turn.updated" }> =>
- event.type === "provider_turn.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "provider_turn.updated" }
+ > => event.type === "provider_turn.updated",
)?.providerTurn.id;
assert.isDefined(providerTurnId);
@@ -7663,7 +7714,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
}),
);
- assert.instanceOf(error, ProviderAdapterRollbackThreadError);
+ assert.instanceOf(error, ProviderAdapter.ProviderAdapterRollbackThreadError);
assert.include(
errorCauseChainText(error),
"legacy",
@@ -7904,7 +7955,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
}),
);
- assert.instanceOf(error, ProviderAdapterForkThreadError);
+ assert.instanceOf(error, ProviderAdapter.ProviderAdapterForkThreadError);
assert.include(
errorCauseChainText(error),
"legacy",
@@ -7969,7 +8020,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
}),
);
- assert.instanceOf(error, ProviderAdapterForkThreadError);
+ assert.instanceOf(error, ProviderAdapter.ProviderAdapterForkThreadError);
assert.include(errorCauseChainText(error), "fork exploded");
}).pipe(Effect.scoped, Effect.provide(Layer.merge(IdAllocator.layer, NodeServices.layer))),
);
@@ -8033,7 +8084,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
}),
),
);
- const providerGoals = (events: ReadonlyArray<ProviderAdapterV2Event>) =>
+ const providerGoals = (events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>) =>
events.flatMap((event) =>
event.type === "provider_thread.updated" ? [event.providerThread.goal?.status ?? null] : [],
);
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.testkit.ts
index 0941a1f88e3..ea949828076 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.testkit.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.testkit.ts
@@ -15,7 +15,7 @@ import * as Schema from "effect/Schema";
import * as ServerConfig from "../../config.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import { ProviderAdapterOpenSessionError } from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import { ProviderAdapterDriverCreateError } from "@t3tools/provider-core/server/adapterDriver";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import type { OrchestratorV2ProviderReplayHarness } from "../testkit/ProviderReplayHarness.ts";
@@ -195,7 +195,7 @@ export function layer(input: {
const context = yield* Layer.build(layerReplay).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterOpenSessionError({
+ new ProviderAdapter.ProviderAdapterOpenSessionError({
driver: CodexAdapterV2.CODEX_DRIVER_KIND,
providerSessionId: openInput.providerSessionId,
cause,
diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
index c8b98828939..6ae159b2cc3 100644
--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
@@ -102,10 +102,9 @@ import {
} from "../../provider/Drivers/CodexHomeLayout.ts";
import {
boundProviderEventForLogging,
- type EventNdjsonLogger,
shouldPersistProviderEvent,
} from "../../provider/EventNdjsonLogger.ts";
-import { ProviderEventLoggers } from "../../provider/ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import { codexAppServerArgs, resolveCodexLaunchArgs } from "../../provider/codexLaunchArgs.ts";
import { mergeProviderInstanceEnvironment } from "@t3tools/provider-core/server/instanceEnvironment";
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
@@ -121,11 +120,7 @@ import {
type ProviderAdapterDriver,
type ProviderAdapterDriverCreateInput,
} from "@t3tools/provider-core/server/adapterDriver";
-import { IdAllocatorV2, type IdAllocatorV2Shape } from "@t3tools/provider-core/server/IdAllocator";
-import {
- type ProviderContinuationRequest,
- ProviderContinuationRequests,
-} from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { backgroundWorkNotification } from "@t3tools/provider-core/server/notification";
import {
makeProviderFailure,
@@ -137,35 +132,13 @@ import {
isProviderNativeImageAttachment,
providerMessageTextWithAttachmentPaths,
} from "@t3tools/provider-core/server/attachmentPrompt";
-import {
- ProviderAdapterEnsureThreadError,
- ProviderAdapterForkThreadError,
- ProviderAdapterInterruptError,
- ProviderAdapterOpenSessionError,
- ProviderAdapterProtocolError,
- ProviderAdapterReadThreadSnapshotError,
- ProviderAdapterResumeThreadError,
- ProviderAdapterRollbackThreadError,
- ProviderAdapterRuntimeRequestResponseError,
- ProviderAdapterSteerRunError,
- ProviderAdapterTurnStartError,
- ProviderAdapterV2,
- type ProviderAdapterV2Shape,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2ForkThreadInput,
- type ProviderAdapterV2RollbackThreadInput,
- type ProviderAdapterV2RuntimePolicy,
- type ProviderAdapterV2McpApps,
- type ProviderAdapterV2SessionRuntime,
- type ProviderAdapterV2InterruptInput,
- type ProviderAdapterV2SteerInput,
- type ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import {
makeSubagentChildThread,
makeSubagentConversationArtifacts,
subagentThreadTitle,
} from "@t3tools/provider-core/server/subagentProjection";
+import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const CODEX_PROVIDER = ProviderDriverKind.make("codex");
export const CODEX_DRIVER_KIND = CODEX_PROVIDER;
@@ -341,8 +314,11 @@ export const CodexProviderCapabilitiesV2 = {
},
} satisfies OrchestrationV2ProviderCapabilities;
-function toProtocolError(detail: string, payload?: unknown): ProviderAdapterProtocolError {
- return new ProviderAdapterProtocolError({
+function toProtocolError(
+ detail: string,
+ payload?: unknown,
+): ProviderAdapter.ProviderAdapterProtocolError {
+ return new ProviderAdapter.ProviderAdapterProtocolError({
driver: CODEX_PROVIDER,
detail,
...(payload === undefined ? {} : { payload }),
@@ -385,7 +361,7 @@ function mapCodexTurnStatus(
function providerTurnStatusToTerminal(
status: OrchestrationV2ProviderTurn["status"],
-): Extract<ProviderAdapterV2Event, { type: "turn.terminal" }>["status"] {
+): Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }>["status"] {
switch (status) {
case "completed":
return "completed";
@@ -677,7 +653,7 @@ const decodeCodexTurnStartParamsWithCollaborationMode = Schema.decodeUnknownEffe
CodexTurnStartParamsWithCollaborationMode,
);
const isProviderAdapterRuntimeRequestResponseError = Schema.is(
- ProviderAdapterRuntimeRequestResponseError,
+ ProviderAdapter.ProviderAdapterRuntimeRequestResponseError,
);
function codexRuntimeModeTurnDefaults(runtimeMode: RuntimeMode): {
@@ -724,7 +700,7 @@ function codexRuntimeModeTurnDefaults(runtimeMode: RuntimeMode): {
export function buildCodexTurnStartParams(input: {
readonly nativeThreadId: string;
readonly codexInput: ReadonlyArray<CodexSchema.V2TurnStartParams__UserInput>;
- readonly runtimePolicy: ProviderAdapterV2RuntimePolicy;
+ readonly runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
readonly modelSelection: ModelSelection;
readonly hasT3Mcp?: boolean;
readonly browserToolsAvailable?: boolean;
@@ -732,7 +708,7 @@ export function buildCodexTurnStartParams(input: {
/** ChatGPT token sharing does not accept service tiers. */
readonly omitServiceTier?: boolean;
/** What the thread's MCP Apps want the agent to know (`ui/update-model-context`). */
- readonly appContext?: ProviderAdapterV2TurnInput["appContext"];
+ readonly appContext?: ProviderAdapter.ProviderAdapterV2TurnInput["appContext"];
}) {
return Effect.gen(function* () {
const runtimeModeDefaults = codexRuntimeModeTurnDefaults(input.runtimePolicy.runtimeMode);
@@ -851,7 +827,7 @@ function getNativeThreadId(providerThread: OrchestrationV2ProviderThread) {
function providerThreadFromCodexThread(input: {
readonly appThreadId: ThreadId | null;
- readonly idAllocator: IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly ownerNodeId: OrchestrationV2ProviderThread["ownerNodeId"];
readonly providerSessionId: OrchestrationV2ProviderThread["providerSessionId"];
readonly providerInstanceId: ProviderInstanceId;
@@ -983,7 +959,7 @@ const countTerminalTurnsAfterBoundary = (
};
const resolveCodexForkRollbackTurnCount = Effect.fn("CodexAdapterV2.resolveForkRollbackTurnCount")(
- function* (input: ProviderAdapterV2ForkThreadInput) {
+ function* (input: ProviderAdapter.ProviderAdapterV2ForkThreadInput) {
if (input.providerTurnId === undefined || input.sourceProviderTurns === undefined) {
return 0;
}
@@ -993,7 +969,7 @@ const resolveCodexForkRollbackTurnCount = Effect.fn("CodexAdapterV2.resolveForkR
input.providerTurnId,
);
if (rollbackTurnCount === null) {
- return yield* new ProviderAdapterForkThreadError({
+ return yield* new ProviderAdapter.ProviderAdapterForkThreadError({
driver: CODEX_PROVIDER,
providerThreadId: input.sourceProviderThread.id,
cause: `Cannot fork Codex thread from provider turn ${input.providerTurnId}: source turn was not found in provider thread ${input.sourceProviderThread.id}.`,
@@ -1012,7 +988,7 @@ const resolveCodexForkRollbackTurnCount = Effect.fn("CodexAdapterV2.resolveForkR
* only for source turns that predate native turn references.
*/
export const resolveCodexForkBoundary = Effect.fn("CodexAdapterV2.resolveForkBoundary")(function* (
- input: ProviderAdapterV2ForkThreadInput,
+ input: ProviderAdapter.ProviderAdapterV2ForkThreadInput,
) {
const rollbackTurnCount = yield* resolveCodexForkRollbackTurnCount(input);
if (input.providerTurnId === undefined || input.sourceProviderTurns === undefined) {
@@ -1066,14 +1042,14 @@ const readCodexThreadHistoryMetadata = Effect.fn("CodexAdapterV2.readThreadHisto
);
export const resolveCodexRollbackTurnCount = Effect.fn("CodexAdapterV2.resolveRollbackTurnCount")(
- function* (input: ProviderAdapterV2RollbackThreadInput) {
+ function* (input: ProviderAdapter.ProviderAdapterV2RollbackThreadInput) {
const providerTurns = input.providerThreadTurns;
switch (input.target.type) {
case "thread_start":
return providerTurns.filter(isTerminalProviderTurn).length;
case "provider_turn": {
if (input.target.providerTurn.providerThreadId !== input.providerThread.id) {
- return yield* new ProviderAdapterRollbackThreadError({
+ return yield* new ProviderAdapter.ProviderAdapterRollbackThreadError({
driver: CODEX_PROVIDER,
providerThreadId: input.providerThread.id,
cause: `Cannot roll back Codex thread ${input.providerThread.id} to provider turn ${input.target.providerTurn.id}: target turn belongs to provider thread ${input.target.providerTurn.providerThreadId}.`,
@@ -1085,7 +1061,7 @@ export const resolveCodexRollbackTurnCount = Effect.fn("CodexAdapterV2.resolveRo
input.target.providerTurn.id,
);
if (rollbackTurnCount === null) {
- return yield* new ProviderAdapterRollbackThreadError({
+ return yield* new ProviderAdapter.ProviderAdapterRollbackThreadError({
driver: CODEX_PROVIDER,
providerThreadId: input.providerThread.id,
cause: `Cannot roll back Codex thread ${input.providerThread.id} to provider turn ${input.target.providerTurn.id}: target turn was not found in durable provider turn history.`,
@@ -1129,10 +1105,10 @@ interface ActiveCodexTurnContext {
readonly failure: OrchestrationV2ProviderFailure;
};
readonly nativeStartReady?: Deferred.Deferred<void>;
- readonly input: ProviderAdapterV2TurnInput;
+ readonly input: ProviderAdapter.ProviderAdapterV2TurnInput;
readonly projectionAppThread: OrchestrationV2AppThread;
readonly projectionThreadId: ThreadId;
- readonly projectionRunId: ProviderAdapterV2TurnInput["runId"] | null;
+ readonly projectionRunId: ProviderAdapter.ProviderAdapterV2TurnInput["runId"] | null;
readonly nativeTurnId: string;
readonly providerThread: OrchestrationV2ProviderThread;
readonly providerTurnId: ProviderTurnId;
@@ -1177,7 +1153,10 @@ function isPersistentCodexDynamicTool(item: CodexDynamicToolItem): boolean {
return Reflect.get(input, "persistent") === true;
}
-type CodexRootTerminalEvent = Extract<ProviderAdapterV2Event, { readonly type: "turn.terminal" }>;
+type CodexRootTerminalEvent = Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { readonly type: "turn.terminal" }
+>;
/** A completed root turn whose run stays open for the goal turn Codex starts next. */
interface CodexGoalHold {
@@ -1294,12 +1273,12 @@ export interface CodexAppServerClientFactoryShape {
readonly instanceId: ProviderInstanceId;
readonly threadId: ThreadId;
readonly providerSessionId: OrchestrationV2ProviderSession["id"];
- readonly runtimePolicy: ProviderAdapterV2RuntimePolicy;
+ readonly runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
readonly settings: CodexSettings;
readonly environment: NodeJS.ProcessEnv;
}) => Effect.Effect<
CodexClient.CodexAppServerClient["Service"],
- ProviderAdapterOpenSessionError,
+ ProviderAdapter.ProviderAdapterOpenSessionError,
Scope.Scope
>;
}
@@ -1319,7 +1298,7 @@ export const CODEX_THREAD_CONFIG = { "tools.update_plan.enabled": true } as cons
export function codexThreadRuntimeParams(input: {
readonly threadId: ThreadId | null;
readonly modelSelection?: { readonly model: string };
- readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
+ readonly runtimePolicy?: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
}): {
readonly cwd?: string;
readonly model?: string;
@@ -1417,7 +1396,7 @@ const layerCodexAppServerClientFactoryCommand = (
Effect.provideService(Scope.Scope, scope),
Effect.mapError(
(cause) =>
- new ProviderAdapterOpenSessionError({
+ new ProviderAdapter.ProviderAdapterOpenSessionError({
driver: CODEX_PROVIDER,
providerSessionId: input.providerSessionId,
cause,
@@ -1434,7 +1413,7 @@ const layerCodexAppServerClientFactoryCommand = (
);
export function makeCodexAppServerProtocolLogger(input: {
- readonly nativeEventLogger: EventNdjsonLogger | undefined;
+ readonly nativeEventLogger: ProviderEventLoggers.EventNdjsonLogger | undefined;
readonly threadId: ThreadId;
readonly providerSessionId: OrchestrationV2ProviderSession["id"];
}): CodexClient.CodexAppServerClientOptions["logger"] | undefined {
@@ -1510,12 +1489,12 @@ function isSensitiveCodexProtocolKey(key: string): boolean {
export const layerAppServerClientFactory: Layer.Layer<
CodexAppServerClientFactory,
never,
- ChildProcessSpawner.ChildProcessSpawner | ProviderEventLoggers
+ ChildProcessSpawner.ChildProcessSpawner | ProviderEventLoggers.ProviderEventLoggers
> = Layer.effect(
CodexAppServerClientFactory,
Effect.gen(function* () {
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
- const { native: nativeEventLogger } = yield* ProviderEventLoggers;
+ const { native: nativeEventLogger } = yield* ProviderEventLoggers.ProviderEventLoggers;
return CodexAppServerClientFactory.of({
open: (input) =>
@@ -1536,7 +1515,7 @@ export const layerAppServerClientFactory: Layer.Layer<
Effect.provideService(Scope.Scope, scope),
Effect.mapError(
(cause) =>
- new ProviderAdapterOpenSessionError({
+ new ProviderAdapter.ProviderAdapterOpenSessionError({
driver: CODEX_PROVIDER,
providerSessionId: input.providerSessionId,
cause,
@@ -1569,7 +1548,7 @@ export type CodexAdapterV2DriverEnv =
| CodexAppServerClientFactory
| Crypto.Crypto
| FileSystem.FileSystem
- | IdAllocatorV2
+ | IdAllocator.IdAllocatorV2
| Path.Path
| ServerConfig;
@@ -1579,11 +1558,11 @@ export const createCodexAdapterV2 = (
) =>
Effect.gen(function* () {
const clientFactory = yield* CodexAppServerClientFactory;
- const continuationRequests = yield* ProviderContinuationRequests;
+ const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
const crypto = yield* Crypto.Crypto;
const fileSystem = yield* FileSystem.FileSystem;
const hostEnvironment = yield* HostProcessEnvironment;
- const idAllocator = yield* IdAllocatorV2;
+ const idAllocator = yield* IdAllocator.IdAllocatorV2;
const serverConfig = yield* ServerConfig;
const homeLayout = yield* resolveCodexHomeLayout(config);
@@ -1628,18 +1607,22 @@ export const CodexAdapterV2Driver: ProviderAdapterDriver<CodexSettings, CodexAda
};
const layer: Layer.Layer<
- ProviderAdapterV2,
+ ProviderAdapter.ProviderAdapterV2,
never,
- CodexAppServerClientFactory | Crypto.Crypto | FileSystem.FileSystem | IdAllocatorV2 | ServerConfig
+ | CodexAppServerClientFactory
+ | Crypto.Crypto
+ | FileSystem.FileSystem
+ | IdAllocator.IdAllocatorV2
+ | ServerConfig
> = Layer.effect(
- ProviderAdapterV2,
+ ProviderAdapter.ProviderAdapterV2,
Effect.gen(function* () {
const clientFactory = yield* CodexAppServerClientFactory;
- const continuationRequests = yield* ProviderContinuationRequests;
+ const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
const crypto = yield* Crypto.Crypto;
const fileSystem = yield* FileSystem.FileSystem;
const hostEnvironment = yield* HostProcessEnvironment;
- const idAllocator = yield* IdAllocatorV2;
+ const idAllocator = yield* IdAllocator.IdAllocatorV2;
const serverConfig = yield* ServerConfig;
return makeCodexAdapterV2({
@@ -1670,7 +1653,7 @@ export interface CodexAdapterV2Options {
readonly resolveRuntime?: Effect.Effect<CodexEffectiveRuntime, ProviderSetupError, Scope.Scope>;
readonly crypto: Crypto.Crypto;
readonly fileSystem: FileSystem.FileSystem;
- readonly idAllocator: IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly serverConfig: ServerConfig["Service"];
/**
* Sink for post-settle background command completions so the orchestrator
@@ -1678,15 +1661,19 @@ export interface CodexAdapterV2Options {
* projection-only handling for late item completions.
*/
readonly continuationRequests?: {
- readonly offer: (request: ProviderContinuationRequest) => Effect.Effect<void>;
+ readonly offer: (
+ request: ProviderContinuationRequests.ProviderContinuationRequest,
+ ) => Effect.Effect<void>;
};
}
-export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): ProviderAdapterV2Shape {
+export function makeCodexAdapterV2(
+ adapterOptions: CodexAdapterV2Options,
+): ProviderAdapter.ProviderAdapterV2["Service"] {
const { clientFactory, crypto, fileSystem, idAllocator, serverConfig } = adapterOptions;
const continuationRequests = adapterOptions.continuationRequests;
- return ProviderAdapterV2.of({
+ return ProviderAdapter.ProviderAdapterV2.of({
instanceId: adapterOptions.instanceId,
driver: CODEX_PROVIDER,
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
@@ -1700,7 +1687,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
: yield* adapterOptions.resolveRuntime.pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterOpenSessionError({
+ new ProviderAdapter.ProviderAdapterOpenSessionError({
driver: CODEX_PROVIDER,
providerSessionId: input.providerSessionId,
cause,
@@ -1800,7 +1787,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
model: input.modelSelection.model,
now,
});
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
const rateLimitSnapshot = yield* Ref.make<CodexRateLimitSnapshot | undefined>(undefined);
const limitedTurnItems = yield* Ref.make(
new Map<ProviderThreadId, Extract<OrchestrationV2TurnItem, { type: "error" }>>(),
@@ -1833,7 +1820,9 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
context.nativeTurnId,
).hasSubagents = true;
};
- const pendingRootTurns = yield* Ref.make(new Map<string, ProviderAdapterV2TurnInput>());
+ const pendingRootTurns = yield* Ref.make(
+ new Map<string, ProviderAdapter.ProviderAdapterV2TurnInput>(),
+ );
const turnWaiters = yield* Ref.make(new Map<string, Deferred.Deferred<void, never>>());
const subagentThreads = yield* Ref.make(new Map<string, CodexSubagentThreadContext>());
const subagentSelections = new Map<string, Omit<ModelSelection, "instanceId">>();
@@ -1893,7 +1882,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
const latestGoalTurnId = (providerTurnId: ProviderTurnId) =>
goalRuns.get(providerTurnId)?.at(-1)?.providerTurnId ?? providerTurnId;
- const emitProviderEvent = (event: ProviderAdapterV2Event) =>
+ const emitProviderEvent = (event: ProviderAdapter.ProviderAdapterV2Event) =>
Queue.offer(events, event).pipe(Effect.asVoid);
/** Writes the thread's current native goal onto its root provider thread. */
@@ -1942,7 +1931,6 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
type: "turn_item.updated",
driver: CODEX_PROVIDER,
turnItem: makeProviderRetryTurnItem({
- idAllocator,
driver: CODEX_PROVIDER,
threadId: context.projectionThreadId,
runId: context.projectionRunId,
@@ -1960,7 +1948,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
});
const registerRootTurn = (input: {
- readonly turnInput: ProviderAdapterV2TurnInput;
+ readonly turnInput: ProviderAdapter.ProviderAdapterV2TurnInput;
readonly nativeTurnId: string;
readonly startedAt: DateTime.Utc;
readonly waitForNativeStart?: boolean;
@@ -3143,7 +3131,11 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
});
const toCodexInput = (
- turnInput: Pick<ProviderAdapterV2TurnInput | ProviderAdapterV2SteerInput, "message">,
+ turnInput: Pick<
+ | ProviderAdapter.ProviderAdapterV2TurnInput
+ | ProviderAdapter.ProviderAdapterV2SteerInput,
+ "message"
+ >,
) =>
Effect.gen(function* () {
const inputItems: Array<CodexSchema.V2TurnStartParams__UserInput> = [];
@@ -4539,7 +4531,6 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
type: "turn_item.updated",
driver: CODEX_PROVIDER,
turnItem: makeProviderRetryTurnItem({
- idAllocator,
driver: CODEX_PROVIDER,
threadId: context.projectionThreadId,
runId: context.projectionRunId,
@@ -5584,7 +5575,6 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}
if (current.status === "failed" && current.failure.class === "usage_limit") {
const item = makeProviderFailureTurnItem({
- idAllocator,
driver: CODEX_PROVIDER,
threadId: context.input.threadId,
runId: context.input.runId,
@@ -5735,7 +5725,6 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
type: "turn_item.updated",
driver: CODEX_PROVIDER,
turnItem: makeProviderRetryTurnItem({
- idAllocator,
driver: CODEX_PROVIDER,
threadId: input.context.projectionThreadId,
runId: input.context.projectionRunId,
@@ -6000,7 +5989,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
* assistant text, as Claude's own `/goal` output is.
*/
const completeGoalCommandTurn = Effect.fnUntraced(function* (
- turnInput: ProviderAdapterV2TurnInput,
+ turnInput: ProviderAdapter.ProviderAdapterV2TurnInput,
reply: string,
) {
const now = yield* DateTime.now;
@@ -6104,7 +6093,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
* Stop also reaches.
*/
const resolveGoalStopTarget = Effect.fnUntraced(function* (
- turnInput: ProviderAdapterV2InterruptInput,
+ turnInput: ProviderAdapter.ProviderAdapterV2InterruptInput,
) {
const goalThreadId = turnInput.providerThread.nativeThreadRef?.nativeId;
if (goalThreadId == null) {
@@ -6172,7 +6161,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
/** Starts a native turn with this run's full turn configuration. */
const startNativeTurn = (
- turnInput: ProviderAdapterV2TurnInput,
+ turnInput: ProviderAdapter.ProviderAdapterV2TurnInput,
codexInput: ReadonlyArray<CodexSchema.V2TurnStartParams__UserInput>,
) =>
Effect.gen(function* () {
@@ -6227,7 +6216,10 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
* turn Codex starts on its own reuses the last turn's settings. Codex
* continues later goal turns itself. Other commands settle with a reply.
*/
- const runGoalCommand = (turnInput: ProviderAdapterV2TurnInput, command: CodexGoalCommand) =>
+ const runGoalCommand = (
+ turnInput: ProviderAdapter.ProviderAdapterV2TurnInput,
+ command: CodexGoalCommand,
+ ) =>
Effect.gen(function* () {
const threadId = yield* getNativeThreadId(turnInput.providerThread);
// Goal notifications during the command belong to this run's snapshot.
@@ -6326,7 +6318,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterTurnStartError({
+ new ProviderAdapter.ProviderAdapterTurnStartError({
driver: CODEX_PROVIDER,
threadId: turnInput.threadId,
providerThreadId: turnInput.providerThread.id,
@@ -6339,8 +6331,12 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
// MCP Apps reach their server through Codex's own MCP client, so any
// server the user configured for Codex works without T3 connecting to it.
const mcpAppsError = (detail: string) => (cause: unknown) =>
- new ProviderAdapterProtocolError({ driver: CODEX_PROVIDER, detail, payload: cause });
- const mcpApps: ProviderAdapterV2McpApps = {
+ new ProviderAdapter.ProviderAdapterProtocolError({
+ driver: CODEX_PROVIDER,
+ detail,
+ payload: cause,
+ });
+ const mcpApps: ProviderAdapter.ProviderAdapterV2McpApps = {
listTools: (toolsInput) =>
Effect.gen(function* () {
const threadId = yield* getNativeThreadId(toolsInput.providerThread);
@@ -6394,7 +6390,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(Effect.mapError(mcpAppsError("Codex MCP resource read failed."))),
};
- const runtime: ProviderAdapterV2SessionRuntime = {
+ const runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime = {
instanceId: adapterOptions.instanceId,
driver: CODEX_PROVIDER,
providerSessionId: input.providerSessionId,
@@ -6471,7 +6467,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
),
Effect.mapError(
(cause) =>
- new ProviderAdapterEnsureThreadError({
+ new ProviderAdapter.ProviderAdapterEnsureThreadError({
driver: CODEX_PROVIDER,
threadId: threadInput.threadId,
cause: normalizeCodexCause(cause),
@@ -6535,7 +6531,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterResumeThreadError({
+ new ProviderAdapter.ProviderAdapterResumeThreadError({
driver: CODEX_PROVIDER,
providerSessionId: input.providerSessionId,
providerThreadId: threadInput.providerThread.id,
@@ -6563,7 +6559,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterTurnStartError({
+ new ProviderAdapter.ProviderAdapterTurnStartError({
driver: CODEX_PROVIDER,
threadId: turnInput.threadId,
providerThreadId: turnInput.providerThread.id,
@@ -6593,7 +6589,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterProtocolError({
+ new ProviderAdapter.ProviderAdapterProtocolError({
driver: CODEX_PROVIDER,
detail: "Failed to inject historical context",
cause,
@@ -6617,7 +6613,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterTurnStartError({
+ new ProviderAdapter.ProviderAdapterTurnStartError({
driver: CODEX_PROVIDER,
threadId: turnInput.threadId,
providerThreadId: turnInput.providerThread.id,
@@ -6655,7 +6651,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterSteerRunError({
+ new ProviderAdapter.ProviderAdapterSteerRunError({
driver: CODEX_PROVIDER,
providerThreadId: turnInput.providerThread.id,
providerTurnId: turnInput.providerTurnId,
@@ -6674,7 +6670,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
Effect.mapError((cause) =>
cause._tag === "ProviderAdapterProtocolError"
? cause
- : new ProviderAdapterProtocolError({
+ : new ProviderAdapter.ProviderAdapterProtocolError({
driver: CODEX_PROVIDER,
detail: `Failed to unload Codex thread for provider thread ${unloadInput.providerThread.id}`,
cause: normalizeCodexCause(cause),
@@ -7061,7 +7057,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterInterruptError({
+ new ProviderAdapter.ProviderAdapterInterruptError({
driver: CODEX_PROVIDER,
providerThreadId: requestedInput.providerThread.id,
providerTurnId: requestedInput.providerTurnId,
@@ -7075,7 +7071,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
String(requestInput.requestId),
);
if (pending === undefined) {
- return yield* new ProviderAdapterRuntimeRequestResponseError({
+ return yield* new ProviderAdapter.ProviderAdapterRuntimeRequestResponseError({
driver: CODEX_PROVIDER,
requestId: requestInput.requestId,
cause: toProtocolError(
@@ -7085,7 +7081,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}
if (pending.type === "user_input") {
if (requestInput.answers === undefined) {
- return yield* new ProviderAdapterRuntimeRequestResponseError({
+ return yield* new ProviderAdapter.ProviderAdapterRuntimeRequestResponseError({
driver: CODEX_PROVIDER,
requestId: requestInput.requestId,
cause: toProtocolError(
@@ -7097,7 +7093,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
return;
}
if (requestInput.decision === undefined) {
- return yield* new ProviderAdapterRuntimeRequestResponseError({
+ return yield* new ProviderAdapter.ProviderAdapterRuntimeRequestResponseError({
driver: CODEX_PROVIDER,
requestId: requestInput.requestId,
cause: toProtocolError(
@@ -7110,7 +7106,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
Effect.mapError((cause) =>
isProviderAdapterRuntimeRequestResponseError(cause)
? cause
- : new ProviderAdapterRuntimeRequestResponseError({
+ : new ProviderAdapter.ProviderAdapterRuntimeRequestResponseError({
driver: CODEX_PROVIDER,
requestId: requestInput.requestId,
cause,
@@ -7134,7 +7130,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterProtocolError({
+ new ProviderAdapter.ProviderAdapterProtocolError({
driver: CODEX_PROVIDER,
detail: "Failed to upload Codex thread feedback.",
payload: cause,
@@ -7167,7 +7163,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterReadThreadSnapshotError({
+ new ProviderAdapter.ProviderAdapterReadThreadSnapshotError({
driver: CODEX_PROVIDER,
providerThreadId: threadInput.providerThread.id,
cause,
@@ -7200,7 +7196,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
Effect.andThen(readCodexThreadHistoryMetadata(client.raw, threadId)),
);
if (historyMode !== "paginated") {
- return yield* new ProviderAdapterRollbackThreadError({
+ return yield* new ProviderAdapter.ProviderAdapterRollbackThreadError({
driver: CODEX_PROVIDER,
providerThreadId: threadInput.providerThread.id,
cause: `Cannot roll back Codex thread ${threadId}: the thread uses legacy history, which Codex 0.156 cannot revert.`,
@@ -7244,7 +7240,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterRollbackThreadError({
+ new ProviderAdapter.ProviderAdapterRollbackThreadError({
driver: CODEX_PROVIDER,
providerThreadId: threadInput.providerThread.id,
cause: normalizeCodexCause(cause),
@@ -7275,7 +7271,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
),
Effect.mapError(
(cause) =>
- new ProviderAdapterForkThreadError({
+ new ProviderAdapter.ProviderAdapterForkThreadError({
driver: CODEX_PROVIDER,
providerThreadId: threadInput.sourceProviderThread.id,
cause: normalizeCodexCause(cause),
@@ -7291,7 +7287,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
Effect.andThen(readCodexThreadHistoryMetadata(client.raw, response.thread.id)),
);
if (historyMode !== "paginated") {
- return yield* new ProviderAdapterForkThreadError({
+ return yield* new ProviderAdapter.ProviderAdapterForkThreadError({
driver: CODEX_PROVIDER,
providerThreadId: threadInput.sourceProviderThread.id,
cause: `Cannot fork Codex thread ${threadId} at provider turn ${threadInput.providerTurnId}: the source turn has no native Codex turn reference, and the forked thread uses legacy history which Codex 0.156 cannot revert.`,
@@ -7303,7 +7299,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
),
Effect.mapError(
(cause) =>
- new ProviderAdapterForkThreadError({
+ new ProviderAdapter.ProviderAdapterForkThreadError({
driver: CODEX_PROVIDER,
providerThreadId: threadInput.sourceProviderThread.id,
cause: normalizeCodexCause(cause),
@@ -7328,7 +7324,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterForkThreadError({
+ new ProviderAdapter.ProviderAdapterForkThreadError({
driver: CODEX_PROVIDER,
providerThreadId: threadInput.sourceProviderThread.id,
cause: normalizeCodexCause(cause),
@@ -7340,7 +7336,7 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}).pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterOpenSessionError({
+ new ProviderAdapter.ProviderAdapterOpenSessionError({
driver: CODEX_PROVIDER,
providerSessionId: input.providerSessionId,
cause,
diff --git a/apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.testkit.ts
index 3f2f6581f90..fa347db3478 100644
--- a/apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.testkit.ts
+++ b/apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.testkit.ts
@@ -28,7 +28,7 @@ import {
cursorSdkModelSelection,
makeCursorAgentOptions,
} from "@t3tools/provider-cursor/testing";
-import type { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import type { RuntimePolicyV2Override } from "../RuntimePolicy.ts";
const CursorAgentSdkReplayTranscript = Schema.Struct({
@@ -625,7 +625,7 @@ function recordingRuntimePolicy(input: {
readonly cwd: string;
readonly interactionMode: "default" | "plan";
readonly override?: Pick<RuntimePolicyV2Override, "approvalPolicy" | "sandboxPolicy">;
-}): ProviderAdapterV2RuntimePolicy {
+}): ProviderAdapter.ProviderAdapterV2RuntimePolicy {
return {
runtimeMode: "full-access",
interactionMode: input.interactionMode,
diff --git a/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts
index a21f16853b9..960d29beb4e 100644
--- a/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts
@@ -26,7 +26,7 @@ import { buildInitialGrokProviderSnapshot } from "@t3tools/provider-grok/testing
import type { ProviderInstance } from "@t3tools/provider-core/server/driver";
import * as ProviderInstanceRegistry from "../../provider/ProviderInstanceRegistry.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as RuntimePolicy from "../RuntimePolicy.ts";
import { acpPermissionDisposition } from "@t3tools/provider-acp/server/clientPolicy";
import {
@@ -68,7 +68,7 @@ function runtimePolicy(input: {
readonly approvalPolicy?: unknown;
readonly sandboxPolicy?: unknown;
}) {
- return ProviderAdapterV2RuntimePolicy.make({
+ return ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: input.runtimeMode,
interactionMode: "default",
cwd: "/workspace",
@@ -314,7 +314,7 @@ describe("Grok launch permission mode", () => {
// Opens a session through the adapter's own Grok runtime factory and returns
// the argv it tried to launch. The spawn fails after recording, so no
// process starts.
- const launchArgs = (runtimePolicy: ProviderAdapterV2RuntimePolicy) =>
+ const launchArgs = (runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy) =>
Effect.gen(function* () {
const launches: Array<ReadonlyArray<string>> = [];
const childProcessSpawner = ChildProcessSpawner.make((command) => {
@@ -352,9 +352,9 @@ describe("Grok launch permission mode", () => {
const policy = (
runtimeMode: RuntimeMode,
- override: Partial<ProviderAdapterV2RuntimePolicy> = {},
+ override: Partial<ProviderAdapter.ProviderAdapterV2RuntimePolicy> = {},
) =>
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode,
interactionMode: "default",
cwd: process.cwd(),
diff --git a/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts
index 37de61f072c..467ad620d53 100644
--- a/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts
+++ b/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts
@@ -13,7 +13,7 @@ import { layerTestProviderHost } from "@t3tools/provider-testing/host";
import { GROK_ACP_CANCEL_META, GROK_ACP_INITIALIZE_META } from "@t3tools/provider-grok/testing";
import { makeXAiPromptCompletionRuntime } from "@t3tools/provider-grok/testing";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import type { ProviderReplayGate } from "@t3tools/provider-testing/replayGate";
import type { OrchestratorV2ProviderReplayHarness } from "../testkit/ProviderReplayHarness.ts";
diff --git a/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts
index 1d10bb8e50e..b695b39fa8d 100644
--- a/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts
+++ b/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts
@@ -36,7 +36,7 @@ import {
} from "@t3tools/provider-muse/testing";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import type { OrchestratorV2ProviderReplayHarness } from "../testkit/ProviderReplayHarness.ts";
import { makeMuseAdapterV2 } from "@t3tools/provider-muse/server";
diff --git a/apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
index ff87c347641..789ed7e7785 100644
--- a/apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
@@ -38,14 +38,10 @@ import * as Exit from "effect/Exit";
import { TestClock } from "effect/testing";
import { describe } from "vite-plus/test";
-import type {
- ProviderAdapterV2Event,
- ProviderAdapterV2SessionRuntime,
-} from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import type { ProviderContinuationRequest } from "@t3tools/provider-core/server/continuationRequests";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import {
OPENCODE_2_STILL_STOPPING,
OPENCODE_PROVIDER,
@@ -347,21 +343,27 @@ const resumed = (
return { runtime, thread };
});
-const requestOf = (runtime: ProviderAdapterV2SessionRuntime) =>
+const requestOf = (runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime) =>
runtime.events.pipe(
Stream.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "runtime_request.updated" }> =>
- event.type === "runtime_request.updated",
+ (
+ event,
+ ): event is Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { type: "runtime_request.updated" }
+ > => event.type === "runtime_request.updated",
),
Stream.map((event) => event.runtimeRequest),
Stream.runHead,
Effect.map(Option.getOrUndefined),
);
-const terminalOf = (runtime: ProviderAdapterV2SessionRuntime) =>
+const terminalOf = (runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime) =>
runtime.events.pipe(
Stream.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn.terminal" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }> =>
event.type === "turn.terminal",
),
Stream.runHead,
@@ -637,7 +639,7 @@ describe("OpenCode2 adapter", () => {
* The single reader of the runtime's events: resolves `attached` once the
* running background child has its thread, then returns the turn's terminal.
*/
- const watchBackgroundTurn = (runtime: ProviderAdapterV2SessionRuntime) =>
+ const watchBackgroundTurn = (runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime) =>
Effect.gen(function* () {
const attached = yield* Deferred.make<void>();
const terminal = yield* runtime.events.pipe(
@@ -647,7 +649,9 @@ describe("OpenCode2 adapter", () => {
: Effect.void,
),
Stream.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn.terminal" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }> =>
event.type === "turn.terminal",
),
Stream.runHead,
@@ -767,7 +771,9 @@ describe("OpenCode2 adapter", () => {
: Effect.void,
),
Stream.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn.terminal" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }> =>
event.type === "turn.terminal",
),
Stream.runHead,
@@ -809,7 +815,9 @@ describe("OpenCode2 adapter", () => {
const firstEnded = yield* Deferred.make<void>();
const ended = yield* runtime.events.pipe(
Stream.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn.terminal" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }> =>
event.type === "turn.terminal",
),
Stream.tap(() => Deferred.succeed(firstEnded, undefined)),
@@ -1110,7 +1118,7 @@ describe("OpenCode2 adapter", () => {
event("session.execution.succeeded", { sessionID: SESSION }),
];
/** The runtime's events, with the background subagent's statuses and the middle session's turns. */
- const watchNested = (runtime: ProviderAdapterV2SessionRuntime) =>
+ const watchNested = (runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime) =>
Effect.gen(function* () {
const deep: Array<string> = [];
const middleTurns = new Map<string, string>();
@@ -1325,7 +1333,7 @@ describe("OpenCode2 adapter", () => {
attemptId: RunAttemptId.make("attempt:opencode2-adapter:2"),
});
const stopFirstTurn = (
- runtime: ProviderAdapterV2SessionRuntime,
+ runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime,
thread: OrchestrationV2ProviderThread,
) =>
Effect.gen(function* () {
@@ -1336,10 +1344,12 @@ describe("OpenCode2 adapter", () => {
yield* TestClock.adjust("11 seconds");
yield* Fiber.join(interrupt);
});
- const terminals = (runtime: ProviderAdapterV2SessionRuntime, count: number) =>
+ const terminals = (runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime, count: number) =>
runtime.events.pipe(
Stream.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn.terminal" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }> =>
event.type === "turn.terminal",
),
Stream.take(count),
@@ -2113,7 +2123,9 @@ describe("OpenCode2 adapter", () => {
}),
),
Stream.filter(
- (event): event is Extract<ProviderAdapterV2Event, { type: "turn.terminal" }> =>
+ (
+ event,
+ ): event is Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn.terminal" }> =>
event.type === "turn.terminal",
),
Stream.tap(() => Deferred.succeed(firstEnded, undefined)),
@@ -2331,7 +2343,7 @@ describe("OpenCode2 adapter", () => {
replyData("session.form.list", forms),
];
- const turnItems = (collected: ReadonlyArray<ProviderAdapterV2Event>) =>
+ const turnItems = (collected: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>) =>
collected.flatMap((event) =>
event.type === "turn_item.updated" ? [`${event.turnItem.type}:${event.turnItem.status}`] : [],
);
@@ -3043,7 +3055,7 @@ describe("OpenCode2 adapter", () => {
Effect.gen(function* () {
const kept = "msg_t3_turn_run-attempt:kept:1";
const dropped = "msg_t3_turn_run-attempt:dropped:1";
- const offers: Array<ProviderContinuationRequest> = [];
+ const offers: Array<ProviderContinuationRequests.ProviderContinuationRequest> = [];
const { runtime, thread } = yield* resumed([
out("message.list", "<any>"),
reply("message.list", {
@@ -3727,7 +3739,7 @@ describe("OpenCode2 adapter", () => {
*/
const continued = (after: ReadonlyArray<ProviderReplayEntry>) =>
Effect.gen(function* () {
- const offers: Array<ProviderContinuationRequest> = [];
+ const offers: Array<ProviderContinuationRequests.ProviderContinuationRequest> = [];
const { runtime, thread } = yield* resumed([
...backgroundLaunch(CHILD),
event("session.execution.succeeded", { sessionID: SESSION }),
@@ -3867,7 +3879,7 @@ describe("OpenCode2 adapter", () => {
Effect.gen(function* () {
const reportText = `<subagent sessionID="${CHILD}" state="completed" description="Sleep">\nCHILD_OK\n</subagent>`;
const steerId = `msg_t3_steer_${SESSION}:message:opencode2-adapter:steer`;
- const offers: Array<ProviderContinuationRequest> = [];
+ const offers: Array<ProviderContinuationRequests.ProviderContinuationRequest> = [];
const { runtime, thread } = yield* resumed([
...backgroundLaunch(CHILD),
event("session.execution.succeeded", { sessionID: SESSION }),
diff --git a/apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.testkit.ts
index 36d0e35ddce..5c982997a92 100644
--- a/apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.testkit.ts
+++ b/apps/server/src/orchestration-v2/Adapters/OpenCodeAdapterV2.testkit.ts
@@ -9,7 +9,7 @@ import * as Schema from "effect/Schema";
import { OpenCodeAdapterV2Driver } from "@t3tools/provider-opencode/server";
import * as OpenCodeRuntime from "@t3tools/provider-opencode/server/OpenCodeRuntime";
import { layerTestProviderHost } from "@t3tools/provider-testing/host";
-import * as ProviderEventLoggers from "../../provider/ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import { ProviderAdapterDriverCreateError } from "@t3tools/provider-core/server/adapterDriver";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
diff --git a/apps/server/src/orchestration-v2/BackgroundWorkStop.integration.test.ts b/apps/server/src/orchestration-v2/BackgroundWorkStop.integration.test.ts
index 4d4950bcb4b..6d5e0b92d87 100644
--- a/apps/server/src/orchestration-v2/BackgroundWorkStop.integration.test.ts
+++ b/apps/server/src/orchestration-v2/BackgroundWorkStop.integration.test.ts
@@ -24,16 +24,11 @@ import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as EffectWorker from "./EffectWorker.ts";
import * as EventSink from "./EventSink.ts";
import * as Orchestrator from "./Orchestrator.ts";
-import type {
- ProviderAdapterV2Event,
- ProviderAdapterV2InterruptInput,
- ProviderAdapterV2Shape,
- ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const driver = ProviderDriverKind.make("codex");
const instanceId = ProviderInstanceId.make("codex");
@@ -61,10 +56,10 @@ const stopEarlierBackgroundWork = ({
Effect.scoped(
Effect.gen(function* () {
const cwd = yield* checkpointWorkspace("background-work-stop");
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
- const started: ProviderAdapterV2TurnInput[] = [];
- const interrupts: ProviderAdapterV2InterruptInput[] = [];
- const adapter: ProviderAdapterV2Shape = {
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
+ const started: ProviderAdapter.ProviderAdapterV2TurnInput[] = [];
+ const interrupts: ProviderAdapter.ProviderAdapterV2InterruptInput[] = [];
+ const adapter: ProviderAdapter.ProviderAdapterV2["Service"] = {
instanceId,
driver,
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
diff --git a/apps/server/src/orchestration-v2/CheckpointCaptureService.ts b/apps/server/src/orchestration-v2/CheckpointCaptureService.ts
index 6be935c9c23..45bf0361031 100644
--- a/apps/server/src/orchestration-v2/CheckpointCaptureService.ts
+++ b/apps/server/src/orchestration-v2/CheckpointCaptureService.ts
@@ -252,7 +252,7 @@ export const layer: Layer.Layer<
);
function makeCheckpointTurnItem(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly run: OrchestrationV2Run;
readonly rootNode: OrchestrationV2ExecutionNode;
readonly providerThread: OrchestrationV2ProviderThread;
diff --git a/apps/server/src/orchestration-v2/CheckpointRollbackService.test.ts b/apps/server/src/orchestration-v2/CheckpointRollbackService.test.ts
index 217a7369713..018b4f8f49b 100644
--- a/apps/server/src/orchestration-v2/CheckpointRollbackService.test.ts
+++ b/apps/server/src/orchestration-v2/CheckpointRollbackService.test.ts
@@ -26,7 +26,7 @@ import * as EventSink from "./EventSink.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProjectionStore from "./ProjectionStore.ts";
import * as ProjectStore from "./ProjectStore.ts";
-import type { ProviderAdapterV2RollbackThreadInput } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
import * as RuntimePolicy from "./RuntimePolicy.ts";
@@ -457,7 +457,7 @@ it.effect.each([
Layer.mock(ProviderSessionManager.ProviderSessionManagerV2)({
open: () =>
Effect.succeed({
- rollbackThread: (input: ProviderAdapterV2RollbackThreadInput) =>
+ rollbackThread: (input: ProviderAdapter.ProviderAdapterV2RollbackThreadInput) =>
Effect.gen(function* () {
const count = yield* resolveCodexRollbackTurnCount(input);
assert.equal(count, 2 - targetOrdinal);
diff --git a/apps/server/src/orchestration-v2/CheckpointRollbackService.ts b/apps/server/src/orchestration-v2/CheckpointRollbackService.ts
index f9747abe209..acacfed521c 100644
--- a/apps/server/src/orchestration-v2/CheckpointRollbackService.ts
+++ b/apps/server/src/orchestration-v2/CheckpointRollbackService.ts
@@ -20,10 +20,10 @@ import {
} from "./CheckpointRestoreSafety.ts";
import { CheckpointServiceV2 } from "./CheckpointService.ts";
import { EventSinkV2 } from "./EventSink.ts";
-import { IdAllocatorV2 } from "@t3tools/provider-core/server/IdAllocator";
+import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import { ProjectionStoreV2 } from "./ProjectionStore.ts";
import * as ProjectStore from "./ProjectStore.ts";
-import type { ProviderAdapterV2RollbackTarget } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import { ProviderSessionManagerV2 } from "./ProviderSessionManager.ts";
import { RuntimePolicyV2 } from "./RuntimePolicy.ts";
import * as ThreadCommandExecutor from "./ThreadCommandExecutor.ts";
@@ -85,7 +85,7 @@ export const layer: Layer.Layer<
never,
| CheckpointServiceV2
| EventSinkV2
- | IdAllocatorV2
+ | IdAllocator.IdAllocatorV2
| ProjectionStoreV2
| ProviderSessionManagerV2
| RuntimePolicyV2
@@ -98,7 +98,7 @@ export const layer: Layer.Layer<
Effect.gen(function* () {
const checkpoints = yield* CheckpointServiceV2;
const eventSink = yield* EventSinkV2;
- const ids = yield* IdAllocatorV2;
+ const ids = yield* IdAllocator.IdAllocatorV2;
const projections = yield* ProjectionStoreV2;
const sessions = yield* ProviderSessionManagerV2;
const runtimePolicy = yield* RuntimePolicyV2;
@@ -225,7 +225,7 @@ export const layer: Layer.Layer<
turn.providerThreadId === providerThread.id &&
(turn.runAttemptId === null || !rolledBackAttemptIds.has(turn.runAttemptId)),
);
- const rollbackTarget: ProviderAdapterV2RollbackTarget =
+ const rollbackTarget: ProviderAdapter.ProviderAdapterV2RollbackTarget =
targetOrdinal === 0
? {
type: "thread_start",
diff --git a/apps/server/src/orchestration-v2/CheckpointService.ts b/apps/server/src/orchestration-v2/CheckpointService.ts
index c0bf30311a2..913e53658e2 100644
--- a/apps/server/src/orchestration-v2/CheckpointService.ts
+++ b/apps/server/src/orchestration-v2/CheckpointService.ts
@@ -172,7 +172,7 @@ export const checkpointRefForScopeOrdinal = Effect.fn("checkpointRefForScopeOrdi
);
function checkpointIdForScopeOrdinal(
- idAllocator: IdAllocator.IdAllocatorV2Shape,
+ idAllocator: IdAllocator.IdAllocatorV2["Service"],
input: {
readonly scopeId: CheckpointScopeId;
readonly ordinalWithinScope: number;
@@ -185,7 +185,7 @@ function checkpointIdForScopeOrdinal(
}
function makeRootRunScope(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly threadId: ThreadId;
readonly runId: RunId;
readonly rootNodeId: NodeId;
diff --git a/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts b/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts
index 0335d921da3..bbab4b5fd45 100644
--- a/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts
+++ b/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts
@@ -1,4 +1,4 @@
-import type { ProviderAdapterV2HistoricalContext } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import { assert, describe, it } from "@effect/vitest";
import {
ContextHandoffId,
@@ -501,7 +501,7 @@ describe("handoff delivery", () => {
providerThread,
budget: 16_000,
alreadyDeliveredItemIds: new Set<string>(),
- inject: (value: ProviderAdapterV2HistoricalContext) =>
+ inject: (value: ProviderAdapter.ProviderAdapterV2HistoricalContext) =>
Effect.sync(() => {
history.push(...historyResponseItems(value.messages, value.context));
return true;
@@ -588,7 +588,7 @@ describe("handoff delivery", () => {
...handoff,
id: ContextHandoffId.make(`handoff:retry:${index}`),
}));
- let captured: ProviderAdapterV2HistoricalContext | undefined;
+ let captured: ProviderAdapter.ProviderAdapterV2HistoricalContext | undefined;
const result = yield* deliverContextHandoffs({
handoffs: many,
providerThread,
diff --git a/apps/server/src/orchestration-v2/ContextHandoffDelivery.ts b/apps/server/src/orchestration-v2/ContextHandoffDelivery.ts
index 534217a58a2..30f5873b9cf 100644
--- a/apps/server/src/orchestration-v2/ContextHandoffDelivery.ts
+++ b/apps/server/src/orchestration-v2/ContextHandoffDelivery.ts
@@ -2,7 +2,7 @@ import type {
OrchestrationV2ContextHandoff,
OrchestrationV2ProviderThread,
} from "@t3tools/contracts";
-import type { ProviderAdapterV2HistoricalContext } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import { ContextHandoffBudgetError } from "@t3tools/provider-core/server/failure";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
@@ -25,7 +25,7 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH
readonly deferInline?: boolean;
readonly alreadyDeliveredItemIds: ReadonlySet<string>;
readonly inject?: (
- history: ProviderAdapterV2HistoricalContext,
+ history: ProviderAdapter.ProviderAdapterV2HistoricalContext,
) => Effect.Effect<boolean, InjectError>;
readonly persist: (handoff: OrchestrationV2ContextHandoff) => Effect.Effect<void, PersistError>;
}) {
diff --git a/apps/server/src/orchestration-v2/CursorOrchestratorV2.live.test.ts b/apps/server/src/orchestration-v2/CursorOrchestratorV2.live.test.ts
index 1c74ee18d7a..044f3fd8da9 100644
--- a/apps/server/src/orchestration-v2/CursorOrchestratorV2.live.test.ts
+++ b/apps/server/src/orchestration-v2/CursorOrchestratorV2.live.test.ts
@@ -29,7 +29,7 @@ import * as CodexInstallation from "../provider/CodexInstallation.ts";
import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
import * as ModelManifest from "../provider/ModelManifest.ts";
import * as ProviderInstanceRegistryHydration from "../provider/ProviderInstanceRegistryHydration.ts";
-import * as ProviderEventLoggers from "../provider/ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as OpenCodeRuntime from "@t3tools/provider-opencode/server/OpenCodeRuntime";
import * as OpenCodeServerLedger from "@t3tools/provider-opencode/server/OpenCodeServerLedger";
import * as ServerSettings from "../serverSettings.ts";
diff --git a/apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts b/apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
index ed2ae984501..3f93674cd5d 100644
--- a/apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
+++ b/apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
@@ -36,10 +36,10 @@ import * as WorkspacePaths from "../workspace/WorkspacePaths.ts";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as EventSink from "./EventSink.ts";
import * as Orchestrator from "./Orchestrator.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import { continueRestartedRun } from "./RestartContinuation.ts";
import * as RuntimeLayer from "./runtimeLayer.ts";
import * as ProviderTurnStartServiceTestkit from "./ProviderTurnStartService.testkit.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const layerPlatformTest = Layer.merge(
NodeServices.layer,
@@ -74,7 +74,7 @@ const orchestrationAdapter = {
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
openSession: () => Effect.die("sessions are not used by delegated completion tests"),
-} as ProviderAdapterV2Shape;
+} as ProviderAdapter.ProviderAdapterV2["Service"];
const providerInstance = {
instanceId: modelSelection.instanceId,
driverKind: driver,
diff --git a/apps/server/src/orchestration-v2/DispatchModeLimit.test.ts b/apps/server/src/orchestration-v2/DispatchModeLimit.test.ts
index 044b1b66bcd..8e2fd54f06f 100644
--- a/apps/server/src/orchestration-v2/DispatchModeLimit.test.ts
+++ b/apps/server/src/orchestration-v2/DispatchModeLimit.test.ts
@@ -13,9 +13,9 @@ import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import { DispatchModeLimit } from "./DispatchModeLimit.ts";
import * as Orchestrator from "./Orchestrator.ts";
import * as ProjectionStore from "./ProjectionStore.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const instanceId = ProviderInstanceId.make("codex");
const adapter = {
@@ -24,7 +24,7 @@ const adapter = {
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" as const }),
openSession: () => Effect.die("No provider process needed for metadata commands"),
-} as ProviderAdapterV2Shape;
+} as ProviderAdapter.ProviderAdapterV2["Service"];
const layerDatabase = SqlitePersistence.layerMemory;
const layerTest = Layer.mergeAll(
layerDatabase,
diff --git a/apps/server/src/orchestration-v2/GrokOrchestratorV2.live.test.ts b/apps/server/src/orchestration-v2/GrokOrchestratorV2.live.test.ts
index 15d29d30f8a..abdf28155a0 100644
--- a/apps/server/src/orchestration-v2/GrokOrchestratorV2.live.test.ts
+++ b/apps/server/src/orchestration-v2/GrokOrchestratorV2.live.test.ts
@@ -29,7 +29,7 @@ import * as CodexInstallation from "../provider/CodexInstallation.ts";
import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
import * as ModelManifest from "../provider/ModelManifest.ts";
import * as ProviderInstanceRegistryHydration from "../provider/ProviderInstanceRegistryHydration.ts";
-import * as ProviderEventLoggers from "../provider/ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as OpenCodeRuntime from "@t3tools/provider-opencode/server/OpenCodeRuntime";
import * as OpenCodeServerLedger from "@t3tools/provider-opencode/server/OpenCodeServerLedger";
import * as ServerSettings from "../serverSettings.ts";
diff --git a/apps/server/src/orchestration-v2/OpenCode2OrchestratorV2.live.test.ts b/apps/server/src/orchestration-v2/OpenCode2OrchestratorV2.live.test.ts
index 55d93ded6e6..b3d025ed0bd 100644
--- a/apps/server/src/orchestration-v2/OpenCode2OrchestratorV2.live.test.ts
+++ b/apps/server/src/orchestration-v2/OpenCode2OrchestratorV2.live.test.ts
@@ -54,7 +54,7 @@ import * as CodexInstallation from "../provider/CodexInstallation.ts";
import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
import * as ModelManifest from "../provider/ModelManifest.ts";
import * as ProviderInstanceRegistryHydration from "../provider/ProviderInstanceRegistryHydration.ts";
-import * as ProviderEventLoggers from "../provider/ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as OpenCode2Client from "@t3tools/provider-opencode/server/v2/OpenCode2Client";
import * as OpenCodeRuntime from "@t3tools/provider-opencode/server/OpenCodeRuntime";
import * as OpenCodeServerLedger from "@t3tools/provider-opencode/server/OpenCodeServerLedger";
@@ -67,7 +67,7 @@ import * as ProviderInstanceRegistry from "../provider/ProviderInstanceRegistry.
import * as ProviderTurnStartServiceTestkit from "./ProviderTurnStartService.testkit.ts";
import * as RuntimeLayer from "./runtimeLayer.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as ProviderContinuationService from "./ProviderContinuationService.ts";
import * as ThreadManagementService from "./ThreadManagementService.ts";
import * as McpSessionRegistry from "../mcp/McpSessionRegistry.ts";
diff --git a/apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts b/apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts
index 76a4bd8c1be..8e5fca79cf5 100644
--- a/apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts
+++ b/apps/server/src/orchestration-v2/Orchestrator.control-reads.test.ts
@@ -25,9 +25,9 @@ import * as SqlitePersistence from "../persistence/Sqlite.ts";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as Orchestrator from "./Orchestrator.ts";
import * as ProjectionStore from "./ProjectionStore.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const instanceId = ProviderInstanceId.make("codex");
const modelSelection = { instanceId, model: "gpt-5.1-codex" };
@@ -37,7 +37,7 @@ const adapter = {
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" as const }),
openSession: () => Effect.die("No provider process needed for metadata controls"),
-} as ProviderAdapterV2Shape;
+} as ProviderAdapter.ProviderAdapterV2["Service"];
const layerDatabase = SqlitePersistence.layerMemory;
const layerTest = Layer.mergeAll(
layerDatabase,
diff --git a/apps/server/src/orchestration-v2/Orchestrator.ts b/apps/server/src/orchestration-v2/Orchestrator.ts
index c85f11c5683..4f870a606e0 100644
--- a/apps/server/src/orchestration-v2/Orchestrator.ts
+++ b/apps/server/src/orchestration-v2/Orchestrator.ts
@@ -91,7 +91,7 @@ import { isUndeliveredMailboxSteer } from "./NotificationMailbox.ts";
import { EventSinkV2 } from "./EventSink.ts";
import * as EffectOutbox from "./EffectOutbox.ts";
import type { OrchestrationEffectRequestV2, PendingOrchestrationEffectV2 } from "./EffectOutbox.ts";
-import { IdAllocatorV2 } from "@t3tools/provider-core/server/IdAllocator";
+import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ThreadCommandExecutor from "./ThreadCommandExecutor.ts";
import { DispatchModeLimit, exceededDispatchModeLimit } from "./DispatchModeLimit.ts";
import {
@@ -107,9 +107,8 @@ import {
type ProjectionCheckpointContext,
type ShellSnapshotOptions,
} from "./ProjectionStore.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import { ProviderAdapterRegistryV2 } from "./ProviderAdapterRegistry.ts";
-import { ProviderContinuationRequests } from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
import * as RunExecutionService from "./RunExecutionService.ts";
import { ProviderSessionManagerV2 } from "./ProviderSessionManager.ts";
@@ -128,6 +127,7 @@ import {
ThreadForkServiceV2,
} from "./ThreadForkService.ts";
import { planThreadDeletion } from "./ThreadDeletion.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
export class OrchestratorDispatchError extends Schema.TaggedError<OrchestratorDispatchError>()(
"OrchestratorDispatchError",
@@ -800,7 +800,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
const contextHandoffService = yield* ContextHandoffServiceV2;
const eventSink = yield* EventSinkV2;
const commandReceipts = yield* CommandReceiptStoreV2;
- const idAllocator = yield* IdAllocatorV2;
+ const idAllocator = yield* IdAllocator.IdAllocatorV2;
const projects = yield* ProjectStore.ProjectStoreV2;
const projectionStore = yield* ProjectionStoreV2;
const effectOutbox = yield* EffectOutbox.EffectOutboxV2;
@@ -823,7 +823,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const providerAdapters = yield* ProviderAdapterRegistryV2;
- const continuationRequests = yield* ProviderContinuationRequests;
+ const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
const providerSessions = yield* ProviderSessionManagerV2;
const providerSwitchService = yield* ProviderSwitchServiceV2;
const runtimePolicy = yield* RuntimePolicyV2;
@@ -857,7 +857,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
);
const providerSessionIdFor = (input: {
- readonly adapter: ProviderAdapterV2Shape;
+ readonly adapter: ProviderAdapter.ProviderAdapterV2["Service"];
readonly providerInstanceId: ProviderInstanceId;
readonly threadId: ThreadId;
}) =>
@@ -10955,7 +10955,7 @@ export const layer: Layer.Layer<
| ContextHandoffServiceV2
| EffectOutbox.EffectOutboxV2
| EventSinkV2
- | IdAllocatorV2
+ | IdAllocator.IdAllocatorV2
| ProjectStore.ProjectStoreV2
| ProviderAdapterRegistryV2
| ProviderSessionManagerV2
diff --git a/apps/server/src/orchestration-v2/ProviderAdapterRegistry.test.ts b/apps/server/src/orchestration-v2/ProviderAdapterRegistry.test.ts
index 3e8f6dfa297..2f2c545377e 100644
--- a/apps/server/src/orchestration-v2/ProviderAdapterRegistry.test.ts
+++ b/apps/server/src/orchestration-v2/ProviderAdapterRegistry.test.ts
@@ -18,36 +18,35 @@ import * as Schema from "effect/Schema";
import type * as Scope from "effect/Scope";
import * as Stream from "effect/Stream";
-import * as ProviderAuthFlow from "@t3tools/provider-core/server/ProviderAuthFlow";
+import * as ProviderAuthFlow from "@t3tools/provider-core/server/providerAuthFlow";
import type { ProviderAuthController } from "../provider/ProviderAuthService.ts";
import type { ProviderInstance } from "@t3tools/provider-core/server/driver";
import * as ProviderInstanceRegistry from "../provider/ProviderInstanceRegistry.ts";
-import {
- ProviderAdapterOpenSessionError,
- type ProviderAdapterV2Shape,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import {
ProviderAdapterDriverCreateError,
type ProviderAdapterDriver,
} from "@t3tools/provider-core/server/adapterDriver";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const driver = ProviderDriverKind.make("codex");
const personalId = ProviderInstanceId.make("codex_personal");
const workId = ProviderInstanceId.make("codex_work");
-const makeAdapter = (instanceId: ProviderInstanceId): ProviderAdapterV2Shape =>
+const makeAdapter = (
+ instanceId: ProviderInstanceId,
+): ProviderAdapter.ProviderAdapterV2["Service"] =>
({
instanceId,
driver,
getCapabilities: () => Effect.die("capabilities are not used by this registry test"),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
openSession: () => Effect.die("sessions are not used by this registry test"),
- }) as ProviderAdapterV2Shape;
+ }) as ProviderAdapter.ProviderAdapterV2["Service"];
const makeInstance = (
instanceId: ProviderInstanceId,
- orchestrationAdapter: ProviderAdapterV2Shape,
+ orchestrationAdapter: ProviderAdapter.ProviderAdapterV2["Service"],
): ProviderInstance => ({
instanceId,
driverKind: driver,
@@ -101,7 +100,11 @@ const lifecycleConfigMap: ProviderInstanceConfigMap = {
const lifecycleAdapter = makeAdapter(lifecycleInstanceId);
const makeLifecycleDriver = (
- create: Effect.Effect<ProviderAdapterV2Shape, ProviderAdapterDriverCreateError, Scope.Scope>,
+ create: Effect.Effect<
+ ProviderAdapter.ProviderAdapterV2["Service"],
+ ProviderAdapterDriverCreateError,
+ Scope.Scope
+ >,
): ProviderAdapterDriver<Record<string, never>> => ({
driverKind: lifecycleDriver,
configSchema: Schema.Struct({}),
@@ -263,7 +266,7 @@ it.effect(
},
})
.pipe(Effect.flip);
- assert.instanceOf(error, ProviderAdapterOpenSessionError);
+ assert.instanceOf(error, ProviderAdapter.ProviderAdapterOpenSessionError);
assert.instanceOf(error.cause, ProviderSetupError);
}),
);
@@ -287,7 +290,7 @@ it.effect("interrupts admitted session startup when a shared peer signs out", ()
authenticate: () => Effect.void,
logout: Effect.void,
});
- const adapter: ProviderAdapterV2Shape = {
+ const adapter: ProviderAdapter.ProviderAdapterV2["Service"] = {
...workAdapter,
openSession: () =>
Effect.gen(function* () {
diff --git a/apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts b/apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts
index 984fd586e5e..9811907f250 100644
--- a/apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts
+++ b/apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts
@@ -48,11 +48,11 @@ export type ProviderAdapterRegistryV2Error = typeof ProviderAdapterRegistryV2Err
export interface ProviderAdapterRegistryV2Shape {
readonly get: (
instanceId: ProviderInstanceId,
- ) => Effect.Effect<ProviderAdapter.ProviderAdapterV2Shape, ProviderAdapterRegistryV2Error>;
+ ) => Effect.Effect<ProviderAdapter.ProviderAdapterV2["Service"], ProviderAdapterRegistryV2Error>;
readonly list: () => Effect.Effect<ReadonlyArray<ProviderInstanceId>>;
readonly getMetadata?: (instanceId: ProviderInstanceId) => Effect.Effect<
{
- readonly driver: ProviderAdapter.ProviderAdapterV2Shape["driver"];
+ readonly driver: ProviderAdapter.ProviderAdapterV2["Service"]["driver"];
readonly continuationKey: string;
readonly enabled: boolean;
readonly capabilities: OrchestrationV2ProviderCapabilities;
@@ -134,7 +134,7 @@ export const layerFromProviderInstanceRegistry: Layer.Layer<
),
);
},
- } satisfies ProviderAdapter.ProviderAdapterV2Shape);
+ } satisfies ProviderAdapter.ProviderAdapterV2["Service"]);
}),
),
list: () =>
@@ -169,7 +169,7 @@ export const ProviderAdapterRegistryBuildError = Schema.Union([ProviderAdapterDr
export type ProviderAdapterRegistryBuildError = typeof ProviderAdapterRegistryBuildError.Type;
function makeRegistry(
- adapters: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Shape>,
+ adapters: ReadonlyArray<ProviderAdapter.ProviderAdapterV2["Service"]>,
): ProviderAdapterRegistryV2Shape {
return {
get: (instanceId) =>
@@ -185,7 +185,7 @@ function makeRegistry(
}
export function layerFromAdapters(
- adapters: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Shape>,
+ adapters: ReadonlyArray<ProviderAdapter.ProviderAdapterV2["Service"]>,
): Layer.Layer<ProviderAdapterRegistryV2> {
return Layer.succeed(
ProviderAdapterRegistryV2,
@@ -194,7 +194,7 @@ export function layerFromAdapters(
}
export function layerFromAdaptersEffect<R, E>(
- adapters: Effect.Effect<ReadonlyArray<ProviderAdapter.ProviderAdapterV2Shape>, E, R>,
+ adapters: Effect.Effect<ReadonlyArray<ProviderAdapter.ProviderAdapterV2["Service"]>, E, R>,
): Layer.Layer<ProviderAdapterRegistryV2, E, R> {
return Layer.effect(
ProviderAdapterRegistryV2,
@@ -203,7 +203,7 @@ export function layerFromAdaptersEffect<R, E>(
}
export function layerSingle(
- adapter: ProviderAdapter.ProviderAdapterV2Shape,
+ adapter: ProviderAdapter.ProviderAdapterV2["Service"],
): Layer.Layer<ProviderAdapterRegistryV2> {
return layerFromAdapters([adapter]);
}
@@ -217,7 +217,7 @@ const decodedConfigEnabled = (config: unknown): boolean | undefined => {
};
interface LiveAdapterEntry {
- readonly adapter: ProviderAdapter.ProviderAdapterV2Shape;
+ readonly adapter: ProviderAdapter.ProviderAdapterV2["Service"];
readonly scope: Scope.Closeable;
readonly entry: ProviderInstanceConfig;
}
diff --git a/apps/server/src/orchestration-v2/ProviderContinuationService.test.ts b/apps/server/src/orchestration-v2/ProviderContinuationService.test.ts
index 6e99d80a30e..a6afc4a4b2f 100644
--- a/apps/server/src/orchestration-v2/ProviderContinuationService.test.ts
+++ b/apps/server/src/orchestration-v2/ProviderContinuationService.test.ts
@@ -19,7 +19,7 @@ import * as Semaphore from "effect/Semaphore";
import * as TestClock from "effect/testing/TestClock";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as ProviderContinuationService from "./ProviderContinuationService.ts";
import * as ThreadManagementService from "./ThreadManagementService.ts";
diff --git a/apps/server/src/orchestration-v2/ProviderContinuationService.ts b/apps/server/src/orchestration-v2/ProviderContinuationService.ts
index 928a5c90952..b8a57a88937 100644
--- a/apps/server/src/orchestration-v2/ProviderContinuationService.ts
+++ b/apps/server/src/orchestration-v2/ProviderContinuationService.ts
@@ -4,7 +4,7 @@ import * as Layer from "effect/Layer";
import * as Ref from "effect/Ref";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as ThreadManagementService from "./ThreadManagementService.ts";
import { isUndeliveredMailboxSteer } from "./NotificationMailbox.ts";
diff --git a/apps/server/src/orchestration-v2/ProviderEventIngestor.ts b/apps/server/src/orchestration-v2/ProviderEventIngestor.ts
index 355a73e2199..02acf9b51da 100644
--- a/apps/server/src/orchestration-v2/ProviderEventIngestor.ts
+++ b/apps/server/src/orchestration-v2/ProviderEventIngestor.ts
@@ -31,7 +31,7 @@ import * as AnalyticsService from "../telemetry/AnalyticsService.ts";
import * as EventSink from "./EventSink.ts";
import * as ProjectionStore from "./ProjectionStore.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import { ProviderAdapterV2Event } from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import { makeProviderFailureTurnItem } from "@t3tools/provider-core/server/failure";
import * as ThreadCommandExecutor from "./ThreadCommandExecutor.ts";
import { stripUnservedToolOutputImageBytes } from "./toolOutputImageBytes.ts";
@@ -41,7 +41,7 @@ export class ProviderEventNormalizeError extends Schema.TaggedError<ProviderEven
{
providerSessionId: ProviderSessionId,
threadId: ThreadId,
- providerEvent: ProviderAdapterV2Event,
+ providerEvent: ProviderAdapter.ProviderAdapterV2Event,
cause: Schema.optional(Schema.Defect()),
},
) {
@@ -93,7 +93,7 @@ export const layerAnalytics = Layer.effect(
);
function providerTurnAnalyticsProperties(input: {
- readonly driver: ProviderAdapterV2Event["driver"];
+ readonly driver: ProviderAdapter.ProviderAdapterV2Event["driver"];
readonly providerTurn: OrchestrationV2ProviderTurn;
readonly context?: ProviderTurnAnalyticsContext;
}): Readonly<Record<string, unknown>> {
@@ -257,7 +257,7 @@ export interface ProviderEventIngestInput {
readonly runId?: RunId;
readonly nodeId?: NodeId;
readonly rawEventId?: RawEventId;
- readonly event: ProviderAdapterV2Event;
+ readonly event: ProviderAdapter.ProviderAdapterV2Event;
readonly analyticsContext?: ProviderTurnAnalyticsContext;
}
@@ -657,7 +657,6 @@ export const layer: Layer.Layer<
yield* makeDomainEvent(input, {
type: "turn-item.updated",
payload: makeProviderFailureTurnItem({
- idAllocator,
driver: input.event.driver,
threadId: input.threadId,
runId: input.runId ?? null,
diff --git a/apps/server/src/orchestration-v2/ProviderSessionManager.test.ts b/apps/server/src/orchestration-v2/ProviderSessionManager.test.ts
index bb994377f4b..7f5d935771b 100644
--- a/apps/server/src/orchestration-v2/ProviderSessionManager.test.ts
+++ b/apps/server/src/orchestration-v2/ProviderSessionManager.test.ts
@@ -44,18 +44,11 @@ import * as EventSink from "./EventSink.ts";
import * as EventStore from "./EventStore.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProjectionStore from "./ProjectionStore.ts";
-import {
- ProviderAdapterEventStreamError,
- type ProviderAdapterV2Event,
- ProviderAdapterProtocolError,
- type ProviderAdapterV2RuntimePolicy,
- type ProviderAdapterV2SessionRuntime,
- type ProviderAdapterV2Shape,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderEventIngestor from "./ProviderEventIngestor.ts";
import * as ThreadCommandExecutor from "./ThreadCommandExecutor.ts";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const layerTestDatabase = SqlitePersistence.layerMemory;
const layerTestStores = Layer.merge(EventStore.layer, ProjectionStore.layer).pipe(
@@ -167,7 +160,10 @@ interface TestProviderRuntimeState {
readonly interruptCount: number;
readonly resumeCount: number;
readonly unloadedNativeThreadIds: ReadonlyArray<string>;
- readonly eventQueues: ReadonlyMap<string, Queue.Queue<ProviderAdapterV2Event, Cause.Done>>;
+ readonly eventQueues: ReadonlyMap<
+ string,
+ Queue.Queue<ProviderAdapter.ProviderAdapterV2Event, Cause.Done>
+ >;
}
const emptyState: TestProviderRuntimeState = {
@@ -189,7 +185,7 @@ const runtimePolicy = {
runtimeMode: "full-access",
interactionMode: "default",
cwd: process.cwd(),
-} satisfies ProviderAdapterV2RuntimePolicy;
+} satisfies ProviderAdapter.ProviderAdapterV2RuntimePolicy;
function makeProviderSession(input: {
readonly providerSessionId: ProviderSessionId;
@@ -211,7 +207,7 @@ function makeProviderSession(input: {
}
function makeThreadCreatedEvent(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly threadId: ThreadId;
readonly now: DateTime.Utc;
readonly projectId?: ProjectId;
@@ -264,7 +260,7 @@ function makeThreadCreatedEvent(input: {
}
function makeProviderThread(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly threadId: ThreadId;
readonly providerSessionId: ProviderSessionId;
readonly now: DateTime.Utc;
@@ -299,7 +295,7 @@ function makeProviderThread(input: {
function unimplemented(detail: string) {
return Effect.fail(
- new ProviderAdapterProtocolError({
+ new ProviderAdapter.ProviderAdapterProtocolError({
driver: CODEX_DRIVER,
detail,
}),
@@ -328,7 +324,7 @@ function makeProviderAdapter(
/** Completed when a hanging scope close reaches its wedged finalizer. */
readonly scopeCloseReached?: Deferred.Deferred<void>;
} = {},
-): ProviderAdapterV2Shape {
+): ProviderAdapter.ProviderAdapterV2["Service"] {
const countClose = Effect.addFinalizer(() =>
Ref.update(state, (current) => ({
...current,
@@ -371,7 +367,7 @@ function makeProviderAdapter(
]);
}
const now = yield* DateTime.now;
- const events = yield* Queue.unbounded<ProviderAdapterV2Event, Cause.Done>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event, Cause.Done>();
const session = makeProviderSession({
providerSessionId: input.providerSessionId,
now,
@@ -398,7 +394,7 @@ function makeProviderAdapter(
providerSession: session,
events: options.failEventStream
? Stream.fail(
- new ProviderAdapterEventStreamError({
+ new ProviderAdapter.ProviderAdapterEventStreamError({
driver: CODEX_DRIVER,
providerSessionId: input.providerSessionId,
cause: "process exited",
@@ -442,7 +438,7 @@ function makeProviderAdapter(
readThreadSnapshot: () => unimplemented("readThreadSnapshot unused in test"),
rollbackThread: () => unimplemented("rollbackThread unused in test"),
forkThread: () => unimplemented("forkThread unused in test"),
- } satisfies ProviderAdapterV2SessionRuntime;
+ } satisfies ProviderAdapter.ProviderAdapterV2SessionRuntime;
}),
};
}
@@ -674,7 +670,7 @@ function runBrowserAccessScenario(input: {
}
function makePendingRuntimeRequestEvents(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly threadId: ThreadId;
readonly providerSessionId: ProviderSessionId;
readonly providerThread: OrchestrationV2ProviderThread;
@@ -795,7 +791,7 @@ function makePendingRuntimeRequestEvents(input: {
driver: CODEX_DRIVER,
turnItem,
},
- ] satisfies ReadonlyArray<ProviderAdapterV2Event>;
+ ] satisfies ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>;
return { events, providerEvents, requestId, nodeId };
});
}
diff --git a/apps/server/src/orchestration-v2/ProviderSessionManager.ts b/apps/server/src/orchestration-v2/ProviderSessionManager.ts
index f467b8527e8..705bd4ec27e 100644
--- a/apps/server/src/orchestration-v2/ProviderSessionManager.ts
+++ b/apps/server/src/orchestration-v2/ProviderSessionManager.ts
@@ -46,14 +46,7 @@ import * as McpSessionRegistry from "../mcp/McpSessionRegistry.ts";
import * as EventSink from "./EventSink.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProviderEventIngestor from "./ProviderEventIngestor.ts";
-import {
- ProviderAdapterEventStreamError,
- ProviderAdapterV2RuntimePolicy,
- type ProviderAdapterV2Error,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2EventSubscription,
- type ProviderAdapterV2SessionRuntime,
-} from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProjectionStore from "./ProjectionStore.ts";
@@ -161,14 +154,20 @@ export interface ProviderSessionManagerV2Shape {
readonly threadId: ThreadId;
readonly providerSessionId: ProviderSessionId;
readonly modelSelection: ModelSelection;
- readonly runtimePolicy: ProviderAdapterV2RuntimePolicy;
+ readonly runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
readonly resumeFromSession?: OrchestrationV2ProviderSession;
readonly initialNativeThreadId?: string;
readonly initialProviderItemIdentityVersion?: 2;
- }) => Effect.Effect<ProviderAdapterV2SessionRuntime, ProviderSessionManagerV2Error>;
+ }) => Effect.Effect<
+ ProviderAdapter.ProviderAdapterV2SessionRuntime,
+ ProviderSessionManagerV2Error
+ >;
readonly get: (
providerSessionId: ProviderSessionId,
- ) => Effect.Effect<Option.Option<ProviderAdapterV2SessionRuntime>, ProviderSessionManagerV2Error>;
+ ) => Effect.Effect<
+ Option.Option<ProviderAdapter.ProviderAdapterV2SessionRuntime>,
+ ProviderSessionManagerV2Error
+ >;
readonly close: (
providerSessionId: ProviderSessionId,
) => Effect.Effect<void, ProviderSessionManagerV2Error>;
@@ -211,8 +210,8 @@ interface LiveSessionEntry {
*/
readonly mcpCredentialIdByThread: ReadonlyMap<ThreadId, string>;
readonly supportsMultipleProviderThreads: boolean;
- readonly runtime: ProviderAdapterV2SessionRuntime;
- readonly exposedRuntime: ProviderAdapterV2SessionRuntime;
+ readonly runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime;
+ readonly exposedRuntime: ProviderAdapter.ProviderAdapterV2SessionRuntime;
readonly eventSubscribers: Ref.Ref<
ReadonlyMap<number, Queue.Queue<ProviderSessionEventSignal, Cause.Done>>
>;
@@ -244,10 +243,10 @@ interface IdleThreadUnload {
}
type ProviderSessionEventSignal =
- | { readonly type: "event"; readonly event: ProviderAdapterV2Event }
+ | { readonly type: "event"; readonly event: ProviderAdapter.ProviderAdapterV2Event }
| {
readonly type: "failure";
- readonly cause: Cause.Cause<ProviderAdapterV2Error>;
+ readonly cause: Cause.Cause<ProviderAdapter.ProviderAdapterV2Error>;
};
export interface ProviderSessionManagerV2LayerOptions {
@@ -279,7 +278,9 @@ function sessionKey(providerSessionId: ProviderSessionId): string {
* Their node and transcript item are runless too, so they bypass the normal
* per-run subscriber and are persisted by the session event pump.
*/
-function sessionScopedRuntimeRequestThreadId(event: ProviderAdapterV2Event): ThreadId | undefined {
+function sessionScopedRuntimeRequestThreadId(
+ event: ProviderAdapter.ProviderAdapterV2Event,
+): ThreadId | undefined {
switch (event.type) {
case "runtime_request.updated":
return event.runtimeRequest.providerTurnId === null ? event.threadId : undefined;
@@ -298,7 +299,9 @@ function sessionScopedRuntimeRequestThreadId(event: ProviderAdapterV2Event): Thr
}
function providerThreadRuntimeKey(
- providerThread: Parameters<ProviderAdapterV2SessionRuntime["resumeThread"]>[0]["providerThread"],
+ providerThread: Parameters<
+ ProviderAdapter.ProviderAdapterV2SessionRuntime["resumeThread"]
+ >[0]["providerThread"],
): string {
const nativeThreadRef = providerThread.nativeThreadRef;
return nativeThreadRef === null
@@ -308,10 +311,10 @@ function providerThreadRuntimeKey(
function providerThreadLoadKey(input: {
readonly providerThread: Parameters<
- ProviderAdapterV2SessionRuntime["resumeThread"]
+ ProviderAdapter.ProviderAdapterV2SessionRuntime["resumeThread"]
>[0]["providerThread"];
readonly modelSelection?: ModelSelection;
- readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
+ readonly runtimePolicy?: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
}): string {
return JSON.stringify({
providerThread: providerThreadRuntimeKey(input.providerThread),
@@ -575,7 +578,7 @@ export const layerWithOptions = (
const failSubscribers = (entry: LiveSessionEntry, detail: string) =>
Effect.gen(function* () {
- const error = new ProviderAdapterEventStreamError({
+ const error = new ProviderAdapter.ProviderAdapterEventStreamError({
driver: entry.runtime.driver,
providerSessionId: entry.runtime.providerSessionId,
cause: detail,
@@ -617,7 +620,7 @@ export const layerWithOptions = (
fiber === null ? Effect.void : Fiber.interrupt(fiber).pipe(Effect.ignore);
const writeProviderSessionEvents = (input: {
- readonly runtime: ProviderAdapterV2SessionRuntime;
+ readonly runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime;
readonly threadIds: Iterable<ThreadId>;
readonly type: "provider-session.attached" | "provider-session.updated";
readonly payload: OrchestrationV2ProviderSession;
@@ -1226,7 +1229,7 @@ export const layerWithOptions = (
const removeThreadAttachment = (input: {
readonly providerSessionId: ProviderSessionId;
readonly threadId: ThreadId;
- readonly runtime: ProviderAdapterV2SessionRuntime;
+ readonly runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime;
}) =>
Ref.update(sessions, (current) => {
const key = sessionKey(input.providerSessionId);
@@ -1289,7 +1292,7 @@ export const layerWithOptions = (
readonly providerInstanceId: ProviderInstanceId;
}) =>
Effect.suspend(() => {
- let attachedTo: ProviderAdapterV2SessionRuntime | undefined;
+ let attachedTo: ProviderAdapter.ProviderAdapterV2SessionRuntime | undefined;
let preparedForCleanup: PreparedMcpCredential | undefined;
let reservationDropped = false;
const dropReservation = () => {
@@ -1631,7 +1634,7 @@ export const layerWithOptions = (
subscribers: Ref.Ref<
ReadonlyMap<number, Queue.Queue<ProviderSessionEventSignal, Cause.Done>>
>,
- ): Effect.Effect<ProviderAdapterV2EventSubscription> =>
+ ): Effect.Effect<ProviderAdapter.ProviderAdapterV2EventSubscription> =>
Effect.gen(function* () {
const queue = yield* Queue.unbounded<ProviderSessionEventSignal, Cause.Done>();
const subscriberId = yield* Ref.getAndUpdate(nextSubscriberId, (value) => value + 1);
@@ -1662,15 +1665,15 @@ export const layerWithOptions = (
),
Stream.ensuring(close),
);
- return { events, close } satisfies ProviderAdapterV2EventSubscription;
+ return { events, close } satisfies ProviderAdapter.ProviderAdapterV2EventSubscription;
});
const decorateRuntime = (
- runtime: ProviderAdapterV2SessionRuntime,
+ runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime,
eventSubscribers: Ref.Ref<
ReadonlyMap<number, Queue.Queue<ProviderSessionEventSignal, Cause.Done>>
>,
- ): ProviderAdapterV2SessionRuntime => {
+ ): ProviderAdapter.ProviderAdapterV2SessionRuntime => {
const providerSessionId = runtime.providerSessionId;
const subscribeEvents = makeEventSubscription(eventSubscribers);
// Every provider's turn operations pass through here, so this is where they are
@@ -1852,7 +1855,10 @@ export const layerWithOptions = (
const persistProviderSessionUpdate = (
entry: LiveSessionEntry,
- event: Extract<ProviderAdapterV2Event, { readonly type: "provider_session.updated" }>,
+ event: Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { readonly type: "provider_session.updated" }
+ >,
) =>
Effect.gen(function* () {
const current = (yield* Ref.get(sessions)).get(
@@ -1925,7 +1931,7 @@ export const layerWithOptions = (
.pipe(
Effect.mapError(
(cause) =>
- new ProviderAdapterEventStreamError({
+ new ProviderAdapter.ProviderAdapterEventStreamError({
driver: entry.runtime.driver,
providerSessionId: entry.runtime.providerSessionId,
cause,
@@ -1962,7 +1968,7 @@ export const layerWithOptions = (
const cause = Exit.isFailure(exit)
? exit.cause
: Cause.fail(
- new ProviderAdapterEventStreamError({
+ new ProviderAdapter.ProviderAdapterEventStreamError({
driver: entry.runtime.driver,
providerSessionId: entry.runtime.providerSessionId,
cause: "Provider event stream ended unexpectedly.",
@@ -2212,7 +2218,7 @@ export const layerWithOptions = (
Effect.gen(function* () {
const entry = (yield* Ref.get(sessions)).get(sessionKey(providerSessionId));
if (entry === undefined) {
- return Option.none<ProviderAdapterV2SessionRuntime>();
+ return Option.none<ProviderAdapter.ProviderAdapterV2SessionRuntime>();
}
yield* touchActivity(providerSessionId);
return Option.some(entry.exposedRuntime);
diff --git a/apps/server/src/orchestration-v2/ProviderSwitchService.test.ts b/apps/server/src/orchestration-v2/ProviderSwitchService.test.ts
index 712b9e6e10f..d36721bbd6a 100644
--- a/apps/server/src/orchestration-v2/ProviderSwitchService.test.ts
+++ b/apps/server/src/orchestration-v2/ProviderSwitchService.test.ts
@@ -12,10 +12,10 @@ import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import { acpSelectionTransition } from "@t3tools/provider-core/server/selectionTransition";
import * as ProviderSwitch from "./ProviderSwitchService.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const driver = ProviderDriverKind.make("codex");
const currentInstanceId = ProviderInstanceId.make("codex_primary");
@@ -67,10 +67,12 @@ function deadSessionRecord(
function layerTest(
metadata: Readonly<Record<string, { continuationKey: string }>>,
- planSelectionTransition: ProviderAdapterV2Shape["planSelectionTransition"] = () =>
+ planSelectionTransition: ProviderAdapter.ProviderAdapterV2["Service"]["planSelectionTransition"] = () =>
Effect.succeed({ type: "restart_session" }),
) {
- const adapter = (instanceId: ProviderInstanceId): ProviderAdapterV2Shape => ({
+ const adapter = (
+ instanceId: ProviderInstanceId,
+ ): ProviderAdapter.ProviderAdapterV2["Service"] => ({
instanceId,
driver,
getCapabilities: () => Effect.succeed(capabilitiesWithoutModelSwitch),
diff --git a/apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts b/apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts
index 42b3943e71d..2ac00838018 100644
--- a/apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts
+++ b/apps/server/src/orchestration-v2/ProviderTurnControlService.test.ts
@@ -24,7 +24,7 @@ import * as Stream from "effect/Stream";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as ProjectionStore from "./ProjectionStore.ts";
-import type { ProviderAdapterV2SessionRuntime } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
import * as ProviderTurnControlService from "./ProviderTurnControlService.ts";
@@ -177,7 +177,7 @@ it.effect(
updatedAt: now,
lastError: null,
};
- const runtime: ProviderAdapterV2SessionRuntime = {
+ const runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime = {
instanceId: providerInstanceId,
driver,
providerSessionId: oldSessionId,
diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts
index 54e55c40a3c..d6c12fab7ee 100644
--- a/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts
+++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts
@@ -32,7 +32,7 @@ import * as EventSink from "./EventSink.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as ProjectionStore from "./ProjectionStore.ts";
-import { ProviderAdapterEventStreamError } from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
import * as ProviderTurnStart from "./ProviderTurnStartService.ts";
import * as RunExecutionService from "./RunExecutionService.ts";
@@ -372,7 +372,7 @@ function makeLocalCommandHarness(input: {
}).pipe(
Effect.andThen(
Effect.fail(
- new ProviderAdapterEventStreamError({
+ new ProviderAdapter.ProviderAdapterEventStreamError({
driver: providerThread.driver,
providerSessionId,
cause: input.ensureThreadFailure,
@@ -385,7 +385,7 @@ function makeLocalCommandHarness(input: {
driver: providerThread.driver,
resumeThread: () =>
Effect.fail(
- new ProviderAdapterEventStreamError({
+ new ProviderAdapter.ProviderAdapterEventStreamError({
driver: providerThread.driver,
providerSessionId,
cause: "native thread is gone",
diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts
index a928680b240..e2c905b1e17 100644
--- a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts
@@ -37,12 +37,7 @@ import {
latestNativeContextUsage,
} from "@t3tools/provider-core/server/handoffBudget";
import { deliverContextHandoffs } from "./ContextHandoffDelivery.ts";
-import {
- ProviderAdapterTurnStartError,
- type ProviderAdapterV2Error,
- type ProviderAdapterV2HistoricalContext,
- type ProviderAdapterV2SessionRuntime,
-} from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProjectionStore from "./ProjectionStore.ts";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
@@ -184,15 +179,15 @@ export const layer: Layer.Layer<
};
const makeDeliverySession = (
- session: ProviderAdapterV2SessionRuntime,
+ session: ProviderAdapter.ProviderAdapterV2SessionRuntime,
startWithHandoffs: (
- input: Parameters<ProviderAdapterV2SessionRuntime["startTurn"]>[0],
+ input: Parameters<ProviderAdapter.ProviderAdapterV2SessionRuntime["startTurn"]>[0],
compact?: boolean,
- ) => ReturnType<ProviderAdapterV2SessionRuntime["startTurn"]>,
+ ) => ReturnType<ProviderAdapter.ProviderAdapterV2SessionRuntime["startTurn"]>,
) => {
let deliver: typeof startWithHandoffs | undefined = startWithHandoffs;
const start = (
- input: Parameters<ProviderAdapterV2SessionRuntime["startTurn"]>[0],
+ input: Parameters<ProviderAdapter.ProviderAdapterV2SessionRuntime["startTurn"]>[0],
compact = false,
) =>
Effect.suspend(() => {
@@ -595,7 +590,7 @@ export const layer: Layer.Layer<
// Only the provider's own thread load fails the run on the last attempt;
// store, id and handoff failures around it keep their typed errors.
const loadFromProvider = (
- load: Effect.Effect<OrchestrationV2ProviderThread, ProviderAdapterV2Error>,
+ load: Effect.Effect<OrchestrationV2ProviderThread, ProviderAdapter.ProviderAdapterV2Error>,
) =>
Effect.gen(function* () {
const loaded = yield* Effect.result(load);
@@ -672,7 +667,7 @@ export const layer: Layer.Layer<
const resumed = yield* Effect.result(
uncertainDelivery
? Effect.fail(
- new ProviderAdapterTurnStartError({
+ new ProviderAdapter.ProviderAdapterTurnStartError({
driver: session.driver,
threadId: projection.thread.id,
providerThreadId: providerThread.id,
@@ -1143,7 +1138,7 @@ export const layer: Layer.Layer<
...(session.injectHistory === undefined
? {}
: {
- inject: (history: ProviderAdapterV2HistoricalContext) =>
+ inject: (history: ProviderAdapter.ProviderAdapterV2HistoricalContext) =>
session.injectHistory!({
providerThread: runningProviderThread,
...history,
@@ -1211,7 +1206,7 @@ export const layer: Layer.Layer<
Effect.mapError((cause) =>
cause._tag === "ProviderAdapterTurnStartError"
? cause
- : new ProviderAdapterTurnStartError({
+ : new ProviderAdapter.ProviderAdapterTurnStartError({
driver: session.driver,
threadId: projection.thread.id,
providerThreadId: providerThread.id,
diff --git a/apps/server/src/orchestration-v2/RunExecutionService.test.ts b/apps/server/src/orchestration-v2/RunExecutionService.test.ts
index c7434605807..70820566378 100644
--- a/apps/server/src/orchestration-v2/RunExecutionService.test.ts
+++ b/apps/server/src/orchestration-v2/RunExecutionService.test.ts
@@ -43,14 +43,7 @@ import * as CheckpointService from "./CheckpointService.ts";
import type { PendingOrchestrationEffectV2 } from "./EffectOutbox.ts";
import * as EventSink from "./EventSink.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import {
- ProviderAdapterEventStreamError,
- ProviderAdapterTurnStartError,
- type ProviderAdapterV2Error,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2SessionRuntime,
- type ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProjectionStore from "./ProjectionStore.ts";
import * as ProviderEventIngestor from "./ProviderEventIngestor.ts";
import * as McpAppModelContext from "../mcpApps/McpAppModelContext.ts";
@@ -95,7 +88,7 @@ it.effect("routes shared-runtime events only to their owning root run", () =>
providerThreadId: ProviderThreadId.make("provider-thread:shared-runtime:second"),
};
const firstTurnId = ProviderTurnId.make("provider-turn:shared-runtime:first");
- const turnEvent: ProviderAdapterV2Event = {
+ const turnEvent: ProviderAdapter.ProviderAdapterV2Event = {
type: "provider_turn.updated",
driver,
threadId: first.threadId,
@@ -111,7 +104,7 @@ it.effect("routes shared-runtime events only to their owning root run", () =>
completedAt: null,
},
};
- const messageEvent: ProviderAdapterV2Event = {
+ const messageEvent: ProviderAdapter.ProviderAdapterV2Event = {
type: "message.updated",
driver,
message: {
@@ -129,7 +122,7 @@ it.effect("routes shared-runtime events only to their owning root run", () =>
updatedAt: now,
},
};
- const terminalEvent: ProviderAdapterV2Event = {
+ const terminalEvent: ProviderAdapter.ProviderAdapterV2Event = {
type: "turn.terminal",
driver,
providerThreadId: first.providerThreadId,
@@ -181,7 +174,7 @@ it("leaves a child thread created after the root turn ended to the run that is l
attemptId: RunAttemptId.make("attempt:late-child"),
providerThreadId: ProviderThreadId.make("provider-thread:late-child"),
};
- const childCreated = (childThreadId: ThreadId): ProviderAdapterV2Event =>
+ const childCreated = (childThreadId: ThreadId): ProviderAdapter.ProviderAdapterV2Event =>
({
type: "app_thread.created",
driver,
@@ -193,7 +186,7 @@ it("leaves a child thread created after the root turn ended to the run that is l
rootThreadId: threadId,
},
},
- }) as ProviderAdapterV2Event;
+ }) as ProviderAdapter.ProviderAdapterV2Event;
const earlyChild = ThreadId.make("thread:late-child:early");
const lateChild = ThreadId.make("thread:late-child:late");
@@ -246,7 +239,7 @@ it("does not route a superseded attempt through a reused provider thread", () =>
...oldAttempt,
attemptId: RunAttemptId.make("attempt:shared-runtime:restart:new"),
};
- const oldTurnEvent: ProviderAdapterV2Event = {
+ const oldTurnEvent: ProviderAdapter.ProviderAdapterV2Event = {
type: "provider_turn.updated",
driver,
threadId,
@@ -299,33 +292,33 @@ it("routes only exact same-thread background items inherited from settled runs",
type: "subagent",
status: "running",
},
- } as Extract<ProviderAdapterV2Event, { type: "turn_item.updated" }>;
+ } as Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "turn_item.updated" }>;
const unrelatedRunItem = {
...inheritedRunning,
turnItem: {
...inheritedRunning.turnItem,
runId: RunId.make("run:inherited-background-routing:unrelated"),
},
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
const unlistedPriorItem = {
...inheritedRunning,
turnItem: {
...inheritedRunning.turnItem,
id: TurnItemId.make("turn-item:inherited-background-routing:unrelated"),
},
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
const unrelatedThreadItem = {
...inheritedRunning,
turnItem: { ...inheritedRunning.turnItem, threadId: otherThreadId },
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
const ordinaryItem = {
...inheritedRunning,
turnItem: { ...inheritedRunning.turnItem, type: "reasoning" as const },
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
const inheritedTerminal = {
...inheritedRunning,
turnItem: { ...inheritedRunning.turnItem, status: "completed" as const },
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
const [runningAccepted, afterRunning] = RunExecutionService.routeProviderEvent(
inheritedRunning,
@@ -515,7 +508,7 @@ it("does not carry interrupted or still-running child ownership into later attem
startedAt: null,
completedAt: null,
},
- } satisfies ProviderAdapterV2Event;
+ } satisfies ProviderAdapter.ProviderAdapterV2Event;
assert.isFalse(RunExecutionService.routeProviderEvent(lateChildNode, identity, state)[0]);
});
@@ -550,7 +543,7 @@ it.effect("rechecks run ownership immediately before calling the provider", () =
const session = {
events: Stream.never,
startTurn: () => Ref.update(providerStarts, (count) => count + 1),
- } as unknown as ProviderAdapterV2SessionRuntime;
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime;
yield* runExecution.startRootRun({
commandId: CommandId.make("command:run-execution-start-guard"),
@@ -597,14 +590,15 @@ it.effect("rechecks run ownership immediately before calling the provider", () =
it.effect("passes the thread's MCP app context to the provider under a safe key", () =>
Effect.gen(function* () {
const runExecution = yield* RunExecutionService.RunExecutionServiceV2;
- const started = yield* Deferred.make<ProviderAdapterV2TurnInput>();
+ const started = yield* Deferred.make<ProviderAdapter.ProviderAdapterV2TurnInput>();
const threadId = ThreadId.make("thread:run-execution-app-context");
const providerInstanceId = ProviderInstanceId.make("codex");
const attemptId = RunAttemptId.make("attempt:run-execution-app-context");
const session = {
events: Stream.never,
- startTurn: (input: ProviderAdapterV2TurnInput) => Deferred.succeed(started, input),
- } as unknown as ProviderAdapterV2SessionRuntime;
+ startTurn: (input: ProviderAdapter.ProviderAdapterV2TurnInput) =>
+ Deferred.succeed(started, input),
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime;
yield* runExecution.startRootRun({
commandId: CommandId.make("command:run-execution-app-context"),
@@ -716,7 +710,7 @@ it.effect("fails the run when its ownership check cannot be read before calling
session: {
events: Stream.never,
startTurn: () => Ref.update(providerStarts, (count) => count + 1),
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: { id: runId, threadId, ordinal: 1, providerInstanceId } as OrchestrationV2Run,
rootNode: {
id: NodeId.make("node:run-execution-start-guard-read"),
@@ -821,7 +815,7 @@ it.effect(
Effect.sync(() => {
calls.push("compact");
}),
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: RunId.make(`run:compact-routing:${index}`),
threadId,
@@ -888,7 +882,7 @@ it.effect("refreshes MCP credential liveness before calling the provider", () =>
session: {
events: Stream.never,
startTurn: () => Ref.update(order, (entries) => [...entries, "start-turn"]),
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: RunId.make("run:run-execution-mcp-liveness"),
threadId,
@@ -1000,7 +994,7 @@ it.effect("starts the provider when checkpoint baseline capture fails", () =>
session: {
events: Stream.never,
startTurn: () => Ref.update(providerStarts, (count) => count + 1),
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: runId,
threadId,
@@ -1137,7 +1131,7 @@ it.effect.each(["failure", "interruption", "stale-attempt", "start-guard"] as co
session: {
events: Stream.never,
startTurn: () => Ref.update(providerStarts, (count) => count + 1),
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: runId,
threadId,
@@ -1288,7 +1282,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
),
),
);
- const events: ReadonlyArray<ProviderAdapterV2Event> = [
+ const events: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event> = [
{
type: "app_thread.created",
driver,
@@ -1300,7 +1294,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
rootThreadId: threadId,
},
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
{
type: "provider_thread.updated",
driver,
@@ -1308,7 +1302,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
id: childProviderThreadId,
appThreadId: childThreadId,
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
{
type: "subagent.updated",
driver,
@@ -1318,7 +1312,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
runId,
status: "running",
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
{
type: "provider_turn.updated",
driver,
@@ -1330,7 +1324,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
runAttemptId: null,
status: "running",
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
{
type: "turn.terminal",
driver,
@@ -1353,7 +1347,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
text: "Hello.",
streaming: false,
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
{
type: "provider_turn.updated",
driver,
@@ -1365,7 +1359,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
runAttemptId: null,
status: "completed",
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
{
type: "subagent.updated",
driver,
@@ -1375,7 +1369,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
runId,
status: "completed",
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
];
yield* Effect.gen(function* () {
@@ -1387,7 +1381,7 @@ it.effect("keeps ingesting owned child events after the root turn terminalizes",
session: {
events: Stream.fromIterable(events),
startTurn: () => Effect.void,
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: runId,
threadId,
@@ -1788,7 +1782,7 @@ it.effect(
],
updatedAt: now,
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
rootTerminalEvent(ids, "completed"),
{
type: "provider_thread.updated",
@@ -1799,12 +1793,12 @@ it.effect(
pendingBackgroundTasks: [],
updatedAt: now,
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
]),
close: Deferred.succeed(ingestionDone, undefined),
}),
startTurn: () => Effect.void,
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: ids.runId,
threadId: ids.threadId,
@@ -2000,7 +1994,7 @@ it.effect("drops late root provider-thread writes from a superseded attempt", ()
],
updatedAt: now,
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
rootTerminalEvent(ids, "completed"),
// Late snapshot after a replacement attempt claimed the same
// run ordinal. Without attempt gating this would clobber it.
@@ -2016,12 +2010,12 @@ it.effect("drops late root provider-thread writes from a superseded attempt", ()
],
updatedAt: now,
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
]),
close: Deferred.succeed(ingestionDone, undefined),
}),
startTurn: () => Effect.void,
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: ids.runId,
threadId: ids.threadId,
@@ -2197,7 +2191,7 @@ it.effect(
],
updatedAt: now,
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
// Late completion still writable (turn_item writes are not
// ownership-gated); stream must stay open for it.
backgroundTurnItemEvent(ids, "command_execution", "completed", 2),
@@ -2205,7 +2199,7 @@ it.effect(
close: Deferred.succeed(ingestionDone, undefined),
}),
startTurn: () => Effect.void,
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: ids.runId,
threadId: ids.threadId,
@@ -2371,12 +2365,12 @@ it.effect(
],
updatedAt: now,
},
- } as ProviderAdapterV2Event,
+ } as ProviderAdapter.ProviderAdapterV2Event,
]),
close: Deferred.succeed(ingestionDone, undefined),
}),
startTurn: () => Effect.void,
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: ids.runId,
threadId: ids.threadId,
@@ -2439,7 +2433,7 @@ it.effect(
);
const providerInstanceId = ProviderInstanceId.make("codex");
const written = yield* Ref.make<ReadonlyArray<OrchestrationV2DomainEvent>>([]);
- const ingested = yield* Ref.make<ReadonlyArray<ProviderAdapterV2Event>>([]);
+ const ingested = yield* Ref.make<ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>>([]);
const ingestionDone = yield* Deferred.make<void>();
const layerTest = RunExecutionService.layer.pipe(
Layer.provide(
@@ -2609,11 +2603,11 @@ it.effect(
completedAt: runningChildNode.startedAt,
},
},
- ] satisfies ReadonlyArray<ProviderAdapterV2Event>),
+ ] satisfies ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>),
close: Deferred.succeed(ingestionDone, undefined),
}),
startTurn: () => Effect.void,
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: ids.runId,
threadId: ids.threadId,
@@ -2940,11 +2934,11 @@ it.effect(
},
},
rootTerminalEvent(ids, "interrupted"),
- ] satisfies ReadonlyArray<ProviderAdapterV2Event>),
+ ] satisfies ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>),
close: Deferred.succeed(ingestionDone, undefined),
}),
startTurn: () => Effect.void,
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: ids.runId,
threadId: ids.threadId,
@@ -3439,7 +3433,7 @@ it.effect("refreshes pull requests after a provider stream exits with an error",
shouldFinalizeRun: () => Effect.succeed(true),
events: () =>
Stream.fail(
- new ProviderAdapterEventStreamError({
+ new ProviderAdapter.ProviderAdapterEventStreamError({
driver,
providerSessionId: ProviderSessionId.make("session:exited"),
cause: "provider process exited",
@@ -3468,7 +3462,7 @@ it.effect("refreshes pull requests only once when startup failure closes its eve
Deferred.await(ingestionStarted).pipe(
Effect.andThen(
Effect.fail(
- new ProviderAdapterTurnStartError({
+ new ProviderAdapter.ProviderAdapterTurnStartError({
driver,
threadId: input.threadId,
providerThreadId: input.providerThread.id,
@@ -3506,8 +3500,11 @@ function captureRootRunTermination(input: {
readonly seedOpenSubagent?: boolean;
readonly events?: (
ids: BackgroundScenarioIds,
- ) => Stream.Stream<ProviderAdapterV2Event, ProviderAdapterV2Error>;
- readonly startTurn?: ProviderAdapterV2SessionRuntime["startTurn"];
+ ) => Stream.Stream<
+ ProviderAdapter.ProviderAdapterV2Event,
+ ProviderAdapter.ProviderAdapterV2Error
+ >;
+ readonly startTurn?: ProviderAdapter.ProviderAdapterV2SessionRuntime["startTurn"];
readonly refreshAfterTurn?: Effect.Effect<void>;
}) {
return Effect.gen(function* () {
@@ -3622,11 +3619,11 @@ function captureRootRunTermination(input: {
]
: []),
rootTerminalEvent(ids, "interrupted"),
- ] satisfies ReadonlyArray<ProviderAdapterV2Event>),
+ ] satisfies ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>),
close: Deferred.succeed(ingestionDone, undefined),
}),
startTurn: input.startTurn ?? (() => Effect.void),
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: ids.runId,
threadId: ids.threadId,
@@ -3716,7 +3713,9 @@ function backgroundScenarioIds(key: string): BackgroundScenarioIds {
};
}
-function childThreadCreatedEvent(ids: BackgroundScenarioIds): ProviderAdapterV2Event {
+function childThreadCreatedEvent(
+ ids: BackgroundScenarioIds,
+): ProviderAdapter.ProviderAdapterV2Event {
return {
type: "app_thread.created",
driver,
@@ -3728,14 +3727,14 @@ function childThreadCreatedEvent(ids: BackgroundScenarioIds): ProviderAdapterV2E
rootThreadId: ids.threadId,
},
},
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
}
function childBackgroundTurnItemEvent(
ids: BackgroundScenarioIds,
status: "running" | "completed" | "idle",
ordinal: number,
-): ProviderAdapterV2Event {
+): ProviderAdapter.ProviderAdapterV2Event {
return {
type: "turn_item.updated",
driver,
@@ -3748,7 +3747,7 @@ function childBackgroundTurnItemEvent(
type: "command_execution",
status,
},
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
}
function backgroundTurnItemEvent(
@@ -3757,7 +3756,7 @@ function backgroundTurnItemEvent(
status: "running" | "completed" | "idle",
ordinal: number,
itemId?: TurnItemId,
-): ProviderAdapterV2Event {
+): ProviderAdapter.ProviderAdapterV2Event {
return {
type: "turn_item.updated",
driver,
@@ -3770,7 +3769,7 @@ function backgroundTurnItemEvent(
type,
status,
},
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
}
function backgroundTurnItemEventForRun(
@@ -3779,7 +3778,7 @@ function backgroundTurnItemEventForRun(
type: "command_execution" | "dynamic_tool" | "subagent",
status: "running" | "completed" | "idle",
ordinal: number,
-): ProviderAdapterV2Event {
+): ProviderAdapter.ProviderAdapterV2Event {
const event = backgroundTurnItemEvent(ids, type, status, ordinal);
if (event.type !== "turn_item.updated") {
return event;
@@ -3790,7 +3789,7 @@ function backgroundTurnItemEventForRun(
function subagentEvent(
ids: BackgroundScenarioIds,
status: "running" | "completed" | "idle",
-): ProviderAdapterV2Event {
+): ProviderAdapter.ProviderAdapterV2Event {
return {
type: "subagent.updated",
driver,
@@ -3800,7 +3799,7 @@ function subagentEvent(
runId: ids.runId,
status,
},
- } as ProviderAdapterV2Event;
+ } as ProviderAdapter.ProviderAdapterV2Event;
}
function makeRunOwnedSubagentFixture(input: {
@@ -3977,7 +3976,7 @@ function makeRunOwnedSubagentChildNodeFixture(input: {
function rootTerminalEvent(
ids: BackgroundScenarioIds,
status: "completed" | "interrupted" | "cancelled" | "failed",
-): ProviderAdapterV2Event {
+): ProviderAdapter.ProviderAdapterV2Event {
const common = {
type: "turn.terminal" as const,
driver,
@@ -4003,7 +4002,7 @@ function rootTerminalEvent(
function runBackgroundItemScenario(
key: string,
- makeEvents: (ids: BackgroundScenarioIds) => ReadonlyArray<ProviderAdapterV2Event>,
+ makeEvents: (ids: BackgroundScenarioIds) => ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>,
options?: {
readonly keepEventStreamOpen?: boolean;
readonly loadInheritedBackgroundTurnItems?: () => Effect.Effect<
@@ -4082,7 +4081,7 @@ function runBackgroundItemScenario(
};
}),
startTurn: () => Effect.void,
- } as unknown as ProviderAdapterV2SessionRuntime,
+ } as unknown as ProviderAdapter.ProviderAdapterV2SessionRuntime,
run: {
id: ids.runId,
threadId: ids.threadId,
diff --git a/apps/server/src/orchestration-v2/RunExecutionService.ts b/apps/server/src/orchestration-v2/RunExecutionService.ts
index 111aced2865..a316ce0ccd6 100644
--- a/apps/server/src/orchestration-v2/RunExecutionService.ts
+++ b/apps/server/src/orchestration-v2/RunExecutionService.ts
@@ -41,13 +41,7 @@ import * as ServerSettings from "../serverSettings.ts";
import * as CheckpointService from "./CheckpointService.ts";
import * as EventSink from "./EventSink.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import type {
- ProviderAdapterV2Event,
- ProviderAdapterV2RuntimePolicy,
- ProviderAdapterV2SessionRuntime,
- ProviderAdapterV2TurnMessage,
-} from "@t3tools/provider-core/server/ProviderAdapter";
-import { ProviderAdapterTurnStartError } from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderEventIngestor from "./ProviderEventIngestor.ts";
import type { ProjectionStoreV2Error } from "./ProjectionStore.ts";
import {
@@ -79,7 +73,10 @@ export interface InheritedBackgroundTurnItemRoute {
readonly runId: OrchestrationV2Run["id"];
}
-type ProviderTerminalEvent = Extract<ProviderAdapterV2Event, { readonly type: "turn.terminal" }>;
+type ProviderTerminalEvent = Extract<
+ ProviderAdapter.ProviderAdapterV2Event,
+ { readonly type: "turn.terminal" }
+>;
function isTerminalProviderTurnStatus(status: OrchestrationV2ProviderTurn["status"]): boolean {
return (
@@ -351,7 +348,7 @@ export function makeProviderEventRoutingState(input: {
}
export function routeProviderEvent(
- event: ProviderAdapterV2Event,
+ event: ProviderAdapter.ProviderAdapterV2Event,
input: ProviderEventRouteIdentity,
state: ProviderEventRoutingState,
): readonly [boolean, ProviderEventRoutingState] {
@@ -503,7 +500,7 @@ export interface RunExecutionServiceV2StartRootRunInput {
readonly commandId: CommandId;
readonly appThread: OrchestrationV2AppThread;
readonly providerSessionId: ProviderSessionId;
- readonly session: ProviderAdapterV2SessionRuntime;
+ readonly session: ProviderAdapter.ProviderAdapterV2SessionRuntime;
readonly run: OrchestrationV2Run;
readonly rootNode: OrchestrationV2ExecutionNode;
readonly checkpointScope: OrchestrationV2CheckpointScope;
@@ -521,9 +518,9 @@ export interface RunExecutionServiceV2StartRootRunInput {
readonly shouldStartProviderTurn?: () => Effect.Effect<boolean, ProjectionStoreV2Error>;
readonly shouldFinalizeRun?: () => Effect.Effect<boolean, ProjectionStoreV2Error>;
readonly hasUnpairedRunInterruptRequest?: () => Effect.Effect<boolean, never>;
- readonly message: ProviderAdapterV2TurnMessage;
+ readonly message: ProviderAdapter.ProviderAdapterV2TurnMessage;
readonly modelSelection: ModelSelection;
- readonly runtimePolicy: ProviderAdapterV2RuntimePolicy;
+ readonly runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
}
export interface RunExecutionServiceV2Shape {
@@ -738,7 +735,6 @@ export const layer: Layer.Layer<
providerInstanceId: input.run.providerInstanceId,
occurredAt: completedAt,
payload: makeProviderFailureTurnItem({
- idAllocator,
driver: input.terminal.driver,
threadId: input.run.threadId,
runId: input.run.id,
@@ -1006,7 +1002,10 @@ export const layer: Layer.Layer<
}
yield* Ref.set(rootRunFinalized, true);
});
- const trackChildLifecycle = (event: ProviderAdapterV2Event, deliverable: boolean) =>
+ const trackChildLifecycle = (
+ event: ProviderAdapter.ProviderAdapterV2Event,
+ deliverable: boolean,
+ ) =>
Effect.gen(function* () {
const routing = yield* Ref.get(eventRouting);
if (event.type === "provider_turn.updated") {
@@ -1403,7 +1402,7 @@ export const layer: Layer.Layer<
const startTurn = compact
? (input.session.compactThread?.(turnInput) ??
Effect.fail(
- new ProviderAdapterTurnStartError({
+ new ProviderAdapter.ProviderAdapterTurnStartError({
driver: input.session.driver,
threadId: input.run.threadId,
providerThreadId: input.providerThread.id,
@@ -1471,7 +1470,7 @@ export const layer: Layer.Layer<
);
export function makeInterruptResultTurnItem(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly run: OrchestrationV2Run;
readonly rootNode: OrchestrationV2ExecutionNode;
readonly providerThread: OrchestrationV2ProviderThread;
diff --git a/apps/server/src/orchestration-v2/RuntimePolicy.ts b/apps/server/src/orchestration-v2/RuntimePolicy.ts
index a512b7dcabe..6d6fcf82d64 100644
--- a/apps/server/src/orchestration-v2/RuntimePolicy.ts
+++ b/apps/server/src/orchestration-v2/RuntimePolicy.ts
@@ -12,10 +12,7 @@ import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import * as ProviderInstanceRegistry from "../provider/ProviderInstanceRegistry.ts";
-import {
- ProviderAdapterV2RuntimePolicy,
- type ProviderAdapterV2RuntimePolicy as ProviderAdapterV2RuntimePolicyType,
-} from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProjectStore from "./ProjectStore.ts";
/**
@@ -52,7 +49,7 @@ export interface RuntimePolicyV2Shape {
readonly resolve: (input: {
readonly thread: OrchestrationV2AppThread;
readonly modelSelection: ModelSelection;
- }) => Effect.Effect<ProviderAdapterV2RuntimePolicyType, RuntimePolicyV2Error>;
+ }) => Effect.Effect<ProviderAdapter.ProviderAdapterV2RuntimePolicy, RuntimePolicyV2Error>;
}
export class RuntimePolicyV2 extends Context.Service<RuntimePolicyV2, RuntimePolicyV2Shape>()(
@@ -128,7 +125,7 @@ export const layerFromProjectStore: Layer.Layer<
}),
),
));
- return ProviderAdapterV2RuntimePolicy.make({
+ return ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: providerRuntimeMode(input.thread.runtimeMode, supportedRuntimeModes),
interactionMode: input.thread.interactionMode,
cwd,
@@ -149,7 +146,7 @@ export function layerWithOverride(
resolve: (input) =>
base.resolve(input).pipe(
Effect.map((policy) =>
- ProviderAdapterV2RuntimePolicy.make({
+ ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
...policy,
...(override.cwd === undefined ? {} : { cwd: override.cwd }),
...(override.approvalPolicy === undefined
diff --git a/apps/server/src/orchestration-v2/RuntimeRequestService.test.ts b/apps/server/src/orchestration-v2/RuntimeRequestService.test.ts
index eb467025810..11dedc6ab47 100644
--- a/apps/server/src/orchestration-v2/RuntimeRequestService.test.ts
+++ b/apps/server/src/orchestration-v2/RuntimeRequestService.test.ts
@@ -12,7 +12,7 @@ import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
-import type { ProviderAdapterV2RuntimeRequestResponseInput } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProjectionStore from "./ProjectionStore.ts";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
import * as RuntimeRequestService from "./RuntimeRequestService.ts";
@@ -69,7 +69,7 @@ it.effect("forwards orchestrator-resolved runtime requests to the live adapter",
const providerSessionId = ProviderSessionId.make("provider-session-runtime-request-resolved");
const requestId = RuntimeRequestId.make("request-resolved");
const respondToRuntimeRequest = vi.fn(
- (_input: ProviderAdapterV2RuntimeRequestResponseInput) => Effect.void,
+ (_input: ProviderAdapter.ProviderAdapterV2RuntimeRequestResponseInput) => Effect.void,
);
const getSession = vi.fn(() =>
Effect.succeed(
@@ -133,7 +133,7 @@ it.effect("rejects expired runtime requests before invoking the live adapter", (
const providerSessionId = ProviderSessionId.make("provider-session-runtime-request-expired");
const requestId = RuntimeRequestId.make("request-expired");
const respondToRuntimeRequest = vi.fn(
- (_input: ProviderAdapterV2RuntimeRequestResponseInput) => Effect.void,
+ (_input: ProviderAdapter.ProviderAdapterV2RuntimeRequestResponseInput) => Effect.void,
);
const getSession = vi.fn(() =>
Effect.succeed(
diff --git a/apps/server/src/orchestration-v2/SelectionRestart.integration.test.ts b/apps/server/src/orchestration-v2/SelectionRestart.integration.test.ts
index 425336ac29e..958fb89cc8e 100644
--- a/apps/server/src/orchestration-v2/SelectionRestart.integration.test.ts
+++ b/apps/server/src/orchestration-v2/SelectionRestart.integration.test.ts
@@ -28,15 +28,10 @@ import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as EffectWorker from "./EffectWorker.ts";
import * as EventSink from "./EventSink.ts";
import * as Orchestrator from "./Orchestrator.ts";
-import {
- ProviderAdapterOpenSessionError,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2Shape,
- type ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const driver = ProviderDriverKind.make("codex");
const providerInstanceId = ProviderInstanceId.make("codex-restart-test");
@@ -69,7 +64,7 @@ const exclusiveCapabilities: OrchestrationV2ProviderCapabilities = {
};
interface ActiveTurn {
- readonly input: ProviderAdapterV2TurnInput;
+ readonly input: ProviderAdapter.ProviderAdapterV2TurnInput;
readonly providerTurnId: ProviderTurnId;
}
@@ -92,7 +87,7 @@ function makeRestartAdapter(
state: Ref.Ref<RestartAdapterState>,
sessionCapabilities: OrchestrationV2ProviderCapabilities = pooledCapabilities,
providerInstanceId = initialSelection.instanceId,
-): ProviderAdapterV2Shape {
+): ProviderAdapter.ProviderAdapterV2["Service"] {
return {
instanceId: providerInstanceId,
driver,
@@ -125,14 +120,14 @@ function makeRestartAdapter(
] as const;
});
if (failThisOpen) {
- return yield* new ProviderAdapterOpenSessionError({
+ return yield* new ProviderAdapter.ProviderAdapterOpenSessionError({
driver,
providerSessionId: sessionInput.providerSessionId,
cause: "simulated replacement open failure",
});
}
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
const now = yield* DateTime.now;
const providerSession: OrchestrationV2ProviderSession = {
id: sessionInput.providerSessionId,
@@ -290,7 +285,9 @@ function makeRestartAdapter(
};
}
-function makeCompletingHandoffAdapter(startCount: Ref.Ref<number>): ProviderAdapterV2Shape {
+function makeCompletingHandoffAdapter(
+ startCount: Ref.Ref<number>,
+): ProviderAdapter.ProviderAdapterV2["Service"] {
return {
instanceId: handoffProviderInstanceId,
driver: handoffDriver,
@@ -298,7 +295,7 @@ function makeCompletingHandoffAdapter(startCount: Ref.Ref<number>): ProviderAdap
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
openSession: (sessionInput) =>
Effect.gen(function* () {
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
const now = yield* DateTime.now;
return {
instanceId: handoffProviderInstanceId,
@@ -865,7 +862,7 @@ it.live.each(["active", "idle", "selection-command", "pooled", "separate-home"]
}),
})),
),
- } satisfies ProviderAdapterV2Shape;
+ } satisfies ProviderAdapter.ProviderAdapterV2["Service"];
});
const layerRegistry = Layer.succeed(ProviderAdapterRegistry.ProviderAdapterRegistryV2, {
get: (instanceId) =>
diff --git a/apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts b/apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts
index 8c28cbc03ce..730b72feea6 100644
--- a/apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts
+++ b/apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts
@@ -23,15 +23,10 @@ import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as EffectWorker from "./EffectWorker.ts";
import * as EventSink from "./EventSink.ts";
import * as Orchestrator from "./Orchestrator.ts";
-import {
- ProviderAdapterSteerRunError,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2Shape,
- type ProviderAdapterV2TurnInput,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const driver = ProviderDriverKind.make("codex");
const instanceId = ProviderInstanceId.make("codex");
@@ -67,8 +62,8 @@ it.effect.each(
Effect.scoped(
Effect.gen(function* () {
const cwd = yield* checkpointWorkspace(`steering-completion-${timing.replaceAll(" ", "-")}`);
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
- const started: ProviderAdapterV2TurnInput[] = [];
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
+ const started: ProviderAdapter.ProviderAdapterV2TurnInput[] = [];
const steerEntered = yield* Deferred.make<void>();
const rejectSteer = yield* Deferred.make<void>();
let steerCalls = 0;
@@ -80,7 +75,7 @@ it.effect.each(
activeSteeringInterruptsTools: timing === "with interrupting native steering",
},
};
- const adapter: ProviderAdapterV2Shape = {
+ const adapter: ProviderAdapter.ProviderAdapterV2["Service"] = {
instanceId,
driver,
getCapabilities: () => Effect.succeed(capabilities),
@@ -153,7 +148,7 @@ it.effect.each(
if (timing === "after delivery") return;
yield* Deferred.succeed(steerEntered, undefined);
yield* Deferred.await(rejectSteer);
- return yield* new ProviderAdapterSteerRunError({
+ return yield* new ProviderAdapter.ProviderAdapterSteerRunError({
driver,
providerThreadId: turn.providerThread.id,
providerTurnId: turn.providerTurnId,
@@ -424,8 +419,8 @@ const composerSelection = {
const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function* (name: string) {
const cwd = yield* checkpointWorkspace(name);
- const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
- const started: ProviderAdapterV2TurnInput[] = [];
+ const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
+ const started: ProviderAdapter.ProviderAdapterV2TurnInput[] = [];
const steered: string[] = [];
const capabilities = {
...CodexProviderCapabilitiesV2,
@@ -435,7 +430,7 @@ const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function*
supportsSteeringByInterruptRestart: false,
},
};
- const adapter: ProviderAdapterV2Shape = {
+ const adapter: ProviderAdapter.ProviderAdapterV2["Service"] = {
instanceId,
driver,
getCapabilities: () => Effect.succeed(capabilities),
diff --git a/apps/server/src/orchestration-v2/ThreadDeletion.ts b/apps/server/src/orchestration-v2/ThreadDeletion.ts
index fca9c05ae3e..1b326cc21c4 100644
--- a/apps/server/src/orchestration-v2/ThreadDeletion.ts
+++ b/apps/server/src/orchestration-v2/ThreadDeletion.ts
@@ -7,7 +7,7 @@ import type * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
import type { PendingOrchestrationEffectV2 } from "./EffectOutbox.ts";
-import type { IdAllocatorV2, IdAllocatorV2Error } from "@t3tools/provider-core/server/IdAllocator";
+import type * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
export interface ThreadDeletionPlan {
readonly events: ReadonlyArray<OrchestrationV2DomainEvent>;
@@ -23,8 +23,8 @@ export const planThreadDeletion = Effect.fn("ThreadDeletion.planThreadDeletion")
>;
readonly attachmentIds: ReadonlyArray<string>;
readonly now: DateTime.Utc;
- readonly idAllocator: IdAllocatorV2["Service"];
-}): Effect.fn.Return<ThreadDeletionPlan, IdAllocatorV2Error> {
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
+}): Effect.fn.Return<ThreadDeletionPlan, IdAllocator.IdAllocatorV2Error> {
const { command, projection, now, idAllocator } = input;
const events: Array<OrchestrationV2DomainEvent> = [];
const effects: Array<PendingOrchestrationEffectV2> = [];
diff --git a/apps/server/src/orchestration-v2/ThreadFork.execution.test.ts b/apps/server/src/orchestration-v2/ThreadFork.execution.test.ts
index 77e95378c8b..a1327741855 100644
--- a/apps/server/src/orchestration-v2/ThreadFork.execution.test.ts
+++ b/apps/server/src/orchestration-v2/ThreadFork.execution.test.ts
@@ -21,15 +21,15 @@ import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import { ClaudeProviderCapabilitiesV2 } from "./Adapters/ClaudeAdapterV2.ts";
import * as EventSink from "./EventSink.ts";
import * as Orchestrator from "./Orchestrator.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const forkCases = (["codex", "claudeAgent"] as const).flatMap((driverName) => {
const driver = ProviderDriverKind.make(driverName);
const instanceId = ProviderInstanceId.make(driver);
const modelSelection = { instanceId, model: "test-model" };
- const adapter: ProviderAdapterV2Shape = {
+ const adapter: ProviderAdapter.ProviderAdapterV2["Service"] = {
instanceId,
driver,
getCapabilities: () =>
diff --git a/apps/server/src/orchestration-v2/ThreadLaunchService.test.ts b/apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
index bfbd078e00c..dfa02f4f514 100644
--- a/apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
+++ b/apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
@@ -54,12 +54,12 @@ import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as CommandReceiptStore from "./CommandReceiptStore.ts";
import * as EffectOutbox from "./EffectOutbox.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ThreadLaunch from "./ThreadLaunchService.ts";
import * as ThreadManagement from "./ThreadManagementService.ts";
import * as ThreadTitleRegeneration from "./ThreadTitleRegenerationService.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const projectId = ProjectId.make("project:launch-test");
const otherProjectId = ProjectId.make("project:launch-other");
@@ -94,7 +94,7 @@ const adapter = {
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" as const }),
openSession: () => Effect.die("provider execution is disabled in launch tests"),
-} as ProviderAdapterV2Shape;
+} as ProviderAdapter.ProviderAdapterV2["Service"];
interface HarnessOptions {
readonly managedFolders?: Layer.Layer<ManagedProjectFolders.ManagedProjectFolders>;
diff --git a/apps/server/src/orchestration-v2/ThreadStop.test.ts b/apps/server/src/orchestration-v2/ThreadStop.test.ts
index 43a77a50e75..6c5874cb75f 100644
--- a/apps/server/src/orchestration-v2/ThreadStop.test.ts
+++ b/apps/server/src/orchestration-v2/ThreadStop.test.ts
@@ -24,10 +24,10 @@ import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import { OrchestrationEffectRequestV2 } from "./EffectOutbox.ts";
import * as Orchestrator from "./Orchestrator.ts";
import * as ProjectionStore from "./ProjectionStore.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ThreadManagementService from "./ThreadManagementService.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const instanceId = ProviderInstanceId.make("codex");
const modelSelection = { instanceId, model: "gpt-5.1-codex" };
@@ -37,7 +37,7 @@ const adapter = {
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" as const }),
openSession: () => Effect.die("Runs here never reach a provider"),
-} as ProviderAdapterV2Shape;
+} as ProviderAdapter.ProviderAdapterV2["Service"];
const layerDatabase = SqlitePersistence.layerMemory;
// No effect worker: runs stay unstarted, so Stop ends them without a provider.
const layerTest = ThreadManagementService.layer.pipe(
diff --git a/apps/server/src/orchestration-v2/ThreadTitleRegenerationService.test.ts b/apps/server/src/orchestration-v2/ThreadTitleRegenerationService.test.ts
index 392dc3fdaee..06f7aa2488c 100644
--- a/apps/server/src/orchestration-v2/ThreadTitleRegenerationService.test.ts
+++ b/apps/server/src/orchestration-v2/ThreadTitleRegenerationService.test.ts
@@ -22,11 +22,11 @@ import * as ServerSettings from "../serverSettings.ts";
import * as TextGeneration from "../textGeneration/TextGeneration.ts";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as EffectOutbox from "./EffectOutbox.ts";
-import type { ProviderAdapterV2Shape } from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ThreadManagement from "./ThreadManagementService.ts";
import * as ThreadTitleRegeneration from "./ThreadTitleRegenerationService.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const projectId = ProjectId.make("project:title-regeneration");
const modelSelection = {
@@ -40,7 +40,7 @@ const adapter = {
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" as const }),
openSession: () => Effect.die("provider execution is disabled in title regeneration tests"),
-} as ProviderAdapterV2Shape;
+} as ProviderAdapter.ProviderAdapterV2["Service"];
function makeHarness(
options: {
diff --git a/apps/server/src/orchestration-v2/assistantStreaming.test.ts b/apps/server/src/orchestration-v2/assistantStreaming.test.ts
index 2580936b0df..8e36a5abd75 100644
--- a/apps/server/src/orchestration-v2/assistantStreaming.test.ts
+++ b/apps/server/src/orchestration-v2/assistantStreaming.test.ts
@@ -2,9 +2,9 @@ import { describe, expect, it } from "vite-plus/test";
import { MessageId, NodeId, ProviderDriverKind, ThreadId, TurnItemId } from "@t3tools/contracts";
import * as DateTime from "effect/DateTime";
import { makeAssistantStreamingFilter, splitBufferedAssistantText } from "./assistantStreaming.ts";
-import type { ProviderAdapterV2Event } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
-const message = (text: string, streaming = true): ProviderAdapterV2Event => ({
+const message = (text: string, streaming = true): ProviderAdapter.ProviderAdapterV2Event => ({
type: "message.updated",
driver: ProviderDriverKind.make("codex"),
message: {
@@ -27,7 +27,7 @@ const turnItem = (
text: string,
streaming = true,
type: "assistant_message" | "reasoning" = "assistant_message",
-): ProviderAdapterV2Event => ({
+): ProviderAdapter.ProviderAdapterV2Event => ({
type: "turn_item.updated",
driver: ProviderDriverKind.make("codex"),
turnItem: {
@@ -108,7 +108,7 @@ describe("V2 assistant streaming", () => {
"suppresses running assistant nodes in %s mode while delivering tool and completed nodes",
(mode) => {
const filter = makeAssistantStreamingFilter(mode);
- const running: Extract<ProviderAdapterV2Event, { type: "node.updated" }> = {
+ const running: Extract<ProviderAdapter.ProviderAdapterV2Event, { type: "node.updated" }> = {
type: "node.updated",
driver: ProviderDriverKind.make("codex"),
node: {
diff --git a/apps/server/src/orchestration-v2/assistantStreaming.ts b/apps/server/src/orchestration-v2/assistantStreaming.ts
index 4c70dbbfc35..d17b73daebf 100644
--- a/apps/server/src/orchestration-v2/assistantStreaming.ts
+++ b/apps/server/src/orchestration-v2/assistantStreaming.ts
@@ -1,5 +1,5 @@
import type { ResponseStreamingMode } from "@t3tools/contracts";
-import type { ProviderAdapterV2Event } from "@t3tools/provider-core/server/ProviderAdapter";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
// An opening fence may sit at any indentation, since fences inside list
// items are indented past the marker. A closing fence may be indented at most
@@ -91,7 +91,10 @@ export function splitBufferedAssistantText(text: string): { ready: string; rest:
/** Buffer assistant messages and reasoning alike, keeping unfinished markdown out of the read model. */
export function makeAssistantStreamingFilter(mode: ResponseStreamingMode) {
const delivered = new Map<string, { text: string; at: number }>();
- return (event: ProviderAdapterV2Event, now: number): ProviderAdapterV2Event | null => {
+ return (
+ event: ProviderAdapter.ProviderAdapterV2Event,
+ now: number,
+ ): ProviderAdapter.ProviderAdapterV2Event | null => {
if (
event.type === "node.updated" &&
event.node.kind === "assistant_message" &&
diff --git a/apps/server/src/orchestration-v2/legacy/LegacyV1Cutover.integration.test.ts b/apps/server/src/orchestration-v2/legacy/LegacyV1Cutover.integration.test.ts
index 803bc7ce090..9ae1e74b941 100644
--- a/apps/server/src/orchestration-v2/legacy/LegacyV1Cutover.integration.test.ts
+++ b/apps/server/src/orchestration-v2/legacy/LegacyV1Cutover.integration.test.ts
@@ -44,14 +44,10 @@ import * as LegacyV1ThreadImporter from "./LegacyV1ThreadImporter.ts";
import * as Orchestrator from "../Orchestrator.ts";
import * as ProjectionMaintenance from "../ProjectionMaintenance.ts";
import * as ProjectionStore from "../ProjectionStore.ts";
-import {
- ProviderAdapterProtocolError,
- type ProviderAdapterV2Event,
- type ProviderAdapterV2Shape,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "../testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const PROJECT_ID = "project:cutover";
const ACTIVE_THREAD = "thread:cutover:active";
@@ -422,7 +418,7 @@ interface CapturedTurn {
}
const unimplemented = (detail: string) =>
- Effect.fail(new ProviderAdapterProtocolError({ driver, detail }));
+ Effect.fail(new ProviderAdapter.ProviderAdapterProtocolError({ driver, detail }));
const makeCodexAdapter = (capturedTurns: Ref.Ref<ReadonlyArray<CapturedTurn>>) =>
({
@@ -432,7 +428,7 @@ const makeCodexAdapter = (capturedTurns: Ref.Ref<ReadonlyArray<CapturedTurn>>) =
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
openSession: (sessionInput) =>
Effect.gen(function* () {
- const events = yield* PubSub.unbounded<ProviderAdapterV2Event>();
+ const events = yield* PubSub.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
const now = yield* DateTime.now;
const providerSession: OrchestrationV2ProviderSession = {
id: sessionInput.providerSessionId,
@@ -551,7 +547,7 @@ const makeCodexAdapter = (capturedTurns: Ref.Ref<ReadonlyArray<CapturedTurn>>) =
failure: null,
threadDisposition: "reusable",
},
- ] satisfies ReadonlyArray<ProviderAdapterV2Event>);
+ ] satisfies ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event>);
}),
steerTurn: () => Effect.void,
interruptTurn: () => Effect.void,
@@ -561,7 +557,7 @@ const makeCodexAdapter = (capturedTurns: Ref.Ref<ReadonlyArray<CapturedTurn>>) =
forkThread: () => unimplemented("forkThread unused in cutover test"),
};
}),
- }) satisfies ProviderAdapterV2Shape;
+ }) satisfies ProviderAdapter.ProviderAdapterV2["Service"];
const waitForIdle = Effect.fn("LegacyV1Cutover.waitForIdle")(function* (threadId: ThreadId) {
const orchestrator = yield* Orchestrator.OrchestratorV2;
diff --git a/apps/server/src/orchestration-v2/runtimeLayer.test.ts b/apps/server/src/orchestration-v2/runtimeLayer.test.ts
index aed7f73e6c0..f28cbae6597 100644
--- a/apps/server/src/orchestration-v2/runtimeLayer.test.ts
+++ b/apps/server/src/orchestration-v2/runtimeLayer.test.ts
@@ -67,16 +67,13 @@ import * as PullRequestWatchReactor from "./PullRequestWatchReactor.ts";
import { PullRequestProviderError } from "../pullRequest/PullRequestProvider.ts";
import * as PullRequestService from "../pullRequest/PullRequestService.ts";
import * as ProjectStore from "./ProjectStore.ts";
-import type {
- ProviderAdapterV2SessionRuntime,
- ProviderAdapterV2Shape,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
import * as RuntimeLayer from "./runtimeLayer.ts";
import { shellStreamItemFromThreadShell } from "./ShellStream.ts";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import * as ThreadManagementService from "./ThreadManagementService.ts";
import * as ThreadCommandExecutor from "./ThreadCommandExecutor.ts";
+import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const layerPlatformTest = Layer.merge(
NodeServices.layer,
@@ -119,7 +116,7 @@ const orchestrationAdapter = {
getCapabilities: () => Effect.succeed(CodexProviderCapabilitiesV2),
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
openSession: () => Effect.die("sessions are not used by lifecycle tests"),
-} as ProviderAdapterV2Shape;
+} as ProviderAdapter.ProviderAdapterV2["Service"];
const providerInstance = {
instanceId: modelSelection.instanceId,
driverKind: driver,
@@ -928,7 +925,9 @@ it.layer(layerTest)("OrchestrationV2LayerLive", (it) => {
const sessionSpy = vi
.spyOn(sessions, "get")
.mockReturnValue(
- Effect.succeed(Option.some({ providerSession } as ProviderAdapterV2SessionRuntime)),
+ Effect.succeed(
+ Option.some({ providerSession } as ProviderAdapter.ProviderAdapterV2SessionRuntime),
+ ),
);
yield* Effect.addFinalizer(() => Effect.sync(() => sessionSpy.mockRestore()));
diff --git a/apps/server/src/orchestration-v2/runtimeLayer.ts b/apps/server/src/orchestration-v2/runtimeLayer.ts
index 5d736f1564b..2442a4fa010 100644
--- a/apps/server/src/orchestration-v2/runtimeLayer.ts
+++ b/apps/server/src/orchestration-v2/runtimeLayer.ts
@@ -30,7 +30,7 @@ import * as ProjectionStore from "./ProjectionStore.ts";
import * as ProjectionMaintenance from "./ProjectionMaintenance.ts";
import * as ProjectStore from "./ProjectStore.ts";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as ProviderContinuationService from "./ProviderContinuationService.ts";
import * as ThreadTitleRegenerationService from "./ThreadTitleRegenerationService.ts";
import * as ProviderEventIngestor from "./ProviderEventIngestor.ts";
diff --git a/apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts b/apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts
index d24ae5b624d..318bd28dd9b 100644
--- a/apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts
+++ b/apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts
@@ -35,7 +35,7 @@ import * as ProjectionStore from "../ProjectionStore.ts";
import * as ProjectStore from "../ProjectStore.ts";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import * as ProviderAuthService from "../../provider/ProviderAuthService.ts";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as ProviderContinuationService from "../ProviderContinuationService.ts";
import * as ProviderEventIngestor from "../ProviderEventIngestor.ts";
import * as ProviderRuntimeRecoveryService from "../ProviderRuntimeRecoveryService.ts";
diff --git a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
index e7633781036..9bde775d0d4 100644
--- a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
+++ b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
@@ -52,14 +52,6 @@ import * as EffectWorker from "../EffectWorker.ts";
import * as EffectOutbox from "../EffectOutbox.ts";
import * as ProjectionMaintenance from "../ProjectionMaintenance.ts";
import * as ProjectionStore from "../ProjectionStore.ts";
-import {
- type ProviderAdapterV2Event,
- type ProviderAdapterV2HistoricalContext,
- ProviderAdapterProtocolError,
- ProviderAdapterTurnStartError,
- type ProviderAdapterV2Shape,
- type ProviderAdapterV2SessionRuntime,
-} from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
import {
@@ -70,6 +62,7 @@ import {
} from "./fixtures/shared.ts";
import * as ProviderReplayHarness from "./ProviderReplayHarness.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
const encodeJson = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
@@ -95,7 +88,7 @@ interface CapturedTurn {
}
function unimplemented(driver: ProviderDriverKind, detail: string) {
- return Effect.fail(new ProviderAdapterProtocolError({ driver, detail }));
+ return Effect.fail(new ProviderAdapter.ProviderAdapterProtocolError({ driver, detail }));
}
function makeTestAdapter(input: {
@@ -116,7 +109,7 @@ function makeTestAdapter(input: {
readonly failResumeOnce?: Ref.Ref<boolean>;
readonly initialContextUsage?: OrchestrationV2ProviderThread["contextUsage"];
readonly getModelContextWindow?: (selection: ModelSelection) => number | undefined;
- readonly canReuseContextUsage?: ProviderAdapterV2SessionRuntime["canReuseContextUsage"];
+ readonly canReuseContextUsage?: ProviderAdapter.ProviderAdapterV2SessionRuntime["canReuseContextUsage"];
readonly tokenUsageByRunOrdinal?: Readonly<
Record<number, Omit<OrchestrationV2ProviderTurnTokenUsage, "updatedAt">>
>;
@@ -125,7 +118,7 @@ function makeTestAdapter(input: {
readonly holdRunOrdinal?: number;
readonly holdFirstTurn?: Deferred.Deferred<void>;
readonly releaseFirstTurn?: Deferred.Deferred<void>;
-}): ProviderAdapterV2Shape {
+}): ProviderAdapter.ProviderAdapterV2["Service"] {
return {
instanceId: input.instanceId,
driver: input.driver,
@@ -133,7 +126,7 @@ function makeTestAdapter(input: {
planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
openSession: (sessionInput) =>
Effect.gen(function* () {
- const events = yield* PubSub.unbounded<ProviderAdapterV2Event>();
+ const events = yield* PubSub.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
const now = yield* DateTime.now;
const providerSession: OrchestrationV2ProviderSession = {
id: sessionInput.providerSessionId,
@@ -148,7 +141,7 @@ function makeTestAdapter(input: {
lastError: null,
};
- const runtime: ProviderAdapterV2SessionRuntime = {
+ const runtime: ProviderAdapter.ProviderAdapterV2SessionRuntime = {
instanceId: input.instanceId,
driver: input.driver,
providerSessionId: sessionInput.providerSessionId,
@@ -204,7 +197,7 @@ function makeTestAdapter(input: {
...(input.injectedHistory === undefined
? {}
: {
- injectHistory: (history: ProviderAdapterV2HistoricalContext) =>
+ injectHistory: (history: ProviderAdapter.ProviderAdapterV2HistoricalContext) =>
Ref.update(input.injectedHistory!, (current) => [
...current,
...historyResponseItems(history.messages, history.context),
@@ -236,7 +229,7 @@ function makeTestAdapter(input: {
input.refuseStarts !== undefined &&
(yield* Ref.getAndUpdate(input.refuseStarts, (left) => Math.max(0, left - 1))) > 0
)
- return yield* new ProviderAdapterTurnStartError({
+ return yield* new ProviderAdapter.ProviderAdapterTurnStartError({
driver: input.driver,
threadId: turnInput.threadId,
providerThreadId: turnInput.providerThread.id,
@@ -280,7 +273,7 @@ function makeTestAdapter(input: {
input.responseByThreadId?.[turnInput.threadId]?.[turnInput.runOrdinal] ??
input.responseByRunOrdinal[turnInput.runOrdinal] ??
`${input.driver} response for run ${turnInput.runOrdinal}`;
- const providerEvents: ReadonlyArray<ProviderAdapterV2Event> = [
+ const providerEvents: ReadonlyArray<ProviderAdapter.ProviderAdapterV2Event> = [
{
type: "provider_turn.updated",
driver: input.driver,
diff --git a/apps/server/src/provider/CodexChatGptAuth.ts b/apps/server/src/provider/CodexChatGptAuth.ts
index b6845a02972..2eda1e31533 100644
--- a/apps/server/src/provider/CodexChatGptAuth.ts
+++ b/apps/server/src/provider/CodexChatGptAuth.ts
@@ -19,8 +19,8 @@ import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import * as Semaphore from "effect/Semaphore";
-import * as ProviderAuthFlow from "@t3tools/provider-core/server/ProviderAuthFlow";
-import type { ProviderAuthFlowContext } from "@t3tools/provider-core/server/ProviderAuthFlow";
+import * as ProviderAuthFlow from "@t3tools/provider-core/server/providerAuthFlow";
+import type { ProviderAuthFlowContext } from "@t3tools/provider-core/server/providerAuthFlow";
import { HttpClient, HttpClientRequest } from "effect/http";
import * as ProviderCredentialStore from "./ProviderCredentialStore.ts";
import { withChatGptSessionLock } from "./CodexChatGptSessionLock.ts";
diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts
index 33aa39f5598..7ae333fd1e4 100644
--- a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts
+++ b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts
@@ -29,7 +29,7 @@ import {
ANTIGRAVITY_AUTH_STDOUT_PREFIX,
resolveAntigravityInstanceDirectories,
} from "../antigravityAuthSupport.ts";
-import * as ProviderEventLoggers from "../ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as ModelManifest from "../ModelManifest.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import { AntigravityDriver } from "./AntigravityDriver.ts";
diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts
index d8710e901a4..3bac2a48953 100644
--- a/apps/server/src/provider/Drivers/AntigravityDriver.ts
+++ b/apps/server/src/provider/Drivers/AntigravityDriver.ts
@@ -18,7 +18,7 @@ import * as Stream from "effect/Stream";
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
import type { AcpError } from "effect-acp/errors";
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import {
isAntigravityTextGenerationAvailable,
makeAntigravityTextGeneration,
@@ -46,12 +46,12 @@ import {
removeAntigravitySessionFiles,
} from "../acp/AntigravitySessionFiles.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { makeAntigravityAdapterV2 } from "../../orchestration-v2/Adapters/AntigravityAdapterV2.ts";
import { makeAcpNativeLoggerFactory } from "@t3tools/provider-acp/server/nativeLogging";
import { ProviderDriverError } from "../Errors.ts";
import { makeAntigravityProvider } from "../AntigravityProvider.ts";
-import * as ProviderEventLoggers from "../ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as ModelCatalog from "@t3tools/provider-core/server/ModelCatalog";
import {
defaultProviderContinuationIdentity,
@@ -68,7 +68,7 @@ const isNodeRuntimeUnavailableError = Schema.is(NodeRuntimeUnavailableError);
export type AntigravityDriverEnv =
| AntigravityInstallation.AntigravityInstallation
- | ProviderHost
+ | ProviderHost.ProviderHost
| ChildProcessSpawner.ChildProcessSpawner
| Crypto.Crypto
| FileSystem.FileSystem
@@ -89,7 +89,7 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
- const host = yield* ProviderHost;
+ const host = yield* ProviderHost.ProviderHost;
const selfInvocation = yield* resolveSelfInvocation();
const installation = yield* AntigravityInstallation.AntigravityInstallation;
const loggers = yield* ProviderEventLoggers.ProviderEventLoggers;
diff --git a/apps/server/src/provider/Drivers/ClaudeDriver.ts b/apps/server/src/provider/Drivers/ClaudeDriver.ts
index 18ce1e481ef..33293d2bb11 100644
--- a/apps/server/src/provider/Drivers/ClaudeDriver.ts
+++ b/apps/server/src/provider/Drivers/ClaudeDriver.ts
@@ -24,10 +24,10 @@ import { HttpClient } from "effect/http";
import { ChildProcessSpawner } from "effect/process";
import { makeClaudeTextGeneration } from "../../textGeneration/ClaudeTextGeneration.ts";
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import * as ServerConfig from "../../config.ts";
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
-import * as ProviderEventLoggers from "../ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import {
createClaudeAdapterV2,
type ClaudeAdapterV2DriverEnv,
@@ -94,7 +94,7 @@ const UPDATE = makePackageManagedProviderMaintenanceResolver({
export type ClaudeDriverEnv =
| ClaudeAdapterV2DriverEnv
- | ProviderHost
+ | ProviderHost.ProviderHost
| ChildProcessSpawner.ChildProcessSpawner
| ResetCreditCoordinator.ResetCreditCoordinator
| Crypto.Crypto
@@ -121,7 +121,6 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
const { cwd } = yield* ServerConfig.ServerConfig;
const httpClient = yield* HttpClient.HttpClient;
const resetCreditCoordinator = yield* ResetCreditCoordinator.ResetCreditCoordinator;
- const host = yield* ProviderHost;
const catalogService = yield* ModelCatalog.ModelCatalog;
const modelCatalog = catalogService
.current(DRIVER_KIND)
@@ -237,7 +236,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
Effect.provideService(Path.Path, path),
);
- const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, host.settings);
+ const snapshotSettings = yield* makeProviderSnapshotSettingsSource(effectiveConfig);
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<ClaudeSettings>>({
resolveMaintenance,
getSettings: snapshotSettings.getSettings,
diff --git a/apps/server/src/provider/Drivers/CodexDriver.test.ts b/apps/server/src/provider/Drivers/CodexDriver.test.ts
index 72340b7471c..296cc27eb60 100644
--- a/apps/server/src/provider/Drivers/CodexDriver.test.ts
+++ b/apps/server/src/provider/Drivers/CodexDriver.test.ts
@@ -26,7 +26,7 @@ import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts";
import * as ServerConfig from "../../config.ts";
import * as ServerSettings from "../../serverSettings.ts";
import * as ResetCreditCoordinator from "../resetCreditCoordinator.ts";
-import * as ProviderEventLoggers from "../ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as ModelManifest from "../ModelManifest.ts";
import {
createProviderVersionAdvisory,
@@ -36,7 +36,7 @@ import {
import { CodexDriver } from "./CodexDriver.ts";
import * as CodexAdapterV2 from "../../orchestration-v2/Adapters/CodexAdapterV2.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter";
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import * as ProviderCredentialStore from "../ProviderCredentialStore.ts";
import * as ProviderHostLive from "../ProviderHostLive.ts";
@@ -214,7 +214,7 @@ it.layer(layerTest)("CodexDriver", (it) => {
threadId,
providerSessionId: ProviderSessionId.make("managed-account-session"),
modelSelection: { instanceId, model: "gpt-5.4" },
- runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
+ runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: serverConfig.stateDir,
diff --git a/apps/server/src/provider/Drivers/CodexDriver.ts b/apps/server/src/provider/Drivers/CodexDriver.ts
index a2e580330c3..0759be9b868 100644
--- a/apps/server/src/provider/Drivers/CodexDriver.ts
+++ b/apps/server/src/provider/Drivers/CodexDriver.ts
@@ -31,10 +31,10 @@ import { HttpClient } from "effect/http";
import { ChildProcessSpawner } from "effect/process";
import { makeCodexTextGeneration } from "../../textGeneration/CodexTextGeneration.ts";
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import * as ServerConfig from "../../config.ts";
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
-import * as ProviderEventLoggers from "../ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import {
createCodexAdapterV2,
type CodexAdapterV2DriverEnv,
@@ -109,7 +109,7 @@ function makeCodexMaintenanceResolver(sharedHomePath: string) {
*/
export type CodexDriverEnv =
| CodexAdapterV2DriverEnv
- | ProviderHost
+ | ProviderHost.ProviderHost
| ChildProcessSpawner.ChildProcessSpawner
| ResetCreditCoordinator.ResetCreditCoordinator
| Crypto.Crypto
@@ -147,7 +147,6 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
const fileSystem = yield* FileSystem.FileSystem;
const pathService = yield* Path.Path;
const httpClient = yield* HttpClient.HttpClient;
- const host = yield* ProviderHost;
const modelCatalog = yield* ModelCatalog.ModelCatalog;
const currentCatalog = modelCatalog.current(DRIVER_KIND);
const processEnv = mergeProviderInstanceEnvironment(environment);
@@ -231,7 +230,7 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
),
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
);
- const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, host.settings);
+ const snapshotSettings = yield* makeProviderSnapshotSettingsSource(effectiveConfig);
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<CodexSettings>>({
resolveMaintenance,
getSettings: snapshotSettings.getSettings,
diff --git a/apps/server/src/provider/Drivers/CodexManagedProvider.ts b/apps/server/src/provider/Drivers/CodexManagedProvider.ts
index 32d88e64487..a7181352b28 100644
--- a/apps/server/src/provider/Drivers/CodexManagedProvider.ts
+++ b/apps/server/src/provider/Drivers/CodexManagedProvider.ts
@@ -4,7 +4,7 @@ import * as Stream from "effect/Stream";
import * as Option from "effect/Option";
import { ChildProcessSpawner } from "effect/process";
import { makeCodexTextGeneration } from "../../textGeneration/CodexTextGeneration.ts";
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import { chatGptModels } from "../CodexChatGptModels.ts";
import { makeCodexManagedRuntime } from "../CodexManagedRuntime.ts";
import { ProviderDriverError } from "../Errors.ts";
@@ -31,7 +31,7 @@ export const makeManagedCodexProvider = Effect.fn("makeManagedCodexProvider")(fu
const { instanceId, enabled, displayName, accentColor, config } = input;
const http = yield* HttpClient.HttpClient;
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
- const host = yield* ProviderHost;
+ const host = yield* ProviderHost.ProviderHost;
const runtime = yield* makeCodexManagedRuntime({
instanceId,
enabled,
diff --git a/apps/server/src/provider/EventNdjsonLogger.ts b/apps/server/src/provider/EventNdjsonLogger.ts
index 1ec5c46d932..f8cbca0c131 100644
--- a/apps/server/src/provider/EventNdjsonLogger.ts
+++ b/apps/server/src/provider/EventNdjsonLogger.ts
@@ -9,7 +9,7 @@ import * as NodeFS from "node:fs";
import * as NodePath from "node:path";
import type { ThreadId } from "@t3tools/contracts";
-import type { EventNdjsonLogger } from "@t3tools/provider-core/server/ProviderEventLoggers";
+import type * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import { RotatingFileSink } from "@t3tools/shared/logging";
import { errorTag } from "@t3tools/shared/observability";
import * as Clock from "effect/Clock";
@@ -21,7 +21,7 @@ import * as Scope from "effect/Scope";
import * as SynchronizedRef from "effect/SynchronizedRef";
import { toSafeThreadAttachmentSegment } from "../attachmentStore.ts";
-import type { ResourceAttribution } from "../resourceTelemetry/ResourceAttribution.ts";
+import type * as ResourceAttribution from "../resourceTelemetry/ResourceAttribution.ts";
const MEBIBYTE = 1024 * 1024;
const DAY_MS = 24 * 60 * 60 * 1_000;
@@ -64,11 +64,9 @@ const transientAcpUpdates = new Set(["agent_message_chunk", "agent_thought_chunk
export type EventNdjsonStream = "native" | "canonical" | "orchestration";
-export type { EventNdjsonLogger };
-
export interface EventNdjsonLogStore {
readonly filePath: string;
- readonly logger: (stream: EventNdjsonStream) => EventNdjsonLogger;
+ readonly logger: (stream: EventNdjsonStream) => ProviderEventLoggers.EventNdjsonLogger;
readonly close: () => Effect.Effect<void>;
}
@@ -81,7 +79,7 @@ export interface EventNdjsonLogStoreOptions {
readonly retentionCheckIntervalMs?: number;
readonly maxBufferedBytes?: number;
readonly maxBufferedRecords?: number;
- readonly attribution?: ResourceAttribution["Service"];
+ readonly attribution?: ResourceAttribution.ResourceAttribution["Service"];
}
export interface EventNdjsonLoggerOptions extends EventNdjsonLogStoreOptions {
@@ -127,7 +125,7 @@ interface ResolvedOptions {
readonly retentionCheckIntervalMs: number;
readonly maxBufferedBytes: number;
readonly maxBufferedRecords: number;
- readonly attribution: ResourceAttribution["Service"] | undefined;
+ readonly attribution: ResourceAttribution.ResourceAttribution["Service"] | undefined;
}
export interface PendingRecord {
@@ -731,8 +729,8 @@ export const makeEventNdjsonLogStore = Effect.fnUntraced(function* (
yield* Scope.close(timerScope, Exit.void);
});
- const loggerViews = new Map<EventNdjsonStream, EventNdjsonLogger>();
- const logger = (stream: EventNdjsonStream): EventNdjsonLogger => {
+ const loggerViews = new Map<EventNdjsonStream, ProviderEventLoggers.EventNdjsonLogger>();
+ const logger = (stream: EventNdjsonStream): ProviderEventLoggers.EventNdjsonLogger => {
const existing = loggerViews.get(stream);
if (existing) return existing;
@@ -778,7 +776,11 @@ export const makeEventNdjsonLogStore = Effect.fnUntraced(function* (
}
});
- const view = { filePath, write, close: () => Effect.void } satisfies EventNdjsonLogger;
+ const view = {
+ filePath,
+ write,
+ close: () => Effect.void,
+ } satisfies ProviderEventLoggers.EventNdjsonLogger;
loggerViews.set(stream, view);
return view;
};
@@ -789,7 +791,7 @@ export const makeEventNdjsonLogStore = Effect.fnUntraced(function* (
export const makeEventNdjsonLogger = Effect.fnUntraced(function* (
filePath: string,
options: EventNdjsonLoggerOptions,
-): Effect.fn.Return<EventNdjsonLogger | undefined> {
+): Effect.fn.Return<ProviderEventLoggers.EventNdjsonLogger | undefined> {
const store = yield* makeEventNdjsonLogStore(filePath, options).pipe(
Effect.catch((error) =>
logWarning(error.message, { error }).pipe(
diff --git a/apps/server/src/provider/ProviderEventLoggers.ts b/apps/server/src/provider/ProviderEventLoggers.ts
deleted file mode 100644
index b31acbef952..00000000000
--- a/apps/server/src/provider/ProviderEventLoggers.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * ProviderEventLoggers — single observability service that owns the shared
- * provider event log store and exposes its two runtime views:
- *
- * - `native` — provider-protocol events as the SDK emits them, written
- * from inside each `<X>Adapter` factory.
- * - `canonical` — runtime events after `ProviderService` has normalized
- * them onto `ProviderRuntimeEvent`.
- *
- * Why a service tag and not constructor options?
- *
- * - Adapters are now constructed *inside* drivers (`<X>Driver.create()`),
- * not at the boot Layer. There is no longer a single `make<X>AdapterLive(options)`
- * call site where we can hand an `EventNdjsonLogger` in by hand.
- * - Multiple driver instances per kind (`codex_personal`, `codex_work`)
- * must share one underlying log store — opening N writers against the
- * same rotating file would race the rotation logic. Owning the loggers on
- * a single tag keeps that invariant intact.
- * - Tests can swap one (or both) loggers with in-memory recorders by
- * `Layer.succeed(ProviderEventLoggers, { native, canonical })` instead of
- * juggling per-Layer option threading.
- *
- * Both fields are optional because observability must not prevent startup.
- *
- * @module provider/ProviderEventLoggers
- */
-import * as Effect from "effect/Effect";
-import * as Layer from "effect/Layer";
-
-import * as ServerConfig from "../config.ts";
-import * as ResourceAttribution from "../resourceTelemetry/ResourceAttribution.ts";
-import {
- NoOpProviderEventLoggers,
- ProviderEventLoggers,
-} from "@t3tools/provider-core/server/ProviderEventLoggers";
-import * as EventNdjsonLogger from "./EventNdjsonLogger.ts";
-
-export { NoOpProviderEventLoggers, ProviderEventLoggers };
-
-/**
- * Builds both stream views over one shared store. Setup failures are logged
- * and downgraded to the no-op service so diagnostics never block startup.
- *
- * @public Service construction is part of the canonical Effect module API.
- */
-export const make = Effect.gen(function* () {
- const { providerEventLogPath } = yield* ServerConfig.ServerConfig;
- const attribution = yield* ResourceAttribution.ResourceAttribution;
- const store = yield* EventNdjsonLogger.makeEventNdjsonLogStore(providerEventLogPath, {
- attribution,
- }).pipe(
- Effect.catch((error) =>
- Effect.logWarning(error.message, { error }).pipe(
- Effect.annotateLogs({ scope: "provider-observability" }),
- Effect.as<EventNdjsonLogger.EventNdjsonLogStore | undefined>(undefined),
- ),
- ),
- );
-
- if (!store) {
- return ProviderEventLoggers.of(NoOpProviderEventLoggers);
- }
-
- yield* Effect.addFinalizer(() => store.close());
- return ProviderEventLoggers.of({
- native: store.logger("native"),
- canonical: store.logger("canonical"),
- });
-});
-
-export const layer = Layer.effect(ProviderEventLoggers, make);
diff --git a/apps/server/src/provider/ProviderHostLive.ts b/apps/server/src/provider/ProviderHostLive.ts
index 3a924b39bd6..14d08de50ee 100644
--- a/apps/server/src/provider/ProviderHostLive.ts
+++ b/apps/server/src/provider/ProviderHostLive.ts
@@ -1,10 +1,10 @@
/**
- * The server's implementation of `ProviderHost`, the only server surface
+ * The server's implementation of `ProviderHost.ProviderHost`, the only server surface
* provider drivers and adapters may use.
*
* @module provider/ProviderHostLive
*/
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import { ProviderCredentialError } from "@t3tools/provider-core/server/errors";
import * as Crypto from "effect/Crypto";
import * as Effect from "effect/Effect";
@@ -18,14 +18,14 @@ import * as ServerSettings from "../serverSettings.ts";
import * as ProviderCredentialStore from "./ProviderCredentialStore.ts";
export const layer = Layer.effect(
- ProviderHost,
+ ProviderHost.ProviderHost,
Effect.gen(function* () {
const config = yield* ServerConfig.ServerConfig;
const serverSettings = yield* ServerSettings.ServerSettingsService;
const backgroundPolicy = yield* BackgroundPolicy.BackgroundPolicy;
const secrets = yield* ServerSecretStore.ServerSecretStore;
const crypto = yield* Crypto.Crypto;
- return ProviderHost.of({
+ return ProviderHost.ProviderHost.of({
paths: {
cwd: config.cwd,
baseDir: config.baseDir,
diff --git a/apps/server/src/provider/ProviderInstanceRegistry.test.ts b/apps/server/src/provider/ProviderInstanceRegistry.test.ts
index 933751bdd39..81208e54091 100644
--- a/apps/server/src/provider/ProviderInstanceRegistry.test.ts
+++ b/apps/server/src/provider/ProviderInstanceRegistry.test.ts
@@ -61,7 +61,7 @@ import * as ModelManifest from "./ModelManifest.ts";
import * as OpenCodeRuntime from "@t3tools/provider-opencode/server/OpenCodeRuntime";
import * as OpenCodeServerLedger from "@t3tools/provider-opencode/server/OpenCodeServerLedger";
import * as ResetCreditCoordinator from "./resetCreditCoordinator.ts";
-import * as ProviderEventLoggers from "./ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import { makeProviderInstanceRegistry } from "./ProviderInstanceRegistry.ts";
import * as ProviderOrchestrationAdapterInfrastructure from "./ProviderOrchestrationAdapterInfrastructure.ts";
import * as ProviderHostLive from "./ProviderHostLive.ts";
diff --git a/apps/server/src/provider/ProviderInstanceRegistryHydration.ts b/apps/server/src/provider/ProviderInstanceRegistryHydration.ts
index 6048f48636e..822b69bcb81 100644
--- a/apps/server/src/provider/ProviderInstanceRegistryHydration.ts
+++ b/apps/server/src/provider/ProviderInstanceRegistryHydration.ts
@@ -40,7 +40,7 @@ import * as ProviderInstanceRegistryMutator from "./ProviderInstanceRegistryMuta
import * as ProviderOrchestrationAdapterInfrastructure from "./ProviderOrchestrationAdapterInfrastructure.ts";
import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRegistrySupport";
import * as ProviderHostLive from "./ProviderHostLive.ts";
-import type { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
+import type * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import type * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
import type * as ServerConfig from "../config.ts";
@@ -49,10 +49,10 @@ type ProviderInstanceRegistryHydrationEnv =
BuiltInDriversEnv,
| ProviderOrchestrationAdapterInfrastructure.ProviderOrchestrationAdapterInfrastructure
| AcpRegistrySupport.AcpRegistryCatalog
- | ProviderHost
+ | ProviderHost.ProviderHost
>
| Settings.ServerSettingsService
- // Requirements of the `ProviderHost` the drivers receive.
+ // Requirements of the `ProviderHost.ProviderHost` the drivers receive.
| BackgroundPolicy.BackgroundPolicy
| ServerConfig.ServerConfig;
diff --git a/apps/server/src/provider/ProviderOrchestrationAdapterInfrastructure.ts b/apps/server/src/provider/ProviderOrchestrationAdapterInfrastructure.ts
index 2cbb70fbbde..3dea8ca677e 100644
--- a/apps/server/src/provider/ProviderOrchestrationAdapterInfrastructure.ts
+++ b/apps/server/src/provider/ProviderOrchestrationAdapterInfrastructure.ts
@@ -4,7 +4,7 @@ import * as ClaudeAdapterV2 from "../orchestration-v2/Adapters/ClaudeAdapterV2.t
import * as CodexAdapterV2 from "../orchestration-v2/Adapters/CodexAdapterV2.ts";
import * as CursorAgentSdk from "@t3tools/provider-cursor/server/CursorAgentSdk";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
export type ProviderOrchestrationAdapterInfrastructure =
| ClaudeAdapterV2.ClaudeAgentSdkQueryRunner
diff --git a/apps/server/src/provider/ProviderRegistry.test.ts b/apps/server/src/provider/ProviderRegistry.test.ts
index 8653bd32ebd..f0ed9625441 100644
--- a/apps/server/src/provider/ProviderRegistry.test.ts
+++ b/apps/server/src/provider/ProviderRegistry.test.ts
@@ -47,7 +47,7 @@ import { applyProviderCompatibility } from "./providerCompatibility.ts";
import * as ResetCreditCoordinator from "./resetCreditCoordinator.ts";
import * as OpenCodeRuntime from "@t3tools/provider-opencode/server/OpenCodeRuntime";
import * as OpenCodeServerLedger from "@t3tools/provider-opencode/server/OpenCodeServerLedger";
-import * as ProviderEventLoggers from "./ProviderEventLoggers.ts";
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as ProviderInstanceRegistryHydration from "./ProviderInstanceRegistryHydration.ts";
import * as ServerConfig from "../config.ts";
import * as ServerSettingsModule from "../serverSettings.ts";
diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts
index 79fb63afb64..ab93e814e70 100644
--- a/apps/server/src/server.ts
+++ b/apps/server/src/server.ts
@@ -1,3 +1,4 @@
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import type { RelayManagedEndpointRuntimeConfig } from "@t3tools/contracts/relay";
import * as Clock from "effect/Clock";
import * as Random from "effect/Random";
@@ -42,7 +43,7 @@ import * as AnalyticsService from "./telemetry/AnalyticsService.ts";
import * as ProviderEventIngestor from "./orchestration-v2/ProviderEventIngestor.ts";
import * as ModelManifest from "./provider/ModelManifest.ts";
import * as ResetCreditCoordinator from "./provider/resetCreditCoordinator.ts";
-import * as ProviderEventLoggers from "./provider/ProviderEventLoggers.ts";
+import * as EventNdjsonLogger from "./provider/EventNdjsonLogger.ts";
import * as OpenCodeRuntime from "@t3tools/provider-opencode/server/OpenCodeRuntime";
import * as OpenCodeServerLedger from "@t3tools/provider-opencode/server/OpenCodeServerLedger";
import * as ProviderHostLive from "./provider/ProviderHostLive.ts";
@@ -193,6 +194,30 @@ const layerApplicationObservability = EventLoopMonitor.layer.pipe(
Layer.provideMerge(layerResourceAttribution),
);
+// One rotating store behind both logger views, so driver instances never race
+// its rotation. Diagnostics must not block startup: a store that cannot open
+// degrades to the no-op loggers.
+const layerProviderEventLoggers = Layer.effect(
+ ProviderEventLoggers.ProviderEventLoggers,
+ Effect.gen(function* () {
+ const { providerEventLogPath } = yield* ServerConfig.ServerConfig;
+ const attribution = yield* ResourceAttribution.ResourceAttribution;
+ const store = yield* EventNdjsonLogger.makeEventNdjsonLogStore(providerEventLogPath, {
+ attribution,
+ }).pipe(
+ Effect.catch((error) =>
+ Effect.logWarning(error.message, { error }).pipe(
+ Effect.annotateLogs({ scope: "provider-observability" }),
+ Effect.as(undefined),
+ ),
+ ),
+ );
+ if (!store) return ProviderEventLoggers.NoOpProviderEventLoggers;
+ yield* Effect.addFinalizer(() => store.close());
+ return { native: store.logger("native"), canonical: store.logger("canonical") };
+ }),
+);
+
const layerPtyAdapter = NodePtyAdapter.layer;
const layerServerSettings = ServerSettings.layer.pipe(
@@ -599,17 +624,14 @@ const layerRuntimeCoreDependencies = layerRuntimeCoreDependenciesBase.pipe(
// Search, prepare, status inspection, and turn launch share one registry
// cache so every client and provider instance sees the same prepared agents.
Layer.provideMerge(AcpRegistrySupport.layerFromHost.pipe(Layer.provide(ProviderHostLive.layer))),
- // Shared native/canonical NDJSON writers used by both the per-instance
- // V2 drivers and the orchestration runtime. Provide resource attribution so
- // the rewritten telemetry pipeline can account for logical NDJSON writes.
- // Provided once at the runtime level so every consumer sees the same
- // logger instances.
+ // Provider event loggers are shared by every driver instance and the
+ // orchestration runtime, so they are provided once here.
// `ModelManifest.layer` is the model manifest, refreshed from the repo's
// `model-manifest.json` on `main`. Drivers read their entry through the
// `ModelCatalog` port it provides.
Layer.provideMerge(
Layer.mergeAll(
- ProviderEventLoggers.layer,
+ layerProviderEventLoggers,
ModelManifest.layerModelCatalog.pipe(Layer.provideMerge(ModelManifest.layer)),
ResetCreditCoordinator.layer,
),
diff --git a/packages/provider-acp-registry/src/server/auth.ts b/packages/provider-acp-registry/src/server/auth.ts
index 7189d5a4fde..72993a7a5f8 100644
--- a/packages/provider-acp-registry/src/server/auth.ts
+++ b/packages/provider-acp-registry/src/server/auth.ts
@@ -16,7 +16,7 @@ import { ChildProcessSpawner } from "effect/process";
import type * as AcpSchema from "effect-acp/compat";
import * as PtyAdapter from "@t3tools/shared/PtyAdapter";
-import * as ProviderAuthFlow from "@t3tools/provider-core/server/ProviderAuthFlow";
+import * as ProviderAuthFlow from "@t3tools/provider-core/server/providerAuthFlow";
import { normalizeAcpRegistryAuthMethods, normalizeAcpRegistryWebUrl } from "./probe.ts";
import * as AcpRegistrySupport from "./AcpRegistrySupport.ts";
import * as AcpRegistryRuntimeCoordinator from "./AcpRegistryRuntimeCoordinator.ts";
diff --git a/packages/provider-acp-registry/src/server/driver.ts b/packages/provider-acp-registry/src/server/driver.ts
index 17ca9ea3ddc..0e699bee5bf 100644
--- a/packages/provider-acp-registry/src/server/driver.ts
+++ b/packages/provider-acp-registry/src/server/driver.ts
@@ -21,7 +21,7 @@ import * as Schema from "effect/Schema";
import * as Semaphore from "effect/Semaphore";
import { ChildProcessSpawner } from "effect/process";
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
import { AcpRegistryAdapterV2Driver, type AcpRegistryAdapterV2DriverEnv } from "./adapter.ts";
import type { ProviderTextGeneration } from "@t3tools/provider-core/server/textGeneration";
import { ProviderDriverError } from "@t3tools/provider-core/server/errors";
@@ -455,7 +455,7 @@ export const checkAcpRegistryProviderReadiness = Effect.fn(
: snapshot;
});
-export type AcpRegistryDriverEnv = AcpRegistryAdapterV2DriverEnv | ProviderHost;
+export type AcpRegistryDriverEnv = AcpRegistryAdapterV2DriverEnv | ProviderHost.ProviderHost;
/** Canonical provider-instance wrapper for ACP Registry orchestration adapters. */
export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryDriverEnv> = {
@@ -485,7 +485,7 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
const crypto = yield* Crypto.Crypto;
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const hostEnvironment = yield* HostProcessEnvironment;
- const host = yield* ProviderHost;
+ const host = yield* ProviderHost.ProviderHost;
const continuationIdentity = defaultProviderContinuationIdentity({
driverKind: DRIVER_KIND,
instanceId,
@@ -619,7 +619,7 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
}
return { provider: enriched, generation: cacheState.generation };
});
- const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, host.settings);
+ const snapshotSettings = yield* makeProviderSnapshotSettingsSource(effectiveConfig);
const snapshot = yield* makeManagedServerProvider<
ProviderSnapshotSettings<AcpRegistrySettings>
>({
diff --git a/packages/provider-acp/src/server/adapter.ts b/packages/provider-acp/src/server/adapter.ts
index 65c168314fd..22052101981 100644
--- a/packages/provider-acp/src/server/adapter.ts
+++ b/packages/provider-acp/src/server/adapter.ts
@@ -95,7 +95,7 @@ import {
} from "@t3tools/provider-core/server/orchestrationInstructions";
import { buildRuntimeInstructions } from "@t3tools/provider-core/server/runtimeInstructions";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import { type ProviderContinuationRequest } from "@t3tools/provider-core/server/continuationRequests";
+import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import {
type BackgroundWork,
type BackgroundWorkReport,
@@ -499,7 +499,9 @@ export interface AcpAdapterV2Options {
* / history-only behavior for null-activeTurn updates.
*/
readonly continuationRequests?: {
- readonly offer: (request: ProviderContinuationRequest) => Effect.Effect<void>;
+ readonly offer: (
+ request: ProviderContinuationRequests.ProviderContinuationRequest,
+ ) => Effect.Effect<void>;
};
readonly testHooks?: {
/**
@@ -743,7 +745,7 @@ function nativeThreadId(
function makeProviderThread(input: {
readonly driver: ProviderDriverKind;
readonly providerInstanceId: ProviderInstanceId;
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly appThreadId: OrchestrationV2ProviderThread["appThreadId"];
readonly providerSessionId: OrchestrationV2ProviderThread["providerSessionId"];
readonly nativeThreadId: string;
@@ -2226,7 +2228,6 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
type: "turn_item.updated",
driver,
turnItem: makeProviderRetryTurnItem({
- idAllocator,
driver,
threadId: context.input.threadId,
runId: context.input.runId,
diff --git a/packages/provider-core/package.json b/packages/provider-core/package.json
index fe4b25b981b..2b7b653b6ba 100644
--- a/packages/provider-core/package.json
+++ b/packages/provider-core/package.json
@@ -23,10 +23,6 @@
"types": "./src/server/collectStreamText.ts",
"import": "./src/server/collectStreamText.ts"
},
- "./server/continuationRequests": {
- "types": "./src/server/continuationRequests.ts",
- "import": "./src/server/continuationRequests.ts"
- },
"./server/driver": {
"types": "./src/server/driver.ts",
"import": "./src/server/driver.ts"
@@ -103,9 +99,13 @@
"types": "./src/server/ProviderAdapter.ts",
"import": "./src/server/ProviderAdapter.ts"
},
- "./server/ProviderAuthFlow": {
- "types": "./src/server/ProviderAuthFlow.ts",
- "import": "./src/server/ProviderAuthFlow.ts"
+ "./server/providerAuthFlow": {
+ "types": "./src/server/providerAuthFlow.ts",
+ "import": "./src/server/providerAuthFlow.ts"
+ },
+ "./server/ProviderContinuationRequests": {
+ "types": "./src/server/ProviderContinuationRequests.ts",
+ "import": "./src/server/ProviderContinuationRequests.ts"
},
"./server/ProviderEventLoggers": {
"types": "./src/server/ProviderEventLoggers.ts",
diff --git a/packages/provider-core/src/server/IdAllocator.ts b/packages/provider-core/src/server/IdAllocator.ts
index cb31cfb5895..3382ca49a23 100644
--- a/packages/provider-core/src/server/IdAllocator.ts
+++ b/packages/provider-core/src/server/IdAllocator.ts
@@ -67,7 +67,7 @@ export class IdAllocatorV2AllocationError extends Schema.TaggedError<IdAllocator
export const IdAllocatorV2Error = Schema.Union([IdAllocatorV2AllocationError]);
export type IdAllocatorV2Error = typeof IdAllocatorV2Error.Type;
-export interface IdAllocatorV2AllocateShape {
+export interface IdAllocatorV2Allocate {
readonly command: (input: {
readonly fixtureName: string;
readonly commandName: string;
@@ -126,7 +126,7 @@ export interface IdAllocatorV2AllocateShape {
}) => Effect.Effect<PlanId, IdAllocatorV2Error>;
}
-export interface IdAllocatorV2DeriveShape {
+export interface IdAllocatorV2Derive {
readonly providerSession: (input: {
readonly providerInstanceId: ProviderInstanceId;
}) => ProviderSessionId;
@@ -180,14 +180,13 @@ export interface IdAllocatorV2DeriveShape {
readonly approvalTurnItem: (input: { readonly requestId: RuntimeRequestId }) => TurnItemId;
}
-export interface IdAllocatorV2Shape {
- readonly allocate: IdAllocatorV2AllocateShape;
- readonly derive: IdAllocatorV2DeriveShape;
-}
-
-export class IdAllocatorV2 extends Context.Service<IdAllocatorV2, IdAllocatorV2Shape>()(
- "@t3tools/provider-core/server/IdAllocator/IdAllocatorV2",
-) {}
+export class IdAllocatorV2 extends Context.Service<
+ IdAllocatorV2,
+ {
+ readonly allocate: IdAllocatorV2Allocate;
+ readonly derive: IdAllocatorV2Derive;
+ }
+>()("@t3tools/provider-core/server/IdAllocator/IdAllocatorV2") {}
const encodePart = (part: string | number): string => encodeURIComponent(String(part));
@@ -252,6 +251,49 @@ const randomId =
),
);
+/** Deterministic id derivations; pure, so callers that only derive need no allocator. */
+export const derive: IdAllocatorV2Derive = {
+ providerSession: (input) =>
+ ProviderSessionId.make(
+ joinId("provider-session", "provider-instance", input.providerInstanceId, "shared"),
+ ),
+ delegatedTaskNode: (input) => NodeId.make(joinId("node", "delegated-task", input.commandId)),
+ delegatedTaskThread: (input) =>
+ ThreadId.make(joinId("thread", "delegated-task", input.commandId)),
+ delegatedTaskMessage: (input) =>
+ MessageId.make(joinId("message", "delegated-task", input.commandId)),
+ delegatedTaskTurnItem: (input) =>
+ TurnItemId.make(joinId("turn-item", "delegated-task", input.commandId)),
+ createdThreadTurnItem: (input) =>
+ TurnItemId.make(joinId("turn-item", "created-thread", input.commandId)),
+ threadFromProviderThread: deriveThreadFromProviderThread,
+ run: (input) => RunId.make(joinId("run", "thread", input.threadId, "ordinal", input.ordinal)),
+ runAttempt: (input) =>
+ RunAttemptId.make(joinId("run-attempt", "run", input.runId, "attempt", input.attemptOrdinal)),
+ rootNode: (input) => NodeId.make(joinId("node", "run", input.runId, "root")),
+ rootNodeAttempt: (input) =>
+ NodeId.make(joinId("node", "run", input.runId, "attempt", input.attemptOrdinal, "root")),
+ userTurnItem: (input) => TurnItemId.make(joinId("turn-item", "message", input.messageId)),
+ runSignalTurnItem: (input) =>
+ TurnItemId.make(joinId("turn-item", "run", input.runId, "signal", input.signal)),
+ providerThread: deriveProviderThread,
+ providerTurn: (input) =>
+ ProviderTurnId.make(
+ joinId("provider-turn", "provider", input.driver, "native-turn", input.nativeTurnId),
+ ),
+ nodeFromProviderItem: (input) =>
+ NodeId.make(joinId("node", "provider", input.driver, "native-item", input.nativeItemId)),
+ messageFromProviderItem: (input) =>
+ MessageId.make(joinId("message", "provider", input.driver, "native-item", input.nativeItemId)),
+ turnItemFromProviderItem: (input) =>
+ TurnItemId.make(
+ joinId("turn-item", "provider", input.driver, "native-item", input.nativeItemId),
+ ),
+ approvalNode: (input) => NodeId.make(joinId("node", "runtime-request", input.requestId)),
+ approvalTurnItem: (input) =>
+ TurnItemId.make(joinId("turn-item", "runtime-request", input.requestId)),
+};
+
export const layer: Layer.Layer<IdAllocatorV2> = Layer.succeed(
IdAllocatorV2,
IdAllocatorV2.of({
@@ -386,50 +428,6 @@ export const layer: Layer.Layer<IdAllocatorV2> = Layer.succeed(
make: PlanId.make,
})(input),
},
- derive: {
- providerSession: (input) =>
- ProviderSessionId.make(
- joinId("provider-session", "provider-instance", input.providerInstanceId, "shared"),
- ),
- delegatedTaskNode: (input) => NodeId.make(joinId("node", "delegated-task", input.commandId)),
- delegatedTaskThread: (input) =>
- ThreadId.make(joinId("thread", "delegated-task", input.commandId)),
- delegatedTaskMessage: (input) =>
- MessageId.make(joinId("message", "delegated-task", input.commandId)),
- delegatedTaskTurnItem: (input) =>
- TurnItemId.make(joinId("turn-item", "delegated-task", input.commandId)),
- createdThreadTurnItem: (input) =>
- TurnItemId.make(joinId("turn-item", "created-thread", input.commandId)),
- threadFromProviderThread: deriveThreadFromProviderThread,
- run: (input) => RunId.make(joinId("run", "thread", input.threadId, "ordinal", input.ordinal)),
- runAttempt: (input) =>
- RunAttemptId.make(
- joinId("run-attempt", "run", input.runId, "attempt", input.attemptOrdinal),
- ),
- rootNode: (input) => NodeId.make(joinId("node", "run", input.runId, "root")),
- rootNodeAttempt: (input) =>
- NodeId.make(joinId("node", "run", input.runId, "attempt", input.attemptOrdinal, "root")),
- userTurnItem: (input) => TurnItemId.make(joinId("turn-item", "message", input.messageId)),
- runSignalTurnItem: (input) =>
- TurnItemId.make(joinId("turn-item", "run", input.runId, "signal", input.signal)),
- providerThread: deriveProviderThread,
- providerTurn: (input) =>
- ProviderTurnId.make(
- joinId("provider-turn", "provider", input.driver, "native-turn", input.nativeTurnId),
- ),
- nodeFromProviderItem: (input) =>
- NodeId.make(joinId("node", "provider", input.driver, "native-item", input.nativeItemId)),
- messageFromProviderItem: (input) =>
- MessageId.make(
- joinId("message", "provider", input.driver, "native-item", input.nativeItemId),
- ),
- turnItemFromProviderItem: (input) =>
- TurnItemId.make(
- joinId("turn-item", "provider", input.driver, "native-item", input.nativeItemId),
- ),
- approvalNode: (input) => NodeId.make(joinId("node", "runtime-request", input.requestId)),
- approvalTurnItem: (input) =>
- TurnItemId.make(joinId("turn-item", "runtime-request", input.requestId)),
- },
+ derive,
}),
);
diff --git a/packages/provider-core/src/server/ProviderAdapter.ts b/packages/provider-core/src/server/ProviderAdapter.ts
index c6e6ef48627..086300e2187 100644
--- a/packages/provider-core/src/server/ProviderAdapter.ts
+++ b/packages/provider-core/src/server/ProviderAdapter.ts
@@ -632,21 +632,20 @@ export interface ProviderAdapterV2SessionRuntime {
) => 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>()(
- "@t3tools/provider-core/server/ProviderAdapter/ProviderAdapterV2",
-) {}
+export class ProviderAdapterV2 extends Context.Service<
+ ProviderAdapterV2,
+ {
+ 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>;
+ }
+>()("@t3tools/provider-core/server/ProviderAdapter/ProviderAdapterV2") {}
diff --git a/packages/provider-core/src/server/continuationRequests.ts b/packages/provider-core/src/server/ProviderContinuationRequests.ts
similarity index 97%
rename from packages/provider-core/src/server/continuationRequests.ts
rename to packages/provider-core/src/server/ProviderContinuationRequests.ts
index f7c8606ace1..638068eb621 100644
--- a/packages/provider-core/src/server/continuationRequests.ts
+++ b/packages/provider-core/src/server/ProviderContinuationRequests.ts
@@ -59,7 +59,7 @@ export interface ProviderContinuationRequest {
export class ProviderContinuationRequests extends Context.Reference<{
readonly offer: (request: ProviderContinuationRequest) => Effect.Effect<void>;
readonly take: Effect.Effect<ProviderContinuationRequest>;
-}>("@t3tools/provider-core/server/continuationRequests/ProviderContinuationRequests", {
+}>("@t3tools/provider-core/server/ProviderContinuationRequests", {
defaultValue: () => ({ offer: () => Effect.void, take: Effect.never }),
}) {}
diff --git a/packages/provider-core/src/server/ProviderHost.ts b/packages/provider-core/src/server/ProviderHost.ts
index 050ad0882fd..858a7c1e22d 100644
--- a/packages/provider-core/src/server/ProviderHost.ts
+++ b/packages/provider-core/src/server/ProviderHost.ts
@@ -45,33 +45,32 @@ export interface ProviderCredentials {
readonly remove: Effect.Effect<void, ProviderCredentialError>;
}
-interface ProviderHostService {
- readonly paths: ProviderHostPaths;
- readonly settings: {
- readonly get: Effect.Effect<ServerSettings, ServerSettingsError>;
- /** Runs `use` on a settings snapshot that no settings write can change until it finishes. */
- readonly withSnapshot: <A, E, R>(
- use: (settings: ServerSettings) => Effect.Effect<A, E, R>,
- ) => Effect.Effect<A, E | ServerSettingsError, R>;
- /** Every settings change after subscription, starting with the next one. */
- readonly changes: Stream.Stream<ServerSettings>;
- /** Changes buffered from the moment the scoped subscription is acquired. */
- readonly subscribe: Effect.Effect<Stream.Stream<ServerSettings>, never, Scope.Scope>;
- };
- /** Whether background work for `scope` should run now (client demand and host power). */
- readonly shouldRunBackgroundWork: (scope: BackgroundScope) => Effect.Effect<boolean>;
- /**
- * Absolute path of a stored chat attachment, or `null` when its id does not
- * resolve inside the attachments directory.
- */
- readonly resolveAttachmentPath: (attachment: ChatAttachment) => string | null;
- /** The credentials stored for `bindingId`, usually an instance id, under a provider-chosen namespace. */
- readonly credentials: (
- namespace: string,
- bindingId: string,
- ) => Effect.Effect<ProviderCredentials>;
-}
-
-export class ProviderHost extends Context.Service<ProviderHost, ProviderHostService>()(
- "@t3tools/provider-core/server/ProviderHost",
-) {}
+export class ProviderHost extends Context.Service<
+ ProviderHost,
+ {
+ readonly paths: ProviderHostPaths;
+ readonly settings: {
+ readonly get: Effect.Effect<ServerSettings, ServerSettingsError>;
+ /** Runs `use` on a settings snapshot that no settings write can change until it finishes. */
+ readonly withSnapshot: <A, E, R>(
+ use: (settings: ServerSettings) => Effect.Effect<A, E, R>,
+ ) => Effect.Effect<A, E | ServerSettingsError, R>;
+ /** Every settings change after subscription, starting with the next one. */
+ readonly changes: Stream.Stream<ServerSettings>;
+ /** Changes buffered from the moment the scoped subscription is acquired. */
+ readonly subscribe: Effect.Effect<Stream.Stream<ServerSettings>, never, Scope.Scope>;
+ };
+ /** Whether background work for `scope` should run now (client demand and host power). */
+ readonly shouldRunBackgroundWork: (scope: BackgroundScope) => Effect.Effect<boolean>;
+ /**
+ * Absolute path of a stored chat attachment, or `null` when its id does not
+ * resolve inside the attachments directory.
+ */
+ readonly resolveAttachmentPath: (attachment: ChatAttachment) => string | null;
+ /** The credentials stored for `bindingId`, usually an instance id, under a provider-chosen namespace. */
+ readonly credentials: (
+ namespace: string,
+ bindingId: string,
+ ) => Effect.Effect<ProviderCredentials>;
+ }
+>()("@t3tools/provider-core/server/ProviderHost") {}
diff --git a/packages/provider-core/src/server/adapterDriver.ts b/packages/provider-core/src/server/adapterDriver.ts
index 7445dc7ed01..27f14323947 100644
--- a/packages/provider-core/src/server/adapterDriver.ts
+++ b/packages/provider-core/src/server/adapterDriver.ts
@@ -39,7 +39,7 @@ export interface ProviderAdapterDriver<Config, R = never> {
readonly create: (
input: ProviderAdapterDriverCreateInput<Config>,
) => Effect.Effect<
- ProviderAdapter.ProviderAdapterV2Shape,
+ ProviderAdapter.ProviderAdapterV2["Service"],
ProviderAdapterDriverCreateError,
R | Scope.Scope
>;
diff --git a/packages/provider-core/src/server/driver.ts b/packages/provider-core/src/server/driver.ts
index b177ba926ba..df215d31974 100644
--- a/packages/provider-core/src/server/driver.ts
+++ b/packages/provider-core/src/server/driver.ts
@@ -101,7 +101,7 @@ export interface ProviderInstance {
ProviderConsumeResetCreditOutcome,
ProviderDriverError
>;
- readonly orchestrationAdapter: ProviderAdapter.ProviderAdapterV2Shape;
+ readonly orchestrationAdapter: ProviderAdapter.ProviderAdapterV2["Service"];
readonly textGeneration: ProviderTextGeneration;
readonly auth?: ProviderAuthController;
readonly acpSessionManagement?: {
diff --git a/packages/provider-core/src/server/failure.ts b/packages/provider-core/src/server/failure.ts
index 8a745f83aaa..45c90822aaf 100644
--- a/packages/provider-core/src/server/failure.ts
+++ b/packages/provider-core/src/server/failure.ts
@@ -13,7 +13,7 @@ import type {
import * as DateTime from "effect/DateTime";
import * as Cause from "effect/Cause";
-import type * as IdAllocator from "./IdAllocator.ts";
+import * as IdAllocator from "./IdAllocator.ts";
import * as Schema from "effect/Schema";
/** Raised when portable history does not fit the target provider's context window. */
@@ -172,7 +172,6 @@ export function makeProviderFailure(input: {
}
export function makeProviderFailureTurnItem(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
readonly driver: ProviderDriverKind;
readonly threadId: ThreadId;
readonly runId: RunId | null;
@@ -186,7 +185,7 @@ export function makeProviderFailureTurnItem(input: {
readonly occurredAt: DateTime.Utc;
}): Extract<OrchestrationV2TurnItem, { readonly type: "error" }> {
return {
- id: input.idAllocator.derive.turnItemFromProviderItem({
+ id: IdAllocator.derive.turnItemFromProviderItem({
driver: input.driver,
nativeItemId: `terminal-failure:${input.providerTurnId}`,
}),
@@ -210,7 +209,6 @@ export function makeProviderFailureTurnItem(input: {
}
export function makeProviderRetryTurnItem(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
readonly driver: ProviderDriverKind;
readonly threadId: ThreadId;
readonly runId: RunId | null;
@@ -237,7 +235,7 @@ export function makeProviderRetryTurnItem(input: {
title = "Provider retry stopped";
}
return {
- id: input.idAllocator.derive.turnItemFromProviderItem({
+ id: IdAllocator.derive.turnItemFromProviderItem({
driver: input.driver,
nativeItemId: `terminal-failure:${input.providerTurnId}`,
}),
diff --git a/packages/provider-core/src/server/ProviderAuthFlow.test.ts b/packages/provider-core/src/server/providerAuthFlow.test.ts
similarity index 99%
rename from packages/provider-core/src/server/ProviderAuthFlow.test.ts
rename to packages/provider-core/src/server/providerAuthFlow.test.ts
index 5ea9a0fc2f3..2351243f1e0 100644
--- a/packages/provider-core/src/server/ProviderAuthFlow.test.ts
+++ b/packages/provider-core/src/server/providerAuthFlow.test.ts
@@ -16,7 +16,7 @@ import * as Option from "effect/Option";
import * as Stream from "effect/Stream";
import * as TestClock from "effect/testing/TestClock";
-import * as ProviderAuthFlow from "./ProviderAuthFlow.ts";
+import * as ProviderAuthFlow from "./providerAuthFlow.ts";
const instanceId = ProviderInstanceId.make("auth-flow-test");
const method = { id: "browser", name: "Browser", description: null, type: "agent" as const };
diff --git a/packages/provider-core/src/server/ProviderAuthFlow.ts b/packages/provider-core/src/server/providerAuthFlow.ts
similarity index 100%
rename from packages/provider-core/src/server/ProviderAuthFlow.ts
rename to packages/provider-core/src/server/providerAuthFlow.ts
diff --git a/packages/provider-core/src/server/snapshotSettings.ts b/packages/provider-core/src/server/snapshotSettings.ts
index f434d35b967..bf0996d0a15 100644
--- a/packages/provider-core/src/server/snapshotSettings.ts
+++ b/packages/provider-core/src/server/snapshotSettings.ts
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
import * as Equal from "effect/Equal";
import * as Stream from "effect/Stream";
-import type * as ProviderHost from "./ProviderHost.ts";
+import * as ProviderHost from "./ProviderHost.ts";
export interface ProviderSnapshotSettings<Settings> {
readonly provider: Settings;
@@ -27,17 +27,23 @@ export function haveProviderSnapshotSettingsChanged<Settings>(
return !Equal.equals(previous, next);
}
-export function makeProviderSnapshotSettingsSource<Settings>(
+/** The instance's settings paired with the host's server settings, as snapshots read them. */
+export const makeProviderSnapshotSettingsSource = <Settings>(
provider: Settings,
- settings: ProviderHost.ProviderHost["Service"]["settings"],
-): {
- readonly getSettings: Effect.Effect<ProviderSnapshotSettings<Settings>, ServerSettingsError>;
- readonly streamSettings: Stream.Stream<ProviderSnapshotSettings<Settings>>;
-} {
- const mapSettings = (settings: ServerSettings) =>
- makeProviderSnapshotSettings(provider, settings);
- return {
- getSettings: settings.get.pipe(Effect.map(mapSettings)),
- streamSettings: settings.changes.pipe(Stream.map(mapSettings)),
- };
-}
+): Effect.Effect<
+ {
+ readonly getSettings: Effect.Effect<ProviderSnapshotSettings<Settings>, ServerSettingsError>;
+ readonly streamSettings: Stream.Stream<ProviderSnapshotSettings<Settings>>;
+ },
+ never,
+ ProviderHost.ProviderHost
+> =>
+ Effect.gen(function* () {
+ const { settings } = yield* ProviderHost.ProviderHost;
+ const mapSettings = (current: ServerSettings) =>
+ makeProviderSnapshotSettings(provider, current);
+ return {
+ getSettings: settings.get.pipe(Effect.map(mapSettings)),
+ streamSettings: settings.changes.pipe(Stream.map(mapSettings)),
+ };
+ });
diff --git a/packages/provider-cursor/src/server/adapter.ts b/packages/provider-cursor/src/server/adapter.ts
index 5aa9e836bd7..8ebf8ea9a44 100644
--- a/packages/provider-cursor/src/server/adapter.ts
+++ b/packages/provider-cursor/src/server/adapter.ts
@@ -239,7 +239,7 @@ function providerSession(input: {
}
function makeProviderThread(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly providerInstanceId: ProviderInstanceId;
readonly appThreadId: OrchestrationV2ProviderThread["appThreadId"];
readonly providerSessionId: OrchestrationV2ProviderThread["providerSessionId"];
diff --git a/packages/provider-cursor/src/server/driver.ts b/packages/provider-cursor/src/server/driver.ts
index 157b7dca5c1..e007e8b6fda 100644
--- a/packages/provider-cursor/src/server/driver.ts
+++ b/packages/provider-cursor/src/server/driver.ts
@@ -223,7 +223,7 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
Effect.provide(CursorSdkCatalog.layer),
);
- const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, host.settings);
+ const snapshotSettings = yield* makeProviderSnapshotSettingsSource(effectiveConfig);
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<CursorSettings>>({
resolveMaintenance: () => Effect.succeed(MAINTENANCE_CAPABILITIES),
getSettings: snapshotSettings.getSettings,
diff --git a/packages/provider-grok/src/server/adapter.ts b/packages/provider-grok/src/server/adapter.ts
index b25faa9db4e..e8332425201 100644
--- a/packages/provider-grok/src/server/adapter.ts
+++ b/packages/provider-grok/src/server/adapter.ts
@@ -58,7 +58,7 @@ import { acpPermissionDisposition } from "@t3tools/provider-acp/server/clientPol
import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
import {
ProviderAdapterDriverCreateError,
diff --git a/packages/provider-grok/src/server/driver.ts b/packages/provider-grok/src/server/driver.ts
index e3201d0f03c..a2ce6ce4a41 100644
--- a/packages/provider-grok/src/server/driver.ts
+++ b/packages/provider-grok/src/server/driver.ts
@@ -160,7 +160,7 @@ export const GrokDriver: ProviderDriver<GrokSettings, GrokDriverEnv> = {
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
);
- const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, host.settings);
+ const snapshotSettings = yield* makeProviderSnapshotSettingsSource(effectiveConfig);
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<GrokSettings>>({
resolveMaintenance,
getSettings: snapshotSettings.getSettings,
diff --git a/packages/provider-muse/src/server/adapter.test.ts b/packages/provider-muse/src/server/adapter.test.ts
index 33191bb8e46..90071af22ed 100644
--- a/packages/provider-muse/src/server/adapter.test.ts
+++ b/packages/provider-muse/src/server/adapter.test.ts
@@ -36,7 +36,7 @@ import type { MuseItem } from "./protocol.ts";
import type { MuseSdkHost } from "./sdk.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
-import type { ProviderContinuationRequest } from "@t3tools/provider-core/server/continuationRequests";
+import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { makeMuseAdapterV2, type MuseAdapterV2Options } from "./adapter.ts";
const testLayer = Layer.mergeAll(
@@ -766,7 +766,7 @@ describe("MuseAdapterV2", () => {
it.effect("lets a user turn take a held Muse report turn, approvals included", () =>
Effect.gen(function* () {
const fake = yield* makeFakeMuse();
- const offers: Array<ProviderContinuationRequest> = [];
+ const offers: Array<ProviderContinuationRequests.ProviderContinuationRequest> = [];
const harness = yield* makeHarness(
fake,
INSTANCE_ID,
diff --git a/packages/provider-muse/src/server/adapter.ts b/packages/provider-muse/src/server/adapter.ts
index c834e1370eb..558a50960f8 100644
--- a/packages/provider-muse/src/server/adapter.ts
+++ b/packages/provider-muse/src/server/adapter.ts
@@ -74,7 +74,7 @@ import {
backgroundWorkNotification,
type BackgroundWorkReport,
} from "@t3tools/provider-core/server/notification";
-import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
import { turnScopedSelectionTransition } from "@t3tools/provider-core/server/selectionTransition";
import { museItemStatus, museToolPresentation } from "./itemPresentation.ts";
diff --git a/packages/provider-muse/src/server/driver.ts b/packages/provider-muse/src/server/driver.ts
index 805749f7ef8..2b35db227ff 100644
--- a/packages/provider-muse/src/server/driver.ts
+++ b/packages/provider-muse/src/server/driver.ts
@@ -14,7 +14,7 @@ import { makeMuseTextGeneration } from "./textGeneration.ts";
import { ProviderDriverError } from "@t3tools/provider-core/server/errors";
import { makeMuseAdapterV2 } from "./adapter.ts";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { checkMuseProviderStatus, makePendingMuseProvider } from "./status.ts";
import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import { makeManagedServerProvider } from "@t3tools/provider-core/server/managedProvider";
@@ -86,7 +86,7 @@ export const MuseDriver: ProviderDriver<MuseSettings, MuseDriverEnv> = {
accentColor,
continuationGroupKey: continuationIdentity.continuationKey,
});
- const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, host.settings);
+ const snapshotSettings = yield* makeProviderSnapshotSettingsSource(effectiveConfig);
const resolveInstallation = yield* makeCachedProviderMaintenanceResolution(
resolveProviderMaintenanceCapabilitiesEffect(museMaintenance, {
binaryPath: effectiveConfig.binaryPath,
diff --git a/packages/provider-opencode/src/server/adapter.ts b/packages/provider-opencode/src/server/adapter.ts
index 8c9f5e83ae6..0beb1c2147e 100644
--- a/packages/provider-opencode/src/server/adapter.ts
+++ b/packages/provider-opencode/src/server/adapter.ts
@@ -459,7 +459,7 @@ function formatOpenCodeProtocolLogPayload(event: OpenCodeProtocolLogEvent) {
export function makeOpenCodeProtocolLogger(input: {
readonly nativeEventLogger: ProviderEventLoggers.EventNdjsonLogger | undefined;
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly providerInstanceId: ProviderInstanceId;
readonly providerSessionId: ProviderSessionId;
readonly threadId: ThreadId;
@@ -830,7 +830,7 @@ function taskSessionId(part: ToolPart): string | null {
}
function makeProviderThread(input: {
- readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
+ readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
readonly providerInstanceId: ProviderInstanceId;
readonly providerSessionId: OrchestrationV2ProviderThread["providerSessionId"];
readonly appThreadId: OrchestrationV2ProviderThread["appThreadId"];
diff --git a/packages/provider-opencode/src/server/driver.ts b/packages/provider-opencode/src/server/driver.ts
index 9c37ab2abd4..fba34659806 100644
--- a/packages/provider-opencode/src/server/driver.ts
+++ b/packages/provider-opencode/src/server/driver.ts
@@ -123,9 +123,9 @@ function byOpenCodeRuntime<A, E, R, PE>(
*/
function selectOpenCodeRuntimeAdapter(input: {
readonly probe: OpenCodeRuntimeProbe;
- readonly v1: ProviderAdapter.ProviderAdapterV2Shape;
- readonly v2: ProviderAdapter.ProviderAdapterV2Shape;
-}): ProviderAdapter.ProviderAdapterV2Shape {
+ readonly v1: ProviderAdapter.ProviderAdapterV2["Service"];
+ readonly v2: ProviderAdapter.ProviderAdapterV2["Service"];
+}): ProviderAdapter.ProviderAdapterV2["Service"] {
const pick = <PE>(probed: Effect.Effect<ProbedOpenCode | undefined, PE>) =>
byOpenCodeRuntime(probed, { v1: Effect.succeed(input.v1), v2: Effect.succeed(input.v2) });
const hot = pick(Effect.map(input.probe.lastSuccess, Option.getOrUndefined));
@@ -445,7 +445,7 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
),
);
- const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, host.settings);
+ const snapshotSettings = yield* makeProviderSnapshotSettingsSource(effectiveConfig);
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<OpenCodeSettings>>(
{
resolveMaintenance,
diff --git a/packages/provider-opencode/src/server/v2/adapter.ts b/packages/provider-opencode/src/server/v2/adapter.ts
index 97429ddfde8..89fb4821003 100644
--- a/packages/provider-opencode/src/server/v2/adapter.ts
+++ b/packages/provider-opencode/src/server/v2/adapter.ts
@@ -88,7 +88,7 @@ import {
backgroundWorkNotification,
type BackgroundWorkReport,
} from "@t3tools/provider-core/server/notification";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
import {
makeSubagentChildThread,
@@ -858,7 +858,7 @@ export const make = Effect.fn("OpenCode2Adapter.make")(function* (instanceId: Pr
});
const openSession = Effect.fn("OpenCode2Adapter.openSession")(function* (
- input: Parameters<ProviderAdapter.ProviderAdapterV2Shape["openSession"]>[0],
+ input: Parameters<ProviderAdapter.ProviderAdapterV2["Service"]["openSession"]>[0],
initial: {
readonly connection: OpenCode2Server.OpenCode2Connection;
readonly scope: Scope.Closeable;
diff --git a/packages/provider-pi/src/server/adapter.test.ts b/packages/provider-pi/src/server/adapter.test.ts
index ed3236d763c..b6942a4d529 100644
--- a/packages/provider-pi/src/server/adapter.test.ts
+++ b/packages/provider-pi/src/server/adapter.test.ts
@@ -32,7 +32,7 @@ import * as TestClock from "effect/testing/TestClock";
import { ChildProcess, ChildProcessSpawner } from "effect/process";
import { layerTestProviderHost } from "@t3tools/provider-testing/host";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
diff --git a/packages/provider-pi/src/server/adapter.ts b/packages/provider-pi/src/server/adapter.ts
index e0d93d51a01..d2709307c98 100644
--- a/packages/provider-pi/src/server/adapter.ts
+++ b/packages/provider-pi/src/server/adapter.ts
@@ -67,7 +67,7 @@ import { parsePiCompactCommand, type PiCompactCommand } from "./commands.ts";
import { mergeProviderInstanceEnvironment } from "@t3tools/provider-core/server/instanceEnvironment";
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
-import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
+import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
import {
ProviderAdapterDriverCreateError,
type ProviderAdapterDriver,
@@ -775,7 +775,6 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
type: "turn_item.updated",
driver: PI_PROVIDER,
turnItem: makeProviderRetryTurnItem({
- idAllocator,
driver: PI_PROVIDER,
threadId: turn.turnInput.threadId,
runId: turn.turnInput.runId,
diff --git a/packages/provider-pi/src/server/driver.ts b/packages/provider-pi/src/server/driver.ts
index 25d39091178..c1507b861ca 100644
--- a/packages/provider-pi/src/server/driver.ts
+++ b/packages/provider-pi/src/server/driver.ts
@@ -142,7 +142,7 @@ export const PiDriver: ProviderDriver<PiSettings, PiDriverEnv> = {
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
);
- const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, host.settings);
+ const snapshotSettings = yield* makeProviderSnapshotSettingsSource(effectiveConfig);
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<PiSettings>>({
resolveMaintenance,
getSettings: snapshotSettings.getSettings,