@cecwxf/wtt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +147 -0
- package/bin/openclaw-wtt-bootstrap.mjs +181 -0
- package/dist/channel.d.ts +275 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +2088 -0
- package/dist/channel.js.map +1 -0
- package/dist/commands/account.d.ts +16 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +37 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/bind.d.ts +3 -0
- package/dist/commands/bind.d.ts.map +1 -0
- package/dist/commands/bind.js +102 -0
- package/dist/commands/bind.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +38 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/delegate.d.ts +7 -0
- package/dist/commands/delegate.d.ts.map +1 -0
- package/dist/commands/delegate.js +99 -0
- package/dist/commands/delegate.js.map +1 -0
- package/dist/commands/formatter.d.ts +8 -0
- package/dist/commands/formatter.d.ts.map +1 -0
- package/dist/commands/formatter.js +198 -0
- package/dist/commands/formatter.js.map +1 -0
- package/dist/commands/handlers.d.ts +3 -0
- package/dist/commands/handlers.d.ts.map +1 -0
- package/dist/commands/handlers.js +79 -0
- package/dist/commands/handlers.js.map +1 -0
- package/dist/commands/http.d.ts +26 -0
- package/dist/commands/http.d.ts.map +1 -0
- package/dist/commands/http.js +190 -0
- package/dist/commands/http.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/parser.d.ts +5 -0
- package/dist/commands/parser.d.ts.map +1 -0
- package/dist/commands/parser.js +325 -0
- package/dist/commands/parser.js.map +1 -0
- package/dist/commands/pipeline.d.ts +7 -0
- package/dist/commands/pipeline.d.ts.map +1 -0
- package/dist/commands/pipeline.js +99 -0
- package/dist/commands/pipeline.js.map +1 -0
- package/dist/commands/router.d.ts +18 -0
- package/dist/commands/router.d.ts.map +1 -0
- package/dist/commands/router.js +74 -0
- package/dist/commands/router.js.map +1 -0
- package/dist/commands/setup.d.ts +7 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +89 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/task.d.ts +26 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +438 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/types.d.ts +173 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/e2e-crypto.d.ts +36 -0
- package/dist/e2e-crypto.d.ts.map +1 -0
- package/dist/e2e-crypto.js +166 -0
- package/dist/e2e-crypto.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-config.d.ts +32 -0
- package/dist/plugin-config.d.ts.map +1 -0
- package/dist/plugin-config.js +268 -0
- package/dist/plugin-config.js.map +1 -0
- package/dist/runtime/index.d.ts +13 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/progress-ticker.d.ts +65 -0
- package/dist/runtime/progress-ticker.d.ts.map +1 -0
- package/dist/runtime/progress-ticker.js +116 -0
- package/dist/runtime/progress-ticker.js.map +1 -0
- package/dist/runtime/session-binding.d.ts +16 -0
- package/dist/runtime/session-binding.d.ts.map +1 -0
- package/dist/runtime/session-binding.js +20 -0
- package/dist/runtime/session-binding.js.map +1 -0
- package/dist/runtime/status-transition.d.ts +19 -0
- package/dist/runtime/status-transition.d.ts.map +1 -0
- package/dist/runtime/status-transition.js +95 -0
- package/dist/runtime/status-transition.js.map +1 -0
- package/dist/runtime/task-executor-persistence.d.ts +63 -0
- package/dist/runtime/task-executor-persistence.d.ts.map +1 -0
- package/dist/runtime/task-executor-persistence.js +201 -0
- package/dist/runtime/task-executor-persistence.js.map +1 -0
- package/dist/runtime/task-executor.d.ts +169 -0
- package/dist/runtime/task-executor.d.ts.map +1 -0
- package/dist/runtime/task-executor.js +1230 -0
- package/dist/runtime/task-executor.js.map +1 -0
- package/dist/runtime/task-status-handler.d.ts +28 -0
- package/dist/runtime/task-status-handler.d.ts.map +1 -0
- package/dist/runtime/task-status-handler.js +102 -0
- package/dist/runtime/task-status-handler.js.map +1 -0
- package/dist/types.d.ts +159 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/ws-client.d.ts +90 -0
- package/dist/ws-client.d.ts.map +1 -0
- package/dist/ws-client.js +385 -0
- package/dist/ws-client.js.map +1 -0
- package/index.ts +19 -0
- package/openclaw.plugin.json +49 -0
- package/package.json +62 -0
- package/scripts/install-bootstrap-cli.sh +54 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { TaskRunDetailPayload } from "../runtime/index.js";
|
|
2
|
+
import type { WTTCloudClient } from "../ws-client.js";
|
|
3
|
+
export type WTTCommandName = "list" | "find" | "join" | "leave" | "publish" | "poll" | "history" | "p2p" | "detail" | "subscribed" | "task" | "pipeline" | "delegate" | "config" | "bind" | "setup" | "help";
|
|
4
|
+
export type ParsedWTTCommand = {
|
|
5
|
+
name: "list";
|
|
6
|
+
limit?: number;
|
|
7
|
+
} | {
|
|
8
|
+
name: "find";
|
|
9
|
+
query: string;
|
|
10
|
+
} | {
|
|
11
|
+
name: "join";
|
|
12
|
+
topicId: string;
|
|
13
|
+
} | {
|
|
14
|
+
name: "leave";
|
|
15
|
+
topicId: string;
|
|
16
|
+
} | {
|
|
17
|
+
name: "publish";
|
|
18
|
+
topicId: string;
|
|
19
|
+
content: string;
|
|
20
|
+
} | {
|
|
21
|
+
name: "poll";
|
|
22
|
+
limit?: number;
|
|
23
|
+
} | {
|
|
24
|
+
name: "history";
|
|
25
|
+
topicId: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
} | {
|
|
28
|
+
name: "p2p";
|
|
29
|
+
agentId: string;
|
|
30
|
+
content: string;
|
|
31
|
+
} | {
|
|
32
|
+
name: "detail";
|
|
33
|
+
topicId: string;
|
|
34
|
+
} | {
|
|
35
|
+
name: "subscribed";
|
|
36
|
+
} | {
|
|
37
|
+
name: "task";
|
|
38
|
+
action: "list";
|
|
39
|
+
} | {
|
|
40
|
+
name: "task";
|
|
41
|
+
action: "detail";
|
|
42
|
+
taskId: string;
|
|
43
|
+
} | {
|
|
44
|
+
name: "task";
|
|
45
|
+
action: "create";
|
|
46
|
+
title: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
} | {
|
|
49
|
+
name: "task";
|
|
50
|
+
action: "run";
|
|
51
|
+
taskId: string;
|
|
52
|
+
} | {
|
|
53
|
+
name: "task";
|
|
54
|
+
action: "review";
|
|
55
|
+
taskId: string;
|
|
56
|
+
reviewAction: "approve" | "reject" | "block";
|
|
57
|
+
comment?: string;
|
|
58
|
+
} | {
|
|
59
|
+
name: "pipeline";
|
|
60
|
+
action: "list";
|
|
61
|
+
} | {
|
|
62
|
+
name: "pipeline";
|
|
63
|
+
action: "create";
|
|
64
|
+
nameArg: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
} | {
|
|
67
|
+
name: "pipeline";
|
|
68
|
+
action: "run";
|
|
69
|
+
pipelineId: string;
|
|
70
|
+
} | {
|
|
71
|
+
name: "delegate";
|
|
72
|
+
action: "list";
|
|
73
|
+
} | {
|
|
74
|
+
name: "delegate";
|
|
75
|
+
action: "create";
|
|
76
|
+
targetAgentId: string;
|
|
77
|
+
} | {
|
|
78
|
+
name: "delegate";
|
|
79
|
+
action: "remove";
|
|
80
|
+
targetAgentId: string;
|
|
81
|
+
} | {
|
|
82
|
+
name: "config";
|
|
83
|
+
mode: "show" | "auto";
|
|
84
|
+
} | {
|
|
85
|
+
name: "bind";
|
|
86
|
+
} | {
|
|
87
|
+
name: "setup";
|
|
88
|
+
agentId: string;
|
|
89
|
+
token: string;
|
|
90
|
+
cloudUrl?: string;
|
|
91
|
+
} | {
|
|
92
|
+
name: "help";
|
|
93
|
+
} | {
|
|
94
|
+
name: "invalid";
|
|
95
|
+
reason: string;
|
|
96
|
+
usage?: string;
|
|
97
|
+
};
|
|
98
|
+
export type WTTCommandClient = Pick<WTTCloudClient, "connected" | "list" | "find" | "join" | "leave" | "publish" | "poll" | "history" | "p2p" | "detail" | "subscribed" | "decryptMessage">;
|
|
99
|
+
export interface WTTCommandAccountContext {
|
|
100
|
+
accountId: string;
|
|
101
|
+
name?: string;
|
|
102
|
+
source?: string;
|
|
103
|
+
cloudUrl?: string;
|
|
104
|
+
agentId?: string;
|
|
105
|
+
token?: string;
|
|
106
|
+
enabled?: boolean;
|
|
107
|
+
configured?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface WTTFetchResponseLike {
|
|
110
|
+
ok: boolean;
|
|
111
|
+
status: number;
|
|
112
|
+
statusText?: string;
|
|
113
|
+
json: () => Promise<unknown>;
|
|
114
|
+
text: () => Promise<string>;
|
|
115
|
+
}
|
|
116
|
+
export type WTTFetchLike = (input: string, init?: {
|
|
117
|
+
method?: string;
|
|
118
|
+
headers?: Record<string, string>;
|
|
119
|
+
body?: string;
|
|
120
|
+
signal?: AbortSignal;
|
|
121
|
+
}) => Promise<WTTFetchResponseLike>;
|
|
122
|
+
export interface WTTTaskInferenceRuntimeRequest {
|
|
123
|
+
taskId: string;
|
|
124
|
+
prompt: string;
|
|
125
|
+
task: TaskRunDetailPayload;
|
|
126
|
+
accountId: string;
|
|
127
|
+
}
|
|
128
|
+
export interface WTTTaskInferenceUsage {
|
|
129
|
+
promptTokens?: number;
|
|
130
|
+
completionTokens?: number;
|
|
131
|
+
cacheReadTokens?: number;
|
|
132
|
+
cacheWriteTokens?: number;
|
|
133
|
+
totalTokens?: number;
|
|
134
|
+
source?: string;
|
|
135
|
+
provider?: string;
|
|
136
|
+
model?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface WTTTaskInferenceRuntimeResult {
|
|
139
|
+
outputText: string;
|
|
140
|
+
provider?: string;
|
|
141
|
+
usage?: WTTTaskInferenceUsage;
|
|
142
|
+
raw?: unknown;
|
|
143
|
+
}
|
|
144
|
+
export interface WTTSessionRuntimeMetrics {
|
|
145
|
+
source?: string;
|
|
146
|
+
queueDepth?: number;
|
|
147
|
+
queueMode?: string;
|
|
148
|
+
sessionKey?: string;
|
|
149
|
+
inflight?: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface WTTCommandRuntimeHooks {
|
|
152
|
+
dispatchTaskInference?: (params: WTTTaskInferenceRuntimeRequest) => Promise<WTTTaskInferenceRuntimeResult>;
|
|
153
|
+
getSessionRuntimeMetrics?: (params: {
|
|
154
|
+
taskId: string;
|
|
155
|
+
topicId?: string;
|
|
156
|
+
accountId: string;
|
|
157
|
+
}) => Promise<WTTSessionRuntimeMetrics | undefined>;
|
|
158
|
+
}
|
|
159
|
+
export interface WTTCommandExecutionContext {
|
|
160
|
+
accountId: string;
|
|
161
|
+
account?: WTTCommandAccountContext;
|
|
162
|
+
clientConnected?: boolean;
|
|
163
|
+
client?: WTTCommandClient;
|
|
164
|
+
fetchImpl?: WTTFetchLike;
|
|
165
|
+
runtimeHooks?: WTTCommandRuntimeHooks;
|
|
166
|
+
}
|
|
167
|
+
export interface WTTCommandProcessResult {
|
|
168
|
+
handled: boolean;
|
|
169
|
+
response?: string;
|
|
170
|
+
accountId?: string;
|
|
171
|
+
command?: ParsedWTTCommand["name"];
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM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nB,KAAK,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,wBAAwB,CAAC;IACnC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACvC;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2E Crypto — Isomorphic AES-256-CTR encryption with PBKDF2 key derivation.
|
|
3
|
+
*
|
|
4
|
+
* Works in both Web Crypto API (browser / Cloudflare Workers) and Node.js.
|
|
5
|
+
*
|
|
6
|
+
* Design (compatible with BotChat's approach, adapted for WTT):
|
|
7
|
+
* - Salt = "wtt-e2e-shared" (fixed, so same password → same key for all parties)
|
|
8
|
+
* - PBKDF2-SHA256 with 310,000 iterations (OWASP 2023)
|
|
9
|
+
* - AES-256-CTR with nonce derived from contextId via HKDF-SHA256
|
|
10
|
+
* - Zero ciphertext overhead (no tag/MAC — CTR mode)
|
|
11
|
+
* - Each contextId MUST be globally unique and used ONLY ONCE per key
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Derive a 256-bit master key from the user's E2E password.
|
|
15
|
+
* Uses PBKDF2-SHA256 with 310,000 iterations; salt = "wtt-e2e-shared".
|
|
16
|
+
* agentId parameter is accepted but ignored (kept for API compatibility).
|
|
17
|
+
* Same password always produces same key, enabling cross-party P2P decryption.
|
|
18
|
+
*/
|
|
19
|
+
export declare function deriveKey(password: string, _agentId?: string): Promise<Uint8Array>;
|
|
20
|
+
/**
|
|
21
|
+
* Encrypt plaintext string. Returns raw ciphertext bytes (same length as UTF-8 input).
|
|
22
|
+
* ⚠️ Each contextId MUST be globally unique and used ONLY ONCE per key.
|
|
23
|
+
*/
|
|
24
|
+
export declare function encryptText(key: Uint8Array, plaintext: string, contextId: string): Promise<Uint8Array>;
|
|
25
|
+
/**
|
|
26
|
+
* Decrypt ciphertext bytes back to plaintext string.
|
|
27
|
+
* AES-CTR has no authentication — caller must handle garbled output gracefully.
|
|
28
|
+
*/
|
|
29
|
+
export declare function decryptText(key: Uint8Array, ciphertext: Uint8Array, contextId: string): Promise<string>;
|
|
30
|
+
/** Encrypt raw bytes. Returns ciphertext of same length. */
|
|
31
|
+
export declare function encryptBytes(key: Uint8Array, plaintext: Uint8Array, contextId: string): Promise<Uint8Array>;
|
|
32
|
+
/** Decrypt raw ciphertext bytes. */
|
|
33
|
+
export declare function decryptBytes(key: Uint8Array, ciphertext: Uint8Array, contextId: string): Promise<Uint8Array>;
|
|
34
|
+
export declare function toBase64(data: Uint8Array): string;
|
|
35
|
+
export declare function fromBase64(b64: string): Uint8Array;
|
|
36
|
+
//# sourceMappingURL=e2e-crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e-crypto.d.ts","sourceRoot":"","sources":["../src/e2e-crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoIH;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAExF;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAG5G;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7G;AAED,4DAA4D;AAC5D,wBAAsB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAEjH;AAED,oCAAoC;AACpC,wBAAsB,YAAY,CAChC,GAAG,EAAE,UAAU,EACf,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,UAAU,CAAC,CAErB;AAMD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CASjD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAWlD"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2E Crypto — Isomorphic AES-256-CTR encryption with PBKDF2 key derivation.
|
|
3
|
+
*
|
|
4
|
+
* Works in both Web Crypto API (browser / Cloudflare Workers) and Node.js.
|
|
5
|
+
*
|
|
6
|
+
* Design (compatible with BotChat's approach, adapted for WTT):
|
|
7
|
+
* - Salt = "wtt-e2e-shared" (fixed, so same password → same key for all parties)
|
|
8
|
+
* - PBKDF2-SHA256 with 310,000 iterations (OWASP 2023)
|
|
9
|
+
* - AES-256-CTR with nonce derived from contextId via HKDF-SHA256
|
|
10
|
+
* - Zero ciphertext overhead (no tag/MAC — CTR mode)
|
|
11
|
+
* - Each contextId MUST be globally unique and used ONLY ONCE per key
|
|
12
|
+
*/
|
|
13
|
+
const isNode = typeof globalThis.process !== "undefined" &&
|
|
14
|
+
typeof globalThis.process.versions?.node === "string";
|
|
15
|
+
const PBKDF2_ITERATIONS = 310_000;
|
|
16
|
+
const KEY_LENGTH = 32; // 256 bits
|
|
17
|
+
const NONCE_LENGTH = 16; // AES-CTR counter block
|
|
18
|
+
const SALT_PREFIX = "wtt-e2e-shared";
|
|
19
|
+
function utf8Encode(str) {
|
|
20
|
+
return new TextEncoder().encode(str);
|
|
21
|
+
}
|
|
22
|
+
function utf8Decode(buf) {
|
|
23
|
+
return new TextDecoder().decode(buf);
|
|
24
|
+
}
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Web Crypto implementation (browser + Cloudflare Workers)
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
async function deriveKeyWeb(password, _agentId) {
|
|
29
|
+
const enc = utf8Encode(password);
|
|
30
|
+
const salt = utf8Encode(SALT_PREFIX);
|
|
31
|
+
const baseKey = await crypto.subtle.importKey("raw", enc.buffer, "PBKDF2", false, [
|
|
32
|
+
"deriveBits",
|
|
33
|
+
]);
|
|
34
|
+
const bits = await crypto.subtle.deriveBits({ name: "PBKDF2", salt: salt.buffer, iterations: PBKDF2_ITERATIONS, hash: "SHA-256" }, baseKey, KEY_LENGTH * 8);
|
|
35
|
+
return new Uint8Array(bits);
|
|
36
|
+
}
|
|
37
|
+
async function hkdfNonceWeb(key, contextId) {
|
|
38
|
+
const hmacKey = await crypto.subtle.importKey("raw", key.buffer, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
39
|
+
const info = utf8Encode("nonce-" + contextId);
|
|
40
|
+
const input = new Uint8Array(info.length + 1);
|
|
41
|
+
input.set(info);
|
|
42
|
+
input[info.length] = 0x01;
|
|
43
|
+
const full = await crypto.subtle.sign("HMAC", hmacKey, input.buffer);
|
|
44
|
+
return new Uint8Array(full).slice(0, NONCE_LENGTH);
|
|
45
|
+
}
|
|
46
|
+
async function encryptWeb(key, plaintext, contextId) {
|
|
47
|
+
const counter = await hkdfNonceWeb(key, contextId);
|
|
48
|
+
const aesKey = await crypto.subtle.importKey("raw", key.buffer, { name: "AES-CTR" }, false, [
|
|
49
|
+
"encrypt",
|
|
50
|
+
]);
|
|
51
|
+
const ciphertext = await crypto.subtle.encrypt({ name: "AES-CTR", counter: counter.buffer, length: 128 }, aesKey, plaintext.buffer);
|
|
52
|
+
return new Uint8Array(ciphertext);
|
|
53
|
+
}
|
|
54
|
+
async function decryptWeb(key, ciphertext, contextId) {
|
|
55
|
+
const counter = await hkdfNonceWeb(key, contextId);
|
|
56
|
+
const aesKey = await crypto.subtle.importKey("raw", key.buffer, { name: "AES-CTR" }, false, [
|
|
57
|
+
"decrypt",
|
|
58
|
+
]);
|
|
59
|
+
const plaintext = await crypto.subtle.decrypt({ name: "AES-CTR", counter: counter.buffer, length: 128 }, aesKey, ciphertext.buffer);
|
|
60
|
+
return new Uint8Array(plaintext);
|
|
61
|
+
}
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Node.js implementation
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
let _nodeCrypto = null;
|
|
66
|
+
let _nodeUtil = null;
|
|
67
|
+
async function ensureNodeModules() {
|
|
68
|
+
if (_nodeCrypto && _nodeUtil)
|
|
69
|
+
return;
|
|
70
|
+
_nodeCrypto = await import("node:crypto");
|
|
71
|
+
_nodeUtil = await import("node:util");
|
|
72
|
+
}
|
|
73
|
+
async function deriveKeyNode(password, _agentId) {
|
|
74
|
+
await ensureNodeModules();
|
|
75
|
+
const pbkdf2Async = _nodeUtil.promisify(_nodeCrypto.pbkdf2);
|
|
76
|
+
const salt = SALT_PREFIX;
|
|
77
|
+
const buf = await pbkdf2Async(password, salt, PBKDF2_ITERATIONS, KEY_LENGTH, "sha256");
|
|
78
|
+
return new Uint8Array(buf);
|
|
79
|
+
}
|
|
80
|
+
async function hkdfNonceNode(key, contextId) {
|
|
81
|
+
await ensureNodeModules();
|
|
82
|
+
const info = utf8Encode("nonce-" + contextId);
|
|
83
|
+
const input = new Uint8Array(info.length + 1);
|
|
84
|
+
input.set(info);
|
|
85
|
+
input[info.length] = 0x01;
|
|
86
|
+
const hmac = _nodeCrypto.createHmac("sha256", Buffer.from(key));
|
|
87
|
+
hmac.update(Buffer.from(input));
|
|
88
|
+
const full = hmac.digest();
|
|
89
|
+
return new Uint8Array(full.buffer, full.byteOffset, NONCE_LENGTH);
|
|
90
|
+
}
|
|
91
|
+
async function encryptNode(key, plaintext, contextId) {
|
|
92
|
+
await ensureNodeModules();
|
|
93
|
+
const iv = await hkdfNonceNode(key, contextId);
|
|
94
|
+
const cipher = _nodeCrypto.createCipheriv("aes-256-ctr", Buffer.from(key), Buffer.from(iv));
|
|
95
|
+
const encrypted = Buffer.concat([cipher.update(Buffer.from(plaintext)), cipher.final()]);
|
|
96
|
+
return new Uint8Array(encrypted);
|
|
97
|
+
}
|
|
98
|
+
async function decryptNode(key, ciphertext, contextId) {
|
|
99
|
+
await ensureNodeModules();
|
|
100
|
+
const iv = await hkdfNonceNode(key, contextId);
|
|
101
|
+
const decipher = _nodeCrypto.createDecipheriv("aes-256-ctr", Buffer.from(key), Buffer.from(iv));
|
|
102
|
+
const decrypted = Buffer.concat([decipher.update(Buffer.from(ciphertext)), decipher.final()]);
|
|
103
|
+
return new Uint8Array(decrypted);
|
|
104
|
+
}
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
// Public API — auto-selects implementation based on runtime
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
/**
|
|
109
|
+
* Derive a 256-bit master key from the user's E2E password.
|
|
110
|
+
* Uses PBKDF2-SHA256 with 310,000 iterations; salt = "wtt-e2e-shared".
|
|
111
|
+
* agentId parameter is accepted but ignored (kept for API compatibility).
|
|
112
|
+
* Same password always produces same key, enabling cross-party P2P decryption.
|
|
113
|
+
*/
|
|
114
|
+
export async function deriveKey(password, _agentId) {
|
|
115
|
+
return isNode ? deriveKeyNode(password) : deriveKeyWeb(password);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Encrypt plaintext string. Returns raw ciphertext bytes (same length as UTF-8 input).
|
|
119
|
+
* ⚠️ Each contextId MUST be globally unique and used ONLY ONCE per key.
|
|
120
|
+
*/
|
|
121
|
+
export async function encryptText(key, plaintext, contextId) {
|
|
122
|
+
const data = utf8Encode(plaintext);
|
|
123
|
+
return isNode ? encryptNode(key, data, contextId) : encryptWeb(key, data, contextId);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Decrypt ciphertext bytes back to plaintext string.
|
|
127
|
+
* AES-CTR has no authentication — caller must handle garbled output gracefully.
|
|
128
|
+
*/
|
|
129
|
+
export async function decryptText(key, ciphertext, contextId) {
|
|
130
|
+
const data = isNode ? await decryptNode(key, ciphertext, contextId) : await decryptWeb(key, ciphertext, contextId);
|
|
131
|
+
return utf8Decode(data);
|
|
132
|
+
}
|
|
133
|
+
/** Encrypt raw bytes. Returns ciphertext of same length. */
|
|
134
|
+
export async function encryptBytes(key, plaintext, contextId) {
|
|
135
|
+
return isNode ? encryptNode(key, plaintext, contextId) : encryptWeb(key, plaintext, contextId);
|
|
136
|
+
}
|
|
137
|
+
/** Decrypt raw ciphertext bytes. */
|
|
138
|
+
export async function decryptBytes(key, ciphertext, contextId) {
|
|
139
|
+
return isNode ? decryptNode(key, ciphertext, contextId) : decryptWeb(key, ciphertext, contextId);
|
|
140
|
+
}
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// Utility: base64 encode/decode for JSON transport
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
export function toBase64(data) {
|
|
145
|
+
if (typeof Buffer !== "undefined") {
|
|
146
|
+
return Buffer.from(data).toString("base64");
|
|
147
|
+
}
|
|
148
|
+
let binary = "";
|
|
149
|
+
for (let i = 0; i < data.length; i++) {
|
|
150
|
+
binary += String.fromCharCode(data[i]);
|
|
151
|
+
}
|
|
152
|
+
return btoa(binary);
|
|
153
|
+
}
|
|
154
|
+
export function fromBase64(b64) {
|
|
155
|
+
if (typeof Buffer !== "undefined") {
|
|
156
|
+
const buf = Buffer.from(b64, "base64");
|
|
157
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
158
|
+
}
|
|
159
|
+
const binary = atob(b64);
|
|
160
|
+
const bytes = new Uint8Array(binary.length);
|
|
161
|
+
for (let i = 0; i < binary.length; i++) {
|
|
162
|
+
bytes[i] = binary.charCodeAt(i);
|
|
163
|
+
}
|
|
164
|
+
return bytes;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=e2e-crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e-crypto.js","sourceRoot":"","sources":["../src/e2e-crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,GACV,OAAO,UAAU,CAAC,OAAO,KAAK,WAAW;IACzC,OAAO,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ,CAAC;AAExD,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,UAAU,GAAG,EAAE,CAAC,CAAC,WAAW;AAClC,MAAM,YAAY,GAAG,EAAE,CAAC,CAAC,wBAAwB;AACjD,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,UAAU,CAAC,GAAe;IACjC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,8EAA8E;AAC9E,2DAA2D;AAC3D,8EAA8E;AAE9E,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,QAAiB;IAC7D,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,MAAqB,EAAE,Q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
|
|
4
|
+
* Adds WTT as a first-class communication channel with:
|
|
5
|
+
* - Persistent WebSocket to WTT cloud
|
|
6
|
+
* - E2E encryption (AES-256-CTR with PBKDF2 key derivation)
|
|
7
|
+
* - A2UI interactive messages (buttons, selects, confirms)
|
|
8
|
+
* - Lifecycle hooks (before/after tool calls)
|
|
9
|
+
* - Multi-account support
|
|
10
|
+
*/
|
|
11
|
+
export { wttPlugin, processWTTCommandText } from "./channel.js";
|
|
12
|
+
export { createWTTCommandRouter, parseWTTCommandText } from "./commands/index.js";
|
|
13
|
+
export type { ParsedWTTCommand, WTTCommandProcessResult } from "./commands/index.js";
|
|
14
|
+
export { WTTCloudClient } from "./ws-client.js";
|
|
15
|
+
export type { WTTCloudClientOptions } from "./ws-client.js";
|
|
16
|
+
export { deriveKey, encryptText, decryptText, encryptBytes, decryptBytes, toBase64, fromBase64, } from "./e2e-crypto.js";
|
|
17
|
+
export { createSessionBindingPlaceholder, describeSessionBindingNextAction, buildProgressHeartbeat, validateTaskTransition, createTaskRunExecutorLoop, getSharedTaskRunExecutor, } from "./runtime/index.js";
|
|
18
|
+
export type { SessionBindingPlaceholder, ProgressHeartbeatPayload, RuntimeReviewAction, RuntimeTransitionIntent, RuntimeTransitionResult, TaskRunDetailPayload, TaskRunExecutionResult, TaskRunExecutorLoop, TaskRunExecutorLoopOptions, TaskRunExecutorRequest, TaskRunExecutorSnapshot, TaskRunInferenceRequest, TaskRunInferenceResult, TaskRunPersistenceAck, TaskRunSummaryPayload, } from "./runtime/index.js";
|
|
19
|
+
export type { WTTAccountConfig, ResolvedWTTAccount, WsAction, WsActionMessage, WsAuthMessage, WsActionResult, WsNewMessage, WsTaskStatus, WsServerMessage, WsMessagePayload, WsTopicPayload, ActionPayloads, E2EConfig, EncryptedContent, } from "./types.js";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,UAAU,GACX,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,aAAa,EACb,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,SAAS,EACT,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @wtt/plugin — WTT Channel Plugin for OpenClaw
|
|
3
|
+
*
|
|
4
|
+
* Adds WTT as a first-class communication channel with:
|
|
5
|
+
* - Persistent WebSocket to WTT cloud
|
|
6
|
+
* - E2E encryption (AES-256-CTR with PBKDF2 key derivation)
|
|
7
|
+
* - A2UI interactive messages (buttons, selects, confirms)
|
|
8
|
+
* - Lifecycle hooks (before/after tool calls)
|
|
9
|
+
* - Multi-account support
|
|
10
|
+
*/
|
|
11
|
+
// Plugin
|
|
12
|
+
export { wttPlugin, processWTTCommandText } from "./channel.js";
|
|
13
|
+
// Commands (@wtt ...)
|
|
14
|
+
export { createWTTCommandRouter, parseWTTCommandText } from "./commands/index.js";
|
|
15
|
+
// WebSocket Client
|
|
16
|
+
export { WTTCloudClient } from "./ws-client.js";
|
|
17
|
+
// E2E Crypto
|
|
18
|
+
export { deriveKey, encryptText, decryptText, encryptBytes, decryptBytes, toBase64, fromBase64, } from "./e2e-crypto.js";
|
|
19
|
+
// Runtime scaffolding (P3-prep)
|
|
20
|
+
export { createSessionBindingPlaceholder, describeSessionBindingNextAction, buildProgressHeartbeat, validateTaskTransition, createTaskRunExecutorLoop, getSharedTaskRunExecutor, } from "./runtime/index.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEhE,sBAAsB;AACtB,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGlF,mBAAmB;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,aAAa;AACb,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,gCAAgC;AAChC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { WTTAccountConfig } from "./types.js";
|
|
2
|
+
export type WTTConfigSection = {
|
|
3
|
+
accounts?: Record<string, WTTAccountConfig>;
|
|
4
|
+
defaultAccountId?: string;
|
|
5
|
+
} & WTTAccountConfig;
|
|
6
|
+
export type OpenClawConfigLike = {
|
|
7
|
+
channels?: {
|
|
8
|
+
wtt?: WTTConfigSection;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export type ConfigFieldSource = "openclaw" | "file" | "default";
|
|
12
|
+
export declare const WTT_ACCOUNT_FIELD_NAMES: readonly ["enabled", "name", "cloudUrl", "agentId", "token", "e2ePassword", "inboundPollIntervalMs", "inboundPollLimit", "inboundDedupWindowMs", "inboundDedupMaxEntries"];
|
|
13
|
+
export type WTTAccountFieldName = typeof WTT_ACCOUNT_FIELD_NAMES[number];
|
|
14
|
+
export type AccountFieldSourceMap = Partial<Record<WTTAccountFieldName, ConfigFieldSource>>;
|
|
15
|
+
export type PluginConfigFileStatus = {
|
|
16
|
+
path: string;
|
|
17
|
+
envOverride: boolean;
|
|
18
|
+
loaded: boolean;
|
|
19
|
+
exists: boolean;
|
|
20
|
+
error?: string;
|
|
21
|
+
defaultAccountId: string;
|
|
22
|
+
};
|
|
23
|
+
export type EffectiveWTTConfig = {
|
|
24
|
+
defaultAccountId: string;
|
|
25
|
+
accounts: Record<string, WTTAccountConfig>;
|
|
26
|
+
accountSources: Record<string, string>;
|
|
27
|
+
accountFieldSources: Record<string, AccountFieldSourceMap>;
|
|
28
|
+
fileStatus: PluginConfigFileStatus;
|
|
29
|
+
};
|
|
30
|
+
export declare function resolveEffectiveWTTConfig(cfg: OpenClawConfigLike | undefined): EffectiveWTTConfig;
|
|
31
|
+
export declare function resetPluginConfigCacheForTests(): void;
|
|
32
|
+
//# sourceMappingURL=plugin-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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