@threadplane/angularInterfacev0.3.7

AgentControls

What an agent adds because it outlives any one session: the thread it is on, a retained list of the current run's custom events, and its lifecycle.

import type { AgentControls } from '@threadplane/angular';

Declaration

export interface AgentControls  {
  readonly customEvents: Signal<readonly AgentSessionCustomEvent[]>;
  readonly isThreadLoading: Signal<boolean>;
  readonly lifecycle: AgentLifecycle;
  onStop(listener: () => void): () => void;
  readonly sessionEpoch: Signal<number>;
  switchThread(threadId: string | null): void;
  readonly threadId: Signal<string | null>;
}

Members

customEvents

The custom events the current run has emitted, oldest first. Empty again when the next run starts and when the agent switches threads. Stays empty on a session without onCustomEvent.

readonly customEvents: Signal<readonly AgentSessionCustomEvent[]>;

isThreadLoading

True while the selected thread's saved history is being read.

readonly isThreadLoading: Signal<boolean>;

lifecycle

Milestone timestamps; see AgentLifecycle.

readonly lifecycle: AgentLifecycle;

onStop · overload 1

Registers a listener that is called each time stop() is called on the agent, before the session is told to stop. A library uses it to cancel work of its own that a session cannot reach, such as a client tool handler running in the browser. The registration outlives thread switches and ends with the returned release or with the agent. A thread switch and the agent's destruction stop the old session without calling the listeners.

onStop(listener: () => void): () => void;

Parameters

listener · required
() => void

Returns

() => void

sessionEpoch

How many times the session underneath has been replaced: 0 for the session the agent was built with, one more after each thread switch. Read it in an effect to redo what belongs to one session, such as handing it a client tool catalog.

readonly sessionEpoch: Signal<number>;

switchThread · overload 1

Moves the agent to another thread, or to a new empty one with null. The session underneath is replaced: the old one is stopped and disposed and can publish nothing further, and every signal carries on with the new thread. Calling it with the current id reloads that thread.

switchThread(threadId: string | null): void;

Parameters

threadId · required
string | null

Returns

void

threadId

The thread the agent is on: the configured or switched-to id, or the id the session reported when it created its thread. Null before a thread exists.

readonly threadId: Signal<string | null>;