@@ -21,10 +21,15 @@ const registeredKnowledgeOperationIds = new Set<string>(
2121 Object . values ( knowledgeOperations ) . map ( ( operation ) => operation . id )
2222)
2323
24- /** Normalizes immutable Copilot execution identity into a knowledge delegation. */
25- export function resolveCopilotKnowledgePrincipal (
24+ type TrustedCopilotKnowledgeDelegationContext = CopilotKnowledgeDelegationContext & {
25+ workspaceId : string
26+ toolCallId : string
27+ copilotToolExecution : true
28+ }
29+
30+ function requireTrustedCopilotKnowledgeContext (
2631 context : CopilotKnowledgeDelegationContext | undefined
27- ) : DelegatedPrincipal {
32+ ) : TrustedCopilotKnowledgeDelegationContext {
2833 if ( ! context ) throw new Error ( 'Knowledge delegation requires a Copilot execution context' )
2934 if ( ! context . copilotToolExecution ) {
3035 throw new Error ( 'Knowledge delegation requires a trusted Copilot execution context' )
@@ -33,7 +38,23 @@ export function resolveCopilotKnowledgePrincipal(
3338 if ( ! context . workspaceId ) throw new Error ( 'Knowledge delegation requires a workspace ID' )
3439 if ( ! context . toolCallId ) throw new Error ( 'Knowledge delegation requires a tool call ID' )
3540
36- return createCopilotWorkspacePrincipal ( context , {
41+ return context as TrustedCopilotKnowledgeDelegationContext
42+ }
43+
44+ /** Requires the immutable trusted workspace bound to a Copilot Knowledge execution. */
45+ export function requireCopilotKnowledgeWorkspaceId (
46+ context : CopilotKnowledgeDelegationContext | undefined
47+ ) : string {
48+ return requireTrustedCopilotKnowledgeContext ( context ) . workspaceId
49+ }
50+
51+ /** Normalizes immutable Copilot execution identity into a knowledge delegation. */
52+ export function resolveCopilotKnowledgePrincipal (
53+ context : CopilotKnowledgeDelegationContext | undefined
54+ ) : DelegatedPrincipal {
55+ const trustedContext = requireTrustedCopilotKnowledgeContext ( context )
56+
57+ return createCopilotWorkspacePrincipal ( trustedContext , {
3758 audience : KNOWLEDGE_DELEGATION_AUDIENCE ,
3859 } )
3960}
0 commit comments