@developerz.ai/ui-debugger-mcp 1.9.0 → 1.10.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 +56 -44
- package/dist/adapters/android/adb.d.ts +19 -7
- package/dist/adapters/android/adb.js +50 -13
- package/dist/adapters/android/adb.js.map +1 -1
- package/dist/adapters/android/android-adapter.d.ts +42 -2
- package/dist/adapters/android/android-adapter.js +366 -36
- package/dist/adapters/android/android-adapter.js.map +1 -1
- package/dist/adapters/android/commands.js.map +1 -1
- package/dist/adapters/android/ports.js.map +1 -1
- package/dist/adapters/android/sdk.d.ts +65 -0
- package/dist/adapters/android/sdk.js +107 -0
- package/dist/adapters/android/sdk.js.map +1 -0
- package/dist/adapters/android/uiautomator.d.ts +23 -7
- package/dist/adapters/android/uiautomator.js +31 -7
- package/dist/adapters/android/uiautomator.js.map +1 -1
- package/dist/adapters/availability.d.ts +39 -0
- package/dist/adapters/availability.js +62 -0
- package/dist/adapters/availability.js.map +1 -0
- package/dist/adapters/browser/browser-adapter.d.ts +11 -22
- package/dist/adapters/browser/browser-adapter.js +98 -67
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +15 -7
- package/dist/adapters/browser/cdp.js +25 -3
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/filters.d.ts +1 -1
- package/dist/adapters/browser/filters.js.map +1 -1
- package/dist/adapters/browser/geometry.js.map +1 -1
- package/dist/adapters/browser/launch.d.ts +14 -5
- package/dist/adapters/browser/launch.js +14 -5
- package/dist/adapters/browser/launch.js.map +1 -1
- package/dist/adapters/browser/lifecycle.d.ts +58 -0
- package/dist/adapters/browser/lifecycle.js +98 -0
- package/dist/adapters/browser/lifecycle.js.map +1 -0
- package/dist/adapters/browser/log-filters.d.ts +2 -2
- package/dist/adapters/browser/log-filters.js.map +1 -1
- package/dist/adapters/browser/log-format.d.ts +14 -23
- package/dist/adapters/browser/log-format.js +16 -55
- package/dist/adapters/browser/log-format.js.map +1 -1
- package/dist/adapters/browser/tab-context.d.ts +30 -0
- package/dist/adapters/browser/tab-context.js +41 -0
- package/dist/adapters/browser/tab-context.js.map +1 -0
- package/dist/adapters/contract.d.ts +91 -5
- package/dist/adapters/contract.js +7 -2
- package/dist/adapters/contract.js.map +1 -1
- package/dist/adapters/desktop/atspi-busctl.d.ts +26 -0
- package/dist/adapters/desktop/atspi-busctl.js +330 -0
- package/dist/adapters/desktop/atspi-busctl.js.map +1 -0
- package/dist/adapters/desktop/atspi-parse.d.ts +39 -0
- package/dist/adapters/desktop/atspi-parse.js +155 -0
- package/dist/adapters/desktop/atspi-parse.js.map +1 -0
- package/dist/adapters/desktop/atspi.d.ts +75 -50
- package/dist/adapters/desktop/atspi.js +64 -285
- package/dist/adapters/desktop/atspi.js.map +1 -1
- package/dist/adapters/desktop/capture.d.ts +11 -20
- package/dist/adapters/desktop/capture.js +68 -37
- package/dist/adapters/desktop/capture.js.map +1 -1
- package/dist/adapters/desktop/desktop-adapter.d.ts +20 -2
- package/dist/adapters/desktop/desktop-adapter.js +91 -9
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +18 -4
- package/dist/adapters/desktop/input.js +15 -10
- package/dist/adapters/desktop/input.js.map +1 -1
- package/dist/adapters/desktop/proc.d.ts +32 -4
- package/dist/adapters/desktop/proc.js +33 -6
- package/dist/adapters/desktop/proc.js.map +1 -1
- package/dist/adapters/factory.d.ts +12 -5
- package/dist/adapters/factory.js +29 -3
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/log-format.d.ts +32 -0
- package/dist/adapters/log-format.js +39 -0
- package/dist/adapters/log-format.js.map +1 -0
- package/dist/agent/belt/act.d.ts +421 -21
- package/dist/agent/belt/act.js +4 -4
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +471 -14
- package/dist/agent/belt/look.js +74 -12
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +663 -42
- package/dist/agent/belt/observe.js +76 -12
- package/dist/agent/belt/observe.js.map +1 -1
- package/dist/agent/belt/report.d.ts +754 -48
- package/dist/agent/belt/report.js +121 -38
- package/dist/agent/belt/report.js.map +1 -1
- package/dist/agent/belt/trail.d.ts +44 -16
- package/dist/agent/belt/trail.js +46 -11
- package/dist/agent/belt/trail.js.map +1 -1
- package/dist/agent/capabilities.js.map +1 -1
- package/dist/agent/fallback.d.ts +33 -0
- package/dist/agent/fallback.js +84 -0
- package/dist/agent/fallback.js.map +1 -0
- package/dist/agent/loop.d.ts +54 -52
- package/dist/agent/loop.js +173 -176
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/models.d.ts +10 -6
- package/dist/agent/models.js +15 -9
- package/dist/agent/models.js.map +1 -1
- package/dist/agent/prompts/compose.d.ts +1 -1
- package/dist/agent/prompts/debug-agent.js +45 -8
- package/dist/agent/prompts/debug-agent.js.map +1 -1
- package/dist/agent/prompts/web-addendum.d.ts +1 -1
- package/dist/agent/prompts/web-addendum.js +15 -3
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/agent/provider.d.ts +38 -0
- package/dist/agent/provider.js +55 -3
- package/dist/agent/provider.js.map +1 -1
- package/dist/boot.d.ts +64 -0
- package/dist/boot.js +145 -0
- package/dist/boot.js.map +1 -0
- package/dist/cli/chromium-libs.d.ts +262 -0
- package/dist/cli/chromium-libs.js +522 -0
- package/dist/cli/chromium-libs.js.map +1 -0
- package/dist/cli/control.js +51 -9
- package/dist/cli/control.js.map +1 -1
- package/dist/cli/init.d.ts +52 -3
- package/dist/cli/init.js +62 -10
- package/dist/cli/init.js.map +1 -1
- package/dist/config/load.d.ts +25 -8
- package/dist/config/load.js +40 -13
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +18 -6
- package/dist/config/schema.js +22 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +18 -0
- package/dist/errors.js.map +1 -1
- package/dist/findings/schema.d.ts +44 -6
- package/dist/findings/schema.js +39 -3
- package/dist/findings/schema.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +4 -82
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/describe.d.ts +5 -4
- package/dist/mcp/tools/describe.js +14 -10
- package/dist/mcp/tools/describe.js.map +1 -1
- package/dist/mcp/tools/end-session.d.ts +3 -1
- package/dist/mcp/tools/end-session.js +7 -3
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +5 -4
- package/dist/mcp/tools/output.js +10 -2
- package/dist/mcp/tools/output.js.map +1 -1
- package/dist/mcp/tools/result.d.ts +10 -1
- package/dist/mcp/tools/result.js +8 -6
- package/dist/mcp/tools/result.js.map +1 -1
- package/dist/mcp/tools/start-debug.js +7 -5
- package/dist/mcp/tools/start-debug.js.map +1 -1
- package/dist/redact.d.ts +28 -0
- package/dist/redact.js +51 -0
- package/dist/redact.js.map +1 -0
- package/dist/services/catalog.d.ts +28 -0
- package/dist/services/catalog.js +65 -0
- package/dist/services/catalog.js.map +1 -0
- package/dist/services/debug-api.d.ts +172 -0
- package/dist/services/debug-api.js +9 -0
- package/dist/services/debug-api.js.map +1 -0
- package/dist/services/debug-service.d.ts +25 -173
- package/dist/services/debug-service.js +108 -175
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/login.d.ts +7 -2
- package/dist/services/login.js +203 -29
- package/dist/services/login.js.map +1 -1
- package/dist/services/retained-snapshot.d.ts +36 -0
- package/dist/services/retained-snapshot.js +63 -0
- package/dist/services/retained-snapshot.js.map +1 -0
- package/dist/services/session-builder.d.ts +26 -0
- package/dist/services/session-builder.js +46 -19
- package/dist/services/session-builder.js.map +1 -1
- package/dist/services/start-guards.d.ts +32 -0
- package/dist/services/start-guards.js +50 -0
- package/dist/services/start-guards.js.map +1 -0
- package/dist/services/summarize.d.ts +12 -3
- package/dist/services/summarize.js +13 -5
- package/dist/services/summarize.js.map +1 -1
- package/dist/session/cleanup.js.map +1 -1
- package/dist/session/findings-store.d.ts +2 -1
- package/dist/session/findings-store.js +30 -2
- package/dist/session/findings-store.js.map +1 -1
- package/dist/session/live-pointer.d.ts +19 -0
- package/dist/session/live-pointer.js +41 -0
- package/dist/session/live-pointer.js.map +1 -0
- package/dist/session/manager.d.ts +11 -1
- package/dist/session/manager.js +46 -2
- package/dist/session/manager.js.map +1 -1
- package/dist/session/owner-lock.d.ts +208 -0
- package/dist/session/owner-lock.js +499 -0
- package/dist/session/owner-lock.js.map +1 -0
- package/dist/session/process-identity.js.map +1 -1
- package/dist/session/session.js +61 -7
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +74 -14
- package/dist/session/state-file.js +203 -21
- package/dist/session/state-file.js.map +1 -1
- package/package.json +7 -7
- package/dist/adapters/android/android-adapter.test-helpers.d.ts +0 -52
- package/dist/adapters/android/android-adapter.test-helpers.js +0 -115
- package/dist/adapters/android/android-adapter.test-helpers.js.map +0 -1
- package/dist/mcp/server.test-helpers.d.ts +0 -23
- package/dist/mcp/server.test-helpers.js +0 -49
- package/dist/mcp/server.test-helpers.js.map +0 -1
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exclusive workspace ownership — a kernel-held lock.
|
|
3
|
+
*
|
|
4
|
+
* Exclusion is `flock(2)` (`LOCK_EX | LOCK_NB`) on `<workspace>/owner.lock`,
|
|
5
|
+
* held on an open fd for as long as this process owns the workspace. A live
|
|
6
|
+
* owner's exclusion is NON-REVOCABLE: no contender, and no recovery logic, can
|
|
7
|
+
* take it or remove it — the kernel refuses every other `flock` on the file —
|
|
8
|
+
* and the kernel releases it when the owner dies. Both halves replace the
|
|
9
|
+
* previous claim-file protocol, which published a link(2)'d claim and reclaimed
|
|
10
|
+
* a stale one with a verified rename-aside into a `.reclaiming-*` quarantine.
|
|
11
|
+
* That protocol's recovery could restore one live owner's claim over another
|
|
12
|
+
* (two stranded quarantines, resolved in readdir order, left the wrong holder
|
|
13
|
+
* at the path and admitted a second owner — PR #104). With the kernel as the
|
|
14
|
+
* referee there is no judgment about a previous holder's liveness, no reclaim,
|
|
15
|
+
* no hole, no quarantine, and nothing to recover: a dead holder is simply a
|
|
16
|
+
* lock nobody holds.
|
|
17
|
+
*
|
|
18
|
+
* `owner.lock` is a NOTICE BOARD, not the lock: the owner writes its claim
|
|
19
|
+
* (pid + process identity + session) under the lock, and a refused contender
|
|
20
|
+
* reads it to name the holder in its error. Two invariants keep the flock
|
|
21
|
+
* sound, and both are absolute:
|
|
22
|
+
*
|
|
23
|
+
* 1. The file is NEVER unlinked. `flock` binds to the inode; unlinking the
|
|
24
|
+
* path and letting a rival create a fresh file hands that rival a lock on a
|
|
25
|
+
* different inode while the old one is still held — two owners. Release
|
|
26
|
+
* empties the file and unlocks; the empty file itself is litter.
|
|
27
|
+
* 2. Only the process holding the lock ever writes or unlocks. A refused
|
|
28
|
+
* contender only ever reads.
|
|
29
|
+
*
|
|
30
|
+
* Re-entrancy is per process identity (pid + start ticks): `flock` treats each
|
|
31
|
+
* open file description as an independent contender — even two fds in ONE
|
|
32
|
+
* process contend — so the acquiring fd is kept in a registry keyed by lock
|
|
33
|
+
* path and reused. A second claim from this process with a DIFFERENT identity
|
|
34
|
+
* is refused like a foreign process: it opens its own fd and the kernel
|
|
35
|
+
* refuses it.
|
|
36
|
+
*
|
|
37
|
+
* Litter from the previous protocol (`.reclaiming-*` quarantines, a stray
|
|
38
|
+
* `owner.lock.reclaim` mutex, an empty or stale claim file) is inert: nothing
|
|
39
|
+
* reads or removes it. It cannot resurrect an owner — exclusion lives in the
|
|
40
|
+
* kernel, not in file contents.
|
|
41
|
+
*
|
|
42
|
+
* `flock` comes from the kernel, and the RUNTIME decides how this process
|
|
43
|
+
* reaches it. Under Bun it is libc's, through Bun's FFI; under Node there is
|
|
44
|
+
* no FFI, so the very same kernel lock is taken by util-linux's `flock(1)`,
|
|
45
|
+
* applied to the descriptor this process already holds. Either way it is ONE
|
|
46
|
+
* lock on ONE file: the kernel refuses every other `flock` on it, and it dies
|
|
47
|
+
* with the descriptor. The server targets Linux (see CLAUDE.md); the glibc and
|
|
48
|
+
* musl sonames and the macOS libc are covered, and anything else fails loud —
|
|
49
|
+
* a silent fallback here would be two processes both believing they own the
|
|
50
|
+
* workspace.
|
|
51
|
+
*
|
|
52
|
+
* The FFI access is DYNAMIC: the published bin runs on Node (`package.json` →
|
|
53
|
+
* `dist/main.js` behind `#!/usr/bin/env node`), where `bun:ffi` does not
|
|
54
|
+
* exist — a static import would crash the module on LOAD, before any probe
|
|
55
|
+
* could report why. The boot gate ({@link assertOwnerLockBackend}) resolves
|
|
56
|
+
* the backend BEFORE the server comes up: a host that cannot provide one can
|
|
57
|
+
* never enforce the one-run rule.
|
|
58
|
+
*/
|
|
59
|
+
import { spawn } from 'node:child_process';
|
|
60
|
+
import { accessSync, closeSync, constants as fsConstants, ftruncateSync, openSync, readFileSync, writeSync, } from 'node:fs';
|
|
61
|
+
import { delimiter, join } from 'node:path';
|
|
62
|
+
import { z } from 'zod';
|
|
63
|
+
import { SessionBusyError, WorkspaceError } from '../errors.js';
|
|
64
|
+
import { ProcessIdentitySchema } from './process-identity.js';
|
|
65
|
+
/** The owner recorded in `<workspace>/owner.lock`. */
|
|
66
|
+
export const OwnerLockSchema = z.object({
|
|
67
|
+
/** Server process id. */
|
|
68
|
+
pid: z.number().int().positive(),
|
|
69
|
+
/** Process fingerprint that distinguishes this owner from a recycled PID. */
|
|
70
|
+
identity: ProcessIdentitySchema,
|
|
71
|
+
/** Session that acquired the claim. */
|
|
72
|
+
sessionId: z.string(),
|
|
73
|
+
/** ISO timestamp the claim was acquired. */
|
|
74
|
+
acquiredAt: z.string(),
|
|
75
|
+
});
|
|
76
|
+
/** A live owner holds the lock. */
|
|
77
|
+
export class OwnerLockBusyError extends SessionBusyError {
|
|
78
|
+
}
|
|
79
|
+
/** `<workspace.root>/owner.lock` */
|
|
80
|
+
export function ownerLockPath(workspace) {
|
|
81
|
+
return join(workspace.root, 'owner.lock');
|
|
82
|
+
}
|
|
83
|
+
/** flock(2) operations — the Linux/glibc values, identical on the BSDs and macOS. */
|
|
84
|
+
const LOCK_EX = 2;
|
|
85
|
+
const LOCK_NB = 4;
|
|
86
|
+
const LOCK_UN = 8;
|
|
87
|
+
/** libc sonames carrying `flock`, in probe order (glibc, musl, macOS). */
|
|
88
|
+
export const LIBC_CANDIDATES = [
|
|
89
|
+
'libc.so.6',
|
|
90
|
+
'libc.musl-x86_64.so.1',
|
|
91
|
+
'libc.musl-aarch64.so.1',
|
|
92
|
+
'libc.dylib',
|
|
93
|
+
];
|
|
94
|
+
/**
|
|
95
|
+
* The FFI module, loaded DYNAMICALLY.
|
|
96
|
+
*
|
|
97
|
+
* `bun:ffi` exists only under Bun, and the published bin runs on Node: a
|
|
98
|
+
* static import of it crashes the module on LOAD, before any probe can report
|
|
99
|
+
* why the backend is missing. A failed load is NOT cached — the next attempt
|
|
100
|
+
* retries, so a host that gains the backend (or a later boot in the same
|
|
101
|
+
* process) is not stuck with the first failure.
|
|
102
|
+
*/
|
|
103
|
+
let ffiModule;
|
|
104
|
+
async function loadFfi() {
|
|
105
|
+
if (ffiModule !== undefined)
|
|
106
|
+
return ffiModule;
|
|
107
|
+
let loaded;
|
|
108
|
+
try {
|
|
109
|
+
loaded = await import('bun:ffi');
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
// The runtime has no FFI backend AT ALL (Node): say so plainly. "flock is
|
|
113
|
+
// missing" would send an operator hunting for the wrong libc, when the
|
|
114
|
+
// backend that could have opened one was never there.
|
|
115
|
+
throw new WorkspaceError(`no FFI backend on this runtime — bun:ffi is unavailable: ${error.message}`);
|
|
116
|
+
}
|
|
117
|
+
ffiModule = loaded;
|
|
118
|
+
return loaded;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The default opener: the platform's libc, through Bun's FFI.
|
|
122
|
+
*
|
|
123
|
+
* Exported so a test can compose a failing opener with the REAL backend: a
|
|
124
|
+
* stub symbol cannot prove that a kernel lock was actually taken.
|
|
125
|
+
*/
|
|
126
|
+
export async function openFlockInLibc(soname) {
|
|
127
|
+
const ffi = await loadFfi();
|
|
128
|
+
const lib = ffi.dlopen(soname, {
|
|
129
|
+
flock: { args: [ffi.FFIType.int, ffi.FFIType.int], returns: ffi.FFIType.int },
|
|
130
|
+
});
|
|
131
|
+
return lib.symbols.flock;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Probe the libc candidates for `flock(2)`.
|
|
135
|
+
*
|
|
136
|
+
* Fails loud, naming the platform and EVERY soname tried with what each one
|
|
137
|
+
* said: an operator needs to know which libc was looked for, not just that
|
|
138
|
+
* "something went wrong".
|
|
139
|
+
*/
|
|
140
|
+
async function resolveFlock(opener) {
|
|
141
|
+
const misses = [];
|
|
142
|
+
for (const name of LIBC_CANDIDATES) {
|
|
143
|
+
try {
|
|
144
|
+
return await opener(name);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
// A house error is a BACKEND-level failure, not a soname-level miss: the
|
|
148
|
+
// FFI itself could not be loaded, so no libc was ever opened. Folding it
|
|
149
|
+
// into the misses would name sonames that were never tried and bury the
|
|
150
|
+
// one fact that matters ("this runtime has no FFI backend") — so it goes
|
|
151
|
+
// out unchanged.
|
|
152
|
+
if (error instanceof WorkspaceError)
|
|
153
|
+
throw error;
|
|
154
|
+
misses.push(`${name}: ${error.message}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
throw new WorkspaceError(`cannot load flock(2) for the workspace ownership lock on ${process.platform} ` +
|
|
158
|
+
`(tried ${LIBC_CANDIDATES.join(', ')}): ${misses.join('; ')}`);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The backend over a RESOLVED `flock(2)` symbol.
|
|
162
|
+
*
|
|
163
|
+
* The symbol is the libc one, so the unlock is an explicit `LOCK_UN` — and
|
|
164
|
+
* the descriptor is closed even when that call fails, because closing alone
|
|
165
|
+
* releases the flock and a descriptor left open would keep the kernel lock
|
|
166
|
+
* alive with no registry entry to reach it by.
|
|
167
|
+
*/
|
|
168
|
+
function symbolBackend(flock) {
|
|
169
|
+
return {
|
|
170
|
+
async tryLock(fd) {
|
|
171
|
+
return flock(fd, LOCK_EX | LOCK_NB) === 0;
|
|
172
|
+
},
|
|
173
|
+
release(fd) {
|
|
174
|
+
try {
|
|
175
|
+
flock(fd, LOCK_UN);
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
closeSync(fd);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The Bun-side backend: libc's `flock(2)`, through Bun's FFI.
|
|
185
|
+
*
|
|
186
|
+
* `bun:ffi` is a Bun-only module, and a STATIC import of it would make every
|
|
187
|
+
* installed copy die on Node with ERR_UNSUPPORTED_ESM_URL_SCHEME before it
|
|
188
|
+
* could print its own help — the published bin runs on the node floor
|
|
189
|
+
* package.json declares. So the import is dynamic ({@link loadFfi}), and only
|
|
190
|
+
* the runtime check that picks this backend ever reaches it.
|
|
191
|
+
*/
|
|
192
|
+
async function bunFlockBackend() {
|
|
193
|
+
return symbolBackend(await resolveFlock(openFlockInLibc));
|
|
194
|
+
}
|
|
195
|
+
/** util-linux `flock(1)`'s exit code for "another process holds the lock". */
|
|
196
|
+
const FLOCK_CONFLICT_EXIT = 42;
|
|
197
|
+
/**
|
|
198
|
+
* The slot our descriptor rides in on the child's stdio.
|
|
199
|
+
*
|
|
200
|
+
* `flock(1)` locks THAT descriptor — the one this process already holds — so
|
|
201
|
+
* the lock lands on the open file description we keep: it stays ours after the
|
|
202
|
+
* child exits, every rival is refused by the kernel, and the kernel drops it
|
|
203
|
+
* when we close the descriptor or die.
|
|
204
|
+
*/
|
|
205
|
+
const CHILD_FD = 3;
|
|
206
|
+
/** Run util-linux's `flock(1)` against our descriptor and read what it decided. */
|
|
207
|
+
function runFlockCli(fd, bin) {
|
|
208
|
+
return new Promise((resolve) => {
|
|
209
|
+
const child = spawn(bin, [
|
|
210
|
+
'--exclusive',
|
|
211
|
+
'--nonblock',
|
|
212
|
+
'--conflict-exit-code',
|
|
213
|
+
String(FLOCK_CONFLICT_EXIT),
|
|
214
|
+
String(CHILD_FD),
|
|
215
|
+
], { stdio: ['ignore', 'ignore', 'pipe', fd] });
|
|
216
|
+
let stderr = '';
|
|
217
|
+
child.stderr?.on('data', (chunk) => {
|
|
218
|
+
stderr += chunk.toString();
|
|
219
|
+
});
|
|
220
|
+
child.on('error', (error) => {
|
|
221
|
+
resolve({
|
|
222
|
+
granted: false,
|
|
223
|
+
conflict: false,
|
|
224
|
+
detail: `cannot run ${bin} to take the workspace lock: ${error.message}`,
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
child.on('close', (code) => {
|
|
228
|
+
if (code === 0) {
|
|
229
|
+
resolve({ granted: true, conflict: false, detail: '' });
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (code === FLOCK_CONFLICT_EXIT) {
|
|
233
|
+
resolve({ granted: false, conflict: true, detail: '' });
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
resolve({
|
|
237
|
+
granted: false,
|
|
238
|
+
conflict: false,
|
|
239
|
+
detail: `${bin} could not take the workspace lock (exit ${code ?? 'none'}): ` +
|
|
240
|
+
(stderr.trim() || 'no output'),
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* `flock(2)` through util-linux's `flock(1)` — how Node reaches the syscall.
|
|
247
|
+
*
|
|
248
|
+
* Node has no FFI, so a short-lived child inherits our descriptor and locks
|
|
249
|
+
* it. The child exits at once; the lock stays ours because it lives on the
|
|
250
|
+
* open file description we still hold, and the kernel drops it when that
|
|
251
|
+
* descriptor closes or this process dies — a crashed owner never wedges the
|
|
252
|
+
* workspace.
|
|
253
|
+
*
|
|
254
|
+
* `bin` is a seam: the tests point it at a binary that does not exist to
|
|
255
|
+
* prove the failure is loud instead of a quiet "nobody holds this".
|
|
256
|
+
*/
|
|
257
|
+
export async function nodeFlockBackend(bin = 'flock') {
|
|
258
|
+
return {
|
|
259
|
+
async tryLock(fd) {
|
|
260
|
+
const outcome = await runFlockCli(fd, bin);
|
|
261
|
+
if (outcome.granted)
|
|
262
|
+
return true;
|
|
263
|
+
if (outcome.conflict)
|
|
264
|
+
return false;
|
|
265
|
+
throw new WorkspaceError(`cannot take the workspace ownership lock on ${process.platform}: ${outcome.detail}`);
|
|
266
|
+
},
|
|
267
|
+
release(fd) {
|
|
268
|
+
// Closing IS the unlock here: the child is long gone, so ours is the
|
|
269
|
+
// last descriptor referring to the locked description, and the kernel
|
|
270
|
+
// drops the flock when it closes.
|
|
271
|
+
closeSync(fd);
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The backend for THIS runtime, resolved fresh.
|
|
277
|
+
*
|
|
278
|
+
* Bun reaches libc through its own FFI; Node has none, so the same kernel
|
|
279
|
+
* lock comes from util-linux's `flock(1)`. The choice is the runtime's, made
|
|
280
|
+
* once — never a fallback: a platform with neither fails loud at first use
|
|
281
|
+
* rather than pretending the workspace is free.
|
|
282
|
+
*/
|
|
283
|
+
function createBackend() {
|
|
284
|
+
return 'bun' in process.versions ? bunFlockBackend() : nodeFlockBackend();
|
|
285
|
+
}
|
|
286
|
+
/** The resolved backend of THIS runtime, cached once it is known to work. */
|
|
287
|
+
let backend;
|
|
288
|
+
function loadBackend() {
|
|
289
|
+
backend ??= createBackend().catch((error) => {
|
|
290
|
+
// A failed resolution is not a verdict: the next attempt retries instead
|
|
291
|
+
// of replaying a dead one.
|
|
292
|
+
backend = undefined;
|
|
293
|
+
throw error;
|
|
294
|
+
});
|
|
295
|
+
return backend;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* The gate's Node-side check: util-linux's `flock(1)` must be reachable.
|
|
299
|
+
*
|
|
300
|
+
* The Node backend reaches the kernel through that binary, so a host without
|
|
301
|
+
* it can never enforce the one-run rule — the same hole the libc probe closes
|
|
302
|
+
* on Bun. Nothing is locked and no file is touched: this only asks whether
|
|
303
|
+
* the binary is there.
|
|
304
|
+
*/
|
|
305
|
+
function assertFlockCli(bin = 'flock') {
|
|
306
|
+
for (const dir of (process.env.PATH ?? '').split(delimiter)) {
|
|
307
|
+
if (dir === '')
|
|
308
|
+
continue;
|
|
309
|
+
try {
|
|
310
|
+
accessSync(join(dir, bin), fsConstants.X_OK);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
// not this directory — keep looking
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
throw new WorkspaceError(`cannot take the workspace ownership lock on ${process.platform}: ` +
|
|
318
|
+
`${bin}(1) is not on PATH — the workspace lock needs util-linux's flock`);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* The BOOT GATE: resolve this host's `flock(2)` WITHOUT taking a lock.
|
|
322
|
+
*
|
|
323
|
+
* The workspace's one-run rule rests on a kernel-held lock. A host that cannot
|
|
324
|
+
* provide that backend can never enforce it — two servers would each believe
|
|
325
|
+
* they own the workspace — so the server refuses to come up instead. This
|
|
326
|
+
* runs BEFORE the workspace exists, before a config is read and before the MCP
|
|
327
|
+
* server starts.
|
|
328
|
+
*
|
|
329
|
+
* It RESOLVES the backend and nothing more: no file is opened, no `flock` is
|
|
330
|
+
* called, `<workspace>/owner.lock` is never created, and the acquire path's
|
|
331
|
+
* module cache is never written — an injected opener must not leak into the
|
|
332
|
+
* real one. A failed resolution is not cached either: the next attempt
|
|
333
|
+
* retries. A backend that failed outright (no FFI on this runtime) is
|
|
334
|
+
* reported as it is — never as a hunt through sonames it never opened.
|
|
335
|
+
*
|
|
336
|
+
* @param opener the libc seam to resolve through — the real one by default,
|
|
337
|
+
* injectable so a failed resolution is testable. An injected opener probes
|
|
338
|
+
* the libc candidates; without one, THIS runtime's own backend is resolved.
|
|
339
|
+
*/
|
|
340
|
+
export async function assertOwnerLockBackend(opener) {
|
|
341
|
+
if (opener !== undefined) {
|
|
342
|
+
await resolveFlock(opener);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if ('bun' in process.versions) {
|
|
346
|
+
await bunFlockBackend(); // resolves libc's `flock(2)` — takes no lock
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
assertFlockCli(); // Node has no FFI: util-linux's `flock(1)` is the backend
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* The locks this process holds, keyed by lock path. The fd must live as long
|
|
353
|
+
* as the ownership: `flock` is released when the fd closes, and the kernel
|
|
354
|
+
* releases it when the process dies — a crashed server never wedges anything.
|
|
355
|
+
*/
|
|
356
|
+
const holds = new Map();
|
|
357
|
+
/** Whether two owners identify the same live process. */
|
|
358
|
+
function sameOwner(left, right) {
|
|
359
|
+
return left.pid === right.pid && left.identity.startTicks === right.identity.startTicks;
|
|
360
|
+
}
|
|
361
|
+
/** The exact bytes an acquire writes for a claim. */
|
|
362
|
+
function serialize(owner) {
|
|
363
|
+
return `${JSON.stringify(owner, null, 2)}\n`;
|
|
364
|
+
}
|
|
365
|
+
/** Read and validate the claim on the notice board; `null` when absent or unreadable. */
|
|
366
|
+
function readHolder(lockPath) {
|
|
367
|
+
try {
|
|
368
|
+
const parsed = OwnerLockSchema.safeParse(JSON.parse(readFileSync(lockPath, 'utf8')));
|
|
369
|
+
return parsed.success ? parsed.data : null;
|
|
370
|
+
}
|
|
371
|
+
catch {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/** Rewrite the notice board under the lock we hold. */
|
|
376
|
+
function writeClaim(fd, owner) {
|
|
377
|
+
ftruncateSync(fd, 0);
|
|
378
|
+
writeSync(fd, serialize(owner), 0, 'utf8');
|
|
379
|
+
}
|
|
380
|
+
/** How often a busy contender re-reads an unreadable claim before failing loud. */
|
|
381
|
+
const BUSY_ATTEMPTS = 3;
|
|
382
|
+
/** Pause between those reads — covers a release (truncate → unlock) racing the read. */
|
|
383
|
+
const BUSY_RETRY_MS = 5;
|
|
384
|
+
/**
|
|
385
|
+
* Acquire the exclusive workspace claim.
|
|
386
|
+
*
|
|
387
|
+
* The publish is one non-blocking `flock(2)`: the kernel either grants this
|
|
388
|
+
* process the workspace or refuses it — there is no read-then-act window, so
|
|
389
|
+
* no rival can slip between a judgment and the act, and no admission can be
|
|
390
|
+
* invalidated after the fact. A refused contender reports the holder named on
|
|
391
|
+
* the notice board.
|
|
392
|
+
*
|
|
393
|
+
* An existing claim held by this same process (same pid + start ticks) is
|
|
394
|
+
* re-entrant and reports `created: false`; any fresh take — an empty workspace
|
|
395
|
+
* or one whose previous holder died — reports `created: true`.
|
|
396
|
+
*
|
|
397
|
+
* @param opener the backend to resolve `flock(2)` through — the real one by
|
|
398
|
+
* default, injectable so a failed resolution is testable. An injected
|
|
399
|
+
* opener resolves fresh on every call and never enters the module cache.
|
|
400
|
+
*/
|
|
401
|
+
export async function acquireOwnerLock(lockPath, owner, opener) {
|
|
402
|
+
// An INJECTED opener resolves fresh every time and never enters the module
|
|
403
|
+
// cache: a test's stub can never become the workspace's real lock backend.
|
|
404
|
+
const flock = opener !== undefined ? symbolBackend(await resolveFlock(opener)) : await loadBackend();
|
|
405
|
+
const held = holds.get(lockPath);
|
|
406
|
+
if (held !== undefined && sameOwner(held.owner, owner)) {
|
|
407
|
+
return { acquired: true, created: false }; // re-entrant: this process already owns it
|
|
408
|
+
}
|
|
409
|
+
for (let attempt = 0; attempt < BUSY_ATTEMPTS; attempt += 1) {
|
|
410
|
+
// O_RDWR | O_CREAT: create the notice board on the first take, never
|
|
411
|
+
// truncate it here — truncation is a write, and writes belong under the lock.
|
|
412
|
+
const fd = openSync(lockPath, fsConstants.O_RDWR | fsConstants.O_CREAT, 0o644);
|
|
413
|
+
let locked = false;
|
|
414
|
+
try {
|
|
415
|
+
locked = await flock.tryLock(fd);
|
|
416
|
+
}
|
|
417
|
+
finally {
|
|
418
|
+
if (!locked)
|
|
419
|
+
closeSync(fd);
|
|
420
|
+
}
|
|
421
|
+
if (locked) {
|
|
422
|
+
try {
|
|
423
|
+
writeClaim(fd, owner);
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
closeSync(fd); // closing releases the lock — a half-written claim owns nothing
|
|
427
|
+
throw error;
|
|
428
|
+
}
|
|
429
|
+
holds.set(lockPath, { fd, owner, flock });
|
|
430
|
+
return { acquired: true, created: true };
|
|
431
|
+
}
|
|
432
|
+
// The kernel refused: the holder is provably alive, whatever the file says.
|
|
433
|
+
// Name it from the notice board — unless it names US, which happens when a
|
|
434
|
+
// same-process acquire raced this one and won: that is re-entrance, not
|
|
435
|
+
// busy (pid + start ticks cannot belong to another process).
|
|
436
|
+
const holder = readHolder(lockPath);
|
|
437
|
+
if (holder !== null) {
|
|
438
|
+
if (sameOwner(holder, owner))
|
|
439
|
+
return { acquired: true, created: false };
|
|
440
|
+
return { acquired: false, holder };
|
|
441
|
+
}
|
|
442
|
+
// A release (truncate → unlock) racing this read can leave the file
|
|
443
|
+
// momentarily empty — retry the flock itself before concluding anything.
|
|
444
|
+
await new Promise((resolve) => setTimeout(resolve, BUSY_RETRY_MS));
|
|
445
|
+
}
|
|
446
|
+
throw new OwnerLockBusyError('owner lock is held by another process, but its claim file could not be read');
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Release the claim only when this process still holds it.
|
|
450
|
+
*
|
|
451
|
+
* Returns `false` when this process holds nothing here (or a different owner
|
|
452
|
+
* does) — another owner's lock is never touched. The notice board is emptied,
|
|
453
|
+
* never unlinked: a stale claim file must never be mistaken for a held lock,
|
|
454
|
+
* and unlinking the path would put a fresh inode where the owner's lock lives.
|
|
455
|
+
*
|
|
456
|
+
* The lock ALWAYS comes home: the release runs in a `finally`, so a failed
|
|
457
|
+
* board write (a read-only remount, say) fails loud but cannot leave this
|
|
458
|
+
* process holding the kernel lock with no registry entry to reach it by —
|
|
459
|
+
* that would wedge every rival until the process exits (PR #104 review).
|
|
460
|
+
*
|
|
461
|
+
* @param emptyBoard the notice-board teardown, injectable for tests (defaults
|
|
462
|
+
* to truncating the file to nothing) — the same seam doctrine as `makeExec`'s
|
|
463
|
+
* `now`: a failure injected through the parameter never leaks into other
|
|
464
|
+
* test files the way a module mock does.
|
|
465
|
+
* @param unlock the `flock(LOCK_UN)` call, injectable for tests. Its failure
|
|
466
|
+
* must not keep the fd open: closing it alone releases the flock, and a fd
|
|
467
|
+
* left open would keep the kernel lock alive with no registry entry to
|
|
468
|
+
* reach it by. Without an injected unlock, the backend that took the lock
|
|
469
|
+
* gives it back — and disposes of the descriptor with it.
|
|
470
|
+
*/
|
|
471
|
+
export async function releaseOwnerLock(lockPath, owner, emptyBoard = (fd) => ftruncateSync(fd, 0), unlock) {
|
|
472
|
+
const held = holds.get(lockPath);
|
|
473
|
+
if (held === undefined || !sameOwner(held.owner, owner))
|
|
474
|
+
return false;
|
|
475
|
+
holds.delete(lockPath); // teardown has begun — the registry names no hold from here
|
|
476
|
+
try {
|
|
477
|
+
emptyBoard(held.fd); // the board names no owner once we are out
|
|
478
|
+
}
|
|
479
|
+
finally {
|
|
480
|
+
if (unlock !== undefined) {
|
|
481
|
+
try {
|
|
482
|
+
await unlock(held.fd);
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
// The fd closes even when the unlock fails: closing alone releases the
|
|
486
|
+
// flock, and a fd left open would keep the kernel lock alive with no
|
|
487
|
+
// registry entry to reach it by.
|
|
488
|
+
closeSync(held.fd);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
// The backend that took the lock gives it back — and disposes of the
|
|
493
|
+
// descriptor, which alone releases the flock even after a failed write.
|
|
494
|
+
held.flock.release(held.fd);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
//# sourceMappingURL=owner-lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-lock.js","sourceRoot":"","sources":["../../src/session/owner-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,IAAI,WAAW,EACxB,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,sDAAsD;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,yBAAyB;IACzB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAChC,6EAA6E;IAC7E,QAAQ,EAAE,qBAAqB;IAC/B,uCAAuC;IACvC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,4CAA4C;IAC5C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;CACvB,CAAC,CAAC;AAIH,mCAAmC;AACnC,MAAM,OAAO,kBAAmB,SAAQ,gBAAgB;CAAG;AAE3D,oCAAoC;AACpC,MAAM,UAAU,aAAa,CAAC,SAAyB;IACrD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;AAC5C,CAAC;AAED,qFAA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+115,7 @@ export class Session {
|
|
|
115
115
|
// settles `failed`, never the verdict it may have written just before close.
|
|
116
116
|
if (this.#abort.signal.aborted) {
|
|
117
117
|
this.#status = 'failed';
|
|
118
|
+
await this.#persistAbortedVerdict();
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
121
|
this.#status = await this.#verdict();
|
|
@@ -129,12 +130,45 @@ export class Session {
|
|
|
129
130
|
}
|
|
130
131
|
catch (error) {
|
|
131
132
|
this.#status = 'failed';
|
|
132
|
-
// Aborted by `close()` — the teardown is the verdict
|
|
133
|
-
|
|
133
|
+
// Aborted by `close()` — the teardown is the verdict, not the agent's failure:
|
|
134
|
+
// persist the terminal `failed` record (replacing any stale `running`/`passed`
|
|
135
|
+
// snapshot) and skip the agent-error surfacing.
|
|
136
|
+
if (this.#abort.signal.aborted) {
|
|
137
|
+
await this.#persistAbortedVerdict();
|
|
134
138
|
return;
|
|
139
|
+
}
|
|
135
140
|
await this.#surfaceAgentError(error);
|
|
136
141
|
}
|
|
137
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Persist the aborted run's terminal `failed` verdict, replacing any stale
|
|
145
|
+
* `running`/`passed` snapshot while preserving every step, bug, visual finding
|
|
146
|
+
* and evidence pointer already streamed before the abort.
|
|
147
|
+
*
|
|
148
|
+
* The summary is the one field NOT carried over blindly: prose the driver wrote
|
|
149
|
+
* under a `passed` verdict claims success, and the abort overrules that verdict —
|
|
150
|
+
* kept as-is it would read "all good" under a `failed` status and send the
|
|
151
|
+
* caller hunting for a clean run that never happened. A summary written under a
|
|
152
|
+
* `failed` verdict already describes the failure, so it stays.
|
|
153
|
+
*/
|
|
154
|
+
async #persistAbortedVerdict() {
|
|
155
|
+
const prior = await this.#findingsStore.tryReadFindings().catch(() => null);
|
|
156
|
+
const carriedSummary = prior?.status === 'failed' ? prior.summary : undefined;
|
|
157
|
+
try {
|
|
158
|
+
await this.#findingsStore.writeFindings({
|
|
159
|
+
...prior,
|
|
160
|
+
status: this.#status,
|
|
161
|
+
steps: prior?.steps ?? [],
|
|
162
|
+
bugs: prior?.bugs ?? [],
|
|
163
|
+
visual: prior?.visual ?? [],
|
|
164
|
+
// Overrides the spread's summary — a success summary never survives the abort.
|
|
165
|
+
summary: carriedSummary,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// Best-effort persistence — the in-memory terminal status still stands.
|
|
170
|
+
}
|
|
171
|
+
}
|
|
138
172
|
/** Hand the loop every pending message and clear the queue (the `LoopInbox` seam over `#inbox`). */
|
|
139
173
|
#drainInbox() {
|
|
140
174
|
return this.#inbox.splice(0, this.#inbox.length);
|
|
@@ -181,15 +215,31 @@ export class Session {
|
|
|
181
215
|
}
|
|
182
216
|
/**
|
|
183
217
|
* Record, as the summary, the fact that the run produced no verdict — naming
|
|
184
|
-
* what actually happened and what to do about it, with no invented cause
|
|
218
|
+
* what actually happened and what to do about it, with no invented cause and
|
|
219
|
+
* never a model in the loop (deterministic counts and framing only). Two
|
|
220
|
+
* branches, one terminal framing: when the loop streamed evidence before the
|
|
221
|
+
* cap (the `progressForStep` running writes), the summary names those leads by
|
|
222
|
+
* count as partial and unconfirmed — the arrays below carry them — and never
|
|
223
|
+
* claims the run recorded nothing; a truly empty run keeps that claim. Both
|
|
224
|
+
* branches lead with the no-verdict fact and close with the same cut-short
|
|
225
|
+
* guidance, so an empty and a partial run read the same way.
|
|
185
226
|
*/
|
|
186
227
|
async #writeUnreportedSummary(findings) {
|
|
187
228
|
const steps = findings.steps ?? [];
|
|
229
|
+
const bugs = findings.bugs ?? [];
|
|
230
|
+
const visual = findings.visual ?? [];
|
|
188
231
|
const failed = steps.filter((step) => step.ok === false).length;
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
232
|
+
const lead = 'Run ended WITHOUT a verdict: the driver used up its step budget without calling `report`';
|
|
233
|
+
const evidence = bugs.length + visual.length > 0
|
|
234
|
+
? `. ${plural(bugs.length, 'bug')} and ${plural(visual.length, 'visual issue')} streamed in ` +
|
|
235
|
+
'before the cap as partial, unconfirmed leads and are preserved below — none was ' +
|
|
236
|
+
'confirmed by a `report`. '
|
|
237
|
+
: ', so no findings were recorded. ';
|
|
238
|
+
const summary = lead +
|
|
239
|
+
evidence +
|
|
240
|
+
`${steps.length} step(s) ran (${failed} failed) — read the step trail and screenshots for ` +
|
|
241
|
+
'what it actually did. This is NOT a clean pass and NOT evidence of a crash: the run was ' +
|
|
242
|
+
'simply cut short. Re-run with a narrower goal, or raise `timeout`.';
|
|
193
243
|
await this.#findingsStore.writeFindings({ ...findings, status: this.#status, summary });
|
|
194
244
|
}
|
|
195
245
|
/**
|
|
@@ -348,4 +398,8 @@ function toAgentError(error) {
|
|
|
348
398
|
function hasText(value) {
|
|
349
399
|
return typeof value === 'string' && value.trim().length > 0;
|
|
350
400
|
}
|
|
401
|
+
/** `plural(1, 'bug')` → '1 bug'; `plural(2, 'bug')` → '2 bugs' — the summary's deterministic counts. */
|
|
402
|
+
function plural(n, noun) {
|
|
403
|
+
return `${n} ${noun}${n === 1 ? '' : 's'}`;
|
|
404
|
+
}
|
|
351
405
|
//# sourceMappingURL=session.js.map
|