@wirecat/drive-cli 0.65.0 → 0.66.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/contracts/wirecat.json +2871 -0
- package/dist/bin/drive.js +2 -2
- package/dist/bin/drive.js.map +1 -1
- package/dist/browse.d.ts +1 -1
- package/dist/browse.d.ts.map +1 -1
- package/dist/browse.js +1 -1
- package/dist/bundle/{all-profiles-PD7GJHFA.js → all-profiles-WCQLIHUG.js} +14 -14
- package/dist/bundle/{anthropic-PJKFON5H.js → anthropic-5RJMB6O7.js} +20 -13
- package/dist/bundle/{app-server-6ELQA6FJ.js → app-server-3RGYXPKG.js} +67 -56
- package/dist/bundle/{bun-P54TGES2.js → bun-L34VEKGG.js} +2 -2
- package/dist/bundle/{bun-sqlite-TND5ZRJH.js → bun-sqlite-H6IAXQXI.js} +9 -9
- package/dist/bundle/{chunk-VHQYWFWV.js → chunk-2AF77WMH.js} +1 -1
- package/dist/bundle/{chunk-CWLL63JD.js → chunk-2S3E2HVV.js} +17 -17
- package/dist/bundle/{chunk-I272E6UR.js → chunk-3NYH756U.js} +49 -117
- package/dist/bundle/{chunk-UTNRBOEN.js → chunk-3QFUDXMQ.js} +2 -2
- package/dist/bundle/{chunk-RNHGQ35R.js → chunk-3SDJIMZB.js} +1 -1
- package/dist/bundle/{chunk-NQ5XMSLA.js → chunk-4UHBJSMI.js} +22086 -29123
- package/dist/bundle/{chunk-OWMZUWCM.js → chunk-5HVJK3ZJ.js} +6 -14
- package/dist/bundle/chunk-5K54RZBK.js +70 -0
- package/dist/bundle/{chunk-SIWXYB4E.js → chunk-5PLINHEY.js} +2987 -2717
- package/dist/bundle/{chunk-O7ZDCOZE.js → chunk-5VDVGDOC.js} +1 -1
- package/dist/bundle/{chunk-B2LPCHQN.js → chunk-5XLU4NN6.js} +4 -4
- package/dist/bundle/{chunk-5XSBCMAF.js → chunk-6UJCCOZC.js} +4 -4
- package/dist/bundle/{chunk-7AQGVX5O.js → chunk-6X3KUFRQ.js} +60 -29
- package/dist/bundle/{chunk-WRMJN6UQ.js → chunk-7EP4AU6A.js} +3 -3
- package/dist/bundle/{chunk-GW3LBY3T.js → chunk-7LT2G5BC.js} +146 -133
- package/dist/bundle/{chunk-ZILALBYQ.js → chunk-7ZGJRVBH.js} +7 -5
- package/dist/bundle/{chunk-PLP5527C.js → chunk-ALE67WRR.js} +5 -5
- package/dist/bundle/{chunk-EHU6EYGO.js → chunk-AP4MX247.js} +12 -12
- package/dist/bundle/{chunk-NI5PD5KM.js → chunk-BIJW6AYA.js} +14124 -12049
- package/dist/bundle/{chunk-54V4H6PM.js → chunk-BQXSE645.js} +12 -12
- package/dist/bundle/{chunk-EM7NL5ES.js → chunk-COGWKO2T.js} +3 -3
- package/dist/bundle/{chunk-II4S2DBJ.js → chunk-D4MIMH2N.js} +12 -6
- package/dist/bundle/{chunk-42G2XNPN.js → chunk-D7KOAPG6.js} +2 -2
- package/dist/bundle/{chunk-NQRTKYJB.js → chunk-E2F2XIX6.js} +47 -80
- package/dist/bundle/{chunk-VDZY3L7U.js → chunk-FA2TNA5X.js} +1 -1
- package/dist/bundle/{chunk-A4QNADEX.js → chunk-FHBTQPA3.js} +49 -49
- package/dist/bundle/{chunk-7TAP7Y2E.js → chunk-FKKPVPZR.js} +196 -112
- package/dist/bundle/{chunk-2AFI4KGI.js → chunk-G4TNKBDX.js} +7 -7
- package/dist/bundle/{chunk-ECEP4SO3.js → chunk-GVA3KTCD.js} +10 -10
- package/dist/bundle/{chunk-PHOL2DZM.js → chunk-GY4DAJSK.js} +34 -5
- package/dist/bundle/{chunk-Z2ADO6UA.js → chunk-H7XL6WTW.js} +2 -2
- package/dist/bundle/{chunk-SE352DBY.js → chunk-HHRJPLFO.js} +1 -1
- package/dist/bundle/{chunk-WRAUO5EJ.js → chunk-HPKE2GDP.js} +45 -22
- package/dist/bundle/{chunk-D7WB54P7.js → chunk-HPSHQVJU.js} +540 -456
- package/dist/bundle/{chunk-4Y5YBFMS.js → chunk-HQBLJLYH.js} +7 -7
- package/dist/bundle/{chunk-IMHW7VIV.js → chunk-I5R5CMQR.js} +5 -5
- package/dist/bundle/{chunk-ELJUBPY4.js → chunk-IIHZTV6V.js} +1 -1
- package/dist/bundle/{chunk-M7ELUGU6.js → chunk-IRNDYNQX.js} +4 -4
- package/dist/bundle/{chunk-TTP4NOP3.js → chunk-JCHF7LZT.js} +4 -4
- package/dist/bundle/{chunk-3HXNDF6Q.js → chunk-JHMEETXI.js} +2 -2
- package/dist/bundle/{chunk-4EDWLR22.js → chunk-JLCR24UM.js} +1 -1
- package/dist/bundle/{chunk-6DCLZLGX.js → chunk-JQXK3M5M.js} +1 -1
- package/dist/bundle/{chunk-EZ2OLYEK.js → chunk-KOY5HUBY.js} +14 -5
- package/dist/bundle/{chunk-IBO23OID.js → chunk-KRG5X5PH.js} +2 -2
- package/dist/bundle/{chunk-FA6JNXCC.js → chunk-LVAPSAHF.js} +8 -8
- package/dist/bundle/{chunk-ZR2EJPMQ.js → chunk-M7543RUJ.js} +18 -15
- package/dist/bundle/{chunk-A27UVLPK.js → chunk-MZWXTJ4O.js} +3 -3
- package/dist/bundle/{chunk-XPWZSW6Y.js → chunk-NK4GVFJH.js} +4 -4
- package/dist/bundle/chunk-NYECVHFH.js +10283 -0
- package/dist/bundle/{chunk-W2XY6C5S.js → chunk-NYZS2LKF.js} +2 -2
- package/dist/bundle/{chunk-4AOINPN2.js → chunk-O53WLYX3.js} +8 -2
- package/dist/bundle/{chunk-RX5CJ55S.js → chunk-OIF4B526.js} +1 -1
- package/dist/bundle/{chunk-SS4LKLD7.js → chunk-OT7SQQJK.js} +371 -362
- package/dist/bundle/chunk-OZOQLAWK.js +72 -0
- package/dist/bundle/{chunk-DA63E2UM.js → chunk-P7HQFII6.js} +18 -15
- package/dist/bundle/{chunk-MCPOZNWG.js → chunk-PJGOQSE5.js} +1 -1
- package/dist/bundle/{chunk-F56DRBGY.js → chunk-PKM55ZRR.js} +75 -20
- package/dist/bundle/{chunk-SNLSEYJO.js → chunk-PUMDOCAF.js} +1 -1
- package/dist/bundle/{chunk-LMKPP2JP.js → chunk-QF7VL4C3.js} +1 -1
- package/dist/bundle/{chunk-D6Z43SOG.js → chunk-QJ57PV55.js} +383 -361
- package/dist/bundle/{chunk-EU5MD24W.js → chunk-QSELSDWE.js} +13 -13
- package/dist/bundle/{chunk-TMHF4BCL.js → chunk-SOOU5WO6.js} +2 -2
- package/dist/bundle/{chunk-3ONWN3IA.js → chunk-SZ6JFOL4.js} +137 -45
- package/dist/bundle/{chunk-WVJHZIDH.js → chunk-T3ULDA7C.js} +3 -3
- package/dist/bundle/{chunk-XYE7XZPB.js → chunk-TAHISPDE.js} +5 -5
- package/dist/bundle/{chunk-HP3NT6JJ.js → chunk-TYLEICTX.js} +3 -3
- package/dist/bundle/{chunk-Y5PKRITX.js → chunk-UAKX6DP4.js} +5 -5
- package/dist/bundle/{chunk-VLXWAH5E.js → chunk-UG3GHFGY.js} +4 -4
- package/dist/bundle/{chunk-X7YGGWXI.js → chunk-ULXEW6FT.js} +3 -2
- package/dist/bundle/{chunk-JPPPLKAO.js → chunk-UNTIVT47.js} +1 -2
- package/dist/bundle/{chunk-SEQWBZYH.js → chunk-UQPW42HF.js} +1 -1
- package/dist/bundle/{chunk-JMJIH6JH.js → chunk-V2WXTILT.js} +6 -6
- package/dist/bundle/{chunk-TOVWMURV.js → chunk-VQKNKJYL.js} +22 -7
- package/dist/bundle/{chunk-OFJXHEFT.js → chunk-VR3YKXHL.js} +93 -31
- package/dist/bundle/{chunk-VMAMRFFC.js → chunk-VUUPFDRU.js} +26 -27
- package/dist/bundle/{chunk-FBHSWQU7.js → chunk-WYTYHUFH.js} +319 -102
- package/dist/bundle/{chunk-ZD4MB7NH.js → chunk-XLGDNI4S.js} +1 -1
- package/dist/bundle/{chunk-O6K2E7OA.js → chunk-XVZNFA2P.js} +1507 -1107
- package/dist/bundle/chunk-Y5U4HIZS.js +71 -0
- package/dist/bundle/chunk-YTIPTHEE.js +47 -0
- package/dist/bundle/cli-KW6QQVS5.js +1101 -0
- package/dist/bundle/command-contract-CE543JBN.js +41 -0
- package/dist/bundle/{command-server-entry-36JXYIJB.js → command-server-entry-OC4E4DED.js} +31 -30
- package/dist/bundle/{decode-T5ZW57WZ.js → decode-AH5ZLLDK.js} +8 -8
- package/dist/bundle/{dispatch-RMA2XFYA.js → dispatch-CDWZZ54Q.js} +9 -9
- package/dist/bundle/drive.js +13 -13
- package/dist/bundle/{echarts-KQ44LPSF.js → echarts-VC7MTXWY.js} +2 -2
- package/dist/bundle/{embed-Q7XST53J.js → embed-EPSQY6QG.js} +9 -9
- package/dist/bundle/{embedder-RWZSBVW2.js → embedder-TK4U4TJR.js} +12 -12
- package/dist/bundle/entry-3VN23M7M.js +25 -0
- package/dist/bundle/{failure-7NP4QPIN.js → failure-WSVZOPFE.js} +4 -4
- package/dist/bundle/first-run-7ZYJ7EB3.js +30 -0
- package/dist/bundle/first-screen-CZDH7QY3.js +39 -0
- package/dist/bundle/google-OBZMWA7J.js +45 -0
- package/dist/bundle/{google-api-P5DRHD7L.js → google-api-AV4X2JH3.js} +68 -63
- package/dist/bundle/grants-WTRLN4ZI.js +111 -0
- package/dist/bundle/{identity-VDV6CHRW.js → identity-CGHHF7AK.js} +8 -6
- package/dist/bundle/{instructions-Q45FVY6H.js → instructions-24PHDBBE.js} +1 -1
- package/dist/bundle/{login-XKN3NI6X.js → login-XHFESAFM.js} +73 -70
- package/dist/bundle/{mcp-7KQUJNFN.js → mcp-M5YCSWJJ.js} +2 -2
- package/dist/bundle/{node-MSW565D3.js → node-GIDULTV5.js} +2 -2
- package/dist/bundle/{node-sqlite-S74XVVHL.js → node-sqlite-LINBOAWK.js} +10 -10
- package/dist/bundle/oauth-JHUX3KE3.js +22 -0
- package/dist/bundle/{open-P7UQG7XJ.js → open-RYFKPNCJ.js} +8 -8
- package/dist/bundle/{openai-DDHJ57KZ.js → openai-Q7YYUHJF.js} +28 -21
- package/dist/bundle/{process-NMUB5SHK.js → process-VPIZTIJR.js} +1 -1
- package/dist/bundle/{program-PJNWP6JW.js → program-IUXFRBZA.js} +213 -555
- package/dist/bundle/{prompt-VOSMK4C2.js → prompt-LF4KX3XL.js} +8 -8
- package/dist/bundle/{reasons-KDAXOC5S.js → reasons-JPYOU5GV.js} +5 -5
- package/dist/bundle/{recognize-GZIY63HS.js → recognize-KEWTJXFH.js} +7 -7
- package/dist/bundle/{remote-V3YGN7LN.js → remote-HGGLB76S.js} +13 -10
- package/dist/bundle/{rerank-XRU6AVN7.js → rerank-TDUKETFT.js} +10 -10
- package/dist/bundle/{serve-NDOAFA57.js → serve-XFYMKW5W.js} +12 -12
- package/dist/bundle/server-BDEV3CZJ.js +74 -0
- package/dist/bundle/{server-BKGWJYMC.js → server-PXIPSGFP.js} +47 -45
- package/dist/bundle/{services-TYDMFQCA.js → services-2BOCGMJU.js} +44 -34
- package/dist/bundle/{sqlite-runtime-UAFJKSJR.js → sqlite-runtime-R7M5XUMW.js} +9 -9
- package/dist/bundle/{start-2ZLDP2OE.js → start-YRLT4MQZ.js} +7 -7
- package/dist/bundle/{state-6SP27J2K.js → state-NZ7WRJWH.js} +9 -9
- package/dist/bundle/{store-EJN27MXI.js → store-7LCVDO7G.js} +23 -21
- package/dist/bundle/{store-4UUY545Q.js → store-ICDGPSEN.js} +21 -19
- package/dist/bundle/store-maintenance-command-SJPLY6IH.js +65 -0
- package/dist/bundle/tokens-FGTBE7VW.js +111 -0
- package/dist/commands/discovery.d.ts +0 -1
- package/dist/commands/discovery.d.ts.map +1 -1
- package/dist/commands/discovery.js +6 -26
- package/dist/commands/discovery.js.map +1 -1
- package/dist/commands/knowledge.d.ts.map +1 -1
- package/dist/commands/knowledge.js +7 -6
- package/dist/commands/knowledge.js.map +1 -1
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +11 -8
- package/dist/commands/search.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -2
- package/dist/config.js.map +1 -1
- package/dist/contract-overrides.d.ts +16 -4
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +86 -410
- package/dist/contract-overrides.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -1
- package/dist/google-api.d.ts.map +1 -1
- package/dist/google-api.js +4 -1
- package/dist/google-api.js.map +1 -1
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +22 -0
- package/dist/identity.js.map +1 -1
- package/dist/knowledge.js +2 -2
- package/dist/knowledge.js.map +1 -1
- package/dist/login.d.ts.map +1 -1
- package/dist/login.js +2 -2
- package/dist/login.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +8 -6
- package/dist/program.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +0 -1
- package/dist/reasons.js.map +1 -1
- package/dist/store-transition.js +2 -2
- package/dist/store-transition.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +7 -7
- package/dist/store.js.map +1 -1
- package/dist/tokens.d.ts +9 -2
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +18 -15
- package/dist/tokens.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- 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 +7 -7
- package/dist/bundle/chunk-CGQRZRTH.js +0 -26
- package/dist/bundle/chunk-IKHOIXJR.js +0 -27
- package/dist/bundle/chunk-SBZB7HMU.js +0 -1055
- package/dist/bundle/command-contract-25E4PYMD.js +0 -40
- package/dist/bundle/dist-PY3MVR3G.js +0 -21
- package/dist/bundle/entry-HPLW4QL2.js +0 -25
- package/dist/bundle/first-run-RL3RKYZW.js +0 -30
- package/dist/bundle/first-screen-NX3TM2VJ.js +0 -38
- package/dist/bundle/google-DPD5N6AQ.js +0 -42
- package/dist/bundle/grants-TX4MHLI4.js +0 -109
- package/dist/bundle/oauth-6R7AWAES.js +0 -22
- package/dist/bundle/server-QD2MUJJZ.js +0 -72
- package/dist/bundle/store-maintenance-command-LETURZDC.js +0 -60
- package/dist/bundle/tokens-MTFJPTYT.js +0 -107
- /package/dist/bundle/{chunk-YVNHQFLC.js → chunk-HVJJWJYQ.js} +0 -0
|
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
refuseLacking
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HPKE2GDP.js";
|
|
6
6
|
import {
|
|
7
7
|
FloodMemory,
|
|
8
8
|
OFFLINE,
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
servicesFor,
|
|
19
19
|
throughWrapper,
|
|
20
20
|
withFileLockAsync
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XVZNFA2P.js";
|
|
22
22
|
import {
|
|
23
23
|
servingProfiles
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-COGWKO2T.js";
|
|
25
25
|
import {
|
|
26
26
|
asFirstWord,
|
|
27
27
|
baseContext,
|
|
@@ -32,14 +32,15 @@ import {
|
|
|
32
32
|
recalledAccount,
|
|
33
33
|
rememberAccount,
|
|
34
34
|
rootOf2 as rootOf
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-5PLINHEY.js";
|
|
36
36
|
import {
|
|
37
37
|
providerErrorKey
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-P7HQFII6.js";
|
|
39
39
|
import {
|
|
40
40
|
AUTHORITY_KEY,
|
|
41
41
|
CEILING_KEY,
|
|
42
42
|
DEFAULT_PERMISSIONS,
|
|
43
|
+
KEYED_UNDER_HOUSEKEEPING,
|
|
43
44
|
WRITE_KEYS,
|
|
44
45
|
codeOf,
|
|
45
46
|
currentOperation,
|
|
@@ -48,7 +49,7 @@ import {
|
|
|
48
49
|
limitBatch,
|
|
49
50
|
readKeysForCommand,
|
|
50
51
|
skipFlagFor
|
|
51
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-PKM55ZRR.js";
|
|
52
53
|
import {
|
|
53
54
|
chatReferenceOf,
|
|
54
55
|
ensureAccount,
|
|
@@ -56,21 +57,21 @@ import {
|
|
|
56
57
|
isId,
|
|
57
58
|
openStore,
|
|
58
59
|
pickPerson
|
|
59
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-BIJW6AYA.js";
|
|
60
61
|
import {
|
|
61
62
|
isCliFailure
|
|
62
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-O53WLYX3.js";
|
|
63
64
|
import {
|
|
64
65
|
resolvePaths
|
|
65
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-6X3KUFRQ.js";
|
|
66
67
|
import {
|
|
67
68
|
CliError
|
|
68
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-IIHZTV6V.js";
|
|
69
70
|
import {
|
|
70
71
|
__name
|
|
71
72
|
} from "./chunk-ZVVMGPBJ.js";
|
|
72
73
|
|
|
73
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
74
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/cli/messenger/ask.js
|
|
74
75
|
import { openSync } from "node:fs";
|
|
75
76
|
import { createInterface } from "node:readline";
|
|
76
77
|
import { ReadStream } from "node:tty";
|
|
@@ -125,97 +126,7 @@ var terminalAsker = /* @__PURE__ */ __name((command) => async (key, request) =>
|
|
|
125
126
|
throw new CliError("cancelled", `${key}: not done \u2014 the answer was no`);
|
|
126
127
|
}, "terminalAsker");
|
|
127
128
|
|
|
128
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
129
|
-
import { readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
130
|
-
import { join } from "node:path";
|
|
131
|
-
var DEFAULT_PACE = { perMinute: 60, burst: 20 };
|
|
132
|
-
var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
|
|
133
|
-
var Pacer = class {
|
|
134
|
-
static {
|
|
135
|
-
__name(this, "Pacer");
|
|
136
|
-
}
|
|
137
|
-
path;
|
|
138
|
-
rate;
|
|
139
|
-
now;
|
|
140
|
-
constructor(path, rate, now = Date.now) {
|
|
141
|
-
this.path = path;
|
|
142
|
-
this.rate = rate;
|
|
143
|
-
this.now = now;
|
|
144
|
-
}
|
|
145
|
-
get interval() {
|
|
146
|
-
return this.rate.perMinute > 0 ? 6e4 / this.rate.perMinute : 0;
|
|
147
|
-
}
|
|
148
|
-
/** When this call may go; reserved at once, so the next caller in any process lines up behind it. */
|
|
149
|
-
async reserve() {
|
|
150
|
-
const now = this.now();
|
|
151
|
-
if (this.interval === 0)
|
|
152
|
-
return now;
|
|
153
|
-
return withFileLockAsync(this.path, "the request pace", () => {
|
|
154
|
-
const tat = Math.max(this.read(), now);
|
|
155
|
-
this.write(tat + this.interval);
|
|
156
|
-
return Math.max(now, tat - this.rate.burst * this.interval);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
/** The messenger asked every caller to wait: nothing goes before `now + waitMs`, in any process. */
|
|
160
|
-
async holdFor(waitMs) {
|
|
161
|
-
if (this.interval === 0)
|
|
162
|
-
return;
|
|
163
|
-
await withFileLockAsync(this.path, "the request pace", () => {
|
|
164
|
-
const hold = this.now() + waitMs + this.rate.burst * this.interval;
|
|
165
|
-
this.write(Math.max(this.read(), hold));
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
/** The owner's `flood clear`: every process may go again at once. */
|
|
169
|
-
async reset() {
|
|
170
|
-
await withFileLockAsync(this.path, "the request pace", () => this.write(0));
|
|
171
|
-
}
|
|
172
|
-
read() {
|
|
173
|
-
try {
|
|
174
|
-
const tat = Number(JSON.parse(readFileSync(this.path, "utf8")).tat);
|
|
175
|
-
return Number.isFinite(tat) ? tat : 0;
|
|
176
|
-
} catch {
|
|
177
|
-
return 0;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
write(tat) {
|
|
181
|
-
const temporary = `${this.path}.${process.pid}.tmp`;
|
|
182
|
-
writeFileSync(temporary, JSON.stringify({ tat }), { mode: 384 });
|
|
183
|
-
renameSync(temporary, this.path);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
var ANNOUNCE_WAIT_MS = 5e3;
|
|
187
|
-
var LONGEST_PACE_WAIT_MS = 5 * 6e4;
|
|
188
|
-
var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
|
|
189
|
-
const { name, operation, warn } = options;
|
|
190
|
-
const now = options.now ?? Date.now;
|
|
191
|
-
let at = now();
|
|
192
|
-
try {
|
|
193
|
-
at = await pacer.reserve();
|
|
194
|
-
} catch (error) {
|
|
195
|
-
warn?.(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
|
|
196
|
-
event: "warning",
|
|
197
|
-
code: "wait_not_remembered",
|
|
198
|
-
operation
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
const waitMs = at - now();
|
|
202
|
-
if (waitMs <= 0)
|
|
203
|
-
return;
|
|
204
|
-
if (waitMs > LONGEST_PACE_WAIT_MS)
|
|
205
|
-
throw new CliError("rate_limited", `${name} asked this profile to wait, ${Math.ceil(waitMs / 1e3)} s are left \u2014 nothing was sent to ${name}`, { retry_after_ms: waitMs, retry_at: new Date(at).toISOString(), remembered: true });
|
|
206
|
-
if (waitMs >= ANNOUNCE_WAIT_MS) {
|
|
207
|
-
const seconds = Math.ceil(waitMs / 1e3);
|
|
208
|
-
warn?.(`waiting ${seconds} s to keep this profile's pace with ${name}`, {
|
|
209
|
-
event: "warning",
|
|
210
|
-
code: "pace_wait",
|
|
211
|
-
operation,
|
|
212
|
-
counts: { seconds }
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
await (options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
|
|
216
|
-
}, "waitForTurn");
|
|
217
|
-
|
|
218
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
|
|
129
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
|
|
219
130
|
var HOUSEKEEPING = /* @__PURE__ */ new Set([
|
|
220
131
|
"help",
|
|
221
132
|
"guide",
|
|
@@ -229,7 +140,7 @@ var HOUSEKEEPING = /* @__PURE__ */ new Set([
|
|
|
229
140
|
"mcp",
|
|
230
141
|
"runs"
|
|
231
142
|
]);
|
|
232
|
-
var commandPathKey = /* @__PURE__ */ __name((path) => path[0] === void 0 || HOUSEKEEPING.has(path[0]) ? null : path.join("."), "commandPathKey");
|
|
143
|
+
var commandPathKey = /* @__PURE__ */ __name((path) => path[0] === void 0 || HOUSEKEEPING.has(path[0]) && !KEYED_UNDER_HOUSEKEEPING.has(path.join(".")) ? null : path.join("."), "commandPathKey");
|
|
233
144
|
var commandPermissions = /* @__PURE__ */ __name(({ keyOf = commandPathKey, extra = [], defaults = {}, alsoChecks } = {}) => ({
|
|
234
145
|
keyOf,
|
|
235
146
|
extra: [AUTHORITY_KEY, ...extra],
|
|
@@ -295,271 +206,75 @@ var refuseUnknownPermissionKeys = /* @__PURE__ */ __name((command, settings, too
|
|
|
295
206
|
throw new CliError("validation_error", `--permission ${key} names no command`, { permission: key });
|
|
296
207
|
}, "refuseUnknownPermissionKeys");
|
|
297
208
|
|
|
298
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
299
|
-
var
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
operation
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}, "kept");
|
|
315
|
-
const noted = /* @__PURE__ */ __name(async (operation, chatId, error) => {
|
|
316
|
-
if (!isCliFailure(error))
|
|
317
|
-
return;
|
|
318
|
-
const details = error.details ?? {};
|
|
319
|
-
const standing = details.standing;
|
|
320
|
-
if (standing && BLOCKING.has(standing.state)) {
|
|
321
|
-
await kept(operation, () => {
|
|
322
|
-
const block = memory.block({
|
|
323
|
-
state: standing.state,
|
|
324
|
-
hint: standing.hint ?? error.message,
|
|
325
|
-
...standing.until ? { until: standing.until } : {}
|
|
326
|
-
});
|
|
327
|
-
warn(`writes from this profile are held ${holdEnd(block)}: ${block.hint}`, {
|
|
328
|
-
event: "warning",
|
|
329
|
-
code: `account_${block.state}`,
|
|
330
|
-
operation
|
|
331
|
-
});
|
|
332
|
-
});
|
|
209
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
|
|
210
|
+
var REKEY_PACING = { lockMs: 50, pauseMs: 25 };
|
|
211
|
+
var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events, pending, announcing, deletedWithoutChat, profile, rekeyed, rekeyPacing = REKEY_PACING, closing, namesFromStore, recipientIds, countsUnread = false, historyLimits, command = "cli" }) => {
|
|
212
|
+
let warned = false;
|
|
213
|
+
let limitedNoted = false;
|
|
214
|
+
const limited = /* @__PURE__ */ __name(async (opened, batch) => {
|
|
215
|
+
if (!historyLimits || !batch.messages?.length)
|
|
216
|
+
return { batch, skipped: /* @__PURE__ */ new Map() };
|
|
217
|
+
const shapes = await opened.chats.historyShapes(account, [...new Set(batch.messages.map((one) => one.chatId))]);
|
|
218
|
+
return limitBatch(batch, (chatId) => shapes.get(chatId), (chatId) => shapes.get(chatId)?.included === true, historyLimits);
|
|
219
|
+
}, "limited");
|
|
220
|
+
const noteLimited = /* @__PURE__ */ __name((skipped) => {
|
|
221
|
+
if (skipped.size === 0)
|
|
333
222
|
return;
|
|
223
|
+
const counts = {
|
|
224
|
+
chats: skipped.size,
|
|
225
|
+
messages: 0,
|
|
226
|
+
group_too_large: 0,
|
|
227
|
+
older_than_window: 0
|
|
228
|
+
};
|
|
229
|
+
for (const skip of skipped.values()) {
|
|
230
|
+
counts.messages = (counts.messages ?? 0) + skip.messages;
|
|
231
|
+
counts[skip.reason] = (counts[skip.reason] ?? 0) + 1;
|
|
334
232
|
}
|
|
335
|
-
const
|
|
336
|
-
|
|
233
|
+
const warning = { event: "warning", code: "history_limited", operation: "history.save", counts };
|
|
234
|
+
events(warning);
|
|
235
|
+
if (limitedNoted)
|
|
337
236
|
return;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
warn(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
await
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
await waitForTurn(pacer, { name, operation, warn });
|
|
359
|
-
}, "turn");
|
|
360
|
-
return throughWrapper(messenger, {}, (operation, call) => {
|
|
361
|
-
if (LONG_LIVED.has(operation))
|
|
362
|
-
return call;
|
|
363
|
-
if (LISTENING.has(operation))
|
|
364
|
-
return (async (...args) => {
|
|
365
|
-
try {
|
|
366
|
-
return await call(...args);
|
|
367
|
-
} catch (error) {
|
|
368
|
-
await noted(operation, void 0, error);
|
|
369
|
-
throw error;
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
return (async (...args) => {
|
|
373
|
-
const chatId = chatOf(args);
|
|
374
|
-
const owed = memory.owed(operation, chatId);
|
|
375
|
-
if (owed) {
|
|
376
|
-
const waitMs = Math.max(0, Date.parse(owed.until) - Date.now());
|
|
377
|
-
throw new CliError("rate_limited", `${name} asked to wait before ${operation} again, ${Math.ceil(waitMs / 1e3)} s are left \u2014 nothing was sent to ${name}`, {
|
|
378
|
-
retry_after_ms: waitMs,
|
|
379
|
-
retry_at: owed.until,
|
|
380
|
-
remembered: true,
|
|
381
|
-
...owed.providerError ? { provider_error: owed.providerError } : {}
|
|
237
|
+
limitedNoted = true;
|
|
238
|
+
warn(`history limits left out ${counts.messages} pushed messages of ${skipped.size} chats (big groups, older than the window) \u2014 \`${command} store status\` lists them; \`${command} messages sync <chat> --full-history\` fetches one and keeps it in full`, warning);
|
|
239
|
+
}, "noteLimited");
|
|
240
|
+
let recorded = profile === void 0;
|
|
241
|
+
const notWritten = /* @__PURE__ */ __name((operation, error) => {
|
|
242
|
+
const warning = { event: "warning", code: "store_not_written", operation };
|
|
243
|
+
events(warning);
|
|
244
|
+
if (!warned)
|
|
245
|
+
warn(`not saved to the local store: ${error instanceof Error ? error.message : String(error)}`, warning);
|
|
246
|
+
warned = true;
|
|
247
|
+
}, "notWritten");
|
|
248
|
+
const attempt = /* @__PURE__ */ __name(async (operation, write) => {
|
|
249
|
+
try {
|
|
250
|
+
const opened = await store();
|
|
251
|
+
if (!opened)
|
|
252
|
+
return false;
|
|
253
|
+
await write(opened);
|
|
254
|
+
if (opened && !recorded && profile) {
|
|
255
|
+
recorded = true;
|
|
256
|
+
await Promise.resolve().then(() => opened.accounts.saveProfile(profile.app, profile.name, account)).catch(() => {
|
|
382
257
|
});
|
|
383
258
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
const write = currentOperation();
|
|
399
|
-
const marked = /* @__PURE__ */ __name((part = {}) => write === void 0 ? part : { ...part, ids: { ...part.ids, operation: write } }, "marked");
|
|
400
|
-
events({ event: "request", operation, level: "operation", ...marked(named) });
|
|
401
|
-
const started = performance.now();
|
|
402
|
-
const durationMs = /* @__PURE__ */ __name(() => Math.round(performance.now() - started), "durationMs");
|
|
259
|
+
return true;
|
|
260
|
+
} catch (error) {
|
|
261
|
+
notWritten(operation, error);
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}, "attempt");
|
|
265
|
+
const save = /* @__PURE__ */ __name((operation, writing) => {
|
|
266
|
+
const saving = attempt(operation, writing);
|
|
267
|
+
pending?.add(saving);
|
|
268
|
+
return saving.finally(() => pending?.delete(saving));
|
|
269
|
+
}, "save");
|
|
270
|
+
const { chats, history, around, people } = messenger;
|
|
271
|
+
const followed = /* @__PURE__ */ __name(async (opened, scoped, held) => {
|
|
272
|
+
let answered;
|
|
403
273
|
try {
|
|
404
|
-
|
|
405
|
-
events({
|
|
406
|
-
event: "response",
|
|
407
|
-
operation,
|
|
408
|
-
level: "operation",
|
|
409
|
-
durationMs: durationMs(),
|
|
410
|
-
outcome: "ok",
|
|
411
|
-
...marked(after?.(answer))
|
|
412
|
-
});
|
|
413
|
-
return answer;
|
|
274
|
+
answered = await messenger.resolve(held.id);
|
|
414
275
|
} catch (error) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
event: "response",
|
|
418
|
-
operation,
|
|
419
|
-
level: "operation",
|
|
420
|
-
durationMs: durationMs(),
|
|
421
|
-
outcome: "error",
|
|
422
|
-
errorCode: isCliFailure(error) ? error.code : "generic_failure",
|
|
423
|
-
...providerError ? { providerError } : {},
|
|
424
|
-
...marked()
|
|
425
|
-
});
|
|
426
|
-
throw error;
|
|
427
|
-
}
|
|
428
|
-
}, "timed");
|
|
429
|
-
const counted = /* @__PURE__ */ __name(async (operation, onItem, work, count) => {
|
|
430
|
-
const counts = {};
|
|
431
|
-
await timed(operation, {}, () => work((item, ...rest) => {
|
|
432
|
-
count(item, counts);
|
|
433
|
-
return onItem(item, ...rest);
|
|
434
|
-
}), () => ({ counts }));
|
|
435
|
-
}, "counted");
|
|
436
|
-
const mint = messenger.newSendId;
|
|
437
|
-
const { chats, history, contact, around, watch, feed, listen, listenHistory } = messenger;
|
|
438
|
-
return throughWrapper(messenger, {
|
|
439
|
-
self: /* @__PURE__ */ __name(() => messenger.self(), "self"),
|
|
440
|
-
...mint ? { newSendId: /* @__PURE__ */ __name(() => mint.call(messenger), "newSendId") } : {},
|
|
441
|
-
me: /* @__PURE__ */ __name(() => timed("account.me", {}, () => messenger.me()), "me"),
|
|
442
|
-
...chats ? {
|
|
443
|
-
chats: /* @__PURE__ */ __name((window) => timed("chats.list", {}, () => chats.call(messenger, window), (page) => ({ counts: { chats: page.items.length } })), "chats")
|
|
444
|
-
} : {},
|
|
445
|
-
...history ? {
|
|
446
|
-
history: /* @__PURE__ */ __name((reference, options) => timed("messages.list", {}, () => history.call(messenger, reference, options), (page) => ({
|
|
447
|
-
...page.items[0] ? { ids: { chat: page.items[0].chatId } } : {},
|
|
448
|
-
counts: { messages: page.items.length }
|
|
449
|
-
})), "history")
|
|
450
|
-
} : {},
|
|
451
|
-
resolve: /* @__PURE__ */ __name((reference) => timed("chats.resolve", {}, () => messenger.resolve(reference), (chat) => ({ ids: { chat: chat.id } })), "resolve"),
|
|
452
|
-
chat: /* @__PURE__ */ __name((reference) => timed("chats.show", {}, () => messenger.chat(reference), (card) => ({ ids: { chat: card.id }, ...card.members ? { counts: { members: card.members.length } } : {} })), "chat"),
|
|
453
|
-
...contact ? {
|
|
454
|
-
contact: /* @__PURE__ */ __name((reference) => timed("contacts.show", {}, () => contact.call(messenger, reference), (card) => ({ ids: { person: card.id }, counts: { chats: card.chats.length } })), "contact")
|
|
455
|
-
} : {},
|
|
456
|
-
...around ? {
|
|
457
|
-
around: /* @__PURE__ */ __name((reference, messageId, window) => timed("messages.around", { ids: { message_id: messageId } }, () => around.call(messenger, reference, messageId, window), (items) => ({
|
|
458
|
-
...items[0] ? { ids: { chat: items[0].chatId, message_id: messageId } } : {},
|
|
459
|
-
counts: { messages: items.length }
|
|
460
|
-
})), "around")
|
|
461
|
-
} : {},
|
|
462
|
-
send: /* @__PURE__ */ __name((chatId, text, options) => timed("messages.send", {
|
|
463
|
-
ids: {
|
|
464
|
-
chat: chatId,
|
|
465
|
-
send: options.sendId,
|
|
466
|
-
...options.replyTo ? { reply: options.replyTo } : {},
|
|
467
|
-
...options.threadId ? { thread: options.threadId } : {}
|
|
468
|
-
}
|
|
469
|
-
}, () => messenger.send(chatId, text, options), (sent) => ({ ids: { chat: sent.message.chatId || chatId, message_id: sent.message.id } })), "send"),
|
|
470
|
-
...watch ? {
|
|
471
|
-
watch: /* @__PURE__ */ __name((onEvent, signal, onReady) => counted("messages.watch", onEvent, (counting) => watch.call(messenger, counting, signal, onReady), byEvent), "watch")
|
|
472
|
-
} : {},
|
|
473
|
-
...feed ? { feed: /* @__PURE__ */ __name((onBatch, signal) => timed("history.feed", {}, () => feed.call(messenger, onBatch, signal)), "feed") } : {},
|
|
474
|
-
...listen ? {
|
|
475
|
-
listen: /* @__PURE__ */ __name((onEvent, signal) => counted("messages.listen", onEvent, (counting) => listen.call(messenger, counting, signal), byEvent), "listen")
|
|
476
|
-
} : {},
|
|
477
|
-
...listenHistory ? {
|
|
478
|
-
listenHistory: /* @__PURE__ */ __name((onBatch, signal) => counted("history.listen", onBatch, (counting) => listenHistory.call(messenger, counting, signal), byPart), "listenHistory")
|
|
479
|
-
} : {},
|
|
480
|
-
logout: /* @__PURE__ */ __name(() => timed("session.logout", {}, () => messenger.logout()), "logout"),
|
|
481
|
-
close: /* @__PURE__ */ __name(() => messenger.close(), "close")
|
|
482
|
-
}, (name, call) => (...args) => timed(`adapter.${name}`, {}, () => call(...args)));
|
|
483
|
-
}, "observed");
|
|
484
|
-
var byEvent = /* @__PURE__ */ __name((event, counts) => {
|
|
485
|
-
counts[event.event] = (counts[event.event] ?? 0) + 1;
|
|
486
|
-
}, "byEvent");
|
|
487
|
-
var byPart = /* @__PURE__ */ __name((batch, counts) => {
|
|
488
|
-
counts.batches = (counts.batches ?? 0) + 1;
|
|
489
|
-
for (const [part, items] of Object.entries(batch))
|
|
490
|
-
if (Array.isArray(items) && items.length > 0)
|
|
491
|
-
counts[part] = (counts[part] ?? 0) + items.length;
|
|
492
|
-
}, "byPart");
|
|
493
|
-
|
|
494
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
|
|
495
|
-
var REKEY_PACING = { lockMs: 50, pauseMs: 25 };
|
|
496
|
-
var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events, pending, announcing, deletedWithoutChat, profile, rekeyed, rekeyPacing = REKEY_PACING, closing, namesFromStore, recipientIds, countsUnread = false, historyLimits, command = "cli" }) => {
|
|
497
|
-
let warned = false;
|
|
498
|
-
let limitedNoted = false;
|
|
499
|
-
const limited = /* @__PURE__ */ __name(async (opened, batch) => {
|
|
500
|
-
if (!historyLimits || !batch.messages?.length)
|
|
501
|
-
return { batch, skipped: /* @__PURE__ */ new Map() };
|
|
502
|
-
const shapes = await opened.chats.historyShapes(account, [...new Set(batch.messages.map((one) => one.chatId))]);
|
|
503
|
-
return limitBatch(batch, (chatId) => shapes.get(chatId), (chatId) => shapes.get(chatId)?.included === true, historyLimits);
|
|
504
|
-
}, "limited");
|
|
505
|
-
const noteLimited = /* @__PURE__ */ __name((skipped) => {
|
|
506
|
-
if (skipped.size === 0)
|
|
507
|
-
return;
|
|
508
|
-
const counts = {
|
|
509
|
-
chats: skipped.size,
|
|
510
|
-
messages: 0,
|
|
511
|
-
group_too_large: 0,
|
|
512
|
-
older_than_window: 0
|
|
513
|
-
};
|
|
514
|
-
for (const skip of skipped.values()) {
|
|
515
|
-
counts.messages = (counts.messages ?? 0) + skip.messages;
|
|
516
|
-
counts[skip.reason] = (counts[skip.reason] ?? 0) + 1;
|
|
517
|
-
}
|
|
518
|
-
const warning = { event: "warning", code: "history_limited", operation: "history.save", counts };
|
|
519
|
-
events(warning);
|
|
520
|
-
if (limitedNoted)
|
|
521
|
-
return;
|
|
522
|
-
limitedNoted = true;
|
|
523
|
-
warn(`history limits left out ${counts.messages} pushed messages of ${skipped.size} chats (big groups, older than the window) \u2014 \`${command} store status\` lists them; \`${command} messages sync <chat> --full-history\` fetches one and keeps it in full`, warning);
|
|
524
|
-
}, "noteLimited");
|
|
525
|
-
let recorded = profile === void 0;
|
|
526
|
-
const notWritten = /* @__PURE__ */ __name((operation, error) => {
|
|
527
|
-
const warning = { event: "warning", code: "store_not_written", operation };
|
|
528
|
-
events(warning);
|
|
529
|
-
if (!warned)
|
|
530
|
-
warn(`not saved to the local store: ${error instanceof Error ? error.message : String(error)}`, warning);
|
|
531
|
-
warned = true;
|
|
532
|
-
}, "notWritten");
|
|
533
|
-
const attempt = /* @__PURE__ */ __name(async (operation, write) => {
|
|
534
|
-
try {
|
|
535
|
-
const opened = await store();
|
|
536
|
-
if (!opened)
|
|
537
|
-
return false;
|
|
538
|
-
await write(opened);
|
|
539
|
-
if (opened && !recorded && profile) {
|
|
540
|
-
recorded = true;
|
|
541
|
-
await Promise.resolve().then(() => opened.accounts.saveProfile(profile.app, profile.name, account)).catch(() => {
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
return true;
|
|
545
|
-
} catch (error) {
|
|
546
|
-
notWritten(operation, error);
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
}, "attempt");
|
|
550
|
-
const save = /* @__PURE__ */ __name((operation, writing) => {
|
|
551
|
-
const saving = attempt(operation, writing);
|
|
552
|
-
pending?.add(saving);
|
|
553
|
-
return saving.finally(() => pending?.delete(saving));
|
|
554
|
-
}, "save");
|
|
555
|
-
const { chats, history, around, people } = messenger;
|
|
556
|
-
const followed = /* @__PURE__ */ __name(async (opened, scoped, held) => {
|
|
557
|
-
let answered;
|
|
558
|
-
try {
|
|
559
|
-
answered = await messenger.resolve(held.id);
|
|
560
|
-
} catch (error) {
|
|
561
|
-
if (codeOf(error) === "not_found")
|
|
562
|
-
return void 0;
|
|
276
|
+
if (codeOf(error) === "not_found")
|
|
277
|
+
return void 0;
|
|
563
278
|
throw error;
|
|
564
279
|
}
|
|
565
280
|
if (answered.id === held.id)
|
|
@@ -1067,7 +782,298 @@ var keep = /* @__PURE__ */ __name(async (store, account, event, seenAt, among, c
|
|
|
1067
782
|
}
|
|
1068
783
|
}, "keep");
|
|
1069
784
|
|
|
1070
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
785
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/sends/pace.js
|
|
786
|
+
import { readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
787
|
+
import { join } from "node:path";
|
|
788
|
+
var DEFAULT_PACE = { perMinute: 60, burst: 20 };
|
|
789
|
+
var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
|
|
790
|
+
var Pacer = class {
|
|
791
|
+
static {
|
|
792
|
+
__name(this, "Pacer");
|
|
793
|
+
}
|
|
794
|
+
path;
|
|
795
|
+
rate;
|
|
796
|
+
now;
|
|
797
|
+
constructor(path, rate, now = Date.now) {
|
|
798
|
+
this.path = path;
|
|
799
|
+
this.rate = rate;
|
|
800
|
+
this.now = now;
|
|
801
|
+
}
|
|
802
|
+
get interval() {
|
|
803
|
+
return this.rate.perMinute > 0 ? 6e4 / this.rate.perMinute : 0;
|
|
804
|
+
}
|
|
805
|
+
/** When this call may go; reserved at once, so the next caller in any process lines up behind it. */
|
|
806
|
+
async reserve() {
|
|
807
|
+
if (this.interval === 0)
|
|
808
|
+
return this.now();
|
|
809
|
+
return withFileLockAsync(this.path, "the request pace", () => {
|
|
810
|
+
const now = this.now();
|
|
811
|
+
const tat = Math.max(this.read(now), now);
|
|
812
|
+
this.write(tat + this.interval, now);
|
|
813
|
+
return Math.max(now, tat - this.rate.burst * this.interval);
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
/** The messenger asked every caller to wait: nothing goes before `now + waitMs`, in any process. */
|
|
817
|
+
async holdFor(waitMs) {
|
|
818
|
+
if (this.interval === 0)
|
|
819
|
+
return;
|
|
820
|
+
await withFileLockAsync(this.path, "the request pace", () => {
|
|
821
|
+
const now = this.now();
|
|
822
|
+
const hold = now + waitMs + this.rate.burst * this.interval;
|
|
823
|
+
this.write(Math.max(this.read(now), hold), now);
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
/** The owner's `flood clear`: every process may go again at once. */
|
|
827
|
+
async reset() {
|
|
828
|
+
await withFileLockAsync(this.path, "the request pace", () => this.write(0, this.now()));
|
|
829
|
+
}
|
|
830
|
+
read(now) {
|
|
831
|
+
try {
|
|
832
|
+
const file = JSON.parse(readFileSync(this.path, "utf8"));
|
|
833
|
+
const tat = Number(file.tat);
|
|
834
|
+
if (!Number.isFinite(tat))
|
|
835
|
+
return 0;
|
|
836
|
+
const at = Number(file.at);
|
|
837
|
+
return Number.isFinite(at) && at > now ? now + Math.max(0, tat - at) : tat;
|
|
838
|
+
} catch {
|
|
839
|
+
return 0;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
write(tat, at) {
|
|
843
|
+
const temporary = `${this.path}.${process.pid}.tmp`;
|
|
844
|
+
writeFileSync(temporary, JSON.stringify({ tat, at }), { mode: 384 });
|
|
845
|
+
renameSync(temporary, this.path);
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
var ANNOUNCE_WAIT_MS = 5e3;
|
|
849
|
+
var LONGEST_PACE_WAIT_MS = 5 * 6e4;
|
|
850
|
+
var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
|
|
851
|
+
const { name, operation, warn } = options;
|
|
852
|
+
const now = options.now ?? Date.now;
|
|
853
|
+
let at = now();
|
|
854
|
+
try {
|
|
855
|
+
at = await pacer.reserve();
|
|
856
|
+
} catch (error) {
|
|
857
|
+
warn?.(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
|
|
858
|
+
event: "warning",
|
|
859
|
+
code: "wait_not_remembered",
|
|
860
|
+
operation
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
const waitMs = at - now();
|
|
864
|
+
if (waitMs <= 0)
|
|
865
|
+
return;
|
|
866
|
+
if (waitMs > (options.longestWaitMs ?? LONGEST_PACE_WAIT_MS))
|
|
867
|
+
throw new CliError("rate_limited", `this profile's next request to ${name} has to wait ${Math.ceil(waitMs / 1e3)} s more \u2014 nothing was sent to ${name}`, { retry_after_ms: waitMs, retry_at: new Date(at).toISOString(), remembered: true });
|
|
868
|
+
if (waitMs >= ANNOUNCE_WAIT_MS) {
|
|
869
|
+
const seconds = Math.ceil(waitMs / 1e3);
|
|
870
|
+
warn?.(`waiting ${seconds} s to keep this profile's pace with ${name}`, {
|
|
871
|
+
event: "warning",
|
|
872
|
+
code: "pace_wait",
|
|
873
|
+
operation,
|
|
874
|
+
counts: { seconds }
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
await (options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
|
|
878
|
+
}, "waitForTurn");
|
|
879
|
+
|
|
880
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/cli/messenger/flooded.js
|
|
881
|
+
var LONG_LIVED = /* @__PURE__ */ new Set(["self", "newSendId", "close", "formatMarkdown", "formatHtml", "storedChats"]);
|
|
882
|
+
var LISTENING = /* @__PURE__ */ new Set(["watch", "feed", "listen", "listenHistory"]);
|
|
883
|
+
var BLOCKING = /* @__PURE__ */ new Set(["frozen", "limited", "banned"]);
|
|
884
|
+
var chatOf = /* @__PURE__ */ __name((args) => typeof args[0] === "string" && /^-?\d+$/.test(args[0]) ? args[0] : void 0, "chatOf");
|
|
885
|
+
var flooded = /* @__PURE__ */ __name((messenger, memory, { name, warn, pacer }) => {
|
|
886
|
+
const kept = /* @__PURE__ */ __name(async (operation, what2) => {
|
|
887
|
+
try {
|
|
888
|
+
await what2();
|
|
889
|
+
} catch (error) {
|
|
890
|
+
warn(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
|
|
891
|
+
event: "warning",
|
|
892
|
+
code: "wait_not_remembered",
|
|
893
|
+
operation
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
}, "kept");
|
|
897
|
+
const noted = /* @__PURE__ */ __name(async (operation, chatId, error) => {
|
|
898
|
+
if (!isCliFailure(error))
|
|
899
|
+
return;
|
|
900
|
+
const details = error.details ?? {};
|
|
901
|
+
const standing = details.standing;
|
|
902
|
+
if (standing && BLOCKING.has(standing.state)) {
|
|
903
|
+
await kept(operation, () => {
|
|
904
|
+
const block = memory.block({
|
|
905
|
+
state: standing.state,
|
|
906
|
+
hint: standing.hint ?? error.message,
|
|
907
|
+
...standing.until ? { until: standing.until } : {}
|
|
908
|
+
});
|
|
909
|
+
warn(`writes from this profile are held ${holdEnd(block)}: ${block.hint}`, {
|
|
910
|
+
event: "warning",
|
|
911
|
+
code: `account_${block.state}`,
|
|
912
|
+
operation
|
|
913
|
+
});
|
|
914
|
+
});
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
const waitMs = Number(details.retry_after_ms);
|
|
918
|
+
if (error.code !== "rate_limited" || details.remembered === true || !Number.isFinite(waitMs) || waitMs <= 0)
|
|
919
|
+
return;
|
|
920
|
+
const providerError = providerErrorKey(details.provider_error);
|
|
921
|
+
await kept(operation, () => {
|
|
922
|
+
const deadline = memory.remember({
|
|
923
|
+
operation,
|
|
924
|
+
...chatId ? { chatId } : {},
|
|
925
|
+
...providerError ? { providerError } : {},
|
|
926
|
+
waitMs
|
|
927
|
+
});
|
|
928
|
+
warn(`${name} asked to wait before ${operation} again \u2014 until ${deadline.until}`, {
|
|
929
|
+
event: "warning",
|
|
930
|
+
code: "flood_wait",
|
|
931
|
+
operation,
|
|
932
|
+
counts: { seconds: Math.ceil(waitMs / 1e3) }
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
if (pacer)
|
|
936
|
+
await kept(operation, () => pacer.holdFor(waitMs));
|
|
937
|
+
}, "noted");
|
|
938
|
+
const turn = /* @__PURE__ */ __name(async (operation) => {
|
|
939
|
+
if (pacer)
|
|
940
|
+
await waitForTurn(pacer, { name, operation, warn });
|
|
941
|
+
}, "turn");
|
|
942
|
+
return throughWrapper(messenger, {}, (operation, call) => {
|
|
943
|
+
if (LONG_LIVED.has(operation))
|
|
944
|
+
return call;
|
|
945
|
+
if (LISTENING.has(operation))
|
|
946
|
+
return (async (...args) => {
|
|
947
|
+
try {
|
|
948
|
+
return await call(...args);
|
|
949
|
+
} catch (error) {
|
|
950
|
+
await noted(operation, void 0, error);
|
|
951
|
+
throw error;
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
return (async (...args) => {
|
|
955
|
+
const chatId = chatOf(args);
|
|
956
|
+
const owed = memory.owed(operation, chatId);
|
|
957
|
+
if (owed) {
|
|
958
|
+
const waitMs = Math.max(0, Date.parse(owed.until) - Date.now());
|
|
959
|
+
throw new CliError("rate_limited", `${name} asked to wait before ${operation} again, ${Math.ceil(waitMs / 1e3)} s are left \u2014 nothing was sent to ${name}`, {
|
|
960
|
+
retry_after_ms: waitMs,
|
|
961
|
+
retry_at: owed.until,
|
|
962
|
+
remembered: true,
|
|
963
|
+
...owed.providerError ? { provider_error: owed.providerError } : {}
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
await turn(operation);
|
|
967
|
+
try {
|
|
968
|
+
return await call(...args);
|
|
969
|
+
} catch (error) {
|
|
970
|
+
await noted(operation, chatId, error);
|
|
971
|
+
throw error;
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
});
|
|
975
|
+
}, "flooded");
|
|
976
|
+
|
|
977
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/cli/messenger/observed.js
|
|
978
|
+
var observed = /* @__PURE__ */ __name((messenger, events) => {
|
|
979
|
+
const timed = /* @__PURE__ */ __name(async (operation, named, work, after) => {
|
|
980
|
+
const write = currentOperation();
|
|
981
|
+
const marked = /* @__PURE__ */ __name((part = {}) => write === void 0 ? part : { ...part, ids: { ...part.ids, operation: write } }, "marked");
|
|
982
|
+
events({ event: "request", operation, level: "operation", ...marked(named) });
|
|
983
|
+
const started = performance.now();
|
|
984
|
+
const durationMs = /* @__PURE__ */ __name(() => Math.round(performance.now() - started), "durationMs");
|
|
985
|
+
try {
|
|
986
|
+
const answer = await work();
|
|
987
|
+
events({
|
|
988
|
+
event: "response",
|
|
989
|
+
operation,
|
|
990
|
+
level: "operation",
|
|
991
|
+
durationMs: durationMs(),
|
|
992
|
+
outcome: "ok",
|
|
993
|
+
...marked(after?.(answer))
|
|
994
|
+
});
|
|
995
|
+
return answer;
|
|
996
|
+
} catch (error) {
|
|
997
|
+
const providerError = isCliFailure(error) ? providerErrorKey(error.details?.provider_error) : void 0;
|
|
998
|
+
events({
|
|
999
|
+
event: "response",
|
|
1000
|
+
operation,
|
|
1001
|
+
level: "operation",
|
|
1002
|
+
durationMs: durationMs(),
|
|
1003
|
+
outcome: "error",
|
|
1004
|
+
errorCode: isCliFailure(error) ? error.code : "generic_failure",
|
|
1005
|
+
...providerError ? { providerError } : {},
|
|
1006
|
+
...marked()
|
|
1007
|
+
});
|
|
1008
|
+
throw error;
|
|
1009
|
+
}
|
|
1010
|
+
}, "timed");
|
|
1011
|
+
const counted = /* @__PURE__ */ __name(async (operation, onItem, work, count) => {
|
|
1012
|
+
const counts = {};
|
|
1013
|
+
await timed(operation, {}, () => work((item, ...rest) => {
|
|
1014
|
+
count(item, counts);
|
|
1015
|
+
return onItem(item, ...rest);
|
|
1016
|
+
}), () => ({ counts }));
|
|
1017
|
+
}, "counted");
|
|
1018
|
+
const mint = messenger.newSendId;
|
|
1019
|
+
const { chats, history, contact, around, watch, feed, listen, listenHistory } = messenger;
|
|
1020
|
+
return throughWrapper(messenger, {
|
|
1021
|
+
self: /* @__PURE__ */ __name(() => messenger.self(), "self"),
|
|
1022
|
+
...mint ? { newSendId: /* @__PURE__ */ __name(() => mint.call(messenger), "newSendId") } : {},
|
|
1023
|
+
me: /* @__PURE__ */ __name(() => timed("account.me", {}, () => messenger.me()), "me"),
|
|
1024
|
+
...chats ? {
|
|
1025
|
+
chats: /* @__PURE__ */ __name((window) => timed("chats.list", {}, () => chats.call(messenger, window), (page) => ({ counts: { chats: page.items.length } })), "chats")
|
|
1026
|
+
} : {},
|
|
1027
|
+
...history ? {
|
|
1028
|
+
history: /* @__PURE__ */ __name((reference, options) => timed("messages.list", {}, () => history.call(messenger, reference, options), (page) => ({
|
|
1029
|
+
...page.items[0] ? { ids: { chat: page.items[0].chatId } } : {},
|
|
1030
|
+
counts: { messages: page.items.length }
|
|
1031
|
+
})), "history")
|
|
1032
|
+
} : {},
|
|
1033
|
+
resolve: /* @__PURE__ */ __name((reference) => timed("chats.resolve", {}, () => messenger.resolve(reference), (chat) => ({ ids: { chat: chat.id } })), "resolve"),
|
|
1034
|
+
chat: /* @__PURE__ */ __name((reference) => timed("chats.show", {}, () => messenger.chat(reference), (card) => ({ ids: { chat: card.id }, ...card.members ? { counts: { members: card.members.length } } : {} })), "chat"),
|
|
1035
|
+
...contact ? {
|
|
1036
|
+
contact: /* @__PURE__ */ __name((reference) => timed("contacts.show", {}, () => contact.call(messenger, reference), (card) => ({ ids: { person: card.id }, counts: { chats: card.chats.length } })), "contact")
|
|
1037
|
+
} : {},
|
|
1038
|
+
...around ? {
|
|
1039
|
+
around: /* @__PURE__ */ __name((reference, messageId, window) => timed("messages.around", { ids: { message_id: messageId } }, () => around.call(messenger, reference, messageId, window), (items) => ({
|
|
1040
|
+
...items[0] ? { ids: { chat: items[0].chatId, message_id: messageId } } : {},
|
|
1041
|
+
counts: { messages: items.length }
|
|
1042
|
+
})), "around")
|
|
1043
|
+
} : {},
|
|
1044
|
+
send: /* @__PURE__ */ __name((chatId, text, options) => timed("messages.send", {
|
|
1045
|
+
ids: {
|
|
1046
|
+
chat: chatId,
|
|
1047
|
+
send: options.sendId,
|
|
1048
|
+
...options.replyTo ? { reply: options.replyTo } : {},
|
|
1049
|
+
...options.threadId ? { thread: options.threadId } : {}
|
|
1050
|
+
}
|
|
1051
|
+
}, () => messenger.send(chatId, text, options), (sent) => ({ ids: { chat: sent.message.chatId || chatId, message_id: sent.message.id } })), "send"),
|
|
1052
|
+
...watch ? {
|
|
1053
|
+
watch: /* @__PURE__ */ __name((onEvent, signal, onReady) => counted("messages.watch", onEvent, (counting) => watch.call(messenger, counting, signal, onReady), byEvent), "watch")
|
|
1054
|
+
} : {},
|
|
1055
|
+
...feed ? { feed: /* @__PURE__ */ __name((onBatch, signal) => timed("history.feed", {}, () => feed.call(messenger, onBatch, signal)), "feed") } : {},
|
|
1056
|
+
...listen ? {
|
|
1057
|
+
listen: /* @__PURE__ */ __name((onEvent, signal) => counted("messages.listen", onEvent, (counting) => listen.call(messenger, counting, signal), byEvent), "listen")
|
|
1058
|
+
} : {},
|
|
1059
|
+
...listenHistory ? {
|
|
1060
|
+
listenHistory: /* @__PURE__ */ __name((onBatch, signal) => counted("history.listen", onBatch, (counting) => listenHistory.call(messenger, counting, signal), byPart), "listenHistory")
|
|
1061
|
+
} : {},
|
|
1062
|
+
logout: /* @__PURE__ */ __name(() => timed("session.logout", {}, () => messenger.logout()), "logout"),
|
|
1063
|
+
close: /* @__PURE__ */ __name(() => messenger.close(), "close")
|
|
1064
|
+
}, (name, call) => (...args) => timed(`adapter.${name}`, {}, () => call(...args)));
|
|
1065
|
+
}, "observed");
|
|
1066
|
+
var byEvent = /* @__PURE__ */ __name((event, counts) => {
|
|
1067
|
+
counts[event.event] = (counts[event.event] ?? 0) + 1;
|
|
1068
|
+
}, "byEvent");
|
|
1069
|
+
var byPart = /* @__PURE__ */ __name((batch, counts) => {
|
|
1070
|
+
counts.batches = (counts.batches ?? 0) + 1;
|
|
1071
|
+
for (const [part, items] of Object.entries(batch))
|
|
1072
|
+
if (Array.isArray(items) && items.length > 0)
|
|
1073
|
+
counts[part] = (counts[part] ?? 0) + items.length;
|
|
1074
|
+
}, "byPart");
|
|
1075
|
+
|
|
1076
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/cli/messenger/context.js
|
|
1071
1077
|
var lazyStore = /* @__PURE__ */ __name((env, command, version) => {
|
|
1072
1078
|
let opened;
|
|
1073
1079
|
return {
|
|
@@ -1475,9 +1481,12 @@ export {
|
|
|
1475
1481
|
commandPermissions,
|
|
1476
1482
|
knownPermissionKeys,
|
|
1477
1483
|
knownBeside,
|
|
1484
|
+
unknownPermissionKeys,
|
|
1478
1485
|
unknownPermissionIssues,
|
|
1479
1486
|
refuseUnknownPermissionKeys,
|
|
1487
|
+
stored,
|
|
1480
1488
|
fill,
|
|
1489
|
+
connectFor,
|
|
1481
1490
|
connectedFor,
|
|
1482
1491
|
refuseLocalWrite,
|
|
1483
1492
|
messengerContext
|