AIDK API Reference / aidk/jsx / SpawnComponent
Class: SpawnComponent ​
Defined in: packages/core/src/jsx/components/spawn.tsx:95
Spawn component implementation
Extends ​
Constructors ​
Constructor ​
new SpawnComponent(props: SpawnProps): SpawnComponent;Defined in: packages/core/src/component/component.ts:331
Parameters ​
| Parameter | Type |
|---|---|
props | SpawnProps |
Returns ​
SpawnComponent
Inherited from ​
Properties ​
| Property | Modifier | Type | Default value | Inherited from | Defined in |
|---|---|---|---|---|---|
hooks | static | Record<string, ComponentHookMiddleware<any>[]> | {} | Component.hooks | packages/core/src/component/component.ts:319 |
props | public | SpawnProps | undefined | Component.props | packages/core/src/component/component.ts:328 |
state | public | { } | undefined | Component.state | packages/core/src/component/component.ts:329 |
tags | static | string[] | [] | Component.tags | packages/core/src/component/component.ts:320 |
Accessors ​
hooks ​
Get Signature ​
get hooks(): ComponentHookRegistry;Defined in: packages/core/src/component/component.ts:324
Returns ​
Inherited from ​
Methods ​
getHandle() ​
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() ​
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 Parameter | Default type |
|---|---|
T | unknown |
Parameters ​
| Parameter | Type |
|---|---|
key | never |
Returns ​
T
Deprecated ​
Consider using signals for component state
Inherited from ​
onAfterCompile() ​
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 ​
| Parameter | Type |
|---|---|
_com | ContextObjectModel |
_compiled | CompiledStructure |
_state | TickState |
_ctx | AfterCompileContext |
Returns ​
void
Inherited from ​
onComplete() ​
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 ​
| Parameter | Type |
|---|---|
_com | ContextObjectModel |
_finalState | COMInput |
Returns ​
void
Inherited from ​
onError() ​
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 ​
| Parameter | Type |
|---|---|
_com | ContextObjectModel |
_state | TickState |
Returns ​
void | RecoveryAction
RecoveryAction to indicate whether to continue execution, or void/undefined to let error propagate
Inherited from ​
onMessage() ​
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 ​
| Parameter | Type |
|---|---|
_com | ContextObjectModel |
_message | ExecutionMessage |
_state | TickState |
Returns ​
void | Promise<void>
Example ​
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 ​
onMount() ​
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 ​
| Parameter | Type |
|---|---|
_com | ContextObjectModel |
Returns ​
void
Inherited from ​
onStart() ​
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 ​
| Parameter | Type |
|---|---|
_com | ContextObjectModel |
Returns ​
void
Inherited from ​
onTickEnd() ​
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 ​
| Parameter | Type |
|---|---|
_com | ContextObjectModel |
_state | TickState |
Returns ​
void
Inherited from ​
onTickStart() ​
onTickStart(_com: ContextObjectModel, _state: TickState): void;Defined in: packages/core/src/component/component.ts:388
Parameters ​
| Parameter | Type |
|---|---|
_com | ContextObjectModel |
_state | TickState |
Returns ​
void
Inherited from ​
onUnmount() ​
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 ​
| Parameter | Type |
|---|---|
com | ContextObjectModel |
Returns ​
Promise<void>
Overrides ​
render() ​
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 ​
| Parameter | Type |
|---|---|
com | ContextObjectModel |
_state | TickState |
Returns ​
Element | null
Overrides ​
setState() ​
setState(partial: Partial<S>): void;Defined in: packages/core/src/component/component.ts:362
Legacy state management - use signals instead for better reactivity.
Parameters ​
| Parameter | Type |
|---|---|
partial | Partial<S> |
Returns ​
void
Deprecated ​
Consider using signals for component state