Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
npm exec --yes --package=@anthropic-ai/claude-code@2.1.291 -- claude plugin validate ./plugins/openorange --strict
npm exec --yes --package=@anthropic-ai/claude-code@2.1.291 -- claude plugin validate . --strict
# The Buzz Desktop plugin against a stub ACP agent in place of `oo acp`: no Sunport, no network.
# The Buzz Desktop plugin against stubs in place of `oo acp` and `oo buzz hosted`: no Sunport, no network.
buzz-plugin:
name: Buzz plugin
runs-on: ubuntu-24.04
Expand Down
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,11 @@ on the Bot's computer. Grok Bot's computer can also run the `oo` CLI
## Buzz Desktop

The Buzz plugin is in [`packages/buzz/openorange-buzz`](packages/buzz/openorange-buzz).
It makes OpenOrange an agent type in Buzz Desktop: mention your agent in a
It makes OpenOrange agent types in Buzz Desktop: mention your agent in a
thread and it answers there from your Sunport, each thread one continuing
conversation. Buzz passes the messages to `oo` on your computer, which reaches
your Sunport as you.
conversation. With **OpenOrange**, Buzz passes the messages to `oo` on your
computer, which reaches your Sunport as you, while Buzz Desktop is open. With
**OpenOrange (always on)**, your Sunport answers in Buzz itself (below).

You need Buzz Desktop and, on the same computer, the `oo` CLI with `oo login`
done ([CLI guide](usage/references/cli.md)).
Expand All @@ -211,12 +212,29 @@ done ([CLI guide](usage/references/cli.md)).
Or, in Buzz, open **Settings › Plugins › Manage plugins**, choose **Add**, and
enter the repository `2bb-dev/openorange-integrations` and the folder
`packages/buzz/openorange-buzz`. Buzz shows the access the plugin asks for,
starting `oo acp`; choose **Install plugin**.
starting `oo acp` and `oo buzz hosted`; choose **Install plugin**.
2. Open **Agents › New agent › Custom › Harness › OpenOrange**. The agent is
Clem on your Sunport.
3. Mention the agent in a thread. It answers only your own mentions, while Buzz
Desktop is open.

### Always on

An always-on agent is Clem on your Sunport, which runs it in Buzz itself: it
answers even while Buzz Desktop is closed and your computer is off. It needs a
current Sunport. The plugin and `oo` above set it up; it answers without them.

1. Open **Agents › New agent › Custom › Harness › OpenOrange (always on)**
(under Remote), name the agent and create it.
2. Your browser opens once for you to sign in to Buzz. If the setup stops
before it finishes, choose **Finish setup** on the agent.
3. Add the agent to a channel in Buzz and mention it there. It answers only
your own mentions.

Buzz asks for a new sign-in from time to time. Until you give it one, the agent
doesn't answer: run `oo buzz renew` in a terminal, which opens your browser to
sign in again.

## The packages

The Claude, OpenAI and Grok Bot packages use the same [MCP guide](usage/references/mcp.md) and
Expand Down
17 changes: 17 additions & 0 deletions packages/buzz/openorange-buzz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,20 @@ conversation.
and **OpenOrange**.
3. Mention the agent in a thread. It answers your own mentions while Buzz
Desktop is open.

## Always on

Choose the harness **OpenOrange (always on)** instead, under Remote, and your
Sunport runs the agent in Buzz itself: it answers even while Buzz Desktop is
closed and this computer is off. It needs a current Sunport.

1. With `oo` installed and signed in as above, create the agent with the
harness **OpenOrange (always on)**.
2. Your browser opens once for you to sign in to Buzz. If the setup stops
before it finishes, choose **Finish setup** on the agent.
3. Add the agent to a channel in Buzz and mention it there. It answers only
your own mentions.

Buzz asks for a new sign-in from time to time. Until you give it one, the agent
doesn't answer: run `oo buzz renew` in a terminal, which opens your browser to
sign in again.
10 changes: 9 additions & 1 deletion packages/buzz/openorange-buzz/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "openorange.agents",
"name": "OpenOrange",
"apiVersion": 1,
"description": "Talk to your OpenOrange agents, such as Clem, in Buzz. They keep running on your Sunport; this computer only passes messages.",
"description": "Talk to your OpenOrange agents, such as Clem, in Buzz. They run on your Sunport and answer through this computer while Buzz Desktop is open, or always on from your Sunport.",
"host": {
"processes": [
{
Expand All @@ -11,6 +11,14 @@
"args": [
"acp"
]
},
{
"id": "oo-buzz",
"program": "oo",
"args": [
"buzz",
"hosted"
]
}
]
}
Expand Down
96 changes: 91 additions & 5 deletions packages/buzz/openorange-buzz/plugin.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// OpenOrange in Buzz: an agent type whose agents are the owner's agents on their Sunport, Clem unless the agent's
// config names another. Buzz keeps the agent's identity and posts its replies. Each thread the agent is mentioned in is
// one continuing conversation with the Sunport's agent, reached through `oo acp` (the Agent Client Protocol on stdin
// and stdout), which signs in as the person who ran `oo login`. Nothing of the agent runs on this computer, and no key
// of Buzz's ever reaches `oo`.
// OpenOrange in Buzz: two agent types whose agents are the owner's agents on their Sunport.
//
// "OpenOrange" (`agent`): Clem unless the agent's config names another. Buzz keeps the agent's identity and posts its
// replies. Each thread the agent is mentioned in is one continuing conversation with the Sunport's agent, reached
// through `oo acp` (the Agent Client Protocol on stdin and stdout), which signs in as the person who ran `oo login`.
// Nothing of the agent runs on this computer, and no key of Buzz's ever reaches `oo`.
//
// "OpenOrange (always on)" (`hosted`): an agent Buzz calls hosted. The owner's Sunport makes and keeps its key, hears
// the owner's mentions and posts the replies itself, so it answers while this computer is off. This computer only
// makes, sets up, renames and removes it, each step one `oo buzz hosted <step>`.
export const inject = ["agents", "host"];

