@forge-sdk/tool
Tool definition, execution, approval, and registry for the Forge SDK
Tool definition, execution, approval, and registry for the Forge SDK
Package contract
| Field | Value |
|---|---|
| Language | typescript |
| Source version | 0.1.0 |
| Manifest | forge-ts/packages/forge-tool/package.json |
| Source files | 7 |
| Evidence | Source reference; registry publication and runtime conformance are separate checks |
Import boundary
import * as api from '@forge-sdk/tool';Use a source checkout or your verified private registry. Manifest coordinates identify the package; they do not establish that a public registry release exists.
Source reference
Download package reference JSON. Each original source file and generated declaration artifact has its own SHA-256 digest. Function bodies and constant values are omitted from downloads. These are source declaration inventories, not compiler-resolved rustdoc, TypeDoc, DocC, or Dokka output. Private modules can contain public declarations that are not reachable through the package boundary; consult the entry point before importing.
approval.ts
Read declaration text · 4 declaration entries
export interface ApprovalHandler {
/**
* Checks whether a tool call should be approved, denied, or modified.
*
* @param call - The tool call to evaluate.
* @param tier - The tool's tier classification.
* @returns A ToolApproval indicating the decision.
*/
check(call: ToolCall, tier: ToolTier): Promise<ToolApproval>;
}
export class AutoApprove implements ApprovalHandler {
async check(_call: ToolCall, _tier: ToolTier): Promise<ToolApproval>;
}
export class DenyAll implements ApprovalHandler {
constructor(reason: string);
async check(_call: ToolCall, _tier: ToolTier): Promise<ToolApproval>;
}
export class TierBasedApproval implements ApprovalHandler {
async check(call: ToolCall, tier: ToolTier): Promise<ToolApproval>;
}definition.ts
Read declaration text · 1 declaration entries
export class ToolBuilder {
constructor(name: string);
description(desc: string): this;
tier(tier: ToolTier): this;
parameters(schema: JsonSchema): this;
executor(executor: ToolExecutor): this;
handler(handler: (call: ToolCall) => ToolResult | Promise<ToolResult>): this;
build(): [ToolDefinition, ToolExecutor | undefined];
}error.ts
Read declaration text · 3 declaration entries
export const ForgeToolErrorCode /* type inferred in source */;
export type ForgeToolErrorCodeType = (typeof ForgeToolErrorCode)[keyof typeof ForgeToolErrorCode];
export class ForgeToolError extends Error {
readonly code: ForgeToolErrorCodeType;
readonly toolName?: string;
static toolNotFound(name: string): ForgeToolError;
static executionFailed(name: string, reason: string): ForgeToolError;
static approvalDenied(name: string, reason: string): ForgeToolError;
static schemaValidation(name: string, path: string, reason: string): ForgeToolError;
static invalidTier(name: string, expected: string, actual: string): ForgeToolError;
static registryError(reason: string): ForgeToolError;
}execution.ts
Read declaration text · 3 declaration entries
export interface ToolExecutor {
/** The name of the tool this executor handles. */
readonly name: string;
/**
* Executes the tool with the given call arguments.
*
* @param call - The tool call containing the call ID, tool name, and JSON arguments.
* @returns A ToolResult with the execution output.
* @throws {ForgeToolError} If the tool logic fails.
*/
execute(call: ToolCall): Promise<ToolResult>;
}
export class FnToolExecutor implements ToolExecutor {
readonly name: string;
constructor(
name: string,
handler: (call: ToolCall) => ToolResult | Promise<ToolResult>
);
async execute(call: ToolCall): Promise<ToolResult>;
}
export async function executeToolCall(
call: ToolCall,
definition: ToolDefinition,
executor: ToolExecutor,
approvalHandler: ApprovalHandler
): Promise<ToolResult>;index.ts
Read declaration text · 6 declaration entries
export { ForgeToolError, ForgeToolErrorCode, type ForgeToolErrorCodeType } from './error.js';
export {
ExecutionContext,
type TierClassification,
classifyTier,
tierRequiresAuthorization,
executionContextFor,
} from './tiers.js';
export { type ToolExecutor, FnToolExecutor, executeToolCall } from './execution.js';
export { type ApprovalHandler, AutoApprove, DenyAll, TierBasedApproval } from './approval.js';
export { ToolBuilder } from './definition.js';
export { ToolRegistry } from './registry.js';registry.ts
Read declaration text · 1 declaration entries
export class ToolRegistry {
register(definition: ToolDefinition, executor: ToolExecutor): void;
get(name: string): [ToolDefinition, ToolExecutor] | undefined;
list(): ToolDefinition[];
definitions(): ToolDefinition[];
get size(): number;
get isEmpty(): boolean;
remove(name: string): [ToolDefinition, ToolExecutor] | undefined;
contains(name: string): boolean;
}tiers.ts
Read declaration text · 6 declaration entries
export const ExecutionContext /* type inferred in source */;
export type ExecutionContext = (typeof ExecutionContext)[keyof typeof ExecutionContext];
export interface TierClassification {
/** The name of the tool that was classified. */
readonly toolName: string;
/** The tool's tier classification. */
readonly tier: ToolTier;
/** Whether this tool requires Arsenal ACT authorization before execution. */
readonly requiresAuthorization: boolean;
/** The execution context (sandbox or host) for this tool. */
readonly executionContext: ExecutionContext;
}
export function classifyTier(toolName: string, tier: ToolTier): TierClassification;
export function tierRequiresAuthorization(tier: ToolTier): boolean;
export function executionContextFor(tier: ToolTier): ExecutionContext;