@openacp/cli 2026.327.1 → 2026.327.3

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 (119) hide show
  1. package/dist/{adapter-Z435XYBQ.js → adapter-LC2QSDAS.js} +4 -5
  2. package/dist/{adapter-PQGHVG4K.js → adapter-Y55NXX6I.js} +2 -2
  3. package/dist/{api-server-5VEESFOT.js → api-server-7G3ZUZRM.js} +2 -2
  4. package/dist/{api-server-2I7B3MXR.js → api-server-CAYNPUF2.js} +2 -2
  5. package/dist/{chunk-5YW56UJK.js → chunk-2YCW3QDV.js} +21 -5
  6. package/dist/chunk-2YCW3QDV.js.map +1 -0
  7. package/dist/{chunk-366FOUJG.js → chunk-36YQ44D7.js} +2 -2
  8. package/dist/{chunk-UB2QB6DE.js → chunk-3ASUU6WW.js} +2 -2
  9. package/dist/{chunk-ZPTM4NGK.js → chunk-4GMLGCF2.js} +2 -2
  10. package/dist/{chunk-CFM4GJ74.js → chunk-HUWOFP2H.js} +7 -11
  11. package/dist/chunk-HUWOFP2H.js.map +1 -0
  12. package/dist/{chunk-P4SNGQNI.js → chunk-KMMEFXIE.js} +2 -2
  13. package/dist/{chunk-FDLQ5M6W.js → chunk-LP45RCA4.js} +568 -23
  14. package/dist/chunk-LP45RCA4.js.map +1 -0
  15. package/dist/{chunk-L7YNNBI5.js → chunk-QAQDGPB4.js} +1 -75
  16. package/dist/chunk-QAQDGPB4.js.map +1 -0
  17. package/dist/{chunk-V2M243KZ.js → chunk-TRXBJEZ5.js} +55 -53
  18. package/dist/chunk-TRXBJEZ5.js.map +1 -0
  19. package/dist/{chunk-7KGWYNWE.js → chunk-UMT7RU77.js} +45 -118
  20. package/dist/chunk-UMT7RU77.js.map +1 -0
  21. package/dist/{chunk-QUXTZU36.js → chunk-XIBG7LSL.js} +137 -3
  22. package/dist/chunk-XIBG7LSL.js.map +1 -0
  23. package/dist/cli.js +24 -17
  24. package/dist/cli.js.map +1 -1
  25. package/dist/{config-editor-2GYL2SSZ.js → config-editor-3IKBPZA7.js} +2 -2
  26. package/dist/{core-plugins-I6UPXQBL.js → core-plugins-ROU4GPLT.js} +6 -7
  27. package/dist/{dev-loader-RDC5E2CW.js → dev-loader-DRU3R7ZM.js} +7 -18
  28. package/dist/dev-loader-DRU3R7ZM.js.map +1 -0
  29. package/dist/{doctor-H72BZOPA.js → doctor-QZQAP46W.js} +2 -2
  30. package/dist/index.d.ts +115 -5
  31. package/dist/index.js +45 -18
  32. package/dist/index.js.map +1 -1
  33. package/dist/{integrate-APK4OEQF.js → integrate-G6CVXTGT.js} +2 -3
  34. package/dist/integrate-G6CVXTGT.js.map +1 -0
  35. package/dist/{main-EJBK65NS.js → main-UVTZ46WP.js} +20 -147
  36. package/dist/main-UVTZ46WP.js.map +1 -0
  37. package/dist/{plugin-create-LCXXNDK6.js → plugin-create-5HQRF2ID.js} +19 -2
  38. package/dist/plugin-create-5HQRF2ID.js.map +1 -0
  39. package/dist/plugin-installer-GQ2P3Q3E.js +23 -0
  40. package/dist/plugin-installer-GQ2P3Q3E.js.map +1 -0
  41. package/dist/{post-upgrade-2MG3VUDV.js → post-upgrade-3ADZRMYJ.js} +2 -2
  42. package/dist/{setup-N7KT56O7.js → setup-EYAFK2WI.js} +77 -50
  43. package/dist/setup-EYAFK2WI.js.map +1 -0
  44. package/dist/{slack-KH7E3VBS.js → slack-37ZWBDUI.js} +2 -2
  45. package/dist/{telegram-QWMJU3A6.js → telegram-2ZCCCZIY.js} +2 -2
  46. package/dist/{tunnel-M47I7H4B.js → tunnel-45HA72MB.js} +2 -2
  47. package/dist/{tunnel-service-WADYHREX.js → tunnel-service-QJPUYEKU.js} +11 -3
  48. package/dist/tunnel-service-QJPUYEKU.js.map +1 -0
  49. package/package.json +1 -2
  50. package/dist/action-detect-QPA775HB.js +0 -16
  51. package/dist/adapter-IZNL6AK2.js +0 -2394
  52. package/dist/adapter-IZNL6AK2.js.map +0 -1
  53. package/dist/admin-GBPZFFAU.js +0 -23
  54. package/dist/agents-BWU4MRRD.js +0 -15
  55. package/dist/chunk-4KGLKKQK.js +0 -298
  56. package/dist/chunk-4KGLKKQK.js.map +0 -1
  57. package/dist/chunk-5RO42TWV.js +0 -150
  58. package/dist/chunk-5RO42TWV.js.map +0 -1
  59. package/dist/chunk-5YW56UJK.js.map +0 -1
  60. package/dist/chunk-5ZOFBTOR.js +0 -553
  61. package/dist/chunk-5ZOFBTOR.js.map +0 -1
  62. package/dist/chunk-6RXVEXF3.js +0 -23
  63. package/dist/chunk-6RXVEXF3.js.map +0 -1
  64. package/dist/chunk-7KGWYNWE.js.map +0 -1
  65. package/dist/chunk-CFM4GJ74.js.map +0 -1
  66. package/dist/chunk-FDLQ5M6W.js.map +0 -1
  67. package/dist/chunk-GJOY37U7.js +0 -265
  68. package/dist/chunk-GJOY37U7.js.map +0 -1
  69. package/dist/chunk-HVBNCPAY.js +0 -71
  70. package/dist/chunk-HVBNCPAY.js.map +0 -1
  71. package/dist/chunk-I3CGU5W7.js +0 -134
  72. package/dist/chunk-I3CGU5W7.js.map +0 -1
  73. package/dist/chunk-L7YNNBI5.js.map +0 -1
  74. package/dist/chunk-MTSDOSXS.js +0 -219
  75. package/dist/chunk-MTSDOSXS.js.map +0 -1
  76. package/dist/chunk-NAM4ERUW.js +0 -203
  77. package/dist/chunk-NAM4ERUW.js.map +0 -1
  78. package/dist/chunk-O5RG4YZY.js +0 -122
  79. package/dist/chunk-O5RG4YZY.js.map +0 -1
  80. package/dist/chunk-QUXTZU36.js.map +0 -1
  81. package/dist/chunk-V2M243KZ.js.map +0 -1
  82. package/dist/chunk-VO3A2NI4.js +0 -145
  83. package/dist/chunk-VO3A2NI4.js.map +0 -1
  84. package/dist/dev-loader-RDC5E2CW.js.map +0 -1
  85. package/dist/discord-DXDTGVGS.js +0 -8
  86. package/dist/doctor-H72BZOPA.js.map +0 -1
  87. package/dist/doctor-RF6BHMCC.js +0 -15
  88. package/dist/doctor-RF6BHMCC.js.map +0 -1
  89. package/dist/integrate-APK4OEQF.js.map +0 -1
  90. package/dist/main-EJBK65NS.js.map +0 -1
  91. package/dist/new-session-HFO5GHSZ.js +0 -17
  92. package/dist/new-session-HFO5GHSZ.js.map +0 -1
  93. package/dist/plugin-create-LCXXNDK6.js.map +0 -1
  94. package/dist/session-KZFA6Z26.js +0 -20
  95. package/dist/session-KZFA6Z26.js.map +0 -1
  96. package/dist/settings-MFYM7CZO.js +0 -14
  97. package/dist/settings-MFYM7CZO.js.map +0 -1
  98. package/dist/setup-N7KT56O7.js.map +0 -1
  99. package/dist/slack-KH7E3VBS.js.map +0 -1
  100. package/dist/telegram-QWMJU3A6.js.map +0 -1
  101. package/dist/tunnel-M47I7H4B.js.map +0 -1
  102. package/dist/tunnel-service-WADYHREX.js.map +0 -1
  103. package/dist/validators-6CLEZUBD.js +0 -8
  104. package/dist/validators-6CLEZUBD.js.map +0 -1
  105. /package/dist/{action-detect-QPA775HB.js.map → adapter-LC2QSDAS.js.map} +0 -0
  106. /package/dist/{adapter-PQGHVG4K.js.map → adapter-Y55NXX6I.js.map} +0 -0
  107. /package/dist/{adapter-Z435XYBQ.js.map → api-server-7G3ZUZRM.js.map} +0 -0
  108. /package/dist/{admin-GBPZFFAU.js.map → api-server-CAYNPUF2.js.map} +0 -0
  109. /package/dist/{chunk-366FOUJG.js.map → chunk-36YQ44D7.js.map} +0 -0
  110. /package/dist/{chunk-UB2QB6DE.js.map → chunk-3ASUU6WW.js.map} +0 -0
  111. /package/dist/{chunk-ZPTM4NGK.js.map → chunk-4GMLGCF2.js.map} +0 -0
  112. /package/dist/{chunk-P4SNGQNI.js.map → chunk-KMMEFXIE.js.map} +0 -0
  113. /package/dist/{agents-BWU4MRRD.js.map → config-editor-3IKBPZA7.js.map} +0 -0
  114. /package/dist/{api-server-2I7B3MXR.js.map → core-plugins-ROU4GPLT.js.map} +0 -0
  115. /package/dist/{api-server-5VEESFOT.js.map → doctor-QZQAP46W.js.map} +0 -0
  116. /package/dist/{post-upgrade-2MG3VUDV.js.map → post-upgrade-3ADZRMYJ.js.map} +0 -0
  117. /package/dist/{config-editor-2GYL2SSZ.js.map → slack-37ZWBDUI.js.map} +0 -0
  118. /package/dist/{core-plugins-I6UPXQBL.js.map → telegram-2ZCCCZIY.js.map} +0 -0
  119. /package/dist/{discord-DXDTGVGS.js.map → tunnel-45HA72MB.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runConfigEditor
3
- } from "./chunk-7KGWYNWE.js";
3
+ } from "./chunk-UMT7RU77.js";
4
4
  import "./chunk-PPSMUECX.js";
5
5
  import "./chunk-QVMEF6FB.js";
6
6
  import "./chunk-XMMAGAT4.js";
@@ -8,4 +8,4 @@ import "./chunk-VUNV25KB.js";
8
8
  export {
9
9
  runConfigEditor
10
10
  };
11
- //# sourceMappingURL=config-editor-2GYL2SSZ.js.map
11
+ //# sourceMappingURL=config-editor-3IKBPZA7.js.map
@@ -1,12 +1,11 @@
1
1
  import {
2
2
  corePlugins
3
- } from "./chunk-CFM4GJ74.js";
4
- import "./chunk-UB2QB6DE.js";
5
- import "./chunk-5RO42TWV.js";
6
- import "./chunk-366FOUJG.js";
3
+ } from "./chunk-HUWOFP2H.js";
4
+ import "./chunk-36YQ44D7.js";
5
+ import "./chunk-3ASUU6WW.js";
7
6
  import "./chunk-SNPYTMPR.js";
8
- import "./chunk-P4SNGQNI.js";
9
- import "./chunk-ZPTM4NGK.js";
7
+ import "./chunk-KMMEFXIE.js";
8
+ import "./chunk-4GMLGCF2.js";
10
9
  import "./chunk-5OCGO27U.js";
11
10
  import "./chunk-YEULD3SG.js";
12
11
  import "./chunk-ZHGPZBS4.js";
@@ -21,4 +20,4 @@ import "./chunk-VUNV25KB.js";
21
20
  export {
22
21
  corePlugins
23
22
  };
24
- //# sourceMappingURL=core-plugins-I6UPXQBL.js.map
23
+ //# sourceMappingURL=core-plugins-ROU4GPLT.js.map
@@ -3,7 +3,6 @@ import "./chunk-VUNV25KB.js";
3
3
  // src/core/plugin/dev-loader.ts
4
4
  import fs from "fs";
5
5
  import path from "path";
6
- import os from "os";
7
6
  var loadCounter = 0;
