@app-vitals/agent-admin 1.120.0 → 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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.120.0",
3
+ "version": "1.121.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/app-vitals/agent.git",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@anthropic-ai/sdk": "0.137.0",
47
- "@app-vitals/agent-lib": "1.120.0",
47
+ "@app-vitals/agent-lib": "1.121.0",
48
48
  "@hono/zod-openapi": "^1.0.0",
49
49
  "@prisma/adapter-pg": "^7.10.0",
50
50
  "@prisma/client": "^7.10.0",
@@ -7,8 +7,8 @@
7
7
 
8
8
  import { afterEach, beforeEach, describe, expect, it } from "bun:test";
9
9
  import type { PrismaClient } from "../prisma/client/client.ts";
10
- import { createAccountRepoLookupApp } from "./account-repo-lookup-api.ts";
11
10
  import { AccountRepoLookupService } from "./account-repo-lookup.ts";
11
+ import { createAccountRepoLookupApp } from "./account-repo-lookup-api.ts";
12
12
  import { createAdminPrismaClient } from "./prisma-client.ts";
13
13
 
14
14
  const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
@@ -12,9 +12,9 @@
12
12
  import { join } from "node:path";
13
13
  import type { PrismaClient } from "../prisma/client/client.ts";
14
14
  import { AgentAnthropicIdentityService } from "./agent-anthropic-identity.ts";
15
- import { parseAgentPodLabels } from "./agent-pod-labels.ts";
16
15
  import { parseAgentImageMap } from "./agent-image-map.ts";
17
16
  import type { AgentAnthropicFederation } from "./agent-manifest.ts";
