@openape/ape-agent 2.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Patrick Hofmann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # `@openape/ape-agent`
2
+
3
+ The OpenApe agent runtime. One process per spawned agent. Hosts the LLM
4
+ loop (tools + per-thread memory + cron tasks) and proxies chat messages
5
+ to/from `chat.openape.ai` on the agent's behalf.
6
+
7
+ Renamed from `@openape/chat-bridge` in v2.0.0 — the old name was an
8
+ implementation leak ("bridge" suggested a dumb pipe, but the package
9
+ hosts the whole agent runtime). The `openape-chat-bridge` binary still
10
+ ships as an alias so existing pm2 ecosystem.config.js files keep working.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm i -g @openape/ape-agent
16
+ ```
17
+
18
+ The `apes agents spawn --bridge` workflow expects `ape-agent`, `apes`,
19
+ and `node` on PATH — install them globally on the host once, not per
20
+ agent.
21
+
22
+ ## What it does
23
+
24
+ - WebSocket-connect to `chat.openape.ai` as the agent identity
25
+ (token from `~/.config/apes/auth.json`)
26
+ - For each inbound message, open or reuse a `ThreadSession`
27
+ - The session runs `runLoop` from `@openape/apes`:
28
+ - Sends `messages + tools[] + tool_choice: 'auto'` to the LiteLLM proxy
29
+ - Executes `tool_calls` locally (time, http, file, tasks, mail …)
30
+ - Streams text deltas back by PATCHing the chat placeholder message
31
+ - Cron tasks (`agent.json.tasks[]`) fire on schedule through the
32
+ same loop, no per-turn user message
33
+
34
+ Tools and system prompt are read from `~/.openape/agent/agent.json`,
35
+ written by `apes agents sync` from `troop.openape.ai`. Owner-side edits
36
+ in the troop UI take effect on the next sync, no restart needed.
37
+
38
+ ## Configuration (`~/Library/Application Support/openape/bridge/.env`)
39
+
40
+ Written by `apes agents spawn --bridge`. Required:
41
+
42
+ | Variable | Purpose |
43
+ |---|---|
44
+ | `LITELLM_API_KEY` | Master key for the local LiteLLM proxy |
45
+ | `LITELLM_BASE_URL` | Default: `http://127.0.0.1:4000/v1` |
46
+ | `APE_CHAT_BRIDGE_MODEL` | Model name as the proxy knows it (e.g. `gpt-5.4`) |
47
+
48
+ Optional:
49
+
50
+ | Variable | Purpose |
51
+ |---|---|
52
+ | `APE_CHAT_BRIDGE_MAX_STEPS` | Per-turn step cap (default 10) |
53
+ | `APE_CHAT_BRIDGE_ROOM` | Restrict to a single room (default: all) |
54
+ | `APE_CHAT_BRIDGE_SYSTEM_PROMPT` | Fallback when `agent.json` lacks one |
55
+ | `OPENAPE_OWNER_EMAIL` | Defense-in-depth owner identity |
56
+
57
+ ## Logs
58
+
59
+ pm2 puts them under the agent user's `~/.pm2/logs/`. Boot line:
60
+
61
+ ```
62
+ bridge starting — agent=<email> owner=<email> apes=<bin> model=<m> tools=[<...>] max_steps=<n> room=<filter>
63
+ ```
64
+
65
+ Per-turn:
66
+
67
+ ```
68
+ [<room>/<thread>] in: <user message>
69
+ [<room>/<thread>] tool_call: time.now
70
+ [<room>/<thread>] tool_result: time.now
71
+ ```
72
+
73
+ No `tool_call` log line on a "Wie spät ist es?" turn is the canonical
74
+ fingerprint that `tools[]` was empty when the API call left the agent —
75
+ agent.json missing or stale, or the agent is on the pre-2.0 binary that
76
+ didn't read agent.json.
77
+
78
+ ## Build (monorepo)
79
+
80
+ ```bash
81
+ pnpm install --filter @openape/ape-agent...
82
+ pnpm --filter @openape/ape-agent build
83
+ node apps/openape-ape-agent/dist/bridge.mjs # foreground
84
+ ```