gestalt-mobile 0.48.2 → 0.49.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/README.md +12 -0
- package/dist/client/assets/index-C3IKYq_X.js +113 -0
- package/dist/client/index.html +1 -1
- package/dist/server/server/app.js +1 -1
- package/dist/server/server/composition.contracts.js +3 -0
- package/dist/server/server/composition.js +2 -0
- package/dist/server/server/features/maintenance/register-routes.js +3 -1
- package/dist/server/server/features/maintenance/upgrade/endpoint.js +30 -0
- package/dist/server/server/platform/maintenance/managed-upgrade.js +67 -0
- package/dist/server/shared/contracts/upgrade.js +6 -0
- package/package.json +1 -1
- package/dist/client/assets/index-DvIxykMj.js +0 -112
package/dist/client/index.html
CHANGED
|
@@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
16
16
|
<link rel="icon" href="/icons/gestalt-mobile-192.png" />
|
|
17
17
|
<link rel="apple-touch-icon" href="/icons/gestalt-mobile-180.png" />
|
|
18
18
|
<title>Gestalt Mobile</title>
|
|
19
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
+
<script type="module" crossorigin src="/assets/index-C3IKYq_X.js"></script>
|
|
20
20
|
<link rel="stylesheet" crossorigin href="/assets/index-CE4-9CY1.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
|
@@ -58,7 +58,7 @@ export async function buildApp(deps) {
|
|
|
58
58
|
registerFileRoutes(app, deps);
|
|
59
59
|
registerGitRoutes(app, deps);
|
|
60
60
|
registerSkillRoutes(app, deps);
|
|
61
|
-
registerMaintenanceRoutes(app);
|
|
61
|
+
registerMaintenanceRoutes(app, deps.upgrade);
|
|
62
62
|
registerProblemHandler(app, Boolean(deps.staticDir));
|
|
63
63
|
return app;
|
|
64
64
|
}
|
|
@@ -3772,6 +3772,9 @@ describe('production composition', () => {
|
|
|
3772
3772
|
],
|
|
3773
3773
|
['POST', '/api/git/clone', '/api/git/clone', 'protected'],
|
|
3774
3774
|
['POST', '/api/maintenance/quit', '/api/maintenance/quit', 'protected'],
|
|
3775
|
+
['POST', '/api/maintenance/upgrade', '/api/maintenance/upgrade', 'protected'],
|
|
3776
|
+
['GET', '/api/maintenance/upgrade', '/api/maintenance/upgrade', 'protected'],
|
|
3777
|
+
['HEAD', '/api/maintenance/upgrade', '/api/maintenance/upgrade', 'protected'],
|
|
3775
3778
|
['GET', '/api/skills', '/api/skills', 'protected'],
|
|
3776
3779
|
['HEAD', '/api/skills', '/api/skills', 'protected'],
|
|
3777
3780
|
['GET', '/api/skill-profiles', '/api/skill-profiles', 'protected'],
|
|
@@ -11,6 +11,7 @@ import { SessionModelConfig } from './platform/codex/session-model-config.js';
|
|
|
11
11
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
12
12
|
import { debuglog } from 'node:util';
|
|
13
13
|
import { buildApp } from './app.js';
|
|
14
|
+
import { ManagedUpgrade } from './platform/maintenance/managed-upgrade.js';
|
|
14
15
|
import { SelfDebugWorkspace } from './platform/self-debug/workspace.js';
|
|
15
16
|
import { createSelfDebugSession } from './features/self-debug/create-session.js';
|
|
16
17
|
import { startSession } from './features/sessions/start-session/use-case.js';
|
|
@@ -1218,6 +1219,7 @@ export async function composeRelayApp(options) {
|
|
|
1218
1219
|
let app;
|
|
1219
1220
|
try {
|
|
1220
1221
|
app = await buildApp({
|
|
1222
|
+
upgrade: new ManagedUpgrade(options.root),
|
|
1221
1223
|
...(authorization
|
|
1222
1224
|
? {
|
|
1223
1225
|
auth: {
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { registerQuit } from './quit/endpoint.js';
|
|
7
|
-
|
|
7
|
+
import { registerUpgrade } from './upgrade/endpoint.js';
|
|
8
|
+
export function registerMaintenanceRoutes(app, upgrade) {
|
|
8
9
|
registerQuit(app);
|
|
10
|
+
registerUpgrade(app, upgrade);
|
|
9
11
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
import { problem } from '../../../platform/http/problem.js';
|
|
7
|
+
export function registerUpgrade(app, upgrade) {
|
|
8
|
+
app.get('/api/maintenance/upgrade', async (_request, reply) => {
|
|
9
|
+
reply.header('Cache-Control', 'no-store');
|
|
10
|
+
if (!upgrade)
|
|
11
|
+
return reply
|
|
12
|
+
.code(503)
|
|
13
|
+
.send(problem('UPGRADE_UNAVAILABLE', 503, 'Start Mobile with gestalt mobile to enable upgrades.'));
|
|
14
|
+
return upgrade.status();
|
|
15
|
+
});
|
|
16
|
+
app.post('/api/maintenance/upgrade', async (_request, reply) => {
|
|
17
|
+
if (!upgrade)
|
|
18
|
+
return reply
|
|
19
|
+
.code(503)
|
|
20
|
+
.send(problem('UPGRADE_UNAVAILABLE', 503, 'Start Mobile with gestalt mobile to enable upgrades.'));
|
|
21
|
+
try {
|
|
22
|
+
return reply.code(202).send(await upgrade.start());
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return reply
|
|
26
|
+
.code(503)
|
|
27
|
+
.send(problem('UPGRADE_FAILED', 503, 'Could not start the upgrade. Check the Gestalt manager and whether another upgrade is running.'));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
import { execFile } from 'node:child_process';
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { access } from 'node:fs/promises';
|
|
9
|
+
import { dirname, join } from 'node:path';
|
|
10
|
+
import { promisify } from 'node:util';
|
|
11
|
+
const runFile = promisify(execFile);
|
|
12
|
+
export class ManagedUpgrade {
|
|
13
|
+
cwd;
|
|
14
|
+
environment;
|
|
15
|
+
run;
|
|
16
|
+
exists;
|
|
17
|
+
current = { instanceId: randomUUID(), phase: 'idle' };
|
|
18
|
+
starting;
|
|
19
|
+
constructor(cwd, environment = process.env, run = runFile, exists = (path) => access(path).then(() => true, () => false)) {
|
|
20
|
+
this.cwd = cwd;
|
|
21
|
+
this.environment = environment;
|
|
22
|
+
this.run = run;
|
|
23
|
+
this.exists = exists;
|
|
24
|
+
}
|
|
25
|
+
async status() {
|
|
26
|
+
if (this.current.phase === 'updating' && !this.starting) {
|
|
27
|
+
const state = this.environment.GESTALT_MOBILE_RESTART_STATE;
|
|
28
|
+
if (!state || !(await this.exists(join(dirname(state), 'update-restart.lock')))) {
|
|
29
|
+
this.current = {
|
|
30
|
+
...this.current,
|
|
31
|
+
phase: 'failed',
|
|
32
|
+
message: 'The upgrade stopped before Mobile restarted. Check the Gestalt update-restart.log, then retry.',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { ...this.current };
|
|
37
|
+
}
|
|
38
|
+
async start() {
|
|
39
|
+
if (this.starting)
|
|
40
|
+
return this.starting;
|
|
41
|
+
if ((await this.status()).phase === 'updating')
|
|
42
|
+
return { ...this.current };
|
|
43
|
+
// Check again after the asynchronous status read so concurrent requests share one launch.
|
|
44
|
+
if (this.starting)
|
|
45
|
+
return this.starting;
|
|
46
|
+
if (this.environment.GESTALT_MOBILE_PID !== String(process.pid) ||
|
|
47
|
+
!this.environment.GESTALT_MOBILE_RESTART_STATE) {
|
|
48
|
+
throw new Error('A managed Mobile restart descriptor is required');
|
|
49
|
+
}
|
|
50
|
+
this.current = { instanceId: this.current.instanceId, phase: 'updating' };
|
|
51
|
+
this.starting = this.run('gestalt', ['update-restart'], {
|
|
52
|
+
cwd: this.cwd,
|
|
53
|
+
env: this.environment,
|
|
54
|
+
timeout: 15_000,
|
|
55
|
+
maxBuffer: 64 * 1024,
|
|
56
|
+
})
|
|
57
|
+
.then(() => ({ ...this.current }))
|
|
58
|
+
.catch(() => {
|
|
59
|
+
this.current = { ...this.current, phase: 'failed' };
|
|
60
|
+
throw new Error('Could not schedule the managed upgrade');
|
|
61
|
+
})
|
|
62
|
+
.finally(() => {
|
|
63
|
+
this.starting = undefined;
|
|
64
|
+
});
|
|
65
|
+
return this.starting;
|
|
66
|
+
}
|
|
67
|
+
}
|