@app-vitals/agent-admin 1.36.1 → 1.37.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.json +5 -0
- package/openapi.platform.json +5 -0
- package/package.json +2 -2
- package/src/admin-boot.ts +1 -0
- package/src/admin-ui-installation-repos-pages.ts +1 -1
- package/src/admin-ui-installation-repos.smoke.test.ts +11 -0
- package/src/agents-api.ts +4 -0
- package/src/api.smoke.test.ts +47 -0
- package/src/api.ts +14 -1
- package/src/github-installation-wiring.unit.test.ts +1 -1
- package/src/github-sync.ts +3 -1
- package/src/github-sync.unit.test.ts +35 -2
- package/src/installation-ports-fixture.integration.test.ts +5 -4
- package/src/installation-repos-service.ts +24 -3
- package/src/installation-repos-service.unit.test.ts +18 -3
- package/src/openapi-schemas.ts +8 -1
- package/src/transcript-config.ts +12 -1
- package/src/transcript-config.unit.test.ts +18 -0
package/openapi.json
CHANGED
|
@@ -3490,6 +3490,11 @@
|
|
|
3490
3490
|
"type": "boolean",
|
|
3491
3491
|
"description": "Reserved for the repo-access check (COS-44.1).",
|
|
3492
3492
|
"example": false
|
|
3493
|
+
},
|
|
3494
|
+
"loopTranscriptUpload": {
|
|
3495
|
+
"type": "boolean",
|
|
3496
|
+
"description": "True when SHIPWRIGHT_TRANSCRIPT_API_ENABLED is on and this agent is listed in SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS: coding-loop runs may upload a redacted transcript through the extension capability.",
|
|
3497
|
+
"example": false
|
|
3493
3498
|
}
|
|
3494
3499
|
},
|
|
3495
3500
|
"required": [
|
package/openapi.platform.json
CHANGED
|
@@ -3731,6 +3731,11 @@
|
|
|
3731
3731
|
"type": "boolean",
|
|
3732
3732
|
"description": "Reserved for the repo-access check (COS-44.1).",
|
|
3733
3733
|
"example": false
|
|
3734
|
+
},
|
|
3735
|
+
"loopTranscriptUpload": {
|
|
3736
|
+
"type": "boolean",
|
|
3737
|
+
"description": "True when SHIPWRIGHT_TRANSCRIPT_API_ENABLED is on and this agent is listed in SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS: coding-loop runs may upload a redacted transcript through the extension capability.",
|
|
3738
|
+
"example": false
|
|
3734
3739
|
}
|
|
3735
3740
|
},
|
|
3736
3741
|
"required": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@anthropic-ai/sdk": "0.135.0",
|
|
45
|
-
"@app-vitals/agent-lib": "1.
|
|
45
|
+
"@app-vitals/agent-lib": "1.37.0",
|
|
46
46
|
"@hono/zod-openapi": "^1.0.0",
|
|
47
47
|
"@prisma/adapter-pg": "^7.10.0",
|
|
48
48
|
"@prisma/client": "^7.10.0",
|
package/src/admin-boot.ts
CHANGED
|
@@ -456,6 +456,7 @@ export async function startAdmin(
|
|
|
456
456
|
agentTokenService,
|
|
457
457
|
anthropicFederationEnabled,
|
|
458
458
|
transcriptUploadEnabled: transcriptConfig.enabled,
|
|
459
|
+
loopTranscriptAgentIds: transcriptConfig.loopAgentIds,
|
|
459
460
|
repoAccessCheckEnabled: repoAccessConfig.enabled,
|
|
460
461
|
});
|
|
461
462
|
|
|
@@ -88,7 +88,7 @@ export const NO_USERNAME_REASON =
|
|
|
88
88
|
"No GitHub username is bound to this agent, so there is nothing to sync against. Bind one under Owner and identities.";
|
|
89
89
|
|
|
90
90
|
export const APP_ID_MISMATCH_MESSAGE =
|
|
91
|
-
"No installation
|
|
91
|
+
"No installation of the agent GitHub App was found on any org the installer can reach, although the Installations card lists one. The App is matched by client id or slug: check the App installation and the agent GH_APP_CLIENT_ID / GH_APP_SLUG.";
|
|
92
92
|
|
|
93
93
|
/** JSON body of GET /agents/:id/github-sync/preview. */
|
|
94
94
|
export interface GithubSyncPreviewView {
|
|
@@ -314,6 +314,17 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
314
314
|
expect(html).not.toContain("github-sync-confirm-btn");
|
|
315
315
|
});
|
|
316
316
|
|
|
317
|
+
it("shows the no-installation reason, never 'Already in sync'", async () => {
|
|
318
|
+
const reason = "No installation of the agent GitHub App was found";
|
|
319
|
+
const { app } = setup({
|
|
320
|
+
agentsApi: () => json({ status: "skipped", reason }),
|
|
321
|
+
});
|
|
322
|
+
const html = await (await get(app, "/github-sync/confirm")).text();
|
|
323
|
+
expect(html).toContain('data-sync="skipped"');
|
|
324
|
+
expect(html).toContain("No installation of the agent GitHub App");
|
|
325
|
+
expect(html).not.toContain("Already in sync");
|
|
326
|
+
});
|
|
327
|
+
|
|
317
328
|
it("surfaces an API failure on the confirm step", async () => {
|
|
318
329
|
const { app } = setup({
|
|
319
330
|
agentsApi: () => json({ error: "GitHub Apps are not configured" }, 503),
|
package/src/agents-api.ts
CHANGED
|
@@ -3251,6 +3251,10 @@ export function createAdminApp(deps: AdminDeps): OpenAPIHono<AdminAuthEnv> {
|
|
|
3251
3251
|
const svc = installationReposService(c);
|
|
3252
3252
|
const { id: agentId } = c.req.valid("param");
|
|
3253
3253
|
const result = await svc.list(agentId);
|
|
3254
|
+
if (result.status === "skipped") {
|
|
3255
|
+
// No installation matched: the listing stays empty (additive shape).
|
|
3256
|
+
return c.json({ appId: result.appId, orgs: [] }, 200);
|
|
3257
|
+
}
|
|
3254
3258
|
if (result.status !== "ok") return installationFailure(agentId, result);
|
|
3255
3259
|
return c.json({ appId: result.appId, orgs: result.orgs }, 200);
|
|
3256
3260
|
});
|
package/src/api.smoke.test.ts
CHANGED
|
@@ -244,6 +244,7 @@ function buildApp(opts?: {
|
|
|
244
244
|
cleanupMergedWorktrees?: boolean;
|
|
245
245
|
cleanupAfterDays?: number;
|
|
246
246
|
transcriptUploadEnabled?: boolean;
|
|
247
|
+
loopTranscriptAgentIds?: string[];
|
|
247
248
|
repoAccessCheckEnabled?: boolean;
|
|
248
249
|
}) {
|
|
249
250
|
const hasAgent = opts?.hasAgent ?? true;
|
|
@@ -319,6 +320,7 @@ function buildApp(opts?: {
|
|
|
319
320
|
sessionSecret: SESSION_SECRET,
|
|
320
321
|
anthropicFederationEnabled: opts?.anthropicFederationEnabled,
|
|
321
322
|
transcriptUploadEnabled: opts?.transcriptUploadEnabled,
|
|
323
|
+
loopTranscriptAgentIds: opts?.loopTranscriptAgentIds,
|
|
322
324
|
repoAccessCheckEnabled: opts?.repoAccessCheckEnabled,
|
|
323
325
|
});
|
|
324
326
|
}
|
|
@@ -364,6 +366,7 @@ describe("GET /:id/config features (COS-43.1)", () => {
|
|
|
364
366
|
expect(body.features).toEqual({
|
|
365
367
|
transcriptUpload: false,
|
|
366
368
|
repoAccessCheck: false,
|
|
369
|
+
loopTranscriptUpload: false,
|
|
367
370
|
});
|
|
368
371
|
});
|
|
369
372
|
|
|
@@ -374,10 +377,53 @@ describe("GET /:id/config features (COS-43.1)", () => {
|
|
|
374
377
|
expect(body.features).toEqual({
|
|
375
378
|
transcriptUpload: true,
|
|
376
379
|
repoAccessCheck: false,
|
|
380
|
+
loopTranscriptUpload: false,
|
|
377
381
|
});
|
|
378
382
|
});
|
|
379
383
|
});
|
|
380
384
|
|
|
385
|
+
describe("GET /:id/config features.loopTranscriptUpload", () => {
|
|
386
|
+
const loopFlag = async (opts: Parameters<typeof buildApp>[0]) => {
|
|
387
|
+
const res = await buildApp(opts).request(`/${KNOWN_AGENT_ID}/config`, {
|
|
388
|
+
headers: { Authorization: `Bearer ${VALID_ADMIN_KEY}` },
|
|
389
|
+
});
|
|
390
|
+
return (await res.json()).features.loopTranscriptUpload;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
test("truth table: only a listed agent with the transcript flag on is true", async () => {
|
|
394
|
+
expect(await loopFlag({})).toBe(false);
|
|
395
|
+
expect(await loopFlag({ loopTranscriptAgentIds: [] })).toBe(false);
|
|
396
|
+
expect(
|
|
397
|
+
await loopFlag({
|
|
398
|
+
transcriptUploadEnabled: true,
|
|
399
|
+
loopTranscriptAgentIds: ["other-agent"],
|
|
400
|
+
}),
|
|
401
|
+
).toBe(false);
|
|
402
|
+
expect(
|
|
403
|
+
await loopFlag({
|
|
404
|
+
transcriptUploadEnabled: false,
|
|
405
|
+
loopTranscriptAgentIds: [KNOWN_AGENT_ID],
|
|
406
|
+
}),
|
|
407
|
+
).toBe(false);
|
|
408
|
+
expect(
|
|
409
|
+
await loopFlag({
|
|
410
|
+
transcriptUploadEnabled: true,
|
|
411
|
+
loopTranscriptAgentIds: [KNOWN_AGENT_ID],
|
|
412
|
+
}),
|
|
413
|
+
).toBe(true);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
test("leaves features.transcriptUpload untouched", async () => {
|
|
417
|
+
const res = await buildApp({
|
|
418
|
+
transcriptUploadEnabled: false,
|
|
419
|
+
loopTranscriptAgentIds: [KNOWN_AGENT_ID],
|
|
420
|
+
}).request(`/${KNOWN_AGENT_ID}/config`, {
|
|
421
|
+
headers: { Authorization: `Bearer ${VALID_ADMIN_KEY}` },
|
|
422
|
+
});
|
|
423
|
+
expect((await res.json()).features.transcriptUpload).toBe(false);
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
|
|
381
427
|
describe("GET /:id/config features.repoAccessCheck (COS-44.1)", () => {
|
|
382
428
|
test("follows the repo-access flag", async () => {
|
|
383
429
|
const app = buildApp({ repoAccessCheckEnabled: true });
|
|
@@ -387,6 +433,7 @@ describe("GET /:id/config features.repoAccessCheck (COS-44.1)", () => {
|
|
|
387
433
|
expect((await res.json()).features).toEqual({
|
|
388
434
|
transcriptUpload: false,
|
|
389
435
|
repoAccessCheck: true,
|
|
436
|
+
loopTranscriptUpload: false,
|
|
390
437
|
});
|
|
391
438
|
});
|
|
392
439
|
});
|
package/src/api.ts
CHANGED
|
@@ -108,7 +108,11 @@ export interface AgentConfigResponse {
|
|
|
108
108
|
* COS-43.1: feature flags the runtime acts on. Optional so fixtures built
|
|
109
109
|
* before it keep compiling; the live handler always populates it.
|
|
110
110
|
*/
|
|
111
|
-
features?: {
|
|
111
|
+
features?: {
|
|
112
|
+
transcriptUpload: boolean;
|
|
113
|
+
repoAccessCheck: boolean;
|
|
114
|
+
loopTranscriptUpload?: boolean;
|
|
115
|
+
};
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
interface AgentEnvServiceLike {
|
|
@@ -201,6 +205,12 @@ export interface AgentRuntimeDeps {
|
|
|
201
205
|
* as `features.transcriptUpload` in the config bundle. Defaults to false.
|
|
202
206
|
*/
|
|
203
207
|
transcriptUploadEnabled?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS: agent ids whose coding-loop runs
|
|
210
|
+
* upload transcripts. Combined with `transcriptUploadEnabled` into
|
|
211
|
+
* `features.loopTranscriptUpload`. Defaults to none.
|
|
212
|
+
*/
|
|
213
|
+
loopTranscriptAgentIds?: readonly string[];
|
|
204
214
|
/**
|
|
205
215
|
* COS-44.1: SHIPWRIGHT_AGENT_REPO_ACCESS_CHECK_ENABLED is on — surfaced to the
|
|
206
216
|
* runtime as `features.repoAccessCheck` in the config bundle. Defaults to false.
|
|
@@ -393,6 +403,9 @@ export function createAgentRuntimeApp(deps: AgentRuntimeDeps): OpenAPIHono {
|
|
|
393
403
|
cleanupAfterDays: agent.cleanupAfterDays,
|
|
394
404
|
features: {
|
|
395
405
|
transcriptUpload: deps.transcriptUploadEnabled === true,
|
|
406
|
+
loopTranscriptUpload:
|
|
407
|
+
deps.transcriptUploadEnabled === true &&
|
|
408
|
+
(deps.loopTranscriptAgentIds ?? []).includes(agent.id),
|
|
396
409
|
repoAccessCheck: deps.repoAccessCheckEnabled === true,
|
|
397
410
|
},
|
|
398
411
|
};
|
package/src/github-sync.ts
CHANGED
|
@@ -28,6 +28,7 @@ import type { GithubAccessPreviewFn } from "./github-access-preview.ts";
|
|
|
28
28
|
import {
|
|
29
29
|
identityOf,
|
|
30
30
|
type InstallationReposPort,
|
|
31
|
+
NO_INSTALLATION_REASON,
|
|
31
32
|
} from "./installation-repos-service.ts";
|
|
32
33
|
import {
|
|
33
34
|
MAX_UNCONFIRMED_REMOVALS,
|
|
@@ -393,12 +394,13 @@ export class GithubSyncService {
|
|
|
393
394
|
agent.appId,
|
|
394
395
|
identityOf(agent),
|
|
395
396
|
);
|
|
397
|
+
if (installed.status === "none") return skippedPlan(NO_INSTALLATION_REASON);
|
|
396
398
|
return planGithubSync({
|
|
397
399
|
username,
|
|
398
400
|
access: preview.access,
|
|
399
401
|
agentRepos: agent.repos,
|
|
400
402
|
installationRepos: Object.fromEntries(
|
|
401
|
-
installed.map(({ org, repos }) => [org, repos]),
|
|
403
|
+
installed.orgs.map(({ org, repos }) => [org, repos]),
|
|
402
404
|
),
|
|
403
405
|
...(requested
|
|
404
406
|
? {
|
|
@@ -13,7 +13,10 @@ import type {
|
|
|
13
13
|
InstallationAgentRecord,
|
|
14
14
|
InstallationAuditEntry,
|
|
15
15
|
} from "./installation-ports.ts";
|
|
16
|
-
import
|
|
16
|
+
import {
|
|
17
|
+
type InstallationReposPort,
|
|
18
|
+
NO_INSTALLATION_REASON,
|
|
19
|
+
} from "./installation-repos-service.ts";
|
|
17
20
|
import type { OpenWorkPort } from "./reconcile-open-work.ts";
|
|
18
21
|
import { repoLostAccessBlockReason } from "./repo-removal-open-work.ts";
|
|
19
22
|
import {
|
|
@@ -249,6 +252,7 @@ function harness(
|
|
|
249
252
|
agent?: Partial<InstallationAgentRecord> | null;
|
|
250
253
|
access?: Awaited<ReturnType<GithubAccessPreviewFn>>;
|
|
251
254
|
installed?: { org: string; repos: string[] }[];
|
|
255
|
+
noInstallation?: boolean;
|
|
252
256
|
removeFails?: boolean;
|
|
253
257
|
openWork?: Partial<OpenWorkPort> | null;
|
|
254
258
|
} = {},
|
|
@@ -269,7 +273,9 @@ function harness(
|
|
|
269
273
|
> = {
|
|
270
274
|
listInstalled: async (appId) => {
|
|
271
275
|
calls.push(["listInstalled", appId]);
|
|
272
|
-
return
|
|
276
|
+
return opts.noInstallation
|
|
277
|
+
? { status: "none" }
|
|
278
|
+
: { status: "found", orgs: installed };
|
|
273
279
|
},
|
|
274
280
|
addRepos: async (appId, o, r) => {
|
|
275
281
|
calls.push(["addRepos", appId, o, [...r]]);
|
|
@@ -339,6 +345,33 @@ const applyInput = (
|
|
|
339
345
|
...extra,
|
|
340
346
|
});
|
|
341
347
|
|
|
348
|
+
describe("GithubSyncService with no installation", () => {
|
|
349
|
+
it("preview is skipped with the no-installation reason", async () => {
|
|
350
|
+
const { svc } = harness({ noInstallation: true });
|
|
351
|
+
expect(await svc.preview("ag")).toEqual({
|
|
352
|
+
status: "skipped",
|
|
353
|
+
reason: NO_INSTALLATION_REASON,
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it("apply is skipped, not noop, and changes nothing", async () => {
|
|
358
|
+
const { svc, calls, audits } = harness({ noInstallation: true });
|
|
359
|
+
expect(await svc.apply(applyInput({}))).toEqual({
|
|
360
|
+
status: "skipped",
|
|
361
|
+
reason: NO_INSTALLATION_REASON,
|
|
362
|
+
});
|
|
363
|
+
expect(calls.map((c) => c[0])).toEqual(["listInstalled"]);
|
|
364
|
+
expect(audits).toEqual([]);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it("an App matched to an org with nothing to change still returns noop", async () => {
|
|
368
|
+
const { svc } = harness({
|
|
369
|
+
installed: [{ org: "acme", repos: ["acme/a", "acme/b"] }],
|
|
370
|
+
});
|
|
371
|
+
expect((await svc.apply(applyInput({}))).status).toBe("noop");
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
|
|
342
375
|
describe("GithubSyncService.preview", () => {
|
|
343
376
|
it("returns all three lists plus the open work removals block, changing nothing", async () => {
|
|
344
377
|
const { svc, calls, audits } = harness();
|
|
@@ -53,9 +53,10 @@ describe("installation ports with the no-app_id fixture", () => {
|
|
|
53
53
|
});
|
|
54
54
|
await port.addRepos(7, ORG, [`${ORG}/repo-b`], identity);
|
|
55
55
|
await port.removeRepos(7, ORG, [`${ORG}/repo-c`], identity);
|
|
56
|
-
expect(await reposPort.listInstalled(7, identity)).toEqual(
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
expect(await reposPort.listInstalled(7, identity)).toEqual({
|
|
57
|
+
status: "found",
|
|
58
|
+
orgs: [{ org: ORG, repos: [`${ORG}/repo-a`] }],
|
|
59
|
+
});
|
|
59
60
|
expect(calls).toEqual([
|
|
60
61
|
"list:1000001",
|
|
61
62
|
"add:1000001:repo-b",
|
|
@@ -73,6 +74,6 @@ describe("installation ports with the no-app_id fixture", () => {
|
|
|
73
74
|
await expect(
|
|
74
75
|
port.addRepos(7, ORG, [`${ORG}/x`], {}),
|
|
75
76
|
).rejects.toBeInstanceOf(AppNotInstalledError);
|
|
76
|
-
expect(await reposPort.listInstalled(7)).toEqual(
|
|
77
|
+
expect(await reposPort.listInstalled(7)).toEqual({ status: "none" });
|
|
77
78
|
});
|
|
78
79
|
});
|
|
@@ -18,14 +18,25 @@ import type {
|
|
|
18
18
|
UserRepoAccessResult,
|
|
19
19
|
} from "./user-repo-access-resolver.ts";
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* The orgs the agent App is installed on, or "none" when the App matched no
|
|
23
|
+
* org the installer can reach (distinct from an installation with no changes).
|
|
24
|
+
*/
|
|
25
|
+
export type InstalledOrgsResult =
|
|
26
|
+
| { status: "found"; orgs: { org: string; repos: string[] }[] }
|
|
27
|
+
| { status: "none" };
|
|
28
|
+
|
|
21
29
|
/** Installation port plus discovery of the orgs the agent App is installed on. */
|
|
22
30
|
export interface InstallationReposPort extends AppInstallationPort {
|
|
23
31
|
listInstalled(
|
|
24
32
|
appId: number,
|
|
25
33
|
identity?: AppIdentity,
|
|
26
|
-
): Promise<
|
|
34
|
+
): Promise<InstalledOrgsResult>;
|
|
27
35
|
}
|
|
28
36
|
|
|
37
|
+
export const NO_INSTALLATION_REASON =
|
|
38
|
+
"No installation of the agent GitHub App was found on any org the installer can reach (matched by client id or slug). Check the App installation and the agent GH_APP_CLIENT_ID / GH_APP_SLUG.";
|
|
39
|
+
|
|
29
40
|
export interface InstallationRepoView {
|
|
30
41
|
fullName: string;
|
|
31
42
|
/** Present only when the bound user's access to this repo is known. */
|
|
@@ -40,6 +51,7 @@ export interface InstallationOrgView {
|
|
|
40
51
|
export type InstallationListResult =
|
|
41
52
|
| { status: "agent_not_found" }
|
|
42
53
|
| { status: "no_app_id"; reason: string }
|
|
54
|
+
| { status: "skipped"; appId: number; reason: string }
|
|
43
55
|
| { status: "ok"; appId: number; orgs: InstallationOrgView[] };
|
|
44
56
|
|
|
45
57
|
export interface InstallationReposDeps {
|
|
@@ -107,6 +119,13 @@ export class InstallationReposService {
|
|
|
107
119
|
agent.appId,
|
|
108
120
|
identityOf(agent),
|
|
109
121
|
);
|
|
122
|
+
if (installed.status === "none") {
|
|
123
|
+
return {
|
|
124
|
+
status: "skipped",
|
|
125
|
+
appId: agent.appId,
|
|
126
|
+
reason: NO_INSTALLATION_REASON,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
110
129
|
const username = agent.githubUsername?.trim();
|
|
111
130
|
let access: UserRepoAccessResult | undefined;
|
|
112
131
|
if (username) {
|
|
@@ -120,7 +139,7 @@ export class InstallationReposService {
|
|
|
120
139
|
return {
|
|
121
140
|
status: "ok",
|
|
122
141
|
appId: agent.appId,
|
|
123
|
-
orgs: installed.map(({ org, repos }) => ({
|
|
142
|
+
orgs: installed.orgs.map(({ org, repos }) => ({
|
|
124
143
|
org,
|
|
125
144
|
repos: userPushHints(access, org, repos),
|
|
126
145
|
})),
|
|
@@ -154,7 +173,9 @@ export function createInstallationReposPort(
|
|
|
154
173
|
throw err;
|
|
155
174
|
}
|
|
156
175
|
}
|
|
157
|
-
return out
|
|
176
|
+
return out.length === 0
|
|
177
|
+
? { status: "none" }
|
|
178
|
+
: { status: "found", orgs: out };
|
|
158
179
|
},
|
|
159
180
|
};
|
|
160
181
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { describe, expect, it } from "bun:test";
|
|
8
8
|
import {
|
|
9
9
|
InstallationReposService,
|
|
10
|
+
NO_INSTALLATION_REASON,
|
|
10
11
|
type InstallationReposPort,
|
|
11
12
|
userPushHints,
|
|
12
13
|
} from "./installation-repos-service.ts";
|
|
@@ -103,6 +104,7 @@ function noHint(r: { userCanPush?: boolean }): boolean {
|
|
|
103
104
|
function build(
|
|
104
105
|
opts: {
|
|
105
106
|
agent?: { githubUsername: string | null; appId?: number } | null;
|
|
107
|
+
noInstallation?: boolean;
|
|
106
108
|
access?: () => Promise<
|
|
107
109
|
| { status: "unconfigured" }
|
|
108
110
|
| { status: "ok"; access: UserRepoAccessResult }
|
|
@@ -110,9 +112,13 @@ function build(
|
|
|
110
112
|
} = {},
|
|
111
113
|
) {
|
|
112
114
|
const installation: InstallationReposPort = {
|
|
113
|
-
listInstalled: async () =>
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
listInstalled: async () =>
|
|
116
|
+
opts.noInstallation
|
|
117
|
+
? { status: "none" }
|
|
118
|
+
: {
|
|
119
|
+
status: "found",
|
|
120
|
+
orgs: [{ org: "acme", repos: ["acme/push", "acme/unlisted"] }],
|
|
121
|
+
},
|
|
116
122
|
listRepos: async () => ({}),
|
|
117
123
|
addRepos: async () => {},
|
|
118
124
|
removeRepos: async () => {},
|
|
@@ -175,6 +181,15 @@ describe("InstallationReposService.list", () => {
|
|
|
175
181
|
}
|
|
176
182
|
});
|
|
177
183
|
|
|
184
|
+
it("is skipped with a reason when the App matches no installation", async () => {
|
|
185
|
+
const r = await build({ noInstallation: true }).svc.list("a1");
|
|
186
|
+
expect(r).toEqual({
|
|
187
|
+
status: "skipped",
|
|
188
|
+
appId: 42,
|
|
189
|
+
reason: NO_INSTALLATION_REASON,
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
178
193
|
it("reports unknown agent and a missing GH_APP_ID distinctly", async () => {
|
|
179
194
|
expect(await build({ agent: null }).svc.list("x")).toEqual({
|
|
180
195
|
status: "agent_not_found",
|
package/src/openapi-schemas.ts
CHANGED
|
@@ -1104,7 +1104,9 @@ export const PutBakedMarketplacesBodySchema = z
|
|
|
1104
1104
|
|
|
1105
1105
|
export const BakedMarketplacesResultSchema = z
|
|
1106
1106
|
.object({
|
|
1107
|
-
bakedMarketplaces: z
|
|
1107
|
+
bakedMarketplaces: z
|
|
1108
|
+
.array(z.string())
|
|
1109
|
+
.openapi({ example: ["example-marketplace"] }),
|
|
1108
1110
|
})
|
|
1109
1111
|
.openapi("BakedMarketplacesResult");
|
|
1110
1112
|
|
|
@@ -1475,6 +1477,11 @@ export const AgentConfigResponseSchema = z
|
|
|
1475
1477
|
description: "Reserved for the repo-access check (COS-44.1).",
|
|
1476
1478
|
example: false,
|
|
1477
1479
|
}),
|
|
1480
|
+
loopTranscriptUpload: z.boolean().optional().openapi({
|
|
1481
|
+
description:
|
|
1482
|
+
"True when SHIPWRIGHT_TRANSCRIPT_API_ENABLED is on and this agent is listed in SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS: coding-loop runs may upload a redacted transcript through the extension capability.",
|
|
1483
|
+
example: false,
|
|
1484
|
+
}),
|
|
1478
1485
|
})
|
|
1479
1486
|
.optional()
|
|
1480
1487
|
.openapi("AgentConfigFeatures"),
|
package/src/transcript-config.ts
CHANGED
|
@@ -12,8 +12,19 @@ type TranscriptEnv = Readonly<Record<string, string | undefined>>;
|
|
|
12
12
|
export interface TranscriptConfig {
|
|
13
13
|
/** True only when SHIPWRIGHT_TRANSCRIPT_API_ENABLED === "enabled". */
|
|
14
14
|
enabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Agent ids allowed to upload coding-loop run transcripts
|
|
17
|
+
* (SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS, comma-separated). Empty by default.
|
|
18
|
+
*/
|
|
19
|
+
loopAgentIds: readonly string[];
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export function parseTranscriptConfig(env: TranscriptEnv): TranscriptConfig {
|
|
18
|
-
return {
|
|
23
|
+
return {
|
|
24
|
+
enabled: env.SHIPWRIGHT_TRANSCRIPT_API_ENABLED === "enabled",
|
|
25
|
+
loopAgentIds: (env.SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS ?? "")
|
|
26
|
+
.split(",")
|
|
27
|
+
.map((id) => id.trim())
|
|
28
|
+
.filter(Boolean),
|
|
29
|
+
};
|
|
19
30
|
}
|
|
@@ -30,3 +30,21 @@ describe("parseTranscriptConfig", () => {
|
|
|
30
30
|
expect(parseTranscriptConfig({}).enabled).toBe(false);
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
|
+
|
|
34
|
+
describe("loop transcript allowlist", () => {
|
|
35
|
+
it("defaults to empty when unset or blank", () => {
|
|
36
|
+
expect(parseTranscriptConfig({}).loopAgentIds).toEqual([]);
|
|
37
|
+
expect(
|
|
38
|
+
parseTranscriptConfig({ SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS: " , " })
|
|
39
|
+
.loopAgentIds,
|
|
40
|
+
).toEqual([]);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("parses a trimmed comma-separated list", () => {
|
|
44
|
+
expect(
|
|
45
|
+
parseTranscriptConfig({
|
|
46
|
+
SHIPWRIGHT_LOOP_TRANSCRIPT_AGENT_IDS: "a, b ,,c",
|
|
47
|
+
}).loopAgentIds,
|
|
48
|
+
).toEqual(["a", "b", "c"]);
|
|
49
|
+
});
|
|
50
|
+
});
|