@@ -215,7 +215,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
215215 start_timestamp : undefined ,
216216 end_timestamp : undefined ,
217217 agent_id : undefined ,
218- created_by_subject_id : undefined ,
218+ created_by_or_agent_ids : undefined ,
219219 } ) ;
220220 expect ( listed . data . map ( s => s . session_id ) ) . toContain ( 'created-by-session' ) ;
221221 expect ( listed . data . find ( s => s . session_id === 'created-by-session' ) ?. created_by_subject . subject_id ) . toBe (
@@ -241,7 +241,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
241241
242242 const filtered = await store . listSessions ( {
243243 agent_id : 'agent-abc' ,
244- created_by_subject_id : undefined ,
244+ created_by_or_agent_ids : undefined ,
245245 tenant_id : tenant ,
246246 limit : 10 ,
247247 page_token : undefined ,
@@ -578,7 +578,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
578578
579579 const listed = await store . listSessions ( {
580580 agent_id : undefined ,
581- created_by_subject_id : undefined ,
581+ created_by_or_agent_ids : undefined ,
582582 tenant_id : tenant ,
583583 limit : 10 ,
584584 page_token : undefined ,
@@ -834,7 +834,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
834834
835835 const desc = await store . listSessions ( {
836836 agent_id : undefined ,
837- created_by_subject_id : undefined ,
837+ created_by_or_agent_ids : undefined ,
838838 tenant_id : tenant ,
839839 limit : 10 ,
840840 page_token : undefined ,
@@ -846,7 +846,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
846846
847847 const asc = await store . listSessions ( {
848848 agent_id : undefined ,
849- created_by_subject_id : undefined ,
849+ created_by_or_agent_ids : undefined ,
850850 tenant_id : tenant ,
851851 limit : 10 ,
852852 page_token : undefined ,
@@ -863,7 +863,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
863863
864864 const first = await store . listSessions ( {
865865 agent_id : undefined ,
866- created_by_subject_id : undefined ,
866+ created_by_or_agent_ids : undefined ,
867867 tenant_id : tenant ,
868868 limit : 2 ,
869869 page_token : undefined ,
@@ -875,7 +875,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
875875 expect ( first . pagination . next_page_token ) . toBeDefined ( ) ;
876876 const second = await store . listSessions ( {
877877 agent_id : undefined ,
878- created_by_subject_id : undefined ,
878+ created_by_or_agent_ids : undefined ,
879879 tenant_id : tenant ,
880880 limit : 2 ,
881881 page_token : first . pagination . next_page_token ,
@@ -888,7 +888,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
888888
889889 const all = await store . listSessions ( {
890890 agent_id : undefined ,
891- created_by_subject_id : undefined ,
891+ created_by_or_agent_ids : undefined ,
892892 tenant_id : tenant ,
893893 limit : 10 ,
894894 page_token : undefined ,
@@ -903,7 +903,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
903903 const middleCreatedAt = middleSession . created_at ;
904904 const bounded = await store . listSessions ( {
905905 agent_id : undefined ,
906- created_by_subject_id : undefined ,
906+ created_by_or_agent_ids : undefined ,
907907 tenant_id : tenant ,
908908 limit : 10 ,
909909 order : 'asc' ,
@@ -928,7 +928,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
928928
929929 const listArgs = {
930930 agent_id : undefined ,
931- created_by_subject_id : undefined ,
931+ created_by_or_agent_ids : undefined ,
932932 tenant_id : tenant ,
933933 order : undefined ,
934934 start_timestamp : undefined ,
@@ -954,7 +954,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
954954
955955 const listArgs = {
956956 agent_id : undefined ,
957- created_by_subject_id : undefined ,
957+ created_by_or_agent_ids : undefined ,
958958 tenant_id : tenant ,
959959 order : 'desc' as const ,
960960 start_timestamp : undefined ,
@@ -975,7 +975,7 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
975975 expect ( page2 . pagination . next_page_token ) . toBeUndefined ( ) ;
976976 } ) ;
977977
978- it ( 'filters by created_by_subject_id ' , async ( ) => {
978+ it ( 'filters by creator or named-agent ids ' , async ( ) => {
979979 const store = createStore ( ) ;
980980 await store . createSession ( {
981981 tenant_id : tenant ,
@@ -995,10 +995,31 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
995995 metadata : { } ,
996996 external_id : null ,
997997 } ) ;
998+ await store . createSession ( {
999+ tenant_id : tenant ,
1000+ session_id : 'managed-session' ,
1001+ created_by_subject : { subject_id : 'charlie' , subject_type : 'user' , subject_display_name : 'charlie' } ,
1002+ agent : { type : 'reference' , id : 'managed-agent' , name : null } ,
1003+ custom : null ,
1004+ metadata : { } ,
1005+ external_id : null ,
1006+ } ) ;
1007+ await store . createSession ( {
1008+ tenant_id : tenant ,
1009+ session_id : 'unmanaged-session' ,
1010+ created_by_subject : { subject_id : 'dave' , subject_type : 'user' , subject_display_name : 'dave' } ,
1011+ agent : { type : 'reference' , id : 'unmanaged-agent' , name : null } ,
1012+ custom : null ,
1013+ metadata : { } ,
1014+ external_id : null ,
1015+ } ) ;
9981016
9991017 const aliceOnly = await store . listSessions ( {
10001018 agent_id : undefined ,
1001- created_by_subject_id : 'alice' ,
1019+ created_by_or_agent_ids : {
1020+ created_by_subject_id : 'alice' ,
1021+ agent_ids : [ ] ,
1022+ } ,
10021023 tenant_id : tenant ,
10031024 limit : 10 ,
10041025 page_token : undefined ,
@@ -1009,9 +1030,42 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
10091030 expect ( aliceOnly . data . map ( s => s . session_id ) ) . toEqual ( [ 'alice-session' ] ) ;
10101031 expect ( aliceOnly . data [ 0 ] ?. created_by_subject . subject_id ) . toBe ( 'alice' ) ;
10111032
1033+ const aliceOrManaged = await store . listSessions ( {
1034+ agent_id : undefined ,
1035+ created_by_or_agent_ids : {
1036+ created_by_subject_id : 'alice' ,
1037+ agent_ids : [ 'managed-agent' ] ,
1038+ } ,
1039+ tenant_id : tenant ,
1040+ limit : 10 ,
1041+ page_token : undefined ,
1042+ order : 'asc' ,
1043+ start_timestamp : undefined ,
1044+ end_timestamp : undefined ,
1045+ } ) ;
1046+ expect ( aliceOrManaged . data . map ( s => s . session_id ) ) . toEqual ( [ 'alice-session' , 'managed-session' ] ) ;
1047+
1048+ const managedAgentOnly = await store . listSessions ( {
1049+ agent_id : 'managed-agent' ,
1050+ created_by_or_agent_ids : {
1051+ created_by_subject_id : 'alice' ,
1052+ agent_ids : [ 'managed-agent' ] ,
1053+ } ,
1054+ tenant_id : tenant ,
1055+ limit : 10 ,
1056+ page_token : undefined ,
1057+ order : undefined ,
1058+ start_timestamp : undefined ,
1059+ end_timestamp : undefined ,
1060+ } ) ;
1061+ expect ( managedAgentOnly . data . map ( s => s . session_id ) ) . toEqual ( [ 'managed-session' ] ) ;
1062+
10121063 const unmatched = await store . listSessions ( {
10131064 agent_id : undefined ,
1014- created_by_subject_id : 'nobody' ,
1065+ created_by_or_agent_ids : {
1066+ created_by_subject_id : 'nobody' ,
1067+ agent_ids : [ ] ,
1068+ } ,
10151069 tenant_id : tenant ,
10161070 limit : 10 ,
10171071 page_token : undefined ,
0 commit comments