Skip to content

AIDK API Reference / aidk/jsx / SpawnComponent

Class: SpawnComponent ​

Defined in: packages/core/src/jsx/components/spawn.tsx:95

Spawn component implementation

Extends ​

Constructors ​

Constructor ​

ts
new SpawnComponent(props: SpawnProps): SpawnComponent;

Defined in: packages/core/src/component/component.ts:331

Parameters ​

ParameterType
propsSpawnProps

Returns ​

SpawnComponent

Inherited from ​

Component.constructor

Properties ​

PropertyModifierTypeDefault valueInherited fromDefined in
hooksstaticRecord<string, ComponentHookMiddleware<any>[]>{}Component.hookspackages/core/src/component/component.ts:319
propspublicSpawnPropsundefinedComponent.propspackages/core/src/component/component.ts:328
statepublic{ }undefinedComponent.statepackages/core/src/component/component.ts:329
tagsstaticstring[][]Component.tagspackages/core/src/component/component.ts:320

Accessors ​

hooks ​

Get Signature ​

ts
get hooks(): ComponentHookRegistry;

Defined in: packages/core/src/component/component.ts:324

Returns ​

ComponentHookRegistry

Inherited from ​

Component.hooks

Methods ​

getHandle() ​

ts
getHandle(): 
  | ExecutionHandle
  | undefined;

Defined in: packages/core/src/jsx/components/spawn.tsx:173

Get the ExecutionHandle for this spawn Useful for accessing spawn status, result, etc.

Returns ​

| ExecutionHandle | undefined


getState() ​

ts
getState<T>(key: never): T;

Defined in: packages/core/src/component/component.ts:370

Legacy state management - use signals instead for better reactivity.

Type Parameters ​

Type ParameterDefault type
Tunknown

Parameters ​

ParameterType
keynever

Returns ​

T

Deprecated ​

Consider using signals for component state

Inherited from ​

Component.getState


onAfterCompile() ​

ts
onAfterCompile(
   _com: ContextObjectModel, 
   _compiled: CompiledStructure, 
   _state: TickState, 
   _ctx: AfterCompileContext): void;

Defined in: packages/core/src/component/component.ts:389

Called after each compilation pass, before the final render is applied. Use this to inspect the compiled structure and potentially request re-compilation if state changes are needed (e.g., context summarization, tool adjustments).

The compilation loop continues until no component calls com.requestRecompile() or the maximum iteration limit is reached.

Parameters ​

ParameterType
_comContextObjectModel
_compiledCompiledStructure
_stateTickState
_ctxAfterCompileContext

Returns ​

void

Inherited from ​

Component.onAfterCompile


onComplete() ​

ts
onComplete(_com: ContextObjectModel, _finalState: COMInput): void;

Defined in: packages/core/src/component/component.ts:396

Called after the entire execution completes (all ticks finished). At this point, the final COMInput is available. Use this for final state processing, persistence, reporting, side effects, etc. Called before onUnmount.

Note: This is for side effects only, not rendering. Rendering should happen in render(). Model outputs are automatically included in the final COM state.

Parameters ​

ParameterType
_comContextObjectModel
_finalStateCOMInput

Returns ​

void

Inherited from ​

Component.onComplete


onError() ​

ts
onError(_com: ContextObjectModel, _state: TickState): void | RecoveryAction;

Defined in: packages/core/src/component/component.ts:397

Called when an error occurs during engine execution. Components can use this to handle errors and potentially recover.

Parameters ​

ParameterType
_comContextObjectModel
_stateTickState

Returns ​

void | RecoveryAction

RecoveryAction to indicate whether to continue execution, or void/undefined to let error propagate

Inherited from ​

Component.onError


onMessage() ​

ts
onMessage(
   _com: ContextObjectModel, 
   _message: ExecutionMessage, 
   _state: TickState): void | Promise<void>;

Defined in: packages/core/src/component/component.ts:402

Called immediately when a message is sent to the running execution.

Messages can arrive via:

  • CompileSession.sendMessage() - Direct programmatic injection
  • ExecutionHandle.send() - Via handle reference
  • Channel events with type='message' - From client

This hook is called immediately when the message arrives, not at tick boundaries. Use com.abort() to interrupt execution if needed, or update state for the next tick. Messages are also available in TickState.queuedMessages during render.

Parameters ​

ParameterType
_comContextObjectModel
_messageExecutionMessage
_stateTickState

Returns ​

void | Promise<void>

Example ​

typescript
class InteractiveAgent extends Component {
  onMessage(com, message, state) {
    if (message.type === 'stop') {
      com.abort('User requested stop');
    } else if (message.type === 'feedback') {
      com.setState('userFeedback', message.content);
    }
  }
}

Inherited from ​

Component.onMessage


onMount() ​

ts
onMount(_com: ContextObjectModel): void;

Defined in: packages/core/src/component/component.ts:378

Called when the component is mounted to the engine. Use this to register static resources like tools.

Parameters ​

ParameterType
_comContextObjectModel

Returns ​

void

Inherited from ​

Component.onMount


onStart() ​

ts
onStart(_com: ContextObjectModel): void;

Defined in: packages/core/src/component/component.ts:387

Called once before the first tick, after the COM is created. Use this for initialization that needs to happen before execution starts.

Parameters ​

ParameterType
_comContextObjectModel

Returns ​

void

Inherited from ​

Component.onStart


onTickEnd() ​

ts
onTickEnd(_com: ContextObjectModel, _state: TickState): void;

Defined in: packages/core/src/component/component.ts:395

Called after model execution completes for this tick. At this point, current is available (contains model outputs from this tick). Use this for per-tick processing, validation, or side effects. Note: Model outputs are automatically included in the next tick's previous.

Parameters ​

ParameterType
_comContextObjectModel
_stateTickState

Returns ​

void

Inherited from ​

Component.onTickEnd


onTickStart() ​

ts
onTickStart(_com: ContextObjectModel, _state: TickState): void;

Defined in: packages/core/src/component/component.ts:388

Parameters ​

ParameterType
_comContextObjectModel
_stateTickState

Returns ​

void

Inherited from ​

Component.onTickStart


onUnmount() ​

ts
onUnmount(com: ContextObjectModel): Promise<void>;

Defined in: packages/core/src/jsx/components/spawn.tsx:99

Called when the component is unmounted from the engine.

Parameters ​

ParameterType
comContextObjectModel

Returns ​

Promise<void>

Overrides ​

Component.onUnmount


render() ​

ts
render(com: ContextObjectModel, _state: TickState): Element | null;

Defined in: packages/core/src/jsx/components/spawn.tsx:109

Declaratively render context for the current tick. Components should interact with the COM to compose the context. OR return a Virtual DOM tree (JSX.Element) to be rendered by the Engine.

Parameters ​

ParameterType
comContextObjectModel
_stateTickState

Returns ​

Element | null

Overrides ​

Component.render


setState() ​

ts
setState(partial: Partial<S>): void;

Defined in: packages/core/src/component/component.ts:362

Legacy state management - use signals instead for better reactivity.

Parameters ​

ParameterType
partialPartial<S>

Returns ​

void

Deprecated ​

Consider using signals for component state

Inherited from ​

Component.setState

Released under the MIT License.