import { z } from "zod"; import type { AgentActivitySummary } from "../interfaces/database.interface.js"; /** * Centralized activity-summary permission projection (IND-605). * * `read_activity_summary` is the only public name for grounded, aggregate-only * agent activity reporting. The handler passes a typed resolved caller context * into this one projection: * * - Human owners (REST/chat surfaces and session-authenticated MCP callers) * receive every domain. * - Registered agents receive only the domains their permissions authorize. * Signal IDs/titles (`opportunitiesBySignal`) require `manage:intents`. * - Question counts are meta-network: they are never narrowed by a network * binding, but each count inherits the permission of the domain the * question AFFECTS. A caller sees a domain's question counts only when it * holds that domain's permission; conversational (`chat`-mode) and * unrecognized modes are human-owner-only. There is deliberately no * any-of all-question count shortcut. * - Network agents additionally narrow network-bound aggregates to their bound * community — exposed here as `activitySummaryNetworkId` so the narrowing * happens in the query/adapter layer, never as transport-local JSON * filtering. * * The projection can only drop fields. It never fabricates data and it never * exposes counterparty identities, chats, turns, transcripts, or private * content; the strict response schema below is the explicit output contract. */ /** Canonical public tool name for aggregate activity reporting. */ export declare const READ_ACTIVITY_SUMMARY_TOOL_NAME = "read_activity_summary"; /** Activity summary domains, in stable projection order. */ export declare const ActivitySummaryDomainSchema: z.ZodEnum<["signals", "opportunities", "questions", "negotiations"]>; export type ActivitySummaryDomain = z.infer; /** * Domains a question can affect. `'chat'` covers conversational questions * (and, fail-closed, any mode added to the protocol enum later): they have no * agent-permission domain and are visible to human owners only. */ export declare const ActivityQuestionDomainSchema: z.ZodEnum<["identity", "premises", "intents", "opportunities", "negotiations", "chat"]>; export type ActivityQuestionDomain = z.infer; /** * Maps every current `QuestionMode` to the domain the question affects. * Modes missing from this table fail closed to the human-only `'chat'` * bucket so a future protocol mode can never leak to an agent caller. */ export declare const QUESTION_MODE_TO_DOMAIN: Readonly>; /** * Explicit per-domain question counts. Each key is present only when the * caller is authorized for that domain and the count is non-zero. */ export declare const ActivityQuestionCountsSchema: z.ZodObject<{ identity: z.ZodOptional; premises: z.ZodOptional; intents: z.ZodOptional; opportunities: z.ZodOptional; negotiations: z.ZodOptional; /** Human-owner-only conversational (or unrecognized) question counts. */ chat: z.ZodOptional; }, "strict", z.ZodTypeAny, { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; }, { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; }>; export type ActivityQuestionCounts = z.infer; /** * Typed resolved MCP caller context consumed by the projection. Derived from * the MCP capability subject at the transport boundary (see * `resolveMcpActivityCaller` in mcp.authorization-policy.ts); absent on * REST/chat surfaces, which are owner-trusted. */ export declare const McpActivityCallerSchema: z.ZodObject<{ /** `'human'` callers own the summarized data and see every domain. */ kind: z.ZodEnum<["human", "agent"]>; /** Canonical `manage:*` permission actions granted to the caller. */ permissions: z.ZodArray; /** A network agent's bound community; always null for humans. */ networkScopeId: z.ZodNullable; }, "strict", z.ZodTypeAny, { kind: "agent" | "human"; permissions: string[]; networkScopeId: string | null; }, { kind: "agent" | "human"; permissions: string[]; networkScopeId: string | null; }>; export type McpActivityCaller = z.infer; /** * Canonical affected-domain permission an agent must hold to read or answer a * question of the given mode. Returns `null` for human-owner-only questions * (`chat`, and any unrecognized mode, which fail closed to the human-only * bucket) — no agent permission can release those. * * This is the single shared mode → affected-domain → permission mapping, reusing * `QUESTION_MODE_TO_DOMAIN` and `QUESTION_DOMAIN_PERMISSIONS` so question * read/answer inheritance is identical to the `read_activity_summary` * projection. It keys on `mode` only: the canonical question model does not vary * a question's owning domain by `purpose` (purpose refines generation and * provenance, not the affected domain), so purpose is intentionally not a * discriminant here rather than being guessed at. */ export declare function questionModeRequiredPermission(mode: string): string | null; /** * Whether an MCP caller may read or answer a question of the given mode. Human * (owner) callers see every mode; agents are confined to modes backed by one of * their exact affected-domain permissions. A network agent's binding is applied * separately by the caller (network/intent clamp); this is purely the * affected-domain permission gate. */ export declare function callerMayAccessQuestionMode(caller: McpActivityCaller, mode: string): boolean; /** * Explicit response contract for `read_activity_summary`. Every domain field * is optional because agent callers receive only their authorized domains. * Strict: no counterparty or unspecified field can pass validation. */ export declare const ActivitySummaryResponseSchema: z.ZodObject<{ /** The reporting window actually used, in hours. */ sinceHours: z.ZodNumber; /** signals domain — liveSignalsWatched and per-signal opportunity counts. */ liveSignalsWatched: z.ZodOptional; /** opportunities domain. */ opportunitiesSurfaced: z.ZodOptional; /** signals domain — signal IDs/titles, authorized by manage:intents only. */ opportunitiesBySignal: z.ZodOptional, "many">>; /** questions domain (meta-network) — counts grouped by affected domain. */ pendingQuestionsByDomain: z.ZodOptional; premises: z.ZodOptional; intents: z.ZodOptional; opportunities: z.ZodOptional; negotiations: z.ZodOptional; /** Human-owner-only conversational (or unrecognized) question counts. */ chat: z.ZodOptional; }, "strict", z.ZodTypeAny, { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; }, { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; }>>; answeredQuestionsByDomain: z.ZodOptional; premises: z.ZodOptional; intents: z.ZodOptional; opportunities: z.ZodOptional; negotiations: z.ZodOptional; /** Human-owner-only conversational (or unrecognized) question counts. */ chat: z.ZodOptional; }, "strict", z.ZodTypeAny, { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; }, { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; }>>; /** negotiations domain. */ negotiationsStarted: z.ZodOptional; negotiationsCompleted: z.ZodOptional; }, "strict", z.ZodTypeAny, { sinceHours: number; liveSignalsWatched?: number | undefined; opportunitiesSurfaced?: number | undefined; opportunitiesBySignal?: { title: string; intentId: string; count: number; }[] | undefined; pendingQuestionsByDomain?: { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; } | undefined; answeredQuestionsByDomain?: { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; } | undefined; negotiationsStarted?: number | undefined; negotiationsCompleted?: number | undefined; }, { sinceHours: number; liveSignalsWatched?: number | undefined; opportunitiesSurfaced?: number | undefined; opportunitiesBySignal?: { title: string; intentId: string; count: number; }[] | undefined; pendingQuestionsByDomain?: { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; } | undefined; answeredQuestionsByDomain?: { chat?: number | undefined; identity?: number | undefined; intents?: number | undefined; premises?: number | undefined; opportunities?: number | undefined; negotiations?: number | undefined; } | undefined; negotiationsStarted?: number | undefined; negotiationsCompleted?: number | undefined; }>; export type ProjectedActivitySummary = z.infer; /** * Resolves the summary domains a caller may see. Human owners receive every * domain; agents receive only domains backed by one of their permissions. * The `questions` domain only flags that at least one affected-domain count * may be visible — each count is still filtered per affected domain in * `projectActivitySummary`. */ export declare function resolveActivitySummaryDomains(caller: McpActivityCaller): ActivitySummaryDomain[]; /** * Returns the bound community a network agent's network-bound aggregates must * be narrowed to in the query/adapter layer. Undefined for human callers and * global agents, whose aggregates span the owner's networks. */ export declare function activitySummaryNetworkId(caller: McpActivityCaller): string | undefined; /** * Projects a full owner-scoped summary down to the caller's authorized * domains. Pure field selection — no data is transformed or fabricated. */ export declare function projectActivitySummary(caller: McpActivityCaller, summary: AgentActivitySummary): ProjectedActivitySummary;