@ycodium-ai/agent-claude 0.2.2130 → 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 +61 -29
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -21537,6 +21537,22 @@ function readClaudeSessionRecord(input) {
21537
21537
  };
21538
21538
  }
21539
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
+
21540
21556
  // src/usage.ts
21541
21557
  function maxClaudeContextWindowFromModelUsage(modelUsage) {
21542
21558
  if (!modelUsage) return void 0;
@@ -24775,10 +24791,24 @@ function createClaudeAdapter(recipe, host, options) {
24775
24791
  }
24776
24792
  return context;
24777
24793
  };
24794
+ const withProcessGeneration = (session, context) => ({
24795
+ ...session,
24796
+ ...context.origin.originBindingGeneration === void 0 ? {} : { bindingGeneration: context.origin.originBindingGeneration }
24797
+ });
24778
24798
  const reconfigureSession = async (context, input, desired) => {
24779
24799
  const resumeTarget = readClaudeResumeState(input.resumeCursor)?.resume;
24780
- 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;
24781
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
+ }
24782
24812
  return void 0;
24783
24813
  }
24784
24814
  if (context.currentApiModelId !== desired.apiModelId) {
@@ -24825,10 +24855,7 @@ function createClaudeAdapter(recipe, host, options) {
24825
24855
  },
24826
24856
  providerRefs: {}
24827
24857
  });
24828
- return {
24829
- ...context.session,
24830
- ...context.origin.originBindingGeneration === void 0 ? {} : { bindingGeneration: context.origin.originBindingGeneration }
24831
- };
24858
+ return withProcessGeneration(context.session, context);
24832
24859
  };
24833
24860
  const startSession = async (input) => {
24834
24861
  const extraArgs = parseCliArgs(recipe.launchArgs).flags;
@@ -24862,6 +24889,29 @@ function createClaudeAdapter(recipe, host, options) {
24862
24889
  ultracode,
24863
24890
  autoCompactWindow: recipe.autoCompactWindow
24864
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
+ };
24865
24915
  const existingContext = sessions.get(input.threadId);
24866
24916
  if (existingContext) {
24867
24917
  const reconfigured = await reconfigureSession(existingContext, input, {
@@ -24870,7 +24920,8 @@ function createClaudeAdapter(recipe, host, options) {
24870
24920
  ...effectiveEffort ? { effectiveEffort } : {},
24871
24921
  ...initialContextWindow !== void 0 ? { contextWindow: initialContextWindow } : {},
24872
24922
  ...modelSelection?.model ? { model: modelSelection.model } : {},
24873
- settings
24923
+ settings,
24924
+ spawnEnvironment
24874
24925
  });
24875
24926
  if (reconfigured) {
24876
24927
  return reconfigured;
@@ -25187,31 +25238,11 @@ function createClaudeAdapter(recipe, host, options) {
25187
25238
  const onUserDialog = (request, callbackOptions) => handleResumeDialog(request, callbackOptions);
25188
25239
  const additionalDirectories = input.cwd ? [input.cwd] : [];
25189
25240
  const mcpServers = toClaudeMcpServers(input.mcpServers);
25190
- const homeLayout = resolveClaudeLaunchHome({
25191
- homePath: recipe.homePath,
25192
- credentialsPath: recipe.credentialsPath,
25193
- launchProcessEnv: input.launch.processEnv,
25194
- pluginDataDirPath: options?.pluginDataDirPath,
25195
- environment: claudeHomeEnvironment,
25196
- ...options?.log === void 0 ? {} : { log: options.log }
25197
- });
25198
25241
  await materializeClaudeRoutedHome(homeLayout, {
25199
25242
  ...input.cwd ? { trustedPaths: [input.cwd] } : {},
25200
25243
  ...options?.log === void 0 ? {} : { log: options.log }
25201
25244
  });
25202
- const launchEnvironment = mergeLaunchEnv2({
25203
- brainSlots: brainSlotEnvKeys3(CLAUDE_CARD),
25204
- inherited: { ...process.env, ...options?.environment },
25205
- instanceTable: recipe.environment,
25206
- handOverrides: claudeHomeVariables(homeLayout),
25207
- launch: input.launch.processEnv
25208
- });
25209
- const envOverride = routedEnvOverride({
25210
- launchProcessEnv: input.launch.processEnv,
25211
- mergedEnv: launchEnvironment,
25212
- ...recipe.customModels === void 0 ? {} : { customModels: recipe.customModels }
25213
- });
25214
- const querySettings = envOverride === void 0 ? { ...settings } : { ...settings, env: envOverride };
25245
+ const querySettings = spawnEnvironment.settingsEnv === void 0 ? { ...settings } : { ...settings, env: { ...spawnEnvironment.settingsEnv } };
25215
25246
  const stderrTail = createOutputTail(CLAUDE_STDERR_TAIL_CHARS);
25216
25247
  const queryOptions = {
25217
25248
  ...input.cwd ? { cwd: input.cwd } : {},
@@ -25246,7 +25277,7 @@ function createClaudeAdapter(recipe, host, options) {
25246
25277
  ]
25247
25278
  },
25248
25279
  supportedDialogKinds: ["resume_return"],
25249
- env: compactEnv(launchEnvironment),
25280
+ env: { ...spawnEnvironment.processEnv },
25250
25281
  additionalDirectories,
25251
25282
  ...Object.keys(extraArgs).length > 0 ? { extraArgs } : {},
25252
25283
  ...mcpServers === void 0 ? {} : { mcpServers }
@@ -25294,6 +25325,7 @@ function createClaudeAdapter(recipe, host, options) {
25294
25325
  currentApiModelId: apiModelId,
25295
25326
  currentEffort: effectiveEffort ?? void 0,
25296
25327
  launchEffort: effectiveEffort ?? void 0,
25328
+ spawnEnvironment,
25297
25329
  currentSettings: settings,
25298
25330
  interruptSettled: void 0,
25299
25331
  resumeSessionId: sessionId,
@@ -25370,7 +25402,7 @@ function createClaudeAdapter(recipe, host, options) {
25370
25402
  cause: cause instanceof Error ? cause.message : String(cause)
25371
25403
  });
25372
25404
  });
25373
- return { ...session };
25405
+ return withProcessGeneration(session, context);
25374
25406
  };
25375
25407
  const compactContext = async (threadId) => {
25376
25408
  const context = requireSession(threadId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-claude",
3
- "version": "0.2.2130",
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.2130"
26
+ "@ycodium-ai/plugin-api": "0.2.2143"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",