Skip to content

Documentation / @agentick/kernel / HandleFactory

Type Alias: HandleFactory()<THandle, TContext> ​

HandleFactory<THandle, TContext> = (events, traceId, result, context, abortController?) => THandle

Defined in: kernel/src/procedure.ts:418

Factory function for creating custom execution handles.

Use this to provide custom handle implementations with additional functionality like cancellation, status tracking, or specialized events.

Type Parameters ​

THandle ​

THandle extends ExecutionHandle<any, any> = ExecutionHandle<any, any>

The custom handle type (must extend ExecutionHandle)

TContext ​

TContext extends KernelContext = KernelContext

The context type (must extend KernelContext)

Parameters ​

events ​

EventBuffer<any>

traceId ​

string

result ​

Promise<any>

context ​

TContext

abortController? ​

AbortController

Returns ​

THandle

Example ​

typescript
const customHandleFactory: HandleFactory = (events, traceId, result, context, abortController) => {
  const handle = new ExecutionHandleImpl(result, events, traceId, abortController);
  // Add custom properties/methods
  return Object.assign(handle, {
    customMethod() { ... }
  });
};

const proc = createProcedure(
  { handleFactory: customHandleFactory },
  async (input) => input
);

See ​

Released under the ISC License.