@openacp/cli 0.4.11 → 0.5.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 (74) hide show
  1. package/README.md +41 -3
  2. package/dist/agent-catalog-LAAVBVLY.js +10 -0
  3. package/dist/agent-dependencies-FCLRGMZM.js +23 -0
  4. package/dist/agent-registry-KZANAFXQ.js +8 -0
  5. package/dist/agent-store-ZBXGOFPH.js +8 -0
  6. package/dist/chunk-5HGXUCMX.js +83 -0
  7. package/dist/chunk-5HGXUCMX.js.map +1 -0
  8. package/dist/chunk-5MH66WUY.js +424 -0
  9. package/dist/chunk-5MH66WUY.js.map +1 -0
  10. package/dist/{chunk-FKOARMAE.js → chunk-776VAU3T.js} +3 -3
  11. package/dist/chunk-GUHCS6X7.js +282 -0
  12. package/dist/chunk-GUHCS6X7.js.map +1 -0
  13. package/dist/{chunk-3DIPXFZJ.js → chunk-IRGYTNLP.js} +2 -2
  14. package/dist/chunk-IURZ4QHG.js +91 -0
  15. package/dist/chunk-IURZ4QHG.js.map +1 -0
  16. package/dist/{chunk-WYZFGHHI.js → chunk-JRF4G4X7.js} +60 -24
  17. package/dist/chunk-JRF4G4X7.js.map +1 -0
  18. package/dist/chunk-NAMYZIS5.js +1 -0
  19. package/dist/{chunk-ZW444AQY.js → chunk-NDR5JCS7.js} +2 -2
  20. package/dist/{chunk-66RVSUAR.js → chunk-PHC67OP4.js} +567 -103
  21. package/dist/chunk-PHC67OP4.js.map +1 -0
  22. package/dist/{chunk-W7QQA6CW.js → chunk-QODDJ4PH.js} +83 -36
  23. package/dist/chunk-QODDJ4PH.js.map +1 -0
  24. package/dist/{chunk-YRJEZD7R.js → chunk-VBEWSWVL.js} +2 -2
  25. package/dist/{chunk-C33LTDZV.js → chunk-Z46LGZ7R.js} +21 -8
  26. package/dist/chunk-Z46LGZ7R.js.map +1 -0
  27. package/dist/cli.js +440 -64
  28. package/dist/cli.js.map +1 -1
  29. package/dist/{config-XURP6B3S.js → config-PCPIBPUA.js} +2 -2
  30. package/dist/config-editor-RGV6VKPZ.js +12 -0
  31. package/dist/{config-registry-OGX4YM2U.js → config-registry-SNKA2EH2.js} +2 -2
  32. package/dist/{daemon-GWJM2S4A.js → daemon-JZLFRUW6.js} +3 -3
  33. package/dist/daemon-JZLFRUW6.js.map +1 -0
  34. package/dist/data/registry-snapshot.json +876 -0
  35. package/dist/doctor-N2HKKUUQ.js +9 -0
  36. package/dist/doctor-N2HKKUUQ.js.map +1 -0
  37. package/dist/index.d.ts +138 -17
  38. package/dist/index.js +24 -15
  39. package/dist/integrate-X7LI6MUO.js +257 -0
  40. package/dist/integrate-X7LI6MUO.js.map +1 -0
  41. package/dist/{main-2QKD2EI2.js → main-DSQBCJHR.js} +18 -15
  42. package/dist/{main-2QKD2EI2.js.map → main-DSQBCJHR.js.map} +1 -1
  43. package/dist/{menu-CARRTW2F.js → menu-J5YVH665.js} +2 -4
  44. package/dist/menu-J5YVH665.js.map +1 -0
  45. package/dist/{setup-TTOL7XAN.js → setup-3A3XDGCM.js} +4 -3
  46. package/dist/setup-3A3XDGCM.js.map +1 -0
  47. package/dist/suggest-RST5VOHB.js +36 -0
  48. package/dist/suggest-RST5VOHB.js.map +1 -0
  49. package/package.json +11 -2
  50. package/dist/agent-registry-7HC6D4CH.js +0 -7
  51. package/dist/chunk-66RVSUAR.js.map +0 -1
  52. package/dist/chunk-BGKQHQB4.js +0 -276
  53. package/dist/chunk-BGKQHQB4.js.map +0 -1
  54. package/dist/chunk-C33LTDZV.js.map +0 -1
  55. package/dist/chunk-VA2M52CM.js +0 -15
  56. package/dist/chunk-VA2M52CM.js.map +0 -1
  57. package/dist/chunk-W7QQA6CW.js.map +0 -1
  58. package/dist/chunk-WYZFGHHI.js.map +0 -1
  59. package/dist/config-editor-AALY3URF.js +0 -11
  60. package/dist/doctor-X477CVZN.js +0 -9
  61. package/dist/integrate-WUPLRJD3.js +0 -145
  62. package/dist/integrate-WUPLRJD3.js.map +0 -1
  63. /package/dist/{agent-registry-7HC6D4CH.js.map → agent-catalog-LAAVBVLY.js.map} +0 -0
  64. /package/dist/{config-XURP6B3S.js.map → agent-dependencies-FCLRGMZM.js.map} +0 -0
  65. /package/dist/{config-editor-AALY3URF.js.map → agent-registry-KZANAFXQ.js.map} +0 -0
  66. /package/dist/{config-registry-OGX4YM2U.js.map → agent-store-ZBXGOFPH.js.map} +0 -0
  67. /package/dist/{chunk-FKOARMAE.js.map → chunk-776VAU3T.js.map} +0 -0
  68. /package/dist/{chunk-3DIPXFZJ.js.map → chunk-IRGYTNLP.js.map} +0 -0
  69. /package/dist/{daemon-GWJM2S4A.js.map → chunk-NAMYZIS5.js.map} +0 -0
  70. /package/dist/{chunk-ZW444AQY.js.map → chunk-NDR5JCS7.js.map} +0 -0
  71. /package/dist/{chunk-YRJEZD7R.js.map → chunk-VBEWSWVL.js.map} +0 -0
  72. /package/dist/{doctor-X477CVZN.js.map → config-PCPIBPUA.js.map} +0 -0
  73. /package/dist/{menu-CARRTW2F.js.map → config-editor-RGV6VKPZ.js.map} +0 -0
  74. /package/dist/{setup-TTOL7XAN.js.map → config-registry-SNKA2EH2.js.map} +0 -0
