Visibility
Control your agent’s UI from code: open or close the prompt, show or hide the widget, or tear it down entirely. Use it to wire the agent into your app’s own controls and lifecycle.
Every call references your Agent API Name, found in Agent Studio → Setup.
Initialize the agent
Section titled “Initialize the agent”foldspace("when", "ready", () => { const agent = foldspace.agent({ /* …common setup… */ }); // Now you can call any of the methods below: // agent.message(...).open().setViewType("WIDGET").hide()...});Open and close
Section titled “Open and close”Open the agent prompt:
foldspace.agent("myproduct-agentic-agent").open();Close the agent prompt:
foldspace.agent("myproduct-agentic-agent").close();Show and hide
Section titled “Show and hide”Show the agent widget:
foldspace.agent("myproduct-agentic-agent").show();Hide the agent widget:
foldspace.agent("myproduct-agentic-agent").hide();Remove
Section titled “Remove”Tear down the agent completely: unmounts the UI, clears its state, and frees resources.
agent("myproduct-agentic-agent").remove();