Skip to content
Closed
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
1 change: 1 addition & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@effect/vitest": "catalog:",
"@modelcontextprotocol/sdk": "1.29.0",
"@t3tools/contracts": "workspace:*",
"@t3tools/provider-testing": "workspace:*",
"@t3tools/shared": "workspace:*",
"@t3tools/ssh": "workspace:*",
"@t3tools/tailscale": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
type ClaudeAgentSdkQueryOptions,
} from "../src/orchestration-v2/Adapters/ClaudeAdapterV2.ts";
import { randomUuidV4 } from "../src/orchestration-v2/RandomUuid.ts";
import { makeCheckpointWorkspace } from "../src/orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
import { makeCheckpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";

const SCENARIO = "thread_fork_native_fork_local_rollback";
const DEFAULT_OUTPUT = new URL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
type ProviderAdapterV2RuntimePolicy as ProviderAdapterV2RuntimePolicyType,
} from "@t3tools/provider-core/server/adapter";
import type { RuntimePolicyV2Override } from "../src/orchestration-v2/RuntimePolicy.ts";
import { makeCheckpointWorkspace } from "../src/orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
import { makeCheckpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import { CLAUDE_MODEL_SELECTION } from "../src/orchestration-v2/testkit/fixtures/shared.ts";
import {
MESSAGE_STEERING_INITIAL_PROMPT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
recordCursorAgentSdkReplayTranscript,
type CursorAgentSdkReplayTranscript,
} from "../src/orchestration-v2/Adapters/CursorAdapterV2.testkit.ts";
import { checkpointWorkspace } from "../src/orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import {
CURSOR_MODEL_SELECTION,
MESSAGE_STEERING_INITIAL_PROMPT,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/scripts/record-grok-acp-replay-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { materializeFixtureInput } from "../src/orchestration-v2/testkit/fixture
import { runOrchestratorV2Scenario } from "../src/orchestration-v2/testkit/OrchestratorScenario.ts";
import { makeReplayServerConfig } from "../src/orchestration-v2/testkit/ProviderReplayHarness.ts";
import * as ProviderReplayHarness from "../src/orchestration-v2/testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "../src/orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import { makeGrokAcpRuntime } from "../src/provider/acp/GrokAcpSupport.ts";
import { buildRuntimeInstructions } from "../src/provider/RuntimeInstructions.ts";

Expand Down
4 changes: 2 additions & 2 deletions apps/server/scripts/record-muse-msp-replay-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ import { provideDeterministicTestRuntime } from "../src/orchestration-v2/testkit
import { ORCHESTRATOR_REPLAY_FIXTURES } from "../src/orchestration-v2/testkit/fixtures/index.ts";
import { materializeFixtureInput } from "../src/orchestration-v2/testkit/fixtures/shared.ts";
import { runOrchestratorV2ProviderReplayScenario } from "../src/orchestration-v2/testkit/ProviderReplayHarness.ts";
import { materializeReplayTranscriptWorkspace } from "../src/orchestration-v2/testkit/ReplayTranscriptNdjson.ts";
import { materializeReplayTranscriptWorkspace } from "@t3tools/provider-testing/replayTranscript";
import {
checkpointWorkspace,
makeCheckpointWorkspace,
} from "../src/orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
} from "@t3tools/provider-testing/replayWorkspace";

const CLOCK_TICK = Duration.millis(20);

Expand Down
2 changes: 1 addition & 1 deletion apps/server/scripts/record-pi-rpc-replay-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { runOrchestratorV2ProviderReplayScenario } from "../src/orchestration-v2
import {
checkpointWorkspace,
makeCheckpointWorkspace,
} from "../src/orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
} from "@t3tools/provider-testing/replayWorkspace";