@@ -0,0 +1,9 @@
1
+ import {
2
+ DoctorEngine
3
+ } from "./chunk-IRGYTNLP.js";
4
+ import "./chunk-JRF4G4X7.js";
5
+ import "./chunk-ESOPMQAY.js";
6
+ export {
7
+ DoctorEngine
8
+ };
9
+ //# sourceMappingURL=doctor-N2HKKUUQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts CHANGED
@@ -96,6 +96,83 @@ interface AgentDefinition {
96
96
  workingDirectory?: string;
97
97
  env?: Record<string, string>;
98
98
  }
99
+ type AgentDistribution = "npx" | "uvx" | "binary" | "custom";
100
+ interface InstalledAgent {
101
+ registryId: string | null;
102
+ name: string;
103
+ version: string;
104
+ distribution: AgentDistribution;
105
+ command: string;
106
+ args: string[];
107
+ env: Record<string, string>;
108
+ workingDirectory?: string;
109
+ installedAt: string;
110
+ binaryPath: string | null;
111
+ }
112
+ interface RegistryBinaryTarget {
113
+ archive: string;
114
+ cmd: string;
115
+ args?: string[];
116
+ env?: Record<string, string>;
117
+ }
118
+ interface RegistryDistribution {
119
+ npx?: {
120
+ package: string;
121
+ args?: string[];
122
+ env?: Record<string, string>;
123
+ };
124
+ uvx?: {
125
+ package: string;
126
+ args?: string[];
127
+ env?: Record<string, string>;
128
+ };
129
+ binary?: Record<string, RegistryBinaryTarget>;
130
+ }
131
+ interface RegistryAgent {
132
+ id: string;
133
+ name: string;
134
+ version: string;
135
+ description: string;
136
+ repository?: string;
137
+ website?: string;
138
+ authors?: string[];
139
+ license?: string;
140
+ icon?: string;
141
+ distribution: RegistryDistribution;
142
+ }
143
+ interface AgentListItem {
144
+ key: string;
145
+ registryId: string;
146
+ name: string;
147
+ version: string;
148
+ description?: string;
149
+ distribution: AgentDistribution;
150
+ installed: boolean;
151
+ available: boolean;
152
+ missingDeps?: string[];
153
+ }
154
+ interface AvailabilityResult {
155
+ available: boolean;
156
+ reason?: string;
157
+ missing?: Array<{
158
+ label: string;
159
+ installHint: string;
160
+ }>;
161
+ }
162
+ interface InstallProgress {
163
+ onStart(agentId: string, agentName: string): void | Promise<void>;
164
+ onStep(step: string): void | Promise<void>;
165
+ onDownloadProgress(percent: number): void | Promise<void>;
166
+ onSuccess(agentName: string): void | Promise<void>;
167
+ onError(error: string, hint?: string): void | Promise<void>;
168
+ }
169
+ interface InstallResult {
170
+ ok: boolean;
171
+ agentKey: string;
172
+ error?: string;
173
+ hint?: string;
174
+ setupSteps?: string[];
175
+ }
99
176
  type SessionStatus = "initializing" | "active" | "cancelled" | "finished" | "error";
