cclawd 1.0.4 → 1.0.6

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 (123) hide show
  1. package/dist/{active-listener-BLd27Pxd.js → active-listener-Dkhmfuwx.js} +1 -1
  2. package/dist/{api-key-rotation-Dg3JlNDQ.js → api-key-rotation-BOfI3cG3.js} +1 -1
  3. package/dist/{audio-preflight-eV5m9mMp.js → audio-preflight-CtkZ5SAs.js} +6 -6
  4. package/dist/{audio-transcription-runner-CQU4Eg1M.js → audio-transcription-runner-CbPqoiHX.js} +6 -6
  5. package/dist/build-info.json +3 -3
  6. package/dist/bundled/boot-md/handler.js +23 -23
  7. package/dist/bundled/session-memory/handler.js +23 -23
  8. package/dist/{channel-activity-dT3cYb0e.js → channel-activity-DWAER4wd.js} +1 -1
  9. package/dist/{commands-registry-CyLMCPuP.js → commands-registry-BUyiA7nE.js} +1 -1
  10. package/dist/compact.runtime-DpcZpcTl.js +39 -0
  11. package/dist/{deliver-B6eTtXSk.js → deliver-aHOaRbkt.js} +4 -4
  12. package/dist/{deliver-runtime-CLDpY6AW.js → deliver-runtime-D4bCsr6d.js} +7 -7
  13. package/dist/{deps-send-discord.runtime-CxADlame.js → deps-send-discord.runtime-BziKU-pE.js} +7 -7
  14. package/dist/{deps-send-imessage.runtime-Wi79xm6H.js → deps-send-imessage.runtime-CFRnDTqp.js} +7 -7
  15. package/dist/{deps-send-signal.runtime-BDtzvsnR.js → deps-send-signal.runtime-BuOtABJm.js} +6 -6
  16. package/dist/{deps-send-slack.runtime-CgX24hgT.js → deps-send-slack.runtime-BOLqvMxW.js} +5 -5
  17. package/dist/{deps-send-telegram.runtime-CEWc7ePn.js → deps-send-telegram.runtime-DeEoFLv5.js} +6 -6
  18. package/dist/deps-send-whatsapp.runtime-CG1uXYLY.js +43 -0
  19. package/dist/{diagnostic-BZmAxdu9.js → diagnostic-BdcXX9iJ.js} +1 -1
  20. package/dist/{fetch-CMLoICyN.js → fetch-D9NUULbj.js} +2 -2
  21. package/dist/{fetch-guard-DCj3k042.js → fetch-guard-B5ZMnGaN.js} +1 -1
  22. package/dist/{image-Bt49ybRv.js → image-4x07m4Jl.js} +2 -2
  23. package/dist/{image-runtime-Cilhq73U.js → image-runtime-smkMrIol.js} +2 -2
  24. package/dist/{ir-CVtBjUiL.js → ir-CsgNUpOU.js} +2 -2
  25. package/dist/llm-slug-generator.js +23 -23
  26. package/dist/{login-D0fUoX-p.js → login-p_O59TVQ.js} +2 -2
  27. package/dist/{login-qr-ClBxstxZ.js → login-qr-BCJpDsAy.js} +2 -2
  28. package/dist/{manager-DSfEj66R.js → manager-CwYv8O3T.js} +3 -3
  29. package/dist/{manager-runtime-BrZlGJsj.js → manager-runtime-D_jEoBr9.js} +4 -4
  30. package/dist/{model-selection-CMEj8bpy.js → model-selection-Cv2Puf5z.js} +11 -11
  31. package/dist/{outbound-BxIJyMzV.js → outbound-Chpiwybe.js} +4 -4
  32. package/dist/{outbound-attachment-CVJwpypG.js → outbound-attachment-BnAVJDLe.js} +2 -2
  33. package/dist/{pi-embedded-CHNPEUAv.js → pi-embedded-CJVNBk0y.js} +57 -57
  34. package/dist/{pi-model-discovery-D-r5y7kV.js → pi-model-discovery-7IzK0Uc3.js} +1 -1
  35. package/dist/{pi-model-discovery-runtime-DZQXYmdu.js → pi-model-discovery-runtime-DABef3qy.js} +2 -2
  36. package/dist/{pi-tools.before-tool-call.runtime-DagGpfw0.js → pi-tools.before-tool-call.runtime-BP2UvGJb.js} +2 -2
  37. package/dist/plugin-sdk/index.js +35 -35
  38. package/dist/plugin-sdk/signal.js +2 -2
  39. package/dist/{pw-ai-CoIUdns_.js → pw-ai-DwH5GpEO.js} +1 -1
  40. package/dist/{runtime-whatsapp-login.runtime-ChqE9BkX.js → runtime-whatsapp-login.runtime-BI3U306v.js} +3 -3
  41. package/dist/{runtime-whatsapp-outbound.runtime-yiy6jzKk.js → runtime-whatsapp-outbound.runtime-Bsc2uD09.js} +6 -6
  42. package/dist/{send-V1MRV7QF.js → send-BDnOgWIp.js} +3 -3
  43. package/dist/{send-EDBPXjTT.js → send-C-Q_WPMf.js} +3 -3
  44. package/dist/{send-K2mAG7KC.js → send-DUibfNQD.js} +4 -4
  45. package/dist/{send-4rRrSKp9.js → send-DtBvCnPQ.js} +4 -4
  46. package/dist/{send-BKO1-P1t.js → send-ORtn50qg.js} +3 -3
  47. package/dist/{session-CuVCho2m.js → session-B7imi6T5.js} +1 -1
  48. package/dist/{skill-commands-B55LOaMB.js → skill-commands-B9brPuiL.js} +2 -2
  49. package/dist/{slash-commands.runtime-BchS0VkW.js → slash-commands.runtime-Cf6ygfBp.js} +2 -2
  50. package/dist/{slash-dispatch.runtime-BIKRY3fr.js → slash-dispatch.runtime-CsmvhO5K.js} +23 -23
  51. package/dist/{slash-skill-commands.runtime-BP4jBHU9.js → slash-skill-commands.runtime-CX7stIEP.js} +3 -3
  52. package/dist/{subagent-registry-runtime-DjEYzSyM.js → subagent-registry-runtime-B_S1nf7y.js} +23 -23
  53. package/dist/{tables-BAGqh2XD.js → tables-CjQqTOdD.js} +1 -1
  54. package/dist/{target-errors-CeBF8Pws.js → target-errors-BZE1mc-W.js} +1 -1
  55. package/dist/{web-BRSmQdtm.js → web-Cd8yK1Zq.js} +27 -27
  56. package/dist/{whatsapp-actions-Dxb2K2Xh.js → whatsapp-actions-CYEzUMBI.js} +7 -7
  57. package/extensions/mfa-auth/index.ts +20 -39
  58. package/extensions/mfa-auth/src/auth-manager.ts +0 -4
  59. package/extensions/mfa-auth/src/notification-service.ts +3 -7
  60. package/package.json +1 -1
  61. package/dist/compact.runtime-DGRl4st4.js +0 -39
  62. package/dist/deps-send-whatsapp.runtime-B1KJ7YOp.js +0 -43
  63. package/dist/plugin-sdk/active-listener-CN-tMEvN.js +0 -35
  64. package/dist/plugin-sdk/api-key-rotation-CimGYMBc.js +0 -176
  65. package/dist/plugin-sdk/audio-preflight-C-xXBoE2.js +0 -51
  66. package/dist/plugin-sdk/audio-transcription-runner-CTIHpebA.js +0 -2173
  67. package/dist/plugin-sdk/audit-membership-runtime-BFatB2LJ.js +0 -58
  68. package/dist/plugin-sdk/channel-activity-DO0FEzyj.js +0 -95
  69. package/dist/plugin-sdk/channel-web-Da-__nUF.js +0 -2238
  70. package/dist/plugin-sdk/commands-registry-6no2NNrY.js +0 -1118
  71. package/dist/plugin-sdk/compact.runtime-CCoclu5e.js +0 -35
  72. package/dist/plugin-sdk/config-B9ODwgpz.js +0 -37426
  73. package/dist/plugin-sdk/deliver-B1fFpKjV.js +0 -1757
  74. package/dist/plugin-sdk/deliver-runtime-DB-VRMe1.js +0 -15
  75. package/dist/plugin-sdk/deps-send-discord.runtime-DklqycYG.js +0 -15
  76. package/dist/plugin-sdk/deps-send-imessage.runtime-Chs8zeon.js +0 -14
  77. package/dist/plugin-sdk/deps-send-signal.runtime-clW9aSJP.js +0 -13
  78. package/dist/plugin-sdk/deps-send-slack.runtime-BUx0LYY1.js +0 -13
  79. package/dist/plugin-sdk/deps-send-telegram.runtime-LECSHgMG.js +0 -16
  80. package/dist/plugin-sdk/deps-send-whatsapp.runtime-D2d65fw0.js +0 -40
  81. package/dist/plugin-sdk/diagnostic-CxIvS-C2.js +0 -315
  82. package/dist/plugin-sdk/dispatch-BqlR4dPx.js +0 -105863
  83. package/dist/plugin-sdk/env-b9k1PHMI.js +0 -34
  84. package/dist/plugin-sdk/fetch-PoxzAANT.js +0 -326
  85. package/dist/plugin-sdk/fetch-guard-4UVSZ0uS.js +0 -164
  86. package/dist/plugin-sdk/image-Ch6M4tnJ.js +0 -2420
  87. package/dist/plugin-sdk/image-runtime-CSh2o5wY.js +0 -8
  88. package/dist/plugin-sdk/ir-CugsqGH8.js +0 -1312
  89. package/dist/plugin-sdk/local-roots-adnEg9zb.js +0 -217
  90. package/dist/plugin-sdk/logger-D6zRubj0.js +0 -1164
  91. package/dist/plugin-sdk/login-CYvkQ0At.js +0 -54
  92. package/dist/plugin-sdk/login-qr-ll4NtaT5.js +0 -316
  93. package/dist/plugin-sdk/manager-CHy8IclH.js +0 -3959
  94. package/dist/plugin-sdk/manager-runtime-C70EkEr7.js +0 -11
  95. package/dist/plugin-sdk/outbound-Wzs2iN7X.js +0 -216
  96. package/dist/plugin-sdk/outbound-attachment-khXJwucX.js +0 -17
  97. package/dist/plugin-sdk/paths-BtVqCdw4.js +0 -3063
  98. package/dist/plugin-sdk/pi-model-discovery-Dh4ziodY.js +0 -131
  99. package/dist/plugin-sdk/pi-model-discovery-runtime-b83Xe-HT.js +0 -8
  100. package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-C1z5CDBF.js +0 -349
  101. package/dist/plugin-sdk/proxy-fetch-CJEmoBxi.js +0 -54
  102. package/dist/plugin-sdk/pw-ai-Dj3Cvlzl.js +0 -1990
  103. package/dist/plugin-sdk/qmd-manager-egHUAseQ.js +0 -1581
  104. package/dist/plugin-sdk/resolve-outbound-target-BiICvIKs.js +0 -38
  105. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-DNApufzW.js +0 -9
  106. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-CBmtfIQ8.js +0 -13
  107. package/dist/plugin-sdk/send-CScblaI4.js +0 -532
  108. package/dist/plugin-sdk/send-CeHhnld6.js +0 -407
  109. package/dist/plugin-sdk/send-DP_c8JfR.js +0 -3277
  110. package/dist/plugin-sdk/send-Dc5fI6e8.js +0 -495
  111. package/dist/plugin-sdk/send-l-77_s1_.js +0 -2507
  112. package/dist/plugin-sdk/session-CkOKZaqa.js +0 -166
  113. package/dist/plugin-sdk/skill-commands-BohYCgkq.js +0 -336
  114. package/dist/plugin-sdk/slash-commands.runtime-DpLfVTM6.js +0 -8
  115. package/dist/plugin-sdk/slash-dispatch.runtime-CASMHwpm.js +0 -35
  116. package/dist/plugin-sdk/slash-skill-commands.runtime-D7rrJEci.js +0 -9
  117. package/dist/plugin-sdk/sqlite-CJE3X7Mv.js +0 -1005
  118. package/dist/plugin-sdk/subagent-registry-runtime-B1oo5bih.js +0 -35
  119. package/dist/plugin-sdk/tables-D5VgpTmm.js +0 -53
  120. package/dist/plugin-sdk/target-errors-C6zZ_OpA.js +0 -191
  121. package/dist/plugin-sdk/tokens-DUnJnpMS.js +0 -50
  122. package/dist/plugin-sdk/web-TfUM1nSi.js +0 -39
  123. package/dist/plugin-sdk/whatsapp-actions-DuWJ0j1r.js +0 -71
