11import { HostProcessEnvironment } from "@t3tools/shared/hostProcess" ;
2- import * as OtelEnvironment from "@t3tools/shared/otelEnvironment" ;
3- import { DEFAULT_SIGNAL_EXPORT } from "@t3tools/shared/observability" ;
42import type { InteractionUpdate , RunResult } from "@cursor/sdk" ;
53import * as NodeServices from "@effect/platform-node/NodeServices" ;
64import {
@@ -15,23 +13,21 @@ import * as Effect from "effect/Effect";
1513import * as Fiber from "effect/Fiber" ;
1614import * as FileSystem from "effect/FileSystem" ;
1715import * as Layer from "effect/Layer" ;
18- import * as Path from "effect/Path" ;
19- import * as PlatformError from "effect/PlatformError" ;
2016import * as Schema from "effect/Schema" ;
2117
22- import * as ServerConfig from "../../config.ts " ;
18+ import { layerTestProviderHost } from "@t3tools/provider-testing/host " ;
2319import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator" ;
2420import { ProviderAdapterDriverCreateError } from "@t3tools/provider-core/server/adapterDriver" ;
2521import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts" ;
2622import type { OrchestratorV2ProviderReplayHarness } from "../testkit/ProviderReplayHarness.ts" ;
27- import * as CursorAgentSdk from "./CursorAgentSdk.ts" ;
23+ import { CursorAdapterV2Driver } from "@t3tools/provider-cursor/server" ;
24+ import * as CursorAgentSdk from "@t3tools/provider-cursor/server/CursorAgentSdk" ;
2825import {
2926 CURSOR_DEFAULT_INSTANCE_ID ,
3027 CURSOR_DRIVER_KIND ,
31- CursorAdapterV2Driver ,
3228 cursorSdkModelSelection ,
3329 makeCursorAgentOptions ,
34- } from "./CursorAdapterV2.ts " ;
30+ } from "@t3tools/provider-cursor/testing " ;
3531import type { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter" ;
3632import type { RuntimePolicyV2Override } from "../RuntimePolicy.ts" ;
3733
@@ -513,102 +509,13 @@ function layerCursorAgentSdkReplay(
513509 ) ;
514510}
515511
516- function makeReplayServerConfig (
517- scenario : string ,
518- ) : Effect . Effect <
519- ServerConfig . ServerConfig [ "Service" ] ,
520- PlatformError . PlatformError ,
521- FileSystem . FileSystem | Path . Path
522- > {
523- return Effect . gen ( function * ( ) {
524- const fs = yield * FileSystem . FileSystem ;
525- const path = yield * Path . Path ;
526- const baseDir = yield * fs . makeTempDirectory ( {
527- prefix : `t3-orchestration-v2-cursor-${ scenario } -` ,
528- } ) ;
529- const stateDir = path . join ( baseDir , "userdata" ) ;
530- const logsDir = path . join ( stateDir , "logs" ) ;
531- const providerLogsDir = path . join ( logsDir , "provider" ) ;
532- const terminalLogsDir = path . join ( logsDir , "terminals" ) ;
533- const attachmentsDir = path . join ( stateDir , "attachments" ) ;
534- const environmentThemesDir = path . join ( stateDir , "themes" ) ;
535- const worktreesDir = path . join ( baseDir , "worktrees" ) ;
536- const providerStatusCacheDir = path . join ( baseDir , "caches" ) ;
537- for ( const directory of [
538- stateDir ,
539- logsDir ,
540- providerLogsDir ,
541- terminalLogsDir ,
542- attachmentsDir ,
543- environmentThemesDir ,
544- worktreesDir ,
545- providerStatusCacheDir ,
546- ] ) {
547- yield * fs . makeDirectory ( directory , { recursive : true } ) ;
548- }
549- return {
550- logLevel : "Error" ,
551- traceMinLevel : "Info" ,
552- traceTimingEnabled : true ,
553- traceBatchWindowMs : 200 ,
554- traceMaxBytes : 10 * 1024 * 1024 ,
555- traceMaxFiles : 10 ,
556- otelEnvironment : OtelEnvironment . none ,
557- otlpTracesUrl : undefined ,
558- otlpMetricsUrl : undefined ,
559- otlpLogsUrl : undefined ,
560- otlpTracesExport : DEFAULT_SIGNAL_EXPORT ,
561- otlpMetricsExport : DEFAULT_SIGNAL_EXPORT ,
562- otlpLogsExport : DEFAULT_SIGNAL_EXPORT ,
563- mode : "web" ,
564- port : 0 ,
565- host : undefined ,
566- cwd : process . cwd ( ) ,
567- baseDir,
568- staticDir : undefined ,
569- devUrl : undefined ,
570- devAllowedOrigins : [ ] ,
571- noBrowser : false ,
572- startupPresentation : "browser" ,
573- tailscaleServeEnabled : false ,
574- tailscaleServePort : 443 ,
575- desktopBootstrapToken : undefined ,
576- autoBootstrapProjectFromCwd : false ,
577- logWebSocketEvents : false ,
578- stateDir,
579- dbPath : path . join ( stateDir , "state.sqlite" ) ,
580- keybindingsConfigPath : path . join ( stateDir , "keybindings.json" ) ,
581- settingsPath : path . join ( stateDir , "settings.json" ) ,
582- providerStatusCacheDir,
583- worktreesDir,
584- attachmentsDir,
585- browserArtifactsDir : path . join ( stateDir , "browser-artifacts" ) ,
586- environmentThemesDir,
587- logsDir,
588- serverLogPath : path . join ( logsDir , "server.log" ) ,
589- serverTracePath : path . join ( logsDir , "server.trace.ndjson" ) ,
590- providerLogsDir,
591- providerEventLogPath : path . join ( providerLogsDir , "events.log" ) ,
592- terminalLogsDir,
593- anonymousIdPath : path . join ( stateDir , "anonymous-id" ) ,
594- environmentIdPath : path . join ( stateDir , "environment-id" ) ,
595- serverRuntimeStatePath : path . join ( stateDir , "server-runtime.json" ) ,
596- secretsDir : path . join ( stateDir , "secrets" ) ,
597- } ;
598- } ) ;
599- }
600-
601512export function layer (
602513 transcript : CursorAgentSdkReplayTranscript ,
603514 options ?: {
604515 readonly runner ?: CursorAgentSdk . CursorAgentSdkRunnerShape ;
605516 readonly assertCompleteOnFinalize ?: boolean ;
606517 } ,
607518) {
608- const layerServerConfig = Layer . effect (
609- ServerConfig . ServerConfig ,
610- makeReplayServerConfig ( transcript . scenario ) . pipe ( Effect . orDie ) ,
611- ) . pipe ( Layer . provide ( NodeServices . layer ) ) ;
612519 // Skill discovery also scans user roots under HOME; an empty HOME keeps
613520 // replays from picking up the host's own skills.
614521 const layerHostEnvironment = Layer . effect (
@@ -630,7 +537,7 @@ export function layer(
630537 Layer . provide (
631538 Layer . mergeAll (
632539 layerCursorAgentSdkReplay ( transcript , options ) ,
633- layerServerConfig ,
540+ layerTestProviderHost ( ) . pipe ( Layer . provide ( NodeServices . layer ) ) ,
634541 layerHostEnvironment ,
635542 NodeServices . layer ,
636543 IdAllocator . layer ,
0 commit comments