@app-vitals/agent-admin 1.106.2 → 1.107.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.
Files changed (42) hide show
  1. package/e2e/real/admin-access.real.e2e.ts +88 -0
  2. package/e2e/real/agents-real.real.e2e.ts +116 -0
  3. package/e2e/real/constants.ts +73 -0
  4. package/e2e/real/fixture.ts +120 -0
  5. package/e2e/real/harness.ts +191 -0
  6. package/e2e/real/member-access-self-serve.real.e2e.ts +114 -0
  7. package/e2e/real/member-agents.real.e2e.ts +267 -0
  8. package/e2e/real/member-chat.real.e2e.ts +153 -0
  9. package/e2e/real/owner-access.real.e2e.ts +237 -0
  10. package/e2e/real/seed.ts +105 -0
  11. package/e2e/real/session.ts +29 -0
  12. package/openapi.json +0 -280
  13. package/openapi.platform.json +0 -280
  14. package/package.json +2 -2
  15. package/playwright.config.ts +11 -0
  16. package/prisma/client/browser.ts +0 -10
  17. package/prisma/client/client.ts +0 -10
  18. package/prisma/client/internal/class.ts +4 -24
  19. package/prisma/client/internal/prismaNamespace.ts +1 -181
  20. package/prisma/client/internal/prismaNamespaceBrowser.ts +0 -30
  21. package/prisma/client/models.ts +0 -2
  22. package/prisma/migrations/20261129000000_drop_cron_run_transcripts/migration.sql +9 -0
  23. package/prisma/schema/schema.prisma +0 -34
  24. package/src/admin-boot.ts +0 -11
  25. package/src/admin-ui.ts +2 -1
  26. package/src/agents-api.ts +0 -13
  27. package/src/api.smoke.test.ts +6 -73
  28. package/src/api.ts +0 -17
  29. package/src/cron-run-now.integration.test.ts +163 -0
  30. package/src/cron-run-transcripts-removed.smoke.test.ts +82 -0
  31. package/src/drop-cron-run-transcripts-migration.integration.test.ts +114 -0
  32. package/src/openapi-schemas.ts +0 -55
  33. package/src/repo-access-config.ts +1 -1
  34. package/src/secrets-equal.ts +8 -0
  35. package/src/secrets-equal.unit.test.ts +15 -0
  36. package/prisma/client/models/AgentCronRunTranscript.ts +0 -1339
  37. package/prisma/client/models/AgentTranscriptRead.ts +0 -1177
  38. package/src/cron-run-transcripts.integration.test.ts +0 -220
  39. package/src/cron-run-transcripts.smoke.test.ts +0 -286
  40. package/src/cron-run-transcripts.ts +0 -314
  41. package/src/transcript-config.ts +0 -30
  42. package/src/transcript-config.unit.test.ts +0 -50