const TYPE_ID = "agent";
const HOSTED_TYPE_ID = "hosted";
/** The Sunport agent a Buzz agent is, when its config names none. */
const DEFAULT_AGENT = "clem";
const SAVED = "openorange.agents.sessions.v1";
Expand Down Expand Up @@ -39,6 +45,7 @@ export function apply(ctx) {
return next;
},
});
agents.register(hostedType(host));
}

/** The Sunport agent a Buzz agent's config names: an id or alias `oo acp --agent` takes. */
Expand Down Expand Up @@ -317,3 +324,82 @@ function createSaved(storage) {
},
};
}

/** The always-on type: Clem on the owner's Sunport, which keeps the agent's key and answers in Buzz itself. Buzz runs
* these steps one at a time for an agent and asks a failed one again, so the Sunport makes each safe to repeat. None
* has a deadline: activate waits while the owner signs in to Buzz in their browser. */
function hostedType(host) {
return {
id: HOSTED_TYPE_ID,
title: "OpenOrange (always on)",
description:
"Clem on your OpenOrange Sunport, which runs it, so it answers your mentions even while this computer is off. oo on this computer sets it up with one sign-in to Buzz.",
defaults: () => ({ config: {} }),
remote: {
async provision({ name, picture, community, signal }) {
const { pubkey } = await hosted(host, "provision", { community, name, ...(picture && { picture }) }, signal);
// The picture it was made with, which Buzz keeps for a retried creation.
return { pubkey, ...(picture && { picture }) };
},
async activate({ pubkey, community, name, auth, signal }) {
await hosted(host, "activate", { pubkey, community, name, auth }, signal);
},
async profile({ pubkey, community, name, picture, signal }) {
await hosted(host, "profile", { pubkey, community, name, ...(picture && { picture }) }, signal);
},
async remove({ pubkey, community, signal }) {
await hosted(host, "remove", { pubkey, community }, signal);
},
async interrupt({ pubkey, community, channelId, threadRootId, signal }) {
const { stopped } = await hosted(host, "interrupt", { pubkey, community, channel: channelId, root: threadRootId }, signal);
return stopped === true;
},
},
};
}

