hyperclaw 4.0.2 → 5.0.0

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 (134) hide show
  1. package/README.md +54 -3
  2. package/dist/a2ui-protocol-CfBI44-Q.js +75 -0
  3. package/dist/agents-routing-ChHiZp36.js +327 -0
  4. package/dist/agents-routing-ChqZ6l2S.js +4 -0
  5. package/dist/api-keys-guide-BCcOl0Q7.js +149 -0
  6. package/dist/audit-BaIiyWFu.js +441 -0
  7. package/dist/bounty-tools-DWudyZie.js +211 -0
  8. package/dist/browser-tools-BsTeGMnX.js +5 -0
  9. package/dist/browser-tools-D8_rLe2p.js +179 -0
  10. package/dist/claw-tasks-CgTsiNE8.js +80 -0
  11. package/dist/connector-5N0-X_xs.js +194 -0
  12. package/dist/connector-B3v0qcXg.js +425 -0
  13. package/dist/connector-B8R3iBY1.js +280 -0
  14. package/dist/connector-BAM-08NN.js +189 -0
  15. package/dist/connector-BC8FIVu4.js +181 -0
  16. package/dist/connector-BDmwwaVc.js +213 -0
  17. package/dist/connector-BGjbBy69.js +225 -0
  18. package/dist/connector-BO2SRzfG.js +218 -0
  19. package/dist/connector-BfXky0L3.js +167 -0
  20. package/dist/connector-BiiSJpx3.js +192 -0
  21. package/dist/connector-BnDmIhIu.js +85 -0
  22. package/dist/connector-C1HSoUyk.js +189 -0
  23. package/dist/connector-CKQHZOXg.js +568 -0
  24. package/dist/connector-CRl-iidy.js +239 -0
  25. package/dist/connector-Ci9glMD-.js +340 -0
  26. package/dist/connector-CjtZIEDj.js +181 -0
  27. package/dist/connector-Ck6JtOsX.js +531 -0
  28. package/dist/connector-D8Kelee0.js +286 -0
  29. package/dist/connector-DAnRJ0oP.js +162 -0
  30. package/dist/connector-DXTp5PE8.js +508 -0
  31. package/dist/connector-Dih6dUPP.js +173 -0
  32. package/dist/connector-DqTH_tPX.js +182 -0
  33. package/dist/connector-DrnEiiyP.js +419 -0
  34. package/dist/connector-DtR5GGTX.js +167 -0
  35. package/dist/connector-Tky_qS_K.js +350 -0
  36. package/dist/connector-ZSc3oTTy.js +305 -0
  37. package/dist/connector-sW5yhU1m.js +498 -0
  38. package/dist/connector-u3ICd3Ic.js +552 -0
  39. package/dist/cost-tracker-DD9wtWsr.js +103 -0
  40. package/dist/credentials-store-C6ir0Dae.js +4 -0
  41. package/dist/credentials-store-H13LqOwJ.js +77 -0
  42. package/dist/cron-tasks-Bli7Kzd2.js +82 -0
  43. package/dist/daemon-Bg4GtCmc.js +318 -0
  44. package/dist/daemon-DhmwY8k4.js +5 -0
  45. package/dist/delivery-BmIYy9VQ.js +4 -0
  46. package/dist/delivery-pWUPBp1F.js +95 -0
  47. package/dist/destructive-gate-D6vWOdEl.js +101 -0
  48. package/dist/developer-keys-CPWT7Q6S.js +8 -0
  49. package/dist/developer-keys-DrrcUqFa.js +127 -0
  50. package/dist/doctor-BvCe8BBk.js +230 -0
  51. package/dist/doctor-CxyPLYsJ.js +6 -0
  52. package/dist/engine-CEDSqXfw.js +256 -0
  53. package/dist/engine-Da4JMNpI.js +7 -0
  54. package/dist/env-resolve-CiXbWYwe.js +10 -0
  55. package/dist/env-resolve-CmGWhWXJ.js +115 -0
  56. package/dist/extraction-tools-HOZstZ0y.js +91 -0
  57. package/dist/extraction-tools-m4lmAv7l.js +5 -0
  58. package/dist/form_data-Cz040rio.js +8657 -0
  59. package/dist/gmail-watch-setup-Du7DVV7S.js +40 -0
  60. package/dist/health-B-asI__D.js +6 -0
  61. package/dist/health-Ds2YlpTB.js +152 -0
  62. package/dist/heartbeat-engine-BYT5ayQH.js +83 -0
  63. package/dist/hub-D0XwdjM-.js +515 -0
  64. package/dist/hub-LiD5Iztb.js +6 -0
  65. package/dist/hyperclawbot-zvczQgKx.js +505 -0
  66. package/dist/inference-BKVkBREb.js +6 -0
  67. package/dist/inference-DCXH4Q3x.js +922 -0
  68. package/dist/knowledge-graph-iBG76fvm.js +131 -0
  69. package/dist/loader-CC45xGpC.js +4 -0
  70. package/dist/loader-CnEdOyjT.js +400 -0
  71. package/dist/logger-ybOp7VOC.js +83 -0
  72. package/dist/manager-03ipO9R0.js +105 -0
  73. package/dist/manager-BpDfbDjg.js +117 -0
  74. package/dist/manager-Bxl0sqlh.js +4 -0
  75. package/dist/manager-CrVDn6eN.js +6 -0
  76. package/dist/manager-FCgF1plu.js +218 -0
  77. package/dist/manager-rgCsaWT1.js +40 -0
  78. package/dist/mcp-CfoSU4Uz.js +139 -0
  79. package/dist/mcp-loader-DkRBsLpk.js +94 -0
  80. package/dist/memory-BlHL7JCO.js +4 -0
  81. package/dist/memory-DsS_eFvJ.js +270 -0
  82. package/dist/memory-auto-BkvtSFUw.js +5 -0
  83. package/dist/memory-auto-Bnz_-1wP.js +306 -0
  84. package/dist/memory-integration-cSYkZyEo.js +91 -0
  85. package/dist/moltbook-BtLDZTfM.js +81 -0
  86. package/dist/node-Dw2Gi-cP.js +222 -0
  87. package/dist/nodes-registry-B8dmrlLv.js +52 -0
  88. package/dist/oauth-flow-DQPvMHRH.js +150 -0
  89. package/dist/oauth-provider-Uo4Nib_c.js +110 -0
  90. package/dist/observability-BV-Yx0V9.js +89 -0
  91. package/dist/onboard-0WoDxbv_.js +10 -0
  92. package/dist/onboard-BXNXCQp4.js +4070 -0
  93. package/dist/orchestrator-DmnEvMaL.js +189 -0
  94. package/dist/orchestrator-RI3bpqqc.js +6 -0
  95. package/dist/pairing-6iM27aD8.js +196 -0
  96. package/dist/pairing-dGoiGepK.js +4 -0
  97. package/dist/pc-access-CgCsYrpt.js +8 -0
  98. package/dist/pc-access-_iH2aorG.js +819 -0
  99. package/dist/pending-approval-CUXjysAo.js +22 -0
  100. package/dist/reminders-store-Drjed_-h.js +58 -0
  101. package/dist/renderer-BVQrd0_g.js +225 -0
  102. package/dist/rules-BE4GV6cV.js +103 -0
  103. package/dist/run-main.js +1607 -443
  104. package/dist/runner-DatMMYYE.js +1271 -0
  105. package/dist/sdk/index.js +2 -2
  106. package/dist/sdk/index.mjs +2 -2
  107. package/dist/security-BqNyT4ID.js +4 -0
  108. package/dist/security-tpgqPWWH.js +73 -0
  109. package/dist/server-D4wVHiX9.js +4 -0
  110. package/dist/server-Dh3JlBFB.js +1255 -0
  111. package/dist/session-store-BUiPz0Vv.js +5 -0
  112. package/dist/session-store-is4B6qmD.js +113 -0
  113. package/dist/sessions-tools-CbUTFe4i.js +5 -0
  114. package/dist/sessions-tools-CeqD7iil.js +95 -0
  115. package/dist/skill-loader-BaNLVmJy.js +7 -0
  116. package/dist/skill-loader-HgpF6Vqs.js +159 -0
  117. package/dist/skill-runtime-CJN24QPW.js +102 -0
  118. package/dist/skill-runtime-w1ig_lcw.js +5 -0
  119. package/dist/src-BxPHKO5x.js +63 -0
  120. package/dist/src-DIc-L2IG.js +20 -0
  121. package/dist/src-g_rNx5rh.js +458 -0
  122. package/dist/sub-agent-tools-CHQoHz9c.js +39 -0
  123. package/dist/theme-DcxwcUgZ.js +180 -0
  124. package/dist/theme-cx0fkgWC.js +8 -0
  125. package/dist/tool-policy-CNT-mF2Z.js +189 -0
  126. package/dist/tts-elevenlabs-BRosZv-f.js +61 -0
  127. package/dist/update-check-C2Dz85wJ.js +81 -0
  128. package/dist/vision-BMmiIKy7.js +121 -0
  129. package/dist/vision-tools-DVuYc17I.js +51 -0
  130. package/dist/vision-tools-U3YC4L-g.js +5 -0
  131. package/dist/voice-transcription-B555DbWR.js +138 -0
  132. package/dist/website-watch-tools-DFMrJU-R.js +139 -0
  133. package/dist/website-watch-tools-Du3W5sN7.js +5 -0
  134. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+
