@ycodium-ai/agent-claude 0.2.2126 → 0.2.2143

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -29
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -19737,6 +19737,9 @@ function resolveClaudeHomePath(homePath) {
19737
19737
  const trimmed = homePath.trim();
19738
19738
  return NodePath4.resolve(trimmed.length > 0 ? expandHomePath(trimmed) : NodeOS4.homedir());
19739
19739
  }
19740
+ function claudeContinuationKey(homePath) {
19741
+ return `claude:home:${resolveClaudeHomePath(homePath)}`;
19742
+ }
19740
19743
  function resolveClaudeConfigDirPath(homePath, environment, cwd) {
19741
19744
  const trimmed = homePath.trim();
19742
19745
  if (trimmed.length > 0) {
@@ -21534,6 +21537,22 @@ function readClaudeSessionRecord(input) {
21534
21537
  };
21535
21538
  }
21536
21539
 
21540
+ // src/spawnEnvironment.ts
21541
+ function changedSpawnEnvironmentKeys(previous, next) {
21542
+ const settingsPresenceChanged = previous.settingsEnv === void 0 !== (next.settingsEnv === void 0);
21543
+ return [
21544
+ ...changedKeys(previous.processEnv, next.processEnv),
21545
+ ...settingsPresenceChanged ? ["settings.env"] : [],
21546
+ ...changedKeys(previous.settingsEnv ?? {}, next.settingsEnv ?? {}).map(
21547
+ (key) => `settings.env.${key}`
21548
+ )
21549
+ ];
21550
+ }
21551
+ function changedKeys(previous, next) {
21552
+ const keys = /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(next)]);
21553
+ return [...keys].filter((key) => previous[key] !== next[key]).sort();
21554
+ }
21555
+
21537
21556
  // src/usage.ts
21538
21557
  function maxClaudeContextWindowFromModelUsage(modelUsage) {
21539
21558
  if (!modelUsage) return void 0;
@@ -24772,10 +24791,24 @@ function createClaudeAdapter(recipe, host, options) {
24772
24791
  }
24773
24792
  return context;
24774
24793
  };
24794
+ const withProcessGeneration = (session, context) => ({
24795
+ ...session,
24796
+ ...context.origin.originBindingGeneration === void 0 ? {} : { bindingGeneration: context.origin.originBindingGeneration }
24797
+ });
24775
24798
  const reconfigureSession = async (context, input, desired) => {
24776
24799
  const resumeTarget = readClaudeResumeState(input.resumeCursor)?.resume;
24777
- const reusable = !context.stopped && context.session.status !== "closed" && context.session.cwd === input.cwd && context.session.runtimeMode === input.runtimeMode && context.basePermissionMode === desired.permissionMode && context.launchEffort === desired.effectiveEffort && (resumeTarget === void 0 || resumeTarget === context.resumeSessionId);
24800
+ const changedEnvironmentKeys = changedSpawnEnvironmentKeys(
24801
+ context.spawnEnvironment,
24802
+ desired.spawnEnvironment
24803
+ );
24804
+ const reusable = !context.stopped && context.session.status !== "closed" && context.session.cwd === input.cwd && context.session.runtimeMode === input.runtimeMode && context.basePermissionMode === desired.permissionMode && context.launchEffort === desired.effectiveEffort && (resumeTarget === void 0 || resumeTarget === context.resumeSessionId) && changedEnvironmentKeys.length === 0;
24778
24805
  if (!reusable) {
24806
+ if (changedEnvironmentKeys.length > 0) {
24807
+ (options?.log ?? host.log).info("claude.session.environment-changed", {
24808
+ threadId: context.session.threadId,
24809
+ changedKeys: changedEnvironmentKeys
24810
+ });
24811
+ }
24779
24812
  return void 0;
24780
24813
  }
24781
24814
  if (context.currentApiModelId !== desired.apiModelId) {
@@ -24822,10 +24855,7 @@ function createClaudeAdapter(recipe, host, options) {
24822
24855
  },
24823
24856
  providerRefs: {}
24824
24857
  });
24825
- return {
24826
- ...context.session,
24827
- ...context.origin.originBindingGeneration === void 0 ? {} : { bindingGeneration: context.origin.originBindingGeneration }
24828
- };
24858
+ return withProcessGeneration(context.session, context);
24829
24859
  };
24830
24860
  const startSession = async (input) => {
24831
24861
  const extraArgs = parseCliArgs(recipe.launchArgs).flags;
@@ -24859,6 +24889,29 @@ function createClaudeAdapter(recipe, host, options) {
24859
24889
  ultracode,
24860
24890
  autoCompactWindow: recipe.autoCompactWindow
24861
24891
  });
24892
+ const homeLayout = resolveClaudeLaunchHome({
24893
+ homePath: recipe.homePath,
24894
+ credentialsPath: recipe.credentialsPath,
24895
+ launchProcessEnv: input.launch.processEnv,
24896
+ pluginDataDirPath: options?.pluginDataDirPath,
24897
+ environment: claudeHomeEnvironment,
24898
+ ...options?.log === void 0 ? {} : { log: options.log }
24899
+ });
24900
+ const launchEnvironment = mergeLaunchEnv2({
24901
+ brainSlots: brainSlotEnvKeys3(CLAUDE_CARD),
24902
+ inherited: { ...process.env, ...options?.environment },
24903
+ instanceTable: recipe.environment,
24904
+ handOverrides: claudeHomeVariables(homeLayout),
24905
+ launch: input.launch.processEnv
24906
+ });
24907
+ const spawnEnvironment = {
24908
+ processEnv: compactEnv(launchEnvironment),
24909
+ settingsEnv: routedEnvOverride({
24910
+ launchProcessEnv: input.launch.processEnv,
24911
+ mergedEnv: launchEnvironment,
24912
+ ...recipe.customModels === void 0 ? {} : { customModels: recipe.customModels }
24913
+ })
24914
+ };
24862
24915
  const existingContext = sessions.get(input.threadId);