@@ -0,0 +1,105 @@
1
+ /**
2
+ * admin/e2e/real/seed.ts
3
+ *
4
+ * Seeds the admin database for the real-service e2e layer: two accounts, a
5
+ * platform admin (allowlist only, no row), an owner and a member in account
6
+ * one, an owner in account two, and three agents with different repos. The
7
+ * member is on `alpha` only; `beta` (same account) and `gamma` (other account)
8
+ * are agents the member is not on.
9
+ *
10
+ * Standalone: `ADMIN_E2E_SEED_URL=postgres://... bun admin/e2e/real/seed.ts`.
11
+ */
12
+
13
+ import { createAdminPrismaClient } from "../../src/prisma-client.ts";
14
+ import {
15
+ ACCOUNTS,
16
+ AGENTS,
17
+ CHAT_ADMIN_TOKEN,
18
+ EMAILS,
19
+ THREADS,
20
+ } from "./constants.ts";
21
+
22
+ const MEMBER1_ID = "member-e2e-member1";
23
+
24
+ export async function seedAdminDb(databaseUrl: string): Promise<void> {
25
+ const prisma = createAdminPrismaClient(databaseUrl);
26
+ try {
27
+ for (const account of Object.values(ACCOUNTS)) {
28
+ await prisma.account.create({
29
+ data: { id: account.id, name: account.name, maxAgents: 5 },
30
+ });
31
+ }
32
+ await prisma.accountMember.createMany({
33
+ data: [
34
+ { accountId: ACCOUNTS.one.id, email: EMAILS.owner1, role: "owner" },
35
+ {
36
+ id: MEMBER1_ID,
37
+ accountId: ACCOUNTS.one.id,
38
+ email: EMAILS.member1,
39
+ role: "member",
40
+ },
41
+ { accountId: ACCOUNTS.two.id, email: EMAILS.owner2, role: "owner" },
42
+ ],
43
+ });
44
+ for (const agent of Object.values(AGENTS)) {
45
+ await prisma.agent.create({
46
+ data: {
47
+ id: agent.id,
48
+ name: agent.name,
49
+ repos: [...agent.repos],
50
+ accountId: agent.accountId,
51
+ },
52
+ });
53
+ }
54
+ await prisma.agentMember.create({
55
+ // AgentMember reads key on memberId (AccountMember.id), not email.
56
+ data: {
57
+ agentId: AGENTS.alpha.id,
58
+ email: EMAILS.member1,
59
+ memberId: MEMBER1_ID,
60
+ },
61
+ });
62
+ } finally {
63
+ await prisma.$disconnect();
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Seeds one chat thread (with one message) per agent through the real chat
69
+ * service HTTP API, using the seeded admin token. Additive to seedAdminDb.
70
+ */
71
+ export async function seedChatService(chatUrl: string): Promise<void> {
72
+ const headers = {
73
+ Authorization: `Bearer ${CHAT_ADMIN_TOKEN}`,
74
+ "Content-Type": "application/json",
75
+ };
76
+ for (const t of Object.values(THREADS)) {
77
+ const created = await fetch(`${chatUrl}/threads`, {
78
+ method: "POST",
79
+ headers,
80
+ body: JSON.stringify({ agentId: AGENTS[t.agent].id, title: t.title }),
81
+ });
82
+ if (!created.ok) {
83
+ throw new Error(`seed thread ${t.title} failed: ${created.status}`);
84
+ }
85
+ const thread = (await created.json()) as { id: string };
86
+ const msg = await fetch(`${chatUrl}/threads/${thread.id}/messages`, {
87
+ method: "POST",
88
+ headers,
89
+ body: JSON.stringify({ role: "user", body: t.message }),
90
+ });
91
+ if (!msg.ok) {
92
+ throw new Error(`seed message for ${t.title} failed: ${msg.status}`);
93
+ }
94
+ }
95
+ }
96
+
97
+ if (import.meta.main) {
98
+ const url = process.env.ADMIN_E2E_SEED_URL;
99
+ if (!url) {
100
+ console.error("ADMIN_E2E_SEED_URL is required");
101
+ process.exit(1);
102
+ }
103
+ await seedAdminDb(url);
104
+ console.log("[admin-e2e] seeded");
105
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * admin/e2e/real/session.ts
3
+ *
4
+ * Mints an `admin_session` cookie value with the test session secret, in the
5
+ * same shape the admin app issues after a real sign-in (HS256 JWT). No sign-in
6
+ * route is involved; `isAdmin` must agree with the harness allowlist because
7
+ * the admin app re-derives it from the allowlist when it renews a session.
8
+ */
9
+
10
+ import { sign } from "hono/jwt";
11
+ import { EMAILS, SESSION_SECRET } from "./constants.ts";
12
+
13
+ export async function mintSessionCookie(
14
+ email: string,
15
+ secret: string = SESSION_SECRET,
16
+ ): Promise<string> {
17
+ const now = Math.floor(Date.now() / 1000);
18
+ return sign(
19
+ {
20
+ userId: `e2e-${email}`,
21
+ email,
22
+ isAdmin: email === EMAILS.admin,
23
+ iat: now,
24
+ exp: now + 3600,
25
+ },
26
+ secret,
27
+ "HS256",
28
+ );
29
+ }
package/openapi.json CHANGED
@@ -3370,135 +3370,16 @@
3370
3370
  "repliedAt"
3371
3371
  ]
3372
3372
  },
3373
- "CronRunTranscriptUploadResult": {
3374
- "type": "object",
3375
- "properties": {
3376
- "runId": {
3377
- "type": "string",
3378
- "example": "clx1111111111"
3379
- },
3380
- "bytes": {
3381
- "type": "integer",
3382
- "example": 2048
3383
- },
3384
- "truncated": {
3385
- "type": "boolean",
3386
- "example": false
3387
- },
3388
- "redactions": {
3389
- "type": "integer",
3390
- "example": 0
3391
- }
3392
- },
3393
- "required": [
3394
- "runId",
3395
- "bytes",
3396
- "truncated",
3397
- "redactions"
3398
- ]
3399
- },
3400
- "UploadCronRunTranscriptBody": {
3401
- "type": "object",
3402
- "properties": {
3403
- "sessionId": {
3404
- "type": "string",
3405
- "minLength": 1,
3406
- "description": "Claude session id the transcript was read from.",
3407
- "example": "7c1c8d1e-0000-4000-8000-000000000000"
3408
- },
3409
- "body": {
3410
- "type": "string",
3411
- "description": "The already-redacted transcript (JSONL text). Over 1 MiB (UTF-8 bytes) is a 413. Never logged."
3412
- },
3413
- "truncated": {
3414
- "type": "boolean",
3415
- "description": "True when the runtime dropped earlier lines to fit.",
3416
- "example": false
3417
- },
3418
- "redactions": {
3419
- "type": "integer",
3420
- "minimum": 0,
3421
- "description": "How many secrets the runtime redacted.",
3422
- "example": 0
3423
- }
3424
- },
3425
- "required": [
3426
- "body",
3427
- "truncated",
3428
- "redactions"
3429
- ]
3430
- },
3431
- "CronRunTranscript": {
3432
- "type": "object",
3433
- "properties": {
3434
- "runId": {
3435
- "type": "string",
3436
- "example": "clx1111111111"
3437
- },
3438
- "cronId": {
3439
- "type": "string",
3440
- "example": "clx0987654321"
3441
- },
3442
- "sessionId": {
3443
- "type": [
3444
- "string",
3445
- "null"
3446
- ],
3447
- "example": null
3448
- },
3449
- "bytes": {
3450
- "type": "integer",
3451
- "example": 2048
3452
- },
3453
- "truncated": {
3454
- "type": "boolean",
3455
- "example": false
3456
- },
3457
- "redactions": {
3458
- "type": "integer",
3459
- "example": 0
3460
- },
3461
- "createdAt": {
3462
- "type": "string",
3463
- "example": "2026-10-26T12:00:00.000Z"
3464
- },
3465
- "body": {
3466
- "type": "string",
3467
- "description": "Redacted JSONL transcript."
3468
- }
3469
- },
3470
- "required": [
3471
- "runId",
3472
- "cronId",
3473
- "sessionId",
3474
- "bytes",
3475
- "truncated",
3476
- "redactions",
3477
- "createdAt",
3478
- "body"
3479
- ]
3480
- },
3481
3373
  "AgentConfigFeatures": {
3482
3374
  "type": "object",
3483
3375
  "properties": {
3484
- "transcriptUpload": {
3485
- "type": "boolean",
3486
- "description": "True when SHIPWRIGHT_TRANSCRIPT_API_ENABLED is on: the runtime uploads a redacted transcript after each cron run.",
3487
- "example": false
3488
- },
3489
3376
  "repoAccessCheck": {
3490
3377
  "type": "boolean",
3491
3378
  "description": "Reserved for the repo-access check (COS-44.1).",
3492
3379
  "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
3498
3380
  }
3499
3381
  },
3500
3382
  "required": [
3501
- "transcriptUpload",
3502
3383
  "repoAccessCheck"
3503
3384
  ]
3504
3385
  },
@@ -7046,167 +6927,6 @@
7046
6927
  }
