@ycodium-ai/agent-codex 0.2.3976 → 0.2.3990

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 +36 -45
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { definePlugin } from "@ycodium-ai/plugin-api";
3
3
 
4
4
  // ../../packages/plugin-api/src/version.ts
5
- var PLUGIN_API_VERSION = 75;
5
+ var PLUGIN_API_VERSION = 77;
6
6
 
7
7
  // src/index.ts
8
8
  import {
@@ -3258,7 +3258,12 @@ function mapCollabAgentEvent(input) {
3258
3258
  baseEvent({
3259
3259
  type: "task.updated",
3260
3260
  threadId,
3261
- payload: { taskId: agentThreadId, status, ...linkage },
3261
+ payload: {
3262
+ taskId: agentThreadId,
3263
+ status,
3264
+ ...input.params["outcomeUnknown"] === true ? { outcomeUnknown: true } : {},
3265
+ ...linkage
3266
+ },
3262
3267
  method,
3263
3268
  providerInstanceId: input.providerInstanceId
3264
3269
  })
@@ -4702,14 +4707,24 @@ var CodexBackgroundCommands = class {
4702
4707
  }
4703
4708
  return events;
4704
4709
  }
4710
+ /** 进程异常退出不能确认后台命令已结束,只收口本代观察。 */
4711
+ settleSessionEnded(outcomeUnknown, method) {
4712
+ const closed = [...this.#commands].filter(([, command]) => command.background);
4713
+ this.#commands.clear();
4714
+ return closed.map(
4715
+ ([id, command]) => outcomeUnknown ? baseEvent({
4716
+ type: "task.updated",
4717
+ threadId: this.#threadId,
4718
+ turnId: command.turnId,
4719
+ providerInstanceId: this.#providerInstanceId,
4720
+ payload: { taskId: id, status: "idle", outcomeUnknown: true }
4721
+ }) : this.#completed(id, command.turnId, "stopped", method)
4722
+ );
4723
+ }
4705
4724
  /** 跟着通知走,返回要补发的 task 事件;放在该通知本身的事件之后发。 */
4706
4725
  observe(method, params) {
4707
4726
  if (method === "turn/completed") return this.#settleTurn(method, params);
4708
- if (method === "thread/closed") {
4709
- const closed = [...this.#commands].filter(([, command2]) => command2.background);
4710
- this.#commands.clear();
4711
- return closed.map(([id2, command2]) => this.#completed(id2, command2.turnId, "stopped", method));
4712
- }
4727
+ if (method === "thread/closed") return this.settleSessionEnded(false, method);
4713
4728
  if (!isRecord2(params) || !isRecord2(params["item"])) return [];
4714
4729
  const item = params["item"];
4715
4730
  const id = item["id"];
@@ -4935,6 +4950,16 @@ var CodexSessionCollab = class {
4935
4950
  constructor(runtime) {
4936
4951
  this.runtime = runtime;
4937
4952
  }
4953
+ /** 父进程结束只收口本代观察;没有子线程终态时不能断言外部任务已结束。 */
4954
+ settleSessionEnded() {
4955
+ for (const child of this.runtime.collabChildren.values()) {
4956
+ this.metaOf(child.agentThreadId).closed = true;
4957
+ if (child.status !== "running") continue;
4958
+ child.status = "idle";
4959
+ this.emitCollab("collabAgent/statusChanged", child, { status: "idle", outcomeUnknown: true });
4960
+ }
4961
+ this.runtime.liveForeignTurns.clear();
4962
+ }
4938
4963
  interceptCollab(method, params, conversationId) {
4939
4964
  const thread = isRecord2(params) && isRecord2(params["thread"]) ? params["thread"] : void 0;
4940
4965
  const source = thread === void 0 ? void 0 : thread["source"];
@@ -5872,44 +5897,13 @@ var CodexSessionRuntime = class {
5872
5897
  this.host.log.warn("codex output drain timed out", { threadId: this.threadId });
5873
5898
  }
5874
5899
  });
5900
+ for (const event of this.#background.settleSessionEnded(reason === "process"))
5901
+ this.emit(event);
5902
+ this.#collab.settleSessionEnded();
5875
5903
  });
5876
5904
  }
5877
5905
  };
5878
5906
 
5879
- // src/eventBus.ts
5880
- var EventBus = class {
5881
- #queued = [];
5882
- #waiters = [];
5883
- #closed = false;
5884
- push(event) {
5885
- const waiter = this.#waiters.shift();
5886
- if (waiter) {
5887
- waiter({ done: false, value: event });
5888
- return;
5889
- }
5890
- this.#queued.push(event);
5891
- }
5892
- close() {
5893
- if (this.#closed) return;
5894
- this.#closed = true;
5895
- while (this.#waiters.length > 0) {
5896
- this.#waiters.shift()?.({ done: true, value: void 0 });
5897
- }
5898
- }
5899
- [Symbol.asyncIterator]() {
5900
- return {
5901
- next: () => {
5902
- const queued = this.#queued.shift();
5903
- if (queued !== void 0) return Promise.resolve({ done: false, value: queued });
5904
- if (this.#closed) return Promise.resolve({ done: true, value: void 0 });
5905
- return new Promise((resolve4) => {
5906
- this.#waiters.push(resolve4);
5907
- });
5908
- }
5909
- };
5910
- }
5911
- };
5912
-
5913
5907
  // src/mcpOAuth.ts
5914
5908
  function codexMcpOAuthLaunchConfig(name, transport) {
5915
5909
  const key = `mcp_servers.${name}`;
@@ -7536,7 +7530,6 @@ function layoutFor(recipe) {
7536
7530
  }
7537
7531
  var createCodexInstance = (config, host, attachments, cache) => {
7538
7532
  const recipe = parseCodexInstanceConfig(config);
7539
- const events = new EventBus();
7540
7533
  const threads = /* @__PURE__ */ new Map();
7541
7534
  const signInOperations = /* @__PURE__ */ new Map();
7542
7535
  const live = /* @__PURE__ */ new Map();
@@ -7767,7 +7760,7 @@ var createCodexInstance = (config, host, attachments, cache) => {
7767
7760
  runtime = new CodexSessionRuntime(
7768
7761
  host,
7769
7762
  rpc,
7770
- (event) => events.push(event),
7763
+ input.events.emit,
7771
7764
  input,
7772
7765
  cwd,
7773
7766
  args,
@@ -7845,7 +7838,6 @@ var createCodexInstance = (config, host, attachments, cache) => {
7845
7838
  const booked = requireThread(threadId);
7846
7839
  return await booked.runtime.readThread();
7847
7840
  },
7848
- events,
7849
7841
  dispose: () => {
7850
7842
  if (disposeTask) return disposeTask;
7851
7843
  disposed = true;
@@ -7860,7 +7852,6 @@ var createCodexInstance = (config, host, attachments, cache) => {
7860
7852
  for (const result of await closing) {
7861
7853
  if (result.status === "rejected") throw result.reason;
7862
7854
  }
7863
- events.close();
7864
7855
  })();
7865
7856
  return disposeTask;
7866
7857
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-codex",
3
- "version": "0.2.3976",
3
+ "version": "0.2.3990",
4
4
  "description": "Codex executor: Codex CLI over the app-server JSON-RPC protocol.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -29,9 +29,9 @@
29
29
  "tailwindcss": "^4.0.0",
30
30
  "typescript": "~6.0.3",
31
31
  "vite-plus": "0.2.2",
32
- "@ycodium-ai/plugin-api": "0.2.3976",
33
- "ycodium-jsonl-stream": "0.0.0",
34
- "ycodium-executor-testing": "0.0.0"
32
+ "@ycodium-ai/plugin-api": "0.2.3990",
33
+ "ycodium-executor-testing": "0.0.0",
34
+ "ycodium-jsonl-stream": "0.0.0"
35
35
  },
36
36
  "ycodium": {
37
37
  "plugin": "./dist/index.js",