@openacp/cli 0.3.0 → 0.3.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.
@@ -614,9 +614,11 @@ var Session = class {
614
614
  }
615
615
  }
616
616
  async cancel() {
617
- this.status = "cancelled";
617
+ this.promptQueue = [];
618
618
  this.log.info("Session cancelled");
619
619
  await this.agentInstance.cancel();
620
+ this.promptRunning = false;
621
+ this.status = "active";
620
622
  }
621
623
  async destroy() {
622
624
  this.log.info("Session destroyed");
@@ -1945,16 +1947,30 @@ async function handleNewChat(ctx, core, chatId) {
1945
1947
  );
1946
1948
  return;
1947
1949
  }
1948
- try {
1949
- const session = await core.handleNewChat("telegram", String(threadId));
1950
- if (!session) {
1950
+ const currentSession = core.sessionManager.getSessionByThread(
1951
+ "telegram",
1952
+ String(threadId)
1953
+ );
1954
+ let agentName;
1955
+ let workspace;
1956
+ if (currentSession) {
1957
+ agentName = currentSession.agentName;
1958
+ workspace = currentSession.workingDirectory;
1959
+ } else {
1960
+ const record = core.sessionManager.getRecordByThread("telegram", String(threadId));
1961
+ if (!record || record.status === "cancelled" || record.status === "error") {
1951
1962
  await ctx.reply("No active session in this topic.", {
1952
1963
  parse_mode: "HTML"
1953
1964
  });
1954
1965
  return;
1955
1966
  }
1956
- const topicName = `\u{1F504} ${session.agentName} \u2014 New Chat`;
1957
- const newThreadId = await createSessionTopic(
1967
+ agentName = record.agentName;
1968
+ workspace = record.workingDir;
1969
+ }
1970
+ let newThreadId;
1971
+ try {
1972
+ const topicName = `\u{1F504} ${agentName} \u2014 New Chat`;
1973
+ newThreadId = await createSessionTopic(
1958
1974
  botFromCtx(ctx),
1959
1975
  chatId,
1960
1976
  topicName
@@ -1963,6 +1979,11 @@ async function handleNewChat(ctx, core, chatId) {
1963
1979
  message_thread_id: newThreadId,
1964
1980
  parse_mode: "HTML"
1965
1981
  });
1982
+ const session = await core.handleNewSession(
1983
+ "telegram",
1984
+ agentName,
1985
+ workspace
1986
+ );
1966
1987
  session.threadId = String(newThreadId);
1967
1988
  await core.sessionManager.updateSessionPlatform(session.id, {
1968
1989
  topicId: newThreadId
@@ -1980,6 +2001,12 @@ async function handleNewChat(ctx, core, chatId) {
1980
2001
  );
1981
2002
  session.warmup().catch((err) => log6.error({ err }, "Warm-up error"));
1982
2003
  } catch (err) {
2004
+ if (newThreadId) {
2005
+ try {
2006
+ await ctx.api.deleteForumTopic(chatId, newThreadId);
2007
+ } catch {
2008
+ }
2009
+ }
1983
2010
  const message = err instanceof Error ? err.message : String(err);
1984
2011
  await ctx.reply(`\u274C ${escapeHtml(message)}`, { parse_mode: "HTML" });
1985
2012
  }
@@ -2204,10 +2231,11 @@ function setupSkillCallbacks(bot, core) {
2204
2231
  }
2205
2232
  async function executeNewSession(bot, core, chatId, agentName, workspace) {
2206
2233
  const threadId = await createSessionTopic(bot, chatId, "\u{1F504} New Session");
2207
- await bot.api.sendMessage(chatId, "\u23F3 Setting up session, please wait...", {
2234
+ const setupMsg = await bot.api.sendMessage(chatId, "\u23F3 Setting up session, please wait...", {
2208
2235
  message_thread_id: threadId,
2209
2236
  parse_mode: "HTML"
2210
2237
  });
2238
+ const firstMsgId = setupMsg.message_id;
2211
2239
  try {
2212
2240
  const session = await core.handleNewSession(
2213
2241
  "telegram",
@@ -2221,7 +2249,7 @@ async function executeNewSession(bot, core, chatId, agentName, workspace) {
2221
2249
  const finalName = `\u{1F504} ${session.agentName} \u2014 New Session`;
2222
2250
  await renameSessionTopic(bot, chatId, threadId, finalName);
2223
2251
  session.warmup().catch((err) => log6.error({ err }, "Warm-up error"));
2224
- return { session, threadId };
2252
+ return { session, threadId, firstMsgId };
2225
2253
  } catch (err) {
2226
2254
  try {
2227
2255
  await bot.api.deleteForumTopic(chatId, threadId);
@@ -2495,6 +2523,9 @@ var UsageMessage = class {
2495
2523
  log9.warn({ err }, "UsageMessage.send() failed");
2496
2524
  }
2497
2525
  }
2526
+ getMsgId() {
2527
+ return this.msgId;
2528
+ }
2498
2529
  async delete() {
2499
2530
  if (!this.msgId) return;
2500
2531
  const id = this.msgId;
@@ -2632,6 +2663,9 @@ var ActivityTracker = class {
2632
2663
  async sendUsage(data) {
2633
2664
  await this.usage.send(data);
2634
2665
  }
2666
+ getUsageMsgId() {
2667
+ return this.usage.getMsgId();
2668
+ }
2635
2669
  async onComplete() {
2636
2670
  if (this.hasPlanCard) {
2637
2671
  await this.planCard.finalize();
@@ -2650,6 +2684,7 @@ var ActivityTracker = class {
2650
2684
  }
2651
2685
  }
2652
2686
  destroy() {
2687
+ this.thinking.dismiss();
2653
2688
  this.planCard.destroy();
2654
2689
  }
2655
2690
  async _firstEventGuard() {
@@ -2807,14 +2842,14 @@ function setupActionCallbacks(bot, core, chatId, getAssistantSessionId) {
2807
2842
  try {
2808
2843
  if (action.action === "new_session") {
2809
2844
  await ctx.answerCallbackQuery({ text: "\u23F3 Creating session..." });
2810
- const { threadId } = await executeNewSession(
2845
+ const { threadId, firstMsgId } = await executeNewSession(
2811
2846
  bot,
2812
2847
  core,
2813
2848
  chatId,
2814
2849
  action.agent,
2815
2850
  action.workspace
2816
2851
  );
2817
- const topicLink = `https://t.me/c/${String(chatId).replace("-100", "")}/${threadId}`;
2852
+ const topicLink = `https://t.me/c/${String(chatId).replace("-100", "")}/${firstMsgId ?? threadId}`;
2818
2853
  const originalText = ctx.callbackQuery.message?.text ?? "";
2819
2854
  try {
2820
2855
  await ctx.editMessageText(
@@ -3242,7 +3277,8 @@ Workspace: <code>${workspace}</code>
3242
3277
  const sessionName = sess?.name || "Session";
3243
3278
  const chatIdStr = String(this.telegramConfig.chatId);
3244
3279
  const numericId = chatIdStr.startsWith("-100") ? chatIdStr.slice(4) : chatIdStr.replace("-", "");
3245
- const deepLink = `https://t.me/c/${numericId}/${threadId}`;
3280
+ const usageMsgId = tracker.getUsageMsgId();
3281
+ const deepLink = `https://t.me/c/${numericId}/${usageMsgId ?? threadId}`;
3246
3282
  const text = `\u2705 <b>${escapeHtml(sessionName)}</b>
3247
3283
  Task completed.
3248
3284
 
@@ -3537,4 +3573,4 @@ export {
3537
3573
  ApiServer,
3538
3574
  TelegramAdapter
3539
3575
  };
3540
- //# sourceMappingURL=chunk-C6IFPAWN.js.map
3576
+ //# sourceMappingURL=chunk-66PHSLNS.js.map