imsg-mcp 1.10.0 → 1.12.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/CHANGELOG.md +14 -0
- package/dist/app-config-CVixby2Z.js +211 -0
- package/dist/app-config-CVixby2Z.js.map +1 -0
- package/dist/cli.js +56 -40
- package/dist/cli.js.map +1 -1
- package/dist/{export-formats-wytSyBTp.js → export-formats-DosZugMa.js} +4 -4
- package/dist/{export-formats-wytSyBTp.js.map → export-formats-DosZugMa.js.map} +1 -1
- package/dist/{exportStream-DgPVRZTZ.js → exportStream-Dp5KKwtE.js} +2 -2
- package/dist/{exportStream-DgPVRZTZ.js.map → exportStream-Dp5KKwtE.js.map} +1 -1
- package/dist/{imessage-db-vrzopRGT.js → imessage-db-CbI0AYGw.js} +59 -4
- package/dist/imessage-db-CbI0AYGw.js.map +1 -0
- package/dist/index-D8A4ss3o.js +1970 -0
- package/dist/index-D8A4ss3o.js.map +1 -0
- package/dist/index.js +5 -5
- package/dist/{meta-D6ZUMB_B.js → meta-BA-d51LM.js} +2 -2
- package/dist/{meta-D6ZUMB_B.js.map → meta-BA-d51LM.js.map} +1 -1
- package/dist/{setup-CgLVaoGu.js → setup-Tpk356yq.js} +2 -2
- package/dist/{setup-CgLVaoGu.js.map → setup-Tpk356yq.js.map} +1 -1
- package/dist/setup-wizard-Z6_0P-yc.js +375 -0
- package/dist/setup-wizard-Z6_0P-yc.js.map +1 -0
- package/dist/{shutdown-CQ9wzrxA.js → shutdown-CjDoFsTF.js} +50 -50
- package/dist/{shutdown-CQ9wzrxA.js.map → shutdown-CjDoFsTF.js.map} +1 -1
- package/dist/tui-config-DWD0O2SW.js +17 -0
- package/dist/tui-config-DWD0O2SW.js.map +1 -0
- package/dist/tui.js +26 -6
- package/dist/tui.js.map +1 -1
- package/dist/{watchdog-Cl5PoHhW.js → watchdog-wY5uccJH.js} +4 -4
- package/dist/watchdog-wY5uccJH.js.map +1 -0
- package/package.json +2 -1
- package/dist/imessage-db-vrzopRGT.js.map +0 -1
- package/dist/tui-config-Crn6TZPg.js +0 -122
- package/dist/tui-config-Crn6TZPg.js.map +0 -1
- package/dist/watchdog-Cl5PoHhW.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and follows [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
# [1.12.0](https://github.com/george43g/imsg-mcp/compare/v1.11.0...v1.12.0) (2026-07-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **cli:** interactive setup wizard for media interpretation ([0ad7507](https://github.com/george43g/imsg-mcp/commit/0ad75075e08e6cc9db7900a15ba7469b4e91314c))
|
|
12
|
+
|
|
13
|
+
# [1.11.0](https://github.com/george43g/imsg-mcp/compare/v1.10.0...v1.11.0) (2026-07-21)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **db+tui:** parse message edit history and show it in the drawer ([e4df935](https://github.com/george43g/imsg-mcp/commit/e4df93552f96419bebe50acd241b7d0b74854c9b))
|
|
19
|
+
|
|
6
20
|
# [1.10.0](https://github.com/george43g/imsg-mcp/compare/v1.9.0...v1.10.0) (2026-07-21)
|
|
7
21
|
|
|
8
22
|
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, chmodSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
const HEX6 = /^#[0-9a-fA-F]{6}$/;
|
|
6
|
+
const PROVIDER_PRESET_NAMES = [
|
|
7
|
+
"openai",
|
|
8
|
+
"groq",
|
|
9
|
+
"openrouter",
|
|
10
|
+
"cloudflare",
|
|
11
|
+
"huggingface",
|
|
12
|
+
"ollama"
|
|
13
|
+
];
|
|
14
|
+
const ProviderModelsSchema = z.object({ transcribe: z.string().optional(), vision: z.string().optional() }).optional();
|
|
15
|
+
const ProviderConfigSchema = z.object({
|
|
16
|
+
name: z.string().min(1),
|
|
17
|
+
preset: z.enum(PROVIDER_PRESET_NAMES).optional(),
|
|
18
|
+
baseUrl: z.string().url().optional(),
|
|
19
|
+
accountId: z.string().optional(),
|
|
20
|
+
models: ProviderModelsSchema
|
|
21
|
+
}).refine((p) => Boolean(p.preset) || Boolean(p.baseUrl), {
|
|
22
|
+
message: "provider needs either a preset or a baseUrl"
|
|
23
|
+
});
|
|
24
|
+
const ChainsSchema = z.object({
|
|
25
|
+
audio: z.array(z.string()).default(["apple", "local"]),
|
|
26
|
+
image: z.array(z.string()).default([]),
|
|
27
|
+
video: z.array(z.string()).default([])
|
|
28
|
+
}).default({});
|
|
29
|
+
const NudgeSchema = z.object({
|
|
30
|
+
enabled: z.boolean().default(true),
|
|
31
|
+
tier2SyncNow: z.boolean().default(false),
|
|
32
|
+
timeoutSeconds: z.number().int().positive().default(30)
|
|
33
|
+
}).default({});
|
|
34
|
+
const InterpretConfigSchema = z.object({
|
|
35
|
+
/** Auto-interpretation gate. "free" (default) never makes a paid call without
|
|
36
|
+
* an explicit force; "all" runs the full chain incl. cloud; "off" disables. */
|
|
37
|
+
auto: z.enum(["all", "free", "off"]).default("free"),
|
|
38
|
+
/** Inline cached transcripts/captions in read surfaces (get_messages, TUI). */
|
|
39
|
+
inlineTranscripts: z.boolean().default(true),
|
|
40
|
+
/** Confirm before an export triggers more than this many uncached cloud calls. */
|
|
41
|
+
exportConfirmThreshold: z.number().int().nonnegative().default(25),
|
|
42
|
+
chains: ChainsSchema,
|
|
43
|
+
providers: z.array(ProviderConfigSchema).default([]),
|
|
44
|
+
nudge: NudgeSchema
|
|
45
|
+
});
|
|
46
|
+
const AppConfigSchema = z.object({
|
|
47
|
+
/** Glyph preset. "safe" is the universally-renderable default. */
|
|
48
|
+
theme: z.enum(["safe", "powerline"]).default("safe"),
|
|
49
|
+
/** 6-digit hex color used to derive the whole UI palette. */
|
|
50
|
+
accentColor: z.string().regex(HEX6, "must be a 6-digit hex like #RRGGBB").default("#1982FC"),
|
|
51
|
+
/** Media-interpretation config (optional — absent on TUI-only configs). */
|
|
52
|
+
interpret: InterpretConfigSchema.optional()
|
|
53
|
+
});
|
|
54
|
+
const DEFAULT_TUI_CONFIG = {
|
|
55
|
+
theme: "safe",
|
|
56
|
+
accentColor: "#1982FC"
|
|
57
|
+
};
|
|
58
|
+
InterpretConfigSchema.parse({});
|
|
59
|
+
function candidatePaths() {
|
|
60
|
+
const home = homedir();
|
|
61
|
+
const out = [];
|
|
62
|
+
if (process.env.XDG_CONFIG_HOME) {
|
|
63
|
+
out.push(join(process.env.XDG_CONFIG_HOME, "imsg-mcp", "config.json"));
|
|
64
|
+
}
|
|
65
|
+
out.push(join(home, ".config", "imsg-mcp", "config.json"));
|
|
66
|
+
out.push(join(home, ".imsg-mcp", "config.json"));
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
function findTuiConfigPath() {
|
|
70
|
+
for (const p of candidatePaths()) {
|
|
71
|
+
if (existsSync(p)) return p;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
function defaultTuiConfigPath() {
|
|
76
|
+
return candidatePaths()[0] ?? candidatePaths()[1];
|
|
77
|
+
}
|
|
78
|
+
function loadTuiConfig() {
|
|
79
|
+
const warnings = [];
|
|
80
|
+
const path = findTuiConfigPath();
|
|
81
|
+
if (!path) return { config: { ...DEFAULT_TUI_CONFIG }, source: null, warnings };
|
|
82
|
+
let parsed;
|
|
83
|
+
try {
|
|
84
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
85
|
+
} catch (err) {
|
|
86
|
+
warnings.push(
|
|
87
|
+
`config: failed to read ${path} (${err instanceof Error ? err.message : String(err)}); using defaults`
|
|
88
|
+
);
|
|
89
|
+
return { config: { ...DEFAULT_TUI_CONFIG }, source: path, warnings };
|
|
90
|
+
}
|
|
91
|
+
const result = AppConfigSchema.safeParse(parsed);
|
|
92
|
+
if (result.success) return { config: result.data, source: path, warnings };
|
|
93
|
+
const tuiOnly = AppConfigSchema.pick({ theme: true, accentColor: true }).safeParse(parsed);
|
|
94
|
+
const issues = result.error.issues.map((i) => `${i.path.join(".") || "<root>"}: ${i.message}`).join("; ");
|
|
95
|
+
if (tuiOnly.success) {
|
|
96
|
+
warnings.push(`config: ${path} has invalid fields (${issues}); ignoring them`);
|
|
97
|
+
return { config: { ...tuiOnly.data }, source: path, warnings };
|
|
98
|
+
}
|
|
99
|
+
warnings.push(`config: ${path} has invalid fields (${issues}); using defaults`);
|
|
100
|
+
return { config: { ...DEFAULT_TUI_CONFIG }, source: path, warnings };
|
|
101
|
+
}
|
|
102
|
+
function writeTuiConfig(config, path = defaultTuiConfigPath()) {
|
|
103
|
+
const validated = AppConfigSchema.parse(config);
|
|
104
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
105
|
+
writeFileSync(path, `${JSON.stringify(validated, null, 2)}
|
|
106
|
+
`);
|
|
107
|
+
return path;
|
|
108
|
+
}
|
|
109
|
+
function credentialsPath() {
|
|
110
|
+
return join(homedir(), ".imsg-mcp", "credentials.json");
|
|
111
|
+
}
|
|
112
|
+
function readCredentials() {
|
|
113
|
+
const path = credentialsPath();
|
|
114
|
+
if (!existsSync(path)) return {};
|
|
115
|
+
try {
|
|
116
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
117
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
118
|
+
const out = {};
|
|
119
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
120
|
+
if (typeof v === "string") out[k] = v;
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
} catch {
|
|
125
|
+
}
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
function writeCredentials(creds) {
|
|
129
|
+
const path = credentialsPath();
|
|
130
|
+
const dir = dirname(path);
|
|
131
|
+
mkdirSync(dir, { recursive: true });
|
|
132
|
+
try {
|
|
133
|
+
chmodSync(dir, 448);
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
136
|
+
writeFileSync(path, `${JSON.stringify(creds, null, 2)}
|
|
137
|
+
`, { mode: 384 });
|
|
138
|
+
chmodSync(path, 384);
|
|
139
|
+
return path;
|
|
140
|
+
}
|
|
141
|
+
function setCredential(name, key) {
|
|
142
|
+
const creds = readCredentials();
|
|
143
|
+
if (key) creds[name] = key;
|
|
144
|
+
else delete creds[name];
|
|
145
|
+
writeCredentials(creds);
|
|
146
|
+
}
|
|
147
|
+
function resolveTuiConfig(overrides = {}) {
|
|
148
|
+
const loaded = loadTuiConfig();
|
|
149
|
+
const warnings = [...loaded.warnings];
|
|
150
|
+
let theme = loaded.config.theme;
|
|
151
|
+
let themeOrigin = loaded.source ? "config" : "default";
|
|
152
|
+
if (process.env.IMSG_TUI_THEME) {
|
|
153
|
+
const t = process.env.IMSG_TUI_THEME;
|
|
154
|
+
if (t === "safe" || t === "powerline") {
|
|
155
|
+
theme = t;
|
|
156
|
+
themeOrigin = "env";
|
|
157
|
+
} else {
|
|
158
|
+
warnings.push(`IMSG_TUI_THEME="${t}" is not "safe" or "powerline"; ignoring`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (overrides.cliTheme !== void 0) {
|
|
162
|
+
if (overrides.cliTheme === "safe" || overrides.cliTheme === "powerline") {
|
|
163
|
+
theme = overrides.cliTheme;
|
|
164
|
+
themeOrigin = "cli";
|
|
165
|
+
} else {
|
|
166
|
+
warnings.push(`--theme="${overrides.cliTheme}" is not "safe" or "powerline"; ignoring`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
let accentColor = loaded.config.accentColor;
|
|
170
|
+
let accentOrigin = loaded.source ? "config" : "default";
|
|
171
|
+
if (process.env.IMSG_TUI_ACCENT) {
|
|
172
|
+
if (HEX6.test(process.env.IMSG_TUI_ACCENT)) {
|
|
173
|
+
accentColor = process.env.IMSG_TUI_ACCENT;
|
|
174
|
+
accentOrigin = "env";
|
|
175
|
+
} else {
|
|
176
|
+
warnings.push(
|
|
177
|
+
`IMSG_TUI_ACCENT="${process.env.IMSG_TUI_ACCENT}" is not a 6-digit hex; ignoring`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (overrides.cliAccent !== void 0) {
|
|
182
|
+
if (HEX6.test(overrides.cliAccent)) {
|
|
183
|
+
accentColor = overrides.cliAccent;
|
|
184
|
+
accentOrigin = "cli";
|
|
185
|
+
} else {
|
|
186
|
+
warnings.push(`--accent="${overrides.cliAccent}" is not a 6-digit hex; ignoring`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
theme,
|
|
191
|
+
accentColor,
|
|
192
|
+
origin: { theme: themeOrigin, accentColor: accentOrigin },
|
|
193
|
+
configPath: loaded.source,
|
|
194
|
+
warnings
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export {
|
|
198
|
+
AppConfigSchema as A,
|
|
199
|
+
DEFAULT_TUI_CONFIG as D,
|
|
200
|
+
InterpretConfigSchema as I,
|
|
201
|
+
readCredentials as a,
|
|
202
|
+
writeCredentials as b,
|
|
203
|
+
credentialsPath as c,
|
|
204
|
+
defaultTuiConfigPath as d,
|
|
205
|
+
findTuiConfigPath as f,
|
|
206
|
+
loadTuiConfig as l,
|
|
207
|
+
resolveTuiConfig as r,
|
|
208
|
+
setCredential as s,
|
|
209
|
+
writeTuiConfig as w
|
|
210
|
+
};
|
|
211
|
+
//# sourceMappingURL=app-config-CVixby2Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-config-CVixby2Z.js","sources":["../src/app-config.ts"],"sourcesContent":["/**\n * Canonical persistent configuration for imsg-mcp — one JSON file that carries\n * both the flat TUI keys (theme / accentColor) AND the `interpret` block that\n * configures media interpretation (Stage 2 core: chains, providers, toggles).\n *\n * Resolution order (first one found wins) — unchanged from the original\n * tui-config module so existing files keep loading:\n * 1. $XDG_CONFIG_HOME/imsg-mcp/config.json\n * 2. $HOME/.config/imsg-mcp/config.json\n * 3. $HOME/.imsg-mcp/config.json (matches the slugs.db location)\n *\n * `src/tui-config.ts` re-exports this module verbatim for back-compat.\n *\n * API keys are NEVER stored in config.json. They live in\n * `~/.imsg-mcp/credentials.json` (chmod 600, `{ \"<providerName>\": \"sk-…\" }`)\n * or the legacy `IMSG_TRANSCRIBE_*` env vars, and are merged into providers only\n * at resolution time (`resolveInterpretConfig`).\n */\n\nimport { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { z } from \"zod\";\nimport { getTranscribeCloudConfig } from \"./config.js\";\nimport type { AutoMode, InterpretChains, InterpretConfig } from \"./media-intel.js\";\nimport type { ProviderConfig, ProviderPreset } from \"./media-providers.js\";\n\n// ── Schema ────────────────────────────────────────────────────────────────\n\nconst HEX6 = /^#[0-9a-fA-F]{6}$/;\n\n/** Preset names accepted in the `interpret.providers[].preset` field. Kept as a\n * literal tuple so Zod can build an enum without a runtime import of the\n * providers module (and asserted to stay in sync with `ProviderPreset`). */\nconst PROVIDER_PRESET_NAMES = [\n \"openai\",\n \"groq\",\n \"openrouter\",\n \"cloudflare\",\n \"huggingface\",\n \"ollama\",\n] as const satisfies readonly ProviderPreset[];\n\nconst ProviderModelsSchema = z\n .object({ transcribe: z.string().optional(), vision: z.string().optional() })\n .optional();\n\n/** A provider profile as stored in config.json — NO apiKey (that lives in\n * credentials.json / env and is merged in at resolution time). */\nconst ProviderConfigSchema = z\n .object({\n name: z.string().min(1),\n preset: z.enum(PROVIDER_PRESET_NAMES).optional(),\n baseUrl: z.string().url().optional(),\n accountId: z.string().optional(),\n models: ProviderModelsSchema,\n })\n .refine((p) => Boolean(p.preset) || Boolean(p.baseUrl), {\n message: \"provider needs either a preset or a baseUrl\",\n });\n\nconst ChainsSchema = z\n .object({\n audio: z.array(z.string()).default([\"apple\", \"local\"]),\n image: z.array(z.string()).default([]),\n video: z.array(z.string()).default([]),\n })\n .default({});\n\nconst NudgeSchema = z\n .object({\n enabled: z.boolean().default(true),\n tier2SyncNow: z.boolean().default(false),\n timeoutSeconds: z.number().int().positive().default(30),\n })\n .default({});\n\nexport const InterpretConfigSchema = z.object({\n /** Auto-interpretation gate. \"free\" (default) never makes a paid call without\n * an explicit force; \"all\" runs the full chain incl. cloud; \"off\" disables. */\n auto: z.enum([\"all\", \"free\", \"off\"]).default(\"free\"),\n /** Inline cached transcripts/captions in read surfaces (get_messages, TUI). */\n inlineTranscripts: z.boolean().default(true),\n /** Confirm before an export triggers more than this many uncached cloud calls. */\n exportConfirmThreshold: z.number().int().nonnegative().default(25),\n chains: ChainsSchema,\n providers: z.array(ProviderConfigSchema).default([]),\n nudge: NudgeSchema,\n});\n\nexport const AppConfigSchema = z.object({\n /** Glyph preset. \"safe\" is the universally-renderable default. */\n theme: z.enum([\"safe\", \"powerline\"]).default(\"safe\"),\n /** 6-digit hex color used to derive the whole UI palette. */\n accentColor: z.string().regex(HEX6, \"must be a 6-digit hex like #RRGGBB\").default(\"#1982FC\"),\n /** Media-interpretation config (optional — absent on TUI-only configs). */\n interpret: InterpretConfigSchema.optional(),\n});\n\nexport type AppConfig = z.infer<typeof AppConfigSchema>;\nexport type InterpretConfigInput = z.infer<typeof InterpretConfigSchema>;\n\n/** Back-compat alias — the TUI only ever reads theme/accentColor. */\nexport const TuiConfigSchema = AppConfigSchema;\nexport type TuiConfig = AppConfig;\n\nexport const DEFAULT_TUI_CONFIG: TuiConfig = {\n theme: \"safe\",\n accentColor: \"#1982FC\",\n};\n\n/** Free-first interpret defaults used when the block is absent from config. */\nexport const DEFAULT_INTERPRET_CONFIG: InterpretConfigInput = InterpretConfigSchema.parse({});\n\n// ── Path resolution ───────────────────────────────────────────────────────\n\n/** Candidate paths we try to read from, in order. */\nfunction candidatePaths(): string[] {\n const home = homedir();\n const out: string[] = [];\n if (process.env.XDG_CONFIG_HOME) {\n out.push(join(process.env.XDG_CONFIG_HOME, \"imsg-mcp\", \"config.json\"));\n }\n out.push(join(home, \".config\", \"imsg-mcp\", \"config.json\"));\n out.push(join(home, \".imsg-mcp\", \"config.json\"));\n return out;\n}\n\n/** Where the file actually lives (first existing candidate), or null. */\nexport function findTuiConfigPath(): string | null {\n for (const p of candidatePaths()) {\n if (existsSync(p)) return p;\n }\n return null;\n}\n\n/** Where to write a fresh config file. Returns the *first* candidate so\n * XDG-style wins on a clean machine. */\nexport function defaultTuiConfigPath(): string {\n return candidatePaths()[0] ?? candidatePaths()[1];\n}\n\n// ── Loader ────────────────────────────────────────────────────────────────\n\nexport interface LoadedTuiConfig {\n config: AppConfig;\n /** Path of the file we read from, or `null` if defaults were used. */\n source: string | null;\n /** Human-readable warnings (parse errors, schema errors). Empty when clean. */\n warnings: string[];\n}\n\nexport function loadTuiConfig(): LoadedTuiConfig {\n const warnings: string[] = [];\n const path = findTuiConfigPath();\n if (!path) return { config: { ...DEFAULT_TUI_CONFIG }, source: null, warnings };\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(path, \"utf8\"));\n } catch (err) {\n warnings.push(\n `config: failed to read ${path} (${err instanceof Error ? err.message : String(err)}); using defaults`,\n );\n return { config: { ...DEFAULT_TUI_CONFIG }, source: path, warnings };\n }\n\n const result = AppConfigSchema.safeParse(parsed);\n if (result.success) return { config: result.data, source: path, warnings };\n\n // Full parse failed. Degrade gracefully: if the flat TUI keys alone are valid,\n // keep them (a malformed `interpret` block should not blow away the theme).\n const tuiOnly = AppConfigSchema.pick({ theme: true, accentColor: true }).safeParse(parsed);\n const issues = result.error.issues\n .map((i) => `${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"; \");\n if (tuiOnly.success) {\n warnings.push(`config: ${path} has invalid fields (${issues}); ignoring them`);\n return { config: { ...tuiOnly.data }, source: path, warnings };\n }\n warnings.push(`config: ${path} has invalid fields (${issues}); using defaults`);\n return { config: { ...DEFAULT_TUI_CONFIG }, source: path, warnings };\n}\n\n// ── Writer (used by `imsg config edit` + `imsg setup`) ────────────────────\n\nexport function writeTuiConfig(config: AppConfig, path = defaultTuiConfigPath()): string {\n // Validate before writing so we never persist garbage.\n const validated = AppConfigSchema.parse(config);\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, `${JSON.stringify(validated, null, 2)}\\n`);\n return path;\n}\n\n// ── Credentials (chmod 600) ───────────────────────────────────────────────\n\n/** `~/.imsg-mcp/credentials.json` — `{ \"<providerName>\": \"<apiKey>\" }`. */\nexport function credentialsPath(): string {\n return join(homedir(), \".imsg-mcp\", \"credentials.json\");\n}\n\nexport function readCredentials(): Record<string, string> {\n const path = credentialsPath();\n if (!existsSync(path)) return {};\n try {\n const parsed = JSON.parse(readFileSync(path, \"utf8\"));\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(parsed)) {\n if (typeof v === \"string\") out[k] = v;\n }\n return out;\n }\n } catch {\n // Corrupt credentials file — treat as empty (never throw on read).\n }\n return {};\n}\n\n/** Write the whole credentials map, enforcing 0600 on the file (and 0700 dir). */\nexport function writeCredentials(creds: Record<string, string>): string {\n const path = credentialsPath();\n const dir = dirname(path);\n mkdirSync(dir, { recursive: true });\n try {\n chmodSync(dir, 0o700);\n } catch {\n // Best-effort — a shared dir may already exist with other perms.\n }\n writeFileSync(path, `${JSON.stringify(creds, null, 2)}\\n`, { mode: 0o600 });\n // writeFileSync's `mode` is masked by umask on CREATE and ignored when the\n // file already exists — chmod unconditionally so 0600 is guaranteed.\n chmodSync(path, 0o600);\n return path;\n}\n\n/** Set (or clear, when key is empty) one provider's credential. */\nexport function setCredential(name: string, key: string): void {\n const creds = readCredentials();\n if (key) creds[name] = key;\n else delete creds[name];\n writeCredentials(creds);\n}\n\n// ── Interpret-config resolution (config + credentials + env → service) ─────\n\n/** The env-mapped implicit provider name (legacy IMSG_TRANSCRIBE_* path). */\nexport const ENV_PROVIDER_NAME = \"env\";\n\n/** Interpret config ready for `MediaIntelService`, plus the surfacing toggles\n * that frontends (Stage 4/6/7) read. Providers carry their merged apiKey. */\nexport interface ResolvedInterpretConfig extends InterpretConfig {\n inlineTranscripts: boolean;\n exportConfirmThreshold: number;\n nudge: { enabled: boolean; tier2SyncNow: boolean; timeoutSeconds: number };\n /** Where the config was read from (null = defaults). */\n configPath: string | null;\n warnings: string[];\n}\n\n/**\n * Resolve the full interpret configuration:\n * - start from the config file's `interpret` block (or free-first defaults),\n * - merge API keys from credentials.json into each named provider,\n * - map the legacy `IMSG_TRANSCRIBE_*` env vars to an implicit `env` provider\n * (and append `provider:env` to the audio chain if it has no provider yet),\n * preserving the shipped v1.7.0 cloud-transcription fallback.\n */\nexport function resolveInterpretConfig(): ResolvedInterpretConfig {\n const loaded = loadTuiConfig();\n const warnings = [...loaded.warnings];\n const block = InterpretConfigSchema.parse(loaded.config.interpret ?? {});\n const creds = readCredentials();\n\n const providers: ProviderConfig[] = block.providers.map((p) => ({\n ...p,\n apiKey: creds[p.name],\n }));\n const chains: InterpretChains = {\n audio: [...block.chains.audio],\n image: [...block.chains.image],\n video: [...block.chains.video],\n };\n\n // Legacy env fallback → implicit provider, if not already configured by name.\n const envCloud = getTranscribeCloudConfig();\n if (envCloud && !providers.some((p) => p.name === ENV_PROVIDER_NAME)) {\n providers.push({\n name: ENV_PROVIDER_NAME,\n baseUrl: envCloud.baseUrl,\n apiKey: envCloud.apiKey,\n models: { transcribe: envCloud.model },\n });\n if (!chains.audio.some((l) => l.startsWith(\"provider:\"))) {\n chains.audio.push(`provider:${ENV_PROVIDER_NAME}`);\n }\n }\n\n const auto: AutoMode = block.auto;\n return {\n auto,\n chains,\n providers,\n inlineTranscripts: block.inlineTranscripts,\n exportConfirmThreshold: block.exportConfirmThreshold,\n nudge: block.nudge,\n configPath: loaded.source,\n warnings,\n };\n}\n\n// ── Layered resolution (CLI > env > config > defaults) — TUI theme/accent ──\n\nexport interface TuiConfigOverrides {\n /** From `imsg --theme=...` */\n cliTheme?: string;\n /** From `imsg --accent=...` */\n cliAccent?: string;\n}\n\nexport interface ResolvedTuiConfig {\n theme: TuiConfig[\"theme\"];\n accentColor: string;\n /** Where each value came from, useful for `imsg config show`. */\n origin: {\n theme: \"cli\" | \"env\" | \"config\" | \"default\";\n accentColor: \"cli\" | \"env\" | \"config\" | \"default\";\n };\n /** The on-disk file path that contributed (or `null` if no file). */\n configPath: string | null;\n /** Any warnings raised during loading (malformed file, invalid env, etc). */\n warnings: string[];\n}\n\nexport function resolveTuiConfig(overrides: TuiConfigOverrides = {}): ResolvedTuiConfig {\n const loaded = loadTuiConfig();\n const warnings = [...loaded.warnings];\n\n // Theme precedence: CLI > env > config > default\n let theme: TuiConfig[\"theme\"] = loaded.config.theme;\n let themeOrigin: ResolvedTuiConfig[\"origin\"][\"theme\"] = loaded.source ? \"config\" : \"default\";\n\n if (process.env.IMSG_TUI_THEME) {\n const t = process.env.IMSG_TUI_THEME;\n if (t === \"safe\" || t === \"powerline\") {\n theme = t;\n themeOrigin = \"env\";\n } else {\n warnings.push(`IMSG_TUI_THEME=\"${t}\" is not \"safe\" or \"powerline\"; ignoring`);\n }\n }\n if (overrides.cliTheme !== undefined) {\n if (overrides.cliTheme === \"safe\" || overrides.cliTheme === \"powerline\") {\n theme = overrides.cliTheme;\n themeOrigin = \"cli\";\n } else {\n warnings.push(`--theme=\"${overrides.cliTheme}\" is not \"safe\" or \"powerline\"; ignoring`);\n }\n }\n\n // Accent precedence: CLI > env > config > default\n let accentColor = loaded.config.accentColor;\n let accentOrigin: ResolvedTuiConfig[\"origin\"][\"accentColor\"] = loaded.source\n ? \"config\"\n : \"default\";\n\n if (process.env.IMSG_TUI_ACCENT) {\n if (HEX6.test(process.env.IMSG_TUI_ACCENT)) {\n accentColor = process.env.IMSG_TUI_ACCENT;\n accentOrigin = \"env\";\n } else {\n warnings.push(\n `IMSG_TUI_ACCENT=\"${process.env.IMSG_TUI_ACCENT}\" is not a 6-digit hex; ignoring`,\n );\n }\n }\n if (overrides.cliAccent !== undefined) {\n if (HEX6.test(overrides.cliAccent)) {\n accentColor = overrides.cliAccent;\n accentOrigin = \"cli\";\n } else {\n warnings.push(`--accent=\"${overrides.cliAccent}\" is not a 6-digit hex; ignoring`);\n }\n }\n\n return {\n theme,\n accentColor,\n origin: { theme: themeOrigin, accentColor: accentOrigin },\n configPath: loaded.source,\n warnings,\n };\n}\n"],"names":[],"mappings":";;;;AA6BA,MAAM,OAAO;AAKb,MAAM,wBAAwB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,uBAAuB,EAC1B,OAAO,EAAE,YAAY,EAAE,SAAS,SAAA,GAAY,QAAQ,EAAE,OAAA,EAAS,WAAS,CAAG,EAC3E,SAAA;AAIH,MAAM,uBAAuB,EAC1B,OAAO;AAAA,EACN,MAAM,EAAE,SAAS,IAAI,CAAC;AAAA,EACtB,QAAQ,EAAE,KAAK,qBAAqB,EAAE,SAAA;AAAA,EACtC,SAAS,EAAE,OAAA,EAAS,IAAA,EAAM,SAAA;AAAA,EAC1B,WAAW,EAAE,OAAA,EAAS,SAAA;AAAA,EACtB,QAAQ;AACV,CAAC,EACA,OAAO,CAAC,MAAM,QAAQ,EAAE,MAAM,KAAK,QAAQ,EAAE,OAAO,GAAG;AAAA,EACtD,SAAS;AACX,CAAC;AAEH,MAAM,eAAe,EAClB,OAAO;AAAA,EACN,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,OAAO,CAAC;AAAA,EACrD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE;AAAA,EACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAA,C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GED
|
@@ -3,8 +3,8 @@ import { existsSync, realpathSync } from "node:fs";
|
|
|
3
3
|
import { createInterface } from "node:readline";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import { Command } from "commander";
|
|
6
|
-
import { c as checkLocalAccess, f as formatAccessReport,
|
|
7
|
-
import { A as APP_VERSION, t as toYaml } from "./meta-
|
|
6
|
+
import { c as checkLocalAccess, f as formatAccessReport, I as IMPLEMENTED_TYPES, A as ANALYTIC_INFO, i as installShutdownHandlers, r as registerCleanup, l as looksLikeThreadSlug } from "./shutdown-CjDoFsTF.js";
|
|
7
|
+
import { A as APP_VERSION, t as toYaml } from "./meta-BA-d51LM.js";
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
9
|
import { join, dirname } from "node:path";
|
|
10
10
|
function distRoot() {
|
|
@@ -446,9 +446,9 @@ async function runExportCommand(target, opts) {
|
|
|
446
446
|
const { existsSync: existsSync2, mkdirSync, copyFileSync, statSync } = await import("node:fs");
|
|
447
447
|
const { homedir } = await import("node:os");
|
|
448
448
|
const { dirname: dirname2, join: join2, isAbsolute, resolve } = await import("node:path");
|
|
449
|
-
const { getContactsDbPaths, getImsgDbPath, getSlugsDbPath } = await import("./shutdown-
|
|
450
|
-
const { IMessageDB } = await import("./imessage-db-
|
|
451
|
-
const { streamExport } = await import("./exportStream-
|
|
449
|
+
const { getContactsDbPaths, getImsgDbPath, getSlugsDbPath } = await import("./shutdown-CjDoFsTF.js").then((n) => n.a0);
|
|
450
|
+
const { IMessageDB } = await import("./imessage-db-CbI0AYGw.js").then((n) => n.i);
|
|
451
|
+
const { streamExport } = await import("./exportStream-Dp5KKwtE.js");
|
|
452
452
|
const { parseUserDate } = await import("./date-parse-DJXMfq3a.js");
|
|
453
453
|
const format = normalizeFormat(opts.format ?? "md");
|
|
454
454
|
const ext = extForFormat(format);
|
|
@@ -694,49 +694,65 @@ program.command("tui").description("Launch the read-only terminal UI").option("-
|
|
|
694
694
|
await runTui();
|
|
695
695
|
});
|
|
696
696
|
program.command("export <target>").description("Export a conversation to a file (md/csv/json/ndjson)").option("-f, --format <fmt>", "Output format: md (default), csv, json, ndjson", "md").option("--since <date>", "Earliest date (ISO or relative, e.g. '3 months ago')").option("--until <date>", "Latest date (ISO or relative)").option("-o, --output <path>", "Output path (default: ~/imsg-export-<target>-<YYYY-MM-DD>.<ext>)").option("--include-attachments", "Copy attachments next to the export").option("--attachments-dir <path>", "Where to copy attachments (default: <output>.attachments/)").option("--page-size <n>", "Messages per DB page (100-5000)", "1000").action(runExportCommand);
|
|
697
|
-
program.command("setup").description("Autodetect DB paths and emit an MCP host config snippet").option("-w, --write <host>", 'Write into a host config: "claude" or "cursor"').option("-r, --runtime <runtime>", 'Runtime command: "npx" (default), "bunx", or "global"').option("--print-only", "Just print the snippet (default behaviour)").
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (opts.write !== "claude" && opts.write !== "cursor") {
|
|
722
|
-
log(`✗ unknown host: ${opts.write} (expected "claude" or "cursor")`, "err");
|
|
697
|
+
program.command("setup").description("Autodetect DB paths and emit an MCP host config snippet").option("-w, --write <host>", 'Write into a host config: "claude" or "cursor"').option("-r, --runtime <runtime>", 'Runtime command: "npx" (default), "bunx", or "global"').option("--print-only", "Just print the snippet (default behaviour)").option("-i, --interactive", "Configure media interpretation (providers, chains, keys)").action(
|
|
698
|
+
async (opts) => {
|
|
699
|
+
if (opts.interactive) {
|
|
700
|
+
const { runSetupWizard } = await import("./setup-wizard-Z6_0P-yc.js");
|
|
701
|
+
try {
|
|
702
|
+
await runSetupWizard();
|
|
703
|
+
} catch (err) {
|
|
704
|
+
if (err instanceof Error && err.name === "ExitPromptError") {
|
|
705
|
+
log("setup cancelled", "warn");
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
throw err;
|
|
709
|
+
}
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
const { probeMachine, buildMcpSnippet, writeHostConfig } = await import("./setup-Tpk356yq.js");
|
|
713
|
+
const report = probeMachine();
|
|
714
|
+
if (!report.imsgDb.readable) {
|
|
715
|
+
log(`✗ Messages DB is not readable: ${report.imsgDb.path}`, "err");
|
|
716
|
+
log(` ${report.imsgDb.error ?? ""}`, "err");
|
|
717
|
+
log(
|
|
718
|
+
" Grant Full Disk Access to the running app: System Settings → Privacy & Security → Full Disk Access",
|
|
719
|
+
"warn"
|
|
720
|
+
);
|
|
723
721
|
process.exitCode = 1;
|
|
724
722
|
return;
|
|
725
723
|
}
|
|
726
|
-
|
|
724
|
+
log(`✓ Messages DB readable: ${report.imsgDb.path}`, "ok");
|
|
727
725
|
log(
|
|
728
|
-
`✓
|
|
726
|
+
`✓ Address Book: ${report.contactsDbs.length} source(s), ${report.contactsDbs.filter((p) => p.readable).length} readable`,
|
|
729
727
|
"ok"
|
|
730
728
|
);
|
|
731
|
-
log(
|
|
732
|
-
|
|
729
|
+
log(
|
|
730
|
+
` slugs.db: ${report.slugsDb.path} ${report.slugsDb.exists ? "(exists)" : "(will be created on first run)"}`
|
|
731
|
+
);
|
|
732
|
+
const runtime = opts.runtime === "bunx" || opts.runtime === "global" ? opts.runtime : "npx";
|
|
733
|
+
const snippet = buildMcpSnippet(report, { runtime });
|
|
734
|
+
if (opts.write) {
|
|
735
|
+
if (opts.write !== "claude" && opts.write !== "cursor") {
|
|
736
|
+
log(`✗ unknown host: ${opts.write} (expected "claude" or "cursor")`, "err");
|
|
737
|
+
process.exitCode = 1;
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
const result = writeHostConfig(opts.write, report, { runtime });
|
|
741
|
+
log(
|
|
742
|
+
`✓ wrote ${opts.write} config to ${result.path}${result.replaced ? " (replaced existing imessage entry)" : ""}`,
|
|
743
|
+
"ok"
|
|
744
|
+
);
|
|
745
|
+
log(` backup of any prior file at ${result.path}.bak`);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
log("--- snippet ---", "dim");
|
|
749
|
+
process.stdout.write(snippet);
|
|
750
|
+
log("tip: run `imsg setup --interactive` to configure media interpretation", "dim");
|
|
733
751
|
}
|
|
734
|
-
|
|
735
|
-
process.stdout.write(snippet);
|
|
736
|
-
});
|
|
752
|
+
);
|
|
737
753
|
const configCmd = program.command("config").description("Manage TUI settings (theme, accent color)");
|
|
738
754
|
configCmd.command("show").description("Print resolved TUI settings and where each value came from").action(async () => {
|
|
739
|
-
const { resolveTuiConfig, defaultTuiConfigPath } = await import("./tui-config-
|
|
755
|
+
const { resolveTuiConfig, defaultTuiConfigPath } = await import("./tui-config-DWD0O2SW.js");
|
|
740
756
|
const cfg = resolveTuiConfig();
|
|
741
757
|
log(
|
|
742
758
|
`config file : ${cfg.configPath ?? `(none — defaults; would write to ${defaultTuiConfigPath()})`}`
|
|
@@ -749,7 +765,7 @@ configCmd.command("show").description("Print resolved TUI settings and where eac
|
|
|
749
765
|
for (const w of cfg.warnings) log(w, "warn");
|
|
750
766
|
});
|
|
751
767
|
configCmd.command("edit").description("Open the TUI config file in $EDITOR (creates it if missing)").action(async () => {
|
|
752
|
-
const { defaultTuiConfigPath, findTuiConfigPath, writeTuiConfig, DEFAULT_TUI_CONFIG } = await import("./tui-config-
|
|
768
|
+
const { defaultTuiConfigPath, findTuiConfigPath, writeTuiConfig, DEFAULT_TUI_CONFIG } = await import("./tui-config-DWD0O2SW.js");
|
|
753
769
|
const path = findTuiConfigPath() ?? defaultTuiConfigPath();
|
|
754
770
|
const { existsSync: existsSync2 } = await import("node:fs");
|
|
755
771
|
if (!existsSync2(path)) {
|