Skip to main content

DelegatingToolSpec

@forge/monorepo


@forge/monorepo / backend/src / DelegatingToolSpec

Type Alias: DelegatingToolSpec<I, O>

DelegatingToolSpec<I, O> = Omit<ToolSpec<I, O>, "execute"> & object

Defined in: backend/src/tools/delegating.ts:39

Type Declaration

delegatesTo

readonly delegatesTo: string

The function this capability wraps, named so a reviewer can see it (AC-6).

Required, not optional. A comment does not survive review at scale, and "which existing function does this delegate to" is the question the whole bridge exists to make answerable — so a capability that does not say what it wraps cannot be defined.

delegate()

delegate(input, context, details): O | Promise<O>

The deterministic function. Receives validated input, the execution context and the call's idempotency key; returns data or throws. Knows nothing about authorisation or approvals.

Parameters

input

I

context

ExecutionContext

details

DelegateDetails

Returns

O | Promise<O>

preflight()?

optional preflight(input, context): void | Promise<void>

A check that runs before the approval gate (#119 AC-4).

The general property, not a publishing one: do not ask a person to authorise something that cannot succeed. Content validation placed inside the delegate runs after the gate, so a human would already have approved something that then fails — which teaches them their approval does not mean much.

Throw to refuse. The thrown error is returned as-is, so a preflight that has structured findings can carry them in details rather than flattening them into a sentence.

It must be read-only. It runs on every call including one that is about to be refused for want of an approval, so a preflight with a side effect would be a side effect that happens without approval — the exact thing the gate exists to prevent.

Parameters

input

I

context

ExecutionContext

Returns

void | Promise<void>

Type Parameters

I

I = unknown

O

O = unknown