@wirecat/amo-cli 0.2.0 → 0.3.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 +28 -0
- package/README.md +11 -10
- package/contracts/wirecat.json +45 -6
- package/dist/amo/button.d.ts +53 -0
- package/dist/amo/button.d.ts.map +1 -0
- package/dist/amo/button.js +234 -0
- package/dist/amo/button.js.map +1 -0
- package/dist/amo/oauth.d.ts +12 -3
- package/dist/amo/oauth.d.ts.map +1 -1
- package/dist/amo/oauth.js +19 -6
- package/dist/amo/oauth.js.map +1 -1
- package/dist/bin/amo.js +2 -2
- package/dist/bundle/agent-FDNP27SW.js +40 -0
- package/dist/bundle/{all-profiles-3KQVWDV4.js → all-profiles-PPUN52SP.js} +63 -21
- package/dist/bundle/amo.js +28 -26
- package/dist/bundle/{anthropic-N5NOX7K7.js → anthropic-RDNDT6ZP.js} +5 -5
- package/dist/bundle/{app-server-2MST5EZ5.js → app-server-MMALJDBP.js} +79 -68
- package/dist/bundle/{bun-4NHWOFX2.js → bun-Y4FRPURU.js} +2 -2
- package/dist/bundle/{bun-sqlite-DRSXPWPR.js → bun-sqlite-7NXJGZCO.js} +6 -6
- package/dist/bundle/{chunk-GNTJMB6X.js → chunk-2YEDK2XV.js} +4 -4
- package/dist/bundle/chunk-3NDMVXGS.js +80 -0
- package/dist/bundle/{chunk-Y37A3232.js → chunk-3RP57VDS.js} +114 -7
- package/dist/bundle/{chunk-ODNQU7DH.js → chunk-3YOZTGZ6.js} +43 -64
- package/dist/bundle/{chunk-ESZSMZKT.js → chunk-4EYPFFTN.js} +2 -2
- package/dist/bundle/{chunk-5QFHNBGB.js → chunk-4MVTSMWP.js} +2 -2
- package/dist/bundle/{chunk-LJQUYECN.js → chunk-5DPMNYQT.js} +1 -1
- package/dist/bundle/{chunk-7PKFYX7V.js → chunk-5POLHHDZ.js} +8 -8
- package/dist/bundle/{chunk-A33TIM5D.js → chunk-5RXH35ZA.js} +225 -225
- package/dist/bundle/{chunk-BVMNXI53.js → chunk-77FP6AWC.js} +25 -25
- package/dist/bundle/{chunk-L6AFE73L.js → chunk-7E6QSIRQ.js} +1 -1
- package/dist/bundle/chunk-7SBAHYZW.js +734 -0
- package/dist/bundle/{chunk-GQ7VFIYM.js → chunk-7USADF2W.js} +23 -7
- package/dist/bundle/{chunk-AHJ4W2IL.js → chunk-7VSYOMEH.js} +2 -2
- package/dist/bundle/chunk-7Z6NYSAN.js +52 -0
- package/dist/bundle/chunk-AYR6FIXN.js +30 -0
- package/dist/bundle/{chunk-ADEWU4P4.js → chunk-B4ITT55D.js} +1 -1
- package/dist/bundle/{chunk-AUBB72VF.js → chunk-BKTLAXUK.js} +41 -10
- package/dist/bundle/{chunk-63F65DHU.js → chunk-BYVDMPLX.js} +2 -2
- package/dist/bundle/{chunk-V77XNPXG.js → chunk-CQ472K6W.js} +11 -11
- package/dist/bundle/{chunk-FKR3M62D.js → chunk-CUZISGWH.js} +13 -13
- package/dist/bundle/{chunk-LDEBZ3IX.js → chunk-D6UPCAPD.js} +1 -1
- package/dist/bundle/{chunk-P3WQRTYZ.js → chunk-E2DLRLJ5.js} +1 -1
- package/dist/bundle/{chunk-NJYAL3UW.js → chunk-EHULZEXQ.js} +1 -1
- package/dist/bundle/chunk-EKNP326Q.js +108 -0
- package/dist/bundle/{chunk-DJD7TBYG.js → chunk-ELJGALVX.js} +76 -74
- package/dist/bundle/{chunk-RPWAJYI6.js → chunk-FI2TP6TY.js} +3 -3
- package/dist/bundle/{chunk-CDY2NJFE.js → chunk-FPDTIQOK.js} +2 -2
- package/dist/bundle/{chunk-NC76INB2.js → chunk-FPIUFSWK.js} +3099 -2266
- package/dist/bundle/{chunk-SZ2V62HB.js → chunk-GCUFGDKE.js} +2 -2
- package/dist/bundle/{chunk-LRBPT7LQ.js → chunk-GKP7CKW2.js} +6 -6
- package/dist/bundle/chunk-H34RBRS3.js +209 -0
- package/dist/bundle/{chunk-O2UCU52O.js → chunk-HQH4YPO5.js} +134 -569
- package/dist/bundle/{chunk-TNUFLULO.js → chunk-I4QCJZW7.js} +8 -8
- package/dist/bundle/{chunk-DXGGCGRP.js → chunk-IDQ7BNCZ.js} +14 -14
- package/dist/bundle/{chunk-JMDLPBXK.js → chunk-IEAPNTHT.js} +17 -17
- package/dist/bundle/{chunk-XQL7FEF4.js → chunk-ILUREFWJ.js} +9 -9
- package/dist/bundle/{chunk-QRQYUHCZ.js → chunk-IYUWVMGP.js} +12 -12
- package/dist/bundle/chunk-JTFAG3BX.js +338 -0
- package/dist/bundle/{chunk-CHUKWON6.js → chunk-JZ2AITOE.js} +3 -3
- package/dist/bundle/{chunk-JR6TSMFX.js → chunk-KEOKH2OZ.js} +103 -70
- package/dist/bundle/{chunk-UMVRT7VQ.js → chunk-KKXF6TSS.js} +1 -1
- package/dist/bundle/{chunk-5E5R65CA.js → chunk-KTLCQ7GC.js} +2 -2
- package/dist/bundle/{chunk-QDMXZZG4.js → chunk-KZDBO2FT.js} +18 -8
- package/dist/bundle/{chunk-VX37MPTJ.js → chunk-L2ZQDTDU.js} +1 -1
- package/dist/bundle/{chunk-CUZRHF34.js → chunk-L3JDQNBC.js} +4 -4
- package/dist/bundle/{chunk-3IRJDH2U.js → chunk-L72UALL5.js} +2 -100
- package/dist/bundle/{chunk-XRTD2GCU.js → chunk-LOSOWTAZ.js} +19 -258
- package/dist/bundle/{chunk-LGQXGOPJ.js → chunk-LYRICHEK.js} +2 -2
- package/dist/bundle/{chunk-UBRREVLJ.js → chunk-MMOEAH5G.js} +2 -2
- package/dist/bundle/{chunk-EQ7A6NA6.js → chunk-MPXKBF37.js} +1 -1
- package/dist/bundle/{chunk-SMSTGO2G.js → chunk-MYMBPQPQ.js} +4 -4
- package/dist/bundle/chunk-N4A6E2LL.js +559 -0
- package/dist/bundle/{chunk-5HGGG3QO.js → chunk-NJ2LJKNH.js} +16 -3
- package/dist/bundle/{chunk-TGEQNS6G.js → chunk-OMH3WP7F.js} +1 -1
- package/dist/bundle/{chunk-ULXQ5MJM.js → chunk-ORFLQGWH.js} +4 -4
- package/dist/bundle/{chunk-DQV2IKCF.js → chunk-PFZ7WG2B.js} +10 -3
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/{chunk-6RS7OYTD.js → chunk-Q2YVY7IR.js} +3 -3
- package/dist/bundle/{chunk-DOSJONCX.js → chunk-QHA33ZS6.js} +7 -7
- package/dist/bundle/{chunk-JH3UOHRE.js → chunk-QQT7WUR4.js} +4 -4
- package/dist/bundle/{chunk-EROSAUNP.js → chunk-R23DRW2T.js} +5 -5
- package/dist/bundle/{chunk-WCYCUTSK.js → chunk-SBQ5MFHM.js} +7 -7
- package/dist/bundle/{chunk-DAY6TSPF.js → chunk-SJYVKR54.js} +62 -50
- package/dist/bundle/{chunk-T2UDLX76.js → chunk-SJZ52MZE.js} +6 -6
- package/dist/bundle/{chunk-ZM7I52EP.js → chunk-T6D34X5S.js} +3 -4
- package/dist/bundle/{chunk-P5LYZRKW.js → chunk-TCDER3G7.js} +1586 -749
- package/dist/bundle/{chunk-2I5UVMLW.js → chunk-TWZF7VO6.js} +1726 -1159
- package/dist/bundle/{chunk-VVHRQ46X.js → chunk-UA7C57IB.js} +2 -2
- package/dist/bundle/{chunk-5SBLU7D7.js → chunk-UM6SDFB6.js} +1 -1
- package/dist/bundle/{chunk-7U5HJEPZ.js → chunk-UOPP6ORQ.js} +21 -19
- package/dist/bundle/{chunk-U7RLVJ34.js → chunk-UT3ODJMI.js} +4 -4
- package/dist/bundle/{chunk-7GTUZY7M.js → chunk-UZLT6VSP.js} +3 -3
- package/dist/bundle/{chunk-5RLUHTK6.js → chunk-V3ZWYMXT.js} +1 -1
- package/dist/bundle/{chunk-LSND5QYI.js → chunk-VD7HD25M.js} +9 -9
- package/dist/bundle/{chunk-PFO76YFP.js → chunk-VEGNZPQU.js} +18 -18
- package/dist/bundle/{chunk-5Z5PEEKP.js → chunk-VFU25P57.js} +4 -4
- package/dist/bundle/{chunk-4ZAK773N.js → chunk-VJHOBOJR.js} +3 -3
- package/dist/bundle/{chunk-PM77PRB6.js → chunk-VPBSZ4HQ.js} +185 -162
- package/dist/bundle/{chunk-Q2VNBY4Y.js → chunk-VY27K2SH.js} +746 -1205
- package/dist/bundle/{chunk-XEFAMLSD.js → chunk-W4KY5JF5.js} +3 -3
- package/dist/bundle/{chunk-73CXFE36.js → chunk-WBWVBEHH.js} +29 -1
- package/dist/bundle/{chunk-NHXJYS4R.js → chunk-XDT74W5P.js} +32 -28
- package/dist/bundle/{chunk-EPOV5UIO.js → chunk-XI75EKLG.js} +11 -11
- package/dist/bundle/{chunk-CHH42KI4.js → chunk-XM2G62YF.js} +8 -6
- package/dist/bundle/{chunk-5D4Z2B5B.js → chunk-YSOGGUK3.js} +9 -9
- package/dist/bundle/chunk-YVO2YGML.js +353 -0
- package/dist/bundle/{chunk-EQUKVVHX.js → chunk-ZIFEIJRK.js} +7 -7
- package/dist/bundle/{cli-QVWTXADI.js → cli-GAO7LDDA.js} +150 -103
- package/dist/bundle/command-contract-RLIBGIDT.js +39 -0
- package/dist/bundle/{command-server-entry-5VL5U5EE.js → command-server-entry-BCDJP7XE.js} +28 -28
- package/dist/bundle/{decode-SQ5WGNDX.js → decode-OY2GR442.js} +5 -5
- package/dist/bundle/{dispatch-LA4DFXJD.js → dispatch-JWEJCBTF.js} +8 -8
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/{echarts-25Z3RINX.js → echarts-AHEPEA5P.js} +2 -2
- package/dist/bundle/{embed-BNOTNXMA.js → embed-RVSUV54Z.js} +6 -6
- package/dist/bundle/{embedder-BCUT7KKV.js → embedder-GRZXZUXR.js} +9 -9
- package/dist/bundle/{failure-PKAC6XCT.js → failure-DDCSR54L.js} +2 -2
- package/dist/bundle/{first-run-EO5K5GME.js → first-run-G3WI4DH4.js} +12 -12
- package/dist/bundle/first-screen-6MLCMW2U.js +39 -0
- package/dist/bundle/{instructions-VLM3QAYB.js → instructions-NWQC5IP4.js} +1 -1
- package/dist/bundle/{mcp-7ILNMJH5.js → mcp-KGWT6TGO.js} +2 -2
- package/dist/bundle/meeting-combined-SVTFVZNJ.js +24 -0
- package/dist/bundle/{meeting-model-GHMMUQ34.js → meeting-model-I6T5HIZ5.js} +11 -11
- package/dist/bundle/{meeting-semantic-BMP6323L.js → meeting-semantic-47UA5JBF.js} +6 -6
- package/dist/bundle/{node-CT3N3TNL.js → node-7VXN7F4B.js} +2 -2
- package/dist/bundle/{node-sqlite-MELD2SBX.js → node-sqlite-BSEON57L.js} +7 -7
- package/dist/bundle/{oauth-YBH5OKC2.js → oauth-V6UAT4YD.js} +8 -8
- package/dist/bundle/{open-WNSBWTAG.js → open-7LVAY7ZU.js} +5 -5
- package/dist/bundle/{openai-XSNMNLW6.js → openai-OIEH342H.js} +15 -15
- package/dist/bundle/{process-I2QKOMM7.js → process-PTUCNLZ7.js} +1 -1
- package/dist/bundle/{program-G6O3IJR2.js → program-S5WY5IZP.js} +640 -852
- package/dist/bundle/{prompt-SOG4AKPM.js → prompt-7XWTEQ62.js} +5 -5
- package/dist/bundle/{recognize-WMQLWMXH.js → recognize-HGIAJXDR.js} +4 -4
- package/dist/bundle/{remote-4BTFOLFY.js → remote-X4SVEMHS.js} +9 -9
- package/dist/bundle/{rerank-LJ3TWRNV.js → rerank-QWM3DQMU.js} +7 -7
- package/dist/bundle/{serve-B6UANKXN.js → serve-VVG3TXYT.js} +10 -10
- package/dist/bundle/{server-YRH6GJ5Z.js → server-EHYK62BJ.js} +73 -61
- package/dist/bundle/server-WRPTBVNW.js +86 -0
- package/dist/bundle/source-YISMYLBQ.js +44 -0
- package/dist/bundle/{sqlite-runtime-R7QFWFE7.js → sqlite-runtime-MCKXDNYC.js} +6 -6
- package/dist/bundle/{state-DIJ5YUOE.js → state-MYNYQJCT.js} +6 -6
- package/dist/bundle/store-A7R2SZVD.js +34 -0
- package/dist/bundle/{store-MYTYDV6A.js → store-B7O3F3QB.js} +28 -21
- package/dist/bundle/{store-6WFWW7EC.js → store-FPIU2546.js} +24 -23
- package/dist/bundle/store-maintenance-command-D55FRTIK.js +73 -0
- package/dist/bundle/surface-3EX6IGHW.js +72 -0
- package/dist/bundle/writer-XDHZ54JD.js +46 -0
- package/dist/commands/session.d.ts +23 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +115 -45
- package/dist/commands/session.js.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/identity.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +2 -0
- package/dist/reasons.js.map +1 -1
- package/dist/setup/flow.d.ts.map +1 -1
- package/dist/setup/flow.js +74 -4
- package/dist/setup/flow.js.map +1 -1
- package/dist/setup/texts.en.json +22 -1
- package/dist/setup/texts.es.json +22 -1
- package/dist/setup/texts.ru.json +22 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/skills/amo-cli/references/setup.md +8 -2
- package/dist/bundle/command-contract-QBUQBXH7.js +0 -39
- package/dist/bundle/first-screen-GMN3T6RW.js +0 -39
- package/dist/bundle/meeting-combined-LAMF7S2B.js +0 -24
- package/dist/bundle/server-S6XD6V6E.js +0 -77
- package/dist/bundle/source-DGFTA2TN.js +0 -42
- package/dist/bundle/store-CHWY2USQ.js +0 -32
- package/dist/bundle/store-maintenance-command-B5TMKFMG.js +0 -68
- package/dist/bundle/writer-GP7VIMAU.js +0 -44
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
throughWrapper
|
|
5
|
+
} from "./chunk-AYR6FIXN.js";
|
|
6
|
+
import {
|
|
7
|
+
environmentOf,
|
|
8
|
+
readOnlyLockOf
|
|
9
|
+
} from "./chunk-VPBSZ4HQ.js";
|
|
10
|
+
import {
|
|
11
|
+
array,
|
|
12
|
+
boolean,
|
|
13
|
+
check,
|
|
14
|
+
pipe,
|
|
15
|
+
record,
|
|
16
|
+
safeParse,
|
|
17
|
+
strictObject,
|
|
18
|
+
string
|
|
19
|
+
} from "./chunk-BKTLAXUK.js";
|
|
20
|
+
import {
|
|
21
|
+
CliError
|
|
22
|
+
} from "./chunk-GCUFGDKE.js";
|
|
23
|
+
import {
|
|
24
|
+
__name
|
|
25
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/background/relay.js
|
|
28
|
+
import { createHash } from "node:crypto";
|
|
29
|
+
import { chmodSync, lstatSync, mkdirSync, rmSync } from "node:fs";
|
|
30
|
+
import { createConnection, createServer } from "node:net";
|
|
31
|
+
import { tmpdir } from "node:os";
|
|
32
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
33
|
+
import { PassThrough, Writable } from "node:stream";
|
|
34
|
+
var RELAY_PROTOCOL = 1;
|
|
35
|
+
var requestSchema = strictObject({
|
|
36
|
+
argv: array(string()),
|
|
37
|
+
env: record(string(), string()),
|
|
38
|
+
cwd: pipe(string(), check((path) => isAbsolute(path))),
|
|
39
|
+
tty: boolean(),
|
|
40
|
+
stdinTty: boolean()
|
|
41
|
+
});
|
|
42
|
+
var MAX_CLIENT_LINE = 1024 * 1024;
|
|
43
|
+
var MAX_SERVE_LINE = 64 * 1024 * 1024;
|
|
44
|
+
var MAX_SOCKET_PATH = 100;
|
|
45
|
+
var relayPath = /* @__PURE__ */ __name((lockPath) => {
|
|
46
|
+
const beside = lockPath.replace(/\.lock$/, ".sock");
|
|
47
|
+
if (beside.length <= MAX_SOCKET_PATH)
|
|
48
|
+
return beside;
|
|
49
|
+
const hash = createHash("sha256").update(beside).digest("hex").slice(0, 16);
|
|
50
|
+
const name = join(`wirecat-relay-${process.getuid?.() ?? "user"}`, `${hash}.sock`);
|
|
51
|
+
const temporary = join(tmpdir(), name);
|
|
52
|
+
if (temporary.length <= MAX_SOCKET_PATH || process.platform === "win32")
|
|
53
|
+
return temporary;
|
|
54
|
+
return join("/tmp", name);
|
|
55
|
+
}, "relayPath");
|
|
56
|
+
var privateDirectory = /* @__PURE__ */ __name((dir) => {
|
|
57
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
58
|
+
const stat = lstatSync(dir);
|
|
59
|
+
const mine = process.getuid === void 0 || stat.uid === process.getuid();
|
|
60
|
+
if (!stat.isDirectory() || !mine || (stat.mode & 63) !== 0) {
|
|
61
|
+
throw new CliError("permission_error", `${dir} is not a private directory, so serve does not listen there`);
|
|
62
|
+
}
|
|
63
|
+
}, "privateDirectory");
|
|
64
|
+
var lines = /* @__PURE__ */ __name((socket, max, onLine, onTooLong) => {
|
|
65
|
+
let buffered = "";
|
|
66
|
+
socket.setEncoding("utf8");
|
|
67
|
+
socket.on("data", (chunk) => {
|
|
68
|
+
buffered += chunk;
|
|
69
|
+
for (let end = buffered.indexOf("\n"); end >= 0; end = buffered.indexOf("\n")) {
|
|
70
|
+
const line = buffered.slice(0, end);
|
|
71
|
+
buffered = buffered.slice(end + 1);
|
|
72
|
+
if (line)
|
|
73
|
+
onLine(line);
|
|
74
|
+
}
|
|
75
|
+
if (buffered.length > max)
|
|
76
|
+
onTooLong();
|
|
77
|
+
});
|
|
78
|
+
}, "lines");
|
|
79
|
+
var frame = /* @__PURE__ */ __name((socket, value) => {
|
|
80
|
+
if (!socket.destroyed)
|
|
81
|
+
socket.write(`${JSON.stringify(value)}
|
|
82
|
+
`);
|
|
83
|
+
}, "frame");
|
|
84
|
+
var listenRelay = /* @__PURE__ */ __name(async (path, run) => {
|
|
85
|
+
privateDirectory(dirname(path));
|
|
86
|
+
rmSync(path, { force: true });
|
|
87
|
+
const open = /* @__PURE__ */ new Set();
|
|
88
|
+
const running = /* @__PURE__ */ new Set();
|
|
89
|
+
const server = createServer((socket) => {
|
|
90
|
+
open.add(socket);
|
|
91
|
+
const stop = new AbortController();
|
|
92
|
+
const stdin = new PassThrough();
|
|
93
|
+
let started = false;
|
|
94
|
+
socket.on("error", () => {
|
|
95
|
+
});
|
|
96
|
+
socket.on("close", () => {
|
|
97
|
+
open.delete(socket);
|
|
98
|
+
stop.abort(new CliError("cancelled", "the client went away", { retryable: false }));
|
|
99
|
+
if (!stdin.writableEnded)
|
|
100
|
+
stdin.end();
|
|
101
|
+
});
|
|
102
|
+
lines(socket, MAX_CLIENT_LINE, (line) => {
|
|
103
|
+
let message;
|
|
104
|
+
try {
|
|
105
|
+
message = JSON.parse(line);
|
|
106
|
+
} catch {
|
|
107
|
+
socket.destroy();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (!started) {
|
|
111
|
+
started = true;
|
|
112
|
+
if (message.v !== RELAY_PROTOCOL) {
|
|
113
|
+
frame(socket, { diagnostic: `serve speaks relay protocol ${RELAY_PROTOCOL}; restart it`, exit: 1 });
|
|
114
|
+
socket.end();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const parsed = safeParse(requestSchema, message.run);
|
|
118
|
+
if (!parsed.success) {
|
|
119
|
+
socket.destroy();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
stdin.isTTY = parsed.output.stdinTty;
|
|
123
|
+
if (parsed.output.stdinTty)
|
|
124
|
+
stdin.end();
|
|
125
|
+
const job = serve(socket, parsed.output, stdin, stop.signal, run);
|
|
126
|
+
running.add(job);
|
|
127
|
+
void job.then(() => running.delete(job), () => running.delete(job));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (typeof message.stdin === "string" && !stdin.writableEnded)
|
|
131
|
+
stdin.write(Buffer.from(message.stdin, "base64"));
|
|
132
|
+
if (message.stdinEnd === true && !stdin.writableEnded)
|
|
133
|
+
stdin.end();
|
|
134
|
+
}, () => socket.destroy());
|
|
135
|
+
});
|
|
136
|
+
await new Promise((resolve, reject) => {
|
|
137
|
+
server.once("error", reject);
|
|
138
|
+
server.listen(path, () => {
|
|
139
|
+
server.off("error", reject);
|
|
140
|
+
resolve();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
chmodSync(path, 384);
|
|
144
|
+
return {
|
|
145
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
146
|
+
for (const socket of open)
|
|
147
|
+
socket.destroy();
|
|
148
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
149
|
+
await Promise.allSettled(running);
|
|
150
|
+
rmSync(path, { force: true });
|
|
151
|
+
}, "close")
|
|
152
|
+
};
|
|
153
|
+
}, "listenRelay");
|
|
154
|
+
var serve = /* @__PURE__ */ __name(async (socket, request, stdin, signal, run) => {
|
|
155
|
+
const streams = {
|
|
156
|
+
data: /* @__PURE__ */ __name((text) => frame(socket, { data: text }), "data"),
|
|
157
|
+
diagnostic: /* @__PURE__ */ __name((text) => frame(socket, { diagnostic: text }), "diagnostic"),
|
|
158
|
+
progress: /* @__PURE__ */ __name((text) => frame(socket, { progress: text }), "progress")
|
|
159
|
+
};
|
|
160
|
+
const stdout = new Writable({
|
|
161
|
+
write: /* @__PURE__ */ __name((chunk, _encoding, done) => {
|
|
162
|
+
frame(socket, { raw: Buffer.from(chunk).toString("base64") });
|
|
163
|
+
done();
|
|
164
|
+
}, "write")
|
|
165
|
+
});
|
|
166
|
+
let code = 1;
|
|
167
|
+
try {
|
|
168
|
+
code = await run(request, { streams, stdin, stdout, signal });
|
|
169
|
+
} finally {
|
|
170
|
+
frame(socket, { exit: code });
|
|
171
|
+
socket.end();
|
|
172
|
+
}
|
|
173
|
+
}, "serve");
|
|
174
|
+
var relayCommand = /* @__PURE__ */ __name((path, request, options) => new Promise((resolve, reject) => {
|
|
175
|
+
const { streams, stdin, stdout, signal, deadlineMs, writes, holder, listens = false } = options;
|
|
176
|
+
const socket = createConnection(path);
|
|
177
|
+
let connected = false;
|
|
178
|
+
let settled = false;
|
|
179
|
+
let timer;
|
|
180
|
+
const forward = /* @__PURE__ */ __name((chunk) => frame(socket, { stdin: Buffer.from(chunk).toString("base64") }), "forward");
|
|
181
|
+
const ended = /* @__PURE__ */ __name(() => frame(socket, { stdinEnd: true }), "ended");
|
|
182
|
+
const brokenPipe = /* @__PURE__ */ __name((error) => {
|
|
183
|
+
if (error.code === "EPIPE")
|
|
184
|
+
finish({ code: 0 });
|
|
185
|
+
}, "brokenPipe");
|
|
186
|
+
const finish = /* @__PURE__ */ __name((outcome) => {
|
|
187
|
+
if (settled)
|
|
188
|
+
return;
|
|
189
|
+
settled = true;
|
|
190
|
+
if (timer)
|
|
191
|
+
clearTimeout(timer);
|
|
192
|
+
stdout.off("error", brokenPipe);
|
|
193
|
+
signal.removeEventListener("abort", aborted);
|
|
194
|
+
stdin.off("data", forward).off("end", ended);
|
|
195
|
+
stdin.pause();
|
|
196
|
+
socket.destroy();
|
|
197
|
+
if ("code" in outcome)
|
|
198
|
+
resolve(outcome.code);
|
|
199
|
+
else
|
|
200
|
+
reject(outcome.error);
|
|
201
|
+
}, "finish");
|
|
202
|
+
const stopped = /* @__PURE__ */ __name(() => writes ? new CliError("outcome_unknown", `${holder} stopped before the command finished; it may have run \u2014 check before repeating it`, { retryable: false }) : new CliError("provider_unavailable", `${holder} stopped before the command finished`, { retryable: true }), "stopped");
|
|
203
|
+
const aborted = /* @__PURE__ */ __name(() => finish(listens ? { code: 0 } : { error: signal.reason }), "aborted");
|
|
204
|
+
if (signal.aborted)
|
|
205
|
+
return aborted();
|
|
206
|
+
signal.addEventListener("abort", aborted, { once: true });
|
|
207
|
+
stdout.on("error", brokenPipe);
|
|
208
|
+
if (deadlineMs !== void 0)
|
|
209
|
+
timer = setTimeout(() => finish({ error: stopped() }), deadlineMs);
|
|
210
|
+
socket.on("connect", () => {
|
|
211
|
+
connected = true;
|
|
212
|
+
frame(socket, { v: RELAY_PROTOCOL, run: request });
|
|
213
|
+
if (request.stdinTty)
|
|
214
|
+
ended();
|
|
215
|
+
else {
|
|
216
|
+
stdin.on("data", forward).once("end", ended);
|
|
217
|
+
stdin.resume();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
socket.on("error", (error) => {
|
|
221
|
+
if (connected)
|
|
222
|
+
return finish({ error: stopped() });
|
|
223
|
+
finish({
|
|
224
|
+
error: new CliError("provider_unavailable", `${holder} holds the connection but does not answer its relay (${error.code ?? error.message}) \u2014 restart it`, { retryable: false, sent: false })
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
socket.on("close", () => finish({ error: stopped() }));
|
|
228
|
+
lines(socket, MAX_SERVE_LINE, (line) => {
|
|
229
|
+
let message;
|
|
230
|
+
try {
|
|
231
|
+
message = JSON.parse(line);
|
|
232
|
+
} catch {
|
|
233
|
+
return finish({ error: stopped() });
|
|
234
|
+
}
|
|
235
|
+
if (typeof message.data === "string")
|
|
236
|
+
streams.data(message.data);
|
|
237
|
+
if (typeof message.diagnostic === "string")
|
|
238
|
+
streams.diagnostic(message.diagnostic);
|
|
239
|
+
if (typeof message.progress === "string")
|
|
240
|
+
streams.progress?.(message.progress);
|
|
241
|
+
if (typeof message.raw === "string")
|
|
242
|
+
stdout.write(Buffer.from(message.raw, "base64"));
|
|
243
|
+
if (typeof message.exit === "number")
|
|
244
|
+
finish({ code: message.exit });
|
|
245
|
+
}, () => finish({ error: stopped() }));
|
|
246
|
+
}), "relayCommand");
|
|
247
|
+
|
|
248
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-relay.js
|
|
249
|
+
var lentConnection = /* @__PURE__ */ __name((connection, watchers) => throughWrapper(connection, {
|
|
250
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
251
|
+
}, "close"),
|
|
252
|
+
feed: void 0,
|
|
253
|
+
storedChats: void 0,
|
|
254
|
+
listen: void 0,
|
|
255
|
+
listenHistory: void 0,
|
|
256
|
+
...connection.watch && watchers ? {
|
|
257
|
+
// A watcher that throws (its output limit, a closed reader) ends its own watch, never serve's.
|
|
258
|
+
watch: /* @__PURE__ */ __name(async (onEvent, signal, onReady) => {
|
|
259
|
+
let watcher;
|
|
260
|
+
try {
|
|
261
|
+
await new Promise((resolve, reject) => {
|
|
262
|
+
watcher = /* @__PURE__ */ __name((event) => {
|
|
263
|
+
try {
|
|
264
|
+
onEvent(event);
|
|
265
|
+
} catch (error) {
|
|
266
|
+
reject(error);
|
|
267
|
+
}
|
|
268
|
+
}, "watcher");
|
|
269
|
+
watchers.add(watcher);
|
|
270
|
+
signal.addEventListener("abort", () => resolve(), { once: true });
|
|
271
|
+
onReady?.();
|
|
272
|
+
if (signal.aborted)
|
|
273
|
+
resolve();
|
|
274
|
+
});
|
|
275
|
+
} finally {
|
|
276
|
+
if (watcher)
|
|
277
|
+
watchers.delete(watcher);
|
|
278
|
+
}
|
|
279
|
+
}, "watch")
|
|
280
|
+
} : { watch: void 0 }
|
|
281
|
+
}), "lentConnection");
|
|
282
|
+
var serveRelay = /* @__PURE__ */ __name((command, messenger) => {
|
|
283
|
+
let held;
|
|
284
|
+
let relay;
|
|
285
|
+
const watchers = /* @__PURE__ */ new Set();
|
|
286
|
+
const borrowed = /* @__PURE__ */ __name(() => {
|
|
287
|
+
const connection = held;
|
|
288
|
+
if (!connection)
|
|
289
|
+
throw new CliError("provider_unavailable", "serve is not connected yet", { retryable: true });
|
|
290
|
+
return lentConnection(connection, watchers);
|
|
291
|
+
}, "borrowed");
|
|
292
|
+
return {
|
|
293
|
+
messenger: {
|
|
294
|
+
...messenger,
|
|
295
|
+
connect: /* @__PURE__ */ __name(async (...args) => {
|
|
296
|
+
held = await messenger.connect(...args);
|
|
297
|
+
return held;
|
|
298
|
+
}, "connect")
|
|
299
|
+
},
|
|
300
|
+
arrived: /* @__PURE__ */ __name((event) => {
|
|
301
|
+
for (const watcher of watchers)
|
|
302
|
+
watcher(event);
|
|
303
|
+
}, "arrived"),
|
|
304
|
+
/** Listens beside the lock; the address goes into it, which is how a client finds it. */
|
|
305
|
+
open: /* @__PURE__ */ __name(async (lockPath, profile) => {
|
|
306
|
+
const environment = environmentOf(command);
|
|
307
|
+
const runCommand = environment.runCommand;
|
|
308
|
+
if (!runCommand)
|
|
309
|
+
return void 0;
|
|
310
|
+
const readOnly = readOnlyLockOf(messenger.app, environment.env ?? process.env);
|
|
311
|
+
const path = relayPath(lockPath);
|
|
312
|
+
relay = await listenRelay(path, (request, io) => runCommand(request.argv, {
|
|
313
|
+
env: {
|
|
314
|
+
...request.env,
|
|
315
|
+
...readOnly ? { [`${messenger.app.envPrefix}_READ_ONLY`]: "1" } : {}
|
|
316
|
+
},
|
|
317
|
+
streams: io.streams,
|
|
318
|
+
stdin: io.stdin,
|
|
319
|
+
stdout: io.stdout,
|
|
320
|
+
tty: request.tty,
|
|
321
|
+
signal: io.signal,
|
|
322
|
+
answer: /* @__PURE__ */ __name(() => null, "answer"),
|
|
323
|
+
relayed: { profile, cwd: request.cwd, connection: borrowed }
|
|
324
|
+
}));
|
|
325
|
+
return { path, protocol: RELAY_PROTOCOL };
|
|
326
|
+
}, "open"),
|
|
327
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
328
|
+
await relay?.close();
|
|
329
|
+
}, "close")
|
|
330
|
+
};
|
|
331
|
+
}, "serveRelay");
|
|
332
|
+
|
|
333
|
+
export {
|
|
334
|
+
RELAY_PROTOCOL,
|
|
335
|
+
relayCommand,
|
|
336
|
+
lentConnection,
|
|
337
|
+
serveRelay
|
|
338
|
+
};
|
|
@@ -4,17 +4,17 @@ import {
|
|
|
4
4
|
ENTITIES,
|
|
5
5
|
LOST,
|
|
6
6
|
WON
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-D6UPCAPD.js";
|
|
8
8
|
import {
|
|
9
9
|
fieldNamed,
|
|
10
10
|
foldFieldName,
|
|
11
11
|
optionOf,
|
|
12
12
|
values_exports
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TWZF7VO6.js";
|
|
14
14
|
import {
|
|
15
15
|
CliError,
|
|
16
16
|
isCliError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-GCUFGDKE.js";
|
|
18
18
|
import {
|
|
19
19
|
__name
|
|
20
20
|
} from "./chunk-ZVVMGPBJ.js";
|