import type { Template as ProtoTemplate, TemplateBuild as ProtoTemplateBuild } from "./internal/proto/tenki/sandbox/v1/template_pb.js";
import { TemplateBuildState as ProtoTemplateBuildState, TemplateDefinitionMode as ProtoTemplateDefinitionMode, TemplateVisibility as ProtoTemplateVisibility } from "./internal/proto/tenki/sandbox/v1/template_pb.js";
import type { RegistryImage } from "./registry.js";
import { TemplateSpec } from "./template-spec.js";
import type { SandboxWarning } from "./warning.js";
export type TemplateBuildState = "UNSPECIFIED" | "PENDING" | "BUILDING" | "READY" | "FAILED";
export interface TemplateResources {
    cpuCores: number;
    memoryMb: number;
    diskSizeGb: number;
}
/** Private registry image produced by a successful template build. */
export interface TemplateImage extends RegistryImage {
    /** Untagged ref tracking the latest eligible successful build. */
    ref: string;
    /** Immutable SHA-256 image manifest digest. */
    digest: string;
    /** Immutable digest-addressed ref, e.g. "acme/node-api@sha256:...". */
    digestRef: string;
}
/** Accepted by create({ image }); a TemplateImage satisfies it. */
export interface TemplateImageRef {
    ref?: string;
    digestRef?: string;
}
export interface TemplateBuild {
    id: string;
    templateId: string;
    state: TemplateBuildState;
    version: number;
    error: string;
    buildLogTail: string;
    buildLogTruncated: boolean;
    buildLogArtifactId: string;
    startedAt: Date;
    completedAt: Date;
    snapshotId: string;
    sessionId: string;
    /** Frozen typed spec this build executes; immutable once submitted. */
    spec?: TemplateSpec;
    /** Server-computed hash of the normalized spec. */
    specHash: string;
    /** Present once the build succeeds. */
    image?: TemplateImage;
    imageDigest: string;
    imageDigestRef: string;
    events: TemplateBuildEvent[];
    provenance?: TemplateBuildProvenance;
    failure?: TemplateBuildFailure;
    /** Warnings returned by the buildTemplate call that started this build. */
    warnings?: SandboxWarning[];
}
export interface TemplateBuildStepReference {
    index: number;
    kind: string;
    name?: string;
    label: string;
}
interface TemplateBuildEventBase {
    timestamp: Date;
    phase: string;
    step?: TemplateBuildStepReference;
}
export interface TemplateBuildLogEvent extends TemplateBuildEventBase {
    type: "log";
    stream: "stdout" | "stderr" | "system";
    data: string;
}
export interface TemplateBuildProgressEvent extends TemplateBuildEventBase {
    type: "progress";
    state: "unspecified" | "started" | "completed" | "failed";
    message?: string;
}
export type TemplateBuildEvent = TemplateBuildLogEvent | TemplateBuildProgressEvent;
export interface TemplateBuildWaitOptions {
    signal?: AbortSignal;
    onEvent?: (event: TemplateBuildEvent) => void | Promise<void>;
}
export interface TemplateBuildOptions extends TemplateBuildWaitOptions {
    /** Request-scoped environment overrides frozen into this build. */
    buildEnv?: Record<string, string>;
    /** Ephemeral environment variables available only during this build. */
    buildSecrets?: Record<string, string>;
    publishRawImage?: boolean;
    waitForCompletion?: boolean;
}
export interface TemplateBuildProvenance {
    requestedGitRef?: string;
    resolvedGitCommitSha?: string;
    buildSecretKeys?: string[];
}
export interface TemplateBuildFailure {
    code: string;
    message: string;
    step?: TemplateBuildStepReference;
}
export type TemplateVisibility = "UNSPECIFIED" | "PRIVATE" | "PUBLIC";
export type TemplateDefinitionMode = "UNSPECIFIED" | "LEGACY" | "TYPED";
export interface Template {
    id: string;
    workspaceId: string;
    ownerType: string;
    ownerId: string;
    name: string;
    baseImageId: string;
    setupScript: string;
    startCmd: string;
    envVars: Record<string, string>;
    tags: string[];
    resources?: TemplateResources;
    /** Typed v1 recipe when the template is spec-backed. */
    spec?: TemplateSpec;
    /** Server-computed hash of the normalized spec. */
    specHash: string;
    latestBuild?: TemplateBuild;
    visibility: TemplateVisibility;
    definitionMode: TemplateDefinitionMode;
    parentWorkspaceId: string;
    createdAt: Date;
    updatedAt: Date;
    /** Warnings returned by the createTemplate or updateTemplate call that produced this value. */
    warnings?: SandboxWarning[];
}
export declare function templateBuildStateFromProto(state: ProtoTemplateBuildState): TemplateBuildState;
export declare function templateBuildFromProto(proto: ProtoTemplateBuild | undefined): TemplateBuild | undefined;
export declare function templateVisibilityFromProto(state: ProtoTemplateVisibility): TemplateVisibility;
export declare function templateDefinitionModeFromProto(state: ProtoTemplateDefinitionMode): TemplateDefinitionMode;
export declare function templateFromProto(proto: ProtoTemplate): Template;
export {};
