@app-vitals/agent-admin 1.120.1 → 1.121.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.
Files changed (73) hide show
  1. package/package.json +2 -2
  2. package/src/account-repo-lookup-api.integration.test.ts +1 -1
  3. package/src/admin-boot-config.ts +2 -2
  4. package/src/admin-boot-config.unit.test.ts +1 -1
  5. package/src/admin-boot.ts +1 -1
  6. package/src/admin-ui-account.ts +2 -2
  7. package/src/admin-ui-agent-template.smoke.test.ts +1 -1
  8. package/src/admin-ui-github-identity-pages.ts +2 -2
  9. package/src/admin-ui-push-test.smoke.test.ts +7 -5
  10. package/src/admin-ui-styles.unit.test.ts +3 -1
  11. package/src/admin-ui-templates-pages.ts +5 -5
  12. package/src/agent-cron-run-stats.integration.test.ts +11 -2
  13. package/src/agent-deletion-checklist.unit.test.ts +1 -1
  14. package/src/agent-manifest.unit.test.ts +3 -3
  15. package/src/agent-marketplaces-api.integration.test.ts +22 -1
  16. package/src/agent-members.integration.test.ts +1 -1
  17. package/src/agent-pod-labels.unit.test.ts +2 -2
  18. package/src/agent-provisioner.unit.test.ts +4 -4
  19. package/src/agent-setup.unit.test.ts +14 -3
  20. package/src/agent-template-items.ts +1 -1
  21. package/src/agent-templates.ts +1 -1
  22. package/src/agent-tools-token.integration.test.ts +3 -3
  23. package/src/api-auth.ts +11 -4
  24. package/src/brand-tokens.json +23 -4
  25. package/src/brand-tokens.unit.test.ts +11 -4
  26. package/src/chat-credential-config.unit.test.ts +6 -2
  27. package/src/chat-markers.unit.test.ts +5 -2
  28. package/src/cron-run-now.smoke.test.ts +1 -1
  29. package/src/cron-run-now.ts +1 -1
  30. package/src/errors.unit.test.ts +7 -4
  31. package/src/fixtures/github-agent-installation-cassette.json +35 -5
  32. package/src/github-access-backfill.ts +1 -1
  33. package/src/github-access-backfill.unit.test.ts +1 -1
  34. package/src/github-agent-installation-crawler.integration.test.ts +29 -12
  35. package/src/github-agent-installation-crawler.ts +2 -2
  36. package/src/github-agent-installation-crawler.unit.test.ts +28 -7
  37. package/src/github-app-api.ts +1 -1
  38. package/src/github-app-jwt.unit.test.ts +2 -1
  39. package/src/github-cache-roundtrip.integration.test.ts +4 -4
  40. package/src/github-enterprise-api.integration.test.ts +4 -4
  41. package/src/github-enterprise-api.ts +6 -6
  42. package/src/github-enterprise-client-page.unit.test.ts +18 -6
  43. package/src/github-enterprise-client.integration.test.ts +97 -32
  44. package/src/github-enterprise-client.ts +81 -22
  45. package/src/github-enterprise-client.unit.test.ts +1 -1
  46. package/src/github-enterprise-warnings.unit.test.ts +19 -6
  47. package/src/github-installation-selection.integration.test.ts +4 -1
  48. package/src/github-installation-wiring.unit.test.ts +1 -1
  49. package/src/github-repo-refresh-discovery.unit.test.ts +1 -1
  50. package/src/github-repo-refresher.unit.test.ts +11 -5
  51. package/src/github-sync-cache.integration.test.ts +1 -1
  52. package/src/github-sync-cached-access.ts +1 -1
  53. package/src/github-sync-reverify.unit.test.ts +1 -1
  54. package/src/github-sync-snapshot-refresh.integration.test.ts +1 -1
  55. package/src/github-sync.unit.test.ts +6 -6
  56. package/src/installation-ports-fixture.integration.test.ts +2 -2
  57. package/src/installation-repos-service.ts +5 -5
  58. package/src/kubernetes-client.integration.test.ts +1 -2
  59. package/src/platform-routes.ts +1 -1
  60. package/src/push-content.unit.test.ts +2 -2
  61. package/src/push-sender.unit.test.ts +1 -1
  62. package/src/push-service.integration.test.ts +1 -1
  63. package/src/pwa-icons.unit.test.ts +1 -1
  64. package/src/slack-config-token-resolve.unit.test.ts +25 -7
  65. package/src/slack-provisioning-client.integration.test.ts +10 -8
  66. package/src/slack-provisioning-client.ts +2 -6
  67. package/src/tools-token-policy.integration.test.ts +68 -6
  68. package/src/tools-token-policy.smoke.test.ts +22 -5
  69. package/src/tools-token-policy.ts +100 -8
  70. package/src/tools-token-policy.unit.test.ts +137 -4
  71. package/src/trial-expiry-sweeper.unit.test.ts +1 -1
  72. package/src/user-prefs.integration.test.ts +1 -1
  73. package/src/user-repo-access-resolver.unit.test.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { describe, expect, it } from "bun:test";
