@openacp/cli 2026.407.1 → 2026.408.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/cli.js CHANGED
@@ -4879,15 +4879,6 @@ function stripPythonPackageVersion(pkg) {
4879
4879
  async function installAgent(agent, store, progress, agentsDir) {
4880
4880
  const agentKey = getAgentAlias(agent.id);
4881
4881
  await progress?.onStart(agent.id, agent.name);
4882
- await progress?.onStep("Checking requirements...");
4883
- const depResult = checkDependencies(agent.id);
4884
- if (!depResult.available) {
4885
- const hints = depResult.missing.map((m) => ` ${m.label}: ${m.installHint}`).join("\n");
4886
- const msg = `${agent.name} needs some tools installed first:
4887
- ${hints}`;
4888
- await progress?.onError(msg);
4889
- return { ok: false, agentKey, error: msg };
4890
- }
4891
4882
  const dist = resolveDistribution(agent);
4892
4883
  if (!dist) {
4893
4884
  const platformKey = getPlatformKey();
@@ -4901,6 +4892,7 @@ Install it with: pip install uv`;
4901
4892
  await progress?.onError(msg, "pip install uv");
4902
4893
  return { ok: false, agentKey, error: msg, hint: "pip install uv" };
4903
4894
  }
4895
+ const depResult = checkDependencies(agent.id);
4904
4896
  let binaryPath;
4905
4897
  if (dist.type === "binary") {
4906
4898
  try {
@@ -4916,8 +4908,9 @@ Install it with: pip install uv`;
4916
4908
  const installed = buildInstalledAgent(agent.id, agent.name, agent.version, dist, binaryPath);
4917
4909
  store.addAgent(agentKey, installed);
4918
4910
  const setup = getAgentSetup(agent.id);
4911
+ const setupSteps = setup?.setupSteps ?? (depResult.missing?.map((m) => `${m.label}: ${m.installHint}`) ?? []);
4919
4912
  await progress?.onSuccess(agent.name);
4920
- return { ok: true, agentKey, setupSteps: setup?.setupSteps };
4913
+ return { ok: true, agentKey, setupSteps: setupSteps.length > 0 ? setupSteps : void 0 };
4921
4914
  }
4922
4915
  async function downloadAndExtract(agentId, archiveUrl, progress, agentsDir) {
4923
4916
  const destDir = path15.join(agentsDir ?? DEFAULT_AGENTS_DIR, agentId);
@@ -5723,7 +5716,7 @@ var init_openacp = __esm({
5723
5716
  this.startHeartbeat();
5724
5717
  return this.publicUrl;
5725
5718
  }
5726
- async stop(force = false) {
5719
+ async stop(force = false, preserveState = false) {
5727
5720
  this.stopHeartbeat();
5728
5721
  const child = this.child;
5729
5722
  const tunnelId = this.tunnelId;
@@ -5739,7 +5732,7 @@ var init_openacp = __esm({
5739
5732
  child.once("exit", () => clearTimeout(killTimer));
5740
5733
  }
5741
5734
  }
5742
- if (tunnelId) {
5735
+ if (tunnelId && !preserveState) {
5743
5736
  this.deleteFromWorker(tunnelId).catch((err) => {
5744
5737
  log8.warn({ err: err.message }, "Failed to delete tunnel from worker");
5745
5738
  });
@@ -5747,7 +5740,7 @@ var init_openacp = __esm({
5747
5740
  delete all[String(localPort)];
5748
5741
  await this.storage.set(STORAGE_KEY, all);
5749
5742
  }
5750
- log8.info({ localPort }, "OpenACP tunnel stopped");
5743
+ log8.info({ localPort, preserveState }, "OpenACP tunnel stopped");
5751
5744
  }
5752
5745
  getPublicUrl() {
5753
5746
  return this.publicUrl;
@@ -5790,6 +5783,16 @@ var init_openacp = __esm({
5790
5783
  return;
5791
5784
  }
5792
5785
  this.child = child;
5786
+ const onData = (data) => {
5787
+ const line = data.toString();
5788
+ if (/Registered tunnel connection/.test(line)) {
5789
+ clearTimeout(timeout);
5790
+ log8.info({ port }, "cloudflared connection registered");
5791
+ settle(resolve8);
5792
+ }
5793
+ };
5794
+ child.stdout?.on("data", onData);
5795
+ child.stderr?.on("data", onData);
5793
5796
  child.on("error", (err) => {
5794
5797
  clearTimeout(timeout);
5795
5798
  settle(() => reject(new Error(`cloudflared failed to start: ${err.message}`)));
@@ -6066,19 +6069,24 @@ var init_tunnel_registry = __esm({
6066
6069
  }
6067
6070
  }
6068
6071
  async shutdown() {
6072
+ if (this.shuttingDown) return;
6069
6073
  this.keepalive.stop();
6070
6074
  this.shuttingDown = true;
6075
+ if (this.saveTimeout) {
6076
+ clearTimeout(this.saveTimeout);
6077
+ this.saveTimeout = null;
6078
+ }
6071
6079
  const stopPromises = [];
6072
6080
  for (const [, live] of this.entries) {
6073
6081
  if (live.retryTimer) clearTimeout(live.retryTimer);
6074
6082
  if (live.process) {
6075
- stopPromises.push(live.process.stop(true).catch(() => {
6083
+ stopPromises.push(live.process.stop(true, true).catch(() => {
6076
6084
  }));
6077
6085
  }
6078
6086
  }
6079
6087
  await Promise.all(stopPromises);
6088
+ this.save();
6080
6089
  this.entries.clear();
6081
- this.scheduleSave();
6082
6090
  }
6083
6091
  list(includeSystem = false) {
6084
6092
  const entries = Array.from(this.entries.values()).map((l) => l.entry);
@@ -6103,16 +6111,20 @@ var init_tunnel_registry = __esm({
6103
6111
  const raw = JSON.parse(fs16.readFileSync(this.registryPath, "utf-8"));
6104
6112
  log9.info({ count: raw.length }, "Restoring tunnels");
6105
6113
  const userEntries = raw.filter((e) => e.type === "user");
6106
- for (const persisted of userEntries) {
6107
- try {
6108
- await this.add(persisted.port, {
6114
+ const results = await Promise.allSettled(
6115
+ userEntries.map(
6116
+ (persisted) => this.add(persisted.port, {
6109
6117
  type: persisted.type,
6110
6118
  provider: persisted.provider,
6111
- label: persisted.label,
6112
- sessionId: persisted.sessionId
6113
- });
6114
- } catch (err) {
6115
- log9.warn({ port: persisted.port, err: err.message }, "Failed to restore tunnel");
6119
+ label: persisted.label
6120
+ // sessionId intentionally omitted — sessions don't survive restart
6121
+ })
6122
+ )
6123
+ );
6124
+ for (let i = 0; i < results.length; i++) {
6125
+ if (results[i].status === "rejected") {
6126
+ const reason = results[i].reason;
6127
+ log9.warn({ port: userEntries[i].port, err: reason.message }, "Failed to restore tunnel");
6116
6128
  }
6117
6129
  }
6118
6130
  } catch (err) {
@@ -6170,7 +6182,9 @@ var init_tunnel_registry = __esm({
6170
6182
  clearTimeout(this.saveTimeout);
6171
6183
  this.saveTimeout = null;
6172
6184
  }
6173
- this.save();
6185
+ if (!this.shuttingDown) {
6186
+ this.save();
6187
+ }
6174
6188
  }
6175
6189
  };
6176
6190
  }
@@ -8300,7 +8314,9 @@ var init_sessions = __esm({
8300
8314
  sourceAdapterId: z.string().optional(),
8301
8315
  responseAdapterId: z.string().nullable().optional(),
8302
8316
  // Optional file attachments; each decoded and stored via FileService
8303
- attachments: z.array(AttachmentInputSchema).max(10).optional()
8317
+ attachments: z.array(AttachmentInputSchema).max(10).optional(),
8318
+ // Client-provided turnId to avoid SSE echo race condition
8319
+ turnId: z.string().max(64).optional()
8304
8320
  });
8305
8321
  PermissionResponseBodySchema = z.object({
8306
8322
  permissionId: z.string().min(1).max(200),
@@ -8497,7 +8513,7 @@ async function sessionRoutes(app, deps) {
8497
8513
  attachments = await resolveAttachments(fileService, sessionId, body.attachments);
8498
8514
  }
8499
8515
  const sourceAdapterId = body.sourceAdapterId ?? "api";
8500
- const turnId = nanoid2(8);
8516
+ const turnId = body.turnId ?? nanoid2(8);
8501
8517
  deps.core.eventBus.emit(BusEvent.MESSAGE_QUEUED, {
8502
8518
  sessionId,
8503
8519
  turnId,
@@ -19310,6 +19326,12 @@ function resolveAgentCommand(cmd) {
19310
19326
  }
19311
19327
  } catch {
19312
19328
  }
19329
+ if (cmd === "npx" || cmd === "uvx") {
19330
+ const sibling = path44.join(path44.dirname(process.execPath), cmd);
19331
+ if (fs40.existsSync(sibling)) {
19332
+ return { command: sibling, args: [] };
19333
+ }
19334
+ }
19313
19335
  return { command: cmd, args: [] };
19314
19336
  }
19315
19337
  var log31, AgentInstance;
@@ -22722,7 +22744,7 @@ var init_agent_catalog = __esm({
22722
22744
  description: agent.description,
22723
22745
  distribution: dist?.type ?? "binary",
22724
22746
  installed: false,
22725
- available: dist !== null && availability.available,
22747
+ available: dist !== null,
22726
22748
  missingDeps: availability.missing?.map((m) => m.label)
22727
22749
  });
22728
22750
  }