const daemonBase = "http://127.0.0.1:4000";
const token = "<admin-or-scoped-token>";
const sessionResponse = await fetch(`${daemonBase}/v1/sessions`, {
method: "POST",
headers: {
authorization: `Bearer ${token}`,
"content-type": "application/json",
},
body: JSON.stringify({ session_id: "demo" }),
});
if (!sessionResponse.ok && sessionResponse.status !== 409) {
throw new Error(await sessionResponse.text());
}
const response = await fetch(`${daemonBase}/v1/sessions/demo/runs`, {
method: "POST",
headers: {
authorization: `Bearer ${token}`,
"content-type": "application/json",
},
body: JSON.stringify({
input_items: [
{
type: "text",
text: "Reply with exactly WEB_OK.",
},
],
source_plugin: "web",
source_kind: "browser",
actor_id: "operator",
}),
});
if (!response.ok) {
throw new Error(await response.text());
}
const run = await response.json();