24863
24916
  if (existingContext) {
24864
24917
  const reconfigured = await reconfigureSession(existingContext, input, {
@@ -24867,7 +24920,8 @@ function createClaudeAdapter(recipe, host, options) {
24867
24920
  ...effectiveEffort ? { effectiveEffort } : {},
24868
24921
  ...initialContextWindow !== void 0 ? { contextWindow: initialContextWindow } : {},
24869
24922
  ...modelSelection?.model ? { model: modelSelection.model } : {},
24870
- settings
24923
+ settings,
24924
+ spawnEnvironment
24871
24925
  });
24872
24926
  if (reconfigured) {
24873
24927
  return reconfigured;
@@ -25184,31 +25238,11 @@ function createClaudeAdapter(recipe, host, options) {
25184
25238
  const onUserDialog = (request, callbackOptions) => handleResumeDialog(request, callbackOptions);
25185
25239
  const additionalDirectories = input.cwd ? [input.cwd] : [];
25186
25240
  const mcpServers = toClaudeMcpServers(input.mcpServers);
25187
- const homeLayout = resolveClaudeLaunchHome({
25188
- homePath: recipe.homePath,
25189
- credentialsPath: recipe.credentialsPath,
25190
- launchProcessEnv: input.launch.processEnv,
25191
- pluginDataDirPath: options?.pluginDataDirPath,
25192
- environment: claudeHomeEnvironment,
25193
- ...options?.log === void 0 ? {} : { log: options.log }
25194
- });
25195
25241
  await materializeClaudeRoutedHome(homeLayout, {
25196
25242
  ...input.cwd ? { trustedPaths: [input.cwd] } : {},
25197
25243
  ...options?.log === void 0 ? {} : { log: options.log }
25198
25244
  });
25199
- const launchEnvironment = mergeLaunchEnv2({
25200
- brainSlots: brainSlotEnvKeys3(CLAUDE_CARD),
25201
- inherited: { ...process.env, ...options?.environment },
25202
- instanceTable: recipe.environment,
25203
- handOverrides: claudeHomeVariables(homeLayout),
25204
- launch: input.launch.processEnv
25205
- });
25206
- const envOverride = routedEnvOverride({
25207
- launchProcessEnv: input.launch.processEnv,
25208
- mergedEnv: launchEnvironment,
25209
- ...recipe.customModels === void 0 ? {} : { customModels: recipe.customModels }
25210
- });
25211
- const querySettings = envOverride === void 0 ? { ...settings } : { ...settings, env: envOverride };
25245
+ const querySettings = spawnEnvironment.settingsEnv === void 0 ? { ...settings } : { ...settings, env: { ...spawnEnvironment.settingsEnv } };
25212
25246
  const stderrTail = createOutputTail(CLAUDE_STDERR_TAIL_CHARS);
25213
25247
  const queryOptions = {
25214
25248
  ...input.cwd ? { cwd: input.cwd } : {},
@@ -25243,7 +25277,7 @@ function createClaudeAdapter(recipe, host, options) {
25243
25277
  ]
25244
25278
  },
25245
25279
  supportedDialogKinds: ["resume_return"],
25246
- env: compactEnv(launchEnvironment),
25280
+ env: { ...spawnEnvironment.processEnv },
25247
25281
  additionalDirectories,
25248
25282
  ...Object.keys(extraArgs).length > 0 ? { extraArgs } : {},
25249
25283
  ...mcpServers === void 0 ? {} : { mcpServers }
@@ -25291,6 +25325,7 @@ function createClaudeAdapter(recipe, host, options) {
25291
25325
  currentApiModelId: apiModelId,
25292
25326
  currentEffort: effectiveEffort ?? void 0,
25293
25327
  launchEffort: effectiveEffort ?? void 0,
25328
+ spawnEnvironment,
25294
25329
  currentSettings: settings,
25295
25330
  interruptSettled: void 0,
25296
25331
  resumeSessionId: sessionId,
@@ -25367,7 +25402,7 @@ function createClaudeAdapter(recipe, host, options) {
25367
25402
  cause: cause instanceof Error ? cause.message : String(cause)
25368
25403
  });
25369
25404
  });
25370
- return { ...session };
25405
+ return withProcessGeneration(session, context);
25371
25406
  };
25372
25407
  const compactContext = async (threadId) => {
25373
25408
  const context = requireSession(threadId);
@@ -25747,6 +25782,7 @@ ${stderr}`);
25747
25782
  events: adapter.events,
25748
25783
  dispose: adapter.dispose,
25749
25784
  textGeneration: createClaudeTextGeneration(recipe, host, pluginDataDirPath),
25785
+ continuationKey: claudeContinuationKey(recipe.homePath),
25750
25786
  sessions: {
25751
25787
  scan: async (input) => {
25752
25788
  const roots = resolveTranscriptRoots(input.directory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-claude",
3
- "version": "0.2.2126",
3
+ "version": "0.2.2143",
4
4
  "description": "Claude executor: Claude Code CLI via @anthropic-ai/claude-agent-sdk.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -23,7 +23,7 @@
23
23
  "@types/node": "24.12.4",
24
24
  "esbuild": "0.28.1",
25
25
  "vite-plus": "0.2.2",
26
- "@ycodium-ai/plugin-api": "0.2.2126"
26
+ "@ycodium-ai/plugin-api": "0.2.2143"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",