/**
* Keeps the user's skills, templates and context files out of the recording.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ import {
} from "@t3tools/provider-core/server/adapter";
import * as ProviderAdapterRegistry from "../orchestration-v2/ProviderAdapterRegistry.ts";
import * as ProviderContinuationRequests from "../orchestration-v2/ProviderContinuationRequests.ts";
import { checkpointWorkspace } from "../orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import * as ProviderReplayHarness from "../orchestration-v2/testkit/ProviderReplayHarness.ts";
import {
decodeProviderReplayNdjson,
materializeReplayTranscriptWorkspace,
} from "../orchestration-v2/testkit/ReplayTranscriptNdjson.ts";
} from "@t3tools/provider-testing/replayTranscript";
import * as ProviderRegistryMock from "../provider/testUtils/providerRegistryMock.ts";
import * as ProjectService from "../project/ProjectService.ts";
import * as ScheduledTaskService from "../scheduledTasks/ScheduledTaskService.ts";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ChildProcessSpawner } from "effect/process";
import * as EffectAcpErrors from "effect-acp/errors";

import * as AcpSessionRuntime from "../../provider/acp/AcpSessionRuntime.ts";
import type { ProviderReplayGate } from "../testkit/ProviderReplayGate.testkit.ts";
import type { ProviderReplayGate } from "@t3tools/provider-testing/replayGate";
import { ACP_PROTOCOL, type AcpAdapterV2RuntimeInput } from "./AcpAdapterV2.ts";

export const AcpReplayTranscript = Schema.Struct({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ChildProcessSpawner } from "effect/process";
import * as ServerConfig from "../../config.ts";
import * as IdAllocator from "../IdAllocator.ts";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import type { ProviderReplayGate } from "../testkit/ProviderReplayGate.testkit.ts";
import type { ProviderReplayGate } from "@t3tools/provider-testing/replayGate";
import type { OrchestratorV2ProviderReplayHarness } from "../testkit/ProviderReplayHarness.ts";
import { makeReplayServerConfig } from "../testkit/ProviderReplayHarness.ts";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
makeReplayServerConfig,
type OrchestratorV2ProviderReplayHarness,
} from "../testkit/ProviderReplayHarness.ts";
import type { ProviderReplayGate } from "../testkit/ProviderReplayGate.testkit.ts";
import type { ProviderReplayGate } from "@t3tools/provider-testing/replayGate";

export const CLAUDE_AGENT_SDK_REPLAY_PROTOCOL = "claude-agent-sdk.query" as const;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ProviderAdapterOpenSessionError } from "@t3tools/provider-core/server/a
import { ProviderAdapterDriverCreateError } from "../ProviderAdapterDriver.ts";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import type { OrchestratorV2ProviderReplayHarness } from "../testkit/ProviderReplayHarness.ts";
import type { ProviderReplayGate } from "../testkit/ProviderReplayGate.testkit.ts";
import type { ProviderReplayGate } from "@t3tools/provider-testing/replayGate";
import * as CodexAdapterV2 from "./CodexAdapterV2.ts";

export class CodexReplayTranscriptDecodeError extends Schema.TaggedError<CodexReplayTranscriptDecodeError>()(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { makeXAiPromptCompletionRuntime } from "../../provider/acp/XAiAcpExtensi
import * as IdAllocator from "../IdAllocator.ts";
import * as ProviderContinuationRequests from "../ProviderContinuationRequests.ts";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import type { ProviderReplayGate } from "../testkit/ProviderReplayGate.testkit.ts";
import type { ProviderReplayGate } from "@t3tools/provider-testing/replayGate";
import type { OrchestratorV2ProviderReplayHarness } from "../testkit/ProviderReplayHarness.ts";
import { makeReplayServerConfig } from "../testkit/ProviderReplayHarness.ts";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as OpenCode2Client from "../../provider/opencode2/OpenCode2Client.ts";
import * as OpenCode2Server from "../../provider/opencode2/OpenCode2Server.ts";
import * as IdAllocator from "../IdAllocator.ts";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import type { ProviderReplayGate } from "../testkit/ProviderReplayGate.testkit.ts";
import type { ProviderReplayGate } from "@t3tools/provider-testing/replayGate";
import {
makeReplayServerConfig,
type OrchestratorV2ProviderReplayHarness,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import type {
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "./testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";

const driver = ProviderDriverKind.make("codex");
const instanceId = ProviderInstanceId.make("codex");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ThreadLaunchService from "./ThreadLaunchService.ts";
import * as ThreadManagementService from "./ThreadManagementService.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "./testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";

const sessionId = "automatic-delivery-session";
const settings = Schema.decodeSync(ClaudeSettings)({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import { OPENCODE_PROVIDER } from "./Adapters/OpenCodeAdapterV2.ts";
import { provideDeterministicTestRuntime } from "./testkit/DeterministicRuntime.ts";
import type { OrchestratorV2ScenarioStep } from "./testkit/OrchestratorScenario.ts";
import { runOrchestratorV2ProviderReplayScenario } from "./testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "./testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import {
decodeProviderReplayNdjson,
readProviderReplayTranscript,
} from "./testkit/ReplayTranscriptNdjson.ts";
} from "@t3tools/provider-testing/replayTranscript";
import * as IdAllocator from "./IdAllocator.ts";

const SESSION = "ses_f148ca2deffeJcwCnRQtb0YFNX";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
} from "@t3tools/provider-core/server/adapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "./testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";

const driver = ProviderDriverKind.make("codex");
const providerInstanceId = ProviderInstanceId.make("codex-restart-test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from "@t3tools/provider-core/server/adapter";
import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "./testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";

const driver = ProviderDriverKind.make("codex");
const instanceId = ProviderInstanceId.make("codex");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
} from "@t3tools/provider-core/server/adapter";
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
import * as ProviderReplayHarness from "../testkit/ProviderReplayHarness.ts";
import { checkpointWorkspace } from "../testkit/ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";

const PROJECT_ID = "project:cutover";
const ACTIVE_THREAD = "thread:cutover:active";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ORCHESTRATOR_REPLAY_FIXTURES } from "./fixtures/index.ts";
import { subagentInput } from "./fixtures/subagent/input.ts";
import { runOrchestratorV2Scenario } from "./OrchestratorScenario.ts";
import * as ProviderReplayHarness from "./ProviderReplayHarness.ts";
import { materializeReplayTranscriptRuntimeInstructions } from "./ReplayTranscriptNdjson.ts";
import { materializeReplayTranscriptRuntimeInstructions } from "./ReplayRuntimeInstructions.ts";
import { CLAUDE_MODEL_SELECTION, materializeFixtureInput } from "./fixtures/shared.ts";
import {
THREAD_FORK_NATIVE_CONTINUE_FORK_MARKER,
Expand All @@ -33,7 +33,7 @@ import {
THREAD_MERGE_BACK_SIBLINGS_SOURCE_MARKER,
THREAD_MERGE_BACK_SOURCE_MARKER,
} from "./fixtures/shared.ts";
import { readProviderReplayTranscript } from "./ReplayTranscriptNdjson.ts";
import { readProviderReplayTranscript } from "@t3tools/provider-testing/replayTranscript";

const readTranscript = Effect.fn("readClaudeReplayFixture")(function* (file: URL) {
return yield* readProviderReplayTranscript(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
THREAD_MERGE_BACK_SIBLINGS_SOURCE_MARKER,
THREAD_MERGE_BACK_SOURCE_MARKER,
} from "./fixtures/shared.ts";
import { readProviderReplayTranscript } from "./ReplayTranscriptNdjson.ts";
import { readProviderReplayTranscript } from "@t3tools/provider-testing/replayTranscript";

const PROVIDER_THREAD_RESUME_FIRST_FINAL = "provider thread resume fixture first turn complete";
const PROVIDER_THREAD_RESUME_SECOND_FINAL = "provider thread resume fixture second turn complete";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as IdAllocator from "../IdAllocator.ts";
import { provideDeterministicTestRuntime } from "./DeterministicRuntime.ts";
import { ORCHESTRATOR_REPLAY_FIXTURES } from "./fixtures/index.ts";
import { materializeFixtureInput } from "./fixtures/shared.ts";
import { readProviderReplayTranscript } from "./ReplayTranscriptNdjson.ts";
import { readProviderReplayTranscript } from "@t3tools/provider-testing/replayTranscript";

const decodeCommand = Schema.decodeUnknownEffect(OrchestrationV2Command);
const readTranscript = Effect.fn("readOrchestratorReplayContractTranscript")(function* (file: URL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ import {
runOrchestratorV2ProviderReplayScenario,
type OrchestratorV2ProviderReplayHarness,
} from "./ProviderReplayHarness.ts";
import { checkpointWorkspace } from "./ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import { materializeReplayTranscriptRuntimeInstructions } from "./ReplayRuntimeInstructions.ts";
import {
materializeReplayTranscriptRuntimeInstructions,
materializeReplayTranscriptWorkspace,
readProviderReplayTranscript,
} from "./ReplayTranscriptNdjson.ts";
} from "@t3tools/provider-testing/replayTranscript";

const readTranscript = Effect.fn("readOrchestratorReplayTranscript")(function* (file: URL) {
return yield* readProviderReplayTranscript(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ import {
projectionFor,
} from "./fixtures/shared.ts";
import { runOrchestratorV2ProviderReplayScenario } from "./ProviderReplayHarness.ts";
import { checkpointWorkspace } from "./ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import { materializeReplayTranscriptRuntimeInstructions } from "./ReplayRuntimeInstructions.ts";
import {
materializeReplayTranscriptRuntimeInstructions,
materializeReplayTranscriptWorkspace,
readProviderReplayTranscript,
} from "./ReplayTranscriptNdjson.ts";
} from "@t3tools/provider-testing/replayTranscript";

const FIRST_FINAL = "provider thread resume fixture first turn complete";
const SECOND_FINAL = "provider thread resume fixture second turn complete";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
import { runOrchestratorV2ProviderReplayScenario } from "./ProviderReplayHarness.ts";
import * as ProviderReplayHarness from "./ProviderReplayHarness.ts";
import { runOrchestratorV2Scenario } from "./OrchestratorScenario.ts";
import { checkpointWorkspace } from "./ReplayFixtureWorkspace.ts";
import { readProviderReplayTranscript } from "./ReplayTranscriptNdjson.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
import { readProviderReplayTranscript } from "@t3tools/provider-testing/replayTranscript";

const SCENARIO = "claude_background_subagent_after_root";
const SESSION_ID = "cca274e4-25ae-4171-b972-bbb31118517e";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import * as Stream from "effect/Stream";
import { TestClock } from "effect/testing";

import * as Orchestrator from "../Orchestrator.ts";
import type { ProviderReplayGate } from "./ProviderReplayGate.testkit.ts";
import type { ProviderReplayGate } from "@t3tools/provider-testing/replayGate";

export type OrchestratorV2ScenarioStep =
| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ import {
type OrchestratorV2Scenario,
type OrchestratorV2ScenarioResult,
} from "./OrchestratorScenario.ts";
import { makeProviderReplayGate, type ProviderReplayGate } from "./ProviderReplayGate.testkit.ts";
import {
makeProviderReplayGate,
type ProviderReplayGate,
} from "@t3tools/provider-testing/replayGate";

export function makeReplayServerConfig(
scenario: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import {
GROK_MODEL_SELECTION,
} from "./fixtures/shared.ts";
import * as ProviderReplayHarness from "./ProviderReplayHarness.ts";
import { checkpointWorkspace } from "./ReplayFixtureWorkspace.ts";
import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";

const encodeJson = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import type { ProviderDriverKind, ProviderReplayTranscript } from "@t3tools/contracts";

import { buildRuntimeInstructions } from "../../provider/RuntimeInstructions.ts";

/** Adds current runtime context to legacy prompt expectations, keeping outbound matching exact. */
export function materializeReplayTranscriptRuntimeInstructions(
transcript: ProviderReplayTranscript,
runtime: { readonly driver: ProviderDriverKind; readonly model: string },
): ProviderReplayTranscript {
const harness =
runtime.driver === "cursor"
? "Cursor"
: runtime.driver === "grok"
? "Grok"
: runtime.driver === "acpRegistry"
? "acpRegistry"
: undefined;
if (harness === undefined) return transcript;
const instructions = buildRuntimeInstructions({ harness, model: runtime.model });

return {
...transcript,
entries: transcript.entries.map((entry) => {
if (entry.type !== "expect_outbound") return entry;
const frame = entry.frame;
if (typeof frame !== "object" || frame === null) return entry;
if (
runtime.driver === "cursor" &&
"type" in frame &&
frame.type === "run.start" &&
"message" in frame &&
typeof frame.message === "string"
) {
return frame.message.endsWith(instructions)
? entry
: { ...entry, frame: { ...frame, message: `${frame.message}\n\n${instructions}` } };
}
if (
"method" in frame &&
frame.method === "session/prompt" &&
"params" in frame &&
typeof frame.params === "object" &&
frame.params !== null &&
"prompt" in frame.params &&
Array.isArray(frame.params.prompt)
) {
const prompt: ReadonlyArray<unknown> = frame.params.prompt;
const lastPart = prompt.at(-1);
if (
typeof lastPart === "object" &&
lastPart !== null &&
"type" in lastPart &&
lastPart.type === "text" &&
"text" in lastPart &&
lastPart.text === instructions
) {
return entry;
}
return {
...entry,
frame: {
...frame,
params: { ...frame.params, prompt: [...prompt, { type: "text", text: instructions }] },
},
};
}
return entry;
}),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { runOrchestratorV2ProviderReplayScenario } from "./ProviderReplayHarness
import {
decodeProviderReplayNdjson,
materializeReplayTranscriptWorkspace,
} from "./ReplayTranscriptNdjson.ts";
} from "@t3tools/provider-testing/replayTranscript";

const CODEX_MODEL_SELECTION = {
instanceId: ProviderInstanceId.make("codex"),
Expand Down
Loading
Loading