opencode-apex 0.2.1 → 0.2.2
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 +80 -48
- package/LICENSE +21 -0
- package/README.md +299 -151
- package/browser/endpoint.ts +4 -1
- package/browser.ts +2 -1
- package/core/compat.ts +6 -6
- package/core/config.ts +14 -3
- package/core/crypto.ts +2 -1
- package/core/rpc.ts +1 -1
- package/core/server-endpoint.ts +1 -1
- package/core/tools-run.ts +7 -7
- package/docs/ADVISOR.md +129 -71
- package/docs/BROWSER.md +185 -158
- package/docs/CONFIG.md +145 -55
- package/docs/EVENTS.md +206 -89
- package/docs/GUARD.md +142 -104
- package/docs/REDACT.md +143 -89
- package/docs/TROUBLESHOOTING.md +225 -190
- package/events.ts +28 -22
- package/index.ts +9 -2
- package/opencode-apex.jsonc +150 -132
- package/package.json +32 -6
- package/redact.ts +5 -4
- package/skills/apex-callbacks/SKILL.md +129 -123
package/opencode-apex.jsonc
CHANGED
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
// ==========================================================================
|
|
3
|
-
// opencode-apex —
|
|
3
|
+
// opencode-apex — complete annotated example configuration
|
|
4
|
+
// (OpenCode V2 only, 2.1 or newer)
|
|
4
5
|
//
|
|
5
|
-
//
|
|
6
|
-
// 1.
|
|
7
|
-
// 2.
|
|
8
|
-
// 3.
|
|
9
|
-
//
|
|
10
|
-
//
|
|
6
|
+
// WHERE SETTINGS COME FROM (lowest to highest priority):
|
|
7
|
+
// 1. GLOBAL file ~/.config/opencode/opencode-apex.jsonc
|
|
8
|
+
// 2. inline plugin options in opencode.json { "plugins": [{ "package": "opencode-apex", "options": {…} }] }
|
|
9
|
+
// 3. LOCAL file <project>/.opencode/opencode-apex.jsonc ← like this one
|
|
10
|
+
// Rule: scope wins (local over global) and, within a scope, the file wins
|
|
11
|
+
// over the inline options ⇒ inline options override the global file but
|
|
12
|
+
// are overridden by the local file. Objects merge; arrays are REPLACED.
|
|
11
13
|
//
|
|
12
|
-
//
|
|
14
|
+
// COMMENTS: #, // and /* */ are accepted (a # inside a string is kept).
|
|
15
|
+
// Strings cannot span lines: write line breaks as \n. Regex backslashes are
|
|
16
|
+
// doubled: \\b.
|
|
13
17
|
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
18
|
+
// TEMPLATES (events.subscriptions[].promptTemplateFile, advisor.promptTemplateFile):
|
|
19
|
+
// relative paths only — to the project ("prompts/x.md") or to home ("~/x.md").
|
|
20
|
+
// Absolute paths and ../ escapes are rejected; a missing file is CREATED
|
|
21
|
+
// with the default template.
|
|
17
22
|
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
23
|
+
// Every field is optional: with no source at all the plugin starts with the
|
|
24
|
+
// defaults. Environment variables in this file: ${VAR}, ${VAR:-default} or
|
|
25
|
+
// $VAR. (A ${VAR} that is not set invalidates the config → all defaults; use
|
|
26
|
+
// ${VAR:-} for an empty fallback.) {env:VAR} is OpenCode syntax and only
|
|
27
|
+
// works inside opencode.json.
|
|
20
28
|
// ==========================================================================
|
|
21
29
|
|
|
22
30
|
// --------------------------------------------------------------------------
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
31
|
+
// Modules: turn each one on or off.
|
|
32
|
+
// SINGLE SWITCH: it lives ONLY here — there is no <module>.enabled.
|
|
33
|
+
// An omitted key means the module's default: all ON except guard (OFF).
|
|
26
34
|
// --------------------------------------------------------------------------
|
|
27
35
|
"modules": {
|
|
28
36
|
"redact": true,
|
|
@@ -34,33 +42,35 @@
|
|
|
34
42
|
|
|
35
43
|
|
|
36
44
|
// --------------------------------------------------------------------------
|
|
37
|
-
// redact —
|
|
45
|
+
// redact — keep secrets away from the model by encrypting them (AES-256-GCM).
|
|
38
46
|
//
|
|
39
|
-
//
|
|
40
|
-
// ${prefix}${
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
47
|
+
// Each match is encrypted and replaced by a readable marker:
|
|
48
|
+
// ${prefix}${patternName}:${base64url(iv||tag||ciphertext)}${suffix}
|
|
49
|
+
// e.g. [SECRET:github-pat:AbC123...]
|
|
50
|
+
// Restoring decrypts the marker itself (there is no in-memory mapping).
|
|
51
|
+
// Redaction applies only to what is sent to the model ("context" hook);
|
|
52
|
+
// restoration only to tool arguments ("execute.before" hook). Model answers
|
|
53
|
+
// are not restored: you see the readable marker.
|
|
46
54
|
//
|
|
47
|
-
// patterns:
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
55
|
+
// patterns: your own regexes (added on top of the bundles); each is named
|
|
56
|
+
// custom-<index> and is always active
|
|
57
|
+
// bundles: named groups of detectors. Setting this REPLACES the default
|
|
58
|
+
// list. Default (38): aws, github, gitlab, slack, jwt, pem,
|
|
59
|
+
// bearer, env, openai, anthropic, google, stripe, npm, database,
|
|
51
60
|
// azure, terraform, vault, heroku, vercel, supabase, digitalocean,
|
|
52
61
|
// cloudflare, observability, pypi, rubygems, twilio, sendgrid,
|
|
53
62
|
// postman, mailgun, mailchimp, linear, shopify, square, docker,
|
|
54
63
|
// kubernetes, cohere, huggingface, discord.
|
|
55
|
-
// Opt-in (
|
|
56
|
-
// minConfidence: low | medium | high —
|
|
57
|
-
// allowlist:
|
|
58
|
-
// key: material
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
+
// Opt-in (noisy / personal data, NOT on by default): pii, network, datadog.
|
|
65
|
+
// minConfidence: low | medium | high — drops noisy detectors (default medium)
|
|
66
|
+
// allowlist: regexes tested against each matched secret; matches stay in clear
|
|
67
|
+
// key: key material -> literal | env:VAR | file:/absolute/path | hex:... | base64:...
|
|
68
|
+
// (file: does not expand ~). Empty → the APEX_REDACT_KEY variable.
|
|
69
|
+
// If nothing resolves, the key saved in ~/.config/opencode/apex.key
|
|
70
|
+
// is reused, or a random one is generated there (0600).
|
|
71
|
+
// Changing the key orphans markers made with the old one.
|
|
72
|
+
// mode: "strict" (replaces) | "warn" (only logs)
|
|
73
|
+
// restore: which outputs are decrypted (only tool input for now)
|
|
64
74
|
// --------------------------------------------------------------------------
|
|
65
75
|
"redact": {
|
|
66
76
|
"mode": "strict",
|
|
@@ -75,44 +85,50 @@
|
|
|
75
85
|
},
|
|
76
86
|
|
|
77
87
|
// --------------------------------------------------------------------------
|
|
78
|
-
// events —
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
88
|
+
// events — wake an agent from outside the conversation: callbacks, webhooks,
|
|
89
|
+
// scheduled checks. An external process calls the OpenCode server's RPC
|
|
90
|
+
// endpoint; matching subscriptions deliver the event to a session.
|
|
91
|
+
// routing: "all" (fan-out to every matching subscription) | "first" (only the
|
|
92
|
+
// highest priority one)
|
|
93
|
+
// Each subscription filters events and delivers them to a session. The text
|
|
94
|
+
// comes from promptTemplate (inline) or promptTemplateFile (wins).
|
|
95
|
+
// Placeholders: {{payload.field}}, {{source}}, {{type}}, {{eventID}}.
|
|
96
|
+
// agent: switch the target session to this agent before delivering (optional).
|
|
97
|
+
// deliverAs: "prompt" (a user prompt: starts a turn; default) | "synthetic".
|
|
98
|
+
// resume: ONLY with deliverAs="synthetic". true → wakes the agent loop and
|
|
99
|
+
// the model processes the message; false → passive, it waits for
|
|
100
|
+
// the next turn (default false).
|
|
87
101
|
// sessionID:
|
|
88
|
-
// - "" / null /
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
// - "ses_xxx" →
|
|
94
|
-
//
|
|
102
|
+
// - "" / null / missing → AUTO-BINDING to the active main session of THIS
|
|
103
|
+
// project: the root session you work in. Never the advisor, the
|
|
104
|
+
// tools.run runner, or subagent sessions (parentID).
|
|
105
|
+
// When that session is deleted the subscription is UNBOUND; the next
|
|
106
|
+
// main session binds it again.
|
|
107
|
+
// - "ses_xxx" → that session (if it does not exist, delivery fails and is logged).
|
|
108
|
+
// The examples below have "enabled": false.
|
|
95
109
|
// operator: equals | contains | matches | gt | lt | in | notIn | exists | notExists
|
|
96
|
-
// delivery: "queue" (
|
|
110
|
+
// delivery: "queue" (waits its turn) | "steer" (injected into the running turn)
|
|
97
111
|
// --------------------------------------------------------------------------
|
|
98
112
|
"events": {
|
|
99
113
|
"routing": "all",
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
//
|
|
114
|
+
// Everything enters through the server's RPC (POST /api/rpc/apex/<method>,
|
|
115
|
+
// HTTP Basic auth). There is no listener of its own: OpenCode unloads plugins
|
|
116
|
+
// after 60 min without activity, and an RPC call loads the project again.
|
|
117
|
+
// Webhooks → a relay (n8n, a small daemon) that turns the HTTP call into
|
|
118
|
+
// events.ingest (see the apex-callbacks skill and docs/EVENTS.md).
|
|
104
119
|
"server": {
|
|
105
|
-
// URL
|
|
106
|
-
//
|
|
120
|
+
// Base URL of the server for local scripts. Empty = discover it (the
|
|
121
|
+
// background service record, or --port of `opencode serve`). Set it when
|
|
122
|
+
// the server sits behind a proxy.
|
|
107
123
|
"url": "",
|
|
108
|
-
// URL
|
|
109
|
-
//
|
|
124
|
+
// Public URL (tunnel/proxy) for senders on other machines. The agent can
|
|
125
|
+
// set it at runtime with apex_set_callback_url (precedence: runtime > config).
|
|
110
126
|
"publicUrl": ""
|
|
111
127
|
},
|
|
112
|
-
// RPC apex/tools.run:
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
128
|
+
// RPC apex/tools.run: an external process runs one OpenCode tool (built-in,
|
|
129
|
+
// from a plugin, or MCP) without a model. deny wins over allow; then the
|
|
130
|
+
// permissions of `agent` (or the agent passed in the call) decide. With
|
|
131
|
+
// nobody watching, an "ask" waits for the advisor or until timeoutMs.
|
|
116
132
|
"tools": {
|
|
117
133
|
"enabled": true,
|
|
118
134
|
"allow": ["*"],
|
|
@@ -126,7 +142,8 @@
|
|
|
126
142
|
"agent": "plan",
|
|
127
143
|
"filters": [
|
|
128
144
|
{ "field": "type", "operator": "equals", "value": "ci.failed" },
|
|
129
|
-
|
|
145
|
+
// `in` compares exact values; for prefixes or wildcards use `matches` with a regex.
|
|
146
|
+
{ "field": "payload.branch", "operator": "matches", "pattern": "^(main|release/.+)$" }
|
|
130
147
|
],
|
|
131
148
|
"promptTemplate": "CI failed on {{payload.branch}} ({{payload.commit}}). Investigate and propose a fix.",
|
|
132
149
|
"promptTemplateFile": "prompts/ci-failure.md",
|
|
@@ -138,7 +155,7 @@
|
|
|
138
155
|
{
|
|
139
156
|
"sessionID": "",
|
|
140
157
|
"filters": [{ "field": "type", "operator": "matches", "pattern": "^deploy\\." }],
|
|
141
|
-
"promptTemplate": "Deploy
|
|
158
|
+
"promptTemplate": "Deploy detected: {{payload.env}}",
|
|
142
159
|
"deliverAs": "synthetic",
|
|
143
160
|
"resume": true,
|
|
144
161
|
"delivery": "steer",
|
|
@@ -151,57 +168,59 @@
|
|
|
151
168
|
|
|
152
169
|
|
|
153
170
|
// --------------------------------------------------------------------------
|
|
154
|
-
// browser —
|
|
171
|
+
// browser — serves the browser.* tools against an EXTERNAL Chromium over CDP
|
|
172
|
+
// (Chrome DevTools Protocol).
|
|
155
173
|
//
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
174
|
+
// OpenCode's browser plugin already registers those tools, but they only work
|
|
175
|
+
// when something attaches a browser. On a server without the desktop app
|
|
176
|
+
// nothing does, and every call fails with "browser is disconnected". This
|
|
177
|
+
// module attaches a real browser and serves them.
|
|
160
178
|
//
|
|
161
179
|
// mode:
|
|
162
|
-
// "auto" (default)
|
|
163
|
-
//
|
|
164
|
-
//
|
|
180
|
+
// "auto" (default) and "external": attach only when asked to — by the
|
|
181
|
+
// agent (tool browser.target) or by you (/browser-target), never
|
|
182
|
+
// on every tool call. No surprises.
|
|
183
|
+
// "in-app" never attaches, and releases any attachment so the desktop
|
|
184
|
+
// app can serve the session.
|
|
165
185
|
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
186
|
+
// MIND THE CONFLICT: the protocol allows ONE attachment per session (each
|
|
187
|
+
// attach replaces the previous one). The plugin and the Electron desktop app
|
|
188
|
+
// never serve the same session at once; the loser sees "browser.disconnected".
|
|
189
|
+
// Switch at runtime with the browser.target tool or /browser-target.
|
|
170
190
|
//
|
|
171
|
-
// cdpUrl: "auto" (
|
|
172
|
-
// | "
|
|
173
|
-
// profile:
|
|
174
|
-
// ai.opencode.desktop
|
|
175
|
-
//
|
|
176
|
-
// headers/caFile/insecureSkipVerify:
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
// cloudflared, nginx)
|
|
191
|
+
// cdpUrl: "auto" (reads DevToolsActivePort from known profiles)
|
|
192
|
+
// | "port" | "ws://host:port/path" | "wss://…" for a remote browser
|
|
193
|
+
// profile: explicit profile directory. "" = detect. Pointing this at
|
|
194
|
+
// ai.opencode.desktop requires the Electron app to be CLOSED: two
|
|
195
|
+
// processes on the same user-data-dir corrupt the cookie SQLite.
|
|
196
|
+
// headers/caFile/insecureSkipVerify: for a remote wss:// behind a reverse
|
|
197
|
+
// proxy. Chrome's native CDP speaks neither TLS nor headers, so a
|
|
198
|
+
// browser on another machine needs a tunnel in front (ssh -L,
|
|
199
|
+
// tailscale, cloudflared, nginx).
|
|
180
200
|
//
|
|
181
|
-
//
|
|
182
|
-
//
|
|
201
|
+
// THIS IS THE DEFAULT, NOT THE ONLY OPTION. browser.target and /browser-target
|
|
202
|
+
// accept a target and override the config at runtime:
|
|
183
203
|
// browser.target({ mode: "external", cdpUrl: "9333" })
|
|
184
204
|
// browser.target({ mode: "external", profile: "~/.config/google-chrome" })
|
|
185
205
|
// /browser-target external 9333
|
|
186
206
|
// /browser-target external wss://tunnel.example/devtools
|
|
187
|
-
//
|
|
188
|
-
//
|
|
189
|
-
// attachments;
|
|
190
|
-
//
|
|
191
|
-
// enganche es siempre a petición, nunca en cada tool call).
|
|
207
|
+
// A target starting with / or ~ is a profile; anything else is a URL or port.
|
|
208
|
+
// Omitting it keeps the current one. Changing it closes the socket and drops
|
|
209
|
+
// the attachments; the session that changed it re-attaches in the same call
|
|
210
|
+
// and the others ask again with browser.target or /browser-target.
|
|
192
211
|
//
|
|
193
|
-
//
|
|
194
|
-
// --remote-debugging-port → /json/version
|
|
195
|
-
// user-data-dir
|
|
196
|
-
//
|
|
197
|
-
// chrome://inspect/#remote-debugging (toggle) → /json/version
|
|
198
|
-
//
|
|
199
|
-
// debugging?"
|
|
200
|
-
//
|
|
212
|
+
// CHROME MODES THAT MATTER:
|
|
213
|
+
// --remote-debugging-port → /json/version answers 200. IGNORED on the
|
|
214
|
+
// default user-data-dir since Chrome 136, so it needs its own profile.
|
|
215
|
+
// No popup.
|
|
216
|
+
// chrome://inspect/#remote-debugging (toggle) → /json/version answers 404
|
|
217
|
+
// BY DESIGN and the URL comes from DevToolsActivePort. It shows an
|
|
218
|
+
// "Allow remote debugging?" popup FOR EACH CONNECTION. The socket stays
|
|
219
|
+
// open, but reloading the plugin asks again.
|
|
201
220
|
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
221
|
+
// Several profiles can declare the same port (the files go stale when Chrome
|
|
222
|
+
// closes), so they are tried in order and the first that really answers
|
|
223
|
+
// wins. That is why connecting can take a while.
|
|
205
224
|
// --------------------------------------------------------------------------
|
|
206
225
|
"browser": {
|
|
207
226
|
"mode": "auto",
|
|
@@ -216,27 +235,31 @@
|
|
|
216
235
|
|
|
217
236
|
|
|
218
237
|
// --------------------------------------------------------------------------
|
|
219
|
-
// advisor —
|
|
238
|
+
// advisor — permission decisions made by a dedicated advisor session.
|
|
220
239
|
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
//
|
|
225
|
-
//
|
|
240
|
+
// The plugin defines (upserts) the hidden agent "apex-advisor" with its own
|
|
241
|
+
// model and permissions: it can ONLY use the apex_advisor_decide tool.
|
|
242
|
+
// There is ONE advisor session per session TREE: your root session and all
|
|
243
|
+
// its subagents share it, and it is kept whole → a full audit trail of every
|
|
244
|
+
// allow/deny.
|
|
226
245
|
//
|
|
227
|
-
//
|
|
228
|
-
// model:
|
|
229
|
-
// decisive: true =
|
|
230
|
-
//
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
246
|
+
// Vocabulary: approve = "allow"; deny = "deny" + reason.
|
|
247
|
+
// model: the advisor's model (fast/cheap; it runs with full context)
|
|
248
|
+
// decisive: true = its decision is applied to the permission · false = advisory only
|
|
249
|
+
// (default false)
|
|
250
|
+
// evaluate: "ask-only" (default) only when your rules did not decide ·
|
|
251
|
+
// "all" consults it on EVERY tool call
|
|
252
|
+
// timeoutMs: no decision in time → the permission is left as it was (never blocks)
|
|
253
|
+
// (default 10000)
|
|
254
|
+
// location: directory of the advisor session. Default: a dedicated one
|
|
255
|
+
// OUTSIDE the project (<tmp>/opencode-apex-advisor). Instruction
|
|
256
|
+
// discovery is per location, so the repo's AGENTS.md is not
|
|
257
|
+
// injected. (The global AGENTS.md in ~/.config/opencode always applies.)
|
|
258
|
+
// actions: filter by tool name (empty = all)
|
|
259
|
+
// system: system prompt of the advisor agent (optional)
|
|
260
|
+
// promptTemplate: template of each request ({{requestID}}, {{action}}, {{resources}},
|
|
261
|
+
// {{sessionID}}, {{agent}}, {{enforcement}}, {{metadata.<field>}}). A single-line JSON
|
|
262
|
+
// string: write line breaks as \n.
|
|
240
263
|
// --------------------------------------------------------------------------
|
|
241
264
|
"advisor": {
|
|
242
265
|
"model": "opencode/big-pickle",
|
|
@@ -245,12 +268,7 @@
|
|
|
245
268
|
"timeoutMs": 10000,
|
|
246
269
|
"location": "",
|
|
247
270
|
"actions": [],
|
|
248
|
-
"promptTemplate": "
|
|
249
|
-
Tool: {{action}}
|
|
250
|
-
Recursos: {{resources}}
|
|
251
|
-
Sesión: {{sessionID}} ({{agent}})
|
|
252
|
-
{{enforcement}}
|
|
253
|
-
Decidí con apex_advisor_decide."
|
|
271
|
+
"promptTemplate": "Request {{requestID}}\nTool: {{action}}\nResources: {{resources}}\nSession: {{sessionID}} ({{agent}})\n{{enforcement}}\nDecide with apex_advisor_decide."
|
|
254
272
|
}
|
|
255
273
|
|
|
256
274
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-apex",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Modular
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Modular plugin for OpenCode V2 (>= 2.1): secret redaction, RPC callbacks/webhooks/watchers that wake agents, tools.run, AI permission advisor, guard meta-permissions, external browser over CDP",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Antonio Orizondo Leyva",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/aorizondo/opencode-apex.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/aorizondo/opencode-apex#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/aorizondo/opencode-apex/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"opencode",
|
|
17
|
+
"opencode-plugin",
|
|
18
|
+
"opencode-v2",
|
|
19
|
+
"plugin",
|
|
20
|
+
"redaction",
|
|
21
|
+
"secrets",
|
|
22
|
+
"webhooks",
|
|
23
|
+
"callbacks",
|
|
24
|
+
"rpc",
|
|
25
|
+
"automation",
|
|
26
|
+
"permissions",
|
|
27
|
+
"cdp",
|
|
28
|
+
"browser"
|
|
29
|
+
],
|
|
7
30
|
"engines": {
|
|
8
|
-
"opencode": ">=2.
|
|
31
|
+
"opencode": ">=2.1.0"
|
|
9
32
|
},
|
|
33
|
+
"type": "module",
|
|
34
|
+
"main": "index.ts",
|
|
10
35
|
"files": [
|
|
11
36
|
"index.ts",
|
|
12
37
|
"redact.ts",
|
|
@@ -19,7 +44,8 @@
|
|
|
19
44
|
"docs",
|
|
20
45
|
"opencode-apex.jsonc",
|
|
21
46
|
"skills",
|
|
22
|
-
"CHANGELOG.md"
|
|
47
|
+
"CHANGELOG.md",
|
|
48
|
+
"LICENSE"
|
|
23
49
|
],
|
|
24
50
|
"dependencies": {
|
|
25
51
|
"@opencode/plugin": "^2.1.1",
|
package/redact.ts
CHANGED
|
@@ -57,6 +57,7 @@ export function createDefaultRedactConfig(): RedactConfig & { enabled: boolean }
|
|
|
57
57
|
export interface CompiledRedact {
|
|
58
58
|
readonly engine: RedactEngine
|
|
59
59
|
readonly patterns: PatternDefinition[]
|
|
60
|
+
readonly allowlist: RegExp[]
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
export function compileRedactConfig(config: RedactConfig): CompiledRedact {
|
|
@@ -85,7 +86,7 @@ export function compileRedactConfig(config: RedactConfig): CompiledRedact {
|
|
|
85
86
|
},
|
|
86
87
|
})
|
|
87
88
|
|
|
88
|
-
return { engine, patterns }
|
|
89
|
+
return { engine, patterns, allowlist }
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
// ---------------------------------------------------------------------------
|
|
@@ -99,18 +100,18 @@ export function register(
|
|
|
99
100
|
return Effect.gen(function* () {
|
|
100
101
|
if (!config.enabled) return
|
|
101
102
|
|
|
102
|
-
const { engine, patterns } = compileRedactConfig(config)
|
|
103
|
+
const { engine, patterns, allowlist } = compileRedactConfig(config)
|
|
103
104
|
const key = resolveKey(config.key).key
|
|
104
105
|
|
|
105
106
|
// Motores precompilados para el RPC (evita recompilar y re-resolver la clave
|
|
106
107
|
// en cada llamada).
|
|
107
108
|
const rpcEngines = {
|
|
108
109
|
strict: createRedactEngine({
|
|
109
|
-
patterns, allowlist
|
|
110
|
+
patterns, allowlist, prefix: config.prefix, suffix: config.suffix,
|
|
110
111
|
key, mode: "strict", onFinding: (f) => rpcFindings.push({ pattern: f.pattern }),
|
|
111
112
|
}),
|
|
112
113
|
warn: createRedactEngine({
|
|
113
|
-
patterns, allowlist
|
|
114
|
+
patterns, allowlist, prefix: config.prefix, suffix: config.suffix,
|
|
114
115
|
key, mode: "warn", onFinding: (f) => rpcFindings.push({ pattern: f.pattern }),
|
|
115
116
|
}),
|
|
116
117
|
}
|