import { NativeCodemodeProvider } from "./native-codemode.js"; import type { Usage } from "@earendil-works/pi-ai"; import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; import { type FabricExecutionTraceV1 } from "./audit/trace.js"; import { FabricActivityStore } from "./activity/store.js"; import { type FabricAssessmentTraceV1 } from "./audit/assessment.js"; import type { CapturedToolCatalog } from "./capture/catalog.js"; import type { FabricRunDisplay } from "./activity/types.js"; import { type FabricConfig } from "./config.js"; import { type ActionRegistry, type FabricCallAudit, type ResolvedFabricAction } from "./core/action-registry.js"; import { FabricSessionApprovals } from "./core/approval-controller.js"; import { FabricAutoApprovalClassifier } from "./core/auto-approval-classifier.js"; import type { FabricActionPolicyHooks } from "./core/action-policy-hooks.js"; import type { FabricCommittedCapabilityView, FabricMediaBlock } from "./protocol.js"; import type { FabricKernel } from "./runtime/kernel.js"; import { type ProviderParticipantRegistry, type ProviderParticipantStopOutcome } from "./topology/provider-participants.js"; import type { FabricTypeError } from "./runtime/type-checker.js"; export interface FabricExecutionResult { success: boolean; kernel?: FabricKernel; value: unknown; logs: string[]; /** Images hoisted out of `value` by the media sanitizer, indexed by descriptor. */ media?: FabricMediaBlock[]; audits: FabricCallAudit[]; phases: string[]; trace: FabricExecutionTraceV1; /** Opt-in (`trace.assessment`) timings and usage; never part of `trace`. */ assessment?: FabricAssessmentTraceV1; elapsedMs: number; typeErrors?: FabricTypeError[]; error?: string; handoffRequest?: Record; usage?: Usage; /** Stop outcomes for owned provider participants after cancellation or timeout. */ ownedWork?: ProviderParticipantStopOutcome[]; } interface FabricExecutionPartial { audits: FabricCallAudit[]; phases: string[]; progress?: string | undefined; /** Running program deadline (epoch ms); absent while a human wait pauses it. */ deadlineAt?: number | undefined; } export type FabricHeadlessApproval = (action: ResolvedFabricAction, reason: string | undefined, signal: AbortSignal | undefined) => Promise; /** One saved program run nested inside an active execution (`programs.run`). */ export interface FabricNestedProgramRun { /** `name@digest`, recorded on the `fabric.program.run` trace operation. */ program: string; /** Guest source in the execution's kernel language. */ code?: string; /** A single host action, used for Jev programs (`jev.run`). */ call?: { ref: string; args: Record; }; } /** Program text a host caller supplied, with the SHA-256 Fabric computed for it. Never saved. */ export interface FabricCallerProgram { code: string; sha256: string; } /** * Runs a program through the enclosing execution's own host bridge: the same * capability view, approval controller, agent budget, signal and trace. It * can never widen what the calling program may do. */ export interface FabricNestedProgramRunner { kernel: FabricKernel; /** Caller-supplied code that `programs.run` may run in place of a saved program. */ callerProgram?: FabricCallerProgram; run(request: FabricNestedProgramRun, signal: AbortSignal | undefined): Promise; } /** Bounds recursive `programs.run` chains within one outer execution. */ export declare const MAX_NESTED_PROGRAM_RUNS = 16; export interface FabricExecutionAuthorizer { authorize(ref: string, parentToolCallId: string): Promise; } export interface FabricExecutionOptions { code: string; strings?: Record; /** Per-invocation whole-program deadline request from fabric_exec.timeoutMs. * Raises (never lowers) the configured executor.timeoutMs, subject to * executor.maxTimeoutMs. */ requestedTimeoutMs?: number; /** Hard whole-script deadline; unlike timeoutMs this cannot be raised or paused. */ hardTimeoutMs?: number; signal: AbortSignal | undefined; parentToolCallId: string; context: ExtensionContext; tokenBudget?: number; maxAgentCalls?: number; display?: FabricRunDisplay; /** Host-invoked program runs (`/fabric run`, the program run event). */ invokedBy?: "host"; /** The code a host caller supplied; `programs.run` runs it as `callerCodeProgram(sha256)`. */ callerProgram?: FabricCallerProgram; onPartial(snapshot: FabricExecutionPartial): void; } export declare class FabricExecutionService { #private; readonly registry: ActionRegistry; readonly config: FabricConfig; readonly activity?: FabricActivityStore | undefined; readonly authorizer?: FabricExecutionAuthorizer | undefined; readonly autoApprovalClassifier: FabricAutoApprovalClassifier; readonly sessionApprovals: FabricSessionApprovals; readonly capturedTools?: CapturedToolCatalog | undefined; readonly brokeredNetwork?: ((provider: string) => boolean) | undefined; readonly nativeCodemode: NativeCodemodeProvider; constructor(registry: ActionRegistry, config: FabricConfig, activity?: FabricActivityStore | undefined, authorizer?: FabricExecutionAuthorizer | undefined, autoApprovalClassifier?: FabricAutoApprovalClassifier, sessionApprovals?: FabricSessionApprovals, capturedTools?: CapturedToolCatalog | undefined, brokeredNetwork?: ((provider: string) => boolean) | undefined); setCapabilityView(view: FabricCommittedCapabilityView | undefined): void; /** Host event bus for observation-only events such as workflow item transitions. */ setEventEmitter(emit: ((channel: string, data: unknown) => void) | undefined): void; /** Session registry behind `context.participants` and owned-work cancellation. */ setParticipantRegistry(registry: ProviderParticipantRegistry | undefined): void; /** The nested program runner of the active execution with this outer call id. */ nestedProgramRunner(parentToolCallId: string): FabricNestedProgramRunner | undefined; /** No-UI approval fallback used when approvals.headless is "decision". */ setHeadlessApproval(handler: FabricHeadlessApproval | undefined): void; /** Extension hooks consulted at the approve stage when approvals.policyHooks is true. */ setActionPolicyHooks(hooks: FabricActionPolicyHooks | undefined): void; execute(options: FabricExecutionOptions): Promise; } export {}; //# sourceMappingURL=execution-service.d.ts.map