import { PermissionProfileFile } from '@granular-software/policy-engine';

/**
 * @module @granular-software/sdk/types
 * Type definitions for the Granular SDK
 */

/**
 * Configuration for the Granular client
 */
type AccessTokenProvider = () => Promise<string | null | undefined> | string | null | undefined;
type EndpointMode = "auto" | "local" | "production";
interface GranularOptions {
    /** Your Granular API key (for service/CLI auth; use with GRANULAR_API_KEY) */
    apiKey?: string;
    /** Application/session JWT (for user-context auth; use from simulator or getAccessToken) */
    token?: string;
    /** Optional provider used to refresh JWT before WebSocket (re)connect attempts */
    tokenProvider?: AccessTokenProvider;
    /** Optional API URL (for on-prem or testing) */
    apiUrl?: string;
    /** Optional live effect-host WebSocket/base URL override (for local/on-prem routing) */
    effectHostUrl?: string;
    /** Optional endpoint mode when apiUrl is not explicitly provided */
    endpointMode?: EndpointMode;
    /** Optional WebSocket constructor (for Node.js environments) */
    WebSocketCtor?: any;
    /**
     * Optional callback invoked when a connected WebSocket closes unexpectedly.
     * Useful for forwarding close diagnostics to monitoring (e.g., Sentry).
     */
    onUnexpectedClose?: (info: WSDisconnectInfo) => void;
    /**
     * Optional callback invoked when automatic reconnect fails.
     * Useful to capture auth or gateway rejection causes.
     */
    onReconnectError?: (info: WSReconnectErrorInfo) => void;
}
/** Resolved auth credential: either apiKey or token must be provided */
type GranularAuth = string;
/**
 * A user/subject object returned from recordUser()
 */
interface User {
    /** Internal Granular user identifier */
    granularId: string;
    /** External user identifier from your app */
    userId: string;
    /** @deprecated Use `granularId` instead */
    subjectId: string;
    /** @deprecated Use `userId` instead */
    identityId: string;
    /** User's display name */
    name?: string;
    /** User's email */
    email?: string;
    /** Permission profile IDs to be assigned when connecting */
    permissions: string[];
}
/**
 * Options for recording a user
 */
interface RecordUserOptions {
    /** External user/identity ID (e.g. your Auth0 or database user ID) */
    userId: string;
    /** User's display name */
    name?: string;
    /** User's email */
    email?: string;
    /** Permission profile IDs to assign when connecting to sandboxes */
    permissions?: string[];
}
/**
 * Subject as returned from the API
 */
interface Subject {
    /** Internal Granular user identifier */
    granularId: string;
    /** External user identifier from your app */
    userId: string;
    subjectId: string;
    tenantId: string;
    identityId: string;
    email?: string | null;
    name?: string | null;
    metadata?: Record<string, unknown>;
    createdAt: number;
    updatedAt: number;
}
/**
 * Options for opening an ontology environment for one delegated subject.
 *
 * This does not open a live runtime session. Use
 * `environment.sessions.create()` or `granular.createSession({ environmentId })`
 * when you need a conversation/session with jobs, prompts, heap, and effects.
 */
interface OpenEnvironmentOptions {
    /** The ontology name or ID to open. */
    ontology: string;
    /** Version channel to follow, typically `dev` or `prod`. */
    tag?: string;
    /**
     * External user identifier from your app.
     *
     * Exactly one of `userId`, `granularId`, or `user` should be provided.
     */
    userId?: string;
    /**
     * Internal Granular user identifier.
     *
     * Exactly one of `userId`, `granularId`, or `user` should be provided.
     */
    granularId?: string;
    /** Optional display name used when upserting the user. */
    name?: string;
    /** Optional email used when upserting the user. */
    email?: string;
    /**
     * Permission profile names or IDs to ensure before opening the environment.
     * This should be provided even for existing users so the SDK can guarantee
     * assignments for first-time environment creation.
     */
    permissions: string[];
    /**
     * When true, if the latest environment for this ontology/user/tag is marked
     * outdated relative to the current tag target, create a fresh environment on
     * the newest tag target instead of reusing the outdated one.
     */
    createFreshIfOutdated?: boolean;
    /** Backwards-compatible user object returned from `recordUser()`. */
    user?: User;
}
/**
 * Deprecated compatibility alias for the legacy `connect()` entry point.
 *
 * `connect()` now resolves an environment handle and no longer opens a runtime
 * session automatically. Prefer `openEnvironment()` for new code.
 */
interface ConnectOptions extends OpenEnvironmentOptions {
    /** @deprecated Legacy explicit environment slot name. Prefer `tag`. */
    environment?: string;
    /** @deprecated Legacy tag field. Prefer `tag`. */
    tagName?: string;
    /** @deprecated Ignored by `connect()` now that it no longer opens sessions. */
    clientId?: string;
    /**
     * @deprecated Ignored by `connect()` now that it no longer opens sessions.
     * Uses application record identity: class name plus the record id from the
     * customer's own system. Granular resolves the internal graph path.
     */
    initialHeap?: Array<{
        className: string;
        id: string;
    }>;
}
/**
 * Options for creating a live runtime session from an opened environment.
 */
interface CreateSessionOptions {
    /** Optional stable client ID. Defaults to `client_${Date.now()}`. */
    clientId?: string;
    /**
     * Optional session heap seed. Each item uses application record identity:
     * class name plus the record id from the customer's own system. Granular
     * resolves and hydrates the corresponding internal graph record on connect.
     */
    initialHeap?: Array<{
        className: string;
        id: string;
    }>;
}
/**
 * Control-plane session row: one real-time conversation thread with the agent for an environment.
 */
