opencode-apex 0.4.1 → 0.5.1
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/CHANGELOG.md +31 -4
- package/README.md +2 -3
- package/core/config.ts +1 -1
- package/core/daemon-client.ts +3 -26
- package/daemon/main.ts +21 -372
- package/daemon/shared.ts +3 -39
- package/docs/CONFIG.md +1 -1
- package/docs/ENDPOINTS.md +25 -48
- package/endpoints.ts +8 -73
- package/index.ts +4 -4
- package/opencode-apex.jsonc +1 -1
- package/package.json +3 -4
- package/skills/apex-callbacks/SKILL.md +3 -7
- package/skills/apex-endpoints/SKILL.md +46 -62
- package/core/autostart.ts +0 -67
package/CHANGELOG.md
CHANGED
|
@@ -5,13 +5,40 @@ All notable changes to `opencode-apex`. Format based on
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
-
## [0.
|
|
8
|
+
## [0.5.1] — 2026-11-26
|
|
9
9
|
|
|
10
10
|
### Fixed
|
|
11
11
|
|
|
12
|
-
- **Redaction froze OpenCode on long sessions
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
- **Redaction froze OpenCode on long sessions.** The `k8s-secret-data-value` pattern (from
|
|
13
|
+
warden) had an unbounded, ambiguous lookbehind (`\s+` crossing lines, unlimited repetition):
|
|
14
|
+
one pass over a ~500 KB context took ~80 s of CPU in Bun/JSC. Since the `context` hook
|
|
15
|
+
re-redacts the whole history on every request, the server stopped answering `/health`, the
|
|
16
|
+
desktop app killed it, and the busy session resumed into the same freeze on every restart.
|
|
17
|
+
The lookbehind is now bounded (`[ \t]` indentation, up to 16 keys between `data:` and the
|
|
18
|
+
value, lines up to 512 chars): ~80 ms on the same text. It also matches keys with `.` and `-`.
|
|
19
|
+
|
|
20
|
+
## [0.5.0] — 2026-11-25
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
|
|
24
|
+
- **`apex_service` (supervised microservices) and daemon autostart.** They made the apex
|
|
25
|
+
daemon much larger without being needed to receive webhooks or publish a port. What was
|
|
26
|
+
removed:
|
|
27
|
+
- the supervisor: restarts with backoff, adopting processes from a previous daemon, logs,
|
|
28
|
+
and the per-service ingest token;
|
|
29
|
+
- autostart: the crontab or Windows logon task, and its launcher script.
|
|
30
|
+
|
|
31
|
+
The daemon now does two things: OpenTunnel routes and verified webhooks. To expose its own
|
|
32
|
+
microservice, the agent runs it (skill `apex-callbacks`, `run-anywhere.md`) and publishes
|
|
33
|
+
its port with `apex_tunnel`. After a reboot, the daemon comes back when apex loads in any
|
|
34
|
+
project.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- Webhook routes are read straight from the webhook entries instead of being duplicated as
|
|
39
|
+
tunnel entries.
|
|
40
|
+
- The daemon's ports are no longer persisted between runs.
|
|
41
|
+
- A newer plugin simply stops the old daemon and starts its own.
|
|
15
42
|
|
|
16
43
|
## [0.4.0] — 2026-11-25
|
|
17
44
|
|
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ apex is one plugin with six independent modules. Each one can be switched on or
|
|
|
62
62
|
| **Guard** | Meta-permissions per agent, tool and path, with a report of what was attempted and decided. | **off** | [docs/GUARD.md](docs/GUARD.md) |
|
|
63
63
|
| **Browser** *(deprecated)* | Serves OpenCode's `browser.*` tools against an **external** Chromium over CDP. Superseded by OpenCode's [browse](https://opencode.ai/product/browse) for your own browser; kept for a headless or remote Chromium and for `browser.*` performance captures. | **off** | [docs/BROWSER.md](docs/BROWSER.md) |
|
|
64
64
|
| **Temp access** | Allows `external_directory` in OpenCode's temporary directory (`<tmpdir>/opencode`, `/tmp/opencode` on Linux) without asking. OpenCode tells the model to use it but no rule approves it. A deny you configure for that path still wins. | on | — |
|
|
65
|
-
| **Endpoints** | Public URLs through [OpenTunnel](https://opentunnel.xyz) (same device tunnel as OpenCode remote access, own routes)
|
|
65
|
+
| **Endpoints** | Public URLs through [OpenTunnel](https://opentunnel.xyz) (same device tunnel as OpenCode remote access, own routes) and **verified webhooks** (GitHub, Stripe, Slack, HMAC, token) that wake agents without exposing the server password. Optional TTL. Kept by a per-user apex daemon that outlives the plugin; Linux, macOS, Windows, no tunnel CLI. The daemon starts only when a tool is used. | on | [docs/ENDPOINTS.md](docs/ENDPOINTS.md) |
|
|
66
66
|
|
|
67
67
|
Turn modules on or off in `modules`. That is the only switch: there is no `<module>.enabled`.
|
|
68
68
|
|
|
@@ -243,8 +243,7 @@ curl -sS -u "opencode:$PW" -H 'content-type: application/json' \
|
|
|
243
243
|
| `apex_set_callback_url` | events | Sets or clears the server's public URL (tunnel / reverse proxy), for senders on other machines |
|
|
244
244
|
| `apex_webhook` | endpoints | Verified webhook URL (github, stripe, slack, hmac, token) that calls `events.ingest` locally: create / list / delete, TTL |
|
|
245
245
|
| `apex_tunnel` | endpoints | Publishes a local port on an OpenTunnel HTTPS URL: open / list / close, TTL |
|
|
246
|
-
| `
|
|
247
|
-
| `apex_daemon` | endpoints | Daemon status, autostart after reboot (cron `@reboot` / Windows logon task), stop |
|
|
246
|
+
| `apex_daemon` | endpoints | Daemon status and stop |
|
|
248
247
|
| `apex_advisor_decide` | advisor | The advisor agent's only tool: `allow` / `deny` + reason |
|
|
249
248
|
| `apex_guard_report` | guard | Report of what each agent attempted and what was decided |
|
|
250
249
|
| `browser_target` | browser (deprecated, off by default) | Chooses which browser serves `browser.*`: `external` (CDP), `in-app` (desktop app) or `auto` |
|
package/core/config.ts
CHANGED
|
@@ -266,7 +266,7 @@ export const apexConfigSchema = z.object({
|
|
|
266
266
|
browser: z.boolean().optional(),
|
|
267
267
|
// Activado por defecto: external_directory sin preguntar en <tmpdir>/opencode.
|
|
268
268
|
tempAccess: z.boolean().optional(),
|
|
269
|
-
// Activado por defecto: apex_tunnel/webhook/
|
|
269
|
+
// Activado por defecto: apex_tunnel/webhook/daemon (el daemon solo se lanza al usarlas).
|
|
270
270
|
endpoints: z.boolean().optional(),
|
|
271
271
|
})
|
|
272
272
|
.default(() => ({})),
|
package/core/daemon-client.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { spawn } from "node:child_process"
|
|
11
|
-
import { closeSync, existsSync, mkdirSync, openSync, readFileSync
|
|
11
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync } from "node:fs"
|
|
12
12
|
import { fileURLToPath } from "node:url"
|
|
13
13
|
import { daemonPaths, type DaemonInfo, type DaemonPaths, type ServerTarget } from "../daemon/shared.js"
|
|
14
14
|
import type { ServerEndpoint } from "./server-endpoint.js"
|
|
@@ -44,20 +44,6 @@ export function daemonCommand(version: string, execPath = process.execPath, scri
|
|
|
44
44
|
return { command: execPath, args: [script], env }
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/** Lanzador para el autoarranque (crontab @reboot / tarea de Windows), con las rutas de hoy. */
|
|
48
|
-
export function launcherText(version: string, paths: DaemonPaths, platform = process.platform, execPath = process.execPath): string {
|
|
49
|
-
const { command, args, env } = daemonCommand(version, execPath, DAEMON_SCRIPT, paths.home)
|
|
50
|
-
// La identidad de OpenTunnel vive en XDG_DATA_HOME: cron no la hereda.
|
|
51
|
-
if (process.env.XDG_DATA_HOME) env.XDG_DATA_HOME = process.env.XDG_DATA_HOME
|
|
52
|
-
if (platform === "win32") {
|
|
53
|
-
const sets = Object.entries(env).map(([key, value]) => `set "${key}=${value}"`)
|
|
54
|
-
return ["@echo off", ...sets, `"${command}" "${args[0]}" >> "${paths.log}" 2>&1`, ""].join("\r\n")
|
|
55
|
-
}
|
|
56
|
-
const quote = (s: string) => `'${s.replaceAll("'", `'\\''`)}'`
|
|
57
|
-
const exports = Object.entries(env).map(([key, value]) => `export ${key}=${quote(value)}`)
|
|
58
|
-
return ["#!/bin/sh", ...exports, `exec ${quote(command)} ${quote(args[0]!)} >> ${quote(paths.log)} 2>&1`, ""].join("\n")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
47
|
function readInfo(paths: DaemonPaths): DaemonInfo | null {
|
|
62
48
|
try {
|
|
63
49
|
return JSON.parse(readFileSync(paths.info, "utf8")) as DaemonInfo
|
|
@@ -113,7 +99,7 @@ export async function ensureDaemon(options: EnsureOptions): Promise<DaemonClient
|
|
|
113
99
|
let info = readInfo(paths)
|
|
114
100
|
let health = await healthy(info)
|
|
115
101
|
if (health && info && newerVersion(options.version, health.version)) {
|
|
116
|
-
// Plugin actualizado: el daemon viejo
|
|
102
|
+
// Plugin actualizado: el daemon viejo se cierra y arranca el nuevo.
|
|
117
103
|
await call(info, "POST", "/v1/shutdown", {}).catch(() => undefined)
|
|
118
104
|
for (let i = 0; i < 50 && (await healthy(info)); i++) await sleep(100)
|
|
119
105
|
health = null
|
|
@@ -122,7 +108,6 @@ export async function ensureDaemon(options: EnsureOptions): Promise<DaemonClient
|
|
|
122
108
|
if (!options.spawn) return null
|
|
123
109
|
|
|
124
110
|
mkdirSync(paths.home, { recursive: true, mode: 0o700 })
|
|
125
|
-
writeLauncher(options.version, paths)
|
|
126
111
|
const { command, args, env } = daemonCommand(options.version, process.execPath, DAEMON_SCRIPT, paths.home)
|
|
127
112
|
const fd = openSync(paths.log, "a", 0o600)
|
|
128
113
|
try {
|
|
@@ -150,20 +135,12 @@ function client(info: DaemonInfo): DaemonClient {
|
|
|
150
135
|
return { info, request: (method, path, body) => call(info, method, path, body) }
|
|
151
136
|
}
|
|
152
137
|
|
|
153
|
-
export function writeLauncher(version: string, paths: DaemonPaths = daemonPaths()): void {
|
|
154
|
-
try {
|
|
155
|
-
writeFileSync(paths.launcher, launcherText(version, paths), { mode: 0o700 })
|
|
156
|
-
} catch {
|
|
157
|
-
// best-effort: solo lo usa el autoarranque
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
138
|
/** ¿Hay algo que mantener? (sin registro no se lanza nada al cargar el plugin). */
|
|
162
139
|
export function hasRegistryEntries(paths: DaemonPaths = daemonPaths()): boolean {
|
|
163
140
|
if (!existsSync(paths.registry)) return false
|
|
164
141
|
try {
|
|
165
142
|
const registry = JSON.parse(readFileSync(paths.registry, "utf8")) as Record<string, unknown[] | undefined>
|
|
166
|
-
return ["tunnels", "webhooks"
|
|
143
|
+
return ["tunnels", "webhooks"].some((key) => (registry[key]?.length ?? 0) > 0)
|
|
167
144
|
} catch {
|
|
168
145
|
return false
|
|
169
146
|
}
|