@app-vitals/agent-admin 1.107.1 → 1.107.3
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/e2e/real/seed.ts +0 -1
- package/package.json +2 -2
- package/prisma/client/internal/class.ts +4 -4
- package/prisma/client/internal/prismaNamespace.ts +1 -5
- package/prisma/client/internal/prismaNamespaceBrowser.ts +1 -5
- package/prisma/client/models/AgentMember.ts +26 -61
- package/prisma/client/models/ChatThreadWatch.ts +19 -47
- package/prisma/client/models/PushSubscription.ts +15 -43
- package/prisma/client/models/UserNotificationPrefs.ts +38 -66
- package/prisma/migrations/20261130000000_drop_email_key_columns/migration.sql +49 -0
- package/prisma/schema/schema.prisma +11 -15
- package/src/account-member-removal.integration.test.ts +31 -44
- package/src/account-members.ts +4 -6
- package/src/account-onboarding.ts +2 -5
- package/src/account-onboarding.unit.test.ts +71 -0
- package/src/accounts-api.smoke.test.ts +0 -11
- package/src/accounts.ts +1 -3
- package/src/admin-dev-login.smoke.test.ts +1 -1
- package/src/admin-local-agent.smoke.test.ts +3 -3
- package/src/admin-ui-accounts.smoke.test.ts +6 -14
- package/src/admin-ui-agent-members.smoke.test.ts +29 -1
- package/src/admin-ui.fixtures.ts +1 -1
- package/src/admin-ui.smoke.test.ts +18 -18
- package/src/admin-ui.ts +20 -12
- package/src/agent-cron-run-stats.smoke.test.ts +1 -1
- package/src/agent-deletion.integration.test.ts +1 -1
- package/src/agent-members.integration.test.ts +15 -11
- package/src/agent-members.ts +28 -18
- package/src/agents-api.integration.test.ts +2 -2
- package/src/agents-api.smoke.test.ts +5 -5
- package/src/agents.integration.test.ts +1 -2
- package/src/api.smoke.test.ts +1 -1
- package/src/chat-credential-config.unit.test.ts +30 -0
- package/src/chat.smoke.test.ts +68 -14
- package/src/drop-email-key-columns-migration.integration.test.ts +141 -0
- package/src/ensure-account-member.integration.test.ts +17 -232
- package/src/ensure-account-member.ts +0 -5
- package/src/github-enterprise-client.unit.test.ts +62 -2
- package/src/member-rows.ts +24 -0
- package/src/member-rows.unit.test.ts +48 -0
- package/src/principals-api.integration.test.ts +3 -2
- package/src/push-service.integration.test.ts +8 -13
- package/src/push-service.ts +28 -39
- package/src/push-service.unit.test.ts +8 -8
- package/src/reconcile-open-work.integration.test.ts +237 -0
- package/src/slack-provisioning.integration.test.ts +1 -1
- package/src/{member-id-test-support.ts → test-support/member-id-test-support.ts} +2 -2
- package/src/user-notification-prefs.integration.test.ts +6 -17
- package/src/user-notification-prefs.ts +12 -18
- package/scripts/backfill-member-id.ts +0 -50
- package/src/member-id-backfill.integration.test.ts +0 -167
- package/src/member-id-backfill.ts +0 -253
- package/src/member-id-backfill.unit.test.ts +0 -12
- package/src/member-id-stamp.ts +0 -68
|
@@ -1302,7 +1302,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1302
1302
|
id: "m1",
|
|
1303
1303
|
agentId: AGENT_ID,
|
|
1304
1304
|
email,
|
|
1305
|
-
memberId:
|
|
1305
|
+
memberId: "member-1",
|
|
1306
1306
|
createdAt: new Date(),
|
|
1307
1307
|
},
|
|
1308
1308
|
]
|
|
@@ -1313,7 +1313,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1313
1313
|
id: "m1",
|
|
1314
1314
|
agentId: AGENT_ID,
|
|
1315
1315
|
email: MEMBER_EMAIL,
|
|
1316
|
-
memberId:
|
|
1316
|
+
memberId: "member-1",
|
|
1317
1317
|
createdAt: new Date(),
|
|
1318
1318
|
}),
|
|
1319
1319
|
remove: async () => {},
|
|
@@ -2888,7 +2888,7 @@ describe("admin UI — member access control", () => {
|
|
|
2888
2888
|
id: "m1",
|
|
2889
2889
|
agentId: AGENT_ID,
|
|
2890
2890
|
email,
|
|
2891
|
-
memberId:
|
|
2891
|
+
memberId: "member-1",
|
|
2892
2892
|
createdAt: new Date(),
|
|
2893
2893
|
},
|
|
2894
2894
|
]
|
|
@@ -2899,7 +2899,7 @@ describe("admin UI — member access control", () => {
|
|
|
2899
2899
|
id: "m1",
|
|
2900
2900
|
agentId: AGENT_ID,
|
|
2901
2901
|
email: MEMBER_EMAIL,
|
|
2902
|
-
memberId:
|
|
2902
|
+
memberId: "member-1",
|
|
2903
2903
|
createdAt: new Date(),
|
|
2904
2904
|
}),
|
|
2905
2905
|
remove: async () => {},
|
|
@@ -3042,7 +3042,7 @@ describe("admin UI — member access control", () => {
|
|
|
3042
3042
|
id: "m1",
|
|
3043
3043
|
agentId: AGENT_ID,
|
|
3044
3044
|
email: MEMBER_EMAIL,
|
|
3045
|
-
memberId:
|
|
3045
|
+
memberId: "member-1",
|
|
3046
3046
|
createdAt: new Date(),
|
|
3047
3047
|
},
|
|
3048
3048
|
]
|
|
@@ -3052,7 +3052,7 @@ describe("admin UI — member access control", () => {
|
|
|
3052
3052
|
id: "m1",
|
|
3053
3053
|
agentId: AGENT_ID,
|
|
3054
3054
|
email: MEMBER_EMAIL,
|
|
3055
|
-
memberId:
|
|
3055
|
+
memberId: "member-1",
|
|
3056
3056
|
createdAt: new Date(),
|
|
3057
3057
|
}),
|
|
3058
3058
|
remove: async () => {},
|
|
@@ -3199,7 +3199,7 @@ describe("admin UI — member access control", () => {
|
|
|
3199
3199
|
id: "m1",
|
|
3200
3200
|
agentId: AGENT_ID,
|
|
3201
3201
|
email: MEMBER_EMAIL,
|
|
3202
|
-
memberId:
|
|
3202
|
+
memberId: "member-1",
|
|
3203
3203
|
createdAt: new Date(),
|
|
3204
3204
|
},
|
|
3205
3205
|
]
|
|
@@ -3209,7 +3209,7 @@ describe("admin UI — member access control", () => {
|
|
|
3209
3209
|
id: "m1",
|
|
3210
3210
|
agentId: AGENT_ID,
|
|
3211
3211
|
email: MEMBER_EMAIL,
|
|
3212
|
-
memberId:
|
|
3212
|
+
memberId: "member-1",
|
|
3213
3213
|
createdAt: new Date(),
|
|
3214
3214
|
}),
|
|
3215
3215
|
remove: async () => {},
|
|
@@ -3687,7 +3687,7 @@ describe("admin UI — member management routes", () => {
|
|
|
3687
3687
|
id: "m-new",
|
|
3688
3688
|
agentId,
|
|
3689
3689
|
email,
|
|
3690
|
-
memberId:
|
|
3690
|
+
memberId: "member-1",
|
|
3691
3691
|
createdAt: new Date(),
|
|
3692
3692
|
};
|
|
3693
3693
|
},
|
|
@@ -3782,7 +3782,7 @@ describe("admin UI — member management routes", () => {
|
|
|
3782
3782
|
id: "m1",
|
|
3783
3783
|
agentId: AGENT_ID,
|
|
3784
3784
|
email: "member@example.com",
|
|
3785
|
-
memberId:
|
|
3785
|
+
memberId: "member-1",
|
|
3786
3786
|
createdAt: new Date(),
|
|
3787
3787
|
}),
|
|
3788
3788
|
remove: async (_agentId: string, memberId: string) => {
|
|
@@ -3848,7 +3848,7 @@ describe("admin UI — marketplaces (PMK-1.5)", () => {
|
|
|
3848
3848
|
id: "m1",
|
|
3849
3849
|
agentId: AGENT_ID,
|
|
3850
3850
|
email,
|
|
3851
|
-
memberId:
|
|
3851
|
+
memberId: "member-1",
|
|
3852
3852
|
createdAt: new Date(),
|
|
3853
3853
|
},
|
|
3854
3854
|
]
|
|
@@ -3858,7 +3858,7 @@ describe("admin UI — marketplaces (PMK-1.5)", () => {
|
|
|
3858
3858
|
id: "m1",
|
|
3859
3859
|
agentId: AGENT_ID,
|
|
3860
3860
|
email: MEMBER,
|
|
3861
|
-
memberId:
|
|
3861
|
+
memberId: "member-1",
|
|
3862
3862
|
createdAt: new Date(),
|
|
3863
3863
|
}),
|
|
3864
3864
|
remove: async () => {},
|
|
@@ -4087,7 +4087,7 @@ describe("admin UI — plugin add/remove (PUI-1.2)", () => {
|
|
|
4087
4087
|
id: "m1",
|
|
4088
4088
|
agentId: AGENT_ID,
|
|
4089
4089
|
email,
|
|
4090
|
-
memberId:
|
|
4090
|
+
memberId: "member-1",
|
|
4091
4091
|
createdAt: new Date(),
|
|
4092
4092
|
},
|
|
4093
4093
|
]
|
|
@@ -7025,7 +7025,7 @@ describe("admin UI — Slack access settings route (restrictSlackToMembers)", ()
|
|
|
7025
7025
|
id: "m1",
|
|
7026
7026
|
agentId: AGENT_ID,
|
|
7027
7027
|
email: "member@example.com",
|
|
7028
|
-
memberId:
|
|
7028
|
+
memberId: "member-1",
|
|
7029
7029
|
createdAt: new Date("2024-01-01"),
|
|
7030
7030
|
},
|
|
7031
7031
|
],
|
|
@@ -7288,7 +7288,7 @@ describe("admin UI — Okta-authenticated access control", () => {
|
|
|
7288
7288
|
id: "m1",
|
|
7289
7289
|
agentId: AGENT_ID,
|
|
7290
7290
|
email: OKTA_MEMBER_EMAIL,
|
|
7291
|
-
memberId:
|
|
7291
|
+
memberId: "member-1",
|
|
7292
7292
|
createdAt: new Date(),
|
|
7293
7293
|
},
|
|
7294
7294
|
]
|
|
@@ -7299,7 +7299,7 @@ describe("admin UI — Okta-authenticated access control", () => {
|
|
|
7299
7299
|
id: "m1",
|
|
7300
7300
|
agentId: AGENT_ID,
|
|
7301
7301
|
email: OKTA_MEMBER_EMAIL,
|
|
7302
|
-
memberId:
|
|
7302
|
+
memberId: "member-1",
|
|
7303
7303
|
createdAt: new Date(),
|
|
7304
7304
|
}),
|
|
7305
7305
|
remove: async () => {},
|
|
@@ -7409,7 +7409,7 @@ describe("admin UI — Okta-authenticated access control", () => {
|
|
|
7409
7409
|
id: "m1",
|
|
7410
7410
|
agentId: AGENT_ID,
|
|
7411
7411
|
email,
|
|
7412
|
-
memberId:
|
|
7412
|
+
memberId: "member-1",
|
|
7413
7413
|
createdAt: new Date(),
|
|
7414
7414
|
},
|
|
7415
7415
|
]
|
|
@@ -7420,7 +7420,7 @@ describe("admin UI — Okta-authenticated access control", () => {
|
|
|
7420
7420
|
id: "m1",
|
|
7421
7421
|
agentId: AGENT_ID,
|
|
7422
7422
|
email: OKTA_MEMBER_EMAIL,
|
|
7423
|
-
memberId:
|
|
7423
|
+
memberId: "member-1",
|
|
7424
7424
|
createdAt: new Date(),
|
|
7425
7425
|
}),
|
|
7426
7426
|
remove: async () => {},
|
package/src/admin-ui.ts
CHANGED
|
@@ -118,7 +118,10 @@ import { deleteAgentFully } from "./agent-deletion.ts";
|
|
|
118
118
|
import type { ManualStep } from "./agent-deletion-checklist.ts";
|
|
119
119
|
import type { AgentEnvService } from "./agent-envs.ts";
|
|
120
120
|
import type { AgentMarketplaceService } from "./agent-marketplaces.ts";
|
|
121
|
-
import
|
|
121
|
+
import {
|
|
122
|
+
type AgentMemberService,
|
|
123
|
+
NoAccountMemberError,
|
|
124
|
+
} from "./agent-members.ts";
|
|
122
125
|
import type { AgentPluginService } from "./agent-plugins.ts";
|
|
123
126
|
import type { AgentProvisioner } from "./agent-provisioner.ts";
|
|
124
127
|
import type { AgentTemplateReconcileService } from "./agent-template-reconcile.ts";
|
|
@@ -328,16 +331,13 @@ interface PrismaLike {
|
|
|
328
331
|
};
|
|
329
332
|
agentMember: {
|
|
330
333
|
findMany(args: {
|
|
331
|
-
where: {
|
|
332
|
-
}): Promise<
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}): Promise<{ id: string; agentId: string
|
|
338
|
-
create(args: {
|
|
339
|
-
data: { agentId: string; email: string };
|
|
340
|
-
}): Promise<{ id: string; agentId: string; email: string }>;
|
|
334
|
+
where: { memberId?: string; agentId?: string };
|
|
335
|
+
}): Promise<Array<{ id: string; agentId: string; createdAt: Date }>>;
|
|
336
|
+
findUnique(args: { where: unknown }): Promise<{
|
|
337
|
+
id: string;
|
|
338
|
+
agentId: string;
|
|
339
|
+
} | null>;
|
|
340
|
+
create(args: { data: unknown }): Promise<{ id: string; agentId: string }>;
|
|
341
341
|
deleteMany(args: { where: { id: string; agentId: string } }): Promise<{
|
|
342
342
|
count: number;
|
|
343
343
|
}>;
|
|
@@ -4539,7 +4539,15 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
4539
4539
|
}
|
|
4540
4540
|
try {
|
|
4541
4541
|
await agentMemberService.add(agentId, email);
|
|
4542
|
-
} catch {
|
|
4542
|
+
} catch (err) {
|
|
4543
|
+
if (err instanceof NoAccountMemberError) {
|
|
4544
|
+
return c.redirect(
|
|
4545
|
+
agentSectionPath(agentId, "access", {
|
|
4546
|
+
error: `${email} is not an account member, so it cannot be added to this agent.`,
|
|
4547
|
+
}),
|
|
4548
|
+
302,
|
|
4549
|
+
);
|
|
4550
|
+
}
|
|
4543
4551
|
// unique constraint violation — already a member, ignore
|
|
4544
4552
|
}
|
|
4545
4553
|
}
|
|
@@ -78,7 +78,7 @@ async function seedFullFixture(
|
|
|
78
78
|
data: { agentId, name: "@shipwright/plugin" },
|
|
79
79
|
});
|
|
80
80
|
await prisma.agentMember.create({
|
|
81
|
-
data: { agentId,
|
|
81
|
+
data: { agentId, memberId: "member-1" },
|
|
82
82
|
});
|
|
83
83
|
await prisma.agentChatTokenUsageDailyByModel.create({
|
|
84
84
|
data: {
|
|
@@ -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 { AgentMemberService } from "./agent-members.ts";
|
|
12
|
-
import { resetMemberIdFixture } from "./member-id-test-support.ts";
|
|
11
|
+
import { AgentMemberService, NoAccountMemberError } from "./agent-members.ts";
|
|
12
|
+
import { resetMemberIdFixture } from "./test-support/member-id-test-support.ts";
|
|
13
13
|
import { createAdminPrismaClient } from "./prisma-client.ts";
|
|
14
14
|
|
|
15
15
|
const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
|
|
@@ -52,9 +52,11 @@ describeOrSkip("AgentMemberService by memberId (integration)", () => {
|
|
|
52
52
|
expect(rows.map((r) => r.memberId)).toEqual([bobId]);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
it("add for an email with no AccountMember
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
it("add for an email with no AccountMember throws and writes nothing", async () => {
|
|
56
|
+
await expect(service.add(agentId, "ghost@nowhere.com")).rejects.toThrow(
|
|
57
|
+
NoAccountMemberError,
|
|
58
|
+
);
|
|
59
|
+
expect(await prisma.agentMember.count()).toBe(0);
|
|
58
60
|
});
|
|
59
61
|
|
|
60
62
|
it("listByEmail and listByMemberId return the member's agents", async () => {
|
|
@@ -71,10 +73,9 @@ describeOrSkip("AgentMemberService by memberId (integration)", () => {
|
|
|
71
73
|
expect(await service.exists(agentId, "ghost@nowhere.com")).toBe(false);
|
|
72
74
|
});
|
|
73
75
|
|
|
74
|
-
it("
|
|
75
|
-
// Legacy row: email only, never backfilled.
|
|
76
|
+
it("rows whose member no longer resolves are skipped on every read", async () => {
|
|
76
77
|
await prisma.agentMember.create({
|
|
77
|
-
data: { agentId,
|
|
78
|
+
data: { agentId, memberId: "gone-member" },
|
|
78
79
|
});
|
|
79
80
|
expect(await service.listByEmail("alice@acme.com")).toEqual([]);
|
|
80
81
|
expect(await service.exists(agentId, "alice@acme.com")).toBe(false);
|
|
@@ -83,10 +84,13 @@ describeOrSkip("AgentMemberService by memberId (integration)", () => {
|
|
|
83
84
|
|
|
84
85
|
it("listByAgentId returns rows with the email resolved through the lookup", async () => {
|
|
85
86
|
await service.add(agentId, "alice@acme.com");
|
|
86
|
-
//
|
|
87
|
-
await prisma.
|
|
87
|
+
// The member's email changed after the row was written.
|
|
88
|
+
await prisma.accountMember.update({
|
|
89
|
+
where: { id: aliceId },
|
|
90
|
+
data: { email: "alice2@acme.com" },
|
|
91
|
+
});
|
|
88
92
|
const rows = await service.listByAgentId(agentId);
|
|
89
|
-
expect(rows.map((r) => r.email)).toEqual(["
|
|
93
|
+
expect(rows.map((r) => r.email)).toEqual(["alice2@acme.com"]);
|
|
90
94
|
});
|
|
91
95
|
|
|
92
96
|
it("remove deletes by row id scoped to the agent", async () => {
|
package/src/agent-members.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* agent/src/agent-members.ts
|
|
3
3
|
* AgentMemberService — authorized human members per agent (access control).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Reads and writes key on AgentMember.memberId (AccountMember.id); the
|
|
6
|
+
* [agentId, memberId] unique constraint guards duplicate adds. Callers still
|
|
7
|
+
* pass emails; they are resolved to a member id through the AccountMember
|
|
8
|
+
* lookup, and emails handed back are resolved the same way (ACM-5.1 dropped the
|
|
9
|
+
* email column).
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type { AgentMember, PrismaClient } from "../prisma/client/client.ts";
|
|
@@ -16,6 +16,17 @@ import type { PrismaTransactionClient } from "./prisma-tx.ts";
|
|
|
16
16
|
|
|
17
17
|
export type { AgentMember };
|
|
18
18
|
|
|
19
|
+
/** An AgentMember row plus the member's current email, resolved via the lookup. */
|
|
20
|
+
export type AgentMemberWithEmail = AgentMember & { email: string };
|
|
21
|
+
|
|
22
|
+
/** Thrown when an agent membership is requested for an email with no AccountMember. */
|
|
23
|
+
export class NoAccountMemberError extends Error {
|
|
24
|
+
constructor(readonly email: string) {
|
|
25
|
+
super(`No account member exists for ${email}`);
|
|
26
|
+
this.name = "NoAccountMemberError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
export class AgentMemberService {
|
|
20
31
|
private readonly lookup: PrincipalLookupService;
|
|
21
32
|
|
|
@@ -28,20 +39,18 @@ export class AgentMemberService {
|
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
/**
|
|
31
|
-
* List all memberships for a given agent. Rows
|
|
32
|
-
*
|
|
33
|
-
*
|
|
42
|
+
* List all memberships for a given agent. Rows whose memberId no longer
|
|
43
|
+
* resolves are skipped; `email` on each returned row is the member's current
|
|
44
|
+
* email from the lookup.
|
|
34
45
|
*/
|
|
35
|
-
async listByAgentId(agentId: string): Promise<
|
|
36
|
-
const rows = await this.prisma.agentMember.findMany({
|
|
37
|
-
where: { agentId, memberId: { not: null } },
|
|
38
|
-
});
|
|
46
|
+
async listByAgentId(agentId: string): Promise<AgentMemberWithEmail[]> {
|
|
47
|
+
const rows = await this.prisma.agentMember.findMany({ where: { agentId } });
|
|
39
48
|
const { principals } = await this.lookup.resolveMany(
|
|
40
|
-
rows.
|
|
49
|
+
rows.map((r) => r.memberId),
|
|
41
50
|
);
|
|
42
51
|
const emails = new Map(principals.map((p) => [p.id, p.email]));
|
|
43
52
|
return rows.flatMap((r) => {
|
|
44
|
-
const email =
|
|
53
|
+
const email = emails.get(r.memberId);
|
|
45
54
|
return email ? [{ ...r, email }] : [];
|
|
46
55
|
});
|
|
47
56
|
}
|
|
@@ -74,9 +83,9 @@ export class AgentMemberService {
|
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
/**
|
|
77
|
-
* Create a membership row for the given agentId and email,
|
|
78
|
-
* email's AccountMember id
|
|
79
|
-
* row
|
|
86
|
+
* Create a membership row for the given agentId and email, keyed on the
|
|
87
|
+
* email's AccountMember id. Throws `NoAccountMemberError` when the email has
|
|
88
|
+
* no AccountMember (a row cannot be written without a member id).
|
|
80
89
|
* Throws (unique-constraint violation) if the membership already exists —
|
|
81
90
|
* callers are expected to catch and handle "already a member" as a no-op.
|
|
82
91
|
*
|
|
@@ -94,8 +103,9 @@ export class AgentMemberService {
|
|
|
94
103
|
where: { email: normalized },
|
|
95
104
|
select: { id: true },
|
|
96
105
|
});
|
|
106
|
+
if (!member) throw new NoAccountMemberError(normalized);
|
|
97
107
|
return client.agentMember.create({
|
|
98
|
-
data: { agentId,
|
|
108
|
+
data: { agentId, memberId: member.id },
|
|
99
109
|
});
|
|
100
110
|
}
|
|
101
111
|
|
|
@@ -108,7 +108,7 @@ async function seedAgentMember(
|
|
|
108
108
|
data: { accountId: account.id, email, role: "member" },
|
|
109
109
|
});
|
|
110
110
|
await prisma.agentMember.create({
|
|
111
|
-
data: { agentId,
|
|
111
|
+
data: { agentId, memberId: member.id },
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -372,7 +372,7 @@ describeOrSkip("admin CRUD API (integration)", () => {
|
|
|
372
372
|
data: { agentId: preExisting.id, key: "FOO", value: "encrypted-value" },
|
|
373
373
|
});
|
|
374
374
|
const member = await prisma.agentMember.create({
|
|
375
|
-
data: { agentId: preExisting.id,
|
|
375
|
+
data: { agentId: preExisting.id, memberId: "member-1" },
|
|
376
376
|
});
|
|
377
377
|
|
|
378
378
|
// Re-running `prisma migrate deploy` against an already-migrated schema
|
|
@@ -578,7 +578,7 @@ function makeMockDeps(): AdminDeps {
|
|
|
578
578
|
id: "member-test-id",
|
|
579
579
|
agentId,
|
|
580
580
|
email,
|
|
581
|
-
memberId:
|
|
581
|
+
memberId: "member-1",
|
|
582
582
|
createdAt: new Date("2024-01-01"),
|
|
583
583
|
}),
|
|
584
584
|
// Default: at least one member, so restrictSlackToMembers tests that
|
|
@@ -589,7 +589,7 @@ function makeMockDeps(): AdminDeps {
|
|
|
589
589
|
id: "member-test-id",
|
|
590
590
|
agentId,
|
|
591
591
|
email: "member@example.com",
|
|
592
|
-
memberId:
|
|
592
|
+
memberId: "member-1",
|
|
593
593
|
createdAt: new Date("2024-01-01"),
|
|
594
594
|
},
|
|
595
595
|
],
|
|
@@ -3072,7 +3072,7 @@ describe("admin API — restrictSlackToMembers field", () => {
|
|
|
3072
3072
|
id: "member-1",
|
|
3073
3073
|
agentId: AGENT_ID,
|
|
3074
3074
|
email: "member@example.com",
|
|
3075
|
-
memberId:
|
|
3075
|
+
memberId: "member-1",
|
|
3076
3076
|
createdAt: new Date("2024-01-01"),
|
|
3077
3077
|
},
|
|
3078
3078
|
],
|
|
@@ -5232,7 +5232,7 @@ describe("non-admin session cookie scoping", () => {
|
|
|
5232
5232
|
id: "m1",
|
|
5233
5233
|
agentId: AGENT_ID,
|
|
5234
5234
|
email,
|
|
5235
|
-
memberId:
|
|
5235
|
+
memberId: "member-1",
|
|
5236
5236
|
createdAt: new Date("2024-01-01"),
|
|
5237
5237
|
},
|
|
5238
5238
|
]
|
|
@@ -6241,7 +6241,7 @@ describe("admin API — repo removal blocks open work", () => {
|
|
|
6241
6241
|
id: "m1",
|
|
6242
6242
|
agentId: AGENT_ID,
|
|
6243
6243
|
email,
|
|
6244
|
-
memberId:
|
|
6244
|
+
memberId: "member-1",
|
|
6245
6245
|
createdAt: new Date("2024-01-01"),
|
|
6246
6246
|
},
|
|
6247
6247
|
]
|
|
@@ -225,13 +225,12 @@ describeOrSkip("createAgent() — integration (real Postgres)", () => {
|
|
|
225
225
|
const members = await prisma.agentMember.findMany({
|
|
226
226
|
where: { agentId: result.agent.id },
|
|
227
227
|
});
|
|
228
|
-
expect(members.map((m) => m.email)).toEqual(["dev@example.com"]);
|
|
229
228
|
// The email got an AccountMember (the only Account), so the row is listed.
|
|
230
229
|
const record = await prisma.accountMember.findUniqueOrThrow({
|
|
231
230
|
where: { email: "dev@example.com" },
|
|
232
231
|
});
|
|
233
232
|
expect(record.role).toBe("member");
|
|
234
|
-
expect(members
|
|
233
|
+
expect(members.map((m) => m.memberId)).toEqual([record.id]);
|
|
235
234
|
});
|
|
236
235
|
|
|
237
236
|
it("a member email that cannot get an account member fails with a message and writes nothing", async () => {
|
package/src/api.smoke.test.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { parseChatCredentialConfig } from "./chat-credential-config.ts";
|
|
3
|
+
|
|
4
|
+
describe("parseChatCredentialConfig", () => {
|
|
5
|
+
it("is enabled only for the exact value 'enabled'", () => {
|
|
6
|
+
expect(
|
|
7
|
+
parseChatCredentialConfig({ SHIPWRIGHT_CHAT_TOKEN_MINT_ENABLED: "enabled" }),
|
|
8
|
+
).toEqual({ enabled: true });
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("is disabled when the flag is unset", () => {
|
|
12
|
+
expect(parseChatCredentialConfig({})).toEqual({ enabled: false });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// The parser never throws: any invalid/unrecognized value fails closed.
|
|
16
|
+
it.each(["true", "1", "ENABLED", "Enabled", " enabled", "disabled", ""])(
|
|
17
|
+
"fails closed (disabled) for invalid value %p",
|
|
18
|
+
(value) => {
|
|
19
|
+
expect(
|
|
20
|
+
parseChatCredentialConfig({ SHIPWRIGHT_CHAT_TOKEN_MINT_ENABLED: value }),
|
|
21
|
+
).toEqual({ enabled: false });
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
it("ignores unrelated env vars", () => {
|
|
26
|
+
expect(parseChatCredentialConfig({ OTHER: "enabled" })).toEqual({
|
|
27
|
+
enabled: false,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
package/src/chat.smoke.test.ts
CHANGED
|
@@ -346,7 +346,7 @@ function makeBaseDeps(overrides?: Partial<AdminUIDeps>): AdminUIDeps {
|
|
|
346
346
|
id: "m1",
|
|
347
347
|
agentId,
|
|
348
348
|
email,
|
|
349
|
-
memberId:
|
|
349
|
+
memberId: "member-1",
|
|
350
350
|
createdAt: new Date(),
|
|
351
351
|
}),
|
|
352
352
|
remove: async () => {},
|
|
@@ -1610,8 +1610,7 @@ function makeMemberDeps(
|
|
|
1610
1610
|
? memberOf.map((agentId) => ({
|
|
1611
1611
|
id: `m-${agentId}`,
|
|
1612
1612
|
agentId,
|
|
1613
|
-
email
|
|
1614
|
-
memberId: null,
|
|
1613
|
+
memberId: `member-${email}`,
|
|
1615
1614
|
createdAt: new Date(),
|
|
1616
1615
|
}))
|
|
1617
1616
|
: [],
|
|
@@ -1871,17 +1870,72 @@ describe("chat routes — caller scope matrix (ACM-7.4)", () => {
|
|
|
1871
1870
|
path: (agent: string, thread: string) => string;
|
|
1872
1871
|
init?: () => { headers: Record<string, string>; body: BodyInit };
|
|
1873
1872
|
}[] = [
|
|
1874
|
-
{
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
{
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1873
|
+
{
|
|
1874
|
+
name: "thread view",
|
|
1875
|
+
method: "GET",
|
|
1876
|
+
path: (a, t) => `/admin/chat/${a}/threads/${t}`,
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
name: "create thread",
|
|
1880
|
+
method: "POST",
|
|
1881
|
+
path: (a) => `/admin/chat/${a}/threads`,
|
|
1882
|
+
init: () => ({ headers: {}, body: new FormData() }),
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
name: "post message (form)",
|
|
1886
|
+
method: "POST",
|
|
1887
|
+
path: (a, t) => `/admin/chat/${a}/threads/${t}/messages`,
|
|
1888
|
+
init: () => ({
|
|
1889
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1890
|
+
body: "body=hi",
|
|
1891
|
+
}),
|
|
1892
|
+
},
|
|
1893
|
+
{
|
|
1894
|
+
name: "upload",
|
|
1895
|
+
method: "POST",
|
|
1896
|
+
path: (a, t) => `/admin/chat/${a}/threads/${t}/messages/upload`,
|
|
1897
|
+
init: form,
|
|
1898
|
+
},
|
|
1899
|
+
{
|
|
1900
|
+
name: "attachment",
|
|
1901
|
+
method: "GET",
|
|
1902
|
+
path: (a, t) => `/admin/chat/${a}/threads/${t}/messages/m1/attachment`,
|
|
1903
|
+
},
|
|
1904
|
+
{
|
|
1905
|
+
name: "rename",
|
|
1906
|
+
method: "POST",
|
|
1907
|
+
path: (a, t) => `/admin/chat/${a}/threads/${t}/rename`,
|
|
1908
|
+
init: () => json({ title: "x" }),
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
name: "delete",
|
|
1912
|
+
method: "POST",
|
|
1913
|
+
path: (a, t) => `/admin/chat/${a}/threads/${t}/delete`,
|
|
1914
|
+
init: () => json({}),
|
|
1915
|
+
},
|
|
1916
|
+
{
|
|
1917
|
+
name: "messages.json GET",
|
|
1918
|
+
method: "GET",
|
|
1919
|
+
path: (a, t) => `/admin/chat/${a}/threads/${t}/messages.json`,
|
|
1920
|
+
},
|
|
1921
|
+
{
|
|
1922
|
+
name: "messages.json POST",
|
|
1923
|
+
method: "POST",
|
|
1924
|
+
path: (a, t) => `/admin/chat/${a}/threads/${t}/messages.json`,
|
|
1925
|
+
init: () => json({ body: "hi" }),
|
|
1926
|
+
},
|
|
1927
|
+
{
|
|
1928
|
+
name: "push subscribe",
|
|
1929
|
+
method: "POST",
|
|
1930
|
+
path: (a) => `/admin/chat/${a}/push/subscribe`,
|
|
1931
|
+
init: () => json({}),
|
|
1932
|
+
},
|
|
1933
|
+
{
|
|
1934
|
+
name: "push unsubscribe",
|
|
1935
|
+
method: "POST",
|
|
1936
|
+
path: (a) => `/admin/chat/${a}/push/unsubscribe`,
|
|
1937
|
+
init: () => json({}),
|
|
1938
|
+
},
|
|
1885
1939
|
];
|
|
1886
1940
|
|
|
1887
1941
|
async function call(
|