@ycodium-ai/agent-claude 0.2.3851 → 0.2.3908

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 (3) hide show
  1. package/README.md +5 -2
  2. package/dist/index.js +51 -121
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -15,8 +15,11 @@ Facts:
15
15
  - Isolation is `CLAUDE_CONFIG_DIR` and, when set, `CLAUDE_SECURESTORAGE_CONFIG_DIR`.
16
16
  `HOME` is never overridden (macOS keychain lookup lives under `$HOME`).
17
17
  - Manifest permission is `{ kind: "executor" }`.
18
- - `SessionStart` reports `session_id` and `transcript_path` through
19
- `thread.metadata.updated.payload.nativeHistory`. The host persists this location on the
18
+ - `UserPromptSubmit` and `SessionStart` report the main session's `session_id` and
19
+ `transcript_path` through `thread.metadata.updated.payload.nativeHistory`, once per path.
20
+ SDK sessions do not call back `SessionStart` on startup or resume (Claude Code 2.1.312),
21
+ so the first prompt of each process records the location; calls carrying `agent_id`
22
+ come from a subagent and are ignored. The host persists this location on the
20
23
  owning session binding and supplies `parentTranscriptPath` to `sessions.openHistory`.
21
24
  The reader derives the subagent path from that transcript and checks its native session
22
25
  and workspace metadata. Bindings without a saved location use the configured projects
package/dist/index.js CHANGED
@@ -22912,25 +22912,6 @@ function readClaudeToolUseResult(message) {
22912
22912
  const result = message.tool_use_result;
22913
22913
  return result !== null && typeof result === "object" && !Array.isArray(result) ? result : void 0;
22914
22914
  }
22915
- function imageBlocksFromToolResult(block) {
22916
- if (!block || typeof block !== "object") return [];
22917
- const content = block.content;
22918
- if (!Array.isArray(content)) return [];
22919
- const images = [];
22920
- for (const entry of content) {
22921
- if (!entry || typeof entry !== "object") continue;
22922
- const candidate = entry;
22923
- if (candidate.type !== "image") continue;
22924
- const source = candidate.source;
22925
- if (!source || typeof source !== "object") continue;
22926
- const typedSource = source;
22927
- if (typedSource.type !== "base64" || typeof typedSource.media_type !== "string" || typeof typedSource.data !== "string" || typedSource.data.length === 0) {
22928
- continue;
22929
- }
22930
- images.push({ mimeType: typedSource.media_type, base64: typedSource.data });
22931
- }
22932
- return images;
22933
- }
22934
22915
  function extractExitPlanModePlan(value) {
22935
22916
  if (!value || typeof value !== "object") {
22936
22917
  return void 0;
@@ -23181,49 +23162,6 @@ function describeUnknownSdkMessage(kind, message) {
23181
23162
  return preview ? `${kind} \u2014 ${preview}` : `${kind} (no displayable text content)`;
23182
23163
  }
23183
23164
 
23184
- // src/imageMime.ts
23185
- var IMAGE_EXTENSION_BY_MIME_TYPE = {
23186
- "image/avif": ".avif",
23187
- "image/bmp": ".bmp",
23188
- "image/gif": ".gif",
23189
- "image/heic": ".heic",
23190
- "image/heif": ".heif",
23191
- "image/jpeg": ".jpg",
23192
- "image/jpg": ".jpg",
23193
- "image/png": ".png",
23194
- "image/svg+xml": ".svg",
23195
- "image/tiff": ".tiff",
23196
- "image/webp": ".webp"
23197
- };
23198
- var SAFE_IMAGE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
23199
- ".avif",
23200
- ".bmp",
23201
- ".gif",
23202
- ".heic",
23203
- ".heif",
23204
- ".ico",
23205
- ".jpeg",
23206
- ".jpg",
23207
- ".png",
23208
- ".svg",
23209
- ".tiff",
23210
- ".webp"
23211
- ]);
23212
- function inferImageExtension(input) {
23213
- const key = input.mimeType.toLowerCase();
23214
- const fromMime = Object.hasOwn(IMAGE_EXTENSION_BY_MIME_TYPE, key) ? IMAGE_EXTENSION_BY_MIME_TYPE[key] : void 0;
23215
- if (fromMime) {
23216
- return fromMime;
23217
- }
23218
- const fileName = input.fileName?.trim() ?? "";
23219
- const extensionMatch = /\.([a-z0-9]{1,8})$/i.exec(fileName);
23220
- const fileNameExtension = extensionMatch ? `.${extensionMatch[1].toLowerCase()}` : "";
23221
- if (SAFE_IMAGE_FILE_EXTENSIONS.has(fileNameExtension)) {
23222
- return fileNameExtension;
23223
- }
23224
- return ".bin";
23225
- }
23226
-
23227
23165
  // src/types.ts
