@wirecat/notion-cli 0.0.0-stage → 0.1.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 +33 -0
- package/LICENSE +204 -0
- package/README.md +36 -2
- package/contracts/wirecat.json +1315 -0
- package/dist/bin/notion.d.ts +3 -0
- package/dist/bin/notion.d.ts.map +1 -0
- package/dist/bin/notion.js +40 -0
- package/dist/bin/notion.js.map +1 -0
- package/dist/bundle/all-profiles-OETMCOLN.js +278 -0
- package/dist/bundle/anthropic-5Y3O2TYM.js +91 -0
- package/dist/bundle/app-server-IVWBIVHC.js +231 -0
- package/dist/bundle/bun-EO636SAD.js +169 -0
- package/dist/bundle/bun-sqlite-C2T7QJ2M.js +76 -0
- package/dist/bundle/chunk-24FAYAML.js +52 -0
- package/dist/bundle/chunk-2YR3RYT4.js +73 -0
- package/dist/bundle/chunk-35K5T6WV.js +24 -0
- package/dist/bundle/chunk-3D3PFXBP.js +2315 -0
- package/dist/bundle/chunk-47R43UVJ.js +1068 -0
- package/dist/bundle/chunk-4GC5DBHW.js +100 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-64D5VUZ4.js +9564 -0
- package/dist/bundle/chunk-66PL7P4C.js +23 -0
- package/dist/bundle/chunk-7FII4DCE.js +362 -0
- package/dist/bundle/chunk-7N5QB6NL.js +156 -0
- package/dist/bundle/chunk-AE2KQ37N.js +95 -0
- package/dist/bundle/chunk-AQZO3ITW.js +58 -0
- package/dist/bundle/chunk-B2WFKFYL.js +1488 -0
- package/dist/bundle/chunk-B2XKEEFX.js +230 -0
- package/dist/bundle/chunk-B4B65XIO.js +73 -0
- package/dist/bundle/chunk-BWICUW7W.js +288 -0
- package/dist/bundle/chunk-CLG2ISQH.js +206 -0
- package/dist/bundle/chunk-CWVAYQXI.js +185 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DIM5YWBU.js +53 -0
- package/dist/bundle/chunk-EGTBL3MJ.js +6848 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-EPAZ7DJB.js +783 -0
- package/dist/bundle/chunk-ESZT4WW3.js +142 -0
- package/dist/bundle/chunk-EU5WCOMQ.js +4001 -0
- package/dist/bundle/chunk-F6MLJ3V5.js +72 -0
- package/dist/bundle/chunk-FF4DDBCB.js +1028 -0
- package/dist/bundle/chunk-GA3URWIF.js +46 -0
- package/dist/bundle/chunk-HRTIRRXR.js +3112 -0
- package/dist/bundle/chunk-HWRKURQH.js +54 -0
- package/dist/bundle/chunk-IQWEJEB5.js +39724 -0
- package/dist/bundle/chunk-JK44XO2S.js +392 -0
- package/dist/bundle/chunk-JKIN5TOU.js +131 -0
- package/dist/bundle/chunk-K5TWMQSY.js +188 -0
- package/dist/bundle/chunk-KHOVVPLC.js +18 -0
- package/dist/bundle/chunk-NLDYZBTC.js +5862 -0
- package/dist/bundle/chunk-OWJDC4CB.js +217 -0
- package/dist/bundle/chunk-QBC23NHD.js +38 -0
- package/dist/bundle/chunk-QC3KOJT4.js +300 -0
- package/dist/bundle/chunk-R6ZM45NF.js +1239 -0
- package/dist/bundle/chunk-RAZKIHGH.js +76 -0
- package/dist/bundle/chunk-RDZ7SVBZ.js +731 -0
- package/dist/bundle/chunk-RLSFOR2D.js +161 -0
- package/dist/bundle/chunk-RSIS7BR7.js +2778 -0
- package/dist/bundle/chunk-ST2UC7FS.js +1324 -0
- package/dist/bundle/chunk-TR7R5DL4.js +370 -0
- package/dist/bundle/chunk-TSCIIXN3.js +106 -0
- package/dist/bundle/chunk-UWIA2G6Q.js +12737 -0
- package/dist/bundle/chunk-UWW24JQF.js +66 -0
- package/dist/bundle/chunk-WK3OSDNV.js +1197 -0
- package/dist/bundle/chunk-WM7663C2.js +1221 -0
- package/dist/bundle/chunk-WVZFXI36.js +274 -0
- package/dist/bundle/chunk-WWMB4UHF.js +78 -0
- package/dist/bundle/chunk-XC5CKHX2.js +63 -0
- package/dist/bundle/chunk-XL2HXHP3.js +82 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-XYIT2XB3.js +1372 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YA4LSSDZ.js +64499 -0
- package/dist/bundle/chunk-ZI3YTXSF.js +2 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-6G5DC2FN.js +35 -0
- package/dist/bundle/command-server-entry-A66DJ3MH.js +164 -0
- package/dist/bundle/decode-7XOFRAAT.js +163 -0
- package/dist/bundle/definitions-M3U4UYHN.js +45607 -0
- package/dist/bundle/dispatch-FEKU5UXC.js +411 -0
- package/dist/bundle/dist-YFKABFFF.js +7577 -0
- package/dist/bundle/echarts-XD2JSWU4.js +42501 -0
- package/dist/bundle/embed-F3HYGAF7.js +38 -0
- package/dist/bundle/embedder-GSEDDUH7.js +111 -0
- package/dist/bundle/failure-HDJLR2YJ.js +25 -0
- package/dist/bundle/first-run-TXNTIUSP.js +28 -0
- package/dist/bundle/first-screen-JZPJND7J.js +33 -0
- package/dist/bundle/instructions-NZGJ4FW5.js +11 -0
- package/dist/bundle/mcp-VFIOZDVY.js +167 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-RPKPDYQS.js +176 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-KH2UUYVO.js +74 -0
- package/dist/bundle/notion.js +185 -0
- package/dist/bundle/oauth-NKAI7TQD.js +20 -0
- package/dist/bundle/open-WSAEAA2V.js +23 -0
- package/dist/bundle/openai-JPVDGHG5.js +238 -0
- package/dist/bundle/process-5ZFVKOQX.js +91 -0
- package/dist/bundle/program-M3D56D6T.js +28854 -0
- package/dist/bundle/prompt-FROYQ5LV.js +17 -0
- package/dist/bundle/recognize-NYCHQMCX.js +26 -0
- package/dist/bundle/remote-4OERF3Z4.js +32 -0
- package/dist/bundle/rerank-TEGXFUWY.js +52 -0
- package/dist/bundle/schemas-MZNNOEYN.js +12214 -0
- package/dist/bundle/serve-HLYYBAXY.js +199 -0
- package/dist/bundle/server-D5OYNEUW.js +193 -0
- package/dist/bundle/server-LWZGVMNW.js +62 -0
- package/dist/bundle/sqlite-runtime-H2S5RR2F.js +20 -0
- package/dist/bundle/state-OPOXCDZL.js +36 -0
- package/dist/bundle/store-NHMXEJPD.js +164 -0
- package/dist/bundle/store-Y3KRLCJ7.js +281 -0
- package/dist/bundle/store-maintenance-command-D4W7WSLQ.js +53 -0
- package/dist/commands/api.d.ts +4 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +140 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/comments.d.ts +3 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +114 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/databases.d.ts +3 -0
- package/dist/commands/databases.d.ts.map +1 -0
- package/dist/commands/databases.js +65 -0
- package/dist/commands/databases.js.map +1 -0
- package/dist/commands/documents.d.ts +3 -0
- package/dist/commands/documents.d.ts.map +1 -0
- package/dist/commands/documents.js +41 -0
- package/dist/commands/documents.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 +104 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +46 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +58 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +45603 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +3 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +2089 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/metadata.d.ts +6 -0
- package/dist/generated/metadata.d.ts.map +1 -0
- package/dist/generated/metadata.js +24 -0
- package/dist/generated/metadata.js.map +1 -0
- package/dist/generated/schemas.d.ts +1223 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +11557 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +11120 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/identity.d.ts +7 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +29 -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/notion/client.d.ts +42 -0
- package/dist/notion/client.d.ts.map +1 -0
- package/dist/notion/client.js +118 -0
- package/dist/notion/client.js.map +1 -0
- package/dist/notion/errors.d.ts +24 -0
- package/dist/notion/errors.d.ts.map +1 -0
- package/dist/notion/errors.js +102 -0
- package/dist/notion/errors.js.map +1 -0
- package/dist/notion/ids.d.ts +7 -0
- package/dist/notion/ids.d.ts.map +1 -0
- package/dist/notion/ids.js +37 -0
- package/dist/notion/ids.js.map +1 -0
- package/dist/notion/links.d.ts +6 -0
- package/dist/notion/links.d.ts.map +1 -0
- package/dist/notion/links.js +22 -0
- package/dist/notion/links.js.map +1 -0
- package/dist/notion/notion.d.ts +95 -0
- package/dist/notion/notion.d.ts.map +1 -0
- package/dist/notion/notion.js +269 -0
- package/dist/notion/notion.js.map +1 -0
- package/dist/notion/port.d.ts +13 -0
- package/dist/notion/port.d.ts.map +1 -0
- package/dist/notion/port.js +60 -0
- package/dist/notion/port.js.map +1 -0
- package/dist/notion/read-posts.d.ts +36 -0
- package/dist/notion/read-posts.d.ts.map +1 -0
- package/dist/notion/read-posts.js +24 -0
- package/dist/notion/read-posts.js.map +1 -0
- package/dist/notion/reads.d.ts +327 -0
- package/dist/notion/reads.d.ts.map +1 -0
- package/dist/notion/reads.js +18 -0
- package/dist/notion/reads.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +62 -0
- package/dist/program.js.map +1 -0
- package/dist/sample/comments.d.ts +61 -0
- package/dist/sample/comments.d.ts.map +1 -0
- package/dist/sample/comments.js +39 -0
- package/dist/sample/comments.js.map +1 -0
- package/dist/sample/records.d.ts +16 -0
- package/dist/sample/records.d.ts.map +1 -0
- package/dist/sample/records.js +22 -0
- package/dist/sample/records.js.map +1 -0
- package/dist/sample/transport.d.ts +42 -0
- package/dist/sample/transport.d.ts.map +1 -0
- package/dist/sample/transport.js +153 -0
- package/dist/sample/transport.js.map +1 -0
- package/dist/sync/cursor.d.ts +54 -0
- package/dist/sync/cursor.d.ts.map +1 -0
- package/dist/sync/cursor.js +52 -0
- package/dist/sync/cursor.js.map +1 -0
- package/dist/sync/front-matter.d.ts +10 -0
- package/dist/sync/front-matter.d.ts.map +1 -0
- package/dist/sync/front-matter.js +114 -0
- package/dist/sync/front-matter.js.map +1 -0
- package/dist/sync/markdown.d.ts +8 -0
- package/dist/sync/markdown.d.ts.map +1 -0
- package/dist/sync/markdown.js +40 -0
- package/dist/sync/markdown.js.map +1 -0
- package/dist/sync/source.d.ts +64 -0
- package/dist/sync/source.d.ts.map +1 -0
- package/dist/sync/source.js +634 -0
- package/dist/sync/source.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/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +85 -4
- package/skills/notion-cli/SKILL.md +34 -0
|
@@ -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,35 @@
|
|
|
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-JKIN5TOU.js";
|
|
10
|
+
import "./chunk-UWIA2G6Q.js";
|
|
11
|
+
import "./chunk-7FII4DCE.js";
|
|
12
|
+
import "./chunk-XC5CKHX2.js";
|
|
13
|
+
import "./chunk-24FAYAML.js";
|
|
14
|
+
import "./chunk-UWW24JQF.js";
|
|
15
|
+
import "./chunk-NLDYZBTC.js";
|
|
16
|
+
import "./chunk-7N5QB6NL.js";
|
|
17
|
+
import "./chunk-2YR3RYT4.js";
|
|
18
|
+
import "./chunk-WK3OSDNV.js";
|
|
19
|
+
import "./chunk-WVZFXI36.js";
|
|
20
|
+
import "./chunk-ZI3YTXSF.js";
|
|
21
|
+
import "./chunk-QC3KOJT4.js";
|
|
22
|
+
import "./chunk-HWRKURQH.js";
|
|
23
|
+
import "./chunk-RSIS7BR7.js";
|
|
24
|
+
import "./chunk-WM7663C2.js";
|
|
25
|
+
import "./chunk-XYIT2XB3.js";
|
|
26
|
+
import "./chunk-Y5E2WNWB.js";
|
|
27
|
+
import "./chunk-F6MLJ3V5.js";
|
|
28
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
29
|
+
export {
|
|
30
|
+
SCHEMA_DIALECT,
|
|
31
|
+
commandContract,
|
|
32
|
+
commandPathOf,
|
|
33
|
+
findCommand,
|
|
34
|
+
outputOf
|
|
35
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
COMMAND_SERVER_CONCURRENT,
|
|
5
|
+
enterCommandServer,
|
|
6
|
+
serveCommands
|
|
7
|
+
} from "./chunk-K5TWMQSY.js";
|
|
8
|
+
import {
|
|
9
|
+
ensureSqlite
|
|
10
|
+
} from "./chunk-TSCIIXN3.js";
|
|
11
|
+
import "./chunk-KHOVVPLC.js";
|
|
12
|
+
import "./chunk-JKIN5TOU.js";
|
|
13
|
+
import {
|
|
14
|
+
commandServerRequest,
|
|
15
|
+
exitCodeSet,
|
|
16
|
+
inCommandServerRequest
|
|
17
|
+
} from "./chunk-UWIA2G6Q.js";
|
|
18
|
+
import "./chunk-7FII4DCE.js";
|
|
19
|
+
import "./chunk-XC5CKHX2.js";
|
|
20
|
+
import "./chunk-24FAYAML.js";
|
|
21
|
+
import "./chunk-UWW24JQF.js";
|
|
22
|
+
import {
|
|
23
|
+
asOwnProcess
|
|
24
|
+
} from "./chunk-NLDYZBTC.js";
|
|
25
|
+
import "./chunk-7N5QB6NL.js";
|
|
26
|
+
import "./chunk-2YR3RYT4.js";
|
|
27
|
+
import "./chunk-WK3OSDNV.js";
|
|
28
|
+
import "./chunk-WVZFXI36.js";
|
|
29
|
+
import "./chunk-ZI3YTXSF.js";
|
|
30
|
+
import "./chunk-QC3KOJT4.js";
|
|
31
|
+
import "./chunk-HWRKURQH.js";
|
|
32
|
+
import "./chunk-AE2KQ37N.js";
|
|
33
|
+
import "./chunk-QBC23NHD.js";
|
|
34
|
+
import "./chunk-RSIS7BR7.js";
|
|
35
|
+
import {
|
|
36
|
+
catchCrashes
|
|
37
|
+
} from "./chunk-WM7663C2.js";
|
|
38
|
+
import "./chunk-XYIT2XB3.js";
|
|
39
|
+
import "./chunk-Y5E2WNWB.js";
|
|
40
|
+
import {
|
|
41
|
+
CliError
|
|
42
|
+
} from "./chunk-F6MLJ3V5.js";
|
|
43
|
+
import {
|
|
44
|
+
__name
|
|
45
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
46
|
+
|
|
47
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.663.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_8be6aa3a41727a76ce87cf0d5a7bd659/node_modules/@wirecat/cli-core/dist/cli/command-server-entry.js
|
|
48
|
+
import { PassThrough } from "node:stream";
|
|
49
|
+
var route = /* @__PURE__ */ __name((stream, sink) => {
|
|
50
|
+
const original = stream.write;
|
|
51
|
+
stream.write = ((chunk, encoding, callback) => {
|
|
52
|
+
sink()(typeof chunk === "string" ? Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8") : Buffer.from(chunk));
|
|
53
|
+
const done = typeof encoding === "function" ? encoding : callback;
|
|
54
|
+
if (done)
|
|
55
|
+
process.nextTick(done);
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
stream.write = original;
|
|
60
|
+
};
|
|
61
|
+
}, "route");
|
|
62
|
+
var closedStdin = /* @__PURE__ */ __name(() => {
|
|
63
|
+
const stdin = new PassThrough();
|
|
64
|
+
stdin.end();
|
|
65
|
+
return stdin;
|
|
66
|
+
}, "closedStdin");
|
|
67
|
+
var useStdin = /* @__PURE__ */ __name((outside) => Object.defineProperty(process, "stdin", {
|
|
68
|
+
get: /* @__PURE__ */ __name(() => commandServerRequest()?.stdin ?? outside, "get"),
|
|
69
|
+
configurable: true,
|
|
70
|
+
enumerable: true
|
|
71
|
+
}), "useStdin");
|
|
72
|
+
var roomFor = /* @__PURE__ */ __name((runs) => {
|
|
73
|
+
const emitters = [process, process.stdout, process.stderr];
|
|
74
|
+
const before = emitters.map((emitter) => emitter.getMaxListeners());
|
|
75
|
+
for (const emitter of emitters)
|
|
76
|
+
emitter.setMaxListeners(emitter.getMaxListeners() + 2 * runs);
|
|
77
|
+
return () => {
|
|
78
|
+
for (const [at, emitter] of emitters.entries())
|
|
79
|
+
emitter.setMaxListeners(before[at]);
|
|
80
|
+
};
|
|
81
|
+
}, "roomFor");
|
|
82
|
+
var serveEntry = /* @__PURE__ */ __name(async (entry, io, { firstRunAt, commanderExit }) => {
|
|
83
|
+
const release = catchCrashes({
|
|
84
|
+
cli: entry.app.command,
|
|
85
|
+
interactive: false,
|
|
86
|
+
...entry.reasons ? { reasons: entry.reasons } : {},
|
|
87
|
+
target: io.signals
|
|
88
|
+
});
|
|
89
|
+
const stopper = new AbortController();
|
|
90
|
+
const stop = /* @__PURE__ */ __name(() => stopper.abort(new CliError("cancelled", "the command server was stopped", { retryable: false })), "stop");
|
|
91
|
+
const protocol = io.stdout.write.bind(io.stdout);
|
|
92
|
+
const ownStderr = io.stderr.write.bind(io.stderr);
|
|
93
|
+
const toStderr = /* @__PURE__ */ __name((chunk) => {
|
|
94
|
+
ownStderr(chunk);
|
|
95
|
+
}, "toStderr");
|
|
96
|
+
const sink = /* @__PURE__ */ __name((pick) => () => {
|
|
97
|
+
const request = commandServerRequest();
|
|
98
|
+
return request ? (chunk) => pick(request).push(chunk) : toStderr;
|
|
99
|
+
}, "sink");
|
|
100
|
+
const unrouteOut = route(process.stdout, sink((request) => request.stdout));
|
|
101
|
+
const unrouteErr = route(process.stderr, sink((request) => request.stderr));
|
|
102
|
+
const stdin = Object.getOwnPropertyDescriptor(process, "stdin");
|
|
103
|
+
const requests = io.stdin;
|
|
104
|
+
useStdin(closedStdin());
|
|
105
|
+
const unroom = roomFor(COMMAND_SERVER_CONCURRENT);
|
|
106
|
+
io.signals.on("SIGINT", stop).on("SIGTERM", stop);
|
|
107
|
+
io.stdout.on("error", stop);
|
|
108
|
+
const run = /* @__PURE__ */ __name(async (argv, alone) => {
|
|
109
|
+
const request = { stdout: [], stderr: [], stdin: closedStdin(), alone };
|
|
110
|
+
const requestIo = { ...io, argv: [...io.argv.slice(0, 2), ...argv], stdin: request.stdin };
|
|
111
|
+
const context = {
|
|
112
|
+
args: argv,
|
|
113
|
+
env: io.env,
|
|
114
|
+
tty: false,
|
|
115
|
+
signal: stopper.signal,
|
|
116
|
+
atStart: /* @__PURE__ */ __name(async (command) => {
|
|
117
|
+
await enterCommandServer(command, entry.app.command);
|
|
118
|
+
await firstRunAt(entry, requestIo, () => true)(command);
|
|
119
|
+
}, "atStart"),
|
|
120
|
+
ask: /* @__PURE__ */ __name(async () => false, "ask"),
|
|
121
|
+
openBrowser: /* @__PURE__ */ __name(async () => void 0, "openBrowser"),
|
|
122
|
+
outputClosed: /* @__PURE__ */ __name(() => false, "outputClosed"),
|
|
123
|
+
setExitCode: /* @__PURE__ */ __name((code2) => {
|
|
124
|
+
request.exitCode = code2;
|
|
125
|
+
}, "setExitCode")
|
|
126
|
+
};
|
|
127
|
+
const code = await inCommandServerRequest(request, () => asOwnProcess(async () => {
|
|
128
|
+
try {
|
|
129
|
+
const returned = await entry.run(context);
|
|
130
|
+
return typeof returned === "number" ? returned : exitCodeSet() ?? 0;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return commanderExit(error) ?? entry.fail(error, context);
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
const text = /* @__PURE__ */ __name((chunks) => Buffer.concat(chunks).toString("utf8"), "text");
|
|
136
|
+
return { code, stdout: text(request.stdout), stderr: text(request.stderr) };
|
|
137
|
+
}, "run");
|
|
138
|
+
try {
|
|
139
|
+
if (entry.sqlite)
|
|
140
|
+
await ensureSqlite();
|
|
141
|
+
await serveCommands({
|
|
142
|
+
input: requests,
|
|
143
|
+
write: /* @__PURE__ */ __name((line) => new Promise((resolve) => protocol(line) ? resolve() : io.stdout.once("drain", resolve)), "write"),
|
|
144
|
+
run,
|
|
145
|
+
cli: entry.app.command,
|
|
146
|
+
concurrent: COMMAND_SERVER_CONCURRENT,
|
|
147
|
+
version: entry.app.version,
|
|
148
|
+
signal: stopper.signal
|
|
149
|
+
});
|
|
150
|
+
io.setExitCode(0);
|
|
151
|
+
} finally {
|
|
152
|
+
io.signals.off("SIGINT", stop).off("SIGTERM", stop);
|
|
153
|
+
unroom();
|
|
154
|
+
unrouteOut();
|
|
155
|
+
unrouteErr();
|
|
156
|
+
if (stdin)
|
|
157
|
+
Object.defineProperty(process, "stdin", stdin);
|
|
158
|
+
requests.destroy?.();
|
|
159
|
+
release();
|
|
160
|
+
}
|
|
161
|
+
}, "serveEntry");
|
|
162
|
+
export {
|
|
163
|
+
serveEntry
|
|
164
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
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-B2XKEEFX.js";
|
|
7
|
+
import "./chunk-RSIS7BR7.js";
|
|
8
|
+
import "./chunk-WM7663C2.js";
|
|
9
|
+
import "./chunk-XYIT2XB3.js";
|
|
10
|
+
import {
|
|
11
|
+
importFrom
|
|
12
|
+
} from "./chunk-Y5E2WNWB.js";
|
|
13
|
+
import {
|
|
14
|
+
CliError
|
|
15
|
+
} from "./chunk-F6MLJ3V5.js";
|
|
16
|
+
import {
|
|
17
|
+
__name
|
|
18
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
19
|
+
|
|
20
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.663.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_8be6aa3a41727a76ce87cf0d5a7bd659/node_modules/@wirecat/cli-core/dist/speech/decode.js
|
|
21
|
+
import { spawn } from "node:child_process";
|
|
22
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
23
|
+
import { createRequire } from "node:module";
|
|
24
|
+
import { tmpdir } from "node:os";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
import { pathToFileURL } from "node:url";
|
|
27
|
+
var LONGEST_AUDIO_SECONDS = 3600;
|
|
28
|
+
var FFMPEG_TIMEOUT_MS = 12e4;
|
|
29
|
+
var FFMPEG_FORMATS = "mov,mp4,m4a,3gp,3g2,mj2,aac,mp3,wav,amr,caf,aiff,flac,ogg,matroska,webm,asf";
|
|
30
|
+
var text = /* @__PURE__ */ __name((bytes, from, length) => String.fromCharCode(...bytes.subarray(from, from + length)), "text");
|
|
31
|
+
var contains = /* @__PURE__ */ __name((bytes, needle, within) => Buffer.from(bytes.buffer, bytes.byteOffset, Math.min(bytes.length, within)).includes(needle, 0, "latin1"), "contains");
|
|
32
|
+
var formatOf = /* @__PURE__ */ __name((bytes) => {
|
|
33
|
+
if (text(bytes, 0, 4) === "OggS") {
|
|
34
|
+
if (contains(bytes, "OpusHead", 128))
|
|
35
|
+
return "opus";
|
|
36
|
+
if (contains(bytes, "vorbis", 128))
|
|
37
|
+
return "vorbis";
|
|
38
|
+
return "other";
|
|
39
|
+
}
|
|
40
|
+
if (text(bytes, 0, 4) === "fLaC")
|
|
41
|
+
return "flac";
|
|
42
|
+
const frame = bytes[0] === 255 && ((bytes[1] ?? 0) & 224) === 224 && ((bytes[1] ?? 0) >> 1 & 3) !== 0;
|
|
43
|
+
if (text(bytes, 0, 3) === "ID3" || frame)
|
|
44
|
+
return "mp3";
|
|
45
|
+
return "other";
|
|
46
|
+
}, "formatOf");
|
|
47
|
+
var everyChannel = /* @__PURE__ */ __name((decoded) => {
|
|
48
|
+
if (!decoded.channelData[0] || decoded.samplesDecoded === 0)
|
|
49
|
+
throw new CliError("validation_error", "no audio in that file");
|
|
50
|
+
return decoded.channelData.map((samples) => ({ samples, rate: decoded.sampleRate }));
|
|
51
|
+
}, "everyChannel");
|
|
52
|
+
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");
|
|
53
|
+
var decodeVorbis = /* @__PURE__ */ __name(async (bytes) => {
|
|
54
|
+
const { OggVorbisDecoder } = await load("@wasm-audio-decoders/ogg-vorbis");
|
|
55
|
+
const decoder = new OggVorbisDecoder();
|
|
56
|
+
await decoder.ready;
|
|
57
|
+
try {
|
|
58
|
+
return everyChannel(await decoder.decodeFile(bytes));
|
|
59
|
+
} finally {
|
|
60
|
+
decoder.free();
|
|
61
|
+
}
|
|
62
|
+
}, "decodeVorbis");
|
|
63
|
+
var decodeFlac = /* @__PURE__ */ __name(async (bytes) => {
|
|
64
|
+
const { FLACDecoder } = await load("@wasm-audio-decoders/flac");
|
|
65
|
+
const decoder = new FLACDecoder();
|
|
66
|
+
await decoder.ready;
|
|
67
|
+
try {
|
|
68
|
+
return everyChannel(await decoder.decodeFile(bytes));
|
|
69
|
+
} finally {
|
|
70
|
+
decoder.free();
|
|
71
|
+
}
|
|
72
|
+
}, "decodeFlac");
|
|
73
|
+
var decodeMp3 = /* @__PURE__ */ __name(async (bytes) => {
|
|
74
|
+
const { MPEGDecoder } = await load("mpg123-decoder");
|
|
75
|
+
const decoder = new MPEGDecoder();
|
|
76
|
+
await decoder.ready;
|
|
77
|
+
try {
|
|
78
|
+
return everyChannel(decoder.decode(bytes));
|
|
79
|
+
} finally {
|
|
80
|
+
decoder.free();
|
|
81
|
+
}
|
|
82
|
+
}, "decodeMp3");
|
|
83
|
+
var runFfmpeg = /* @__PURE__ */ __name(async (bytes) => {
|
|
84
|
+
const directory = await mkdtemp(join(tmpdir(), "wirecat-audio-"));
|
|
85
|
+
try {
|
|
86
|
+
const input = join(directory, "audio");
|
|
87
|
+
await writeFile(input, bytes, { mode: 384 });
|
|
88
|
+
const largest = LONGEST_AUDIO_SECONDS * SAMPLE_RATE * 4;
|
|
89
|
+
const output = await new Promise((resolve, reject) => {
|
|
90
|
+
const child = spawn("ffmpeg", [
|
|
91
|
+
"-nostdin",
|
|
92
|
+
"-hide_banner",
|
|
93
|
+
"-loglevel",
|
|
94
|
+
"error",
|
|
95
|
+
"-protocol_whitelist",
|
|
96
|
+
"file",
|
|
97
|
+
"-format_whitelist",
|
|
98
|
+
FFMPEG_FORMATS,
|
|
99
|
+
"-i",
|
|
100
|
+
input,
|
|
101
|
+
"-vn",
|
|
102
|
+
"-ac",
|
|
103
|
+
"1",
|
|
104
|
+
"-ar",
|
|
105
|
+
String(SAMPLE_RATE),
|
|
106
|
+
"-f",
|
|
107
|
+
"f32le",
|
|
108
|
+
"pipe:1"
|
|
109
|
+
], { stdio: ["ignore", "pipe", "pipe"], timeout: FFMPEG_TIMEOUT_MS });
|
|
110
|
+
const chunks = [];
|
|
111
|
+
let size = 0;
|
|
112
|
+
let errors = "";
|
|
113
|
+
child.stdout.on("data", (chunk) => {
|
|
114
|
+
size += chunk.length;
|
|
115
|
+
if (size > largest)
|
|
116
|
+
child.kill();
|
|
117
|
+
else
|
|
118
|
+
chunks.push(chunk);
|
|
119
|
+
});
|
|
120
|
+
child.stderr.on("data", (chunk) => {
|
|
121
|
+
errors = (errors + chunk.toString()).slice(-500);
|
|
122
|
+
});
|
|
123
|
+
child.on("error", (error) => reject(error.code === "ENOENT" ? new CliError("validation_error", "only ffmpeg reads this audio format, and ffmpeg is not installed") : error));
|
|
124
|
+
child.on("close", (code) => {
|
|
125
|
+
if (size > largest)
|
|
126
|
+
reject(new CliError("validation_error", `the audio is longer than ${LONGEST_AUDIO_SECONDS / 60} minutes`));
|
|
127
|
+
else if (code === 0)
|
|
128
|
+
resolve(Buffer.concat(chunks));
|
|
129
|
+
else
|
|
130
|
+
reject(new CliError("validation_error", `ffmpeg could not read the audio: ${errors.trim() || code}`));
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
const samples = new Float32Array(Math.floor(output.length / 4));
|
|
134
|
+
Buffer.from(samples.buffer).set(output.subarray(0, samples.length * 4));
|
|
135
|
+
return { samples, rate: SAMPLE_RATE };
|
|
136
|
+
} finally {
|
|
137
|
+
await rm(directory, { recursive: true, force: true });
|
|
138
|
+
}
|
|
139
|
+
}, "runFfmpeg");
|
|
140
|
+
var BUNDLED = {
|
|
141
|
+
opus: decodeOgg,
|
|
142
|
+
vorbis: decodeVorbis,
|
|
143
|
+
flac: decodeFlac,
|
|
144
|
+
mp3: decodeMp3
|
|
145
|
+
};
|
|
146
|
+
var tooLong = /* @__PURE__ */ __name((pcm) => pcm.samples.length / pcm.rate > LONGEST_AUDIO_SECONDS, "tooLong");
|
|
147
|
+
var decodeChannels = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => {
|
|
148
|
+
const format = formatOf(bytes);
|
|
149
|
+
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 }), () => {
|
|
150
|
+
throw error;
|
|
151
|
+
}));
|
|
152
|
+
if (decoded.channels.some(tooLong))
|
|
153
|
+
throw new CliError("validation_error", `the audio is longer than ${LONGEST_AUDIO_SECONDS / 60} minutes`);
|
|
154
|
+
return decoded;
|
|
155
|
+
}, "decodeChannels");
|
|
156
|
+
var decodeAudio = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => (await decodeChannels(bytes, ffmpeg)).channels[0], "decodeAudio");
|
|
157
|
+
export {
|
|
158
|
+
LONGEST_AUDIO_SECONDS,
|
|
159
|
+
decodeAudio,
|
|
160
|
+
decodeChannels,
|
|
161
|
+
formatOf,
|
|
162
|
+
runFfmpeg
|
|
163
|
+
};
|