11import { afterAll , beforeEach , describe , expect , it , vi } from 'vitest'
2+ import type { ExecutorDelegationOrigin } from '@/executor/types'
23import { mergeToolParameters } from '@/tools/merge-params'
34import * as toolMetadata from '@/tools/metadata'
45import {
@@ -634,6 +635,13 @@ describe('Tool Parameters Utils', () => {
634635
635636 describe ( 'createLLMToolSchema - child workflow input enrichment' , ( ) => {
636637 const mockReadWorkflowInputFields = vi . fn ( )
638+ const executorDelegationOrigin : ExecutorDelegationOrigin = {
639+ subjectUserId : 'user-1' ,
640+ workflowId : 'parent-workflow' ,
641+ executionId : 'execution-1' ,
642+ principal : { kind : 'session' , userId : 'user-1' , sessionId : 'session-1' } ,
643+ currentWorkflow : { workflowId : 'parent-workflow' , mode : 'draft' } ,
644+ }
637645
638646 beforeEach ( ( ) => {
639647 mockReadWorkflowInputFields . mockReset ( )
@@ -652,6 +660,7 @@ describe('Tool Parameters Utils', () => {
652660 workflowId : 'parent-workflow' ,
653661 executionId : 'execution-1' ,
654662 workspaceId : 'workspace-1' ,
663+ executorDelegationOrigin,
655664 } ,
656665 mockReadWorkflowInputFields
657666 )
@@ -661,6 +670,7 @@ describe('Tool Parameters Utils', () => {
661670 workflowId : 'parent-workflow' ,
662671 executionId : 'execution-1' ,
663672 workspaceId : 'workspace-1' ,
673+ executorDelegationOrigin,
664674 } )
665675 expect ( schema . properties . inputMapping . properties ) . toEqual ( {
666676 email : { type : 'string' , description : 'Recipient address' } ,
@@ -673,18 +683,24 @@ describe('Tool Parameters Utils', () => {
673683 await createLLMToolSchema (
674684 mockWorkflowExecutorConfig ,
675685 { workflowId : 'parent-workflow' } ,
676- { userId : 'user-1' , workflowId : 'parent-workflow' , executionId : 'execution-1' } ,
686+ {
687+ userId : 'user-1' ,
688+ workflowId : 'parent-workflow' ,
689+ executionId : 'execution-1' ,
690+ executorDelegationOrigin,
691+ } ,
677692 mockReadWorkflowInputFields
678693 )
679694
680695 expect ( mockReadWorkflowInputFields ) . toHaveBeenCalledWith ( 'parent-workflow' , {
681696 userId : 'user-1' ,
682697 workflowId : 'parent-workflow' ,
683698 executionId : 'execution-1' ,
699+ executorDelegationOrigin,
684700 } )
685701 } )
686702
687- it ( 'leaves inputMapping untyped and issues no request without an execution subject ' , async ( ) => {
703+ it ( 'leaves inputMapping untyped and issues no request without trusted execution authority ' , async ( ) => {
688704 const { schema } = await createLLMToolSchema (
689705 mockWorkflowExecutorConfig ,
690706 { workflowId : 'child-workflow' } ,
@@ -702,10 +718,19 @@ describe('Tool Parameters Utils', () => {
702718 const { schema } = await createLLMToolSchema (
703719 mockWorkflowExecutorConfig ,
704720 { workflowId : 'child-workflow' } ,
705- { userId : 'user-1' , workflowId : 'parent-workflow' } ,
721+ {
722+ userId : 'user-1' ,
723+ workflowId : 'parent-workflow' ,
724+ executorDelegationOrigin,
725+ } ,
706726 mockReadWorkflowInputFields
707727 )
708728
729+ expect ( mockReadWorkflowInputFields ) . toHaveBeenCalledWith ( 'child-workflow' , {
730+ userId : 'user-1' ,
731+ workflowId : 'parent-workflow' ,
732+ executorDelegationOrigin,
733+ } )
709734 expect ( schema . properties . inputMapping . properties ) . toBeUndefined ( )
710735 } )
711736 } )
0 commit comments