/** * channel-profiles/intake.ts * * The bridge channel intake calls when it turns an inbound message into a * session: it resolves WHO the sender is (a named principal, via the principal * registry) and WHICH profile the originating channel binds (model/permission * defaults, via the channel-profile registry), and packages both into the two * things the origination path needs, session metadata (attribution) and spawn * overrides (model/provider) plus the permission posture. * * These are pure functions over the two registries so intake adopts them with a * single call before submitMessage/trySpawnAgent, without the SharedSessionBroker * needing to know about principals or channel profiles. */ import { type PrincipalRegistry, type PrincipalResolution } from '../principals/index.js'; import type { ChannelProfileRegistry } from './registry.js'; import type { ChannelPermissionMode, ChannelProfileDefaults } from './types.js'; import type { ChannelPolicyManager } from '../channels/policy-manager.js'; /** Stable session-metadata keys the attribution stamps. */ export declare const ATTRIBUTED_PRINCIPAL_ID_KEY = "attributedPrincipalId"; export declare const ATTRIBUTED_PRINCIPAL_NAME_KEY = "attributedPrincipalName"; export declare const ATTRIBUTED_PRINCIPAL_KNOWN_KEY = "attributedPrincipalKnown"; /** * Stable session-metadata keys recording the channel profile applied at intake: * the model/provider the originating channel binds and the permission posture. * Recorded on the originated session so the profile it inherited is observable * and the spawn path can pick the model/provider up from the session it belongs * to (never overriding a value the caller set explicitly). */ export declare const CHANNEL_PROFILE_MODEL_KEY = "channelProfileModel"; export declare const CHANNEL_PROFILE_PROVIDER_KEY = "channelProfileProvider"; export declare const CHANNEL_PROFILE_PERMISSION_MODE_KEY = "channelProfilePermissionMode"; export interface InboundSender { /** The surface the message arrived on (e.g. 'slack'), used as the identity channel. */ readonly surfaceKind: string; /** The sender's channel-specific id (a Slack user id, an address, a number). */ readonly userId?: string | undefined; /** The channel/account within the surface, to scope the profile binding. */ readonly channelId?: string | undefined; } /** * Resolve the sending principal for an inbound message and produce the session * metadata that attributes the originated session to it. An absent userId or an * unmapped identity attributes to the honest unknown principal (known:false), * never a guess. * * `channelPolicy`, when supplied, is the one exception to "never a guess": a * sender who is not in the named-principal registry but whom the channel's OWN * ingress policy already authorized as its owner (the per-surface allowlist * self-seeded from whoever pairs the channel first, see * `ChannelPolicyManager.evaluateIngress`) is attributed to the honest OWNER * principal, not the unknown one. Channel policy already decided this sender is * the owner in order to let the message through at all; attribution repeating * "unknown" for the person the platform just finished authorizing would be * dishonest, not cautious. */ export declare function attributeInboundSession(principals: Pick, sender: InboundSender, channelPolicy?: Pick | undefined): Promise<{ readonly metadata: Record; readonly resolution: PrincipalResolution | null; }>; /** Resolve the profile the originating channel binds, or null when none applies. */ export declare function resolveOriginationProfile(channelProfiles: Pick, sender: Pick): Promise; /** * Merge a channel profile's model/provider into a spawn input WITHOUT overriding * values the caller already set explicitly, a channel default fills a gap, it * never overrules an intent the intake path expressed. Returns a new object. */ export declare function applyChannelProfileToSpawn(spawnInput: T, defaults: ChannelProfileDefaults | null | undefined): T; /** The complete enrichment for one inbound message: attribution + profile + posture. */ export interface InboundIntakeEnrichment { readonly sessionMetadata: Record; readonly spawnOverrides: { readonly model?: string; readonly provider?: string; }; readonly permissionMode?: ChannelPermissionMode | undefined; readonly principal: PrincipalResolution | null; } /** * One call intake makes to enrich an origination: resolves the sending principal * and the channel's bound profile, returning the session metadata to stamp, the * spawn model/provider overrides to apply, and the permission posture to set. */ export declare function buildInboundIntakeEnrichment(deps: { readonly principals: Pick; readonly channelProfiles: Pick; readonly channelPolicy?: Pick | undefined; }, sender: InboundSender): Promise; //# sourceMappingURL=intake.d.ts.map