@oathe/oathe 0.4.4 → 0.4.6
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/.claude-plugin/marketplace.json +18 -2
- package/README.md +6 -3
- package/bin/oathe.mjs +199 -35
- package/docs/PRIVACY.md +26 -4
- package/notch/Oathe Notch.app/Contents/Info.plist +1 -1
- package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
- package/notch/README.md +4 -3
- package/package.json +5 -4
- package/plugin/.claude-plugin/plugin.json +21 -3
- package/plugin/.cursor-plugin/plugin.json +2 -2
- package/plugin/hooks/hooks.json +4 -4
- package/plugin/hooks/lib.mjs +9 -0
- package/plugin/hooks/render-board.mjs +4 -2
- package/src/blocks.mjs +10 -1
- package/src/board-render.mjs +7 -4
- package/src/breach-digest.mjs +75 -10
- package/src/config.mjs +18 -0
- package/src/context.mjs +1 -1
- package/src/device.mjs +106 -0
- package/src/doctor.mjs +101 -6
- package/src/engine-update.mjs +170 -0
- package/src/evidence-discovery.mjs +170 -0
- package/src/fence.mjs +3 -3
- package/src/harnesses/catalog.mjs +46 -4
- package/src/harnesses/claude.mjs +56 -4
- package/src/harnesses/codex-rollout.mjs +110 -21
- package/src/harnesses/codex.mjs +106 -19
- package/src/harnesses/cursor.mjs +31 -18
- package/src/harnesses/harness.mjs +82 -13
- package/src/harnesses/surfaces.mjs +2 -2
- package/src/home.mjs +174 -52
- package/src/init.mjs +27 -2
- package/src/launch.mjs +7 -9
- package/src/launchd.mjs +100 -0
- package/src/manifest.mjs +48 -6
- package/src/mcp/connection.mjs +73 -7
- package/src/mcp/daemon.mjs +123 -0
- package/src/mcp/forwarder.mjs +99 -0
- package/src/mcp/oathe-tools.mjs +392 -145
- package/src/notch-frame.mjs +118 -42
- package/src/notch.mjs +34 -68
- package/src/oathe-annotator.mjs +10 -10
- package/src/pager.mjs +144 -40
- package/src/paths.mjs +1 -0
- package/src/plans.mjs +44 -5
- package/src/registry.mjs +10 -2
- package/src/serve.mjs +82 -0
- package/src/session-host.mjs +1 -1
- package/src/sessions.mjs +39 -8
- package/src/shim.mjs +110 -0
- package/src/speaker.mjs +24 -5
- package/src/statements.mjs +116 -2
- package/src/traces.mjs +61 -19
- package/src/uninstall.mjs +20 -3
- package/src/update.mjs +35 -7
- package/src/verifier.mjs +215 -105
- package/src/verify-dispatch.mjs +86 -32
- package/src/wire.mjs +7 -1
- package/plugin/.mcp.json +0 -10
package/src/notch-frame.mjs
CHANGED
|
@@ -10,14 +10,19 @@
|
|
|
10
10
|
// whose last word is younger than notchMotionMinutes, or one the wire just heard (hear(),
|
|
11
11
|
// ephemeral by design). Idle-held work is `oathe ls`'s business.
|
|
12
12
|
|
|
13
|
-
import { launchable, ownerOfTracePath, surfaceForSession } from './harnesses/catalog.mjs';
|
|
13
|
+
import { appResumable, displayFor, launchable, ownerOfTracePath, surfaceForSession, updatable } from './harnesses/catalog.mjs';
|
|
14
|
+
import { HomeError, Place } from './home.mjs';
|
|
14
15
|
import { pidAlive } from './sessions.mjs';
|
|
15
|
-
import { KINDS, CONTINUE_ACT } from './breach-digest.mjs';
|
|
16
|
+
import { KINDS, CONTINUE_ACT, JUDGMENT, UPDATE_ACT, OPEN_APP_FLASH } from './breach-digest.mjs';
|
|
17
|
+
import { shimPath } from './shim.mjs';
|
|
18
|
+
import { systemTaskOf } from './plans.mjs';
|
|
16
19
|
|
|
17
20
|
/** The system terminal — an OS fact, the fallback when no session names its own. */
|
|
18
21
|
export const TERMINAL_FALLBACK = '/System/Applications/Utilities/Terminal.app';
|
|
19
22
|
|
|
20
23
|
const shellQuote = (s) => `'${String(s).replaceAll("'", "'\\''")}'`;
|
|
24
|
+
/** The one line that resumes a task — typed into a terminal by the spawn, or pasted into an app. */
|
|
25
|
+
const continueLine = (taskId) => `continue ${taskId}`;
|
|
21
26
|
/** A kind whose one act is a judgment (never-judged, engine-failed) rather than a resumption. */
|
|
22
27
|
const judges = (kind) => KINDS[kind].act !== CONTINUE_ACT;
|
|
23
28
|
|
|
@@ -30,7 +35,7 @@ export class NotchFrame {
|
|
|
30
35
|
* motionWindowMs: number, operatorHome: string, now?: () => number}} o
|
|
31
36
|
* sessions — the device session registry, read per frame (its failure is the caller's
|
|
32
37
|
* fail-soft: an empty map costs the frame its session refs, never the frame);
|
|
33
|
-
* operatorHome — where a
|
|
38
|
+
* operatorHome — where a judgment of work residing in an app runs.
|
|
34
39
|
*/
|
|
35
40
|
constructor({ registry, sessions, defaultAgent, motionWindowMs, operatorHome, now = () => Date.now() }) {
|
|
36
41
|
this.registry = registry;
|
|
@@ -38,6 +43,9 @@ export class NotchFrame {
|
|
|
38
43
|
this.defaultAgent = this.#launchables.includes(defaultAgent) ? defaultAgent : null;
|
|
39
44
|
this.motionWindowMs = motionWindowMs;
|
|
40
45
|
this.operatorHome = operatorHome;
|
|
46
|
+
// The acts run in a FRESH terminal the glass opens — same spawn class as a GUI harness,
|
|
47
|
+
// so the same durable address (connection-lane plan, 2026-09-04): never a bare `oathe`.
|
|
48
|
+
this.oatheBin = shimPath(operatorHome);
|
|
41
49
|
this.now = now;
|
|
42
50
|
}
|
|
43
51
|
|
|
@@ -53,9 +61,12 @@ export class NotchFrame {
|
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
/**
|
|
56
|
-
* Continue
|
|
57
|
-
* app; else spawn the agent at the task
|
|
58
|
-
*
|
|
64
|
+
* Continue goes WHERE THE WORK LIVES (founder rulings 2026-08-30, 2026-09-05): activate the
|
|
65
|
+
* living app; else spawn the agent at the folder the task resides in; else open the app it
|
|
66
|
+
* resides in (the recorded place — durable, so a feed restart forgets nothing); else there
|
|
67
|
+
* is nothing to resume into and the row offers NO act — never a clipboard dressed as one.
|
|
68
|
+
* The package decides — the glass executes.
|
|
69
|
+
* @returns {object|null}
|
|
59
70
|
*/
|
|
60
71
|
resumeFor(base, ref) {
|
|
61
72
|
const word = CONTINUE_ACT;
|
|
@@ -69,66 +80,121 @@ export class NotchFrame {
|
|
|
69
80
|
if (agent && typeof base.home_path === 'string' && base.home_path.startsWith('/')) {
|
|
70
81
|
return {
|
|
71
82
|
kind: 'spawn-terminal',
|
|
72
|
-
command: `
|
|
83
|
+
command: `"${this.oatheBin}" ${agent} ${shellQuote(continueLine(base.task_id))}`,
|
|
73
84
|
cwd: base.home_path,
|
|
74
|
-
terminal_bundle: ref?.bundle ?? TERMINAL_FALLBACK,
|
|
85
|
+
terminal_bundle: ref?.bundle ?? base.place_app ?? TERMINAL_FALLBACK, // the terminal it was spoken from, when known
|
|
75
86
|
word,
|
|
76
87
|
};
|
|
77
88
|
}
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
// An APP residence opens — only when its adapter says that app is a place to resume into
|
|
90
|
+
// (appResumable); a recorded terminal bundle is not one.
|
|
91
|
+
const residence = Place.parseOrNull(base.place ?? null);
|
|
92
|
+
const appSurface = residence !== null && !residence.isFolder ? residence.ref : surface;
|
|
93
|
+
const bundle = ref?.bundle ?? base.place_app ?? null;
|
|
94
|
+
if (bundle && appResumable(appSurface)) {
|
|
95
|
+
// Opening the app IS the resumption; the line rides the clipboard and the row says so
|
|
96
|
+
// (ruling 2026-09-05) — the app cannot be opened to a thread, so the person pastes.
|
|
97
|
+
return { kind: 'open-app', bundle, word, paste: continueLine(base.task_id), flash: OPEN_APP_FLASH(displayFor(appSurface) ?? appSurface) };
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
80
100
|
}
|
|
81
101
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
/** The word a place wears on the glass: the folder path, or the app's display word. A row on
|
|
103
|
+
* the glass is a claim's, and every claim has a place — none is a broken record, said loudly. */
|
|
104
|
+
#homePath(place) {
|
|
105
|
+
const residence = Place.parseOrNull(place ?? null);
|
|
106
|
+
if (residence === null) {
|
|
107
|
+
throw new HomeError('OATHE_PLACE_UNKNOWN', 'a claim on the glass has no recorded place — the record is broken (every pickup records one)');
|
|
108
|
+
}
|
|
109
|
+
if (residence.isFolder) return this.registry.rootOf(residence.ref) ?? residence.ref;
|
|
110
|
+
return displayFor(residence.ref) ?? residence.ref;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Where a task can be resumed INTO: the durable registry row outranks the wire's ephemeral
|
|
115
|
+
* word; either way the ref carries surface + the focusable app, so a task heard from a
|
|
116
|
+
* living app (ChatGPT's embedded codex — no hooks, no registry row) still resolves to a
|
|
117
|
+
* switch. One resolver for a moving row and a breach row alike.
|
|
118
|
+
*/
|
|
119
|
+
#refFor(taskId, traceSessionId, sess) {
|
|
120
|
+
const row = (traceSessionId && sess[traceSessionId]) || null;
|
|
121
|
+
if (row !== null) {
|
|
122
|
+
return {
|
|
123
|
+
surface: surfaceForSession({ ancestry: row.ancestry, app: row.app, transcriptPath: row.transcript_path }),
|
|
124
|
+
app_pid: row.app?.pid ?? null,
|
|
125
|
+
bundle: row.app?.bundle ?? null,
|
|
126
|
+
alive: pidAlive(row.pid),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const heard = this.#heard.get(taskId);
|
|
130
|
+
if (!heard?.app) return null;
|
|
131
|
+
return {
|
|
94
132
|
surface: heard.via ?? null,
|
|
95
133
|
app_pid: heard.app.pid ?? null,
|
|
96
134
|
bundle: heard.app.bundle ?? null,
|
|
97
135
|
alive: heard.app.pid !== null && heard.app.pid !== undefined && pidAlive(heard.app.pid),
|
|
98
|
-
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
glassRow(r, sess) {
|
|
140
|
+
const heard = this.#heard.get(r.task_id);
|
|
141
|
+
const ref = this.#refFor(r.task_id, r.trace_session_id, sess);
|
|
142
|
+
const residence = Place.parseOrNull(r.place ?? null);
|
|
99
143
|
const base = {
|
|
100
144
|
task_id: r.task_id, objective: r.objective, holder: r.principal_id, state: r.state,
|
|
101
145
|
last_word_at: r.last_word_at, last_progress: r.last_progress,
|
|
102
146
|
children_line: r.children?.line ?? null,
|
|
103
|
-
home_path: this
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
|
|
147
|
+
home_path: this.#homePath(r.place),
|
|
148
|
+
place: r.place ?? null, place_app: r.place_app ?? null, place_dir: r.place_dir ?? null,
|
|
149
|
+
// The surface speaking on the claim: the wire's live word wins; then the latest trace
|
|
150
|
+
// link's transcript, mapped by its owning store; then the app it resides in (durable).
|
|
151
|
+
surface: heard?.via ?? (r.trace_path ? ownerOfTracePath(r.trace_path) : null)
|
|
152
|
+
?? (residence !== null && !residence.isFolder ? residence.ref : null),
|
|
107
153
|
};
|
|
108
154
|
return { ...base, session: ref, resume: this.resumeFor(base, ref) };
|
|
109
155
|
}
|
|
110
156
|
|
|
111
157
|
/**
|
|
112
158
|
* A breach row carries the ONE act that can change its truth (ruling 2026-08-31): never-
|
|
113
|
-
* judged and engine-failed → dispatch the judgment,
|
|
114
|
-
* orphan
|
|
115
|
-
* in breach order); judged-rejected and gone-quiet →
|
|
159
|
+
* judged and engine-failed → dispatch the judgment, HEADLESS and detached (the feed runs
|
|
160
|
+
* the dispatcher; no window to close, nothing to orphan) — for a sibling group, on its
|
|
161
|
+
* oldest idle child (children ride in breach order); judged-rejected and gone-quiet →
|
|
162
|
+
* CONTINUE into the work in a terminal (a session needs one; a judgment does not), at the parent
|
|
116
163
|
* for a group (the reclaim bundle carries the verdict — re-judging a judged assertion is
|
|
117
164
|
* the one act that can never help). The act's WORD is the kinds table's; the act's KIND is
|
|
118
|
-
* decided here, from the environment. Home is the ONE resolver's answer; a
|
|
119
|
-
*
|
|
165
|
+
* decided here, from the environment. Home is the ONE resolver's answer; a judgment of work
|
|
166
|
+
* residing in an app runs from the operator's home.
|
|
120
167
|
*/
|
|
121
|
-
glassBreach(b) {
|
|
168
|
+
glassBreach(b, sess = {}) {
|
|
169
|
+
// A judgment in flight offers NO act (ruling 2026-09-04): the glass never offers an act it
|
|
170
|
+
// would refuse (a re-dispatch is OATHE_VERIFY_IN_FLIGHT) — the row says verifying instead.
|
|
171
|
+
if (b.busy) return { ...b, act: null };
|
|
122
172
|
const home = typeof b.home === 'string' && b.home.startsWith('/') ? b.home : null;
|
|
123
173
|
const word = KINDS[b.kind].act;
|
|
124
174
|
if (judges(b.kind)) {
|
|
125
|
-
const target = b.group ? b.group.
|
|
126
|
-
return { ...b, act:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
175
|
+
const target = b.group ? b.group.retry : b.task_id;
|
|
176
|
+
if (target === null) return { ...b, act: null }; // every child of the group is being judged
|
|
177
|
+
// A judgment needs no terminal (ruling 2026-09-04): the act names the task and the feed
|
|
178
|
+
// dispatches it through the one dispatcher (src/verify-dispatch.mjs) — detached, so it
|
|
179
|
+
// still outlives everything; the judgment's own claim then wakes the frame. The command
|
|
180
|
+
// rides for the clipboard: the terminal form of the same act, for a person who wants it.
|
|
181
|
+
// The glass relays `act` and `harness` up the pipe and decides nothing (ruling 2026-09-05).
|
|
182
|
+
const dispatch = (extra) => ({ ...b, act: { kind: 'dispatch', task_id: target, cwd: home ?? this.operatorHome, ...extra } });
|
|
183
|
+
// A stall whose cause is an OUT-OF-DATE engine the adapter can update: retry cannot help,
|
|
184
|
+
// so the one act is the update — the child claims update:<engine> and re-verifies.
|
|
185
|
+
if (b.kind === 'stalled' && b.cause === 'outdated' && updatable(b.engine)) {
|
|
186
|
+
return dispatch({ act: 'update', harness: b.engine, word: UPDATE_ACT, command: `"${this.oatheBin}" engine update ${b.engine} --then-verify` });
|
|
187
|
+
}
|
|
188
|
+
return dispatch({ act: 'verify', word, command: `"${this.oatheBin}" verify --detach ${shellQuote(target)}` });
|
|
130
189
|
}
|
|
131
|
-
|
|
190
|
+
// A resumption climbs the one ladder a moving row's continue climbs (#refFor + resumeFor):
|
|
191
|
+
// the living app that spoke the task, else the agent at the folder it resides in, else the
|
|
192
|
+
// app it resides in — else no act (ruling 2026-09-05: nothing known offers nothing).
|
|
193
|
+
const base = {
|
|
194
|
+
task_id: b.task_id, home_path: home ?? this.#homePath(b.place), place: b.place ?? null, place_app: b.place_app ?? null, place_dir: b.place_dir ?? null,
|
|
195
|
+
surface: this.#heard.get(b.task_id)?.via ?? null,
|
|
196
|
+
};
|
|
197
|
+
return { ...b, act: this.resumeFor(base, this.#refFor(b.task_id, b.trace_session_id ?? null, sess)) };
|
|
132
198
|
}
|
|
133
199
|
|
|
134
200
|
/**
|
|
@@ -140,11 +206,21 @@ export class NotchFrame {
|
|
|
140
206
|
build({ digest, sections }) {
|
|
141
207
|
const sess = this.sessions();
|
|
142
208
|
const row = (r) => this.glassRow(r, sess);
|
|
209
|
+
// The judge's own `verify:<task>` claim is never a row: one row per task (R-GROUP-ROWS),
|
|
210
|
+
// and that task's row already says verifying while the judge holds it.
|
|
211
|
+
const work = (rows) => rows.filter((r) => systemTaskOf(r.task_id) === null); // a system task (verify:, update:) is never a work row
|
|
212
|
+
// An asserted claim is never invisible (ruling 2026-09-04): between done and verdict its
|
|
213
|
+
// row says which judgment it awaits — the JUDGMENT table's word, the spinner on `busy`
|
|
214
|
+
// (the key a breach already spins on), no act (nothing a person does moves a judgment;
|
|
215
|
+
// the fork lands in the asserter's session). A breached task is its breach row alone.
|
|
216
|
+
const breached = new Set(digest.rows.map((b) => b.task_id));
|
|
217
|
+
const judged = (r) => ({ ...row(r), resume: null, judgment: JUDGMENT[r.judgment].word, busy: JUDGMENT[r.judgment].busy });
|
|
143
218
|
return {
|
|
144
|
-
breaches: digest.rows.map((b) => this.glassBreach(b)),
|
|
219
|
+
breaches: digest.rows.map((b) => this.glassBreach(b, sess)),
|
|
145
220
|
more: digest.more,
|
|
146
|
-
motion: [...sections.mine, ...sections.held].filter((r) => this.moving(r)).map(row),
|
|
147
|
-
|
|
221
|
+
motion: work([...sections.mine, ...sections.held]).filter((r) => this.moving(r)).map(row),
|
|
222
|
+
judged: work(sections.asserted).filter((r) => !breached.has(r.task_id)).map(judged),
|
|
223
|
+
idle: work(sections.mine).filter((r) => !this.moving(r)).map(row),
|
|
148
224
|
sections,
|
|
149
225
|
default_agent: this.defaultAgent,
|
|
150
226
|
};
|
package/src/notch.mjs
CHANGED
|
@@ -15,45 +15,27 @@ import path from 'node:path';
|
|
|
15
15
|
|
|
16
16
|
import { defaultExec } from './harnesses/harness.mjs';
|
|
17
17
|
import { sha256Hex } from './manifest.mjs';
|
|
18
|
+
import {
|
|
19
|
+
serviceLabel, agentPathFor, launchAgentPlistFor, launchdJob as launchdJobOf,
|
|
20
|
+
bootstrapWithRetry, blockingSleep,
|
|
21
|
+
} from './launchd.mjs';
|
|
18
22
|
|
|
19
23
|
export const NOTCH_LABEL = 'ai.oathe.notch';
|
|
20
24
|
|
|
21
|
-
/** The
|
|
22
|
-
*
|
|
23
|
-
* special case: "am I the default home" cannot be judged from inside an environment
|
|
24
|
-
* (os.homedir() follows $HOME, so a sandboxed child believes its sandbox is home — the
|
|
25
|
-
* self-reference that let a full-suite run kill the founder's live island through the
|
|
26
|
-
* shared fixed label, 2026-08-31, twice). The uid's launchd domain is shared across
|
|
27
|
-
* homes; only the hash keeps installations apart. */
|
|
25
|
+
/** The notch's per-home label — the mechanism (and its 2026-08-31 scar story) lives in
|
|
26
|
+
* src/launchd.mjs, ONE implementation for every oathe service. */
|
|
28
27
|
export function notchLabel(home) {
|
|
29
|
-
|
|
30
|
-
return `${NOTCH_LABEL}.${sha256Hex(real(home)).slice(0, 12)}`;
|
|
28
|
+
return serviceLabel(home, NOTCH_LABEL);
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
export function launchAgentPath(home) {
|
|
34
|
-
return
|
|
32
|
+
return agentPathFor(home, notchLabel(home));
|
|
35
33
|
}
|
|
36
34
|
|
|
35
|
+
/** The notch's plist: the app binary as the one program argument. KeepAlive rationale — a
|
|
36
|
+
* dead viewer is a silent breach surface — rides the shared writer. */
|
|
37
37
|
export function launchAgentPlist(appPath, { label = NOTCH_LABEL, nodeBinDir = path.dirname(process.execPath) } = {}) {
|
|
38
|
-
|
|
39
|
-
// oathe running, so it knows exactly where the bin lives: the running node's own bin dir
|
|
40
|
-
// (the global npm bin) leads the agent's PATH. The app resolves `oathe` from this, no
|
|
41
|
-
// shell guessing. KeepAlive: the notch is a viewer with no side effects — a dead viewer
|
|
42
|
-
// is a silent breach surface, so launchd owns its liveness (crash, kill, or a replaced
|
|
43
|
-
// binary all end in a restart, never in quiet absence).
|
|
44
|
-
const agentPath = [nodeBinDir, '/usr/local/bin', '/opt/homebrew/bin', '/usr/bin', '/bin'].join(':');
|
|
45
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
46
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
47
|
-
<plist version="1.0">
|
|
48
|
-
<dict>
|
|
49
|
-
<key>Label</key><string>${label}</string>
|
|
50
|
-
<key>ProgramArguments</key><array><string>${appPath}</string></array>
|
|
51
|
-
<key>EnvironmentVariables</key><dict><key>PATH</key><string>${agentPath}</string></dict>
|
|
52
|
-
<key>RunAtLoad</key><true/>
|
|
53
|
-
<key>KeepAlive</key><true/>
|
|
54
|
-
</dict>
|
|
55
|
-
</plist>
|
|
56
|
-
`;
|
|
38
|
+
return launchAgentPlistFor({ label, programArguments: [appPath], nodeBinDir });
|
|
57
39
|
}
|
|
58
40
|
|
|
59
41
|
/** The app the npm package ships — built by prepack, the SOURCE every machine materializes from. */
|
|
@@ -94,22 +76,15 @@ export function materializeNotchApp({ home, appBinary, version }) {
|
|
|
94
76
|
return { dir, binary, sha256: sha };
|
|
95
77
|
}
|
|
96
78
|
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
export
|
|
100
|
-
const r = exec.run('launchctl', ['print', `gui/${uid}/${label}`]);
|
|
101
|
-
const pid = r.status === 0 ? Number(/^\s*pid = (\d+)/m.exec(r.stdout)?.[1] ?? NaN) : NaN;
|
|
102
|
-
return { label, loaded: r.status === 0, pid: Number.isFinite(pid) ? pid : null };
|
|
103
|
-
}
|
|
79
|
+
/** launchd's word on one label — the implementation lives in src/launchd.mjs; re-exported
|
|
80
|
+
* here for its standing consumers (doctor's liveness row). */
|
|
81
|
+
export const launchdJob = launchdJobOf;
|
|
104
82
|
|
|
105
83
|
/** The same word for this home's notch agent. */
|
|
106
84
|
export function notchStatus({ home, exec = defaultExec, uid = process.getuid() }) {
|
|
107
85
|
return launchdJob({ label: notchLabel(home), exec, uid });
|
|
108
86
|
}
|
|
109
87
|
|
|
110
|
-
/** A synchronous pause — init is a straight line, and launchd is asked, not raced. */
|
|
111
|
-
const blockingSleep = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
112
|
-
|
|
113
88
|
export function wireNotch({ home, manifest, config, version, exec = defaultExec, uid = process.getuid(), packageRoot, sleep = blockingSleep }) {
|
|
114
89
|
if (process.platform !== 'darwin') return [];
|
|
115
90
|
const source = config.get('notchApp') ?? packagedNotchApp(packageRoot);
|
|
@@ -130,11 +105,13 @@ export function wireNotch({ home, manifest, config, version, exec = defaultExec,
|
|
|
130
105
|
|
|
131
106
|
// Replaced wholesale on every wire: the manifest rows say what exists NOW (upsert keys on
|
|
132
107
|
// detail, so a moved app path would otherwise accumulate rows instead of replacing them).
|
|
133
|
-
// A replaced agent under a DIFFERENT name (
|
|
134
|
-
// out and removed here — otherwise the old job lingers loaded beside the new one.
|
|
135
|
-
|
|
108
|
+
// A replaced agent under a DIFFERENT name (an earlier wiring's label, a moved home) is booted
|
|
109
|
+
// out and removed here — otherwise the old job lingers loaded beside the new one. The
|
|
110
|
+
// sweep is scoped to the NOTCH'S OWN rows (phase 2): the serve daemon's launch agent is
|
|
111
|
+
// another owner's — a kind-wide sweep would boot it out on every init.
|
|
112
|
+
for (const row of manifest.removeWhere((r) => r.harness === 'notch' && (r.kind === 'launch-agent' || r.kind === 'notch-app'))) {
|
|
136
113
|
if (row.kind === 'launch-agent' && row.file !== file) {
|
|
137
|
-
exec.run('launchctl', ['bootout', `gui/${uid}/${path.basename(row.file, '.plist')}`]); // result unread: a
|
|
114
|
+
exec.run('launchctl', ['bootout', `gui/${uid}/${path.basename(row.file, '.plist')}`]); // result unread: a replaced label that is not loaded answers 'Could not find service' — nothing to do either way
|
|
138
115
|
if (fs.existsSync(row.file)) fs.rmSync(row.file);
|
|
139
116
|
}
|
|
140
117
|
}
|
|
@@ -154,36 +131,25 @@ export function wireNotch({ home, manifest, config, version, exec = defaultExec,
|
|
|
154
131
|
const stale = path.join(materializedNotchRoot(home), key);
|
|
155
132
|
if (stale !== app.dir) fs.rmSync(stale, { recursive: true, force: true });
|
|
156
133
|
}
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
last = exec.run('launchctl', ['bootstrap', `gui/${uid}`, file]);
|
|
169
|
-
}
|
|
170
|
-
let status = notchStatus({ home, exec, uid });
|
|
171
|
-
while (last.status === 0 && status.pid === null && Date.now() < deadline) {
|
|
172
|
-
sleep(poll());
|
|
173
|
-
status = notchStatus({ home, exec, uid });
|
|
174
|
-
}
|
|
175
|
-
const outcome = status.pid !== null
|
|
176
|
-
? { action: 'notch-running', pid: status.pid, label }
|
|
177
|
-
: { action: 'notch-not-running', file, label, detail: lastLine(last.stderr) || (status.loaded ? 'loaded, no pid yet' : 'not loaded') };
|
|
134
|
+
// The restart, asked not raced — the shared bootstrapWithRetry (src/launchd.mjs) carries
|
|
135
|
+
// the 0.4.3 lesson: retry the refused bootstrap inside the budget, read the pid back from
|
|
136
|
+
// launchd, and past the budget answer with launchd's own last word.
|
|
137
|
+
const took = bootstrapWithRetry({
|
|
138
|
+
label, file, uid, exec, sleep,
|
|
139
|
+
deadlineMs: config.get('notchRestartSeconds') * 1000,
|
|
140
|
+
pollMs: config.get('notchRestartPollMs'),
|
|
141
|
+
});
|
|
142
|
+
const outcome = took.pid !== null
|
|
143
|
+
? { action: 'notch-running', pid: took.pid, label }
|
|
144
|
+
: { action: 'notch-not-running', file, label, detail: took.detail };
|
|
178
145
|
return [{ action: 'launch-agent-written', file }, outcome];
|
|
179
146
|
}
|
|
180
147
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
/** @returns {object[]} action rows for the uninstall report */
|
|
148
|
+
/** @returns {object[]} action rows for the uninstall report — the NOTCH'S rows only; the
|
|
149
|
+
* serve daemon unwires through its own owner (src/serve.mjs). */
|
|
184
150
|
export function unwireNotch({ manifest, exec = defaultExec, uid = process.getuid() }) {
|
|
185
151
|
const actions = [];
|
|
186
|
-
for (const row of manifest.removeWhere((r) => r.kind === 'launch-agent')) {
|
|
152
|
+
for (const row of manifest.removeWhere((r) => r.harness === 'notch' && r.kind === 'launch-agent')) {
|
|
187
153
|
// The label rides the recorded file name — unwire boots out exactly what wire named.
|
|
188
154
|
exec.run('launchctl', ['bootout', `gui/${uid}/${path.basename(row.file, '.plist')}`]); // result unread: an agent already gone answers 'Could not find service'; the removal below is what uninstall promises
|
|
189
155
|
if (fs.existsSync(row.file)) fs.rmSync(row.file);
|
package/src/oathe-annotator.mjs
CHANGED
|
@@ -79,16 +79,16 @@ export class OatheAnnotator {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
#step(step) {
|
|
82
|
-
// A speech act is a tool call by an oathe verb — or, on codex, an act the record
|
|
83
|
-
// INSIDE an exec source that ran several things (
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
];
|
|
82
|
+
// A speech act is a tool call by an oathe verb — or, on codex, an act the record names
|
|
83
|
+
// INSIDE an exec source that ran several things (the call's ledger,
|
|
84
|
+
// extra.record.executions[].tool — named from the source at call-start, completed by the
|
|
85
|
+
// items): the exec stays one call, the act is on the record before the cell returns. A
|
|
86
|
+
// step this trajectory INHERITED (is_copied_context — a forked child's copy of the
|
|
87
|
+
// parent's turn) carries the parent's acts, never this agent's claim events.
|
|
88
|
+
const acts = step.is_copied_context === true ? [] : (step.tool_calls ?? []).flatMap((call) => [
|
|
89
|
+
{ name: call.function_name, args: call.arguments },
|
|
90
|
+
...(call.extra?.record?.executions ?? []).filter((ran) => ran.tool).map((ran) => ({ name: ran.tool, args: ran.arguments })),
|
|
91
|
+
]);
|
|
92
92
|
const events = acts
|
|
93
93
|
.map(({ name, args }) => {
|
|
94
94
|
const verb = oatheVerbFor(name);
|