17
+ import { parseAgentPodLabels } from "./agent-pod-labels.ts";
18
18
  import type {
19
19
  AgentProvisioner,
20
20
  PerAgentIdentityConfig,
@@ -32,8 +32,8 @@ import {
32
32
  HttpChatServiceProvisioningClient,
33
33
  NoopChatServiceProvisioningClient,
34
34
  } from "./chat-service-provisioning-client.ts";
35
- import { parsePodServiceAccountConfig } from "./pod-service-account-config.ts";
36
35
  import { HttpKubernetesClient } from "./kubernetes-client.ts";
36
+ import { parsePodServiceAccountConfig } from "./pod-service-account-config.ts";
37
37
  import type { ServiceIntegration } from "./service-integration.ts";
38
38
 
39
39
  // ─── Migration preflight ──────────────────────────────────────────────────────
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "bun:test";
2
+ import { buildDeletionClients, buildProvisioner } from "./admin-boot-config.ts";
2
3
  import type { AgentTokenService } from "./agent-tokens.ts";
3
- import { buildProvisioner, buildDeletionClients } from "./admin-boot-config.ts";
4
4
  import {
5
5
  HttpChatServiceProvisioningClient,
6
6
  NoopChatServiceProvisioningClient,
package/src/admin-boot.ts CHANGED
@@ -87,8 +87,8 @@ import { AgentPluginService } from "./agent-plugins.ts";
87
87
  import { AgentTemplateReconcileService } from "./agent-template-reconcile.ts";
88
88
  import { AgentTemplateService } from "./agent-templates.ts";
89
89
  import { AgentTokenService } from "./agent-tokens.ts";
90
- import { AgentToolsTokenService } from "./agent-tools-token.ts";
91
90
  import { AgentToolService } from "./agent-tools.ts";
91
+ import { AgentToolsTokenService } from "./agent-tools-token.ts";
92
92
  import { AgentService } from "./agents.ts";
93
93
  import { parseAdminApiKeys } from "./agents-api.ts";
94
94
  import { createAdminAuthMiddleware } from "./api-auth.ts";
@@ -9,16 +9,16 @@
9
9
  */
10
10
 
11
11
  import type { Context, Hono, MiddlewareHandler } from "hono";
12
+ import { normalizeEmail } from "./account-email.ts";
12
13
  import type { AccountInviteService } from "./account-invites.ts";
13
14
  import {
14
15
  AccountMemberNotFoundError,
15
16
  type AccountMemberService,
16
17
  LastOwnerError,
17
18
  } from "./account-members.ts";
18
- import { normalizeEmail } from "./account-email.ts";
19
19
  import type { Account, AccountService } from "./accounts.ts";
20
- import { ACCOUNT_PATH, renderAccountPage } from "./admin-ui-account-pages.ts";
21
20
  import type { AdminUIEnv } from "./admin-ui.ts";
21
+ import { ACCOUNT_PATH, renderAccountPage } from "./admin-ui-account-pages.ts";
22
22
  import type { SettingsNav } from "./admin-ui-settings-layout.ts";
23
23
 
24
24
  export interface AccountRouteDeps {
@@ -14,8 +14,8 @@ import {
14
14
  makeSessionCookie,
15
15
  } from "./admin-ui.fixtures.ts";
16
16
  import { createAdminUIApp } from "./admin-ui.ts";
17
- import { resolveDefaultSpecialtyName } from "./specialty-types.ts";
18
17
  import type { TemplateView } from "./agent-templates.ts";
18
+ import { resolveDefaultSpecialtyName } from "./specialty-types.ts";
19
19
 
20
20
  const TYPE = resolveDefaultSpecialtyName();
21
21
  const d = new Date("2024-01-01");
@@ -6,12 +6,12 @@
6
6
  * escaped.
7
7
  */
8
8
 
9
+ import type { GheOrgs } from "./admin-ui-github-enterprise-pages.ts";
10
+ import { escapeHtml } from "./admin-ui-styles.ts";
9
11
  import {
10
12
  type GithubAppsState,
11
13
  LOOKUP_ONLY_REASON,
12
14
  } from "./github-apps-state.ts";
13
- import type { GheOrgs } from "./admin-ui-github-enterprise-pages.ts";
14
- import { escapeHtml } from "./admin-ui-styles.ts";
15
15
 
16
16
  /** The GitHub username `<tr>` for the "Owner & identities" card. */
17
17
  export function renderGithubUsernameRow(
@@ -9,22 +9,24 @@
9
9
  */
10
10
 
11
11
  import { describe, expect, it } from "bun:test";
12
- import { Hono } from "hono";
13
12
  import type { MiddlewareHandler } from "hono";
13
+ import { Hono } from "hono";
14
+ import type { AdminUIEnv } from "./admin-ui.ts";
14
15
  import {
15
16
  PUSH_TEST_PATH,
16
17
  PUSH_TEST_PAYLOAD,
17
18
  type PushTestRouteDeps,
18
19
  registerPushTestRoute,
19
20
  } from "./admin-ui-push-test.ts";
20
- import type { AdminUIEnv } from "./admin-ui.ts";
21
21
  import type { PushDetailLevel } from "./push-content.ts";
22
22
 
23
23
  const DEFAULT_EMAIL = "dave@example.com";
24
24
 
25
- function makeFakeRequireAuth(
26
- { isAdmin = true }: { isAdmin?: boolean } = {},
27
- ): MiddlewareHandler<AdminUIEnv> {
25
+ function makeFakeRequireAuth({
26
+ isAdmin = true,
27
+ }: {
28
+ isAdmin?: boolean;
29
+ } = {}): MiddlewareHandler<AdminUIEnv> {
28
30
  return async (c, next) => {
29
31
  c.set("userEmail", c.req.header("x-test-user-email") ?? DEFAULT_EMAIL);
30
32
  c.set("isAdmin", isAdmin);
@@ -126,7 +126,9 @@ describe("baseStyles — SGL-1.1 settings layout", () => {
126
126
  expect(css).toMatch(
127
127
  /\.vos-page-wide\s*{\s*max-width:\s*none;\s*width:\s*100%;/,
128
128
  );
129
- expect(block).toMatch(/\.settings-content \.form-input[^}]*max-width: 640px/);
129
+ expect(block).toMatch(
130
+ /\.settings-content \.form-input[^}]*max-width: 640px/,
131
+ );
130
132
  expect(block).toContain('.settings-content input[type="search"]');
131
133
  });
132
134
 
@@ -9,16 +9,16 @@
9
9
  */
10
10
 
11
11
  import { renderAdminPage } from "./admin-ui-layout.ts";
12
- import { escapeHtml } from "./admin-ui-styles.ts";
13
- import {
14
- AGENT_TEMPLATE_ITEM_KINDS,
15
- type AgentTemplateItemKind,
16
- } from "./agent-template-items.ts";
17
12
  import {
18
13
  buildSettingsNav,
19
14
  renderSettingsLayout,
20
15
  type SettingsNav,
21
16
  } from "./admin-ui-settings-layout.ts";
17
+ import { escapeHtml } from "./admin-ui-styles.ts";
18
+ import {
19
+ AGENT_TEMPLATE_ITEM_KINDS,
20
+ type AgentTemplateItemKind,
21
+ } from "./agent-template-items.ts";
22
22
 
23
23
  export const ADMIN_TEMPLATES_PATH = "/admin/settings/templates";
24
24
 
@@ -1506,7 +1506,12 @@ describeOrSkip("AgentCronRunStatsService (integration)", () => {
1506
1506
  const phaseA = await createPhaseCron(cronJobService, agentA, "dev-task");
1507
1507
  const phaseB = await createPhaseCron(cronJobService, agentB, "dev-task");
1508
1508
 
1509
- const mk = (cronId: string, agentId: string, phaseId: string, skipped: boolean) =>
1509
+ const mk = (
1510
+ cronId: string,
1511
+ agentId: string,
1512
+ phaseId: string,
1513
+ skipped: boolean,
1514
+ ) =>
1510
1515
  prisma.agentCronRun.create({
1511
1516
  data: {
1512
1517
  cronId,
@@ -1527,7 +1532,11 @@ describeOrSkip("AgentCronRunStatsService (integration)", () => {
1527
1532
  await mk(cronB, agentB, phaseB, true);
1528
1533
  await mk(cronB, agentB, phaseB, true);
1529
1534
 
1530
- const { series } = await statsService.outcomes(undefined, undefined, agentA);
1535
+ const { series } = await statsService.outcomes(
1536
+ undefined,
1537
+ undefined,
1538
+ agentA,
1539
+ );
1531
1540
  expect(series).toHaveLength(1);
1532
1541
  expect(series[0]).toMatchObject({
1533
1542
  runs: 2,
@@ -6,8 +6,8 @@
6
6
 
7
7
  import { describe, expect, it } from "bun:test";
8
8
  import {
9
- type ManualStep,
10
9
  buildManualStepsChecklist,
10
+ type ManualStep,
11
11
  } from "./agent-deletion-checklist.ts";
12
12
 
13
13
  describe("buildManualStepsChecklist — named keys", () => {
@@ -15,9 +15,9 @@ import {
15
15
  buildAgentDeploymentManifest,
16
16
  buildAgentPvcManifest,
17
17
  buildAgentSecretManifest,
18
+ PodServiceAccountConflictError,
18
19
  resolveAgentContainerResources,
19
20
  sanitizeAgentName,
20
- PodServiceAccountConflictError,
21
21
  TENANT_LABEL,
22
22
  } from "./agent-manifest.ts";
23
23
 
@@ -78,8 +78,8 @@ describe("buildAgentDeploymentManifest", () => {
78
78
  it("adds configured pod labels without changing immutable selectors or identity labels", () => {
79
79
  const base = buildAgentDeploymentManifest(deployOpts);
80
80
  const podLabels = {
81
- "vgs.io/service": "shipwright",
82
- "vgs.io/team": "team-infrastructure",
81
+ "example.com/service": "shipwright",
82
+ "example.com/team": "team-infrastructure",
83
83
  };
84
84
  const labeled = buildAgentDeploymentManifest({
85
85
  ...deployOpts,
@@ -7,7 +7,15 @@
7
7
  * Requires DATABASE_URL_ADMIN_TEST to be set; skips otherwise.
8
8
  */
9
9
 
10
- import { afterEach, beforeEach, describe, expect, it } from "bun:test";
10
+ import {
11
+ afterAll,
12
+ afterEach,
13
+ beforeAll,
14
+ beforeEach,
15
+ describe,
16
+ expect,
17
+ it,
18
+ } from "bun:test";
11
19
  import type { PrismaClient } from "../prisma/client/client.ts";
12
20
  import { AgentMarketplaceService } from "./agent-marketplaces.ts";
13
21
  import { AgentTokenService } from "./agent-tokens.ts";
@@ -28,6 +36,19 @@ const SESSION_SECRET = "test-admin-session-secret-32-bytes!";
28
36
  const ADMIN_KEY = "admin-key-token";
29
37
 
30
38
  describeOrSkip("AgentMarketplaceService + routes (integration)", () => {
39
+ // These routes are exercised with agent-scoped (runtime-kind) tokens; the
40
+ // runtime denylist would 403 the writes, so it is switched off here. The
41
+ // denylist itself is covered in tools-token-policy.*.test.ts.
42
+ const savedPolicy = process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY;
43
+ beforeAll(() => {
44
+ process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY = "off";
45
+ });
46
+ afterAll(() => {
47
+ if (savedPolicy === undefined)
48
+ delete process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY;
49
+ else process.env.SHIPWRIGHT_RUNTIME_TOKEN_POLICY = savedPolicy;
50
+ });
51
+
31
52
  let prisma: PrismaClient;
32
53
  let service: AgentMarketplaceService;
33
54
  let tokens: AgentTokenService;
@@ -9,8 +9,8 @@
9
9
  import { afterEach, beforeEach, describe, expect, it } from "bun:test";
10
10
  import type { PrismaClient } from "../prisma/client/client.ts";
11
11
  import { AgentMemberService, NoAccountMemberError } from "./agent-members.ts";
12
- import { resetMemberIdFixture } from "./test-support/member-id-test-support.ts";
13
12
  import { createAdminPrismaClient } from "./prisma-client.ts";
13
+ import { resetMemberIdFixture } from "./test-support/member-id-test-support.ts";
14
14
 
15
15
  const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
16
16
  const describeOrSkip = TEST_DB ? describe : describe.skip;
@@ -13,10 +13,10 @@ describe("agent pod label configuration", () => {
13
13
  it("accepts qualified keys, plain keys and Kubernetes label values", () => {
14
14
  expect(
15
15
  parseAgentPodLabels(
16
- '{"vgs.io/team":"team-infrastructure","app":"shipwright","empty":""}',
16
+ '{"example.com/team":"team-infrastructure","app":"shipwright","empty":""}',
17
17
  ),
18
18
  ).toEqual({
19
- "vgs.io/team": "team-infrastructure",
19
+ "example.com/team": "team-infrastructure",
20
20
  app: "shipwright",
21
21
  empty: "",
22
22
  });
@@ -2208,8 +2208,8 @@ describe("KubernetesAgentProvisioner.reconcile() — pod ServiceAccount drift (C
2208
2208
  describe("KubernetesAgentProvisioner configured pod labels", () => {
2209
2209
  const agentId = "agent-label-example";
2210
2210
  const podLabels = {
2211
- "vgs.io/service": "shipwright",
2212
- "vgs.io/team": "team-infrastructure",
2211
+ "example.com/service": "shipwright",
2212
+ "example.com/team": "team-infrastructure",
2213
2213
  };
2214
2214
  for (const policyOnly of [false, true]) {
2215
2215
  it(`updates existing templates and preserves selectors/unrelated labels (policyOnly=${policyOnly})`, async () => {
@@ -2229,7 +2229,7 @@ describe("KubernetesAgentProvisioner configured pod labels", () => {
2229
2229
  metadata: {
2230
2230
  labels: {
2231
2231
  "other.io/label": "preserved",
2232
- "vgs.io/team": "NOT_SET",
2232
+ "example.com/team": "NOT_SET",
2233
2233
  },
2234
2234
  },
2235
2235
  },
@@ -2247,7 +2247,7 @@ describe("KubernetesAgentProvisioner configured pod labels", () => {
2247
2247
  expect(preview.updated).toEqual([agentId]);
2248
2248
  expect(
2249
2249
  (await client.getDeployment(NAMESPACE, name)).spec.template.metadata
2250
- .labels["vgs.io/team"],
2250
+ .labels["example.com/team"],
2251
2251
  ).toBe("NOT_SET");
2252
2252
  expect(
2253
2253
  (await next.reconcile([{ id: agentId }], { policyOnly })).updated,
@@ -1,5 +1,8 @@
1
1
  import { describe, expect, it } from "bun:test";
2
- import { deriveAgentSetupSteps, renderAgentSetupPage } from "./admin-ui-pages.ts";
2
+ import {
3
+ deriveAgentSetupSteps,
4
+ renderAgentSetupPage,
5
+ } from "./admin-ui-pages.ts";
3
6
 
4
7
  const state = (env: Record<string, unknown>) =>
5
8
  Object.fromEntries(
@@ -29,7 +32,11 @@ describe("deriveAgentSetupSteps", () => {
29
32
  describe("renderAgentSetupPage", () => {
30
33
  const agent = { id: "a1", name: "Bot <b>" };
31
34
  it("shows connect links and no done state when incomplete", () => {
32
- const html = renderAgentSetupPage("u@x.com", agent, deriveAgentSetupSteps("a1", { GH_TOKEN: "t" }));
35
+ const html = renderAgentSetupPage(
36
+ "u@x.com",
37
+ agent,
38
+ deriveAgentSetupSteps("a1", { GH_TOKEN: "t" }),
39
+ );
33
40
  expect(html).toContain("Slack: not connected");
34
41
  expect(html).toContain("GitHub: connected");
35
42
  expect(html).toContain('href="/admin/agents/a1/access"');
@@ -37,7 +44,11 @@ describe("renderAgentSetupPage", () => {
37
44
  expect(html).toContain("Bot &lt;b&gt;");
38
45
  });
39
46
  it("shows all-done state linking to the agent page", () => {
40
- const html = renderAgentSetupPage("u@x.com", agent, deriveAgentSetupSteps("a1", { SLACK_APP_TOKEN: "x", GH_TOKEN: "t" }));
47
+ const html = renderAgentSetupPage(
48
+ "u@x.com",
49
+ agent,
50
+ deriveAgentSetupSteps("a1", { SLACK_APP_TOKEN: "x", GH_TOKEN: "t" }),
51
+ );
41
52
  expect(html).toContain("All set");
42
53
  expect(html).toContain('href="/admin/agents/a1"');
43
54
  });
@@ -11,12 +11,12 @@
11
11
  */
12
12
 
13
13
  import type { Prisma } from "../prisma/client/client.ts";
14
- import { ANTHROPIC_CREDENTIAL_KEYS } from "./anthropic-credential-guard.ts";
15
14
  import {
16
15
  validateMarketplaceName,
17
16
  validateMarketplaceRef,
18
17
  validateMarketplaceSource,
19
18
  } from "./agent-marketplaces.ts";
19
+ import { ANTHROPIC_CREDENTIAL_KEYS } from "./anthropic-credential-guard.ts";
20
20
  import { UnprocessableEntityError } from "./errors.ts";
21
21
  import type { TokenCrypto } from "./token-crypto.ts";
22
22
 
@@ -21,8 +21,8 @@ import { z } from "zod";
21
21
  import type { PrismaClient } from "../prisma/client/client.ts";
22
22
  import {
23
23
  AGENT_TEMPLATE_ITEM_KINDS,
24
- assertMarketplaceTemplateItem,
25
24
  type AgentTemplateItemKind,
25
+ assertMarketplaceTemplateItem,
26
26
  assertTemplateEnvKeyAllowed,
27
27
  openTemplateItemPayload,
28
28
  sealTemplateItemPayload,
@@ -8,15 +8,15 @@ import { AgentCronJobService } from "./agent-cron-jobs.ts";
8
8
  import { AgentEnvService } from "./agent-envs.ts";
9
9
  import { AgentMemberService } from "./agent-members.ts";
10
10
  import { AgentPluginService } from "./agent-plugins.ts";
11
- import { AgentToolService } from "./agent-tools.ts";
12
- import { AgentService, createAgent } from "./agents.ts";
13
- import { SpecialtyTypes } from "./specialty-types.ts";
14
11
  import { AgentTokenService } from "./agent-tokens.ts";
12
+ import { AgentToolService } from "./agent-tools.ts";
15
13
  import {
16
14
  AgentToolsTokenService,
17
15
  TOOLS_TOKEN_ENV_KEY,
18
16
  } from "./agent-tools-token.ts";
17
+ import { AgentService, createAgent } from "./agents.ts";
19
18
  import { createAdminPrismaClient } from "./prisma-client.ts";
19
+ import { SpecialtyTypes } from "./specialty-types.ts";
20
20
  import { identityCrypto } from "./token-crypto.ts";
21
21
 
22
22
  const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
package/src/api-auth.ts CHANGED
@@ -22,6 +22,7 @@ import {
22
22
  } from "./caller-scope.ts";
23
23
  import { ForbiddenError } from "./errors.ts";
24
24
  import {
25
+ runtimeTokenDenied,
25
26
  type ToolsTokenPolicyRule,
26
27
  toolsTokenDecision,
27
28
  } from "./tools-token-policy.ts";
@@ -383,11 +384,17 @@ export function createAdminAuthMiddleware(deps: {
383
384
  return c.json({ error: "Forbidden" }, 403);
384
385
  }
385
386
  // Tools-kind tokens are restricted by one route policy (see
386
- // tools-token-policy.ts); runtime-kind tokens are unaffected.
387
+ // tools-token-policy.ts); runtime-kind tokens get the smaller denylist
388
+ // unless SHIPWRIGHT_RUNTIME_TOKEN_POLICY=off.
387
389
  if (
388
- result.kind === "tools" &&
389
- toolsTokenDecision(c.req.method, c.req.path, deps.toolsTokenPolicy) ===
390
- "deny"
390
+ (result.kind === "tools" &&
391
+ toolsTokenDecision(
392
+ c.req.method,
393
+ c.req.path,
394
+ deps.toolsTokenPolicy,
395
+ ) === "deny") ||
396
+ (result.kind === "runtime" &&
397
+ runtimeTokenDenied(c.req.method, c.req.path))
391
398
  ) {
392
399
  return c.json({ error: "Forbidden" }, 403);
393
400
  }
@@ -1,10 +1,29 @@
1
1
  {
2
2
  "$comment": "The admin UI's actual current palette (light theme): toolbar base from lib/web/toolbar.ts plus the status/badge families from admin-ui-styles.ts. color + font only. Kept separate from theme-tokens.json, which stays PWA-chrome-only.",
3
3
  "color": {
4
- "bg": { "page": "#f7f7fb", "surface": "#ffffff", "subtle": "#f3f4f6", "muted": "#f9fafb" },
5
- "border": { "default": "#e8e8ee", "strong": "#d1d5db", "subtle": "#f3f4f6" },
6
- "text": { "heading": "#1a1a2e", "body": "#374151", "muted": "#6b7280", "faint": "#9ca3af" },
7
- "brand": { "default": "#4f46e5", "strong": "#4338ca", "bg": "#eef2ff", "border": "#c7d2fe" },
4
+ "bg": {
5
+ "page": "#f7f7fb",
6
+ "surface": "#ffffff",
7
+ "subtle": "#f3f4f6",
8
+ "muted": "#f9fafb"
9
+ },
10
+ "border": {
11
+ "default": "#e8e8ee",
12
+ "strong": "#d1d5db",
13
+ "subtle": "#f3f4f6"
14
+ },
15
+ "text": {
16
+ "heading": "#1a1a2e",
17
+ "body": "#374151",
18
+ "muted": "#6b7280",
19
+ "faint": "#9ca3af"
20
+ },
21
+ "brand": {
22
+ "default": "#4f46e5",
23
+ "strong": "#4338ca",
24
+ "bg": "#eef2ff",
25
+ "border": "#c7d2fe"
26
+ },
8
27
  "primary": { "default": "#1a1a2e", "hover": "#2d2d4e", "text": "#ffffff" },
9
28
  "success": { "bg": "#d1fae5", "text": "#065f46", "border": "#a7f3d0" },
10
29
  "warning": { "bg": "#fef3c7", "text": "#92400e", "border": "#fde68a" },
@@ -42,14 +42,21 @@ describe("brand-tokens.json", () => {
42
42
  });
43
43
 
44
44
  it("covers the status/badge families", () => {
45
- for (const k of ["success", "warning", "danger", "info", "violet", "teal"]) {
45
+ for (const k of [
46
+ "success",
47
+ "warning",
48
+ "danger",
49
+ "info",
50
+ "violet",
51
+ "teal",
52
+ ]) {
46
53
  expect(Object.keys(tokens.color), k).toContain(k);
47
54
  }
48
55
  });
49
56
 
50
57
  it("is exported via the package exports map", () => {
51
- expect(
52
- (pkg.exports as Record<string, string>)["./brand-tokens.json"],
53
- ).toBe("./src/brand-tokens.json");
58
+ expect((pkg.exports as Record<string, string>)["./brand-tokens.json"]).toBe(
59
+ "./src/brand-tokens.json",
60
+ );
54
61
  });
55
62
  });
@@ -4,7 +4,9 @@ import { parseChatCredentialConfig } from "./chat-credential-config.ts";
4
4
  describe("parseChatCredentialConfig", () => {
5
5
  it("is enabled only for the exact value 'enabled'", () => {
6
6
  expect(
7
- parseChatCredentialConfig({ SHIPWRIGHT_CHAT_TOKEN_MINT_ENABLED: "enabled" }),
7
+ parseChatCredentialConfig({
8
+ SHIPWRIGHT_CHAT_TOKEN_MINT_ENABLED: "enabled",
9
+ }),
8
10
  ).toEqual({ enabled: true });
9
11
  });
10
12
 
@@ -17,7 +19,9 @@ describe("parseChatCredentialConfig", () => {
17
19
  "fails closed (disabled) for invalid value %p",
18
20
  (value) => {
19
21
  expect(
20
- parseChatCredentialConfig({ SHIPWRIGHT_CHAT_TOKEN_MINT_ENABLED: value }),
22
+ parseChatCredentialConfig({
23
+ SHIPWRIGHT_CHAT_TOKEN_MINT_ENABLED: value,
24
+ }),
21
25
  ).toEqual({ enabled: false });
22
26
  },
23
27
  );
@@ -20,7 +20,9 @@ describe("parseChatMarkers", () => {
20
20
  });
21
21
 
22
22
  it("extracts plan URL from [plan:https://example.com/plan] marker", () => {
23
- const result = parseChatMarkers("See the plan [plan:https://example.com/plan]");
23
+ const result = parseChatMarkers(
24
+ "See the plan [plan:https://example.com/plan]",
25
+ );
24
26
  expect(result.planUrls).toContain("https://example.com/plan");
25
27
  expect(result.cleaned).not.toContain("[plan:");
26
28
  });
@@ -107,7 +109,8 @@ describe("parseChatMarkers", () => {
107
109
  });
108
110
 
109
111
  it("does not extract non-http plan URLs (defense-in-depth against javascript: injection)", () => {
110
- const text = "See [plan:javascript:alert(1)] and [plan:https://safe.example.com]";
112
+ const text =
113
+ "See [plan:javascript:alert(1)] and [plan:https://safe.example.com]";
111
114
  const result = parseChatMarkers(text);
112
115
  // javascript: URL should not be extracted — left in text as-is
113
116
  expect(result.planUrls).toEqual(["https://safe.example.com"]);
@@ -15,8 +15,8 @@ import {
15
15
  import { PLATFORM_OPS_ROUTES } from "./api-auth.ts";
16
16
  import type {
17
17
  CronRunNowStore,
18
- RunRequestRow,
19
18
  RunNowCron,
19
+ RunRequestRow,
20
20
  } from "./cron-run-now.ts";
21
21
  import { parseCronRunNowConfig } from "./cron-run-now-config.ts";
22
22
 
@@ -18,13 +18,13 @@ import { createRoute, type OpenAPIHono } from "@hono/zod-openapi";
18
18
  import type { PrismaClient } from "../prisma/client/client.ts";
19
19
  import type { AdminAuthEnv, AdminScope } from "./api-auth.ts";
20
20
  import { type Clock, SystemClock } from "./clock.ts";
21
+ import type { CronRunNowConfig } from "./cron-run-now-config.ts";
21
22
  import {
22
23
  BadRequestError,
23
24
  ConflictError,
24
25
  ForbiddenError,
25
26
  NotFoundError,
26
27
  } from "./errors.ts";
27
- import type { CronRunNowConfig } from "./cron-run-now-config.ts";
28
28
  import {
29
29
  CronIdParamSchema,
30
30
  CronRunNowResponseSchema,
@@ -45,8 +45,11 @@ describe("ApiError.status alias (Sentry defaultShouldHandleError contract)", ()
45
45
  ["BadRequestError", new BadRequestError(), 400],
46
46
  ["ForbiddenError", new ForbiddenError(), 403],
47
47
  ["BadGatewayError", new BadGatewayError(), 502],
48
- ] as const)("exposes status equal to statusCode on %s", (_name, err, expectedStatus) => {
49
- expect(err.status).toBe(err.statusCode);
50
- expect(err.status).toBe(expectedStatus);
51
- });
48
+ ] as const)(
49
+ "exposes status equal to statusCode on %s",
50
+ (_name, err, expectedStatus) => {
51
+ expect(err.status).toBe(err.statusCode);
52
+ expect(err.status).toBe(expectedStatus);
53
+ },
54
+ );
52
55
  });