@@ -6,8 +6,8 @@ describe("buildDiscordNativeCommandContext", () => {
66 const ctx = buildDiscordNativeCommandContext ( {
77 prompt : "/status" ,
88 commandArgs : { } ,
9- sessionKey : "agent:codex:discord:slash:user-1 " ,
10- commandTargetSessionKey : "agent:codex:discord:direct:user-1 " ,
9+ sessionKey : "agent:codex:discord:slash:123456789 " ,
10+ commandTargetSessionKey : "agent:codex:discord:direct:123456789 " ,
1111 accountId : "default" ,
1212 interactionId : "interaction-1" ,
1313 channelId : "dm-1" ,
@@ -17,24 +17,28 @@ describe("buildDiscordNativeCommandContext", () => {
1717 isGuild : false ,
1818 isThreadChannel : false ,
1919 user : {
20- id : "user-1 " ,
20+ id : "123456789 " ,
2121 username : "tester" ,
2222 globalName : "Tester" ,
2323 } ,
2424 sender : {
25- id : "user-1 " ,
25+ id : "123456789 " ,
2626 tag : "tester#0001" ,
2727 } ,
28+ identityLinks : {
29+ owner : [ "discord:123456789" ] ,
30+ } ,
2831 timestampMs : 123 ,
2932 } ) ;
3033
31- expect ( ctx . From ) . toBe ( "discord:user-1 " ) ;
32- expect ( ctx . To ) . toBe ( "slash:user-1 " ) ;
34+ expect ( ctx . From ) . toBe ( "discord:123456789 " ) ;
35+ expect ( ctx . To ) . toBe ( "slash:123456789 " ) ;
3336 expect ( ctx . ChatType ) . toBe ( "direct" ) ;
3437 expect ( ctx . ConversationLabel ) . toBe ( "Tester" ) ;
35- expect ( ctx . SessionKey ) . toBe ( "agent:codex:discord:slash:user-1" ) ;
36- expect ( ctx . CommandTargetSessionKey ) . toBe ( "agent:codex:discord:direct:user-1" ) ;
37- expect ( ctx . OriginatingTo ) . toBe ( "user:user-1" ) ;
38+ expect ( ctx . SessionKey ) . toBe ( "agent:codex:discord:slash:123456789" ) ;
39+ expect ( ctx . CommandTargetSessionKey ) . toBe ( "agent:codex:discord:direct:123456789" ) ;
40+ expect ( ctx . OriginatingTo ) . toBe ( "user:123456789" ) ;
41+ expect ( ctx . TrustedSenderPrincipal ) . toBe ( "owner" ) ;
3842 expect ( ctx . UntrustedContext ) . toBeUndefined ( ) ;
3943 expect ( ctx . UntrustedStructuredContext ) . toBeUndefined ( ) ;
4044 expect ( ctx . GroupSystemPrompt ) . toBeUndefined ( ) ;
@@ -45,7 +49,7 @@ describe("buildDiscordNativeCommandContext", () => {
4549 const ctx = buildDiscordNativeCommandContext ( {
4650 prompt : "/status" ,
4751 commandArgs : { values : { model : "gpt-5.2" } } ,
48- sessionKey : "agent:codex:discord:slash:user-1 " ,
52+ sessionKey : "agent:codex:discord:slash:123456789 " ,
4953 commandTargetSessionKey : "agent:codex:discord:channel:chan-1" ,
5054 accountId : "default" ,
5155 interactionId : "interaction-1" ,
@@ -56,7 +60,7 @@ describe("buildDiscordNativeCommandContext", () => {
5660 channelTopic : "Production alerts only" ,
5761 channelConfig : {
5862 allowed : true ,
59- users : [ "discord:user-1 " ] ,
63+ users : [ "discord:123456789 " ] ,
6064 systemPrompt : "Use the runbook." ,
6165 } ,
6266 guildInfo : {
@@ -69,14 +73,17 @@ describe("buildDiscordNativeCommandContext", () => {
6973 isGuild : true ,
7074 isThreadChannel : true ,
7175 user : {
72- id : "user-1 " ,
76+ id : "123456789 " ,
7377 username : "tester" ,
7478 } ,
7579 sender : {
76- id : "user-1 " ,
80+ id : "123456789 " ,
7781 name : "tester" ,
7882 tag : "tester#0001" ,
7983 } ,
84+ identityLinks : {
85+ alice : [ "discord:123456789" ] ,
86+ } ,
8087 timestampMs : 456 ,
8188 } ) ;
8289
@@ -87,7 +94,8 @@ describe("buildDiscordNativeCommandContext", () => {
8794 expect ( ctx . GroupSpace ) . toBe ( "guild-1" ) ;
8895 expect ( ctx . MemberRoleIds ) . toEqual ( [ "admin" ] ) ;
8996 expect ( ctx . GroupSystemPrompt ) . toBe ( "Use the runbook." ) ;
90- expect ( ctx . OwnerAllowFrom ) . toEqual ( [ "user-1" ] ) ;
97+ expect ( ctx . OwnerAllowFrom ) . toEqual ( [ "123456789" ] ) ;
98+ expect ( ctx . TrustedSenderPrincipal ) . toBe ( "alice" ) ;
9199 expect ( ctx . MessageThreadId ) . toBe ( "chan-1" ) ;
92100 expect ( ctx . ThreadParentId ) . toBe ( "parent-1" ) ;
93101 expect ( ctx . OriginatingTo ) . toBe ( "channel:chan-1" ) ;
0 commit comments