@@ -25,7 +25,6 @@ import {
2525 type ThreadId ,
2626} from "@t3tools/contracts" ;
2727import type { MuseSettings } from "../settings.ts" ;
28- import { SKILL_MENTION_PATTERN } from "@t3tools/shared/composerInlineTokens" ;
2928import { AgentScope } from "@t3tools/shared/AgentScope" ;
3029import { getModelSelectionStringOptionValue } from "@t3tools/shared/model" ;
3130import { formatDuration } from "@t3tools/shared/orchestrationTiming" ;
@@ -52,7 +51,6 @@ import {
5251 MuseDelta ,
5352 MuseItemEvent ,
5453 MuseSessionResult ,
55- MuseSkillList ,
5654 MuseSubscriptionUsage ,
5755 MuseTokenUsageEvent ,
5856 MuseTodoList ,
@@ -2030,27 +2028,8 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
20302028 ) ,
20312029 ) ;
20322030 } ) ;
2033- const resolveSkillSelector = Effect . fnUntraced ( function * ( text : string ) {
2034- const mentions = [ ...text . matchAll ( SKILL_MENTION_PATTERN ) ] ;
2035- if ( ! mentions . length ) return undefined ;
2036- // An optional catalog timeout must not close the host needed for the text fallback.
2037- return yield * Effect . tryPromise ( {
2038- try : ( ) => host . connection . request ( "skill/list" , { sessionId : nativeSessionId } ) ,
2039- catch : ( cause ) => protocolError ( "Muse skill/list failed" , cause ) ,
2040- } ) . pipe (
2041- Effect . flatMap ( ( value ) => decode ( MuseSkillList , value ) ) ,
2042- Effect . map ( ( { skills } ) => {
2043- const selectors = new Set ( skills . map ( ( skill ) => skill . selector ) ) ;
2044- return mentions . find ( ( match ) => match [ 2 ] !== undefined && selectors . has ( match [ 2 ] ) ) ?. [ 2 ] ;
2045- } ) ,
2046- Effect . timeout ( 5_000 ) ,
2047- Effect . orElseSucceed ( ( ) => undefined ) ,
2048- ) ;
2049- } ) ;
20502031 const prompt = Effect . fnUntraced ( function * (
20512032 message : ProviderAdapter . ProviderAdapterV2TurnMessage ,
2052- runtimeInstructions ?: string ,
2053- selector ?: string ,
20542033 ) {
20552034 const parts : SendUserTurnOptions < unknown > [ "input" ] = [ ] ;
20562035 const text = yield * providerMessageTextWithAttachmentPaths ( {
@@ -2059,19 +2038,7 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
20592038 resolveAttachmentPath : providerHost . resolveAttachmentPath ,
20602039 resolveExtractedTextPath : providerHost . resolveExtractedTextPath ,
20612040 } ) ;
2062- if ( ! text && ! message . attachments . some ( isProviderNativeImageAttachment ) )
2063- return yield * protocolError ( "Muse needs text or an image" ) ;
2064- if ( selector ) {
2065- // MSP permits one skill plus images, but rejects skill/text mixtures.
2066- parts . push ( {
2067- type : "skill" ,
2068- selector,
2069- arguments : [ runtimeInstructions , text ] . filter ( Boolean ) . join ( "\n\n" ) ,
2070- } ) ;
2071- } else {
2072- if ( runtimeInstructions ) parts . push ( { type : "text" , text : runtimeInstructions } ) ;
2073- if ( text ) parts . push ( { type : "text" , text } ) ;
2074- }
2041+ if ( text ) parts . push ( { type : "text" , text } ) ;
20752042 for ( const attachment of message . attachments )
20762043 if ( isProviderNativeImageAttachment ( attachment ) ) {
20772044 const path = providerHost . resolveAttachmentPath ( attachment ) ;
@@ -2085,6 +2052,7 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
20852052 mediaType : attachment . mimeType ,
20862053 } ) ;
20872054 }
2055+ if ( ! parts . length ) return yield * protocolError ( "Muse needs text or an image" ) ;
20882056 return parts ;
20892057 } ) ;
20902058 const validateThread = ( candidate : OrchestrationV2ProviderThread ) =>
@@ -2125,6 +2093,7 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
21252093 turnInput . message . creationSource === "provider" ;
21262094 const adopted = continuation ? wake : undefined ;
21272095 const effort = continuation ? undefined : yield * selectionEffort ( turnInput . modelSelection ) ;
2096+ const parts = compact || continuation ? [ ] : yield * prompt ( turnInput . message ) ;
21282097 const targetModel = continuation
21292098 ? undefined
21302099 : yield * resolveModel ( turnInput . modelSelection ) ;
@@ -2134,18 +2103,6 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
21342103 } ) ;
21352104 session = { ...session , model : targetModel } ;
21362105 }
2137- const parts =
2138- compact || continuation
2139- ? [ ]
2140- : yield * prompt (
2141- turnInput . message ,
2142- buildRuntimeInstructions ( {
2143- harness : "Muse Code" ,
2144- model : session . model ?? undefined ,
2145- reasoningEffort : effort ,
2146- } ) ,
2147- yield * resolveSkillSelector ( turnInput . message . text ) ,
2148- ) ;
21492106 const nativeId = adopted ?. nativeId ?? host . connection . mintCommandId ( ) ;
21502107 const startedAt = yield * DateTime . now ;
21512108 const providerTurn : OrchestrationV2ProviderTurn = {
@@ -2225,7 +2182,17 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
22252182 const result = yield * request (
22262183 "turn/start" ,
22272184 {
2228- input : parts ,
2185+ input : [
2186+ {
2187+ type : "text" ,
2188+ text : buildRuntimeInstructions ( {
2189+ harness : "Muse Code" ,
2190+ model : session . model ?? undefined ,
2191+ reasoningEffort : effort ,
2192+ } ) ,
2193+ } ,
2194+ ...parts ,
2195+ ] ,
22292196 displayText : turnInput . message . text || "Image attachment" ,
22302197 // Resumed sessions retain old roots; pin edits to the current checkout.
22312198 workspaceRoots : [ workspaceRoot ] ,
0 commit comments