interface ConversationSessionInfo {
    sessionId: string;
    tenantId?: string;
    environmentId: string;
    versionId?: string | null;
    docId: string;
    status: "active" | "closed" | "expired";
    createdAt: string;
    lastSeenAt: string;
    summary?: string | null;
    summaryUpdatedAt?: string | null;
    subjectId?: string | null;
    jobCount?: number;
    toolCallCount?: number;
}
type SpendLineItemType = "llm_tokens" | "granular_session_time" | string;
type QuotaScopeType = "tenant" | "sandbox" | "permission_profile" | "subject";
type QuotaPeriod = "hour" | "day" | "week" | "month";
type QuotaStatus = "active" | "paused" | "archived";
interface SpendSummary {
    amountMicros: number;
    inputTokens: number;
    outputTokens: number;
    cachedInputTokens: number;
    reasoningTokens: number;
    quantity: number;
    eventCount: number;
}
interface QuotaLineItemFilter {
    lineItemTypes?: string[];
    sources?: string[];
    providers?: string[];
    models?: string[];
}
interface GranularQuotaPolicy {
    quotaId: string;
    tenantId: string;
    scopeType: QuotaScopeType;
    sandboxId: string | null;
    permissionProfileId: string | null;
    subjectId: string | null;
    period: QuotaPeriod;
    limitAmountMicros: number;
    currency: string;
    lineItemFilter: QuotaLineItemFilter | null;
    status: QuotaStatus;
    description: string | null;
    createdBy: string | null;
    startsAt: number | null;
    endsAt: number | null;
    createdAt: number;
    updatedAt: number;
}
interface GranularQuotaProgress {
    unlimited: boolean;
    allowed: boolean;
    blocked: boolean;
    policy: GranularQuotaPolicy | null;
    period: QuotaPeriod | null;
    periodStart: number | null;
    periodEnd: number | null;
    usedAmountMicros: number;
    limitAmountMicros: number | null;
    remainingAmountMicros: number | null;
    percentUsed: number | null;
    currency: string;
    summary: SpendSummary;
}
/**
 * A sandbox container
 */
interface Sandbox {
    sandboxId: string;
    tenantId: string;
    name: string;
    description?: string | null;
    createdAt: number;
    updatedAt: number;
}
/**
 * Data for creating a new sandbox
 */
interface CreateSandboxData {
    name: string;
    description?: string;
}
/**
 * List response for sandboxes
 */
interface SandboxListResponse {
    items: Sandbox[];
}
/**
 * Rules defining what effects and resources are allowed or denied.
 */
interface PermissionRules {
    /** Effect access rules */
    effects?: {
        /** Patterns for allowed effects (e.g. ["*"] for all, ["read_*"] for prefix match) */
        allow?: string[];
        /** Patterns for denied effects */
        deny?: string[];
    };
    /** Legacy alias accepted by the backend while migrating to `effects`. */
    tools?: {
        /** Patterns for allowed effects (e.g. ["*"] for all, ["read_*"] for prefix match) */
        allow?: string[];
        /** Patterns for denied effects */
        deny?: string[];
    };
    /** Resource access rules */
    resources?: {
        /** Patterns for allowed resources */
        allow?: string[];
        /** Patterns for denied resources */
        deny?: string[];
    };
}
/**
 * A permission profile defines access controls for an environment
 */
interface PermissionProfile {
    permissionProfileId: string;
    sandboxId: string;
    name: string;
    description?: string;
    rules?: PermissionProfileFile;
    profile?: PermissionProfileFile;
    createdAt: number;
    updatedAt: number;
}
/**
 * Data for creating a new permission profile
 */
interface CreatePermissionProfileData {
    name: string;
    rules: PermissionProfileFile;
}
/**
 * List response for permission profiles
 */
interface PermissionProfileListResponse {
    items: PermissionProfile[];
}
/**
 * An assignment links a subject to a sandbox with a permission profile
 */
interface Assignment {
    assignmentId: string;
    tenantId: string;
    subjectId: string;
    sandboxId: string;
    permissionProfileId: string;
    createdAt: number;
    createdBy?: string | null;
}
/**
 * List response for assignments
 */
interface AssignmentListResponse {
    items: Assignment[];
}
/**
 * Version tracking policy for environments.
 *
 * Environments either follow a version tag such as `dev` or `prod`, or they
 * pin themselves to one immutable ontology version.
 */
interface BuildPolicy {
    mode: "tag" | "current" | "pinned";
    buildId?: string;
    versionId?: string;
    tagId?: string;
    tagName?: string;
}
type VersionTracking = BuildPolicy;
interface VersionTag {
    tagId: string;
    sandboxId: string;
    name: string;
    kind: "channel" | "release" | "system";
    targetBuildId?: string | null;
    targetVersionId?: string | null;
    description?: string | null;
    protected?: boolean;
    createdAt: number;
    updatedAt: number;
}
/**
 * An environment links a user (subject) to a sandbox with specific permissions
 */
interface EnvironmentData {
    environmentId: string;
    sandboxId: string;
    ontologyId?: string;
    buildId: string;
    versionNumber?: number | null;
    versionId: string;
    subjectId: string;
    envName: string;
    environment?: string;
    permissionProfileId: string;
    tagId?: string | null;
    tag?: VersionTag | null;
    tracking?: BuildPolicy;
    buildPolicy: BuildPolicy;
    setup?: EnvironmentSetupSummary | null;
    updateState?: "up_to_date" | "update_available" | "upgrading" | "failed";
    createdAt: number;
    updatedAt: number;
}
/**
 * Data for creating a new environment
 */
interface CreateEnvironmentData {
    /** The user/subject ID to create the environment for */
    subjectId: string;
    /** Named environment slot such as dev or prod */
    environment?: string;
    /** @deprecated Use `environment` instead. */
    envName?: string;
    /** The permission profile to apply (optional - uses assignment if not specified) */
    permissionProfileId?: string | null;
    /** Follow a tag directly */
    tagId?: string;
    /** Follow a tag by name, typically dev or prod */
    tagName?: string;
    /** Pin the environment to a specific version */
    versionId?: string;
    /** Legacy/compat environment tracking input */
    buildPolicy?: BuildPolicy;
}
/**
 * List response for environments
 */
interface EnvironmentListResponse {
    items: EnvironmentData[];
}
/**
 * A manifest describes the structure and behavior of a sandbox
 */
interface Manifest {
    manifestId: string;
    sandboxId: string;
    version: string;
    digest: string;
    content?: Record<string, unknown>;
    createdAt: number;
    locked?: boolean;
}
/**
 * List response for manifests
 */
interface ManifestListResponse {
    items: Manifest[];
}
type BuildStatus = "queued" | "building" | "completed" | "failed" | "canceled";
/**
 * An immutable ontology version derived from a specific manifest revision.
 *
 * The same version may have multiple build runs over time when the manifest
 * content is unchanged but the compilation process is re-executed.
 */
interface Build {
    buildId: string;
    sandboxId: string;
    manifestId: string;
    manifestDigest?: string;
    versionNumber?: number;
    status: BuildStatus;
    graphBinaryId?: string | null;
    logsUri?: string | null;
    latestBuildRunId?: string | null;
    buildRunId?: string;
    createdNewVersion?: boolean;
    environmentCount?: number;
    laggingEnvironmentCount?: number;
    sessionCount?: number;
    createdAt: number;
    updatedAt: number;
    isCurrent?: boolean;
}
type Version = Build;
/**
 * List response for versions
 */