23228
23166
  var PROVIDER = "claudeAgent";
23229
23167
  var PromptQueue = class {
@@ -23370,19 +23308,6 @@ async function buildUserMessageFromTurn(input) {
23370
23308
  }
23371
23309
  return buildUserMessage({ sdkContent });
23372
23310
  }
23373
- async function persistProducedImage(input) {
23374
- if (!input.attachmentsApi) return null;
23375
- try {
23376
- return await input.attachmentsApi.store({
23377
- threadId: input.threadId,
23378
- name: `image${inferImageExtension({ mimeType: input.mimeType })}`,
23379
- mimeType: input.mimeType,
23380
- bytes: input.bytes
23381
- });
23382
- } catch {
23383
- return null;
23384
- }
23385
- }
23386
23311
 
23387
23312
  // src/adapter/assistantText.ts
23388
23313
  var makeAssistantText = (emitter) => {
@@ -25460,29 +25385,40 @@ var makeSessionCallbacks = (deps) => {
25460
25385
  }
25461
25386
  return {};
25462
25387
  };
25388
+ const isNewMainTranscript = (context, hookInput) => hookInput.agent_id === void 0 && hookInput.session_id === context.resumeSessionId && typeof hookInput.transcript_path === "string" && hookInput.transcript_path.length > 0 && hookInput.transcript_path !== context.reportedTranscriptPath;
25389
+ const reportTranscriptPath = async (context, hookInput) => {
25390
+ context.reportedTranscriptPath = hookInput.transcript_path;
25391
+ const stamp = await makeEventStamp();
25392
+ if (context.stopped || context.stopping) return;
25393
+ offerRuntimeEvent(context, {
25394
+ type: "thread.metadata.updated",
25395
+ ...eventHeader(context, stamp),
25396
+ payload: {
25397
+ nativeHistory: {
25398
+ nativeSessionId: hookInput.session_id,
25399
+ transcriptPath: hookInput.transcript_path
25400
+ }
25401
+ },
25402
+ providerRefs: {}
25403
+ });
25404
+ };
25405
+ const handleUserPromptSubmit = async (hookInput) => {
25406
+ sessionContext ??= await waitSessionContext();
25407
+ const context = sessionContext;
25408
+ if (context && !context.stopped && !context.stopping && isNewMainTranscript(context, hookInput))
25409
+ await reportTranscriptPath(context, hookInput);
25410
+ return {};
25411
+ };
25463
25412
  const handleSessionStart = async (hookInput) => {
25464
25413
  sessionContext ??= await waitSessionContext();
25465
25414
  const context = sessionContext;
25466
25415
  if (!context || context.stopped || context.stopping) return {};
25467
- if (hookInput.session_id === context.resumeSessionId && typeof hookInput.transcript_path === "string" && hookInput.transcript_path.length > 0 && hookInput.transcript_path !== context.reportedTranscriptPath) {
25468
- context.reportedTranscriptPath = hookInput.transcript_path;
25469
- const stamp = await makeEventStamp();
25416
+ if (isNewMainTranscript(context, hookInput)) {
25417
+ await reportTranscriptPath(context, hookInput);
25470
25418
  if (context.stopped || context.stopping) return {};
25471
- offerRuntimeEvent(context, {
25472
- type: "thread.metadata.updated",
25473
- ...eventHeader(context, stamp),
25474
- payload: {
25475
- nativeHistory: {
25476
- nativeSessionId: hookInput.session_id,
25477
- transcriptPath: hookInput.transcript_path
25478
- }
25479
- },
25480
- providerRefs: {}
25481
- });
25482
25419
  }
25483
25420
  if (hookInput.source !== "compact" || session.contextAfterCompaction === void 0) return {};
25484
- sessionContext ??= context;
25485
- const compactionId = sessionContext?.compaction?.compactionId;
25421
+ const compactionId = context.compaction?.compactionId;
25486
25422
  if (compactionId === void 0) return {};
25487
25423
  const signal = AbortSignal.timeout(CONTEXT_AFTER_COMPACTION_TIMEOUT_MS);
25488
25424
  const aborted = Promise.withResolvers();
@@ -25776,7 +25712,14 @@ var makeSessionCallbacks = (deps) => {
25776
25712
  });
25777
25713
  };
25778
25714
  const onUserDialog = (request, callbackOptions) => handleResumeDialog(request, callbackOptions);
