@@ -36,7 +36,6 @@ import * as NodeCrypto from "node:crypto";
3636import * as Crypto from "effect/Crypto" ;
3737import * as Exit from "effect/Exit" ;
3838import * as Fiber from "effect/Fiber" ;
39- import * as FileSystem from "effect/FileSystem" ;
4039import * as Queue from "effect/Queue" ;
4140import * as Schema from "effect/Schema" ;
4241import * as Scope from "effect/Scope" ;
@@ -67,6 +66,7 @@ import {
6766 makeCodexSessionRuntime ,
6867 type CodexSessionRuntimeError ,
6968 type CodexSessionRuntimeOptions ,
69+ type CodexSessionRuntimeSendTurnInput ,
7070 type CodexSessionRuntimeShape ,
7171} from "./CodexSessionRuntime.ts" ;
7272import { type EventNdjsonLogger , makeEventNdjsonLogger } from "./EventNdjsonLogger.ts" ;
@@ -2218,7 +2218,6 @@ export const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (
22182218 options ?: CodexAdapterLiveOptions ,
22192219) {
22202220 const boundInstanceId = options ?. instanceId ?? ProviderInstanceId . make ( "codex" ) ;
2221- const fileSystem = yield * FileSystem . FileSystem ;
22222221 const childProcessSpawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
22232222 const crypto = yield * Crypto . Crypto ;
22242223 const serverConfig = yield * Effect . service ( ServerConfig ) ;
@@ -2488,27 +2487,18 @@ export const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (
24882487 detail : `Invalid attachment id '${ attachment . id } '.` ,
24892488 } ) ;
24902489 }
2491- const bytes = yield * fileSystem . readFile ( attachmentPath ) . pipe (
2492- Effect . mapError (
2493- ( cause ) =>
2494- new ProviderAdapterRequestError ( {
2495- provider : PROVIDER ,
2496- method : "turn/start" ,
2497- detail : `Failed to read attachment file: ${ cause . message } .` ,
2498- cause,
2499- } ) ,
2500- ) ,
2501- ) ;
25022490 return {
2503- type : "image " as const ,
2504- url : `data: ${ attachment . mimeType } ;base64, ${ Buffer . from ( bytes ) . toString ( "base64" ) } ` ,
2491+ type : "localImage " as const ,
2492+ path : attachmentPath ,
25052493 } ;
25062494 } ) ;
25072495
25082496 const sendTurn : CodexAdapterShape [ "sendTurn" ] = Effect . fn ( "sendTurn" ) ( function * ( input ) {
2509- // Codex ingests images only. Anything else would be base64-encoded as an
2510- // image and rejected or misread; generic files reach the agent through the
2511- // path line ProviderService puts in the prompt.
2497+ // Codex ingests images only. Anything else would be inlined as an image
2498+ // and rejected or misread; generic files reach the agent through the path
2499+ // line ProviderService puts in the prompt. Images are passed by path
2500+ // instead of base64 so the turn/start request does not scale with file
2501+ // size; the CLI reads the file itself.
25122502 const codexAttachments = yield * Effect . forEach (
25132503 ( input . attachments ?? [ ] ) . filter ( ( attachment ) => attachment . type === "image" ) ,
25142504 ( attachment ) => resolveAttachment ( input , attachment ) ,
0 commit comments