@@ -1,166 +0,0 @@
1
- import { $a as resolveWebCredsBackupPath, Ja as maybeRestoreCredsFromBackup, Qa as resolveDefaultWebAuthDir, Ul as formatCliCommand, Xa as readCredsJsonRaw, eo as resolveWebCredsPath, ou as VERSION } from "./config-B9ODwgpz.js";
2
- import { D as resolveUserPath, I as danger, J as toPinoLikeLogger, K as getChildLogger, V as success, _ as ensureDir } from "./logger-D6zRubj0.js";
3
- import fs from "node:fs";
4
- import "node:crypto";
5
- import { DisconnectReason, fetchLatestBaileysVersion, makeCacheableSignalKeyStore, makeWASocket, useMultiFileAuthState } from "@whiskeysockets/baileys";
6
- import qrcode from "qrcode-terminal";
7
- //#region src/web/session.ts
8
- let credsSaveQueue = Promise.resolve();
9
- function enqueueSaveCreds(authDir, saveCreds, logger) {
10
- credsSaveQueue = credsSaveQueue.then(() => safeSaveCreds(authDir, saveCreds, logger)).catch((err) => {
11
- logger.warn({ error: String(err) }, "WhatsApp creds save queue error");
12
- });
13
- }
14
- async function safeSaveCreds(authDir, saveCreds, logger) {
15
- try {
16
- const credsPath = resolveWebCredsPath(authDir);
17
- const backupPath = resolveWebCredsBackupPath(authDir);
18
- const raw = readCredsJsonRaw(credsPath);
19
- if (raw) try {
20
- JSON.parse(raw);
21
- fs.copyFileSync(credsPath, backupPath);
22
- try {
23
- fs.chmodSync(backupPath, 384);
24
- } catch {}
25
- } catch {}
26
- } catch {}
27
- try {
28
- await Promise.resolve(saveCreds());
29
- try {
30
- fs.chmodSync(resolveWebCredsPath(authDir), 384);
31
- } catch {}
32
- } catch (err) {
33
- logger.warn({ error: String(err) }, "failed saving WhatsApp creds");
34
- }
35
- }
36
- /**
37
- * Create a Baileys socket backed by the multi-file auth store we keep on disk.
38
- * Consumers can opt into QR printing for interactive login flows.
39
- */
40
- async function createWaSocket(printQr, verbose, opts = {}) {
41
- const logger = toPinoLikeLogger(getChildLogger({ module: "baileys" }, { level: verbose ? "info" : "silent" }), verbose ? "info" : "silent");
42
- const authDir = resolveUserPath(opts.authDir ?? resolveDefaultWebAuthDir());
43
- await ensureDir(authDir);
44
- const sessionLogger = getChildLogger({ module: "web-session" });
45
- maybeRestoreCredsFromBackup(authDir);
46
- const { state, saveCreds } = await useMultiFileAuthState(authDir);
47
- const { version } = await fetchLatestBaileysVersion();
48
- const sock = makeWASocket({
49
- auth: {
50
- creds: state.creds,
51
- keys: makeCacheableSignalKeyStore(state.keys, logger)
52
- },
53
- version,
54
- logger,
55
- printQRInTerminal: false,
56
- browser: [
57
- "openclaw",
58
- "cli",
59
- VERSION
60
- ],
61
- syncFullHistory: false,
62
- markOnlineOnConnect: false
63
- });
64
- sock.ev.on("creds.update", () => enqueueSaveCreds(authDir, saveCreds, sessionLogger));
65
- sock.ev.on("connection.update", (update) => {
66
- try {
67
- const { connection, lastDisconnect, qr } = update;
68
- if (qr) {
69
- opts.onQr?.(qr);
70
- if (printQr) {
71
- console.log("Scan this QR in WhatsApp (Linked Devices):");
72
- qrcode.generate(qr, { small: true });
73
- }
74
- }
75
- if (connection === "close") {
76
- if (getStatusCode(lastDisconnect?.error) === DisconnectReason.loggedOut) console.error(danger(`WhatsApp session logged out. Run: ${formatCliCommand("openclaw channels login")}`));
77
- }
78
- if (connection === "open" && verbose) console.log(success("WhatsApp Web connected."));
79
- } catch (err) {
80
- sessionLogger.error({ error: String(err) }, "connection.update handler error");
81
- }
82
- });
83
- if (sock.ws && typeof sock.ws.on === "function") sock.ws.on("error", (err) => {
84
- sessionLogger.error({ error: String(err) }, "WebSocket error");
85
- });
86
- return sock;
87
- }
88
- async function waitForWaConnection(sock) {
89
- return new Promise((resolve, reject) => {
90
- const evWithOff = sock.ev;
91
- const handler = (...args) => {
92
- const update = args[0] ?? {};
93
- if (update.connection === "open") {
94
- evWithOff.off?.("connection.update", handler);
95
- resolve();
96
- }
97
- if (update.connection === "close") {
98
- evWithOff.off?.("connection.update", handler);
99
- reject(update.lastDisconnect ?? /* @__PURE__ */ new Error("Connection closed"));
100
- }
101
- };
102
- sock.ev.on("connection.update", handler);
103
- });
104
- }
105
- function getStatusCode(err) {
106
- return err?.output?.statusCode ?? err?.status;
107
- }
108
- function safeStringify(value, limit = 800) {
109
- try {
110
- const seen = /* @__PURE__ */ new WeakSet();
111
- const raw = JSON.stringify(value, (_key, v) => {
112
- if (typeof v === "bigint") return v.toString();
113
- if (typeof v === "function") {
114
- const maybeName = v.name;
115
- return `[Function ${typeof maybeName === "string" && maybeName.length > 0 ? maybeName : "anonymous"}]`;
116
- }
117
- if (typeof v === "object" && v) {
118
- if (seen.has(v)) return "[Circular]";
119
- seen.add(v);
120
- }
121
- return v;
122
- }, 2);
123
- if (!raw) return String(value);
124
- return raw.length > limit ? `${raw.slice(0, limit)}…` : raw;
125
- } catch {
126
- return String(value);
127
- }
128
- }
129
- function extractBoomDetails(err) {
130
- if (!err || typeof err !== "object") return null;
131
- const output = err?.output;
132
- if (!output || typeof output !== "object") return null;
133
- const payload = output.payload;
134
- const statusCode = typeof output.statusCode === "number" ? output.statusCode : typeof payload?.statusCode === "number" ? payload.statusCode : void 0;
135
- const error = typeof payload?.error === "string" ? payload.error : void 0;
136
- const message = typeof payload?.message === "string" ? payload.message : void 0;
137
- if (!statusCode && !error && !message) return null;
138
- return {
139
- statusCode,
140
- error,
141
- message
142
- };
143
- }
144
- function formatError(err) {
145
- if (err instanceof Error) return err.message;
146
- if (typeof err === "string") return err;
147
- if (!err || typeof err !== "object") return String(err);
148
- const boom = extractBoomDetails(err) ?? extractBoomDetails(err?.error) ?? extractBoomDetails(err?.lastDisconnect?.error);
149
- const status = boom?.statusCode ?? getStatusCode(err);
150
- const code = err?.code;
151
- const codeText = typeof code === "string" || typeof code === "number" ? String(code) : void 0;
152
- const message = [
153
- boom?.message,
154
- typeof err?.message === "string" ? err.message : void 0,
155
- typeof err?.error?.message === "string" ? err.error?.message : void 0
156
- ].filter((v) => Boolean(v && v.trim().length > 0))[0];
157
- const pieces = [];
158
- if (typeof status === "number") pieces.push(`status=${status}`);
159
- if (boom?.error) pieces.push(boom.error);
160
- if (message) pieces.push(message);
161
- if (codeText) pieces.push(`code=${codeText}`);
162
- if (pieces.length > 0) return pieces.join(" ");
163
- return safeStringify(err);
164
- }
165
- //#endregion
166
- export { waitForWaConnection as i, formatError as n, getStatusCode as r, createWaSocket as t };
@@ -1,336 +0,0 @@
1
- import { I as resolveAgentSkillsFilter, L as resolveAgentWorkspaceDir, M as listAgentIds } from "./paths-BtVqCdw4.js";
2
- import { Yo as createAsyncLock, dc as resolvePluginSkillDirs, sc as buildWorkspaceSkillCommandSpecs } from "./config-B9ODwgpz.js";
3
- import { c as resolveStateDir } from "./paths-eFexkPEh.js";
4
- import { D as resolveUserPath, R as logVerbose, a as createSubsystemLogger, p as CONFIG_DIR } from "./logger-D6zRubj0.js";
5
- import { i as listChatCommands } from "./commands-registry-6no2NNrY.js";
6
- import fs from "node:fs";
7
- import path from "node:path";
8
- import os from "node:os";
9
- import { randomBytes } from "node:crypto";
10
- import chokidar from "chokidar";
11
- //#region src/infra/pairing-files.ts
12
- function resolvePairingPaths(baseDir, subdir) {
13
- const root = baseDir ?? resolveStateDir();
14
- const dir = path.join(root, subdir);
15
- return {
16
- dir,
17
- pendingPath: path.join(dir, "pending.json"),
18
- pairedPath: path.join(dir, "paired.json")
19
- };
20
- }
21
- function pruneExpiredPending(pendingById, nowMs, ttlMs) {
22
- for (const [id, req] of Object.entries(pendingById)) if (nowMs - req.ts > ttlMs) delete pendingById[id];
23
- }
24
- //#endregion
25
- //#region src/infra/pairing-pending.ts
26
- async function rejectPendingPairingRequest(params) {
27
- const state = await params.loadState();
28
- const pending = state.pendingById[params.requestId];
29
- if (!pending) return null;
30
- delete state.pendingById[params.requestId];
31
- await params.persistState(state);
32
- return {
33
- requestId: params.requestId,
34
- [params.idKey]: params.getId(pending)
35
- };
36
- }
37
- function generatePairingToken() {
38
- return randomBytes(32).toString("base64url");
39
- }
40
- //#endregion
41
- //#region src/agents/skills/refresh.ts
42
- const log$1 = createSubsystemLogger("gateway/skills");
43
- const listeners = /* @__PURE__ */ new Set();
44
- const workspaceVersions = /* @__PURE__ */ new Map();
45
- const watchers = /* @__PURE__ */ new Map();
46
- let globalVersion = 0;
47
- const DEFAULT_SKILLS_WATCH_IGNORED = [
48
- /(^|[\\/])\.git([\\/]|$)/,
49
- /(^|[\\/])node_modules([\\/]|$)/,
50
- /(^|[\\/])dist([\\/]|$)/,
51
- /(^|[\\/])\.venv([\\/]|$)/,
52
- /(^|[\\/])venv([\\/]|$)/,
53
- /(^|[\\/])__pycache__([\\/]|$)/,
54
- /(^|[\\/])\.mypy_cache([\\/]|$)/,
55
- /(^|[\\/])\.pytest_cache([\\/]|$)/,
56
- /(^|[\\/])build([\\/]|$)/,
57
- /(^|[\\/])\.cache([\\/]|$)/
58
- ];
59
- function bumpVersion(current) {
60
- const now = Date.now();
61
- return now <= current ? current + 1 : now;
62
- }
63
- function emit(event) {
64
- for (const listener of listeners) try {
65
- listener(event);
66
- } catch (err) {
67
- log$1.warn(`skills change listener failed: ${String(err)}`);
68
- }
69
- }
70
- function resolveWatchPaths(workspaceDir, config) {
71
- const paths = [];
72
- if (workspaceDir.trim()) {
73
- paths.push(path.join(workspaceDir, "skills"));
74
- paths.push(path.join(workspaceDir, ".agents", "skills"));
75
- }
76
- paths.push(path.join(CONFIG_DIR, "skills"));
77
- paths.push(path.join(os.homedir(), ".agents", "skills"));
78
- const extraDirs = (config?.skills?.load?.extraDirs ?? []).map((d) => typeof d === "string" ? d.trim() : "").filter(Boolean).map((dir) => resolveUserPath(dir));
79
- paths.push(...extraDirs);
80
- const pluginSkillDirs = resolvePluginSkillDirs({
81
- workspaceDir,
82
- config
83
- });
84
- paths.push(...pluginSkillDirs);
85
- return paths;
86
- }
87
- function toWatchGlobRoot(raw) {
88
- return raw.replaceAll("\\", "/").replace(/\/+$/, "");
89
- }
90
- function resolveWatchTargets(workspaceDir, config) {
91
- const targets = /* @__PURE__ */ new Set();
92
- for (const root of resolveWatchPaths(workspaceDir, config)) {
93
- const globRoot = toWatchGlobRoot(root);
94
- targets.add(`${globRoot}/SKILL.md`);
95
- targets.add(`${globRoot}/*/SKILL.md`);
96
- }
97
- return Array.from(targets).toSorted();
98
- }
99
- function bumpSkillsSnapshotVersion(params) {
100
- const reason = params?.reason ?? "manual";
101
- const changedPath = params?.changedPath;
102
- if (params?.workspaceDir) {
103
- const next = bumpVersion(workspaceVersions.get(params.workspaceDir) ?? 0);
104
- workspaceVersions.set(params.workspaceDir, next);
105
- emit({
106
- workspaceDir: params.workspaceDir,
107
- reason,
108
- changedPath
109
- });
110
- return next;
111
- }
112
- globalVersion = bumpVersion(globalVersion);
113
- emit({
114
- reason,
115
- changedPath
116
- });
117
- return globalVersion;
118
- }
119
- function getSkillsSnapshotVersion(workspaceDir) {
120
- if (!workspaceDir) return globalVersion;
121
- const local = workspaceVersions.get(workspaceDir) ?? 0;
122
- return Math.max(globalVersion, local);
123
- }
124
- function ensureSkillsWatcher(params) {
125
- const workspaceDir = params.workspaceDir.trim();
126
- if (!workspaceDir) return;
127
- const watchEnabled = params.config?.skills?.load?.watch !== false;
128
- const debounceMsRaw = params.config?.skills?.load?.watchDebounceMs;
129
- const debounceMs = typeof debounceMsRaw === "number" && Number.isFinite(debounceMsRaw) ? Math.max(0, debounceMsRaw) : 250;
130
- const existing = watchers.get(workspaceDir);
131
- if (!watchEnabled) {
132
- if (existing) {
133
- watchers.delete(workspaceDir);
134
- if (existing.timer) clearTimeout(existing.timer);
135
- existing.watcher.close().catch(() => {});
136
- }
137
- return;
138
- }
139
- const watchTargets = resolveWatchTargets(workspaceDir, params.config);
140
- const pathsKey = watchTargets.join("|");
141
- if (existing && existing.pathsKey === pathsKey && existing.debounceMs === debounceMs) return;
142
- if (existing) {
143
- watchers.delete(workspaceDir);
144
- if (existing.timer) clearTimeout(existing.timer);
145
- existing.watcher.close().catch(() => {});
146
- }
147
- const watcher = chokidar.watch(watchTargets, {
148
- ignoreInitial: true,
149
- awaitWriteFinish: {
150
- stabilityThreshold: debounceMs,
151
- pollInterval: 100
152
- },
153
- ignored: DEFAULT_SKILLS_WATCH_IGNORED
154
- });
155
- const state = {
156
- watcher,
157
- pathsKey,
158
- debounceMs
159
- };
160
- const schedule = (changedPath) => {
161
- state.pendingPath = changedPath ?? state.pendingPath;
162
- if (state.timer) clearTimeout(state.timer);
163
- state.timer = setTimeout(() => {
164
- const pendingPath = state.pendingPath;
165
- state.pendingPath = void 0;
166
- state.timer = void 0;
167
- bumpSkillsSnapshotVersion({
168
- workspaceDir,
169
- reason: "watch",
170
- changedPath: pendingPath
171
- });
172
- }, debounceMs);
173
- };
174
- watcher.on("add", (p) => schedule(p));
175
- watcher.on("change", (p) => schedule(p));
176
- watcher.on("unlink", (p) => schedule(p));
177
- watcher.on("error", (err) => {
178
- log$1.warn(`skills watcher error (${workspaceDir}): ${String(err)}`);
179
- });
180
- watchers.set(workspaceDir, state);
181
- }
182
- createAsyncLock();
183
- createSubsystemLogger("gateway/skills-remote");
184
- const remoteNodes = /* @__PURE__ */ new Map();
185
- function isMacPlatform(platform, deviceFamily) {
186
- const platformNorm = String(platform ?? "").trim().toLowerCase();
187
- const familyNorm = String(deviceFamily ?? "").trim().toLowerCase();
188
- if (platformNorm.includes("mac")) return true;
189
- if (platformNorm.includes("darwin")) return true;
190
- if (familyNorm === "mac") return true;
191
- return false;
192
- }
193
- function supportsSystemRun(commands) {
194
- return Array.isArray(commands) && commands.includes("system.run");
195
- }
196
- function getRemoteSkillEligibility() {
197
- const macNodes = [...remoteNodes.values()].filter((node) => isMacPlatform(node.platform, node.deviceFamily) && supportsSystemRun(node.commands));
198
- if (macNodes.length === 0) return;
199
- const bins = /* @__PURE__ */ new Set();
200
- for (const node of macNodes) for (const bin of node.bins) bins.add(bin);
201
- const labels = macNodes.map((node) => node.displayName ?? node.nodeId).filter(Boolean);
202
- return {
203
- platforms: ["darwin"],
204
- hasBin: (bin) => bins.has(bin),
205
- hasAnyBin: (required) => required.some((bin) => bins.has(bin)),
206
- note: labels.length > 0 ? `Remote macOS node available (${labels.join(", ")}). Run macOS-only skills via nodes.run on that node.` : "Remote macOS node available. Run macOS-only skills via nodes.run on that node."
207
- };
208
- }
209
- //#endregion
210
- //#region src/auto-reply/skill-commands.ts
211
- function listReservedChatSlashCommandNames(extraNames = []) {
212
- const reserved = /* @__PURE__ */ new Set();
213
- for (const command of listChatCommands()) {
214
- if (command.nativeName) reserved.add(command.nativeName.toLowerCase());
215
- for (const alias of command.textAliases) {
216
- const trimmed = alias.trim();
217
- if (!trimmed.startsWith("/")) continue;
218
- reserved.add(trimmed.slice(1).toLowerCase());
219
- }
220
- }
221
- for (const name of extraNames) {
222
- const trimmed = name.trim().toLowerCase();
223
- if (trimmed) reserved.add(trimmed);
224
- }
225
- return reserved;
226
- }
227
- function listSkillCommandsForWorkspace(params) {
228
- return buildWorkspaceSkillCommandSpecs(params.workspaceDir, {
229
- config: params.cfg,
230
- skillFilter: params.skillFilter,
231
- eligibility: { remote: getRemoteSkillEligibility() },
232
- reservedNames: listReservedChatSlashCommandNames()
233
- });
234
- }
235
- function dedupeBySkillName(commands) {
236
- const seen = /* @__PURE__ */ new Set();
237
- const out = [];
238
- for (const cmd of commands) {
239
- const key = cmd.skillName.trim().toLowerCase();
240
- if (key && seen.has(key)) continue;
241
- if (key) seen.add(key);
242
- out.push(cmd);
243
- }
244
- return out;
245
- }
246
- function listSkillCommandsForAgents(params) {
247
- const mergeSkillFilters = (existing, incoming) => {
248
- if (existing === void 0 || incoming === void 0) return;
249
- if (existing.length === 0) return Array.from(new Set(incoming));
250
- if (incoming.length === 0) return Array.from(new Set(existing));
251
- return Array.from(new Set([...existing, ...incoming]));
252
- };
253
- const agentIds = params.agentIds ?? listAgentIds(params.cfg);
254
- const used = listReservedChatSlashCommandNames();
255
- const entries = [];
256
- const workspaceFilters = /* @__PURE__ */ new Map();
257
- for (const agentId of agentIds) {
258
- const workspaceDir = resolveAgentWorkspaceDir(params.cfg, agentId);
259
- if (!fs.existsSync(workspaceDir)) {
260
- logVerbose(`Skipping agent "${agentId}": workspace does not exist: ${workspaceDir}`);
261
- continue;
262
- }
263
- let canonicalDir;
264
- try {
265
- canonicalDir = fs.realpathSync(workspaceDir);
266
- } catch {
267
- logVerbose(`Skipping agent "${agentId}": cannot resolve workspace: ${workspaceDir}`);
268
- continue;
269
- }
270
- const skillFilter = resolveAgentSkillsFilter(params.cfg, agentId);
271
- const existing = workspaceFilters.get(canonicalDir);
272
- if (existing) {
273
- existing.skillFilter = mergeSkillFilters(existing.skillFilter, skillFilter);
274
- continue;
275
- }
276
- workspaceFilters.set(canonicalDir, {
277
- workspaceDir,
278
- skillFilter
279
- });
280
- }
281
- for (const { workspaceDir, skillFilter } of workspaceFilters.values()) {
282
- const commands = buildWorkspaceSkillCommandSpecs(workspaceDir, {
283
- config: params.cfg,
284
- skillFilter,
285
- eligibility: { remote: getRemoteSkillEligibility() },
286
- reservedNames: used
287
- });
288
- for (const command of commands) {
289
- used.add(command.name.toLowerCase());
290
- entries.push(command);
291
- }
292
- }
293
- return dedupeBySkillName(entries);
294
- }
295
- function normalizeSkillCommandLookup(value) {
296
- return value.trim().toLowerCase().replace(/[\s_]+/g, "-");
297
- }
298
- function findSkillCommand(skillCommands, rawName) {
299
- const trimmed = rawName.trim();
300
- if (!trimmed) return;
301
- const lowered = trimmed.toLowerCase();
302
- const normalized = normalizeSkillCommandLookup(trimmed);
303
- return skillCommands.find((entry) => {
304
- if (entry.name.toLowerCase() === lowered) return true;
305
- if (entry.skillName.toLowerCase() === lowered) return true;
306
- return normalizeSkillCommandLookup(entry.name) === normalized || normalizeSkillCommandLookup(entry.skillName) === normalized;
307
- });
308
- }
309
- function resolveSkillCommandInvocation(params) {
310
- const trimmed = params.commandBodyNormalized.trim();
311
- if (!trimmed.startsWith("/")) return null;
312
- const match = trimmed.match(/^\/([^\s]+)(?:\s+([\s\S]+))?$/);
313
- if (!match) return null;
314
- const commandName = match[1]?.trim().toLowerCase();
315
- if (!commandName) return null;
316
- if (commandName === "skill") {
317
- const remainder = match[2]?.trim();
318
- if (!remainder) return null;
319
- const skillMatch = remainder.match(/^([^\s]+)(?:\s+([\s\S]+))?$/);
320
- if (!skillMatch) return null;
321
- const skillCommand = findSkillCommand(params.skillCommands, skillMatch[1] ?? "");
322
- if (!skillCommand) return null;
323
- return {
324
- command: skillCommand,
325
- args: skillMatch[2]?.trim() || void 0
326
- };
327
- }
328
- const command = params.skillCommands.find((entry) => entry.name.toLowerCase() === commandName);
329
- if (!command) return null;
330
- return {
331
- command,
332
- args: match[2]?.trim() || void 0
333
- };
334
- }
335
- //#endregion
336
- export { getRemoteSkillEligibility as a, generatePairingToken as c, resolvePairingPaths as d, resolveSkillCommandInvocation as i, rejectPendingPairingRequest as l, listSkillCommandsForAgents as n, ensureSkillsWatcher as o, listSkillCommandsForWorkspace as r, getSkillsSnapshotVersion as s, listReservedChatSlashCommandNames as t, pruneExpiredPending as u };
@@ -1,8 +0,0 @@
1
- import "./paths-BtVqCdw4.js";
2
- import "./config-B9ODwgpz.js";
3
- import "./paths-eFexkPEh.js";
4
- import "./github-copilot-token-Cxf8QYZb.js";
5
- import "./logger-D6zRubj0.js";
6
- import "./env-b9k1PHMI.js";
7
- import { f as resolveCommandArgMenu, n as findCommandByNativeName, s as listNativeCommandSpecsForConfig, t as buildCommandTextFromArgs, u as parseCommandArgs } from "./commands-registry-6no2NNrY.js";
8
- export { buildCommandTextFromArgs, findCommandByNativeName, listNativeCommandSpecsForConfig, parseCommandArgs, resolveCommandArgMenu };
@@ -1,35 +0,0 @@
1
- import "./paths-BtVqCdw4.js";
2
- import { Mo as resolveConversationLabel } from "./config-B9ODwgpz.js";
3
- import { Et as finalizeInboundContext, X as dispatchReplyWithDispatcher, j as createReplyPrefixOptions, m as deliverSlackSlashReplies, p as recordInboundSessionMetaSafe, wt as resolveAgentRoute } from "./dispatch-BqlR4dPx.js";
4
- import "./paths-eFexkPEh.js";
5
- import "./github-copilot-token-Cxf8QYZb.js";
6
- import "./logger-D6zRubj0.js";
7
- import "./env-b9k1PHMI.js";
8
- import "./send-DP_c8JfR.js";
9
- import "./fetch-BSKpf2dM.js";
10
- import "./channel-activity-DO0FEzyj.js";
11
- import "./fetch-guard-4UVSZ0uS.js";
12
- import "./local-roots-adnEg9zb.js";
13
- import { d as resolveChunkMode, i as resolveMarkdownTableMode } from "./ir-CugsqGH8.js";
14
- import "./render-CKf6NJ1M.js";
15
- import "./tables-D5VgpTmm.js";
16
- import "./send-l-77_s1_.js";
17
- import "./target-errors-C6zZ_OpA.js";
18
- import "./send-CeHhnld6.js";
19
- import "./deliver-B1fFpKjV.js";
20
- import "./diagnostic-CxIvS-C2.js";
21
- import "./pi-model-discovery-Dh4ziodY.js";
22
- import "./audio-transcription-runner-CTIHpebA.js";
23
- import "./image-Ch6M4tnJ.js";
24
- import "./api-key-rotation-CimGYMBc.js";
25
- import "./proxy-fetch-CJEmoBxi.js";
26
- import "./tokens-DUnJnpMS.js";
27
- import "./commands-registry-6no2NNrY.js";
28
- import "./skill-commands-BohYCgkq.js";
29
- import "./send-CScblaI4.js";
30
- import "./outbound-attachment-khXJwucX.js";
31
- import "./send-Dc5fI6e8.js";
32
- import "./sqlite-CJE3X7Mv.js";
33
- import "./fetch-PoxzAANT.js";
34
- import "./manager-CHy8IclH.js";
35
- export { createReplyPrefixOptions, deliverSlackSlashReplies, dispatchReplyWithDispatcher, finalizeInboundContext, recordInboundSessionMetaSafe, resolveAgentRoute, resolveChunkMode, resolveConversationLabel, resolveMarkdownTableMode };
@@ -1,9 +0,0 @@
1
- import "./paths-BtVqCdw4.js";
2
- import "./config-B9ODwgpz.js";
3
- import "./paths-eFexkPEh.js";
4
- import "./github-copilot-token-Cxf8QYZb.js";
5
- import "./logger-D6zRubj0.js";
6
- import "./env-b9k1PHMI.js";
7
- import "./commands-registry-6no2NNrY.js";
8
- import { n as listSkillCommandsForAgents } from "./skill-commands-BohYCgkq.js";
9
- export { listSkillCommandsForAgents };