Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions apps/server/scripts/record-claude-agent-sdk-replay-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions apps/server/scripts/record-grok-acp-replay-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)),
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/mcp/McpToolAccess.race.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions apps/server/src/mcp/OrchestratorMcpService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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", () =>
Expand Down Expand Up @@ -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 }),
),
Expand Down
27 changes: 12 additions & 15 deletions apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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`.
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -185,18 +180,20 @@ 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,
getCapabilities: () => Effect.succeed(input.capabilities),
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,
Expand All @@ -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,
Expand Down
13 changes: 6 additions & 7 deletions apps/server/src/mcpApps/McpAppRequests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -121,7 +118,9 @@ function makeLayer(input: {
: Option.some(
(input.mcpApps === undefined
? {}
: { mcpApps: input.mcpApps }) as ProviderAdapterV2SessionRuntime,
: {
mcpApps: input.mcpApps,
}) as ProviderAdapter.ProviderAdapterV2SessionRuntime,
),
),
}),
Expand All @@ -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 } },
Expand Down
11 changes: 4 additions & 7 deletions apps/server/src/mcpApps/McpAppRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading
Loading