@moxxy/core 0.6.3 → 0.7.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/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/host-options.d.ts +2 -0
- package/dist/plugins/host-options.d.ts.map +1 -1
- package/dist/plugins/registry-kinds.d.ts +1 -0
- package/dist/plugins/registry-kinds.d.ts.map +1 -1
- package/dist/plugins/registry-kinds.js +12 -0
- package/dist/plugins/registry-kinds.js.map +1 -1
- package/dist/registries/active-def-registry.d.ts +46 -9
- package/dist/registries/active-def-registry.d.ts.map +1 -1
- package/dist/registries/active-def-registry.js +39 -10
- package/dist/registries/active-def-registry.js.map +1 -1
- package/dist/registries/event-stores.d.ts +13 -0
- package/dist/registries/event-stores.d.ts.map +1 -0
- package/dist/registries/event-stores.js +14 -0
- package/dist/registries/event-stores.js.map +1 -0
- package/dist/registries/modes.d.ts +6 -0
- package/dist/registries/modes.d.ts.map +1 -1
- package/dist/registries/modes.js +10 -0
- package/dist/registries/modes.js.map +1 -1
- package/dist/registries/services.d.ts +15 -0
- package/dist/registries/services.d.ts.map +1 -0
- package/dist/registries/services.js +26 -0
- package/dist/registries/services.js.map +1 -0
- package/dist/run-turn.d.ts.map +1 -1
- package/dist/run-turn.js +2 -0
- package/dist/run-turn.js.map +1 -1
- package/dist/session-runtime.d.ts +3 -1
- package/dist/session-runtime.d.ts.map +1 -1
- package/dist/session.d.ts +25 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +78 -8
- package/dist/session.js.map +1 -1
- package/dist/sessions/jsonl-event-store.d.ts +16 -0
- package/dist/sessions/jsonl-event-store.d.ts.map +1 -0
- package/dist/sessions/jsonl-event-store.js +30 -0
- package/dist/sessions/jsonl-event-store.js.map +1 -0
- package/dist/sessions/persistence.d.ts +3 -58
- package/dist/sessions/persistence.d.ts.map +1 -1
- package/dist/sessions/persistence.js +2 -0
- package/dist/sessions/persistence.js.map +1 -1
- package/dist/subagents/run-child.d.ts.map +1 -1
- package/dist/subagents/run-child.js +2 -0
- package/dist/subagents/run-child.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +11 -6
- package/src/plugins/host-options.ts +2 -0
- package/src/plugins/registry-kinds.test.ts +17 -0
- package/src/plugins/registry-kinds.ts +14 -0
- package/src/registries/active-def-registry.test.ts +42 -0
- package/src/registries/active-def-registry.ts +70 -13
- package/src/registries/event-stores.test.ts +77 -0
- package/src/registries/event-stores.ts +15 -0
- package/src/registries/modes.ts +12 -0
- package/src/registries/services.test.ts +29 -0
- package/src/registries/services.ts +33 -0
- package/src/run-turn.ts +2 -0
- package/src/session-runtime.ts +3 -0
- package/src/session.ts +89 -8
- package/src/sessions/jsonl-event-store.ts +31 -0
- package/src/sessions/persistence.ts +11 -58
- package/src/subagents/run-child.ts +2 -0
- package/dist/preferences.d.ts +0 -40
- package/dist/preferences.d.ts.map +0 -1
- package/dist/preferences.js +0 -59
- package/dist/preferences.js.map +0 -1
- package/src/preferences.test.ts +0 -156
- package/src/preferences.ts +0 -85
package/src/preferences.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'node:fs';
|
|
2
|
-
import { createMutex, migrateModeName } from '@moxxy/sdk';
|
|
3
|
-
import { moxxyPath, writeFileAtomic } from '@moxxy/sdk/server';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* User-level runtime preferences persisted at ~/.moxxy/preferences.json.
|
|
7
|
-
* Distinct from `~/.moxxy/config.yaml` (user-edited, source of truth for
|
|
8
|
-
* provider/plugin wiring) — this file is mutated by the TUI as the user
|
|
9
|
-
* picks a model / loop strategy via slash commands, so it survives across
|
|
10
|
-
* CLI invocations. A missing file or unreadable contents is a no-op:
|
|
11
|
-
* preferences are best-effort, never load-blocking.
|
|
12
|
-
*/
|
|
13
|
-
export interface MoxxyPreferences {
|
|
14
|
-
/** Active provider name (e.g. "openai", "anthropic"). */
|
|
15
|
-
readonly providerName?: string;
|
|
16
|
-
/** Active model id under that provider (e.g. "gpt-5.4-mini"). */
|
|
17
|
-
readonly model?: string;
|
|
18
|
-
/** Active loop strategy name (e.g. "default", "research", "goal"). */
|
|
19
|
-
readonly mode?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Providers the user disabled (desktop Settings → Providers toggle).
|
|
22
|
-
* Seeded into the ProviderRegistry at boot; a listed provider stays
|
|
23
|
-
* registered but can't be activated until re-enabled.
|
|
24
|
-
*/
|
|
25
|
-
readonly disabledProviders?: ReadonlyArray<string>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function preferencesPath(): string {
|
|
29
|
-
// Route through `moxxyPath` so a `$MOXXY_HOME` override relocates preferences
|
|
30
|
-
// alongside the rest of the data dir (config.yaml, vault, providers.json, …).
|
|
31
|
-
// Identical to `~/.moxxy/preferences.json` when MOXXY_HOME is unset.
|
|
32
|
-
return moxxyPath('preferences.json');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Read preferences from disk. Returns an empty object when the file
|
|
37
|
-
* doesn't exist or fails to parse — preferences are an optional layer,
|
|
38
|
-
* never a hard dependency of session bootstrap.
|
|
39
|
-
*/
|
|
40
|
-
export async function loadPreferences(): Promise<MoxxyPreferences> {
|
|
41
|
-
try {
|
|
42
|
-
const raw = await fs.readFile(preferencesPath(), 'utf8');
|
|
43
|
-
const parsed = JSON.parse(raw) as unknown;
|
|
44
|
-
if (parsed && typeof parsed === 'object') {
|
|
45
|
-
const prefs = parsed as MoxxyPreferences;
|
|
46
|
-
return prefs.mode ? { ...prefs, mode: migrateModeName(prefs.mode) } : prefs;
|
|
47
|
-
}
|
|
48
|
-
return {};
|
|
49
|
-
} catch {
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Serializes the read-modify-write in `savePreferences` so two concurrent
|
|
55
|
-
// saves (e.g. a /model pick and a provider-disable toggle firing close
|
|
56
|
-
// together) can't both read the same snapshot and have the second write
|
|
57
|
-
// clobber the first's field. This is the single write path for the file —
|
|
58
|
-
// other packages (CLI, runner, channels) route their fire-and-forget saves
|
|
59
|
-
// through it, and any load-modify-save must go through it too.
|
|
60
|
-
const writeMutex = createMutex();
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Merge-and-write preferences. Reads the current file (if any), merges
|
|
64
|
-
* the patch on top so we don't blow away unrelated fields, and writes
|
|
65
|
-
* the result back atomically. The whole read-merge-write runs inside a
|
|
66
|
-
* module-level mutex so overlapping saves serialize (invariant #5) and
|
|
67
|
-
* never lose an update. Best-effort: a write failure logs to stderr but
|
|
68
|
-
* does not throw — the user's pick still takes effect in this session,
|
|
69
|
-
* just won't persist across invocations.
|
|
70
|
-
*/
|
|
71
|
-
export async function savePreferences(patch: Partial<MoxxyPreferences>): Promise<void> {
|
|
72
|
-
return writeMutex.run(async () => {
|
|
73
|
-
const current = await loadPreferences();
|
|
74
|
-
const next: MoxxyPreferences = { ...current, ...patch };
|
|
75
|
-
const target = preferencesPath();
|
|
76
|
-
try {
|
|
77
|
-
await writeFileAtomic(target, JSON.stringify(next, null, 2) + '\n');
|
|
78
|
-
} catch (err) {
|
|
79
|
-
process.stderr.write(
|
|
80
|
-
`moxxy: failed to persist preferences to ${target}: ` +
|
|
81
|
-
`${err instanceof Error ? err.message : String(err)}\n`,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|