gestalt-mobile 0.59.0 → 0.60.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 +6 -5
- package/dist/server/server/cli.js +2 -2
- package/dist/server/server/composition.js +7 -9
- package/dist/server/server/config.js +2 -5
- package/dist/server/server/platform/host-tests/config.js +20 -17
- package/dist/server/server/platform/host-tests/runner.js +26 -23
- package/dist/server/shared/contracts/host-tests.js +1 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -623,11 +623,12 @@ when configuring GitHub, rotating credentials, or recovering a partial release.
|
|
|
623
623
|
|
|
624
624
|
## Host-owned test suites
|
|
625
625
|
|
|
626
|
-
The
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
626
|
+
The host test runner is enabled by default. Root supervisors configure suites at
|
|
627
|
+
runtime in the session workspace's `.gestalt/host-tests.json` and run them as the
|
|
628
|
+
host user, outside the agent shell sandbox, without fingerprint approval or a
|
|
629
|
+
restart. See [host test runner](docs/host-tests.md) for configuration, calls,
|
|
630
|
+
evidence and the execution boundary. Use `--disable-test-runner` to turn it off.
|
|
631
|
+
Serena's own sandbox checks remain in place.
|
|
631
632
|
|
|
632
633
|
## Copyright and license
|
|
633
634
|
|
|
@@ -29,7 +29,7 @@ Options:
|
|
|
29
29
|
--disable-passkey-auth Disable passkey access control (unsafe on shared or network hosts)
|
|
30
30
|
--data-dir <path> Directory for persistent application data
|
|
31
31
|
--icon <path> SVG or PNG used as the installed PWA application icon
|
|
32
|
-
--test-runner
|
|
32
|
+
--disable-test-runner Disable host tests (default: runtime .gestalt/host-tests.json suites)
|
|
33
33
|
--xerj <mode> Source discovery: auto (default, index and watch), manual, off
|
|
34
34
|
--skills <profile> Use a global skill profile for every session
|
|
35
35
|
--skills list List saved global skill profiles without starting the server
|
|
@@ -289,7 +289,7 @@ export async function runCli(dependencies = {}) {
|
|
|
289
289
|
root: config.root,
|
|
290
290
|
xerj: config.xerj,
|
|
291
291
|
dataDir: config.dataDir,
|
|
292
|
-
|
|
292
|
+
testRunnerEnabled: config.testRunnerEnabled,
|
|
293
293
|
relyingParty: config.relyingParty,
|
|
294
294
|
passkeyAuthEnabled: config.passkeyAuthEnabled,
|
|
295
295
|
staticDir: packagedClientDir(moduleUrl),
|
|
@@ -15,7 +15,7 @@ import { SqliteTransportDiagnostics } from './platform/persistence/sqlite-transp
|
|
|
15
15
|
import { buildApp } from './app.js';
|
|
16
16
|
import { ManagedUpgrade } from './platform/maintenance/managed-upgrade.js';
|
|
17
17
|
import { LocalHostTestRunner } from './platform/host-tests/runner.js';
|
|
18
|
-
import {
|
|
18
|
+
import { loadWorkspaceHostTestConfig, within } from './platform/host-tests/config.js';
|
|
19
19
|
import { handleHostTestTool } from './features/host-tests/application/handle-tool.js';
|
|
20
20
|
import { gestaltTestRunnerDynamicTool } from '../shared/contracts/host-tests.js';
|
|
21
21
|
import { SelfDebugWorkspace } from './platform/self-debug/workspace.js';
|
|
@@ -113,9 +113,6 @@ export async function composeRelayApp(options) {
|
|
|
113
113
|
if (ownerHandle && ownerHandle.length !== 32)
|
|
114
114
|
throw new Error('Authorization randomness must return exactly 32 bytes');
|
|
115
115
|
const root = resolve(options.root);
|
|
116
|
-
const hostTestSuites = options.testRunnerConfig
|
|
117
|
-
? await loadHostTestConfig(options.testRunnerConfig, root)
|
|
118
|
-
: undefined;
|
|
119
116
|
let hostTests;
|
|
120
117
|
const databasePath = options.dataDir
|
|
121
118
|
? join(resolve(options.dataDir), 'relay.sqlite')
|
|
@@ -1435,15 +1432,16 @@ export async function composeRelayApp(options) {
|
|
|
1435
1432
|
}
|
|
1436
1433
|
let app;
|
|
1437
1434
|
try {
|
|
1438
|
-
if (
|
|
1439
|
-
|
|
1440
|
-
throw new Error('Host test evidence must be outside the agent workspace; choose a private --data-dir');
|
|
1441
|
-
}
|
|
1442
|
-
hostTests = new LocalHostTestRunner(hostTestSuites, join(dirname(databasePath), 'host-test-runs'), (sessionId, runId, observedAt) => {
|
|
1435
|
+
if (options.testRunnerEnabled !== false) {
|
|
1436
|
+
hostTests = new LocalHostTestRunner(join(dirname(databasePath), 'host-test-runs'), (sessionId, runId, observedAt) => {
|
|
1443
1437
|
if (!sessions.find(sessionId))
|
|
1444
1438
|
return;
|
|
1445
1439
|
events.publish(journal.append(sessionId, 'host-test.completed', { runId, observedAt }, observedAt));
|
|
1446
1440
|
autopilot.rootProcessCompleted(sessionId, runId);
|
|
1441
|
+
}, async (workspace) => {
|
|
1442
|
+
if (!within(await realpath(root), await realpath(workspace)))
|
|
1443
|
+
throw new Error('Host test workspace is outside the configured root');
|
|
1444
|
+
return loadWorkspaceHostTestConfig(workspace);
|
|
1447
1445
|
});
|
|
1448
1446
|
await hostTests.initialize();
|
|
1449
1447
|
}
|
|
@@ -17,9 +17,8 @@ const optionNames = new Set([
|
|
|
17
17
|
'--skills',
|
|
18
18
|
'--icon',
|
|
19
19
|
'--xerj',
|
|
20
|
-
'--test-runner-config',
|
|
21
20
|
]);
|
|
22
|
-
const flagNames = new Set(['--disable-passkey-auth']);
|
|
21
|
+
const flagNames = new Set(['--disable-passkey-auth', '--disable-test-runner']);
|
|
23
22
|
export function parseConfig(args, cwd = process.cwd()) {
|
|
24
23
|
const values = new Map();
|
|
25
24
|
const flags = new Set();
|
|
@@ -65,9 +64,7 @@ export function parseConfig(args, cwd = process.cwd()) {
|
|
|
65
64
|
dataDir: values.get('--data-dir'),
|
|
66
65
|
skillsProfile: values.get('--skills'),
|
|
67
66
|
iconPath: values.has('--icon') ? resolveIconPath(cwd, values.get('--icon')) : undefined,
|
|
68
|
-
|
|
69
|
-
? resolve(cwd, values.get('--test-runner-config'))
|
|
70
|
-
: undefined,
|
|
67
|
+
testRunnerEnabled: !flags.has('--disable-test-runner'),
|
|
71
68
|
};
|
|
72
69
|
}
|
|
73
70
|
function resolveIconPath(cwd, value) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { lstat, readFile, realpath } from 'node:fs/promises';
|
|
7
|
-
import { isAbsolute, relative, sep } from 'node:path';
|
|
7
|
+
import { isAbsolute, join, relative, sep } from 'node:path';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
const suiteSchema = z
|
|
10
10
|
.object({
|
|
@@ -12,10 +12,6 @@ const suiteSchema = z
|
|
|
12
12
|
repository: z.string().min(1),
|
|
13
13
|
command: z.string().min(1),
|
|
14
14
|
args: z.array(z.string().max(4096)).max(64),
|
|
15
|
-
candidate: z
|
|
16
|
-
.string()
|
|
17
|
-
.regex(/^[a-f0-9]{64}$/)
|
|
18
|
-
.nullable(),
|
|
19
15
|
timeoutMs: z.number().int().min(100).max(3_600_000),
|
|
20
16
|
maxOutputBytes: z.number().int().min(1024).max(16_777_216),
|
|
21
17
|
})
|
|
@@ -27,22 +23,29 @@ export function within(root, target) {
|
|
|
27
23
|
const path = relative(root, target);
|
|
28
24
|
return path === '' || (!isAbsolute(path) && path !== '..' && !path.startsWith('..' + sep));
|
|
29
25
|
}
|
|
30
|
-
/**
|
|
31
|
-
export async function
|
|
26
|
+
/** Reload agent-editable workspace suites on demand. Absence permits later creation. */
|
|
27
|
+
export async function loadWorkspaceHostTestConfig(workspaceRoot) {
|
|
32
28
|
const root = await realpath(workspaceRoot);
|
|
29
|
+
const path = join(root, '.gestalt', 'host-tests.json');
|
|
30
|
+
let info;
|
|
31
|
+
try {
|
|
32
|
+
info = await lstat(path);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error.code === 'ENOENT')
|
|
36
|
+
return [];
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
33
39
|
const canonical = await realpath(path);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
info.isSymbolicLink() ||
|
|
37
|
-
!info.isFile() ||
|
|
38
|
-
info.size > 65536 ||
|
|
39
|
-
(info.mode & 0o077) !== 0 ||
|
|
40
|
-
info.uid !== process.getuid?.()) {
|
|
41
|
-
throw new Error('Host test configuration must be a private user-owned file outside the workspace');
|
|
40
|
+
if (!within(root, canonical) || info.isSymbolicLink() || !info.isFile() || info.size > 65536) {
|
|
41
|
+
throw new Error('Host test configuration must be a bounded regular file within the workspace');
|
|
42
42
|
}
|
|
43
43
|
const config = configSchema.parse(JSON.parse(await readFile(canonical, 'utf8')));
|
|
44
|
+
return validateSuites(config.suites, root);
|
|
45
|
+
}
|
|
46
|
+
async function validateSuites(suites, root) {
|
|
44
47
|
const names = new Set();
|
|
45
|
-
for (const suite of
|
|
48
|
+
for (const suite of suites) {
|
|
46
49
|
if (names.has(suite.id) || !isAbsolute(suite.repository) || !isAbsolute(suite.command)) {
|
|
47
50
|
throw new Error('Host test suites require unique names and absolute repository/command paths');
|
|
48
51
|
}
|
|
@@ -54,5 +57,5 @@ export async function loadHostTestConfig(path, workspaceRoot) {
|
|
|
54
57
|
if (!executable.isFile() && !executable.isSymbolicLink())
|
|
55
58
|
throw new Error('Invalid host test executable');
|
|
56
59
|
}
|
|
57
|
-
return
|
|
60
|
+
return suites;
|
|
58
61
|
}
|
|
@@ -9,7 +9,7 @@ import { closeSync, openSync, writeSync } from 'node:fs';
|
|
|
9
9
|
import { lstat, mkdir, readFile, readdir, realpath, rename, writeFile } from 'node:fs/promises';
|
|
10
10
|
import { join } from 'node:path';
|
|
11
11
|
import { candidate } from './candidate.js';
|
|
12
|
-
import { within } from './config.js';
|
|
12
|
+
import { loadWorkspaceHostTestConfig, within } from './config.js';
|
|
13
13
|
// The host owns a lifetime pipe; even a host crash closes it. Tests cannot inherit
|
|
14
14
|
// that pipe or the IPC channel. The guardian reaps its own group, never a stored PID.
|
|
15
15
|
const guardian = `
|
|
@@ -24,21 +24,21 @@ const child=spawn(command,JSON.parse(args),{cwd,env:process.env,stdio:['ignore',
|
|
|
24
24
|
child.once('error',()=>{if(process.connected)process.send({exitCode:127,signal:null});stop()});
|
|
25
25
|
child.once('exit',(exitCode,signal)=>{if(process.connected)process.send({exitCode,signal});stop()});
|
|
26
26
|
`;
|
|
27
|
-
/** One host-owned runner per relay.
|
|
27
|
+
/** One host-owned runner per relay. Each run retains its resolved configuration. */
|
|
28
28
|
export class LocalHostTestRunner {
|
|
29
|
-
suites;
|
|
30
29
|
evidenceRoot;
|
|
31
30
|
completed;
|
|
31
|
+
workspaceSuites;
|
|
32
32
|
results = new Map();
|
|
33
33
|
active = new Map();
|
|
34
34
|
reservations = new Set();
|
|
35
35
|
requests = new Map();
|
|
36
36
|
sessionGenerations = new Map();
|
|
37
37
|
closing = false;
|
|
38
|
-
constructor(
|
|
39
|
-
this.suites = suites;
|
|
38
|
+
constructor(evidenceRoot, completed = () => { }, workspaceSuites = loadWorkspaceHostTestConfig) {
|
|
40
39
|
this.evidenceRoot = evidenceRoot;
|
|
41
40
|
this.completed = completed;
|
|
41
|
+
this.workspaceSuites = workspaceSuites;
|
|
42
42
|
}
|
|
43
43
|
async initialize() {
|
|
44
44
|
if (process.platform !== 'linux' && process.platform !== 'darwin')
|
|
@@ -110,13 +110,24 @@ export class LocalHostTestRunner {
|
|
|
110
110
|
this.active.get(result.runId)?.stop('cancelled');
|
|
111
111
|
return structuredClone(result);
|
|
112
112
|
}
|
|
113
|
+
if (input.operation === 'start') {
|
|
114
|
+
const previous = [...this.results.values()].find((result) => result.sessionId === owner.sessionId && result.requestId === input.requestId);
|
|
115
|
+
if (previous) {
|
|
116
|
+
return previous.suite === input.suite
|
|
117
|
+
? structuredClone(previous)
|
|
118
|
+
: { error: 'requestIdConflict' };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
113
121
|
const workspace = await realpath(owner.workspace);
|
|
114
|
-
|
|
122
|
+
if (within(workspace, await realpath(this.evidenceRoot)))
|
|
123
|
+
return { error: 'evidenceInsideWorkspace' };
|
|
124
|
+
const suites = await this.workspaceSuites(workspace);
|
|
125
|
+
const available = suites.filter((suite) => within(workspace, suite.repository));
|
|
115
126
|
if (input.operation === 'list')
|
|
116
127
|
return {
|
|
117
128
|
suites: available.map((suite) => ({
|
|
118
129
|
id: suite.id,
|
|
119
|
-
|
|
130
|
+
repository: suite.repository,
|
|
120
131
|
timeoutMs: suite.timeoutMs,
|
|
121
132
|
})),
|
|
122
133
|
};
|
|
@@ -129,23 +140,16 @@ export class LocalHostTestRunner {
|
|
|
129
140
|
const current = await candidate(suite.repository);
|
|
130
141
|
return {
|
|
131
142
|
suite: suite.id,
|
|
143
|
+
repository: suite.repository,
|
|
132
144
|
candidate: current,
|
|
133
|
-
authorized: suite.candidate === current,
|
|
134
145
|
fingerprintScope: 'Git-visible files, modes, index, HEAD and branch; excludes ignored dependencies and host toolchains',
|
|
135
146
|
};
|
|
136
147
|
}
|
|
137
|
-
|
|
138
|
-
if (previous)
|
|
139
|
-
return previous.suite === suite.id && previous.candidate === input.candidate
|
|
140
|
-
? structuredClone(previous)
|
|
141
|
-
: { error: 'requestIdConflict' };
|
|
142
|
-
return this.start(owner, suite, input.candidate, input.requestId, generation);
|
|
148
|
+
return this.start(owner, suite, input.requestId, generation);
|
|
143
149
|
}
|
|
144
|
-
async start(owner, suite,
|
|
150
|
+
async start(owner, suite, requestId, generation) {
|
|
145
151
|
if (this.closing)
|
|
146
152
|
return { error: 'hostShuttingDown' };
|
|
147
|
-
if (suite.candidate !== expected)
|
|
148
|
-
return { error: 'candidateNotAuthorized' };
|
|
149
153
|
if (this.results.size >= 1000)
|
|
150
154
|
return { error: 'evidenceCapacityReached' };
|
|
151
155
|
if (this.reservations.has(suite.repository))
|
|
@@ -154,8 +158,7 @@ export class LocalHostTestRunner {
|
|
|
154
158
|
return { error: 'hostRunnerBusy' };
|
|
155
159
|
this.reservations.add(suite.repository);
|
|
156
160
|
try {
|
|
157
|
-
|
|
158
|
-
return { error: 'candidateChanged' };
|
|
161
|
+
const current = await candidate(suite.repository);
|
|
159
162
|
if (this.closing)
|
|
160
163
|
return { error: 'hostShuttingDown' };
|
|
161
164
|
const runId = randomUUID();
|
|
@@ -168,7 +171,7 @@ export class LocalHostTestRunner {
|
|
|
168
171
|
requestId,
|
|
169
172
|
sessionId: owner.sessionId,
|
|
170
173
|
suite: suite.id,
|
|
171
|
-
candidate:
|
|
174
|
+
candidate: current,
|
|
172
175
|
finalCandidate: null,
|
|
173
176
|
state: 'running',
|
|
174
177
|
startedAt: now,
|
|
@@ -190,7 +193,7 @@ export class LocalHostTestRunner {
|
|
|
190
193
|
timeoutMs: suite.timeoutMs,
|
|
191
194
|
maxOutputBytes: suite.maxOutputBytes,
|
|
192
195
|
fingerprintVersion: 1,
|
|
193
|
-
candidate:
|
|
196
|
+
candidate: current,
|
|
194
197
|
nodeVersion: process.version,
|
|
195
198
|
platform: process.platform,
|
|
196
199
|
arch: process.arch,
|
|
@@ -212,7 +215,7 @@ export class LocalHostTestRunner {
|
|
|
212
215
|
return structuredClone(result);
|
|
213
216
|
}
|
|
214
217
|
finally {
|
|
215
|
-
if (![...this.active.values()].some((run) => run.
|
|
218
|
+
if (![...this.active.values()].some((run) => run.repository === suite.repository))
|
|
216
219
|
this.reservations.delete(suite.repository);
|
|
217
220
|
}
|
|
218
221
|
}
|
|
@@ -250,7 +253,7 @@ export class LocalHostTestRunner {
|
|
|
250
253
|
reason ??= state;
|
|
251
254
|
child.stdin?.end();
|
|
252
255
|
};
|
|
253
|
-
this.active.set(result.runId, { result, stop, done });
|
|
256
|
+
this.active.set(result.runId, { result, repository: suite.repository, stop, done });
|
|
254
257
|
const timeout = setTimeout(() => stop('timedOut'), suite.timeoutMs);
|
|
255
258
|
let summary = '';
|
|
256
259
|
child.stdin?.on('error', () => { });
|
|
@@ -13,7 +13,6 @@ export const hostTestRequest = z.discriminatedUnion('operation', [
|
|
|
13
13
|
.object({
|
|
14
14
|
operation: z.literal('start'),
|
|
15
15
|
suite,
|
|
16
|
-
candidate: z.string().regex(/^[a-f0-9]{64}$/),
|
|
17
16
|
requestId: runId,
|
|
18
17
|
})
|
|
19
18
|
.strict(),
|
|
@@ -23,14 +22,13 @@ export const hostTestRequest = z.discriminatedUnion('operation', [
|
|
|
23
22
|
export const gestaltTestRunnerDynamicTool = {
|
|
24
23
|
type: 'function',
|
|
25
24
|
name: 'gestalt_test_runner',
|
|
26
|
-
description: 'Run
|
|
25
|
+
description: 'Run workspace test suites outside the agent shell sandbox as the host user. Enabled by default; root supervisor only. Create or edit .gestalt/host-tests.json in the session workspace using normal file tools; suites reload at runtime without restart or fingerprint approval. list/inspect do not execute code. start requires suite and an idempotent requestId; status/cancel require runId. Tool arguments never accept commands, environment, or paths. Results retain automatic source fingerprints, UTC observations and private evidence; counts can be unknown. Keep the writer idle during tests. Does not approve milestones or resume Autopilot.',
|
|
27
26
|
inputSchema: {
|
|
28
27
|
type: 'object',
|
|
29
28
|
additionalProperties: false,
|
|
30
29
|
properties: {
|
|
31
30
|
operation: { type: 'string', enum: ['list', 'inspect', 'start', 'status', 'cancel'] },
|
|
32
31
|
suite: { type: 'string' },
|
|
33
|
-
candidate: { type: 'string' },
|
|
34
32
|
requestId: { type: 'string' },
|
|
35
33
|
runId: { type: 'string' },
|
|
36
34
|
},
|