@app-vitals/agent-admin 1.38.0 → 1.40.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 (34) hide show
  1. package/package.json +2 -2
  2. package/prisma/client/browser.ts +10 -0
  3. package/prisma/client/client.ts +10 -0
  4. package/prisma/client/internal/class.ts +24 -4
  5. package/prisma/client/internal/prismaNamespace.ts +184 -2
  6. package/prisma/client/internal/prismaNamespaceBrowser.ts +33 -1
  7. package/prisma/client/models/Account.ts +148 -0
  8. package/prisma/client/models/Agent.ts +80 -1
  9. package/prisma/client/models/AgentCronJob.ts +54 -1
  10. package/prisma/client/models/AgentEnv.ts +36 -1
  11. package/prisma/client/models/AgentPlugin.ts +36 -1
  12. package/prisma/client/models/AgentTemplate.ts +1501 -0
  13. package/prisma/client/models/AgentTemplateItem.ts +1416 -0
  14. package/prisma/client/models/AgentTool.ts +71 -1
  15. package/prisma/client/models.ts +2 -0
  16. package/prisma/migrations/20261113000000_add_agent_templates/migration.sql +71 -0
  17. package/prisma/schema/schema.prisma +61 -4
  18. package/src/admin-boot.ts +11 -4
  19. package/src/admin-extension.ts +6 -0
  20. package/src/admin-extension.unit.test.ts +17 -0
  21. package/src/admin-local-agent.smoke.test.ts +2 -0
  22. package/src/admin-ui.fixtures.ts +3 -0
  23. package/src/admin-ui.smoke.test.ts +2 -0
  24. package/src/agent-cron-run-stats.smoke.test.ts +10 -0
  25. package/src/agent-plugins.unit.test.ts +1 -0
  26. package/src/agent-template-items.ts +55 -0
  27. package/src/agent-template-items.unit.test.ts +55 -0
  28. package/src/agent-templates.integration.test.ts +200 -0
  29. package/src/agents-api.smoke.test.ts +17 -0
  30. package/src/api.smoke.test.ts +13 -0
  31. package/src/chat.smoke.test.ts +2 -0
  32. package/src/github-enterprise-api.ts +93 -46
  33. package/src/github-lookup-repositories.integration.test.ts +178 -0
  34. package/src/github-lookup-repositories.ts +60 -0
