@intentius/behold 0.29.57 → 0.30.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/AGENTS.md +388 -57
- package/README.md +67 -50
- package/demos.json +1 -1
- package/dist/cli.js +9958 -3080
- package/example-choudoufu-estate/chant.workspace.json +1 -1
- package/example-terraform-estate/README.md +10 -10
- package/example-terraform-estate/chant.workspace.json +1 -1
- package/example-three-cloud/README.md +17 -9
- package/example-three-cloud/aws/chant.config.ts +1 -1
- package/example-three-cloud/aws/site.component.ts +13 -0
- package/example-three-cloud/azure/chant.config.ts +1 -1
- package/example-three-cloud/azure/src/site.component.ts +13 -0
- package/example-three-cloud/azure/src/site.ts +5 -7
- package/example-three-cloud/dns/chant.config.ts +1 -1
- package/example-three-cloud/dns/src/records.component.ts +14 -0
- package/example-three-cloud/dns/src/route53.ts +4 -5
- package/example-three-cloud/gcp/chant.config.ts +1 -1
- package/example-three-cloud/gcp/src/site.component.ts +13 -0
- package/example-three-cloud/gcp/src/site.ts +7 -7
- package/example-three-cloud/package-lock.json +19 -19
- package/example-three-cloud/package.json +4 -4
- package/example-three-cloud/scripts/front-door.ts +89 -15
- package/package.json +10 -11
- package/web/agent-move.js +60 -0
- package/web/agent-move.test.js +55 -0
- package/web/app.js +622 -79
- package/web/dots-lod.js +1 -1
- package/web/embed.d.ts +3 -0
- package/web/embed.js +5 -3
- package/web/embed.test.js +8 -0
- package/web/index.html +64 -9
- package/web/layout-store.js +3 -3
- package/web/panel.js +28 -4
- package/web/release.js +6 -4
- package/web/release.test.js +2 -2
- package/web/search-view.d.ts +27 -0
- package/web/search-view.js +213 -0
- package/web/search-view.test.js +144 -0
- package/web/shot-frame.d.ts +5 -0
- package/web/shot-frame.js +116 -0
- package/web/shot-frame.test.js +90 -0
- package/web/themes.js +1 -1
- package/web/view-url.d.ts +18 -0
- package/web/view-url.js +153 -6
- package/web/view-url.test.js +72 -1
- package/example-three-cloud/azure/composites/container-app-site.ts +0 -77
- package/example-three-cloud/dns/composites/latency-entry.ts +0 -73
- package/example-three-cloud/gcp/composites/public-cloud-run.ts +0 -102
|
@@ -83,25 +83,25 @@ HCL.
|
|
|
83
83
|
|
|
84
84
|
## It needs the lexicon
|
|
85
85
|
|
|
86
|
-
behold parses no HCL
|
|
87
|
-
`@intentius/chant-lexicon-terraform`,
|
|
88
|
-
a ~1.8 MB wasm blob. Both are
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
behold parses no HCL itself. The reading goes through
|
|
87
|
+
`@intentius/chant-lexicon-terraform`, and chant parses the HCL with
|
|
88
|
+
`@cdktn/hcl2json`, a ~1.8 MB wasm blob. Both are dependencies of behold
|
|
89
|
+
(#909), so `npx @intentius/behold demo terraform-estate` needs nothing else.
|
|
90
|
+
|
|
91
|
+
An install that skipped or pruned them makes the demo refuse before it serves,
|
|
92
|
+
naming both packages, the ranges behold declares, where it looked, and the line
|
|
93
|
+
that puts them back:
|
|
91
94
|
|
|
92
95
|
```sh
|
|
93
|
-
npm install
|
|
96
|
+
npm install @intentius/chant-lexicon-terraform@^0.124.51 @cdktn/hcl2json@^0.24.0
|
|
94
97
|
```
|
|
95
98
|
|
|
96
|
-
Without them the demo refuses before it serves, naming both packages, the
|
|
97
|
-
ranges behold declares, and where it looked.
|
|
98
|
-
|
|
99
99
|
The estate is a declared chant workspace, and chant reads a member's kind from
|
|
100
100
|
the packages `chant.workspace.json` pins, looked up from the workspace's own
|
|
101
101
|
`node_modules` at exactly the pinned version. A demo copy has no
|
|
102
102
|
`node_modules`, so `behold demo` links the lexicon behold resolved into the
|
|
103
103
|
copy and sets the copy's pin to that version (#484). It says so as it loads:
|
|
104
|
-
`linked @intentius/chant-lexicon-terraform 0.124.
|
|
104
|
+
`linked @intentius/chant-lexicon-terraform 0.124.38 into the copy`. Serving
|
|
105
105
|
your own declared workspace is different: install the pinned lexicon in its
|
|
106
106
|
root, the way `chant workspace check` asks.
|
|
107
107
|
|
|
@@ -5,16 +5,24 @@ the floci emulators. It is behold's `three-cloud` demo, and its exported page
|
|
|
5
5
|
asks one question: turn Azure off, and where does traffic go?
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
chant.workspace.json
|
|
9
|
-
dns/src/route53.ts
|
|
10
|
-
dns/ops/front-door.op.ts
|
|
11
|
-
aws/src/site.ts
|
|
12
|
-
azure/src/site.ts
|
|
13
|
-
gcp/src/site.ts
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
chant.workspace.json the workspace: dns, aws, azure, gcp
|
|
9
|
+
dns/src/route53.ts hosted zone, and a latency entry per cloud (HostnameEntry, AddressEntry)
|
|
10
|
+
dns/ops/front-door.op.ts the Op that rebuilds the page
|
|
11
|
+
aws/src/site.ts ECS on Fargate behind a load balancer (FargateAlb)
|
|
12
|
+
azure/src/site.ts a Container Apps site and its network (ContainerAppSite, ContainerAppNetwork)
|
|
13
|
+
gcp/src/site.ts Cloud Run behind a global load balancer (PublicCloudRun, PrivateEgressNetwork)
|
|
14
|
+
*.component.ts one component per member: how it deploys
|
|
15
|
+
(aws/ at its root, beside its stacks; the others in src/)
|
|
16
|
+
scripts/emulators-up.sh boots floci, floci-az and floci-gcp
|
|
17
|
+
scripts/front-door.ts the Op's steps: apply, turn Azure off, wait, export
|
|
16
18
|
```
|
|
17
19
|
|
|
20
|
+
The composites are the lexicons' own. Each member is one component. aws
|
|
21
|
+
deploys with `cfn-deploy`. azure and gcp run their member's apply from
|
|
22
|
+
`scripts/front-door.ts` (`apply-azure`, `apply-gcp`) until their lexicons have
|
|
23
|
+
deploy steps of their own (chant#4273). dns runs `apply-dns`, which points
|
|
24
|
+
each health check at the emulator that answers for it.
|
|
25
|
+
|
|
18
26
|
Each cloud publishes its endpoint with `output()` and `dns` reads it as a
|
|
19
27
|
parameter of the same name.
|
|
20
28
|
|
|
@@ -35,4 +43,4 @@ npx serve export
|
|
|
35
43
|
|
|
36
44
|
`cd dns && npx chant run front-door` runs the same steps as an Op.
|
|
37
45
|
|
|
38
|
-
Needs chant 0.124.
|
|
46
|
+
Needs chant 0.124.39 or newer.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { phase, type Component } from "@intentius/chant/components";
|
|
2
|
+
|
|
3
|
+
// The aws member as one component: build its template, then apply it as the
|
|
4
|
+
// stack three-cloud-aws, the name the dns member reads its output from.
|
|
5
|
+
export const site: Component = {
|
|
6
|
+
name: "site",
|
|
7
|
+
archetype: "infra",
|
|
8
|
+
dependsOn: [],
|
|
9
|
+
deploy: [
|
|
10
|
+
phase("Build", [{ kind: "shell", cmd: "npx chant build src -o dist/site.json", reason: "the template cfn-deploy applies is this member's own build" }]),
|
|
11
|
+
phase("Apply", [{ kind: "cfn-deploy", stack: "three-cloud-aws", template: "dist/site.json" }]),
|
|
12
|
+
],
|
|
13
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { lexicons: ["azure"], sourceDir: "src", environments: ["local"] };
|
|
1
|
+
export default { lexicons: ["azure"], sourceDir: "src", environments: [{ name: "local", endpoint: "http://localhost:4577" }] };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { phase, type Component } from "@intentius/chant/components";
|
|
2
|
+
|
|
3
|
+
// The azure member as one component: build its ARM template, then deploy it
|
|
4
|
+
// into the resource group named after the environment.
|
|
5
|
+
export const site: Component = {
|
|
6
|
+
name: "site",
|
|
7
|
+
archetype: "infra",
|
|
8
|
+
dependsOn: [],
|
|
9
|
+
deploy: [
|
|
10
|
+
phase("Build", [{ kind: "shell", cmd: "npx chant build src -o dist/site.json", reason: "the template arm-deploy applies is this member's own build" }]),
|
|
11
|
+
phase("Apply", [{ kind: "arm-deploy", template: "dist/site.json", resourceGroup: "local", location: "westeurope", noRollback: "a failed deploy is fixed forward by deploying the template again" }]),
|
|
12
|
+
],
|
|
13
|
+
};
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { output } from "@intentius/chant-lexicon-azure";
|
|
2
|
-
import { ContainerAppNetwork, ContainerAppSite } from "../composites/container-app-site";
|
|
1
|
+
import { ContainerAppNetwork, ContainerAppSite, output } from "@intentius/chant-lexicon-azure";
|
|
3
2
|
|
|
4
|
-
// The website on Azure Container Apps in West Europe, from
|
|
5
|
-
// composites
|
|
6
|
-
// in it.
|
|
3
|
+
// The website on Azure Container Apps in West Europe, from the lexicon's
|
|
4
|
+
// composites: its network, and the site in it.
|
|
7
5
|
export const network = ContainerAppNetwork({ name: "three-cloud", location: "westeurope", addressSpace: "10.40.0.0/16", subnetPrefix: "10.40.0.0/23" });
|
|
8
6
|
|
|
9
7
|
export const web = ContainerAppSite({
|
|
10
8
|
name: "three-cloud",
|
|
11
9
|
app: "web",
|
|
12
10
|
location: "westeurope",
|
|
13
|
-
|
|
11
|
+
subnetId: network.subnet.id as unknown as string,
|
|
14
12
|
image: "traefik/whoami:v1.10",
|
|
15
13
|
port: 80,
|
|
16
14
|
replicas: 1,
|
|
17
15
|
});
|
|
18
16
|
|
|
19
17
|
// The dns member reads this as its `azureEndpoint` parameter.
|
|
20
|
-
export const azureEndpoint = output(web.
|
|
18
|
+
export const azureEndpoint = output(web.containerApp.configuration_ingress_fqdn, "azureEndpoint");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { lexicons: ["aws"], sourceDir: "src", environments: ["local"] };
|
|
1
|
+
export default { lexicons: ["aws"], sourceDir: "src", environments: [{ name: "local", endpoint: "http://localhost:4566" }] };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { phase, type Component } from "@intentius/chant/components";
|
|
2
|
+
|
|
3
|
+
// The dns member as one component, applied after the three sites: its
|
|
4
|
+
// parameters are the endpoints they publish. The step is the emulator apply in
|
|
5
|
+
// scripts/front-door.ts, which reads those endpoints from what is applied and
|
|
6
|
+
// points each health check at the emulator that answers for it.
|
|
7
|
+
export const records: Component = {
|
|
8
|
+
name: "records",
|
|
9
|
+
archetype: "infra",
|
|
10
|
+
dependsOn: [],
|
|
11
|
+
deploy: [
|
|
12
|
+
phase("Apply", [{ kind: "shell", cmd: "npx tsx ../scripts/front-door.ts apply-dns", reason: "the checks probe emulator addresses that only exist on this machine" }]),
|
|
13
|
+
],
|
|
14
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { HostedZone, Parameter } from "@intentius/chant-lexicon-aws";
|
|
2
|
-
import { AddressEntry, HostnameEntry } from "../composites/latency-entry";
|
|
1
|
+
import { AddressEntry, HostedZone, HostnameEntry, Parameter } from "@intentius/chant-lexicon-aws";
|
|
3
2
|
|
|
4
3
|
// Route 53 in front of the three clouds: one latency record per cloud, each
|
|
5
4
|
// guarded by a health check on that cloud's endpoint. A record whose check
|
|
@@ -23,9 +22,9 @@ export const awsEndpoint = new Parameter("String", { description: "The aws membe
|
|
|
23
22
|
export const azureEndpoint = new Parameter("String", { description: "The azure member's Container App hostname" });
|
|
24
23
|
export const gcpEndpoint = new Parameter("String", { description: "The gcp member's load balancer IP address" });
|
|
25
24
|
|
|
26
|
-
// One entry per cloud, from
|
|
27
|
-
//
|
|
28
|
-
//
|
|
25
|
+
// One entry per cloud, from the lexicon's composites. Azure (West Europe)
|
|
26
|
+
// answers as eu-west-1 and GCP (Tokyo) as ap-northeast-1, since latency
|
|
27
|
+
// records name AWS regions.
|
|
29
28
|
const endpoint = (p: Parameter) => p as unknown as string;
|
|
30
29
|
export const aws = HostnameEntry({ zoneId: zone.Id, name: NAME, id: "aws", region: "us-east-1", endpoint: endpoint(awsEndpoint) });
|
|
31
30
|
export const azure = HostnameEntry({ zoneId: zone.Id, name: NAME, id: "azure", region: "eu-west-1", endpoint: endpoint(azureEndpoint) });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// The project every gcp resource builds, applies and is read in.
|
|
2
|
-
export default { lexicons: ["gcp"], sourceDir: "src", environments: ["local"], gcp: { project: "three-cloud" } };
|
|
2
|
+
export default { lexicons: ["gcp"], sourceDir: "src", environments: [{ name: "local", endpoint: "http://localhost:4588" }], gcp: { project: "three-cloud" } };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { phase, type Component } from "@intentius/chant/components";
|
|
2
|
+
|
|
3
|
+
// The gcp member as one component: build its Config Connector manifest, then
|
|
4
|
+
// apply it into the project.
|
|
5
|
+
export const site: Component = {
|
|
6
|
+
name: "site",
|
|
7
|
+
archetype: "infra",
|
|
8
|
+
dependsOn: [],
|
|
9
|
+
deploy: [
|
|
10
|
+
phase("Build", [{ kind: "shell", cmd: "npx chant build src -o dist/site.yaml", reason: "the manifest gcp-apply applies is this member's own build" }]),
|
|
11
|
+
phase("Apply", [{ kind: "gcp-apply", manifest: "dist/site.yaml", project: "three-cloud", noRollback: "a failed apply is fixed forward by applying the manifest again" }]),
|
|
12
|
+
],
|
|
13
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { output } from "@intentius/chant-lexicon-gcp";
|
|
2
|
-
import { PrivateEgressNetwork, PublicCloudRun } from "../composites/public-cloud-run";
|
|
1
|
+
import { PrivateEgressNetwork, PublicCloudRun, output } from "@intentius/chant-lexicon-gcp";
|
|
3
2
|
|
|
4
|
-
// The website on Cloud Run in Tokyo behind a global load balancer, from
|
|
5
|
-
//
|
|
6
|
-
// and the site that sends its egress into it.
|
|
3
|
+
// The website on Cloud Run in Tokyo behind a global load balancer, from the
|
|
4
|
+
// lexicon's composites: its network, and the site that sends its egress into it.
|
|
7
5
|
export const network = PrivateEgressNetwork({ name: "three-cloud", region: "asia-northeast1", subnetCidr: "10.30.0.0/24" });
|
|
8
6
|
|
|
9
7
|
export const web = PublicCloudRun({
|
|
10
8
|
name: "three-cloud",
|
|
11
|
-
|
|
9
|
+
projectId: "three-cloud",
|
|
12
10
|
region: "asia-northeast1",
|
|
13
11
|
vpc: network.vpc,
|
|
14
12
|
subnet: network.subnet,
|
|
15
13
|
image: "traefik/whoami:v1.10",
|
|
16
14
|
port: 80,
|
|
17
|
-
|
|
15
|
+
frontendPort: 80,
|
|
16
|
+
minInstanceCount: 1,
|
|
17
|
+
maxInstanceCount: 1,
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
// The dns member reads this as its `gcpEndpoint` parameter: the load
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"": {
|
|
7
7
|
"name": "behold-example-three-cloud",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@intentius/chant": "^0.124.
|
|
10
|
-
"@intentius/chant-lexicon-aws": "^0.124.
|
|
11
|
-
"@intentius/chant-lexicon-azure": "^0.124.
|
|
12
|
-
"@intentius/chant-lexicon-gcp": "^0.124.
|
|
9
|
+
"@intentius/chant": "^0.124.51",
|
|
10
|
+
"@intentius/chant-lexicon-aws": "^0.124.51",
|
|
11
|
+
"@intentius/chant-lexicon-azure": "^0.124.51",
|
|
12
|
+
"@intentius/chant-lexicon-gcp": "^0.124.51"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"node_modules/@dagrejs/dagre": {
|
|
@@ -444,9 +444,9 @@
|
|
|
444
444
|
}
|
|
445
445
|
},
|
|
446
446
|
"node_modules/@intentius/chant": {
|
|
447
|
-
"version": "0.124.
|
|
448
|
-
"resolved": "https://registry.npmjs.org/@intentius/chant/-/chant-0.124.
|
|
449
|
-
"integrity": "sha512-
|
|
447
|
+
"version": "0.124.51",
|
|
448
|
+
"resolved": "https://registry.npmjs.org/@intentius/chant/-/chant-0.124.51.tgz",
|
|
449
|
+
"integrity": "sha512-68nNpD7jvpqIjsJSTbIeudeyN0SoYr0+pVrXp2Wc2wVtYWdtmam3O7ANDBBDYWRnWT9I0vuo/L/urZB/EBtERg==",
|
|
450
450
|
"license": "Apache-2.0",
|
|
451
451
|
"dependencies": {
|
|
452
452
|
"@dagrejs/dagre": "^3.0.0",
|
|
@@ -473,34 +473,34 @@
|
|
|
473
473
|
}
|
|
474
474
|
},
|
|
475
475
|
"node_modules/@intentius/chant-lexicon-aws": {
|
|
476
|
-
"version": "0.124.
|
|
477
|
-
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-aws/-/chant-lexicon-aws-0.124.
|
|
478
|
-
"integrity": "sha512-
|
|
476
|
+
"version": "0.124.51",
|
|
477
|
+
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-aws/-/chant-lexicon-aws-0.124.51.tgz",
|
|
478
|
+
"integrity": "sha512-IgiZ7RTTlaVSNocHwhd1JwRc/VYrL6Eylmz9Y0ueedRpnRd/WgQRdpSyII2qE5Qh2NKUUigLJvSc9J0rC9ONeA==",
|
|
479
479
|
"license": "Apache-2.0",
|
|
480
480
|
"dependencies": {
|
|
481
481
|
"fflate": "^0.8.2",
|
|
482
482
|
"js-yaml": "^4.3.1"
|
|
483
483
|
},
|
|
484
484
|
"peerDependencies": {
|
|
485
|
-
"@intentius/chant": "^0.124.
|
|
485
|
+
"@intentius/chant": "^0.124.51"
|
|
486
486
|
}
|
|
487
487
|
},
|
|
488
488
|
"node_modules/@intentius/chant-lexicon-azure": {
|
|
489
|
-
"version": "0.124.
|
|
490
|
-
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-azure/-/chant-lexicon-azure-0.124.
|
|
491
|
-
"integrity": "sha512
|
|
489
|
+
"version": "0.124.51",
|
|
490
|
+
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-azure/-/chant-lexicon-azure-0.124.51.tgz",
|
|
491
|
+
"integrity": "sha512-+oaLuw08hm0mQw7DdcezUrStY8YgzOTwCF/5n3aoJEJt2n2p70iY9xLa/4UEk4u+mG7pb4B8QPoSHzSn3fi+lA==",
|
|
492
492
|
"license": "Apache-2.0",
|
|
493
493
|
"dependencies": {
|
|
494
494
|
"fflate": "^0.8.2"
|
|
495
495
|
},
|
|
496
496
|
"peerDependencies": {
|
|
497
|
-
"@intentius/chant": "^0.124.
|
|
497
|
+
"@intentius/chant": "^0.124.51"
|
|
498
498
|
}
|
|
499
499
|
},
|
|
500
500
|
"node_modules/@intentius/chant-lexicon-gcp": {
|
|
501
|
-
"version": "0.124.
|
|
502
|
-
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-gcp/-/chant-lexicon-gcp-0.124.
|
|
503
|
-
"integrity": "sha512-
|
|
501
|
+
"version": "0.124.51",
|
|
502
|
+
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-gcp/-/chant-lexicon-gcp-0.124.51.tgz",
|
|
503
|
+
"integrity": "sha512-AthygbSUsL0ZlYQk13UA1tu1SHJ0AoZGZrFdt5NSj8SVWjQx2waszDz2wjxdvgc/Cfw47dJF92Yv3NHGV/JO4Q==",
|
|
504
504
|
"license": "Apache-2.0",
|
|
505
505
|
"dependencies": {
|
|
506
506
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -508,7 +508,7 @@
|
|
|
508
508
|
"js-yaml": "^4.3.1"
|
|
509
509
|
},
|
|
510
510
|
"peerDependencies": {
|
|
511
|
-
"@intentius/chant": "^0.124.
|
|
511
|
+
"@intentius/chant": "^0.124.51"
|
|
512
512
|
}
|
|
513
513
|
},
|
|
514
514
|
"node_modules/@types/js-yaml": {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"front-door": "tsx scripts/front-door.ts all --out export"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@intentius/chant": "^0.124.
|
|
12
|
-
"@intentius/chant-lexicon-aws": "^0.124.
|
|
13
|
-
"@intentius/chant-lexicon-azure": "^0.124.
|
|
14
|
-
"@intentius/chant-lexicon-gcp": "^0.124.
|
|
11
|
+
"@intentius/chant": "^0.124.51",
|
|
12
|
+
"@intentius/chant-lexicon-aws": "^0.124.51",
|
|
13
|
+
"@intentius/chant-lexicon-azure": "^0.124.51",
|
|
14
|
+
"@intentius/chant-lexicon-gcp": "^0.124.51"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -3,21 +3,29 @@
|
|
|
3
3
|
* turn Azure off, wait for Route 53 to notice, and export the page.
|
|
4
4
|
*
|
|
5
5
|
* tsx scripts/front-door.ts all --out <dir> every step below, in order
|
|
6
|
-
* tsx scripts/front-door.ts apply
|
|
7
|
-
*
|
|
6
|
+
* tsx scripts/front-door.ts apply run each member's component (gcp, azure, aws, then dns)
|
|
7
|
+
* with `chant run --components`, in a copy of the
|
|
8
|
+
* workspace, and wait until `chant lifecycle health`
|
|
9
|
+
* reads azureCheck healthy
|
|
8
10
|
* tsx scripts/front-door.ts azure-off deactivate the Azure app's active revision
|
|
9
11
|
* tsx scripts/front-door.ts wait until azureCheck reads unhealthy
|
|
10
|
-
* tsx scripts/front-door.ts export --out <dir> behold export, opening on env local at the
|
|
12
|
+
* tsx scripts/front-door.ts export --out <dir> behold export, opening on env local at the components zoom
|
|
11
13
|
*
|
|
12
14
|
* dns/ops/front-door.op.ts runs the same steps as an Op's phases. The emulators
|
|
13
15
|
* are the ones `behold demo three-cloud` boots (chant-floci, chant-floci-az,
|
|
14
16
|
* chant-floci-gcp); FLOCI_CONTAINER, FLOCI_AZ_CONTAINER and FLOCI_GCP_CONTAINER
|
|
15
17
|
* name others, and AWS_ENDPOINT_URL, AZURE_ENDPOINT_URL and GCP_ENDPOINT_URL
|
|
16
18
|
* say where they answer.
|
|
19
|
+
*
|
|
20
|
+
* The components run in a copy of the workspace (.front-door/run) whose git
|
|
21
|
+
* remote is a bare repository beside it (.front-door/run-remote.git). chant
|
|
22
|
+
* records each component's release on that remote's chant/lifecycle branch, so
|
|
23
|
+
* the exported page shows a real last release on every component card, and
|
|
24
|
+
* nothing is pushed anywhere but this directory. The export reads the copy.
|
|
17
25
|
*/
|
|
18
26
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
19
|
-
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
20
|
-
import { dirname, join, resolve } from "node:path";
|
|
27
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
28
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
21
29
|
import { fileURLToPath } from "node:url";
|
|
22
30
|
import { awsApply, awsDelete } from "@intentius/chant-lexicon-aws/op/activities";
|
|
23
31
|
import { azApply } from "@intentius/chant-lexicon-azure/op/activities";
|
|
@@ -26,6 +34,9 @@ import { gcpApply } from "@intentius/chant-lexicon-gcp/op/activities";
|
|
|
26
34
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
27
35
|
const WORK = join(ROOT, ".front-door");
|
|
28
36
|
const CHANT = join(ROOT, "node_modules", ".bin", "chant");
|
|
37
|
+
/** The copy the components run in, and the bare repository it pushes its release records to. */
|
|
38
|
+
const RUN = join(WORK, "run");
|
|
39
|
+
const REMOTE = join(WORK, "run-remote.git");
|
|
29
40
|
|
|
30
41
|
const ENV = "local";
|
|
31
42
|
// The Azure resource group and the GCP project, as chant's live reads find them:
|
|
@@ -209,11 +220,57 @@ async function applyDns(endpoints: Record<string, string>, probes: Record<string
|
|
|
209
220
|
}
|
|
210
221
|
|
|
211
222
|
export async function apply(): Promise<void> {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
223
|
+
workspaceCopy();
|
|
224
|
+
runComponent("gcp", "site");
|
|
225
|
+
runComponent("azure", "site");
|
|
226
|
+
// A run before this one turned Azure off, and applying the same app again leaves its revision inactive.
|
|
227
|
+
await azureOn();
|
|
228
|
+
runComponent("aws", "site");
|
|
229
|
+
runComponent("dns", "records");
|
|
230
|
+
// Before anything is turned off, the check on Azure has to pass: that is
|
|
231
|
+
// what shows the checkers reach floci-az at all.
|
|
232
|
+
await waitFor("healthy");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** A git, as the copy's commits and pushes need it, with a test identity. */
|
|
236
|
+
function git(args: string[], cwd: string): void {
|
|
237
|
+
const r = spawnSync("git", args, { cwd, encoding: "utf8", env: { ...process.env, GIT_AUTHOR_NAME: "three-cloud demo", GIT_AUTHOR_EMAIL: "demo@three-cloud.test", GIT_COMMITTER_NAME: "three-cloud demo", GIT_COMMITTER_EMAIL: "demo@three-cloud.test" } });
|
|
238
|
+
if (r.status !== 0) throw new Refusal(`git ${args.join(" ")} failed: ${r.stderr || r.stdout}`);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** A fresh copy of the workspace, committed, with a bare repository beside it as its origin. */
|
|
242
|
+
function workspaceCopy(): void {
|
|
243
|
+
rmSync(RUN, { recursive: true, force: true });
|
|
244
|
+
rmSync(REMOTE, { recursive: true, force: true });
|
|
245
|
+
const skip = /(^|[/\\])(node_modules|export|\.front-door|dist|\.git)([/\\]|$)/;
|
|
246
|
+
// Entry by entry: a directory can't be copied into its own .front-door.
|
|
247
|
+
mkdirSync(RUN, { recursive: true });
|
|
248
|
+
for (const e of readdirSync(ROOT)) {
|
|
249
|
+
if (!skip.test(e)) cpSync(join(ROOT, e), join(RUN, e), { recursive: true, filter: (src) => !skip.test(relative(ROOT, src)) });
|
|
250
|
+
}
|
|
251
|
+
symlinkSync(join(ROOT, "node_modules"), join(RUN, "node_modules"));
|
|
252
|
+
git(["init", "-q", "-b", "main"], RUN);
|
|
253
|
+
git(["add", "-A"], RUN);
|
|
254
|
+
git(["commit", "-q", "-m", "three-cloud"], RUN);
|
|
255
|
+
git(["init", "-q", "--bare", REMOTE], WORK);
|
|
256
|
+
git(["remote", "add", "origin", REMOTE], RUN);
|
|
257
|
+
git(["push", "-q", "origin", "main"], RUN);
|
|
258
|
+
say(`run: the workspace copied to ${relative(ROOT, RUN)}, its releases recorded on ${relative(ROOT, REMOTE)}`);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** One member's component, through chant's own deploy steps, against the emulators. */
|
|
262
|
+
function runComponent(member: string, component: string): void {
|
|
263
|
+
say(`${member}: chant run --components ${component} --env ${ENV}`);
|
|
264
|
+
const r = spawnSync(join(RUN, "node_modules", ".bin", "chant"), ["run", "--components", component, "--env", ENV], {
|
|
265
|
+
cwd: join(RUN, member),
|
|
266
|
+
env: { ...childEnv, USER: "three-cloud-demo", GIT_AUTHOR_NAME: "three-cloud demo", GIT_AUTHOR_EMAIL: "demo@three-cloud.test", GIT_COMMITTER_NAME: "three-cloud demo", GIT_COMMITTER_EMAIL: "demo@three-cloud.test" },
|
|
267
|
+
stdio: "inherit",
|
|
268
|
+
});
|
|
269
|
+
if (r.status !== 0) throw new Refusal(`${member}: the ${component} component did not apply (exit ${r.status})`);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** The dns member, with the three endpoints the other members published. */
|
|
273
|
+
async function applyFrontDoor(gcp: string, azure: string, aws: { endpoint: string } | { refused: string }): Promise<void> {
|
|
217
274
|
// An aws stack that doesn't apply leaves its record pointing at a name that
|
|
218
275
|
// doesn't resolve and its check probing an address nothing answers on
|
|
219
276
|
// (192.0.2.1, kept for documentation by RFC 5737), so the page shows AWS
|
|
@@ -237,9 +294,16 @@ export async function apply(): Promise<void> {
|
|
|
237
294
|
},
|
|
238
295
|
);
|
|
239
296
|
say("dns: applied");
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** The dns member alone, reading the three endpoints from what is already applied (its component's step). */
|
|
300
|
+
async function applyFrontDoorFromLive(): Promise<void> {
|
|
301
|
+
const out = await stackOutputs("three-cloud-aws");
|
|
302
|
+
const app = await getJson(`${appUrl()}?api-version=2024-03-01`);
|
|
303
|
+
const azure = (app.properties as { configuration?: { ingress?: { fqdn?: string } } } | undefined)?.configuration?.ingress?.fqdn;
|
|
304
|
+
if (!azure) throw new Refusal("azure: the container app web has no ingress fqdn; apply the azure member first");
|
|
305
|
+
const addr = (await fetch(`${GCP}/compute/v1/projects/${GCP_PROJECT}/global/addresses/three-cloud-ip`).then((r) => (r.ok ? r.json() : {}))) as { address?: string };
|
|
306
|
+
await applyFrontDoor(addr.address ?? "192.0.2.1", azure, out.awsEndpoint ? { endpoint: out.awsEndpoint } : { refused: "the stack has no awsEndpoint output" });
|
|
243
307
|
}
|
|
244
308
|
|
|
245
309
|
// ---------------------------------------------------------------------------
|
|
@@ -309,7 +373,9 @@ export function exportPage(out: string): void {
|
|
|
309
373
|
// BEHOLD names the behold to run (a checkout's `tsx src/cli.ts`, say);
|
|
310
374
|
// by default it is the published one.
|
|
311
375
|
const behold = (process.env.BEHOLD ?? "npx --yes @intentius/behold").split(" ");
|
|
312
|
-
|
|
376
|
+
// The copy the components ran in, when there is one: its remote holds their release records.
|
|
377
|
+
const served = existsSync(join(RUN, "chant.workspace.json")) ? RUN : ROOT;
|
|
378
|
+
const args = [...behold.slice(1), "export", served, "--out", resolve(out), "--open-env", ENV, "--open-zoom", "components", "--note", NOTE];
|
|
313
379
|
say(`export: ${behold[0]} ${args.join(" ")}`);
|
|
314
380
|
const r = spawnSync(behold[0]!, args, { env: childEnv, stdio: "inherit" });
|
|
315
381
|
if (r.status !== 0) throw new Refusal(`behold export exited ${r.status}`);
|
|
@@ -380,6 +446,14 @@ async function main(argv: string[]): Promise<void> {
|
|
|
380
446
|
const outAt = rest.indexOf("--out");
|
|
381
447
|
const out = outAt >= 0 ? rest[outAt + 1] : undefined;
|
|
382
448
|
if (step === "apply") return apply();
|
|
449
|
+
// One member at a time, outside chant: apply-dns is the dns component's step; the others apply as before components ran them.
|
|
450
|
+
if (step === "apply-gcp") return void say(`gcp: the load balancer answers on ${await applyGcp()}`);
|
|
451
|
+
if (step === "apply-azure") return void say(`azure: web answers as ${await applyAzure()}`);
|
|
452
|
+
if (step === "apply-aws") {
|
|
453
|
+
const aws = await applyAws();
|
|
454
|
+
return void say("refused" in aws ? `aws: NOT APPLIED: ${aws.refused}` : `aws: web answers as ${aws.endpoint}`);
|
|
455
|
+
}
|
|
456
|
+
if (step === "apply-dns") return applyFrontDoorFromLive();
|
|
383
457
|
if (step === "azure-off") return azureOff();
|
|
384
458
|
if (step === "wait") return waitFor("unhealthy");
|
|
385
459
|
if (step === "export" || step === "all") {
|
|
@@ -391,7 +465,7 @@ async function main(argv: string[]): Promise<void> {
|
|
|
391
465
|
}
|
|
392
466
|
return exportPage(out);
|
|
393
467
|
}
|
|
394
|
-
throw new Refusal("usage: front-door.ts all|apply|azure-off|wait|export [--out <dir>]");
|
|
468
|
+
throw new Refusal("usage: front-door.ts all|apply|apply-gcp|apply-azure|apply-aws|apply-dns|azure-off|wait|export [--out <dir>]");
|
|
395
469
|
}
|
|
396
470
|
|
|
397
471
|
main(process.argv.slice(2)).catch((e: unknown) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
|
@@ -41,32 +41,31 @@
|
|
|
41
41
|
"preview:tour": "tsx scripts/tour-preview.ts",
|
|
42
42
|
"tsc": "tsc --noEmit",
|
|
43
43
|
"test": "vitest run",
|
|
44
|
-
"build": "esbuild src/cli.ts --bundle --platform=node --format=esm --external:hono --external:@hono/node-server --external:@intentius/pinhole --external:@kubernetes/client-node --external:ajv --outfile=dist/cli.js && chmod +x dist/cli.js",
|
|
44
|
+
"build": "esbuild src/cli.ts --bundle --platform=node --format=esm --external:hono --external:@hono/node-server --external:@intentius/pinhole --external:@kubernetes/client-node --external:ajv --external:@modelcontextprotocol/sdk --outfile=dist/cli.js && chmod +x dist/cli.js",
|
|
45
45
|
"prepare": "npm run build",
|
|
46
46
|
"prepublishOnly": "npm run build"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
+
"@cdktn/hcl2json": "^0.24.0",
|
|
49
50
|
"@hono/node-server": "^2.0.5",
|
|
50
|
-
"@intentius/chant": "^0.124.
|
|
51
|
-
"@intentius/chant-k8s-client": "^0.124.
|
|
51
|
+
"@intentius/chant": "^0.124.51",
|
|
52
|
+
"@intentius/chant-k8s-client": "^0.124.51",
|
|
53
|
+
"@intentius/chant-lexicon-terraform": "^0.124.51",
|
|
52
54
|
"@intentius/pinhole": "^0.5.0",
|
|
55
|
+
"@modelcontextprotocol/sdk": "1.30.1",
|
|
53
56
|
"ajv": "^8.20.0",
|
|
54
57
|
"hono": "^4.13.13"
|
|
55
58
|
},
|
|
56
59
|
"peerDependencies": {
|
|
57
|
-
"
|
|
58
|
-
"@cdktn/hcl2json": "^0.24.0"
|
|
60
|
+
"playwright-core": "^1.62.0"
|
|
59
61
|
},
|
|
60
62
|
"peerDependenciesMeta": {
|
|
61
|
-
"
|
|
62
|
-
"optional": true
|
|
63
|
-
},
|
|
64
|
-
"@cdktn/hcl2json": {
|
|
63
|
+
"playwright-core": {
|
|
65
64
|
"optional": true
|
|
66
65
|
}
|
|
67
66
|
},
|
|
68
67
|
"devDependencies": {
|
|
69
|
-
"@intentius/chant-lexicon-sql": "^0.124.
|
|
68
|
+
"@intentius/chant-lexicon-sql": "^0.124.51",
|
|
70
69
|
"@types/node": "^26.4.1",
|
|
71
70
|
"esbuild": "^0.28.0",
|
|
72
71
|
"playwright": "^1.62.1",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// #914: an agent moved the open tab (POST /api/view, the `view` event on
|
|
2
|
+
// /api/events). Pure logic, no DOM: the banner's words and the history entry
|
|
3
|
+
// a move makes. app.js `agentMove` does the moving.
|
|
4
|
+
|
|
5
|
+
/** How many agent moves in a row get their own history entry. Past it, a move
|
|
6
|
+
* replaces the newest agent entry instead of pushing, so Back still reaches
|
|
7
|
+
* the person's own view after at most this many steps. */
|
|
8
|
+
export const AGENT_STACK_MAX = 20;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The history entry an agent move makes. `state` is history.state of the entry
|
|
12
|
+
* being left; a move pushes a new entry with `beholdMove` on it, numbered by
|
|
13
|
+
* how many agent moves in a row it is. At AGENT_STACK_MAX it replaces instead.
|
|
14
|
+
*/
|
|
15
|
+
export function agentEntry(state, move, max = AGENT_STACK_MAX) {
|
|
16
|
+
const before = state && typeof state === "object" ? state : {};
|
|
17
|
+
const prev = (before.beholdMove && Number(before.beholdMove.depth)) || 0;
|
|
18
|
+
const push = prev < max;
|
|
19
|
+
return { push, state: { ...before, beholdMove: { ...move, depth: push ? prev + 1 : prev } } };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** What clears each key of a question: q, its grouping and its plan depth. */
|
|
23
|
+
export const QUESTION_KEYS = Object.freeze({ q: null, countBy: null, plan: false });
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An agent's move that asks a question (it carries q or countBy) asks it
|
|
27
|
+
* whole: a question key it leaves out, and the tab still holds, is cleared
|
|
28
|
+
* rather than kept from the view the tab was on. Found in #908's stage 3 run:
|
|
29
|
+
* step 3's countBy=module stayed on step 4's `cap:` query, so the tab showed
|
|
30
|
+
* chant's refusal while the agent's answer was right. env and the rest stay:
|
|
31
|
+
* they are where the tab is, not what it asks.
|
|
32
|
+
*/
|
|
33
|
+
export function wholeQuestion(want, current) {
|
|
34
|
+
if (!want || !("q" in want || "countBy" in want)) return want;
|
|
35
|
+
const out = { ...want };
|
|
36
|
+
for (const [k, clear] of Object.entries(QUESTION_KEYS)) if (!(k in out) && current && current[k]) out[k] = clear;
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** HH:MM:SS in the viewer's clock, or "" for a date that isn't one. */
|
|
41
|
+
export function clockTime(d) {
|
|
42
|
+
if (!(d instanceof Date) || Number.isNaN(d.getTime())) return "";
|
|
43
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
44
|
+
return `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The banner's line: "Moved by an agent: <by> asked `<q>` at 14:02:11
|
|
49
|
+
* (request 7f3a)." Without a question it says what moved it and when. The
|
|
50
|
+
* label is the caller's own claim (`by`), never checked.
|
|
51
|
+
*/
|
|
52
|
+
export function agentBanner(move, at) {
|
|
53
|
+
const m = move || {};
|
|
54
|
+
const by = typeof m.by === "string" && m.by ? m.by : "an agent";
|
|
55
|
+
const q = typeof m.q === "string" && m.q ? m.q : "";
|
|
56
|
+
const when = clockTime(at);
|
|
57
|
+
const id = typeof m.id === "string" && m.id ? ` (request ${m.id})` : "";
|
|
58
|
+
const asked = q ? ` asked \`${q.length > 120 ? q.slice(0, 120) + "..." : q}\`` : " moved this view";
|
|
59
|
+
return { text: `Moved by an agent: ${by}${asked}${when ? ` at ${when}` : ""}${id}.` };
|
|
60
|
+
}
|