@app-vitals/agent-admin 1.83.0 → 1.84.1
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 +13 -1
- package/package.json +3 -2
- package/src/admin-boot.ts +123 -149
- package/src/admin-spec.ts +128 -164
- package/src/admin-ui-installation-repos-pages.ts +20 -2
- package/src/agents-api.smoke.test.ts +39 -2
- package/src/agents-api.ts +15 -7
- package/src/github-installation-wiring.ts +61 -1
- package/src/github-installation-wiring.unit.test.ts +55 -3
- package/src/github-installation.fixtures.ts +44 -3
- package/src/github-repo-cache.ts +15 -0
- package/src/github-sync-cache.integration.test.ts +134 -0
- package/src/github-sync-cached-access.ts +125 -0
- package/src/github-sync-reverify.unit.test.ts +138 -0
- package/src/github-sync.ts +174 -8
- package/src/installation-repos-service.ts +36 -1
- package/src/platform-routes.ts +134 -0
- package/src/platform-routes.unit.test.ts +98 -0
- package/src/repo-access-rules.ts +13 -1
package/openapi.platform.json
CHANGED
|
@@ -3625,6 +3625,18 @@
|
|
|
3625
3625
|
"userCanPush": {
|
|
3626
3626
|
"type": "boolean",
|
|
3627
3627
|
"description": "Whether the agent's bound GitHub user can push, from cached access rows. Omitted when no username is bound or the org's access data is incomplete (a missing or errored pair is never reported as false)."
|
|
3628
|
+
},
|
|
3629
|
+
"accessCheckedAt": {
|
|
3630
|
+
"type": "string",
|
|
3631
|
+
"description": "When the bound user's access to this repo was last checked (ISO 8601), when a cached row exists."
|
|
3632
|
+
},
|
|
3633
|
+
"accessAttempts": {
|
|
3634
|
+
"type": "integer",
|
|
3635
|
+
"description": "Failed access checks for this repo since the last success, when any."
|
|
3636
|
+
},
|
|
3637
|
+
"accessError": {
|
|
3638
|
+
"type": "string",
|
|
3639
|
+
"description": "Last access-check error for this repo, when any."
|
|
3628
3640
|
}
|
|
3629
3641
|
},
|
|
3630
3642
|
"required": [
|
|
@@ -3697,7 +3709,7 @@
|
|
|
3697
3709
|
"reason"
|
|
3698
3710
|
]
|
|
3699
3711
|
},
|
|
3700
|
-
"description": "Orgs whose access listing is missing, partial or failed, or whose lookup App is not installed or installed on selected repositories only; nothing there is added or removed."
|
|
3712
|
+
"description": "Orgs whose access listing is missing, partial or failed, whose cached access data is incomplete or stale, or whose lookup App is not installed or installed on selected repositories only; nothing there is added or removed. `reason` says why (for stale data, when it was checked)."
|
|
3701
3713
|
},
|
|
3702
3714
|
"openWork": {
|
|
3703
3715
|
"type": "array",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.84.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"./admin-spec": "./src/admin-spec.ts",
|
|
21
21
|
"./main": "./src/main.ts",
|
|
22
22
|
"./openapi-schemas": "./src/openapi-schemas.ts",
|
|
23
|
+
"./platform-routes": "./src/platform-routes.ts",
|
|
23
24
|
"./prisma-client": "./src/prisma-client.ts",
|
|
24
25
|
"./specialty-types": "./src/specialty-types.ts",
|
|
25
26
|
"./brand-tokens.json": "./src/brand-tokens.json",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@anthropic-ai/sdk": "0.137.0",
|
|
46
|
-
"@app-vitals/agent-lib": "1.
|
|
47
|
+
"@app-vitals/agent-lib": "1.84.1",
|
|
47
48
|
"@hono/zod-openapi": "^1.0.0",
|
|
48
49
|
"@prisma/adapter-pg": "^7.10.0",
|
|
49
50
|
"@prisma/client": "^7.10.0",
|
package/src/admin-boot.ts
CHANGED
|
@@ -51,7 +51,6 @@ import { AccountOnboardingService } from "./account-onboarding.ts";
|
|
|
51
51
|
import { AccountTrialExpirySweeper } from "./account-trial-expiry-sweeper.ts";
|
|
52
52
|
import { AccountTrialWarningSweeper } from "./account-trial-warning-sweeper.ts";
|
|
53
53
|
import { AccountService } from "./accounts.ts";
|
|
54
|
-
import { createAccountsApp } from "./accounts-api.ts";
|
|
55
54
|
import {
|
|
56
55
|
buildDeletionClients,
|
|
57
56
|
buildProvisioner,
|
|
@@ -86,12 +85,10 @@ import { AgentMemberService } from "./agent-members.ts";
|
|
|
86
85
|
import { AgentPluginService } from "./agent-plugins.ts";
|
|
87
86
|
import { AgentTemplateReconcileService } from "./agent-template-reconcile.ts";
|
|
88
87
|
import { AgentTemplateService } from "./agent-templates.ts";
|
|
89
|
-
import { createAgentTemplatesApp } from "./agent-templates-api.ts";
|
|
90
88
|
import { AgentTokenService } from "./agent-tokens.ts";
|
|
91
89
|
import { AgentToolService } from "./agent-tools.ts";
|
|
92
90
|
import { AgentService } from "./agents.ts";
|
|
93
|
-
import {
|
|
94
|
-
import { createAgentRuntimeApp } from "./api.ts";
|
|
91
|
+
import { parseAdminApiKeys } from "./agents-api.ts";
|
|
95
92
|
import { createAdminAuthMiddleware } from "./api-auth.ts";
|
|
96
93
|
import {
|
|
97
94
|
callerScopeDepsFromServices,
|
|
@@ -107,7 +104,6 @@ import { isDevAuthAllowed } from "./dev-auth-guard.ts";
|
|
|
107
104
|
import { HttpGithubAppProvisioningClient } from "./github-app-provisioning-client.ts";
|
|
108
105
|
import {
|
|
109
106
|
createGithubAccessPreview,
|
|
110
|
-
createGithubEnterpriseApp,
|
|
111
107
|
createGithubLookupService,
|
|
112
108
|
} from "./github-enterprise-api.ts";
|
|
113
109
|
import { GitHubEnterpriseAppService } from "./github-enterprise-apps.ts";
|
|
@@ -125,10 +121,9 @@ import {
|
|
|
125
121
|
import { HttpGoogleAuthClient } from "./google-auth-client.ts";
|
|
126
122
|
import { HttpChatClient } from "./http-chat-client.ts";
|
|
127
123
|
import { HttpOktaAuthClient } from "./okta-auth-client.ts";
|
|
128
|
-
import {
|
|
124
|
+
import { mountPlatformApis } from "./platform-routes.ts";
|
|
129
125
|
import { parsePodServiceAccountConfig } from "./pod-service-account-config.ts";
|
|
130
126
|
import { PrincipalLookupService } from "./principal-lookup.ts";
|
|
131
|
-
import { createPrincipalsApp } from "./principals-api.ts";
|
|
132
127
|
import { createAdminPrismaClient } from "./prisma-client.ts";
|
|
133
128
|
import { isPushEnabled } from "./push-sender.ts";
|
|
134
129
|
import { PushService } from "./push-service.ts";
|
|
@@ -486,37 +481,15 @@ export async function startAdmin(
|
|
|
486
481
|
// Redirect bare root to the login page — no handler exists at "/" otherwise.
|
|
487
482
|
root.get("/", (c) => c.redirect("/admin/login", 302));
|
|
488
483
|
|
|
489
|
-
// 2.
|
|
490
|
-
//
|
|
491
|
-
//
|
|
492
|
-
//
|
|
484
|
+
// 2.-3b. Platform APIs, mounted in one place (platform-routes.ts):
|
|
485
|
+
// runtime API — root.route("/agents", runtimeApp) — then the admin CRUD API
|
|
486
|
+
// (root.route("/", adminApiApp)), flag-gated GET /doc, accounts
|
|
487
|
+
// (createAccountsApp(...)), principals, templates and github-enterprise.
|
|
488
|
+
// Runtime API: admin key | per-agent bearer | session JWT. Hono v4 strips
|
|
489
|
+
// the /agents prefix before dispatching, so its routes resolve at
|
|
493
490
|
// GET /agents/:id/config and GET /agents/:id/crons from root.
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
agentCronJobService,
|
|
497
|
-
agentService,
|
|
498
|
-
agentPluginService,
|
|
499
|
-
agentMarketplaceService,
|
|
500
|
-
...(resolvedExtensions.agentPhaseMethodologyService
|
|
501
|
-
? {
|
|
502
|
-
agentPhaseMethodologyService:
|
|
503
|
-
resolvedExtensions.agentPhaseMethodologyService,
|
|
504
|
-
}
|
|
505
|
-
: {}),
|
|
506
|
-
sessionSecret,
|
|
507
|
-
adminApiKeys,
|
|
508
|
-
agentTokenService,
|
|
509
|
-
anthropicFederationEnabled,
|
|
510
|
-
transcriptUploadEnabled: transcriptConfig.enabled,
|
|
511
|
-
loopTranscriptAgentIds: transcriptConfig.loopAgentIds,
|
|
512
|
-
repoAccessCheckEnabled: repoAccessConfig.enabled,
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
root.route("/agents", runtimeApp);
|
|
516
|
-
|
|
517
|
-
// 3. Admin CRUD API — /agents/:id/* — admin key | per-agent bearer | session JWT
|
|
518
|
-
// Routes are now at /agents/:id/* (same prefix as runtime, different sub-paths).
|
|
519
|
-
// MUST be mounted before admin-ui (/admin/*) to avoid shadowing.
|
|
491
|
+
// Admin CRUD API (/agents/:id/*) MUST be mounted before admin-ui (/admin/*)
|
|
492
|
+
// to avoid shadowing.
|
|
520
493
|
// Built before the admin API: GHE-2.4's access preview reads the same Apps.
|
|
521
494
|
// Strict crypto: no plain-text key storage.
|
|
522
495
|
const githubAccessPreview = createGithubAccessPreview({
|
|
@@ -535,140 +508,141 @@ export async function startAdmin(
|
|
|
535
508
|
agentEnv: agentEnvService,
|
|
536
509
|
openWork: resolvedExtensions.openWork,
|
|
537
510
|
});
|
|
538
|
-
const
|
|
539
|
-
githubAccessPreview,
|
|
540
|
-
...(resolvedExtensions.openWork
|
|
541
|
-
? { openWork: resolvedExtensions.openWork }
|
|
542
|
-
: {}),
|
|
543
|
-
githubInstallationRepos,
|
|
544
|
-
githubSync,
|
|
545
|
-
agentService,
|
|
546
|
-
agentEnvService,
|
|
547
|
-
agentCronJobService,
|
|
548
|
-
agentCronRunService,
|
|
549
|
-
agentCronRunStatsService,
|
|
550
|
-
agentToolService,
|
|
551
|
-
agentTokenService,
|
|
552
|
-
agentPluginService,
|
|
553
|
-
agentMarketplaceService,
|
|
554
|
-
agentMemberService,
|
|
555
|
-
callerScopeResolver,
|
|
556
|
-
specialtyRegistry,
|
|
557
|
-
specialtyDefaults,
|
|
558
|
-
agentChatTokenService,
|
|
559
|
-
agentGitHubInstallationsService,
|
|
511
|
+
const templateService = new AgentTemplateService(
|
|
560
512
|
prisma,
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
podServiceAccountEnabled: parsePodServiceAccountConfig(process.env).enabled,
|
|
575
|
-
chatCredentialsEnabled: parseChatCredentialConfig(process.env).enabled,
|
|
576
|
-
...(chatCredentialsClient
|
|
577
|
-
? { chatCredentials: chatCredentialsClient }
|
|
578
|
-
: {}),
|
|
579
|
-
agentAsk: {
|
|
580
|
-
config: agentAskConfig,
|
|
581
|
-
store: new AgentAskService(prisma),
|
|
582
|
-
},
|
|
583
|
-
cronRunNow: {
|
|
584
|
-
config: cronRunNowConfig,
|
|
585
|
-
store: new CronRunNowService(prisma),
|
|
586
|
-
},
|
|
587
|
-
...(chatClient ? { chatClient } : {}),
|
|
588
|
-
transcripts: {
|
|
589
|
-
config: transcriptConfig,
|
|
590
|
-
store: new CronRunTranscriptService(prisma),
|
|
591
|
-
},
|
|
592
|
-
...resolvedExtensions.apiDeps,
|
|
513
|
+
crypto,
|
|
514
|
+
specialtyRegistry,
|
|
515
|
+
templateReconcileService,
|
|
516
|
+
);
|
|
517
|
+
// GLC-2.4: the github-enterprise Refresh action marks the cache stale (DB
|
|
518
|
+
// only). It asks the refresher (created further down) to re-discover through
|
|
519
|
+
// this hook.
|
|
520
|
+
const githubRefreshConfig = resolveRefreshConfig(process.env);
|
|
521
|
+
let invalidateGithubDiscovery: () => void = () => {};
|
|
522
|
+
const githubRefreshAction = createGithubRefreshAction({
|
|
523
|
+
cache: githubRepoCache,
|
|
524
|
+
stalenessCapMs: githubRefreshConfig.stalenessCapMs,
|
|
525
|
+
onMarked: () => invalidateGithubDiscovery(),
|
|
593
526
|
});
|
|
594
|
-
root
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
527
|
+
const { adminApiApp, githubEnterpriseApp } = mountPlatformApis(root, {
|
|
528
|
+
runtime: {
|
|
529
|
+
agentEnvService,
|
|
530
|
+
agentCronJobService,
|
|
531
|
+
agentService,
|
|
532
|
+
agentPluginService,
|
|
533
|
+
agentMarketplaceService,
|
|
534
|
+
...(resolvedExtensions.agentPhaseMethodologyService
|
|
535
|
+
? {
|
|
536
|
+
agentPhaseMethodologyService:
|
|
537
|
+
resolvedExtensions.agentPhaseMethodologyService,
|
|
538
|
+
}
|
|
539
|
+
: {}),
|
|
600
540
|
sessionSecret,
|
|
601
|
-
agentTokenService,
|
|
602
541
|
adminApiKeys,
|
|
542
|
+
agentTokenService,
|
|
543
|
+
anthropicFederationEnabled,
|
|
544
|
+
transcriptUploadEnabled: transcriptConfig.enabled,
|
|
545
|
+
loopTranscriptAgentIds: transcriptConfig.loopAgentIds,
|
|
546
|
+
repoAccessCheckEnabled: repoAccessConfig.enabled,
|
|
547
|
+
},
|
|
548
|
+
adminApi: {
|
|
549
|
+
githubAccessPreview,
|
|
550
|
+
...(resolvedExtensions.openWork
|
|
551
|
+
? { openWork: resolvedExtensions.openWork }
|
|
552
|
+
: {}),
|
|
553
|
+
githubInstallationRepos,
|
|
554
|
+
githubSync,
|
|
555
|
+
agentService,
|
|
556
|
+
agentEnvService,
|
|
557
|
+
agentCronJobService,
|
|
558
|
+
agentCronRunService,
|
|
559
|
+
agentCronRunStatsService,
|
|
560
|
+
agentToolService,
|
|
561
|
+
agentTokenService,
|
|
562
|
+
agentPluginService,
|
|
563
|
+
agentMarketplaceService,
|
|
603
564
|
agentMemberService,
|
|
604
565
|
callerScopeResolver,
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
566
|
+
specialtyRegistry,
|
|
567
|
+
specialtyDefaults,
|
|
568
|
+
agentChatTokenService,
|
|
569
|
+
agentGitHubInstallationsService,
|
|
570
|
+
prisma,
|
|
571
|
+
provisioner,
|
|
572
|
+
serviceIntegrations,
|
|
573
|
+
chatService: deletionChatService,
|
|
574
|
+
slack: slackClient,
|
|
575
|
+
decrypt: crypto.decrypt,
|
|
576
|
+
slackConfigTokens,
|
|
577
|
+
agentTemplateReconcileService: templateReconcileService,
|
|
578
|
+
sessionSecret,
|
|
579
|
+
adminApiKeys,
|
|
580
|
+
sentryClient: process.env.SENTRY_DSN ? Sentry : undefined,
|
|
581
|
+
pool: adminPool,
|
|
582
|
+
selfServe,
|
|
583
|
+
anthropicFederationEnabled,
|
|
584
|
+
podServiceAccountEnabled: parsePodServiceAccountConfig(process.env)
|
|
585
|
+
.enabled,
|
|
586
|
+
chatCredentialsEnabled: parseChatCredentialConfig(process.env).enabled,
|
|
587
|
+
...(chatCredentialsClient
|
|
588
|
+
? { chatCredentials: chatCredentialsClient }
|
|
589
|
+
: {}),
|
|
590
|
+
agentAsk: {
|
|
591
|
+
config: agentAskConfig,
|
|
592
|
+
store: new AgentAskService(prisma),
|
|
593
|
+
},
|
|
594
|
+
cronRunNow: {
|
|
595
|
+
config: cronRunNowConfig,
|
|
596
|
+
store: new CronRunNowService(prisma),
|
|
597
|
+
},
|
|
598
|
+
...(chatClient ? { chatClient } : {}),
|
|
599
|
+
transcripts: {
|
|
600
|
+
config: transcriptConfig,
|
|
601
|
+
store: new CronRunTranscriptService(prisma),
|
|
602
|
+
},
|
|
603
|
+
...resolvedExtensions.apiDeps,
|
|
604
|
+
},
|
|
605
|
+
doc: {
|
|
606
|
+
env: process.env,
|
|
607
|
+
auth: createAdminAuthMiddleware({
|
|
608
|
+
sessionSecret,
|
|
609
|
+
agentTokenService,
|
|
610
|
+
adminApiKeys,
|
|
611
|
+
agentMemberService,
|
|
612
|
+
callerScopeResolver,
|
|
613
|
+
}),
|
|
614
|
+
},
|
|
615
|
+
accounts: {
|
|
612
616
|
accountService: new AccountService(prisma),
|
|
613
617
|
accountLifecycle,
|
|
614
618
|
selfServe,
|
|
615
619
|
sessionSecret,
|
|
616
620
|
adminApiKeys,
|
|
617
621
|
agentTokenService,
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
// 3b'. Principals lookup API — /principals/* — admin-only (ACM-1.1)
|
|
622
|
-
root.route(
|
|
623
|
-
"/",
|
|
624
|
-
createPrincipalsApp({
|
|
622
|
+
},
|
|
623
|
+
principals: {
|
|
625
624
|
lookup: new PrincipalLookupService(prisma),
|
|
626
625
|
sessionSecret,
|
|
627
626
|
adminApiKeys,
|
|
628
627
|
agentTokenService,
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
// 3b''. Agent templates API — /templates/* — admin or account-scoped (ATP-1.3)
|
|
633
|
-
const templateService = new AgentTemplateService(
|
|
634
|
-
prisma,
|
|
635
|
-
crypto,
|
|
636
|
-
specialtyRegistry,
|
|
637
|
-
templateReconcileService,
|
|
638
|
-
);
|
|
639
|
-
root.route(
|
|
640
|
-
"/",
|
|
641
|
-
createAgentTemplatesApp({
|
|
628
|
+
},
|
|
629
|
+
templates: {
|
|
642
630
|
templateService,
|
|
643
631
|
callerScopeResolver,
|
|
644
632
|
sessionSecret,
|
|
645
633
|
adminApiKeys,
|
|
646
634
|
agentTokenService,
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
const githubRefreshAction = createGithubRefreshAction({
|
|
658
|
-
cache: githubRepoCache,
|
|
659
|
-
stalenessCapMs: githubRefreshConfig.stalenessCapMs,
|
|
660
|
-
onMarked: () => invalidateGithubDiscovery(),
|
|
661
|
-
});
|
|
662
|
-
const githubEnterpriseApp = createGithubEnterpriseApp({
|
|
663
|
-
refreshAction: githubRefreshAction,
|
|
664
|
-
appService: githubEnterpriseAppService,
|
|
665
|
-
agentService,
|
|
666
|
-
agentEnvService,
|
|
667
|
-
sessionSecret,
|
|
668
|
-
adminApiKeys,
|
|
669
|
-
agentTokenService,
|
|
635
|
+
},
|
|
636
|
+
githubEnterprise: {
|
|
637
|
+
refreshAction: githubRefreshAction,
|
|
638
|
+
appService: githubEnterpriseAppService,
|
|
639
|
+
agentService,
|
|
640
|
+
agentEnvService,
|
|
641
|
+
sessionSecret,
|
|
642
|
+
adminApiKeys,
|
|
643
|
+
agentTokenService,
|
|
644
|
+
},
|
|
670
645
|
});
|
|
671
|
-
root.route("/", githubEnterpriseApp);
|
|
672
646
|
|
|
673
647
|
// 3c. Extension API routes — after every platform API, before the admin UI
|
|
674
648
|
// (same no-shadowing rule as the admin CRUD API above).
|