import type { Database } from "./database.js"; import * as schema from "./schema.js"; type RouteSession = Pick; /** Where a child's blocking question goes, and the hop its authority comes from. */ export type ChildRequiresActionRoute = { targetSessionId: string; /** The session directly under the target on the child's path: the child itself for its parent. */ via: RouteSession; /** The parent that could not act, when the question went further up. */ escalatedFromSessionId: string | null; /** Whether the target's agent can answer it now: not the fallback parent, not waiting for capacity. */ targetCanAct: boolean; }; /** Bounded walk: a question goes to the nearest ancestor that can act, never further. */ export declare const CHILD_REQUIRES_ACTION_ESCALATION_LIMIT = 32; /** * Whether a session's agent can act on a child's question: it is not failed or * cancelled, and its frozen agent configuration has the session tools * (`subagents`, which carries session_human_input_respond). A legacy session * without a configuration counts as able. */ export declare function sessionCanActOnChildQuestion(row: { status: string; agentConfig: unknown; }): boolean; /** * The session a child's `child_requires_action` notice goes to. Normally its * parent. When the parent cannot act on it (see sessionCanActOnChildQuestion), * the nearest ancestor that can, so the question does not sit with an agent * that cannot handle it. Only one session gets it. With `targetSessionId`, * the route to that exact ancestor (a resolution follows its question). * Falls back to the parent when no ancestor qualifies or the chain is broken. */ export declare function childRequiresActionRouteTx(tx: Database, workspaceId: string, session: RouteSession & { parentSessionId: string; }, targetSessionId?: string | null): Promise; /** The session the outbox sent this exact child question to, if it is still recorded. */ export declare function recordedChildNoticeTargetTx(tx: Database, workspaceId: string, dedupeKey: string): Promise; /** Preserve the accepted producer evidence identically for every notice kind. */ export declare function parentOutboxAuthorityTx(tx: Database, workspaceId: string, session: Pick & { parentSessionId: string; }): Promise<{ personalConnectionDelegations: { serverId: string; canonicalServerId?: string | undefined; connectionId: string; originWorkspaceId?: string | undefined; ownerSubjectId: string; providerDomain: string; kind?: "api_key" | "app_install" | "delegated" | "oauth2" | undefined; connectionType?: "atlassian" | "github_personal" | "mcp" | "social" | undefined; userDelegation?: { authorityId: string; grantId: string; organizationId: string; workspaceId: string; sessionId: string | null; action: string; mode: "always" | "once" | "session"; context: "user_private" | "workspace_shared"; authorityEpoch: number | null; authorityGeneration: number; grantGeneration: number; resourceVersionId?: string | null | undefined; } | undefined; personalGitHubRepositorySelection?: { credentialBindingId: string; connectionAuthorityGeneration: number; selectionGeneration: number; allRepositoriesAccess?: "read" | "write" | undefined; repositories: { repositoryId: string; fullName: string; canonicalUrl: string; ref: string; access: "read" | "write"; selectionGeneration: number; }[]; } | undefined; outputDestination?: { folderId: string; folderName: string; driveId: string | null; location: "my_drive" | "shared_drive"; selectedAt: string; } | undefined; }[]; mcpAccountBindings: { serverId: string; canonicalServerId: string; connectionId: string; originWorkspaceId: string; subjectScope: "subject" | "workspace"; ownerSubjectId: string | null; accountLabel: string; providerDomain: string; kind: "api_key" | "app_install" | "delegated" | "oauth2"; connectionRef: { connectionId?: string | undefined; accountSelection?: "all_eligible" | undefined; authoritySource?: "host" | undefined; hostBinding?: { bindingId: string; generation: number; } | { selection: "accepted_turn"; } | undefined; provider?: string | undefined; providerDomain: string; kind?: "api_key" | "app_install" | "delegated" | "oauth2" | undefined; scopes?: string[] | undefined; resource?: string | undefined; selectedResources?: { id: string; kind: "repository"; }[] | undefined; subjectScope?: "subject" | "workspace" | undefined; }; connectionAuthorityGeneration?: number | undefined; }[] | null; xaiProviderAccountAuthoritySnapshot: { version: 1; scope: "organization"; } | { version: 1; scope: "workspace"; } | { version: 1; scope: "user"; authorityGeneration: number; } | { readonly version: 1; readonly scope: "workspace"; }; claudeProviderAccountAuthoritySnapshot: { version: 1; scope: "organization"; } | { version: 1; scope: "workspace"; } | { version: 1; scope: "user"; authorityGeneration: number; } | { readonly version: 1; readonly scope: "workspace"; }; subscriptionAuthority: { version: 2; personal: { provider: "claude" | "codex" | "xai"; ownerMembershipId: string; authorityGeneration: number; sharedSessionChoice?: { sessionId: string; connectionId: string; } | undefined; }[]; } | null; lineage: { childSessionId: string; parentSessionId: string; parentTurnId?: string; connectionAuthoritySubjectId?: string | null; xaiAuthoritySubjectId?: string; claudeAuthoritySubjectId?: string; }; }>; export {};