@lightcone-ai/daemon 0.14.17 → 0.14.19

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.
@@ -0,0 +1,90 @@
1
+ import { readFileSync } from 'fs';
2
+
3
+ function isPlainObject(value) {
4
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
5
+ }
6
+
7
+ function normalizeToken(value) {
8
+ return String(value ?? '').trim();
9
+ }
10
+
11
+ function normalizeId(value) {
12
+ return normalizeToken(value).toLowerCase();
13
+ }
14
+
15
+ function normalizeToolList(value) {
16
+ if (Array.isArray(value)) {
17
+ return value
18
+ .map(item => normalizeToken(item).toLowerCase())
19
+ .filter(Boolean);
20
+ }
21
+ const direct = normalizeToken(value).toLowerCase();
22
+ return direct ? [direct] : [];
23
+ }
24
+
25
+ function normalizeRule(rawRule) {
26
+ if (!isPlainObject(rawRule)) return null;
27
+
28
+ const workspaceId = normalizeId(rawRule.workspace_id ?? rawRule.workspaceId);
29
+ const agentId = normalizeId(rawRule.agent_id ?? rawRule.agentId);
30
+ const tools = normalizeToolList(
31
+ rawRule.tools
32
+ ?? rawRule.tool_names
33
+ ?? rawRule.toolNames
34
+ ?? rawRule.tool
35
+ );
36
+ const message = normalizeToken(rawRule.message ?? rawRule.error ?? rawRule.reason);
37
+
38
+ if (!workspaceId || !agentId || tools.length === 0 || !message) {
39
+ return null;
40
+ }
41
+
42
+ return {
43
+ workspaceId,
44
+ agentId,
45
+ tools,
46
+ message,
47
+ };
48
+ }
49
+
50
+ export function loadToolBlockRulesFromManifest(manifestUrl) {
51
+ if (!manifestUrl) return [];
52
+ let rawManifest = null;
53
+ try {
54
+ rawManifest = JSON.parse(readFileSync(manifestUrl, 'utf8'));
55
+ } catch {
56
+ return [];
57
+ }
58
+ if (!isPlainObject(rawManifest)) return [];
59
+
60
+ const rawRules = Array.isArray(rawManifest.tool_block_rules)
61
+ ? rawManifest.tool_block_rules
62
+ : Array.isArray(rawManifest.toolBlockRules)
63
+ ? rawManifest.toolBlockRules
64
+ : [];
65
+
66
+ return rawRules
67
+ .map(rule => normalizeRule(rule))
68
+ .filter(Boolean);
69
+ }
70
+
71
+ export function findToolBlockRule(rules, {
72
+ toolName = '',
73
+ workspaceId = '',
74
+ agentId = '',
75
+ } = {}) {
76
+ if (!Array.isArray(rules) || rules.length === 0) return null;
77
+
78
+ const targetTool = normalizeToken(toolName).toLowerCase();
79
+ const targetWorkspaceId = normalizeId(workspaceId);
80
+ const targetAgentId = normalizeId(agentId);
81
+ if (!targetTool || !targetWorkspaceId || !targetAgentId) return null;
82
+
83
+ for (const rule of rules) {
84
+ if (!rule || rule.workspaceId !== targetWorkspaceId || rule.agentId !== targetAgentId) continue;
85
+ if (rule.tools.includes('*') || rule.tools.includes(targetTool)) {
86
+ return rule;
87
+ }
88
+ }
89
+ return null;
90
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.14.17",
3
+ "version": "0.14.19",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -18,9 +18,11 @@
18
18
  "postpack": "node scripts/unvendor-shared.js"
19
19
  },
20
20
  "dependencies": {
21
+ "@mozilla/readability": "^0.6.0",
21
22
  "@modelcontextprotocol/sdk": "^1.12.0",
22
23
  "dotenv": "^17.4.0",
23
24
  "mysql2": "^3.14.0",
25
+ "playwright-core": "^1.59.1",
24
26
  "ws": "^8.20.0",
25
27
  "zod": "^3.24.0"
26
28
  }