interface BuildListResponse {
    items: Build[];
}
interface SemanticVersionDiffEntry {
    operationId: string;
    kind: "create" | "update" | "relationship" | "effect" | "eventStream" | "unknown";
    changeType: "added" | "removed" | "changed";
    label: string;
    additive: boolean;
    breaking: boolean;
    before?: Record<string, unknown>;
    after?: Record<string, unknown>;
}
interface SemanticVersionDiff {
    summary: {
        added: number;
        removed: number;
        changed: number;
        additive: number;
        breaking: number;
        onlyAdditiveChanges: boolean;
    };
    entries: SemanticVersionDiffEntry[];
}
/**
 * Effect handler for static/global effects: receives (input, context)
 */
interface EffectHandlerContext {
    effectClientId: string;
    sandboxId: string;
    environmentId: string;
    buildId?: string;
    buildVersionNumber?: number;
    sessionId: string;
    tenantId?: string;
    principalId?: string;
    permissionProfileId?: string;
    user: {
        granularId?: string;
        userId?: string;
        subjectId: string;
        identityId?: string;
        principalId?: string;
    };
    behaviors?: ResolvedEffectBehaviors;
    invocation?: EffectInvocationMetadata;
}
interface ResolvedEffectPostCondition {
    condition: string;
    description?: string;
}
interface ResolvedEffectDryRun {
    enabled: boolean;
    description?: string;
}
interface ResolvedEffectReverse {
    handler?: string;
    description?: string;
}
interface ResolvedEffectApprovalRequired {
    required: boolean;
    reason?: string;
    mode?: string;
}
interface ResolvedEffectBehaviors {
    postCondition?: ResolvedEffectPostCondition;
    dryRun?: ResolvedEffectDryRun;
    reverse?: ResolvedEffectReverse;
    approvalRequired?: ResolvedEffectApprovalRequired;
}
type EffectInvocationMode = "execute" | "dryRun" | "reverse";
interface EffectInvocationMetadata {
    mode?: EffectInvocationMode;
    reverseHandler?: string;
    sourceEffectKey?: string;
    sourceEffectName?: string;
}
type ToolHandler = (input: any, context: EffectHandlerContext) => Promise<unknown>;
/**
 * Effect handler for instance methods: receives (objectId, input, context)
 */
type InstanceToolHandler = (id: string, input: any, context: EffectHandlerContext) => Promise<unknown>;
/**
 * Effect schema for declaring or registering an effect.
 *
 * Effects come in three flavours:
 *
 * 1. **Instance methods** — set `className`, omit `static`.
 *    In the sandbox: `tolkien.get_bio({ detailed: true })`
 *    Handler signature: `(objectId: string, params: any) => any`
 *
 * 2. **Static methods** — set `className` + `static: true`.
 *    In the sandbox: `Author.search({ query: 'tolkien' })`
 *    Handler signature: `(params: any) => any`
 *
 * 3. **Global effects** — omit `className`.
 *    In the sandbox: `global_search({ query: 'rings' })`
 *    Handler signature: `(params: any) => any`
 *
 * Both `inputSchema` and `outputSchema` accept JSON Schema objects.
 * The `outputSchema` drives the return type in the auto-generated
 * TypeScript declarations that sandbox code imports from `./sandbox-tools`.
 */
interface ToolSchema {
    effectKey?: string;
    name: string;
    description: string;
    /** JSON Schema for the effect input parameters */
    inputSchema: Record<string, unknown>;
    /**
     * JSON Schema for the tool's return value.
     * Used to generate typed return types in the sandbox TypeScript declarations.
     *
     * @example
     * ```typescript
     * outputSchema: {
     *   type: 'object',
     *   properties: {
     *     bio: { type: 'string', description: 'The biography text' },
     *     source: { type: 'string', description: 'Source of the bio' },
     *   },
     *   required: ['bio'],
     * }
     * // Generates: Promise<{ bio: string; source?: string }>
     * ```
     */
    outputSchema?: Record<string, unknown>;
    stability?: "stable" | "experimental" | "deprecated";
    provenance?: {
        source: "mcp" | "custom";
    };
    tags?: string[];
    /**
     * The class this effect belongs to (e.g., `'author'`, `'book'`).
     * When set, the effect becomes a method on the auto-generated class.
     * Omit for global effects (standalone exported functions).
     */
    className?: string;
    /**
     * If `true`, this is a static/class-level method (no object ID required).
     * If `false` or omitted and `className` is set, this is an instance method
     * that operates on a specific object (the object's real-world ID is
     * passed as the first argument to the handler).
     */
    static?: boolean;
    /**
     * Optional build-version selector for this live effect binding.
     *
     * When omitted, the binding applies to all build versions for the sandbox.
     */
    versionSelector?: EffectVersionSelector;
    /** Declarative runtime behaviors attached to the effect. */
    metamodels?: ManifestEffectMetamodelSpec;
}
type EffectSchema = ToolSchema;
/**
 * Effect with handler — what users provide to `registerEffect()`.
 *
 * - **Instance methods** (`className` set, `static` omitted):
 *   handler receives `(objectId: string, params: any)`
 * - **Static methods** (`className` set, `static: true`):
 *   handler receives `(params: any)`
 * - **Global tools** (no `className`):
 *   handler receives `(params: any)`
 */
interface ToolWithHandler extends ToolSchema {
    handler: ToolHandler | InstanceToolHandler;
    dryRunHandler?: ToolHandler | InstanceToolHandler;
    reverseHandler?: ToolHandler | InstanceToolHandler;
}
type EffectWithHandler = ToolWithHandler;
/**
 * Result from publishing or synchronizing effects
 */
interface PublishToolsResult {
    accepted: boolean;
    domainRevision: string;
    rejected?: Array<{
        name: string;
        reason: string;
    }>;
}
type PublishEffectsResult = PublishToolsResult;
type EffectVersionSelector = {
    mode: "all";
} | {
    mode: "exact";
    versionNumber: number;
} | {
    mode: "before";
    versionNumber: number;
} | {
    mode: "after";
    versionNumber: number;
};
/**
 * Domain state response
 */
interface DomainState {
    activeDomainRevision?: string;
    tools?: Array<{
        name: string;
        description?: string;
        inputSchema?: Record<string, unknown>;
        outputSchema?: Record<string, unknown>;
        metamodels?: ManifestEffectMetamodelSpec;
    }>;
    [key: string]: unknown;
}
/**
 * Information about a live or declared effect
 */
