opencode-telegram-link 1.0.0-rc.1
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 +464 -0
- package/container/broker.Dockerfile +30 -0
- package/container/entrypoint.sh +19 -0
- package/dist/broker/commands.d.ts +17 -0
- package/dist/broker/commands.d.ts.map +1 -0
- package/dist/broker/dashboard-html.d.ts +2 -0
- package/dist/broker/dashboard-html.d.ts.map +1 -0
- package/dist/broker/index.d.ts +3 -0
- package/dist/broker/index.d.ts.map +1 -0
- package/dist/broker/main.d.ts +3 -0
- package/dist/broker/main.d.ts.map +1 -0
- package/dist/broker/main.js +21896 -0
- package/dist/broker/main.js.map +110 -0
- package/dist/broker/registry.d.ts +92 -0
- package/dist/broker/registry.d.ts.map +1 -0
- package/dist/broker/server.d.ts +133 -0
- package/dist/broker/server.d.ts.map +1 -0
- package/dist/config.d.ts +76 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/doctor.d.ts +21 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/i18n/catalogs.d.ts +120 -0
- package/dist/i18n/catalogs.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +10 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/opencode/bridge.d.ts +39 -0
- package/dist/opencode/bridge.d.ts.map +1 -0
- package/dist/opencode/config-helper.d.ts +20 -0
- package/dist/opencode/config-helper.d.ts.map +1 -0
- package/dist/opencode/events.d.ts +47 -0
- package/dist/opencode/events.d.ts.map +1 -0
- package/dist/opencode/index.d.ts +4 -0
- package/dist/opencode/index.d.ts.map +1 -0
- package/dist/plugin/client.d.ts +57 -0
- package/dist/plugin/client.d.ts.map +1 -0
- package/dist/plugin/commands.d.ts +4 -0
- package/dist/plugin/commands.d.ts.map +1 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +16913 -0
- package/dist/plugin.js.map +95 -0
- package/dist/protocol/index.d.ts +792 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +14540 -0
- package/dist/protocol/index.js.map +84 -0
- package/dist/setup.d.ts +77 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/state/database.d.ts +159 -0
- package/dist/state/database.d.ts.map +1 -0
- package/dist/state/discovery.d.ts +16 -0
- package/dist/state/discovery.d.ts.map +1 -0
- package/dist/state/identity.d.ts +19 -0
- package/dist/state/identity.d.ts.map +1 -0
- package/dist/state/index.d.ts +4 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/telegram/api.d.ts +212 -0
- package/dist/telegram/api.d.ts.map +1 -0
- package/dist/telegram/authorization.d.ts +25 -0
- package/dist/telegram/authorization.d.ts.map +1 -0
- package/dist/telegram/commands.d.ts +20 -0
- package/dist/telegram/commands.d.ts.map +1 -0
- package/dist/telegram/index.d.ts +9 -0
- package/dist/telegram/index.d.ts.map +1 -0
- package/dist/telegram/interaction.d.ts +49 -0
- package/dist/telegram/interaction.d.ts.map +1 -0
- package/dist/telegram/outbox.d.ts +46 -0
- package/dist/telegram/outbox.d.ts.map +1 -0
- package/dist/telegram/poller.d.ts +26 -0
- package/dist/telegram/poller.d.ts.map +1 -0
- package/dist/telegram/render.d.ts +16 -0
- package/dist/telegram/render.d.ts.map +1 -0
- package/dist/telegram/transcriber.d.ts +20 -0
- package/dist/telegram/transcriber.d.ts.map +1 -0
- package/dist/uninstall.d.ts +12 -0
- package/dist/uninstall.d.ts.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/docker-compose.yml +19 -0
- package/package.json +73 -0
package/dist/setup.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type NotifierConfig } from "./config";
|
|
2
|
+
import type { SupportedLocale } from "./i18n";
|
|
3
|
+
import { type TelegramBot } from "./telegram/api";
|
|
4
|
+
export declare function resolveDockerComposeContext(cwd?: string, explicitComposePath?: string): {
|
|
5
|
+
composeFile: string;
|
|
6
|
+
projectDir: string;
|
|
7
|
+
} | undefined;
|
|
8
|
+
export type PairingCandidate = {
|
|
9
|
+
userId: string;
|
|
10
|
+
chatId: string;
|
|
11
|
+
updateId: number;
|
|
12
|
+
};
|
|
13
|
+
export type GuidedSetupResult = {
|
|
14
|
+
status: "ready";
|
|
15
|
+
bot: Pick<TelegramBot, "id" | "username">;
|
|
16
|
+
config: NotifierConfig;
|
|
17
|
+
tokenFile: string;
|
|
18
|
+
readyForTestNotification: true;
|
|
19
|
+
pairing?: PairingCandidate;
|
|
20
|
+
} | {
|
|
21
|
+
status: "confirmation_required";
|
|
22
|
+
bot: Pick<TelegramBot, "id" | "username">;
|
|
23
|
+
nonce: string;
|
|
24
|
+
expiresAt: number;
|
|
25
|
+
pairing: PairingCandidate;
|
|
26
|
+
};
|
|
27
|
+
export type GuidedSetupOptions = {
|
|
28
|
+
botToken: string;
|
|
29
|
+
locale?: SupportedLocale;
|
|
30
|
+
userId?: string;
|
|
31
|
+
chatId?: string;
|
|
32
|
+
stateDirectory?: string;
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
fetch?: typeof fetch;
|
|
35
|
+
now?: () => number;
|
|
36
|
+
pairing?: {
|
|
37
|
+
enabled: true;
|
|
38
|
+
nonce?: string;
|
|
39
|
+
expiresInMs?: number;
|
|
40
|
+
pollTimeoutSeconds?: number;
|
|
41
|
+
confirm?: (candidate: PairingCandidate) => boolean | Promise<boolean>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type InteractiveSetupOptions = {
|
|
45
|
+
stdin?: AsyncIterable<Buffer | string> | NodeJS.ReadableStream | undefined;
|
|
46
|
+
stdout?: Pick<NodeJS.WriteStream, "write"> | undefined;
|
|
47
|
+
stderr?: Pick<NodeJS.WriteStream, "write"> | undefined;
|
|
48
|
+
env?: NodeJS.ProcessEnv | undefined;
|
|
49
|
+
fetch?: typeof fetch | undefined;
|
|
50
|
+
stateDirectory?: string | undefined;
|
|
51
|
+
cwd?: string | undefined;
|
|
52
|
+
now?: (() => number) | undefined;
|
|
53
|
+
};
|
|
54
|
+
export declare class SetupError extends Error {
|
|
55
|
+
readonly code: string;
|
|
56
|
+
constructor(code: string, message: string);
|
|
57
|
+
}
|
|
58
|
+
export declare class AsyncPromptReader {
|
|
59
|
+
private iterator;
|
|
60
|
+
private buffer;
|
|
61
|
+
constructor(input: AsyncIterable<Buffer | string> | NodeJS.ReadableStream);
|
|
62
|
+
readLine(): Promise<string>;
|
|
63
|
+
ask(promptText: string, stdout: Pick<NodeJS.WriteStream, "write">, defaultValue?: string): Promise<string>;
|
|
64
|
+
}
|
|
65
|
+
export declare function runGuidedSetup(options: GuidedSetupOptions): Promise<GuidedSetupResult>;
|
|
66
|
+
export declare function runInteractiveSetup(options?: InteractiveSetupOptions): Promise<number>;
|
|
67
|
+
export declare function runSetupCli(options?: {
|
|
68
|
+
argv?: string[];
|
|
69
|
+
env?: NodeJS.ProcessEnv;
|
|
70
|
+
stdout?: Pick<NodeJS.WriteStream, "write">;
|
|
71
|
+
stderr?: Pick<NodeJS.WriteStream, "write">;
|
|
72
|
+
stdin?: AsyncIterable<Buffer | string>;
|
|
73
|
+
fetch?: typeof fetch;
|
|
74
|
+
cwd?: string;
|
|
75
|
+
}): Promise<number>;
|
|
76
|
+
export declare function createPairingNonce(): string;
|
|
77
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAO9C,OAAO,EAAE,KAAK,WAAW,EAAuC,MAAM,gBAAgB,CAAC;AAEvF,wBAAgB,2BAA2B,CACzC,GAAG,GAAE,MAAsB,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AC;CAQnB;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA+D5F;AAED,wBAAsB,mBAAmB,CAAC,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,CAqdhG;AAED,wBAAsB,WAAW,CAC/B,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACT,GACL,OAAO,CAAC,MAAM,CAAC,CAoEjB;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { RouteKey } from "../protocol";
|
|
2
|
+
export type MessageRouteKind = "session_prompt" | "question_reply" | "permission_notice" | "informational";
|
|
3
|
+
export type MessageRouteStatus = "active" | "consumed" | "expired" | "offline";
|
|
4
|
+
export type MessageRouteRecord = {
|
|
5
|
+
chatId: string;
|
|
6
|
+
messageId: number;
|
|
7
|
+
route: RouteKey;
|
|
8
|
+
kind: MessageRouteKind;
|
|
9
|
+
interactionId?: string;
|
|
10
|
+
createdAt: number;
|
|
11
|
+
expiresAt: number;
|
|
12
|
+
status: MessageRouteStatus;
|
|
13
|
+
};
|
|
14
|
+
export type CallbackTokenRecord = {
|
|
15
|
+
token: string;
|
|
16
|
+
chatId: string;
|
|
17
|
+
messageId: number;
|
|
18
|
+
action: string;
|
|
19
|
+
payload?: string;
|
|
20
|
+
createdAt: number;
|
|
21
|
+
expiresAt: number;
|
|
22
|
+
consumedAt?: number;
|
|
23
|
+
};
|
|
24
|
+
export type OutboxRecord = {
|
|
25
|
+
id: number;
|
|
26
|
+
idempotencyKey: string;
|
|
27
|
+
chatId: string;
|
|
28
|
+
payload: string;
|
|
29
|
+
priority: number;
|
|
30
|
+
attempts: number;
|
|
31
|
+
nextAttemptAt: number;
|
|
32
|
+
expiresAt: number;
|
|
33
|
+
status: "pending" | "retry" | "delivered" | "failed";
|
|
34
|
+
resultCode: string | null;
|
|
35
|
+
createdAt: number;
|
|
36
|
+
updatedAt: number;
|
|
37
|
+
};
|
|
38
|
+
export type InboundUpdateRecord = {
|
|
39
|
+
updateId: number;
|
|
40
|
+
actionId?: string;
|
|
41
|
+
disposition: "rejected" | "acknowledged" | "failed";
|
|
42
|
+
payloadHash?: string;
|
|
43
|
+
occurredAt: number;
|
|
44
|
+
};
|
|
45
|
+
export type RetentionPolicy = {
|
|
46
|
+
terminalRouteRetentionMs: number;
|
|
47
|
+
terminalOutboxRetentionMs: number;
|
|
48
|
+
inboundUpdateRetentionMs: number;
|
|
49
|
+
maxMessageRoutes: number;
|
|
50
|
+
maxCallbackTokens: number;
|
|
51
|
+
maxOutboxRecords: number;
|
|
52
|
+
maxInboundUpdates: number;
|
|
53
|
+
maxDedupeRecords: number;
|
|
54
|
+
};
|
|
55
|
+
export type CleanupResult = {
|
|
56
|
+
expiredMessageRoutes: number;
|
|
57
|
+
expiredOutboxRecords: number;
|
|
58
|
+
deletedMessageRoutes: number;
|
|
59
|
+
deletedCallbackTokens: number;
|
|
60
|
+
deletedOutboxRecords: number;
|
|
61
|
+
deletedInboundUpdates: number;
|
|
62
|
+
deletedDedupeRecords: number;
|
|
63
|
+
};
|
|
64
|
+
export type StateInspection = {
|
|
65
|
+
schemaVersion: number;
|
|
66
|
+
machineId: string;
|
|
67
|
+
telegramUpdateOffset: number;
|
|
68
|
+
messageRoutes: Record<MessageRouteStatus, number>;
|
|
69
|
+
callbackTokens: number;
|
|
70
|
+
outbox: Record<OutboxRecord["status"], number>;
|
|
71
|
+
inboundUpdates: number;
|
|
72
|
+
dedupeRecords: number;
|
|
73
|
+
};
|
|
74
|
+
export declare const DEFAULT_RETENTION_POLICY: RetentionPolicy;
|
|
75
|
+
export declare class StateDatabase {
|
|
76
|
+
#private;
|
|
77
|
+
readonly path: string;
|
|
78
|
+
private constructor();
|
|
79
|
+
static open(input: {
|
|
80
|
+
stateDirectory: string;
|
|
81
|
+
machineId: string;
|
|
82
|
+
}): Promise<StateDatabase>;
|
|
83
|
+
get schemaVersion(): number;
|
|
84
|
+
getTelegramUpdateOffset(): number;
|
|
85
|
+
getTelegramBotFingerprint(): string | undefined;
|
|
86
|
+
pinTelegramBotFingerprint(botId: string, force?: boolean): void;
|
|
87
|
+
setTelegramBotFingerprint(botId: string): void;
|
|
88
|
+
commitInboundUpdate(input: {
|
|
89
|
+
updateId: number;
|
|
90
|
+
actionId?: string;
|
|
91
|
+
disposition: "rejected" | "acknowledged" | "failed";
|
|
92
|
+
payloadHash?: string;
|
|
93
|
+
occurredAt: number;
|
|
94
|
+
}): boolean;
|
|
95
|
+
getInboundUpdate(updateId: number): InboundUpdateRecord | undefined;
|
|
96
|
+
saveMessageRoute(record: MessageRouteRecord): void;
|
|
97
|
+
getMessageRoute(chatId: string, messageId: number): MessageRouteRecord | undefined;
|
|
98
|
+
setMessageRouteStatus(chatId: string, messageId: number, status: MessageRouteStatus): boolean;
|
|
99
|
+
saveCallbackToken(record: CallbackTokenRecord): void;
|
|
100
|
+
getCallbackToken(token: string): CallbackTokenRecord | undefined;
|
|
101
|
+
consumeCallbackToken(token: string, now: number): boolean;
|
|
102
|
+
consumeCallbackTokenAndRoute(input: {
|
|
103
|
+
token: string;
|
|
104
|
+
chatId: string;
|
|
105
|
+
messageId: number;
|
|
106
|
+
now: number;
|
|
107
|
+
}): boolean;
|
|
108
|
+
enqueueOutbox(input: {
|
|
109
|
+
idempotencyKey: string;
|
|
110
|
+
chatId: string;
|
|
111
|
+
payload: string;
|
|
112
|
+
priority: number;
|
|
113
|
+
nextAttemptAt: number;
|
|
114
|
+
expiresAt: number;
|
|
115
|
+
createdAt: number;
|
|
116
|
+
}): {
|
|
117
|
+
id: number;
|
|
118
|
+
created: boolean;
|
|
119
|
+
};
|
|
120
|
+
nextOutbox(now: number, limit: number): OutboxRecord[];
|
|
121
|
+
recordOutboxRetry(id: number, nextAttemptAt: number, resultCode: string, now: number): void;
|
|
122
|
+
finishOutbox(id: number, status: "delivered" | "failed", resultCode: string | null, now: number): void;
|
|
123
|
+
finishOutboxDeliveryWithBinding(input: {
|
|
124
|
+
outboxId: number;
|
|
125
|
+
route: MessageRouteRecord;
|
|
126
|
+
callbackTokens?: CallbackTokenRecord[];
|
|
127
|
+
now: number;
|
|
128
|
+
}): void;
|
|
129
|
+
claimNotification(idempotencyKey: string, expiresAt: number, now: number): boolean;
|
|
130
|
+
cleanup(now: number, policy?: RetentionPolicy): CleanupResult;
|
|
131
|
+
inspect(): StateInspection;
|
|
132
|
+
purgeOperationalState(): StateInspection;
|
|
133
|
+
vacuum(): void;
|
|
134
|
+
close(): void;
|
|
135
|
+
}
|
|
136
|
+
export declare class DatabaseVersionError extends Error {
|
|
137
|
+
readonly found: number;
|
|
138
|
+
readonly supported: number;
|
|
139
|
+
constructor(found: number, supported: number);
|
|
140
|
+
}
|
|
141
|
+
export type DatabaseIntegrity = {
|
|
142
|
+
status: "missing";
|
|
143
|
+
} | {
|
|
144
|
+
status: "healthy";
|
|
145
|
+
} | {
|
|
146
|
+
status: "corrupt";
|
|
147
|
+
reason: string;
|
|
148
|
+
};
|
|
149
|
+
export declare function inspectDatabaseIntegrity(stateDirectory: string): Promise<DatabaseIntegrity>;
|
|
150
|
+
export declare function repairCorruptStateDatabase(input: {
|
|
151
|
+
stateDirectory: string;
|
|
152
|
+
machineId: string;
|
|
153
|
+
confirm: boolean;
|
|
154
|
+
force?: boolean;
|
|
155
|
+
}): Promise<{
|
|
156
|
+
archivePath: string;
|
|
157
|
+
previousIntegrity: DatabaseIntegrity;
|
|
158
|
+
}>;
|
|
159
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/state/database.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,CAAC;AACpB,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MA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;
|
|
8
|
+
minor: z.ZodNumber;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
startedAt: z.ZodISODateTime;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type DiscoveryRecord = z.infer<typeof DiscoveryRecordSchema>;
|
|
13
|
+
export declare function writeDiscoveryRecord(stateDirectory: string, port: number): Promise<DiscoveryRecord>;
|
|
14
|
+
export declare function removeDiscoveryRecord(stateDirectory: string, expectedNonce: string): Promise<void>;
|
|
15
|
+
export declare function discoveryRecordPath(stateDirectory: string): string;
|
|
16
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/state/discovery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,qBAAqB;;;;;;;;;iBAShC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,wBAAsB,oBAAoB,CACxC,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC,CAa1B;AAED,wBAAsB,qBAAqB,CACzC,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAElE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RouteKey } from "../protocol";
|
|
2
|
+
export type StateIdentity = {
|
|
3
|
+
stateDirectory: string;
|
|
4
|
+
machineId: string;
|
|
5
|
+
brokerSecret: string;
|
|
6
|
+
routeSalt: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function defaultStateDirectory(environment?: NodeJS.ProcessEnv): string;
|
|
9
|
+
export declare function loadOrCreateStateIdentity(stateDirectory?: string): Promise<StateIdentity>;
|
|
10
|
+
export declare function createInstanceId(): string;
|
|
11
|
+
export declare function createRouteGeneration(): string;
|
|
12
|
+
export declare function deriveProjectId(projectPath: string, routeSalt: string): Promise<string>;
|
|
13
|
+
export declare function createRouteKey(input: {
|
|
14
|
+
machineId: string;
|
|
15
|
+
instanceId: string;
|
|
16
|
+
projectId: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
}): RouteKey;
|
|
19
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/state/identity.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,WAAW,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAc1F;AAED,wBAAsB,yBAAyB,CAC7C,cAAc,SAA0B,GACvC,OAAO,CAAC,aAAa,CAAC,CAqBxB;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7F;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,QAAQ,CAKX"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type CallbackTokenRecord, type CleanupResult, type DatabaseIntegrity, DatabaseVersionError, DEFAULT_RETENTION_POLICY, type InboundUpdateRecord, inspectDatabaseIntegrity, type MessageRouteKind, type MessageRouteRecord, type MessageRouteStatus, type OutboxRecord, type RetentionPolicy, repairCorruptStateDatabase, StateDatabase, type StateInspection, } from "./database";
|
|
2
|
+
export { type DiscoveryRecord, DiscoveryRecordSchema, discoveryRecordPath, removeDiscoveryRecord, writeDiscoveryRecord, } from "./discovery";
|
|
3
|
+
export { createInstanceId, createRouteGeneration, createRouteKey, defaultStateDirectory, deriveProjectId, loadOrCreateStateIdentity, type StateIdentity, } from "./identity";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,0BAA0B,EAC1B,aAAa,EACb,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,eAAe,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,yBAAyB,EACzB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const TelegramFileSchema: z.ZodObject<{
|
|
3
|
+
file_id: z.ZodString;
|
|
4
|
+
file_unique_id: z.ZodOptional<z.ZodString>;
|
|
5
|
+
file_size: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
file_path: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type TelegramFile = z.infer<typeof TelegramFileSchema>;
|
|
9
|
+
export declare const TelegramUpdateSchema: z.ZodObject<{
|
|
10
|
+
update_id: z.ZodNumber;
|
|
11
|
+
message: z.ZodOptional<z.ZodObject<{
|
|
12
|
+
message_id: z.ZodNumber;
|
|
13
|
+
from: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
id: z.ZodNumber;
|
|
15
|
+
is_bot: z.ZodBoolean;
|
|
16
|
+
first_name: z.ZodString;
|
|
17
|
+
username: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
chat: z.ZodObject<{
|
|
20
|
+
id: z.ZodNumber;
|
|
21
|
+
type: z.ZodEnum<{
|
|
22
|
+
private: "private";
|
|
23
|
+
group: "group";
|
|
24
|
+
supergroup: "supergroup";
|
|
25
|
+
channel: "channel";
|
|
26
|
+
}>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
date: z.ZodNumber;
|
|
29
|
+
text: z.ZodOptional<z.ZodString>;
|
|
30
|
+
voice: z.ZodOptional<z.ZodObject<{
|
|
31
|
+
file_id: z.ZodString;
|
|
32
|
+
file_unique_id: z.ZodOptional<z.ZodString>;
|
|
33
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
35
|
+
file_size: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
audio: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
file_id: z.ZodString;
|
|
39
|
+
file_unique_id: z.ZodOptional<z.ZodString>;
|
|
40
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
42
|
+
file_size: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
file_name: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
sender_chat: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
id: z.ZodNumber;
|
|
47
|
+
type: z.ZodEnum<{
|
|
48
|
+
private: "private";
|
|
49
|
+
group: "group";
|
|
50
|
+
supergroup: "supergroup";
|
|
51
|
+
channel: "channel";
|
|
52
|
+
}>;
|
|
53
|
+
}, z.core.$strip>>;
|
|
54
|
+
forward_origin: z.ZodOptional<z.ZodUnknown>;
|
|
55
|
+
author_signature: z.ZodOptional<z.ZodString>;
|
|
56
|
+
business_connection_id: z.ZodOptional<z.ZodString>;
|
|
57
|
+
reply_to_message: z.ZodOptional<z.ZodObject<{
|
|
58
|
+
message_id: z.ZodNumber;
|
|
59
|
+
chat: z.ZodObject<{
|
|
60
|
+
id: z.ZodNumber;
|
|
61
|
+
type: z.ZodEnum<{
|
|
62
|
+
private: "private";
|
|
63
|
+
group: "group";
|
|
64
|
+
supergroup: "supergroup";
|
|
65
|
+
channel: "channel";
|
|
66
|
+
}>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
callback_query: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
id: z.ZodString;
|
|
72
|
+
from: z.ZodObject<{
|
|
73
|
+
id: z.ZodNumber;
|
|
74
|
+
is_bot: z.ZodBoolean;
|
|
75
|
+
first_name: z.ZodString;
|
|
76
|
+
username: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
message: z.ZodOptional<z.ZodObject<{
|
|
79
|
+
message_id: z.ZodNumber;
|
|
80
|
+
from: z.ZodOptional<z.ZodObject<{
|
|
81
|
+
id: z.ZodNumber;
|
|
82
|
+
is_bot: z.ZodBoolean;
|
|
83
|
+
first_name: z.ZodString;
|
|
84
|
+
username: z.ZodOptional<z.ZodString>;
|
|
85
|
+
}, z.core.$strip>>;
|
|
86
|
+
chat: z.ZodObject<{
|
|
87
|
+
id: z.ZodNumber;
|
|
88
|
+
type: z.ZodEnum<{
|
|
89
|
+
private: "private";
|
|
90
|
+
group: "group";
|
|
91
|
+
supergroup: "supergroup";
|
|
92
|
+
channel: "channel";
|
|
93
|
+
}>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
date: z.ZodNumber;
|
|
96
|
+
text: z.ZodOptional<z.ZodString>;
|
|
97
|
+
voice: z.ZodOptional<z.ZodObject<{
|
|
98
|
+
file_id: z.ZodString;
|
|
99
|
+
file_unique_id: z.ZodOptional<z.ZodString>;
|
|
100
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
102
|
+
file_size: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
audio: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
file_id: z.ZodString;
|
|
106
|
+
file_unique_id: z.ZodOptional<z.ZodString>;
|
|
107
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
108
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
109
|
+
file_size: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
file_name: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
sender_chat: z.ZodOptional<z.ZodObject<{
|
|
113
|
+
id: z.ZodNumber;
|
|
114
|
+
type: z.ZodEnum<{
|
|
115
|
+
private: "private";
|
|
116
|
+
group: "group";
|
|
117
|
+
supergroup: "supergroup";
|
|
118
|
+
channel: "channel";
|
|
119
|
+
}>;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
forward_origin: z.ZodOptional<z.ZodUnknown>;
|
|
122
|
+
author_signature: z.ZodOptional<z.ZodString>;
|
|
123
|
+
business_connection_id: z.ZodOptional<z.ZodString>;
|
|
124
|
+
reply_to_message: z.ZodOptional<z.ZodObject<{
|
|
125
|
+
message_id: z.ZodNumber;
|
|
126
|
+
chat: z.ZodObject<{
|
|
127
|
+
id: z.ZodNumber;
|
|
128
|
+
type: z.ZodEnum<{
|
|
129
|
+
private: "private";
|
|
130
|
+
group: "group";
|
|
131
|
+
supergroup: "supergroup";
|
|
132
|
+
channel: "channel";
|
|
133
|
+
}>;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
}, z.core.$strip>>;
|
|
137
|
+
data: z.ZodOptional<z.ZodString>;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
export type TelegramUpdate = z.infer<typeof TelegramUpdateSchema>;
|
|
141
|
+
export declare const TelegramBotSchema: z.ZodObject<{
|
|
142
|
+
id: z.ZodNumber;
|
|
143
|
+
first_name: z.ZodString;
|
|
144
|
+
username: z.ZodOptional<z.ZodString>;
|
|
145
|
+
is_bot: z.ZodLiteral<true>;
|
|
146
|
+
}, z.core.$strip>;
|
|
147
|
+
export type TelegramBot = z.infer<typeof TelegramBotSchema>;
|
|
148
|
+
export type SendMessageInput = {
|
|
149
|
+
chatId: string;
|
|
150
|
+
text: string;
|
|
151
|
+
parseMode?: "HTML";
|
|
152
|
+
disableNotification?: boolean;
|
|
153
|
+
replyMarkup?: Record<string, unknown>;
|
|
154
|
+
signal?: AbortSignal;
|
|
155
|
+
};
|
|
156
|
+
export type TelegramBotApiOptions = {
|
|
157
|
+
token: string;
|
|
158
|
+
baseUrl?: string;
|
|
159
|
+
fetch?: typeof fetch;
|
|
160
|
+
};
|
|
161
|
+
export declare class TelegramBotApi {
|
|
162
|
+
#private;
|
|
163
|
+
constructor(options: TelegramBotApiOptions);
|
|
164
|
+
getMe(signal?: AbortSignal): Promise<TelegramBot>;
|
|
165
|
+
deleteWebhook(signal?: AbortSignal): Promise<void>;
|
|
166
|
+
getUpdates(input: {
|
|
167
|
+
offset: number;
|
|
168
|
+
timeoutSeconds?: number;
|
|
169
|
+
signal?: AbortSignal;
|
|
170
|
+
}): Promise<TelegramUpdate[]>;
|
|
171
|
+
sendMessage(input: SendMessageInput): Promise<{
|
|
172
|
+
messageId: number;
|
|
173
|
+
chatId: string;
|
|
174
|
+
}>;
|
|
175
|
+
answerCallbackQuery(input: {
|
|
176
|
+
callbackQueryId: string;
|
|
177
|
+
text?: string;
|
|
178
|
+
showAlert?: boolean;
|
|
179
|
+
signal?: AbortSignal;
|
|
180
|
+
}): Promise<boolean>;
|
|
181
|
+
editMessageText(input: {
|
|
182
|
+
chatId: string;
|
|
183
|
+
messageId: number;
|
|
184
|
+
text: string;
|
|
185
|
+
parseMode?: "HTML";
|
|
186
|
+
replyMarkup?: Record<string, unknown>;
|
|
187
|
+
signal?: AbortSignal;
|
|
188
|
+
}): Promise<{
|
|
189
|
+
messageId: number;
|
|
190
|
+
chatId: string;
|
|
191
|
+
}>;
|
|
192
|
+
getFile(fileId: string, signal?: AbortSignal | undefined): Promise<TelegramFile>;
|
|
193
|
+
downloadFile(filePath: string, signal?: AbortSignal | undefined): Promise<Uint8Array>;
|
|
194
|
+
}
|
|
195
|
+
export declare class TelegramApiError extends Error {
|
|
196
|
+
readonly method: string;
|
|
197
|
+
readonly statusCode: number;
|
|
198
|
+
readonly errorCode: number | undefined;
|
|
199
|
+
readonly retryAfterSeconds: number | undefined;
|
|
200
|
+
readonly retryable: boolean;
|
|
201
|
+
constructor(input: {
|
|
202
|
+
method: string;
|
|
203
|
+
statusCode: number;
|
|
204
|
+
errorCode?: number;
|
|
205
|
+
description: string;
|
|
206
|
+
retryAfterSeconds?: number;
|
|
207
|
+
retryable: boolean;
|
|
208
|
+
});
|
|
209
|
+
get authenticationFailed(): boolean;
|
|
210
|
+
get pollingConflict(): boolean;
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/telegram/api.ts"],"names":[],"mappings":"AAAA,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AS,CAAC;IACvC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;gBAEhB,KAAK,EAAE;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,SAAS,EAAE,OAAO,CAAC;KACpB;IAUD,IAAI,oBAAoB,IAAI,OAAO,CAElC;IAED,IAAI,eAAe,IAAI,OAAO,CAE7B;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TelegramUpdate } from "./api";
|
|
2
|
+
import type { UpdateDisposition } from "./poller";
|
|
3
|
+
export type AuthorizationRejection = "UNSUPPORTED_UPDATE" | "USER_MISSING" | "BOT_SENDER" | "USER_MISMATCH" | "CHAT_MISSING" | "CHAT_NOT_PRIVATE" | "CHAT_MISMATCH" | "FORWARDED_MESSAGE" | "SENDER_CHAT" | "BUSINESS_MESSAGE";
|
|
4
|
+
export type AuthorizedUpdate = {
|
|
5
|
+
kind: "message" | "callback_query";
|
|
6
|
+
userId: string;
|
|
7
|
+
chatId: string;
|
|
8
|
+
};
|
|
9
|
+
export type AuthorizationResult = {
|
|
10
|
+
authorized: true;
|
|
11
|
+
subject: AuthorizedUpdate;
|
|
12
|
+
} | {
|
|
13
|
+
authorized: false;
|
|
14
|
+
reason: AuthorizationRejection;
|
|
15
|
+
};
|
|
16
|
+
export declare class TelegramUpdateAuthorizer {
|
|
17
|
+
#private;
|
|
18
|
+
constructor(input: {
|
|
19
|
+
userId: string;
|
|
20
|
+
chatId: string;
|
|
21
|
+
});
|
|
22
|
+
authorize(update: TelegramUpdate): AuthorizationResult;
|
|
23
|
+
}
|
|
24
|
+
export declare function createAuthorizedUpdateHandler(authorizer: TelegramUpdateAuthorizer, handleAuthorized: (update: TelegramUpdate, subject: AuthorizedUpdate) => UpdateDisposition | Promise<UpdateDisposition>): (update: TelegramUpdate) => UpdateDisposition | Promise<UpdateDisposition>;
|
|
25
|
+
//# sourceMappingURL=authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../../src/telegram/authorization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,MAAM,sBAAsB,GAC9B,oBAAoB,GACpB,cAAc,GACd,YAAY,GACZ,eAAe,GACf,cAAc,GACd,kBAAkB,GAClB,eAAe,GACf,mBAAmB,GACnB,aAAa,GACb,kBAAkB,CAAC;AAEvB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,SAAS,GAAG,gBAAgB,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,GAC/C;IAAE,UAAU,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAE1D,qBAAa,wBAAwB;;gBAIvB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAWrD,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,mBAAmB;CAmCvD;AAED,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,wBAAwB,EACpC,gBAAgB,EAAE,CAChB,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,gBAAgB,KACtB,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAClD,CAAC,MAAM,EAAE,cAAc,KAAK,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAU5E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RouteRegistry } from "../broker/registry";
|
|
2
|
+
import { type SupportedLocale } from "../i18n";
|
|
3
|
+
import type { BrokerCommand, CommandResult } from "../protocol";
|
|
4
|
+
export type SlashCommandContext = {
|
|
5
|
+
text: string;
|
|
6
|
+
locale?: SupportedLocale;
|
|
7
|
+
registry: RouteRegistry;
|
|
8
|
+
dispatcher: {
|
|
9
|
+
sendCommand(command: BrokerCommand): Promise<CommandResult>;
|
|
10
|
+
};
|
|
11
|
+
startedAt?: number;
|
|
12
|
+
packageVersion?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function isSlashCommand(text?: string): boolean;
|
|
15
|
+
export declare function parseSlashCommand(text: string): {
|
|
16
|
+
command: string;
|
|
17
|
+
args: string[];
|
|
18
|
+
} | undefined;
|
|
19
|
+
export declare function executeSlashCommand(context: SlashCommandContext): Promise<string>;
|
|
20
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/telegram/commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,KAAK,eAAe,EAAa,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGhE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE;QACV,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;KAC7D,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAIrD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,SAAS,CAe/F;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkCvF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { type SendMessageInput, TelegramApiError, type TelegramBot, TelegramBotApi, type TelegramBotApiOptions, type TelegramUpdate, TelegramUpdateSchema, } from "./api";
|
|
2
|
+
export { type AuthorizationRejection, type AuthorizationResult, type AuthorizedUpdate, createAuthorizedUpdateHandler, TelegramUpdateAuthorizer, } from "./authorization";
|
|
3
|
+
export { executeSlashCommand, isSlashCommand, parseSlashCommand, type SlashCommandContext, } from "./commands";
|
|
4
|
+
export { type BrokerCommandDispatcher, createValidatedInteractionHandler, type InteractionFeedbackCode, type InteractionSubmissionOutcome, type InteractionValidationReason, type InteractionValidationResult, type InteractionValidatorOptions, interactionFeedbackText, submitCompletedSessionReply, submitQuestionReply, submitTelegramInteraction, type ValidatedTelegramInteraction, validateTelegramInteraction, validationFeedback, } from "./interaction";
|
|
5
|
+
export { type TelegramOutboxPayload, TelegramOutboxPayloadSchema, TelegramOutboxWorker, type TelegramOutboxWorkerOptions, } from "./outbox";
|
|
6
|
+
export { TelegramPoller, type TelegramPollerOptions, type UpdateDisposition, } from "./poller";
|
|
7
|
+
export { type RenderedTelegramPayload, redactText, renderTelegramNotification, sanitizeTelegramText, TelegramRenderError, type TelegramRenderOptions, } from "./render";
|
|
8
|
+
export { VoiceTranscriber, type VoiceTranscriberOptions, } from "./transcriber";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telegram/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,KAAK,WAAW,EAChB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,uBAAuB,EAC5B,iCAAiC,EACjC,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,uBAAuB,EACvB,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,4BAA4B,EACjC,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,GACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,uBAAuB,EAC5B,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,qBAAqB,GAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type SupportedLocale } from "../i18n";
|
|
2
|
+
import type { BrokerCommand, CommandResult, RouteKey } from "../protocol";
|
|
3
|
+
import type { MessageRouteKind, StateDatabase } from "../state";
|
|
4
|
+
import type { TelegramUpdate } from "./api";
|
|
5
|
+
import type { AuthorizedUpdate, TelegramUpdateAuthorizer } from "./authorization";
|
|
6
|
+
import type { UpdateDisposition } from "./poller";
|
|
7
|
+
export type InteractionValidationReason = "ALREADY_HANDLED" | "MESSAGE_BINDING_REQUIRED" | "MESSAGE_BINDING_NOT_FOUND" | "MESSAGE_BINDING_EXPIRED" | "MESSAGE_BINDING_INACTIVE" | "CALLBACK_TOKEN_INVALID" | "CALLBACK_TOKEN_EXPIRED" | "CALLBACK_TOKEN_MESSAGE_MISMATCH" | "ACTION_KIND_MISMATCH" | "ROUTE_STALE";
|
|
8
|
+
export type ValidatedTelegramInteraction = {
|
|
9
|
+
updateId: number;
|
|
10
|
+
chatId: string;
|
|
11
|
+
messageId: number;
|
|
12
|
+
kind: MessageRouteKind;
|
|
13
|
+
route: RouteKey;
|
|
14
|
+
interactionId?: string;
|
|
15
|
+
text?: string;
|
|
16
|
+
callbackToken?: string;
|
|
17
|
+
callbackAction?: string;
|
|
18
|
+
callbackPayload?: string;
|
|
19
|
+
};
|
|
20
|
+
export type InteractionValidationResult = {
|
|
21
|
+
accepted: true;
|
|
22
|
+
interaction: ValidatedTelegramInteraction;
|
|
23
|
+
} | {
|
|
24
|
+
accepted: false;
|
|
25
|
+
reason: InteractionValidationReason;
|
|
26
|
+
disposition: UpdateDisposition;
|
|
27
|
+
};
|
|
28
|
+
export type InteractionValidatorOptions = {
|
|
29
|
+
database: StateDatabase;
|
|
30
|
+
isRouteLive: (route: RouteKey) => boolean;
|
|
31
|
+
now?: () => number;
|
|
32
|
+
};
|
|
33
|
+
export type BrokerCommandDispatcher = {
|
|
34
|
+
sendCommand(command: BrokerCommand): Promise<CommandResult>;
|
|
35
|
+
};
|
|
36
|
+
export type InteractionFeedbackCode = "accepted" | "already_handled" | "expired" | "indeterminate" | "invalid" | "offline" | "rejected" | "reply_required" | "stale" | "terminal_only";
|
|
37
|
+
export type InteractionSubmissionOutcome = {
|
|
38
|
+
result: CommandResult;
|
|
39
|
+
feedback: InteractionFeedbackCode;
|
|
40
|
+
};
|
|
41
|
+
export declare function validateTelegramInteraction(update: TelegramUpdate, subject: AuthorizedUpdate, options: InteractionValidatorOptions): InteractionValidationResult;
|
|
42
|
+
export declare function createValidatedInteractionHandler(authorizer: TelegramUpdateAuthorizer, options: InteractionValidatorOptions, handleValidated: (interaction: ValidatedTelegramInteraction, update: TelegramUpdate) => UpdateDisposition | Promise<UpdateDisposition>): (update: TelegramUpdate) => UpdateDisposition | Promise<UpdateDisposition>;
|
|
43
|
+
export declare function submitCompletedSessionReply(dispatcher: BrokerCommandDispatcher, interaction: ValidatedTelegramInteraction): Promise<CommandResult>;
|
|
44
|
+
export declare function submitQuestionReply(dispatcher: BrokerCommandDispatcher, interaction: ValidatedTelegramInteraction): Promise<CommandResult>;
|
|
45
|
+
export declare function submitPermissionReply(dispatcher: BrokerCommandDispatcher, interaction: ValidatedTelegramInteraction): Promise<CommandResult>;
|
|
46
|
+
export declare function submitTelegramInteraction(dispatcher: BrokerCommandDispatcher, interaction: ValidatedTelegramInteraction): Promise<InteractionSubmissionOutcome>;
|
|
47
|
+
export declare function validationFeedback(reason: InteractionValidationReason): InteractionFeedbackCode;
|
|
48
|
+
export declare function interactionFeedbackText(locale: SupportedLocale, feedback: InteractionFeedbackCode): string;
|
|
49
|
+
//# sourceMappingURL=interaction.d.ts.map
|