@taewooopark/agent-blackbox 0.44.0 → 0.46.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.
|
@@ -81,6 +81,7 @@ function createTraceEvent(seq, input) {
|
|
|
81
81
|
runId: input.runId,
|
|
82
82
|
sessionId: input.sessionId,
|
|
83
83
|
...input.parentSessionId ? { parentSessionId: input.parentSessionId } : {},
|
|
84
|
+
...input.cwd ? { cwd: input.cwd } : {},
|
|
84
85
|
...input.agentId ? { agentId: input.agentId } : {},
|
|
85
86
|
...input.agentRole ? { agentRole: input.agentRole } : {},
|
|
86
87
|
...input.turnId ? { turnId: input.turnId } : {},
|
|
@@ -111,6 +112,9 @@ function validateTraceEvent(event) {
|
|
|
111
112
|
requireEnum(event, "host", traceHosts, errors);
|
|
112
113
|
requireString(event, "runId", errors);
|
|
113
114
|
requireString(event, "sessionId", errors);
|
|
115
|
+
if (event.cwd !== void 0 && typeof event.cwd !== "string") {
|
|
116
|
+
errors.push("cwd must be a string when present");
|
|
117
|
+
}
|
|
114
118
|
requireEnum(event, "kind", traceEventKinds, errors);
|
|
115
119
|
requireEnum(event, "sensitivity", dataSensitivities, errors);
|
|
116
120
|
if (!isRecord(event.payload)) {
|
|
@@ -168,16 +172,16 @@ var defaultRedactionRules = [
|
|
|
168
172
|
pattern: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{20,}\b/g,
|
|
169
173
|
replacement: "[REDACTED_GITHUB_TOKEN]"
|
|
170
174
|
},
|
|
171
|
-
{
|
|
172
|
-
name: "openai-key",
|
|
173
|
-
pattern: /\bsk-[A-Za-z0-9_-]{20,}\b/g,
|
|
174
|
-
replacement: "[REDACTED_OPENAI_KEY]"
|
|
175
|
-
},
|
|
176
175
|
{
|
|
177
176
|
name: "anthropic-key",
|
|
178
177
|
pattern: /\bsk-ant-[A-Za-z0-9_-]{20,}\b/g,
|
|
179
178
|
replacement: "[REDACTED_ANTHROPIC_KEY]"
|
|
180
179
|
},
|
|
180
|
+
{
|
|
181
|
+
name: "openai-key",
|
|
182
|
+
pattern: /\bsk-[A-Za-z0-9_-]{20,}\b/g,
|
|
183
|
+
replacement: "[REDACTED_OPENAI_KEY]"
|
|
184
|
+
},
|
|
181
185
|
{
|
|
182
186
|
name: "private-key",
|
|
183
187
|
pattern: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
|
|
@@ -195,12 +199,12 @@ function redactJsonValue(value, options = {}) {
|
|
|
195
199
|
const visit = (current) => {
|
|
196
200
|
if (typeof current === "string") {
|
|
197
201
|
let next = current;
|
|
198
|
-
if (options.homeDir) {
|
|
199
|
-
next = replaceLiteral(next, options.homeDir, "~", "home-dir", applied);
|
|
200
|
-
}
|
|
201
202
|
if (options.projectDir) {
|
|
202
203
|
next = replaceLiteral(next, options.projectDir, "$PROJECT", "project-dir", applied);
|
|
203
204
|
}
|
|
205
|
+
if (options.homeDir) {
|
|
206
|
+
next = replaceLiteral(next, options.homeDir, "~", "home-dir", applied);
|
|
207
|
+
}
|
|
204
208
|
for (const rule of rules) {
|
|
205
209
|
if (rule.pattern.test(next)) {
|
|
206
210
|
applied.add(rule.name);
|
|
@@ -618,7 +622,9 @@ function sanitizeJson(value, seen) {
|
|
|
618
622
|
return "[Circular]";
|
|
619
623
|
}
|
|
620
624
|
seen.add(value);
|
|
621
|
-
|
|
625
|
+
const mapped = value.map((item) => sanitizeJson(item, seen));
|
|
626
|
+
seen.delete(value);
|
|
627
|
+
return mapped;
|
|
622
628
|
}
|
|
623
629
|
if (typeof value === "object") {
|
|
624
630
|
if (seen.has(value)) {
|
|
@@ -632,6 +638,7 @@ function sanitizeJson(value, seen) {
|
|
|
632
638
|
}
|
|
633
639
|
output[key] = sanitizeJson(nested, seen);
|
|
634
640
|
}
|
|
641
|
+
seen.delete(value);
|
|
635
642
|
return output;
|
|
636
643
|
}
|
|
637
644
|
return String(value);
|
|
@@ -851,18 +858,24 @@ async function appendTraceEvent(filePath, event) {
|
|
|
851
858
|
// packages/opencode-adapter/dist/sink.js
|
|
852
859
|
import { join } from "node:path";
|
|
853
860
|
function createTraceSink(options) {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
+
const base = options.sink ? options.sink : options.daemonUrl ? createHttpTraceSink(options.daemonUrl) : createFileTraceSink(options.eventsFile ?? join(options.directory, ".agent-blackbox", "events.ndjson"));
|
|
862
|
+
return {
|
|
863
|
+
async write(event) {
|
|
864
|
+
if (!event.cwd && options.directory) {
|
|
865
|
+
event.cwd = options.directory;
|
|
866
|
+
}
|
|
867
|
+
await base.write(event);
|
|
868
|
+
}
|
|
869
|
+
};
|
|
861
870
|
}
|
|
862
871
|
function createFileTraceSink(eventsFile) {
|
|
863
872
|
return {
|
|
864
873
|
async write(event) {
|
|
865
|
-
|
|
874
|
+
try {
|
|
875
|
+
await appendTraceEvent(eventsFile, event);
|
|
876
|
+
} catch (error) {
|
|
877
|
+
console.warn(`[agent-blackbox] could not write event ${event.id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
878
|
+
}
|
|
866
879
|
}
|
|
867
880
|
};
|
|
868
881
|
}
|
|
@@ -933,7 +946,24 @@ function resolveRecorderOptions(options) {
|
|
|
933
946
|
}
|
|
934
947
|
|
|
935
948
|
// packages/opencode-adapter/dist/index.js
|
|
949
|
+
function noopRecorderHooks() {
|
|
950
|
+
return {
|
|
951
|
+
event: async () => {
|
|
952
|
+
},
|
|
953
|
+
"tool.execute.before": async () => {
|
|
954
|
+
},
|
|
955
|
+
"tool.execute.after": async () => {
|
|
956
|
+
},
|
|
957
|
+
"experimental.session.compacting": async () => {
|
|
958
|
+
},
|
|
959
|
+
"experimental.chat.system.transform": async () => {
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
}
|
|
936
963
|
async function createOpenCodeRecorder(context, options = {}) {
|
|
964
|
+
if (process.env.AGENT_BLACKBOX_DISABLE === "1") {
|
|
965
|
+
return noopRecorderHooks();
|
|
966
|
+
}
|
|
937
967
|
const resolved = resolveRecorderOptions(options);
|
|
938
968
|
const directory = context.directory ?? process.cwd();
|
|
939
969
|
const runId = resolved.runId ?? `opencode-${Date.now()}`;
|
|
@@ -1021,7 +1051,7 @@ function createOpenCodeEventFactory(options) {
|
|
|
1021
1051
|
const decision = decideReadServe(readCache.get(key), { hash, content: current }, compactionGen, path);
|
|
1022
1052
|
readCache.set(key, { hash, content: current, gen: compactionGen });
|
|
1023
1053
|
bumpFile(path, "read", hash);
|
|
1024
|
-
if (decision.mode !== "full" && typeof decision.output === "string") {
|
|
1054
|
+
if (decision.mode !== "full" && typeof decision.output === "string" && decision.saved > 0) {
|
|
1025
1055
|
output.output = decision.output;
|
|
1026
1056
|
}
|
|
1027
1057
|
};
|