interface ToolInfo {
    effectKey?: string;
    /** Unique name of the effect */
    name: string;
    /** Description of what the effect does */
    description?: string;
    /** JSON Schema for effect input */
    inputSchema?: Record<string, unknown>;
    /** JSON Schema for effect output */
    outputSchema?: Record<string, unknown>;
    /** Client ID that published this effect (absent for domain-only entries) */
    clientId?: string;
    /** Whether the effect is ready for use (has a registered handler) */
    ready: boolean;
    /** Timestamp when the effect was published */
    publishedAt?: number;
    /** Class this effect belongs to (instance/static method) */
    className?: string;
    /** Whether this is a static method */
    static?: boolean;
    /** Optional build-version selector associated with the live binding. */
    versionSelector?: EffectVersionSelector;
    /** Declarative runtime behaviors attached to the effect. */
    metamodels?: ManifestEffectMetamodelSpec;
}
interface EffectInfo extends ToolInfo {
}
/**
 * Event data when the list of available effects changes
 */
interface ToolsChangedEvent {
    /** The current list of all available effects */
    tools: ToolInfo[];
    /** Names of effects that were added or updated */
    added: string[];
    /** Names of effects that were removed */
    removed: string[];
}
interface EffectsChangedEvent extends ToolsChangedEvent {
    /** The current list of all available effects */
    effects: EffectInfo[];
}
type EffectHandler = ToolHandler;
type InstanceEffectHandler = InstanceToolHandler;
type JobStatus = "queued" | "running" | "awaitingTool" | "awaitingHuman" | "succeeded" | "failed" | "timeout" | "canceled";
type JobFeedbackSentiment = "good" | "bad";
interface JobFeedbackToolCall {
    callId?: string;
    toolName?: string;
    input?: unknown;
    output?: unknown;
    error?: string;
    startedAt?: number;
    completedAt?: number;
    durationMs?: number | null;
}
interface JobFeedbackMetadata {
    source: "sdk";
    status: JobStatus;
    code: string;
    domainRevision?: string;
    createdAt: number;
    startedAt?: number;
    completedAt?: number;
    durationMs?: number | null;
    result?: unknown;
    error?: string;
    stdout: string[];
    stderr: string[];
    toolCalls: JobFeedbackToolCall[];
}
interface JobFeedbackInput {
    sentiment: JobFeedbackSentiment;
    comment?: string | null;
}
interface JobFeedbackRecord {
    feedbackId: string;
    tenantId?: string;
    sessionId: string;
    environmentId: string;
    sandboxId?: string;
    buildId?: string;
    subjectId?: string;
    jobId: string;
    sentiment: JobFeedbackSentiment;
    comment?: string | null;
    metadata: JobFeedbackMetadata & Record<string, unknown>;
    createdAt: number;
    updatedAt: number;
}
/**
 * Persisted feedback row listed at the environment level.
 */
interface EnvironmentFeedbackRecord {
    feedbackId: string;
    sessionId: string;
    jobId: string;
    sentiment: JobFeedbackSentiment;
    comment?: string | null;
    metadata?: Record<string, unknown> | null;
    createdAt: string | null;
}
/**
 * Result from submitting a job
 */
interface JobSubmitResult {
    jobId: string;
}
/**
 * Represents a job executed in the sandbox
 */
