@wirecat/bitrix24-cli 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/LICENSE +204 -0
- package/README.md +17 -2
- package/dist/api-keys.d.ts +21 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +58 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/bin/b24.d.ts +3 -0
- package/dist/bin/b24.d.ts.map +1 -0
- package/dist/bin/b24.js +40 -0
- package/dist/bin/b24.js.map +1 -0
- package/dist/bitrix/errors.d.ts +22 -0
- package/dist/bitrix/errors.d.ts.map +1 -0
- package/dist/bitrix/errors.js +76 -0
- package/dist/bitrix/errors.js.map +1 -0
- package/dist/bitrix/methods.d.ts +13 -0
- package/dist/bitrix/methods.d.ts.map +1 -0
- package/dist/bitrix/methods.js +33 -0
- package/dist/bitrix/methods.js.map +1 -0
- package/dist/bitrix/transport.d.ts +50 -0
- package/dist/bitrix/transport.d.ts.map +1 -0
- package/dist/bitrix/transport.js +189 -0
- package/dist/bitrix/transport.js.map +1 -0
- package/dist/bitrix/webhook.d.ts +14 -0
- package/dist/bitrix/webhook.d.ts.map +1 -0
- package/dist/bitrix/webhook.js +29 -0
- package/dist/bitrix/webhook.js.map +1 -0
- package/dist/bundle/all-profiles-QJ444GSX.js +24 -0
- package/dist/bundle/anthropic-RHRAVHC2.js +70 -0
- package/dist/bundle/app-server-QIT6S7AZ.js +224 -0
- package/dist/bundle/b24.js +32 -0
- package/dist/bundle/bun-H6RSODZ3.js +169 -0
- package/dist/bundle/bun-sqlite-BO4LTQHX.js +69 -0
- package/dist/bundle/chunk-2KCZ7BKW.js +215 -0
- package/dist/bundle/chunk-2SNUMZ7S.js +1028 -0
- package/dist/bundle/chunk-45AKJVKV.js +24 -0
- package/dist/bundle/chunk-4PDYYS5K.js +2 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-6WY72XVQ.js +216 -0
- package/dist/bundle/chunk-7GRZAKBB.js +639 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-BCF7P4FZ.js +558 -0
- package/dist/bundle/chunk-CNNEA2M4.js +54 -0
- package/dist/bundle/chunk-CXL33BFL.js +570 -0
- package/dist/bundle/chunk-D5S6QV6R.js +95 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DTXERR44.js +35 -0
- package/dist/bundle/chunk-EVYSBZ3I.js +153 -0
- package/dist/bundle/chunk-EXOOKUEA.js +82 -0
- package/dist/bundle/chunk-FLUEXJ4X.js +53 -0
- package/dist/bundle/chunk-FOTREPNS.js +366 -0
- package/dist/bundle/chunk-FZL7F5NR.js +2022 -0
- package/dist/bundle/chunk-GDFNH33E.js +1691 -0
- package/dist/bundle/chunk-H2ADPPSH.js +50910 -0
- package/dist/bundle/chunk-HAXNUIGQ.js +1245 -0
- package/dist/bundle/chunk-HGL63O5V.js +288 -0
- package/dist/bundle/chunk-INFYLWUA.js +929 -0
- package/dist/bundle/chunk-IRV2PCQ2.js +5213 -0
- package/dist/bundle/chunk-K3UIB6ZF.js +45 -0
- package/dist/bundle/chunk-LRGYKOCP.js +91 -0
- package/dist/bundle/chunk-LSPIOT6Z.js +459 -0
- package/dist/bundle/chunk-MBDK4YXG.js +34 -0
- package/dist/bundle/chunk-N6FLBXZS.js +73 -0
- package/dist/bundle/chunk-OTD2ZRXD.js +161 -0
- package/dist/bundle/chunk-P33NDCDI.js +78 -0
- package/dist/bundle/chunk-P364PLIK.js +257 -0
- package/dist/bundle/chunk-PH5FZX6E.js +193 -0
- package/dist/bundle/chunk-POC3V3AO.js +36616 -0
- package/dist/bundle/chunk-QC53QBNC.js +143 -0
- package/dist/bundle/chunk-QGMDQ2PM.js +122 -0
- package/dist/bundle/chunk-QIPTIUMJ.js +281 -0
- package/dist/bundle/chunk-QMPN6WKD.js +3512 -0
- package/dist/bundle/chunk-QQXH2OPB.js +594 -0
- package/dist/bundle/chunk-QSNROIJL.js +413 -0
- package/dist/bundle/chunk-RRJNNPR4.js +76 -0
- package/dist/bundle/chunk-SFRNX2TI.js +6848 -0
- package/dist/bundle/chunk-SGRYYE4X.js +266 -0
- package/dist/bundle/chunk-TE3FR6MI.js +884 -0
- package/dist/bundle/chunk-U5ACMCAQ.js +12049 -0
- package/dist/bundle/chunk-VEWWAGTD.js +2315 -0
- package/dist/bundle/chunk-VL6SPMZV.js +194 -0
- package/dist/bundle/chunk-WII44RXN.js +58 -0
- package/dist/bundle/chunk-WKRQ44EH.js +528 -0
- package/dist/bundle/chunk-WTPMJYMD.js +8308 -0
- package/dist/bundle/chunk-XD4FRDSL.js +565 -0
- package/dist/bundle/chunk-XJXONOB5.js +63 -0
- package/dist/bundle/chunk-XNHSPHUN.js +48 -0
- package/dist/bundle/chunk-XRFJWHY5.js +131 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YYO7D2MO.js +783 -0
- package/dist/bundle/chunk-YZ5LHE5Q.js +31 -0
- package/dist/bundle/chunk-ZDQQCXFG.js +392 -0
- package/dist/bundle/chunk-ZEW4P6AH.js +158 -0
- package/dist/bundle/chunk-ZGZT5S6B.js +3480 -0
- package/dist/bundle/chunk-ZIAQPTUS.js +82 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-OKQOE6G4.js +30 -0
- package/dist/bundle/decode-5ZPLTYV6.js +160 -0
- package/dist/bundle/dist-6Y64DTOE.js +7577 -0
- package/dist/bundle/echarts-J6LAPIX7.js +42501 -0
- package/dist/bundle/embed-YG5LDHME.js +35 -0
- package/dist/bundle/embedder-7FNUA5OZ.js +108 -0
- package/dist/bundle/first-run-JPZNWIJN.js +23 -0
- package/dist/bundle/first-screen-VQM4MTS7.js +28 -0
- package/dist/bundle/instructions-AXWTQHMR.js +11 -0
- package/dist/bundle/mcp-7F46P6AM.js +165 -0
- package/dist/bundle/mcp-HUD6UH5X.js +160 -0
- package/dist/bundle/mcp-J5R5A65I.js +87 -0
- package/dist/bundle/node-CWKAIOEM.js +176 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-LSEKVRDA.js +67 -0
- package/dist/bundle/oauth-THYNLRLD.js +17 -0
- package/dist/bundle/open-E47QYKFC.js +20 -0
- package/dist/bundle/openai-EWSGC3BC.js +227 -0
- package/dist/bundle/process-WKTEA3WE.js +91 -0
- package/dist/bundle/program-UYX5362I.js +20851 -0
- package/dist/bundle/prompt-CAQ7QR3U.js +12 -0
- package/dist/bundle/recognize-6KGHNZC3.js +23 -0
- package/dist/bundle/remote-3UO2WDC3.js +26 -0
- package/dist/bundle/rerank-2JVDPZBX.js +49 -0
- package/dist/bundle/serve-ES7AG5IK.js +19 -0
- package/dist/bundle/server-5LE5LNUQ.js +45 -0
- package/dist/bundle/server-BU4VBM6S.js +58 -0
- package/dist/bundle/state-7NH5G4XJ.js +33 -0
- package/dist/bundle/store-7O4JQD2Z.js +127 -0
- package/dist/bundle/store-maintenance-command-UDVGEY2D.js +47 -0
- package/dist/commands/api.d.ts +3 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +131 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/crm-writes.d.ts +4 -0
- package/dist/commands/crm-writes.d.ts.map +1 -0
- package/dist/commands/crm-writes.js +182 -0
- package/dist/commands/crm-writes.js.map +1 -0
- package/dist/commands/crm.d.ts +3 -0
- package/dist/commands/crm.d.ts.map +1 -0
- package/dist/commands/crm.js +144 -0
- package/dist/commands/crm.js.map +1 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +74 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +97 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +101 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/write.d.ts +21 -0
- package/dist/commands/write.d.ts.map +1 -0
- package/dist/commands/write.js +47 -0
- package/dist/commands/write.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -0
- package/dist/crm/conditions.d.ts +25 -0
- package/dist/crm/conditions.d.ts.map +1 -0
- package/dist/crm/conditions.js +78 -0
- package/dist/crm/conditions.js.map +1 -0
- package/dist/crm/deal.d.ts +27 -0
- package/dist/crm/deal.d.ts.map +1 -0
- package/dist/crm/deal.js +74 -0
- package/dist/crm/deal.js.map +1 -0
- package/dist/crm/items.d.ts +30 -0
- package/dist/crm/items.d.ts.map +1 -0
- package/dist/crm/items.js +76 -0
- package/dist/crm/items.js.map +1 -0
- package/dist/crm/lead.d.ts +36 -0
- package/dist/crm/lead.d.ts.map +1 -0
- package/dist/crm/lead.js +85 -0
- package/dist/crm/lead.js.map +1 -0
- package/dist/crm/organization.d.ts +32 -0
- package/dist/crm/organization.d.ts.map +1 -0
- package/dist/crm/organization.js +67 -0
- package/dist/crm/organization.js.map +1 -0
- package/dist/crm/person.d.ts +31 -0
- package/dist/crm/person.d.ts.map +1 -0
- package/dist/crm/person.js +67 -0
- package/dist/crm/person.js.map +1 -0
- package/dist/crm/pipeline.d.ts +17 -0
- package/dist/crm/pipeline.d.ts.map +1 -0
- package/dist/crm/pipeline.js +42 -0
- package/dist/crm/pipeline.js.map +1 -0
- package/dist/crm/product.d.ts +43 -0
- package/dist/crm/product.d.ts.map +1 -0
- package/dist/crm/product.js +42 -0
- package/dist/crm/product.js.map +1 -0
- package/dist/crm/stage.d.ts +20 -0
- package/dist/crm/stage.d.ts.map +1 -0
- package/dist/crm/stage.js +65 -0
- package/dist/crm/stage.js.map +1 -0
- package/dist/crm/user.d.ts +39 -0
- package/dist/crm/user.d.ts.map +1 -0
- package/dist/crm/user.js +54 -0
- package/dist/crm/user.js.map +1 -0
- package/dist/crm/values.d.ts +33 -0
- package/dist/crm/values.d.ts.map +1 -0
- package/dist/crm/values.js +54 -0
- package/dist/crm/values.js.map +1 -0
- package/dist/crm/walk.d.ts +19 -0
- package/dist/crm/walk.d.ts.map +1 -0
- package/dist/crm/walk.js +22 -0
- package/dist/crm/walk.js.map +1 -0
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +18 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +29 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +99 -0
- package/dist/mcp.js.map +1 -0
- package/dist/portal.d.ts +47 -0
- package/dist/portal.d.ts.map +1 -0
- package/dist/portal.js +52 -0
- package/dist/portal.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +45 -0
- package/dist/program.js.map +1 -0
- package/dist/reasons.d.ts +10 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +28 -0
- package/dist/reasons.js.map +1 -0
- package/dist/token.d.ts +12 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +41 -0
- package/dist/token.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/whoami.d.ts +8 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +9 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +83 -4
- package/skills/bitrix24-cli/SKILL.md +41 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
MAX_SECRET_INPUT,
|
|
5
|
+
bufferedInput,
|
|
6
|
+
inputPolicy
|
|
7
|
+
} from "./chunk-EXOOKUEA.js";
|
|
8
|
+
import {
|
|
9
|
+
CliError
|
|
10
|
+
} from "./chunk-IRV2PCQ2.js";
|
|
11
|
+
import {
|
|
12
|
+
__name
|
|
13
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/terminal/prompt.js
|
|
16
|
+
import { createInterface } from "node:readline";
|
|
17
|
+
import { Writable } from "node:stream";
|
|
18
|
+
var readSecret = /* @__PURE__ */ __name(async (prompt, { input = process.stdin, output = process.stderr, echo = false, signal: givenSignal } = {}) => {
|
|
19
|
+
const policy = inputPolicy(input);
|
|
20
|
+
const signals = [givenSignal, policy.signal].filter((one) => one !== void 0);
|
|
21
|
+
const signal = signals.length ? AbortSignal.any(signals) : void 0;
|
|
22
|
+
const cancelled = /* @__PURE__ */ __name(() => new CliError("cancelled", "cancelled \u2014 nothing was stored"), "cancelled");
|
|
23
|
+
if (signal?.aborted)
|
|
24
|
+
throw cancelled();
|
|
25
|
+
if (input.isTTY && policy.noInput)
|
|
26
|
+
throw new CliError("validation_error", "interactive input is disabled \u2014 provide the input through a pipe", {
|
|
27
|
+
reason: "input.required"
|
|
28
|
+
});
|
|
29
|
+
if (!input.isTTY) {
|
|
30
|
+
return (await bufferedInput(input, {
|
|
31
|
+
maxBytes: Math.min(policy.maxBytes ?? MAX_SECRET_INPUT, MAX_SECRET_INPUT),
|
|
32
|
+
...signal ? { signal } : {}
|
|
33
|
+
})).toString("utf8").trim();
|
|
34
|
+
}
|
|
35
|
+
let muted = false;
|
|
36
|
+
const shim = new Writable({
|
|
37
|
+
write(chunk, _encoding, done) {
|
|
38
|
+
if (!muted)
|
|
39
|
+
output.write(chunk);
|
|
40
|
+
done();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const reader = createInterface({ input, output: shim, terminal: true });
|
|
44
|
+
const abort = /* @__PURE__ */ __name(() => reader.close(), "abort");
|
|
45
|
+
let bytes = 0;
|
|
46
|
+
let inputFailure;
|
|
47
|
+
const data = /* @__PURE__ */ __name((chunk) => {
|
|
48
|
+
bytes += Buffer.byteLength(chunk);
|
|
49
|
+
if (bytes > Math.min(policy.maxBytes ?? MAX_SECRET_INPUT, MAX_SECRET_INPUT)) {
|
|
50
|
+
inputFailure = new CliError("validation_error", "secret input exceeds its byte limit", {
|
|
51
|
+
reason: "input.too-large",
|
|
52
|
+
retryable: false
|
|
53
|
+
});
|
|
54
|
+
reader.close();
|
|
55
|
+
}
|
|
56
|
+
}, "data");
|
|
57
|
+
const inputError = /* @__PURE__ */ __name((error) => {
|
|
58
|
+
inputFailure = error;
|
|
59
|
+
reader.close();
|
|
60
|
+
}, "inputError");
|
|
61
|
+
input.on("data", data).on("error", inputError);
|
|
62
|
+
try {
|
|
63
|
+
const answer = await new Promise((resolve, reject) => {
|
|
64
|
+
const cancel = /* @__PURE__ */ __name(() => reject(inputFailure ?? cancelled()), "cancel");
|
|
65
|
+
reader.once("SIGINT", cancel);
|
|
66
|
+
reader.once("close", cancel);
|
|
67
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
68
|
+
reader.question(prompt, resolve);
|
|
69
|
+
muted = !echo;
|
|
70
|
+
});
|
|
71
|
+
return answer.trim();
|
|
72
|
+
} finally {
|
|
73
|
+
input.off("data", data).off("error", inputError);
|
|
74
|
+
signal?.removeEventListener("abort", abort);
|
|
75
|
+
reader.close();
|
|
76
|
+
output.write("\n");
|
|
77
|
+
}
|
|
78
|
+
}, "readSecret");
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
readSecret
|
|
82
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
}) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
+
});
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
try {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw mod = 0, e;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
36
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
37
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
38
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
39
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
40
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
41
|
+
mod
|
|
42
|
+
));
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
__name,
|
|
46
|
+
__require,
|
|
47
|
+
__commonJS,
|
|
48
|
+
__export,
|
|
49
|
+
__toESM
|
|
50
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
SCHEMA_DIALECT,
|
|
5
|
+
commandContract,
|
|
6
|
+
commandPathOf,
|
|
7
|
+
findCommand,
|
|
8
|
+
outputOf
|
|
9
|
+
} from "./chunk-XRFJWHY5.js";
|
|
10
|
+
import "./chunk-U5ACMCAQ.js";
|
|
11
|
+
import "./chunk-FOTREPNS.js";
|
|
12
|
+
import "./chunk-CNNEA2M4.js";
|
|
13
|
+
import "./chunk-XJXONOB5.js";
|
|
14
|
+
import "./chunk-SGRYYE4X.js";
|
|
15
|
+
import "./chunk-XD4FRDSL.js";
|
|
16
|
+
import "./chunk-P364PLIK.js";
|
|
17
|
+
import "./chunk-TE3FR6MI.js";
|
|
18
|
+
import "./chunk-DTXERR44.js";
|
|
19
|
+
import "./chunk-ZGZT5S6B.js";
|
|
20
|
+
import "./chunk-LRGYKOCP.js";
|
|
21
|
+
import "./chunk-IRV2PCQ2.js";
|
|
22
|
+
import "./chunk-Y5E2WNWB.js";
|
|
23
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
24
|
+
export {
|
|
25
|
+
SCHEMA_DIALECT,
|
|
26
|
+
commandContract,
|
|
27
|
+
commandPathOf,
|
|
28
|
+
findCommand,
|
|
29
|
+
outputOf
|
|
30
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
SAMPLE_RATE,
|
|
5
|
+
decodeOgg
|
|
6
|
+
} from "./chunk-6WY72XVQ.js";
|
|
7
|
+
import {
|
|
8
|
+
CliError
|
|
9
|
+
} from "./chunk-IRV2PCQ2.js";
|
|
10
|
+
import {
|
|
11
|
+
importFrom
|
|
12
|
+
} from "./chunk-Y5E2WNWB.js";
|
|
13
|
+
import {
|
|
14
|
+
__name
|
|
15
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
16
|
+
|
|
17
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/speech/decode.js
|
|
18
|
+
import { spawn } from "node:child_process";
|
|
19
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
20
|
+
import { createRequire } from "node:module";
|
|
21
|
+
import { tmpdir } from "node:os";
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
import { pathToFileURL } from "node:url";
|
|
24
|
+
var LONGEST_AUDIO_SECONDS = 3600;
|
|
25
|
+
var FFMPEG_TIMEOUT_MS = 12e4;
|
|
26
|
+
var FFMPEG_FORMATS = "mov,mp4,m4a,3gp,3g2,mj2,aac,mp3,wav,amr,caf,aiff,flac,ogg,matroska,webm,asf";
|
|
27
|
+
var text = /* @__PURE__ */ __name((bytes, from, length) => String.fromCharCode(...bytes.subarray(from, from + length)), "text");
|
|
28
|
+
var contains = /* @__PURE__ */ __name((bytes, needle, within) => Buffer.from(bytes.buffer, bytes.byteOffset, Math.min(bytes.length, within)).includes(needle, 0, "latin1"), "contains");
|
|
29
|
+
var formatOf = /* @__PURE__ */ __name((bytes) => {
|
|
30
|
+
if (text(bytes, 0, 4) === "OggS") {
|
|
31
|
+
if (contains(bytes, "OpusHead", 128))
|
|
32
|
+
return "opus";
|
|
33
|
+
if (contains(bytes, "vorbis", 128))
|
|
34
|
+
return "vorbis";
|
|
35
|
+
return "other";
|
|
36
|
+
}
|
|
37
|
+
if (text(bytes, 0, 4) === "fLaC")
|
|
38
|
+
return "flac";
|
|
39
|
+
const frame = bytes[0] === 255 && ((bytes[1] ?? 0) & 224) === 224 && ((bytes[1] ?? 0) >> 1 & 3) !== 0;
|
|
40
|
+
if (text(bytes, 0, 3) === "ID3" || frame)
|
|
41
|
+
return "mp3";
|
|
42
|
+
return "other";
|
|
43
|
+
}, "formatOf");
|
|
44
|
+
var everyChannel = /* @__PURE__ */ __name((decoded) => {
|
|
45
|
+
if (!decoded.channelData[0] || decoded.samplesDecoded === 0)
|
|
46
|
+
throw new CliError("validation_error", "no audio in that file");
|
|
47
|
+
return decoded.channelData.map((samples) => ({ samples, rate: decoded.sampleRate }));
|
|
48
|
+
}, "everyChannel");
|
|
49
|
+
var load = /* @__PURE__ */ __name((name) => importFrom(new URL("speech/decode.js", import.meta.resolve("@wirecat/cli-core")).href, pathToFileURL(createRequire(new URL("speech/decode.js", import.meta.resolve("@wirecat/cli-core")).href).resolve(name)).href), "load");
|
|
50
|
+
var decodeVorbis = /* @__PURE__ */ __name(async (bytes) => {
|
|
51
|
+
const { OggVorbisDecoder } = await load("@wasm-audio-decoders/ogg-vorbis");
|
|
52
|
+
const decoder = new OggVorbisDecoder();
|
|
53
|
+
await decoder.ready;
|
|
54
|
+
try {
|
|
55
|
+
return everyChannel(await decoder.decodeFile(bytes));
|
|
56
|
+
} finally {
|
|
57
|
+
decoder.free();
|
|
58
|
+
}
|
|
59
|
+
}, "decodeVorbis");
|
|
60
|
+
var decodeFlac = /* @__PURE__ */ __name(async (bytes) => {
|
|
61
|
+
const { FLACDecoder } = await load("@wasm-audio-decoders/flac");
|
|
62
|
+
const decoder = new FLACDecoder();
|
|
63
|
+
await decoder.ready;
|
|
64
|
+
try {
|
|
65
|
+
return everyChannel(await decoder.decodeFile(bytes));
|
|
66
|
+
} finally {
|
|
67
|
+
decoder.free();
|
|
68
|
+
}
|
|
69
|
+
}, "decodeFlac");
|
|
70
|
+
var decodeMp3 = /* @__PURE__ */ __name(async (bytes) => {
|
|
71
|
+
const { MPEGDecoder } = await load("mpg123-decoder");
|
|
72
|
+
const decoder = new MPEGDecoder();
|
|
73
|
+
await decoder.ready;
|
|
74
|
+
try {
|
|
75
|
+
return everyChannel(decoder.decode(bytes));
|
|
76
|
+
} finally {
|
|
77
|
+
decoder.free();
|
|
78
|
+
}
|
|
79
|
+
}, "decodeMp3");
|
|
80
|
+
var runFfmpeg = /* @__PURE__ */ __name(async (bytes) => {
|
|
81
|
+
const directory = await mkdtemp(join(tmpdir(), "wirecat-audio-"));
|
|
82
|
+
try {
|
|
83
|
+
const input = join(directory, "audio");
|
|
84
|
+
await writeFile(input, bytes, { mode: 384 });
|
|
85
|
+
const largest = LONGEST_AUDIO_SECONDS * SAMPLE_RATE * 4;
|
|
86
|
+
const output = await new Promise((resolve, reject) => {
|
|
87
|
+
const child = spawn("ffmpeg", [
|
|
88
|
+
"-nostdin",
|
|
89
|
+
"-hide_banner",
|
|
90
|
+
"-loglevel",
|
|
91
|
+
"error",
|
|
92
|
+
"-protocol_whitelist",
|
|
93
|
+
"file",
|
|
94
|
+
"-format_whitelist",
|
|
95
|
+
FFMPEG_FORMATS,
|
|
96
|
+
"-i",
|
|
97
|
+
input,
|
|
98
|
+
"-vn",
|
|
99
|
+
"-ac",
|
|
100
|
+
"1",
|
|
101
|
+
"-ar",
|
|
102
|
+
String(SAMPLE_RATE),
|
|
103
|
+
"-f",
|
|
104
|
+
"f32le",
|
|
105
|
+
"pipe:1"
|
|
106
|
+
], { stdio: ["ignore", "pipe", "pipe"], timeout: FFMPEG_TIMEOUT_MS });
|
|
107
|
+
const chunks = [];
|
|
108
|
+
let size = 0;
|
|
109
|
+
let errors = "";
|
|
110
|
+
child.stdout.on("data", (chunk) => {
|
|
111
|
+
size += chunk.length;
|
|
112
|
+
if (size > largest)
|
|
113
|
+
child.kill();
|
|
114
|
+
else
|
|
115
|
+
chunks.push(chunk);
|
|
116
|
+
});
|
|
117
|
+
child.stderr.on("data", (chunk) => {
|
|
118
|
+
errors = (errors + chunk.toString()).slice(-500);
|
|
119
|
+
});
|
|
120
|
+
child.on("error", (error) => reject(error.code === "ENOENT" ? new CliError("validation_error", "only ffmpeg reads this audio format, and ffmpeg is not installed") : error));
|
|
121
|
+
child.on("close", (code) => {
|
|
122
|
+
if (size > largest)
|
|
123
|
+
reject(new CliError("validation_error", `the audio is longer than ${LONGEST_AUDIO_SECONDS / 60} minutes`));
|
|
124
|
+
else if (code === 0)
|
|
125
|
+
resolve(Buffer.concat(chunks));
|
|
126
|
+
else
|
|
127
|
+
reject(new CliError("validation_error", `ffmpeg could not read the audio: ${errors.trim() || code}`));
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
const samples = new Float32Array(Math.floor(output.length / 4));
|
|
131
|
+
Buffer.from(samples.buffer).set(output.subarray(0, samples.length * 4));
|
|
132
|
+
return { samples, rate: SAMPLE_RATE };
|
|
133
|
+
} finally {
|
|
134
|
+
await rm(directory, { recursive: true, force: true });
|
|
135
|
+
}
|
|
136
|
+
}, "runFfmpeg");
|
|
137
|
+
var BUNDLED = {
|
|
138
|
+
opus: decodeOgg,
|
|
139
|
+
vorbis: decodeVorbis,
|
|
140
|
+
flac: decodeFlac,
|
|
141
|
+
mp3: decodeMp3
|
|
142
|
+
};
|
|
143
|
+
var tooLong = /* @__PURE__ */ __name((pcm) => pcm.samples.length / pcm.rate > LONGEST_AUDIO_SECONDS, "tooLong");
|
|
144
|
+
var decodeChannels = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => {
|
|
145
|
+
const format = formatOf(bytes);
|
|
146
|
+
const decoded = format === "other" ? { channels: [await ffmpeg(bytes)], mixed: true } : await BUNDLED[format](bytes).then((channels) => ({ channels, mixed: false }), (error) => ffmpeg(bytes).then((pcm) => ({ channels: [pcm], mixed: true }), () => {
|
|
147
|
+
throw error;
|
|
148
|
+
}));
|
|
149
|
+
if (decoded.channels.some(tooLong))
|
|
150
|
+
throw new CliError("validation_error", `the audio is longer than ${LONGEST_AUDIO_SECONDS / 60} minutes`);
|
|
151
|
+
return decoded;
|
|
152
|
+
}, "decodeChannels");
|
|
153
|
+
var decodeAudio = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => (await decodeChannels(bytes, ffmpeg)).channels[0], "decodeAudio");
|
|
154
|
+
export {
|
|
155
|
+
LONGEST_AUDIO_SECONDS,
|
|
156
|
+
decodeAudio,
|
|
157
|
+
decodeChannels,
|
|
158
|
+
formatOf,
|
|
159
|
+
runFfmpeg
|
|
160
|
+
};
|