opencrush 0.3.4 → 0.3.5
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/index.js +527 -598
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -562,52 +562,15 @@ var init_source = __esm({
|
|
|
562
562
|
// src/paths.ts
|
|
563
563
|
var paths_exports = {};
|
|
564
564
|
__export(paths_exports, {
|
|
565
|
-
|
|
565
|
+
ROOT_DIR: () => ROOT_DIR,
|
|
566
566
|
ensureHomeDirExists: () => ensureHomeDirExists,
|
|
567
|
-
ensureTemplatesSynced: () => ensureTemplatesSynced,
|
|
568
|
-
getBundledTemplatesDir: () => getBundledTemplatesDir,
|
|
569
567
|
getCharactersDir: () => getCharactersDir,
|
|
570
568
|
getEnvPath: () => getEnvPath,
|
|
571
569
|
getTemplatesDir: () => getTemplatesDir,
|
|
572
570
|
isConfigured: () => isConfigured
|
|
573
571
|
});
|
|
574
572
|
function ensureHomeDirExists() {
|
|
575
|
-
(0, import_fs.mkdirSync)((
|
|
576
|
-
}
|
|
577
|
-
function getEnvPath() {
|
|
578
|
-
return (0, import_path.join)(OPENCRUSH_HOME, "config.env");
|
|
579
|
-
}
|
|
580
|
-
function getCharactersDir() {
|
|
581
|
-
return (0, import_path.join)(OPENCRUSH_HOME, "characters");
|
|
582
|
-
}
|
|
583
|
-
function getBundledTemplatesDir() {
|
|
584
|
-
const candidates = [
|
|
585
|
-
(0, import_path.join)(_dirname, "..", "templates"),
|
|
586
|
-
// npm package (dist/ → templates/)
|
|
587
|
-
(0, import_path.join)(_dirname, "..", "..", "templates")
|
|
588
|
-
// monorepo root templates/
|
|
589
|
-
];
|
|
590
|
-
for (const p2 of candidates) {
|
|
591
|
-
if ((0, import_fs.existsSync)(p2)) return p2;
|
|
592
|
-
}
|
|
593
|
-
return candidates[0];
|
|
594
|
-
}
|
|
595
|
-
function getTemplatesDir() {
|
|
596
|
-
const userTemplates = (0, import_path.join)(OPENCRUSH_HOME, "templates");
|
|
597
|
-
ensureTemplatesSynced();
|
|
598
|
-
return userTemplates;
|
|
599
|
-
}
|
|
600
|
-
function ensureTemplatesSynced() {
|
|
601
|
-
const dest = (0, import_path.join)(OPENCRUSH_HOME, "templates");
|
|
602
|
-
const src = getBundledTemplatesDir();
|
|
603
|
-
if (!(0, import_fs.existsSync)(src)) return;
|
|
604
|
-
(0, import_fs.mkdirSync)(dest, { recursive: true });
|
|
605
|
-
for (const file of (0, import_fs.readdirSync)(src)) {
|
|
606
|
-
const destFile = (0, import_path.join)(dest, file);
|
|
607
|
-
if (!(0, import_fs.existsSync)(destFile)) {
|
|
608
|
-
(0, import_fs.copyFileSync)((0, import_path.join)(src, file), destFile);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
573
|
+
(0, import_fs.mkdirSync)(getCharactersDir(), { recursive: true });
|
|
611
574
|
}
|
|
612
575
|
function isConfigured() {
|
|
613
576
|
const envPath = getEnvPath();
|
|
@@ -618,14 +581,15 @@ function isConfigured() {
|
|
|
618
581
|
return false;
|
|
619
582
|
}
|
|
620
583
|
}
|
|
621
|
-
var
|
|
584
|
+
var import_path, import_fs, ROOT_DIR, getEnvPath, getCharactersDir, getTemplatesDir;
|
|
622
585
|
var init_paths = __esm({
|
|
623
586
|
"src/paths.ts"() {
|
|
624
|
-
import_os = require("os");
|
|
625
587
|
import_path = require("path");
|
|
626
588
|
import_fs = require("fs");
|
|
627
|
-
|
|
628
|
-
|
|
589
|
+
ROOT_DIR = process.env.INIT_CWD ?? process.cwd();
|
|
590
|
+
getEnvPath = () => (0, import_path.join)(ROOT_DIR, ".env");
|
|
591
|
+
getCharactersDir = () => (0, import_path.join)(ROOT_DIR, "characters");
|
|
592
|
+
getTemplatesDir = () => (0, import_path.join)(ROOT_DIR, "templates");
|
|
629
593
|
}
|
|
630
594
|
});
|
|
631
595
|
|
|
@@ -3701,13 +3665,13 @@ var init_promise_polyfill = __esm({
|
|
|
3701
3665
|
// Available starting from Node 22
|
|
3702
3666
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
3703
3667
|
static withResolver() {
|
|
3704
|
-
let
|
|
3668
|
+
let resolve;
|
|
3705
3669
|
let reject;
|
|
3706
3670
|
const promise = new Promise((res, rej) => {
|
|
3707
|
-
|
|
3671
|
+
resolve = res;
|
|
3708
3672
|
reject = rej;
|
|
3709
3673
|
});
|
|
3710
|
-
return { promise, resolve
|
|
3674
|
+
return { promise, resolve, reject };
|
|
3711
3675
|
}
|
|
3712
3676
|
};
|
|
3713
3677
|
}
|
|
@@ -3743,7 +3707,7 @@ function createPrompt(view) {
|
|
|
3743
3707
|
output
|
|
3744
3708
|
});
|
|
3745
3709
|
const screen = new ScreenManager(rl);
|
|
3746
|
-
const { promise, resolve
|
|
3710
|
+
const { promise, resolve, reject } = PromisePolyfill.withResolver();
|
|
3747
3711
|
const cancel = () => reject(new CancelPromptError());
|
|
3748
3712
|
if (signal) {
|
|
3749
3713
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -3771,7 +3735,7 @@ function createPrompt(view) {
|
|
|
3771
3735
|
var _a3;
|
|
3772
3736
|
try {
|
|
3773
3737
|
const nextView = view(config, (value) => {
|
|
3774
|
-
setImmediate(() =>
|
|
3738
|
+
setImmediate(() => resolve(value));
|
|
3775
3739
|
});
|
|
3776
3740
|
if (nextView === void 0) {
|
|
3777
3741
|
const callerFilename = (_a3 = callSites[1]) == null ? void 0 : _a3.getFileName();
|
|
@@ -9626,7 +9590,7 @@ var require_lib2 = __commonJS({
|
|
|
9626
9590
|
return matches;
|
|
9627
9591
|
};
|
|
9628
9592
|
exports2.analyse = analyse;
|
|
9629
|
-
var detectFile = (filepath, opts = {}) => new Promise((
|
|
9593
|
+
var detectFile = (filepath, opts = {}) => new Promise((resolve, reject) => {
|
|
9630
9594
|
let fd;
|
|
9631
9595
|
const fs4 = (0, node_1.default)();
|
|
9632
9596
|
const handler = (err, buffer) => {
|
|
@@ -9636,7 +9600,7 @@ var require_lib2 = __commonJS({
|
|
|
9636
9600
|
if (err) {
|
|
9637
9601
|
reject(err);
|
|
9638
9602
|
} else if (buffer) {
|
|
9639
|
-
|
|
9603
|
+
resolve((0, exports2.detect)(buffer));
|
|
9640
9604
|
} else {
|
|
9641
9605
|
reject(new Error("No error and no buffer received"));
|
|
9642
9606
|
}
|
|
@@ -15356,7 +15320,7 @@ var require_Observable = __commonJS({
|
|
|
15356
15320
|
Observable2.prototype.forEach = function(next2, promiseCtor) {
|
|
15357
15321
|
var _this = this;
|
|
15358
15322
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
15359
|
-
return new promiseCtor(function(
|
|
15323
|
+
return new promiseCtor(function(resolve, reject) {
|
|
15360
15324
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
15361
15325
|
next: function(value) {
|
|
15362
15326
|
try {
|
|
@@ -15367,7 +15331,7 @@ var require_Observable = __commonJS({
|
|
|
15367
15331
|
}
|
|
15368
15332
|
},
|
|
15369
15333
|
error: reject,
|
|
15370
|
-
complete:
|
|
15334
|
+
complete: resolve
|
|
15371
15335
|
});
|
|
15372
15336
|
_this.subscribe(subscriber);
|
|
15373
15337
|
});
|
|
@@ -15389,14 +15353,14 @@ var require_Observable = __commonJS({
|
|
|
15389
15353
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
15390
15354
|
var _this = this;
|
|
15391
15355
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
15392
|
-
return new promiseCtor(function(
|
|
15356
|
+
return new promiseCtor(function(resolve, reject) {
|
|
15393
15357
|
var value;
|
|
15394
15358
|
_this.subscribe(function(x2) {
|
|
15395
15359
|
return value = x2;
|
|
15396
15360
|
}, function(err) {
|
|
15397
15361
|
return reject(err);
|
|
15398
15362
|
}, function() {
|
|
15399
|
-
return
|
|
15363
|
+
return resolve(value);
|
|
15400
15364
|
});
|
|
15401
15365
|
});
|
|
15402
15366
|
};
|
|
@@ -17492,11 +17456,11 @@ var require_innerFrom = __commonJS({
|
|
|
17492
17456
|
"use strict";
|
|
17493
17457
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
17494
17458
|
function adopt(value) {
|
|
17495
|
-
return value instanceof P2 ? value : new P2(function(
|
|
17496
|
-
|
|
17459
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
17460
|
+
resolve(value);
|
|
17497
17461
|
});
|
|
17498
17462
|
}
|
|
17499
|
-
return new (P2 || (P2 = Promise))(function(
|
|
17463
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
17500
17464
|
function fulfilled(value) {
|
|
17501
17465
|
try {
|
|
17502
17466
|
step(generator.next(value));
|
|
@@ -17512,7 +17476,7 @@ var require_innerFrom = __commonJS({
|
|
|
17512
17476
|
}
|
|
17513
17477
|
}
|
|
17514
17478
|
function step(result) {
|
|
17515
|
-
result.done ?
|
|
17479
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
17516
17480
|
}
|
|
17517
17481
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17518
17482
|
});
|
|
@@ -17594,14 +17558,14 @@ var require_innerFrom = __commonJS({
|
|
|
17594
17558
|
}, i2);
|
|
17595
17559
|
function verb(n2) {
|
|
17596
17560
|
i2[n2] = o2[n2] && function(v2) {
|
|
17597
|
-
return new Promise(function(
|
|
17598
|
-
v2 = o2[n2](v2), settle(
|
|
17561
|
+
return new Promise(function(resolve, reject) {
|
|
17562
|
+
v2 = o2[n2](v2), settle(resolve, reject, v2.done, v2.value);
|
|
17599
17563
|
});
|
|
17600
17564
|
};
|
|
17601
17565
|
}
|
|
17602
|
-
function settle(
|
|
17566
|
+
function settle(resolve, reject, d2, v2) {
|
|
17603
17567
|
Promise.resolve(v2).then(function(v6) {
|
|
17604
|
-
|
|
17568
|
+
resolve({ value: v6, done: d2 });
|
|
17605
17569
|
}, reject);
|
|
17606
17570
|
}
|
|
17607
17571
|
};
|
|
@@ -18220,7 +18184,7 @@ var require_lastValueFrom = __commonJS({
|
|
|
18220
18184
|
var EmptyError_1 = require_EmptyError();
|
|
18221
18185
|
function lastValueFrom2(source, config) {
|
|
18222
18186
|
var hasConfig = typeof config === "object";
|
|
18223
|
-
return new Promise(function(
|
|
18187
|
+
return new Promise(function(resolve, reject) {
|
|
18224
18188
|
var _hasValue = false;
|
|
18225
18189
|
var _value;
|
|
18226
18190
|
source.subscribe({
|
|
@@ -18231,9 +18195,9 @@ var require_lastValueFrom = __commonJS({
|
|
|
18231
18195
|
error: reject,
|
|
18232
18196
|
complete: function() {
|
|
18233
18197
|
if (_hasValue) {
|
|
18234
|
-
|
|
18198
|
+
resolve(_value);
|
|
18235
18199
|
} else if (hasConfig) {
|
|
18236
|
-
|
|
18200
|
+
resolve(config.defaultValue);
|
|
18237
18201
|
} else {
|
|
18238
18202
|
reject(new EmptyError_1.EmptyError());
|
|
18239
18203
|
}
|
|
@@ -18255,16 +18219,16 @@ var require_firstValueFrom = __commonJS({
|
|
|
18255
18219
|
var Subscriber_1 = require_Subscriber();
|
|
18256
18220
|
function firstValueFrom(source, config) {
|
|
18257
18221
|
var hasConfig = typeof config === "object";
|
|
18258
|
-
return new Promise(function(
|
|
18222
|
+
return new Promise(function(resolve, reject) {
|
|
18259
18223
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
18260
18224
|
next: function(value) {
|
|
18261
|
-
|
|
18225
|
+
resolve(value);
|
|
18262
18226
|
subscriber.unsubscribe();
|
|
18263
18227
|
},
|
|
18264
18228
|
error: reject,
|
|
18265
18229
|
complete: function() {
|
|
18266
18230
|
if (hasConfig) {
|
|
18267
|
-
|
|
18231
|
+
resolve(config.defaultValue);
|
|
18268
18232
|
} else {
|
|
18269
18233
|
reject(new EmptyError_1.EmptyError());
|
|
18270
18234
|
}
|
|
@@ -24056,14 +24020,14 @@ var require_run_async = __commonJS({
|
|
|
24056
24020
|
return function() {
|
|
24057
24021
|
var args = arguments;
|
|
24058
24022
|
var originalThis = this;
|
|
24059
|
-
var promise = new Promise(function(
|
|
24023
|
+
var promise = new Promise(function(resolve, reject) {
|
|
24060
24024
|
var resolved = false;
|
|
24061
24025
|
const wrappedResolve = function(value) {
|
|
24062
24026
|
if (resolved) {
|
|
24063
24027
|
console.warn("Run-async promise already resolved.");
|
|
24064
24028
|
}
|
|
24065
24029
|
resolved = true;
|
|
24066
|
-
|
|
24030
|
+
resolve(value);
|
|
24067
24031
|
};
|
|
24068
24032
|
var rejected = false;
|
|
24069
24033
|
const wrappedReject = function(value) {
|
|
@@ -24292,7 +24256,7 @@ var init_prompt = __esm({
|
|
|
24292
24256
|
throw new Error(`Prompt for type ${question.type} not found`);
|
|
24293
24257
|
}
|
|
24294
24258
|
let cleanupSignal;
|
|
24295
|
-
const promptFn = isPromptConstructor(prompt2) ? (q2, opt) => new Promise((
|
|
24259
|
+
const promptFn = isPromptConstructor(prompt2) ? (q2, opt) => new Promise((resolve, reject) => {
|
|
24296
24260
|
const { signal: signal2 } = opt;
|
|
24297
24261
|
if (signal2.aborted) {
|
|
24298
24262
|
reject(new AbortPromptError({ cause: signal2.reason }));
|
|
@@ -24329,7 +24293,7 @@ var init_prompt = __esm({
|
|
|
24329
24293
|
signal2.removeEventListener("abort", abort);
|
|
24330
24294
|
cleanupSignal = void 0;
|
|
24331
24295
|
};
|
|
24332
|
-
activePrompt.run().then(
|
|
24296
|
+
activePrompt.run().then(resolve, reject).finally(cleanup);
|
|
24333
24297
|
}) : prompt2;
|
|
24334
24298
|
let cleanupModuleSignal;
|
|
24335
24299
|
const { signal: moduleSignal } = this.opt;
|
|
@@ -30418,7 +30382,7 @@ function consumeBody() {
|
|
|
30418
30382
|
let accum = [];
|
|
30419
30383
|
let accumBytes = 0;
|
|
30420
30384
|
let abort = false;
|
|
30421
|
-
return new Body.Promise(function(
|
|
30385
|
+
return new Body.Promise(function(resolve, reject) {
|
|
30422
30386
|
let resTimeout;
|
|
30423
30387
|
if (_this4.timeout) {
|
|
30424
30388
|
resTimeout = setTimeout(function() {
|
|
@@ -30452,7 +30416,7 @@ function consumeBody() {
|
|
|
30452
30416
|
}
|
|
30453
30417
|
clearTimeout(resTimeout);
|
|
30454
30418
|
try {
|
|
30455
|
-
|
|
30419
|
+
resolve(Buffer.concat(accum, accumBytes));
|
|
30456
30420
|
} catch (err) {
|
|
30457
30421
|
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
30458
30422
|
}
|
|
@@ -30715,7 +30679,7 @@ function fetch3(url, opts) {
|
|
|
30715
30679
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
30716
30680
|
}
|
|
30717
30681
|
Body.Promise = fetch3.Promise;
|
|
30718
|
-
return new fetch3.Promise(function(
|
|
30682
|
+
return new fetch3.Promise(function(resolve, reject) {
|
|
30719
30683
|
const request2 = new Request2(url, opts);
|
|
30720
30684
|
const options2 = getNodeRequestOptions(request2);
|
|
30721
30685
|
const send = (options2.protocol === "https:" ? import_https.default : import_http.default).request;
|
|
@@ -30848,7 +30812,7 @@ function fetch3(url, opts) {
|
|
|
30848
30812
|
requestOpts.body = void 0;
|
|
30849
30813
|
requestOpts.headers.delete("content-length");
|
|
30850
30814
|
}
|
|
30851
|
-
|
|
30815
|
+
resolve(fetch3(new Request2(locationURL, requestOpts)));
|
|
30852
30816
|
finalize();
|
|
30853
30817
|
return;
|
|
30854
30818
|
}
|
|
@@ -30869,7 +30833,7 @@ function fetch3(url, opts) {
|
|
|
30869
30833
|
const codings = headers.get("Content-Encoding");
|
|
30870
30834
|
if (!request2.compress || request2.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
30871
30835
|
response = new Response3(body, response_options);
|
|
30872
|
-
|
|
30836
|
+
resolve(response);
|
|
30873
30837
|
return;
|
|
30874
30838
|
}
|
|
30875
30839
|
const zlibOptions = {
|
|
@@ -30879,7 +30843,7 @@ function fetch3(url, opts) {
|
|
|
30879
30843
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
30880
30844
|
body = body.pipe(import_zlib.default.createGunzip(zlibOptions));
|
|
30881
30845
|
response = new Response3(body, response_options);
|
|
30882
|
-
|
|
30846
|
+
resolve(response);
|
|
30883
30847
|
return;
|
|
30884
30848
|
}
|
|
30885
30849
|
if (codings == "deflate" || codings == "x-deflate") {
|
|
@@ -30891,12 +30855,12 @@ function fetch3(url, opts) {
|
|
|
30891
30855
|
body = body.pipe(import_zlib.default.createInflateRaw());
|
|
30892
30856
|
}
|
|
30893
30857
|
response = new Response3(body, response_options);
|
|
30894
|
-
|
|
30858
|
+
resolve(response);
|
|
30895
30859
|
});
|
|
30896
30860
|
raw.on("end", function() {
|
|
30897
30861
|
if (!response) {
|
|
30898
30862
|
response = new Response3(body, response_options);
|
|
30899
|
-
|
|
30863
|
+
resolve(response);
|
|
30900
30864
|
}
|
|
30901
30865
|
});
|
|
30902
30866
|
return;
|
|
@@ -30904,11 +30868,11 @@ function fetch3(url, opts) {
|
|
|
30904
30868
|
if (codings == "br" && typeof import_zlib.default.createBrotliDecompress === "function") {
|
|
30905
30869
|
body = body.pipe(import_zlib.default.createBrotliDecompress());
|
|
30906
30870
|
response = new Response3(body, response_options);
|
|
30907
|
-
|
|
30871
|
+
resolve(response);
|
|
30908
30872
|
return;
|
|
30909
30873
|
}
|
|
30910
30874
|
response = new Response3(body, response_options);
|
|
30911
|
-
|
|
30875
|
+
resolve(response);
|
|
30912
30876
|
});
|
|
30913
30877
|
writeToStream(req, request2);
|
|
30914
30878
|
});
|
|
@@ -36121,8 +36085,8 @@ var init_core = __esm({
|
|
|
36121
36085
|
};
|
|
36122
36086
|
APIPromise = class _APIPromise extends Promise {
|
|
36123
36087
|
constructor(responsePromise, parseResponse = defaultParseResponse) {
|
|
36124
|
-
super((
|
|
36125
|
-
|
|
36088
|
+
super((resolve) => {
|
|
36089
|
+
resolve(null);
|
|
36126
36090
|
});
|
|
36127
36091
|
this.responsePromise = responsePromise;
|
|
36128
36092
|
this.parseResponse = parseResponse;
|
|
@@ -36662,7 +36626,7 @@ var init_core = __esm({
|
|
|
36662
36626
|
isAbsoluteURL = (url) => {
|
|
36663
36627
|
return startsWithSchemeRegexp.test(url);
|
|
36664
36628
|
};
|
|
36665
|
-
sleep = (ms) => new Promise((
|
|
36629
|
+
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
36666
36630
|
validatePositiveInteger = (name, n2) => {
|
|
36667
36631
|
if (typeof n2 !== "number" || !Number.isInteger(n2)) {
|
|
36668
36632
|
throw new AnthropicError(`${name} must be an integer`);
|
|
@@ -37269,12 +37233,12 @@ var init_PromptCachingBetaMessageStream = __esm({
|
|
|
37269
37233
|
}
|
|
37270
37234
|
return this._emit("error", new AnthropicError(String(error2)));
|
|
37271
37235
|
});
|
|
37272
|
-
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((
|
|
37273
|
-
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_resolveConnectedPromise,
|
|
37236
|
+
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve, reject) => {
|
|
37237
|
+
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve, "f");
|
|
37274
37238
|
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
37275
37239
|
}), "f");
|
|
37276
|
-
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_endPromise, new Promise((
|
|
37277
|
-
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_resolveEndPromise,
|
|
37240
|
+
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve, reject) => {
|
|
37241
|
+
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve, "f");
|
|
37278
37242
|
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_rejectEndPromise, reject, "f");
|
|
37279
37243
|
}), "f");
|
|
37280
37244
|
__classPrivateFieldGet7(this, _PromptCachingBetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -37404,11 +37368,11 @@ var init_PromptCachingBetaMessageStream = __esm({
|
|
|
37404
37368
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
37405
37369
|
*/
|
|
37406
37370
|
emitted(event) {
|
|
37407
|
-
return new Promise((
|
|
37371
|
+
return new Promise((resolve, reject) => {
|
|
37408
37372
|
__classPrivateFieldSet6(this, _PromptCachingBetaMessageStream_catchingPromiseCreated, true, "f");
|
|
37409
37373
|
if (event !== "error")
|
|
37410
37374
|
this.once("error", reject);
|
|
37411
|
-
this.once(event,
|
|
37375
|
+
this.once(event, resolve);
|
|
37412
37376
|
});
|
|
37413
37377
|
}
|
|
37414
37378
|
async done() {
|
|
@@ -37636,7 +37600,7 @@ var init_PromptCachingBetaMessageStream = __esm({
|
|
|
37636
37600
|
if (done) {
|
|
37637
37601
|
return { value: void 0, done: true };
|
|
37638
37602
|
}
|
|
37639
|
-
return new Promise((
|
|
37603
|
+
return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
37640
37604
|
}
|
|
37641
37605
|
const chunk = pushQueue.shift();
|
|
37642
37606
|
return { value: chunk, done: false };
|
|
@@ -37801,12 +37765,12 @@ var init_MessageStream = __esm({
|
|
|
37801
37765
|
}
|
|
37802
37766
|
return this._emit("error", new AnthropicError(String(error2)));
|
|
37803
37767
|
});
|
|
37804
|
-
__classPrivateFieldSet7(this, _MessageStream_connectedPromise, new Promise((
|
|
37805
|
-
__classPrivateFieldSet7(this, _MessageStream_resolveConnectedPromise,
|
|
37768
|
+
__classPrivateFieldSet7(this, _MessageStream_connectedPromise, new Promise((resolve, reject) => {
|
|
37769
|
+
__classPrivateFieldSet7(this, _MessageStream_resolveConnectedPromise, resolve, "f");
|
|
37806
37770
|
__classPrivateFieldSet7(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
37807
37771
|
}), "f");
|
|
37808
|
-
__classPrivateFieldSet7(this, _MessageStream_endPromise, new Promise((
|
|
37809
|
-
__classPrivateFieldSet7(this, _MessageStream_resolveEndPromise,
|
|
37772
|
+
__classPrivateFieldSet7(this, _MessageStream_endPromise, new Promise((resolve, reject) => {
|
|
37773
|
+
__classPrivateFieldSet7(this, _MessageStream_resolveEndPromise, resolve, "f");
|
|
37810
37774
|
__classPrivateFieldSet7(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
37811
37775
|
}), "f");
|
|
37812
37776
|
__classPrivateFieldGet8(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -37936,11 +37900,11 @@ var init_MessageStream = __esm({
|
|
|
37936
37900
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
37937
37901
|
*/
|
|
37938
37902
|
emitted(event) {
|
|
37939
|
-
return new Promise((
|
|
37903
|
+
return new Promise((resolve, reject) => {
|
|
37940
37904
|
__classPrivateFieldSet7(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
37941
37905
|
if (event !== "error")
|
|
37942
37906
|
this.once("error", reject);
|
|
37943
|
-
this.once(event,
|
|
37907
|
+
this.once(event, resolve);
|
|
37944
37908
|
});
|
|
37945
37909
|
}
|
|
37946
37910
|
async done() {
|
|
@@ -38168,7 +38132,7 @@ var init_MessageStream = __esm({
|
|
|
38168
38132
|
if (done) {
|
|
38169
38133
|
return { value: void 0, done: true };
|
|
38170
38134
|
}
|
|
38171
|
-
return new Promise((
|
|
38135
|
+
return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
38172
38136
|
}
|
|
38173
38137
|
const chunk = pushQueue.shift();
|
|
38174
38138
|
return { value: chunk, done: false };
|
|
@@ -39292,7 +39256,7 @@ function printCreationSuccess(folderName, name) {
|
|
|
39292
39256
|
console.log(source_default.gray(` Edit personality anytime: characters/${folderName}/SOUL.md`));
|
|
39293
39257
|
console.log();
|
|
39294
39258
|
}
|
|
39295
|
-
var import_fs4, import_path3, import_child_process2,
|
|
39259
|
+
var import_fs4, import_path3, import_child_process2, HAIR_COLORS, EYE_COLORS, SKIN_TONES, BODY_TYPES, SIGNATURE_FEATURES, FASHION_STYLES, PERSONALITY_TRAITS;
|
|
39296
39260
|
var init_create = __esm({
|
|
39297
39261
|
"src/create.ts"() {
|
|
39298
39262
|
init_esm16();
|
|
@@ -39304,10 +39268,7 @@ var init_create = __esm({
|
|
|
39304
39268
|
init_presets();
|
|
39305
39269
|
init_llm_direct();
|
|
39306
39270
|
init_paths();
|
|
39307
|
-
import_fs5 = require("fs");
|
|
39308
|
-
import_path4 = require("path");
|
|
39309
39271
|
ensureHomeDirExists();
|
|
39310
|
-
ROOT_DIR = (0, import_fs5.existsSync)((0, import_path4.resolve)(process.env.INIT_CWD ?? process.cwd(), ".env")) ? process.env.INIT_CWD ?? process.cwd() : OPENCRUSH_HOME;
|
|
39311
39272
|
HAIR_COLORS = [
|
|
39312
39273
|
"Jet black",
|
|
39313
39274
|
"Dark brown",
|
|
@@ -39450,18 +39411,18 @@ async function runTestChat(characterName, apiKey, provider) {
|
|
|
39450
39411
|
console.log(source_default.yellow(`
|
|
39451
39412
|
Edit the files in: characters/${characterName}/`));
|
|
39452
39413
|
console.log(source_default.yellow(" SOUL.md controls personality. IDENTITY.md controls backstory."));
|
|
39453
|
-
console.log(source_default.gray(" Run `
|
|
39414
|
+
console.log(source_default.gray(" Run `npx opencrush@latest setup` again when ready.\n"));
|
|
39454
39415
|
process.exit(0);
|
|
39455
39416
|
}
|
|
39456
39417
|
console.log(source_default.green("\n Great! Continuing...\n"));
|
|
39457
39418
|
}
|
|
39458
39419
|
async function buildTestSystemPrompt(characterName) {
|
|
39459
|
-
const dir = (0,
|
|
39460
|
-
if (!(0,
|
|
39420
|
+
const dir = (0, import_path4.join)(ROOT_DIR, "characters", characterName);
|
|
39421
|
+
if (!(0, import_fs5.existsSync)(dir)) return null;
|
|
39461
39422
|
const parts = [];
|
|
39462
39423
|
for (const file of ["IDENTITY.md", "SOUL.md", "USER.md", "MEMORY.md"]) {
|
|
39463
|
-
const filePath = (0,
|
|
39464
|
-
if ((0,
|
|
39424
|
+
const filePath = (0, import_path4.join)(dir, file);
|
|
39425
|
+
if ((0, import_fs5.existsSync)(filePath)) {
|
|
39465
39426
|
const { readFileSync: readFileSync8 } = await import("fs");
|
|
39466
39427
|
parts.push(readFileSync8(filePath, "utf-8"));
|
|
39467
39428
|
}
|
|
@@ -39476,19 +39437,16 @@ Keep your replies natural and conversational. 1-3 sentences unless the topic cal
|
|
|
39476
39437
|
async function callLLM(systemPrompt, history, apiKey, provider) {
|
|
39477
39438
|
return callLLMDirect(provider, apiKey, systemPrompt, history, 300);
|
|
39478
39439
|
}
|
|
39479
|
-
var
|
|
39440
|
+
var import_path4, import_fs5;
|
|
39480
39441
|
var init_test_chat = __esm({
|
|
39481
39442
|
"src/test-chat.ts"() {
|
|
39482
39443
|
init_esm16();
|
|
39483
39444
|
init_source();
|
|
39484
39445
|
init_ora();
|
|
39485
|
-
|
|
39486
|
-
|
|
39446
|
+
import_path4 = require("path");
|
|
39447
|
+
import_fs5 = require("fs");
|
|
39487
39448
|
init_llm_direct();
|
|
39488
39449
|
init_paths();
|
|
39489
|
-
import_fs7 = require("fs");
|
|
39490
|
-
import_path6 = require("path");
|
|
39491
|
-
ROOT_DIR2 = (0, import_fs7.existsSync)((0, import_path6.resolve)(process.env.INIT_CWD ?? process.cwd(), ".env")) ? process.env.INIT_CWD ?? process.cwd() : OPENCRUSH_HOME;
|
|
39492
39450
|
}
|
|
39493
39451
|
});
|
|
39494
39452
|
|
|
@@ -43008,11 +42966,11 @@ var require_FileFetcher = __commonJS({
|
|
|
43008
42966
|
};
|
|
43009
42967
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
43010
42968
|
function adopt(value) {
|
|
43011
|
-
return value instanceof P2 ? value : new P2(function(
|
|
43012
|
-
|
|
42969
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
42970
|
+
resolve(value);
|
|
43013
42971
|
});
|
|
43014
42972
|
}
|
|
43015
|
-
return new (P2 || (P2 = Promise))(function(
|
|
42973
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
43016
42974
|
function fulfilled(value) {
|
|
43017
42975
|
try {
|
|
43018
42976
|
step(generator.next(value));
|
|
@@ -43028,7 +42986,7 @@ var require_FileFetcher = __commonJS({
|
|
|
43028
42986
|
}
|
|
43029
42987
|
}
|
|
43030
42988
|
function step(result) {
|
|
43031
|
-
result.done ?
|
|
42989
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
43032
42990
|
}
|
|
43033
42991
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43034
42992
|
});
|
|
@@ -43791,11 +43749,11 @@ var require_LocalIndex = __commonJS({
|
|
|
43791
43749
|
};
|
|
43792
43750
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
43793
43751
|
function adopt(value) {
|
|
43794
|
-
return value instanceof P2 ? value : new P2(function(
|
|
43795
|
-
|
|
43752
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
43753
|
+
resolve(value);
|
|
43796
43754
|
});
|
|
43797
43755
|
}
|
|
43798
|
-
return new (P2 || (P2 = Promise))(function(
|
|
43756
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
43799
43757
|
function fulfilled(value) {
|
|
43800
43758
|
try {
|
|
43801
43759
|
step(generator.next(value));
|
|
@@ -43811,7 +43769,7 @@ var require_LocalIndex = __commonJS({
|
|
|
43811
43769
|
}
|
|
43812
43770
|
}
|
|
43813
43771
|
function step(result) {
|
|
43814
|
-
result.done ?
|
|
43772
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
43815
43773
|
}
|
|
43816
43774
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43817
43775
|
});
|
|
@@ -44199,11 +44157,11 @@ var require_LocalDocument = __commonJS({
|
|
|
44199
44157
|
};
|
|
44200
44158
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
44201
44159
|
function adopt(value) {
|
|
44202
|
-
return value instanceof P2 ? value : new P2(function(
|
|
44203
|
-
|
|
44160
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
44161
|
+
resolve(value);
|
|
44204
44162
|
});
|
|
44205
44163
|
}
|
|
44206
|
-
return new (P2 || (P2 = Promise))(function(
|
|
44164
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
44207
44165
|
function fulfilled(value) {
|
|
44208
44166
|
try {
|
|
44209
44167
|
step(generator.next(value));
|
|
@@ -44219,7 +44177,7 @@ var require_LocalDocument = __commonJS({
|
|
|
44219
44177
|
}
|
|
44220
44178
|
}
|
|
44221
44179
|
function step(result) {
|
|
44222
|
-
result.done ?
|
|
44180
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
44223
44181
|
}
|
|
44224
44182
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44225
44183
|
});
|
|
@@ -44852,11 +44810,11 @@ var require_LocalDocumentResult = __commonJS({
|
|
|
44852
44810
|
"use strict";
|
|
44853
44811
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
44854
44812
|
function adopt(value) {
|
|
44855
|
-
return value instanceof P2 ? value : new P2(function(
|
|
44856
|
-
|
|
44813
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
44814
|
+
resolve(value);
|
|
44857
44815
|
});
|
|
44858
44816
|
}
|
|
44859
|
-
return new (P2 || (P2 = Promise))(function(
|
|
44817
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
44860
44818
|
function fulfilled(value) {
|
|
44861
44819
|
try {
|
|
44862
44820
|
step(generator.next(value));
|
|
@@ -44872,7 +44830,7 @@ var require_LocalDocumentResult = __commonJS({
|
|
|
44872
44830
|
}
|
|
44873
44831
|
}
|
|
44874
44832
|
function step(result) {
|
|
44875
|
-
result.done ?
|
|
44833
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
44876
44834
|
}
|
|
44877
44835
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44878
44836
|
});
|
|
@@ -45154,11 +45112,11 @@ var require_LocalDocumentIndex = __commonJS({
|
|
|
45154
45112
|
};
|
|
45155
45113
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
45156
45114
|
function adopt(value) {
|
|
45157
|
-
return value instanceof P2 ? value : new P2(function(
|
|
45158
|
-
|
|
45115
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
45116
|
+
resolve(value);
|
|
45159
45117
|
});
|
|
45160
45118
|
}
|
|
45161
|
-
return new (P2 || (P2 = Promise))(function(
|
|
45119
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
45162
45120
|
function fulfilled(value) {
|
|
45163
45121
|
try {
|
|
45164
45122
|
step(generator.next(value));
|
|
@@ -45174,7 +45132,7 @@ var require_LocalDocumentIndex = __commonJS({
|
|
|
45174
45132
|
}
|
|
45175
45133
|
}
|
|
45176
45134
|
function step(result) {
|
|
45177
|
-
result.done ?
|
|
45135
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
45178
45136
|
}
|
|
45179
45137
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45180
45138
|
});
|
|
@@ -58338,10 +58296,10 @@ var require_axios = __commonJS({
|
|
|
58338
58296
|
}
|
|
58339
58297
|
};
|
|
58340
58298
|
var CanceledError$1 = CanceledError;
|
|
58341
|
-
function settle(
|
|
58299
|
+
function settle(resolve, reject, response) {
|
|
58342
58300
|
const validateStatus = response.config.validateStatus;
|
|
58343
58301
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
58344
|
-
|
|
58302
|
+
resolve(response);
|
|
58345
58303
|
} else {
|
|
58346
58304
|
reject(
|
|
58347
58305
|
new AxiosError$1(
|
|
@@ -58933,7 +58891,7 @@ var require_axios = __commonJS({
|
|
|
58933
58891
|
}
|
|
58934
58892
|
var isHttpAdapterSupported = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
|
|
58935
58893
|
var wrapAsync = (asyncExecutor) => {
|
|
58936
|
-
return new Promise((
|
|
58894
|
+
return new Promise((resolve, reject) => {
|
|
58937
58895
|
let onDone;
|
|
58938
58896
|
let isDone;
|
|
58939
58897
|
const done = (value, isRejected) => {
|
|
@@ -58941,15 +58899,15 @@ var require_axios = __commonJS({
|
|
|
58941
58899
|
isDone = true;
|
|
58942
58900
|
onDone && onDone(value, isRejected);
|
|
58943
58901
|
};
|
|
58944
|
-
const
|
|
58902
|
+
const _resolve = (value) => {
|
|
58945
58903
|
done(value);
|
|
58946
|
-
|
|
58904
|
+
resolve(value);
|
|
58947
58905
|
};
|
|
58948
58906
|
const _reject = (reason) => {
|
|
58949
58907
|
done(reason, true);
|
|
58950
58908
|
reject(reason);
|
|
58951
58909
|
};
|
|
58952
|
-
asyncExecutor(
|
|
58910
|
+
asyncExecutor(_resolve, _reject, (onDoneHandler) => onDone = onDoneHandler).catch(_reject);
|
|
58953
58911
|
});
|
|
58954
58912
|
};
|
|
58955
58913
|
var resolveFamily = ({ address, family }) => {
|
|
@@ -58990,7 +58948,7 @@ var require_axios = __commonJS({
|
|
|
58990
58948
|
}
|
|
58991
58949
|
};
|
|
58992
58950
|
var httpAdapter = isHttpAdapterSupported && function httpAdapter2(config) {
|
|
58993
|
-
return wrapAsync(async function dispatchHttpRequest(
|
|
58951
|
+
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
|
58994
58952
|
let { data, lookup, family, httpVersion = 1, http2Options } = config;
|
|
58995
58953
|
const { responseType, responseEncoding } = config;
|
|
58996
58954
|
const method = config.method.toUpperCase();
|
|
@@ -59080,7 +59038,7 @@ var require_axios = __commonJS({
|
|
|
59080
59038
|
}
|
|
59081
59039
|
let convertedData;
|
|
59082
59040
|
if (method !== "GET") {
|
|
59083
|
-
return settle(
|
|
59041
|
+
return settle(resolve, reject, {
|
|
59084
59042
|
status: 405,
|
|
59085
59043
|
statusText: "method not allowed",
|
|
59086
59044
|
headers: {},
|
|
@@ -59102,7 +59060,7 @@ var require_axios = __commonJS({
|
|
|
59102
59060
|
} else if (responseType === "stream") {
|
|
59103
59061
|
convertedData = stream__default["default"].Readable.from(convertedData);
|
|
59104
59062
|
}
|
|
59105
|
-
return settle(
|
|
59063
|
+
return settle(resolve, reject, {
|
|
59106
59064
|
data: convertedData,
|
|
59107
59065
|
status: 200,
|
|
59108
59066
|
statusText: "OK",
|
|
@@ -59343,7 +59301,7 @@ var require_axios = __commonJS({
|
|
|
59343
59301
|
};
|
|
59344
59302
|
if (responseType === "stream") {
|
|
59345
59303
|
response.data = responseStream;
|
|
59346
|
-
settle(
|
|
59304
|
+
settle(resolve, reject, response);
|
|
59347
59305
|
} else {
|
|
59348
59306
|
const responseBuffer = [];
|
|
59349
59307
|
let totalResponseBytes = 0;
|
|
@@ -59393,7 +59351,7 @@ var require_axios = __commonJS({
|
|
|
59393
59351
|
} catch (err) {
|
|
59394
59352
|
return reject(AxiosError$1.from(err, null, config, response.request, response));
|
|
59395
59353
|
}
|
|
59396
|
-
settle(
|
|
59354
|
+
settle(resolve, reject, response);
|
|
59397
59355
|
});
|
|
59398
59356
|
}
|
|
59399
59357
|
abortEmitter.once("abort", (err) => {
|
|
@@ -59643,7 +59601,7 @@ var require_axios = __commonJS({
|
|
|
59643
59601
|
};
|
|
59644
59602
|
var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
59645
59603
|
var xhrAdapter = isXHRAdapterSupported && function(config) {
|
|
59646
|
-
return new Promise(function dispatchXhrRequest(
|
|
59604
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
59647
59605
|
const _config = resolveConfig(config);
|
|
59648
59606
|
let requestData = _config.data;
|
|
59649
59607
|
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
@@ -59677,8 +59635,8 @@ var require_axios = __commonJS({
|
|
|
59677
59635
|
request: request2
|
|
59678
59636
|
};
|
|
59679
59637
|
settle(
|
|
59680
|
-
function
|
|
59681
|
-
|
|
59638
|
+
function _resolve(value) {
|
|
59639
|
+
resolve(value);
|
|
59682
59640
|
done();
|
|
59683
59641
|
},
|
|
59684
59642
|
function _reject(err) {
|
|
@@ -60070,8 +60028,8 @@ var require_axios = __commonJS({
|
|
|
60070
60028
|
config
|
|
60071
60029
|
);
|
|
60072
60030
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
60073
|
-
return await new Promise((
|
|
60074
|
-
settle(
|
|
60031
|
+
return await new Promise((resolve, reject) => {
|
|
60032
|
+
settle(resolve, reject, {
|
|
60075
60033
|
data: responseData,
|
|
60076
60034
|
headers: AxiosHeaders$1.from(response.headers),
|
|
60077
60035
|
status: response.status,
|
|
@@ -60475,8 +60433,8 @@ var require_axios = __commonJS({
|
|
|
60475
60433
|
throw new TypeError("executor must be a function.");
|
|
60476
60434
|
}
|
|
60477
60435
|
let resolvePromise;
|
|
60478
|
-
this.promise = new Promise(function promiseExecutor(
|
|
60479
|
-
resolvePromise =
|
|
60436
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
60437
|
+
resolvePromise = resolve;
|
|
60480
60438
|
});
|
|
60481
60439
|
const token = this;
|
|
60482
60440
|
this.promise.then((cancel) => {
|
|
@@ -60488,13 +60446,13 @@ var require_axios = __commonJS({
|
|
|
60488
60446
|
token._listeners = null;
|
|
60489
60447
|
});
|
|
60490
60448
|
this.promise.then = (onfulfilled) => {
|
|
60491
|
-
let
|
|
60492
|
-
const promise = new Promise((
|
|
60493
|
-
token.subscribe(
|
|
60494
|
-
|
|
60449
|
+
let _resolve;
|
|
60450
|
+
const promise = new Promise((resolve) => {
|
|
60451
|
+
token.subscribe(resolve);
|
|
60452
|
+
_resolve = resolve;
|
|
60495
60453
|
}).then(onfulfilled);
|
|
60496
60454
|
promise.cancel = function reject() {
|
|
60497
|
-
token.unsubscribe(
|
|
60455
|
+
token.unsubscribe(_resolve);
|
|
60498
60456
|
};
|
|
60499
60457
|
return promise;
|
|
60500
60458
|
};
|
|
@@ -62608,11 +62566,11 @@ var require_OpenAIEmbeddings = __commonJS({
|
|
|
62608
62566
|
"use strict";
|
|
62609
62567
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
62610
62568
|
function adopt(value) {
|
|
62611
|
-
return value instanceof P2 ? value : new P2(function(
|
|
62612
|
-
|
|
62569
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
62570
|
+
resolve(value);
|
|
62613
62571
|
});
|
|
62614
62572
|
}
|
|
62615
|
-
return new (P2 || (P2 = Promise))(function(
|
|
62573
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
62616
62574
|
function fulfilled(value) {
|
|
62617
62575
|
try {
|
|
62618
62576
|
step(generator.next(value));
|
|
@@ -62628,7 +62586,7 @@ var require_OpenAIEmbeddings = __commonJS({
|
|
|
62628
62586
|
}
|
|
62629
62587
|
}
|
|
62630
62588
|
function step(result) {
|
|
62631
|
-
result.done ?
|
|
62589
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
62632
62590
|
}
|
|
62633
62591
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
62634
62592
|
});
|
|
@@ -62761,7 +62719,7 @@ var require_OpenAIEmbeddings = __commonJS({
|
|
|
62761
62719
|
const response = yield this._httpClient.post(url, body, requestConfig);
|
|
62762
62720
|
if (response.status == 429 && Array.isArray(this.options.retryPolicy) && retryCount < this.options.retryPolicy.length) {
|
|
62763
62721
|
const delay = this.options.retryPolicy[retryCount];
|
|
62764
|
-
yield new Promise((
|
|
62722
|
+
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
62765
62723
|
return this.post(url, body, retryCount + 1);
|
|
62766
62724
|
} else {
|
|
62767
62725
|
return response;
|
|
@@ -87004,9 +86962,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
87004
86962
|
}
|
|
87005
86963
|
close(callback) {
|
|
87006
86964
|
if (callback === void 0) {
|
|
87007
|
-
return new Promise((
|
|
86965
|
+
return new Promise((resolve, reject) => {
|
|
87008
86966
|
this.close((err, data) => {
|
|
87009
|
-
return err ? reject(err) :
|
|
86967
|
+
return err ? reject(err) : resolve(data);
|
|
87010
86968
|
});
|
|
87011
86969
|
});
|
|
87012
86970
|
}
|
|
@@ -87044,9 +87002,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
87044
87002
|
err = null;
|
|
87045
87003
|
}
|
|
87046
87004
|
if (callback === void 0) {
|
|
87047
|
-
return new Promise((
|
|
87005
|
+
return new Promise((resolve, reject) => {
|
|
87048
87006
|
this.destroy(err, (err2, data) => {
|
|
87049
|
-
return err2 ? reject(err2) :
|
|
87007
|
+
return err2 ? reject(err2) : resolve(data);
|
|
87050
87008
|
});
|
|
87051
87009
|
});
|
|
87052
87010
|
}
|
|
@@ -90530,8 +90488,8 @@ var require_promise = __commonJS({
|
|
|
90530
90488
|
function createDeferredPromise() {
|
|
90531
90489
|
let res;
|
|
90532
90490
|
let rej;
|
|
90533
|
-
const promise = new Promise((
|
|
90534
|
-
res =
|
|
90491
|
+
const promise = new Promise((resolve, reject) => {
|
|
90492
|
+
res = resolve;
|
|
90535
90493
|
rej = reject;
|
|
90536
90494
|
});
|
|
90537
90495
|
return { promise, resolve: res, reject: rej };
|
|
@@ -91832,12 +91790,12 @@ upgrade: ${upgrade}\r
|
|
|
91832
91790
|
cb();
|
|
91833
91791
|
}
|
|
91834
91792
|
}
|
|
91835
|
-
const waitForDrain = () => new Promise((
|
|
91793
|
+
const waitForDrain = () => new Promise((resolve, reject) => {
|
|
91836
91794
|
assert(callback === null);
|
|
91837
91795
|
if (socket[kError]) {
|
|
91838
91796
|
reject(socket[kError]);
|
|
91839
91797
|
} else {
|
|
91840
|
-
callback =
|
|
91798
|
+
callback = resolve;
|
|
91841
91799
|
}
|
|
91842
91800
|
});
|
|
91843
91801
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -92678,12 +92636,12 @@ var require_client_h2 = __commonJS({
|
|
|
92678
92636
|
cb();
|
|
92679
92637
|
}
|
|
92680
92638
|
}
|
|
92681
|
-
const waitForDrain = () => new Promise((
|
|
92639
|
+
const waitForDrain = () => new Promise((resolve, reject) => {
|
|
92682
92640
|
assert(callback === null);
|
|
92683
92641
|
if (socket[kError]) {
|
|
92684
92642
|
reject(socket[kError]);
|
|
92685
92643
|
} else {
|
|
92686
|
-
callback =
|
|
92644
|
+
callback = resolve;
|
|
92687
92645
|
}
|
|
92688
92646
|
});
|
|
92689
92647
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -92993,16 +92951,16 @@ var require_client = __commonJS({
|
|
|
92993
92951
|
return this[kNeedDrain] < 2;
|
|
92994
92952
|
}
|
|
92995
92953
|
[kClose]() {
|
|
92996
|
-
return new Promise((
|
|
92954
|
+
return new Promise((resolve) => {
|
|
92997
92955
|
if (this[kSize]) {
|
|
92998
|
-
this[kClosedResolve] =
|
|
92956
|
+
this[kClosedResolve] = resolve;
|
|
92999
92957
|
} else {
|
|
93000
|
-
|
|
92958
|
+
resolve(null);
|
|
93001
92959
|
}
|
|
93002
92960
|
});
|
|
93003
92961
|
}
|
|
93004
92962
|
[kDestroy](err) {
|
|
93005
|
-
return new Promise((
|
|
92963
|
+
return new Promise((resolve) => {
|
|
93006
92964
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
93007
92965
|
for (let i2 = 0; i2 < requests.length; i2++) {
|
|
93008
92966
|
const request2 = requests[i2];
|
|
@@ -93013,7 +92971,7 @@ var require_client = __commonJS({
|
|
|
93013
92971
|
this[kClosedResolve]();
|
|
93014
92972
|
this[kClosedResolve] = null;
|
|
93015
92973
|
}
|
|
93016
|
-
|
|
92974
|
+
resolve(null);
|
|
93017
92975
|
};
|
|
93018
92976
|
if (this[kHTTPContext]) {
|
|
93019
92977
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -93414,8 +93372,8 @@ var require_pool_base = __commonJS({
|
|
|
93414
93372
|
}
|
|
93415
93373
|
return Promise.all(closeAll);
|
|
93416
93374
|
} else {
|
|
93417
|
-
return new Promise((
|
|
93418
|
-
this[kClosedResolve] =
|
|
93375
|
+
return new Promise((resolve) => {
|
|
93376
|
+
this[kClosedResolve] = resolve;
|
|
93419
93377
|
});
|
|
93420
93378
|
}
|
|
93421
93379
|
}
|
|
@@ -94957,7 +94915,7 @@ var require_readable = __commonJS({
|
|
|
94957
94915
|
if (this._readableState.closeEmitted) {
|
|
94958
94916
|
return Promise.resolve(null);
|
|
94959
94917
|
}
|
|
94960
|
-
return new Promise((
|
|
94918
|
+
return new Promise((resolve, reject) => {
|
|
94961
94919
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
94962
94920
|
this.destroy(new AbortError2());
|
|
94963
94921
|
}
|
|
@@ -94971,11 +94929,11 @@ var require_readable = __commonJS({
|
|
|
94971
94929
|
if (signal.aborted) {
|
|
94972
94930
|
reject(signal.reason ?? new AbortError2());
|
|
94973
94931
|
} else {
|
|
94974
|
-
|
|
94932
|
+
resolve(null);
|
|
94975
94933
|
}
|
|
94976
94934
|
});
|
|
94977
94935
|
} else {
|
|
94978
|
-
this.on("close",
|
|
94936
|
+
this.on("close", resolve);
|
|
94979
94937
|
}
|
|
94980
94938
|
this.on("error", noop).on("data", () => {
|
|
94981
94939
|
if (this[kBytesRead] > limit) {
|
|
@@ -95004,7 +94962,7 @@ var require_readable = __commonJS({
|
|
|
95004
94962
|
}
|
|
95005
94963
|
function consume(stream, type) {
|
|
95006
94964
|
assert(!stream[kConsume]);
|
|
95007
|
-
return new Promise((
|
|
94965
|
+
return new Promise((resolve, reject) => {
|
|
95008
94966
|
if (isUnusable(stream)) {
|
|
95009
94967
|
const rState = stream._readableState;
|
|
95010
94968
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -95019,7 +94977,7 @@ var require_readable = __commonJS({
|
|
|
95019
94977
|
stream[kConsume] = {
|
|
95020
94978
|
type,
|
|
95021
94979
|
stream,
|
|
95022
|
-
resolve
|
|
94980
|
+
resolve,
|
|
95023
94981
|
reject,
|
|
95024
94982
|
length: 0,
|
|
95025
94983
|
body: []
|
|
@@ -95093,18 +95051,18 @@ var require_readable = __commonJS({
|
|
|
95093
95051
|
return buffer;
|
|
95094
95052
|
}
|
|
95095
95053
|
function consumeEnd(consume2, encoding) {
|
|
95096
|
-
const { type, body, resolve
|
|
95054
|
+
const { type, body, resolve, stream, length } = consume2;
|
|
95097
95055
|
try {
|
|
95098
95056
|
if (type === "text") {
|
|
95099
|
-
|
|
95057
|
+
resolve(chunksDecode(body, length, encoding));
|
|
95100
95058
|
} else if (type === "json") {
|
|
95101
|
-
|
|
95059
|
+
resolve(JSON.parse(chunksDecode(body, length, encoding)));
|
|
95102
95060
|
} else if (type === "arrayBuffer") {
|
|
95103
|
-
|
|
95061
|
+
resolve(chunksConcat(body, length).buffer);
|
|
95104
95062
|
} else if (type === "blob") {
|
|
95105
|
-
|
|
95063
|
+
resolve(new Blob(body, { type: stream[kContentType] }));
|
|
95106
95064
|
} else if (type === "bytes") {
|
|
95107
|
-
|
|
95065
|
+
resolve(chunksConcat(body, length));
|
|
95108
95066
|
}
|
|
95109
95067
|
consumeFinish(consume2);
|
|
95110
95068
|
} catch (err) {
|
|
@@ -95294,9 +95252,9 @@ var require_api_request = __commonJS({
|
|
|
95294
95252
|
};
|
|
95295
95253
|
function request2(opts, callback) {
|
|
95296
95254
|
if (callback === void 0) {
|
|
95297
|
-
return new Promise((
|
|
95255
|
+
return new Promise((resolve, reject) => {
|
|
95298
95256
|
request2.call(this, opts, (err, data) => {
|
|
95299
|
-
return err ? reject(err) :
|
|
95257
|
+
return err ? reject(err) : resolve(data);
|
|
95300
95258
|
});
|
|
95301
95259
|
});
|
|
95302
95260
|
}
|
|
@@ -95510,9 +95468,9 @@ var require_api_stream = __commonJS({
|
|
|
95510
95468
|
};
|
|
95511
95469
|
function stream(opts, factory, callback) {
|
|
95512
95470
|
if (callback === void 0) {
|
|
95513
|
-
return new Promise((
|
|
95471
|
+
return new Promise((resolve, reject) => {
|
|
95514
95472
|
stream.call(this, opts, factory, (err, data) => {
|
|
95515
|
-
return err ? reject(err) :
|
|
95473
|
+
return err ? reject(err) : resolve(data);
|
|
95516
95474
|
});
|
|
95517
95475
|
});
|
|
95518
95476
|
}
|
|
@@ -95800,9 +95758,9 @@ var require_api_upgrade = __commonJS({
|
|
|
95800
95758
|
};
|
|
95801
95759
|
function upgrade(opts, callback) {
|
|
95802
95760
|
if (callback === void 0) {
|
|
95803
|
-
return new Promise((
|
|
95761
|
+
return new Promise((resolve, reject) => {
|
|
95804
95762
|
upgrade.call(this, opts, (err, data) => {
|
|
95805
|
-
return err ? reject(err) :
|
|
95763
|
+
return err ? reject(err) : resolve(data);
|
|
95806
95764
|
});
|
|
95807
95765
|
});
|
|
95808
95766
|
}
|
|
@@ -95895,9 +95853,9 @@ var require_api_connect = __commonJS({
|
|
|
95895
95853
|
};
|
|
95896
95854
|
function connect(opts, callback) {
|
|
95897
95855
|
if (callback === void 0) {
|
|
95898
|
-
return new Promise((
|
|
95856
|
+
return new Promise((resolve, reject) => {
|
|
95899
95857
|
connect.call(this, opts, (err, data) => {
|
|
95900
|
-
return err ? reject(err) :
|
|
95858
|
+
return err ? reject(err) : resolve(data);
|
|
95901
95859
|
});
|
|
95902
95860
|
});
|
|
95903
95861
|
}
|
|
@@ -97167,7 +97125,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
97167
97125
|
"../../node_modules/.pnpm/undici@7.22.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
|
|
97168
97126
|
"use strict";
|
|
97169
97127
|
var { writeFile, readFile: readFile2, mkdir } = require("fs/promises");
|
|
97170
|
-
var { dirname
|
|
97128
|
+
var { dirname, resolve } = require("path");
|
|
97171
97129
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require("timers");
|
|
97172
97130
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
97173
97131
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -97368,7 +97326,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
97368
97326
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
97369
97327
|
}
|
|
97370
97328
|
try {
|
|
97371
|
-
const data = await readFile2(
|
|
97329
|
+
const data = await readFile2(resolve(path3), "utf8");
|
|
97372
97330
|
const parsed = JSON.parse(data);
|
|
97373
97331
|
if (Array.isArray(parsed)) {
|
|
97374
97332
|
this.#snapshots.clear();
|
|
@@ -97397,8 +97355,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
97397
97355
|
if (!path3) {
|
|
97398
97356
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
97399
97357
|
}
|
|
97400
|
-
const resolvedPath =
|
|
97401
|
-
await mkdir(
|
|
97358
|
+
const resolvedPath = resolve(path3);
|
|
97359
|
+
await mkdir(dirname(resolvedPath), { recursive: true });
|
|
97402
97360
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
97403
97361
|
hash,
|
|
97404
97362
|
snapshot
|
|
@@ -104039,7 +103997,7 @@ var require_fetch = __commonJS({
|
|
|
104039
103997
|
function dispatch({ body }) {
|
|
104040
103998
|
const url = requestCurrentURL(request2);
|
|
104041
103999
|
const agent = fetchParams.controller.dispatcher;
|
|
104042
|
-
return new Promise((
|
|
104000
|
+
return new Promise((resolve, reject) => agent.dispatch(
|
|
104043
104001
|
{
|
|
104044
104002
|
path: url.pathname + url.search,
|
|
104045
104003
|
origin: url.origin,
|
|
@@ -104119,7 +104077,7 @@ var require_fetch = __commonJS({
|
|
|
104119
104077
|
}
|
|
104120
104078
|
}
|
|
104121
104079
|
const onError = this.onError.bind(this);
|
|
104122
|
-
|
|
104080
|
+
resolve({
|
|
104123
104081
|
status,
|
|
104124
104082
|
statusText,
|
|
104125
104083
|
headersList,
|
|
@@ -104173,7 +104131,7 @@ var require_fetch = __commonJS({
|
|
|
104173
104131
|
headersList.append(headerName, String(value), true);
|
|
104174
104132
|
}
|
|
104175
104133
|
}
|
|
104176
|
-
|
|
104134
|
+
resolve({
|
|
104177
104135
|
status,
|
|
104178
104136
|
statusText: STATUS_CODES2[status],
|
|
104179
104137
|
headersList,
|
|
@@ -104189,7 +104147,7 @@ var require_fetch = __commonJS({
|
|
|
104189
104147
|
for (let i2 = 0; i2 < rawHeaders.length; i2 += 2) {
|
|
104190
104148
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i2]), rawHeaders[i2 + 1].toString("latin1"), true);
|
|
104191
104149
|
}
|
|
104192
|
-
|
|
104150
|
+
resolve({
|
|
104193
104151
|
status,
|
|
104194
104152
|
statusText: STATUS_CODES2[status],
|
|
104195
104153
|
headersList,
|
|
@@ -108676,7 +108634,7 @@ var require_commonjs3 = __commonJS({
|
|
|
108676
108634
|
path: urlObject.pathname + urlObject.search,
|
|
108677
108635
|
...requestOptions
|
|
108678
108636
|
};
|
|
108679
|
-
const promise = new Promise((
|
|
108637
|
+
const promise = new Promise((resolve, reject) => {
|
|
108680
108638
|
undiciStream = new undici.Client(urlObject.origin).compose(undici.interceptors.redirect({ maxRedirections: 5 })).stream(streamOptions, (res) => {
|
|
108681
108639
|
var _a3, _b2;
|
|
108682
108640
|
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
@@ -108699,7 +108657,7 @@ var require_commonjs3 = __commonJS({
|
|
|
108699
108657
|
baseURI,
|
|
108700
108658
|
...cheerioOptions
|
|
108701
108659
|
};
|
|
108702
|
-
return decodeStream(opts, (err, $2) => err ? reject(err) :
|
|
108660
|
+
return decodeStream(opts, (err, $2) => err ? reject(err) : resolve($2));
|
|
108703
108661
|
});
|
|
108704
108662
|
});
|
|
108705
108663
|
await undiciStream;
|
|
@@ -126129,11 +126087,11 @@ var require_WebFetcher = __commonJS({
|
|
|
126129
126087
|
};
|
|
126130
126088
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
126131
126089
|
function adopt(value) {
|
|
126132
|
-
return value instanceof P2 ? value : new P2(function(
|
|
126133
|
-
|
|
126090
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
126091
|
+
resolve(value);
|
|
126134
126092
|
});
|
|
126135
126093
|
}
|
|
126136
|
-
return new (P2 || (P2 = Promise))(function(
|
|
126094
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
126137
126095
|
function fulfilled(value) {
|
|
126138
126096
|
try {
|
|
126139
126097
|
step(generator.next(value));
|
|
@@ -126149,7 +126107,7 @@ var require_WebFetcher = __commonJS({
|
|
|
126149
126107
|
}
|
|
126150
126108
|
}
|
|
126151
126109
|
function step(result) {
|
|
126152
|
-
result.done ?
|
|
126110
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
126153
126111
|
}
|
|
126154
126112
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
126155
126113
|
});
|
|
@@ -126361,23 +126319,23 @@ var require_lib16 = __commonJS({
|
|
|
126361
126319
|
// ../core/dist/index.mjs
|
|
126362
126320
|
function loadBlueprint(characterName, charactersDir) {
|
|
126363
126321
|
var _a3;
|
|
126364
|
-
const dir = (0,
|
|
126365
|
-
if (!(0,
|
|
126322
|
+
const dir = (0, import_path5.join)(charactersDir, characterName);
|
|
126323
|
+
if (!(0, import_fs6.existsSync)(dir)) {
|
|
126366
126324
|
throw new Error(
|
|
126367
126325
|
`Character "${characterName}" not found in ${charactersDir}.
|
|
126368
126326
|
Run "pnpm create-character" to create one, or check your CHARACTER_NAME in .env`
|
|
126369
126327
|
);
|
|
126370
126328
|
}
|
|
126371
126329
|
const readFile2 = (filename) => {
|
|
126372
|
-
const path3 = (0,
|
|
126373
|
-
if (!(0,
|
|
126330
|
+
const path3 = (0, import_path5.join)(dir, filename);
|
|
126331
|
+
if (!(0, import_fs6.existsSync)(path3)) {
|
|
126374
126332
|
throw new Error(
|
|
126375
126333
|
`Missing ${filename} for character "${characterName}".
|
|
126376
126334
|
Expected at: ${path3}
|
|
126377
126335
|
Copy from templates/ directory to get started.`
|
|
126378
126336
|
);
|
|
126379
126337
|
}
|
|
126380
|
-
return (0,
|
|
126338
|
+
return (0, import_fs6.readFileSync)(path3, "utf-8");
|
|
126381
126339
|
};
|
|
126382
126340
|
const identityRaw = readFile2("IDENTITY.md");
|
|
126383
126341
|
const { data: meta } = (0, import_gray_matter.default)(identityRaw);
|
|
@@ -126386,8 +126344,8 @@ Copy from templates/ directory to get started.`
|
|
|
126386
126344
|
const imageExts = [".jpg", ".jpeg", ".png", ".webp"];
|
|
126387
126345
|
let referenceImagePath;
|
|
126388
126346
|
for (const ext of imageExts) {
|
|
126389
|
-
const imgPath = (0,
|
|
126390
|
-
if ((0,
|
|
126347
|
+
const imgPath = (0, import_path5.join)(dir, `reference${ext}`);
|
|
126348
|
+
if ((0, import_fs6.existsSync)(imgPath)) {
|
|
126391
126349
|
referenceImagePath = imgPath;
|
|
126392
126350
|
break;
|
|
126393
126351
|
}
|
|
@@ -126737,7 +126695,7 @@ function debugLog(msg) {
|
|
|
126737
126695
|
`;
|
|
126738
126696
|
console.log(msg);
|
|
126739
126697
|
try {
|
|
126740
|
-
(0,
|
|
126698
|
+
(0, import_fs8.appendFileSync)("/tmp/opencrush-debug.log", line);
|
|
126741
126699
|
} catch {
|
|
126742
126700
|
}
|
|
126743
126701
|
}
|
|
@@ -127143,20 +127101,20 @@ function inferSelfieStyle(userMessage, llmResponse) {
|
|
|
127143
127101
|
if (/close|face|eyes|cute|脸|眼睛/.test(combined)) return "close-up";
|
|
127144
127102
|
return "casual";
|
|
127145
127103
|
}
|
|
127146
|
-
var
|
|
127104
|
+
var import_fs6, import_path5, import_gray_matter, import_better_sqlite3, import_vectra, import_path6, import_fs7, import_openai, import_fs8, MemorySystem, SMALLTALK_PATTERNS, OPENAI_COMPAT_PROVIDERS, LLMRouter, DEFAULT_BASELINE, EMOTION_KEYS, EmotionEngine, STAGE_THRESHOLDS, RelationshipTracker, ConversationEngine;
|
|
127147
127105
|
var init_dist = __esm({
|
|
127148
127106
|
"../core/dist/index.mjs"() {
|
|
127149
127107
|
"use strict";
|
|
127150
|
-
|
|
127151
|
-
|
|
127108
|
+
import_fs6 = require("fs");
|
|
127109
|
+
import_path5 = require("path");
|
|
127152
127110
|
import_gray_matter = __toESM(require_gray_matter(), 1);
|
|
127153
127111
|
import_better_sqlite3 = __toESM(require("better-sqlite3"), 1);
|
|
127154
127112
|
import_vectra = __toESM(require_lib16(), 1);
|
|
127155
|
-
|
|
127156
|
-
|
|
127113
|
+
import_path6 = require("path");
|
|
127114
|
+
import_fs7 = require("fs");
|
|
127157
127115
|
init_sdk();
|
|
127158
127116
|
import_openai = __toESM(require("openai"), 1);
|
|
127159
|
-
|
|
127117
|
+
import_fs8 = require("fs");
|
|
127160
127118
|
MemorySystem = class {
|
|
127161
127119
|
db;
|
|
127162
127120
|
vectorIndex;
|
|
@@ -127178,11 +127136,11 @@ var init_dist = __esm({
|
|
|
127178
127136
|
this.characterName = characterName;
|
|
127179
127137
|
this.embedFn = embedFn;
|
|
127180
127138
|
this.summarizeFn = summarizeFn;
|
|
127181
|
-
this.charDir = (0,
|
|
127182
|
-
const dbPath = (0,
|
|
127183
|
-
const vectorPath = (0,
|
|
127184
|
-
(0,
|
|
127185
|
-
(0,
|
|
127139
|
+
this.charDir = (0, import_path6.join)(dataDir, characterName);
|
|
127140
|
+
const dbPath = (0, import_path6.join)(this.charDir, "memory.db");
|
|
127141
|
+
const vectorPath = (0, import_path6.join)(this.charDir, "vectors");
|
|
127142
|
+
(0, import_fs7.mkdirSync)((0, import_path6.join)(dataDir, characterName), { recursive: true });
|
|
127143
|
+
(0, import_fs7.mkdirSync)(vectorPath, { recursive: true });
|
|
127186
127144
|
this.db = new import_better_sqlite3.default(dbPath);
|
|
127187
127145
|
this.vectorIndex = new import_vectra.LocalIndex(vectorPath);
|
|
127188
127146
|
this.initSchema();
|
|
@@ -127388,14 +127346,14 @@ ${transcript}`
|
|
|
127388
127346
|
*/
|
|
127389
127347
|
async syncMemoryFile() {
|
|
127390
127348
|
if (!this.summarizeFn) return;
|
|
127391
|
-
const memoryPath = (0,
|
|
127349
|
+
const memoryPath = (0, import_path6.join)(this.charDir, "MEMORY.md");
|
|
127392
127350
|
const recentMessages = this.getRecentMessages(30);
|
|
127393
127351
|
const recentEpisodes = this.getRecentEpisodes(20);
|
|
127394
127352
|
const transcript = recentMessages.map((m2) => `${m2.role}: ${m2.content.slice(0, 200)}`).join("\n");
|
|
127395
127353
|
const episodeList = recentEpisodes.map((e2) => `[${e2.type}] ${e2.title}: ${e2.description}`).join("\n");
|
|
127396
127354
|
let existingMemory = "";
|
|
127397
|
-
if ((0,
|
|
127398
|
-
existingMemory = (0,
|
|
127355
|
+
if ((0, import_fs7.existsSync)(memoryPath)) {
|
|
127356
|
+
existingMemory = (0, import_fs7.readFileSync)(memoryPath, "utf-8");
|
|
127399
127357
|
}
|
|
127400
127358
|
const prompt2 = `You are updating a character's memory file based on recent conversations and activities.
|
|
127401
127359
|
|
|
@@ -127437,7 +127395,7 @@ RULES:
|
|
|
127437
127395
|
- If the existing MEMORY.md was manually edited by the user, respect those edits as the source of truth.`;
|
|
127438
127396
|
const newContent = await this.summarizeFn(prompt2);
|
|
127439
127397
|
if (newContent && newContent.length > 50) {
|
|
127440
|
-
(0,
|
|
127398
|
+
(0, import_fs7.writeFileSync)(memoryPath, newContent.trim() + "\n", "utf-8");
|
|
127441
127399
|
console.log("[Memory] MEMORY.md synced with latest knowledge");
|
|
127442
127400
|
}
|
|
127443
127401
|
}
|
|
@@ -127448,12 +127406,12 @@ RULES:
|
|
|
127448
127406
|
*/
|
|
127449
127407
|
async syncUserFile() {
|
|
127450
127408
|
if (!this.summarizeFn) return;
|
|
127451
|
-
const userPath = (0,
|
|
127409
|
+
const userPath = (0, import_path6.join)(this.charDir, "USER.md");
|
|
127452
127410
|
const recentMessages = this.getRecentMessages(30);
|
|
127453
127411
|
const transcript = recentMessages.map((m2) => `${m2.role}: ${m2.content.slice(0, 200)}`).join("\n");
|
|
127454
127412
|
let existingUser = "";
|
|
127455
|
-
if ((0,
|
|
127456
|
-
existingUser = (0,
|
|
127413
|
+
if ((0, import_fs7.existsSync)(userPath)) {
|
|
127414
|
+
existingUser = (0, import_fs7.readFileSync)(userPath, "utf-8");
|
|
127457
127415
|
}
|
|
127458
127416
|
let relationshipInfo = "";
|
|
127459
127417
|
try {
|
|
@@ -127499,7 +127457,7 @@ RULES:
|
|
|
127499
127457
|
- Write from the character's perspective (casual, warm)`;
|
|
127500
127458
|
const newContent = await this.summarizeFn(prompt2);
|
|
127501
127459
|
if (newContent && newContent.length > 50) {
|
|
127502
|
-
(0,
|
|
127460
|
+
(0, import_fs7.writeFileSync)(userPath, newContent.trim() + "\n", "utf-8");
|
|
127503
127461
|
console.log("[Memory] USER.md synced with latest knowledge");
|
|
127504
127462
|
}
|
|
127505
127463
|
}
|
|
@@ -128263,11 +128221,11 @@ var require_middleware = __commonJS({
|
|
|
128263
128221
|
"use strict";
|
|
128264
128222
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
128265
128223
|
function adopt(value) {
|
|
128266
|
-
return value instanceof P2 ? value : new P2(function(
|
|
128267
|
-
|
|
128224
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
128225
|
+
resolve(value);
|
|
128268
128226
|
});
|
|
128269
128227
|
}
|
|
128270
|
-
return new (P2 || (P2 = Promise))(function(
|
|
128228
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
128271
128229
|
function fulfilled(value) {
|
|
128272
128230
|
try {
|
|
128273
128231
|
step(generator.next(value));
|
|
@@ -128283,7 +128241,7 @@ var require_middleware = __commonJS({
|
|
|
128283
128241
|
}
|
|
128284
128242
|
}
|
|
128285
128243
|
function step(result) {
|
|
128286
|
-
result.done ?
|
|
128244
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
128287
128245
|
}
|
|
128288
128246
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
128289
128247
|
});
|
|
@@ -128352,11 +128310,11 @@ var require_response2 = __commonJS({
|
|
|
128352
128310
|
"use strict";
|
|
128353
128311
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
128354
128312
|
function adopt(value) {
|
|
128355
|
-
return value instanceof P2 ? value : new P2(function(
|
|
128356
|
-
|
|
128313
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
128314
|
+
resolve(value);
|
|
128357
128315
|
});
|
|
128358
128316
|
}
|
|
128359
|
-
return new (P2 || (P2 = Promise))(function(
|
|
128317
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
128360
128318
|
function fulfilled(value) {
|
|
128361
128319
|
try {
|
|
128362
128320
|
step(generator.next(value));
|
|
@@ -128372,7 +128330,7 @@ var require_response2 = __commonJS({
|
|
|
128372
128330
|
}
|
|
128373
128331
|
}
|
|
128374
128332
|
function step(result) {
|
|
128375
|
-
result.done ?
|
|
128333
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
128376
128334
|
}
|
|
128377
128335
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
128378
128336
|
});
|
|
@@ -128479,11 +128437,11 @@ var require_utils8 = __commonJS({
|
|
|
128479
128437
|
"use strict";
|
|
128480
128438
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
128481
128439
|
function adopt(value) {
|
|
128482
|
-
return value instanceof P2 ? value : new P2(function(
|
|
128483
|
-
|
|
128440
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
128441
|
+
resolve(value);
|
|
128484
128442
|
});
|
|
128485
128443
|
}
|
|
128486
|
-
return new (P2 || (P2 = Promise))(function(
|
|
128444
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
128487
128445
|
function fulfilled(value) {
|
|
128488
128446
|
try {
|
|
128489
128447
|
step(generator.next(value));
|
|
@@ -128499,7 +128457,7 @@ var require_utils8 = __commonJS({
|
|
|
128499
128457
|
}
|
|
128500
128458
|
}
|
|
128501
128459
|
function step(result) {
|
|
128502
|
-
result.done ?
|
|
128460
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
128503
128461
|
}
|
|
128504
128462
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
128505
128463
|
});
|
|
@@ -128592,7 +128550,7 @@ var require_utils8 = __commonJS({
|
|
|
128592
128550
|
}
|
|
128593
128551
|
function sleep3(ms) {
|
|
128594
128552
|
return __awaiter2(this, void 0, void 0, function* () {
|
|
128595
|
-
return new Promise((
|
|
128553
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
128596
128554
|
});
|
|
128597
128555
|
}
|
|
128598
128556
|
}
|
|
@@ -128604,11 +128562,11 @@ var require_retry3 = __commonJS({
|
|
|
128604
128562
|
"use strict";
|
|
128605
128563
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
128606
128564
|
function adopt(value) {
|
|
128607
|
-
return value instanceof P2 ? value : new P2(function(
|
|
128608
|
-
|
|
128565
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
128566
|
+
resolve(value);
|
|
128609
128567
|
});
|
|
128610
128568
|
}
|
|
128611
|
-
return new (P2 || (P2 = Promise))(function(
|
|
128569
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
128612
128570
|
function fulfilled(value) {
|
|
128613
128571
|
try {
|
|
128614
128572
|
step(generator.next(value));
|
|
@@ -128624,7 +128582,7 @@ var require_retry3 = __commonJS({
|
|
|
128624
128582
|
}
|
|
128625
128583
|
}
|
|
128626
128584
|
function step(result) {
|
|
128627
|
-
result.done ?
|
|
128585
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
128628
128586
|
}
|
|
128629
128587
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
128630
128588
|
});
|
|
@@ -128830,11 +128788,11 @@ var require_request3 = __commonJS({
|
|
|
128830
128788
|
"use strict";
|
|
128831
128789
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
128832
128790
|
function adopt(value) {
|
|
128833
|
-
return value instanceof P2 ? value : new P2(function(
|
|
128834
|
-
|
|
128791
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
128792
|
+
resolve(value);
|
|
128835
128793
|
});
|
|
128836
128794
|
}
|
|
128837
|
-
return new (P2 || (P2 = Promise))(function(
|
|
128795
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
128838
128796
|
function fulfilled(value) {
|
|
128839
128797
|
try {
|
|
128840
128798
|
step(generator.next(value));
|
|
@@ -128850,7 +128808,7 @@ var require_request3 = __commonJS({
|
|
|
128850
128808
|
}
|
|
128851
128809
|
}
|
|
128852
128810
|
function step(result) {
|
|
128853
|
-
result.done ?
|
|
128811
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
128854
128812
|
}
|
|
128855
128813
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
128856
128814
|
});
|
|
@@ -128937,11 +128895,11 @@ var require_storage = __commonJS({
|
|
|
128937
128895
|
"use strict";
|
|
128938
128896
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
128939
128897
|
function adopt(value) {
|
|
128940
|
-
return value instanceof P2 ? value : new P2(function(
|
|
128941
|
-
|
|
128898
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
128899
|
+
resolve(value);
|
|
128942
128900
|
});
|
|
128943
128901
|
}
|
|
128944
|
-
return new (P2 || (P2 = Promise))(function(
|
|
128902
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
128945
128903
|
function fulfilled(value) {
|
|
128946
128904
|
try {
|
|
128947
128905
|
step(generator.next(value));
|
|
@@ -128957,7 +128915,7 @@ var require_storage = __commonJS({
|
|
|
128957
128915
|
}
|
|
128958
128916
|
}
|
|
128959
128917
|
function step(result) {
|
|
128960
|
-
result.done ?
|
|
128918
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
128961
128919
|
}
|
|
128962
128920
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
128963
128921
|
});
|
|
@@ -129276,11 +129234,11 @@ var require_auth = __commonJS({
|
|
|
129276
129234
|
"use strict";
|
|
129277
129235
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
129278
129236
|
function adopt(value) {
|
|
129279
|
-
return value instanceof P2 ? value : new P2(function(
|
|
129280
|
-
|
|
129237
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
129238
|
+
resolve(value);
|
|
129281
129239
|
});
|
|
129282
129240
|
}
|
|
129283
|
-
return new (P2 || (P2 = Promise))(function(
|
|
129241
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
129284
129242
|
function fulfilled(value) {
|
|
129285
129243
|
try {
|
|
129286
129244
|
step(generator.next(value));
|
|
@@ -129296,7 +129254,7 @@ var require_auth = __commonJS({
|
|
|
129296
129254
|
}
|
|
129297
129255
|
}
|
|
129298
129256
|
function step(result) {
|
|
129299
|
-
result.done ?
|
|
129257
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
129300
129258
|
}
|
|
129301
129259
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
129302
129260
|
});
|
|
@@ -129335,11 +129293,11 @@ var require_streaming = __commonJS({
|
|
|
129335
129293
|
"use strict";
|
|
129336
129294
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
129337
129295
|
function adopt(value) {
|
|
129338
|
-
return value instanceof P2 ? value : new P2(function(
|
|
129339
|
-
|
|
129296
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
129297
|
+
resolve(value);
|
|
129340
129298
|
});
|
|
129341
129299
|
}
|
|
129342
|
-
return new (P2 || (P2 = Promise))(function(
|
|
129300
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
129343
129301
|
function fulfilled(value) {
|
|
129344
129302
|
try {
|
|
129345
129303
|
step(generator.next(value));
|
|
@@ -129355,7 +129313,7 @@ var require_streaming = __commonJS({
|
|
|
129355
129313
|
}
|
|
129356
129314
|
}
|
|
129357
129315
|
function step(result) {
|
|
129358
|
-
result.done ?
|
|
129316
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
129359
129317
|
}
|
|
129360
129318
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
129361
129319
|
});
|
|
@@ -129588,7 +129546,7 @@ var require_streaming = __commonJS({
|
|
|
129588
129546
|
query: options2.queryParams
|
|
129589
129547
|
});
|
|
129590
129548
|
this.options = options2;
|
|
129591
|
-
this.donePromise = new Promise((
|
|
129549
|
+
this.donePromise = new Promise((resolve, reject) => {
|
|
129592
129550
|
if (this.streamClosed) {
|
|
129593
129551
|
reject(new response_1.ApiError({
|
|
129594
129552
|
message: "Streaming connection is already closed.",
|
|
@@ -129599,11 +129557,11 @@ var require_streaming = __commonJS({
|
|
|
129599
129557
|
}
|
|
129600
129558
|
this.signal.addEventListener("abort", () => {
|
|
129601
129559
|
var _a4;
|
|
129602
|
-
|
|
129560
|
+
resolve((_a4 = this.currentData) !== null && _a4 !== void 0 ? _a4 : {});
|
|
129603
129561
|
});
|
|
129604
129562
|
this.on("done", (data) => {
|
|
129605
129563
|
this.streamClosed = true;
|
|
129606
|
-
|
|
129564
|
+
resolve(data);
|
|
129607
129565
|
});
|
|
129608
129566
|
this.on("error", (error2) => {
|
|
129609
129567
|
this.streamClosed = true;
|
|
@@ -129628,7 +129586,7 @@ var require_streaming = __commonJS({
|
|
|
129628
129586
|
if (data) {
|
|
129629
129587
|
yield yield __await2(data);
|
|
129630
129588
|
}
|
|
129631
|
-
yield __await2(new Promise((
|
|
129589
|
+
yield __await2(new Promise((resolve) => setTimeout(resolve, 16)));
|
|
129632
129590
|
}
|
|
129633
129591
|
});
|
|
129634
129592
|
}
|
|
@@ -129673,11 +129631,11 @@ var require_queue2 = __commonJS({
|
|
|
129673
129631
|
"use strict";
|
|
129674
129632
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
129675
129633
|
function adopt(value) {
|
|
129676
|
-
return value instanceof P2 ? value : new P2(function(
|
|
129677
|
-
|
|
129634
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
129635
|
+
resolve(value);
|
|
129678
129636
|
});
|
|
129679
129637
|
}
|
|
129680
|
-
return new (P2 || (P2 = Promise))(function(
|
|
129638
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
129681
129639
|
function fulfilled(value) {
|
|
129682
129640
|
try {
|
|
129683
129641
|
step(generator.next(value));
|
|
@@ -129693,7 +129651,7 @@ var require_queue2 = __commonJS({
|
|
|
129693
129651
|
}
|
|
129694
129652
|
}
|
|
129695
129653
|
function step(result) {
|
|
129696
|
-
result.done ?
|
|
129654
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
129697
129655
|
}
|
|
129698
129656
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
129699
129657
|
});
|
|
@@ -129828,7 +129786,7 @@ var require_queue2 = __commonJS({
|
|
|
129828
129786
|
}
|
|
129829
129787
|
return doneStatus;
|
|
129830
129788
|
}
|
|
129831
|
-
return new Promise((
|
|
129789
|
+
return new Promise((resolve, reject) => {
|
|
129832
129790
|
var _a3;
|
|
129833
129791
|
let pollingTimeoutId;
|
|
129834
129792
|
const pollInterval = "pollInterval" in options2 && typeof options2.pollInterval === "number" ? (_a3 = options2.pollInterval) !== null && _a3 !== void 0 ? _a3 : DEFAULT_POLL_INTERVAL : DEFAULT_POLL_INTERVAL;
|
|
@@ -129860,7 +129818,7 @@ var require_queue2 = __commonJS({
|
|
|
129860
129818
|
}
|
|
129861
129819
|
if (requestStatus.status === "COMPLETED") {
|
|
129862
129820
|
clearScheduledTasks();
|
|
129863
|
-
|
|
129821
|
+
resolve(requestStatus);
|
|
129864
129822
|
return;
|
|
129865
129823
|
}
|
|
129866
129824
|
pollingTimeoutId = setTimeout(poll, pollInterval);
|
|
@@ -131726,11 +131684,11 @@ var require_realtime = __commonJS({
|
|
|
131726
131684
|
"use strict";
|
|
131727
131685
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
131728
131686
|
function adopt(value) {
|
|
131729
|
-
return value instanceof P2 ? value : new P2(function(
|
|
131730
|
-
|
|
131687
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
131688
|
+
resolve(value);
|
|
131731
131689
|
});
|
|
131732
131690
|
}
|
|
131733
|
-
return new (P2 || (P2 = Promise))(function(
|
|
131691
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
131734
131692
|
function fulfilled(value) {
|
|
131735
131693
|
try {
|
|
131736
131694
|
step(generator.next(value));
|
|
@@ -131746,7 +131704,7 @@ var require_realtime = __commonJS({
|
|
|
131746
131704
|
}
|
|
131747
131705
|
}
|
|
131748
131706
|
function step(result) {
|
|
131749
|
-
result.done ?
|
|
131707
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
131750
131708
|
}
|
|
131751
131709
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
131752
131710
|
});
|
|
@@ -132069,11 +132027,11 @@ var require_client2 = __commonJS({
|
|
|
132069
132027
|
"use strict";
|
|
132070
132028
|
var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
132071
132029
|
function adopt(value) {
|
|
132072
|
-
return value instanceof P2 ? value : new P2(function(
|
|
132073
|
-
|
|
132030
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
132031
|
+
resolve(value);
|
|
132074
132032
|
});
|
|
132075
132033
|
}
|
|
132076
|
-
return new (P2 || (P2 = Promise))(function(
|
|
132034
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
132077
132035
|
function fulfilled(value) {
|
|
132078
132036
|
try {
|
|
132079
132037
|
step(generator.next(value));
|
|
@@ -132089,7 +132047,7 @@ var require_client2 = __commonJS({
|
|
|
132089
132047
|
}
|
|
132090
132048
|
}
|
|
132091
132049
|
function step(result) {
|
|
132092
|
-
result.done ?
|
|
132050
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
132093
132051
|
}
|
|
132094
132052
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
132095
132053
|
});
|
|
@@ -132255,7 +132213,7 @@ function debugLog2(msg) {
|
|
|
132255
132213
|
`;
|
|
132256
132214
|
console.log(msg);
|
|
132257
132215
|
try {
|
|
132258
|
-
(0,
|
|
132216
|
+
(0, import_fs9.appendFileSync)("/tmp/opencrush-debug.log", line);
|
|
132259
132217
|
} catch {
|
|
132260
132218
|
}
|
|
132261
132219
|
}
|
|
@@ -132317,18 +132275,18 @@ function debugLog22(msg) {
|
|
|
132317
132275
|
`;
|
|
132318
132276
|
console.log(msg);
|
|
132319
132277
|
try {
|
|
132320
|
-
(0,
|
|
132278
|
+
(0, import_fs10.appendFileSync)("/tmp/opencrush-debug.log", line);
|
|
132321
132279
|
} catch {
|
|
132322
132280
|
}
|
|
132323
132281
|
}
|
|
132324
|
-
var
|
|
132282
|
+
var import_fs9, import_openai2, import_client, import_fs10, ImageEngine, KOKORO_ENDPOINTS, KOKORO_DEFAULT_VOICES, VoiceEngine, VideoEngine, MediaEngine;
|
|
132325
132283
|
var init_dist3 = __esm({
|
|
132326
132284
|
"../media/dist/index.mjs"() {
|
|
132327
132285
|
"use strict";
|
|
132328
|
-
|
|
132286
|
+
import_fs9 = require("fs");
|
|
132329
132287
|
import_openai2 = __toESM(require("openai"), 1);
|
|
132330
132288
|
import_client = __toESM(require_src2(), 1);
|
|
132331
|
-
|
|
132289
|
+
import_fs10 = require("fs");
|
|
132332
132290
|
ImageEngine = class {
|
|
132333
132291
|
config;
|
|
132334
132292
|
constructor(config) {
|
|
@@ -132343,7 +132301,7 @@ var init_dist3 = __esm({
|
|
|
132343
132301
|
const styledPrompt = this.buildImagePrompt(request2);
|
|
132344
132302
|
const imageSize = this.getImageSizePreset(request2);
|
|
132345
132303
|
debugLog2(`[Media/Image] Generating: style=${request2.style ?? "casual"}, ratio=${imageSize}`);
|
|
132346
|
-
if (request2.referenceImagePath && (0,
|
|
132304
|
+
if (request2.referenceImagePath && (0, import_fs9.existsSync)(request2.referenceImagePath)) {
|
|
132347
132305
|
debugLog2(`[Media/Image] Using reference image: ${request2.referenceImagePath}`);
|
|
132348
132306
|
const result2 = await this.generateWithReference(styledPrompt, request2.referenceImagePath, imageSize);
|
|
132349
132307
|
debugLog2(`[Media/Image] generateWithReference result: ${result2 ? `${result2.length} bytes` : "null"}`);
|
|
@@ -132424,7 +132382,7 @@ var init_dist3 = __esm({
|
|
|
132424
132382
|
* Tries models in order: PuLID → InstantCharacter → IP-Adapter (fallback).
|
|
132425
132383
|
*/
|
|
132426
132384
|
async generateWithReference(prompt2, imagePath, imageSize) {
|
|
132427
|
-
const imageData = (0,
|
|
132385
|
+
const imageData = (0, import_fs9.readFileSync)(imagePath);
|
|
132428
132386
|
const base64Image = `data:image/jpeg;base64,${imageData.toString("base64")}`;
|
|
132429
132387
|
const dims = this.presetToPixels(imageSize);
|
|
132430
132388
|
const refModel = this.config.referenceModel ?? "fal-ai/flux-pulid";
|
|
@@ -132790,7 +132748,7 @@ var init_dist3 = __esm({
|
|
|
132790
132748
|
return null;
|
|
132791
132749
|
}
|
|
132792
132750
|
try {
|
|
132793
|
-
const hasRef = this.config.referenceImagePath && (0,
|
|
132751
|
+
const hasRef = this.config.referenceImagePath && (0, import_fs10.existsSync)(this.config.referenceImagePath);
|
|
132794
132752
|
if (hasRef) {
|
|
132795
132753
|
debugLog22(`[Media/Video] Using reference pipeline (PuLID still \u2192 Wan i2v)`);
|
|
132796
132754
|
return await this.generateWithReference(prompt2);
|
|
@@ -132809,7 +132767,7 @@ var init_dist3 = __esm({
|
|
|
132809
132767
|
async generateWithReference(prompt2) {
|
|
132810
132768
|
var _a3, _b2, _c, _d, _e2, _f, _g, _h;
|
|
132811
132769
|
const refPath = this.config.referenceImagePath;
|
|
132812
|
-
const imageData = (0,
|
|
132770
|
+
const imageData = (0, import_fs10.readFileSync)(refPath);
|
|
132813
132771
|
const base64Image = `data:image/jpeg;base64,${imageData.toString("base64")}`;
|
|
132814
132772
|
debugLog22(`[Media/Video] Step 1: PuLID still frame...`);
|
|
132815
132773
|
const stillResult = await import_client.fal.subscribe("fal-ai/flux-pulid", {
|
|
@@ -134145,12 +134103,12 @@ function percentEncodeData(data) {
|
|
|
134145
134103
|
async function readFileIntoBuffer(file) {
|
|
134146
134104
|
const handle = await getFileHandle(file);
|
|
134147
134105
|
if (typeof handle === "number") {
|
|
134148
|
-
return new Promise((
|
|
134106
|
+
return new Promise((resolve, reject) => {
|
|
134149
134107
|
fs3.readFile(handle, (err, data) => {
|
|
134150
134108
|
if (err) {
|
|
134151
134109
|
return reject(err);
|
|
134152
134110
|
}
|
|
134153
|
-
|
|
134111
|
+
resolve(data);
|
|
134154
134112
|
});
|
|
134155
134113
|
});
|
|
134156
134114
|
} else if (handle instanceof Buffer) {
|
|
@@ -134174,11 +134132,11 @@ function getFileHandle(file) {
|
|
|
134174
134132
|
}
|
|
134175
134133
|
async function getFileSizeFromFileHandle(fileHandle) {
|
|
134176
134134
|
if (typeof fileHandle === "number") {
|
|
134177
|
-
const stats = await new Promise((
|
|
134135
|
+
const stats = await new Promise((resolve, reject) => {
|
|
134178
134136
|
fs3.fstat(fileHandle, (err, stats2) => {
|
|
134179
134137
|
if (err)
|
|
134180
134138
|
reject(err);
|
|
134181
|
-
|
|
134139
|
+
resolve(stats2);
|
|
134182
134140
|
});
|
|
134183
134141
|
});
|
|
134184
134142
|
return stats.size;
|
|
@@ -134255,7 +134213,7 @@ function getMediaCategoryByMime(name, target) {
|
|
|
134255
134213
|
return target === "tweet" ? "TweetImage" : "DmImage";
|
|
134256
134214
|
}
|
|
134257
134215
|
function sleepSecs(seconds) {
|
|
134258
|
-
return new Promise((
|
|
134216
|
+
return new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
|
|
134259
134217
|
}
|
|
134260
134218
|
async function readNextPartOf(file, chunkLength, bufferOffset = 0, buffer) {
|
|
134261
134219
|
if (file instanceof Buffer) {
|
|
@@ -134267,11 +134225,11 @@ async function readNextPartOf(file, chunkLength, bufferOffset = 0, buffer) {
|
|
|
134267
134225
|
}
|
|
134268
134226
|
let bytesRead;
|
|
134269
134227
|
if (typeof file === "number") {
|
|
134270
|
-
bytesRead = await new Promise((
|
|
134228
|
+
bytesRead = await new Promise((resolve, reject) => {
|
|
134271
134229
|
fs3.read(file, buffer, 0, chunkLength, bufferOffset, (err, nread) => {
|
|
134272
134230
|
if (err)
|
|
134273
134231
|
reject(err);
|
|
134274
|
-
|
|
134232
|
+
resolve(nread);
|
|
134275
134233
|
});
|
|
134276
134234
|
});
|
|
134277
134235
|
} else {
|
|
@@ -136893,7 +136851,7 @@ async function requestApi(url, auth, method = "GET", options2 = {}) {
|
|
|
136893
136851
|
if (xRateLimitRemaining == "0" && xRateLimitReset) {
|
|
136894
136852
|
const currentTime = (/* @__PURE__ */ new Date()).valueOf() / 1e3;
|
|
136895
136853
|
const timeDeltaMs = 1e3 * (parseInt(xRateLimitReset) - currentTime);
|
|
136896
|
-
await new Promise((
|
|
136854
|
+
await new Promise((resolve) => setTimeout(resolve, timeDeltaMs));
|
|
136897
136855
|
}
|
|
136898
136856
|
}
|
|
136899
136857
|
} while (res.status === 429);
|
|
@@ -138690,7 +138648,7 @@ async function uploadMedia(mediaData, auth, mediaType) {
|
|
|
138690
138648
|
async function checkUploadStatus(mediaId) {
|
|
138691
138649
|
let processing = true;
|
|
138692
138650
|
while (processing) {
|
|
138693
|
-
await new Promise((
|
|
138651
|
+
await new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
138694
138652
|
const statusParams = new URLSearchParams();
|
|
138695
138653
|
statusParams.append("command", "STATUS");
|
|
138696
138654
|
statusParams.append("media_id", mediaId);
|
|
@@ -139675,7 +139633,7 @@ async function createBroadcast(params) {
|
|
|
139675
139633
|
const data = await resp.json();
|
|
139676
139634
|
return data;
|
|
139677
139635
|
}
|
|
139678
|
-
var fs2, import_events, import_https2, zlib2, import_events2, import_events3, import_events4, crypto9, crypto22, fs3, crypto32, import_events5, fs32,
|
|
139636
|
+
var fs2, import_events, import_https2, zlib2, import_events2, import_events3, import_events4, crypto9, crypto22, fs3, crypto32, import_events5, fs32, import_fs11, import_path7, import_child_process3, import_tls, import_crypto8, punycode_es6_exports, maxInt, base, tMin, tMax, skew, damp, initialBias, initialN, delimiter, regexPunycode, regexNonASCII, regexSeparators, errors, baseMinusTMin, floor, stringFromCharCode, ucs2encode, basicToDigit, digitToBasic, adapt, decode2, encode2, toUnicode, toASCII, punycode, punycode_es6_default, init_punycode_es6, require_requires_port, require_querystringify, require_url_parse, require_psl, require_pubsuffix_psl, require_store, require_universalify, require_permuteDomain, require_pathMatch, require_utilHelper, require_memstore, require_validators, require_version, require_cookie, require_set_cookie, require_parse5, require_stringify3, require_jsonify, require_isarray, require_isArguments, require_implementation2, require_object_keys, require_es_object_atoms2, require_es_errors2, require_eval2, require_range3, require_ref2, require_syntax2, require_type3, require_uri2, require_abs2, require_floor2, require_max3, require_min3, require_pow2, require_round2, require_isNaN2, require_sign2, require_gOPD2, require_gopd2, require_es_define_property2, require_shams3, require_has_symbols2, require_Reflect_getPrototypeOf2, require_Object_getPrototypeOf2, require_implementation22, require_function_bind2, require_functionCall2, require_functionApply2, require_reflectApply2, require_actualApply2, require_call_bind_apply_helpers2, require_get2, require_get_proto2, require_hasown2, require_get_intrinsic2, require_define_data_property, require_has_property_descriptors, require_set_function_length, require_applyBind, require_call_bind, require_call_bound, require_json_stable_stringify, require_constants7, require_buffer_util, require_limiter, require_permessage_deflate2, require_validation, require_receiver2, require_sender2, require_event_target, require_extension, require_websocket2, require_stream, require_subprotocol, require_websocket_server, require_binding, require_eventtarget, require_mediadevices, require_lib17, require_utils9, require_legacy_error_codes, require_DOMException_impl, require_DOMException2, require_webidl2js_wrapper, require_domexception, require_datachannelevent, require_icecandidate, require_rtcpeerconnectioniceevent, require_rtcpeerconnectioniceerrorevent, require_sessiondescription, require_peerconnection, require_lib22, import_tough_cookie, import_set_cookie_parser2, __create3, __defProp3, __getOwnPropDesc3, __getOwnPropNames3, __getProtoOf3, __hasOwnProp3, __commonJS22, __copyProps3, __toESM22, require_set_cookie2, import_set_cookie_parser, HEADERS_INVALID_CHARACTERS, charCodesToRemove, HEADER_VALUE_REMOVE_REGEXP, NORMALIZED_HEADERS, RAW_HEADER_NAMES, HEADER_VALUE_DELIMITER, _a2, _b, Headers22, API_V2_PREFIX, API_V2_LABS_PREFIX, API_V1_1_PREFIX, API_V1_1_UPLOAD_PREFIX, API_V1_1_STREAM_PREFIX, API_ADS_PREFIX, API_ADS_SANDBOX_PREFIX, TwitterPaginator, PreviousableTwitterPaginator, TwitterPaginator_default, CursoredV1Paginator, DmEventsV1Paginator, WelcomeDmV1Paginator, EUploadMimeType, EDirectMessageEventTypeV1, ETwitterApiError, ApiError, ApiRequestError, ApiPartialResponseError, ApiResponseError, EApiV1ErrorCode, EApiV2ErrorCode, ETwitterStreamEvent, TwitterApiPluginResponseOverride, TwitterApiV2Settings, deprecationWarningsCache, RequestHandlerHelper, request_handler_helper_default, TweetStreamEventCombiner, TweetStreamEventCombiner_default, TweetStreamParser, EStreamParserEvent, basicRetriesAttempt, basicReconnectRetry, TweetStream, TweetStream_default, OAuth1Helper, oauth1_helper_default, FormDataHelper, RequestParamHelpers, request_param_helper_default, OAuth2Helper, ClientRequestMaker, TwitterApiBase, TwitterApiSubClient, TweetTimelineV1Paginator, HomeTimelineV1Paginator, MentionTimelineV1Paginator, UserTimelineV1Paginator, ListTimelineV1Paginator, UserFavoritesV1Paginator, MuteUserListV1Paginator, MuteUserIdsV1Paginator, UserFollowerListV1Paginator, UserFollowerIdsV1Paginator, UserFriendListV1Paginator, UserFollowersIdsV1Paginator, UserSearchV1Paginator, FriendshipsIncomingV1Paginator, FriendshipsOutgoingV1Paginator, ListListsV1Paginator, ListMembershipsV1Paginator, ListOwnershipsV1Paginator, ListSubscriptionsV1Paginator, ListUsersV1Paginator, ListMembersV1Paginator, ListSubscribersV1Paginator, TwitterApiv1ReadOnly, UPLOAD_ENDPOINT, TwitterApiv1ReadWrite, TwitterApiv1, client_v1_default, TwitterV2IncludesHelper, TwitterV2Paginator, TimelineV2Paginator, TweetTimelineV2Paginator, TweetPaginableTimelineV2Paginator, TweetSearchRecentV2Paginator, TweetSearchAllV2Paginator, QuotedTweetsTimelineV2Paginator, TweetHomeTimelineV2Paginator, TweetUserTimelineV2Paginator, TweetUserMentionTimelineV2Paginator, TweetBookmarksTimelineV2Paginator, TweetListV2Paginator, TweetV2UserLikedTweetsPaginator, TweetV2ListTweetsPaginator, UserTimelineV2Paginator, UserBlockingUsersV2Paginator, UserMutingUsersV2Paginator, UserFollowersV2Paginator, UserFollowingV2Paginator, UserListMembersV2Paginator, UserListFollowersV2Paginator, TweetLikingUsersV2Paginator, TweetRetweetersUsersV2Paginator, ListTimelineV2Paginator, UserOwnedListsV2Paginator, UserListMembershipsV2Paginator, UserListFollowedV2Paginator, TwitterApiv2LabsReadOnly, DMTimelineV2Paginator, FullDMTimelineV2Paginator, OneToOneDMTimelineV2Paginator, ConversationDMTimelineV2Paginator, TwitterApiv2ReadOnly, TwitterApiv2LabsReadWrite, TwitterApiv2ReadWrite, TwitterApiv2Labs, client_v2_labs_default, TwitterApiv2, client_v2_default, TwitterApiReadOnly, TwitterApiReadWrite, TwitterAdsReadOnly, TwitterAdsReadWrite, TwitterAdsSandboxReadOnly, TwitterAdsSandboxReadWrite, TwitterAdsSandbox, client_ads_sandbox_default, TwitterAds, client_ads_default, TwitterApi, value_exports, TypeBoxError, TransformKind, ReadonlyKind, OptionalKind, Hint, Kind, type_exports, TypeGuardUnknownTypeError, KnownTypes, PatternBoolean, PatternNumber, PatternString, PatternNever, PatternBooleanExact, PatternNumberExact, PatternStringExact, PatternNeverExact, format_exports, map2, type_exports2, map3, TemplateLiteralParserError, TemplateLiteralFiniteError, TemplateLiteralGenerateError, TemplateLiteralPatternError, Object2, includePatternProperties, ExtendsResolverError, ExtendsResult, Ordinal, TransformDecodeBuilder, TransformEncodeBuilder, type_exports3, Type, TypeSystemPolicy, TypeSystemDuplicateTypeKind, TypeSystemDuplicateFormat, TypeSystem, TypeDereferenceError, ValueHashError, ByteMarker, Accumulator, Prime, Size, Bytes, F64, F64In, F64Out, ValueErrorType, ValueCheckUnknownTypeError, Insert, Update, Delete3, Edit, uintDecode, globalScope, canonicalizeAlgorithm, hmacDigest, ALPHABET, base32Decode, base32Encode, hexDecode, hexEncode, latin1Decode, latin1Encode, ENCODER, DECODER, utf8Decode2, utf8Encode2, randomBytes2, Secret, timingSafeEqual2, HOTP, TOTP, import_json_stable_stringify, import_stream3, import_receiver, import_sender, import_websocket, import_websocket_server, wrapper_default, import_wrtc, ApiError2, Platform, DEFAULT_USER_AGENT, DEFAULT_REFERER, DEFAULT_ACCEPT_LANGUAGE, bearerToken, TwitterGuestAuth, idCache, TwitterUserAuthSubtask, TwitterUserAuth, reHashtag, reCashtag, reTwitterUrl, reUsername, expectedEntryTypes, SearchMode, endpoints, ApiRequest, apiRequestFactory, defaultOptions2, twUrl, UserTweetsUrl, Scraper, ChatClient, nonstandard, RTCAudioSource, RTCAudioSink, JanusAudioSource, JanusAudioSink, RTCPeerConnection, MediaStream, JanusClient, Logger, Space, SttTtsPlugin, RecordToDiskPlugin, MonitorAudioPlugin, IdleMonitorPlugin, HlsRecordPlugin, ORIGINAL_CIPHERS, TOP_N_SHUFFLE, shuffleArray, randomizeCiphers, NodePlatform, platform, index;
|
|
139679
139637
|
var init_esm_GWSBNV3N = __esm({
|
|
139680
139638
|
"../autonomous/dist/esm-GWSBNV3N.mjs"() {
|
|
139681
139639
|
"use strict";
|
|
@@ -139693,8 +139651,8 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
139693
139651
|
crypto32 = __toESM(require("crypto"), 1);
|
|
139694
139652
|
import_events5 = require("events");
|
|
139695
139653
|
fs32 = __toESM(require("fs"), 1);
|
|
139696
|
-
|
|
139697
|
-
|
|
139654
|
+
import_fs11 = __toESM(require("fs"), 1);
|
|
139655
|
+
import_path7 = __toESM(require("path"), 1);
|
|
139698
139656
|
import_child_process3 = require("child_process");
|
|
139699
139657
|
import_tls = __toESM(require("tls"), 1);
|
|
139700
139658
|
import_crypto8 = require("crypto");
|
|
@@ -140085,7 +140043,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
140085
140043
|
rest
|
|
140086
140044
|
};
|
|
140087
140045
|
}
|
|
140088
|
-
function
|
|
140046
|
+
function resolve(relative, base2) {
|
|
140089
140047
|
if (relative === "") return base2;
|
|
140090
140048
|
var path22 = (base2 || "/").split("/").slice(0, -1).concat(relative.split("/")), i2 = path22.length, last = path22[i2 - 1], unshift = false, up = 0;
|
|
140091
140049
|
while (i2--) {
|
|
@@ -140155,7 +140113,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
140155
140113
|
}
|
|
140156
140114
|
if (parser) url.query = parser(url.query);
|
|
140157
140115
|
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
|
|
140158
|
-
url.pathname =
|
|
140116
|
+
url.pathname = resolve(url.pathname, location.pathname);
|
|
140159
140117
|
}
|
|
140160
140118
|
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
|
|
140161
140119
|
url.pathname = "/" + url.pathname;
|
|
@@ -140527,10 +140485,10 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
140527
140485
|
return Object.defineProperty(function() {
|
|
140528
140486
|
if (typeof arguments[arguments.length - 1] === "function") fn.apply(this, arguments);
|
|
140529
140487
|
else {
|
|
140530
|
-
return new Promise((
|
|
140488
|
+
return new Promise((resolve, reject) => {
|
|
140531
140489
|
arguments[arguments.length] = (err, res) => {
|
|
140532
140490
|
if (err) return reject(err);
|
|
140533
|
-
|
|
140491
|
+
resolve(res);
|
|
140534
140492
|
};
|
|
140535
140493
|
arguments.length++;
|
|
140536
140494
|
fn.apply(this, arguments);
|
|
@@ -149739,12 +149697,12 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
149739
149697
|
this.req.destroy(new Error("Request timeout."));
|
|
149740
149698
|
}
|
|
149741
149699
|
/* Response event handlers */
|
|
149742
|
-
classicResponseHandler(
|
|
149700
|
+
classicResponseHandler(resolve, reject, res) {
|
|
149743
149701
|
this.res = res;
|
|
149744
149702
|
const dataStream = this.getResponseDataStream(res);
|
|
149745
149703
|
dataStream.on("data", (chunk) => this.responseData.push(chunk));
|
|
149746
|
-
dataStream.on("end", this.onResponseEndHandler.bind(this,
|
|
149747
|
-
dataStream.on("close", this.onResponseCloseHandler.bind(this,
|
|
149704
|
+
dataStream.on("end", this.onResponseEndHandler.bind(this, resolve, reject));
|
|
149705
|
+
dataStream.on("close", this.onResponseCloseHandler.bind(this, resolve, reject));
|
|
149748
149706
|
if (this.requestData.requestEventDebugHandler) {
|
|
149749
149707
|
this.requestData.requestEventDebugHandler("response", { res });
|
|
149750
149708
|
res.on("aborted", (error2) => this.requestData.requestEventDebugHandler("response-aborted", { error: error2 }));
|
|
@@ -149753,7 +149711,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
149753
149711
|
res.on("end", () => this.requestData.requestEventDebugHandler("response-end"));
|
|
149754
149712
|
}
|
|
149755
149713
|
}
|
|
149756
|
-
onResponseEndHandler(
|
|
149714
|
+
onResponseEndHandler(resolve, reject) {
|
|
149757
149715
|
const rateLimit = this.getRateLimitFromResponse(this.res);
|
|
149758
149716
|
let data;
|
|
149759
149717
|
try {
|
|
@@ -149771,18 +149729,18 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
149771
149729
|
TwitterApiV2Settings.logger.log(`[${this.requestData.options.method} ${this.hrefPathname}]: Request succeeds with code ${this.res.statusCode}`);
|
|
149772
149730
|
TwitterApiV2Settings.logger.log("Response body:", data);
|
|
149773
149731
|
}
|
|
149774
|
-
|
|
149732
|
+
resolve({
|
|
149775
149733
|
data,
|
|
149776
149734
|
headers: this.res.headers,
|
|
149777
149735
|
rateLimit
|
|
149778
149736
|
});
|
|
149779
149737
|
}
|
|
149780
|
-
onResponseCloseHandler(
|
|
149738
|
+
onResponseCloseHandler(resolve, reject) {
|
|
149781
149739
|
const res = this.res;
|
|
149782
149740
|
if (res.aborted) {
|
|
149783
149741
|
try {
|
|
149784
149742
|
this.getParsedResponse(this.res);
|
|
149785
|
-
return this.onResponseEndHandler(
|
|
149743
|
+
return this.onResponseEndHandler(resolve, reject);
|
|
149786
149744
|
} catch (e2) {
|
|
149787
149745
|
return reject(this.createPartialResponseError(e2, true));
|
|
149788
149746
|
}
|
|
@@ -149791,14 +149749,14 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
149791
149749
|
return reject(this.createPartialResponseError(new Error("Response has been interrupted before response could be parsed."), true));
|
|
149792
149750
|
}
|
|
149793
149751
|
}
|
|
149794
|
-
streamResponseHandler(
|
|
149752
|
+
streamResponseHandler(resolve, reject, res) {
|
|
149795
149753
|
const code = res.statusCode;
|
|
149796
149754
|
if (code < 400) {
|
|
149797
149755
|
if (TwitterApiV2Settings.debug) {
|
|
149798
149756
|
TwitterApiV2Settings.logger.log(`[${this.requestData.options.method} ${this.hrefPathname}]: Request succeeds with code ${res.statusCode} (starting stream)`);
|
|
149799
149757
|
}
|
|
149800
149758
|
const dataStream = this.getResponseDataStream(res);
|
|
149801
|
-
|
|
149759
|
+
resolve({ req: this.req, res: dataStream, originalResponse: res, requestData: this.requestData });
|
|
149802
149760
|
} else {
|
|
149803
149761
|
this.classicResponseHandler(() => void 0, reject, res);
|
|
149804
149762
|
}
|
|
@@ -149855,10 +149813,10 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
149855
149813
|
}
|
|
149856
149814
|
makeRequest() {
|
|
149857
149815
|
this.buildRequest();
|
|
149858
|
-
return new Promise((
|
|
149859
|
-
const
|
|
149816
|
+
return new Promise((_resolve, _reject) => {
|
|
149817
|
+
const resolve = (value) => {
|
|
149860
149818
|
cleanupListener.emit("complete");
|
|
149861
|
-
|
|
149819
|
+
_resolve(value);
|
|
149862
149820
|
};
|
|
149863
149821
|
const reject = (value) => {
|
|
149864
149822
|
cleanupListener.emit("complete");
|
|
@@ -149868,7 +149826,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
149868
149826
|
const req = this.req;
|
|
149869
149827
|
req.on("error", this.requestErrorHandler.bind(this, reject));
|
|
149870
149828
|
req.on("socket", this.onSocketEventHandler.bind(this, reject, cleanupListener));
|
|
149871
|
-
req.on("response", this.classicResponseHandler.bind(this,
|
|
149829
|
+
req.on("response", this.classicResponseHandler.bind(this, resolve, reject));
|
|
149872
149830
|
if (this.requestData.options.timeout) {
|
|
149873
149831
|
req.on("timeout", this.timeoutErrorHandler.bind(this));
|
|
149874
149832
|
}
|
|
@@ -149887,10 +149845,10 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
149887
149845
|
}
|
|
149888
149846
|
makeRequestAndResolveWhenReady() {
|
|
149889
149847
|
this.buildRequest();
|
|
149890
|
-
return new Promise((
|
|
149848
|
+
return new Promise((resolve, reject) => {
|
|
149891
149849
|
const req = this.req;
|
|
149892
149850
|
req.on("error", this.requestErrorHandler.bind(this, reject));
|
|
149893
|
-
req.on("response", this.streamResponseHandler.bind(this,
|
|
149851
|
+
req.on("response", this.streamResponseHandler.bind(this, resolve, reject));
|
|
149894
149852
|
if (this.requestData.body) {
|
|
149895
149853
|
req.write(this.requestData.body);
|
|
149896
149854
|
}
|
|
@@ -153751,7 +153709,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
153751
153709
|
if (runningJob.status === "expired" || runningJob.status === "failed") {
|
|
153752
153710
|
throw new Error("Job failed to be completed.");
|
|
153753
153711
|
}
|
|
153754
|
-
await new Promise((
|
|
153712
|
+
await new Promise((resolve) => setTimeout(resolve, 3500));
|
|
153755
153713
|
runningJob = (await this.complianceJob(job.id)).data;
|
|
153756
153714
|
}
|
|
153757
153715
|
const result = await this.get(job.download_url, void 0, {
|
|
@@ -153939,7 +153897,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
153939
153897
|
case "in_progress": {
|
|
153940
153898
|
const waitTime = info === null || info === void 0 ? void 0 : info.check_after_secs;
|
|
153941
153899
|
if (waitTime && waitTime > 0) {
|
|
153942
|
-
await new Promise((
|
|
153900
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime * 1e3));
|
|
153943
153901
|
await this.waitForMediaProcessing(mediaId);
|
|
153944
153902
|
}
|
|
153945
153903
|
}
|
|
@@ -156086,7 +156044,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
156086
156044
|
});
|
|
156087
156045
|
} catch (err) {
|
|
156088
156046
|
error2 = err;
|
|
156089
|
-
await new Promise((
|
|
156047
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3 * attempts));
|
|
156090
156048
|
}
|
|
156091
156049
|
}
|
|
156092
156050
|
throw error2;
|
|
@@ -157017,12 +156975,12 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
157017
156975
|
if (!this.ws) {
|
|
157018
156976
|
throw new Error("No WebSocket instance");
|
|
157019
156977
|
}
|
|
157020
|
-
return new Promise((
|
|
156978
|
+
return new Promise((resolve, reject) => {
|
|
157021
156979
|
this.ws.on("open", () => {
|
|
157022
156980
|
this.logger.info("[ChatClient] Connected");
|
|
157023
156981
|
this.connected = true;
|
|
157024
156982
|
this.sendAuthAndJoin();
|
|
157025
|
-
|
|
156983
|
+
resolve();
|
|
157026
156984
|
});
|
|
157027
156985
|
this.ws.on("message", (data) => {
|
|
157028
156986
|
this.handleMessage(data.toString());
|
|
@@ -157637,8 +157595,8 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
157637
157595
|
* Allows code to wait for a specific Janus event that matches a predicate
|
|
157638
157596
|
*/
|
|
157639
157597
|
async waitForJanusEvent(predicate, timeoutMs = 5e3, description = "some event") {
|
|
157640
|
-
return new Promise((
|
|
157641
|
-
const waiter = { predicate, resolve
|
|
157598
|
+
return new Promise((resolve, reject) => {
|
|
157599
|
+
const waiter = { predicate, resolve, reject };
|
|
157642
157600
|
this.eventWaiters.push(waiter);
|
|
157643
157601
|
setTimeout(() => {
|
|
157644
157602
|
const idx = this.eventWaiters.indexOf(waiter);
|
|
@@ -158214,7 +158172,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
158214
158172
|
const wavPath = await this.convertPcmToWav(merged, 48e3);
|
|
158215
158173
|
console.log("[SttTtsPlugin] WAV ready =>", wavPath);
|
|
158216
158174
|
const sttText = await this.transcribeWithOpenAI(wavPath, this.sttLanguage);
|
|
158217
|
-
|
|
158175
|
+
import_fs11.default.unlinkSync(wavPath);
|
|
158218
158176
|
if (!sttText.trim()) {
|
|
158219
158177
|
console.log("[SttTtsPlugin] No speech recognized for user =>", userId);
|
|
158220
158178
|
return;
|
|
@@ -158254,8 +158212,8 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
158254
158212
|
this.isSpeaking = false;
|
|
158255
158213
|
}
|
|
158256
158214
|
convertPcmToWav(samples, sampleRate) {
|
|
158257
|
-
return new Promise((
|
|
158258
|
-
const tmpPath =
|
|
158215
|
+
return new Promise((resolve, reject) => {
|
|
158216
|
+
const tmpPath = import_path7.default.resolve("/tmp", `stt-${Date.now()}.wav`);
|
|
158259
158217
|
const ff = (0, import_child_process3.spawn)("ffmpeg", [
|
|
158260
158218
|
"-f",
|
|
158261
158219
|
"s16le",
|
|
@@ -158271,7 +158229,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
158271
158229
|
ff.stdin.write(Buffer.from(samples.buffer));
|
|
158272
158230
|
ff.stdin.end();
|
|
158273
158231
|
ff.on("close", (code) => {
|
|
158274
|
-
if (code === 0)
|
|
158232
|
+
if (code === 0) resolve(tmpPath);
|
|
158275
158233
|
else reject(new Error(`ffmpeg error code=${code}`));
|
|
158276
158234
|
});
|
|
158277
158235
|
});
|
|
@@ -158286,7 +158244,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
158286
158244
|
}
|
|
158287
158245
|
try {
|
|
158288
158246
|
console.log("[SttTtsPlugin] Transcribe =>", wavPath);
|
|
158289
|
-
const fileBuffer =
|
|
158247
|
+
const fileBuffer = import_fs11.default.readFileSync(wavPath);
|
|
158290
158248
|
console.log(
|
|
158291
158249
|
"[SttTtsPlugin] File read, size:",
|
|
158292
158250
|
fileBuffer.length,
|
|
@@ -158294,7 +158252,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
158294
158252
|
);
|
|
158295
158253
|
const blob = new Blob([fileBuffer], { type: "audio/wav" });
|
|
158296
158254
|
const formData = new FormData();
|
|
158297
|
-
formData.append("file", blob,
|
|
158255
|
+
formData.append("file", blob, import_path7.default.basename(wavPath));
|
|
158298
158256
|
formData.append("model", "whisper-1");
|
|
158299
158257
|
formData.append("language", language);
|
|
158300
158258
|
formData.append("temperature", "0");
|
|
@@ -158390,7 +158348,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
158390
158348
|
* Convert MP3 => PCM via ffmpeg
|
|
158391
158349
|
*/
|
|
158392
158350
|
convertMp3ToPcm(mp3Buf, outRate) {
|
|
158393
|
-
return new Promise((
|
|
158351
|
+
return new Promise((resolve, reject) => {
|
|
158394
158352
|
const ff = (0, import_child_process3.spawn)("ffmpeg", [
|
|
158395
158353
|
"-i",
|
|
158396
158354
|
"pipe:0",
|
|
@@ -158418,7 +158376,7 @@ var init_esm_GWSBNV3N = __esm({
|
|
|
158418
158376
|
raw.byteOffset,
|
|
158419
158377
|
raw.byteLength / 2
|
|
158420
158378
|
);
|
|
158421
|
-
|
|
158379
|
+
resolve(samples);
|
|
158422
158380
|
});
|
|
158423
158381
|
ff.stdin.write(mp3Buf);
|
|
158424
158382
|
ff.stdin.end();
|
|
@@ -158805,16 +158763,16 @@ __export(dist_exports2, {
|
|
|
158805
158763
|
saveMediaToArchive: () => saveMediaToArchive
|
|
158806
158764
|
});
|
|
158807
158765
|
function saveMediaToArchive(opts) {
|
|
158808
|
-
const archiveDir = (0,
|
|
158809
|
-
(0,
|
|
158766
|
+
const archiveDir = (0, import_path8.join)(opts.charactersDir, opts.characterName, "social-media");
|
|
158767
|
+
(0, import_fs12.mkdirSync)(archiveDir, { recursive: true });
|
|
158810
158768
|
const now = /* @__PURE__ */ new Date();
|
|
158811
158769
|
const datePart = now.toISOString().slice(0, 10);
|
|
158812
158770
|
const timePart = now.toTimeString().slice(0, 8).replace(/:/g, "-");
|
|
158813
158771
|
const rand = Math.random().toString(36).slice(2, 6);
|
|
158814
158772
|
const ext = opts.mediaType === "video" ? "mp4" : "jpg";
|
|
158815
158773
|
const fileName = `${opts.contentType}_${datePart}_${timePart}_${rand}.${ext}`;
|
|
158816
|
-
const filePath = (0,
|
|
158817
|
-
(0,
|
|
158774
|
+
const filePath = (0, import_path8.join)(archiveDir, fileName);
|
|
158775
|
+
(0, import_fs12.writeFileSync)(filePath, opts.mediaBuffer);
|
|
158818
158776
|
console.log(`[Social/Archive] Saved ${fileName} (${(opts.mediaBuffer.length / 1024).toFixed(0)} KB)`);
|
|
158819
158777
|
return { filePath, fileName };
|
|
158820
158778
|
}
|
|
@@ -159074,7 +159032,7 @@ async function waitForMediaProcessing(mediaId, accessToken, maxAttempts = 30) {
|
|
|
159074
159032
|
return { mediaId, success: false, error: "Processing timed out" };
|
|
159075
159033
|
}
|
|
159076
159034
|
function sleep2(ms) {
|
|
159077
|
-
return new Promise((
|
|
159035
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
159078
159036
|
}
|
|
159079
159037
|
function encodeRFC3986(str2) {
|
|
159080
159038
|
return encodeURIComponent(str2).replace(
|
|
@@ -159082,18 +159040,18 @@ function encodeRFC3986(str2) {
|
|
|
159082
159040
|
(c2) => "%" + c2.charCodeAt(0).toString(16).toUpperCase()
|
|
159083
159041
|
);
|
|
159084
159042
|
}
|
|
159085
|
-
var cron,
|
|
159043
|
+
var cron, import_path8, import_fs12, import_path9, import_fs13, import_crypto9, import_fs14, CONTENT_WEIGHTS, SocialContentGenerator, AutonomousScheduler, MusicEngine, DramaEngine, DEFAULT_DAILY_ROUTINE, ActivityManager, playwright, NAV_TIMEOUT, MAX_CONSECUTIVE_FAILURES, BrowserAgent, UPLOAD_URL, MAX_CHUNK_SIZE, SocialEngine;
|
|
159086
159044
|
var init_dist4 = __esm({
|
|
159087
159045
|
"../autonomous/dist/index.mjs"() {
|
|
159088
159046
|
"use strict";
|
|
159089
159047
|
init_chunk_HEBXNMVQ();
|
|
159090
159048
|
cron = __toESM(require_node_cron(), 1);
|
|
159091
|
-
|
|
159092
|
-
|
|
159093
|
-
|
|
159094
|
-
|
|
159049
|
+
import_path8 = require("path");
|
|
159050
|
+
import_fs12 = require("fs");
|
|
159051
|
+
import_path9 = require("path");
|
|
159052
|
+
import_fs13 = require("fs");
|
|
159095
159053
|
import_crypto9 = require("crypto");
|
|
159096
|
-
|
|
159054
|
+
import_fs14 = require("fs");
|
|
159097
159055
|
CONTENT_WEIGHTS = [
|
|
159098
159056
|
{ type: "text_reflection", weight: 20 },
|
|
159099
159057
|
{ type: "selfie_post", weight: 55 },
|
|
@@ -160307,9 +160265,9 @@ var init_dist4 = __esm({
|
|
|
160307
160265
|
* Persistent profile mode: Launch Chromium with a dedicated user data directory.
|
|
160308
160266
|
*/
|
|
160309
160267
|
async tryLaunchPersistent(pw) {
|
|
160310
|
-
const profileDir = this.config.profileDir ?? (0,
|
|
160268
|
+
const profileDir = this.config.profileDir ?? (0, import_path9.join)(process.env.HOME ?? "/tmp", ".opencrush", "chrome-profile");
|
|
160311
160269
|
try {
|
|
160312
|
-
(0,
|
|
160270
|
+
(0, import_fs13.mkdirSync)(profileDir, { recursive: true });
|
|
160313
160271
|
this.context = await pw.chromium.launchPersistentContext(profileDir, {
|
|
160314
160272
|
headless: this.config.headless ?? false,
|
|
160315
160273
|
args: [
|
|
@@ -160335,9 +160293,9 @@ var init_dist4 = __esm({
|
|
|
160335
160293
|
* Chrome mode: Launch the user's real Google Chrome with a dedicated profile.
|
|
160336
160294
|
*/
|
|
160337
160295
|
async tryLaunchChrome(pw) {
|
|
160338
|
-
const profileDir = this.config.profileDir ?? (0,
|
|
160296
|
+
const profileDir = this.config.profileDir ?? (0, import_path9.join)(process.env.HOME ?? "/tmp", ".opencrush", "chrome-profile");
|
|
160339
160297
|
try {
|
|
160340
|
-
(0,
|
|
160298
|
+
(0, import_fs13.mkdirSync)(profileDir, { recursive: true });
|
|
160341
160299
|
this.context = await pw.chromium.launchPersistentContext(profileDir, {
|
|
160342
160300
|
channel: "chrome",
|
|
160343
160301
|
headless: this.config.headless ?? false,
|
|
@@ -160629,7 +160587,7 @@ var init_dist4 = __esm({
|
|
|
160629
160587
|
if (tc.cookiePath) {
|
|
160630
160588
|
try {
|
|
160631
160589
|
const cookies = await this.twitterClient.getCookies();
|
|
160632
|
-
(0,
|
|
160590
|
+
(0, import_fs14.writeFileSync)(tc.cookiePath, JSON.stringify(cookies));
|
|
160633
160591
|
} catch {
|
|
160634
160592
|
}
|
|
160635
160593
|
}
|
|
@@ -160655,11 +160613,11 @@ var init_dist4 = __esm({
|
|
|
160655
160613
|
*/
|
|
160656
160614
|
async loadAndRefreshOAuth2Token(tc) {
|
|
160657
160615
|
const tokenFile = tc.oauth2TokenFile;
|
|
160658
|
-
if (!(0,
|
|
160616
|
+
if (!(0, import_fs14.existsSync)(tokenFile)) {
|
|
160659
160617
|
console.log("[Social/Twitter] OAuth 2.0 token file not found \u2014 run test-twitter-oauth2.mjs first");
|
|
160660
160618
|
return null;
|
|
160661
160619
|
}
|
|
160662
|
-
const saved = JSON.parse((0,
|
|
160620
|
+
const saved = JSON.parse((0, import_fs14.readFileSync)(tokenFile, "utf-8"));
|
|
160663
160621
|
if (!saved.refresh_token) {
|
|
160664
160622
|
console.log("[Social/Twitter] No refresh_token in token file");
|
|
160665
160623
|
return null;
|
|
@@ -160684,7 +160642,7 @@ var init_dist4 = __esm({
|
|
|
160684
160642
|
body.toString()
|
|
160685
160643
|
);
|
|
160686
160644
|
if (refreshed.access_token) {
|
|
160687
|
-
(0,
|
|
160645
|
+
(0, import_fs14.writeFileSync)(tokenFile, JSON.stringify(refreshed, null, 2));
|
|
160688
160646
|
return refreshed.access_token;
|
|
160689
160647
|
}
|
|
160690
160648
|
console.warn("[Social/Twitter] Token refresh failed:", JSON.stringify(refreshed));
|
|
@@ -161126,11 +161084,11 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
161126
161084
|
}
|
|
161127
161085
|
function __awaiter(thisArg, _arguments, P2, generator) {
|
|
161128
161086
|
function adopt(value) {
|
|
161129
|
-
return value instanceof P2 ? value : new P2(function(
|
|
161130
|
-
|
|
161087
|
+
return value instanceof P2 ? value : new P2(function(resolve) {
|
|
161088
|
+
resolve(value);
|
|
161131
161089
|
});
|
|
161132
161090
|
}
|
|
161133
|
-
return new (P2 || (P2 = Promise))(function(
|
|
161091
|
+
return new (P2 || (P2 = Promise))(function(resolve, reject) {
|
|
161134
161092
|
function fulfilled(value) {
|
|
161135
161093
|
try {
|
|
161136
161094
|
step(generator.next(value));
|
|
@@ -161146,7 +161104,7 @@ function __awaiter(thisArg, _arguments, P2, generator) {
|
|
|
161146
161104
|
}
|
|
161147
161105
|
}
|
|
161148
161106
|
function step(result) {
|
|
161149
|
-
result.done ?
|
|
161107
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
161150
161108
|
}
|
|
161151
161109
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
161152
161110
|
});
|
|
@@ -161337,14 +161295,14 @@ function __asyncValues(o2) {
|
|
|
161337
161295
|
}, i2);
|
|
161338
161296
|
function verb(n2) {
|
|
161339
161297
|
i2[n2] = o2[n2] && function(v2) {
|
|
161340
|
-
return new Promise(function(
|
|
161341
|
-
v2 = o2[n2](v2), settle(
|
|
161298
|
+
return new Promise(function(resolve, reject) {
|
|
161299
|
+
v2 = o2[n2](v2), settle(resolve, reject, v2.done, v2.value);
|
|
161342
161300
|
});
|
|
161343
161301
|
};
|
|
161344
161302
|
}
|
|
161345
|
-
function settle(
|
|
161303
|
+
function settle(resolve, reject, d2, v2) {
|
|
161346
161304
|
Promise.resolve(v2).then(function(v6) {
|
|
161347
|
-
|
|
161305
|
+
resolve({ value: v6, done: d2 });
|
|
161348
161306
|
}, reject);
|
|
161349
161307
|
}
|
|
161350
161308
|
}
|
|
@@ -163204,9 +163162,9 @@ var require_dispatcher_base2 = __commonJS({
|
|
|
163204
163162
|
}
|
|
163205
163163
|
close(callback) {
|
|
163206
163164
|
if (callback === void 0) {
|
|
163207
|
-
return new Promise((
|
|
163165
|
+
return new Promise((resolve, reject) => {
|
|
163208
163166
|
this.close((err, data) => {
|
|
163209
|
-
return err ? reject(err) :
|
|
163167
|
+
return err ? reject(err) : resolve(data);
|
|
163210
163168
|
});
|
|
163211
163169
|
});
|
|
163212
163170
|
}
|
|
@@ -163244,12 +163202,12 @@ var require_dispatcher_base2 = __commonJS({
|
|
|
163244
163202
|
err = null;
|
|
163245
163203
|
}
|
|
163246
163204
|
if (callback === void 0) {
|
|
163247
|
-
return new Promise((
|
|
163205
|
+
return new Promise((resolve, reject) => {
|
|
163248
163206
|
this.destroy(err, (err2, data) => {
|
|
163249
163207
|
return err2 ? (
|
|
163250
163208
|
/* istanbul ignore next: should never error */
|
|
163251
163209
|
reject(err2)
|
|
163252
|
-
) :
|
|
163210
|
+
) : resolve(data);
|
|
163253
163211
|
});
|
|
163254
163212
|
});
|
|
163255
163213
|
}
|
|
@@ -165518,8 +165476,8 @@ var require_util8 = __commonJS({
|
|
|
165518
165476
|
function createDeferredPromise() {
|
|
165519
165477
|
let res;
|
|
165520
165478
|
let rej;
|
|
165521
|
-
const promise = new Promise((
|
|
165522
|
-
res =
|
|
165479
|
+
const promise = new Promise((resolve, reject) => {
|
|
165480
|
+
res = resolve;
|
|
165523
165481
|
rej = reject;
|
|
165524
165482
|
});
|
|
165525
165483
|
return { promise, resolve: res, reject: rej };
|
|
@@ -167670,12 +167628,12 @@ upgrade: ${upgrade}\r
|
|
|
167670
167628
|
cb();
|
|
167671
167629
|
}
|
|
167672
167630
|
}
|
|
167673
|
-
const waitForDrain = () => new Promise((
|
|
167631
|
+
const waitForDrain = () => new Promise((resolve, reject) => {
|
|
167674
167632
|
assert(callback === null);
|
|
167675
167633
|
if (socket[kError]) {
|
|
167676
167634
|
reject(socket[kError]);
|
|
167677
167635
|
} else {
|
|
167678
|
-
callback =
|
|
167636
|
+
callback = resolve;
|
|
167679
167637
|
}
|
|
167680
167638
|
});
|
|
167681
167639
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -168313,12 +168271,12 @@ var require_client_h22 = __commonJS({
|
|
|
168313
168271
|
cb();
|
|
168314
168272
|
}
|
|
168315
168273
|
}
|
|
168316
|
-
const waitForDrain = () => new Promise((
|
|
168274
|
+
const waitForDrain = () => new Promise((resolve, reject) => {
|
|
168317
168275
|
assert(callback === null);
|
|
168318
168276
|
if (socket[kError]) {
|
|
168319
168277
|
reject(socket[kError]);
|
|
168320
168278
|
} else {
|
|
168321
|
-
callback =
|
|
168279
|
+
callback = resolve;
|
|
168322
168280
|
}
|
|
168323
168281
|
});
|
|
168324
168282
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -168797,16 +168755,16 @@ var require_client3 = __commonJS({
|
|
|
168797
168755
|
return this[kNeedDrain] < 2;
|
|
168798
168756
|
}
|
|
168799
168757
|
async [kClose]() {
|
|
168800
|
-
return new Promise((
|
|
168758
|
+
return new Promise((resolve) => {
|
|
168801
168759
|
if (this[kSize]) {
|
|
168802
|
-
this[kClosedResolve] =
|
|
168760
|
+
this[kClosedResolve] = resolve;
|
|
168803
168761
|
} else {
|
|
168804
|
-
|
|
168762
|
+
resolve(null);
|
|
168805
168763
|
}
|
|
168806
168764
|
});
|
|
168807
168765
|
}
|
|
168808
168766
|
async [kDestroy](err) {
|
|
168809
|
-
return new Promise((
|
|
168767
|
+
return new Promise((resolve) => {
|
|
168810
168768
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
168811
168769
|
for (let i2 = 0; i2 < requests.length; i2++) {
|
|
168812
168770
|
const request2 = requests[i2];
|
|
@@ -168817,7 +168775,7 @@ var require_client3 = __commonJS({
|
|
|
168817
168775
|
this[kClosedResolve]();
|
|
168818
168776
|
this[kClosedResolve] = null;
|
|
168819
168777
|
}
|
|
168820
|
-
|
|
168778
|
+
resolve(null);
|
|
168821
168779
|
};
|
|
168822
168780
|
if (this[kHTTPContext]) {
|
|
168823
168781
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -168869,7 +168827,7 @@ var require_client3 = __commonJS({
|
|
|
168869
168827
|
});
|
|
168870
168828
|
}
|
|
168871
168829
|
try {
|
|
168872
|
-
const socket = await new Promise((
|
|
168830
|
+
const socket = await new Promise((resolve, reject) => {
|
|
168873
168831
|
client[kConnector]({
|
|
168874
168832
|
host,
|
|
168875
168833
|
hostname,
|
|
@@ -168881,7 +168839,7 @@ var require_client3 = __commonJS({
|
|
|
168881
168839
|
if (err) {
|
|
168882
168840
|
reject(err);
|
|
168883
168841
|
} else {
|
|
168884
|
-
|
|
168842
|
+
resolve(socket2);
|
|
168885
168843
|
}
|
|
168886
168844
|
});
|
|
168887
168845
|
});
|
|
@@ -169218,8 +169176,8 @@ var require_pool_base2 = __commonJS({
|
|
|
169218
169176
|
if (this[kQueue].isEmpty()) {
|
|
169219
169177
|
await Promise.all(this[kClients].map((c2) => c2.close()));
|
|
169220
169178
|
} else {
|
|
169221
|
-
await new Promise((
|
|
169222
|
-
this[kClosedResolve] =
|
|
169179
|
+
await new Promise((resolve) => {
|
|
169180
|
+
this[kClosedResolve] = resolve;
|
|
169223
169181
|
});
|
|
169224
169182
|
}
|
|
169225
169183
|
}
|
|
@@ -170371,7 +170329,7 @@ var require_readable2 = __commonJS({
|
|
|
170371
170329
|
if (this._readableState.closeEmitted) {
|
|
170372
170330
|
return null;
|
|
170373
170331
|
}
|
|
170374
|
-
return await new Promise((
|
|
170332
|
+
return await new Promise((resolve, reject) => {
|
|
170375
170333
|
if (this[kContentLength] > limit) {
|
|
170376
170334
|
this.destroy(new AbortError2());
|
|
170377
170335
|
}
|
|
@@ -170384,7 +170342,7 @@ var require_readable2 = __commonJS({
|
|
|
170384
170342
|
if (signal == null ? void 0 : signal.aborted) {
|
|
170385
170343
|
reject(signal.reason ?? new AbortError2());
|
|
170386
170344
|
} else {
|
|
170387
|
-
|
|
170345
|
+
resolve(null);
|
|
170388
170346
|
}
|
|
170389
170347
|
}).on("error", noop).on("data", function(chunk) {
|
|
170390
170348
|
limit -= chunk.length;
|
|
@@ -170403,7 +170361,7 @@ var require_readable2 = __commonJS({
|
|
|
170403
170361
|
}
|
|
170404
170362
|
async function consume(stream, type) {
|
|
170405
170363
|
assert(!stream[kConsume]);
|
|
170406
|
-
return new Promise((
|
|
170364
|
+
return new Promise((resolve, reject) => {
|
|
170407
170365
|
if (isUnusable(stream)) {
|
|
170408
170366
|
const rState = stream._readableState;
|
|
170409
170367
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -170420,7 +170378,7 @@ var require_readable2 = __commonJS({
|
|
|
170420
170378
|
stream[kConsume] = {
|
|
170421
170379
|
type,
|
|
170422
170380
|
stream,
|
|
170423
|
-
resolve
|
|
170381
|
+
resolve,
|
|
170424
170382
|
reject,
|
|
170425
170383
|
length: 0,
|
|
170426
170384
|
body: []
|
|
@@ -170490,18 +170448,18 @@ var require_readable2 = __commonJS({
|
|
|
170490
170448
|
return buffer;
|
|
170491
170449
|
}
|
|
170492
170450
|
function consumeEnd(consume2) {
|
|
170493
|
-
const { type, body, resolve
|
|
170451
|
+
const { type, body, resolve, stream, length } = consume2;
|
|
170494
170452
|
try {
|
|
170495
170453
|
if (type === "text") {
|
|
170496
|
-
|
|
170454
|
+
resolve(chunksDecode(body, length));
|
|
170497
170455
|
} else if (type === "json") {
|
|
170498
|
-
|
|
170456
|
+
resolve(JSON.parse(chunksDecode(body, length)));
|
|
170499
170457
|
} else if (type === "arrayBuffer") {
|
|
170500
|
-
|
|
170458
|
+
resolve(chunksConcat(body, length).buffer);
|
|
170501
170459
|
} else if (type === "blob") {
|
|
170502
|
-
|
|
170460
|
+
resolve(new Blob(body, { type: stream[kContentType] }));
|
|
170503
170461
|
} else if (type === "bytes") {
|
|
170504
|
-
|
|
170462
|
+
resolve(chunksConcat(body, length));
|
|
170505
170463
|
}
|
|
170506
170464
|
consumeFinish(consume2);
|
|
170507
170465
|
} catch (err) {
|
|
@@ -170759,9 +170717,9 @@ var require_api_request2 = __commonJS({
|
|
|
170759
170717
|
};
|
|
170760
170718
|
function request2(opts, callback) {
|
|
170761
170719
|
if (callback === void 0) {
|
|
170762
|
-
return new Promise((
|
|
170720
|
+
return new Promise((resolve, reject) => {
|
|
170763
170721
|
request2.call(this, opts, (err, data) => {
|
|
170764
|
-
return err ? reject(err) :
|
|
170722
|
+
return err ? reject(err) : resolve(data);
|
|
170765
170723
|
});
|
|
170766
170724
|
});
|
|
170767
170725
|
}
|
|
@@ -170986,9 +170944,9 @@ var require_api_stream2 = __commonJS({
|
|
|
170986
170944
|
};
|
|
170987
170945
|
function stream(opts, factory, callback) {
|
|
170988
170946
|
if (callback === void 0) {
|
|
170989
|
-
return new Promise((
|
|
170947
|
+
return new Promise((resolve, reject) => {
|
|
170990
170948
|
stream.call(this, opts, factory, (err, data) => {
|
|
170991
|
-
return err ? reject(err) :
|
|
170949
|
+
return err ? reject(err) : resolve(data);
|
|
170992
170950
|
});
|
|
170993
170951
|
});
|
|
170994
170952
|
}
|
|
@@ -171273,9 +171231,9 @@ var require_api_upgrade2 = __commonJS({
|
|
|
171273
171231
|
};
|
|
171274
171232
|
function upgrade(opts, callback) {
|
|
171275
171233
|
if (callback === void 0) {
|
|
171276
|
-
return new Promise((
|
|
171234
|
+
return new Promise((resolve, reject) => {
|
|
171277
171235
|
upgrade.call(this, opts, (err, data) => {
|
|
171278
|
-
return err ? reject(err) :
|
|
171236
|
+
return err ? reject(err) : resolve(data);
|
|
171279
171237
|
});
|
|
171280
171238
|
});
|
|
171281
171239
|
}
|
|
@@ -171367,9 +171325,9 @@ var require_api_connect2 = __commonJS({
|
|
|
171367
171325
|
};
|
|
171368
171326
|
function connect(opts, callback) {
|
|
171369
171327
|
if (callback === void 0) {
|
|
171370
|
-
return new Promise((
|
|
171328
|
+
return new Promise((resolve, reject) => {
|
|
171371
171329
|
connect.call(this, opts, (err, data) => {
|
|
171372
|
-
return err ? reject(err) :
|
|
171330
|
+
return err ? reject(err) : resolve(data);
|
|
171373
171331
|
});
|
|
171374
171332
|
});
|
|
171375
171333
|
}
|
|
@@ -175243,7 +175201,7 @@ var require_fetch2 = __commonJS({
|
|
|
175243
175201
|
function dispatch({ body }) {
|
|
175244
175202
|
const url = requestCurrentURL(request2);
|
|
175245
175203
|
const agent = fetchParams.controller.dispatcher;
|
|
175246
|
-
return new Promise((
|
|
175204
|
+
return new Promise((resolve, reject) => agent.dispatch(
|
|
175247
175205
|
{
|
|
175248
175206
|
path: url.pathname + url.search,
|
|
175249
175207
|
origin: url.origin,
|
|
@@ -175317,7 +175275,7 @@ var require_fetch2 = __commonJS({
|
|
|
175317
175275
|
}
|
|
175318
175276
|
}
|
|
175319
175277
|
const onError = this.onError.bind(this);
|
|
175320
|
-
|
|
175278
|
+
resolve({
|
|
175321
175279
|
status,
|
|
175322
175280
|
statusText,
|
|
175323
175281
|
headersList,
|
|
@@ -175364,7 +175322,7 @@ var require_fetch2 = __commonJS({
|
|
|
175364
175322
|
for (let i2 = 0; i2 < rawHeaders.length; i2 += 2) {
|
|
175365
175323
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i2]), rawHeaders[i2 + 1].toString("latin1"), true);
|
|
175366
175324
|
}
|
|
175367
|
-
|
|
175325
|
+
resolve({
|
|
175368
175326
|
status,
|
|
175369
175327
|
statusText: STATUS_CODES2[status],
|
|
175370
175328
|
headersList,
|
|
@@ -178958,8 +178916,8 @@ var require_util14 = __commonJS({
|
|
|
178958
178916
|
return true;
|
|
178959
178917
|
}
|
|
178960
178918
|
function delay(ms) {
|
|
178961
|
-
return new Promise((
|
|
178962
|
-
setTimeout(
|
|
178919
|
+
return new Promise((resolve) => {
|
|
178920
|
+
setTimeout(resolve, ms).unref();
|
|
178963
178921
|
});
|
|
178964
178922
|
}
|
|
178965
178923
|
module2.exports = {
|
|
@@ -186602,7 +186560,7 @@ Emitted 'error' event${ctorInfo} at:
|
|
|
186602
186560
|
if (signal == null ? void 0 : signal.aborted) {
|
|
186603
186561
|
throw new AbortError2(void 0, { cause: getReason(signal) });
|
|
186604
186562
|
}
|
|
186605
|
-
return new Promise((
|
|
186563
|
+
return new Promise((resolve, reject) => {
|
|
186606
186564
|
const errorListener = /* @__PURE__ */ __name((err) => {
|
|
186607
186565
|
emitter.removeListener(eventName, resolver);
|
|
186608
186566
|
if (signal) {
|
|
@@ -186615,7 +186573,7 @@ Emitted 'error' event${ctorInfo} at:
|
|
|
186615
186573
|
if (signal) {
|
|
186616
186574
|
eventTargetAgnosticRemoveListener(signal, "abort", abortListener);
|
|
186617
186575
|
}
|
|
186618
|
-
|
|
186576
|
+
resolve(args);
|
|
186619
186577
|
}, "resolver");
|
|
186620
186578
|
emitter.once(eventName, resolver);
|
|
186621
186579
|
if (eventName !== "error") {
|
|
@@ -186677,8 +186635,8 @@ Emitted 'error' event${ctorInfo} at:
|
|
|
186677
186635
|
if (finished) {
|
|
186678
186636
|
return Promise.resolve(createIterResult(void 0, true));
|
|
186679
186637
|
}
|
|
186680
|
-
return new Promise((
|
|
186681
|
-
unconsumedPromises.push({ resolve
|
|
186638
|
+
return new Promise((resolve, reject) => {
|
|
186639
|
+
unconsumedPromises.push({ resolve, reject });
|
|
186682
186640
|
});
|
|
186683
186641
|
},
|
|
186684
186642
|
return() {
|
|
@@ -188136,8 +188094,8 @@ var require_cjs6 = __commonJS({
|
|
|
188136
188094
|
__publicField2(this, "signal", null);
|
|
188137
188095
|
__publicField2(this, "signalListener", null);
|
|
188138
188096
|
this.queue = queue;
|
|
188139
|
-
this.promise = new Promise((
|
|
188140
|
-
this.resolve =
|
|
188097
|
+
this.promise = new Promise((resolve, reject) => {
|
|
188098
|
+
this.resolve = resolve;
|
|
188141
188099
|
this.reject = reject;
|
|
188142
188100
|
});
|
|
188143
188101
|
}
|
|
@@ -188549,8 +188507,8 @@ var require_dist6 = __commonJS({
|
|
|
188549
188507
|
}
|
|
188550
188508
|
__name(calculateUserDefaultAvatarIndex, "calculateUserDefaultAvatarIndex");
|
|
188551
188509
|
async function sleep3(ms) {
|
|
188552
|
-
return new Promise((
|
|
188553
|
-
setTimeout(() =>
|
|
188510
|
+
return new Promise((resolve) => {
|
|
188511
|
+
setTimeout(() => resolve(), ms);
|
|
188554
188512
|
});
|
|
188555
188513
|
}
|
|
188556
188514
|
__name(sleep3, "sleep");
|
|
@@ -189370,9 +189328,9 @@ ${flattened}` : error2.message || flattened || "Unknown Error";
|
|
|
189370
189328
|
(_a10 = __privateGet(this, _sublimitPromise)) == null ? void 0 : _a10.resolve();
|
|
189371
189329
|
__privateSet(this, _sublimitPromise, null);
|
|
189372
189330
|
await sleep3(sublimitTimeout);
|
|
189373
|
-
let
|
|
189374
|
-
const promise = new Promise((res2) =>
|
|
189375
|
-
__privateSet(this, _sublimitPromise, { promise, resolve
|
|
189331
|
+
let resolve;
|
|
189332
|
+
const promise = new Promise((res2) => resolve = res2);
|
|
189333
|
+
__privateSet(this, _sublimitPromise, { promise, resolve });
|
|
189376
189334
|
if (firstSublimit) {
|
|
189377
189335
|
await __privateGet(this, _asyncQueue).wait();
|
|
189378
189336
|
__privateSet(this, _shiftSublimit, true);
|
|
@@ -194158,7 +194116,7 @@ var require_Collector = __commonJS({
|
|
|
194158
194116
|
* @readonly
|
|
194159
194117
|
*/
|
|
194160
194118
|
get next() {
|
|
194161
|
-
return new Promise((
|
|
194119
|
+
return new Promise((resolve, reject) => {
|
|
194162
194120
|
if (this.ended) {
|
|
194163
194121
|
reject(this.collected);
|
|
194164
194122
|
return;
|
|
@@ -194169,7 +194127,7 @@ var require_Collector = __commonJS({
|
|
|
194169
194127
|
};
|
|
194170
194128
|
const onCollect = (item) => {
|
|
194171
194129
|
cleanup();
|
|
194172
|
-
|
|
194130
|
+
resolve(item);
|
|
194173
194131
|
};
|
|
194174
194132
|
const onEnd = () => {
|
|
194175
194133
|
cleanup();
|
|
@@ -194240,11 +194198,11 @@ var require_Collector = __commonJS({
|
|
|
194240
194198
|
if (queue.length) {
|
|
194241
194199
|
yield queue.shift();
|
|
194242
194200
|
} else {
|
|
194243
|
-
await new Promise((
|
|
194201
|
+
await new Promise((resolve) => {
|
|
194244
194202
|
const tick = () => {
|
|
194245
194203
|
this.removeListener("collect", tick);
|
|
194246
194204
|
this.removeListener("end", tick);
|
|
194247
|
-
return
|
|
194205
|
+
return resolve();
|
|
194248
194206
|
};
|
|
194249
194207
|
this.on("collect", tick);
|
|
194250
194208
|
this.on("end", tick);
|
|
@@ -195783,11 +195741,11 @@ var require_GuildTemplate = __commonJS({
|
|
|
195783
195741
|
}
|
|
195784
195742
|
});
|
|
195785
195743
|
if (client.guilds.cache.has(data.id)) return client.guilds.cache.get(data.id);
|
|
195786
|
-
return new Promise((
|
|
195744
|
+
return new Promise((resolve) => {
|
|
195787
195745
|
const resolveGuild = (guild) => {
|
|
195788
195746
|
client.off(Events3.GuildCreate, handleGuild);
|
|
195789
195747
|
client.decrementMaxListeners();
|
|
195790
|
-
|
|
195748
|
+
resolve(guild);
|
|
195791
195749
|
};
|
|
195792
195750
|
const handleGuild = (guild) => {
|
|
195793
195751
|
if (guild.id === data.id) {
|
|
@@ -209342,12 +209300,12 @@ var require_Message = __commonJS({
|
|
|
209342
209300
|
* .catch(console.error);
|
|
209343
209301
|
*/
|
|
209344
209302
|
awaitReactions(options2 = {}) {
|
|
209345
|
-
return new Promise((
|
|
209303
|
+
return new Promise((resolve, reject) => {
|
|
209346
209304
|
const collector = this.createReactionCollector(options2);
|
|
209347
209305
|
collector.once("end", (reactions, reason) => {
|
|
209348
209306
|
var _a3;
|
|
209349
209307
|
if ((_a3 = options2.errors) == null ? void 0 : _a3.includes(reason)) reject(reactions);
|
|
209350
|
-
else
|
|
209308
|
+
else resolve(reactions);
|
|
209351
209309
|
});
|
|
209352
209310
|
});
|
|
209353
209311
|
}
|
|
@@ -209400,11 +209358,11 @@ var require_Message = __commonJS({
|
|
|
209400
209358
|
*/
|
|
209401
209359
|
awaitMessageComponent(options2 = {}) {
|
|
209402
209360
|
const _options = { ...options2, max: 1 };
|
|
209403
|
-
return new Promise((
|
|
209361
|
+
return new Promise((resolve, reject) => {
|
|
209404
209362
|
const collector = this.createMessageComponentCollector(_options);
|
|
209405
209363
|
collector.once("end", (interactions, reason) => {
|
|
209406
209364
|
const interaction = interactions.first();
|
|
209407
|
-
if (interaction)
|
|
209365
|
+
if (interaction) resolve(interaction);
|
|
209408
209366
|
else reject(new DiscordjsError2(ErrorCodes2.InteractionCollectorError, reason));
|
|
209409
209367
|
});
|
|
209410
209368
|
});
|
|
@@ -211989,14 +211947,14 @@ var require_TextBasedChannel = __commonJS({
|
|
|
211989
211947
|
* .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
|
|
211990
211948
|
*/
|
|
211991
211949
|
awaitMessages(options2 = {}) {
|
|
211992
|
-
return new Promise((
|
|
211950
|
+
return new Promise((resolve, reject) => {
|
|
211993
211951
|
const collector = this.createMessageCollector(options2);
|
|
211994
211952
|
collector.once("end", (collection, reason) => {
|
|
211995
211953
|
var _a3;
|
|
211996
211954
|
if ((_a3 = options2.errors) == null ? void 0 : _a3.includes(reason)) {
|
|
211997
211955
|
reject(collection);
|
|
211998
211956
|
} else {
|
|
211999
|
-
|
|
211957
|
+
resolve(collection);
|
|
212000
211958
|
}
|
|
212001
211959
|
});
|
|
212002
211960
|
});
|
|
@@ -212033,11 +211991,11 @@ var require_TextBasedChannel = __commonJS({
|
|
|
212033
211991
|
*/
|
|
212034
211992
|
awaitMessageComponent(options2 = {}) {
|
|
212035
211993
|
const _options = { ...options2, max: 1 };
|
|
212036
|
-
return new Promise((
|
|
211994
|
+
return new Promise((resolve, reject) => {
|
|
212037
211995
|
const collector = this.createMessageComponentCollector(_options);
|
|
212038
211996
|
collector.once("end", (interactions, reason) => {
|
|
212039
211997
|
const interaction = interactions.first();
|
|
212040
|
-
if (interaction)
|
|
211998
|
+
if (interaction) resolve(interaction);
|
|
212041
211999
|
else reject(new DiscordjsError2(ErrorCodes2.InteractionCollectorError, reason));
|
|
212042
212000
|
});
|
|
212043
212001
|
});
|
|
@@ -217338,11 +217296,11 @@ var require_InteractionResponse = __commonJS({
|
|
|
217338
217296
|
*/
|
|
217339
217297
|
awaitMessageComponent(options2 = {}) {
|
|
217340
217298
|
const _options = { ...options2, max: 1 };
|
|
217341
|
-
return new Promise((
|
|
217299
|
+
return new Promise((resolve, reject) => {
|
|
217342
217300
|
const collector = this.createMessageComponentCollector(_options);
|
|
217343
217301
|
collector.once("end", (interactions, reason) => {
|
|
217344
217302
|
const interaction = interactions.first();
|
|
217345
|
-
if (interaction)
|
|
217303
|
+
if (interaction) resolve(interaction);
|
|
217346
217304
|
else reject(new DiscordjsError2(ErrorCodes2.InteractionCollectorError, reason));
|
|
217347
217305
|
});
|
|
217348
217306
|
});
|
|
@@ -217769,11 +217727,11 @@ var require_InteractionResponses = __commonJS({
|
|
|
217769
217727
|
async awaitModalSubmit(options2) {
|
|
217770
217728
|
if (typeof options2.time !== "number") throw new DiscordjsError2(ErrorCodes2.InvalidType, "time", "number");
|
|
217771
217729
|
const _options = { ...options2, max: 1, interactionType: InteractionType.ModalSubmit };
|
|
217772
|
-
return new Promise((
|
|
217730
|
+
return new Promise((resolve, reject) => {
|
|
217773
217731
|
const collector = new InteractionCollector(this.client, _options);
|
|
217774
217732
|
collector.once("end", (interactions, reason) => {
|
|
217775
217733
|
const interaction = interactions.first();
|
|
217776
|
-
if (interaction)
|
|
217734
|
+
if (interaction) resolve(interaction);
|
|
217777
217735
|
else reject(new DiscordjsError2(ErrorCodes2.InteractionCollectorError, reason));
|
|
217778
217736
|
});
|
|
217779
217737
|
});
|
|
@@ -223429,7 +223387,7 @@ var require_dist10 = __commonJS({
|
|
|
223429
223387
|
op: 0,
|
|
223430
223388
|
shardId
|
|
223431
223389
|
};
|
|
223432
|
-
const promise = new Promise((
|
|
223390
|
+
const promise = new Promise((resolve2) => this.connectPromises.set(shardId, resolve2));
|
|
223433
223391
|
worker.postMessage(payload);
|
|
223434
223392
|
promises2.push(promise);
|
|
223435
223393
|
}
|
|
@@ -223448,7 +223406,7 @@ var require_dist10 = __commonJS({
|
|
|
223448
223406
|
};
|
|
223449
223407
|
promises2.push(
|
|
223450
223408
|
// eslint-disable-next-line no-promise-executor-return, promise/prefer-await-to-then
|
|
223451
|
-
new Promise((
|
|
223409
|
+
new Promise((resolve2) => this.destroyPromises.set(shardId, resolve2)).then(async () => worker.terminate())
|
|
223452
223410
|
);
|
|
223453
223411
|
worker.postMessage(payload);
|
|
223454
223412
|
}
|
|
@@ -223483,7 +223441,7 @@ var require_dist10 = __commonJS({
|
|
|
223483
223441
|
shardId,
|
|
223484
223442
|
nonce
|
|
223485
223443
|
};
|
|
223486
|
-
const promise = new Promise((
|
|
223444
|
+
const promise = new Promise((resolve2) => this.fetchStatusPromises.set(nonce, resolve2));
|
|
223487
223445
|
worker.postMessage(payload);
|
|
223488
223446
|
const status = await promise;
|
|
223489
223447
|
statuses.set(shardId, status);
|
|
@@ -223529,10 +223487,10 @@ var require_dist10 = __commonJS({
|
|
|
223529
223487
|
}
|
|
223530
223488
|
}
|
|
223531
223489
|
async waitForWorkerReady(worker) {
|
|
223532
|
-
return new Promise((
|
|
223490
|
+
return new Promise((resolve2) => {
|
|
223533
223491
|
const handler = /* @__PURE__ */ __name((payload) => {
|
|
223534
223492
|
if (payload.op === 7) {
|
|
223535
|
-
|
|
223493
|
+
resolve2();
|
|
223536
223494
|
worker.off("message", handler);
|
|
223537
223495
|
}
|
|
223538
223496
|
}, "handler");
|
|
@@ -223650,7 +223608,7 @@ var require_dist10 = __commonJS({
|
|
|
223650
223608
|
shardId,
|
|
223651
223609
|
nonce
|
|
223652
223610
|
};
|
|
223653
|
-
const promise = new Promise((
|
|
223611
|
+
const promise = new Promise((resolve2) => this.sessionPromises.set(nonce, resolve2));
|
|
223654
223612
|
import_node_worker_threads2.parentPort.postMessage(payload);
|
|
223655
223613
|
return promise;
|
|
223656
223614
|
}
|
|
@@ -223670,9 +223628,9 @@ var require_dist10 = __commonJS({
|
|
|
223670
223628
|
shardId
|
|
223671
223629
|
};
|
|
223672
223630
|
const promise = new Promise(
|
|
223673
|
-
(
|
|
223631
|
+
(resolve2, reject) => (
|
|
223674
223632
|
// eslint-disable-next-line no-promise-executor-return
|
|
223675
|
-
this.waitForIdentifyPromises.set(nonce, { signal, resolve:
|
|
223633
|
+
this.waitForIdentifyPromises.set(nonce, { signal, resolve: resolve2, reject })
|
|
223676
223634
|
)
|
|
223677
223635
|
);
|
|
223678
223636
|
import_node_worker_threads2.parentPort.postMessage(payload);
|
|
@@ -223971,8 +223929,8 @@ var require_dist10 = __commonJS({
|
|
|
223971
223929
|
]);
|
|
223972
223930
|
if (shouldClose) {
|
|
223973
223931
|
let outerResolve;
|
|
223974
|
-
const promise = new Promise((
|
|
223975
|
-
outerResolve =
|
|
223932
|
+
const promise = new Promise((resolve2) => {
|
|
223933
|
+
outerResolve = resolve2;
|
|
223976
223934
|
});
|
|
223977
223935
|
this.connection.onclose = outerResolve;
|
|
223978
223936
|
this.connection.close(options2.code, options2.reason);
|
|
@@ -224160,13 +224118,13 @@ var require_dist10 = __commonJS({
|
|
|
224160
224118
|
}
|
|
224161
224119
|
const decompressable = new Uint8Array(data);
|
|
224162
224120
|
if (this.useIdentifyCompress) {
|
|
224163
|
-
return new Promise((
|
|
224121
|
+
return new Promise((resolve2, reject) => {
|
|
224164
224122
|
(0, import_node_zlib.inflate)(decompressable, { chunkSize: 65535 }, (err, result) => {
|
|
224165
224123
|
if (err) {
|
|
224166
224124
|
reject(err);
|
|
224167
224125
|
return;
|
|
224168
224126
|
}
|
|
224169
|
-
|
|
224127
|
+
resolve2(JSON.parse(this.textDecoder.decode(result)));
|
|
224170
224128
|
});
|
|
224171
224129
|
});
|
|
224172
224130
|
}
|
|
@@ -226604,17 +226562,17 @@ var require_ShardClientUtil = __commonJS({
|
|
|
226604
226562
|
* @emits Shard#message
|
|
226605
226563
|
*/
|
|
226606
226564
|
send(message) {
|
|
226607
|
-
return new Promise((
|
|
226565
|
+
return new Promise((resolve, reject) => {
|
|
226608
226566
|
switch (this.mode) {
|
|
226609
226567
|
case "process":
|
|
226610
226568
|
process13.send(message, (err) => {
|
|
226611
226569
|
if (err) reject(err);
|
|
226612
|
-
else
|
|
226570
|
+
else resolve();
|
|
226613
226571
|
});
|
|
226614
226572
|
break;
|
|
226615
226573
|
case "worker":
|
|
226616
226574
|
this.parentPort.postMessage(message);
|
|
226617
|
-
|
|
226575
|
+
resolve();
|
|
226618
226576
|
break;
|
|
226619
226577
|
}
|
|
226620
226578
|
});
|
|
@@ -226631,13 +226589,13 @@ var require_ShardClientUtil = __commonJS({
|
|
|
226631
226589
|
* @see {@link ShardingManager#fetchClientValues}
|
|
226632
226590
|
*/
|
|
226633
226591
|
fetchClientValues(prop, shard) {
|
|
226634
|
-
return new Promise((
|
|
226592
|
+
return new Promise((resolve, reject) => {
|
|
226635
226593
|
const parent = this.parentPort ?? process13;
|
|
226636
226594
|
const listener = (message) => {
|
|
226637
226595
|
if ((message == null ? void 0 : message._sFetchProp) !== prop || message._sFetchPropShard !== shard) return;
|
|
226638
226596
|
parent.removeListener("message", listener);
|
|
226639
226597
|
this.decrementMaxListeners(parent);
|
|
226640
|
-
if (!message._error)
|
|
226598
|
+
if (!message._error) resolve(message._result);
|
|
226641
226599
|
else reject(makeError(message._error));
|
|
226642
226600
|
};
|
|
226643
226601
|
this.incrementMaxListeners(parent);
|
|
@@ -226661,7 +226619,7 @@ var require_ShardClientUtil = __commonJS({
|
|
|
226661
226619
|
* @see {@link ShardingManager#broadcastEval}
|
|
226662
226620
|
*/
|
|
226663
226621
|
broadcastEval(script2, options2 = {}) {
|
|
226664
|
-
return new Promise((
|
|
226622
|
+
return new Promise((resolve, reject) => {
|
|
226665
226623
|
const parent = this.parentPort ?? process13;
|
|
226666
226624
|
if (typeof script2 !== "function") {
|
|
226667
226625
|
reject(new DiscordjsTypeError2(ErrorCodes2.ShardingInvalidEvalBroadcast));
|
|
@@ -226672,7 +226630,7 @@ var require_ShardClientUtil = __commonJS({
|
|
|
226672
226630
|
if ((message == null ? void 0 : message._sEval) !== script2 || message._sEvalShard !== options2.shard) return;
|
|
226673
226631
|
parent.removeListener("message", listener);
|
|
226674
226632
|
this.decrementMaxListeners(parent);
|
|
226675
|
-
if (!message._error)
|
|
226633
|
+
if (!message._error) resolve(message._result);
|
|
226676
226634
|
else reject(makeError(message._error));
|
|
226677
226635
|
};
|
|
226678
226636
|
this.incrementMaxListeners(parent);
|
|
@@ -228543,7 +228501,7 @@ var require_GuildMemberManager = __commonJS({
|
|
|
228543
228501
|
nonce = DiscordSnowflake.generate().toString()
|
|
228544
228502
|
} = {}) {
|
|
228545
228503
|
if (nonce.length > 32) throw new DiscordjsRangeError2(ErrorCodes2.MemberFetchNonceLength);
|
|
228546
|
-
return new Promise((
|
|
228504
|
+
return new Promise((resolve, reject) => {
|
|
228547
228505
|
if (!query && !users) query = "";
|
|
228548
228506
|
const fetchedMembers = new Collection2();
|
|
228549
228507
|
let i2 = 0;
|
|
@@ -228567,7 +228525,7 @@ var require_GuildMemberManager = __commonJS({
|
|
|
228567
228525
|
}
|
|
228568
228526
|
if (members.size < 1e3 || limit && fetchedMembers.size >= limit || i2 === chunk.count) {
|
|
228569
228527
|
cleanup();
|
|
228570
|
-
|
|
228528
|
+
resolve(users && !Array.isArray(users) && fetchedMembers.size ? fetchedMembers.first() : fetchedMembers);
|
|
228571
228529
|
}
|
|
228572
228530
|
};
|
|
228573
228531
|
const requestData = {
|
|
@@ -231841,12 +231799,12 @@ var require_GuildManager = __commonJS({
|
|
|
231841
231799
|
system_channel_flags: systemChannelFlags === void 0 ? void 0 : SystemChannelFlagsBitField.resolve(systemChannelFlags)
|
|
231842
231800
|
}
|
|
231843
231801
|
});
|
|
231844
|
-
return this.client.guilds.cache.get(data.id) ?? new Promise((
|
|
231802
|
+
return this.client.guilds.cache.get(data.id) ?? new Promise((resolve) => {
|
|
231845
231803
|
const handleGuild = (guild) => {
|
|
231846
231804
|
if (guild.id === data.id) {
|
|
231847
231805
|
clearTimeout2(timeout);
|
|
231848
231806
|
this.client.decrementMaxListeners();
|
|
231849
|
-
|
|
231807
|
+
resolve(guild);
|
|
231850
231808
|
}
|
|
231851
231809
|
};
|
|
231852
231810
|
this.client.incrementMaxListeners();
|
|
@@ -231854,7 +231812,7 @@ var require_GuildManager = __commonJS({
|
|
|
231854
231812
|
const timeout = setTimeout2(() => {
|
|
231855
231813
|
this.client.removeListener(Events3.GuildCreate, handleGuild);
|
|
231856
231814
|
this.client.decrementMaxListeners();
|
|
231857
|
-
|
|
231815
|
+
resolve(this.client.guilds._add(data));
|
|
231858
231816
|
}, 1e4).unref();
|
|
231859
231817
|
});
|
|
231860
231818
|
}
|
|
@@ -231926,7 +231884,7 @@ var require_GuildManager = __commonJS({
|
|
|
231926
231884
|
}
|
|
231927
231885
|
});
|
|
231928
231886
|
}
|
|
231929
|
-
return new Promise((
|
|
231887
|
+
return new Promise((resolve, reject) => {
|
|
231930
231888
|
const remainingGuildIds = new Set(guildIds);
|
|
231931
231889
|
const fetchedSoundboardSounds = new Collection2();
|
|
231932
231890
|
const handler = (soundboardSounds, guild) => {
|
|
@@ -231938,7 +231896,7 @@ var require_GuildManager = __commonJS({
|
|
|
231938
231896
|
clearTimeout2(timeout);
|
|
231939
231897
|
this.client.removeListener(Events3.SoundboardSounds, handler);
|
|
231940
231898
|
this.client.decrementMaxListeners();
|
|
231941
|
-
|
|
231899
|
+
resolve(fetchedSoundboardSounds);
|
|
231942
231900
|
}
|
|
231943
231901
|
};
|
|
231944
231902
|
const timeout = setTimeout2(() => {
|
|
@@ -233357,7 +233315,7 @@ var require_Shard = __commonJS({
|
|
|
233357
233315
|
const child = this.process ?? this.worker;
|
|
233358
233316
|
this.emit(ShardEvents.Spawn, child);
|
|
233359
233317
|
if (timeout === -1 || timeout === Infinity) return child;
|
|
233360
|
-
return new Promise((
|
|
233318
|
+
return new Promise((resolve, reject) => {
|
|
233361
233319
|
const cleanup = () => {
|
|
233362
233320
|
clearTimeout2(spawnTimeoutTimer);
|
|
233363
233321
|
this.off("ready", onReady);
|
|
@@ -233366,7 +233324,7 @@ var require_Shard = __commonJS({
|
|
|
233366
233324
|
};
|
|
233367
233325
|
const onReady = () => {
|
|
233368
233326
|
cleanup();
|
|
233369
|
-
|
|
233327
|
+
resolve(child);
|
|
233370
233328
|
};
|
|
233371
233329
|
const onDisconnect = () => {
|
|
233372
233330
|
cleanup();
|
|
@@ -233423,15 +233381,15 @@ var require_Shard = __commonJS({
|
|
|
233423
233381
|
* @returns {Promise<Shard>}
|
|
233424
233382
|
*/
|
|
233425
233383
|
send(message) {
|
|
233426
|
-
return new Promise((
|
|
233384
|
+
return new Promise((resolve, reject) => {
|
|
233427
233385
|
if (this.process) {
|
|
233428
233386
|
this.process.send(message, (err) => {
|
|
233429
233387
|
if (err) reject(err);
|
|
233430
|
-
else
|
|
233388
|
+
else resolve(this);
|
|
233431
233389
|
});
|
|
233432
233390
|
} else {
|
|
233433
233391
|
this.worker.postMessage(message);
|
|
233434
|
-
|
|
233392
|
+
resolve(this);
|
|
233435
233393
|
}
|
|
233436
233394
|
});
|
|
233437
233395
|
}
|
|
@@ -233449,14 +233407,14 @@ var require_Shard = __commonJS({
|
|
|
233449
233407
|
throw new DiscordjsError2(ErrorCodes2.ShardingNoChildExists, this.id);
|
|
233450
233408
|
}
|
|
233451
233409
|
if (this._fetches.has(prop)) return this._fetches.get(prop);
|
|
233452
|
-
const promise = new Promise((
|
|
233410
|
+
const promise = new Promise((resolve, reject) => {
|
|
233453
233411
|
const child = this.process ?? this.worker;
|
|
233454
233412
|
const listener = (message) => {
|
|
233455
233413
|
if ((message == null ? void 0 : message._fetchProp) !== prop) return;
|
|
233456
233414
|
child.removeListener("message", listener);
|
|
233457
233415
|
this.decrementMaxListeners(child);
|
|
233458
233416
|
this._fetches.delete(prop);
|
|
233459
|
-
if (!message._error)
|
|
233417
|
+
if (!message._error) resolve(message._result);
|
|
233460
233418
|
else reject(makeError(message._error));
|
|
233461
233419
|
};
|
|
233462
233420
|
this.incrementMaxListeners(child);
|
|
@@ -233483,14 +233441,14 @@ var require_Shard = __commonJS({
|
|
|
233483
233441
|
throw new DiscordjsError2(ErrorCodes2.ShardingNoChildExists, this.id);
|
|
233484
233442
|
}
|
|
233485
233443
|
if (this._evals.has(_eval)) return this._evals.get(_eval);
|
|
233486
|
-
const promise = new Promise((
|
|
233444
|
+
const promise = new Promise((resolve, reject) => {
|
|
233487
233445
|
const child = this.process ?? this.worker;
|
|
233488
233446
|
const listener = (message) => {
|
|
233489
233447
|
if ((message == null ? void 0 : message._eval) !== _eval) return;
|
|
233490
233448
|
child.removeListener("message", listener);
|
|
233491
233449
|
this.decrementMaxListeners(child);
|
|
233492
233450
|
this._evals.delete(_eval);
|
|
233493
|
-
if (!message._error)
|
|
233451
|
+
if (!message._error) resolve(message._result);
|
|
233494
233452
|
else reject(makeError(message._error));
|
|
233495
233453
|
};
|
|
233496
233454
|
this.incrementMaxListeners(child);
|
|
@@ -234626,7 +234584,7 @@ function debugLog3(msg) {
|
|
|
234626
234584
|
`;
|
|
234627
234585
|
console.log(msg);
|
|
234628
234586
|
try {
|
|
234629
|
-
(0,
|
|
234587
|
+
(0, import_fs15.appendFileSync)(DEBUG_LOG, line);
|
|
234630
234588
|
} catch {
|
|
234631
234589
|
}
|
|
234632
234590
|
}
|
|
@@ -234652,12 +234610,12 @@ function splitMessage(text, maxLength = 1900) {
|
|
|
234652
234610
|
if (current) chunks.push(current.trim());
|
|
234653
234611
|
return chunks;
|
|
234654
234612
|
}
|
|
234655
|
-
var import_discord,
|
|
234613
|
+
var import_discord, import_fs15, import_voice, import_stream4, DEBUG_LOG, prism, DiscordBridge;
|
|
234656
234614
|
var init_dist5 = __esm({
|
|
234657
234615
|
"../bridges/discord/dist/index.mjs"() {
|
|
234658
234616
|
"use strict";
|
|
234659
234617
|
import_discord = __toESM(require_src3(), 1);
|
|
234660
|
-
|
|
234618
|
+
import_fs15 = require("fs");
|
|
234661
234619
|
import_voice = require("@discordjs/voice");
|
|
234662
234620
|
import_stream4 = require("stream");
|
|
234663
234621
|
DEBUG_LOG = "/tmp/opencrush-debug.log";
|
|
@@ -234981,21 +234939,21 @@ var init_dist5 = __esm({
|
|
|
234981
234939
|
frameSize: 960
|
|
234982
234940
|
});
|
|
234983
234941
|
const pcmChunks = [];
|
|
234984
|
-
return new Promise((
|
|
234942
|
+
return new Promise((resolve) => {
|
|
234985
234943
|
const pipeline = opusStream.pipe(decoder);
|
|
234986
234944
|
pipeline.on("data", (chunk) => {
|
|
234987
234945
|
pcmChunks.push(chunk);
|
|
234988
234946
|
});
|
|
234989
234947
|
pipeline.on("end", () => {
|
|
234990
234948
|
if (pcmChunks.length === 0) {
|
|
234991
|
-
|
|
234949
|
+
resolve(null);
|
|
234992
234950
|
return;
|
|
234993
234951
|
}
|
|
234994
234952
|
const pcm = Buffer.concat(pcmChunks);
|
|
234995
|
-
|
|
234953
|
+
resolve(this.wrapPcmAsWav(pcm, 48e3, 1, 16));
|
|
234996
234954
|
});
|
|
234997
234955
|
pipeline.on("error", () => {
|
|
234998
|
-
|
|
234956
|
+
resolve(null);
|
|
234999
234957
|
});
|
|
235000
234958
|
setTimeout(() => {
|
|
235001
234959
|
opusStream.destroy();
|
|
@@ -235169,8 +235127,8 @@ var init_dist5 = __esm({
|
|
|
235169
235127
|
const ssAction = action;
|
|
235170
235128
|
try {
|
|
235171
235129
|
const { readFileSync: readFileSync8 } = await import("fs");
|
|
235172
|
-
const { resolve
|
|
235173
|
-
const resolved =
|
|
235130
|
+
const { resolve } = await import("path");
|
|
235131
|
+
const resolved = resolve(ssAction.filePath);
|
|
235174
235132
|
if (!resolved.startsWith("/tmp/")) {
|
|
235175
235133
|
debugLog3(`[Discord] Screenshot path rejected \u2014 outside /tmp: ${resolved}`);
|
|
235176
235134
|
continue;
|
|
@@ -243991,7 +243949,7 @@ var require_frameworks = __commonJS({
|
|
|
243991
243949
|
end: () => resolveResponse({ status: 204 }),
|
|
243992
243950
|
respond: (json) => resolveResponse({ jsonBody: json }),
|
|
243993
243951
|
unauthorized: () => resolveResponse({ status: 401, body: WRONG_TOKEN_ERROR }),
|
|
243994
|
-
handlerReturn: new Promise((
|
|
243952
|
+
handlerReturn: new Promise((resolve) => resolveResponse = resolve)
|
|
243995
243953
|
};
|
|
243996
243954
|
};
|
|
243997
243955
|
var bun = (request2) => {
|
|
@@ -244015,8 +243973,8 @@ var require_frameworks = __commonJS({
|
|
|
244015
243973
|
};
|
|
244016
243974
|
var cloudflare = (event) => {
|
|
244017
243975
|
let resolveResponse;
|
|
244018
|
-
event.respondWith(new Promise((
|
|
244019
|
-
resolveResponse =
|
|
243976
|
+
event.respondWith(new Promise((resolve) => {
|
|
243977
|
+
resolveResponse = resolve;
|
|
244020
243978
|
}));
|
|
244021
243979
|
return {
|
|
244022
243980
|
get update() {
|
|
@@ -244100,12 +244058,12 @@ var require_frameworks = __commonJS({
|
|
|
244100
244058
|
const secretHeaderFromRequest = req.headers[SECRET_HEADER_LOWERCASE];
|
|
244101
244059
|
return {
|
|
244102
244060
|
get update() {
|
|
244103
|
-
return new Promise((
|
|
244061
|
+
return new Promise((resolve, reject) => {
|
|
244104
244062
|
const chunks = [];
|
|
244105
244063
|
req.on("data", (chunk) => chunks.push(chunk)).once("end", () => {
|
|
244106
244064
|
const raw = Buffer.concat(chunks).toString("utf-8");
|
|
244107
244065
|
try {
|
|
244108
|
-
|
|
244066
|
+
resolve(JSON.parse(raw));
|
|
244109
244067
|
} catch (err) {
|
|
244110
244068
|
reject(err);
|
|
244111
244069
|
}
|
|
@@ -244356,7 +244314,7 @@ var require_webhook2 = __commonJS({
|
|
|
244356
244314
|
function timeoutIfNecessary(task, onTimeout, timeout) {
|
|
244357
244315
|
if (timeout === Infinity)
|
|
244358
244316
|
return task;
|
|
244359
|
-
return new Promise((
|
|
244317
|
+
return new Promise((resolve, reject) => {
|
|
244360
244318
|
const handle = setTimeout(() => {
|
|
244361
244319
|
debugErr(`Request timed out after ${timeout} ms`);
|
|
244362
244320
|
if (onTimeout === "throw") {
|
|
@@ -244364,7 +244322,7 @@ var require_webhook2 = __commonJS({
|
|
|
244364
244322
|
} else {
|
|
244365
244323
|
if (typeof onTimeout === "function")
|
|
244366
244324
|
onTimeout();
|
|
244367
|
-
|
|
244325
|
+
resolve();
|
|
244368
244326
|
}
|
|
244369
244327
|
const now = Date.now();
|
|
244370
244328
|
task.finally(() => {
|
|
@@ -244372,7 +244330,7 @@ var require_webhook2 = __commonJS({
|
|
|
244372
244330
|
debugErr(`Request completed ${diff} ms after timeout!`);
|
|
244373
244331
|
});
|
|
244374
244332
|
}, timeout);
|
|
244375
|
-
task.then(
|
|
244333
|
+
task.then(resolve).catch(reject).finally(() => clearTimeout(handle));
|
|
244376
244334
|
});
|
|
244377
244335
|
}
|
|
244378
244336
|
}
|
|
@@ -244612,9 +244570,9 @@ __export(start_exports, {
|
|
|
244612
244570
|
function killExistingProcess() {
|
|
244613
244571
|
let killed = false;
|
|
244614
244572
|
const myPid = process.pid;
|
|
244615
|
-
if ((0,
|
|
244573
|
+
if ((0, import_fs16.existsSync)(PID_FILE)) {
|
|
244616
244574
|
try {
|
|
244617
|
-
const pid = parseInt((0,
|
|
244575
|
+
const pid = parseInt((0, import_fs16.readFileSync)(PID_FILE, "utf-8").trim(), 10);
|
|
244618
244576
|
if (!isNaN(pid) && pid !== myPid) {
|
|
244619
244577
|
try {
|
|
244620
244578
|
process.kill(pid, 0);
|
|
@@ -244625,7 +244583,7 @@ function killExistingProcess() {
|
|
|
244625
244583
|
}
|
|
244626
244584
|
}
|
|
244627
244585
|
try {
|
|
244628
|
-
(0,
|
|
244586
|
+
(0, import_fs16.unlinkSync)(PID_FILE);
|
|
244629
244587
|
} catch {
|
|
244630
244588
|
}
|
|
244631
244589
|
} catch {
|
|
@@ -244686,11 +244644,11 @@ function killExistingProcess() {
|
|
|
244686
244644
|
return killed;
|
|
244687
244645
|
}
|
|
244688
244646
|
function writePidFile() {
|
|
244689
|
-
(0,
|
|
244647
|
+
(0, import_fs16.writeFileSync)(PID_FILE, String(process.pid), "utf-8");
|
|
244690
244648
|
}
|
|
244691
244649
|
function cleanupPidFile() {
|
|
244692
244650
|
try {
|
|
244693
|
-
(0,
|
|
244651
|
+
(0, import_fs16.unlinkSync)(PID_FILE);
|
|
244694
244652
|
} catch {
|
|
244695
244653
|
}
|
|
244696
244654
|
}
|
|
@@ -244701,7 +244659,7 @@ async function startOpencrush() {
|
|
|
244701
244659
|
validateConfig(config);
|
|
244702
244660
|
const engine = new ConversationEngine({
|
|
244703
244661
|
characterName: config.CHARACTER_NAME,
|
|
244704
|
-
charactersDir: (0,
|
|
244662
|
+
charactersDir: (0, import_path10.join)(ROOT_DIR, "characters"),
|
|
244705
244663
|
llm: {
|
|
244706
244664
|
provider: config.LLM_PROVIDER,
|
|
244707
244665
|
// International
|
|
@@ -244723,7 +244681,7 @@ async function startOpencrush() {
|
|
|
244723
244681
|
}
|
|
244724
244682
|
});
|
|
244725
244683
|
console.log(source_default.green(` \u2713 ${engine.characterName} is waking up...`));
|
|
244726
|
-
console.log(source_default.gray(` Provider: ${config.LLM_PROVIDER} | Character dir: ${(0,
|
|
244684
|
+
console.log(source_default.gray(` Provider: ${config.LLM_PROVIDER} | Character dir: ${(0, import_path10.join)(ROOT_DIR, "characters", config.CHARACTER_NAME)}`));
|
|
244727
244685
|
const media = new MediaEngine({
|
|
244728
244686
|
image: {
|
|
244729
244687
|
falKey: config.FAL_KEY,
|
|
@@ -244763,7 +244721,7 @@ async function startOpencrush() {
|
|
|
244763
244721
|
twitter: hasAnyTwitter ? {
|
|
244764
244722
|
clientId: config.TWITTER_CLIENT_ID,
|
|
244765
244723
|
clientSecret: config.TWITTER_CLIENT_SECRET,
|
|
244766
|
-
oauth2TokenFile: hasTwitterOAuth2 ? (0,
|
|
244724
|
+
oauth2TokenFile: hasTwitterOAuth2 ? (0, import_path10.join)(ROOT_DIR, ".twitter-oauth2-tokens.json") : void 0,
|
|
244767
244725
|
apiKey: config.TWITTER_API_KEY ?? config.TWITTER_CONSUMER_KEY,
|
|
244768
244726
|
apiSecret: config.TWITTER_API_SECRET ?? config.TWITTER_CONSUMER_SECRET,
|
|
244769
244727
|
accessToken: config.TWITTER_ACCESS_TOKEN,
|
|
@@ -244771,7 +244729,7 @@ async function startOpencrush() {
|
|
|
244771
244729
|
username: config.TWITTER_USERNAME,
|
|
244772
244730
|
password: config.TWITTER_PASSWORD,
|
|
244773
244731
|
email: config.TWITTER_EMAIL,
|
|
244774
|
-
cookiePath: (0,
|
|
244732
|
+
cookiePath: (0, import_path10.join)(ROOT_DIR, ".twitter-cookies.json")
|
|
244775
244733
|
} : void 0,
|
|
244776
244734
|
minPostIntervalMinutes: parseInt(config.SOCIAL_MIN_POST_INTERVAL ?? "120"),
|
|
244777
244735
|
autoPost: config.SOCIAL_AUTO_POST === "true"
|
|
@@ -244845,7 +244803,7 @@ async function startOpencrush() {
|
|
|
244845
244803
|
socialEngine,
|
|
244846
244804
|
mediaEngine: media,
|
|
244847
244805
|
socialAutoPost: config.SOCIAL_AUTO_POST === "true",
|
|
244848
|
-
charactersDir: (0,
|
|
244806
|
+
charactersDir: (0, import_path10.join)(ROOT_DIR, "characters"),
|
|
244849
244807
|
quietHoursStart: parseInt(config.QUIET_HOURS_START ?? "23"),
|
|
244850
244808
|
quietHoursEnd: parseInt(config.QUIET_HOURS_END ?? "8"),
|
|
244851
244809
|
minIntervalMinutes: parseInt(config.PROACTIVE_MESSAGE_MIN_INTERVAL ?? "60"),
|
|
@@ -244953,7 +244911,7 @@ function loadConfig() {
|
|
|
244953
244911
|
function validateConfig(config) {
|
|
244954
244912
|
if (!config.CHARACTER_NAME) {
|
|
244955
244913
|
console.log(source_default.red("\n \u274C CHARACTER_NAME not set in .env"));
|
|
244956
|
-
console.log(source_default.gray(' Run "
|
|
244914
|
+
console.log(source_default.gray(' Run "npx opencrush@latest setup" to configure, or edit .env directly'));
|
|
244957
244915
|
process.exit(1);
|
|
244958
244916
|
}
|
|
244959
244917
|
const hasLLM = config.ANTHROPIC_API_KEY || config.OPENAI_API_KEY || config.DEEPSEEK_API_KEY || config.DASHSCOPE_API_KEY || config.MOONSHOT_API_KEY || config.ZHIPU_API_KEY || config.MINIMAX_API_KEY || config.LLM_PROVIDER === "ollama";
|
|
@@ -244966,24 +244924,20 @@ function validateConfig(config) {
|
|
|
244966
244924
|
process.exit(1);
|
|
244967
244925
|
}
|
|
244968
244926
|
}
|
|
244969
|
-
var import_dotenv,
|
|
244927
|
+
var import_dotenv, import_path10, import_fs16, import_child_process4, PID_FILE;
|
|
244970
244928
|
var init_start = __esm({
|
|
244971
244929
|
"src/start.ts"() {
|
|
244972
244930
|
import_dotenv = __toESM(require_main());
|
|
244973
|
-
import_path12 = require("path");
|
|
244974
244931
|
init_paths();
|
|
244975
|
-
import_fs18 = require("fs");
|
|
244976
244932
|
init_source();
|
|
244977
244933
|
init_dist();
|
|
244978
244934
|
init_dist3();
|
|
244979
244935
|
init_dist4();
|
|
244980
|
-
|
|
244981
|
-
|
|
244936
|
+
import_path10 = require("path");
|
|
244937
|
+
import_fs16 = require("fs");
|
|
244982
244938
|
import_child_process4 = require("child_process");
|
|
244983
244939
|
ensureHomeDirExists();
|
|
244984
|
-
|
|
244985
|
-
import_dotenv.default.config({ path: (0, import_fs18.existsSync)(legacyEnv) ? legacyEnv : getEnvPath() });
|
|
244986
|
-
ROOT_DIR3 = (0, import_fs18.existsSync)((0, import_path12.resolve)(process.env.INIT_CWD ?? process.cwd(), ".env")) ? process.env.INIT_CWD ?? process.cwd() : OPENCRUSH_HOME;
|
|
244940
|
+
import_dotenv.default.config({ path: getEnvPath() });
|
|
244987
244941
|
PID_FILE = "/tmp/opencrush.pid";
|
|
244988
244942
|
}
|
|
244989
244943
|
});
|
|
@@ -245504,8 +245458,8 @@ async function runSetupWizard() {
|
|
|
245504
245458
|
envValues.PROACTIVE_MESSAGE_MAX_INTERVAL = maxInterval;
|
|
245505
245459
|
const spinner = ora("Writing configuration...").start();
|
|
245506
245460
|
const envContent = generateEnvFile(envValues);
|
|
245507
|
-
const envFilePath =
|
|
245508
|
-
(0,
|
|
245461
|
+
const envFilePath = getEnvPath();
|
|
245462
|
+
(0, import_fs17.writeFileSync)(envFilePath, envContent, "utf-8");
|
|
245509
245463
|
spinner.succeed(`Configuration saved to ${envFilePath}`);
|
|
245510
245464
|
const enabledFeatures = [];
|
|
245511
245465
|
enabledFeatures.push(`\u{1F9E0} AI: ${providerInfo.name}`);
|
|
@@ -245550,8 +245504,8 @@ async function runSetupWizard() {
|
|
|
245550
245504
|
}
|
|
245551
245505
|
function getCharacterPreview(name) {
|
|
245552
245506
|
var _a3, _b2;
|
|
245553
|
-
const identityPath = (0,
|
|
245554
|
-
if (!(0,
|
|
245507
|
+
const identityPath = (0, import_path11.join)(findCharDir(name), "IDENTITY.md");
|
|
245508
|
+
if (!(0, import_fs17.existsSync)(identityPath)) return "";
|
|
245555
245509
|
try {
|
|
245556
245510
|
const { readFileSync: readFileSync8 } = require("fs");
|
|
245557
245511
|
const content = readFileSync8(identityPath, "utf-8");
|
|
@@ -245565,33 +245519,22 @@ function getCharacterPreview(name) {
|
|
|
245565
245519
|
}
|
|
245566
245520
|
}
|
|
245567
245521
|
function maybeOpenCard(name) {
|
|
245568
|
-
const cardPath = (0,
|
|
245569
|
-
if (!(0,
|
|
245522
|
+
const cardPath = (0, import_path11.join)(findCharDir(name), "card.png");
|
|
245523
|
+
if (!(0, import_fs17.existsSync)(cardPath)) return;
|
|
245570
245524
|
const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
245571
245525
|
(0, import_child_process5.exec)(`${opener} "${cardPath}"`);
|
|
245572
245526
|
}
|
|
245573
|
-
function getCharsDirResolved() {
|
|
245574
|
-
return (0, import_path14.join)(ROOT_DIR4, "characters");
|
|
245575
|
-
}
|
|
245576
|
-
function getAllCharsDirs() {
|
|
245577
|
-
return [.../* @__PURE__ */ new Set([getCharsDirResolved(), getCharactersDir()])];
|
|
245578
|
-
}
|
|
245579
245527
|
function findCharDir(name) {
|
|
245580
|
-
|
|
245581
|
-
if ((0, import_fs20.existsSync)((0, import_path14.join)(dir, name))) return (0, import_path14.join)(dir, name);
|
|
245582
|
-
}
|
|
245583
|
-
return (0, import_path14.join)(getCharsDirResolved(), name);
|
|
245528
|
+
return (0, import_path11.join)(getCharactersDir(), name);
|
|
245584
245529
|
}
|
|
245585
245530
|
function getExistingCharacters() {
|
|
245586
|
-
const
|
|
245587
|
-
|
|
245588
|
-
|
|
245589
|
-
|
|
245590
|
-
|
|
245591
|
-
|
|
245592
|
-
}
|
|
245531
|
+
const dir = getCharactersDir();
|
|
245532
|
+
if (!(0, import_fs17.existsSync)(dir)) return [];
|
|
245533
|
+
try {
|
|
245534
|
+
return (0, import_fs17.readdirSync)(dir, { withFileTypes: true }).filter((d2) => d2.isDirectory() && d2.name !== "example").map((d2) => d2.name);
|
|
245535
|
+
} catch {
|
|
245536
|
+
return [];
|
|
245593
245537
|
}
|
|
245594
|
-
return [...names];
|
|
245595
245538
|
}
|
|
245596
245539
|
function generateEnvFile(values) {
|
|
245597
245540
|
const sections = {
|
|
@@ -245633,23 +245576,21 @@ function generateEnvFile(values) {
|
|
|
245633
245576
|
lines.push("");
|
|
245634
245577
|
return lines.join("\n");
|
|
245635
245578
|
}
|
|
245636
|
-
var
|
|
245579
|
+
var import_fs17, import_path11, import_child_process5;
|
|
245637
245580
|
var init_setup = __esm({
|
|
245638
245581
|
"src/setup.ts"() {
|
|
245639
245582
|
init_esm16();
|
|
245640
245583
|
init_source();
|
|
245641
245584
|
init_ora();
|
|
245642
245585
|
init_boxen();
|
|
245643
|
-
|
|
245644
|
-
|
|
245586
|
+
import_fs17 = require("fs");
|
|
245587
|
+
import_path11 = require("path");
|
|
245645
245588
|
import_child_process5 = require("child_process");
|
|
245646
245589
|
init_create();
|
|
245647
245590
|
init_test_chat();
|
|
245648
245591
|
init_llm_direct();
|
|
245649
245592
|
init_paths();
|
|
245650
245593
|
ensureHomeDirExists();
|
|
245651
|
-
_legacyEnv = (0, import_path14.resolve)(process.env.INIT_CWD ?? process.cwd(), ".env");
|
|
245652
|
-
ROOT_DIR4 = (0, import_fs20.existsSync)(_legacyEnv) ? process.env.INIT_CWD ?? process.cwd() : OPENCRUSH_HOME;
|
|
245653
245594
|
}
|
|
245654
245595
|
});
|
|
245655
245596
|
|
|
@@ -245660,7 +245601,7 @@ __export(card_exports, {
|
|
|
245660
245601
|
});
|
|
245661
245602
|
function parseIdentity(identityPath) {
|
|
245662
245603
|
var _a3, _b2, _c, _d;
|
|
245663
|
-
const raw = (0,
|
|
245604
|
+
const raw = (0, import_fs18.readFileSync)(identityPath, "utf-8");
|
|
245664
245605
|
const { content } = (0, import_gray_matter2.default)(raw);
|
|
245665
245606
|
const nameMatch = content.match(/^#\s+(.+)$/m);
|
|
245666
245607
|
const name = ((_a3 = nameMatch == null ? void 0 : nameMatch[1]) == null ? void 0 : _a3.trim()) ?? "Unknown";
|
|
@@ -245762,17 +245703,13 @@ function truncate(str2, max) {
|
|
|
245762
245703
|
}
|
|
245763
245704
|
async function generateCard(characterName) {
|
|
245764
245705
|
const sharp = (await import("sharp")).default;
|
|
245765
|
-
const {
|
|
245766
|
-
const
|
|
245767
|
-
|
|
245768
|
-
const _legacyCard = _resolveCard(process.env.INIT_CWD ?? process.cwd(), ".env");
|
|
245769
|
-
const rootDir = _existsCard(_legacyCard) ? process.env.INIT_CWD ?? process.cwd() : _home;
|
|
245770
|
-
const charDir = (0, import_path15.join)(rootDir, "characters", characterName);
|
|
245771
|
-
if (!(0, import_fs21.existsSync)(charDir)) {
|
|
245706
|
+
const { ROOT_DIR: ROOT_DIR2 } = await Promise.resolve().then(() => (init_paths(), paths_exports));
|
|
245707
|
+
const charDir = (0, import_path12.join)(ROOT_DIR2, "characters", characterName);
|
|
245708
|
+
if (!(0, import_fs18.existsSync)(charDir)) {
|
|
245772
245709
|
throw new Error(`Character "${characterName}" not found in characters/`);
|
|
245773
245710
|
}
|
|
245774
|
-
const identityPath = (0,
|
|
245775
|
-
if (!(0,
|
|
245711
|
+
const identityPath = (0, import_path12.join)(charDir, "IDENTITY.md");
|
|
245712
|
+
if (!(0, import_fs18.existsSync)(identityPath)) {
|
|
245776
245713
|
throw new Error(`Missing IDENTITY.md for character "${characterName}"`);
|
|
245777
245714
|
}
|
|
245778
245715
|
const data = parseIdentity(identityPath);
|
|
@@ -245780,8 +245717,8 @@ async function generateCard(characterName) {
|
|
|
245780
245717
|
const imageExts = [".jpeg", ".jpg", ".png", ".webp"];
|
|
245781
245718
|
let refImagePath;
|
|
245782
245719
|
for (const ext of imageExts) {
|
|
245783
|
-
const p2 = (0,
|
|
245784
|
-
if ((0,
|
|
245720
|
+
const p2 = (0, import_path12.join)(charDir, `reference${ext}`);
|
|
245721
|
+
if ((0, import_fs18.existsSync)(p2)) {
|
|
245785
245722
|
refImagePath = p2;
|
|
245786
245723
|
break;
|
|
245787
245724
|
}
|
|
@@ -245804,7 +245741,7 @@ async function generateCard(characterName) {
|
|
|
245804
245741
|
}
|
|
245805
245742
|
]);
|
|
245806
245743
|
}
|
|
245807
|
-
const outputPath = (0,
|
|
245744
|
+
const outputPath = (0, import_path12.join)(charDir, "card.png");
|
|
245808
245745
|
await card.png().toFile(outputPath);
|
|
245809
245746
|
console.log(source_default.green(`
|
|
245810
245747
|
Card generated: characters/${characterName}/card.png`));
|
|
@@ -245812,11 +245749,11 @@ async function generateCard(characterName) {
|
|
|
245812
245749
|
`));
|
|
245813
245750
|
return outputPath;
|
|
245814
245751
|
}
|
|
245815
|
-
var
|
|
245752
|
+
var import_fs18, import_path12, import_gray_matter2, WIDTH, HEIGHT, PORTRAIT_SIZE, PORTRAIT_X, PORTRAIT_Y;
|
|
245816
245753
|
var init_card = __esm({
|
|
245817
245754
|
"src/card.ts"() {
|
|
245818
|
-
|
|
245819
|
-
|
|
245755
|
+
import_fs18 = require("fs");
|
|
245756
|
+
import_path12 = require("path");
|
|
245820
245757
|
import_gray_matter2 = __toESM(require_gray_matter());
|
|
245821
245758
|
init_source();
|
|
245822
245759
|
WIDTH = 1200;
|
|
@@ -245833,19 +245770,15 @@ __export(export_import_exports, {
|
|
|
245833
245770
|
exportCharacter: () => exportCharacter,
|
|
245834
245771
|
importCharacter: () => importCharacter
|
|
245835
245772
|
});
|
|
245836
|
-
function getRootDir() {
|
|
245837
|
-
const legacyEnv2 = require("path").resolve(process.env.INIT_CWD ?? process.cwd(), ".env");
|
|
245838
|
-
return require("fs").existsSync(legacyEnv2) ? process.env.INIT_CWD ?? process.cwd() : OPENCRUSH_HOME;
|
|
245839
|
-
}
|
|
245840
245773
|
async function exportCharacter(characterName) {
|
|
245841
|
-
const rootDir =
|
|
245842
|
-
const charDir = (0,
|
|
245843
|
-
if (!(0,
|
|
245774
|
+
const rootDir = ROOT_DIR;
|
|
245775
|
+
const charDir = (0, import_path13.join)(rootDir, "characters", characterName);
|
|
245776
|
+
if (!(0, import_fs19.existsSync)(charDir)) {
|
|
245844
245777
|
throw new Error(`Character "${characterName}" not found in characters/`);
|
|
245845
245778
|
}
|
|
245846
245779
|
const outputFile = `${characterName}.opencrush.tar.gz`;
|
|
245847
|
-
const outputPath = (0,
|
|
245848
|
-
(0, import_child_process6.execSync)(`tar -czf "${outputPath}" -C "${(0,
|
|
245780
|
+
const outputPath = (0, import_path13.join)(rootDir, outputFile);
|
|
245781
|
+
(0, import_child_process6.execSync)(`tar -czf "${outputPath}" -C "${(0, import_path13.join)(rootDir, "characters")}" "${characterName}"`, {
|
|
245849
245782
|
stdio: "pipe"
|
|
245850
245783
|
});
|
|
245851
245784
|
console.log(source_default.green(`
|
|
@@ -245855,14 +245788,14 @@ async function exportCharacter(characterName) {
|
|
|
245855
245788
|
return outputPath;
|
|
245856
245789
|
}
|
|
245857
245790
|
async function importCharacter(source) {
|
|
245858
|
-
const rootDir =
|
|
245859
|
-
const charactersDir = (0,
|
|
245860
|
-
(0,
|
|
245791
|
+
const rootDir = ROOT_DIR;
|
|
245792
|
+
const charactersDir = (0, import_path13.join)(rootDir, "characters");
|
|
245793
|
+
(0, import_fs19.mkdirSync)(charactersDir, { recursive: true });
|
|
245861
245794
|
let tarPath;
|
|
245862
245795
|
let isTemp = false;
|
|
245863
245796
|
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
245864
245797
|
console.log(source_default.gray(` Downloading from ${source}...`));
|
|
245865
|
-
tarPath = (0,
|
|
245798
|
+
tarPath = (0, import_path13.join)(rootDir, `_import_temp_${Date.now()}.tar.gz`);
|
|
245866
245799
|
isTemp = true;
|
|
245867
245800
|
const response = await fetch(source);
|
|
245868
245801
|
if (!response.ok) {
|
|
@@ -245874,31 +245807,31 @@ async function importCharacter(source) {
|
|
|
245874
245807
|
writeFileSync7(tarPath, buffer);
|
|
245875
245808
|
} else {
|
|
245876
245809
|
tarPath = source;
|
|
245877
|
-
if (!(0,
|
|
245810
|
+
if (!(0, import_fs19.existsSync)(tarPath)) {
|
|
245878
245811
|
throw new Error(`File not found: ${tarPath}`);
|
|
245879
245812
|
}
|
|
245880
245813
|
}
|
|
245881
245814
|
if (!tarPath.endsWith(".opencrush.tar.gz") && !tarPath.endsWith(".tar.gz")) {
|
|
245882
|
-
if (isTemp) (0,
|
|
245815
|
+
if (isTemp) (0, import_fs19.unlinkSync)(tarPath);
|
|
245883
245816
|
throw new Error("File must be a .opencrush.tar.gz or .tar.gz archive");
|
|
245884
245817
|
}
|
|
245885
245818
|
const listing = (0, import_child_process6.execSync)(`tar -tzf "${tarPath}"`, { encoding: "utf-8" });
|
|
245886
245819
|
const firstEntry = listing.split("\n")[0];
|
|
245887
245820
|
const characterName = firstEntry.split("/")[0];
|
|
245888
245821
|
if (!characterName) {
|
|
245889
|
-
if (isTemp) (0,
|
|
245822
|
+
if (isTemp) (0, import_fs19.unlinkSync)(tarPath);
|
|
245890
245823
|
throw new Error("Could not determine character name from archive");
|
|
245891
245824
|
}
|
|
245892
|
-
const destDir = (0,
|
|
245893
|
-
if ((0,
|
|
245894
|
-
if (isTemp) (0,
|
|
245825
|
+
const destDir = (0, import_path13.join)(charactersDir, characterName);
|
|
245826
|
+
if ((0, import_fs19.existsSync)(destDir)) {
|
|
245827
|
+
if (isTemp) (0, import_fs19.unlinkSync)(tarPath);
|
|
245895
245828
|
throw new Error(
|
|
245896
245829
|
`Character "${characterName}" already exists. Remove characters/${characterName}/ first.`
|
|
245897
245830
|
);
|
|
245898
245831
|
}
|
|
245899
245832
|
(0, import_child_process6.execSync)(`tar -xzf "${tarPath}" -C "${charactersDir}"`, { stdio: "pipe" });
|
|
245900
245833
|
if (isTemp) {
|
|
245901
|
-
(0,
|
|
245834
|
+
(0, import_fs19.unlinkSync)(tarPath);
|
|
245902
245835
|
}
|
|
245903
245836
|
console.log(source_default.green(`
|
|
245904
245837
|
Imported: ${characterName}`));
|
|
@@ -245906,11 +245839,11 @@ async function importCharacter(source) {
|
|
|
245906
245839
|
`));
|
|
245907
245840
|
return characterName;
|
|
245908
245841
|
}
|
|
245909
|
-
var
|
|
245842
|
+
var import_fs19, import_path13, import_child_process6;
|
|
245910
245843
|
var init_export_import = __esm({
|
|
245911
245844
|
"src/export-import.ts"() {
|
|
245912
|
-
|
|
245913
|
-
|
|
245845
|
+
import_fs19 = require("fs");
|
|
245846
|
+
import_path13 = require("path");
|
|
245914
245847
|
import_child_process6 = require("child_process");
|
|
245915
245848
|
init_source();
|
|
245916
245849
|
init_paths();
|
|
@@ -245921,12 +245854,9 @@ var init_export_import = __esm({
|
|
|
245921
245854
|
init_source();
|
|
245922
245855
|
init_paths();
|
|
245923
245856
|
var import_dotenv2 = __toESM(require_main());
|
|
245924
|
-
var
|
|
245925
|
-
|
|
245926
|
-
var _legacyCwd = (0, import_path17.resolve)(process.env.INIT_CWD ?? process.cwd(), ".env");
|
|
245927
|
-
import_dotenv2.default.config({ path: (0, import_fs23.existsSync)(_legacyCwd) ? _legacyCwd : getEnvPath() });
|
|
245857
|
+
var import_fs20 = require("fs");
|
|
245858
|
+
import_dotenv2.default.config({ path: getEnvPath() });
|
|
245928
245859
|
var [, , command] = process.argv;
|
|
245929
|
-
var HOME = OPENCRUSH_HOME;
|
|
245930
245860
|
async function main2() {
|
|
245931
245861
|
var _a3;
|
|
245932
245862
|
switch (command) {
|
|
@@ -245939,7 +245869,7 @@ async function main2() {
|
|
|
245939
245869
|
case "start":
|
|
245940
245870
|
case void 0: {
|
|
245941
245871
|
ensureHomeDirExists();
|
|
245942
|
-
if (!isConfigured()
|
|
245872
|
+
if (!isConfigured()) {
|
|
245943
245873
|
console.log(source_default.yellow("\n First run \u2014 launching setup wizard...\n"));
|
|
245944
245874
|
const { runSetupWizard: runSetupWizard2 } = await Promise.resolve().then(() => (init_setup(), setup_exports));
|
|
245945
245875
|
await runSetupWizard2();
|
|
@@ -245952,7 +245882,7 @@ async function main2() {
|
|
|
245952
245882
|
case "wakeup":
|
|
245953
245883
|
case "wake":
|
|
245954
245884
|
case "restart": {
|
|
245955
|
-
if (!isConfigured()
|
|
245885
|
+
if (!isConfigured()) {
|
|
245956
245886
|
console.log(source_default.yellow("\n No config found. Running setup first...\n"));
|
|
245957
245887
|
const { runSetupWizard: runSetupWizard2 } = await Promise.resolve().then(() => (init_setup(), setup_exports));
|
|
245958
245888
|
await runSetupWizard2();
|
|
@@ -245974,15 +245904,14 @@ async function main2() {
|
|
|
245974
245904
|
break;
|
|
245975
245905
|
}
|
|
245976
245906
|
case "status": {
|
|
245977
|
-
const { readdirSync:
|
|
245907
|
+
const { readdirSync: readdirSync2 } = await import("fs");
|
|
245978
245908
|
const { join: join11 } = await import("path");
|
|
245979
245909
|
console.log(source_default.magenta("\n \u{1F49D} Opencrush Status\n"));
|
|
245980
|
-
|
|
245981
|
-
console.log(`
|
|
245982
|
-
console.log(` Home: ${source_default.gray(HOME)}`);
|
|
245910
|
+
console.log(` Config: ${isConfigured() ? source_default.green("\u2713 configured") : source_default.red("\u2717 Not configured \u2014 run: npx opencrush@latest setup")}`);
|
|
245911
|
+
console.log(` Root: ${source_default.gray(ROOT_DIR)}`);
|
|
245983
245912
|
const charactersDir = getCharactersDir();
|
|
245984
|
-
if ((0,
|
|
245985
|
-
const chars =
|
|
245913
|
+
if ((0, import_fs20.existsSync)(charactersDir)) {
|
|
245914
|
+
const chars = readdirSync2(charactersDir, { withFileTypes: true }).filter((d2) => d2.isDirectory()).map((d2) => d2.name);
|
|
245986
245915
|
console.log(` Characters: ${chars.map((c2) => source_default.cyan(c2)).join(", ") || source_default.gray("none")}`);
|
|
245987
245916
|
}
|
|
245988
245917
|
const activeChar = process.env.CHARACTER_NAME;
|
|
@@ -246173,7 +246102,7 @@ async function main2() {
|
|
|
246173
246102
|
console.log(source_default.gray(" Relationship stats, episodes, and MEMORY.md will be preserved.\n"));
|
|
246174
246103
|
const readline4 = await import("readline");
|
|
246175
246104
|
const rl = readline4.createInterface({ input: process.stdin, output: process.stdout });
|
|
246176
|
-
const answer = await new Promise((
|
|
246105
|
+
const answer = await new Promise((resolve) => rl.question(source_default.yellow(' Type "reset" to confirm: '), resolve));
|
|
246177
246106
|
rl.close();
|
|
246178
246107
|
if (answer.trim().toLowerCase() === "reset") {
|
|
246179
246108
|
const db = new Database2(dbPath);
|
|
@@ -246237,8 +246166,8 @@ async function main2() {
|
|
|
246237
246166
|
${source_default.cyan("npx opencrush@latest import <file|url>")} Import a character package
|
|
246238
246167
|
|
|
246239
246168
|
${source_default.bold("Config & Data:")}
|
|
246240
|
-
${source_default.gray(
|
|
246241
|
-
${source_default.gray(
|
|
246169
|
+
${source_default.gray(ROOT_DIR + "/.env")} Your API keys and settings
|
|
246170
|
+
${source_default.gray(ROOT_DIR + "/characters/")} Your companion's blueprint files
|
|
246242
246171
|
|
|
246243
246172
|
${source_default.bold("Documentation:")}
|
|
246244
246173
|
${source_default.gray("https://github.com/Hollandchirs/Opencrush")}
|