@openacp/cli 0.3.1 → 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.
@@ -615,9 +615,10 @@ var Session = class {
615
615
  }
616
616
  async cancel() {
617
617
  this.promptQueue = [];
618
- this.status = "cancelled";
619
618
  this.log.info("Session cancelled");
620
619
  await this.agentInstance.cancel();
620
+ this.promptRunning = false;
621
+ this.status = "active";
621
622
  }
622
623
  async destroy() {
623
624
  this.log.info("Session destroyed");
@@ -1946,16 +1947,30 @@ async function handleNewChat(ctx, core, chatId) {
1946
1947
  );
1947
1948
  return;
1948
1949
  }
1949
- try {
1950
- const session = await core.handleNewChat("telegram", String(threadId));
1951
- 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") {
1952
1962
  await ctx.reply("No active session in this topic.", {
1953
1963
  parse_mode: "HTML"
1954
1964
  });
1955
1965
  return;
1956
1966
  }
1957
- const topicName = `\u{1F504} ${session.agentName} \u2014 New Chat`;
1958
- 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(
1959
1974
  botFromCtx(ctx),
1960
1975
  chatId,
1961
1976
  topicName
@@ -1964,6 +1979,11 @@ async function handleNewChat(ctx, core, chatId) {
1964
1979
  message_thread_id: newThreadId,
1965
1980
  parse_mode: "HTML"
1966
1981
  });
1982
+ const session = await core.handleNewSession(
1983
+ "telegram",
1984
+ agentName,
1985
+ workspace
1986
+ );
1967
1987
  session.threadId = String(newThreadId);
1968
1988
  await core.sessionManager.updateSessionPlatform(session.id, {
1969
1989
  topicId: newThreadId
@@ -1981,6 +2001,12 @@ async function handleNewChat(ctx, core, chatId) {
1981
2001
  );
1982
2002
  session.warmup().catch((err) => log6.error({ err }, "Warm-up error"));
1983
2003
  } catch (err) {
2004
+ if (newThreadId) {
2005
+ try {
2006
+ await ctx.api.deleteForumTopic(chatId, newThreadId);
2007
+ } catch {
2008
+ }
2009
+ }
1984
2010
  const message = err instanceof Error ? err.message : String(err);
1985
2011
  await ctx.reply(`\u274C ${escapeHtml(message)}`, { parse_mode: "HTML" });
1986
2012
  }
@@ -3547,4 +3573,4 @@ export {
3547
3573
  ApiServer,
3548
3574
  TelegramAdapter
3549
3575
  };
3550
- //# sourceMappingURL=chunk-SWQRUVBW.js.map
3576
+ //# sourceMappingURL=chunk-66PHSLNS.js.map