@openacp/cli 2026.404.1 → 2026.404.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.
@@ -35,8 +35,9 @@ interface TurnRouting {
35
35
  }
36
36
  /**
37
37
  * Create a new TurnContext. Called when a prompt is dequeued from the queue.
38
+ * If a pre-generated turnId is provided (from enqueuePrompt), it is used; otherwise a new one is generated.
38
39
  */
39
- declare function createTurnContext(sourceAdapterId: string, responseAdapterId?: string | null): TurnContext;
40
+ declare function createTurnContext(sourceAdapterId: string, responseAdapterId?: string | null, turnId?: string): TurnContext;
40
41
  /**
41
42
  * Get the effective response adapter for a turn.
42
43
  * - null → silent (no adapter renders)
package/dist/cli.js CHANGED
@@ -7818,7 +7818,9 @@ var init_sse_manager = __esm({
7818
7818
  "session:updated",
7819
7819
  "session:deleted",
7820
7820
  "agent:event",
7821
- "permission:request"
7821
+ "permission:request",
7822
+ "message:queued",
7823
+ "message:processing"
7822
7824
  ];
7823
7825
  for (const eventName of events) {
7824
7826
  const handler = (data) => {
@@ -7883,7 +7885,9 @@ data: ${JSON.stringify(data)}
7883
7885
  const sessionEvents = [
7884
7886
  "agent:event",
7885
7887
  "permission:request",
7886
- "session:updated"
7888
+ "session:updated",
7889
+ "message:queued",
7890
+ "message:processing"
7887
7891
  ];
7888
7892
  for (const res of this.sseConnections) {
7889
7893
  const filter = res.sessionFilter;
@@ -19396,21 +19400,21 @@ var init_prompt_queue = __esm({
19396
19400
  queue = [];
19397
19401
  processing = false;
19398
19402
  abortController = null;
19399
- async enqueue(text6, attachments, routing) {
19403
+ async enqueue(text6, attachments, routing, turnId) {
19400
19404
  if (this.processing) {
19401
19405
  return new Promise((resolve8) => {
19402
- this.queue.push({ text: text6, attachments, routing, resolve: resolve8 });
19406
+ this.queue.push({ text: text6, attachments, routing, turnId, resolve: resolve8 });
19403
19407
  });
19404
19408
  }
19405
- await this.process(text6, attachments, routing);
19409
+ await this.process(text6, attachments, routing, turnId);
19406
19410
  }
19407
- async process(text6, attachments, routing) {
19411
+ async process(text6, attachments, routing, turnId) {
19408
19412
  this.processing = true;
19409
19413
  this.abortController = new AbortController();
19410
19414
  const { signal } = this.abortController;
19411
19415
  try {
19412
19416
  await Promise.race([
19413
- this.processor(text6, attachments, routing),
19417
+ this.processor(text6, attachments, routing, turnId),
19414
19418
  new Promise((_, reject) => {
19415
19419
  signal.addEventListener("abort", () => reject(new Error("Prompt aborted")), { once: true });
19416
19420
  })
@@ -19428,7 +19432,7 @@ var init_prompt_queue = __esm({
19428
19432
  drainNext() {
19429
19433
  const next = this.queue.shift();
19430
19434
  if (next) {
19431
- this.process(next.text, next.attachments, next.routing).then(next.resolve);
19435
+ this.process(next.text, next.attachments, next.routing, next.turnId).then(next.resolve);
19432
19436
  }
19433
19437
  }
19434
19438
  clear() {
@@ -19525,9 +19529,9 @@ var init_permission_gate = __esm({
19525
19529
 
19526
19530
  // src/core/sessions/turn-context.ts
19527
19531
  import { nanoid as nanoid3 } from "nanoid";
19528
- function createTurnContext(sourceAdapterId, responseAdapterId) {
19532
+ function createTurnContext(sourceAdapterId, responseAdapterId, turnId) {
19529
19533
  return {
19530
- turnId: nanoid3(8),
19534
+ turnId: turnId ?? nanoid3(8),
19531
19535
  sourceAdapterId,
19532
19536
  responseAdapterId
19533
19537
  };
@@ -19636,7 +19640,7 @@ Additionally, include a [TTS]...[/TTS] block with a spoken-friendly summary of y
19636
19640
  this.log = createSessionLogger(this.id, moduleLog);
19637
19641
  this.log.info({ agentName: this.agentName }, "Session created");
19638
19642
  this.queue = new PromptQueue(
19639
- (text6, attachments, routing) => this.processPrompt(text6, attachments, routing),
19643
+ (text6, attachments, routing, turnId) => this.processPrompt(text6, attachments, routing, turnId),
19640
19644
  (err) => {
19641
19645
  this.log.error({ err }, "Prompt execution failed");
19642
19646
  const message = err instanceof Error ? err.message : String(err);
@@ -19711,22 +19715,26 @@ Additionally, include a [TTS]...[/TTS] block with a spoken-friendly summary of y
19711
19715
  this.log.info({ voiceMode: mode }, "TTS mode changed");
19712
19716
  }
19713
19717
  // --- Public API ---
19714
- async enqueuePrompt(text6, attachments, routing) {
19718
+ async enqueuePrompt(text6, attachments, routing, externalTurnId) {
19719
+ const turnId = externalTurnId ?? nanoid4(8);
19715
19720
  if (this.middlewareChain) {
19716
19721
  const payload = { text: text6, attachments, sessionId: this.id };
19717
19722
  const result = await this.middlewareChain.execute("agent:beforePrompt", payload, async (p2) => p2);
19718
- if (!result) return;
19723
+ if (!result) return turnId;
19719
19724
  text6 = result.text;
19720
19725
  attachments = result.attachments;
19721
19726
  }
19722
- await this.queue.enqueue(text6, attachments, routing);
19727
+ await this.queue.enqueue(text6, attachments, routing, turnId);
19728
+ return turnId;
19723
19729
  }
19724
- async processPrompt(text6, attachments, routing) {
19730
+ async processPrompt(text6, attachments, routing, turnId) {
19725
19731
  if (this._status === "finished") return;
19726
19732
  this.activeTurnContext = createTurnContext(
19727
19733
  routing?.sourceAdapterId ?? this.channelId,
19728
- routing?.responseAdapterId
19734
+ routing?.responseAdapterId,
19735
+ turnId
19729
19736
  );
19737
+ this.emit("turn_started", this.activeTurnContext);
19730
19738
  this.promptCount++;
19731
19739
  this.emit("prompt_count_changed", this.promptCount);
19732
19740
  if (this._status === "initializing" || this._status === "cancelled" || this._status === "error") {
@@ -20415,6 +20423,16 @@ var init_session_bridge = __esm({
20415
20423
  this.listen(this.session, "prompt_count_changed", (count) => {
20416
20424
  this.deps.sessionManager.patchRecord(this.session.id, { currentPromptCount: count });
20417
20425
  });
20426
+ this.listen(this.session, "turn_started", (ctx) => {
20427
+ if (ctx.sourceAdapterId !== "sse" && ctx.sourceAdapterId !== "api") {
20428
+ this.deps.eventBus?.emit("message:processing", {
20429
+ sessionId: this.session.id,
20430
+ turnId: ctx.turnId,
20431
+ sourceAdapterId: ctx.sourceAdapterId,
20432
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
20433
+ });
20434
+ }
20435
+ });
20418
20436
  if (this.session.latestCommands !== null) {
20419
20437
  this.session.emit("agent_event", { type: "commands_update", commands: this.session.latestCommands });
20420
20438
  }
@@ -23393,6 +23411,7 @@ var init_core_items = __esm({
23393
23411
  // src/core/core.ts
23394
23412
  import path52 from "path";
23395
23413
  import os23 from "os";
23414
+ import { nanoid as nanoid5 } from "nanoid";
23396
23415
  var log40, OpenACPCore;
23397
23416
  var init_core = __esm({
23398
23417
  "src/core/core.ts"() {
@@ -23702,7 +23721,22 @@ User message:
23702
23721
  ${text6}`;
23703
23722
  }
23704
23723
  }
23705
- await session.enqueuePrompt(text6, message.attachments, message.routing);
23724
+ const sourceAdapterId = message.routing?.sourceAdapterId ?? message.channelId;
23725
+ if (sourceAdapterId && sourceAdapterId !== "sse" && sourceAdapterId !== "api") {
23726
+ const turnId = nanoid5(8);
23727
+ this.eventBus.emit("message:queued", {
23728
+ sessionId: session.id,
23729
+ turnId,
23730
+ text: text6,
23731
+ sourceAdapterId,
23732
+ attachments: message.attachments,
23733
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
23734
+ queueDepth: session.queueDepth
23735
+ });
23736
+ await session.enqueuePrompt(text6, message.attachments, message.routing, turnId);
23737
+ } else {
23738
+ await session.enqueuePrompt(text6, message.attachments, message.routing);
23739
+ }
23706
23740
  }
23707
23741
  // --- Unified Session Creation Pipeline ---
23708
23742
  async createSession(params) {