7047
6928
  }
7048
6929
  },
7049
- "/agents/{id}/crons/{cronId}/runs/{runId}/transcript": {
7050
- "put": {
7051
- "summary": "Upload a cron run transcript",
7052
- "description": "Stores (upserts) the runtime's already-redacted session transcript for a cron run, then keeps only the agent's newest 200 transcripts. Callers: the agent's own key, or `*`. `body` over 1 MiB (UTF-8 bytes) is a 413. 404 unless SHIPWRIGHT_TRANSCRIPT_API_ENABLED is `enabled`, or when the run is not owned by the cron/agent.",
7053
- "parameters": [
7054
- {
7055
- "schema": {
7056
- "type": "string",
7057
- "example": "clx1234567890"
7058
- },
7059
- "required": true,
7060
- "name": "id",
7061
- "in": "path"
7062
- },
7063
- {
7064
- "schema": {
7065
- "type": "string",
7066
- "example": "clx0987654321"
7067
- },
7068
- "required": true,
7069
- "name": "cronId",
7070
- "in": "path"
7071
- },
7072
- {
7073
- "schema": {
7074
- "type": "string",
7075
- "example": "clx1111111111"
7076
- },
7077
- "required": true,
7078
- "name": "runId",
7079
- "in": "path"
7080
- }
7081
- ],
7082
- "requestBody": {
7083
- "content": {
7084
- "application/json": {
7085
- "schema": {
7086
- "$ref": "#/components/schemas/UploadCronRunTranscriptBody"
7087
- }
7088
- }
7089
- }
7090
- },
7091
- "responses": {
7092
- "200": {
7093
- "description": "Transcript stored",
7094
- "content": {
7095
- "application/json": {
7096
- "schema": {
7097
- "$ref": "#/components/schemas/CronRunTranscriptUploadResult"
7098
- }
7099
- }
7100
- }
7101
- },
7102
- "400": {
7103
- "description": "Bad request",
7104
- "content": {
7105
- "application/json": {
7106
- "schema": {
7107
- "$ref": "#/components/schemas/Error"
7108
- }
7109
- }
7110
- }
7111
- },
7112
- "403": {
7113
- "description": "Caller not allowed",
7114
- "content": {
7115
- "application/json": {
7116
- "schema": {
7117
- "$ref": "#/components/schemas/Error"
7118
- }
7119
- }
7120
- }
7121
- },
7122
- "404": {
7123
- "description": "Run not found, or transcript API disabled",
7124
- "content": {
7125
- "application/json": {
7126
- "schema": {
7127
- "$ref": "#/components/schemas/Error"
7128
- }
7129
- }
7130
- }
7131
- },
7132
- "413": {
7133
- "description": "Transcript body over 1 MiB",
7134
- "content": {
7135
- "application/json": {
7136
- "schema": {
7137
- "$ref": "#/components/schemas/Error"
7138
- }
7139
- }
7140
- }
7141
- }
7142
- }
7143
- },
7144
- "get": {
7145
- "summary": "Get a cron run transcript",
7146
- "description": "Returns the stored redacted transcript. `*`, `platform.read` and `platform.ops` callers only: an agent key is 403 even for its own runs. Every read writes an AgentTranscriptRead audit row before the response. 404 when SHIPWRIGHT_TRANSCRIPT_API_ENABLED is not `enabled` or no transcript exists.",
7147
- "parameters": [
7148
- {
7149
- "schema": {
7150
- "type": "string",
7151
- "example": "clx1234567890"
7152
- },
7153
- "required": true,
7154
- "name": "id",
7155
- "in": "path"
7156
- },
7157
- {
7158
- "schema": {
7159
- "type": "string",
7160
- "example": "clx0987654321"
7161
- },
7162
- "required": true,
7163
- "name": "cronId",
7164
- "in": "path"
7165
- },
7166
- {
7167
- "schema": {
7168
- "type": "string",
7169
- "example": "clx1111111111"
7170
- },
7171
- "required": true,
7172
- "name": "runId",
7173
- "in": "path"
7174
- }
7175
- ],
7176
- "responses": {
7177
- "200": {
7178
- "description": "The transcript",
7179
- "content": {
7180
- "application/json": {
7181
- "schema": {
7182
- "$ref": "#/components/schemas/CronRunTranscript"
7183
- }
7184
- }
7185
- }
7186
- },
7187
- "403": {
7188
- "description": "Forbidden",
7189
- "content": {
7190
- "application/json": {
7191
- "schema": {
7192
- "$ref": "#/components/schemas/Error"
7193
- }
7194
- }
7195
- }
7196
- },
7197
- "404": {
7198
- "description": "No transcript, or transcript API disabled",
7199
- "content": {
7200
- "application/json": {
7201
- "schema": {
7202
- "$ref": "#/components/schemas/Error"
7203
- }
7204
- }
7205
- }
7206
- }
7207
- }
7208
- }
7209
- },
7210
6930
  "/agents/{id}/marketplaces": {
7211
6931
  "get": {
7212
6932
  "summary": "List marketplaces",