@hsuite/smart-engines-cli 1.0.1 → 1.0.3
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/README.md +25 -9
- package/dist/commands/deploy.d.ts +13 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +132 -10
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/subscribe.d.ts.map +1 -1
- package/dist/commands/subscribe.js +19 -4
- package/dist/commands/subscribe.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ Flow:
|
|
|
84
84
|
1. Reads `XRPL_*` + `APP_NAME` from `.env.local`
|
|
85
85
|
2. Builds a signer using `ripple-keypairs.sign`
|
|
86
86
|
3. Authenticates via `BaasClient.authenticate({chain: 'xrpl', ...})` against the cluster
|
|
87
|
-
4. Calls `BaasClient.
|
|
87
|
+
4. Calls `BaasClient.deployment.init({name, port, services})` — the new four-step deploy flow's step 1 (legacy `register()` removed in PR-A); the cluster runs the per-entity DKG ceremony and returns the DKG entityId as `appId`
|
|
88
88
|
5. Appends `SUBSCRIPTION_APP_ID=<appId>` and `APP_ID=<appId>` to your `.env.local`, flips `SKIP_SUBSCRIPTION_CHECK=false`
|
|
89
89
|
|
|
90
90
|
After this, your smart-app boots in cluster-mode automatically.
|
|
@@ -93,27 +93,43 @@ After this, your smart-app boots in cluster-mode automatically.
|
|
|
93
93
|
|
|
94
94
|
## `hsuite deploy`
|
|
95
95
|
|
|
96
|
-
Deploy a smart-app from a JSON manifest via the SDK's
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
Deploy a smart-app image from a JSON manifest via the SDK's four-step
|
|
97
|
+
runtime-orchestration flow (`init` → `docker push` → optional
|
|
98
|
+
`uploadFrontend` → `deploy`). Use this for CI pipelines that ship a
|
|
99
|
+
container image to the cluster.
|
|
100
100
|
|
|
101
101
|
```bash
|
|
102
102
|
hsuite deploy --manifest ./my-app.json --env .env.local
|
|
103
|
+
hsuite deploy --manifest ./my-app.json --env .env.local --non-interactive # for CI
|
|
103
104
|
```
|
|
104
105
|
|
|
105
106
|
`my-app.json`:
|
|
106
107
|
|
|
107
108
|
```json
|
|
108
109
|
{
|
|
109
|
-
"name": "
|
|
110
|
+
"name": "my-smart-app",
|
|
111
|
+
"port": 3000,
|
|
112
|
+
"tag": "v1",
|
|
113
|
+
"replicas": 1,
|
|
110
114
|
"services": ["database", "storage", "messaging", "functions"],
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
}
|
|
115
|
+
"env": { "NODE_ENV": "production" },
|
|
116
|
+
"frontend": { "bundlePath": "./dist/bundle.tar.gz" }
|
|
114
117
|
}
|
|
115
118
|
```
|
|
116
119
|
|
|
120
|
+
What the command does, in order:
|
|
121
|
+
|
|
122
|
+
1. **`deployment.init`** — cluster allocates the `appId` (per-entity DKG
|
|
123
|
+
entityId) and returns ephemeral DOCR push credentials.
|
|
124
|
+
2. **(out-of-band)** the CLI prints the `docker login` + `docker push`
|
|
125
|
+
commands and waits for Enter (skipped with `--non-interactive`,
|
|
126
|
+
`CI=true`, or no TTY — the caller is assumed to have completed the
|
|
127
|
+
push).
|
|
128
|
+
3. **`deployment.uploadFrontend`** — if `frontend.bundlePath` is set, the
|
|
129
|
+
tarball is uploaded.
|
|
130
|
+
4. **`deployment.deploy`** — the cluster reconciles the requested `tag`
|
|
131
|
+
+ `replicas` + `env` to k8s.
|
|
132
|
+
|
|
117
133
|
The returned `appId` is appended to `.env.local` as `DEPLOYED_APP_ID`.
|
|
118
134
|
|
|
119
135
|
---
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `hsuite deploy` — Deploy a smart-app from a JSON manifest.
|
|
3
|
+
*
|
|
4
|
+
* Implements the four-step runtime-deploy flow defined in
|
|
5
|
+
* `docs/superpowers/specs/2026-05-14-smart-app-runtime-orchestration-design.md` §6.1:
|
|
6
|
+
*
|
|
7
|
+
* 1. `init` → server allocates appId + ephemeral DOCR creds
|
|
8
|
+
* 2. (out-of-band, manual) → customer `docker push <repo>:<tag>`
|
|
9
|
+
* 3. `uploadFrontend` (opt.) → tarball with the SPA bundle
|
|
10
|
+
* 4. `deploy` → server reconciles to k8s
|
|
11
|
+
*
|
|
12
|
+
* The manifest schema widens to include `image`, `port`, `tag`, `replicas`,
|
|
13
|
+
* `env`, and an optional `frontend.bundlePath`. Between init and deploy the
|
|
14
|
+
* CLI prints the docker push command and waits for Enter (skipped in CI /
|
|
15
|
+
* with `--non-interactive`).
|
|
3
16
|
*/
|
|
4
17
|
import { Command } from 'commander';
|
|
5
18
|
export declare const deployCommand: Command;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+DpC,eAAO,MAAM,aAAa,SA6HtB,CAAC"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -6,19 +39,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
39
|
exports.deployCommand = void 0;
|
|
7
40
|
/**
|
|
8
41
|
* `hsuite deploy` — Deploy a smart-app from a JSON manifest.
|
|
42
|
+
*
|
|
43
|
+
* Implements the four-step runtime-deploy flow defined in
|
|
44
|
+
* `docs/superpowers/specs/2026-05-14-smart-app-runtime-orchestration-design.md` §6.1:
|
|
45
|
+
*
|
|
46
|
+
* 1. `init` → server allocates appId + ephemeral DOCR creds
|
|
47
|
+
* 2. (out-of-band, manual) → customer `docker push <repo>:<tag>`
|
|
48
|
+
* 3. `uploadFrontend` (opt.) → tarball with the SPA bundle
|
|
49
|
+
* 4. `deploy` → server reconciles to k8s
|
|
50
|
+
*
|
|
51
|
+
* The manifest schema widens to include `image`, `port`, `tag`, `replicas`,
|
|
52
|
+
* `env`, and an optional `frontend.bundlePath`. Between init and deploy the
|
|
53
|
+
* CLI prints the docker push command and waits for Enter (skipped in CI /
|
|
54
|
+
* with `--non-interactive`).
|
|
9
55
|
*/
|
|
10
56
|
const commander_1 = require("commander");
|
|
11
57
|
const chalk_1 = __importDefault(require("chalk"));
|
|
12
58
|
const ora_1 = __importDefault(require("ora"));
|
|
13
59
|
const fs_1 = require("fs");
|
|
14
60
|
const path_1 = require("path");
|
|
61
|
+
const readline = __importStar(require("readline"));
|
|
15
62
|
const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
|
|
16
63
|
const env_1 = require("../_lib/env");
|
|
64
|
+
/**
|
|
65
|
+
* Block until the user presses Enter on stdin. Skipped in non-interactive
|
|
66
|
+
* mode (env `CI=true`, no TTY, or `--non-interactive` flag) — caller is
|
|
67
|
+
* assumed to have completed the docker push before invoking the CLI.
|
|
68
|
+
*/
|
|
69
|
+
async function waitForEnter() {
|
|
70
|
+
return new Promise((res) => {
|
|
71
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
72
|
+
rl.question('', () => {
|
|
73
|
+
rl.close();
|
|
74
|
+
res();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function isNonInteractive(flag) {
|
|
79
|
+
if (flag)
|
|
80
|
+
return true;
|
|
81
|
+
if (process.env.CI === 'true')
|
|
82
|
+
return true;
|
|
83
|
+
if (!process.stdin.isTTY)
|
|
84
|
+
return true;
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
17
87
|
exports.deployCommand = new commander_1.Command('deploy')
|
|
18
|
-
.description('Deploy a smart-app from a JSON manifest')
|
|
88
|
+
.description('Deploy a smart-app from a JSON manifest (init → push → deploy)')
|
|
19
89
|
.requiredOption('--manifest <file>', 'JSON manifest path')
|
|
20
90
|
.option('--env <file>', 'Env file with auth creds', '.env.local')
|
|
21
91
|
.option('--gateway <url>', 'Smart-engines gateway URL', 'https://v3-testnet-gateway.hsuite.network')
|
|
92
|
+
.option('--non-interactive', 'Skip the wait-for-Enter between init and deploy', false)
|
|
22
93
|
.action(async (opts) => {
|
|
23
94
|
console.log(chalk_1.default.bold.cyan('\n hsuite deploy\n'));
|
|
24
95
|
const manifestPath = (0, path_1.resolve)(opts.manifest);
|
|
@@ -27,13 +98,18 @@ exports.deployCommand = new commander_1.Command('deploy')
|
|
|
27
98
|
process.exit(1);
|
|
28
99
|
}
|
|
29
100
|
const manifest = JSON.parse((0, fs_1.readFileSync)(manifestPath, 'utf8'));
|
|
30
|
-
if (!manifest.name ||
|
|
31
|
-
|
|
101
|
+
if (!manifest.name ||
|
|
102
|
+
typeof manifest.port !== 'number' ||
|
|
103
|
+
!Array.isArray(manifest.services) ||
|
|
104
|
+
!manifest.tag) {
|
|
105
|
+
console.error(chalk_1.default.red(` manifest must have at minimum {name, port, services[], tag}\n`));
|
|
32
106
|
process.exit(1);
|
|
33
107
|
}
|
|
34
108
|
console.log(chalk_1.default.gray(` manifest: ${manifestPath}`));
|
|
35
109
|
console.log(chalk_1.default.gray(` name: ${manifest.name}`));
|
|
36
|
-
console.log(chalk_1.default.gray(`
|
|
110
|
+
console.log(chalk_1.default.gray(` port: ${manifest.port}`));
|
|
111
|
+
console.log(chalk_1.default.gray(` services: ${manifest.services.join(', ') || '(none)'}`));
|
|
112
|
+
console.log(chalk_1.default.gray(` tag: ${manifest.tag}`));
|
|
37
113
|
console.log(chalk_1.default.gray(` gateway: ${opts.gateway}\n`));
|
|
38
114
|
const env = (0, env_1.readEnv)(opts.env);
|
|
39
115
|
const signer = (0, env_1.buildSignerFromEnv)(env);
|
|
@@ -57,21 +133,67 @@ exports.deployCommand = new commander_1.Command('deploy')
|
|
|
57
133
|
process.exit(1);
|
|
58
134
|
}
|
|
59
135
|
spinner.succeed('authenticated');
|
|
60
|
-
|
|
61
|
-
|
|
136
|
+
// ── Step 1: init ──────────────────────────────────────────────────
|
|
137
|
+
spinner = (0, ora_1.default)('init...').start();
|
|
138
|
+
let init;
|
|
62
139
|
try {
|
|
63
|
-
|
|
140
|
+
init = await client.deployment.init({
|
|
64
141
|
name: manifest.name,
|
|
142
|
+
port: manifest.port,
|
|
65
143
|
services: manifest.services,
|
|
66
|
-
|
|
144
|
+
limits: manifest.limits,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
spinner.fail(`init failed: ${err.message}`);
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
spinner.succeed(`init: appId=${init.appId} registry=${init.registry.repository}`);
|
|
152
|
+
// ── Step 2 (out-of-band): docker push ─────────────────────────────
|
|
153
|
+
console.log(chalk_1.default.bold.yellow('\n → push your image now:'));
|
|
154
|
+
console.log(` echo ${JSON.stringify(init.registry.password)} | docker login ${init.registry.server} -u ${init.registry.username} --password-stdin`);
|
|
155
|
+
console.log(` docker push ${init.registry.server}/${init.registry.repository}:${manifest.tag}`);
|
|
156
|
+
if (!isNonInteractive(opts.nonInteractive)) {
|
|
157
|
+
console.log(chalk_1.default.bold.yellow('\n → press Enter when push is complete'));
|
|
158
|
+
await waitForEnter();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
console.log(chalk_1.default.gray(' (non-interactive: assuming push already complete)'));
|
|
162
|
+
}
|
|
163
|
+
// ── Step 3 (optional): upload frontend ────────────────────────────
|
|
164
|
+
if (manifest.frontend?.bundlePath) {
|
|
165
|
+
const bundlePath = (0, path_1.resolve)(manifest.frontend.bundlePath);
|
|
166
|
+
if (!(0, fs_1.existsSync)(bundlePath)) {
|
|
167
|
+
console.error(chalk_1.default.red(` frontend bundle not found: ${bundlePath}\n`));
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
spinner = (0, ora_1.default)('uploading frontend bundle...').start();
|
|
171
|
+
try {
|
|
172
|
+
const bundle = await fs_1.promises.readFile(bundlePath);
|
|
173
|
+
const upload = await client.deployment.uploadFrontend(init.appId, bundle);
|
|
174
|
+
spinner.succeed(`frontend uploaded: sha256=${upload.bundleSha256.slice(0, 12)}…`);
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
spinner.fail(`frontend upload failed: ${err.message}`);
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// ── Step 4: deploy ────────────────────────────────────────────────
|
|
182
|
+
spinner = (0, ora_1.default)('deploying...').start();
|
|
183
|
+
let deployRes;
|
|
184
|
+
try {
|
|
185
|
+
deployRes = await client.deployment.deploy(init.appId, {
|
|
186
|
+
tag: manifest.tag,
|
|
187
|
+
replicas: manifest.replicas ?? 1,
|
|
188
|
+
env: manifest.env,
|
|
67
189
|
});
|
|
68
190
|
}
|
|
69
191
|
catch (err) {
|
|
70
192
|
spinner.fail(`deploy failed: ${err.message}`);
|
|
71
193
|
process.exit(1);
|
|
72
194
|
}
|
|
73
|
-
spinner.succeed(`deployed:
|
|
74
|
-
(0, env_1.upsertEnv)(opts.env, { DEPLOYED_APP_ID:
|
|
195
|
+
spinner.succeed(`deployed: ${deployRes.url}`);
|
|
196
|
+
(0, env_1.upsertEnv)(opts.env, { DEPLOYED_APP_ID: init.appId });
|
|
75
197
|
console.log(chalk_1.default.bold.green('\n ✓ done\n'));
|
|
76
198
|
});
|
|
77
199
|
//# sourceMappingURL=deploy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,yCAAoC;AACpC,kDAA0B;AAC1B,8CAAsB;AACtB,2BAA8D;AAC9D,+BAA+B;AAC/B,mDAAqC;AACrC,iEAAuD;AAIvD,qCAAqE;AA+B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AAC,IAAI,CAAC,kBAAmB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,aAAa,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;IAE9C,IAAA,eAAS,EAAC,IAAI,CAAC,GAAG,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/commands/subscribe.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/commands/subscribe.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,gBAAgB,SAqGzB,CAAC"}
|
|
@@ -35,7 +35,15 @@ exports.subscribeCommand = new commander_1.Command('subscribe')
|
|
|
35
35
|
console.error(chalk_1.default.gray(' hint: run `hsuite init` first\n'));
|
|
36
36
|
process.exit(1);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
// The init endpoint requires a DNS-safe name (lowercase alphanumeric +
|
|
39
|
+
// hyphens, max 63 chars). Normalise the display-name accordingly so a
|
|
40
|
+
// CLI invocation with a free-text APP_NAME doesn't 400 at the boundary.
|
|
41
|
+
const rawAppName = opts.name ?? env.get('APP_NAME') ?? 'smart-app-showcase';
|
|
42
|
+
const appName = rawAppName
|
|
43
|
+
.toLowerCase()
|
|
44
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
45
|
+
.replace(/^-+|-+$/g, '')
|
|
46
|
+
.slice(0, 63) || 'smart-app-showcase';
|
|
39
47
|
const services = opts.services
|
|
40
48
|
.split(',')
|
|
41
49
|
.map((s) => s.trim())
|
|
@@ -73,15 +81,22 @@ exports.subscribeCommand = new commander_1.Command('subscribe')
|
|
|
73
81
|
spinner = (0, ora_1.default)('register free_testnet smart-app...').start();
|
|
74
82
|
let result;
|
|
75
83
|
try {
|
|
76
|
-
|
|
84
|
+
// PR-A runtime-orchestration: `deployment.init` is the first step of
|
|
85
|
+
// the four-step deploy flow and the new entry-point for allocating an
|
|
86
|
+
// appId on the cluster. The legacy `BaasClient.register()` +
|
|
87
|
+
// `POST /api/deployment/apps` surface was removed (no backward compat
|
|
88
|
+
// per spec §4 hard rules). `subscribe` does not deploy an image, so
|
|
89
|
+
// we synthesise a reasonable default port — the runtime sub-doc is
|
|
90
|
+
// populated at `deploy` time (PR-D), not at init.
|
|
91
|
+
result = await client.deployment.init({ name: appName, port: 3000, services });
|
|
77
92
|
}
|
|
78
93
|
catch (err) {
|
|
79
94
|
spinner.fail(`register failed: ${err.message}`);
|
|
80
95
|
process.exit(1);
|
|
81
96
|
}
|
|
82
97
|
spinner.succeed(`appId: ${result.appId}`);
|
|
83
|
-
console.log(chalk_1.default.gray(`
|
|
84
|
-
console.log(chalk_1.default.gray(` services: ${
|
|
98
|
+
console.log(chalk_1.default.gray(` registry: ${result.registry.server}/${result.registry.repository}`));
|
|
99
|
+
console.log(chalk_1.default.gray(` services: ${services.join(', ')}`));
|
|
85
100
|
(0, env_1.upsertEnv)(opts.env, {
|
|
86
101
|
SUBSCRIPTION_APP_ID: result.appId,
|
|
87
102
|
APP_ID: result.appId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../src/commands/subscribe.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;GAMG;AACH,yCAAoC;AACpC,kDA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