44 * HTTP server. Frames reuse the shapes recorded against 2.0.18.
55 */
66import * as NodeCrypto from "@effect/platform-node/NodeCrypto" ;
7+ import * as NodeServices from "@effect/platform-node/NodeServices" ;
78import { assert , it } from "@effect/vitest" ;
89import {
910 ChatAttachmentId ,
@@ -31,6 +32,7 @@ import * as DateTime from "effect/DateTime";
3132import * as Deferred from "effect/Deferred" ;
3233import * as Effect from "effect/Effect" ;
3334import * as Fiber from "effect/Fiber" ;
35+ import * as FileSystem from "effect/FileSystem" ;
3436import * as Layer from "effect/Layer" ;
3537import * as Logger from "effect/Logger" ;
3638import * as Option from "effect/Option" ;
@@ -52,6 +54,7 @@ import * as ProviderContinuationRequests from "@t3tools/provider-core/server/con
5254import { OPENCODE_PROVIDER } from "./OpenCodeAdapterV2.ts" ;
5355import {
5456 OPENCODE_2_STILL_STOPPING ,
57+ presentPromptFiles ,
5558 promptImageFiles ,
5659 t3McpServerName ,
5760} from "./OpenCode2AdapterV2.ts" ;
@@ -2825,9 +2828,15 @@ describe("OpenCode2 adapter", () => {
28252828 it . effect ( "sends a turn's and a steer's pasted images as prompt files" , ( ) =>
28262829 Effect . gen ( function * ( ) {
28272830 const steerId = "msg_recorded_steer_image" ;
2828- const attachmentsDir = "/t3/attachments" ;
2831+ const fileSystem = yield * FileSystem . FileSystem ;
2832+ const attachmentsDir = yield * fileSystem . makeTempDirectoryScoped ( {
2833+ prefix : "t3-oc2-images-" ,
2834+ } ) ;
28292835 const screenshot = `${ attachmentsDir } /thread-opencode2-adapter-12345678-1234-1234-1234-123456789abc.png` ;
28302836 const chart = `${ attachmentsDir } /thread-opencode2-adapter-abcdefab-1234-1234-1234-123456789abc.png` ;
2837+ yield * Effect . forEach ( [ screenshot , chart ] , ( file ) =>
2838+ fileSystem . writeFileString ( file , "png!" ) ,
2839+ ) ;
28312840 const { runtime, thread } = yield * resumed (
28322841 [
28332842 out ( "session.prompt" , {
@@ -2892,7 +2901,20 @@ describe("OpenCode2 adapter", () => {
28922901 } ,
28932902 } ) ;
28942903 assert . equal ( ( yield * Fiber . join ( terminal ) ) ?. status , "completed" ) ;
2895- } ) . pipe ( Effect . scoped , Effect . provide ( IdAllocator . layer ) ) ,
2904+ } ) . pipe ( Effect . scoped , Effect . provide ( Layer . mergeAll ( IdAllocator . layer , NodeServices . layer ) ) ) ,
2905+ ) ;
2906+
2907+ it . effect ( "drops a pasted image whose saved file is gone" , ( ) =>
2908+ Effect . gen ( function * ( ) {
2909+ const fileSystem = yield * FileSystem . FileSystem ;
2910+ const attachmentsDir = yield * fileSystem . makeTempDirectoryScoped ( {
2911+ prefix : "t3-oc2-images-" ,
2912+ } ) ;
2913+ const kept = { uri : `file://${ attachmentsDir } /kept.png` , name : "kept.png" } ;
2914+ yield * fileSystem . writeFileString ( `${ attachmentsDir } /kept.png` , "png!" ) ;
2915+ const deleted = { uri : `file://${ attachmentsDir } /deleted.png` , name : "deleted.png" } ;
2916+ assert . deepEqual ( yield * presentPromptFiles ( fileSystem , [ kept , deleted ] ) , [ kept ] ) ;
2917+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
28962918 ) ;
28972919
28982920 it ( "gives a server T3 started a file URL for each pasted image, an external one none" , ( ) => {
0 commit comments