@awebai/oats 0.50.0 → 0.52.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 +1 -0
- package/bin/oats.mjs +153 -51
- package/docs/capabilities.md +11 -3
- package/docs/configuration.md +134 -88
- package/docs/desktop-cli-api.md +994 -71
- package/docs/desktop-instance-start.md +56 -0
- package/docs/desktop.md +10 -7
- package/docs/execution-targets.md +230 -59
- package/docs/first-team.md +3 -1
- package/docs/harness-trust.md +50 -2
- package/docs/implementation.md +73 -8
- package/docs/integrations.md +9 -8
- package/docs/knowledge-reference/acceptance.md +1 -0
- package/docs/knowledge-reference/harvester.md +5 -3
- package/docs/knowledge-reference/model.md +5 -3
- package/docs/knowledge-theory.md +1 -1
- package/docs/knowledge.md +43 -7
- package/docs/launch-prompt-completion.md +50 -48
- package/docs/oats-local.schema.json +4 -3
- package/docs/official-catalog.md +4 -4
- package/docs/packages.md +14 -14
- package/docs/release-lane.md +15 -5
- package/docs/release-notes/v0.44.0.md +1 -1
- package/docs/release-notes/v0.51.0.md +156 -0
- package/docs/release-notes/v0.52.0.md +933 -0
- package/docs/schedules.md +91 -4
- package/docs/servers.md +21 -2
- package/docs/souls-and-instances.md +113 -21
- package/docs/tui.md +152 -0
- package/docs/workspaces.md +2 -2
- package/lib/claim.mjs +266 -0
- package/lib/core.mjs +845 -166
- package/lib/errors.mjs +170 -0
- package/lib/harness-trust-write.mjs +68 -27
- package/lib/harness-trust.mjs +34 -16
- package/lib/instance-inspect.mjs +40 -11
- package/lib/instance-lifecycle.mjs +169 -47
- package/lib/launch-preference.mjs +16 -0
- package/lib/launch-prompt-completion.mjs +7 -43
- package/lib/launch-prompt-evidence.mjs +14 -7
- package/lib/launch-prompt-fixtures/README.md +86 -152
- package/lib/launch-prompt-fixtures/dev-channel-confirmation.json +50 -0
- package/lib/launch-prompt-fixtures.mjs +122 -109
- package/lib/launch-prompt-transport.mjs +2 -56
- package/lib/launch-prompts.mjs +102 -100
- package/lib/schedule-host.mjs +154 -22
- package/lib/schedule.mjs +73 -24
- package/lib/servers.mjs +20 -4
- package/lib/session-viewer.mjs +87 -10
- package/lib/system-tools.mjs +39 -0
- package/lib/tmux-server-scope.mjs +62 -0
- package/lib/triggers.mjs +4 -4
- package/lib/workspace.mjs +5 -11
- package/lib/worktree-hooks.mjs +116 -23
- package/lib/worktree.mjs +89 -102
- package/package-catalog.json +3 -3
- package/package.json +7 -2
- package/packages/client/capability-show-contract.mjs +230 -0
- package/packages/client/capability-warnings-contract.mjs +57 -0
- package/packages/client/cli-adapter.mjs +548 -0
- package/packages/client/cli-environment.mjs +53 -0
- package/packages/client/cli-locator.mjs +253 -0
- package/packages/client/cli-probe-contract.mjs +47 -0
- package/packages/client/client-terms.mjs +60 -0
- package/packages/client/deployment-contract.mjs +68 -0
- package/packages/client/deployment-data.mjs +483 -0
- package/packages/client/deployment-facts.mjs +34 -0
- package/packages/client/deployment-label.mjs +76 -0
- package/packages/client/deployment-observer.mjs +89 -0
- package/packages/client/deployment-panel.mjs +142 -0
- package/packages/client/deployment-read-cli.mjs +53 -0
- package/packages/client/display-text.mjs +44 -0
- package/packages/client/harness-names.mjs +30 -0
- package/packages/client/inspect-contract.mjs +62 -0
- package/packages/client/instance-acts.mjs +54 -0
- package/packages/client/instance-admission.mjs +45 -0
- package/packages/client/instance-events-contract.mjs +74 -0
- package/packages/client/instance-git-contract.mjs +80 -0
- package/packages/client/instance-presentation.mjs +22 -0
- package/packages/client/instance-tree.mjs +453 -0
- package/packages/client/kernel-environment.mjs +11 -0
- package/packages/client/launch-contract.mjs +51 -0
- package/packages/client/launch-prompt-outcome.mjs +165 -0
- package/packages/client/lifecycle-cli.mjs +61 -0
- package/packages/client/lifecycle-contract.mjs +372 -0
- package/packages/client/liveness-main.mjs +10 -0
- package/packages/client/liveness.mjs +35 -0
- package/packages/client/machine-contract.mjs +123 -0
- package/packages/client/own-environment.mjs +22 -0
- package/packages/client/panel-views.mjs +286 -0
- package/packages/client/readiness-contract.mjs +172 -0
- package/packages/client/refresh-loop.mjs +52 -0
- package/packages/client/remote-address.mjs +126 -0
- package/packages/client/remote-roster.mjs +67 -0
- package/packages/client/roster-sections.mjs +80 -0
- package/packages/client/spawn-apply-cli.mjs +104 -0
- package/packages/client/spawn-apply-contract.mjs +183 -0
- package/packages/client/spawn-decision.mjs +46 -0
- package/packages/client/spawn-messages.mjs +119 -0
- package/packages/client/spawn-preview-cli.mjs +32 -0
- package/packages/client/spawn-preview-contract.mjs +314 -0
- package/packages/client/team-members.mjs +41 -0
- package/packages/client/team-rows.mjs +45 -0
- package/packages/client/terminal-contract.mjs +57 -0
- package/packages/client/tmux-status.mjs +66 -0
- package/packages/client/waiting-on-you.mjs +88 -0
- package/packages/client/workspace-admission.mjs +45 -0
- package/packages/client/workspace-cli.mjs +142 -0
- package/packages/client/workspace-views.mjs +147 -0
- package/packages/tui/README.md +46 -0
- package/packages/tui/bin/tui.mjs +7 -0
- package/packages/tui/lib/actions.mjs +29 -0
- package/packages/tui/lib/client.mjs +4 -0
- package/packages/tui/lib/main.mjs +105 -0
- package/packages/tui/lib/term/keys.mjs +323 -0
- package/packages/tui/lib/term/screen.mjs +122 -0
- package/packages/tui/lib/term/style.mjs +43 -0
- package/packages/tui/lib/term/text.mjs +49 -0
- package/packages/tui/lib/term/tty.mjs +168 -0
- package/packages/tui/lib/term/width.mjs +124 -0
- package/packages/tui/lib/views/frame.mjs +62 -0
- package/packages/tui/lib/views/help.mjs +28 -0
- package/packages/tui/package.json +8 -0
- package/skills/oats-getting-started/SKILL.md +29 -22
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-05-channel-seeded.txt +0 -35
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-06-first-after-channel.txt +0 -35
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-07-after-channel-200ms.txt +0 -35
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-08-installed-after-channel-200ms.txt +0 -35
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/manifest.json +0 -77
- package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/max-bypass-source.json +0 -88
- package/lib/launch-prompt-fixtures/structural-completion.json +0 -205
- package/lib/launch-prompt-policy.mjs +0 -87
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
/** Launch-only tmux observations. Exact visible bytes, never scrollback or
|
|
2
|
-
* joined wrapped lines; both identity/geometry reads must agree.
|
|
2
|
+
* joined wrapped lines; both identity/geometry reads must agree. The transport
|
|
3
|
+
* never resizes: matching is width-independent. */
|
|
3
4
|
import { execFileSync } from 'node:child_process';
|
|
4
5
|
import { isAbsolute } from 'node:path';
|
|
5
|
-
import { performance } from 'node:perf_hooks';
|
|
6
|
-
|
|
7
|
-
function budget(timeout) {
|
|
8
|
-
if (!Number.isFinite(timeout) || timeout <= 0) throw new Error('invalid launch timeout');
|
|
9
|
-
const deadline = performance.now() + timeout;
|
|
10
|
-
return () => {
|
|
11
|
-
const left = deadline - performance.now();
|
|
12
|
-
if (left <= 0) throw new Error('launch geometry timeout');
|
|
13
|
-
return left;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
6
|
|
|
17
7
|
export const LAUNCH_PANE_FORMAT = '#{window_id}\t#{pane_id}\t#{pane_pid}';
|
|
18
8
|
const SNAPSHOT_FORMAT = `${LAUNCH_PANE_FORMAT}\t#{pane_width}\t#{pane_height}\t#{window_panes}`;
|
|
@@ -28,7 +18,6 @@ export function launchPromptTransport(io) {
|
|
|
28
18
|
encoding: 'utf8', timeout: Math.max(1, Math.floor(timeout)), killSignal: 'SIGKILL', maxBuffer: 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'],
|
|
29
19
|
}));
|
|
30
20
|
};
|
|
31
|
-
const pins = new WeakMap();
|
|
32
21
|
const transport = {
|
|
33
22
|
// Called only before this invocation respawns an already-owned exact pane.
|
|
34
23
|
identity(socket, paneId) {
|
|
@@ -49,49 +38,6 @@ export function launchPromptTransport(io) {
|
|
|
49
38
|
if (lines.length !== Number(fields[4])) throw new Error('incomplete visible capture');
|
|
50
39
|
return { ...actual, width: Number(fields[3]), height: Number(fields[4]), text: lines.join('\n') + '\n' };
|
|
51
40
|
},
|
|
52
|
-
// Pin only an exclusively owned window. Tokens are invocation-local and
|
|
53
|
-
// cannot be reconstructed from an event receipt or another transport.
|
|
54
|
-
pin(target, geometry, timeout) {
|
|
55
|
-
if (!Number.isSafeInteger(geometry?.width) || geometry.width < 1 || !Number.isSafeInteger(geometry?.height) || geometry.height < 1) throw new Error('invalid launch geometry');
|
|
56
|
-
const remaining = budget(timeout);
|
|
57
|
-
const before = transport.snapshot(target, remaining());
|
|
58
|
-
const windowSize = run(target, ['show-options', '-w', '-q', '-v', '-t', target.windowId, 'window-size'], remaining()).trim();
|
|
59
|
-
if (!['', 'largest', 'smallest', 'manual', 'latest'].includes(windowSize)) throw new Error('invalid window-size policy');
|
|
60
|
-
// An empty option is inherited; restoration must unset our local override.
|
|
61
|
-
const token = Object.freeze({ previous: Object.freeze({ width: before.width, height: before.height, windowSize }) });
|
|
62
|
-
pins.set(token, { target: { ...target }, previous: token.previous });
|
|
63
|
-
try {
|
|
64
|
-
transport.snapshot(target, remaining());
|
|
65
|
-
run(target, ['set-option', '-w', '-t', target.windowId, 'window-size', 'manual', ';',
|
|
66
|
-
'resize-window', '-t', target.windowId, '-x', String(geometry.width), '-y', String(geometry.height)], remaining());
|
|
67
|
-
const after = transport.snapshot(target, remaining());
|
|
68
|
-
if (after.width !== geometry.width || after.height !== geometry.height) throw new Error('launch geometry pin failed');
|
|
69
|
-
return token;
|
|
70
|
-
} catch (error) {
|
|
71
|
-
// A failed command may already have changed the option/dimensions.
|
|
72
|
-
try { transport.restore(target, token, 3000); error.geometryRestored = true; }
|
|
73
|
-
catch { error.geometryRestoreFailed = true; }
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
restore(target, token, timeout) {
|
|
78
|
-
const remaining = budget(timeout);
|
|
79
|
-
const saved = pins.get(token);
|
|
80
|
-
if (!saved || ['socket', 'windowId', 'paneId', 'pid'].some(key => String(saved.target[key]) !== String(target[key]))) throw new Error('invalid launch geometry token');
|
|
81
|
-
// Consume even on failure: no retries can resize a replacement process.
|
|
82
|
-
pins.delete(token);
|
|
83
|
-
transport.snapshot(target, remaining());
|
|
84
|
-
const { width, height, windowSize } = saved.previous;
|
|
85
|
-
const reset = windowSize === ''
|
|
86
|
-
? ['set-option', '-w', '-u', '-t', target.windowId, 'window-size']
|
|
87
|
-
: ['set-option', '-w', '-t', target.windowId, 'window-size', windowSize];
|
|
88
|
-
run(target, ['set-option', '-w', '-t', target.windowId, 'window-size', 'manual', ';',
|
|
89
|
-
'resize-window', '-t', target.windowId, '-x', String(width), '-y', String(height), ';', ...reset], remaining());
|
|
90
|
-
const after = transport.snapshot(target, remaining());
|
|
91
|
-
const restoredPolicy = run(target, ['show-options', '-w', '-q', '-v', '-t', target.windowId, 'window-size'], remaining()).trim();
|
|
92
|
-
if (after.width !== width || after.height !== height || restoredPolicy !== windowSize) throw new Error('launch geometry restoration failed');
|
|
93
|
-
return { status: 'restored' };
|
|
94
|
-
},
|
|
95
41
|
send(target, key, timeout) {
|
|
96
42
|
if (key !== 'Enter') throw new Error('invalid launch action');
|
|
97
43
|
run(target, ['send-keys', '-t', target.paneId, key], timeout);
|
package/lib/launch-prompts.mjs
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
1
1
|
import { lstatSync, realpathSync } from "node:fs";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { performance } from "node:perf_hooks";
|
|
4
|
+
import { DEV_CHANNEL_ENTRIES, FLAG_IGNORED_ENTRIES, matchDevChannelEntry, matchFlagIgnoredEntry, devChannelDifference, normalizeScreen, showsClaudeSession } from "./launch-prompt-fixtures.mjs";
|
|
5
|
+
import { hasClaudeQuestionMarker } from "./launch-prompt-completion.mjs";
|
|
4
6
|
|
|
5
7
|
const LIMIT = 30000;
|
|
6
8
|
const INTERVAL = 100;
|
|
9
|
+
// The settle window. Before the Enter, an unknown screen is a verdict only once it has held this
|
|
10
|
+
// long unchanged: Claude paints transient frames while it starts (a logo mid-animation, a renderer
|
|
11
|
+
// notice) and, under load, holds one for a second or more. After the Enter, a start completes only
|
|
12
|
+
// once its captures have been clean (non-blank, no question marker, no entry) this long in a row,
|
|
13
|
+
// the screen free to change: a working session repaints all the time. No key is sent while waiting.
|
|
14
|
+
const SETTLE = 2000;
|
|
15
|
+
// The confirmation may stay painted briefly after its Enter; seen again after
|
|
16
|
+
// this long, it came back.
|
|
17
|
+
const RETURN = 2000;
|
|
18
|
+
const OBSERVATION_TIMEOUT = "blocked: observation timeout";
|
|
19
|
+
/** Whether a recorded reason says the screen never settled within the bound, so no prompt
|
|
20
|
+
* was established (a failed evidence write appends to the reason, never changes its start). */
|
|
21
|
+
export const neverSettled = (reason) => typeof reason === "string" && reason.startsWith(OBSERVATION_TIMEOUT);
|
|
7
22
|
const digest = (text) => createHash("sha256").update(text).digest("hex");
|
|
8
23
|
const sameTarget = (a, b, pid = true) => a && b && ["socket", "windowId", "paneId", ...(pid ? ["pid"] : [])].every(k => String(a[k]) === String(b[k]));
|
|
9
24
|
const validTarget = t => t && typeof t.socket === "string" && t.socket.length > 0 && /^@\d+$/.test(t.windowId) && /^%\d+$/.test(t.paneId) && /^[1-9]\d*$/.test(String(t.pid));
|
|
10
25
|
const wait = ms => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
11
26
|
|
|
12
|
-
/** Private, single-invocation authority
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
27
|
+
/** Private, single-invocation authority over the development-channel
|
|
28
|
+
* confirmation in the one pane this start created. The caller constructs it only
|
|
29
|
+
* when the launch argv engages it (launchPromptEngages). It sends at most one
|
|
30
|
+
* fixed Enter, and only while the normalized screen EQUALS a tolerance entry.
|
|
31
|
+
* A screen whose notice block EQUALS a flag-ignored entry means Claude ignored
|
|
32
|
+
* the flag and shows no confirmation: that start ends flag-ignored, with no key.
|
|
33
|
+
* Transport captures visible bytes only and independently verifies ownership
|
|
34
|
+
* around capture. Every call receives the remaining deadline.
|
|
18
35
|
* audit receives launch-prompt event data and returns appendEvent's checked result.
|
|
19
36
|
*/
|
|
20
|
-
export function createLaunchPromptController({ home, startId,
|
|
21
|
-
now = () => performance.now(), sleep = wait,
|
|
22
|
-
const selectedHarness = typeof harness === "string" ? { name: harness } : { ...harness };
|
|
23
|
-
const consent = { ...policy };
|
|
24
|
-
// Copy fixture data so a caller cannot change signatures during an answer.
|
|
25
|
-
const accepted = structuredClone(fixtures);
|
|
37
|
+
export function createLaunchPromptController({ home, startId, transport, audit, retainFrame, entries = DEV_CHANNEL_ENTRIES, flagIgnoredEntries = FLAG_IGNORED_ENTRIES,
|
|
38
|
+
claudeVersion = "unknown", claudeVersionSource = "unknown", now = () => performance.now(), sleep = wait, expectedHomeIdentity }) {
|
|
26
39
|
let identity;
|
|
27
40
|
try {
|
|
28
41
|
const st = lstatSync(home);
|
|
@@ -39,21 +52,17 @@ export function createLaunchPromptController({ home, startId, harness, policy =
|
|
|
39
52
|
const st = lstatSync(home);
|
|
40
53
|
if (!st.isDirectory() || st.dev !== identity.dev || st.ino !== identity.ino || realpathSync(home) !== home) throw new Error("home identity changed");
|
|
41
54
|
}
|
|
42
|
-
function checkAuthority() {
|
|
43
|
-
checkHome();
|
|
44
|
-
if (validateExecutable && validateExecutable() !== true) throw new Error("launch executable changed");
|
|
45
|
-
}
|
|
46
55
|
function remaining() {
|
|
47
56
|
const left = deadline - now();
|
|
48
57
|
if (!(left > 0)) throw new Error("observation timeout");
|
|
49
58
|
return Math.max(1, Math.ceil(left));
|
|
50
59
|
}
|
|
51
60
|
function capture(t) {
|
|
52
|
-
|
|
61
|
+
checkHome();
|
|
53
62
|
if (!validTarget(t)) throw new Error("invalid target");
|
|
54
63
|
const screen = transport.snapshot(t, remaining());
|
|
55
64
|
remaining();
|
|
56
|
-
|
|
65
|
+
checkHome();
|
|
57
66
|
if (!sameTarget(t, screen) || !Number.isInteger(screen.width) || screen.width < 1 || !Number.isInteger(screen.height) || screen.height < 1 || typeof screen.text !== "string") throw new Error("target or geometry changed");
|
|
58
67
|
lastText = screen.text;
|
|
59
68
|
return { ...screen };
|
|
@@ -63,7 +72,7 @@ export function createLaunchPromptController({ home, startId, harness, policy =
|
|
|
63
72
|
try {
|
|
64
73
|
checkHome();
|
|
65
74
|
result = audit({ home, startId, socket: target?.socket, windowId: target?.windowId,
|
|
66
|
-
paneId: target?.paneId, pid: target?.pid,
|
|
75
|
+
paneId: target?.paneId, pid: target?.pid, claudeVersion, claudeVersionSource, ...data });
|
|
67
76
|
} catch { auditFailed = true; return false; }
|
|
68
77
|
// Preserve actual appendEvent paths, including partial-log availability.
|
|
69
78
|
if (result && Array.isArray(result.results)) receipts.push({ ok: result.ok === true, ...(result.row ? { row: structuredClone(result.row) } : {}), results: result.results.map(r => ({ ...r })) });
|
|
@@ -81,20 +90,14 @@ export function createLaunchPromptController({ home, startId, harness, policy =
|
|
|
81
90
|
status = "incomplete";
|
|
82
91
|
reason = "launch prompt audit failed";
|
|
83
92
|
}
|
|
84
|
-
|
|
93
|
+
// A blocked result carries what differed, and whether Claude's session UI was
|
|
94
|
+
// shown, for the readiness warning (R2).
|
|
95
|
+
terminal = { status, answers: answers.map(a => ({ ...a })), reason, receipt: receipts,
|
|
96
|
+
...(status === "flag-ignored" ? { signatureId: extra.signatureId } : {}),
|
|
97
|
+
...(status === "blocked" && extra.differed ? { differed: extra.differed } : {}),
|
|
98
|
+
...(status === "blocked" && extra.claudeSessionShown ? { claudeSessionShown: true } : {}) };
|
|
85
99
|
return terminal;
|
|
86
100
|
}
|
|
87
|
-
function matching(screen) {
|
|
88
|
-
const candidates = [];
|
|
89
|
-
for (const fixture of accepted) {
|
|
90
|
-
if (!fixture.id || fixture.home !== home || fixture.harness !== selectedHarness.name || !fixture.version || fixture.version !== selectedHarness.version || !fixture.platform || fixture.platform !== selectedHarness.platform) continue;
|
|
91
|
-
for (const frame of fixture.frames ?? []) {
|
|
92
|
-
if (frame.text === screen.text && frame.width === screen.width && frame.height === screen.height
|
|
93
|
-
&& JSON.stringify(frame.after) === JSON.stringify(answers.map(a => a.class))) candidates.push({ fixture, frame });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return candidates.length === 1 ? candidates[0] : null;
|
|
97
|
-
}
|
|
98
101
|
const exact = (a, b) => sameTarget(a, b) && a.width === b.width && a.height === b.height && a.text === b.text;
|
|
99
102
|
function retain(screen, outcome, recognition) {
|
|
100
103
|
try {
|
|
@@ -102,82 +105,87 @@ export function createLaunchPromptController({ home, startId, harness, policy =
|
|
|
102
105
|
screen: { text: screen.text, width: screen.width, height: screen.height }, outcome, recognition })?.ok === true;
|
|
103
106
|
} catch { return false; } // No raw text, OS diagnostic or private receipt escapes.
|
|
104
107
|
}
|
|
108
|
+
// A loud miss: the receipt row says what differed; private evidence holds the
|
|
109
|
+
// exact compared screen, never the row.
|
|
110
|
+
// Before any Enter, Claude's running-session banner on the blocked screen says
|
|
111
|
+
// the session may already be up with the flag ignored and its notice hidden.
|
|
112
|
+
function blocked(screen, reason, beforeEnter = false) {
|
|
113
|
+
const sessionShown = beforeEnter && showsClaudeSession(screen.text);
|
|
114
|
+
if (!retain(screen, "blocked", "unmatched")) reason += "; private launch evidence retention failed";
|
|
115
|
+
return finish("blocked", reason, { differed: devChannelDifference(screen.text, entries), ...(sessionShown ? { claudeSessionShown: true } : {}) });
|
|
116
|
+
}
|
|
105
117
|
function observe(t, before) {
|
|
106
118
|
if (used) return terminal ?? { status: "blocked", answers: [], reason: "blocked: launch authority already used", receipt: [] };
|
|
107
119
|
used = true;
|
|
108
120
|
target = { ...t };
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
function incompleteCleanup() {
|
|
116
|
-
if (!terminal) terminal = { answers: answers.map(a => ({ ...a })), receipt: receipts };
|
|
117
|
-
terminal.status = "incomplete";
|
|
118
|
-
terminal.reason = "launch prompt geometry restoration incomplete";
|
|
119
|
-
}
|
|
121
|
+
// `unknown` is the last non-blank screen before the Enter that equalled no entry: a screen
|
|
122
|
+
// that never settles is an observation timeout at the bound, and says what differed.
|
|
123
|
+
// After the Enter: `clean` is when the current run of clean captures began, `left` whether the
|
|
124
|
+
// confirmation has been off screen since, and `last` the last non-blank screen.
|
|
125
|
+
let fresh = before === undefined, enteredAt, pending, unknown, clean, left = false, last;
|
|
126
|
+
const submitted = () => answers.length === 1 && answers[0].status === "submitted";
|
|
120
127
|
try {
|
|
121
128
|
checkHome();
|
|
122
129
|
if (!validTarget(target)) return finish("blocked", "blocked: invalid target");
|
|
123
130
|
if (before !== undefined && (!before || !sameTarget(target, before, false) || String(target.pid) === String(before.pid))) return finish("blocked", "blocked: respawn ownership not proven");
|
|
124
131
|
// Hard iteration bound also protects against a broken injected clock.
|
|
125
132
|
for (let observations = 0; observations <= LIMIT / INTERVAL; observations++) {
|
|
126
|
-
|
|
133
|
+
const screen = capture(target);
|
|
127
134
|
if (!fresh) {
|
|
128
|
-
// A resize can reflow the *old* prompt into different bytes
|
|
129
|
-
// a fresh process screen at the original geometry
|
|
135
|
+
// A resize can reflow the *old* prompt into different bytes that still
|
|
136
|
+
// normalize to an entry. Require a fresh process screen at the original geometry.
|
|
130
137
|
if (screen.width !== before.width || screen.height !== before.height) return finish("blocked", "blocked: respawn geometry changed before fresh screen");
|
|
131
138
|
if (screen.text !== before.text) fresh = true;
|
|
132
139
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
resizeToken = transport.pin(target, { ...geometry }, remaining());
|
|
139
|
-
if (!resizeToken) return finish("incomplete", "launch prompt geometry pin failed");
|
|
140
|
-
if (!record({ ...fields, status: "submitted" })) return finish("incomplete", "launch prompt audit failed after geometry pin");
|
|
140
|
+
const reading = normalizeScreen(screen.text);
|
|
141
|
+
if (!fresh || reading === "") {
|
|
142
|
+
// A blank screen restarts any window; after the Enter it also means the confirmation left.
|
|
143
|
+
pending = undefined;
|
|
144
|
+
if (submitted()) { clean = undefined; left = true; }
|
|
141
145
|
sleep(Math.min(INTERVAL, remaining()));
|
|
142
|
-
|
|
143
|
-
if (screen.width !== geometry.width || screen.height !== geometry.height) return finish("blocked", "blocked: launch geometry not pinned");
|
|
146
|
+
continue;
|
|
144
147
|
}
|
|
145
|
-
|
|
148
|
+
const entry = matchDevChannelEntry(screen.text, entries);
|
|
149
|
+
if (submitted()) {
|
|
150
|
+
// Completion reporting only, never input authority: no key follows.
|
|
151
|
+
last = screen;
|
|
152
|
+
if (entry) {
|
|
153
|
+
// Still painted just after the Enter is waited out; back after leaving, or still there
|
|
154
|
+
// after RETURN, it came back.
|
|
155
|
+
if (left || now() - enteredAt >= RETURN) return blocked(screen, "blocked: repeated or unsupported prompt");
|
|
156
|
+
clean = undefined;
|
|
157
|
+
} else if (hasClaudeQuestionMarker(screen.text)) {
|
|
158
|
+
return blocked(screen, "blocked: unexpected prompt");
|
|
159
|
+
} else {
|
|
160
|
+
left = true;
|
|
161
|
+
clean ??= now();
|
|
162
|
+
if (now() - clean >= SETTLE) {
|
|
163
|
+
if (!retain(screen, "completed", "stable-screen")) return finish("incomplete", "private launch evidence retention failed");
|
|
164
|
+
return finish("completed", "recognized launch boundary", { signatureId: answers[0].signatureId });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
146
167
|
sleep(Math.min(INTERVAL, remaining()));
|
|
147
168
|
continue;
|
|
148
169
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return finish("completed", "recognized launch boundary");
|
|
157
|
-
}
|
|
158
|
-
if (!match) {
|
|
159
|
-
let reason = "blocked: unexpected prompt";
|
|
160
|
-
if (submitted && screen.width === 110 && screen.height === 35 && retainFrame) {
|
|
161
|
-
// This is the exact object just compared, not a later pane capture.
|
|
162
|
-
// Private evidence cannot authorize input or change the launch outcome.
|
|
163
|
-
if (!retain(screen, "blocked", "unmatched")) reason += "; private launch evidence retention failed";
|
|
170
|
+
if (!entry) {
|
|
171
|
+
// A question beside the notice means someone must answer: that screen is a miss.
|
|
172
|
+
const ignored = !hasClaudeQuestionMarker(screen.text) && matchFlagIgnoredEntry(screen.text, flagIgnoredEntries);
|
|
173
|
+
if (ignored) {
|
|
174
|
+
// Claude ignored the flag and asks nothing: no key, ever.
|
|
175
|
+
if (!retain(screen, "flag-ignored", "notice-block")) return finish("incomplete", "private launch evidence retention failed");
|
|
176
|
+
return finish("flag-ignored", "channels-unavailable", { signatureId: ignored.id });
|
|
164
177
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (frame.kind === "startup") {
|
|
178
|
+
// A screen still being painted keeps changing; an unknown one that
|
|
179
|
+
// holds still for the settle window is a miss, and blocks without any key.
|
|
180
|
+
unknown = screen;
|
|
181
|
+
if (pending?.reading === reading && now() - pending.at >= SETTLE) return blocked(screen, "blocked: unexpected prompt", true);
|
|
182
|
+
if (pending?.reading !== reading) pending = { reading, at: now() };
|
|
171
183
|
sleep(Math.min(INTERVAL, remaining()));
|
|
172
184
|
continue;
|
|
173
185
|
}
|
|
174
|
-
const klass = frame.class;
|
|
175
|
-
if (frame.kind !== "prompt" || klass !== "awebDevelopmentChannel" || prior.length !== 0) return finish("blocked", "blocked: repeated or unsupported prompt");
|
|
176
|
-
if (consent.awebDevelopmentChannel !== true || selectedHarness.name !== "claude" || selectedHarness.developmentChannelEligible !== true) return finish("blocked", "blocked: prompt consent absent");
|
|
177
186
|
const expected = screen;
|
|
178
187
|
if (!exact(capture(target), expected)) return finish("blocked", "blocked: prompt changed before input");
|
|
179
|
-
const fields = { signatureId:
|
|
180
|
-
signatureDigest: digest(expected.text), class: klass, key: "Enter" };
|
|
188
|
+
const fields = { signatureId: entry.id, signatureDigest: digest(expected.text), class: "awebDevelopmentChannel", key: "Enter" };
|
|
181
189
|
if (!record({ ...fields, status: "attempted" })) {
|
|
182
190
|
terminal = { status: "incomplete", answers: answers.map(a => ({ ...a })), reason: "launch prompt audit failed", receipt: receipts };
|
|
183
191
|
return terminal;
|
|
@@ -187,7 +195,7 @@ export function createLaunchPromptController({ home, startId, harness, policy =
|
|
|
187
195
|
if (!exact(capture(target), expected)) return finish("blocked", "blocked: prompt changed before input", fields);
|
|
188
196
|
let outcome = "uncertain";
|
|
189
197
|
try {
|
|
190
|
-
|
|
198
|
+
checkHome();
|
|
191
199
|
const sent = transport.send(target, "Enter", remaining());
|
|
192
200
|
outcome = sent?.status === "submitted" ? "submitted" : sent?.status === "failed" ? "failed" : "uncertain";
|
|
193
201
|
} catch { /* A thrown send might already have delivered the key. */ }
|
|
@@ -196,26 +204,20 @@ export function createLaunchPromptController({ home, startId, harness, policy =
|
|
|
196
204
|
return terminal;
|
|
197
205
|
}
|
|
198
206
|
if (outcome !== "submitted") return finish("incomplete", `launch prompt input ${outcome}`, fields);
|
|
199
|
-
answers.push({ class:
|
|
207
|
+
answers.push({ class: "awebDevelopmentChannel", signatureId: entry.id, status: "submitted" });
|
|
208
|
+
enteredAt = now();
|
|
209
|
+
pending = undefined;
|
|
200
210
|
sleep(Math.min(INTERVAL, remaining()));
|
|
201
211
|
}
|
|
202
|
-
|
|
212
|
+
throw new Error("observation timeout");
|
|
203
213
|
} catch (error) {
|
|
204
|
-
if (error?.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
// independently refuses a replaced process/window before touching it.
|
|
212
|
-
const fields = { action: "restore-geometry", previous: resizeToken.previous, signatureDigest: digest(lastText) };
|
|
213
|
-
let audited = record({ ...fields, status: "attempted" });
|
|
214
|
-
let restored = false;
|
|
215
|
-
try { restored = transport.restore(target, resizeToken, 3000)?.status === "restored"; } catch { /* retained incomplete below */ }
|
|
216
|
-
audited = record({ ...fields, status: restored ? "submitted" : "failed" }) && audited;
|
|
217
|
-
if (!restored || !audited) incompleteCleanup();
|
|
218
|
-
}
|
|
214
|
+
if (error?.message !== "observation timeout") return finish("blocked", "blocked: launch observation failed");
|
|
215
|
+
// After the Enter, no complete clean window by the bound: an observation timeout, with the one
|
|
216
|
+
// Enter recorded in the answers.
|
|
217
|
+
if (submitted()) return last ? blocked(last, OBSERVATION_TIMEOUT) : finish("blocked", OBSERVATION_TIMEOUT);
|
|
218
|
+
// A screen still changing at the bound never settled into a prompt: an observation timeout,
|
|
219
|
+
// with what differed and the last screen kept as evidence.
|
|
220
|
+
return unknown ? blocked(unknown, OBSERVATION_TIMEOUT, true) : finish("blocked", OBSERVATION_TIMEOUT);
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
return {
|