omo-ai 5.1.63 → 5.1.65
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/bin/darwin/omo-keychain +0 -0
- package/bin/lib/doctor-memory-runtime.js +167 -0
- package/bin/lib/doctor-reflection-lock.js +102 -6
- package/bin/lib/doctor.js +4 -2
- package/bin/lib/engine-boot.js +27 -0
- package/bin/lib/launcher.js +44 -3
- package/bin/lib/memory-sync-boot.js +19 -0
- package/bin/lib/provider-map.json +1 -1
- package/bin/lib/reflection-lock.generated.js +39 -1
- package/bin/lib/service-auth.generated.js +37 -18
- package/bin/lib/thread.js +28 -2
- package/package.json +2 -2
- package/plugin/CHANGELOG.md +86 -0
- package/plugin/extensions/dream-persona.md +1 -1
- package/plugin/extensions/gateway-store-worker.mjs +2 -2
- package/plugin/extensions/memory-run-supervisor.mjs +3 -3
- package/plugin/extensions/omo-claim-receipt.js +1 -1
- package/plugin/extensions/omo-computer-use.js +1 -1
- package/plugin/extensions/omo-desktop-toolkit.js +1 -1
- package/plugin/extensions/omo-device-account.js +66 -2
- package/plugin/extensions/omo-device-service.js +5 -5
- package/plugin/extensions/omo-feedback.js +2 -2
- package/plugin/extensions/omo-init-deep-advisor.js +1 -1
- package/plugin/extensions/omo-member.js +2 -2
- package/plugin/extensions/omo-memory-commands.js +3 -3
- package/plugin/extensions/omo-memory-doctor.js +3 -3
- package/plugin/extensions/omo-memory-memfs.js +3 -3
- package/plugin/extensions/omo-memory-palace.js +3 -3
- package/plugin/extensions/omo-memory-sync.js +2 -2
- package/plugin/extensions/omo-onboarding-scan.js +3 -3
- package/plugin/extensions/omo-recall-store.js +1 -1
- package/plugin/extensions/omo-session-history.js +1 -1
- package/plugin/extensions/omo-side-panel.js +2 -2
- package/plugin/extensions/omo-task.js +2 -2
- package/plugin/extensions/omo-telemetry-otlp.js +2 -2
- package/plugin/extensions/omo-telemetry-posthog.js +1 -1
- package/plugin/extensions/omo-telemetry-recovery.js +1 -1
- package/plugin/extensions/omo-thread-client.js +5 -5
- package/plugin/extensions/omo.js +3 -3
- package/plugin/package.json +2 -1
- package/plugin/runtime/agent-toolkit-sdk/sdk.js +2 -2
- package/plugin/runtime/ast-grep-mcp/manifest.json +1 -1
- package/plugin/runtime/bunshin-ts/sdk.js +2 -2
- package/plugin/runtime/category-coverage/index.js +2 -2
- package/plugin/runtime/rollback-migrate.js +1 -1
- package/plugin/runtime/task-config/index.js +3 -3
- package/plugin/runtime/thread-sdk/sdk.js +5 -5
- package/plugin/skills/browser/SKILL.md +3 -1
- package/plugin/skills/browser/runtime/omowright/index.js +232 -341
- package/plugin/skills/browser/runtime/omowright/manifest.json +5 -5
- package/plugin/skills/browser/runtime/omowright/page-bundle.js +1586 -1394
- package/plugin/skills/browser/scripts/browser-doctor-report.mjs +68 -0
- package/plugin/skills/browser/scripts/browser-doctor.mjs +8 -43
- package/plugin/skills/browser/scripts/omowright.mjs +7 -1
package/bin/darwin/omo-keychain
CHANGED
|
Binary file
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// omo doctor: how much each durable memory identity holds under runtime/ and the total (#10144). The
|
|
2
|
+
// number comes from the same measure the session's size cap acts on (memory-core retention/size.ts),
|
|
3
|
+
// run from the generated doctor bundle, so the CLI and the cap cannot count differently.
|
|
4
|
+
|
|
5
|
+
import { existsSync, readdirSync } from "node:fs"
|
|
6
|
+
import { createRequire } from "node:module"
|
|
7
|
+
import { homedir } from "node:os"
|
|
8
|
+
import { join, resolve } from "node:path"
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_RUNTIME_MAX_BYTES,
|
|
11
|
+
DEFAULT_RUNTIME_RETENTION,
|
|
12
|
+
buildIdentityPaths,
|
|
13
|
+
describeRuntimeCapExcess,
|
|
14
|
+
formatRuntimeBytes,
|
|
15
|
+
measureRuntimeCapEvictableBytes,
|
|
16
|
+
measureRuntimeSizeWithinBudget,
|
|
17
|
+
measureUnreflectedJournalBytes,
|
|
18
|
+
runtimeSizeStanding,
|
|
19
|
+
} from "./reflection-lock.generated.js"
|
|
20
|
+
|
|
21
|
+
const MEMORY_ROOT_ENV_VAR = "OMO_MEMORY_HOME"
|
|
22
|
+
// The listing stays readable on hosts with thousands of identities; the total and every warning still
|
|
23
|
+
// cover all of them.
|
|
24
|
+
const LISTED_IDENTITIES = 10
|
|
25
|
+
|
|
26
|
+
function memoryRoot(env) {
|
|
27
|
+
const override = env[MEMORY_ROOT_ENV_VAR]
|
|
28
|
+
if (override === undefined || override.trim() === "") return join(homedir(), ".omo", "memory")
|
|
29
|
+
return resolve(process.cwd(), override)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function listDurableIdentities(agentsRoot) {
|
|
33
|
+
try {
|
|
34
|
+
return readdirSync(agentsRoot, { withFileTypes: true })
|
|
35
|
+
.filter((entry) => entry.isDirectory() && !entry.name.startsWith("."))
|
|
36
|
+
.map((entry) => entry.name)
|
|
37
|
+
.filter((name) => existsSync(join(agentsRoot, name, "repo")))
|
|
38
|
+
.sort()
|
|
39
|
+
} catch {
|
|
40
|
+
return []
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const requireRuntime = createRequire(import.meta.url)
|
|
45
|
+
const TASK_CONFIG_RUNTIME = join("runtime", "task-config", "index.js")
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `memory.runtime.max_bytes` per identity, read through the staged config runtime (the loader every
|
|
49
|
+
* other omo.json key goes through). Fail-open: a payload without the runtime, or any error in it,
|
|
50
|
+
* reads the shipped default.
|
|
51
|
+
*/
|
|
52
|
+
function loadMemoryRuntimeCaps(options) {
|
|
53
|
+
try {
|
|
54
|
+
const runtime = (options.loadRuntime ?? ((pluginRoot) => requireRuntime(join(pluginRoot, TASK_CONFIG_RUNTIME))))(options.pluginRoot)
|
|
55
|
+
return runtime.resolveMemoryRuntimeCaps({ cwd: options.cwd ?? process.cwd(), env: options.env ?? process.env })
|
|
56
|
+
} catch {
|
|
57
|
+
return undefined
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function memoryRuntimeMaxBytesResolver(options) {
|
|
62
|
+
const caps = loadMemoryRuntimeCaps(options)
|
|
63
|
+
return (identity) => caps?.agents[identity] ?? caps?.maxBytes ?? DEFAULT_RUNTIME_MAX_BYTES
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** `memory.runtime.discard_unreflected_journals` per identity, from the same loader; fail-open to the shipped false. */
|
|
67
|
+
export function memoryRuntimeDiscardResolver(options) {
|
|
68
|
+
const caps = loadMemoryRuntimeCaps(options)
|
|
69
|
+
return (identity) => caps?.discardAgents?.[identity] ?? caps?.discardUnreflectedJournals ?? false
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function capText(maxBytes) {
|
|
73
|
+
return maxBytes > 0 ? `${formatRuntimeBytes(maxBytes)} cap` : "no cap"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function formatMemoryRuntimeLines(identities, totalBytes) {
|
|
77
|
+
if (identities.length === 0) return []
|
|
78
|
+
const bySize = [...identities].sort((left, right) => right.bytes - left.bytes || left.identity.localeCompare(right.identity))
|
|
79
|
+
const lines = bySize.slice(0, LISTED_IDENTITIES).map((entry) => {
|
|
80
|
+
if (entry.sizeUnknown !== undefined) return `INFO memory runtime: ${entry.identity} size unknown (${capText(entry.maxBytes)})`
|
|
81
|
+
const standing = runtimeSizeStanding(entry.bytes, entry.maxBytes)
|
|
82
|
+
const share = standing.percent === undefined ? "" : `, ${standing.percent}%`
|
|
83
|
+
return `INFO memory runtime: ${entry.identity} ${formatRuntimeBytes(entry.bytes)} (${capText(entry.maxBytes)}${share})`
|
|
84
|
+
})
|
|
85
|
+
const rest = bySize.slice(LISTED_IDENTITIES)
|
|
86
|
+
if (rest.length > 0) {
|
|
87
|
+
const restBytes = rest.reduce((sum, entry) => sum + entry.bytes, 0)
|
|
88
|
+
lines.push(`INFO memory runtime: ${rest.length} more identities hold ${formatRuntimeBytes(restBytes)}`)
|
|
89
|
+
}
|
|
90
|
+
const unknown = identities.filter((entry) => entry.sizeUnknown !== undefined).length
|
|
91
|
+
lines.push(`INFO memory runtime total: ${formatRuntimeBytes(totalBytes)} across ${identities.length} identit${identities.length === 1 ? "y" : "ies"}${unknown === 0 ? "" : ` (${unknown} not measured)`}`)
|
|
92
|
+
for (const entry of bySize) {
|
|
93
|
+
if (entry.sizeUnknown !== undefined) {
|
|
94
|
+
lines.push(`WARN memory runtime (${entry.identity}): size unknown: measurement exceeded ${entry.sizeUnknown.budgetMs} ms on ${entry.sizeUnknown.at}`)
|
|
95
|
+
continue
|
|
96
|
+
}
|
|
97
|
+
const excess = describeRuntimeCapExcess({
|
|
98
|
+
overCapBytes: entry.maxBytes > 0 ? entry.bytes - entry.maxBytes : 0,
|
|
99
|
+
evictableBytes: entry.evictableBytes ?? 0,
|
|
100
|
+
unreflectedBytes: entry.unreflectedBytes ?? 0,
|
|
101
|
+
discardUnreflectedJournals: entry.discardUnreflectedJournals,
|
|
102
|
+
})
|
|
103
|
+
// Over the cap, the excess line says what the next pass does; the near-cap line is for 80-100 %.
|
|
104
|
+
if (excess !== undefined) {
|
|
105
|
+
lines.push(`WARN memory runtime (${entry.identity}): ${excess}; raise memory.runtime.max_bytes, or set it to 0, to keep more.`)
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
const standing = runtimeSizeStanding(entry.bytes, entry.maxBytes)
|
|
109
|
+
if (standing.level !== "warn") continue
|
|
110
|
+
lines.push(`WARN memory runtime is near its size cap (${entry.identity}): ${formatRuntimeBytes(entry.bytes)} is ${standing.percent}% of the ${formatRuntimeBytes(entry.maxBytes)} cap (memory.runtime.max_bytes). The next maintenance pass evicts the oldest runtime data down to the cap; raise the cap, or set it to 0, to keep more.`)
|
|
111
|
+
}
|
|
112
|
+
return lines
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @param options.env where OMO_MEMORY_HOME is read
|
|
117
|
+
* @param options.maxBytesFor the resolved `memory.runtime.max_bytes` for one identity (default: the shipped default)
|
|
118
|
+
* @param options.discardFor the resolved `memory.runtime.discard_unreflected_journals` for one identity (default: the shipped false)
|
|
119
|
+
* @param options.measureBudgetMs each identity's measurement deadline, the one `/doctor` uses (default: the shipped pass_budget_ms)
|
|
120
|
+
* @param options.measureSignal a caller deadline that replaces the per-identity timer
|
|
121
|
+
* @returns {Promise<{ identities: { identity: string, bytes: number, maxBytes: number, unreflectedBytes?: number, discardUnreflectedJournals: boolean, evictableBytes?: number, sizeUnknown?: { budgetMs: number, at: string } }[], totalBytes: number, lines: string[] }>}
|
|
122
|
+
*/
|
|
123
|
+
export async function memoryRuntimeReport(options = {}) {
|
|
124
|
+
const root = memoryRoot(options.env ?? process.env)
|
|
125
|
+
const agentsRoot = join(root, "agents")
|
|
126
|
+
const maxBytesFor = options.maxBytesFor ?? (() => DEFAULT_RUNTIME_MAX_BYTES)
|
|
127
|
+
const discardFor = options.discardFor ?? (() => false)
|
|
128
|
+
const budgetMs = options.measureBudgetMs ?? DEFAULT_RUNTIME_RETENTION.passBudgetMs
|
|
129
|
+
const identities = []
|
|
130
|
+
for (const identity of options.listIdentities?.(agentsRoot) ?? listDurableIdentities(agentsRoot)) {
|
|
131
|
+
const paths = buildIdentityPaths(root, identity)
|
|
132
|
+
const maxBytes = maxBytesFor(identity)
|
|
133
|
+
const discardUnreflectedJournals = discardFor(identity)
|
|
134
|
+
// One deadline per identity bounds the size walk and the journal scans that read whole transcripts.
|
|
135
|
+
const signal = options.measureSignal ?? AbortSignal.timeout(budgetMs)
|
|
136
|
+
const startedAt = Date.now()
|
|
137
|
+
const measured = await measureRuntimeSizeWithinBudget(paths.runtime, { budgetMs, now: startedAt, signal })
|
|
138
|
+
if ("sizeUnknown" in measured) {
|
|
139
|
+
identities.push({ identity, bytes: 0, maxBytes, discardUnreflectedJournals, sizeUnknown: measured.sizeUnknown })
|
|
140
|
+
continue
|
|
141
|
+
}
|
|
142
|
+
const bytes = measured.size.bytes
|
|
143
|
+
const policy = { ...DEFAULT_RUNTIME_RETENTION, discardUnreflectedJournals }
|
|
144
|
+
const overCap = maxBytes > 0 && bytes > maxBytes
|
|
145
|
+
let unreflectedBytes
|
|
146
|
+
let evictableBytes
|
|
147
|
+
try {
|
|
148
|
+
// Printed only on the over-cap line, and only with the switch off.
|
|
149
|
+
unreflectedBytes = overCap && !discardUnreflectedJournals ? await measureUnreflectedJournalBytes({ paths, policy, signal }) : undefined
|
|
150
|
+
evictableBytes = overCap ? await measureRuntimeCapEvictableBytes({ paths, policy, now: Date.now, signal }) : undefined
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if (!signal.aborted) throw error
|
|
153
|
+
identities.push({ identity, bytes: 0, maxBytes, discardUnreflectedJournals, sizeUnknown: { budgetMs, at: new Date(startedAt).toISOString() } })
|
|
154
|
+
continue
|
|
155
|
+
}
|
|
156
|
+
identities.push({
|
|
157
|
+
identity,
|
|
158
|
+
bytes,
|
|
159
|
+
maxBytes,
|
|
160
|
+
discardUnreflectedJournals,
|
|
161
|
+
...(unreflectedBytes === undefined ? {} : { unreflectedBytes }),
|
|
162
|
+
...(evictableBytes === undefined ? {} : { evictableBytes }),
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
const totalBytes = identities.reduce((sum, entry) => sum + entry.bytes, 0)
|
|
166
|
+
return { identities, totalBytes, lines: formatMemoryRuntimeLines(identities, totalBytes) }
|
|
167
|
+
}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
// omo doctor: a reflection lock held by a run that cannot finish (#10377). The decision is the one the
|
|
2
2
|
// session uses (memory-core reflection/stale-holder.ts), run from its generated bundle, so the two
|
|
3
3
|
// surfaces cannot disagree. A dead holder and a stuck one are both reported with the next step;
|
|
4
|
-
// a live holder or no lock prints nothing.
|
|
4
|
+
// a live holder or no lock prints nothing. `omo doctor --fix` runs the shared reaper
|
|
5
|
+
// (stale-lock-reaper.ts) with its minimal settle on every durable identity (#11976).
|
|
5
6
|
|
|
6
7
|
import { existsSync, readdirSync } from "node:fs"
|
|
8
|
+
import { createRequire } from "node:module"
|
|
7
9
|
import { homedir } from "node:os"
|
|
8
10
|
import { basename, join, resolve } from "node:path"
|
|
9
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
classifyReflectionLockHolder,
|
|
13
|
+
createRetentionHostSweepStep,
|
|
14
|
+
decideStaleReflectionLock,
|
|
15
|
+
decideStrandedRun,
|
|
16
|
+
formatStaleLockFixLines,
|
|
17
|
+
reclaimDeadOwnerLocks,
|
|
18
|
+
runStaleLockReaper,
|
|
19
|
+
sweepHostIdentities,
|
|
20
|
+
sweepIdentityOrphanWorktrees,
|
|
21
|
+
} from "./reflection-lock.generated.js"
|
|
22
|
+
import { TASK_CONFIG_RUNTIME } from "./daemon-config.js"
|
|
23
|
+
import { packageRoot } from "./package-paths.js"
|
|
24
|
+
|
|
25
|
+
const requireRuntime = createRequire(import.meta.url)
|
|
10
26
|
|
|
11
27
|
const MEMORY_ROOT_ENV_VAR = "OMO_MEMORY_HOME"
|
|
12
28
|
|
|
@@ -20,13 +36,24 @@ export function classifyReflectionLock(reflectionDir, probe = {}) {
|
|
|
20
36
|
return classifyReflectionLockHolder(reflectionDir, probe)
|
|
21
37
|
}
|
|
22
38
|
|
|
23
|
-
export function
|
|
39
|
+
export function decideReflectionLock(reflectionDir, probe = {}) {
|
|
40
|
+
return decideStaleReflectionLock(reflectionDir, probe)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function decideStrandedReflectionRun(runDir, probe = {}) {
|
|
44
|
+
return decideStrandedRun(runDir, probe)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function formatReflectionLockLines(identity, verdict, reflectionDir, decision) {
|
|
24
48
|
if (verdict.state === "none" || verdict.state === "live") return []
|
|
25
49
|
const lock = join(reflectionDir, "active.lock")
|
|
26
50
|
if (verdict.state === "dead") {
|
|
27
51
|
return [`WARN memory reflection is stuck on a stale lock (${identity}): run ${verdict.runId} still holds ${lock}, but its launcher is gone and it already recorded its outcome. Next step: open a session and send /reflect (or any message); the session settles that run and starts any queued request.`]
|
|
28
52
|
}
|
|
29
|
-
|
|
53
|
+
if (decision?.kind === "reap") {
|
|
54
|
+
return [`WARN memory reflection is stuck on a stale lock (${identity}): run ${verdict.runId} still holds ${lock} and ${decision.reason}. Next step: omo doctor --fix (it would apply ${decision.action}).`]
|
|
55
|
+
}
|
|
56
|
+
return [`WARN memory reflection is stuck on a stale lock (${identity}): run ${verdict.runId} still holds ${lock} and ${verdict.reason}. Next step: run /doctor in a session; if no reflection run is active, run omo doctor --fix.`]
|
|
30
57
|
}
|
|
31
58
|
|
|
32
59
|
function listDurableIdentities(agentsRoot) {
|
|
@@ -45,8 +72,77 @@ export async function reflectionLockReport(options = {}) {
|
|
|
45
72
|
const lines = []
|
|
46
73
|
for (const identityRoot of options.listIdentities?.(agentsRoot) ?? listDurableIdentities(agentsRoot)) {
|
|
47
74
|
const reflectionDir = join(identityRoot, "runtime", "reflection")
|
|
48
|
-
const verdict = await
|
|
49
|
-
lines.push(...formatReflectionLockLines(basename(identityRoot), verdict, reflectionDir))
|
|
75
|
+
const { verdict, decision } = await decideStaleReflectionLock(reflectionDir, options.reflectionLockProbe ?? {})
|
|
76
|
+
lines.push(...formatReflectionLockLines(basename(identityRoot), verdict, reflectionDir, decision))
|
|
50
77
|
}
|
|
51
78
|
return lines
|
|
52
79
|
}
|
|
80
|
+
|
|
81
|
+
function orphanLines(identity, report, dryRun) {
|
|
82
|
+
if (report.skipped !== undefined) return []
|
|
83
|
+
const lines = report.removed.map((target) => `${dryRun ? "WOULD FIX" : "FIXED"} ${identity} removed orphan ${target}`)
|
|
84
|
+
if (dryRun) lines.push(...report.kept.map((entry) => `KEPT ${identity} worktree ${entry.target} (${entry.reason})`))
|
|
85
|
+
lines.push(...report.failed.map((entry) => `KEPT ${identity} orphan ${entry.target} (${entry.detail})`))
|
|
86
|
+
return lines
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function loadTaskConfigRuntime() {
|
|
90
|
+
return requireRuntime(join(packageRoot, "plugin", TASK_CONFIG_RUNTIME))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// The memory settings of the user's GLOBAL omo config only (omo.jsonc, else omo.json under ~/.omo):
|
|
94
|
+
// `--fix` sweeps identities of every project, so it never reads a project layer (REVIEW-4 M-b). They
|
|
95
|
+
// are resolved by the session's own loader (`[senpi]`, `[native]`, the active profile, merged per agent
|
|
96
|
+
// and per runtime key) through the staged task-config runtime (task-config-entry.ts). Unreadable config
|
|
97
|
+
// or a runtime that cannot load means no settings, which keeps unreflected journal input.
|
|
98
|
+
export function readGlobalMemorySettings(home = homedir(), options = {}) {
|
|
99
|
+
try {
|
|
100
|
+
const runtime = (options.loadTaskConfig ?? loadTaskConfigRuntime)()
|
|
101
|
+
return runtime.resolveGlobalMemorySettings({ env: { ...(options.env ?? process.env), HOME: home, USERPROFILE: home } })
|
|
102
|
+
} catch {
|
|
103
|
+
return undefined
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// `omo doctor --fix`: driver 1 of the host sweep (memory-core reflection/host-sweep.ts). Every identity
|
|
108
|
+
// with a runtime/ is visited, repo or not, resuming at the persisted cursor; a repo-less identity gets
|
|
109
|
+
// the reaper and the lock sweep, never the git-backed orphan sweep.
|
|
110
|
+
export async function reflectionLockFix(options = {}) {
|
|
111
|
+
const memory = memoryRoot(options.env ?? process.env)
|
|
112
|
+
const dryRun = options.dryRun === true
|
|
113
|
+
const probe = options.reflectionLockProbe ?? {}
|
|
114
|
+
let failed = false
|
|
115
|
+
const reap = async (identity) => {
|
|
116
|
+
try {
|
|
117
|
+
const report = await runStaleLockReaper({ runtimeDir: identity.runtimeDir, probe, dryRun })
|
|
118
|
+
const locks = dryRun ? undefined : await reclaimDeadOwnerLocks(join(identity.runtimeDir, "locks"))
|
|
119
|
+
return formatStaleLockFixLines(identity.name, report, locks)
|
|
120
|
+
} catch (error) {
|
|
121
|
+
failed = true
|
|
122
|
+
return [`FAIL ${identity.name} reflection lock fix failed: ${error instanceof Error ? error.message : String(error)}`]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const orphans = async (identity) => {
|
|
126
|
+
try {
|
|
127
|
+
return orphanLines(identity.name, await sweepIdentityOrphanWorktrees(identity.root, { now: (probe.now ?? Date.now)(), dryRun }), dryRun)
|
|
128
|
+
} catch (error) {
|
|
129
|
+
failed = true
|
|
130
|
+
return [`FAIL ${identity.name} orphan worktree sweep failed: ${error instanceof Error ? error.message : String(error)}`]
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const settings = options.memorySettings ?? readGlobalMemorySettings(options.home ?? homedir(), {
|
|
134
|
+
env: options.env ?? process.env,
|
|
135
|
+
...(options.loadTaskConfig === undefined ? {} : { loadTaskConfig: options.loadTaskConfig }),
|
|
136
|
+
})
|
|
137
|
+
const retention = createRetentionHostSweepStep({ ...(settings === undefined ? {} : { settings }), ...(probe.now === undefined ? {} : { now: probe.now }), dryRun })
|
|
138
|
+
const retain = async (identity) => {
|
|
139
|
+
const lines = await retention(identity)
|
|
140
|
+
if (lines.some((line) => line.startsWith("FAIL "))) failed = true
|
|
141
|
+
return lines
|
|
142
|
+
}
|
|
143
|
+
const result = await sweepHostIdentities({ memoryRoot: memory, steps: [reap, orphans, retain], dryRun })
|
|
144
|
+
if (result.status === "busy") return { lines: ["INFO another sweep is running on this host; try again when it finishes"], failed: false }
|
|
145
|
+
const lines = result.lines.filter((line) => !/^INFO \S+ locks reclaimed 0, kept 0$/.test(line))
|
|
146
|
+
if (lines.length === 0) lines.push(dryRun ? "INFO nothing to fix" : "PASS no stale reflection locks")
|
|
147
|
+
return { lines, failed }
|
|
148
|
+
}
|
package/bin/lib/doctor.js
CHANGED
|
@@ -91,9 +91,10 @@ const MANAGED_MODE_FLAG = "--mode"
|
|
|
91
91
|
* it can never be a reason for diagnostics to fail, so an unavailable or unparsable listing is an
|
|
92
92
|
* empty list.
|
|
93
93
|
*/
|
|
94
|
-
function listProcesses() {
|
|
94
|
+
export function listProcesses() {
|
|
95
95
|
if (process.platform === "win32") return []
|
|
96
|
-
|
|
96
|
+
// -ww: an unlimited width, so `args` is never cut at the terminal width (BSD/macOS `ps` truncates).
|
|
97
|
+
const listed = spawnSync("ps", ["-ww", "-axo", "pid=,ppid=,etime=,tty=,args="], { encoding: "utf8" })
|
|
97
98
|
if (listed.status !== 0 || typeof listed.stdout !== "string") return []
|
|
98
99
|
const entries = []
|
|
99
100
|
for (const line of listed.stdout.split("\n")) {
|
|
@@ -426,6 +427,7 @@ export function runDoctor(inventory, args = [], options = {}) {
|
|
|
426
427
|
lines.push(...retiredPayloadReport(options))
|
|
427
428
|
lines.push(...transientMemoryReport(options))
|
|
428
429
|
lines.push(...(options.reflectionLock ?? []))
|
|
430
|
+
lines.push(...(options.memoryRuntime ?? []))
|
|
429
431
|
const launchSpec = launchSpecDoctorLines(options.pluginRoot ?? join(packageRoot, "plugin"), options.launchSpecIo)
|
|
430
432
|
if (launchSpec.some((line) => line.startsWith("FAIL "))) failed = true
|
|
431
433
|
lines.push(...launchSpec)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The npm launcher's engine entry for a launch that claims memory sync at boot (#11997, memory-sync-boot.js):
|
|
2
|
+
// argv is `<runtime> engine-boot.js <senpi cli> ...engine args`. It drops its own path so the engine sees the argv
|
|
3
|
+
// it always has, starts the claim, then runs senpi's CLI in this process. It follows the entry contract in omo-senpi
|
|
4
|
+
// desktop-sync/bootClaim.ts with the engine's own modules: cwd guard, filler release, gate, then the capture and claim.
|
|
5
|
+
import { basename, dirname, join } from "node:path"
|
|
6
|
+
import { pathToFileURL } from "node:url"
|
|
7
|
+
import { launchClaimsMemorySyncAtBoot } from "./memory-sync-boot.js"
|
|
8
|
+
import { packageRoot } from "./package-paths.js"
|
|
9
|
+
|
|
10
|
+
const cliPath = process.argv[2]
|
|
11
|
+
process.argv.splice(1, 1)
|
|
12
|
+
// The engine ships its CLI pre-bundled under dist/bundle and every module unbundled under dist.
|
|
13
|
+
const distDir = basename(dirname(cliPath)) === "bundle" ? dirname(dirname(cliPath)) : dirname(cliPath)
|
|
14
|
+
const moduleUrl = (path) => pathToFileURL(path).href
|
|
15
|
+
try {
|
|
16
|
+
await import(moduleUrl(join(distDir, "valid-cwd.js")))
|
|
17
|
+
await import(moduleUrl(join(distDir, "private-fd-startup-release.js")))
|
|
18
|
+
const sidecar = await import(moduleUrl(join(packageRoot, "plugin", "extensions", "omo-device-account.js")))
|
|
19
|
+
if (launchClaimsMemorySyncAtBoot(process.argv.slice(2), process.env, sidecar.claimsMemorySyncAtBoot)) {
|
|
20
|
+
const { takeInheritedPrivateChannel } = await import(moduleUrl(join(distDir, "private-fds.js")))
|
|
21
|
+
sidecar.claimMemorySyncAtBoot(takeInheritedPrivateChannel)
|
|
22
|
+
}
|
|
23
|
+
} catch (error) {
|
|
24
|
+
// The memory component's registration still selects once when the first session opens.
|
|
25
|
+
process.stderr.write(`omo: memory sync could not start at boot: ${error instanceof Error ? error.message : String(error)}\n`)
|
|
26
|
+
}
|
|
27
|
+
await import(moduleUrl(cliPath))
|
package/bin/lib/launcher.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process"
|
|
2
2
|
import { existsSync } from "node:fs"
|
|
3
3
|
import { join } from "node:path"
|
|
4
|
+
import { pathToFileURL } from "node:url"
|
|
4
5
|
import { isEngineCommand } from "./engine-commands.js"
|
|
5
6
|
import { spawnNode } from "./child-process.js"
|
|
6
7
|
import { privateFdHandoff } from "./private-fds.js"
|
|
8
|
+
import { launchClaimsMemorySyncAtBoot } from "./memory-sync-boot.js"
|
|
7
9
|
import { doctorCoverageLines } from "./category-coverage.js"
|
|
8
10
|
import { runDoctorModels } from "./model-chains.js"
|
|
9
11
|
import { doctorComputerUseLines } from "./computer-use-doctor.js"
|
|
@@ -12,7 +14,8 @@ import { runDaemonCommand } from "./daemon.js"
|
|
|
12
14
|
import { runThreadCommand } from "./thread.js"
|
|
13
15
|
import { isHostStatusAll, runHostStatusAll, sessionActivityReader } from "./host-status.js"
|
|
14
16
|
import { runDoctor } from "./doctor.js"
|
|
15
|
-
import { reflectionLockReport } from "./doctor-reflection-lock.js"
|
|
17
|
+
import { reflectionLockFix, reflectionLockReport } from "./doctor-reflection-lock.js"
|
|
18
|
+
import { memoryRuntimeDiscardResolver, memoryRuntimeMaxBytesResolver, memoryRuntimeReport } from "./doctor-memory-runtime.js"
|
|
16
19
|
import { ensureEnginePrepared, preparePluginLaunchSpec } from "./engine-prepare.js"
|
|
17
20
|
import { migrateLegacyBunGlobalManifest } from "./legacy-bun-global-migration.js"
|
|
18
21
|
import { removeLegacyServiceCredentials } from "./legacy-service-credentials.js"
|
|
@@ -46,6 +49,23 @@ function preparedSenpi() {
|
|
|
46
49
|
return senpi
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
// A memory-sync launch reaches the engine through this entry, which claims before senpi's CLI loads (#11997).
|
|
53
|
+
const ENGINE_BOOT_ENTRY = join(packageRoot, "bin", "lib", "engine-boot.js")
|
|
54
|
+
const DEVICE_ACCOUNT_SIDECAR = join(packageRoot, "plugin", "extensions", "omo-device-account.js")
|
|
55
|
+
|
|
56
|
+
/** Whether a launch that hands down a private-descriptor table claims memory sync at boot (the sidecar's gate). */
|
|
57
|
+
async function bootsWithMemorySyncClaim(args, env) {
|
|
58
|
+
try {
|
|
59
|
+
const { claimsMemorySyncAtBoot } = await import(pathToFileURL(DEVICE_ACCOUNT_SIDECAR).href)
|
|
60
|
+
// spawnNode starts the engine entry on this runtime without exec arguments; engine-boot.js checks again in-process.
|
|
61
|
+
return launchClaimsMemorySyncAtBoot(args, env, claimsMemorySyncAtBoot, { execArgv: [], versions: process.versions })
|
|
62
|
+
} catch (error) {
|
|
63
|
+
// Without the sidecar the memory component's registration still selects once when the first session opens.
|
|
64
|
+
process.stderr.write(`omo: memory sync could not start at boot: ${error instanceof Error ? error.message : String(error)}\n`)
|
|
65
|
+
return false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
49
69
|
async function spawnSenpi(args, withExtension) {
|
|
50
70
|
const senpi = preparedSenpi()
|
|
51
71
|
const finalArgs = withExtension
|
|
@@ -62,6 +82,10 @@ async function spawnSenpi(args, withExtension) {
|
|
|
62
82
|
// A failed replacement still uses the signal-aware child path below.
|
|
63
83
|
}
|
|
64
84
|
}
|
|
85
|
+
if (handoff !== undefined && await bootsWithMemorySyncClaim(finalArgs, handoff.env)) {
|
|
86
|
+
await spawnNode(ENGINE_BOOT_ENTRY, [senpi.cliPath, ...finalArgs], handoff)
|
|
87
|
+
return
|
|
88
|
+
}
|
|
65
89
|
await spawnNode(senpi.cliPath, finalArgs, handoff ?? { env })
|
|
66
90
|
}
|
|
67
91
|
|
|
@@ -195,13 +219,29 @@ export async function runLauncher(args = process.argv.slice(2)) {
|
|
|
195
219
|
process.exitCode = await runDoctorModels(args.slice(2), { agentDir: canonicalAgentDir() })
|
|
196
220
|
return
|
|
197
221
|
}
|
|
198
|
-
|
|
199
|
-
|
|
222
|
+
if (args[1] === "--fix") {
|
|
223
|
+
const extra = args.slice(2).filter((arg) => arg !== "--dry-run")
|
|
224
|
+
if (extra.length > 0) {
|
|
225
|
+
console.log(`FAIL unknown argument ${JSON.stringify(extra[0])}: omo doctor --fix [--dry-run]`)
|
|
226
|
+
process.exitCode = 1
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
const result = await reflectionLockFix({ dryRun: args.includes("--dry-run") })
|
|
230
|
+
console.log(result.lines.join("\n"))
|
|
231
|
+
process.exitCode = result.failed ? 1 : 0
|
|
232
|
+
return
|
|
233
|
+
}
|
|
234
|
+
const [categoryCoverage, computerUse, configDiagnostics, reflectionLock, memoryRuntime] = args[1] === "--reap"
|
|
235
|
+
? [[], [], [], [], []]
|
|
200
236
|
: await Promise.all([
|
|
201
237
|
doctorCoverageLines({ agentDir: canonicalAgentDir() }),
|
|
202
238
|
doctorComputerUseLines(),
|
|
203
239
|
doctorConfigLines(),
|
|
204
240
|
reflectionLockReport(),
|
|
241
|
+
memoryRuntimeReport({
|
|
242
|
+
maxBytesFor: memoryRuntimeMaxBytesResolver({ pluginRoot: join(packageRoot, "plugin") }),
|
|
243
|
+
discardFor: memoryRuntimeDiscardResolver({ pluginRoot: join(packageRoot, "plugin") }),
|
|
244
|
+
}).then((report) => report.lines, (error) => [`WARN memory runtime: unavailable: ${error instanceof Error ? error.message : String(error)}`]),
|
|
205
245
|
])
|
|
206
246
|
runDoctor(await detectHarnesses(), args.slice(1), {
|
|
207
247
|
daemonEngine: { run: engineHostCall },
|
|
@@ -209,6 +249,7 @@ export async function runLauncher(args = process.argv.slice(2)) {
|
|
|
209
249
|
computerUse,
|
|
210
250
|
configDiagnostics,
|
|
211
251
|
reflectionLock,
|
|
252
|
+
memoryRuntime,
|
|
212
253
|
})
|
|
213
254
|
return
|
|
214
255
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isEngineCommand } from "./engine-commands.js"
|
|
2
|
+
|
|
3
|
+
// #11997: a `--mode rpc` engine whose launch carried a private-descriptor table naming memory-sync starts that claim
|
|
4
|
+
// before senpi's CLI loads, because a multi-session host (what `host ensure` starts) loads extensions only when a
|
|
5
|
+
// session opens, and the desktop opens none before it has answered the claim's bootstrap frame. The launch rules are
|
|
6
|
+
// the device-account sidecar's `claimsMemorySyncAtBoot` (omo-senpi desktop-sync/bootGate.ts), which every entry, the
|
|
7
|
+
// desktop's included, calls; each omo entry passes it in from where it loads omo-senpi. omo adds only its own one-shot
|
|
8
|
+
// engine commands on top.
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether this omo launch should claim memory sync at boot: not an omo one-shot engine command, and the shared gate.
|
|
12
|
+
* @param {readonly string[]} args
|
|
13
|
+
* @param {Readonly<Record<string, string | undefined>>} env
|
|
14
|
+
* @param {(args: readonly string[], env?: Readonly<Record<string, string | undefined>>, runtime?: { readonly execArgv: readonly string[], readonly versions: { readonly bun?: string | undefined } }) => boolean} claimsMemorySyncAtBoot
|
|
15
|
+
* @param {{ readonly execArgv: readonly string[], readonly versions: { readonly bun?: string | undefined } }} [runtime]
|
|
16
|
+
*/
|
|
17
|
+
export function launchClaimsMemorySyncAtBoot(args, env, claimsMemorySyncAtBoot, runtime = process) {
|
|
18
|
+
return !isEngineCommand(args) && claimsMemorySyncAtBoot(args, env, runtime)
|
|
19
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "Derived from @code-yeongyu/senpi 2026.11.
|
|
2
|
+
"_comment": "Derived from @code-yeongyu/senpi 2026.11.6-3 builtinProviders(). builtinProviderIds and oauthProviderIds are the engine registry verbatim; providers maps a source harness id onto the omo provider that serves the same endpoint; oauthLogins maps a source OAuth id onto the omo provider to run /login for. Re-derive all four whenever the senpi pin changes.",
|
|
3
3
|
"builtinProviderIds": [
|
|
4
4
|
"alibaba-token-plan",
|
|
5
5
|
"amazon-bedrock",
|