@app-vitals/agent-admin 1.30.0 → 1.32.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 +393 -0
- package/package.json +2 -2
- package/src/admin-boot.ts +26 -4
- package/src/admin-extension.ts +13 -0
- package/src/admin-extension.unit.test.ts +20 -0
- package/src/agents-api.smoke.test.ts +378 -0
- package/src/agents-api.ts +224 -0
- package/src/github-enterprise-isolation.unit.test.ts +8 -4
- package/src/github-reconcile-routes.integration.test.ts +6 -2
- package/src/github-reconcile-wiring.ts +122 -0
- package/src/github-reconcile-wiring.unit.test.ts +170 -0
- package/src/installation-repos-service.ts +237 -0
- package/src/installation-repos-service.unit.test.ts +270 -0
- package/src/reconcile-apply-service.integration.test.ts +11 -3
- package/src/reconcile-apply-service.ts +88 -22
- package/src/reconcile-apply-service.unit.test.ts +70 -24
package/openapi.platform.json
CHANGED
|
@@ -3492,6 +3492,94 @@
|
|
|
3492
3492
|
"planHash"
|
|
3493
3493
|
]
|
|
3494
3494
|
},
|
|
3495
|
+
"GithubInstallationReposList": {
|
|
3496
|
+
"type": "object",
|
|
3497
|
+
"properties": {
|
|
3498
|
+
"appId": {
|
|
3499
|
+
"type": "integer"
|
|
3500
|
+
},
|
|
3501
|
+
"orgs": {
|
|
3502
|
+
"type": "array",
|
|
3503
|
+
"items": {
|
|
3504
|
+
"type": "object",
|
|
3505
|
+
"properties": {
|
|
3506
|
+
"org": {
|
|
3507
|
+
"type": "string"
|
|
3508
|
+
},
|
|
3509
|
+
"repos": {
|
|
3510
|
+
"type": "array",
|
|
3511
|
+
"items": {
|
|
3512
|
+
"type": "object",
|
|
3513
|
+
"properties": {
|
|
3514
|
+
"fullName": {
|
|
3515
|
+
"type": "string"
|
|
3516
|
+
},
|
|
3517
|
+
"userCanPush": {
|
|
3518
|
+
"type": "boolean",
|
|
3519
|
+
"description": "Whether the agent's bound GitHub user can push. Omitted when no username is bound or the org's access lookup is incomplete; never reported as false for unknown."
|
|
3520
|
+
}
|
|
3521
|
+
},
|
|
3522
|
+
"required": [
|
|
3523
|
+
"fullName"
|
|
3524
|
+
]
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
},
|
|
3528
|
+
"required": [
|
|
3529
|
+
"org",
|
|
3530
|
+
"repos"
|
|
3531
|
+
]
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
},
|
|
3535
|
+
"required": [
|
|
3536
|
+
"appId",
|
|
3537
|
+
"orgs"
|
|
3538
|
+
]
|
|
3539
|
+
},
|
|
3540
|
+
"GithubInstallationReposChange": {
|
|
3541
|
+
"type": "object",
|
|
3542
|
+
"properties": {
|
|
3543
|
+
"status": {
|
|
3544
|
+
"type": "string",
|
|
3545
|
+
"enum": [
|
|
3546
|
+
"applied"
|
|
3547
|
+
]
|
|
3548
|
+
},
|
|
3549
|
+
"auditId": {
|
|
3550
|
+
"type": "string"
|
|
3551
|
+
},
|
|
3552
|
+
"repos": {
|
|
3553
|
+
"type": "array",
|
|
3554
|
+
"items": {
|
|
3555
|
+
"type": "string"
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
},
|
|
3559
|
+
"required": [
|
|
3560
|
+
"status",
|
|
3561
|
+
"auditId",
|
|
3562
|
+
"repos"
|
|
3563
|
+
]
|
|
3564
|
+
},
|
|
3565
|
+
"GithubInstallationReposBody": {
|
|
3566
|
+
"type": "object",
|
|
3567
|
+
"properties": {
|
|
3568
|
+
"repos": {
|
|
3569
|
+
"type": "array",
|
|
3570
|
+
"items": {
|
|
3571
|
+
"type": "string",
|
|
3572
|
+
"pattern": "^[^/\\s]+\\/[^/\\s]+$"
|
|
3573
|
+
},
|
|
3574
|
+
"minItems": 1,
|
|
3575
|
+
"maxItems": 100,
|
|
3576
|
+
"description": "Repos (owner/repo) to change on the agent App's installation."
|
|
3577
|
+
}
|
|
3578
|
+
},
|
|
3579
|
+
"required": [
|
|
3580
|
+
"repos"
|
|
3581
|
+
]
|
|
3582
|
+
},
|
|
3495
3583
|
"AgentConfigResponse": {
|
|
3496
3584
|
"type": "object",
|
|
3497
3585
|
"properties": {
|
|
@@ -7283,6 +7371,311 @@
|
|
|
7283
7371
|
}
|
|
7284
7372
|
}
|
|
7285
7373
|
},
|
|
7374
|
+
"/agents/{id}/github-installation/repos": {
|
|
7375
|
+
"get": {
|
|
7376
|
+
"summary": "List the repos on the agent App's installation",
|
|
7377
|
+
"description": "Platform-admin only (session members, ops keys and agent keys get 403). Per org the agent's own GitHub App (its GH_APP_ID) is installed on, lists the installation's repos. When the agent has a bound githubUsername, each repo carries `userCanPush` from the access lookup only when that org's lookup result is complete; otherwise the field is omitted (never false). 404 for an unknown agent; 422 when the agent has no GH_APP_ID.",
|
|
7378
|
+
"parameters": [
|
|
7379
|
+
{
|
|
7380
|
+
"schema": {
|
|
7381
|
+
"type": "string",
|
|
7382
|
+
"example": "clx1234567890"
|
|
7383
|
+
},
|
|
7384
|
+
"required": true,
|
|
7385
|
+
"name": "id",
|
|
7386
|
+
"in": "path"
|
|
7387
|
+
}
|
|
7388
|
+
],
|
|
7389
|
+
"responses": {
|
|
7390
|
+
"200": {
|
|
7391
|
+
"description": "Installation repos",
|
|
7392
|
+
"content": {
|
|
7393
|
+
"application/json": {
|
|
7394
|
+
"schema": {
|
|
7395
|
+
"$ref": "#/components/schemas/GithubInstallationReposList"
|
|
7396
|
+
}
|
|
7397
|
+
}
|
|
7398
|
+
}
|
|
7399
|
+
},
|
|
7400
|
+
"401": {
|
|
7401
|
+
"description": "Unauthorized",
|
|
7402
|
+
"content": {
|
|
7403
|
+
"application/json": {
|
|
7404
|
+
"schema": {
|
|
7405
|
+
"$ref": "#/components/schemas/Error"
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
}
|
|
7409
|
+
},
|
|
7410
|
+
"403": {
|
|
7411
|
+
"description": "Platform admin required",
|
|
7412
|
+
"content": {
|
|
7413
|
+
"application/json": {
|
|
7414
|
+
"schema": {
|
|
7415
|
+
"$ref": "#/components/schemas/Error"
|
|
7416
|
+
}
|
|
7417
|
+
}
|
|
7418
|
+
}
|
|
7419
|
+
},
|
|
7420
|
+
"404": {
|
|
7421
|
+
"description": "Agent not found",
|
|
7422
|
+
"content": {
|
|
7423
|
+
"application/json": {
|
|
7424
|
+
"schema": {
|
|
7425
|
+
"$ref": "#/components/schemas/Error"
|
|
7426
|
+
}
|
|
7427
|
+
}
|
|
7428
|
+
}
|
|
7429
|
+
},
|
|
7430
|
+
"422": {
|
|
7431
|
+
"description": "Agent has no GH_APP_ID (its own GitHub App is not set up)",
|
|
7432
|
+
"content": {
|
|
7433
|
+
"application/json": {
|
|
7434
|
+
"schema": {
|
|
7435
|
+
"$ref": "#/components/schemas/Error"
|
|
7436
|
+
}
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
},
|
|
7440
|
+
"502": {
|
|
7441
|
+
"description": "GitHub unavailable or refused",
|
|
7442
|
+
"content": {
|
|
7443
|
+
"application/json": {
|
|
7444
|
+
"schema": {
|
|
7445
|
+
"$ref": "#/components/schemas/Error"
|
|
7446
|
+
}
|
|
7447
|
+
}
|
|
7448
|
+
}
|
|
7449
|
+
},
|
|
7450
|
+
"503": {
|
|
7451
|
+
"description": "GitHub Apps are not configured",
|
|
7452
|
+
"content": {
|
|
7453
|
+
"application/json": {
|
|
7454
|
+
"schema": {
|
|
7455
|
+
"$ref": "#/components/schemas/Error"
|
|
7456
|
+
}
|
|
7457
|
+
}
|
|
7458
|
+
}
|
|
7459
|
+
}
|
|
7460
|
+
}
|
|
7461
|
+
},
|
|
7462
|
+
"post": {
|
|
7463
|
+
"summary": "Add repos to the agent App's installation",
|
|
7464
|
+
"description": "Platform-admin only. Grants the agent's own GitHub App installation access to the named repos, with no plan step; the agent's configured repos are not changed. Writes one audit entry (GitHubReconcileAudit, planHash `direct:add`) recording the caller and repos. 404 unknown agent; 422 no GH_APP_ID; 409 when the App is not installed on a repo's org (nothing is changed or audited); 502 when GitHub refuses (a failed audit entry is written).",
|
|
7465
|
+
"parameters": [
|
|
7466
|
+
{
|
|
7467
|
+
"schema": {
|
|
7468
|
+
"type": "string",
|
|
7469
|
+
"example": "clx1234567890"
|
|
7470
|
+
},
|
|
7471
|
+
"required": true,
|
|
7472
|
+
"name": "id",
|
|
7473
|
+
"in": "path"
|
|
7474
|
+
}
|
|
7475
|
+
],
|
|
7476
|
+
"requestBody": {
|
|
7477
|
+
"required": true,
|
|
7478
|
+
"content": {
|
|
7479
|
+
"application/json": {
|
|
7480
|
+
"schema": {
|
|
7481
|
+
"$ref": "#/components/schemas/GithubInstallationReposBody"
|
|
7482
|
+
}
|
|
7483
|
+
}
|
|
7484
|
+
}
|
|
7485
|
+
},
|
|
7486
|
+
"responses": {
|
|
7487
|
+
"200": {
|
|
7488
|
+
"description": "Repos added",
|
|
7489
|
+
"content": {
|
|
7490
|
+
"application/json": {
|
|
7491
|
+
"schema": {
|
|
7492
|
+
"$ref": "#/components/schemas/GithubInstallationReposChange"
|
|
7493
|
+
}
|
|
7494
|
+
}
|
|
7495
|
+
}
|
|
7496
|
+
},
|
|
7497
|
+
"401": {
|
|
7498
|
+
"description": "Unauthorized",
|
|
7499
|
+
"content": {
|
|
7500
|
+
"application/json": {
|
|
7501
|
+
"schema": {
|
|
7502
|
+
"$ref": "#/components/schemas/Error"
|
|
7503
|
+
}
|
|
7504
|
+
}
|
|
7505
|
+
}
|
|
7506
|
+
},
|
|
7507
|
+
"403": {
|
|
7508
|
+
"description": "Platform admin required",
|
|
7509
|
+
"content": {
|
|
7510
|
+
"application/json": {
|
|
7511
|
+
"schema": {
|
|
7512
|
+
"$ref": "#/components/schemas/Error"
|
|
7513
|
+
}
|
|
7514
|
+
}
|
|
7515
|
+
}
|
|
7516
|
+
},
|
|
7517
|
+
"404": {
|
|
7518
|
+
"description": "Agent not found",
|
|
7519
|
+
"content": {
|
|
7520
|
+
"application/json": {
|
|
7521
|
+
"schema": {
|
|
7522
|
+
"$ref": "#/components/schemas/Error"
|
|
7523
|
+
}
|
|
7524
|
+
}
|
|
7525
|
+
}
|
|
7526
|
+
},
|
|
7527
|
+
"409": {
|
|
7528
|
+
"description": "Agent App not installed on the org",
|
|
7529
|
+
"content": {
|
|
7530
|
+
"application/json": {
|
|
7531
|
+
"schema": {
|
|
7532
|
+
"$ref": "#/components/schemas/Error"
|
|
7533
|
+
}
|
|
7534
|
+
}
|
|
7535
|
+
}
|
|
7536
|
+
},
|
|
7537
|
+
"422": {
|
|
7538
|
+
"description": "Agent has no GH_APP_ID (its own GitHub App is not set up)",
|
|
7539
|
+
"content": {
|
|
7540
|
+
"application/json": {
|
|
7541
|
+
"schema": {
|
|
7542
|
+
"$ref": "#/components/schemas/Error"
|
|
7543
|
+
}
|
|
7544
|
+
}
|
|
7545
|
+
}
|
|
7546
|
+
},
|
|
7547
|
+
"502": {
|
|
7548
|
+
"description": "GitHub unavailable or refused",
|
|
7549
|
+
"content": {
|
|
7550
|
+
"application/json": {
|
|
7551
|
+
"schema": {
|
|
7552
|
+
"$ref": "#/components/schemas/Error"
|
|
7553
|
+
}
|
|
7554
|
+
}
|
|
7555
|
+
}
|
|
7556
|
+
},
|
|
7557
|
+
"503": {
|
|
7558
|
+
"description": "GitHub Apps are not configured",
|
|
7559
|
+
"content": {
|
|
7560
|
+
"application/json": {
|
|
7561
|
+
"schema": {
|
|
7562
|
+
"$ref": "#/components/schemas/Error"
|
|
7563
|
+
}
|
|
7564
|
+
}
|
|
7565
|
+
}
|
|
7566
|
+
}
|
|
7567
|
+
}
|
|
7568
|
+
}
|
|
7569
|
+
},
|
|
7570
|
+
"/agents/{id}/github-installation/repos/remove": {
|
|
7571
|
+
"post": {
|
|
7572
|
+
"summary": "Remove repos from the agent App's installation",
|
|
7573
|
+
"description": "Platform-admin only. Revokes the agent's own GitHub App installation access to the named repos, with no plan step; the agent's configured repos are not changed. Writes one audit entry (GitHubReconcileAudit, planHash `direct:remove`) recording the caller and repos. Same errors as the add route.",
|
|
7574
|
+
"parameters": [
|
|
7575
|
+
{
|
|
7576
|
+
"schema": {
|
|
7577
|
+
"type": "string",
|
|
7578
|
+
"example": "clx1234567890"
|
|
7579
|
+
},
|
|
7580
|
+
"required": true,
|
|
7581
|
+
"name": "id",
|
|
7582
|
+
"in": "path"
|
|
7583
|
+
}
|
|
7584
|
+
],
|
|
7585
|
+
"requestBody": {
|
|
7586
|
+
"required": true,
|
|
7587
|
+
"content": {
|
|
7588
|
+
"application/json": {
|
|
7589
|
+
"schema": {
|
|
7590
|
+
"$ref": "#/components/schemas/GithubInstallationReposBody"
|
|
7591
|
+
}
|
|
7592
|
+
}
|
|
7593
|
+
}
|
|
7594
|
+
},
|
|
7595
|
+
"responses": {
|
|
7596
|
+
"200": {
|
|
7597
|
+
"description": "Repos removed",
|
|
7598
|
+
"content": {
|
|
7599
|
+
"application/json": {
|
|
7600
|
+
"schema": {
|
|
7601
|
+
"$ref": "#/components/schemas/GithubInstallationReposChange"
|
|
7602
|
+
}
|
|
7603
|
+
}
|
|
7604
|
+
}
|
|
7605
|
+
},
|
|
7606
|
+
"401": {
|
|
7607
|
+
"description": "Unauthorized",
|
|
7608
|
+
"content": {
|
|
7609
|
+
"application/json": {
|
|
7610
|
+
"schema": {
|
|
7611
|
+
"$ref": "#/components/schemas/Error"
|
|
7612
|
+
}
|
|
7613
|
+
}
|
|
7614
|
+
}
|
|
7615
|
+
},
|
|
7616
|
+
"403": {
|
|
7617
|
+
"description": "Platform admin required",
|
|
7618
|
+
"content": {
|
|
7619
|
+
"application/json": {
|
|
7620
|
+
"schema": {
|
|
7621
|
+
"$ref": "#/components/schemas/Error"
|
|
7622
|
+
}
|
|
7623
|
+
}
|
|
7624
|
+
}
|
|
7625
|
+
},
|
|
7626
|
+
"404": {
|
|
7627
|
+
"description": "Agent not found",
|
|
7628
|
+
"content": {
|
|
7629
|
+
"application/json": {
|
|
7630
|
+
"schema": {
|
|
7631
|
+
"$ref": "#/components/schemas/Error"
|
|
7632
|
+
}
|
|
7633
|
+
}
|
|
7634
|
+
}
|
|
7635
|
+
},
|
|
7636
|
+
"409": {
|
|
7637
|
+
"description": "Agent App not installed on the org",
|
|
7638
|
+
"content": {
|
|
7639
|
+
"application/json": {
|
|
7640
|
+
"schema": {
|
|
7641
|
+
"$ref": "#/components/schemas/Error"
|
|
7642
|
+
}
|
|
7643
|
+
}
|
|
7644
|
+
}
|
|
7645
|
+
},
|
|
7646
|
+
"422": {
|
|
7647
|
+
"description": "Agent has no GH_APP_ID (its own GitHub App is not set up)",
|
|
7648
|
+
"content": {
|
|
7649
|
+
"application/json": {
|
|
7650
|
+
"schema": {
|
|
7651
|
+
"$ref": "#/components/schemas/Error"
|
|
7652
|
+
}
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
},
|
|
7656
|
+
"502": {
|
|
7657
|
+
"description": "GitHub unavailable or refused",
|
|
7658
|
+
"content": {
|
|
7659
|
+
"application/json": {
|
|
7660
|
+
"schema": {
|
|
7661
|
+
"$ref": "#/components/schemas/Error"
|
|
7662
|
+
}
|
|
7663
|
+
}
|
|
7664
|
+
}
|
|
7665
|
+
},
|
|
7666
|
+
"503": {
|
|
7667
|
+
"description": "GitHub Apps are not configured",
|
|
7668
|
+
"content": {
|
|
7669
|
+
"application/json": {
|
|
7670
|
+
"schema": {
|
|
7671
|
+
"$ref": "#/components/schemas/Error"
|
|
7672
|
+
}
|
|
7673
|
+
}
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7678
|
+
},
|
|
7286
7679
|
"/agents/{id}/config": {
|
|
7287
7680
|
"get": {
|
|
7288
7681
|
"tags": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.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.135.0",
|
|
45
|
-
"@app-vitals/agent-lib": "1.
|
|
45
|
+
"@app-vitals/agent-lib": "1.32.0",
|
|
46
46
|
"@hono/zod-openapi": "^1.0.0",
|
|
47
47
|
"@prisma/adapter-pg": "^7.10.0",
|
|
48
48
|
"@prisma/client": "^7.10.0",
|
package/src/admin-boot.ts
CHANGED
|
@@ -99,12 +99,16 @@ import { CronRunNowService } from "./cron-run-now.ts";
|
|
|
99
99
|
import { parseCronRunNowConfig } from "./cron-run-now-config.ts";
|
|
100
100
|
import { CronRunTranscriptService } from "./cron-run-transcripts.ts";
|
|
101
101
|
import { isDevAuthAllowed } from "./dev-auth-guard.ts";
|
|
102
|
+
import { HttpGithubAppProvisioningClient } from "./github-app-provisioning-client.ts";
|
|
102
103
|
import {
|
|
103
104
|
createGithubAccessPreview,
|
|
104
105
|
createGithubEnterpriseApp,
|
|
105
106
|
} from "./github-enterprise-api.ts";
|
|
106
107
|
import { GitHubEnterpriseAppService } from "./github-enterprise-apps.ts";
|
|
107
|
-
import {
|
|
108
|
+
import {
|
|
109
|
+
createGithubInstallationRepos,
|
|
110
|
+
createGithubReconcile,
|
|
111
|
+
} from "./github-reconcile-wiring.ts";
|
|
108
112
|
import { HttpGoogleAuthClient } from "./google-auth-client.ts";
|
|
109
113
|
import { HttpChatClient } from "./http-chat-client.ts";
|
|
110
114
|
import { HttpOktaAuthClient } from "./okta-auth-client.ts";
|
|
@@ -466,10 +470,28 @@ export async function startAdmin(
|
|
|
466
470
|
prisma,
|
|
467
471
|
makeStrictTokenCrypto(),
|
|
468
472
|
);
|
|
473
|
+
const githubAccessPreview = createGithubAccessPreview({
|
|
474
|
+
appService: githubEnterpriseAppService,
|
|
475
|
+
});
|
|
476
|
+
// GHE-3.9: the reconcile routes' service, with the extension's optional
|
|
477
|
+
// open-work port. Each agent's App id is read from its own stored GH_APP_ID.
|
|
478
|
+
const githubReconcile = createGithubReconcile({
|
|
479
|
+
prisma,
|
|
480
|
+
appService: githubEnterpriseAppService,
|
|
481
|
+
access: githubAccessPreview,
|
|
482
|
+
agentEnv: agentEnvService,
|
|
483
|
+
openWork: resolvedExtensions.openWork,
|
|
484
|
+
});
|
|
485
|
+
const githubInstallationRepos = createGithubInstallationRepos({
|
|
486
|
+
prisma,
|
|
487
|
+
appService: githubEnterpriseAppService,
|
|
488
|
+
access: githubAccessPreview,
|
|
489
|
+
agentEnv: agentEnvService,
|
|
490
|
+
});
|
|
469
491
|
const adminApiApp = createAdminApp({
|
|
470
|
-
githubAccessPreview
|
|
471
|
-
|
|
472
|
-
|
|
492
|
+
githubAccessPreview,
|
|
493
|
+
githubReconcile,
|
|
494
|
+
githubInstallationRepos,
|
|
473
495
|
agentService,
|
|
474
496
|
agentEnvService,
|
|
475
497
|
agentCronJobService,
|
package/src/admin-extension.ts
CHANGED
|
@@ -62,6 +62,7 @@ import type { AdminDeps, parseAdminApiKeys } from "./agents-api.ts";
|
|
|
62
62
|
import type { AgentPhaseMethodologyServiceLike } from "./api.ts";
|
|
63
63
|
import type { createCallerScopeResolver } from "./caller-scope.ts";
|
|
64
64
|
import type { PushService } from "./push-service.ts";
|
|
65
|
+
import type { OpenWorkPort } from "./reconcile-open-work.ts";
|
|
65
66
|
import type { ServiceIntegration } from "./service-integration.ts";
|
|
66
67
|
import type {
|
|
67
68
|
SpecialtyDefaults,
|
|
@@ -128,6 +129,12 @@ export interface AdminExtensionServices {
|
|
|
128
129
|
* the runtime app omits the field.
|
|
129
130
|
*/
|
|
130
131
|
agentPhaseMethodologyService?: AgentPhaseMethodologyServiceLike;
|
|
132
|
+
/**
|
|
133
|
+
* Supplies the GitHub reconcile's open-work port (GHE-3.9): plan lists the
|
|
134
|
+
* open work on repos it would remove and apply blocks it. Absent from every
|
|
135
|
+
* extension → nothing is listed or blocked.
|
|
136
|
+
*/
|
|
137
|
+
openWork?: OpenWorkPort;
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
export interface AgentDetailCardContext {
|
|
@@ -212,6 +219,7 @@ export interface ResolvedAdminExtensions {
|
|
|
212
219
|
apiDeps: Partial<AdminDeps>;
|
|
213
220
|
uiDeps: Partial<AdminUIDeps>;
|
|
214
221
|
agentPhaseMethodologyService?: AgentPhaseMethodologyServiceLike;
|
|
222
|
+
openWork?: OpenWorkPort;
|
|
215
223
|
apiRoutes: AdminRouteContribution[];
|
|
216
224
|
adminUiRoutes: AdminRouteContribution[];
|
|
217
225
|
agentDetailCards: AgentDetailCardSlot[];
|
|
@@ -238,8 +246,13 @@ export function resolveAdminExtensions(
|
|
|
238
246
|
.map((s) => s.agentPhaseMethodologyService)
|
|
239
247
|
.filter((svc) => svc !== undefined)
|
|
240
248
|
.at(-1);
|
|
249
|
+
const openWork = services
|
|
250
|
+
.map((s) => s.openWork)
|
|
251
|
+
.filter((port) => port !== undefined)
|
|
252
|
+
.at(-1);
|
|
241
253
|
return {
|
|
242
254
|
...(agentPhaseMethodologyService ? { agentPhaseMethodologyService } : {}),
|
|
255
|
+
...(openWork ? { openWork } : {}),
|
|
243
256
|
apiDeps: Object.assign({}, ...services.map((s) => s.api ?? {})),
|
|
244
257
|
uiDeps: Object.assign({}, ...services.map((s) => s.ui ?? {})),
|
|
245
258
|
apiRoutes,
|
|
@@ -18,12 +18,32 @@ import {
|
|
|
18
18
|
startBackgroundPasses,
|
|
19
19
|
withExtensionAgentTypes,
|
|
20
20
|
} from "./admin-extension.ts";
|
|
21
|
+
import type { OpenWorkPort } from "./reconcile-open-work.ts";
|
|
21
22
|
|
|
22
23
|
// The seam only hands the context through to hooks, so an opaque stand-in is
|
|
23
24
|
// enough — no hook under test reads from it.
|
|
24
25
|
const ctx = { env: {} } as unknown as AdminExtensionContext;
|
|
25
26
|
|
|
26
27
|
describe("resolveAdminExtensions", () => {
|
|
28
|
+
it("openWork: absent from every extension is omitted; the last supplier wins", () => {
|
|
29
|
+
const mk = (id: string): OpenWorkPort => ({
|
|
30
|
+
listOpenWork: async () => [{ id, repo: "acme/x" }],
|
|
31
|
+
blockOpenWork: async () => {},
|
|
32
|
+
});
|
|
33
|
+
expect("openWork" in resolveAdminExtensions([{}], ctx)).toBe(false);
|
|
34
|
+
const first = mk("first");
|
|
35
|
+
const last = mk("last");
|
|
36
|
+
const resolved = resolveAdminExtensions(
|
|
37
|
+
[
|
|
38
|
+
{ services: () => ({ openWork: first }) },
|
|
39
|
+
{ services: () => ({}) },
|
|
40
|
+
{ services: () => ({ openWork: last }) },
|
|
41
|
+
],
|
|
42
|
+
ctx,
|
|
43
|
+
);
|
|
44
|
+
expect(resolved.openWork).toBe(last);
|
|
45
|
+
});
|
|
46
|
+
|
|
27
47
|
it("no extensions resolves to empty contributions", () => {
|
|
28
48
|
expect(resolveAdminExtensions([], ctx)).toEqual({
|
|
29
49
|
apiDeps: {},
|