import type { CfcEnforcementMode, CfcLabelView, } from "@commonfabric/runner/cfc"; import type { HarnessCfcInvocationContext, HarnessCfcInvocationInputLabelPath, HarnessCfcInvocationOperation, } from "../contracts/cfc-invocation-context.ts"; import type { HarnessAllowedSkillScript, HarnessSkillActivations, HarnessSkillRegistry, HarnessSkillResourceRead, HarnessSkillScriptExecution, HarnessSkillScriptExecutionTarget, } from "../contracts/skill.ts"; import type { HarnessBrowserAccessLease } from "../contracts/browser-access.ts"; import type { HarnessToolDescriptor } from "../contracts/tool-descriptor.ts"; import type { ToolOutputId } from "../contracts/tool-result.ts"; import type { ProcessRunner } from "../sandbox/process-runner.ts"; import type { SandboxRuntime } from "../sandbox/types.ts"; export interface HarnessToolContext { runId: string; cfcEnforcementMode: CfcEnforcementMode; skillRegistry?: HarnessSkillRegistry; skillActivations?: HarnessSkillActivations; allowedSkillScripts?: readonly HarnessAllowedSkillScript[]; skillScriptExecutionTarget: HarnessSkillScriptExecutionTarget; browserAccess?: HarnessBrowserAccessLease; sandbox: SandboxRuntime; hostProcessRunner: ProcessRunner; currentDir: string; workspaceHostPath?: string; resolvePath(path: string): string; resolveHostPath(path: string): string; resolveHostRootPath(path: string): string; hostPathToWorkspacePath(path: string): string | undefined; isHostPathWithinWorkspace( path: string, options?: { allowMissing?: boolean }, ): Promise; isHostPathWithinArtifactRoot( path: string, options?: { allowMissing?: boolean }, ): Promise; doesHostPathIntersectArtifactRoot( path: string, options?: { allowMissing?: boolean }, ): Promise; setCurrentDir(path: string): void; nextOutputId(toolId: string): ToolOutputId; now(): string; recordSkillResourceRead(read: HarnessSkillResourceRead): Promise; recordSkillScriptExecution( execution: HarnessSkillScriptExecution, ): Promise; createCfcInvocationContext(options: { toolId: string; toolOutputId?: ToolOutputId; operation: HarnessCfcInvocationOperation; cwd: string; command?: string; argv?: readonly string[]; args?: readonly string[]; stdinText?: string; env?: Record; cfcInputLabels?: CfcLabelView; cfcInputLabelPaths?: readonly HarnessCfcInvocationInputLabelPath[]; cfcPromptSlotInputLabelPaths?: readonly HarnessCfcInvocationInputLabelPath[]; cfcModelContextInputLabelPaths?: readonly HarnessCfcInvocationInputLabelPath[]; }): Promise; } export interface HarnessToolDefinition { descriptor: HarnessToolDescriptor; invoke(context: HarnessToolContext, input: Input): Promise; } export const createUnimplementedToolError = (toolId: string): Error => new Error(`${toolId} is not implemented yet`);