aamp-openclaw-plugin 0.1.24 → 0.1.25
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/bin/aamp-openclaw-plugin.mjs +105 -1
- package/package.json +1 -1
|
@@ -62,9 +62,113 @@ function expandHome(pathValue) {
|
|
|
62
62
|
return pathValue
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
function stripJsonComments(text) {
|
|
66
|
+
let result = ''
|
|
67
|
+
let inString = false
|
|
68
|
+
let stringQuote = ''
|
|
69
|
+
let escaped = false
|
|
70
|
+
|
|
71
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
72
|
+
const char = text[i]
|
|
73
|
+
const next = text[i + 1]
|
|
74
|
+
|
|
75
|
+
if (inString) {
|
|
76
|
+
result += char
|
|
77
|
+
if (escaped) {
|
|
78
|
+
escaped = false
|
|
79
|
+
} else if (char === '\\') {
|
|
80
|
+
escaped = true
|
|
81
|
+
} else if (char === stringQuote) {
|
|
82
|
+
inString = false
|
|
83
|
+
stringQuote = ''
|
|
84
|
+
}
|
|
85
|
+
continue
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (char === '"' || char === "'") {
|
|
89
|
+
inString = true
|
|
90
|
+
stringQuote = char
|
|
91
|
+
result += char
|
|
92
|
+
continue
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (char === '/' && next === '/') {
|
|
96
|
+
i += 2
|
|
97
|
+
while (i < text.length && text[i] !== '\n') i += 1
|
|
98
|
+
if (i < text.length) result += text[i]
|
|
99
|
+
continue
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (char === '/' && next === '*') {
|
|
103
|
+
i += 2
|
|
104
|
+
while (i < text.length && !(text[i] === '*' && text[i + 1] === '/')) i += 1
|
|
105
|
+
i += 1
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
result += char
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return result
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function stripTrailingCommas(text) {
|
|
116
|
+
let result = ''
|
|
117
|
+
let inString = false
|
|
118
|
+
let stringQuote = ''
|
|
119
|
+
let escaped = false
|
|
120
|
+
|
|
121
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
122
|
+
const char = text[i]
|
|
123
|
+
|
|
124
|
+
if (inString) {
|
|
125
|
+
result += char
|
|
126
|
+
if (escaped) {
|
|
127
|
+
escaped = false
|
|
128
|
+
} else if (char === '\\') {
|
|
129
|
+
escaped = true
|
|
130
|
+
} else if (char === stringQuote) {
|
|
131
|
+
inString = false
|
|
132
|
+
stringQuote = ''
|
|
133
|
+
}
|
|
134
|
+
continue
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (char === '"' || char === "'") {
|
|
138
|
+
inString = true
|
|
139
|
+
stringQuote = char
|
|
140
|
+
result += char
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (char === ',') {
|
|
145
|
+
let lookahead = i + 1
|
|
146
|
+
while (lookahead < text.length && /\s/.test(text[lookahead])) lookahead += 1
|
|
147
|
+
if (text[lookahead] === '}' || text[lookahead] === ']') {
|
|
148
|
+
continue
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
result += char
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return result
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function parseJsonConfig(raw, path) {
|
|
159
|
+
const normalized = raw.replace(/^\uFEFF/, '')
|
|
160
|
+
const sanitized = stripTrailingCommas(stripJsonComments(normalized))
|
|
161
|
+
try {
|
|
162
|
+
return JSON.parse(sanitized)
|
|
163
|
+
} catch (error) {
|
|
164
|
+
const reason = error instanceof Error ? error.message : String(error)
|
|
165
|
+
throw new Error(`Failed to parse ${path}: ${reason}`)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
65
169
|
function readJsonFile(path) {
|
|
66
170
|
if (!existsSync(path)) return null
|
|
67
|
-
return
|
|
171
|
+
return parseJsonConfig(readFileSync(path, 'utf-8'), path)
|
|
68
172
|
}
|
|
69
173
|
|
|
70
174
|
function writeJsonFile(path, value) {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"skills"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.1.
|
|
10
|
+
"version": "0.1.25",
|
|
11
11
|
"description": "AAMP Agent Mail Protocol — OpenClaw plugin. Gives OpenClaw an AAMP mailbox identity and lets it receive, process and reply to AAMP tasks.",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "dist/index.js",
|