open-walnut 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.js +247 -245
- package/dist/integrations/calendar/index.js +42 -36
- package/dist/integrations/jira/index.js +100 -78
- package/dist/integrations/ms-todo/index.js +94 -72
- package/dist/web/server.js +295 -293
- package/dist/web/static/assets/{OfficePreview-CEHO0xkd.js → OfficePreview-DcPiG7nq.js} +2 -2
- package/dist/web/static/assets/{docx-preview-CuZwjAMS.js → docx-preview-BWSwr6o8.js} +1 -1
- package/dist/web/static/assets/index-1mQq6abn.css +32 -0
- package/dist/web/static/assets/{index-BRLxNhyy.js → index-A2G2h66W.js} +1 -1
- package/dist/web/static/assets/{index-DrWzb338.js → index-BWTJQD8q.js} +1 -1
- package/dist/web/static/assets/{index-DLjK8dGE.js → index-BcxyDA3F.js} +1 -1
- package/dist/web/static/assets/{index-DR-LSqAg.js → index-CEldo7Tq.js} +1 -1
- package/dist/web/static/assets/{index-DOXm2Aye.js → index-CYY_N36O.js} +1 -1
- package/dist/web/static/assets/{index-D1dpOEzW.js → index-CakB6vm_.js} +1 -1
- package/dist/web/static/assets/{index-DAOPV34I.js → index-Ch4LQw8-.js} +1 -1
- package/dist/web/static/assets/{index-BBjg7m-_.js → index-CnmikCRj.js} +1 -1
- package/dist/web/static/assets/{index-DtRwkh8J.js → index-CtytO7Ce.js} +1 -1
- package/dist/web/static/assets/{index-DXtp_ZWh.js → index-CvUyfkEn.js} +1 -1
- package/dist/web/static/assets/{index-BFF_G72i.js → index-Cw6d8sbx.js} +245 -245
- package/dist/web/static/assets/{index-0MyC-yGG.js → index-DK9AxMTA.js} +1 -1
- package/dist/web/static/assets/{index-mWEwJcqw.js → index-DPeOcZuH.js} +1 -1
- package/dist/web/static/assets/{index-D9qPPm7h.js → index-DUWox7Cm.js} +1 -1
- package/dist/web/static/assets/{index-C2YGUYGS.js → index-Zb9B6znf.js} +1 -1
- package/dist/web/static/assets/{index-ccs5s80D.js → index-a6-uB8ph.js} +1 -1
- package/dist/web/static/assets/{index-Bqg4_WEG.js → index-aAfs_cWd.js} +1 -1
- package/dist/web/static/assets/{index-unnPilnK.js → index-xpwLXfWl.js} +1 -1
- package/dist/web/static/assets/{jszip.min-DYFwy4PE.js → jszip.min-BXx8_j4Y.js} +1 -1
- package/dist/web/static/assets/{pptx-preview.es-eu2nX9JC.js → pptx-preview.es-ByVfeUXp.js} +1 -1
- package/dist/web/static/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/static/assets/index-DeYCGmOR.css +0 -32
package/dist/cli.js
CHANGED
|
@@ -2996,10 +2996,155 @@ var init_model_catalog = __esm({
|
|
|
2996
2996
|
}
|
|
2997
2997
|
});
|
|
2998
2998
|
|
|
2999
|
-
// src/core/
|
|
3000
|
-
|
|
3001
|
-
|
|
2999
|
+
// src/core/claude-cli-detect.ts
|
|
3000
|
+
var claude_cli_detect_exports = {};
|
|
3001
|
+
__export(claude_cli_detect_exports, {
|
|
3002
|
+
_CLAUDE_CREDENTIALS_HOME: () => _CLAUDE_CREDENTIALS_HOME,
|
|
3003
|
+
describeClaudeCliAuth: () => describeClaudeCliAuth,
|
|
3004
|
+
detectClaudeCli: () => detectClaudeCli,
|
|
3005
|
+
hasClaudeSubscriptionAuth: () => hasClaudeSubscriptionAuth,
|
|
3006
|
+
isClaudeCliInstalled: () => isClaudeCliInstalled,
|
|
3007
|
+
resolveClaudeCliExecutable: () => resolveClaudeCliExecutable
|
|
3008
|
+
});
|
|
3009
|
+
import { execFileSync } from "child_process";
|
|
3010
|
+
import fs6 from "fs";
|
|
3002
3011
|
import os3 from "os";
|
|
3012
|
+
import path8 from "path";
|
|
3013
|
+
function resolveClaudeCliExecutable(env3 = process.env) {
|
|
3014
|
+
const home = env3.HOME || os3.homedir();
|
|
3015
|
+
const pathDirs = (env3.PATH ?? "").split(path8.delimiter).filter(Boolean);
|
|
3016
|
+
const fallbackDirs = [
|
|
3017
|
+
path8.join(home, ".toolbox", "bin"),
|
|
3018
|
+
path8.join(home, ".local", "bin"),
|
|
3019
|
+
path8.join(home, ".npm-global", "bin"),
|
|
3020
|
+
path8.join(home, ".bun", "bin"),
|
|
3021
|
+
"/usr/local/bin",
|
|
3022
|
+
"/opt/homebrew/bin",
|
|
3023
|
+
"/usr/bin",
|
|
3024
|
+
"/bin"
|
|
3025
|
+
];
|
|
3026
|
+
for (const dir2 of [.../* @__PURE__ */ new Set([...pathDirs, ...fallbackDirs])]) {
|
|
3027
|
+
const candidate = path8.join(dir2, "claude");
|
|
3028
|
+
try {
|
|
3029
|
+
fs6.accessSync(candidate, fs6.constants.X_OK);
|
|
3030
|
+
return candidate;
|
|
3031
|
+
} catch {
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
return null;
|
|
3035
|
+
}
|
|
3036
|
+
function isClaudeCliInstalled() {
|
|
3037
|
+
return resolveClaudeCliExecutable() !== null;
|
|
3038
|
+
}
|
|
3039
|
+
function hasClaudeSubscriptionAuth() {
|
|
3040
|
+
if (process.platform === "darwin") {
|
|
3041
|
+
try {
|
|
3042
|
+
execFileSync("security", ["find-generic-password", "-s", KEYCHAIN_OAUTH_SERVICE], {
|
|
3043
|
+
stdio: "ignore"
|
|
3044
|
+
});
|
|
3045
|
+
return true;
|
|
3046
|
+
} catch {
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
return fileCredentialExists();
|
|
3050
|
+
}
|
|
3051
|
+
function fileCredentialExists() {
|
|
3052
|
+
try {
|
|
3053
|
+
return fs6.existsSync(CLAUDE_CREDENTIALS_FILE);
|
|
3054
|
+
} catch {
|
|
3055
|
+
return false;
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
function detectClaudeCli() {
|
|
3059
|
+
const installed2 = isClaudeCliInstalled();
|
|
3060
|
+
const subscriptionAuth = installed2 && hasClaudeSubscriptionAuth();
|
|
3061
|
+
return {
|
|
3062
|
+
installed: installed2,
|
|
3063
|
+
subscriptionAuth,
|
|
3064
|
+
subscriptionReady: installed2 && subscriptionAuth,
|
|
3065
|
+
ready: installed2,
|
|
3066
|
+
auth: installed2 ? describeClaudeCliAuth() : { mode: "unknown", label: "not installed" }
|
|
3067
|
+
};
|
|
3068
|
+
}
|
|
3069
|
+
function describeClaudeCliAuth(env3 = process.env, settingsEnv = readClaudeSettingsEnv()) {
|
|
3070
|
+
const merged = { ...env3, ...settingsEnv };
|
|
3071
|
+
const truthy = (v3) => !!v3 && v3 !== "0" && v3.toLowerCase() !== "false";
|
|
3072
|
+
if (truthy(merged.CLAUDE_CODE_USE_BEDROCK)) {
|
|
3073
|
+
const region = merged.AWS_REGION || merged.AWS_DEFAULT_REGION;
|
|
3074
|
+
return { mode: "bedrock", label: region ? `Bedrock (${region})` : "Bedrock" };
|
|
3075
|
+
}
|
|
3076
|
+
if (truthy(merged.CLAUDE_CODE_USE_VERTEX)) return { mode: "vertex", label: "Vertex AI" };
|
|
3077
|
+
if (merged.ANTHROPIC_API_KEY || merged.ANTHROPIC_AUTH_TOKEN) return { mode: "api-key", label: "an Anthropic API key" };
|
|
3078
|
+
if (hasClaudeSubscriptionAuth()) return { mode: "subscription", label: "your Claude subscription" };
|
|
3079
|
+
return { mode: "unknown", label: "its own login" };
|
|
3080
|
+
}
|
|
3081
|
+
function readClaudeSettingsEnv() {
|
|
3082
|
+
try {
|
|
3083
|
+
const raw = fs6.readFileSync(path8.join(os3.homedir(), ".claude", "settings.json"), "utf8");
|
|
3084
|
+
const env3 = JSON.parse(raw).env ?? {};
|
|
3085
|
+
return Object.fromEntries(Object.entries(env3).filter(([, v3]) => typeof v3 === "string"));
|
|
3086
|
+
} catch {
|
|
3087
|
+
return {};
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
var KEYCHAIN_OAUTH_SERVICE, _CLAUDE_CREDENTIALS_HOME;
|
|
3091
|
+
var init_claude_cli_detect = __esm({
|
|
3092
|
+
"src/core/claude-cli-detect.ts"() {
|
|
3093
|
+
"use strict";
|
|
3094
|
+
init_constants();
|
|
3095
|
+
KEYCHAIN_OAUTH_SERVICE = "Claude Code-credentials";
|
|
3096
|
+
_CLAUDE_CREDENTIALS_HOME = os3.homedir();
|
|
3097
|
+
}
|
|
3098
|
+
});
|
|
3099
|
+
|
|
3100
|
+
// src/agent/providers/default-provider.ts
|
|
3101
|
+
var default_provider_exports = {};
|
|
3102
|
+
__export(default_provider_exports, {
|
|
3103
|
+
CLAUDE_CLI_PROVIDER: () => CLAUDE_CLI_PROVIDER,
|
|
3104
|
+
LEGACY_DEFAULT_PROVIDER: () => LEGACY_DEFAULT_PROVIDER,
|
|
3105
|
+
_resetDefaultProviderCacheForTesting: () => _resetDefaultProviderCacheForTesting,
|
|
3106
|
+
hasExplicitBedrockConfig: () => hasExplicitBedrockConfig,
|
|
3107
|
+
mainProviderIsImplicit: () => mainProviderIsImplicit,
|
|
3108
|
+
resolveMainProviderName: () => resolveMainProviderName
|
|
3109
|
+
});
|
|
3110
|
+
function claudeCliInstalledCached() {
|
|
3111
|
+
const now = Date.now();
|
|
3112
|
+
if (!cliProbe || now - cliProbe.at > CLI_PROBE_TTL_MS) {
|
|
3113
|
+
cliProbe = { at: now, installed: isClaudeCliInstalled() };
|
|
3114
|
+
}
|
|
3115
|
+
return cliProbe.installed;
|
|
3116
|
+
}
|
|
3117
|
+
function _resetDefaultProviderCacheForTesting() {
|
|
3118
|
+
cliProbe = void 0;
|
|
3119
|
+
}
|
|
3120
|
+
function hasExplicitBedrockConfig(config) {
|
|
3121
|
+
const b8 = config.providers?.bedrock;
|
|
3122
|
+
if (b8 && (b8.bearer_token || b8.aws_access_key_id || b8.aws_profile || b8.aws_credential_export)) return true;
|
|
3123
|
+
return !!config.provider?.bedrock_bearer_token;
|
|
3124
|
+
}
|
|
3125
|
+
function resolveMainProviderName(config, claudeInstalled = claudeCliInstalledCached()) {
|
|
3126
|
+
if (config.agent?.main_provider) return config.agent.main_provider;
|
|
3127
|
+
if (claudeInstalled) return CLAUDE_CLI_PROVIDER;
|
|
3128
|
+
return LEGACY_DEFAULT_PROVIDER;
|
|
3129
|
+
}
|
|
3130
|
+
function mainProviderIsImplicit(config) {
|
|
3131
|
+
return !config.agent?.main_provider;
|
|
3132
|
+
}
|
|
3133
|
+
var LEGACY_DEFAULT_PROVIDER, CLAUDE_CLI_PROVIDER, CLI_PROBE_TTL_MS, cliProbe;
|
|
3134
|
+
var init_default_provider = __esm({
|
|
3135
|
+
"src/agent/providers/default-provider.ts"() {
|
|
3136
|
+
"use strict";
|
|
3137
|
+
init_claude_cli_detect();
|
|
3138
|
+
LEGACY_DEFAULT_PROVIDER = "bedrock";
|
|
3139
|
+
CLAUDE_CLI_PROVIDER = "claude_cli";
|
|
3140
|
+
CLI_PROBE_TTL_MS = 6e4;
|
|
3141
|
+
}
|
|
3142
|
+
});
|
|
3143
|
+
|
|
3144
|
+
// src/core/ssh-config-scanner.ts
|
|
3145
|
+
import fs7 from "fs/promises";
|
|
3146
|
+
import path9 from "path";
|
|
3147
|
+
import os4 from "os";
|
|
3003
3148
|
function isGitServerHost(h8) {
|
|
3004
3149
|
if (h8.user === "git") return true;
|
|
3005
3150
|
const gitPrefix = /^(git|github|gitlab|bitbucket|codecommit|ssh\.github)\./i;
|
|
@@ -3015,10 +3160,10 @@ function shortLabelForFqdn(hostname) {
|
|
|
3015
3160
|
return `${first.slice(0, 12)}\u2026${first.slice(-8)}`;
|
|
3016
3161
|
}
|
|
3017
3162
|
async function scanSshConfig(configPath) {
|
|
3018
|
-
const sshConfigPath = configPath ??
|
|
3163
|
+
const sshConfigPath = configPath ?? path9.join(os4.homedir(), ".ssh", "config");
|
|
3019
3164
|
let mtimeMs2;
|
|
3020
3165
|
try {
|
|
3021
|
-
mtimeMs2 = (await
|
|
3166
|
+
mtimeMs2 = (await fs7.stat(sshConfigPath)).mtimeMs;
|
|
3022
3167
|
} catch {
|
|
3023
3168
|
return /* @__PURE__ */ new Map();
|
|
3024
3169
|
}
|
|
@@ -3031,7 +3176,7 @@ async function scanSshConfig(configPath) {
|
|
|
3031
3176
|
async function parseSshConfigFile(sshConfigPath) {
|
|
3032
3177
|
const discovered = /* @__PURE__ */ new Map();
|
|
3033
3178
|
try {
|
|
3034
|
-
const content = await
|
|
3179
|
+
const content = await fs7.readFile(sshConfigPath, "utf-8");
|
|
3035
3180
|
const lines = content.split("\n");
|
|
3036
3181
|
let currentHost = null;
|
|
3037
3182
|
for (const rawLine of lines) {
|
|
@@ -3132,23 +3277,24 @@ __export(config_manager_exports, {
|
|
|
3132
3277
|
updatePushTokens: () => updatePushTokens,
|
|
3133
3278
|
writeFileAtomic: () => writeFileAtomic2
|
|
3134
3279
|
});
|
|
3135
|
-
import
|
|
3280
|
+
import fs8 from "fs/promises";
|
|
3136
3281
|
import yaml from "js-yaml";
|
|
3137
|
-
function resolveAgentEngineProvider(config) {
|
|
3282
|
+
function resolveAgentEngineProvider(config, claudeInstalled) {
|
|
3138
3283
|
if (CLOUD_MODE) return "walnut-agent";
|
|
3139
3284
|
const raw = config.agent?.provider;
|
|
3140
3285
|
if (typeof raw === "string" && VALID_AGENT_ENGINE_PROVIDERS.has(raw)) {
|
|
3141
3286
|
return raw;
|
|
3142
3287
|
}
|
|
3143
|
-
if (raw
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
using: FALLBACK_AGENT_ENGINE_PROVIDER,
|
|
3147
|
-
valid: [...VALID_AGENT_ENGINE_PROVIDERS].join(", ")
|
|
3148
|
-
});
|
|
3149
|
-
return FALLBACK_AGENT_ENGINE_PROVIDER;
|
|
3288
|
+
if (raw === void 0) {
|
|
3289
|
+
const main = claudeInstalled === void 0 ? resolveMainProviderName(config) : resolveMainProviderName(config, claudeInstalled);
|
|
3290
|
+
return main === CLAUDE_CLI_PROVIDER ? "claude-code" : "walnut-agent";
|
|
3150
3291
|
}
|
|
3151
|
-
|
|
3292
|
+
log.session.warn("config-manager: agent.provider is not a known engine \u2014 using the fallback", {
|
|
3293
|
+
value: typeof raw === "string" ? raw : `<${typeof raw}>`,
|
|
3294
|
+
using: FALLBACK_AGENT_ENGINE_PROVIDER,
|
|
3295
|
+
valid: [...VALID_AGENT_ENGINE_PROVIDERS].join(", ")
|
|
3296
|
+
});
|
|
3297
|
+
return FALLBACK_AGENT_ENGINE_PROVIDER;
|
|
3152
3298
|
}
|
|
3153
3299
|
function migrateConfigToProjectOnly(config) {
|
|
3154
3300
|
let changed = false;
|
|
@@ -3221,13 +3367,13 @@ function migrateConfigToProjectOnly(config) {
|
|
|
3221
3367
|
}
|
|
3222
3368
|
async function readRawConfigContent() {
|
|
3223
3369
|
try {
|
|
3224
|
-
const primary = await
|
|
3370
|
+
const primary = await fs8.readFile(CONFIG_FILE, "utf-8");
|
|
3225
3371
|
if (primary.trim()) return primary;
|
|
3226
3372
|
throw new Error("config.yaml is empty");
|
|
3227
3373
|
} catch (primaryErr) {
|
|
3228
3374
|
let backup;
|
|
3229
3375
|
try {
|
|
3230
|
-
backup = await
|
|
3376
|
+
backup = await fs8.readFile(CONFIG_BACKUP_FILE, "utf-8");
|
|
3231
3377
|
} catch {
|
|
3232
3378
|
return null;
|
|
3233
3379
|
}
|
|
@@ -3237,7 +3383,7 @@ async function readRawConfigContent() {
|
|
|
3237
3383
|
backup: CONFIG_BACKUP_FILE
|
|
3238
3384
|
});
|
|
3239
3385
|
try {
|
|
3240
|
-
await
|
|
3386
|
+
await fs8.writeFile(CONFIG_FILE, backup, "utf-8");
|
|
3241
3387
|
} catch {
|
|
3242
3388
|
}
|
|
3243
3389
|
return backup;
|
|
@@ -3246,10 +3392,10 @@ async function readRawConfigContent() {
|
|
|
3246
3392
|
async function writeFileAtomic2(filePath, content) {
|
|
3247
3393
|
const tmp = `${filePath}.tmp-${process.pid}-${Date.now().toString(36)}`;
|
|
3248
3394
|
try {
|
|
3249
|
-
await
|
|
3250
|
-
await
|
|
3395
|
+
await fs8.writeFile(tmp, content, "utf-8");
|
|
3396
|
+
await fs8.rename(tmp, filePath);
|
|
3251
3397
|
} catch (err2) {
|
|
3252
|
-
await
|
|
3398
|
+
await fs8.rm(tmp, { force: true }).catch(() => {
|
|
3253
3399
|
});
|
|
3254
3400
|
throw err2;
|
|
3255
3401
|
}
|
|
@@ -3447,7 +3593,7 @@ async function seedConfigDefaults() {
|
|
|
3447
3593
|
const config = await getConfig();
|
|
3448
3594
|
let needsWrite = false;
|
|
3449
3595
|
try {
|
|
3450
|
-
const raw = await
|
|
3596
|
+
const raw = await fs8.readFile(CONFIG_FILE, "utf-8");
|
|
3451
3597
|
if (!raw.includes("available_models")) {
|
|
3452
3598
|
needsWrite = true;
|
|
3453
3599
|
}
|
|
@@ -3475,6 +3621,7 @@ var init_config_manager = __esm({
|
|
|
3475
3621
|
init_constants();
|
|
3476
3622
|
init_types();
|
|
3477
3623
|
init_model_catalog();
|
|
3624
|
+
init_default_provider();
|
|
3478
3625
|
init_ssh_config_scanner();
|
|
3479
3626
|
DEFAULT_CONFIG = {
|
|
3480
3627
|
version: 1,
|
|
@@ -3486,12 +3633,12 @@ var init_config_manager = __esm({
|
|
|
3486
3633
|
// so this never re-routes an established setup.
|
|
3487
3634
|
defaults: { priority: "none", platform: "local" },
|
|
3488
3635
|
provider: { type: "claude-code" },
|
|
3489
|
-
// Which ENGINE answers a Personal AI chat turn
|
|
3490
|
-
//
|
|
3491
|
-
//
|
|
3492
|
-
//
|
|
3493
|
-
//
|
|
3494
|
-
agent: {
|
|
3636
|
+
// Which ENGINE answers a Personal AI chat turn is NOT defaulted here: it follows
|
|
3637
|
+
// the AI provider (Settings → AI Provider) — see resolveAgentEngineProvider().
|
|
3638
|
+
// getConfig() spreads the parsed file OVER these defaults at the TOP level, so
|
|
3639
|
+
// anything put in this object is dropped by any config.yaml with an `agent:`
|
|
3640
|
+
// section; the resolver is what actually applies the rule.
|
|
3641
|
+
agent: {}
|
|
3495
3642
|
};
|
|
3496
3643
|
CONFIG_BACKUP_FILE = `${CONFIG_FILE}.bak`;
|
|
3497
3644
|
writeLock = Promise.resolve();
|
|
@@ -3500,15 +3647,15 @@ var init_config_manager = __esm({
|
|
|
3500
3647
|
|
|
3501
3648
|
// src/core/tmp-sweep.ts
|
|
3502
3649
|
import fsp5 from "fs/promises";
|
|
3503
|
-
import
|
|
3650
|
+
import path10 from "path";
|
|
3504
3651
|
function sweepDirs() {
|
|
3505
3652
|
return [
|
|
3506
3653
|
WALNUT_HOME,
|
|
3507
3654
|
SYNC_DIR,
|
|
3508
|
-
|
|
3509
|
-
|
|
3655
|
+
path10.join(WALNUT_HOME, "sessions"),
|
|
3656
|
+
path10.join(WALNUT_HOME, "sessions", "transcripts"),
|
|
3510
3657
|
TASKS_DIR,
|
|
3511
|
-
|
|
3658
|
+
path10.join(TASKS_DIR, "outbox"),
|
|
3512
3659
|
CONVERSATIONS_DIR,
|
|
3513
3660
|
MEMORY_DIR,
|
|
3514
3661
|
DAILY_DIR,
|
|
@@ -3529,7 +3676,7 @@ async function sweepOrphanAtomicTmpFiles() {
|
|
|
3529
3676
|
const entries = await fsp5.readdir(dir2, { withFileTypes: true });
|
|
3530
3677
|
for (const entry of entries) {
|
|
3531
3678
|
if (!entry.isFile() || !ORPHAN_RE.test(entry.name)) continue;
|
|
3532
|
-
const full =
|
|
3679
|
+
const full = path10.join(dir2, entry.name);
|
|
3533
3680
|
try {
|
|
3534
3681
|
const st = await fsp5.stat(full);
|
|
3535
3682
|
if (st.mtimeMs > cutoff) continue;
|
|
@@ -3566,10 +3713,10 @@ __export(init_exports, {
|
|
|
3566
3713
|
initDirectories: () => initDirectories
|
|
3567
3714
|
});
|
|
3568
3715
|
import fsp6 from "fs/promises";
|
|
3569
|
-
import
|
|
3716
|
+
import fs9 from "fs";
|
|
3570
3717
|
async function migrateLegacyMemoryFile() {
|
|
3571
3718
|
try {
|
|
3572
|
-
if (
|
|
3719
|
+
if (fs9.existsSync(LEGACY_MEMORY_FILE) && !fs9.existsSync(MEMORY_FILE)) {
|
|
3573
3720
|
await fsp6.rename(LEGACY_MEMORY_FILE, MEMORY_FILE);
|
|
3574
3721
|
log.memory.info("Migrated MEMORY.md into memory/ folder", { from: LEGACY_MEMORY_FILE, to: MEMORY_FILE });
|
|
3575
3722
|
}
|
|
@@ -4524,15 +4671,15 @@ __export(task_db_exports, {
|
|
|
4524
4671
|
transaction: () => transaction
|
|
4525
4672
|
});
|
|
4526
4673
|
import Database from "better-sqlite3";
|
|
4527
|
-
import
|
|
4528
|
-
import
|
|
4674
|
+
import fs10 from "fs";
|
|
4675
|
+
import path11 from "path";
|
|
4529
4676
|
import yaml2 from "js-yaml";
|
|
4530
4677
|
function getDb() {
|
|
4531
4678
|
if (db) return db;
|
|
4532
4679
|
if (initAttempted) throw initError;
|
|
4533
4680
|
initAttempted = true;
|
|
4534
4681
|
try {
|
|
4535
|
-
|
|
4682
|
+
fs10.mkdirSync(path11.dirname(TASK_DB_PATH), { recursive: true });
|
|
4536
4683
|
const handle2 = new Database(TASK_DB_PATH);
|
|
4537
4684
|
handle2.pragma("journal_mode = WAL");
|
|
4538
4685
|
handle2.pragma("busy_timeout = 5000");
|
|
@@ -4762,8 +4909,8 @@ function migrateToProjectOnly(handle2) {
|
|
|
4762
4909
|
}
|
|
4763
4910
|
try {
|
|
4764
4911
|
handle2.pragma("wal_checkpoint(TRUNCATE)");
|
|
4765
|
-
if (!
|
|
4766
|
-
|
|
4912
|
+
if (!fs10.existsSync(TASK_DB_PRE_V5_BACKUP_PATH)) {
|
|
4913
|
+
fs10.copyFileSync(TASK_DB_PATH, TASK_DB_PRE_V5_BACKUP_PATH);
|
|
4767
4914
|
log.task.info("task-db v5: wrote pre-migration backup", { path: TASK_DB_PRE_V5_BACKUP_PATH });
|
|
4768
4915
|
}
|
|
4769
4916
|
} catch (err2) {
|
|
@@ -5273,7 +5420,7 @@ var init_task_db = __esm({
|
|
|
5273
5420
|
init_constants();
|
|
5274
5421
|
init_logging();
|
|
5275
5422
|
init_phase2();
|
|
5276
|
-
TASK_DB_PATH =
|
|
5423
|
+
TASK_DB_PATH = path11.join(TASKS_DIR, "tasks.sqlite");
|
|
5277
5424
|
EXPLICIT_TASK_COLUMNS = [
|
|
5278
5425
|
"id",
|
|
5279
5426
|
"title",
|
|
@@ -5436,8 +5583,8 @@ var init_task_db = __esm({
|
|
|
5436
5583
|
});
|
|
5437
5584
|
|
|
5438
5585
|
// src/core/task-db-migration.ts
|
|
5439
|
-
import
|
|
5440
|
-
import
|
|
5586
|
+
import fs11 from "fs";
|
|
5587
|
+
import path12 from "path";
|
|
5441
5588
|
import yaml3 from "js-yaml";
|
|
5442
5589
|
async function runMigrationIfNeeded() {
|
|
5443
5590
|
const db5 = getDb();
|
|
@@ -5448,7 +5595,7 @@ async function runMigrationIfNeeded() {
|
|
|
5448
5595
|
if (existing.n > 0) {
|
|
5449
5596
|
return { migrated: false, count: existing.n };
|
|
5450
5597
|
}
|
|
5451
|
-
if (!
|
|
5598
|
+
if (!fs11.existsSync(TASKS_FILE)) {
|
|
5452
5599
|
return { migrated: false, count: 0 };
|
|
5453
5600
|
}
|
|
5454
5601
|
const store3 = await readJsonFile(TASKS_FILE, { version: 1, tasks: [] });
|
|
@@ -5605,9 +5752,9 @@ async function runMigrationIfNeeded() {
|
|
|
5605
5752
|
}
|
|
5606
5753
|
const after = db5.prepare("SELECT COUNT(*) AS n FROM tasks").get();
|
|
5607
5754
|
const count2 = after.n;
|
|
5608
|
-
const backupPath =
|
|
5755
|
+
const backupPath = path12.join(path12.dirname(TASKS_FILE), "tasks.json.migrated-from-json.backup");
|
|
5609
5756
|
try {
|
|
5610
|
-
|
|
5757
|
+
fs11.copyFileSync(TASKS_FILE, backupPath);
|
|
5611
5758
|
} catch (err2) {
|
|
5612
5759
|
log.task.warn("task-db migration: backup copy failed (non-fatal)", {
|
|
5613
5760
|
path: backupPath,
|
|
@@ -5631,9 +5778,9 @@ var init_task_db_migration = __esm({
|
|
|
5631
5778
|
});
|
|
5632
5779
|
|
|
5633
5780
|
// src/core/memory-dir-migration.ts
|
|
5634
|
-
import
|
|
5781
|
+
import fs12 from "fs";
|
|
5635
5782
|
import fsp7 from "fs/promises";
|
|
5636
|
-
import
|
|
5783
|
+
import path13 from "path";
|
|
5637
5784
|
function bodyOf(content) {
|
|
5638
5785
|
const fm = content.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);
|
|
5639
5786
|
return fm ? content.slice(fm[0].length) : content;
|
|
@@ -5651,7 +5798,7 @@ ${legacyBody}
|
|
|
5651
5798
|
}
|
|
5652
5799
|
function mtimeMs(file) {
|
|
5653
5800
|
try {
|
|
5654
|
-
return
|
|
5801
|
+
return fs12.statSync(file).mtimeMs;
|
|
5655
5802
|
} catch {
|
|
5656
5803
|
return 0;
|
|
5657
5804
|
}
|
|
@@ -5660,24 +5807,24 @@ function findCandidates(root6) {
|
|
|
5660
5807
|
const out = [];
|
|
5661
5808
|
let level1;
|
|
5662
5809
|
try {
|
|
5663
|
-
level1 =
|
|
5810
|
+
level1 = fs12.readdirSync(root6, { withFileTypes: true });
|
|
5664
5811
|
} catch {
|
|
5665
5812
|
return out;
|
|
5666
5813
|
}
|
|
5667
5814
|
for (const cat of level1) {
|
|
5668
5815
|
if (!cat.isDirectory()) continue;
|
|
5669
|
-
const catDir =
|
|
5670
|
-
if (
|
|
5816
|
+
const catDir = path13.join(root6, cat.name);
|
|
5817
|
+
if (fs12.existsSync(path13.join(catDir, MEMORY_FILE_NAME))) continue;
|
|
5671
5818
|
let level2;
|
|
5672
5819
|
try {
|
|
5673
|
-
level2 =
|
|
5820
|
+
level2 = fs12.readdirSync(catDir, { withFileTypes: true });
|
|
5674
5821
|
} catch {
|
|
5675
5822
|
continue;
|
|
5676
5823
|
}
|
|
5677
5824
|
for (const proj of level2) {
|
|
5678
5825
|
if (!proj.isDirectory()) continue;
|
|
5679
|
-
const sourceDir =
|
|
5680
|
-
if (!
|
|
5826
|
+
const sourceDir = path13.join(catDir, proj.name);
|
|
5827
|
+
if (!fs12.existsSync(path13.join(sourceDir, MEMORY_FILE_NAME))) continue;
|
|
5681
5828
|
out.push({ category: cat.name, project: proj.name, sourceDir });
|
|
5682
5829
|
}
|
|
5683
5830
|
}
|
|
@@ -5691,11 +5838,11 @@ async function drainDir(from, to) {
|
|
|
5691
5838
|
return;
|
|
5692
5839
|
}
|
|
5693
5840
|
for (const name of entries) {
|
|
5694
|
-
const target =
|
|
5695
|
-
if (
|
|
5696
|
-
await fsp7.rename(
|
|
5841
|
+
const target = path13.join(to, name);
|
|
5842
|
+
if (fs12.existsSync(target)) continue;
|
|
5843
|
+
await fsp7.rename(path13.join(from, name), target).catch((err2) => {
|
|
5697
5844
|
log.memory.warn("memory-dir migration: entry move failed", {
|
|
5698
|
-
from:
|
|
5845
|
+
from: path13.join(from, name),
|
|
5699
5846
|
to: target,
|
|
5700
5847
|
error: String(err2)
|
|
5701
5848
|
});
|
|
@@ -5707,23 +5854,23 @@ async function drainDir(from, to) {
|
|
|
5707
5854
|
async function migrateProjectMemoryDirs() {
|
|
5708
5855
|
const result = { ran: false, moved: 0, merged: 0 };
|
|
5709
5856
|
try {
|
|
5710
|
-
if (!
|
|
5711
|
-
if (
|
|
5857
|
+
if (!fs12.existsSync(PROJECTS_MEMORY_DIR)) return result;
|
|
5858
|
+
if (fs12.existsSync(MEMORY_DIR_MIGRATION_MARKER)) return result;
|
|
5712
5859
|
result.ran = true;
|
|
5713
5860
|
const candidates = findCandidates(PROJECTS_MEMORY_DIR);
|
|
5714
5861
|
const touchedCategories = new Set(candidates.map((c8) => c8.category));
|
|
5715
5862
|
for (const c8 of candidates) {
|
|
5716
|
-
const targetDir =
|
|
5863
|
+
const targetDir = path13.join(PROJECTS_MEMORY_DIR, c8.project);
|
|
5717
5864
|
const label = `${c8.category}/${c8.project}`;
|
|
5718
5865
|
try {
|
|
5719
|
-
if (!
|
|
5866
|
+
if (!fs12.existsSync(targetDir)) {
|
|
5720
5867
|
await fsp7.rename(c8.sourceDir, targetDir);
|
|
5721
5868
|
result.moved += 1;
|
|
5722
5869
|
continue;
|
|
5723
5870
|
}
|
|
5724
|
-
const sourceMem =
|
|
5725
|
-
const targetMem =
|
|
5726
|
-
if (!
|
|
5871
|
+
const sourceMem = path13.join(c8.sourceDir, MEMORY_FILE_NAME);
|
|
5872
|
+
const targetMem = path13.join(targetDir, MEMORY_FILE_NAME);
|
|
5873
|
+
if (!fs12.existsSync(targetMem)) {
|
|
5727
5874
|
await fsp7.rename(sourceMem, targetMem);
|
|
5728
5875
|
await drainDir(c8.sourceDir, targetDir);
|
|
5729
5876
|
result.moved += 1;
|
|
@@ -5745,7 +5892,7 @@ async function migrateProjectMemoryDirs() {
|
|
|
5745
5892
|
}
|
|
5746
5893
|
}
|
|
5747
5894
|
for (const cat of touchedCategories) {
|
|
5748
|
-
await fsp7.rmdir(
|
|
5895
|
+
await fsp7.rmdir(path13.join(PROJECTS_MEMORY_DIR, cat)).catch(() => {
|
|
5749
5896
|
});
|
|
5750
5897
|
}
|
|
5751
5898
|
await fsp7.writeFile(
|
|
@@ -5773,7 +5920,7 @@ var init_memory_dir_migration = __esm({
|
|
|
5773
5920
|
"use strict";
|
|
5774
5921
|
init_constants();
|
|
5775
5922
|
init_logging();
|
|
5776
|
-
MEMORY_DIR_MIGRATION_MARKER =
|
|
5923
|
+
MEMORY_DIR_MIGRATION_MARKER = path13.join(PROJECTS_MEMORY_DIR, ".migrated-project-only");
|
|
5777
5924
|
MEMORY_FILE_NAME = "MEMORY.md";
|
|
5778
5925
|
}
|
|
5779
5926
|
});
|
|
@@ -5989,7 +6136,7 @@ __export(microsoft_todo_exports, {
|
|
|
5989
6136
|
});
|
|
5990
6137
|
import * as msal from "@azure/msal-node";
|
|
5991
6138
|
import https from "https";
|
|
5992
|
-
import
|
|
6139
|
+
import path14 from "path";
|
|
5993
6140
|
function getMsTodoConfig(config) {
|
|
5994
6141
|
return config.plugins?.["ms-todo"];
|
|
5995
6142
|
}
|
|
@@ -7208,8 +7355,8 @@ var init_microsoft_todo = __esm({
|
|
|
7208
7355
|
init_format();
|
|
7209
7356
|
init_task_manager();
|
|
7210
7357
|
init_task_remote_links();
|
|
7211
|
-
TOKENS_FILE =
|
|
7212
|
-
DELTA_FILE =
|
|
7358
|
+
TOKENS_FILE = path14.join(SYNC_DIR, "ms-todo-tokens.json");
|
|
7359
|
+
DELTA_FILE = path14.join(SYNC_DIR, "ms-todo-delta.json");
|
|
7213
7360
|
GRAPH_BASE = "https://graph.microsoft.com/v1.0";
|
|
7214
7361
|
SCOPES = ["Tasks.ReadWrite"];
|
|
7215
7362
|
PRIORITY_TO_IMPORTANCE = {
|
|
@@ -7332,8 +7479,8 @@ __export(daemon_version_check_exports, {
|
|
|
7332
7479
|
verifyDaemonBinaryVersion: () => verifyDaemonBinaryVersion
|
|
7333
7480
|
});
|
|
7334
7481
|
import { createHash } from "crypto";
|
|
7335
|
-
import
|
|
7336
|
-
import
|
|
7482
|
+
import fs13 from "fs";
|
|
7483
|
+
import path15 from "path";
|
|
7337
7484
|
import { spawnSync } from "child_process";
|
|
7338
7485
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7339
7486
|
function computeExpectedDaemonVersion() {
|
|
@@ -7342,11 +7489,11 @@ function computeExpectedDaemonVersion() {
|
|
|
7342
7489
|
const hash = createHash("sha256");
|
|
7343
7490
|
const NUL = Buffer.from([0]);
|
|
7344
7491
|
for (const rel of DAEMON_SOURCE_FILES) {
|
|
7345
|
-
const abs =
|
|
7492
|
+
const abs = path15.join(repoRoot, rel);
|
|
7346
7493
|
try {
|
|
7347
7494
|
hash.update(Buffer.from(rel));
|
|
7348
7495
|
hash.update(NUL);
|
|
7349
|
-
hash.update(
|
|
7496
|
+
hash.update(fs13.readFileSync(abs));
|
|
7350
7497
|
hash.update(NUL);
|
|
7351
7498
|
} catch {
|
|
7352
7499
|
return null;
|
|
@@ -7355,12 +7502,12 @@ function computeExpectedDaemonVersion() {
|
|
|
7355
7502
|
return "walnut-daemon-" + hash.digest("hex").slice(0, 12);
|
|
7356
7503
|
}
|
|
7357
7504
|
function findRepoRoot() {
|
|
7358
|
-
let dir2 =
|
|
7505
|
+
let dir2 = path15.dirname(fileURLToPath2(import.meta.url));
|
|
7359
7506
|
for (let i8 = 0; i8 < 10; i8++) {
|
|
7360
|
-
if (
|
|
7507
|
+
if (fs13.existsSync(path15.join(dir2, "package.json")) && fs13.existsSync(path15.join(dir2, "src", "providers", "daemon-standalone.ts"))) {
|
|
7361
7508
|
return dir2;
|
|
7362
7509
|
}
|
|
7363
|
-
const parent =
|
|
7510
|
+
const parent = path15.dirname(dir2);
|
|
7364
7511
|
if (parent === dir2) break;
|
|
7365
7512
|
dir2 = parent;
|
|
7366
7513
|
}
|
|
@@ -7369,14 +7516,14 @@ function findRepoRoot() {
|
|
|
7369
7516
|
function bunAvailable() {
|
|
7370
7517
|
const home = process.env.HOME ?? "";
|
|
7371
7518
|
const candidates = [
|
|
7372
|
-
...(process.env.PATH ?? "").split(
|
|
7373
|
-
|
|
7519
|
+
...(process.env.PATH ?? "").split(path15.delimiter).filter(Boolean).map((d8) => path15.join(d8, "bun")),
|
|
7520
|
+
path15.join(home, ".bun", "bin", "bun"),
|
|
7374
7521
|
"/opt/homebrew/bin/bun",
|
|
7375
7522
|
"/usr/local/bin/bun"
|
|
7376
7523
|
];
|
|
7377
7524
|
return candidates.some((p6) => {
|
|
7378
7525
|
try {
|
|
7379
|
-
|
|
7526
|
+
fs13.accessSync(p6, fs13.constants.X_OK);
|
|
7380
7527
|
return true;
|
|
7381
7528
|
} catch {
|
|
7382
7529
|
return false;
|
|
@@ -7386,10 +7533,10 @@ function bunAvailable() {
|
|
|
7386
7533
|
function readBuiltVersions() {
|
|
7387
7534
|
const out = /* @__PURE__ */ new Map();
|
|
7388
7535
|
try {
|
|
7389
|
-
for (const f8 of
|
|
7536
|
+
for (const f8 of fs13.readdirSync(DAEMON_BINARIES_DIR)) {
|
|
7390
7537
|
if (!f8.endsWith(".version")) continue;
|
|
7391
7538
|
const arch = f8.slice(0, -".version".length);
|
|
7392
|
-
const v3 =
|
|
7539
|
+
const v3 = fs13.readFileSync(path15.join(DAEMON_BINARIES_DIR, f8), "utf-8").trim();
|
|
7393
7540
|
if (v3) out.set(arch, v3);
|
|
7394
7541
|
}
|
|
7395
7542
|
} catch {
|
|
@@ -7849,12 +7996,12 @@ var init_daemon_fold = __esm({
|
|
|
7849
7996
|
});
|
|
7850
7997
|
|
|
7851
7998
|
// src/providers/daemon-source.ts
|
|
7852
|
-
import
|
|
7853
|
-
import
|
|
7999
|
+
import fs14 from "fs";
|
|
8000
|
+
import path16 from "path";
|
|
7854
8001
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
7855
8002
|
function resolveDaemonSourceVersion() {
|
|
7856
8003
|
const here = fileURLToPath3(import.meta.url);
|
|
7857
|
-
const bundled = here.split(
|
|
8004
|
+
const bundled = here.split(path16.sep).includes("dist");
|
|
7858
8005
|
if (bundled) {
|
|
7859
8006
|
const sidecar = readSidecarDaemonVersion(here);
|
|
7860
8007
|
if (sidecar) return sidecar;
|
|
@@ -7862,32 +8009,32 @@ function resolveDaemonSourceVersion() {
|
|
|
7862
8009
|
const computed = computeExpectedDaemonVersion();
|
|
7863
8010
|
if (computed) return computed;
|
|
7864
8011
|
if (process.env.DAEMON_VERSION) return process.env.DAEMON_VERSION;
|
|
7865
|
-
let dir2 =
|
|
8012
|
+
let dir2 = path16.dirname(fileURLToPath3(import.meta.url));
|
|
7866
8013
|
for (let i8 = 0; i8 < 10; i8++) {
|
|
7867
8014
|
try {
|
|
7868
|
-
const pkg = JSON.parse(
|
|
8015
|
+
const pkg = JSON.parse(fs14.readFileSync(path16.join(dir2, "package.json"), "utf-8"));
|
|
7869
8016
|
if (pkg.name === "open-walnut" && pkg.version) return `walnut-daemon-pkg-${pkg.version}`;
|
|
7870
8017
|
} catch {
|
|
7871
8018
|
}
|
|
7872
|
-
const parent =
|
|
8019
|
+
const parent = path16.dirname(dir2);
|
|
7873
8020
|
if (parent === dir2) break;
|
|
7874
8021
|
dir2 = parent;
|
|
7875
8022
|
}
|
|
7876
8023
|
return "dev-source";
|
|
7877
8024
|
}
|
|
7878
8025
|
function readSidecarDaemonVersion(fromPath) {
|
|
7879
|
-
let dir2 =
|
|
8026
|
+
let dir2 = path16.dirname(fromPath);
|
|
7880
8027
|
for (let i8 = 0; i8 < 5; i8++) {
|
|
7881
|
-
const binDir =
|
|
8028
|
+
const binDir = path16.join(dir2, "daemon-binaries");
|
|
7882
8029
|
try {
|
|
7883
|
-
for (const name of
|
|
8030
|
+
for (const name of fs14.readdirSync(binDir)) {
|
|
7884
8031
|
if (!name.endsWith(".version")) continue;
|
|
7885
|
-
const v3 =
|
|
8032
|
+
const v3 = fs14.readFileSync(path16.join(binDir, name), "utf-8").trim();
|
|
7886
8033
|
if (v3) return v3;
|
|
7887
8034
|
}
|
|
7888
8035
|
} catch {
|
|
7889
8036
|
}
|
|
7890
|
-
const parent =
|
|
8037
|
+
const parent = path16.dirname(dir2);
|
|
7891
8038
|
if (parent === dir2) break;
|
|
7892
8039
|
dir2 = parent;
|
|
7893
8040
|
}
|
|
@@ -15001,7 +15148,7 @@ if (action === '--start') {
|
|
|
15001
15148
|
});
|
|
15002
15149
|
|
|
15003
15150
|
// src/core/jsonl-tailer.ts
|
|
15004
|
-
import
|
|
15151
|
+
import fs15 from "fs";
|
|
15005
15152
|
var init_jsonl_tailer = __esm({
|
|
15006
15153
|
"src/core/jsonl-tailer.ts"() {
|
|
15007
15154
|
"use strict";
|
|
@@ -15010,10 +15157,10 @@ var init_jsonl_tailer = __esm({
|
|
|
15010
15157
|
});
|
|
15011
15158
|
|
|
15012
15159
|
// src/providers/session-io.ts
|
|
15013
|
-
import
|
|
15160
|
+
import fs16 from "fs";
|
|
15014
15161
|
import fsp8 from "fs/promises";
|
|
15015
|
-
import
|
|
15016
|
-
import { execFileSync } from "child_process";
|
|
15162
|
+
import path17 from "path";
|
|
15163
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
15017
15164
|
function shellQuote(s4) {
|
|
15018
15165
|
return "'" + s4.replace(/'/g, "'\\''") + "'";
|
|
15019
15166
|
}
|
|
@@ -15058,7 +15205,7 @@ function findRelativeImageNames(text, opts) {
|
|
|
15058
15205
|
function findLocalImagePaths(text) {
|
|
15059
15206
|
return findImagePaths(text).filter((p6) => {
|
|
15060
15207
|
try {
|
|
15061
|
-
return
|
|
15208
|
+
return fs16.statSync(p6).isFile();
|
|
15062
15209
|
} catch {
|
|
15063
15210
|
return false;
|
|
15064
15211
|
}
|
|
@@ -16103,107 +16250,6 @@ var init_daemon_core = __esm({
|
|
|
16103
16250
|
}
|
|
16104
16251
|
});
|
|
16105
16252
|
|
|
16106
|
-
// src/core/claude-cli-detect.ts
|
|
16107
|
-
var claude_cli_detect_exports = {};
|
|
16108
|
-
__export(claude_cli_detect_exports, {
|
|
16109
|
-
_CLAUDE_CREDENTIALS_HOME: () => _CLAUDE_CREDENTIALS_HOME,
|
|
16110
|
-
describeClaudeCliAuth: () => describeClaudeCliAuth,
|
|
16111
|
-
detectClaudeCli: () => detectClaudeCli,
|
|
16112
|
-
hasClaudeSubscriptionAuth: () => hasClaudeSubscriptionAuth,
|
|
16113
|
-
isClaudeCliInstalled: () => isClaudeCliInstalled,
|
|
16114
|
-
resolveClaudeCliExecutable: () => resolveClaudeCliExecutable
|
|
16115
|
-
});
|
|
16116
|
-
import { execFileSync as execFileSync2 } from "child_process";
|
|
16117
|
-
import fs16 from "fs";
|
|
16118
|
-
import os4 from "os";
|
|
16119
|
-
import path17 from "path";
|
|
16120
|
-
function resolveClaudeCliExecutable(env3 = process.env) {
|
|
16121
|
-
const home = env3.HOME || os4.homedir();
|
|
16122
|
-
const pathDirs = (env3.PATH ?? "").split(path17.delimiter).filter(Boolean);
|
|
16123
|
-
const fallbackDirs = [
|
|
16124
|
-
path17.join(home, ".toolbox", "bin"),
|
|
16125
|
-
path17.join(home, ".local", "bin"),
|
|
16126
|
-
path17.join(home, ".npm-global", "bin"),
|
|
16127
|
-
path17.join(home, ".bun", "bin"),
|
|
16128
|
-
"/usr/local/bin",
|
|
16129
|
-
"/opt/homebrew/bin",
|
|
16130
|
-
"/usr/bin",
|
|
16131
|
-
"/bin"
|
|
16132
|
-
];
|
|
16133
|
-
for (const dir2 of [.../* @__PURE__ */ new Set([...pathDirs, ...fallbackDirs])]) {
|
|
16134
|
-
const candidate = path17.join(dir2, "claude");
|
|
16135
|
-
try {
|
|
16136
|
-
fs16.accessSync(candidate, fs16.constants.X_OK);
|
|
16137
|
-
return candidate;
|
|
16138
|
-
} catch {
|
|
16139
|
-
}
|
|
16140
|
-
}
|
|
16141
|
-
return null;
|
|
16142
|
-
}
|
|
16143
|
-
function isClaudeCliInstalled() {
|
|
16144
|
-
return resolveClaudeCliExecutable() !== null;
|
|
16145
|
-
}
|
|
16146
|
-
function hasClaudeSubscriptionAuth() {
|
|
16147
|
-
if (process.platform === "darwin") {
|
|
16148
|
-
try {
|
|
16149
|
-
execFileSync2("security", ["find-generic-password", "-s", KEYCHAIN_OAUTH_SERVICE], {
|
|
16150
|
-
stdio: "ignore"
|
|
16151
|
-
});
|
|
16152
|
-
return true;
|
|
16153
|
-
} catch {
|
|
16154
|
-
}
|
|
16155
|
-
}
|
|
16156
|
-
return fileCredentialExists();
|
|
16157
|
-
}
|
|
16158
|
-
function fileCredentialExists() {
|
|
16159
|
-
try {
|
|
16160
|
-
return fs16.existsSync(CLAUDE_CREDENTIALS_FILE);
|
|
16161
|
-
} catch {
|
|
16162
|
-
return false;
|
|
16163
|
-
}
|
|
16164
|
-
}
|
|
16165
|
-
function detectClaudeCli() {
|
|
16166
|
-
const installed2 = isClaudeCliInstalled();
|
|
16167
|
-
const subscriptionAuth = installed2 && hasClaudeSubscriptionAuth();
|
|
16168
|
-
return {
|
|
16169
|
-
installed: installed2,
|
|
16170
|
-
subscriptionAuth,
|
|
16171
|
-
subscriptionReady: installed2 && subscriptionAuth,
|
|
16172
|
-
ready: installed2,
|
|
16173
|
-
auth: installed2 ? describeClaudeCliAuth() : { mode: "unknown", label: "not installed" }
|
|
16174
|
-
};
|
|
16175
|
-
}
|
|
16176
|
-
function describeClaudeCliAuth(env3 = process.env, settingsEnv = readClaudeSettingsEnv()) {
|
|
16177
|
-
const merged = { ...env3, ...settingsEnv };
|
|
16178
|
-
const truthy = (v3) => !!v3 && v3 !== "0" && v3.toLowerCase() !== "false";
|
|
16179
|
-
if (truthy(merged.CLAUDE_CODE_USE_BEDROCK)) {
|
|
16180
|
-
const region = merged.AWS_REGION || merged.AWS_DEFAULT_REGION;
|
|
16181
|
-
return { mode: "bedrock", label: region ? `Bedrock (${region})` : "Bedrock" };
|
|
16182
|
-
}
|
|
16183
|
-
if (truthy(merged.CLAUDE_CODE_USE_VERTEX)) return { mode: "vertex", label: "Vertex AI" };
|
|
16184
|
-
if (merged.ANTHROPIC_API_KEY || merged.ANTHROPIC_AUTH_TOKEN) return { mode: "api-key", label: "an Anthropic API key" };
|
|
16185
|
-
if (hasClaudeSubscriptionAuth()) return { mode: "subscription", label: "your Claude subscription" };
|
|
16186
|
-
return { mode: "unknown", label: "its own login" };
|
|
16187
|
-
}
|
|
16188
|
-
function readClaudeSettingsEnv() {
|
|
16189
|
-
try {
|
|
16190
|
-
const raw = fs16.readFileSync(path17.join(os4.homedir(), ".claude", "settings.json"), "utf8");
|
|
16191
|
-
const env3 = JSON.parse(raw).env ?? {};
|
|
16192
|
-
return Object.fromEntries(Object.entries(env3).filter(([, v3]) => typeof v3 === "string"));
|
|
16193
|
-
} catch {
|
|
16194
|
-
return {};
|
|
16195
|
-
}
|
|
16196
|
-
}
|
|
16197
|
-
var KEYCHAIN_OAUTH_SERVICE, _CLAUDE_CREDENTIALS_HOME;
|
|
16198
|
-
var init_claude_cli_detect = __esm({
|
|
16199
|
-
"src/core/claude-cli-detect.ts"() {
|
|
16200
|
-
"use strict";
|
|
16201
|
-
init_constants();
|
|
16202
|
-
KEYCHAIN_OAUTH_SERVICE = "Claude Code-credentials";
|
|
16203
|
-
_CLAUDE_CREDENTIALS_HOME = os4.homedir();
|
|
16204
|
-
}
|
|
16205
|
-
});
|
|
16206
|
-
|
|
16207
16253
|
// src/providers/daemon-ownership.ts
|
|
16208
16254
|
import fs17 from "fs";
|
|
16209
16255
|
import os5 from "os";
|
|
@@ -67054,50 +67100,6 @@ var init_registry2 = __esm({
|
|
|
67054
67100
|
}
|
|
67055
67101
|
});
|
|
67056
67102
|
|
|
67057
|
-
// src/agent/providers/default-provider.ts
|
|
67058
|
-
var default_provider_exports = {};
|
|
67059
|
-
__export(default_provider_exports, {
|
|
67060
|
-
CLAUDE_CLI_PROVIDER: () => CLAUDE_CLI_PROVIDER,
|
|
67061
|
-
LEGACY_DEFAULT_PROVIDER: () => LEGACY_DEFAULT_PROVIDER,
|
|
67062
|
-
_resetDefaultProviderCacheForTesting: () => _resetDefaultProviderCacheForTesting,
|
|
67063
|
-
hasExplicitBedrockConfig: () => hasExplicitBedrockConfig,
|
|
67064
|
-
mainProviderIsImplicit: () => mainProviderIsImplicit,
|
|
67065
|
-
resolveMainProviderName: () => resolveMainProviderName
|
|
67066
|
-
});
|
|
67067
|
-
function claudeCliInstalledCached() {
|
|
67068
|
-
const now = Date.now();
|
|
67069
|
-
if (!cliProbe || now - cliProbe.at > CLI_PROBE_TTL_MS) {
|
|
67070
|
-
cliProbe = { at: now, installed: isClaudeCliInstalled() };
|
|
67071
|
-
}
|
|
67072
|
-
return cliProbe.installed;
|
|
67073
|
-
}
|
|
67074
|
-
function _resetDefaultProviderCacheForTesting() {
|
|
67075
|
-
cliProbe = void 0;
|
|
67076
|
-
}
|
|
67077
|
-
function hasExplicitBedrockConfig(config) {
|
|
67078
|
-
const b8 = config.providers?.bedrock;
|
|
67079
|
-
if (b8 && (b8.bearer_token || b8.aws_access_key_id || b8.aws_profile || b8.aws_credential_export)) return true;
|
|
67080
|
-
return !!config.provider?.bedrock_bearer_token;
|
|
67081
|
-
}
|
|
67082
|
-
function resolveMainProviderName(config, claudeInstalled = claudeCliInstalledCached()) {
|
|
67083
|
-
if (config.agent?.main_provider) return config.agent.main_provider;
|
|
67084
|
-
if (claudeInstalled) return CLAUDE_CLI_PROVIDER;
|
|
67085
|
-
return LEGACY_DEFAULT_PROVIDER;
|
|
67086
|
-
}
|
|
67087
|
-
function mainProviderIsImplicit(config) {
|
|
67088
|
-
return !config.agent?.main_provider;
|
|
67089
|
-
}
|
|
67090
|
-
var LEGACY_DEFAULT_PROVIDER, CLAUDE_CLI_PROVIDER, CLI_PROBE_TTL_MS, cliProbe;
|
|
67091
|
-
var init_default_provider = __esm({
|
|
67092
|
-
"src/agent/providers/default-provider.ts"() {
|
|
67093
|
-
"use strict";
|
|
67094
|
-
init_claude_cli_detect();
|
|
67095
|
-
LEGACY_DEFAULT_PROVIDER = "bedrock";
|
|
67096
|
-
CLAUDE_CLI_PROVIDER = "claude_cli";
|
|
67097
|
-
CLI_PROBE_TTL_MS = 6e4;
|
|
67098
|
-
}
|
|
67099
|
-
});
|
|
67100
|
-
|
|
67101
67103
|
// src/agent/model.ts
|
|
67102
67104
|
var model_exports = {};
|
|
67103
67105
|
__export(model_exports, {
|