25779
- return { canUseTool, onUserDialog, handlePostCompact, handlePreCompact, handleSessionStart };
25715
+ return {
25716
+ canUseTool,
25717
+ onUserDialog,
25718
+ handlePostCompact,
25719
+ handlePreCompact,
25720
+ handleSessionStart,
25721
+ handleUserPromptSubmit
25722
+ };
25780
25723
  };
25781
25724
  return { forSession };
25782
25725
  };
@@ -26338,7 +26281,14 @@ var makeStartSession = (deps) => {
26338
26281
  if (timer !== void 0) clearTimeout(timer);
26339
26282
  }
26340
26283
  };
26341
- const { canUseTool, onUserDialog, handlePostCompact, handlePreCompact, handleSessionStart } = sessionCallbacks.forSession({
26284
+ const {
26285
+ canUseTool,
26286
+ onUserDialog,
26287
+ handlePostCompact,
26288
+ handlePreCompact,
26289
+ handleSessionStart,
26290
+ handleUserPromptSubmit
26291
+ } = sessionCallbacks.forSession({
26342
26292
  waitSessionContext,
26343
26293
  pendingApprovals,
26344
26294
  pendingUserInputs,
@@ -26403,6 +26353,13 @@ var makeStartSession = (deps) => {
26403
26353
  ]
26404
26354
  }
26405
26355
  ],
26356
+ UserPromptSubmit: [
26357
+ {
26358
+ hooks: [
26359
+ async (hookInput) => hookInput.hook_event_name === "UserPromptSubmit" ? handleUserPromptSubmit(hookInput) : {}
26360
+ ]
26361
+ }
26362
+ ],
26406
26363
  PostCompact: [
26407
26364
  {
26408
26365
  hooks: [
@@ -27758,32 +27715,6 @@ var makeTurnMessageHandlers = (deps) => {
27758
27715
  payload: message
27759
27716
  }
27760
27717
  });
27761
- const producedImages = imageBlocksFromToolResult(toolResult.block);
27762
- if (producedImages.length > 0) {
27763
- const persisted = [];
27764
- for (const image of producedImages) {
27765
- persisted.push(
27766
- await persistProducedImage({
27767
- attachmentsApi: deps.attachments,
27768
- threadId: context.session.threadId,
27769
- mimeType: image.mimeType,
27770
- bytes: Buffer.from(image.base64, "base64")
27771
- })
27772
- );
27773
- }
27774
- const attachments = persisted.filter((entry) => entry !== null);
27775
- if (attachments.length > 0) {
27776
- const attachmentStamp = await makeEventStamp();
27777
- offerRuntimeEvent(context, {
27778
- type: "assistant.attachment.produced",
27779
- ...eventHeader(context, attachmentStamp),
27780
- ...context.turnState ? { turnId: asCanonicalTurnId(context.turnState.turnId) } : {},
27781
- itemId: asRuntimeItemId(tool.itemId),
27782
- payload: { attachments },
27783
- providerRefs: nativeProviderRefs({ providerItemId: tool.itemId })
27784
- });
27785
- }
27786
- }
27787
27718
  const streamKind = toolResultStreamKind(tool.itemType);
27788
27719
  if (streamKind && toolResult.text.length > 0 && context.turnState) {
27789
27720
  const deltaStamp = await makeEventStamp();
@@ -29403,7 +29334,6 @@ function createClaudeAdapter(recipe, host, options) {
29403
29334
  log: options?.log ?? host.log,
29404
29335
  now,
29405
29336
  buildLaunchEnvironment,
29406
- attachments: options?.attachments,
29407
29337
  emitRuntimeError,
29408
29338
  emitProposedPlanCompleted,
29409
29339
  emitClaudeTaskPlanUpdated,
@@ -29680,7 +29610,7 @@ var executors = [
29680
29610
  ];
29681
29611
  var index_default = definePlugin({
29682
29612
  id: "agent-claude",
29683
- apiVersion: 63,
29613
+ apiVersion: 67,
29684
29614
  executors,
29685
29615
  activate(ctx) {
29686
29616
  ctx.command({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-claude",
3
- "version": "0.2.3851",
3
+ "version": "0.2.3908",
4
4
  "description": "Claude executor: Claude Code CLI via @anthropic-ai/claude-agent-sdk.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -24,8 +24,8 @@
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.3851",
28
27
  "ycodium-composer-tokens": "0.0.0",
28
+ "@ycodium-ai/plugin-api": "0.2.3908",
29
29
  "ycodium-executor-testing": "0.0.0",
30
30
  "ycodium-jsonl-stream": "0.0.0"
31
31
  },