@ycodium-ai/agent-claude 0.2.2130 → 0.2.2167
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 +85 -36
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -73,7 +73,9 @@ var CLAUDE_CARD = {
|
|
|
73
73
|
// SDK 的 `setPermissionMode` 会话中途就能改,所以这一位也是真的。
|
|
74
74
|
nativeModeSwitch: true,
|
|
75
75
|
contextCompaction: "native",
|
|
76
|
-
turnSteering: true
|
|
76
|
+
turnSteering: true,
|
|
77
|
+
// 子代理、workflow 与其成员经 SDK 的 task_* 系统消息报成 task.*(claudeInstance.ts)。
|
|
78
|
+
reportsSpawnedAgents: true
|
|
77
79
|
},
|
|
78
80
|
credentialSources: [
|
|
79
81
|
{
|
|
@@ -21537,6 +21539,22 @@ function readClaudeSessionRecord(input) {
|
|
|
21537
21539
|
};
|
|
21538
21540
|
}
|
|
21539
21541
|
|
|
21542
|
+
// src/spawnEnvironment.ts
|
|
21543
|
+
function changedSpawnEnvironmentKeys(previous, next) {
|
|
21544
|
+
const settingsPresenceChanged = previous.settingsEnv === void 0 !== (next.settingsEnv === void 0);
|
|
21545
|
+
return [
|
|
21546
|
+
...changedKeys(previous.processEnv, next.processEnv),
|
|
21547
|
+
...settingsPresenceChanged ? ["settings.env"] : [],
|
|
21548
|
+
...changedKeys(previous.settingsEnv ?? {}, next.settingsEnv ?? {}).map(
|
|
21549
|
+
(key) => `settings.env.${key}`
|
|
21550
|
+
)
|
|
21551
|
+
];
|
|
21552
|
+
}
|
|
21553
|
+
function changedKeys(previous, next) {
|
|
21554
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(next)]);
|
|
21555
|
+
return [...keys].filter((key) => previous[key] !== next[key]).sort();
|
|
21556
|
+
}
|
|
21557
|
+
|
|
21540
21558
|
// src/usage.ts
|
|
21541
21559
|
function maxClaudeContextWindowFromModelUsage(modelUsage) {
|
|
21542
21560
|
if (!modelUsage) return void 0;
|
|
@@ -21674,6 +21692,11 @@ function compactBoundaryTokenUsageSnapshot(message, contextWindow, totalProcesse
|
|
|
21674
21692
|
}
|
|
21675
21693
|
|
|
21676
21694
|
// src/taskProgress.ts
|
|
21695
|
+
function claudeTaskRosterKind(input) {
|
|
21696
|
+
if (input.taskType === "local_workflow") return "workflow";
|
|
21697
|
+
if (input.subagentType !== void 0 && input.subagentType.trim().length > 0) return "subagent";
|
|
21698
|
+
return void 0;
|
|
21699
|
+
}
|
|
21677
21700
|
var PENDING_TASK_MODEL_CAP = 64;
|
|
21678
21701
|
function rememberPendingTaskModel(pending, parentToolUseId, model) {
|
|
21679
21702
|
pending.set(parentToolUseId, model);
|
|
@@ -21835,7 +21858,8 @@ function taskLinkageFor(agents, taskId) {
|
|
|
21835
21858
|
...agent.effort ? { effort: agent.effort } : {},
|
|
21836
21859
|
...agent.toolUseId ? { toolUseId: agent.toolUseId } : {},
|
|
21837
21860
|
...agent.workflowName ? { workflowName: agent.workflowName } : {},
|
|
21838
|
-
...agent.runHandles ? { runHandles: agent.runHandles } : {}
|
|
21861
|
+
...agent.runHandles ? { runHandles: agent.runHandles } : {},
|
|
21862
|
+
...agent.rosterKind ? { rosterKind: agent.rosterKind } : {}
|
|
21839
21863
|
};
|
|
21840
21864
|
}
|
|
21841
21865
|
var WORKFLOW_PHASE_CAP = 64;
|
|
@@ -24007,18 +24031,20 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24007
24031
|
...sessionUrl === void 0 ? {} : { sessionUrl }
|
|
24008
24032
|
};
|
|
24009
24033
|
const existing = context.taskAgents.get(workflowTaskId);
|
|
24034
|
+
const taskType = existing?.taskType ?? "local_workflow";
|
|
24010
24035
|
context.taskAgents.set(workflowTaskId, {
|
|
24011
24036
|
taskId: workflowTaskId,
|
|
24012
24037
|
toolUseId: existing?.toolUseId ?? tool.itemId,
|
|
24013
24038
|
description: existing?.description,
|
|
24014
24039
|
subagentType: existing?.subagentType,
|
|
24015
|
-
taskType
|
|
24040
|
+
taskType,
|
|
24016
24041
|
workflowName: existing?.workflowName,
|
|
24017
24042
|
skipTranscript: existing?.skipTranscript ?? false,
|
|
24018
24043
|
runHandles,
|
|
24019
24044
|
owningAgentId: existing?.owningAgentId,
|
|
24020
24045
|
model: existing?.model,
|
|
24021
|
-
effort: existing?.effort
|
|
24046
|
+
effort: existing?.effort,
|
|
24047
|
+
rosterKind: claudeTaskRosterKind({ taskType, subagentType: existing?.subagentType })
|
|
24022
24048
|
});
|
|
24023
24049
|
}
|
|
24024
24050
|
}
|
|
@@ -24156,7 +24182,8 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24156
24182
|
...entry.phaseIndex !== void 0 ? { phaseIndex: entry.phaseIndex } : {},
|
|
24157
24183
|
...entry.phaseTitle ? { phaseTitle: entry.phaseTitle } : {},
|
|
24158
24184
|
...entry.attempt !== void 0 ? { attempt: entry.attempt } : {},
|
|
24159
|
-
timelineBypass: true
|
|
24185
|
+
timelineBypass: true,
|
|
24186
|
+
rosterKind: "workflow_member"
|
|
24160
24187
|
}
|
|
24161
24188
|
});
|
|
24162
24189
|
}
|
|
@@ -24314,6 +24341,10 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24314
24341
|
const model = bufferedModel ?? trimmedString(launchInput?.model) ?? trimmedString(context.session.model ?? void 0);
|
|
24315
24342
|
const rawLaunchEffort = launchInput?.effort;
|
|
24316
24343
|
const effort = trimmedString(rawLaunchEffort) ?? (typeof rawLaunchEffort === "number" && Number.isFinite(rawLaunchEffort) ? String(rawLaunchEffort) : context.currentEffort);
|
|
24344
|
+
const rosterKind = claudeTaskRosterKind({
|
|
24345
|
+
taskType: message.task_type,
|
|
24346
|
+
subagentType: message.subagent_type
|
|
24347
|
+
});
|
|
24317
24348
|
context.taskAgents.set(message.task_id, {
|
|
24318
24349
|
taskId: message.task_id,
|
|
24319
24350
|
toolUseId: message.tool_use_id,
|
|
@@ -24325,7 +24356,8 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24325
24356
|
runHandles: context.taskAgents.get(message.task_id)?.runHandles,
|
|
24326
24357
|
owningAgentId,
|
|
24327
24358
|
model,
|
|
24328
|
-
effort
|
|
24359
|
+
effort,
|
|
24360
|
+
rosterKind
|
|
24329
24361
|
});
|
|
24330
24362
|
context.liveTaskIds.add(message.task_id);
|
|
24331
24363
|
offerRuntimeEvent(context, {
|
|
@@ -24341,7 +24373,8 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24341
24373
|
...model ? { model } : {},
|
|
24342
24374
|
...effort ? { effort } : {},
|
|
24343
24375
|
...message.tool_use_id ? { toolUseId: message.tool_use_id } : {},
|
|
24344
|
-
...message.workflow_name ? { workflowName: message.workflow_name } : {}
|
|
24376
|
+
...message.workflow_name ? { workflowName: message.workflow_name } : {},
|
|
24377
|
+
...rosterKind ? { rosterKind } : {}
|
|
24345
24378
|
}
|
|
24346
24379
|
});
|
|
24347
24380
|
return;
|
|
@@ -24775,10 +24808,24 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24775
24808
|
}
|
|
24776
24809
|
return context;
|
|
24777
24810
|
};
|
|
24811
|
+
const withProcessGeneration = (session, context) => ({
|
|
24812
|
+
...session,
|
|
24813
|
+
...context.origin.originBindingGeneration === void 0 ? {} : { bindingGeneration: context.origin.originBindingGeneration }
|
|
24814
|
+
});
|
|
24778
24815
|
const reconfigureSession = async (context, input, desired) => {
|
|
24779
24816
|
const resumeTarget = readClaudeResumeState(input.resumeCursor)?.resume;
|
|
24780
|
-
const
|
|
24817
|
+
const changedEnvironmentKeys = changedSpawnEnvironmentKeys(
|
|
24818
|
+
context.spawnEnvironment,
|
|
24819
|
+
desired.spawnEnvironment
|
|
24820
|
+
);
|
|
24821
|
+
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
24822
|
if (!reusable) {
|
|
24823
|
+
if (changedEnvironmentKeys.length > 0) {
|
|
24824
|
+
(options?.log ?? host.log).info("claude.session.environment-changed", {
|
|
24825
|
+
threadId: context.session.threadId,
|
|
24826
|
+
changedKeys: changedEnvironmentKeys
|
|
24827
|
+
});
|
|
24828
|
+
}
|
|
24782
24829
|
return void 0;
|
|
24783
24830
|
}
|
|
24784
24831
|
if (context.currentApiModelId !== desired.apiModelId) {
|
|
@@ -24825,10 +24872,7 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24825
24872
|
},
|
|
24826
24873
|
providerRefs: {}
|
|
24827
24874
|
});
|
|
24828
|
-
return
|
|
24829
|
-
...context.session,
|
|
24830
|
-
...context.origin.originBindingGeneration === void 0 ? {} : { bindingGeneration: context.origin.originBindingGeneration }
|
|
24831
|
-
};
|
|
24875
|
+
return withProcessGeneration(context.session, context);
|
|
24832
24876
|
};
|
|
24833
24877
|
const startSession = async (input) => {
|
|
24834
24878
|
const extraArgs = parseCliArgs(recipe.launchArgs).flags;
|
|
@@ -24862,6 +24906,29 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24862
24906
|
ultracode,
|
|
24863
24907
|
autoCompactWindow: recipe.autoCompactWindow
|
|
24864
24908
|
});
|
|
24909
|
+
const homeLayout = resolveClaudeLaunchHome({
|
|
24910
|
+
homePath: recipe.homePath,
|
|
24911
|
+
credentialsPath: recipe.credentialsPath,
|
|
24912
|
+
launchProcessEnv: input.launch.processEnv,
|
|
24913
|
+
pluginDataDirPath: options?.pluginDataDirPath,
|
|
24914
|
+
environment: claudeHomeEnvironment,
|
|
24915
|
+
...options?.log === void 0 ? {} : { log: options.log }
|
|
24916
|
+
});
|
|
24917
|
+
const launchEnvironment = mergeLaunchEnv2({
|
|
24918
|
+
brainSlots: brainSlotEnvKeys3(CLAUDE_CARD),
|
|
24919
|
+
inherited: { ...process.env, ...options?.environment },
|
|
24920
|
+
instanceTable: recipe.environment,
|
|
24921
|
+
handOverrides: claudeHomeVariables(homeLayout),
|
|
24922
|
+
launch: input.launch.processEnv
|
|
24923
|
+
});
|
|
24924
|
+
const spawnEnvironment = {
|
|
24925
|
+
processEnv: compactEnv(launchEnvironment),
|
|
24926
|
+
settingsEnv: routedEnvOverride({
|
|
24927
|
+
launchProcessEnv: input.launch.processEnv,
|
|
24928
|
+
mergedEnv: launchEnvironment,
|
|
24929
|
+
...recipe.customModels === void 0 ? {} : { customModels: recipe.customModels }
|
|
24930
|
+
})
|
|
24931
|
+
};
|
|
24865
24932
|
const existingContext = sessions.get(input.threadId);
|
|
24866
24933
|
if (existingContext) {
|
|
24867
24934
|
const reconfigured = await reconfigureSession(existingContext, input, {
|
|
@@ -24870,7 +24937,8 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
24870
24937
|
...effectiveEffort ? { effectiveEffort } : {},
|
|
24871
24938
|
...initialContextWindow !== void 0 ? { contextWindow: initialContextWindow } : {},
|
|
24872
24939
|
...modelSelection?.model ? { model: modelSelection.model } : {},
|
|
24873
|
-
settings
|
|
24940
|
+
settings,
|
|
24941
|
+
spawnEnvironment
|
|
24874
24942
|
});
|
|
24875
24943
|
if (reconfigured) {
|
|
24876
24944
|
return reconfigured;
|
|
@@ -25187,31 +25255,11 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
25187
25255
|
const onUserDialog = (request, callbackOptions) => handleResumeDialog(request, callbackOptions);
|
|
25188
25256
|
const additionalDirectories = input.cwd ? [input.cwd] : [];
|
|
25189
25257
|
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
25258
|
await materializeClaudeRoutedHome(homeLayout, {
|
|
25199
25259
|
...input.cwd ? { trustedPaths: [input.cwd] } : {},
|
|
25200
25260
|
...options?.log === void 0 ? {} : { log: options.log }
|
|
25201
25261
|
});
|
|
25202
|
-
const
|
|
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 };
|
|
25262
|
+
const querySettings = spawnEnvironment.settingsEnv === void 0 ? { ...settings } : { ...settings, env: { ...spawnEnvironment.settingsEnv } };
|
|
25215
25263
|
const stderrTail = createOutputTail(CLAUDE_STDERR_TAIL_CHARS);
|
|
25216
25264
|
const queryOptions = {
|
|
25217
25265
|
...input.cwd ? { cwd: input.cwd } : {},
|
|
@@ -25246,7 +25294,7 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
25246
25294
|
]
|
|
25247
25295
|
},
|
|
25248
25296
|
supportedDialogKinds: ["resume_return"],
|
|
25249
|
-
env:
|
|
25297
|
+
env: { ...spawnEnvironment.processEnv },
|
|
25250
25298
|
additionalDirectories,
|
|
25251
25299
|
...Object.keys(extraArgs).length > 0 ? { extraArgs } : {},
|
|
25252
25300
|
...mcpServers === void 0 ? {} : { mcpServers }
|
|
@@ -25294,6 +25342,7 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
25294
25342
|
currentApiModelId: apiModelId,
|
|
25295
25343
|
currentEffort: effectiveEffort ?? void 0,
|
|
25296
25344
|
launchEffort: effectiveEffort ?? void 0,
|
|
25345
|
+
spawnEnvironment,
|
|
25297
25346
|
currentSettings: settings,
|
|
25298
25347
|
interruptSettled: void 0,
|
|
25299
25348
|
resumeSessionId: sessionId,
|
|
@@ -25370,7 +25419,7 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
25370
25419
|
cause: cause instanceof Error ? cause.message : String(cause)
|
|
25371
25420
|
});
|
|
25372
25421
|
});
|
|
25373
|
-
return
|
|
25422
|
+
return withProcessGeneration(session, context);
|
|
25374
25423
|
};
|
|
25375
25424
|
const compactContext = async (threadId) => {
|
|
25376
25425
|
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.
|
|
3
|
+
"version": "0.2.2167",
|
|
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.
|
|
26
|
+
"@ycodium-ai/plugin-api": "0.2.2167"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|
|
29
29
|
"plugin": "./dist/index.js",
|