Class: AgentOS
Defined in: packages/agentos/src/api/AgentOS.ts:912
Implements
Description
The AgentOS class is the SOTA public-facing service facade for the entire AI agent platform.
It provides a unified API for interacting with the system, managing the lifecycle of core
components, and orchestrating complex AI interactions. This class ensures that all
operations adhere to the defined architectural tenets, including robust error handling,
comprehensive documentation, and strict type safety.
Implements
IAgentOS
Constructors
Constructor
new AgentOS(
logger?):AgentOS
Defined in: packages/agentos/src/api/AgentOS.ts:948
Constructs an AgentOS instance. The instance is not operational until
initialize() is called and successfully completes.
Parameters
logger?
ILogger = ...
Returns
AgentOS
Methods
applyWorkflowTaskUpdates()
applyWorkflowTaskUpdates(
workflowId,updates):Promise<WorkflowInstance|null>
Defined in: packages/agentos/src/api/AgentOS.ts:2624
Applies task-level updates to a workflow instance.
Parameters
workflowId
string
The workflow instance ID.
updates
Array of task updates to apply.
Returns
Promise<WorkflowInstance | null>
Updated workflow instance or null if not found.
Implementation of
IAgentOS.applyWorkflowTaskUpdates
getConversationHistory()
getConversationHistory(
conversationId,userId):Promise<ConversationContext|null>
Defined in: packages/agentos/src/api/AgentOS.ts:2674
Async
Retrieves the conversation history for a specific conversation ID, subject to user authorization.
Parameters
conversationId
string
The unique identifier of the conversation to retrieve.
userId
string
The ID of the user requesting the history. Authorization checks are performed to ensure the user has access to this conversation.
Returns
Promise<ConversationContext | null>
A promise that resolves to the
ConversationContext object if found and accessible, or null otherwise.
Throws
If the service is not initialized or if a critical error
occurs during history retrieval (permission errors might result in null or specific error type).
Implementation of
IAgentOS.getConversationHistory
getConversationManager()
getConversationManager():
ConversationManager
Defined in: packages/agentos/src/api/AgentOS.ts:1856
Explicit runtime getters for devtools integrations such as AgentOS Workbench.
Returns
Implementation of
IAgentOS.getConversationManager
getExtensionManager()
getExtensionManager():
ExtensionManager
Defined in: packages/agentos/src/api/AgentOS.ts:2011
Returns
Implementation of
IAgentOS.getExtensionManager
getExternalToolRegistry()
getExternalToolRegistry():
ExternalToolRegistry|undefined
Defined in: packages/agentos/src/api/AgentOS.ts:2036
Returns
ExternalToolRegistry | undefined
Implementation of
IAgentOS.getExternalToolRegistry
getGMIManager()
getGMIManager():
GMIManager
Defined in: packages/agentos/src/api/AgentOS.ts:1861
Returns
Implementation of
IAgentOS.getGMIManager
getHttpHandlers()
getHttpHandlers():
HttpHandlerPayload[]
Defined in: packages/agentos/src/api/AgentOS.ts:2022
Active extension HTTP handlers (EXTENSION_KIND_HTTP_HANDLER payloads), in registration order. Empty before initialize() or when none are loaded. Hosts (AgentOSServer, wunderland start, express mounts) iterate these to serve pack-contributed endpoints such as webhooks.
Returns
getLearningLayer()
getLearningLayer():
ILearningLayer|undefined
Defined in: packages/agentos/src/api/AgentOS.ts:1871
The runtime's learning layer, or undefined when learning is off: no learning option and no layer passed
in gmiManagerConfig.learningLayer. A host reads the loop manifest from it; a measurement asserts on it
that a runtime it compares has learning off.
Returns
ILearningLayer | undefined
Implementation of
IAgentOS.getLearningLayer
getModelProviderManager()
getModelProviderManager():
AIModelProviderManager
Defined in: packages/agentos/src/api/AgentOS.ts:2046
Returns
Implementation of
IAgentOS.getModelProviderManager
getPendingExternalToolRequest()
getPendingExternalToolRequest(
conversationId,userId):Promise<AgentOSPendingExternalToolRequest|null>
Defined in: packages/agentos/src/api/AgentOS.ts:2717
Returns the pending external-tool pause snapshot for a conversation, if one
was persisted during an actionable TOOL_CALL_REQUEST pause. A pause saved
by a stream an output guardrail blocked is never returned: it is dropped
once the stream's turn ends, and this returns null for it meanwhile.
Parameters
conversationId
string
userId
string
Returns
Promise<AgentOSPendingExternalToolRequest | null>
Implementation of
IAgentOS.getPendingExternalToolRequest
getRuntimeSnapshot()
getRuntimeSnapshot():
Promise<AgentOSRuntimeSnapshot>
Defined in: packages/agentos/src/api/AgentOS.ts:1753
Returns a serializable runtime/devtools snapshot of the initialized AgentOS instance.
Returns
Promise<AgentOSRuntimeSnapshot>
Implementation of
IAgentOS.getRuntimeSnapshot
getToolOrchestrator()
getToolOrchestrator():
IToolOrchestrator
Defined in: packages/agentos/src/api/AgentOS.ts:2031
Returns
IToolOrchestrator
Implementation of
IAgentOS.getToolOrchestrator
getWorkflow()
getWorkflow(
workflowId):Promise<WorkflowInstance|null>
Defined in: packages/agentos/src/api/AgentOS.ts:2587
Retrieves a workflow instance by its identifier.
Parameters
workflowId
string
The workflow instance ID.
Returns
Promise<WorkflowInstance | null>
The workflow instance or null if not found.
Implementation of
IAgentOS.getWorkflow
getWorkflowProgress()
getWorkflowProgress(
workflowId,sinceTimestamp?):Promise<WorkflowProgressUpdate|null>
Defined in: packages/agentos/src/api/AgentOS.ts:2608
Retrieves workflow progress details, including recent events.
Parameters
workflowId
string
The workflow instance ID.
sinceTimestamp?
string
Optional timestamp to get events since.
Returns
Promise<WorkflowProgressUpdate | null>
Progress details or null if not found.
Implementation of
IAgentOS.getWorkflowProgress
handleToolResult()
handleToolResult(
streamId,toolCallId,toolName,toolOutput,isSuccess,errorMessage?):AsyncGenerator<AgentOSResponse,void,undefined>
Defined in: packages/agentos/src/api/AgentOS.ts:2430
Async Generator
Handles the result of an externally executed tool and continues the agent interaction. This method is an asynchronous generator that yields new AgentOSResponse chunks resulting from the GMI processing the tool's output.
It functions similarly to processRequest by:
- Delegating to AgentOSOrchestrator.orchestrateToolResult, which pushes new
chunks to the existing
streamId. - Registering a temporary, request-scoped stream client (bridge) to this
streamId. - Yielding AgentOSResponse chunks received by this bridge.
- Ensuring the bridge client is deregistered.
Parameters
streamId
string
The ID of the existing stream to which the tool result pertains.
toolCallId
string
The ID of the specific tool call being responded to.
toolName
string
The name of the tool that was executed.
toolOutput
any
The output data from the tool execution.
isSuccess
boolean
Indicates whether the tool execution was successful.
errorMessage?
string
An error message if isSuccess is false.
Returns
AsyncGenerator<AgentOSResponse, void, undefined>
An asynchronous generator for new response chunks.
Yields
New response chunks from the agent after processing the tool result.
Throws
If a critical error occurs during setup or if the service is not initialized.
Errors during GMI processing are yielded as AgentOSErrorChunks.
Implementation of
IAgentOS.handleToolResult
handleToolResults()
handleToolResults(
streamId,toolResults):AsyncGenerator<AgentOSResponse,void,undefined>
Defined in: packages/agentos/src/api/AgentOS.ts:2449
Handles a batch of externally executed tool results that belong to the same paused stream and continues the agent interaction once.
Parameters
streamId
string
The original stream ID associated with the paused request.
toolResults
Ordered tool results to apply to the paused turn.
Returns
AsyncGenerator<AgentOSResponse, void, undefined>
An async generator that yields response chunks after processing the tool results.
Throws
If the streamId is invalid or the tool result batch is empty.
The batch continues the pause once, as handleToolResult() does: on an
open stream, a batch for a pause that is being continued already, or with
a result for a call the stream's pause does not hold, yields one error
chunk with the code SYS_INVALID_STATE.