import type { OrganizationSkillReach, SkillFile, SkillRecord, SkillWriteContext, SkillWriteReceipt, SkillActor, SkillReviewReference } from "@opengeni/contracts"; import { type Database } from "./database.js"; /** The existing portable artifact framing; never substitutes for a historical content hash. */ export declare function skillFilesContentHash(files: readonly SkillFile[]): string; /** * A Skill change the lifecycle refused, rolled back as a whole. `code` is the * SQLSTATE (42501 not permitted, 40001/23505 changed or key reused, 22023/23514 * invalid) and `message` the lifecycle's own fixed explanation, never a query * or its parameters. The original driver error stays as `cause`. */ export declare class SkillLifecycleRefusedError extends Error { readonly code: string; readonly retryable: boolean; constructor(code: string, message: string, options: { cause: unknown; }); } /** HTTP authorization must precede this boundary. Agent claims are host-bound, not model input. */ export declare function applySkillLifecycle(db: Database, context: SkillWriteContext, request: Record): Promise; export type SkillReadContext = { accountId: string; workspaceId: string; /** Trusted subject enables the existing user-tier visibility; agents share workspace reads. */ subjectId?: string; }; /** Scope only, for authorizing an exact human deletion retry after the head is gone. * The lifecycle still verifies the complete request fingerprint before replay. */ export declare function readSkillRemovalScope(db: Database, context: SkillReadContext & { subjectId: string; }, skillId: string, operationId: string): Promise<"workspace" | "user" | null>; /** Recheck the host-bound attempt before any agent-facing Skill read/search. */ export declare function assertSkillReadAttempt(db: Database, context: SkillReadContext & { actor: Extract; }): Promise; export type SkillDescriptor = { id: string; stableKey: string; title: string; description: string; revisionId: string; scopeVersion: number; installationVersion: number | null; activationMode: "workspace_managed" | "session_selected"; /** * The SKILL.md of a personal (user-scope) Skill that has no other files and * fits the caller's byte cap; null otherwise. Present only when requested. */ personalSkillMarkdown?: string | null; }; /** Active metadata only: building an index must not transfer every Skill folder. */ export declare function listSkillDescriptors(db: Database, context: SkillReadContext, options?: { /** Also return the SKILL.md of small single-file personal Skills, up to this many bytes. */ personalSkillMarkdownMaxBytes?: number; }): Promise; /** Same live descriptor visibility, without transferring metadata just to test presence. */ export declare function hasWorkspaceManagedSkill(db: Database, context: SkillReadContext): Promise; export declare function listSkillRecords(db: Database, context: SkillReadContext, options?: { skillId?: string; revisionId?: string; limit?: number; metadataOnly?: boolean; /** Pending revisions authored by this exact session, independent of event retention. */ sessionId?: string; after?: { stableKey: string; id: string; }; /** * People's Skills pages list organization Skills that don't work in this * workspace too, marked `availableHere: false`, so their managers can change * that from anywhere. Agents' reads leave this off and never see them. */ includeOrganizationElsewhere?: boolean; /** Only Skills of this scope (`user` is the person's own). */ scope?: "workspace" | "organization" | "user"; }): Promise; export type OrganizationSkillReachUpdate = { status: "updated"; reach: OrganizationSkillReach; } | { status: "not_found"; } | { status: "not_organization"; } | { status: "unknown_workspaces"; workspaceIds: string[]; }; /** * Change where an organization Skill works. The caller has checked that the * person may manage organization Skills. Agents in a workspace it no longer * works in stop seeing it from their next turn's Skill index. */ export declare function updateOrganizationSkillReach(db: Database, input: { accountId: string; workspaceId: string; subjectId: string; skillId: string; allowedWorkspaceIds: readonly string[] | null; allowPersonalWorkspaces: boolean; }): Promise; export declare class SkillHumanResponseError extends Error { readonly code: "conflict" | "forbidden" | "invalid"; constructor(code: "conflict" | "forbidden" | "invalid", cause: unknown); } /** Called only inside canonical-human response admission, after the answer and * authorization stamp were written in the same transaction. The lifecycle * independently requires that stamp and the exact initiating human. */ export declare function confirmSkillHumanResponse(db: Database, input: { accountId: string; workspaceId: string; subjectId: string; requestId: string; }): Promise; /** Current projection is separate from the immutable original write receipt. */ export declare function skillReviewResolution(db: Database, context: SkillReadContext, review: SkillReviewReference): Promise<"pending" | "activated" | "removed" | "declined" | "superseded" | "unavailable">;