@blogic-cz/agent-tools 1.14.4 → 1.14.6
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/README.md +12 -11
- package/dist/api-tool/main.d.ts +6 -1
- package/dist/api-tool/main.d.ts.map +1 -1
- package/dist/audit-tool/main.d.ts +6 -1
- package/dist/audit-tool/main.d.ts.map +1 -1
- package/dist/az-tool/main.d.ts +6 -1
- package/dist/az-tool/main.d.ts.map +1 -1
- package/dist/azdo-tool/main.d.ts +6 -1
- package/dist/azdo-tool/main.d.ts.map +1 -1
- package/dist/credential-guard/issue-227.test.d.ts +2 -0
- package/dist/credential-guard/issue-227.test.d.ts.map +1 -0
- package/dist/credential-guard/policy.d.ts.map +1 -1
- package/dist/credential-guard/registry.d.ts.map +1 -1
- package/dist/db-tool/main.d.ts +8 -1
- package/dist/db-tool/main.d.ts.map +1 -1
- package/dist/db-tool/service.d.ts +1 -0
- package/dist/db-tool/service.d.ts.map +1 -1
- package/dist/gh-tool/main.d.ts +4 -1
- package/dist/gh-tool/main.d.ts.map +1 -1
- package/dist/gh-tool/pr/commands.d.ts +13 -0
- package/dist/gh-tool/pr/commands.d.ts.map +1 -1
- package/dist/gh-tool/pr/review.d.ts +1 -1
- package/dist/gh-tool/pr/review.d.ts.map +1 -1
- package/dist/gh-tool/read/store.d.ts +4 -1
- package/dist/gh-tool/read/store.d.ts.map +1 -1
- package/dist/k8s-tool/main.d.ts +8 -1
- package/dist/k8s-tool/main.d.ts.map +1 -1
- package/dist/logs-tool/main.d.ts +4 -0
- package/dist/logs-tool/main.d.ts.map +1 -1
- package/dist/observability-tool/main.d.ts +6 -1
- package/dist/observability-tool/main.d.ts.map +1 -1
- package/dist/session-tool/main.d.ts +4 -0
- package/dist/session-tool/main.d.ts.map +1 -1
- package/dist/shared/secret-env.d.ts +9 -0
- package/dist/shared/secret-env.d.ts.map +1 -1
- package/package.json +10 -11
- package/src/api-tool/index.ts +1 -1
- package/src/api-tool/main.ts +19 -6
- package/src/audit-tool/index.ts +1 -1
- package/src/audit-tool/main.ts +13 -4
- package/src/az-tool/index.ts +1 -1
- package/src/az-tool/main.ts +10 -4
- package/src/azdo-tool/index.ts +1 -1
- package/src/azdo-tool/main.ts +13 -4
- package/src/credential-guard/issue-227.test.ts +69 -0
- package/src/credential-guard/policy.ts +23 -20
- package/src/credential-guard/registry.ts +99 -11
- package/src/db-tool/index.ts +1 -1
- package/src/db-tool/main.ts +10 -4
- package/src/db-tool/service.ts +6 -1
- package/src/gh-tool/index.ts +1 -1
- package/src/gh-tool/main.ts +5 -4
- package/src/gh-tool/pr/commands.ts +85 -10
- package/src/gh-tool/pr/review.ts +2 -1
- package/src/gh-tool/read/store.ts +8 -2
- package/src/k8s-tool/index.ts +1 -1
- package/src/k8s-tool/main.ts +10 -4
- package/src/logs-tool/index.ts +1 -1
- package/src/logs-tool/main.ts +13 -4
- package/src/observability-tool/index.ts +1 -1
- package/src/observability-tool/main.ts +10 -2
- package/src/session-tool/index.ts +1 -1
- package/src/session-tool/main.ts +10 -13
- package/src/shared/secret-env.ts +108 -88
package/src/logs-tool/main.ts
CHANGED
|
@@ -221,7 +221,7 @@ const readCommand = Command.make(
|
|
|
221
221
|
|
|
222
222
|
const commandsCommand = makeSchemaCommand(() => mainCommand);
|
|
223
223
|
|
|
224
|
-
const mainCommand = Command.make("logs-tool", {}).pipe(
|
|
224
|
+
export const mainCommand = Command.make("logs-tool", {}).pipe(
|
|
225
225
|
Command.withDescription("Application Logs Tool for Coding Agents"),
|
|
226
226
|
Command.withSubcommands([listCommand, readCommand, commandsCommand]),
|
|
227
227
|
);
|
|
@@ -249,6 +249,15 @@ const program = withRedactedOutput(withAudit("logs", cli)).pipe(
|
|
|
249
249
|
Effect.tapCause(renderCauseToStderr),
|
|
250
250
|
);
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
export const runMain = () =>
|
|
253
|
+
BunRuntime.runMain(program, {
|
|
254
|
+
disableErrorReporting: true,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
export const runProgram = (args: readonly string[]) =>
|
|
258
|
+
withRedactedOutput(
|
|
259
|
+
withAudit(
|
|
260
|
+
"logs",
|
|
261
|
+
Command.runWith(mainCommand, { version: VERSION, renderErrors: false })(args),
|
|
262
|
+
),
|
|
263
|
+
).pipe(Effect.provide(MainLayer), Effect.tapCause(renderCauseToStderr));
|
|
@@ -16,7 +16,7 @@ import { traceCommand } from "./trace";
|
|
|
16
16
|
|
|
17
17
|
const commandsCommand = makeSchemaCommand(() => mainCommand);
|
|
18
18
|
|
|
19
|
-
const mainCommand = Command.make("observability-tool", {}).pipe(
|
|
19
|
+
export const mainCommand = Command.make("observability-tool", {}).pipe(
|
|
20
20
|
Command.withDescription(
|
|
21
21
|
"LGTM observability queries — Tempo traces, Loki logs, Prometheus metrics",
|
|
22
22
|
),
|
|
@@ -37,4 +37,12 @@ const program = withRedactedOutput(withAudit("observability", cli)).pipe(
|
|
|
37
37
|
Effect.tapCause(renderCauseToStderr),
|
|
38
38
|
);
|
|
39
39
|
|
|
40
|
-
BunRuntime.runMain(program, { disableErrorReporting: true });
|
|
40
|
+
export const runMain = () => BunRuntime.runMain(program, { disableErrorReporting: true });
|
|
41
|
+
|
|
42
|
+
export const runProgram = (args: readonly string[]) =>
|
|
43
|
+
withRedactedOutput(
|
|
44
|
+
withAudit(
|
|
45
|
+
"observability",
|
|
46
|
+
Command.runWith(mainCommand, { version: VERSION, renderErrors: false })(args),
|
|
47
|
+
),
|
|
48
|
+
).pipe(Effect.provide(MainLayer), Effect.tapCause(renderCauseToStderr));
|
package/src/session-tool/main.ts
CHANGED
|
@@ -322,16 +322,11 @@ const readCommand = Command.make(
|
|
|
322
322
|
|
|
323
323
|
const commandsCommand = makeSchemaCommand(() => mainCommand);
|
|
324
324
|
|
|
325
|
-
const mainCommand = Command.make("session-tool", {}).pipe(
|
|
325
|
+
export const mainCommand = Command.make("session-tool", {}).pipe(
|
|
326
326
|
Command.withDescription("OpenCode session history tool"),
|
|
327
327
|
Command.withSubcommands([listCommand, readCommand, searchCommand, commandsCommand]),
|
|
328
328
|
);
|
|
329
329
|
|
|
330
|
-
const cli = Command.run(mainCommand, {
|
|
331
|
-
version: VERSION,
|
|
332
|
-
renderErrors: false,
|
|
333
|
-
});
|
|
334
|
-
|
|
335
330
|
const runWithErrorsDisabled = Command.runWith(mainCommand, {
|
|
336
331
|
version: VERSION,
|
|
337
332
|
renderErrors: false,
|
|
@@ -344,11 +339,13 @@ const MainLayer = AppLayer.pipe(
|
|
|
344
339
|
Layer.provideMerge(AuditServiceLayer),
|
|
345
340
|
);
|
|
346
341
|
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
)
|
|
342
|
+
export const runProgram = (args: readonly string[]) =>
|
|
343
|
+
withRedactedOutput(withAudit("session", runWithErrorsDisabled(args))).pipe(
|
|
344
|
+
Effect.provide(MainLayer),
|
|
345
|
+
Effect.tapCause(renderCauseToStderr),
|
|
346
|
+
);
|
|
351
347
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
348
|
+
export const runMain = () =>
|
|
349
|
+
BunRuntime.runMain(runProgram(process.argv.slice(2)), {
|
|
350
|
+
disableErrorReporting: true,
|
|
351
|
+
});
|
package/src/shared/secret-env.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
1
|
+
import { spawn, type SpawnOptions } from "node:child_process";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { relative, resolve as resolvePath } from "node:path";
|
|
4
4
|
import { Context, Layer } from "effect";
|
|
@@ -75,101 +75,121 @@ const inspectFrame = (frame: Buffer): FrameInspection => {
|
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
type ZshProcess = Pick<ReturnType<typeof spawn>, "pid" | "stdio" | "kill"> & {
|
|
79
|
+
on: {
|
|
80
|
+
(event: "error", listener: () => void): unknown;
|
|
81
|
+
(event: "exit", listener: (code: number | null) => void): unknown;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type ZshLauncher = (
|
|
85
|
+
command: string,
|
|
86
|
+
args: readonly string[],
|
|
87
|
+
options: SpawnOptions,
|
|
88
|
+
) => ZshProcess;
|
|
89
|
+
export const makeZshRunner =
|
|
90
|
+
(
|
|
91
|
+
launch: ZshLauncher = spawn,
|
|
92
|
+
terminate: (pid: number) => void = (pid) => {
|
|
93
|
+
process.kill(pid, "SIGKILL");
|
|
94
|
+
},
|
|
95
|
+
): ZshRunner =>
|
|
96
|
+
(name, timeoutMs) =>
|
|
97
|
+
new Promise((resolve) => {
|
|
98
|
+
if (process.env.VITEST !== undefined) {
|
|
99
|
+
const home = process.env.HOME;
|
|
100
|
+
const zdotdir = process.env.ZDOTDIR;
|
|
101
|
+
const relativeZdotdir = zdotdir ? relative(tmpdir(), resolvePath(zdotdir)) : "..";
|
|
102
|
+
if (
|
|
103
|
+
!home ||
|
|
104
|
+
!zdotdir ||
|
|
105
|
+
resolvePath(home) !== resolvePath(zdotdir) ||
|
|
106
|
+
relativeZdotdir === ".." ||
|
|
107
|
+
relativeZdotdir.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`)
|
|
108
|
+
) {
|
|
109
|
+
resolve(failed(name));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
93
112
|
}
|
|
94
|
-
}
|
|
95
113
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
let child: ReturnType<typeof spawn>;
|
|
105
|
-
try {
|
|
106
|
-
child = spawn("zsh", ["-i", "-c", script, "agent-tools-secret-env", name], {
|
|
107
|
-
detached: true,
|
|
108
|
-
env: childEnv,
|
|
109
|
-
stdio: ["ignore", "ignore", "ignore", "pipe"],
|
|
110
|
-
});
|
|
111
|
-
} catch {
|
|
112
|
-
resolve(failed(name));
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
114
|
+
const childEnv = Object.fromEntries(
|
|
115
|
+
STARTUP_ENV_NAMES.flatMap((key) => {
|
|
116
|
+
const value = process.env[key];
|
|
117
|
+
return value === undefined ? [] : [[key, value]];
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
120
|
+
const script = `export LC_ALL=C; if (( \${+parameters[$1]} )); then value=\${(P)1}; print -ru3 -- "set"; print -ru3 -- "\${#value}"; print -rn -- "$value" >&3; else print -ru3 -- "unset"; fi`;
|
|
115
121
|
|
|
116
|
-
|
|
117
|
-
if (!stream || typeof stream === "number") {
|
|
118
|
-
child.kill("SIGKILL");
|
|
119
|
-
resolve(failed(name));
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const chunks: Buffer[] = [];
|
|
124
|
-
let exited = false;
|
|
125
|
-
let ended = false;
|
|
126
|
-
let exitCode: number | null = null;
|
|
127
|
-
let settled = false;
|
|
128
|
-
const killProcessGroup = () => {
|
|
129
|
-
if (child.pid === undefined) return;
|
|
122
|
+
let child: ZshProcess;
|
|
130
123
|
try {
|
|
131
|
-
|
|
124
|
+
child = launch("zsh", ["-i", "-c", script, "agent-tools-secret-env", name], {
|
|
125
|
+
detached: true,
|
|
126
|
+
env: childEnv,
|
|
127
|
+
stdio: ["ignore", "ignore", "ignore", "pipe"],
|
|
128
|
+
});
|
|
132
129
|
} catch {
|
|
133
|
-
|
|
130
|
+
resolve(failed(name));
|
|
131
|
+
return;
|
|
134
132
|
}
|
|
135
|
-
};
|
|
136
|
-
const finish = (result: LookupResult) => {
|
|
137
|
-
if (settled) return;
|
|
138
|
-
settled = true;
|
|
139
|
-
clearTimeout(timer);
|
|
140
|
-
stream.destroy();
|
|
141
|
-
killProcessGroup();
|
|
142
|
-
resolve(result);
|
|
143
|
-
};
|
|
144
|
-
const checkFrame = () => {
|
|
145
|
-
if (settled) return;
|
|
146
|
-
const inspection = inspectFrame(Buffer.concat(chunks));
|
|
147
|
-
if (inspection._tag === "malformed") return finish(failed(name));
|
|
148
|
-
if (!exited) return;
|
|
149
|
-
if (exitCode !== 0) return finish(failed(name));
|
|
150
|
-
if (inspection._tag === "complete") finish(inspection.result);
|
|
151
|
-
else if (ended) finish(failed(name));
|
|
152
|
-
};
|
|
153
|
-
const timer = setTimeout(() => {
|
|
154
|
-
finish(failed(name));
|
|
155
|
-
}, timeoutMs);
|
|
156
133
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
134
|
+
const stream = child.stdio[3];
|
|
135
|
+
if (!stream || typeof stream === "number") {
|
|
136
|
+
child.kill("SIGKILL");
|
|
137
|
+
resolve(failed(name));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const chunks: Buffer[] = [];
|
|
142
|
+
let exited = false;
|
|
143
|
+
let ended = false;
|
|
144
|
+
let exitCode: number | null = null;
|
|
145
|
+
let settled = false;
|
|
146
|
+
const killProcessGroup = () => {
|
|
147
|
+
if (child.pid === undefined) return;
|
|
148
|
+
try {
|
|
149
|
+
terminate(-child.pid);
|
|
150
|
+
} catch {
|
|
151
|
+
// The process group may already have exited.
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const finish = (result: LookupResult) => {
|
|
155
|
+
if (settled) return;
|
|
156
|
+
settled = true;
|
|
157
|
+
clearTimeout(timer);
|
|
158
|
+
stream.destroy();
|
|
159
|
+
killProcessGroup();
|
|
160
|
+
resolve(result);
|
|
161
|
+
};
|
|
162
|
+
const checkFrame = () => {
|
|
163
|
+
if (settled) return;
|
|
164
|
+
const inspection = inspectFrame(Buffer.concat(chunks));
|
|
165
|
+
if (inspection._tag === "malformed") return finish(failed(name));
|
|
166
|
+
if (!exited) return;
|
|
167
|
+
if (exitCode !== 0) return finish(failed(name));
|
|
168
|
+
if (inspection._tag === "complete") finish(inspection.result);
|
|
169
|
+
else if (ended) finish(failed(name));
|
|
170
|
+
};
|
|
171
|
+
const timer = setTimeout(() => {
|
|
172
|
+
finish(failed(name));
|
|
173
|
+
}, timeoutMs);
|
|
174
|
+
|
|
175
|
+
stream.on("data", (chunk: Buffer | string) => {
|
|
176
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
177
|
+
checkFrame();
|
|
178
|
+
});
|
|
179
|
+
stream.on("end", () => {
|
|
180
|
+
ended = true;
|
|
181
|
+
checkFrame();
|
|
182
|
+
});
|
|
183
|
+
stream.on("error", () => finish(failed(name)));
|
|
184
|
+
child.on("error", () => finish(failed(name)));
|
|
185
|
+
child.on("exit", (code) => {
|
|
186
|
+
exited = true;
|
|
187
|
+
exitCode = code;
|
|
188
|
+
checkFrame();
|
|
189
|
+
});
|
|
171
190
|
});
|
|
172
|
-
|
|
191
|
+
|
|
192
|
+
const runInteractiveZsh = makeZshRunner();
|
|
173
193
|
|
|
174
194
|
export class SecretEnvResolver extends Context.Service<
|
|
175
195
|
SecretEnvResolver,
|