koishi-plugin-dynamic-bot 0.0.0-dev

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.
@@ -0,0 +1,239 @@
1
+ import { create } from "@bufbuild/protobuf";
2
+ import { ErrorCode, RpcErrorSchema } from "../gen/dbk/v1/common_pb";
3
+ import { FrameOp, type Frame } from "../gen/dbk/v1/frame_pb";
4
+ import { createFrame, decodePayload, encodeFrame, encodePayload } from "./codec";
5
+ import { DbkRpcError } from "./error";
6
+ import {
7
+ DbkEventCodecs,
8
+ DbkMethod,
9
+ DbkRpcCodecs,
10
+ PING_INTERVAL_MS,
11
+ PONG_TIMEOUT_MS,
12
+ PROTOCOL_VERSION,
13
+ type DbkEncoding,
14
+ type DbkEventMap,
15
+ type DbkGatewayHandlers,
16
+ type DbkRpcMap,
17
+ } from "./protocol";
18
+
19
+ export interface DbkLogger {
20
+ debug(...args: unknown[]): void;
21
+ info(...args: unknown[]): void;
22
+ warn(...args: unknown[]): void;
23
+ error(...args: unknown[]): void;
24
+ }
25
+
26
+ export interface DbkSessionOptions {
27
+ encoding: DbkEncoding;
28
+ accessToken: string;
29
+ handlers: DbkGatewayHandlers;
30
+ logger: DbkLogger;
31
+ send: (data: Uint8Array | string) => void;
32
+ onDead: (reason: string) => void;
33
+ onUnauthorized?: () => void;
34
+ now?: () => number;
35
+ }
36
+
37
+ export class DbkGatewaySession {
38
+ private closed = false;
39
+ private handshook = false;
40
+ private seq = 0n;
41
+ private sendQueue = Promise.resolve();
42
+ private lastInboundAt: number;
43
+ private heartbeat: ReturnType<typeof setInterval> | undefined;
44
+ private readonly now: () => number;
45
+
46
+ constructor(private readonly options: DbkSessionOptions) {
47
+ this.now = options.now ?? Date.now;
48
+ this.lastInboundAt = this.now();
49
+ }
50
+
51
+ get isHandshook(): boolean {
52
+ return this.handshook && !this.closed;
53
+ }
54
+
55
+ onFrame(frame: Frame): void {
56
+ if (this.closed) return;
57
+ this.lastInboundAt = this.now();
58
+ void this.handle(frame);
59
+ }
60
+
61
+ rejectText(): void {
62
+ this.fail("DBK only accepts protobuf binary frames");
63
+ }
64
+
65
+ rejectDecode(error: unknown): void {
66
+ this.options.logger.warn("DBK frame decode failed: %s", error);
67
+ this.fail("DBK frame could not be decoded");
68
+ }
69
+
70
+ emit<K extends keyof DbkEventMap>(method: K, event: DbkEventMap[K]): void {
71
+ if (!this.isHandshook) return;
72
+ this.seq += 1n;
73
+ this.enqueueFrame(
74
+ createFrame({
75
+ op: FrameOp.EVENT,
76
+ seq: this.seq,
77
+ method,
78
+ payload: encodePayload(DbkEventCodecs[method], event as never),
79
+ }),
80
+ );
81
+ }
82
+
83
+ close(reason = "closed"): void {
84
+ if (this.closed) return;
85
+ this.closed = true;
86
+ this.handshook = false;
87
+ if (this.heartbeat) {
88
+ clearInterval(this.heartbeat);
89
+ this.heartbeat = undefined;
90
+ }
91
+ this.options.logger.debug("DBK session closed: %s", reason);
92
+ }
93
+
94
+ private async handle(frame: Frame): Promise<void> {
95
+ switch (frame.op) {
96
+ case FrameOp.PING:
97
+ if (!this.handshook) return;
98
+ this.enqueueFrame(createFrame({ op: FrameOp.PONG, id: frame.id }));
99
+ return;
100
+ case FrameOp.PONG:
101
+ return;
102
+ case FrameOp.CALL:
103
+ await this.handleCall(frame);
104
+ return;
105
+ case FrameOp.EVENT:
106
+ case FrameOp.OK:
107
+ case FrameOp.ERROR:
108
+ this.options.logger.debug("gateway ignored peer %s: method=%s", FrameOp[frame.op], frame.method);
109
+ return;
110
+ default:
111
+ this.options.logger.warn("ignored DBK frame with unspecified op");
112
+ }
113
+ }
114
+
115
+ private async handleCall(frame: Frame): Promise<void> {
116
+ if (!frame.id) {
117
+ this.replyError("", ErrorCode.PROTOCOL, "CALL is missing id");
118
+ return;
119
+ }
120
+ if (!this.handshook && frame.method !== DbkMethod.SESSION_HELLO) {
121
+ this.options.logger.debug("drop CALL before handshake: method=%s", frame.method);
122
+ this.replyError(frame.id, ErrorCode.PROTOCOL, "DBK handshake is not complete");
123
+ return;
124
+ }
125
+ if (!(frame.method in DbkRpcCodecs)) {
126
+ this.replyError(frame.id, ErrorCode.UNSUPPORTED, `unknown method: ${frame.method}`);
127
+ return;
128
+ }
129
+ try {
130
+ const payload = await this.dispatchCall(frame.method, frame.payload);
131
+ this.enqueueFrame(
132
+ createFrame({
133
+ op: FrameOp.OK,
134
+ id: frame.id,
135
+ method: frame.method,
136
+ payload,
137
+ }),
138
+ );
139
+ } catch (error) {
140
+ const rpcError = error instanceof DbkRpcError
141
+ ? error
142
+ : new DbkRpcError(ErrorCode.INTERNAL, error instanceof Error ? error.message : String(error));
143
+ this.options.logger.warn("DBK RPC failed: method=%s code=%s %s", frame.method, ErrorCode[rpcError.code], rpcError.message);
144
+ this.replyError(frame.id, rpcError.code, rpcError.message);
145
+ if (frame.method === DbkMethod.SESSION_HELLO && rpcError.code === ErrorCode.UNAUTHORIZED) {
146
+ this.options.onUnauthorized?.();
147
+ await this.sendQueue;
148
+ this.fail(rpcError.message);
149
+ }
150
+ }
151
+ }
152
+
153
+ private dispatchCall(method: string, payload: Uint8Array): Promise<Uint8Array> {
154
+ switch (method) {
155
+ case DbkMethod.SESSION_HELLO:
156
+ return this.runRpc(method, payload, (request) => this.hello(request));
157
+ case DbkMethod.BOTS_LIST:
158
+ case DbkMethod.TARGETS_LIST:
159
+ case DbkMethod.TARGETS_GET:
160
+ case DbkMethod.MESSAGE_SEND:
161
+ case DbkMethod.MESSAGE_RECALL:
162
+ return this.runRpc(method, payload, this.options.handlers[method]);
163
+ default:
164
+ return Promise.reject(new DbkRpcError(ErrorCode.UNSUPPORTED, `unknown method: ${method}`));
165
+ }
166
+ }
167
+
168
+ private async runRpc<K extends keyof DbkRpcMap>(
169
+ method: K,
170
+ payload: Uint8Array,
171
+ handler: DbkGatewayHandlers[K],
172
+ ): Promise<Uint8Array> {
173
+ const codec = DbkRpcCodecs[method];
174
+ const request = decodePayload(codec.request, payload);
175
+ const response = await handler(request);
176
+ return encodePayload(codec.response, response);
177
+ }
178
+
179
+ private async hello(request: DbkRpcMap[typeof DbkMethod.SESSION_HELLO]["request"]): Promise<DbkRpcMap[typeof DbkMethod.SESSION_HELLO]["response"]> {
180
+ if (request.token !== this.options.accessToken) {
181
+ throw new DbkRpcError(ErrorCode.UNAUTHORIZED, "invalid access token");
182
+ }
183
+ const remote = request.protocolVersion.trim();
184
+ if (remote && remote !== PROTOCOL_VERSION) {
185
+ throw new DbkRpcError(
186
+ ErrorCode.PROTOCOL,
187
+ `protocol version mismatch: local=${PROTOCOL_VERSION} remote=${remote}`,
188
+ );
189
+ }
190
+ const response = await this.options.handlers[DbkMethod.SESSION_HELLO](request);
191
+ this.handshook = true;
192
+ this.startHeartbeat();
193
+ this.options.logger.info(
194
+ "DBK handshake complete: bots=%d app=%s",
195
+ response.bots.length,
196
+ request.appVersion || "-",
197
+ );
198
+ return response;
199
+ }
200
+
201
+ private replyError(id: string, code: ErrorCode, detail: string): void {
202
+ this.enqueueFrame(
203
+ createFrame({
204
+ op: FrameOp.ERROR,
205
+ id,
206
+ error: create(RpcErrorSchema, { code, detail }),
207
+ }),
208
+ );
209
+ }
210
+
211
+ private startHeartbeat(): void {
212
+ if (this.heartbeat) clearInterval(this.heartbeat);
213
+ this.lastInboundAt = this.now();
214
+ this.heartbeat = setInterval(() => {
215
+ if (this.closed) return;
216
+ if (this.now() - this.lastInboundAt >= PONG_TIMEOUT_MS) {
217
+ this.fail("DBK heartbeat timed out");
218
+ return;
219
+ }
220
+ this.enqueueFrame(createFrame({ op: FrameOp.PING }));
221
+ }, PING_INTERVAL_MS);
222
+ }
223
+
224
+ private enqueueFrame(frame: Frame): void {
225
+ this.sendQueue = this.sendQueue.then(() => {
226
+ if (this.closed) return;
227
+ this.options.send(encodeFrame(frame, this.options.encoding));
228
+ }).catch((error) => {
229
+ this.options.logger.warn("DBK send failed: %s", error);
230
+ this.fail("DBK send failed");
231
+ });
232
+ }
233
+
234
+ private fail(reason: string): void {
235
+ if (this.closed) return;
236
+ this.options.onDead(reason);
237
+ this.close(reason);
238
+ }
239
+ }
@@ -0,0 +1,52 @@
1
+ import { decodeFrame, toBytes } from "./codec";
2
+ import type { DbkEncoding } from "./protocol";
3
+ import type { DbkGatewaySession } from "./session";
4
+
5
+ export interface DbkSocket {
6
+ readyState: number;
7
+ binaryType?: string;
8
+ send(data: Uint8Array | string): void;
9
+ close(code?: number, reason?: string): void;
10
+ on?(event: string, listener: (...args: unknown[]) => void): void;
11
+ addEventListener?(type: string, listener: (event: { data?: unknown; code?: number; reason?: string }) => void): void;
12
+ }
13
+
14
+ export const WS_OPEN = 1;
15
+
16
+ export function sendSocket(socket: DbkSocket, data: Uint8Array | string): void {
17
+ if (socket.readyState !== WS_OPEN) {
18
+ throw new Error("WebSocket is not open");
19
+ }
20
+ socket.send(data);
21
+ }
22
+
23
+ export function attachSocket(socket: DbkSocket, session: DbkGatewaySession, encoding: DbkEncoding): void {
24
+ if (socket.binaryType !== undefined) {
25
+ socket.binaryType = "arraybuffer";
26
+ }
27
+
28
+ const onMessage = (data: unknown, isBinary?: boolean) => {
29
+ const binary = isBinary ?? typeof data !== "string";
30
+ if (encoding === "binary" && !binary) {
31
+ session.rejectText();
32
+ return;
33
+ }
34
+ try {
35
+ const raw = typeof data === "string" ? data : toBytes(data);
36
+ session.onFrame(decodeFrame(raw, encoding));
37
+ } catch (error) {
38
+ session.rejectDecode(error);
39
+ }
40
+ };
41
+
42
+ const onClose = () => session.close("ws close");
43
+
44
+ if (typeof socket.on === "function") {
45
+ socket.on("message", (data, isBinary) => onMessage(data, isBinary as boolean | undefined));
46
+ socket.on("close", onClose);
47
+ return;
48
+ }
49
+
50
+ socket.addEventListener?.("message", (event) => onMessage(event.data));
51
+ socket.addEventListener?.("close", onClose);
52
+ }
@@ -0,0 +1,65 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const FALLBACK = "0.0.0-dev";
7
+
8
+ function hereDir(): string {
9
+ try {
10
+ return dirname(fileURLToPath(import.meta.url));
11
+ } catch {
12
+ return process.cwd();
13
+ }
14
+ }
15
+
16
+ function packageDir(): string {
17
+ const fromHere = join(hereDir(), "..", "..");
18
+ if (existsSync(join(fromHere, "package.json"))) return fromHere;
19
+ const fromCwd = join(process.cwd(), "koishi");
20
+ if (existsSync(join(fromCwd, "package.json"))) return fromCwd;
21
+ return process.cwd();
22
+ }
23
+
24
+ function isProductRepo(root: string): boolean {
25
+ return (
26
+ existsSync(join(root, "pnpm-workspace.yaml")) &&
27
+ existsSync(join(root, "jvm", "build.gradle.kts")) &&
28
+ existsSync(join(root, "koishi", "package.json"))
29
+ );
30
+ }
31
+
32
+ function gitDescribe(cwd: string): string | undefined {
33
+ try {
34
+ const described = execFileSync(
35
+ "git",
36
+ ["describe", "--tags", "--always", "--abbrev=7", "--dirty"],
37
+ { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] },
38
+ ).trim();
39
+ return described || undefined;
40
+ } catch {
41
+ return undefined;
42
+ }
43
+ }
44
+
45
+ function packageVersion(dir: string): string {
46
+ try {
47
+ const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8")) as {
48
+ version?: string;
49
+ };
50
+ return pkg.version?.trim() || FALLBACK;
51
+ } catch {
52
+ return FALLBACK;
53
+ }
54
+ }
55
+
56
+ function resolveGatewayVersion(): string {
57
+ const pkg = packageDir();
58
+ const repoRoot = join(pkg, "..");
59
+ if (isProductRepo(repoRoot)) {
60
+ return gitDescribe(repoRoot) ?? packageVersion(pkg);
61
+ }
62
+ return packageVersion(pkg);
63
+ }
64
+
65
+ export const GATEWAY_VERSION = resolveGatewayVersion();
@@ -0,0 +1,238 @@
1
+ // @generated by protoc-gen-es v2.12.1 with parameter "target=ts"
2
+ // @generated from file dbk/v1/common.proto (package dbk.v1, syntax proto3)
3
+ /* eslint-disable */
4
+
5
+ import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
6
+ import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
7
+ import type { Message } from "@bufbuild/protobuf";
8
+
9
+ /**
10
+ * Describes the file dbk/v1/common.proto.
11
+ */
12
+ export const file_dbk_v1_common: GenFile = /*@__PURE__*/
13
+ fileDesc("ChNkYmsvdjEvY29tbW9uLnByb3RvEgZkYmsudjEiSAoGVGFyZ2V0EiAKBGtpbmQYASABKA4yEi5kYmsudjEuVGFyZ2V0S2luZBIKCgJpZBgCIAEoCRIQCghndWlsZF9pZBgDIAEoCSI7CghScGNFcnJvchIfCgRjb2RlGAEgASgOMhEuZGJrLnYxLkVycm9yQ29kZRIOCgZkZXRhaWwYAiABKAkqhwEKClRhcmdldEtpbmQSGwoXVEFSR0VUX0tJTkRfVU5TUEVDSUZJRUQQABIUChBUQVJHRVRfS0lORF9VU0VSEAESFQoRVEFSR0VUX0tJTkRfR1JPVVAQAhIXChNUQVJHRVRfS0lORF9DSEFOTkVMEAMSFgoSVEFSR0VUX0tJTkRfVEhSRUFEEAQqdAoJQm90U3RhdHVzEhoKFkJPVF9TVEFUVVNfVU5TUEVDSUZJRUQQABIUChBCT1RfU1RBVFVTX1JFQURZEAESGgoWQk9UX1NUQVRVU19VTkFWQUlMQUJMRRACEhkKFUJPVF9TVEFUVVNfQ09OTkVDVElORxADKocBCgpTZW5kU3RhdHVzEhsKF1NFTkRfU1RBVFVTX1VOU1BFQ0lGSUVEEAASEgoOU0VORF9TVEFUVVNfT0sQARIXChNTRU5EX1NUQVRVU19QQVJUSUFMEAISFwoTU0VORF9TVEFUVVNfVU5LTk9XThADEhYKElNFTkRfU1RBVFVTX0ZBSUxFRBAEKqwBCglFcnJvckNvZGUSGgoWRVJST1JfQ09ERV9VTlNQRUNJRklFRBAAEhsKF0VSUk9SX0NPREVfVU5BVVRIT1JJWkVEEAESFwoTRVJST1JfQ09ERV9QUk9UT0NPTBACEhgKFEVSUk9SX0NPREVfTk9UX0ZPVU5EEAMSGgoWRVJST1JfQ09ERV9VTlNVUFBPUlRFRBAEEhcKE0VSUk9SX0NPREVfSU5URVJOQUwQBSqFAQoNQm90Q2hhbmdlVHlwZRIfChtCT1RfQ0hBTkdFX1RZUEVfVU5TUEVDSUZJRUQQABIZChVCT1RfQ0hBTkdFX1RZUEVfQURERUQQARIbChdCT1RfQ0hBTkdFX1RZUEVfVVBEQVRFRBACEhsKF0JPVF9DSEFOR0VfVFlQRV9SRU1PVkVEEANiBnByb3RvMw");
14
+
15
+ /**
16
+ * @generated from message dbk.v1.Target
17
+ */
18
+ export type Target = Message<"dbk.v1.Target"> & {
19
+ /**
20
+ * @generated from field: dbk.v1.TargetKind kind = 1;
21
+ */
22
+ kind: TargetKind;
23
+
24
+ /**
25
+ * @generated from field: string id = 2;
26
+ */
27
+ id: string;
28
+
29
+ /**
30
+ * @generated from field: string guild_id = 3;
31
+ */
32
+ guildId: string;
33
+ };
34
+
35
+ /**
36
+ * Describes the message dbk.v1.Target.
37
+ * Use `create(TargetSchema)` to create a new message.
38
+ */
39
+ export const TargetSchema: GenMessage<Target> = /*@__PURE__*/
40
+ messageDesc(file_dbk_v1_common, 0);
41
+
42
+ /**
43
+ * @generated from message dbk.v1.RpcError
44
+ */
45
+ export type RpcError = Message<"dbk.v1.RpcError"> & {
46
+ /**
47
+ * @generated from field: dbk.v1.ErrorCode code = 1;
48
+ */
49
+ code: ErrorCode;
50
+
51
+ /**
52
+ * @generated from field: string detail = 2;
53
+ */
54
+ detail: string;
55
+ };
56
+
57
+ /**
58
+ * Describes the message dbk.v1.RpcError.
59
+ * Use `create(RpcErrorSchema)` to create a new message.
60
+ */
61
+ export const RpcErrorSchema: GenMessage<RpcError> = /*@__PURE__*/
62
+ messageDesc(file_dbk_v1_common, 1);
63
+
64
+ /**
65
+ * @generated from enum dbk.v1.TargetKind
66
+ */
67
+ export enum TargetKind {
68
+ /**
69
+ * @generated from enum value: TARGET_KIND_UNSPECIFIED = 0;
70
+ */
71
+ UNSPECIFIED = 0,
72
+
73
+ /**
74
+ * @generated from enum value: TARGET_KIND_USER = 1;
75
+ */
76
+ USER = 1,
77
+
78
+ /**
79
+ * @generated from enum value: TARGET_KIND_GROUP = 2;
80
+ */
81
+ GROUP = 2,
82
+
83
+ /**
84
+ * @generated from enum value: TARGET_KIND_CHANNEL = 3;
85
+ */
86
+ CHANNEL = 3,
87
+
88
+ /**
89
+ * @generated from enum value: TARGET_KIND_THREAD = 4;
90
+ */
91
+ THREAD = 4,
92
+ }
93
+
94
+ /**
95
+ * Describes the enum dbk.v1.TargetKind.
96
+ */
97
+ export const TargetKindSchema: GenEnum<TargetKind> = /*@__PURE__*/
98
+ enumDesc(file_dbk_v1_common, 0);
99
+
100
+ /**
101
+ * @generated from enum dbk.v1.BotStatus
102
+ */
103
+ export enum BotStatus {
104
+ /**
105
+ * @generated from enum value: BOT_STATUS_UNSPECIFIED = 0;
106
+ */
107
+ UNSPECIFIED = 0,
108
+
109
+ /**
110
+ * @generated from enum value: BOT_STATUS_READY = 1;
111
+ */
112
+ READY = 1,
113
+
114
+ /**
115
+ * @generated from enum value: BOT_STATUS_UNAVAILABLE = 2;
116
+ */
117
+ UNAVAILABLE = 2,
118
+
119
+ /**
120
+ * @generated from enum value: BOT_STATUS_CONNECTING = 3;
121
+ */
122
+ CONNECTING = 3,
123
+ }
124
+
125
+ /**
126
+ * Describes the enum dbk.v1.BotStatus.
127
+ */
128
+ export const BotStatusSchema: GenEnum<BotStatus> = /*@__PURE__*/
129
+ enumDesc(file_dbk_v1_common, 1);
130
+
131
+ /**
132
+ * @generated from enum dbk.v1.SendStatus
133
+ */
134
+ export enum SendStatus {
135
+ /**
136
+ * @generated from enum value: SEND_STATUS_UNSPECIFIED = 0;
137
+ */
138
+ UNSPECIFIED = 0,
139
+
140
+ /**
141
+ * @generated from enum value: SEND_STATUS_OK = 1;
142
+ */
143
+ OK = 1,
144
+
145
+ /**
146
+ * @generated from enum value: SEND_STATUS_PARTIAL = 2;
147
+ */
148
+ PARTIAL = 2,
149
+
150
+ /**
151
+ * @generated from enum value: SEND_STATUS_UNKNOWN = 3;
152
+ */
153
+ UNKNOWN = 3,
154
+
155
+ /**
156
+ * @generated from enum value: SEND_STATUS_FAILED = 4;
157
+ */
158
+ FAILED = 4,
159
+ }
160
+
161
+ /**
162
+ * Describes the enum dbk.v1.SendStatus.
163
+ */
164
+ export const SendStatusSchema: GenEnum<SendStatus> = /*@__PURE__*/
165
+ enumDesc(file_dbk_v1_common, 2);
166
+
167
+ /**
168
+ * @generated from enum dbk.v1.ErrorCode
169
+ */
170
+ export enum ErrorCode {
171
+ /**
172
+ * @generated from enum value: ERROR_CODE_UNSPECIFIED = 0;
173
+ */
174
+ UNSPECIFIED = 0,
175
+
176
+ /**
177
+ * @generated from enum value: ERROR_CODE_UNAUTHORIZED = 1;
178
+ */
179
+ UNAUTHORIZED = 1,
180
+
181
+ /**
182
+ * @generated from enum value: ERROR_CODE_PROTOCOL = 2;
183
+ */
184
+ PROTOCOL = 2,
185
+
186
+ /**
187
+ * @generated from enum value: ERROR_CODE_NOT_FOUND = 3;
188
+ */
189
+ NOT_FOUND = 3,
190
+
191
+ /**
192
+ * @generated from enum value: ERROR_CODE_UNSUPPORTED = 4;
193
+ */
194
+ UNSUPPORTED = 4,
195
+
196
+ /**
197
+ * @generated from enum value: ERROR_CODE_INTERNAL = 5;
198
+ */
199
+ INTERNAL = 5,
200
+ }
201
+
202
+ /**
203
+ * Describes the enum dbk.v1.ErrorCode.
204
+ */
205
+ export const ErrorCodeSchema: GenEnum<ErrorCode> = /*@__PURE__*/
206
+ enumDesc(file_dbk_v1_common, 3);
207
+
208
+ /**
209
+ * @generated from enum dbk.v1.BotChangeType
210
+ */
211
+ export enum BotChangeType {
212
+ /**
213
+ * @generated from enum value: BOT_CHANGE_TYPE_UNSPECIFIED = 0;
214
+ */
215
+ UNSPECIFIED = 0,
216
+
217
+ /**
218
+ * @generated from enum value: BOT_CHANGE_TYPE_ADDED = 1;
219
+ */
220
+ ADDED = 1,
221
+
222
+ /**
223
+ * @generated from enum value: BOT_CHANGE_TYPE_UPDATED = 2;
224
+ */
225
+ UPDATED = 2,
226
+
227
+ /**
228
+ * @generated from enum value: BOT_CHANGE_TYPE_REMOVED = 3;
229
+ */
230
+ REMOVED = 3,
231
+ }
232
+
233
+ /**
234
+ * Describes the enum dbk.v1.BotChangeType.
235
+ */
236
+ export const BotChangeTypeSchema: GenEnum<BotChangeType> = /*@__PURE__*/
237
+ enumDesc(file_dbk_v1_common, 4);
238
+
@@ -0,0 +1,114 @@
1
+ // @generated by protoc-gen-es v2.12.1 with parameter "target=ts"
2
+ // @generated from file dbk/v1/frame.proto (package dbk.v1, syntax proto3)
3
+ /* eslint-disable */
4
+
5
+ import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
6
+ import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
7
+ import type { RpcError } from "./common_pb";
8
+ import { file_dbk_v1_common } from "./common_pb";
9
+ import type { Message } from "@bufbuild/protobuf";
10
+
11
+ /**
12
+ * Describes the file dbk/v1/frame.proto.
13
+ */
14
+ export const file_dbk_v1_frame: GenFile = /*@__PURE__*/
15
+ fileDesc("ChJkYmsvdjEvZnJhbWUucHJvdG8SBmRiay52MSJ/CgVGcmFtZRIbCgJvcBgBIAEoDjIPLmRiay52MS5GcmFtZU9wEgoKAmlkGAIgASgJEgsKA3NlcRgDIAEoBBIOCgZtZXRob2QYBCABKAkSDwoHcGF5bG9hZBgFIAEoDBIfCgVlcnJvchgGIAEoCzIQLmRiay52MS5ScGNFcnJvciqVAQoHRnJhbWVPcBIYChRGUkFNRV9PUF9VTlNQRUNJRklFRBAAEhEKDUZSQU1FX09QX0NBTEwQARIPCgtGUkFNRV9PUF9PSxACEhIKDkZSQU1FX09QX0VSUk9SEAMSEgoORlJBTUVfT1BfRVZFTlQQBBIRCg1GUkFNRV9PUF9QSU5HEAUSEQoNRlJBTUVfT1BfUE9ORxAGYgZwcm90bzM", [file_dbk_v1_common]);
16
+
17
+ /**
18
+ * @generated from message dbk.v1.Frame
19
+ */
20
+ export type Frame = Message<"dbk.v1.Frame"> & {
21
+ /**
22
+ * @generated from field: dbk.v1.FrameOp op = 1;
23
+ */
24
+ op: FrameOp;
25
+
26
+ /**
27
+ * CALL / OK / ERROR. Generated by the caller.
28
+ *
29
+ * @generated from field: string id = 2;
30
+ */
31
+ id: string;
32
+
33
+ /**
34
+ * EVENT only. Monotonic per connection; v1 does not resume by seq.
35
+ *
36
+ * @generated from field: uint64 seq = 3;
37
+ */
38
+ seq: bigint;
39
+
40
+ /**
41
+ * CALL / EVENT method name, e.g. `session.hello`, `message.created`.
42
+ *
43
+ * @generated from field: string method = 4;
44
+ */
45
+ method: string;
46
+
47
+ /**
48
+ * Encoded request, response, or event body for `method`.
49
+ *
50
+ * @generated from field: bytes payload = 5;
51
+ */
52
+ payload: Uint8Array;
53
+
54
+ /**
55
+ * ERROR only. Business send failures use OK + SendStatus, not this.
56
+ *
57
+ * @generated from field: dbk.v1.RpcError error = 6;
58
+ */
59
+ error?: RpcError | undefined;
60
+ };
61
+
62
+ /**
63
+ * Describes the message dbk.v1.Frame.
64
+ * Use `create(FrameSchema)` to create a new message.
65
+ */
66
+ export const FrameSchema: GenMessage<Frame> = /*@__PURE__*/
67
+ messageDesc(file_dbk_v1_frame, 0);
68
+
69
+ /**
70
+ * @generated from enum dbk.v1.FrameOp
71
+ */
72
+ export enum FrameOp {
73
+ /**
74
+ * @generated from enum value: FRAME_OP_UNSPECIFIED = 0;
75
+ */
76
+ UNSPECIFIED = 0,
77
+
78
+ /**
79
+ * @generated from enum value: FRAME_OP_CALL = 1;
80
+ */
81
+ CALL = 1,
82
+
83
+ /**
84
+ * @generated from enum value: FRAME_OP_OK = 2;
85
+ */
86
+ OK = 2,
87
+
88
+ /**
89
+ * @generated from enum value: FRAME_OP_ERROR = 3;
90
+ */
91
+ ERROR = 3,
92
+
93
+ /**
94
+ * @generated from enum value: FRAME_OP_EVENT = 4;
95
+ */
96
+ EVENT = 4,
97
+
98
+ /**
99
+ * @generated from enum value: FRAME_OP_PING = 5;
100
+ */
101
+ PING = 5,
102
+
103
+ /**
104
+ * @generated from enum value: FRAME_OP_PONG = 6;
105
+ */
106
+ PONG = 6,
107
+ }
108
+
109
+ /**
110
+ * Describes the enum dbk.v1.FrameOp.
111
+ */
112
+ export const FrameOpSchema: GenEnum<FrameOp> = /*@__PURE__*/
113
+ enumDesc(file_dbk_v1_frame, 0);
114
+