@ycodium-ai/agent-claude 0.2.3976 → 0.2.3982

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 +13 -55
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import * as NodePath20 from "node:path";
3
3
  import { definePlugin } from "@ycodium-ai/plugin-api";
4
4
 
5
5
  // ../../packages/plugin-api/src/version.ts
6
- var PLUGIN_API_VERSION = 75;
6
+ var PLUGIN_API_VERSION = 76;
7
7
 
8
8
  // src/index.ts
9
9
  import {
@@ -23927,8 +23927,8 @@ var makeEventEmitter = (deps) => {
23927
23927
  threadId: context.session.threadId
23928
23928
  });
23929
23929
  const offerRuntimeEvent = (context, event) => {
23930
- deps.push({
23931
- ...context?.origin,
23930
+ context.events.emit({
23931
+ ...context.origin,
23932
23932
  ...event
23933
23933
  });
23934
23934
  };
@@ -24632,9 +24632,7 @@ var makeSdkStream = (deps) => {
24632
24632
  } else if (context.turnState) {
24633
24633
  await completeTurn(context, "interrupted", "Claude runtime stream ended.");
24634
24634
  }
24635
- await stopSessionInternal(context, {
24636
- emitExitEvent: true
24637
- });
24635
+ await stopSessionInternal(context);
24638
24636
  };
24639
24637
  return { runSdkStream };
24640
24638
  };
@@ -25912,7 +25910,7 @@ var makeSessionLifecycle = (deps) => {
25912
25910
  clearTimeout(timer);
25913
25911
  }
25914
25912
  };
