khala-cli 0.4.14 → 0.4.16
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/dist/{chunk-OPBOWFBB.mjs → chunk-3AOD6N2X.mjs} +134 -40
- package/dist/{chunk-QEIYPWN4.mjs → chunk-3BMYI3II.mjs} +12 -12
- package/dist/{chunk-RXM47OGD.mjs → chunk-4GVGGDP3.mjs} +3 -3
- package/dist/{chunk-PISWOM3Q.mjs → chunk-4XN4FXQN.mjs} +10 -10
- package/dist/{chunk-YXMJJAMH.mjs → chunk-7DAJUPE7.mjs} +50 -9
- package/dist/{chunk-H3XIRV2S.mjs → chunk-AU75ZQGN.mjs} +1 -1
- package/dist/{chunk-P2S3OAZ5.mjs → chunk-AYG5S5CG.mjs} +6 -6
- package/dist/{chunk-W3LLNKEB.mjs → chunk-DVNUQCCY.mjs} +3 -3
- package/dist/{chunk-U2OUPWUW.mjs → chunk-E3IVG3BK.mjs} +2 -2
- package/dist/{chunk-WMZ7YE6H.mjs → chunk-EY27N2BY.mjs} +3 -3
- package/dist/{chunk-VXHWS7JD.mjs → chunk-FEJE7ZOF.mjs} +2 -2
- package/dist/{chunk-FOCBFFH5.mjs → chunk-G323ZXDL.mjs} +2 -2
- package/dist/{chunk-QH5WZEIG.mjs → chunk-GS7FTTHW.mjs} +9 -9
- package/dist/{chunk-BSB77FJG.mjs → chunk-H27WKQYQ.mjs} +2 -2
- package/dist/{chunk-2ZT7TFV5.mjs → chunk-JKBHRHSY.mjs} +8 -8
- package/dist/{chunk-PYVAMHAG.mjs → chunk-K7UICTRQ.mjs} +2 -2
- package/dist/chunk-M5II3E5T.mjs +19 -0
- package/dist/chunk-NEJRSW7R.mjs +20 -0
- package/dist/{chunk-ZWDINIQJ.mjs → chunk-NXEQEY3M.mjs} +1 -1
- package/dist/{chunk-T3BRQFVF.mjs → chunk-ODMW45B6.mjs} +1 -1
- package/dist/{chunk-N7B2VPDU.mjs → chunk-OSSYXQKY.mjs} +1 -1
- package/dist/{chunk-G2TAYBYB.mjs → chunk-PC7MEL4R.mjs} +1 -1
- package/dist/{chunk-O2NDYSYF.mjs → chunk-QSIO26HF.mjs} +6 -6
- package/dist/{chunk-4THILKJ5.mjs → chunk-RXQJ7W3V.mjs} +6 -6
- package/dist/{chunk-KZO6BSPQ.mjs → chunk-T5EJ7PRO.mjs} +5 -5
- package/dist/{chunk-PIYD4WCN.mjs → chunk-THOO43JY.mjs} +1 -1
- package/dist/{chunk-4YHVAWZF.mjs → chunk-TYHET72S.mjs} +3 -3
- package/dist/chunk-UWRWWFN5.mjs +165 -0
- package/dist/{chunk-TVWBZD24.mjs → chunk-W33R7NQS.mjs} +16 -16
- package/dist/chunk-WFRW2X2S.mjs +27 -0
- package/dist/{chunk-RHAAMCRD.mjs → chunk-XD2AELOT.mjs} +7 -7
- package/dist/{chunk-VQDIOGV7.mjs → chunk-YAIJB4FT.mjs} +7 -7
- package/dist/{chunk-PFWYYXR5.mjs → chunk-YMH6MKJJ.mjs} +2 -2
- package/dist/{chunk-UBDI4XFO.mjs → chunk-ZKVCL3WP.mjs} +10 -10
- package/dist/khala.mjs +11 -11
- package/dist/web/assets/local-d0y_F2g5.js +13 -0
- package/dist/web/assets/{local-DLmpMMaF.css → local-rpKMAzbU.css} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-6CDTY2EG.mjs +0 -20
- package/dist/chunk-HPZY6LHL.mjs +0 -14
- package/dist/chunk-TMOAMJMV.mjs +0 -19
- package/dist/chunk-UQJHB4AH.mjs +0 -27
- package/dist/web/assets/local-EzltpNwn.js +0 -11
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
bundle
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ODMW45B6.mjs";
|
|
5
5
|
import {
|
|
6
6
|
init_define_KHALA_BUNDLE
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
10
|
init_define_KHALA_BUNDLE();
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
listChannels
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4GVGGDP3.mjs";
|
|
5
5
|
import {
|
|
6
6
|
TERMINAL_SESSION_DETAILS,
|
|
7
7
|
cachedProcessReader,
|
|
8
8
|
readStateFile,
|
|
9
9
|
readStatus,
|
|
10
10
|
validAgentRejoinSecret
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-OSSYXQKY.mjs";
|
|
12
12
|
import {
|
|
13
13
|
init_define_KHALA_BUNDLE
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
15
15
|
|
|
16
16
|
// src/session-start-wake.ts
|
|
17
17
|
init_define_KHALA_BUNDLE();
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
object,
|
|
6
6
|
readMatrixUserId,
|
|
7
7
|
version
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-OSSYXQKY.mjs";
|
|
9
9
|
import {
|
|
10
10
|
init_define_KHALA_BUNDLE
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
12
12
|
|
|
13
13
|
// ../contracts/src/m1/listening-mode.ts
|
|
14
14
|
init_define_KHALA_BUNDLE();
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
readJson,
|
|
5
5
|
readProcess,
|
|
6
6
|
writeJsonAtomic
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OSSYXQKY.mjs";
|
|
8
8
|
import {
|
|
9
9
|
init_define_KHALA_BUNDLE
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
11
11
|
|
|
12
12
|
// src/wake/terminal/capture.ts
|
|
13
13
|
init_define_KHALA_BUNDLE();
|
|
@@ -2,7 +2,7 @@ import { createRequire as __khalaCreateRequire } from 'node:module'; const requi
|
|
|
2
2
|
import {
|
|
3
3
|
parseChannelLink,
|
|
4
4
|
resolveLocalOwnerName
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TYHET72S.mjs";
|
|
6
6
|
import {
|
|
7
7
|
LOCAL_AGENT_DEVICE_PREFIX,
|
|
8
8
|
LOCAL_IDLE_EXIT_MS,
|
|
@@ -32,14 +32,14 @@ import {
|
|
|
32
32
|
normalizeInitials,
|
|
33
33
|
olderHelperVersion,
|
|
34
34
|
readHelperFile
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import "./chunk-
|
|
35
|
+
} from "./chunk-T5EJ7PRO.mjs";
|
|
36
|
+
import "./chunk-THOO43JY.mjs";
|
|
37
37
|
import {
|
|
38
38
|
KHALA_AGENT_VERSION
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-E3IVG3BK.mjs";
|
|
40
40
|
import {
|
|
41
41
|
bundle
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-ODMW45B6.mjs";
|
|
43
43
|
import {
|
|
44
44
|
DEFAULT_LISTENING_MODE,
|
|
45
45
|
LISTENING_MODE_COMMAND_TYPE,
|
|
@@ -47,13 +47,13 @@ import {
|
|
|
47
47
|
decodeListeningMode,
|
|
48
48
|
decodeListeningModeCommand,
|
|
49
49
|
memberListeningMode
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-FEJE7ZOF.mjs";
|
|
51
51
|
import {
|
|
52
52
|
CHANNEL_EVENT_TYPE,
|
|
53
53
|
decodeChannelEvent,
|
|
54
54
|
encodeChannelEvent,
|
|
55
55
|
memberRenameContent
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-YMH6MKJJ.mjs";
|
|
57
57
|
import {
|
|
58
58
|
LEGACY_HARNESSES,
|
|
59
59
|
StateError,
|
|
@@ -67,10 +67,10 @@ import {
|
|
|
67
67
|
validAgentRejoinSecret,
|
|
68
68
|
validAgentSessionId,
|
|
69
69
|
writeJsonAtomic
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-OSSYXQKY.mjs";
|
|
71
71
|
import {
|
|
72
72
|
init_define_KHALA_BUNDLE
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
74
74
|
|
|
75
75
|
// src/local/cli.ts
|
|
76
76
|
init_define_KHALA_BUNDLE();
|
|
@@ -14,21 +14,21 @@ import {
|
|
|
14
14
|
decodeLocalSendResult,
|
|
15
15
|
ensureHelper,
|
|
16
16
|
localRoomPath
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-T5EJ7PRO.mjs";
|
|
18
|
+
import "./chunk-THOO43JY.mjs";
|
|
19
|
+
import "./chunk-E3IVG3BK.mjs";
|
|
20
|
+
import "./chunk-ODMW45B6.mjs";
|
|
21
21
|
import {
|
|
22
22
|
LISTENING_MODE_COMMAND_TYPE
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-FEJE7ZOF.mjs";
|
|
24
24
|
import {
|
|
25
25
|
CHANNEL_EVENT_TYPE,
|
|
26
26
|
memberRenameContent
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
27
|
+
} from "./chunk-YMH6MKJJ.mjs";
|
|
28
|
+
import "./chunk-OSSYXQKY.mjs";
|
|
29
29
|
import {
|
|
30
30
|
init_define_KHALA_BUNDLE
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
32
32
|
|
|
33
33
|
// src/local/session.ts
|
|
34
34
|
init_define_KHALA_BUNDLE();
|
|
@@ -2,10 +2,10 @@ import { createRequire as __khalaCreateRequire } from 'node:module'; const requi
|
|
|
2
2
|
import {
|
|
3
3
|
adapterFor,
|
|
4
4
|
resolveSources
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-W33R7NQS.mjs";
|
|
6
6
|
import {
|
|
7
7
|
init_define_KHALA_BUNDLE
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
9
9
|
|
|
10
10
|
// src/mcp/session-id.ts
|
|
11
11
|
init_define_KHALA_BUNDLE();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
ADAPTERS,
|
|
4
|
+
adapterFor,
|
|
5
|
+
createAdapterRegistry
|
|
6
|
+
} from "./chunk-W33R7NQS.mjs";
|
|
7
|
+
import "./chunk-G323ZXDL.mjs";
|
|
8
|
+
import "./chunk-YAIJB4FT.mjs";
|
|
9
|
+
import "./chunk-FEJE7ZOF.mjs";
|
|
10
|
+
import "./chunk-4GVGGDP3.mjs";
|
|
11
|
+
import "./chunk-YMH6MKJJ.mjs";
|
|
12
|
+
import "./chunk-OSSYXQKY.mjs";
|
|
13
|
+
import "./chunk-PC7MEL4R.mjs";
|
|
14
|
+
import "./chunk-AU75ZQGN.mjs";
|
|
15
|
+
export {
|
|
16
|
+
ADAPTERS,
|
|
17
|
+
adapterFor,
|
|
18
|
+
createAdapterRegistry
|
|
19
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
resolveHarness,
|
|
4
|
+
resolveSession,
|
|
5
|
+
resolveSessionId
|
|
6
|
+
} from "./chunk-K7UICTRQ.mjs";
|
|
7
|
+
import "./chunk-W33R7NQS.mjs";
|
|
8
|
+
import "./chunk-G323ZXDL.mjs";
|
|
9
|
+
import "./chunk-YAIJB4FT.mjs";
|
|
10
|
+
import "./chunk-FEJE7ZOF.mjs";
|
|
11
|
+
import "./chunk-4GVGGDP3.mjs";
|
|
12
|
+
import "./chunk-YMH6MKJJ.mjs";
|
|
13
|
+
import "./chunk-OSSYXQKY.mjs";
|
|
14
|
+
import "./chunk-PC7MEL4R.mjs";
|
|
15
|
+
import "./chunk-AU75ZQGN.mjs";
|
|
16
|
+
export {
|
|
17
|
+
resolveHarness,
|
|
18
|
+
resolveSession,
|
|
19
|
+
resolveSessionId
|
|
20
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
init_define_KHALA_BUNDLE
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
5
5
|
|
|
6
6
|
// src/matrix/decryption-retry.ts
|
|
7
7
|
init_define_KHALA_BUNDLE();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
init_define_KHALA_BUNDLE
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
5
5
|
|
|
6
6
|
// ../contracts/src/m1/harness.ts
|
|
7
7
|
init_define_KHALA_BUNDLE();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
init_define_KHALA_BUNDLE
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
5
5
|
|
|
6
6
|
// src/wake/shared/nonce.ts
|
|
7
7
|
init_define_KHALA_BUNDLE();
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
adapterFor
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-W33R7NQS.mjs";
|
|
5
5
|
import {
|
|
6
6
|
installedLauncher,
|
|
7
7
|
launcherShellQuote,
|
|
8
8
|
readWakeSettings
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YAIJB4FT.mjs";
|
|
10
10
|
import {
|
|
11
11
|
HARNESS_REGISTRY,
|
|
12
12
|
filesForDir,
|
|
13
13
|
readStateFile,
|
|
14
14
|
stateRoot
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-OSSYXQKY.mjs";
|
|
16
16
|
import {
|
|
17
17
|
readWakeState
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-PC7MEL4R.mjs";
|
|
19
19
|
import {
|
|
20
20
|
init_define_KHALA_BUNDLE
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
22
22
|
|
|
23
23
|
// src/wake/status.ts
|
|
24
24
|
init_define_KHALA_BUNDLE();
|
|
@@ -875,7 +875,7 @@ function selectedWakeStatus(rows) {
|
|
|
875
875
|
}
|
|
876
876
|
var WAKE_HARNESSES = HARNESS_REGISTRY.map((row) => row.id);
|
|
877
877
|
async function wakeDisableNotice(dir) {
|
|
878
|
-
const { takeWakeDisableNotices } = await import("./chunk-
|
|
878
|
+
const { takeWakeDisableNotices } = await import("./chunk-H27WKQYQ.mjs");
|
|
879
879
|
let drivers;
|
|
880
880
|
try {
|
|
881
881
|
const states = await readWakeState(dir);
|
|
@@ -3,27 +3,27 @@ import {
|
|
|
3
3
|
WAKE_HARNESSES,
|
|
4
4
|
wakeDrivers,
|
|
5
5
|
wakeStatus
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QSIO26HF.mjs";
|
|
7
7
|
import {
|
|
8
8
|
adapterFor,
|
|
9
9
|
registerAntigravityWake,
|
|
10
10
|
resolveSources
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-W33R7NQS.mjs";
|
|
12
12
|
import {
|
|
13
13
|
CURSOR_DEFAULT_SESSION,
|
|
14
14
|
updateWakeSettings
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-YAIJB4FT.mjs";
|
|
16
16
|
import {
|
|
17
17
|
SESSION_ID_PATTERN,
|
|
18
18
|
filesForDir,
|
|
19
19
|
stateRoot
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-OSSYXQKY.mjs";
|
|
21
21
|
import {
|
|
22
22
|
resetWakeDriver
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PC7MEL4R.mjs";
|
|
24
24
|
import {
|
|
25
25
|
init_define_KHALA_BUNDLE
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
27
27
|
|
|
28
28
|
// src/wake/cli.ts
|
|
29
29
|
init_define_KHALA_BUNDLE();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
KHALA_AGENT_VERSION
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-E3IVG3BK.mjs";
|
|
5
5
|
import {
|
|
6
6
|
bundle
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ODMW45B6.mjs";
|
|
8
8
|
import {
|
|
9
9
|
LISTENING_MODES
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FEJE7ZOF.mjs";
|
|
11
11
|
import {
|
|
12
12
|
HARNESS_REGISTRY,
|
|
13
13
|
M1_LABEL_MAX_BYTES,
|
|
@@ -35,10 +35,10 @@ import {
|
|
|
35
35
|
utcTimestamp,
|
|
36
36
|
utf8Length,
|
|
37
37
|
version
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-OSSYXQKY.mjs";
|
|
39
39
|
import {
|
|
40
40
|
init_define_KHALA_BUNDLE
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
42
42
|
|
|
43
43
|
// src/client.ts
|
|
44
44
|
init_define_KHALA_BUNDLE();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
init_define_KHALA_BUNDLE
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
5
5
|
|
|
6
6
|
// src/events/member-rename.ts
|
|
7
7
|
init_define_KHALA_BUNDLE();
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
checkName,
|
|
5
5
|
isDefaultAgentName,
|
|
6
6
|
restartHelper
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-T5EJ7PRO.mjs";
|
|
8
8
|
import {
|
|
9
9
|
StateError,
|
|
10
10
|
harnessInfo,
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
stateRoot,
|
|
14
14
|
validateAgentName,
|
|
15
15
|
writeJsonAtomic
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-OSSYXQKY.mjs";
|
|
17
17
|
import {
|
|
18
18
|
init_define_KHALA_BUNDLE
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
20
20
|
|
|
21
21
|
// src/local/identity.ts
|
|
22
22
|
init_define_KHALA_BUNDLE();
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
init_define_KHALA_BUNDLE
|
|
4
|
+
} from "./chunk-AU75ZQGN.mjs";
|
|
5
|
+
|
|
6
|
+
// ../contracts/src/m1/image.ts
|
|
7
|
+
init_define_KHALA_BUNDLE();
|
|
8
|
+
var IMAGE_MIME_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
9
|
+
var IMAGE_MAX_BYTES = 10 * 1024 * 1024;
|
|
10
|
+
var MAX_DIMENSION = 65535;
|
|
11
|
+
var u16be = (b, i) => b[i] << 8 | b[i + 1];
|
|
12
|
+
var u16le = (b, i) => b[i] | b[i + 1] << 8;
|
|
13
|
+
var u24le = (b, i) => b[i] | b[i + 1] << 8 | b[i + 2] << 16;
|
|
14
|
+
var ascii = (b, i, text) => [...text].every((c, k) => b[i + k] === c.charCodeAt(0));
|
|
15
|
+
function sniffType(b) {
|
|
16
|
+
if (b.length >= 24 && b[0] === 137 && ascii(b, 1, "PNG\r\n\n") && ascii(b, 12, "IHDR")) {
|
|
17
|
+
return { mimetype: "image/png", w: (u16be(b, 16) << 16 | u16be(b, 18)) >>> 0, h: (u16be(b, 20) << 16 | u16be(b, 22)) >>> 0 };
|
|
18
|
+
}
|
|
19
|
+
if (b.length >= 10 && (ascii(b, 0, "GIF87a") || ascii(b, 0, "GIF89a"))) return { mimetype: "image/gif", w: u16le(b, 6), h: u16le(b, 8) };
|
|
20
|
+
if (b.length >= 30 && ascii(b, 0, "RIFF") && ascii(b, 8, "WEBP")) {
|
|
21
|
+
if (ascii(b, 12, "VP8 ")) return { mimetype: "image/webp", w: u16le(b, 26) & 16383, h: u16le(b, 28) & 16383 };
|
|
22
|
+
if (ascii(b, 12, "VP8L")) {
|
|
23
|
+
return { mimetype: "image/webp", w: 1 + ((b[22] & 63) << 8 | b[21]), h: 1 + ((b[24] & 15) << 10 | b[23] << 2 | (b[22] & 192) >> 6) };
|
|
24
|
+
}
|
|
25
|
+
if (ascii(b, 12, "VP8X")) return { mimetype: "image/webp", w: 1 + u24le(b, 24), h: 1 + u24le(b, 27) };
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (b.length >= 4 && b[0] === 255 && b[1] === 216) {
|
|
29
|
+
for (let i = 2; i + 9 < b.length; ) {
|
|
30
|
+
if (b[i] !== 255) return null;
|
|
31
|
+
const marker = b[i + 1];
|
|
32
|
+
if (marker === 255) {
|
|
33
|
+
i += 1;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
37
|
+
return { mimetype: "image/jpeg", w: u16be(b, i + 7), h: u16be(b, i + 5) };
|
|
38
|
+
}
|
|
39
|
+
if (marker === 218 || marker === 217) return null;
|
|
40
|
+
i += 2 + u16be(b, i + 2);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function sniffImage(bytes) {
|
|
46
|
+
const found = sniffType(bytes);
|
|
47
|
+
return found && found.w >= 1 && found.h >= 1 && found.w <= MAX_DIMENSION && found.h <= MAX_DIMENSION ? found : null;
|
|
48
|
+
}
|
|
49
|
+
function checkImage(bytes) {
|
|
50
|
+
if (bytes.length === 0) return { ok: false, reason: "empty" };
|
|
51
|
+
if (bytes.length > IMAGE_MAX_BYTES) return { ok: false, reason: "too_large" };
|
|
52
|
+
const image = sniffImage(bytes);
|
|
53
|
+
return image ? { ok: true, image } : { ok: false, reason: "unsupported_type" };
|
|
54
|
+
}
|
|
55
|
+
function stripJpegMetadata(bytes) {
|
|
56
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) return bytes;
|
|
57
|
+
const parts = [bytes.subarray(0, 2)];
|
|
58
|
+
let i = 2;
|
|
59
|
+
while (i + 3 < bytes.length && bytes[i] === 255) {
|
|
60
|
+
const marker = bytes[i + 1];
|
|
61
|
+
if (marker === 218) break;
|
|
62
|
+
const end = i + 2 + u16be(bytes, i + 2);
|
|
63
|
+
if (end > bytes.length) return bytes;
|
|
64
|
+
if (marker !== 225 && marker !== 237 && marker !== 254) parts.push(bytes.subarray(i, end));
|
|
65
|
+
i = end;
|
|
66
|
+
}
|
|
67
|
+
parts.push(bytes.subarray(i));
|
|
68
|
+
const out = new Uint8Array(parts.reduce((sum, part) => sum + part.length, 0));
|
|
69
|
+
let at = 0;
|
|
70
|
+
for (const part of parts) {
|
|
71
|
+
out.set(part, at);
|
|
72
|
+
at += part.length;
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
function base64(bytes, url = false) {
|
|
77
|
+
let binary = "";
|
|
78
|
+
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
79
|
+
const encoded = btoa(binary).replace(/=+$/u, "");
|
|
80
|
+
return url ? encoded.replace(/\+/gu, "-").replace(/\//gu, "_") : encoded;
|
|
81
|
+
}
|
|
82
|
+
function unbase64(text) {
|
|
83
|
+
const binary = atob(text.replace(/-/gu, "+").replace(/_/gu, "/").padEnd(Math.ceil(text.length / 4) * 4, "="));
|
|
84
|
+
return Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
85
|
+
}
|
|
86
|
+
var sha256 = async (bytes) => base64(new Uint8Array(await crypto.subtle.digest("SHA-256", new Uint8Array(bytes))));
|
|
87
|
+
async function encryptAttachment(plaintext) {
|
|
88
|
+
const raw = crypto.getRandomValues(new Uint8Array(32));
|
|
89
|
+
const iv = new Uint8Array(16);
|
|
90
|
+
iv.set(crypto.getRandomValues(new Uint8Array(8)));
|
|
91
|
+
const key = await crypto.subtle.importKey("raw", raw, "AES-CTR", false, ["encrypt"]);
|
|
92
|
+
const ciphertext = new Uint8Array(await crypto.subtle.encrypt({ name: "AES-CTR", counter: iv, length: 64 }, key, new Uint8Array(plaintext)));
|
|
93
|
+
return { ciphertext, key: base64(raw, true), iv: base64(iv), sha256: await sha256(ciphertext) };
|
|
94
|
+
}
|
|
95
|
+
async function decryptAttachment(ciphertext, ref) {
|
|
96
|
+
if (await sha256(ciphertext) !== ref.sha256) throw new Error("attachment_hash_mismatch");
|
|
97
|
+
const key = await crypto.subtle.importKey("raw", new Uint8Array(unbase64(ref.key)), "AES-CTR", false, ["decrypt"]);
|
|
98
|
+
return new Uint8Array(await crypto.subtle.decrypt({ name: "AES-CTR", counter: new Uint8Array(unbase64(ref.iv)), length: 64 }, key, new Uint8Array(ciphertext)));
|
|
99
|
+
}
|
|
100
|
+
var MXC = /^mxc:\/\/[A-Za-z0-9.:[\]-]{1,255}\/[A-Za-z0-9_-]{1,255}$/u;
|
|
101
|
+
var NAME = /^[^\p{Cc}\p{Cf}/\\]{1,255}$/u;
|
|
102
|
+
function readImageRef(value) {
|
|
103
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
104
|
+
const v = value;
|
|
105
|
+
const keys = Object.keys(v).sort().join(",");
|
|
106
|
+
if (keys !== "h,iv,key,mimetype,name,sha256,size,url,w") return null;
|
|
107
|
+
const int = (n, max) => typeof n === "number" && Number.isInteger(n) && n >= 1 && n <= max;
|
|
108
|
+
return typeof v.name === "string" && NAME.test(v.name) && IMAGE_MIME_TYPES.includes(v.mimetype) && int(v.size, IMAGE_MAX_BYTES * 2) && int(v.w, MAX_DIMENSION) && int(v.h, MAX_DIMENSION) && typeof v.url === "string" && MXC.test(v.url) && typeof v.key === "string" && /^[A-Za-z0-9_-]{43}$/u.test(v.key) && typeof v.iv === "string" && /^[A-Za-z0-9+/]{22}(==)?$/u.test(v.iv) && typeof v.sha256 === "string" && /^[A-Za-z0-9+/]{43}$/u.test(v.sha256) ? v : null;
|
|
109
|
+
}
|
|
110
|
+
function imageEventContent(ref, caption) {
|
|
111
|
+
return {
|
|
112
|
+
msgtype: "m.image",
|
|
113
|
+
body: caption || ref.name,
|
|
114
|
+
filename: ref.name,
|
|
115
|
+
info: { mimetype: ref.mimetype, size: ref.size, w: ref.w, h: ref.h },
|
|
116
|
+
file: {
|
|
117
|
+
v: "v2",
|
|
118
|
+
url: ref.url,
|
|
119
|
+
iv: ref.iv,
|
|
120
|
+
hashes: { sha256: ref.sha256 },
|
|
121
|
+
key: { kty: "oct", key_ops: ["encrypt", "decrypt"], alg: "A256CTR", k: ref.key, ext: true }
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function readImageEvent(content) {
|
|
126
|
+
if (content.msgtype !== "m.image" || typeof content.body !== "string") return null;
|
|
127
|
+
const obj = (value) => typeof value === "object" && value !== null ? value : {};
|
|
128
|
+
const file = obj(content.file), info = obj(content.info), key = obj(file.key), hashes = obj(file.hashes);
|
|
129
|
+
if (file.v !== "v2" || key.alg !== "A256CTR" || key.kty !== "oct") return null;
|
|
130
|
+
const name = typeof content.filename === "string" ? content.filename : content.body;
|
|
131
|
+
const image = readImageRef({
|
|
132
|
+
name,
|
|
133
|
+
mimetype: info.mimetype,
|
|
134
|
+
size: info.size,
|
|
135
|
+
w: info.w,
|
|
136
|
+
h: info.h,
|
|
137
|
+
url: file.url,
|
|
138
|
+
key: key.k,
|
|
139
|
+
iv: file.iv,
|
|
140
|
+
sha256: hashes.sha256
|
|
141
|
+
});
|
|
142
|
+
return image ? { image, caption: content.body === name ? "" : content.body } : null;
|
|
143
|
+
}
|
|
144
|
+
function imageLabel(image) {
|
|
145
|
+
return `[image: ${image.name}, ${image.w}x${image.h}]`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// src/transport.ts
|
|
149
|
+
init_define_KHALA_BUNDLE();
|
|
150
|
+
var RESTORE_HISTORY_MAX_PAGES = 20;
|
|
151
|
+
var startChannelSession = async (creds, options) => creds.transport === "local" ? (await import("./chunk-JKBHRHSY.mjs")).createLocalSession(creds) : (await import("./chunk-7DAJUPE7.mjs")).createAgentMatrixSession(creds, options);
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
IMAGE_MAX_BYTES,
|
|
155
|
+
sniffImage,
|
|
156
|
+
checkImage,
|
|
157
|
+
stripJpegMetadata,
|
|
158
|
+
encryptAttachment,
|
|
159
|
+
decryptAttachment,
|
|
160
|
+
imageEventContent,
|
|
161
|
+
readImageEvent,
|
|
162
|
+
imageLabel,
|
|
163
|
+
RESTORE_HISTORY_MAX_PAGES,
|
|
164
|
+
startChannelSession
|
|
165
|
+
};
|