@mono-agent/agent-app 0.6.2 → 0.9.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 +259 -19
- package/dist/account-home.d.ts +6 -0
- package/dist/account-home.d.ts.map +1 -0
- package/dist/account-home.js +9 -0
- package/dist/account-home.js.map +1 -0
- package/dist/adapter-send-proxy.d.ts +18 -0
- package/dist/adapter-send-proxy.d.ts.map +1 -0
- package/dist/adapter-send-proxy.js +229 -0
- package/dist/adapter-send-proxy.js.map +1 -0
- package/dist/adapter-send-tools-main.js +62 -4
- package/dist/adapter-send-tools-main.js.map +1 -1
- package/dist/adapter-send-tools.d.ts +33 -6
- package/dist/adapter-send-tools.d.ts.map +1 -1
- package/dist/adapter-send-tools.js +485 -87
- package/dist/adapter-send-tools.js.map +1 -1
- package/dist/app-config.d.ts +3 -1
- package/dist/app-config.d.ts.map +1 -1
- package/dist/app-config.js +16 -5
- package/dist/app-config.js.map +1 -1
- package/dist/app.d.ts +27 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +761 -147
- package/dist/app.js.map +1 -1
- package/dist/background-environment.d.ts +16 -0
- package/dist/background-environment.d.ts.map +1 -0
- package/dist/background-environment.js +68 -0
- package/dist/background-environment.js.map +1 -0
- package/dist/background-runtime.d.ts +62 -0
- package/dist/background-runtime.d.ts.map +1 -0
- package/dist/background-runtime.js +1115 -0
- package/dist/background-runtime.js.map +1 -0
- package/dist/background-snapshot-key.d.ts +13 -0
- package/dist/background-snapshot-key.d.ts.map +1 -0
- package/dist/background-snapshot-key.js +194 -0
- package/dist/background-snapshot-key.js.map +1 -0
- package/dist/background-snapshot.d.ts +96 -0
- package/dist/background-snapshot.d.ts.map +1 -0
- package/dist/background-snapshot.js +450 -0
- package/dist/background-snapshot.js.map +1 -0
- package/dist/background-worker-lease.d.ts +39 -0
- package/dist/background-worker-lease.d.ts.map +1 -0
- package/dist/background-worker-lease.js +356 -0
- package/dist/background-worker-lease.js.map +1 -0
- package/dist/background.d.ts +74 -2
- package/dist/background.d.ts.map +1 -1
- package/dist/background.js +815 -73
- package/dist/background.js.map +1 -1
- package/dist/broadcast-recorder.d.ts.map +1 -1
- package/dist/broadcast-recorder.js +24 -2
- package/dist/broadcast-recorder.js.map +1 -1
- package/dist/channel-plugins.d.ts +2 -0
- package/dist/channel-plugins.d.ts.map +1 -1
- package/dist/channel-plugins.js +8 -0
- package/dist/channel-plugins.js.map +1 -1
- package/dist/channels.d.ts +10 -0
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js +87 -9
- package/dist/channels.js.map +1 -1
- package/dist/cli.d.ts +86 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2421 -143
- package/dist/cli.js.map +1 -1
- package/dist/config-reference.d.ts.map +1 -1
- package/dist/config-reference.js +448 -6
- package/dist/config-reference.js.map +1 -1
- package/dist/configuration-proposal-main.d.ts +3 -0
- package/dist/configuration-proposal-main.d.ts.map +1 -0
- package/dist/configuration-proposal-main.js +13 -0
- package/dist/configuration-proposal-main.js.map +1 -0
- package/dist/configuration-proposal-tool.d.ts +33 -0
- package/dist/configuration-proposal-tool.d.ts.map +1 -0
- package/dist/configuration-proposal-tool.js +188 -0
- package/dist/configuration-proposal-tool.js.map +1 -0
- package/dist/configured-agent.d.ts +16 -0
- package/dist/configured-agent.d.ts.map +1 -1
- package/dist/configured-agent.js +165 -18
- package/dist/configured-agent.js.map +1 -1
- package/dist/consumer-contract.d.ts +3 -0
- package/dist/consumer-contract.d.ts.map +1 -1
- package/dist/consumer-contract.js +44 -1
- package/dist/consumer-contract.js.map +1 -1
- package/dist/continuation-command.d.ts +15 -0
- package/dist/continuation-command.d.ts.map +1 -0
- package/dist/continuation-command.js +170 -0
- package/dist/continuation-command.js.map +1 -0
- package/dist/continuation-config.d.ts +25 -0
- package/dist/continuation-config.d.ts.map +1 -0
- package/dist/continuation-config.js +236 -0
- package/dist/continuation-config.js.map +1 -0
- package/dist/continuation-service.d.ts +99 -0
- package/dist/continuation-service.d.ts.map +1 -0
- package/dist/continuation-service.js +1313 -0
- package/dist/continuation-service.js.map +1 -0
- package/dist/continuation-store.d.ts +104 -0
- package/dist/continuation-store.d.ts.map +1 -0
- package/dist/continuation-store.js +688 -0
- package/dist/continuation-store.js.map +1 -0
- package/dist/continuations.d.ts +167 -0
- package/dist/continuations.d.ts.map +1 -0
- package/dist/continuations.js +71 -0
- package/dist/continuations.js.map +1 -0
- package/dist/doctor.d.ts +29 -5
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +1611 -116
- package/dist/doctor.js.map +1 -1
- package/dist/first-run-managed-memory.d.ts +39 -0
- package/dist/first-run-managed-memory.d.ts.map +1 -0
- package/dist/first-run-managed-memory.js +584 -0
- package/dist/first-run-managed-memory.js.map +1 -0
- package/dist/first-run-readiness.d.ts +111 -0
- package/dist/first-run-readiness.d.ts.map +1 -0
- package/dist/first-run-readiness.js +728 -0
- package/dist/first-run-readiness.js.map +1 -0
- package/dist/index.d.ts +17 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +95 -3
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +1218 -24
- package/dist/init.js.map +1 -1
- package/dist/interaction-bridge.d.ts +25 -1
- package/dist/interaction-bridge.d.ts.map +1 -1
- package/dist/interaction-bridge.js +281 -19
- package/dist/interaction-bridge.js.map +1 -1
- package/dist/launchd.d.ts +16 -6
- package/dist/launchd.d.ts.map +1 -1
- package/dist/launchd.js +30 -15
- package/dist/launchd.js.map +1 -1
- package/dist/local-configuration.d.ts +99 -0
- package/dist/local-configuration.d.ts.map +1 -0
- package/dist/local-configuration.js +1299 -0
- package/dist/local-configuration.js.map +1 -0
- package/dist/managed-runtime-packages.d.ts +9 -0
- package/dist/managed-runtime-packages.d.ts.map +1 -0
- package/dist/managed-runtime-packages.js +56 -0
- package/dist/managed-runtime-packages.js.map +1 -0
- package/dist/memory-command.d.ts +4 -0
- package/dist/memory-command.d.ts.map +1 -1
- package/dist/memory-command.js +751 -27
- package/dist/memory-command.js.map +1 -1
- package/dist/memory-embedding-service.d.ts +33 -0
- package/dist/memory-embedding-service.d.ts.map +1 -0
- package/dist/memory-embedding-service.js +207 -0
- package/dist/memory-embedding-service.js.map +1 -0
- package/dist/memory-recall.d.ts +43 -14
- package/dist/memory-recall.d.ts.map +1 -1
- package/dist/memory-recall.js +103 -33
- package/dist/memory-recall.js.map +1 -1
- package/dist/memory-retrieval.d.ts +66 -0
- package/dist/memory-retrieval.d.ts.map +1 -0
- package/dist/memory-retrieval.js +332 -0
- package/dist/memory-retrieval.js.map +1 -0
- package/dist/modules/base.d.ts +6 -5
- package/dist/modules/base.d.ts.map +1 -1
- package/dist/modules/base.js +11 -7
- package/dist/modules/base.js.map +1 -1
- package/dist/modules/catalog.d.ts.map +1 -1
- package/dist/modules/catalog.js +141 -25
- package/dist/modules/catalog.js.map +1 -1
- package/dist/modules/index.d.ts +2 -2
- package/dist/modules/index.d.ts.map +1 -1
- package/dist/modules/index.js +1 -1
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/known-tools.d.ts +3 -0
- package/dist/modules/known-tools.d.ts.map +1 -1
- package/dist/modules/known-tools.js +11 -1
- package/dist/modules/known-tools.js.map +1 -1
- package/dist/modules/types.d.ts +20 -6
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/types.js.map +1 -1
- package/dist/notify-runtime.d.ts +26 -0
- package/dist/notify-runtime.d.ts.map +1 -0
- package/dist/notify-runtime.js +27 -0
- package/dist/notify-runtime.js.map +1 -0
- package/dist/notify-tool.d.ts +51 -0
- package/dist/notify-tool.d.ts.map +1 -0
- package/dist/notify-tool.js +182 -0
- package/dist/notify-tool.js.map +1 -0
- package/dist/package-version.d.ts +3 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +14 -0
- package/dist/package-version.js.map +1 -0
- package/dist/pi-auth-store-inspection.d.ts +21 -0
- package/dist/pi-auth-store-inspection.d.ts.map +1 -0
- package/dist/pi-auth-store-inspection.js +120 -0
- package/dist/pi-auth-store-inspection.js.map +1 -0
- package/dist/pi-oauth-login-main.d.ts +3 -0
- package/dist/pi-oauth-login-main.d.ts.map +1 -0
- package/dist/pi-oauth-login-main.js +14 -0
- package/dist/pi-oauth-login-main.js.map +1 -0
- package/dist/pi-oauth-login.d.ts +22 -0
- package/dist/pi-oauth-login.d.ts.map +1 -0
- package/dist/pi-oauth-login.js +79 -0
- package/dist/pi-oauth-login.js.map +1 -0
- package/dist/proactive-notify.d.ts +2 -0
- package/dist/proactive-notify.d.ts.map +1 -1
- package/dist/proactive-notify.js +1 -0
- package/dist/proactive-notify.js.map +1 -1
- package/dist/process-incarnation.d.ts +23 -0
- package/dist/process-incarnation.d.ts.map +1 -0
- package/dist/process-incarnation.js +208 -0
- package/dist/process-incarnation.js.map +1 -0
- package/dist/project-skills.d.ts +40 -0
- package/dist/project-skills.d.ts.map +1 -0
- package/dist/project-skills.js +573 -0
- package/dist/project-skills.js.map +1 -0
- package/dist/provider-setup.d.ts +117 -2
- package/dist/provider-setup.d.ts.map +1 -1
- package/dist/provider-setup.js +1505 -49
- package/dist/provider-setup.js.map +1 -1
- package/dist/readiness-probe-worker.d.ts +12 -0
- package/dist/readiness-probe-worker.d.ts.map +1 -0
- package/dist/readiness-probe-worker.js +276 -0
- package/dist/readiness-probe-worker.js.map +1 -0
- package/dist/readiness-probe.d.ts +100 -0
- package/dist/readiness-probe.d.ts.map +1 -0
- package/dist/readiness-probe.js +780 -0
- package/dist/readiness-probe.js.map +1 -0
- package/dist/recipes/base.d.ts +15 -0
- package/dist/recipes/base.d.ts.map +1 -0
- package/dist/recipes/base.js +51 -0
- package/dist/recipes/base.js.map +1 -0
- package/dist/recipes/catalog.d.ts +4 -0
- package/dist/recipes/catalog.d.ts.map +1 -0
- package/dist/recipes/catalog.js +525 -0
- package/dist/recipes/catalog.js.map +1 -0
- package/dist/recipes/index.d.ts +11 -0
- package/dist/recipes/index.d.ts.map +1 -0
- package/dist/recipes/index.js +14 -0
- package/dist/recipes/index.js.map +1 -0
- package/dist/recipes/types.d.ts +70 -0
- package/dist/recipes/types.d.ts.map +1 -0
- package/dist/recipes/types.js +15 -0
- package/dist/recipes/types.js.map +1 -0
- package/dist/request-model-override.d.ts +43 -1
- package/dist/request-model-override.d.ts.map +1 -1
- package/dist/request-model-override.js +178 -19
- package/dist/request-model-override.js.map +1 -1
- package/dist/run-history.d.ts +32 -0
- package/dist/run-history.d.ts.map +1 -0
- package/dist/run-history.js +859 -0
- package/dist/run-history.js.map +1 -0
- package/dist/runs-health.d.ts.map +1 -1
- package/dist/runs-health.js +12 -4
- package/dist/runs-health.js.map +1 -1
- package/dist/runtime-option-extensions.d.ts +14 -0
- package/dist/runtime-option-extensions.d.ts.map +1 -0
- package/dist/runtime-option-extensions.js +98 -0
- package/dist/runtime-option-extensions.js.map +1 -0
- package/dist/runtime-routes.d.ts +9 -0
- package/dist/runtime-routes.d.ts.map +1 -0
- package/dist/runtime-routes.js +13 -0
- package/dist/runtime-routes.js.map +1 -0
- package/dist/sandbox-manager.d.ts +86 -0
- package/dist/sandbox-manager.d.ts.map +1 -0
- package/dist/sandbox-manager.js +1402 -0
- package/dist/sandbox-manager.js.map +1 -0
- package/dist/setup.d.ts +29 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +97 -0
- package/dist/setup.js.map +1 -0
- package/dist/supermemory-plugin.d.ts +56 -0
- package/dist/supermemory-plugin.d.ts.map +1 -0
- package/dist/supermemory-plugin.js +142 -0
- package/dist/supermemory-plugin.js.map +1 -0
- package/dist/tui-command.d.ts +56 -0
- package/dist/tui-command.d.ts.map +1 -1
- package/dist/tui-command.js +305 -31
- package/dist/tui-command.js.map +1 -1
- package/dist/web-command.d.ts +8 -0
- package/dist/web-command.d.ts.map +1 -1
- package/dist/web-command.js +174 -17
- package/dist/web-command.js.map +1 -1
- package/dist/wizard/answers.d.ts +31 -4
- package/dist/wizard/answers.d.ts.map +1 -1
- package/dist/wizard/answers.js +141 -29
- package/dist/wizard/answers.js.map +1 -1
- package/dist/wizard/from-flags.d.ts +7 -0
- package/dist/wizard/from-flags.d.ts.map +1 -1
- package/dist/wizard/from-flags.js +36 -2
- package/dist/wizard/from-flags.js.map +1 -1
- package/dist/wizard/index.d.ts +4 -4
- package/dist/wizard/index.d.ts.map +1 -1
- package/dist/wizard/index.js +2 -2
- package/dist/wizard/index.js.map +1 -1
- package/dist/wizard/model-discovery.d.ts +33 -2
- package/dist/wizard/model-discovery.d.ts.map +1 -1
- package/dist/wizard/model-discovery.js +826 -108
- package/dist/wizard/model-discovery.js.map +1 -1
- package/dist/wizard/presets.d.ts +1 -1
- package/dist/wizard/presets.d.ts.map +1 -1
- package/dist/wizard/presets.js +7 -12
- package/dist/wizard/presets.js.map +1 -1
- package/dist/wizard/prompts.d.ts +56 -9
- package/dist/wizard/prompts.d.ts.map +1 -1
- package/dist/wizard/prompts.js +172 -20
- package/dist/wizard/prompts.js.map +1 -1
- package/dist/wizard/run.d.ts +59 -3
- package/dist/wizard/run.d.ts.map +1 -1
- package/dist/wizard/run.js +1290 -191
- package/dist/wizard/run.js.map +1 -1
- package/package.json +21 -16
- package/resources/srt/package-lock.json +66 -0
- package/resources/srt/package.json +9 -0
- package/schema/mono-agent.config.schema.json +587 -20
- package/skills/mono-agent-composer/SKILL.md +6 -6
- package/skills/mono-agent-composer/references/config-blueprint.md +11 -10
- package/skills/mono-agent-composer/references/discovery-questions.md +33 -18
- package/skills/mono-agent-composer/references/feature-coverage.md +14 -12
- package/skills/mono-agent-composer/references/package-map.md +2 -2
- package/skills/mono-agent-composer/references/playbooks.md +8 -7
- package/skills/mono-agent-composer/references/validation.md +3 -3
package/dist/memory-command.js
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
|
-
import { readdir, readFile, stat } from "node:fs/promises";
|
|
1
|
+
import { readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
2
2
|
import { basename, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
3
|
import { resolveSupermemoryContainer } from "@mono-agent/config";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { isAppCoreConfigError, loadAppCoreConfig } from "./app-config.js";
|
|
7
|
-
import { createRecallStore, resolveMemoryRecallSettings, } from "./memory-recall.js";
|
|
4
|
+
import { listTraceSources } from "@mono-agent/observability";
|
|
5
|
+
import { isAppCoreConfigError, loadAppCoreConfig, resolveAppTraceRegistryDir, resolveGlobalTraceRegistryDir, } from "./app-config.js";
|
|
8
6
|
import * as ui from "./ui.js";
|
|
9
7
|
const DEFAULT_SEARCH_LIMIT = 8;
|
|
10
8
|
const DEFAULT_TOP_LIMIT = 10;
|
|
11
9
|
const DEFAULT_ENTITY_LIMIT = 8;
|
|
12
10
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/u;
|
|
11
|
+
const INTAKE_ID_RE = /^[a-f0-9]{64}$/u;
|
|
12
|
+
const INTAKE_REASON_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/u;
|
|
13
|
+
const MEMORY_HEALTH_SCHEMA_VERSION = 1;
|
|
14
|
+
const REPLAY_ADOPTION_SCHEMA_VERSION = 1;
|
|
15
|
+
const EMPTY_HEALTH_COUNTS = Object.freeze({
|
|
16
|
+
pending: 0,
|
|
17
|
+
due: 0,
|
|
18
|
+
dead: 0,
|
|
19
|
+
outbox: 0,
|
|
20
|
+
temporary: 0,
|
|
21
|
+
memories: 0,
|
|
22
|
+
vectors: 0,
|
|
23
|
+
missingVectors: 0,
|
|
24
|
+
});
|
|
13
25
|
export async function runMemoryCommand(input) {
|
|
26
|
+
const usageError = memoryCommandUsageError(input);
|
|
27
|
+
if (usageError !== undefined) {
|
|
28
|
+
if (input.positionals[0] === "adopt-replay") {
|
|
29
|
+
writeReplayAdoptionCliFailure(input.json, "replay_adoption_usage");
|
|
30
|
+
return 2;
|
|
31
|
+
}
|
|
32
|
+
process.stderr.write(ui.errorLine(usageError));
|
|
33
|
+
return 2;
|
|
34
|
+
}
|
|
14
35
|
const context = await loadMemoryCommandContext(input);
|
|
15
36
|
if ("code" in context) {
|
|
16
37
|
return context.code;
|
|
@@ -18,6 +39,15 @@ export async function runMemoryCommand(input) {
|
|
|
18
39
|
const [rawSubcommand, ...rest] = input.positionals;
|
|
19
40
|
const subcommand = rawSubcommand ?? "stats";
|
|
20
41
|
if (context.config.memory === undefined) {
|
|
42
|
+
if (subcommand === "audit" && input.strict) {
|
|
43
|
+
const result = notConfiguredHealthReport();
|
|
44
|
+
write(input.json, result, () => renderStrictAudit(result));
|
|
45
|
+
return strictHealthExitCode(result.status);
|
|
46
|
+
}
|
|
47
|
+
if (subcommand === "adopt-replay") {
|
|
48
|
+
writeReplayAdoptionCliFailure(input.json, "replay_adoption_requires_bujo");
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
21
51
|
writeNoMemory(context.configPath, input.json);
|
|
22
52
|
return 0;
|
|
23
53
|
}
|
|
@@ -44,23 +74,503 @@ export async function runMemoryCommand(input) {
|
|
|
44
74
|
}
|
|
45
75
|
case "top":
|
|
46
76
|
return await runTop(context, input);
|
|
77
|
+
case "audit":
|
|
78
|
+
return input.strict
|
|
79
|
+
? await runStrictAudit(context, input.json)
|
|
80
|
+
: await runAudit(context, input.json);
|
|
81
|
+
case "inspect":
|
|
82
|
+
return await runIntakeInspect(context, rest[0], input.json);
|
|
83
|
+
case "retry":
|
|
84
|
+
return await runIntakeMutation(context, "retry", rest[0], undefined, input.json);
|
|
85
|
+
case "resolve":
|
|
86
|
+
return await runIntakeMutation(context, "resolve", rest[0], rest[1], input.json);
|
|
87
|
+
case "rebuild":
|
|
88
|
+
return await runIndexTransition(context, "rebuild", input.json);
|
|
89
|
+
case "rollback":
|
|
90
|
+
return await runIndexTransition(context, "rollback", input.json);
|
|
91
|
+
case "adopt-replay":
|
|
92
|
+
return await runReplayAdoption(context, input.json);
|
|
47
93
|
default:
|
|
48
94
|
process.stderr.write(ui.errorLine(`Unknown memory subcommand \`${subcommand}\`.`));
|
|
49
|
-
process.stderr.write(ui.hint("Expected stats, today, show <date>, search <query>, or
|
|
95
|
+
process.stderr.write(ui.hint("Expected stats, today, show <date>, search <query>, top, audit, inspect [id], retry [id], resolve <id> <reason>, rebuild, rollback, or adopt-replay."));
|
|
50
96
|
return 2;
|
|
51
97
|
}
|
|
52
98
|
}
|
|
99
|
+
function memoryCommandUsageError(input) {
|
|
100
|
+
const [rawSubcommand, ...rest] = input.positionals;
|
|
101
|
+
const subcommand = rawSubcommand ?? "stats";
|
|
102
|
+
if (input.strict && subcommand !== "audit") {
|
|
103
|
+
return "--strict is only supported for `mono-agent memory audit`.";
|
|
104
|
+
}
|
|
105
|
+
if (input.limit !== undefined && subcommand !== "stats" && subcommand !== "search" && subcommand !== "top") {
|
|
106
|
+
return "--limit is only supported for memory stats, search, and top.";
|
|
107
|
+
}
|
|
108
|
+
switch (subcommand) {
|
|
109
|
+
case "stats":
|
|
110
|
+
case "today":
|
|
111
|
+
case "top":
|
|
112
|
+
case "audit":
|
|
113
|
+
case "rebuild":
|
|
114
|
+
case "rollback":
|
|
115
|
+
case "adopt-replay":
|
|
116
|
+
return rest.length === 0 ? undefined : `Usage: mono-agent memory ${subcommand}.`;
|
|
117
|
+
case "show":
|
|
118
|
+
return rest.length === 1 && DATE_RE.test(rest[0] ?? "")
|
|
119
|
+
? undefined
|
|
120
|
+
: "Usage: mono-agent memory show <YYYY-MM-DD>.";
|
|
121
|
+
case "search":
|
|
122
|
+
return rest.join(" ").trim().length > 0
|
|
123
|
+
? undefined
|
|
124
|
+
: "Usage: mono-agent memory search <query>.";
|
|
125
|
+
case "inspect":
|
|
126
|
+
return rest.length <= 1 && (rest[0] === undefined || INTAKE_ID_RE.test(rest[0]))
|
|
127
|
+
? undefined
|
|
128
|
+
: "Usage: mono-agent memory inspect [<64-character-id>].";
|
|
129
|
+
case "retry":
|
|
130
|
+
return rest.length <= 1 && (rest[0] === undefined || INTAKE_ID_RE.test(rest[0]))
|
|
131
|
+
? undefined
|
|
132
|
+
: "Usage: mono-agent memory retry [<64-character-id>].";
|
|
133
|
+
case "resolve":
|
|
134
|
+
if (rest.length !== 2 || !INTAKE_ID_RE.test(rest[0] ?? "")) {
|
|
135
|
+
return "Usage: mono-agent memory resolve <64-character-id> <reason-slug>.";
|
|
136
|
+
}
|
|
137
|
+
return INTAKE_REASON_RE.test(rest[1] ?? "")
|
|
138
|
+
? undefined
|
|
139
|
+
: "memory resolve reason must be a 1-64 character lowercase slug.";
|
|
140
|
+
default:
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function runReplayAdoption(context, json) {
|
|
145
|
+
const memory = context.config.memory;
|
|
146
|
+
if (memory === undefined || (memory.backend ?? "bujo") === "supermemory"
|
|
147
|
+
|| memory.mode !== "bujo" || memory.embeddings === undefined) {
|
|
148
|
+
writeReplayAdoptionCliFailure(json, "replay_adoption_requires_bujo");
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const registryDirs = await memoryRegistryDirs(context);
|
|
153
|
+
if (await hasLiveConfiguredAgent(context.configPath, registryDirs)) {
|
|
154
|
+
writeReplayAdoptionCliFailure(json, "replay_adoption_agent_running");
|
|
155
|
+
return 1;
|
|
156
|
+
}
|
|
157
|
+
const { adoptLegacyReplayProjection } = await loadBujoModule();
|
|
158
|
+
// Re-check after the lazy module load so a configured process cannot race
|
|
159
|
+
// the SSH-only stopped-store precondition during setup. The package also
|
|
160
|
+
// takes the memory-root writer lease and SQLite writer fence.
|
|
161
|
+
if (await hasLiveConfiguredAgent(context.configPath, registryDirs)) {
|
|
162
|
+
writeReplayAdoptionCliFailure(json, "replay_adoption_agent_running");
|
|
163
|
+
return 1;
|
|
164
|
+
}
|
|
165
|
+
const adopted = await adoptLegacyReplayProjection({
|
|
166
|
+
root: memory.path,
|
|
167
|
+
mode: "bujo",
|
|
168
|
+
embeddingModel: `${memory.embeddings.provider}:${memory.embeddings.model}`,
|
|
169
|
+
dimension: memory.embeddings.dim ?? 768,
|
|
170
|
+
});
|
|
171
|
+
const result = publicReplayAdoptionResult(adopted);
|
|
172
|
+
write(json, result, () => renderReplayAdoption(result));
|
|
173
|
+
return 0;
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
// Adoption is a privacy boundary. Do not classify or interpolate the
|
|
177
|
+
// package/native error: it may contain paths, record ids, marker bytes, or
|
|
178
|
+
// model-owned text. Operators get a stable remediation contract instead.
|
|
179
|
+
writeReplayAdoptionCliFailure(json, "replay_adoption_failed");
|
|
180
|
+
return 1;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const REPLAY_ADOPTION_FAILURE_MESSAGES = Object.freeze({
|
|
184
|
+
replay_adoption_usage: "Usage: mono-agent memory adopt-replay [--json] [--config <path>] [--env-file <path>].",
|
|
185
|
+
replay_adoption_config_invalid: "Replay adoption requires a valid mono-agent configuration.",
|
|
186
|
+
replay_adoption_requires_bujo: "Replay adoption requires a configured built-in BuJo memory store with embeddings.",
|
|
187
|
+
replay_adoption_agent_running: "Replay adoption requires the configured agent to be stopped. Stop it and retry.",
|
|
188
|
+
replay_adoption_failed: "Replay adoption failed. Keep the agent stopped, inspect strict memory health, resolve the reported condition, and retry.",
|
|
189
|
+
});
|
|
190
|
+
export function writeReplayAdoptionCliFailure(json, code) {
|
|
191
|
+
const result = {
|
|
192
|
+
schemaVersion: REPLAY_ADOPTION_SCHEMA_VERSION,
|
|
193
|
+
operation: "adopt-replay",
|
|
194
|
+
status: "failed",
|
|
195
|
+
code,
|
|
196
|
+
message: REPLAY_ADOPTION_FAILURE_MESSAGES[code],
|
|
197
|
+
};
|
|
198
|
+
if (json) {
|
|
199
|
+
write(true, result, () => "");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
process.stderr.write(ui.errorLine(`[${result.code}] ${result.message}`));
|
|
203
|
+
}
|
|
204
|
+
function publicReplayAdoptionResult(result) {
|
|
205
|
+
const counts = result.counts;
|
|
206
|
+
if (result.backend !== "bujo" || result.mode !== "bujo" || result.status !== "adopted"
|
|
207
|
+
|| result.rebuildRequired !== true || !/^[a-f0-9]{64}$/u.test(result.authorityDigest)
|
|
208
|
+
|| !isSafeAggregateCount(counts.terminals)
|
|
209
|
+
|| !isSafeAggregateCount(counts.supersedes)
|
|
210
|
+
|| !isSafeAggregateCount(counts.threads)) {
|
|
211
|
+
throw new Error("invalid private adoption result");
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
backend: "bujo",
|
|
215
|
+
mode: "bujo",
|
|
216
|
+
status: "adopted",
|
|
217
|
+
counts: {
|
|
218
|
+
terminals: counts.terminals,
|
|
219
|
+
supersedes: counts.supersedes,
|
|
220
|
+
threads: counts.threads,
|
|
221
|
+
},
|
|
222
|
+
authorityDigest: result.authorityDigest,
|
|
223
|
+
rebuildRequired: true,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function isSafeAggregateCount(value) {
|
|
227
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
228
|
+
}
|
|
229
|
+
function notConfiguredHealthReport(now = new Date()) {
|
|
230
|
+
return {
|
|
231
|
+
schemaVersion: MEMORY_HEALTH_SCHEMA_VERSION,
|
|
232
|
+
backend: "none",
|
|
233
|
+
status: "not_configured",
|
|
234
|
+
checkedAt: now.toISOString(),
|
|
235
|
+
issues: [],
|
|
236
|
+
counts: EMPTY_HEALTH_COUNTS,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
async function runStrictAudit(context, json) {
|
|
240
|
+
const memory = context.config.memory;
|
|
241
|
+
if (memory === undefined) {
|
|
242
|
+
const result = notConfiguredHealthReport();
|
|
243
|
+
write(json, result, () => renderStrictAudit(result));
|
|
244
|
+
return 0;
|
|
245
|
+
}
|
|
246
|
+
if ((memory.backend ?? "bujo") === "supermemory") {
|
|
247
|
+
const result = {
|
|
248
|
+
schemaVersion: MEMORY_HEALTH_SCHEMA_VERSION,
|
|
249
|
+
backend: "supermemory",
|
|
250
|
+
status: "unknown",
|
|
251
|
+
checkedAt: new Date().toISOString(),
|
|
252
|
+
issues: [],
|
|
253
|
+
counts: EMPTY_HEALTH_COUNTS,
|
|
254
|
+
};
|
|
255
|
+
write(json, result, () => renderStrictAudit(result));
|
|
256
|
+
return 1;
|
|
257
|
+
}
|
|
258
|
+
let result;
|
|
259
|
+
try {
|
|
260
|
+
const { auditBujoMemoryHealth } = await loadBujoModule();
|
|
261
|
+
result = auditBujoMemoryHealth({
|
|
262
|
+
root: memory.path,
|
|
263
|
+
mode: memory.mode,
|
|
264
|
+
...(memory.embeddings === undefined
|
|
265
|
+
? {}
|
|
266
|
+
: {
|
|
267
|
+
configuredEmbeddingModel: `${memory.embeddings.provider}:${memory.embeddings.model}`,
|
|
268
|
+
configuredDimension: memory.embeddings.dim ?? 768,
|
|
269
|
+
}),
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
result = {
|
|
274
|
+
schemaVersion: MEMORY_HEALTH_SCHEMA_VERSION,
|
|
275
|
+
backend: "bujo",
|
|
276
|
+
mode: memory.mode,
|
|
277
|
+
status: "unknown",
|
|
278
|
+
checkedAt: new Date().toISOString(),
|
|
279
|
+
issues: isNativeModuleFailure(error) ? ["native_module_unavailable"] : ["health_check_failed"],
|
|
280
|
+
counts: EMPTY_HEALTH_COUNTS,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
write(json, result, () => renderStrictAudit(result));
|
|
284
|
+
return strictHealthExitCode(result.status);
|
|
285
|
+
}
|
|
286
|
+
function strictHealthExitCode(status) {
|
|
287
|
+
switch (status) {
|
|
288
|
+
case "healthy":
|
|
289
|
+
case "in_progress":
|
|
290
|
+
case "not_configured":
|
|
291
|
+
return 0;
|
|
292
|
+
case "degraded":
|
|
293
|
+
case "unhealthy":
|
|
294
|
+
case "unknown":
|
|
295
|
+
return 1;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async function runIntakeInspect(context, id, json) {
|
|
299
|
+
const memory = context.config.memory;
|
|
300
|
+
if (memory === undefined) {
|
|
301
|
+
writeNoMemory(context.configPath, json);
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
if ((memory.backend ?? "bujo") === "supermemory") {
|
|
305
|
+
process.stderr.write(ui.errorLine("memory inspect is available only for the built-in memory intake."));
|
|
306
|
+
return 1;
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
const { inspectCompletedTurnIntake } = await loadBujoModule();
|
|
310
|
+
const inspection = inspectCompletedTurnIntake(memory.path);
|
|
311
|
+
const result = intakeInspectionResult(inspection, id);
|
|
312
|
+
write(json, result, () => renderIntakeInspection(result));
|
|
313
|
+
return 0;
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
process.stderr.write(ui.errorLine("memory inspect failed; the intake metadata is unavailable or invalid."));
|
|
317
|
+
return 1;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async function runIntakeMutation(context, operation, id, reason, json) {
|
|
321
|
+
const memory = context.config.memory;
|
|
322
|
+
if (memory === undefined) {
|
|
323
|
+
writeNoMemory(context.configPath, json);
|
|
324
|
+
return 0;
|
|
325
|
+
}
|
|
326
|
+
if ((memory.backend ?? "bujo") === "supermemory") {
|
|
327
|
+
process.stderr.write(ui.errorLine(`memory ${operation} is available only for the built-in memory intake.`));
|
|
328
|
+
return 1;
|
|
329
|
+
}
|
|
330
|
+
try {
|
|
331
|
+
await assertNoLiveConfiguredAgent(context.configPath, await memoryRegistryDirs(context));
|
|
332
|
+
const bujo = await loadBujoModule();
|
|
333
|
+
if (operation === "retry") {
|
|
334
|
+
const mutation = bujo.retryCompletedTurnIntake(memory.path, id === undefined ? {} : { id });
|
|
335
|
+
const result = {
|
|
336
|
+
schemaVersion: MEMORY_HEALTH_SCHEMA_VERSION,
|
|
337
|
+
operation,
|
|
338
|
+
changed: mutation.retried > 0,
|
|
339
|
+
retried: mutation.retried,
|
|
340
|
+
};
|
|
341
|
+
write(json, result, () => renderIntakeMutation(result));
|
|
342
|
+
return 0;
|
|
343
|
+
}
|
|
344
|
+
const mutation = bujo.resolveCompletedTurnIntake(memory.path, id, reason);
|
|
345
|
+
const result = {
|
|
346
|
+
schemaVersion: MEMORY_HEALTH_SCHEMA_VERSION,
|
|
347
|
+
operation,
|
|
348
|
+
changed: mutation.resolved,
|
|
349
|
+
resolved: mutation.resolved,
|
|
350
|
+
};
|
|
351
|
+
write(json, result, () => renderIntakeMutation(result));
|
|
352
|
+
return 0;
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
const retainedPlan = /retained semantic-plan recovery/iu.test(reasonOf(error));
|
|
356
|
+
process.stderr.write(ui.errorLine(retainedPlan
|
|
357
|
+
? "memory resolve refused: retained semantic-plan recovery must complete first."
|
|
358
|
+
: `memory ${operation} failed: ${reasonOf(error)}`));
|
|
359
|
+
return 1;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function intakeInspectionResult(inspection, id) {
|
|
363
|
+
const items = id === undefined ? inspection.items : inspection.items.filter((item) => item.id === id);
|
|
364
|
+
return {
|
|
365
|
+
schemaVersion: inspection.schemaVersion,
|
|
366
|
+
operation: "inspect",
|
|
367
|
+
matched: items.length,
|
|
368
|
+
temporary: inspection.temporary,
|
|
369
|
+
snapshot: inspection.snapshot,
|
|
370
|
+
items,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
async function memoryRegistryDirs(context) {
|
|
374
|
+
return await dedupeRegistryDirs([
|
|
375
|
+
await resolveAppTraceRegistryDir({
|
|
376
|
+
env: context.env,
|
|
377
|
+
cwd: context.cwd,
|
|
378
|
+
configPath: context.configPath,
|
|
379
|
+
}),
|
|
380
|
+
resolveGlobalTraceRegistryDir(context.env),
|
|
381
|
+
]);
|
|
382
|
+
}
|
|
383
|
+
async function runIndexTransition(context, operation, json) {
|
|
384
|
+
const memory = context.config.memory;
|
|
385
|
+
if (memory === undefined) {
|
|
386
|
+
writeNoMemory(context.configPath, json);
|
|
387
|
+
return 0;
|
|
388
|
+
}
|
|
389
|
+
if ((memory.backend ?? "bujo") === "supermemory") {
|
|
390
|
+
process.stderr.write(ui.errorLine(`mono-agent memory ${operation} is available only for the built-in Lite, Journal, and BuJo stores; Supermemory manages its remote index.`));
|
|
391
|
+
return 1;
|
|
392
|
+
}
|
|
393
|
+
const settings = previewRecallSettings(context.config);
|
|
394
|
+
if (settings === undefined || "supermemory" in settings) {
|
|
395
|
+
process.stderr.write(ui.errorLine(`Unable to resolve the configured built-in memory store for ${operation}.`));
|
|
396
|
+
return 1;
|
|
397
|
+
}
|
|
398
|
+
try {
|
|
399
|
+
const registryDirs = await memoryRegistryDirs(context);
|
|
400
|
+
await assertNoLiveConfiguredAgent(context.configPath, registryDirs);
|
|
401
|
+
const { resolveActiveMemoryDbPath, rollbackMemoryIndex, safeRebuildMemoryIndex, } = await loadBujoModule();
|
|
402
|
+
const { createMemoryEmbeddingProvider } = await loadMemoryRecallModule();
|
|
403
|
+
const embeddings = settings.embeddings === undefined
|
|
404
|
+
? undefined
|
|
405
|
+
: await createMemoryEmbeddingProvider(settings.embeddings);
|
|
406
|
+
const options = {
|
|
407
|
+
root: memory.path,
|
|
408
|
+
tier: memory.mode,
|
|
409
|
+
...(embeddings === undefined ? {} : { embeddings, dim: settings.embeddings?.dim ?? 768 }),
|
|
410
|
+
};
|
|
411
|
+
// Re-check after provider construction so a legacy writer that started
|
|
412
|
+
// during setup cannot be raced by the destructive transition.
|
|
413
|
+
await assertNoLiveConfiguredAgent(context.configPath, registryDirs);
|
|
414
|
+
const details = operation === "rebuild"
|
|
415
|
+
? await safeRebuildMemoryIndex(options)
|
|
416
|
+
: await rollbackMemoryIndex(options);
|
|
417
|
+
const activeDatabase = await resolveActiveMemoryDbPath(memory.path);
|
|
418
|
+
const result = {
|
|
419
|
+
configured: true,
|
|
420
|
+
backend: "bujo",
|
|
421
|
+
operation,
|
|
422
|
+
activeDatabase,
|
|
423
|
+
details,
|
|
424
|
+
};
|
|
425
|
+
write(json, result, () => renderIndexTransition(result));
|
|
426
|
+
return 0;
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
process.stderr.write(ui.errorLine(`memory ${operation} failed: ${reasonOf(error)}`));
|
|
430
|
+
return 1;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
async function runAudit(context, json) {
|
|
434
|
+
const memory = context.config.memory;
|
|
435
|
+
if (memory === undefined) {
|
|
436
|
+
writeNoMemory(context.configPath, json);
|
|
437
|
+
return 0;
|
|
438
|
+
}
|
|
439
|
+
if ((memory.backend ?? "bujo") === "supermemory") {
|
|
440
|
+
const result = {
|
|
441
|
+
configured: true,
|
|
442
|
+
backend: "supermemory",
|
|
443
|
+
metadataOnly: true,
|
|
444
|
+
counts: null,
|
|
445
|
+
bytes: null,
|
|
446
|
+
duplicates: null,
|
|
447
|
+
vectorCoverage: null,
|
|
448
|
+
accessConcentration: null,
|
|
449
|
+
backlog: { known: false, captureQueue: null, vectorIndex: null },
|
|
450
|
+
latency: { known: false, searchP50Ms: null, searchP95Ms: null, indexingMs: null },
|
|
451
|
+
cost: { known: false, totalUsd: null, embeddingCalls: null, llmCalls: null, tokens: null },
|
|
452
|
+
notes: ["Remote backend health metadata is not exposed by the configured client."],
|
|
453
|
+
};
|
|
454
|
+
write(json, result, () => renderAudit(result));
|
|
455
|
+
return 0;
|
|
456
|
+
}
|
|
457
|
+
const root = memory.path;
|
|
458
|
+
const { readBujoRuntimeSnapshot, resolveActiveMemoryDbPath } = await loadBujoModule();
|
|
459
|
+
const { openMemoryDb } = await loadMemoryStoreModule();
|
|
460
|
+
const runtime = readBujoRuntimeSnapshot(root);
|
|
461
|
+
const dbPath = await resolveActiveMemoryDbPath(root);
|
|
462
|
+
const rootExists = await exists(root);
|
|
463
|
+
const size = rootExists ? await collectStoreSize(root) : emptySize();
|
|
464
|
+
let audit;
|
|
465
|
+
let generation;
|
|
466
|
+
let metadataQueryMs = null;
|
|
467
|
+
if (await exists(dbPath)) {
|
|
468
|
+
const db = openMemoryDb({ path: dbPath, readOnly: true });
|
|
469
|
+
try {
|
|
470
|
+
const started = performance.now();
|
|
471
|
+
audit = db.audit();
|
|
472
|
+
generation = db.indexMetadata();
|
|
473
|
+
metadataQueryMs = performance.now() - started;
|
|
474
|
+
}
|
|
475
|
+
finally {
|
|
476
|
+
db.close();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
const live = audit?.counts.live ?? 0;
|
|
480
|
+
const liveIndexed = audit?.vectors.liveIndexed ?? 0;
|
|
481
|
+
const semanticExpected = memory.embeddings !== undefined;
|
|
482
|
+
const runtimeQueues = runtime.snapshot?.queues;
|
|
483
|
+
const captureQueue = runtime.stale ? undefined : runtimeQueues?.capture;
|
|
484
|
+
const runtimeVectorBacklog = runtime.stale ? undefined : runtimeQueues?.index?.remainingBacklog;
|
|
485
|
+
const result = {
|
|
486
|
+
configured: true,
|
|
487
|
+
backend: "bujo",
|
|
488
|
+
mode: memory.mode,
|
|
489
|
+
...(generation === undefined ? {} : { generation }),
|
|
490
|
+
metadataOnly: true,
|
|
491
|
+
counts: audit?.counts ?? { total: 0, live: 0, entities: 0, entityRelations: 0 },
|
|
492
|
+
bytes: size,
|
|
493
|
+
duplicates: audit?.duplicates ?? { groups: 0, redundantRecords: 0, ratio: 0 },
|
|
494
|
+
vectorCoverage: audit?.vectors ?? { indexed: 0, liveIndexed: 0, liveCoverage: live === 0 ? 1 : 0 },
|
|
495
|
+
accessConcentration: audit?.access ?? { totalCount: 0, accessedMemories: 0, topOnePercentShare: 0 },
|
|
496
|
+
backlog: {
|
|
497
|
+
known: true,
|
|
498
|
+
captureQueue: captureQueue === undefined ? null : captureQueue.queued + captureQueue.inFlight,
|
|
499
|
+
vectorIndex: runtimeVectorBacklog ?? (semanticExpected ? Math.max(0, live - liveIndexed) : 0),
|
|
500
|
+
},
|
|
501
|
+
runtime: {
|
|
502
|
+
available: runtime.available,
|
|
503
|
+
stale: runtime.stale,
|
|
504
|
+
...(runtime.reason === undefined ? {} : { reason: runtime.reason }),
|
|
505
|
+
...(runtime.ageMs === undefined ? {} : { ageMs: runtime.ageMs }),
|
|
506
|
+
...(runtime.processAlive === undefined ? {} : { processAlive: runtime.processAlive }),
|
|
507
|
+
...(runtime.snapshot === undefined ? {} : {
|
|
508
|
+
pid: runtime.snapshot.pid,
|
|
509
|
+
tier: runtime.snapshot.tier,
|
|
510
|
+
state: runtime.snapshot.state,
|
|
511
|
+
startedAt: runtime.snapshot.startedAt,
|
|
512
|
+
updatedAt: runtime.snapshot.updatedAt,
|
|
513
|
+
queues: runtime.snapshot.queues,
|
|
514
|
+
}),
|
|
515
|
+
},
|
|
516
|
+
latency: {
|
|
517
|
+
known: metadataQueryMs !== null,
|
|
518
|
+
metadataQueryMs,
|
|
519
|
+
searchP50Ms: null,
|
|
520
|
+
searchP95Ms: null,
|
|
521
|
+
indexingMs: null,
|
|
522
|
+
},
|
|
523
|
+
cost: {
|
|
524
|
+
known: runtime.snapshot !== undefined,
|
|
525
|
+
totalUsd: null,
|
|
526
|
+
embeddingCalls: runtime.snapshot?.counters.embeddingCalls ?? null,
|
|
527
|
+
embeddingTexts: runtime.snapshot?.counters.embeddingTexts ?? null,
|
|
528
|
+
llmCalls: runtime.snapshot?.counters.llmCalls ?? null,
|
|
529
|
+
llmInputChars: runtime.snapshot?.counters.llmInputChars ?? null,
|
|
530
|
+
tokens: null,
|
|
531
|
+
},
|
|
532
|
+
notes: [
|
|
533
|
+
...(audit === undefined ? [`No SQLite index found at ${dbPath}.`] : []),
|
|
534
|
+
...(generation === undefined ? [] : [
|
|
535
|
+
`Generation ${generation.generation}: skipped raw summaries ${generation.skippedRawRecords ?? 0}, `
|
|
536
|
+
+ `unstructured source lines ${generation.skippedUnstructuredRecords ?? 0}, `
|
|
537
|
+
+ `missing-identity source lines ${generation.skippedMissingIdentityRecords ?? 0} `
|
|
538
|
+
+ `(${generation.missingIdentityLocations?.join(", ") || "none"}), `
|
|
539
|
+
+ `legacy-source lines ${generation.skippedLegacySourceRecords ?? 0} `
|
|
540
|
+
+ `(${generation.legacySourceLocations?.join(", ") || "none"}), `
|
|
541
|
+
+ `Journal duplicate lines ${generation.skippedJournalDuplicateRecords ?? 0}, `
|
|
542
|
+
+ `parsed source items ${generation.parsedSourceItems ?? 0}, `
|
|
543
|
+
+ `derived legacy associations ${generation.derivedLegacyAssociations ?? 0}.`,
|
|
544
|
+
]),
|
|
545
|
+
"Search latency and model cost require benchmark/run telemetry and are not inferred from memory content.",
|
|
546
|
+
...(!runtime.available ? [
|
|
547
|
+
`Runtime queue/call telemetry is ${runtime.reason === "invalid" ? "invalid" : "not available until the configured store starts"}.`,
|
|
548
|
+
] : runtime.stale ? [
|
|
549
|
+
`Runtime queue/call telemetry is stale (${runtime.snapshot?.state ?? "unknown"} snapshot; last update ${runtime.snapshot?.updatedAt ?? "unknown"}).`,
|
|
550
|
+
] : []),
|
|
551
|
+
],
|
|
552
|
+
};
|
|
553
|
+
write(json, result, () => renderAudit(result));
|
|
554
|
+
return 0;
|
|
555
|
+
}
|
|
53
556
|
async function loadMemoryCommandContext(input) {
|
|
54
557
|
const cwd = input.cwd;
|
|
55
558
|
const configPath = resolve(cwd, input.configPath ?? "mono-agent.config.json");
|
|
56
559
|
try {
|
|
57
560
|
return {
|
|
58
561
|
cwd,
|
|
562
|
+
env: input.env,
|
|
59
563
|
configPath,
|
|
60
564
|
config: await loadAppCoreConfig({ env: input.env, cwd, configPath }),
|
|
61
565
|
};
|
|
62
566
|
}
|
|
63
567
|
catch (error) {
|
|
568
|
+
if (input.positionals[0] === "adopt-replay") {
|
|
569
|
+
// Config/native failures can contain the config path or invalid private
|
|
570
|
+
// values. Adoption always exposes the same closed error contract.
|
|
571
|
+
writeReplayAdoptionCliFailure(input.json, "replay_adoption_config_invalid");
|
|
572
|
+
return { code: 1 };
|
|
573
|
+
}
|
|
64
574
|
if (isAppCoreConfigError(error)) {
|
|
65
575
|
process.stderr.write(ui.errorLine(error.message));
|
|
66
576
|
process.stderr.write(ui.hint(`Fix ${configPath}, then re-run \`mono-agent memory\`.`));
|
|
@@ -69,6 +579,78 @@ async function loadMemoryCommandContext(input) {
|
|
|
69
579
|
throw error;
|
|
70
580
|
}
|
|
71
581
|
}
|
|
582
|
+
async function assertNoLiveConfiguredAgent(configPath, registryDirs) {
|
|
583
|
+
const live = await findLiveConfiguredAgent(configPath, registryDirs);
|
|
584
|
+
if (live === undefined)
|
|
585
|
+
return;
|
|
586
|
+
const canonicalConfig = await canonicalPath(configPath);
|
|
587
|
+
throw new Error(`agent process ${live.pid} (${live.sourceId}) is still alive for this config (trace health: ${live.health}); ` +
|
|
588
|
+
`stop it first with: mono-agent stop --config ${canonicalConfig}`);
|
|
589
|
+
}
|
|
590
|
+
async function hasLiveConfiguredAgent(configPath, registryDirs) {
|
|
591
|
+
return await findLiveConfiguredAgent(configPath, registryDirs) !== undefined;
|
|
592
|
+
}
|
|
593
|
+
async function findLiveConfiguredAgent(configPath, registryDirs) {
|
|
594
|
+
const canonicalConfig = await canonicalPath(configPath);
|
|
595
|
+
const listings = await Promise.all(registryDirs.map(async (registryDir) => await listTraceSources({ registryDir })));
|
|
596
|
+
const sources = dedupeTraceSources(listings.flatMap((listing) => listing.sources));
|
|
597
|
+
let live;
|
|
598
|
+
for (const source of sources) {
|
|
599
|
+
if (source.configPath === undefined || source.pid === undefined || !pidIsAlive(source.pid))
|
|
600
|
+
continue;
|
|
601
|
+
if (await canonicalPath(source.configPath) === canonicalConfig) {
|
|
602
|
+
live = source;
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return live;
|
|
607
|
+
}
|
|
608
|
+
async function dedupeRegistryDirs(registryDirs) {
|
|
609
|
+
const seen = new Set();
|
|
610
|
+
const deduped = [];
|
|
611
|
+
for (const registryDir of registryDirs) {
|
|
612
|
+
const canonical = await canonicalPath(registryDir);
|
|
613
|
+
if (seen.has(canonical))
|
|
614
|
+
continue;
|
|
615
|
+
seen.add(canonical);
|
|
616
|
+
deduped.push(registryDir);
|
|
617
|
+
}
|
|
618
|
+
return deduped;
|
|
619
|
+
}
|
|
620
|
+
function dedupeTraceSources(sources) {
|
|
621
|
+
const seen = new Set();
|
|
622
|
+
const deduped = [];
|
|
623
|
+
for (const source of sources) {
|
|
624
|
+
// Primary and global registries mirror the same source/PID pair. Preserve
|
|
625
|
+
// a reused source ID with a different PID so either live process blocks.
|
|
626
|
+
const key = `${source.sourceId}\0${source.pid ?? "unknown"}`;
|
|
627
|
+
if (seen.has(key))
|
|
628
|
+
continue;
|
|
629
|
+
seen.add(key);
|
|
630
|
+
deduped.push(source);
|
|
631
|
+
}
|
|
632
|
+
return deduped;
|
|
633
|
+
}
|
|
634
|
+
async function canonicalPath(path) {
|
|
635
|
+
const absolute = resolve(path);
|
|
636
|
+
try {
|
|
637
|
+
return await realpath(absolute);
|
|
638
|
+
}
|
|
639
|
+
catch {
|
|
640
|
+
return absolute;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function pidIsAlive(pid) {
|
|
644
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
645
|
+
return false;
|
|
646
|
+
try {
|
|
647
|
+
process.kill(pid, 0);
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
650
|
+
catch (error) {
|
|
651
|
+
return error.code === "EPERM";
|
|
652
|
+
}
|
|
653
|
+
}
|
|
72
654
|
async function runStats(context, input) {
|
|
73
655
|
const memory = context.config.memory;
|
|
74
656
|
if (memory === undefined) {
|
|
@@ -81,7 +663,9 @@ async function runStats(context, input) {
|
|
|
81
663
|
return 0;
|
|
82
664
|
}
|
|
83
665
|
const root = memory.path;
|
|
84
|
-
const
|
|
666
|
+
const { resolveActiveMemoryDbPath } = await loadBujoModule();
|
|
667
|
+
const { openMemoryDb } = await loadMemoryStoreModule();
|
|
668
|
+
const dbPath = await resolveActiveMemoryDbPath(root);
|
|
85
669
|
const rootExists = await exists(root);
|
|
86
670
|
const dbExists = await exists(dbPath);
|
|
87
671
|
const size = rootExists ? await collectStoreSize(root) : emptySize();
|
|
@@ -91,7 +675,7 @@ async function runStats(context, input) {
|
|
|
91
675
|
let entityCount = 0;
|
|
92
676
|
let topMemories = [];
|
|
93
677
|
if (dbExists) {
|
|
94
|
-
const db = openMemoryDb({ path: dbPath });
|
|
678
|
+
const db = openMemoryDb({ path: dbPath, readOnly: true });
|
|
95
679
|
try {
|
|
96
680
|
stats = readLocalStats(db, input.limit ?? DEFAULT_ENTITY_LIMIT);
|
|
97
681
|
entityCount = db.countEntities();
|
|
@@ -164,6 +748,7 @@ async function runShow(context, date, json) {
|
|
|
164
748
|
return 0;
|
|
165
749
|
}
|
|
166
750
|
const content = await readFile(found, "utf8");
|
|
751
|
+
const { parseDailyFile } = await loadBujoModule();
|
|
167
752
|
const parsed = parseDailyFile(content);
|
|
168
753
|
const result = {
|
|
169
754
|
configured: true,
|
|
@@ -185,18 +770,24 @@ async function runShow(context, date, json) {
|
|
|
185
770
|
return 0;
|
|
186
771
|
}
|
|
187
772
|
async function runSearch(context, query, input) {
|
|
188
|
-
|
|
773
|
+
let settings = previewRecallSettings(context.config);
|
|
189
774
|
if (settings === undefined) {
|
|
190
775
|
writeNoMemory(context.configPath, input.json);
|
|
191
776
|
return 0;
|
|
192
777
|
}
|
|
193
|
-
if (!("supermemory" in settings)
|
|
778
|
+
if (!("supermemory" in settings)) {
|
|
779
|
+
const { resolveActiveMemoryDbPath } = await loadBujoModule();
|
|
780
|
+
const dbPath = await resolveActiveMemoryDbPath(settings.root);
|
|
781
|
+
settings = { ...settings, dbPath };
|
|
782
|
+
}
|
|
783
|
+
if (!("supermemory" in settings) && !(await exists(settings.dbPath ?? join(settings.root, "memory.db")))) {
|
|
784
|
+
const dbPath = settings.dbPath ?? join(settings.root, "memory.db");
|
|
194
785
|
const result = {
|
|
195
786
|
configured: true,
|
|
196
787
|
backend: "bujo",
|
|
197
788
|
query,
|
|
198
789
|
hits: [],
|
|
199
|
-
notes: [`No SQLite index found at ${
|
|
790
|
+
notes: [`No SQLite index found at ${dbPath}; run mono-agent memory rebuild or wait for capture.`],
|
|
200
791
|
};
|
|
201
792
|
write(input.json, result, () => renderSearch(result));
|
|
202
793
|
return 0;
|
|
@@ -248,18 +839,20 @@ async function runTop(context, input) {
|
|
|
248
839
|
write(input.json, result, () => `${ui.banner("mono-agent memory", "top")}\n${result.message}\n`);
|
|
249
840
|
return 0;
|
|
250
841
|
}
|
|
251
|
-
const
|
|
842
|
+
const { resolveActiveMemoryDbPath } = await loadBujoModule();
|
|
843
|
+
const { openMemoryDb } = await loadMemoryStoreModule();
|
|
844
|
+
const dbPath = await resolveActiveMemoryDbPath(memory.path);
|
|
252
845
|
if (!(await exists(dbPath))) {
|
|
253
846
|
const result = {
|
|
254
847
|
configured: true,
|
|
255
848
|
backend: "bujo",
|
|
256
849
|
hits: [],
|
|
257
|
-
notes: [`No SQLite index found at ${dbPath}; run
|
|
850
|
+
notes: [`No SQLite index found at ${dbPath}; run mono-agent memory rebuild or wait for capture.`],
|
|
258
851
|
};
|
|
259
852
|
write(input.json, result, () => renderTop(result));
|
|
260
853
|
return 0;
|
|
261
854
|
}
|
|
262
|
-
const db = openMemoryDb({ path: dbPath });
|
|
855
|
+
const db = openMemoryDb({ path: dbPath, readOnly: true });
|
|
263
856
|
try {
|
|
264
857
|
const hits = db.topSalient(input.limit ?? DEFAULT_TOP_LIMIT).map((record) => ({
|
|
265
858
|
id: record.id,
|
|
@@ -279,10 +872,6 @@ async function runTop(context, input) {
|
|
|
279
872
|
return 0;
|
|
280
873
|
}
|
|
281
874
|
function previewRecallSettings(config) {
|
|
282
|
-
const fromTool = resolveMemoryRecallSettings(config);
|
|
283
|
-
if (fromTool !== undefined) {
|
|
284
|
-
return fromTool;
|
|
285
|
-
}
|
|
286
875
|
const memory = config.memory;
|
|
287
876
|
if (memory === undefined) {
|
|
288
877
|
return undefined;
|
|
@@ -303,10 +892,11 @@ function previewRecallSettings(config) {
|
|
|
303
892
|
}
|
|
304
893
|
const embeddings = memory.embeddings;
|
|
305
894
|
if (embeddings === undefined) {
|
|
306
|
-
return { root: memory.path };
|
|
895
|
+
return { root: memory.path, tier: memory.mode };
|
|
307
896
|
}
|
|
308
897
|
return {
|
|
309
898
|
root: memory.path,
|
|
899
|
+
tier: memory.mode,
|
|
310
900
|
embeddings: {
|
|
311
901
|
provider: embeddings.provider,
|
|
312
902
|
model: embeddings.model,
|
|
@@ -320,6 +910,7 @@ function previewRecallSettings(config) {
|
|
|
320
910
|
};
|
|
321
911
|
}
|
|
322
912
|
async function recallWithFtsFallback(settings, query, limit) {
|
|
913
|
+
const { createRecallStore } = await loadMemoryRecallModule();
|
|
323
914
|
const store = await createRecallStore(settings);
|
|
324
915
|
try {
|
|
325
916
|
return { hits: await store.recall(query, { topK: limit, trackAccess: false }) };
|
|
@@ -329,7 +920,12 @@ async function recallWithFtsFallback(settings, query, limit) {
|
|
|
329
920
|
throw error;
|
|
330
921
|
}
|
|
331
922
|
await store.close().catch(() => undefined);
|
|
332
|
-
const fallback = {
|
|
923
|
+
const fallback = {
|
|
924
|
+
root: settings.root,
|
|
925
|
+
...(settings.tier === undefined ? {} : { tier: settings.tier }),
|
|
926
|
+
...(settings.dbPath === undefined ? {} : { dbPath: settings.dbPath }),
|
|
927
|
+
ftsOnlyFallback: true,
|
|
928
|
+
};
|
|
333
929
|
const ftsStore = await createRecallStore(fallback);
|
|
334
930
|
try {
|
|
335
931
|
return {
|
|
@@ -367,13 +963,7 @@ function readLocalStats(db, topEntitiesLimit) {
|
|
|
367
963
|
return db.stats({ topEntitiesLimit });
|
|
368
964
|
}
|
|
369
965
|
function effectiveLocalTier(memory) {
|
|
370
|
-
|
|
371
|
-
return "lite";
|
|
372
|
-
}
|
|
373
|
-
if (memory.mode === "journal") {
|
|
374
|
-
return "journal";
|
|
375
|
-
}
|
|
376
|
-
return memory.llm === undefined ? "journal" : "bujo";
|
|
966
|
+
return memory.mode;
|
|
377
967
|
}
|
|
378
968
|
function supermemoryStats(config) {
|
|
379
969
|
return {
|
|
@@ -540,6 +1130,81 @@ function renderSupermemoryStats(stats) {
|
|
|
540
1130
|
...stats.unavailable.map((item) => ` - ${item}\n`),
|
|
541
1131
|
].join("");
|
|
542
1132
|
}
|
|
1133
|
+
function renderAudit(result) {
|
|
1134
|
+
let out = ui.banner("mono-agent memory", "metadata audit") + "\n";
|
|
1135
|
+
out += ui.keyValue([
|
|
1136
|
+
["backend", result.backend],
|
|
1137
|
+
["memories", result.counts === null ? "unknown" : `${result.counts.total} total, ${result.counts.live} live`],
|
|
1138
|
+
["bytes", result.bytes === null ? "unknown" : formatBytes(result.bytes.rootBytes)],
|
|
1139
|
+
["duplicate ratio", result.duplicates === null ? "unknown" : formatRatio(result.duplicates.ratio)],
|
|
1140
|
+
["vector coverage", result.vectorCoverage === null ? "unknown" : formatRatio(result.vectorCoverage.liveCoverage)],
|
|
1141
|
+
["top 1% access share", result.accessConcentration === null ? "unknown" : formatRatio(result.accessConcentration.topOnePercentShare)],
|
|
1142
|
+
["vector backlog", result.backlog.vectorIndex === null ? "unknown" : String(result.backlog.vectorIndex)],
|
|
1143
|
+
["capture queue", result.backlog.captureQueue === null ? "not live/available" : String(result.backlog.captureQueue)],
|
|
1144
|
+
["runtime telemetry", result.runtime === undefined || !result.runtime.available
|
|
1145
|
+
? "unavailable"
|
|
1146
|
+
: `${result.runtime.state ?? "unknown"}${result.runtime.stale ? " (stale)" : " (live)"}`],
|
|
1147
|
+
["metadata query", result.latency.metadataQueryMs == null ? "unknown" : `${result.latency.metadataQueryMs.toFixed(3)} ms`],
|
|
1148
|
+
["embedding calls", result.cost.embeddingCalls === null ? "unknown" : String(result.cost.embeddingCalls)],
|
|
1149
|
+
["memory LLM calls", result.cost.llmCalls === null ? "unknown" : String(result.cost.llmCalls)],
|
|
1150
|
+
["recorded cost", result.cost.totalUsd === null ? "unknown" : `$${result.cost.totalUsd.toFixed(6)}`],
|
|
1151
|
+
], 2);
|
|
1152
|
+
for (const note of result.notes)
|
|
1153
|
+
out += ui.style.yellow(`[WARN] ${note}`) + "\n";
|
|
1154
|
+
return out;
|
|
1155
|
+
}
|
|
1156
|
+
function renderStrictAudit(result) {
|
|
1157
|
+
return [
|
|
1158
|
+
ui.banner("mono-agent memory", "strict health"),
|
|
1159
|
+
"\n",
|
|
1160
|
+
ui.keyValue([
|
|
1161
|
+
["schema", String(result.schemaVersion)],
|
|
1162
|
+
["backend", result.backend],
|
|
1163
|
+
["mode", "mode" in result ? result.mode : "none"],
|
|
1164
|
+
["status", result.status],
|
|
1165
|
+
["checked", result.checkedAt],
|
|
1166
|
+
["issues", result.issues.length === 0 ? "none" : result.issues.join(", ")],
|
|
1167
|
+
["pending", String(result.counts.pending)],
|
|
1168
|
+
["due", String(result.counts.due)],
|
|
1169
|
+
["dead", String(result.counts.dead)],
|
|
1170
|
+
["outbox", String(result.counts.outbox)],
|
|
1171
|
+
["temporary", String(result.counts.temporary)],
|
|
1172
|
+
["memories", String(result.counts.memories)],
|
|
1173
|
+
["vectors", String(result.counts.vectors)],
|
|
1174
|
+
["missing vectors", String(result.counts.missingVectors)],
|
|
1175
|
+
], 2),
|
|
1176
|
+
].join("");
|
|
1177
|
+
}
|
|
1178
|
+
function renderIntakeInspection(result) {
|
|
1179
|
+
let out = ui.banner("mono-agent memory", "intake inspection") + "\n";
|
|
1180
|
+
out += ui.keyValue([
|
|
1181
|
+
["matched", String(result.matched)],
|
|
1182
|
+
["pending", String(result.snapshot.pending)],
|
|
1183
|
+
["due", String(result.snapshot.due)],
|
|
1184
|
+
["dead", String(result.snapshot.dead)],
|
|
1185
|
+
["resolved", String(result.snapshot.resolved)],
|
|
1186
|
+
["transitioning", String(result.snapshot.transitioning)],
|
|
1187
|
+
["temporary", String(result.temporary)],
|
|
1188
|
+
], 2);
|
|
1189
|
+
for (const item of result.items) {
|
|
1190
|
+
out += ` ${item.id} state=${item.state} attempt=${item.attempt} revision=${item.revision} due=${item.due ? "yes" : "no"}`;
|
|
1191
|
+
if (item.lastError !== undefined)
|
|
1192
|
+
out += ` lastError=${item.lastError}`;
|
|
1193
|
+
out += "\n";
|
|
1194
|
+
}
|
|
1195
|
+
return out;
|
|
1196
|
+
}
|
|
1197
|
+
function renderIntakeMutation(result) {
|
|
1198
|
+
return [
|
|
1199
|
+
ui.banner("mono-agent memory", `intake ${result.operation}`),
|
|
1200
|
+
"\n",
|
|
1201
|
+
ui.keyValue([
|
|
1202
|
+
["changed", result.changed ? "yes" : "no"],
|
|
1203
|
+
...(result.retried === undefined ? [] : [["retried", String(result.retried)]]),
|
|
1204
|
+
...(result.resolved === undefined ? [] : [["resolved", result.resolved ? "yes" : "no"]]),
|
|
1205
|
+
], 2),
|
|
1206
|
+
].join("");
|
|
1207
|
+
}
|
|
543
1208
|
function renderLocalStats(stats) {
|
|
544
1209
|
let out = ui.banner("mono-agent memory", "stats") + "\n";
|
|
545
1210
|
out += ui.keyValue([
|
|
@@ -584,6 +1249,41 @@ function renderDaily(result) {
|
|
|
584
1249
|
result.content.endsWith("\n") ? result.content : `${result.content}\n`,
|
|
585
1250
|
].join("");
|
|
586
1251
|
}
|
|
1252
|
+
function renderIndexTransition(result) {
|
|
1253
|
+
return [
|
|
1254
|
+
ui.banner("mono-agent memory", result.operation),
|
|
1255
|
+
"\n",
|
|
1256
|
+
ui.keyValue([
|
|
1257
|
+
["status", "complete"],
|
|
1258
|
+
["active database", result.activeDatabase],
|
|
1259
|
+
["generation", result.details.generation],
|
|
1260
|
+
["indexed memories", String(result.details.indexed)],
|
|
1261
|
+
["skipped raw summaries", String(result.details.skippedRawRecords)],
|
|
1262
|
+
["skipped unstructured lines", String(result.details.skippedUnstructuredRecords)],
|
|
1263
|
+
["skipped missing-identity lines", String(result.details.skippedMissingIdentityRecords)],
|
|
1264
|
+
["missing-identity locations", result.details.missingIdentityLocations.join(", ") || "none"],
|
|
1265
|
+
["skipped legacy-source lines", String(result.details.skippedLegacySourceRecords)],
|
|
1266
|
+
["legacy-source locations", result.details.legacySourceLocations.join(", ") || "none"],
|
|
1267
|
+
["skipped Journal duplicates", String(result.details.skippedJournalDuplicateRecords)],
|
|
1268
|
+
["parsed source items", String(result.details.parsedSourceItems)],
|
|
1269
|
+
["derived legacy associations", String(result.details.derivedLegacyAssociations)],
|
|
1270
|
+
], 2),
|
|
1271
|
+
].join("");
|
|
1272
|
+
}
|
|
1273
|
+
function renderReplayAdoption(result) {
|
|
1274
|
+
return [
|
|
1275
|
+
ui.banner("mono-agent memory", "adopt replay"),
|
|
1276
|
+
"\n",
|
|
1277
|
+
ui.keyValue([
|
|
1278
|
+
["status", result.status],
|
|
1279
|
+
["terminal lifecycles", String(result.counts.terminals)],
|
|
1280
|
+
["supersedes", String(result.counts.supersedes)],
|
|
1281
|
+
["threads", String(result.counts.threads)],
|
|
1282
|
+
["authority digest", result.authorityDigest],
|
|
1283
|
+
["rebuild required", result.rebuildRequired ? "yes" : "no"],
|
|
1284
|
+
], 2),
|
|
1285
|
+
].join("");
|
|
1286
|
+
}
|
|
587
1287
|
function renderSearch(result) {
|
|
588
1288
|
let out = ui.banner("mono-agent memory", `search: ${result.query}`) + "\n";
|
|
589
1289
|
if (result.degraded !== undefined) {
|
|
@@ -643,7 +1343,31 @@ function formatBytes(bytes) {
|
|
|
643
1343
|
}
|
|
644
1344
|
return `${value >= 10 ? value.toFixed(1) : value.toFixed(2)} ${unit}`;
|
|
645
1345
|
}
|
|
1346
|
+
function formatRatio(value) {
|
|
1347
|
+
return `${(value * 100).toFixed(2)}%`;
|
|
1348
|
+
}
|
|
646
1349
|
function reasonOf(error) {
|
|
647
1350
|
return error instanceof Error ? error.message : String(error);
|
|
648
1351
|
}
|
|
1352
|
+
async function loadBujoModule() {
|
|
1353
|
+
return await import("@mono-agent/memory/bujo");
|
|
1354
|
+
}
|
|
1355
|
+
async function loadMemoryStoreModule() {
|
|
1356
|
+
return await import("@mono-agent/memory/store");
|
|
1357
|
+
}
|
|
1358
|
+
async function loadMemoryRecallModule() {
|
|
1359
|
+
return await import("./memory-recall.js");
|
|
1360
|
+
}
|
|
1361
|
+
function isNativeModuleFailure(error) {
|
|
1362
|
+
try {
|
|
1363
|
+
const message = error instanceof Error ? error.message : "";
|
|
1364
|
+
const code = typeof error === "object" && error !== null && "code" in error
|
|
1365
|
+
? String(error.code ?? "")
|
|
1366
|
+
: "";
|
|
1367
|
+
return /better[-_ ]?sqlite|sqlite[-_ ]?vec|node_module_version|native module|dlopen|\.node\b/iu.test(`${code} ${message}`);
|
|
1368
|
+
}
|
|
1369
|
+
catch {
|
|
1370
|
+
return false;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
649
1373
|
//# sourceMappingURL=memory-command.js.map
|