Class: SkyboxAgent
Defined in: src/agent/SkyboxAgent.ts:72
Skybox Agent for generating 360-degree equirectangular backgrounds through conversation.
Examples
// 1. Enable audio (required for live sessions)
await xb.core.sound.enableAudio();
// 2. Create agent
const agent = new xb.SkyboxAgent(xb.core.ai, xb.core.sound, xb.core.scene);
// 3. Start session
await agent.startLiveSession({
onopen: () => console.log('Session ready'),
onmessage: (msg) => handleMessage(msg),
onclose: () => console.log('Session closed')
});
// 4. Clean up when done
await agent.stopLiveSession();
xb.core.sound.disableAudio();
const agent = new xb.SkyboxAgent(
xb.core.ai,
xb.core.sound,
xb.core.scene,
{
onSessionStart: () => updateUI('active'),
onSessionEnd: () => updateUI('inactive'),
onError: (error) => showError(error)
}
);
Remarks
- Audio must be enabled BEFORE starting live session using
xb.core.sound.enableAudio() - Users are responsible for managing audio lifecycle
- Always call
stopLiveSession()before disabling audio - Session state can be checked using
getSessionState()andgetLiveSessionState()
Extends
Constructors
Constructor
new SkyboxAgent(
ai,sound,scene,callbacks?):SkyboxAgent
Defined in: src/agent/SkyboxAgent.ts:79
Parameters
ai
sound
scene
callbacks?
Returns
SkyboxAgent
Overrides
Properties
ai
ai:
AI
Defined in: src/agent/Agent.ts:28
Inherited from
contextBuilder
contextBuilder:
Context
Defined in: src/agent/Agent.ts:31
Inherited from
isSessionActive
isSessionActive:
boolean=false
Defined in: src/agent/Agent.ts:33
Inherited from
lifecycleCallbacks?
optionallifecycleCallbacks:AgentLifecycleCallbacks
Defined in: src/agent/Agent.ts:32
Inherited from
memory
memory:
Memory
Defined in: src/agent/Agent.ts:30
Inherited from
tools
tools:
Tool[]
Defined in: src/agent/Agent.ts:29
Inherited from
dependencies
staticdependencies:object={}
Defined in: src/agent/Agent.ts:27
Inherited from
Methods
findTool()
findTool(
name):undefined|Tool
Defined in: src/agent/Agent.ts:104
Parameters
name
string
Returns
undefined | Tool
Inherited from
getLiveSessionState()
getLiveSessionState():
Readonly<LiveSessionState>
Defined in: src/agent/SkyboxAgent.ts:246
Gets the current live session state.
Returns
Read-only session state information
getSessionDuration()
getSessionDuration():
null|number
Defined in: src/agent/SkyboxAgent.ts:255
Gets the duration of the session in milliseconds.
Returns
null | number
Duration in ms, or null if session hasn't started
getSessionState()
getSessionState():
object
Defined in: src/agent/Agent.ts:112
Get the current session state.
Returns
object
Object containing session information
isActive
isActive:
boolean
memorySize
memorySize:
number
toolCount
toolCount:
number
Inherited from
sendToolResponse()
sendToolResponse(
response):Promise<void>
Defined in: src/agent/SkyboxAgent.ts:181
Sends tool execution results back to the AI.
Parameters
response
LiveSendToolResponseParameters
The tool response containing function results
Returns
Promise<void>
start()
start(
prompt):Promise<string>
Defined in: src/agent/Agent.ts:53
Starts the agent's reasoning loop with an initial prompt.
Parameters
prompt
string
The initial prompt from the user.
Returns
Promise<string>
The final text response from the agent.
Inherited from
startLiveSession()
startLiveSession(
callbacks?):Promise<void>
Defined in: src/agent/SkyboxAgent.ts:107
Starts a live AI session for real-time conversation.
Parameters
callbacks?
LiveCallbacks
Optional callbacks for session events. Can also be set using ai.setLiveCallbacks()
Returns
Promise<void>
Throws
If AI model is not initialized or live session is not available
Remarks
Audio must be enabled separately using xb.core.sound.enableAudio() before starting the session.
This gives users control over when microphone permissions are requested.
stopLiveSession()
stopLiveSession():
Promise<void>
Defined in: src/agent/SkyboxAgent.ts:138
Stops the live AI session.
Returns
Promise<void>
Remarks
Audio must be disabled separately using xb.core.sound.disableAudio() after stopping the session.
createToolResponse()
staticcreateToolResponse(id,name,result):FunctionResponse
Defined in: src/agent/SkyboxAgent.ts:229
Helper to create a properly formatted tool response from a ToolResult.
Parameters
id
string
The function call ID
name
string
The function name
result
The ToolResult from tool execution
Returns
FunctionResponse
A properly formatted FunctionResponse