funolio-agent 1.0.75 → 1.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/credential-reader.d.ts.map +1 -1
- package/dist/auth/credential-reader.js +4 -3
- package/dist/auth/credential-reader.js.map +1 -1
- package/dist/auth/token-refresh.d.ts +8 -0
- package/dist/auth/token-refresh.d.ts.map +1 -1
- package/dist/auth/token-refresh.js +82 -52
- package/dist/auth/token-refresh.js.map +1 -1
- package/dist/auto-organizer.d.ts.map +1 -1
- package/dist/auto-organizer.js +6 -7
- package/dist/auto-organizer.js.map +1 -1
- package/dist/bench-prefix.d.ts +16 -0
- package/dist/bench-prefix.d.ts.map +1 -0
- package/dist/bench-prefix.js +25 -0
- package/dist/bench-prefix.js.map +1 -0
- package/dist/bot-manager.d.ts.map +1 -1
- package/dist/bot-manager.js +23 -14
- package/dist/bot-manager.js.map +1 -1
- package/dist/chat-sync.d.ts +42 -0
- package/dist/chat-sync.d.ts.map +1 -0
- package/dist/chat-sync.js +95 -0
- package/dist/chat-sync.js.map +1 -0
- package/dist/clerk-model.d.ts +7 -0
- package/dist/clerk-model.d.ts.map +1 -1
- package/dist/clerk-model.js +42 -8
- package/dist/clerk-model.js.map +1 -1
- package/dist/cli-bootstrap-history.d.ts +10 -0
- package/dist/cli-bootstrap-history.d.ts.map +1 -0
- package/dist/cli-bootstrap-history.js +112 -0
- package/dist/cli-bootstrap-history.js.map +1 -0
- package/dist/cli-models.d.ts +8 -0
- package/dist/cli-models.d.ts.map +1 -0
- package/dist/cli-models.js +91 -0
- package/dist/cli-models.js.map +1 -0
- package/dist/cli-session-epoch.d.ts +13 -3
- package/dist/cli-session-epoch.d.ts.map +1 -1
- package/dist/cli-session-epoch.js +53 -4
- package/dist/cli-session-epoch.js.map +1 -1
- package/dist/codex-app-server-manager.d.ts +64 -4
- package/dist/codex-app-server-manager.d.ts.map +1 -1
- package/dist/codex-app-server-manager.js +755 -55
- package/dist/codex-app-server-manager.js.map +1 -1
- package/dist/commands/pool.d.ts +32 -0
- package/dist/commands/pool.d.ts.map +1 -1
- package/dist/commands/pool.js +145 -66
- package/dist/commands/pool.js.map +1 -1
- package/dist/commands/start.d.ts +21 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +484 -63
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +5 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +170 -58
- package/dist/config.js.map +1 -1
- package/dist/context-window.d.ts +37 -1
- package/dist/context-window.d.ts.map +1 -1
- package/dist/context-window.js +202 -16
- package/dist/context-window.js.map +1 -1
- package/dist/live-activity.d.ts +3 -1
- package/dist/live-activity.d.ts.map +1 -1
- package/dist/live-activity.js.map +1 -1
- package/dist/local-chat-execution.d.ts +114 -0
- package/dist/local-chat-execution.d.ts.map +1 -0
- package/dist/local-chat-execution.js +349 -0
- package/dist/local-chat-execution.js.map +1 -0
- package/dist/local-cli-pty-manager.d.ts +138 -3
- package/dist/local-cli-pty-manager.d.ts.map +1 -1
- package/dist/local-cli-pty-manager.js +1415 -111
- package/dist/local-cli-pty-manager.js.map +1 -1
- package/dist/local-conversation-gateway.d.ts +110 -0
- package/dist/local-conversation-gateway.d.ts.map +1 -0
- package/dist/local-conversation-gateway.js +175 -0
- package/dist/local-conversation-gateway.js.map +1 -0
- package/dist/local-data.d.ts +235 -5
- package/dist/local-data.d.ts.map +1 -1
- package/dist/local-data.js +1066 -87
- package/dist/local-data.js.map +1 -1
- package/dist/local-db.d.ts +6 -0
- package/dist/local-db.d.ts.map +1 -1
- package/dist/local-db.js +376 -4
- package/dist/local-db.js.map +1 -1
- package/dist/local-funnel.d.ts.map +1 -1
- package/dist/local-funnel.js +6 -5
- package/dist/local-funnel.js.map +1 -1
- package/dist/local-server.d.ts +30 -0
- package/dist/local-server.d.ts.map +1 -1
- package/dist/local-server.js +2898 -319
- package/dist/local-server.js.map +1 -1
- package/dist/managed-process-registry.d.ts +59 -0
- package/dist/managed-process-registry.d.ts.map +1 -0
- package/dist/managed-process-registry.js +390 -0
- package/dist/managed-process-registry.js.map +1 -0
- package/dist/mcp/claude-config-writer.d.ts +5 -5
- package/dist/mcp/claude-config-writer.d.ts.map +1 -1
- package/dist/mcp/claude-config-writer.js +19 -11
- package/dist/mcp/claude-config-writer.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/sync-cli-config.d.ts +42 -4
- package/dist/mcp/sync-cli-config.d.ts.map +1 -1
- package/dist/mcp/sync-cli-config.js +497 -17
- package/dist/mcp/sync-cli-config.js.map +1 -1
- package/dist/message-loop.d.ts.map +1 -1
- package/dist/message-loop.js +43 -1
- package/dist/message-loop.js.map +1 -1
- package/dist/mqtt-client.d.ts +34 -0
- package/dist/mqtt-client.d.ts.map +1 -1
- package/dist/mqtt-client.js +270 -45
- package/dist/mqtt-client.js.map +1 -1
- package/dist/mqtt-data-relay.d.ts +44 -0
- package/dist/mqtt-data-relay.d.ts.map +1 -0
- package/dist/mqtt-data-relay.js +106 -0
- package/dist/mqtt-data-relay.js.map +1 -0
- package/dist/orchestration/capabilities.d.ts +13 -0
- package/dist/orchestration/capabilities.d.ts.map +1 -0
- package/dist/orchestration/capabilities.js +152 -0
- package/dist/orchestration/capabilities.js.map +1 -0
- package/dist/orchestration/dispatch-executor.d.ts +83 -0
- package/dist/orchestration/dispatch-executor.d.ts.map +1 -0
- package/dist/orchestration/dispatch-executor.js +266 -0
- package/dist/orchestration/dispatch-executor.js.map +1 -0
- package/dist/orchestration/dispatch-hint.d.ts +134 -0
- package/dist/orchestration/dispatch-hint.d.ts.map +1 -0
- package/dist/orchestration/dispatch-hint.js +247 -0
- package/dist/orchestration/dispatch-hint.js.map +1 -0
- package/dist/orchestration/dispatch-runner.d.ts +106 -0
- package/dist/orchestration/dispatch-runner.d.ts.map +1 -0
- package/dist/orchestration/dispatch-runner.js +604 -0
- package/dist/orchestration/dispatch-runner.js.map +1 -0
- package/dist/orchestration/dispatch-tools.d.ts +167 -0
- package/dist/orchestration/dispatch-tools.d.ts.map +1 -0
- package/dist/orchestration/dispatch-tools.js +328 -0
- package/dist/orchestration/dispatch-tools.js.map +1 -0
- package/dist/orchestration/front-door-policy.d.ts +35 -10
- package/dist/orchestration/front-door-policy.d.ts.map +1 -1
- package/dist/orchestration/front-door-policy.js +30 -267
- package/dist/orchestration/front-door-policy.js.map +1 -1
- package/dist/orchestration/orchestrator-dispatch-prompt.d.ts +43 -0
- package/dist/orchestration/orchestrator-dispatch-prompt.d.ts.map +1 -0
- package/dist/orchestration/orchestrator-dispatch-prompt.js +267 -0
- package/dist/orchestration/orchestrator-dispatch-prompt.js.map +1 -0
- package/dist/orchestration/orchestrator-operating-prompt.d.ts +14 -0
- package/dist/orchestration/orchestrator-operating-prompt.d.ts.map +1 -1
- package/dist/orchestration/orchestrator-operating-prompt.js +157 -31
- package/dist/orchestration/orchestrator-operating-prompt.js.map +1 -1
- package/dist/orchestration/plan-import.d.ts +39 -0
- package/dist/orchestration/plan-import.d.ts.map +1 -0
- package/dist/orchestration/plan-import.js +547 -0
- package/dist/orchestration/plan-import.js.map +1 -0
- package/dist/orchestration/worker-operating-prompt.d.ts +2 -0
- package/dist/orchestration/worker-operating-prompt.d.ts.map +1 -1
- package/dist/orchestration/worker-operating-prompt.js +36 -46
- package/dist/orchestration/worker-operating-prompt.js.map +1 -1
- package/dist/orchestrator.d.ts +195 -3
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +1970 -432
- package/dist/orchestrator.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +8 -4
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/claude-cli.d.ts.map +1 -1
- package/dist/providers/claude-cli.js +28 -3
- package/dist/providers/claude-cli.js.map +1 -1
- package/dist/providers/codex-cli.d.ts +10 -6
- package/dist/providers/codex-cli.d.ts.map +1 -1
- package/dist/providers/codex-cli.js +190 -17
- package/dist/providers/codex-cli.js.map +1 -1
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +15 -5
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/index.d.ts +15 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +13 -5
- package/dist/providers/openai.js.map +1 -1
- package/dist/server-adapter.d.ts +8 -0
- package/dist/server-adapter.d.ts.map +1 -1
- package/dist/server-adapter.js +7 -0
- package/dist/server-adapter.js.map +1 -1
- package/dist/service-mode.d.ts +1 -1
- package/dist/service-mode.d.ts.map +1 -1
- package/dist/service-mode.js +64 -1
- package/dist/service-mode.js.map +1 -1
- package/dist/service-setup-only.d.ts +8 -0
- package/dist/service-setup-only.d.ts.map +1 -0
- package/dist/service-setup-only.js +37 -0
- package/dist/service-setup-only.js.map +1 -0
- package/dist/slash-commands.d.ts +21 -0
- package/dist/slash-commands.d.ts.map +1 -0
- package/dist/slash-commands.js +99 -0
- package/dist/slash-commands.js.map +1 -0
- package/dist/subagent/index.d.ts +4 -2
- package/dist/subagent/index.d.ts.map +1 -1
- package/dist/subagent/index.js.map +1 -1
- package/dist/summarization-pipeline.d.ts.map +1 -1
- package/dist/summarization-pipeline.js +1 -9
- package/dist/summarization-pipeline.js.map +1 -1
- package/dist/token-counter.d.ts.map +1 -1
- package/dist/token-counter.js +11 -4
- package/dist/token-counter.js.map +1 -1
- package/dist/tool-filter.d.ts.map +1 -1
- package/dist/tool-filter.js +10 -6
- package/dist/tool-filter.js.map +1 -1
- package/dist/tools/admin-tools.d.ts.map +1 -1
- package/dist/tools/admin-tools.js +13 -4
- package/dist/tools/admin-tools.js.map +1 -1
- package/dist/tools/run-command.d.ts.map +1 -1
- package/dist/tools/run-command.js +5 -1
- package/dist/tools/run-command.js.map +1 -1
- package/dist/tools/search-conversation-history.d.ts.map +1 -1
- package/dist/tools/search-conversation-history.js +12 -2
- package/dist/tools/search-conversation-history.js.map +1 -1
- package/dist/tools/todo-tasks.d.ts.map +1 -1
- package/dist/tools/todo-tasks.js +77 -5
- package/dist/tools/todo-tasks.js.map +1 -1
- package/dist/usage-log.d.ts +62 -0
- package/dist/usage-log.d.ts.map +1 -0
- package/dist/usage-log.js +98 -0
- package/dist/usage-log.js.map +1 -0
- package/dist/wizard-state.d.ts +13 -0
- package/dist/wizard-state.d.ts.map +1 -1
- package/dist/wizard-state.js +61 -3
- package/dist/wizard-state.js.map +1 -1
- package/dist/wizard-support.d.ts.map +1 -1
- package/dist/wizard-support.js +27 -1
- package/dist/wizard-support.js.map +1 -1
- package/dist/workflow-engine.d.ts +40 -1
- package/dist/workflow-engine.d.ts.map +1 -1
- package/dist/workflow-engine.js +753 -93
- package/dist/workflow-engine.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sync MCP server configs to CLI provider native config files.
|
|
3
3
|
*
|
|
4
|
-
* For `claude-cli`: writes to
|
|
5
|
-
* both user-installed MCP servers and the funolio-tools bridge
|
|
4
|
+
* For `claude-cli`: writes to the selected Claude JSON config so Claude Code
|
|
5
|
+
* can discover both user-installed MCP servers and the funolio-tools bridge.
|
|
6
6
|
*/
|
|
7
|
+
export type CliProviderId = 'claude-cli' | 'codex-cli';
|
|
8
|
+
export declare function getCliProviderSessionHome(provider: CliProviderId): string;
|
|
9
|
+
export declare function getCliBotSessionHome(provider: CliProviderId, botId: string): string;
|
|
10
|
+
export declare function getCliSessionRuntimeHome(provider: CliProviderId, botId: string, conversationId: string): string;
|
|
11
|
+
export declare function claudeUserCredentialsPath(): string;
|
|
12
|
+
export declare function claudeCanonicalCredentialsPath(): string;
|
|
13
|
+
export declare function syncClaudeCanonicalCredentials(): string | null;
|
|
14
|
+
export declare function promoteClaudeBotHomeCredentialsToCanonical(botHomeDir: string): string | null;
|
|
15
|
+
export declare function forceSyncClaudeCanonicalCredentialsFromUser(): string | null;
|
|
16
|
+
export declare function resolveClaudeCredentialsSourcePath(): string | null;
|
|
17
|
+
export declare function ensureCliBotSessionHome(provider: CliProviderId, botId: string): string;
|
|
18
|
+
export declare function ensureCliSessionRuntimeHome(provider: CliProviderId, botId: string, conversationId: string): string;
|
|
19
|
+
export declare function claudeJsonConfigPath(baseDir?: string): string;
|
|
7
20
|
export declare function resolvePackagedAgentCommand(): string;
|
|
8
21
|
/**
|
|
9
22
|
* Sync installed MCP servers + funolio-tools bridge to the CLI provider's
|
|
@@ -11,9 +24,34 @@ export declare function resolvePackagedAgentCommand(): string;
|
|
|
11
24
|
*
|
|
12
25
|
* @returns Summary string for logging.
|
|
13
26
|
*/
|
|
14
|
-
export declare function syncMcpToCliConfig(provider: string
|
|
15
|
-
|
|
27
|
+
export declare function syncMcpToCliConfig(provider: string, funolioToolEnv?: Record<string, string>, target?: {
|
|
28
|
+
claudeJsonPath?: string;
|
|
29
|
+
codexHomeDir?: string;
|
|
30
|
+
}): Promise<string>;
|
|
31
|
+
export declare function syncClaudeJsonConfig(funolioToolEnv?: Record<string, string>, claudeJsonPath?: string): string;
|
|
32
|
+
export declare function codexConfigPath(baseDir?: string): string;
|
|
16
33
|
export declare function stripCodexMcpSection(raw: string, name: string): string;
|
|
17
34
|
export declare function appendCodexMcpStdio(raw: string, name: string, command: string, args: string[], envVars?: Record<string, string>): string;
|
|
18
35
|
export declare const CODEX_FUNOLIO_SERVER_NAME = "funolio_tools";
|
|
36
|
+
type ClaudeBotSettingsInput = {
|
|
37
|
+
model?: string | null;
|
|
38
|
+
effortLevel?: string | null;
|
|
39
|
+
outputStyle?: string | null;
|
|
40
|
+
fastMode?: boolean | null;
|
|
41
|
+
permissions?: Record<string, unknown> | null;
|
|
42
|
+
};
|
|
43
|
+
export declare function writeClaudeBotSettings(botId: string, settings: ClaudeBotSettingsInput): string;
|
|
44
|
+
export declare function claudeBotSettingsPath(botId: string): string;
|
|
45
|
+
export declare function readClaudeBotSettings(botId: string): ClaudeBotSettingsInput;
|
|
46
|
+
type CodexBotConfigInput = {
|
|
47
|
+
model?: string | null;
|
|
48
|
+
modelReasoningEffort?: string | null;
|
|
49
|
+
personality?: string | null;
|
|
50
|
+
serviceTier?: string | null;
|
|
51
|
+
sandbox?: string | null;
|
|
52
|
+
approvalPolicy?: string | null;
|
|
53
|
+
};
|
|
54
|
+
export declare function writeCodexBotConfig(botId: string, config: CodexBotConfigInput): string;
|
|
55
|
+
export declare function readCodexBotConfig(botId: string): CodexBotConfigInput;
|
|
56
|
+
export {};
|
|
19
57
|
//# sourceMappingURL=sync-cli-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-cli-config.d.ts","sourceRoot":"","sources":["../../src/mcp/sync-cli-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"sync-cli-config.d.ts","sourceRoot":"","sources":["../../src/mcp/sync-cli-config.ts"],"names":[],"mappings":"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"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Sync MCP server configs to CLI provider native config files.
|
|
4
4
|
*
|
|
5
|
-
* For `claude-cli`: writes to
|
|
6
|
-
* both user-installed MCP servers and the funolio-tools bridge
|
|
5
|
+
* For `claude-cli`: writes to the selected Claude JSON config so Claude Code
|
|
6
|
+
* can discover both user-installed MCP servers and the funolio-tools bridge.
|
|
7
7
|
*/
|
|
8
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
9
|
if (k2 === undefined) k2 = k;
|
|
@@ -40,20 +40,316 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
40
|
})();
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.CODEX_FUNOLIO_SERVER_NAME = void 0;
|
|
43
|
+
exports.getCliProviderSessionHome = getCliProviderSessionHome;
|
|
44
|
+
exports.getCliBotSessionHome = getCliBotSessionHome;
|
|
45
|
+
exports.getCliSessionRuntimeHome = getCliSessionRuntimeHome;
|
|
46
|
+
exports.claudeUserCredentialsPath = claudeUserCredentialsPath;
|
|
47
|
+
exports.claudeCanonicalCredentialsPath = claudeCanonicalCredentialsPath;
|
|
48
|
+
exports.syncClaudeCanonicalCredentials = syncClaudeCanonicalCredentials;
|
|
49
|
+
exports.promoteClaudeBotHomeCredentialsToCanonical = promoteClaudeBotHomeCredentialsToCanonical;
|
|
50
|
+
exports.forceSyncClaudeCanonicalCredentialsFromUser = forceSyncClaudeCanonicalCredentialsFromUser;
|
|
51
|
+
exports.resolveClaudeCredentialsSourcePath = resolveClaudeCredentialsSourcePath;
|
|
52
|
+
exports.ensureCliBotSessionHome = ensureCliBotSessionHome;
|
|
53
|
+
exports.ensureCliSessionRuntimeHome = ensureCliSessionRuntimeHome;
|
|
54
|
+
exports.claudeJsonConfigPath = claudeJsonConfigPath;
|
|
43
55
|
exports.resolvePackagedAgentCommand = resolvePackagedAgentCommand;
|
|
44
56
|
exports.syncMcpToCliConfig = syncMcpToCliConfig;
|
|
57
|
+
exports.syncClaudeJsonConfig = syncClaudeJsonConfig;
|
|
45
58
|
exports.codexConfigPath = codexConfigPath;
|
|
46
59
|
exports.stripCodexMcpSection = stripCodexMcpSection;
|
|
47
60
|
exports.appendCodexMcpStdio = appendCodexMcpStdio;
|
|
61
|
+
exports.writeClaudeBotSettings = writeClaudeBotSettings;
|
|
62
|
+
exports.claudeBotSettingsPath = claudeBotSettingsPath;
|
|
63
|
+
exports.readClaudeBotSettings = readClaudeBotSettings;
|
|
64
|
+
exports.writeCodexBotConfig = writeCodexBotConfig;
|
|
65
|
+
exports.readCodexBotConfig = readCodexBotConfig;
|
|
48
66
|
const fs = __importStar(require("fs"));
|
|
49
67
|
const path = __importStar(require("path"));
|
|
50
68
|
const os = __importStar(require("os"));
|
|
51
69
|
const config_1 = require("../config");
|
|
70
|
+
function resolveHomeDir() {
|
|
71
|
+
const override = process.env.FUNOLIO_CLI_HOME_OVERRIDE?.trim();
|
|
72
|
+
return override || os.homedir();
|
|
73
|
+
}
|
|
74
|
+
function funolioCliSessionsRoot() {
|
|
75
|
+
return path.join(resolveHomeDir(), '.funolio', 'cli-sessions');
|
|
76
|
+
}
|
|
77
|
+
function providerDirName(provider) {
|
|
78
|
+
return provider === 'claude-cli' ? 'claude' : 'codex';
|
|
79
|
+
}
|
|
80
|
+
function getCliProviderSessionHome(provider) {
|
|
81
|
+
return path.join(funolioCliSessionsRoot(), providerDirName(provider));
|
|
82
|
+
}
|
|
83
|
+
function getCliBotSessionHome(provider, botId) {
|
|
84
|
+
return path.join(getCliProviderSessionHome(provider), botId);
|
|
85
|
+
}
|
|
86
|
+
function safeSessionDirName(value) {
|
|
87
|
+
const normalized = String(value || '').trim();
|
|
88
|
+
if (!normalized)
|
|
89
|
+
return 'session';
|
|
90
|
+
return normalized.replace(/[^a-zA-Z0-9._-]/g, '_');
|
|
91
|
+
}
|
|
92
|
+
function getCliSessionRuntimeHome(provider, botId, conversationId) {
|
|
93
|
+
return path.join(getCliBotSessionHome(provider, botId), 'runtime', safeSessionDirName(conversationId));
|
|
94
|
+
}
|
|
95
|
+
function userCliHome(provider) {
|
|
96
|
+
return path.join(resolveHomeDir(), provider === 'claude-cli' ? '.claude' : '.codex');
|
|
97
|
+
}
|
|
98
|
+
function copyDirectoryRecursive(sourceDir, targetDir) {
|
|
99
|
+
if (!fs.existsSync(sourceDir))
|
|
100
|
+
return;
|
|
101
|
+
if (!fs.existsSync(targetDir))
|
|
102
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
103
|
+
for (const entry of fs.readdirSync(sourceDir, { withFileTypes: true })) {
|
|
104
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
105
|
+
const targetPath = path.join(targetDir, entry.name);
|
|
106
|
+
if (entry.isDirectory()) {
|
|
107
|
+
copyDirectoryRecursive(sourcePath, targetPath);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (!entry.isFile())
|
|
111
|
+
continue;
|
|
112
|
+
if (!fs.existsSync(targetPath)) {
|
|
113
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function copyFileIfPresent(sourcePath, targetPath, overwrite = false) {
|
|
118
|
+
if (!fs.existsSync(sourcePath))
|
|
119
|
+
return;
|
|
120
|
+
if (!overwrite && fs.existsSync(targetPath))
|
|
121
|
+
return;
|
|
122
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
123
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
124
|
+
}
|
|
125
|
+
function fileMtimeMs(filePath) {
|
|
126
|
+
try {
|
|
127
|
+
return fs.statSync(filePath).mtimeMs;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function readClaudeOauthJson(filePath) {
|
|
134
|
+
try {
|
|
135
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
136
|
+
const oauth = parsed.claudeAiOauth;
|
|
137
|
+
return oauth && typeof oauth === 'object' ? oauth : null;
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function toNonEmptyString(value) {
|
|
144
|
+
return typeof value === 'string' && value.trim() ? value : null;
|
|
145
|
+
}
|
|
146
|
+
function toEpochMs(value) {
|
|
147
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
148
|
+
return value;
|
|
149
|
+
if (typeof value === 'string' && value.trim()) {
|
|
150
|
+
const asNumber = Number(value);
|
|
151
|
+
if (Number.isFinite(asNumber))
|
|
152
|
+
return asNumber;
|
|
153
|
+
const asDate = Date.parse(value);
|
|
154
|
+
return Number.isFinite(asDate) ? asDate : null;
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
function mergeClaudeOauth(baseOauth, incomingOauth) {
|
|
159
|
+
if (!baseOauth && !incomingOauth)
|
|
160
|
+
return null;
|
|
161
|
+
if (!baseOauth)
|
|
162
|
+
return incomingOauth ? { ...incomingOauth } : null;
|
|
163
|
+
if (!incomingOauth)
|
|
164
|
+
return { ...baseOauth };
|
|
165
|
+
const baseAccess = toNonEmptyString(baseOauth.accessToken);
|
|
166
|
+
const incomingAccess = toNonEmptyString(incomingOauth.accessToken);
|
|
167
|
+
const baseRefresh = toNonEmptyString(baseOauth.refreshToken);
|
|
168
|
+
const incomingRefresh = toNonEmptyString(incomingOauth.refreshToken);
|
|
169
|
+
const baseExpiry = toEpochMs(baseOauth.expiresAt);
|
|
170
|
+
const incomingExpiry = toEpochMs(incomingOauth.expiresAt);
|
|
171
|
+
let accessToken = baseAccess;
|
|
172
|
+
if (!accessToken && incomingAccess) {
|
|
173
|
+
accessToken = incomingAccess;
|
|
174
|
+
}
|
|
175
|
+
else if (incomingAccess
|
|
176
|
+
&& incomingAccess !== baseAccess
|
|
177
|
+
&& (!!incomingRefresh
|
|
178
|
+
|| !baseAccess
|
|
179
|
+
|| ((incomingExpiry ?? -1) > (baseExpiry ?? -1)))) {
|
|
180
|
+
accessToken = incomingAccess;
|
|
181
|
+
}
|
|
182
|
+
const refreshToken = incomingRefresh || baseRefresh || '';
|
|
183
|
+
const expiresAt = Math.max(baseExpiry ?? 0, incomingExpiry ?? 0) || incomingOauth.expiresAt || baseOauth.expiresAt;
|
|
184
|
+
return {
|
|
185
|
+
...baseOauth,
|
|
186
|
+
...incomingOauth,
|
|
187
|
+
...(accessToken ? { accessToken } : {}),
|
|
188
|
+
refreshToken,
|
|
189
|
+
expiresAt,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function writeClaudeOauthJson(targetPath, oauth) {
|
|
193
|
+
const existing = readJsonFile(targetPath);
|
|
194
|
+
const payload = existing && typeof existing === 'object' ? existing : {};
|
|
195
|
+
payload.claudeAiOauth = oauth;
|
|
196
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
197
|
+
fs.writeFileSync(targetPath, JSON.stringify(payload, null, 2), 'utf-8');
|
|
198
|
+
}
|
|
199
|
+
function removeFileIfPresent(filePath) {
|
|
200
|
+
try {
|
|
201
|
+
if (fs.existsSync(filePath))
|
|
202
|
+
fs.unlinkSync(filePath);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// best effort
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function claudeUserCredentialsPath() {
|
|
209
|
+
return path.join(userCliHome('claude-cli'), '.credentials.json');
|
|
210
|
+
}
|
|
211
|
+
function claudeCanonicalCredentialsPath() {
|
|
212
|
+
return path.join(getCliProviderSessionHome('claude-cli'), '.credentials.json');
|
|
213
|
+
}
|
|
214
|
+
function overwriteFileFromSource(sourcePath, targetPath) {
|
|
215
|
+
if (!fs.existsSync(sourcePath))
|
|
216
|
+
return false;
|
|
217
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
218
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
function syncClaudeCanonicalCredentials() {
|
|
222
|
+
const canonicalPath = claudeCanonicalCredentialsPath();
|
|
223
|
+
return fs.existsSync(canonicalPath) ? canonicalPath : null;
|
|
224
|
+
}
|
|
225
|
+
function promoteClaudeBotHomeCredentialsToCanonical(botHomeDir) {
|
|
226
|
+
const botPath = path.join(botHomeDir, '.credentials.json');
|
|
227
|
+
if (!fs.existsSync(botPath)) {
|
|
228
|
+
return syncClaudeCanonicalCredentials();
|
|
229
|
+
}
|
|
230
|
+
const canonicalPath = claudeCanonicalCredentialsPath();
|
|
231
|
+
if (!fs.existsSync(canonicalPath)) {
|
|
232
|
+
try {
|
|
233
|
+
overwriteFileFromSource(botPath, canonicalPath);
|
|
234
|
+
return canonicalPath;
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return syncClaudeCanonicalCredentials();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
const merged = mergeClaudeOauth(readClaudeOauthJson(canonicalPath), readClaudeOauthJson(botPath));
|
|
242
|
+
if (merged) {
|
|
243
|
+
writeClaudeOauthJson(canonicalPath, merged);
|
|
244
|
+
return canonicalPath;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// fall through
|
|
249
|
+
}
|
|
250
|
+
return syncClaudeCanonicalCredentials();
|
|
251
|
+
}
|
|
252
|
+
function forceSyncClaudeCanonicalCredentialsFromUser() {
|
|
253
|
+
const userPath = claudeUserCredentialsPath();
|
|
254
|
+
const canonicalPath = claudeCanonicalCredentialsPath();
|
|
255
|
+
if (!fs.existsSync(userPath))
|
|
256
|
+
return fs.existsSync(canonicalPath) ? canonicalPath : null;
|
|
257
|
+
try {
|
|
258
|
+
overwriteFileFromSource(userPath, canonicalPath);
|
|
259
|
+
return canonicalPath;
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function resolveClaudeCredentialsSourcePath() {
|
|
266
|
+
return syncClaudeCanonicalCredentials();
|
|
267
|
+
}
|
|
268
|
+
function syncClaudeCredentialsIntoBotHome(targetDir) {
|
|
269
|
+
const sourcePath = syncClaudeCanonicalCredentials();
|
|
270
|
+
const targetPath = path.join(targetDir, '.credentials.json');
|
|
271
|
+
if (!sourcePath) {
|
|
272
|
+
removeFileIfPresent(targetPath);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
overwriteFileFromSource(sourcePath, targetPath);
|
|
276
|
+
}
|
|
277
|
+
function seedCliBotSessionHome(provider, targetDir) {
|
|
278
|
+
const sources = [getCliProviderSessionHome(provider), userCliHome(provider)];
|
|
279
|
+
for (const sourceDir of sources) {
|
|
280
|
+
if (!fs.existsSync(sourceDir))
|
|
281
|
+
continue;
|
|
282
|
+
if (provider === 'claude-cli') {
|
|
283
|
+
copyFileIfPresent(path.join(sourceDir, 'settings.json'), path.join(targetDir, 'settings.json'));
|
|
284
|
+
const pluginsDir = path.join(sourceDir, 'plugins');
|
|
285
|
+
if (fs.existsSync(pluginsDir)) {
|
|
286
|
+
copyDirectoryRecursive(pluginsDir, path.join(targetDir, 'plugins'));
|
|
287
|
+
}
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
for (const fileName of ['auth.json', 'config.toml', 'version.json', 'installation_id', 'cap_sid', '.env', '.personality_migration']) {
|
|
291
|
+
copyFileIfPresent(path.join(sourceDir, fileName), path.join(targetDir, fileName));
|
|
292
|
+
}
|
|
293
|
+
for (const dirName of ['rules', 'skills', 'memories']) {
|
|
294
|
+
const sourcePath = path.join(sourceDir, dirName);
|
|
295
|
+
if (fs.existsSync(sourcePath)) {
|
|
296
|
+
copyDirectoryRecursive(sourcePath, path.join(targetDir, dirName));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function refreshCliBotSessionRuntimeFiles(provider, targetDir) {
|
|
303
|
+
if (provider === 'claude-cli') {
|
|
304
|
+
syncClaudeCredentialsIntoBotHome(targetDir);
|
|
305
|
+
copyFileIfPresent(claudeJsonConfigPath(), path.join(targetDir, '.claude.json'), true);
|
|
306
|
+
copyFileIfPresent(path.join(userCliHome(provider), 'settings.json'), path.join(targetDir, 'settings.json'), true);
|
|
307
|
+
ensureClaudeBotSettingsDefaults(path.join(targetDir, 'settings.json'));
|
|
308
|
+
const sourceDir = userCliHome(provider);
|
|
309
|
+
const pluginsDir = path.join(sourceDir, 'plugins');
|
|
310
|
+
if (fs.existsSync(pluginsDir)) {
|
|
311
|
+
copyDirectoryRecursive(pluginsDir, path.join(targetDir, 'plugins'));
|
|
312
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const sourceDir = userCliHome(provider);
|
|
316
|
+
if (!fs.existsSync(sourceDir))
|
|
317
|
+
return;
|
|
318
|
+
for (const fileName of ['auth.json', 'version.json', 'installation_id', 'cap_sid', '.env', '.personality_migration']) {
|
|
319
|
+
copyFileIfPresent(path.join(sourceDir, fileName), path.join(targetDir, fileName), true);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function ensureCliSessionHome(provider, targetDir) {
|
|
323
|
+
if (!fs.existsSync(targetDir)) {
|
|
324
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
325
|
+
}
|
|
326
|
+
seedCliBotSessionHome(provider, targetDir);
|
|
327
|
+
refreshCliBotSessionRuntimeFiles(provider, targetDir);
|
|
328
|
+
return targetDir;
|
|
329
|
+
}
|
|
330
|
+
function ensureCliBotSessionHome(provider, botId) {
|
|
331
|
+
return ensureCliSessionHome(provider, getCliBotSessionHome(provider, botId));
|
|
332
|
+
}
|
|
333
|
+
function ensureCliSessionRuntimeHome(provider, botId, conversationId) {
|
|
334
|
+
return ensureCliSessionHome(provider, getCliSessionRuntimeHome(provider, botId, conversationId));
|
|
335
|
+
}
|
|
336
|
+
function claudeJsonConfigPath(baseDir) {
|
|
337
|
+
return baseDir
|
|
338
|
+
? path.join(baseDir, '.claude.json')
|
|
339
|
+
: path.join(resolveHomeDir(), '.claude.json');
|
|
340
|
+
}
|
|
52
341
|
function resolvePackagedAgentCommand() {
|
|
53
342
|
const execBase = path.basename(process.execPath).toLowerCase();
|
|
54
343
|
if (execBase === 'funolio-agent' || execBase === 'funolio-agent.exe') {
|
|
55
344
|
return process.execPath;
|
|
56
345
|
}
|
|
346
|
+
const argvCliCandidate = process.argv[1];
|
|
347
|
+
if (argvCliCandidate
|
|
348
|
+
&& path.basename(argvCliCandidate).toLowerCase() === 'cli.js'
|
|
349
|
+
&& argvCliCandidate.toLowerCase().includes(`${path.sep}funolio-agent${path.sep}`)
|
|
350
|
+
&& fs.existsSync(argvCliCandidate)) {
|
|
351
|
+
return argvCliCandidate;
|
|
352
|
+
}
|
|
57
353
|
const exeName = process.platform === 'win32' ? 'funolio-agent.exe' : 'funolio-agent';
|
|
58
354
|
const installedCandidate = process.platform === 'win32'
|
|
59
355
|
? path.join(os.homedir(), 'AppData', 'Local', 'Funolio', exeName)
|
|
@@ -61,7 +357,17 @@ function resolvePackagedAgentCommand() {
|
|
|
61
357
|
if (fs.existsSync(installedCandidate)) {
|
|
62
358
|
return installedCandidate;
|
|
63
359
|
}
|
|
64
|
-
|
|
360
|
+
if (process.platform !== 'win32') {
|
|
361
|
+
const localBinCandidate = '/usr/local/bin/funolio-agent';
|
|
362
|
+
if (fs.existsSync(localBinCandidate)) {
|
|
363
|
+
return localBinCandidate;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const distCliCandidate = path.resolve(__dirname, '..', 'cli.js');
|
|
367
|
+
if (fs.existsSync(distCliCandidate)) {
|
|
368
|
+
return distCliCandidate;
|
|
369
|
+
}
|
|
370
|
+
const distCandidate = path.resolve(__dirname, '..', '..', 'dist', 'cli.js');
|
|
65
371
|
if (fs.existsSync(distCandidate)) {
|
|
66
372
|
return distCandidate;
|
|
67
373
|
}
|
|
@@ -73,19 +379,18 @@ function resolvePackagedAgentCommand() {
|
|
|
73
379
|
*
|
|
74
380
|
* @returns Summary string for logging.
|
|
75
381
|
*/
|
|
76
|
-
async function syncMcpToCliConfig(provider) {
|
|
382
|
+
async function syncMcpToCliConfig(provider, funolioToolEnv, target) {
|
|
77
383
|
if (provider === 'claude-cli') {
|
|
78
|
-
return syncToClaudeJson();
|
|
384
|
+
return syncToClaudeJson(target?.claudeJsonPath);
|
|
79
385
|
}
|
|
80
386
|
if (provider === 'codex-cli') {
|
|
81
|
-
return syncToCodexCli();
|
|
387
|
+
return syncToCodexCli(funolioToolEnv, target?.codexHomeDir);
|
|
82
388
|
}
|
|
83
389
|
return `[MCP sync] Provider "${provider}" is not a CLI provider — skipping`;
|
|
84
390
|
}
|
|
85
|
-
function
|
|
86
|
-
const claudeJsonPath = path.join(os.homedir(), '.claude.json');
|
|
391
|
+
function syncClaudeJsonConfig(funolioToolEnv = {}, claudeJsonPath = claudeJsonConfigPath()) {
|
|
87
392
|
let config = {};
|
|
88
|
-
// Read existing
|
|
393
|
+
// Read existing Claude JSON config.
|
|
89
394
|
try {
|
|
90
395
|
if (fs.existsSync(claudeJsonPath)) {
|
|
91
396
|
config = JSON.parse(fs.readFileSync(claudeJsonPath, 'utf-8'));
|
|
@@ -132,18 +437,30 @@ function syncToClaudeJson() {
|
|
|
132
437
|
}
|
|
133
438
|
// 2. Add the funolio-tools bridge server through the packaged binary.
|
|
134
439
|
const agentCommand = resolvePackagedAgentCommand();
|
|
440
|
+
const funolioEnv = {};
|
|
441
|
+
if (process.env.BRAVE_API_KEY)
|
|
442
|
+
funolioEnv.BRAVE_API_KEY = process.env.BRAVE_API_KEY;
|
|
443
|
+
for (const [key, value] of Object.entries(funolioToolEnv || {})) {
|
|
444
|
+
if (!value || !String(value).trim())
|
|
445
|
+
continue;
|
|
446
|
+
funolioEnv[key] = String(value);
|
|
447
|
+
}
|
|
135
448
|
config.mcpServers['funolio-tools'] = {
|
|
136
449
|
command: agentCommand,
|
|
137
450
|
args: ['mcp-serve'],
|
|
138
|
-
env:
|
|
451
|
+
env: Object.keys(funolioEnv).length > 0 ? funolioEnv : undefined,
|
|
139
452
|
};
|
|
140
453
|
serverCount++;
|
|
141
|
-
|
|
454
|
+
ensureClaudeJsonOnboardingDefaults(config);
|
|
455
|
+
// Write back the selected Claude JSON config.
|
|
142
456
|
fs.writeFileSync(claudeJsonPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
143
|
-
return `[MCP sync] Wrote ${serverCount} MCP server(s) to
|
|
457
|
+
return `[MCP sync] Wrote ${serverCount} MCP server(s) to ${claudeJsonPath} (including funolio-tools bridge)`;
|
|
458
|
+
}
|
|
459
|
+
function syncToClaudeJson(claudeJsonPath) {
|
|
460
|
+
return syncClaudeJsonConfig({}, claudeJsonPath || claudeJsonConfigPath());
|
|
144
461
|
}
|
|
145
|
-
function codexConfigPath() {
|
|
146
|
-
return path.join(
|
|
462
|
+
function codexConfigPath(baseDir) {
|
|
463
|
+
return path.join(baseDir || path.join(resolveHomeDir(), '.codex'), 'config.toml');
|
|
147
464
|
}
|
|
148
465
|
function stripCodexMcpSection(raw, name) {
|
|
149
466
|
const lines = raw.split(/\r?\n/);
|
|
@@ -183,11 +500,11 @@ function appendCodexMcpStdio(raw, name, command, args, envVars) {
|
|
|
183
500
|
}
|
|
184
501
|
return `${raw.trimEnd()}\n${lines.join('\n')}\n`;
|
|
185
502
|
}
|
|
186
|
-
function syncToCodexCli() {
|
|
503
|
+
function syncToCodexCli(funolioToolEnv, codexHomeDir) {
|
|
187
504
|
const codexFunolioServerName = exports.CODEX_FUNOLIO_SERVER_NAME;
|
|
188
505
|
let serverCount = 0;
|
|
189
506
|
const configuredNames = [];
|
|
190
|
-
const configPath = codexConfigPath();
|
|
507
|
+
const configPath = codexConfigPath(codexHomeDir);
|
|
191
508
|
if (!fs.existsSync(path.dirname(configPath))) {
|
|
192
509
|
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
193
510
|
}
|
|
@@ -219,11 +536,174 @@ function syncToCodexCli() {
|
|
|
219
536
|
catch {
|
|
220
537
|
// non-fatal
|
|
221
538
|
}
|
|
222
|
-
|
|
539
|
+
const mcpEnv = {};
|
|
540
|
+
if (process.env.BRAVE_API_KEY)
|
|
541
|
+
mcpEnv.BRAVE_API_KEY = process.env.BRAVE_API_KEY;
|
|
542
|
+
for (const [key, value] of Object.entries(funolioToolEnv || {})) {
|
|
543
|
+
if (value && String(value).trim())
|
|
544
|
+
mcpEnv[key] = String(value);
|
|
545
|
+
}
|
|
546
|
+
raw = appendCodexMcpStdio(raw, codexFunolioServerName, resolvePackagedAgentCommand(), ['mcp-serve'], Object.keys(mcpEnv).length > 0 ? mcpEnv : undefined);
|
|
223
547
|
serverCount++;
|
|
224
548
|
configuredNames.push(codexFunolioServerName);
|
|
225
549
|
fs.writeFileSync(configPath, raw, 'utf-8');
|
|
226
550
|
return `[MCP sync] Wrote ${serverCount} MCP server(s) to Codex CLI (${configuredNames.join(', ')})`;
|
|
227
551
|
}
|
|
228
552
|
exports.CODEX_FUNOLIO_SERVER_NAME = 'funolio_tools';
|
|
553
|
+
function readJsonFile(filePath) {
|
|
554
|
+
try {
|
|
555
|
+
if (fs.existsSync(filePath)) {
|
|
556
|
+
const parsed = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
557
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
558
|
+
return parsed;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
// fall through
|
|
564
|
+
}
|
|
565
|
+
return {};
|
|
566
|
+
}
|
|
567
|
+
function ensureClaudeBotSettingsDefaults(settingsPath) {
|
|
568
|
+
const next = readJsonFile(settingsPath);
|
|
569
|
+
let dirty = false;
|
|
570
|
+
if (next.skipDangerousModePermissionPrompt !== true) {
|
|
571
|
+
next.skipDangerousModePermissionPrompt = true;
|
|
572
|
+
dirty = true;
|
|
573
|
+
}
|
|
574
|
+
if (typeof next.theme !== 'string' || !next.theme.trim()) {
|
|
575
|
+
next.theme = 'dark';
|
|
576
|
+
dirty = true;
|
|
577
|
+
}
|
|
578
|
+
if (dirty) {
|
|
579
|
+
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
580
|
+
fs.writeFileSync(settingsPath, `${JSON.stringify(next, null, 2)}\n`, 'utf-8');
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
function ensureClaudeJsonOnboardingDefaults(config) {
|
|
584
|
+
if (config.hasCompletedOnboarding !== true) {
|
|
585
|
+
config.hasCompletedOnboarding = true;
|
|
586
|
+
}
|
|
587
|
+
if (typeof config.lastOnboardingVersion !== 'string' || !config.lastOnboardingVersion.trim()) {
|
|
588
|
+
config.lastOnboardingVersion = '2.1.0';
|
|
589
|
+
}
|
|
590
|
+
if (config.hasSeenTasksHint !== true) {
|
|
591
|
+
config.hasSeenTasksHint = true;
|
|
592
|
+
}
|
|
593
|
+
if (config.hasSeenStashHint !== true) {
|
|
594
|
+
config.hasSeenStashHint = true;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function writeClaudeBotSettings(botId, settings) {
|
|
598
|
+
const homeDir = ensureCliBotSessionHome('claude-cli', botId);
|
|
599
|
+
const settingsPath = path.join(homeDir, 'settings.json');
|
|
600
|
+
const next = readJsonFile(settingsPath);
|
|
601
|
+
const apply = (key, value) => {
|
|
602
|
+
if (value === undefined)
|
|
603
|
+
return;
|
|
604
|
+
if (value === null || value === '') {
|
|
605
|
+
delete next[key];
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
next[key] = value;
|
|
609
|
+
};
|
|
610
|
+
apply('model', settings.model ?? undefined);
|
|
611
|
+
apply('effortLevel', settings.effortLevel ?? undefined);
|
|
612
|
+
apply('outputStyle', settings.outputStyle ?? undefined);
|
|
613
|
+
apply('fastMode', settings.fastMode ?? undefined);
|
|
614
|
+
apply('permissions', settings.permissions ?? undefined);
|
|
615
|
+
fs.writeFileSync(settingsPath, `${JSON.stringify(next, null, 2)}\n`, 'utf-8');
|
|
616
|
+
ensureClaudeBotSettingsDefaults(settingsPath);
|
|
617
|
+
return settingsPath;
|
|
618
|
+
}
|
|
619
|
+
function claudeBotSettingsPath(botId) {
|
|
620
|
+
return path.join(ensureCliBotSessionHome('claude-cli', botId), 'settings.json');
|
|
621
|
+
}
|
|
622
|
+
function readClaudeBotSettings(botId) {
|
|
623
|
+
const settingsPath = claudeBotSettingsPath(botId);
|
|
624
|
+
const parsed = readJsonFile(settingsPath);
|
|
625
|
+
const permissions = parsed.permissions && typeof parsed.permissions === 'object' && !Array.isArray(parsed.permissions)
|
|
626
|
+
? parsed.permissions
|
|
627
|
+
: null;
|
|
628
|
+
return {
|
|
629
|
+
model: typeof parsed.model === 'string' ? parsed.model : null,
|
|
630
|
+
effortLevel: typeof parsed.effortLevel === 'string' ? parsed.effortLevel : null,
|
|
631
|
+
outputStyle: typeof parsed.outputStyle === 'string' ? parsed.outputStyle : null,
|
|
632
|
+
fastMode: typeof parsed.fastMode === 'boolean' ? parsed.fastMode : null,
|
|
633
|
+
permissions,
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function setTomlScalarValue(raw, key, value) {
|
|
637
|
+
const linePattern = new RegExp(`^${key.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\$&')}\\s*=.*$`, 'm');
|
|
638
|
+
if (value === undefined)
|
|
639
|
+
return raw;
|
|
640
|
+
if (value === null || value === '') {
|
|
641
|
+
return raw.replace(linePattern, '').replace(/\n{3,}/g, '\n\n').trimEnd();
|
|
642
|
+
}
|
|
643
|
+
const serialized = typeof value === 'string'
|
|
644
|
+
? JSON.stringify(value)
|
|
645
|
+
: typeof value === 'boolean'
|
|
646
|
+
? (value ? 'true' : 'false')
|
|
647
|
+
: String(value);
|
|
648
|
+
if (linePattern.test(raw)) {
|
|
649
|
+
return raw.replace(linePattern, `${key} = ${serialized}`);
|
|
650
|
+
}
|
|
651
|
+
const suffix = raw.trimEnd().length > 0 ? '\n' : '';
|
|
652
|
+
return `${raw.trimEnd()}${suffix}${key} = ${serialized}\n`;
|
|
653
|
+
}
|
|
654
|
+
function writeCodexBotConfig(botId, config) {
|
|
655
|
+
const homeDir = ensureCliBotSessionHome('codex-cli', botId);
|
|
656
|
+
const configPath = codexConfigPath(homeDir);
|
|
657
|
+
let raw = fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf-8') : '';
|
|
658
|
+
raw = setTomlScalarValue(raw, 'model', config.model ?? undefined);
|
|
659
|
+
raw = setTomlScalarValue(raw, 'model_reasoning_effort', config.modelReasoningEffort ?? undefined);
|
|
660
|
+
raw = setTomlScalarValue(raw, 'personality', config.personality ?? undefined);
|
|
661
|
+
raw = setTomlScalarValue(raw, 'service_tier', config.serviceTier ?? undefined);
|
|
662
|
+
raw = setTomlScalarValue(raw, 'sandbox', config.sandbox ?? undefined);
|
|
663
|
+
raw = setTomlScalarValue(raw, 'approval_policy', config.approvalPolicy ?? undefined);
|
|
664
|
+
raw = setTomlScalarValue(raw, 'funolio_statusline_json', null);
|
|
665
|
+
raw = setTomlScalarValue(raw, 'funolio_terminal_title_json', null);
|
|
666
|
+
raw = setTomlScalarValue(raw, 'funolio_experimental_flags_json', null);
|
|
667
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
668
|
+
fs.writeFileSync(configPath, raw.trimEnd() ? `${raw.trimEnd()}\n` : '', 'utf-8');
|
|
669
|
+
return configPath;
|
|
670
|
+
}
|
|
671
|
+
function readTomlScalarValue(raw, key) {
|
|
672
|
+
const linePattern = new RegExp(`^${key.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\$&')}\\s*=\\s*(.+)$`, 'm');
|
|
673
|
+
const match = linePattern.exec(raw);
|
|
674
|
+
if (!match)
|
|
675
|
+
return null;
|
|
676
|
+
const value = match[1].trim();
|
|
677
|
+
if (!value)
|
|
678
|
+
return null;
|
|
679
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
|
680
|
+
try {
|
|
681
|
+
return JSON.parse(value);
|
|
682
|
+
}
|
|
683
|
+
catch {
|
|
684
|
+
return value.slice(1, -1);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return value;
|
|
688
|
+
}
|
|
689
|
+
function readCodexBotConfig(botId) {
|
|
690
|
+
const configPath = codexConfigPath(ensureCliBotSessionHome('codex-cli', botId));
|
|
691
|
+
if (!fs.existsSync(configPath))
|
|
692
|
+
return {};
|
|
693
|
+
let raw = '';
|
|
694
|
+
try {
|
|
695
|
+
raw = fs.readFileSync(configPath, 'utf-8');
|
|
696
|
+
}
|
|
697
|
+
catch {
|
|
698
|
+
return {};
|
|
699
|
+
}
|
|
700
|
+
return {
|
|
701
|
+
model: readTomlScalarValue(raw, 'model'),
|
|
702
|
+
modelReasoningEffort: readTomlScalarValue(raw, 'model_reasoning_effort'),
|
|
703
|
+
personality: readTomlScalarValue(raw, 'personality'),
|
|
704
|
+
serviceTier: readTomlScalarValue(raw, 'service_tier'),
|
|
705
|
+
sandbox: readTomlScalarValue(raw, 'sandbox'),
|
|
706
|
+
approvalPolicy: readTomlScalarValue(raw, 'approval_policy'),
|
|
707
|
+
};
|
|
708
|
+
}
|
|
229
709
|
//# sourceMappingURL=sync-cli-config.js.map
|