@chrysb/alphaclaw 0.6.0-beta.0 → 0.6.0-beta.2
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/lib/public/js/components/agents-tab/agent-bindings-section/channel-item-trailing.js +203 -0
- package/lib/public/js/components/agents-tab/agent-bindings-section/helpers.js +10 -12
- package/lib/public/js/components/agents-tab/agent-bindings-section/index.js +19 -287
- package/lib/public/js/components/agents-tab/agent-bindings-section/use-agent-bindings.js +1 -1
- package/lib/public/js/components/agents-tab/agent-bindings-section/use-channel-items.js +211 -0
- package/lib/public/js/components/agents-tab/agent-pairing-section.js +17 -4
- package/lib/public/js/components/agents-tab/create-channel-modal.js +29 -6
- package/lib/public/js/components/channels.js +19 -14
- package/lib/public/js/components/doctor/index.js +2 -1
- package/lib/public/js/lib/channel-accounts.js +20 -0
- package/lib/server/agents/agents.js +207 -0
- package/lib/server/agents/bindings.js +74 -0
- package/lib/server/agents/channels.js +674 -0
- package/lib/server/agents/service.js +28 -1457
- package/lib/server/agents/shared.js +631 -0
- package/lib/server/constants.js +1 -0
- package/lib/server/openclaw-config.js +13 -0
- package/lib/server/routes/pairings.js +29 -3
- package/lib/server/routes/system.js +1 -6
- package/lib/server/routes/telegram.js +34 -16
- package/lib/server/telegram-workspace.js +16 -5
- package/lib/server/topic-registry.js +1 -4
- package/lib/server/utils/channels.js +13 -0
- package/package.json +2 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const {
|
|
2
|
+
loadConfig,
|
|
3
|
+
saveConfig,
|
|
4
|
+
cloneJson,
|
|
5
|
+
normalizeBindingMatch,
|
|
6
|
+
matchesBinding,
|
|
7
|
+
appendBindingToConfig,
|
|
8
|
+
withNormalizedAgentsConfig,
|
|
9
|
+
} = require("./shared");
|
|
10
|
+
|
|
11
|
+
const createBindingsDomain = ({ fsImpl, OPENCLAW_DIR }) => {
|
|
12
|
+
const getBindingsForAgent = (agentId) => {
|
|
13
|
+
const normalized = String(agentId || "").trim();
|
|
14
|
+
const cfg = withNormalizedAgentsConfig({
|
|
15
|
+
OPENCLAW_DIR,
|
|
16
|
+
cfg: loadConfig({ fsImpl, OPENCLAW_DIR }),
|
|
17
|
+
});
|
|
18
|
+
const bindings = Array.isArray(cfg.bindings) ? cfg.bindings : [];
|
|
19
|
+
return bindings
|
|
20
|
+
.filter((binding) => String(binding?.agentId || "").trim() === normalized)
|
|
21
|
+
.map((binding) => cloneJson(binding));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const addBinding = (agentId, input = {}) => {
|
|
25
|
+
const normalizedAgentId = String(agentId || "").trim();
|
|
26
|
+
const cfg = withNormalizedAgentsConfig({
|
|
27
|
+
OPENCLAW_DIR,
|
|
28
|
+
cfg: loadConfig({ fsImpl, OPENCLAW_DIR }),
|
|
29
|
+
});
|
|
30
|
+
const agent = cfg.agents.list.find(
|
|
31
|
+
(entry) => entry.id === normalizedAgentId,
|
|
32
|
+
);
|
|
33
|
+
if (!agent) throw new Error(`Agent "${normalizedAgentId}" not found`);
|
|
34
|
+
const match = normalizeBindingMatch(input);
|
|
35
|
+
const nextBinding = appendBindingToConfig({
|
|
36
|
+
cfg,
|
|
37
|
+
agentId: normalizedAgentId,
|
|
38
|
+
match,
|
|
39
|
+
});
|
|
40
|
+
saveConfig({ fsImpl, OPENCLAW_DIR, config: cfg });
|
|
41
|
+
return nextBinding;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const removeBinding = (agentId, input = {}) => {
|
|
45
|
+
const normalizedAgentId = String(agentId || "").trim();
|
|
46
|
+
const cfg = withNormalizedAgentsConfig({
|
|
47
|
+
OPENCLAW_DIR,
|
|
48
|
+
cfg: loadConfig({ fsImpl, OPENCLAW_DIR }),
|
|
49
|
+
});
|
|
50
|
+
const bindings = Array.isArray(cfg.bindings) ? cfg.bindings : [];
|
|
51
|
+
const nextMatch = normalizeBindingMatch(input);
|
|
52
|
+
const nextBindings = bindings.filter(
|
|
53
|
+
(binding) =>
|
|
54
|
+
!(
|
|
55
|
+
String(binding?.agentId || "").trim() === normalizedAgentId &&
|
|
56
|
+
matchesBinding(binding?.match || {}, nextMatch)
|
|
57
|
+
),
|
|
58
|
+
);
|
|
59
|
+
if (nextBindings.length === bindings.length) {
|
|
60
|
+
throw new Error("Binding not found");
|
|
61
|
+
}
|
|
62
|
+
cfg.bindings = nextBindings;
|
|
63
|
+
saveConfig({ fsImpl, OPENCLAW_DIR, config: cfg });
|
|
64
|
+
return { ok: true };
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
getBindingsForAgent,
|
|
69
|
+
addBinding,
|
|
70
|
+
removeBinding,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = { createBindingsDomain };
|