/** One `oo buzz hosted <step>`: the step's input as a JSON object on its stdin, its answer one on its stdout, and on
* failure the reason as its last line on stderr. Ended when Buzz stops waiting for it. */
async function hosted(host, step, input, signal) {
// Buzz no longer waits: start nothing, so activate opens no browser.
signal.throwIfAborted();
let answer = "";
let errors = "";
let oo;
try {
oo = await host.spawn("oo-buzz", {
args: [step],
onStdout: (data) => void (answer += data),
onStderr: (data) => void (errors = (errors + data).slice(-1200)),
});
} catch (error) {
if (/os error 2|no such file|not found/i.test(String(error?.message ?? error)))
throw new Error(
"The oo command was not found on this computer. Install it from your Sunport (Connect, then Command line), run `oo login`, and try again.",
);
throw error;
}
// An oo that ended before reading its input is answered by its exit; one still running would wait for it forever.
oo.end(JSON.stringify(input)).catch(() => oo.kill());
const code = await new Promise((resolve, reject) => {
const stop = () => {
void oo.kill();
reject(signal.reason);
};
if (signal.aborted) return stop();
signal.addEventListener("abort", stop, { once: true });
oo.exited.then((exit) => {
signal.removeEventListener("abort", stop);
resolve(exit);
}, reject);
});
if (code !== 0) throw new Error(errors.trim().split("\n").pop().trim() || "oo stopped without saying why.");
let result;
try {
result = JSON.parse(answer);
} catch {
// Read as not an answer, below.
}
if (!result || typeof result !== "object") throw new Error("oo's answer could not be read. Update oo with `oo update`, then try again.");
return result;
}
10 changes: 6 additions & 4 deletions scripts/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@
HOST_FILES = {"openai": {"assets/openorange-logo-512.png": "assets/openorange-logo-512.png"}}
# Buzz Desktop installs this folder from the repository as it is, so nothing here generates or builds it: its manifest,
# one self-contained plugin.js and a README. Buzz refuses a manifest with any other key, updates an installed plugin by
# its id, and shows the person the computer access it asks for at install: starting `oo acp`, nothing else.
# its id, and shows the person the computer access it asks for at install: starting `oo acp` (an agent answering while
# Buzz Desktop is open) and `oo buzz hosted` (setting up an always-on one), nothing else.
BUZZ = "packages/buzz/openorange-buzz"
BUZZ_FILES = ("manifest.json", "plugin.js", "README.md")
BUZZ_MANIFEST = {"id", "name", "apiVersion", "description", "discovery", "host"}
BUZZ_HOST = {"processes": [{"id": "oo", "program": "oo", "args": ["acp"]}]}
BUZZ_HOST = {"processes": [{"id": "oo", "program": "oo", "args": ["acp"]},
{"id": "oo-buzz", "program": "oo", "args": ["buzz", "hosted"]}]}
SOURCE_FILES = {
"README.md", "LICENSE", ".gitignore", ".claude-plugin/marketplace.json", ".cursor-plugin/marketplace.json",
"assets/openorange.svg", "assets/openorange-icon-1024.png", "assets/openorange-logo-512.png", "usage/README.md", "usage/SKILL.md", "usage/references/mcp.md",
"usage/references/cli.md", "usage/agent-guide.json", "scripts/package.py", "scripts/live_tools.py", "tests/test_package.py",
"tests/test_buzz_plugin.mjs", "tests/acp_stub.mjs", ".github/workflows/ci.yml",
"tests/test_buzz_plugin.mjs", "tests/acp_stub.mjs", "tests/hosted_stub.mjs", ".github/workflows/ci.yml",
}
# How an agent stays in touch with its Sunport comes from one source in the Layer
# (packages/billing/src/contracts/agent-guide.ts). Its guideJson() export is vendored
Expand Down Expand Up @@ -190,7 +192,7 @@ def check(root):
buzz = json.loads(read_file(root, f"{BUZZ}/manifest.json"))
if (not set(buzz) <= BUZZ_MANIFEST or buzz.get("id") != "openorange.agents" or buzz.get("apiVersion") != 1
or buzz.get("host") != BUZZ_HOST):
raise ValueError("Buzz plugin must keep its id, the manifest keys Buzz accepts and only oo acp")
raise ValueError("Buzz plugin must keep its id, the manifest keys Buzz accepts and only oo acp and oo buzz hosted")
expected.update(f"{BUZZ}/{name}" for name in BUZZ_FILES)
actual = set()
for path in root.rglob("*"):
Expand Down
50 changes: 50 additions & 0 deletions tests/hosted_stub.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// A stand-in for `oo buzz hosted <step>` with no Sunport behind it: the step's input as one JSON object on stdin, its
// answer as one on stdout, or a line of progress and then the reason on stderr and exit 1. Each call (its arguments and
// input) and the agents made are kept in the file named by HOSTED_STUB_STATE, so a test can read them and a later call
// finds the agents an earlier one made: provision answers a repeat with the same agent. HOSTED_STUB='{"<step>": …}'
// changes a step: "wait" (milliseconds before it answers), "hang" (never answers, until it is ended), "fail" (the
// reason it fails with), "exit" (a code it exits with, saying nothing), "answer" (raw text in place of its answer),
// "stopped" (interrupt's answer; true by default).
import { createHash } from "node:crypto";
import { readFileSync, writeFileSync } from "node:fs";

const file = process.env.HOSTED_STUB_STATE;
const args = process.argv.slice(2);
const step = args.at(-1);
const how = JSON.parse(process.env.HOSTED_STUB || "{}")[step] ?? {};
let state;
try {
state = JSON.parse(readFileSync(file, "utf8"));
} catch {
state = { calls: [], agents: {} };
}
const save = () => writeFileSync(file, JSON.stringify(state));

let stdin = "";
process.stdin.setEncoding("utf8");
for await (const data of process.stdin) stdin += data;
const input = JSON.parse(stdin);
state.calls.push({ args, input });
save();

if (how.hang) setInterval(() => undefined, 60_000);
else {
await new Promise((resolve) => setTimeout(resolve, how.wait ?? 0));
if (how.fail) {
process.stderr.write(`Working on ${step}…\n${how.fail}\n`);
process.exit(1);
}
if (how.exit) process.exit(how.exit);
let answer = {};
if (step === "provision") {
const key = `${input.community} ${input.name}`;
state.agents[key] ??= {
id: `agent-${Object.keys(state.agents).length + 1}`,
pubkey: createHash("sha256").update(key).digest("hex"),
};
save();
answer = state.agents[key];
} else if (step === "activate") answer = { state: "active" };
else if (step === "interrupt") answer = { stopped: how.stopped ?? true };
process.stdout.write(how.answer ?? `${JSON.stringify(answer)}\n`);
}
Loading