@app-vitals/agent-admin 1.67.0 → 1.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.68.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@anthropic-ai/sdk": "0.137.0",
|
|
45
|
-
"@app-vitals/agent-lib": "1.
|
|
45
|
+
"@app-vitals/agent-lib": "1.68.0",
|
|
46
46
|
"@hono/zod-openapi": "^1.0.0",
|
|
47
47
|
"@prisma/adapter-pg": "^7.10.0",
|
|
48
48
|
"@prisma/client": "^7.10.0",
|
|
@@ -419,3 +419,96 @@ describe("provisioning form (ATP-2.4)", () => {
|
|
|
419
419
|
expect(patched.some((e) => e.EXTRA === "two words")).toBe(true);
|
|
420
420
|
});
|
|
421
421
|
});
|
|
422
|
+
|
|
423
|
+
describe("agent Marketplaces card (TMK-3.1)", () => {
|
|
424
|
+
const row = (over: Record<string, unknown>) => ({
|
|
425
|
+
id: "m-x",
|
|
426
|
+
agentId: AGENT_ID,
|
|
427
|
+
name: "x",
|
|
428
|
+
source: "acme/x",
|
|
429
|
+
ref: null,
|
|
430
|
+
rowSource: "custom",
|
|
431
|
+
enabled: true,
|
|
432
|
+
createdAt: d,
|
|
433
|
+
updatedAt: d,
|
|
434
|
+
...over,
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
function marketplaceApp() {
|
|
438
|
+
const deps = detailDeps({ agentsApi: fakeAgentsApi().api });
|
|
439
|
+
const agentDetail = deps.agentService.getDetail;
|
|
440
|
+
return createAdminUIApp({
|
|
441
|
+
...deps,
|
|
442
|
+
agentService: {
|
|
443
|
+
...deps.agentService,
|
|
444
|
+
getDetail: async (id: string) => ({
|
|
445
|
+
...(await agentDetail(id)),
|
|
446
|
+
bakedMarketplaces: ["baked-mp"],
|
|
447
|
+
}),
|
|
448
|
+
},
|
|
449
|
+
agentMarketplaceService: {
|
|
450
|
+
list: async () => [
|
|
451
|
+
row({ id: "m-tpl", name: "tpl-mp", rowSource: "template" }),
|
|
452
|
+
row({ id: "m-own", name: "own-mp", rowSource: "custom" }),
|
|
453
|
+
row({
|
|
454
|
+
id: "m-dead",
|
|
455
|
+
name: "dead-mp",
|
|
456
|
+
rowSource: "template",
|
|
457
|
+
enabled: false,
|
|
458
|
+
}),
|
|
459
|
+
],
|
|
460
|
+
upsert: async () => row({}),
|
|
461
|
+
remove: async () => undefined,
|
|
462
|
+
},
|
|
463
|
+
} as never);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
async function card(): Promise<string> {
|
|
467
|
+
const html = await (
|
|
468
|
+
await get(marketplaceApp(), `/admin/agents/${AGENT_ID}/extensions`)
|
|
469
|
+
).text();
|
|
470
|
+
const start = html.indexOf('id="marketplaces-table"');
|
|
471
|
+
return html.slice(start, html.indexOf("</table>", start));
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const rowHtml = (html: string, name: string) =>
|
|
475
|
+
html
|
|
476
|
+
.slice(html.lastIndexOf("<tr", html.indexOf(`>${name}`)))
|
|
477
|
+
.split("</tr>")[0] ?? "";
|
|
478
|
+
|
|
479
|
+
it("badges template and custom rows", async () => {
|
|
480
|
+
const html = await card();
|
|
481
|
+
expect(rowHtml(html, "tpl-mp")).toContain('data-source="template"');
|
|
482
|
+
expect(rowHtml(html, "own-mp")).toContain('data-source="custom"');
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it("marks tombstoned rows disabled", async () => {
|
|
486
|
+
const html = await card();
|
|
487
|
+
const dead = rowHtml(html, "dead-mp");
|
|
488
|
+
expect(dead).toContain('data-disabled="true"');
|
|
489
|
+
expect(dead).toContain(">disabled</span>");
|
|
490
|
+
expect(dead).not.toContain("marketplaces/delete");
|
|
491
|
+
const live = rowHtml(html, "tpl-mp");
|
|
492
|
+
expect(live).not.toContain("data-disabled");
|
|
493
|
+
expect(live).toContain("marketplaces/delete");
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it("still renders baked rows as from image", async () => {
|
|
497
|
+
const html = await card();
|
|
498
|
+
expect(html).toContain('data-baked-marketplace="baked-mp"');
|
|
499
|
+
expect(html).toContain("from image");
|
|
500
|
+
expect(rowHtml(html, "baked-mp")).not.toContain("data-source=");
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
it("suggests template-sourced marketplace names for the plugin field, not tombstones", async () => {
|
|
504
|
+
const html = await (
|
|
505
|
+
await get(marketplaceApp(), `/admin/agents/${AGENT_ID}/extensions`)
|
|
506
|
+
).text();
|
|
507
|
+
const list = html.slice(html.indexOf('id="plugin-marketplaces"'));
|
|
508
|
+
const datalist = list.slice(0, list.indexOf("</datalist>"));
|
|
509
|
+
expect(datalist).toContain('value="tpl-mp"');
|
|
510
|
+
expect(datalist).toContain('value="own-mp"');
|
|
511
|
+
expect(datalist).toContain('value="baked-mp"');
|
|
512
|
+
expect(datalist).not.toContain("dead-mp");
|
|
513
|
+
});
|
|
514
|
+
});
|
package/src/admin-ui-pages.ts
CHANGED
|
@@ -212,6 +212,10 @@ export interface MarketplaceItem {
|
|
|
212
212
|
name: string;
|
|
213
213
|
source: string;
|
|
214
214
|
ref: string | null;
|
|
215
|
+
/** TMK-3.1: `template` or `custom` (AgentMarketplace.rowSource). */
|
|
216
|
+
rowSource?: string;
|
|
217
|
+
/** TMK-3.1: false = tombstone of a deleted template row. */
|
|
218
|
+
enabled?: boolean;
|
|
215
219
|
createdAt: Date;
|
|
216
220
|
}
|
|
217
221
|
|
|
@@ -1544,20 +1548,28 @@ export function renderAgentDetailPage(
|
|
|
1544
1548
|
const marketplaces = opts?.marketplaces ?? [];
|
|
1545
1549
|
const bakedMarketplaces = agent.bakedMarketplaces ?? [];
|
|
1546
1550
|
const marketplaceRows = marketplaces
|
|
1547
|
-
.map(
|
|
1548
|
-
|
|
1549
|
-
|
|
1551
|
+
.map((m) => {
|
|
1552
|
+
const tombstone = m.enabled === false;
|
|
1553
|
+
return `<tr${tombstone ? ' data-disabled="true" style="opacity:.6"' : ""}>
|
|
1554
|
+
<td class="mono">${escapeHtml(m.name)}${sourceBadge(m.rowSource)}</td>
|
|
1550
1555
|
<td class="mono">${escapeHtml(m.source)}</td>
|
|
1551
1556
|
<td class="mono">${m.ref ? escapeHtml(m.ref) : "default"}</td>
|
|
1552
|
-
<td
|
|
1553
|
-
|
|
1557
|
+
<td>${
|
|
1558
|
+
tombstone
|
|
1559
|
+
? `<span class="badge badge-gray" title="Removed from this agent; the template no longer re-adds it">disabled</span>`
|
|
1560
|
+
: `<span class="badge badge-green">remote</span>`
|
|
1561
|
+
}</td>
|
|
1562
|
+
<td>${
|
|
1563
|
+
tombstone
|
|
1564
|
+
? ""
|
|
1565
|
+
: `
|
|
1554
1566
|
<form method="POST" action="/admin/agents/${escapeHtml(agent.id)}/marketplaces/delete" style="display:inline">
|
|
1555
1567
|
<input type="hidden" name="marketplaceId" value="${escapeHtml(m.id)}" />
|
|
1556
1568
|
<button type="submit" class="btn btn-danger" style="font-size:11px;padding:3px 8px">Remove</button>
|
|
1557
|
-
</form
|
|
1558
|
-
</td>
|
|
1559
|
-
</tr
|
|
1560
|
-
)
|
|
1569
|
+
</form>`
|
|
1570
|
+
}</td>
|
|
1571
|
+
</tr>`;
|
|
1572
|
+
})
|
|
1561
1573
|
.join("\n");
|
|
1562
1574
|
const bakedMarketplaceRows = bakedMarketplaces
|
|
1563
1575
|
.map(
|
|
@@ -2009,7 +2021,10 @@ export function renderAgentDetailPage(
|
|
|
2009
2021
|
</div>`;
|
|
2010
2022
|
|
|
2011
2023
|
const pluginMarketplaceNames = [
|
|
2012
|
-
...new Set([
|
|
2024
|
+
...new Set([
|
|
2025
|
+
...marketplaces.filter((m) => m.enabled !== false).map((m) => m.name),
|
|
2026
|
+
...bakedMarketplaces,
|
|
2027
|
+
]),
|
|
2013
2028
|
];
|
|
2014
2029
|
const pluginsSection = `<div class="card">
|
|
2015
2030
|
<div class="card-title">Plugins</div>
|
|
@@ -83,3 +83,33 @@ describe("renderTemplatesPage settings shell (SGL-2.2)", () => {
|
|
|
83
83
|
);
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
|
+
|
|
87
|
+
describe("renderTemplatesPage marketplace kind (TMK-3.1)", () => {
|
|
88
|
+
const html = renderTemplatesPage({
|
|
89
|
+
...base,
|
|
90
|
+
templateExists: true,
|
|
91
|
+
items: [
|
|
92
|
+
{
|
|
93
|
+
kind: "marketplace",
|
|
94
|
+
key: "acme-plugins",
|
|
95
|
+
payload: { source: "acme/<plugins>", ref: "v1" },
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("renders a Marketplaces card with an add form for name, source and ref", () => {
|
|
101
|
+
expect(html).toContain('id="template-marketplace"');
|
|
102
|
+
expect(html).toContain("Add marketplace");
|
|
103
|
+
expect(html).toContain('name="source"');
|
|
104
|
+
expect(html).toContain('name="ref"');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("lists an existing item with escaped values and a remove button", () => {
|
|
108
|
+
expect(html).toContain('data-kind="marketplace" data-key="acme-plugins"');
|
|
109
|
+
expect(html).toContain('value="acme/<plugins>"');
|
|
110
|
+
expect(html).toContain('value="v1"');
|
|
111
|
+
expect(html).toContain(
|
|
112
|
+
'formaction="/admin/settings/templates/items/delete"',
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -328,3 +328,84 @@ describe("/admin/settings/templates smoke", () => {
|
|
|
328
328
|
).toBe(403);
|
|
329
329
|
});
|
|
330
330
|
});
|
|
331
|
+
|
|
332
|
+
describe("/admin/settings/templates marketplace items (TMK-3.1)", () => {
|
|
333
|
+
const scope = { accountId: "", specialty: "" };
|
|
334
|
+
|
|
335
|
+
it("creates a marketplace item with name, source and ref and lists it", async () => {
|
|
336
|
+
const { app, rows } = setup();
|
|
337
|
+
const res = await app.request(
|
|
338
|
+
`${BASE}/items`,
|
|
339
|
+
form({
|
|
340
|
+
...scope,
|
|
341
|
+
kind: "marketplace",
|
|
342
|
+
key: "acme-plugins",
|
|
343
|
+
source: "acme/plugins",
|
|
344
|
+
ref: "v1",
|
|
345
|
+
}),
|
|
346
|
+
);
|
|
347
|
+
expect(res.status).toBe(302);
|
|
348
|
+
expect(rows[0]?.items[0]).toMatchObject({
|
|
349
|
+
kind: "marketplace",
|
|
350
|
+
key: "acme-plugins",
|
|
351
|
+
payload: { source: "acme/plugins", ref: "v1" },
|
|
352
|
+
});
|
|
353
|
+
const html = await (await app.request(BASE)).text();
|
|
354
|
+
expect(html).toContain('data-kind="marketplace" data-key="acme-plugins"');
|
|
355
|
+
expect(html).toContain('value="acme/plugins"');
|
|
356
|
+
expect(html).toContain('value="v1"');
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it("stores an empty ref as null", async () => {
|
|
360
|
+
const { app, rows } = setup();
|
|
361
|
+
await app.request(
|
|
362
|
+
`${BASE}/items`,
|
|
363
|
+
form({
|
|
364
|
+
...scope,
|
|
365
|
+
kind: "marketplace",
|
|
366
|
+
key: "m",
|
|
367
|
+
source: "acme/plugins",
|
|
368
|
+
ref: "",
|
|
369
|
+
}),
|
|
370
|
+
);
|
|
371
|
+
expect(rows[0]?.items[0]?.payload).toMatchObject({ ref: null });
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it("shows an invalid source as an inline 422 and creates nothing", async () => {
|
|
375
|
+
const { app, rows } = setup();
|
|
376
|
+
const res = await app.request(
|
|
377
|
+
`${BASE}/items`,
|
|
378
|
+
form({
|
|
379
|
+
...scope,
|
|
380
|
+
kind: "marketplace",
|
|
381
|
+
key: "m",
|
|
382
|
+
source: "/etc/passwd",
|
|
383
|
+
ref: "",
|
|
384
|
+
}),
|
|
385
|
+
);
|
|
386
|
+
expect(res.status).toBe(422);
|
|
387
|
+
const html = await res.text();
|
|
388
|
+
expect(html).toContain("alert-error");
|
|
389
|
+
expect(html).toContain("source must be a GitHub");
|
|
390
|
+
expect(rows).toHaveLength(0);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it("removes a marketplace item", async () => {
|
|
394
|
+
const { app, rows } = setup();
|
|
395
|
+
await app.request(
|
|
396
|
+
`${BASE}/items`,
|
|
397
|
+
form({
|
|
398
|
+
...scope,
|
|
399
|
+
kind: "marketplace",
|
|
400
|
+
key: "m",
|
|
401
|
+
source: "acme/plugins",
|
|
402
|
+
}),
|
|
403
|
+
);
|
|
404
|
+
const res = await app.request(
|
|
405
|
+
`${BASE}/items/delete`,
|
|
406
|
+
form({ ...scope, kind: "marketplace", key: "m" }),
|
|
407
|
+
);
|
|
408
|
+
expect(res.status).toBe(302);
|
|
409
|
+
expect(rows[0]?.items).toHaveLength(0);
|
|
410
|
+
});
|
|
411
|
+
});
|