interface Job {
    /** Unique Job ID */
    id: string;
    /** Current status of the job */
    status: JobStatus;
    /** Promise that resolves with the job result */
    result: Promise<unknown>;
    /** Attach user feedback to this job and persist it with job/session metadata */
    leaveFeedback(input: JobFeedbackInput): Promise<JobFeedbackRecord>;
    /** Subscribe to job events */
    on(event: string, handler: (data: unknown) => void): () => void;
}
interface Prompt {
    id: string;
    type: "confirm" | "choice" | "input";
    title: string;
    message: string;
    options?: Array<string | {
        value: string;
        label: string;
        description?: string;
    }>;
    defaultValue?: unknown;
    placeholder?: string;
    allowEmpty?: boolean;
    metadata?: Record<string, unknown>;
}
interface ConversationMessageShowRefs {
    entryPaths?: string[];
    listNames?: string[];
    variableNames?: string[];
    fileIds?: string[];
}
interface ConversationMessageInput {
    role: "user" | "assistant";
    content?: string;
    show?: ConversationMessageShowRefs;
    jobId?: string;
    promptId?: string;
    timestamp?: number;
}
interface ConversationAppendResult {
    ok: boolean;
    messageId: string;
    timestamp: number;
    jobId?: string;
    promptId?: string;
}
interface SessionConversationMessage {
    id: string;
    role: "user" | "assistant";
    content?: string;
    show?: ConversationMessageShowRefs;
    jobId?: string;
    promptId?: string;
    ts: number;
    [key: string]: unknown;
}
interface SessionTimelineEvent {
    id?: string;
    eventId?: string;
    kind?: string;
    type?: string;
    status?: string | null;
    message?: string;
    summary?: string;
    title?: string;
    ts?: number;
    timestamp?: number;
    at?: number;
    createdAt?: number;
    [key: string]: unknown;
}
type SessionFileSource = "dock" | "sdk" | "agent" | "runtime" | "processor" | "library" | "imported";
type SessionFileKind = "csv" | "spreadsheet" | "pdf" | "image" | "text" | "document" | "binary";
type SessionFileStatus = "queued" | "ready" | "processing" | "processed" | "failed" | "deleted";
interface SessionFileRecord {
    fileId: string;
    sessionId: string;
    tenantId: string | null;
    subjectId: string | null;
    sandboxId: string | null;
    environmentId: string | null;
    filename: string;
    safeFilename: string;
    contentType: string;
    byteLength: number;
    sha256: string;
    r2Key: string;
    kind: SessionFileKind;
    source: SessionFileSource;
    status: SessionFileStatus;
    createdAt: number;
    updatedAt: number;
    jobId?: string;
    parentFileIds?: string[];
    outputPath?: string;
    metadata?: Record<string, unknown>;
}
interface SessionFileUploadOptions {
    filename?: string;
    contentType?: string;
    source?: "dock" | "sdk" | "imported";
    parentFileIds?: string[];
    metadata?: Record<string, unknown>;
}
interface SessionJobRecord {
    jobId: string;
    status: string;
    code?: string;
    createdAt?: number;
    startedAt?: number;
    completedAt?: number;
    durationMs?: number | null;
    progressPercent?: number | null;
    progressMessage?: string | null;
    stdout?: string[];
    stderr?: string[];
    result?: unknown;
    error?: string | null;
    toolCalls?: JobFeedbackToolCall[];
    prompts?: Record<string, unknown>;
    actionSummary?: string[];
    actionTrace?: Array<Record<string, unknown>>;
    agentMessages?: Array<Record<string, unknown>>;
    [key: string]: unknown;
}
interface SessionTranscriptEntry {
    id: string;
    role: "user" | "assistant";
    content: string;
    timestamp: number;
    jobId?: string;
    promptId?: string;
    code?: string;
    jobStatus?: string;
    jobResultPreview?: string;
    error?: string;
    show?: ConversationMessageShowRefs;
    historyContent?: string;
    source: "conversation" | "job_code" | "job_result" | "job_prompt" | "job_agent_message";
}
type SessionHeapFieldType = "string" | "number" | "boolean" | "null" | "unknown";
interface SessionHeapFieldValue {
    name: string;
    type: SessionHeapFieldType;
    value: string | number | boolean | null;
}
interface SessionHeapEntry {
    path: string;
    className: string;
    id: string;
    label?: string | null;
    description?: string | null;
    prototypes: string[];
    fields: SessionHeapFieldValue[];
    relatedJobIds: string[];
    source: string;
    createdAt: number;
    updatedAt: number;
}
interface SessionHeapList {
    name: string;
    className: string;
    paths: string[];
    relatedJobIds: string[];
    updatedAt: number;
}
interface SessionHeapVariable {
    name: string;
    kind: "entry" | "list" | "scalar";
    entryPath?: string;
    listName?: string;
    value?: string | number | boolean | null;
    className?: string;
    updatedAt: number;
}
interface SessionHeapSnapshot {
    entriesByPath: Record<string, SessionHeapEntry>;
    listsByName: Record<string, SessionHeapList>;
    variablesByName: Record<string, SessionHeapVariable>;
    updatedAt: number;
}
interface RecordSearchResult {
    path: string;
    className: string;
    id: string;
    label: string;
    description?: string | null;
    fields: SessionHeapFieldValue[];
}
interface RecordSearchOptions {
    limit?: number;
    offset?: number;
    classNames?: string[];
}
interface RecordMentionInput {
    className: string;
    id?: string;
    path?: string;
}
interface SessionDocumentResult {
    sessionState: Record<string, unknown> | null;
    document: Record<string, unknown> | null;
    savedAt: number;
}
interface SessionCollectionListOptions {
    limit?: number;
    cursor?: string | null;
}
interface SessionJobListOptions extends SessionCollectionListOptions {
    status?: string | null;
}
interface SessionCollectionListResult<T = unknown> {
    items: T[];
    nextCursor: string | null;
    totalCount: number;
}
interface WSDisconnectInfo {
    code?: number;
    reason?: string;
    wasClean?: boolean;
    unexpected: boolean;
    timestamp: number;
    reconnectScheduled: boolean;
    reconnectDelayMs?: number;
}
interface WSReconnectErrorInfo {
    sessionId: string;
    error: string;
    timestamp: number;
}
interface WSClientOptions {
    url: string;
    sessionId: string;
    token: string;
    tokenProvider?: AccessTokenProvider;
    WebSocketCtor?: any;
    onUnexpectedClose?: (info: WSDisconnectInfo) => void;
    onReconnectError?: (info: WSReconnectErrorInfo) => void;
}
interface RPCRequest {
    type: "rpc";
    method: string;
    params: unknown;
    id: string;
}
interface RPCResponse {
    type: "rpc_result" | "rpc_error";
    id: string;
    result?: unknown;
    error?: {
        code: number;
        message: string;
        data?: unknown;
    };
}
interface SyncMessage {
    type: "sync";
    message?: string | number[] | Uint8Array;
    data?: number[];
}
interface RPCRequestFromServer {
    type: "rpc";
    method: string;
    params: unknown;
    id: string;
}
interface ToolInvokeParams {
    callId: string;
    toolName: string;
    input: unknown;
}
interface ToolResultParams {
    callId: string;
    result?: unknown;
    error?: string | {
        code: string;
        message: string;
    };
}
/**
 * A model reference as returned from relationship queries
 */
interface ModelRef {
    path: string;
    label?: string;
}
/**
 * Relationship info as returned from the GraphQL API.
 * Represents a typed, bidirectional relationship between two model types,
 * seen from one model's perspective.
 */
interface RelationshipInfo {
    /** Unique name of this relationship definition */
    name: string;
    /** The submodel on this model that holds the relationship */
    local_submodel: ModelRef;
    /** Whether this side is a "many" collection */
    local_is_many: boolean;
    /** The submodel on the foreign model */
    foreign_submodel: ModelRef;
    /** Whether the foreign side is a "many" collection */
    foreign_is_many: boolean;
    /** The foreign model type */
    foreign_model: ModelRef;
    /** Computed relationship kind: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many" */
    relationship_kind: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many";
}
/**
 * Options for defining a relationship between two model types
 */
interface DefineRelationshipOptions {
    /** The model to define the relationship on (the "left" / "local" type) */
    model: string;
    /** The submodel name on the local model (e.g., "books") */
    localSubmodel: string;
    /** Whether the local side is "many" */
    localIsMany: boolean;
    /** The foreign model type (e.g., "book") */
    foreignModel: string;
    /** The submodel name on the foreign model (e.g., "author") */
    foreignSubmodel: string;
    /** Whether the foreign side is "many" */
    foreignIsMany: boolean;
    /** Optional relationship name (auto-generated if omitted) */
    name?: string;
}
/**
 * Options for creating or updating a class instance in the graph.
 *
 * `recordObject` uses the graph's `instantiate` (find-or-create) semantics:
 * if an instance with the given `id` already exists under the class, its
 * fields are updated in place; otherwise a new instance is created.
 */
interface RecordObjectOptions {
    /** The class to instantiate (e.g., "author") */
    className: string;
    /**
     * Real-world object ID. Unique within its class, but two objects of
     * different classes may share the same ID.  Internally the SDK derives
     * a unique graph path as `{className}__{id}`.
     */
    id: string;
    /** Optional display label (defaults to `id`) */
    label?: string;
    /** Scalar field values to set on the instance */
    fields?: Record<string, string | number | boolean | null>;
    /**
     * Relationship attachments.
     * Keys are relationship submodel names.  Values are real-world IDs
     * (not graph paths) — the SDK resolves them using the foreign class
     * derived from the relationship definition.
     * - For a "one" side: pass a single target ID (string)
     * - For a "many" side: pass an array of target IDs
     */
    relationships?: Record<string, string | string[]>;
}
/**
 * Return value from `recordObject()`
 */
