@openacp/cli 2026.326.4 → 2026.327.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.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/dist/{adapter-77ZCVABT.js → adapter-IZNL6AK2.js} +13 -13
  3. package/dist/{adapter-6ANPBSVU.js → adapter-Z435XYBQ.js} +2 -2
  4. package/dist/{api-server-CHVSUDBX.js → api-server-2I7B3MXR.js} +2 -2
  5. package/dist/{api-server-3PYLRBCN.js → api-server-5VEESFOT.js} +2 -2
  6. package/dist/{chunk-Y64XWMJ4.js → chunk-366FOUJG.js} +2 -2
  7. package/dist/{chunk-WVLDNYOJ.js → chunk-5RO42TWV.js} +2 -2
  8. package/dist/{chunk-UNJUWWQO.js → chunk-5YW56UJK.js} +1 -10
  9. package/dist/chunk-5YW56UJK.js.map +1 -0
  10. package/dist/{chunk-NBFIBGAT.js → chunk-7KGWYNWE.js} +1 -1
  11. package/dist/chunk-CDAUYTVP.js +41 -0
  12. package/dist/chunk-CDAUYTVP.js.map +1 -0
  13. package/dist/{chunk-Q6ZXJTZB.js → chunk-CFM4GJ74.js} +7 -11
  14. package/dist/chunk-CFM4GJ74.js.map +1 -0
  15. package/dist/{chunk-RKB2ZK6S.js → chunk-FDLQ5M6W.js} +17 -136
  16. package/dist/chunk-FDLQ5M6W.js.map +1 -0
  17. package/dist/{chunk-FQEBWOZR.js → chunk-QUXTZU36.js} +45 -126
  18. package/dist/chunk-QUXTZU36.js.map +1 -0
  19. package/dist/{chunk-QSDZDHNS.js → chunk-VO3A2NI4.js} +4 -4
  20. package/dist/{chunk-V5JT5TPD.js → chunk-ZPTM4NGK.js} +2 -2
  21. package/dist/cli.js +145 -46
  22. package/dist/cli.js.map +1 -1
  23. package/dist/{config-editor-HNEKXRLQ.js → config-editor-2GYL2SSZ.js} +2 -2
  24. package/dist/{core-plugins-VEUNFTMB.js → core-plugins-I6UPXQBL.js} +7 -10
  25. package/dist/{discord-NOJQ5PZO.js → discord-DXDTGVGS.js} +2 -2
  26. package/dist/index.d.ts +14 -62
  27. package/dist/index.js +15 -21
  28. package/dist/index.js.map +1 -1
  29. package/dist/{integrate-5C6KSU6D.js → integrate-APK4OEQF.js} +2 -2
  30. package/dist/integrate-APK4OEQF.js.map +1 -0
  31. package/dist/{main-T5WVCCFN.js → main-EJBK65NS.js} +33 -52
  32. package/dist/main-EJBK65NS.js.map +1 -0
  33. package/dist/{new-session-AVQCNXRG.js → new-session-HFO5GHSZ.js} +3 -3
  34. package/dist/plugin-create-LCXXNDK6.js +950 -0
  35. package/dist/plugin-create-LCXXNDK6.js.map +1 -0
  36. package/dist/plugin-search-HQ4WQKOF.js +40 -0
  37. package/dist/plugin-search-HQ4WQKOF.js.map +1 -0
  38. package/dist/{post-upgrade-XLHZ6ZB7.js → post-upgrade-2MG3VUDV.js} +2 -2
  39. package/dist/registry-client-AVGRE4CF.js +8 -0
  40. package/dist/{setup-BAI2F24H.js → setup-N7KT56O7.js} +7 -7
  41. package/dist/{telegram-ZDC3JQF2.js → telegram-QWMJU3A6.js} +2 -2
  42. package/package.json +2 -2
  43. package/dist/chunk-2CX4IEEC.js +0 -124
  44. package/dist/chunk-2CX4IEEC.js.map +0 -1
  45. package/dist/chunk-FQEBWOZR.js.map +0 -1
  46. package/dist/chunk-Q6ZXJTZB.js.map +0 -1
  47. package/dist/chunk-RKB2ZK6S.js.map +0 -1
  48. package/dist/chunk-UNJUWWQO.js.map +0 -1
  49. package/dist/chunk-WAAD23KY.js +0 -222
  50. package/dist/chunk-WAAD23KY.js.map +0 -1
  51. package/dist/integrate-5C6KSU6D.js.map +0 -1
  52. package/dist/main-T5WVCCFN.js.map +0 -1
  53. package/dist/plugin-create-AQ3B22BZ.js +0 -334
  54. package/dist/plugin-create-AQ3B22BZ.js.map +0 -1
  55. package/dist/usage-WYNK6ZC5.js +0 -10
  56. /package/dist/{adapter-77ZCVABT.js.map → adapter-IZNL6AK2.js.map} +0 -0
  57. /package/dist/{adapter-6ANPBSVU.js.map → adapter-Z435XYBQ.js.map} +0 -0
  58. /package/dist/{api-server-3PYLRBCN.js.map → api-server-2I7B3MXR.js.map} +0 -0
  59. /package/dist/{api-server-CHVSUDBX.js.map → api-server-5VEESFOT.js.map} +0 -0
  60. /package/dist/{chunk-Y64XWMJ4.js.map → chunk-366FOUJG.js.map} +0 -0
  61. /package/dist/{chunk-WVLDNYOJ.js.map → chunk-5RO42TWV.js.map} +0 -0
  62. /package/dist/{chunk-NBFIBGAT.js.map → chunk-7KGWYNWE.js.map} +0 -0
  63. /package/dist/{chunk-QSDZDHNS.js.map → chunk-VO3A2NI4.js.map} +0 -0
  64. /package/dist/{chunk-V5JT5TPD.js.map → chunk-ZPTM4NGK.js.map} +0 -0
  65. /package/dist/{config-editor-HNEKXRLQ.js.map → config-editor-2GYL2SSZ.js.map} +0 -0
  66. /package/dist/{core-plugins-VEUNFTMB.js.map → core-plugins-I6UPXQBL.js.map} +0 -0
  67. /package/dist/{discord-NOJQ5PZO.js.map → discord-DXDTGVGS.js.map} +0 -0
  68. /package/dist/{new-session-AVQCNXRG.js.map → new-session-HFO5GHSZ.js.map} +0 -0
  69. /package/dist/{post-upgrade-XLHZ6ZB7.js.map → post-upgrade-2MG3VUDV.js.map} +0 -0
  70. /package/dist/{telegram-ZDC3JQF2.js.map → registry-client-AVGRE4CF.js.map} +0 -0
  71. /package/dist/{setup-BAI2F24H.js.map → setup-N7KT56O7.js.map} +0 -0
  72. /package/dist/{usage-WYNK6ZC5.js.map → telegram-QWMJU3A6.js.map} +0 -0
