@jamiexiongr/panda-hub 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/bin/panda-hub.cjs +3 -0
- package/dist/chunk-CS7XM33H.mjs +89 -0
- package/dist/{chunk-NPUEJ7HU.mjs → chunk-GPLVIR3L.mjs} +1510 -46
- package/dist/cli.mjs +9 -3
- package/dist/index.mjs +2 -2
- package/dist/{src-DT2GYCA4.mjs → src-LEEO2YLS.mjs} +23 -1
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/{diagnostics-page-DnSAjsY5.js → diagnostics-page-D4xGds9x.js} +1 -1
- package/dist/web/assets/index-CgfCWbq0.css +1 -0
- package/dist/web/assets/index-DxHRG-hx.js +130 -0
- package/dist/web/assets/{session-diff-preview-DLGNrbUv.js → session-diff-preview-Dg7a3ySE.js} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/maskable-512.png +0 -0
- package/dist/web/pwa-192.png +0 -0
- package/dist/web/pwa-512.png +0 -0
- package/dist/web/pwa-home-logo.png +0 -0
- package/dist/web/sw.js +1 -1
- package/package.json +3 -2
- package/dist/chunk-HEZ5JMF3.mjs +0 -55
- package/dist/web/assets/index-C_piwCwO.js +0 -124
- package/dist/web/assets/index-DfUcIUg_.css +0 -1
|
@@ -1,15 +1,1109 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
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 __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
2
10
|
var __export = (target, all) => {
|
|
3
11
|
for (var name in all)
|
|
4
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
13
|
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js
|
|
32
|
+
var require_QRMode = __commonJS({
|
|
33
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js"(exports, module) {
|
|
34
|
+
module.exports = {
|
|
35
|
+
MODE_NUMBER: 1 << 0,
|
|
36
|
+
MODE_ALPHA_NUM: 1 << 1,
|
|
37
|
+
MODE_8BIT_BYTE: 1 << 2,
|
|
38
|
+
MODE_KANJI: 1 << 3
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js
|
|
44
|
+
var require_QR8bitByte = __commonJS({
|
|
45
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js"(exports, module) {
|
|
46
|
+
var QRMode = require_QRMode();
|
|
47
|
+
function QR8bitByte(data) {
|
|
48
|
+
this.mode = QRMode.MODE_8BIT_BYTE;
|
|
49
|
+
this.data = data;
|
|
50
|
+
}
|
|
51
|
+
QR8bitByte.prototype = {
|
|
52
|
+
getLength: function() {
|
|
53
|
+
return this.data.length;
|
|
54
|
+
},
|
|
55
|
+
write: function(buffer) {
|
|
56
|
+
for (var i = 0; i < this.data.length; i++) {
|
|
57
|
+
buffer.put(this.data.charCodeAt(i), 8);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
module.exports = QR8bitByte;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js
|
|
66
|
+
var require_QRMath = __commonJS({
|
|
67
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js"(exports, module) {
|
|
68
|
+
var QRMath = {
|
|
69
|
+
glog: function(n) {
|
|
70
|
+
if (n < 1) {
|
|
71
|
+
throw new Error("glog(" + n + ")");
|
|
72
|
+
}
|
|
73
|
+
return QRMath.LOG_TABLE[n];
|
|
74
|
+
},
|
|
75
|
+
gexp: function(n) {
|
|
76
|
+
while (n < 0) {
|
|
77
|
+
n += 255;
|
|
78
|
+
}
|
|
79
|
+
while (n >= 256) {
|
|
80
|
+
n -= 255;
|
|
81
|
+
}
|
|
82
|
+
return QRMath.EXP_TABLE[n];
|
|
83
|
+
},
|
|
84
|
+
EXP_TABLE: new Array(256),
|
|
85
|
+
LOG_TABLE: new Array(256)
|
|
86
|
+
};
|
|
87
|
+
for (i = 0; i < 8; i++) {
|
|
88
|
+
QRMath.EXP_TABLE[i] = 1 << i;
|
|
89
|
+
}
|
|
90
|
+
var i;
|
|
91
|
+
for (i = 8; i < 256; i++) {
|
|
92
|
+
QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
|
|
93
|
+
}
|
|
94
|
+
var i;
|
|
95
|
+
for (i = 0; i < 255; i++) {
|
|
96
|
+
QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
|
|
97
|
+
}
|
|
98
|
+
var i;
|
|
99
|
+
module.exports = QRMath;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js
|
|
104
|
+
var require_QRPolynomial = __commonJS({
|
|
105
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js"(exports, module) {
|
|
106
|
+
var QRMath = require_QRMath();
|
|
107
|
+
function QRPolynomial(num, shift) {
|
|
108
|
+
if (num.length === void 0) {
|
|
109
|
+
throw new Error(num.length + "/" + shift);
|
|
110
|
+
}
|
|
111
|
+
var offset = 0;
|
|
112
|
+
while (offset < num.length && num[offset] === 0) {
|
|
113
|
+
offset++;
|
|
114
|
+
}
|
|
115
|
+
this.num = new Array(num.length - offset + shift);
|
|
116
|
+
for (var i = 0; i < num.length - offset; i++) {
|
|
117
|
+
this.num[i] = num[i + offset];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
QRPolynomial.prototype = {
|
|
121
|
+
get: function(index) {
|
|
122
|
+
return this.num[index];
|
|
123
|
+
},
|
|
124
|
+
getLength: function() {
|
|
125
|
+
return this.num.length;
|
|
126
|
+
},
|
|
127
|
+
multiply: function(e) {
|
|
128
|
+
var num = new Array(this.getLength() + e.getLength() - 1);
|
|
129
|
+
for (var i = 0; i < this.getLength(); i++) {
|
|
130
|
+
for (var j = 0; j < e.getLength(); j++) {
|
|
131
|
+
num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return new QRPolynomial(num, 0);
|
|
135
|
+
},
|
|
136
|
+
mod: function(e) {
|
|
137
|
+
if (this.getLength() - e.getLength() < 0) {
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0));
|
|
141
|
+
var num = new Array(this.getLength());
|
|
142
|
+
for (var i = 0; i < this.getLength(); i++) {
|
|
143
|
+
num[i] = this.get(i);
|
|
144
|
+
}
|
|
145
|
+
for (var x = 0; x < e.getLength(); x++) {
|
|
146
|
+
num[x] ^= QRMath.gexp(QRMath.glog(e.get(x)) + ratio);
|
|
147
|
+
}
|
|
148
|
+
return new QRPolynomial(num, 0).mod(e);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
module.exports = QRPolynomial;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js
|
|
156
|
+
var require_QRMaskPattern = __commonJS({
|
|
157
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js"(exports, module) {
|
|
158
|
+
module.exports = {
|
|
159
|
+
PATTERN000: 0,
|
|
160
|
+
PATTERN001: 1,
|
|
161
|
+
PATTERN010: 2,
|
|
162
|
+
PATTERN011: 3,
|
|
163
|
+
PATTERN100: 4,
|
|
164
|
+
PATTERN101: 5,
|
|
165
|
+
PATTERN110: 6,
|
|
166
|
+
PATTERN111: 7
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js
|
|
172
|
+
var require_QRUtil = __commonJS({
|
|
173
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js"(exports, module) {
|
|
174
|
+
var QRMode = require_QRMode();
|
|
175
|
+
var QRPolynomial = require_QRPolynomial();
|
|
176
|
+
var QRMath = require_QRMath();
|
|
177
|
+
var QRMaskPattern = require_QRMaskPattern();
|
|
178
|
+
var QRUtil = {
|
|
179
|
+
PATTERN_POSITION_TABLE: [
|
|
180
|
+
[],
|
|
181
|
+
[6, 18],
|
|
182
|
+
[6, 22],
|
|
183
|
+
[6, 26],
|
|
184
|
+
[6, 30],
|
|
185
|
+
[6, 34],
|
|
186
|
+
[6, 22, 38],
|
|
187
|
+
[6, 24, 42],
|
|
188
|
+
[6, 26, 46],
|
|
189
|
+
[6, 28, 50],
|
|
190
|
+
[6, 30, 54],
|
|
191
|
+
[6, 32, 58],
|
|
192
|
+
[6, 34, 62],
|
|
193
|
+
[6, 26, 46, 66],
|
|
194
|
+
[6, 26, 48, 70],
|
|
195
|
+
[6, 26, 50, 74],
|
|
196
|
+
[6, 30, 54, 78],
|
|
197
|
+
[6, 30, 56, 82],
|
|
198
|
+
[6, 30, 58, 86],
|
|
199
|
+
[6, 34, 62, 90],
|
|
200
|
+
[6, 28, 50, 72, 94],
|
|
201
|
+
[6, 26, 50, 74, 98],
|
|
202
|
+
[6, 30, 54, 78, 102],
|
|
203
|
+
[6, 28, 54, 80, 106],
|
|
204
|
+
[6, 32, 58, 84, 110],
|
|
205
|
+
[6, 30, 58, 86, 114],
|
|
206
|
+
[6, 34, 62, 90, 118],
|
|
207
|
+
[6, 26, 50, 74, 98, 122],
|
|
208
|
+
[6, 30, 54, 78, 102, 126],
|
|
209
|
+
[6, 26, 52, 78, 104, 130],
|
|
210
|
+
[6, 30, 56, 82, 108, 134],
|
|
211
|
+
[6, 34, 60, 86, 112, 138],
|
|
212
|
+
[6, 30, 58, 86, 114, 142],
|
|
213
|
+
[6, 34, 62, 90, 118, 146],
|
|
214
|
+
[6, 30, 54, 78, 102, 126, 150],
|
|
215
|
+
[6, 24, 50, 76, 102, 128, 154],
|
|
216
|
+
[6, 28, 54, 80, 106, 132, 158],
|
|
217
|
+
[6, 32, 58, 84, 110, 136, 162],
|
|
218
|
+
[6, 26, 54, 82, 110, 138, 166],
|
|
219
|
+
[6, 30, 58, 86, 114, 142, 170]
|
|
220
|
+
],
|
|
221
|
+
G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0,
|
|
222
|
+
G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,
|
|
223
|
+
G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,
|
|
224
|
+
getBCHTypeInfo: function(data) {
|
|
225
|
+
var d = data << 10;
|
|
226
|
+
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
|
|
227
|
+
d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
|
|
228
|
+
}
|
|
229
|
+
return (data << 10 | d) ^ QRUtil.G15_MASK;
|
|
230
|
+
},
|
|
231
|
+
getBCHTypeNumber: function(data) {
|
|
232
|
+
var d = data << 12;
|
|
233
|
+
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
|
|
234
|
+
d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
|
|
235
|
+
}
|
|
236
|
+
return data << 12 | d;
|
|
237
|
+
},
|
|
238
|
+
getBCHDigit: function(data) {
|
|
239
|
+
var digit = 0;
|
|
240
|
+
while (data !== 0) {
|
|
241
|
+
digit++;
|
|
242
|
+
data >>>= 1;
|
|
243
|
+
}
|
|
244
|
+
return digit;
|
|
245
|
+
},
|
|
246
|
+
getPatternPosition: function(typeNumber) {
|
|
247
|
+
return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
248
|
+
},
|
|
249
|
+
getMask: function(maskPattern, i, j) {
|
|
250
|
+
switch (maskPattern) {
|
|
251
|
+
case QRMaskPattern.PATTERN000:
|
|
252
|
+
return (i + j) % 2 === 0;
|
|
253
|
+
case QRMaskPattern.PATTERN001:
|
|
254
|
+
return i % 2 === 0;
|
|
255
|
+
case QRMaskPattern.PATTERN010:
|
|
256
|
+
return j % 3 === 0;
|
|
257
|
+
case QRMaskPattern.PATTERN011:
|
|
258
|
+
return (i + j) % 3 === 0;
|
|
259
|
+
case QRMaskPattern.PATTERN100:
|
|
260
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
261
|
+
case QRMaskPattern.PATTERN101:
|
|
262
|
+
return i * j % 2 + i * j % 3 === 0;
|
|
263
|
+
case QRMaskPattern.PATTERN110:
|
|
264
|
+
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
265
|
+
case QRMaskPattern.PATTERN111:
|
|
266
|
+
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
267
|
+
default:
|
|
268
|
+
throw new Error("bad maskPattern:" + maskPattern);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
getErrorCorrectPolynomial: function(errorCorrectLength) {
|
|
272
|
+
var a = new QRPolynomial([1], 0);
|
|
273
|
+
for (var i = 0; i < errorCorrectLength; i++) {
|
|
274
|
+
a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
|
|
275
|
+
}
|
|
276
|
+
return a;
|
|
277
|
+
},
|
|
278
|
+
getLengthInBits: function(mode, type) {
|
|
279
|
+
if (1 <= type && type < 10) {
|
|
280
|
+
switch (mode) {
|
|
281
|
+
case QRMode.MODE_NUMBER:
|
|
282
|
+
return 10;
|
|
283
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
284
|
+
return 9;
|
|
285
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
286
|
+
return 8;
|
|
287
|
+
case QRMode.MODE_KANJI:
|
|
288
|
+
return 8;
|
|
289
|
+
default:
|
|
290
|
+
throw new Error("mode:" + mode);
|
|
291
|
+
}
|
|
292
|
+
} else if (type < 27) {
|
|
293
|
+
switch (mode) {
|
|
294
|
+
case QRMode.MODE_NUMBER:
|
|
295
|
+
return 12;
|
|
296
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
297
|
+
return 11;
|
|
298
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
299
|
+
return 16;
|
|
300
|
+
case QRMode.MODE_KANJI:
|
|
301
|
+
return 10;
|
|
302
|
+
default:
|
|
303
|
+
throw new Error("mode:" + mode);
|
|
304
|
+
}
|
|
305
|
+
} else if (type < 41) {
|
|
306
|
+
switch (mode) {
|
|
307
|
+
case QRMode.MODE_NUMBER:
|
|
308
|
+
return 14;
|
|
309
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
310
|
+
return 13;
|
|
311
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
312
|
+
return 16;
|
|
313
|
+
case QRMode.MODE_KANJI:
|
|
314
|
+
return 12;
|
|
315
|
+
default:
|
|
316
|
+
throw new Error("mode:" + mode);
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
throw new Error("type:" + type);
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
getLostPoint: function(qrCode) {
|
|
323
|
+
var moduleCount = qrCode.getModuleCount();
|
|
324
|
+
var lostPoint = 0;
|
|
325
|
+
var row = 0;
|
|
326
|
+
var col = 0;
|
|
327
|
+
for (row = 0; row < moduleCount; row++) {
|
|
328
|
+
for (col = 0; col < moduleCount; col++) {
|
|
329
|
+
var sameCount = 0;
|
|
330
|
+
var dark = qrCode.isDark(row, col);
|
|
331
|
+
for (var r = -1; r <= 1; r++) {
|
|
332
|
+
if (row + r < 0 || moduleCount <= row + r) {
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
for (var c = -1; c <= 1; c++) {
|
|
336
|
+
if (col + c < 0 || moduleCount <= col + c) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (r === 0 && c === 0) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (dark === qrCode.isDark(row + r, col + c)) {
|
|
343
|
+
sameCount++;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (sameCount > 5) {
|
|
348
|
+
lostPoint += 3 + sameCount - 5;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
for (row = 0; row < moduleCount - 1; row++) {
|
|
353
|
+
for (col = 0; col < moduleCount - 1; col++) {
|
|
354
|
+
var count = 0;
|
|
355
|
+
if (qrCode.isDark(row, col)) count++;
|
|
356
|
+
if (qrCode.isDark(row + 1, col)) count++;
|
|
357
|
+
if (qrCode.isDark(row, col + 1)) count++;
|
|
358
|
+
if (qrCode.isDark(row + 1, col + 1)) count++;
|
|
359
|
+
if (count === 0 || count === 4) {
|
|
360
|
+
lostPoint += 3;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
for (row = 0; row < moduleCount; row++) {
|
|
365
|
+
for (col = 0; col < moduleCount - 6; col++) {
|
|
366
|
+
if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) {
|
|
367
|
+
lostPoint += 40;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
for (col = 0; col < moduleCount; col++) {
|
|
372
|
+
for (row = 0; row < moduleCount - 6; row++) {
|
|
373
|
+
if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) {
|
|
374
|
+
lostPoint += 40;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
var darkCount = 0;
|
|
379
|
+
for (col = 0; col < moduleCount; col++) {
|
|
380
|
+
for (row = 0; row < moduleCount; row++) {
|
|
381
|
+
if (qrCode.isDark(row, col)) {
|
|
382
|
+
darkCount++;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
|
|
387
|
+
lostPoint += ratio * 10;
|
|
388
|
+
return lostPoint;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
module.exports = QRUtil;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js
|
|
396
|
+
var require_QRErrorCorrectLevel = __commonJS({
|
|
397
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js"(exports, module) {
|
|
398
|
+
module.exports = {
|
|
399
|
+
L: 1,
|
|
400
|
+
M: 0,
|
|
401
|
+
Q: 3,
|
|
402
|
+
H: 2
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js
|
|
408
|
+
var require_QRRSBlock = __commonJS({
|
|
409
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js"(exports, module) {
|
|
410
|
+
var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
|
|
411
|
+
function QRRSBlock(totalCount, dataCount) {
|
|
412
|
+
this.totalCount = totalCount;
|
|
413
|
+
this.dataCount = dataCount;
|
|
414
|
+
}
|
|
415
|
+
QRRSBlock.RS_BLOCK_TABLE = [
|
|
416
|
+
// L
|
|
417
|
+
// M
|
|
418
|
+
// Q
|
|
419
|
+
// H
|
|
420
|
+
// 1
|
|
421
|
+
[1, 26, 19],
|
|
422
|
+
[1, 26, 16],
|
|
423
|
+
[1, 26, 13],
|
|
424
|
+
[1, 26, 9],
|
|
425
|
+
// 2
|
|
426
|
+
[1, 44, 34],
|
|
427
|
+
[1, 44, 28],
|
|
428
|
+
[1, 44, 22],
|
|
429
|
+
[1, 44, 16],
|
|
430
|
+
// 3
|
|
431
|
+
[1, 70, 55],
|
|
432
|
+
[1, 70, 44],
|
|
433
|
+
[2, 35, 17],
|
|
434
|
+
[2, 35, 13],
|
|
435
|
+
// 4
|
|
436
|
+
[1, 100, 80],
|
|
437
|
+
[2, 50, 32],
|
|
438
|
+
[2, 50, 24],
|
|
439
|
+
[4, 25, 9],
|
|
440
|
+
// 5
|
|
441
|
+
[1, 134, 108],
|
|
442
|
+
[2, 67, 43],
|
|
443
|
+
[2, 33, 15, 2, 34, 16],
|
|
444
|
+
[2, 33, 11, 2, 34, 12],
|
|
445
|
+
// 6
|
|
446
|
+
[2, 86, 68],
|
|
447
|
+
[4, 43, 27],
|
|
448
|
+
[4, 43, 19],
|
|
449
|
+
[4, 43, 15],
|
|
450
|
+
// 7
|
|
451
|
+
[2, 98, 78],
|
|
452
|
+
[4, 49, 31],
|
|
453
|
+
[2, 32, 14, 4, 33, 15],
|
|
454
|
+
[4, 39, 13, 1, 40, 14],
|
|
455
|
+
// 8
|
|
456
|
+
[2, 121, 97],
|
|
457
|
+
[2, 60, 38, 2, 61, 39],
|
|
458
|
+
[4, 40, 18, 2, 41, 19],
|
|
459
|
+
[4, 40, 14, 2, 41, 15],
|
|
460
|
+
// 9
|
|
461
|
+
[2, 146, 116],
|
|
462
|
+
[3, 58, 36, 2, 59, 37],
|
|
463
|
+
[4, 36, 16, 4, 37, 17],
|
|
464
|
+
[4, 36, 12, 4, 37, 13],
|
|
465
|
+
// 10
|
|
466
|
+
[2, 86, 68, 2, 87, 69],
|
|
467
|
+
[4, 69, 43, 1, 70, 44],
|
|
468
|
+
[6, 43, 19, 2, 44, 20],
|
|
469
|
+
[6, 43, 15, 2, 44, 16],
|
|
470
|
+
// 11
|
|
471
|
+
[4, 101, 81],
|
|
472
|
+
[1, 80, 50, 4, 81, 51],
|
|
473
|
+
[4, 50, 22, 4, 51, 23],
|
|
474
|
+
[3, 36, 12, 8, 37, 13],
|
|
475
|
+
// 12
|
|
476
|
+
[2, 116, 92, 2, 117, 93],
|
|
477
|
+
[6, 58, 36, 2, 59, 37],
|
|
478
|
+
[4, 46, 20, 6, 47, 21],
|
|
479
|
+
[7, 42, 14, 4, 43, 15],
|
|
480
|
+
// 13
|
|
481
|
+
[4, 133, 107],
|
|
482
|
+
[8, 59, 37, 1, 60, 38],
|
|
483
|
+
[8, 44, 20, 4, 45, 21],
|
|
484
|
+
[12, 33, 11, 4, 34, 12],
|
|
485
|
+
// 14
|
|
486
|
+
[3, 145, 115, 1, 146, 116],
|
|
487
|
+
[4, 64, 40, 5, 65, 41],
|
|
488
|
+
[11, 36, 16, 5, 37, 17],
|
|
489
|
+
[11, 36, 12, 5, 37, 13],
|
|
490
|
+
// 15
|
|
491
|
+
[5, 109, 87, 1, 110, 88],
|
|
492
|
+
[5, 65, 41, 5, 66, 42],
|
|
493
|
+
[5, 54, 24, 7, 55, 25],
|
|
494
|
+
[11, 36, 12],
|
|
495
|
+
// 16
|
|
496
|
+
[5, 122, 98, 1, 123, 99],
|
|
497
|
+
[7, 73, 45, 3, 74, 46],
|
|
498
|
+
[15, 43, 19, 2, 44, 20],
|
|
499
|
+
[3, 45, 15, 13, 46, 16],
|
|
500
|
+
// 17
|
|
501
|
+
[1, 135, 107, 5, 136, 108],
|
|
502
|
+
[10, 74, 46, 1, 75, 47],
|
|
503
|
+
[1, 50, 22, 15, 51, 23],
|
|
504
|
+
[2, 42, 14, 17, 43, 15],
|
|
505
|
+
// 18
|
|
506
|
+
[5, 150, 120, 1, 151, 121],
|
|
507
|
+
[9, 69, 43, 4, 70, 44],
|
|
508
|
+
[17, 50, 22, 1, 51, 23],
|
|
509
|
+
[2, 42, 14, 19, 43, 15],
|
|
510
|
+
// 19
|
|
511
|
+
[3, 141, 113, 4, 142, 114],
|
|
512
|
+
[3, 70, 44, 11, 71, 45],
|
|
513
|
+
[17, 47, 21, 4, 48, 22],
|
|
514
|
+
[9, 39, 13, 16, 40, 14],
|
|
515
|
+
// 20
|
|
516
|
+
[3, 135, 107, 5, 136, 108],
|
|
517
|
+
[3, 67, 41, 13, 68, 42],
|
|
518
|
+
[15, 54, 24, 5, 55, 25],
|
|
519
|
+
[15, 43, 15, 10, 44, 16],
|
|
520
|
+
// 21
|
|
521
|
+
[4, 144, 116, 4, 145, 117],
|
|
522
|
+
[17, 68, 42],
|
|
523
|
+
[17, 50, 22, 6, 51, 23],
|
|
524
|
+
[19, 46, 16, 6, 47, 17],
|
|
525
|
+
// 22
|
|
526
|
+
[2, 139, 111, 7, 140, 112],
|
|
527
|
+
[17, 74, 46],
|
|
528
|
+
[7, 54, 24, 16, 55, 25],
|
|
529
|
+
[34, 37, 13],
|
|
530
|
+
// 23
|
|
531
|
+
[4, 151, 121, 5, 152, 122],
|
|
532
|
+
[4, 75, 47, 14, 76, 48],
|
|
533
|
+
[11, 54, 24, 14, 55, 25],
|
|
534
|
+
[16, 45, 15, 14, 46, 16],
|
|
535
|
+
// 24
|
|
536
|
+
[6, 147, 117, 4, 148, 118],
|
|
537
|
+
[6, 73, 45, 14, 74, 46],
|
|
538
|
+
[11, 54, 24, 16, 55, 25],
|
|
539
|
+
[30, 46, 16, 2, 47, 17],
|
|
540
|
+
// 25
|
|
541
|
+
[8, 132, 106, 4, 133, 107],
|
|
542
|
+
[8, 75, 47, 13, 76, 48],
|
|
543
|
+
[7, 54, 24, 22, 55, 25],
|
|
544
|
+
[22, 45, 15, 13, 46, 16],
|
|
545
|
+
// 26
|
|
546
|
+
[10, 142, 114, 2, 143, 115],
|
|
547
|
+
[19, 74, 46, 4, 75, 47],
|
|
548
|
+
[28, 50, 22, 6, 51, 23],
|
|
549
|
+
[33, 46, 16, 4, 47, 17],
|
|
550
|
+
// 27
|
|
551
|
+
[8, 152, 122, 4, 153, 123],
|
|
552
|
+
[22, 73, 45, 3, 74, 46],
|
|
553
|
+
[8, 53, 23, 26, 54, 24],
|
|
554
|
+
[12, 45, 15, 28, 46, 16],
|
|
555
|
+
// 28
|
|
556
|
+
[3, 147, 117, 10, 148, 118],
|
|
557
|
+
[3, 73, 45, 23, 74, 46],
|
|
558
|
+
[4, 54, 24, 31, 55, 25],
|
|
559
|
+
[11, 45, 15, 31, 46, 16],
|
|
560
|
+
// 29
|
|
561
|
+
[7, 146, 116, 7, 147, 117],
|
|
562
|
+
[21, 73, 45, 7, 74, 46],
|
|
563
|
+
[1, 53, 23, 37, 54, 24],
|
|
564
|
+
[19, 45, 15, 26, 46, 16],
|
|
565
|
+
// 30
|
|
566
|
+
[5, 145, 115, 10, 146, 116],
|
|
567
|
+
[19, 75, 47, 10, 76, 48],
|
|
568
|
+
[15, 54, 24, 25, 55, 25],
|
|
569
|
+
[23, 45, 15, 25, 46, 16],
|
|
570
|
+
// 31
|
|
571
|
+
[13, 145, 115, 3, 146, 116],
|
|
572
|
+
[2, 74, 46, 29, 75, 47],
|
|
573
|
+
[42, 54, 24, 1, 55, 25],
|
|
574
|
+
[23, 45, 15, 28, 46, 16],
|
|
575
|
+
// 32
|
|
576
|
+
[17, 145, 115],
|
|
577
|
+
[10, 74, 46, 23, 75, 47],
|
|
578
|
+
[10, 54, 24, 35, 55, 25],
|
|
579
|
+
[19, 45, 15, 35, 46, 16],
|
|
580
|
+
// 33
|
|
581
|
+
[17, 145, 115, 1, 146, 116],
|
|
582
|
+
[14, 74, 46, 21, 75, 47],
|
|
583
|
+
[29, 54, 24, 19, 55, 25],
|
|
584
|
+
[11, 45, 15, 46, 46, 16],
|
|
585
|
+
// 34
|
|
586
|
+
[13, 145, 115, 6, 146, 116],
|
|
587
|
+
[14, 74, 46, 23, 75, 47],
|
|
588
|
+
[44, 54, 24, 7, 55, 25],
|
|
589
|
+
[59, 46, 16, 1, 47, 17],
|
|
590
|
+
// 35
|
|
591
|
+
[12, 151, 121, 7, 152, 122],
|
|
592
|
+
[12, 75, 47, 26, 76, 48],
|
|
593
|
+
[39, 54, 24, 14, 55, 25],
|
|
594
|
+
[22, 45, 15, 41, 46, 16],
|
|
595
|
+
// 36
|
|
596
|
+
[6, 151, 121, 14, 152, 122],
|
|
597
|
+
[6, 75, 47, 34, 76, 48],
|
|
598
|
+
[46, 54, 24, 10, 55, 25],
|
|
599
|
+
[2, 45, 15, 64, 46, 16],
|
|
600
|
+
// 37
|
|
601
|
+
[17, 152, 122, 4, 153, 123],
|
|
602
|
+
[29, 74, 46, 14, 75, 47],
|
|
603
|
+
[49, 54, 24, 10, 55, 25],
|
|
604
|
+
[24, 45, 15, 46, 46, 16],
|
|
605
|
+
// 38
|
|
606
|
+
[4, 152, 122, 18, 153, 123],
|
|
607
|
+
[13, 74, 46, 32, 75, 47],
|
|
608
|
+
[48, 54, 24, 14, 55, 25],
|
|
609
|
+
[42, 45, 15, 32, 46, 16],
|
|
610
|
+
// 39
|
|
611
|
+
[20, 147, 117, 4, 148, 118],
|
|
612
|
+
[40, 75, 47, 7, 76, 48],
|
|
613
|
+
[43, 54, 24, 22, 55, 25],
|
|
614
|
+
[10, 45, 15, 67, 46, 16],
|
|
615
|
+
// 40
|
|
616
|
+
[19, 148, 118, 6, 149, 119],
|
|
617
|
+
[18, 75, 47, 31, 76, 48],
|
|
618
|
+
[34, 54, 24, 34, 55, 25],
|
|
619
|
+
[20, 45, 15, 61, 46, 16]
|
|
620
|
+
];
|
|
621
|
+
QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
|
|
622
|
+
var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
|
|
623
|
+
if (rsBlock === void 0) {
|
|
624
|
+
throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
|
|
625
|
+
}
|
|
626
|
+
var length = rsBlock.length / 3;
|
|
627
|
+
var list = [];
|
|
628
|
+
for (var i = 0; i < length; i++) {
|
|
629
|
+
var count = rsBlock[i * 3 + 0];
|
|
630
|
+
var totalCount = rsBlock[i * 3 + 1];
|
|
631
|
+
var dataCount = rsBlock[i * 3 + 2];
|
|
632
|
+
for (var j = 0; j < count; j++) {
|
|
633
|
+
list.push(new QRRSBlock(totalCount, dataCount));
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return list;
|
|
637
|
+
};
|
|
638
|
+
QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
|
|
639
|
+
switch (errorCorrectLevel) {
|
|
640
|
+
case QRErrorCorrectLevel.L:
|
|
641
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
|
|
642
|
+
case QRErrorCorrectLevel.M:
|
|
643
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
|
|
644
|
+
case QRErrorCorrectLevel.Q:
|
|
645
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
|
|
646
|
+
case QRErrorCorrectLevel.H:
|
|
647
|
+
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
|
|
648
|
+
default:
|
|
649
|
+
return void 0;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
module.exports = QRRSBlock;
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js
|
|
657
|
+
var require_QRBitBuffer = __commonJS({
|
|
658
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js"(exports, module) {
|
|
659
|
+
function QRBitBuffer() {
|
|
660
|
+
this.buffer = [];
|
|
661
|
+
this.length = 0;
|
|
662
|
+
}
|
|
663
|
+
QRBitBuffer.prototype = {
|
|
664
|
+
get: function(index) {
|
|
665
|
+
var bufIndex = Math.floor(index / 8);
|
|
666
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
|
|
667
|
+
},
|
|
668
|
+
put: function(num, length) {
|
|
669
|
+
for (var i = 0; i < length; i++) {
|
|
670
|
+
this.putBit((num >>> length - i - 1 & 1) == 1);
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
getLengthInBits: function() {
|
|
674
|
+
return this.length;
|
|
675
|
+
},
|
|
676
|
+
putBit: function(bit) {
|
|
677
|
+
var bufIndex = Math.floor(this.length / 8);
|
|
678
|
+
if (this.buffer.length <= bufIndex) {
|
|
679
|
+
this.buffer.push(0);
|
|
680
|
+
}
|
|
681
|
+
if (bit) {
|
|
682
|
+
this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
683
|
+
}
|
|
684
|
+
this.length++;
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
module.exports = QRBitBuffer;
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/index.js
|
|
692
|
+
var require_QRCode = __commonJS({
|
|
693
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/index.js"(exports, module) {
|
|
694
|
+
var QR8bitByte = require_QR8bitByte();
|
|
695
|
+
var QRUtil = require_QRUtil();
|
|
696
|
+
var QRPolynomial = require_QRPolynomial();
|
|
697
|
+
var QRRSBlock = require_QRRSBlock();
|
|
698
|
+
var QRBitBuffer = require_QRBitBuffer();
|
|
699
|
+
function QRCode(typeNumber, errorCorrectLevel) {
|
|
700
|
+
this.typeNumber = typeNumber;
|
|
701
|
+
this.errorCorrectLevel = errorCorrectLevel;
|
|
702
|
+
this.modules = null;
|
|
703
|
+
this.moduleCount = 0;
|
|
704
|
+
this.dataCache = null;
|
|
705
|
+
this.dataList = [];
|
|
706
|
+
}
|
|
707
|
+
QRCode.prototype = {
|
|
708
|
+
addData: function(data) {
|
|
709
|
+
var newData = new QR8bitByte(data);
|
|
710
|
+
this.dataList.push(newData);
|
|
711
|
+
this.dataCache = null;
|
|
712
|
+
},
|
|
713
|
+
isDark: function(row, col) {
|
|
714
|
+
if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
|
|
715
|
+
throw new Error(row + "," + col);
|
|
716
|
+
}
|
|
717
|
+
return this.modules[row][col];
|
|
718
|
+
},
|
|
719
|
+
getModuleCount: function() {
|
|
720
|
+
return this.moduleCount;
|
|
721
|
+
},
|
|
722
|
+
make: function() {
|
|
723
|
+
if (this.typeNumber < 1) {
|
|
724
|
+
var typeNumber = 1;
|
|
725
|
+
for (typeNumber = 1; typeNumber < 40; typeNumber++) {
|
|
726
|
+
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
|
|
727
|
+
var buffer = new QRBitBuffer();
|
|
728
|
+
var totalDataCount = 0;
|
|
729
|
+
for (var i = 0; i < rsBlocks.length; i++) {
|
|
730
|
+
totalDataCount += rsBlocks[i].dataCount;
|
|
731
|
+
}
|
|
732
|
+
for (var x = 0; x < this.dataList.length; x++) {
|
|
733
|
+
var data = this.dataList[x];
|
|
734
|
+
buffer.put(data.mode, 4);
|
|
735
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
|
|
736
|
+
data.write(buffer);
|
|
737
|
+
}
|
|
738
|
+
if (buffer.getLengthInBits() <= totalDataCount * 8)
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
this.typeNumber = typeNumber;
|
|
742
|
+
}
|
|
743
|
+
this.makeImpl(false, this.getBestMaskPattern());
|
|
744
|
+
},
|
|
745
|
+
makeImpl: function(test, maskPattern) {
|
|
746
|
+
this.moduleCount = this.typeNumber * 4 + 17;
|
|
747
|
+
this.modules = new Array(this.moduleCount);
|
|
748
|
+
for (var row = 0; row < this.moduleCount; row++) {
|
|
749
|
+
this.modules[row] = new Array(this.moduleCount);
|
|
750
|
+
for (var col = 0; col < this.moduleCount; col++) {
|
|
751
|
+
this.modules[row][col] = null;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
this.setupPositionProbePattern(0, 0);
|
|
755
|
+
this.setupPositionProbePattern(this.moduleCount - 7, 0);
|
|
756
|
+
this.setupPositionProbePattern(0, this.moduleCount - 7);
|
|
757
|
+
this.setupPositionAdjustPattern();
|
|
758
|
+
this.setupTimingPattern();
|
|
759
|
+
this.setupTypeInfo(test, maskPattern);
|
|
760
|
+
if (this.typeNumber >= 7) {
|
|
761
|
+
this.setupTypeNumber(test);
|
|
762
|
+
}
|
|
763
|
+
if (this.dataCache === null) {
|
|
764
|
+
this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
|
|
765
|
+
}
|
|
766
|
+
this.mapData(this.dataCache, maskPattern);
|
|
767
|
+
},
|
|
768
|
+
setupPositionProbePattern: function(row, col) {
|
|
769
|
+
for (var r = -1; r <= 7; r++) {
|
|
770
|
+
if (row + r <= -1 || this.moduleCount <= row + r) continue;
|
|
771
|
+
for (var c = -1; c <= 7; c++) {
|
|
772
|
+
if (col + c <= -1 || this.moduleCount <= col + c) continue;
|
|
773
|
+
if (0 <= r && r <= 6 && (c === 0 || c === 6) || 0 <= c && c <= 6 && (r === 0 || r === 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
|
|
774
|
+
this.modules[row + r][col + c] = true;
|
|
775
|
+
} else {
|
|
776
|
+
this.modules[row + r][col + c] = false;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
getBestMaskPattern: function() {
|
|
782
|
+
var minLostPoint = 0;
|
|
783
|
+
var pattern = 0;
|
|
784
|
+
for (var i = 0; i < 8; i++) {
|
|
785
|
+
this.makeImpl(true, i);
|
|
786
|
+
var lostPoint = QRUtil.getLostPoint(this);
|
|
787
|
+
if (i === 0 || minLostPoint > lostPoint) {
|
|
788
|
+
minLostPoint = lostPoint;
|
|
789
|
+
pattern = i;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return pattern;
|
|
793
|
+
},
|
|
794
|
+
createMovieClip: function(target_mc, instance_name, depth) {
|
|
795
|
+
var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
|
|
796
|
+
var cs = 1;
|
|
797
|
+
this.make();
|
|
798
|
+
for (var row = 0; row < this.modules.length; row++) {
|
|
799
|
+
var y = row * cs;
|
|
800
|
+
for (var col = 0; col < this.modules[row].length; col++) {
|
|
801
|
+
var x = col * cs;
|
|
802
|
+
var dark = this.modules[row][col];
|
|
803
|
+
if (dark) {
|
|
804
|
+
qr_mc.beginFill(0, 100);
|
|
805
|
+
qr_mc.moveTo(x, y);
|
|
806
|
+
qr_mc.lineTo(x + cs, y);
|
|
807
|
+
qr_mc.lineTo(x + cs, y + cs);
|
|
808
|
+
qr_mc.lineTo(x, y + cs);
|
|
809
|
+
qr_mc.endFill();
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return qr_mc;
|
|
814
|
+
},
|
|
815
|
+
setupTimingPattern: function() {
|
|
816
|
+
for (var r = 8; r < this.moduleCount - 8; r++) {
|
|
817
|
+
if (this.modules[r][6] !== null) {
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
this.modules[r][6] = r % 2 === 0;
|
|
821
|
+
}
|
|
822
|
+
for (var c = 8; c < this.moduleCount - 8; c++) {
|
|
823
|
+
if (this.modules[6][c] !== null) {
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
this.modules[6][c] = c % 2 === 0;
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
setupPositionAdjustPattern: function() {
|
|
830
|
+
var pos = QRUtil.getPatternPosition(this.typeNumber);
|
|
831
|
+
for (var i = 0; i < pos.length; i++) {
|
|
832
|
+
for (var j = 0; j < pos.length; j++) {
|
|
833
|
+
var row = pos[i];
|
|
834
|
+
var col = pos[j];
|
|
835
|
+
if (this.modules[row][col] !== null) {
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
for (var r = -2; r <= 2; r++) {
|
|
839
|
+
for (var c = -2; c <= 2; c++) {
|
|
840
|
+
if (Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0) {
|
|
841
|
+
this.modules[row + r][col + c] = true;
|
|
842
|
+
} else {
|
|
843
|
+
this.modules[row + r][col + c] = false;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
},
|
|
850
|
+
setupTypeNumber: function(test) {
|
|
851
|
+
var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
|
|
852
|
+
var mod;
|
|
853
|
+
for (var i = 0; i < 18; i++) {
|
|
854
|
+
mod = !test && (bits >> i & 1) === 1;
|
|
855
|
+
this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
|
|
856
|
+
}
|
|
857
|
+
for (var x = 0; x < 18; x++) {
|
|
858
|
+
mod = !test && (bits >> x & 1) === 1;
|
|
859
|
+
this.modules[x % 3 + this.moduleCount - 8 - 3][Math.floor(x / 3)] = mod;
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
setupTypeInfo: function(test, maskPattern) {
|
|
863
|
+
var data = this.errorCorrectLevel << 3 | maskPattern;
|
|
864
|
+
var bits = QRUtil.getBCHTypeInfo(data);
|
|
865
|
+
var mod;
|
|
866
|
+
for (var v = 0; v < 15; v++) {
|
|
867
|
+
mod = !test && (bits >> v & 1) === 1;
|
|
868
|
+
if (v < 6) {
|
|
869
|
+
this.modules[v][8] = mod;
|
|
870
|
+
} else if (v < 8) {
|
|
871
|
+
this.modules[v + 1][8] = mod;
|
|
872
|
+
} else {
|
|
873
|
+
this.modules[this.moduleCount - 15 + v][8] = mod;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
for (var h = 0; h < 15; h++) {
|
|
877
|
+
mod = !test && (bits >> h & 1) === 1;
|
|
878
|
+
if (h < 8) {
|
|
879
|
+
this.modules[8][this.moduleCount - h - 1] = mod;
|
|
880
|
+
} else if (h < 9) {
|
|
881
|
+
this.modules[8][15 - h - 1 + 1] = mod;
|
|
882
|
+
} else {
|
|
883
|
+
this.modules[8][15 - h - 1] = mod;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
this.modules[this.moduleCount - 8][8] = !test;
|
|
887
|
+
},
|
|
888
|
+
mapData: function(data, maskPattern) {
|
|
889
|
+
var inc = -1;
|
|
890
|
+
var row = this.moduleCount - 1;
|
|
891
|
+
var bitIndex = 7;
|
|
892
|
+
var byteIndex = 0;
|
|
893
|
+
for (var col = this.moduleCount - 1; col > 0; col -= 2) {
|
|
894
|
+
if (col === 6) col--;
|
|
895
|
+
while (true) {
|
|
896
|
+
for (var c = 0; c < 2; c++) {
|
|
897
|
+
if (this.modules[row][col - c] === null) {
|
|
898
|
+
var dark = false;
|
|
899
|
+
if (byteIndex < data.length) {
|
|
900
|
+
dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
901
|
+
}
|
|
902
|
+
var mask = QRUtil.getMask(maskPattern, row, col - c);
|
|
903
|
+
if (mask) {
|
|
904
|
+
dark = !dark;
|
|
905
|
+
}
|
|
906
|
+
this.modules[row][col - c] = dark;
|
|
907
|
+
bitIndex--;
|
|
908
|
+
if (bitIndex === -1) {
|
|
909
|
+
byteIndex++;
|
|
910
|
+
bitIndex = 7;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
row += inc;
|
|
915
|
+
if (row < 0 || this.moduleCount <= row) {
|
|
916
|
+
row -= inc;
|
|
917
|
+
inc = -inc;
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
QRCode.PAD0 = 236;
|
|
925
|
+
QRCode.PAD1 = 17;
|
|
926
|
+
QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
|
|
927
|
+
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
|
|
928
|
+
var buffer = new QRBitBuffer();
|
|
929
|
+
for (var i = 0; i < dataList.length; i++) {
|
|
930
|
+
var data = dataList[i];
|
|
931
|
+
buffer.put(data.mode, 4);
|
|
932
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
|
|
933
|
+
data.write(buffer);
|
|
934
|
+
}
|
|
935
|
+
var totalDataCount = 0;
|
|
936
|
+
for (var x = 0; x < rsBlocks.length; x++) {
|
|
937
|
+
totalDataCount += rsBlocks[x].dataCount;
|
|
938
|
+
}
|
|
939
|
+
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
|
940
|
+
throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
|
|
941
|
+
}
|
|
942
|
+
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
|
|
943
|
+
buffer.put(0, 4);
|
|
944
|
+
}
|
|
945
|
+
while (buffer.getLengthInBits() % 8 !== 0) {
|
|
946
|
+
buffer.putBit(false);
|
|
947
|
+
}
|
|
948
|
+
while (true) {
|
|
949
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
950
|
+
break;
|
|
951
|
+
}
|
|
952
|
+
buffer.put(QRCode.PAD0, 8);
|
|
953
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
954
|
+
break;
|
|
955
|
+
}
|
|
956
|
+
buffer.put(QRCode.PAD1, 8);
|
|
957
|
+
}
|
|
958
|
+
return QRCode.createBytes(buffer, rsBlocks);
|
|
959
|
+
};
|
|
960
|
+
QRCode.createBytes = function(buffer, rsBlocks) {
|
|
961
|
+
var offset = 0;
|
|
962
|
+
var maxDcCount = 0;
|
|
963
|
+
var maxEcCount = 0;
|
|
964
|
+
var dcdata = new Array(rsBlocks.length);
|
|
965
|
+
var ecdata = new Array(rsBlocks.length);
|
|
966
|
+
for (var r = 0; r < rsBlocks.length; r++) {
|
|
967
|
+
var dcCount = rsBlocks[r].dataCount;
|
|
968
|
+
var ecCount = rsBlocks[r].totalCount - dcCount;
|
|
969
|
+
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
970
|
+
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
971
|
+
dcdata[r] = new Array(dcCount);
|
|
972
|
+
for (var i = 0; i < dcdata[r].length; i++) {
|
|
973
|
+
dcdata[r][i] = 255 & buffer.buffer[i + offset];
|
|
974
|
+
}
|
|
975
|
+
offset += dcCount;
|
|
976
|
+
var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
|
|
977
|
+
var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
|
|
978
|
+
var modPoly = rawPoly.mod(rsPoly);
|
|
979
|
+
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
|
980
|
+
for (var x = 0; x < ecdata[r].length; x++) {
|
|
981
|
+
var modIndex = x + modPoly.getLength() - ecdata[r].length;
|
|
982
|
+
ecdata[r][x] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
var totalCodeCount = 0;
|
|
986
|
+
for (var y = 0; y < rsBlocks.length; y++) {
|
|
987
|
+
totalCodeCount += rsBlocks[y].totalCount;
|
|
988
|
+
}
|
|
989
|
+
var data = new Array(totalCodeCount);
|
|
990
|
+
var index = 0;
|
|
991
|
+
for (var z = 0; z < maxDcCount; z++) {
|
|
992
|
+
for (var s = 0; s < rsBlocks.length; s++) {
|
|
993
|
+
if (z < dcdata[s].length) {
|
|
994
|
+
data[index++] = dcdata[s][z];
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
for (var xx = 0; xx < maxEcCount; xx++) {
|
|
999
|
+
for (var t = 0; t < rsBlocks.length; t++) {
|
|
1000
|
+
if (xx < ecdata[t].length) {
|
|
1001
|
+
data[index++] = ecdata[t][xx];
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
return data;
|
|
1006
|
+
};
|
|
1007
|
+
module.exports = QRCode;
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
|
|
1011
|
+
// node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/lib/main.js
|
|
1012
|
+
var require_main = __commonJS({
|
|
1013
|
+
"node_modules/.pnpm/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/lib/main.js"(exports, module) {
|
|
1014
|
+
var QRCode = require_QRCode();
|
|
1015
|
+
var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
|
|
1016
|
+
var black = "\x1B[40m \x1B[0m";
|
|
1017
|
+
var white = "\x1B[47m \x1B[0m";
|
|
1018
|
+
var toCell = function(isBlack) {
|
|
1019
|
+
return isBlack ? black : white;
|
|
1020
|
+
};
|
|
1021
|
+
var repeat = function(color) {
|
|
1022
|
+
return {
|
|
1023
|
+
times: function(count) {
|
|
1024
|
+
return new Array(count).join(color);
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
var fill = function(length, value) {
|
|
1029
|
+
var arr = new Array(length);
|
|
1030
|
+
for (var i = 0; i < length; i++) {
|
|
1031
|
+
arr[i] = value;
|
|
1032
|
+
}
|
|
1033
|
+
return arr;
|
|
1034
|
+
};
|
|
1035
|
+
module.exports = {
|
|
1036
|
+
error: QRErrorCorrectLevel.L,
|
|
1037
|
+
generate: function(input, opts, cb) {
|
|
1038
|
+
if (typeof opts === "function") {
|
|
1039
|
+
cb = opts;
|
|
1040
|
+
opts = {};
|
|
1041
|
+
}
|
|
1042
|
+
var qrcode2 = new QRCode(-1, this.error);
|
|
1043
|
+
qrcode2.addData(input);
|
|
1044
|
+
qrcode2.make();
|
|
1045
|
+
var output = "";
|
|
1046
|
+
if (opts && opts.small) {
|
|
1047
|
+
var BLACK = true, WHITE = false;
|
|
1048
|
+
var moduleCount = qrcode2.getModuleCount();
|
|
1049
|
+
var moduleData = qrcode2.modules.slice();
|
|
1050
|
+
var oddRow = moduleCount % 2 === 1;
|
|
1051
|
+
if (oddRow) {
|
|
1052
|
+
moduleData.push(fill(moduleCount, WHITE));
|
|
1053
|
+
}
|
|
1054
|
+
var platte = {
|
|
1055
|
+
WHITE_ALL: "\u2588",
|
|
1056
|
+
WHITE_BLACK: "\u2580",
|
|
1057
|
+
BLACK_WHITE: "\u2584",
|
|
1058
|
+
BLACK_ALL: " "
|
|
1059
|
+
};
|
|
1060
|
+
var borderTop = repeat(platte.BLACK_WHITE).times(moduleCount + 3);
|
|
1061
|
+
var borderBottom = repeat(platte.WHITE_BLACK).times(moduleCount + 3);
|
|
1062
|
+
output += borderTop + "\n";
|
|
1063
|
+
for (var row = 0; row < moduleCount; row += 2) {
|
|
1064
|
+
output += platte.WHITE_ALL;
|
|
1065
|
+
for (var col = 0; col < moduleCount; col++) {
|
|
1066
|
+
if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === WHITE) {
|
|
1067
|
+
output += platte.WHITE_ALL;
|
|
1068
|
+
} else if (moduleData[row][col] === WHITE && moduleData[row + 1][col] === BLACK) {
|
|
1069
|
+
output += platte.WHITE_BLACK;
|
|
1070
|
+
} else if (moduleData[row][col] === BLACK && moduleData[row + 1][col] === WHITE) {
|
|
1071
|
+
output += platte.BLACK_WHITE;
|
|
1072
|
+
} else {
|
|
1073
|
+
output += platte.BLACK_ALL;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
output += platte.WHITE_ALL + "\n";
|
|
1077
|
+
}
|
|
1078
|
+
if (!oddRow) {
|
|
1079
|
+
output += borderBottom;
|
|
1080
|
+
}
|
|
1081
|
+
} else {
|
|
1082
|
+
var border = repeat(white).times(qrcode2.getModuleCount() + 3);
|
|
1083
|
+
output += border + "\n";
|
|
1084
|
+
qrcode2.modules.forEach(function(row2) {
|
|
1085
|
+
output += white;
|
|
1086
|
+
output += row2.map(toCell).join("");
|
|
1087
|
+
output += white + "\n";
|
|
1088
|
+
});
|
|
1089
|
+
output += border;
|
|
1090
|
+
}
|
|
1091
|
+
if (cb) cb(output);
|
|
1092
|
+
else console.log(output);
|
|
1093
|
+
},
|
|
1094
|
+
setErrorLevel: function(error) {
|
|
1095
|
+
this.error = QRErrorCorrectLevel[error] || this.error;
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
6
1100
|
|
|
7
1101
|
// packages/provider-codex/src/index.ts
|
|
8
1102
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
9
1103
|
import { createHash as createHash4 } from "crypto";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
1104
|
+
import fs8 from "fs/promises";
|
|
1105
|
+
import os8 from "os";
|
|
1106
|
+
import path9 from "path";
|
|
13
1107
|
|
|
14
1108
|
// packages/provider-codex/src/injected-user-text.ts
|
|
15
1109
|
var consumeTaggedBlock = (input, tagName) => {
|
|
@@ -530,8 +1624,8 @@ function getErrorMap() {
|
|
|
530
1624
|
|
|
531
1625
|
// node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
532
1626
|
var makeIssue = (params) => {
|
|
533
|
-
const { data, path:
|
|
534
|
-
const fullPath = [...
|
|
1627
|
+
const { data, path: path10, errorMaps, issueData } = params;
|
|
1628
|
+
const fullPath = [...path10, ...issueData.path || []];
|
|
535
1629
|
const fullIssue = {
|
|
536
1630
|
...issueData,
|
|
537
1631
|
path: fullPath
|
|
@@ -647,11 +1741,11 @@ var errorUtil;
|
|
|
647
1741
|
|
|
648
1742
|
// node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
649
1743
|
var ParseInputLazyPath = class {
|
|
650
|
-
constructor(parent, value,
|
|
1744
|
+
constructor(parent, value, path10, key) {
|
|
651
1745
|
this._cachedPath = [];
|
|
652
1746
|
this.parent = parent;
|
|
653
1747
|
this.data = value;
|
|
654
|
-
this._path =
|
|
1748
|
+
this._path = path10;
|
|
655
1749
|
this._key = key;
|
|
656
1750
|
}
|
|
657
1751
|
get path() {
|
|
@@ -11632,7 +12726,7 @@ var startPandaSessionService = async ({
|
|
|
11632
12726
|
if (managedTimeline) {
|
|
11633
12727
|
return mergeTimelineEntries(managedTimeline, readTimelineOverlay(sessionId, managedTimeline));
|
|
11634
12728
|
}
|
|
11635
|
-
const { readCodexTimeline: readCodexTimeline2 } = await import("./src-
|
|
12729
|
+
const { readCodexTimeline: readCodexTimeline2 } = await import("./src-LEEO2YLS.mjs");
|
|
11636
12730
|
const discoveredTimeline = await readCodexTimeline2(sessionId, {
|
|
11637
12731
|
codexHome,
|
|
11638
12732
|
sessionFiles: discoveredSessionFiles
|
|
@@ -12317,7 +13411,7 @@ var startPandaSessionService = async ({
|
|
|
12317
13411
|
lastSnapshotRefreshAt = Date.now();
|
|
12318
13412
|
return snapshot;
|
|
12319
13413
|
}
|
|
12320
|
-
const { discoverLocalCodexData: discoverLocalCodexData2 } = await import("./src-
|
|
13414
|
+
const { discoverLocalCodexData: discoverLocalCodexData2 } = await import("./src-LEEO2YLS.mjs");
|
|
12321
13415
|
const discovery = await discoverLocalCodexData2({
|
|
12322
13416
|
agentId: localAgentId,
|
|
12323
13417
|
agentName: localAgentName,
|
|
@@ -14381,24 +15475,139 @@ var startPandaSessionService = async ({
|
|
|
14381
15475
|
return app;
|
|
14382
15476
|
};
|
|
14383
15477
|
|
|
14384
|
-
// packages/provider-codex/src/
|
|
14385
|
-
import {
|
|
15478
|
+
// packages/provider-codex/src/hub-api-key.ts
|
|
15479
|
+
import { randomBytes } from "crypto";
|
|
15480
|
+
import fs7 from "fs/promises";
|
|
14386
15481
|
import os6 from "os";
|
|
14387
|
-
|
|
15482
|
+
import path8 from "path";
|
|
14388
15483
|
var trimToNull = (value) => {
|
|
14389
15484
|
const normalized = value?.trim() ?? "";
|
|
14390
15485
|
return normalized ? normalized : null;
|
|
14391
15486
|
};
|
|
14392
|
-
var
|
|
14393
|
-
|
|
14394
|
-
|
|
15487
|
+
var defaultPandaHome = (codexHome) => trimToNull(codexHome) ?? trimToNull(process.env.PANDA_CODEX_HOME) ?? path8.join(os6.homedir(), ".panda");
|
|
15488
|
+
var getPandaHubApiKeyFilePath = (codexHome) => path8.join(defaultPandaHome(codexHome), "secrets", "hub-api-key");
|
|
15489
|
+
var readStoredHubApiKey = async (filePath) => {
|
|
15490
|
+
try {
|
|
15491
|
+
return trimToNull(await fs7.readFile(filePath, "utf8"));
|
|
15492
|
+
} catch {
|
|
14395
15493
|
return null;
|
|
14396
15494
|
}
|
|
15495
|
+
};
|
|
15496
|
+
var writeStoredHubApiKey = async (filePath, apiKey, options) => {
|
|
15497
|
+
await fs7.mkdir(path8.dirname(filePath), { recursive: true });
|
|
15498
|
+
await fs7.writeFile(filePath, `${apiKey}
|
|
15499
|
+
`, {
|
|
15500
|
+
encoding: "utf8",
|
|
15501
|
+
flag: options?.exclusive ? "wx" : "w",
|
|
15502
|
+
mode: 384
|
|
15503
|
+
});
|
|
15504
|
+
};
|
|
15505
|
+
var resolvePandaHubApiKey = async (options) => {
|
|
15506
|
+
const apiKey = trimToNull(options?.configuredApiKey);
|
|
15507
|
+
const filePath = getPandaHubApiKeyFilePath(options?.codexHome);
|
|
15508
|
+
if (apiKey) {
|
|
15509
|
+
return {
|
|
15510
|
+
apiKey,
|
|
15511
|
+
filePath,
|
|
15512
|
+
source: "env"
|
|
15513
|
+
};
|
|
15514
|
+
}
|
|
15515
|
+
const storedApiKey = await readStoredHubApiKey(filePath);
|
|
15516
|
+
if (storedApiKey) {
|
|
15517
|
+
return {
|
|
15518
|
+
apiKey: storedApiKey,
|
|
15519
|
+
filePath,
|
|
15520
|
+
source: "file"
|
|
15521
|
+
};
|
|
15522
|
+
}
|
|
15523
|
+
return {
|
|
15524
|
+
apiKey: null,
|
|
15525
|
+
filePath,
|
|
15526
|
+
source: "missing"
|
|
15527
|
+
};
|
|
15528
|
+
};
|
|
15529
|
+
var ensurePandaHubApiKey = async (options) => {
|
|
15530
|
+
const resolved = await resolvePandaHubApiKey(options);
|
|
15531
|
+
if (resolved.source === "env") {
|
|
15532
|
+
const configuredApiKey = resolved.apiKey;
|
|
15533
|
+
if (!configuredApiKey) {
|
|
15534
|
+
throw new Error("Resolved Panda hub API key from env is empty.");
|
|
15535
|
+
}
|
|
15536
|
+
const storedApiKey = await readStoredHubApiKey(resolved.filePath);
|
|
15537
|
+
if (storedApiKey !== configuredApiKey) {
|
|
15538
|
+
await writeStoredHubApiKey(resolved.filePath, configuredApiKey);
|
|
15539
|
+
options?.logger?.info?.(
|
|
15540
|
+
storedApiKey ? `Updated Panda hub API key file at ${resolved.filePath} from PANDA_HUB_API_KEY.` : `Persisted Panda hub API key to ${resolved.filePath} from PANDA_HUB_API_KEY.`
|
|
15541
|
+
);
|
|
15542
|
+
}
|
|
15543
|
+
return resolved;
|
|
15544
|
+
}
|
|
15545
|
+
if (resolved.source === "file") {
|
|
15546
|
+
return resolved;
|
|
15547
|
+
}
|
|
15548
|
+
const generatedApiKey = randomBytes(32).toString("hex");
|
|
14397
15549
|
try {
|
|
14398
|
-
|
|
14399
|
-
|
|
15550
|
+
await writeStoredHubApiKey(resolved.filePath, generatedApiKey, {
|
|
15551
|
+
exclusive: true
|
|
15552
|
+
});
|
|
15553
|
+
options?.logger?.info?.(
|
|
15554
|
+
`Generated Panda hub API key at ${resolved.filePath}. Share this key with agents: ${generatedApiKey}`
|
|
15555
|
+
);
|
|
15556
|
+
return {
|
|
15557
|
+
apiKey: generatedApiKey,
|
|
15558
|
+
filePath: resolved.filePath,
|
|
15559
|
+
source: "generated"
|
|
15560
|
+
};
|
|
15561
|
+
} catch (error) {
|
|
15562
|
+
if (error.code !== "EEXIST") {
|
|
15563
|
+
throw error;
|
|
15564
|
+
}
|
|
15565
|
+
const storedApiKey = await readStoredHubApiKey(resolved.filePath);
|
|
15566
|
+
if (!storedApiKey) {
|
|
15567
|
+
throw error;
|
|
15568
|
+
}
|
|
15569
|
+
return {
|
|
15570
|
+
apiKey: storedApiKey,
|
|
15571
|
+
filePath: resolved.filePath,
|
|
15572
|
+
source: "file"
|
|
15573
|
+
};
|
|
15574
|
+
}
|
|
15575
|
+
};
|
|
15576
|
+
|
|
15577
|
+
// packages/provider-codex/src/agent-hub-sync.ts
|
|
15578
|
+
import os7 from "os";
|
|
15579
|
+
|
|
15580
|
+
// packages/provider-codex/src/tailscale.ts
|
|
15581
|
+
import { execFileSync } from "child_process";
|
|
15582
|
+
var ENABLED_ARGS = /* @__PURE__ */ new Set([
|
|
15583
|
+
"tailscareserv",
|
|
15584
|
+
"--tailscareserv",
|
|
15585
|
+
"tailscale-serve",
|
|
15586
|
+
"--tailscale-serve"
|
|
15587
|
+
]);
|
|
15588
|
+
var DISABLED_ARGS = /* @__PURE__ */ new Set([
|
|
15589
|
+
"no-tailscareserv",
|
|
15590
|
+
"--no-tailscareserv",
|
|
15591
|
+
"no-tailscale-serve",
|
|
15592
|
+
"--no-tailscale-serve"
|
|
15593
|
+
]);
|
|
15594
|
+
var trimToNull2 = (value) => {
|
|
15595
|
+
const normalized = value?.trim() ?? "";
|
|
15596
|
+
return normalized ? normalized : null;
|
|
15597
|
+
};
|
|
15598
|
+
var normalizeDnsName = (value) => {
|
|
15599
|
+
const normalized = trimToNull2(value);
|
|
15600
|
+
if (!normalized) {
|
|
15601
|
+
return null;
|
|
15602
|
+
}
|
|
15603
|
+
return normalized.replace(/\.+$/, "");
|
|
15604
|
+
};
|
|
15605
|
+
var buildTailscaleHttpsUrl = (options) => {
|
|
15606
|
+
const dnsName = normalizeDnsName(options.dnsName);
|
|
15607
|
+
if (!dnsName) {
|
|
14400
15608
|
return null;
|
|
14401
15609
|
}
|
|
15610
|
+
return `https://${dnsName}${options.servePort === 443 ? "" : `:${options.servePort}`}`;
|
|
14402
15611
|
};
|
|
14403
15612
|
var toWsUrl = (baseUrl) => {
|
|
14404
15613
|
const url = new URL(baseUrl);
|
|
@@ -14406,6 +15615,47 @@ var toWsUrl = (baseUrl) => {
|
|
|
14406
15615
|
url.pathname = "/ws";
|
|
14407
15616
|
return url.toString();
|
|
14408
15617
|
};
|
|
15618
|
+
var resolveCliOptionValue = (options) => {
|
|
15619
|
+
const argv = options.argv ?? [];
|
|
15620
|
+
const aliases = options.aliases.map((alias) => alias.trim().toLowerCase()).filter(Boolean);
|
|
15621
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
15622
|
+
const candidate = argv[index]?.trim() ?? "";
|
|
15623
|
+
const normalized = candidate.toLowerCase();
|
|
15624
|
+
for (const alias of aliases) {
|
|
15625
|
+
if (normalized === alias) {
|
|
15626
|
+
return trimToNull2(argv[index + 1]);
|
|
15627
|
+
}
|
|
15628
|
+
if (normalized.startsWith(`${alias}=`)) {
|
|
15629
|
+
return trimToNull2(candidate.slice(alias.length + 1));
|
|
15630
|
+
}
|
|
15631
|
+
}
|
|
15632
|
+
}
|
|
15633
|
+
return null;
|
|
15634
|
+
};
|
|
15635
|
+
var parseBooleanLike = (value) => {
|
|
15636
|
+
const normalized = trimToNull2(value)?.toLowerCase();
|
|
15637
|
+
if (!normalized) {
|
|
15638
|
+
return null;
|
|
15639
|
+
}
|
|
15640
|
+
if (["1", "true", "yes", "on"].includes(normalized)) {
|
|
15641
|
+
return true;
|
|
15642
|
+
}
|
|
15643
|
+
if (["0", "false", "no", "off"].includes(normalized)) {
|
|
15644
|
+
return false;
|
|
15645
|
+
}
|
|
15646
|
+
return null;
|
|
15647
|
+
};
|
|
15648
|
+
var parsePort = (value) => {
|
|
15649
|
+
const normalized = trimToNull2(value);
|
|
15650
|
+
if (!normalized) {
|
|
15651
|
+
return null;
|
|
15652
|
+
}
|
|
15653
|
+
const parsed = Number(normalized);
|
|
15654
|
+
if (!Number.isInteger(parsed) || parsed <= 0 || parsed > 65535) {
|
|
15655
|
+
return null;
|
|
15656
|
+
}
|
|
15657
|
+
return parsed;
|
|
15658
|
+
};
|
|
14409
15659
|
var readTailscaleStatus = () => {
|
|
14410
15660
|
try {
|
|
14411
15661
|
const stdout = execFileSync("tailscale", ["status", "--json"], {
|
|
@@ -14419,8 +15669,187 @@ var readTailscaleStatus = () => {
|
|
|
14419
15669
|
return null;
|
|
14420
15670
|
}
|
|
14421
15671
|
};
|
|
15672
|
+
var isTailscaleRunning = (status) => {
|
|
15673
|
+
if (!status?.Self) {
|
|
15674
|
+
return false;
|
|
15675
|
+
}
|
|
15676
|
+
const backendState = trimToNull2(status.BackendState)?.toLowerCase();
|
|
15677
|
+
if (backendState && backendState !== "running") {
|
|
15678
|
+
return false;
|
|
15679
|
+
}
|
|
15680
|
+
return Boolean(
|
|
15681
|
+
normalizeDnsName(status.Self.DNSName) ?? trimToNull2(status.Self.TailscaleIPs?.[0])
|
|
15682
|
+
);
|
|
15683
|
+
};
|
|
15684
|
+
var resolveTailscaleServeEnabled = (options) => {
|
|
15685
|
+
const argv = options?.argv ?? [];
|
|
15686
|
+
for (const candidate of argv) {
|
|
15687
|
+
const normalized = candidate.trim().toLowerCase();
|
|
15688
|
+
if (ENABLED_ARGS.has(normalized)) {
|
|
15689
|
+
return true;
|
|
15690
|
+
}
|
|
15691
|
+
if (DISABLED_ARGS.has(normalized)) {
|
|
15692
|
+
return false;
|
|
15693
|
+
}
|
|
15694
|
+
}
|
|
15695
|
+
const envEnabled = parseBooleanLike((options?.env ?? process.env).PANDA_TAILSCALE_SERVE);
|
|
15696
|
+
return envEnabled ?? false;
|
|
15697
|
+
};
|
|
15698
|
+
var resolveTailscaleServePort = (options) => {
|
|
15699
|
+
const env = options.env ?? process.env;
|
|
15700
|
+
const scopedPort = options.envPrefix ? parsePort(env[`${options.envPrefix}_TAILSCALE_SERVE_PORT`]) : null;
|
|
15701
|
+
const genericPort = parsePort(env.PANDA_TAILSCALE_SERVE_PORT);
|
|
15702
|
+
return scopedPort ?? genericPort ?? options.defaultPort;
|
|
15703
|
+
};
|
|
15704
|
+
var configureTailscaleServe = (options) => {
|
|
15705
|
+
if (!options.enabled) {
|
|
15706
|
+
return {
|
|
15707
|
+
enabled: false,
|
|
15708
|
+
active: false,
|
|
15709
|
+
servePort: null,
|
|
15710
|
+
dnsName: null,
|
|
15711
|
+
tailscaleIp: null,
|
|
15712
|
+
baseUrl: null,
|
|
15713
|
+
wsBaseUrl: null,
|
|
15714
|
+
reason: "disabled"
|
|
15715
|
+
};
|
|
15716
|
+
}
|
|
15717
|
+
const status = readTailscaleStatus();
|
|
15718
|
+
if (!status) {
|
|
15719
|
+
options.logger?.warn?.(
|
|
15720
|
+
`Skipping Tailscale Serve for ${options.serviceName}: tailscale CLI is unavailable or not logged in.`
|
|
15721
|
+
);
|
|
15722
|
+
return {
|
|
15723
|
+
enabled: true,
|
|
15724
|
+
active: false,
|
|
15725
|
+
servePort: options.servePort,
|
|
15726
|
+
dnsName: null,
|
|
15727
|
+
tailscaleIp: null,
|
|
15728
|
+
baseUrl: null,
|
|
15729
|
+
wsBaseUrl: null,
|
|
15730
|
+
reason: "unavailable"
|
|
15731
|
+
};
|
|
15732
|
+
}
|
|
15733
|
+
if (!isTailscaleRunning(status)) {
|
|
15734
|
+
options.logger?.warn?.(
|
|
15735
|
+
`Skipping Tailscale Serve for ${options.serviceName}: Tailscale is not running.`
|
|
15736
|
+
);
|
|
15737
|
+
return {
|
|
15738
|
+
enabled: true,
|
|
15739
|
+
active: false,
|
|
15740
|
+
servePort: options.servePort,
|
|
15741
|
+
dnsName: normalizeDnsName(status.Self?.DNSName),
|
|
15742
|
+
tailscaleIp: trimToNull2(status.Self?.TailscaleIPs?.[0]),
|
|
15743
|
+
baseUrl: null,
|
|
15744
|
+
wsBaseUrl: null,
|
|
15745
|
+
reason: "offline"
|
|
15746
|
+
};
|
|
15747
|
+
}
|
|
15748
|
+
const dnsName = normalizeDnsName(status.Self?.DNSName);
|
|
15749
|
+
const tailscaleIp = trimToNull2(status.Self?.TailscaleIPs?.[0]);
|
|
15750
|
+
if (!dnsName) {
|
|
15751
|
+
options.logger?.warn?.(
|
|
15752
|
+
`Skipping Tailscale Serve for ${options.serviceName}: MagicDNS name is unavailable.`
|
|
15753
|
+
);
|
|
15754
|
+
return {
|
|
15755
|
+
enabled: true,
|
|
15756
|
+
active: false,
|
|
15757
|
+
servePort: options.servePort,
|
|
15758
|
+
dnsName: null,
|
|
15759
|
+
tailscaleIp,
|
|
15760
|
+
baseUrl: null,
|
|
15761
|
+
wsBaseUrl: null,
|
|
15762
|
+
reason: "missing-dns"
|
|
15763
|
+
};
|
|
15764
|
+
}
|
|
15765
|
+
try {
|
|
15766
|
+
execFileSync(
|
|
15767
|
+
"tailscale",
|
|
15768
|
+
[
|
|
15769
|
+
"serve",
|
|
15770
|
+
"--bg",
|
|
15771
|
+
`--https=${options.servePort}`,
|
|
15772
|
+
`http://127.0.0.1:${options.localPort}`
|
|
15773
|
+
],
|
|
15774
|
+
{
|
|
15775
|
+
encoding: "utf8",
|
|
15776
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
15777
|
+
windowsHide: true,
|
|
15778
|
+
timeout: 5e3
|
|
15779
|
+
}
|
|
15780
|
+
);
|
|
15781
|
+
} catch (error) {
|
|
15782
|
+
const message = error instanceof Error ? error.message : "tailscale serve failed";
|
|
15783
|
+
options.logger?.warn?.(
|
|
15784
|
+
`Unable to publish ${options.serviceName} via Tailscale Serve: ${message}`
|
|
15785
|
+
);
|
|
15786
|
+
return {
|
|
15787
|
+
enabled: true,
|
|
15788
|
+
active: false,
|
|
15789
|
+
servePort: options.servePort,
|
|
15790
|
+
dnsName,
|
|
15791
|
+
tailscaleIp,
|
|
15792
|
+
baseUrl: null,
|
|
15793
|
+
wsBaseUrl: null,
|
|
15794
|
+
reason: "failed"
|
|
15795
|
+
};
|
|
15796
|
+
}
|
|
15797
|
+
const baseUrl = buildTailscaleHttpsUrl({
|
|
15798
|
+
dnsName,
|
|
15799
|
+
servePort: options.servePort
|
|
15800
|
+
});
|
|
15801
|
+
if (!baseUrl) {
|
|
15802
|
+
return {
|
|
15803
|
+
enabled: true,
|
|
15804
|
+
active: false,
|
|
15805
|
+
servePort: options.servePort,
|
|
15806
|
+
dnsName,
|
|
15807
|
+
tailscaleIp,
|
|
15808
|
+
baseUrl: null,
|
|
15809
|
+
wsBaseUrl: null,
|
|
15810
|
+
reason: "missing-dns"
|
|
15811
|
+
};
|
|
15812
|
+
}
|
|
15813
|
+
options.logger?.info?.(
|
|
15814
|
+
`Published ${options.serviceName} over Tailscale Serve at ${baseUrl}`
|
|
15815
|
+
);
|
|
15816
|
+
return {
|
|
15817
|
+
enabled: true,
|
|
15818
|
+
active: true,
|
|
15819
|
+
servePort: options.servePort,
|
|
15820
|
+
dnsName,
|
|
15821
|
+
tailscaleIp,
|
|
15822
|
+
baseUrl,
|
|
15823
|
+
wsBaseUrl: toWsUrl(baseUrl),
|
|
15824
|
+
reason: "configured"
|
|
15825
|
+
};
|
|
15826
|
+
};
|
|
15827
|
+
|
|
15828
|
+
// packages/provider-codex/src/agent-hub-sync.ts
|
|
15829
|
+
var DEFAULT_HEARTBEAT_INTERVAL_MS = 15e3;
|
|
15830
|
+
var trimToNull3 = (value) => {
|
|
15831
|
+
const normalized = value?.trim() ?? "";
|
|
15832
|
+
return normalized ? normalized : null;
|
|
15833
|
+
};
|
|
15834
|
+
var readHostnameFromUrl = (value) => {
|
|
15835
|
+
const normalized = trimToNull3(value);
|
|
15836
|
+
if (!normalized) {
|
|
15837
|
+
return null;
|
|
15838
|
+
}
|
|
15839
|
+
try {
|
|
15840
|
+
return trimToNull3(new URL(normalized).hostname);
|
|
15841
|
+
} catch {
|
|
15842
|
+
return null;
|
|
15843
|
+
}
|
|
15844
|
+
};
|
|
15845
|
+
var toWsUrl2 = (baseUrl) => {
|
|
15846
|
+
const url = new URL(baseUrl);
|
|
15847
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
15848
|
+
url.pathname = "/ws";
|
|
15849
|
+
return url.toString();
|
|
15850
|
+
};
|
|
14422
15851
|
var resolveHostAddress = () => {
|
|
14423
|
-
const interfaces =
|
|
15852
|
+
const interfaces = os7.networkInterfaces();
|
|
14424
15853
|
let fallback = null;
|
|
14425
15854
|
for (const [name, entries] of Object.entries(interfaces)) {
|
|
14426
15855
|
for (const entry of entries ?? []) {
|
|
@@ -14433,20 +15862,20 @@ var resolveHostAddress = () => {
|
|
|
14433
15862
|
fallback ??= entry.address;
|
|
14434
15863
|
}
|
|
14435
15864
|
}
|
|
14436
|
-
return fallback ??
|
|
15865
|
+
return fallback ?? os7.hostname();
|
|
14437
15866
|
};
|
|
14438
15867
|
var resolveAgentNetworkIdentity = (options) => {
|
|
14439
15868
|
const tailscaleStatus = readTailscaleStatus();
|
|
14440
|
-
const detectedDnsName =
|
|
14441
|
-
const detectedTailscaleIp =
|
|
15869
|
+
const detectedDnsName = trimToNull3(tailscaleStatus?.Self?.DNSName);
|
|
15870
|
+
const detectedTailscaleIp = trimToNull3(tailscaleStatus?.Self?.TailscaleIPs?.[0]);
|
|
14442
15871
|
const port = options?.port ?? 4242;
|
|
14443
|
-
const host = readHostnameFromUrl(options?.directBaseUrl) ??
|
|
14444
|
-
const directBaseUrl =
|
|
14445
|
-
const wsBaseUrl =
|
|
15872
|
+
const host = readHostnameFromUrl(options?.directBaseUrl) ?? trimToNull3(options?.tailscaleDnsName) ?? trimToNull3(options?.tailscaleIp) ?? detectedDnsName ?? detectedTailscaleIp ?? resolveHostAddress();
|
|
15873
|
+
const directBaseUrl = trimToNull3(options?.directBaseUrl) ?? `http://${host}:${port}`;
|
|
15874
|
+
const wsBaseUrl = trimToNull3(options?.wsBaseUrl) ?? toWsUrl2(directBaseUrl);
|
|
14446
15875
|
return {
|
|
14447
15876
|
host,
|
|
14448
|
-
tailscaleIp:
|
|
14449
|
-
tailscaleDnsName:
|
|
15877
|
+
tailscaleIp: trimToNull3(options?.tailscaleIp) ?? detectedTailscaleIp,
|
|
15878
|
+
tailscaleDnsName: trimToNull3(options?.tailscaleDnsName) ?? detectedDnsName,
|
|
14450
15879
|
directBaseUrl,
|
|
14451
15880
|
wsBaseUrl
|
|
14452
15881
|
};
|
|
@@ -14576,6 +16005,30 @@ var startAgentHubSync = (options) => {
|
|
|
14576
16005
|
};
|
|
14577
16006
|
};
|
|
14578
16007
|
|
|
16008
|
+
// packages/provider-codex/src/terminal-qr.ts
|
|
16009
|
+
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
16010
|
+
var trimToNull4 = (value) => {
|
|
16011
|
+
const normalized = value?.trim() ?? "";
|
|
16012
|
+
return normalized ? normalized : null;
|
|
16013
|
+
};
|
|
16014
|
+
var printTerminalQr = (url, options) => {
|
|
16015
|
+
const normalizedUrl = trimToNull4(url);
|
|
16016
|
+
if (!normalizedUrl) {
|
|
16017
|
+
return;
|
|
16018
|
+
}
|
|
16019
|
+
const logger = options?.logger ?? console;
|
|
16020
|
+
if (options?.label) {
|
|
16021
|
+
logger.info?.(options.label);
|
|
16022
|
+
}
|
|
16023
|
+
import_qrcode_terminal.default.generate(normalizedUrl, { small: true }, (rendered) => {
|
|
16024
|
+
const content = trimToNull4(rendered);
|
|
16025
|
+
if (content) {
|
|
16026
|
+
logger.info?.(`
|
|
16027
|
+
${content}`);
|
|
16028
|
+
}
|
|
16029
|
+
});
|
|
16030
|
+
};
|
|
16031
|
+
|
|
14579
16032
|
// packages/provider-codex/src/index.ts
|
|
14580
16033
|
var ACTIVE_WINDOW_MS2 = 10 * 60 * 1e3;
|
|
14581
16034
|
var LIVE_WINDOW_MS = 30 * 60 * 1e3;
|
|
@@ -14587,12 +16040,12 @@ var TOOL_OUTPUT_LIMIT2 = 1400;
|
|
|
14587
16040
|
var COMPLETED_STATE_TTL_MS2 = 3 * 60 * 1e3;
|
|
14588
16041
|
var stableId = (prefix, value) => `${prefix}-${createHash4("sha1").update(value).digest("hex").slice(0, 12)}`;
|
|
14589
16042
|
var normalizePathKey2 = (value) => {
|
|
14590
|
-
const normalized =
|
|
16043
|
+
const normalized = path9.normalize(value.trim());
|
|
14591
16044
|
return process.platform === "win32" ? normalized.replace(/\//g, "\\").toLowerCase() : normalized;
|
|
14592
16045
|
};
|
|
14593
16046
|
var basenameFromPath = (targetPath) => {
|
|
14594
16047
|
const normalized = targetPath.replace(/[\\/]+$/, "");
|
|
14595
|
-
return
|
|
16048
|
+
return path9.basename(normalized) || normalized;
|
|
14596
16049
|
};
|
|
14597
16050
|
var pickNewestTimestamp = (...candidates) => {
|
|
14598
16051
|
let newestValue = null;
|
|
@@ -14689,7 +16142,7 @@ var parseSessionContextUsage2 = (info, timestamp) => {
|
|
|
14689
16142
|
updated_at: timestamp
|
|
14690
16143
|
};
|
|
14691
16144
|
};
|
|
14692
|
-
var defaultCodexHome3 = () =>
|
|
16145
|
+
var defaultCodexHome3 = () => path9.join(os8.homedir(), ".codex");
|
|
14693
16146
|
var isWithinWorkspaceRoots = (cwd, workspaceRoots) => {
|
|
14694
16147
|
if (workspaceRoots.length === 0) {
|
|
14695
16148
|
return true;
|
|
@@ -14707,7 +16160,7 @@ var resolveHostAddress2 = (providedHost) => {
|
|
|
14707
16160
|
if (providedHost) {
|
|
14708
16161
|
return providedHost;
|
|
14709
16162
|
}
|
|
14710
|
-
const interfaces =
|
|
16163
|
+
const interfaces = os8.networkInterfaces();
|
|
14711
16164
|
let fallback = null;
|
|
14712
16165
|
for (const [name, entries] of Object.entries(interfaces)) {
|
|
14713
16166
|
for (const entry of entries ?? []) {
|
|
@@ -14720,10 +16173,10 @@ var resolveHostAddress2 = (providedHost) => {
|
|
|
14720
16173
|
fallback ??= entry.address;
|
|
14721
16174
|
}
|
|
14722
16175
|
}
|
|
14723
|
-
return fallback ??
|
|
16176
|
+
return fallback ?? os8.hostname();
|
|
14724
16177
|
};
|
|
14725
16178
|
var readFirstLine3 = async (filePath) => {
|
|
14726
|
-
const handle = await
|
|
16179
|
+
const handle = await fs8.open(filePath, "r");
|
|
14727
16180
|
try {
|
|
14728
16181
|
const chunks = [];
|
|
14729
16182
|
let bytesReadTotal = 0;
|
|
@@ -14750,7 +16203,7 @@ var readFirstLine3 = async (filePath) => {
|
|
|
14750
16203
|
}
|
|
14751
16204
|
};
|
|
14752
16205
|
var readInitialChunk = async (filePath, limit) => {
|
|
14753
|
-
const handle = await
|
|
16206
|
+
const handle = await fs8.open(filePath, "r");
|
|
14754
16207
|
try {
|
|
14755
16208
|
const buffer = Buffer.alloc(limit);
|
|
14756
16209
|
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
@@ -14760,7 +16213,7 @@ var readInitialChunk = async (filePath, limit) => {
|
|
|
14760
16213
|
}
|
|
14761
16214
|
};
|
|
14762
16215
|
var readJsonLines = async (filePath) => {
|
|
14763
|
-
const content = await
|
|
16216
|
+
const content = await fs8.readFile(filePath, "utf8");
|
|
14764
16217
|
const lines = content.split(/\r?\n/).filter(Boolean);
|
|
14765
16218
|
const records = [];
|
|
14766
16219
|
for (const line of lines) {
|
|
@@ -14774,9 +16227,9 @@ var readJsonLines = async (filePath) => {
|
|
|
14774
16227
|
};
|
|
14775
16228
|
var loadSessionIndex = async (codexHome) => {
|
|
14776
16229
|
const result = /* @__PURE__ */ new Map();
|
|
14777
|
-
const filePath =
|
|
16230
|
+
const filePath = path9.join(codexHome, "session_index.jsonl");
|
|
14778
16231
|
try {
|
|
14779
|
-
const content = await
|
|
16232
|
+
const content = await fs8.readFile(filePath, "utf8");
|
|
14780
16233
|
for (const line of content.split(/\r?\n/).filter(Boolean)) {
|
|
14781
16234
|
try {
|
|
14782
16235
|
const parsed = JSON.parse(line);
|
|
@@ -14795,13 +16248,13 @@ var loadSessionIndex = async (codexHome) => {
|
|
|
14795
16248
|
var walkRolloutFiles3 = async (rootPath) => {
|
|
14796
16249
|
let entries;
|
|
14797
16250
|
try {
|
|
14798
|
-
entries = await
|
|
16251
|
+
entries = await fs8.readdir(rootPath, { withFileTypes: true });
|
|
14799
16252
|
} catch {
|
|
14800
16253
|
return [];
|
|
14801
16254
|
}
|
|
14802
16255
|
const files = [];
|
|
14803
16256
|
for (const entry of entries) {
|
|
14804
|
-
const fullPath =
|
|
16257
|
+
const fullPath = path9.join(rootPath, entry.name);
|
|
14805
16258
|
if (entry.isDirectory()) {
|
|
14806
16259
|
files.push(...await walkRolloutFiles3(fullPath));
|
|
14807
16260
|
continue;
|
|
@@ -15047,7 +16500,7 @@ var readRolloutRecord = async (filePath, sessionIndex, archived) => {
|
|
|
15047
16500
|
if (!sessionId || !cwd) {
|
|
15048
16501
|
return null;
|
|
15049
16502
|
}
|
|
15050
|
-
const stat = await
|
|
16503
|
+
const stat = await fs8.stat(filePath);
|
|
15051
16504
|
const indexed = sessionIndex.get(sessionId);
|
|
15052
16505
|
const indexedTitle = indexed?.thread_name?.trim() ?? "";
|
|
15053
16506
|
const updatedAt = pickNewestTimestamp(
|
|
@@ -15075,8 +16528,8 @@ var readCodexTimelineDetails = async (sessionId, options) => {
|
|
|
15075
16528
|
if (!filePath) {
|
|
15076
16529
|
const sessionIndex = await loadSessionIndex(codexHome);
|
|
15077
16530
|
const [files, archivedFiles] = await Promise.all([
|
|
15078
|
-
walkRolloutFiles3(
|
|
15079
|
-
walkRolloutFiles3(
|
|
16531
|
+
walkRolloutFiles3(path9.join(codexHome, "sessions")),
|
|
16532
|
+
walkRolloutFiles3(path9.join(codexHome, "archived_sessions"))
|
|
15080
16533
|
]);
|
|
15081
16534
|
for (const [candidate, archived] of [
|
|
15082
16535
|
...files.map((candidate2) => [candidate2, false]),
|
|
@@ -15353,8 +16806,8 @@ var discoverLocalCodexData = async (options = {}) => {
|
|
|
15353
16806
|
);
|
|
15354
16807
|
const orderedWorkspaceRoots = getOrderedWorkspaceRoots(pandaThreadPrefs);
|
|
15355
16808
|
const pinnedSessionIds = new Set(getPinnedSessionIds(pandaSessionPrefs));
|
|
15356
|
-
const rolloutRoot =
|
|
15357
|
-
const archivedRolloutRoot =
|
|
16809
|
+
const rolloutRoot = path9.join(codexHome, "sessions");
|
|
16810
|
+
const archivedRolloutRoot = path9.join(codexHome, "archived_sessions");
|
|
15358
16811
|
const [rolloutFiles, archivedRolloutFiles] = await Promise.all([
|
|
15359
16812
|
walkRolloutFiles3(rolloutRoot),
|
|
15360
16813
|
walkRolloutFiles3(archivedRolloutRoot)
|
|
@@ -15381,7 +16834,7 @@ var discoverLocalCodexData = async (options = {}) => {
|
|
|
15381
16834
|
const gitInfo = readGitInfo(record.cwd);
|
|
15382
16835
|
projectMap.set(projectKey, {
|
|
15383
16836
|
id: stableId("project", projectKey),
|
|
15384
|
-
agent_id: options.agentId ?? stableId("agent", options.agentName ??
|
|
16837
|
+
agent_id: options.agentId ?? stableId("agent", options.agentName ?? os8.hostname()),
|
|
15385
16838
|
name: basenameFromPath(record.cwd),
|
|
15386
16839
|
display_name: workspaceRootLabels[projectKey] ?? null,
|
|
15387
16840
|
pinned: pinnedWorkspaceRoots.has(projectKey),
|
|
@@ -15424,13 +16877,13 @@ var discoverLocalCodexData = async (options = {}) => {
|
|
|
15424
16877
|
capability: buildSessionCapability(mode === "attached-live", record.archived)
|
|
15425
16878
|
});
|
|
15426
16879
|
}
|
|
15427
|
-
const agentId = options.agentId ?? stableId("agent", options.agentName ??
|
|
16880
|
+
const agentId = options.agentId ?? stableId("agent", options.agentName ?? os8.hostname());
|
|
15428
16881
|
const host = resolveHostAddress2(options.host);
|
|
15429
16882
|
const directBaseUrl = options.directBaseUrl?.trim() || `http://${host}:4242`;
|
|
15430
16883
|
const wsBaseUrl = options.wsBaseUrl?.trim() || directBaseUrl.replace(/^http/i, "ws").replace(/\/+$/, "") + "/ws";
|
|
15431
16884
|
const agent = {
|
|
15432
16885
|
id: agentId,
|
|
15433
|
-
name: options.agentName ??
|
|
16886
|
+
name: options.agentName ?? os8.hostname(),
|
|
15434
16887
|
host,
|
|
15435
16888
|
tailscale_ip: options.tailscaleIp ?? (host.startsWith("100.") ? host : null),
|
|
15436
16889
|
tailscale_dns_name: options.tailscaleDnsName ?? null,
|
|
@@ -15511,8 +16964,19 @@ export {
|
|
|
15511
16964
|
createCodexRolloutMonitor,
|
|
15512
16965
|
createCodexLiveSessionStream,
|
|
15513
16966
|
startPandaSessionService,
|
|
16967
|
+
getPandaHubApiKeyFilePath,
|
|
16968
|
+
resolvePandaHubApiKey,
|
|
16969
|
+
ensurePandaHubApiKey,
|
|
16970
|
+
buildTailscaleHttpsUrl,
|
|
16971
|
+
resolveCliOptionValue,
|
|
16972
|
+
readTailscaleStatus,
|
|
16973
|
+
isTailscaleRunning,
|
|
16974
|
+
resolveTailscaleServeEnabled,
|
|
16975
|
+
resolveTailscaleServePort,
|
|
16976
|
+
configureTailscaleServe,
|
|
15514
16977
|
resolveAgentNetworkIdentity,
|
|
15515
16978
|
startAgentHubSync,
|
|
16979
|
+
printTerminalQr,
|
|
15516
16980
|
readCodexTimelineDetails,
|
|
15517
16981
|
readCodexTimeline,
|
|
15518
16982
|
discoverLocalCodexData,
|