import { type Server } from "node:http";
export type JsonSchema = Record<string, unknown>;
export type AgentDslLanguage = "typescript" | "javascript";
export type AuthStrategy = "public" | "api_key" | "platform_user" | "jwt" | "custom";
export type AgentIdentity = {
    name: string;
    description: string;
    version?: string;
};
export type AgentDslAuth = {
    model: string;
    strategy: AuthStrategy;
    principal_schema: JsonSchema;
    resolver?: string | null;
    required: boolean;
};
export type SkillPolicy = {
    timeout_seconds?: number | null;
    idempotent?: boolean;
    max_retries?: number;
    cost_class?: string | null;
    allow_scope_expansion?: boolean;
    grant_mode?: string | null;
    grant_allow_patterns?: string[];
    grant_deny_patterns?: string[];
    grant_outputs_prefix?: string | null;
    grant_write_prefixes?: string[];
    grant_ttl_seconds?: number | null;
    grant_run_timeout_seconds?: number | null;
    grant_approval_timeout_seconds?: number | null;
    grant_scope_approval_timeout_seconds?: number | null;
};
export type SkillDeclaration = {
    name: string;
    description?: string;
    handler?: string;
    tags?: string[];
    scopes?: string[];
    stream?: boolean;
    policy?: SkillPolicy;
    input_schema: JsonSchema;
    output_schema: JsonSchema;
};
export type AgentRuntime = {
    lifecycle?: "ephemeral" | "session" | "warm";
    state?: "none" | "session" | "durable";
    sandbox?: "microsandbox";
    resources?: {
        cpu?: string;
        memory?: string;
        gpu?: number;
        max_runtime_seconds?: number;
    };
    concurrency?: number;
    egress?: {
        allow_hosts?: string[];
        allow_internal_services?: string[];
        deny_internet_by_default?: boolean;
    };
    tools_used?: string[];
    llm_provisioning?: "platform" | "platform_or_caller_provided" | "caller_provided" | "agent_byok";
    pricing?: {
        price_per_call_usd?: number;
        caller_pays_llm?: boolean;
        notes?: string;
    };
    wants_cp_jwt?: boolean;
};
export type AgentDslEntrypoint = {
    module?: string | null;
    class_name?: string | null;
    function?: string | null;
    command?: string[];
};
export type AgentDslSkill = Required<Pick<SkillDeclaration, "name" | "input_schema" | "output_schema">> & {
    description: string;
    handler: string;
    tags: string[];
    scopes: string[];
    stream: boolean;
    policy: Required<SkillPolicy>;
};
export type AgentDsl = {
    schema_version: "2026-06-04";
    language: AgentDslLanguage;
    name: string;
    description: string;
    version: string;
    entrypoint: AgentDslEntrypoint;
    skills: AgentDslSkill[];
    capabilities: Record<string, unknown>;
    input_modes: string[];
    output_modes: string[];
    required_secrets: string[];
    required_env: string[];
    consumer_setup: {
        fields: unknown[];
    };
    runtime: AgentRuntime;
    template_lineage?: unknown | null;
    meta_agent_manifest?: unknown | null;
    state_schema?: JsonSchema | null;
    workspace_access: Record<string, unknown>;
    config_schema?: JsonSchema | null;
    auth: AgentDslAuth;
    metadata: Record<string, unknown>;
};
export type AgentClass<T extends A2AAgent = A2AAgent> = {
    new (): T;
    agent: AgentIdentity;
    auth: AgentDslAuth;
    skills: SkillDeclaration[];
    capabilities: Record<string, unknown>;
    inputModes: string[];
    outputModes: string[];
    requiredSecrets: string[];
    requiredEnv: string[];
    consumerSetup: {
        fields: unknown[];
    };
    runtime: AgentRuntime;
    workspaceAccess: Record<string, unknown>;
    configSchema: JsonSchema | null;
    stateSchema: JsonSchema | null;
    templateLineage: unknown | null;
    metaAgentManifest: unknown | null;
};
export declare abstract class A2AAgent {
    static agent: AgentIdentity;
    static auth: AgentDslAuth;
    static skills: SkillDeclaration[];
    static capabilities: Record<string, unknown>;
    static inputModes: string[];
    static outputModes: string[];
    static requiredSecrets: string[];
    static requiredEnv: string[];
    static consumerSetup: {
        fields: unknown[];
    };
    static runtime: AgentRuntime;
    static workspaceAccess: Record<string, unknown>;
    static configSchema: JsonSchema | null;
    static stateSchema: JsonSchema | null;
    static templateLineage: unknown | null;
    static metaAgentManifest: unknown | null;
    dispatch(request: WorkerRequest): Promise<WorkerResponse>;
}
export type WorkerRequest = {
    agent: string;
    skill: string;
    handler: string;
    arguments: Record<string, unknown>;
    task_id?: string | null;
    grant?: string | null;
    llm_creds?: Record<string, unknown> | null;
    composition?: Record<string, unknown> | null;
    consumer_config?: Record<string, unknown> | null;
    consumer_secrets?: Record<string, string> | null;
    cp_jwt?: string | null;
    cp_url?: string | null;
    auth?: Record<string, unknown> | null;
    emit?: (event: Record<string, unknown>) => void | Promise<void>;
    context?: RunContext;
    cancelled?: boolean;
};
export type WorkerResponse = {
    result: unknown;
    events?: Record<string, unknown>[];
    artifacts?: Record<string, unknown>[];
};
export type Handler = (request: WorkerRequest) => WorkerResponse | Promise<WorkerResponse>;
export type ContextHandler = (context: RunContext, input: Record<string, unknown>) => unknown | Promise<unknown>;
export type AgentEvent = {
    kind: string;
    payload?: Record<string, unknown>;
};
export type ArtifactRef = {
    name?: string;
    path?: string;
    uri?: string;
    mime_type?: string;
    bytes?: number;
    content_type?: string;
    metadata?: Record<string, unknown>;
};
export type ArtifactData = string | Uint8Array | Buffer;
export type LLMCreds = Record<string, unknown>;
export type WorkspaceMode = "read_only" | "read_write_overlay" | "read_write_direct";
export type WorkspaceGrantPayload = {
    grant_id?: string;
    issuer?: string;
    audience?: string;
    bucket?: string;
    mode?: WorkspaceMode;
    allow_patterns?: string[];
    deny_patterns?: string[];
    outputs_prefix?: string | null;
    write_prefixes?: string[];
    expires_at?: number;
};
export type WorkspaceFileInfo = {
    path: string;
    size_bytes?: number;
    file_type?: string;
};
export type ExecResult = {
    stdout: string;
    stderr: string;
    exit_code: number;
    truncated?: boolean;
    files?: Record<string, unknown>[];
};
export type SandboxSpec = {
    name: string;
    image?: string;
    memory_mib?: number;
    cpus?: number;
    workspace?: string | null;
    secrets?: string[];
    egress?: string[];
    labels?: Record<string, string>;
};
export declare class WorkspaceDenied extends Error {
    constructor(message: string);
}
export declare class SandboxUnavailable extends Error {
    constructor(message?: string);
}
export declare class SandboxRuntimeError extends Error {
    readonly statusCode?: number;
    readonly responseBody?: string;
    constructor(message: string, options?: {
        statusCode?: number;
        responseBody?: string;
    });
}
export declare class HttpSandboxHandle {
    readonly baseUrl: string;
    readonly name: string;
    readonly timeoutSeconds: number;
    readonly authToken?: string;
    readonly grantToken?: string;
    constructor(options: {
        baseUrl: string;
        name: string;
        timeoutSeconds?: number;
        authToken?: string | null;
        grantToken?: string | null;
    });
    exec(cmd: string, args?: string[], options?: {
        timeout?: number;
    }): Promise<ExecResult>;
    shell(script: string, options?: {
        timeout?: number;
    }): Promise<ExecResult>;
    stop(): Promise<void>;
    kill(): Promise<void>;
    logs(_options?: {
        tail?: number;
    }): Promise<string>;
    private postExec;
}
export declare class HttpSandboxClient {
    readonly baseUrl: string;
    readonly defaultWorkspace?: string;
    readonly timeoutSeconds: number;
    readonly authToken?: string;
    readonly grantToken?: string;
    constructor(baseUrl: string, options?: {
        defaultWorkspace?: string | null;
        timeoutSeconds?: number;
        authToken?: string | null;
        grantToken?: string | null;
    });
    create(spec: SandboxSpec): Promise<HttpSandboxHandle>;
    get(name: string): Promise<HttpSandboxHandle>;
    list(): Promise<string[]>;
    remove(name: string): Promise<void>;
    runPython(code: string, options?: Record<string, unknown>): Promise<ExecResult>;
    run_python(code: string, options?: Record<string, unknown>): Promise<ExecResult>;
    runShell(script: string, options?: Record<string, unknown>): Promise<ExecResult>;
    run_shell(script: string, options?: Record<string, unknown>): Promise<ExecResult>;
    private runOneShot;
}
export declare class WorkspaceClient {
    readonly grantToken: string;
    readonly grant: WorkspaceGrantPayload | null;
    private readonly baseUrl;
    constructor(options: {
        cpUrl: string;
        grantToken: string;
        grant?: WorkspaceGrantPayload | null;
    });
    get outputsPrefix(): string | null;
    exists(path: string): Promise<boolean>;
    readBytes(path: string): Promise<Uint8Array>;
    readText(path: string): Promise<string>;
    writeBytes(path: string, content: Uint8Array | Buffer, contentType?: string): Promise<void>;
    writeText(path: string, content: string, contentType?: string): Promise<void>;
    delete(path: string): Promise<void>;
    list(): Promise<WorkspaceFileInfo[]>;
    private headers;
    private url;
}
export declare class MissingScopes extends Error {
    missing: string[];
    constructor(missing: string[]);
}
export declare class RunContext {
    readonly request: WorkerRequest;
    readonly agent: string;
    readonly skill: string;
    readonly handler: string;
    readonly arguments: Record<string, unknown>;
    readonly auth: Record<string, unknown> | null;
    private readonly events;
    private readonly artifacts;
    private workspaceClient?;
    private sandboxClient?;
    constructor(request: WorkerRequest);
    get emittedEvents(): Record<string, unknown>[];
    get emittedArtifacts(): Record<string, unknown>[];
    get taskId(): string;
    get grant(): WorkspaceGrantPayload | null;
    get workspace(): WorkspaceClient;
    get sandbox(): HttpSandboxClient;
    emitEvent(event: AgentEvent | Record<string, unknown>): Promise<void>;
    emitProgress(message: string, payload?: Record<string, unknown>): Promise<void>;
    emitTextDelta(text: string): Promise<void>;
    emitError(message: string, options?: {
        code?: string;
    }): Promise<void>;
    emitArtifact(ref: ArtifactRef): Promise<void>;
    writeArtifact(name: string, data: ArtifactData, contentType?: string, metadata?: Record<string, unknown>): Promise<ArtifactRef>;
    secret(name: string): string;
    consumerConfig<T = unknown>(name: string, defaultValue?: T): T;
    consumerSecret(name: string): string;
    llm(): LLMCreds;
    cpJwt(): string | null;
    cpUrl(): string | null;
    requireScopes(required: string[]): void;
    checkCancelled(): Promise<void>;
    finalizeResponse(response: WorkerResponse): WorkerResponse;
    private artifactPath;
}
export declare function publicAuth(): AgentDslAuth;
export declare function skill(declaration: SkillDeclaration): SkillDeclaration;
export declare function compileAgent(agentClass: AgentClass, options?: {
    language?: AgentDslLanguage;
    entrypoint?: AgentDslEntrypoint;
    metadata?: Record<string, unknown>;
}): AgentDsl;
export declare function writeAgentDsl(agentClass: AgentClass, path?: string, options?: Parameters<typeof compileAgent>[1]): Promise<AgentDsl>;
export declare function serveWorker(agentClass: AgentClass, handlers: Record<string, Handler>, options?: {
    port?: number;
    host?: string;
}): Server;
export declare function serveAgent(agentClass: AgentClass, options?: {
    port?: number;
    host?: string;
}): Server;
//# sourceMappingURL=index.d.ts.map