100
177
  interface SessionRecord<P = Record<string, unknown>> {
101
178
  sessionId: string;
@@ -186,7 +263,7 @@ declare const ConfigSchema: z.ZodObject<{
186
263
  enabled: z.ZodDefault<z.ZodBoolean>;
187
264
  adapter: z.ZodOptional<z.ZodString>;
188
265
  }, z.ZodTypeAny, "passthrough">>>;
189
- agents: z.ZodRecord<z.ZodString, z.ZodObject<{
266
+ agents: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
190
267
  command: z.ZodString;
191
268
  args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
192
269
  workingDirectory: z.ZodOptional<z.ZodString>;
@@ -201,7 +278,7 @@ declare const ConfigSchema: z.ZodObject<{
201
278
  args?: string[] | undefined;
202
279
  workingDirectory?: string | undefined;
203
280
  env?: Record<string, string> | undefined;
204
- }>>;
281
+ }>>>>;
205
282
  defaultAgent: z.ZodString;
206
283
  workspace: z.ZodDefault<z.ZodObject<{
207
284
  baseDir: z.ZodDefault<z.ZodString>;
@@ -313,6 +390,12 @@ declare const ConfigSchema: z.ZodObject<{
313
390
  port: number;
314
391
  host: string;
315
392
  };
393
+ agents: Record<string, {
394
+ command: string;
395
+ args: string[];
396
+ env: Record<string, string>;
397
+ workingDirectory?: string | undefined;
398
+ }>;
316
399
  tunnel: {
317
400
  options: Record<string, unknown>;
318
401
  enabled: boolean;
@@ -324,12 +407,6 @@ declare const ConfigSchema: z.ZodObject<{
324
407
  token?: string | undefined;
325
408
  };
326
409
  };
327
- agents: Record<string, {
328
- command: string;
329
- args: string[];
330
- env: Record<string, string>;
331
- workingDirectory?: string | undefined;
332
- }>;
333
410
  channels: Record<string, z.objectOutputType<{
334
411
  enabled: z.ZodDefault<z.ZodBoolean>;
335
412
  adapter: z.ZodOptional<z.ZodString>;
@@ -360,12 +437,6 @@ declare const ConfigSchema: z.ZodObject<{
360
437
  installedAt?: string | undefined;
361
438
  }>;
362
439
  }, {
363
- agents: Record<string, {
364
- command: string;
365
- args?: string[] | undefined;
366
- workingDirectory?: string | undefined;
367
- env?: Record<string, string> | undefined;
368
- }>;
369
440
  channels: Record<string, z.objectInputType<{
370
441
  enabled: z.ZodDefault<z.ZodBoolean>;
371
442
  adapter: z.ZodOptional<z.ZodString>;
@@ -375,6 +446,12 @@ declare const ConfigSchema: z.ZodObject<{
375
446
  port?: number | undefined;
376
447
  host?: string | undefined;
377
448
  } | undefined;
449
+ agents?: Record<string, {
450
+ command: string;
451
+ args?: string[] | undefined;
452
+ workingDirectory?: string | undefined;
453
+ env?: Record<string, string> | undefined;
454
+ }> | undefined;
378
455
  tunnel?: {
379
456
  options?: Record<string, unknown> | undefined;
380
457
  enabled?: boolean | undefined;
@@ -522,9 +599,48 @@ declare class AgentInstance {
522
599
  destroy(): Promise<void>;
523
600
  }
524
601
 
602
+ declare class AgentStore {
603
+ private data;
604
+ private filePath;
605
+ constructor(filePath?: string);
606
+ load(): void;
607
+ exists(): boolean;
608
+ getInstalled(): Record<string, InstalledAgent>;
609
+ getAgent(key: string): InstalledAgent | undefined;
610
+ addAgent(key: string, agent: InstalledAgent): void;
611
+ removeAgent(key: string): void;
612
+ hasAgent(key: string): boolean;
613
+ private save;
614
+ }
615
+
616
+ declare class AgentCatalog {
617
+ private store;
618
+ private registryAgents;
619
+ constructor(store?: AgentStore);
620
+ load(): void;
621
+ fetchRegistry(): Promise<void>;
622
+ refreshRegistryIfStale(): Promise<void>;
623
+ getRegistryAgents(): RegistryAgent[];
624
+ getRegistryAgent(registryId: string): RegistryAgent | undefined;
625
+ findRegistryAgent(keyOrId: string): RegistryAgent | undefined;
626
+ getInstalled(): InstalledAgent[];
627
+ getInstalledEntries(): Record<string, InstalledAgent>;
628
+ getInstalledAgent(key: string): InstalledAgent | undefined;
629
+ getAvailable(): AgentListItem[];
630
+ checkAvailability(keyOrId: string): AvailabilityResult;
631
+ install(keyOrId: string, progress?: InstallProgress, force?: boolean): Promise<InstallResult>;
632
+ uninstall(key: string): Promise<{
633
+ ok: boolean;
634
+ error?: string;
635
+ }>;
636
+ resolve(key: string): AgentDefinition | undefined;
637
+ private isCacheStale;
638
+ private loadRegistryFromCacheOrSnapshot;
639
+ }
640
+
525
641
  declare class AgentManager {
526
- private config;
527
- constructor(config: Config);
642
+ private catalog;
643
+ constructor(catalog: AgentCatalog);
528
644
  getAvailableAgents(): AgentDefinition[];
529
645
  getAgent(name: string): AgentDefinition | undefined;
530
646
  spawn(agentName: string, workingDirectory: string): Promise<AgentInstance>;
@@ -574,6 +690,9 @@ declare class PermissionGate {
574
690
  private resolveFn?;
575
691
  private rejectFn?;
576
692
  private settled;
693
+ private timeoutTimer?;
694
+ private timeoutMs;
695
+ constructor(timeoutMs?: number);
577
696
  setPending(request: PermissionRequest): Promise<string>;
578
697
  resolve(optionId: string): void;
579
698
  reject(reason?: string): void;
@@ -581,6 +700,7 @@ declare class PermissionGate {
581
700
  get currentRequest(): PermissionRequest | undefined;
582
701
  /** The request ID of the current pending request, undefined after settlement */
583
702
  get requestId(): string | undefined;
703
+ private clearTimeout;
584
704
  private cleanup;
585
705
  }
586
706
 
@@ -762,6 +882,7 @@ declare class SessionBridge {
762
882
 
763
883
  declare class OpenACPCore {
764
884
  configManager: ConfigManager;
885
+ agentCatalog: AgentCatalog;
765
886
  agentManager: AgentManager;
766
887
  sessionManager: SessionManager;
767
888
  notificationManager: NotificationManager;
@@ -983,4 +1104,4 @@ declare class TelegramAdapter extends ChannelAdapter<OpenACPCore> {
983
1104
  cleanupSkillCommands(sessionId: string): Promise<void>;
984
1105
  }
985
1106
 
986
- export { type AdapterFactory, type AgentCommand, type AgentDefinition, type AgentEvent, AgentInstance, AgentManager, type ApiConfig, ApiServer, type BridgeDeps, CONFIG_REGISTRY, ChannelAdapter, type ChannelConfig, type CleanupResult, type Config, type ConfigFieldDef, ConfigManager, type DeleteTopicResult, type IChannelAdapter, type IncomingMessage, type Logger, type LoggingConfig, MessageTransformer, NotificationManager, type NotificationMessage, OpenACPCore, type OutgoingMessage, PLUGINS_DIR, PermissionGate, type PermissionOption, type PermissionRequest, type PlanEntry, PromptQueue, Session, SessionBridge, type SessionEvents, SessionManager, type SessionRecord, type SessionStatus, StderrCapture, TelegramAdapter, type TelegramPlatformData, type TopicInfo, TopicManager, TypedEmitter, cleanupOldSessionLogs, createChildLogger, createSessionLogger, expandHome, getConfigValue, getFieldDef, getPidPath, getSafeFields, getStatus, initLogger, installAutoStart, installPlugin, isAutoStartInstalled, isAutoStartSupported, isHotReloadable, listPlugins, loadAdapterFactory, log, nodeToWebReadable, nodeToWebWritable, resolveOptions, runConfigEditor, setLogLevel, shutdownLogger, startDaemon, stopDaemon, uninstallAutoStart, uninstallPlugin };
1107
+ export { type AdapterFactory, AgentCatalog, type AgentCommand, type AgentDefinition, type AgentDistribution, type AgentEvent, AgentInstance, type AgentListItem, AgentManager, AgentStore, type ApiConfig, ApiServer, type AvailabilityResult, type BridgeDeps, CONFIG_REGISTRY, ChannelAdapter, type ChannelConfig, type CleanupResult, type Config, type ConfigFieldDef, ConfigManager, type DeleteTopicResult, type IChannelAdapter, type IncomingMessage, type InstallProgress, type InstallResult, type InstalledAgent, type Logger, type LoggingConfig, MessageTransformer, NotificationManager, type NotificationMessage, OpenACPCore, type OutgoingMessage, PLUGINS_DIR, PermissionGate, type PermissionOption, type PermissionRequest, type PlanEntry, PromptQueue, type RegistryAgent, type RegistryBinaryTarget, type RegistryDistribution, Session, SessionBridge, type SessionEvents, SessionManager, type SessionRecord, type SessionStatus, StderrCapture, TelegramAdapter, type TelegramPlatformData, type TopicInfo, TopicManager, TypedEmitter, cleanupOldSessionLogs, createChildLogger, createSessionLogger, expandHome, getConfigValue, getFieldDef, getPidPath, getSafeFields, getStatus, initLogger, installAutoStart, installPlugin, isAutoStartInstalled, isAutoStartSupported, isHotReloadable, listPlugins, loadAdapterFactory, log, nodeToWebReadable, nodeToWebWritable, resolveOptions, runConfigEditor, setLogLevel, shutdownLogger, startDaemon, stopDaemon, uninstallAutoStart, uninstallPlugin };
package/dist/index.js CHANGED
@@ -17,26 +17,39 @@ import {
17
17
  TypedEmitter,
18
18
  nodeToWebReadable,
19
19
  nodeToWebWritable
20
- } from "./chunk-66RVSUAR.js";
20
+ } from "./chunk-PHC67OP4.js";
21
21
  import {
22
22
  runConfigEditor
23
- } from "./chunk-FKOARMAE.js";
23
+ } from "./chunk-776VAU3T.js";
24
+ import "./chunk-IRGYTNLP.js";
25
+ import "./chunk-NAMYZIS5.js";
26
+ import "./chunk-IURZ4QHG.js";
27
+ import {
28
+ getPidPath,
29
+ getStatus,
30
+ startDaemon,
31
+ stopDaemon
32
+ } from "./chunk-VBEWSWVL.js";
33
+ import {
34
+ AgentCatalog
35
+ } from "./chunk-5MH66WUY.js";
36
+ import {
37
+ AgentStore
38
+ } from "./chunk-5HGXUCMX.js";
24
39
  import {
25
40
  installAutoStart,
26
41
  isAutoStartInstalled,
27
42
  isAutoStartSupported,
28
43
  uninstallAutoStart
29
44
  } from "./chunk-X6LLG7XN.js";
30
- import "./chunk-W7QQA6CW.js";
31
- import "./chunk-3DIPXFZJ.js";
32
- import "./chunk-VA2M52CM.js";
33
- import "./chunk-BGKQHQB4.js";
45
+ import "./chunk-QODDJ4PH.js";
46
+ import "./chunk-GUHCS6X7.js";
34
47
  import {
35
48
  installPlugin,
36
49
  listPlugins,
37
50
  loadAdapterFactory,
38
51
  uninstallPlugin
39
- } from "./chunk-ZW444AQY.js";
52
+ } from "./chunk-NDR5JCS7.js";
40
53
  import {
41
54
  CONFIG_REGISTRY,
42
55
  getConfigValue,
@@ -44,18 +57,12 @@ import {
44
57
  getSafeFields,
45
58
  isHotReloadable,
46
59
  resolveOptions
47
- } from "./chunk-C33LTDZV.js";
48
- import {
49
- getPidPath,
50
- getStatus,
51
- startDaemon,
52
- stopDaemon
53
- } from "./chunk-YRJEZD7R.js";
60
+ } from "./chunk-Z46LGZ7R.js";
54
61
  import {
55
62
  ConfigManager,
56
63
  PLUGINS_DIR,
57
64
  expandHome
58
- } from "./chunk-WYZFGHHI.js";
65
+ } from "./chunk-JRF4G4X7.js";
59
66
  import {
60
67
  cleanupOldSessionLogs,
61
68
  createChildLogger,
@@ -66,8 +73,10 @@ import {
66
73
  shutdownLogger
67
74
  } from "./chunk-ESOPMQAY.js";
68
75
  export {
76
+ AgentCatalog,
69
77
  AgentInstance,
70
78
  AgentManager,
79
+ AgentStore,
71
80
  ApiServer,
72
81
  CONFIG_REGISTRY,
73
82
  ChannelAdapter,
@@ -0,0 +1,257 @@
1
+ import {
2
+ commandExists,
3
+ getAgentCapabilities,
4
+ listAgentsWithIntegration
5
+ } from "./chunk-GUHCS6X7.js";
6
+
7
+ // src/cli/integrate.ts
8
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, chmodSync, rmdirSync } from "fs";
9
+ import { join, dirname } from "path";
10
+ import { homedir } from "os";
11
+ var HOOK_MARKER = "openacp-inject-session.sh";
12
+ function expandPath(p) {
13
+ return p.replace(/^~/, homedir());
14
+ }
15
+ function generateInjectScript(_agentKey, spec) {
16
+ const sidVar = spec.sessionIdVar ?? "SESSION_ID";
17
+ const cwdVar = spec.workingDirVar ?? "WORKING_DIR";
18
+ if (spec.outputFormat === "plaintext") {
19
+ return `#!/bin/bash
20
+ INPUT=$(cat)
21
+ SESSION_ID=$(echo "$INPUT" | jq -r '${spec.sessionIdField}')
22
+ CWD=$(echo "$INPUT" | jq -r '.cwd')
23
+
24
+ echo "${sidVar}: $SESSION_ID"
25
+ echo "${cwdVar}: $CWD"
26
+
27
+ exit 0
28
+ `;
29
+ }
30
+ return `#!/bin/bash
31
+ INPUT=$(cat)
32
+ SESSION_ID=$(echo "$INPUT" | jq -r '${spec.sessionIdField}')
33
+ CWD=$(echo "$INPUT" | jq -r '.cwd')
34
+
35
+ jq -n --arg sid "$SESSION_ID" --arg cwd "$CWD" \\
36
+ '{"additionalContext":"${sidVar}: \\($sid)\\n${cwdVar}: \\($cwd)"}'
37
+
38
+ exit 0
39
+ `;
40
+ }
41
+ function generateHandoffScript(agentKey) {
42
+ return `#!/bin/bash
43
+ SESSION_ID=$1
44
+ CWD=$2
45
+
46
+ if [ -z "$SESSION_ID" ]; then
47
+ echo "Usage: openacp-handoff.sh <session_id> [cwd]"
48
+ exit 1
49
+ fi
50
+
51
+ openacp adopt ${agentKey} "$SESSION_ID" \${CWD:+--cwd "$CWD"}
52
+ `;
53
+ }
54
+ function generateHandoffCommand(_agentKey, spec) {
55
+ const sidVar = spec.sessionIdVar ?? "SESSION_ID";
56
+ const cwdVar = spec.workingDirVar ?? "WORKING_DIR";
57
+ const hooksDir = expandPath(spec.hooksDirPath);
58
+ return `---
59
+ description: Transfer current session to OpenACP (Telegram)
60
+ ---
61
+
62
+ Look at the context injected at the start of this message to find
63
+ ${sidVar} and ${cwdVar}, then run:
64
+
65
+ bash ${hooksDir}openacp-handoff.sh <${sidVar}> <${cwdVar}>
66
+ `;
67
+ }
68
+ function mergeSettingsJson(settingsPath, hookEvent, hookScriptPath) {
69
+ const fullPath = expandPath(settingsPath);
70
+ let settings = {};
71
+ if (existsSync(fullPath)) {
72
+ const raw = readFileSync(fullPath, "utf-8");
73
+ writeFileSync(`${fullPath}.bak`, raw);
74
+ settings = JSON.parse(raw);
75
+ }
76
+ const hooks = settings.hooks ?? {};
77
+ settings.hooks = hooks;
78
+ const eventHooks = hooks[hookEvent] ?? [];
79
+ hooks[hookEvent] = eventHooks;
80
+ const alreadyInstalled = eventHooks.some(
81
+ (group) => group.hooks?.some((h) => h.command?.includes(HOOK_MARKER))
82
+ );
83
+ if (!alreadyInstalled) {
84
+ eventHooks.push({
85
+ hooks: [{ type: "command", command: hookScriptPath }]
86
+ });
87
+ }
88
+ mkdirSync(dirname(fullPath), { recursive: true });
89
+ writeFileSync(fullPath, JSON.stringify(settings, null, 2) + "\n");
90
+ }
91
+ function mergeHooksJson(settingsPath, hookEvent, hookScriptPath) {
92
+ const fullPath = expandPath(settingsPath);
93
+ let config = { version: 1 };
94
+ if (existsSync(fullPath)) {
95
+ const raw = readFileSync(fullPath, "utf-8");
96
+ writeFileSync(`${fullPath}.bak`, raw);
97
+ config = JSON.parse(raw);
98
+ }
99
+ const hooks = config.hooks ?? {};
100
+ config.hooks = hooks;
101
+ const eventHooks = hooks[hookEvent] ?? [];
102
+ hooks[hookEvent] = eventHooks;
103
+ const alreadyInstalled = eventHooks.some((h) => h.command?.includes(HOOK_MARKER));
104
+ if (!alreadyInstalled) {
105
+ eventHooks.push({ command: hookScriptPath });
106
+ }
107
+ mkdirSync(dirname(fullPath), { recursive: true });
108
+ writeFileSync(fullPath, JSON.stringify(config, null, 2) + "\n");
109
+ }
110
+ function removeFromSettingsJson(settingsPath, hookEvent) {
111
+ const fullPath = expandPath(settingsPath);
112
+ if (!existsSync(fullPath)) return;
113
+ const raw = readFileSync(fullPath, "utf-8");
114
+ const settings = JSON.parse(raw);
115
+ const hooks = settings.hooks;
116
+ if (!hooks?.[hookEvent]) return;
117
+ hooks[hookEvent] = hooks[hookEvent].filter(
118
+ (group) => !group.hooks?.some((h) => h.command?.includes("openacp-"))
119
+ );
120
+ if (hooks[hookEvent].length === 0) {
121
+ delete hooks[hookEvent];
122
+ }
123
+ writeFileSync(fullPath, JSON.stringify(settings, null, 2) + "\n");
124
+ }
125
+ function removeFromHooksJson(settingsPath, hookEvent) {
126
+ const fullPath = expandPath(settingsPath);
127
+ if (!existsSync(fullPath)) return;
128
+ const raw = readFileSync(fullPath, "utf-8");
129
+ const config = JSON.parse(raw);
130
+ const hooks = config.hooks;
131
+ if (!hooks?.[hookEvent]) return;
132
+ hooks[hookEvent] = hooks[hookEvent].filter(
133
+ (h) => !h.command?.includes("openacp-")
134
+ );
135
+ if (hooks[hookEvent].length === 0) {
136
+ delete hooks[hookEvent];
137
+ }
138
+ writeFileSync(fullPath, JSON.stringify(config, null, 2) + "\n");
139
+ }
140
+ async function installIntegration(agentKey, spec) {
141
+ const logs = [];
142
+ try {
143
+ if (!commandExists("jq")) {
144
+ return {
145
+ success: false,
146
+ logs: ["jq is required for handoff hooks. Install: brew install jq (macOS) or apt install jq (Linux)"]
147
+ };
148
+ }
149
+ const hooksDir = expandPath(spec.hooksDirPath);
150
+ mkdirSync(hooksDir, { recursive: true });
151
+ const injectPath = join(hooksDir, "openacp-inject-session.sh");
152
+ writeFileSync(injectPath, generateInjectScript(agentKey, spec));
153
+ chmodSync(injectPath, 493);
154
+ logs.push(`Created ${injectPath}`);
155
+ const handoffPath = join(hooksDir, "openacp-handoff.sh");
156
+ writeFileSync(handoffPath, generateHandoffScript(agentKey));
157
+ chmodSync(handoffPath, 493);
158
+ logs.push(`Created ${handoffPath}`);
159
+ if (spec.commandsPath && spec.handoffCommandName) {
160
+ if (spec.commandFormat === "skill") {
161
+ const skillDir = expandPath(join(spec.commandsPath, spec.handoffCommandName));
162
+ mkdirSync(skillDir, { recursive: true });
163
+ const skillPath = join(skillDir, "SKILL.md");
164
+ writeFileSync(skillPath, generateHandoffCommand(agentKey, spec));
165
+ logs.push(`Created ${skillPath}`);
166
+ } else {
167
+ const cmdsDir = expandPath(spec.commandsPath);
168
+ mkdirSync(cmdsDir, { recursive: true });
169
+ const cmdPath = join(cmdsDir, `${spec.handoffCommandName}.md`);
170
+ writeFileSync(cmdPath, generateHandoffCommand(agentKey, spec));
171
+ logs.push(`Created ${cmdPath}`);
172
+ }
173
+ }
174
+ const injectFullPath = join(hooksDir, "openacp-inject-session.sh");
175
+ if (spec.settingsFormat === "hooks_json") {
176
+ mergeHooksJson(spec.settingsPath, spec.hookEvent, injectFullPath);
177
+ } else {
178
+ mergeSettingsJson(spec.settingsPath, spec.hookEvent, injectFullPath);
179
+ }
180
+ logs.push(`Updated ${expandPath(spec.settingsPath)}`);
181
+ return { success: true, logs };
182
+ } catch (err) {
183
+ logs.push(`Error: ${err instanceof Error ? err.message : String(err)}`);
184
+ return { success: false, logs };
185
+ }
186
+ }
187
+ async function uninstallIntegration(agentKey, spec) {
188
+ const logs = [];
189
+ try {
190
+ const hooksDir = expandPath(spec.hooksDirPath);
191
+ for (const filename of ["openacp-inject-session.sh", "openacp-handoff.sh"]) {
192
+ const filePath = join(hooksDir, filename);
193
+ if (existsSync(filePath)) {
194
+ unlinkSync(filePath);
195
+ logs.push(`Removed ${filePath}`);
196
+ }
197
+ }
198
+ if (spec.commandsPath && spec.handoffCommandName) {
199
+ if (spec.commandFormat === "skill") {
200
+ const skillDir = expandPath(join(spec.commandsPath, spec.handoffCommandName));
201
+ const skillPath = join(skillDir, "SKILL.md");
202
+ if (existsSync(skillPath)) {
203
+ unlinkSync(skillPath);
204
+ try {
205
+ rmdirSync(skillDir);
206
+ } catch {
207
+ }
208
+ logs.push(`Removed ${skillPath}`);
209
+ }
210
+ } else {
211
+ const cmdPath = expandPath(join(spec.commandsPath, `${spec.handoffCommandName}.md`));
212
+ if (existsSync(cmdPath)) {
213
+ unlinkSync(cmdPath);
214
+ logs.push(`Removed ${cmdPath}`);
215
+ }
216
+ }
217
+ }
218
+ if (spec.settingsFormat === "hooks_json") {
219
+ removeFromHooksJson(spec.settingsPath, spec.hookEvent);
220
+ } else {
221
+ removeFromSettingsJson(spec.settingsPath, spec.hookEvent);
222
+ }
223
+ logs.push(`Updated ${expandPath(spec.settingsPath)}`);
224
+ return { success: true, logs };
225
+ } catch (err) {
226
+ logs.push(`Error: ${err instanceof Error ? err.message : String(err)}`);
227
+ return { success: false, logs };
228
+ }
229
+ }
230
+ function buildIntegrationItem(agentKey, spec) {
231
+ const hooksDir = expandPath(spec.hooksDirPath);
232
+ return {
233
+ id: "handoff",
234
+ name: "Handoff",
235
+ description: "Transfer sessions between terminal and Telegram",
236
+ isInstalled() {
237
+ return existsSync(join(hooksDir, "openacp-inject-session.sh")) && existsSync(join(hooksDir, "openacp-handoff.sh"));
238
+ },
239
+ install: () => installIntegration(agentKey, spec),
240
+ uninstall: () => uninstallIntegration(agentKey, spec)
241
+ };
242
+ }
243
+ function getIntegration(agentName) {
244
+ const caps = getAgentCapabilities(agentName);
245
+ if (!caps.integration) return void 0;
246
+ return { items: [buildIntegrationItem(agentName, caps.integration)] };
247
+ }
248
+ function listIntegrations() {
249
+ return listAgentsWithIntegration();
250
+ }
251
+ export {
252
+ getIntegration,
253
+ installIntegration,
254
+ listIntegrations,
255
+ uninstallIntegration
256
+ };
257
+ //# sourceMappingURL=integrate-X7LI6MUO.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/agent-dependencies.js\";\nimport type { AgentIntegrationSpec } from \"../core/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 if (spec.outputFormat === \"plaintext\") {\n return `#!/bin/bash\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\nINPUT=$(cat)\nSESSION_ID=$(echo \"$INPUT\" | jq -r '${spec.sessionIdField}')\nCWD=$(echo \"$INPUT\" | jq -r '.cwd')\n\njq -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\n\nif [ -z \"$SESSION_ID\" ]; then\n echo \"Usage: openacp-handoff.sh <session_id> [cwd]\"\n exit 1\nfi\n\nopenacp adopt ${agentKey} \"$SESSION_ID\" \\${CWD:+--cwd \"$CWD\"}\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)\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}>\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 buildIntegrationItem(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 Telegram\",\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\nexport function getIntegration(agentName: string): AgentIntegration | undefined {\n const caps = getAgentCapabilities(agentName);\n if (!caps.integration) return undefined;\n return { items: [buildIntegrationItem(agentName, caps.integration)] };\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;AAErC,MAAI,KAAK,iBAAiB,aAAa;AACrC,WAAO;AAAA;AAAA,sCAE2B,KAAK,cAAc;AAAA;AAAA;AAAA,QAGjD,MAAM;AAAA,QACN,MAAM;AAAA;AAAA;AAAA;AAAA,EAIZ;AAGA,SAAO;AAAA;AAAA,sCAE6B,KAAK,cAAc;AAAA;AAAA;AAAA;AAAA,2BAI9B,MAAM,gBAAgB,MAAM;AAAA;AAAA;AAAA;AAIvD;AAEA,SAAS,sBAAsB,UAA0B;AACvD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBASO,QAAQ;AAAA;AAExB;AAEA,SAAS,uBAAuB,WAAmB,MAAoC;AACrF,QAAM,SAAS,KAAK,gBAAgB;AACpC,QAAM,SAAS,KAAK,iBAAiB;AACrC,QAAM,WAAW,WAAW,KAAK,YAAY;AAE7C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKP,MAAM,QAAQ,MAAM;AAAA;AAAA,OAEf,QAAQ,uBAAuB,MAAM,MAAM,MAAM;AAAA;AAExD;AAIA,SAAS,kBAAkB,cAAsB,WAAmB,gBAA8B;AAChG,QAAM,WAAW,WAAW,YAAY;AACxC,MAAI,WAAoC,CAAC;AAEzC,MAAI,WAAW,QAAQ,GAAG;AACxB,UAAM,MA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