grix-connector 3.31.2 → 3.32.0
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/dist/adapter/acp/acp-adapter.js +10 -10
- package/dist/adapter/claude/protocol-contract.js +1 -1
- package/dist/adapter/claude/skill-scanner.js +2 -2
- package/dist/adapter/codex/codex-bridge.js +8 -8
- package/dist/adapter/cursor/cursor-adapter.js +7 -7
- package/dist/adapter/cursor/resolve-command.js +1 -0
- package/dist/adapter/deepseek-harness/jsonrpc-adapter.js +2 -2
- package/dist/adapter/deepseek-harness/skill-manager.js +1 -1
- package/dist/adapter/shared/native-provider-config.js +5 -5
- package/dist/assets/dsh-bridge/{grix-dsh-bridge-3.31.2.tgz → grix-dsh-bridge-3.32.0.tgz} +0 -0
- package/dist/assets/dsh-bridge/manifest.json +5 -5
- package/dist/bridge/adapter-pool.js +1 -1
- package/dist/bridge/bridge.js +7 -7
- package/dist/bridge/session-controller.js +6 -6
- package/dist/core/aibot/binding-card-meta-cache.js +1 -1
- package/dist/core/aibot/connection-handle.js +1 -1
- package/dist/core/skill-sync/enable-roots.js +1 -1
- package/dist/core/skill-sync/hermes-trust.js +1 -0
- package/dist/core/skill-sync/skill-delete.js +1 -0
- package/dist/core/skill-sync/skill-enable.js +1 -1
- package/dist/core/skill-sync/sync-state.js +1 -1
- package/dist/core/util/display-path.js +1 -0
- package/dist/core/util/index.js +1 -1
- package/dist/default-skills/index.js +1 -1
- package/dist/grix.js +0 -0
- package/dist/manager.js +2 -2
- package/openclaw-plugin/index.js +727 -2606
- package/openclaw.plugin.json +14 -0
- package/package.json +4 -3
- package/dist/adapter/claude/claude-bridge-server.js +0 -1
- package/dist/adapter/claude/claude-tools.js +0 -1
- package/dist/adapter/claude/claude-worker-client.js +0 -1
- package/dist/adapter/claude/mcp-http-launcher.js +0 -2
- package/dist/adapter/claude/result-timeout.js +0 -1
- package/dist/adapter/deepseek/deepseek-adapter.js +0 -6
- package/dist/adapter/deepseek/index.js +0 -1
- package/dist/adapter/qwen/index.js +0 -1
- package/dist/adapter/qwen/qwen-adapter.js +0 -4
- package/dist/aibot/client.js +0 -1
- package/dist/aibot/index.js +0 -1
- package/dist/aibot/types.js +0 -0
- package/dist/core/access/allowlist-gate.js +0 -1
- package/dist/core/access/allowlist-store.js +0 -1
- package/dist/core/access/index.js +0 -1
- package/dist/core/file-ops/handler.js +0 -1
- package/dist/core/file-ops/list-files.js +0 -1
- package/dist/core/file-ops/types.js +0 -0
- package/dist/log.js +0 -3
- package/dist/main.js +0 -31
- package/dist/mcp/stream-http/config.js +0 -1
- package/dist/mcp/stream-http/connection-binding.js +0 -1
- package/dist/mcp/stream-http/event-tool-executor.js +0 -1
- package/dist/mcp/stream-http/gateway.js +0 -1
- package/dist/mcp/stream-http/index.js +0 -1
- package/dist/mcp/stream-http/security.js +0 -1
- package/dist/mcp/stream-http/session-manager.js +0 -1
- package/dist/mcp/stream-http/tool-executor.js +0 -1
- package/dist/mcp/stream-http/tool-registry.js +0 -1
- package/dist/mcp/stream-http/tool-schemas.js +0 -1
- package/dist/session/index.js +0 -1
- package/dist/session/manager.js +0 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/json-rpc.js +0 -3
package/openclaw-plugin/index.js
CHANGED
|
@@ -1,2399 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
32
|
-
|
|
33
|
-
// node_modules/ms/index.js
|
|
34
|
-
var require_ms = __commonJS({
|
|
35
|
-
"node_modules/ms/index.js"(exports, module) {
|
|
36
|
-
var s = 1e3;
|
|
37
|
-
var m = s * 60;
|
|
38
|
-
var h = m * 60;
|
|
39
|
-
var d = h * 24;
|
|
40
|
-
var w2 = d * 7;
|
|
41
|
-
var y = d * 365.25;
|
|
42
|
-
module.exports = function(val, options) {
|
|
43
|
-
options = options || {};
|
|
44
|
-
var type = typeof val;
|
|
45
|
-
if (type === "string" && val.length > 0) {
|
|
46
|
-
return parse(val);
|
|
47
|
-
} else if (type === "number" && isFinite(val)) {
|
|
48
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
49
|
-
}
|
|
50
|
-
throw new Error(
|
|
51
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
function parse(str) {
|
|
55
|
-
str = String(str);
|
|
56
|
-
if (str.length > 100) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
60
|
-
str
|
|
61
|
-
);
|
|
62
|
-
if (!match) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
var n = parseFloat(match[1]);
|
|
66
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
67
|
-
switch (type) {
|
|
68
|
-
case "years":
|
|
69
|
-
case "year":
|
|
70
|
-
case "yrs":
|
|
71
|
-
case "yr":
|
|
72
|
-
case "y":
|
|
73
|
-
return n * y;
|
|
74
|
-
case "weeks":
|
|
75
|
-
case "week":
|
|
76
|
-
case "w":
|
|
77
|
-
return n * w2;
|
|
78
|
-
case "days":
|
|
79
|
-
case "day":
|
|
80
|
-
case "d":
|
|
81
|
-
return n * d;
|
|
82
|
-
case "hours":
|
|
83
|
-
case "hour":
|
|
84
|
-
case "hrs":
|
|
85
|
-
case "hr":
|
|
86
|
-
case "h":
|
|
87
|
-
return n * h;
|
|
88
|
-
case "minutes":
|
|
89
|
-
case "minute":
|
|
90
|
-
case "mins":
|
|
91
|
-
case "min":
|
|
92
|
-
case "m":
|
|
93
|
-
return n * m;
|
|
94
|
-
case "seconds":
|
|
95
|
-
case "second":
|
|
96
|
-
case "secs":
|
|
97
|
-
case "sec":
|
|
98
|
-
case "s":
|
|
99
|
-
return n * s;
|
|
100
|
-
case "milliseconds":
|
|
101
|
-
case "millisecond":
|
|
102
|
-
case "msecs":
|
|
103
|
-
case "msec":
|
|
104
|
-
case "ms":
|
|
105
|
-
return n;
|
|
106
|
-
default:
|
|
107
|
-
return void 0;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function fmtShort(ms) {
|
|
111
|
-
var msAbs = Math.abs(ms);
|
|
112
|
-
if (msAbs >= d) {
|
|
113
|
-
return Math.round(ms / d) + "d";
|
|
114
|
-
}
|
|
115
|
-
if (msAbs >= h) {
|
|
116
|
-
return Math.round(ms / h) + "h";
|
|
117
|
-
}
|
|
118
|
-
if (msAbs >= m) {
|
|
119
|
-
return Math.round(ms / m) + "m";
|
|
120
|
-
}
|
|
121
|
-
if (msAbs >= s) {
|
|
122
|
-
return Math.round(ms / s) + "s";
|
|
123
|
-
}
|
|
124
|
-
return ms + "ms";
|
|
125
|
-
}
|
|
126
|
-
function fmtLong(ms) {
|
|
127
|
-
var msAbs = Math.abs(ms);
|
|
128
|
-
if (msAbs >= d) {
|
|
129
|
-
return plural(ms, msAbs, d, "day");
|
|
130
|
-
}
|
|
131
|
-
if (msAbs >= h) {
|
|
132
|
-
return plural(ms, msAbs, h, "hour");
|
|
133
|
-
}
|
|
134
|
-
if (msAbs >= m) {
|
|
135
|
-
return plural(ms, msAbs, m, "minute");
|
|
136
|
-
}
|
|
137
|
-
if (msAbs >= s) {
|
|
138
|
-
return plural(ms, msAbs, s, "second");
|
|
139
|
-
}
|
|
140
|
-
return ms + " ms";
|
|
141
|
-
}
|
|
142
|
-
function plural(ms, msAbs, n, name) {
|
|
143
|
-
var isPlural = msAbs >= n * 1.5;
|
|
144
|
-
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// node_modules/debug/src/common.js
|
|
150
|
-
var require_common = __commonJS({
|
|
151
|
-
"node_modules/debug/src/common.js"(exports, module) {
|
|
152
|
-
function setup(env) {
|
|
153
|
-
createDebug.debug = createDebug;
|
|
154
|
-
createDebug.default = createDebug;
|
|
155
|
-
createDebug.coerce = coerce;
|
|
156
|
-
createDebug.disable = disable;
|
|
157
|
-
createDebug.enable = enable;
|
|
158
|
-
createDebug.enabled = enabled;
|
|
159
|
-
createDebug.humanize = require_ms();
|
|
160
|
-
createDebug.destroy = destroy;
|
|
161
|
-
Object.keys(env).forEach((key) => {
|
|
162
|
-
createDebug[key] = env[key];
|
|
163
|
-
});
|
|
164
|
-
createDebug.names = [];
|
|
165
|
-
createDebug.skips = [];
|
|
166
|
-
createDebug.formatters = {};
|
|
167
|
-
function selectColor(namespace) {
|
|
168
|
-
let hash = 0;
|
|
169
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
170
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
171
|
-
hash |= 0;
|
|
172
|
-
}
|
|
173
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
174
|
-
}
|
|
175
|
-
createDebug.selectColor = selectColor;
|
|
176
|
-
function createDebug(namespace) {
|
|
177
|
-
let prevTime;
|
|
178
|
-
let enableOverride = null;
|
|
179
|
-
let namespacesCache;
|
|
180
|
-
let enabledCache;
|
|
181
|
-
function debug(...args) {
|
|
182
|
-
if (!debug.enabled) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
const self = debug;
|
|
186
|
-
const curr = Number(/* @__PURE__ */ new Date());
|
|
187
|
-
const ms = curr - (prevTime || curr);
|
|
188
|
-
self.diff = ms;
|
|
189
|
-
self.prev = prevTime;
|
|
190
|
-
self.curr = curr;
|
|
191
|
-
prevTime = curr;
|
|
192
|
-
args[0] = createDebug.coerce(args[0]);
|
|
193
|
-
if (typeof args[0] !== "string") {
|
|
194
|
-
args.unshift("%O");
|
|
195
|
-
}
|
|
196
|
-
let index = 0;
|
|
197
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
198
|
-
if (match === "%%") {
|
|
199
|
-
return "%";
|
|
200
|
-
}
|
|
201
|
-
index++;
|
|
202
|
-
const formatter = createDebug.formatters[format];
|
|
203
|
-
if (typeof formatter === "function") {
|
|
204
|
-
const val = args[index];
|
|
205
|
-
match = formatter.call(self, val);
|
|
206
|
-
args.splice(index, 1);
|
|
207
|
-
index--;
|
|
208
|
-
}
|
|
209
|
-
return match;
|
|
210
|
-
});
|
|
211
|
-
createDebug.formatArgs.call(self, args);
|
|
212
|
-
const logFn = self.log || createDebug.log;
|
|
213
|
-
logFn.apply(self, args);
|
|
214
|
-
}
|
|
215
|
-
debug.namespace = namespace;
|
|
216
|
-
debug.useColors = createDebug.useColors();
|
|
217
|
-
debug.color = createDebug.selectColor(namespace);
|
|
218
|
-
debug.extend = extend;
|
|
219
|
-
debug.destroy = createDebug.destroy;
|
|
220
|
-
Object.defineProperty(debug, "enabled", {
|
|
221
|
-
enumerable: true,
|
|
222
|
-
configurable: false,
|
|
223
|
-
get: () => {
|
|
224
|
-
if (enableOverride !== null) {
|
|
225
|
-
return enableOverride;
|
|
226
|
-
}
|
|
227
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
228
|
-
namespacesCache = createDebug.namespaces;
|
|
229
|
-
enabledCache = createDebug.enabled(namespace);
|
|
230
|
-
}
|
|
231
|
-
return enabledCache;
|
|
232
|
-
},
|
|
233
|
-
set: (v) => {
|
|
234
|
-
enableOverride = v;
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
if (typeof createDebug.init === "function") {
|
|
238
|
-
createDebug.init(debug);
|
|
239
|
-
}
|
|
240
|
-
return debug;
|
|
241
|
-
}
|
|
242
|
-
function extend(namespace, delimiter) {
|
|
243
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
244
|
-
newDebug.log = this.log;
|
|
245
|
-
return newDebug;
|
|
246
|
-
}
|
|
247
|
-
function enable(namespaces) {
|
|
248
|
-
createDebug.save(namespaces);
|
|
249
|
-
createDebug.namespaces = namespaces;
|
|
250
|
-
createDebug.names = [];
|
|
251
|
-
createDebug.skips = [];
|
|
252
|
-
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
253
|
-
for (const ns of split) {
|
|
254
|
-
if (ns[0] === "-") {
|
|
255
|
-
createDebug.skips.push(ns.slice(1));
|
|
256
|
-
} else {
|
|
257
|
-
createDebug.names.push(ns);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
function matchesTemplate(search, template) {
|
|
262
|
-
let searchIndex = 0;
|
|
263
|
-
let templateIndex = 0;
|
|
264
|
-
let starIndex = -1;
|
|
265
|
-
let matchIndex = 0;
|
|
266
|
-
while (searchIndex < search.length) {
|
|
267
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
268
|
-
if (template[templateIndex] === "*") {
|
|
269
|
-
starIndex = templateIndex;
|
|
270
|
-
matchIndex = searchIndex;
|
|
271
|
-
templateIndex++;
|
|
272
|
-
} else {
|
|
273
|
-
searchIndex++;
|
|
274
|
-
templateIndex++;
|
|
275
|
-
}
|
|
276
|
-
} else if (starIndex !== -1) {
|
|
277
|
-
templateIndex = starIndex + 1;
|
|
278
|
-
matchIndex++;
|
|
279
|
-
searchIndex = matchIndex;
|
|
280
|
-
} else {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
285
|
-
templateIndex++;
|
|
286
|
-
}
|
|
287
|
-
return templateIndex === template.length;
|
|
288
|
-
}
|
|
289
|
-
function disable() {
|
|
290
|
-
const namespaces = [
|
|
291
|
-
...createDebug.names,
|
|
292
|
-
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
293
|
-
].join(",");
|
|
294
|
-
createDebug.enable("");
|
|
295
|
-
return namespaces;
|
|
296
|
-
}
|
|
297
|
-
function enabled(name) {
|
|
298
|
-
for (const skip of createDebug.skips) {
|
|
299
|
-
if (matchesTemplate(name, skip)) {
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
for (const ns of createDebug.names) {
|
|
304
|
-
if (matchesTemplate(name, ns)) {
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
function coerce(val) {
|
|
311
|
-
if (val instanceof Error) {
|
|
312
|
-
return val.stack || val.message;
|
|
313
|
-
}
|
|
314
|
-
return val;
|
|
315
|
-
}
|
|
316
|
-
function destroy() {
|
|
317
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
318
|
-
}
|
|
319
|
-
createDebug.enable(createDebug.load());
|
|
320
|
-
return createDebug;
|
|
321
|
-
}
|
|
322
|
-
module.exports = setup;
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
// node_modules/debug/src/browser.js
|
|
327
|
-
var require_browser = __commonJS({
|
|
328
|
-
"node_modules/debug/src/browser.js"(exports, module) {
|
|
329
|
-
exports.formatArgs = formatArgs;
|
|
330
|
-
exports.save = save;
|
|
331
|
-
exports.load = load2;
|
|
332
|
-
exports.useColors = useColors;
|
|
333
|
-
exports.storage = localstorage();
|
|
334
|
-
exports.destroy = /* @__PURE__ */ (() => {
|
|
335
|
-
let warned = false;
|
|
336
|
-
return () => {
|
|
337
|
-
if (!warned) {
|
|
338
|
-
warned = true;
|
|
339
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
})();
|
|
343
|
-
exports.colors = [
|
|
344
|
-
"#0000CC",
|
|
345
|
-
"#0000FF",
|
|
346
|
-
"#0033CC",
|
|
347
|
-
"#0033FF",
|
|
348
|
-
"#0066CC",
|
|
349
|
-
"#0066FF",
|
|
350
|
-
"#0099CC",
|
|
351
|
-
"#0099FF",
|
|
352
|
-
"#00CC00",
|
|
353
|
-
"#00CC33",
|
|
354
|
-
"#00CC66",
|
|
355
|
-
"#00CC99",
|
|
356
|
-
"#00CCCC",
|
|
357
|
-
"#00CCFF",
|
|
358
|
-
"#3300CC",
|
|
359
|
-
"#3300FF",
|
|
360
|
-
"#3333CC",
|
|
361
|
-
"#3333FF",
|
|
362
|
-
"#3366CC",
|
|
363
|
-
"#3366FF",
|
|
364
|
-
"#3399CC",
|
|
365
|
-
"#3399FF",
|
|
366
|
-
"#33CC00",
|
|
367
|
-
"#33CC33",
|
|
368
|
-
"#33CC66",
|
|
369
|
-
"#33CC99",
|
|
370
|
-
"#33CCCC",
|
|
371
|
-
"#33CCFF",
|
|
372
|
-
"#6600CC",
|
|
373
|
-
"#6600FF",
|
|
374
|
-
"#6633CC",
|
|
375
|
-
"#6633FF",
|
|
376
|
-
"#66CC00",
|
|
377
|
-
"#66CC33",
|
|
378
|
-
"#9900CC",
|
|
379
|
-
"#9900FF",
|
|
380
|
-
"#9933CC",
|
|
381
|
-
"#9933FF",
|
|
382
|
-
"#99CC00",
|
|
383
|
-
"#99CC33",
|
|
384
|
-
"#CC0000",
|
|
385
|
-
"#CC0033",
|
|
386
|
-
"#CC0066",
|
|
387
|
-
"#CC0099",
|
|
388
|
-
"#CC00CC",
|
|
389
|
-
"#CC00FF",
|
|
390
|
-
"#CC3300",
|
|
391
|
-
"#CC3333",
|
|
392
|
-
"#CC3366",
|
|
393
|
-
"#CC3399",
|
|
394
|
-
"#CC33CC",
|
|
395
|
-
"#CC33FF",
|
|
396
|
-
"#CC6600",
|
|
397
|
-
"#CC6633",
|
|
398
|
-
"#CC9900",
|
|
399
|
-
"#CC9933",
|
|
400
|
-
"#CCCC00",
|
|
401
|
-
"#CCCC33",
|
|
402
|
-
"#FF0000",
|
|
403
|
-
"#FF0033",
|
|
404
|
-
"#FF0066",
|
|
405
|
-
"#FF0099",
|
|
406
|
-
"#FF00CC",
|
|
407
|
-
"#FF00FF",
|
|
408
|
-
"#FF3300",
|
|
409
|
-
"#FF3333",
|
|
410
|
-
"#FF3366",
|
|
411
|
-
"#FF3399",
|
|
412
|
-
"#FF33CC",
|
|
413
|
-
"#FF33FF",
|
|
414
|
-
"#FF6600",
|
|
415
|
-
"#FF6633",
|
|
416
|
-
"#FF9900",
|
|
417
|
-
"#FF9933",
|
|
418
|
-
"#FFCC00",
|
|
419
|
-
"#FFCC33"
|
|
420
|
-
];
|
|
421
|
-
function useColors() {
|
|
422
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
423
|
-
return true;
|
|
424
|
-
}
|
|
425
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
428
|
-
let m;
|
|
429
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
430
|
-
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
431
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
432
|
-
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
433
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
434
|
-
}
|
|
435
|
-
function formatArgs(args) {
|
|
436
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
437
|
-
if (!this.useColors) {
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
const c = "color: " + this.color;
|
|
441
|
-
args.splice(1, 0, c, "color: inherit");
|
|
442
|
-
let index = 0;
|
|
443
|
-
let lastC = 0;
|
|
444
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
445
|
-
if (match === "%%") {
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
index++;
|
|
449
|
-
if (match === "%c") {
|
|
450
|
-
lastC = index;
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
args.splice(lastC, 0, c);
|
|
454
|
-
}
|
|
455
|
-
exports.log = console.debug || console.log || (() => {
|
|
456
|
-
});
|
|
457
|
-
function save(namespaces) {
|
|
458
|
-
try {
|
|
459
|
-
if (namespaces) {
|
|
460
|
-
exports.storage.setItem("debug", namespaces);
|
|
461
|
-
} else {
|
|
462
|
-
exports.storage.removeItem("debug");
|
|
463
|
-
}
|
|
464
|
-
} catch (error) {
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
function load2() {
|
|
468
|
-
let r;
|
|
469
|
-
try {
|
|
470
|
-
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
471
|
-
} catch (error) {
|
|
472
|
-
}
|
|
473
|
-
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
474
|
-
r = process.env.DEBUG;
|
|
475
|
-
}
|
|
476
|
-
return r;
|
|
477
|
-
}
|
|
478
|
-
function localstorage() {
|
|
479
|
-
try {
|
|
480
|
-
return localStorage;
|
|
481
|
-
} catch (error) {
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
module.exports = require_common()(exports);
|
|
485
|
-
var { formatters } = module.exports;
|
|
486
|
-
formatters.j = function(v) {
|
|
487
|
-
try {
|
|
488
|
-
return JSON.stringify(v);
|
|
489
|
-
} catch (error) {
|
|
490
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
// node_modules/debug/src/node.js
|
|
497
|
-
var require_node = __commonJS({
|
|
498
|
-
"node_modules/debug/src/node.js"(exports, module) {
|
|
499
|
-
var tty = __require("tty");
|
|
500
|
-
var util = __require("util");
|
|
501
|
-
exports.init = init;
|
|
502
|
-
exports.log = log2;
|
|
503
|
-
exports.formatArgs = formatArgs;
|
|
504
|
-
exports.save = save;
|
|
505
|
-
exports.load = load2;
|
|
506
|
-
exports.useColors = useColors;
|
|
507
|
-
exports.destroy = util.deprecate(
|
|
508
|
-
() => {
|
|
509
|
-
},
|
|
510
|
-
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
511
|
-
);
|
|
512
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
513
|
-
try {
|
|
514
|
-
const supportsColor = __require("supports-color");
|
|
515
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
516
|
-
exports.colors = [
|
|
517
|
-
20,
|
|
518
|
-
21,
|
|
519
|
-
26,
|
|
520
|
-
27,
|
|
521
|
-
32,
|
|
522
|
-
33,
|
|
523
|
-
38,
|
|
524
|
-
39,
|
|
525
|
-
40,
|
|
526
|
-
41,
|
|
527
|
-
42,
|
|
528
|
-
43,
|
|
529
|
-
44,
|
|
530
|
-
45,
|
|
531
|
-
56,
|
|
532
|
-
57,
|
|
533
|
-
62,
|
|
534
|
-
63,
|
|
535
|
-
68,
|
|
536
|
-
69,
|
|
537
|
-
74,
|
|
538
|
-
75,
|
|
539
|
-
76,
|
|
540
|
-
77,
|
|
541
|
-
78,
|
|
542
|
-
79,
|
|
543
|
-
80,
|
|
544
|
-
81,
|
|
545
|
-
92,
|
|
546
|
-
93,
|
|
547
|
-
98,
|
|
548
|
-
99,
|
|
549
|
-
112,
|
|
550
|
-
113,
|
|
551
|
-
128,
|
|
552
|
-
129,
|
|
553
|
-
134,
|
|
554
|
-
135,
|
|
555
|
-
148,
|
|
556
|
-
149,
|
|
557
|
-
160,
|
|
558
|
-
161,
|
|
559
|
-
162,
|
|
560
|
-
163,
|
|
561
|
-
164,
|
|
562
|
-
165,
|
|
563
|
-
166,
|
|
564
|
-
167,
|
|
565
|
-
168,
|
|
566
|
-
169,
|
|
567
|
-
170,
|
|
568
|
-
171,
|
|
569
|
-
172,
|
|
570
|
-
173,
|
|
571
|
-
178,
|
|
572
|
-
179,
|
|
573
|
-
184,
|
|
574
|
-
185,
|
|
575
|
-
196,
|
|
576
|
-
197,
|
|
577
|
-
198,
|
|
578
|
-
199,
|
|
579
|
-
200,
|
|
580
|
-
201,
|
|
581
|
-
202,
|
|
582
|
-
203,
|
|
583
|
-
204,
|
|
584
|
-
205,
|
|
585
|
-
206,
|
|
586
|
-
207,
|
|
587
|
-
208,
|
|
588
|
-
209,
|
|
589
|
-
214,
|
|
590
|
-
215,
|
|
591
|
-
220,
|
|
592
|
-
221
|
|
593
|
-
];
|
|
594
|
-
}
|
|
595
|
-
} catch (error) {
|
|
596
|
-
}
|
|
597
|
-
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
598
|
-
return /^debug_/i.test(key);
|
|
599
|
-
}).reduce((obj, key) => {
|
|
600
|
-
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
601
|
-
return k.toUpperCase();
|
|
602
|
-
});
|
|
603
|
-
let val = process.env[key];
|
|
604
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
605
|
-
val = true;
|
|
606
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
607
|
-
val = false;
|
|
608
|
-
} else if (val === "null") {
|
|
609
|
-
val = null;
|
|
610
|
-
} else {
|
|
611
|
-
val = Number(val);
|
|
612
|
-
}
|
|
613
|
-
obj[prop] = val;
|
|
614
|
-
return obj;
|
|
615
|
-
}, {});
|
|
616
|
-
function useColors() {
|
|
617
|
-
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
618
|
-
}
|
|
619
|
-
function formatArgs(args) {
|
|
620
|
-
const { namespace: name, useColors: useColors2 } = this;
|
|
621
|
-
if (useColors2) {
|
|
622
|
-
const c = this.color;
|
|
623
|
-
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
624
|
-
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
625
|
-
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
626
|
-
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
627
|
-
} else {
|
|
628
|
-
args[0] = getDate() + name + " " + args[0];
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
function getDate() {
|
|
632
|
-
if (exports.inspectOpts.hideDate) {
|
|
633
|
-
return "";
|
|
634
|
-
}
|
|
635
|
-
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
636
|
-
}
|
|
637
|
-
function log2(...args) {
|
|
638
|
-
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
|
|
639
|
-
}
|
|
640
|
-
function save(namespaces) {
|
|
641
|
-
if (namespaces) {
|
|
642
|
-
process.env.DEBUG = namespaces;
|
|
643
|
-
} else {
|
|
644
|
-
delete process.env.DEBUG;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
function load2() {
|
|
648
|
-
return process.env.DEBUG;
|
|
649
|
-
}
|
|
650
|
-
function init(debug) {
|
|
651
|
-
debug.inspectOpts = {};
|
|
652
|
-
const keys = Object.keys(exports.inspectOpts);
|
|
653
|
-
for (let i = 0; i < keys.length; i++) {
|
|
654
|
-
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
module.exports = require_common()(exports);
|
|
658
|
-
var { formatters } = module.exports;
|
|
659
|
-
formatters.o = function(v) {
|
|
660
|
-
this.inspectOpts.colors = this.useColors;
|
|
661
|
-
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
662
|
-
};
|
|
663
|
-
formatters.O = function(v) {
|
|
664
|
-
this.inspectOpts.colors = this.useColors;
|
|
665
|
-
return util.inspect(v, this.inspectOpts);
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
// node_modules/debug/src/index.js
|
|
671
|
-
var require_src = __commonJS({
|
|
672
|
-
"node_modules/debug/src/index.js"(exports, module) {
|
|
673
|
-
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
674
|
-
module.exports = require_browser();
|
|
675
|
-
} else {
|
|
676
|
-
module.exports = require_node();
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
// node_modules/wrappy/wrappy.js
|
|
682
|
-
var require_wrappy = __commonJS({
|
|
683
|
-
"node_modules/wrappy/wrappy.js"(exports, module) {
|
|
684
|
-
module.exports = wrappy;
|
|
685
|
-
function wrappy(fn, cb) {
|
|
686
|
-
if (fn && cb) return wrappy(fn)(cb);
|
|
687
|
-
if (typeof fn !== "function")
|
|
688
|
-
throw new TypeError("need wrapper function");
|
|
689
|
-
Object.keys(fn).forEach(function(k) {
|
|
690
|
-
wrapper[k] = fn[k];
|
|
691
|
-
});
|
|
692
|
-
return wrapper;
|
|
693
|
-
function wrapper() {
|
|
694
|
-
var args = new Array(arguments.length);
|
|
695
|
-
for (var i = 0; i < args.length; i++) {
|
|
696
|
-
args[i] = arguments[i];
|
|
697
|
-
}
|
|
698
|
-
var ret = fn.apply(this, args);
|
|
699
|
-
var cb2 = args[args.length - 1];
|
|
700
|
-
if (typeof ret === "function" && ret !== cb2) {
|
|
701
|
-
Object.keys(cb2).forEach(function(k) {
|
|
702
|
-
ret[k] = cb2[k];
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
return ret;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
// node_modules/once/once.js
|
|
712
|
-
var require_once = __commonJS({
|
|
713
|
-
"node_modules/once/once.js"(exports, module) {
|
|
714
|
-
var wrappy = require_wrappy();
|
|
715
|
-
module.exports = wrappy(once);
|
|
716
|
-
module.exports.strict = wrappy(onceStrict);
|
|
717
|
-
once.proto = once(function() {
|
|
718
|
-
Object.defineProperty(Function.prototype, "once", {
|
|
719
|
-
value: function() {
|
|
720
|
-
return once(this);
|
|
721
|
-
},
|
|
722
|
-
configurable: true
|
|
723
|
-
});
|
|
724
|
-
Object.defineProperty(Function.prototype, "onceStrict", {
|
|
725
|
-
value: function() {
|
|
726
|
-
return onceStrict(this);
|
|
727
|
-
},
|
|
728
|
-
configurable: true
|
|
729
|
-
});
|
|
730
|
-
});
|
|
731
|
-
function once(fn) {
|
|
732
|
-
var f = function() {
|
|
733
|
-
if (f.called) return f.value;
|
|
734
|
-
f.called = true;
|
|
735
|
-
return f.value = fn.apply(this, arguments);
|
|
736
|
-
};
|
|
737
|
-
f.called = false;
|
|
738
|
-
return f;
|
|
739
|
-
}
|
|
740
|
-
function onceStrict(fn) {
|
|
741
|
-
var f = function() {
|
|
742
|
-
if (f.called)
|
|
743
|
-
throw new Error(f.onceError);
|
|
744
|
-
f.called = true;
|
|
745
|
-
return f.value = fn.apply(this, arguments);
|
|
746
|
-
};
|
|
747
|
-
var name = fn.name || "Function wrapped with `once`";
|
|
748
|
-
f.onceError = name + " shouldn't be called more than once";
|
|
749
|
-
f.called = false;
|
|
750
|
-
return f;
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
// node_modules/end-of-stream/index.js
|
|
756
|
-
var require_end_of_stream = __commonJS({
|
|
757
|
-
"node_modules/end-of-stream/index.js"(exports, module) {
|
|
758
|
-
var once = require_once();
|
|
759
|
-
var noop = function() {
|
|
760
|
-
};
|
|
761
|
-
var qnt = global.Bare ? queueMicrotask : process.nextTick.bind(process);
|
|
762
|
-
var isRequest = function(stream) {
|
|
763
|
-
return stream.setHeader && typeof stream.abort === "function";
|
|
764
|
-
};
|
|
765
|
-
var isChildProcess = function(stream) {
|
|
766
|
-
return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3;
|
|
767
|
-
};
|
|
768
|
-
var eos = function(stream, opts, callback) {
|
|
769
|
-
if (typeof opts === "function") return eos(stream, null, opts);
|
|
770
|
-
if (!opts) opts = {};
|
|
771
|
-
callback = once(callback || noop);
|
|
772
|
-
var ws = stream._writableState;
|
|
773
|
-
var rs = stream._readableState;
|
|
774
|
-
var readable = opts.readable || opts.readable !== false && stream.readable;
|
|
775
|
-
var writable = opts.writable || opts.writable !== false && stream.writable;
|
|
776
|
-
var cancelled = false;
|
|
777
|
-
var onlegacyfinish = function() {
|
|
778
|
-
if (!stream.writable) onfinish();
|
|
779
|
-
};
|
|
780
|
-
var onfinish = function() {
|
|
781
|
-
writable = false;
|
|
782
|
-
if (!readable) callback.call(stream);
|
|
783
|
-
};
|
|
784
|
-
var onend = function() {
|
|
785
|
-
readable = false;
|
|
786
|
-
if (!writable) callback.call(stream);
|
|
787
|
-
};
|
|
788
|
-
var onexit = function(exitCode) {
|
|
789
|
-
callback.call(stream, exitCode ? new Error("exited with error code: " + exitCode) : null);
|
|
790
|
-
};
|
|
791
|
-
var onerror = function(err) {
|
|
792
|
-
callback.call(stream, err);
|
|
793
|
-
};
|
|
794
|
-
var onclose = function() {
|
|
795
|
-
qnt(onclosenexttick);
|
|
796
|
-
};
|
|
797
|
-
var onclosenexttick = function() {
|
|
798
|
-
if (cancelled) return;
|
|
799
|
-
if (readable && !(rs && (rs.ended && !rs.destroyed))) return callback.call(stream, new Error("premature close"));
|
|
800
|
-
if (writable && !(ws && (ws.ended && !ws.destroyed))) return callback.call(stream, new Error("premature close"));
|
|
801
|
-
};
|
|
802
|
-
var onrequest = function() {
|
|
803
|
-
stream.req.on("finish", onfinish);
|
|
804
|
-
};
|
|
805
|
-
if (isRequest(stream)) {
|
|
806
|
-
stream.on("complete", onfinish);
|
|
807
|
-
stream.on("abort", onclose);
|
|
808
|
-
if (stream.req) onrequest();
|
|
809
|
-
else stream.on("request", onrequest);
|
|
810
|
-
} else if (writable && !ws) {
|
|
811
|
-
stream.on("end", onlegacyfinish);
|
|
812
|
-
stream.on("close", onlegacyfinish);
|
|
813
|
-
}
|
|
814
|
-
if (isChildProcess(stream)) stream.on("exit", onexit);
|
|
815
|
-
stream.on("end", onend);
|
|
816
|
-
stream.on("finish", onfinish);
|
|
817
|
-
if (opts.error !== false) stream.on("error", onerror);
|
|
818
|
-
stream.on("close", onclose);
|
|
819
|
-
return function() {
|
|
820
|
-
cancelled = true;
|
|
821
|
-
stream.removeListener("complete", onfinish);
|
|
822
|
-
stream.removeListener("abort", onclose);
|
|
823
|
-
stream.removeListener("request", onrequest);
|
|
824
|
-
if (stream.req) stream.req.removeListener("finish", onfinish);
|
|
825
|
-
stream.removeListener("end", onlegacyfinish);
|
|
826
|
-
stream.removeListener("close", onlegacyfinish);
|
|
827
|
-
stream.removeListener("finish", onfinish);
|
|
828
|
-
stream.removeListener("exit", onexit);
|
|
829
|
-
stream.removeListener("end", onend);
|
|
830
|
-
stream.removeListener("error", onerror);
|
|
831
|
-
stream.removeListener("close", onclose);
|
|
832
|
-
};
|
|
833
|
-
};
|
|
834
|
-
module.exports = eos;
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
// node_modules/pump/index.js
|
|
839
|
-
var require_pump = __commonJS({
|
|
840
|
-
"node_modules/pump/index.js"(exports, module) {
|
|
841
|
-
var once = require_once();
|
|
842
|
-
var eos = require_end_of_stream();
|
|
843
|
-
var fs;
|
|
844
|
-
try {
|
|
845
|
-
fs = __require("fs");
|
|
846
|
-
} catch (e) {
|
|
847
|
-
}
|
|
848
|
-
var noop = function() {
|
|
849
|
-
};
|
|
850
|
-
var ancient = typeof process === "undefined" ? false : /^v?\.0/.test(process.version);
|
|
851
|
-
var isFn = function(fn) {
|
|
852
|
-
return typeof fn === "function";
|
|
853
|
-
};
|
|
854
|
-
var isFS = function(stream) {
|
|
855
|
-
if (!ancient) return false;
|
|
856
|
-
if (!fs) return false;
|
|
857
|
-
return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close);
|
|
858
|
-
};
|
|
859
|
-
var isRequest = function(stream) {
|
|
860
|
-
return stream.setHeader && isFn(stream.abort);
|
|
861
|
-
};
|
|
862
|
-
var destroyer = function(stream, reading, writing, callback) {
|
|
863
|
-
callback = once(callback);
|
|
864
|
-
var closed = false;
|
|
865
|
-
stream.on("close", function() {
|
|
866
|
-
closed = true;
|
|
867
|
-
});
|
|
868
|
-
eos(stream, { readable: reading, writable: writing }, function(err) {
|
|
869
|
-
if (err) return callback(err);
|
|
870
|
-
closed = true;
|
|
871
|
-
callback();
|
|
872
|
-
});
|
|
873
|
-
var destroyed = false;
|
|
874
|
-
return function(err) {
|
|
875
|
-
if (closed) return;
|
|
876
|
-
if (destroyed) return;
|
|
877
|
-
destroyed = true;
|
|
878
|
-
if (isFS(stream)) return stream.close(noop);
|
|
879
|
-
if (isRequest(stream)) return stream.abort();
|
|
880
|
-
if (isFn(stream.destroy)) return stream.destroy();
|
|
881
|
-
callback(err || new Error("stream was destroyed"));
|
|
882
|
-
};
|
|
883
|
-
};
|
|
884
|
-
var call = function(fn) {
|
|
885
|
-
fn();
|
|
886
|
-
};
|
|
887
|
-
var pipe = function(from, to) {
|
|
888
|
-
return from.pipe(to);
|
|
889
|
-
};
|
|
890
|
-
var pump = function() {
|
|
891
|
-
var streams = Array.prototype.slice.call(arguments);
|
|
892
|
-
var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop;
|
|
893
|
-
if (Array.isArray(streams[0])) streams = streams[0];
|
|
894
|
-
if (streams.length < 2) throw new Error("pump requires two streams per minimum");
|
|
895
|
-
var error;
|
|
896
|
-
var destroys = streams.map(function(stream, i) {
|
|
897
|
-
var reading = i < streams.length - 1;
|
|
898
|
-
var writing = i > 0;
|
|
899
|
-
return destroyer(stream, reading, writing, function(err) {
|
|
900
|
-
if (!error) error = err;
|
|
901
|
-
if (err) destroys.forEach(call);
|
|
902
|
-
if (reading) return;
|
|
903
|
-
destroys.forEach(call);
|
|
904
|
-
callback(error);
|
|
905
|
-
});
|
|
906
|
-
});
|
|
907
|
-
return streams.reduce(pipe);
|
|
908
|
-
};
|
|
909
|
-
module.exports = pump;
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
// node_modules/get-stream/buffer-stream.js
|
|
914
|
-
var require_buffer_stream = __commonJS({
|
|
915
|
-
"node_modules/get-stream/buffer-stream.js"(exports, module) {
|
|
916
|
-
"use strict";
|
|
917
|
-
var { PassThrough: PassThroughStream } = __require("stream");
|
|
918
|
-
module.exports = (options) => {
|
|
919
|
-
options = { ...options };
|
|
920
|
-
const { array } = options;
|
|
921
|
-
let { encoding } = options;
|
|
922
|
-
const isBuffer = encoding === "buffer";
|
|
923
|
-
let objectMode = false;
|
|
924
|
-
if (array) {
|
|
925
|
-
objectMode = !(encoding || isBuffer);
|
|
926
|
-
} else {
|
|
927
|
-
encoding = encoding || "utf8";
|
|
928
|
-
}
|
|
929
|
-
if (isBuffer) {
|
|
930
|
-
encoding = null;
|
|
931
|
-
}
|
|
932
|
-
const stream = new PassThroughStream({ objectMode });
|
|
933
|
-
if (encoding) {
|
|
934
|
-
stream.setEncoding(encoding);
|
|
935
|
-
}
|
|
936
|
-
let length = 0;
|
|
937
|
-
const chunks = [];
|
|
938
|
-
stream.on("data", (chunk) => {
|
|
939
|
-
chunks.push(chunk);
|
|
940
|
-
if (objectMode) {
|
|
941
|
-
length = chunks.length;
|
|
942
|
-
} else {
|
|
943
|
-
length += chunk.length;
|
|
944
|
-
}
|
|
945
|
-
});
|
|
946
|
-
stream.getBufferedValue = () => {
|
|
947
|
-
if (array) {
|
|
948
|
-
return chunks;
|
|
949
|
-
}
|
|
950
|
-
return isBuffer ? Buffer.concat(chunks, length) : chunks.join("");
|
|
951
|
-
};
|
|
952
|
-
stream.getBufferedLength = () => length;
|
|
953
|
-
return stream;
|
|
954
|
-
};
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
|
|
958
|
-
// node_modules/get-stream/index.js
|
|
959
|
-
var require_get_stream = __commonJS({
|
|
960
|
-
"node_modules/get-stream/index.js"(exports, module) {
|
|
961
|
-
"use strict";
|
|
962
|
-
var { constants: BufferConstants } = __require("buffer");
|
|
963
|
-
var pump = require_pump();
|
|
964
|
-
var bufferStream = require_buffer_stream();
|
|
965
|
-
var MaxBufferError = class extends Error {
|
|
966
|
-
constructor() {
|
|
967
|
-
super("maxBuffer exceeded");
|
|
968
|
-
this.name = "MaxBufferError";
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
async function getStream(inputStream, options) {
|
|
972
|
-
if (!inputStream) {
|
|
973
|
-
return Promise.reject(new Error("Expected a stream"));
|
|
974
|
-
}
|
|
975
|
-
options = {
|
|
976
|
-
maxBuffer: Infinity,
|
|
977
|
-
...options
|
|
978
|
-
};
|
|
979
|
-
const { maxBuffer } = options;
|
|
980
|
-
let stream;
|
|
981
|
-
await new Promise((resolve3, reject) => {
|
|
982
|
-
const rejectPromise = (error) => {
|
|
983
|
-
if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
|
|
984
|
-
error.bufferedData = stream.getBufferedValue();
|
|
985
|
-
}
|
|
986
|
-
reject(error);
|
|
987
|
-
};
|
|
988
|
-
stream = pump(inputStream, bufferStream(options), (error) => {
|
|
989
|
-
if (error) {
|
|
990
|
-
rejectPromise(error);
|
|
991
|
-
return;
|
|
992
|
-
}
|
|
993
|
-
resolve3();
|
|
994
|
-
});
|
|
995
|
-
stream.on("data", () => {
|
|
996
|
-
if (stream.getBufferedLength() > maxBuffer) {
|
|
997
|
-
rejectPromise(new MaxBufferError());
|
|
998
|
-
}
|
|
999
|
-
});
|
|
1000
|
-
});
|
|
1001
|
-
return stream.getBufferedValue();
|
|
1002
|
-
}
|
|
1003
|
-
module.exports = getStream;
|
|
1004
|
-
module.exports.default = getStream;
|
|
1005
|
-
module.exports.buffer = (stream, options) => getStream(stream, { ...options, encoding: "buffer" });
|
|
1006
|
-
module.exports.array = (stream, options) => getStream(stream, { ...options, array: true });
|
|
1007
|
-
module.exports.MaxBufferError = MaxBufferError;
|
|
1008
|
-
}
|
|
1009
|
-
});
|
|
1010
|
-
|
|
1011
|
-
// node_modules/pend/index.js
|
|
1012
|
-
var require_pend = __commonJS({
|
|
1013
|
-
"node_modules/pend/index.js"(exports, module) {
|
|
1014
|
-
module.exports = Pend;
|
|
1015
|
-
function Pend() {
|
|
1016
|
-
this.pending = 0;
|
|
1017
|
-
this.max = Infinity;
|
|
1018
|
-
this.listeners = [];
|
|
1019
|
-
this.waiting = [];
|
|
1020
|
-
this.error = null;
|
|
1021
|
-
}
|
|
1022
|
-
Pend.prototype.go = function(fn) {
|
|
1023
|
-
if (this.pending < this.max) {
|
|
1024
|
-
pendGo(this, fn);
|
|
1025
|
-
} else {
|
|
1026
|
-
this.waiting.push(fn);
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
Pend.prototype.wait = function(cb) {
|
|
1030
|
-
if (this.pending === 0) {
|
|
1031
|
-
cb(this.error);
|
|
1032
|
-
} else {
|
|
1033
|
-
this.listeners.push(cb);
|
|
1034
|
-
}
|
|
1035
|
-
};
|
|
1036
|
-
Pend.prototype.hold = function() {
|
|
1037
|
-
return pendHold(this);
|
|
1038
|
-
};
|
|
1039
|
-
function pendHold(self) {
|
|
1040
|
-
self.pending += 1;
|
|
1041
|
-
var called = false;
|
|
1042
|
-
return onCb;
|
|
1043
|
-
function onCb(err) {
|
|
1044
|
-
if (called) throw new Error("callback called twice");
|
|
1045
|
-
called = true;
|
|
1046
|
-
self.error = self.error || err;
|
|
1047
|
-
self.pending -= 1;
|
|
1048
|
-
if (self.waiting.length > 0 && self.pending < self.max) {
|
|
1049
|
-
pendGo(self, self.waiting.shift());
|
|
1050
|
-
} else if (self.pending === 0) {
|
|
1051
|
-
var listeners = self.listeners;
|
|
1052
|
-
self.listeners = [];
|
|
1053
|
-
listeners.forEach(cbListener);
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
function cbListener(listener) {
|
|
1057
|
-
listener(self.error);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
function pendGo(self, fn) {
|
|
1061
|
-
fn(pendHold(self));
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
});
|
|
1065
|
-
|
|
1066
|
-
// node_modules/fd-slicer/index.js
|
|
1067
|
-
var require_fd_slicer = __commonJS({
|
|
1068
|
-
"node_modules/fd-slicer/index.js"(exports) {
|
|
1069
|
-
var fs = __require("fs");
|
|
1070
|
-
var util = __require("util");
|
|
1071
|
-
var stream = __require("stream");
|
|
1072
|
-
var Readable = stream.Readable;
|
|
1073
|
-
var Writable = stream.Writable;
|
|
1074
|
-
var PassThrough = stream.PassThrough;
|
|
1075
|
-
var Pend = require_pend();
|
|
1076
|
-
var EventEmitter = __require("events").EventEmitter;
|
|
1077
|
-
exports.createFromBuffer = createFromBuffer;
|
|
1078
|
-
exports.createFromFd = createFromFd;
|
|
1079
|
-
exports.BufferSlicer = BufferSlicer;
|
|
1080
|
-
exports.FdSlicer = FdSlicer;
|
|
1081
|
-
util.inherits(FdSlicer, EventEmitter);
|
|
1082
|
-
function FdSlicer(fd, options) {
|
|
1083
|
-
options = options || {};
|
|
1084
|
-
EventEmitter.call(this);
|
|
1085
|
-
this.fd = fd;
|
|
1086
|
-
this.pend = new Pend();
|
|
1087
|
-
this.pend.max = 1;
|
|
1088
|
-
this.refCount = 0;
|
|
1089
|
-
this.autoClose = !!options.autoClose;
|
|
1090
|
-
}
|
|
1091
|
-
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
1092
|
-
var self = this;
|
|
1093
|
-
self.pend.go(function(cb) {
|
|
1094
|
-
fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
|
|
1095
|
-
cb();
|
|
1096
|
-
callback(err, bytesRead, buffer2);
|
|
1097
|
-
});
|
|
1098
|
-
});
|
|
1099
|
-
};
|
|
1100
|
-
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
1101
|
-
var self = this;
|
|
1102
|
-
self.pend.go(function(cb) {
|
|
1103
|
-
fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer2) {
|
|
1104
|
-
cb();
|
|
1105
|
-
callback(err, written, buffer2);
|
|
1106
|
-
});
|
|
1107
|
-
});
|
|
1108
|
-
};
|
|
1109
|
-
FdSlicer.prototype.createReadStream = function(options) {
|
|
1110
|
-
return new ReadStream(this, options);
|
|
1111
|
-
};
|
|
1112
|
-
FdSlicer.prototype.createWriteStream = function(options) {
|
|
1113
|
-
return new WriteStream(this, options);
|
|
1114
|
-
};
|
|
1115
|
-
FdSlicer.prototype.ref = function() {
|
|
1116
|
-
this.refCount += 1;
|
|
1117
|
-
};
|
|
1118
|
-
FdSlicer.prototype.unref = function() {
|
|
1119
|
-
var self = this;
|
|
1120
|
-
self.refCount -= 1;
|
|
1121
|
-
if (self.refCount > 0) return;
|
|
1122
|
-
if (self.refCount < 0) throw new Error("invalid unref");
|
|
1123
|
-
if (self.autoClose) {
|
|
1124
|
-
fs.close(self.fd, onCloseDone);
|
|
1125
|
-
}
|
|
1126
|
-
function onCloseDone(err) {
|
|
1127
|
-
if (err) {
|
|
1128
|
-
self.emit("error", err);
|
|
1129
|
-
} else {
|
|
1130
|
-
self.emit("close");
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
};
|
|
1134
|
-
util.inherits(ReadStream, Readable);
|
|
1135
|
-
function ReadStream(context, options) {
|
|
1136
|
-
options = options || {};
|
|
1137
|
-
Readable.call(this, options);
|
|
1138
|
-
this.context = context;
|
|
1139
|
-
this.context.ref();
|
|
1140
|
-
this.start = options.start || 0;
|
|
1141
|
-
this.endOffset = options.end;
|
|
1142
|
-
this.pos = this.start;
|
|
1143
|
-
this.destroyed = false;
|
|
1144
|
-
}
|
|
1145
|
-
ReadStream.prototype._read = function(n) {
|
|
1146
|
-
var self = this;
|
|
1147
|
-
if (self.destroyed) return;
|
|
1148
|
-
var toRead = Math.min(self._readableState.highWaterMark, n);
|
|
1149
|
-
if (self.endOffset != null) {
|
|
1150
|
-
toRead = Math.min(toRead, self.endOffset - self.pos);
|
|
1151
|
-
}
|
|
1152
|
-
if (toRead <= 0) {
|
|
1153
|
-
self.destroyed = true;
|
|
1154
|
-
self.push(null);
|
|
1155
|
-
self.context.unref();
|
|
1156
|
-
return;
|
|
1157
|
-
}
|
|
1158
|
-
self.context.pend.go(function(cb) {
|
|
1159
|
-
if (self.destroyed) return cb();
|
|
1160
|
-
var buffer = new Buffer(toRead);
|
|
1161
|
-
fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
1162
|
-
if (err) {
|
|
1163
|
-
self.destroy(err);
|
|
1164
|
-
} else if (bytesRead === 0) {
|
|
1165
|
-
self.destroyed = true;
|
|
1166
|
-
self.push(null);
|
|
1167
|
-
self.context.unref();
|
|
1168
|
-
} else {
|
|
1169
|
-
self.pos += bytesRead;
|
|
1170
|
-
self.push(buffer.slice(0, bytesRead));
|
|
1171
|
-
}
|
|
1172
|
-
cb();
|
|
1173
|
-
});
|
|
1174
|
-
});
|
|
1175
|
-
};
|
|
1176
|
-
ReadStream.prototype.destroy = function(err) {
|
|
1177
|
-
if (this.destroyed) return;
|
|
1178
|
-
err = err || new Error("stream destroyed");
|
|
1179
|
-
this.destroyed = true;
|
|
1180
|
-
this.emit("error", err);
|
|
1181
|
-
this.context.unref();
|
|
1182
|
-
};
|
|
1183
|
-
util.inherits(WriteStream, Writable);
|
|
1184
|
-
function WriteStream(context, options) {
|
|
1185
|
-
options = options || {};
|
|
1186
|
-
Writable.call(this, options);
|
|
1187
|
-
this.context = context;
|
|
1188
|
-
this.context.ref();
|
|
1189
|
-
this.start = options.start || 0;
|
|
1190
|
-
this.endOffset = options.end == null ? Infinity : +options.end;
|
|
1191
|
-
this.bytesWritten = 0;
|
|
1192
|
-
this.pos = this.start;
|
|
1193
|
-
this.destroyed = false;
|
|
1194
|
-
this.on("finish", this.destroy.bind(this));
|
|
1195
|
-
}
|
|
1196
|
-
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
|
1197
|
-
var self = this;
|
|
1198
|
-
if (self.destroyed) return;
|
|
1199
|
-
if (self.pos + buffer.length > self.endOffset) {
|
|
1200
|
-
var err = new Error("maximum file length exceeded");
|
|
1201
|
-
err.code = "ETOOBIG";
|
|
1202
|
-
self.destroy();
|
|
1203
|
-
callback(err);
|
|
1204
|
-
return;
|
|
1205
|
-
}
|
|
1206
|
-
self.context.pend.go(function(cb) {
|
|
1207
|
-
if (self.destroyed) return cb();
|
|
1208
|
-
fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err2, bytes) {
|
|
1209
|
-
if (err2) {
|
|
1210
|
-
self.destroy();
|
|
1211
|
-
cb();
|
|
1212
|
-
callback(err2);
|
|
1213
|
-
} else {
|
|
1214
|
-
self.bytesWritten += bytes;
|
|
1215
|
-
self.pos += bytes;
|
|
1216
|
-
self.emit("progress");
|
|
1217
|
-
cb();
|
|
1218
|
-
callback();
|
|
1219
|
-
}
|
|
1220
|
-
});
|
|
1221
|
-
});
|
|
1222
|
-
};
|
|
1223
|
-
WriteStream.prototype.destroy = function() {
|
|
1224
|
-
if (this.destroyed) return;
|
|
1225
|
-
this.destroyed = true;
|
|
1226
|
-
this.context.unref();
|
|
1227
|
-
};
|
|
1228
|
-
util.inherits(BufferSlicer, EventEmitter);
|
|
1229
|
-
function BufferSlicer(buffer, options) {
|
|
1230
|
-
EventEmitter.call(this);
|
|
1231
|
-
options = options || {};
|
|
1232
|
-
this.refCount = 0;
|
|
1233
|
-
this.buffer = buffer;
|
|
1234
|
-
this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
|
1235
|
-
}
|
|
1236
|
-
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
1237
|
-
var end = position + length;
|
|
1238
|
-
var delta = end - this.buffer.length;
|
|
1239
|
-
var written = delta > 0 ? delta : length;
|
|
1240
|
-
this.buffer.copy(buffer, offset, position, end);
|
|
1241
|
-
setImmediate(function() {
|
|
1242
|
-
callback(null, written);
|
|
1243
|
-
});
|
|
1244
|
-
};
|
|
1245
|
-
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
1246
|
-
buffer.copy(this.buffer, position, offset, offset + length);
|
|
1247
|
-
setImmediate(function() {
|
|
1248
|
-
callback(null, length, buffer);
|
|
1249
|
-
});
|
|
1250
|
-
};
|
|
1251
|
-
BufferSlicer.prototype.createReadStream = function(options) {
|
|
1252
|
-
options = options || {};
|
|
1253
|
-
var readStream = new PassThrough(options);
|
|
1254
|
-
readStream.destroyed = false;
|
|
1255
|
-
readStream.start = options.start || 0;
|
|
1256
|
-
readStream.endOffset = options.end;
|
|
1257
|
-
readStream.pos = readStream.endOffset || this.buffer.length;
|
|
1258
|
-
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
|
1259
|
-
var offset = 0;
|
|
1260
|
-
while (true) {
|
|
1261
|
-
var nextOffset = offset + this.maxChunkSize;
|
|
1262
|
-
if (nextOffset >= entireSlice.length) {
|
|
1263
|
-
if (offset < entireSlice.length) {
|
|
1264
|
-
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
|
1265
|
-
}
|
|
1266
|
-
break;
|
|
1267
|
-
}
|
|
1268
|
-
readStream.write(entireSlice.slice(offset, nextOffset));
|
|
1269
|
-
offset = nextOffset;
|
|
1270
|
-
}
|
|
1271
|
-
readStream.end();
|
|
1272
|
-
readStream.destroy = function() {
|
|
1273
|
-
readStream.destroyed = true;
|
|
1274
|
-
};
|
|
1275
|
-
return readStream;
|
|
1276
|
-
};
|
|
1277
|
-
BufferSlicer.prototype.createWriteStream = function(options) {
|
|
1278
|
-
var bufferSlicer = this;
|
|
1279
|
-
options = options || {};
|
|
1280
|
-
var writeStream = new Writable(options);
|
|
1281
|
-
writeStream.start = options.start || 0;
|
|
1282
|
-
writeStream.endOffset = options.end == null ? this.buffer.length : +options.end;
|
|
1283
|
-
writeStream.bytesWritten = 0;
|
|
1284
|
-
writeStream.pos = writeStream.start;
|
|
1285
|
-
writeStream.destroyed = false;
|
|
1286
|
-
writeStream._write = function(buffer, encoding, callback) {
|
|
1287
|
-
if (writeStream.destroyed) return;
|
|
1288
|
-
var end = writeStream.pos + buffer.length;
|
|
1289
|
-
if (end > writeStream.endOffset) {
|
|
1290
|
-
var err = new Error("maximum file length exceeded");
|
|
1291
|
-
err.code = "ETOOBIG";
|
|
1292
|
-
writeStream.destroyed = true;
|
|
1293
|
-
callback(err);
|
|
1294
|
-
return;
|
|
1295
|
-
}
|
|
1296
|
-
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
|
1297
|
-
writeStream.bytesWritten += buffer.length;
|
|
1298
|
-
writeStream.pos = end;
|
|
1299
|
-
writeStream.emit("progress");
|
|
1300
|
-
callback();
|
|
1301
|
-
};
|
|
1302
|
-
writeStream.destroy = function() {
|
|
1303
|
-
writeStream.destroyed = true;
|
|
1304
|
-
};
|
|
1305
|
-
return writeStream;
|
|
1306
|
-
};
|
|
1307
|
-
BufferSlicer.prototype.ref = function() {
|
|
1308
|
-
this.refCount += 1;
|
|
1309
|
-
};
|
|
1310
|
-
BufferSlicer.prototype.unref = function() {
|
|
1311
|
-
this.refCount -= 1;
|
|
1312
|
-
if (this.refCount < 0) {
|
|
1313
|
-
throw new Error("invalid unref");
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
function createFromBuffer(buffer, options) {
|
|
1317
|
-
return new BufferSlicer(buffer, options);
|
|
1318
|
-
}
|
|
1319
|
-
function createFromFd(fd, options) {
|
|
1320
|
-
return new FdSlicer(fd, options);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
});
|
|
1324
|
-
|
|
1325
|
-
// node_modules/buffer-crc32/index.js
|
|
1326
|
-
var require_buffer_crc32 = __commonJS({
|
|
1327
|
-
"node_modules/buffer-crc32/index.js"(exports, module) {
|
|
1328
|
-
var Buffer2 = __require("buffer").Buffer;
|
|
1329
|
-
var CRC_TABLE = [
|
|
1330
|
-
0,
|
|
1331
|
-
1996959894,
|
|
1332
|
-
3993919788,
|
|
1333
|
-
2567524794,
|
|
1334
|
-
124634137,
|
|
1335
|
-
1886057615,
|
|
1336
|
-
3915621685,
|
|
1337
|
-
2657392035,
|
|
1338
|
-
249268274,
|
|
1339
|
-
2044508324,
|
|
1340
|
-
3772115230,
|
|
1341
|
-
2547177864,
|
|
1342
|
-
162941995,
|
|
1343
|
-
2125561021,
|
|
1344
|
-
3887607047,
|
|
1345
|
-
2428444049,
|
|
1346
|
-
498536548,
|
|
1347
|
-
1789927666,
|
|
1348
|
-
4089016648,
|
|
1349
|
-
2227061214,
|
|
1350
|
-
450548861,
|
|
1351
|
-
1843258603,
|
|
1352
|
-
4107580753,
|
|
1353
|
-
2211677639,
|
|
1354
|
-
325883990,
|
|
1355
|
-
1684777152,
|
|
1356
|
-
4251122042,
|
|
1357
|
-
2321926636,
|
|
1358
|
-
335633487,
|
|
1359
|
-
1661365465,
|
|
1360
|
-
4195302755,
|
|
1361
|
-
2366115317,
|
|
1362
|
-
997073096,
|
|
1363
|
-
1281953886,
|
|
1364
|
-
3579855332,
|
|
1365
|
-
2724688242,
|
|
1366
|
-
1006888145,
|
|
1367
|
-
1258607687,
|
|
1368
|
-
3524101629,
|
|
1369
|
-
2768942443,
|
|
1370
|
-
901097722,
|
|
1371
|
-
1119000684,
|
|
1372
|
-
3686517206,
|
|
1373
|
-
2898065728,
|
|
1374
|
-
853044451,
|
|
1375
|
-
1172266101,
|
|
1376
|
-
3705015759,
|
|
1377
|
-
2882616665,
|
|
1378
|
-
651767980,
|
|
1379
|
-
1373503546,
|
|
1380
|
-
3369554304,
|
|
1381
|
-
3218104598,
|
|
1382
|
-
565507253,
|
|
1383
|
-
1454621731,
|
|
1384
|
-
3485111705,
|
|
1385
|
-
3099436303,
|
|
1386
|
-
671266974,
|
|
1387
|
-
1594198024,
|
|
1388
|
-
3322730930,
|
|
1389
|
-
2970347812,
|
|
1390
|
-
795835527,
|
|
1391
|
-
1483230225,
|
|
1392
|
-
3244367275,
|
|
1393
|
-
3060149565,
|
|
1394
|
-
1994146192,
|
|
1395
|
-
31158534,
|
|
1396
|
-
2563907772,
|
|
1397
|
-
4023717930,
|
|
1398
|
-
1907459465,
|
|
1399
|
-
112637215,
|
|
1400
|
-
2680153253,
|
|
1401
|
-
3904427059,
|
|
1402
|
-
2013776290,
|
|
1403
|
-
251722036,
|
|
1404
|
-
2517215374,
|
|
1405
|
-
3775830040,
|
|
1406
|
-
2137656763,
|
|
1407
|
-
141376813,
|
|
1408
|
-
2439277719,
|
|
1409
|
-
3865271297,
|
|
1410
|
-
1802195444,
|
|
1411
|
-
476864866,
|
|
1412
|
-
2238001368,
|
|
1413
|
-
4066508878,
|
|
1414
|
-
1812370925,
|
|
1415
|
-
453092731,
|
|
1416
|
-
2181625025,
|
|
1417
|
-
4111451223,
|
|
1418
|
-
1706088902,
|
|
1419
|
-
314042704,
|
|
1420
|
-
2344532202,
|
|
1421
|
-
4240017532,
|
|
1422
|
-
1658658271,
|
|
1423
|
-
366619977,
|
|
1424
|
-
2362670323,
|
|
1425
|
-
4224994405,
|
|
1426
|
-
1303535960,
|
|
1427
|
-
984961486,
|
|
1428
|
-
2747007092,
|
|
1429
|
-
3569037538,
|
|
1430
|
-
1256170817,
|
|
1431
|
-
1037604311,
|
|
1432
|
-
2765210733,
|
|
1433
|
-
3554079995,
|
|
1434
|
-
1131014506,
|
|
1435
|
-
879679996,
|
|
1436
|
-
2909243462,
|
|
1437
|
-
3663771856,
|
|
1438
|
-
1141124467,
|
|
1439
|
-
855842277,
|
|
1440
|
-
2852801631,
|
|
1441
|
-
3708648649,
|
|
1442
|
-
1342533948,
|
|
1443
|
-
654459306,
|
|
1444
|
-
3188396048,
|
|
1445
|
-
3373015174,
|
|
1446
|
-
1466479909,
|
|
1447
|
-
544179635,
|
|
1448
|
-
3110523913,
|
|
1449
|
-
3462522015,
|
|
1450
|
-
1591671054,
|
|
1451
|
-
702138776,
|
|
1452
|
-
2966460450,
|
|
1453
|
-
3352799412,
|
|
1454
|
-
1504918807,
|
|
1455
|
-
783551873,
|
|
1456
|
-
3082640443,
|
|
1457
|
-
3233442989,
|
|
1458
|
-
3988292384,
|
|
1459
|
-
2596254646,
|
|
1460
|
-
62317068,
|
|
1461
|
-
1957810842,
|
|
1462
|
-
3939845945,
|
|
1463
|
-
2647816111,
|
|
1464
|
-
81470997,
|
|
1465
|
-
1943803523,
|
|
1466
|
-
3814918930,
|
|
1467
|
-
2489596804,
|
|
1468
|
-
225274430,
|
|
1469
|
-
2053790376,
|
|
1470
|
-
3826175755,
|
|
1471
|
-
2466906013,
|
|
1472
|
-
167816743,
|
|
1473
|
-
2097651377,
|
|
1474
|
-
4027552580,
|
|
1475
|
-
2265490386,
|
|
1476
|
-
503444072,
|
|
1477
|
-
1762050814,
|
|
1478
|
-
4150417245,
|
|
1479
|
-
2154129355,
|
|
1480
|
-
426522225,
|
|
1481
|
-
1852507879,
|
|
1482
|
-
4275313526,
|
|
1483
|
-
2312317920,
|
|
1484
|
-
282753626,
|
|
1485
|
-
1742555852,
|
|
1486
|
-
4189708143,
|
|
1487
|
-
2394877945,
|
|
1488
|
-
397917763,
|
|
1489
|
-
1622183637,
|
|
1490
|
-
3604390888,
|
|
1491
|
-
2714866558,
|
|
1492
|
-
953729732,
|
|
1493
|
-
1340076626,
|
|
1494
|
-
3518719985,
|
|
1495
|
-
2797360999,
|
|
1496
|
-
1068828381,
|
|
1497
|
-
1219638859,
|
|
1498
|
-
3624741850,
|
|
1499
|
-
2936675148,
|
|
1500
|
-
906185462,
|
|
1501
|
-
1090812512,
|
|
1502
|
-
3747672003,
|
|
1503
|
-
2825379669,
|
|
1504
|
-
829329135,
|
|
1505
|
-
1181335161,
|
|
1506
|
-
3412177804,
|
|
1507
|
-
3160834842,
|
|
1508
|
-
628085408,
|
|
1509
|
-
1382605366,
|
|
1510
|
-
3423369109,
|
|
1511
|
-
3138078467,
|
|
1512
|
-
570562233,
|
|
1513
|
-
1426400815,
|
|
1514
|
-
3317316542,
|
|
1515
|
-
2998733608,
|
|
1516
|
-
733239954,
|
|
1517
|
-
1555261956,
|
|
1518
|
-
3268935591,
|
|
1519
|
-
3050360625,
|
|
1520
|
-
752459403,
|
|
1521
|
-
1541320221,
|
|
1522
|
-
2607071920,
|
|
1523
|
-
3965973030,
|
|
1524
|
-
1969922972,
|
|
1525
|
-
40735498,
|
|
1526
|
-
2617837225,
|
|
1527
|
-
3943577151,
|
|
1528
|
-
1913087877,
|
|
1529
|
-
83908371,
|
|
1530
|
-
2512341634,
|
|
1531
|
-
3803740692,
|
|
1532
|
-
2075208622,
|
|
1533
|
-
213261112,
|
|
1534
|
-
2463272603,
|
|
1535
|
-
3855990285,
|
|
1536
|
-
2094854071,
|
|
1537
|
-
198958881,
|
|
1538
|
-
2262029012,
|
|
1539
|
-
4057260610,
|
|
1540
|
-
1759359992,
|
|
1541
|
-
534414190,
|
|
1542
|
-
2176718541,
|
|
1543
|
-
4139329115,
|
|
1544
|
-
1873836001,
|
|
1545
|
-
414664567,
|
|
1546
|
-
2282248934,
|
|
1547
|
-
4279200368,
|
|
1548
|
-
1711684554,
|
|
1549
|
-
285281116,
|
|
1550
|
-
2405801727,
|
|
1551
|
-
4167216745,
|
|
1552
|
-
1634467795,
|
|
1553
|
-
376229701,
|
|
1554
|
-
2685067896,
|
|
1555
|
-
3608007406,
|
|
1556
|
-
1308918612,
|
|
1557
|
-
956543938,
|
|
1558
|
-
2808555105,
|
|
1559
|
-
3495958263,
|
|
1560
|
-
1231636301,
|
|
1561
|
-
1047427035,
|
|
1562
|
-
2932959818,
|
|
1563
|
-
3654703836,
|
|
1564
|
-
1088359270,
|
|
1565
|
-
936918e3,
|
|
1566
|
-
2847714899,
|
|
1567
|
-
3736837829,
|
|
1568
|
-
1202900863,
|
|
1569
|
-
817233897,
|
|
1570
|
-
3183342108,
|
|
1571
|
-
3401237130,
|
|
1572
|
-
1404277552,
|
|
1573
|
-
615818150,
|
|
1574
|
-
3134207493,
|
|
1575
|
-
3453421203,
|
|
1576
|
-
1423857449,
|
|
1577
|
-
601450431,
|
|
1578
|
-
3009837614,
|
|
1579
|
-
3294710456,
|
|
1580
|
-
1567103746,
|
|
1581
|
-
711928724,
|
|
1582
|
-
3020668471,
|
|
1583
|
-
3272380065,
|
|
1584
|
-
1510334235,
|
|
1585
|
-
755167117
|
|
1586
|
-
];
|
|
1587
|
-
if (typeof Int32Array !== "undefined") {
|
|
1588
|
-
CRC_TABLE = new Int32Array(CRC_TABLE);
|
|
1589
|
-
}
|
|
1590
|
-
function ensureBuffer(input) {
|
|
1591
|
-
if (Buffer2.isBuffer(input)) {
|
|
1592
|
-
return input;
|
|
1593
|
-
}
|
|
1594
|
-
var hasNewBufferAPI = typeof Buffer2.alloc === "function" && typeof Buffer2.from === "function";
|
|
1595
|
-
if (typeof input === "number") {
|
|
1596
|
-
return hasNewBufferAPI ? Buffer2.alloc(input) : new Buffer2(input);
|
|
1597
|
-
} else if (typeof input === "string") {
|
|
1598
|
-
return hasNewBufferAPI ? Buffer2.from(input) : new Buffer2(input);
|
|
1599
|
-
} else {
|
|
1600
|
-
throw new Error("input must be buffer, number, or string, received " + typeof input);
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
function bufferizeInt(num) {
|
|
1604
|
-
var tmp = ensureBuffer(4);
|
|
1605
|
-
tmp.writeInt32BE(num, 0);
|
|
1606
|
-
return tmp;
|
|
1607
|
-
}
|
|
1608
|
-
function _crc32(buf, previous) {
|
|
1609
|
-
buf = ensureBuffer(buf);
|
|
1610
|
-
if (Buffer2.isBuffer(previous)) {
|
|
1611
|
-
previous = previous.readUInt32BE(0);
|
|
1612
|
-
}
|
|
1613
|
-
var crc = ~~previous ^ -1;
|
|
1614
|
-
for (var n = 0; n < buf.length; n++) {
|
|
1615
|
-
crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
|
|
1616
|
-
}
|
|
1617
|
-
return crc ^ -1;
|
|
1618
|
-
}
|
|
1619
|
-
function crc32() {
|
|
1620
|
-
return bufferizeInt(_crc32.apply(null, arguments));
|
|
1621
|
-
}
|
|
1622
|
-
crc32.signed = function() {
|
|
1623
|
-
return _crc32.apply(null, arguments);
|
|
1624
|
-
};
|
|
1625
|
-
crc32.unsigned = function() {
|
|
1626
|
-
return _crc32.apply(null, arguments) >>> 0;
|
|
1627
|
-
};
|
|
1628
|
-
module.exports = crc32;
|
|
1629
|
-
}
|
|
1630
|
-
});
|
|
1631
|
-
|
|
1632
|
-
// node_modules/yauzl/index.js
|
|
1633
|
-
var require_yauzl = __commonJS({
|
|
1634
|
-
"node_modules/yauzl/index.js"(exports) {
|
|
1635
|
-
var fs = __require("fs");
|
|
1636
|
-
var zlib = __require("zlib");
|
|
1637
|
-
var fd_slicer = require_fd_slicer();
|
|
1638
|
-
var crc32 = require_buffer_crc32();
|
|
1639
|
-
var util = __require("util");
|
|
1640
|
-
var EventEmitter = __require("events").EventEmitter;
|
|
1641
|
-
var Transform = __require("stream").Transform;
|
|
1642
|
-
var PassThrough = __require("stream").PassThrough;
|
|
1643
|
-
var Writable = __require("stream").Writable;
|
|
1644
|
-
exports.open = open;
|
|
1645
|
-
exports.fromFd = fromFd;
|
|
1646
|
-
exports.fromBuffer = fromBuffer;
|
|
1647
|
-
exports.fromRandomAccessReader = fromRandomAccessReader;
|
|
1648
|
-
exports.dosDateTimeToDate = dosDateTimeToDate;
|
|
1649
|
-
exports.validateFileName = validateFileName;
|
|
1650
|
-
exports.ZipFile = ZipFile;
|
|
1651
|
-
exports.Entry = Entry;
|
|
1652
|
-
exports.RandomAccessReader = RandomAccessReader;
|
|
1653
|
-
function open(path7, options, callback) {
|
|
1654
|
-
if (typeof options === "function") {
|
|
1655
|
-
callback = options;
|
|
1656
|
-
options = null;
|
|
1657
|
-
}
|
|
1658
|
-
if (options == null) options = {};
|
|
1659
|
-
if (options.autoClose == null) options.autoClose = true;
|
|
1660
|
-
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
1661
|
-
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
1662
|
-
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
1663
|
-
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
1664
|
-
if (callback == null) callback = defaultCallback;
|
|
1665
|
-
fs.open(path7, "r", function(err, fd) {
|
|
1666
|
-
if (err) return callback(err);
|
|
1667
|
-
fromFd(fd, options, function(err2, zipfile) {
|
|
1668
|
-
if (err2) fs.close(fd, defaultCallback);
|
|
1669
|
-
callback(err2, zipfile);
|
|
1670
|
-
});
|
|
1671
|
-
});
|
|
1672
|
-
}
|
|
1673
|
-
function fromFd(fd, options, callback) {
|
|
1674
|
-
if (typeof options === "function") {
|
|
1675
|
-
callback = options;
|
|
1676
|
-
options = null;
|
|
1677
|
-
}
|
|
1678
|
-
if (options == null) options = {};
|
|
1679
|
-
if (options.autoClose == null) options.autoClose = false;
|
|
1680
|
-
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
1681
|
-
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
1682
|
-
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
1683
|
-
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
1684
|
-
if (callback == null) callback = defaultCallback;
|
|
1685
|
-
fs.fstat(fd, function(err, stats) {
|
|
1686
|
-
if (err) return callback(err);
|
|
1687
|
-
var reader = fd_slicer.createFromFd(fd, { autoClose: true });
|
|
1688
|
-
fromRandomAccessReader(reader, stats.size, options, callback);
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1691
|
-
function fromBuffer(buffer, options, callback) {
|
|
1692
|
-
if (typeof options === "function") {
|
|
1693
|
-
callback = options;
|
|
1694
|
-
options = null;
|
|
1695
|
-
}
|
|
1696
|
-
if (options == null) options = {};
|
|
1697
|
-
options.autoClose = false;
|
|
1698
|
-
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
1699
|
-
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
1700
|
-
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
1701
|
-
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
1702
|
-
var reader = fd_slicer.createFromBuffer(buffer, { maxChunkSize: 65536 });
|
|
1703
|
-
fromRandomAccessReader(reader, buffer.length, options, callback);
|
|
1704
|
-
}
|
|
1705
|
-
function fromRandomAccessReader(reader, totalSize, options, callback) {
|
|
1706
|
-
if (typeof options === "function") {
|
|
1707
|
-
callback = options;
|
|
1708
|
-
options = null;
|
|
1709
|
-
}
|
|
1710
|
-
if (options == null) options = {};
|
|
1711
|
-
if (options.autoClose == null) options.autoClose = true;
|
|
1712
|
-
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
1713
|
-
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
1714
|
-
var decodeStrings = !!options.decodeStrings;
|
|
1715
|
-
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
1716
|
-
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
1717
|
-
if (callback == null) callback = defaultCallback;
|
|
1718
|
-
if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
|
|
1719
|
-
if (totalSize > Number.MAX_SAFE_INTEGER) {
|
|
1720
|
-
throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
|
|
1721
|
-
}
|
|
1722
|
-
reader.ref();
|
|
1723
|
-
var eocdrWithoutCommentSize = 22;
|
|
1724
|
-
var maxCommentSize = 65535;
|
|
1725
|
-
var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
|
|
1726
|
-
var buffer = newBuffer(bufferSize);
|
|
1727
|
-
var bufferReadStart = totalSize - buffer.length;
|
|
1728
|
-
readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
|
|
1729
|
-
if (err) return callback(err);
|
|
1730
|
-
for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
|
|
1731
|
-
if (buffer.readUInt32LE(i) !== 101010256) continue;
|
|
1732
|
-
var eocdrBuffer = buffer.slice(i);
|
|
1733
|
-
var diskNumber = eocdrBuffer.readUInt16LE(4);
|
|
1734
|
-
if (diskNumber !== 0) {
|
|
1735
|
-
return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
|
|
1736
|
-
}
|
|
1737
|
-
var entryCount = eocdrBuffer.readUInt16LE(10);
|
|
1738
|
-
var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
|
|
1739
|
-
var commentLength = eocdrBuffer.readUInt16LE(20);
|
|
1740
|
-
var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
|
|
1741
|
-
if (commentLength !== expectedCommentLength) {
|
|
1742
|
-
return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
|
|
1743
|
-
}
|
|
1744
|
-
var comment = decodeStrings ? decodeBuffer(eocdrBuffer, 22, eocdrBuffer.length, false) : eocdrBuffer.slice(22);
|
|
1745
|
-
if (!(entryCount === 65535 || centralDirectoryOffset === 4294967295)) {
|
|
1746
|
-
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
|
|
1747
|
-
}
|
|
1748
|
-
var zip64EocdlBuffer = newBuffer(20);
|
|
1749
|
-
var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
|
|
1750
|
-
readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err2) {
|
|
1751
|
-
if (err2) return callback(err2);
|
|
1752
|
-
if (zip64EocdlBuffer.readUInt32LE(0) !== 117853008) {
|
|
1753
|
-
return callback(new Error("invalid zip64 end of central directory locator signature"));
|
|
1754
|
-
}
|
|
1755
|
-
var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
|
|
1756
|
-
var zip64EocdrBuffer = newBuffer(56);
|
|
1757
|
-
readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err3) {
|
|
1758
|
-
if (err3) return callback(err3);
|
|
1759
|
-
if (zip64EocdrBuffer.readUInt32LE(0) !== 101075792) {
|
|
1760
|
-
return callback(new Error("invalid zip64 end of central directory record signature"));
|
|
1761
|
-
}
|
|
1762
|
-
entryCount = readUInt64LE(zip64EocdrBuffer, 32);
|
|
1763
|
-
centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
|
|
1764
|
-
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
|
|
1765
|
-
});
|
|
1766
|
-
});
|
|
1767
|
-
return;
|
|
1768
|
-
}
|
|
1769
|
-
callback(new Error("end of central directory record signature not found"));
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
util.inherits(ZipFile, EventEmitter);
|
|
1773
|
-
function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
|
|
1774
|
-
var self = this;
|
|
1775
|
-
EventEmitter.call(self);
|
|
1776
|
-
self.reader = reader;
|
|
1777
|
-
self.reader.on("error", function(err) {
|
|
1778
|
-
emitError(self, err);
|
|
1779
|
-
});
|
|
1780
|
-
self.reader.once("close", function() {
|
|
1781
|
-
self.emit("close");
|
|
1782
|
-
});
|
|
1783
|
-
self.readEntryCursor = centralDirectoryOffset;
|
|
1784
|
-
self.fileSize = fileSize;
|
|
1785
|
-
self.entryCount = entryCount;
|
|
1786
|
-
self.comment = comment;
|
|
1787
|
-
self.entriesRead = 0;
|
|
1788
|
-
self.autoClose = !!autoClose;
|
|
1789
|
-
self.lazyEntries = !!lazyEntries;
|
|
1790
|
-
self.decodeStrings = !!decodeStrings;
|
|
1791
|
-
self.validateEntrySizes = !!validateEntrySizes;
|
|
1792
|
-
self.strictFileNames = !!strictFileNames;
|
|
1793
|
-
self.isOpen = true;
|
|
1794
|
-
self.emittedError = false;
|
|
1795
|
-
if (!self.lazyEntries) self._readEntry();
|
|
1796
|
-
}
|
|
1797
|
-
ZipFile.prototype.close = function() {
|
|
1798
|
-
if (!this.isOpen) return;
|
|
1799
|
-
this.isOpen = false;
|
|
1800
|
-
this.reader.unref();
|
|
1801
|
-
};
|
|
1802
|
-
function emitErrorAndAutoClose(self, err) {
|
|
1803
|
-
if (self.autoClose) self.close();
|
|
1804
|
-
emitError(self, err);
|
|
1805
|
-
}
|
|
1806
|
-
function emitError(self, err) {
|
|
1807
|
-
if (self.emittedError) return;
|
|
1808
|
-
self.emittedError = true;
|
|
1809
|
-
self.emit("error", err);
|
|
1810
|
-
}
|
|
1811
|
-
ZipFile.prototype.readEntry = function() {
|
|
1812
|
-
if (!this.lazyEntries) throw new Error("readEntry() called without lazyEntries:true");
|
|
1813
|
-
this._readEntry();
|
|
1814
|
-
};
|
|
1815
|
-
ZipFile.prototype._readEntry = function() {
|
|
1816
|
-
var self = this;
|
|
1817
|
-
if (self.entryCount === self.entriesRead) {
|
|
1818
|
-
setImmediate(function() {
|
|
1819
|
-
if (self.autoClose) self.close();
|
|
1820
|
-
if (self.emittedError) return;
|
|
1821
|
-
self.emit("end");
|
|
1822
|
-
});
|
|
1823
|
-
return;
|
|
1824
|
-
}
|
|
1825
|
-
if (self.emittedError) return;
|
|
1826
|
-
var buffer = newBuffer(46);
|
|
1827
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
|
|
1828
|
-
if (err) return emitErrorAndAutoClose(self, err);
|
|
1829
|
-
if (self.emittedError) return;
|
|
1830
|
-
var entry = new Entry();
|
|
1831
|
-
var signature = buffer.readUInt32LE(0);
|
|
1832
|
-
if (signature !== 33639248) return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
|
|
1833
|
-
entry.versionMadeBy = buffer.readUInt16LE(4);
|
|
1834
|
-
entry.versionNeededToExtract = buffer.readUInt16LE(6);
|
|
1835
|
-
entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
|
|
1836
|
-
entry.compressionMethod = buffer.readUInt16LE(10);
|
|
1837
|
-
entry.lastModFileTime = buffer.readUInt16LE(12);
|
|
1838
|
-
entry.lastModFileDate = buffer.readUInt16LE(14);
|
|
1839
|
-
entry.crc32 = buffer.readUInt32LE(16);
|
|
1840
|
-
entry.compressedSize = buffer.readUInt32LE(20);
|
|
1841
|
-
entry.uncompressedSize = buffer.readUInt32LE(24);
|
|
1842
|
-
entry.fileNameLength = buffer.readUInt16LE(28);
|
|
1843
|
-
entry.extraFieldLength = buffer.readUInt16LE(30);
|
|
1844
|
-
entry.fileCommentLength = buffer.readUInt16LE(32);
|
|
1845
|
-
entry.internalFileAttributes = buffer.readUInt16LE(36);
|
|
1846
|
-
entry.externalFileAttributes = buffer.readUInt32LE(38);
|
|
1847
|
-
entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
|
|
1848
|
-
if (entry.generalPurposeBitFlag & 64) return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));
|
|
1849
|
-
self.readEntryCursor += 46;
|
|
1850
|
-
buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
|
|
1851
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err2) {
|
|
1852
|
-
if (err2) return emitErrorAndAutoClose(self, err2);
|
|
1853
|
-
if (self.emittedError) return;
|
|
1854
|
-
var isUtf8 = (entry.generalPurposeBitFlag & 2048) !== 0;
|
|
1855
|
-
entry.fileName = self.decodeStrings ? decodeBuffer(buffer, 0, entry.fileNameLength, isUtf8) : buffer.slice(0, entry.fileNameLength);
|
|
1856
|
-
var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
|
|
1857
|
-
var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
|
|
1858
|
-
entry.extraFields = [];
|
|
1859
|
-
var i = 0;
|
|
1860
|
-
while (i < extraFieldBuffer.length - 3) {
|
|
1861
|
-
var headerId = extraFieldBuffer.readUInt16LE(i + 0);
|
|
1862
|
-
var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
|
|
1863
|
-
var dataStart = i + 4;
|
|
1864
|
-
var dataEnd = dataStart + dataSize;
|
|
1865
|
-
if (dataEnd > extraFieldBuffer.length) return emitErrorAndAutoClose(self, new Error("extra field length exceeds extra field buffer size"));
|
|
1866
|
-
var dataBuffer = newBuffer(dataSize);
|
|
1867
|
-
extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
|
|
1868
|
-
entry.extraFields.push({
|
|
1869
|
-
id: headerId,
|
|
1870
|
-
data: dataBuffer
|
|
1871
|
-
});
|
|
1872
|
-
i = dataEnd;
|
|
1873
|
-
}
|
|
1874
|
-
entry.fileComment = self.decodeStrings ? decodeBuffer(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8) : buffer.slice(fileCommentStart, fileCommentStart + entry.fileCommentLength);
|
|
1875
|
-
entry.comment = entry.fileComment;
|
|
1876
|
-
self.readEntryCursor += buffer.length;
|
|
1877
|
-
self.entriesRead += 1;
|
|
1878
|
-
if (entry.uncompressedSize === 4294967295 || entry.compressedSize === 4294967295 || entry.relativeOffsetOfLocalHeader === 4294967295) {
|
|
1879
|
-
var zip64EiefBuffer = null;
|
|
1880
|
-
for (var i = 0; i < entry.extraFields.length; i++) {
|
|
1881
|
-
var extraField = entry.extraFields[i];
|
|
1882
|
-
if (extraField.id === 1) {
|
|
1883
|
-
zip64EiefBuffer = extraField.data;
|
|
1884
|
-
break;
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
if (zip64EiefBuffer == null) {
|
|
1888
|
-
return emitErrorAndAutoClose(self, new Error("expected zip64 extended information extra field"));
|
|
1889
|
-
}
|
|
1890
|
-
var index = 0;
|
|
1891
|
-
if (entry.uncompressedSize === 4294967295) {
|
|
1892
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
|
1893
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
|
|
1894
|
-
}
|
|
1895
|
-
entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
1896
|
-
index += 8;
|
|
1897
|
-
}
|
|
1898
|
-
if (entry.compressedSize === 4294967295) {
|
|
1899
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
|
1900
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
|
|
1901
|
-
}
|
|
1902
|
-
entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
1903
|
-
index += 8;
|
|
1904
|
-
}
|
|
1905
|
-
if (entry.relativeOffsetOfLocalHeader === 4294967295) {
|
|
1906
|
-
if (index + 8 > zip64EiefBuffer.length) {
|
|
1907
|
-
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
|
|
1908
|
-
}
|
|
1909
|
-
entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
|
|
1910
|
-
index += 8;
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
if (self.decodeStrings) {
|
|
1914
|
-
for (var i = 0; i < entry.extraFields.length; i++) {
|
|
1915
|
-
var extraField = entry.extraFields[i];
|
|
1916
|
-
if (extraField.id === 28789) {
|
|
1917
|
-
if (extraField.data.length < 6) {
|
|
1918
|
-
continue;
|
|
1919
|
-
}
|
|
1920
|
-
if (extraField.data.readUInt8(0) !== 1) {
|
|
1921
|
-
continue;
|
|
1922
|
-
}
|
|
1923
|
-
var oldNameCrc32 = extraField.data.readUInt32LE(1);
|
|
1924
|
-
if (crc32.unsigned(buffer.slice(0, entry.fileNameLength)) !== oldNameCrc32) {
|
|
1925
|
-
continue;
|
|
1926
|
-
}
|
|
1927
|
-
entry.fileName = decodeBuffer(extraField.data, 5, extraField.data.length, true);
|
|
1928
|
-
break;
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
if (self.validateEntrySizes && entry.compressionMethod === 0) {
|
|
1933
|
-
var expectedCompressedSize = entry.uncompressedSize;
|
|
1934
|
-
if (entry.isEncrypted()) {
|
|
1935
|
-
expectedCompressedSize += 12;
|
|
1936
|
-
}
|
|
1937
|
-
if (entry.compressedSize !== expectedCompressedSize) {
|
|
1938
|
-
var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
|
|
1939
|
-
return emitErrorAndAutoClose(self, new Error(msg));
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
if (self.decodeStrings) {
|
|
1943
|
-
if (!self.strictFileNames) {
|
|
1944
|
-
entry.fileName = entry.fileName.replace(/\\/g, "/");
|
|
1945
|
-
}
|
|
1946
|
-
var errorMessage = validateFileName(entry.fileName, self.validateFileNameOptions);
|
|
1947
|
-
if (errorMessage != null) return emitErrorAndAutoClose(self, new Error(errorMessage));
|
|
1948
|
-
}
|
|
1949
|
-
self.emit("entry", entry);
|
|
1950
|
-
if (!self.lazyEntries) self._readEntry();
|
|
1951
|
-
});
|
|
1952
|
-
});
|
|
1953
|
-
};
|
|
1954
|
-
ZipFile.prototype.openReadStream = function(entry, options, callback) {
|
|
1955
|
-
var self = this;
|
|
1956
|
-
var relativeStart = 0;
|
|
1957
|
-
var relativeEnd = entry.compressedSize;
|
|
1958
|
-
if (callback == null) {
|
|
1959
|
-
callback = options;
|
|
1960
|
-
options = {};
|
|
1961
|
-
} else {
|
|
1962
|
-
if (options.decrypt != null) {
|
|
1963
|
-
if (!entry.isEncrypted()) {
|
|
1964
|
-
throw new Error("options.decrypt can only be specified for encrypted entries");
|
|
1965
|
-
}
|
|
1966
|
-
if (options.decrypt !== false) throw new Error("invalid options.decrypt value: " + options.decrypt);
|
|
1967
|
-
if (entry.isCompressed()) {
|
|
1968
|
-
if (options.decompress !== false) throw new Error("entry is encrypted and compressed, and options.decompress !== false");
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
if (options.decompress != null) {
|
|
1972
|
-
if (!entry.isCompressed()) {
|
|
1973
|
-
throw new Error("options.decompress can only be specified for compressed entries");
|
|
1974
|
-
}
|
|
1975
|
-
if (!(options.decompress === false || options.decompress === true)) {
|
|
1976
|
-
throw new Error("invalid options.decompress value: " + options.decompress);
|
|
1977
|
-
}
|
|
1978
|
-
}
|
|
1979
|
-
if (options.start != null || options.end != null) {
|
|
1980
|
-
if (entry.isCompressed() && options.decompress !== false) {
|
|
1981
|
-
throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
|
|
1982
|
-
}
|
|
1983
|
-
if (entry.isEncrypted() && options.decrypt !== false) {
|
|
1984
|
-
throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
if (options.start != null) {
|
|
1988
|
-
relativeStart = options.start;
|
|
1989
|
-
if (relativeStart < 0) throw new Error("options.start < 0");
|
|
1990
|
-
if (relativeStart > entry.compressedSize) throw new Error("options.start > entry.compressedSize");
|
|
1991
|
-
}
|
|
1992
|
-
if (options.end != null) {
|
|
1993
|
-
relativeEnd = options.end;
|
|
1994
|
-
if (relativeEnd < 0) throw new Error("options.end < 0");
|
|
1995
|
-
if (relativeEnd > entry.compressedSize) throw new Error("options.end > entry.compressedSize");
|
|
1996
|
-
if (relativeEnd < relativeStart) throw new Error("options.end < options.start");
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
if (!self.isOpen) return callback(new Error("closed"));
|
|
2000
|
-
if (entry.isEncrypted()) {
|
|
2001
|
-
if (options.decrypt !== false) return callback(new Error("entry is encrypted, and options.decrypt !== false"));
|
|
2002
|
-
}
|
|
2003
|
-
self.reader.ref();
|
|
2004
|
-
var buffer = newBuffer(30);
|
|
2005
|
-
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
|
|
2006
|
-
try {
|
|
2007
|
-
if (err) return callback(err);
|
|
2008
|
-
var signature = buffer.readUInt32LE(0);
|
|
2009
|
-
if (signature !== 67324752) {
|
|
2010
|
-
return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
|
|
2011
|
-
}
|
|
2012
|
-
var fileNameLength = buffer.readUInt16LE(26);
|
|
2013
|
-
var extraFieldLength = buffer.readUInt16LE(28);
|
|
2014
|
-
var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
|
|
2015
|
-
var decompress;
|
|
2016
|
-
if (entry.compressionMethod === 0) {
|
|
2017
|
-
decompress = false;
|
|
2018
|
-
} else if (entry.compressionMethod === 8) {
|
|
2019
|
-
decompress = options.decompress != null ? options.decompress : true;
|
|
2020
|
-
} else {
|
|
2021
|
-
return callback(new Error("unsupported compression method: " + entry.compressionMethod));
|
|
2022
|
-
}
|
|
2023
|
-
var fileDataStart = localFileHeaderEnd;
|
|
2024
|
-
var fileDataEnd = fileDataStart + entry.compressedSize;
|
|
2025
|
-
if (entry.compressedSize !== 0) {
|
|
2026
|
-
if (fileDataEnd > self.fileSize) {
|
|
2027
|
-
return callback(new Error("file data overflows file bounds: " + fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
var readStream = self.reader.createReadStream({
|
|
2031
|
-
start: fileDataStart + relativeStart,
|
|
2032
|
-
end: fileDataStart + relativeEnd
|
|
2033
|
-
});
|
|
2034
|
-
var endpointStream = readStream;
|
|
2035
|
-
if (decompress) {
|
|
2036
|
-
var destroyed = false;
|
|
2037
|
-
var inflateFilter = zlib.createInflateRaw();
|
|
2038
|
-
readStream.on("error", function(err2) {
|
|
2039
|
-
setImmediate(function() {
|
|
2040
|
-
if (!destroyed) inflateFilter.emit("error", err2);
|
|
2041
|
-
});
|
|
2042
|
-
});
|
|
2043
|
-
readStream.pipe(inflateFilter);
|
|
2044
|
-
if (self.validateEntrySizes) {
|
|
2045
|
-
endpointStream = new AssertByteCountStream(entry.uncompressedSize);
|
|
2046
|
-
inflateFilter.on("error", function(err2) {
|
|
2047
|
-
setImmediate(function() {
|
|
2048
|
-
if (!destroyed) endpointStream.emit("error", err2);
|
|
2049
|
-
});
|
|
2050
|
-
});
|
|
2051
|
-
inflateFilter.pipe(endpointStream);
|
|
2052
|
-
} else {
|
|
2053
|
-
endpointStream = inflateFilter;
|
|
2054
|
-
}
|
|
2055
|
-
endpointStream.destroy = function() {
|
|
2056
|
-
destroyed = true;
|
|
2057
|
-
if (inflateFilter !== endpointStream) inflateFilter.unpipe(endpointStream);
|
|
2058
|
-
readStream.unpipe(inflateFilter);
|
|
2059
|
-
readStream.destroy();
|
|
2060
|
-
};
|
|
2061
|
-
}
|
|
2062
|
-
callback(null, endpointStream);
|
|
2063
|
-
} finally {
|
|
2064
|
-
self.reader.unref();
|
|
2065
|
-
}
|
|
2066
|
-
});
|
|
2067
|
-
};
|
|
2068
|
-
function Entry() {
|
|
2069
|
-
}
|
|
2070
|
-
Entry.prototype.getLastModDate = function() {
|
|
2071
|
-
return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
|
|
2072
|
-
};
|
|
2073
|
-
Entry.prototype.isEncrypted = function() {
|
|
2074
|
-
return (this.generalPurposeBitFlag & 1) !== 0;
|
|
2075
|
-
};
|
|
2076
|
-
Entry.prototype.isCompressed = function() {
|
|
2077
|
-
return this.compressionMethod === 8;
|
|
2078
|
-
};
|
|
2079
|
-
function dosDateTimeToDate(date, time) {
|
|
2080
|
-
var day = date & 31;
|
|
2081
|
-
var month = (date >> 5 & 15) - 1;
|
|
2082
|
-
var year = (date >> 9 & 127) + 1980;
|
|
2083
|
-
var millisecond = 0;
|
|
2084
|
-
var second = (time & 31) * 2;
|
|
2085
|
-
var minute = time >> 5 & 63;
|
|
2086
|
-
var hour = time >> 11 & 31;
|
|
2087
|
-
return new Date(year, month, day, hour, minute, second, millisecond);
|
|
2088
|
-
}
|
|
2089
|
-
function validateFileName(fileName) {
|
|
2090
|
-
if (fileName.indexOf("\\") !== -1) {
|
|
2091
|
-
return "invalid characters in fileName: " + fileName;
|
|
2092
|
-
}
|
|
2093
|
-
if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
|
|
2094
|
-
return "absolute path: " + fileName;
|
|
2095
|
-
}
|
|
2096
|
-
if (fileName.split("/").indexOf("..") !== -1) {
|
|
2097
|
-
return "invalid relative path: " + fileName;
|
|
2098
|
-
}
|
|
2099
|
-
return null;
|
|
2100
|
-
}
|
|
2101
|
-
function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
|
|
2102
|
-
if (length === 0) {
|
|
2103
|
-
return setImmediate(function() {
|
|
2104
|
-
callback(null, newBuffer(0));
|
|
2105
|
-
});
|
|
2106
|
-
}
|
|
2107
|
-
reader.read(buffer, offset, length, position, function(err, bytesRead) {
|
|
2108
|
-
if (err) return callback(err);
|
|
2109
|
-
if (bytesRead < length) {
|
|
2110
|
-
return callback(new Error("unexpected EOF"));
|
|
2111
|
-
}
|
|
2112
|
-
callback();
|
|
2113
|
-
});
|
|
2114
|
-
}
|
|
2115
|
-
util.inherits(AssertByteCountStream, Transform);
|
|
2116
|
-
function AssertByteCountStream(byteCount) {
|
|
2117
|
-
Transform.call(this);
|
|
2118
|
-
this.actualByteCount = 0;
|
|
2119
|
-
this.expectedByteCount = byteCount;
|
|
2120
|
-
}
|
|
2121
|
-
AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
|
|
2122
|
-
this.actualByteCount += chunk.length;
|
|
2123
|
-
if (this.actualByteCount > this.expectedByteCount) {
|
|
2124
|
-
var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
|
|
2125
|
-
return cb(new Error(msg));
|
|
2126
|
-
}
|
|
2127
|
-
cb(null, chunk);
|
|
2128
|
-
};
|
|
2129
|
-
AssertByteCountStream.prototype._flush = function(cb) {
|
|
2130
|
-
if (this.actualByteCount < this.expectedByteCount) {
|
|
2131
|
-
var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
|
|
2132
|
-
return cb(new Error(msg));
|
|
2133
|
-
}
|
|
2134
|
-
cb();
|
|
2135
|
-
};
|
|
2136
|
-
util.inherits(RandomAccessReader, EventEmitter);
|
|
2137
|
-
function RandomAccessReader() {
|
|
2138
|
-
EventEmitter.call(this);
|
|
2139
|
-
this.refCount = 0;
|
|
2140
|
-
}
|
|
2141
|
-
RandomAccessReader.prototype.ref = function() {
|
|
2142
|
-
this.refCount += 1;
|
|
2143
|
-
};
|
|
2144
|
-
RandomAccessReader.prototype.unref = function() {
|
|
2145
|
-
var self = this;
|
|
2146
|
-
self.refCount -= 1;
|
|
2147
|
-
if (self.refCount > 0) return;
|
|
2148
|
-
if (self.refCount < 0) throw new Error("invalid unref");
|
|
2149
|
-
self.close(onCloseDone);
|
|
2150
|
-
function onCloseDone(err) {
|
|
2151
|
-
if (err) return self.emit("error", err);
|
|
2152
|
-
self.emit("close");
|
|
2153
|
-
}
|
|
2154
|
-
};
|
|
2155
|
-
RandomAccessReader.prototype.createReadStream = function(options) {
|
|
2156
|
-
var start = options.start;
|
|
2157
|
-
var end = options.end;
|
|
2158
|
-
if (start === end) {
|
|
2159
|
-
var emptyStream = new PassThrough();
|
|
2160
|
-
setImmediate(function() {
|
|
2161
|
-
emptyStream.end();
|
|
2162
|
-
});
|
|
2163
|
-
return emptyStream;
|
|
2164
|
-
}
|
|
2165
|
-
var stream = this._readStreamForRange(start, end);
|
|
2166
|
-
var destroyed = false;
|
|
2167
|
-
var refUnrefFilter = new RefUnrefFilter(this);
|
|
2168
|
-
stream.on("error", function(err) {
|
|
2169
|
-
setImmediate(function() {
|
|
2170
|
-
if (!destroyed) refUnrefFilter.emit("error", err);
|
|
2171
|
-
});
|
|
2172
|
-
});
|
|
2173
|
-
refUnrefFilter.destroy = function() {
|
|
2174
|
-
stream.unpipe(refUnrefFilter);
|
|
2175
|
-
refUnrefFilter.unref();
|
|
2176
|
-
stream.destroy();
|
|
2177
|
-
};
|
|
2178
|
-
var byteCounter = new AssertByteCountStream(end - start);
|
|
2179
|
-
refUnrefFilter.on("error", function(err) {
|
|
2180
|
-
setImmediate(function() {
|
|
2181
|
-
if (!destroyed) byteCounter.emit("error", err);
|
|
2182
|
-
});
|
|
2183
|
-
});
|
|
2184
|
-
byteCounter.destroy = function() {
|
|
2185
|
-
destroyed = true;
|
|
2186
|
-
refUnrefFilter.unpipe(byteCounter);
|
|
2187
|
-
refUnrefFilter.destroy();
|
|
2188
|
-
};
|
|
2189
|
-
return stream.pipe(refUnrefFilter).pipe(byteCounter);
|
|
2190
|
-
};
|
|
2191
|
-
RandomAccessReader.prototype._readStreamForRange = function(start, end) {
|
|
2192
|
-
throw new Error("not implemented");
|
|
2193
|
-
};
|
|
2194
|
-
RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
|
|
2195
|
-
var readStream = this.createReadStream({ start: position, end: position + length });
|
|
2196
|
-
var writeStream = new Writable();
|
|
2197
|
-
var written = 0;
|
|
2198
|
-
writeStream._write = function(chunk, encoding, cb) {
|
|
2199
|
-
chunk.copy(buffer, offset + written, 0, chunk.length);
|
|
2200
|
-
written += chunk.length;
|
|
2201
|
-
cb();
|
|
2202
|
-
};
|
|
2203
|
-
writeStream.on("finish", callback);
|
|
2204
|
-
readStream.on("error", function(error) {
|
|
2205
|
-
callback(error);
|
|
2206
|
-
});
|
|
2207
|
-
readStream.pipe(writeStream);
|
|
2208
|
-
};
|
|
2209
|
-
RandomAccessReader.prototype.close = function(callback) {
|
|
2210
|
-
setImmediate(callback);
|
|
2211
|
-
};
|
|
2212
|
-
util.inherits(RefUnrefFilter, PassThrough);
|
|
2213
|
-
function RefUnrefFilter(context) {
|
|
2214
|
-
PassThrough.call(this);
|
|
2215
|
-
this.context = context;
|
|
2216
|
-
this.context.ref();
|
|
2217
|
-
this.unreffedYet = false;
|
|
2218
|
-
}
|
|
2219
|
-
RefUnrefFilter.prototype._flush = function(cb) {
|
|
2220
|
-
this.unref();
|
|
2221
|
-
cb();
|
|
2222
|
-
};
|
|
2223
|
-
RefUnrefFilter.prototype.unref = function(cb) {
|
|
2224
|
-
if (this.unreffedYet) return;
|
|
2225
|
-
this.unreffedYet = true;
|
|
2226
|
-
this.context.unref();
|
|
2227
|
-
};
|
|
2228
|
-
var cp437 = "\0\u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\xB6\xA7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";
|
|
2229
|
-
function decodeBuffer(buffer, start, end, isUtf8) {
|
|
2230
|
-
if (isUtf8) {
|
|
2231
|
-
return buffer.toString("utf8", start, end);
|
|
2232
|
-
} else {
|
|
2233
|
-
var result = "";
|
|
2234
|
-
for (var i = start; i < end; i++) {
|
|
2235
|
-
result += cp437[buffer[i]];
|
|
2236
|
-
}
|
|
2237
|
-
return result;
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
function readUInt64LE(buffer, offset) {
|
|
2241
|
-
var lower32 = buffer.readUInt32LE(offset);
|
|
2242
|
-
var upper32 = buffer.readUInt32LE(offset + 4);
|
|
2243
|
-
return upper32 * 4294967296 + lower32;
|
|
2244
|
-
}
|
|
2245
|
-
var newBuffer;
|
|
2246
|
-
if (typeof Buffer.allocUnsafe === "function") {
|
|
2247
|
-
newBuffer = function(len) {
|
|
2248
|
-
return Buffer.allocUnsafe(len);
|
|
2249
|
-
};
|
|
2250
|
-
} else {
|
|
2251
|
-
newBuffer = function(len) {
|
|
2252
|
-
return new Buffer(len);
|
|
2253
|
-
};
|
|
2254
|
-
}
|
|
2255
|
-
function defaultCallback(err) {
|
|
2256
|
-
if (err) throw err;
|
|
2257
|
-
}
|
|
2258
|
-
}
|
|
2259
|
-
});
|
|
2260
|
-
|
|
2261
|
-
// node_modules/extract-zip/index.js
|
|
2262
|
-
var require_extract_zip = __commonJS({
|
|
2263
|
-
"node_modules/extract-zip/index.js"(exports, module) {
|
|
2264
|
-
var debug = require_src()("extract-zip");
|
|
2265
|
-
var { createWriteStream: createWriteStream2, promises: fs } = __require("fs");
|
|
2266
|
-
var getStream = require_get_stream();
|
|
2267
|
-
var path7 = __require("path");
|
|
2268
|
-
var { promisify: promisify2 } = __require("util");
|
|
2269
|
-
var stream = __require("stream");
|
|
2270
|
-
var yauzl = require_yauzl();
|
|
2271
|
-
var openZip = promisify2(yauzl.open);
|
|
2272
|
-
var pipeline = promisify2(stream.pipeline);
|
|
2273
|
-
var Extractor = class {
|
|
2274
|
-
constructor(zipPath, opts) {
|
|
2275
|
-
this.zipPath = zipPath;
|
|
2276
|
-
this.opts = opts;
|
|
2277
|
-
}
|
|
2278
|
-
async extract() {
|
|
2279
|
-
debug("opening", this.zipPath, "with opts", this.opts);
|
|
2280
|
-
this.zipfile = await openZip(this.zipPath, { lazyEntries: true });
|
|
2281
|
-
this.canceled = false;
|
|
2282
|
-
return new Promise((resolve3, reject) => {
|
|
2283
|
-
this.zipfile.on("error", (err) => {
|
|
2284
|
-
this.canceled = true;
|
|
2285
|
-
reject(err);
|
|
2286
|
-
});
|
|
2287
|
-
this.zipfile.readEntry();
|
|
2288
|
-
this.zipfile.on("close", () => {
|
|
2289
|
-
if (!this.canceled) {
|
|
2290
|
-
debug("zip extraction complete");
|
|
2291
|
-
resolve3();
|
|
2292
|
-
}
|
|
2293
|
-
});
|
|
2294
|
-
this.zipfile.on("entry", async (entry) => {
|
|
2295
|
-
if (this.canceled) {
|
|
2296
|
-
debug("skipping entry", entry.fileName, { cancelled: this.canceled });
|
|
2297
|
-
return;
|
|
2298
|
-
}
|
|
2299
|
-
debug("zipfile entry", entry.fileName);
|
|
2300
|
-
if (entry.fileName.startsWith("__MACOSX/")) {
|
|
2301
|
-
this.zipfile.readEntry();
|
|
2302
|
-
return;
|
|
2303
|
-
}
|
|
2304
|
-
const destDir = path7.dirname(path7.join(this.opts.dir, entry.fileName));
|
|
2305
|
-
try {
|
|
2306
|
-
await fs.mkdir(destDir, { recursive: true });
|
|
2307
|
-
const canonicalDestDir = await fs.realpath(destDir);
|
|
2308
|
-
const relativeDestDir = path7.relative(this.opts.dir, canonicalDestDir);
|
|
2309
|
-
if (relativeDestDir.split(path7.sep).includes("..")) {
|
|
2310
|
-
throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
|
|
2311
|
-
}
|
|
2312
|
-
await this.extractEntry(entry);
|
|
2313
|
-
debug("finished processing", entry.fileName);
|
|
2314
|
-
this.zipfile.readEntry();
|
|
2315
|
-
} catch (err) {
|
|
2316
|
-
this.canceled = true;
|
|
2317
|
-
this.zipfile.close();
|
|
2318
|
-
reject(err);
|
|
2319
|
-
}
|
|
2320
|
-
});
|
|
2321
|
-
});
|
|
2322
|
-
}
|
|
2323
|
-
async extractEntry(entry) {
|
|
2324
|
-
if (this.canceled) {
|
|
2325
|
-
debug("skipping entry extraction", entry.fileName, { cancelled: this.canceled });
|
|
2326
|
-
return;
|
|
2327
|
-
}
|
|
2328
|
-
if (this.opts.onEntry) {
|
|
2329
|
-
this.opts.onEntry(entry, this.zipfile);
|
|
2330
|
-
}
|
|
2331
|
-
const dest = path7.join(this.opts.dir, entry.fileName);
|
|
2332
|
-
const mode = entry.externalFileAttributes >> 16 & 65535;
|
|
2333
|
-
const IFMT = 61440;
|
|
2334
|
-
const IFDIR = 16384;
|
|
2335
|
-
const IFLNK = 40960;
|
|
2336
|
-
const symlink = (mode & IFMT) === IFLNK;
|
|
2337
|
-
let isDir = (mode & IFMT) === IFDIR;
|
|
2338
|
-
if (!isDir && entry.fileName.endsWith("/")) {
|
|
2339
|
-
isDir = true;
|
|
2340
|
-
}
|
|
2341
|
-
const madeBy = entry.versionMadeBy >> 8;
|
|
2342
|
-
if (!isDir) isDir = madeBy === 0 && entry.externalFileAttributes === 16;
|
|
2343
|
-
debug("extracting entry", { filename: entry.fileName, isDir, isSymlink: symlink });
|
|
2344
|
-
const procMode = this.getExtractedMode(mode, isDir) & 511;
|
|
2345
|
-
const destDir = isDir ? dest : path7.dirname(dest);
|
|
2346
|
-
const mkdirOptions = { recursive: true };
|
|
2347
|
-
if (isDir) {
|
|
2348
|
-
mkdirOptions.mode = procMode;
|
|
2349
|
-
}
|
|
2350
|
-
debug("mkdir", { dir: destDir, ...mkdirOptions });
|
|
2351
|
-
await fs.mkdir(destDir, mkdirOptions);
|
|
2352
|
-
if (isDir) return;
|
|
2353
|
-
debug("opening read stream", dest);
|
|
2354
|
-
const readStream = await promisify2(this.zipfile.openReadStream.bind(this.zipfile))(entry);
|
|
2355
|
-
if (symlink) {
|
|
2356
|
-
const link = await getStream(readStream);
|
|
2357
|
-
debug("creating symlink", link, dest);
|
|
2358
|
-
await fs.symlink(link, dest);
|
|
2359
|
-
} else {
|
|
2360
|
-
await pipeline(readStream, createWriteStream2(dest, { mode: procMode }));
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
getExtractedMode(entryMode, isDir) {
|
|
2364
|
-
let mode = entryMode;
|
|
2365
|
-
if (mode === 0) {
|
|
2366
|
-
if (isDir) {
|
|
2367
|
-
if (this.opts.defaultDirMode) {
|
|
2368
|
-
mode = parseInt(this.opts.defaultDirMode, 10);
|
|
2369
|
-
}
|
|
2370
|
-
if (!mode) {
|
|
2371
|
-
mode = 493;
|
|
2372
|
-
}
|
|
2373
|
-
} else {
|
|
2374
|
-
if (this.opts.defaultFileMode) {
|
|
2375
|
-
mode = parseInt(this.opts.defaultFileMode, 10);
|
|
2376
|
-
}
|
|
2377
|
-
if (!mode) {
|
|
2378
|
-
mode = 420;
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
return mode;
|
|
2383
|
-
}
|
|
2384
|
-
};
|
|
2385
|
-
module.exports = async function(zipPath, opts) {
|
|
2386
|
-
debug("creating target directory", opts.dir);
|
|
2387
|
-
if (!path7.isAbsolute(opts.dir)) {
|
|
2388
|
-
throw new Error("Target directory is expected to be absolute");
|
|
2389
|
-
}
|
|
2390
|
-
await fs.mkdir(opts.dir, { recursive: true });
|
|
2391
|
-
opts.dir = await fs.realpath(opts.dir);
|
|
2392
|
-
return new Extractor(zipPath, opts).extract();
|
|
2393
|
-
};
|
|
2394
|
-
}
|
|
2395
|
-
});
|
|
2396
|
-
|
|
2397
1
|
// src/openclaw/account-id.ts
|
|
2398
2
|
var DEFAULT_ACCOUNT_ID = "default";
|
|
2399
3
|
function normalizeOptionalAccountId(raw) {
|
|
@@ -2859,8 +463,8 @@ async function handleFileListAction(params, context) {
|
|
|
2859
463
|
allowedExtensions: params.allowed_extensions
|
|
2860
464
|
});
|
|
2861
465
|
return { status: "ok", result: { files, current_path: realTarget } };
|
|
2862
|
-
} catch (
|
|
2863
|
-
const msg =
|
|
466
|
+
} catch (err2) {
|
|
467
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
2864
468
|
return {
|
|
2865
469
|
status: "failed",
|
|
2866
470
|
error_code: "list_failed",
|
|
@@ -2993,9 +597,9 @@ async function handleCreateFolderAction(params, context) {
|
|
|
2993
597
|
const folderPath = path3.join(realParent, trimmed);
|
|
2994
598
|
try {
|
|
2995
599
|
await mkdir(folderPath);
|
|
2996
|
-
} catch (
|
|
2997
|
-
const msg =
|
|
2998
|
-
if (
|
|
600
|
+
} catch (err2) {
|
|
601
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
602
|
+
if (err2 && typeof err2 === "object" && "code" in err2 && err2.code === "EEXIST") {
|
|
2999
603
|
return {
|
|
3000
604
|
status: "failed",
|
|
3001
605
|
error_code: "already_exists",
|
|
@@ -3208,8 +812,8 @@ import { readdir, readFile as readFile2 } from "node:fs/promises";
|
|
|
3208
812
|
import { createInterface } from "node:readline";
|
|
3209
813
|
import { dirname as dirname3, join as join4 } from "node:path";
|
|
3210
814
|
import { homedir as homedir5 } from "node:os";
|
|
3211
|
-
function warnUsage(message,
|
|
3212
|
-
const detail =
|
|
815
|
+
function warnUsage(message, err2) {
|
|
816
|
+
const detail = err2 instanceof Error ? err2.message : err2 != null ? String(err2) : "";
|
|
3213
817
|
console.warn(`[openclaw/usage] ${message}${detail ? `: ${detail}` : ""}`);
|
|
3214
818
|
}
|
|
3215
819
|
function zeroUsage() {
|
|
@@ -3264,8 +868,8 @@ async function listSessionStorePaths(stateDir2) {
|
|
|
3264
868
|
let agentIds;
|
|
3265
869
|
try {
|
|
3266
870
|
agentIds = await readdir(agentsRoot);
|
|
3267
|
-
} catch (
|
|
3268
|
-
warnUsage(`failed to list agents under ${agentsRoot}`,
|
|
871
|
+
} catch (err2) {
|
|
872
|
+
warnUsage(`failed to list agents under ${agentsRoot}`, err2);
|
|
3269
873
|
return [];
|
|
3270
874
|
}
|
|
3271
875
|
const paths2 = [];
|
|
@@ -3283,8 +887,8 @@ async function loadSessionStore(storePath) {
|
|
|
3283
887
|
return null;
|
|
3284
888
|
}
|
|
3285
889
|
return raw;
|
|
3286
|
-
} catch (
|
|
3287
|
-
warnUsage(`failed to read sessions store ${storePath}`,
|
|
890
|
+
} catch (err2) {
|
|
891
|
+
warnUsage(`failed to read sessions store ${storePath}`, err2);
|
|
3288
892
|
return null;
|
|
3289
893
|
}
|
|
3290
894
|
}
|
|
@@ -3306,8 +910,8 @@ function resolveTranscriptPaths(params) {
|
|
|
3306
910
|
let dirEntries = [];
|
|
3307
911
|
try {
|
|
3308
912
|
dirEntries = readdirSync(sessionsDir);
|
|
3309
|
-
} catch (
|
|
3310
|
-
warnUsage(`failed to list session transcripts in ${sessionsDir}`,
|
|
913
|
+
} catch (err2) {
|
|
914
|
+
warnUsage(`failed to list session transcripts in ${sessionsDir}`, err2);
|
|
3311
915
|
dirEntries = [];
|
|
3312
916
|
}
|
|
3313
917
|
if (typeof entry.sessionFile === "string" && entry.sessionFile.trim()) {
|
|
@@ -3562,13 +1166,13 @@ async function handleConfigureGatewayProviderLocalAction(payload) {
|
|
|
3562
1166
|
status: "success",
|
|
3563
1167
|
result: { relay: "enabled", model, restart_required: true }
|
|
3564
1168
|
};
|
|
3565
|
-
} catch (
|
|
1169
|
+
} catch (err2) {
|
|
3566
1170
|
return {
|
|
3567
1171
|
action_id: actionID,
|
|
3568
1172
|
status: "failed",
|
|
3569
1173
|
error_code: "config_write_failed",
|
|
3570
1174
|
// 绝不把 api_key 带进错误信息。
|
|
3571
|
-
error_msg:
|
|
1175
|
+
error_msg: err2 instanceof Error ? err2.message : String(err2)
|
|
3572
1176
|
};
|
|
3573
1177
|
}
|
|
3574
1178
|
}
|
|
@@ -3761,7 +1365,7 @@ function handleSkillsCommand() {
|
|
|
3761
1365
|
const skills = scanOpenClawSkills();
|
|
3762
1366
|
if (skills.length === 0) return "No skills found.";
|
|
3763
1367
|
const lines = skills.map(
|
|
3764
|
-
(s,
|
|
1368
|
+
(s, i2) => `${i2 + 1}. ${s.name} [${s.source}]
|
|
3765
1369
|
${s.description}`
|
|
3766
1370
|
);
|
|
3767
1371
|
return `Found ${skills.length} skill(s):
|
|
@@ -3782,8 +1386,8 @@ function isTailnetIPv4(addr) {
|
|
|
3782
1386
|
}
|
|
3783
1387
|
function detectViaCLI() {
|
|
3784
1388
|
return new Promise((resolve3) => {
|
|
3785
|
-
execFile2("tailscale", ["ip", "-4"], { timeout: 3e3 }, (
|
|
3786
|
-
if (
|
|
1389
|
+
execFile2("tailscale", ["ip", "-4"], { timeout: 3e3 }, (err2, stdout) => {
|
|
1390
|
+
if (err2) {
|
|
3787
1391
|
resolve3(void 0);
|
|
3788
1392
|
return;
|
|
3789
1393
|
}
|
|
@@ -3865,21 +1469,21 @@ var AibotPacketError = class extends Error {
|
|
|
3865
1469
|
this.code = code;
|
|
3866
1470
|
}
|
|
3867
1471
|
};
|
|
3868
|
-
function clampInt(value, fallback, min,
|
|
1472
|
+
function clampInt(value, fallback, min, max2) {
|
|
3869
1473
|
const n = Number(value);
|
|
3870
1474
|
if (!Number.isFinite(n)) {
|
|
3871
1475
|
return fallback;
|
|
3872
1476
|
}
|
|
3873
|
-
return Math.max(min, Math.min(
|
|
1477
|
+
return Math.max(min, Math.min(max2, Math.floor(n)));
|
|
3874
1478
|
}
|
|
3875
1479
|
function buildFastRetryDelays(baseDelayMs) {
|
|
3876
1480
|
const first = Math.max(100, Math.min(300, Math.floor(baseDelayMs / 4)));
|
|
3877
1481
|
const second = Math.max(first, Math.min(1e3, Math.floor(baseDelayMs / 2)));
|
|
3878
1482
|
return [first, second];
|
|
3879
1483
|
}
|
|
3880
|
-
function randomIntInclusive(min,
|
|
1484
|
+
function randomIntInclusive(min, max2) {
|
|
3881
1485
|
const boundedMin = Math.floor(min);
|
|
3882
|
-
const boundedMax = Math.floor(
|
|
1486
|
+
const boundedMax = Math.floor(max2);
|
|
3883
1487
|
if (boundedMax <= boundedMin) {
|
|
3884
1488
|
return boundedMin;
|
|
3885
1489
|
}
|
|
@@ -4102,8 +1706,8 @@ var AibotWsClient = class {
|
|
|
4102
1706
|
`client start ws=${redactWsUrlForLog(this.account.wsUrl)} reconnectBaseMs=${this.reconnectPolicy.baseDelayMs} reconnectMaxMs=${this.reconnectPolicy.maxDelayMs} reconnectStableMs=${this.reconnectPolicy.stableConnectionMs} connectTimeoutMs=${this.reconnectPolicy.connectTimeoutMs}`
|
|
4103
1707
|
);
|
|
4104
1708
|
this.loopPromise = this.runLoop(abortSignal);
|
|
4105
|
-
void this.loopPromise.catch((
|
|
4106
|
-
const msg =
|
|
1709
|
+
void this.loopPromise.catch((err2) => {
|
|
1710
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
4107
1711
|
this.updateStatus({
|
|
4108
1712
|
running: false,
|
|
4109
1713
|
connected: false,
|
|
@@ -4135,9 +1739,9 @@ var AibotWsClient = class {
|
|
|
4135
1739
|
const payload = this.buildSendTextPayload(sessionId, text, clientMsgId, opts);
|
|
4136
1740
|
try {
|
|
4137
1741
|
return await this.sendMessageWithRetry(sessionId, payload, opts.timeoutMs ?? 2e4, "sendText");
|
|
4138
|
-
} catch (
|
|
4139
|
-
if (!this.isMessageTooLargeError(
|
|
4140
|
-
throw
|
|
1742
|
+
} catch (err2) {
|
|
1743
|
+
if (!this.isMessageTooLargeError(err2)) {
|
|
1744
|
+
throw err2;
|
|
4141
1745
|
}
|
|
4142
1746
|
return this.sendSplitTextAfterSizeError(sessionId, text, clientMsgId, opts);
|
|
4143
1747
|
}
|
|
@@ -4148,9 +1752,9 @@ var AibotWsClient = class {
|
|
|
4148
1752
|
const payload = this.buildSendMediaPayload(sessionId, mediaUrl, caption, clientMsgId, opts);
|
|
4149
1753
|
try {
|
|
4150
1754
|
return await this.sendMessageWithRetry(sessionId, payload, opts.timeoutMs ?? 3e4, "sendMedia");
|
|
4151
|
-
} catch (
|
|
4152
|
-
if (!this.isMessageTooLargeError(
|
|
4153
|
-
throw
|
|
1755
|
+
} catch (err2) {
|
|
1756
|
+
if (!this.isMessageTooLargeError(err2) || !caption) {
|
|
1757
|
+
throw err2;
|
|
4154
1758
|
}
|
|
4155
1759
|
return this.sendMediaCaptionAfterSizeError(sessionId, mediaUrl, caption, clientMsgId, opts);
|
|
4156
1760
|
}
|
|
@@ -4589,9 +2193,9 @@ var AibotWsClient = class {
|
|
|
4589
2193
|
`websocket closed cause=${outcome.cause} code=${codeText}${reasonText} uptimeMs=${uptimeMs}`
|
|
4590
2194
|
);
|
|
4591
2195
|
}
|
|
4592
|
-
} catch (
|
|
4593
|
-
const msg =
|
|
4594
|
-
authRejected =
|
|
2196
|
+
} catch (err2) {
|
|
2197
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
2198
|
+
authRejected = err2 instanceof AuthRejectedError;
|
|
4595
2199
|
this.updateStatus({
|
|
4596
2200
|
connected: false,
|
|
4597
2201
|
authed: false,
|
|
@@ -4642,8 +2246,8 @@ var AibotWsClient = class {
|
|
|
4642
2246
|
});
|
|
4643
2247
|
this.logInfo(`websocket connected conn=${connSerial}`);
|
|
4644
2248
|
const onMessage = (event) => {
|
|
4645
|
-
void this.handleMessageEvent(event.data, connSerial).catch((
|
|
4646
|
-
const message =
|
|
2249
|
+
void this.handleMessageEvent(event.data, connSerial).catch((err2) => {
|
|
2250
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
4647
2251
|
this.logError(`handle message failed conn=${connSerial}: ${message}`);
|
|
4648
2252
|
});
|
|
4649
2253
|
};
|
|
@@ -4682,9 +2286,9 @@ var AibotWsClient = class {
|
|
|
4682
2286
|
...outcome,
|
|
4683
2287
|
uptimeMs: Math.max(0, Date.now() - connectedAt)
|
|
4684
2288
|
};
|
|
4685
|
-
} catch (
|
|
2289
|
+
} catch (err2) {
|
|
4686
2290
|
this.safeCloseSpecificWs(ws, "connect_once_error");
|
|
4687
|
-
throw
|
|
2291
|
+
throw err2;
|
|
4688
2292
|
} finally {
|
|
4689
2293
|
ws.removeEventListener("message", onMessage);
|
|
4690
2294
|
ws.removeEventListener("close", onClose);
|
|
@@ -4947,22 +2551,22 @@ var AibotWsClient = class {
|
|
|
4947
2551
|
payload
|
|
4948
2552
|
};
|
|
4949
2553
|
this.ws?.send(JSON.stringify(packet));
|
|
4950
|
-
} catch (
|
|
2554
|
+
} catch (err2) {
|
|
4951
2555
|
this.pending.delete(seq);
|
|
4952
2556
|
clearTimeout(timer);
|
|
4953
|
-
reject(
|
|
2557
|
+
reject(err2 instanceof Error ? err2 : new Error(String(err2)));
|
|
4954
2558
|
}
|
|
4955
2559
|
});
|
|
4956
2560
|
}
|
|
4957
|
-
rejectAllPending(
|
|
2561
|
+
rejectAllPending(err2) {
|
|
4958
2562
|
const pendingCount = this.pending.size;
|
|
4959
2563
|
if (pendingCount > 0) {
|
|
4960
|
-
this.logWarn(`reject pending requests count=${pendingCount} reason=${
|
|
2564
|
+
this.logWarn(`reject pending requests count=${pendingCount} reason=${err2.message}`);
|
|
4961
2565
|
}
|
|
4962
2566
|
for (const [seq, pending] of this.pending.entries()) {
|
|
4963
2567
|
this.pending.delete(seq);
|
|
4964
2568
|
clearTimeout(pending.timer);
|
|
4965
|
-
pending.reject(
|
|
2569
|
+
pending.reject(err2);
|
|
4966
2570
|
}
|
|
4967
2571
|
}
|
|
4968
2572
|
buildSendTextPayload(sessionId, text, clientMsgId, opts) {
|
|
@@ -5027,8 +2631,8 @@ var AibotWsClient = class {
|
|
|
5027
2631
|
if (packet.cmd === "send_ack") {
|
|
5028
2632
|
return packet.payload;
|
|
5029
2633
|
}
|
|
5030
|
-
const
|
|
5031
|
-
if (this.isRetryableSendError(
|
|
2634
|
+
const err2 = this.packetError(packet);
|
|
2635
|
+
if (this.isRetryableSendError(err2) && attempt < maxAttempts) {
|
|
5032
2636
|
const delayMs = resolveAibotSendRetryDelayMs(attempt);
|
|
5033
2637
|
this.logWarn(
|
|
5034
2638
|
`${action} rate limited sessionId=${sessionId} attempt=${attempt}/${maxAttempts} delayMs=${delayMs}`
|
|
@@ -5036,7 +2640,7 @@ var AibotWsClient = class {
|
|
|
5036
2640
|
await sleep(delayMs);
|
|
5037
2641
|
continue;
|
|
5038
2642
|
}
|
|
5039
|
-
throw
|
|
2643
|
+
throw err2;
|
|
5040
2644
|
}
|
|
5041
2645
|
throw new Error(`grix ${action} exhausted retry attempts`);
|
|
5042
2646
|
}
|
|
@@ -5115,11 +2719,11 @@ var AibotWsClient = class {
|
|
|
5115
2719
|
await sleep(waitMs);
|
|
5116
2720
|
}
|
|
5117
2721
|
}
|
|
5118
|
-
isRetryableSendError(
|
|
5119
|
-
return
|
|
2722
|
+
isRetryableSendError(err2) {
|
|
2723
|
+
return err2 instanceof AibotPacketError && isRetryableAibotSendCode(err2.code);
|
|
5120
2724
|
}
|
|
5121
|
-
isMessageTooLargeError(
|
|
5122
|
-
return
|
|
2725
|
+
isMessageTooLargeError(err2) {
|
|
2726
|
+
return err2 instanceof AibotPacketError && err2.code === 4004;
|
|
5123
2727
|
}
|
|
5124
2728
|
buildChunkClientMsgId(clientMsgId, chunkIndex) {
|
|
5125
2729
|
return `${clientMsgId}_chunk${chunkIndex}`;
|
|
@@ -5225,8 +2829,8 @@ var AibotWsClient = class {
|
|
|
5225
2829
|
if (latencyMs >= 2e3) {
|
|
5226
2830
|
this.logWarn(`keepalive high latency conn=${connSerial} latencyMs=${latencyMs}`);
|
|
5227
2831
|
}
|
|
5228
|
-
} catch (
|
|
5229
|
-
const msg =
|
|
2832
|
+
} catch (err2) {
|
|
2833
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
5230
2834
|
this.logWarn(`keepalive failed conn=${connSerial} err=${msg}, force reconnect`);
|
|
5231
2835
|
if (this.ws === ws) {
|
|
5232
2836
|
this.safeCloseSpecificWs(ws, "keepalive_probe_failed");
|
|
@@ -5413,8 +3017,8 @@ async function resolveAibotOutboundTarget(params) {
|
|
|
5413
3017
|
normalizedTarget,
|
|
5414
3018
|
resolveSource: "sessionRouteMap"
|
|
5415
3019
|
};
|
|
5416
|
-
} catch (
|
|
5417
|
-
lastResolveError =
|
|
3020
|
+
} catch (err2) {
|
|
3021
|
+
lastResolveError = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
5418
3022
|
}
|
|
5419
3023
|
}
|
|
5420
3024
|
if (lastResolveError) {
|
|
@@ -6148,12 +3752,12 @@ function guardInternalReplyText(rawText) {
|
|
|
6148
3752
|
var DEFAULT_UPSTREAM_RETRY_MAX_ATTEMPTS = 3;
|
|
6149
3753
|
var DEFAULT_UPSTREAM_RETRY_BASE_DELAY_MS = 300;
|
|
6150
3754
|
var DEFAULT_UPSTREAM_RETRY_MAX_DELAY_MS = 2e3;
|
|
6151
|
-
function clampInt2(value, fallback, min,
|
|
3755
|
+
function clampInt2(value, fallback, min, max2) {
|
|
6152
3756
|
const n = Number(value);
|
|
6153
3757
|
if (!Number.isFinite(n)) {
|
|
6154
3758
|
return fallback;
|
|
6155
3759
|
}
|
|
6156
|
-
return Math.max(min, Math.min(
|
|
3760
|
+
return Math.max(min, Math.min(max2, Math.floor(n)));
|
|
6157
3761
|
}
|
|
6158
3762
|
function resolveUpstreamRetryPolicy(account) {
|
|
6159
3763
|
const maxAttempts = clampInt2(
|
|
@@ -7627,8 +5231,8 @@ async function bindSessionRouteMapping(params) {
|
|
|
7627
5231
|
params.runtime.log(
|
|
7628
5232
|
`[grix:${params.account.accountId}] session route bind success routeSessionKey=${routeSessionKey} sessionId=${sessionId}`
|
|
7629
5233
|
);
|
|
7630
|
-
} catch (
|
|
7631
|
-
const reason = `grix session route bind failed routeSessionKey=${routeSessionKey} sessionId=${sessionId}: ${String(
|
|
5234
|
+
} catch (err2) {
|
|
5235
|
+
const reason = `grix session route bind failed routeSessionKey=${routeSessionKey} sessionId=${sessionId}: ${String(err2)}`;
|
|
7632
5236
|
params.runtime.error(`[grix:${params.account.accountId}] ${reason}`);
|
|
7633
5237
|
params.statusSink?.({ lastError: reason });
|
|
7634
5238
|
}
|
|
@@ -7657,8 +5261,8 @@ function handleEventStop(params) {
|
|
|
7657
5261
|
params.runtime.log(
|
|
7658
5262
|
`[grix:${params.account.accountId}] event_stop_ack sent eventId=${eventId} sessionId=${sessionId} stopId=${stopId || "-"}`
|
|
7659
5263
|
);
|
|
7660
|
-
} catch (
|
|
7661
|
-
const reason = `event_stop_ack failed eventId=${eventId} sessionId=${sessionId}: ${String(
|
|
5264
|
+
} catch (err2) {
|
|
5265
|
+
const reason = `event_stop_ack failed eventId=${eventId} sessionId=${sessionId}: ${String(err2)}`;
|
|
7662
5266
|
params.runtime.error(`[grix:${params.account.accountId}] ${reason}`);
|
|
7663
5267
|
params.statusSink?.({ lastError: reason });
|
|
7664
5268
|
return;
|
|
@@ -7694,9 +5298,9 @@ function handleEventStop(params) {
|
|
|
7694
5298
|
`[grix:${params.account.accountId}] owner stop requested eventId=${eventId} sessionId=${sessionId} stopId=${stopId || "-"} aborted=${activeRun.controller.signal.aborted} abortReason=${resolveAbortReason(activeRun.controller.signal)}`
|
|
7695
5299
|
);
|
|
7696
5300
|
activeRun.stopComposing?.();
|
|
7697
|
-
params.client.sendText(sessionId, "/stop", { eventId }).catch((
|
|
5301
|
+
params.client.sendText(sessionId, "/stop", { eventId }).catch((err2) => {
|
|
7698
5302
|
params.runtime.error(
|
|
7699
|
-
`[grix:${params.account.accountId}] event_stop /stop send failed eventId=${eventId} sessionId=${sessionId}: ${String(
|
|
5303
|
+
`[grix:${params.account.accountId}] event_stop /stop send failed eventId=${eventId} sessionId=${sessionId}: ${String(err2)}`
|
|
7700
5304
|
);
|
|
7701
5305
|
});
|
|
7702
5306
|
}
|
|
@@ -7770,9 +5374,9 @@ async function processEvent(params) {
|
|
|
7770
5374
|
if (recoveryHandle && inboundEvent.confirmed) {
|
|
7771
5375
|
try {
|
|
7772
5376
|
await deletePendingInboundEvent(recoveryHandle);
|
|
7773
|
-
} catch (
|
|
5377
|
+
} catch (err2) {
|
|
7774
5378
|
runtime2.error(
|
|
7775
|
-
`[grix:${account.accountId}] duplicate recovered event cleanup failed ${baseLogContext}: ${String(
|
|
5379
|
+
`[grix:${account.accountId}] duplicate recovered event cleanup failed ${baseLogContext}: ${String(err2)}`
|
|
7776
5380
|
);
|
|
7777
5381
|
}
|
|
7778
5382
|
}
|
|
@@ -7784,11 +5388,11 @@ async function processEvent(params) {
|
|
|
7784
5388
|
receivedAt: Date.now()
|
|
7785
5389
|
});
|
|
7786
5390
|
statusSink?.({ lastOutboundAt: Date.now(), lastError: null });
|
|
7787
|
-
} catch (
|
|
5391
|
+
} catch (err2) {
|
|
7788
5392
|
runtime2.error(
|
|
7789
|
-
`[grix:${account.accountId}] duplicate event ack failed eventId=${eventId}: ${String(
|
|
5393
|
+
`[grix:${account.accountId}] duplicate event ack failed eventId=${eventId}: ${String(err2)}`
|
|
7790
5394
|
);
|
|
7791
|
-
statusSink?.({ lastError: String(
|
|
5395
|
+
statusSink?.({ lastError: String(err2) });
|
|
7792
5396
|
}
|
|
7793
5397
|
}
|
|
7794
5398
|
return;
|
|
@@ -7802,9 +5406,9 @@ async function processEvent(params) {
|
|
|
7802
5406
|
accountId: account.accountId,
|
|
7803
5407
|
event
|
|
7804
5408
|
});
|
|
7805
|
-
} catch (
|
|
5409
|
+
} catch (err2) {
|
|
7806
5410
|
releaseInboundEvent(inboundEvent.claim);
|
|
7807
|
-
throw
|
|
5411
|
+
throw err2;
|
|
7808
5412
|
}
|
|
7809
5413
|
if (!recoveryHandle) {
|
|
7810
5414
|
releaseInboundEvent(inboundEvent.claim);
|
|
@@ -7839,9 +5443,9 @@ async function processEvent(params) {
|
|
|
7839
5443
|
if (recoveryHandle && inboundEventAccepted && (eventId ? eventResultDelivered : terminalCompletionRecorded)) {
|
|
7840
5444
|
try {
|
|
7841
5445
|
await deletePendingInboundEvent(recoveryHandle);
|
|
7842
|
-
} catch (
|
|
5446
|
+
} catch (err2) {
|
|
7843
5447
|
runtime2.error(
|
|
7844
|
-
`[grix:${account.accountId}] pending inbound cleanup failed ${baseLogContext}: ${String(
|
|
5448
|
+
`[grix:${account.accountId}] pending inbound cleanup failed ${baseLogContext}: ${String(err2)}`
|
|
7845
5449
|
);
|
|
7846
5450
|
}
|
|
7847
5451
|
}
|
|
@@ -7927,7 +5531,7 @@ async function processEvent(params) {
|
|
|
7927
5531
|
storePath,
|
|
7928
5532
|
sessionKey: routeSessionKey,
|
|
7929
5533
|
ctx: ctxPayload,
|
|
7930
|
-
onRecordError: (
|
|
5534
|
+
onRecordError: (err2) => runtime2.error(`grix session meta update failed: ${String(err2)}`)
|
|
7931
5535
|
});
|
|
7932
5536
|
await bindSessionRouteMapping({
|
|
7933
5537
|
client,
|
|
@@ -7961,8 +5565,8 @@ Supported: skills, stop`;
|
|
|
7961
5565
|
}
|
|
7962
5566
|
try {
|
|
7963
5567
|
await client.sendText(sessionId, resultText, { eventId });
|
|
7964
|
-
} catch (
|
|
7965
|
-
runtime2.error(`[grix:${account.accountId}] exec reply send failed: ${String(
|
|
5568
|
+
} catch (err2) {
|
|
5569
|
+
runtime2.error(`[grix:${account.accountId}] exec reply send failed: ${String(err2)}`);
|
|
7966
5570
|
}
|
|
7967
5571
|
client.sendEventResult({ event_id: eventId, status: "responded", msg: resultText, updated_at: Date.now() });
|
|
7968
5572
|
statusSink?.({ lastOutboundAt: Date.now(), lastError: null });
|
|
@@ -7985,11 +5589,11 @@ Supported: skills, stop`;
|
|
|
7985
5589
|
});
|
|
7986
5590
|
composingSet = active;
|
|
7987
5591
|
statusSink?.({ lastOutboundAt: Date.now(), lastError: null });
|
|
7988
|
-
} catch (
|
|
5592
|
+
} catch (err2) {
|
|
7989
5593
|
runtime2.error(
|
|
7990
|
-
`[grix:${account.accountId}] session activity update failed eventId=${eventId || "-"} sessionId=${sessionId} active=${active}: ${String(
|
|
5594
|
+
`[grix:${account.accountId}] session activity update failed eventId=${eventId || "-"} sessionId=${sessionId} active=${active}: ${String(err2)}`
|
|
7991
5595
|
);
|
|
7992
|
-
statusSink?.({ lastError: String(
|
|
5596
|
+
statusSink?.({ lastError: String(err2) });
|
|
7993
5597
|
}
|
|
7994
5598
|
};
|
|
7995
5599
|
const stopComposingRenewal = () => {
|
|
@@ -8032,11 +5636,11 @@ Supported: skills, stop`;
|
|
|
8032
5636
|
statusSink?.({ lastOutboundAt: Date.now(), lastError: null });
|
|
8033
5637
|
eventResultDelivered = true;
|
|
8034
5638
|
return true;
|
|
8035
|
-
} catch (
|
|
5639
|
+
} catch (err2) {
|
|
8036
5640
|
runtime2.error(
|
|
8037
|
-
`[grix:${account.accountId}] event result send failed eventId=${eventId} status=${status}: ${String(
|
|
5641
|
+
`[grix:${account.accountId}] event result send failed eventId=${eventId} status=${status}: ${String(err2)}`
|
|
8038
5642
|
);
|
|
8039
|
-
statusSink?.({ lastError: String(
|
|
5643
|
+
statusSink?.({ lastError: String(err2) });
|
|
8040
5644
|
eventResultDelivered = false;
|
|
8041
5645
|
return false;
|
|
8042
5646
|
}
|
|
@@ -8059,11 +5663,11 @@ Supported: skills, stop`;
|
|
|
8059
5663
|
runtime2.log(
|
|
8060
5664
|
`[grix:${account.accountId}] event_stop_result sent eventId=${eventId} stopId=${activeRun.stopId || "-"} status=${status} code=${code || "-"} msg=${msg || "-"}`
|
|
8061
5665
|
);
|
|
8062
|
-
} catch (
|
|
5666
|
+
} catch (err2) {
|
|
8063
5667
|
runtime2.error(
|
|
8064
|
-
`[grix:${account.accountId}] event_stop_result send failed eventId=${eventId} status=${status}: ${String(
|
|
5668
|
+
`[grix:${account.accountId}] event_stop_result send failed eventId=${eventId} status=${status}: ${String(err2)}`
|
|
8065
5669
|
);
|
|
8066
|
-
statusSink?.({ lastError: String(
|
|
5670
|
+
statusSink?.({ lastError: String(err2) });
|
|
8067
5671
|
}
|
|
8068
5672
|
};
|
|
8069
5673
|
const clearComposing = () => {
|
|
@@ -8078,7 +5682,6 @@ Supported: skills, stop`;
|
|
|
8078
5682
|
}
|
|
8079
5683
|
visibleOutputSent = true;
|
|
8080
5684
|
clearComposing();
|
|
8081
|
-
reportEventResult("responded");
|
|
8082
5685
|
};
|
|
8083
5686
|
const streamingEnabled = resolveStreamingEnabled(account);
|
|
8084
5687
|
setComposing(true);
|
|
@@ -8109,9 +5712,9 @@ Supported: skills, stop`;
|
|
|
8109
5712
|
onSent: () => {
|
|
8110
5713
|
statusSink?.({ lastOutboundAt: Date.now(), lastError: null });
|
|
8111
5714
|
},
|
|
8112
|
-
onFinishError: (
|
|
8113
|
-
runtime2.error(`[grix:${account.accountId}] stream finish failed: ${String(
|
|
8114
|
-
statusSink?.({ lastError: String(
|
|
5715
|
+
onFinishError: (err2) => {
|
|
5716
|
+
runtime2.error(`[grix:${account.accountId}] stream finish failed: ${String(err2)}`);
|
|
5717
|
+
statusSink?.({ lastError: String(err2) });
|
|
8115
5718
|
}
|
|
8116
5719
|
}) : null;
|
|
8117
5720
|
activePartialReplyStream = partialReplyStream;
|
|
@@ -8218,9 +5821,9 @@ Supported: skills, stop`;
|
|
|
8218
5821
|
markVisibleOutputSent();
|
|
8219
5822
|
}
|
|
8220
5823
|
},
|
|
8221
|
-
onError: (
|
|
8222
|
-
runtime2.error(`[grix:${account.accountId}] ${info.kind} reply failed: ${String(
|
|
8223
|
-
statusSink?.({ lastError: String(
|
|
5824
|
+
onError: (err2, info) => {
|
|
5825
|
+
runtime2.error(`[grix:${account.accountId}] ${info.kind} reply failed: ${String(err2)}`);
|
|
5826
|
+
statusSink?.({ lastError: String(err2) });
|
|
8224
5827
|
}
|
|
8225
5828
|
},
|
|
8226
5829
|
replyOptions: {
|
|
@@ -8321,10 +5924,10 @@ Supported: skills, stop`;
|
|
|
8321
5924
|
});
|
|
8322
5925
|
} else {
|
|
8323
5926
|
let chunkSeq = 0;
|
|
8324
|
-
for (let
|
|
5927
|
+
for (let i2 = 0; i2 < textChunks.length; i2++) {
|
|
8325
5928
|
if (runAbortController.signal.aborted) break;
|
|
8326
5929
|
chunkSeq++;
|
|
8327
|
-
await client.sendStreamChunk(sessionId, textChunks[
|
|
5930
|
+
await client.sendStreamChunk(sessionId, textChunks[i2], {
|
|
8328
5931
|
eventId,
|
|
8329
5932
|
clientMsgId: stableClientMsgId,
|
|
8330
5933
|
chunkSeq,
|
|
@@ -8426,11 +6029,16 @@ Supported: skills, stop`;
|
|
|
8426
6029
|
}
|
|
8427
6030
|
break;
|
|
8428
6031
|
}
|
|
8429
|
-
if (
|
|
6032
|
+
if (visibleOutputSent && !eventResultReported) {
|
|
6033
|
+
reportEventResult("responded");
|
|
6034
|
+
} else if (!eventResultReported) {
|
|
8430
6035
|
reportEventResult("failed", "grix_no_outbound_reply", "no outbound reply emitted");
|
|
8431
6036
|
}
|
|
8432
|
-
} catch (
|
|
6037
|
+
} catch (err2) {
|
|
8433
6038
|
await activePartialReplyStream?.finish();
|
|
6039
|
+
if (visibleOutputSent && !eventResultReported) {
|
|
6040
|
+
reportEventResult("responded");
|
|
6041
|
+
}
|
|
8434
6042
|
if (runAbortController.signal.aborted) {
|
|
8435
6043
|
runtime2.log(
|
|
8436
6044
|
`[grix:${account.accountId}] dispatch aborted ${baseLogContext} stopRequested=${activeRun?.stopRequested === true} abortReason=${resolveAbortReason(runAbortController.signal)}`
|
|
@@ -8445,11 +6053,11 @@ Supported: skills, stop`;
|
|
|
8445
6053
|
}
|
|
8446
6054
|
}
|
|
8447
6055
|
if (!visibleOutputSent) {
|
|
8448
|
-
const message =
|
|
6056
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
8449
6057
|
reportEventResult("failed", "grix_dispatch_failed", message);
|
|
8450
6058
|
}
|
|
8451
|
-
reportStopResult("failed", "grix_stop_failed",
|
|
8452
|
-
throw
|
|
6059
|
+
reportStopResult("failed", "grix_stop_failed", err2 instanceof Error ? err2.message : String(err2));
|
|
6060
|
+
throw err2;
|
|
8453
6061
|
} finally {
|
|
8454
6062
|
stopComposingRenewal();
|
|
8455
6063
|
if (composingSet) {
|
|
@@ -8492,8 +6100,8 @@ async function replayRecoveredInboundEvents(params) {
|
|
|
8492
6100
|
recoveredHandle: handle,
|
|
8493
6101
|
statusSink: params.statusSink
|
|
8494
6102
|
});
|
|
8495
|
-
} catch (
|
|
8496
|
-
const message =
|
|
6103
|
+
} catch (err2) {
|
|
6104
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
8497
6105
|
params.runtime.error(
|
|
8498
6106
|
`[grix:${params.account.accountId}] recoverable inbound replay failed recordId=${handle.recordId} eventId=${toStringId2(handle.record.event?.event_id) || "-"} sessionId=${toStringId2(handle.record.event?.session_id) || "-"} msgId=${toStringId2(handle.record.event?.msg_id) || "-"}: ${message}`
|
|
8499
6107
|
);
|
|
@@ -8537,11 +6145,11 @@ async function monitorAibotProvider(options) {
|
|
|
8537
6145
|
client,
|
|
8538
6146
|
abortSignal,
|
|
8539
6147
|
statusSink: guardedStatusSink
|
|
8540
|
-
}).catch((
|
|
6148
|
+
}).catch((err2) => {
|
|
8541
6149
|
if (!isActiveMonitor(account.accountId, client)) {
|
|
8542
6150
|
return;
|
|
8543
6151
|
}
|
|
8544
|
-
const message =
|
|
6152
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
8545
6153
|
wrappedRuntime.error(`[grix:${account.accountId}] recovered inbound replay failed: ${message}`);
|
|
8546
6154
|
guardedStatusSink({ lastError: message });
|
|
8547
6155
|
}).finally(() => {
|
|
@@ -8595,11 +6203,11 @@ async function monitorAibotProvider(options) {
|
|
|
8595
6203
|
runtime: wrappedRuntime,
|
|
8596
6204
|
client,
|
|
8597
6205
|
statusSink: guardedStatusSink
|
|
8598
|
-
}).catch((
|
|
6206
|
+
}).catch((err2) => {
|
|
8599
6207
|
if (!isActiveMonitor(account.accountId, client)) {
|
|
8600
6208
|
return;
|
|
8601
6209
|
}
|
|
8602
|
-
const msg =
|
|
6210
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
8603
6211
|
wrappedRuntime.error(`[grix:${account.accountId}] process event failed: ${msg}`);
|
|
8604
6212
|
guardedStatusSink({ lastError: msg });
|
|
8605
6213
|
});
|
|
@@ -8620,8 +6228,8 @@ async function monitorAibotProvider(options) {
|
|
|
8620
6228
|
wrappedRuntime.log(
|
|
8621
6229
|
`[grix:${account.accountId}] inbound react sessionId=${String(event.session_id ?? "").trim() || "-"} messageSid=${String(event.msg_id ?? "").trim() || "-"} emoji=${String(event.emoji ?? "").trim() || "-"} op=${String(event.op ?? "add").trim() || "add"}`
|
|
8622
6230
|
);
|
|
8623
|
-
} catch (
|
|
8624
|
-
const msg =
|
|
6231
|
+
} catch (err2) {
|
|
6232
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
8625
6233
|
wrappedRuntime.error(`[grix:${account.accountId}] process react event failed: ${msg}`);
|
|
8626
6234
|
guardedStatusSink({ lastError: msg });
|
|
8627
6235
|
}
|
|
@@ -8654,8 +6262,8 @@ async function monitorAibotProvider(options) {
|
|
|
8654
6262
|
`[grix:${account.accountId}] inbound revoke skipped sessionId=${revokeEvent.sessionId} messageSid=${revokeEvent.messageId} reason=missing_system_event`
|
|
8655
6263
|
);
|
|
8656
6264
|
}
|
|
8657
|
-
} catch (
|
|
8658
|
-
const msg =
|
|
6265
|
+
} catch (err2) {
|
|
6266
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
8659
6267
|
wrappedRuntime.error(`[grix:${account.accountId}] process revoke event failed: ${msg}`);
|
|
8660
6268
|
guardedStatusSink({ lastError: msg });
|
|
8661
6269
|
}
|
|
@@ -8709,16 +6317,16 @@ async function monitorAibotProvider(options) {
|
|
|
8709
6317
|
setActiveAibotClient(account.accountId, client);
|
|
8710
6318
|
try {
|
|
8711
6319
|
await client.start(abortSignal);
|
|
8712
|
-
} catch (
|
|
6320
|
+
} catch (err2) {
|
|
8713
6321
|
clearActiveAibotClient(account.accountId, client);
|
|
8714
6322
|
clearActiveMonitor(account.accountId, client);
|
|
8715
|
-
throw
|
|
6323
|
+
throw err2;
|
|
8716
6324
|
}
|
|
8717
|
-
void client.waitUntilStopped().catch((
|
|
6325
|
+
void client.waitUntilStopped().catch((err2) => {
|
|
8718
6326
|
if (!isActiveMonitor(account.accountId, client)) {
|
|
8719
6327
|
return;
|
|
8720
6328
|
}
|
|
8721
|
-
const msg =
|
|
6329
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
8722
6330
|
wrappedRuntime.error(`[grix:${account.accountId}] background run loop failed: ${msg}`);
|
|
8723
6331
|
guardedStatusSink({ lastError: msg });
|
|
8724
6332
|
}).finally(() => {
|
|
@@ -8861,9 +6469,9 @@ function chunkTextForOutbound(text, limit) {
|
|
|
8861
6469
|
const chunks = [];
|
|
8862
6470
|
let remaining = text;
|
|
8863
6471
|
while (remaining.length > limit) {
|
|
8864
|
-
const
|
|
8865
|
-
const lastNewline =
|
|
8866
|
-
const lastSpace =
|
|
6472
|
+
const window = remaining.slice(0, limit);
|
|
6473
|
+
const lastNewline = window.lastIndexOf("\n");
|
|
6474
|
+
const lastSpace = window.lastIndexOf(" ");
|
|
8867
6475
|
const candidateBreak = lastNewline > 0 ? lastNewline : lastSpace;
|
|
8868
6476
|
const breakIdx = Number.isFinite(candidateBreak) && candidateBreak > 0 && candidateBreak <= limit ? candidateBreak : limit;
|
|
8869
6477
|
const chunk = remaining.slice(0, breakIdx).trimEnd();
|
|
@@ -9039,11 +6647,11 @@ var aibotPlugin = {
|
|
|
9039
6647
|
accountId: account.accountId,
|
|
9040
6648
|
to
|
|
9041
6649
|
});
|
|
9042
|
-
} catch (
|
|
6650
|
+
} catch (err2) {
|
|
9043
6651
|
logAibotOutboundAdapter(
|
|
9044
|
-
`sendText target resolve failed accountId=${account.accountId} rawTarget=${rawTarget} error=${String(
|
|
6652
|
+
`sendText target resolve failed accountId=${account.accountId} rawTarget=${rawTarget} error=${String(err2)}`
|
|
9045
6653
|
);
|
|
9046
|
-
throw
|
|
6654
|
+
throw err2;
|
|
9047
6655
|
}
|
|
9048
6656
|
const sessionId = resolvedTarget.sessionId;
|
|
9049
6657
|
const quotedMessageId = normalizeQuotedMessageId(replyToId);
|
|
@@ -9085,11 +6693,11 @@ var aibotPlugin = {
|
|
|
9085
6693
|
accountId: account.accountId,
|
|
9086
6694
|
to
|
|
9087
6695
|
});
|
|
9088
|
-
} catch (
|
|
6696
|
+
} catch (err2) {
|
|
9089
6697
|
logAibotOutboundAdapter(
|
|
9090
|
-
`sendMedia target resolve failed accountId=${account.accountId} rawTarget=${rawTarget} error=${String(
|
|
6698
|
+
`sendMedia target resolve failed accountId=${account.accountId} rawTarget=${rawTarget} error=${String(err2)}`
|
|
9091
6699
|
);
|
|
9092
|
-
throw
|
|
6700
|
+
throw err2;
|
|
9093
6701
|
}
|
|
9094
6702
|
const sessionId = resolvedTarget.sessionId;
|
|
9095
6703
|
if (!mediaUrl) {
|
|
@@ -9135,11 +6743,11 @@ var aibotPlugin = {
|
|
|
9135
6743
|
accountId: account.accountId,
|
|
9136
6744
|
to
|
|
9137
6745
|
});
|
|
9138
|
-
} catch (
|
|
6746
|
+
} catch (err2) {
|
|
9139
6747
|
logAibotOutboundAdapter(
|
|
9140
|
-
`sendPayload target resolve failed accountId=${account.accountId} rawTarget=${rawTarget} error=${String(
|
|
6748
|
+
`sendPayload target resolve failed accountId=${account.accountId} rawTarget=${rawTarget} error=${String(err2)}`
|
|
9141
6749
|
);
|
|
9142
|
-
throw
|
|
6750
|
+
throw err2;
|
|
9143
6751
|
}
|
|
9144
6752
|
const sessionId = resolvedTarget.sessionId;
|
|
9145
6753
|
const quotedMessageId = normalizeQuotedMessageId(replyToId);
|
|
@@ -10398,10 +8006,10 @@ function createGrixGroupTool(api, ctx) {
|
|
|
10398
8006
|
action: params.action,
|
|
10399
8007
|
data
|
|
10400
8008
|
});
|
|
10401
|
-
} catch (
|
|
8009
|
+
} catch (err2) {
|
|
10402
8010
|
return jsonToolResult({
|
|
10403
8011
|
ok: false,
|
|
10404
|
-
error:
|
|
8012
|
+
error: err2 instanceof Error ? err2.message : String(err2)
|
|
10405
8013
|
});
|
|
10406
8014
|
}
|
|
10407
8015
|
}
|
|
@@ -10443,10 +8051,10 @@ function createGrixQueryTool(api, ctx) {
|
|
|
10443
8051
|
action: params.action,
|
|
10444
8052
|
data
|
|
10445
8053
|
});
|
|
10446
|
-
} catch (
|
|
8054
|
+
} catch (err2) {
|
|
10447
8055
|
return jsonToolResult({
|
|
10448
8056
|
ok: false,
|
|
10449
|
-
error:
|
|
8057
|
+
error: err2 instanceof Error ? err2.message : String(err2)
|
|
10450
8058
|
});
|
|
10451
8059
|
}
|
|
10452
8060
|
}
|
|
@@ -10485,13 +8093,13 @@ function normalizeNonEmptyString(value) {
|
|
|
10485
8093
|
const normalized = value.trim();
|
|
10486
8094
|
return normalized || void 0;
|
|
10487
8095
|
}
|
|
10488
|
-
function clampInt3(value, fallback, min,
|
|
8096
|
+
function clampInt3(value, fallback, min, max2) {
|
|
10489
8097
|
const numeric = Number(value);
|
|
10490
8098
|
if (!Number.isFinite(numeric)) {
|
|
10491
8099
|
return fallback;
|
|
10492
8100
|
}
|
|
10493
8101
|
const integer = Math.floor(numeric);
|
|
10494
|
-
return Math.min(
|
|
8102
|
+
return Math.min(max2, Math.max(min, integer));
|
|
10495
8103
|
}
|
|
10496
8104
|
function resolveSubagentSessionKey(params) {
|
|
10497
8105
|
const explicitSessionKey = normalizeNonEmptyString(params.toolParams.sessionKey);
|
|
@@ -10572,10 +8180,10 @@ function createDelegatedSkillTool(params) {
|
|
|
10572
8180
|
error: waitResult.error,
|
|
10573
8181
|
messages: sessionMessages.messages
|
|
10574
8182
|
});
|
|
10575
|
-
} catch (
|
|
8183
|
+
} catch (err2) {
|
|
10576
8184
|
return jsonToolResult({
|
|
10577
8185
|
ok: false,
|
|
10578
|
-
error:
|
|
8186
|
+
error: err2 instanceof Error ? err2.message : String(err2)
|
|
10579
8187
|
});
|
|
10580
8188
|
}
|
|
10581
8189
|
}
|
|
@@ -10678,10 +8286,10 @@ function createGrixAdminTool(api, ctx) {
|
|
|
10678
8286
|
action,
|
|
10679
8287
|
data
|
|
10680
8288
|
});
|
|
10681
|
-
} catch (
|
|
8289
|
+
} catch (err2) {
|
|
10682
8290
|
return jsonToolResult({
|
|
10683
8291
|
ok: false,
|
|
10684
|
-
error:
|
|
8292
|
+
error: err2 instanceof Error ? err2.message : String(err2)
|
|
10685
8293
|
});
|
|
10686
8294
|
}
|
|
10687
8295
|
}
|
|
@@ -10760,10 +8368,10 @@ function parseInstallContext(rawInstallContext) {
|
|
|
10760
8368
|
throw new Error("install context must be a JSON object");
|
|
10761
8369
|
}
|
|
10762
8370
|
return parsed;
|
|
10763
|
-
} catch (
|
|
8371
|
+
} catch (err2) {
|
|
10764
8372
|
throw new EggContextParseError(
|
|
10765
8373
|
"installContext",
|
|
10766
|
-
|
|
8374
|
+
err2 instanceof Error ? err2.message : "failed to parse JSON"
|
|
10767
8375
|
);
|
|
10768
8376
|
}
|
|
10769
8377
|
}
|
|
@@ -10990,13 +8598,13 @@ async function downloadPackage(params) {
|
|
|
10990
8598
|
}
|
|
10991
8599
|
}
|
|
10992
8600
|
return buffer;
|
|
10993
|
-
} catch (
|
|
10994
|
-
if (
|
|
10995
|
-
if (
|
|
8601
|
+
} catch (err2) {
|
|
8602
|
+
if (err2 instanceof PackageDownloadError) throw err2;
|
|
8603
|
+
if (err2 instanceof DOMException && err2.name === "AbortError") {
|
|
10996
8604
|
throw new PackageDownloadError(`download timed out after ${timeoutMs}ms`);
|
|
10997
8605
|
}
|
|
10998
8606
|
throw new PackageDownloadError(
|
|
10999
|
-
`download failed: ${
|
|
8607
|
+
`download failed: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
11000
8608
|
);
|
|
11001
8609
|
} finally {
|
|
11002
8610
|
clearTimeout(timer);
|
|
@@ -11004,62 +8612,575 @@ async function downloadPackage(params) {
|
|
|
11004
8612
|
}
|
|
11005
8613
|
|
|
11006
8614
|
// src/openclaw/egg/persona-installer.ts
|
|
11007
|
-
var import_extract_zip = __toESM(require_extract_zip(), 1);
|
|
11008
8615
|
import { join as join9 } from "node:path";
|
|
11009
|
-
|
|
8616
|
+
|
|
8617
|
+
// node_modules/fflate/esm/index.mjs
|
|
8618
|
+
import { createRequire } from "module";
|
|
8619
|
+
var require2 = createRequire("/");
|
|
8620
|
+
var _a;
|
|
8621
|
+
var Worker;
|
|
8622
|
+
var isMarkedAsUntransferable;
|
|
8623
|
+
try {
|
|
8624
|
+
_a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
|
|
8625
|
+
} catch (e) {
|
|
8626
|
+
}
|
|
8627
|
+
var u8 = Uint8Array;
|
|
8628
|
+
var u16 = Uint16Array;
|
|
8629
|
+
var i32 = Int32Array;
|
|
8630
|
+
var fleb = new u8([
|
|
8631
|
+
0,
|
|
8632
|
+
0,
|
|
8633
|
+
0,
|
|
8634
|
+
0,
|
|
8635
|
+
0,
|
|
8636
|
+
0,
|
|
8637
|
+
0,
|
|
8638
|
+
0,
|
|
8639
|
+
1,
|
|
8640
|
+
1,
|
|
8641
|
+
1,
|
|
8642
|
+
1,
|
|
8643
|
+
2,
|
|
8644
|
+
2,
|
|
8645
|
+
2,
|
|
8646
|
+
2,
|
|
8647
|
+
3,
|
|
8648
|
+
3,
|
|
8649
|
+
3,
|
|
8650
|
+
3,
|
|
8651
|
+
4,
|
|
8652
|
+
4,
|
|
8653
|
+
4,
|
|
8654
|
+
4,
|
|
8655
|
+
5,
|
|
8656
|
+
5,
|
|
8657
|
+
5,
|
|
8658
|
+
5,
|
|
8659
|
+
0,
|
|
8660
|
+
/* unused */
|
|
8661
|
+
0,
|
|
8662
|
+
0,
|
|
8663
|
+
/* impossible */
|
|
8664
|
+
0
|
|
8665
|
+
]);
|
|
8666
|
+
var fdeb = new u8([
|
|
8667
|
+
0,
|
|
8668
|
+
0,
|
|
8669
|
+
0,
|
|
8670
|
+
0,
|
|
8671
|
+
1,
|
|
8672
|
+
1,
|
|
8673
|
+
2,
|
|
8674
|
+
2,
|
|
8675
|
+
3,
|
|
8676
|
+
3,
|
|
8677
|
+
4,
|
|
8678
|
+
4,
|
|
8679
|
+
5,
|
|
8680
|
+
5,
|
|
8681
|
+
6,
|
|
8682
|
+
6,
|
|
8683
|
+
7,
|
|
8684
|
+
7,
|
|
8685
|
+
8,
|
|
8686
|
+
8,
|
|
8687
|
+
9,
|
|
8688
|
+
9,
|
|
8689
|
+
10,
|
|
8690
|
+
10,
|
|
8691
|
+
11,
|
|
8692
|
+
11,
|
|
8693
|
+
12,
|
|
8694
|
+
12,
|
|
8695
|
+
13,
|
|
8696
|
+
13,
|
|
8697
|
+
/* unused */
|
|
8698
|
+
0,
|
|
8699
|
+
0
|
|
8700
|
+
]);
|
|
8701
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
8702
|
+
var freb = function(eb, start) {
|
|
8703
|
+
var b = new u16(31);
|
|
8704
|
+
for (var i2 = 0; i2 < 31; ++i2) {
|
|
8705
|
+
b[i2] = start += 1 << eb[i2 - 1];
|
|
8706
|
+
}
|
|
8707
|
+
var r = new i32(b[30]);
|
|
8708
|
+
for (var i2 = 1; i2 < 30; ++i2) {
|
|
8709
|
+
for (var j = b[i2]; j < b[i2 + 1]; ++j) {
|
|
8710
|
+
r[j] = j - b[i2] << 5 | i2;
|
|
8711
|
+
}
|
|
8712
|
+
}
|
|
8713
|
+
return { b, r };
|
|
8714
|
+
};
|
|
8715
|
+
var _a = freb(fleb, 2);
|
|
8716
|
+
var fl = _a.b;
|
|
8717
|
+
var revfl = _a.r;
|
|
8718
|
+
fl[28] = 258, revfl[258] = 28;
|
|
8719
|
+
var _b = freb(fdeb, 0);
|
|
8720
|
+
var fd = _b.b;
|
|
8721
|
+
var revfd = _b.r;
|
|
8722
|
+
var rev = new u16(32768);
|
|
8723
|
+
for (i = 0; i < 32768; ++i) {
|
|
8724
|
+
x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
8725
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
8726
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
8727
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
8728
|
+
}
|
|
8729
|
+
var x;
|
|
8730
|
+
var i;
|
|
8731
|
+
var hMap = (function(cd, mb, r) {
|
|
8732
|
+
var s = cd.length;
|
|
8733
|
+
var i2 = 0;
|
|
8734
|
+
var l = new u16(mb);
|
|
8735
|
+
for (; i2 < s; ++i2) {
|
|
8736
|
+
if (cd[i2])
|
|
8737
|
+
++l[cd[i2] - 1];
|
|
8738
|
+
}
|
|
8739
|
+
var le = new u16(mb);
|
|
8740
|
+
for (i2 = 1; i2 < mb; ++i2) {
|
|
8741
|
+
le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
|
|
8742
|
+
}
|
|
8743
|
+
var co;
|
|
8744
|
+
if (r) {
|
|
8745
|
+
co = new u16(1 << mb);
|
|
8746
|
+
var rvb = 15 - mb;
|
|
8747
|
+
for (i2 = 0; i2 < s; ++i2) {
|
|
8748
|
+
if (cd[i2]) {
|
|
8749
|
+
var sv = i2 << 4 | cd[i2];
|
|
8750
|
+
var r_1 = mb - cd[i2];
|
|
8751
|
+
var v = le[cd[i2] - 1]++ << r_1;
|
|
8752
|
+
for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
|
|
8753
|
+
co[rev[v] >> rvb] = sv;
|
|
8754
|
+
}
|
|
8755
|
+
}
|
|
8756
|
+
}
|
|
8757
|
+
} else {
|
|
8758
|
+
co = new u16(s);
|
|
8759
|
+
for (i2 = 0; i2 < s; ++i2) {
|
|
8760
|
+
if (cd[i2]) {
|
|
8761
|
+
co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
|
|
8762
|
+
}
|
|
8763
|
+
}
|
|
8764
|
+
}
|
|
8765
|
+
return co;
|
|
8766
|
+
});
|
|
8767
|
+
var flt = new u8(288);
|
|
8768
|
+
for (i = 0; i < 144; ++i)
|
|
8769
|
+
flt[i] = 8;
|
|
8770
|
+
var i;
|
|
8771
|
+
for (i = 144; i < 256; ++i)
|
|
8772
|
+
flt[i] = 9;
|
|
8773
|
+
var i;
|
|
8774
|
+
for (i = 256; i < 280; ++i)
|
|
8775
|
+
flt[i] = 7;
|
|
8776
|
+
var i;
|
|
8777
|
+
for (i = 280; i < 288; ++i)
|
|
8778
|
+
flt[i] = 8;
|
|
8779
|
+
var i;
|
|
8780
|
+
var fdt = new u8(32);
|
|
8781
|
+
for (i = 0; i < 32; ++i)
|
|
8782
|
+
fdt[i] = 5;
|
|
8783
|
+
var i;
|
|
8784
|
+
var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
|
|
8785
|
+
var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
|
|
8786
|
+
var max = function(a) {
|
|
8787
|
+
var m = a[0];
|
|
8788
|
+
for (var i2 = 1; i2 < a.length; ++i2) {
|
|
8789
|
+
if (a[i2] > m)
|
|
8790
|
+
m = a[i2];
|
|
8791
|
+
}
|
|
8792
|
+
return m;
|
|
8793
|
+
};
|
|
8794
|
+
var bits = function(d, p, m) {
|
|
8795
|
+
var o = p / 8 | 0;
|
|
8796
|
+
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
|
|
8797
|
+
};
|
|
8798
|
+
var bits16 = function(d, p) {
|
|
8799
|
+
var o = p / 8 | 0;
|
|
8800
|
+
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
|
|
8801
|
+
};
|
|
8802
|
+
var shft = function(p) {
|
|
8803
|
+
return (p + 7) / 8 | 0;
|
|
8804
|
+
};
|
|
8805
|
+
var slc = function(v, s, e) {
|
|
8806
|
+
if (s == null || s < 0)
|
|
8807
|
+
s = 0;
|
|
8808
|
+
if (e == null || e > v.length)
|
|
8809
|
+
e = v.length;
|
|
8810
|
+
return new u8(v.subarray(s, e));
|
|
8811
|
+
};
|
|
8812
|
+
var ec = [
|
|
8813
|
+
"unexpected EOF",
|
|
8814
|
+
"invalid block type",
|
|
8815
|
+
"invalid length/literal",
|
|
8816
|
+
"invalid distance",
|
|
8817
|
+
"stream finished",
|
|
8818
|
+
"no stream handler",
|
|
8819
|
+
,
|
|
8820
|
+
// determined by compression function
|
|
8821
|
+
"no callback",
|
|
8822
|
+
"invalid UTF-8 data",
|
|
8823
|
+
"extra field too long",
|
|
8824
|
+
"date not in range 1980-2099",
|
|
8825
|
+
"filename too long",
|
|
8826
|
+
"stream finishing",
|
|
8827
|
+
"invalid zip data"
|
|
8828
|
+
// determined by unknown compression method
|
|
8829
|
+
];
|
|
8830
|
+
var err = function(ind, msg, nt) {
|
|
8831
|
+
var e = new Error(msg || ec[ind]);
|
|
8832
|
+
e.code = ind;
|
|
8833
|
+
if (Error.captureStackTrace)
|
|
8834
|
+
Error.captureStackTrace(e, err);
|
|
8835
|
+
if (!nt)
|
|
8836
|
+
throw e;
|
|
8837
|
+
return e;
|
|
8838
|
+
};
|
|
8839
|
+
var inflt = function(dat, st, buf, dict) {
|
|
8840
|
+
var sl = dat.length, dl = dict ? dict.length : 0;
|
|
8841
|
+
if (!sl || st.f && !st.l)
|
|
8842
|
+
return buf || new u8(0);
|
|
8843
|
+
var noBuf = !buf;
|
|
8844
|
+
var resize = noBuf || st.i != 2;
|
|
8845
|
+
var noSt = st.i;
|
|
8846
|
+
if (noBuf)
|
|
8847
|
+
buf = new u8(sl * 3);
|
|
8848
|
+
var cbuf = function(l2) {
|
|
8849
|
+
var bl = buf.length;
|
|
8850
|
+
if (l2 > bl) {
|
|
8851
|
+
var nbuf = new u8(Math.max(bl * 2, l2));
|
|
8852
|
+
nbuf.set(buf);
|
|
8853
|
+
buf = nbuf;
|
|
8854
|
+
}
|
|
8855
|
+
};
|
|
8856
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
8857
|
+
var tbts = sl * 8;
|
|
8858
|
+
do {
|
|
8859
|
+
if (!lm) {
|
|
8860
|
+
final = bits(dat, pos, 1);
|
|
8861
|
+
var type = bits(dat, pos + 1, 3);
|
|
8862
|
+
pos += 3;
|
|
8863
|
+
if (!type) {
|
|
8864
|
+
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
|
|
8865
|
+
if (t > sl) {
|
|
8866
|
+
if (noSt)
|
|
8867
|
+
err(0);
|
|
8868
|
+
break;
|
|
8869
|
+
}
|
|
8870
|
+
if (resize)
|
|
8871
|
+
cbuf(bt + l);
|
|
8872
|
+
buf.set(dat.subarray(s, t), bt);
|
|
8873
|
+
st.b = bt += l, st.p = pos = t * 8, st.f = final;
|
|
8874
|
+
continue;
|
|
8875
|
+
} else if (type == 1)
|
|
8876
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
8877
|
+
else if (type == 2) {
|
|
8878
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
8879
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
8880
|
+
pos += 14;
|
|
8881
|
+
var ldt = new u8(tl);
|
|
8882
|
+
var clt = new u8(19);
|
|
8883
|
+
for (var i2 = 0; i2 < hcLen; ++i2) {
|
|
8884
|
+
clt[clim[i2]] = bits(dat, pos + i2 * 3, 7);
|
|
8885
|
+
}
|
|
8886
|
+
pos += hcLen * 3;
|
|
8887
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
8888
|
+
var clm = hMap(clt, clb, 1);
|
|
8889
|
+
for (var i2 = 0; i2 < tl; ) {
|
|
8890
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
8891
|
+
pos += r & 15;
|
|
8892
|
+
var s = r >> 4;
|
|
8893
|
+
if (s < 16) {
|
|
8894
|
+
ldt[i2++] = s;
|
|
8895
|
+
} else {
|
|
8896
|
+
var c = 0, n = 0;
|
|
8897
|
+
if (s == 16)
|
|
8898
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i2 - 1];
|
|
8899
|
+
else if (s == 17)
|
|
8900
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
8901
|
+
else if (s == 18)
|
|
8902
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
8903
|
+
while (n--)
|
|
8904
|
+
ldt[i2++] = c;
|
|
8905
|
+
}
|
|
8906
|
+
}
|
|
8907
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
8908
|
+
lbt = max(lt);
|
|
8909
|
+
dbt = max(dt);
|
|
8910
|
+
lm = hMap(lt, lbt, 1);
|
|
8911
|
+
dm = hMap(dt, dbt, 1);
|
|
8912
|
+
} else
|
|
8913
|
+
err(1);
|
|
8914
|
+
if (pos > tbts) {
|
|
8915
|
+
if (noSt)
|
|
8916
|
+
err(0);
|
|
8917
|
+
break;
|
|
8918
|
+
}
|
|
8919
|
+
}
|
|
8920
|
+
if (resize)
|
|
8921
|
+
cbuf(bt + 131072);
|
|
8922
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
8923
|
+
var lpos = pos;
|
|
8924
|
+
for (; ; lpos = pos) {
|
|
8925
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
|
|
8926
|
+
pos += c & 15;
|
|
8927
|
+
if (pos > tbts) {
|
|
8928
|
+
if (noSt)
|
|
8929
|
+
err(0);
|
|
8930
|
+
break;
|
|
8931
|
+
}
|
|
8932
|
+
if (!c)
|
|
8933
|
+
err(2);
|
|
8934
|
+
if (sym < 256)
|
|
8935
|
+
buf[bt++] = sym;
|
|
8936
|
+
else if (sym == 256) {
|
|
8937
|
+
lpos = pos, lm = null;
|
|
8938
|
+
break;
|
|
8939
|
+
} else {
|
|
8940
|
+
var add = sym - 254;
|
|
8941
|
+
if (sym > 264) {
|
|
8942
|
+
var i2 = sym - 257, b = fleb[i2];
|
|
8943
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i2];
|
|
8944
|
+
pos += b;
|
|
8945
|
+
}
|
|
8946
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
|
|
8947
|
+
if (!d)
|
|
8948
|
+
err(3);
|
|
8949
|
+
pos += d & 15;
|
|
8950
|
+
var dt = fd[dsym];
|
|
8951
|
+
if (dsym > 3) {
|
|
8952
|
+
var b = fdeb[dsym];
|
|
8953
|
+
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
8954
|
+
}
|
|
8955
|
+
if (pos > tbts) {
|
|
8956
|
+
if (noSt)
|
|
8957
|
+
err(0);
|
|
8958
|
+
break;
|
|
8959
|
+
}
|
|
8960
|
+
if (resize)
|
|
8961
|
+
cbuf(bt + 131072);
|
|
8962
|
+
var end = bt + add;
|
|
8963
|
+
if (bt < dt) {
|
|
8964
|
+
var shift = dl - dt, dend = Math.min(dt, end);
|
|
8965
|
+
if (shift + bt < 0)
|
|
8966
|
+
err(3);
|
|
8967
|
+
for (; bt < dend; ++bt)
|
|
8968
|
+
buf[bt] = dict[shift + bt];
|
|
8969
|
+
}
|
|
8970
|
+
for (; bt < end; ++bt)
|
|
8971
|
+
buf[bt] = buf[bt - dt];
|
|
8972
|
+
}
|
|
8973
|
+
}
|
|
8974
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
8975
|
+
if (lm)
|
|
8976
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
8977
|
+
} while (!final);
|
|
8978
|
+
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
|
|
8979
|
+
};
|
|
8980
|
+
var et = /* @__PURE__ */ new u8(0);
|
|
8981
|
+
var b2 = function(d, b) {
|
|
8982
|
+
return d[b] | d[b + 1] << 8;
|
|
8983
|
+
};
|
|
8984
|
+
var b4 = function(d, b) {
|
|
8985
|
+
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
|
|
8986
|
+
};
|
|
8987
|
+
var b8 = function(d, b) {
|
|
8988
|
+
return b4(d, b) + b4(d, b + 4) * 4294967296;
|
|
8989
|
+
};
|
|
8990
|
+
function inflateSync(data, opts) {
|
|
8991
|
+
return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
8992
|
+
}
|
|
8993
|
+
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
|
|
8994
|
+
var tds = 0;
|
|
8995
|
+
try {
|
|
8996
|
+
td.decode(et, { stream: true });
|
|
8997
|
+
tds = 1;
|
|
8998
|
+
} catch (e) {
|
|
8999
|
+
}
|
|
9000
|
+
var dutf8 = function(d) {
|
|
9001
|
+
for (var r = "", i2 = 0; ; ) {
|
|
9002
|
+
var c = d[i2++];
|
|
9003
|
+
var eb = (c > 127) + (c > 223) + (c > 239);
|
|
9004
|
+
if (i2 + eb > d.length)
|
|
9005
|
+
return { s: r, r: slc(d, i2 - 1) };
|
|
9006
|
+
if (!eb)
|
|
9007
|
+
r += String.fromCharCode(c);
|
|
9008
|
+
else if (eb == 3) {
|
|
9009
|
+
c = ((c & 15) << 18 | (d[i2++] & 63) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
|
|
9010
|
+
} else if (eb & 1)
|
|
9011
|
+
r += String.fromCharCode((c & 31) << 6 | d[i2++] & 63);
|
|
9012
|
+
else
|
|
9013
|
+
r += String.fromCharCode((c & 15) << 12 | (d[i2++] & 63) << 6 | d[i2++] & 63);
|
|
9014
|
+
}
|
|
9015
|
+
};
|
|
9016
|
+
function strFromU8(dat, latin1) {
|
|
9017
|
+
if (latin1) {
|
|
9018
|
+
var r = "";
|
|
9019
|
+
for (var i2 = 0; i2 < dat.length; i2 += 16384)
|
|
9020
|
+
r += String.fromCharCode.apply(null, dat.subarray(i2, i2 + 16384));
|
|
9021
|
+
return r;
|
|
9022
|
+
} else if (td) {
|
|
9023
|
+
return td.decode(dat);
|
|
9024
|
+
} else {
|
|
9025
|
+
var _a2 = dutf8(dat), s = _a2.s, r = _a2.r;
|
|
9026
|
+
if (r.length)
|
|
9027
|
+
err(8);
|
|
9028
|
+
return s;
|
|
9029
|
+
}
|
|
9030
|
+
}
|
|
9031
|
+
var slzh = function(d, b) {
|
|
9032
|
+
return b + 30 + b2(d, b + 26) + b2(d, b + 28);
|
|
9033
|
+
};
|
|
9034
|
+
var zh = function(d, b, z) {
|
|
9035
|
+
var fnl = b2(d, b + 28), efl = b2(d, b + 30), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;
|
|
9036
|
+
var _a2 = z64hs(d, es, efl, z, b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)), sc = _a2[0], su = _a2[1], off = _a2[2];
|
|
9037
|
+
return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];
|
|
9038
|
+
};
|
|
9039
|
+
var z64hs = function(d, b, l, z, sc, su, off) {
|
|
9040
|
+
var nsc = sc == 4294967295, nsu = su == 4294967295, noff = off == 4294967295, e = b + l;
|
|
9041
|
+
var nf = nsc + nsu + noff;
|
|
9042
|
+
if (z && nf) {
|
|
9043
|
+
for (; b + 4 < e; b += 4 + b2(d, b + 2)) {
|
|
9044
|
+
if (b2(d, b) == 1) {
|
|
9045
|
+
return [
|
|
9046
|
+
nsc ? b8(d, b + 4 + 8 * nsu) : sc,
|
|
9047
|
+
nsu ? b8(d, b + 4) : su,
|
|
9048
|
+
noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,
|
|
9049
|
+
1
|
|
9050
|
+
];
|
|
9051
|
+
}
|
|
9052
|
+
}
|
|
9053
|
+
if (z < 2)
|
|
9054
|
+
err(13);
|
|
9055
|
+
}
|
|
9056
|
+
return [sc, su, off, 0];
|
|
9057
|
+
};
|
|
9058
|
+
function unzipSync(data, opts) {
|
|
9059
|
+
var files = {};
|
|
9060
|
+
var e = data.length - 22;
|
|
9061
|
+
for (; b4(data, e) != 101010256; --e) {
|
|
9062
|
+
if (!e || data.length - e > 65558)
|
|
9063
|
+
err(13);
|
|
9064
|
+
}
|
|
9065
|
+
;
|
|
9066
|
+
var c = b2(data, e + 8);
|
|
9067
|
+
if (!c)
|
|
9068
|
+
return {};
|
|
9069
|
+
var o = b4(data, e + 16);
|
|
9070
|
+
var z = b4(data, e - 20) == 117853008;
|
|
9071
|
+
if (z) {
|
|
9072
|
+
var ze = b4(data, e - 12);
|
|
9073
|
+
z = b4(data, ze) == 101075792;
|
|
9074
|
+
if (z) {
|
|
9075
|
+
c = b4(data, ze + 32);
|
|
9076
|
+
o = b4(data, ze + 48);
|
|
9077
|
+
}
|
|
9078
|
+
}
|
|
9079
|
+
var fltr = opts && opts.filter;
|
|
9080
|
+
for (var i2 = 0; i2 < c; ++i2) {
|
|
9081
|
+
var _a2 = zh(data, o, z), c_2 = _a2[0], sc = _a2[1], su = _a2[2], fn = _a2[3], no = _a2[4], off = _a2[5], b = slzh(data, off);
|
|
9082
|
+
o = no;
|
|
9083
|
+
if (!fltr || fltr({
|
|
9084
|
+
name: fn,
|
|
9085
|
+
size: sc,
|
|
9086
|
+
originalSize: su,
|
|
9087
|
+
compression: c_2
|
|
9088
|
+
})) {
|
|
9089
|
+
if (!c_2)
|
|
9090
|
+
files[fn] = slc(data, b, b + sc);
|
|
9091
|
+
else if (c_2 == 8)
|
|
9092
|
+
files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
|
|
9093
|
+
else
|
|
9094
|
+
err(14, "unknown compression type " + c_2);
|
|
9095
|
+
}
|
|
9096
|
+
}
|
|
9097
|
+
return files;
|
|
9098
|
+
}
|
|
9099
|
+
|
|
9100
|
+
// src/openclaw/egg/persona-installer.ts
|
|
9101
|
+
var PersonaInstallError = class extends Error {
|
|
9102
|
+
constructor(message) {
|
|
9103
|
+
super(`[egg:install] ${message}`);
|
|
9104
|
+
this.name = "PersonaInstallError";
|
|
9105
|
+
}
|
|
9106
|
+
};
|
|
11010
9107
|
var PERSONA_FILES = ["IDENTITY.md", "SOUL.md", "AGENTS.md"];
|
|
11011
9108
|
var OPTIONAL_PERSONA_FILES = ["USER.md", "MEMORY.md"];
|
|
11012
9109
|
var ALL_PERSONA_FILES = [...PERSONA_FILES, ...OPTIONAL_PERSONA_FILES];
|
|
9110
|
+
var MAX_ARCHIVE_BYTES = 10 * 1024 * 1024;
|
|
9111
|
+
var MAX_PERSONA_FILE_BYTES = 1024 * 1024;
|
|
9112
|
+
var MAX_PERSONA_ENTRY_COUNT = ALL_PERSONA_FILES.length;
|
|
9113
|
+
var MAX_TOTAL_PERSONA_BYTES = 4 * 1024 * 1024;
|
|
11013
9114
|
function getWorkspaceRoot(agentName, openclawHome) {
|
|
11014
9115
|
return join9(openclawHome, `workspace-${agentName}`);
|
|
11015
9116
|
}
|
|
11016
9117
|
async function ensureWorkspaceDir(workspaceRoot) {
|
|
11017
9118
|
await mkdir(workspaceRoot, { recursive: true });
|
|
11018
9119
|
}
|
|
11019
|
-
|
|
11020
|
-
const
|
|
11021
|
-
|
|
11022
|
-
const
|
|
11023
|
-
|
|
11024
|
-
await (0, import_extract_zip.default)(zipPath, { dir: tmpDir });
|
|
11025
|
-
return tmpDir;
|
|
9120
|
+
function personaFileName(entryName) {
|
|
9121
|
+
const normalized = entryName.replace(/\\/g, "/");
|
|
9122
|
+
if (normalized.endsWith("/")) return void 0;
|
|
9123
|
+
const fileName = normalized.split("/").filter(Boolean).at(-1);
|
|
9124
|
+
return fileName && ALL_PERSONA_FILES.includes(fileName) ? fileName : void 0;
|
|
11026
9125
|
}
|
|
11027
|
-
|
|
9126
|
+
function readPersonaFilesFromZip(buffer) {
|
|
9127
|
+
if (buffer.byteLength > MAX_ARCHIVE_BYTES) {
|
|
9128
|
+
throw new PersonaInstallError(`package exceeds ${MAX_ARCHIVE_BYTES} bytes`);
|
|
9129
|
+
}
|
|
11028
9130
|
const result = /* @__PURE__ */ new Map();
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
9131
|
+
try {
|
|
9132
|
+
const selectedEntries = /* @__PURE__ */ new Map();
|
|
9133
|
+
let totalOriginalSize = 0;
|
|
9134
|
+
unzipSync(buffer, {
|
|
9135
|
+
filter(entry) {
|
|
9136
|
+
const fileName = personaFileName(entry.name);
|
|
9137
|
+
if (!fileName) return false;
|
|
9138
|
+
if (selectedEntries.has(fileName)) {
|
|
9139
|
+
throw new PersonaInstallError(`duplicate persona file: ${fileName}`);
|
|
9140
|
+
}
|
|
9141
|
+
if (selectedEntries.size >= MAX_PERSONA_ENTRY_COUNT) {
|
|
9142
|
+
throw new PersonaInstallError(`package contains too many persona files`);
|
|
9143
|
+
}
|
|
9144
|
+
if (entry.originalSize > MAX_PERSONA_FILE_BYTES) {
|
|
9145
|
+
throw new PersonaInstallError(`${fileName} exceeds ${MAX_PERSONA_FILE_BYTES} bytes`);
|
|
9146
|
+
}
|
|
9147
|
+
totalOriginalSize += entry.originalSize;
|
|
9148
|
+
if (totalOriginalSize > MAX_TOTAL_PERSONA_BYTES) {
|
|
9149
|
+
throw new PersonaInstallError(`persona content exceeds ${MAX_TOTAL_PERSONA_BYTES} bytes`);
|
|
9150
|
+
}
|
|
9151
|
+
selectedEntries.set(fileName, entry.name);
|
|
9152
|
+
return false;
|
|
9153
|
+
}
|
|
9154
|
+
});
|
|
9155
|
+
const entries2 = unzipSync(buffer, {
|
|
9156
|
+
filter(entry) {
|
|
9157
|
+
const fileName = personaFileName(entry.name);
|
|
9158
|
+
return fileName !== void 0 && selectedEntries.get(fileName) === entry.name;
|
|
9159
|
+
}
|
|
9160
|
+
});
|
|
9161
|
+
for (const [entryName, content] of Object.entries(entries2)) {
|
|
9162
|
+
const fileName = personaFileName(entryName);
|
|
9163
|
+
if (fileName) {
|
|
9164
|
+
result.set(fileName, strFromU8(content));
|
|
11038
9165
|
}
|
|
11039
|
-
} else if (ALL_PERSONA_FILES.includes(entry.name)) {
|
|
11040
|
-
result.set(entry.name, fullPath);
|
|
11041
9166
|
}
|
|
9167
|
+
} catch (err2) {
|
|
9168
|
+
if (err2 instanceof PersonaInstallError) throw err2;
|
|
9169
|
+
throw new PersonaInstallError(`invalid zip package: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
11042
9170
|
}
|
|
11043
9171
|
return result;
|
|
11044
9172
|
}
|
|
11045
9173
|
async function installPersonaFromZip(params) {
|
|
11046
9174
|
const { agentName, zipBuffer, openclawHome } = params;
|
|
11047
9175
|
const workspaceRoot = getWorkspaceRoot(agentName, openclawHome);
|
|
9176
|
+
const personaFiles = readPersonaFilesFromZip(zipBuffer);
|
|
11048
9177
|
await ensureWorkspaceDir(workspaceRoot);
|
|
11049
|
-
const tmpDir = await extractZipToTemp(zipBuffer);
|
|
11050
9178
|
const installedFiles = [];
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
const content = await loadFile(sourcePath, "utf-8");
|
|
11055
|
-
await writeFile(join9(workspaceRoot, fileName), content, "utf-8");
|
|
11056
|
-
installedFiles.push(fileName);
|
|
11057
|
-
}
|
|
11058
|
-
await ensureMinimalPersonaFiles(workspaceRoot, installedFiles);
|
|
11059
|
-
} finally {
|
|
11060
|
-
await rm(tmpDir, { recursive: true, force: true }).catch(() => {
|
|
11061
|
-
});
|
|
9179
|
+
for (const [fileName, content] of personaFiles) {
|
|
9180
|
+
await writeFile(join9(workspaceRoot, fileName), content, "utf-8");
|
|
9181
|
+
installedFiles.push(fileName);
|
|
11062
9182
|
}
|
|
9183
|
+
await ensureMinimalPersonaFiles(workspaceRoot, installedFiles);
|
|
11063
9184
|
return { installedFiles };
|
|
11064
9185
|
}
|
|
11065
9186
|
async function ensureMinimalPersonaFiles(workspaceRoot, existingFiles) {
|
|
@@ -11236,8 +9357,8 @@ async function runLocalBinding(params) {
|
|
|
11236
9357
|
throw new LocalBindingError("verification failed: agents bindings check failed");
|
|
11237
9358
|
}
|
|
11238
9359
|
result.ok = true;
|
|
11239
|
-
} catch (
|
|
11240
|
-
result.error =
|
|
9360
|
+
} catch (err2) {
|
|
9361
|
+
result.error = err2 instanceof Error ? err2.message : String(err2);
|
|
11241
9362
|
}
|
|
11242
9363
|
return result;
|
|
11243
9364
|
}
|
|
@@ -11477,8 +9598,8 @@ async function sendDeliveryMessage(params) {
|
|
|
11477
9598
|
await params.runtime.sendText(params.runtime.target, params.message);
|
|
11478
9599
|
attempt.ok = true;
|
|
11479
9600
|
attempt.error = void 0;
|
|
11480
|
-
} catch (
|
|
11481
|
-
attempt.error =
|
|
9601
|
+
} catch (err2) {
|
|
9602
|
+
attempt.error = err2 instanceof Error ? err2.message : String(err2);
|
|
11482
9603
|
}
|
|
11483
9604
|
params.state.delivery.attempts.push(attempt);
|
|
11484
9605
|
params.state.interaction_status = refreshInteractionStatus(params.state);
|
|
@@ -11861,14 +9982,14 @@ async function runEggOrchestrator(params) {
|
|
|
11861
9982
|
state.runtime.createdAgent = createdAgent2;
|
|
11862
9983
|
markStepDone(state, "create_or_resolve", "credentials ready");
|
|
11863
9984
|
await writeStateFile(stateFilePath, state);
|
|
11864
|
-
} catch (
|
|
9985
|
+
} catch (err2) {
|
|
11865
9986
|
return failAndPersist({
|
|
11866
9987
|
state,
|
|
11867
9988
|
stateFilePath,
|
|
11868
9989
|
request,
|
|
11869
9990
|
deliveryRuntime,
|
|
11870
9991
|
step: "create_or_resolve",
|
|
11871
|
-
error:
|
|
9992
|
+
error: err2 instanceof Error ? err2.message : String(err2),
|
|
11872
9993
|
reason: "Remote agent creation or credential resolution failed",
|
|
11873
9994
|
errorCode: "create_agent_failed"
|
|
11874
9995
|
});
|
|
@@ -11898,14 +10019,14 @@ async function runEggOrchestrator(params) {
|
|
|
11898
10019
|
});
|
|
11899
10020
|
markStepDone(state, "download", "package downloaded");
|
|
11900
10021
|
await writeStateFile(stateFilePath, state);
|
|
11901
|
-
} catch (
|
|
10022
|
+
} catch (err2) {
|
|
11902
10023
|
return failAndPersist({
|
|
11903
10024
|
state,
|
|
11904
10025
|
stateFilePath,
|
|
11905
10026
|
request,
|
|
11906
10027
|
deliveryRuntime,
|
|
11907
10028
|
step: "download",
|
|
11908
|
-
error:
|
|
10029
|
+
error: err2 instanceof Error ? err2.message : String(err2),
|
|
11909
10030
|
reason: "Failed to download package",
|
|
11910
10031
|
errorCode: "download_failed"
|
|
11911
10032
|
});
|
|
@@ -11919,14 +10040,14 @@ async function runEggOrchestrator(params) {
|
|
|
11919
10040
|
await writeSoulIfProvided(request, workspaceRoot);
|
|
11920
10041
|
markStepDone(state, "install", "persona installed");
|
|
11921
10042
|
await writeStateFile(stateFilePath, state);
|
|
11922
|
-
} catch (
|
|
10043
|
+
} catch (err2) {
|
|
11923
10044
|
return failAndPersist({
|
|
11924
10045
|
state,
|
|
11925
10046
|
stateFilePath,
|
|
11926
10047
|
request,
|
|
11927
10048
|
deliveryRuntime,
|
|
11928
10049
|
step: "install",
|
|
11929
|
-
error:
|
|
10050
|
+
error: err2 instanceof Error ? err2.message : String(err2),
|
|
11930
10051
|
reason: "Failed to install persona locally",
|
|
11931
10052
|
errorCode: "install_failed"
|
|
11932
10053
|
});
|
|
@@ -12059,14 +10180,14 @@ async function runEggOrchestrator(params) {
|
|
|
12059
10180
|
state.acceptance = acceptance;
|
|
12060
10181
|
markStepDone(state, "accept", "acceptance passed");
|
|
12061
10182
|
await writeStateFile(stateFilePath, state);
|
|
12062
|
-
} catch (
|
|
10183
|
+
} catch (err2) {
|
|
12063
10184
|
return failAndPersist({
|
|
12064
10185
|
state,
|
|
12065
10186
|
stateFilePath,
|
|
12066
10187
|
request,
|
|
12067
10188
|
deliveryRuntime,
|
|
12068
10189
|
step: "accept",
|
|
12069
|
-
error:
|
|
10190
|
+
error: err2 instanceof Error ? err2.message : String(err2),
|
|
12070
10191
|
reason: "Identity acceptance verification failed",
|
|
12071
10192
|
errorCode: "accept_failed"
|
|
12072
10193
|
});
|
|
@@ -12196,13 +10317,13 @@ function createGrixEggTool(api, ctx) {
|
|
|
12196
10317
|
deps: { api, ctx }
|
|
12197
10318
|
});
|
|
12198
10319
|
return jsonToolResult(result);
|
|
12199
|
-
} catch (
|
|
12200
|
-
if (
|
|
10320
|
+
} catch (err2) {
|
|
10321
|
+
if (err2 instanceof EggContextParseError) {
|
|
12201
10322
|
return jsonToolResult({
|
|
12202
10323
|
ok: false,
|
|
12203
10324
|
install_id: parseInstallIdHint(rawParams),
|
|
12204
10325
|
error_code: "parse_failed",
|
|
12205
|
-
reason:
|
|
10326
|
+
reason: err2.message,
|
|
12206
10327
|
suggestion: "Fix installContext/structured parameters and retry."
|
|
12207
10328
|
});
|
|
12208
10329
|
}
|
|
@@ -12210,7 +10331,7 @@ function createGrixEggTool(api, ctx) {
|
|
|
12210
10331
|
ok: false,
|
|
12211
10332
|
install_id: parseInstallIdHint(rawParams),
|
|
12212
10333
|
error_code: "internal_error",
|
|
12213
|
-
reason:
|
|
10334
|
+
reason: err2 instanceof Error ? err2.message : String(err2),
|
|
12214
10335
|
suggestion: "Fix based on the error message and retry; use resume for transient failures."
|
|
12215
10336
|
});
|
|
12216
10337
|
}
|
|
@@ -12233,16 +10354,16 @@ function createGrixRegisterTool(api, ctx) {
|
|
|
12233
10354
|
}
|
|
12234
10355
|
|
|
12235
10356
|
// src/openclaw/skill-tools/grix-update-tool.ts
|
|
12236
|
-
import { tmpdir
|
|
10357
|
+
import { tmpdir } from "node:os";
|
|
12237
10358
|
import { join as join12 } from "node:path";
|
|
12238
10359
|
|
|
12239
10360
|
// src/openclaw/skill-tools/timed-file-lock.ts
|
|
12240
10361
|
import { dirname as dirname7 } from "node:path";
|
|
12241
|
-
function getErrorCode(
|
|
12242
|
-
if (typeof
|
|
10362
|
+
function getErrorCode(err2) {
|
|
10363
|
+
if (typeof err2 !== "object" || err2 === null || !("code" in err2)) {
|
|
12243
10364
|
return void 0;
|
|
12244
10365
|
}
|
|
12245
|
-
const code =
|
|
10366
|
+
const code = err2.code;
|
|
12246
10367
|
return typeof code === "string" ? code : void 0;
|
|
12247
10368
|
}
|
|
12248
10369
|
function parseLockRecord(raw) {
|
|
@@ -12269,9 +10390,9 @@ async function readExistingLock(lockFilePath, ttlMs) {
|
|
|
12269
10390
|
expiresAt: parsed.expiresAt
|
|
12270
10391
|
};
|
|
12271
10392
|
}
|
|
12272
|
-
} catch (
|
|
12273
|
-
if (getErrorCode(
|
|
12274
|
-
throw
|
|
10393
|
+
} catch (err2) {
|
|
10394
|
+
if (getErrorCode(err2) !== "ENOENT") {
|
|
10395
|
+
throw err2;
|
|
12275
10396
|
}
|
|
12276
10397
|
return void 0;
|
|
12277
10398
|
}
|
|
@@ -12282,11 +10403,11 @@ async function readExistingLock(lockFilePath, ttlMs) {
|
|
|
12282
10403
|
createdAt,
|
|
12283
10404
|
expiresAt: createdAt + ttlMs
|
|
12284
10405
|
};
|
|
12285
|
-
} catch (
|
|
12286
|
-
if (getErrorCode(
|
|
10406
|
+
} catch (err2) {
|
|
10407
|
+
if (getErrorCode(err2) === "ENOENT") {
|
|
12287
10408
|
return void 0;
|
|
12288
10409
|
}
|
|
12289
|
-
throw
|
|
10410
|
+
throw err2;
|
|
12290
10411
|
}
|
|
12291
10412
|
}
|
|
12292
10413
|
async function tryAcquireTimedFileLock(options) {
|
|
@@ -12308,9 +10429,9 @@ async function tryAcquireTimedFileLock(options) {
|
|
|
12308
10429
|
createdAt,
|
|
12309
10430
|
expiresAt
|
|
12310
10431
|
};
|
|
12311
|
-
} catch (
|
|
12312
|
-
if (getErrorCode(
|
|
12313
|
-
throw
|
|
10432
|
+
} catch (err2) {
|
|
10433
|
+
if (getErrorCode(err2) !== "EEXIST") {
|
|
10434
|
+
throw err2;
|
|
12314
10435
|
}
|
|
12315
10436
|
}
|
|
12316
10437
|
const existingLock = await readExistingLock(options.lockFilePath, options.ttlMs);
|
|
@@ -12325,9 +10446,9 @@ async function tryAcquireTimedFileLock(options) {
|
|
|
12325
10446
|
}
|
|
12326
10447
|
try {
|
|
12327
10448
|
await unlink(options.lockFilePath);
|
|
12328
|
-
} catch (
|
|
12329
|
-
if (getErrorCode(
|
|
12330
|
-
throw
|
|
10449
|
+
} catch (err2) {
|
|
10450
|
+
if (getErrorCode(err2) !== "ENOENT") {
|
|
10451
|
+
throw err2;
|
|
12331
10452
|
}
|
|
12332
10453
|
}
|
|
12333
10454
|
}
|
|
@@ -12345,7 +10466,7 @@ function normalizeNonEmptyString2(value) {
|
|
|
12345
10466
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
12346
10467
|
}
|
|
12347
10468
|
function resolveGrixUpdateLockFilePath(lockFilePath) {
|
|
12348
|
-
return lockFilePath ?? join12(
|
|
10469
|
+
return lockFilePath ?? join12(tmpdir(), "grix-connector-update.lock");
|
|
12349
10470
|
}
|
|
12350
10471
|
function createGrixUpdateTool(api, ctx, options = {}) {
|
|
12351
10472
|
const delegatedTool = createDelegatedSkillTool({
|
|
@@ -12382,10 +10503,10 @@ function createGrixUpdateTool(api, ctx, options = {}) {
|
|
|
12382
10503
|
message: "[grix_update] skipped because another recent update request already covered this run."
|
|
12383
10504
|
});
|
|
12384
10505
|
}
|
|
12385
|
-
} catch (
|
|
10506
|
+
} catch (err2) {
|
|
12386
10507
|
return jsonToolResult({
|
|
12387
10508
|
ok: false,
|
|
12388
|
-
error:
|
|
10509
|
+
error: err2 instanceof Error ? err2.message : String(err2)
|
|
12389
10510
|
});
|
|
12390
10511
|
}
|
|
12391
10512
|
return delegatedTool.execute(toolCallId, rawParams);
|
|
@@ -12599,9 +10720,9 @@ async function ensureServer(host) {
|
|
|
12599
10720
|
if (server && serverHost === host) return;
|
|
12600
10721
|
if (server && serverHost !== host) await stopServer();
|
|
12601
10722
|
if (!startPromise) {
|
|
12602
|
-
startPromise = startServer(host).catch((
|
|
10723
|
+
startPromise = startServer(host).catch((err2) => {
|
|
12603
10724
|
startPromise = null;
|
|
12604
|
-
throw
|
|
10725
|
+
throw err2;
|
|
12605
10726
|
});
|
|
12606
10727
|
}
|
|
12607
10728
|
await startPromise;
|
|
@@ -12664,11 +10785,11 @@ async function handleFileServeAction(params) {
|
|
|
12664
10785
|
expires_at: served.expires_at
|
|
12665
10786
|
}
|
|
12666
10787
|
};
|
|
12667
|
-
} catch (
|
|
10788
|
+
} catch (err2) {
|
|
12668
10789
|
return {
|
|
12669
10790
|
status: "failed",
|
|
12670
10791
|
error_code: "serve_failed",
|
|
12671
|
-
error_msg:
|
|
10792
|
+
error_msg: err2 instanceof Error ? err2.message : String(err2)
|
|
12672
10793
|
};
|
|
12673
10794
|
}
|
|
12674
10795
|
}
|