/** * Type system for the skill-script model. * * This module defines the complete type contract for backend skills in `.github/skills/`. * Skills contain `scripts/` directories with executable JS handlers that replace built-in * tool handlers in ToolRegistry. * * The skill-script model enables stateful, framework-aware backends for tasks, decisions, * memories, and logging concerns. Handlers are ordinary async functions that return * SquadToolResult values. */ import type { SquadToolResult, SquadTool } from "../adapter/types.js"; /** * Arguments for squad_create_issue. * All tool arg interfaces include [key: string]: unknown for skill-documented extensions. */ export interface CreateIssueArgs { title: string; body?: string; assignee?: string; [key: string]: unknown; } /** * Arguments for squad_update_issue. */ export interface UpdateIssueArgs { issueId: string | number; title?: string; body?: string; [key: string]: unknown; } /** * Arguments for squad_list_issues. */ export interface ListIssuesArgs { status?: "all" | "open" | "closed"; limit?: number; [key: string]: unknown; } /** * Arguments for squad_close_issue. */ export interface CloseIssueArgs { issueId: string | number; comment?: string; [key: string]: unknown; } /** * Arguments for squad_create_decision. */ export interface CreateDecisionArgs { author: string; summary: string; body: string; [key: string]: unknown; } /** * Arguments for squad_list_decisions. */ export interface ListDecisionsArgs { status?: "all" | "pending" | "merged"; limit?: number; [key: string]: unknown; } /** * Arguments for squad_merge_decision. */ export interface MergeDecisionArgs { slugs?: string[]; [key: string]: unknown; } /** * Arguments for squad_create_memory. */ export interface CreateMemoryArgs { content: string; agent?: string; [key: string]: unknown; } /** * Arguments for squad_list_memories. */ export interface ListMemoriesArgs { agent?: string; limit?: number; [key: string]: unknown; } /** * Arguments for squad_create_log. */ export interface CreateLogArgs { kind: "orchestration" | "session"; content: string; agent?: string; [key: string]: unknown; } /** * Arguments for squad_list_logs. */ export interface ListLogsArgs { kind?: "orchestration" | "session"; limit?: number; [key: string]: unknown; } /** * Skill handler function. * * @param args - Tool input matching the tool's schema * @param config - Non-framework keys from the tracking config entry (excludes 'skill', 'disposeTimeoutMs') * @returns SquadToolResult (string or SquadToolResultObject) */ export type SkillHandler = (args: TArgs, config: Record) => Promise | SquadToolResult; /** * Lifecycle hooks for stateful backend skills. * lifecycle.js in the scripts/ dir exports these. */ export interface HandlerLifecycle { /** * Called once after handler resolution, before first tool call. * init() must be idempotent. */ init?(config: Record): Promise; /** * Called once at session end. * Must be safe to call even if init() partially failed. */ dispose?(): Promise; } /** * Task concern handlers (squad_*_issue). */ export interface TaskHandlers extends HandlerLifecycle { squad_create_issue?: SkillHandler; squad_update_issue?: SkillHandler; squad_list_issues?: SkillHandler; squad_close_issue?: SkillHandler; } /** * Decision concern handlers (squad_*_decision). */ export interface DecisionHandlers extends HandlerLifecycle { squad_create_decision?: SkillHandler; squad_list_decisions?: SkillHandler; squad_merge_decision?: SkillHandler; } /** * Memory concern handlers (squad_*_memory). */ export interface MemoryHandlers extends HandlerLifecycle { squad_create_memory?: SkillHandler; squad_list_memories?: SkillHandler; } /** * Logging concern handlers (squad_*_log). */ export interface LogHandlers extends HandlerLifecycle { squad_create_log?: SkillHandler; squad_list_logs?: SkillHandler; } /** * Union of all handler interfaces. */ export type AllHandlers = TaskHandlers & DecisionHandlers & MemoryHandlers & LogHandlers; /** * Strip HandlerLifecycle keys, keep only tool-name keys. */ type OwnKeys = Exclude; /** * true if A and B share no tool-name keys; never otherwise. */ type AssertDisjoint = Extract, OwnKeys> extends never ? true : never; export type _TaskDecision = AssertDisjoint; export type _TaskMemory = AssertDisjoint; export type _TaskLog = AssertDisjoint; export type _DecisionMemory = AssertDisjoint; export type _DecisionLog = AssertDisjoint; export type _MemoryLog = AssertDisjoint; /** * Maps concern names to their handler interfaces. */ export interface ConcernMap { tasks: TaskHandlers; decisions: DecisionHandlers; memories: MemoryHandlers; logging: LogHandlers; } /** * Valid concern names. */ export type Concern = keyof ConcernMap; /** * Return type for SkillScriptLoader.load(). */ export interface LoadResult { /** * Fully-formed SquadTool entries — skill handlers combined with built-in schemas. */ tools: SquadTool[]; /** * Lifecycle hooks from scripts/lifecycle.js, if present. */ lifecycle?: { init?(config: Record): Promise; dispose?(): Promise; }; } /** * Skill configuration entry. * * Specifies a skill directory path and optional disposal timeout. * The 'package' key is reserved for future use and forbidden here. * * @warning **Security note:** `backendConfig` is for non-secret runtime configuration (URLs, feature * flags, timeouts). Do NOT put credentials, tokens, or secrets in `backendConfig` — this config is * part of the skill definition and will be committed to the repository. Handler scripts run with full * process trust and can access the filesystem and the network. Only load skills from trusted sources. */ export interface SkillConfig { /** Path to skill directory (relative to squad root) */ skill: string; /** Prevent future package key coexisting with skill */ package?: never; /** Timeout for dispose() in ms (default: 10000) */ disposeTimeoutMs?: number; [key: string]: unknown; } /** * A reference to a backend: * - undefined → built-in markdown (default) * - "markdown" → built-in markdown (explicit reset) * - "noop" → silent no-op (disables the concern) * - { skill, ...opts } → skill directory with config options */ export type BackendRef = "markdown" | "noop" | SkillConfig; /** * Direct handler registration (alternative to skill path). * Used for programmatically-provided handlers. */ export interface HandlerRegistration { handlers: H; } /** * Tracking configuration for backend skills. * * Controls which backend (markdown, noop, or skill) serves each concern. * Supports a global default with per-concern overrides. */ export interface TrackingConfig { /** Backend for ALL concerns unless individually overridden */ default?: BackendRef; decisions?: BackendRef | HandlerRegistration; memories?: BackendRef | HandlerRegistration; tasks?: BackendRef | HandlerRegistration; logging?: BackendRef | HandlerRegistration; } /** * Identity function for type inference in handler scripts. * * Provides compile-time safety when authoring TypeScript handlers. * The compiled .js output is a plain function — no runtime dependency on this. * * @example * ```typescript * export default defineHandler(async (args, config) => { * return { type: "success", text: `Issue created: ${args.title}` }; * }); * ``` */ export declare function defineHandler(handler: SkillHandler): SkillHandler; export {}; //# sourceMappingURL=handler-types.d.ts.map