1
+ import { afterEach, describe, expect, it, spyOn } from "bun:test";
2
2
  import { Hono } from "hono";
3
3
  import {
4
4
  type AdminExtension,
@@ -12,7 +12,11 @@ import {
12
12
  blankEnvForToolsToken,
13
13
  createToolsTokenGuard,
14
14
  isPluginScriptPreCheck,
15
+ isRuntimePolicyEnforced,
16
+ RUNTIME_TOKEN_DENYLIST,
15
17
  ruleMatches,
18
+ runtimeTokenDecision,
19
+ runtimeTokenDenied,
16
20
  TOOLS_TOKEN_POLICY,
17
21
  type ToolsTokenPolicyRule,
18
22
  toolsTokenDecision,
@@ -242,9 +246,6 @@ describe("createAdminAuthMiddleware tools-token policy", () => {
242
246
  expect(
243
247
  (await call(app, TOOLS_KEY, "PUT", `/agents/${ID}/gadgets/g`)).status,
244
248
  ).toBe(200);
245
- expect(
246
- (await call(app, RUNTIME_KEY, "POST", `/agents/${ID}/tokens`)).status,
247
- ).toBe(200);
248
249
  expect(
249
250
  (await call(app, RUNTIME_KEY, "PUT", `/agents/${ID}/widgets/w`)).status,
250
251
  ).toBe(200);
@@ -277,3 +278,135 @@ describe("createToolsTokenGuard (extension routes)", () => {
277
278
  ).toBe(200);
278
279
  });
279
280
  });
281
+
282
+ describe("runtime-kind denylist", () => {
283
+ const denied: Array<[string, string]> = [
284
+ ["POST", `/agents/${ID}/tokens`],
285
+ ["GET", `/agents/${ID}/tokens`],
286
+ ["DELETE", `/agents/${ID}/tokens/t1`],
287
+ ["POST", `/agents/${ID}/envs`],
288
+ ["PATCH", `/agents/${ID}/envs`],
289
+ ["DELETE", `/agents/${ID}/envs/FOO`],
290
+ ["POST", `/agents/${ID}/tools`],
291
+ ["PATCH", `/agents/${ID}/tools/t1`],
292
+ ["DELETE", `/agents/${ID}/tools/t1`],
293
+ ["POST", `/agents/${ID}/plugins`],
294
+ ["PATCH", `/agents/${ID}/plugins`],
295
+ ["DELETE", `/agents/${ID}/plugins`],
296
+ ["POST", `/agents/${ID}/marketplaces`],
297
+ ["DELETE", `/agents/${ID}/marketplaces/m1`],
298
+ ["POST", `/agents/${ID}/crons`],
299
+ ["PATCH", `/agents/${ID}/crons/c1`],
300
+ ["DELETE", `/agents/${ID}/crons/c1`],
301
+ ];
302
+ const allowed: Array<[string, string]> = [
303
+ ["GET", `/agents/${ID}/config`],
304
+ ["GET", `/agents/${ID}/crons`],
305
+ ["POST", `/agents/${ID}/crons/reconcile`],
306
+ ["POST", `/agents/${ID}/template/reconcile`],
307
+ ["POST", `/agents/${ID}/crons/c1/runs`],
308
+ ["PATCH", `/agents/${ID}/crons/c1/runs/r1`],
309
+ ["GET", `/agents/${ID}/crons/c1/runs`],
310
+ ["PUT", `/agents/${ID}/github-installations`],
311
+ ["GET", `/agents/${ID}/github-installations`],
312
+ ["PUT", `/agents/${ID}/baked-marketplaces`],
313
+ ["POST", `/agents/${ID}/chat-tokens/daily`],
314
+ ["GET", `/agents/${ID}/chat-tokens/daily/stats`],
315
+ ["POST", `/agents/${ID}/work-queue`],
316
+ ["PUT", `/agents/${ID}/phase-methodology`],
317
+ ["GET", `/agents/${ID}/envs`],
318
+ ];
319
+ for (const [m, p] of denied)
320
+ it(`denies ${m} ${p}`, () =>
321
+ expect(runtimeTokenDecision(m, p)).toBe("deny"));
322
+ for (const [m, p] of allowed)
323
+ it(`allows ${m} ${p}`, () =>
324
+ expect(runtimeTokenDecision(m, p)).toBe("allow"));
325
+
326
+ it("has unique method+path entries, all deny", () => {
327
+ const keys = RUNTIME_TOKEN_DENYLIST.map((r) => `${r.method} ${r.path}`);
328
+ expect(new Set(keys).size).toBe(keys.length);
329
+ for (const r of RUNTIME_TOKEN_DENYLIST) expect(r.decision).toBe("deny");
330
+ });
331
+
332
+ describe("kill switch and logging", () => {
333
+ afterEach(() => spyOn(console, "warn").mockRestore());
334
+ it("defaults to enforce; only `off` disables", () => {
335
+ expect(isRuntimePolicyEnforced({})).toBe(true);
336
+ expect(
337
+ isRuntimePolicyEnforced({ SHIPWRIGHT_RUNTIME_TOKEN_POLICY: "enforce" }),
338
+ ).toBe(true);
339
+ expect(
340
+ isRuntimePolicyEnforced({ SHIPWRIGHT_RUNTIME_TOKEN_POLICY: "garbage" }),
341
+ ).toBe(true);
342
+ expect(
343
+ isRuntimePolicyEnforced({ SHIPWRIGHT_RUNTIME_TOKEN_POLICY: "off" }),
344
+ ).toBe(false);
345
+ });
346
+ it("logs one line per denial and nothing when off or allowed", () => {
347
+ const warn = spyOn(console, "warn").mockImplementation(() => {});
348
+ expect(runtimeTokenDenied("post", `/agents/${ID}/envs`, {})).toBe(true);
349
+ expect(warn).toHaveBeenCalledTimes(1);
350
+ expect(warn.mock.calls[0]?.[0]).toBe(
351
+ `[token-policy] runtime token denied POST "/agents/${ID}/envs"`,
352
+ );
353
+ expect(
354
+ runtimeTokenDenied("POST", `/agents/${ID}/envs`, {
355
+ SHIPWRIGHT_RUNTIME_TOKEN_POLICY: "off",
356
+ }),
357
+ ).toBe(false);
358
+ expect(runtimeTokenDenied("GET", `/agents/${ID}/config`, {})).toBe(false);
359
+ expect(warn).toHaveBeenCalledTimes(1);
360
+ });
361
+ it("escapes control characters in the logged path (no log forging)", () => {
362
+ const warn = spyOn(console, "warn").mockImplementation(() => {});
363
+ const path = `/agents/${ID}/envs/x\n[token-policy] runtime token denied POST /forged`;
364
+ expect(runtimeTokenDenied("DELETE", path, {})).toBe(true);
365
+ expect(warn).toHaveBeenCalledTimes(1);
366
+ const msg = String(warn.mock.calls[0]?.[0]);
367
+ expect(msg).not.toContain("\n");
368
+ expect(msg).toContain("\\n[token-policy]");
369
+ });
370
+ });
371
+ });
372
+
373
+ describe("runtime-kind enforcement points", () => {
374
+ const prev = process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY;
375
+ afterEach(() => {
376
+ if (prev === undefined) delete process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY;
377
+ else process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY = prev;
378
+ spyOn(console, "warn").mockRestore();
379
+ });
380
+ const mk = (guard: boolean) => {
381
+ const app = new Hono();
382
+ app.use(
383
+ "/agents/*",
384
+ guard
385
+ ? createToolsTokenGuard({ agentTokenService: tokenService })
386
+ : createAdminAuthMiddleware({
387
+ sessionSecret: "s".repeat(32),
388
+ agentTokenService: tokenService,
389
+ }),
390
+ );
391
+ app.all("/agents/*", (c) => c.json({ ok: true }));
392
+ return app;
393
+ };
394
+ for (const guard of [false, true]) {
395
+ it(`${guard ? "guard" : "auth middleware"}: 403 on denied, 200 on allowed, switch off restores`, async () => {
396
+ spyOn(console, "warn").mockImplementation(() => {});
397
+ const app = mk(guard);
398
+ delete process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY;
399
+ expect(
400
+ (await call(app, RUNTIME_KEY, "POST", `/agents/${ID}/tokens`)).status,
401
+ ).toBe(403);
402
+ expect(
403
+ (await call(app, RUNTIME_KEY, "POST", `/agents/${ID}/crons/reconcile`))
404
+ .status,
405
+ ).toBe(200);
406
+ process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY = "off";
407
+ expect(
408
+ (await call(app, RUNTIME_KEY, "POST", `/agents/${ID}/tokens`)).status,
409
+ ).toBe(200);
410
+ });
411
+ }
412
+ });
@@ -16,9 +16,9 @@ import { describe, expect, it } from "bun:test";
16
16
  import { FixedClock } from "./clock.ts";
17
17
  import {
18
18
  DEFAULT_TRIAL_EXPIRY_SWEEP_INTERVAL_MS,
19
+ resolveTrialExpirySweepIntervalMs,
19
20
  type TrialExpiryCronJobServiceLike,
20
21
  TrialExpirySweeper,
21
- resolveTrialExpirySweepIntervalMs,
22
22
  } from "./trial-expiry-sweeper.ts";
23
23
 
24
24
  const NOW = new Date("2026-06-15T00:00:00.000Z");
@@ -8,8 +8,8 @@
8
8
 
9
9
  import { afterEach, beforeEach, describe, expect, it } from "bun:test";
10
10
  import type { PrismaClient } from "../prisma/client/client.ts";
11
- import { resetMemberIdFixture } from "./test-support/member-id-test-support.ts";
12
11
  import { createAdminPrismaClient } from "./prisma-client.ts";
12
+ import { resetMemberIdFixture } from "./test-support/member-id-test-support.ts";
13
13
  import { InvalidTimezoneError, UserPrefsService } from "./user-prefs.ts";
14
14
 
15
15
  const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
@@ -8,8 +8,8 @@ import { GithubEnterpriseError } from "./github-enterprise-client.ts";
8
8
  import type { RepoRole } from "./github-lookup-client.ts";
9
9
  import {
10
10
  canPushForRole,
11
- UserRepoAccessResolver,
12
11
  type LookupPort,
12
+ UserRepoAccessResolver,
13
13
  } from "./user-repo-access-resolver.ts";
14
14
 
15
15
  const NOW = new Date("2026-11-09T12:00:00Z");