@wirecat/cli-template 0.14.0 → 0.16.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/.github/workflows/ci.yml +17 -0
- package/AGENTS.md +56 -2
- package/CHANGELOG.md +46 -0
- package/README.md +12 -4
- package/biome.json +2 -2
- package/contracts/mcp-tools.json +2 -2
- package/dist/bin/clidev.js +2 -2
- package/dist/bundle/{chunk-LU4A2T7Y.js → all-profiles-FS7AEOE7.js} +8 -5
- package/dist/bundle/{anthropic-ICTW7CNQ.js → anthropic-5RN7BGDI.js} +3 -3
- package/dist/bundle/{app-server-B6BCKXR7.js → app-server-WGTKZQKJ.js} +28 -29
- package/dist/bundle/{bun-sqlite-JE6FJFQT.js → bun-sqlite-WK2IGBGD.js} +2 -2
- package/dist/bundle/{chunk-AS2PJNQ2.js → chunk-2MWNE4L3.js} +1 -1
- package/dist/bundle/{chunk-2DAXUNTS.js → chunk-5HHIPDNW.js} +1 -1
- package/dist/bundle/{chunk-YOJLIVGO.js → chunk-5KAYQKBK.js} +1 -1
- package/dist/bundle/{chunk-62JRF2JA.js → chunk-6WOJIAYA.js} +1 -1
- package/dist/bundle/chunk-7EUX7AZV.js +141 -0
- package/dist/bundle/{chunk-7F5VMLVK.js → chunk-ADFSSIV4.js} +1 -1
- package/dist/bundle/{chunk-U6QD3J3F.js → chunk-ATHZEV2Z.js} +2 -2
- package/dist/bundle/{chunk-UT5TQ6MD.js → chunk-BPMKAZSS.js} +8 -8
- package/dist/bundle/{chunk-DZLHY4IA.js → chunk-C3GNOEJP.js} +1 -1
- package/dist/bundle/{chunk-PIJUGF5F.js → chunk-CTBHQRX6.js} +1 -1
- package/dist/bundle/{chunk-LFLSV353.js → chunk-DEHBTFIC.js} +1 -1
- package/dist/bundle/{chunk-NVNUUHT5.js → chunk-EA3TMI4A.js} +8 -8
- package/dist/bundle/{chunk-BEBD27QT.js → chunk-EILS4BTQ.js} +16 -18
- package/dist/bundle/{chunk-BVLPNNEL.js → chunk-ENDBOYQR.js} +14 -14
- package/dist/bundle/{chunk-6AW4DDK4.js → chunk-ETJXPB6A.js} +1 -1
- package/dist/bundle/{chunk-LATYBJ4T.js → chunk-FMO6F5Q2.js} +1 -1
- package/dist/bundle/{chunk-RJ7AS7UB.js → chunk-HTYLT6ME.js} +24 -7
- package/dist/bundle/{chunk-F34HGYWF.js → chunk-JFXWLQ2L.js} +1 -1
- package/dist/bundle/{chunk-IZKXJJ7V.js → chunk-JJZCPBH3.js} +29 -6
- package/dist/bundle/{chunk-G7W53MQP.js → chunk-LRHX62ZF.js} +2 -2
- package/dist/bundle/{chunk-SOYOOU2D.js → chunk-MBBOINK4.js} +2 -2
- package/dist/bundle/{chunk-BM5ZCDPQ.js → chunk-MEXT6XDP.js} +2 -2
- package/dist/bundle/{chunk-R2JKPHH5.js → chunk-NVPWZF67.js} +1 -1
- package/dist/bundle/{chunk-45244QQ6.js → chunk-OF56L2JU.js} +2 -2
- package/dist/bundle/{chunk-4PA6DJ7F.js → chunk-OGTRPW2K.js} +3 -3
- package/dist/bundle/{chunk-VXOR76ZL.js → chunk-ORV4EGNC.js} +1 -1
- package/dist/bundle/{chunk-TJJ2XSJP.js → chunk-QGOOPPEW.js} +2 -2
- package/dist/bundle/{chunk-NH6LZ3H3.js → chunk-RFJKNFVF.js} +3 -3
- package/dist/bundle/{chunk-R5RYPD23.js → chunk-RYOAQCVJ.js} +1 -1
- package/dist/bundle/{chunk-66VMJGV6.js → chunk-SKBRW5U3.js} +1 -1
- package/dist/bundle/{chunk-BWBZCYUN.js → chunk-TXHCL75B.js} +43 -6
- package/dist/bundle/{chunk-QXOSPYM3.js → chunk-VPCXYY46.js} +1 -1
- package/dist/bundle/{chunk-IOJ2DTCY.js → chunk-WDWP5N6M.js} +2 -0
- package/dist/bundle/{chunk-HYTHTSJP.js → chunk-WM5AMTRY.js} +4 -4
- package/dist/bundle/{chunk-ASHVHS52.js → chunk-YNROUY3R.js} +10 -10
- package/dist/bundle/{chunk-DQIBGCF3.js → chunk-Z5NL6YNU.js} +2 -2
- package/dist/bundle/{chunk-5SAF3XOL.js → chunk-ZSY4WAGI.js} +28 -21
- package/dist/bundle/clidev.js +3 -3
- package/dist/bundle/{command-contract-JMVMT5HT.js → command-contract-ZDU73EPH.js} +9 -9
- package/dist/bundle/{decode-NXB5UKMO.js → decode-QMLOGZ6R.js} +2 -2
- package/dist/bundle/{embed-IKZ24BMC.js → embed-PIR2LJR2.js} +4 -4
- package/dist/bundle/{embedder-GMQ24DOQ.js → embedder-6KBRPAEQ.js} +4 -4
- package/dist/bundle/{first-run-MDD4SIUK.js → first-run-JO3CMY3Z.js} +7 -7
- package/dist/bundle/{first-screen-376CXGXJ.js → first-screen-3T5IXTFL.js} +10 -10
- package/dist/bundle/{node-sqlite-73Z4SFOA.js → node-sqlite-LIK6OYNF.js} +2 -2
- package/dist/bundle/{oauth-EVTPAMZP.js → oauth-7FVF7HQQ.js} +4 -4
- package/dist/bundle/{open-46WZAPJ3.js → open-CRZDEATN.js} +2 -2
- package/dist/bundle/{openai-GWRDAHDU.js → openai-WAJ6WREQ.js} +11 -32
- package/dist/bundle/{program-B3CY3FP7.js → program-ZFFFPBRS.js} +2263 -300
- package/dist/bundle/{prompt-IVEYRLS5.js → prompt-QQIVHO3M.js} +3 -3
- package/dist/bundle/{recognize-WVEKHODM.js → recognize-4KLBZDEC.js} +2 -2
- package/dist/bundle/{remote-4K5VPMC7.js → remote-BABMZTHA.js} +5 -5
- package/dist/bundle/{rerank-V24UJZYJ.js → rerank-P3IQQJIL.js} +4 -4
- package/dist/bundle/{chunk-EMHCXXNJ.js → serve-25SSAKRZ.js} +6 -4
- package/dist/bundle/server-G4GCDMYI.js +52 -0
- package/dist/bundle/{chunk-PX2KP4QE.js → server-P4XUYY5A.js} +27 -7
- package/dist/bundle/{state-ZPYGECVP.js → state-QCQALQBJ.js} +3 -3
- package/dist/bundle/{store-6JQCLPQF.js → store-ZECPRGGH.js} +7 -7
- package/dist/bundle/store-maintenance-command-ECUO5G6L.js +42 -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/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +96 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +83 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +58 -0
- package/dist/context.js.map +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +26 -5
- package/dist/program.js.map +1 -1
- 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/transport.d.ts +42 -0
- package/dist/sample/transport.d.ts.map +1 -0
- package/dist/sample/transport.js +152 -0
- package/dist/sample/transport.js.map +1 -0
- package/dist/token.d.ts +16 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +32 -0
- package/dist/token.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/commands.md +234 -12
- package/docs/configuration.md +1 -1
- package/docs/dev/reference-clis.md +3 -2
- package/docs/dev/test-matrix.md +36 -5
- package/docs/index.md +4 -3
- package/docs/security.md +4 -2
- package/kit/dist/new.js +6 -3
- package/lint/overrides.json +9 -1
- package/package.json +3 -4
- package/scripts/test-matrix-untested.ts +19 -0
- package/skills/clidev-cli/SKILL.md +1 -1
- package/src/commands/comments.ts +167 -0
- package/src/commands/session.ts +144 -0
- package/src/comments.test.ts +258 -0
- package/src/config.ts +5 -2
- package/src/context.ts +78 -0
- package/src/mcp.test.ts +71 -76
- package/src/program.test.ts +39 -17
- package/src/program.ts +30 -5
- package/src/sample/comments.ts +51 -0
- package/src/sample/transport.test.ts +117 -0
- package/src/sample/transport.ts +184 -0
- package/src/testing/fake-comments.ts +167 -0
- package/src/testing/harness.ts +51 -0
- package/src/token.ts +42 -0
- package/src/version.ts +1 -1
- package/dist/bundle/all-profiles-NVB2HT2S.js +0 -24
- package/dist/bundle/chunk-GUFPQZUA.js +0 -48
- package/dist/bundle/chunk-NL2DQPT7.js +0 -2
- package/dist/bundle/mcp-KHUZOJO6.js +0 -82
- package/dist/bundle/mcp-MZHWJXAE.js +0 -152
- package/dist/bundle/serve-PJWSOV7F.js +0 -19
- package/dist/bundle/server-2ZN7KZHZ.js +0 -40
- package/dist/bundle/server-5VYM7CCF.js +0 -53
- package/dist/bundle/store-maintenance-command-7XICIYHW.js +0 -42
- package/dist/commands/doctor.d.ts +0 -77
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -74
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/mcp.d.ts +0 -3
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js +0 -97
- package/dist/commands/mcp.js.map +0 -1
- package/dist/mcp.d.ts +0 -29
- package/dist/mcp.d.ts.map +0 -1
- package/dist/mcp.js +0 -98
- package/dist/mcp.js.map +0 -1
- package/src/commands/doctor.ts +0 -86
- package/src/commands/mcp.ts +0 -130
- package/src/mcp-http.test.ts +0 -172
- package/src/mcp.ts +0 -140
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { createRequire as __bundleRequire } from "node:module";
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
providerWaitMs,
|
|
5
|
+
readJsonResponse,
|
|
6
|
+
statusToCode
|
|
7
|
+
} from "./chunk-7EUX7AZV.js";
|
|
3
8
|
import {
|
|
4
9
|
listen
|
|
5
10
|
} from "./chunk-NENYWEXF.js";
|
|
@@ -25,11 +30,14 @@ import {
|
|
|
25
30
|
historyLimitGaps,
|
|
26
31
|
historySkipsOf,
|
|
27
32
|
keepRefreshedRefs,
|
|
33
|
+
mcpUrlOf,
|
|
28
34
|
meaningNote,
|
|
29
35
|
messagesAnswer,
|
|
30
36
|
notesAnswer,
|
|
31
37
|
officialAnswer,
|
|
32
38
|
offsetOf,
|
|
39
|
+
portOf,
|
|
40
|
+
publicUrlOf,
|
|
33
41
|
rankingAnswer,
|
|
34
42
|
readsStdin,
|
|
35
43
|
refreshAnswer,
|
|
@@ -44,12 +52,7 @@ import {
|
|
|
44
52
|
syncsFirst,
|
|
45
53
|
taskStatsAnswer,
|
|
46
54
|
waitingAnswer
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import {
|
|
49
|
-
mcpUrlOf,
|
|
50
|
-
portOf,
|
|
51
|
-
publicUrlOf
|
|
52
|
-
} from "./chunk-GUFPQZUA.js";
|
|
55
|
+
} from "./chunk-TXHCL75B.js";
|
|
53
56
|
import "./chunk-YIVY2WI3.js";
|
|
54
57
|
import {
|
|
55
58
|
INPUT_FIELD_REASONS,
|
|
@@ -63,7 +66,7 @@ import {
|
|
|
63
66
|
skillStatus,
|
|
64
67
|
skillVersion,
|
|
65
68
|
withVersion
|
|
66
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-WM5AMTRY.js";
|
|
67
70
|
import {
|
|
68
71
|
DAY_MS,
|
|
69
72
|
DRY_RUN_DAYS,
|
|
@@ -103,7 +106,7 @@ import {
|
|
|
103
106
|
writeRepliesFile,
|
|
104
107
|
writeRepliesState,
|
|
105
108
|
writeReplyConsent
|
|
106
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-ENDBOYQR.js";
|
|
107
110
|
import {
|
|
108
111
|
DEFAULT_PACE,
|
|
109
112
|
FloodMemory,
|
|
@@ -111,7 +114,9 @@ import {
|
|
|
111
114
|
RecipientList,
|
|
112
115
|
SendJournal,
|
|
113
116
|
answerOf,
|
|
117
|
+
commandPermissions,
|
|
114
118
|
floodPathFor,
|
|
119
|
+
guardFor,
|
|
115
120
|
holdEnd,
|
|
116
121
|
knownBeside,
|
|
117
122
|
knownPermissionKeys,
|
|
@@ -124,7 +129,7 @@ import {
|
|
|
124
129
|
sendsPathFor,
|
|
125
130
|
terminalAsker,
|
|
126
131
|
unknownPermissionIssues
|
|
127
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-JJZCPBH3.js";
|
|
128
133
|
import {
|
|
129
134
|
ADMIN_RIGHTS,
|
|
130
135
|
AGENDA_QUERY,
|
|
@@ -189,6 +194,7 @@ import {
|
|
|
189
194
|
chatShown,
|
|
190
195
|
checkMediaArchive,
|
|
191
196
|
closedStateOf,
|
|
197
|
+
commandPath,
|
|
192
198
|
communicationFields,
|
|
193
199
|
contactAnswer,
|
|
194
200
|
contactShown,
|
|
@@ -298,36 +304,36 @@ import {
|
|
|
298
304
|
withQuery,
|
|
299
305
|
withoutPhone,
|
|
300
306
|
wrongAccount
|
|
301
|
-
} from "./chunk-
|
|
307
|
+
} from "./chunk-ZSY4WAGI.js";
|
|
302
308
|
import {
|
|
303
309
|
acquireLock,
|
|
304
310
|
readBoundedUtf8File,
|
|
305
311
|
syncDirectory,
|
|
306
312
|
writeFileAtomic
|
|
307
|
-
} from "./chunk-
|
|
313
|
+
} from "./chunk-CTBHQRX6.js";
|
|
308
314
|
import {
|
|
309
315
|
readSecret
|
|
310
|
-
} from "./chunk-
|
|
316
|
+
} from "./chunk-LRHX62ZF.js";
|
|
311
317
|
import {
|
|
312
318
|
MAX_BUFFERED_INPUT,
|
|
313
319
|
bufferedInput,
|
|
314
320
|
provideInputPolicy
|
|
315
|
-
} from "./chunk-
|
|
321
|
+
} from "./chunk-5HHIPDNW.js";
|
|
316
322
|
import {
|
|
317
323
|
commandsText,
|
|
318
324
|
installHelp
|
|
319
|
-
} from "./chunk-
|
|
325
|
+
} from "./chunk-OGTRPW2K.js";
|
|
320
326
|
import "./chunk-HTQTIKWP.js";
|
|
321
327
|
import {
|
|
322
328
|
setupAtStart
|
|
323
|
-
} from "./chunk-
|
|
329
|
+
} from "./chunk-YNROUY3R.js";
|
|
324
330
|
import {
|
|
325
331
|
installerOf,
|
|
326
332
|
isNewer,
|
|
327
333
|
latestVersion,
|
|
328
334
|
runUpdate,
|
|
329
335
|
updateNotice
|
|
330
|
-
} from "./chunk-
|
|
336
|
+
} from "./chunk-2MWNE4L3.js";
|
|
331
337
|
import "./chunk-7Z4HR6GO.js";
|
|
332
338
|
import {
|
|
333
339
|
httpLaunchFile,
|
|
@@ -337,23 +343,23 @@ import {
|
|
|
337
343
|
readHttpLaunch,
|
|
338
344
|
readHttpLock,
|
|
339
345
|
signedInClients
|
|
340
|
-
} from "./chunk-
|
|
346
|
+
} from "./chunk-ETJXPB6A.js";
|
|
341
347
|
import {
|
|
342
348
|
lockPath,
|
|
343
349
|
readLock
|
|
344
|
-
} from "./chunk-
|
|
350
|
+
} from "./chunk-C3GNOEJP.js";
|
|
345
351
|
import {
|
|
346
352
|
isLocal,
|
|
347
353
|
remoteModel
|
|
348
|
-
} from "./chunk-
|
|
349
|
-
import "./chunk-
|
|
350
|
-
import "./chunk-
|
|
354
|
+
} from "./chunk-MBBOINK4.js";
|
|
355
|
+
import "./chunk-RYOAQCVJ.js";
|
|
356
|
+
import "./chunk-FMO6F5Q2.js";
|
|
351
357
|
import {
|
|
352
358
|
SCHEMA_DIALECT,
|
|
353
359
|
commandContract,
|
|
354
360
|
commandPathOf,
|
|
355
361
|
findCommand
|
|
356
|
-
} from "./chunk-
|
|
362
|
+
} from "./chunk-MEXT6XDP.js";
|
|
357
363
|
import {
|
|
358
364
|
AUTHORITY_KEY,
|
|
359
365
|
Argument,
|
|
@@ -422,6 +428,7 @@ import {
|
|
|
422
428
|
commandWords,
|
|
423
429
|
contact,
|
|
424
430
|
contactNote,
|
|
431
|
+
currentAttempt,
|
|
425
432
|
describeOptions,
|
|
426
433
|
describeProgram,
|
|
427
434
|
destroysNothing,
|
|
@@ -465,6 +472,7 @@ import {
|
|
|
465
472
|
listJobs,
|
|
466
473
|
listOf,
|
|
467
474
|
listRuns,
|
|
475
|
+
logsInOrOut,
|
|
468
476
|
mailHolderVariable,
|
|
469
477
|
meetingPreparation,
|
|
470
478
|
meetingProjectCandidates,
|
|
@@ -485,6 +493,7 @@ import {
|
|
|
485
493
|
printItem,
|
|
486
494
|
processRun,
|
|
487
495
|
profileFree,
|
|
496
|
+
profilesHere,
|
|
488
497
|
provide,
|
|
489
498
|
reachesOtherService,
|
|
490
499
|
reaction,
|
|
@@ -499,15 +508,18 @@ import {
|
|
|
499
508
|
recordLogFor,
|
|
500
509
|
recorded,
|
|
501
510
|
recordedRun,
|
|
511
|
+
refuseCommandName,
|
|
502
512
|
refuseJoinedPath,
|
|
503
513
|
refuseUnderReadOnly,
|
|
504
514
|
registryProfiles,
|
|
515
|
+
rememberAccount,
|
|
505
516
|
removeJob,
|
|
506
517
|
renderAnswer,
|
|
507
518
|
renderDocument,
|
|
508
519
|
repairConfigText,
|
|
509
520
|
rootOf,
|
|
510
521
|
rootOf2,
|
|
522
|
+
runEvent,
|
|
511
523
|
runnable,
|
|
512
524
|
runsDirFor,
|
|
513
525
|
runtime,
|
|
@@ -544,7 +556,7 @@ import {
|
|
|
544
556
|
wasSettled,
|
|
545
557
|
withLines,
|
|
546
558
|
withoutProviderRefs
|
|
547
|
-
} from "./chunk-
|
|
559
|
+
} from "./chunk-HTYLT6ME.js";
|
|
548
560
|
import {
|
|
549
561
|
agentOf,
|
|
550
562
|
isCliFailure,
|
|
@@ -553,8 +565,8 @@ import {
|
|
|
553
565
|
providerErrorKey,
|
|
554
566
|
runContextOf,
|
|
555
567
|
secretInput
|
|
556
|
-
} from "./chunk-
|
|
557
|
-
import "./chunk-
|
|
568
|
+
} from "./chunk-ORV4EGNC.js";
|
|
569
|
+
import "./chunk-ATHZEV2Z.js";
|
|
558
570
|
import {
|
|
559
571
|
alive,
|
|
560
572
|
carries
|
|
@@ -563,7 +575,7 @@ import {
|
|
|
563
575
|
IDENTITY,
|
|
564
576
|
PACKAGE,
|
|
565
577
|
SKILL
|
|
566
|
-
} from "./chunk-
|
|
578
|
+
} from "./chunk-VPCXYY46.js";
|
|
567
579
|
import {
|
|
568
580
|
ACCOUNT_GROUPS_SETTING,
|
|
569
581
|
ATTACHMENT_LIMIT_ENV,
|
|
@@ -598,11 +610,11 @@ import {
|
|
|
598
610
|
savedTaskCategories,
|
|
599
611
|
stemmersOrigin,
|
|
600
612
|
titlePart
|
|
601
|
-
} from "./chunk-
|
|
613
|
+
} from "./chunk-EA3TMI4A.js";
|
|
602
614
|
import {
|
|
603
615
|
DEFAULT_STEMMERS,
|
|
604
616
|
parseStemmers
|
|
605
|
-
} from "./chunk-
|
|
617
|
+
} from "./chunk-NVPWZF67.js";
|
|
606
618
|
import {
|
|
607
619
|
PRIORITY_LABELS,
|
|
608
620
|
SAVE_HELP,
|
|
@@ -625,7 +637,7 @@ import {
|
|
|
625
637
|
validateQuery,
|
|
626
638
|
walkQuery,
|
|
627
639
|
zonedTime
|
|
628
|
-
} from "./chunk-
|
|
640
|
+
} from "./chunk-5KAYQKBK.js";
|
|
629
641
|
import "./chunk-3WDYHOAF.js";
|
|
630
642
|
import {
|
|
631
643
|
DEFAULT_TASK_CATEGORIES,
|
|
@@ -637,16 +649,16 @@ import {
|
|
|
637
649
|
unlistedNote,
|
|
638
650
|
withTaskCategory,
|
|
639
651
|
writeTaskCategoryEdits
|
|
640
|
-
} from "./chunk-
|
|
652
|
+
} from "./chunk-QGOOPPEW.js";
|
|
641
653
|
import {
|
|
642
654
|
openCache
|
|
643
|
-
} from "./chunk-
|
|
655
|
+
} from "./chunk-RFJKNFVF.js";
|
|
644
656
|
import "./chunk-3MDNAYQA.js";
|
|
645
657
|
import "./chunk-CGFQT3LQ.js";
|
|
646
658
|
import {
|
|
647
659
|
isTextModelInstalled,
|
|
648
660
|
textModelsDirectory
|
|
649
|
-
} from "./chunk-
|
|
661
|
+
} from "./chunk-Z5NL6YNU.js";
|
|
650
662
|
import {
|
|
651
663
|
DEFAULT_ORDER,
|
|
652
664
|
OPENAI_TRANSCRIBE_MODEL,
|
|
@@ -660,10 +672,10 @@ import {
|
|
|
660
672
|
orderedModels,
|
|
661
673
|
speechModel,
|
|
662
674
|
vadPath
|
|
663
|
-
} from "./chunk-
|
|
675
|
+
} from "./chunk-OF56L2JU.js";
|
|
664
676
|
import {
|
|
665
677
|
storePath
|
|
666
|
-
} from "./chunk-
|
|
678
|
+
} from "./chunk-6WOJIAYA.js";
|
|
667
679
|
import {
|
|
668
680
|
BATCH_LIMITS,
|
|
669
681
|
COMPACT_FLAG,
|
|
@@ -705,6 +717,7 @@ import {
|
|
|
705
717
|
pipe,
|
|
706
718
|
prepareBatch,
|
|
707
719
|
processStreams,
|
|
720
|
+
realSleep,
|
|
708
721
|
record,
|
|
709
722
|
regex,
|
|
710
723
|
renderError,
|
|
@@ -718,9 +731,10 @@ import {
|
|
|
718
731
|
union,
|
|
719
732
|
unknown,
|
|
720
733
|
visibleControls,
|
|
734
|
+
wallClock,
|
|
721
735
|
writeSecurely,
|
|
722
736
|
writes
|
|
723
|
-
} from "./chunk-
|
|
737
|
+
} from "./chunk-WDWP5N6M.js";
|
|
724
738
|
import "./chunk-Y5E2WNWB.js";
|
|
725
739
|
import {
|
|
726
740
|
__name
|
|
@@ -1366,16 +1380,16 @@ var guardedApp = /* @__PURE__ */ __name(async (guard, connection, { chat: chat2,
|
|
|
1366
1380
|
}, "guardedApp");
|
|
1367
1381
|
|
|
1368
1382
|
// node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_type_ab8c0b68b8b4768d5b87d6e249ef10da/node_modules/@wirecat/cli-core/dist/sends/polls.js
|
|
1369
|
-
var pollVoters = /* @__PURE__ */ __name(async (connection, { chat: chat2, message: message2, answer:
|
|
1383
|
+
var pollVoters = /* @__PURE__ */ __name(async (connection, { chat: chat2, message: message2, answer: answer3, limit }) => {
|
|
1370
1384
|
const voters = capability(connection, "pollVoters", "list who voted");
|
|
1371
1385
|
const read3 = capability(connection, "poll", "read a poll");
|
|
1372
1386
|
const { id: chatId } = await connection.resolve(chat2);
|
|
1373
1387
|
const poll = await read3(chatId, message2);
|
|
1374
1388
|
if (poll.anonymous)
|
|
1375
1389
|
throw new CliError("validation_error", "nobody can see who voted in an anonymous poll");
|
|
1376
|
-
if (
|
|
1377
|
-
throw new CliError("validation_error", `the poll has no answer ${
|
|
1378
|
-
const page = await voters(chatId, message2, { limit, ...
|
|
1390
|
+
if (answer3 !== void 0 && !poll.answers.some((one) => one.id === answer3))
|
|
1391
|
+
throw new CliError("validation_error", `the poll has no answer ${answer3}; \`polls show\` prints their ids`);
|
|
1392
|
+
const page = await voters(chatId, message2, { limit, ...answer3 === void 0 ? {} : { answerId: answer3 } });
|
|
1379
1393
|
return { chatId, messageId: message2, ...page };
|
|
1380
1394
|
}, "pollVoters");
|
|
1381
1395
|
var guardedVote = /* @__PURE__ */ __name(async (guard, connection, { chat: chat2, message: message2, answers }) => {
|
|
@@ -1524,12 +1538,12 @@ var priced = /* @__PURE__ */ __name((argv) => {
|
|
|
1524
1538
|
}, "priced");
|
|
1525
1539
|
var reportOf = /* @__PURE__ */ __name((stdout) => {
|
|
1526
1540
|
try {
|
|
1527
|
-
const
|
|
1528
|
-
if (
|
|
1541
|
+
const answer3 = JSON.parse(stdout.toString("utf8"));
|
|
1542
|
+
if (answer3?.type !== "result")
|
|
1529
1543
|
return { text: stdout };
|
|
1530
1544
|
return {
|
|
1531
|
-
text: typeof
|
|
1532
|
-
...typeof
|
|
1545
|
+
text: typeof answer3.result === "string" ? Buffer.from(answer3.result) : stdout,
|
|
1546
|
+
...typeof answer3.total_cost_usd === "number" ? { costUsd: answer3.total_cost_usd } : {}
|
|
1533
1547
|
};
|
|
1534
1548
|
} catch {
|
|
1535
1549
|
return { text: stdout };
|
|
@@ -1582,9 +1596,9 @@ var shortTime = /* @__PURE__ */ __name((iso) => {
|
|
|
1582
1596
|
const two = /* @__PURE__ */ __name((n2) => String(n2).padStart(2, "0"), "two");
|
|
1583
1597
|
return `${at2.getFullYear()}-${two(at2.getMonth() + 1)}-${two(at2.getDate())} ${two(at2.getHours())}:${two(at2.getMinutes())}`;
|
|
1584
1598
|
}, "shortTime");
|
|
1585
|
-
var failingNotice = /* @__PURE__ */ __name((command, runs,
|
|
1599
|
+
var failingNotice = /* @__PURE__ */ __name((command, runs, statusCommand4) => {
|
|
1586
1600
|
const lines2 = runs.flatMap(({ job: job2, last }) => last && last.exitCode !== 0 ? [
|
|
1587
|
-
`${command}: scheduled ${job2} failing since ${shortTime(last.failingSince ?? last.at)} (${last.failures ?? 1} run${(last.failures ?? 1) === 1 ? "" : "s"})${last.reason ? `: ${last.reason}` : ""} \u2014 ${
|
|
1601
|
+
`${command}: scheduled ${job2} failing since ${shortTime(last.failingSince ?? last.at)} (${last.failures ?? 1} run${(last.failures ?? 1) === 1 ? "" : "s"})${last.reason ? `: ${last.reason}` : ""} \u2014 ${statusCommand4}`
|
|
1588
1602
|
] : []);
|
|
1589
1603
|
return lines2.length ? lines2.join("\n") : void 0;
|
|
1590
1604
|
}, "failingNotice");
|
|
@@ -2086,14 +2100,14 @@ var PreviewComplete = class extends Error {
|
|
|
2086
2100
|
};
|
|
2087
2101
|
var preview = /* @__PURE__ */ __name((command, settings, tool, keys, messenger = true) => {
|
|
2088
2102
|
const path = commandPathOf(command);
|
|
2089
|
-
const { permissions } = settings;
|
|
2103
|
+
const { permissions: permissions2 } = settings;
|
|
2090
2104
|
const declared = typeof keys === "object" ? keys : void 0;
|
|
2091
2105
|
const keyOf3 = typeof keys === "object" ? keys.keyOf : keys;
|
|
2092
2106
|
refuseUnknownPermissionKeys(command, settings, tool, declared ?? (keyOf3 && ((one) => keyOf3(commandPathOf(one)))));
|
|
2093
2107
|
const key = declared ? declared.keyOf(path) : keyOf3?.(path) ?? keyForCommand(path);
|
|
2094
|
-
const level = key ? levelFor(
|
|
2108
|
+
const level = key ? levelFor(permissions2, key, declared?.defaults).level : "allow";
|
|
2095
2109
|
for (const source of declared ? [] : readKeysForCommand(path)) {
|
|
2096
|
-
if (levelFor(
|
|
2110
|
+
if (levelFor(permissions2, source).level === "deny")
|
|
2097
2111
|
throw new CliError("permission_error", `this profile does not permit ${source}`, { permission: source });
|
|
2098
2112
|
}
|
|
2099
2113
|
const meta = metaOf(command);
|
|
@@ -2102,7 +2116,7 @@ var preview = /* @__PURE__ */ __name((command, settings, tool, keys, messenger =
|
|
|
2102
2116
|
throw new CliError("permission_error", `this profile does not permit ${path.join(" ")}`, { permission: key });
|
|
2103
2117
|
const also = (declared?.alsoChecks?.(path) ?? []).map((one) => ({
|
|
2104
2118
|
key: one,
|
|
2105
|
-
level: levelFor(
|
|
2119
|
+
level: levelFor(permissions2, one, declared?.defaults).level
|
|
2106
2120
|
}));
|
|
2107
2121
|
const stopped = also.find((one) => one.level === "deny" || writes2 && one.level === "readonly");
|
|
2108
2122
|
if (stopped)
|
|
@@ -2617,7 +2631,7 @@ var runOnce = /* @__PURE__ */ __name(async (argv, definition2, options) => {
|
|
|
2617
2631
|
forEachCommand(program, (child) => child.exitOverride());
|
|
2618
2632
|
const profiled = liftProfile(argv, commandWords(program), valuedOptions(program));
|
|
2619
2633
|
const { profile } = profiled;
|
|
2620
|
-
const lifted = options.agent ? profiled.rest : liftOptionsAfterDashes(profiled.rest, (words3) => commandAt(program,
|
|
2634
|
+
const lifted = options.agent ? profiled.rest : liftOptionsAfterDashes(profiled.rest, (words3) => commandAt(program, commandPath2(program, words3)));
|
|
2621
2635
|
const liftedEnd = lifted.indexOf("--");
|
|
2622
2636
|
const liftedFlags = lifted.slice(0, liftedEnd < 0 ? void 0 : liftedEnd);
|
|
2623
2637
|
machine ||= isMachine(liftedFlags);
|
|
@@ -2626,22 +2640,22 @@ var runOnce = /* @__PURE__ */ __name(async (argv, definition2, options) => {
|
|
|
2626
2640
|
try {
|
|
2627
2641
|
for (const words3 of [flags, liftedFlags])
|
|
2628
2642
|
refuseJoinedPath(program, words3.filter((word) => !word.startsWith("-")), profile !== void 0 && !/\s/.test(profile) ? [profile] : []);
|
|
2629
|
-
} catch (
|
|
2630
|
-
const settled = await settleFailure(
|
|
2631
|
-
return report(streams, reporting, failed(definition2, program, lifted,
|
|
2643
|
+
} catch (failure2) {
|
|
2644
|
+
const settled = await settleFailure(failure2, { definition: definition2, program, rest: lifted, argv, profile, options });
|
|
2645
|
+
return report(streams, reporting, failed(definition2, program, lifted, failure2, settled, debug));
|
|
2632
2646
|
}
|
|
2633
2647
|
if (profile !== void 0)
|
|
2634
2648
|
program.setOptionValue("profile", profile);
|
|
2635
|
-
const requested = liftJson(lifted, (words3) => commandAt(program,
|
|
2649
|
+
const requested = liftJson(lifted, (words3) => commandAt(program, commandPath2(program, words3)));
|
|
2636
2650
|
const rest = requested.argv;
|
|
2637
2651
|
if (requested.fields !== void 0)
|
|
2638
2652
|
program.setOptionValue("fields", requested.fields);
|
|
2639
2653
|
if (profile !== void 0 && rest.length === 0) {
|
|
2640
2654
|
const asProfile = commandAt(program, "account show") && isProfileName(profile) ? `, or \`${command} ${profile} account show\` if "${profile}" is your profile` : "";
|
|
2641
2655
|
const message2 = `"${profile}" is not a command, so it was read as a profile name \u2014 and no command followed it. Run \`${command} --help\` for the commands${asProfile}.`;
|
|
2642
|
-
const
|
|
2643
|
-
const settled = await settleFailure(
|
|
2644
|
-
return report(streams, reporting, failed(definition2, program, rest,
|
|
2656
|
+
const failure2 = new CliError("validation_error", message2, { param: "profile" });
|
|
2657
|
+
const settled = await settleFailure(failure2, { definition: definition2, program, rest, argv, profile, options });
|
|
2658
|
+
return report(streams, reporting, failed(definition2, program, rest, failure2, settled, debug));
|
|
2645
2659
|
}
|
|
2646
2660
|
try {
|
|
2647
2661
|
await control.race(() => program.parseAsync(rest, { from: "user" }));
|
|
@@ -2673,16 +2687,16 @@ var runOnce = /* @__PURE__ */ __name(async (argv, definition2, options) => {
|
|
|
2673
2687
|
streams.diagnostic(help.replace(/\n$/, ""));
|
|
2674
2688
|
return exitCodeFor("validation_error");
|
|
2675
2689
|
}
|
|
2676
|
-
const group =
|
|
2690
|
+
const group = commandPath2(program, rest);
|
|
2677
2691
|
message2 = `give a command \u2014 run \`${[command, group, "--help"].filter(Boolean).join(" ")}\` for the commands`;
|
|
2678
2692
|
}
|
|
2679
2693
|
if (profile !== void 0 && error.code === "commander.unknownCommand" && rest[0] !== void 0 && !commandWords(program).has(rest[0])) {
|
|
2680
2694
|
message2 = message2.trimEnd();
|
|
2681
2695
|
message2 += ` \u2014 "${profile}" is not a command, so it was read as a profile name \u2014 which left "${rest[0]}" to be one.`;
|
|
2682
2696
|
}
|
|
2683
|
-
const
|
|
2684
|
-
const settled2 = await settleFailure(
|
|
2685
|
-
return report(streams, reporting, failed(definition2, program, rest,
|
|
2697
|
+
const failure2 = new CliError("validation_error", message2);
|
|
2698
|
+
const settled2 = await settleFailure(failure2, { definition: definition2, program, rest, argv, profile, options });
|
|
2699
|
+
return report(streams, reporting, failed(definition2, program, rest, failure2, settled2, debug));
|
|
2686
2700
|
}
|
|
2687
2701
|
const settled = await settleFailure(error, { definition: definition2, program, rest, argv, profile, options });
|
|
2688
2702
|
const exit2 = report(streams, reporting, failed(definition2, program, rest, error, settled, debug));
|
|
@@ -2746,17 +2760,17 @@ var hintFor = /* @__PURE__ */ __name(({ app, configuration: configuration2 }, ar
|
|
|
2746
2760
|
const statePath = join3(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "update-check.json");
|
|
2747
2761
|
return skillHint({ app, argv, env, statePath, enabled });
|
|
2748
2762
|
}, "hintFor");
|
|
2749
|
-
var settleFailure = /* @__PURE__ */ __name(async (
|
|
2763
|
+
var settleFailure = /* @__PURE__ */ __name(async (failure2, state) => {
|
|
2750
2764
|
let timer;
|
|
2751
2765
|
let settlementFailed;
|
|
2752
2766
|
try {
|
|
2753
2767
|
const settle = (async () => {
|
|
2754
2768
|
try {
|
|
2755
|
-
await state.definition.onFailure?.(
|
|
2769
|
+
await state.definition.onFailure?.(failure2, state.program);
|
|
2756
2770
|
} catch {
|
|
2757
2771
|
settlementFailed = true;
|
|
2758
2772
|
}
|
|
2759
|
-
await keepFailure(
|
|
2773
|
+
await keepFailure(failure2, state);
|
|
2760
2774
|
})();
|
|
2761
2775
|
await Promise.race([
|
|
2762
2776
|
settle,
|
|
@@ -2772,11 +2786,11 @@ var settleFailure = /* @__PURE__ */ __name(async (failure3, state) => {
|
|
|
2772
2786
|
clearTimeout(timer);
|
|
2773
2787
|
}
|
|
2774
2788
|
}, "settleFailure");
|
|
2775
|
-
var keepFailure = /* @__PURE__ */ __name(async (
|
|
2776
|
-
if (wasSettled(
|
|
2789
|
+
var keepFailure = /* @__PURE__ */ __name(async (failure2, { definition: definition2, program, rest, argv, profile, options }) => {
|
|
2790
|
+
if (wasSettled(failure2))
|
|
2777
2791
|
return;
|
|
2778
2792
|
const env = options.env ?? process.env;
|
|
2779
|
-
const path =
|
|
2793
|
+
const path = commandPath2(program, program.args.length > 0 ? program.args : rest);
|
|
2780
2794
|
const { resolveSettings } = definition2.configuration ?? settingsFor(definition2.app);
|
|
2781
2795
|
let settings;
|
|
2782
2796
|
try {
|
|
@@ -2807,11 +2821,11 @@ var keepFailure = /* @__PURE__ */ __name(async (failure3, { definition: definiti
|
|
|
2807
2821
|
...settings ? { keepDays: settings.keepRunsForDays } : {},
|
|
2808
2822
|
...settings?.keepSuccessfulRunsForDays === void 0 ? {} : { keepSuccessDays: settings.keepSuccessfulRunsForDays }
|
|
2809
2823
|
}, async () => {
|
|
2810
|
-
throw
|
|
2824
|
+
throw failure2;
|
|
2811
2825
|
}).catch(() => {
|
|
2812
2826
|
});
|
|
2813
2827
|
}, "keepFailure");
|
|
2814
|
-
var
|
|
2828
|
+
var commandPath2 = /* @__PURE__ */ __name((program, rest) => {
|
|
2815
2829
|
const words3 = [];
|
|
2816
2830
|
let current = program;
|
|
2817
2831
|
for (const token of rest) {
|
|
@@ -2825,19 +2839,19 @@ var commandPath = /* @__PURE__ */ __name((program, rest) => {
|
|
|
2825
2839
|
}
|
|
2826
2840
|
return words3.join(" ");
|
|
2827
2841
|
}, "commandPath");
|
|
2828
|
-
var budgetSteps = /* @__PURE__ */ __name((program, path,
|
|
2842
|
+
var budgetSteps = /* @__PURE__ */ __name((program, path, failure2) => {
|
|
2829
2843
|
const command = path ? commandAt(program, path) : void 0;
|
|
2830
|
-
if (!command || !(
|
|
2844
|
+
if (!command || !(failure2 instanceof CliError) || failure2.details?.reason !== "output.too-large")
|
|
2831
2845
|
return [];
|
|
2832
|
-
const { max_bytes: maxBytes, needed_bytes: neededBytes } =
|
|
2846
|
+
const { max_bytes: maxBytes, needed_bytes: neededBytes } = failure2.details;
|
|
2833
2847
|
return typeof maxBytes === "number" && typeof neededBytes === "number" ? tooLargeSteps(command, { maxBytes, neededBytes }) : [];
|
|
2834
2848
|
}, "budgetSteps");
|
|
2835
2849
|
var failed = /* @__PURE__ */ __name(({ app }, program, rest, error, settled, debug) => {
|
|
2836
|
-
const path =
|
|
2850
|
+
const path = commandPath2(program, program.args.length > 0 ? program.args : rest);
|
|
2837
2851
|
const told = error instanceof NoProfileHere && !commandAt(program, "setup") ? error.withoutSetup(path) : error;
|
|
2838
|
-
const
|
|
2852
|
+
const failure2 = settled.settlementFailed && isCliFailure(told) ? new CliError(told.code, told.message, { ...told.details, settlement_failed: true }) : told;
|
|
2839
2853
|
const effects = judgedEffects(path ? metaOf(commandAt(program, path) ?? program).effects : void 0);
|
|
2840
|
-
const built = errorObjectOf(
|
|
2854
|
+
const built = errorObjectOf(failure2, {
|
|
2841
2855
|
...failureContext(app.errors),
|
|
2842
2856
|
targets: judgedTargets(program),
|
|
2843
2857
|
...effects ? { effects } : {}
|
|
@@ -2845,7 +2859,7 @@ var failed = /* @__PURE__ */ __name(({ app }, program, rest, error, settled, deb
|
|
|
2845
2859
|
const { next: _named, ...said } = built.error;
|
|
2846
2860
|
const steps = failureSteps(program, {
|
|
2847
2861
|
...built.error,
|
|
2848
|
-
next: [...built.error.next ?? [], ...budgetSteps(program, path,
|
|
2862
|
+
next: [...built.error.next ?? [], ...budgetSteps(program, path, failure2)]
|
|
2849
2863
|
});
|
|
2850
2864
|
const object2 = { ...built, error: { ...said, ...steps.length > 0 ? { next: steps } : {} } };
|
|
2851
2865
|
showInputFields(object2, path && commandAt(program, path) || program);
|
|
@@ -2854,7 +2868,7 @@ var failed = /* @__PURE__ */ __name(({ app }, program, rest, error, settled, deb
|
|
|
2854
2868
|
object: object2,
|
|
2855
2869
|
cli: app.command,
|
|
2856
2870
|
program,
|
|
2857
|
-
...debug ? { record: errorRecordOf(
|
|
2871
|
+
...debug ? { record: errorRecordOf(failure2, object2, { command, service: app.command, version: app.version }) } : {}
|
|
2858
2872
|
};
|
|
2859
2873
|
}, "failed");
|
|
2860
2874
|
var report = /* @__PURE__ */ __name((streams, options, { object: object2, record: record2, cli, program }) => {
|
|
@@ -3256,11 +3270,11 @@ var reasonOf = /* @__PURE__ */ __name((error) => {
|
|
|
3256
3270
|
return code;
|
|
3257
3271
|
return error instanceof Error ? error.name : "an unknown problem";
|
|
3258
3272
|
}, "reasonOf");
|
|
3259
|
-
var quietly = /* @__PURE__ */ __name(async (
|
|
3273
|
+
var quietly = /* @__PURE__ */ __name(async (write2, warn) => {
|
|
3260
3274
|
let store;
|
|
3261
3275
|
try {
|
|
3262
3276
|
store = await openStore();
|
|
3263
|
-
await
|
|
3277
|
+
await write2(store);
|
|
3264
3278
|
return true;
|
|
3265
3279
|
} catch (error) {
|
|
3266
3280
|
warn(`the local copy was not updated: ${reasonOf(error)}`);
|
|
@@ -3887,6 +3901,35 @@ var PressLog = class {
|
|
|
3887
3901
|
// node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_type_ab8c0b68b8b4768d5b87d6e249ef10da/node_modules/@wirecat/cli-core/dist/cli/command-runs.js
|
|
3888
3902
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3889
3903
|
var parses = new AsyncLocalStorage();
|
|
3904
|
+
var providerEvent = /* @__PURE__ */ __name((event) => {
|
|
3905
|
+
const parse3 = parses.getStore();
|
|
3906
|
+
if (parse3)
|
|
3907
|
+
parse3.runs.events(event);
|
|
3908
|
+
else
|
|
3909
|
+
runEvent(event);
|
|
3910
|
+
}, "providerEvent");
|
|
3911
|
+
var providerRequest = /* @__PURE__ */ __name((operation, sink = providerEvent, call = {}) => {
|
|
3912
|
+
const { bytes: sent, ...shape } = call;
|
|
3913
|
+
const wire = { operation, level: "wire", ...call.attempt === void 0 ? currentAttempt() : {}, ...shape };
|
|
3914
|
+
sink({ event: "request", ...wire, ...sent === void 0 ? {} : { bytes: sent } });
|
|
3915
|
+
const started = performance.now();
|
|
3916
|
+
return ({ status, error, errorCode, providerError, bytes, counts, ids } = {}) => {
|
|
3917
|
+
const failed2 = error !== void 0 || errorCode !== void 0;
|
|
3918
|
+
const key = providerErrorKey(providerError);
|
|
3919
|
+
sink({
|
|
3920
|
+
event: "response",
|
|
3921
|
+
...wire,
|
|
3922
|
+
...status === void 0 ? {} : { status },
|
|
3923
|
+
durationMs: Math.round(performance.now() - started),
|
|
3924
|
+
outcome: failed2 ? "error" : "ok",
|
|
3925
|
+
...failed2 ? { errorCode: errorCode ?? (isCliError(error) ? error.code : "provider_error") } : {},
|
|
3926
|
+
...key ? { providerError: key } : {},
|
|
3927
|
+
...bytes === void 0 ? {} : { bytes },
|
|
3928
|
+
...counts ? { counts } : {},
|
|
3929
|
+
...ids ? { ids } : {}
|
|
3930
|
+
});
|
|
3931
|
+
};
|
|
3932
|
+
}, "providerRequest");
|
|
3890
3933
|
|
|
3891
3934
|
// node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_type_ab8c0b68b8b4768d5b87d6e249ef10da/node_modules/@wirecat/cli-core/dist/cli/discovery-descriptions.js
|
|
3892
3935
|
var DISCOVERY_DESCRIPTIONS = Object.freeze({
|
|
@@ -4426,15 +4469,15 @@ var repairCommand = /* @__PURE__ */ __name((app, config2) => profileFree(grantsA
|
|
|
4426
4469
|
const context = baseContext(this, (flags, options) => config2.resolveSettings(flags, { ...options, readOnly: true, needsProfile: false, withIssues: true }));
|
|
4427
4470
|
const { settings, renderer, env } = context;
|
|
4428
4471
|
const file = settings.configPath;
|
|
4429
|
-
const
|
|
4472
|
+
const answer3 = /* @__PURE__ */ __name((fields) => renderAnswer(this, context, itemOf({ file, found: existsSync7(file), dry_run: dryRun2, changes: [], backup: null, ...fields })), "answer");
|
|
4430
4473
|
if (!existsSync7(file)) {
|
|
4431
|
-
|
|
4474
|
+
answer3({ repaired: false, reason: "no settings file" });
|
|
4432
4475
|
return;
|
|
4433
4476
|
}
|
|
4434
4477
|
const bytes = readFileSync6(file);
|
|
4435
4478
|
const result = repairConfigText(bytes.toString("utf8"));
|
|
4436
4479
|
if (result.state === "valid") {
|
|
4437
|
-
|
|
4480
|
+
answer3({ repaired: false, reason: "nothing to repair" });
|
|
4438
4481
|
return;
|
|
4439
4482
|
}
|
|
4440
4483
|
if (result.state === "refused")
|
|
@@ -4448,7 +4491,7 @@ var repairCommand = /* @__PURE__ */ __name((app, config2) => profileFree(grantsA
|
|
|
4448
4491
|
writeSecurely(backup, bytes, statSync3(file).mode & 511);
|
|
4449
4492
|
writeSecurely(file, result.text, 384);
|
|
4450
4493
|
}
|
|
4451
|
-
|
|
4494
|
+
answer3({ repaired: !dryRun2, changes: result.fixes, backup });
|
|
4452
4495
|
for (const one of result.fixes)
|
|
4453
4496
|
renderer.note(`line ${one.line}: ${dryRun2 ? "would fix" : "fixed"} ${REPAIR_WORDS[one.kind]}`);
|
|
4454
4497
|
if (backup)
|
|
@@ -4606,7 +4649,7 @@ var maskedRun = /* @__PURE__ */ __name((metadata, label, program = new Command()
|
|
|
4606
4649
|
}
|
|
4607
4650
|
} : {},
|
|
4608
4651
|
...partial2 ? {
|
|
4609
|
-
partial: { ...partial2, failures: partial2.failures.map((
|
|
4652
|
+
partial: { ...partial2, failures: partial2.failures.map((failure2) => ({ ...failure2, id: label(failure2.id) })) }
|
|
4610
4653
|
} : {}
|
|
4611
4654
|
};
|
|
4612
4655
|
}, "maskedRun");
|
|
@@ -5234,7 +5277,7 @@ var serving = /* @__PURE__ */ __name((target, lock, now) => ({
|
|
|
5234
5277
|
var clientLines = /* @__PURE__ */ __name((clients) => clients.length === 0 ? ["No browser app is logged in."] : [
|
|
5235
5278
|
`Logged-in apps (names are what each app calls itself): ${clients.map((one) => `${one.claimedName === null ? "no name" : JSON.stringify(one.claimedName)} (${clock(one.lastLoginAt)}${one.lastTool && one.lastToolAt ? `; last call ${one.lastTool} at ${clock(one.lastToolAt)}, ${one.toolCallsToday} today` : ""})`).join(", ")}.`
|
|
5236
5279
|
], "clientLines");
|
|
5237
|
-
var mcpServerCommand = /* @__PURE__ */ __name(({ example, defaultPort = MCP_HTTP_DEFAULT_PORT, permission = false, profiles = false, target, answer:
|
|
5280
|
+
var mcpServerCommand = /* @__PURE__ */ __name(({ example, defaultPort = MCP_HTTP_DEFAULT_PORT, permission = false, profiles = false, target, answer: answer3, system }) => {
|
|
5238
5281
|
const command = annotate(new Command("server"), { effects: LOCAL_READ, mcp: false }).summary("run the HTTP MCP server in the background").description("start, stop and check `mcp serve --http` in the background; status shows the login code for a browser app");
|
|
5239
5282
|
const machine = /* @__PURE__ */ __name((self) => system?.(self) ?? thisMachine(), "machine");
|
|
5240
5283
|
const start = destroysNothing(annotate(command.command("start"), {
|
|
@@ -5256,7 +5299,7 @@ var mcpServerCommand = /* @__PURE__ */ __name(({ example, defaultPort = MCP_HTTP
|
|
|
5256
5299
|
const lockFile = httpLockFile(one.tokenFile);
|
|
5257
5300
|
const before = readHttpLock(lockFile);
|
|
5258
5301
|
if (before && alive(before.pid)) {
|
|
5259
|
-
|
|
5302
|
+
answer3(this, { ...named(one), started: false, running: true, ...serving(one, before, Date.now()) }, [
|
|
5260
5303
|
`Already serving ${shown(one)} over HTTP since ${clock(before.startedAt)} (PID ${before.pid}, port ${before.port}).`
|
|
5261
5304
|
]);
|
|
5262
5305
|
return;
|
|
@@ -5283,7 +5326,7 @@ var mcpServerCommand = /* @__PURE__ */ __name(({ example, defaultPort = MCP_HTTP
|
|
|
5283
5326
|
const now = readHttpLock(lockFile);
|
|
5284
5327
|
if (now?.pid === pid && now.listeningAt) {
|
|
5285
5328
|
const code = liveCode(now, Date.now());
|
|
5286
|
-
|
|
5329
|
+
answer3(this, { ...named(one), started: true, running: true, ...serving(one, now, Date.now()), log }, [
|
|
5287
5330
|
`Started: serving ${shown(one)} over HTTP (PID ${pid}) on 127.0.0.1:${now.port}.`,
|
|
5288
5331
|
`Browser apps connect to ${connectorUrl(now)}`,
|
|
5289
5332
|
...code ? [`Login code for a new browser app: ${code.code} (until ${clock(code.expires_at)}).`] : []
|
|
@@ -5303,7 +5346,7 @@ ${last}` : ""}`, { retryable: false });
|
|
|
5303
5346
|
const one = target(this);
|
|
5304
5347
|
const lock = readHttpLock(httpLockFile(one.tokenFile));
|
|
5305
5348
|
if (!lock || !alive(lock.pid)) {
|
|
5306
|
-
|
|
5349
|
+
answer3(this, { ...named(one), stopped: false }, [
|
|
5307
5350
|
`Nothing to stop: ${shown(one)} is not serving MCP over HTTP.`
|
|
5308
5351
|
]);
|
|
5309
5352
|
return;
|
|
@@ -5317,7 +5360,7 @@ ${last}` : ""}`, { retryable: false });
|
|
|
5317
5360
|
await sys.pause();
|
|
5318
5361
|
if (alive(lock.pid))
|
|
5319
5362
|
throw new CliError("timeout", `mcp serve --http (PID ${lock.pid}) has not stopped yet`);
|
|
5320
|
-
|
|
5363
|
+
answer3(this, { ...named(one), stopped: true, pid: lock.pid }, [
|
|
5321
5364
|
`Stopped serving ${shown(one)} over HTTP (PID ${lock.pid}).`
|
|
5322
5365
|
]);
|
|
5323
5366
|
});
|
|
@@ -5332,7 +5375,7 @@ ${last}` : ""}`, { retryable: false });
|
|
|
5332
5375
|
const running = lock !== void 0 && alive(lock.pid);
|
|
5333
5376
|
const clients = signedInClients(one.tokenFile, now);
|
|
5334
5377
|
const live = running ? serving(one, lock, now) : void 0;
|
|
5335
|
-
|
|
5378
|
+
answer3(this, {
|
|
5336
5379
|
...named(one),
|
|
5337
5380
|
running,
|
|
5338
5381
|
...live ?? {},
|
|
@@ -5416,11 +5459,11 @@ var messengerHost = /* @__PURE__ */ __name((messenger) => ({
|
|
|
5416
5459
|
context: /* @__PURE__ */ __name((self, options) => messengerContext(self, messenger, options), "context"),
|
|
5417
5460
|
permissionExample: "messages.send=deny",
|
|
5418
5461
|
serveStdio: /* @__PURE__ */ __name(async (self, context) => {
|
|
5419
|
-
const { serveOverStdio } = await import("./server-
|
|
5462
|
+
const { serveOverStdio } = await import("./server-G4GCDMYI.js");
|
|
5420
5463
|
await serveOverStdio(self, context, messenger, {});
|
|
5421
5464
|
}, "serveStdio"),
|
|
5422
5465
|
serveHttp: /* @__PURE__ */ __name(async (self, context, http) => {
|
|
5423
|
-
const { serveOverHttpUntilStopped } = await import("./server-
|
|
5466
|
+
const { serveOverHttpUntilStopped } = await import("./server-G4GCDMYI.js");
|
|
5424
5467
|
await serveOverHttpUntilStopped(self, context, messenger, {}, http);
|
|
5425
5468
|
}, "serveHttp"),
|
|
5426
5469
|
instructions: /* @__PURE__ */ __name(async (profiles) => {
|
|
@@ -5480,7 +5523,7 @@ var mcpGroup = /* @__PURE__ */ __name((host) => {
|
|
|
5480
5523
|
}).summary("forget every login given to a browser app").description("forget every login `mcp serve --http` gave a browser app, of this profile or of the server `--profiles` names; each app must log in again")).action(async function() {
|
|
5481
5524
|
const context = host.context(this, { needsProfile: false });
|
|
5482
5525
|
const served = servedProfiles(this, host, context, this.opts().profiles, "mcp revoke", "whose browser logins to forget");
|
|
5483
|
-
const { revokeAll } = await import("./oauth-
|
|
5526
|
+
const { revokeAll } = await import("./oauth-7FVF7HQQ.js");
|
|
5484
5527
|
revokeAll(httpTokenFile(app, "set" in served ? served.set.key : served.profile, context.env));
|
|
5485
5528
|
renderAnswer(this, context, itemOf("set" in served ? { revoked: true, profile: null, profiles: served.set.option } : { revoked: true, profile: served.profile }));
|
|
5486
5529
|
}));
|
|
@@ -5650,8 +5693,8 @@ var serveProfiles = /* @__PURE__ */ __name(async (self, context, host, flags, se
|
|
|
5650
5693
|
reaches: `the browser apps reach ${app.command}`,
|
|
5651
5694
|
path: true
|
|
5652
5695
|
});
|
|
5653
|
-
const { serveAllProfilesOverHttp } = await import("./all-profiles-
|
|
5654
|
-
const { mcpHttpMarker: mcpHttpMarker2 } = await import("./state-
|
|
5696
|
+
const { serveAllProfilesOverHttp } = await import("./all-profiles-FS7AEOE7.js");
|
|
5697
|
+
const { mcpHttpMarker: mcpHttpMarker2 } = await import("./state-QCQALQBJ.js");
|
|
5655
5698
|
const port = portOf(flags.port, DEFAULT_PORT);
|
|
5656
5699
|
const listening = await serveAllProfilesOverHttp(options, {
|
|
5657
5700
|
publicUrl,
|
|
@@ -5674,7 +5717,7 @@ var serveProfiles = /* @__PURE__ */ __name(async (self, context, host, flags, se
|
|
|
5674
5717
|
await listening.close();
|
|
5675
5718
|
return;
|
|
5676
5719
|
}
|
|
5677
|
-
const { serveAllProfilesOverStdio } = await import("./all-profiles-
|
|
5720
|
+
const { serveAllProfilesOverStdio } = await import("./all-profiles-FS7AEOE7.js");
|
|
5678
5721
|
context.renderer.note(`serving ${profileSetLabel(set)} over MCP on stdin and stdout`);
|
|
5679
5722
|
const { stdin, stdout, signal } = environmentOf(self);
|
|
5680
5723
|
await serveAllProfilesOverStdio(options, {
|
|
@@ -5817,7 +5860,7 @@ var searchRuns = /* @__PURE__ */ __name((dir, { query = "", terms = [], status,
|
|
|
5817
5860
|
for (const run3 of listRuns(dir, from === void 0 ? {} : { since: from })) {
|
|
5818
5861
|
if (profile !== void 0 && run3.profile !== profile || status !== void 0 && run3.status !== status || from !== void 0 && Date.parse(run3.startedAt) < from || window2.until !== void 0 && Date.parse(run3.startedAt) > window2.until)
|
|
5819
5862
|
continue;
|
|
5820
|
-
const metadataMatch = (!errorCode || run3.errorCode === errorCode || run3.partial?.failures.some((
|
|
5863
|
+
const metadataMatch = (!errorCode || run3.errorCode === errorCode || run3.partial?.failures.some((failure2) => failure2.errorCode === errorCode)) && !operation && needles.every((needle) => JSON.stringify(run3).toLowerCase().includes(needle));
|
|
5821
5864
|
const ruledOut = !metadataMatch && needles.length === 0 && (operation !== void 0 && run3.operations !== void 0 && !run3.operations.includes(operation) || errorCode !== void 0 && run3.codes !== void 0 && !run3.codes.includes(errorCode));
|
|
5822
5865
|
if (ruledOut)
|
|
5823
5866
|
continue;
|
|
@@ -6010,10 +6053,10 @@ You are the configured analysis provider. Do not execute CLI commands or ask for
|
|
|
6010
6053
|
`, "analysisPrompt");
|
|
6011
6054
|
var analysisAnswer = /* @__PURE__ */ __name((text2, model2) => {
|
|
6012
6055
|
try {
|
|
6013
|
-
const
|
|
6014
|
-
if (!
|
|
6056
|
+
const answer3 = JSON.parse(text2);
|
|
6057
|
+
if (!answer3 || answer3.model !== model2 || answer3.skill !== "1" || !Array.isArray(answer3.answers) || !answer3.answers.length || answer3.answers.some((item) => !item || typeof item.message !== "string" || !(item.parent === null || typeof item.parent === "string") || typeof item.confidence !== "number" || !Number.isFinite(item.confidence) || item.confidence < 0 || item.confidence > 1))
|
|
6015
6058
|
throw new Error("invalid");
|
|
6016
|
-
return
|
|
6059
|
+
return answer3;
|
|
6017
6060
|
} catch {
|
|
6018
6061
|
throw new CliError("invalid_response", "analysis returned invalid linking JSON; this batch was not stored");
|
|
6019
6062
|
}
|
|
@@ -6045,10 +6088,10 @@ var runAnalysis = /* @__PURE__ */ __name(async (conversations, chat2, request, {
|
|
|
6045
6088
|
if (!Number.isInteger(response.tokens) || response.tokens < 1 || response.tokens > inputBound + outputBound)
|
|
6046
6089
|
throw new CliError("invalid_response", "analysis token usage exceeded the reserved budget; this batch was not stored");
|
|
6047
6090
|
tokens += response.tokens;
|
|
6048
|
-
const
|
|
6091
|
+
const answer3 = analysisAnswer(response.text, model2);
|
|
6049
6092
|
let saved;
|
|
6050
6093
|
try {
|
|
6051
|
-
saved = await conversations.addAnswers(batch.batch,
|
|
6094
|
+
saved = await conversations.addAnswers(batch.batch, answer3);
|
|
6052
6095
|
} catch {
|
|
6053
6096
|
throw new CliError("invalid_response", "analysis named invalid batch messages or parents; this batch was not stored");
|
|
6054
6097
|
}
|
|
@@ -6285,10 +6328,10 @@ var conversationBuildCommand = /* @__PURE__ */ __name((messenger) => boundOption
|
|
|
6285
6328
|
if (status.messages && !await consents.has(status.chat, identity)) {
|
|
6286
6329
|
const what = `${status.messages} messages, ${status.characters} characters (about ${status.tokensEstimate} message tokens, plus prompt and batch context), go to ${target.model} at ${target.baseUrl}; this run reserves at most ${maxTokens} input/output tokens. Consent is remembered for this chat and provider until revoked`;
|
|
6287
6330
|
if (!options.yes) {
|
|
6288
|
-
const
|
|
6289
|
-
if (
|
|
6331
|
+
const answer3 = await answerOf(this, `${what}. Allow analysis? [y/N] `);
|
|
6332
|
+
if (answer3 === null)
|
|
6290
6333
|
throw new CliError("confirmation_required", `${what} \u2014 add --yes`);
|
|
6291
|
-
if (!/^y(es)?$/i.test(
|
|
6334
|
+
if (!/^y(es)?$/i.test(answer3.trim()))
|
|
6292
6335
|
throw new CliError("cancelled", "cancelled \u2014 nothing was sent");
|
|
6293
6336
|
}
|
|
6294
6337
|
await consents.remember(status.chat, identity);
|
|
@@ -6442,8 +6485,8 @@ ${batch.messages.map((one) => `${one.answer ? "?" : " "} ${one.id} ${one.at.sli
|
|
|
6442
6485
|
const { batch } = this.opts();
|
|
6443
6486
|
const context = messengerContext(this, messenger);
|
|
6444
6487
|
refuseLocalWrite(context, messenger.app.command, LINKS_KEY);
|
|
6445
|
-
const
|
|
6446
|
-
const stored2 = await context.withServices((services) => services.conversations.addAnswers(batch,
|
|
6488
|
+
const answer3 = answerOf2(await readAll(context.stdin));
|
|
6489
|
+
const stored2 = await context.withServices((services) => services.conversations.addAnswers(batch, answer3));
|
|
6447
6490
|
renderAnswer(this, context, itemOf(stored2, { next: [nextStep("conversations.build", { args: { chat: stored2.chat } })] }), () => `${stored2.stored} answers stored
|
|
6448
6491
|
`);
|
|
6449
6492
|
});
|
|
@@ -6605,10 +6648,10 @@ var consent = /* @__PURE__ */ __name(async (command, status, baseUrl, { yes: yes
|
|
|
6605
6648
|
const what = `${status.left} chunks of chat ${status.chat}, up to ${status.tokensAtMost} tokens${price}, go to ${status.model} (${new URL(baseUrl).host})`;
|
|
6606
6649
|
if (yes2)
|
|
6607
6650
|
return;
|
|
6608
|
-
const
|
|
6609
|
-
if (
|
|
6651
|
+
const answer3 = await answerOf(command, `${what}. Send them? [y/N] `);
|
|
6652
|
+
if (answer3 === null)
|
|
6610
6653
|
throw new CliError("confirmation_required", `${what} \u2014 add --yes to send them`);
|
|
6611
|
-
if (!/^y(es)?$/i.test(
|
|
6654
|
+
if (!/^y(es)?$/i.test(answer3.trim()))
|
|
6612
6655
|
throw new CliError("cancelled", "cancelled \u2014 nothing was sent");
|
|
6613
6656
|
}, "consent");
|
|
6614
6657
|
var LINKS_KEY = "conversations.links";
|
|
@@ -6622,11 +6665,11 @@ var answerOf2 = /* @__PURE__ */ __name((text2) => {
|
|
|
6622
6665
|
} catch {
|
|
6623
6666
|
throw new CliError("validation_error", "the answer on stdin is not JSON \u2014 see `conversations links add --help`");
|
|
6624
6667
|
}
|
|
6625
|
-
const
|
|
6626
|
-
if (!
|
|
6668
|
+
const answer3 = parsed;
|
|
6669
|
+
if (!answer3 || typeof answer3 !== "object" || !Array.isArray(answer3.answers)) {
|
|
6627
6670
|
throw new CliError("validation_error", 'the answer needs "answers": a list of { "message", "parent", "confidence" }');
|
|
6628
6671
|
}
|
|
6629
|
-
return
|
|
6672
|
+
return answer3;
|
|
6630
6673
|
}, "answerOf");
|
|
6631
6674
|
var linksCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("links"), {
|
|
6632
6675
|
output: { entity: "message_links" },
|
|
@@ -7411,7 +7454,7 @@ var handlers = /* @__PURE__ */ __name((reader, meta) => {
|
|
|
7411
7454
|
if (index.remaining > 0)
|
|
7412
7455
|
found.coverage = { ...found.coverage, indexing: "pending" };
|
|
7413
7456
|
const complete = found.coverage.indexing === "ready";
|
|
7414
|
-
const
|
|
7457
|
+
const answer3 = {
|
|
7415
7458
|
...meetingHitsList(found, request.limit ?? 100, "search meetings", meetingSearchArguments(query, flags)),
|
|
7416
7459
|
meta: {
|
|
7417
7460
|
...meta(),
|
|
@@ -7420,7 +7463,7 @@ var handlers = /* @__PURE__ */ __name((reader, meta) => {
|
|
|
7420
7463
|
...!complete ? { issues: [{ code: "invalid_response", source: "meeting-index" }] } : {}
|
|
7421
7464
|
}
|
|
7422
7465
|
};
|
|
7423
|
-
return { answer:
|
|
7466
|
+
return { answer: answer3, complete };
|
|
7424
7467
|
}, "run")
|
|
7425
7468
|
};
|
|
7426
7469
|
}
|
|
@@ -9006,11 +9049,11 @@ var runCapOf = /* @__PURE__ */ __name((argv) => {
|
|
|
9006
9049
|
const cap = at2 < 0 ? Number.NaN : Number(argv[at2 + 1]);
|
|
9007
9050
|
return Number.isFinite(cap) ? cap : null;
|
|
9008
9051
|
}, "runCapOf");
|
|
9009
|
-
var scheduleCommandFor = /* @__PURE__ */ __name(({ app, context:
|
|
9052
|
+
var scheduleCommandFor = /* @__PURE__ */ __name(({ app, context: contextOf2, newMail, limits: configured, agentRuns = [] }) => {
|
|
9010
9053
|
const agentClis = [app, ...agentRuns];
|
|
9011
9054
|
const command = new Command("schedule").description(`run a ${app.command} command or an agent later or on a timer (systemd, launchd, Task Scheduler); an agent cannot send`);
|
|
9012
9055
|
const prepare = /* @__PURE__ */ __name((self, resolving = {}) => {
|
|
9013
|
-
const context =
|
|
9056
|
+
const context = contextOf2(self, resolving);
|
|
9014
9057
|
const system = environmentOf(self).system ?? thisMachine();
|
|
9015
9058
|
const state = resolvePaths({ appName: app.appName, prefix: app.envPrefix, env: context.env }).state;
|
|
9016
9059
|
const say = /* @__PURE__ */ __name((value2, lines2) => renderAnswer(self, context, itemOf(value2), () => lines2.join("\n")), "say");
|
|
@@ -9189,12 +9232,12 @@ var scheduleCommandFor = /* @__PURE__ */ __name(({ app, context: contextOf, newM
|
|
|
9189
9232
|
maxCostPerDayUsd: limitsOf(this, schedule).maxCostPerDay
|
|
9190
9233
|
} : {}
|
|
9191
9234
|
}));
|
|
9192
|
-
const
|
|
9235
|
+
const answer3 = listOf("schedule list", {
|
|
9193
9236
|
items: rows2.map((row2) => snakeKeys(row2)),
|
|
9194
9237
|
limit: Math.max(1, rows2.length),
|
|
9195
9238
|
has_more: false
|
|
9196
9239
|
});
|
|
9197
|
-
renderAnswer(this, context,
|
|
9240
|
+
renderAnswer(this, context, answer3, () => {
|
|
9198
9241
|
if (rows2.length === 0) {
|
|
9199
9242
|
context.renderer.note(`no schedules \u2014 \`${lineOf(this, "schedule command|agent")}\` adds one`);
|
|
9200
9243
|
return "";
|
|
@@ -9277,12 +9320,12 @@ var appMcpCommand = /* @__PURE__ */ __name((app, configuration2, options) => {
|
|
|
9277
9320
|
permissionExample: options.permissionExample,
|
|
9278
9321
|
serveStdio: /* @__PURE__ */ __name(async (self, context) => {
|
|
9279
9322
|
checked2(self, context);
|
|
9280
|
-
const { serveAppOverStdio } = await import("./app-server-
|
|
9323
|
+
const { serveAppOverStdio } = await import("./app-server-WGTKZQKJ.js");
|
|
9281
9324
|
await serveAppOverStdio(self, context, server());
|
|
9282
9325
|
}, "serveStdio"),
|
|
9283
9326
|
serveHttp: /* @__PURE__ */ __name(async (self, context, http) => {
|
|
9284
9327
|
checked2(self, context);
|
|
9285
|
-
const { serveAppOverHttp } = await import("./app-server-
|
|
9328
|
+
const { serveAppOverHttp } = await import("./app-server-WGTKZQKJ.js");
|
|
9286
9329
|
await serveAppOverHttp(self, context, server(), http);
|
|
9287
9330
|
}, "serveHttp"),
|
|
9288
9331
|
instructions: /* @__PURE__ */ __name(async (profiles) => {
|
|
@@ -9600,15 +9643,15 @@ var requestsCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
9600
9643
|
[true, "let them in; the group sees them join"],
|
|
9601
9644
|
[false, "turn the request away"]
|
|
9602
9645
|
]) {
|
|
9603
|
-
const
|
|
9646
|
+
const answer3 = annotate(new Command(accept ? "confirm" : "reject"), {
|
|
9604
9647
|
output: { entity: "chat_request_change" },
|
|
9605
9648
|
effects: REMOTE_WRITE
|
|
9606
9649
|
}).description(help).argument("<chat>", messenger.chatArgument).argument(everyone ? "[person]" : "<person>", "who asked: an id from `chats requests list`");
|
|
9607
9650
|
if (everyone)
|
|
9608
|
-
|
|
9651
|
+
answer3.option("--all", "every pending request, counted against the hourly limit first");
|
|
9609
9652
|
if (byLink)
|
|
9610
|
-
|
|
9611
|
-
requests.addCommand(
|
|
9653
|
+
answer3.option("--link <link>", "with --all: only the requests made by this invite link");
|
|
9654
|
+
requests.addCommand(answer3.action(async function(chat2, person) {
|
|
9612
9655
|
const context = messengerContext(this, messenger);
|
|
9613
9656
|
const { all, link } = this.opts();
|
|
9614
9657
|
if (person === void 0 === (all !== true))
|
|
@@ -9862,7 +9905,7 @@ var botMcpCommand = /* @__PURE__ */ __name((bot) => {
|
|
|
9862
9905
|
const mcp = bot.mcp;
|
|
9863
9906
|
if (!mcp)
|
|
9864
9907
|
throw new Error("bot mcp is mounted only with BotMessenger.mcp");
|
|
9865
|
-
const [{ serveBotOverStdio }, run3] = await Promise.all([import("./server-
|
|
9908
|
+
const [{ serveBotOverStdio }, run3] = await Promise.all([import("./server-P4XUYY5A.js"), mcp.program()]);
|
|
9866
9909
|
await serveBotOverStdio({
|
|
9867
9910
|
bot,
|
|
9868
9911
|
program: { run: run3, commands: describeProgram(rootOf2(this)) },
|
|
@@ -10085,7 +10128,7 @@ var moderatorOf = /* @__PURE__ */ __name((context, bot, adapter, botId, ban) =>
|
|
|
10085
10128
|
}, () => remove(chatId, personId, { block: ban }));
|
|
10086
10129
|
}, "removePerson")
|
|
10087
10130
|
}), "moderatorOf");
|
|
10088
|
-
var yes = /* @__PURE__ */ __name((
|
|
10131
|
+
var yes = /* @__PURE__ */ __name((answer3) => /^\s*y(es)?\s*$/i.test(answer3), "yes");
|
|
10089
10132
|
var botModerateCommand = /* @__PURE__ */ __name((bot) => annotate(new Command("moderate"), {
|
|
10090
10133
|
effects: REMOTE_WRITE,
|
|
10091
10134
|
examples: botExamples(bot, "chats moderate Team --dry-run")
|
|
@@ -10117,8 +10160,8 @@ var botModerateCommand = /* @__PURE__ */ __name((bot) => annotate(new Command("m
|
|
|
10117
10160
|
allowDangerous: options.allowDangerous === true,
|
|
10118
10161
|
maxActions,
|
|
10119
10162
|
confirm: /* @__PURE__ */ __name(async (finding) => {
|
|
10120
|
-
const
|
|
10121
|
-
return
|
|
10163
|
+
const answer3 = await ask(`${describe(finding)}? [y/N] `);
|
|
10164
|
+
return answer3 === null ? void 0 : yes(answer3);
|
|
10122
10165
|
}, "confirm")
|
|
10123
10166
|
});
|
|
10124
10167
|
if (context.format === "pretty")
|
|
@@ -10202,8 +10245,8 @@ var cardOf = /* @__PURE__ */ __name(async (store, context, bot, who3, across, li
|
|
|
10202
10245
|
const [person] = await resolve6(store, bot, [who3], people2);
|
|
10203
10246
|
const rows2 = (await store.messages.find({ ...filter, senders: [person.id], perChat: true, limit: 1 })).items;
|
|
10204
10247
|
const latest = rows2.filter((hit, index) => rows2.findIndex((other) => other.chatId === hit.chatId) === index);
|
|
10205
|
-
const
|
|
10206
|
-
const dialogs = latest.filter((hit) =>
|
|
10248
|
+
const kindOf2 = bot.chatKindOf ?? kindByNumber;
|
|
10249
|
+
const dialogs = latest.filter((hit) => kindOf2(hit) === "dialog");
|
|
10207
10250
|
const pages = await Promise.all(dialogs.map(async (hit) => {
|
|
10208
10251
|
const { account } = parseLocator(hit.locator);
|
|
10209
10252
|
const page = await store.messages.messages({ provider: bot.provider, account }, hit.chatId, { limit });
|
|
@@ -10218,7 +10261,7 @@ var cardOf = /* @__PURE__ */ __name(async (store, context, bot, who3, across, li
|
|
|
10218
10261
|
chats: latest.map((hit) => ({
|
|
10219
10262
|
id: hit.chatId,
|
|
10220
10263
|
title: hit.chatTitle,
|
|
10221
|
-
kind:
|
|
10264
|
+
kind: kindOf2(hit),
|
|
10222
10265
|
lastMessageAt: hit.timestamp
|
|
10223
10266
|
})),
|
|
10224
10267
|
messages: messages.slice(-limit)
|
|
@@ -10362,7 +10405,7 @@ var typesOf = /* @__PURE__ */ __name((typed2) => {
|
|
|
10362
10405
|
const types = typed2?.split(",").map((one) => one.trim()).filter(Boolean);
|
|
10363
10406
|
return types && types.length > 0 ? types : void 0;
|
|
10364
10407
|
}, "typesOf");
|
|
10365
|
-
var botWrite = /* @__PURE__ */ __name((context, key,
|
|
10408
|
+
var botWrite = /* @__PURE__ */ __name((context, key, write2) => guardedWrite(context.guard(), { operationId: newOperationId(), chatId: null, kind: "account", key }, write2), "botWrite");
|
|
10366
10409
|
var botMenuCommand = /* @__PURE__ */ __name((bot) => {
|
|
10367
10410
|
const command = new Command("commands").description("the bot's command menu \u2014 what people see after /");
|
|
10368
10411
|
withQuery(annotate(command.command("list"), { effects: REMOTE_READ, examples: botExamples(bot, "commands list") }), BOT_MENU_QUERY).description("the commands in the menu now").action(async function(words3) {
|
|
@@ -10409,7 +10452,7 @@ var botCallbacksCommand = /* @__PURE__ */ __name((bot) => new Command("callbacks
|
|
|
10409
10452
|
const press = text2 === void 0 ? void 0 : new PressLog(botFiles(bot.app, context.profile, context.env).presses).find(callbackId);
|
|
10410
10453
|
await context.run(async (events) => {
|
|
10411
10454
|
const adapter = await context.authenticated({ events });
|
|
10412
|
-
const
|
|
10455
|
+
const answer3 = botCan(adapter, "answer", bot, "answer a button");
|
|
10413
10456
|
const operationId = newOperationId();
|
|
10414
10457
|
await guardedWrite(context.guard(), {
|
|
10415
10458
|
operationId,
|
|
@@ -10417,7 +10460,7 @@ var botCallbacksCommand = /* @__PURE__ */ __name((bot) => new Command("callbacks
|
|
|
10417
10460
|
kind: "message",
|
|
10418
10461
|
key: "bot.callbacks.answer",
|
|
10419
10462
|
...text2 === void 0 ? {} : { length: text2.length }
|
|
10420
|
-
}, () =>
|
|
10463
|
+
}, () => answer3(callbackId, {
|
|
10421
10464
|
...text2 === void 0 ? {} : { text: text2 },
|
|
10422
10465
|
...notification === void 0 ? {} : { notification },
|
|
10423
10466
|
...press ? { press } : {}
|
|
@@ -10963,9 +11006,9 @@ var chatsCommand = /* @__PURE__ */ __name((bot) => {
|
|
|
10963
11006
|
const ref = context.chatRef(chat2);
|
|
10964
11007
|
await context.run(async (events) => {
|
|
10965
11008
|
const adapter = await context.authenticated({ events });
|
|
10966
|
-
const
|
|
11009
|
+
const act2 = botCan(adapter, "action", bot, "show an action");
|
|
10967
11010
|
const operationId = newOperationId();
|
|
10968
|
-
await guardedWrite(context.guard(), { operationId, chatId: ref, kind: "chat", key: "bot.chats.action" }, () =>
|
|
11011
|
+
await guardedWrite(context.guard(), { operationId, chatId: ref, kind: "chat", key: "bot.chats.action" }, () => act2(ref, action));
|
|
10969
11012
|
renderAnswer(this, context, itemOf({ operation_id: operationId, chat_id: ref, action }));
|
|
10970
11013
|
});
|
|
10971
11014
|
});
|
|
@@ -11592,11 +11635,11 @@ var syncCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
11592
11635
|
throw new CliError("validation_error", "--dry-run prices a full fetch; --since-time and --last do not narrow it");
|
|
11593
11636
|
}
|
|
11594
11637
|
const named2 = chat2;
|
|
11595
|
-
const
|
|
11596
|
-
renderAnswer(this, context, itemOf(snakeKeys(
|
|
11597
|
-
if (
|
|
11638
|
+
const answer3 = await context.withServices((services) => services.archive.estimate(named2, { limit, pageSize, pauseMs }));
|
|
11639
|
+
renderAnswer(this, context, itemOf(snakeKeys(answer3)));
|
|
11640
|
+
if (answer3.missing === null) {
|
|
11598
11641
|
context.renderer.note(`nothing held of this chat to measure by \u2014 \`${lineOf(this, `messages sync ${chat2} --limit ${pageSize}`)}\` gives the estimate something to go on`);
|
|
11599
|
-
} else if (
|
|
11642
|
+
} else if (answer3.missing > 0)
|
|
11600
11643
|
context.renderer.note("an estimate: provider waits (FloodWait) come on top");
|
|
11601
11644
|
return;
|
|
11602
11645
|
}
|
|
@@ -12948,10 +12991,10 @@ var moderateCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command
|
|
|
12948
12991
|
allowDangerous: options.allowDangerous === true,
|
|
12949
12992
|
maxActions,
|
|
12950
12993
|
confirm: /* @__PURE__ */ __name(async (finding) => {
|
|
12951
|
-
const
|
|
12952
|
-
if (
|
|
12994
|
+
const answer3 = await answerOf(this, `${describe(finding)}? [y/N] `);
|
|
12995
|
+
if (answer3 === null)
|
|
12953
12996
|
return void 0;
|
|
12954
|
-
return /^\s*y(es)?\s*$/i.test(
|
|
12997
|
+
return /^\s*y(es)?\s*$/i.test(answer3);
|
|
12955
12998
|
}, "confirm")
|
|
12956
12999
|
}));
|
|
12957
13000
|
renderAnswer(this, context, itemOf(snakeKeys({ chatId, rows: rows2 }), { meta: window2.meta }), () => rows2.map((row2) => [row2.kind, row2.personName ?? row2.personId, row2.rule, row2.action, row2.outcome, row2.reason ?? ""].join(" ").trimEnd()).map((line7) => `${line7}
|
|
@@ -14552,8 +14595,8 @@ var CONTACTS_QUERY = {
|
|
|
14552
14595
|
validate: { notes: notesText }
|
|
14553
14596
|
})
|
|
14554
14597
|
};
|
|
14555
|
-
var notesAllowed = /* @__PURE__ */ __name((
|
|
14556
|
-
if (notes2 && levelFor(
|
|
14598
|
+
var notesAllowed = /* @__PURE__ */ __name((permissions2, notes2) => {
|
|
14599
|
+
if (notes2 && levelFor(permissions2, "contacts.notes.list").level === "deny")
|
|
14557
14600
|
throw new CliError("permission_error", "profile denies contacts.notes.list");
|
|
14558
14601
|
}, "notesAllowed");
|
|
14559
14602
|
var VOTERS_QUERY = {
|
|
@@ -14784,14 +14827,14 @@ var contactsCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
14784
14827
|
const checked2 = await context.withServices((services) => services.botcheck.person(person, { registries: registries2, ...key ? { registry: { casKey: key } } : {} }));
|
|
14785
14828
|
for (const note2 of checked2.notes)
|
|
14786
14829
|
context.renderer.note(note2);
|
|
14787
|
-
for (const { name, answer:
|
|
14788
|
-
if (
|
|
14830
|
+
for (const { name, answer: answer4, detail } of checked2.registries) {
|
|
14831
|
+
if (answer4 === "unknown")
|
|
14789
14832
|
context.renderer.note(`${name}: not known \u2014 ${detail ?? "no answer"}`);
|
|
14790
14833
|
}
|
|
14791
14834
|
if (checked2.unknown.length > 0)
|
|
14792
14835
|
context.renderer.note(`not judged, nothing to judge by: ${checked2.unknown.join(", ")}`);
|
|
14793
|
-
const { notes: _2, ...
|
|
14794
|
-
renderAnswer(this, context, itemOf(snakeKeys(
|
|
14836
|
+
const { notes: _2, ...answer3 } = checked2;
|
|
14837
|
+
renderAnswer(this, context, itemOf(snakeKeys(answer3)));
|
|
14795
14838
|
});
|
|
14796
14839
|
annotate(contacts.command("link"), { effects: LOCAL_WRITE, output: { entity: "linked_person" } }).summary("link identities that belong to one person").description("record that two people in the store are one person \u2014 the same name is never enough").argument("<person>", "their id, @username, or part of their name").argument("<other>", "the same in another messenger of the store, as <messenger>:<person> \u2014 max:Ana; me: it is you, as zoom:<id> me").action(async function(person, other) {
|
|
14797
14840
|
const context = messengerContext(this, messenger);
|
|
@@ -15005,12 +15048,12 @@ var hearOnline = /* @__PURE__ */ __name(async (messenger, connection, chat2, mes
|
|
|
15005
15048
|
}, "hearOnline");
|
|
15006
15049
|
var hearLocally = /* @__PURE__ */ __name(async (bytes, messageId, choice) => {
|
|
15007
15050
|
const { model: model2, directory, open, ffmpeg } = choice;
|
|
15008
|
-
const { decodeAudio } = await import("./decode-
|
|
15051
|
+
const { decodeAudio } = await import("./decode-QMLOGZ6R.js");
|
|
15009
15052
|
const { samples, rate } = await decodeAudio(bytes, ffmpeg);
|
|
15010
15053
|
if (choice.with === "openai") {
|
|
15011
15054
|
if (choice.refusal)
|
|
15012
15055
|
throw choice.refusal;
|
|
15013
|
-
const { transcribeOpenAI } = await import("./openai-
|
|
15056
|
+
const { transcribeOpenAI } = await import("./openai-WAJ6WREQ.js");
|
|
15014
15057
|
const transcribeModel = choice.transcribeModel ?? OPENAI_TRANSCRIBE_MODEL;
|
|
15015
15058
|
const pieces = await transcribeOpenAI({ samples, rate }, {
|
|
15016
15059
|
apiKey: choice.apiKey ?? "",
|
|
@@ -15029,7 +15072,7 @@ var hearLocally = /* @__PURE__ */ __name(async (bytes, messageId, choice) => {
|
|
|
15029
15072
|
model: transcribeModel
|
|
15030
15073
|
};
|
|
15031
15074
|
}
|
|
15032
|
-
const { openRecognizer, toModelRate } = await import("./recognize-
|
|
15075
|
+
const { openRecognizer, toModelRate } = await import("./recognize-4KLBZDEC.js");
|
|
15033
15076
|
const recognizer = (open ?? openRecognizer)(model2, modelPath(directory, model2), vadPath(directory));
|
|
15034
15077
|
try {
|
|
15035
15078
|
return {
|
|
@@ -15117,7 +15160,7 @@ var downloadAudioModel = /* @__PURE__ */ __name(async (command, messenger, id3)
|
|
|
15117
15160
|
await install(model2, directory, { progress: /* @__PURE__ */ __name((line7) => context.renderer.note(line7), "progress") });
|
|
15118
15161
|
}
|
|
15119
15162
|
context.renderer.note(`${model2.id}: loading it once to check it works`);
|
|
15120
|
-
const { openRecognizer, SAMPLE_RATE } = await import("./recognize-
|
|
15163
|
+
const { openRecognizer, SAMPLE_RATE } = await import("./recognize-4KLBZDEC.js");
|
|
15121
15164
|
const recognizer = openRecognizer(model2, modelPath(directory, model2), vadPath(directory));
|
|
15122
15165
|
try {
|
|
15123
15166
|
recognizer.recognize(new Float32Array(SAMPLE_RATE));
|
|
@@ -15336,9 +15379,9 @@ var hearVoices = /* @__PURE__ */ __name(async (messenger, messages, kept, transc
|
|
|
15336
15379
|
}
|
|
15337
15380
|
return answers;
|
|
15338
15381
|
});
|
|
15339
|
-
for (const [voice,
|
|
15382
|
+
for (const [voice, answer3] of fetched) {
|
|
15340
15383
|
try {
|
|
15341
|
-
const heard2 =
|
|
15384
|
+
const heard2 = answer3 instanceof Uint8Array ? await hearLocally(answer3, voice.messageId, choice) : answer3;
|
|
15342
15385
|
if (heard2.pending || heard2.text.trim() === "")
|
|
15343
15386
|
continue;
|
|
15344
15387
|
transcripts.set(keyOf2(voice), heard2.text);
|
|
@@ -15591,9 +15634,9 @@ var inboxCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("i
|
|
|
15591
15634
|
});
|
|
15592
15635
|
if (inbox.partial && format === "pretty")
|
|
15593
15636
|
renderer.warn(PARTIAL_NOTE);
|
|
15594
|
-
const
|
|
15595
|
-
renderAnswer(this, context,
|
|
15596
|
-
if (
|
|
15637
|
+
const answer3 = inboxAnswer(inbox, hearing, reader, transcribe === true, meta);
|
|
15638
|
+
renderAnswer(this, context, answer3, () => {
|
|
15639
|
+
if (answer3.items.length === 0) {
|
|
15597
15640
|
renderer.note(inbox.mode === "unread" ? "nothing unread" : `nothing new since ${inbox.since}`);
|
|
15598
15641
|
return "";
|
|
15599
15642
|
}
|
|
@@ -15896,7 +15939,7 @@ var downloadChat = /* @__PURE__ */ __name(async (command, context, messenger, ch
|
|
|
15896
15939
|
stop.release();
|
|
15897
15940
|
}
|
|
15898
15941
|
}, "downloadChat");
|
|
15899
|
-
var summary2 = /* @__PURE__ */ __name(({ saved, existing, complete, batch }) => `${saved} saved${existing > 0 ? `, ${existing} already there` : ""}${complete ? " \u2014 the whole chat" : batch?.failures.every((
|
|
15942
|
+
var summary2 = /* @__PURE__ */ __name(({ saved, existing, complete, batch }) => `${saved} saved${existing > 0 ? `, ${existing} already there` : ""}${complete ? " \u2014 the whole chat" : batch?.failures.every((failure2) => failure2.stage === "extract") ? " \u2014 downloads retained; retry attachments extract for failed locators" : " \u2014 run it again to continue"}`, "summary");
|
|
15900
15943
|
var joined = /* @__PURE__ */ __name((a2, b) => {
|
|
15901
15944
|
const from = Math.min(a2.from, b.from);
|
|
15902
15945
|
const to = Math.max(a2.to, b.to);
|
|
@@ -16536,8 +16579,8 @@ var starCommands = /* @__PURE__ */ __name((messenger) => [true, false].map((star
|
|
|
16536
16579
|
examples: [`${messenger.app.command} messages ${name} <chat> <message>`]
|
|
16537
16580
|
}).description(starred ? "star a message, so it is easy to find again; only you see the star" : "take the star off a message").argument("<chat>", messenger.chatArgument).argument("<message>", "the message id").action(async function(chat2, message2) {
|
|
16538
16581
|
const context = messengerContext(this, messenger);
|
|
16539
|
-
const
|
|
16540
|
-
renderAnswer(this, context, itemOf(snakeKeys(
|
|
16582
|
+
const answer3 = await context.withServices((services) => services.messages.star({ chat: chat2, message: message2.trim(), starred }));
|
|
16583
|
+
renderAnswer(this, context, itemOf(snakeKeys(answer3)));
|
|
16541
16584
|
});
|
|
16542
16585
|
}), "starCommands");
|
|
16543
16586
|
|
|
@@ -16827,14 +16870,14 @@ var pollsCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
16827
16870
|
effects: REMOTE_READ,
|
|
16828
16871
|
examples: [`${messenger.app.command} personal polls voters "Book club" 101 answers:0 --limit 10`]
|
|
16829
16872
|
}).description(messenger.pollAnonymous === false ? "who voted for what, newest first" : "who voted for what, newest first; not in an anonymous poll").argument("<chat>", messenger.chatArgument).argument("<message>", "the id of the message that carries the poll").option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")), { output: { entity: "poll_vote" } }), VOTERS_QUERY).action(async function(chat2, message2, words3) {
|
|
16830
|
-
const
|
|
16873
|
+
const answer3 = nativeTerms(listQuery(typedQuery(words3), VOTERS_QUERY, "polls voters"), "polls voters").get("answers")?.value;
|
|
16831
16874
|
const context = messengerContext(this, messenger);
|
|
16832
16875
|
const { limit, page } = context.settings;
|
|
16833
16876
|
const found = await context.withMessenger((connection) => pollVoters(connection, {
|
|
16834
16877
|
chat: chat2,
|
|
16835
16878
|
message: message2.trim(),
|
|
16836
16879
|
limit: limit * page,
|
|
16837
|
-
...
|
|
16880
|
+
...answer3 === void 0 ? {} : { answer: answer3.trim() }
|
|
16838
16881
|
}));
|
|
16839
16882
|
renderAnswer(this, context, listOf("polls voters", {
|
|
16840
16883
|
items: found.items.slice((page - 1) * limit).map(pollVoteAnswer),
|
|
@@ -17340,11 +17383,11 @@ var addReplyEditors = /* @__PURE__ */ __name((replies, messenger) => {
|
|
|
17340
17383
|
audience.action(function() {
|
|
17341
17384
|
const context = messengerContext(this, messenger);
|
|
17342
17385
|
const { settings, renderer, env } = context;
|
|
17343
|
-
const
|
|
17386
|
+
const answer3 = editAudience(repliesPathFor(messenger.app, settings.profile, env), messenger.provider, this.opts());
|
|
17344
17387
|
const warn = renderer.warn;
|
|
17345
|
-
for (const { text: text2, warning } of audienceWarnings(
|
|
17388
|
+
for (const { text: text2, warning } of audienceWarnings(answer3))
|
|
17346
17389
|
warn(text2, warning);
|
|
17347
|
-
renderItem(this, context,
|
|
17390
|
+
renderItem(this, context, answer3);
|
|
17348
17391
|
});
|
|
17349
17392
|
replies.addCommand(audience);
|
|
17350
17393
|
}, "addReplyEditors");
|
|
@@ -17388,7 +17431,7 @@ var repliesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
17388
17431
|
renderer.note(`${found.botUnknown} sender(s) not known as bot or person; taken as people`);
|
|
17389
17432
|
}
|
|
17390
17433
|
renderer.note(`only what this machine has stored from ${found.since} to ${found.until} was read`);
|
|
17391
|
-
const
|
|
17434
|
+
const answer3 = {
|
|
17392
17435
|
since: found.since,
|
|
17393
17436
|
until: found.until,
|
|
17394
17437
|
bot_unknown: found.botUnknown,
|
|
@@ -17409,7 +17452,7 @@ var repliesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
17409
17452
|
].filter(Boolean).join(" + ")}`),
|
|
17410
17453
|
...Object.entries(skipped).sort(([, a2], [, b]) => b - a2).map(([why, count5]) => ` passed over ${count5}: ${why}`)
|
|
17411
17454
|
]);
|
|
17412
|
-
renderAnswer(this, context, itemOf(
|
|
17455
|
+
renderAnswer(this, context, itemOf(answer3, { meta: window2.meta }), () => `${lines2.join("\n")}
|
|
17413
17456
|
`);
|
|
17414
17457
|
});
|
|
17415
17458
|
const switched = /* @__PURE__ */ __name((on) => async function() {
|
|
@@ -18885,149 +18928,2052 @@ var appUpdate = /* @__PURE__ */ __name((app) => {
|
|
|
18885
18928
|
};
|
|
18886
18929
|
}, "appUpdate");
|
|
18887
18930
|
|
|
18888
|
-
// dist/
|
|
18889
|
-
|
|
18890
|
-
|
|
18931
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_type_ab8c0b68b8b4768d5b87d6e249ef10da/node_modules/@wirecat/cli-core/dist/sends/keyed-guard.js
|
|
18932
|
+
var keyedGuard = /* @__PURE__ */ __name((build, ask, levelOf, extra) => {
|
|
18933
|
+
let question;
|
|
18934
|
+
let answered = false;
|
|
18935
|
+
const guard = build(async (key, request) => {
|
|
18936
|
+
if (answered)
|
|
18937
|
+
return;
|
|
18938
|
+
await ask(question || key, request);
|
|
18939
|
+
answered = true;
|
|
18940
|
+
});
|
|
18941
|
+
const probes = /* @__PURE__ */ new WeakMap();
|
|
18942
|
+
const all = /* @__PURE__ */ __name((request) => {
|
|
18943
|
+
let found = probes.get(request);
|
|
18944
|
+
if (!found) {
|
|
18945
|
+
found = extra.map((key) => ({ chatId: null, kind: "read", key }));
|
|
18946
|
+
probes.set(request, found);
|
|
18947
|
+
}
|
|
18948
|
+
return [request, ...found];
|
|
18949
|
+
}, "all");
|
|
18950
|
+
const levelOfRequest = /* @__PURE__ */ __name(({ key }) => levelOf(key ?? ""), "levelOfRequest");
|
|
18951
|
+
const refuse = /* @__PURE__ */ __name((request) => {
|
|
18952
|
+
const refused = all(request).find((one) => ["deny", "readonly"].includes(levelOfRequest(one)));
|
|
18953
|
+
if (refused)
|
|
18954
|
+
guard.check(refused, { reserve: false });
|
|
18955
|
+
}, "refuse");
|
|
18956
|
+
return {
|
|
18957
|
+
refuse,
|
|
18958
|
+
ask: /* @__PURE__ */ __name(async (request) => {
|
|
18959
|
+
refuse(request);
|
|
18960
|
+
question = all(request).filter((one) => levelOfRequest(one) === "ask").map(({ key }) => key).join(" and ");
|
|
18961
|
+
for (const one of all(request))
|
|
18962
|
+
await guard.ask?.(one);
|
|
18963
|
+
}, "ask"),
|
|
18964
|
+
check: /* @__PURE__ */ __name((request, options) => {
|
|
18965
|
+
for (const one of all(request).slice(1))
|
|
18966
|
+
guard.check(one, { reserve: false });
|
|
18967
|
+
guard.check(request, options);
|
|
18968
|
+
}, "check"),
|
|
18969
|
+
...guard.reserve ? { reserve: guard.reserve } : {},
|
|
18970
|
+
record: /* @__PURE__ */ __name((entry) => guard.record(entry), "record")
|
|
18971
|
+
};
|
|
18972
|
+
}, "keyedGuard");
|
|
18891
18973
|
|
|
18892
18974
|
// dist/config.js
|
|
18893
|
-
var
|
|
18894
|
-
|
|
18895
|
-
|
|
18896
|
-
|
|
18897
|
-
var
|
|
18898
|
-
|
|
18899
|
-
|
|
18900
|
-
|
|
18975
|
+
var permissions = commandPermissions();
|
|
18976
|
+
var configuration = settingsFor(IDENTITY, { permissions });
|
|
18977
|
+
|
|
18978
|
+
// dist/sample/comments.js
|
|
18979
|
+
var wireComment = object({
|
|
18980
|
+
id: string(),
|
|
18981
|
+
body: string(),
|
|
18982
|
+
authorName: string(),
|
|
18983
|
+
createdAt: string()
|
|
18984
|
+
});
|
|
18985
|
+
var wirePage = object({ comments: array(wireComment), hasMore: boolean() });
|
|
18986
|
+
var wireUser = object({ id: string(), name: string() });
|
|
18987
|
+
var commentSchema = strictObject({
|
|
18988
|
+
id: string(),
|
|
18989
|
+
text: string(),
|
|
18990
|
+
author: string(),
|
|
18991
|
+
created_at: string()
|
|
18992
|
+
});
|
|
18993
|
+
var commentOf = /* @__PURE__ */ __name((wire) => ({
|
|
18994
|
+
id: wire.id,
|
|
18995
|
+
text: wire.body,
|
|
18996
|
+
author: wire.authorName,
|
|
18997
|
+
created_at: wire.createdAt
|
|
18998
|
+
}), "commentOf");
|
|
18999
|
+
var commentsService = /* @__PURE__ */ __name((api) => ({
|
|
19000
|
+
me: /* @__PURE__ */ __name(() => api.send({ method: "GET", path: "me" }, wireUser), "me"),
|
|
19001
|
+
list: /* @__PURE__ */ __name(async ({ limit, offset, author }) => {
|
|
19002
|
+
const page = await api.send({ method: "GET", path: "comments", query: { limit, offset, by: author } }, wirePage);
|
|
19003
|
+
return { items: page.comments.map(commentOf), has_more: page.hasMore };
|
|
19004
|
+
}, "list"),
|
|
19005
|
+
show: /* @__PURE__ */ __name(async (id3) => commentOf(await api.send({ method: "GET", path: "comments/{id}", ids: { id: id3 } }, wireComment)), "show"),
|
|
19006
|
+
create: /* @__PURE__ */ __name(async (text2) => commentOf(await api.send({ method: "POST", path: "comments", body: { body: text2 } }, wireComment)), "create"),
|
|
19007
|
+
update: /* @__PURE__ */ __name(async (id3, text2) => commentOf(await api.send({ method: "PATCH", path: "comments/{id}", ids: { id: id3 }, body: { body: text2 } }, wireComment)), "update")
|
|
19008
|
+
}), "commentsService");
|
|
19009
|
+
|
|
19010
|
+
// dist/sample/transport.js
|
|
19011
|
+
var SERVICE_URL = "https://comments.example.invalid/v1/";
|
|
19012
|
+
var SERVICE = "Example Comments";
|
|
19013
|
+
var TIMEOUT_MS = 3e4;
|
|
19014
|
+
var LARGEST_ANSWER = 8 * 1024 * 1024;
|
|
19015
|
+
var LONGEST_PACE_WAIT_MS = 6e4;
|
|
19016
|
+
var segment = /* @__PURE__ */ __name((name, value2) => {
|
|
19017
|
+
if (value2 === "" || value2 === "." || value2 === "..")
|
|
19018
|
+
throw new CliError("validation_error", `${name} must name one item; an empty, "." or ".." id is refused`);
|
|
19019
|
+
return encodeURIComponent(value2);
|
|
19020
|
+
}, "segment");
|
|
19021
|
+
var urlOf = /* @__PURE__ */ __name(({ path, ids = {}, query = {} }) => {
|
|
19022
|
+
const url = new URL(path.replace(/\{(\w+)\}/g, (_2, name) => segment(name, ids[name] ?? "")), SERVICE_URL);
|
|
19023
|
+
for (const [key, value2] of Object.entries(query))
|
|
19024
|
+
if (value2 !== void 0)
|
|
19025
|
+
url.searchParams.set(key, String(value2));
|
|
19026
|
+
return url;
|
|
19027
|
+
}, "urlOf");
|
|
19028
|
+
var failureOf2 = /* @__PURE__ */ __name((status, writes2, retryAfterMs) => {
|
|
19029
|
+
if (status === 401)
|
|
19030
|
+
return new CliError("authentication_error", `${SERVICE} refused the token; sign in again with session start`, {
|
|
19031
|
+
status
|
|
19032
|
+
});
|
|
19033
|
+
if (status === 429)
|
|
19034
|
+
return new CliError("rate_limited", `${SERVICE} asked to slow down; retry the command later`, {
|
|
19035
|
+
status,
|
|
19036
|
+
retryable: true,
|
|
19037
|
+
...retryAfterMs === void 0 ? {} : { retry_after_ms: retryAfterMs }
|
|
19038
|
+
});
|
|
19039
|
+
if (status >= 500 && writes2)
|
|
19040
|
+
return new CliError("outcome_unknown", `${SERVICE} failed during a write; check it before repeating the write`, {
|
|
19041
|
+
status,
|
|
19042
|
+
retryable: false
|
|
19043
|
+
});
|
|
19044
|
+
if (status === 404)
|
|
19045
|
+
return new CliError("not_found", `${SERVICE} has no such item, or this token cannot see it`);
|
|
19046
|
+
return new CliError(statusToCode(status), `${SERVICE} refused the request (HTTP ${status})`, {
|
|
19047
|
+
status,
|
|
19048
|
+
retryable: status >= 500
|
|
19049
|
+
});
|
|
19050
|
+
}, "failureOf");
|
|
19051
|
+
var transport = /* @__PURE__ */ __name((options) => {
|
|
19052
|
+
const fetchOf = options.fetch ?? fetch;
|
|
19053
|
+
const sleep4 = options.sleep ?? realSleep;
|
|
19054
|
+
const now = options.now ?? Date.now;
|
|
19055
|
+
const turn = /* @__PURE__ */ __name(async () => {
|
|
19056
|
+
if (!options.pacer)
|
|
19057
|
+
return;
|
|
19058
|
+
const wait = await options.pacer.reserve() - now();
|
|
19059
|
+
if (wait <= 0)
|
|
19060
|
+
return;
|
|
19061
|
+
if (wait > LONGEST_PACE_WAIT_MS)
|
|
19062
|
+
throw new CliError("rate_limited", `this profile must wait ${Math.ceil(wait / 1e3)} s before its next request`, {
|
|
19063
|
+
retry_after_ms: wait
|
|
19064
|
+
});
|
|
19065
|
+
await sleep4(wait, options.signal, "retry");
|
|
19066
|
+
}, "turn");
|
|
19067
|
+
const unanswered2 = /* @__PURE__ */ __name((writes2, error) => {
|
|
19068
|
+
if (writes2)
|
|
19069
|
+
return new CliError("outcome_unknown", `${SERVICE} did not answer a write; check it before repeating the write`, {
|
|
19070
|
+
retryable: false
|
|
19071
|
+
});
|
|
19072
|
+
if (options.signal?.aborted)
|
|
19073
|
+
return new CliError("cancelled", `the ${SERVICE} request was stopped`);
|
|
19074
|
+
const timedOut = error?.name === "TimeoutError";
|
|
19075
|
+
return timedOut ? new CliError("timeout", `${SERVICE} did not answer in time`, { retryable: true }) : new CliError("network_error", `${SERVICE} could not be reached`, { retryable: true });
|
|
19076
|
+
}, "unanswered");
|
|
19077
|
+
const send = /* @__PURE__ */ __name(async (request, answer3) => {
|
|
19078
|
+
const writes2 = request.method !== "GET";
|
|
19079
|
+
const url = urlOf(request);
|
|
19080
|
+
await turn();
|
|
19081
|
+
const deadline = new AbortController();
|
|
19082
|
+
const timer = setTimeout(() => deadline.abort(new DOMException("timed out", "TimeoutError")), options.timeoutMs ?? TIMEOUT_MS);
|
|
19083
|
+
timer.unref();
|
|
19084
|
+
const signal = options.signal ? AbortSignal.any([options.signal, deadline.signal]) : deadline.signal;
|
|
19085
|
+
const end = providerRequest(`${request.method} /${request.path}`, options.events, {
|
|
19086
|
+
method: request.method,
|
|
19087
|
+
transport: "http"
|
|
19088
|
+
});
|
|
19089
|
+
try {
|
|
19090
|
+
let response;
|
|
19091
|
+
try {
|
|
19092
|
+
response = await fetchOf(url, {
|
|
19093
|
+
method: request.method,
|
|
19094
|
+
headers: {
|
|
19095
|
+
authorization: `Bearer ${options.token}`,
|
|
19096
|
+
accept: "application/json",
|
|
19097
|
+
...request.body ? { "content-type": "application/json" } : {}
|
|
19098
|
+
},
|
|
19099
|
+
...request.body ? { body: JSON.stringify(request.body) } : {},
|
|
19100
|
+
// A redirect would carry the Authorization header to an address we did not choose.
|
|
19101
|
+
redirect: "error",
|
|
19102
|
+
signal
|
|
19103
|
+
});
|
|
19104
|
+
} catch (error) {
|
|
19105
|
+
const failure2 = unanswered2(writes2, deadline.signal.reason ?? error);
|
|
19106
|
+
end({ errorCode: failure2.code });
|
|
19107
|
+
throw failure2;
|
|
19108
|
+
}
|
|
19109
|
+
if (!response.ok) {
|
|
19110
|
+
const failure2 = failureOf2(response.status, writes2, providerWaitMs(response.headers, wallClock));
|
|
19111
|
+
end({ status: response.status, errorCode: failure2.code });
|
|
19112
|
+
throw failure2;
|
|
19113
|
+
}
|
|
19114
|
+
let body;
|
|
19115
|
+
try {
|
|
19116
|
+
body = await readJsonResponse(response, { maxBytes: LARGEST_ANSWER, signal });
|
|
19117
|
+
} catch (error) {
|
|
19118
|
+
const failure2 = isCliError(error) && error.code !== "invalid_response" ? error : new CliError("invalid_response", `${SERVICE} answered with something other than bounded JSON`);
|
|
19119
|
+
end({ status: response.status, errorCode: failure2.code });
|
|
19120
|
+
throw failure2;
|
|
19121
|
+
}
|
|
19122
|
+
const parsed = safeParse(answer3, body);
|
|
19123
|
+
if (!parsed.success) {
|
|
19124
|
+
end({ status: response.status, errorCode: "invalid_response" });
|
|
19125
|
+
throw new CliError("invalid_response", `${SERVICE}'s answer does not have the documented shape`);
|
|
19126
|
+
}
|
|
19127
|
+
end({ status: response.status });
|
|
19128
|
+
return parsed.output;
|
|
19129
|
+
} finally {
|
|
19130
|
+
clearTimeout(timer);
|
|
19131
|
+
}
|
|
19132
|
+
}, "send");
|
|
19133
|
+
return { send };
|
|
19134
|
+
}, "transport");
|
|
19135
|
+
|
|
19136
|
+
// dist/token.js
|
|
19137
|
+
var TOKEN_VARIABLE = `${IDENTITY.envPrefix}_TOKEN`;
|
|
19138
|
+
var tokenStore = /* @__PURE__ */ __name((env, keyring, warn) => {
|
|
19139
|
+
const where = { appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env };
|
|
19140
|
+
const options = {
|
|
19141
|
+
configDir: resolvePaths(where).config,
|
|
19142
|
+
service: IDENTITY.appName,
|
|
19143
|
+
envVar: TOKEN_VARIABLE,
|
|
19144
|
+
isolated: isMovedRun(where),
|
|
19145
|
+
env,
|
|
19146
|
+
...keyring ? { keyring } : {},
|
|
19147
|
+
warn
|
|
19148
|
+
};
|
|
19149
|
+
const credentials = new Credentials(options);
|
|
19150
|
+
const account = /* @__PURE__ */ __name((profile) => `token:${profile}`, "account");
|
|
18901
19151
|
return {
|
|
18902
|
-
|
|
18903
|
-
|
|
19152
|
+
read: /* @__PURE__ */ __name((profile) => credentials.read(account(profile)), "read"),
|
|
19153
|
+
write: /* @__PURE__ */ __name((profile, token, storage) => new Credentials({ ...options, storage: storage === "file" ? "file" : "auto" }).write(account(profile), token, {
|
|
19154
|
+
signIn: true
|
|
19155
|
+
}), "write"),
|
|
19156
|
+
remove: /* @__PURE__ */ __name((profile) => credentials.remove(account(profile)), "remove")
|
|
18904
19157
|
};
|
|
18905
|
-
}, "
|
|
18906
|
-
var
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
19158
|
+
}, "tokenStore");
|
|
19159
|
+
var holdsToken = /* @__PURE__ */ __name((env, profile, keyring) => tokenStore(env, keyring, () => {
|
|
19160
|
+
}).read(profile) !== void 0, "holdsToken");
|
|
19161
|
+
|
|
19162
|
+
// dist/context.js
|
|
19163
|
+
var PACE = { perMinute: 120, burst: 20 };
|
|
19164
|
+
var contextOf = /* @__PURE__ */ __name((command) => {
|
|
19165
|
+
const base = baseContext(command, configuration.resolveSettings);
|
|
19166
|
+
return {
|
|
19167
|
+
...base,
|
|
19168
|
+
environment: environmentOf(command),
|
|
19169
|
+
flags: command.optsWithGlobals(),
|
|
19170
|
+
profile: base.settings.profile,
|
|
19171
|
+
tokens: tokenStore(base.env, base.keyring, base.renderer.warn)
|
|
18912
19172
|
};
|
|
18913
|
-
|
|
19173
|
+
}, "contextOf");
|
|
19174
|
+
var signInWords = /* @__PURE__ */ __name((profile) => `\`${IDENTITY.command} ${profile} session start\``, "signInWords");
|
|
19175
|
+
var refuseOffline = /* @__PURE__ */ __name((flags) => {
|
|
19176
|
+
if (flags.offline)
|
|
19177
|
+
throw new CliError("permission_error", `this needs ${SERVICE}; leave out --offline`, { reason: "offline.refused" });
|
|
19178
|
+
}, "refuseOffline");
|
|
19179
|
+
var serviceFor = /* @__PURE__ */ __name((command, token, events) => {
|
|
19180
|
+
const { environment, env, profile } = contextOf(command);
|
|
19181
|
+
return commentsService(transport({
|
|
19182
|
+
token,
|
|
19183
|
+
events,
|
|
19184
|
+
signal: environment.signal,
|
|
19185
|
+
...environment.fetch ? { fetch: environment.fetch } : {},
|
|
19186
|
+
pacer: new Pacer(pacePathFor(IDENTITY, profile, env), PACE)
|
|
19187
|
+
}));
|
|
19188
|
+
}, "serviceFor");
|
|
19189
|
+
var tokenOf = /* @__PURE__ */ __name((command) => {
|
|
19190
|
+
const { flags, profile, tokens } = contextOf(command);
|
|
19191
|
+
refuseOffline(flags);
|
|
19192
|
+
const saved = tokens.read(profile);
|
|
19193
|
+
if (!saved)
|
|
19194
|
+
throw new CliError("authentication_error", `profile ${profile} is not signed in \u2014 run ${signInWords(profile)}`);
|
|
19195
|
+
return saved.secret;
|
|
19196
|
+
}, "tokenOf");
|
|
19197
|
+
var withService = /* @__PURE__ */ __name((command, body) => {
|
|
19198
|
+
const token = tokenOf(command);
|
|
19199
|
+
return contextOf(command).run((events) => body(serviceFor(command, token, events)));
|
|
19200
|
+
}, "withService");
|
|
19201
|
+
|
|
19202
|
+
// dist/commands/comments.js
|
|
19203
|
+
var CLI = IDENTITY.command;
|
|
19204
|
+
var COMMENTS_QUERY2 = {
|
|
19205
|
+
entity: "comment",
|
|
19206
|
+
backend: "native",
|
|
19207
|
+
fields: [termField("author", "kw", "author:u2")]
|
|
19208
|
+
};
|
|
19209
|
+
var ALL_PAGES = 20;
|
|
19210
|
+
var ALL_PAGE_SIZE = 100;
|
|
19211
|
+
var listAll = /* @__PURE__ */ __name(async (service, author) => {
|
|
19212
|
+
const items = [];
|
|
19213
|
+
for (let page = 0; page < ALL_PAGES; page++) {
|
|
19214
|
+
const found = await service.list({ limit: ALL_PAGE_SIZE, offset: page * ALL_PAGE_SIZE, author });
|
|
19215
|
+
for (const item of found.items)
|
|
19216
|
+
items.push(item);
|
|
19217
|
+
if (!found.has_more)
|
|
19218
|
+
return { items, has_more: false };
|
|
19219
|
+
}
|
|
19220
|
+
return { items, has_more: true };
|
|
19221
|
+
}, "listAll");
|
|
19222
|
+
var listCommand4 = /* @__PURE__ */ __name(() => withPaging(withQuery(answerEntity(annotate(new Command("list"), {
|
|
19223
|
+
effects: REMOTE_READ,
|
|
19224
|
+
offline: false,
|
|
19225
|
+
examples: [`${CLI} personal comments list`, `${CLI} personal comments list author:u2 --json=id,text`]
|
|
19226
|
+
}), "comment", commentSchema), COMMENTS_QUERY2)).description(`list the comments in ${SERVICE}, newest first`).action(async function(words3) {
|
|
19227
|
+
const path = commandPath(this);
|
|
19228
|
+
const author = queryTerms(words3, COMMENTS_QUERY2, path).get("author");
|
|
19229
|
+
const { settings } = contextOf(this);
|
|
19230
|
+
const found = await withService(this, (service) => settings.all ? listAll(service, author) : service.list({ ...pageOf(settings), author }));
|
|
19231
|
+
renderAnswer(this, outputFor(this), pagedList(path, settings, found));
|
|
19232
|
+
}), "listCommand");
|
|
19233
|
+
var showCommand3 = /* @__PURE__ */ __name(() => answerEntity(annotate(new Command("show"), {
|
|
19234
|
+
effects: REMOTE_READ,
|
|
19235
|
+
offline: false,
|
|
19236
|
+
examples: [`${CLI} personal comments show c1`, `${CLI} personal comments show c1 --json`]
|
|
19237
|
+
}), "comment", commentSchema).description(`show one comment in ${SERVICE}`).argument("<id>", "the comment's id, as list prints it").action(async function(id3) {
|
|
19238
|
+
renderAnswer(this, outputFor(this), itemOf(await withService(this, (service) => service.show(id3))));
|
|
19239
|
+
}), "showCommand");
|
|
19240
|
+
var write = /* @__PURE__ */ __name(async (command, act2) => {
|
|
19241
|
+
const { settings, env, renderer } = contextOf(command);
|
|
19242
|
+
const key = commandPath(command).replaceAll(" ", ".");
|
|
19243
|
+
const operationId = newOperationId();
|
|
19244
|
+
const levelOf = /* @__PURE__ */ __name((one) => levelFor(settings.permissions, one, permissions.defaults).level, "levelOf");
|
|
19245
|
+
const guard = keyedGuard((ask) => guardFor(
|
|
19246
|
+
IDENTITY,
|
|
19247
|
+
// SAMPLE: the service limits its own rate, so this guard keeps the levels and the journal, not a send cap.
|
|
19248
|
+
{ ...settings, sendsPerHour: Number.MAX_SAFE_INTEGER, permissionDefaults: permissions.defaults },
|
|
19249
|
+
renderer.warn,
|
|
19250
|
+
env,
|
|
19251
|
+
ask
|
|
19252
|
+
), terminalAsker(command), levelOf, []);
|
|
19253
|
+
const request = { chatId: null, kind: "edit", key, operationId };
|
|
19254
|
+
guard.refuse(request);
|
|
19255
|
+
let comment;
|
|
18914
19256
|
try {
|
|
18915
|
-
|
|
18916
|
-
const { files, fixes } = configFiles3(settings.configPath);
|
|
18917
|
-
return {
|
|
18918
|
-
report: {
|
|
18919
|
-
...common,
|
|
18920
|
-
config: { path: settings.configPath, found: settings.configFound, issues: settings.configIssues ?? [] },
|
|
18921
|
-
profiles: settings.configuredProfiles,
|
|
18922
|
-
read_only: readOnly,
|
|
18923
|
-
files
|
|
18924
|
-
},
|
|
18925
|
-
fixes
|
|
18926
|
-
};
|
|
19257
|
+
comment = await guardedWrite(guard, request, () => withService(command, act2));
|
|
18927
19258
|
} catch (error) {
|
|
18928
|
-
|
|
18929
|
-
|
|
18930
|
-
|
|
18931
|
-
report: {
|
|
18932
|
-
...common,
|
|
18933
|
-
config: { path: file, found: existsSync18(file), issues: [] },
|
|
18934
|
-
settings: { error: failure2(error) },
|
|
18935
|
-
profiles: null,
|
|
18936
|
-
read_only: readOnly,
|
|
18937
|
-
files
|
|
18938
|
-
},
|
|
18939
|
-
fixes
|
|
18940
|
-
};
|
|
19259
|
+
if (error instanceof CliError && error.code === "outcome_unknown")
|
|
19260
|
+
throw new CliError("outcome_unknown", error.message, { ...error.details, operation_id: operationId });
|
|
19261
|
+
throw error;
|
|
18941
19262
|
}
|
|
18942
|
-
|
|
18943
|
-
|
|
18944
|
-
|
|
18945
|
-
examples: [`${IDENTITY.command} doctor`, `${IDENTITY.command} doctor --json`]
|
|
18946
|
-
})).description("check this installation: version, paths, config, profiles; no keyring or network").action(function() {
|
|
18947
|
-
const env = environmentOf(this).env ?? process.env;
|
|
18948
|
-
const { report: report2, fixes } = doctorReport(env);
|
|
18949
|
-
const output = outputFor(this);
|
|
18950
|
-
renderAnswer(this, output, itemOf(report2));
|
|
18951
|
-
for (const fix of fixes)
|
|
18952
|
-
output.renderer.note(`to make it private: ${fix}`);
|
|
18953
|
-
}), "doctorCommand");
|
|
18954
|
-
|
|
18955
|
-
// dist/commands/mcp.js
|
|
18956
|
-
var SETUP = `claude mcp add ${IDENTITY.command} -- ${IDENTITY.command} personal mcp serve`;
|
|
18957
|
-
var settingsOf2 = /* @__PURE__ */ __name((command) => {
|
|
18958
|
-
const flags = command.optsWithGlobals();
|
|
18959
|
-
const env = environmentOf(command).env ?? process.env;
|
|
18960
|
-
const { profile } = configuration.resolveSettings(flags, { env });
|
|
18961
|
-
return { flags, env, profile, tokenFile: httpTokenFile(IDENTITY, profile, env) };
|
|
18962
|
-
}, "settingsOf");
|
|
18963
|
-
var serveCommand3 = /* @__PURE__ */ __name(() => annotate(new Command("serve"), {
|
|
19263
|
+
renderAnswer(command, outputFor(command), itemOf({ operation_id: operationId, comment }));
|
|
19264
|
+
}, "write");
|
|
19265
|
+
var createCommand = /* @__PURE__ */ __name(() => annotate(new Command("create"), {
|
|
18964
19266
|
effects: REMOTE_WRITE,
|
|
18965
|
-
|
|
18966
|
-
mcp: false,
|
|
19267
|
+
offline: false,
|
|
18967
19268
|
examples: [
|
|
18968
|
-
`${
|
|
18969
|
-
`${
|
|
19269
|
+
`${CLI} personal comments create --text "Looks good to me"`,
|
|
19270
|
+
`${CLI} personal comments create --text "Looks good to me" --dry-run`
|
|
18970
19271
|
]
|
|
18971
|
-
}).
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
|
|
18978
|
-
|
|
18979
|
-
|
|
18980
|
-
|
|
18981
|
-
|
|
18982
|
-
|
|
18983
|
-
|
|
18984
|
-
|
|
18985
|
-
|
|
18986
|
-
|
|
19272
|
+
}).description(`post a comment in ${SERVICE}`).requiredOption("--text <text>", "the comment's text").action(async function(args) {
|
|
19273
|
+
await write(this, (service) => service.create(args.text));
|
|
19274
|
+
}), "createCommand");
|
|
19275
|
+
var updateCommand2 = /* @__PURE__ */ __name(() => annotate(new Command("update"), {
|
|
19276
|
+
effects: REMOTE_WRITE,
|
|
19277
|
+
offline: false,
|
|
19278
|
+
examples: [`${CLI} personal comments update c1 --text "Looks good now"`]
|
|
19279
|
+
}).description(`change the text of your comment in ${SERVICE}`).argument("<id>", "the comment's id, as list prints it").requiredOption("--text <text>", "the new text").action(async function(id3, args) {
|
|
19280
|
+
await write(this, (service) => service.update(id3, args.text));
|
|
19281
|
+
}), "updateCommand");
|
|
19282
|
+
var commentsCommand2 = /* @__PURE__ */ __name(() => annotate(new Command("comments"), { effects: REMOTE_READ }).description(`read and write comments in ${SERVICE}, the sample service`).addCommand(listCommand4()).addCommand(showCommand3()).addCommand(createCommand()).addCommand(updateCommand2()), "commentsCommand");
|
|
19283
|
+
|
|
19284
|
+
// node_modules/.pnpm/qrcode-generator@2.0.4/node_modules/qrcode-generator/dist/qrcode.mjs
|
|
19285
|
+
var qrcode = /* @__PURE__ */ __name(function(typeNumber, errorCorrectionLevel) {
|
|
19286
|
+
const PAD0 = 236;
|
|
19287
|
+
const PAD1 = 17;
|
|
19288
|
+
let _typeNumber = typeNumber;
|
|
19289
|
+
const _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
|
|
19290
|
+
let _modules = null;
|
|
19291
|
+
let _moduleCount = 0;
|
|
19292
|
+
let _dataCache = null;
|
|
19293
|
+
const _dataList = [];
|
|
19294
|
+
const _this = {};
|
|
19295
|
+
const makeImpl = /* @__PURE__ */ __name(function(test, maskPattern) {
|
|
19296
|
+
_moduleCount = _typeNumber * 4 + 17;
|
|
19297
|
+
_modules = (function(moduleCount) {
|
|
19298
|
+
const modules = new Array(moduleCount);
|
|
19299
|
+
for (let row2 = 0; row2 < moduleCount; row2 += 1) {
|
|
19300
|
+
modules[row2] = new Array(moduleCount);
|
|
19301
|
+
for (let col = 0; col < moduleCount; col += 1) {
|
|
19302
|
+
modules[row2][col] = null;
|
|
19303
|
+
}
|
|
19304
|
+
}
|
|
19305
|
+
return modules;
|
|
19306
|
+
})(_moduleCount);
|
|
19307
|
+
setupPositionProbePattern(0, 0);
|
|
19308
|
+
setupPositionProbePattern(_moduleCount - 7, 0);
|
|
19309
|
+
setupPositionProbePattern(0, _moduleCount - 7);
|
|
19310
|
+
setupPositionAdjustPattern();
|
|
19311
|
+
setupTimingPattern();
|
|
19312
|
+
setupTypeInfo(test, maskPattern);
|
|
19313
|
+
if (_typeNumber >= 7) {
|
|
19314
|
+
setupTypeNumber(test);
|
|
19315
|
+
}
|
|
19316
|
+
if (_dataCache == null) {
|
|
19317
|
+
_dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
|
|
19318
|
+
}
|
|
19319
|
+
mapData(_dataCache, maskPattern);
|
|
19320
|
+
}, "makeImpl");
|
|
19321
|
+
const setupPositionProbePattern = /* @__PURE__ */ __name(function(row2, col) {
|
|
19322
|
+
for (let r2 = -1; r2 <= 7; r2 += 1) {
|
|
19323
|
+
if (row2 + r2 <= -1 || _moduleCount <= row2 + r2) continue;
|
|
19324
|
+
for (let c2 = -1; c2 <= 7; c2 += 1) {
|
|
19325
|
+
if (col + c2 <= -1 || _moduleCount <= col + c2) continue;
|
|
19326
|
+
if (0 <= r2 && r2 <= 6 && (c2 == 0 || c2 == 6) || 0 <= c2 && c2 <= 6 && (r2 == 0 || r2 == 6) || 2 <= r2 && r2 <= 4 && 2 <= c2 && c2 <= 4) {
|
|
19327
|
+
_modules[row2 + r2][col + c2] = true;
|
|
19328
|
+
} else {
|
|
19329
|
+
_modules[row2 + r2][col + c2] = false;
|
|
19330
|
+
}
|
|
19331
|
+
}
|
|
19332
|
+
}
|
|
19333
|
+
}, "setupPositionProbePattern");
|
|
19334
|
+
const getBestMaskPattern = /* @__PURE__ */ __name(function() {
|
|
19335
|
+
let minLostPoint = 0;
|
|
19336
|
+
let pattern = 0;
|
|
19337
|
+
for (let i3 = 0; i3 < 8; i3 += 1) {
|
|
19338
|
+
makeImpl(true, i3);
|
|
19339
|
+
const lostPoint = QRUtil.getLostPoint(_this);
|
|
19340
|
+
if (i3 == 0 || minLostPoint > lostPoint) {
|
|
19341
|
+
minLostPoint = lostPoint;
|
|
19342
|
+
pattern = i3;
|
|
19343
|
+
}
|
|
19344
|
+
}
|
|
19345
|
+
return pattern;
|
|
19346
|
+
}, "getBestMaskPattern");
|
|
19347
|
+
const setupTimingPattern = /* @__PURE__ */ __name(function() {
|
|
19348
|
+
for (let r2 = 8; r2 < _moduleCount - 8; r2 += 1) {
|
|
19349
|
+
if (_modules[r2][6] != null) {
|
|
19350
|
+
continue;
|
|
19351
|
+
}
|
|
19352
|
+
_modules[r2][6] = r2 % 2 == 0;
|
|
19353
|
+
}
|
|
19354
|
+
for (let c2 = 8; c2 < _moduleCount - 8; c2 += 1) {
|
|
19355
|
+
if (_modules[6][c2] != null) {
|
|
19356
|
+
continue;
|
|
19357
|
+
}
|
|
19358
|
+
_modules[6][c2] = c2 % 2 == 0;
|
|
19359
|
+
}
|
|
19360
|
+
}, "setupTimingPattern");
|
|
19361
|
+
const setupPositionAdjustPattern = /* @__PURE__ */ __name(function() {
|
|
19362
|
+
const pos = QRUtil.getPatternPosition(_typeNumber);
|
|
19363
|
+
for (let i3 = 0; i3 < pos.length; i3 += 1) {
|
|
19364
|
+
for (let j = 0; j < pos.length; j += 1) {
|
|
19365
|
+
const row2 = pos[i3];
|
|
19366
|
+
const col = pos[j];
|
|
19367
|
+
if (_modules[row2][col] != null) {
|
|
19368
|
+
continue;
|
|
19369
|
+
}
|
|
19370
|
+
for (let r2 = -2; r2 <= 2; r2 += 1) {
|
|
19371
|
+
for (let c2 = -2; c2 <= 2; c2 += 1) {
|
|
19372
|
+
if (r2 == -2 || r2 == 2 || c2 == -2 || c2 == 2 || r2 == 0 && c2 == 0) {
|
|
19373
|
+
_modules[row2 + r2][col + c2] = true;
|
|
19374
|
+
} else {
|
|
19375
|
+
_modules[row2 + r2][col + c2] = false;
|
|
19376
|
+
}
|
|
19377
|
+
}
|
|
19378
|
+
}
|
|
19379
|
+
}
|
|
19380
|
+
}
|
|
19381
|
+
}, "setupPositionAdjustPattern");
|
|
19382
|
+
const setupTypeNumber = /* @__PURE__ */ __name(function(test) {
|
|
19383
|
+
const bits = QRUtil.getBCHTypeNumber(_typeNumber);
|
|
19384
|
+
for (let i3 = 0; i3 < 18; i3 += 1) {
|
|
19385
|
+
const mod = !test && (bits >> i3 & 1) == 1;
|
|
19386
|
+
_modules[Math.floor(i3 / 3)][i3 % 3 + _moduleCount - 8 - 3] = mod;
|
|
19387
|
+
}
|
|
19388
|
+
for (let i3 = 0; i3 < 18; i3 += 1) {
|
|
19389
|
+
const mod = !test && (bits >> i3 & 1) == 1;
|
|
19390
|
+
_modules[i3 % 3 + _moduleCount - 8 - 3][Math.floor(i3 / 3)] = mod;
|
|
19391
|
+
}
|
|
19392
|
+
}, "setupTypeNumber");
|
|
19393
|
+
const setupTypeInfo = /* @__PURE__ */ __name(function(test, maskPattern) {
|
|
19394
|
+
const data = _errorCorrectionLevel << 3 | maskPattern;
|
|
19395
|
+
const bits = QRUtil.getBCHTypeInfo(data);
|
|
19396
|
+
for (let i3 = 0; i3 < 15; i3 += 1) {
|
|
19397
|
+
const mod = !test && (bits >> i3 & 1) == 1;
|
|
19398
|
+
if (i3 < 6) {
|
|
19399
|
+
_modules[i3][8] = mod;
|
|
19400
|
+
} else if (i3 < 8) {
|
|
19401
|
+
_modules[i3 + 1][8] = mod;
|
|
19402
|
+
} else {
|
|
19403
|
+
_modules[_moduleCount - 15 + i3][8] = mod;
|
|
19404
|
+
}
|
|
19405
|
+
}
|
|
19406
|
+
for (let i3 = 0; i3 < 15; i3 += 1) {
|
|
19407
|
+
const mod = !test && (bits >> i3 & 1) == 1;
|
|
19408
|
+
if (i3 < 8) {
|
|
19409
|
+
_modules[8][_moduleCount - i3 - 1] = mod;
|
|
19410
|
+
} else if (i3 < 9) {
|
|
19411
|
+
_modules[8][15 - i3 - 1 + 1] = mod;
|
|
19412
|
+
} else {
|
|
19413
|
+
_modules[8][15 - i3 - 1] = mod;
|
|
19414
|
+
}
|
|
19415
|
+
}
|
|
19416
|
+
_modules[_moduleCount - 8][8] = !test;
|
|
19417
|
+
}, "setupTypeInfo");
|
|
19418
|
+
const mapData = /* @__PURE__ */ __name(function(data, maskPattern) {
|
|
19419
|
+
let inc = -1;
|
|
19420
|
+
let row2 = _moduleCount - 1;
|
|
19421
|
+
let bitIndex = 7;
|
|
19422
|
+
let byteIndex = 0;
|
|
19423
|
+
const maskFunc = QRUtil.getMaskFunction(maskPattern);
|
|
19424
|
+
for (let col = _moduleCount - 1; col > 0; col -= 2) {
|
|
19425
|
+
if (col == 6) col -= 1;
|
|
19426
|
+
while (true) {
|
|
19427
|
+
for (let c2 = 0; c2 < 2; c2 += 1) {
|
|
19428
|
+
if (_modules[row2][col - c2] == null) {
|
|
19429
|
+
let dark = false;
|
|
19430
|
+
if (byteIndex < data.length) {
|
|
19431
|
+
dark = (data[byteIndex] >>> bitIndex & 1) == 1;
|
|
19432
|
+
}
|
|
19433
|
+
const mask = maskFunc(row2, col - c2);
|
|
19434
|
+
if (mask) {
|
|
19435
|
+
dark = !dark;
|
|
19436
|
+
}
|
|
19437
|
+
_modules[row2][col - c2] = dark;
|
|
19438
|
+
bitIndex -= 1;
|
|
19439
|
+
if (bitIndex == -1) {
|
|
19440
|
+
byteIndex += 1;
|
|
19441
|
+
bitIndex = 7;
|
|
19442
|
+
}
|
|
19443
|
+
}
|
|
19444
|
+
}
|
|
19445
|
+
row2 += inc;
|
|
19446
|
+
if (row2 < 0 || _moduleCount <= row2) {
|
|
19447
|
+
row2 -= inc;
|
|
19448
|
+
inc = -inc;
|
|
19449
|
+
break;
|
|
19450
|
+
}
|
|
19451
|
+
}
|
|
19452
|
+
}
|
|
19453
|
+
}, "mapData");
|
|
19454
|
+
const createBytes = /* @__PURE__ */ __name(function(buffer, rsBlocks) {
|
|
19455
|
+
let offset = 0;
|
|
19456
|
+
let maxDcCount = 0;
|
|
19457
|
+
let maxEcCount = 0;
|
|
19458
|
+
const dcdata = new Array(rsBlocks.length);
|
|
19459
|
+
const ecdata = new Array(rsBlocks.length);
|
|
19460
|
+
for (let r2 = 0; r2 < rsBlocks.length; r2 += 1) {
|
|
19461
|
+
const dcCount = rsBlocks[r2].dataCount;
|
|
19462
|
+
const ecCount = rsBlocks[r2].totalCount - dcCount;
|
|
19463
|
+
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
19464
|
+
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
19465
|
+
dcdata[r2] = new Array(dcCount);
|
|
19466
|
+
for (let i3 = 0; i3 < dcdata[r2].length; i3 += 1) {
|
|
19467
|
+
dcdata[r2][i3] = 255 & buffer.getBuffer()[i3 + offset];
|
|
19468
|
+
}
|
|
19469
|
+
offset += dcCount;
|
|
19470
|
+
const rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
|
|
19471
|
+
const rawPoly = qrPolynomial(dcdata[r2], rsPoly.getLength() - 1);
|
|
19472
|
+
const modPoly = rawPoly.mod(rsPoly);
|
|
19473
|
+
ecdata[r2] = new Array(rsPoly.getLength() - 1);
|
|
19474
|
+
for (let i3 = 0; i3 < ecdata[r2].length; i3 += 1) {
|
|
19475
|
+
const modIndex = i3 + modPoly.getLength() - ecdata[r2].length;
|
|
19476
|
+
ecdata[r2][i3] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
|
|
19477
|
+
}
|
|
19478
|
+
}
|
|
19479
|
+
let totalCodeCount = 0;
|
|
19480
|
+
for (let i3 = 0; i3 < rsBlocks.length; i3 += 1) {
|
|
19481
|
+
totalCodeCount += rsBlocks[i3].totalCount;
|
|
19482
|
+
}
|
|
19483
|
+
const data = new Array(totalCodeCount);
|
|
19484
|
+
let index = 0;
|
|
19485
|
+
for (let i3 = 0; i3 < maxDcCount; i3 += 1) {
|
|
19486
|
+
for (let r2 = 0; r2 < rsBlocks.length; r2 += 1) {
|
|
19487
|
+
if (i3 < dcdata[r2].length) {
|
|
19488
|
+
data[index] = dcdata[r2][i3];
|
|
19489
|
+
index += 1;
|
|
19490
|
+
}
|
|
19491
|
+
}
|
|
19492
|
+
}
|
|
19493
|
+
for (let i3 = 0; i3 < maxEcCount; i3 += 1) {
|
|
19494
|
+
for (let r2 = 0; r2 < rsBlocks.length; r2 += 1) {
|
|
19495
|
+
if (i3 < ecdata[r2].length) {
|
|
19496
|
+
data[index] = ecdata[r2][i3];
|
|
19497
|
+
index += 1;
|
|
19498
|
+
}
|
|
19499
|
+
}
|
|
19500
|
+
}
|
|
19501
|
+
return data;
|
|
19502
|
+
}, "createBytes");
|
|
19503
|
+
const createData = /* @__PURE__ */ __name(function(typeNumber2, errorCorrectionLevel2, dataList) {
|
|
19504
|
+
const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, errorCorrectionLevel2);
|
|
19505
|
+
const buffer = qrBitBuffer();
|
|
19506
|
+
for (let i3 = 0; i3 < dataList.length; i3 += 1) {
|
|
19507
|
+
const data = dataList[i3];
|
|
19508
|
+
buffer.put(data.getMode(), 4);
|
|
19509
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
|
|
19510
|
+
data.write(buffer);
|
|
19511
|
+
}
|
|
19512
|
+
let totalDataCount = 0;
|
|
19513
|
+
for (let i3 = 0; i3 < rsBlocks.length; i3 += 1) {
|
|
19514
|
+
totalDataCount += rsBlocks[i3].dataCount;
|
|
19515
|
+
}
|
|
19516
|
+
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
|
19517
|
+
throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
|
|
19518
|
+
}
|
|
19519
|
+
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
|
|
19520
|
+
buffer.put(0, 4);
|
|
19521
|
+
}
|
|
19522
|
+
while (buffer.getLengthInBits() % 8 != 0) {
|
|
19523
|
+
buffer.putBit(false);
|
|
19524
|
+
}
|
|
19525
|
+
while (true) {
|
|
19526
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
19527
|
+
break;
|
|
19528
|
+
}
|
|
19529
|
+
buffer.put(PAD0, 8);
|
|
19530
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
19531
|
+
break;
|
|
19532
|
+
}
|
|
19533
|
+
buffer.put(PAD1, 8);
|
|
19534
|
+
}
|
|
19535
|
+
return createBytes(buffer, rsBlocks);
|
|
19536
|
+
}, "createData");
|
|
19537
|
+
_this.addData = function(data, mode) {
|
|
19538
|
+
mode = mode || "Byte";
|
|
19539
|
+
let newData = null;
|
|
19540
|
+
switch (mode) {
|
|
19541
|
+
case "Numeric":
|
|
19542
|
+
newData = qrNumber(data);
|
|
19543
|
+
break;
|
|
19544
|
+
case "Alphanumeric":
|
|
19545
|
+
newData = qrAlphaNum(data);
|
|
19546
|
+
break;
|
|
19547
|
+
case "Byte":
|
|
19548
|
+
newData = qr8BitByte(data);
|
|
19549
|
+
break;
|
|
19550
|
+
case "Kanji":
|
|
19551
|
+
newData = qrKanji(data);
|
|
19552
|
+
break;
|
|
19553
|
+
default:
|
|
19554
|
+
throw "mode:" + mode;
|
|
19555
|
+
}
|
|
19556
|
+
_dataList.push(newData);
|
|
19557
|
+
_dataCache = null;
|
|
18987
19558
|
};
|
|
18988
|
-
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
|
|
19559
|
+
_this.isDark = function(row2, col) {
|
|
19560
|
+
if (row2 < 0 || _moduleCount <= row2 || col < 0 || _moduleCount <= col) {
|
|
19561
|
+
throw row2 + "," + col;
|
|
19562
|
+
}
|
|
19563
|
+
return _modules[row2][col];
|
|
19564
|
+
};
|
|
19565
|
+
_this.getModuleCount = function() {
|
|
19566
|
+
return _moduleCount;
|
|
19567
|
+
};
|
|
19568
|
+
_this.make = function() {
|
|
19569
|
+
if (_typeNumber < 1) {
|
|
19570
|
+
let typeNumber2 = 1;
|
|
19571
|
+
for (; typeNumber2 < 40; typeNumber2++) {
|
|
19572
|
+
const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, _errorCorrectionLevel);
|
|
19573
|
+
const buffer = qrBitBuffer();
|
|
19574
|
+
for (let i3 = 0; i3 < _dataList.length; i3++) {
|
|
19575
|
+
const data = _dataList[i3];
|
|
19576
|
+
buffer.put(data.getMode(), 4);
|
|
19577
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
|
|
19578
|
+
data.write(buffer);
|
|
19579
|
+
}
|
|
19580
|
+
let totalDataCount = 0;
|
|
19581
|
+
for (let i3 = 0; i3 < rsBlocks.length; i3++) {
|
|
19582
|
+
totalDataCount += rsBlocks[i3].dataCount;
|
|
19583
|
+
}
|
|
19584
|
+
if (buffer.getLengthInBits() <= totalDataCount * 8) {
|
|
19585
|
+
break;
|
|
19586
|
+
}
|
|
19587
|
+
}
|
|
19588
|
+
_typeNumber = typeNumber2;
|
|
19589
|
+
}
|
|
19590
|
+
makeImpl(false, getBestMaskPattern());
|
|
19591
|
+
};
|
|
19592
|
+
_this.createTableTag = function(cellSize, margin) {
|
|
19593
|
+
cellSize = cellSize || 2;
|
|
19594
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
19595
|
+
let qrHtml = "";
|
|
19596
|
+
qrHtml += '<table style="';
|
|
19597
|
+
qrHtml += " border-width: 0px; border-style: none;";
|
|
19598
|
+
qrHtml += " border-collapse: collapse;";
|
|
19599
|
+
qrHtml += " padding: 0px; margin: " + margin + "px;";
|
|
19600
|
+
qrHtml += '">';
|
|
19601
|
+
qrHtml += "<tbody>";
|
|
19602
|
+
for (let r2 = 0; r2 < _this.getModuleCount(); r2 += 1) {
|
|
19603
|
+
qrHtml += "<tr>";
|
|
19604
|
+
for (let c2 = 0; c2 < _this.getModuleCount(); c2 += 1) {
|
|
19605
|
+
qrHtml += '<td style="';
|
|
19606
|
+
qrHtml += " border-width: 0px; border-style: none;";
|
|
19607
|
+
qrHtml += " border-collapse: collapse;";
|
|
19608
|
+
qrHtml += " padding: 0px; margin: 0px;";
|
|
19609
|
+
qrHtml += " width: " + cellSize + "px;";
|
|
19610
|
+
qrHtml += " height: " + cellSize + "px;";
|
|
19611
|
+
qrHtml += " background-color: ";
|
|
19612
|
+
qrHtml += _this.isDark(r2, c2) ? "#000000" : "#ffffff";
|
|
19613
|
+
qrHtml += ";";
|
|
19614
|
+
qrHtml += '"/>';
|
|
19615
|
+
}
|
|
19616
|
+
qrHtml += "</tr>";
|
|
19617
|
+
}
|
|
19618
|
+
qrHtml += "</tbody>";
|
|
19619
|
+
qrHtml += "</table>";
|
|
19620
|
+
return qrHtml;
|
|
19621
|
+
};
|
|
19622
|
+
_this.createSvgTag = function(cellSize, margin, alt, title) {
|
|
19623
|
+
let opts = {};
|
|
19624
|
+
if (typeof arguments[0] == "object") {
|
|
19625
|
+
opts = arguments[0];
|
|
19626
|
+
cellSize = opts.cellSize;
|
|
19627
|
+
margin = opts.margin;
|
|
19628
|
+
alt = opts.alt;
|
|
19629
|
+
title = opts.title;
|
|
19630
|
+
}
|
|
19631
|
+
cellSize = cellSize || 2;
|
|
19632
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
19633
|
+
alt = typeof alt === "string" ? { text: alt } : alt || {};
|
|
19634
|
+
alt.text = alt.text || null;
|
|
19635
|
+
alt.id = alt.text ? alt.id || "qrcode-description" : null;
|
|
19636
|
+
title = typeof title === "string" ? { text: title } : title || {};
|
|
19637
|
+
title.text = title.text || null;
|
|
19638
|
+
title.id = title.text ? title.id || "qrcode-title" : null;
|
|
19639
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
19640
|
+
let c2, mc, r2, mr, qrSvg = "", rect;
|
|
19641
|
+
rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
|
|
19642
|
+
qrSvg += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"';
|
|
19643
|
+
qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : "";
|
|
19644
|
+
qrSvg += ' viewBox="0 0 ' + size + " " + size + '" ';
|
|
19645
|
+
qrSvg += ' preserveAspectRatio="xMinYMin meet"';
|
|
19646
|
+
qrSvg += title.text || alt.text ? ' role="img" aria-labelledby="' + escapeXml([title.id, alt.id].join(" ").trim()) + '"' : "";
|
|
19647
|
+
qrSvg += ">";
|
|
19648
|
+
qrSvg += title.text ? '<title id="' + escapeXml(title.id) + '">' + escapeXml(title.text) + "</title>" : "";
|
|
19649
|
+
qrSvg += alt.text ? '<description id="' + escapeXml(alt.id) + '">' + escapeXml(alt.text) + "</description>" : "";
|
|
19650
|
+
qrSvg += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>';
|
|
19651
|
+
qrSvg += '<path d="';
|
|
19652
|
+
for (r2 = 0; r2 < _this.getModuleCount(); r2 += 1) {
|
|
19653
|
+
mr = r2 * cellSize + margin;
|
|
19654
|
+
for (c2 = 0; c2 < _this.getModuleCount(); c2 += 1) {
|
|
19655
|
+
if (_this.isDark(r2, c2)) {
|
|
19656
|
+
mc = c2 * cellSize + margin;
|
|
19657
|
+
qrSvg += "M" + mc + "," + mr + rect;
|
|
19658
|
+
}
|
|
19659
|
+
}
|
|
19660
|
+
}
|
|
19661
|
+
qrSvg += '" stroke="transparent" fill="black"/>';
|
|
19662
|
+
qrSvg += "</svg>";
|
|
19663
|
+
return qrSvg;
|
|
19664
|
+
};
|
|
19665
|
+
_this.createDataURL = function(cellSize, margin) {
|
|
19666
|
+
cellSize = cellSize || 2;
|
|
19667
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
19668
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
19669
|
+
const min = margin;
|
|
19670
|
+
const max = size - margin;
|
|
19671
|
+
return createDataURL(size, size, function(x, y) {
|
|
19672
|
+
if (min <= x && x < max && min <= y && y < max) {
|
|
19673
|
+
const c2 = Math.floor((x - min) / cellSize);
|
|
19674
|
+
const r2 = Math.floor((y - min) / cellSize);
|
|
19675
|
+
return _this.isDark(r2, c2) ? 0 : 1;
|
|
19676
|
+
} else {
|
|
19677
|
+
return 1;
|
|
19678
|
+
}
|
|
19679
|
+
});
|
|
19680
|
+
};
|
|
19681
|
+
_this.createImgTag = function(cellSize, margin, alt) {
|
|
19682
|
+
cellSize = cellSize || 2;
|
|
19683
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
19684
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
19685
|
+
let img = "";
|
|
19686
|
+
img += "<img";
|
|
19687
|
+
img += ' src="';
|
|
19688
|
+
img += _this.createDataURL(cellSize, margin);
|
|
19689
|
+
img += '"';
|
|
19690
|
+
img += ' width="';
|
|
19691
|
+
img += size;
|
|
19692
|
+
img += '"';
|
|
19693
|
+
img += ' height="';
|
|
19694
|
+
img += size;
|
|
19695
|
+
img += '"';
|
|
19696
|
+
if (alt) {
|
|
19697
|
+
img += ' alt="';
|
|
19698
|
+
img += escapeXml(alt);
|
|
19699
|
+
img += '"';
|
|
19700
|
+
}
|
|
19701
|
+
img += "/>";
|
|
19702
|
+
return img;
|
|
19703
|
+
};
|
|
19704
|
+
const escapeXml = /* @__PURE__ */ __name(function(s2) {
|
|
19705
|
+
let escaped = "";
|
|
19706
|
+
for (let i3 = 0; i3 < s2.length; i3 += 1) {
|
|
19707
|
+
const c2 = s2.charAt(i3);
|
|
19708
|
+
switch (c2) {
|
|
19709
|
+
case "<":
|
|
19710
|
+
escaped += "<";
|
|
19711
|
+
break;
|
|
19712
|
+
case ">":
|
|
19713
|
+
escaped += ">";
|
|
19714
|
+
break;
|
|
19715
|
+
case "&":
|
|
19716
|
+
escaped += "&";
|
|
19717
|
+
break;
|
|
19718
|
+
case '"':
|
|
19719
|
+
escaped += """;
|
|
19720
|
+
break;
|
|
19721
|
+
default:
|
|
19722
|
+
escaped += c2;
|
|
19723
|
+
break;
|
|
19724
|
+
}
|
|
19725
|
+
}
|
|
19726
|
+
return escaped;
|
|
19727
|
+
}, "escapeXml");
|
|
19728
|
+
const _createHalfASCII = /* @__PURE__ */ __name(function(margin) {
|
|
19729
|
+
const cellSize = 1;
|
|
19730
|
+
margin = typeof margin == "undefined" ? cellSize * 2 : margin;
|
|
19731
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
19732
|
+
const min = margin;
|
|
19733
|
+
const max = size - margin;
|
|
19734
|
+
let y, x, r1, r2, p;
|
|
19735
|
+
const blocks = {
|
|
19736
|
+
"\u2588\u2588": "\u2588",
|
|
19737
|
+
"\u2588 ": "\u2580",
|
|
19738
|
+
" \u2588": "\u2584",
|
|
19739
|
+
" ": " "
|
|
19740
|
+
};
|
|
19741
|
+
const blocksLastLineNoMargin = {
|
|
19742
|
+
"\u2588\u2588": "\u2580",
|
|
19743
|
+
"\u2588 ": "\u2580",
|
|
19744
|
+
" \u2588": " ",
|
|
19745
|
+
" ": " "
|
|
19746
|
+
};
|
|
19747
|
+
let ascii = "";
|
|
19748
|
+
for (y = 0; y < size; y += 2) {
|
|
19749
|
+
r1 = Math.floor((y - min) / cellSize);
|
|
19750
|
+
r2 = Math.floor((y + 1 - min) / cellSize);
|
|
19751
|
+
for (x = 0; x < size; x += 1) {
|
|
19752
|
+
p = "\u2588";
|
|
19753
|
+
if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {
|
|
19754
|
+
p = " ";
|
|
19755
|
+
}
|
|
19756
|
+
if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
|
|
19757
|
+
p += " ";
|
|
19758
|
+
} else {
|
|
19759
|
+
p += "\u2588";
|
|
19760
|
+
}
|
|
19761
|
+
ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
|
|
19762
|
+
}
|
|
19763
|
+
ascii += "\n";
|
|
19764
|
+
}
|
|
19765
|
+
if (size % 2 && margin > 0) {
|
|
19766
|
+
return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("\u2580");
|
|
19767
|
+
}
|
|
19768
|
+
return ascii.substring(0, ascii.length - 1);
|
|
19769
|
+
}, "_createHalfASCII");
|
|
19770
|
+
_this.createASCII = function(cellSize, margin) {
|
|
19771
|
+
cellSize = cellSize || 1;
|
|
19772
|
+
if (cellSize < 2) {
|
|
19773
|
+
return _createHalfASCII(margin);
|
|
19774
|
+
}
|
|
19775
|
+
cellSize -= 1;
|
|
19776
|
+
margin = typeof margin == "undefined" ? cellSize * 2 : margin;
|
|
19777
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
19778
|
+
const min = margin;
|
|
19779
|
+
const max = size - margin;
|
|
19780
|
+
let y, x, r2, p;
|
|
19781
|
+
const white = Array(cellSize + 1).join("\u2588\u2588");
|
|
19782
|
+
const black = Array(cellSize + 1).join(" ");
|
|
19783
|
+
let ascii = "";
|
|
19784
|
+
let line7 = "";
|
|
19785
|
+
for (y = 0; y < size; y += 1) {
|
|
19786
|
+
r2 = Math.floor((y - min) / cellSize);
|
|
19787
|
+
line7 = "";
|
|
19788
|
+
for (x = 0; x < size; x += 1) {
|
|
19789
|
+
p = 1;
|
|
19790
|
+
if (min <= x && x < max && min <= y && y < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
|
|
19791
|
+
p = 0;
|
|
19792
|
+
}
|
|
19793
|
+
line7 += p ? white : black;
|
|
19794
|
+
}
|
|
19795
|
+
for (r2 = 0; r2 < cellSize; r2 += 1) {
|
|
19796
|
+
ascii += line7 + "\n";
|
|
19797
|
+
}
|
|
19798
|
+
}
|
|
19799
|
+
return ascii.substring(0, ascii.length - 1);
|
|
19800
|
+
};
|
|
19801
|
+
_this.renderTo2dContext = function(context, cellSize) {
|
|
19802
|
+
cellSize = cellSize || 2;
|
|
19803
|
+
const length = _this.getModuleCount();
|
|
19804
|
+
for (let row2 = 0; row2 < length; row2++) {
|
|
19805
|
+
for (let col = 0; col < length; col++) {
|
|
19806
|
+
context.fillStyle = _this.isDark(row2, col) ? "black" : "white";
|
|
19807
|
+
context.fillRect(col * cellSize, row2 * cellSize, cellSize, cellSize);
|
|
19808
|
+
}
|
|
19809
|
+
}
|
|
19810
|
+
};
|
|
19811
|
+
return _this;
|
|
19812
|
+
}, "qrcode");
|
|
19813
|
+
qrcode.stringToBytes = function(s2) {
|
|
19814
|
+
const bytes = [];
|
|
19815
|
+
for (let i3 = 0; i3 < s2.length; i3 += 1) {
|
|
19816
|
+
const c2 = s2.charCodeAt(i3);
|
|
19817
|
+
bytes.push(c2 & 255);
|
|
19818
|
+
}
|
|
19819
|
+
return bytes;
|
|
19820
|
+
};
|
|
19821
|
+
qrcode.createStringToBytes = function(unicodeData, numChars) {
|
|
19822
|
+
const unicodeMap = (function() {
|
|
19823
|
+
const bin = base64DecodeInputStream(unicodeData);
|
|
19824
|
+
const read3 = /* @__PURE__ */ __name(function() {
|
|
19825
|
+
const b = bin.read();
|
|
19826
|
+
if (b == -1) throw "eof";
|
|
19827
|
+
return b;
|
|
19828
|
+
}, "read");
|
|
19829
|
+
let count5 = 0;
|
|
19830
|
+
const unicodeMap2 = {};
|
|
19831
|
+
while (true) {
|
|
19832
|
+
const b0 = bin.read();
|
|
19833
|
+
if (b0 == -1) break;
|
|
19834
|
+
const b1 = read3();
|
|
19835
|
+
const b2 = read3();
|
|
19836
|
+
const b3 = read3();
|
|
19837
|
+
const k = String.fromCharCode(b0 << 8 | b1);
|
|
19838
|
+
const v = b2 << 8 | b3;
|
|
19839
|
+
unicodeMap2[k] = v;
|
|
19840
|
+
count5 += 1;
|
|
19841
|
+
}
|
|
19842
|
+
if (count5 != numChars) {
|
|
19843
|
+
throw count5 + " != " + numChars;
|
|
19844
|
+
}
|
|
19845
|
+
return unicodeMap2;
|
|
19846
|
+
})();
|
|
19847
|
+
const unknownChar = "?".charCodeAt(0);
|
|
19848
|
+
return function(s2) {
|
|
19849
|
+
const bytes = [];
|
|
19850
|
+
for (let i3 = 0; i3 < s2.length; i3 += 1) {
|
|
19851
|
+
const c2 = s2.charCodeAt(i3);
|
|
19852
|
+
if (c2 < 128) {
|
|
19853
|
+
bytes.push(c2);
|
|
19854
|
+
} else {
|
|
19855
|
+
const b = unicodeMap[s2.charAt(i3)];
|
|
19856
|
+
if (typeof b == "number") {
|
|
19857
|
+
if ((b & 255) == b) {
|
|
19858
|
+
bytes.push(b);
|
|
19859
|
+
} else {
|
|
19860
|
+
bytes.push(b >>> 8);
|
|
19861
|
+
bytes.push(b & 255);
|
|
19862
|
+
}
|
|
19863
|
+
} else {
|
|
19864
|
+
bytes.push(unknownChar);
|
|
19865
|
+
}
|
|
19866
|
+
}
|
|
19867
|
+
}
|
|
19868
|
+
return bytes;
|
|
19869
|
+
};
|
|
19870
|
+
};
|
|
19871
|
+
var QRMode = {
|
|
19872
|
+
MODE_NUMBER: 1 << 0,
|
|
19873
|
+
MODE_ALPHA_NUM: 1 << 1,
|
|
19874
|
+
MODE_8BIT_BYTE: 1 << 2,
|
|
19875
|
+
MODE_KANJI: 1 << 3
|
|
19876
|
+
};
|
|
19877
|
+
var QRErrorCorrectionLevel = {
|
|
19878
|
+
L: 1,
|
|
19879
|
+
M: 0,
|
|
19880
|
+
Q: 3,
|
|
19881
|
+
H: 2
|
|
19882
|
+
};
|
|
19883
|
+
var QRMaskPattern = {
|
|
19884
|
+
PATTERN000: 0,
|
|
19885
|
+
PATTERN001: 1,
|
|
19886
|
+
PATTERN010: 2,
|
|
19887
|
+
PATTERN011: 3,
|
|
19888
|
+
PATTERN100: 4,
|
|
19889
|
+
PATTERN101: 5,
|
|
19890
|
+
PATTERN110: 6,
|
|
19891
|
+
PATTERN111: 7
|
|
19892
|
+
};
|
|
19893
|
+
var QRUtil = (function() {
|
|
19894
|
+
const PATTERN_POSITION_TABLE = [
|
|
19895
|
+
[],
|
|
19896
|
+
[6, 18],
|
|
19897
|
+
[6, 22],
|
|
19898
|
+
[6, 26],
|
|
19899
|
+
[6, 30],
|
|
19900
|
+
[6, 34],
|
|
19901
|
+
[6, 22, 38],
|
|
19902
|
+
[6, 24, 42],
|
|
19903
|
+
[6, 26, 46],
|
|
19904
|
+
[6, 28, 50],
|
|
19905
|
+
[6, 30, 54],
|
|
19906
|
+
[6, 32, 58],
|
|
19907
|
+
[6, 34, 62],
|
|
19908
|
+
[6, 26, 46, 66],
|
|
19909
|
+
[6, 26, 48, 70],
|
|
19910
|
+
[6, 26, 50, 74],
|
|
19911
|
+
[6, 30, 54, 78],
|
|
19912
|
+
[6, 30, 56, 82],
|
|
19913
|
+
[6, 30, 58, 86],
|
|
19914
|
+
[6, 34, 62, 90],
|
|
19915
|
+
[6, 28, 50, 72, 94],
|
|
19916
|
+
[6, 26, 50, 74, 98],
|
|
19917
|
+
[6, 30, 54, 78, 102],
|
|
19918
|
+
[6, 28, 54, 80, 106],
|
|
19919
|
+
[6, 32, 58, 84, 110],
|
|
19920
|
+
[6, 30, 58, 86, 114],
|
|
19921
|
+
[6, 34, 62, 90, 118],
|
|
19922
|
+
[6, 26, 50, 74, 98, 122],
|
|
19923
|
+
[6, 30, 54, 78, 102, 126],
|
|
19924
|
+
[6, 26, 52, 78, 104, 130],
|
|
19925
|
+
[6, 30, 56, 82, 108, 134],
|
|
19926
|
+
[6, 34, 60, 86, 112, 138],
|
|
19927
|
+
[6, 30, 58, 86, 114, 142],
|
|
19928
|
+
[6, 34, 62, 90, 118, 146],
|
|
19929
|
+
[6, 30, 54, 78, 102, 126, 150],
|
|
19930
|
+
[6, 24, 50, 76, 102, 128, 154],
|
|
19931
|
+
[6, 28, 54, 80, 106, 132, 158],
|
|
19932
|
+
[6, 32, 58, 84, 110, 136, 162],
|
|
19933
|
+
[6, 26, 54, 82, 110, 138, 166],
|
|
19934
|
+
[6, 30, 58, 86, 114, 142, 170]
|
|
19935
|
+
];
|
|
19936
|
+
const G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
|
|
19937
|
+
const G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
|
|
19938
|
+
const G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
|
|
19939
|
+
const _this = {};
|
|
19940
|
+
const getBCHDigit = /* @__PURE__ */ __name(function(data) {
|
|
19941
|
+
let digit = 0;
|
|
19942
|
+
while (data != 0) {
|
|
19943
|
+
digit += 1;
|
|
19944
|
+
data >>>= 1;
|
|
19945
|
+
}
|
|
19946
|
+
return digit;
|
|
19947
|
+
}, "getBCHDigit");
|
|
19948
|
+
_this.getBCHTypeInfo = function(data) {
|
|
19949
|
+
let d2 = data << 10;
|
|
19950
|
+
while (getBCHDigit(d2) - getBCHDigit(G15) >= 0) {
|
|
19951
|
+
d2 ^= G15 << getBCHDigit(d2) - getBCHDigit(G15);
|
|
19952
|
+
}
|
|
19953
|
+
return (data << 10 | d2) ^ G15_MASK;
|
|
19954
|
+
};
|
|
19955
|
+
_this.getBCHTypeNumber = function(data) {
|
|
19956
|
+
let d2 = data << 12;
|
|
19957
|
+
while (getBCHDigit(d2) - getBCHDigit(G18) >= 0) {
|
|
19958
|
+
d2 ^= G18 << getBCHDigit(d2) - getBCHDigit(G18);
|
|
19959
|
+
}
|
|
19960
|
+
return data << 12 | d2;
|
|
19961
|
+
};
|
|
19962
|
+
_this.getPatternPosition = function(typeNumber) {
|
|
19963
|
+
return PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
19964
|
+
};
|
|
19965
|
+
_this.getMaskFunction = function(maskPattern) {
|
|
19966
|
+
switch (maskPattern) {
|
|
19967
|
+
case QRMaskPattern.PATTERN000:
|
|
19968
|
+
return function(i3, j) {
|
|
19969
|
+
return (i3 + j) % 2 == 0;
|
|
19970
|
+
};
|
|
19971
|
+
case QRMaskPattern.PATTERN001:
|
|
19972
|
+
return function(i3, j) {
|
|
19973
|
+
return i3 % 2 == 0;
|
|
19974
|
+
};
|
|
19975
|
+
case QRMaskPattern.PATTERN010:
|
|
19976
|
+
return function(i3, j) {
|
|
19977
|
+
return j % 3 == 0;
|
|
19978
|
+
};
|
|
19979
|
+
case QRMaskPattern.PATTERN011:
|
|
19980
|
+
return function(i3, j) {
|
|
19981
|
+
return (i3 + j) % 3 == 0;
|
|
19982
|
+
};
|
|
19983
|
+
case QRMaskPattern.PATTERN100:
|
|
19984
|
+
return function(i3, j) {
|
|
19985
|
+
return (Math.floor(i3 / 2) + Math.floor(j / 3)) % 2 == 0;
|
|
19986
|
+
};
|
|
19987
|
+
case QRMaskPattern.PATTERN101:
|
|
19988
|
+
return function(i3, j) {
|
|
19989
|
+
return i3 * j % 2 + i3 * j % 3 == 0;
|
|
19990
|
+
};
|
|
19991
|
+
case QRMaskPattern.PATTERN110:
|
|
19992
|
+
return function(i3, j) {
|
|
19993
|
+
return (i3 * j % 2 + i3 * j % 3) % 2 == 0;
|
|
19994
|
+
};
|
|
19995
|
+
case QRMaskPattern.PATTERN111:
|
|
19996
|
+
return function(i3, j) {
|
|
19997
|
+
return (i3 * j % 3 + (i3 + j) % 2) % 2 == 0;
|
|
19998
|
+
};
|
|
19999
|
+
default:
|
|
20000
|
+
throw "bad maskPattern:" + maskPattern;
|
|
20001
|
+
}
|
|
20002
|
+
};
|
|
20003
|
+
_this.getErrorCorrectPolynomial = function(errorCorrectLength) {
|
|
20004
|
+
let a2 = qrPolynomial([1], 0);
|
|
20005
|
+
for (let i3 = 0; i3 < errorCorrectLength; i3 += 1) {
|
|
20006
|
+
a2 = a2.multiply(qrPolynomial([1, QRMath.gexp(i3)], 0));
|
|
20007
|
+
}
|
|
20008
|
+
return a2;
|
|
20009
|
+
};
|
|
20010
|
+
_this.getLengthInBits = function(mode, type) {
|
|
20011
|
+
if (1 <= type && type < 10) {
|
|
20012
|
+
switch (mode) {
|
|
20013
|
+
case QRMode.MODE_NUMBER:
|
|
20014
|
+
return 10;
|
|
20015
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
20016
|
+
return 9;
|
|
20017
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
20018
|
+
return 8;
|
|
20019
|
+
case QRMode.MODE_KANJI:
|
|
20020
|
+
return 8;
|
|
20021
|
+
default:
|
|
20022
|
+
throw "mode:" + mode;
|
|
20023
|
+
}
|
|
20024
|
+
} else if (type < 27) {
|
|
20025
|
+
switch (mode) {
|
|
20026
|
+
case QRMode.MODE_NUMBER:
|
|
20027
|
+
return 12;
|
|
20028
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
20029
|
+
return 11;
|
|
20030
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
20031
|
+
return 16;
|
|
20032
|
+
case QRMode.MODE_KANJI:
|
|
20033
|
+
return 10;
|
|
20034
|
+
default:
|
|
20035
|
+
throw "mode:" + mode;
|
|
20036
|
+
}
|
|
20037
|
+
} else if (type < 41) {
|
|
20038
|
+
switch (mode) {
|
|
20039
|
+
case QRMode.MODE_NUMBER:
|
|
20040
|
+
return 14;
|
|
20041
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
20042
|
+
return 13;
|
|
20043
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
20044
|
+
return 16;
|
|
20045
|
+
case QRMode.MODE_KANJI:
|
|
20046
|
+
return 12;
|
|
20047
|
+
default:
|
|
20048
|
+
throw "mode:" + mode;
|
|
20049
|
+
}
|
|
20050
|
+
} else {
|
|
20051
|
+
throw "type:" + type;
|
|
20052
|
+
}
|
|
20053
|
+
};
|
|
20054
|
+
_this.getLostPoint = function(qrcode2) {
|
|
20055
|
+
const moduleCount = qrcode2.getModuleCount();
|
|
20056
|
+
let lostPoint = 0;
|
|
20057
|
+
for (let row2 = 0; row2 < moduleCount; row2 += 1) {
|
|
20058
|
+
for (let col = 0; col < moduleCount; col += 1) {
|
|
20059
|
+
let sameCount = 0;
|
|
20060
|
+
const dark = qrcode2.isDark(row2, col);
|
|
20061
|
+
for (let r2 = -1; r2 <= 1; r2 += 1) {
|
|
20062
|
+
if (row2 + r2 < 0 || moduleCount <= row2 + r2) {
|
|
20063
|
+
continue;
|
|
20064
|
+
}
|
|
20065
|
+
for (let c2 = -1; c2 <= 1; c2 += 1) {
|
|
20066
|
+
if (col + c2 < 0 || moduleCount <= col + c2) {
|
|
20067
|
+
continue;
|
|
20068
|
+
}
|
|
20069
|
+
if (r2 == 0 && c2 == 0) {
|
|
20070
|
+
continue;
|
|
20071
|
+
}
|
|
20072
|
+
if (dark == qrcode2.isDark(row2 + r2, col + c2)) {
|
|
20073
|
+
sameCount += 1;
|
|
20074
|
+
}
|
|
20075
|
+
}
|
|
20076
|
+
}
|
|
20077
|
+
if (sameCount > 5) {
|
|
20078
|
+
lostPoint += 3 + sameCount - 5;
|
|
20079
|
+
}
|
|
20080
|
+
}
|
|
20081
|
+
}
|
|
20082
|
+
;
|
|
20083
|
+
for (let row2 = 0; row2 < moduleCount - 1; row2 += 1) {
|
|
20084
|
+
for (let col = 0; col < moduleCount - 1; col += 1) {
|
|
20085
|
+
let count5 = 0;
|
|
20086
|
+
if (qrcode2.isDark(row2, col)) count5 += 1;
|
|
20087
|
+
if (qrcode2.isDark(row2 + 1, col)) count5 += 1;
|
|
20088
|
+
if (qrcode2.isDark(row2, col + 1)) count5 += 1;
|
|
20089
|
+
if (qrcode2.isDark(row2 + 1, col + 1)) count5 += 1;
|
|
20090
|
+
if (count5 == 0 || count5 == 4) {
|
|
20091
|
+
lostPoint += 3;
|
|
20092
|
+
}
|
|
20093
|
+
}
|
|
20094
|
+
}
|
|
20095
|
+
for (let row2 = 0; row2 < moduleCount; row2 += 1) {
|
|
20096
|
+
for (let col = 0; col < moduleCount - 6; col += 1) {
|
|
20097
|
+
if (qrcode2.isDark(row2, col) && !qrcode2.isDark(row2, col + 1) && qrcode2.isDark(row2, col + 2) && qrcode2.isDark(row2, col + 3) && qrcode2.isDark(row2, col + 4) && !qrcode2.isDark(row2, col + 5) && qrcode2.isDark(row2, col + 6)) {
|
|
20098
|
+
lostPoint += 40;
|
|
20099
|
+
}
|
|
20100
|
+
}
|
|
20101
|
+
}
|
|
20102
|
+
for (let col = 0; col < moduleCount; col += 1) {
|
|
20103
|
+
for (let row2 = 0; row2 < moduleCount - 6; row2 += 1) {
|
|
20104
|
+
if (qrcode2.isDark(row2, col) && !qrcode2.isDark(row2 + 1, col) && qrcode2.isDark(row2 + 2, col) && qrcode2.isDark(row2 + 3, col) && qrcode2.isDark(row2 + 4, col) && !qrcode2.isDark(row2 + 5, col) && qrcode2.isDark(row2 + 6, col)) {
|
|
20105
|
+
lostPoint += 40;
|
|
20106
|
+
}
|
|
20107
|
+
}
|
|
20108
|
+
}
|
|
20109
|
+
let darkCount = 0;
|
|
20110
|
+
for (let col = 0; col < moduleCount; col += 1) {
|
|
20111
|
+
for (let row2 = 0; row2 < moduleCount; row2 += 1) {
|
|
20112
|
+
if (qrcode2.isDark(row2, col)) {
|
|
20113
|
+
darkCount += 1;
|
|
20114
|
+
}
|
|
20115
|
+
}
|
|
20116
|
+
}
|
|
20117
|
+
const ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
|
|
20118
|
+
lostPoint += ratio * 10;
|
|
20119
|
+
return lostPoint;
|
|
20120
|
+
};
|
|
20121
|
+
return _this;
|
|
20122
|
+
})();
|
|
20123
|
+
var QRMath = (function() {
|
|
20124
|
+
const EXP_TABLE = new Array(256);
|
|
20125
|
+
const LOG_TABLE = new Array(256);
|
|
20126
|
+
for (let i3 = 0; i3 < 8; i3 += 1) {
|
|
20127
|
+
EXP_TABLE[i3] = 1 << i3;
|
|
20128
|
+
}
|
|
20129
|
+
for (let i3 = 8; i3 < 256; i3 += 1) {
|
|
20130
|
+
EXP_TABLE[i3] = EXP_TABLE[i3 - 4] ^ EXP_TABLE[i3 - 5] ^ EXP_TABLE[i3 - 6] ^ EXP_TABLE[i3 - 8];
|
|
20131
|
+
}
|
|
20132
|
+
for (let i3 = 0; i3 < 255; i3 += 1) {
|
|
20133
|
+
LOG_TABLE[EXP_TABLE[i3]] = i3;
|
|
20134
|
+
}
|
|
20135
|
+
const _this = {};
|
|
20136
|
+
_this.glog = function(n2) {
|
|
20137
|
+
if (n2 < 1) {
|
|
20138
|
+
throw "glog(" + n2 + ")";
|
|
20139
|
+
}
|
|
20140
|
+
return LOG_TABLE[n2];
|
|
20141
|
+
};
|
|
20142
|
+
_this.gexp = function(n2) {
|
|
20143
|
+
while (n2 < 0) {
|
|
20144
|
+
n2 += 255;
|
|
20145
|
+
}
|
|
20146
|
+
while (n2 >= 256) {
|
|
20147
|
+
n2 -= 255;
|
|
20148
|
+
}
|
|
20149
|
+
return EXP_TABLE[n2];
|
|
20150
|
+
};
|
|
20151
|
+
return _this;
|
|
20152
|
+
})();
|
|
20153
|
+
var qrPolynomial = /* @__PURE__ */ __name(function(num, shift) {
|
|
20154
|
+
if (typeof num.length == "undefined") {
|
|
20155
|
+
throw num.length + "/" + shift;
|
|
20156
|
+
}
|
|
20157
|
+
const _num = (function() {
|
|
20158
|
+
let offset = 0;
|
|
20159
|
+
while (offset < num.length && num[offset] == 0) {
|
|
20160
|
+
offset += 1;
|
|
20161
|
+
}
|
|
20162
|
+
const _num2 = new Array(num.length - offset + shift);
|
|
20163
|
+
for (let i3 = 0; i3 < num.length - offset; i3 += 1) {
|
|
20164
|
+
_num2[i3] = num[i3 + offset];
|
|
20165
|
+
}
|
|
20166
|
+
return _num2;
|
|
20167
|
+
})();
|
|
20168
|
+
const _this = {};
|
|
20169
|
+
_this.getAt = function(index) {
|
|
20170
|
+
return _num[index];
|
|
20171
|
+
};
|
|
20172
|
+
_this.getLength = function() {
|
|
20173
|
+
return _num.length;
|
|
20174
|
+
};
|
|
20175
|
+
_this.multiply = function(e) {
|
|
20176
|
+
const num2 = new Array(_this.getLength() + e.getLength() - 1);
|
|
20177
|
+
for (let i3 = 0; i3 < _this.getLength(); i3 += 1) {
|
|
20178
|
+
for (let j = 0; j < e.getLength(); j += 1) {
|
|
20179
|
+
num2[i3 + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i3)) + QRMath.glog(e.getAt(j)));
|
|
20180
|
+
}
|
|
20181
|
+
}
|
|
20182
|
+
return qrPolynomial(num2, 0);
|
|
20183
|
+
};
|
|
20184
|
+
_this.mod = function(e) {
|
|
20185
|
+
if (_this.getLength() - e.getLength() < 0) {
|
|
20186
|
+
return _this;
|
|
20187
|
+
}
|
|
20188
|
+
const ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
|
|
20189
|
+
const num2 = new Array(_this.getLength());
|
|
20190
|
+
for (let i3 = 0; i3 < _this.getLength(); i3 += 1) {
|
|
20191
|
+
num2[i3] = _this.getAt(i3);
|
|
20192
|
+
}
|
|
20193
|
+
for (let i3 = 0; i3 < e.getLength(); i3 += 1) {
|
|
20194
|
+
num2[i3] ^= QRMath.gexp(QRMath.glog(e.getAt(i3)) + ratio);
|
|
20195
|
+
}
|
|
20196
|
+
return qrPolynomial(num2, 0).mod(e);
|
|
20197
|
+
};
|
|
20198
|
+
return _this;
|
|
20199
|
+
}, "qrPolynomial");
|
|
20200
|
+
var QRRSBlock = (function() {
|
|
20201
|
+
const RS_BLOCK_TABLE = [
|
|
20202
|
+
// L
|
|
20203
|
+
// M
|
|
20204
|
+
// Q
|
|
20205
|
+
// H
|
|
20206
|
+
// 1
|
|
20207
|
+
[1, 26, 19],
|
|
20208
|
+
[1, 26, 16],
|
|
20209
|
+
[1, 26, 13],
|
|
20210
|
+
[1, 26, 9],
|
|
20211
|
+
// 2
|
|
20212
|
+
[1, 44, 34],
|
|
20213
|
+
[1, 44, 28],
|
|
20214
|
+
[1, 44, 22],
|
|
20215
|
+
[1, 44, 16],
|
|
20216
|
+
// 3
|
|
20217
|
+
[1, 70, 55],
|
|
20218
|
+
[1, 70, 44],
|
|
20219
|
+
[2, 35, 17],
|
|
20220
|
+
[2, 35, 13],
|
|
20221
|
+
// 4
|
|
20222
|
+
[1, 100, 80],
|
|
20223
|
+
[2, 50, 32],
|
|
20224
|
+
[2, 50, 24],
|
|
20225
|
+
[4, 25, 9],
|
|
20226
|
+
// 5
|
|
20227
|
+
[1, 134, 108],
|
|
20228
|
+
[2, 67, 43],
|
|
20229
|
+
[2, 33, 15, 2, 34, 16],
|
|
20230
|
+
[2, 33, 11, 2, 34, 12],
|
|
20231
|
+
// 6
|
|
20232
|
+
[2, 86, 68],
|
|
20233
|
+
[4, 43, 27],
|
|
20234
|
+
[4, 43, 19],
|
|
20235
|
+
[4, 43, 15],
|
|
20236
|
+
// 7
|
|
20237
|
+
[2, 98, 78],
|
|
20238
|
+
[4, 49, 31],
|
|
20239
|
+
[2, 32, 14, 4, 33, 15],
|
|
20240
|
+
[4, 39, 13, 1, 40, 14],
|
|
20241
|
+
// 8
|
|
20242
|
+
[2, 121, 97],
|
|
20243
|
+
[2, 60, 38, 2, 61, 39],
|
|
20244
|
+
[4, 40, 18, 2, 41, 19],
|
|
20245
|
+
[4, 40, 14, 2, 41, 15],
|
|
20246
|
+
// 9
|
|
20247
|
+
[2, 146, 116],
|
|
20248
|
+
[3, 58, 36, 2, 59, 37],
|
|
20249
|
+
[4, 36, 16, 4, 37, 17],
|
|
20250
|
+
[4, 36, 12, 4, 37, 13],
|
|
20251
|
+
// 10
|
|
20252
|
+
[2, 86, 68, 2, 87, 69],
|
|
20253
|
+
[4, 69, 43, 1, 70, 44],
|
|
20254
|
+
[6, 43, 19, 2, 44, 20],
|
|
20255
|
+
[6, 43, 15, 2, 44, 16],
|
|
20256
|
+
// 11
|
|
20257
|
+
[4, 101, 81],
|
|
20258
|
+
[1, 80, 50, 4, 81, 51],
|
|
20259
|
+
[4, 50, 22, 4, 51, 23],
|
|
20260
|
+
[3, 36, 12, 8, 37, 13],
|
|
20261
|
+
// 12
|
|
20262
|
+
[2, 116, 92, 2, 117, 93],
|
|
20263
|
+
[6, 58, 36, 2, 59, 37],
|
|
20264
|
+
[4, 46, 20, 6, 47, 21],
|
|
20265
|
+
[7, 42, 14, 4, 43, 15],
|
|
20266
|
+
// 13
|
|
20267
|
+
[4, 133, 107],
|
|
20268
|
+
[8, 59, 37, 1, 60, 38],
|
|
20269
|
+
[8, 44, 20, 4, 45, 21],
|
|
20270
|
+
[12, 33, 11, 4, 34, 12],
|
|
20271
|
+
// 14
|
|
20272
|
+
[3, 145, 115, 1, 146, 116],
|
|
20273
|
+
[4, 64, 40, 5, 65, 41],
|
|
20274
|
+
[11, 36, 16, 5, 37, 17],
|
|
20275
|
+
[11, 36, 12, 5, 37, 13],
|
|
20276
|
+
// 15
|
|
20277
|
+
[5, 109, 87, 1, 110, 88],
|
|
20278
|
+
[5, 65, 41, 5, 66, 42],
|
|
20279
|
+
[5, 54, 24, 7, 55, 25],
|
|
20280
|
+
[11, 36, 12, 7, 37, 13],
|
|
20281
|
+
// 16
|
|
20282
|
+
[5, 122, 98, 1, 123, 99],
|
|
20283
|
+
[7, 73, 45, 3, 74, 46],
|
|
20284
|
+
[15, 43, 19, 2, 44, 20],
|
|
20285
|
+
[3, 45, 15, 13, 46, 16],
|
|
20286
|
+
// 17
|
|
20287
|
+
[1, 135, 107, 5, 136, 108],
|
|
20288
|
+
[10, 74, 46, 1, 75, 47],
|
|
20289
|
+
[1, 50, 22, 15, 51, 23],
|
|
20290
|
+
[2, 42, 14, 17, 43, 15],
|
|
20291
|
+
// 18
|
|
20292
|
+
[5, 150, 120, 1, 151, 121],
|
|
20293
|
+
[9, 69, 43, 4, 70, 44],
|
|
20294
|
+
[17, 50, 22, 1, 51, 23],
|
|
20295
|
+
[2, 42, 14, 19, 43, 15],
|
|
20296
|
+
// 19
|
|
20297
|
+
[3, 141, 113, 4, 142, 114],
|
|
20298
|
+
[3, 70, 44, 11, 71, 45],
|
|
20299
|
+
[17, 47, 21, 4, 48, 22],
|
|
20300
|
+
[9, 39, 13, 16, 40, 14],
|
|
20301
|
+
// 20
|
|
20302
|
+
[3, 135, 107, 5, 136, 108],
|
|
20303
|
+
[3, 67, 41, 13, 68, 42],
|
|
20304
|
+
[15, 54, 24, 5, 55, 25],
|
|
20305
|
+
[15, 43, 15, 10, 44, 16],
|
|
20306
|
+
// 21
|
|
20307
|
+
[4, 144, 116, 4, 145, 117],
|
|
20308
|
+
[17, 68, 42],
|
|
20309
|
+
[17, 50, 22, 6, 51, 23],
|
|
20310
|
+
[19, 46, 16, 6, 47, 17],
|
|
20311
|
+
// 22
|
|
20312
|
+
[2, 139, 111, 7, 140, 112],
|
|
20313
|
+
[17, 74, 46],
|
|
20314
|
+
[7, 54, 24, 16, 55, 25],
|
|
20315
|
+
[34, 37, 13],
|
|
20316
|
+
// 23
|
|
20317
|
+
[4, 151, 121, 5, 152, 122],
|
|
20318
|
+
[4, 75, 47, 14, 76, 48],
|
|
20319
|
+
[11, 54, 24, 14, 55, 25],
|
|
20320
|
+
[16, 45, 15, 14, 46, 16],
|
|
20321
|
+
// 24
|
|
20322
|
+
[6, 147, 117, 4, 148, 118],
|
|
20323
|
+
[6, 73, 45, 14, 74, 46],
|
|
20324
|
+
[11, 54, 24, 16, 55, 25],
|
|
20325
|
+
[30, 46, 16, 2, 47, 17],
|
|
20326
|
+
// 25
|
|
20327
|
+
[8, 132, 106, 4, 133, 107],
|
|
20328
|
+
[8, 75, 47, 13, 76, 48],
|
|
20329
|
+
[7, 54, 24, 22, 55, 25],
|
|
20330
|
+
[22, 45, 15, 13, 46, 16],
|
|
20331
|
+
// 26
|
|
20332
|
+
[10, 142, 114, 2, 143, 115],
|
|
20333
|
+
[19, 74, 46, 4, 75, 47],
|
|
20334
|
+
[28, 50, 22, 6, 51, 23],
|
|
20335
|
+
[33, 46, 16, 4, 47, 17],
|
|
20336
|
+
// 27
|
|
20337
|
+
[8, 152, 122, 4, 153, 123],
|
|
20338
|
+
[22, 73, 45, 3, 74, 46],
|
|
20339
|
+
[8, 53, 23, 26, 54, 24],
|
|
20340
|
+
[12, 45, 15, 28, 46, 16],
|
|
20341
|
+
// 28
|
|
20342
|
+
[3, 147, 117, 10, 148, 118],
|
|
20343
|
+
[3, 73, 45, 23, 74, 46],
|
|
20344
|
+
[4, 54, 24, 31, 55, 25],
|
|
20345
|
+
[11, 45, 15, 31, 46, 16],
|
|
20346
|
+
// 29
|
|
20347
|
+
[7, 146, 116, 7, 147, 117],
|
|
20348
|
+
[21, 73, 45, 7, 74, 46],
|
|
20349
|
+
[1, 53, 23, 37, 54, 24],
|
|
20350
|
+
[19, 45, 15, 26, 46, 16],
|
|
20351
|
+
// 30
|
|
20352
|
+
[5, 145, 115, 10, 146, 116],
|
|
20353
|
+
[19, 75, 47, 10, 76, 48],
|
|
20354
|
+
[15, 54, 24, 25, 55, 25],
|
|
20355
|
+
[23, 45, 15, 25, 46, 16],
|
|
20356
|
+
// 31
|
|
20357
|
+
[13, 145, 115, 3, 146, 116],
|
|
20358
|
+
[2, 74, 46, 29, 75, 47],
|
|
20359
|
+
[42, 54, 24, 1, 55, 25],
|
|
20360
|
+
[23, 45, 15, 28, 46, 16],
|
|
20361
|
+
// 32
|
|
20362
|
+
[17, 145, 115],
|
|
20363
|
+
[10, 74, 46, 23, 75, 47],
|
|
20364
|
+
[10, 54, 24, 35, 55, 25],
|
|
20365
|
+
[19, 45, 15, 35, 46, 16],
|
|
20366
|
+
// 33
|
|
20367
|
+
[17, 145, 115, 1, 146, 116],
|
|
20368
|
+
[14, 74, 46, 21, 75, 47],
|
|
20369
|
+
[29, 54, 24, 19, 55, 25],
|
|
20370
|
+
[11, 45, 15, 46, 46, 16],
|
|
20371
|
+
// 34
|
|
20372
|
+
[13, 145, 115, 6, 146, 116],
|
|
20373
|
+
[14, 74, 46, 23, 75, 47],
|
|
20374
|
+
[44, 54, 24, 7, 55, 25],
|
|
20375
|
+
[59, 46, 16, 1, 47, 17],
|
|
20376
|
+
// 35
|
|
20377
|
+
[12, 151, 121, 7, 152, 122],
|
|
20378
|
+
[12, 75, 47, 26, 76, 48],
|
|
20379
|
+
[39, 54, 24, 14, 55, 25],
|
|
20380
|
+
[22, 45, 15, 41, 46, 16],
|
|
20381
|
+
// 36
|
|
20382
|
+
[6, 151, 121, 14, 152, 122],
|
|
20383
|
+
[6, 75, 47, 34, 76, 48],
|
|
20384
|
+
[46, 54, 24, 10, 55, 25],
|
|
20385
|
+
[2, 45, 15, 64, 46, 16],
|
|
20386
|
+
// 37
|
|
20387
|
+
[17, 152, 122, 4, 153, 123],
|
|
20388
|
+
[29, 74, 46, 14, 75, 47],
|
|
20389
|
+
[49, 54, 24, 10, 55, 25],
|
|
20390
|
+
[24, 45, 15, 46, 46, 16],
|
|
20391
|
+
// 38
|
|
20392
|
+
[4, 152, 122, 18, 153, 123],
|
|
20393
|
+
[13, 74, 46, 32, 75, 47],
|
|
20394
|
+
[48, 54, 24, 14, 55, 25],
|
|
20395
|
+
[42, 45, 15, 32, 46, 16],
|
|
20396
|
+
// 39
|
|
20397
|
+
[20, 147, 117, 4, 148, 118],
|
|
20398
|
+
[40, 75, 47, 7, 76, 48],
|
|
20399
|
+
[43, 54, 24, 22, 55, 25],
|
|
20400
|
+
[10, 45, 15, 67, 46, 16],
|
|
20401
|
+
// 40
|
|
20402
|
+
[19, 148, 118, 6, 149, 119],
|
|
20403
|
+
[18, 75, 47, 31, 76, 48],
|
|
20404
|
+
[34, 54, 24, 34, 55, 25],
|
|
20405
|
+
[20, 45, 15, 61, 46, 16]
|
|
20406
|
+
];
|
|
20407
|
+
const qrRSBlock = /* @__PURE__ */ __name(function(totalCount, dataCount) {
|
|
20408
|
+
const _this2 = {};
|
|
20409
|
+
_this2.totalCount = totalCount;
|
|
20410
|
+
_this2.dataCount = dataCount;
|
|
20411
|
+
return _this2;
|
|
20412
|
+
}, "qrRSBlock");
|
|
20413
|
+
const _this = {};
|
|
20414
|
+
const getRsBlockTable = /* @__PURE__ */ __name(function(typeNumber, errorCorrectionLevel) {
|
|
20415
|
+
switch (errorCorrectionLevel) {
|
|
20416
|
+
case QRErrorCorrectionLevel.L:
|
|
20417
|
+
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
|
|
20418
|
+
case QRErrorCorrectionLevel.M:
|
|
20419
|
+
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
|
|
20420
|
+
case QRErrorCorrectionLevel.Q:
|
|
20421
|
+
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
|
|
20422
|
+
case QRErrorCorrectionLevel.H:
|
|
20423
|
+
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
|
|
20424
|
+
default:
|
|
20425
|
+
return void 0;
|
|
20426
|
+
}
|
|
20427
|
+
}, "getRsBlockTable");
|
|
20428
|
+
_this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
|
|
20429
|
+
const rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
|
|
20430
|
+
if (typeof rsBlock == "undefined") {
|
|
20431
|
+
throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
|
|
20432
|
+
}
|
|
20433
|
+
const length = rsBlock.length / 3;
|
|
20434
|
+
const list2 = [];
|
|
20435
|
+
for (let i3 = 0; i3 < length; i3 += 1) {
|
|
20436
|
+
const count5 = rsBlock[i3 * 3 + 0];
|
|
20437
|
+
const totalCount = rsBlock[i3 * 3 + 1];
|
|
20438
|
+
const dataCount = rsBlock[i3 * 3 + 2];
|
|
20439
|
+
for (let j = 0; j < count5; j += 1) {
|
|
20440
|
+
list2.push(qrRSBlock(totalCount, dataCount));
|
|
20441
|
+
}
|
|
20442
|
+
}
|
|
20443
|
+
return list2;
|
|
20444
|
+
};
|
|
20445
|
+
return _this;
|
|
20446
|
+
})();
|
|
20447
|
+
var qrBitBuffer = /* @__PURE__ */ __name(function() {
|
|
20448
|
+
const _buffer = [];
|
|
20449
|
+
let _length = 0;
|
|
20450
|
+
const _this = {};
|
|
20451
|
+
_this.getBuffer = function() {
|
|
20452
|
+
return _buffer;
|
|
20453
|
+
};
|
|
20454
|
+
_this.getAt = function(index) {
|
|
20455
|
+
const bufIndex = Math.floor(index / 8);
|
|
20456
|
+
return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
|
|
20457
|
+
};
|
|
20458
|
+
_this.put = function(num, length) {
|
|
20459
|
+
for (let i3 = 0; i3 < length; i3 += 1) {
|
|
20460
|
+
_this.putBit((num >>> length - i3 - 1 & 1) == 1);
|
|
20461
|
+
}
|
|
20462
|
+
};
|
|
20463
|
+
_this.getLengthInBits = function() {
|
|
20464
|
+
return _length;
|
|
20465
|
+
};
|
|
20466
|
+
_this.putBit = function(bit) {
|
|
20467
|
+
const bufIndex = Math.floor(_length / 8);
|
|
20468
|
+
if (_buffer.length <= bufIndex) {
|
|
20469
|
+
_buffer.push(0);
|
|
20470
|
+
}
|
|
20471
|
+
if (bit) {
|
|
20472
|
+
_buffer[bufIndex] |= 128 >>> _length % 8;
|
|
20473
|
+
}
|
|
20474
|
+
_length += 1;
|
|
20475
|
+
};
|
|
20476
|
+
return _this;
|
|
20477
|
+
}, "qrBitBuffer");
|
|
20478
|
+
var qrNumber = /* @__PURE__ */ __name(function(data) {
|
|
20479
|
+
const _mode = QRMode.MODE_NUMBER;
|
|
20480
|
+
const _data = data;
|
|
20481
|
+
const _this = {};
|
|
20482
|
+
_this.getMode = function() {
|
|
20483
|
+
return _mode;
|
|
20484
|
+
};
|
|
20485
|
+
_this.getLength = function(buffer) {
|
|
20486
|
+
return _data.length;
|
|
20487
|
+
};
|
|
20488
|
+
_this.write = function(buffer) {
|
|
20489
|
+
const data2 = _data;
|
|
20490
|
+
let i3 = 0;
|
|
20491
|
+
while (i3 + 2 < data2.length) {
|
|
20492
|
+
buffer.put(strToNum(data2.substring(i3, i3 + 3)), 10);
|
|
20493
|
+
i3 += 3;
|
|
20494
|
+
}
|
|
20495
|
+
if (i3 < data2.length) {
|
|
20496
|
+
if (data2.length - i3 == 1) {
|
|
20497
|
+
buffer.put(strToNum(data2.substring(i3, i3 + 1)), 4);
|
|
20498
|
+
} else if (data2.length - i3 == 2) {
|
|
20499
|
+
buffer.put(strToNum(data2.substring(i3, i3 + 2)), 7);
|
|
20500
|
+
}
|
|
20501
|
+
}
|
|
20502
|
+
};
|
|
20503
|
+
const strToNum = /* @__PURE__ */ __name(function(s2) {
|
|
20504
|
+
let num = 0;
|
|
20505
|
+
for (let i3 = 0; i3 < s2.length; i3 += 1) {
|
|
20506
|
+
num = num * 10 + chatToNum(s2.charAt(i3));
|
|
20507
|
+
}
|
|
20508
|
+
return num;
|
|
20509
|
+
}, "strToNum");
|
|
20510
|
+
const chatToNum = /* @__PURE__ */ __name(function(c2) {
|
|
20511
|
+
if ("0" <= c2 && c2 <= "9") {
|
|
20512
|
+
return c2.charCodeAt(0) - "0".charCodeAt(0);
|
|
20513
|
+
}
|
|
20514
|
+
throw "illegal char :" + c2;
|
|
20515
|
+
}, "chatToNum");
|
|
20516
|
+
return _this;
|
|
20517
|
+
}, "qrNumber");
|
|
20518
|
+
var qrAlphaNum = /* @__PURE__ */ __name(function(data) {
|
|
20519
|
+
const _mode = QRMode.MODE_ALPHA_NUM;
|
|
20520
|
+
const _data = data;
|
|
20521
|
+
const _this = {};
|
|
20522
|
+
_this.getMode = function() {
|
|
20523
|
+
return _mode;
|
|
20524
|
+
};
|
|
20525
|
+
_this.getLength = function(buffer) {
|
|
20526
|
+
return _data.length;
|
|
20527
|
+
};
|
|
20528
|
+
_this.write = function(buffer) {
|
|
20529
|
+
const s2 = _data;
|
|
20530
|
+
let i3 = 0;
|
|
20531
|
+
while (i3 + 1 < s2.length) {
|
|
20532
|
+
buffer.put(
|
|
20533
|
+
getCode(s2.charAt(i3)) * 45 + getCode(s2.charAt(i3 + 1)),
|
|
20534
|
+
11
|
|
20535
|
+
);
|
|
20536
|
+
i3 += 2;
|
|
20537
|
+
}
|
|
20538
|
+
if (i3 < s2.length) {
|
|
20539
|
+
buffer.put(getCode(s2.charAt(i3)), 6);
|
|
20540
|
+
}
|
|
20541
|
+
};
|
|
20542
|
+
const getCode = /* @__PURE__ */ __name(function(c2) {
|
|
20543
|
+
if ("0" <= c2 && c2 <= "9") {
|
|
20544
|
+
return c2.charCodeAt(0) - "0".charCodeAt(0);
|
|
20545
|
+
} else if ("A" <= c2 && c2 <= "Z") {
|
|
20546
|
+
return c2.charCodeAt(0) - "A".charCodeAt(0) + 10;
|
|
20547
|
+
} else {
|
|
20548
|
+
switch (c2) {
|
|
20549
|
+
case " ":
|
|
20550
|
+
return 36;
|
|
20551
|
+
case "$":
|
|
20552
|
+
return 37;
|
|
20553
|
+
case "%":
|
|
20554
|
+
return 38;
|
|
20555
|
+
case "*":
|
|
20556
|
+
return 39;
|
|
20557
|
+
case "+":
|
|
20558
|
+
return 40;
|
|
20559
|
+
case "-":
|
|
20560
|
+
return 41;
|
|
20561
|
+
case ".":
|
|
20562
|
+
return 42;
|
|
20563
|
+
case "/":
|
|
20564
|
+
return 43;
|
|
20565
|
+
case ":":
|
|
20566
|
+
return 44;
|
|
20567
|
+
default:
|
|
20568
|
+
throw "illegal char :" + c2;
|
|
20569
|
+
}
|
|
20570
|
+
}
|
|
20571
|
+
}, "getCode");
|
|
20572
|
+
return _this;
|
|
20573
|
+
}, "qrAlphaNum");
|
|
20574
|
+
var qr8BitByte = /* @__PURE__ */ __name(function(data) {
|
|
20575
|
+
const _mode = QRMode.MODE_8BIT_BYTE;
|
|
20576
|
+
const _data = data;
|
|
20577
|
+
const _bytes = qrcode.stringToBytes(data);
|
|
20578
|
+
const _this = {};
|
|
20579
|
+
_this.getMode = function() {
|
|
20580
|
+
return _mode;
|
|
20581
|
+
};
|
|
20582
|
+
_this.getLength = function(buffer) {
|
|
20583
|
+
return _bytes.length;
|
|
20584
|
+
};
|
|
20585
|
+
_this.write = function(buffer) {
|
|
20586
|
+
for (let i3 = 0; i3 < _bytes.length; i3 += 1) {
|
|
20587
|
+
buffer.put(_bytes[i3], 8);
|
|
20588
|
+
}
|
|
20589
|
+
};
|
|
20590
|
+
return _this;
|
|
20591
|
+
}, "qr8BitByte");
|
|
20592
|
+
var qrKanji = /* @__PURE__ */ __name(function(data) {
|
|
20593
|
+
const _mode = QRMode.MODE_KANJI;
|
|
20594
|
+
const _data = data;
|
|
20595
|
+
const stringToBytes2 = qrcode.stringToBytes;
|
|
20596
|
+
!(function(c2, code) {
|
|
20597
|
+
const test = stringToBytes2(c2);
|
|
20598
|
+
if (test.length != 2 || (test[0] << 8 | test[1]) != code) {
|
|
20599
|
+
throw "sjis not supported.";
|
|
20600
|
+
}
|
|
20601
|
+
})("\u53CB", 38726);
|
|
20602
|
+
const _bytes = stringToBytes2(data);
|
|
20603
|
+
const _this = {};
|
|
20604
|
+
_this.getMode = function() {
|
|
20605
|
+
return _mode;
|
|
20606
|
+
};
|
|
20607
|
+
_this.getLength = function(buffer) {
|
|
20608
|
+
return ~~(_bytes.length / 2);
|
|
20609
|
+
};
|
|
20610
|
+
_this.write = function(buffer) {
|
|
20611
|
+
const data2 = _bytes;
|
|
20612
|
+
let i3 = 0;
|
|
20613
|
+
while (i3 + 1 < data2.length) {
|
|
20614
|
+
let c2 = (255 & data2[i3]) << 8 | 255 & data2[i3 + 1];
|
|
20615
|
+
if (33088 <= c2 && c2 <= 40956) {
|
|
20616
|
+
c2 -= 33088;
|
|
20617
|
+
} else if (57408 <= c2 && c2 <= 60351) {
|
|
20618
|
+
c2 -= 49472;
|
|
20619
|
+
} else {
|
|
20620
|
+
throw "illegal char at " + (i3 + 1) + "/" + c2;
|
|
20621
|
+
}
|
|
20622
|
+
c2 = (c2 >>> 8 & 255) * 192 + (c2 & 255);
|
|
20623
|
+
buffer.put(c2, 13);
|
|
20624
|
+
i3 += 2;
|
|
20625
|
+
}
|
|
20626
|
+
if (i3 < data2.length) {
|
|
20627
|
+
throw "illegal char at " + (i3 + 1);
|
|
20628
|
+
}
|
|
20629
|
+
};
|
|
20630
|
+
return _this;
|
|
20631
|
+
}, "qrKanji");
|
|
20632
|
+
var byteArrayOutputStream = /* @__PURE__ */ __name(function() {
|
|
20633
|
+
const _bytes = [];
|
|
20634
|
+
const _this = {};
|
|
20635
|
+
_this.writeByte = function(b) {
|
|
20636
|
+
_bytes.push(b & 255);
|
|
20637
|
+
};
|
|
20638
|
+
_this.writeShort = function(i3) {
|
|
20639
|
+
_this.writeByte(i3);
|
|
20640
|
+
_this.writeByte(i3 >>> 8);
|
|
20641
|
+
};
|
|
20642
|
+
_this.writeBytes = function(b, off, len) {
|
|
20643
|
+
off = off || 0;
|
|
20644
|
+
len = len || b.length;
|
|
20645
|
+
for (let i3 = 0; i3 < len; i3 += 1) {
|
|
20646
|
+
_this.writeByte(b[i3 + off]);
|
|
20647
|
+
}
|
|
20648
|
+
};
|
|
20649
|
+
_this.writeString = function(s2) {
|
|
20650
|
+
for (let i3 = 0; i3 < s2.length; i3 += 1) {
|
|
20651
|
+
_this.writeByte(s2.charCodeAt(i3));
|
|
20652
|
+
}
|
|
20653
|
+
};
|
|
20654
|
+
_this.toByteArray = function() {
|
|
20655
|
+
return _bytes;
|
|
20656
|
+
};
|
|
20657
|
+
_this.toString = function() {
|
|
20658
|
+
let s2 = "";
|
|
20659
|
+
s2 += "[";
|
|
20660
|
+
for (let i3 = 0; i3 < _bytes.length; i3 += 1) {
|
|
20661
|
+
if (i3 > 0) {
|
|
20662
|
+
s2 += ",";
|
|
20663
|
+
}
|
|
20664
|
+
s2 += _bytes[i3];
|
|
20665
|
+
}
|
|
20666
|
+
s2 += "]";
|
|
20667
|
+
return s2;
|
|
20668
|
+
};
|
|
20669
|
+
return _this;
|
|
20670
|
+
}, "byteArrayOutputStream");
|
|
20671
|
+
var base64EncodeOutputStream = /* @__PURE__ */ __name(function() {
|
|
20672
|
+
let _buffer = 0;
|
|
20673
|
+
let _buflen = 0;
|
|
20674
|
+
let _length = 0;
|
|
20675
|
+
let _base64 = "";
|
|
20676
|
+
const _this = {};
|
|
20677
|
+
const writeEncoded = /* @__PURE__ */ __name(function(b) {
|
|
20678
|
+
_base64 += String.fromCharCode(encode(b & 63));
|
|
20679
|
+
}, "writeEncoded");
|
|
20680
|
+
const encode = /* @__PURE__ */ __name(function(n2) {
|
|
20681
|
+
if (n2 < 0) {
|
|
20682
|
+
throw "n:" + n2;
|
|
20683
|
+
} else if (n2 < 26) {
|
|
20684
|
+
return 65 + n2;
|
|
20685
|
+
} else if (n2 < 52) {
|
|
20686
|
+
return 97 + (n2 - 26);
|
|
20687
|
+
} else if (n2 < 62) {
|
|
20688
|
+
return 48 + (n2 - 52);
|
|
20689
|
+
} else if (n2 == 62) {
|
|
20690
|
+
return 43;
|
|
20691
|
+
} else if (n2 == 63) {
|
|
20692
|
+
return 47;
|
|
20693
|
+
} else {
|
|
20694
|
+
throw "n:" + n2;
|
|
20695
|
+
}
|
|
20696
|
+
}, "encode");
|
|
20697
|
+
_this.writeByte = function(n2) {
|
|
20698
|
+
_buffer = _buffer << 8 | n2 & 255;
|
|
20699
|
+
_buflen += 8;
|
|
20700
|
+
_length += 1;
|
|
20701
|
+
while (_buflen >= 6) {
|
|
20702
|
+
writeEncoded(_buffer >>> _buflen - 6);
|
|
20703
|
+
_buflen -= 6;
|
|
20704
|
+
}
|
|
20705
|
+
};
|
|
20706
|
+
_this.flush = function() {
|
|
20707
|
+
if (_buflen > 0) {
|
|
20708
|
+
writeEncoded(_buffer << 6 - _buflen);
|
|
20709
|
+
_buffer = 0;
|
|
20710
|
+
_buflen = 0;
|
|
20711
|
+
}
|
|
20712
|
+
if (_length % 3 != 0) {
|
|
20713
|
+
const padlen = 3 - _length % 3;
|
|
20714
|
+
for (let i3 = 0; i3 < padlen; i3 += 1) {
|
|
20715
|
+
_base64 += "=";
|
|
20716
|
+
}
|
|
20717
|
+
}
|
|
20718
|
+
};
|
|
20719
|
+
_this.toString = function() {
|
|
20720
|
+
return _base64;
|
|
20721
|
+
};
|
|
20722
|
+
return _this;
|
|
20723
|
+
}, "base64EncodeOutputStream");
|
|
20724
|
+
var base64DecodeInputStream = /* @__PURE__ */ __name(function(str) {
|
|
20725
|
+
const _str = str;
|
|
20726
|
+
let _pos = 0;
|
|
20727
|
+
let _buffer = 0;
|
|
20728
|
+
let _buflen = 0;
|
|
20729
|
+
const _this = {};
|
|
20730
|
+
_this.read = function() {
|
|
20731
|
+
while (_buflen < 8) {
|
|
20732
|
+
if (_pos >= _str.length) {
|
|
20733
|
+
if (_buflen == 0) {
|
|
20734
|
+
return -1;
|
|
20735
|
+
}
|
|
20736
|
+
throw "unexpected end of file./" + _buflen;
|
|
20737
|
+
}
|
|
20738
|
+
const c2 = _str.charAt(_pos);
|
|
20739
|
+
_pos += 1;
|
|
20740
|
+
if (c2 == "=") {
|
|
20741
|
+
_buflen = 0;
|
|
20742
|
+
return -1;
|
|
20743
|
+
} else if (c2.match(/^\s$/)) {
|
|
20744
|
+
continue;
|
|
20745
|
+
}
|
|
20746
|
+
_buffer = _buffer << 6 | decode(c2.charCodeAt(0));
|
|
20747
|
+
_buflen += 6;
|
|
20748
|
+
}
|
|
20749
|
+
const n2 = _buffer >>> _buflen - 8 & 255;
|
|
20750
|
+
_buflen -= 8;
|
|
20751
|
+
return n2;
|
|
20752
|
+
};
|
|
20753
|
+
const decode = /* @__PURE__ */ __name(function(c2) {
|
|
20754
|
+
if (65 <= c2 && c2 <= 90) {
|
|
20755
|
+
return c2 - 65;
|
|
20756
|
+
} else if (97 <= c2 && c2 <= 122) {
|
|
20757
|
+
return c2 - 97 + 26;
|
|
20758
|
+
} else if (48 <= c2 && c2 <= 57) {
|
|
20759
|
+
return c2 - 48 + 52;
|
|
20760
|
+
} else if (c2 == 43) {
|
|
20761
|
+
return 62;
|
|
20762
|
+
} else if (c2 == 47) {
|
|
20763
|
+
return 63;
|
|
20764
|
+
} else {
|
|
20765
|
+
throw "c:" + c2;
|
|
20766
|
+
}
|
|
20767
|
+
}, "decode");
|
|
20768
|
+
return _this;
|
|
20769
|
+
}, "base64DecodeInputStream");
|
|
20770
|
+
var gifImage = /* @__PURE__ */ __name(function(width, height) {
|
|
20771
|
+
const _width = width;
|
|
20772
|
+
const _height = height;
|
|
20773
|
+
const _data = new Array(width * height);
|
|
20774
|
+
const _this = {};
|
|
20775
|
+
_this.setPixel = function(x, y, pixel) {
|
|
20776
|
+
_data[y * _width + x] = pixel;
|
|
20777
|
+
};
|
|
20778
|
+
_this.write = function(out) {
|
|
20779
|
+
out.writeString("GIF87a");
|
|
20780
|
+
out.writeShort(_width);
|
|
20781
|
+
out.writeShort(_height);
|
|
20782
|
+
out.writeByte(128);
|
|
20783
|
+
out.writeByte(0);
|
|
20784
|
+
out.writeByte(0);
|
|
20785
|
+
out.writeByte(0);
|
|
20786
|
+
out.writeByte(0);
|
|
20787
|
+
out.writeByte(0);
|
|
20788
|
+
out.writeByte(255);
|
|
20789
|
+
out.writeByte(255);
|
|
20790
|
+
out.writeByte(255);
|
|
20791
|
+
out.writeString(",");
|
|
20792
|
+
out.writeShort(0);
|
|
20793
|
+
out.writeShort(0);
|
|
20794
|
+
out.writeShort(_width);
|
|
20795
|
+
out.writeShort(_height);
|
|
20796
|
+
out.writeByte(0);
|
|
20797
|
+
const lzwMinCodeSize = 2;
|
|
20798
|
+
const raster = getLZWRaster(lzwMinCodeSize);
|
|
20799
|
+
out.writeByte(lzwMinCodeSize);
|
|
20800
|
+
let offset = 0;
|
|
20801
|
+
while (raster.length - offset > 255) {
|
|
20802
|
+
out.writeByte(255);
|
|
20803
|
+
out.writeBytes(raster, offset, 255);
|
|
20804
|
+
offset += 255;
|
|
20805
|
+
}
|
|
20806
|
+
out.writeByte(raster.length - offset);
|
|
20807
|
+
out.writeBytes(raster, offset, raster.length - offset);
|
|
20808
|
+
out.writeByte(0);
|
|
20809
|
+
out.writeString(";");
|
|
20810
|
+
};
|
|
20811
|
+
const bitOutputStream = /* @__PURE__ */ __name(function(out) {
|
|
20812
|
+
const _out = out;
|
|
20813
|
+
let _bitLength = 0;
|
|
20814
|
+
let _bitBuffer = 0;
|
|
20815
|
+
const _this2 = {};
|
|
20816
|
+
_this2.write = function(data, length) {
|
|
20817
|
+
if (data >>> length != 0) {
|
|
20818
|
+
throw "length over";
|
|
20819
|
+
}
|
|
20820
|
+
while (_bitLength + length >= 8) {
|
|
20821
|
+
_out.writeByte(255 & (data << _bitLength | _bitBuffer));
|
|
20822
|
+
length -= 8 - _bitLength;
|
|
20823
|
+
data >>>= 8 - _bitLength;
|
|
20824
|
+
_bitBuffer = 0;
|
|
20825
|
+
_bitLength = 0;
|
|
20826
|
+
}
|
|
20827
|
+
_bitBuffer = data << _bitLength | _bitBuffer;
|
|
20828
|
+
_bitLength = _bitLength + length;
|
|
20829
|
+
};
|
|
20830
|
+
_this2.flush = function() {
|
|
20831
|
+
if (_bitLength > 0) {
|
|
20832
|
+
_out.writeByte(_bitBuffer);
|
|
20833
|
+
}
|
|
20834
|
+
};
|
|
20835
|
+
return _this2;
|
|
20836
|
+
}, "bitOutputStream");
|
|
20837
|
+
const getLZWRaster = /* @__PURE__ */ __name(function(lzwMinCodeSize) {
|
|
20838
|
+
const clearCode = 1 << lzwMinCodeSize;
|
|
20839
|
+
const endCode = (1 << lzwMinCodeSize) + 1;
|
|
20840
|
+
let bitLength = lzwMinCodeSize + 1;
|
|
20841
|
+
const table = lzwTable();
|
|
20842
|
+
for (let i3 = 0; i3 < clearCode; i3 += 1) {
|
|
20843
|
+
table.add(String.fromCharCode(i3));
|
|
20844
|
+
}
|
|
20845
|
+
table.add(String.fromCharCode(clearCode));
|
|
20846
|
+
table.add(String.fromCharCode(endCode));
|
|
20847
|
+
const byteOut = byteArrayOutputStream();
|
|
20848
|
+
const bitOut = bitOutputStream(byteOut);
|
|
20849
|
+
bitOut.write(clearCode, bitLength);
|
|
20850
|
+
let dataIndex = 0;
|
|
20851
|
+
let s2 = String.fromCharCode(_data[dataIndex]);
|
|
20852
|
+
dataIndex += 1;
|
|
20853
|
+
while (dataIndex < _data.length) {
|
|
20854
|
+
const c2 = String.fromCharCode(_data[dataIndex]);
|
|
20855
|
+
dataIndex += 1;
|
|
20856
|
+
if (table.contains(s2 + c2)) {
|
|
20857
|
+
s2 = s2 + c2;
|
|
20858
|
+
} else {
|
|
20859
|
+
bitOut.write(table.indexOf(s2), bitLength);
|
|
20860
|
+
if (table.size() < 4095) {
|
|
20861
|
+
if (table.size() == 1 << bitLength) {
|
|
20862
|
+
bitLength += 1;
|
|
20863
|
+
}
|
|
20864
|
+
table.add(s2 + c2);
|
|
20865
|
+
}
|
|
20866
|
+
s2 = c2;
|
|
20867
|
+
}
|
|
20868
|
+
}
|
|
20869
|
+
bitOut.write(table.indexOf(s2), bitLength);
|
|
20870
|
+
bitOut.write(endCode, bitLength);
|
|
20871
|
+
bitOut.flush();
|
|
20872
|
+
return byteOut.toByteArray();
|
|
20873
|
+
}, "getLZWRaster");
|
|
20874
|
+
const lzwTable = /* @__PURE__ */ __name(function() {
|
|
20875
|
+
const _map = {};
|
|
20876
|
+
let _size = 0;
|
|
20877
|
+
const _this2 = {};
|
|
20878
|
+
_this2.add = function(key) {
|
|
20879
|
+
if (_this2.contains(key)) {
|
|
20880
|
+
throw "dup key:" + key;
|
|
20881
|
+
}
|
|
20882
|
+
_map[key] = _size;
|
|
20883
|
+
_size += 1;
|
|
20884
|
+
};
|
|
20885
|
+
_this2.size = function() {
|
|
20886
|
+
return _size;
|
|
20887
|
+
};
|
|
20888
|
+
_this2.indexOf = function(key) {
|
|
20889
|
+
return _map[key];
|
|
20890
|
+
};
|
|
20891
|
+
_this2.contains = function(key) {
|
|
20892
|
+
return typeof _map[key] != "undefined";
|
|
20893
|
+
};
|
|
20894
|
+
return _this2;
|
|
20895
|
+
}, "lzwTable");
|
|
20896
|
+
return _this;
|
|
20897
|
+
}, "gifImage");
|
|
20898
|
+
var createDataURL = /* @__PURE__ */ __name(function(width, height, getPixel) {
|
|
20899
|
+
const gif = gifImage(width, height);
|
|
20900
|
+
for (let y = 0; y < height; y += 1) {
|
|
20901
|
+
for (let x = 0; x < width; x += 1) {
|
|
20902
|
+
gif.setPixel(x, y, getPixel(x, y));
|
|
20903
|
+
}
|
|
20904
|
+
}
|
|
20905
|
+
const b = byteArrayOutputStream();
|
|
20906
|
+
gif.write(b);
|
|
20907
|
+
const base64 = base64EncodeOutputStream();
|
|
20908
|
+
const bytes = b.toByteArray();
|
|
20909
|
+
for (let i3 = 0; i3 < bytes.length; i3 += 1) {
|
|
20910
|
+
base64.writeByte(bytes[i3]);
|
|
20911
|
+
}
|
|
20912
|
+
base64.flush();
|
|
20913
|
+
return "data:image/gif;base64," + base64;
|
|
20914
|
+
}, "createDataURL");
|
|
20915
|
+
var stringToBytes = qrcode.stringToBytes;
|
|
20916
|
+
|
|
20917
|
+
// dist/commands/session.js
|
|
20918
|
+
var CLI2 = IDENTITY.command;
|
|
20919
|
+
var answer2 = /* @__PURE__ */ __name((command, item) => renderAnswer(command, outputFor(command), itemOf(item)), "answer");
|
|
20920
|
+
var storageOf = /* @__PURE__ */ __name((raw) => {
|
|
20921
|
+
if (raw === "keyring" || raw === "file")
|
|
20922
|
+
return raw;
|
|
20923
|
+
throw new CliError("validation_error", `--credential-storage takes keyring or file; got ${raw}`);
|
|
20924
|
+
}, "storageOf");
|
|
20925
|
+
var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("start"), {
|
|
20926
|
+
effects: FETCH,
|
|
20927
|
+
lifetime: "interactive",
|
|
20928
|
+
mcp: false,
|
|
20929
|
+
examples: [`${CLI2} personal session start`, `${CLI2} personal session start --credential-storage file`]
|
|
20930
|
+
})).summary(`sign in to ${SERVICE} with an API token`).description(`sign this profile in: the ${SERVICE} API token is asked hidden or read from stdin, never taken as an argument, checked against the service, and only then kept in the keyring, or in a private file`).option("--credential-storage <storage>", "where the token is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring").action(async function(args) {
|
|
20931
|
+
const { env, flags, profile, tokens, run: run3 } = contextOf(this);
|
|
20932
|
+
refuseCommandName(profile, commandWords(rootOf(this)), CLI2);
|
|
20933
|
+
refuseOffline(flags);
|
|
20934
|
+
const token = (await readSecret(`${SERVICE} API token: `, secretInputOf(this))).trim();
|
|
20935
|
+
if (!token)
|
|
20936
|
+
throw new CliError("validation_error", "no token was given");
|
|
20937
|
+
const user = await run3((events) => serviceFor(this, token, events).me());
|
|
20938
|
+
const storedIn = tokens.write(profile, token, args.credentialStorage);
|
|
20939
|
+
rememberAccount(IDENTITY, profile, user.id, env);
|
|
20940
|
+
answer2(this, { profile, state: "saved", stored_in: storedIn, verified: true, user });
|
|
20941
|
+
}), "startCommand");
|
|
20942
|
+
var statusCommand3 = /* @__PURE__ */ __name(() => annotate(new Command("status"), {
|
|
20943
|
+
effects: REMOTE_READ,
|
|
20944
|
+
examples: [`${CLI2} personal session status`, `${CLI2} personal session status --check --json`]
|
|
20945
|
+
}).summary("show where this profile's token comes from; never the token").description(`show where this profile's token comes from: ${TOKEN_VARIABLE}, the keyring or a file, never the token; --check asks ${SERVICE} whose token it is`).option("--check", `ask ${SERVICE} whether the token still works, and whose it is`).action(async function(args) {
|
|
20946
|
+
const { profile, tokens } = contextOf(this);
|
|
20947
|
+
const saved = tokens.read(profile);
|
|
20948
|
+
const status = { profile, state: saved ? "saved" : "missing", token_from: saved?.source ?? null };
|
|
20949
|
+
if (!args.check || !saved)
|
|
20950
|
+
return answer2(this, { ...status, verified: false });
|
|
20951
|
+
answer2(this, { ...status, verified: true, user: await withService(this, (service) => service.me()) });
|
|
20952
|
+
}), "statusCommand");
|
|
20953
|
+
var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
|
|
19005
20954
|
effects: LOCAL_WRITE,
|
|
19006
20955
|
mcp: false,
|
|
19007
|
-
examples: [`${
|
|
19008
|
-
}).summary("forget
|
|
19009
|
-
refuseUnderReadOnly(this, "
|
|
19010
|
-
const { profile,
|
|
19011
|
-
|
|
19012
|
-
|
|
19013
|
-
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
}, "target"),
|
|
19029
|
-
answer: /* @__PURE__ */ __name((self, item, lines2) => renderAnswer(self, outputFor(self), itemOf(item), () => lines2.join("\n")), "answer")
|
|
19030
|
-
})), "mcpCommand");
|
|
20956
|
+
examples: [`${CLI2} personal session end`]
|
|
20957
|
+
})).summary("forget this profile's token on this computer").description(`forget this profile's token on this computer; the token itself stays valid in ${SERVICE}`).action(function() {
|
|
20958
|
+
refuseUnderReadOnly(this, "session end");
|
|
20959
|
+
const { profile, tokens } = contextOf(this);
|
|
20960
|
+
answer2(this, { profile, ended: tokens.remove(profile) });
|
|
20961
|
+
}), "endCommand");
|
|
20962
|
+
var listCommand5 = /* @__PURE__ */ __name(() => profileFree(annotate(new Command("list"), {
|
|
20963
|
+
effects: LOCAL_READ,
|
|
20964
|
+
examples: [`${CLI2} session list`, `${CLI2} session list --json`]
|
|
20965
|
+
})).summary("list the profiles here and whether each is signed in").description("list the profiles on this computer and whether each has a token; picks none").action(function() {
|
|
20966
|
+
const environment = environmentOf(this);
|
|
20967
|
+
const env = environment.env ?? process.env;
|
|
20968
|
+
const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
|
|
20969
|
+
const tokens = tokenStore(env, environment.keyring, outputFor(this).renderer.warn);
|
|
20970
|
+
const items = profilesHere(IDENTITY, configuredProfiles, env).map((profile) => {
|
|
20971
|
+
const saved = tokens.read(profile);
|
|
20972
|
+
return { profile, signed_in: saved !== void 0, token_from: saved?.source ?? null };
|
|
20973
|
+
});
|
|
20974
|
+
renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
|
|
20975
|
+
}), "listCommand");
|
|
20976
|
+
var sessionCommand = /* @__PURE__ */ __name(() => annotate(new Command("session"), { effects: LOCAL_READ }).description(`keep this profile's ${SERVICE} token in the OS keyring`).addCommand(startCommand()).addCommand(statusCommand3()).addCommand(endCommand()).addCommand(listCommand5()), "sessionCommand");
|
|
19031
20977
|
|
|
19032
20978
|
// dist/program.js
|
|
19033
20979
|
var update = appUpdate({
|
|
@@ -19039,12 +20985,29 @@ var update = appUpdate({
|
|
|
19039
20985
|
enabled: /* @__PURE__ */ __name((env) => configuration.resolveSettings({}, { env, needsProfile: false }).updateCheck, "enabled"),
|
|
19040
20986
|
offVariables: [`${IDENTITY.envPrefix}_NO_UPDATE_CHECK`]
|
|
19041
20987
|
});
|
|
20988
|
+
var mcpCommand3 = /* @__PURE__ */ __name(() => {
|
|
20989
|
+
let keyring;
|
|
20990
|
+
const mcp = appMcpCommand2(IDENTITY, configuration, {
|
|
20991
|
+
name: SERVICE,
|
|
20992
|
+
// SAMPLE: name the kinds of text other people wrote that your answers carry (WC-MCP-11).
|
|
20993
|
+
untrusted: ["comment text", "author names"],
|
|
20994
|
+
permissionExample: "comments.create=deny",
|
|
20995
|
+
skill: SKILL,
|
|
20996
|
+
signedIn: /* @__PURE__ */ __name((profile, env) => holdsToken(env, profile, keyring), "signedIn")
|
|
20997
|
+
});
|
|
20998
|
+
return mcp.hook("preAction", (_mcp, action) => {
|
|
20999
|
+
keyring = environmentOf(action).keyring;
|
|
21000
|
+
});
|
|
21001
|
+
}, "mcpCommand");
|
|
19042
21002
|
var definition = /* @__PURE__ */ __name(() => ({
|
|
19043
21003
|
app: IDENTITY,
|
|
19044
|
-
|
|
21004
|
+
// The whole object: cli-core refuses a command by its key only when it gets the permission table too.
|
|
21005
|
+
configuration,
|
|
19045
21006
|
commands: /* @__PURE__ */ __name(() => [
|
|
19046
21007
|
commandsCommand2(IDENTITY),
|
|
19047
|
-
|
|
21008
|
+
sessionCommand(),
|
|
21009
|
+
commentsCommand2(),
|
|
21010
|
+
appDoctorCommand2(IDENTITY, configuration, { packageName: PACKAGE }),
|
|
19048
21011
|
skillCommand3(IDENTITY, SKILL),
|
|
19049
21012
|
mcpCommand3(),
|
|
19050
21013
|
upgradeCommand2(IDENTITY, PACKAGE, (command) => ({
|