@ycodium-ai/agent-claude 0.2.3078 → 0.2.3082
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +137 -75
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -181,8 +181,8 @@ var CLAUDE_CARD = {
|
|
|
181
181
|
};
|
|
182
182
|
|
|
183
183
|
// src/claudeInstance.ts
|
|
184
|
-
import * as
|
|
185
|
-
import * as
|
|
184
|
+
import * as NodeOS9 from "node:os";
|
|
185
|
+
import * as NodePath16 from "node:path";
|
|
186
186
|
|
|
187
187
|
// ../../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.3.170_@anthropic-ai+sdk@0.93.0_zod@4.6.5__@modelcontex_64204813d4dba2ebc464c3aa751485a4/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
188
188
|
import { createRequire as xz } from "node:module";
|
|
@@ -19921,18 +19921,18 @@ function parseSkillFrontMatter(contents) {
|
|
|
19921
19921
|
...parseFrontMatterBoolean(values["user-invocable"]) === false ? { userInvocable: false } : {}
|
|
19922
19922
|
};
|
|
19923
19923
|
}
|
|
19924
|
-
function claudeManagedSettingsPath(
|
|
19925
|
-
if (
|
|
19924
|
+
function claudeManagedSettingsPath(platform3, environment) {
|
|
19925
|
+
if (platform3 === "darwin") {
|
|
19926
19926
|
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
19927
19927
|
}
|
|
19928
|
-
if (
|
|
19928
|
+
if (platform3 === "win32") {
|
|
19929
19929
|
const programData = environment["PROGRAMDATA"]?.trim();
|
|
19930
19930
|
return programData ? NodePath4.join(programData, "ClaudeCode", "managed-settings.json") : void 0;
|
|
19931
19931
|
}
|
|
19932
19932
|
return "/etc/claude-code/managed-settings.json";
|
|
19933
19933
|
}
|
|
19934
|
-
function skillOverrideSettingsPaths(configDirPath, cwd,
|
|
19935
|
-
const managedPath = claudeManagedSettingsPath(
|
|
19934
|
+
function skillOverrideSettingsPaths(configDirPath, cwd, platform3, environment, repositoryRoot) {
|
|
19935
|
+
const managedPath = claudeManagedSettingsPath(platform3, environment);
|
|
19936
19936
|
const root = repositoryRoot !== void 0 && repositoryRoot !== cwd ? repositoryRoot : void 0;
|
|
19937
19937
|
return [
|
|
19938
19938
|
NodePath4.join(configDirPath, "settings.json"),
|
|
@@ -20007,13 +20007,13 @@ function readOverridesFromSettings(text) {
|
|
|
20007
20007
|
}
|
|
20008
20008
|
return result;
|
|
20009
20009
|
}
|
|
20010
|
-
async function readSkillOverrides(configDirPath, cwd,
|
|
20010
|
+
async function readSkillOverrides(configDirPath, cwd, platform3, environment) {
|
|
20011
20011
|
const repositoryRoot = cwd === void 0 ? void 0 : await findRepositoryRoot(cwd);
|
|
20012
20012
|
const merged = /* @__PURE__ */ new Map();
|
|
20013
20013
|
for (const settingsPath of skillOverrideSettingsPaths(
|
|
20014
20014
|
configDirPath,
|
|
20015
20015
|
cwd,
|
|
20016
|
-
|
|
20016
|
+
platform3,
|
|
20017
20017
|
environment,
|
|
20018
20018
|
repositoryRoot
|
|
20019
20019
|
)) {
|
|
@@ -22321,12 +22321,20 @@ function parseCliArgs(args, options) {
|
|
|
22321
22321
|
const booleanSet = options?.booleanFlags ? new Set(options.booleanFlags) : void 0;
|
|
22322
22322
|
const flags = {};
|
|
22323
22323
|
const positionals = [];
|
|
22324
|
+
const variadicArgs = [];
|
|
22324
22325
|
for (let i = 0; i < tokens.length; i++) {
|
|
22325
22326
|
const token = tokens[i];
|
|
22326
22327
|
if (token.startsWith("--")) {
|
|
22327
22328
|
const rest = token.slice(2);
|
|
22328
22329
|
if (!rest) continue;
|
|
22329
22330
|
const eqIndex = rest.indexOf("=");
|
|
22331
|
+
if (options?.variadicFlags?.includes(eqIndex === -1 ? rest : rest.slice(0, eqIndex))) {
|
|
22332
|
+
variadicArgs.push(token);
|
|
22333
|
+
while (tokens[i + 1] !== void 0 && !tokens[i + 1].startsWith("-")) {
|
|
22334
|
+
variadicArgs.push(tokens[++i]);
|
|
22335
|
+
}
|
|
22336
|
+
continue;
|
|
22337
|
+
}
|
|
22330
22338
|
if (eqIndex !== -1) {
|
|
22331
22339
|
flags[rest.slice(0, eqIndex)] = rest.slice(eqIndex + 1);
|
|
22332
22340
|
continue;
|
|
@@ -22346,7 +22354,7 @@ function parseCliArgs(args, options) {
|
|
|
22346
22354
|
positionals.push(token);
|
|
22347
22355
|
}
|
|
22348
22356
|
}
|
|
22349
|
-
return { flags, positionals };
|
|
22357
|
+
return { flags, positionals, variadicArgs };
|
|
22350
22358
|
}
|
|
22351
22359
|
|
|
22352
22360
|
// src/sdkModels.ts
|
|
@@ -23532,7 +23540,7 @@ var makeSessionLifecycle = (deps) => {
|
|
|
23532
23540
|
await completeTurn(context, "interrupted", "Session stopped.");
|
|
23533
23541
|
}
|
|
23534
23542
|
if (closeFailure) throw closeFailure;
|
|
23535
|
-
context.cliProcess.clear();
|
|
23543
|
+
await context.cliProcess.clear();
|
|
23536
23544
|
context.promptQueue.terminate();
|
|
23537
23545
|
const streamFiber = context.streamFiber;
|
|
23538
23546
|
context.streamFiber = void 0;
|
|
@@ -23663,7 +23671,7 @@ var ClaudeProcess = class extends NodeEvents.EventEmitter {
|
|
|
23663
23671
|
exitCode = null;
|
|
23664
23672
|
handle;
|
|
23665
23673
|
ended = false;
|
|
23666
|
-
constructor(host, options, stderr) {
|
|
23674
|
+
constructor(host, options, stderr, cleanup) {
|
|
23667
23675
|
super();
|
|
23668
23676
|
const env2 = {
|
|
23669
23677
|
...Object.fromEntries(Object.keys(process.env).map((key) => [key, void 0])),
|
|
@@ -23715,14 +23723,16 @@ var ClaudeProcess = class extends NodeEvents.EventEmitter {
|
|
|
23715
23723
|
this.ended = true;
|
|
23716
23724
|
this.handle = void 0;
|
|
23717
23725
|
this.exitCode = code;
|
|
23726
|
+
await cleanup();
|
|
23718
23727
|
this.emit("exit", code, null);
|
|
23719
23728
|
} finally {
|
|
23720
23729
|
options.signal.removeEventListener("abort", abort);
|
|
23721
23730
|
}
|
|
23722
|
-
}).catch((cause) => {
|
|
23731
|
+
}).catch(async (cause) => {
|
|
23723
23732
|
this.ended = true;
|
|
23724
23733
|
this.handle = void 0;
|
|
23725
23734
|
options.signal.removeEventListener("abort", abort);
|
|
23735
|
+
await cleanup();
|
|
23726
23736
|
this.emit("error", asError(cause));
|
|
23727
23737
|
});
|
|
23728
23738
|
}
|
|
@@ -23734,23 +23744,69 @@ var ClaudeProcess = class extends NodeEvents.EventEmitter {
|
|
|
23734
23744
|
return true;
|
|
23735
23745
|
}
|
|
23736
23746
|
};
|
|
23737
|
-
function makeClaudeProcessSpawner(host, stderr) {
|
|
23747
|
+
function makeClaudeProcessSpawner(host, stderr, config = {}) {
|
|
23748
|
+
const cleanup = config.cleanup ?? (async () => {
|
|
23749
|
+
});
|
|
23738
23750
|
let process2;
|
|
23739
23751
|
let launch;
|
|
23740
23752
|
return {
|
|
23741
23753
|
spawn: (options) => {
|
|
23742
|
-
|
|
23743
|
-
|
|
23754
|
+
const args = [...options.args, ...config.mcpConfigArgs ?? []];
|
|
23755
|
+
if (config.mcpConfigPath !== void 0) {
|
|
23756
|
+
const flag = args.findLastIndex(
|
|
23757
|
+
(arg) => arg === "--mcp-config" || arg.startsWith("--mcp-config=")
|
|
23758
|
+
);
|
|
23759
|
+
if (flag === -1) args.push("--mcp-config", config.mcpConfigPath);
|
|
23760
|
+
else {
|
|
23761
|
+
let end = flag + 1;
|
|
23762
|
+
while (end < args.length && !args[end].startsWith("-")) end++;
|
|
23763
|
+
args.splice(end, 0, config.mcpConfigPath);
|
|
23764
|
+
}
|
|
23765
|
+
}
|
|
23766
|
+
launch = { ...options, args };
|
|
23767
|
+
process2 = new ClaudeProcess(host, launch, stderr, cleanup);
|
|
23744
23768
|
return process2;
|
|
23745
23769
|
},
|
|
23746
23770
|
current: () => process2?.handle && launch ? { handle: process2.handle, command: launch.command, args: launch.args } : void 0,
|
|
23747
23771
|
clear: () => {
|
|
23748
23772
|
process2 = void 0;
|
|
23749
23773
|
launch = void 0;
|
|
23774
|
+
return cleanup();
|
|
23750
23775
|
}
|
|
23751
23776
|
};
|
|
23752
23777
|
}
|
|
23753
23778
|
|
|
23779
|
+
// src/claudeMcpConfig.ts
|
|
23780
|
+
import * as NodeFSP3 from "node:fs/promises";
|
|
23781
|
+
import * as NodeOS6 from "node:os";
|
|
23782
|
+
import * as NodePath7 from "node:path";
|
|
23783
|
+
import * as NodeProcess2 from "node:process";
|
|
23784
|
+
async function createClaudeMcpConfig(mcpServers, log) {
|
|
23785
|
+
let directory;
|
|
23786
|
+
let cleanupWork;
|
|
23787
|
+
const cleanup = () => {
|
|
23788
|
+
cleanupWork ??= directory === void 0 ? Promise.resolve() : NodeFSP3.rm(directory, { recursive: true, force: true }).catch(() => {
|
|
23789
|
+
log.warn("claude.mcpConfig.cleanupFailed");
|
|
23790
|
+
});
|
|
23791
|
+
return cleanupWork;
|
|
23792
|
+
};
|
|
23793
|
+
if (mcpServers === void 0) {
|
|
23794
|
+
return { path: void 0, cleanup };
|
|
23795
|
+
}
|
|
23796
|
+
try {
|
|
23797
|
+
directory = await NodeFSP3.mkdtemp(NodePath7.join(NodeOS6.tmpdir(), "ycodium-claude-mcp-"));
|
|
23798
|
+
const file = NodePath7.join(directory, "mcp.json");
|
|
23799
|
+
await NodeFSP3.writeFile(file, JSON.stringify({ mcpServers }), { mode: 384 });
|
|
23800
|
+
await NodeFSP3.chmod(file, 384).catch((cause) => {
|
|
23801
|
+
if (NodeProcess2.platform !== "win32") throw cause;
|
|
23802
|
+
});
|
|
23803
|
+
return { path: file, cleanup };
|
|
23804
|
+
} catch (cause) {
|
|
23805
|
+
await cleanup();
|
|
23806
|
+
throw cause;
|
|
23807
|
+
}
|
|
23808
|
+
}
|
|
23809
|
+
|
|
23754
23810
|
// src/readOnlyDirectories.ts
|
|
23755
23811
|
var GLOB_METACHARACTERS = /[*?[\]{}]/;
|
|
23756
23812
|
function toClaudeAbsolutePath(directory) {
|
|
@@ -23813,13 +23869,15 @@ var makeStartSession = (deps) => {
|
|
|
23813
23869
|
const { nowIso, randomUUIDv4, makeEventStamp, offerRuntimeEvent } = emitter;
|
|
23814
23870
|
const startSession = async (input) => {
|
|
23815
23871
|
if (recipe.binaryPath.length === 0) throw new Error(CLAUDE_PROGRAM_NOT_CONFIGURED);
|
|
23872
|
+
const { flags, variadicArgs } = parseCliArgs(recipe.launchArgs, {
|
|
23873
|
+
booleanFlags: ["dangerously-skip-permissions"],
|
|
23874
|
+
variadicFlags: ["mcp-config"]
|
|
23875
|
+
});
|
|
23816
23876
|
const {
|
|
23817
23877
|
"permission-mode": launchArgPermissionMode,
|
|
23818
23878
|
"dangerously-skip-permissions": launchArgSkipPermissions,
|
|
23819
23879
|
...extraArgs
|
|
23820
|
-
} =
|
|
23821
|
-
booleanFlags: ["dangerously-skip-permissions"]
|
|
23822
|
-
}).flags;
|
|
23880
|
+
} = flags;
|
|
23823
23881
|
const modelSelection = boundModelSelection(input.modelSelection, boundInstanceId);
|
|
23824
23882
|
await modelCatalog.pendingRead();
|
|
23825
23883
|
const caps = claudeModelCapabilities(
|
|
@@ -23933,7 +23991,12 @@ var makeStartSession = (deps) => {
|
|
|
23933
23991
|
querySettings.permissions = { allow: [...readAllowRules] };
|
|
23934
23992
|
}
|
|
23935
23993
|
const stderrTail = createOutputTail(CLAUDE_STDERR_TAIL_CHARS);
|
|
23936
|
-
const
|
|
23994
|
+
const mcpConfig = await createClaudeMcpConfig(mcpServers, log);
|
|
23995
|
+
const cliProcess = makeClaudeProcessSpawner(deps.host, stderrTail.append, {
|
|
23996
|
+
cleanup: mcpConfig.cleanup,
|
|
23997
|
+
...mcpConfig.path === void 0 ? {} : { mcpConfigPath: mcpConfig.path },
|
|
23998
|
+
mcpConfigArgs: variadicArgs
|
|
23999
|
+
});
|
|
23937
24000
|
const queryOptions = {
|
|
23938
24001
|
spawnClaudeCodeProcess: cliProcess.spawn,
|
|
23939
24002
|
...input.cwd ? { cwd: input.cwd } : {},
|
|
@@ -23970,7 +24033,6 @@ var makeStartSession = (deps) => {
|
|
|
23970
24033
|
env: { ...spawnEnvironment.processEnv },
|
|
23971
24034
|
additionalDirectories,
|
|
23972
24035
|
...Object.keys(extraArgs).length > 0 ? { extraArgs } : {},
|
|
23973
|
-
...mcpServers === void 0 ? {} : { mcpServers },
|
|
23974
24036
|
...claudeSessionPlugins(input.skills)
|
|
23975
24037
|
};
|
|
23976
24038
|
let queryRuntime;
|
|
@@ -23980,7 +24042,7 @@ var makeStartSession = (deps) => {
|
|
|
23980
24042
|
options: queryOptions
|
|
23981
24043
|
});
|
|
23982
24044
|
} catch (cause) {
|
|
23983
|
-
cliProcess.clear();
|
|
24045
|
+
await cliProcess.clear();
|
|
23984
24046
|
throw new Error("Failed to start Claude runtime session.", { cause });
|
|
23985
24047
|
}
|
|
23986
24048
|
const session = {
|
|
@@ -24354,8 +24416,8 @@ var makeStreamEventHandler = (deps) => {
|
|
|
24354
24416
|
};
|
|
24355
24417
|
|
|
24356
24418
|
// src/claudeWorkspaceInventory.ts
|
|
24357
|
-
import * as
|
|
24358
|
-
import * as
|
|
24419
|
+
import * as NodeFSP4 from "node:fs/promises";
|
|
24420
|
+
import * as NodePath8 from "node:path";
|
|
24359
24421
|
var MAX_COMMAND_DEPTH = 5;
|
|
24360
24422
|
var MAX_COMMAND_FILES = 500;
|
|
24361
24423
|
var MAX_DESCRIPTION_LENGTH = 200;
|
|
@@ -24373,7 +24435,7 @@ var firstBodyLine = (contents) => {
|
|
|
24373
24435
|
return void 0;
|
|
24374
24436
|
};
|
|
24375
24437
|
var scanCommands = async (claudeDir) => {
|
|
24376
|
-
const root =
|
|
24438
|
+
const root = NodePath8.join(claudeDir, "commands");
|
|
24377
24439
|
const commands = /* @__PURE__ */ new Map();
|
|
24378
24440
|
const watched = [root];
|
|
24379
24441
|
let level = [root];
|
|
@@ -24381,9 +24443,9 @@ var scanCommands = async (claudeDir) => {
|
|
|
24381
24443
|
for (let depth = 0; depth < MAX_COMMAND_DEPTH && level.length > 0; depth += 1) {
|
|
24382
24444
|
const next = [];
|
|
24383
24445
|
for (const directory of level) {
|
|
24384
|
-
const entries = await
|
|
24446
|
+
const entries = await NodeFSP4.readdir(directory, { withFileTypes: true }).catch(() => []);
|
|
24385
24447
|
for (const entry of entries.toSorted((left, right) => left.name.localeCompare(right.name))) {
|
|
24386
|
-
const entryPath =
|
|
24448
|
+
const entryPath = NodePath8.join(directory, entry.name);
|
|
24387
24449
|
if (entry.isDirectory()) {
|
|
24388
24450
|
next.push(entryPath);
|
|
24389
24451
|
watched.push(entryPath);
|
|
@@ -24395,7 +24457,7 @@ var scanCommands = async (claudeDir) => {
|
|
|
24395
24457
|
files += 1;
|
|
24396
24458
|
const name = entry.name.slice(0, -".md".length).trim();
|
|
24397
24459
|
if (name.length === 0 || commands.has(name)) continue;
|
|
24398
|
-
const contents = await
|
|
24460
|
+
const contents = await NodeFSP4.readFile(entryPath, "utf8").catch(() => void 0);
|
|
24399
24461
|
if (contents === void 0) continue;
|
|
24400
24462
|
const frontMatter = parseSkillFrontMatter(contents);
|
|
24401
24463
|
const description = frontMatter.description ?? firstBodyLine(contents);
|
|
@@ -24411,13 +24473,13 @@ var scanCommands = async (claudeDir) => {
|
|
|
24411
24473
|
return { commands: [...commands.values()], watched };
|
|
24412
24474
|
};
|
|
24413
24475
|
var watchSkillsRoot = async (claudeDir) => {
|
|
24414
|
-
const root =
|
|
24415
|
-
const entries = await
|
|
24476
|
+
const root = NodePath8.join(claudeDir, "skills");
|
|
24477
|
+
const entries = await NodeFSP4.readdir(root).catch(() => []);
|
|
24416
24478
|
return [
|
|
24417
24479
|
root,
|
|
24418
24480
|
...entries.flatMap((entry) => [
|
|
24419
|
-
|
|
24420
|
-
|
|
24481
|
+
NodePath8.join(root, entry),
|
|
24482
|
+
NodePath8.join(root, entry, "SKILL.md")
|
|
24421
24483
|
])
|
|
24422
24484
|
];
|
|
24423
24485
|
};
|
|
@@ -24428,7 +24490,7 @@ var mergeByName = (base, preferred) => {
|
|
|
24428
24490
|
return [...merged.values()].toSorted((left, right) => left.name.localeCompare(right.name));
|
|
24429
24491
|
};
|
|
24430
24492
|
var discoverClaudeWorkspaceInventory = async (input) => {
|
|
24431
|
-
const projectClaudeDir =
|
|
24493
|
+
const projectClaudeDir = NodePath8.join(input.cwd, ".claude");
|
|
24432
24494
|
const [userCommands, projectCommands, skills, userSkillWatch, projectSkillWatch] = await Promise.all([
|
|
24433
24495
|
scanCommands(input.configDirPath),
|
|
24434
24496
|
scanCommands(projectClaudeDir),
|
|
@@ -24450,9 +24512,9 @@ var discoverClaudeWorkspaceInventory = async (input) => {
|
|
|
24450
24512
|
...userSkillWatch,
|
|
24451
24513
|
...projectSkillWatch,
|
|
24452
24514
|
// `skillOverrides` 在这几个设置文件里:开关一个技能也要重查。
|
|
24453
|
-
|
|
24454
|
-
|
|
24455
|
-
|
|
24515
|
+
NodePath8.join(input.configDirPath, "settings.json"),
|
|
24516
|
+
NodePath8.join(projectClaudeDir, "settings.json"),
|
|
24517
|
+
NodePath8.join(projectClaudeDir, "settings.local.json")
|
|
24456
24518
|
]
|
|
24457
24519
|
};
|
|
24458
24520
|
};
|
|
@@ -25238,7 +25300,7 @@ var makeTurnLifecycle = (deps) => {
|
|
|
25238
25300
|
};
|
|
25239
25301
|
|
|
25240
25302
|
// src/adapter/turnMessages.ts
|
|
25241
|
-
import * as
|
|
25303
|
+
import * as NodePath9 from "node:path";
|
|
25242
25304
|
var makeTurnMessageHandlers = (deps) => {
|
|
25243
25305
|
const {
|
|
25244
25306
|
emitter,
|
|
@@ -25494,7 +25556,7 @@ var makeTurnMessageHandlers = (deps) => {
|
|
|
25494
25556
|
claudeFailureHint({
|
|
25495
25557
|
authenticationFailed: context.turnState?.authenticationFailed === true,
|
|
25496
25558
|
environment: buildLaunchEnvironment(),
|
|
25497
|
-
cwd:
|
|
25559
|
+
cwd: NodePath9.resolve(context.session.cwd ?? "."),
|
|
25498
25560
|
...context.turnState === void 0 ? {} : {
|
|
25499
25561
|
usageLimit: {
|
|
25500
25562
|
rejected: context.turnState.rejectedRateLimits,
|
|
@@ -25536,11 +25598,11 @@ function withClaudeCredentialsDir(input) {
|
|
|
25536
25598
|
const variable = CLAUDE_CREDENTIALS_DIR_ENVIRONMENT_VARIABLE;
|
|
25537
25599
|
return input.platform === "win32" ? `$env:${variable}=${quotePowerShellValue(input.credentialsDirPath)}; ${input.command}` : `${variable}=${quotePosixShellValue(input.credentialsDirPath)} ${input.command}`;
|
|
25538
25600
|
}
|
|
25539
|
-
function claudeSignInCommand(credentialsPath,
|
|
25601
|
+
function claudeSignInCommand(credentialsPath, platform3) {
|
|
25540
25602
|
const command = "claude auth login";
|
|
25541
25603
|
const credentialsDirPath = resolveClaudeCredentialsDirPath(credentialsPath);
|
|
25542
25604
|
if (credentialsDirPath === null) return command;
|
|
25543
|
-
return withClaudeCredentialsDir({ command, credentialsDirPath, platform:
|
|
25605
|
+
return withClaudeCredentialsDir({ command, credentialsDirPath, platform: platform3 });
|
|
25544
25606
|
}
|
|
25545
25607
|
|
|
25546
25608
|
// src/events.ts
|
|
@@ -25579,9 +25641,9 @@ var EventBus = class {
|
|
|
25579
25641
|
|
|
25580
25642
|
// src/sessions.ts
|
|
25581
25643
|
import * as NodeFS3 from "node:fs";
|
|
25582
|
-
import * as
|
|
25583
|
-
import * as
|
|
25584
|
-
import * as
|
|
25644
|
+
import * as NodeOS7 from "node:os";
|
|
25645
|
+
import * as NodePath10 from "node:path";
|
|
25646
|
+
import * as NodeProcess3 from "node:process";
|
|
25585
25647
|
|
|
25586
25648
|
// ../../packages/ycodium-jsonl-stream/src/jsonlStream.ts
|
|
25587
25649
|
var DEFAULT_MAX_RETAINED_CHARS = 8e6;
|
|
@@ -26209,7 +26271,7 @@ function listTranscriptFiles(transcriptDir, directory) {
|
|
|
26209
26271
|
const scanned = matched.length > 0 ? matched : dirs;
|
|
26210
26272
|
const found = [];
|
|
26211
26273
|
for (const dir of scanned) {
|
|
26212
|
-
const projectDir =
|
|
26274
|
+
const projectDir = NodePath10.join(transcriptDir, dir);
|
|
26213
26275
|
let names;
|
|
26214
26276
|
try {
|
|
26215
26277
|
names = NodeFS3.readdirSync(projectDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(TRANSCRIPT_SUFFIX)).map((entry) => entry.name);
|
|
@@ -26219,12 +26281,12 @@ function listTranscriptFiles(transcriptDir, directory) {
|
|
|
26219
26281
|
for (const name of names) {
|
|
26220
26282
|
let stat2;
|
|
26221
26283
|
try {
|
|
26222
|
-
stat2 = NodeFS3.statSync(
|
|
26284
|
+
stat2 = NodeFS3.statSync(NodePath10.join(projectDir, name));
|
|
26223
26285
|
} catch {
|
|
26224
26286
|
continue;
|
|
26225
26287
|
}
|
|
26226
26288
|
found.push({
|
|
26227
|
-
path:
|
|
26289
|
+
path: NodePath10.join(projectDir, name),
|
|
26228
26290
|
sessionId: name.slice(0, -TRANSCRIPT_SUFFIX.length),
|
|
26229
26291
|
size: stat2.size,
|
|
26230
26292
|
mtimeMs: Number.isFinite(stat2.mtimeMs) ? stat2.mtimeMs : 0
|
|
@@ -26235,7 +26297,7 @@ function listTranscriptFiles(transcriptDir, directory) {
|
|
|
26235
26297
|
}
|
|
26236
26298
|
function readClaudeLiveSessionIds(configDir) {
|
|
26237
26299
|
const live = /* @__PURE__ */ new Set();
|
|
26238
|
-
const markerDir =
|
|
26300
|
+
const markerDir = NodePath10.join(configDir, "sessions");
|
|
26239
26301
|
let entries;
|
|
26240
26302
|
try {
|
|
26241
26303
|
entries = NodeFS3.readdirSync(markerDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name);
|
|
@@ -26245,7 +26307,7 @@ function readClaudeLiveSessionIds(configDir) {
|
|
|
26245
26307
|
for (const entry of entries) {
|
|
26246
26308
|
let marker;
|
|
26247
26309
|
try {
|
|
26248
|
-
marker = JSON.parse(NodeFS3.readFileSync(
|
|
26310
|
+
marker = JSON.parse(NodeFS3.readFileSync(NodePath10.join(markerDir, entry), "utf8"));
|
|
26249
26311
|
} catch {
|
|
26250
26312
|
continue;
|
|
26251
26313
|
}
|
|
@@ -26253,7 +26315,7 @@ function readClaudeLiveSessionIds(configDir) {
|
|
|
26253
26315
|
const typed = marker;
|
|
26254
26316
|
if (typeof typed.pid !== "number" || typeof typed.sessionId !== "string") continue;
|
|
26255
26317
|
try {
|
|
26256
|
-
|
|
26318
|
+
NodeProcess3.kill(typed.pid, 0);
|
|
26257
26319
|
} catch {
|
|
26258
26320
|
continue;
|
|
26259
26321
|
}
|
|
@@ -26275,7 +26337,7 @@ async function scanClaudeSessions(input) {
|
|
|
26275
26337
|
}
|
|
26276
26338
|
const files = [...listTranscriptFiles(input.transcriptDir, input.directory)].sort((left, right) => right.mtimeMs - left.mtimeMs).slice(0, MAX_SCANNED_FILES);
|
|
26277
26339
|
const live = readClaudeLiveSessionIds(input.configDir);
|
|
26278
|
-
const caseInsensitive = input.caseInsensitive ??
|
|
26340
|
+
const caseInsensitive = input.caseInsensitive ?? NodeOS7.type() === "Windows_NT";
|
|
26279
26341
|
const rows = [];
|
|
26280
26342
|
for (const file of files) {
|
|
26281
26343
|
if (rows.length >= MAX_ROWS) break;
|
|
@@ -26299,7 +26361,7 @@ async function scanClaudeSessions(input) {
|
|
|
26299
26361
|
function resolveTranscriptPath(input) {
|
|
26300
26362
|
const fileName = `${input.sessionId}${TRANSCRIPT_SUFFIX}`;
|
|
26301
26363
|
if (input.cwd !== void 0 && input.cwd.length > 0) {
|
|
26302
|
-
const direct =
|
|
26364
|
+
const direct = NodePath10.join(
|
|
26303
26365
|
input.transcriptDir,
|
|
26304
26366
|
encodeClaudeProjectDirName(input.cwd),
|
|
26305
26367
|
fileName
|
|
@@ -26316,7 +26378,7 @@ function resolveTranscriptPath(input) {
|
|
|
26316
26378
|
return null;
|
|
26317
26379
|
}
|
|
26318
26380
|
for (const dir of dirs) {
|
|
26319
|
-
const candidate =
|
|
26381
|
+
const candidate = NodePath10.join(input.transcriptDir, dir, fileName);
|
|
26320
26382
|
try {
|
|
26321
26383
|
if (NodeFS3.statSync(candidate).isFile()) return candidate;
|
|
26322
26384
|
} catch {
|
|
@@ -26392,9 +26454,9 @@ async function readClaudeSessionRecord(input) {
|
|
|
26392
26454
|
}
|
|
26393
26455
|
|
|
26394
26456
|
// src/textGeneration.ts
|
|
26395
|
-
import * as
|
|
26396
|
-
import * as
|
|
26397
|
-
import * as
|
|
26457
|
+
import * as NodeFSP5 from "node:fs/promises";
|
|
26458
|
+
import * as NodeOS8 from "node:os";
|
|
26459
|
+
import * as NodePath11 from "node:path";
|
|
26398
26460
|
import { mergeLaunchEnv } from "@ycodium-ai/plugin-api/executor";
|
|
26399
26461
|
|
|
26400
26462
|
// src/textGenerationUtils.ts
|
|
@@ -26863,13 +26925,13 @@ function createClaudeTextGeneration(recipe, host, modelCatalog) {
|
|
|
26863
26925
|
return decodeStructuredOutput(stdout, input.operation);
|
|
26864
26926
|
};
|
|
26865
26927
|
if (input.operation !== "generateThreadTitle") return runIn(input.cwd);
|
|
26866
|
-
const scratchDirectory = await
|
|
26867
|
-
|
|
26928
|
+
const scratchDirectory = await NodeFSP5.mkdtemp(
|
|
26929
|
+
NodePath11.join(NodeOS8.tmpdir(), "ycodium-claude-title-")
|
|
26868
26930
|
);
|
|
26869
26931
|
try {
|
|
26870
26932
|
return await runIn(scratchDirectory);
|
|
26871
26933
|
} finally {
|
|
26872
|
-
await
|
|
26934
|
+
await NodeFSP5.rm(scratchDirectory, { recursive: true, force: true }).catch(() => void 0);
|
|
26873
26935
|
}
|
|
26874
26936
|
};
|
|
26875
26937
|
const asRecord2 = (value, operation) => {
|
|
@@ -27019,11 +27081,11 @@ function createClaudeTextGeneration(recipe, host, modelCatalog) {
|
|
|
27019
27081
|
}
|
|
27020
27082
|
|
|
27021
27083
|
// src/usageRead/index.ts
|
|
27022
|
-
import * as
|
|
27084
|
+
import * as NodePath15 from "node:path";
|
|
27023
27085
|
|
|
27024
27086
|
// src/usageRead/quota.ts
|
|
27025
27087
|
import * as NodeFS4 from "node:fs";
|
|
27026
|
-
import * as
|
|
27088
|
+
import * as NodePath12 from "node:path";
|
|
27027
27089
|
import { mergeLaunchEnv as mergeLaunchEnv2, setsOwnModelConnection } from "@ycodium-ai/plugin-api/executor";
|
|
27028
27090
|
import {
|
|
27029
27091
|
parseRetryAfterMs
|
|
@@ -27046,14 +27108,14 @@ var claudeCredentialFileCandidates = (recipe) => {
|
|
|
27046
27108
|
const credentialsDir = resolveClaudeCredentialsDirPath(
|
|
27047
27109
|
environment[CLAUDE_CREDENTIALS_DIR_ENVIRONMENT_VARIABLE] ?? ""
|
|
27048
27110
|
);
|
|
27049
|
-
if (credentialsDir !== null) return [
|
|
27111
|
+
if (credentialsDir !== null) return [NodePath12.join(credentialsDir, ".credentials.json")];
|
|
27050
27112
|
const configDir = resolveClaudeConfigDirPath(recipe.homePath, environment);
|
|
27051
27113
|
const home = resolveClaudeHomePath(recipe.homePath);
|
|
27052
27114
|
return [
|
|
27053
27115
|
.../* @__PURE__ */ new Set([
|
|
27054
|
-
|
|
27055
|
-
|
|
27056
|
-
|
|
27116
|
+
NodePath12.join(configDir, ".credentials.json"),
|
|
27117
|
+
NodePath12.join(home, ".claude", ".credentials.json"),
|
|
27118
|
+
NodePath12.join(home, ".credentials.json")
|
|
27057
27119
|
])
|
|
27058
27120
|
];
|
|
27059
27121
|
};
|
|
@@ -27214,11 +27276,11 @@ var claudeQuotaFromRateLimitEvent = (message) => {
|
|
|
27214
27276
|
};
|
|
27215
27277
|
|
|
27216
27278
|
// src/usageRead/scanCache.ts
|
|
27217
|
-
import * as
|
|
27279
|
+
import * as NodePath14 from "node:path";
|
|
27218
27280
|
|
|
27219
27281
|
// src/usageRead/transcriptScan.ts
|
|
27220
27282
|
import * as NodeFS5 from "node:fs";
|
|
27221
|
-
import * as
|
|
27283
|
+
import * as NodePath13 from "node:path";
|
|
27222
27284
|
|
|
27223
27285
|
// src/usageRead/transcriptLine.ts
|
|
27224
27286
|
var int = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.trunc(value) : 0;
|
|
@@ -27280,7 +27342,7 @@ async function listTranscriptFiles2(root, sinceMs) {
|
|
|
27280
27342
|
return;
|
|
27281
27343
|
}
|
|
27282
27344
|
for (const entry of entries) {
|
|
27283
|
-
const child =
|
|
27345
|
+
const child = NodePath13.join(dir, entry.name);
|
|
27284
27346
|
if (entry.isDirectory()) {
|
|
27285
27347
|
await walk(child);
|
|
27286
27348
|
continue;
|
|
@@ -27517,8 +27579,8 @@ function pruneScanCache(cache, options) {
|
|
|
27517
27579
|
for (const [path, entry] of cache) {
|
|
27518
27580
|
const agedOut = entry.mtimeMs < options.retentionCutoffMs;
|
|
27519
27581
|
const underWalkedRoot = options.walkedRoots.some((root) => {
|
|
27520
|
-
const relative2 =
|
|
27521
|
-
return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${
|
|
27582
|
+
const relative2 = NodePath14.relative(root, path);
|
|
27583
|
+
return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${NodePath14.sep}`) && !NodePath14.isAbsolute(relative2);
|
|
27522
27584
|
});
|
|
27523
27585
|
const deleted = underWalkedRoot && entry.mtimeMs >= options.windowStartMs && !options.livePaths.has(path);
|
|
27524
27586
|
if (agedOut || deleted) {
|
|
@@ -27694,7 +27756,7 @@ var createClaudeUsage = (input) => {
|
|
|
27694
27756
|
});
|
|
27695
27757
|
const tokens = createClaudeTokenReader({
|
|
27696
27758
|
configDir,
|
|
27697
|
-
transcriptRoot:
|
|
27759
|
+
transcriptRoot: NodePath15.join(configDir, "projects"),
|
|
27698
27760
|
cache: input.cache
|
|
27699
27761
|
});
|
|
27700
27762
|
return {
|
|
@@ -27741,11 +27803,11 @@ function openCommandsOf(context) {
|
|
|
27741
27803
|
if (commands.length === 0) return void 0;
|
|
27742
27804
|
return {
|
|
27743
27805
|
rootPid: current.handle.pid,
|
|
27744
|
-
sessionProcess: (argv,
|
|
27745
|
-
const normalize2 = (value) =>
|
|
27806
|
+
sessionProcess: (argv, platform3) => {
|
|
27807
|
+
const normalize2 = (value) => platform3 === "win32" ? value.replaceAll("\\", "/").toLowerCase() : value;
|
|
27746
27808
|
const expected = normalize2(current.command);
|
|
27747
27809
|
const actual = normalize2(argv[0] ?? "");
|
|
27748
|
-
const sameProgram = expected.includes("/") ? actual === expected :
|
|
27810
|
+
const sameProgram = expected.includes("/") ? actual === expected : platform3 === "win32" ? basename(actual).replace(/\.exe$/, "") === expected.replace(/\.exe$/, "") : actual.split("/").at(-1) === expected;
|
|
27749
27811
|
return sameProgram && sameArgv(argv.slice(1), current.args);
|
|
27750
27812
|
},
|
|
27751
27813
|
commands
|
|
@@ -27964,7 +28026,7 @@ function createClaudeInstance(config, host, attachments, overrides, usageCache)
|
|
|
27964
28026
|
);
|
|
27965
28027
|
return {
|
|
27966
28028
|
configDir,
|
|
27967
|
-
transcriptDir:
|
|
28029
|
+
transcriptDir: NodePath16.join(configDir, "projects")
|
|
27968
28030
|
};
|
|
27969
28031
|
};
|
|
27970
28032
|
return {
|
|
@@ -28018,7 +28080,7 @@ function createClaudeInstance(config, host, attachments, overrides, usageCache)
|
|
|
28018
28080
|
start: async () => {
|
|
28019
28081
|
const command = claudeSignInCommand(
|
|
28020
28082
|
recipe.credentialsPath,
|
|
28021
|
-
|
|
28083
|
+
NodeOS9.type() === "Windows_NT" ? "win32" : "linux"
|
|
28022
28084
|
);
|
|
28023
28085
|
return {
|
|
28024
28086
|
operationId: `claude-sign-in-${crypto.randomUUID()}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-claude",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3082",
|
|
4
4
|
"description": "Claude executor: Claude Code CLI via @anthropic-ai/claude-agent-sdk.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@types/node": "24.12.4",
|
|
25
25
|
"esbuild": "0.28.1",
|
|
26
26
|
"vite-plus": "0.2.2",
|
|
27
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
27
|
+
"@ycodium-ai/plugin-api": "0.2.0",
|
|
28
28
|
"ycodium-composer-tokens": "0.0.0",
|
|
29
29
|
"ycodium-executor-testing": "0.0.0",
|
|
30
30
|
"ycodium-jsonl-stream": "0.0.0"
|