HTTP client for the Agent Play web UI: session, snapshot RPC, mutating RPC with sid, and optional SSE subscription.

Authenticates like the CLI: x-node-id (derived node id) and x-node-passw (hashed passphrase material) on every request.

Register automation agents with RemotePlayWorld.addAgent (nodeId is the agent node id; the server stores it as agentId). Call RemotePlayWorld.initAudio before addAgent to have the SDK mint per-agent OpenAI Realtime client secrets and forward them on registration.

Incremental updates: RemotePlayWorld.subscribeWorldState listens for playerChainNotify in SSE data, then fetches each changed leaf via RemotePlayWorld.getPlayerChainNode and merges with mergeSnapshotWithPlayerChainNode.

Human→agent intercom (Assist/Chat from the watch UI) is delivered as SSE world:intercom payloads with status forwarded. Call RemotePlayWorld.subscribeIntercomCommands with playerId or playerIds (one SSE stream; routes forwarded commands by toPlayerId) so your process runs tools and posts intercomResponse via RemotePlayWorld.sendIntercomResponse (the subscription does this when executeTool resolves).

Set logging: "on" to trace forwarded commands for subscribed ids and sendIntercomResponse HTTP results.

Constructors

Methods

  • Parameters

    • payload: {
          error?: null | string;
          fromPlayerId: string;
          intercomAddress?: string;
          kind: "assist" | "chat" | "realtime";
          mainNodeId: string;
          message?: string;
          requestId: string;
          result?: Record<string, unknown>;
          status: "stream" | "completed" | "failed";
          toolName?: string;
          toPlayerId: string;
          ts: string;
      }
      • Optionalerror?: null | string
      • fromPlayerId: string
      • OptionalintercomAddress?: string
      • kind: "assist" | "chat" | "realtime"
      • mainNodeId: string
      • Optionalmessage?: string
      • requestId: string
      • Optionalresult?: Record<string, unknown>
      • status: "stream" | "completed" | "failed"
      • OptionaltoolName?: string
      • toPlayerId: string
      • ts: string

    Returns Promise<void>

  • Subscribes to the session SSE stream and handles forwarded intercom commands whose toPlayerId is in playerId or playerIds, invoking assist/chat execution and posting intercomResponse (completed / failed). Realtime commands mint ephemeral WebRTC credentials in the agent process and return them through intercomResponse. Uses a single SSE connection when playerIds lists multiple automation agents (recommended for several agents in one process). Not invoked automatically by RemotePlayWorld.addAgent.

    Returns {
        close: (() => void);
    }

    • close: (() => void)
        • (): void
        • Returns void

  • Opens the session SSE stream, emits an initial snapshot from RemotePlayWorld.getWorldSnapshot, then on each playerChainNotify merges nodes in deterministic order via RemotePlayWorld.getPlayerChainNode.

    Parameters

    • callbacks: {
          onError?: ((err: Error) => void);
          onIntercomEvent?: ((payload: {
              channelKey?: string;
              command?: {
                  args?: Record<string, unknown>;
                  fromPlayerId: string;
                  intercomAddress?: string;
                  kind: "assist" | "chat" | "realtime";
                  mainNodeId: string;
                  requestId: string;
                  text?: string;
                  toolName?: string;
                  toPlayerId: string;
              };
              error?: null | string;
              fromPlayerId: string;
              intercomAddress?: string;
              kind: "assist" | "chat" | "realtime";
              mainNodeId: string;
              message?: string;
              requestId: string;
              result?: Record<string, unknown>;
              status:
                  | "started"
                  | "stream"
                  | "completed"
                  | "failed"
                  | "forwarded";
              toolName?: string;
              toPlayerId: string;
              ts: string;
          }) => void);
          onSnapshot: ((snapshot: AgentPlaySnapshot) => void);
      }
      • OptionalonError?: ((err: Error) => void)
          • (err): void
          • Parameters

            • err: Error

            Returns void

      • OptionalonIntercomEvent?: ((payload: {
            channelKey?: string;
            command?: {
                args?: Record<string, unknown>;
                fromPlayerId: string;
                intercomAddress?: string;
                kind: "assist" | "chat" | "realtime";
                mainNodeId: string;
                requestId: string;
                text?: string;
                toolName?: string;
                toPlayerId: string;
            };
            error?: null | string;
            fromPlayerId: string;
            intercomAddress?: string;
            kind: "assist" | "chat" | "realtime";
            mainNodeId: string;
            message?: string;
            requestId: string;
            result?: Record<string, unknown>;
            status:
                | "started"
                | "stream"
                | "completed"
                | "failed"
                | "forwarded";
            toolName?: string;
            toPlayerId: string;
            ts: string;
        }) => void)
          • (payload): void
          • Parameters

            • payload: {
                  channelKey?: string;
                  command?: {
                      args?: Record<string, unknown>;
                      fromPlayerId: string;
                      intercomAddress?: string;
                      kind: "assist" | "chat" | "realtime";
                      mainNodeId: string;
                      requestId: string;
                      text?: string;
                      toolName?: string;
                      toPlayerId: string;
                  };
                  error?: null | string;
                  fromPlayerId: string;
                  intercomAddress?: string;
                  kind: "assist" | "chat" | "realtime";
                  mainNodeId: string;
                  message?: string;
                  requestId: string;
                  result?: Record<string, unknown>;
                  status:
                      | "started"
                      | "stream"
                      | "completed"
                      | "failed"
                      | "forwarded";
                  toolName?: string;
                  toPlayerId: string;
                  ts: string;
              }
              • OptionalchannelKey?: string
              • Optionalcommand?: {
                    args?: Record<string, unknown>;
                    fromPlayerId: string;
                    intercomAddress?: string;
                    kind: "assist" | "chat" | "realtime";
                    mainNodeId: string;
                    requestId: string;
                    text?: string;
                    toolName?: string;
                    toPlayerId: string;
                }
                • Optionalargs?: Record<string, unknown>
                • fromPlayerId: string
                • OptionalintercomAddress?: string
                • kind: "assist" | "chat" | "realtime"
                • mainNodeId: string
                • requestId: string
                • Optionaltext?: string
                • OptionaltoolName?: string
                • toPlayerId: string
              • Optionalerror?: null | string
              • fromPlayerId: string
              • OptionalintercomAddress?: string
              • kind: "assist" | "chat" | "realtime"
              • mainNodeId: string
              • Optionalmessage?: string
              • requestId: string
              • Optionalresult?: Record<string, unknown>
              • status:
                    | "started"
                    | "stream"
                    | "completed"
                    | "failed"
                    | "forwarded"
              • OptionaltoolName?: string
              • toPlayerId: string
              • ts: string

            Returns void

      • onSnapshot: ((snapshot: AgentPlaySnapshot) => void)

    Returns {
        close: (() => void);
    }

    • close: (() => void)
        • (): void
        • Returns void