25915
- const stopSessionInternal = async (context, stopOptions) => {
25913
+ const stopSessionInternal = async (context) => {
25916
25914
  if (context.stopWork) {
25917
25915
  await context.stopWork;
25918
25916
  return;
@@ -25987,7 +25985,7 @@ var makeSessionLifecycle = (deps) => {
25987
25985
  status: "closed",
25988
25986
  updatedAt
25989
25987
  };
25990
- if (stopOptions?.emitExitEvent !== false && sessions.get(context.session.threadId) === context) {
25988
+ if (sessions.get(context.session.threadId) === context) {
25991
25989
  const stamp = await makeEventStamp();
25992
25990
  offerRuntimeEvent(context, {
25993
25991
  type: "session.exited",
@@ -26022,7 +26020,7 @@ var makeSessionLifecycle = (deps) => {
26022
26020
  };
26023
26021
  const withProcessGeneration = (session, context) => ({
26024
26022
  ...session,
26025
- ...context.origin.originBindingGeneration === void 0 ? {} : { bindingGeneration: context.origin.originBindingGeneration }
26023
+ ...context.bindingGeneration === void 0 ? {} : { bindingGeneration: context.bindingGeneration }
26026
26024
  });
26027
26025
  const reconfigureSession = async (context, input, desired) => {
26028
26026
  const resumeTarget = readClaudeResumeState(input.resumeCursor)?.resume;
@@ -26253,7 +26251,7 @@ var makeStartSession = (deps) => {
26253
26251
  existingSessionStatus: existingContext.session.status,
26254
26252
  reason: "startSession called with existing active session"
26255
26253
  });
26256
- await stopSessionInternal(existingContext, { emitExitEvent: false });
26254
+ await stopSessionInternal(existingContext);
26257
26255
  }
26258
26256
  const startedAt = nowIso();
26259
26257
  const resumeState = input.discardResumeCursor === true ? void 0 : readClaudeResumeState(input.resumeCursor);
@@ -26414,10 +26412,9 @@ var makeStartSession = (deps) => {
26414
26412
  };
26415
26413
  const context = {
26416
26414
  session,
26417
- origin: {
26418
- ...input.bindingGeneration === void 0 ? {} : { originBindingGeneration: input.bindingGeneration },
26419
- ...input.resumeCursor === void 0 ? {} : { originResumeCursor: input.resumeCursor }
26420
- },
26415
+ events: input.events,
26416
+ bindingGeneration: input.bindingGeneration,
26417
+ origin: input.resumeCursor === void 0 ? {} : { originResumeCursor: input.resumeCursor },
26421
26418
  promptQueue,
26422
26419
  query: queryRuntime,
26423
26420
  cliProcess,
@@ -27950,40 +27947,6 @@ function claudeSignInCommand(credentialsPath, platform4) {
27950
27947
  return withClaudeCredentialsDir({ command, credentialsDirPath, platform: platform4 });
27951
27948
  }
27952
27949
 
27953
- // src/events.ts
27954
- var EventBus = class {
27955
- #queued = [];
27956
- #waiters = [];
27957
- #closed = false;
27958
- push(event) {
27959
- const waiter = this.#waiters.shift();
27960
- if (waiter) {
27961
- waiter({ done: false, value: event });
27962
- return;
27963
- }
27964
- this.#queued.push(event);
27965
- }
27966
- close() {
27967
- if (this.#closed) return;
27968
- this.#closed = true;
27969
- while (this.#waiters.length > 0) {
27970
- this.#waiters.shift()?.({ done: true, value: void 0 });
27971
- }
27972
- }
27973
- [Symbol.asyncIterator]() {
27974
- return {
27975
- next: () => {
27976
- const queued = this.#queued.shift();
27977
- if (queued !== void 0) return Promise.resolve({ done: false, value: queued });
27978
- if (this.#closed) return Promise.resolve({ done: true, value: void 0 });
27979
- return new Promise((resolve6) => {
27980
- this.#waiters.push(resolve6);
27981
- });
27982
- }
27983
- };
27984
- }
27985
- };
27986
-
27987
27950
  // src/textGeneration.ts
27988
27951
  import * as NodeFSP7 from "node:fs/promises";
27989
27952
  import * as NodeOS8 from "node:os";
@@ -29300,11 +29263,9 @@ function createClaudeAdapter(recipe, host, options) {
29300
29263
  });
29301
29264
  const currentModelCatalog = modelCatalog.current;
29302
29265
  const declaredModels = [CLAUDE_CARD.defaultModel];
29303
- const runtimeEventQueue = new EventBus();
29304
29266
  const emitter = makeEventEmitter({
29305
29267
  now,
29306
- randomId: options?.randomId ?? (() => crypto.randomUUID()),
29307
- push: (event) => runtimeEventQueue.push(event)
29268
+ randomId: options?.randomId ?? (() => crypto.randomUUID())
29308
29269
  });
29309
29270
  const { nowIso } = emitter;
29310
29271
  const {
@@ -29432,7 +29393,7 @@ function createClaudeAdapter(recipe, host, options) {
29432
29393
  const stopSession = async (threadId) => {
29433
29394
  const context = sessions.get(threadId);
29434
29395
  if (!context) return;
29435
- await stopSessionInternal(context, { emitExitEvent: true });
29396
+ await stopSessionInternal(context);
29436
29397
  };
29437
29398
  return {
29438
29399
  /** 型号目录:探测用它读并拿当前这份;会话内部自己走同一份。 */
@@ -29456,12 +29417,10 @@ function createClaudeAdapter(recipe, host, options) {
29456
29417
  setNativeMode,
29457
29418
  stopSession,
29458
29419
  openCommandProcesses: async (threadId) => openCommandsOf(sessions.get(threadId)),
29459
- events: runtimeEventQueue,
29460
29420
  dispose: async () => {
29461
29421
  const results = await Promise.allSettled(
29462
29422
  [...sessions.values()].map((ctx) => stopSessionInternal(ctx))
29463
29423
  );
29464
- runtimeEventQueue.close();
29465
29424
  const failures = results.flatMap(
29466
29425
  (result) => result.status === "rejected" ? [result.reason] : []
29467
29426
  );
@@ -29534,7 +29493,6 @@ function createClaudeInstance(config, host, attachments, overrides, usageCache)
29534
29493
  stopSession: adapter.stopSession,
29535
29494
  openCommandProcesses: adapter.openCommandProcesses,
29536
29495
  readThread: adapter.readThread,
29537
- events: adapter.events,
29538
29496
  dispose: adapter.dispose,
29539
29497
  // 项目里的命令与技能:探测没有工作区,只能报用户配置目录那份;这里按目录扫。
29540
29498
  workspaceInventory: ({ cwd }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-claude",
3
- "version": "0.2.3976",
3
+ "version": "0.2.3982",
4
4
  "description": "Claude executor: Claude Code CLI via @anthropic-ai/claude-agent-sdk.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -24,10 +24,10 @@
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.3976",
28
- "ycodium-jsonl-stream": "0.0.0",
27
+ "@ycodium-ai/plugin-api": "0.2.3982",
28
+ "ycodium-composer-tokens": "0.0.0",
29
29
  "ycodium-executor-testing": "0.0.0",
30
- "ycodium-composer-tokens": "0.0.0"
30
+ "ycodium-jsonl-stream": "0.0.0"
31
31
  },
32
32
  "ycodium": {
33
33
  "plugin": "./dist/index.js",