@app-vitals/agent-lib 1.119.0 → 1.120.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/child-env.ts +12 -9
- package/child-env.unit.test.ts +12 -9
- package/package.json +1 -1
- package/web/toolbar.ts +14 -1
package/child-env.ts
CHANGED
|
@@ -74,7 +74,7 @@ const AGENT_KEY = "SHIPWRIGHT_AGENT_API_KEY";
|
|
|
74
74
|
|
|
75
75
|
let warnedMissingToolsKey = false;
|
|
76
76
|
|
|
77
|
-
/** Test hook: re-arm the once-per-process
|
|
77
|
+
/** Test hook: re-arm the once-per-process missing-key error. */
|
|
78
78
|
export function resetChildEnvWarning(): void {
|
|
79
79
|
warnedMissingToolsKey = false;
|
|
80
80
|
}
|
|
@@ -84,9 +84,9 @@ export function resetChildEnvWarning(): void {
|
|
|
84
84
|
* SHIPWRIGHT_AGENT_API_KEY, then layer `extra` last so a per-run override
|
|
85
85
|
* still wins.
|
|
86
86
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
87
|
+
* Fails closed: with no tools token the child gets no SHIPWRIGHT_AGENT_API_KEY
|
|
88
|
+
* at all (the runtime token never reaches the model's process) and one error is
|
|
89
|
+
* logged per process.
|
|
90
90
|
*/
|
|
91
91
|
export function buildChildEnv(
|
|
92
92
|
env: Record<string, string | undefined>,
|
|
@@ -98,11 +98,14 @@ export function buildChildEnv(
|
|
|
98
98
|
delete child[TOOLS_KEY];
|
|
99
99
|
if (toolsKey) {
|
|
100
100
|
child[AGENT_KEY] = toolsKey;
|
|
101
|
-
} else
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
} else {
|
|
102
|
+
delete child[AGENT_KEY];
|
|
103
|
+
if (!warnedMissingToolsKey) {
|
|
104
|
+
warnedMissingToolsKey = true;
|
|
105
|
+
console.error(
|
|
106
|
+
`[child-env] ${TOOLS_KEY} is not set; the child gets no ${AGENT_KEY}`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
return { ...child, ...extra };
|
|
108
111
|
}
|
package/child-env.unit.test.ts
CHANGED
|
@@ -13,6 +13,8 @@ describe("buildChildEnv", () => {
|
|
|
13
13
|
const env: Record<string, string> = { PATH: "/bin", MY_OPERATOR_VAR: "x" };
|
|
14
14
|
for (const k of RUNTIME_ONLY_ENV_VARS) env[k] = "secret";
|
|
15
15
|
for (const k of CHILD_ALLOWED_SECRET_ENV_VARS) env[k] = "ok";
|
|
16
|
+
// The agent key only reaches the child via the tools key (no fallback).
|
|
17
|
+
env.SHIPWRIGHT_AGENT_TOOLS_API_KEY = "ok";
|
|
16
18
|
const child = buildChildEnv(env);
|
|
17
19
|
for (const k of RUNTIME_ONLY_ENV_VARS) expect(k in child).toBe(false);
|
|
18
20
|
for (const k of CHILD_ALLOWED_SECRET_ENV_VARS) expect(child[k]).toBe("ok");
|
|
@@ -89,12 +91,12 @@ describe("secret classification", () => {
|
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
describe("buildChildEnv tools-token mapping", () => {
|
|
92
|
-
let
|
|
94
|
+
let errorLog: ReturnType<typeof spyOn>;
|
|
93
95
|
beforeEach(() => {
|
|
94
96
|
resetChildEnvWarning();
|
|
95
|
-
|
|
97
|
+
errorLog = spyOn(console, "error").mockImplementation(() => {});
|
|
96
98
|
});
|
|
97
|
-
afterEach(() =>
|
|
99
|
+
afterEach(() => errorLog.mockRestore());
|
|
98
100
|
|
|
99
101
|
test("MAPPED_ENV_VARS is the tools key and is not also pass-through", () => {
|
|
100
102
|
expect([...MAPPED_ENV_VARS]).toEqual(["SHIPWRIGHT_AGENT_TOOLS_API_KEY"]);
|
|
@@ -114,14 +116,15 @@ describe("buildChildEnv tools-token mapping", () => {
|
|
|
114
116
|
expect("SHIPWRIGHT_AGENT_TOOLS_API_KEY" in child).toBe(false);
|
|
115
117
|
expect(env.SHIPWRIGHT_AGENT_API_KEY).toBe("pod-key");
|
|
116
118
|
expect(env.SHIPWRIGHT_AGENT_TOOLS_API_KEY).toBe("tools-key");
|
|
117
|
-
expect(
|
|
119
|
+
expect(errorLog).not.toHaveBeenCalled();
|
|
118
120
|
});
|
|
119
121
|
|
|
120
|
-
test("without the tools key, the child
|
|
122
|
+
test("without the tools key, the child gets no agent key and one error is logged per process", () => {
|
|
121
123
|
const env = { SHIPWRIGHT_AGENT_API_KEY: "pod-key" };
|
|
122
|
-
expect(buildChildEnv(env)
|
|
123
|
-
expect(buildChildEnv(env)
|
|
124
|
-
expect(
|
|
124
|
+
expect("SHIPWRIGHT_AGENT_API_KEY" in buildChildEnv(env)).toBe(false);
|
|
125
|
+
expect("SHIPWRIGHT_AGENT_API_KEY" in buildChildEnv(env)).toBe(false);
|
|
126
|
+
expect(env.SHIPWRIGHT_AGENT_API_KEY).toBe("pod-key");
|
|
127
|
+
expect(errorLog).toHaveBeenCalledTimes(1);
|
|
125
128
|
});
|
|
126
129
|
|
|
127
130
|
test("an empty tools key counts as absent", () => {
|
|
@@ -129,7 +132,7 @@ describe("buildChildEnv tools-token mapping", () => {
|
|
|
129
132
|
SHIPWRIGHT_AGENT_API_KEY: "pod-key",
|
|
130
133
|
SHIPWRIGHT_AGENT_TOOLS_API_KEY: "",
|
|
131
134
|
});
|
|
132
|
-
expect(child
|
|
135
|
+
expect("SHIPWRIGHT_AGENT_API_KEY" in child).toBe(false);
|
|
133
136
|
expect("SHIPWRIGHT_AGENT_TOOLS_API_KEY" in child).toBe(false);
|
|
134
137
|
});
|
|
135
138
|
});
|
package/package.json
CHANGED
package/web/toolbar.ts
CHANGED
|
@@ -60,6 +60,18 @@ export interface ShipwrightToolbarOptions {
|
|
|
60
60
|
adminBaseUrl?: string;
|
|
61
61
|
/** Public task board URL, used only for the public audience. Defaults to "/public/tasks". */
|
|
62
62
|
tasksUrl?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Optional logo rendered beside the wordmark. Must be a same-origin path
|
|
65
|
+
* (starts with a single "/"); anything else is ignored. Unset = no logo.
|
|
66
|
+
*/
|
|
67
|
+
logoUrl?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Returns an escaped <img> for a same-origin logo path, or "" if unset/unsafe. */
|
|
71
|
+
export function renderToolbarLogo(logoUrl: string | undefined): string {
|
|
72
|
+
if (!logoUrl) return "";
|
|
73
|
+
if (!/^\/(?![/\\])[^\s\\]*$/.test(logoUrl)) return "";
|
|
74
|
+
return `<img src="${escapeHtml(logoUrl)}" alt="" class="vos-logo" width="20" height="20" />`;
|
|
63
75
|
}
|
|
64
76
|
|
|
65
77
|
/** localStorage key holding the visitor's saved theme: "light" or "dark". */
|
|
@@ -220,6 +232,7 @@ export function baseStyles(): string {
|
|
|
220
232
|
letter-spacing: -0.3px;
|
|
221
233
|
flex-shrink: 0;
|
|
222
234
|
}
|
|
235
|
+
.vos-logo { vertical-align: middle; margin-right: 8px; border-radius: 4px; }
|
|
223
236
|
.vos-wordmark:hover { color: var(--vos-brand); }
|
|
224
237
|
.vos-nav {
|
|
225
238
|
display: flex;
|
|
@@ -437,7 +450,7 @@ export function renderShipwrightToolbar(
|
|
|
437
450
|
|
|
438
451
|
return `<input type="checkbox" id="vos-nav-toggle" class="vos-nav-toggle" aria-hidden="true">
|
|
439
452
|
<nav class="vos-toolbar" aria-label="Site navigation">
|
|
440
|
-
<a href="${adminBase}/admin/agents" class="vos-wordmark"
|
|
453
|
+
<a href="${adminBase}/admin/agents" class="vos-wordmark">${renderToolbarLogo(opts.logoUrl)}Shipwright</a>
|
|
441
454
|
<div id="vos-nav-content" class="vos-nav">
|
|
442
455
|
${links}
|
|
443
456
|
</div>
|