File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,21 @@ describe("App <-> AppBridge integration", () => {
215215 expect ( receivedCancellations [ 0 ] ) . toEqual ( { } ) ;
216216 } ) ;
217217
218+ it ( "tool notifications work with default no-op handlers" , async ( ) => {
219+ // Don't set any custom handlers - use defaults
220+ await app . connect ( appTransport ) ;
221+
222+ // These should not throw (default handlers silently accept them)
223+ // Just verify they complete without error
224+ await bridge . sendToolInput ( { arguments : { } } ) ;
225+ await bridge . sendToolInputPartial ( { arguments : { } } ) ;
226+ await bridge . sendToolResult ( { content : [ { type : "text" , text : "ok" } ] } ) ;
227+ await bridge . sendToolCancelled ( { } ) ;
228+
229+ // If we got here without throwing, the test passes
230+ expect ( true ) . toBe ( true ) ;
231+ } ) ;
232+
218233 it ( "setHostContext triggers app.onhostcontextchanged" , async ( ) => {
219234 const receivedContexts : unknown [ ] = [ ] ;
220235 app . onhostcontextchanged = ( params ) => {
Original file line number Diff line number Diff line change @@ -429,6 +429,29 @@ describe("OpenAITransport", () => {
429429 } ) ;
430430 } ) ;
431431
432+ test ( "converts null _meta to undefined in tool result" , async ( ) => {
433+ // Simulate null being set (e.g., from JSON parsing where null is valid)
434+ ( mockOpenAI as unknown as { toolResponseMetadata : null } ) . toolResponseMetadata = null ;
435+
436+ const transport = new OpenAITransport ( ) ;
437+ const messages : unknown [ ] = [ ] ;
438+ transport . onmessage = ( msg ) => {
439+ messages . push ( msg ) ;
440+ } ;
441+
442+ transport . deliverInitialState ( ) ;
443+
444+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
445+
446+ const toolResultNotification = messages . find (
447+ ( m : unknown ) =>
448+ ( m as { method ?: string } ) . method === "ui/notifications/tool-result" ,
449+ ) as { params ?: { _meta ?: unknown } } | undefined ;
450+ expect ( toolResultNotification ) . toBeDefined ( ) ;
451+ // _meta should be undefined, not null (SDK rejects null)
452+ expect ( toolResultNotification ?. params ?. _meta ) . toBeUndefined ( ) ;
453+ } ) ;
454+
432455 test ( "does not deliver notifications when data is missing" , async ( ) => {
433456 delete mockOpenAI . toolInput ;
434457 delete mockOpenAI . toolOutput ;
You can’t perform that action at this time.
0 commit comments