@@ -265,6 +265,7 @@ function makeMockDeps(): AdminDeps {
265
265
  create: async () => ({
266
266
  id: "cron-id",
267
267
  agentId: AGENT_ID,
268
+ source: "custom",
268
269
  schedule: "0 9 * * *",
269
270
  prompt: "test",
270
271
  channel: null,
@@ -284,6 +285,7 @@ function makeMockDeps(): AdminDeps {
284
285
  update: async () => ({
285
286
  id: "cron-id",
286
287
  agentId: AGENT_ID,
288
+ source: "custom",
287
289
  schedule: "0 9 * * *",
288
290
  prompt: "test",
289
291
  channel: null,
@@ -304,6 +306,7 @@ function makeMockDeps(): AdminDeps {
304
306
  get: async () => ({
305
307
  id: "cron-id",
306
308
  agentId: AGENT_ID,
309
+ source: "custom",
307
310
  schedule: "0 9 * * *",
308
311
  prompt: "test",
309
312
  channel: null,
@@ -323,6 +326,7 @@ function makeMockDeps(): AdminDeps {
323
326
  setEnabled: async (_agentId, _cronId, enabled) => ({
324
327
  id: "cron-id",
325
328
  agentId: AGENT_ID,
329
+ source: "custom",
326
330
  schedule: "0 9 * * *",
327
331
  prompt: "test",
328
332
  channel: null,
@@ -342,6 +346,7 @@ function makeMockDeps(): AdminDeps {
342
346
  updatePreCheck: async (_agentId, _cronId, preCheck) => ({
343
347
  id: "cron-id",
344
348
  agentId: AGENT_ID,
349
+ source: "custom",
345
350
  schedule: "0 9 * * *",
346
351
  prompt: "test",
347
352
  channel: null,
@@ -369,6 +374,8 @@ function makeMockDeps(): AdminDeps {
369
374
  add: async () => ({
370
375
  id: "tool-id",
371
376
  agentId: AGENT_ID,
377
+ source: "custom",
378
+ updatedAt: new Date(),
372
379
  pattern: "Read",
373
380
  enabled: true,
374
381
  createdAt: new Date(),
@@ -376,6 +383,8 @@ function makeMockDeps(): AdminDeps {
376
383
  toggle: async () => ({
377
384
  id: "tool-id",
378
385
  agentId: AGENT_ID,
386
+ source: "custom",
387
+ updatedAt: new Date(),
379
388
  pattern: "Read",
380
389
  enabled: false,
381
390
  createdAt: new Date(),
@@ -411,6 +420,7 @@ function makeMockDeps(): AdminDeps {
411
420
  add: async () => ({
412
421
  id: "plugin-id",
413
422
  agentId: AGENT_ID,
423
+ source: "custom",
414
424
  name: "test",
415
425
  version: "1.0.0",
416
426
  enabled: true,
@@ -26,6 +26,7 @@ describe("AgentPluginService.listEnabled", () => {
26
26
  const enabledPlugin = {
27
27
  id: "p1",
28
28
  agentId: "agent-1",
29
+ source: "custom",
29
30
  name: "shipwright@shipwright",
30
31
  version: null,
31
32
  enabled: true,
@@ -0,0 +1,55 @@
1
+ /**
2
+ * admin/src/agent-template-items.ts
3
+ * ATP-1.1: AgentTemplateItem kinds, row source markers, and the at-rest
4
+ * encryption of template item payloads.
5
+ *
6
+ * An env item's payload is `{ value, secret? }`; `value` is encrypted with the
7
+ * same TokenCrypto (AES-256-GCM, SHIPWRIGHT_ENCRYPTION_KEY) that AgentEnvService
8
+ * uses for AgentEnv.value, so copying a template env onto an agent is a
9
+ * decrypt-then-encrypt with one key. Other kinds hold no secrets and pass
10
+ * through unchanged.
11
+ */
12
+
13
+ import type { Prisma } from "../prisma/client/client.ts";
14
+ import { UnprocessableEntityError } from "./errors.ts";
15
+ import type { TokenCrypto } from "./token-crypto.ts";
16
+
17
+ export const AGENT_TEMPLATE_ITEM_KINDS = [
18
+ "env",
19
+ "tool",
20
+ "plugin",
21
+ "cron",
22
+ ] as const;
23
+ export type AgentTemplateItemKind = (typeof AGENT_TEMPLATE_ITEM_KINDS)[number];
24
+
25
+ /** `source` on AgentEnv / AgentTool / AgentPlugin / AgentCronJob. */
26
+ export const ROW_SOURCES = ["template", "custom"] as const;
27
+ export type RowSource = (typeof ROW_SOURCES)[number];
28
+
29
+ /** AgentTemplateItem.payload: a JSON object whose fields depend on `kind`. */
30
+ export type TemplateItemPayload = Prisma.InputJsonObject;
31
+
32
+ /** Returns the payload to store: an env item's `value` encrypted. */
33
+ export function sealTemplateItemPayload(
34
+ kind: AgentTemplateItemKind,
35
+ payload: TemplateItemPayload,
36
+ crypto: TokenCrypto,
37
+ ): TemplateItemPayload {
38
+ if (kind !== "env") return payload;
39
+ if (typeof payload.value !== "string") {
40
+ throw new UnprocessableEntityError(
41
+ "env template item payload needs a string value",
42
+ );
43
+ }
44
+ return { ...payload, value: crypto.encrypt(payload.value) };
45
+ }
46
+
47
+ /** Reverses sealTemplateItemPayload(): an env item's `value` decrypted. */
48
+ export function openTemplateItemPayload(
49
+ kind: AgentTemplateItemKind,
50
+ payload: TemplateItemPayload,
51
+ crypto: TokenCrypto,
52
+ ): TemplateItemPayload {
53
+ if (kind !== "env" || typeof payload.value !== "string") return payload;
54
+ return { ...payload, value: crypto.decrypt(payload.value) };
55
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * admin/src/agent-template-items.unit.test.ts
3
+ * ATP-1.1: template item payload sealing.
4
+ */
5
+
6
+ import { describe, expect, it } from "bun:test";
7
+ import {
8
+ openTemplateItemPayload,
9
+ sealTemplateItemPayload,
10
+ } from "./agent-template-items.ts";
11
+ import { UnprocessableEntityError } from "./errors.ts";
12
+ import { makeStrictTokenCrypto } from "./token-crypto.ts";
13
+
14
+ const crypto = makeStrictTokenCrypto("ab".repeat(32));
15
+ if (!crypto) throw new Error("test key rejected");
16
+
17
+ describe("sealTemplateItemPayload", () => {
18
+ it("encrypts an env item's value and keeps other fields", () => {
19
+ const sealed = sealTemplateItemPayload(
20
+ "env",
21
+ { value: "s3cret", secret: true },
22
+ crypto,
23
+ );
24
+ expect(sealed.secret).toBe(true);
25
+ expect(sealed.value).not.toBe("s3cret");
26
+ expect(String(sealed.value).split(":")).toHaveLength(3);
27
+ expect(openTemplateItemPayload("env", sealed, crypto)).toEqual({
28
+ value: "s3cret",
29
+ secret: true,
30
+ });
31
+ });
32
+
33
+ it("does not mutate the input payload", () => {
34
+ const payload = { value: "v" };
35
+ sealTemplateItemPayload("env", payload, crypto);
36
+ expect(payload).toEqual({ value: "v" });
37
+ });
38
+
39
+ it("rejects an env payload without a string value", () => {
40
+ expect(() => sealTemplateItemPayload("env", {}, crypto)).toThrow(
41
+ UnprocessableEntityError,
42
+ );
43
+ expect(() => sealTemplateItemPayload("env", { value: 1 }, crypto)).toThrow(
44
+ UnprocessableEntityError,
45
+ );
46
+ });
47
+
48
+ it("passes non-env kinds through unchanged", () => {
49
+ const payload = { schedule: "0 9 * * *", prompt: "hi", value: "x" };
50
+ for (const kind of ["tool", "plugin", "cron"] as const) {
51
+ expect(sealTemplateItemPayload(kind, payload, crypto)).toBe(payload);
52
+ expect(openTemplateItemPayload(kind, payload, crypto)).toBe(payload);
53
+ }
54
+ });
55
+ });
@@ -0,0 +1,200 @@
1
+ /**
2
+ * admin/src/agent-templates.integration.test.ts
3
+ * ATP-1.1: AgentTemplate / AgentTemplateItem schema and the row source
4
+ * markers, against real Postgres.
5
+ *
6
+ * Requires DATABASE_URL_ADMIN_TEST to be set; skips otherwise.
7
+ */
8
+
9
+ import { afterEach, beforeEach, describe, expect, it } from "bun:test";
10
+ import type { PrismaClient } from "../prisma/client/client.ts";
11
+ import {
12
+ openTemplateItemPayload,
13
+ sealTemplateItemPayload,
14
+ type TemplateItemPayload,
15
+ } from "./agent-template-items.ts";
16
+ import { createAdminPrismaClient } from "./prisma-client.ts";
17
+ import { makeStrictTokenCrypto } from "./token-crypto.ts";
18
+
19
+ const TEST_DB = process.env.DATABASE_URL_ADMIN_TEST;
20
+
21
+ const describeOrSkip = TEST_DB ? describe : describe.skip;
22
+
23
+ describeOrSkip("AgentTemplate schema (integration)", () => {
24
+ let prisma: PrismaClient;
25
+
26
+ beforeEach(async () => {
27
+ prisma = createAdminPrismaClient(TEST_DB as string);
28
+ await prisma.agentTemplateItem.deleteMany();
29
+ await prisma.agentTemplate.deleteMany();
30
+ await prisma.agent.deleteMany();
31
+ await prisma.accountInvite.deleteMany();
32
+ await prisma.accountMember.deleteMany();
33
+ await prisma.account.deleteMany();
34
+ });
35
+
36
+ afterEach(async () => {
37
+ await prisma.$disconnect();
38
+ });
39
+
40
+ /** Inserting a second template with the same scope must fail. */
41
+ async function expectDuplicateRejected(
42
+ accountId: string | null,
43
+ specialty: string | null,
44
+ ): Promise<void> {
45
+ await prisma.agentTemplate.create({ data: { accountId, specialty } });
46
+ await expect(
47
+ (async () =>
48
+ prisma.agentTemplate.create({ data: { accountId, specialty } }))(),
49
+ ).rejects.toThrow();
50
+ expect(
51
+ await prisma.agentTemplate.count({ where: { accountId, specialty } }),
52
+ ).toBe(1);
53
+ }
54
+
55
+ describe("(accountId, specialty) uniqueness", () => {
56
+ it("rejects a second deployment-wide template for every specialty (both NULL)", async () => {
57
+ await expectDuplicateRejected(null, null);
58
+ });
59
+
60
+ it("rejects a second deployment-wide template for one specialty (accountId NULL)", async () => {
61
+ await expectDuplicateRejected(null, "specialist");
62
+ });
63
+
64
+ it("rejects a second account template for every specialty (specialty NULL)", async () => {
65
+ const account = await prisma.account.create({ data: { name: "A" } });
66
+ await expectDuplicateRejected(account.id, null);
67
+ });
68
+
69
+ it("rejects a second account template for one specialty (both set)", async () => {
70
+ const account = await prisma.account.create({ data: { name: "A" } });
71
+ await expectDuplicateRejected(account.id, "specialist");
72
+ });
73
+
74
+ it("allows one template per distinct scope", async () => {
75
+ const a = await prisma.account.create({ data: { name: "A" } });
76
+ const b = await prisma.account.create({ data: { name: "B" } });
77
+ const scopes: Array<[string | null, string | null]> = [
78
+ [null, null],
79
+ [null, "specialist"],
80
+ [null, "coder"],
81
+ [a.id, null],
82
+ [a.id, "specialist"],
83
+ [b.id, null],
84
+ [b.id, "specialist"],
85
+ ];
86
+ for (const [accountId, specialty] of scopes) {
87
+ await prisma.agentTemplate.create({ data: { accountId, specialty } });
88
+ }
89
+ expect(await prisma.agentTemplate.count()).toBe(scopes.length);
90
+ });
91
+
92
+ it("rejects a duplicate (templateId, kind, key) item but allows the key under another kind", async () => {
93
+ const t = await prisma.agentTemplate.create({ data: {} });
94
+ await prisma.agentTemplateItem.create({
95
+ data: { templateId: t.id, kind: "tool", key: "Read" },
96
+ });
97
+ await prisma.agentTemplateItem.create({
98
+ data: { templateId: t.id, kind: "plugin", key: "Read" },
99
+ });
100
+ await expect(
101
+ (async () =>
102
+ prisma.agentTemplateItem.create({
103
+ data: { templateId: t.id, kind: "tool", key: "Read" },
104
+ }))(),
105
+ ).rejects.toThrow();
106
+ });
107
+
108
+ it("deletes an account's templates and their items with the account", async () => {
109
+ const account = await prisma.account.create({ data: { name: "A" } });
110
+ const t = await prisma.agentTemplate.create({
111
+ data: { accountId: account.id },
112
+ });
113
+ await prisma.agentTemplateItem.create({
114
+ data: { templateId: t.id, kind: "tool", key: "Read" },
115
+ });
116
+ await prisma.account.delete({ where: { id: account.id } });
117
+ expect(await prisma.agentTemplate.count()).toBe(0);
118
+ expect(await prisma.agentTemplateItem.count()).toBe(0);
119
+ });
120
+ });
121
+
122
+ describe("column defaults (what pre-existing rows get)", () => {
123
+ // Raw INSERTs that omit the new columns exercise the database DEFAULTs,
124
+ // which is what ADD COLUMN gives rows written before the migration.
125
+ it("source defaults to custom, templateDetached to false, AgentTool.updatedAt to now", async () => {
126
+ await prisma.$executeRaw`INSERT INTO "Agent" ("id", "name", "updatedAt") VALUES ('ag1', 'legacy', now())`;
127
+ await prisma.$executeRaw`INSERT INTO "AgentEnv" ("id", "agentId", "key", "value", "updatedAt") VALUES ('e1', 'ag1', 'K', 'v', now())`;
128
+ await prisma.$executeRaw`INSERT INTO "AgentTool" ("id", "agentId", "pattern") VALUES ('t1', 'ag1', 'Read')`;
129
+ await prisma.$executeRaw`INSERT INTO "AgentPlugin" ("id", "agentId", "name", "updatedAt") VALUES ('p1', 'ag1', 'x@y', now())`;
130
+ await prisma.$executeRaw`INSERT INTO "AgentCronJob" ("id", "agentId", "schedule", "prompt", "updatedAt") VALUES ('c1', 'ag1', '* * * * *', 'hi', now())`;
131
+
132
+ const agent = await prisma.agent.findUniqueOrThrow({
133
+ where: { id: "ag1" },
134
+ include: { envVars: true, tools: true, plugins: true, cronJobs: true },
135
+ });
136
+ expect(agent.templateDetached).toBe(false);
137
+ expect(agent.envVars.map((r) => r.source)).toEqual(["custom"]);
138
+ expect(agent.tools.map((r) => r.source)).toEqual(["custom"]);
139
+ expect(agent.plugins.map((r) => r.source)).toEqual(["custom"]);
140
+ expect(agent.cronJobs.map((r) => r.source)).toEqual(["custom"]);
141
+ const tool = agent.tools[0];
142
+ expect(tool?.updatedAt).toBeInstanceOf(Date);
143
+ expect(
144
+ Math.abs((tool?.updatedAt.getTime() ?? 0) - Date.now()),
145
+ ).toBeLessThan(60_000);
146
+ });
147
+
148
+ it("keeps an explicit source=template and bumps AgentTool.updatedAt on update", async () => {
149
+ const agent = await prisma.agent.create({ data: { name: "a" } });
150
+ const tool = await prisma.agentTool.create({
151
+ data: { agentId: agent.id, pattern: "Bash", source: "template" },
152
+ });
153
+ expect(tool.source).toBe("template");
154
+ await Bun.sleep(5);
155
+ const updated = await prisma.agentTool.update({
156
+ where: { id: tool.id },
157
+ data: { enabled: false },
158
+ });
159
+ expect(updated.updatedAt.getTime()).toBeGreaterThan(
160
+ tool.updatedAt.getTime(),
161
+ );
162
+ });
163
+ });
164
+
165
+ describe("env item payload", () => {
166
+ it("stores an env item's value AES-256-GCM encrypted and reads it back", async () => {
167
+ const crypto = makeStrictTokenCrypto("cd".repeat(32));
168
+ if (!crypto) throw new Error("test key rejected");
169
+ const t = await prisma.agentTemplate.create({ data: {} });
170
+ const item = await prisma.agentTemplateItem.create({
171
+ data: {
172
+ templateId: t.id,
173
+ kind: "env",
174
+ key: "API_TOKEN",
175
+ payload: sealTemplateItemPayload(
176
+ "env",
177
+ { value: "plain-secret", secret: true },
178
+ crypto,
179
+ ),
180
+ },
181
+ });
182
+
183
+ // The plaintext never reaches the column.
184
+ const rows = await prisma.$queryRaw<
185
+ Array<{ payload: string }>
186
+ >`SELECT "payload"::text AS payload FROM "AgentTemplateItem" WHERE "id" = ${item.id}`;
187
+ expect(rows[0]?.payload).not.toContain("plain-secret");
188
+
189
+ const stored = await prisma.agentTemplateItem.findUniqueOrThrow({
190
+ where: { id: item.id },
191
+ });
192
+ const payload = stored.payload as TemplateItemPayload;
193
+ expect(String(payload.value).split(":")).toHaveLength(3);
194
+ expect(openTemplateItemPayload("env", payload, crypto)).toEqual({
195
+ value: "plain-secret",
196
+ secret: true,
197
+ });
198
+ });
199
+ });
200
+ });
@@ -171,6 +171,7 @@ async function makeSessionCookie(secret = SESSION_SECRET): Promise<string> {
171
171
  const MOCK_CRON = {
172
172
  id: CRON_ID,
173
173
  agentId: AGENT_ID,
174
+ source: "custom",
174
175
  schedule: "0 9 * * 1-5",
175
176
  prompt: "daily standup",
176
177
  channel: "C123" as string | null,
@@ -374,6 +375,7 @@ function makeMockDeps(): AdminDeps {
374
375
  create: async () => ({
375
376
  id: CRON_ID,
376
377
  agentId: AGENT_ID,
378
+ source: "custom",
377
379
  schedule: "0 9 * * 1-5",
378
380
  prompt: "daily standup",
379
381
  channel: "C123",
@@ -393,6 +395,7 @@ function makeMockDeps(): AdminDeps {
393
395
  update: async () => ({
394
396
  id: CRON_ID,
395
397
  agentId: AGENT_ID,
398
+ source: "custom",
396
399
  schedule: "0 10 * * 1-5",
397
400
  prompt: "updated standup",
398
401
  channel: "C123",
@@ -413,6 +416,7 @@ function makeMockDeps(): AdminDeps {
413
416
  get: async (_agentId, _cronId) => ({
414
417
  id: CRON_ID,
415
418
  agentId: AGENT_ID,
419
+ source: "custom",
416
420
  schedule: "0 9 * * 1-5",
417
421
  prompt: "daily standup",
418
422
  channel: "C123",
@@ -432,6 +436,7 @@ function makeMockDeps(): AdminDeps {
432
436
  setEnabled: async (_agentId, _cronId, enabled) => ({
433
437
  id: CRON_ID,
434
438
  agentId: AGENT_ID,
439
+ source: "custom",
435
440
  schedule: "0 9 * * 1-5",
436
441
  prompt: "daily standup",
437
442
  channel: "C123",
@@ -451,6 +456,7 @@ function makeMockDeps(): AdminDeps {
451
456
  updatePreCheck: async (_agentId, _cronId, preCheck) => ({
452
457
  id: CRON_ID,
453
458
  agentId: AGENT_ID,
459
+ source: "custom",
454
460
  schedule: "0 9 * * 1-5",
455
461
  prompt: "daily standup",
456
462
  channel: "C123",
@@ -478,6 +484,8 @@ function makeMockDeps(): AdminDeps {
478
484
  {
479
485
  id: TOOL_ID,
480
486
  agentId: AGENT_ID,
487
+ source: "custom",
488
+ updatedAt: new Date("2024-01-01"),
481
489
  pattern: "Read",
482
490
  enabled: true,
483
491
  createdAt: new Date("2024-01-01"),
@@ -486,6 +494,8 @@ function makeMockDeps(): AdminDeps {
486
494
  add: async () => ({
487
495
  id: TOOL_ID,
488
496
  agentId: AGENT_ID,
497
+ source: "custom",
498
+ updatedAt: new Date("2024-01-01"),
489
499
  pattern: "Read",
490
500
  enabled: true,
491
501
  createdAt: new Date("2024-01-01"),
@@ -493,6 +503,8 @@ function makeMockDeps(): AdminDeps {
493
503
  toggle: async () => ({
494
504
  id: TOOL_ID,
495
505
  agentId: AGENT_ID,
506
+ source: "custom",
507
+ updatedAt: new Date("2024-01-01"),
496
508
  pattern: "Read",
497
509
  enabled: false,
498
510
  createdAt: new Date("2024-01-01"),
@@ -537,6 +549,7 @@ function makeMockDeps(): AdminDeps {
537
549
  {
538
550
  id: PLUGIN_ID,
539
551
  agentId: AGENT_ID,
552
+ source: "custom",
540
553
  name: "shipwright@shipwright",
541
554
  version: "1.0.0",
542
555
  enabled: true,
@@ -547,6 +560,7 @@ function makeMockDeps(): AdminDeps {
547
560
  add: async () => ({
548
561
  id: PLUGIN_ID,
549
562
  agentId: AGENT_ID,
563
+ source: "custom",
550
564
  name: "shipwright@shipwright",
551
565
  version: "1.0.0",
552
566
  enabled: true,
@@ -4696,6 +4710,7 @@ describe("admin API — cron runs", () => {
4696
4710
  {
4697
4711
  id: CRON_ID,
4698
4712
  agentId: AGENT_ID,
4713
+ source: "custom",
4699
4714
  schedule: "0 9 * * 1-5",
4700
4715
  prompt: "daily standup",
4701
4716
  channel: "C123",
@@ -4717,6 +4732,7 @@ describe("admin API — cron runs", () => {
4717
4732
  {
4718
4733
  id: "cron-child-1",
4719
4734
  agentId: AGENT_ID,
4735
+ source: "custom",
4720
4736
  schedule: "0 9 * * 1-5",
4721
4737
  prompt: "phase-only child cron",
4722
4738
  channel: null,
@@ -5005,6 +5021,7 @@ function makeMockDepsWithRunSummary(): AdminDeps {
5005
5021
  {
5006
5022
  id: CRON_ID,
5007
5023
  agentId: AGENT_ID,
5024
+ source: "custom",
5008
5025
  schedule: "0 9 * * 1-5",
5009
5026
  prompt: "daily standup",
5010
5027
  channel: "C123",
@@ -23,6 +23,7 @@ import { createAgentRuntimeApp } from "./api.ts";
23
23
  interface MockPlugin {
24
24
  id: string;
25
25
  agentId: string;
26
+ source: string;
26
27
  name: string;
27
28
  version: string | null;
28
29
  enabled: boolean;
@@ -189,6 +190,7 @@ function makePlugin(agentId: string, name: string): MockPlugin {
189
190
  return {
190
191
  id: `plugin-${name}`,
191
192
  agentId,
193
+ source: "custom",
192
194
  name,
193
195
  version: null,
194
196
  enabled: true,
@@ -201,6 +203,7 @@ function makeCron(agentId: string, id: string): AgentCronJob {
201
203
  return {
202
204
  id,
203
205
  agentId,
206
+ source: "custom",
204
207
  schedule: "0 9 * * *",
205
208
  prompt: "Good morning",
206
209
  channel: "C123",
@@ -889,6 +892,7 @@ function buildCombinedApp() {
889
892
  create: async () => ({
890
893
  id: "c1",
891
894
  agentId: COMBINED_AGENT_ID,
895
+ source: "custom",
892
896
  schedule: "",
893
897
  prompt: "",
894
898
  channel: null,
@@ -908,6 +912,7 @@ function buildCombinedApp() {
908
912
  update: async () => ({
909
913
  id: "c1",
910
914
  agentId: COMBINED_AGENT_ID,
915
+ source: "custom",
911
916
  schedule: "",
912
917
  prompt: "",
913
918
  channel: null,
@@ -928,6 +933,7 @@ function buildCombinedApp() {
928
933
  setEnabled: async (_agentId, _cronId, enabled) => ({
929
934
  id: "c1",
930
935
  agentId: COMBINED_AGENT_ID,
936
+ source: "custom",
931
937
  schedule: "",
932
938
  prompt: "",
933
939
  channel: null,
@@ -947,6 +953,7 @@ function buildCombinedApp() {
947
953
  updatePreCheck: async (_agentId, _cronId, preCheck) => ({
948
954
  id: "c1",
949
955
  agentId: COMBINED_AGENT_ID,
956
+ source: "custom",
950
957
  schedule: "",
951
958
  prompt: "",
952
959
  channel: null,
@@ -971,6 +978,7 @@ function buildCombinedApp() {
971
978
  get: async () => ({
972
979
  id: "c1",
973
980
  agentId: COMBINED_AGENT_ID,
981
+ source: "custom",
974
982
  schedule: "",
975
983
  prompt: "",
976
984
  channel: null,
@@ -1072,6 +1080,8 @@ function buildCombinedApp() {
1072
1080
  add: async () => ({
1073
1081
  id: "t1",
1074
1082
  agentId: COMBINED_AGENT_ID,
1083
+ source: "custom",
1084
+ updatedAt: new Date(),
1075
1085
  pattern: "Read",
1076
1086
  enabled: true,
1077
1087
  createdAt: new Date(),
@@ -1080,6 +1090,8 @@ function buildCombinedApp() {
1080
1090
  toggle: async () => ({
1081
1091
  id: "t1",
1082
1092
  agentId: COMBINED_AGENT_ID,
1093
+ source: "custom",
1094
+ updatedAt: new Date(),
1083
1095
  pattern: "Read",
1084
1096
  enabled: false,
1085
1097
  createdAt: new Date(),
@@ -1113,6 +1125,7 @@ function buildCombinedApp() {
1113
1125
  add: async () => ({
1114
1126
  id: "p1",
1115
1127
  agentId: COMBINED_AGENT_ID,
1128
+ source: "custom",
1116
1129
  name: "plugin",
1117
1130
  version: null,
1118
1131
  enabled: true,
@@ -178,6 +178,7 @@ function makeGoogleClient(): GoogleAuthClient {
178
178
  const MOCK_CRON = {
179
179
  id: "cron-1",
180
180
  agentId: AGENT_ID,
181
+ source: "custom",
181
182
  schedule: "0 * * * *",
182
183
  prompt: "check",
183
184
  channel: null,
@@ -198,6 +199,7 @@ const MOCK_CRON = {
198
199
  const MOCK_TOOL = {
199
200
  id: "tool-1",
200
201
  agentId: AGENT_ID,
202
+ source: "custom",
201
203
  pattern: "Bash(git:*)",
202
204
  enabled: true,
203
205
  createdAt: new Date("2024-01-01"),