@app-vitals/agent-admin 1.108.0 → 1.109.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 (55) hide show
  1. package/Dockerfile +4 -0
  2. package/account-move.example.json +22 -0
  3. package/e2e/real/admin-access.real.e2e.ts +77 -68
  4. package/e2e/real/agent-management.real.e2e.ts +165 -143
  5. package/e2e/real/owner-access.real.e2e.ts +228 -212
  6. package/openapi.platform.json +11 -6
  7. package/package.json +2 -2
  8. package/src/account-agent-create.ts +18 -9
  9. package/src/account-agent-create.unit.test.ts +12 -14
  10. package/src/account-created-notifier.ts +1 -1
  11. package/src/account-move.integration.test.ts +594 -0
  12. package/src/account-move.ts +867 -0
  13. package/src/account-move.unit.test.ts +206 -0
  14. package/src/account-onboarding.integration.test.ts +69 -0
  15. package/src/account-onboarding.ts +29 -3
  16. package/src/account-trial-expiry-sweeper.ts +1 -1
  17. package/src/accounts-api.integration.test.ts +5 -2
  18. package/src/accounts-api.smoke.test.ts +21 -5
  19. package/src/accounts-api.ts +12 -15
  20. package/src/admin-boot-config.ts +2 -0
  21. package/src/admin-boot-config.unit.test.ts +27 -0
  22. package/src/admin-boot.ts +11 -10
  23. package/src/admin-local-agent.smoke.test.ts +65 -0
  24. package/src/admin-ui-account-pages.ts +2 -3
  25. package/src/admin-ui-account-pages.unit.test.ts +5 -3
  26. package/src/admin-ui-account.smoke.test.ts +7 -3
  27. package/src/admin-ui-account.ts +10 -15
  28. package/src/admin-ui-accounts.smoke.test.ts +4 -4
  29. package/src/admin-ui-accounts.ts +7 -11
  30. package/src/admin-ui-pages.ts +16 -5
  31. package/src/admin-ui-pages.unit.test.ts +25 -20
  32. package/src/admin-ui-settings-nav-context.smoke.test.ts +24 -0
  33. package/src/admin-ui-settings.smoke.test.ts +17 -1
  34. package/src/admin-ui.smoke.test.ts +167 -2
  35. package/src/admin-ui.ts +75 -50
  36. package/src/agent-management-access.integration.test.ts +18 -6
  37. package/src/agent-manifest.ts +2 -1
  38. package/src/agent-provisioner.integration.test.ts +10 -10
  39. package/src/agent-provisioner.ts +10 -1
  40. package/src/agent-provisioner.unit.test.ts +110 -36
  41. package/src/agent-templates-api.integration.test.ts +23 -5
  42. package/src/agent-templates-api.ts +11 -8
  43. package/src/agents-api.smoke.test.ts +106 -8
  44. package/src/agents-api.ts +5 -3
  45. package/src/agents.integration.test.ts +112 -2
  46. package/src/agents.ts +37 -6
  47. package/src/caller-scope.integration.test.ts +8 -6
  48. package/src/caller-scope.ts +32 -26
  49. package/src/caller-scope.unit.test.ts +15 -11
  50. package/src/github-enterprise-isolation.unit.test.ts +17 -0
  51. package/src/move-accounts.ts +201 -0
  52. package/src/openapi-schemas.ts +6 -0
  53. package/src/platform-routes.ts +2 -2
  54. package/src/self-serve-config.ts +8 -8
  55. package/src/self-serve-config.unit.test.ts +3 -10
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * admin/e2e/real/owner-access.real.e2e.ts
3
3
  *
4
- * Real-service e2e, self-serve ON: an account owner (owner1, Account One)
5
- * sees and manages everything in their account, including agents they are not
6
- * an AgentMember of, and nothing in the other account. Direct URLs and requests
4
+ * Real-service e2e, self-serve OFF and ON (the setting must not change it):
5
+ * an account owner (owner1, Account One) sees and manages everything in their
6
+ * account, including agents they are not an AgentMember of, and nothing in the
7
+ * other account. Direct URLs and requests
7
8
  * for Account Two's agents, its chat and the admin-only pages are refused, and
