@openacp/cli 2026.406.5 → 2026.407.1

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/cli.js CHANGED
@@ -362,7 +362,7 @@ async function runUpdate() {
362
362
  });
363
363
  }
364
364
  async function checkAndPromptUpdate() {
365
- if (process.env.OPENACP_DEV_LOOP || process.env.OPENACP_SKIP_UPDATE_CHECK) return;
365
+ if (process.env.OPENACP_DEV_LOOP || process.env.OPENACP_SKIP_UPDATE_CHECK || !process.stdin.isTTY) return;
366
366
  const current = getCurrentVersion();
367
367
  if (current === "0.0.0-dev") return;
368
368
  const latest = await getLatestVersion();
@@ -7555,7 +7555,9 @@ var init_config_registry = __esm({
7555
7555
  displayName: "Default Agent",
7556
7556
  group: "agent",
7557
7557
  type: "select",
7558
- options: () => {
7558
+ options: (config) => {
7559
+ const configAgents = Object.keys(config.agents ?? {});
7560
+ if (configAgents.length > 0) return configAgents;
7559
7561
  try {
7560
7562
  const agentsPath = path24.join(getGlobalRoot(), "agents.json");
7561
7563
  if (fs19.existsSync(agentsPath)) {
@@ -8335,6 +8337,7 @@ var sessions_exports = {};
8335
8337
  __export(sessions_exports, {
8336
8338
  sessionRoutes: () => sessionRoutes
8337
8339
  });
8340
+ import { nanoid as nanoid2 } from "nanoid";
8338
8341
  async function sessionRoutes(app, deps) {
8339
8342
  app.get("/", { preHandler: requireScopes("sessions:read") }, async () => {
8340
8343
  const summaries = deps.core.sessionManager.listAllSessions();
@@ -8493,14 +8496,26 @@ async function sessionRoutes(app, deps) {
8493
8496
  }
8494
8497
  attachments = await resolveAttachments(fileService, sessionId, body.attachments);
8495
8498
  }
8499
+ const sourceAdapterId = body.sourceAdapterId ?? "api";
8500
+ const turnId = nanoid2(8);
8501
+ deps.core.eventBus.emit(BusEvent.MESSAGE_QUEUED, {
8502
+ sessionId,
8503
+ turnId,
8504
+ text: body.prompt,
8505
+ sourceAdapterId,
8506
+ attachments,
8507
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
8508
+ queueDepth: session.queueDepth
8509
+ });
8496
8510
  await session.enqueuePrompt(body.prompt, attachments, {
8497
- sourceAdapterId: body.sourceAdapterId ?? "api",
8511
+ sourceAdapterId,
8498
8512
  responseAdapterId: body.responseAdapterId
8499
- });
8513
+ }, turnId);
8500
8514
  return {
8501
8515
  ok: true,
8502
8516
  sessionId,
8503
- queueDepth: session.queueDepth
8517
+ queueDepth: session.queueDepth,
8518
+ turnId
8504
8519
  };
8505
8520
  }
8506
8521
  );
@@ -8763,6 +8778,7 @@ var init_sessions2 = __esm({
8763
8778
  init_error_handler();
8764
8779
  init_auth();
8765
8780
  init_attachment_utils();
8781
+ init_events();
8766
8782
  init_sessions();
8767
8783
  }
8768
8784
  });
@@ -11877,6 +11893,50 @@ async function createSessionDirect(ctx, core, chatId, agentName, workspace, onCo
11877
11893
  return null;
11878
11894
  }
11879
11895
  }
11896
+ function _pruneExpiredForceReplies() {
11897
+ const cutoff = Date.now() - 10 * 60 * 1e3;
11898
+ for (const [msgId, entry] of _forceReplyMap) {
11899
+ if (entry.createdAt < cutoff) _forceReplyMap.delete(msgId);
11900
+ }
11901
+ }
11902
+ async function _sendCustomPathPrompt(ctx, chatId, agentKey) {
11903
+ const threadId = ctx.message?.message_thread_id ?? ctx.callbackQuery?.message?.message_thread_id;
11904
+ const sent = await ctx.api.sendMessage(
11905
+ chatId,
11906
+ `Please type the workspace path.
11907
+
11908
+ Examples:
11909
+ \u2022 <code>/absolute/path/to/project</code>
11910
+ \u2022 <code>~/my-project</code>
11911
+ \u2022 <code>project-name</code> (created under your base directory)
11912
+
11913
+ Reply to this message with your path.`,
11914
+ {
11915
+ parse_mode: "HTML",
11916
+ reply_markup: { force_reply: true },
11917
+ ...threadId !== void 0 ? { message_thread_id: threadId } : {}
11918
+ }
11919
+ );
11920
+ _forceReplyMap.set(sent.message_id, { agentKey, chatId, createdAt: Date.now() });
11921
+ }
11922
+ async function _handleCustomPathReply(ctx, core, chatId, entry) {
11923
+ const input2 = (ctx.message.text ?? "").trim();
11924
+ let resolvedPath;
11925
+ try {
11926
+ resolvedPath = core.configManager.resolveWorkspace(input2);
11927
+ } catch (err) {
11928
+ const message = err instanceof Error ? err.message : String(err);
11929
+ await ctx.reply(`\u274C ${escapeHtml4(message)}
11930
+
11931
+ Please try again:`, {
11932
+ parse_mode: "HTML"
11933
+ }).catch(() => {
11934
+ });
11935
+ await _sendCustomPathPrompt(ctx, chatId, entry.agentKey);
11936
+ return;
11937
+ }
11938
+ await createSessionDirect(ctx, core, chatId, entry.agentKey, resolvedPath);
11939
+ }
11880
11940
  function cacheWorkspace(agentKey, workspace) {
11881
11941
  const now = Date.now();
11882
11942
  for (const [id2, entry] of workspaceCache) {
@@ -11957,7 +12017,16 @@ Select workspace:`;
11957
12017
  }
11958
12018
  }
11959
12019
  }
11960
- function setupNewSessionCallbacks(bot, core, chatId, getAssistantSession) {
12020
+ function setupNewSessionCallbacks(bot, core, chatId) {
12021
+ bot.on("message:text", async (ctx, next) => {
12022
+ _pruneExpiredForceReplies();
12023
+ const replyToId = ctx.message.reply_to_message?.message_id;
12024
+ if (replyToId === void 0) return next();
12025
+ const entry = _forceReplyMap.get(replyToId);
12026
+ if (!entry || entry.chatId !== ctx.message.chat.id) return next();
12027
+ _forceReplyMap.delete(replyToId);
12028
+ await _handleCustomPathReply(ctx, core, chatId, entry);
12029
+ });
11961
12030
  bot.callbackQuery("ns:start", async (ctx) => {
11962
12031
  try {
11963
12032
  await ctx.answerCallbackQuery();
@@ -12034,33 +12103,20 @@ Try again with /new or /menu`,
12034
12103
  await ctx.answerCallbackQuery();
12035
12104
  } catch {
12036
12105
  }
12037
- const assistant = getAssistantSession?.();
12038
- if (assistant) {
12039
- try {
12040
- await ctx.editMessageText(
12041
- `<b>\u{1F195} New Session</b>
12106
+ try {
12107
+ await ctx.editMessageText(
12108
+ `<b>\u{1F195} New Session</b>
12042
12109
  Agent: <code>${escapeHtml4(agentKey)}</code>
12043
12110
 
12044
- \u{1F4AC} Type your workspace path in the chat below.`,
12045
- { parse_mode: "HTML" }
12046
- );
12047
- } catch {
12048
- }
12049
- await assistant.enqueuePrompt(
12050
- `User wants to create a new session with agent "${agentKey}". Ask them for the workspace (project directory) path, then create the session.`
12111
+ \u2328\uFE0F Waiting for workspace path...`,
12112
+ { parse_mode: "HTML" }
12051
12113
  );
12052
- } else {
12053
- try {
12054
- await ctx.editMessageText(
12055
- `Usage: <code>/new ${escapeHtml4(agentKey)} &lt;workspace-path&gt;</code>`,
12056
- { parse_mode: "HTML" }
12057
- );
12058
- } catch {
12059
- }
12114
+ } catch {
12060
12115
  }
12116
+ await _sendCustomPathPrompt(ctx, chatId, agentKey);
12061
12117
  });
12062
12118
  }
12063
- var log18, WS_CACHE_MAX, workspaceCache, nextWsId;
12119
+ var log18, WS_CACHE_MAX, workspaceCache, nextWsId, _forceReplyMap;
12064
12120
  var init_new_session = __esm({
12065
12121
  "src/plugins/telegram/commands/new-session.ts"() {
12066
12122
  "use strict";
@@ -12072,6 +12128,7 @@ var init_new_session = __esm({
12072
12128
  WS_CACHE_MAX = 50;
12073
12129
  workspaceCache = /* @__PURE__ */ new Map();
12074
12130
  nextWsId = 0;
12131
+ _forceReplyMap = /* @__PURE__ */ new Map();
12075
12132
  }
12076
12133
  });
12077
12134
 
@@ -14666,7 +14723,7 @@ function setupAllCallbacks(bot, core, chatId, systemTopicIds, getAssistantSessio
14666
14723
  core.configManager.get().workspace.baseDir
14667
14724
  );
14668
14725
  });
14669
- setupNewSessionCallbacks(bot, core, chatId, getAssistantSession);
14726
+ setupNewSessionCallbacks(bot, core, chatId);
14670
14727
  bot.callbackQuery(/^ar:/, (ctx) => handleArchiveConfirm(ctx, core, chatId));
14671
14728
  bot.callbackQuery(/^m:/, async (ctx) => {
14672
14729
  const itemId = ctx.callbackQuery.data.replace("m:", "");
@@ -14823,7 +14880,7 @@ var init_commands3 = __esm({
14823
14880
 
14824
14881
  // src/plugins/telegram/permissions.ts
14825
14882
  import { InlineKeyboard as InlineKeyboard11 } from "grammy";
14826
- import { nanoid as nanoid2 } from "nanoid";
14883
+ import { nanoid as nanoid3 } from "nanoid";
14827
14884
  var log26, PermissionHandler;
14828
14885
  var init_permissions = __esm({
14829
14886
  "src/plugins/telegram/permissions.ts"() {
@@ -14842,7 +14899,7 @@ var init_permissions = __esm({
14842
14899
  pending = /* @__PURE__ */ new Map();
14843
14900
  async sendPermissionRequest(session, request) {
14844
14901
  const threadId = Number(session.threadId);
14845
- const callbackKey = nanoid2(8);
14902
+ const callbackKey = nanoid3(8);
14846
14903
  this.pending.set(callbackKey, {
14847
14904
  sessionId: session.id,
14848
14905
  requestId: request.id,
@@ -20044,10 +20101,10 @@ var init_permission_gate = __esm({
20044
20101
  });
20045
20102
 
20046
20103
  // src/core/sessions/turn-context.ts
20047
- import { nanoid as nanoid3 } from "nanoid";
20104
+ import { nanoid as nanoid4 } from "nanoid";
20048
20105
  function createTurnContext(sourceAdapterId, responseAdapterId, turnId) {
20049
20106
  return {
20050
- turnId: turnId ?? nanoid3(8),
20107
+ turnId: turnId ?? nanoid4(8),
20051
20108
  sourceAdapterId,
20052
20109
  responseAdapterId
20053
20110
  };
@@ -20075,7 +20132,7 @@ var init_turn_context = __esm({
20075
20132
  });
20076
20133
 
20077
20134
  // src/core/sessions/session.ts
20078
- import { nanoid as nanoid4 } from "nanoid";
20135
+ import { nanoid as nanoid5 } from "nanoid";
20079
20136
  import * as fs41 from "fs";
20080
20137
  var moduleLog, TTS_PROMPT_INSTRUCTION, TTS_BLOCK_REGEX, TTS_MAX_LENGTH, TTS_TIMEOUT_MS, VALID_TRANSITIONS, Session;
20081
20138
  var init_session2 = __esm({
@@ -20153,7 +20210,7 @@ Additionally, include a [TTS]...[/TTS] block with a spoken-friendly summary of y
20153
20210
  pendingContext = null;
20154
20211
  constructor(opts) {
20155
20212
  super();
20156
- this.id = opts.id || nanoid4(12);
20213
+ this.id = opts.id || nanoid5(12);
20157
20214
  this.channelId = opts.channelId;
20158
20215
  this.attachedAdapters = [opts.channelId];
20159
20216
  this.agentName = opts.agentName;
@@ -20255,7 +20312,7 @@ Additionally, include a [TTS]...[/TTS] block with a spoken-friendly summary of y
20255
20312
  }
20256
20313
  // --- Public API ---
20257
20314
  async enqueuePrompt(text6, attachments, routing, externalTurnId) {
20258
- const turnId = externalTurnId ?? nanoid4(8);
20315
+ const turnId = externalTurnId ?? nanoid5(8);
20259
20316
  if (this.middlewareChain) {
20260
20317
  const payload = { text: text6, attachments, sessionId: this.id, sourceAdapterId: routing?.sourceAdapterId };
20261
20318
  const result = await this.middlewareChain.execute(Hook.AGENT_BEFORE_PROMPT, payload, async (p2) => p2);
@@ -20984,7 +21041,7 @@ var init_session_bridge = __esm({
20984
21041
  this.deps.sessionManager.patchRecord(this.session.id, { currentPromptCount: count });
20985
21042
  });
20986
21043
  this.listen(this.session, SessionEv.TURN_STARTED, (ctx) => {
20987
- if (ctx.sourceAdapterId !== "sse" && ctx.sourceAdapterId !== "api") {
21044
+ if (ctx.sourceAdapterId !== "sse") {
20988
21045
  this.deps.eventBus?.emit(BusEvent.MESSAGE_PROCESSING, {
20989
21046
  sessionId: this.session.id,
20990
21047
  turnId: ctx.turnId,
@@ -24074,7 +24131,7 @@ var init_core_items = __esm({
24074
24131
  // src/core/core.ts
24075
24132
  import path51 from "path";
24076
24133
  import os23 from "os";
24077
- import { nanoid as nanoid5 } from "nanoid";
24134
+ import { nanoid as nanoid6 } from "nanoid";
24078
24135
  var log42, OpenACPCore;
24079
24136
  var init_core = __esm({
24080
24137
  "src/core/core.ts"() {
@@ -24389,7 +24446,7 @@ ${text6}`;
24389
24446
  const sourceAdapterId = message.routing?.sourceAdapterId ?? message.channelId;
24390
24447
  const routing = sourceAdapterId !== message.routing?.sourceAdapterId ? { ...message.routing, sourceAdapterId } : message.routing;
24391
24448
  if (sourceAdapterId && sourceAdapterId !== "sse" && sourceAdapterId !== "api") {
24392
- const turnId = nanoid5(8);
24449
+ const turnId = nanoid6(8);
24393
24450
  this.eventBus.emit(BusEvent.MESSAGE_QUEUED, {
24394
24451
  sessionId: session.id,
24395
24452
  turnId,
@@ -30668,13 +30725,18 @@ async function buildInstanceListEntries() {
30668
30725
  };
30669
30726
  });
30670
30727
  }
30671
- async function cmdInstances(args2 = []) {
30728
+ async function cmdInstances(args2 = [], parentFlags) {
30672
30729
  if (wantsHelp(args2)) {
30673
30730
  printInstancesHelp();
30674
30731
  return;
30675
30732
  }
30676
30733
  const sub = args2[0];
30677
30734
  const subArgs = args2.slice(1);
30735
+ if (parentFlags) {
30736
+ if (parentFlags.dir && !subArgs.includes("--dir")) subArgs.push("--dir", parentFlags.dir);
30737
+ if (parentFlags.from && !subArgs.includes("--from")) subArgs.push("--from", parentFlags.from);
30738
+ if (parentFlags.name && !subArgs.includes("--name")) subArgs.push("--name", parentFlags.name);
30739
+ }
30678
30740
  if (!sub || sub === "list") return cmdInstancesList(subArgs);
30679
30741
  if (sub === "create") return cmdInstancesCreate(subArgs);
30680
30742
  console.error(`Unknown subcommand: instances ${sub}`);
@@ -30774,19 +30836,33 @@ async function cmdInstancesCreate(args2) {
30774
30836
  try {
30775
30837
  const config = JSON.parse(fs53.readFileSync(configPath, "utf-8"));
30776
30838
  config.instanceName = name;
30839
+ if (!config.workspace) config.workspace = {};
30840
+ config.workspace.baseDir = resolvedDir;
30777
30841
  fs53.writeFileSync(configPath, JSON.stringify(config, null, 2));
30778
30842
  } catch {
30779
30843
  }
30780
30844
  } else if (noInteractive || !process.stdin.isTTY) {
30781
30845
  fs53.mkdirSync(instanceRoot, { recursive: true });
30782
- const config = { instanceName: name, runMode: "daemon" };
30783
- if (agent) config.defaultAgent = agent;
30846
+ const config = {
30847
+ channels: { sse: { enabled: true } },
30848
+ defaultAgent: agent || "claude",
30849
+ workspace: { baseDir: resolvedDir },
30850
+ runMode: "daemon",
30851
+ autoStart: false,
30852
+ instanceName: name
30853
+ };
30784
30854
  fs53.writeFileSync(path62.join(instanceRoot, "config.json"), JSON.stringify(config, null, 2));
30785
30855
  fs53.writeFileSync(path62.join(instanceRoot, "plugins.json"), JSON.stringify({ version: 1, installed: {} }, null, 2));
30786
30856
  } else {
30787
30857
  fs53.mkdirSync(instanceRoot, { recursive: true });
30788
- const config = { instanceName: name, runMode: "daemon" };
30789
- if (agent) config.defaultAgent = agent;
30858
+ const config = {
30859
+ channels: { sse: { enabled: true } },
30860
+ defaultAgent: agent || "claude",
30861
+ workspace: { baseDir: resolvedDir },
30862
+ runMode: "daemon",
30863
+ autoStart: false,
30864
+ instanceName: name
30865
+ };
30790
30866
  fs53.writeFileSync(path62.join(instanceRoot, "config.json"), JSON.stringify(config, null, 2));
30791
30867
  fs53.writeFileSync(path62.join(instanceRoot, "plugins.json"), JSON.stringify({ version: 1, installed: {} }, null, 2));
30792
30868
  console.log(`Instance created at ${resolvedDir}. Run 'openacp setup' inside that directory to configure it.`);
@@ -32193,7 +32269,7 @@ var noInstanceCommands = {
32193
32269
  "-v": () => cmdVersion(args),
32194
32270
  "update": () => cmdUpdate(args),
32195
32271
  "adopt": () => cmdAdopt(args),
32196
- "instances": async () => cmdInstances(args),
32272
+ "instances": async () => cmdInstances(args, flags),
32197
32273
  "integrate": () => cmdIntegrate(args),
32198
32274
  "dev": () => cmdDev(args)
32199
32275
  };