@app-vitals/agent-admin 1.126.1 → 1.128.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.
- package/openapi.platform.json +494 -0
- package/package.json +2 -2
- package/prisma/client/internal/class.ts +4 -4
- package/prisma/client/internal/prismaNamespace.ts +2 -0
- package/prisma/client/internal/prismaNamespaceBrowser.ts +2 -0
- package/prisma/client/models/SessionAlertState.ts +37 -2
- package/prisma/client/models/SessionFollow.ts +37 -2
- package/prisma/migrations/20261203000000_add_account_id_to_session_follow_and_alert_state/migration.sql +34 -0
- package/prisma/schema/coding.prisma +6 -0
- package/src/admin-boot.ts +7 -1
- package/src/agent-github-apps-api.smoke.test.ts +330 -0
- package/src/agent-github-apps.ts +65 -0
- package/src/agent-github-apps.unit.test.ts +79 -0
- package/src/agents-api.ts +146 -0
- package/src/api.ts +40 -7
- package/src/openapi-schemas.ts +99 -0
- package/src/session-follow-account-id-migration.integration.test.ts +126 -0
- package/src/session-follow-account-id-migration.unit.test.ts +49 -0
- package/src/tools-token-policy.ts +38 -0
- package/src/tools-token-policy.unit.test.ts +19 -0
package/src/api.ts
CHANGED
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
23
23
|
import type { AgentCronJob } from "./agent-cron-jobs.ts";
|
|
24
24
|
import type { AgentEnvBundle } from "./agent-envs.ts";
|
|
25
|
+
import {
|
|
26
|
+
type AgentConfigBundleApp,
|
|
27
|
+
type AgentGitHubAppService,
|
|
28
|
+
toConfigBundleApps,
|
|
29
|
+
} from "./agent-github-apps.ts";
|
|
25
30
|
import type { AgentTokenService } from "./agent-tokens.ts";
|
|
26
31
|
import { anthropicCredentialKeysIn } from "./anthropic-credential-guard.ts";
|
|
27
32
|
import {
|
|
@@ -37,6 +42,7 @@ import {
|
|
|
37
42
|
RuntimeErrorSchema,
|
|
38
43
|
} from "./openapi-schemas.ts";
|
|
39
44
|
import {
|
|
45
|
+
blankAppsForToolsToken,
|
|
40
46
|
blankEnvForToolsToken,
|
|
41
47
|
type ToolsTokenPolicyRule,
|
|
42
48
|
} from "./tools-token-policy.ts";
|
|
@@ -119,6 +125,11 @@ export interface AgentConfigResponse {
|
|
|
119
125
|
features?: {
|
|
120
126
|
repoAccessCheck: boolean;
|
|
121
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* multi-github-apps 1.2: the agent's GitHub Apps with decrypted keys.
|
|
130
|
+
* Optional (additive); absent when the host did not wire the service.
|
|
131
|
+
*/
|
|
132
|
+
apps?: AgentConfigBundleApp[];
|
|
122
133
|
}
|
|
123
134
|
|
|
124
135
|
interface AgentEnvServiceLike {
|
|
@@ -190,6 +201,11 @@ export interface AgentPhaseMethodologyServiceLike {
|
|
|
190
201
|
}
|
|
191
202
|
|
|
192
203
|
export interface AgentRuntimeDeps {
|
|
204
|
+
/**
|
|
205
|
+
* multi-github-apps 1.2: optional (additive). When supplied the config
|
|
206
|
+
* bundle gains an `apps` array; absent means the member is omitted.
|
|
207
|
+
*/
|
|
208
|
+
agentGitHubAppService?: Pick<AgentGitHubAppService, "listCredentials">;
|
|
193
209
|
agentEnvService: AgentEnvServiceLike;
|
|
194
210
|
agentCronJobService: AgentCronJobServiceLike;
|
|
195
211
|
agentService: AgentServiceLike;
|
|
@@ -321,13 +337,19 @@ export function createAgentRuntimeApp(deps: AgentRuntimeDeps): OpenAPIHono {
|
|
|
321
337
|
}
|
|
322
338
|
|
|
323
339
|
// Fetch env bundle, plugins, and phase-methodology overrides in parallel
|
|
324
|
-
const [
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
340
|
+
const [
|
|
341
|
+
bundle,
|
|
342
|
+
plugins,
|
|
343
|
+
marketplaceRows,
|
|
344
|
+
phaseMethodologyRows,
|
|
345
|
+
appCredentials,
|
|
346
|
+
] = await Promise.all([
|
|
347
|
+
agentEnvService.getConfigBundle(id),
|
|
348
|
+
agentPluginService.listEnabled(id),
|
|
349
|
+
deps.agentMarketplaceService?.list(id),
|
|
350
|
+
agentPhaseMethodologyService?.list(id),
|
|
351
|
+
deps.agentGitHubAppService?.listCredentials(id),
|
|
352
|
+
]);
|
|
331
353
|
|
|
332
354
|
// WIF-2.1: with federation enabled, a non-self-hosted agent must never be
|
|
333
355
|
// handed Anthropic credentials, even ones already stored in its bundle
|
|
@@ -415,6 +437,17 @@ export function createAgentRuntimeApp(deps: AgentRuntimeDeps): OpenAPIHono {
|
|
|
415
437
|
features: {
|
|
416
438
|
repoAccessCheck: deps.repoAccessCheckEnabled === true,
|
|
417
439
|
},
|
|
440
|
+
// Keys travel here only (agent-authenticated route), like
|
|
441
|
+
// GH_APP_PRIVATE_KEY in env; tools-kind tokens get none. Omitted when
|
|
442
|
+
// the service is not wired. Legacy GH_APP_* env stays in `env`.
|
|
443
|
+
...(appCredentials
|
|
444
|
+
? {
|
|
445
|
+
apps: blankAppsForToolsToken(
|
|
446
|
+
scope,
|
|
447
|
+
toConfigBundleApps(appCredentials),
|
|
448
|
+
),
|
|
449
|
+
}
|
|
450
|
+
: {}),
|
|
418
451
|
};
|
|
419
452
|
|
|
420
453
|
// The route's Zod schema requires phaseMethodology; a platform-only admin
|
package/src/openapi-schemas.ts
CHANGED
|
@@ -935,6 +935,98 @@ export const UpsertAgentMarketplaceBodySchema = z
|
|
|
935
935
|
})
|
|
936
936
|
.openapi("UpsertAgentMarketplaceBody");
|
|
937
937
|
|
|
938
|
+
// ─── AgentGitHubApp ───────────────────────────────────────────────────────────
|
|
939
|
+
|
|
940
|
+
/** Read shape: metadata plus key flags. Keys are write-only and never returned. */
|
|
941
|
+
export const AgentGitHubAppSchema = z
|
|
942
|
+
.object({
|
|
943
|
+
id: z.string().openapi({ example: "clx1234567890" }),
|
|
944
|
+
agentId: z.string().openapi({ example: "clx1234567890" }),
|
|
945
|
+
appId: z.string().openapi({ example: "12345" }),
|
|
946
|
+
slug: z.string().nullable().openapi({ example: "my-app" }),
|
|
947
|
+
clientId: z
|
|
948
|
+
.string()
|
|
949
|
+
.nullable()
|
|
950
|
+
.openapi({ example: "Iv1.abcdef0123456789" }),
|
|
951
|
+
installationId: z.string().nullable().openapi({ example: "9876543" }),
|
|
952
|
+
priority: z.number().int().openapi({ example: 0 }),
|
|
953
|
+
hasPrivateKey: z.boolean().openapi({ example: true }),
|
|
954
|
+
hasClientSecret: z.boolean().openapi({ example: false }),
|
|
955
|
+
createdAt: z
|
|
956
|
+
.string()
|
|
957
|
+
.datetime()
|
|
958
|
+
.openapi({ example: "2026-01-01T00:00:00.000Z" }),
|
|
959
|
+
updatedAt: z
|
|
960
|
+
.string()
|
|
961
|
+
.datetime()
|
|
962
|
+
.openapi({ example: "2026-01-01T00:00:00.000Z" }),
|
|
963
|
+
})
|
|
964
|
+
.openapi("AgentGitHubApp");
|
|
965
|
+
|
|
966
|
+
/** Field formats are validated by AgentGitHubAppService (422), not here. */
|
|
967
|
+
export const CreateAgentGitHubAppBodySchema = z
|
|
968
|
+
.object({
|
|
969
|
+
appId: z.string().openapi({ example: "12345" }),
|
|
970
|
+
slug: z.string().nullable().optional().openapi({ example: "my-app" }),
|
|
971
|
+
clientId: z
|
|
972
|
+
.string()
|
|
973
|
+
.nullable()
|
|
974
|
+
.optional()
|
|
975
|
+
.openapi({ example: "Iv1.abcdef0123456789" }),
|
|
976
|
+
privateKey: z.string().openapi({
|
|
977
|
+
description: "PEM private key. Write-only: never returned.",
|
|
978
|
+
}),
|
|
979
|
+
clientSecret: z.string().nullable().optional().openapi({
|
|
980
|
+
description: "OAuth client secret. Write-only: never returned.",
|
|
981
|
+
}),
|
|
982
|
+
installationId: z
|
|
983
|
+
.string()
|
|
984
|
+
.nullable()
|
|
985
|
+
.optional()
|
|
986
|
+
.openapi({ example: "9876543" }),
|
|
987
|
+
priority: z.number().int().optional().openapi({
|
|
988
|
+
description:
|
|
989
|
+
"Lowest wins when two apps are installed on the same owner. Defaults to one past the agent's highest.",
|
|
990
|
+
example: 0,
|
|
991
|
+
}),
|
|
992
|
+
})
|
|
993
|
+
.openapi("CreateAgentGitHubAppBody");
|
|
994
|
+
|
|
995
|
+
export const UpdateAgentGitHubAppBodySchema = z
|
|
996
|
+
.object({
|
|
997
|
+
slug: z.string().nullable().optional(),
|
|
998
|
+
clientId: z.string().nullable().optional(),
|
|
999
|
+
privateKey: z
|
|
1000
|
+
.string()
|
|
1001
|
+
.optional()
|
|
1002
|
+
.openapi({ description: "Replaces the stored key. Write-only." }),
|
|
1003
|
+
clientSecret: z.string().nullable().optional().openapi({
|
|
1004
|
+
description: "Replaces the stored secret; null clears it. Write-only.",
|
|
1005
|
+
}),
|
|
1006
|
+
installationId: z.string().nullable().optional(),
|
|
1007
|
+
priority: z.number().int().optional(),
|
|
1008
|
+
})
|
|
1009
|
+
.openapi("UpdateAgentGitHubAppBody");
|
|
1010
|
+
|
|
1011
|
+
export const AgentGitHubAppIdParamSchema = z.object({
|
|
1012
|
+
id: z.string().openapi({ example: "clx1234567890" }),
|
|
1013
|
+
appRowId: z.string().openapi({ example: "clx0987654321" }),
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
/** One app in the config bundle. Carries keys: agent-authenticated route only. */
|
|
1017
|
+
export const AgentConfigGitHubAppSchema = z
|
|
1018
|
+
.object({
|
|
1019
|
+
id: z.string(),
|
|
1020
|
+
appId: z.string().openapi({ example: "12345" }),
|
|
1021
|
+
slug: z.string().nullable(),
|
|
1022
|
+
clientId: z.string().nullable(),
|
|
1023
|
+
installationId: z.string().nullable(),
|
|
1024
|
+
priority: z.number().int(),
|
|
1025
|
+
privateKey: z.string(),
|
|
1026
|
+
clientSecret: z.string().nullable(),
|
|
1027
|
+
})
|
|
1028
|
+
.openapi("AgentConfigGitHubApp");
|
|
1029
|
+
|
|
938
1030
|
// ─── Pipeline phases ────────────────────────────────────────────────────────────
|
|
939
1031
|
//
|
|
940
1032
|
// The six pipeline phases a methodology override can target — the keys of the
|
|
@@ -1386,6 +1478,13 @@ export const AgentConfigResponseSchema = z
|
|
|
1386
1478
|
* always populates it (empty array when the agent has none).
|
|
1387
1479
|
*/
|
|
1388
1480
|
marketplaces: z.array(AgentConfigMarketplaceSchema).optional(),
|
|
1481
|
+
/**
|
|
1482
|
+
* multi-github-apps 1.2: the agent's GitHub Apps with decrypted keys, in
|
|
1483
|
+
* priority order. Additive and optional; the legacy GH_APP_* env vars stay
|
|
1484
|
+
* in `env` until the runtime reads this (dual-read). Empty for tools-kind
|
|
1485
|
+
* tokens.
|
|
1486
|
+
*/
|
|
1487
|
+
apps: z.array(AgentConfigGitHubAppSchema).optional(),
|
|
1389
1488
|
repos: z.array(z.string()).openapi({ example: ["org/repo1", "org/repo2"] }),
|
|
1390
1489
|
reviewAuthorAllowlist: z
|
|
1391
1490
|
.array(z.string())
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/session-follow-account-id-migration.integration.test.ts
|
|
3
|
+
* Migration + backfill test for 20261203000000_add_account_id_to_session_follow_and_alert_state:
|
|
4
|
+
* members and owners get their account, users with no account stay NULL,
|
|
5
|
+
* existing unique constraints survive, and re-running is a no-op.
|
|
6
|
+
*
|
|
7
|
+
* Requires DATABASE_URL_ADMIN_TEST; skips otherwise.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
|
11
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
12
|
+
import { Client } from "pg";
|
|
13
|
+
|
|
14
|
+
const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
|
|
15
|
+
const describeOrSkip = TEST_DB ? describe : describe.skip;
|
|
16
|
+
|
|
17
|
+
const MIGRATIONS_DIR = new URL("../prisma/migrations/", import.meta.url);
|
|
18
|
+
const TARGET =
|
|
19
|
+
"20261203000000_add_account_id_to_session_follow_and_alert_state";
|
|
20
|
+
|
|
21
|
+
const ALL_MIGRATIONS = readdirSync(MIGRATIONS_DIR, { withFileTypes: true })
|
|
22
|
+
.filter((d) => d.isDirectory())
|
|
23
|
+
.map((d) => d.name)
|
|
24
|
+
.sort();
|
|
25
|
+
|
|
26
|
+
const migrationSql = (dir: string): string =>
|
|
27
|
+
readFileSync(new URL(`${dir}/migration.sql`, MIGRATIONS_DIR), "utf8");
|
|
28
|
+
|
|
29
|
+
describeOrSkip("accountId on SessionFollow and SessionAlertState", () => {
|
|
30
|
+
const schema = `session_acct_${process.pid}_${Date.now()}`;
|
|
31
|
+
let client: Client;
|
|
32
|
+
const notices: string[] = [];
|
|
33
|
+
|
|
34
|
+
beforeEach(async () => {
|
|
35
|
+
client = new Client({ connectionString: TEST_DB as string });
|
|
36
|
+
client.on("notice", (n) => notices.push(n.message ?? ""));
|
|
37
|
+
await client.connect();
|
|
38
|
+
await client.query(`CREATE SCHEMA "${schema}"`);
|
|
39
|
+
await client.query(`SET search_path TO "${schema}"`);
|
|
40
|
+
for (const dir of ALL_MIGRATIONS.slice(0, ALL_MIGRATIONS.indexOf(TARGET))) {
|
|
41
|
+
await client.query(migrationSql(dir));
|
|
42
|
+
}
|
|
43
|
+
await client.query(
|
|
44
|
+
`INSERT INTO "Account" ("id","name","updatedAt") VALUES ('acc1','Acme',now())`,
|
|
45
|
+
);
|
|
46
|
+
await client.query(
|
|
47
|
+
`INSERT INTO "AccountMember" ("id","accountId","email","role")
|
|
48
|
+
VALUES ('m1','acc1','owner@example.com','owner'),
|
|
49
|
+
('m2','acc1','member@example.com','member')`,
|
|
50
|
+
);
|
|
51
|
+
// Distinct shapes: owner, member (mixed-case email), no account.
|
|
52
|
+
for (const email of [
|
|
53
|
+
"owner@example.com",
|
|
54
|
+
"Member@Example.com",
|
|
55
|
+
"nobody@example.com",
|
|
56
|
+
]) {
|
|
57
|
+
await client.query(
|
|
58
|
+
`INSERT INTO "SessionFollow" ("id","userEmail","sessionSlug","updatedAt")
|
|
59
|
+
VALUES ($1,$2,'s1',now())`,
|
|
60
|
+
[`f-${email}`, email],
|
|
61
|
+
);
|
|
62
|
+
await client.query(
|
|
63
|
+
`INSERT INTO "SessionAlertState" ("id","userEmail","sessionSlug","updatedAt")
|
|
64
|
+
VALUES ($1,$2,'s1',now())`,
|
|
65
|
+
[`a-${email}`, email],
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
afterEach(async () => {
|
|
71
|
+
await client.query(`DROP SCHEMA IF EXISTS "${schema}" CASCADE`);
|
|
72
|
+
await client.end();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const accounts = async (table: string) =>
|
|
76
|
+
(
|
|
77
|
+
await client.query(
|
|
78
|
+
`SELECT "userEmail","accountId" FROM "${table}" ORDER BY "userEmail"`,
|
|
79
|
+
)
|
|
80
|
+
).rows;
|
|
81
|
+
|
|
82
|
+
it("backfills members and owners, leaves no-account users NULL, reports the count", async () => {
|
|
83
|
+
await client.query(migrationSql(TARGET));
|
|
84
|
+
const expected = [
|
|
85
|
+
{ userEmail: "Member@Example.com", accountId: "acc1" },
|
|
86
|
+
{ userEmail: "nobody@example.com", accountId: null },
|
|
87
|
+
{ userEmail: "owner@example.com", accountId: "acc1" },
|
|
88
|
+
];
|
|
89
|
+
expect(await accounts("SessionFollow")).toEqual(expected);
|
|
90
|
+
expect(await accounts("SessionAlertState")).toEqual(expected);
|
|
91
|
+
expect(
|
|
92
|
+
notices.some((m) =>
|
|
93
|
+
m.includes("1 SessionFollow and 1 SessionAlertState rows left NULL"),
|
|
94
|
+
),
|
|
95
|
+
).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("is idempotent and does not overwrite an existing accountId", async () => {
|
|
99
|
+
await client.query(migrationSql(TARGET));
|
|
100
|
+
await client.query(
|
|
101
|
+
`UPDATE "SessionFollow" SET "accountId"='other' WHERE "userEmail"='owner@example.com'`,
|
|
102
|
+
);
|
|
103
|
+
await client.query(migrationSql(TARGET));
|
|
104
|
+
const rows = await accounts("SessionFollow");
|
|
105
|
+
expect(
|
|
106
|
+
rows.find((r) => r.userEmail === "owner@example.com")?.accountId,
|
|
107
|
+
).toBe("other");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("keeps the old unique constraint and adds the new one", async () => {
|
|
111
|
+
await client.query(migrationSql(TARGET));
|
|
112
|
+
await expect(
|
|
113
|
+
client.query(
|
|
114
|
+
`INSERT INTO "SessionFollow" ("id","userEmail","sessionSlug","updatedAt")
|
|
115
|
+
VALUES ('dup','owner@example.com','s1',now())`,
|
|
116
|
+
),
|
|
117
|
+
).rejects.toThrow(/SessionFollow_userEmail_sessionSlug_key/);
|
|
118
|
+
await client.query(`DROP INDEX "SessionFollow_userEmail_sessionSlug_key"`);
|
|
119
|
+
await expect(
|
|
120
|
+
client.query(
|
|
121
|
+
`INSERT INTO "SessionFollow" ("id","userEmail","accountId","sessionSlug","updatedAt")
|
|
122
|
+
VALUES ('dup','owner@example.com','acc1','s1',now())`,
|
|
123
|
+
),
|
|
124
|
+
).rejects.toThrow(/SessionFollow_userEmail_accountId_sessionSlug_key/);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/session-follow-account-id-migration.unit.test.ts
|
|
3
|
+
* Static checks on the accountId migration SQL: idempotency, additivity, and
|
|
4
|
+
* the backfill mapping (lowercased email -> AccountMember, only NULL rows).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, expect, it } from "bun:test";
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
|
|
10
|
+
const sql = readFileSync(
|
|
11
|
+
new URL(
|
|
12
|
+
"../prisma/migrations/20261203000000_add_account_id_to_session_follow_and_alert_state/migration.sql",
|
|
13
|
+
import.meta.url,
|
|
14
|
+
),
|
|
15
|
+
"utf8",
|
|
16
|
+
);
|
|
17
|
+
const code = sql.replace(/^--.*$/gm, "");
|
|
18
|
+
const TABLES = ["SessionFollow", "SessionAlertState"];
|
|
19
|
+
|
|
20
|
+
describe("accountId migration SQL", () => {
|
|
21
|
+
it.each(TABLES)("%s: idempotent nullable column and unique index", (t) => {
|
|
22
|
+
expect(code).toContain(
|
|
23
|
+
`ALTER TABLE "${t}" ADD COLUMN IF NOT EXISTS "accountId" TEXT;`,
|
|
24
|
+
);
|
|
25
|
+
expect(code).toContain(
|
|
26
|
+
`CREATE UNIQUE INDEX IF NOT EXISTS "${t}_userEmail_accountId_sessionSlug_key" ON "${t}"("userEmail", "accountId", "sessionSlug");`,
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it.each(TABLES)(
|
|
31
|
+
"%s: backfill maps lower(userEmail) and skips set rows",
|
|
32
|
+
(t) => {
|
|
33
|
+
const stmt = code
|
|
34
|
+
.split(";")
|
|
35
|
+
.find((s) => s.includes(`UPDATE "${t}"`)) as string;
|
|
36
|
+
expect(stmt).toContain(`"AccountMember"`);
|
|
37
|
+
expect(stmt).toContain(`t."accountId" IS NULL`);
|
|
38
|
+
expect(stmt).toContain(`lower(t."userEmail") = m."email"`);
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
it("is additive: no drops, no FKs, no NOT NULL", () => {
|
|
43
|
+
expect(code).not.toMatch(/DROP |FOREIGN KEY|NOT NULL|REFERENCES/i);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("reports the rows left NULL", () => {
|
|
47
|
+
expect(code).toContain("RAISE NOTICE");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -200,6 +200,33 @@ export const TOOLS_TOKEN_POLICY: readonly ToolsTokenPolicyRule[] = [
|
|
|
200
200
|
subpaths: true,
|
|
201
201
|
note: "marketplace write",
|
|
202
202
|
},
|
|
203
|
+
{
|
|
204
|
+
method: "GET",
|
|
205
|
+
path: "/agents/{id}/github-apps",
|
|
206
|
+
decision: A,
|
|
207
|
+
note: "masked read",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
method: "POST",
|
|
211
|
+
path: "/agents/{id}/github-apps",
|
|
212
|
+
decision: D,
|
|
213
|
+
subpaths: true,
|
|
214
|
+
note: "github app write",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
method: "PATCH",
|
|
218
|
+
path: "/agents/{id}/github-apps/{appRowId}",
|
|
219
|
+
decision: D,
|
|
220
|
+
subpaths: true,
|
|
221
|
+
note: "github app write",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
method: "DELETE",
|
|
225
|
+
path: "/agents/{id}/github-apps/{appRowId}",
|
|
226
|
+
decision: D,
|
|
227
|
+
subpaths: true,
|
|
228
|
+
note: "github app write",
|
|
229
|
+
},
|
|
203
230
|
// Crons: reads allowed; create/PATCH allowed with the preCheck content rule.
|
|
204
231
|
{
|
|
205
232
|
method: "POST",
|
|
@@ -438,6 +465,9 @@ export const RUNTIME_TOKEN_DENYLIST: readonly ToolsTokenPolicyRule[] = [
|
|
|
438
465
|
"marketplace write",
|
|
439
466
|
true,
|
|
440
467
|
),
|
|
468
|
+
RD("POST", "/agents/{id}/github-apps", "github app write", true),
|
|
469
|
+
RD("PATCH", "/agents/{id}/github-apps/{appRowId}", "github app write", true),
|
|
470
|
+
RD("DELETE", "/agents/{id}/github-apps/{appRowId}", "github app write", true),
|
|
441
471
|
RD("POST", "/agents/{id}/crons", "cron create"),
|
|
442
472
|
RD("PATCH", "/agents/{id}/crons/{cronId}", "cron update"),
|
|
443
473
|
RD("DELETE", "/agents/{id}/crons/{cronId}", "cron delete"),
|
|
@@ -553,6 +583,14 @@ export function blankEnvForToolsToken(
|
|
|
553
583
|
return isToolsKindScope(scope) ? {} : env;
|
|
554
584
|
}
|
|
555
585
|
|
|
586
|
+
/** Config bundle GitHub App keys for the caller: `[]` for tools-kind, unchanged otherwise. */
|
|
587
|
+
export function blankAppsForToolsToken<T>(
|
|
588
|
+
scope: AdminScope | undefined,
|
|
589
|
+
apps: T[],
|
|
590
|
+
): T[] {
|
|
591
|
+
return isToolsKindScope(scope) ? [] : apps;
|
|
592
|
+
}
|
|
593
|
+
|
|
556
594
|
// ─── Enforcement ──────────────────────────────────────────────────────────────
|
|
557
595
|
|
|
558
596
|
/**
|
|
@@ -384,3 +384,22 @@ describe("runtime-kind enforcement points", () => {
|
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
|
+
|
|
388
|
+
describe("github-apps routes", () => {
|
|
389
|
+
const ID = "agent-1";
|
|
390
|
+
for (const [m, p] of [
|
|
391
|
+
["POST", `/agents/${ID}/github-apps`],
|
|
392
|
+
["PATCH", `/agents/${ID}/github-apps/row1`],
|
|
393
|
+
["DELETE", `/agents/${ID}/github-apps/row1`],
|
|
394
|
+
] as const) {
|
|
395
|
+
it(`denies ${m} ${p} for tools and runtime tokens`, () => {
|
|
396
|
+
expect(toolsTokenDecision(m, p)).toBe("deny");
|
|
397
|
+
expect(runtimeTokenDecision(m, p)).toBe("deny");
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
it("allows the masked list read for tools tokens", () => {
|
|
401
|
+
expect(toolsTokenDecision("GET", `/agents/${ID}/github-apps`)).toBe(
|
|
402
|
+
"allow",
|
|
403
|
+
);
|
|
404
|
+
});
|
|
405
|
+
});
|