@@ -1261,33 +1261,6 @@ ${result.text}` : result.text;
1261
1261
  this.resume();
1262
1262
  }
1263
1263
  }
1264
- async generateSummary(timeoutMs = 15e3) {
1265
- let summary = "";
1266
- let timer;
1267
- const captureHandler = (event) => {
1268
- if (event.type === "text") summary += event.content;
1269
- };
1270
- this.pause((event) => event !== "agent_event");
1271
- this.agentInstance.on("agent_event", captureHandler);
1272
- try {
1273
- const promptPromise = this.agentInstance.prompt(
1274
- "Summarize what you've accomplished so far in this session in 2-3 sentences. Include: key files changed, decisions made, and current status. Reply ONLY with the summary, nothing else."
1275
- );
1276
- const timeoutPromise = new Promise((_, reject) => {
1277
- timer = setTimeout(() => reject(new Error("summary timeout")), timeoutMs);
1278
- });
1279
- await Promise.race([promptPromise, timeoutPromise]);
1280
- return summary.trim().slice(0, 500);
1281
- } catch {
1282
- this.log.warn("Failed to generate session summary");
1283
- return "";
1284
- } finally {
1285
- if (timer) clearTimeout(timer);
1286
- this.agentInstance.off("agent_event", captureHandler);
1287
- this.clearBuffer();
1288
- this.resume();
1289
- }
1290
- }
1291
1264
  /** Fire-and-forget warm-up: primes model cache while user types their first message */
1292
1265
  async warmup() {
1293
1266
  await this.queue.enqueue("\0__warmup__");
@@ -2080,7 +2053,6 @@ var MessageTransformer = class {
2080
2053
  };
2081
2054
 
2082
2055
  // src/core/sessions/session-factory.ts
2083
- import { nanoid as nanoid2 } from "nanoid";
2084
2056
  var log4 = createChildLogger({ module: "session-factory" });
2085
2057
  var SessionFactory = class {
2086
2058
  constructor(agentManager, sessionManager, speechServiceAccessor, eventBus) {
@@ -2145,35 +2117,17 @@ var SessionFactory = class {
2145
2117
  return session;
2146
2118
  }
2147
2119
  wireSideEffects(session, deps) {
2148
- if (deps.usageStore) {
2149
- const usageStore = deps.usageStore;
2150
- const usageBudget = deps.usageBudget;
2151
- const notificationManager = deps.notificationManager;
2152
- session.on("agent_event", (event) => {
2153
- if (event.type !== "usage") return;
2154
- const record = {
2155
- id: nanoid2(),
2156
- sessionId: session.id,
2157
- agentName: session.agentName,
2158
- tokensUsed: event.tokensUsed ?? 0,
2159
- contextSize: event.contextSize ?? 0,
2160
- cost: event.cost,
2161
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
2162
- };
2163
- usageStore.append(record);
2164
- if (usageBudget) {
2165
- const result = usageBudget.check();
2166
- if (result.message) {
2167
- notificationManager.notifyAll({
2168
- sessionId: session.id,
2169
- sessionName: session.name,
2170
- type: "budget_warning",
2171
- summary: result.message
2172
- });
2173
- }
2174
- }
2120
+ session.on("agent_event", (event) => {
2121
+ if (event.type !== "usage") return;
2122
+ deps.eventBus.emit("usage:recorded", {
2123
+ sessionId: session.id,
2124
+ agentName: session.agentName,
2125
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2126
+ tokensUsed: event.tokensUsed ?? 0,
2127
+ contextSize: event.contextSize ?? 0,
2128
+ cost: event.cost
2175
2129
  });
2176
- }
2130
+ });
2177
2131
  session.on("status_change", (_from, to) => {
2178
2132
  if ((to === "finished" || to === "cancelled") && deps.tunnelService) {
2179
2133
  deps.tunnelService.stopBySession(session.id).then((stopped) => {
@@ -2636,7 +2590,7 @@ function createPluginContext(opts) {
2636
2590
  } = opts;
2637
2591
  const registeredListeners = [];
2638
2592
  const registeredCommands = [];
2639
- const log7 = opts.log ?? {
2593
+ const noopLog = {
2640
2594
  trace() {
2641
2595
  },
2642
2596
  debug() {
@@ -2650,9 +2604,11 @@ function createPluginContext(opts) {
2650
2604
  fatal() {
2651
2605
  },
2652
2606
  child() {
2653
- return log7;
2607
+ return noopLog;
2654
2608
  }
2655
2609
  };
2610
+ const baseLog = opts.log ?? noopLog;
2611
+ const log7 = typeof baseLog.child === "function" ? baseLog.child({ plugin: pluginName }) : baseLog;
2656
2612
  const storageImpl = new PluginStorageImpl(storagePath);
2657
2613
  const storage = {
2658
2614
  async get(key) {
@@ -2714,6 +2670,7 @@ function createPluginContext(opts) {
2714
2670
  const registry = serviceRegistry.get("command-registry");
2715
2671
  if (registry && typeof registry.register === "function") {
2716
2672
  registry.register(def, pluginName);
2673
+ log7.debug(`Command '/${def.name}' registered`);
2717
2674
  }
2718
2675
  },
2719
2676
  async sendMessage(_sessionId, _content) {
@@ -2840,6 +2797,20 @@ var LifecycleManager = class {
2840
2797
  this.settingsManager = opts?.settingsManager;
2841
2798
  this.pluginRegistry = opts?.pluginRegistry;
2842
2799
  }
2800
+ getPluginLogger(pluginName) {
2801
+ if (this.log && typeof this.log.child === "function") {
2802
+ return this.log.child({ plugin: pluginName });
2803
+ }
2804
+ return this.log ?? { trace() {
2805
+ }, debug() {
2806
+ }, info() {
2807
+ }, warn() {
2808
+ }, error() {
2809
+ }, fatal() {
2810
+ }, child() {
2811
+ return this;
2812
+ } };
2813
+ }
2843
2814
  async boot(plugins) {
2844
2815
  let sorted;
2845
2816
  try {
@@ -2850,7 +2821,14 @@ var LifecycleManager = class {
2850
2821
  }
2851
2822
  return;
2852
2823
  }
2853
- this.loadOrder = sorted;
2824
+ for (const p of sorted) {
2825
+ if (!this.loadOrder.some((existing) => existing.name === p.name)) {
2826
+ this.loadOrder.push(p);
2827
+ } else {
2828
+ const idx = this.loadOrder.findIndex((existing) => existing.name === p.name);
2829
+ this.loadOrder[idx] = p;
2830
+ }
2831
+ }
2854
2832
  for (const plugin of sorted) {
2855
2833
  if (plugin.pluginDependencies) {
2856
2834
  const depFailed = Object.keys(plugin.pluginDependencies).some(
@@ -2869,10 +2847,11 @@ var LifecycleManager = class {
2869
2847
  if (registryEntry && plugin.migrate && registryEntry.version !== plugin.version && this.settingsManager) {
2870
2848
  try {
2871
2849
  const oldSettings = await this.settingsManager.loadSettings(plugin.name);
2850
+ const pluginLog = this.getPluginLogger(plugin.name);
2872
2851
  const migrateCtx = {
2873
2852
  pluginName: plugin.name,
2874
2853
  settings: this.settingsManager.createAPI(plugin.name),
2875
- log: this.log?.child?.({ plugin: plugin.name }) ?? this.log ?? console
2854
+ log: pluginLog
2876
2855
  };
2877
2856
  const newSettings = await plugin.migrate(migrateCtx, oldSettings, registryEntry.version);
2878
2857
  if (newSettings && typeof newSettings === "object") {
@@ -2881,8 +2860,7 @@ var LifecycleManager = class {
2881
2860
  this.pluginRegistry.updateVersion(plugin.name, plugin.version);
2882
2861
  await this.pluginRegistry.save();
2883
2862
  } catch (err) {
2884
- const childLog = this.log?.child?.({ plugin: plugin.name });
2885
- (childLog ?? this.log ?? console).warn?.({ err }, "Migration failed, continuing with old settings");
2863
+ this.getPluginLogger(plugin.name).warn(`Migration failed, continuing with old settings: ${err}`);
2886
2864
  }
2887
2865
  }
2888
2866
  let pluginConfig;
@@ -2916,6 +2894,7 @@ var LifecycleManager = class {
2916
2894
  } catch (err) {
2917
2895
  this._failed.add(plugin.name);
2918
2896
  ctx.cleanup();
2897
+ this.getPluginLogger(plugin.name).error(`setup() failed: ${err}`);
2919
2898
  this.eventBus?.emit("plugin:failed", { name: plugin.name, error: String(err) });
2920
2899
  }
2921
2900
  }
@@ -2994,14 +2973,6 @@ var OpenACPCore = class {
2994
2973
  get contextManager() {
2995
2974
  return this.lifecycleManager.serviceRegistry.get("context");
2996
2975
  }
2997
- get usageStore() {
2998
- const usage = this.lifecycleManager.serviceRegistry.get("usage");
2999
- return usage?.store ?? null;
3000
- }
3001
- get usageBudget() {
3002
- const usage = this.lifecycleManager.serviceRegistry.get("usage");
3003
- return usage?.budget ?? null;
3004
- }
3005
2976
  constructor(configManager) {
3006
2977
  this.configManager = configManager;
3007
2978
  const config = configManager.get();
@@ -3031,7 +3002,8 @@ var OpenACPCore = class {
3031
3002
  sessions: this.sessionManager,
3032
3003
  config: this.configManager,
3033
3004
  core: this,
3034
- storagePath: path4.join(os.homedir(), ".openacp", "plugins", "data")
3005
+ storagePath: path4.join(os.homedir(), ".openacp", "plugins", "data"),
3006
+ log: createChildLogger({ module: "plugin" })
3035
3007
  });
3036
3008
  this.sessionFactory.middlewareChain = this.lifecycleManager.middlewareChain;
3037
3009
  this.sessionManager.middlewareChain = this.lifecycleManager.middlewareChain;
@@ -3089,58 +3061,6 @@ var OpenACPCore = class {
3089
3061
  for (const adapter of this.adapters.values()) {
3090
3062
  await adapter.stop();
3091
3063
  }
3092
- if (this.usageStore) {
3093
- this.usageStore.destroy();
3094
- }
3095
- }
3096
- // --- Summary ---
3097
- async summarizeSession(sessionId) {
3098
- const session = this.sessionManager.getSession(sessionId);
3099
- if (session && session.status === "active") {
3100
- try {
3101
- const summary = await session.generateSummary();
3102
- if (!summary) return { ok: false, error: "Agent could not generate summary" };
3103
- return { ok: true, summary };
3104
- } catch (err) {
3105
- return { ok: false, error: err.message };
3106
- }
3107
- }
3108
- const record = this.sessionManager.getSessionRecord(sessionId);
3109
- if (!record?.agentSessionId) {
3110
- return { ok: false, error: "Session not found or has no agent history" };
3111
- }
3112
- const caps = getAgentCapabilities(record.agentName);
3113
- if (!caps.supportsResume) {
3114
- return { ok: false, error: `Agent "${record.agentName}" does not support resume \u2014 cannot summarize ended session` };
3115
- }
3116
- let tempSession;
3117
- try {
3118
- const agentInstance = await this.agentManager.resume(
3119
- record.agentName,
3120
- record.workingDir,
3121
- record.agentSessionId
3122
- );
3123
- tempSession = new Session({
3124
- id: `summary-${sessionId}`,
3125
- channelId: record.channelId,
3126
- agentName: record.agentName,
3127
- workingDirectory: record.workingDir,
3128
- agentInstance
3129
- });
3130
- tempSession.activate();
3131
- const summary = await tempSession.generateSummary();
3132
- if (!summary) return { ok: false, error: "Agent could not generate summary" };
3133
- return { ok: true, summary };
3134
- } catch (err) {
3135
- return { ok: false, error: err.message };
3136
- } finally {
3137
- if (tempSession) {
3138
- try {
3139
- await tempSession.destroy();
3140
- } catch {
3141
- }
3142
- }
3143
- }
3144
3064
  }
3145
3065
  // --- Archive ---
3146
3066
  async archiveSession(sessionId) {
@@ -3240,8 +3160,7 @@ var OpenACPCore = class {
3240
3160
  bridge.connect();
3241
3161
  }
3242
3162
  this.sessionFactory.wireSideEffects(session, {
3243
- usageStore: this.usageStore,
3244
- usageBudget: this.usageBudget,
3163
+ eventBus: this.eventBus,
3245
3164
  notificationManager: this.notificationManager,
3246
3165
  tunnelService: this._tunnelService
3247
3166
  });
@@ -3554,4 +3473,4 @@ export {
3554
3473
  EventBus,
3555
3474
  OpenACPCore
3556
3475
  };
3557
- //# sourceMappingURL=chunk-FQEBWOZR.js.map
3476
+ //# sourceMappingURL=chunk-QUXTZU36.js.map