interface RecordObjectResult {
    /** The internal graph path (e.g., "author__tolkien") */
    path: string;
    /** The real-world object ID as provided by the caller (e.g., "tolkien") */
    id: string;
    /** Whether the instance was newly created (false = updated) */
    created: boolean;
}
/**
 * Metadata for one completed HTTP chunk in `recordObjects()`.
 * Chunk indices follow input order; when concurrency is greater than 1, completion order may differ.
 */
interface RecordObjectsChunkInfo {
    /** Zero-based chunk index */
    chunkIndex: number;
    totalChunks: number;
    /** Zero-based offset into the original `records` array */
    offset: number;
    /** Number of records in this chunk */
    recordCount: number;
    /** Wall time for this chunk’s POST (including retries) */
    durationMs: number;
    /** Acknowledgements for this chunk, in the same order as the slice sent */
    results: RecordObjectResult[];
}
/**
 * Optional tuning for `recordObjects()` — batching, parallelism, and progress hooks.
 */
interface RecordObjectsOptions {
    /**
     * Max records per HTTP POST to the control-plane batch endpoint. Default 100.
     * Smaller values: more round trips and finer `onChunkComplete` updates.
     * Larger values: fewer requests (watch request size/timeouts).
     */
    batchSize?: number;
    /**
     * How many chunk POSTs may run concurrently. Default 1 (strictly sequential).
     * Values above 1 can reduce wall time when the server can overlap work; capped at 16.
     */
    concurrency?: number;
    /**
     * Called after each chunk succeeds (after retries). Useful for UI progress bars.
     */
    onChunkComplete?: (info: RecordObjectsChunkInfo) => void | Promise<void>;
}
type RecordImportWriteMode = "adaptive" | "batched" | "per_record" | "parallel_5";
interface RecordImportOptions {
    batchSize?: number;
    setupRunId?: string;
    writeMode?: RecordImportWriteMode;
}
type RecordImportStatus = "queued" | "processing" | "completed" | "failed" | "canceled";
type RecordImportItemStatus = "queued" | "processing" | "completed" | "failed" | "canceled";
interface RecordImportStats {
    totalRecords: number;
    queuedRecords: number;
    processingRecords: number;
    completedRecords: number;
    failedRecords: number;
    canceledRecords: number;
    awaitingRecords: number;
}
interface RecordImportItem {
    itemId: string;
    importId: string;
    tenantId: string;
    environmentId: string;
    className: string;
    id: string;
    label: string | null;
    fields: Record<string, string | number | boolean | null> | null;
    relationships: Record<string, string | string[]> | null;
    status: RecordImportItemStatus;
    attempts: number;
    errorMessage: string | null;
    resultPath: string | null;
    resultCreated: boolean | null;
    createdAt: number;
    updatedAt: number;
    processedAt: number | null;
}
interface RecordImport {
    importId: string;
    tenantId: string;
    environmentId: string;
    sandboxId: string;
    subjectId: string;
    setupRunId?: string | null;
    status: RecordImportStatus;
    batchSize: number;
    errorMessage: string | null;
    createdAt: number;
    updatedAt: number;
    startedAt: number | null;
    finishedAt: number | null;
    canceledAt: number | null;
    stats: RecordImportStats;
}
interface EnvironmentRecordImportSummary extends RecordImportStats {
    environmentId: string;
    totalImports: number;
    activeImports: number;
    updatedAt: number;
}
type EnvironmentSetupTriggerReason = "new_environment" | "fresh_after_version_update";
interface RunEnvironmentImporterOptions {
    /**
     * Ontology name/id used to resolve the registered importer. Defaults to the
     * environment sandbox id.
     */
    ontology?: string;
    /**
     * Reason recorded on the setup run. Defaults to `new_environment`.
     */
    reason?: EnvironmentSetupTriggerReason;
}
type EnvironmentSetupLifecycleStatus = "running" | "completed" | "failed";
interface EnvironmentSetupSummary extends RecordImportStats {
    setupRunId: string;
    environmentId: string;
    sandboxId: string;
    subjectId: string;
    triggerReason: EnvironmentSetupTriggerReason;
    lifecycleStatus: EnvironmentSetupLifecycleStatus;
    stage: string | null;
    totalObjectsToImport: number;
    totalImports: number;
    activeImports: number;
    errorMessage: string | null;
    startedAt: number;
    hookCompletedAt: number | null;
    finishedAt: number | null;
    updatedAt: number;
}
interface EnvironmentImporterImportOptions {
    batchSize?: number;
    writeMode?: RecordImportWriteMode;
}
interface EnvironmentImporter {
    environmentId: string;
    sandboxId: string;
    subjectId: string;
    reason: EnvironmentSetupTriggerReason;
    incrementTotalObjectsToImportCount: (n: number) => Promise<void>;
    setStage: (stage: string | null) => Promise<void>;
    importRecords: (records: RecordObjectOptions[], options?: EnvironmentImporterImportOptions) => Promise<RecordImport>;
}
/**
 * Property specification in a manifest operation
 */
interface ManifestPropertySpec {
    value?: string | number | boolean;
    ref?: string;
    instanceOf?: string;
    create?: string;
    has?: Record<string, ManifestPropertySpec>;
    type?: string;
    description?: string;
    required?: boolean;
    note?: string | string[];
    enum?: string[] | ManifestEnumRuleSpec;
    filterBy?: boolean | string[] | ManifestFilterBySpec;
    validate?: ManifestValidationRuleSpec[];
}
type ManifestValidationOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "true" | "false" | "regex" | "contains" | "not_contains" | "starts_with" | "ends_with";
interface ManifestEnumRuleSpec {
    values: string[];
    message?: string;
}
interface ManifestFilterBySpec {
    operators: string[];
    scalarType?: string;
}
interface ManifestValidationRuleSpec {
    operator: ManifestValidationOperator;
    stringValue?: string;
    numberValue?: number;
    booleanValue?: boolean;
    message?: string;
}
interface ManifestStateMachineStateSpec {
    name: string;
    isFinal?: boolean;
}
interface ManifestStateMachineTransitionSpec {
    name: string;
    from: string;
    to: string;
}
interface ManifestStateMachineSpec {
    name: string;
    entryState: string;
    states: Array<string | ManifestStateMachineStateSpec>;
    transitions: ManifestStateMachineTransitionSpec[];
    finalStates?: string[];
}
interface ManifestPostConditionSpec {
    condition: string;
    description?: string;
}
interface ManifestDryRunSpec {
    enabled?: boolean;
    description?: string;
}
interface ManifestReverseSpec {
    handler?: string;
    description?: string;
}
interface ManifestApprovalRequiredSpec {
    required?: boolean;
    reason?: string;
    mode?: string;
}
interface ManifestEffectMetamodelSpec {
    postCondition?: string | ManifestPostConditionSpec;
    dryRun?: boolean | ManifestDryRunSpec;
    reverse?: string | ManifestReverseSpec;
    approvalRequired?: boolean | ManifestApprovalRequiredSpec;
}
/**
 * Relationship definition between two classes
 */
