@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.
- package/dist/{channel-CmTWKnpK.d.ts → channel-DQWwxUKX.d.ts} +2 -1
- package/dist/cli.js +51 -17
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +21 -5
- package/dist/index.js +53 -19
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Attachment, O as OutgoingMessage, I as IChannelAdapter, N as NotificationMessage, a as AgentEvent, S as StopReason, P as PermissionRequest, U as UsageRecord, b as AgentCapabilities, c as AgentDefinition, M as McpServerConfig, d as SetConfigOptionValue, e as InstalledAgent, R as RegistryAgent, f as AgentListItem, g as AvailabilityResult, h as InstallProgress, i as InstallResult, j as SessionStatus, C as ConfigOption, k as AgentSwitchEntry, l as AgentCommand,
|
|
2
|
-
export { v as AgentDistribution, w as AuthMethod, x as AuthenticateRequest, y as ChannelAdapter, z as ConfigSelectChoice, B as ConfigSelectGroup, E as ContentBlock, K as KIND_ICONS, F as ModelInfo, G as NewSessionResponse, H as PermissionOption, J as PromptResponse, L as RegistryBinaryTarget, Q as RegistryDistribution, W as STATUS_ICONS, X as SessionListItem, Y as SessionListResponse, Z as SessionMode, _ as SessionModeState, $ as SessionModelState, a0 as TelegramPlatformData, a1 as ToolUpdateMeta, a2 as createTurnContext, a3 as getEffectiveTarget, a4 as isSystemEvent } from './channel-
|
|
1
|
+
import { A as Attachment, O as OutgoingMessage, I as IChannelAdapter, N as NotificationMessage, a as AgentEvent, S as StopReason, P as PermissionRequest, U as UsageRecord, b as AgentCapabilities, c as AgentDefinition, M as McpServerConfig, d as SetConfigOptionValue, e as InstalledAgent, R as RegistryAgent, f as AgentListItem, g as AvailabilityResult, h as InstallProgress, i as InstallResult, j as SessionStatus, T as TurnContext, C as ConfigOption, k as AgentSwitchEntry, l as AgentCommand, m as TurnRouting, n as SessionRecord, o as UsageRecordEvent, p as IncomingMessage, D as DisplayVerbosity, q as ChannelConfig, r as AdapterCapabilities, s as ToolCallMeta, V as ViewerLinks, t as OutputMode, u as PlanEntry } from './channel-DQWwxUKX.js';
|
|
2
|
+
export { v as AgentDistribution, w as AuthMethod, x as AuthenticateRequest, y as ChannelAdapter, z as ConfigSelectChoice, B as ConfigSelectGroup, E as ContentBlock, K as KIND_ICONS, F as ModelInfo, G as NewSessionResponse, H as PermissionOption, J as PromptResponse, L as RegistryBinaryTarget, Q as RegistryDistribution, W as STATUS_ICONS, X as SessionListItem, Y as SessionListResponse, Z as SessionMode, _ as SessionModeState, $ as SessionModelState, a0 as TelegramPlatformData, a1 as ToolUpdateMeta, a2 as createTurnContext, a3 as getEffectiveTarget, a4 as isSystemEvent } from './channel-DQWwxUKX.js';
|
|
3
3
|
import pino from 'pino';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { ZodSchema, z } from 'zod';
|
|
@@ -1424,6 +1424,7 @@ interface SessionEvents {
|
|
|
1424
1424
|
named: (name: string) => void;
|
|
1425
1425
|
error: (error: Error) => void;
|
|
1426
1426
|
prompt_count_changed: (count: number) => void;
|
|
1427
|
+
turn_started: (ctx: TurnContext) => void;
|
|
1427
1428
|
}
|
|
1428
1429
|
declare class Session extends TypedEmitter<SessionEvents> {
|
|
1429
1430
|
id: string;
|
|
@@ -1491,7 +1492,7 @@ declare class Session extends TypedEmitter<SessionEvents> {
|
|
|
1491
1492
|
get promptRunning(): boolean;
|
|
1492
1493
|
setContext(markdown: string): void;
|
|
1493
1494
|
setVoiceMode(mode: "off" | "next" | "on"): void;
|
|
1494
|
-
enqueuePrompt(text: string, attachments?: Attachment[], routing?: TurnRouting): Promise<
|
|
1495
|
+
enqueuePrompt(text: string, attachments?: Attachment[], routing?: TurnRouting, externalTurnId?: string): Promise<string>;
|
|
1495
1496
|
private processPrompt;
|
|
1496
1497
|
private maybeTranscribeAudio;
|
|
1497
1498
|
private processTTSResponse;
|
|
@@ -1537,8 +1538,8 @@ declare class PromptQueue {
|
|
|
1537
1538
|
private queue;
|
|
1538
1539
|
private processing;
|
|
1539
1540
|
private abortController;
|
|
1540
|
-
constructor(processor: (text: string, attachments?: Attachment[], routing?: TurnRouting) => Promise<void>, onError?: ((err: unknown) => void) | undefined);
|
|
1541
|
-
enqueue(text: string, attachments?: Attachment[], routing?: TurnRouting): Promise<void>;
|
|
1541
|
+
constructor(processor: (text: string, attachments?: Attachment[], routing?: TurnRouting, turnId?: string) => Promise<void>, onError?: ((err: unknown) => void) | undefined);
|
|
1542
|
+
enqueue(text: string, attachments?: Attachment[], routing?: TurnRouting, turnId?: string): Promise<void>;
|
|
1542
1543
|
private process;
|
|
1543
1544
|
private drainNext;
|
|
1544
1545
|
clear(): void;
|
|
@@ -1651,6 +1652,21 @@ interface EventBusEvents {
|
|
|
1651
1652
|
"session:configChanged": (data: {
|
|
1652
1653
|
sessionId: string;
|
|
1653
1654
|
}) => void;
|
|
1655
|
+
"message:queued": (data: {
|
|
1656
|
+
sessionId: string;
|
|
1657
|
+
turnId: string;
|
|
1658
|
+
text: string;
|
|
1659
|
+
sourceAdapterId: string;
|
|
1660
|
+
attachments?: unknown[];
|
|
1661
|
+
timestamp: string;
|
|
1662
|
+
queueDepth: number;
|
|
1663
|
+
}) => void;
|
|
1664
|
+
"message:processing": (data: {
|
|
1665
|
+
sessionId: string;
|
|
1666
|
+
turnId: string;
|
|
1667
|
+
sourceAdapterId: string;
|
|
1668
|
+
timestamp: string;
|
|
1669
|
+
}) => void;
|
|
1654
1670
|
"session:agentSwitch": (data: {
|
|
1655
1671
|
sessionId: string;
|
|
1656
1672
|
fromAgent: string;
|
package/dist/index.js
CHANGED
|
@@ -3474,7 +3474,9 @@ var init_sse_manager = __esm({
|
|
|
3474
3474
|
"session:updated",
|
|
3475
3475
|
"session:deleted",
|
|
3476
3476
|
"agent:event",
|
|
3477
|
-
"permission:request"
|
|
3477
|
+
"permission:request",
|
|
3478
|
+
"message:queued",
|
|
3479
|
+
"message:processing"
|
|
3478
3480
|
];
|
|
3479
3481
|
for (const eventName of events) {
|
|
3480
3482
|
const handler = (data) => {
|
|
@@ -3539,7 +3541,9 @@ data: ${JSON.stringify(data)}
|
|
|
3539
3541
|
const sessionEvents = [
|
|
3540
3542
|
"agent:event",
|
|
3541
3543
|
"permission:request",
|
|
3542
|
-
"session:updated"
|
|
3544
|
+
"session:updated",
|
|
3545
|
+
"message:queued",
|
|
3546
|
+
"message:processing"
|
|
3543
3547
|
];
|
|
3544
3548
|
for (const res of this.sseConnections) {
|
|
3545
3549
|
const filter = res.sessionFilter;
|
|
@@ -8362,7 +8366,7 @@ var init_commands = __esm({
|
|
|
8362
8366
|
|
|
8363
8367
|
// src/plugins/telegram/permissions.ts
|
|
8364
8368
|
import { InlineKeyboard as InlineKeyboard11 } from "grammy";
|
|
8365
|
-
import { nanoid as
|
|
8369
|
+
import { nanoid as nanoid4 } from "nanoid";
|
|
8366
8370
|
var log30, PermissionHandler;
|
|
8367
8371
|
var init_permissions = __esm({
|
|
8368
8372
|
"src/plugins/telegram/permissions.ts"() {
|
|
@@ -8381,7 +8385,7 @@ var init_permissions = __esm({
|
|
|
8381
8385
|
pending = /* @__PURE__ */ new Map();
|
|
8382
8386
|
async sendPermissionRequest(session, request) {
|
|
8383
8387
|
const threadId = Number(session.threadId);
|
|
8384
|
-
const callbackKey =
|
|
8388
|
+
const callbackKey = nanoid4(8);
|
|
8385
8389
|
this.pending.set(callbackKey, {
|
|
8386
8390
|
sessionId: session.id,
|
|
8387
8391
|
requestId: request.id,
|
|
@@ -11669,21 +11673,21 @@ var PromptQueue = class {
|
|
|
11669
11673
|
queue = [];
|
|
11670
11674
|
processing = false;
|
|
11671
11675
|
abortController = null;
|
|
11672
|
-
async enqueue(text3, attachments, routing) {
|
|
11676
|
+
async enqueue(text3, attachments, routing, turnId) {
|
|
11673
11677
|
if (this.processing) {
|
|
11674
11678
|
return new Promise((resolve6) => {
|
|
11675
|
-
this.queue.push({ text: text3, attachments, routing, resolve: resolve6 });
|
|
11679
|
+
this.queue.push({ text: text3, attachments, routing, turnId, resolve: resolve6 });
|
|
11676
11680
|
});
|
|
11677
11681
|
}
|
|
11678
|
-
await this.process(text3, attachments, routing);
|
|
11682
|
+
await this.process(text3, attachments, routing, turnId);
|
|
11679
11683
|
}
|
|
11680
|
-
async process(text3, attachments, routing) {
|
|
11684
|
+
async process(text3, attachments, routing, turnId) {
|
|
11681
11685
|
this.processing = true;
|
|
11682
11686
|
this.abortController = new AbortController();
|
|
11683
11687
|
const { signal } = this.abortController;
|
|
11684
11688
|
try {
|
|
11685
11689
|
await Promise.race([
|
|
11686
|
-
this.processor(text3, attachments, routing),
|
|
11690
|
+
this.processor(text3, attachments, routing, turnId),
|
|
11687
11691
|
new Promise((_, reject) => {
|
|
11688
11692
|
signal.addEventListener("abort", () => reject(new Error("Prompt aborted")), { once: true });
|
|
11689
11693
|
})
|
|
@@ -11701,7 +11705,7 @@ var PromptQueue = class {
|
|
|
11701
11705
|
drainNext() {
|
|
11702
11706
|
const next = this.queue.shift();
|
|
11703
11707
|
if (next) {
|
|
11704
|
-
this.process(next.text, next.attachments, next.routing).then(next.resolve);
|
|
11708
|
+
this.process(next.text, next.attachments, next.routing, next.turnId).then(next.resolve);
|
|
11705
11709
|
}
|
|
11706
11710
|
}
|
|
11707
11711
|
clear() {
|
|
@@ -11794,9 +11798,9 @@ import * as fs10 from "fs";
|
|
|
11794
11798
|
|
|
11795
11799
|
// src/core/sessions/turn-context.ts
|
|
11796
11800
|
import { nanoid } from "nanoid";
|
|
11797
|
-
function createTurnContext(sourceAdapterId, responseAdapterId) {
|
|
11801
|
+
function createTurnContext(sourceAdapterId, responseAdapterId, turnId) {
|
|
11798
11802
|
return {
|
|
11799
|
-
turnId: nanoid(8),
|
|
11803
|
+
turnId: turnId ?? nanoid(8),
|
|
11800
11804
|
sourceAdapterId,
|
|
11801
11805
|
responseAdapterId
|
|
11802
11806
|
};
|
|
@@ -11888,7 +11892,7 @@ var Session = class extends TypedEmitter {
|
|
|
11888
11892
|
this.log = createSessionLogger(this.id, moduleLog);
|
|
11889
11893
|
this.log.info({ agentName: this.agentName }, "Session created");
|
|
11890
11894
|
this.queue = new PromptQueue(
|
|
11891
|
-
(text3, attachments, routing) => this.processPrompt(text3, attachments, routing),
|
|
11895
|
+
(text3, attachments, routing, turnId) => this.processPrompt(text3, attachments, routing, turnId),
|
|
11892
11896
|
(err) => {
|
|
11893
11897
|
this.log.error({ err }, "Prompt execution failed");
|
|
11894
11898
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -11963,22 +11967,26 @@ var Session = class extends TypedEmitter {
|
|
|
11963
11967
|
this.log.info({ voiceMode: mode }, "TTS mode changed");
|
|
11964
11968
|
}
|
|
11965
11969
|
// --- Public API ---
|
|
11966
|
-
async enqueuePrompt(text3, attachments, routing) {
|
|
11970
|
+
async enqueuePrompt(text3, attachments, routing, externalTurnId) {
|
|
11971
|
+
const turnId = externalTurnId ?? nanoid2(8);
|
|
11967
11972
|
if (this.middlewareChain) {
|
|
11968
11973
|
const payload = { text: text3, attachments, sessionId: this.id };
|
|
11969
11974
|
const result = await this.middlewareChain.execute("agent:beforePrompt", payload, async (p) => p);
|
|
11970
|
-
if (!result) return;
|
|
11975
|
+
if (!result) return turnId;
|
|
11971
11976
|
text3 = result.text;
|
|
11972
11977
|
attachments = result.attachments;
|
|
11973
11978
|
}
|
|
11974
|
-
await this.queue.enqueue(text3, attachments, routing);
|
|
11979
|
+
await this.queue.enqueue(text3, attachments, routing, turnId);
|
|
11980
|
+
return turnId;
|
|
11975
11981
|
}
|
|
11976
|
-
async processPrompt(text3, attachments, routing) {
|
|
11982
|
+
async processPrompt(text3, attachments, routing, turnId) {
|
|
11977
11983
|
if (this._status === "finished") return;
|
|
11978
11984
|
this.activeTurnContext = createTurnContext(
|
|
11979
11985
|
routing?.sourceAdapterId ?? this.channelId,
|
|
11980
|
-
routing?.responseAdapterId
|
|
11986
|
+
routing?.responseAdapterId,
|
|
11987
|
+
turnId
|
|
11981
11988
|
);
|
|
11989
|
+
this.emit("turn_started", this.activeTurnContext);
|
|
11982
11990
|
this.promptCount++;
|
|
11983
11991
|
this.emit("prompt_count_changed", this.promptCount);
|
|
11984
11992
|
if (this._status === "initializing" || this._status === "cancelled" || this._status === "error") {
|
|
@@ -13063,6 +13071,16 @@ var SessionBridge = class {
|
|
|
13063
13071
|
this.listen(this.session, "prompt_count_changed", (count) => {
|
|
13064
13072
|
this.deps.sessionManager.patchRecord(this.session.id, { currentPromptCount: count });
|
|
13065
13073
|
});
|
|
13074
|
+
this.listen(this.session, "turn_started", (ctx) => {
|
|
13075
|
+
if (ctx.sourceAdapterId !== "sse" && ctx.sourceAdapterId !== "api") {
|
|
13076
|
+
this.deps.eventBus?.emit("message:processing", {
|
|
13077
|
+
sessionId: this.session.id,
|
|
13078
|
+
turnId: ctx.turnId,
|
|
13079
|
+
sourceAdapterId: ctx.sourceAdapterId,
|
|
13080
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
13081
|
+
});
|
|
13082
|
+
}
|
|
13083
|
+
});
|
|
13066
13084
|
if (this.session.latestCommands !== null) {
|
|
13067
13085
|
this.session.emit("agent_event", { type: "commands_update", commands: this.session.latestCommands });
|
|
13068
13086
|
}
|
|
@@ -13716,6 +13734,7 @@ var SessionFactory = class {
|
|
|
13716
13734
|
// src/core/core.ts
|
|
13717
13735
|
import path17 from "path";
|
|
13718
13736
|
import os8 from "os";
|
|
13737
|
+
import { nanoid as nanoid3 } from "nanoid";
|
|
13719
13738
|
|
|
13720
13739
|
// src/core/sessions/session-store.ts
|
|
13721
13740
|
init_log();
|
|
@@ -15759,7 +15778,22 @@ User message:
|
|
|
15759
15778
|
${text3}`;
|
|
15760
15779
|
}
|
|
15761
15780
|
}
|
|
15762
|
-
|
|
15781
|
+
const sourceAdapterId = message.routing?.sourceAdapterId ?? message.channelId;
|
|
15782
|
+
if (sourceAdapterId && sourceAdapterId !== "sse" && sourceAdapterId !== "api") {
|
|
15783
|
+
const turnId = nanoid3(8);
|
|
15784
|
+
this.eventBus.emit("message:queued", {
|
|
15785
|
+
sessionId: session.id,
|
|
15786
|
+
turnId,
|
|
15787
|
+
text: text3,
|
|
15788
|
+
sourceAdapterId,
|
|
15789
|
+
attachments: message.attachments,
|
|
15790
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15791
|
+
queueDepth: session.queueDepth
|
|
15792
|
+
});
|
|
15793
|
+
await session.enqueuePrompt(text3, message.attachments, message.routing, turnId);
|
|
15794
|
+
} else {
|
|
15795
|
+
await session.enqueuePrompt(text3, message.attachments, message.routing);
|
|
15796
|
+
}
|
|
15763
15797
|
}
|
|
15764
15798
|
// --- Unified Session Creation Pipeline ---
|
|
15765
15799
|
async createSession(params) {
|