opencode-apex 0.6.0 → 0.8.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/CHANGELOG.md +84 -0
- package/advisor.ts +12 -8
- package/browser.ts +26 -0
- package/core/advisor-session.ts +102 -3
- package/core/config.ts +43 -1
- package/core/cred-channel.ts +300 -0
- package/core/cred.ts +145 -24
- package/core/kdbx.ts +374 -0
- package/core/tools-run.ts +22 -7
- package/cred.ts +803 -130
- package/daemon/main.ts +89 -7
- package/daemon/mcp.ts +261 -0
- package/daemon/shared.ts +9 -0
- package/docs/ADVISOR.md +10 -1
- package/docs/CONFIG.md +3 -1
- package/docs/CRED.md +127 -44
- package/docs/ENDPOINTS.md +11 -3
- package/docs/EVENTS.md +42 -0
- package/endpoints.ts +106 -2
- package/index.ts +14 -3
- package/opencode-apex.jsonc +3 -1
- package/package.json +10 -6
- package/skills/apex-callbacks/SKILL.md +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,90 @@ All notable changes to `opencode-apex`. Format based on
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.8.0] — 2026-12-04
|
|
9
|
+
|
|
10
|
+
### Added (Automations bridge)
|
|
11
|
+
|
|
12
|
+
- **`apex.event`: anything `events.ingest` accepts can trigger an OpenCode automation.**
|
|
13
|
+
Verified end to end against OpenCode 2.4.4 (shell and code actions, source filter, server
|
|
14
|
+
and daemon restarts). OpenCode's automations (≥ 2.4.1) run on timers or on MCP events, but have no webhook or HTTP
|
|
15
|
+
trigger. The apex daemon now serves an MCP server with the Events extension (SEP-3415,
|
|
16
|
+
protocol `2026-07-28`) on 127.0.0.1, and the plugin registers it as `apex` through
|
|
17
|
+
`ctx.mcp.transform`. Each accepted ingest (verified `apex_webhook`, relays, scripts) is
|
|
18
|
+
forwarded to it, so `{ type: "event", server: "apex", event: "apex.event", args: { source?,
|
|
19
|
+
type? } }` fires the automation with `{ id, source, type?, payload, receivedAt }`.
|
|
20
|
+
- Per-project URL (`/mcp/<directory>`): an automation only sees its own project's events.
|
|
21
|
+
- Replay after a disconnect from an in-memory buffer (500 events), with `truncated` when
|
|
22
|
+
events are missing (another daemon run, buffer overflow).
|
|
23
|
+
- Port and token stay the same across daemon restarts (`mcp.json`, 0600), so the MCP entry
|
|
24
|
+
stays valid; if the port is taken, the plugin re-registers it on its next ping.
|
|
25
|
+
- The daemon no longer exits idle while event streams are open or a plugin pinged it in
|
|
26
|
+
the last 10 minutes (the plugin pings every minute), so automations can always be created.
|
|
27
|
+
- New switch `modules.automations` (default on with `events` and `endpoints`). A server
|
|
28
|
+
named `apex` in your own MCP config takes precedence.
|
|
29
|
+
- Built on `createMcpHandler` from `@modelcontextprotocol/server` 2.4.0 (new dependency);
|
|
30
|
+
`events/list` and `events/stream` are implemented in `daemon/mcp.ts`.
|
|
31
|
+
- Docs: `docs/EVENTS.md` explains when to use automations (schedules, checks) and when apex
|
|
32
|
+
(anything that comes from outside); the `apex-callbacks` skill recommends automations over
|
|
33
|
+
writing a watcher when OpenCode has them.
|
|
34
|
+
- Version 0.8.0 in `package.json` and `index.ts`: a running 0.7.0 daemon (without the MCP
|
|
35
|
+
server) is replaced when the plugin loads.
|
|
36
|
+
|
|
37
|
+
### Added (Cred)
|
|
38
|
+
|
|
39
|
+
- **`/cred help`** (also `-h`, `--help`, `ayuda`, or `/cred` with no arguments): the full user
|
|
40
|
+
manual — saving, listing, removing, KDBX, `/cred learn`, how the agent uses `apex_cred`, tips.
|
|
41
|
+
An unknown subcommand prints the error followed by the manual.
|
|
42
|
+
|
|
43
|
+
### Fixed (Cred)
|
|
44
|
+
|
|
45
|
+
- **`/cred` replies were reaching the model.** They are `synthetic` messages, which the model
|
|
46
|
+
does see (an old comment claimed otherwise). Every reply now carries `metadata.apexUiOnly`
|
|
47
|
+
and the module drops those messages in the `context`, `compaction` and `generate` hooks, so
|
|
48
|
+
the manual, listings and notices show in the session without spending context or leaking into
|
|
49
|
+
a compaction summary. Verified live: the drop is logged on every model call, and a model asked
|
|
50
|
+
about the manual's first line reported not seeing it.
|
|
51
|
+
- **`/cred` replies used `delivery: "queue"`,** which delivered each one as a separate input
|
|
52
|
+
once the turn ended — a pointless model call, or never delivered when the turn failed. They
|
|
53
|
+
now use `steer` with `resume: false`: they wait in the inbox and ride on the next real call.
|
|
54
|
+
|
|
55
|
+
### Changed (Advisor)
|
|
56
|
+
|
|
57
|
+
- **The advisor session is named after the session it advises.** It was always titled
|
|
58
|
+
`apex advisor`, so with several active trees you could not tell which advisor decided for
|
|
59
|
+
which conversation. The title is now `apex advisor → <target title> [<target short id>]`
|
|
60
|
+
(or `apex advisor → sesión <id>` when the target has no title). The short id is stable
|
|
61
|
+
across renames and disambiguates equal titles; every permission evaluation refreshes it —
|
|
62
|
+
even when the verdict comes from the 10-minute decision cache, so a rename is picked up on
|
|
63
|
+
the next prompt without a model round trip (`syncAdvisorTitleForRoot`, called before the
|
|
64
|
+
cache fast-path in `advisor.ts`). New exports in `core/advisor-session.ts`:
|
|
65
|
+
`advisorTitleFor()` (pure), `ensureAdvisorTitle()` (best-effort, idempotent) and
|
|
66
|
+
`syncAdvisorTitleForRoot()`. The in-process advisor state cell moved to key `v2` to hold the
|
|
67
|
+
last-applied title per advisor session.
|
|
68
|
+
|
|
69
|
+
## [0.7.0] — 2026-12-02
|
|
70
|
+
|
|
71
|
+
### Added
|
|
72
|
+
|
|
73
|
+
- **Cred KDBX backing store.** `cred.kdbx` enables a `.kdbx` (KeePassXC/KeePass) file as the credential source of truth: loaded at startup, watched for external changes, and written on `/cred set`/`rm`. All protected values feed the redaction engine via cred patterns. Implemented with `kdbxweb` + `hash-wasm` (Argon2, pure WASM).
|
|
74
|
+
- **Extended `/cred` command.** `get`, richer `set` (URI parsing like `ssh://user:pass@host:22`, `--username/--password/--url/--kind/--secret.*`), and `kdbx status|reload|save`.
|
|
75
|
+
- **`apex_cred` agent tool + temporary channel tools.** Agent can list/get public metadata and `open` a handle without seeing secrets; apex spawns `apex_cred_use_<handle>` for safe actions (SSH exec, HTTP request with injected auth). Channel outputs are defensively redacted.
|
|
76
|
+
- **Cred redaction variants.** Added base64url variant; KDBX protected/custom fields included.
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
|
|
80
|
+
- **`apex_cred` channels could send the secret to any host.** `request` accepted an arbitrary `url` and `exec` an arbitrary `host`, so an agent could point a channel at its own server and receive the `Authorization` header or the password. The destination now always comes from the credential: HTTP only reaches the stored URL's own origin (other origins are refused before anything is sent, redirects are not followed, the auth header cannot be overridden), and SSH takes host, port and user from the credential. Channel code moved to `core/cred-channel.ts`.
|
|
81
|
+
- **Temporary `apex_cred_use_<handle>` tools never appeared.** They were only added when the tool transform first ran; opening or closing a channel now calls `ctx.tool.reload()`. `apex_cred action=use` is the same call without the dedicated tool.
|
|
82
|
+
- **SSH channel no longer needs `sshpass`.** The password is handed over through `SSH_ASKPASS` (`SSH_ASKPASS_REQUIRE=force`), still never in argv. A malformed `ssh://` URL returns an error instead of throwing.
|
|
83
|
+
- **KDBX entries sharing a title (or with no title) were left unredacted.** The second entry overwrote the first in the index; each now gets a unique name (`name#2`, `entry-<uuid>`).
|
|
84
|
+
- **KDBX watcher went blind after the first atomic save.** It watched the file's inode; it now watches the directory. A failed reload keeps the last good index.
|
|
85
|
+
- **KDBX file was created `0644`**; now `0600`. `/cred set` reports when the entry could not be saved to the file instead of claiming success.
|
|
86
|
+
- Channel output is scrubbed of every stored secret and of derived strings (the Basic base64); public metadata no longer includes the URL query.
|
|
87
|
+
|
|
88
|
+
### Changed
|
|
89
|
+
|
|
90
|
+
- **`@opencode/plugin` / `@opencode/plugin-browser` bumped to `^2.4.3`** (a fresh npm install already resolved inside that range). Code adapted to the 2.4 plugin API: the tool execute `Context` now requires `tool.call`, which `tools.run` implements by delegating to another registered tool under the same `events.tools` allow/deny; `browser.target` declares the `output` schema it always returned; `index.ts` `VERSION` was stuck at 0.5.0 and now matches the package.
|
|
91
|
+
|
|
8
92
|
## [0.6.0] — 2026-11-30
|
|
9
93
|
|
|
10
94
|
### Added (Advisor)
|
package/advisor.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
isAdvisorSession,
|
|
31
31
|
requestAdvisorDecision,
|
|
32
32
|
resolveRootSessionID,
|
|
33
|
+
syncAdvisorTitleForRoot,
|
|
33
34
|
} from "./core/advisor-session.js"
|
|
34
35
|
import { redactHandler } from "./redact.js"
|
|
35
36
|
|
|
@@ -228,15 +229,18 @@ export function register(
|
|
|
228
229
|
() => null,
|
|
229
230
|
)
|
|
230
231
|
: null
|
|
232
|
+
const rootID = await resolveRootSessionID(ctx, e.sessionID)
|
|
233
|
+
// El título de la sesión advisor sigue a la objetivo en CADA evaluación,
|
|
234
|
+
// también cuando el veredicto salga del cache: el usuario puede renombrar
|
|
235
|
+
// la sesión en cualquier momento y la lista debe reflejarlo siempre.
|
|
236
|
+
await syncAdvisorTitleForRoot(ctx, rootID, config.location)
|
|
237
|
+
|
|
231
238
|
const conversation = conversationContext
|
|
232
|
-
? await (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
redact: redactHandler ? (text) => redactHandler!({ text }).redacted : undefined,
|
|
238
|
-
})
|
|
239
|
-
})().catch(() => "")
|
|
239
|
+
? await buildConversationContext(ctx, {
|
|
240
|
+
rootID,
|
|
241
|
+
maxMessages: conversationMessages,
|
|
242
|
+
redact: redactHandler ? (text) => redactHandler!({ text }).redacted : undefined,
|
|
243
|
+
}).catch(() => "")
|
|
240
244
|
: ""
|
|
241
245
|
const cacheKey = generateCacheKey(e.action, e.resources, `${processes?.text ?? ""}\n${conversation}`)
|
|
242
246
|
|
package/browser.ts
CHANGED
|
@@ -455,6 +455,32 @@ export function register(ctx: Plugin.Context, config: BrowserConfigShape): Effec
|
|
|
455
455
|
"keep the current one; pass an empty string to go back to cdpUrl discovery.",
|
|
456
456
|
},
|
|
457
457
|
},
|
|
458
|
+
// Desde plugin 2.4, devolver `{ output }` exige declarar su schema.
|
|
459
|
+
output: {
|
|
460
|
+
type: "object",
|
|
461
|
+
properties: {
|
|
462
|
+
mode: { type: "string", enum: ["external", "in-app", "auto"] },
|
|
463
|
+
source: { type: "string" },
|
|
464
|
+
target: {
|
|
465
|
+
type: "object",
|
|
466
|
+
properties: { cdpUrl: { type: "string" }, profile: { type: ["string", "null"] } },
|
|
467
|
+
additionalProperties: false,
|
|
468
|
+
},
|
|
469
|
+
connected: {
|
|
470
|
+
type: ["object", "null"],
|
|
471
|
+
properties: {
|
|
472
|
+
profile: { type: ["string", "null"] },
|
|
473
|
+
cdp: { type: ["string", "null"] },
|
|
474
|
+
how: { type: ["string", "null"] },
|
|
475
|
+
},
|
|
476
|
+
additionalProperties: true,
|
|
477
|
+
},
|
|
478
|
+
attached: { type: "array", items: { type: "string" } },
|
|
479
|
+
error: { type: ["string", "null"] },
|
|
480
|
+
},
|
|
481
|
+
required: ["mode", "source", "target", "attached"],
|
|
482
|
+
additionalProperties: true,
|
|
483
|
+
},
|
|
458
484
|
options: { namespace: "browser", permission: "browser", codemode: true },
|
|
459
485
|
execute: (input, context) =>
|
|
460
486
|
Effect.gen(function* () {
|
package/core/advisor-session.ts
CHANGED
|
@@ -81,9 +81,11 @@ interface AdvisorCell {
|
|
|
81
81
|
readonly advisorSessions: Set<string>
|
|
82
82
|
/** requestID → resolver de la promesa pendiente */
|
|
83
83
|
readonly pending: Map<string, (decision: AdvisorDecision) => void>
|
|
84
|
+
/** advisor sessionID → último título aplicado (evita updates redundantes) */
|
|
85
|
+
readonly titleApplied: Map<string, string>
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
const CELL_KEY = Symbol.for("apex.advisor.state.
|
|
88
|
+
const CELL_KEY = Symbol.for("apex.advisor.state.v2")
|
|
87
89
|
|
|
88
90
|
function cell(): AdvisorCell {
|
|
89
91
|
const holder = globalThis as Record<symbol, AdvisorCell | undefined>
|
|
@@ -93,6 +95,7 @@ function cell(): AdvisorCell {
|
|
|
93
95
|
sessionCache: new Map(),
|
|
94
96
|
advisorSessions: new Set(),
|
|
95
97
|
pending: new Map(),
|
|
98
|
+
titleApplied: new Map(),
|
|
96
99
|
}
|
|
97
100
|
holder[CELL_KEY] = created
|
|
98
101
|
return created
|
|
@@ -101,6 +104,7 @@ function cell(): AdvisorCell {
|
|
|
101
104
|
const sessionCache = cell().sessionCache
|
|
102
105
|
const advisorSessions = cell().advisorSessions
|
|
103
106
|
const pending = cell().pending
|
|
107
|
+
const titleApplied = cell().titleApplied
|
|
104
108
|
|
|
105
109
|
const STORAGE_KEY = (rootID: string) => `apex:advisor:session:${rootID}`
|
|
106
110
|
const MAX_DEPTH = 25
|
|
@@ -132,6 +136,68 @@ export function isAdvisorSession(sessionID: string): boolean {
|
|
|
132
136
|
return advisorSessions.has(sessionID)
|
|
133
137
|
}
|
|
134
138
|
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// Título distintivo de la sesión advisor
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
/** Longitud máxima del título de la sesión objetivo que se refleja en el advisor. */
|
|
144
|
+
const MAX_TARGET_TITLE = 60
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Título de la sesión advisor, derivado de la sesión OBJETIVO (la raíz del
|
|
148
|
+
* árbol que atiende). Lleva el título actual de la objetivo —para reconocerla
|
|
149
|
+
* de un vistazo— y su id corto entre corchetes —estable aunque el usuario
|
|
150
|
+
* renombre la sesión, y desambigua dos sesiones con el mismo título—.
|
|
151
|
+
*
|
|
152
|
+
* El prefijo con flecha (`apex advisor → …`) deja claro en la lista de sesiones
|
|
153
|
+
* que es el advisor de esa otra sesión, no una conversación normal.
|
|
154
|
+
*/
|
|
155
|
+
export function advisorTitleFor(rootTitle: string | undefined, rootID: string): string {
|
|
156
|
+
const short = rootID.length > 6 ? rootID.slice(-6) : rootID
|
|
157
|
+
const title = (rootTitle ?? "").trim()
|
|
158
|
+
if (!title) return `apex advisor → sesión ${short}`
|
|
159
|
+
const clipped = title.length > MAX_TARGET_TITLE ? `${title.slice(0, MAX_TARGET_TITLE - 1)}…` : title
|
|
160
|
+
return `apex advisor → ${clipped} [${short}]`
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Título actual de una sesión; undefined si no se puede leer. */
|
|
164
|
+
async function getSessionTitle(ctx: Plugin.Context, sessionID: string): Promise<string | undefined> {
|
|
165
|
+
try {
|
|
166
|
+
const info = (await Effect.runPromise(ctx.session.get({ sessionID: sessionID as never }))) as
|
|
167
|
+
| { title?: string }
|
|
168
|
+
| undefined
|
|
169
|
+
return typeof info?.title === "string" ? info.title : undefined
|
|
170
|
+
} catch {
|
|
171
|
+
return undefined
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Pone (o actualiza) el título de la sesión advisor para que refleje el título
|
|
177
|
+
* ACTUAL de la sesión objetivo. Best-effort e idempotente: si el título ya es
|
|
178
|
+
* el correcto no toca nada (se recuerda el último aplicado por proceso), así
|
|
179
|
+
* que llamarlo en cada petición de permiso recoge los renombrados del usuario
|
|
180
|
+
* sin trabajo redundante. Devuelve el título deseado.
|
|
181
|
+
*/
|
|
182
|
+
export async function ensureAdvisorTitle(
|
|
183
|
+
ctx: Plugin.Context,
|
|
184
|
+
advisorID: string,
|
|
185
|
+
rootID: string,
|
|
186
|
+
rootTitle: string | undefined,
|
|
187
|
+
): Promise<string> {
|
|
188
|
+
const desired = advisorTitleFor(rootTitle, rootID)
|
|
189
|
+
if (titleApplied.get(advisorID) === desired) return desired
|
|
190
|
+
try {
|
|
191
|
+
await Effect.runPromise(
|
|
192
|
+
ctx.session.update({ sessionID: advisorID as never, title: desired as never } as never),
|
|
193
|
+
)
|
|
194
|
+
titleApplied.set(advisorID, desired)
|
|
195
|
+
} catch (error) {
|
|
196
|
+
console.warn(`[apex.advisor] no se pudo renombrar la sesión advisor: ${String(error)}`)
|
|
197
|
+
}
|
|
198
|
+
return desired
|
|
199
|
+
}
|
|
200
|
+
|
|
135
201
|
/** Llamado por la herramienta del advisor para resolver una decisión pendiente. */
|
|
136
202
|
export function resolvePendingDecision(requestID: string, decision: "allow" | "deny", reason?: string): boolean {
|
|
137
203
|
const resolver = pending.get(requestID)
|
|
@@ -183,8 +249,16 @@ export async function getOrCreateAdvisorSession(
|
|
|
183
249
|
const directory = isAbsolute(rawDir) ? normalize(rawDir) : join(process.cwd(), rawDir)
|
|
184
250
|
const cacheKey = `${rootID}|${directory}`
|
|
185
251
|
|
|
252
|
+
// Título actual de la sesión objetivo: puede haber cambiado desde la última
|
|
253
|
+
// vez (el usuario la renombra), así que se lee en cada petición y se
|
|
254
|
+
// resincroniza el título del advisor abajo.
|
|
255
|
+
const rootTitle = await getSessionTitle(ctx, rootID)
|
|
256
|
+
|
|
186
257
|
const cached = sessionCache.get(cacheKey)
|
|
187
|
-
if (cached)
|
|
258
|
+
if (cached) {
|
|
259
|
+
await ensureAdvisorTitle(ctx, cached, rootID, rootTitle)
|
|
260
|
+
return cached
|
|
261
|
+
}
|
|
188
262
|
|
|
189
263
|
// Persistida entre recargas (se valida que siga existiendo, que el agente sea
|
|
190
264
|
// el advisor y que la location coincida; si no, se recrea).
|
|
@@ -204,6 +278,8 @@ export async function getOrCreateAdvisorSession(
|
|
|
204
278
|
advisorSessions.add(stored)
|
|
205
279
|
// Retrofit: sesiones creadas antes de que existiera el archivado.
|
|
206
280
|
void archiveAdvisorSession(ctx, stored)
|
|
281
|
+
// Retrofit del título distintivo (sesiones creadas con "apex advisor" fijo).
|
|
282
|
+
await ensureAdvisorTitle(ctx, stored, rootID, rootTitle)
|
|
207
283
|
return stored
|
|
208
284
|
}
|
|
209
285
|
}
|
|
@@ -217,10 +293,11 @@ export async function getOrCreateAdvisorSession(
|
|
|
217
293
|
// si no se puede crear, se intenta crear la sesión igualmente
|
|
218
294
|
}
|
|
219
295
|
|
|
296
|
+
const initialTitle = advisorTitleFor(rootTitle, rootID)
|
|
220
297
|
const created = (await Effect.runPromise(
|
|
221
298
|
ctx.session.create({
|
|
222
299
|
agent: ADVISOR_AGENT_ID as never,
|
|
223
|
-
title:
|
|
300
|
+
title: initialTitle,
|
|
224
301
|
metadata: { apexAdvisorFor: rootID, apexAdvisorLocation: directory } as never,
|
|
225
302
|
location: { directory } as never,
|
|
226
303
|
} as never),
|
|
@@ -229,6 +306,7 @@ export async function getOrCreateAdvisorSession(
|
|
|
229
306
|
const advisorID = created.id
|
|
230
307
|
sessionCache.set(cacheKey, advisorID)
|
|
231
308
|
advisorSessions.add(advisorID)
|
|
309
|
+
titleApplied.set(advisorID, initialTitle)
|
|
232
310
|
await Effect.runPromise(ctx.storage.set(STORAGE_KEY(rootID), advisorID as never))
|
|
233
311
|
await archiveAdvisorSession(ctx, advisorID)
|
|
234
312
|
return advisorID
|
|
@@ -362,6 +440,27 @@ export async function buildConversationContext(
|
|
|
362
440
|
].join("\n")
|
|
363
441
|
}
|
|
364
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Pone (o crea) la sesión advisor del árbol y resincroniza su título con el
|
|
445
|
+
* título ACTUAL de la sesión objetivo, sin pedir ninguna decisión.
|
|
446
|
+
*
|
|
447
|
+
* Se llama en cada evaluación de permiso, también cuando el veredicto sale del
|
|
448
|
+
* cache: el usuario puede renombrar la sesión objetivo en cualquier momento y
|
|
449
|
+
* el título del advisor debe seguirlo aunque no haya ida al modelo.
|
|
450
|
+
* Best-effort: un fallo aquí no debe frenar la evaluación.
|
|
451
|
+
*/
|
|
452
|
+
export async function syncAdvisorTitleForRoot(
|
|
453
|
+
ctx: Plugin.Context,
|
|
454
|
+
rootID: string,
|
|
455
|
+
location?: string,
|
|
456
|
+
): Promise<void> {
|
|
457
|
+
try {
|
|
458
|
+
await getOrCreateAdvisorSession(ctx, rootID, location)
|
|
459
|
+
} catch {
|
|
460
|
+
// best-effort: la evaluación del permiso sigue su curso
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
365
464
|
/**
|
|
366
465
|
* Pide una decisión al advisor del árbol.
|
|
367
466
|
* Devuelve null si: la sesión solicitante es la del advisor, no hay sesión
|
package/core/config.ts
CHANGED
|
@@ -108,10 +108,28 @@ export interface CredLlmConfig {
|
|
|
108
108
|
allowRemote: boolean
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
export interface CredKdbxConfig {
|
|
112
|
+
/** Usar un fichero .kdbx como almacén principal (interoperable con KeePassXC). */
|
|
113
|
+
enabled: boolean
|
|
114
|
+
/** Ruta al .kdbx. Soporta ~. */
|
|
115
|
+
path: string
|
|
116
|
+
/** Contraseña del .kdbx: literal | env:VAR | file:/ruta. */
|
|
117
|
+
password: string
|
|
118
|
+
/** Fichero de clave opcional. */
|
|
119
|
+
keyFile: string
|
|
120
|
+
/** Crear el .kdbx si no existe. */
|
|
121
|
+
createIfMissing: boolean
|
|
122
|
+
/** Recargar cuando el fichero cambie en disco (interop con apps externas). */
|
|
123
|
+
watch: boolean
|
|
124
|
+
/** Nombre del grupo KDBX donde se guardan entradas creadas por apex. */
|
|
125
|
+
group: string
|
|
126
|
+
}
|
|
127
|
+
|
|
111
128
|
export interface CredConfig {
|
|
112
129
|
/** Secretos más cortos se rechazan (ver core/cred.ts). */
|
|
113
130
|
minLength: number
|
|
114
131
|
llm: CredLlmConfig
|
|
132
|
+
kdbx: CredKdbxConfig
|
|
115
133
|
}
|
|
116
134
|
|
|
117
135
|
export interface AdvisorConfig {
|
|
@@ -158,6 +176,16 @@ const DEFAULT_CRED_LLM = {
|
|
|
158
176
|
allowRemote: false,
|
|
159
177
|
}
|
|
160
178
|
|
|
179
|
+
const DEFAULT_CRED_KDBX = {
|
|
180
|
+
enabled: false,
|
|
181
|
+
path: "~/.config/opencode/apex-creds.kdbx",
|
|
182
|
+
password: "env:APEX_CRED_KDBX_PASSWORD",
|
|
183
|
+
keyFile: "",
|
|
184
|
+
createIfMissing: true,
|
|
185
|
+
watch: true,
|
|
186
|
+
group: "apex",
|
|
187
|
+
}
|
|
188
|
+
|
|
161
189
|
const credLlmConfigSchema = z.object({
|
|
162
190
|
enabled: z.boolean().default(DEFAULT_CRED_LLM.enabled),
|
|
163
191
|
endpoint: z.string().default(DEFAULT_CRED_LLM.endpoint),
|
|
@@ -166,9 +194,20 @@ const credLlmConfigSchema = z.object({
|
|
|
166
194
|
allowRemote: z.boolean().default(DEFAULT_CRED_LLM.allowRemote),
|
|
167
195
|
})
|
|
168
196
|
|
|
197
|
+
const credKdbxConfigSchema = z.object({
|
|
198
|
+
enabled: z.boolean().default(DEFAULT_CRED_KDBX.enabled),
|
|
199
|
+
path: z.string().default(DEFAULT_CRED_KDBX.path),
|
|
200
|
+
password: z.string().default(DEFAULT_CRED_KDBX.password),
|
|
201
|
+
keyFile: z.string().default(DEFAULT_CRED_KDBX.keyFile),
|
|
202
|
+
createIfMissing: z.boolean().default(DEFAULT_CRED_KDBX.createIfMissing),
|
|
203
|
+
watch: z.boolean().default(DEFAULT_CRED_KDBX.watch),
|
|
204
|
+
group: z.string().default(DEFAULT_CRED_KDBX.group),
|
|
205
|
+
})
|
|
206
|
+
|
|
169
207
|
const credConfigSchema = z.object({
|
|
170
208
|
minLength: z.number().int().positive().default(6),
|
|
171
209
|
llm: credLlmConfigSchema.default(() => ({ ...DEFAULT_CRED_LLM })),
|
|
210
|
+
kdbx: credKdbxConfigSchema.default(() => ({ ...DEFAULT_CRED_KDBX })),
|
|
172
211
|
})
|
|
173
212
|
|
|
174
213
|
const ruleConditionSchema = z.object({
|
|
@@ -285,7 +324,7 @@ const browserConfigSchema = z.object({
|
|
|
285
324
|
|
|
286
325
|
export const apexConfigSchema = z.object({
|
|
287
326
|
redact: redactConfigSchema.default(() => ({ mode: "strict" as const, patterns: [], bundles: [...DEFAULT_BUNDLES], minConfidence: "medium" as const, allowlist: [], prefix: "[SECRET:", suffix: "]", key: "", restore: { toolInput: true } })),
|
|
288
|
-
cred: credConfigSchema.default(() => ({ minLength: 6, llm: { ...DEFAULT_CRED_LLM } })),
|
|
327
|
+
cred: credConfigSchema.default(() => ({ minLength: 6, llm: { ...DEFAULT_CRED_LLM }, kdbx: { ...DEFAULT_CRED_KDBX } })),
|
|
289
328
|
events: eventsConfigSchema.default(() => ({ routing: "all" as const, subscriptions: [], server: {}, tools: defaultEventsTools() })),
|
|
290
329
|
advisor: advisorConfigSchema.default(() => ({ actions: [], decisive: false, evaluate: "ask-only" as const, timeoutMs: 10000, processContext: true })),
|
|
291
330
|
guard: guardConfigSchema.default(() => ({
|
|
@@ -317,6 +356,9 @@ export const apexConfigSchema = z.object({
|
|
|
317
356
|
tempAccess: z.boolean().optional(),
|
|
318
357
|
// Activado por defecto: apex_tunnel/webhook/daemon (el daemon solo se lanza al usarlas).
|
|
319
358
|
endpoints: z.boolean().optional(),
|
|
359
|
+
// Activado por defecto (con events y endpoints): servidor MCP `apex` con MCP Events para
|
|
360
|
+
// los triggers de automations de OpenCode. Lanza el daemon al cargar el plugin.
|
|
361
|
+
automations: z.boolean().optional(),
|
|
320
362
|
})
|
|
321
363
|
.default(() => ({})),
|
|
322
364
|
})
|