@wirecat/notion-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 +73 -0
- package/LICENSE +204 -0
- package/README.md +42 -2
- package/contracts/wirecat.json +1964 -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-JGYLQZ5C.js +278 -0
- package/dist/bundle/anthropic-S2VSMIKQ.js +91 -0
- package/dist/bundle/app-server-SASYDBCA.js +240 -0
- package/dist/bundle/bun-LU5LP3JI.js +169 -0
- package/dist/bundle/bun-sqlite-JBSINB4O.js +76 -0
- package/dist/bundle/chunk-22QQUKWA.js +53 -0
- package/dist/bundle/chunk-2F4QQ7WB.js +73 -0
- package/dist/bundle/chunk-2F6VO5HA.js +73 -0
- package/dist/bundle/chunk-2LWO3PDX.js +726 -0
- package/dist/bundle/chunk-3AL7QUS3.js +2778 -0
- package/dist/bundle/chunk-3Z4YTSRY.js +731 -0
- package/dist/bundle/chunk-4HWJOU7N.js +38 -0
- package/dist/bundle/chunk-4IPURN72.js +1221 -0
- package/dist/bundle/chunk-4ZTVJHWU.js +206 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5IYKVRH2.js +44811 -0
- package/dist/bundle/chunk-5NFK5EM2.js +362 -0
- package/dist/bundle/chunk-5QIQEUOG.js +188 -0
- package/dist/bundle/chunk-5RDNBG7D.js +72 -0
- package/dist/bundle/chunk-5RSC54NA.js +1328 -0
- package/dist/bundle/chunk-6EVKHZKN.js +158 -0
- package/dist/bundle/chunk-6RA3EABS.js +4012 -0
- package/dist/bundle/chunk-AOCUKEAX.js +131 -0
- package/dist/bundle/chunk-B26TQZKZ.js +217 -0
- package/dist/bundle/chunk-B7ON6KPT.js +1197 -0
- package/dist/bundle/chunk-BNPTZ5ZB.js +161 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-D7QSEEYW.js +274 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DH5PRHT4.js +392 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-EUIVXFLJ.js +259 -0
- package/dist/bundle/chunk-FPY6EJ7B.js +9568 -0
- package/dist/bundle/chunk-FT3LN3HP.js +6848 -0
- package/dist/bundle/chunk-FWVBPRL4.js +4436 -0
- package/dist/bundle/chunk-FXEJY4OL.js +12538 -0
- package/dist/bundle/chunk-G3EZFRSS.js +1297 -0
- package/dist/bundle/chunk-GZOUFX3C.js +230 -0
- package/dist/bundle/chunk-HL52XXZX.js +78 -0
- package/dist/bundle/chunk-KCLOUUYF.js +100 -0
- package/dist/bundle/chunk-KFVDL2QS.js +146 -0
- package/dist/bundle/chunk-KGERXYTV.js +24 -0
- package/dist/bundle/chunk-KM6WHPHI.js +288 -0
- package/dist/bundle/chunk-LAYPFBOM.js +95 -0
- package/dist/bundle/chunk-LLG2POQ7.js +170 -0
- package/dist/bundle/chunk-M3KB25D3.js +1392 -0
- package/dist/bundle/chunk-M7S2NDWB.js +76 -0
- package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
- package/dist/bundle/chunk-MY742GAD.js +1977 -0
- package/dist/bundle/chunk-MZU2YFBZ.js +823 -0
- package/dist/bundle/chunk-NOQ7B5N7.js +58 -0
- package/dist/bundle/chunk-NQWV4WQO.js +300 -0
- package/dist/bundle/chunk-ODBZNSZ6.js +1028 -0
- package/dist/bundle/chunk-OTV53F34.js +370 -0
- package/dist/bundle/chunk-P7CUM5IB.js +18 -0
- package/dist/bundle/chunk-RV64YUQX.js +185 -0
- package/dist/bundle/chunk-SHJQ6JKG.js +106 -0
- package/dist/bundle/chunk-SWAOWNKW.js +52 -0
- package/dist/bundle/chunk-SZOVLP44.js +29 -0
- package/dist/bundle/chunk-TPX2M45D.js +385 -0
- package/dist/bundle/chunk-TSDBSIFM.js +66 -0
- package/dist/bundle/chunk-VBHETQVV.js +64146 -0
- package/dist/bundle/chunk-VCIALTEM.js +3139 -0
- package/dist/bundle/chunk-VKE77B3F.js +2 -0
- package/dist/bundle/chunk-WCSOH4JS.js +142 -0
- package/dist/bundle/chunk-WF4D56CA.js +54 -0
- package/dist/bundle/chunk-WJHZMR2W.js +335 -0
- package/dist/bundle/chunk-X4TIMMKJ.js +16 -0
- package/dist/bundle/chunk-XF26XKTS.js +82 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -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-YMYUBZWT.js +1068 -0
- package/dist/bundle/chunk-YNTLT3Z3.js +2310 -0
- package/dist/bundle/chunk-YVI5SQPY.js +46 -0
- package/dist/bundle/chunk-Z56QFOBR.js +63 -0
- package/dist/bundle/chunk-ZKAEZXUP.js +787 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/chunk-ZZ32DXTH.js +23 -0
- package/dist/bundle/command-contract-JS5V27NX.js +38 -0
- package/dist/bundle/command-server-entry-UFSG7KRO.js +167 -0
- package/dist/bundle/decode-7LLWTSPT.js +297 -0
- package/dist/bundle/definitions-M3U4UYHN.js +45607 -0
- package/dist/bundle/dispatch-2GY6JIJH.js +411 -0
- package/dist/bundle/dist-ILNOLGYN.js +7577 -0
- package/dist/bundle/echarts-BXX4OQWC.js +42501 -0
- package/dist/bundle/embed-JXFNBTKH.js +38 -0
- package/dist/bundle/embedder-57YZ44KO.js +111 -0
- package/dist/bundle/failure-MYT4HPE3.js +25 -0
- package/dist/bundle/first-run-3PF7T74J.js +29 -0
- package/dist/bundle/first-screen-7BEROEQR.js +36 -0
- package/dist/bundle/instructions-2VECIDXF.js +11 -0
- package/dist/bundle/mcp-O6ACR2DX.js +167 -0
- package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
- package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
- package/dist/bundle/meeting-combined-PPUQ3KBR.js +24 -0
- package/dist/bundle/meeting-model-ZNMYKMCD.js +26 -0
- package/dist/bundle/meeting-semantic-ETN3A4BJ.js +22 -0
- package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-MPEQSFI3.js +176 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-WA32MYSJ.js +74 -0
- package/dist/bundle/notion.js +185 -0
- package/dist/bundle/oauth-IAFZG3IR.js +20 -0
- package/dist/bundle/open-M3JQUC5G.js +23 -0
- package/dist/bundle/openai-HXUEHUSD.js +240 -0
- package/dist/bundle/process-F6TKXWWA.js +91 -0
- package/dist/bundle/program-Y7JAB6TG.js +33219 -0
- package/dist/bundle/prompt-IMUQLZD2.js +17 -0
- package/dist/bundle/recognize-2MZAYHAA.js +26 -0
- package/dist/bundle/remote-OV4LB6VR.js +32 -0
- package/dist/bundle/rerank-ZIULUS34.js +52 -0
- package/dist/bundle/schemas-DIVZS6TU.js +12214 -0
- package/dist/bundle/serve-YU7QBP6L.js +199 -0
- package/dist/bundle/server-FKQET4ZO.js +71 -0
- package/dist/bundle/server-LGMNONSB.js +202 -0
- package/dist/bundle/services-5WY4DCPJ.js +581 -0
- package/dist/bundle/sqlite-runtime-5MXZDETH.js +20 -0
- package/dist/bundle/state-LWMZH2KI.js +36 -0
- package/dist/bundle/store-EPZYV4VW.js +168 -0
- package/dist/bundle/store-QE6FEIZD.js +286 -0
- package/dist/bundle/store-maintenance-command-ZUUUFCHL.js +62 -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/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 +4 -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/library.d.ts +10 -0
- package/dist/commands/library.d.ts.map +1 -0
- package/dist/commands/library.js +468 -0
- package/dist/commands/library.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 +105 -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 +51 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +67 -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 +30 -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/knowledge.d.ts +27 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +87 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/library.d.ts +44 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +149 -0
- package/dist/library.js.map +1 -0
- package/dist/notion/client.d.ts +45 -0
- package/dist/notion/client.d.ts.map +1 -0
- package/dist/notion/client.js +121 -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 +127 -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 +331 -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/sync/cursor.d.ts +135 -0
- package/dist/sync/cursor.d.ts.map +1 -0
- package/dist/sync/cursor.js +113 -0
- package/dist/sync/cursor.js.map +1 -0
- package/dist/sync/files.d.ts +77 -0
- package/dist/sync/files.d.ts.map +1 -0
- package/dist/sync/files.js +12 -0
- package/dist/sync/files.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 +11 -0
- package/dist/sync/markdown.d.ts.map +1 -0
- package/dist/sync/markdown.js +42 -0
- package/dist/sync/markdown.js.map +1 -0
- package/dist/sync/source.d.ts +11 -0
- package/dist/sync/source.d.ts.map +1 -0
- package/dist/sync/source.js +995 -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 +45 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
wirecatDirectory
|
|
5
|
+
} from "./chunk-WF4D56CA.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError
|
|
8
|
+
} from "./chunk-5RDNBG7D.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/speech/models.js
|
|
14
|
+
var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/csukuangfj/${repository}/resolve/${commit}/${name}`, "huggingFace");
|
|
15
|
+
var gigaam = huggingFace("sherpa-onnx-nemo-transducer-punct-giga-am-v3-russian-2025-12-16", "a6039be7cee829a9044a69ac0ebaf1c191217c97");
|
|
16
|
+
var gigaamCtc = huggingFace("sherpa-onnx-nemo-ctc-punct-giga-am-v3-russian-2025-12-16", "4fb5407ff028a69fec516cdf4c10fac9ddea7c16");
|
|
17
|
+
var parakeet = huggingFace("sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8", "2bda32ec70b097a55adaa07d9a7173915b43cc78");
|
|
18
|
+
var MODELS = [
|
|
19
|
+
{
|
|
20
|
+
id: "gigaam-v3",
|
|
21
|
+
title: "GigaAM v3, with punctuation",
|
|
22
|
+
languages: "Russian \u2014 the best of the three for Russian",
|
|
23
|
+
language: "ru",
|
|
24
|
+
featureDim: 64,
|
|
25
|
+
files: [
|
|
26
|
+
{
|
|
27
|
+
name: "encoder.int8.onnx",
|
|
28
|
+
url: gigaam("encoder.int8.onnx"),
|
|
29
|
+
sha256: "369f35a71bf288d3b8e0391fabd8dba5f2314088d440bca474056b7b4b6e66bf",
|
|
30
|
+
bytes: 224570820
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "decoder.onnx",
|
|
34
|
+
url: gigaam("decoder.onnx"),
|
|
35
|
+
sha256: "38fc7475443ea2a26f63211ca350f73ac50fff824ab7a3876ee2bd610c53bbc4",
|
|
36
|
+
bytes: 4600132
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "joiner.onnx",
|
|
40
|
+
url: gigaam("joiner.onnx"),
|
|
41
|
+
sha256: "602ff7017a93311aad34df1437c8d7f49911353c13d6eae7a6ee7b041339465c",
|
|
42
|
+
bytes: 2712896
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "tokens.txt",
|
|
46
|
+
url: gigaam("tokens.txt"),
|
|
47
|
+
sha256: "39abae20e692998290c574e606f11a9edef2902a1995463fcff63d1490cf22b7",
|
|
48
|
+
bytes: 13354
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
config: /* @__PURE__ */ __name((path) => ({
|
|
52
|
+
transducer: { encoder: path("encoder.int8.onnx"), decoder: path("decoder.onnx"), joiner: path("joiner.onnx") },
|
|
53
|
+
tokens: path("tokens.txt"),
|
|
54
|
+
modelType: "nemo_transducer"
|
|
55
|
+
}), "config")
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: "gigaam-v3-ctc",
|
|
59
|
+
title: "GigaAM v3 CTC, with punctuation \u2014 a little faster",
|
|
60
|
+
languages: "Russian \u2014 a little faster, rougher with capital letters",
|
|
61
|
+
language: "ru",
|
|
62
|
+
featureDim: 64,
|
|
63
|
+
files: [
|
|
64
|
+
{
|
|
65
|
+
name: "model.int8.onnx",
|
|
66
|
+
url: gigaamCtc("model.int8.onnx"),
|
|
67
|
+
sha256: "d5fea8df94263c285e54b21e5774b707c707192d3bdbeffd7b1eb07fb6743b35",
|
|
68
|
+
bytes: 224893661
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "tokens.txt",
|
|
72
|
+
url: gigaamCtc("tokens.txt"),
|
|
73
|
+
sha256: "142de7570b3de5b3035ce111a89c228e80e6085273731d944093ddf24fa539cd",
|
|
74
|
+
bytes: 2007
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
config: /* @__PURE__ */ __name((path) => ({ nemoCtc: { model: path("model.int8.onnx") }, tokens: path("tokens.txt") }), "config")
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "parakeet-v3",
|
|
81
|
+
title: "NVIDIA Parakeet TDT 0.6B v3",
|
|
82
|
+
/** The model card's list: huggingface.co/nvidia/parakeet-tdt-0.6b-v3, read 2026-09-24. */
|
|
83
|
+
languages: "25: bg cs da de el en es et fi fr hr hu it lt lv mt nl pl pt ro ru sk sl sv uk",
|
|
84
|
+
featureDim: 80,
|
|
85
|
+
files: [
|
|
86
|
+
{
|
|
87
|
+
name: "encoder.int8.onnx",
|
|
88
|
+
url: parakeet("encoder.int8.onnx"),
|
|
89
|
+
sha256: "acfc2b4456377e15d04f0243af540b7fe7c992f8d898d751cf134c3a55fd2247",
|
|
90
|
+
bytes: 652184281
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "decoder.int8.onnx",
|
|
94
|
+
url: parakeet("decoder.int8.onnx"),
|
|
95
|
+
sha256: "179e50c43d1a9de79c8a24149a2f9bac6eb5981823f2a2ed88d655b24248db4e",
|
|
96
|
+
bytes: 11845275
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "joiner.int8.onnx",
|
|
100
|
+
url: parakeet("joiner.int8.onnx"),
|
|
101
|
+
sha256: "3164c13fc2821009440d20fcb5fdc78bff28b4db2f8d0f0b329101719c0948b3",
|
|
102
|
+
bytes: 6355277
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "tokens.txt",
|
|
106
|
+
url: parakeet("tokens.txt"),
|
|
107
|
+
sha256: "d58544679ea4bc6ac563d1f545eb7d474bd6cfa467f0a6e2c1dc1c7d37e3c35d",
|
|
108
|
+
bytes: 93939
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
config: /* @__PURE__ */ __name((path) => ({
|
|
112
|
+
transducer: {
|
|
113
|
+
encoder: path("encoder.int8.onnx"),
|
|
114
|
+
decoder: path("decoder.int8.onnx"),
|
|
115
|
+
joiner: path("joiner.int8.onnx")
|
|
116
|
+
},
|
|
117
|
+
tokens: path("tokens.txt"),
|
|
118
|
+
modelType: "nemo_transducer"
|
|
119
|
+
}), "config")
|
|
120
|
+
}
|
|
121
|
+
];
|
|
122
|
+
var OPENAI_TRANSCRIBE_MODEL = "gpt-transcribe";
|
|
123
|
+
var VAD = {
|
|
124
|
+
name: "silero_vad.onnx",
|
|
125
|
+
url: "https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx",
|
|
126
|
+
sha256: "9e2449e1087496d8d4caba907f23e0bd3f78d91fa552479bb9c23ac09cbb1fd6",
|
|
127
|
+
bytes: 643854
|
|
128
|
+
};
|
|
129
|
+
var DEFAULT_ORDER = ["parakeet-v3", "gigaam-v3", "gigaam-v3-ctc"];
|
|
130
|
+
var orderedModels = /* @__PURE__ */ __name((order = DEFAULT_ORDER) => [.../* @__PURE__ */ new Set([...order, ...DEFAULT_ORDER])].map(speechModel), "orderedModels");
|
|
131
|
+
var findModel = /* @__PURE__ */ __name((id) => MODELS.find((model) => model.id === id), "findModel");
|
|
132
|
+
var speechModel = /* @__PURE__ */ __name((id) => {
|
|
133
|
+
const model = findModel(id);
|
|
134
|
+
if (!model) {
|
|
135
|
+
throw new CliError("validation_error", `no speech model "${id}" \u2014 one of ${MODELS.map((known) => known.id).join(", ")}`);
|
|
136
|
+
}
|
|
137
|
+
return model;
|
|
138
|
+
}, "speechModel");
|
|
139
|
+
|
|
140
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/speech/install.js
|
|
141
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
142
|
+
import { createReadStream, createWriteStream, mkdirSync, statSync } from "node:fs";
|
|
143
|
+
import { rename, rm } from "node:fs/promises";
|
|
144
|
+
import { dirname, join } from "node:path";
|
|
145
|
+
import { Readable, Transform } from "node:stream";
|
|
146
|
+
import { pipeline } from "node:stream/promises";
|
|
147
|
+
var sharedModelsDirectory = /* @__PURE__ */ __name((kind, env = process.env) => join(wirecatDirectory(env), "models", kind), "sharedModelsDirectory");
|
|
148
|
+
var modelsDirectory = /* @__PURE__ */ __name((env = process.env) => sharedModelsDirectory("audio", env), "modelsDirectory");
|
|
149
|
+
var STALL_MS = 6e4;
|
|
150
|
+
var watchdog = /* @__PURE__ */ __name((ms) => {
|
|
151
|
+
const controller = new AbortController();
|
|
152
|
+
let timer = setTimeout(() => controller.abort(), ms);
|
|
153
|
+
return {
|
|
154
|
+
signal: controller.signal,
|
|
155
|
+
poke: /* @__PURE__ */ __name(() => {
|
|
156
|
+
clearTimeout(timer);
|
|
157
|
+
timer = setTimeout(() => controller.abort(), ms);
|
|
158
|
+
}, "poke"),
|
|
159
|
+
stop: /* @__PURE__ */ __name(() => clearTimeout(timer), "stop")
|
|
160
|
+
};
|
|
161
|
+
}, "watchdog");
|
|
162
|
+
var modelPath = /* @__PURE__ */ __name((directory, model) => (name) => join(directory, model.id, name), "modelPath");
|
|
163
|
+
var vadPath = /* @__PURE__ */ __name((directory) => join(directory, VAD.name), "vadPath");
|
|
164
|
+
var placed = /* @__PURE__ */ __name((model, directory) => [
|
|
165
|
+
...model.files.map((file) => [file, modelPath(directory, model)(file.name)]),
|
|
166
|
+
[VAD, vadPath(directory)]
|
|
167
|
+
], "placed");
|
|
168
|
+
var isInstalled = /* @__PURE__ */ __name((model, directory) => filesPresent(placed(model, directory)), "isInstalled");
|
|
169
|
+
var filesPresent = /* @__PURE__ */ __name((files) => files.every(([file, path]) => sizeOf(path) === file.bytes), "filesPresent");
|
|
170
|
+
var sizeOf = /* @__PURE__ */ __name((path) => {
|
|
171
|
+
try {
|
|
172
|
+
return statSync(path).size;
|
|
173
|
+
} catch {
|
|
174
|
+
return void 0;
|
|
175
|
+
}
|
|
176
|
+
}, "sizeOf");
|
|
177
|
+
var installedBytes = /* @__PURE__ */ __name((model) => model.files.reduce((sum, file) => sum + file.bytes, 0), "installedBytes");
|
|
178
|
+
var install = /* @__PURE__ */ __name(async (model, directory, { fetch: get = fetch, progress, bytes, verifyExisting } = {}) => {
|
|
179
|
+
mkdirSync(join(directory, model.id), { recursive: true, mode: 448 });
|
|
180
|
+
await installFiles(placed(model, directory), { fetch: get, progress, bytes, verifyExisting });
|
|
181
|
+
}, "install");
|
|
182
|
+
var installFiles = /* @__PURE__ */ __name(async (files, { fetch: get = fetch, progress, bytes = /* @__PURE__ */ __name(() => {
|
|
183
|
+
}, "bytes"), verifyExisting } = {}) => {
|
|
184
|
+
if (verifyExisting)
|
|
185
|
+
for (const [file, path] of files) {
|
|
186
|
+
if (sizeOf(path) !== void 0) {
|
|
187
|
+
const hash = createHash("sha256");
|
|
188
|
+
for await (const chunk of createReadStream(path))
|
|
189
|
+
hash.update(chunk);
|
|
190
|
+
if (hash.digest("hex") !== file.sha256) {
|
|
191
|
+
progress?.(`${path}: not the file this version expects, downloading it again`);
|
|
192
|
+
await rm(path, { force: true });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const total = files.reduce((sum, [file]) => sum + file.bytes, 0);
|
|
197
|
+
const missing = files.filter(([file, path]) => sizeOf(path) !== file.bytes);
|
|
198
|
+
let done = total - missing.reduce((sum, [file]) => sum + file.bytes, 0);
|
|
199
|
+
bytes(done, total);
|
|
200
|
+
for (const [file, path] of missing) {
|
|
201
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
202
|
+
progress?.(`downloading ${file.name} (${megabytes(file.bytes)})`);
|
|
203
|
+
const before = done;
|
|
204
|
+
await fetchVerified(file, path, get, (received) => {
|
|
205
|
+
done = before + received;
|
|
206
|
+
bytes(done, total);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}, "installFiles");
|
|
210
|
+
var fetchVerified = /* @__PURE__ */ __name(async (file, path, get, received) => {
|
|
211
|
+
const stalled = watchdog(STALL_MS);
|
|
212
|
+
try {
|
|
213
|
+
await fetchInto(file, path, get, stalled, received);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (stalled.signal.aborted) {
|
|
216
|
+
throw new CliError("timeout", `${file.name} stopped downloading for ${STALL_MS / 1e3} s \u2014 nothing was installed`);
|
|
217
|
+
}
|
|
218
|
+
throw error;
|
|
219
|
+
} finally {
|
|
220
|
+
stalled.stop();
|
|
221
|
+
}
|
|
222
|
+
}, "fetchVerified");
|
|
223
|
+
var fetchInto = /* @__PURE__ */ __name(async (file, path, get, stalled, received) => {
|
|
224
|
+
const response = await get(file.url, { signal: stalled.signal });
|
|
225
|
+
if (!response.ok || !response.body) {
|
|
226
|
+
await response.body?.cancel();
|
|
227
|
+
throw new CliError("network_error", `${file.name} could not be downloaded: HTTP ${response.status}`);
|
|
228
|
+
}
|
|
229
|
+
const partial = `${path}.${randomUUID()}.part`;
|
|
230
|
+
const hash = createHash("sha256");
|
|
231
|
+
let bytes = 0;
|
|
232
|
+
const hashing = new Transform({
|
|
233
|
+
transform(chunk, _encoding, done) {
|
|
234
|
+
stalled.poke();
|
|
235
|
+
bytes += chunk.length;
|
|
236
|
+
if (bytes > file.bytes) {
|
|
237
|
+
done(new CliError("invalid_response", `${file.name} is larger than this version expects \u2014 nothing was installed`));
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
hash.update(chunk);
|
|
241
|
+
received(bytes);
|
|
242
|
+
done(null, chunk);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
try {
|
|
246
|
+
await pipeline(Readable.fromWeb(response.body), hashing, createWriteStream(partial, { flags: "wx", mode: 384 }));
|
|
247
|
+
const actual = hash.digest("hex");
|
|
248
|
+
if (actual !== file.sha256) {
|
|
249
|
+
throw new CliError("invalid_response", `${file.name} is not the file this version expects (sha256 ${actual}) \u2014 nothing was installed`);
|
|
250
|
+
}
|
|
251
|
+
await rename(partial, path);
|
|
252
|
+
} finally {
|
|
253
|
+
await rm(partial, { force: true });
|
|
254
|
+
}
|
|
255
|
+
}, "fetchInto");
|
|
256
|
+
var megabytes = /* @__PURE__ */ __name((bytes) => bytes < 1e6 ? "under 1 MB" : `${Math.round(bytes / 1e6)} MB`, "megabytes");
|
|
257
|
+
|
|
258
|
+
export {
|
|
259
|
+
OPENAI_TRANSCRIBE_MODEL,
|
|
260
|
+
VAD,
|
|
261
|
+
DEFAULT_ORDER,
|
|
262
|
+
orderedModels,
|
|
263
|
+
speechModel,
|
|
264
|
+
sharedModelsDirectory,
|
|
265
|
+
modelsDirectory,
|
|
266
|
+
modelPath,
|
|
267
|
+
vadPath,
|
|
268
|
+
isInstalled,
|
|
269
|
+
filesPresent,
|
|
270
|
+
installedBytes,
|
|
271
|
+
install,
|
|
272
|
+
installFiles,
|
|
273
|
+
megabytes
|
|
274
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// node_modules/.pnpm/@anthropic-ai+sdk@1.3.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/internal/node.mjs
|
|
5
|
+
import * as child_process from "node:child_process";
|
|
6
|
+
import * as crypto from "node:crypto";
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as os from "node:os";
|
|
9
|
+
import * as path from "node:path";
|
|
10
|
+
import * as stream from "node:stream";
|
|
11
|
+
import * as util from "node:util";
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
child_process,
|
|
15
|
+
crypto,
|
|
16
|
+
fs,
|
|
17
|
+
os,
|
|
18
|
+
path,
|
|
19
|
+
stream,
|
|
20
|
+
util
|
|
21
|
+
};
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CliError
|
|
5
|
+
} from "./chunk-5RDNBG7D.js";
|
|
6
|
+
import {
|
|
7
|
+
__name
|
|
8
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
9
|
+
|
|
10
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/atomic-write.js
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
12
|
+
import { constants } from "node:fs";
|
|
13
|
+
import { link, open, realpath, rename, unlink } from "node:fs/promises";
|
|
14
|
+
import { basename, dirname, join } from "node:path";
|
|
15
|
+
var openFolder = /* @__PURE__ */ __name((folder) => process.platform === "win32" ? Promise.resolve(void 0) : open(folder, constants.O_RDONLY | (constants.O_DIRECTORY ?? 0) | (constants.O_NOFOLLOW ?? 0)), "openFolder");
|
|
16
|
+
var writeFileAtomic = /* @__PURE__ */ __name(async (path, content, { mode = 384, overwrite = true, signal, beforePublish } = {}) => {
|
|
17
|
+
signal?.throwIfAborted();
|
|
18
|
+
const folder = await realpath(dirname(path));
|
|
19
|
+
const target = join(folder, basename(path));
|
|
20
|
+
const directory = await openFolder(folder);
|
|
21
|
+
try {
|
|
22
|
+
const temporary = join(folder, `.${basename(path)}.${randomUUID()}.tmp`);
|
|
23
|
+
let handle = await open(temporary, "wx", mode);
|
|
24
|
+
let published = false;
|
|
25
|
+
try {
|
|
26
|
+
await handle.writeFile(content);
|
|
27
|
+
await handle.sync();
|
|
28
|
+
await handle.close();
|
|
29
|
+
handle = void 0;
|
|
30
|
+
signal?.throwIfAborted();
|
|
31
|
+
await beforePublish?.();
|
|
32
|
+
if (overwrite)
|
|
33
|
+
await rename(temporary, target);
|
|
34
|
+
else
|
|
35
|
+
await link(temporary, target);
|
|
36
|
+
published = overwrite;
|
|
37
|
+
await directory?.sync();
|
|
38
|
+
} finally {
|
|
39
|
+
await handle?.close().catch(() => void 0);
|
|
40
|
+
if (!published)
|
|
41
|
+
await unlink(temporary).catch(() => void 0);
|
|
42
|
+
}
|
|
43
|
+
} finally {
|
|
44
|
+
await directory?.close().catch(() => void 0);
|
|
45
|
+
}
|
|
46
|
+
}, "writeFileAtomic");
|
|
47
|
+
|
|
48
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/ordinary-file.js
|
|
49
|
+
import { constants as constants2 } from "node:fs";
|
|
50
|
+
import { lstat, open as open2 } from "node:fs/promises";
|
|
51
|
+
var deviceOf = /* @__PURE__ */ __name((dev) => process.platform === "win32" ? BigInt.asUintN(32, dev) : dev, "deviceOf");
|
|
52
|
+
var sameIdentity = /* @__PURE__ */ __name((left, right) => left.ino === right.ino && deviceOf(left.dev) === deviceOf(right.dev), "sameIdentity");
|
|
53
|
+
var openOrdinaryFile = /* @__PURE__ */ __name(async (path, options = {}) => {
|
|
54
|
+
const before = await lstat(path, { bigint: true });
|
|
55
|
+
if (before.isSymbolicLink())
|
|
56
|
+
throw new CliError("validation_error", "archive path must be an ordinary file without a symlink");
|
|
57
|
+
if (!before.isFile())
|
|
58
|
+
throw new CliError("validation_error", "archive path must be an ordinary file");
|
|
59
|
+
const access = options.writable ? constants2.O_RDWR : constants2.O_RDONLY;
|
|
60
|
+
const flags = process.platform === "win32" ? access : access | (constants2.O_NOFOLLOW ?? 0) | (constants2.O_NONBLOCK ?? 0);
|
|
61
|
+
const file = await open2(path, flags);
|
|
62
|
+
try {
|
|
63
|
+
const opened = await file.stat({ bigint: true });
|
|
64
|
+
const after = await lstat(path, { bigint: true });
|
|
65
|
+
if (!opened.isFile() || !after.isFile() || before.ino !== opened.ino || before.ino !== after.ino)
|
|
66
|
+
throw new CliError("validation_error", "archive file changed while opening");
|
|
67
|
+
if (process.platform === "win32" && before.dev === 0n && after.dev === 0n) {
|
|
68
|
+
const witness = await open2(path, flags);
|
|
69
|
+
try {
|
|
70
|
+
const identified = await witness.stat({ bigint: true });
|
|
71
|
+
const final = await lstat(path, { bigint: true });
|
|
72
|
+
if (opened.dev === 0n || !identified.isFile() || !final.isFile() || !sameIdentity(identified, opened) || final.ino !== before.ino || final.dev !== 0n && deviceOf(final.dev) !== deviceOf(opened.dev))
|
|
73
|
+
throw new CliError("validation_error", "archive file changed while opening");
|
|
74
|
+
} finally {
|
|
75
|
+
await witness.close();
|
|
76
|
+
}
|
|
77
|
+
} else if (deviceOf(before.dev) !== deviceOf(opened.dev) || deviceOf(before.dev) !== deviceOf(after.dev)) {
|
|
78
|
+
throw new CliError("validation_error", "archive file changed while opening");
|
|
79
|
+
}
|
|
80
|
+
return file;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
await file.close();
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}, "openOrdinaryFile");
|
|
86
|
+
var sameOrdinaryFile = /* @__PURE__ */ __name(async (path, created) => {
|
|
87
|
+
let file;
|
|
88
|
+
try {
|
|
89
|
+
file = await openOrdinaryFile(path);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error instanceof CliError || typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
|
|
92
|
+
return false;
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
return sameIdentity(created, await file.stat({ bigint: true }));
|
|
97
|
+
} finally {
|
|
98
|
+
await file.close();
|
|
99
|
+
}
|
|
100
|
+
}, "sameOrdinaryFile");
|
|
101
|
+
var syncDirectory = /* @__PURE__ */ __name(async (path) => {
|
|
102
|
+
if (process.platform === "win32")
|
|
103
|
+
return;
|
|
104
|
+
const directory = await open2(path, constants2.O_RDONLY | (constants2.O_DIRECTORY ?? 0) | (constants2.O_NOFOLLOW ?? 0));
|
|
105
|
+
try {
|
|
106
|
+
if (!(await directory.stat()).isDirectory())
|
|
107
|
+
throw new CliError("validation_error", "archive publication directory must be ordinary");
|
|
108
|
+
await directory.sync();
|
|
109
|
+
} finally {
|
|
110
|
+
await directory.close();
|
|
111
|
+
}
|
|
112
|
+
}, "syncDirectory");
|
|
113
|
+
|
|
114
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/bounded-utf8.js
|
|
115
|
+
var readBoundedUtf8File = /* @__PURE__ */ __name(async (path, { maxBytes }) => {
|
|
116
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 16 * 1024 * 1024)
|
|
117
|
+
throw new CliError("validation_error", "file maxBytes takes 1\u201316777216 bytes");
|
|
118
|
+
const file = await openOrdinaryFile(path);
|
|
119
|
+
try {
|
|
120
|
+
if ((await file.stat()).size > maxBytes)
|
|
121
|
+
throw new CliError("validation_error", "input file exceeds its byte budget");
|
|
122
|
+
const chunks = [], buffer = Buffer.alloc(Math.min(65536, maxBytes + 1));
|
|
123
|
+
let bytes = 0;
|
|
124
|
+
for (; ; ) {
|
|
125
|
+
const { bytesRead } = await file.read(buffer, 0, Math.min(buffer.length, maxBytes - bytes + 1), null);
|
|
126
|
+
if (bytesRead === 0)
|
|
127
|
+
break;
|
|
128
|
+
bytes += bytesRead;
|
|
129
|
+
if (bytes > maxBytes)
|
|
130
|
+
throw new CliError("validation_error", "input file exceeds its byte budget");
|
|
131
|
+
chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks, bytes));
|
|
135
|
+
} catch {
|
|
136
|
+
throw new CliError("validation_error", "input file must contain valid UTF-8");
|
|
137
|
+
}
|
|
138
|
+
} finally {
|
|
139
|
+
await file.close();
|
|
140
|
+
}
|
|
141
|
+
}, "readBoundedUtf8File");
|
|
142
|
+
|
|
143
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/lock.js
|
|
144
|
+
import { mkdir as mkdir2 } from "node:fs/promises";
|
|
145
|
+
import { basename as basename2, dirname as dirname2 } from "node:path";
|
|
146
|
+
|
|
147
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
|
|
148
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
149
|
+
import { lstat as lstat3, mkdir, open as open3, realpath as realpath3, rmdir as rmdir2, unlink as unlink4 } from "node:fs/promises";
|
|
150
|
+
import { hostname as hostname2 } from "node:os";
|
|
151
|
+
import { join as join3 } from "node:path";
|
|
152
|
+
|
|
153
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
|
|
154
|
+
import { lstat as lstat2, readdir, realpath as realpath2, unlink as unlink2 } from "node:fs/promises";
|
|
155
|
+
import { join as join2 } from "node:path";
|
|
156
|
+
|
|
157
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/native-lease-owner.js
|
|
158
|
+
import { hostname } from "node:os";
|
|
159
|
+
var missingLeaseFile = /* @__PURE__ */ __name((error) => typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT", "missingLeaseFile");
|
|
160
|
+
var readLeaseOwner = /* @__PURE__ */ __name(async (path, name, signal) => {
|
|
161
|
+
signal?.throwIfAborted();
|
|
162
|
+
try {
|
|
163
|
+
const file = await openOrdinaryFile(path);
|
|
164
|
+
try {
|
|
165
|
+
if ((await file.stat()).size > 4096)
|
|
166
|
+
return null;
|
|
167
|
+
const buffer = Buffer.alloc(4097);
|
|
168
|
+
let size = 0;
|
|
169
|
+
while (size < buffer.length) {
|
|
170
|
+
signal?.throwIfAborted();
|
|
171
|
+
const { bytesRead } = await file.read(buffer, size, buffer.length - size, size);
|
|
172
|
+
if (bytesRead === 0)
|
|
173
|
+
break;
|
|
174
|
+
size += bytesRead;
|
|
175
|
+
}
|
|
176
|
+
signal?.throwIfAborted();
|
|
177
|
+
if (size > 4096)
|
|
178
|
+
return null;
|
|
179
|
+
const owner = JSON.parse(buffer.subarray(0, size).toString("utf8"));
|
|
180
|
+
if (owner?.version !== 1 || !Number.isSafeInteger(owner.pid) || owner.pid <= 0 || typeof owner.host !== "string" || !owner.host.trim() || !/^[a-f0-9-]{36}$/.test(owner.nonce) || name !== `${owner.pid}-${owner.nonce}.json`)
|
|
181
|
+
return null;
|
|
182
|
+
return owner;
|
|
183
|
+
} finally {
|
|
184
|
+
await file.close();
|
|
185
|
+
}
|
|
186
|
+
} catch {
|
|
187
|
+
signal?.throwIfAborted();
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
}, "readLeaseOwner");
|
|
191
|
+
var leaseOwnerStatus = /* @__PURE__ */ __name((owner) => {
|
|
192
|
+
if (owner.host !== hostname())
|
|
193
|
+
return "foreign";
|
|
194
|
+
try {
|
|
195
|
+
process.kill(owner.pid, 0);
|
|
196
|
+
return "active";
|
|
197
|
+
} catch (error) {
|
|
198
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ESRCH" ? "stale" : "active";
|
|
199
|
+
}
|
|
200
|
+
}, "leaseOwnerStatus");
|
|
201
|
+
|
|
202
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
|
|
203
|
+
var leaseInspection = /* @__PURE__ */ __name((markerDirectory) => {
|
|
204
|
+
const inspect = /* @__PURE__ */ __name(async (destination, options = {}) => {
|
|
205
|
+
options.signal?.throwIfAborted();
|
|
206
|
+
const root = await realpath2(destination);
|
|
207
|
+
options.signal?.throwIfAborted();
|
|
208
|
+
const folder = join2(root, markerDirectory);
|
|
209
|
+
let names;
|
|
210
|
+
try {
|
|
211
|
+
if ((await lstat2(folder)).isSymbolicLink())
|
|
212
|
+
throw new Error("symlink");
|
|
213
|
+
names = await readdir(folder);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
options.signal?.throwIfAborted();
|
|
216
|
+
if (missingLeaseFile(error))
|
|
217
|
+
return [];
|
|
218
|
+
throw new CliError("configuration_error", "archive lock directory could not be read");
|
|
219
|
+
}
|
|
220
|
+
options.signal?.throwIfAborted();
|
|
221
|
+
const result = [];
|
|
222
|
+
for (const name of names.sort()) {
|
|
223
|
+
options.signal?.throwIfAborted();
|
|
224
|
+
const owner = await readLeaseOwner(join2(folder, name), name, options.signal);
|
|
225
|
+
result.push({
|
|
226
|
+
name,
|
|
227
|
+
status: owner ? leaseOwnerStatus(owner) : "unrecognized",
|
|
228
|
+
pid: owner?.pid ?? null,
|
|
229
|
+
host: owner?.host ?? null
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
}, "inspect");
|
|
234
|
+
const recover = /* @__PURE__ */ __name(async (destination, options = {}) => {
|
|
235
|
+
options.signal?.throwIfAborted();
|
|
236
|
+
const root = await realpath2(destination);
|
|
237
|
+
const locks = await inspect(root, options);
|
|
238
|
+
const removed = [];
|
|
239
|
+
if (options.apply)
|
|
240
|
+
for (const lock of locks) {
|
|
241
|
+
options.signal?.throwIfAborted();
|
|
242
|
+
if (lock.status !== "stale")
|
|
243
|
+
continue;
|
|
244
|
+
const path = join2(root, markerDirectory, lock.name);
|
|
245
|
+
const owner = await readLeaseOwner(path, lock.name, options.signal);
|
|
246
|
+
if (!owner || leaseOwnerStatus(owner) !== "stale")
|
|
247
|
+
continue;
|
|
248
|
+
try {
|
|
249
|
+
await unlink2(path);
|
|
250
|
+
removed.push(lock.name);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (!missingLeaseFile(error))
|
|
253
|
+
throw new CliError("configuration_error", "stale archive lock could not be removed");
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return { locks, removed };
|
|
257
|
+
}, "recover");
|
|
258
|
+
return { inspect, recover };
|
|
259
|
+
}, "leaseInspection");
|
|
260
|
+
|
|
261
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/native-lease-release.js
|
|
262
|
+
import { rmdir, unlink as unlink3 } from "node:fs/promises";
|
|
263
|
+
var ownedNativeLease = /* @__PURE__ */ __name((path, name, owner, folder, identity) => {
|
|
264
|
+
let releasing;
|
|
265
|
+
const held = /* @__PURE__ */ __name(async () => {
|
|
266
|
+
if (!await sameOrdinaryFile(path, identity))
|
|
267
|
+
return false;
|
|
268
|
+
const current = await readLeaseOwner(path, name);
|
|
269
|
+
return current?.host === owner.host && current.pid === owner.pid && current.nonce === owner.nonce;
|
|
270
|
+
}, "held");
|
|
271
|
+
const release = /* @__PURE__ */ __name(async () => {
|
|
272
|
+
if (!await held())
|
|
273
|
+
throw new CliError("configuration_error", "owned archive lock changed before release");
|
|
274
|
+
await unlink3(path);
|
|
275
|
+
await rmdir(folder).catch(() => void 0);
|
|
276
|
+
}, "release");
|
|
277
|
+
return {
|
|
278
|
+
held,
|
|
279
|
+
release: /* @__PURE__ */ __name(() => releasing ??= release().catch((error) => {
|
|
280
|
+
releasing = void 0;
|
|
281
|
+
throw error;
|
|
282
|
+
}), "release")
|
|
283
|
+
};
|
|
284
|
+
}, "ownedNativeLease");
|
|
285
|
+
|
|
286
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
|
|
287
|
+
var validName = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !/[\\/\0:]/.test(value), "validName");
|
|
288
|
+
var nativeWriterLeaseStore = /* @__PURE__ */ __name((layout) => {
|
|
289
|
+
const { markerDirectory, legacyMarker } = layout;
|
|
290
|
+
if (!validName(markerDirectory) || legacyMarker !== void 0 && (!validName(legacyMarker) || legacyMarker === markerDirectory))
|
|
291
|
+
throw new CliError("validation_error", "archive lock layout requires distinct ordinary entry names");
|
|
292
|
+
const inspection = leaseInspection(markerDirectory);
|
|
293
|
+
return {
|
|
294
|
+
...inspection,
|
|
295
|
+
acquire: /* @__PURE__ */ __name(async (destination, { signal } = {}) => {
|
|
296
|
+
signal?.throwIfAborted();
|
|
297
|
+
const root = await realpath3(destination);
|
|
298
|
+
signal?.throwIfAborted();
|
|
299
|
+
const folder = join3(root, markerDirectory);
|
|
300
|
+
const owner = { version: 1, pid: process.pid, host: hostname2(), nonce: randomUUID2() };
|
|
301
|
+
const name = `${owner.pid}-${owner.nonce}.json`;
|
|
302
|
+
const path = join3(folder, name);
|
|
303
|
+
const marker = /* @__PURE__ */ __name(async (attempt = 1) => {
|
|
304
|
+
await mkdir(folder, { recursive: true });
|
|
305
|
+
try {
|
|
306
|
+
if ((await lstat3(folder)).isSymbolicLink())
|
|
307
|
+
throw new CliError("validation_error", "archive lock directory must not be a symlink");
|
|
308
|
+
await inspection.recover(root, { apply: true, signal });
|
|
309
|
+
signal?.throwIfAborted();
|
|
310
|
+
return await open3(path, "wx", 384);
|
|
311
|
+
} catch (error) {
|
|
312
|
+
if (attempt < 5 && missingLeaseFile(error))
|
|
313
|
+
return marker(attempt + 1);
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
}, "marker");
|
|
317
|
+
const file = await marker();
|
|
318
|
+
let retained = false;
|
|
319
|
+
let identity;
|
|
320
|
+
try {
|
|
321
|
+
identity = await file.stat({ bigint: true });
|
|
322
|
+
await file.writeFile(JSON.stringify(owner));
|
|
323
|
+
await file.sync();
|
|
324
|
+
await file.close();
|
|
325
|
+
signal?.throwIfAborted();
|
|
326
|
+
const inspected = await inspection.inspect(root, { signal });
|
|
327
|
+
const own = inspected.find((lock) => lock.name === name);
|
|
328
|
+
if (own?.status !== "active" || own.pid !== owner.pid || own.host !== owner.host)
|
|
329
|
+
throw new CliError("configuration_error", "archive writer lost its lock before acquisition");
|
|
330
|
+
const locks = inspected.filter((lock) => lock.name !== name);
|
|
331
|
+
if (locks.length)
|
|
332
|
+
return { status: "busy", locks };
|
|
333
|
+
if (legacyMarker) {
|
|
334
|
+
try {
|
|
335
|
+
await lstat3(join3(root, legacyMarker));
|
|
336
|
+
return { status: "legacy" };
|
|
337
|
+
} catch (error) {
|
|
338
|
+
if (!missingLeaseFile(error))
|
|
339
|
+
throw error;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
signal?.throwIfAborted();
|
|
343
|
+
retained = true;
|
|
344
|
+
return { status: "acquired", lease: ownedNativeLease(path, name, owner, folder, identity) };
|
|
345
|
+
} finally {
|
|
346
|
+
await file.close().catch(() => void 0);
|
|
347
|
+
if (!retained) {
|
|
348
|
+
if (identity && await sameOrdinaryFile(path, identity))
|
|
349
|
+
await unlink4(path).catch(() => void 0);
|
|
350
|
+
await rmdir2(folder).catch(() => void 0);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}, "acquire")
|
|
354
|
+
};
|
|
355
|
+
}, "nativeWriterLeaseStore");
|
|
356
|
+
|
|
357
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/lock.js
|
|
358
|
+
var acquireLock = /* @__PURE__ */ __name(async (path, { signal } = {}) => {
|
|
359
|
+
const folder = dirname2(path);
|
|
360
|
+
await mkdir2(folder, { recursive: true, mode: 448 });
|
|
361
|
+
const acquired = await nativeWriterLeaseStore({ markerDirectory: basename2(path) }).acquire(folder, {
|
|
362
|
+
...signal ? { signal } : {}
|
|
363
|
+
});
|
|
364
|
+
if (acquired.status === "acquired")
|
|
365
|
+
return acquired.lease;
|
|
366
|
+
throw new CliError("validation_error", `${basename2(path)} is locked by another process`, {
|
|
367
|
+
reason: "file.locked",
|
|
368
|
+
...acquired.status === "busy" ? { holders: acquired.locks } : {}
|
|
369
|
+
});
|
|
370
|
+
}, "acquireLock");
|
|
371
|
+
|
|
372
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/files/safe-name.js
|
|
373
|
+
import { basename as basename3 } from "node:path";
|
|
374
|
+
var safeName = /* @__PURE__ */ __name((name, platform = process.platform) => {
|
|
375
|
+
let plain = name === void 0 ? "" : basename3(name.replaceAll("\\", "/")).replace(/[\p{Cc}---]/gu, "").replace(/^\.+/, "");
|
|
376
|
+
if (platform === "win32") {
|
|
377
|
+
plain = plain.replace(/[<>:"|?*]/g, "_").replace(/[. ]+$/, "");
|
|
378
|
+
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(plain))
|
|
379
|
+
return void 0;
|
|
380
|
+
}
|
|
381
|
+
return plain === "" ? void 0 : plain;
|
|
382
|
+
}, "safeName");
|
|
383
|
+
|
|
384
|
+
export {
|
|
385
|
+
writeFileAtomic,
|
|
386
|
+
openOrdinaryFile,
|
|
387
|
+
sameOrdinaryFile,
|
|
388
|
+
syncDirectory,
|
|
389
|
+
readBoundedUtf8File,
|
|
390
|
+
acquireLock,
|
|
391
|
+
safeName
|
|
392
|
+
};
|