@wirecat/yandex-disk-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 +25 -0
- package/LICENSE +204 -0
- package/README.md +243 -2
- package/contracts/wirecat.json +1554 -0
- package/dist/bin/ydisk.d.ts +3 -0
- package/dist/bin/ydisk.d.ts.map +1 -0
- package/dist/bin/ydisk.js +40 -0
- package/dist/bin/ydisk.js.map +1 -0
- package/dist/bundle/all-profiles-4OLZF3RT.js +279 -0
- package/dist/bundle/anthropic-DKB4OJXZ.js +91 -0
- package/dist/bundle/app-server-G4545SSV.js +247 -0
- package/dist/bundle/bun-RXEQKFED.js +169 -0
- package/dist/bundle/bun-sqlite-VHT5LN7U.js +76 -0
- package/dist/bundle/chunk-2BITUXGC.js +12289 -0
- package/dist/bundle/chunk-2CLWDQKA.js +39330 -0
- package/dist/bundle/chunk-2JFDOPKA.js +9575 -0
- package/dist/bundle/chunk-3GVI2MAO.js +106 -0
- package/dist/bundle/chunk-3SZBWBMI.js +131 -0
- package/dist/bundle/chunk-44VSEXW6.js +4054 -0
- package/dist/bundle/chunk-4YPRRQBE.js +95 -0
- package/dist/bundle/chunk-5COYRL5B.js +379 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5DM7DIZL.js +1402 -0
- package/dist/bundle/chunk-6R2DVTVZ.js +24 -0
- package/dist/bundle/chunk-762BS35H.js +2787 -0
- package/dist/bundle/chunk-AG64V7AB.js +1233 -0
- package/dist/bundle/chunk-BC5HGIXB.js +334 -0
- package/dist/bundle/chunk-BH7LFEX7.js +36 -0
- package/dist/bundle/chunk-BLNPGY7N.js +53 -0
- package/dist/bundle/chunk-CNIA2LJF.js +372 -0
- package/dist/bundle/chunk-COSXMDC7.js +230 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-D7FO33KU.js +785 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DJH26PQ3.js +1396 -0
- package/dist/bundle/chunk-DJPT7IUC.js +64567 -0
- package/dist/bundle/chunk-DTMSCZDW.js +209 -0
- package/dist/bundle/chunk-E6LGZ5LX.js +16 -0
- package/dist/bundle/chunk-E6YRIHS5.js +92 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-F3DDSZTF.js +78 -0
- package/dist/bundle/chunk-F4WWTQNL.js +188 -0
- package/dist/bundle/chunk-FDDAUASC.js +1028 -0
- package/dist/bundle/chunk-FMNPG6N2.js +170 -0
- package/dist/bundle/chunk-FOKJ4POB.js +274 -0
- package/dist/bundle/chunk-G22C7JG6.js +731 -0
- package/dist/bundle/chunk-GA442SYZ.js +161 -0
- package/dist/bundle/chunk-GEBSW7UK.js +6848 -0
- package/dist/bundle/chunk-GGRKWAOK.js +594 -0
- package/dist/bundle/chunk-HHINRNZA.js +788 -0
- package/dist/bundle/chunk-HUZCL33L.js +128 -0
- package/dist/bundle/chunk-IALSIQVT.js +142 -0
- package/dist/bundle/chunk-IOXR2QBX.js +398 -0
- package/dist/bundle/chunk-J5CXR6VX.js +63 -0
- package/dist/bundle/chunk-J5PWSTOX.js +82 -0
- package/dist/bundle/chunk-J7BVAEHR.js +364 -0
- package/dist/bundle/chunk-JH46HMZW.js +1334 -0
- package/dist/bundle/chunk-JOBO7F6W.js +52 -0
- package/dist/bundle/chunk-JXZ5B3L5.js +2333 -0
- package/dist/bundle/chunk-KBIAMDZN.js +66 -0
- package/dist/bundle/chunk-KFVDL2QS.js +146 -0
- package/dist/bundle/chunk-LNHTLSR5.js +288 -0
- package/dist/bundle/chunk-M24RAKMJ.js +58 -0
- package/dist/bundle/chunk-MDQ57Q3H.js +1197 -0
- package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
- package/dist/bundle/chunk-MLXQ4X5L.js +206 -0
- package/dist/bundle/chunk-NQAKARHE.js +54 -0
- package/dist/bundle/chunk-OF7VVUDQ.js +23 -0
- package/dist/bundle/chunk-OQVPE3XK.js +324 -0
- package/dist/bundle/chunk-OR3QG7UR.js +259 -0
- package/dist/bundle/chunk-OUUYVROP.js +76 -0
- package/dist/bundle/chunk-PQBAM64O.js +168 -0
- package/dist/bundle/chunk-PYVIA7WF.js +88 -0
- package/dist/bundle/chunk-Q6HK3PHE.js +72 -0
- package/dist/bundle/chunk-QB3KECV2.js +218 -0
- package/dist/bundle/chunk-QGWXSFYN.js +73 -0
- package/dist/bundle/chunk-RC5QAAAE.js +29 -0
- package/dist/bundle/chunk-RMJ26HLB.js +18 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-T7ZUDA4C.js +72 -0
- package/dist/bundle/chunk-TRCSMVV5.js +72 -0
- package/dist/bundle/chunk-UD2BQEKA.js +46 -0
- package/dist/bundle/chunk-V4TL55GS.js +1068 -0
- package/dist/bundle/chunk-VJNWN5VU.js +4072 -0
- package/dist/bundle/chunk-VRRNBLMA.js +1227 -0
- package/dist/bundle/chunk-WUCMMNFJ.js +771 -0
- package/dist/bundle/chunk-XDESE3NY.js +44 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-Z2QEON7B.js +2275 -0
- package/dist/bundle/chunk-ZMJ56GME.js +7 -0
- package/dist/bundle/chunk-ZTSB3D7Q.js +100 -0
- package/dist/bundle/chunk-ZVJWD3FK.js +38 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-YIOYGPJA.js +40 -0
- package/dist/bundle/command-server-entry-MHBQDXS4.js +169 -0
- package/dist/bundle/decode-NUGJIOUW.js +297 -0
- package/dist/bundle/definitions-AILHKEQT.js +2005 -0
- package/dist/bundle/dispatch-5LC4UEGY.js +411 -0
- package/dist/bundle/dist-4I2W6X2I.js +7577 -0
- package/dist/bundle/echarts-MHSH6PGC.js +42501 -0
- package/dist/bundle/embed-ZDXTHHYS.js +38 -0
- package/dist/bundle/embedder-XFEELFUL.js +111 -0
- package/dist/bundle/failure-5S7VPBYK.js +25 -0
- package/dist/bundle/first-run-JHCHT3RJ.js +29 -0
- package/dist/bundle/first-screen-FHGQ6QRV.js +40 -0
- package/dist/bundle/instructions-WKSMBUFX.js +11 -0
- package/dist/bundle/mcp-HS2ZDUVR.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-K4U4NYRZ.js +25 -0
- package/dist/bundle/meeting-model-KCEG6Y5O.js +26 -0
- package/dist/bundle/meeting-semantic-VYGSV3H6.js +22 -0
- package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
- package/dist/bundle/node-CM6NC6UE.js +176 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-5YDQ3LIJ.js +74 -0
- package/dist/bundle/notes-search-PGO7KM2U.js +62 -0
- package/dist/bundle/oauth-NY4C5UCK.js +20 -0
- package/dist/bundle/open-YNUTA6ZE.js +23 -0
- package/dist/bundle/openai-4CVT5PHH.js +241 -0
- package/dist/bundle/process-2XT3TL27.js +91 -0
- package/dist/bundle/program-FMIVF5T6.js +31904 -0
- package/dist/bundle/prompt-VNWY3H6S.js +17 -0
- package/dist/bundle/recognize-JS4PBPSZ.js +26 -0
- package/dist/bundle/remote-RCLFH4V2.js +32 -0
- package/dist/bundle/rerank-EG6VKYGO.js +52 -0
- package/dist/bundle/schemas-ED2LHKXK.js +645 -0
- package/dist/bundle/serve-AHG25QXB.js +199 -0
- package/dist/bundle/server-5FTB7WM3.js +78 -0
- package/dist/bundle/server-JNZVSAZE.js +209 -0
- package/dist/bundle/sqlite-runtime-XSZOAQPF.js +20 -0
- package/dist/bundle/state-XGVAJFF7.js +36 -0
- package/dist/bundle/store-OHSCWZEV.js +177 -0
- package/dist/bundle/store-PKSPKJXL.js +293 -0
- package/dist/bundle/store-maintenance-command-KAWGBSWK.js +69 -0
- package/dist/bundle/ydisk.js +183 -0
- package/dist/commands/api.d.ts +9 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +59 -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/files.d.ts +3 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +272 -0
- package/dist/commands/files.js.map +1 -0
- package/dist/commands/library.d.ts +13 -0
- package/dist/commands/library.d.ts.map +1 -0
- package/dist/commands/library.js +118 -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 +99 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +62 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +80 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +77 -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 +2001 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +1473 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +127 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +545 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +829 -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 +10 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +33 -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/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +65 -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/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/dist/yandex/source.d.ts +39 -0
- package/dist/yandex/source.d.ts.map +1 -0
- package/dist/yandex/source.js +189 -0
- package/dist/yandex/source.js.map +1 -0
- package/dist/yandex/transport.d.ts +41 -0
- package/dist/yandex/transport.d.ts.map +1 -0
- package/dist/yandex/transport.js +152 -0
- package/dist/yandex/transport.js.map +1 -0
- package/dist/yandex/writes.d.ts +27 -0
- package/dist/yandex/writes.d.ts.map +1 -0
- package/dist/yandex/writes.js +61 -0
- package/dist/yandex/writes.js.map +1 -0
- package/package.json +88 -4
- package/skills/yandex-disk-cli/SKILL.md +46 -0
- package/skills/yandex-disk-cli/references/api/api-disk-operations-operation-id.md +13 -0
- package/skills/yandex-disk-cli/references/api/api-disk-public-resources.md +50 -0
- package/skills/yandex-disk-cli/references/api/api-disk-resources.md +171 -0
- package/skills/yandex-disk-cli/references/api/api-disk-trash-resources.md +48 -0
- package/skills/yandex-disk-cli/references/api/api-disk.md +13 -0
- package/skills/yandex-disk-cli/references/api.md +17 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
refuseModelAddress
|
|
5
|
+
} from "./chunk-Q6HK3PHE.js";
|
|
6
|
+
import {
|
|
7
|
+
onThisComputer
|
|
8
|
+
} from "./chunk-CNIA2LJF.js";
|
|
9
|
+
import {
|
|
10
|
+
unit
|
|
11
|
+
} from "./chunk-FDDAUASC.js";
|
|
12
|
+
import {
|
|
13
|
+
CliError
|
|
14
|
+
} from "./chunk-T7ZUDA4C.js";
|
|
15
|
+
import {
|
|
16
|
+
__name
|
|
17
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
18
|
+
|
|
19
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
|
|
20
|
+
import { setTimeout } from "node:timers/promises";
|
|
21
|
+
var OPENAI_URL = "https://api.openai.com/v1";
|
|
22
|
+
var OPENAI_MODELS = {
|
|
23
|
+
"text-embedding-3-small": { dims: 1536, perMillion: 0.02 },
|
|
24
|
+
"text-embedding-3-large": { dims: 3072, perMillion: 0.13 }
|
|
25
|
+
};
|
|
26
|
+
var DEFAULT_OPENAI_MODEL = "text-embedding-3-small";
|
|
27
|
+
var PER_REQUEST = 256;
|
|
28
|
+
var isLocal = /* @__PURE__ */ __name((baseUrl) => onThisComputer(baseUrl), "isLocal");
|
|
29
|
+
var remoteModel = /* @__PURE__ */ __name(({ model = DEFAULT_OPENAI_MODEL, baseUrl, dims }) => {
|
|
30
|
+
const known = baseUrl === void 0 ? OPENAI_MODELS[model] : void 0;
|
|
31
|
+
if (baseUrl === void 0 && !known) {
|
|
32
|
+
throw new CliError("validation_error", `OpenAI has no embedding model ${model} here \u2014 one of: ${Object.keys(OPENAI_MODELS).join(", ")}; another server takes --base-url`);
|
|
33
|
+
}
|
|
34
|
+
const size = dims ?? known?.dims;
|
|
35
|
+
if (size === void 0)
|
|
36
|
+
throw new CliError("validation_error", "with --base-url, say the vector size with --dims");
|
|
37
|
+
return {
|
|
38
|
+
provider: baseUrl === void 0 ? "openai" : `url:${new URL(baseUrl).host}`,
|
|
39
|
+
model,
|
|
40
|
+
dims: size,
|
|
41
|
+
baseUrl: baseUrl ?? OPENAI_URL,
|
|
42
|
+
shorten: known !== void 0 && size !== known.dims,
|
|
43
|
+
...known ? { price: { perMillion: known.perMillion, read: "2026-10-02" } } : {}
|
|
44
|
+
};
|
|
45
|
+
}, "remoteModel");
|
|
46
|
+
var remoteKey = /* @__PURE__ */ __name(({ provider, model, dims }) => `${provider}:${model}:${dims}`, "remoteKey");
|
|
47
|
+
var openRemote = /* @__PURE__ */ __name((remote, apiKey, { concurrency = 4, fetch: post = fetch, tries = 5, env }) => {
|
|
48
|
+
refuseModelAddress(env ?? process.env, remote.baseUrl, "text to embed");
|
|
49
|
+
const request = /* @__PURE__ */ __name(async (input) => {
|
|
50
|
+
for (let attempt = 1; ; attempt++) {
|
|
51
|
+
let response;
|
|
52
|
+
try {
|
|
53
|
+
response = await post(`${remote.baseUrl.replace(/\/$/, "")}/embeddings`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: {
|
|
56
|
+
"content-type": "application/json",
|
|
57
|
+
...apiKey ? { authorization: `Bearer ${apiKey}` } : {}
|
|
58
|
+
},
|
|
59
|
+
body: JSON.stringify({
|
|
60
|
+
model: remote.model,
|
|
61
|
+
input,
|
|
62
|
+
encoding_format: "float",
|
|
63
|
+
...remote.shorten ? { dimensions: remote.dims } : {}
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
} catch {
|
|
67
|
+
if (attempt >= tries)
|
|
68
|
+
throw new CliError("network_error", `${remote.provider} could not be reached`);
|
|
69
|
+
await setTimeout(1e3 * attempt);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (response.ok) {
|
|
73
|
+
const body = await response.json();
|
|
74
|
+
const data = [...body.data ?? []].sort((a, b) => a.index - b.index);
|
|
75
|
+
if (data.length !== input.length || data.some(({ embedding }) => embedding.length !== remote.dims)) {
|
|
76
|
+
throw new CliError("invalid_response", `${remote.provider} answered with vectors of another number or size than ${input.length} \xD7 ${remote.dims}`);
|
|
77
|
+
}
|
|
78
|
+
return data.map(({ embedding }) => unit(Float32Array.from(embedding)));
|
|
79
|
+
}
|
|
80
|
+
const code = await errorCode(response);
|
|
81
|
+
if (response.status === 401 || response.status === 403) {
|
|
82
|
+
throw new CliError("authentication_error", `${remote.provider} refused the key (HTTP ${response.status}${code}) \u2014 set it again with \`models keys set\``);
|
|
83
|
+
}
|
|
84
|
+
const again = response.status === 429 || response.status >= 500;
|
|
85
|
+
if (!again || attempt >= tries) {
|
|
86
|
+
throw new CliError(response.status === 429 ? "rate_limited" : "provider_error", `${remote.provider} answered HTTP ${response.status}${code}`);
|
|
87
|
+
}
|
|
88
|
+
const wait = Number(response.headers.get("retry-after"));
|
|
89
|
+
await setTimeout(Number.isFinite(wait) && wait > 0 ? wait * 1e3 : 1e3 * 2 ** attempt);
|
|
90
|
+
}
|
|
91
|
+
}, "request");
|
|
92
|
+
return {
|
|
93
|
+
model: { id: remote.model, dims: remote.dims },
|
|
94
|
+
embed: /* @__PURE__ */ __name(async (texts) => {
|
|
95
|
+
const parts = [];
|
|
96
|
+
for (let start = 0; start < texts.length; start += PER_REQUEST)
|
|
97
|
+
parts.push(texts.slice(start, start + PER_REQUEST));
|
|
98
|
+
const results = new Array(parts.length);
|
|
99
|
+
let next = 0;
|
|
100
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, parts.length) }, async () => {
|
|
101
|
+
for (let index = next++; index < parts.length; index = next++)
|
|
102
|
+
results[index] = await request(parts[index]);
|
|
103
|
+
}));
|
|
104
|
+
return results.flat();
|
|
105
|
+
}, "embed"),
|
|
106
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
107
|
+
}, "close")
|
|
108
|
+
};
|
|
109
|
+
}, "openRemote");
|
|
110
|
+
var errorCode = /* @__PURE__ */ __name(async (response) => {
|
|
111
|
+
try {
|
|
112
|
+
const body = await response.json();
|
|
113
|
+
const code = body.error?.code ?? body.error?.type;
|
|
114
|
+
return typeof code === "string" && /^[\w.-]{1,64}$/.test(code) ? `, ${code}` : "";
|
|
115
|
+
} catch {
|
|
116
|
+
return "";
|
|
117
|
+
}
|
|
118
|
+
}, "errorCode");
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
OPENAI_URL,
|
|
122
|
+
OPENAI_MODELS,
|
|
123
|
+
DEFAULT_OPENAI_MODEL,
|
|
124
|
+
isLocal,
|
|
125
|
+
remoteModel,
|
|
126
|
+
remoteKey,
|
|
127
|
+
openRemote
|
|
128
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
executableEnvironment,
|
|
5
|
+
executableOnPath
|
|
6
|
+
} from "./chunk-UD2BQEKA.js";
|
|
7
|
+
import {
|
|
8
|
+
require_cross_spawn
|
|
9
|
+
} from "./chunk-D72URWJE.js";
|
|
10
|
+
import {
|
|
11
|
+
loadConfigFile,
|
|
12
|
+
saveConfigFile
|
|
13
|
+
} from "./chunk-762BS35H.js";
|
|
14
|
+
import {
|
|
15
|
+
number,
|
|
16
|
+
object,
|
|
17
|
+
optional,
|
|
18
|
+
string
|
|
19
|
+
} from "./chunk-S4UUN6LD.js";
|
|
20
|
+
import {
|
|
21
|
+
__name,
|
|
22
|
+
__toESM
|
|
23
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
24
|
+
|
|
25
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_commander@15.0.0_esbuild@0.28._2fe0e09d29eda9827e2087fd1a1cce67/node_modules/@wirecat/cli-base/dist/update/index.js
|
|
26
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
27
|
+
import { existsSync } from "node:fs";
|
|
28
|
+
var updateCommand = /* @__PURE__ */ __name((installer, packageName) => {
|
|
29
|
+
const target = `${packageName}@latest`;
|
|
30
|
+
switch (installer) {
|
|
31
|
+
// pnpm 11 installs only versions a day old (minimumReleaseAge 1440); a fix must reach users the day it ships.
|
|
32
|
+
// Only the package's own scope is exempt — every other dependency keeps the wait.
|
|
33
|
+
case "pnpm":
|
|
34
|
+
return ["pnpm", "add", "-g", target, `--config.minimumReleaseAgeExclude=${ownScope(packageName)}`];
|
|
35
|
+
case "npm":
|
|
36
|
+
return ["npm", "install", "-g", target];
|
|
37
|
+
case "bun":
|
|
38
|
+
return ["bun", "add", "-g", target];
|
|
39
|
+
default:
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
}, "updateCommand");
|
|
43
|
+
var ownScope = /* @__PURE__ */ __name((packageName) => packageName.startsWith("@") ? `${packageName.split("/", 1)[0]}/*` : packageName, "ownScope");
|
|
44
|
+
var isNewer = /* @__PURE__ */ __name((candidate, current) => {
|
|
45
|
+
const parse = /* @__PURE__ */ __name((version) => /^\d+\.\d+\.\d+$/.test(version) ? version.split(".").map(Number) : void 0, "parse");
|
|
46
|
+
const a = parse(candidate);
|
|
47
|
+
const b = parse(current);
|
|
48
|
+
if (!a || !b)
|
|
49
|
+
return false;
|
|
50
|
+
for (let i = 0; i < 3; i++) {
|
|
51
|
+
if (a[i] !== b[i])
|
|
52
|
+
return a[i] > b[i];
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}, "isNewer");
|
|
56
|
+
var latestVersion = /* @__PURE__ */ __name(async (packageName, fetch, { timeoutMs = 1e3 } = {}) => {
|
|
57
|
+
try {
|
|
58
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
|
|
59
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
60
|
+
headers: { accept: "application/json" }
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok)
|
|
63
|
+
return void 0;
|
|
64
|
+
const { version } = await response.json();
|
|
65
|
+
return typeof version === "string" ? version : void 0;
|
|
66
|
+
} catch {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
}, "latestVersion");
|
|
70
|
+
var CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
|
|
71
|
+
var mayNotify = /* @__PURE__ */ __name(({ format, stderrIsTTY, quiet, enabled, installer, env, offVariables = [] }) => enabled && format === "pretty" && stderrIsTTY && !quiet && updateCommand(installer, "any") !== void 0 && !env.CI && !env.NO_UPDATE_NOTIFIER && offVariables.every((name) => !env[name]), "mayNotify");
|
|
72
|
+
var updateState = object({
|
|
73
|
+
checkedAt: number(),
|
|
74
|
+
latest: optional(string()),
|
|
75
|
+
/** When the skill hint (`cli-base/skill`) was last shown — the other daily notice kept in this file. */
|
|
76
|
+
skillHintAt: optional(number())
|
|
77
|
+
});
|
|
78
|
+
var readNoticeState = /* @__PURE__ */ __name((path) => {
|
|
79
|
+
try {
|
|
80
|
+
return loadConfigFile(path, updateState, () => ({ checkedAt: 0 }));
|
|
81
|
+
} catch {
|
|
82
|
+
return { checkedAt: 0 };
|
|
83
|
+
}
|
|
84
|
+
}, "readNoticeState");
|
|
85
|
+
var readUpdateState = /* @__PURE__ */ __name((path) => {
|
|
86
|
+
const state = readNoticeState(path);
|
|
87
|
+
return state.checkedAt > 0 ? state : void 0;
|
|
88
|
+
}, "readUpdateState");
|
|
89
|
+
var writeUpdateState = /* @__PURE__ */ __name((path, state) => {
|
|
90
|
+
try {
|
|
91
|
+
saveConfigFile(path, { ...readNoticeState(path), ...state });
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
}, "writeUpdateState");
|
|
95
|
+
var checkIsDue = /* @__PURE__ */ __name((state, now) => state === void 0 || now - state.checkedAt >= CHECK_EVERY_MS, "checkIsDue");
|
|
96
|
+
var spawnPlan = /* @__PURE__ */ __name(([command, ...args], platform = process.platform, env = process.env, exists = existsSync) => ({ file: executableOnPath(command, env, platform, exists), args, shell: false }), "spawnPlan");
|
|
97
|
+
var runUpdate = /* @__PURE__ */ __name((argv) => {
|
|
98
|
+
const { file, args, shell } = spawnPlan(argv);
|
|
99
|
+
const { status, error } = import_cross_spawn.default.sync(file, args, {
|
|
100
|
+
stdio: ["inherit", 2, 2],
|
|
101
|
+
shell,
|
|
102
|
+
env: executableEnvironment(process.env)
|
|
103
|
+
});
|
|
104
|
+
if (error)
|
|
105
|
+
throw new Error(`could not start ${argv[0]}: ${error.message}`);
|
|
106
|
+
return status ?? 1;
|
|
107
|
+
}, "runUpdate");
|
|
108
|
+
var updateNotice = /* @__PURE__ */ __name(async ({ argv, packageName, command, upgradeCommand = "upgrade", version, statePath, fetch, now = Date.now, ...context }) => {
|
|
109
|
+
try {
|
|
110
|
+
const path = commandWords(argv).slice(0, 2);
|
|
111
|
+
if (path.includes("complete") || path.includes(upgradeCommand))
|
|
112
|
+
return void 0;
|
|
113
|
+
if (!mayNotify(context))
|
|
114
|
+
return void 0;
|
|
115
|
+
const at = now();
|
|
116
|
+
let state = readUpdateState(statePath);
|
|
117
|
+
if (checkIsDue(state, at)) {
|
|
118
|
+
const found = await latestVersion(packageName, fetch, { timeoutMs: 1e3 });
|
|
119
|
+
const seen = found ?? state?.latest;
|
|
120
|
+
state = seen ? { checkedAt: at, latest: seen } : { checkedAt: at };
|
|
121
|
+
writeUpdateState(statePath, state);
|
|
122
|
+
}
|
|
123
|
+
return state?.latest && isNewer(state.latest, version) ? `${command} ${state.latest} is out \u2014 you have ${version}. \`${command} ${upgradeCommand}\` installs it.` : void 0;
|
|
124
|
+
} catch {
|
|
125
|
+
return void 0;
|
|
126
|
+
}
|
|
127
|
+
}, "updateNotice");
|
|
128
|
+
var commandWords = /* @__PURE__ */ __name((argv) => {
|
|
129
|
+
const end = argv.indexOf("--");
|
|
130
|
+
return argv.slice(0, end < 0 ? void 0 : end).filter((word) => !word.startsWith("-"));
|
|
131
|
+
}, "commandWords");
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
updateCommand,
|
|
135
|
+
isNewer,
|
|
136
|
+
latestVersion,
|
|
137
|
+
CHECK_EVERY_MS,
|
|
138
|
+
readNoticeState,
|
|
139
|
+
writeUpdateState,
|
|
140
|
+
runUpdate,
|
|
141
|
+
updateNotice
|
|
142
|
+
};
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
endpoint
|
|
5
|
+
} from "./chunk-CNIA2LJF.js";
|
|
6
|
+
import {
|
|
7
|
+
filesPresent,
|
|
8
|
+
sharedModelsDirectory
|
|
9
|
+
} from "./chunk-FOKJ4POB.js";
|
|
10
|
+
import {
|
|
11
|
+
check,
|
|
12
|
+
getDotPath,
|
|
13
|
+
maxLength,
|
|
14
|
+
minLength,
|
|
15
|
+
optional,
|
|
16
|
+
picklist,
|
|
17
|
+
pipe,
|
|
18
|
+
record,
|
|
19
|
+
regex,
|
|
20
|
+
safeParse,
|
|
21
|
+
strictObject,
|
|
22
|
+
string,
|
|
23
|
+
trim
|
|
24
|
+
} from "./chunk-S4UUN6LD.js";
|
|
25
|
+
import {
|
|
26
|
+
CliError,
|
|
27
|
+
isCliError
|
|
28
|
+
} from "./chunk-T7ZUDA4C.js";
|
|
29
|
+
import {
|
|
30
|
+
__name
|
|
31
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
32
|
+
|
|
33
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/ports/app.js
|
|
34
|
+
import { readFileSync } from "node:fs";
|
|
35
|
+
var envName = /* @__PURE__ */ __name((app, name) => `${app.envPrefix}_${name}`, "envName");
|
|
36
|
+
var locking = /* @__PURE__ */ __name((value) => value !== void 0 && value.trim() !== "" && value !== "0", "locking");
|
|
37
|
+
var ancestries = /* @__PURE__ */ new Map();
|
|
38
|
+
var readable = /* @__PURE__ */ __name((read, path) => {
|
|
39
|
+
try {
|
|
40
|
+
return read(path);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error.code === "EACCES")
|
|
43
|
+
return void 0;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}, "readable");
|
|
47
|
+
var ancestorEnvironments = /* @__PURE__ */ __name(({ read = /* @__PURE__ */ __name((path) => readFileSync(path, "utf8"), "read"), from = process.ppid, uid = process.getuid?.() ?? -1, cache = ancestries } = {}) => {
|
|
48
|
+
if (process.platform !== "linux")
|
|
49
|
+
return [];
|
|
50
|
+
const key = `${from}:${uid}`;
|
|
51
|
+
const known = cache.get(key);
|
|
52
|
+
if (known !== void 0)
|
|
53
|
+
return known;
|
|
54
|
+
let found = [];
|
|
55
|
+
try {
|
|
56
|
+
for (let pid = from, depth = 0; pid >= 1 && depth < 64; depth++) {
|
|
57
|
+
const status = read(`/proc/${pid}/status`);
|
|
58
|
+
const field = /* @__PURE__ */ __name((name) => new RegExp(`^${name}:\\s*(\\d+)`, "m").exec(status)?.[1], "field");
|
|
59
|
+
if (Number(field("Uid")) !== uid)
|
|
60
|
+
break;
|
|
61
|
+
const environ = readable(read, `/proc/${pid}/environ`);
|
|
62
|
+
if (environ === void 0)
|
|
63
|
+
break;
|
|
64
|
+
found.push(environ.split("\0"));
|
|
65
|
+
pid = Number(field("PPid"));
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
found = null;
|
|
69
|
+
}
|
|
70
|
+
cache.set(key, found);
|
|
71
|
+
return found;
|
|
72
|
+
}, "ancestorEnvironments");
|
|
73
|
+
var valuesOf = /* @__PURE__ */ __name((environments, name) => environments.flatMap((environ) => environ.filter((entry) => entry.startsWith(`${name}=`)).map((entry) => entry.slice(name.length + 1))), "valuesOf");
|
|
74
|
+
var lockedByAncestor = /* @__PURE__ */ __name((name, ancestry = {}) => {
|
|
75
|
+
const environments = ancestorEnvironments(ancestry);
|
|
76
|
+
return environments === null || valuesOf(environments, name).some(locking);
|
|
77
|
+
}, "lockedByAncestor");
|
|
78
|
+
var ancestorValue = /* @__PURE__ */ __name((name, env, ancestry = {}) => valuesOf(ancestorEnvironments(ancestry) ?? [], name).at(-1) ?? env[name], "ancestorValue");
|
|
79
|
+
var readOnlyLockOf = /* @__PURE__ */ __name((app, env) => {
|
|
80
|
+
const name = envName(app, "READ_ONLY");
|
|
81
|
+
return locking(env[name]) || lockedByAncestor(name) ? name : void 0;
|
|
82
|
+
}, "readOnlyLockOf");
|
|
83
|
+
var mailHolderVariable = /* @__PURE__ */ __name((app) => envName(app, "MAIL_HOLDER"), "mailHolderVariable");
|
|
84
|
+
var MESSENGER_CHANGE_REFUSAL = "send, react, change chats or change the account";
|
|
85
|
+
var readOnlyRefusal = /* @__PURE__ */ __name((lock, what) => new CliError("permission_error", `this process is read-only (${lock}) \u2014 it cannot ${what}`), "readOnlyRefusal");
|
|
86
|
+
|
|
87
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/background/budget.js
|
|
88
|
+
var DEADLINE_MARGIN_MS = 5e3;
|
|
89
|
+
var DEADLINE_MARGIN_SHARE = 0.15;
|
|
90
|
+
var DEFAULT_REQUEST_MS = 2e3;
|
|
91
|
+
var ANSWER_RESERVE_MS = 500;
|
|
92
|
+
var oneMoreFits = /* @__PURE__ */ __name((deadline, at, requestMs = DEFAULT_REQUEST_MS) => deadline !== void 0 && at + requestMs + ANSWER_RESERVE_MS < deadline.endsAt, "oneMoreFits");
|
|
93
|
+
var deadlineMargin = /* @__PURE__ */ __name((deadline) => Math.max(DEADLINE_MARGIN_MS, deadline.ms * DEADLINE_MARGIN_SHARE), "deadlineMargin");
|
|
94
|
+
var requestsFor = /* @__PURE__ */ __name((deadline, requestMs = DEFAULT_REQUEST_MS) => deadline === void 0 ? null : Math.max(1, Math.floor((deadline.ms - deadlineMargin(deadline)) / requestMs)), "requestsFor");
|
|
95
|
+
var runBudget = /* @__PURE__ */ __name(({ requests, deadline, requestMs, signal, now = Date.now } = {}) => {
|
|
96
|
+
const fits = requestsFor(deadline, requestMs);
|
|
97
|
+
const limit = fits === null ? requests ?? null : Math.min(fits, requests ?? fits);
|
|
98
|
+
const margin = deadline ? deadlineMargin(deadline) : 0;
|
|
99
|
+
let used = 0;
|
|
100
|
+
let granted = false;
|
|
101
|
+
let stopped2 = null;
|
|
102
|
+
let last;
|
|
103
|
+
let slowest = 0;
|
|
104
|
+
return {
|
|
105
|
+
take() {
|
|
106
|
+
if (stopped2)
|
|
107
|
+
return stopped2;
|
|
108
|
+
const at = now();
|
|
109
|
+
if (last !== void 0)
|
|
110
|
+
slowest = Math.max(slowest, at - last);
|
|
111
|
+
if (signal?.aborted)
|
|
112
|
+
stopped2 = "cancelled";
|
|
113
|
+
else if (limit !== null && used >= limit)
|
|
114
|
+
stopped2 = "requests";
|
|
115
|
+
else if (deadline && at + margin + slowest >= deadline.endsAt)
|
|
116
|
+
stopped2 = "deadline";
|
|
117
|
+
if (stopped2)
|
|
118
|
+
return stopped2;
|
|
119
|
+
used += 1;
|
|
120
|
+
last = at;
|
|
121
|
+
return null;
|
|
122
|
+
},
|
|
123
|
+
first() {
|
|
124
|
+
if (granted || used > 0 || stopped2 !== "deadline")
|
|
125
|
+
return false;
|
|
126
|
+
const at = now();
|
|
127
|
+
if (!oneMoreFits(deadline, at, Math.max(requestMs ?? DEFAULT_REQUEST_MS, slowest)))
|
|
128
|
+
return false;
|
|
129
|
+
granted = true;
|
|
130
|
+
used += 1;
|
|
131
|
+
last = at;
|
|
132
|
+
return true;
|
|
133
|
+
},
|
|
134
|
+
get used() {
|
|
135
|
+
return used;
|
|
136
|
+
},
|
|
137
|
+
limit,
|
|
138
|
+
get stopped() {
|
|
139
|
+
return stopped2;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}, "runBudget");
|
|
143
|
+
|
|
144
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/images/picture/models.js
|
|
145
|
+
import { join } from "node:path";
|
|
146
|
+
var clip = /* @__PURE__ */ __name((name) => `https://huggingface.co/Xenova/clip-vit-base-patch32/resolve/d15189d7028b43f1d3e65039190477f6af591c2a/${name}`, "clip");
|
|
147
|
+
var IMAGE_MODELS = [
|
|
148
|
+
{
|
|
149
|
+
id: "clip-b32",
|
|
150
|
+
title: "CLIP ViT-B/32, 8-bit",
|
|
151
|
+
languages: "English only: translate a query before searching",
|
|
152
|
+
licence: "MIT",
|
|
153
|
+
dims: 512,
|
|
154
|
+
key: "local:clip-b32:512",
|
|
155
|
+
maxTokens: 77,
|
|
156
|
+
vision: "onnx/vision_model_quantized.onnx",
|
|
157
|
+
text: "onnx/text_model_quantized.onnx",
|
|
158
|
+
files: [
|
|
159
|
+
{
|
|
160
|
+
name: "onnx/vision_model_quantized.onnx",
|
|
161
|
+
url: clip("onnx/vision_model_quantized.onnx"),
|
|
162
|
+
sha256: "583fd1110a514667812fee7d684952aaf82a99b959760c8d7dca7e0ab9839299",
|
|
163
|
+
bytes: 89117001
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "onnx/text_model_quantized.onnx",
|
|
167
|
+
url: clip("onnx/text_model_quantized.onnx"),
|
|
168
|
+
sha256: "73baab855d406190da9faa498cfedf65f15cf309f4cc7385b7b032e6d08e5c3a",
|
|
169
|
+
bytes: 64504507
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "tokenizer.json",
|
|
173
|
+
url: clip("tokenizer.json"),
|
|
174
|
+
sha256: "f7f3b7af117d467b58374797691a6438d3e6b9e9cef800dfd5dced7f697a90cd",
|
|
175
|
+
bytes: 2224119
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "tokenizer_config.json",
|
|
179
|
+
url: clip("tokenizer_config.json"),
|
|
180
|
+
sha256: "60ba2912bc6344c94bc16bbdec27fa1209409167b6f2fdf3cfe9e65462ea3967",
|
|
181
|
+
bytes: 775
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
var DEFAULT_IMAGE_MODEL = "clip-b32";
|
|
187
|
+
var imageModel = /* @__PURE__ */ __name((id) => {
|
|
188
|
+
const found = IMAGE_MODELS.find((model) => model.id === id);
|
|
189
|
+
if (!found) {
|
|
190
|
+
throw new CliError("validation_error", `no image model ${id} \u2014 one of: ${IMAGE_MODELS.map((model) => model.id).join(", ")}`);
|
|
191
|
+
}
|
|
192
|
+
return found;
|
|
193
|
+
}, "imageModel");
|
|
194
|
+
var imageModelsDirectory = /* @__PURE__ */ __name((env = process.env) => sharedModelsDirectory("image", env), "imageModelsDirectory");
|
|
195
|
+
var placedImage = /* @__PURE__ */ __name((model, directory) => model.files.map((file) => [file, join(directory, model.id, file.name)]), "placedImage");
|
|
196
|
+
var isImageModelInstalled = /* @__PURE__ */ __name((model, directory) => filesPresent(placedImage(model, directory)), "isImageModelInstalled");
|
|
197
|
+
|
|
198
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/sends/guarded.js
|
|
199
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
200
|
+
var sentIds = /* @__PURE__ */ __name((typed, message) => ({
|
|
201
|
+
messageId: message.id,
|
|
202
|
+
...message.chatId && message.chatId !== typed ? { resultChatId: message.chatId } : {}
|
|
203
|
+
}), "sentIds");
|
|
204
|
+
var current = new AsyncLocalStorage();
|
|
205
|
+
var writesInFlight = new AsyncLocalStorage();
|
|
206
|
+
var parents = /* @__PURE__ */ new WeakMap();
|
|
207
|
+
var stopped = /* @__PURE__ */ new WeakMap();
|
|
208
|
+
var scopesFor = /* @__PURE__ */ __name((scope = writesInFlight.getStore()) => {
|
|
209
|
+
const result = [];
|
|
210
|
+
for (let at = scope; at; at = parents.get(at))
|
|
211
|
+
result.push(at);
|
|
212
|
+
return result;
|
|
213
|
+
}, "scopesFor");
|
|
214
|
+
var withWriteScope = /* @__PURE__ */ __name((scope, body) => {
|
|
215
|
+
const parent = writesInFlight.getStore();
|
|
216
|
+
if (parent && parent !== scope)
|
|
217
|
+
parents.set(scope, parent);
|
|
218
|
+
return writesInFlight.run(scope, body);
|
|
219
|
+
}, "withWriteScope");
|
|
220
|
+
var stopWrites = /* @__PURE__ */ __name((scope, reason) => {
|
|
221
|
+
stopped.set(scope, reason);
|
|
222
|
+
for (const write of scope)
|
|
223
|
+
write.cut();
|
|
224
|
+
}, "stopWrites");
|
|
225
|
+
var refuseStopped = /* @__PURE__ */ __name((scopes) => {
|
|
226
|
+
for (const scope of scopes)
|
|
227
|
+
if (stopped.has(scope))
|
|
228
|
+
throw stopped.get(scope);
|
|
229
|
+
}, "refuseStopped");
|
|
230
|
+
var currentOperation = /* @__PURE__ */ __name(() => current.getStore(), "currentOperation");
|
|
231
|
+
var guardedWrite = /* @__PURE__ */ __name(async (guard, attempt, act, settled = () => ({}), prepare) => {
|
|
232
|
+
const scopes = scopesFor();
|
|
233
|
+
refuseStopped(scopes);
|
|
234
|
+
try {
|
|
235
|
+
await guard.ask?.(attempt);
|
|
236
|
+
refuseStopped(scopes);
|
|
237
|
+
if (guard.reserve) {
|
|
238
|
+
guard.check(attempt, { reserve: false });
|
|
239
|
+
await guard.reserve(attempt);
|
|
240
|
+
} else
|
|
241
|
+
guard.check(attempt);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
guard.record({ ...attempt, outcome: "refused", errorCode: codeOf(error) });
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
refuseStopped(scopes);
|
|
248
|
+
} catch (error) {
|
|
249
|
+
guard.record({ ...attempt, outcome: "failed", errorCode: codeOf(error) });
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
252
|
+
let recorded = false;
|
|
253
|
+
const once = /* @__PURE__ */ __name((entry) => {
|
|
254
|
+
if (recorded)
|
|
255
|
+
return;
|
|
256
|
+
recorded = true;
|
|
257
|
+
guard.record(entry);
|
|
258
|
+
}, "once");
|
|
259
|
+
let cancelled = false;
|
|
260
|
+
const flight = {
|
|
261
|
+
operationId: attempt.operationId,
|
|
262
|
+
preparing: prepare !== void 0,
|
|
263
|
+
cut: /* @__PURE__ */ __name(() => {
|
|
264
|
+
cancelled = true;
|
|
265
|
+
once({
|
|
266
|
+
...attempt,
|
|
267
|
+
outcome: flight.preparing ? "failed" : "outcome_unknown",
|
|
268
|
+
errorCode: flight.preparing ? "timeout" : "outcome_unknown"
|
|
269
|
+
});
|
|
270
|
+
}, "cut")
|
|
271
|
+
};
|
|
272
|
+
for (const scope of scopes)
|
|
273
|
+
scope.add(flight);
|
|
274
|
+
try {
|
|
275
|
+
if (prepare !== void 0)
|
|
276
|
+
await prepare();
|
|
277
|
+
if (cancelled)
|
|
278
|
+
throw new CliError("timeout", "the command ended before sending; nothing was sent", { sent: false });
|
|
279
|
+
flight.preparing = false;
|
|
280
|
+
const done = await current.run(attempt.operationId, act);
|
|
281
|
+
if (cancelled)
|
|
282
|
+
throw new CliError("outcome_unknown", "the command ended with a write in flight; check its result before continuing", { operation_id: attempt.operationId });
|
|
283
|
+
once({ ...attempt, ...settled(done), outcome: "sent" });
|
|
284
|
+
return done;
|
|
285
|
+
} catch (error) {
|
|
286
|
+
const code = codeOf(error);
|
|
287
|
+
once({ ...attempt, outcome: code === "outcome_unknown" ? "outcome_unknown" : "failed", errorCode: code });
|
|
288
|
+
if (code === "outcome_unknown" && error instanceof Error)
|
|
289
|
+
throw new CliError("outcome_unknown", error.message, {
|
|
290
|
+
...error.details,
|
|
291
|
+
operation_id: attempt.operationId,
|
|
292
|
+
retryable: false
|
|
293
|
+
});
|
|
294
|
+
if (flight.preparing && isCliError(error) && error.details.sent === void 0)
|
|
295
|
+
throw new CliError(error.code, error.message, { ...error.details, sent: false });
|
|
296
|
+
throw error;
|
|
297
|
+
} finally {
|
|
298
|
+
for (const scope of scopes)
|
|
299
|
+
scope.delete(flight);
|
|
300
|
+
}
|
|
301
|
+
}, "guardedWrite");
|
|
302
|
+
var codeOf = /* @__PURE__ */ __name((error) => typeof error?.code === "string" ? error.code : "unknown", "codeOf");
|
|
303
|
+
|
|
304
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/models/settings.js
|
|
305
|
+
var MODEL_FIELDS = ["provider", "model", "base_url"];
|
|
306
|
+
var modelSettingsShape = record(pipe(string(), regex(/^[a-z][a-z0-9-]*$/)), strictObject({
|
|
307
|
+
provider: optional(picklist(["off", "openai", "anthropic"])),
|
|
308
|
+
model: optional(pipe(string(), trim(), minLength(1), maxLength(200))),
|
|
309
|
+
base_url: optional(pipe(string(), check((value) => endpoint(value), "use an HTTP/S endpoint without credentials, query or fragment")))
|
|
310
|
+
}));
|
|
311
|
+
var resolveModelSettings = /* @__PURE__ */ __name((prefix, layers, env) => {
|
|
312
|
+
const configured = layers.map(([from, scope]) => [from, scope?.models ?? {}]);
|
|
313
|
+
const purposes = /* @__PURE__ */ new Set([
|
|
314
|
+
"default",
|
|
315
|
+
"analysis",
|
|
316
|
+
"replies",
|
|
317
|
+
...configured.flatMap(([, models2]) => Object.keys(models2))
|
|
318
|
+
]);
|
|
319
|
+
for (const name of Object.keys(env)) {
|
|
320
|
+
const match = new RegExp(`^${prefix}_MODELS_([A-Z][A-Z0-9_]*)_(PROVIDER|MODEL|BASE_URL)$`).exec(name);
|
|
321
|
+
if (match?.[1])
|
|
322
|
+
purposes.add(match[1].toLowerCase().replaceAll("_", "-"));
|
|
323
|
+
}
|
|
324
|
+
const models = {};
|
|
325
|
+
const sources = {};
|
|
326
|
+
for (const purpose of purposes) {
|
|
327
|
+
const resolved = {};
|
|
328
|
+
for (const field of MODEL_FIELDS) {
|
|
329
|
+
const variable = `${prefix}_MODELS_${purpose.replaceAll("-", "_").toUpperCase()}_${field.toUpperCase()}`;
|
|
330
|
+
const candidates = [
|
|
331
|
+
[variable, env[variable]?.trim() || void 0],
|
|
332
|
+
...configured.map(([from, model]) => [
|
|
333
|
+
`${from}: models.${purpose}.${field}`,
|
|
334
|
+
model[purpose]?.[field]
|
|
335
|
+
]),
|
|
336
|
+
...purpose === "default" ? [] : [
|
|
337
|
+
[
|
|
338
|
+
`${prefix}_MODELS_DEFAULT_${field.toUpperCase()}`,
|
|
339
|
+
env[`${prefix}_MODELS_DEFAULT_${field.toUpperCase()}`]?.trim() || void 0
|
|
340
|
+
],
|
|
341
|
+
...configured.map(([from, model]) => [
|
|
342
|
+
`${from}: models.default.${field}`,
|
|
343
|
+
model.default?.[field]
|
|
344
|
+
])
|
|
345
|
+
]
|
|
346
|
+
];
|
|
347
|
+
const selected = candidates.find(([, value]) => value !== void 0);
|
|
348
|
+
if (selected)
|
|
349
|
+
resolved[field] = selected[1];
|
|
350
|
+
sources[`models.${purpose}.${field}`] = selected?.[0] ?? "default";
|
|
351
|
+
}
|
|
352
|
+
if (Object.keys(resolved).length)
|
|
353
|
+
models[purpose] = resolved;
|
|
354
|
+
}
|
|
355
|
+
const checked = safeParse(modelSettingsShape, models);
|
|
356
|
+
if (!checked.success)
|
|
357
|
+
throw new CliError("configuration_error", `models.${getDotPath(checked.issues[0]) ?? "settings"} is invalid`);
|
|
358
|
+
return { models: checked.output, sources };
|
|
359
|
+
}, "resolveModelSettings");
|
|
360
|
+
var modelTarget = /* @__PURE__ */ __name((settings, purpose) => {
|
|
361
|
+
const configured = { ...settings.models?.default, ...settings.models?.[purpose] };
|
|
362
|
+
if (configured.provider === void 0 || configured.provider === "off")
|
|
363
|
+
return void 0;
|
|
364
|
+
if (!configured.model)
|
|
365
|
+
throw new CliError("configuration_error", `set models.${purpose}.model before calling its provider`);
|
|
366
|
+
return {
|
|
367
|
+
provider: configured.provider,
|
|
368
|
+
model: configured.model,
|
|
369
|
+
...configured.base_url === void 0 ? {} : { baseUrl: configured.base_url }
|
|
370
|
+
};
|
|
371
|
+
}, "modelTarget");
|
|
372
|
+
|
|
373
|
+
export {
|
|
374
|
+
modelSettingsShape,
|
|
375
|
+
resolveModelSettings,
|
|
376
|
+
modelTarget,
|
|
377
|
+
envName,
|
|
378
|
+
ancestorValue,
|
|
379
|
+
readOnlyLockOf,
|
|
380
|
+
mailHolderVariable,
|
|
381
|
+
MESSENGER_CHANGE_REFUSAL,
|
|
382
|
+
readOnlyRefusal,
|
|
383
|
+
ANSWER_RESERVE_MS,
|
|
384
|
+
deadlineMargin,
|
|
385
|
+
runBudget,
|
|
386
|
+
sentIds,
|
|
387
|
+
withWriteScope,
|
|
388
|
+
stopWrites,
|
|
389
|
+
currentOperation,
|
|
390
|
+
guardedWrite,
|
|
391
|
+
codeOf,
|
|
392
|
+
IMAGE_MODELS,
|
|
393
|
+
DEFAULT_IMAGE_MODEL,
|
|
394
|
+
imageModel,
|
|
395
|
+
imageModelsDirectory,
|
|
396
|
+
placedImage,
|
|
397
|
+
isImageModelInstalled
|
|
398
|
+
};
|