@murphai/murph 0.1.1
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 +2009 -0
- package/LICENSE +674 -0
- package/README.md +97 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/assistant/automation/run-loop.d.ts +21 -0
- package/dist/assistant/automation/run-loop.d.ts.map +1 -0
- package/dist/assistant/automation/run-loop.js +31 -0
- package/dist/assistant/automation/run-loop.js.map +1 -0
- package/dist/assistant/automation.d.ts +10 -0
- package/dist/assistant/automation.d.ts.map +1 -0
- package/dist/assistant/automation.js +5 -0
- package/dist/assistant/automation.js.map +1 -0
- package/dist/assistant/cron.d.ts +19 -0
- package/dist/assistant/cron.d.ts.map +1 -0
- package/dist/assistant/cron.js +59 -0
- package/dist/assistant/cron.js.map +1 -0
- package/dist/assistant/doctor-security.d.ts +15 -0
- package/dist/assistant/doctor-security.d.ts.map +1 -0
- package/dist/assistant/doctor-security.js +172 -0
- package/dist/assistant/doctor-security.js.map +1 -0
- package/dist/assistant/doctor.d.ts +5 -0
- package/dist/assistant/doctor.d.ts.map +1 -0
- package/dist/assistant/doctor.js +527 -0
- package/dist/assistant/doctor.js.map +1 -0
- package/dist/assistant/outbox.d.ts +19 -0
- package/dist/assistant/outbox.d.ts.map +1 -0
- package/dist/assistant/outbox.js +28 -0
- package/dist/assistant/outbox.js.map +1 -0
- package/dist/assistant/provider-catalog.d.ts +61 -0
- package/dist/assistant/provider-catalog.d.ts.map +1 -0
- package/dist/assistant/provider-catalog.js +205 -0
- package/dist/assistant/provider-catalog.js.map +1 -0
- package/dist/assistant/service.d.ts +85 -0
- package/dist/assistant/service.d.ts.map +1 -0
- package/dist/assistant/service.js +26 -0
- package/dist/assistant/service.js.map +1 -0
- package/dist/assistant/status.d.ts +9 -0
- package/dist/assistant/status.d.ts.map +1 -0
- package/dist/assistant/status.js +16 -0
- package/dist/assistant/status.js.map +1 -0
- package/dist/assistant/stop.d.ts +20 -0
- package/dist/assistant/stop.d.ts.map +1 -0
- package/dist/assistant/stop.js +142 -0
- package/dist/assistant/stop.js.map +1 -0
- package/dist/assistant/store.d.ts +6 -0
- package/dist/assistant/store.d.ts.map +1 -0
- package/dist/assistant/store.js +21 -0
- package/dist/assistant/store.js.map +1 -0
- package/dist/assistant/ui/ink.d.ts +247 -0
- package/dist/assistant/ui/ink.d.ts.map +1 -0
- package/dist/assistant/ui/ink.js +2417 -0
- package/dist/assistant/ui/ink.js.map +1 -0
- package/dist/assistant/ui/theme.d.ts +64 -0
- package/dist/assistant/ui/theme.d.ts.map +1 -0
- package/dist/assistant/ui/theme.js +180 -0
- package/dist/assistant/ui/theme.js.map +1 -0
- package/dist/assistant/ui/view-model.d.ts +89 -0
- package/dist/assistant/ui/view-model.d.ts.map +1 -0
- package/dist/assistant/ui/view-model.js +298 -0
- package/dist/assistant/ui/view-model.js.map +1 -0
- package/dist/assistant-chat-ink.d.ts +2 -0
- package/dist/assistant-chat-ink.d.ts.map +1 -0
- package/dist/assistant-chat-ink.js +2 -0
- package/dist/assistant-chat-ink.js.map +1 -0
- package/dist/assistant-daemon-client.d.ts +81 -0
- package/dist/assistant-daemon-client.d.ts.map +1 -0
- package/dist/assistant-daemon-client.js +473 -0
- package/dist/assistant-daemon-client.js.map +1 -0
- package/dist/assistant-runtime.d.ts +25 -0
- package/dist/assistant-runtime.d.ts.map +1 -0
- package/dist/assistant-runtime.js +17 -0
- package/dist/assistant-runtime.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +7 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli-entry.d.ts +10 -0
- package/dist/cli-entry.d.ts.map +1 -0
- package/dist/cli-entry.js +127 -0
- package/dist/cli-entry.js.map +1 -0
- package/dist/commands/assistant.d.ts +5 -0
- package/dist/commands/assistant.d.ts.map +1 -0
- package/dist/commands/assistant.js +1663 -0
- package/dist/commands/assistant.js.map +1 -0
- package/dist/commands/audit-command-helpers.d.ts +15 -0
- package/dist/commands/audit-command-helpers.d.ts.map +1 -0
- package/dist/commands/audit-command-helpers.js +24 -0
- package/dist/commands/audit-command-helpers.js.map +1 -0
- package/dist/commands/audit.d.ts +4 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +107 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/device.d.ts +4 -0
- package/dist/commands/device.d.ts.map +1 -0
- package/dist/commands/device.js +177 -0
- package/dist/commands/device.js.map +1 -0
- package/dist/commands/document.d.ts +4 -0
- package/dist/commands/document.d.ts.map +1 -0
- package/dist/commands/document.js +117 -0
- package/dist/commands/document.js.map +1 -0
- package/dist/commands/event.d.ts +4 -0
- package/dist/commands/event.d.ts.map +1 -0
- package/dist/commands/event.js +136 -0
- package/dist/commands/event.js.map +1 -0
- package/dist/commands/experiment.d.ts +4 -0
- package/dist/commands/experiment.d.ts.map +1 -0
- package/dist/commands/experiment.js +140 -0
- package/dist/commands/experiment.js.map +1 -0
- package/dist/commands/export-intake-read-helpers.d.ts +150 -0
- package/dist/commands/export-intake-read-helpers.d.ts.map +1 -0
- package/dist/commands/export-intake-read-helpers.js +328 -0
- package/dist/commands/export-intake-read-helpers.js.map +1 -0
- package/dist/commands/export.d.ts +4 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +179 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/food.d.ts +4 -0
- package/dist/commands/food.d.ts.map +1 -0
- package/dist/commands/food.js +190 -0
- package/dist/commands/food.js.map +1 -0
- package/dist/commands/health-command-factory.d.ts +230 -0
- package/dist/commands/health-command-factory.d.ts.map +1 -0
- package/dist/commands/health-command-factory.js +551 -0
- package/dist/commands/health-command-factory.js.map +1 -0
- package/dist/commands/health-entity-command-registry.d.ts +27 -0
- package/dist/commands/health-entity-command-registry.d.ts.map +1 -0
- package/dist/commands/health-entity-command-registry.js +84 -0
- package/dist/commands/health-entity-command-registry.js.map +1 -0
- package/dist/commands/inbox.d.ts +5 -0
- package/dist/commands/inbox.d.ts.map +1 -0
- package/dist/commands/inbox.js +841 -0
- package/dist/commands/inbox.js.map +1 -0
- package/dist/commands/intake.d.ts +4 -0
- package/dist/commands/intake.d.ts.map +1 -0
- package/dist/commands/intake.js +175 -0
- package/dist/commands/intake.js.map +1 -0
- package/dist/commands/intervention.d.ts +4 -0
- package/dist/commands/intervention.d.ts.map +1 -0
- package/dist/commands/intervention.js +122 -0
- package/dist/commands/intervention.js.map +1 -0
- package/dist/commands/journal.d.ts +12 -0
- package/dist/commands/journal.d.ts.map +1 -0
- package/dist/commands/journal.js +186 -0
- package/dist/commands/journal.js.map +1 -0
- package/dist/commands/meal.d.ts +4 -0
- package/dist/commands/meal.d.ts.map +1 -0
- package/dist/commands/meal.js +123 -0
- package/dist/commands/meal.js.map +1 -0
- package/dist/commands/profile.d.ts +4 -0
- package/dist/commands/profile.d.ts.map +1 -0
- package/dist/commands/profile.js +62 -0
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/protocol.d.ts +4 -0
- package/dist/commands/protocol.d.ts.map +1 -0
- package/dist/commands/protocol.js +79 -0
- package/dist/commands/protocol.js.map +1 -0
- package/dist/commands/provider.d.ts +4 -0
- package/dist/commands/provider.d.ts.map +1 -0
- package/dist/commands/provider.js +115 -0
- package/dist/commands/provider.js.map +1 -0
- package/dist/commands/read.d.ts +4 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +55 -0
- package/dist/commands/read.js.map +1 -0
- package/dist/commands/recipe.d.ts +4 -0
- package/dist/commands/recipe.d.ts.map +1 -0
- package/dist/commands/recipe.js +116 -0
- package/dist/commands/recipe.js.map +1 -0
- package/dist/commands/record-mutation-command-helpers.d.ts +196 -0
- package/dist/commands/record-mutation-command-helpers.d.ts.map +1 -0
- package/dist/commands/record-mutation-command-helpers.js +150 -0
- package/dist/commands/record-mutation-command-helpers.js.map +1 -0
- package/dist/commands/research.d.ts +3 -0
- package/dist/commands/research.d.ts.map +1 -0
- package/dist/commands/research.js +104 -0
- package/dist/commands/research.js.map +1 -0
- package/dist/commands/sample-batch-command-helpers.d.ts +24 -0
- package/dist/commands/sample-batch-command-helpers.d.ts.map +1 -0
- package/dist/commands/sample-batch-command-helpers.js +99 -0
- package/dist/commands/sample-batch-command-helpers.js.map +1 -0
- package/dist/commands/sample-import-command-helpers.d.ts +24 -0
- package/dist/commands/sample-import-command-helpers.d.ts.map +1 -0
- package/dist/commands/sample-import-command-helpers.js +49 -0
- package/dist/commands/sample-import-command-helpers.js.map +1 -0
- package/dist/commands/sample-query-command-helpers.d.ts +11 -0
- package/dist/commands/sample-query-command-helpers.d.ts.map +1 -0
- package/dist/commands/sample-query-command-helpers.js +26 -0
- package/dist/commands/sample-query-command-helpers.js.map +1 -0
- package/dist/commands/samples.d.ts +4 -0
- package/dist/commands/samples.d.ts.map +1 -0
- package/dist/commands/samples.js +261 -0
- package/dist/commands/samples.js.map +1 -0
- package/dist/commands/search.d.ts +4 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +295 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/supplement.d.ts +4 -0
- package/dist/commands/supplement.d.ts.map +1 -0
- package/dist/commands/supplement.js +338 -0
- package/dist/commands/supplement.js.map +1 -0
- package/dist/commands/vault.d.ts +4 -0
- package/dist/commands/vault.d.ts.map +1 -0
- package/dist/commands/vault.js +164 -0
- package/dist/commands/vault.js.map +1 -0
- package/dist/commands/workout.d.ts +4 -0
- package/dist/commands/workout.d.ts.map +1 -0
- package/dist/commands/workout.js +284 -0
- package/dist/commands/workout.js.map +1 -0
- package/dist/incur.generated.d.ts +2164 -0
- package/dist/incur.generated.d.ts.map +1 -0
- package/dist/incur.generated.js +2 -0
- package/dist/incur.generated.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/research-cli-contracts.d.ts +22 -0
- package/dist/research-cli-contracts.d.ts.map +1 -0
- package/dist/research-cli-contracts.js +18 -0
- package/dist/research-cli-contracts.js.map +1 -0
- package/dist/research-runtime.d.ts +79 -0
- package/dist/research-runtime.d.ts.map +1 -0
- package/dist/research-runtime.js +351 -0
- package/dist/research-runtime.js.map +1 -0
- package/dist/run-terminal-logging.d.ts +12 -0
- package/dist/run-terminal-logging.d.ts.map +1 -0
- package/dist/run-terminal-logging.js +323 -0
- package/dist/run-terminal-logging.js.map +1 -0
- package/dist/setup-agentmail.d.ts +30 -0
- package/dist/setup-agentmail.d.ts.map +1 -0
- package/dist/setup-agentmail.js +136 -0
- package/dist/setup-agentmail.js.map +1 -0
- package/dist/setup-assistant-account.d.ts +29 -0
- package/dist/setup-assistant-account.d.ts.map +1 -0
- package/dist/setup-assistant-account.js +443 -0
- package/dist/setup-assistant-account.js.map +1 -0
- package/dist/setup-assistant.d.ts +34 -0
- package/dist/setup-assistant.d.ts.map +1 -0
- package/dist/setup-assistant.js +355 -0
- package/dist/setup-assistant.js.map +1 -0
- package/dist/setup-cli.d.ts +72 -0
- package/dist/setup-cli.d.ts.map +1 -0
- package/dist/setup-cli.js +387 -0
- package/dist/setup-cli.js.map +1 -0
- package/dist/setup-services/channels.d.ts +19 -0
- package/dist/setup-services/channels.d.ts.map +1 -0
- package/dist/setup-services/channels.js +721 -0
- package/dist/setup-services/channels.js.map +1 -0
- package/dist/setup-services/process.d.ts +18 -0
- package/dist/setup-services/process.d.ts.map +1 -0
- package/dist/setup-services/process.js +98 -0
- package/dist/setup-services/process.js.map +1 -0
- package/dist/setup-services/scheduled-updates.d.ts +9 -0
- package/dist/setup-services/scheduled-updates.d.ts.map +1 -0
- package/dist/setup-services/scheduled-updates.js +64 -0
- package/dist/setup-services/scheduled-updates.js.map +1 -0
- package/dist/setup-services/shell.d.ts +18 -0
- package/dist/setup-services/shell.d.ts.map +1 -0
- package/dist/setup-services/shell.js +447 -0
- package/dist/setup-services/shell.js.map +1 -0
- package/dist/setup-services/steps.d.ts +39 -0
- package/dist/setup-services/steps.d.ts.map +1 -0
- package/dist/setup-services/steps.js +86 -0
- package/dist/setup-services/steps.js.map +1 -0
- package/dist/setup-services/toolchain.d.ts +46 -0
- package/dist/setup-services/toolchain.d.ts.map +1 -0
- package/dist/setup-services/toolchain.js +232 -0
- package/dist/setup-services/toolchain.js.map +1 -0
- package/dist/setup-services.d.ts +44 -0
- package/dist/setup-services.d.ts.map +1 -0
- package/dist/setup-services.js +739 -0
- package/dist/setup-services.js.map +1 -0
- package/dist/setup-wizard.d.ts +101 -0
- package/dist/setup-wizard.d.ts.map +1 -0
- package/dist/setup-wizard.js +1458 -0
- package/dist/setup-wizard.js.map +1 -0
- package/dist/usecases/intervention.d.ts +63 -0
- package/dist/usecases/intervention.d.ts.map +1 -0
- package/dist/usecases/intervention.js +205 -0
- package/dist/usecases/intervention.js.map +1 -0
- package/dist/usecases/text-duration.d.ts +4 -0
- package/dist/usecases/text-duration.d.ts.map +1 -0
- package/dist/usecases/text-duration.js +63 -0
- package/dist/usecases/text-duration.js.map +1 -0
- package/dist/usecases/workout-format.d.ts +139 -0
- package/dist/usecases/workout-format.d.ts.map +1 -0
- package/dist/usecases/workout-format.js +445 -0
- package/dist/usecases/workout-format.js.map +1 -0
- package/dist/usecases/workout.d.ts +94 -0
- package/dist/usecases/workout.d.ts.map +1 -0
- package/dist/usecases/workout.js +411 -0
- package/dist/usecases/workout.js.map +1 -0
- package/dist/vault-cli-command-manifest.d.ts +562 -0
- package/dist/vault-cli-command-manifest.d.ts.map +1 -0
- package/dist/vault-cli-command-manifest.js +759 -0
- package/dist/vault-cli-command-manifest.js.map +1 -0
- package/dist/vault-cli.d.ts +6 -0
- package/dist/vault-cli.d.ts.map +1 -0
- package/dist/vault-cli.js +38 -0
- package/dist/vault-cli.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { createIntegratedInboxServices, } from '@murphai/assistant-core/inbox-services';
|
|
6
|
+
import { createIntegratedVaultServices, } from '@murphai/assistant-core/vault-services';
|
|
7
|
+
import { VaultCliError } from '@murphai/assistant-core/vault-cli-errors';
|
|
8
|
+
import { resolveEffectiveTopLevelToken } from '@murphai/assistant-core/command-helpers';
|
|
9
|
+
import { buildAssistantProviderDefaultsPatch, normalizeVaultForConfig, readOperatorConfig, resolveAssistantBackendTarget, saveAssistantOperatorDefaultsPatch, saveDefaultVaultConfig, } from '@murphai/assistant-core/operator-config';
|
|
10
|
+
import {} from '@murphai/assistant-core/setup-cli-contracts';
|
|
11
|
+
import { configureSetupChannels, normalizeSetupChannels, } from './setup-services/channels.js';
|
|
12
|
+
import { configureSetupScheduledUpdates } from './setup-services/scheduled-updates.js';
|
|
13
|
+
import { createSetupAgentmailSelectionResolver, } from './setup-agentmail.js';
|
|
14
|
+
import { createDefaultCommandRunner, defaultDownloadFile, defaultFileExists, defaultLogger, } from './setup-services/process.js';
|
|
15
|
+
import { ensureCliShims, redactHomePath, redactHomePathInText, redactHomePathsInValue, redactNullableHomePath, } from './setup-services/shell.js';
|
|
16
|
+
import { buildBaseFormulaSpecs, createStep, DEFAULT_TOOLCHAIN_DIRECTORY, resolveWhisperModelPath, whisperModelDownloadUrl, } from './setup-services/steps.js';
|
|
17
|
+
import { ensureBrewFormula, ensureHomebrew, ensureWhisperModel, resolveExecutablePath, } from './setup-services/toolchain.js';
|
|
18
|
+
import { describeSelectedSetupWearables } from '@murphai/assistant-core/setup-runtime-env';
|
|
19
|
+
export function createSetupServices(dependencies = {}) {
|
|
20
|
+
const getArch = dependencies.arch ?? (() => process.arch);
|
|
21
|
+
const getBaseEnv = dependencies.env ?? (() => ({ ...process.env }));
|
|
22
|
+
const fileExists = dependencies.fileExists ?? defaultFileExists;
|
|
23
|
+
const getCwd = dependencies.getCwd ?? (() => process.cwd());
|
|
24
|
+
const getHomeDirectory = dependencies.getHomeDirectory ?? (() => os.homedir());
|
|
25
|
+
const getPlatform = dependencies.platform ?? (() => process.platform);
|
|
26
|
+
const log = dependencies.log ?? defaultLogger;
|
|
27
|
+
const resolveCliBinPath = dependencies.resolveCliBinPath ?? defaultResolveCliBinPath;
|
|
28
|
+
const runCommand = dependencies.runCommand ?? createDefaultCommandRunner(log);
|
|
29
|
+
const downloadFile = dependencies.downloadFile ?? defaultDownloadFile;
|
|
30
|
+
const vaultServices = dependencies.vaultServices ?? createIntegratedVaultServices();
|
|
31
|
+
const inboxServices = dependencies.inboxServices ?? createIntegratedInboxServices();
|
|
32
|
+
const resolveAgentmailInboxSelection = dependencies.resolveAgentmailInboxSelection ??
|
|
33
|
+
createSetupAgentmailSelectionResolver();
|
|
34
|
+
async function setupHost(input) {
|
|
35
|
+
const platform = getPlatform();
|
|
36
|
+
if (platform !== 'darwin' && platform !== 'linux') {
|
|
37
|
+
throw unsupportedSetupPlatform(platform);
|
|
38
|
+
}
|
|
39
|
+
const arch = getArch();
|
|
40
|
+
const dryRun = input.dryRun ?? false;
|
|
41
|
+
const strict = input.strict ?? true;
|
|
42
|
+
const vault = path.resolve(getCwd(), input.vault);
|
|
43
|
+
const requestId = input.requestId ?? null;
|
|
44
|
+
const whisperModel = input.whisperModel ?? 'base.en';
|
|
45
|
+
const homeDirectory = path.resolve(getHomeDirectory());
|
|
46
|
+
const cliBinPath = path.resolve(resolveCliBinPath());
|
|
47
|
+
const defaultToolchainRoot = path.join(homeDirectory, DEFAULT_TOOLCHAIN_DIRECTORY);
|
|
48
|
+
const toolchainRoot = path.resolve(getCwd(), input.toolchainRoot ?? defaultToolchainRoot);
|
|
49
|
+
const notes = [];
|
|
50
|
+
const steps = [];
|
|
51
|
+
const effectiveEnv = {
|
|
52
|
+
...getBaseEnv(),
|
|
53
|
+
...(input.envOverrides ?? {}),
|
|
54
|
+
};
|
|
55
|
+
log(`Murph setup targeting ${redactHomePathInText(vault, homeDirectory)} on ${describeSetupHost(platform)} (${arch}).`);
|
|
56
|
+
await ensureDirectoryStep({
|
|
57
|
+
absolutePath: toolchainRoot,
|
|
58
|
+
detailWhenCreated: `Created local toolchain root at ${toolchainRoot}.`,
|
|
59
|
+
detailWhenExisting: `Reusing local toolchain root at ${toolchainRoot}.`,
|
|
60
|
+
dryRun,
|
|
61
|
+
fileExists,
|
|
62
|
+
id: 'toolchain-root',
|
|
63
|
+
kind: 'configure',
|
|
64
|
+
steps,
|
|
65
|
+
title: 'Local toolchain root',
|
|
66
|
+
});
|
|
67
|
+
const provisioning = platform === 'darwin'
|
|
68
|
+
? await provisionMacosToolchain({
|
|
69
|
+
arch,
|
|
70
|
+
downloadFile,
|
|
71
|
+
dryRun,
|
|
72
|
+
env: effectiveEnv,
|
|
73
|
+
fileExists,
|
|
74
|
+
log,
|
|
75
|
+
notes,
|
|
76
|
+
runCommand,
|
|
77
|
+
steps,
|
|
78
|
+
toolchainRoot,
|
|
79
|
+
whisperModel,
|
|
80
|
+
})
|
|
81
|
+
: await provisionLinuxToolchain({
|
|
82
|
+
arch,
|
|
83
|
+
downloadFile,
|
|
84
|
+
dryRun,
|
|
85
|
+
env: effectiveEnv,
|
|
86
|
+
fileExists,
|
|
87
|
+
log,
|
|
88
|
+
notes,
|
|
89
|
+
runCommand,
|
|
90
|
+
steps,
|
|
91
|
+
toolchainRoot,
|
|
92
|
+
whisperModel,
|
|
93
|
+
});
|
|
94
|
+
const toolchainEnv = provisioning.env;
|
|
95
|
+
const tools = provisioning.tools;
|
|
96
|
+
let bootstrap = null;
|
|
97
|
+
const vaultMetadataPath = path.join(vault, 'vault.json');
|
|
98
|
+
const hasExistingVault = await fileExists(vaultMetadataPath);
|
|
99
|
+
if (dryRun) {
|
|
100
|
+
steps.push(createStep({
|
|
101
|
+
detail: hasExistingVault
|
|
102
|
+
? `Would reuse the existing vault at ${vault} and refresh its runtime state.`
|
|
103
|
+
: `Would initialize a new vault at ${vault}.`,
|
|
104
|
+
id: 'vault-init',
|
|
105
|
+
kind: 'configure',
|
|
106
|
+
status: hasExistingVault ? 'reused' : 'planned',
|
|
107
|
+
title: 'Vault initialization',
|
|
108
|
+
}));
|
|
109
|
+
steps.push(createStep({
|
|
110
|
+
detail: 'Would bootstrap the inbox runtime, parser toolchain config, and post-setup doctor checks.',
|
|
111
|
+
id: 'inbox-bootstrap',
|
|
112
|
+
kind: 'configure',
|
|
113
|
+
status: 'planned',
|
|
114
|
+
title: 'Inbox bootstrap',
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
if (!hasExistingVault) {
|
|
119
|
+
await vaultServices.core.init({
|
|
120
|
+
requestId,
|
|
121
|
+
vault,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
steps.push(createStep({
|
|
125
|
+
detail: hasExistingVault
|
|
126
|
+
? `Reusing the existing vault at ${vault}.`
|
|
127
|
+
: `Initialized a new vault scaffold at ${vault}.`,
|
|
128
|
+
id: 'vault-init',
|
|
129
|
+
kind: 'configure',
|
|
130
|
+
status: hasExistingVault ? 'reused' : 'completed',
|
|
131
|
+
title: 'Vault initialization',
|
|
132
|
+
}));
|
|
133
|
+
bootstrap = await inboxServices.bootstrap({
|
|
134
|
+
ffmpegCommand: tools.ffmpegCommand ?? undefined,
|
|
135
|
+
pdftotextCommand: tools.pdftotextCommand ?? undefined,
|
|
136
|
+
rebuild: input.rebuild,
|
|
137
|
+
requestId,
|
|
138
|
+
strict,
|
|
139
|
+
vault,
|
|
140
|
+
whisperCommand: tools.whisperCommand ?? undefined,
|
|
141
|
+
whisperModelPath: tools.whisperModelPath,
|
|
142
|
+
});
|
|
143
|
+
steps.push(createStep({
|
|
144
|
+
detail: 'Wrote parser toolchain config under .runtime/parsers and completed inbox doctor checks.',
|
|
145
|
+
id: 'inbox-bootstrap',
|
|
146
|
+
kind: 'configure',
|
|
147
|
+
status: 'completed',
|
|
148
|
+
title: 'Inbox bootstrap',
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
await ensureCliShims({
|
|
152
|
+
cliBinPath,
|
|
153
|
+
dryRun,
|
|
154
|
+
env: toolchainEnv,
|
|
155
|
+
fileExists,
|
|
156
|
+
homeDirectory,
|
|
157
|
+
notes,
|
|
158
|
+
steps,
|
|
159
|
+
});
|
|
160
|
+
await ensureDefaultVaultSelection({
|
|
161
|
+
dryRun,
|
|
162
|
+
homeDirectory,
|
|
163
|
+
steps,
|
|
164
|
+
vault,
|
|
165
|
+
});
|
|
166
|
+
const assistant = input.assistant == null
|
|
167
|
+
? null
|
|
168
|
+
: await ensureAssistantDefaultSelection({
|
|
169
|
+
assistant: input.assistant,
|
|
170
|
+
dryRun,
|
|
171
|
+
homeDirectory,
|
|
172
|
+
notes,
|
|
173
|
+
steps,
|
|
174
|
+
});
|
|
175
|
+
const channels = input.channels == null
|
|
176
|
+
? []
|
|
177
|
+
: await configureSetupChannels({
|
|
178
|
+
allowPrompt: input.allowChannelPrompts ?? false,
|
|
179
|
+
channels: normalizeSetupChannels(input.channels),
|
|
180
|
+
dryRun,
|
|
181
|
+
env: toolchainEnv,
|
|
182
|
+
inboxServices,
|
|
183
|
+
platform,
|
|
184
|
+
requestId,
|
|
185
|
+
resolveAgentmailInboxSelection,
|
|
186
|
+
steps,
|
|
187
|
+
vault,
|
|
188
|
+
});
|
|
189
|
+
const wearables = input.wearables == null
|
|
190
|
+
? []
|
|
191
|
+
: describeSelectedSetupWearables({
|
|
192
|
+
env: toolchainEnv,
|
|
193
|
+
wearables: input.wearables,
|
|
194
|
+
});
|
|
195
|
+
const scheduledUpdates = input.scheduledUpdatePresetIds == null
|
|
196
|
+
? []
|
|
197
|
+
: await configureSetupScheduledUpdates({
|
|
198
|
+
dryRun,
|
|
199
|
+
presetIds: input.scheduledUpdatePresetIds,
|
|
200
|
+
steps,
|
|
201
|
+
vault,
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
arch,
|
|
205
|
+
bootstrap: bootstrap === null
|
|
206
|
+
? null
|
|
207
|
+
: redactHomePathsInValue(bootstrap, homeDirectory),
|
|
208
|
+
assistant: assistant === null
|
|
209
|
+
? null
|
|
210
|
+
: {
|
|
211
|
+
...assistant,
|
|
212
|
+
detail: redactHomePathInText(assistant.detail, homeDirectory),
|
|
213
|
+
},
|
|
214
|
+
scheduledUpdates: scheduledUpdates.map((scheduledUpdate) => redactHomePathsInValue(scheduledUpdate, homeDirectory)),
|
|
215
|
+
channels: channels.map((channel) => ({
|
|
216
|
+
...channel,
|
|
217
|
+
connectorId: channel.connectorId,
|
|
218
|
+
detail: redactHomePathInText(channel.detail, homeDirectory),
|
|
219
|
+
})),
|
|
220
|
+
wearables: wearables.map((wearable) => ({
|
|
221
|
+
...wearable,
|
|
222
|
+
detail: redactHomePathInText(wearable.detail, homeDirectory),
|
|
223
|
+
})),
|
|
224
|
+
dryRun,
|
|
225
|
+
notes: notes.map((note) => redactHomePathInText(note, homeDirectory)),
|
|
226
|
+
platform,
|
|
227
|
+
steps: steps.map((step) => ({
|
|
228
|
+
...step,
|
|
229
|
+
detail: redactHomePathInText(step.detail, homeDirectory),
|
|
230
|
+
})),
|
|
231
|
+
toolchainRoot: redactHomePath(toolchainRoot, homeDirectory),
|
|
232
|
+
tools: {
|
|
233
|
+
ffmpegCommand: redactNullableHomePath(tools.ffmpegCommand, homeDirectory),
|
|
234
|
+
pdftotextCommand: redactNullableHomePath(tools.pdftotextCommand, homeDirectory),
|
|
235
|
+
whisperCommand: redactNullableHomePath(tools.whisperCommand, homeDirectory),
|
|
236
|
+
whisperModelPath: redactHomePath(tools.whisperModelPath, homeDirectory),
|
|
237
|
+
},
|
|
238
|
+
vault: redactHomePath(vault, homeDirectory),
|
|
239
|
+
whisperModel,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
async function setupMacos(input) {
|
|
243
|
+
const platform = getPlatform();
|
|
244
|
+
if (platform !== 'darwin') {
|
|
245
|
+
throw unsupportedSetupPlatform(platform, 'Murph setup currently supports macOS only through setupMacos(). Use setupHost() for Linux support.');
|
|
246
|
+
}
|
|
247
|
+
return await setupHost(input);
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
setupHost,
|
|
251
|
+
setupMacos,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
async function ensureProvisionedWhisperModel(input) {
|
|
255
|
+
const whisperModelPath = resolveWhisperModelPath(input.toolchainRoot, input.whisperModel);
|
|
256
|
+
await ensureWhisperModel({
|
|
257
|
+
destinationPath: whisperModelPath,
|
|
258
|
+
dryRun: input.dryRun,
|
|
259
|
+
downloadFile: input.downloadFile,
|
|
260
|
+
downloadUrl: whisperModelDownloadUrl(input.whisperModel),
|
|
261
|
+
fileExists: input.fileExists,
|
|
262
|
+
id: 'whisper-model',
|
|
263
|
+
model: input.whisperModel,
|
|
264
|
+
steps: input.steps,
|
|
265
|
+
title: 'Whisper model',
|
|
266
|
+
});
|
|
267
|
+
return whisperModelPath;
|
|
268
|
+
}
|
|
269
|
+
async function ensureMacosToolRequirement(input) {
|
|
270
|
+
const macos = input.requirement.macos;
|
|
271
|
+
return ensureBrewFormula({
|
|
272
|
+
brewState: input.brewState,
|
|
273
|
+
commandCandidates: input.requirement.commandCandidates,
|
|
274
|
+
dryRun: input.dryRun,
|
|
275
|
+
formula: macos.formula,
|
|
276
|
+
id: input.requirement.id,
|
|
277
|
+
installDetail: macos.installDetail,
|
|
278
|
+
kind: 'install',
|
|
279
|
+
missingPlanDetail: macos.missingPlanDetail,
|
|
280
|
+
runCommand: input.runCommand,
|
|
281
|
+
steps: input.steps,
|
|
282
|
+
title: macos.title,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
async function ensureLinuxToolRequirement(input) {
|
|
286
|
+
const linux = input.requirement.linux;
|
|
287
|
+
return ensureLinuxCommand({
|
|
288
|
+
apt: input.apt,
|
|
289
|
+
commandCandidates: input.requirement.commandCandidates,
|
|
290
|
+
completedDetail: linux.completedDetail,
|
|
291
|
+
dryRun: input.dryRun,
|
|
292
|
+
env: input.env,
|
|
293
|
+
id: input.requirement.id,
|
|
294
|
+
installPackages: linux.installPackages,
|
|
295
|
+
missingNoteDetail: linux.missingNoteDetail,
|
|
296
|
+
missingStepDetail: linux.missingStepDetail,
|
|
297
|
+
missingPlanDetail: linux.missingPlanDetail,
|
|
298
|
+
notes: input.notes,
|
|
299
|
+
reuseDetail: linux.reuseDetail,
|
|
300
|
+
runCommand: input.runCommand,
|
|
301
|
+
steps: input.steps,
|
|
302
|
+
title: linux.title,
|
|
303
|
+
validateResolvedCommand: input.validateResolvedCommand,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
async function provisionMacosToolchain(input) {
|
|
307
|
+
let state = await ensureHomebrew({
|
|
308
|
+
arch: input.arch,
|
|
309
|
+
dryRun: input.dryRun,
|
|
310
|
+
env: input.env,
|
|
311
|
+
log: input.log,
|
|
312
|
+
runCommand: input.runCommand,
|
|
313
|
+
steps: input.steps,
|
|
314
|
+
});
|
|
315
|
+
const formulaCommands = {
|
|
316
|
+
ffmpegCommand: null,
|
|
317
|
+
pdftotextCommand: null,
|
|
318
|
+
whisperCommand: null,
|
|
319
|
+
};
|
|
320
|
+
for (const requirement of buildBaseFormulaSpecs()) {
|
|
321
|
+
const formulaResult = await ensureMacosToolRequirement({
|
|
322
|
+
brewState: state,
|
|
323
|
+
dryRun: input.dryRun,
|
|
324
|
+
requirement,
|
|
325
|
+
runCommand: input.runCommand,
|
|
326
|
+
steps: input.steps,
|
|
327
|
+
});
|
|
328
|
+
state = {
|
|
329
|
+
...state,
|
|
330
|
+
env: formulaResult.env,
|
|
331
|
+
};
|
|
332
|
+
formulaCommands[requirement.key] = formulaResult.command;
|
|
333
|
+
}
|
|
334
|
+
const whisperModelPath = await ensureProvisionedWhisperModel(input);
|
|
335
|
+
return {
|
|
336
|
+
env: state.env,
|
|
337
|
+
tools: {
|
|
338
|
+
ffmpegCommand: formulaCommands.ffmpegCommand,
|
|
339
|
+
pdftotextCommand: formulaCommands.pdftotextCommand,
|
|
340
|
+
whisperCommand: formulaCommands.whisperCommand,
|
|
341
|
+
whisperModelPath,
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
async function provisionLinuxToolchain(input) {
|
|
346
|
+
let apt = await resolveAptRunner(input.env);
|
|
347
|
+
const resolvedCommands = {
|
|
348
|
+
ffmpegCommand: null,
|
|
349
|
+
pdftotextCommand: null,
|
|
350
|
+
whisperCommand: null,
|
|
351
|
+
};
|
|
352
|
+
for (const requirement of buildBaseFormulaSpecs()) {
|
|
353
|
+
const resolved = await ensureLinuxToolRequirement({
|
|
354
|
+
apt,
|
|
355
|
+
dryRun: input.dryRun,
|
|
356
|
+
env: input.env,
|
|
357
|
+
notes: input.notes,
|
|
358
|
+
requirement,
|
|
359
|
+
runCommand: input.runCommand,
|
|
360
|
+
steps: input.steps,
|
|
361
|
+
});
|
|
362
|
+
apt = resolved.apt;
|
|
363
|
+
resolvedCommands[requirement.key] = resolved.command;
|
|
364
|
+
}
|
|
365
|
+
const whisperModelPath = await ensureProvisionedWhisperModel(input);
|
|
366
|
+
return {
|
|
367
|
+
env: input.env,
|
|
368
|
+
tools: {
|
|
369
|
+
ffmpegCommand: resolvedCommands.ffmpegCommand,
|
|
370
|
+
pdftotextCommand: resolvedCommands.pdftotextCommand,
|
|
371
|
+
whisperCommand: resolvedCommands.whisperCommand,
|
|
372
|
+
whisperModelPath,
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
async function ensureLinuxCommand(input) {
|
|
377
|
+
const resolveValidatedCommand = async () => {
|
|
378
|
+
const rawCommand = await resolveExecutablePath(input.commandCandidates, input.env);
|
|
379
|
+
if (!rawCommand) {
|
|
380
|
+
return {
|
|
381
|
+
command: null,
|
|
382
|
+
rawCommand: null,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (input.validateResolvedCommand &&
|
|
386
|
+
!(await input.validateResolvedCommand({
|
|
387
|
+
command: rawCommand,
|
|
388
|
+
env: input.env,
|
|
389
|
+
runCommand: input.runCommand,
|
|
390
|
+
}))) {
|
|
391
|
+
return {
|
|
392
|
+
command: null,
|
|
393
|
+
rawCommand,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
command: rawCommand,
|
|
398
|
+
rawCommand,
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
const existingResolution = await resolveValidatedCommand();
|
|
402
|
+
const existing = existingResolution.command;
|
|
403
|
+
if (existing) {
|
|
404
|
+
input.steps.push(createStep({
|
|
405
|
+
detail: input.reuseDetail?.(existing) ?? `Reusing ${input.title} from ${existing}.`,
|
|
406
|
+
id: input.id,
|
|
407
|
+
kind: 'install',
|
|
408
|
+
status: 'reused',
|
|
409
|
+
title: input.title,
|
|
410
|
+
}));
|
|
411
|
+
return {
|
|
412
|
+
apt: input.apt,
|
|
413
|
+
command: existing,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
if (input.dryRun) {
|
|
417
|
+
input.steps.push(createStep({
|
|
418
|
+
detail: input.missingPlanDetail,
|
|
419
|
+
id: input.id,
|
|
420
|
+
kind: 'install',
|
|
421
|
+
status: 'planned',
|
|
422
|
+
title: input.title,
|
|
423
|
+
}));
|
|
424
|
+
return {
|
|
425
|
+
apt: input.apt,
|
|
426
|
+
command: existingResolution.rawCommand,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
const install = await ensureAptPackages({
|
|
430
|
+
apt: input.apt,
|
|
431
|
+
env: input.env,
|
|
432
|
+
packages: input.installPackages,
|
|
433
|
+
runCommand: input.runCommand,
|
|
434
|
+
});
|
|
435
|
+
const resolved = (await resolveValidatedCommand()).command;
|
|
436
|
+
if (resolved) {
|
|
437
|
+
input.steps.push(createStep({
|
|
438
|
+
detail: input.completedDetail ?? `Installed ${input.title} through apt-get.`,
|
|
439
|
+
id: input.id,
|
|
440
|
+
kind: 'install',
|
|
441
|
+
status: 'completed',
|
|
442
|
+
title: input.title,
|
|
443
|
+
}));
|
|
444
|
+
return {
|
|
445
|
+
apt: install.apt,
|
|
446
|
+
command: resolved,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
input.steps.push(createStep({
|
|
450
|
+
detail: install.reason ?? input.missingStepDetail,
|
|
451
|
+
id: input.id,
|
|
452
|
+
kind: 'install',
|
|
453
|
+
status: 'skipped',
|
|
454
|
+
title: input.title,
|
|
455
|
+
}));
|
|
456
|
+
input.notes.push(input.missingNoteDetail ?? input.missingStepDetail);
|
|
457
|
+
if (install.reason && install.reason !== input.missingStepDetail) {
|
|
458
|
+
input.notes.push(`${input.title} auto-install detail: ${install.reason}`);
|
|
459
|
+
}
|
|
460
|
+
return {
|
|
461
|
+
apt: install.apt,
|
|
462
|
+
command: null,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
async function resolveAptRunner(env) {
|
|
466
|
+
const aptGet = await resolveExecutablePath(['apt-get'], env, ['/usr/bin/apt-get', '/bin/apt-get']);
|
|
467
|
+
if (!aptGet) {
|
|
468
|
+
return {
|
|
469
|
+
command: null,
|
|
470
|
+
baseArgs: [],
|
|
471
|
+
updateAttempted: false,
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
if (typeof process.getuid === 'function' && process.getuid() === 0) {
|
|
475
|
+
return {
|
|
476
|
+
command: aptGet,
|
|
477
|
+
baseArgs: [],
|
|
478
|
+
updateAttempted: false,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
const sudo = await resolveExecutablePath(['sudo'], env, ['/usr/bin/sudo', '/bin/sudo']);
|
|
482
|
+
if (!sudo) {
|
|
483
|
+
return {
|
|
484
|
+
command: null,
|
|
485
|
+
baseArgs: [],
|
|
486
|
+
updateAttempted: false,
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
command: sudo,
|
|
491
|
+
baseArgs: ['-n', aptGet],
|
|
492
|
+
updateAttempted: false,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
async function ensureAptPackages(input) {
|
|
496
|
+
if (!input.apt.command) {
|
|
497
|
+
return {
|
|
498
|
+
apt: input.apt,
|
|
499
|
+
reason: 'apt-get or passwordless sudo is unavailable on this host.',
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
let apt = input.apt;
|
|
503
|
+
const aptCommand = input.apt.command;
|
|
504
|
+
const aptEnv = {
|
|
505
|
+
...input.env,
|
|
506
|
+
DEBIAN_FRONTEND: 'noninteractive',
|
|
507
|
+
};
|
|
508
|
+
if (!apt.updateAttempted) {
|
|
509
|
+
const updateResult = await input.runCommand({
|
|
510
|
+
args: [...apt.baseArgs, 'update'],
|
|
511
|
+
env: aptEnv,
|
|
512
|
+
file: aptCommand,
|
|
513
|
+
});
|
|
514
|
+
apt = {
|
|
515
|
+
...apt,
|
|
516
|
+
updateAttempted: true,
|
|
517
|
+
};
|
|
518
|
+
if (updateResult.exitCode !== 0) {
|
|
519
|
+
return {
|
|
520
|
+
apt,
|
|
521
|
+
reason: summarizeCommandFailure(updateResult, 'apt-get update failed during automatic Linux tool provisioning.'),
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
const installResult = await input.runCommand({
|
|
526
|
+
args: [...apt.baseArgs, 'install', '-y', ...input.packages],
|
|
527
|
+
env: aptEnv,
|
|
528
|
+
file: aptCommand,
|
|
529
|
+
});
|
|
530
|
+
if (installResult.exitCode !== 0) {
|
|
531
|
+
return {
|
|
532
|
+
apt,
|
|
533
|
+
reason: summarizeCommandFailure(installResult, `apt-get install failed for ${input.packages.join(', ')}.`),
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
return {
|
|
537
|
+
apt,
|
|
538
|
+
reason: null,
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function summarizeCommandFailure(result, fallback) {
|
|
542
|
+
const stderr = result.stderr.trim();
|
|
543
|
+
if (stderr.length > 0) {
|
|
544
|
+
return stderr;
|
|
545
|
+
}
|
|
546
|
+
const stdout = result.stdout.trim();
|
|
547
|
+
if (stdout.length > 0) {
|
|
548
|
+
return stdout;
|
|
549
|
+
}
|
|
550
|
+
return fallback;
|
|
551
|
+
}
|
|
552
|
+
function unsupportedSetupPlatform(platform, message = 'Murph setup currently supports macOS and Linux only.') {
|
|
553
|
+
return new VaultCliError('unsupported_platform', message, {
|
|
554
|
+
platform,
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
function describeSetupHost(platform) {
|
|
558
|
+
return platform === 'darwin' ? 'macOS' : platform;
|
|
559
|
+
}
|
|
560
|
+
export function detectSetupProgramName(argv0, shimProgramName = process.env.SETUP_PROGRAM_NAME) {
|
|
561
|
+
const normalizedShimProgramName = shimProgramName?.trim().toLowerCase();
|
|
562
|
+
if (normalizedShimProgramName === 'murph') {
|
|
563
|
+
return 'murph';
|
|
564
|
+
}
|
|
565
|
+
const baseName = path.basename(argv0 ?? '').toLowerCase();
|
|
566
|
+
return baseName === 'murph' ? 'murph' : 'vault-cli';
|
|
567
|
+
}
|
|
568
|
+
export function isSetupInvocation(args, programName = 'vault-cli') {
|
|
569
|
+
const commandToken = resolveEffectiveTopLevelToken(args);
|
|
570
|
+
if (commandToken === 'onboard') {
|
|
571
|
+
return true;
|
|
572
|
+
}
|
|
573
|
+
if (programName !== 'murph') {
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
return commandToken === null || commandToken === 'help';
|
|
577
|
+
}
|
|
578
|
+
async function ensureDirectoryStep(input) {
|
|
579
|
+
const exists = await input.fileExists(input.absolutePath);
|
|
580
|
+
if (exists) {
|
|
581
|
+
input.steps.push(createStep({
|
|
582
|
+
detail: input.detailWhenExisting,
|
|
583
|
+
id: input.id,
|
|
584
|
+
kind: input.kind,
|
|
585
|
+
status: 'reused',
|
|
586
|
+
title: input.title,
|
|
587
|
+
}));
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
if (input.dryRun) {
|
|
591
|
+
input.steps.push(createStep({
|
|
592
|
+
detail: input.detailWhenCreated,
|
|
593
|
+
id: input.id,
|
|
594
|
+
kind: input.kind,
|
|
595
|
+
status: 'planned',
|
|
596
|
+
title: input.title,
|
|
597
|
+
}));
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
await mkdir(input.absolutePath, { recursive: true });
|
|
601
|
+
input.steps.push(createStep({
|
|
602
|
+
detail: input.detailWhenCreated,
|
|
603
|
+
id: input.id,
|
|
604
|
+
kind: input.kind,
|
|
605
|
+
status: 'completed',
|
|
606
|
+
title: input.title,
|
|
607
|
+
}));
|
|
608
|
+
}
|
|
609
|
+
async function ensureDefaultVaultSelection(input) {
|
|
610
|
+
const existing = await readOperatorConfig(input.homeDirectory);
|
|
611
|
+
const existingDefaultVault = existing?.defaultVault === null || existing?.defaultVault === undefined
|
|
612
|
+
? null
|
|
613
|
+
: existing.defaultVault;
|
|
614
|
+
const nextDefaultVault = normalizeVaultForConfig(input.vault, input.homeDirectory);
|
|
615
|
+
const status = existingDefaultVault === nextDefaultVault
|
|
616
|
+
? 'reused'
|
|
617
|
+
: input.dryRun
|
|
618
|
+
? 'planned'
|
|
619
|
+
: 'completed';
|
|
620
|
+
const detail = existingDefaultVault === nextDefaultVault
|
|
621
|
+
? `Reusing ${nextDefaultVault} as the default Murph vault for future CLI commands.`
|
|
622
|
+
: input.dryRun
|
|
623
|
+
? `Would save ${nextDefaultVault} as the default Murph vault for future CLI commands.`
|
|
624
|
+
: `Saved ${nextDefaultVault} as the default Murph vault for future CLI commands.`;
|
|
625
|
+
if (!input.dryRun && existingDefaultVault !== nextDefaultVault) {
|
|
626
|
+
await saveDefaultVaultConfig(input.vault, input.homeDirectory);
|
|
627
|
+
}
|
|
628
|
+
input.steps.push(createStep({
|
|
629
|
+
detail,
|
|
630
|
+
id: 'default-vault',
|
|
631
|
+
kind: 'configure',
|
|
632
|
+
status,
|
|
633
|
+
title: 'Default vault selection',
|
|
634
|
+
}));
|
|
635
|
+
}
|
|
636
|
+
async function ensureAssistantDefaultSelection(input) {
|
|
637
|
+
if (!input.assistant.enabled || input.assistant.provider === null) {
|
|
638
|
+
input.steps.push(createStep({
|
|
639
|
+
detail: 'Skipped saving assistant defaults during setup and left any existing assistant config unchanged.',
|
|
640
|
+
id: 'assistant-defaults',
|
|
641
|
+
kind: 'configure',
|
|
642
|
+
status: 'skipped',
|
|
643
|
+
title: 'Assistant defaults',
|
|
644
|
+
}));
|
|
645
|
+
return input.assistant;
|
|
646
|
+
}
|
|
647
|
+
const existing = await readOperatorConfig(input.homeDirectory);
|
|
648
|
+
const nextDefaults = assistantSelectionToOperatorDefaults(input.assistant, existing?.assistant ?? null);
|
|
649
|
+
const status = assistantOperatorDefaultsMatch(existing?.assistant ?? null, nextDefaults)
|
|
650
|
+
? 'reused'
|
|
651
|
+
: input.dryRun
|
|
652
|
+
? 'planned'
|
|
653
|
+
: 'completed';
|
|
654
|
+
const summary = formatAssistantDefaultsSummary(input.assistant);
|
|
655
|
+
const detail = status === 'reused'
|
|
656
|
+
? `Reusing ${summary} as the default assistant for future chats and auto-reply.`
|
|
657
|
+
: input.dryRun
|
|
658
|
+
? `Would save ${summary} as the default assistant for future chats and auto-reply.`
|
|
659
|
+
: `Saved ${summary} as the default assistant for future chats and auto-reply.`;
|
|
660
|
+
if (status !== 'reused' && !input.dryRun) {
|
|
661
|
+
await saveAssistantOperatorDefaultsPatch(nextDefaults, input.homeDirectory);
|
|
662
|
+
}
|
|
663
|
+
if (input.assistant.provider === 'openai-compatible' && input.assistant.apiKeyEnv) {
|
|
664
|
+
input.notes.push(`Export ${input.assistant.apiKeyEnv} before using the saved OpenAI-compatible assistant backend.`);
|
|
665
|
+
}
|
|
666
|
+
input.steps.push(createStep({
|
|
667
|
+
detail,
|
|
668
|
+
id: 'assistant-defaults',
|
|
669
|
+
kind: 'configure',
|
|
670
|
+
status,
|
|
671
|
+
title: 'Assistant defaults',
|
|
672
|
+
}));
|
|
673
|
+
return input.assistant;
|
|
674
|
+
}
|
|
675
|
+
function assistantSelectionToOperatorDefaults(assistant, existingDefaults) {
|
|
676
|
+
if (!assistant.provider) {
|
|
677
|
+
return {
|
|
678
|
+
backend: null,
|
|
679
|
+
account: assistant.account ?? null,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
return {
|
|
683
|
+
...buildAssistantProviderDefaultsPatch({
|
|
684
|
+
defaults: existingDefaults,
|
|
685
|
+
provider: assistant.provider,
|
|
686
|
+
providerConfig: {
|
|
687
|
+
model: assistant.model,
|
|
688
|
+
...(assistant.codexCommand !== null
|
|
689
|
+
? {
|
|
690
|
+
codexCommand: assistant.codexCommand,
|
|
691
|
+
}
|
|
692
|
+
: {}),
|
|
693
|
+
reasoningEffort: assistant.reasoningEffort,
|
|
694
|
+
sandbox: assistant.sandbox,
|
|
695
|
+
approvalPolicy: assistant.approvalPolicy,
|
|
696
|
+
profile: assistant.profile,
|
|
697
|
+
oss: assistant.oss === true,
|
|
698
|
+
baseUrl: assistant.baseUrl,
|
|
699
|
+
apiKeyEnv: assistant.apiKeyEnv,
|
|
700
|
+
providerName: assistant.providerName,
|
|
701
|
+
},
|
|
702
|
+
}),
|
|
703
|
+
account: assistant.account ?? null,
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
function assistantOperatorDefaultsMatch(existing, next) {
|
|
707
|
+
return (JSON.stringify(resolveAssistantBackendTarget(existing)) ===
|
|
708
|
+
JSON.stringify(next.backend ?? null) &&
|
|
709
|
+
JSON.stringify(existing?.account ?? null) ===
|
|
710
|
+
JSON.stringify(next.account ?? null));
|
|
711
|
+
}
|
|
712
|
+
function formatAssistantDefaultsSummary(assistant) {
|
|
713
|
+
if (assistant.provider === 'openai-compatible') {
|
|
714
|
+
return assistant.baseUrl
|
|
715
|
+
? `${assistant.model ?? 'the configured model'} via ${assistant.baseUrl}`
|
|
716
|
+
: `${assistant.model ?? 'the configured model'} via the saved OpenAI-compatible endpoint`;
|
|
717
|
+
}
|
|
718
|
+
if (assistant.oss) {
|
|
719
|
+
return appendAssistantAccountSummary(`${assistant.model ?? 'the configured local model'} in Codex OSS`, assistant);
|
|
720
|
+
}
|
|
721
|
+
return appendAssistantAccountSummary(`${assistant.model ?? 'the configured model'} in Codex CLI`, assistant);
|
|
722
|
+
}
|
|
723
|
+
function normalizeNullableConfigField(value) {
|
|
724
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
|
|
725
|
+
}
|
|
726
|
+
function appendAssistantAccountSummary(summary, assistant) {
|
|
727
|
+
const planName = normalizeNullableConfigField(assistant.account?.planName);
|
|
728
|
+
if (planName) {
|
|
729
|
+
return `${summary} (${planName} account)`;
|
|
730
|
+
}
|
|
731
|
+
if (assistant.account?.kind === 'api-key') {
|
|
732
|
+
return `${summary} (API key account)`;
|
|
733
|
+
}
|
|
734
|
+
return summary;
|
|
735
|
+
}
|
|
736
|
+
function defaultResolveCliBinPath() {
|
|
737
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), 'bin.js');
|
|
738
|
+
}
|
|
739
|
+
//# sourceMappingURL=setup-services.js.map
|