@wirecat/attio-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 +20 -0
- package/LICENSE +204 -0
- package/README.md +248 -2
- package/contracts/wirecat.json +2321 -0
- package/dist/bin/attio.d.ts +3 -0
- package/dist/bin/attio.d.ts.map +1 -0
- package/dist/bin/attio.js +40 -0
- package/dist/bin/attio.js.map +1 -0
- package/dist/bundle/agent-KLBL3FYD.js +37 -0
- package/dist/bundle/all-profiles-C2NMRQPE.js +320 -0
- package/dist/bundle/anthropic-KOU2ILDK.js +91 -0
- package/dist/bundle/app-server-TINV4NNY.js +249 -0
- package/dist/bundle/attio.js +183 -0
- package/dist/bundle/bun-GVNM6IWY.js +169 -0
- package/dist/bundle/bun-sqlite-IF6B3EQI.js +76 -0
- package/dist/bundle/chunk-2343HKEW.js +362 -0
- package/dist/bundle/chunk-2H2MWGBD.js +988 -0
- package/dist/bundle/chunk-2P7ENEQ7.js +288 -0
- package/dist/bundle/chunk-4EYKJLWI.js +771 -0
- package/dist/bundle/chunk-4HQDT5PF.js +338 -0
- package/dist/bundle/chunk-4QE4L7UL.js +142 -0
- package/dist/bundle/chunk-4XHWGJXT.js +6848 -0
- package/dist/bundle/chunk-5DCRHSBI.js +72 -0
- package/dist/bundle/chunk-5ETXE5KF.js +372 -0
- package/dist/bundle/chunk-5WAGTWCS.js +156 -0
- package/dist/bundle/chunk-6B5PSQQ7.js +319 -0
- package/dist/bundle/chunk-6BVPS2YY.js +230 -0
- package/dist/bundle/chunk-6L5EUGLP.js +188 -0
- package/dist/bundle/chunk-7NFEMS4A.js +1028 -0
- package/dist/bundle/chunk-A7YQTQ5U.js +733 -0
- package/dist/bundle/chunk-AEPOHR4Z.js +82 -0
- package/dist/bundle/chunk-ARRQVUJ2.js +334 -0
- package/dist/bundle/chunk-BHNFRL3H.js +95 -0
- package/dist/bundle/chunk-CBPL3GID.js +23 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DVN54VPI.js +16 -0
- package/dist/bundle/chunk-DW3V7GTY.js +388 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-ETSOG6TZ.js +65288 -0
- package/dist/bundle/chunk-FJV3MO57.js +29 -0
- package/dist/bundle/chunk-HLLRNP2G.js +170 -0
- package/dist/bundle/chunk-HQJ2TABD.js +18 -0
- package/dist/bundle/chunk-ICUXAOEM.js +42063 -0
- package/dist/bundle/chunk-IGALQ74S.js +358 -0
- package/dist/bundle/chunk-IPHUAWFG.js +100 -0
- package/dist/bundle/chunk-IYMWUL6E.js +633 -0
- package/dist/bundle/chunk-JKCXDIGC.js +52 -0
- package/dist/bundle/chunk-JTOKDROB.js +95 -0
- package/dist/bundle/chunk-JZMGOVCZ.js +80 -0
- package/dist/bundle/chunk-KB3YJJPN.js +794 -0
- package/dist/bundle/chunk-KD4EUUER.js +37 -0
- package/dist/bundle/chunk-LB6D4QF2.js +2333 -0
- package/dist/bundle/chunk-LWUJZ2E3.js +108 -0
- package/dist/bundle/chunk-MCQOXTAL.js +53 -0
- package/dist/bundle/chunk-MMGCGPKM.js +3571 -0
- package/dist/bundle/chunk-MXDIXBIV.js +24 -0
- package/dist/bundle/chunk-MYVWV5L5.js +407 -0
- package/dist/bundle/chunk-MZNRIH3T.js +1233 -0
- package/dist/bundle/chunk-NEFILPPV.js +353 -0
- package/dist/bundle/chunk-O6CVJGGL.js +131 -0
- package/dist/bundle/chunk-OPXCRQTV.js +161 -0
- package/dist/bundle/chunk-PKNFA5TU.js +38 -0
- package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
- package/dist/bundle/chunk-PO6PLQYL.js +50 -0
- package/dist/bundle/chunk-PWUQC2GI.js +218 -0
- package/dist/bundle/chunk-QCEEPJNN.js +185 -0
- package/dist/bundle/chunk-QG4WCLGB.js +1332 -0
- package/dist/bundle/chunk-QNQ2OF24.js +9578 -0
- package/dist/bundle/chunk-RCKRXBJF.js +1392 -0
- package/dist/bundle/chunk-RK4GN2II.js +2000 -0
- package/dist/bundle/chunk-RRH7UK7L.js +106 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-S7WJXELM.js +58 -0
- package/dist/bundle/chunk-SBRFKB77.js +1197 -0
- package/dist/bundle/chunk-SP6DPFZ4.js +4072 -0
- package/dist/bundle/chunk-SWJDLFDM.js +557 -0
- package/dist/bundle/chunk-TWCVCW5T.js +66 -0
- package/dist/bundle/chunk-V2R2BJJU.js +63 -0
- package/dist/bundle/chunk-V5K3M7FE.js +78 -0
- package/dist/bundle/chunk-V6ALLFEE.js +1068 -0
- package/dist/bundle/chunk-V6EVJXLO.js +259 -0
- package/dist/bundle/chunk-VJ4CPL6F.js +54 -0
- package/dist/bundle/chunk-VL25A6V2.js +41 -0
- package/dist/bundle/chunk-WBEZZGZE.js +12645 -0
- package/dist/bundle/chunk-WIYAMDPP.js +73 -0
- package/dist/bundle/chunk-WRJGITBX.js +76 -0
- package/dist/bundle/chunk-XHIVZPQ2.js +7 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-XTQIXZVM.js +2788 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YKN4Y35P.js +206 -0
- package/dist/bundle/chunk-ZMJZQGCN.js +46 -0
- package/dist/bundle/chunk-ZPSH27BB.js +274 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-3FR7BK72.js +37 -0
- package/dist/bundle/command-server-entry-4XR4GDS7.js +166 -0
- package/dist/bundle/decode-24EITKP4.js +297 -0
- package/dist/bundle/definitions-HU62PG4L.js +43364 -0
- package/dist/bundle/dispatch-VE6CXCJW.js +411 -0
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/dist-ZSNEZYVF.js +7577 -0
- package/dist/bundle/echarts-LEVLEF7L.js +42501 -0
- package/dist/bundle/embed-G6FGY3VZ.js +38 -0
- package/dist/bundle/embedder-B6LNMXZZ.js +111 -0
- package/dist/bundle/failure-ASVFQXMF.js +25 -0
- package/dist/bundle/first-run-NVXVVALW.js +29 -0
- package/dist/bundle/first-screen-N3IPK5AT.js +37 -0
- package/dist/bundle/instructions-F3KPYMJK.js +11 -0
- package/dist/bundle/mcp-BUCB5ZPE.js +167 -0
- package/dist/bundle/meeting-combined-7FREWXMB.js +24 -0
- package/dist/bundle/meeting-model-GJPAIUQL.js +25 -0
- package/dist/bundle/meeting-semantic-YWY645AH.js +22 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-WVUZSDLD.js +176 -0
- package/dist/bundle/node-sqlite-V4NNKABG.js +74 -0
- package/dist/bundle/oauth-7CENTQIN.js +20 -0
- package/dist/bundle/open-OLTONZBG.js +23 -0
- package/dist/bundle/openai-M6ES74YN.js +238 -0
- package/dist/bundle/process-VFIFK5KO.js +91 -0
- package/dist/bundle/program-N72VUDXM.js +33418 -0
- package/dist/bundle/prompt-TNWPBEBB.js +17 -0
- package/dist/bundle/recognize-PV2WOUWS.js +26 -0
- package/dist/bundle/remote-3F6JACS5.js +31 -0
- package/dist/bundle/rerank-33C67PIV.js +52 -0
- package/dist/bundle/schemas-RLDEALIJ.js +21410 -0
- package/dist/bundle/serve-3DEMACSQ.js +199 -0
- package/dist/bundle/server-AAK2HWQM.js +79 -0
- package/dist/bundle/server-LIBRGMUZ.js +212 -0
- package/dist/bundle/sqlite-runtime-SMAREHYG.js +20 -0
- package/dist/bundle/state-WPHAVJIU.js +36 -0
- package/dist/bundle/store-A7V4FEXE.js +177 -0
- package/dist/bundle/store-PMAPJNXT.js +291 -0
- package/dist/bundle/store-maintenance-command-QHRHAEYN.js +66 -0
- package/dist/bundle/surface-MN4RTNYW.js +65 -0
- package/dist/commands/api.d.ts +12 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +27 -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/crm.d.ts +4 -0
- package/dist/commands/crm.d.ts.map +1 -0
- package/dist/commands/crm.js +66 -0
- package/dist/commands/crm.js.map +1 -0
- package/dist/commands/session.d.ts +7 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +22 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +37 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +31 -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 +43360 -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 +5158 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +383 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +21196 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +10156 -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/generated/wirecat-config.d.ts +15 -0
- package/dist/generated/wirecat-config.d.ts.map +1 -0
- package/dist/generated/wirecat-config.js +328 -0
- package/dist/generated/wirecat-config.js.map +1 -0
- package/dist/hooks.d.ts +3 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +7 -0
- package/dist/hooks.js.map +1 -0
- package/dist/identity.d.ts +33 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +31 -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 +54 -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/package.json +87 -4
- package/skills/attio-cli/SKILL.md +58 -0
- package/skills/attio-cli/references/api/api-activities.md +62 -0
- package/skills/attio-cli/references/api/api-activity-records.md +96 -0
- package/skills/attio-cli/references/api/api-attributes.md +148 -0
- package/skills/attio-cli/references/api/api-call-recordings.md +53 -0
- package/skills/attio-cli/references/api/api-comments.md +36 -0
- package/skills/attio-cli/references/api/api-emails.md +23 -0
- package/skills/attio-cli/references/api/api-entries.md +127 -0
- package/skills/attio-cli/references/api/api-files.md +63 -0
- package/skills/attio-cli/references/api/api-lists.md +44 -0
- package/skills/attio-cli/references/api/api-meetings.md +82 -0
- package/skills/attio-cli/references/api/api-meta.md +8 -0
- package/skills/attio-cli/references/api/api-notes.md +64 -0
- package/skills/attio-cli/references/api/api-objects.md +55 -0
- package/skills/attio-cli/references/api/api-records.md +168 -0
- package/skills/attio-cli/references/api/api-sequences.md +15 -0
- package/skills/attio-cli/references/api/api-sql.md +15 -0
- package/skills/attio-cli/references/api/api-tasks.md +67 -0
- package/skills/attio-cli/references/api/api-threads.md +35 -0
- package/skills/attio-cli/references/api/api-transcripts.md +17 -0
- package/skills/attio-cli/references/api/api-views.md +133 -0
- package/skills/attio-cli/references/api/api-webhooks.md +62 -0
- package/skills/attio-cli/references/api/api-workspace-blocklist.md +39 -0
- package/skills/attio-cli/references/api/api-workspace-members.md +19 -0
- package/skills/attio-cli/references/api.md +35 -0
|
@@ -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-A7YQTQ5U.js";
|
|
6
|
+
import {
|
|
7
|
+
environmentOf,
|
|
8
|
+
readOnlyLockOf
|
|
9
|
+
} from "./chunk-WBEZZGZE.js";
|
|
10
|
+
import {
|
|
11
|
+
array,
|
|
12
|
+
boolean,
|
|
13
|
+
check,
|
|
14
|
+
pipe,
|
|
15
|
+
record,
|
|
16
|
+
safeParse,
|
|
17
|
+
strictObject,
|
|
18
|
+
string
|
|
19
|
+
} from "./chunk-S4UUN6LD.js";
|
|
20
|
+
import {
|
|
21
|
+
CliError
|
|
22
|
+
} from "./chunk-5DCRHSBI.js";
|
|
23
|
+
import {
|
|
24
|
+
__name
|
|
25
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.700.0_@wirecat+cli-base@0.118.0_commander@15.0.0_esbuild@0.28.2_typ_365b7216b918b4ff8396dc0e09311081/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.700.0_@wirecat+cli-base@0.118.0_commander@15.0.0_esbuild@0.28.2_typ_365b7216b918b4ff8396dc0e09311081/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
|
+
};
|
|
@@ -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-ZMJZQGCN.js";
|
|
7
|
+
import {
|
|
8
|
+
require_cross_spawn
|
|
9
|
+
} from "./chunk-D72URWJE.js";
|
|
10
|
+
import {
|
|
11
|
+
loadConfigFile,
|
|
12
|
+
saveConfigFile
|
|
13
|
+
} from "./chunk-XTQIXZVM.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.118.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/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
|
+
};
|