8
9
  * each refusal is shown to have changed nothing.
9
10
  */
@@ -12,226 +13,241 @@ import { expect, test } from "@playwright/test";
12
13
  import { AGENTS, EMAILS, THREADS } from "./constants.ts";
13
14
  import { RealHarness } from "./fixture.ts";
14
15
 
15
- const harness = new RealHarness({
16
- selfServe: true,
17
- adminPort: 3520,
18
- chatPort: 3521,
19
- });
20
-
21
16
  test.describe.configure({ mode: "serial" });
22
17
 
23
- test.beforeAll(async () => {
24
- test.setTimeout(240_000);
25
- await harness.start();
26
- });
27
- test.afterAll(async () => {
28
- await harness.stop();
29
- });
30
-
31
18
  const REFUSED = [403, 404];
32
19
 
33
- test.describe("owner, self-serve on", () => {
34
- test("Agents list shows every agent in their account and none of the other", async ({
35
- page,
36
- context,
37
- }) => {
38
- await harness.signIn(context, EMAILS.owner1);
39
- await page.goto(`${harness.adminUrl}/admin/agents`);
40
- await expect(page.getByText(AGENTS.alpha.name).first()).toBeVisible();
41
- // Beta: same account, owner1 is not an AgentMember of it.
42
- await expect(page.getByText(AGENTS.beta.name).first()).toBeVisible();
43
- await expect(page.getByText(AGENTS.gamma.name)).toHaveCount(0);
44
-
45
- const res = await context.request.get(`${harness.adminUrl}/agents`);
46
- const ids = ((await res.json()) as { id: string }[]).map((a) => a.id);
47
- expect(ids.sort()).toEqual([AGENTS.alpha.id, AGENTS.beta.id].sort());
48
- });
49
-
50
- test("owner opens an agent they are not an AgentMember of", async ({
51
- page,
52
- context,
53
- }) => {
54
- await harness.signIn(context, EMAILS.owner1);
55
- const res = await page.goto(
56
- `${harness.adminUrl}/admin/agents/${AGENTS.beta.id}`,
57
- );
58
- expect(res?.status()).toBe(200);
59
- await expect(page.getByText(AGENTS.beta.name).first()).toBeVisible();
60
- const json = await context.request.get(
61
- `${harness.adminUrl}/agents/${AGENTS.beta.id}`,
62
- );
63
- expect(json.status()).toBe(200);
64
- });
20
+ /** The self-serve setting must not change any of this. */
21
+ const MODES = [
22
+ { selfServe: false, adminPort: 3526, chatPort: 3527 },
23
+ { selfServe: true, adminPort: 3520, chatPort: 3521 },
24
+ ];
25
+
26
+ for (const mode of MODES) {
27
+ test.describe(`self-serve ${mode.selfServe ? "on" : "off"}`, () => {
28
+ test.describe.configure({ mode: "serial" });
29
+ const harness = new RealHarness(mode);
30
+
31
+ test.beforeAll(async () => {
32
+ test.setTimeout(240_000);
33
+ await harness.start();
34
+ });
35
+ test.afterAll(async () => {
36
+ await harness.stop();
37
+ });
38
+
39
+ test.describe("owner", () => {
40
+ test("Agents list shows every agent in their account and none of the other", async ({
41
+ page,
42
+ context,
43
+ }) => {
44
+ await harness.signIn(context, EMAILS.owner1);
45
+ await page.goto(`${harness.adminUrl}/admin/agents`);
46
+ await expect(page.getByText(AGENTS.alpha.name).first()).toBeVisible();
47
+ // Beta: same account, owner1 is not an AgentMember of it.
48
+ await expect(page.getByText(AGENTS.beta.name).first()).toBeVisible();
49
+ await expect(page.getByText(AGENTS.gamma.name)).toHaveCount(0);
50
+
51
+ const res = await context.request.get(`${harness.adminUrl}/agents`);
52
+ const ids = ((await res.json()) as { id: string }[]).map((a) => a.id);
53
+ expect(ids.sort()).toEqual([AGENTS.alpha.id, AGENTS.beta.id].sort());
54
+ });
65
55
 
66
- test("owner Settings, Templates and Account pages open; admin-only items do not", async ({
67
- page,
68
- context,
69
- }) => {
70
- await harness.signIn(context, EMAILS.owner1);
71
- const base = harness.adminUrl;
72
- for (const path of [
73
- "/admin/settings",
74
- "/admin/settings/templates",
75
- "/admin/account",
76
- ]) {
77
- const res = await page.goto(`${base}${path}`);
78
- expect(res?.status(), path).toBe(200);
79
- await expect(page.locator("nav.settings-sidebar")).toBeVisible();
80
- }
81
- const nav = page.locator("nav.settings-sidebar");
82
- await expect(nav.locator('a[href^="/admin/account"]')).toHaveCount(1);
83
- await expect(
84
- nav.locator('a[href^="/admin/settings/templates"]'),
85
- ).toHaveCount(1);
86
- // Admin-only items are not offered.
87
- for (const href of [
88
- "/admin/settings/github-enterprise",
89
- "/admin/accounts",
90
- ]) {
91
- await expect(nav.locator(`a[href^="${href}"]`)).toHaveCount(0);
92
- }
93
- // The owner's Account page shows their own account only.
94
- await page.goto(`${base}/admin/account`);
95
- await expect(page.getByText(EMAILS.member1).first()).toBeVisible();
96
- await expect(page.getByText(EMAILS.owner2)).toHaveCount(0);
97
- });
56
+ test("owner opens an agent they are not an AgentMember of", async ({
57
+ page,
58
+ context,
59
+ }) => {
60
+ await harness.signIn(context, EMAILS.owner1);
61
+ const res = await page.goto(
62
+ `${harness.adminUrl}/admin/agents/${AGENTS.beta.id}`,
63
+ );
64
+ expect(res?.status()).toBe(200);
65
+ await expect(page.getByText(AGENTS.beta.name).first()).toBeVisible();
66
+ const json = await context.request.get(
67
+ `${harness.adminUrl}/agents/${AGENTS.beta.id}`,
68
+ );
69
+ expect(json.status()).toBe(200);
70
+ });
98
71
 
99
- test("owner can open the agent creation form", async ({ page, context }) => {
100
- await harness.signIn(context, EMAILS.owner1);
101
- const form = await page.goto(`${harness.adminUrl}/admin/agents/new`);
102
- expect(form?.status()).toBe(200);
103
- await expect(page.locator("form").first()).toBeVisible();
104
- });
72
+ test("owner Settings, Templates and Account pages open; admin-only items do not", async ({
73
+ page,
74
+ context,
75
+ }) => {
76
+ await harness.signIn(context, EMAILS.owner1);
77
+ const base = harness.adminUrl;
78
+ for (const path of [
79
+ "/admin/settings",
80
+ "/admin/settings/templates",
81
+ "/admin/account",
82
+ ]) {
83
+ const res = await page.goto(`${base}${path}`);
84
+ expect(res?.status(), path).toBe(200);
85
+ await expect(page.locator("nav.settings-sidebar")).toBeVisible();
86
+ }
87
+ const nav = page.locator("nav.settings-sidebar");
88
+ await expect(nav.locator('a[href^="/admin/account"]')).toHaveCount(1);
89
+ await expect(
90
+ nav.locator('a[href^="/admin/settings/templates"]'),
91
+ ).toHaveCount(1);
92
+ // Admin-only items are not offered.
93
+ for (const href of [
94
+ "/admin/settings/github-enterprise",
95
+ "/admin/accounts",
96
+ ]) {
97
+ await expect(nav.locator(`a[href^="${href}"]`)).toHaveCount(0);
98
+ }
99
+ // The owner's Account page shows their own account only.
100
+ await page.goto(`${base}/admin/account`);
101
+ await expect(page.getByText(EMAILS.member1).first()).toBeVisible();
102
+ await expect(page.getByText(EMAILS.owner2)).toHaveCount(0);
103
+ });
105
104
 
106
- test("direct URLs and requests for the other account's agent are refused", async ({
107
- page,
108
- context,
109
- }) => {
110
- await harness.signIn(context, EMAILS.owner1);
111
- const base = harness.adminUrl;
112
- const other = AGENTS.gamma;
113
-
114
- for (const path of [
115
- `/admin/agents/${other.id}`,
116
- `/admin/agents/${other.id}/setup`,
117
- ]) {
118
- const res = await page.goto(`${base}${path}`);
119
- expect(REFUSED, path).toContain(res?.status());
120
- await expect(page.getByText(other.name)).toHaveCount(0);
121
- }
122
-
123
- for (const path of [
124
- `/agents/${other.id}`,
125
- `/agents/${other.id}/envs`,
126
- `/agents/${other.id}/crons`,
127
- `/agents/${other.id}/tokens`,
128
- ]) {
129
- const res = await context.request.get(`${base}${path}`);
130
- expect(REFUSED, `GET ${path}`).toContain(res.status());
131
- expect(await res.text()).not.toContain(other.name);
132
- }
133
-
134
- const writes: [string, string, unknown?][] = [
135
- ["PATCH", `/agents/${other.id}`, { repos: ["evil-org/pwn"] }],
136
- ["POST", `/agents/${other.id}/repos`, { repos: ["evil-org/pwn"] }],
137
- ["DELETE", `/agents/${other.id}`],
138
- ];
139
- for (const [method, path, data] of writes) {
140
- const res = await context.request.fetch(`${base}${path}`, {
141
- method,
142
- ...(data ? { data } : {}),
105
+ test("owner can open the agent creation form", async ({
106
+ page,
107
+ context,
108
+ }) => {
109
+ await harness.signIn(context, EMAILS.owner1);
110
+ const form = await page.goto(`${harness.adminUrl}/admin/agents/new`);
111
+ expect(form?.status()).toBe(200);
112
+ await expect(page.locator("form").first()).toBeVisible();
143
113
  });
144
- expect(REFUSED, `${method} ${path}`).toContain(res.status());
145
- }
146
-
147
- for (const path of [
148
- `/admin/agents/${other.id}/settings`,
149
- `/admin/agents/${other.id}/members`,
150
- `/admin/agents/${other.id}/envs`,
151
- `/admin/agents/${other.id}/delete`,
152
- ]) {
153
- const res = await context.request.post(`${base}${path}`, {
154
- form: { email: "owner1@e2e.test", key: "K", value: "V" },
155
- maxRedirects: 0,
114
+
115
+ test("direct URLs and requests for the other account's agent are refused", async ({
116
+ page,
117
+ context,
118
+ }) => {
119
+ await harness.signIn(context, EMAILS.owner1);
120
+ const base = harness.adminUrl;
121
+ const other = AGENTS.gamma;
122
+
123
+ for (const path of [
124
+ `/admin/agents/${other.id}`,
125
+ `/admin/agents/${other.id}/setup`,
126
+ ]) {
127
+ const res = await page.goto(`${base}${path}`);
128
+ expect(REFUSED, path).toContain(res?.status());
129
+ await expect(page.getByText(other.name)).toHaveCount(0);
130
+ }
131
+
132
+ for (const path of [
133
+ `/agents/${other.id}`,
134
+ `/agents/${other.id}/envs`,
135
+ `/agents/${other.id}/crons`,
136
+ `/agents/${other.id}/tokens`,
137
+ ]) {
138
+ const res = await context.request.get(`${base}${path}`);
139
+ expect(REFUSED, `GET ${path}`).toContain(res.status());
140
+ expect(await res.text()).not.toContain(other.name);
141
+ }
142
+
143
+ const writes: [string, string, unknown?][] = [
144
+ ["PATCH", `/agents/${other.id}`, { repos: ["evil-org/pwn"] }],
145
+ ["POST", `/agents/${other.id}/repos`, { repos: ["evil-org/pwn"] }],
146
+ ["DELETE", `/agents/${other.id}`],
147
+ ];
148
+ for (const [method, path, data] of writes) {
149
+ const res = await context.request.fetch(`${base}${path}`, {
150
+ method,
151
+ ...(data ? { data } : {}),
152
+ });
153
+ expect(REFUSED, `${method} ${path}`).toContain(res.status());
154
+ }
155
+
156
+ for (const path of [
157
+ `/admin/agents/${other.id}/settings`,
158
+ `/admin/agents/${other.id}/members`,
159
+ `/admin/agents/${other.id}/envs`,
160
+ `/admin/agents/${other.id}/delete`,
161
+ ]) {
162
+ const res = await context.request.post(`${base}${path}`, {
163
+ form: { email: "owner1@e2e.test", key: "K", value: "V" },
164
+ maxRedirects: 0,
165
+ });
166
+ expect(REFUSED, `POST ${path}`).toContain(res.status());
167
+ }
156
168
  });
157
- expect(REFUSED, `POST ${path}`).toContain(res.status());
158
- }
159
- });
160
169
 
161
- test("the other account's chat is refused", async ({ page, context }) => {
162
- await harness.signIn(context, EMAILS.owner1);
163
- const base = harness.adminUrl;
164
- const other = AGENTS.gamma;
165
- const seeded = THREADS.gamma;
166
- const threadId = await harness.threadIdByTitle(seeded.title);
167
-
168
- const picked = await page.goto(`${base}/admin/chat?agentId=${other.id}`);
169
- expect(REFUSED).toContain(picked?.status());
170
- await expect(page.getByText(seeded.title)).toHaveCount(0);
171
-
172
- const read = await page.goto(
173
- `${base}/admin/chat/${other.id}/threads/${threadId}`,
174
- );
175
- expect(REFUSED).toContain(read?.status());
176
- await expect(page.getByText(seeded.message)).toHaveCount(0);
177
-
178
- const before = await harness.chatThreads();
179
- for (const path of [
180
- `/admin/chat/${other.id}/threads`,
181
- `/admin/chat/${other.id}/threads/${threadId}/messages`,
182
- `/admin/chat/${other.id}/threads/${threadId}/delete`,
183
- ]) {
184
- const res = await context.request.post(`${base}${path}`, {
185
- form: { title: "pwn thread", body: "pwn message" },
186
- maxRedirects: 0,
170
+ test("the other account's chat is refused", async ({ page, context }) => {
171
+ await harness.signIn(context, EMAILS.owner1);
172
+ const base = harness.adminUrl;
173
+ const other = AGENTS.gamma;
174
+ const seeded = THREADS.gamma;
175
+ const threadId = await harness.threadIdByTitle(seeded.title);
176
+
177
+ const picked = await page.goto(
178
+ `${base}/admin/chat?agentId=${other.id}`,
179
+ );
180
+ expect(REFUSED).toContain(picked?.status());
181
+ await expect(page.getByText(seeded.title)).toHaveCount(0);
182
+
183
+ const read = await page.goto(
184
+ `${base}/admin/chat/${other.id}/threads/${threadId}`,
185
+ );
186
+ expect(REFUSED).toContain(read?.status());
187
+ await expect(page.getByText(seeded.message)).toHaveCount(0);
188
+
189
+ const before = await harness.chatThreads();
190
+ for (const path of [
191
+ `/admin/chat/${other.id}/threads`,
192
+ `/admin/chat/${other.id}/threads/${threadId}/messages`,
193
+ `/admin/chat/${other.id}/threads/${threadId}/delete`,
194
+ ]) {
195
+ const res = await context.request.post(`${base}${path}`, {
196
+ form: { title: "pwn thread", body: "pwn message" },
197
+ maxRedirects: 0,
198
+ });
199
+ expect(REFUSED, `POST ${path}`).toContain(res.status());
200
+ }
201
+ const after = await harness.chatThreads();
202
+ expect(after.map((t) => [t.id, t.title]).sort()).toEqual(
203
+ before.map((t) => [t.id, t.title]).sort(),
204
+ );
205
+ expect(
206
+ (await harness.chatMessages(threadId)).map((m) => m.body),
207
+ ).toEqual([seeded.message]);
187
208
  });
188
- expect(REFUSED, `POST ${path}`).toContain(res.status());
189
- }
190
- const after = await harness.chatThreads();
191
- expect(after.map((t) => [t.id, t.title]).sort()).toEqual(
192
- before.map((t) => [t.id, t.title]).sort(),
193
- );
194
- expect((await harness.chatMessages(threadId)).map((m) => m.body)).toEqual([
195
- seeded.message,
196
- ]);
197
- });
198
209
 
199
- test("admin-only pages are refused", async ({ page, context }) => {
200
- await harness.signIn(context, EMAILS.owner1);
201
- const base = harness.adminUrl;
202
- for (const path of [
203
- "/admin/settings/github-enterprise",
204
- "/admin/accounts",
205
- `/admin/accounts/${AGENTS.gamma.accountId}`,
206
- ]) {
207
- const res = await page.goto(`${base}${path}`);
208
- expect(REFUSED, path).toContain(res?.status());
209
- await expect(page.getByText("Account Two")).toHaveCount(0);
210
- }
211
- for (const path of ["/accounts", `/accounts/${AGENTS.gamma.accountId}`]) {
212
- const res = await context.request.get(`${base}${path}`);
213
- expect(REFUSED, `GET ${path}`).toContain(res.status());
214
- expect(await res.text()).not.toContain("Account Two");
215
- }
216
- const post = await context.request.post(
217
- `${base}/admin/accounts/${AGENTS.gamma.accountId}`,
218
- { form: { name: "pwned" }, maxRedirects: 0 },
219
- );
220
- expect(REFUSED).toContain(post.status());
221
- });
210
+ test("admin-only pages are refused", async ({ page, context }) => {
211
+ await harness.signIn(context, EMAILS.owner1);
212
+ const base = harness.adminUrl;
213
+ for (const path of [
214
+ "/admin/settings/github-enterprise",
215
+ "/admin/accounts",
216
+ `/admin/accounts/${AGENTS.gamma.accountId}`,
217
+ ]) {
218
+ const res = await page.goto(`${base}${path}`);
219
+ expect(REFUSED, path).toContain(res?.status());
220
+ await expect(page.getByText("Account Two")).toHaveCount(0);
221
+ }
222
+ for (const path of [
223
+ "/accounts",
224
+ `/accounts/${AGENTS.gamma.accountId}`,
225
+ ]) {
226
+ const res = await context.request.get(`${base}${path}`);
227
+ expect(REFUSED, `GET ${path}`).toContain(res.status());
228
+ expect(await res.text()).not.toContain("Account Two");
229
+ }
230
+ const post = await context.request.post(
231
+ `${base}/admin/accounts/${AGENTS.gamma.accountId}`,
232
+ { form: { name: "pwned" }, maxRedirects: 0 },
233
+ );
234
+ expect(REFUSED).toContain(post.status());
235
+ });
222
236
 
223
- test("nothing in the other account was changed", async ({ context }) => {
224
- await harness.signIn(context, EMAILS.admin);
225
- const res = await context.request.get(
226
- `${harness.adminUrl}/agents/${AGENTS.gamma.id}`,
227
- );
228
- const row = (await res.json()) as {
229
- name: string;
230
- repos: string[];
231
- accountId: string;
232
- };
233
- expect(row.name).toBe(AGENTS.gamma.name);
234
- expect(row.repos).toEqual([...AGENTS.gamma.repos]);
235
- expect(row.accountId).toBe(AGENTS.gamma.accountId);
237
+ test("nothing in the other account was changed", async ({ context }) => {
238
+ await harness.signIn(context, EMAILS.admin);
239
+ const res = await context.request.get(
240
+ `${harness.adminUrl}/agents/${AGENTS.gamma.id}`,
241
+ );
242
+ const row = (await res.json()) as {
243
+ name: string;
244
+ repos: string[];
245
+ accountId: string;
246
+ };
247
+ expect(row.name).toBe(AGENTS.gamma.name);
248
+ expect(row.repos).toEqual([...AGENTS.gamma.repos]);
249
+ expect(row.accountId).toBe(AGENTS.gamma.accountId);
250
+ });
251
+ });
236
252
  });
237
- });
253
+ }
@@ -619,6 +619,11 @@
619
619
  "anthropicApiKey": {
620
620
  "type": "string"
621
621
  },
622
+ "accountId": {
623
+ "type": "string",
624
+ "minLength": 1,
625
+ "example": "acct_123"
626
+ },
622
627
  "env": {
623
628
  "type": "object",
624
629
  "additionalProperties": {
@@ -9147,7 +9152,7 @@
9147
9152
  }
9148
9153
  },
9149
9154
  "403": {
9150
- "description": "Forbidden (caller has no account, or names another account / the deployment scope)",
9155
+ "description": "Forbidden (caller is not an account owner, or names another account / the deployment scope)",
9151
9156
  "content": {
9152
9157
  "application/json": {
9153
9158
  "schema": {
@@ -9225,7 +9230,7 @@
9225
9230
  }
9226
9231
  },
9227
9232
  "403": {
9228
- "description": "Forbidden (caller has no account, or names another account / the deployment scope)",
9233
+ "description": "Forbidden (caller is not an account owner, or names another account / the deployment scope)",
9229
9234
  "content": {
9230
9235
  "application/json": {
9231
9236
  "schema": {
@@ -9296,7 +9301,7 @@
9296
9301
  }
9297
9302
  },
9298
9303
  "403": {
9299
- "description": "Forbidden (caller has no account, or names another account / the deployment scope)",
9304
+ "description": "Forbidden (caller is not an account owner, or names another account / the deployment scope)",
9300
9305
  "content": {
9301
9306
  "application/json": {
9302
9307
  "schema": {
@@ -9348,7 +9353,7 @@
9348
9353
  }
9349
9354
  },
9350
9355
  "403": {
9351
- "description": "Forbidden (caller has no account, or names another account / the deployment scope)",
9356
+ "description": "Forbidden (caller is not an account owner, or names another account / the deployment scope)",
9352
9357
  "content": {
9353
9358
  "application/json": {
9354
9359
  "schema": {
@@ -9428,7 +9433,7 @@
9428
9433
  }
9429
9434
  },
9430
9435
  "403": {
9431
- "description": "Forbidden (caller has no account, or names another account / the deployment scope)",
9436
+ "description": "Forbidden (caller is not an account owner, or names another account / the deployment scope)",
9432
9437
  "content": {
9433
9438
  "application/json": {
9434
9439
  "schema": {
@@ -9507,7 +9512,7 @@
9507
9512
  }
9508
9513
  },
9509
9514
  "403": {
9510
- "description": "Forbidden (caller has no account, or names another account / the deployment scope)",
9515
+ "description": "Forbidden (caller is not an account owner, or names another account / the deployment scope)",
9511
9516
  "content": {
9512
9517
  "application/json": {
9513
9518
  "schema": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-vitals/agent-admin",
3
- "version": "1.108.0",
3
+ "version": "1.109.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.108.0",
47
+ "@app-vitals/agent-lib": "1.109.0",
48
48
  "@hono/zod-openapi": "^1.0.0",
49
49
  "@prisma/adapter-pg": "^7.10.0",
50
50
  "@prisma/client": "^7.10.0",
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * Shared rules for self-serve agent creation by account users (SSP-4.2),
5
5
  * used by both the admin UI form handler and the JSON API route so the two
6
- * cannot drift: account users always create the self-serve specialty (see
7
- * getSelfServeSpecialty) stamped with THEIR account (never a client-supplied
6
+ * cannot drift: account owners always create the default agent type (see
7
+ * getOwnerAgentSpecialty) stamped with THEIR account (never a client-supplied
8
8
  * one), and quota / account-status failures surface as clear messages.
9
9
  */
10
10
 
@@ -12,16 +12,24 @@ import type { CallerScope } from "./caller-scope.ts";
12
12
  import { resolveDefaultSpecialtyName } from "./specialty-types.ts";
13
13
 
14
14
  /**
15
- * The only specialty account users may create: SHIPWRIGHT_SELF_SERVE_AGENT_TYPE
16
- * when set, else the platform's default specialty (SHIPWRIGHT_DEFAULT_AGENT_TYPE,
17
- * "specialist" when unset).
15
+ * The only type an account owner may create: the deployment's default agent
16
+ * type (SHIPWRIGHT_DEFAULT_AGENT_TYPE, "specialist" when unset). Platform
17
+ * admins choose any type.
18
+ */
19
+ export function getOwnerAgentSpecialty(
20
+ env: Record<string, string | undefined> = process.env,
21
+ ): string {
22
+ return resolveDefaultSpecialtyName(env);
23
+ }
24
+
25
+ /**
26
+ * @deprecated The separate self-serve agent type setting is no longer read;
27
+ * this is the default agent type. Use getOwnerAgentSpecialty().
18
28
  */
19
29
  export function getSelfServeSpecialty(
20
30
  env: Record<string, string | undefined> = process.env,
21
31
  ): string {
22
- return (
23
- env.SHIPWRIGHT_SELF_SERVE_AGENT_TYPE || resolveDefaultSpecialtyName(env)
24
- );
32
+ return getOwnerAgentSpecialty(env);
25
33
  }
26
34
 
27
35
  /** Account the caller may create agents in, or null when they have none. */
@@ -31,7 +39,8 @@ export function accountIdFromScope(scope: CallerScope): string | null {
31
39
 
32
40
  /** Clear, user-facing messages for the account-specific createAgent() errors. */
33
41
  export const ACCOUNT_CREATE_ERROR_MESSAGES = {
34
- quota_exceeded: "This account has reached its agent limit.",
42
+ quota_exceeded:
43
+ "This account has reached its agent limit. Delete an agent to free a slot.",
35
44
  account_inactive: "This account is not active.",
36
45
  } as const;
37
46
 
@@ -7,28 +7,26 @@ import { describe, expect, it } from "bun:test";
7
7
  import {
8
8
  canCreateAgent,
9
9
  createAccountIdFromScope,
10
+ getOwnerAgentSpecialty,
10
11
  getSelfServeSpecialty,
11
12
  } from "./account-agent-create.ts";
12
13
  import type { CallerScope } from "./caller-scope.ts";
13
14
 
14
- describe("getSelfServeSpecialty", () => {
15
- it("defaults to specialist", () => {
16
- expect(getSelfServeSpecialty({})).toBe("specialist");
15
+ describe("getOwnerAgentSpecialty", () => {
16
+ it("is the deployment default agent type", () => {
17
+ expect(getOwnerAgentSpecialty({})).toBe("specialist");
17
18
  expect(
18
- getSelfServeSpecialty({ SHIPWRIGHT_DEFAULT_AGENT_TYPE: "fixture" }),
19
+ getOwnerAgentSpecialty({ SHIPWRIGHT_DEFAULT_AGENT_TYPE: "fixture" }),
19
20
  ).toBe("fixture");
20
- expect(
21
- getSelfServeSpecialty({
22
- SHIPWRIGHT_DEFAULT_AGENT_TYPE: "fixture",
23
- SHIPWRIGHT_SELF_SERVE_AGENT_TYPE: "other",
24
- }),
25
- ).toBe("other");
26
21
  });
27
22
 
28
- it("honours SHIPWRIGHT_SELF_SERVE_AGENT_TYPE", () => {
29
- expect(
30
- getSelfServeSpecialty({ SHIPWRIGHT_SELF_SERVE_AGENT_TYPE: "base" }),
31
- ).toBe("base");
23
+ it("ignores the retired self-serve agent type setting", () => {
24
+ const env = {
25
+ SHIPWRIGHT_DEFAULT_AGENT_TYPE: "fixture",
26
+ SHIPWRIGHT_SELF_SERVE_AGENT_TYPE: "other",
27
+ };
28
+ expect(getOwnerAgentSpecialty(env)).toBe("fixture");
29
+ expect(getSelfServeSpecialty(env)).toBe("fixture");
32
30
  });
33
31
  });
34
32
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * admin/src/account-created-notifier.ts
3
- * Best-effort operator notification when self-serve sign-in auto-creates an
3
+ * Best-effort operator notification when self-serve signup auto-creates an
4
4
  * account (SSP-3.3). Reuses the existing web-push wiring — no new integration.
5
5
  * When push isn't configured, the structured `account_created` log emitted by
6
6
  * the Google callback (SSP-3.1) is the only signal.