interface ManifestRelationshipDef {
    /** Optional name (auto-generated from left_right if omitted) */
    name?: string;
    /** Left model path */
    left: string;
    /** Right model path */
    right: string;
    /** Submodel name on the left model */
    leftSubmodel: string;
    /** Submodel name on the right model */
    rightSubmodel: string;
    /** Whether the left side is a collection */
    leftIsMany: boolean;
    /** Whether the right side is a collection */
    rightIsMany: boolean;
}
interface ManifestEffectSchema {
    type: string;
    properties?: Record<string, unknown>;
    required?: string[];
    items?: unknown;
    description?: string;
    [key: string]: unknown;
}
interface ManifestEffectDeclaration {
    name: string;
    description?: string;
    attachedClass?: string;
    isStatic?: boolean;
    inputSchema: ManifestEffectSchema;
    outputSchema?: ManifestEffectSchema;
    stability?: "stable" | "experimental" | "deprecated";
    tags?: string[];
    metamodels?: ManifestEffectMetamodelSpec;
}
/**
 * An event type within an event stream definition
 */
interface ManifestEventTypeDef {
    name: string;
    description?: string;
    payloadSchema: ManifestEffectSchema;
}
/**
 * Event stream definition for outgoing typed events
 */
interface ManifestEventStreamDef {
    name: string;
    description?: string;
    eventTypes: ManifestEventTypeDef[];
}
/**
 * A single operation in a manifest volume
 */
interface ManifestOperation {
    /** Create a new model/class */
    create?: string;
    /** Target an existing model for modification */
    on?: string;
    /** Extend from a parent class */
    extends?: string;
    /** Instantiate a type */
    instanceOf?: string;
    /** Define submodels/fields */
    has?: Record<string, ManifestPropertySpec>;
    /** Advisory notes attached to the model/class itself */
    note?: string | string[];
    /** State machines attached to the created or targeted class */
    stateMachines?: ManifestStateMachineSpec[];
    /** Define a relationship between two classes */
    defineRelationship?: ManifestRelationshipDef;
    /** Declare a build-owned effect */
    withEffect?: ManifestEffectDeclaration;
    /** Define an outgoing event stream with typed events */
    defineEventStream?: ManifestEventStreamDef;
}
/**
 * A volume in a manifest
 */
/**
 * Import descriptor for referencing modules
 */
interface ManifestImport {
    /** Alias prefix used in operations (e.g., "@std") */
    alias: string;
    /** Module name (e.g., "standard_modules") */
    name: string;
    /** Version label (e.g., "prod", "v1.2.3") */
    label?: string;
}
interface ManifestVolume {
    name: string;
    scope: "sandbox" | "build" | "user";
    imports?: ManifestImport[];
    operations: ManifestOperation[];
}
/**
 * A manifest defines the structure of a sandbox's data model
 */
interface ManifestContent {
    schemaVersion: 2;
    name: string;
    description?: string;
    volumes: ManifestVolume[];
}
/**
 * Result from a GraphQL query execution
 */
interface GraphQLResult<T = any> {
    data?: T;
    errors?: Array<{
        message: string;
        locations?: Array<{
            line: number;
            column: number;
        }>;
        path?: Array<string | number>;
        extensions?: Record<string, any>;
    }>;
}
interface APIError {
    error: string;
    message?: string;
}
interface DeleteResponse {
    deleted: boolean;
}
interface StreamEvent {
    eventId: string;
    streamName: string;
    eventType: string;
    payload: Record<string, unknown>;
    environmentId: string;
    sessionId?: string;
    subjectId?: string;
    source: "sandbox" | "api";
    isAcked: boolean;
    createdAt: number;
}
interface StreamSubscription {
    unsubscribe(): void;
}
interface StreamStats {
    streamName: string;
    eventType: string;
    total: number;
    last1h: number;
    last24h: number;
    unacked: number;
}

interface OpenAIModelPricing {
    provider: "openai";
    model: string;
    currency: "USD";
    inputUsdPerMillion: number;
    cachedInputUsdPerMillion: number;
    outputUsdPerMillion: number;
    sourceUrl: string;
    effectiveDate: string;
}
interface NormalizedOpenAIUsage {
    inputTokens: number;
    cachedInputTokens: number;
    uncachedInputTokens: number;
    outputTokens: number;
    reasoningTokens: number;
    totalTokens: number;
}
interface OpenAITokenSpend {
    provider: "openai";
    model: string;
    inputTokens: number;
    cachedInputTokens: number;
    uncachedInputTokens: number;
    outputTokens: number;
    reasoningTokens: number;
    totalTokens: number;
    amountMicros: number;
    currency: "USD";
    inputPricePerMillionMicros: number;
    cachedInputPricePerMillionMicros: number;
    outputPricePerMillionMicros: number;
    pricingSource: string;
    pricingEffectiveAt: string;
    usage: NormalizedOpenAIUsage;
}
declare const OPENAI_MODEL_PRICING_USD_PER_MILLION: Record<string, OpenAIModelPricing>;
declare function getOpenAIModelPricing(model: string): OpenAIModelPricing | null;
declare function normalizeOpenAIUsage(rawUsage: unknown): NormalizedOpenAIUsage;
declare function calculateOpenAITokenSpend(model: string, rawUsage: unknown): OpenAITokenSpend | null;

interface GranularSpendContext {
    tenantId?: string | null;
    sandboxId?: string | null;
    environmentId?: string | null;
    sessionId?: string | null;
    subjectId?: string | null;
    permissionProfileId?: string | null;
    [key: string]: string | null | undefined;
}
interface OpenAIUsageSpendEvent extends OpenAITokenSpend {
    spendEventId?: string;
    source?: "openai";
    lineItemType?: "llm_tokens";
    operation?: string;
    requestId?: string | null;
    usageContext?: GranularSpendContext;
    rawUsage?: unknown;
}
interface RecordOpenAIUsageSpendOptions {
    apiUrl: string;
    token: string;
    usage: OpenAIUsageSpendEvent;
    context?: GranularSpendContext | null;
    metadata?: Record<string, unknown> | null;
}
interface RecordOpenAIUsageSpendResult {
    spendEventId: string;
    inserted: boolean;
    quota: GranularQuotaProgress | null;
}
declare function toGranularHttpBase(apiUrl: string): string;
declare function buildOpenAISpendEventId(usage: Pick<OpenAIUsageSpendEvent, "requestId">, context?: GranularSpendContext): string | undefined;
declare function recordOpenAIUsageSpend(options: RecordOpenAIUsageSpendOptions): Promise<RecordOpenAIUsageSpendResult>;

