@borgee/agents-host 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -91
- package/dist/agents-host.d.ts +1 -0
- package/dist/agents-host.js +5 -0
- package/dist/chat/sdk-chat-control-plane.js +1 -0
- package/dist/cli-args.js +13 -13
- package/dist/cli.js +0 -0
- package/dist/types.d.ts +1 -0
- package/package.json +4 -24
package/README.md
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
# @borgee/agents-host
|
|
2
|
-
|
|
3
|
-
Minimal local runtime host: connects a local **Claude Code CLI** (`claude`) or
|
|
4
|
-
**GitHub Copilot CLI** (`copilot`) process to a single Borgee agent over
|
|
5
|
-
[`@borgee/plugin-sdk`](../../sdk/plugin-ts) — the same BPP (`/ws/plugin`)
|
|
6
|
-
protocol the official OpenClaw plugin uses.
|
|
7
|
-
|
|
8
|
-
## What this is (and isn't)
|
|
9
|
-
|
|
10
|
-
This package is intentionally the *smallest* slice that proves the full loop:
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
Borgee channel message
|
|
14
|
-
→ /ws/plugin (BPP)
|
|
15
|
-
→ @borgee/plugin-sdk
|
|
16
|
-
→ AgentsHost.handleMessage
|
|
17
|
-
→ local `claude`/`copilot` CLI subprocess
|
|
18
|
-
→ BPP reply
|
|
19
|
-
→ Borgee channel
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
**In scope:** one agent per process, mention-only gating (with a DM bypass),
|
|
23
|
-
per-channel conversation memory via each CLI's own native session resume
|
|
24
|
-
(Claude `--resume`, Copilot `--session-id`), and dispatching to a local CLI
|
|
25
|
-
provider.
|
|
26
|
-
|
|
27
|
-
**Out of scope** (see the larger `feat/multi-agent-runtime-host` work for
|
|
28
|
-
these): remote command execution / shell dispatch, node provisioning,
|
|
29
|
-
multi-agent discovery/sync, systemd service install, and scheduled/periodic
|
|
30
|
-
prompts. To run several agents, run several processes with different
|
|
31
|
-
`BORGEE_AGENT_API_KEY` values.
|
|
32
|
-
|
|
33
|
-
## Setup
|
|
34
|
-
|
|
35
|
-
1. In the Borgee web UI, create an Agent and reveal its API key.
|
|
36
|
-
2. Install the Claude Code CLI (`claude`) or GitHub Copilot CLI (`copilot`)
|
|
37
|
-
locally and make sure it works standalone.
|
|
38
|
-
3. Run this package with the environment variables below.
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
BORGEE_BASE_URL=https://your-borgee-server \
|
|
42
|
-
BORGEE_AGENT_API_KEY=bgr_xxxxxxxx \
|
|
43
|
-
BORGEE_AGENT_NAME="My Agent" \
|
|
44
|
-
RUNTIME_PROVIDER=claude \
|
|
45
|
-
pnpm --filter @borgee/agents-host dev
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Environment variables
|
|
49
|
-
|
|
50
|
-
| Variable | Required | Default | Description |
|
|
51
|
-
| --- | --- | --- | --- |
|
|
52
|
-
| `BORGEE_BASE_URL` | yes | — | Borgee server base URL (e.g. `https://borgee.example.com`) |
|
|
53
|
-
| `BORGEE_AGENT_API_KEY` | yes | — | The agent's API key, revealed from the web UI |
|
|
54
|
-
| `BORGEE_AGENT_NAME` | no | `Assistant` | Display name used for mention matching and prompts |
|
|
55
|
-
| `RUNTIME_PROVIDER` | no | `claude` | `claude` or `copilot` |
|
|
56
|
-
| `CLAUDE_COMMAND` / `CLAUDE_ARGS` | no | `claude` / `--print` | Local Claude CLI command + args |
|
|
57
|
-
| `COPILOT_COMMAND` / `COPILOT_ARGS` | no | `copilot` / `-s --no-color --allow-all-tools --output-format text` | Local Copilot CLI command + args |
|
|
58
|
-
| `RESPOND_ON_MENTION_ONLY` | no | `true` | If `true`, only replies in non-DM channels when @mentioned; DMs always get a reply |
|
|
59
|
-
|
|
60
|
-
## Conversation memory
|
|
61
|
-
|
|
62
|
-
Each Borgee channel is mapped 1:1 to a native CLI session, keyed by a
|
|
63
|
-
generated UUID kept in memory for the process's lifetime:
|
|
64
|
-
|
|
65
|
-
- **Claude**: first turn for a channel uses `--session-id <uuid>`; every
|
|
66
|
-
turn after uses `-r/--resume <uuid>` (Claude treats these as distinct
|
|
67
|
-
operations).
|
|
68
|
-
- **Copilot**: every turn uses `--session-id=<uuid>` — Copilot's CLI treats
|
|
69
|
-
that flag as create-or-resume for the same UUID.
|
|
70
|
-
|
|
71
|
-
There is no separate history/context store on our side; if the runtime host
|
|
72
|
-
process restarts, each channel starts a fresh CLI session (no session-id
|
|
73
|
-
persistence across restarts in this minimal version).
|
|
74
|
-
|
|
75
|
-
## Running
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
pnpm --filter @borgee/agents-host dev # tsx, no build step
|
|
79
|
-
pnpm --filter @borgee/agents-host build # tsc -> dist/
|
|
80
|
-
pnpm --filter @borgee/agents-host start # node dist/index.js
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
There is no systemd/service installer here — run it as a plain foreground
|
|
84
|
-
process (or wrap it with your own process manager) and stop it with
|
|
85
|
-
`Ctrl+C`/`SIGTERM`.
|
|
86
|
-
|
|
87
|
-
## Testing
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
pnpm --filter @borgee/agents-host test
|
|
91
|
-
```
|
|
1
|
+
# @borgee/agents-host
|
|
2
|
+
|
|
3
|
+
Minimal local runtime host: connects a local **Claude Code CLI** (`claude`) or
|
|
4
|
+
**GitHub Copilot CLI** (`copilot`) process to a single Borgee agent over
|
|
5
|
+
[`@borgee/plugin-sdk`](../../sdk/plugin-ts) — the same BPP (`/ws/plugin`)
|
|
6
|
+
protocol the official OpenClaw plugin uses.
|
|
7
|
+
|
|
8
|
+
## What this is (and isn't)
|
|
9
|
+
|
|
10
|
+
This package is intentionally the *smallest* slice that proves the full loop:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Borgee channel message
|
|
14
|
+
→ /ws/plugin (BPP)
|
|
15
|
+
→ @borgee/plugin-sdk
|
|
16
|
+
→ AgentsHost.handleMessage
|
|
17
|
+
→ local `claude`/`copilot` CLI subprocess
|
|
18
|
+
→ BPP reply
|
|
19
|
+
→ Borgee channel
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**In scope:** one agent per process, mention-only gating (with a DM bypass),
|
|
23
|
+
per-channel conversation memory via each CLI's own native session resume
|
|
24
|
+
(Claude `--resume`, Copilot `--session-id`), and dispatching to a local CLI
|
|
25
|
+
provider.
|
|
26
|
+
|
|
27
|
+
**Out of scope** (see the larger `feat/multi-agent-runtime-host` work for
|
|
28
|
+
these): remote command execution / shell dispatch, node provisioning,
|
|
29
|
+
multi-agent discovery/sync, systemd service install, and scheduled/periodic
|
|
30
|
+
prompts. To run several agents, run several processes with different
|
|
31
|
+
`BORGEE_AGENT_API_KEY` values.
|
|
32
|
+
|
|
33
|
+
## Setup
|
|
34
|
+
|
|
35
|
+
1. In the Borgee web UI, create an Agent and reveal its API key.
|
|
36
|
+
2. Install the Claude Code CLI (`claude`) or GitHub Copilot CLI (`copilot`)
|
|
37
|
+
locally and make sure it works standalone.
|
|
38
|
+
3. Run this package with the environment variables below.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
BORGEE_BASE_URL=https://your-borgee-server \
|
|
42
|
+
BORGEE_AGENT_API_KEY=bgr_xxxxxxxx \
|
|
43
|
+
BORGEE_AGENT_NAME="My Agent" \
|
|
44
|
+
RUNTIME_PROVIDER=claude \
|
|
45
|
+
pnpm --filter @borgee/agents-host dev
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Environment variables
|
|
49
|
+
|
|
50
|
+
| Variable | Required | Default | Description |
|
|
51
|
+
| --- | --- | --- | --- |
|
|
52
|
+
| `BORGEE_BASE_URL` | yes | — | Borgee server base URL (e.g. `https://borgee.example.com`) |
|
|
53
|
+
| `BORGEE_AGENT_API_KEY` | yes | — | The agent's API key, revealed from the web UI |
|
|
54
|
+
| `BORGEE_AGENT_NAME` | no | `Assistant` | Display name used for mention matching and prompts |
|
|
55
|
+
| `RUNTIME_PROVIDER` | no | `claude` | `claude` or `copilot` |
|
|
56
|
+
| `CLAUDE_COMMAND` / `CLAUDE_ARGS` | no | `claude` / `--print` | Local Claude CLI command + args |
|
|
57
|
+
| `COPILOT_COMMAND` / `COPILOT_ARGS` | no | `copilot` / `-s --no-color --allow-all-tools --output-format text` | Local Copilot CLI command + args |
|
|
58
|
+
| `RESPOND_ON_MENTION_ONLY` | no | `true` | If `true`, only replies in non-DM channels when @mentioned; DMs always get a reply |
|
|
59
|
+
|
|
60
|
+
## Conversation memory
|
|
61
|
+
|
|
62
|
+
Each Borgee channel is mapped 1:1 to a native CLI session, keyed by a
|
|
63
|
+
generated UUID kept in memory for the process's lifetime:
|
|
64
|
+
|
|
65
|
+
- **Claude**: first turn for a channel uses `--session-id <uuid>`; every
|
|
66
|
+
turn after uses `-r/--resume <uuid>` (Claude treats these as distinct
|
|
67
|
+
operations).
|
|
68
|
+
- **Copilot**: every turn uses `--session-id=<uuid>` — Copilot's CLI treats
|
|
69
|
+
that flag as create-or-resume for the same UUID.
|
|
70
|
+
|
|
71
|
+
There is no separate history/context store on our side; if the runtime host
|
|
72
|
+
process restarts, each channel starts a fresh CLI session (no session-id
|
|
73
|
+
persistence across restarts in this minimal version).
|
|
74
|
+
|
|
75
|
+
## Running
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pnpm --filter @borgee/agents-host dev # tsx, no build step
|
|
79
|
+
pnpm --filter @borgee/agents-host build # tsc -> dist/
|
|
80
|
+
pnpm --filter @borgee/agents-host start # node dist/index.js
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
There is no systemd/service installer here — run it as a plain foreground
|
|
84
|
+
process (or wrap it with your own process manager) and stop it with
|
|
85
|
+
`Ctrl+C`/`SIGTERM`.
|
|
86
|
+
|
|
87
|
+
## Testing
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pnpm --filter @borgee/agents-host test
|
|
91
|
+
```
|
package/dist/agents-host.d.ts
CHANGED
package/dist/agents-host.js
CHANGED
|
@@ -102,6 +102,11 @@ export class AgentsHost {
|
|
|
102
102
|
if (message.type === 'mention') {
|
|
103
103
|
return true;
|
|
104
104
|
}
|
|
105
|
+
if (Array.isArray(message.mentions) && this.selfAgentId) {
|
|
106
|
+
if (message.mentions.some((mention) => mention === this.selfAgentId)) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
105
110
|
return this.config.agent.agentName.trim().length > 0
|
|
106
111
|
&& content.toLowerCase().includes(this.config.agent.agentName.toLowerCase());
|
|
107
112
|
}
|
|
@@ -65,6 +65,7 @@ export function mapInboundToChannelMessage(event) {
|
|
|
65
65
|
sender_id: event.message?.authorId ?? event.reaction?.userId,
|
|
66
66
|
content: event.message?.body,
|
|
67
67
|
body: event.message?.body,
|
|
68
|
+
mentions: event.message?.mentions,
|
|
68
69
|
content_type: event.message?.contentType,
|
|
69
70
|
created_at: event.createdAt,
|
|
70
71
|
};
|
package/dist/cli-args.js
CHANGED
|
@@ -52,17 +52,17 @@ export function parseStartArgs(argv) {
|
|
|
52
52
|
throw new CliUsageError(`Unexpected argument: ${extra[0]}`);
|
|
53
53
|
return { serverUrl, apiKey, env };
|
|
54
54
|
}
|
|
55
|
-
export const USAGE = `Usage: agents-host start <serverUrl> <apiKey> [options]
|
|
56
|
-
|
|
57
|
-
Options:
|
|
58
|
-
--name <name> Display name (default: Assistant)
|
|
59
|
-
--provider <claude|copilot> Runtime provider (default: claude)
|
|
60
|
-
--claude-command <cmd> Local Claude CLI command (default: claude)
|
|
61
|
-
--claude-args <args> Local Claude CLI args (default: --print)
|
|
62
|
-
--copilot-command <cmd> Local Copilot CLI command (default: copilot)
|
|
63
|
-
--copilot-args <args> Local Copilot CLI args
|
|
64
|
-
--mention-only <true|false> Reply only when @mentioned outside DMs (default: true)
|
|
65
|
-
|
|
66
|
-
Example:
|
|
67
|
-
agents-host start https://borgee.example.com bgr_xxxxxxxx --provider copilot
|
|
55
|
+
export const USAGE = `Usage: agents-host start <serverUrl> <apiKey> [options]
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
--name <name> Display name (default: Assistant)
|
|
59
|
+
--provider <claude|copilot> Runtime provider (default: claude)
|
|
60
|
+
--claude-command <cmd> Local Claude CLI command (default: claude)
|
|
61
|
+
--claude-args <args> Local Claude CLI args (default: --print)
|
|
62
|
+
--copilot-command <cmd> Local Copilot CLI command (default: copilot)
|
|
63
|
+
--copilot-args <args> Local Copilot CLI args
|
|
64
|
+
--mention-only <true|false> Reply only when @mentioned outside DMs (default: true)
|
|
65
|
+
|
|
66
|
+
Example:
|
|
67
|
+
agents-host start https://borgee.example.com bgr_xxxxxxxx --provider copilot
|
|
68
68
|
`;
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@borgee/agents-host",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,27 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/cross-spawn": "^6.0.6",
|
|
29
|
-
"@types/node": "^24.3.0",
|
|
30
|
-
"tsx": "^4.20.5",
|
|
31
|
-
"typescript": "^5.9.3",
|
|
32
|
-
"vitest": "^4.1.5"
|
|
33
|
-
},
|
|
34
|
-
"scripts": {
|
|
35
|
-
"predev": "pnpm --filter @borgee/plugin-sdk build",
|
|
36
|
-
"dev": "tsx src/index.ts",
|
|
37
|
-
"precli": "pnpm --filter @borgee/plugin-sdk build",
|
|
38
|
-
"cli": "tsx src/cli.ts",
|
|
39
|
-
"prestart": "pnpm --filter @borgee/plugin-sdk build",
|
|
40
|
-
"start": "node dist/index.js",
|
|
41
|
-
"prebuild": "pnpm --filter @borgee/plugin-sdk build",
|
|
42
|
-
"build": "tsc",
|
|
43
|
-
"typecheck": "tsc --noEmit",
|
|
44
|
-
"pretest": "pnpm --filter @borgee/plugin-sdk build",
|
|
45
|
-
"test": "vitest run"
|
|
24
|
+
"@borgee/plugin-sdk": "0.1.0",
|
|
25
|
+
"cross-spawn": "^7.0.6"
|
|
46
26
|
}
|
|
47
|
-
}
|
|
27
|
+
}
|