@congzhen/changewayguard 6.8.12
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.
- package/LICENSE +21 -0
- package/README.md +270 -0
- package/dashboard-dist/api/104.index.js +1420 -0
- package/dashboard-dist/api/104.index.js.map +1 -0
- package/dashboard-dist/api/113.index.js +496 -0
- package/dashboard-dist/api/113.index.js.map +1 -0
- package/dashboard-dist/api/18.index.js +67 -0
- package/dashboard-dist/api/18.index.js.map +1 -0
- package/dashboard-dist/api/217.index.js +44 -0
- package/dashboard-dist/api/217.index.js.map +1 -0
- package/dashboard-dist/api/222.index.js +90 -0
- package/dashboard-dist/api/222.index.js.map +1 -0
- package/dashboard-dist/api/25.index.js +3562 -0
- package/dashboard-dist/api/25.index.js.map +1 -0
- package/dashboard-dist/api/280.index.js +206 -0
- package/dashboard-dist/api/280.index.js.map +1 -0
- package/dashboard-dist/api/369.index.js +115 -0
- package/dashboard-dist/api/369.index.js.map +1 -0
- package/dashboard-dist/api/377.index.js +1176 -0
- package/dashboard-dist/api/377.index.js.map +1 -0
- package/dashboard-dist/api/411.index.js +4250 -0
- package/dashboard-dist/api/411.index.js.map +1 -0
- package/dashboard-dist/api/424.index.js +135 -0
- package/dashboard-dist/api/424.index.js.map +1 -0
- package/dashboard-dist/api/573.index.js +806 -0
- package/dashboard-dist/api/573.index.js.map +1 -0
- package/dashboard-dist/api/598.index.js +328 -0
- package/dashboard-dist/api/598.index.js.map +1 -0
- package/dashboard-dist/api/62.index.js +4151 -0
- package/dashboard-dist/api/62.index.js.map +1 -0
- package/dashboard-dist/api/67.index.js +23383 -0
- package/dashboard-dist/api/67.index.js.map +1 -0
- package/dashboard-dist/api/678.index.js +2734 -0
- package/dashboard-dist/api/678.index.js.map +1 -0
- package/dashboard-dist/api/698.index.js +1896 -0
- package/dashboard-dist/api/698.index.js.map +1 -0
- package/dashboard-dist/api/720.index.js +98 -0
- package/dashboard-dist/api/720.index.js.map +1 -0
- package/dashboard-dist/api/830.index.js +95 -0
- package/dashboard-dist/api/830.index.js.map +1 -0
- package/dashboard-dist/api/831.index.js +99 -0
- package/dashboard-dist/api/831.index.js.map +1 -0
- package/dashboard-dist/api/84.index.js +64 -0
- package/dashboard-dist/api/84.index.js.map +1 -0
- package/dashboard-dist/api/900.index.js +65 -0
- package/dashboard-dist/api/900.index.js.map +1 -0
- package/dashboard-dist/api/917.index.js +88 -0
- package/dashboard-dist/api/917.index.js.map +1 -0
- package/dashboard-dist/api/948.index.js +64 -0
- package/dashboard-dist/api/948.index.js.map +1 -0
- package/dashboard-dist/api/953.index.js +67 -0
- package/dashboard-dist/api/953.index.js.map +1 -0
- package/dashboard-dist/api/975.index.js +374 -0
- package/dashboard-dist/api/975.index.js.map +1 -0
- package/dashboard-dist/api/drizzle/sqlite/0000_short_captain_stacy.sql +70 -0
- package/dashboard-dist/api/drizzle/sqlite/0001_closed_magus.sql +10 -0
- package/dashboard-dist/api/drizzle/sqlite/0002_agent_capability_observation.sql +38 -0
- package/dashboard-dist/api/drizzle/sqlite/0003_auth_magic_link.sql +28 -0
- package/dashboard-dist/api/drizzle/sqlite/0004_static_scan_fields.sql +8 -0
- package/dashboard-dist/api/drizzle/sqlite/0005_gateway_activity.sql +24 -0
- package/dashboard-dist/api/drizzle/sqlite/0006_sour_marauders.sql +41 -0
- package/dashboard-dist/api/drizzle/sqlite/meta/0000_snapshot.json +460 -0
- package/dashboard-dist/api/drizzle/sqlite/meta/0001_snapshot.json +536 -0
- package/dashboard-dist/api/drizzle/sqlite/meta/0006_snapshot.json +1249 -0
- package/dashboard-dist/api/drizzle/sqlite/meta/_journal.json +55 -0
- package/dashboard-dist/api/index.js +27340 -0
- package/dashboard-dist/api/index.js.map +1 -0
- package/dashboard-dist/api/package.json +16 -0
- package/dashboard-dist/api/sourcemap-register.cjs +1 -0
- package/dashboard-dist/web/assets/index-CqWIeBTD.js +158 -0
- package/dashboard-dist/web/assets/index-Dw7--9q4.css +1 -0
- package/dashboard-dist/web/changeway-logo.png +0 -0
- package/dashboard-dist/web/favicon.svg +29 -0
- package/dashboard-dist/web/index.html +14 -0
- package/dashboard-dist/web/logo.svg +16 -0
- package/dist/agent/auth.d.ts +37 -0
- package/dist/agent/auth.d.ts.map +1 -0
- package/dist/agent/auth.js +151 -0
- package/dist/agent/auth.js.map +1 -0
- package/dist/agent/behavior-detector.d.ts +150 -0
- package/dist/agent/behavior-detector.d.ts.map +1 -0
- package/dist/agent/behavior-detector.js +573 -0
- package/dist/agent/behavior-detector.js.map +1 -0
- package/dist/agent/business-reporter.d.ts +114 -0
- package/dist/agent/business-reporter.d.ts.map +1 -0
- package/dist/agent/business-reporter.js +359 -0
- package/dist/agent/business-reporter.js.map +1 -0
- package/dist/agent/config-sync.d.ts +70 -0
- package/dist/agent/config-sync.d.ts.map +1 -0
- package/dist/agent/config-sync.js +133 -0
- package/dist/agent/config-sync.js.map +1 -0
- package/dist/agent/config.d.ts +97 -0
- package/dist/agent/config.d.ts.map +1 -0
- package/dist/agent/config.js +359 -0
- package/dist/agent/config.js.map +1 -0
- package/dist/agent/content-injection-scanner.d.ts +35 -0
- package/dist/agent/content-injection-scanner.d.ts.map +1 -0
- package/dist/agent/content-injection-scanner.js +270 -0
- package/dist/agent/content-injection-scanner.js.map +1 -0
- package/dist/agent/engine-log-writer.d.ts +6 -0
- package/dist/agent/engine-log-writer.d.ts.map +1 -0
- package/dist/agent/engine-log-writer.js +18 -0
- package/dist/agent/engine-log-writer.js.map +1 -0
- package/dist/agent/env.d.ts +19 -0
- package/dist/agent/env.d.ts.map +1 -0
- package/dist/agent/env.js +43 -0
- package/dist/agent/env.js.map +1 -0
- package/dist/agent/event-reporter.d.ts +87 -0
- package/dist/agent/event-reporter.d.ts.map +1 -0
- package/dist/agent/event-reporter.js +315 -0
- package/dist/agent/event-reporter.js.map +1 -0
- package/dist/agent/file-watcher.d.ts +50 -0
- package/dist/agent/file-watcher.d.ts.map +1 -0
- package/dist/agent/file-watcher.js +135 -0
- package/dist/agent/file-watcher.js.map +1 -0
- package/dist/agent/fs-utils.d.ts +22 -0
- package/dist/agent/fs-utils.d.ts.map +1 -0
- package/dist/agent/fs-utils.js +41 -0
- package/dist/agent/fs-utils.js.map +1 -0
- package/dist/agent/gateway-manager.d.ts +59 -0
- package/dist/agent/gateway-manager.d.ts.map +1 -0
- package/dist/agent/gateway-manager.js +583 -0
- package/dist/agent/gateway-manager.js.map +1 -0
- package/dist/agent/hook-types.d.ts +276 -0
- package/dist/agent/hook-types.d.ts.map +1 -0
- package/dist/agent/hook-types.js +51 -0
- package/dist/agent/hook-types.js.map +1 -0
- package/dist/agent/index.d.ts +8 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +8 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/prompt-gate.d.ts +13 -0
- package/dist/agent/prompt-gate.d.ts.map +1 -0
- package/dist/agent/prompt-gate.js +28 -0
- package/dist/agent/prompt-gate.js.map +1 -0
- package/dist/agent/prompt-input.d.ts +9 -0
- package/dist/agent/prompt-input.d.ts.map +1 -0
- package/dist/agent/prompt-input.js +158 -0
- package/dist/agent/prompt-input.js.map +1 -0
- package/dist/agent/prompt-output.d.ts +4 -0
- package/dist/agent/prompt-output.d.ts.map +1 -0
- package/dist/agent/prompt-output.js +19 -0
- package/dist/agent/prompt-output.js.map +1 -0
- package/dist/agent/runner.d.ts +23 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +154 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/sanitizer.d.ts +10 -0
- package/dist/agent/sanitizer.d.ts.map +1 -0
- package/dist/agent/sanitizer.js +175 -0
- package/dist/agent/sanitizer.js.map +1 -0
- package/dist/agent/scan-activity.d.ts +18 -0
- package/dist/agent/scan-activity.d.ts.map +1 -0
- package/dist/agent/scan-activity.js +32 -0
- package/dist/agent/scan-activity.js.map +1 -0
- package/dist/agent/types.d.ts +177 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +5 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/agent/workspace-scanner.d.ts +35 -0
- package/dist/agent/workspace-scanner.d.ts.map +1 -0
- package/dist/agent/workspace-scanner.js +137 -0
- package/dist/agent/workspace-scanner.js.map +1 -0
- package/dist/dashboard-launcher.d.ts +52 -0
- package/dist/dashboard-launcher.d.ts.map +1 -0
- package/dist/dashboard-launcher.js +363 -0
- package/dist/dashboard-launcher.js.map +1 -0
- package/dist/gateway/activity.d.ts +52 -0
- package/dist/gateway/activity.d.ts.map +1 -0
- package/dist/gateway/activity.js +111 -0
- package/dist/gateway/activity.js.map +1 -0
- package/dist/gateway/config.d.ts +50 -0
- package/dist/gateway/config.d.ts.map +1 -0
- package/dist/gateway/config.js +200 -0
- package/dist/gateway/config.js.map +1 -0
- package/dist/gateway/gateway/activity.d.ts +52 -0
- package/dist/gateway/gateway/activity.d.ts.map +1 -0
- package/dist/gateway/gateway/activity.js +111 -0
- package/dist/gateway/gateway/activity.js.map +1 -0
- package/dist/gateway/gateway/config.d.ts +50 -0
- package/dist/gateway/gateway/config.d.ts.map +1 -0
- package/dist/gateway/gateway/config.js +200 -0
- package/dist/gateway/gateway/config.js.map +1 -0
- package/dist/gateway/gateway/handlers/anthropic.d.ts +12 -0
- package/dist/gateway/gateway/handlers/anthropic.d.ts.map +1 -0
- package/dist/gateway/gateway/handlers/anthropic.js +254 -0
- package/dist/gateway/gateway/handlers/anthropic.js.map +1 -0
- package/dist/gateway/gateway/handlers/gemini.d.ts +12 -0
- package/dist/gateway/gateway/handlers/gemini.d.ts.map +1 -0
- package/dist/gateway/gateway/handlers/gemini.js +101 -0
- package/dist/gateway/gateway/handlers/gemini.js.map +1 -0
- package/dist/gateway/gateway/handlers/models.d.ts +4 -0
- package/dist/gateway/gateway/handlers/models.d.ts.map +1 -0
- package/dist/gateway/gateway/handlers/models.js +36 -0
- package/dist/gateway/gateway/handlers/models.js.map +1 -0
- package/dist/gateway/gateway/handlers/openai.d.ts +16 -0
- package/dist/gateway/gateway/handlers/openai.d.ts.map +1 -0
- package/dist/gateway/gateway/handlers/openai.js +254 -0
- package/dist/gateway/gateway/handlers/openai.js.map +1 -0
- package/dist/gateway/gateway/index.d.ts +27 -0
- package/dist/gateway/gateway/index.d.ts.map +1 -0
- package/dist/gateway/gateway/index.js +293 -0
- package/dist/gateway/gateway/index.js.map +1 -0
- package/dist/gateway/gateway/mapping-store.d.ts +38 -0
- package/dist/gateway/gateway/mapping-store.d.ts.map +1 -0
- package/dist/gateway/gateway/mapping-store.js +74 -0
- package/dist/gateway/gateway/mapping-store.js.map +1 -0
- package/dist/gateway/gateway/restorer.d.ts +63 -0
- package/dist/gateway/gateway/restorer.d.ts.map +1 -0
- package/dist/gateway/gateway/restorer.js +284 -0
- package/dist/gateway/gateway/restorer.js.map +1 -0
- package/dist/gateway/gateway/sanitizer.d.ts +17 -0
- package/dist/gateway/gateway/sanitizer.d.ts.map +1 -0
- package/dist/gateway/gateway/sanitizer.js +228 -0
- package/dist/gateway/gateway/sanitizer.js.map +1 -0
- package/dist/gateway/gateway/types.d.ts +53 -0
- package/dist/gateway/gateway/types.d.ts.map +1 -0
- package/dist/gateway/gateway/types.js +5 -0
- package/dist/gateway/gateway/types.js.map +1 -0
- package/dist/gateway/handlers/anthropic.d.ts +12 -0
- package/dist/gateway/handlers/anthropic.d.ts.map +1 -0
- package/dist/gateway/handlers/anthropic.js +254 -0
- package/dist/gateway/handlers/anthropic.js.map +1 -0
- package/dist/gateway/handlers/gemini.d.ts +12 -0
- package/dist/gateway/handlers/gemini.d.ts.map +1 -0
- package/dist/gateway/handlers/gemini.js +101 -0
- package/dist/gateway/handlers/gemini.js.map +1 -0
- package/dist/gateway/handlers/models.d.ts +4 -0
- package/dist/gateway/handlers/models.d.ts.map +1 -0
- package/dist/gateway/handlers/models.js +36 -0
- package/dist/gateway/handlers/models.js.map +1 -0
- package/dist/gateway/handlers/openai.d.ts +16 -0
- package/dist/gateway/handlers/openai.d.ts.map +1 -0
- package/dist/gateway/handlers/openai.js +254 -0
- package/dist/gateway/handlers/openai.js.map +1 -0
- package/dist/gateway/index.d.ts +27 -0
- package/dist/gateway/index.d.ts.map +1 -0
- package/dist/gateway/index.js +293 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/mapping-store.d.ts +38 -0
- package/dist/gateway/mapping-store.d.ts.map +1 -0
- package/dist/gateway/mapping-store.js +74 -0
- package/dist/gateway/mapping-store.js.map +1 -0
- package/dist/gateway/restorer.d.ts +63 -0
- package/dist/gateway/restorer.d.ts.map +1 -0
- package/dist/gateway/restorer.js +284 -0
- package/dist/gateway/restorer.js.map +1 -0
- package/dist/gateway/sanitizer.d.ts +17 -0
- package/dist/gateway/sanitizer.d.ts.map +1 -0
- package/dist/gateway/sanitizer.js +228 -0
- package/dist/gateway/sanitizer.js.map +1 -0
- package/dist/gateway/types.d.ts +53 -0
- package/dist/gateway/types.d.ts.map +1 -0
- package/dist/gateway/types.js +5 -0
- package/dist/gateway/types.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2084 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +5 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/store.d.ts +82 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +194 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/platform-client/index.d.ts +63 -0
- package/dist/platform-client/index.d.ts.map +1 -0
- package/dist/platform-client/index.js +294 -0
- package/dist/platform-client/index.js.map +1 -0
- package/dist/platform-client/types.d.ts +109 -0
- package/dist/platform-client/types.d.ts.map +1 -0
- package/dist/platform-client/types.js +3 -0
- package/dist/platform-client/types.js.map +1 -0
- package/gateway/activity.d.ts +52 -0
- package/gateway/activity.d.ts.map +1 -0
- package/gateway/activity.js +111 -0
- package/gateway/activity.js.map +1 -0
- package/gateway/config.d.ts +50 -0
- package/gateway/config.d.ts.map +1 -0
- package/gateway/config.js +200 -0
- package/gateway/config.js.map +1 -0
- package/gateway/handlers/anthropic.d.ts +12 -0
- package/gateway/handlers/anthropic.d.ts.map +1 -0
- package/gateway/handlers/anthropic.js +254 -0
- package/gateway/handlers/anthropic.js.map +1 -0
- package/gateway/handlers/gemini.d.ts +12 -0
- package/gateway/handlers/gemini.d.ts.map +1 -0
- package/gateway/handlers/gemini.js +101 -0
- package/gateway/handlers/gemini.js.map +1 -0
- package/gateway/handlers/models.d.ts +4 -0
- package/gateway/handlers/models.d.ts.map +1 -0
- package/gateway/handlers/models.js +36 -0
- package/gateway/handlers/models.js.map +1 -0
- package/gateway/handlers/openai.d.ts +16 -0
- package/gateway/handlers/openai.d.ts.map +1 -0
- package/gateway/handlers/openai.js +254 -0
- package/gateway/handlers/openai.js.map +1 -0
- package/gateway/index.d.ts +27 -0
- package/gateway/index.d.ts.map +1 -0
- package/gateway/index.js +293 -0
- package/gateway/index.js.map +1 -0
- package/gateway/mapping-store.d.ts +38 -0
- package/gateway/mapping-store.d.ts.map +1 -0
- package/gateway/mapping-store.js +74 -0
- package/gateway/mapping-store.js.map +1 -0
- package/gateway/restorer.d.ts +63 -0
- package/gateway/restorer.d.ts.map +1 -0
- package/gateway/restorer.js +284 -0
- package/gateway/restorer.js.map +1 -0
- package/gateway/sanitizer.d.ts +17 -0
- package/gateway/sanitizer.d.ts.map +1 -0
- package/gateway/sanitizer.js +228 -0
- package/gateway/sanitizer.js.map +1 -0
- package/gateway/types.d.ts +53 -0
- package/gateway/types.d.ts.map +1 -0
- package/gateway/types.js +5 -0
- package/gateway/types.js.map +1 -0
- package/openclaw.plugin.json +86 -0
- package/package.json +74 -0
- package/samples/Untitled +1 -0
- package/samples/clean-email.txt +20 -0
- package/samples/test-document.md +53 -0
- package/samples/test-email-popup.txt +44 -0
- package/samples/test-email.txt +32 -0
- package/samples/test-webpage.html +51 -0
- package/scripts/enterprise-enroll.sh +89 -0
- package/scripts/enterprise-unenroll.sh +75 -0
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
export const id = 573;
|
|
2
|
+
export const ids = [573];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 6573:
|
|
6
|
+
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
9
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
10
|
+
/* harmony export */ discoveryRouter: () => (/* binding */ discoveryRouter)
|
|
11
|
+
/* harmony export */ });
|
|
12
|
+
/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(316);
|
|
13
|
+
/* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3024);
|
|
14
|
+
/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6760);
|
|
15
|
+
/* harmony import */ var _services_discovery_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9135);
|
|
16
|
+
/* harmony import */ var _og_db__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6020);
|
|
17
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_og_db__WEBPACK_IMPORTED_MODULE_4__]);
|
|
18
|
+
_og_db__WEBPACK_IMPORTED_MODULE_4__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const agentsDb = (0,_og_db__WEBPACK_IMPORTED_MODULE_4__/* .agentQueries */ .Ik)(_og_db__WEBPACK_IMPORTED_MODULE_4__.db);
|
|
25
|
+
const discoveryRouter = (0,express__WEBPACK_IMPORTED_MODULE_0__.Router)();
|
|
26
|
+
function fallbackAgentName(agentId) {
|
|
27
|
+
return agentId ? `Agent ${agentId.slice(0, 6)}` : "Agent";
|
|
28
|
+
}
|
|
29
|
+
function sanitizeAgentName(name, fallback) {
|
|
30
|
+
const raw = name.replace(/\s+/g, " ").trim();
|
|
31
|
+
if (!raw)
|
|
32
|
+
return fallback;
|
|
33
|
+
const cleaned = raw
|
|
34
|
+
.replace(/^[-*]\s+/, "")
|
|
35
|
+
.replace(/^[`*_~\s]+/, "")
|
|
36
|
+
.replace(/[`*_~\s]+$/, "")
|
|
37
|
+
.replace(/^\((.*)\)$/, "$1")
|
|
38
|
+
.trim();
|
|
39
|
+
if (!cleaned)
|
|
40
|
+
return fallback;
|
|
41
|
+
const lower = cleaned.toLowerCase();
|
|
42
|
+
const looksLikeTemplate = /(pick something|your signature|fill this in|make it yours|workspace-relative|something weirder|ghost in the machine|how do you come across)/i.test(lower);
|
|
43
|
+
return looksLikeTemplate ? fallback : cleaned;
|
|
44
|
+
}
|
|
45
|
+
function registeredToDiscovered(a) {
|
|
46
|
+
const m = (a.metadata ?? {});
|
|
47
|
+
const discoveredId = m.openclawId ?? a.id;
|
|
48
|
+
return {
|
|
49
|
+
id: discoveredId,
|
|
50
|
+
name: sanitizeAgentName(a.name, fallbackAgentName(discoveredId)),
|
|
51
|
+
emoji: m.emoji ?? "🤖",
|
|
52
|
+
creature: m.creature ?? "",
|
|
53
|
+
vibe: m.vibe ?? "",
|
|
54
|
+
model: m.model ?? "",
|
|
55
|
+
provider: m.provider ?? a.provider,
|
|
56
|
+
workspacePath: "",
|
|
57
|
+
ownerName: m.ownerName ?? "",
|
|
58
|
+
avatarUrl: null,
|
|
59
|
+
skills: m.skills ?? [],
|
|
60
|
+
connectedSystems: m.connectedSystems ?? [],
|
|
61
|
+
channels: m.channels ?? [],
|
|
62
|
+
plugins: m.plugins ?? [],
|
|
63
|
+
hooks: m.hooks ?? [],
|
|
64
|
+
sessionCount: m.sessionCount ?? 0,
|
|
65
|
+
lastActive: m.lastActive ?? a.lastSeenAt,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function registeredToProfile(a) {
|
|
69
|
+
const m = (a.metadata ?? {});
|
|
70
|
+
const wf = m.workspaceFiles ?? {};
|
|
71
|
+
return {
|
|
72
|
+
...registeredToDiscovered(a),
|
|
73
|
+
workspaceFiles: {
|
|
74
|
+
soul: wf.soul ?? "",
|
|
75
|
+
identity: wf.identity ?? "",
|
|
76
|
+
user: wf.user ?? "",
|
|
77
|
+
agents: wf.agents ?? "",
|
|
78
|
+
tools: wf.tools ?? "",
|
|
79
|
+
heartbeat: wf.heartbeat ?? "",
|
|
80
|
+
},
|
|
81
|
+
bootstrapExists: m.bootstrapExists ?? false,
|
|
82
|
+
cronJobs: m.cronJobs ?? [],
|
|
83
|
+
allSkills: (m.skills ?? []).map((s) => ({ ...s, source: "workspace" })),
|
|
84
|
+
bundledExtensions: [],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// ── Routes ───────────────────────────────────────────────────────────────────
|
|
88
|
+
// GET /api/discovery/agents — list all agents (DB primary, filesystem fallback)
|
|
89
|
+
discoveryRouter.get("/agents", async (_req, res, next) => {
|
|
90
|
+
try {
|
|
91
|
+
const tenantId = res.locals.tenantId;
|
|
92
|
+
const registered = await agentsDb.findAll(tenantId);
|
|
93
|
+
if (registered.length > 0) {
|
|
94
|
+
res.json({ success: true, data: registered.map(registeredToDiscovered) });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Fallback: local filesystem scan (self-hosted, same machine)
|
|
98
|
+
const discovered = (0,_services_discovery_js__WEBPACK_IMPORTED_MODULE_3__/* .scanAgents */ .u)();
|
|
99
|
+
res.json({ success: true, data: discovered });
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
next(err);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
// GET /api/discovery/agents/:id — single agent (DB primary, filesystem fallback)
|
|
106
|
+
discoveryRouter.get("/agents/:id", async (req, res, next) => {
|
|
107
|
+
try {
|
|
108
|
+
const tenantId = res.locals.tenantId;
|
|
109
|
+
const id = req.params.id;
|
|
110
|
+
const registered = await agentsDb.findAll(tenantId);
|
|
111
|
+
// Match by openclawId (from plugin) or DB id
|
|
112
|
+
const match = registered.find((a) => {
|
|
113
|
+
const meta = (a.metadata ?? {});
|
|
114
|
+
return meta.openclawId === id || a.id === id;
|
|
115
|
+
});
|
|
116
|
+
if (match) {
|
|
117
|
+
res.json({ success: true, data: registeredToDiscovered(match) });
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Fallback: filesystem
|
|
121
|
+
const { getAgent } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 9135));
|
|
122
|
+
const agent = getAgent(id);
|
|
123
|
+
if (!agent) {
|
|
124
|
+
res.status(404).json({ success: false, error: "Agent not found" });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
res.json({ success: true, data: agent });
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
next(err);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
// GET /api/discovery/agents/:id/avatar — serve agent avatar image (filesystem only)
|
|
134
|
+
discoveryRouter.get("/agents/:id/avatar", (req, res, next) => {
|
|
135
|
+
try {
|
|
136
|
+
const { getAgent } = require("../services/discovery.js");
|
|
137
|
+
const agent = getAgent(req.params.id);
|
|
138
|
+
if (!agent || !agent.workspacePath) {
|
|
139
|
+
res.status(404).json({ success: false, error: "No avatar found" });
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const mimeTypes = {
|
|
143
|
+
png: "image/png",
|
|
144
|
+
jpg: "image/jpeg",
|
|
145
|
+
jpeg: "image/jpeg",
|
|
146
|
+
svg: "image/svg+xml",
|
|
147
|
+
webp: "image/webp",
|
|
148
|
+
};
|
|
149
|
+
for (const ext of Object.keys(mimeTypes)) {
|
|
150
|
+
const avatarPath = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(agent.workspacePath, `avatar.${ext}`);
|
|
151
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_1__.existsSync)(avatarPath)) {
|
|
152
|
+
const data = (0,node_fs__WEBPACK_IMPORTED_MODULE_1__["read"+"FileSync"])(avatarPath);
|
|
153
|
+
res.setHeader("Content-Type", mimeTypes[ext]);
|
|
154
|
+
res.setHeader("Cache-Control", "public, max-age=3600");
|
|
155
|
+
res.send(data);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
res.status(404).json({ success: false, error: "No avatar found" });
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
next(err);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
// GET /api/discovery/agents/:id/profile — enriched profile (DB primary, filesystem fallback)
|
|
166
|
+
discoveryRouter.get("/agents/:id/profile", async (req, res, next) => {
|
|
167
|
+
try {
|
|
168
|
+
const tenantId = res.locals.tenantId;
|
|
169
|
+
const id = req.params.id;
|
|
170
|
+
const registered = await agentsDb.findAll(tenantId);
|
|
171
|
+
const match = registered.find((a) => {
|
|
172
|
+
const meta = (a.metadata ?? {});
|
|
173
|
+
return meta.openclawId === id || a.id === id;
|
|
174
|
+
});
|
|
175
|
+
if (match) {
|
|
176
|
+
const profile = registeredToProfile(match);
|
|
177
|
+
res.json({ success: true, data: { ...profile, registeredAgentId: match.id } });
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
// Fallback: filesystem
|
|
181
|
+
const profile = (0,_services_discovery_js__WEBPACK_IMPORTED_MODULE_3__/* .getAgentProfile */ .r)(id);
|
|
182
|
+
if (!profile) {
|
|
183
|
+
res.status(404).json({ success: false, error: "Agent not found" });
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// Also try to find registeredAgentId from DB by name
|
|
187
|
+
const byName = registered.find((a) => a.name === profile.name);
|
|
188
|
+
res.json({ success: true, data: { ...profile, registeredAgentId: byName?.id ?? null } });
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
next(err);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
// POST /api/discovery/scan — trigger fresh scan (filesystem only, for local installs)
|
|
195
|
+
discoveryRouter.post("/scan", (_req, res, next) => {
|
|
196
|
+
try {
|
|
197
|
+
const agents = (0,_services_discovery_js__WEBPACK_IMPORTED_MODULE_3__/* .scanAgents */ .u)();
|
|
198
|
+
res.json({ success: true, data: agents });
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
next(err);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
// GET /api/discovery/agents/:id/summary — LLM-generated summary
|
|
205
|
+
discoveryRouter.get("/agents/:id/summary", async (req, res, next) => {
|
|
206
|
+
try {
|
|
207
|
+
const tenantId = res.locals.tenantId;
|
|
208
|
+
const id = req.params.id;
|
|
209
|
+
const registered = await agentsDb.findAll(tenantId);
|
|
210
|
+
const match = registered.find((a) => {
|
|
211
|
+
const meta = (a.metadata ?? {});
|
|
212
|
+
return meta.openclawId === id || a.id === id;
|
|
213
|
+
});
|
|
214
|
+
const agent = match
|
|
215
|
+
? registeredToDiscovered(match)
|
|
216
|
+
: (() => { const { getAgent } = require("../services/discovery.js"); return getAgent(id) ?? null; })();
|
|
217
|
+
if (!agent) {
|
|
218
|
+
res.status(404).json({ success: false, error: "Agent not found" });
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const prompt = `Summarize this AI agent in 2-3 concise paragraphs for a security dashboard:
|
|
222
|
+
|
|
223
|
+
Name: ${agent.name} ${agent.emoji}
|
|
224
|
+
Creature: ${agent.creature}
|
|
225
|
+
Vibe: ${agent.vibe}
|
|
226
|
+
Model: ${agent.provider}/${agent.model}
|
|
227
|
+
Skills: ${agent.skills.map((s) => s.name).join(", ") || "none"}
|
|
228
|
+
Connected Systems: ${agent.connectedSystems.join(", ") || "none"}
|
|
229
|
+
Channels: ${agent.channels.join(", ") || "none"}
|
|
230
|
+
Plugins: ${agent.plugins.map((p) => `${p.name}${p.enabled ? "" : " (disabled)"}`).join(", ") || "none"}
|
|
231
|
+
Hooks: ${agent.hooks.map((h) => `${h.name}${h.enabled ? "" : " (disabled)"}`).join(", ") || "none"}
|
|
232
|
+
Sessions: ${agent.sessionCount}
|
|
233
|
+
Last Active: ${agent.lastActive || "unknown"}
|
|
234
|
+
|
|
235
|
+
Focus on: what this agent does, its capabilities, connected systems and potential security surface area. Keep it factual and useful for a security team.`;
|
|
236
|
+
const { getEnvGatewayPort, getEnvAnthropicApiKey } = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 824));
|
|
237
|
+
const gatewayPort = getEnvGatewayPort();
|
|
238
|
+
try {
|
|
239
|
+
const apiKey = getEnvAnthropicApiKey();
|
|
240
|
+
const response = await fetch(`http://localhost:${gatewayPort}/v1/messages`, {
|
|
241
|
+
method: "POST",
|
|
242
|
+
headers: {
|
|
243
|
+
"Content-Type": "application/json",
|
|
244
|
+
"x-api-key": apiKey,
|
|
245
|
+
"anthropic-version": "2023-06-01",
|
|
246
|
+
},
|
|
247
|
+
body: JSON.stringify({
|
|
248
|
+
model: "claude-sonnet-4-5-20250929",
|
|
249
|
+
max_tokens: 500,
|
|
250
|
+
messages: [{ role: "user", content: prompt }],
|
|
251
|
+
}),
|
|
252
|
+
signal: AbortSignal.timeout(30000),
|
|
253
|
+
});
|
|
254
|
+
if (response.ok) {
|
|
255
|
+
const data = await response.json();
|
|
256
|
+
const text = data.content?.find((c) => c.type === "text")?.text;
|
|
257
|
+
if (text) {
|
|
258
|
+
res.json({ success: true, data: { summary: text } });
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
// Gateway not available, fall through to static summary
|
|
265
|
+
}
|
|
266
|
+
const skillList = agent.skills.map((s) => s.name).join(", ");
|
|
267
|
+
const systemList = agent.connectedSystems.join(", ");
|
|
268
|
+
const summary = `${agent.name} is an AI agent running on ${agent.provider}/${agent.model}. ` +
|
|
269
|
+
(skillList ? `It has ${agent.skills.length} skill(s): ${skillList}. ` : "It has no registered skills. ") +
|
|
270
|
+
(systemList ? `Connected systems: ${systemList}. ` : "") +
|
|
271
|
+
`It has ${agent.sessionCount} recorded session(s)` +
|
|
272
|
+
(agent.lastActive ? `, last active ${new Date(agent.lastActive).toLocaleDateString()}.` : ".");
|
|
273
|
+
res.json({ success: true, data: { summary } });
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
next(err);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
//# sourceMappingURL=discovery.js.map
|
|
280
|
+
__webpack_async_result__();
|
|
281
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
282
|
+
|
|
283
|
+
/***/ }),
|
|
284
|
+
|
|
285
|
+
/***/ 9135:
|
|
286
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
287
|
+
|
|
288
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
289
|
+
/* harmony export */ getAgent: () => (/* binding */ getAgent),
|
|
290
|
+
/* harmony export */ r: () => (/* binding */ getAgentProfile),
|
|
291
|
+
/* harmony export */ u: () => (/* binding */ scanAgents)
|
|
292
|
+
/* harmony export */ });
|
|
293
|
+
/* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3024);
|
|
294
|
+
/* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1421);
|
|
295
|
+
/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6760);
|
|
296
|
+
/* harmony import */ var node_os__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8161);
|
|
297
|
+
/* harmony import */ var _runtime_config_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(824);
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
const OPENCLAW_DIR = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)((0,node_os__WEBPACK_IMPORTED_MODULE_3__.homedir)(), ".openclaw");
|
|
304
|
+
function readJsonSafe(path) {
|
|
305
|
+
try {
|
|
306
|
+
return JSON.parse((0,node_fs__WEBPACK_IMPORTED_MODULE_0__["read"+"FileSync"])(path, "utf-8"));
|
|
307
|
+
}
|
|
308
|
+
catch {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function readFileSafe(path) {
|
|
313
|
+
try {
|
|
314
|
+
return (0,node_fs__WEBPACK_IMPORTED_MODULE_0__["read"+"FileSync"])(path, "utf-8");
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return "";
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function parseOwnerName(workspacePath) {
|
|
321
|
+
const content = readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(workspacePath, "USER.md"));
|
|
322
|
+
if (!content)
|
|
323
|
+
return "";
|
|
324
|
+
for (const line of content.split("\n")) {
|
|
325
|
+
const trimmed = line.trim();
|
|
326
|
+
// Handle "- **Name:** value" (bullet + bold markdown)
|
|
327
|
+
const bulletBold = trimmed.match(/^[-*]\s+\*\*name:\*\*\s*(.*)/i);
|
|
328
|
+
if (bulletBold) {
|
|
329
|
+
const val = bulletBold[1].trim();
|
|
330
|
+
if (val)
|
|
331
|
+
return val;
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
// Handle "**Name:** value" or "Name: value"
|
|
335
|
+
const plain = trimmed.match(/^\*?\*?name\*?\*?:\s*(.*)/i);
|
|
336
|
+
if (plain) {
|
|
337
|
+
const val = plain[1].replace(/^\*?\*?\s*/, "").trim();
|
|
338
|
+
if (val)
|
|
339
|
+
return val;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return "";
|
|
343
|
+
}
|
|
344
|
+
const AVATAR_EXTENSIONS = ["png", "jpg", "jpeg", "svg", "webp"];
|
|
345
|
+
function discoverAvatar(workspacePath) {
|
|
346
|
+
for (const ext of AVATAR_EXTENSIONS) {
|
|
347
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(workspacePath, `avatar.${ext}`))) {
|
|
348
|
+
return ext;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
function parseIdentityMd(content) {
|
|
354
|
+
const result = { name: "", emoji: "", creature: "", vibe: "" };
|
|
355
|
+
const lines = content.split("\n");
|
|
356
|
+
let currentKey = "";
|
|
357
|
+
const normalize = (value) => value
|
|
358
|
+
.replace(/\s+/g, " ")
|
|
359
|
+
.trim()
|
|
360
|
+
.replace(/^[`*_~\s]+/, "")
|
|
361
|
+
.replace(/[`*_~\s]+$/, "")
|
|
362
|
+
.replace(/^\((.*)\)$/, "$1")
|
|
363
|
+
.trim();
|
|
364
|
+
const isTemplatePlaceholder = (value) => {
|
|
365
|
+
const lower = value.toLowerCase();
|
|
366
|
+
return /(pick something|your signature|fill this in|make it yours|workspace-relative|something weirder|ghost in the machine|how do you come across)/i.test(lower);
|
|
367
|
+
};
|
|
368
|
+
const useIfValid = (key, value) => {
|
|
369
|
+
const normalized = normalize(value);
|
|
370
|
+
if (!normalized || isTemplatePlaceholder(normalized))
|
|
371
|
+
return;
|
|
372
|
+
result[key] = normalized;
|
|
373
|
+
};
|
|
374
|
+
for (const line of lines) {
|
|
375
|
+
const trimmed = line.trim();
|
|
376
|
+
if (trimmed.startsWith("- **Name:**")) {
|
|
377
|
+
currentKey = "name";
|
|
378
|
+
const inline = trimmed.replace("- **Name:**", "").trim();
|
|
379
|
+
if (inline)
|
|
380
|
+
useIfValid("name", inline);
|
|
381
|
+
}
|
|
382
|
+
else if (trimmed.startsWith("- **Creature:**")) {
|
|
383
|
+
currentKey = "creature";
|
|
384
|
+
const inline = trimmed.replace("- **Creature:**", "").trim();
|
|
385
|
+
if (inline)
|
|
386
|
+
useIfValid("creature", inline);
|
|
387
|
+
}
|
|
388
|
+
else if (trimmed.startsWith("- **Vibe:**")) {
|
|
389
|
+
currentKey = "vibe";
|
|
390
|
+
const inline = trimmed.replace("- **Vibe:**", "").trim();
|
|
391
|
+
if (inline)
|
|
392
|
+
useIfValid("vibe", inline);
|
|
393
|
+
}
|
|
394
|
+
else if (trimmed.startsWith("- **Emoji:**")) {
|
|
395
|
+
currentKey = "emoji";
|
|
396
|
+
const inline = trimmed.replace("- **Emoji:**", "").trim();
|
|
397
|
+
if (inline)
|
|
398
|
+
useIfValid("emoji", inline);
|
|
399
|
+
}
|
|
400
|
+
else if (trimmed.startsWith("- **") || trimmed.startsWith("---") || trimmed.startsWith("#")) {
|
|
401
|
+
currentKey = "";
|
|
402
|
+
}
|
|
403
|
+
else if (currentKey && trimmed) {
|
|
404
|
+
const key = currentKey;
|
|
405
|
+
if (!result[key])
|
|
406
|
+
useIfValid(key, trimmed);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return result;
|
|
410
|
+
}
|
|
411
|
+
function countSessions(agentDir) {
|
|
412
|
+
const sessionsDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(agentDir, "sessions");
|
|
413
|
+
if (!(0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(sessionsDir))
|
|
414
|
+
return { count: 0, lastActive: null };
|
|
415
|
+
const sessionsFile = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(sessionsDir, "sessions.json");
|
|
416
|
+
const sessionsData = readJsonSafe(sessionsFile);
|
|
417
|
+
if (!sessionsData)
|
|
418
|
+
return { count: 0, lastActive: null };
|
|
419
|
+
let latestTs = 0;
|
|
420
|
+
let count = 0;
|
|
421
|
+
for (const value of Object.values(sessionsData)) {
|
|
422
|
+
count++;
|
|
423
|
+
if (typeof value === "object" && value && typeof value.updatedAt === "number") {
|
|
424
|
+
if (value.updatedAt > latestTs)
|
|
425
|
+
latestTs = value.updatedAt;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
count,
|
|
430
|
+
lastActive: latestTs ? new Date(latestTs).toISOString() : null,
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function discoverSkills(workspacePath) {
|
|
434
|
+
const skillsDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(workspacePath, "skills");
|
|
435
|
+
if (!(0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(skillsDir))
|
|
436
|
+
return [];
|
|
437
|
+
try {
|
|
438
|
+
return (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(skillsDir, { withFileTypes: true })
|
|
439
|
+
.filter((d) => d.isDirectory())
|
|
440
|
+
.map((d) => {
|
|
441
|
+
const metaPath = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(skillsDir, d.name, "_meta.json");
|
|
442
|
+
const meta = readJsonSafe(metaPath);
|
|
443
|
+
return { name: d.name, description: meta?.description };
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
catch {
|
|
447
|
+
return [];
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function discoverCredentials() {
|
|
451
|
+
const credsDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(OPENCLAW_DIR, "credentials");
|
|
452
|
+
if (!(0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(credsDir))
|
|
453
|
+
return [];
|
|
454
|
+
try {
|
|
455
|
+
return (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(credsDir)
|
|
456
|
+
.filter((f) => f.endsWith(".json"))
|
|
457
|
+
.map((f) => (0,node_path__WEBPACK_IMPORTED_MODULE_2__.basename)(f, ".json"));
|
|
458
|
+
}
|
|
459
|
+
catch {
|
|
460
|
+
return [];
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function scanAgents() {
|
|
464
|
+
if (!(0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(OPENCLAW_DIR))
|
|
465
|
+
return [];
|
|
466
|
+
const config = readJsonSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(OPENCLAW_DIR, "openclaw.json"));
|
|
467
|
+
if (!config)
|
|
468
|
+
return [];
|
|
469
|
+
const agentsConfig = config.agents;
|
|
470
|
+
const pluginsConfig = config.plugins;
|
|
471
|
+
const hooksConfig = config.hooks;
|
|
472
|
+
const gatewayConfig = config.gateway;
|
|
473
|
+
const defaultModel = agentsConfig?.defaults?.model?.primary || "unknown";
|
|
474
|
+
const workspacePath = agentsConfig?.defaults?.workspace || (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(OPENCLAW_DIR, "workspace");
|
|
475
|
+
// Parse model string like "openai-codex/gpt-5.3-codex"
|
|
476
|
+
const [provider, model] = defaultModel.includes("/")
|
|
477
|
+
? defaultModel.split("/", 2)
|
|
478
|
+
: ["unknown", defaultModel];
|
|
479
|
+
// Read identity
|
|
480
|
+
const identityContent = readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(workspacePath, "IDENTITY.md"));
|
|
481
|
+
const identity = parseIdentityMd(identityContent);
|
|
482
|
+
// Discover skills
|
|
483
|
+
const skills = discoverSkills(workspacePath);
|
|
484
|
+
// Connected systems (credentials)
|
|
485
|
+
const connectedSystems = discoverCredentials();
|
|
486
|
+
// Channels — derive from session data
|
|
487
|
+
const channels = [];
|
|
488
|
+
const agentsDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(OPENCLAW_DIR, "agents");
|
|
489
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(agentsDir)) {
|
|
490
|
+
try {
|
|
491
|
+
const agentDirs = (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(agentsDir, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
492
|
+
for (const agentDir of agentDirs) {
|
|
493
|
+
const sessionsFile = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(agentsDir, agentDir.name, "sessions", "sessions.json");
|
|
494
|
+
const sessionsData = readJsonSafe(sessionsFile);
|
|
495
|
+
if (sessionsData) {
|
|
496
|
+
for (const value of Object.values(sessionsData)) {
|
|
497
|
+
if (typeof value === "object" && value && typeof value.lastChannel === "string") {
|
|
498
|
+
if (!channels.includes(value.lastChannel)) {
|
|
499
|
+
channels.push(value.lastChannel);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
catch { /* ignore */ }
|
|
507
|
+
}
|
|
508
|
+
// Plugins
|
|
509
|
+
const plugins = [];
|
|
510
|
+
if (pluginsConfig?.entries) {
|
|
511
|
+
for (const [name, entry] of Object.entries(pluginsConfig.entries)) {
|
|
512
|
+
plugins.push({ name, enabled: entry?.enabled !== false });
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
// Hooks
|
|
516
|
+
const hooks = [];
|
|
517
|
+
if (hooksConfig?.internal?.entries) {
|
|
518
|
+
for (const [name, entry] of Object.entries(hooksConfig.internal.entries)) {
|
|
519
|
+
hooks.push({ name, enabled: entry?.enabled !== false });
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
// Count sessions across all agent dirs
|
|
523
|
+
let totalSessions = 0;
|
|
524
|
+
let lastActive = null;
|
|
525
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(agentsDir)) {
|
|
526
|
+
try {
|
|
527
|
+
for (const dir of (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(agentsDir, { withFileTypes: true })) {
|
|
528
|
+
if (!dir.isDirectory())
|
|
529
|
+
continue;
|
|
530
|
+
const result = countSessions((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(agentsDir, dir.name));
|
|
531
|
+
totalSessions += result.count;
|
|
532
|
+
if (result.lastActive && (!lastActive || result.lastActive > lastActive)) {
|
|
533
|
+
lastActive = result.lastActive;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
catch { /* ignore */ }
|
|
538
|
+
}
|
|
539
|
+
const ownerName = parseOwnerName(workspacePath);
|
|
540
|
+
const avatarExt = discoverAvatar(workspacePath);
|
|
541
|
+
const agent = {
|
|
542
|
+
id: "main",
|
|
543
|
+
name: identity.name || "Agent",
|
|
544
|
+
emoji: identity.emoji || "🤖",
|
|
545
|
+
creature: identity.creature || "",
|
|
546
|
+
vibe: identity.vibe || "",
|
|
547
|
+
model,
|
|
548
|
+
provider,
|
|
549
|
+
workspacePath,
|
|
550
|
+
ownerName,
|
|
551
|
+
avatarUrl: avatarExt ? `/api/discovery/agents/main/avatar` : null,
|
|
552
|
+
skills,
|
|
553
|
+
connectedSystems,
|
|
554
|
+
channels,
|
|
555
|
+
plugins,
|
|
556
|
+
hooks,
|
|
557
|
+
sessionCount: totalSessions,
|
|
558
|
+
lastActive,
|
|
559
|
+
};
|
|
560
|
+
// Check for additional agent directories
|
|
561
|
+
const agents = [agent];
|
|
562
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(agentsDir)) {
|
|
563
|
+
try {
|
|
564
|
+
for (const dir of (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(agentsDir, { withFileTypes: true })) {
|
|
565
|
+
if (!dir.isDirectory() || dir.name === "main")
|
|
566
|
+
continue;
|
|
567
|
+
const agentPath = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(agentsDir, dir.name);
|
|
568
|
+
const sessionInfo = countSessions(agentPath);
|
|
569
|
+
agents.push({
|
|
570
|
+
id: dir.name,
|
|
571
|
+
name: dir.name,
|
|
572
|
+
emoji: "🤖",
|
|
573
|
+
creature: "",
|
|
574
|
+
vibe: "",
|
|
575
|
+
model,
|
|
576
|
+
provider,
|
|
577
|
+
workspacePath: agentPath,
|
|
578
|
+
ownerName: "",
|
|
579
|
+
avatarUrl: null,
|
|
580
|
+
skills: [],
|
|
581
|
+
connectedSystems: [],
|
|
582
|
+
channels: [],
|
|
583
|
+
plugins: [],
|
|
584
|
+
hooks: [],
|
|
585
|
+
sessionCount: sessionInfo.count,
|
|
586
|
+
lastActive: sessionInfo.lastActive,
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
catch { /* ignore */ }
|
|
591
|
+
}
|
|
592
|
+
return agents;
|
|
593
|
+
}
|
|
594
|
+
function getAgent(id) {
|
|
595
|
+
const agents = scanAgents();
|
|
596
|
+
return agents.find((a) => a.id === id);
|
|
597
|
+
}
|
|
598
|
+
// ---- Profile enrichment ----
|
|
599
|
+
function parseFrontmatter(content) {
|
|
600
|
+
const result = {};
|
|
601
|
+
if (!content.startsWith("---"))
|
|
602
|
+
return result;
|
|
603
|
+
const end = content.indexOf("---", 3);
|
|
604
|
+
if (end === -1)
|
|
605
|
+
return result;
|
|
606
|
+
const block = content.slice(3, end);
|
|
607
|
+
for (const line of block.split("\n")) {
|
|
608
|
+
const match = line.match(/^(\w[\w\s]*):\s*(.+)/);
|
|
609
|
+
if (match) {
|
|
610
|
+
const key = match[1].trim().toLowerCase();
|
|
611
|
+
let val = match[2].trim();
|
|
612
|
+
// Strip surrounding quotes
|
|
613
|
+
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
|
|
614
|
+
val = val.slice(1, -1);
|
|
615
|
+
}
|
|
616
|
+
result[key] = val;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
// Try to extract nested emoji from metadata block
|
|
620
|
+
const emojiMatch = block.match(/emoji:\s*["']?([^\n"']+)["']?/);
|
|
621
|
+
if (emojiMatch)
|
|
622
|
+
result["emoji"] = emojiMatch[1].trim();
|
|
623
|
+
return result;
|
|
624
|
+
}
|
|
625
|
+
let _openclawRoot = undefined;
|
|
626
|
+
function resolveOpenclawRoot() {
|
|
627
|
+
if (_openclawRoot !== undefined)
|
|
628
|
+
return _openclawRoot;
|
|
629
|
+
// Try env var first
|
|
630
|
+
const skillsPath = (0,_runtime_config_js__WEBPACK_IMPORTED_MODULE_4__.getEnv)("OPENCLAW_SKILLS_PATH");
|
|
631
|
+
if (skillsPath) {
|
|
632
|
+
_openclawRoot = skillsPath;
|
|
633
|
+
return _openclawRoot;
|
|
634
|
+
}
|
|
635
|
+
try {
|
|
636
|
+
const bin = (0,node_child_process__WEBPACK_IMPORTED_MODULE_1__.execSync)("which openclaw", { encoding: "utf-8", timeout: 5000 }).trim();
|
|
637
|
+
if (bin) {
|
|
638
|
+
// Binary is at <prefix>/bin/openclaw
|
|
639
|
+
const binDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.dirname)(bin);
|
|
640
|
+
// Standard global install: <prefix>/bin/openclaw → <prefix>/lib/node_modules/openclaw
|
|
641
|
+
// Covers nvm, volta, fnm, homebrew node, system node
|
|
642
|
+
const globalPkg = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(binDir, "..", "lib", "node_modules", "openclaw");
|
|
643
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(globalPkg, "skills"))) {
|
|
644
|
+
_openclawRoot = globalPkg;
|
|
645
|
+
return _openclawRoot;
|
|
646
|
+
}
|
|
647
|
+
// Sibling layout: <pkg>/bin/openclaw → <pkg>/skills
|
|
648
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(binDir, "..", "skills"))) {
|
|
649
|
+
_openclawRoot = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(binDir, "..");
|
|
650
|
+
return _openclawRoot;
|
|
651
|
+
}
|
|
652
|
+
// node_modules/.bin symlink: node_modules/.bin/openclaw → node_modules/openclaw
|
|
653
|
+
const parentDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.dirname)(binDir);
|
|
654
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(parentDir, "openclaw", "skills"))) {
|
|
655
|
+
_openclawRoot = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(parentDir, "openclaw");
|
|
656
|
+
return _openclawRoot;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
catch {
|
|
661
|
+
// which not found or timeout
|
|
662
|
+
}
|
|
663
|
+
// Fallback: common locations
|
|
664
|
+
const candidates = [
|
|
665
|
+
(0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)((0,node_os__WEBPACK_IMPORTED_MODULE_3__.homedir)(), ".openclaw", "node_modules", "openclaw"),
|
|
666
|
+
"/usr/local/lib/node_modules/openclaw",
|
|
667
|
+
];
|
|
668
|
+
for (const c of candidates) {
|
|
669
|
+
if ((0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(c, "skills"))) {
|
|
670
|
+
_openclawRoot = c;
|
|
671
|
+
return _openclawRoot;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
_openclawRoot = null;
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
function discoverSystemSkills() {
|
|
678
|
+
const root = resolveOpenclawRoot();
|
|
679
|
+
if (!root)
|
|
680
|
+
return [];
|
|
681
|
+
const skillsDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(root, "skills");
|
|
682
|
+
if (!(0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(skillsDir))
|
|
683
|
+
return [];
|
|
684
|
+
try {
|
|
685
|
+
return (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(skillsDir, { withFileTypes: true })
|
|
686
|
+
.filter((d) => d.isDirectory())
|
|
687
|
+
.map((d) => {
|
|
688
|
+
const skillMd = readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(skillsDir, d.name, "SKILL.md"));
|
|
689
|
+
const fm = parseFrontmatter(skillMd);
|
|
690
|
+
return {
|
|
691
|
+
name: fm["name"] || d.name,
|
|
692
|
+
description: fm["description"],
|
|
693
|
+
emoji: fm["emoji"],
|
|
694
|
+
source: "system",
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
catch {
|
|
699
|
+
return [];
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function discoverWorkspaceSkillsEnriched(workspacePath) {
|
|
703
|
+
const skillsDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(workspacePath, "skills");
|
|
704
|
+
if (!(0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(skillsDir))
|
|
705
|
+
return [];
|
|
706
|
+
try {
|
|
707
|
+
return (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(skillsDir, { withFileTypes: true })
|
|
708
|
+
.filter((d) => d.isDirectory())
|
|
709
|
+
.map((d) => {
|
|
710
|
+
// Try SKILL.md frontmatter first, fall back to _meta.json
|
|
711
|
+
const skillMd = readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(skillsDir, d.name, "SKILL.md"));
|
|
712
|
+
const fm = parseFrontmatter(skillMd);
|
|
713
|
+
const meta = readJsonSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(skillsDir, d.name, "_meta.json"));
|
|
714
|
+
return {
|
|
715
|
+
name: fm["name"] || d.name,
|
|
716
|
+
description: fm["description"] || meta?.description,
|
|
717
|
+
emoji: fm["emoji"],
|
|
718
|
+
source: "workspace",
|
|
719
|
+
};
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
catch {
|
|
723
|
+
return [];
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function discoverSystemExtensions() {
|
|
727
|
+
const root = resolveOpenclawRoot();
|
|
728
|
+
if (!root)
|
|
729
|
+
return [];
|
|
730
|
+
const extDir = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(root, "extensions");
|
|
731
|
+
if (!(0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(extDir))
|
|
732
|
+
return [];
|
|
733
|
+
try {
|
|
734
|
+
return (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(extDir, { withFileTypes: true })
|
|
735
|
+
.filter((d) => d.isDirectory())
|
|
736
|
+
.map((d) => {
|
|
737
|
+
const pluginJson = readJsonSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(extDir, d.name, "openclaw.plugin.json"));
|
|
738
|
+
const pkgJson = readJsonSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(extDir, d.name, "package.json"));
|
|
739
|
+
return {
|
|
740
|
+
name: pluginJson?.id || d.name,
|
|
741
|
+
description: pkgJson?.description || "",
|
|
742
|
+
channels: pluginJson?.channels || [],
|
|
743
|
+
};
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
catch {
|
|
747
|
+
return [];
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
function getAgentProfile(id) {
|
|
751
|
+
const agent = getAgent(id);
|
|
752
|
+
if (!agent)
|
|
753
|
+
return undefined;
|
|
754
|
+
const wp = agent.workspacePath;
|
|
755
|
+
// Read workspace MD files
|
|
756
|
+
const workspaceFiles = {
|
|
757
|
+
soul: readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(wp, "SOUL.md")),
|
|
758
|
+
identity: readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(wp, "IDENTITY.md")),
|
|
759
|
+
user: readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(wp, "USER.md")),
|
|
760
|
+
agents: readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(wp, "AGENTS.md")),
|
|
761
|
+
tools: readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(wp, "TOOLS.md")),
|
|
762
|
+
heartbeat: readFileSafe((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(wp, "HEARTBEAT.md")),
|
|
763
|
+
};
|
|
764
|
+
// Bootstrap existence
|
|
765
|
+
const bootstrapExists = (0,node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)((0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(wp, "BOOTSTRAP.md"));
|
|
766
|
+
// Cron jobs
|
|
767
|
+
let cronJobs = [];
|
|
768
|
+
const cronPath = (0,node_path__WEBPACK_IMPORTED_MODULE_2__.join)(OPENCLAW_DIR, "cron", "jobs.json");
|
|
769
|
+
try {
|
|
770
|
+
const raw = readFileSafe(cronPath);
|
|
771
|
+
if (raw) {
|
|
772
|
+
const parsed = JSON.parse(raw);
|
|
773
|
+
if (Array.isArray(parsed)) {
|
|
774
|
+
cronJobs = parsed;
|
|
775
|
+
}
|
|
776
|
+
else if (typeof parsed === "object" && parsed !== null) {
|
|
777
|
+
// Handle { jobs: [...] } shape
|
|
778
|
+
cronJobs = parsed.jobs || Object.values(parsed);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
catch {
|
|
783
|
+
// ignore
|
|
784
|
+
}
|
|
785
|
+
// Combine system + workspace skills
|
|
786
|
+
const systemSkills = discoverSystemSkills();
|
|
787
|
+
const workspaceSkills = discoverWorkspaceSkillsEnriched(wp);
|
|
788
|
+
const allSkills = [...systemSkills, ...workspaceSkills];
|
|
789
|
+
// Bundled extensions
|
|
790
|
+
const bundledExtensions = discoverSystemExtensions();
|
|
791
|
+
return {
|
|
792
|
+
...agent,
|
|
793
|
+
workspaceFiles,
|
|
794
|
+
bootstrapExists,
|
|
795
|
+
cronJobs,
|
|
796
|
+
allSkills,
|
|
797
|
+
bundledExtensions,
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
//# sourceMappingURL=discovery.js.map
|
|
801
|
+
|
|
802
|
+
/***/ })
|
|
803
|
+
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
//# sourceMappingURL=573.index.js.map
|