export { type PermissionProfileListResponse as $, type AccessTokenProvider as A, type QuotaPeriod as B, type ConnectOptions as C, type DomainState as D, type EndpointMode as E, type QuotaStatus as F, type GranularSpendContext as G, type SpendSummary as H, type InstanceToolHandler as I, type QuotaLineItemFilter as J, type GranularQuotaPolicy as K, type GranularQuotaProgress as L, type ManifestEffectMetamodelSpec as M, type NormalizedOpenAIUsage as N, type OpenAIModelPricing as O, type Prompt as P, type QuotaScopeType as Q, type ResolvedEffectBehaviors as R, type SessionHeapEntry as S, type ToolWithHandler as T, type User as U, type Sandbox as V, type CreateSandboxData as W, type SandboxListResponse as X, type PermissionRules as Y, type PermissionProfile as Z, type CreatePermissionProfileData as _, type EffectHandlerContext as a, type WSReconnectErrorInfo as a$, type Assignment as a0, type AssignmentListResponse as a1, type BuildPolicy as a2, type VersionTracking as a3, type VersionTag as a4, type EnvironmentData as a5, type CreateEnvironmentData as a6, type EnvironmentListResponse as a7, type Manifest as a8, type ManifestListResponse as a9, type JobFeedbackInput as aA, type JobFeedbackRecord as aB, type EnvironmentFeedbackRecord as aC, type JobSubmitResult as aD, type Job as aE, type ConversationMessageShowRefs as aF, type ConversationMessageInput as aG, type ConversationAppendResult as aH, type SessionConversationMessage as aI, type SessionTimelineEvent as aJ, type SessionFileSource as aK, type SessionFileKind as aL, type SessionFileStatus as aM, type SessionFileRecord as aN, type SessionFileUploadOptions as aO, type SessionJobRecord as aP, type SessionHeapFieldType as aQ, type SessionHeapFieldValue as aR, type SessionHeapVariable as aS, type RecordSearchResult as aT, type RecordSearchOptions as aU, type RecordMentionInput as aV, type SessionDocumentResult as aW, type SessionCollectionListOptions as aX, type SessionJobListOptions as aY, type SessionCollectionListResult as aZ, type WSDisconnectInfo as a_, type BuildStatus as aa, type Build as ab, type Version as ac, type BuildListResponse as ad, type SemanticVersionDiffEntry as ae, type SemanticVersionDiff as af, type ResolvedEffectPostCondition as ag, type ResolvedEffectDryRun as ah, type ResolvedEffectReverse as ai, type ResolvedEffectApprovalRequired as aj, type EffectInvocationMode as ak, type EffectInvocationMetadata as al, type EffectSchema as am, type EffectWithHandler as an, type PublishEffectsResult as ao, type EffectVersionSelector as ap, type ToolInfo as aq, type EffectInfo as ar, type ToolsChangedEvent as as, type EffectsChangedEvent as at, type EffectHandler as au, type InstanceEffectHandler as av, type JobStatus as aw, type JobFeedbackSentiment as ax, type JobFeedbackToolCall as ay, type JobFeedbackMetadata as az, type SessionHeapList as b, type WSClientOptions as b0, type RPCRequest as b1, type RPCResponse as b2, type SyncMessage as b3, type RPCRequestFromServer as b4, type ToolInvokeParams as b5, type ToolResultParams as b6, type ModelRef as b7, type RelationshipInfo as b8, type DefineRelationshipOptions as b9, type ManifestPostConditionSpec as bA, type ManifestDryRunSpec as bB, type ManifestReverseSpec as bC, type ManifestApprovalRequiredSpec as bD, type ManifestRelationshipDef as bE, type ManifestEffectSchema as bF, type ManifestEffectDeclaration as bG, type ManifestEventTypeDef as bH, type ManifestEventStreamDef as bI, type ManifestOperation as bJ, type ManifestImport as bK, type ManifestVolume as bL, type ManifestContent as bM, type GraphQLResult as bN, type APIError as bO, type DeleteResponse as bP, type StreamEvent as bQ, type StreamSubscription as bR, type StreamStats as bS, type RecordObjectOptions as ba, type RecordObjectResult as bb, type RecordObjectsChunkInfo as bc, type RecordObjectsOptions as bd, type RecordImportWriteMode as be, type RecordImportOptions as bf, type RecordImportStatus as bg, type RecordImportItemStatus as bh, type RecordImportStats as bi, type RecordImportItem as bj, type RecordImport as bk, type EnvironmentRecordImportSummary as bl, type EnvironmentSetupTriggerReason as bm, type RunEnvironmentImporterOptions as bn, type EnvironmentSetupLifecycleStatus as bo, type EnvironmentSetupSummary as bp, type EnvironmentImporterImportOptions as bq, type EnvironmentImporter as br, type ManifestPropertySpec as bs, type ManifestValidationOperator as bt, type ManifestEnumRuleSpec as bu, type ManifestFilterBySpec as bv, type ManifestValidationRuleSpec as bw, type ManifestStateMachineStateSpec as bx, type ManifestStateMachineTransitionSpec as by, type ManifestStateMachineSpec as bz, type SessionHeapSnapshot as c, type SessionTranscriptEntry as d, type ToolSchema as e, type PublishToolsResult as f, type ToolHandler as g, type OpenAITokenSpend as h, OPENAI_MODEL_PRICING_USD_PER_MILLION as i, getOpenAIModelPricing as j, calculateOpenAITokenSpend as k, type OpenAIUsageSpendEvent as l, type RecordOpenAIUsageSpendOptions as m, normalizeOpenAIUsage as n, type RecordOpenAIUsageSpendResult as o, buildOpenAISpendEventId as p, type GranularOptions as q, recordOpenAIUsageSpend as r, type GranularAuth as s, toGranularHttpBase as t, type RecordUserOptions as u, type Subject as v, type OpenEnvironmentOptions as w, type CreateSessionOptions as x, type ConversationSessionInfo as y, type SpendLineItemType as z };
