@openacp/cli 0.4.1 → 0.4.3
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/README.md +1 -1
- package/dist/{chunk-YD7ILGA6.js → chunk-GA26H6JY.js} +55 -96
- package/dist/chunk-GA26H6JY.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/{main-OUVYNLZN.js → main-3WJFOTNT.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-YD7ILGA6.js.map +0 -1
- /package/dist/{main-OUVYNLZN.js.map → main-3WJFOTNT.js.map} +0 -0
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ First run launches an [interactive setup wizard](docs/guide/getting-started.md)
|
|
|
57
57
|
| Command | Description |
|
|
58
58
|
|---------|-------------|
|
|
59
59
|
| `/new [agent] [workspace]` | Create a new session |
|
|
60
|
-
| `/
|
|
60
|
+
| `/newchat` | New session, same agent & workspace |
|
|
61
61
|
| `/cancel` | Cancel current session |
|
|
62
62
|
| `/status` | Show session or system status |
|
|
63
63
|
| `/agents` | List available agents |
|
|
@@ -2040,11 +2040,10 @@ function buildDeepLink(chatId, messageId) {
|
|
|
2040
2040
|
|
|
2041
2041
|
// src/adapters/telegram/commands.ts
|
|
2042
2042
|
import { InlineKeyboard } from "grammy";
|
|
2043
|
-
import { nanoid as nanoid2 } from "nanoid";
|
|
2044
2043
|
var log7 = createChildLogger({ module: "telegram-commands" });
|
|
2045
2044
|
function setupCommands(bot, core, chatId, assistant) {
|
|
2046
2045
|
bot.command("new", (ctx) => handleNew(ctx, core, chatId, assistant));
|
|
2047
|
-
bot.command("
|
|
2046
|
+
bot.command("newchat", (ctx) => handleNewChat(ctx, core, chatId));
|
|
2048
2047
|
bot.command("cancel", (ctx) => handleCancel(ctx, core, assistant));
|
|
2049
2048
|
bot.command("status", (ctx) => handleStatus(ctx, core));
|
|
2050
2049
|
bot.command("agents", (ctx) => handleAgents(ctx, core));
|
|
@@ -2056,7 +2055,7 @@ function setupCommands(bot, core, chatId, assistant) {
|
|
|
2056
2055
|
bot.command("update", (ctx) => handleUpdate(ctx, core));
|
|
2057
2056
|
}
|
|
2058
2057
|
function buildMenuKeyboard() {
|
|
2059
|
-
return new InlineKeyboard().text("\u{1F195} New Session", "m:new").text("\u{1F4AC} New Chat", "m:
|
|
2058
|
+
return new InlineKeyboard().text("\u{1F195} New Session", "m:new").text("\u{1F4AC} New Chat", "m:newchat").row().text("\u26D4 Cancel", "m:cancel").text("\u{1F4CA} Status", "m:status").row().text("\u{1F916} Agents", "m:agents").text("\u2753 Help", "m:help").row().text("\u{1F504} Restart", "m:restart").text("\u2B06\uFE0F Update", "m:update");
|
|
2060
2059
|
}
|
|
2061
2060
|
function setupMenuCallbacks(bot, core, chatId) {
|
|
2062
2061
|
bot.callbackQuery(/^m:/, async (ctx) => {
|
|
@@ -2069,7 +2068,7 @@ function setupMenuCallbacks(bot, core, chatId) {
|
|
|
2069
2068
|
case "m:new":
|
|
2070
2069
|
await handleNew(ctx, core, chatId);
|
|
2071
2070
|
break;
|
|
2072
|
-
case "m:
|
|
2071
|
+
case "m:newchat":
|
|
2073
2072
|
await handleNewChat(ctx, core, chatId);
|
|
2074
2073
|
break;
|
|
2075
2074
|
case "m:cancel":
|
|
@@ -2166,7 +2165,7 @@ async function handleNewChat(ctx, core, chatId) {
|
|
|
2166
2165
|
const threadId = ctx.message?.message_thread_id;
|
|
2167
2166
|
if (!threadId) {
|
|
2168
2167
|
await ctx.reply(
|
|
2169
|
-
"Use /
|
|
2168
|
+
"Use /newchat inside a session topic to inherit its config.",
|
|
2170
2169
|
{ parse_mode: "HTML" }
|
|
2171
2170
|
);
|
|
2172
2171
|
return;
|
|
@@ -2199,6 +2198,11 @@ async function handleNewChat(ctx, core, chatId) {
|
|
|
2199
2198
|
chatId,
|
|
2200
2199
|
topicName
|
|
2201
2200
|
);
|
|
2201
|
+
const topicLink = buildDeepLink(chatId, newThreadId);
|
|
2202
|
+
await ctx.reply(
|
|
2203
|
+
`\u2705 New chat created \u2192 <a href="${topicLink}">Open topic</a>`,
|
|
2204
|
+
{ parse_mode: "HTML" }
|
|
2205
|
+
);
|
|
2202
2206
|
await ctx.api.sendMessage(chatId, `\u23F3 Setting up session, please wait...`, {
|
|
2203
2207
|
message_thread_id: newThreadId,
|
|
2204
2208
|
parse_mode: "HTML"
|
|
@@ -2328,7 +2332,7 @@ async function handleHelp(ctx) {
|
|
|
2328
2332
|
`<b>OpenACP Commands:</b>
|
|
2329
2333
|
|
|
2330
2334
|
/new [agent] [workspace] \u2014 Create new session
|
|
2331
|
-
/
|
|
2335
|
+
/newchat \u2014 New chat, same agent & workspace
|
|
2332
2336
|
/cancel \u2014 Cancel current session
|
|
2333
2337
|
/status \u2014 Show session/system status
|
|
2334
2338
|
/agents \u2014 List available agents
|
|
@@ -2465,41 +2469,24 @@ async function handleDisableDangerous(ctx, core) {
|
|
|
2465
2469
|
function botFromCtx(ctx) {
|
|
2466
2470
|
return { api: ctx.api };
|
|
2467
2471
|
}
|
|
2468
|
-
var
|
|
2469
|
-
function
|
|
2470
|
-
const keyboard = new InlineKeyboard();
|
|
2472
|
+
var TELEGRAM_MSG_LIMIT = 4096;
|
|
2473
|
+
function buildSkillMessages(commands) {
|
|
2471
2474
|
const sorted = [...commands].sort((a, b) => a.name.localeCompare(b.name));
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
function clearSkillCallbacks(sessionId) {
|
|
2484
|
-
for (const [key, entry] of skillCallbackMap) {
|
|
2485
|
-
if (entry.sessionId === sessionId) {
|
|
2486
|
-
skillCallbackMap.delete(key);
|
|
2475
|
+
const header = "\u{1F6E0} <b>Available Skills</b>\n";
|
|
2476
|
+
const lines = sorted.map((c) => `<code>/${c.name}</code>`);
|
|
2477
|
+
const messages = [];
|
|
2478
|
+
let current = header;
|
|
2479
|
+
for (const line of lines) {
|
|
2480
|
+
const candidate = current + "\n" + line;
|
|
2481
|
+
if (candidate.length > TELEGRAM_MSG_LIMIT) {
|
|
2482
|
+
messages.push(current);
|
|
2483
|
+
current = line;
|
|
2484
|
+
} else {
|
|
2485
|
+
current = candidate;
|
|
2487
2486
|
}
|
|
2488
2487
|
}
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
bot.callbackQuery(/^s:/, async (ctx) => {
|
|
2492
|
-
try {
|
|
2493
|
-
await ctx.answerCallbackQuery();
|
|
2494
|
-
} catch {
|
|
2495
|
-
}
|
|
2496
|
-
const key = ctx.callbackQuery.data.slice(2);
|
|
2497
|
-
const entry = skillCallbackMap.get(key);
|
|
2498
|
-
if (!entry) return;
|
|
2499
|
-
const session = core.sessionManager.getSession(entry.sessionId);
|
|
2500
|
-
if (!session || session.status !== "active") return;
|
|
2501
|
-
await session.enqueuePrompt(`/${entry.commandName}`);
|
|
2502
|
-
});
|
|
2488
|
+
if (current) messages.push(current);
|
|
2489
|
+
return messages;
|
|
2503
2490
|
}
|
|
2504
2491
|
async function executeNewSession(bot, core, chatId, agentName, workspace) {
|
|
2505
2492
|
const threadId = await createSessionTopic(bot, chatId, "\u{1F504} New Session");
|
|
@@ -2539,7 +2526,7 @@ async function executeCancelSession(core, excludeSessionId) {
|
|
|
2539
2526
|
}
|
|
2540
2527
|
var STATIC_COMMANDS = [
|
|
2541
2528
|
{ command: "new", description: "Create new session" },
|
|
2542
|
-
{ command: "
|
|
2529
|
+
{ command: "newchat", description: "New chat, same agent & workspace" },
|
|
2543
2530
|
{ command: "cancel", description: "Cancel current session" },
|
|
2544
2531
|
{ command: "status", description: "Show status" },
|
|
2545
2532
|
{ command: "agents", description: "List available agents" },
|
|
@@ -2553,7 +2540,7 @@ var STATIC_COMMANDS = [
|
|
|
2553
2540
|
|
|
2554
2541
|
// src/adapters/telegram/permissions.ts
|
|
2555
2542
|
import { InlineKeyboard as InlineKeyboard2 } from "grammy";
|
|
2556
|
-
import { nanoid as
|
|
2543
|
+
import { nanoid as nanoid2 } from "nanoid";
|
|
2557
2544
|
var log8 = createChildLogger({ module: "telegram-permissions" });
|
|
2558
2545
|
var PermissionHandler = class {
|
|
2559
2546
|
constructor(bot, chatId, getSession, sendNotification) {
|
|
@@ -2565,7 +2552,7 @@ var PermissionHandler = class {
|
|
|
2565
2552
|
pending = /* @__PURE__ */ new Map();
|
|
2566
2553
|
async sendPermissionRequest(session, request) {
|
|
2567
2554
|
const threadId = Number(session.threadId);
|
|
2568
|
-
const callbackKey =
|
|
2555
|
+
const callbackKey = nanoid2(8);
|
|
2569
2556
|
this.pending.set(callbackKey, {
|
|
2570
2557
|
sessionId: session.id,
|
|
2571
2558
|
requestId: request.id,
|
|
@@ -2669,7 +2656,7 @@ When a user wants to create a session, guide them through:
|
|
|
2669
2656
|
|
|
2670
2657
|
Commands reference:
|
|
2671
2658
|
- /new [agent] [workspace] \u2014 Create new session
|
|
2672
|
-
- /
|
|
2659
|
+
- /newchat \u2014 New chat with same agent & workspace
|
|
2673
2660
|
- /cancel \u2014 Cancel current session
|
|
2674
2661
|
- /status \u2014 Show status
|
|
2675
2662
|
- /agents \u2014 List agents
|
|
@@ -3034,7 +3021,7 @@ var TelegramSendQueue = class {
|
|
|
3034
3021
|
};
|
|
3035
3022
|
|
|
3036
3023
|
// src/adapters/telegram/action-detect.ts
|
|
3037
|
-
import { nanoid as
|
|
3024
|
+
import { nanoid as nanoid3 } from "nanoid";
|
|
3038
3025
|
import { InlineKeyboard as InlineKeyboard3 } from "grammy";
|
|
3039
3026
|
var CMD_NEW_RE = /\/new(?:\s+([^\s\u0080-\uFFFF]+)(?:\s+([^\s\u0080-\uFFFF]+))?)?/;
|
|
3040
3027
|
var CMD_CANCEL_RE = /\/cancel\b/;
|
|
@@ -3060,7 +3047,7 @@ function detectAction(text) {
|
|
|
3060
3047
|
var ACTION_TTL_MS = 5 * 60 * 1e3;
|
|
3061
3048
|
var actionMap = /* @__PURE__ */ new Map();
|
|
3062
3049
|
function storeAction(action) {
|
|
3063
|
-
const id =
|
|
3050
|
+
const id = nanoid3(10);
|
|
3064
3051
|
actionMap.set(id, { action, createdAt: Date.now() });
|
|
3065
3052
|
for (const [key, entry] of actionMap) {
|
|
3066
3053
|
if (Date.now() - entry.createdAt > ACTION_TTL_MS) {
|
|
@@ -3288,7 +3275,6 @@ var TelegramAdapter = class extends ChannelAdapter {
|
|
|
3288
3275
|
(sessionId) => this.core.sessionManager.getSession(sessionId),
|
|
3289
3276
|
(notification) => this.sendNotification(notification)
|
|
3290
3277
|
);
|
|
3291
|
-
setupSkillCallbacks(this.bot, this.core);
|
|
3292
3278
|
setupDangerousModeCallbacks(this.bot, this.core);
|
|
3293
3279
|
setupActionCallbacks(
|
|
3294
3280
|
this.bot,
|
|
@@ -3693,9 +3679,7 @@ Task completed.
|
|
|
3693
3679
|
}
|
|
3694
3680
|
async sendSkillCommands(sessionId, commands) {
|
|
3695
3681
|
if (sessionId === this.assistantSession?.id) return;
|
|
3696
|
-
const session = this.core.sessionManager.getSession(
|
|
3697
|
-
sessionId
|
|
3698
|
-
);
|
|
3682
|
+
const session = this.core.sessionManager.getSession(sessionId);
|
|
3699
3683
|
if (!session) return;
|
|
3700
3684
|
const threadId = Number(session.threadId);
|
|
3701
3685
|
if (!threadId) return;
|
|
@@ -3710,54 +3694,52 @@ Task completed.
|
|
|
3710
3694
|
await this.cleanupSkillCommands(sessionId);
|
|
3711
3695
|
return;
|
|
3712
3696
|
}
|
|
3713
|
-
|
|
3714
|
-
const keyboard = buildSkillKeyboard(sessionId, commands);
|
|
3715
|
-
const text = "\u{1F6E0} <b>Available commands:</b>";
|
|
3697
|
+
const messages = buildSkillMessages(commands);
|
|
3716
3698
|
const existingMsgId = this.skillMessages.get(sessionId);
|
|
3717
3699
|
if (existingMsgId) {
|
|
3718
3700
|
try {
|
|
3719
3701
|
await this.bot.api.editMessageText(
|
|
3720
3702
|
this.telegramConfig.chatId,
|
|
3721
3703
|
existingMsgId,
|
|
3722
|
-
|
|
3723
|
-
{ parse_mode: "HTML"
|
|
3704
|
+
messages[0],
|
|
3705
|
+
{ parse_mode: "HTML" }
|
|
3724
3706
|
);
|
|
3725
3707
|
return;
|
|
3726
3708
|
} catch {
|
|
3727
3709
|
}
|
|
3728
3710
|
}
|
|
3729
3711
|
try {
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3712
|
+
let firstMsgId;
|
|
3713
|
+
for (const text of messages) {
|
|
3714
|
+
const msg = await this.sendQueue.enqueue(
|
|
3715
|
+
() => this.bot.api.sendMessage(
|
|
3716
|
+
this.telegramConfig.chatId,
|
|
3717
|
+
text,
|
|
3718
|
+
{
|
|
3719
|
+
message_thread_id: threadId,
|
|
3720
|
+
parse_mode: "HTML",
|
|
3721
|
+
disable_notification: true
|
|
3722
|
+
}
|
|
3723
|
+
)
|
|
3724
|
+
);
|
|
3725
|
+
if (!firstMsgId) firstMsgId = msg.message_id;
|
|
3726
|
+
}
|
|
3727
|
+
this.skillMessages.set(sessionId, firstMsgId);
|
|
3743
3728
|
const record = this.core.sessionManager.getSessionRecord(sessionId);
|
|
3744
3729
|
if (record) {
|
|
3745
3730
|
await this.core.sessionManager.updateSessionPlatform(
|
|
3746
3731
|
sessionId,
|
|
3747
|
-
{ ...record.platform, skillMsgId:
|
|
3732
|
+
{ ...record.platform, skillMsgId: firstMsgId }
|
|
3748
3733
|
);
|
|
3749
3734
|
}
|
|
3750
3735
|
await this.bot.api.pinChatMessage(
|
|
3751
3736
|
this.telegramConfig.chatId,
|
|
3752
|
-
|
|
3753
|
-
{
|
|
3754
|
-
disable_notification: true
|
|
3755
|
-
}
|
|
3737
|
+
firstMsgId,
|
|
3738
|
+
{ disable_notification: true }
|
|
3756
3739
|
);
|
|
3757
3740
|
} catch (err) {
|
|
3758
3741
|
log11.error({ err, sessionId }, "Failed to send skill commands");
|
|
3759
3742
|
}
|
|
3760
|
-
await this.updateCommandAutocomplete(session.agentName, commands);
|
|
3761
3743
|
}
|
|
3762
3744
|
async cleanupSkillCommands(sessionId) {
|
|
3763
3745
|
const msgId = this.skillMessages.get(sessionId);
|
|
@@ -3773,35 +3755,12 @@ Task completed.
|
|
|
3773
3755
|
} catch {
|
|
3774
3756
|
}
|
|
3775
3757
|
this.skillMessages.delete(sessionId);
|
|
3776
|
-
clearSkillCallbacks(sessionId);
|
|
3777
3758
|
const record = this.core.sessionManager.getSessionRecord(sessionId);
|
|
3778
3759
|
if (record) {
|
|
3779
3760
|
const { skillMsgId: _removed, ...rest } = record.platform;
|
|
3780
3761
|
await this.core.sessionManager.updateSessionPlatform(sessionId, rest);
|
|
3781
3762
|
}
|
|
3782
3763
|
}
|
|
3783
|
-
async updateCommandAutocomplete(agentName, skillCommands) {
|
|
3784
|
-
const prefix = `[${agentName}] `;
|
|
3785
|
-
const validSkills = skillCommands.map((c) => ({
|
|
3786
|
-
command: c.name.toLowerCase().replace(/[^a-z0-9_]/g, "_").slice(0, 32),
|
|
3787
|
-
description: (prefix + (c.description || c.name).replace(/\n/g, " ")).slice(0, 256)
|
|
3788
|
-
})).filter((c) => c.command.length > 0);
|
|
3789
|
-
const all = [...STATIC_COMMANDS, ...validSkills];
|
|
3790
|
-
try {
|
|
3791
|
-
await this.bot.api.setMyCommands(all, {
|
|
3792
|
-
scope: { type: "chat", chat_id: this.telegramConfig.chatId }
|
|
3793
|
-
});
|
|
3794
|
-
log11.info(
|
|
3795
|
-
{ count: all.length, skills: validSkills.length },
|
|
3796
|
-
"Updated command autocomplete"
|
|
3797
|
-
);
|
|
3798
|
-
} catch (err) {
|
|
3799
|
-
log11.error(
|
|
3800
|
-
{ err, commands: all },
|
|
3801
|
-
"Failed to update command autocomplete"
|
|
3802
|
-
);
|
|
3803
|
-
}
|
|
3804
|
-
}
|
|
3805
3764
|
async finalizeDraft(sessionId) {
|
|
3806
3765
|
const draft = this.sessionDrafts.get(sessionId);
|
|
3807
3766
|
if (!draft) return;
|
|
@@ -3849,4 +3808,4 @@ export {
|
|
|
3849
3808
|
ApiServer,
|
|
3850
3809
|
TelegramAdapter
|
|
3851
3810
|
};
|
|
3852
|
-
//# sourceMappingURL=chunk-
|
|
3811
|
+
//# sourceMappingURL=chunk-GA26H6JY.js.map
|