@alas-ide/codex-acp 2.1.1-alas.1 → 2.1.1-alas.2

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 +60 -2
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -33523,7 +33523,7 @@ var package_default = {
33523
33523
  publishConfig: {
33524
33524
  access: "public"
33525
33525
  },
33526
- version: "2.1.1-alas.1",
33526
+ version: "2.1.1-alas.2",
33527
33527
  description: "",
33528
33528
  main: "dist/index.js",
33529
33529
  bin: {
@@ -33559,6 +33559,7 @@ var package_default = {
33559
33559
  "generate-types": "./node_modules/.bin/codex app-server generate-ts --out src/app-server",
33560
33560
  "release:preflight": "bash scripts/release-preflight.sh",
33561
33561
  test: "vitest run --no-file-parallelism --retry=2",
33562
+ "test:maintenance": "vitest run --no-file-parallelism scripts/*.test.mjs",
33562
33563
  "test:e2e": "npm run build && RUN_E2E_TESTS=true vitest run --no-file-parallelism --retry=2 src/__tests__/CodexACPAgent/e2e",
33563
33564
  "test:watch": "vitest",
33564
33565
  typecheck: "tsc --noEmit && tsc --noEmit -p examples/tsconfig.json",
@@ -33597,7 +33598,7 @@ var package_default = {
33597
33598
  alasDownstream: {
33598
33599
  upstreamVersion: "2.1.1",
33599
33600
  upstreamCommit: "68d7d2d5ddfc0ed5746f9f6130892dda685e65dd",
33600
- sourceCommit: "4461c5be6a2c567b60f27039ee5ba18c63ba0959"
33601
+ sourceCommit: "6f9ea3170aab4f0a4172456b509a2d11ec4ed905"
33601
33602
  }
33602
33603
  };
33603
33604
 
@@ -38394,6 +38395,7 @@ var CodexAcpServer = class {
38394
38395
  if (!sessionState) {
38395
38396
  throw RequestError.invalidParams(void 0, `Unknown session: ${methodRequest.params.sessionId}`);
38396
38397
  }
38398
+ await this.ensureSessionEventSubscription(sessionState);
38397
38399
  const sessionGeneration = this.getSessionGeneration(sessionState.sessionId);
38398
38400
  const goalControlGeneration = this.bumpGoalControlGeneration(sessionState.sessionId);
38399
38401
  if (methodRequest.params.action === "set") {
@@ -39592,6 +39594,61 @@ Check ${configPath} and project .codex directories, especially their config.toml
39592
39594
  await this.startNewTurnFromExternalPrompt(params, "Steering");
39593
39595
  return { outcome: "startedNewTurn" };
39594
39596
  }
39597
+ /**
39598
+ * Subscribes a session that has not run a prompt yet to its app-server notifications.
39599
+ *
39600
+ * A prompt subscribes the thread and its handler keeps forwarding session-scoped
39601
+ * notifications after the prompt ends. Before the first prompt nothing is subscribed, so
39602
+ * goal control would drop the goal update and the goal turn app-server starts for it.
39603
+ * The next prompt replaces this handler.
39604
+ */
39605
+ ensureSessionEventSubscription(sessionState) {
39606
+ sessionState.eventSubscription ??= this.subscribeSessionEvents(sessionState).catch((error62) => {
39607
+ delete sessionState.eventSubscription;
39608
+ throw error62;
39609
+ });
39610
+ return sessionState.eventSubscription;
39611
+ }
39612
+ async subscribeSessionEvents(sessionState) {
39613
+ const eventHandler = new CodexEventHandler(
39614
+ this.connection,
39615
+ sessionState,
39616
+ clientSupportsTypedSessionFailures(this.clientCapabilities),
39617
+ this.sessionFailureEpoch,
39618
+ sessionState.subagents,
39619
+ (accountUpdated) => this.handleAccountUpdated(accountUpdated),
39620
+ false,
39621
+ clientSupportsCompaction(this.clientCapabilities),
39622
+ clientSupportsNotices(this.clientCapabilities)
39623
+ );
39624
+ const permissionContext = this.permissionLifecycleContext(sessionState).beginPrompt();
39625
+ const toolCallRenderer = new AcpToolCallRenderer(this.capabilities);
39626
+ const signal = new AbortController().signal;
39627
+ const approvalHandler = new CodexApprovalHandler(this.connection, permissionContext, signal, toolCallRenderer);
39628
+ const elicitationHandler = new CodexElicitationHandler(
39629
+ this.connection,
39630
+ permissionContext,
39631
+ this.clientCapabilities,
39632
+ signal,
39633
+ toolCallRenderer
39634
+ );
39635
+ const observeInteraction = async (event) => {
39636
+ permissionContext.handleNotification(event);
39637
+ await elicitationHandler.handleNotification(event);
39638
+ };
39639
+ await this.codexAcpClient.subscribeToSessionEvents(
39640
+ sessionState.sessionId,
39641
+ async (event) => {
39642
+ await observeInteraction(event);
39643
+ await eventHandler.handleSessionScopedNotification(event);
39644
+ },
39645
+ approvalHandler,
39646
+ elicitationHandler,
39647
+ clientSupportsSubagents(this.clientCapabilities),
39648
+ observeInteraction,
39649
+ (childThreadId) => eventHandler.waitForNativeSubagentSession(childThreadId)
39650
+ );
39651
+ }
39595
39652
  async startGoalContinuationIfCurrent(sessionState, sessionGeneration, goalControlGeneration, expectedGoal) {
39596
39653
  await this.startNewTurnFromExternalPrompt({
39597
39654
  sessionId: sessionState.sessionId,
@@ -40530,6 +40587,7 @@ Check ${configPath} and project .codex directories, especially their config.toml
40530
40587
  observeInteraction,
40531
40588
  (childThreadId) => promptEventHandler.waitForNativeSubagentSession(childThreadId)
40532
40589
  );
40590
+ sessionState.eventSubscription = Promise.resolve();
40533
40591
  if (activePrompt.signal.aborted) {
40534
40592
  return cancelledPromptResponse();
40535
40593
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.1.1-alas.1",
6
+ "version": "2.1.1-alas.2",
7
7
  "description": "",
8
8
  "main": "dist/index.js",
9
9
  "bin": {
@@ -39,6 +39,7 @@
39
39
  "generate-types": "./node_modules/.bin/codex app-server generate-ts --out src/app-server",
40
40
  "release:preflight": "bash scripts/release-preflight.sh",
41
41
  "test": "vitest run --no-file-parallelism --retry=2",
42
+ "test:maintenance": "vitest run --no-file-parallelism scripts/*.test.mjs",
42
43
  "test:e2e": "npm run build && RUN_E2E_TESTS=true vitest run --no-file-parallelism --retry=2 src/__tests__/CodexACPAgent/e2e",
43
44
  "test:watch": "vitest",
44
45
  "typecheck": "tsc --noEmit && tsc --noEmit -p examples/tsconfig.json",
@@ -77,6 +78,6 @@
77
78
  "alasDownstream": {
78
79
  "upstreamVersion": "2.1.1",
79
80
  "upstreamCommit": "68d7d2d5ddfc0ed5746f9f6130892dda685e65dd",
80
- "sourceCommit": "4461c5be6a2c567b60f27039ee5ba18c63ba0959"
81
+ "sourceCommit": "6f9ea3170aab4f0a4172456b509a2d11ec4ed905"
81
82
  }
82
83
  }