8
7
  var DevPluginLoader = class {
9
8
  pluginPath;
@@ -19,23 +18,13 @@ var DevPluginLoader = class {
19
18
  if (!fs.existsSync(distIndex)) {
20
19
  throw new Error(`Built plugin not found at ${distIndex}. Run 'npm run build' first.`);
21
20
  }
22
- const tmpDir = path.join(os.tmpdir(), "openacp-dev-loader");
23
- fs.mkdirSync(tmpDir, { recursive: true });
24
- const tmpFile = path.join(tmpDir, `plugin-${Date.now()}-${++loadCounter}.mjs`);
25
- fs.copyFileSync(distIndex, tmpFile);
26
- try {
27
- const mod = await import(`file://${tmpFile}`);
28
- const plugin = mod.default;
29
- if (!plugin || !plugin.name || !plugin.setup) {
30
- throw new Error(`Invalid plugin at ${distIndex}. Must export default OpenACPPlugin with name and setup().`);
31
- }
32
- return plugin;
33
- } finally {
34
- try {
35
- fs.unlinkSync(tmpFile);
36
- } catch {
37
- }
21
+ const cacheBuster = `v=${Date.now()}-${++loadCounter}`;
22
+ const mod = await import(`file://${distIndex}?${cacheBuster}`);
23
+ const plugin = mod.default;
24
+ if (!plugin || !plugin.name || !plugin.setup) {
25
+ throw new Error(`Invalid plugin at ${distIndex}. Must export default OpenACPPlugin with name and setup().`);
38
26
  }
27
+ return plugin;
39
28
  }
40
29
  getPluginPath() {
41
30
  return this.pluginPath;
@@ -47,4 +36,4 @@ var DevPluginLoader = class {
47
36
  export {
48
37
  DevPluginLoader
49
38
  };
50
- //# sourceMappingURL=dev-loader-RDC5E2CW.js.map
39
+ //# sourceMappingURL=dev-loader-DRU3R7ZM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/plugin/dev-loader.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport type { OpenACPPlugin } from './types.js'\n\nlet loadCounter = 0\n\nexport class DevPluginLoader {\n private pluginPath: string\n\n constructor(pluginPath: string) {\n this.pluginPath = path.resolve(pluginPath)\n }\n\n async load(): Promise<OpenACPPlugin> {\n const distIndex = path.join(this.pluginPath, 'dist', 'index.js')\n const srcIndex = path.join(this.pluginPath, 'src', 'index.ts')\n\n if (!fs.existsSync(distIndex) && !fs.existsSync(srcIndex)) {\n throw new Error(`Plugin not found at ${this.pluginPath}. Expected dist/index.js or src/index.ts`)\n }\n\n if (!fs.existsSync(distIndex)) {\n throw new Error(`Built plugin not found at ${distIndex}. Run 'npm run build' first.`)\n }\n\n // Node.js caches ESM imports by URL. Use a unique query string to bust\n // the cache on each reload while keeping the file in its original directory\n // so that relative imports (e.g., './adapter.js') still resolve correctly.\n const cacheBuster = `v=${Date.now()}-${++loadCounter}`\n const mod = await import(`file://${distIndex}?${cacheBuster}`)\n const plugin = mod.default as OpenACPPlugin\n\n if (!plugin || !plugin.name || !plugin.setup) {\n throw new Error(`Invalid plugin at ${distIndex}. Must export default OpenACPPlugin with name and setup().`)\n }\n\n return plugin\n }\n\n getPluginPath(): string {\n return this.pluginPath\n }\n\n getDistPath(): string {\n return path.join(this.pluginPath, 'dist')\n }\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAGjB,IAAI,cAAc;AAEX,IAAM,kBAAN,MAAsB;AAAA,EACnB;AAAA,EAER,YAAY,YAAoB;AAC9B,SAAK,aAAa,KAAK,QAAQ,UAAU;AAAA,EAC3C;AAAA,EAEA,MAAM,OAA+B;AACnC,UAAM,YAAY,KAAK,KAAK,KAAK,YAAY,QAAQ,UAAU;AAC/D,UAAM,WAAW,KAAK,KAAK,KAAK,YAAY,OAAO,UAAU;AAE7D,QAAI,CAAC,GAAG,WAAW,SAAS,KAAK,CAAC,GAAG,WAAW,QAAQ,GAAG;AACzD,YAAM,IAAI,MAAM,uBAAuB,KAAK,UAAU,0CAA0C;AAAA,IAClG;AAEA,QAAI,CAAC,GAAG,WAAW,SAAS,GAAG;AAC7B,YAAM,IAAI,MAAM,6BAA6B,SAAS,8BAA8B;AAAA,IACtF;AAKA,UAAM,cAAc,KAAK,KAAK,IAAI,CAAC,IAAI,EAAE,WAAW;AACpD,UAAM,MAAM,MAAM,OAAO,UAAU,SAAS,IAAI,WAAW;AAC3D,UAAM,SAAS,IAAI;AAEnB,QAAI,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,OAAO,OAAO;AAC5C,YAAM,IAAI,MAAM,qBAAqB,SAAS,4DAA4D;AAAA,IAC5G;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,gBAAwB;AACtB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,cAAsB;AACpB,WAAO,KAAK,KAAK,KAAK,YAAY,MAAM;AAAA,EAC1C;AACF;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  DoctorEngine
3
- } from "./chunk-L7YNNBI5.js";
3
+ } from "./chunk-QAQDGPB4.js";
4
4
  import "./chunk-QVMEF6FB.js";
5
5
  import "./chunk-XMMAGAT4.js";
6
6
  import "./chunk-VUNV25KB.js";
7
7
  export {
8
8
  DoctorEngine
9
9
  };
10
- //# sourceMappingURL=doctor-H72BZOPA.js.map
10
+ //# sourceMappingURL=doctor-QZQAP46W.js.map
package/dist/index.d.ts CHANGED
@@ -272,10 +272,6 @@ interface UsageRecordEvent {
272
272
  currency: string;
273
273
  };
274
274
  }
275
- interface DiscordPlatformData {
276
- threadId: string;
277
- skillMsgId?: string;
278
- }
279
275
  interface SessionMode {
280
276
  id: string;
281
277
  name: string;
@@ -2414,6 +2410,94 @@ declare class OpenACPCore {
2414
2410
  createBridge(session: Session, adapter: IChannelAdapter): SessionBridge;
2415
2411
  }
2416
2412
 
2413
+ interface RegisteredCommand extends CommandDef {
2414
+ /** Scope extracted from pluginName, e.g. '@openacp/speech' → 'speech' */
2415
+ scope?: string;
2416
+ }
2417
+ /**
2418
+ * Central command registry with namespace resolution and adapter-specific overrides.
2419
+ *
2420
+ * Namespace rules:
2421
+ * - System commands always own the short name.
2422
+ * - Among plugins, the first to register wins the short name.
2423
+ * - Every plugin command also gets a qualified name: `scope:name`.
2424
+ * - Adapter plugins (@openacp/telegram, @openacp/discord, @openacp/slack)
2425
+ * registering a command that already exists → stored as an override
2426
+ * keyed by `channelId:commandName`, used when channelId matches.
2427
+ */
2428
+ declare class CommandRegistry {
2429
+ /** Main registry: short names + qualified names → RegisteredCommand */
2430
+ private commands;
2431
+ /** Adapter-specific overrides: `channelId:commandName` → RegisteredCommand */
2432
+ private overrides;
2433
+ private static ADAPTER_SCOPES;
2434
+ /**
2435
+ * Register a command definition.
2436
+ * @param def - Command definition
2437
+ * @param pluginName - Plugin that owns the command (set automatically by PluginContext)
2438
+ */
2439
+ register(def: CommandDef, pluginName?: string): void;
2440
+ /** Retrieve a command by name (short or qualified). */
2441
+ get(name: string): RegisteredCommand | undefined;
2442
+ /** Remove a command by short name. Also removes its qualified name entry. */
2443
+ unregister(name: string): void;
2444
+ /** Remove all commands registered by a given plugin. */
2445
+ unregisterByPlugin(pluginName: string): void;
2446
+ /** Return all unique commands (deduplicated — each command appears once). */
2447
+ getAll(): RegisteredCommand[];
2448
+ /** Filter commands by category. */
2449
+ getByCategory(category: 'system' | 'plugin'): RegisteredCommand[];
2450
+ /**
2451
+ * Parse and execute a command string.
2452
+ * @param commandString - Full command string, e.g. "/greet hello world"
2453
+ * @param baseArgs - Base arguments (channelId, userId, etc.)
2454
+ * @returns CommandResponse
2455
+ */
2456
+ execute(commandString: string, baseArgs: CommandArgs): Promise<CommandResponse>;
2457
+ /** Extract scope from plugin name: '@openacp/speech' → 'speech', 'my-plugin' → 'my-plugin' */
2458
+ static extractScope(pluginName: string): string;
2459
+ }
2460
+
2461
+ interface CheckResult {
2462
+ status: "pass" | "warn" | "fail";
2463
+ message: string;
2464
+ fixable?: boolean;
2465
+ fixRisk?: "safe" | "risky";
2466
+ fix?: () => Promise<FixResult>;
2467
+ }
2468
+ interface FixResult {
2469
+ success: boolean;
2470
+ message: string;
2471
+ }
2472
+ interface DoctorReport {
2473
+ categories: CategoryResult[];
2474
+ summary: {
2475
+ passed: number;
2476
+ warnings: number;
2477
+ failed: number;
2478
+ fixed: number;
2479
+ };
2480
+ pendingFixes: PendingFix[];
2481
+ }
2482
+ interface CategoryResult {
2483
+ name: string;
2484
+ results: CheckResult[];
2485
+ }
2486
+ interface PendingFix {
2487
+ category: string;
2488
+ message: string;
2489
+ fix: () => Promise<FixResult>;
2490
+ }
2491
+
2492
+ declare class DoctorEngine {
2493
+ private dryRun;
2494
+ constructor(options?: {
2495
+ dryRun?: boolean;
2496
+ });
2497
+ runAll(): Promise<DoctorReport>;
2498
+ private buildContext;
2499
+ }
2500
+
2417
2501
  interface ConfigFieldDef {
2418
2502
  path: string;
2419
2503
  displayName: string;
@@ -2596,6 +2680,8 @@ declare class EntireProvider implements ContextProvider {
2596
2680
  }
2597
2681
 
2598
2682
  type DisplayVerbosity = "low" | "medium" | "high";
2683
+ declare const STATUS_ICONS: Record<string, string>;
2684
+ declare const KIND_ICONS: Record<string, string>;
2599
2685
  interface ViewerLinks {
2600
2686
  file?: string;
2601
2687
  diff?: string;
@@ -2613,6 +2699,9 @@ interface ToolCallMeta {
2613
2699
  displayTitle?: string;
2614
2700
  displayKind?: string;
2615
2701
  }
2702
+ interface ToolUpdateMeta extends ToolCallMeta {
2703
+ status: string;
2704
+ }
2616
2705
 
2617
2706
  interface RenderedMessage<TComponents = unknown> {
2618
2707
  body: string;
@@ -2839,6 +2928,27 @@ declare class ActivityTracker {
2839
2928
  private stopRefresh;
2840
2929
  }
2841
2930
 
2931
+ declare function progressBar(ratio: number, length?: number): string;
2932
+ declare function formatTokens(n: number): string;
2933
+ declare function stripCodeFences(text: string): string;
2934
+ declare function truncateContent(text: string, maxLen: number): string;
2935
+ declare function splitMessage(text: string, maxLength: number): string[];
2936
+
2937
+ declare function extractContentText(content: unknown, depth?: number): string;
2938
+ declare function formatToolSummary(name: string, rawInput: unknown, displaySummary?: string): string;
2939
+ declare function formatToolTitle(name: string, rawInput: unknown, displayTitle?: string): string;
2940
+ declare function resolveToolIcon(tool: {
2941
+ status?: string;
2942
+ displayKind?: string;
2943
+ kind?: string;
2944
+ }): string;
2945
+
2946
+ /**
2947
+ * OpenACP Product Guide — comprehensive reference for the AI assistant.
2948
+ * The assistant reads this at runtime to answer user questions about features.
2949
+ */
2950
+ declare const PRODUCT_GUIDE = "\n# OpenACP \u2014 Product Guide\n\nOpenACP lets you chat with AI coding agents (like Claude Code) through messaging platforms (Telegram, Discord).\nYou type messages in your chat platform, the agent reads/writes/runs code in your project folder, and results stream back in real time.\n\n---\n\n## Quick Start\n\n1. Start OpenACP: `openacp` (or `openacp start` for background daemon)\n2. Open your messaging platform (Telegram group or Discord server) \u2014 you'll see the Assistant topic/thread\n3. Tap/click \uD83C\uDD95 New Session or type /new\n4. Pick an agent and a project folder\n5. Chat in the session topic/thread \u2014 the agent works on your code\n\n---\n\n## Core Concepts\n\n### Sessions\nA session = one conversation with one AI agent working in one project folder.\nEach session gets its own topic (Telegram) or forum thread (Discord). Chat there to give instructions to the agent.\n\n### Agents\nAn agent is an AI coding tool (e.g., Claude Code, Gemini, Cursor, Codex, etc.).\nOpenACP supports 28+ agents from the official ACP Registry (agentclientprotocol.com).\nYou can install multiple agents and choose which one to use per session.\nThe default agent is used when you don't specify one.\n\n### Agent Management\n- Browse agents: `/agents` in your chat platform or `openacp agents` in CLI\n- Install: tap the install button in /agents, or `openacp agents install <name>`\n- Uninstall: `openacp agents uninstall <name>`\n- Setup/login: `openacp agents run <name> -- <args>` (e.g., `openacp agents run gemini -- auth login`)\n- Details: `openacp agents info <name>` shows version, dependencies, and setup steps\n\nSome agents need additional setup before they can be used:\n- Claude: requires `claude login`\n- Gemini: requires `openacp agents run gemini -- auth login`\n- Codex: requires setting `OPENAI_API_KEY` environment variable\n- GitHub Copilot: requires `openacp agents run copilot -- auth login`\n\nAgents are installed in three ways depending on the agent:\n- **npx** \u2014 Node.js agents, downloaded automatically on first use\n- **uvx** \u2014 Python agents, downloaded automatically on first use\n- **binary** \u2014 Platform-specific binaries, downloaded to `~/.openacp/agents/`\n\n### Project Folder (Workspace)\nThe directory where the agent reads, writes, and runs code.\nWhen creating a session, you choose which folder the agent works in.\nYou can type a full path like `~/code/my-project` or just a name like `my-project` (it becomes `<base-dir>/my-project`).\n\n### System Topics\n- **Assistant** \u2014 Always-on helper that can answer questions, create sessions, check status, troubleshoot\n- **Notifications** \u2014 System alerts (permission requests, session errors, completions)\n\n---\n\n## Creating Sessions\n\n### From menu\nTap \uD83C\uDD95 New Session \u2192 choose agent (if multiple) \u2192 choose project folder \u2192 confirm\n\n### From command\n- `/new` \u2014 Interactive flow (asks agent + folder)\n- `/new claude ~/code/my-project` \u2014 Create directly with specific agent and folder\n\n### From Assistant topic\nJust ask: \"Create a session for my-project with claude\" \u2014 the assistant handles it\n\n### Quick new chat\n`/newchat` in a session topic \u2014 creates new session with same agent and folder as current one\n\n---\n\n## Working with Sessions\n\n### Chat\nType messages in the session topic. The agent responds with code changes, explanations, tool outputs.\n\n### What you see while the agent works\n- **\uD83D\uDCAD Thinking indicator** \u2014 Shows when the agent is reasoning, with elapsed time\n- **Text responses** \u2014 Streamed in real time, updated every few seconds\n- **Tool calls** \u2014 When the agent runs commands or edits files, you see tool name, input, status, and output\n- **\uD83D\uDCCB Plan card** \u2014 Visual task progress with completed/in-progress/pending items and progress bar\n- **\"View File\" / \"View Diff\" buttons** \u2014 Opens in browser with Monaco editor (requires tunnel)\n\n### Session lifecycle\n1. **Creating** \u2014 Topic created, agent spawning\n2. **Warming up** \u2014 Agent primes its cache (happens automatically, invisible to you)\n3. **Active** \u2014 Ready for your messages\n4. **Auto-naming** \u2014 After your first message, the session gets a descriptive name (agent summarizes in ~5 words). The topic title updates automatically.\n5. **Finished/Error** \u2014 Session completed or hit an error\n\n### Agent skills\nSome agents provide slash commands (e.g., /compact, /review). Available skills are pinned in the session topic.\n\n### Permission requests\nWhen the agent wants to run a command, it asks for permission.\nYou see buttons: \u2705 Allow, \u274C Reject (and sometimes \"Always Allow\").\nA notification also appears in the Notifications topic with a link to the request.\n\n### Dangerous mode\nAuto-approves ALL permission requests \u2014 the agent runs any command without asking.\n- Enable: `/enable_dangerous` or tap the \u2620\uFE0F button in the session\n- Disable: `/disable_dangerous` or tap the \uD83D\uDD10 button\n- \u26A0\uFE0F Use with caution \u2014 the agent can execute anything\n\n### Session timeout\nIdle sessions are automatically cancelled after a configurable timeout (default: 60 minutes).\nConfigure via `security.sessionTimeoutMinutes` in config.\n\n---\n\n## Session Transfer (Handoff)\n\n### Chat \u2192 Terminal\n1. Type `/handoff` in a session topic/thread\n2. You get a command like `claude --resume <SESSION_ID>`\n3. Copy and run it in your terminal \u2014 the session continues there with full conversation history\n\n### Terminal \u2192 Chat\n1. First time: run `openacp integrate claude` to install the handoff skill (one-time setup)\n2. In Claude Code, use the /openacp:handoff slash command\n3. The session appears as a new topic/thread and you can continue chatting there\n\n### How it works\n- The agent session ID is shared between platforms\n- Conversation history is preserved \u2014 pick up where you left off\n- The agent that supports resume (e.g., Claude with `--resume`) handles the actual transfer\n\n---\n\n## Managing Sessions\n\n### Status\n- `/status` \u2014 Shows active sessions count and details\n- Ask the Assistant: \"What sessions are running?\"\n\n### List all sessions\n- `/sessions` \u2014 Shows all sessions with status (active, finished, error)\n\n### Cancel\n- `/cancel` in a session topic \u2014 cancels that session\n- Ask the Assistant: \"Cancel the stuck session\"\n\n### Cleanup\n- From `/sessions` \u2192 tap cleanup buttons (finished, errors, all)\n- Ask the Assistant: \"Clean up old sessions\"\n\n---\n\n## Assistant Topic\n\nThe Assistant is an always-on AI helper in its own topic. It can:\n- Answer questions about OpenACP\n- Create sessions for you\n- Check status and health\n- Cancel sessions\n- Clean up old sessions\n- Troubleshoot issues\n- Manage configuration\n\nJust chat naturally: \"How do I create a session?\", \"What's the status?\", \"Something is stuck\"\n\n### Clear history\n`/clear` in the Assistant topic \u2014 resets the conversation\n\n---\n\n## System Commands\n\n| Command | Where | What it does |\n|---------|-------|-------------|\n| `/new [agent] [path]` | Anywhere | Create new session |\n| `/newchat` | Session topic | New session, same agent + folder |\n| `/cancel` | Session topic | Cancel current session |\n| `/status` | Anywhere | Show status |\n| `/sessions` | Anywhere | List all sessions |\n| `/agents` | Anywhere | Browse & install agents from ACP Registry |\n| `/install <name>` | Anywhere | Install an agent |\n| `/enable_dangerous` | Session topic | Auto-approve all permissions |\n| `/disable_dangerous` | Session topic | Restore permission prompts |\n| `/handoff` | Session topic | Transfer session to terminal |\n| `/clear` | Assistant topic | Clear assistant history |\n| `/menu` | Anywhere | Show action menu |\n| `/help` | Anywhere | Show help |\n| `/restart` | Anywhere | Restart OpenACP |\n| `/update` | Anywhere | Update to latest version |\n| `/integrate` | Anywhere | Manage agent integrations |\n\n---\n\n## Menu Buttons\n\n| Button | Action |\n|--------|--------|\n| \uD83C\uDD95 New Session | Create new session (interactive) |\n| \uD83D\uDCCB Sessions | List all sessions with cleanup options |\n| \uD83D\uDCCA Status | Show active/total session count |\n| \uD83E\uDD16 Agents | List available agents |\n| \uD83D\uDD17 Integrate | Manage agent integrations |\n| \u2753 Help | Show help text |\n| \uD83D\uDD04 Restart | Restart OpenACP |\n| \u2B06\uFE0F Update | Check and install updates |\n\n---\n\n## CLI Commands\n\n### Server\n- `openacp` \u2014 Start (uses configured mode: foreground or daemon)\n- `openacp start` \u2014 Start as background daemon\n- `openacp stop` \u2014 Stop daemon\n- `openacp status` \u2014 Show daemon status\n- `openacp logs` \u2014 Tail daemon logs\n- `openacp --foreground` \u2014 Force foreground mode (useful for debugging or containers)\n\n### Auto-start (run on boot)\n- macOS: installs a LaunchAgent in `~/Library/LaunchAgents/`\n- Linux: installs a systemd user service in `~/.config/systemd/user/`\n- Enabled automatically when you start the daemon. Remove with `openacp stop`.\n\n### Configuration\n- `openacp config` \u2014 Interactive config editor\n- `openacp reset` \u2014 Delete all data and start fresh\n\n### Agent Management (CLI)\n- `openacp agents` \u2014 List all agents (installed + available from ACP Registry)\n- `openacp agents install <name>` \u2014 Install an agent\n- `openacp agents uninstall <name>` \u2014 Remove an agent\n- `openacp agents info <name>` \u2014 Show details, dependencies, and setup guide\n- `openacp agents run <name> [-- args]` \u2014 Run agent CLI directly (for login, config, etc.)\n- `openacp agents refresh` \u2014 Force-refresh registry cache\n\n### Plugins\n- `openacp install <package>` \u2014 Install adapter plugin\n- `openacp uninstall <package>` \u2014 Remove adapter plugin\n- `openacp plugins` \u2014 List installed plugins\n\n### Integration\n- `openacp integrate <agent>` \u2014 Install agent integration (e.g., Claude handoff skill)\n- `openacp integrate <agent> --uninstall` \u2014 Remove integration\n\n### API (requires running daemon)\n`openacp api <command>` \u2014 Interact with running daemon:\n\n| Command | Description |\n|---------|-------------|\n| `status` | List active sessions |\n| `session <id>` | Session details |\n| `new <agent> <path>` | Create session |\n| `send <id> \"text\"` | Send prompt |\n| `cancel <id>` | Cancel session |\n| `dangerous <id> on/off` | Toggle dangerous mode |\n| `topics [--status x,y]` | List topics |\n| `delete-topic <id> [--force]` | Delete topic |\n| `cleanup [--status x,y]` | Cleanup old topics |\n| `agents` | List agents |\n| `health` | System health |\n| `config` | Show config |\n| `config set <key> <value>` | Update config |\n| `adapters` | List adapters |\n| `tunnel` | Tunnel status |\n| `notify \"message\"` | Send notification |\n| `version` | Daemon version |\n| `restart` | Restart daemon |\n\n---\n\n## File Viewer (Tunnel)\n\nWhen tunnel is enabled, file edits and diffs get \"View\" buttons that open in your browser:\n- **Monaco Editor** \u2014 Full VS Code editor with syntax highlighting\n- **Diff viewer** \u2014 Side-by-side or inline comparison\n- **Line highlighting** \u2014 Click lines to highlight\n- Dark/light theme toggle\n\n### Setup\nEnable in config: set `tunnel.enabled` to `true`.\nProviders: Cloudflare (default, free), ngrok, bore, Tailscale Funnel.\n\n### Port Tunneling\n\nExpose any local port (dev servers, APIs, etc.) to the internet:\n\n**CLI commands** (agent can call these directly):\n- `openacp tunnel add <port> --label <name>` \u2014 Create tunnel to a local port\n- `openacp tunnel list` \u2014 List active tunnels\n- `openacp tunnel stop <port>` \u2014 Stop a tunnel\n- `openacp tunnel stop-all` \u2014 Stop all user tunnels\n\n**Telegram commands**:\n- `/tunnel <port> [label]` \u2014 Create tunnel\n- `/tunnels` \u2014 List active tunnels\n- `/tunnel stop <port>` \u2014 Stop tunnel\n\nExample: after starting a dev server on port 3000, run `openacp tunnel add 3000 --label my-app` to get a public URL.\n\n---\n\n## Configuration\n\nConfig file: `~/.openacp/config.json`\n\n### Channels\n- **channels.telegram.botToken** \u2014 Your Telegram bot token\n- **channels.telegram.chatId** \u2014 Your Telegram supergroup ID\n- **channels.discord.botToken** \u2014 Your Discord bot token\n- **channels.discord.guildId** \u2014 Your Discord server (guild) ID\n\n### Agents\n- **defaultAgent** \u2014 Which agent to use by default\n- Agents are managed via `/agents` (Telegram) or `openacp agents` (CLI)\n- Installed agents are stored in `~/.openacp/agents.json`\n- Agent list is fetched from the ACP Registry CDN and cached locally (24h)\n\n### Workspace\n- **workspace.baseDir** \u2014 Base directory for project folders (default: `~/openacp-workspace`)\n\n### Security\n- **security.allowedUserIds** \u2014 Restrict who can use the bot (empty = everyone)\n- **security.maxConcurrentSessions** \u2014 Max parallel sessions (default: 5)\n- **security.sessionTimeoutMinutes** \u2014 Auto-cancel idle sessions (default: 60)\n\n### Tunnel / File Viewer\n- **tunnel.enabled** \u2014 Enable file viewer tunnel\n- **tunnel.provider** \u2014 Tunnel provider: cloudflare (default, free), ngrok, bore, tailscale\n- **tunnel.port** \u2014 Local port for tunnel server (default: 3100)\n- **tunnel.auth.enabled** \u2014 Enable authentication for tunnel URLs\n- **tunnel.auth.token** \u2014 Auth token for tunnel access\n- **tunnel.storeTtlMinutes** \u2014 How long viewer links stay cached (default: 60)\n\n### Logging\n- **logging.level** \u2014 Log level: silent, debug, info, warn, error, fatal (default: info)\n- **logging.logDir** \u2014 Log directory (default: `~/.openacp/logs`)\n- **logging.maxFileSize** \u2014 Max log file size before rotation\n- **logging.maxFiles** \u2014 Max number of rotated log files\n- **logging.sessionLogRetentionDays** \u2014 Auto-delete old session logs (default: 30)\n\n### Data Retention\n- **sessionStore.ttlDays** \u2014 How long session records persist (default: 30). Old records are cleaned up automatically.\n\n### Environment variables\nOverride config with env vars:\n- `OPENACP_TELEGRAM_BOT_TOKEN`\n- `OPENACP_TELEGRAM_CHAT_ID`\n- `OPENACP_DISCORD_BOT_TOKEN`\n- `OPENACP_DISCORD_GUILD_ID`\n- `OPENACP_DEFAULT_AGENT`\n- `OPENACP_RUN_MODE` \u2014 foreground or daemon\n- `OPENACP_API_PORT` \u2014 API server port (default: 21420)\n- `OPENACP_TUNNEL_ENABLED`\n- `OPENACP_TUNNEL_PORT`\n- `OPENACP_TUNNEL_PROVIDER`\n- `OPENACP_LOG_LEVEL`\n- `OPENACP_LOG_DIR`\n- `OPENACP_DEBUG` \u2014 Sets log level to debug\n\n---\n\n## Troubleshooting\n\n### Session stuck / not responding\n- Check status: ask Assistant \"Is anything stuck?\"\n- Cancel and create new: `/cancel` then `/new`\n- Check system health: Assistant can run health check\n\n### Agent not found\n- Check available agents: `/agents` or `openacp agents`\n- Install missing agent: `openacp agents install <name>`\n- Some agents need login first: `openacp agents info <name>` to see setup steps\n- Run agent CLI for setup: `openacp agents run <name> -- <args>`\n\n### Permission request not showing\n- Check Notifications topic for the alert\n- Try `/enable_dangerous` to auto-approve (if you trust the agent)\n\n### Session disappeared after restart\n- Sessions persist across restarts\n- Send a message in the old topic \u2014 it auto-resumes\n- If topic was deleted, the session record may still exist in status\n\n### Bot not responding at all\n- Check daemon: `openacp status`\n- Check logs: `openacp logs`\n- Restart: `openacp start` or `/restart`\n\n### Messages going to wrong topic\n- Each session is bound to a specific topic/thread\n- If you see messages appearing in the Assistant topic instead of the session topic, try creating a new session\n\n### Viewing logs\n- Session-specific logs: `~/.openacp/logs/sessions/`\n- System logs: `openacp logs` to tail live\n- Set `OPENACP_DEBUG=true` for verbose output\n\n---\n\n## Data & Storage\n\nAll data is stored in `~/.openacp/`:\n- `config.json` \u2014 Configuration\n- `agents.json` \u2014 Installed agents (managed by AgentCatalog)\n- `registry-cache.json` \u2014 Cached ACP Registry data (refreshes every 24h)\n- `agents/` \u2014 Downloaded binary agents\n- `sessions/` \u2014 Session records and state\n- `topics/` \u2014 Topic-to-session mappings\n- `logs/` \u2014 System and session logs\n- `plugins/` \u2014 Installed adapter plugins\n- `openacp.pid` \u2014 Daemon PID file\n\nSession records auto-cleanup: 30 days (configurable via `sessionStore.ttlDays`).\nSession logs auto-cleanup: 30 days (configurable via `logging.sessionLogRetentionDays`).\n";
2951
+
2842
2952
  interface TelegramChannelConfig extends ChannelConfig {
2843
2953
  botToken: string;
2844
2954
  chatId: number;
@@ -2900,4 +3010,4 @@ declare class TelegramAdapter extends MessagingAdapter {
2900
3010
  archiveSessionTopic(sessionId: string): Promise<void>;
2901
3011
  }
2902
3012
 
2903
- export { ActivityTracker, type AdapterCapabilities, type AgentCapabilities, AgentCatalog, type AgentCommand, type AgentDefinition, type AgentDistribution, type AgentEvent, AgentInstance, type AgentListItem, AgentManager, AgentStore, type ApiConfig, ApiServer, type Attachment, type AuthMethod, type AuthenticateRequest, type AvailabilityResult, BaseRenderer, type BridgeDeps, CONFIG_REGISTRY, ChannelAdapter, type ChannelConfig, type CleanupResult, type CommandArgs, type CommandDef, type CommandResponse, type Config, type ConfigFieldDef, ConfigManager$1 as ConfigManager, type ConfigOption, type ConfigSelectChoice, type ConfigSelectGroup, type ContentBlock, ContextManager, type ContextOptions, type ContextProvider, type ContextQuery, type ContextResult, type ContextService, type SessionInfo as ContextSessionInfo, type DeleteTopicResult, type DiscordPlatformData, DraftManager, EntireProvider, EventBus, type EventBusEvents, FileService, type FileServiceInterface, GroqSTT, type IChannelAdapter, type IncomingMessage, type InstallContext, type InstallProgress, type InstallResult, type InstalledAgent, type ListItem, type Logger$1 as Logger, type LoggingConfig, type McpServerConfig, type MenuOption, MessageTransformer, MessagingAdapter, type MigrateContext, type ModelInfo, type NewSessionResponse, NotificationManager, type NotificationMessage, type NotificationService, OpenACPCore, type OpenACPPlugin, type OutgoingMessage, PLUGINS_DIR, PermissionGate, type PermissionOption, type PermissionRequest, type PlanEntry, type PluginContext, type PluginPermission, type PluginStorage, PromptQueue, type PromptResponse, type RegistryAgent, type RegistryBinaryTarget, type RegistryDistribution, SSEManager, type STTOptions, type STTProvider$1 as STTProvider, type STTResult, SecurityGuard, type SecurityService, SendQueue, Session, SessionBridge, type SessionCreateParams, type SessionEvents, SessionFactory, type SessionListItem, type SessionListResponse, type SessionListResult, SessionManager, type SessionMode, type SessionModeState, type SessionModelState, type SessionRecord, type SessionStatus, type SetConfigOptionValue, type SettingsAPI, type SideEffectDeps, type SpeechProviderConfig, SpeechService, type SpeechServiceConfig, type SpeechServiceInterface, StaticServer, StderrCapture, type StopReason, StreamAdapter, type TTSOptions, type TTSProvider$1 as TTSProvider, type TTSResult, TelegramAdapter, type TelegramPlatformData, type TerminalIO, ToolCallTracker, type TopicInfo, TopicManager, type TunnelServiceInterface, TypedEmitter, type UsageConfig, type UsageRecord, type UsageRecordEvent, type UsageService, cleanupOldSessionLogs, createChildLogger, createSessionLogger, expandHome, getConfigValue, getFieldDef, getPidPath, getSafeFields, getStatus, initLogger, installAutoStart, isAutoStartInstalled, isAutoStartSupported, isHotReloadable, log, nodeToWebReadable, nodeToWebWritable, resolveOptions, runConfigEditor, setLogLevel, shutdownLogger, startDaemon, stopDaemon, uninstallAutoStart };
3013
+ export { ActivityTracker, type AdapterCapabilities, type AgentCapabilities, AgentCatalog, type AgentCommand, type AgentDefinition, type AgentDistribution, type AgentEvent, AgentInstance, type AgentListItem, AgentManager, AgentStore, type ApiConfig, ApiServer, type Attachment, type AuthMethod, type AuthenticateRequest, type AvailabilityResult, BaseRenderer, type BridgeDeps, CONFIG_REGISTRY, ChannelAdapter, type ChannelConfig, type CleanupResult, type CommandArgs, type CommandDef, CommandRegistry, type CommandResponse, type Config, type ConfigFieldDef, ConfigManager$1 as ConfigManager, type ConfigOption, type ConfigSelectChoice, type ConfigSelectGroup, type ContentBlock, ContextManager, type ContextOptions, type ContextProvider, type ContextQuery, type ContextResult, type ContextService, type SessionInfo as ContextSessionInfo, type DeleteTopicResult, type DisplayVerbosity, DoctorEngine, type DoctorReport, DraftManager, EntireProvider, EventBus, type EventBusEvents, FileService, type FileServiceInterface, GroqSTT, type IChannelAdapter, type IRenderer, type IncomingMessage, type InstallContext, type InstallProgress, type InstallResult, type InstalledAgent, KIND_ICONS, type ListItem, type Logger$1 as Logger, type LoggingConfig, type McpServerConfig, type MenuOption, MessageTransformer, MessagingAdapter, type MessagingAdapterConfig, type MigrateContext, type ModelInfo, type NewSessionResponse, NotificationManager, type NotificationMessage, type NotificationService, OpenACPCore, type OpenACPPlugin, type OutgoingMessage, PLUGINS_DIR, PRODUCT_GUIDE, type PendingFix, PermissionGate, type PermissionOption, type PermissionRequest, type PlanEntry, type PluginContext, type PluginPermission, type PluginStorage, PromptQueue, type PromptResponse, type RegistryAgent, type RegistryBinaryTarget, type RegistryDistribution, type RenderedMessage, SSEManager, STATUS_ICONS, type STTOptions, type STTProvider$1 as STTProvider, type STTResult, SecurityGuard, type SecurityService, SendQueue, Session, SessionBridge, type SessionCreateParams, type SessionEvents, SessionFactory, type SessionListItem, type SessionListResponse, type SessionListResult, SessionManager, type SessionMode, type SessionModeState, type SessionModelState, type SessionRecord, type SessionStatus, type SetConfigOptionValue, type SettingsAPI, type SideEffectDeps, type SpeechProviderConfig, SpeechService, type SpeechServiceConfig, type SpeechServiceInterface, StaticServer, StderrCapture, type StopReason, StreamAdapter, type TTSOptions, type TTSProvider$1 as TTSProvider, type TTSResult, TelegramAdapter, type TelegramPlatformData, type TerminalIO, type ToolCallMeta, ToolCallTracker, type ToolUpdateMeta, type TopicInfo, TopicManager, type TunnelServiceInterface, TypedEmitter, type UsageConfig, type UsageRecord, type UsageRecordEvent, type UsageService, type ViewerLinks, cleanupOldSessionLogs, createChildLogger, createSessionLogger, expandHome, extractContentText, formatTokens, formatToolSummary, formatToolTitle, getConfigValue, getFieldDef, getPidPath, getSafeFields, getStatus, initLogger, installAutoStart, isAutoStartInstalled, isAutoStartSupported, isHotReloadable, log, nodeToWebReadable, nodeToWebWritable, progressBar, resolveOptions, resolveToolIcon, runConfigEditor, setLogLevel, shutdownLogger, splitMessage, startDaemon, stopDaemon, stripCodeFences, truncateContent, uninstallAutoStart };
package/dist/index.js CHANGED
@@ -1,6 +1,10 @@
1
+ import {
2
+ runConfigEditor
3
+ } from "./chunk-UMT7RU77.js";
1
4
  import {
2
5
  AgentInstance,
3
6
  AgentManager,
7
+ CommandRegistry,
4
8
  EventBus,
5
9
  MessageTransformer,
6
10
  OpenACPCore,
@@ -14,16 +18,7 @@ import {
14
18
  TypedEmitter,
15
19
  nodeToWebReadable,
16
20
  nodeToWebWritable
17
- } from "./chunk-QUXTZU36.js";
18
- import {
19
- runConfigEditor
20
- } from "./chunk-7KGWYNWE.js";
21
- import {
22
- installAutoStart,
23
- isAutoStartInstalled,
24
- isAutoStartSupported,
25
- uninstallAutoStart
26
- } from "./chunk-PPSMUECX.js";
21
+ } from "./chunk-XIBG7LSL.js";
27
22
  import {
28
23
  AgentCatalog
29
24
  } from "./chunk-SHTGQGAU.js";
@@ -37,18 +32,36 @@ import {
37
32
  stopDaemon
38
33
  } from "./chunk-BQ6FR32N.js";
39
34
  import {
40
- TelegramAdapter
41
- } from "./chunk-FDLQ5M6W.js";
35
+ installAutoStart,
36
+ isAutoStartInstalled,
37
+ isAutoStartSupported,
38
+ uninstallAutoStart
39
+ } from "./chunk-PPSMUECX.js";
42
40
  import {
41
+ PRODUCT_GUIDE,
43
42
  SendQueue,
43
+ TelegramAdapter,
44
44
  ToolCallTracker
45
- } from "./chunk-5ZOFBTOR.js";
45
+ } from "./chunk-LP45RCA4.js";
46
+ import "./chunk-AFKX424Q.js";
47
+ import {
48
+ DoctorEngine
49
+ } from "./chunk-QAQDGPB4.js";
46
50
  import {
47
51
  BaseRenderer,
48
- MessagingAdapter
49
- } from "./chunk-V2M243KZ.js";
50
- import "./chunk-AFKX424Q.js";
51
- import "./chunk-L7YNNBI5.js";
52
+ KIND_ICONS,
53
+ MessagingAdapter,
54
+ STATUS_ICONS,
55
+ extractContentText,
56
+ formatTokens,
57
+ formatToolSummary,
58
+ formatToolTitle,
59
+ progressBar,
60
+ resolveToolIcon,
61
+ splitMessage,
62
+ stripCodeFences,
63
+ truncateContent
64
+ } from "./chunk-TRXBJEZ5.js";
52
65
  import {
53
66
  NotificationManager
54
67
  } from "./chunk-WXVT3AOY.js";
@@ -56,7 +69,7 @@ import {
56
69
  ApiServer,
57
70
  SSEManager,
58
71
  StaticServer
59
- } from "./chunk-5YW56UJK.js";
72
+ } from "./chunk-2YCW3QDV.js";
60
73
  import "./chunk-FNRSWA2K.js";
61
74
  import "./chunk-ZSLHHQPQ.js";
62
75
  import {
@@ -432,21 +445,26 @@ export {
432
445
  BaseRenderer,
433
446
  CONFIG_REGISTRY,
434
447
  ChannelAdapter,
448
+ CommandRegistry,
435
449
  ConfigManager,
436
450
  ContextManager,
451
+ DoctorEngine,
437
452
  DraftManager,
438
453
  EntireProvider,
439
454
  EventBus,
440
455
  FileService,
441
456
  GroqSTT,
457
+ KIND_ICONS,
442
458
  MessageTransformer,
443
459
  MessagingAdapter,
444
460
  NotificationManager,
445
461
  OpenACPCore,
446
462
  PLUGINS_DIR,
463
+ PRODUCT_GUIDE,
447
464
  PermissionGate,
448
465
  PromptQueue,
449
466
  SSEManager,
467
+ STATUS_ICONS,
450
468
  SecurityGuard,
451
469
  SendQueue,
452
470
  Session,
@@ -465,6 +483,10 @@ export {
465
483
  createChildLogger,
466
484
  createSessionLogger,
467
485
  expandHome,
486
+ extractContentText,
487
+ formatTokens,
488
+ formatToolSummary,
489
+ formatToolTitle,
468
490
  getConfigValue,
469
491
  getFieldDef,
470
492
  getPidPath,
@@ -478,12 +500,17 @@ export {
478
500
  log,
479
501
  nodeToWebReadable,
480
502
  nodeToWebWritable,
503
+ progressBar,
481
504
  resolveOptions,
505
+ resolveToolIcon,
482
506
  runConfigEditor,
483
507
  setLogLevel,
484
508
  shutdownLogger,
509
+ splitMessage,
485
510
  startDaemon,
486
511
  stopDaemon,
512
+ stripCodeFences,
513
+ truncateContent,
487
514
  uninstallAutoStart
488
515
  };
489
516
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/channel.ts","../../src/plugins/telegram/topic-manager.ts","../../src/core/adapter-primitives/stream-adapter.ts","../../src/core/adapter-primitives/primitives/draft-manager.ts","../../src/core/adapter-primitives/primitives/activity-tracker.ts"],"sourcesContent":["import type { OutgoingMessage, PermissionRequest, NotificationMessage, AgentCommand } from './types.js'\n\nexport interface ChannelConfig {\n enabled: boolean\n [key: string]: unknown\n}\n\nexport interface AdapterCapabilities {\n streaming: boolean\n richFormatting: boolean\n threads: boolean\n reactions: boolean\n fileUpload: boolean\n voice: boolean\n}\n\nexport interface IChannelAdapter {\n readonly name: string\n readonly capabilities: AdapterCapabilities\n\n start(): Promise<void>\n stop(): Promise<void>\n\n // Outgoing: core → channel\n sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>\n sendPermissionRequest(sessionId: string, request: PermissionRequest): Promise<void>\n sendNotification(notification: NotificationMessage): Promise<void>\n\n // Session lifecycle on channel side\n createSessionThread(sessionId: string, name: string): Promise<string> // returns threadId\n renameSessionThread(sessionId: string, newName: string): Promise<void>\n deleteSessionThread?(sessionId: string): Promise<void>\n archiveSessionTopic?(sessionId: string): Promise<void>\n\n // Skill commands — optional\n sendSkillCommands?(sessionId: string, commands: AgentCommand[]): Promise<void>\n cleanupSkillCommands?(sessionId: string): Promise<void>\n}\n\n/**\n * Base class providing default no-op implementations for optional methods.\n * Adapters can extend this or implement IChannelAdapter directly.\n * @deprecated Use MessagingAdapter or StreamAdapter instead. Kept for backward compat during migration.\n */\nexport abstract class ChannelAdapter<TCore = unknown> implements IChannelAdapter {\n abstract readonly name: string\n readonly capabilities: AdapterCapabilities = {\n streaming: false, richFormatting: false, threads: false,\n reactions: false, fileUpload: false, voice: false,\n }\n\n constructor(public readonly core: TCore, protected config: ChannelConfig) {}\n\n abstract start(): Promise<void>\n abstract stop(): Promise<void>\n\n abstract sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>\n abstract sendPermissionRequest(sessionId: string, request: PermissionRequest): Promise<void>\n abstract sendNotification(notification: NotificationMessage): Promise<void>\n\n abstract createSessionThread(sessionId: string, name: string): Promise<string>\n abstract renameSessionThread(sessionId: string, newName: string): Promise<void>\n async deleteSessionThread(_sessionId: string): Promise<void> {}\n\n async sendSkillCommands(_sessionId: string, _commands: AgentCommand[]): Promise<void> {}\n async cleanupSkillCommands(_sessionId: string): Promise<void> {}\n async archiveSessionTopic(_sessionId: string): Promise<void> {}\n}\n","import type { SessionManager } from '../../core/sessions/session-manager.js'\nimport type { IChannelAdapter } from '../../core/channel.js'\nimport type { SessionRecord } from '../../core/types.js'\nimport { createChildLogger } from '../../core/utils/log.js'\n\nconst log = createChildLogger({ module: 'topic-manager' })\n\nexport interface TopicInfo {\n sessionId: string\n topicId: number | null\n name: string | null\n status: string\n agentName: string\n lastActiveAt: string\n}\n\nexport interface DeleteTopicResult {\n ok: boolean\n needsConfirmation?: boolean\n topicId?: number | null\n session?: { id: string; name: string | null; status: string }\n error?: string\n}\n\nexport interface CleanupResult {\n deleted: string[]\n failed: { sessionId: string; error: string }[]\n}\n\ninterface SystemTopicIds {\n notificationTopicId: number | null\n assistantTopicId: number | null\n}\n\nexport class TopicManager {\n constructor(\n private sessionManager: SessionManager,\n private adapter: IChannelAdapter | null,\n private systemTopicIds: SystemTopicIds,\n ) {}\n\n listTopics(filter?: { statuses?: string[] }): TopicInfo[] {\n const records = this.sessionManager.listRecords(filter)\n return records\n .filter(r => !this.isSystemTopic(r))\n .filter(r => !filter?.statuses?.length || filter.statuses.includes(r.status))\n .map(r => ({\n sessionId: r.sessionId,\n topicId: (r.platform as Record<string, unknown>)?.topicId as number ?? null,\n name: r.name ?? null,\n status: r.status,\n agentName: r.agentName,\n lastActiveAt: r.lastActiveAt,\n }))\n }\n\n async deleteTopic(sessionId: string, options?: { confirmed?: boolean }): Promise<DeleteTopicResult> {\n const records = this.sessionManager.listRecords()\n const record = records.find(r => r.sessionId === sessionId)\n if (!record) return { ok: false, error: 'Session not found' }\n\n if (this.isSystemTopic(record)) return { ok: false, error: 'Cannot delete system topic' }\n\n const isActive = record.status === 'active' || record.status === 'initializing'\n if (isActive && !options?.confirmed) {\n return {\n ok: false,\n needsConfirmation: true,\n session: { id: record.sessionId, name: record.name ?? null, status: record.status },\n }\n }\n\n if (isActive) {\n await this.sessionManager.cancelSession(sessionId)\n }\n\n const topicId = (record.platform as Record<string, unknown>)?.topicId as number ?? null\n if (this.adapter && topicId) {\n try {\n await this.adapter.deleteSessionThread?.(sessionId)\n } catch (err) {\n log.warn({ err, sessionId, topicId }, 'Failed to delete platform thread, removing record anyway')\n }\n }\n\n await this.sessionManager.removeRecord(sessionId)\n return { ok: true, topicId }\n }\n\n async cleanup(statuses?: string[]): Promise<CleanupResult> {\n const targetStatuses = statuses?.length ? statuses : ['finished', 'error', 'cancelled']\n const records = this.sessionManager.listRecords({ statuses: targetStatuses })\n const targets = records\n .filter(r => !this.isSystemTopic(r))\n .filter(r => targetStatuses.includes(r.status))\n\n const deleted: string[] = []\n const failed: { sessionId: string; error: string }[] = []\n\n for (const record of targets) {\n try {\n // Cancel active/initializing sessions to prevent orphaned agent processes\n const isActive = record.status === 'active' || record.status === 'initializing'\n if (isActive) {\n await this.sessionManager.cancelSession(record.sessionId)\n }\n\n const topicId = (record.platform as Record<string, unknown>)?.topicId as number | undefined\n if (this.adapter && topicId) {\n try {\n await this.adapter.deleteSessionThread?.(record.sessionId)\n } catch (err) {\n log.warn({ err, sessionId: record.sessionId }, 'Failed to delete platform thread during cleanup')\n }\n }\n await this.sessionManager.removeRecord(record.sessionId)\n deleted.push(record.sessionId)\n } catch (err) {\n failed.push({ sessionId: record.sessionId, error: err instanceof Error ? err.message : String(err) })\n }\n }\n\n return { deleted, failed }\n }\n\n private isSystemTopic(record: SessionRecord): boolean {\n const topicId = (record.platform as Record<string, unknown>)?.topicId as number | undefined\n if (!topicId) return false\n return topicId === this.systemTopicIds.notificationTopicId\n || topicId === this.systemTopicIds.assistantTopicId\n }\n}\n","import type {\n IChannelAdapter,\n AdapterCapabilities,\n} from '../channel.js'\nimport type {\n OutgoingMessage,\n PermissionRequest,\n NotificationMessage,\n} from '../types.js'\n\nexport interface StreamEvent {\n type: string\n sessionId?: string\n payload: unknown\n timestamp: number\n}\n\nexport abstract class StreamAdapter implements IChannelAdapter {\n abstract readonly name: string\n\n capabilities: AdapterCapabilities\n\n constructor(config?: Partial<AdapterCapabilities>) {\n this.capabilities = {\n streaming: true,\n richFormatting: false,\n threads: false,\n reactions: false,\n fileUpload: false,\n voice: false,\n ...config,\n }\n }\n\n async sendMessage(sessionId: string, content: OutgoingMessage): Promise<void> {\n await this.emit(sessionId, {\n type: content.type,\n sessionId,\n payload: content,\n timestamp: Date.now(),\n })\n }\n\n async sendPermissionRequest(sessionId: string, request: PermissionRequest): Promise<void> {\n await this.emit(sessionId, {\n type: 'permission_request',\n sessionId,\n payload: request,\n timestamp: Date.now(),\n })\n }\n\n async sendNotification(notification: NotificationMessage): Promise<void> {\n await this.broadcast({\n type: 'notification',\n payload: notification,\n timestamp: Date.now(),\n })\n }\n\n async createSessionThread(_sessionId: string, _name: string): Promise<string> {\n return ''\n }\n\n async renameSessionThread(sessionId: string, name: string): Promise<void> {\n await this.emit(sessionId, {\n type: 'session_rename',\n sessionId,\n payload: { name },\n timestamp: Date.now(),\n })\n }\n\n protected abstract emit(sessionId: string, event: StreamEvent): Promise<void>\n protected abstract broadcast(event: StreamEvent): Promise<void>\n abstract start(): Promise<void>\n abstract stop(): Promise<void>\n}\n","export interface DraftConfig {\n flushInterval: number\n maxLength: number\n onFlush: (sessionId: string, text: string, isEdit: boolean) => Promise<string | undefined>\n onError?: (sessionId: string, error: Error) => void\n}\n\nexport class Draft {\n private buffer = ''\n private _messageId?: string\n private firstFlushPending = false\n private flushTimer?: ReturnType<typeof setTimeout>\n private flushPromise: Promise<void> = Promise.resolve()\n\n constructor(\n private sessionId: string,\n private config: DraftConfig,\n ) {}\n\n get isEmpty(): boolean { return !this.buffer }\n get messageId(): string | undefined { return this._messageId }\n\n append(text: string): void {\n if (!text) return\n this.buffer += text\n this.scheduleFlush()\n }\n\n async finalize(): Promise<string | undefined> {\n if (this.flushTimer) {\n clearTimeout(this.flushTimer)\n this.flushTimer = undefined\n }\n await this.flushPromise\n if (this.buffer) {\n await this.flush()\n }\n return this._messageId\n }\n\n destroy(): void {\n if (this.flushTimer) {\n clearTimeout(this.flushTimer)\n this.flushTimer = undefined\n }\n this.buffer = ''\n }\n\n private scheduleFlush(): void {\n if (this.flushTimer) return\n this.flushTimer = setTimeout(() => {\n this.flushTimer = undefined\n this.flushPromise = this.flushPromise\n .then(() => this.flush())\n .catch(() => {})\n }, this.config.flushInterval)\n }\n\n private async flush(): Promise<void> {\n if (!this.buffer || this.firstFlushPending) return\n\n const snapshot = this.buffer\n const isEdit = !!this._messageId\n\n if (!this._messageId) {\n this.firstFlushPending = true\n }\n\n try {\n const result = await this.config.onFlush(this.sessionId, snapshot, isEdit)\n if (!isEdit && result) {\n this._messageId = result\n }\n } catch (err) {\n this.config.onError?.(this.sessionId, err instanceof Error ? err : new Error(String(err)))\n } finally {\n this.firstFlushPending = false\n }\n }\n}\n\nexport class DraftManager {\n private drafts = new Map<string, Draft>()\n\n constructor(private config: DraftConfig) {}\n\n getOrCreate(sessionId: string): Draft {\n let draft = this.drafts.get(sessionId)\n if (!draft) {\n draft = new Draft(sessionId, this.config)\n this.drafts.set(sessionId, draft)\n }\n return draft\n }\n\n async finalize(sessionId: string): Promise<void> {\n const draft = this.drafts.get(sessionId)\n if (!draft) return\n await draft.finalize()\n }\n\n async finalizeAll(): Promise<void> {\n await Promise.all([...this.drafts.values()].map(d => d.finalize()))\n }\n\n destroy(sessionId: string): void {\n const draft = this.drafts.get(sessionId)\n if (draft) {\n draft.destroy()\n this.drafts.delete(sessionId)\n }\n }\n\n destroyAll(): void {\n for (const draft of this.drafts.values()) {\n draft.destroy()\n }\n this.drafts.clear()\n }\n}\n","export interface ActivityConfig {\n thinkingRefreshInterval: number\n maxThinkingDuration: number\n}\n\nexport interface ActivityCallbacks {\n sendThinkingIndicator(): Promise<void>\n updateThinkingIndicator(): Promise<void>\n removeThinkingIndicator(): Promise<void>\n}\n\ninterface SessionState {\n callbacks: ActivityCallbacks\n refreshTimer?: ReturnType<typeof setInterval>\n startTime: number\n dismissed: boolean\n}\n\nexport class ActivityTracker {\n private sessions = new Map<string, SessionState>()\n\n constructor(private config: ActivityConfig) {}\n\n onThinkingStart(sessionId: string, callbacks: ActivityCallbacks): void {\n this.cleanup(sessionId)\n\n const state: SessionState = {\n callbacks,\n startTime: Date.now(),\n dismissed: false,\n }\n this.sessions.set(sessionId, state)\n\n setTimeout(() => {\n if (state.dismissed) return\n callbacks.sendThinkingIndicator().catch(() => {})\n this.startRefresh(sessionId, state)\n }, 0)\n }\n\n onTextStart(sessionId: string): void {\n const state = this.sessions.get(sessionId)\n if (!state || state.dismissed) return\n state.dismissed = true\n this.stopRefresh(state)\n state.callbacks.removeThinkingIndicator().catch(() => {})\n }\n\n onSessionEnd(sessionId: string): void {\n this.cleanup(sessionId)\n }\n\n destroy(): void {\n for (const [id] of this.sessions) {\n this.cleanup(id)\n }\n }\n\n private cleanup(sessionId: string): void {\n const state = this.sessions.get(sessionId)\n if (!state) return\n state.dismissed = true\n this.stopRefresh(state)\n this.sessions.delete(sessionId)\n }\n\n private startRefresh(sessionId: string, state: SessionState): void {\n state.refreshTimer = setInterval(() => {\n if (state.dismissed) {\n this.stopRefresh(state)\n return\n }\n if (Date.now() - state.startTime >= this.config.maxThinkingDuration) {\n this.stopRefresh(state)\n return\n }\n state.callbacks.updateThinkingIndicator().catch(() => {})\n }, this.config.thinkingRefreshInterval)\n }\n\n private stopRefresh(state: SessionState): void {\n if (state.refreshT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AU;AAChC,WAAK,QAAQ,EAAE;AAAA,IACjB;AAAA,EACF;AAAA,EAEQ,QAAQ,WAAyB;AACvC,UAAM,QAAQ,KAAK,SAAS,IAAI,SAAS;AACzC,QAAI,CAAC,MAAO;AACZ,UAAM,YAAY;AAClB,SAAK,YAAY,KAAK;AACtB,SAAK,SAAS,OAAO,SAAS;AAAA,EAChC;AAAA,EAEQ,aAAa,WAAmB,OAA2B;AACjE,UAAM,eAAe,YAAY,MAAM;AACrC,UAAI,MAAM,WAAW;AACnB,aAAK,YAAY,KAAK;AACtB;AAAA,MACF;AACA,UAAI,KAAK,IAAI,IAAI,MAAM,aAAa,KAAK,OAAO,qBAAqB;AACnE,aAAK,YAAY,KAAK;AACtB;AAAA,MACF;AACA,YAAM,UAAU,wBAAwB,EAAE,MAAM,MAAM;AAAA,MAAC,CAAC;AAAA,IAC1D,GAAG,KAAK,OAAO,uBAAuB;AAAA,EACxC;AAAA,EAEQ,YAAY,OAA2B;AAC7C,QAAI,MAAM,cAAc;AACtB,oBAAc,MAAM,YAAY;AAChC,YAAM,eAAe;AAAA,IACvB;AAAA,EACF;AACF;","names":["log"]}
1
+ {"version":3,"sources":["../../src/core/channel.ts","../../src/plugins/telegram/topic-manager.ts","../../src/core/adapter-primitives/stream-adapter.ts","../../src/core/adapter-primitives/primitives/draft-manager.ts","../../src/core/adapter-primitives/primitives/activity-tracker.ts"],"sourcesContent":["import type { OutgoingMessage, PermissionRequest, NotificationMessage, AgentCommand } from './types.js'\n\nexport interface ChannelConfig {\n enabled: boolean\n [key: string]: unknown\n}\n\nexport interface AdapterCapabilities {\n streaming: boolean\n richFormatting: boolean\n threads: boolean\n reactions: boolean\n fileUpload: boolean\n voice: boolean\n}\n\nexport interface IChannelAdapter {\n readonly name: string\n readonly capabilities: AdapterCapabilities\n\n start(): Promise<void>\n stop(): Promise<void>\n\n // Outgoing: core → channel\n sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>\n sendPermissionRequest(sessionId: string, request: PermissionRequest): Promise<void>\n sendNotification(notification: NotificationMessage): Promise<void>\n\n // Session lifecycle on channel side\n createSessionThread(sessionId: string, name: string): Promise<string> // returns threadId\n renameSessionThread(sessionId: string, newName: string): Promise<void>\n deleteSessionThread?(sessionId: string): Promise<void>\n archiveSessionTopic?(sessionId: string): Promise<void>\n\n // Skill commands — optional\n sendSkillCommands?(sessionId: string, commands: AgentCommand[]): Promise<void>\n cleanupSkillCommands?(sessionId: string): Promise<void>\n}\n\n/**\n * Base class providing default no-op implementations for optional methods.\n * Adapters can extend this or implement IChannelAdapter directly.\n * @deprecated Use MessagingAdapter or StreamAdapter instead. Kept for backward compat during migration.\n */\nexport abstract class ChannelAdapter<TCore = unknown> implements IChannelAdapter {\n abstract readonly name: string\n readonly capabilities: AdapterCapabilities = {\n streaming: false, richFormatting: false, threads: false,\n reactions: false, fileUpload: false, voice: false,\n }\n\n constructor(public readonly core: TCore, protected config: ChannelConfig) {}\n\n abstract start(): Promise<void>\n abstract stop(): Promise<void>\n\n abstract sendMessage(sessionId: string, content: OutgoingMessage): Promise<void>\n abstract sendPermissionRequest(sessionId: string, request: PermissionRequest): Promise<void>\n abstract sendNotification(notification: NotificationMessage): Promise<void>\n\n abstract createSessionThread(sessionId: string, name: string): Promise<string>\n abstract renameSessionThread(sessionId: string, newName: string): Promise<void>\n async deleteSessionThread(_sessionId: string): Promise<void> {}\n\n async sendSkillCommands(_sessionId: string, _commands: AgentCommand[]): Promise<void> {}\n async cleanupSkillCommands(_sessionId: string): Promise<void> {}\n async archiveSessionTopic(_sessionId: string): Promise<void> {}\n}\n","import type { SessionManager } from '../../core/sessions/session-manager.js'\nimport type { IChannelAdapter } from '../../core/channel.js'\nimport type { SessionRecord } from '../../core/types.js'\nimport { createChildLogger } from '../../core/utils/log.js'\n\nconst log = createChildLogger({ module: 'topic-manager' })\n\nexport interface TopicInfo {\n sessionId: string\n topicId: number | null\n name: string | null\n status: string\n agentName: string\n lastActiveAt: string\n}\n\nexport interface DeleteTopicResult {\n ok: boolean\n needsConfirmation?: boolean\n topicId?: number | null\n session?: { id: string; name: string | null; status: string }\n error?: string\n}\n\nexport interface CleanupResult {\n deleted: string[]\n failed: { sessionId: string; error: string }[]\n}\n\ninterface SystemTopicIds {\n notificationTopicId: number | null\n assistantTopicId: number | null\n}\n\nexport class TopicManager {\n constructor(\n private sessionManager: SessionManager,\n private adapter: IChannelAdapter | null,\n private systemTopicIds: SystemTopicIds,\n ) {}\n\n listTopics(filter?: { statuses?: string[] }): TopicInfo[] {\n const records = this.sessionManager.listRecords(filter)\n return records\n .filter(r => !this.isSystemTopic(r))\n .filter(r => !filter?.statuses?.length || filter.statuses.includes(r.status))\n .map(r => ({\n sessionId: r.sessionId,\n topicId: (r.platform as Record<string, unknown>)?.topicId as number ?? null,\n name: r.name ?? null,\n status: r.status,\n agentName: r.agentName,\n lastActiveAt: r.lastActiveAt,\n }))\n }\n\n async deleteTopic(sessionId: string, options?: { confirmed?: boolean }): Promise<DeleteTopicResult> {\n const records = this.sessionManager.listRecords()\n const record = records.find(r => r.sessionId === sessionId)\n if (!record) return { ok: false, error: 'Session not found' }\n\n if (this.isSystemTopic(record)) return { ok: false, error: 'Cannot delete system topic' }\n\n const isActive = record.status === 'active' || record.status === 'initializing'\n if (isActive && !options?.confirmed) {\n return {\n ok: false,\n needsConfirmation: true,\n session: { id: record.sessionId, name: record.name ?? null, status: record.status },\n }\n }\n\n if (isActive) {\n await this.sessionManager.cancelSession(sessionId)\n }\n\n const topicId = (record.platform as Record<string, unknown>)?.topicId as number ?? null\n if (this.adapter && topicId) {\n try {\n await this.adapter.deleteSessionThread?.(sessionId)\n } catch (err) {\n log.warn({ err, sessionId, topicId }, 'Failed to delete platform thread, removing record anyway')\n }\n }\n\n await this.sessionManager.removeRecord(sessionId)\n return { ok: true, topicId }\n }\n\n async cleanup(statuses?: string[]): Promise<CleanupResult> {\n const targetStatuses = statuses?.length ? statuses : ['finished', 'error', 'cancelled']\n const records = this.sessionManager.listRecords({ statuses: targetStatuses })\n const targets = records\n .filter(r => !this.isSystemTopic(r))\n .filter(r => targetStatuses.includes(r.status))\n\n const deleted: string[] = []\n const failed: { sessionId: string; error: string }[] = []\n\n for (const record of targets) {\n try {\n // Cancel active/initializing sessions to prevent orphaned agent processes\n const isActive = record.status === 'active' || record.status === 'initializing'\n if (isActive) {\n await this.sessionManager.cancelSession(record.sessionId)\n }\n\n const topicId = (record.platform as Record<string, unknown>)?.topicId as number | undefined\n if (this.adapter && topicId) {\n try {\n await this.adapter.deleteSessionThread?.(record.sessionId)\n } catch (err) {\n log.warn({ err, sessionId: record.sessionId }, 'Failed to delete platform thread during cleanup')\n }\n }\n await this.sessionManager.removeRecord(record.sessionId)\n deleted.push(record.sessionId)\n } catch (err) {\n failed.push({ sessionId: record.sessionId, error: err instanceof Error ? err.message : String(err) })\n }\n }\n\n return { deleted, failed }\n }\n\n private isSystemTopic(record: SessionRecord): boolean {\n const topicId = (record.platform as Record<string, unknown>)?.topicId as number | undefined\n if (!topicId) return false\n return topicId === this.systemTopicIds.notificationTopicId\n || topicId === this.systemTopicIds.assistantTopicId\n }\n}\n","import type {\n IChannelAdapter,\n AdapterCapabilities,\n} from '../channel.js'\nimport type {\n OutgoingMessage,\n PermissionRequest,\n NotificationMessage,\n} from '../types.js'\n\nexport interface StreamEvent {\n type: string\n sessionId?: string\n payload: unknown\n timestamp: number\n}\n\nexport abstract class StreamAdapter implements IChannelAdapter {\n abstract readonly name: string\n\n capabilities: AdapterCapabilities\n\n constructor(config?: Partial<AdapterCapabilities>) {\n this.capabilities = {\n streaming: true,\n richFormatting: false,\n threads: false,\n reactions: false,\n fileUpload: false,\n voice: false,\n ...config,\n }\n }\n\n async sendMessage(sessionId: string, content: OutgoingMessage): Promise<void> {\n await this.emit(sessionId, {\n type: content.type,\n sessionId,\n payload: content,\n timestamp: Date.now(),\n })\n }\n\n async sendPermissionRequest(sessionId: string, request: PermissionRequest): Promise<void> {\n await this.emit(sessionId, {\n type: 'permission_request',\n sessionId,\n payload: request,\n timestamp: Date.now(),\n })\n }\n\n async sendNotification(notification: NotificationMessage): Promise<void> {\n await this.broadcast({\n type: 'notification',\n payload: notification,\n timestamp: Date.now(),\n })\n }\n\n async createSessionThread(_sessionId: string, _name: string): Promise<string> {\n return ''\n }\n\n async renameSessionThread(sessionId: string, name: string): Promise<void> {\n await this.emit(sessionId, {\n type: 'session_rename',\n sessionId,\n payload: { name },\n timestamp: Date.now(),\n })\n }\n\n protected abstract emit(sessionId: string, event: StreamEvent): Promise<void>\n protected abstract broadcast(event: StreamEvent): Promise<void>\n abstract start(): Promise<void>\n abstract stop(): Promise<void>\n}\n","export interface DraftConfig {\n flushInterval: number\n maxLength: number\n onFlush: (sessionId: string, text: string, isEdit: boolean) => Promise<string | undefined>\n onError?: (sessionId: string, error: Error) => void\n}\n\nexport class Draft {\n private buffer = ''\n private _messageId?: string\n private firstFlushPending = false\n private flushTimer?: ReturnType<typeof setTimeout>\n private flushPromise: Promise<void> = Promise.resolve()\n\n constructor(\n private sessionId: string,\n private config: DraftConfig,\n ) {}\n\n get isEmpty(): boolean { return !this.buffer }\n get messageId(): string | undefined { return this._messageId }\n\n append(text: string): void {\n if (!text) return\n this.buffer += text\n this.scheduleFlush()\n }\n\n async finalize(): Promise<string | undefined> {\n if (this.flushTimer) {\n clearTimeout(this.flushTimer)\n this.flushTimer = undefined\n }\n await this.flushPromise\n if (this.buffer) {\n await this.flush()\n }\n return this._messageId\n }\n\n destroy(): void {\n if (this.flushTimer) {\n clearTimeout(this.flushTimer)\n this.flushTimer = undefined\n }\n this.buffer = ''\n }\n\n private scheduleFlush(): void {\n if (this.flushTimer) return\n this.flushTimer = setTimeout(() => {\n this.flushTimer = undefined\n this.flushPromise = this.flushPromise\n .then(() => this.flush())\n .catch(() => {})\n }, this.config.flushInterval)\n }\n\n private async flush(): Promise<void> {\n if (!this.buffer || this.firstFlushPending) return\n\n const snapshot = this.buffer\n const isEdit = !!this._messageId\n\n if (!this._messageId) {\n this.firstFlushPending = true\n }\n\n try {\n const result = await this.config.onFlush(this.sessionId, snapshot, isEdit)\n if (!isEdit && result) {\n this._messageId = result\n }\n } catch (err) {\n this.config.onError?.(this.sessionId, err instanceof Error ? err : new Error(String(err)))\n } finally {\n this.firstFlushPending = false\n }\n }\n}\n\nexport class DraftManager {\n private drafts = new Map<string, Draft>()\n\n constructor(private config: DraftConfig) {}\n\n getOrCreate(sessionId: string): Draft {\n let draft = this.drafts.get(sessionId)\n if (!draft) {\n draft = new Draft(sessionId, this.config)\n this.drafts.set(sessionId, draft)\n }\n return draft\n }\n\n async finalize(sessionId: string): Promise<void> {\n const draft = this.drafts.get(sessionId)\n if (!draft) return\n await draft.finalize()\n }\n\n async finalizeAll(): Promise<void> {\n await Promise.all([...this.drafts.values()].map(d => d.finalize()))\n }\n\n destroy(sessionId: string): void {\n const draft = this.drafts.get(sessionId)\n if (draft) {\n draft.destroy()\n this.drafts.delete(sessionId)\n }\n }\n\n destroyAll(): void {\n for (const draft of this.drafts.values()) {\n draft.destroy()\n }\n this.drafts.clear()\n }\n}\n","export interface ActivityConfig {\n thinkingRefreshInterval: number\n maxThinkingDuration: number\n}\n\nexport interface ActivityCallbacks {\n sendThinkingIndicator(): Promise<void>\n updateThinkingIndicator(): Promise<void>\n removeThinkingIndicator(): Promise<void>\n}\n\ninterface SessionState {\n callbacks: ActivityCallbacks\n refreshTimer?: ReturnType<typeof setInterval>\n startTime: number\n dismissed: boolean\n}\n\nexport class ActivityTracker {\n private sessions = new Map<string, SessionState>()\n\n constructor(private config: ActivityConfig) {}\n\n onThinkingStart(sessionId: string, callbacks: ActivityCallbacks): void {\n this.cleanup(sessionId)\n\n const state: SessionState = {\n callbacks,\n startTime: Date.now(),\n dismissed: false,\n }\n this.sessions.set(sessionId, state)\n\n setTimeout(() => {\n if (state.dismissed) return\n callbacks.sendThinkingIndicator().catch(() => {})\n this.startRefresh(sessionId, state)\n }, 0)\n }\n\n onTextStart(sessionId: string): void {\n const state = this.sessions.get(sessionId)\n if (!state || state.dismissed) return\n state.dismissed = true\n this.stopRefresh(state)\n state.callbacks.removeThinkingIndicator().catch(() => {})\n }\n\n onSessionEnd(sessionId: string): void {\n this.cleanup(sessionId)\n }\n\n destroy(): void {\n for (const [id] of this.sessions) {\n this.cleanup(id)\n }\n }\n\n private cleanup(sessionId: string): void {\n const state = this.sessions.get(sessionId)\n if (!state) return\n state.dismissed = true\n this.stopRefresh(state)\n this.sessions.delete(sessionId)\n }\n\n private startRefresh(sessionId: string, state: SessionState): void {\n state.refreshTimer = setInterval(() => {\n if (state.dismissed) {\n this.stopRefresh(state)\n return\n }\n if (Date.now() - state.startTime >= this.config.maxThinkingDuration) {\n this.stopRefresh(state)\n return\n }\n state.callbacks.updateThinkingIndicator().catch(() => {})\n }, this.config.thinkingRefreshInterval)\n }\n\n private stopRefresh(state: SessionState): void {\n if (state.refreshTimer) {\n clearInterval(state.refreshTimer)\n state.refreshTimer = undefined\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CO,IAAe,iBAAf,MAA0E;AAAA,EAO/E,YAA4B,MAAuB,QAAuB;AAA9C;AAAuB;AAAA,EAAwB;AAAA,EALlE,eAAoC;AAAA,IAC3C,WAAW;AAAA,IAAO,gBAAgB;AAAA,IAAO,SAAS;AAAA,IAClD,WAAW;AAAA,IAAO,YAAY;AAAA,IAAO,OAAO;AAAA,EAC9C;AAAA,EAaA,MAAM,oBAAoB,YAAmC;AAAA,EAAC;AAAA,EAE9D,MAAM,kBAAkB,YAAoB,WAA0C;AAAA,EAAC;AAAA,EACvF,MAAM,qBAAqB,YAAmC;AAAA,EAAC;AAAA,EAC/D,MAAM,oBAAoB,YAAmC;AAAA,EAAC;AAChE;;;AC9DA,IAAMA,OAAM,kBAAkB,EAAE,QAAQ,gBAAgB,CAAC;AA6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AAAA,EACF;AACF;","names":["log"]}
@@ -120,11 +120,10 @@ ${sidVar} and ${cwdVar}, then run:
120
120
  bash ${hooksDir}openacp-handoff.sh <${sidVar}> <${cwdVar}> <args if any>
121
121
 
122
122
  Usage: /openacp:handoff [channel]
123
- channel: telegram, discord, or omit for default adapter
123
+ channel: name of a registered adapter (e.g. telegram), or omit for default
124
124
 
125
125
  Examples:
126
126
  /openacp:handoff
127
- /openacp:handoff discord
128
127
  /openacp:handoff telegram
129
128
  `;
130
129
  }
@@ -370,4 +369,4 @@ export {
370
369
  listIntegrations,
371
370
  uninstallIntegration
372
371
  };
373
- //# sourceMappingURL=integrate-APK4OEQF.js.map
372
+ //# sourceMappingURL=integrate-G6CVXTGT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli/integrate.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, chmodSync, rmdirSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { getAgentCapabilities, commandExists, listAgentsWithIntegration } from \"../core/agents/agent-dependencies.js\";\nimport type { AgentIntegrationSpec } from \"../core/agents/agent-dependencies.js\";\n\nexport interface IntegrationResult {\n success: boolean;\n logs: string[];\n}\n\nexport interface IntegrationItem {\n id: string;\n name: string;\n description: string;\n isInstalled(): boolean;\n install(): Promise<IntegrationResult>;\n uninstall(): Promise<IntegrationResult>;\n}\n\nexport interface AgentIntegration {\n items: IntegrationItem[];\n}\n\nconst HOOK_MARKER = \"openacp-inject-session.sh\";\n\nfunction expandPath(p: string): string {\n return p.replace(/^~/, homedir());\n}\n\n// --- Script generators ---\n\nfunction generateInjectScript(_agentKey: string, spec: AgentIntegrationSpec): string {\n const sidVar = spec.sessionIdVar ?? \"SESSION_ID\";\n const cwdVar = spec.workingDirVar ?? \"WORKING_DIR\";\n\n // Resolve jq: check ~/.openacp/bin first, then PATH\n const jqResolver = `JQ=$(command -v jq 2>/dev/null || echo \"$HOME/.openacp/bin/jq\")`;\n\n if (spec.outputFormat === \"plaintext\") {\n return `#!/bin/bash\n${jqResolver}\nINPUT=$(cat)\nSESSION_ID=$(echo \"$INPUT\" | \"$JQ\" -r '${spec.sessionIdField}')\nCWD=$(echo \"$INPUT\" | \"$JQ\" -r '.cwd')\n\necho \"${sidVar}: $SESSION_ID\"\necho \"${cwdVar}: $CWD\"\n\nexit 0\n`;\n }\n\n // JSON output (Gemini, Cline, Cursor)\n return `#!/bin/bash\n${jqResolver}\nINPUT=$(cat)\nSESSION_ID=$(echo \"$INPUT\" | \"$JQ\" -r '${spec.sessionIdField}')\nCWD=$(echo \"$INPUT\" | \"$JQ\" -r '.cwd')\n\n\"$JQ\" -n --arg sid \"$SESSION_ID\" --arg cwd \"$CWD\" \\\\\n '{\"additionalContext\":\"${sidVar}: \\\\($sid)\\\\n${cwdVar}: \\\\($cwd)\"}'\n\nexit 0\n`;\n}\n\nfunction generateHandoffScript(agentKey: string): string {\n return `#!/bin/bash\nSESSION_ID=$1\nCWD=$2\nCHANNEL=$3\n\nif [ -z \"$SESSION_ID\" ]; then\n echo \"Usage: openacp-handoff.sh <session_id> [cwd] [channel]\"\n exit 1\nfi\n\nopenacp adopt ${agentKey} \"$SESSION_ID\" \\${CWD:+--cwd \"$CWD\"} \\${CHANNEL:+--channel \"$CHANNEL\"}\n`;\n}\n\nfunction generateTunnelCommand(): string {\n return `---\ndescription: Expose local ports to the internet. Use when user wants to share, preview, or access their local dev server remotely. Triggers on phrases like \"expose port\", \"map port\", \"share my app\", \"make it public\", \"open tunnel\", \"public URL\", \"share localhost\", \"preview on phone\", \"access from outside\", \"forward port\", \"ngrok\", \"cloudflare tunnel\", etc.\n---\n\nYou have access to OpenACP tunnel management via CLI. This creates a public URL for any local port (dev servers, APIs, static sites, etc.) using Cloudflare tunnel.\n\n## Commands\n\n\\`\\`\\`bash\n# Create a tunnel — exposes local port to the internet\nopenacp tunnel add <port> --label <name>\n\n# List all active tunnels with their public URLs\nopenacp tunnel list\n\n# Stop a specific tunnel\nopenacp tunnel stop <port>\n\n# Stop all tunnels\nopenacp tunnel stop-all\n\\`\\`\\`\n\n## When to use\n\nUser wants to:\n- **Share their local app** — \"share this on my phone\", \"let my friend see this\", \"preview on mobile\"\n- **Expose a port** — \"expose port 3000\", \"map port 5173\", \"make port 8080 public\"\n- **Get a public URL** — \"give me a public URL\", \"I need an external link\", \"make localhost accessible\"\n- **Open a tunnel** — \"open tunnel\", \"start tunnel\", \"tunnel this\"\n- **Forward/proxy a port** — \"forward port 3000\", \"proxy my server\"\n- **Deploy preview** — \"deploy preview\", \"share a preview link\"\n- **Access remotely** — \"access from my phone\", \"access from outside\"\n- **Manage tunnels** — \"show tunnels\", \"list tunnels\", \"stop tunnel\", \"close tunnel\", \"kill tunnel\"\n\n## How to respond\n\n1. Run the CLI command\n2. Share the public URL with the user\n3. Mention the URL works on any device (phone, tablet, other computer)\n4. If the user hasn't started a dev server yet, remind them to start one first\n\n## Example flow\n\nUser: \"I want to see this React app on my phone\"\n→ Check if dev server is running (e.g. port 5173 for Vite)\n→ Run: \\`openacp tunnel add 5173 --label react-app\\`\n→ Share the public URL\n`;\n}\n\nfunction generateHandoffCommand(_agentKey: string, spec: AgentIntegrationSpec): string {\n const sidVar = spec.sessionIdVar ?? \"SESSION_ID\";\n const cwdVar = spec.workingDirVar ?? \"WORKING_DIR\";\n const hooksDir = expandPath(spec.hooksDirPath);\n\n return `---\ndescription: Transfer current session to OpenACP (Telegram/Discord)\n---\n\nLook at the context injected at the start of this message to find\n${sidVar} and ${cwdVar}, then run:\n\nbash ${hooksDir}openacp-handoff.sh <${sidVar}> <${cwdVar}> <args if any>\n\nUsage: /openacp:handoff [channel]\n channel: name of a registered adapter (e.g. telegram), or omit for default\n\nExamples:\n /openacp:handoff\n /openacp:handoff telegram\n`;\n}\n\n// --- Settings mergers ---\n\nfunction mergeSettingsJson(settingsPath: string, hookEvent: string, hookScriptPath: string): void {\n const fullPath = expandPath(settingsPath);\n let settings: Record<string, unknown> = {};\n\n if (existsSync(fullPath)) {\n const raw = readFileSync(fullPath, \"utf-8\");\n writeFileSync(`${fullPath}.bak`, raw);\n settings = JSON.parse(raw);\n }\n\n const hooks = (settings.hooks ?? {}) as Record<string, unknown[]>;\n settings.hooks = hooks;\n\n const eventHooks = (hooks[hookEvent] ?? []) as Array<{ hooks?: Array<{ type?: string; command?: string }> }>;\n hooks[hookEvent] = eventHooks;\n\n const alreadyInstalled = eventHooks.some((group) =>\n group.hooks?.some((h) => h.command?.includes(HOOK_MARKER)),\n );\n\n if (!alreadyInstalled) {\n eventHooks.push({\n hooks: [{ type: \"command\", command: hookScriptPath }],\n });\n }\n\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, JSON.stringify(settings, null, 2) + \"\\n\");\n}\n\nfunction mergeHooksJson(settingsPath: string, hookEvent: string, hookScriptPath: string): void {\n const fullPath = expandPath(settingsPath);\n let config: Record<string, unknown> = { version: 1 };\n\n if (existsSync(fullPath)) {\n const raw = readFileSync(fullPath, \"utf-8\");\n writeFileSync(`${fullPath}.bak`, raw);\n config = JSON.parse(raw);\n }\n\n const hooks = (config.hooks ?? {}) as Record<string, unknown[]>;\n config.hooks = hooks;\n\n const eventHooks = (hooks[hookEvent] ?? []) as Array<{ command?: string }>;\n hooks[hookEvent] = eventHooks;\n\n const alreadyInstalled = eventHooks.some((h) => h.command?.includes(HOOK_MARKER));\n\n if (!alreadyInstalled) {\n eventHooks.push({ command: hookScriptPath });\n }\n\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\nfunction removeFromSettingsJson(settingsPath: string, hookEvent: string): void {\n const fullPath = expandPath(settingsPath);\n if (!existsSync(fullPath)) return;\n\n const raw = readFileSync(fullPath, \"utf-8\");\n const settings = JSON.parse(raw);\n const hooks = settings.hooks as Record<string, unknown[]> | undefined;\n if (!hooks?.[hookEvent]) return;\n\n hooks[hookEvent] = (hooks[hookEvent] as Array<{ hooks?: Array<{ command?: string }> }>).filter(\n (group) => !group.hooks?.some((h) => h.command?.includes(\"openacp-\")),\n );\n\n if ((hooks[hookEvent] as unknown[]).length === 0) {\n delete hooks[hookEvent];\n }\n\n writeFileSync(fullPath, JSON.stringify(settings, null, 2) + \"\\n\");\n}\n\nfunction removeFromHooksJson(settingsPath: string, hookEvent: string): void {\n const fullPath = expandPath(settingsPath);\n if (!existsSync(fullPath)) return;\n\n const raw = readFileSync(fullPath, \"utf-8\");\n const config = JSON.parse(raw);\n const hooks = config.hooks as Record<string, unknown[]> | undefined;\n if (!hooks?.[hookEvent]) return;\n\n hooks[hookEvent] = (hooks[hookEvent] as Array<{ command?: string }>).filter(\n (h) => !h.command?.includes(\"openacp-\"),\n );\n\n if ((hooks[hookEvent] as unknown[]).length === 0) {\n delete hooks[hookEvent];\n }\n\n writeFileSync(fullPath, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\n// --- Core install/uninstall ---\n\nexport async function installIntegration(agentKey: string, spec: AgentIntegrationSpec): Promise<IntegrationResult> {\n const logs: string[] = [];\n try {\n // Check jq\n if (!commandExists(\"jq\")) {\n return {\n success: false,\n logs: [\"jq is required for handoff hooks. Install: brew install jq (macOS) or apt install jq (Linux)\"],\n };\n }\n\n const hooksDir = expandPath(spec.hooksDirPath);\n mkdirSync(hooksDir, { recursive: true });\n\n // Inject script\n const injectPath = join(hooksDir, \"openacp-inject-session.sh\");\n writeFileSync(injectPath, generateInjectScript(agentKey, spec));\n chmodSync(injectPath, 0o755);\n logs.push(`Created ${injectPath}`);\n\n // Handoff script\n const handoffPath = join(hooksDir, \"openacp-handoff.sh\");\n writeFileSync(handoffPath, generateHandoffScript(agentKey));\n chmodSync(handoffPath, 0o755);\n logs.push(`Created ${handoffPath}`);\n\n // Slash command / skill\n if (spec.commandsPath && spec.handoffCommandName) {\n if (spec.commandFormat === \"skill\") {\n const skillDir = expandPath(join(spec.commandsPath, spec.handoffCommandName));\n mkdirSync(skillDir, { recursive: true });\n const skillPath = join(skillDir, \"SKILL.md\");\n writeFileSync(skillPath, generateHandoffCommand(agentKey, spec));\n logs.push(`Created ${skillPath}`);\n } else {\n const cmdsDir = expandPath(spec.commandsPath);\n mkdirSync(cmdsDir, { recursive: true });\n const cmdPath = join(cmdsDir, `${spec.handoffCommandName}.md`);\n writeFileSync(cmdPath, generateHandoffCommand(agentKey, spec));\n logs.push(`Created ${cmdPath}`);\n }\n }\n\n // Merge settings\n const injectFullPath = join(hooksDir, \"openacp-inject-session.sh\");\n if (spec.settingsFormat === \"hooks_json\") {\n mergeHooksJson(spec.settingsPath, spec.hookEvent, injectFullPath);\n } else {\n mergeSettingsJson(spec.settingsPath, spec.hookEvent, injectFullPath);\n }\n logs.push(`Updated ${expandPath(spec.settingsPath)}`);\n\n return { success: true, logs };\n } catch (err) {\n logs.push(`Error: ${err instanceof Error ? err.message : String(err)}`);\n return { success: false, logs };\n }\n}\n\nexport async function uninstallIntegration(agentKey: string, spec: AgentIntegrationSpec): Promise<IntegrationResult> {\n const logs: string[] = [];\n try {\n const hooksDir = expandPath(spec.hooksDirPath);\n\n // Remove hook scripts\n for (const filename of [\"openacp-inject-session.sh\", \"openacp-handoff.sh\"]) {\n const filePath = join(hooksDir, filename);\n if (existsSync(filePath)) {\n unlinkSync(filePath);\n logs.push(`Removed ${filePath}`);\n }\n }\n\n // Remove slash command / skill\n if (spec.commandsPath && spec.handoffCommandName) {\n if (spec.commandFormat === \"skill\") {\n const skillDir = expandPath(join(spec.commandsPath, spec.handoffCommandName));\n const skillPath = join(skillDir, \"SKILL.md\");\n if (existsSync(skillPath)) {\n unlinkSync(skillPath);\n try { rmdirSync(skillDir); } catch { /* not empty */ }\n logs.push(`Removed ${skillPath}`);\n }\n } else {\n const cmdPath = expandPath(join(spec.commandsPath, `${spec.handoffCommandName}.md`));\n if (existsSync(cmdPath)) {\n unlinkSync(cmdPath);\n logs.push(`Removed ${cmdPath}`);\n }\n }\n }\n\n // Clean settings\n if (spec.settingsFormat === \"hooks_json\") {\n removeFromHooksJson(spec.settingsPath, spec.hookEvent);\n } else {\n removeFromSettingsJson(spec.settingsPath, spec.hookEvent);\n }\n logs.push(`Updated ${expandPath(spec.settingsPath)}`);\n\n return { success: true, logs };\n } catch (err) {\n logs.push(`Error: ${err instanceof Error ? err.message : String(err)}`);\n return { success: false, logs };\n }\n}\n\n// --- Public API (backward compat with existing cmdIntegrate / Telegram integrate) ---\n\nfunction buildHandoffItem(agentKey: string, spec: AgentIntegrationSpec): IntegrationItem {\n const hooksDir = expandPath(spec.hooksDirPath);\n return {\n id: \"handoff\",\n name: \"Handoff\",\n description: \"Transfer sessions between terminal and messaging platforms\",\n isInstalled(): boolean {\n return (\n existsSync(join(hooksDir, \"openacp-inject-session.sh\")) &&\n existsSync(join(hooksDir, \"openacp-handoff.sh\"))\n );\n },\n install: () => installIntegration(agentKey, spec),\n uninstall: () => uninstallIntegration(agentKey, spec),\n };\n}\n\nfunction getSkillBasePath(spec: AgentIntegrationSpec): string {\n // Skills go into the agent's skills directory (sibling to commands)\n // Claude: ~/.claude/skills/, Cursor: ~/.cursor/skills/\n const base = spec.commandsPath!;\n // If commandsPath is commands/, use skills/ instead\n const skillsBase = base.replace(/\\/commands\\/?$/, \"/skills/\");\n return expandPath(skillsBase);\n}\n\nfunction buildTunnelItem(spec: AgentIntegrationSpec): IntegrationItem | null {\n if (!spec.commandsPath) return null;\n\n function getTunnelPath(): string {\n return join(getSkillBasePath(spec), \"openacp-tunnel\", \"SKILL.md\");\n }\n\n return {\n id: \"tunnel\",\n name: \"Tunnel\",\n description: \"Expose local ports to the internet via OpenACP tunnel\",\n isInstalled(): boolean {\n return existsSync(getTunnelPath());\n },\n async install(): Promise<IntegrationResult> {\n const logs: string[] = [];\n try {\n const skillPath = getTunnelPath();\n mkdirSync(dirname(skillPath), { recursive: true });\n writeFileSync(skillPath, generateTunnelCommand());\n logs.push(`Created ${skillPath}`);\n return { success: true, logs };\n } catch (err) {\n logs.push(`Error: ${err instanceof Error ? err.message : String(err)}`);\n return { success: false, logs };\n }\n },\n async uninstall(): Promise<IntegrationResult> {\n const logs: string[] = [];\n try {\n const skillPath = getTunnelPath();\n if (existsSync(skillPath)) {\n unlinkSync(skillPath);\n try { rmdirSync(dirname(skillPath)); } catch { /* not empty */ }\n logs.push(`Removed ${skillPath}`);\n }\n return { success: true, logs };\n } catch (err) {\n logs.push(`Error: ${err instanceof Error ? err.message : String(err)}`);\n return { success: false, logs };\n }\n },\n };\n}\n\nexport function getIntegration(agentName: string): AgentIntegration | undefined {\n const caps = getAgentCapabilities(agentName);\n if (!caps.integration) return undefined;\n const items: IntegrationItem[] = [buildHandoffItem(agentName, caps.integration)];\n const tunnelItem = buildTunnelItem(caps.integration);\n if (tunnelItem) items.push(tunnelItem);\n return { items };\n}\n\nexport function listIntegrations(): string[] {\n return listAgentsWithIntegration();\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,YAAY,WAAW,cAAc,eAAe,YAAY,WAAW,iBAAiB;AACrG,SAAS,MAAM,eAAe;AAC9B,SAAS,eAAe;AAsBxB,IAAM,cAAc;AAEpB,SAAS,WAAW,GAAmB;AACrC,SAAO,EAAE,QAAQ,MAAM,QAAQ,CAAC;AAClC;AAIA,SAAS,qBAAqB,WAAmB,MAAoC;AACnF,QAAM,SAAS,KAAK,gBAAgB;AACpC,QAAM,SAAS,KAAK,iBAAiB;AAGrC,QAAM,aAAa;AAEnB,MAAI,KAAK,iBAAiB,aAAa;AACrC,WAAO;AAAA,EACT,UAAU;AAAA;AAAA,yCAE6B,KAAK,cAAc;AAAA;AAAA;AAAA,QAGpD,MAAM;AAAA,QACN,MAAM;AAAA;AAAA;AAAA;AAAA,EAIZ;AAGA,SAAO;AAAA,EACP,UAAU;AAAA;AAAA,yCAE6B,KAAK,cAAc;AAAA;AAAA;AAAA;AAAA,2BAIjC,MAAM,gBAAgB,MAAM;AAAA;AAAA;AAAA;AAIvD;AAEA,SAAS,sBAAsB,UAA0B;AACvD,SAAO;AAA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