import { type Config, type RunnerName } from "./config.js"; import { DeliveryLog } from "./delivery-log.js"; import { type Secrets } from "./env.js"; import { type TemplateWrite } from "./examples.js"; import { JobStore, type JobRecord } from "./jobs.js"; import { type Logger } from "./logger.js"; import type { Paths } from "./paths.js"; import { type AdhocRunInput, type ManualRunInput } from "./manual.js"; import { publicJob } from "./server.js"; import { type LoadedProject } from "./projects.js"; import { SkillRegistry } from "./registry.js"; import { type AuthType, type NormalizedAuth, type Skill } from "./skills.js"; export interface Ops { paths: Paths; config: Config; secrets: () => Secrets; /** Secrets from the .env file only. */ fileSecrets: () => Secrets; registry: SkillRegistry; store: JobStore; /** What the server recorded about every webhook it received (read-only outside the server). */ deliveryLog: DeliveryLog; logger: Logger; } export declare function createOps(paths: Paths, options?: { env?: NodeJS.ProcessEnv; logger?: Logger; config?: Config; }): Ops; /** Auth schemes whose secret skillhook can invent (the sender is configured with it afterwards). */ export declare function skillhookManagesSecret(auth: NormalizedAuth): boolean; /** Resolves `admin`, a skill name, or an ENV_VAR_NAME to the env var that holds the secret. */ export declare function resolveSecretName(ops: Ops, name: string): { env: string; skill?: Skill; }; export interface SecretResult { env: string; /** The new value; only present when a value was generated by this call. */ generated?: string; existed: boolean; } export declare function generateSecretFor(ops: Ops, name: string, options?: { force?: boolean; bytes?: number; }): SecretResult; export declare function setSecret(ops: Ops, name: string, value: string): { env: string; }; /** Makes sure a skill whose secret skillhook manages has one; provider-signed skills are left alone. */ export declare function ensureSkillSecret(ops: Ops, skill: Skill): SecretResult | undefined; export interface CreateSkillInput { name: string; description: string; instructions?: string; runner?: RunnerName; model?: string; effort?: string; authType?: AuthType; secretEnv?: string; cwd?: string; timeoutSeconds?: number; when?: unknown[]; env?: string[]; overwrite?: boolean; /** Skip creating a secret (for provider-signed auth you still have to `secret set` it). */ noSecret?: boolean; } export interface CreateSkillResult { skill: Skill; file: string; created: boolean; secret?: SecretResult; /** What the sender must do to authenticate, for humans. */ authNote: string; } export declare function createSkill(ops: Ops, input: CreateSkillInput): CreateSkillResult; export declare function authNoteFor(skill: Skill, secret?: SecretResult): string; export declare function addExampleSkill(ops: Ops, exampleName: string, asName?: string): CreateSkillResult; /** The `projects` entries of skillhook.json as written (no defaults, no resolution). */ export declare function linkedProjectEntries(ops: Ops): string[]; /** Every linked project, loaded. */ export declare function listProjects(ops: Ops): LoadedProject[]; export interface LinkResult { /** The absolute path written to skillhook.json (a directory, or the YAML file when one was named). */ entry: string; project: LoadedProject; /** False when the project was linked before (the entry is left as it was). */ added: boolean; /** Secrets generated for hooks whose auth skillhook manages (bearer, basic, generic hmac). */ secrets: (SecretResult & { hook: string; })[]; /** Hooks whose name is already taken by another source, or that failed to compile. */ errors: { name: string; error: string; }[]; } /** * Registers a directory's skillhook.yaml (or the file itself) in `projects` of skillhook.json. The file must * exist and parse; individual hook problems are reported, not fatal. The running server picks the hooks up * without a restart. */ export declare function linkProject(ops: Ops, dirOrFile: string, options?: { noSecret?: boolean; }): LinkResult; /** Removes a project from `projects`; the hooks stop routing (404) at once. Nothing in the project is touched. */ export declare function unlinkProject(ops: Ops, dirOrFile: string): { entry: string; removed: boolean; }; export interface InitProjectResult { file: string; /** False when the file already existed and `force` was not set (nothing written). */ written: boolean; /** With `--template`: every file the template wrote or kept, and the names it filled in. */ template?: TemplateWrite; link: LinkResult; } /** Writes a starter skillhook.yaml into a directory (creating it if needed) and links the project. */ export declare function initProject(ops: Ops, dir: string, options?: { force?: boolean; noSecret?: boolean; template?: string; }): InitProjectResult; /** `~/dev/api (skillhook.yaml)` for humans. */ export declare function describeProject(project: LoadedProject): string; /** Runs an already created job in this process (a private queue) and resolves when it finishes or `waitMs` elapses. */ export declare function runJobLocally(ops: Ops, job: JobRecord, options: { waitMs?: number; timeoutSeconds: number; }): Promise; /** Creates and runs one job in this process and resolves when it finishes or `waitMs` elapses. */ export declare function runSkillLocally(ops: Ops, input: ManualRunInput & { waitMs?: number; onStart?: (job: JobRecord) => void; }): Promise; /** `skillhook run --file`: runs a SKILL.md that is not installed, in this process. */ export declare function runAdhocLocally(ops: Ops, input: AdhocRunInput & { waitMs?: number; onStart?: (job: JobRecord, skill: Skill) => void; }): Promise; export interface ServerRunResult { baseUrl: string; status: number; body: unknown; } /** POSTs a JSON body to the running server's admin API; undefined when no server is running. */ export declare function postToServer(ops: Ops, path: string, body: unknown): Promise; /** Triggers a skill through the running server's admin API; undefined when no server is running. */ export declare function triggerViaServer(ops: Ops, input: { skill: Skill; payload: unknown; headers?: Record; overrides?: { runner?: RunnerName; model?: string; effort?: string; }; waitSeconds?: number; }): Promise; export type UrlSource = "config" | "tailscale" | "server" | "local"; export declare function resolveBaseUrl(ops: Ops, options?: { prefer?: "public" | "local"; }): Promise<{ baseUrl: string; source: UrlSource; }>; export declare function webhookUrl(baseUrl: string, skillName: string): string; export interface SendResult { url: string; status: number; body: unknown; /** Names of the auth headers that were attached (values are never returned). */ signedHeaders: string[]; job?: Record; } /** Signs a payload exactly like the configured sender would and POSTs it to `/hooks/`. */ export declare function sendSignedWebhook(ops: Ops, input: { skill: Skill; payload: unknown; baseUrl: string; waitSeconds?: number; headers?: Record; }): Promise; export { publicJob }; export * from "./answer.js"; export * from "./manual.js"; export * from "./replay.js";