3
+ //#region packages/core/src/agent/orchestrator.ts
4
+ /** Parse parallel plan into waves: [['A'], ['B','C'], ['D']] = A then B||C then D. */
5
+ function parseParallelWaves(text) {
6
+ const waves = [];
7
+ const lines = (text || "").trim().split(/\n/);
8
+ for (const line of lines) {
9
+ const m = line.match(/^\s*\d+\.\s*(.+)$/);
10
+ if (!m) continue;
11
+ const parts = m[1].split(/\|/).map((s) => s.trim()).filter(Boolean);
12
+ if (parts.length > 0) waves.push(parts);
13
+ }
14
+ return waves;
15
+ }
16
+ /** Parse "1. X\n2. Y" into step strings. */
17
+ function parseSteps(text) {
18
+ const steps = [];
19
+ const lines = (text || "").trim().split(/\n/);
20
+ for (const line of lines) {
21
+ const m = line.match(/^\s*\d+\.\s*(.+)$/);
22
+ if (m) steps.push(m[1].trim());
23
+ }
24
+ return steps.length > 0 ? steps : [];
25
+ }
26
+ /** Multi-step with retry, session context, checkpointing, error recovery. */
27
+ async function runMultiStep(goal, opts) {
28
+ const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-Da4JMNpI.js"));
29
+ const maxRetries = opts.maxStepRetries ?? 2;
30
+ const checkpointable = opts.checkpointable ?? false;
31
+ let steps;
32
+ let results = [];
33
+ let startIndex = 0;
34
+ if (opts.checkpoint && opts.checkpoint.goal === goal && opts.checkpoint.steps.length > 0) {
35
+ steps = opts.checkpoint.steps;
36
+ results = [...opts.checkpoint.results ?? []];
37
+ startIndex = results.length;
38
+ } else {
39
+ const planOpts = opts.sessionId && opts.appendTranscript ? opts : {
40
+ ...opts,
41
+ sessionId: opts.sessionId,
42
+ appendTranscript: opts.appendTranscript
43
+ };
44
+ const planResult = await runAgentEngine(`${PLAN_PROMPT}\n\nGoal: ${goal}`, planOpts);
45
+ steps = parseSteps(planResult.text);
46
+ if (steps.length === 0) return runAgentEngine(goal, opts);
47
+ }
48
+ let lastUsage;
49
+ for (let i = startIndex; i < steps.length; i++) {
50
+ const step = steps[i];
51
+ const ctx = results.length > 0 ? `Previous results:\n${results.map((r, j) => `Step ${j + 1}: ${r.slice(0, 400)}${r.length > 400 ? "..." : ""}`).join("\n")}\n\n` : "";
52
+ const message = `${ctx}Step ${i + 1}: ${step}`;
53
+ let lastErr;
54
+ let stepResult;
55
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
56
+ stepResult = await runAgentEngine(message, opts);
57
+ if (stepResult.usage) lastUsage = stepResult.usage;
58
+ if (!stepResult.error) {
59
+ results.push(stepResult.text);
60
+ if (checkpointable && opts.onCheckpoint) await Promise.resolve(opts.onCheckpoint({
61
+ goal,
62
+ steps,
63
+ completedIndices: [...Array(results.length)].map((_, k) => k),
64
+ results: [...results]
65
+ }));
66
+ break;
67
+ }
68
+ lastErr = stepResult.error;
69
+ if (attempt < maxRetries && opts.onToken) opts.onToken(`[Retry ${attempt + 1}/${maxRetries} for step ${i + 1}…]\n`);
70
+ }
71
+ if (lastErr) {
72
+ const summary$1 = results.length > 0 ? results.map((r, j) => `**Step ${j + 1}**\n${r}`).join("\n\n---\n\n") + `\n\n**Step ${i + 1}** (failed): ${lastErr}` : `Step ${i + 1} failed: ${lastErr}`;
73
+ opts.onDone?.(summary$1);
74
+ return {
75
+ text: summary$1,
76
+ error: lastErr,
77
+ usage: lastUsage
78
+ };
79
+ }
80
+ }
81
+ const summary = results.map((r, i) => `**Step ${i + 1}**\n${r}`).join("\n\n---\n\n");
82
+ opts.onDone?.(summary);
83
+ return {
84
+ text: summary,
85
+ usage: lastUsage
86
+ };
87
+ }
88
+ /** Parallel sub-agents: plan waves → run each wave in parallel (Promise.all) → aggregate. */
89
+ async function runMultiStepParallel(goal, opts) {
90
+ const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-Da4JMNpI.js"));
91
+ const planOpts = {
92
+ ...opts,
93
+ sessionId: void 0,
94
+ appendTranscript: void 0
95
+ };
96
+ const planResult = await runAgentEngine(`${PARALLEL_PLAN_PROMPT}\n\nGoal: ${goal}`, planOpts);
97
+ const waves = parseParallelWaves(planResult.text);
98
+ if (waves.length === 0) return runAgentEngine(goal, opts);
99
+ const allResults = [];
100
+ let lastUsage = planResult.usage;
101
+ for (let w = 0; w < waves.length; w++) {
102
+ const wave = waves[w];
103
+ const ctx = allResults.length > 0 ? `Previous results:\n${allResults.map((r, j) => `Result ${j + 1}: ${r.slice(0, 300)}${r.length > 300 ? "..." : ""}`).join("\n")}\n\n` : "";
104
+ const messages = wave.map((step, i) => `${ctx}Sub-task ${w + 1}.${i + 1}: ${step}`);
105
+ const runOpts = {
106
+ ...opts,
107
+ onToken: void 0,
108
+ onDone: void 0
109
+ };
110
+ const results = await Promise.all(messages.map((msg) => runAgentEngine(msg, runOpts)));
111
+ for (const r of results) {
112
+ if (r.usage) lastUsage = r.usage;
113
+ if (r.error) {
114
+ const summary$1 = allResults.map((r0, j) => `**Sub-agent ${j + 1}**\n${r0}`).join("\n\n---\n\n") + `\n\n**Failed**\n${r.text}`;
115
+ opts.onDone?.(summary$1);
116
+ return {
117
+ text: summary$1,
118
+ error: r.error,
119
+ usage: lastUsage
120
+ };
121
+ }
122
+ allResults.push(r.text);
123
+ }
124
+ }
125
+ const summary = allResults.map((r, i) => `**Sub-agent ${i + 1}**\n${r}`).join("\n\n---\n\n");
126
+ opts.onDone?.(summary);
127
+ return {
128
+ text: summary,
129
+ usage: lastUsage
130
+ };
131
+ }
132
+ /** Single-run passthrough (unchanged). */
133
+ async function runWithPlan(message, opts) {
134
+ const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-Da4JMNpI.js"));
135
+ return runAgentEngine(message, opts);
136
+ }
137
+ async function planSteps(goal) {
138
+ const { runAgentEngine } = await Promise.resolve().then(() => require("./engine-Da4JMNpI.js"));
139
+ const r = await runAgentEngine(`${PLAN_PROMPT}\n\nGoal: ${goal}`, {});
140
+ return parseSteps(r.text).map((g) => ({ goal: g }));
141
+ }
142
+ var PLAN_PROMPT, PARALLEL_PLAN_PROMPT;
143
+ var init_orchestrator = require_chunk.__esm({ "packages/core/src/agent/orchestrator.ts"() {
144
+ PLAN_PROMPT = `Break this goal into 1-4 concrete, executable steps. Output ONLY numbered lines.
145
+ Format: 1. step one
146
+ 2. step two
147
+ ...
148
+ No other text.`;
149
+ PARALLEL_PLAN_PROMPT = `Break this goal into 2-6 steps. Steps that can run IN PARALLEL (independent) put on the SAME line with | between them.
150
+ Format:
151
+ 1. step one
152
+ 2. step A | step B
153
+ 3. step three
154
+ Example: "Compare Python vs Node for APIs" → 1. research Python for APIs | research Node for APIs
155
+ 2. summarize comparison
156
+ Output ONLY numbered lines. No other text.`;
157
+ } });
158
+
159
+ //#endregion
160
+ Object.defineProperty(exports, 'init_orchestrator', {
161
+ enumerable: true,
162
+ get: function () {
163
+ return init_orchestrator;
164
+ }
165
+ });
166
+ Object.defineProperty(exports, 'planSteps', {
167
+ enumerable: true,
168
+ get: function () {
169
+ return planSteps;
170
+ }
171
+ });
172
+ Object.defineProperty(exports, 'runMultiStep', {
173
+ enumerable: true,
174
+ get: function () {
175
+ return runMultiStep;
176
+ }
177
+ });
178
+ Object.defineProperty(exports, 'runMultiStepParallel', {
179
+ enumerable: true,
180
+ get: function () {
181
+ return runMultiStepParallel;
182
+ }
183
+ });
184
+ Object.defineProperty(exports, 'runWithPlan', {
185
+ enumerable: true,
186
+ get: function () {
187
+ return runWithPlan;
188
+ }
189
+ });
@@ -0,0 +1,6 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_orchestrator = require('./orchestrator-DmnEvMaL.js');
3
+
4
+ require_orchestrator.init_orchestrator();
5
+ exports.runMultiStep = require_orchestrator.runMultiStep;
6
+ exports.runMultiStepParallel = require_orchestrator.runMultiStepParallel;
@@ -0,0 +1,196 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const chalk = require_chunk.__toESM(require("chalk"));
3
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
4
+ const path = require_chunk.__toESM(require("path"));
5
+ const os = require_chunk.__toESM(require("os"));
6
+ const crypto = require_chunk.__toESM(require("crypto"));
7
+
8
+ //#region src/channels/pairing.ts
9
+ const CREDENTIALS_DIR = path.default.join(os.default.homedir(), ".hyperclaw", "credentials");
10
+ const CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
11
+ const CODE_LENGTH = 8;
12
+ const EXPIRY_MS = 60 * 60 * 1e3;
13
+ const MAX_PENDING_PER_CHANNEL = 3;
14
+ function generateCode() {
15
+ const bytes = crypto.default.randomBytes(CODE_LENGTH);
16
+ return Array.from(bytes).map((b) => CODE_ALPHABET[b % CODE_ALPHABET.length]).join("");
17
+ }
18
+ function pendingFile(channelId) {
19
+ return path.default.join(CREDENTIALS_DIR, `${channelId}-pairing.json`);
20
+ }
21
+ function allowFromFile(channelId, accountId = "default") {
22
+ const suffix = accountId === "default" ? "" : `-${accountId}`;
23
+ return path.default.join(CREDENTIALS_DIR, `${channelId}${suffix}-allowFrom.json`);
24
+ }
25
+ async function readPending(channelId) {
26
+ try {
27
+ const data = await fs_extra.default.readJson(pendingFile(channelId));
28
+ return Array.isArray(data) ? data : [];
29
+ } catch {
30
+ return [];
31
+ }
32
+ }
33
+ async function writePending(channelId, entries) {
34
+ await fs_extra.default.ensureDir(CREDENTIALS_DIR);
35
+ await fs_extra.default.writeJson(pendingFile(channelId), entries, {
36
+ spaces: 2,
37
+ mode: 384
38
+ });
39
+ }
40
+ async function readAllowFrom(channelId, accountId = "default") {
41
+ try {
42
+ return await fs_extra.default.readJson(allowFromFile(channelId, accountId));
43
+ } catch {
44
+ return {
45
+ senderIds: [],
46
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
47
+ };
48
+ }
49
+ }
50
+ async function writeAllowFrom(channelId, store, accountId = "default") {
51
+ await fs_extra.default.ensureDir(CREDENTIALS_DIR);
52
+ await fs_extra.default.writeJson(allowFromFile(channelId, accountId), store, {
53
+ spaces: 2,
54
+ mode: 384
55
+ });
56
+ }
57
+ var PairingStore = class {
58
+ channelId;
59
+ accountId;
60
+ constructor(channelId, accountId = "default") {
61
+ this.channelId = channelId;
62
+ this.accountId = accountId;
63
+ }
64
+ async isApproved(senderId) {
65
+ const store = await readAllowFrom(this.channelId, this.accountId);
66
+ return store.senderIds.includes(senderId);
67
+ }
68
+ /**
69
+ * Returns the pairing code to send to the user, or null if already pending
70
+ * (code is resent only once per hour per sender).
71
+ */
72
+ async createRequest(senderId) {
73
+ const now = Date.now();
74
+ const entries = (await readPending(this.channelId)).filter((e) => {
75
+ return new Date(e.expiresAt).getTime() > now;
76
+ });
77
+ const existing = entries.find((e) => e.senderId === senderId && e.channelId === this.channelId);
78
+ if (existing) return existing.code;
79
+ const channelPending = entries.filter((e) => e.channelId === this.channelId && e.accountId === this.accountId);
80
+ if (channelPending.length >= MAX_PENDING_PER_CHANNEL) return null;
81
+ const code = generateCode();
82
+ const entry = {
83
+ code,
84
+ channelId: this.channelId,
85
+ accountId: this.accountId,
86
+ senderId,
87
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
88
+ expiresAt: new Date(now + EXPIRY_MS).toISOString()
89
+ };
90
+ entries.push(entry);
91
+ await writePending(this.channelId, entries);
92
+ return code;
93
+ }
94
+ /**
95
+ * Called when a sender submits a code.
96
+ * Returns true if the code was valid and the sender is now approved.
97
+ */
98
+ async verify(code, senderId) {
99
+ const now = Date.now();
100
+ const entries = await readPending(this.channelId);
101
+ const idx = entries.findIndex((e) => e.code === code.toUpperCase() && e.channelId === this.channelId && e.accountId === this.accountId && new Date(e.expiresAt).getTime() > now);
102
+ if (idx === -1) return false;
103
+ const entry = entries[idx];
104
+ entries.splice(idx, 1);
105
+ await writePending(this.channelId, entries);
106
+ const store = await readAllowFrom(this.channelId, this.accountId);
107
+ if (!store.senderIds.includes(entry.senderId)) store.senderIds.push(entry.senderId);
108
+ store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
109
+ await writeAllowFrom(this.channelId, store, this.accountId);
110
+ return true;
111
+ }
112
+ async listPending() {
113
+ const now = Date.now();
114
+ const entries = await readPending(this.channelId);
115
+ return entries.filter((e) => e.channelId === this.channelId && e.accountId === this.accountId && new Date(e.expiresAt).getTime() > now);
116
+ }
117
+ async cliApprove(code) {
118
+ const now = Date.now();
119
+ const entries = await readPending(this.channelId);
120
+ const idx = entries.findIndex((e) => e.code === code.toUpperCase() && e.channelId === this.channelId && e.accountId === this.accountId && new Date(e.expiresAt).getTime() > now);
121
+ if (idx === -1) return false;
122
+ const entry = entries[idx];
123
+ entries.splice(idx, 1);
124
+ await writePending(this.channelId, entries);
125
+ const store = await readAllowFrom(this.channelId, this.accountId);
126
+ if (!store.senderIds.includes(entry.senderId)) store.senderIds.push(entry.senderId);
127
+ store.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
128
+ await writeAllowFrom(this.channelId, store, this.accountId);
129
+ return true;
130
+ }
131
+ };
132
+ const SUPPORTED_CHANNELS = [
133
+ "telegram",
134
+ "whatsapp",
135
+ "signal",
136
+ "imessage",
137
+ "discord",
138
+ "slack",
139
+ "feishu"
140
+ ];
141
+ var GlobalPairingManager = class {
142
+ async showList(channelFilter) {
143
+ const now = Date.now();
144
+ const channels = channelFilter ? [channelFilter] : SUPPORTED_CHANNELS;
145
+ console.log(chalk.default.bold.cyan("\n 🔑 PAIRING CODES\n"));
146
+ let total = 0;
147
+ for (const ch of channels) {
148
+ let pending = [];
149
+ try {
150
+ const raw = await readPending(ch);
151
+ pending = raw.filter((e) => new Date(e.expiresAt).getTime() > now);
152
+ } catch {}
153
+ if (pending.length === 0) continue;
154
+ total += pending.length;
155
+ console.log(chalk.default.yellow(` ─── ${ch} ───`));
156
+ for (const e of pending) {
157
+ const expiresIn = Math.round((new Date(e.expiresAt).getTime() - now) / 6e4);
158
+ const acctSuffix = e.accountId !== "default" ? chalk.default.gray(` [${e.accountId}]`) : "";
159
+ console.log(` ${chalk.default.yellow("○")} ${chalk.default.bold(e.code)} sender: ${chalk.default.white(e.senderId)}${acctSuffix} expires: ${chalk.default.gray(`${expiresIn}m`)}`);
160
+ }
161
+ console.log();
162
+ }
163
+ if (total === 0) console.log(chalk.default.gray(` No pending pairing requests${channelFilter ? ` for ${channelFilter}` : ""}.\n`));
164
+ }
165
+ async cliApprove(channelId, code, accountId = "default") {
166
+ if (!SUPPORTED_CHANNELS.includes(channelId)) {
167
+ console.log(chalk.default.red(`\n ✖ Unknown channel: ${channelId}`));
168
+ console.log(chalk.default.gray(` Supported: ${SUPPORTED_CHANNELS.join(", ")}\n`));
169
+ return;
170
+ }
171
+ const store = new PairingStore(channelId, accountId);
172
+ const ok = await store.cliApprove(code);
173
+ if (ok) {
174
+ console.log(chalk.default.green(`\n ✔ Pairing approved — ${channelId} code ${code.toUpperCase()}`));
175
+ console.log(chalk.default.gray(` Sender added to ${channelId}${accountId !== "default" ? `-${accountId}` : ""}-allowFrom.json\n`));
176
+ } else console.log(chalk.default.red(`\n ✖ Code not found, expired, or already used: ${channelId} ${code.toUpperCase()}\n`));
177
+ }
178
+ async getApprovedSenders(channelId, accountId = "default") {
179
+ const store = await readAllowFrom(channelId, accountId);
180
+ return store.senderIds;
181
+ }
182
+ };
183
+
184
+ //#endregion
185
+ Object.defineProperty(exports, 'GlobalPairingManager', {
186
+ enumerable: true,
187
+ get: function () {
188
+ return GlobalPairingManager;
189
+ }
190
+ });
191
+ Object.defineProperty(exports, 'PairingStore', {
192
+ enumerable: true,
193
+ get: function () {
194
+ return PairingStore;
195
+ }
196
+ });
@@ -0,0 +1,4 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_pairing = require('./pairing-6iM27aD8.js');
3
+
4
+ exports.PairingStore = require_pairing.PairingStore;
@@ -0,0 +1,8 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ require('./paths-AIyBxIzm.js');
3
+ require('./src-DIc-L2IG.js');
4
+ const require_pc_access = require('./pc-access-_iH2aorG.js');
5
+
6
+ require_pc_access.init_pc_access();
7
+ exports.getPCAccessTools = require_pc_access.getPCAccessTools;
8
+ exports.loadPCAccessConfig = require_pc_access.loadPCAccessConfig;