@app-vitals/agent-admin 1.115.1 → 1.116.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/openapi.platform.json +22 -0
- package/package.json +2 -2
- package/prisma/client/internal/class.ts +3 -3
- package/prisma/client/internal/prismaNamespace.ts +1 -0
- package/prisma/client/internal/prismaNamespaceBrowser.ts +1 -0
- package/prisma/client/models/AgentToken.ts +36 -1
- package/prisma/migrations/20261202000000_add_agent_token_kind/migration.sql +4 -0
- package/prisma/schema/schema.prisma +5 -0
- package/src/admin-local-agent.smoke.test.ts +1 -0
- package/src/admin-ui-pages.ts +8 -1
- package/src/admin-ui-pages.unit.test.ts +10 -0
- package/src/admin-ui.fixtures.ts +1 -0
- package/src/agent-cron-run-stats.smoke.test.ts +6 -4
- package/src/agent-env-classification.unit.test.ts +149 -0
- package/src/agent-tokens.integration.test.ts +23 -0
- package/src/agent-tokens.ts +39 -5
- package/src/agent-tokens.unit.test.ts +127 -0
- package/src/agents-api.sentry.smoke.test.ts +3 -1
- package/src/agents-api.smoke.test.ts +111 -10
- package/src/agents-api.ts +4 -1
- package/src/api-auth.ts +11 -2
- package/src/api-auth.unit.test.ts +82 -12
- package/src/api.smoke.test.ts +2 -0
- package/src/chat.smoke.test.ts +1 -0
- package/src/openapi-schemas.ts +11 -0
- package/src/openapi-schemas.unit.test.ts +1 -0
|
@@ -29,6 +29,7 @@ export type AgentTokenMinAggregateOutputType = {
|
|
|
29
29
|
agentId: string | null
|
|
30
30
|
token: string | null
|
|
31
31
|
label: string | null
|
|
32
|
+
kind: string | null
|
|
32
33
|
createdAt: Date | null
|
|
33
34
|
revokedAt: Date | null
|
|
34
35
|
}
|
|
@@ -38,6 +39,7 @@ export type AgentTokenMaxAggregateOutputType = {
|
|
|
38
39
|
agentId: string | null
|
|
39
40
|
token: string | null
|
|
40
41
|
label: string | null
|
|
42
|
+
kind: string | null
|
|
41
43
|
createdAt: Date | null
|
|
42
44
|
revokedAt: Date | null
|
|
43
45
|
}
|
|
@@ -47,6 +49,7 @@ export type AgentTokenCountAggregateOutputType = {
|
|
|
47
49
|
agentId: number
|
|
48
50
|
token: number
|
|
49
51
|
label: number
|
|
52
|
+
kind: number
|
|
50
53
|
createdAt: number
|
|
51
54
|
revokedAt: number
|
|
52
55
|
_all: number
|
|
@@ -58,6 +61,7 @@ export type AgentTokenMinAggregateInputType = {
|
|
|
58
61
|
agentId?: true
|
|
59
62
|
token?: true
|
|
60
63
|
label?: true
|
|
64
|
+
kind?: true
|
|
61
65
|
createdAt?: true
|
|
62
66
|
revokedAt?: true
|
|
63
67
|
}
|
|
@@ -67,6 +71,7 @@ export type AgentTokenMaxAggregateInputType = {
|
|
|
67
71
|
agentId?: true
|
|
68
72
|
token?: true
|
|
69
73
|
label?: true
|
|
74
|
+
kind?: true
|
|
70
75
|
createdAt?: true
|
|
71
76
|
revokedAt?: true
|
|
72
77
|
}
|
|
@@ -76,6 +81,7 @@ export type AgentTokenCountAggregateInputType = {
|
|
|
76
81
|
agentId?: true
|
|
77
82
|
token?: true
|
|
78
83
|
label?: true
|
|
84
|
+
kind?: true
|
|
79
85
|
createdAt?: true
|
|
80
86
|
revokedAt?: true
|
|
81
87
|
_all?: true
|
|
@@ -158,6 +164,7 @@ export type AgentTokenGroupByOutputType = {
|
|
|
158
164
|
agentId: string
|
|
159
165
|
token: string
|
|
160
166
|
label: string | null
|
|
167
|
+
kind: string
|
|
161
168
|
createdAt: Date
|
|
162
169
|
revokedAt: Date | null
|
|
163
170
|
_count: AgentTokenCountAggregateOutputType | null
|
|
@@ -188,6 +195,7 @@ export type AgentTokenWhereInput = {
|
|
|
188
195
|
agentId?: Prisma.StringFilter<"AgentToken"> | string
|
|
189
196
|
token?: Prisma.StringFilter<"AgentToken"> | string
|
|
190
197
|
label?: Prisma.StringNullableFilter<"AgentToken"> | string | null
|
|
198
|
+
kind?: Prisma.StringFilter<"AgentToken"> | string
|
|
191
199
|
createdAt?: Prisma.DateTimeFilter<"AgentToken"> | Date | string
|
|
192
200
|
revokedAt?: Prisma.DateTimeNullableFilter<"AgentToken"> | Date | string | null
|
|
193
201
|
agent?: Prisma.XOR<Prisma.AgentScalarRelationFilter, Prisma.AgentWhereInput>
|
|
@@ -198,6 +206,7 @@ export type AgentTokenOrderByWithRelationInput = {
|
|
|
198
206
|
agentId?: Prisma.SortOrder
|
|
199
207
|
token?: Prisma.SortOrder
|
|
200
208
|
label?: Prisma.SortOrderInput | Prisma.SortOrder
|
|
209
|
+
kind?: Prisma.SortOrder
|
|
201
210
|
createdAt?: Prisma.SortOrder
|
|
202
211
|
revokedAt?: Prisma.SortOrderInput | Prisma.SortOrder
|
|
203
212
|
agent?: Prisma.AgentOrderByWithRelationInput
|
|
@@ -211,6 +220,7 @@ export type AgentTokenWhereUniqueInput = Prisma.AtLeast<{
|
|
|
211
220
|
NOT?: Prisma.AgentTokenWhereInput | Prisma.AgentTokenWhereInput[]
|
|
212
221
|
agentId?: Prisma.StringFilter<"AgentToken"> | string
|
|
213
222
|
label?: Prisma.StringNullableFilter<"AgentToken"> | string | null
|
|
223
|
+
kind?: Prisma.StringFilter<"AgentToken"> | string
|
|
214
224
|
createdAt?: Prisma.DateTimeFilter<"AgentToken"> | Date | string
|
|
215
225
|
revokedAt?: Prisma.DateTimeNullableFilter<"AgentToken"> | Date | string | null
|
|
216
226
|
agent?: Prisma.XOR<Prisma.AgentScalarRelationFilter, Prisma.AgentWhereInput>
|
|
@@ -221,6 +231,7 @@ export type AgentTokenOrderByWithAggregationInput = {
|
|
|
221
231
|
agentId?: Prisma.SortOrder
|
|
222
232
|
token?: Prisma.SortOrder
|
|
223
233
|
label?: Prisma.SortOrderInput | Prisma.SortOrder
|
|
234
|
+
kind?: Prisma.SortOrder
|
|
224
235
|
createdAt?: Prisma.SortOrder
|
|
225
236
|
revokedAt?: Prisma.SortOrderInput | Prisma.SortOrder
|
|
226
237
|
_count?: Prisma.AgentTokenCountOrderByAggregateInput
|
|
@@ -236,6 +247,7 @@ export type AgentTokenScalarWhereWithAggregatesInput = {
|
|
|
236
247
|
agentId?: Prisma.StringWithAggregatesFilter<"AgentToken"> | string
|
|
237
248
|
token?: Prisma.StringWithAggregatesFilter<"AgentToken"> | string
|
|
238
249
|
label?: Prisma.StringNullableWithAggregatesFilter<"AgentToken"> | string | null
|
|
250
|
+
kind?: Prisma.StringWithAggregatesFilter<"AgentToken"> | string
|
|
239
251
|
createdAt?: Prisma.DateTimeWithAggregatesFilter<"AgentToken"> | Date | string
|
|
240
252
|
revokedAt?: Prisma.DateTimeNullableWithAggregatesFilter<"AgentToken"> | Date | string | null
|
|
241
253
|
}
|
|
@@ -244,6 +256,7 @@ export type AgentTokenCreateInput = {
|
|
|
244
256
|
id?: string
|
|
245
257
|
token: string
|
|
246
258
|
label?: string | null
|
|
259
|
+
kind?: string
|
|
247
260
|
createdAt?: Date | string
|
|
248
261
|
revokedAt?: Date | string | null
|
|
249
262
|
agent: Prisma.AgentCreateNestedOneWithoutTokensInput
|
|
@@ -254,6 +267,7 @@ export type AgentTokenUncheckedCreateInput = {
|
|
|
254
267
|
agentId: string
|
|
255
268
|
token: string
|
|
256
269
|
label?: string | null
|
|
270
|
+
kind?: string
|
|
257
271
|
createdAt?: Date | string
|
|
258
272
|
revokedAt?: Date | string | null
|
|
259
273
|
}
|
|
@@ -262,6 +276,7 @@ export type AgentTokenUpdateInput = {
|
|
|
262
276
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
263
277
|
token?: Prisma.StringFieldUpdateOperationsInput | string
|
|
264
278
|
label?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
279
|
+
kind?: Prisma.StringFieldUpdateOperationsInput | string
|
|
265
280
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
266
281
|
revokedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
267
282
|
agent?: Prisma.AgentUpdateOneRequiredWithoutTokensNestedInput
|
|
@@ -272,6 +287,7 @@ export type AgentTokenUncheckedUpdateInput = {
|
|
|
272
287
|
agentId?: Prisma.StringFieldUpdateOperationsInput | string
|
|
273
288
|
token?: Prisma.StringFieldUpdateOperationsInput | string
|
|
274
289
|
label?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
290
|
+
kind?: Prisma.StringFieldUpdateOperationsInput | string
|
|
275
291
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
276
292
|
revokedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
277
293
|
}
|
|
@@ -281,6 +297,7 @@ export type AgentTokenCreateManyInput = {
|
|
|
281
297
|
agentId: string
|
|
282
298
|
token: string
|
|
283
299
|
label?: string | null
|
|
300
|
+
kind?: string
|
|
284
301
|
createdAt?: Date | string
|
|
285
302
|
revokedAt?: Date | string | null
|
|
286
303
|
}
|
|
@@ -289,6 +306,7 @@ export type AgentTokenUpdateManyMutationInput = {
|
|
|
289
306
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
290
307
|
token?: Prisma.StringFieldUpdateOperationsInput | string
|
|
291
308
|
label?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
309
|
+
kind?: Prisma.StringFieldUpdateOperationsInput | string
|
|
292
310
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
293
311
|
revokedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
294
312
|
}
|
|
@@ -298,6 +316,7 @@ export type AgentTokenUncheckedUpdateManyInput = {
|
|
|
298
316
|
agentId?: Prisma.StringFieldUpdateOperationsInput | string
|
|
299
317
|
token?: Prisma.StringFieldUpdateOperationsInput | string
|
|
300
318
|
label?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
319
|
+
kind?: Prisma.StringFieldUpdateOperationsInput | string
|
|
301
320
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
302
321
|
revokedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
303
322
|
}
|
|
@@ -317,6 +336,7 @@ export type AgentTokenCountOrderByAggregateInput = {
|
|
|
317
336
|
agentId?: Prisma.SortOrder
|
|
318
337
|
token?: Prisma.SortOrder
|
|
319
338
|
label?: Prisma.SortOrder
|
|
339
|
+
kind?: Prisma.SortOrder
|
|
320
340
|
createdAt?: Prisma.SortOrder
|
|
321
341
|
revokedAt?: Prisma.SortOrder
|
|
322
342
|
}
|
|
@@ -326,6 +346,7 @@ export type AgentTokenMaxOrderByAggregateInput = {
|
|
|
326
346
|
agentId?: Prisma.SortOrder
|
|
327
347
|
token?: Prisma.SortOrder
|
|
328
348
|
label?: Prisma.SortOrder
|
|
349
|
+
kind?: Prisma.SortOrder
|
|
329
350
|
createdAt?: Prisma.SortOrder
|
|
330
351
|
revokedAt?: Prisma.SortOrder
|
|
331
352
|
}
|
|
@@ -335,6 +356,7 @@ export type AgentTokenMinOrderByAggregateInput = {
|
|
|
335
356
|
agentId?: Prisma.SortOrder
|
|
336
357
|
token?: Prisma.SortOrder
|
|
337
358
|
label?: Prisma.SortOrder
|
|
359
|
+
kind?: Prisma.SortOrder
|
|
338
360
|
createdAt?: Prisma.SortOrder
|
|
339
361
|
revokedAt?: Prisma.SortOrder
|
|
340
362
|
}
|
|
@@ -385,6 +407,7 @@ export type AgentTokenCreateWithoutAgentInput = {
|
|
|
385
407
|
id?: string
|
|
386
408
|
token: string
|
|
387
409
|
label?: string | null
|
|
410
|
+
kind?: string
|
|
388
411
|
createdAt?: Date | string
|
|
389
412
|
revokedAt?: Date | string | null
|
|
390
413
|
}
|
|
@@ -393,6 +416,7 @@ export type AgentTokenUncheckedCreateWithoutAgentInput = {
|
|
|
393
416
|
id?: string
|
|
394
417
|
token: string
|
|
395
418
|
label?: string | null
|
|
419
|
+
kind?: string
|
|
396
420
|
createdAt?: Date | string
|
|
397
421
|
revokedAt?: Date | string | null
|
|
398
422
|
}
|
|
@@ -431,6 +455,7 @@ export type AgentTokenScalarWhereInput = {
|
|
|
431
455
|
agentId?: Prisma.StringFilter<"AgentToken"> | string
|
|
432
456
|
token?: Prisma.StringFilter<"AgentToken"> | string
|
|
433
457
|
label?: Prisma.StringNullableFilter<"AgentToken"> | string | null
|
|
458
|
+
kind?: Prisma.StringFilter<"AgentToken"> | string
|
|
434
459
|
createdAt?: Prisma.DateTimeFilter<"AgentToken"> | Date | string
|
|
435
460
|
revokedAt?: Prisma.DateTimeNullableFilter<"AgentToken"> | Date | string | null
|
|
436
461
|
}
|
|
@@ -439,6 +464,7 @@ export type AgentTokenCreateManyAgentInput = {
|
|
|
439
464
|
id?: string
|
|
440
465
|
token: string
|
|
441
466
|
label?: string | null
|
|
467
|
+
kind?: string
|
|
442
468
|
createdAt?: Date | string
|
|
443
469
|
revokedAt?: Date | string | null
|
|
444
470
|
}
|
|
@@ -447,6 +473,7 @@ export type AgentTokenUpdateWithoutAgentInput = {
|
|
|
447
473
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
448
474
|
token?: Prisma.StringFieldUpdateOperationsInput | string
|
|
449
475
|
label?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
476
|
+
kind?: Prisma.StringFieldUpdateOperationsInput | string
|
|
450
477
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
451
478
|
revokedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
452
479
|
}
|
|
@@ -455,6 +482,7 @@ export type AgentTokenUncheckedUpdateWithoutAgentInput = {
|
|
|
455
482
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
456
483
|
token?: Prisma.StringFieldUpdateOperationsInput | string
|
|
457
484
|
label?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
485
|
+
kind?: Prisma.StringFieldUpdateOperationsInput | string
|
|
458
486
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
459
487
|
revokedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
460
488
|
}
|
|
@@ -463,6 +491,7 @@ export type AgentTokenUncheckedUpdateManyWithoutAgentInput = {
|
|
|
463
491
|
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
464
492
|
token?: Prisma.StringFieldUpdateOperationsInput | string
|
|
465
493
|
label?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
494
|
+
kind?: Prisma.StringFieldUpdateOperationsInput | string
|
|
466
495
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
467
496
|
revokedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
468
497
|
}
|
|
@@ -474,6 +503,7 @@ export type AgentTokenSelect<ExtArgs extends runtime.Types.Extensions.InternalAr
|
|
|
474
503
|
agentId?: boolean
|
|
475
504
|
token?: boolean
|
|
476
505
|
label?: boolean
|
|
506
|
+
kind?: boolean
|
|
477
507
|
createdAt?: boolean
|
|
478
508
|
revokedAt?: boolean
|
|
479
509
|
agent?: boolean | Prisma.AgentDefaultArgs<ExtArgs>
|
|
@@ -484,6 +514,7 @@ export type AgentTokenSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Ex
|
|
|
484
514
|
agentId?: boolean
|
|
485
515
|
token?: boolean
|
|
486
516
|
label?: boolean
|
|
517
|
+
kind?: boolean
|
|
487
518
|
createdAt?: boolean
|
|
488
519
|
revokedAt?: boolean
|
|
489
520
|
agent?: boolean | Prisma.AgentDefaultArgs<ExtArgs>
|
|
@@ -494,6 +525,7 @@ export type AgentTokenSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Ex
|
|
|
494
525
|
agentId?: boolean
|
|
495
526
|
token?: boolean
|
|
496
527
|
label?: boolean
|
|
528
|
+
kind?: boolean
|
|
497
529
|
createdAt?: boolean
|
|
498
530
|
revokedAt?: boolean
|
|
499
531
|
agent?: boolean | Prisma.AgentDefaultArgs<ExtArgs>
|
|
@@ -504,11 +536,12 @@ export type AgentTokenSelectScalar = {
|
|
|
504
536
|
agentId?: boolean
|
|
505
537
|
token?: boolean
|
|
506
538
|
label?: boolean
|
|
539
|
+
kind?: boolean
|
|
507
540
|
createdAt?: boolean
|
|
508
541
|
revokedAt?: boolean
|
|
509
542
|
}
|
|
510
543
|
|
|
511
|
-
export type AgentTokenOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "agentId" | "token" | "label" | "createdAt" | "revokedAt", ExtArgs["result"]["agentToken"]>
|
|
544
|
+
export type AgentTokenOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "agentId" | "token" | "label" | "kind" | "createdAt" | "revokedAt", ExtArgs["result"]["agentToken"]>
|
|
512
545
|
export type AgentTokenInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
|
513
546
|
agent?: boolean | Prisma.AgentDefaultArgs<ExtArgs>
|
|
514
547
|
}
|
|
@@ -529,6 +562,7 @@ export type $AgentTokenPayload<ExtArgs extends runtime.Types.Extensions.Internal
|
|
|
529
562
|
agentId: string
|
|
530
563
|
token: string
|
|
531
564
|
label: string | null
|
|
565
|
+
kind: string
|
|
532
566
|
createdAt: Date
|
|
533
567
|
revokedAt: Date | null
|
|
534
568
|
}, ExtArgs["result"]["agentToken"]>
|
|
@@ -959,6 +993,7 @@ export interface AgentTokenFieldRefs {
|
|
|
959
993
|
readonly agentId: Prisma.FieldRef<"AgentToken", 'String'>
|
|
960
994
|
readonly token: Prisma.FieldRef<"AgentToken", 'String'>
|
|
961
995
|
readonly label: Prisma.FieldRef<"AgentToken", 'String'>
|
|
996
|
+
readonly kind: Prisma.FieldRef<"AgentToken", 'String'>
|
|
962
997
|
readonly createdAt: Prisma.FieldRef<"AgentToken", 'DateTime'>
|
|
963
998
|
readonly revokedAt: Prisma.FieldRef<"AgentToken", 'DateTime'>
|
|
964
999
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- AlterTable: every existing row takes the default, so existing tokens are runtime.
|
|
2
|
+
-- TEXT + CHECK rather than a native enum: consumers' additive-migration guards
|
|
3
|
+
-- accept only CREATE TABLE/INDEX and ADD COLUMN, not CREATE TYPE.
|
|
4
|
+
ALTER TABLE "AgentToken" ADD COLUMN "kind" TEXT NOT NULL DEFAULT 'runtime' CONSTRAINT "AgentToken_kind_check" CHECK ("kind" IN ('runtime', 'tools'));
|
|
@@ -234,6 +234,11 @@ model AgentToken {
|
|
|
234
234
|
agent Agent @relation(fields: [agentId], references: [id], onDelete: Cascade)
|
|
235
235
|
token String @unique // SHA-256 hash of the raw token (hex)
|
|
236
236
|
label String?
|
|
237
|
+
// What the token is for: "runtime" (the agent process) or "tools" (the
|
|
238
|
+
// model's own process). Existing rows are "runtime". A TEXT column with a
|
|
239
|
+
// DB CHECK constraint (not a native enum) so the migration stays additive;
|
|
240
|
+
// values are validated in code by AgentTokenService (agent-tokens.ts).
|
|
241
|
+
kind String @default("runtime")
|
|
237
242
|
createdAt DateTime @default(now())
|
|
238
243
|
revokedAt DateTime?
|
|
239
244
|
}
|
package/src/admin-ui-pages.ts
CHANGED
|
@@ -196,6 +196,11 @@ export interface ToolItem {
|
|
|
196
196
|
export interface TokenItem {
|
|
197
197
|
id: string;
|
|
198
198
|
label: string | null;
|
|
199
|
+
/**
|
|
200
|
+
* Stored token kind ("runtime" | "tools"; a TEXT column). Optional so older
|
|
201
|
+
* callers that omit it still compile; shown as runtime.
|
|
202
|
+
*/
|
|
203
|
+
kind?: string;
|
|
199
204
|
createdAt: Date;
|
|
200
205
|
revokedAt: Date | null;
|
|
201
206
|
}
|
|
@@ -1656,11 +1661,12 @@ export function renderAgentDetailPage(
|
|
|
1656
1661
|
|
|
1657
1662
|
const tokenRows =
|
|
1658
1663
|
tokens.length === 0
|
|
1659
|
-
? `<tr><td colspan="
|
|
1664
|
+
? `<tr><td colspan="5" class="empty-state">No tokens created.</td></tr>`
|
|
1660
1665
|
: tokens
|
|
1661
1666
|
.map(
|
|
1662
1667
|
(t) => `<tr>
|
|
1663
1668
|
<td>${t.label ? escapeHtml(t.label) : '<span style="color:var(--vos-text-faint)">—</span>'}</td>
|
|
1669
|
+
<td>${escapeHtml(t.kind ?? "runtime")}</td>
|
|
1664
1670
|
<td>${escapeHtml(new Date(t.createdAt).toLocaleDateString("en-US", { timeZone: timezone }))}</td>
|
|
1665
1671
|
<td>${t.revokedAt ? `<span class="badge badge-gray">Revoked ${escapeHtml(new Date(t.revokedAt).toLocaleDateString("en-US", { timeZone: timezone }))}</span>` : '<span class="badge badge-green">Active</span>'}</td>
|
|
1666
1672
|
<td>${
|
|
@@ -2166,6 +2172,7 @@ export function renderAgentDetailPage(
|
|
|
2166
2172
|
<thead>
|
|
2167
2173
|
<tr>
|
|
2168
2174
|
<th>Label</th>
|
|
2175
|
+
<th>Kind</th>
|
|
2169
2176
|
<th>Created</th>
|
|
2170
2177
|
<th>Status</th>
|
|
2171
2178
|
<th></th>
|
|
@@ -1908,6 +1908,16 @@ describe("renderAgentDetailPage — tokens", () => {
|
|
|
1908
1908
|
expect(html).toContain(">Active<");
|
|
1909
1909
|
});
|
|
1910
1910
|
|
|
1911
|
+
test("token list shows each token's kind (runtime when unset)", () => {
|
|
1912
|
+
const html = render([
|
|
1913
|
+
{ ...TOKEN_ACTIVE, kind: "tools" },
|
|
1914
|
+
{ ...TOKEN_REVOKED, kind: undefined },
|
|
1915
|
+
]);
|
|
1916
|
+
expect(html).toContain("<th>Kind</th>");
|
|
1917
|
+
expect(html).toContain("<td>tools</td>");
|
|
1918
|
+
expect(html).toContain("<td>runtime</td>");
|
|
1919
|
+
});
|
|
1920
|
+
|
|
1911
1921
|
test("active token: Revoke form present", () => {
|
|
1912
1922
|
const html = render([TOKEN_ACTIVE]);
|
|
1913
1923
|
expect(html).toContain(
|
package/src/admin-ui.fixtures.ts
CHANGED
|
@@ -397,6 +397,7 @@ function makeMockDeps(): AdminDeps {
|
|
|
397
397
|
id: "token-id",
|
|
398
398
|
agentId: AGENT_ID,
|
|
399
399
|
token: "sha256hash",
|
|
400
|
+
kind: "runtime" as const,
|
|
400
401
|
label: null,
|
|
401
402
|
createdAt: new Date(),
|
|
402
403
|
revokedAt: null,
|
|
@@ -409,6 +410,7 @@ function makeMockDeps(): AdminDeps {
|
|
|
409
410
|
id: "token-id",
|
|
410
411
|
agentId: AGENT_ID,
|
|
411
412
|
token: "sha256hash",
|
|
413
|
+
kind: "runtime" as const,
|
|
412
414
|
label: null,
|
|
413
415
|
createdAt: new Date(),
|
|
414
416
|
revokedAt: new Date(),
|
|
@@ -778,7 +780,7 @@ describe("admin API — GET /agents/all/cron-runs/stats", () => {
|
|
|
778
780
|
agentTokenService: {
|
|
779
781
|
...makeMockDeps().agentTokenService,
|
|
780
782
|
// Returns a per-agent token (not admin)
|
|
781
|
-
validate: async () => ({ agentId: AGENT_ID }),
|
|
783
|
+
validate: async () => ({ agentId: AGENT_ID, kind: "runtime" as const }),
|
|
782
784
|
},
|
|
783
785
|
};
|
|
784
786
|
const app = createAdminApp(deps);
|
|
@@ -803,7 +805,7 @@ describe("admin API — GET /agents/:id/cron-runs/stats", () => {
|
|
|
803
805
|
},
|
|
804
806
|
agentTokenService: {
|
|
805
807
|
...base.agentTokenService,
|
|
806
|
-
validate: async () => ({ agentId: AGENT_ID }),
|
|
808
|
+
validate: async () => ({ agentId: AGENT_ID, kind: "runtime" as const }),
|
|
807
809
|
},
|
|
808
810
|
};
|
|
809
811
|
}
|
|
@@ -859,7 +861,7 @@ describe("admin API — GET /agents/:id/cron-runs/outcomes", () => {
|
|
|
859
861
|
},
|
|
860
862
|
agentTokenService: {
|
|
861
863
|
...base.agentTokenService,
|
|
862
|
-
validate: async () => ({ agentId: AGENT_ID }),
|
|
864
|
+
validate: async () => ({ agentId: AGENT_ID, kind: "runtime" as const }),
|
|
863
865
|
},
|
|
864
866
|
};
|
|
865
867
|
}
|
|
@@ -962,7 +964,7 @@ describe("admin API — GET /agents/all/cron-runs/outcomes", () => {
|
|
|
962
964
|
...makeMockDeps(),
|
|
963
965
|
agentTokenService: {
|
|
964
966
|
...makeMockDeps().agentTokenService,
|
|
965
|
-
validate: async () => ({ agentId: AGENT_ID }),
|
|
967
|
+
validate: async () => ({ agentId: AGENT_ID, kind: "runtime" as const }),
|
|
966
968
|
},
|
|
967
969
|
};
|
|
968
970
|
const app = createAdminApp(deps);
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/agent-env-classification.unit.test.ts
|
|
3
|
+
*
|
|
4
|
+
* Every env var the platform provisions onto an agent (written by the GitHub
|
|
5
|
+
* and Slack provisioners, or emitted by the agent pod manifest) must be
|
|
6
|
+
* classified for the model's child process: runtime-only (stripped),
|
|
7
|
+
* pass-through secret, or an explicitly listed non-secret system var. A new
|
|
8
|
+
* system-provisioned var that is not classified fails here, so it cannot reach
|
|
9
|
+
* the child env by default. (Lives in admin: admin may import lib, not the
|
|
10
|
+
* reverse.)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, expect, it } from "bun:test";
|
|
14
|
+
import { readFileSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import {
|
|
17
|
+
CHILD_ALLOWED_SECRET_ENV_VARS,
|
|
18
|
+
RUNTIME_ONLY_ENV_VARS,
|
|
19
|
+
} from "@app-vitals/agent-lib/child-env";
|
|
20
|
+
import {
|
|
21
|
+
type AgentDeploymentOpts,
|
|
22
|
+
buildAgentDeploymentManifest,
|
|
23
|
+
} from "./agent-manifest.ts";
|
|
24
|
+
|
|
25
|
+
/** Non-secret vars the platform provisions: ids, slugs, URLs, paths, flags. */
|
|
26
|
+
const NON_SECRET_SYSTEM_ENV_VARS: readonly string[] = [
|
|
27
|
+
// GitHub provisioner
|
|
28
|
+
"GH_APP_ID",
|
|
29
|
+
"GH_APP_CLIENT_ID",
|
|
30
|
+
"GH_APP_SLUG",
|
|
31
|
+
"GH_APP_INSTALLATION_ID",
|
|
32
|
+
// Slack provisioner
|
|
33
|
+
"SLACK_APP_ID",
|
|
34
|
+
"SLACK_CLIENT_ID",
|
|
35
|
+
// Pod manifest
|
|
36
|
+
"SHIPWRIGHT_AGENT_ID",
|
|
37
|
+
"SHIPWRIGHT_API_URL",
|
|
38
|
+
"SHIPWRIGHT_HEALTH_PORT",
|
|
39
|
+
"AGENT_HOME",
|
|
40
|
+
"SHIPWRIGHT_REPO_DIR",
|
|
41
|
+
"SHIPWRIGHT_WORKTREE_DIR",
|
|
42
|
+
"SHIPWRIGHT_TASK_STORE_URL",
|
|
43
|
+
"SHIPWRIGHT_CHAT_SERVICE_URL",
|
|
44
|
+
"WHISPER_SERVICE_URL",
|
|
45
|
+
"ELEVENLABS_VOICE_ID",
|
|
46
|
+
"ANTHROPIC_IDENTITY_TOKEN_FILE",
|
|
47
|
+
"ANTHROPIC_FEDERATION_RULE_ID",
|
|
48
|
+
"ANTHROPIC_ORGANIZATION_ID",
|
|
49
|
+
"ANTHROPIC_SERVICE_ACCOUNT_ID",
|
|
50
|
+
"ANTHROPIC_WORKSPACE_ID",
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
const classified = new Set<string>([
|
|
54
|
+
...RUNTIME_ONLY_ENV_VARS,
|
|
55
|
+
...CHILD_ALLOWED_SECRET_ENV_VARS,
|
|
56
|
+
...NON_SECRET_SYSTEM_ENV_VARS,
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
/** Every env name the pod manifest emits with all optional wiring switched on. */
|
|
60
|
+
function manifestEnvNames(): string[] {
|
|
61
|
+
const opts: AgentDeploymentOpts = {
|
|
62
|
+
agentId: "agent-1",
|
|
63
|
+
namespace: "ns",
|
|
64
|
+
image: "img",
|
|
65
|
+
imageTag: "t",
|
|
66
|
+
apiUrl: "http://admin.svc",
|
|
67
|
+
pvcName: "pvc",
|
|
68
|
+
secretName: "secret",
|
|
69
|
+
serviceIntegrations: [
|
|
70
|
+
{
|
|
71
|
+
tokenEnv: "SHIPWRIGHT_TASK_STORE_TOKEN",
|
|
72
|
+
urlEnv: "SHIPWRIGHT_TASK_STORE_URL",
|
|
73
|
+
secretKey: "task-store-token",
|
|
74
|
+
url: "http://task-store.svc",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
chatServiceUrl: "http://chat.svc",
|
|
78
|
+
voice: {
|
|
79
|
+
whisperServiceUrl: "http://whisper.svc",
|
|
80
|
+
groqApiKey: "g",
|
|
81
|
+
elevenLabsApiKey: "e",
|
|
82
|
+
voiceId: "v",
|
|
83
|
+
},
|
|
84
|
+
anthropicFederation: {
|
|
85
|
+
serviceAccountName: "sa",
|
|
86
|
+
ruleId: "r",
|
|
87
|
+
organizationId: "o",
|
|
88
|
+
serviceAccountId: "s",
|
|
89
|
+
workspaceId: "w",
|
|
90
|
+
audience: "a",
|
|
91
|
+
expirationSeconds: 3600,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
const env =
|
|
95
|
+
buildAgentDeploymentManifest(opts).spec.template.spec.containers[0].env;
|
|
96
|
+
return (env ?? []).map((e) => e.name);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Every GH_* / SLACK_* name the provisioner sources mention (writes and reads). */
|
|
100
|
+
function provisionerEnvNames(): string[] {
|
|
101
|
+
const names = new Set<string>();
|
|
102
|
+
for (const file of [
|
|
103
|
+
"github-provisioning-service.ts",
|
|
104
|
+
"slack-provisioning-service.ts",
|
|
105
|
+
]) {
|
|
106
|
+
const src = readFileSync(join(import.meta.dir, file), "utf-8");
|
|
107
|
+
for (const m of src.matchAll(/\b(?:GH|SLACK)_[A-Z0-9]+(?:_[A-Z0-9]+)*\b/g))
|
|
108
|
+
names.add(m[0]);
|
|
109
|
+
}
|
|
110
|
+
return [...names];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
describe("system-provisioned agent env classification", () => {
|
|
114
|
+
it("collects a non-trivial set from each source", () => {
|
|
115
|
+
expect(manifestEnvNames()).toContain("SHIPWRIGHT_AGENT_API_KEY");
|
|
116
|
+
expect(manifestEnvNames()).toContain("GROQ_API_KEY");
|
|
117
|
+
expect(provisionerEnvNames()).toContain("GH_APP_PRIVATE_KEY");
|
|
118
|
+
expect(provisionerEnvNames()).toContain("SLACK_APP_TOKEN");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it.each(manifestEnvNames())("manifest env %s is classified", (name) => {
|
|
122
|
+
expect(classified.has(name)).toBe(true);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it.each(provisionerEnvNames())("provisioner env %s is classified", (name) => {
|
|
126
|
+
expect(classified.has(name)).toBe(true);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("classifies every Slack var the Slack flow stores", () => {
|
|
130
|
+
for (const name of [
|
|
131
|
+
"SLACK_BOT_TOKEN",
|
|
132
|
+
"SLACK_APP_TOKEN",
|
|
133
|
+
"SLACK_APP_ID",
|
|
134
|
+
"SLACK_CLIENT_ID",
|
|
135
|
+
"SLACK_CLIENT_SECRET",
|
|
136
|
+
"SLACK_SIGNING_SECRET",
|
|
137
|
+
])
|
|
138
|
+
expect(classified.has(name)).toBe(true);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("keeps the non-secret list disjoint from the secret lists", () => {
|
|
142
|
+
const secretish = new Set<string>([
|
|
143
|
+
...RUNTIME_ONLY_ENV_VARS,
|
|
144
|
+
...CHILD_ALLOWED_SECRET_ENV_VARS,
|
|
145
|
+
]);
|
|
146
|
+
for (const name of NON_SECRET_SYSTEM_ENV_VARS)
|
|
147
|
+
expect(secretish.has(name)).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -88,6 +88,29 @@ describeOrSkip("AgentTokenService (integration)", () => {
|
|
|
88
88
|
expect(result?.agentId).toBe(agentId);
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
it("validate() returns the kind (runtime by default, tools when set)", async () => {
|
|
92
|
+
const agentId = await createAgent(prisma);
|
|
93
|
+
const rt = await service.create(agentId);
|
|
94
|
+
const tools = await service.create(agentId, "t", "tools");
|
|
95
|
+
expect(await service.validate(rt.rawToken)).toEqual({
|
|
96
|
+
agentId,
|
|
97
|
+
kind: "runtime",
|
|
98
|
+
});
|
|
99
|
+
expect(await service.validate(tools.rawToken)).toEqual({
|
|
100
|
+
agentId,
|
|
101
|
+
kind: "tools",
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("rows inserted without a kind column value validate as runtime", async () => {
|
|
106
|
+
const agentId = await createAgent(prisma);
|
|
107
|
+
const raw = "a".repeat(64);
|
|
108
|
+
const hashed = new Bun.CryptoHasher("sha256").update(raw).digest("hex");
|
|
109
|
+
// Raw SQL omitting `kind`, as a pre-migration row would.
|
|
110
|
+
await prisma.$executeRaw`INSERT INTO "AgentToken" ("id", "agentId", "token") VALUES (${"legacy-token-1"}, ${agentId}, ${hashed})`;
|
|
111
|
+
expect(await service.validate(raw)).toEqual({ agentId, kind: "runtime" });
|
|
112
|
+
});
|
|
113
|
+
|
|
91
114
|
it("validate() returns null for unknown token", async () => {
|
|
92
115
|
const result = await service.validate("0".repeat(64));
|
|
93
116
|
expect(result).toBeNull();
|