opencode-apex 0.8.0 → 0.8.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 +23 -0
- package/README.md +5 -1
- package/advisor.ts +65 -2
- package/core/advisor-session.ts +62 -0
- package/core/config.ts +3 -0
- package/core/server-endpoint.ts +16 -0
- package/cred.ts +83 -22
- package/docs/ADVISOR.md +7 -0
- package/docs/CRED.md +10 -8
- package/index.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,29 @@ All notable changes to `opencode-apex`. Format based on
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.8.1] — 2026-12-04
|
|
9
|
+
|
|
10
|
+
### Fixed (Cred)
|
|
11
|
+
|
|
12
|
+
- **`/cred help` (and every `/cred` reply) showed nothing.** A `synthetic` only appears when a
|
|
13
|
+
turn takes it from the inbox, and with `resume: false` that waited for the next prompt;
|
|
14
|
+
even then the app shows a synthetic by its one-line `description` only. Replies now use
|
|
15
|
+
`delivery: "queue"` with `resume: true`, so the session runs a turn that puts them on
|
|
16
|
+
screen right away: in a claude-* session acpbridge answers it itself, free and verbatim
|
|
17
|
+
(the text starts with its `<!-- acp-notice -->` marker); any other model is asked, in an
|
|
18
|
+
HTML comment, to repeat the block as is. The `context` hook keeps the reply only in that
|
|
19
|
+
turn's request; later requests, compactions and `generate` drop both the reply and the
|
|
20
|
+
text-only answer that echoed it.
|
|
21
|
+
|
|
22
|
+
### Added (Advisor)
|
|
23
|
+
|
|
24
|
+
- **`advisor.markRead`** (default `true`): when the advisor answers with
|
|
25
|
+
`apex_advisor_decide` and its turn ends, its session is marked read and archived again
|
|
26
|
+
(`session.prompt` unarchives it), so it no longer shows as unread in the app. A turn that
|
|
27
|
+
ends without a decision stays unread. The plugin API exposes neither `session.view` nor
|
|
28
|
+
`archived`, so apex calls its own server (`POST /api/session/:id/view`,
|
|
29
|
+
`PATCH /api/session/:id`) with the service password, read in-process and never exposed.
|
|
30
|
+
|
|
8
31
|
## [0.8.0] — 2026-12-04
|
|
9
32
|
|
|
10
33
|
### Added (Automations bridge)
|
package/README.md
CHANGED
|
@@ -317,7 +317,11 @@ npm run typecheck # tsc --noEmit
|
|
|
317
317
|
npm run check:install # installs the package like OpenCode does; fails on duplicate `effect`
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
|
|
320
|
+
**Releasing.** Bump the version in `package.json` and `index.ts`, move the CHANGELOG entry to
|
|
321
|
+
`## [X.Y.Z]`, tag `vX.Y.Z` and publish a GitHub Release for that tag. The `Publish` workflow
|
|
322
|
+
(`.github/workflows/publish.yml`) then publishes to npm with provenance (Trusted Publishing).
|
|
323
|
+
Don't run `npm publish` by hand. Before it uploads, `npm publish` runs the tests, the
|
|
324
|
+
typecheck and the install check (`prepublishOnly`).
|
|
321
325
|
|
|
322
326
|
**Dependency rule.** OpenCode (≥ 2.1) serves `effect` and `@opencode/plugin` to plugins from
|
|
323
327
|
its own copy, so apex never pins `effect`: it is only an optional peer. The other `@opencode/*`
|
package/advisor.ts
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { createHash } from "node:crypto"
|
|
19
|
-
import { Effect } from "effect"
|
|
19
|
+
import { Effect, Stream } from "effect"
|
|
20
20
|
import type { Scope } from "effect"
|
|
21
21
|
import type { Plugin } from "@opencode/plugin/effect"
|
|
22
22
|
import { homedir } from "node:os"
|
|
23
|
-
import { ADVISOR_AGENT_ID, ensureAdvisorAgent } from "./core/advisor-agent.js"
|
|
23
|
+
import { ADVISOR_AGENT_ID, ADVISOR_TOOL_NAME, ensureAdvisorAgent } from "./core/advisor-agent.js"
|
|
24
24
|
import { readOrCreateTemplate } from "./core/templates.js"
|
|
25
25
|
import { registerAdvisorTool } from "./core/advisor-tool.js"
|
|
26
26
|
import {
|
|
@@ -28,10 +28,15 @@ import {
|
|
|
28
28
|
buildProcessContext,
|
|
29
29
|
DEFAULT_ADVISOR_REQUEST_TEMPLATE,
|
|
30
30
|
isAdvisorSession,
|
|
31
|
+
markAdvisorSessionRead,
|
|
32
|
+
noteAdvisorAnswered,
|
|
31
33
|
requestAdvisorDecision,
|
|
32
34
|
resolveRootSessionID,
|
|
33
35
|
syncAdvisorTitleForRoot,
|
|
36
|
+
takeAdvisorAnswered,
|
|
37
|
+
type ServerCall,
|
|
34
38
|
} from "./core/advisor-session.js"
|
|
39
|
+
import { readServerPassword, resolveServerEndpoint } from "./core/server-endpoint.js"
|
|
35
40
|
import { redactHandler } from "./redact.js"
|
|
36
41
|
|
|
37
42
|
// ---------------------------------------------------------------------------
|
|
@@ -84,6 +89,13 @@ export interface AdvisorConfig {
|
|
|
84
89
|
conversationContext?: boolean
|
|
85
90
|
/** Cuántos mensajes de usuario recientes incluir. Default 10. */
|
|
86
91
|
conversationMessages?: number
|
|
92
|
+
/**
|
|
93
|
+
* Cuando el advisor responde con su herramienta y acaba el turno, su sesión se
|
|
94
|
+
* marca leída (y se vuelve a archivar) para que no aparezca como "no leída" en
|
|
95
|
+
* la app. Si el turno acaba sin decidir, se deja sin leer: ahí sí hay algo que
|
|
96
|
+
* mirar. Default `true`.
|
|
97
|
+
*/
|
|
98
|
+
markRead?: boolean
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
// ---------------------------------------------------------------------------
|
|
@@ -204,6 +216,29 @@ export function register(
|
|
|
204
216
|
// 2. Única herramienta del advisor
|
|
205
217
|
yield* registerAdvisorTool(ctx)
|
|
206
218
|
|
|
219
|
+
// 2b. Turno del advisor resuelto con su herramienta → sesión leída al acabar.
|
|
220
|
+
if (config.markRead ?? true) {
|
|
221
|
+
yield* ctx.tool.hook("execute.after", (event) =>
|
|
222
|
+
Effect.sync(() => {
|
|
223
|
+
if (event.tool !== ADVISOR_TOOL_NAME) return
|
|
224
|
+
if (event.agent === ADVISOR_AGENT_ID || isAdvisorSession(event.sessionID)) noteAdvisorAnswered(event.sessionID)
|
|
225
|
+
}),
|
|
226
|
+
)
|
|
227
|
+
const call = serverCall(ctx)
|
|
228
|
+
yield* ctx.event.subscribe({ types: ["session.execution.succeeded"] }).pipe(
|
|
229
|
+
Stream.mapEffect((event) =>
|
|
230
|
+
Effect.promise(async () => {
|
|
231
|
+
const sessionID = String((event.data as { sessionID?: unknown })?.sessionID ?? "")
|
|
232
|
+
if (!sessionID || !takeAdvisorAnswered(sessionID)) return
|
|
233
|
+
if (!(await markAdvisorSessionRead(ctx, sessionID, call)))
|
|
234
|
+
console.warn(`[apex.advisor] no se pudo marcar como leída la sesión advisor ${sessionID}`)
|
|
235
|
+
}),
|
|
236
|
+
),
|
|
237
|
+
Stream.runDrain,
|
|
238
|
+
Effect.forkScoped,
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
|
|
207
242
|
// 3. Caché de veredictos
|
|
208
243
|
const cache = yield* Effect.promise(() => loadCache(ctx.storage))
|
|
209
244
|
|
|
@@ -307,6 +342,33 @@ export function register(
|
|
|
307
342
|
})
|
|
308
343
|
}
|
|
309
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Llamadas HTTP del plugin a su propio servidor (Basic `opencode:<password>`).
|
|
347
|
+
* La dirección y el password se resuelven en cada llamada: el servicio puede
|
|
348
|
+
* haber reescrito su registro tras un reinicio.
|
|
349
|
+
*/
|
|
350
|
+
function serverCall(ctx: Plugin.Context): ServerCall {
|
|
351
|
+
return async (path, init) => {
|
|
352
|
+
const endpoint = resolveServerEndpoint({ directory: ctx.location?.directory ?? process.cwd() })
|
|
353
|
+
const password = readServerPassword(endpoint.auth.password)
|
|
354
|
+
if (!endpoint.baseUrl || !password) return false
|
|
355
|
+
try {
|
|
356
|
+
const response = await fetch(`${endpoint.baseUrl.replace(/\/+$/, "")}${path}`, {
|
|
357
|
+
method: init.method,
|
|
358
|
+
headers: {
|
|
359
|
+
authorization: `Basic ${Buffer.from(`${endpoint.auth.username}:${password}`).toString("base64")}`,
|
|
360
|
+
"content-type": "application/json",
|
|
361
|
+
},
|
|
362
|
+
body: JSON.stringify(init.body),
|
|
363
|
+
signal: AbortSignal.timeout(5000),
|
|
364
|
+
})
|
|
365
|
+
return response.ok
|
|
366
|
+
} catch {
|
|
367
|
+
return false
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
310
372
|
/**
|
|
311
373
|
* Aplica la decisión al evento de permiso.
|
|
312
374
|
* - decisive=true → allow/deny sustituyen el efecto (deny deja el motivo).
|
|
@@ -341,5 +403,6 @@ export function createDefaultAdvisorConfig(): AdvisorConfig {
|
|
|
341
403
|
processContext: true,
|
|
342
404
|
conversationContext: true,
|
|
343
405
|
conversationMessages: 10,
|
|
406
|
+
markRead: true,
|
|
344
407
|
}
|
|
345
408
|
}
|
package/core/advisor-session.ts
CHANGED
|
@@ -198,6 +198,68 @@ export async function ensureAdvisorTitle(
|
|
|
198
198
|
return desired
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
// ---------------------------------------------------------------------------
|
|
202
|
+
// Leída al terminar: la sesión advisor no avisa como "no leída"
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Sesiones advisor que han respondido con `apex_advisor_decide` en el turno en
|
|
207
|
+
* curso. Ámbito de proceso, como `cell()` (la herramienta corre en la instancia
|
|
208
|
+
* del location del advisor y el evento puede llegar a otra), con su propia
|
|
209
|
+
* clave para no cambiar la forma de la celda v2.
|
|
210
|
+
*/
|
|
211
|
+
const ANSWERED_KEY = Symbol.for("apex.advisor.answered.v1")
|
|
212
|
+
function answered(): Set<string> {
|
|
213
|
+
const holder = globalThis as Record<symbol, Set<string> | undefined>
|
|
214
|
+
return (holder[ANSWERED_KEY] ??= new Set())
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** La sesión advisor decidió con su herramienta: al acabar el turno se marca leída. */
|
|
218
|
+
export function noteAdvisorAnswered(sessionID: string): void {
|
|
219
|
+
answered().add(sessionID)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** ¿Respondió con su herramienta desde la última vez? Consume la marca. */
|
|
223
|
+
export function takeAdvisorAnswered(sessionID: string): boolean {
|
|
224
|
+
return answered().delete(sessionID)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Llamada HTTP al propio servidor; la API de plugins no expone `session.view` ni `archived`. */
|
|
228
|
+
export interface ServerCall {
|
|
229
|
+
(path: string, init: { method: string; body: unknown }): Promise<boolean>
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Milisegundos de un `time.idle` tal como lo devuelve `session.get` (DateTime, Date o número). */
|
|
233
|
+
export function idleMillis(idle: unknown): number | undefined {
|
|
234
|
+
if (typeof idle === "number" && Number.isFinite(idle)) return idle
|
|
235
|
+
if (idle instanceof Date) return idle.getTime()
|
|
236
|
+
// DateTime.Utc de Effect: `epochMilliseconds`.
|
|
237
|
+
const ms = (idle as { epochMilliseconds?: unknown } | null | undefined)?.epochMilliseconds
|
|
238
|
+
return typeof ms === "number" ? ms : undefined
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Marca la sesión advisor como leída (y la vuelve a archivar: cada `session.prompt`
|
|
243
|
+
* la desarchiva). Sin esto, cada permiso deja la sesión advisor "no leída" en la
|
|
244
|
+
* app, avisando de un turno que el usuario no necesita mirar. Best-effort.
|
|
245
|
+
*/
|
|
246
|
+
export async function markAdvisorSessionRead(ctx: Plugin.Context, sessionID: string, call: ServerCall): Promise<boolean> {
|
|
247
|
+
let idle: number | undefined
|
|
248
|
+
try {
|
|
249
|
+
const info = (await Effect.runPromise(ctx.session.get({ sessionID: sessionID as never }))) as {
|
|
250
|
+
time?: { idle?: unknown }
|
|
251
|
+
}
|
|
252
|
+
idle = idleMillis(info?.time?.idle)
|
|
253
|
+
} catch {
|
|
254
|
+
return false
|
|
255
|
+
}
|
|
256
|
+
if (idle === undefined) return false
|
|
257
|
+
const path = `/api/session/${encodeURIComponent(sessionID)}`
|
|
258
|
+
const viewed = await call(`${path}/view`, { method: "POST", body: { idle } })
|
|
259
|
+
await call(path, { method: "PATCH", body: { archived: true } })
|
|
260
|
+
return viewed
|
|
261
|
+
}
|
|
262
|
+
|
|
201
263
|
/** Llamado por la herramienta del advisor para resolver una decisión pendiente. */
|
|
202
264
|
export function resolvePendingDecision(requestID: string, decision: "allow" | "deny", reason?: string): boolean {
|
|
203
265
|
const resolver = pending.get(requestID)
|
package/core/config.ts
CHANGED
|
@@ -285,6 +285,9 @@ const advisorConfigSchema = z.object({
|
|
|
285
285
|
// igual que un agente con el contexto completo (p. ej. Claude Code en modo auto).
|
|
286
286
|
conversationContext: z.boolean().default(true),
|
|
287
287
|
conversationMessages: z.number().int().positive().default(10),
|
|
288
|
+
// Al acabar un turno en el que decidió con su herramienta, la sesión advisor se
|
|
289
|
+
// marca leída (y se re-archiva) para no salir como "no leída" en la app.
|
|
290
|
+
markRead: z.boolean().default(true),
|
|
288
291
|
})
|
|
289
292
|
|
|
290
293
|
const guardRuleSchema = z.object({
|
package/core/server-endpoint.ts
CHANGED
|
@@ -224,6 +224,22 @@ export function resolveServerEndpoint(input: {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Password del servidor, para que el PROPIO plugin llame a rutas que la API de
|
|
229
|
+
* plugins no expone (p. ej. `session.view`). Se queda en el proceso: nunca va a
|
|
230
|
+
* una herramienta ni a la conversación. null si no se puede leer.
|
|
231
|
+
*/
|
|
232
|
+
export function readServerPassword(source: PasswordSource | null, env: NodeJS.ProcessEnv = process.env): string | null {
|
|
233
|
+
if (!source) return null
|
|
234
|
+
if (source.kind === "env") return (source.env && env[source.env]) || null
|
|
235
|
+
try {
|
|
236
|
+
const value = (JSON.parse(readFileSync(source.file!, "utf8")) as Record<string, unknown>)[source.field ?? "password"]
|
|
237
|
+
return typeof value === "string" && value.length > 0 ? value : null
|
|
238
|
+
} catch {
|
|
239
|
+
return null
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
227
243
|
/** curl listo para una llamada RPC (el password se lee al ejecutar, nunca va en claro). */
|
|
228
244
|
export function curlExample(endpoint: ServerEndpoint, method: "ingest" | "toolsRun", body: unknown): string {
|
|
229
245
|
const password = endpoint.auth.password?.shell ?? 'printenv OPENCODE_SERVER_PASSWORD'
|
package/cred.ts
CHANGED
|
@@ -124,35 +124,96 @@ export function scrubSecrets(value: unknown, store: CredStore, extra: readonly s
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* Marca de metadata para las respuestas de `/cred`: son para el USUARIO,
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
127
|
+
* Marca de metadata para las respuestas de `/cred`: son para el USUARIO, no
|
|
128
|
+
* parte de la conversación. El hook `context`/`compaction`/`generate` de este
|
|
129
|
+
* módulo las quita de cada petición (la metadata del mensaje guardado llega al
|
|
130
|
+
* hook y no se envía al modelo), junto con la respuesta que las mostró. Solo la
|
|
131
|
+
* petición del turno que abre la propia respuesta la conserva: es la que la
|
|
132
|
+
* pone en pantalla (ver `notify`).
|
|
133
133
|
*/
|
|
134
134
|
export const UI_ONLY_KEY = "apexUiOnly"
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Marca de aviso de acpbridge: en una sesión claude-*, su provider contesta él
|
|
138
|
+
* mismo, sin llamar a Claude y gratis, el turno que abre un mensaje que empieza
|
|
139
|
+
* así, con ese mismo texto, y lo deja fuera de la conversación con Claude. Es un
|
|
140
|
+
* comentario HTML: no se ve al renderizar el markdown.
|
|
141
|
+
*/
|
|
142
|
+
export const ACP_NOTICE = "<!-- acp-notice -->"
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Texto del synthetic de una respuesta de `/cred`. La app muestra un synthetic
|
|
146
|
+
* solo por su `description` (una línea), así que lo que el usuario lee es la
|
|
147
|
+
* respuesta del turno que el mensaje despierta: la de acpbridge en una sesión
|
|
148
|
+
* claude-* y, en cualquier otro modelo, el eco que pide el comentario.
|
|
149
|
+
*/
|
|
150
|
+
export function credNoticeText(text: string): string {
|
|
151
|
+
return [
|
|
152
|
+
ACP_NOTICE,
|
|
153
|
+
"<!-- apex /cred: respuesta para el usuario, no una petición. Repite el bloque siguiente tal cual y no añadas nada. -->",
|
|
154
|
+
"```text",
|
|
155
|
+
text,
|
|
156
|
+
"```",
|
|
157
|
+
].join("\n")
|
|
158
|
+
}
|
|
159
|
+
|
|
136
160
|
function notify(ctx: Plugin.Context, sessionID: string, text: string): Effect.Effect<void> {
|
|
137
161
|
return ctx.session
|
|
138
162
|
.synthetic({
|
|
139
163
|
sessionID,
|
|
140
|
-
text,
|
|
164
|
+
text: credNoticeText(text),
|
|
141
165
|
description: "apex cred",
|
|
142
166
|
metadata: { [UI_ONLY_KEY]: true },
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
resume: false,
|
|
167
|
+
// Un synthetic solo aparece cuando un turno lo saca de la bandeja: con
|
|
168
|
+
// resume:false esperaba al siguiente prompt y `/cred help` no mostraba
|
|
169
|
+
// nada. "queue": si hay un turno en curso, va como input propio al acabar.
|
|
170
|
+
delivery: "queue",
|
|
171
|
+
resume: true,
|
|
149
172
|
} as never)
|
|
150
173
|
.pipe(Effect.asVoid, Effect.catch(() => Effect.void))
|
|
151
174
|
}
|
|
152
175
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
176
|
+
type RequestMessageLike = {
|
|
177
|
+
readonly role?: string
|
|
178
|
+
readonly content?: unknown
|
|
179
|
+
readonly metadata?: Record<string, unknown>
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const isUiOnly = (m: RequestMessageLike | undefined): boolean => m?.metadata?.[UI_ONLY_KEY] === true
|
|
183
|
+
|
|
184
|
+
/** Respuesta del modelo hecha solo de texto: el eco de una respuesta de `/cred`. */
|
|
185
|
+
const isTextOnlyAnswer = (m: RequestMessageLike): boolean =>
|
|
186
|
+
m.role === "assistant" &&
|
|
187
|
+
(typeof m.content === "string" ||
|
|
188
|
+
(Array.isArray(m.content) &&
|
|
189
|
+
m.content.every((p: { type?: string }) => p?.type === "text" || p?.type === "reasoning")))
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Quita de los mensajes de una petición las respuestas de `/cred` y el eco que
|
|
193
|
+
* las mostró (la respuesta de solo texto que las sigue). Con `keepTrailing`, una
|
|
194
|
+
* respuesta que cierra la petición se conserva: es el turno que la muestra.
|
|
195
|
+
*/
|
|
196
|
+
export function dropUiOnlyMessages<T extends RequestMessageLike>(
|
|
197
|
+
messages: readonly T[],
|
|
198
|
+
options: { readonly keepTrailing?: boolean } = {},
|
|
199
|
+
): T[] {
|
|
200
|
+
const last = messages.findLastIndex((m) => m?.role !== "system")
|
|
201
|
+
const kept: T[] = []
|
|
202
|
+
let echo = false
|
|
203
|
+
messages.forEach((m, i) => {
|
|
204
|
+
if (isUiOnly(m)) {
|
|
205
|
+
if (options.keepTrailing && i === last) kept.push(m)
|
|
206
|
+
echo = true
|
|
207
|
+
return
|
|
208
|
+
}
|
|
209
|
+
if (echo && isTextOnlyAnswer(m)) {
|
|
210
|
+
echo = false
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
echo = false
|
|
214
|
+
kept.push(m)
|
|
215
|
+
})
|
|
216
|
+
return kept
|
|
156
217
|
}
|
|
157
218
|
|
|
158
219
|
/** Manual de `/cred`, solo para el usuario (va con la marca UI-only). */
|
|
@@ -162,7 +223,7 @@ Qué hace
|
|
|
162
223
|
Guarda credenciales en tu máquina y las redacta del contexto del modelo: si
|
|
163
224
|
el valor aparece en un mensaje o en la salida de una herramienta, el modelo
|
|
164
225
|
ve [SECRET:…] en su lugar. El agente puede USAR una credencial (herramienta
|
|
165
|
-
apex_cred) sin llegar a ver el valor. Este manual no
|
|
226
|
+
apex_cred) sin llegar a ver el valor. Este manual no queda en el contexto.
|
|
166
227
|
|
|
167
228
|
Guardar
|
|
168
229
|
/cred set NOMBRE=VALOR valor literal (queda en el historial del terminal)
|
|
@@ -581,15 +642,15 @@ export function register(
|
|
|
581
642
|
const pending = new Map<string, { name: string; value: string }>()
|
|
582
643
|
const handles = new Map<string, CredHandle>()
|
|
583
644
|
|
|
584
|
-
// Respuestas de /cred (manual, listados, avisos):
|
|
585
|
-
//
|
|
586
|
-
// el resumen no las arrastre al contexto.
|
|
645
|
+
// Respuestas de /cred (manual, listados, avisos): fuera de toda petición al
|
|
646
|
+
// modelo salvo la del turno que las muestra — también de la compactación,
|
|
647
|
+
// para que el resumen no las arrastre al contexto.
|
|
587
648
|
for (const hookName of ["context", "compaction", "generate"] as const) {
|
|
588
649
|
yield* ctx.session.hook(hookName, (event) =>
|
|
589
650
|
Effect.suspend(() => {
|
|
590
|
-
const e = event as unknown as { messages?: Array<
|
|
651
|
+
const e = event as unknown as { messages?: Array<RequestMessageLike> }
|
|
591
652
|
if (!Array.isArray(e.messages)) return Effect.void
|
|
592
|
-
const kept = dropUiOnlyMessages(e.messages)
|
|
653
|
+
const kept = dropUiOnlyMessages(e.messages, { keepTrailing: hookName === "context" })
|
|
593
654
|
const dropped = e.messages.length - kept.length
|
|
594
655
|
e.messages = kept
|
|
595
656
|
// Effect.log (no console.*): es lo único que llega al log del servidor.
|
package/docs/ADVISOR.md
CHANGED
|
@@ -91,6 +91,12 @@ the original permission is left untouched: you get the normal prompt.
|
|
|
91
91
|
never need to open it by hand. It still exists and is still a real audit trail; it just
|
|
92
92
|
doesn't show up in the default list. (If you want to see it, unarchive it; the distinctive
|
|
93
93
|
title makes it identifiable in any view.)
|
|
94
|
+
- **Marked read when it decides.** Every request runs a turn in the advisor session, and the
|
|
95
|
+
app would flag each one as unread. When the advisor answers with `apex_advisor_decide` and
|
|
96
|
+
its turn ends, apex marks the session read and archives it again (a prompt unarchives it).
|
|
97
|
+
A turn that ends without a decision (the model only wrote text, or failed) stays unread:
|
|
98
|
+
that one is worth a look. Off with `markRead: false`. The plugin API has no call for this,
|
|
99
|
+
so apex uses its own server's HTTP API with the service password, read in-process.
|
|
94
100
|
|
|
95
101
|
## `decisive`
|
|
96
102
|
|
|
@@ -116,6 +122,7 @@ The advisor module is **on by default** (`modules.advisor`). Set `"advisor": fal
|
|
|
116
122
|
"processContext": true, // describe the processes a kill/pkill/killall would hit (Linux)
|
|
117
123
|
"conversationContext": true, // include your last chat messages — see below
|
|
118
124
|
"conversationMessages": 10, // how many of your messages to include
|
|
125
|
+
"markRead": true, // mark the advisor session read after a turn that decided
|
|
119
126
|
"system": "…", // optional: replaces the advisor's system prompt
|
|
120
127
|
"promptTemplate": "…", // optional: the request text sent to the advisor
|
|
121
128
|
"promptTemplateFile": "…" // optional: same, from a file (wins over promptTemplate)
|
package/docs/CRED.md
CHANGED
|
@@ -30,14 +30,16 @@ Dos superficies:
|
|
|
30
30
|
|
|
31
31
|
Notas:
|
|
32
32
|
|
|
33
|
-
- **Las respuestas de `/cred`
|
|
34
|
-
`synthetic` con `metadata.apexUiOnly`,
|
|
35
|
-
`
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
- **Las respuestas de `/cred` se muestran al momento y no quedan en el contexto.**
|
|
34
|
+
Son mensajes `synthetic` con `metadata.apexUiOnly`, entregados con
|
|
35
|
+
`delivery: "queue"` y `resume: true`: la sesión corre un turno que los pone en
|
|
36
|
+
pantalla (la app solo enseña la `description` de un synthetic, así que el texto
|
|
37
|
+
llega como respuesta de ese turno). En una sesión claude-* lo contesta acpbridge,
|
|
38
|
+
gratis y tal cual (el texto empieza por `<!-- acp-notice -->`); en otro modelo,
|
|
39
|
+
un comentario HTML le pide repetir el bloque. Solo la petición de ese turno
|
|
40
|
+
lleva la respuesta: en las siguientes, en las compactaciones y en `generate` el
|
|
41
|
+
módulo quita la respuesta y el eco. Con el servidor en `--log-level debug`, cada
|
|
42
|
+
descarte deja `[apex.cred] context: N respuesta(s) de /cred fuera de la petición`.
|
|
41
43
|
- El TUI no enmascara la entrada: `/cred set nombre=valor` puede quedar en
|
|
42
44
|
historial del terminal. Preferir `--from-env` o `--from-file`.
|
|
43
45
|
- `set` acepta URIs como `ssh://user:pass@host:22`; apex extrae
|
package/index.ts
CHANGED
|
@@ -35,7 +35,7 @@ import { registerTempAccess } from "./core/temp-access.js"
|
|
|
35
35
|
import { register as registerEndpoints } from "./endpoints.js"
|
|
36
36
|
|
|
37
37
|
// Plugin version
|
|
38
|
-
const VERSION = "0.8.
|
|
38
|
+
const VERSION = "0.8.1"
|
|
39
39
|
|
|
40
40
|
interface ModuleConfigs {
|
|
41
41
|
redact: RedactConfig & { enabled: boolean }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-apex",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Modular plugin for OpenCode V2 (>= 2.1): secret redaction, RPC callbacks/webhooks/watchers that wake agents, OpenTunnel endpoints + verified webhooks (cross-platform daemon), tools.run, AI permission advisor, guard meta-permissions, temp-directory access",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Antonio Orizondo Leyva",
|