@@ -4,10 +4,6 @@ import {
44 writeToolHostSharedContext
55} from "./toolHostSharedContext.js" ;
66
7- function normalizeToolId ( toolId ) {
8- return typeof toolId === "string" ? toolId . trim ( ) : "" ;
9- }
10-
117function isPlainObject ( value ) {
128 return ! ! value && typeof value === "object" && ! Array . isArray ( value ) ;
139}
@@ -48,30 +44,30 @@ function hasImplicitGlobalKey(value) {
4844}
4945
5046function assertExplicitLaunchInputs ( { toolId = "" , payloadJson = null , paletteJson = null , argumentCount = 0 } ) {
51- const normalizedToolId = normalizeToolId ( toolId ) ;
52- if ( ! normalizedToolId ) {
47+ const toolIdText = typeof toolId === "string" ? toolId . trim ( ) : "" ;
48+ if ( ! toolIdText ) {
5349 throw new Error ( "launch contract violation: toolId is required." ) ;
5450 }
5551 if ( argumentCount < 2 || argumentCount > 3 ) {
5652 throw new Error ( `launch contract violation: launch(toolId, payloadJson, paletteJson?) expected 2-3 args, received ${ argumentCount } .` ) ;
5753 }
5854 if ( ! isPlainObject ( payloadJson ) ) {
59- throw new Error ( `launch contract violation: payloadJson must be an object for ${ normalizedToolId } .` ) ;
55+ throw new Error ( `launch contract violation: payloadJson must be an object for ${ toolIdText } .` ) ;
6056 }
6157 if ( paletteJson !== null && ! isPlainObject ( paletteJson ) ) {
62- throw new Error ( `launch contract violation: paletteJson must be an object or null for ${ normalizedToolId } .` ) ;
58+ throw new Error ( `launch contract violation: paletteJson must be an object or null for ${ toolIdText } .` ) ;
6359 }
6460 if ( isParentJsonLike ( payloadJson ) ) {
65- throw new Error ( `launch contract violation: parent JSON usage detected in payloadJson for ${ normalizedToolId } .` ) ;
61+ throw new Error ( `launch contract violation: parent JSON usage detected in payloadJson for ${ toolIdText } .` ) ;
6662 }
6763 if ( paletteJson !== null && isParentJsonLike ( paletteJson ) ) {
68- throw new Error ( `launch contract violation: parent JSON usage detected in paletteJson for ${ normalizedToolId } .` ) ;
64+ throw new Error ( `launch contract violation: parent JSON usage detected in paletteJson for ${ toolIdText } .` ) ;
6965 }
7066 if ( hasImplicitGlobalKey ( payloadJson ) ) {
71- throw new Error ( `launch contract violation: implicit/global input keys detected in payloadJson for ${ normalizedToolId } .` ) ;
67+ throw new Error ( `launch contract violation: implicit/global input keys detected in payloadJson for ${ toolIdText } .` ) ;
7268 }
7369 if ( paletteJson !== null && hasImplicitGlobalKey ( paletteJson ) ) {
74- throw new Error ( `launch contract violation: implicit/global input keys detected in paletteJson for ${ normalizedToolId } .` ) ;
70+ throw new Error ( `launch contract violation: implicit/global input keys detected in paletteJson for ${ toolIdText } .` ) ;
7571 }
7672}
7773
@@ -219,10 +215,10 @@ export function createToolHostRuntime(options = {}) {
219215 paletteJson,
220216 argumentCount : arguments . length
221217 } ) ;
222- const normalizedToolId = normalizeToolId ( toolId ) ;
223- const toolEntry = getToolHostEntryById ( manifest , normalizedToolId ) ;
218+ const toolIdText = typeof toolId === "string" ? toolId . trim ( ) : "" ;
219+ const toolEntry = getToolHostEntryById ( manifest , toolIdText ) ;
224220 if ( ! toolEntry ) {
225- onStatus ( `Tool id not found: ${ normalizedToolId || "(empty)" } .` ) ;
221+ onStatus ( `Tool id not found: ${ toolIdText || "(empty)" } .` ) ;
226222 return null ;
227223 }
228224
0 commit comments