Skip to main content

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() and getLiveSessionState()

Extends​

Constructors​

Constructor​

new SkyboxAgent(ai, sound, scene, callbacks?): SkyboxAgent

Defined in: src/agent/SkyboxAgent.ts:79

Parameters​

ai​

AI

sound​

CoreSound

scene​

Scene

callbacks?​

AgentLifecycleCallbacks

Returns​

SkyboxAgent

Overrides​

Agent.constructor

Properties​

ai​

ai: AI

Defined in: src/agent/Agent.ts:28

Inherited from​

Agent.ai


contextBuilder​

contextBuilder: Context

Defined in: src/agent/Agent.ts:31

Inherited from​

Agent.contextBuilder


isSessionActive​

isSessionActive: boolean = false

Defined in: src/agent/Agent.ts:33

Inherited from​

Agent.isSessionActive


lifecycleCallbacks?​

optional lifecycleCallbacks: AgentLifecycleCallbacks

Defined in: src/agent/Agent.ts:32

Inherited from​

Agent.lifecycleCallbacks


memory​

memory: Memory

Defined in: src/agent/Agent.ts:30

Inherited from​

Agent.memory


tools​

tools: Tool[]

Defined in: src/agent/Agent.ts:29

Inherited from​

Agent.tools


dependencies​

static dependencies: object = {}

Defined in: src/agent/Agent.ts:27

Inherited from​

Agent.dependencies

Methods​

findTool()​

findTool(name): Tool | undefined

Defined in: src/agent/Agent.ts:104

Parameters​

name​

string

Returns​

Tool | undefined

Inherited from​

Agent.findTool


getLiveSessionState()​

getLiveSessionState(): Readonly<LiveSessionState>

Defined in: src/agent/SkyboxAgent.ts:246

Gets the current live session state.

Returns​

Readonly<LiveSessionState>

Read-only session state information


getSessionDuration()​

getSessionDuration(): number | null

Defined in: src/agent/SkyboxAgent.ts:255

Gets the duration of the session in milliseconds.

Returns​

number | null

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​

Agent.getSessionState


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​

Agent.start


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()​

static createToolResponse(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​

ToolResult

The ToolResult from tool execution

Returns​

FunctionResponse

A properly formatted FunctionResponse