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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +464 -0
  3. package/container/broker.Dockerfile +30 -0
  4. package/container/entrypoint.sh +19 -0
  5. package/dist/broker/commands.d.ts +17 -0
  6. package/dist/broker/commands.d.ts.map +1 -0
  7. package/dist/broker/dashboard-html.d.ts +2 -0
  8. package/dist/broker/dashboard-html.d.ts.map +1 -0
  9. package/dist/broker/index.d.ts +3 -0
  10. package/dist/broker/index.d.ts.map +1 -0
  11. package/dist/broker/main.d.ts +3 -0
  12. package/dist/broker/main.d.ts.map +1 -0
  13. package/dist/broker/main.js +21896 -0
  14. package/dist/broker/main.js.map +110 -0
  15. package/dist/broker/registry.d.ts +92 -0
  16. package/dist/broker/registry.d.ts.map +1 -0
  17. package/dist/broker/server.d.ts +133 -0
  18. package/dist/broker/server.d.ts.map +1 -0
  19. package/dist/config.d.ts +76 -0
  20. package/dist/config.d.ts.map +1 -0
  21. package/dist/doctor.d.ts +21 -0
  22. package/dist/doctor.d.ts.map +1 -0
  23. package/dist/i18n/catalogs.d.ts +120 -0
  24. package/dist/i18n/catalogs.d.ts.map +1 -0
  25. package/dist/i18n/index.d.ts +10 -0
  26. package/dist/i18n/index.d.ts.map +1 -0
  27. package/dist/opencode/bridge.d.ts +39 -0
  28. package/dist/opencode/bridge.d.ts.map +1 -0
  29. package/dist/opencode/config-helper.d.ts +20 -0
  30. package/dist/opencode/config-helper.d.ts.map +1 -0
  31. package/dist/opencode/events.d.ts +47 -0
  32. package/dist/opencode/events.d.ts.map +1 -0
  33. package/dist/opencode/index.d.ts +4 -0
  34. package/dist/opencode/index.d.ts.map +1 -0
  35. package/dist/plugin/client.d.ts +57 -0
  36. package/dist/plugin/client.d.ts.map +1 -0
  37. package/dist/plugin/commands.d.ts +4 -0
  38. package/dist/plugin/commands.d.ts.map +1 -0
  39. package/dist/plugin/index.d.ts +2 -0
  40. package/dist/plugin/index.d.ts.map +1 -0
  41. package/dist/plugin.d.ts +11 -0
  42. package/dist/plugin.d.ts.map +1 -0
  43. package/dist/plugin.js +16913 -0
  44. package/dist/plugin.js.map +95 -0
  45. package/dist/protocol/index.d.ts +792 -0
  46. package/dist/protocol/index.d.ts.map +1 -0
  47. package/dist/protocol/index.js +14540 -0
  48. package/dist/protocol/index.js.map +84 -0
  49. package/dist/setup.d.ts +77 -0
  50. package/dist/setup.d.ts.map +1 -0
  51. package/dist/state/database.d.ts +159 -0
  52. package/dist/state/database.d.ts.map +1 -0
  53. package/dist/state/discovery.d.ts +16 -0
  54. package/dist/state/discovery.d.ts.map +1 -0
  55. package/dist/state/identity.d.ts +19 -0
  56. package/dist/state/identity.d.ts.map +1 -0
  57. package/dist/state/index.d.ts +4 -0
  58. package/dist/state/index.d.ts.map +1 -0
  59. package/dist/telegram/api.d.ts +212 -0
  60. package/dist/telegram/api.d.ts.map +1 -0
  61. package/dist/telegram/authorization.d.ts +25 -0
  62. package/dist/telegram/authorization.d.ts.map +1 -0
  63. package/dist/telegram/commands.d.ts +20 -0
  64. package/dist/telegram/commands.d.ts.map +1 -0
  65. package/dist/telegram/index.d.ts +9 -0
  66. package/dist/telegram/index.d.ts.map +1 -0
  67. package/dist/telegram/interaction.d.ts +49 -0
  68. package/dist/telegram/interaction.d.ts.map +1 -0
  69. package/dist/telegram/outbox.d.ts +46 -0
  70. package/dist/telegram/outbox.d.ts.map +1 -0
  71. package/dist/telegram/poller.d.ts +26 -0
  72. package/dist/telegram/poller.d.ts.map +1 -0
  73. package/dist/telegram/render.d.ts +16 -0
  74. package/dist/telegram/render.d.ts.map +1 -0
  75. package/dist/telegram/transcriber.d.ts +20 -0
  76. package/dist/telegram/transcriber.d.ts.map +1 -0
  77. package/dist/uninstall.d.ts +12 -0
  78. package/dist/uninstall.d.ts.map +1 -0
  79. package/dist/version.d.ts +2 -0
  80. package/dist/version.d.ts.map +1 -0
  81. package/docker-compose.yml +19 -0
  82. package/package.json +73 -0
@@ -0,0 +1,92 @@
1
+ import type { ServerWebSocket } from "bun";
2
+ import { type RouteKey } from "../protocol";
3
+ export type BrokerConnectionData = {
4
+ connectionId: string;
5
+ connectedAt: number;
6
+ lastHeartbeatAt: number;
7
+ instanceId?: string;
8
+ };
9
+ export type RegisteredRoute = {
10
+ route: RouteKey;
11
+ hostLabel?: string | undefined;
12
+ projectLabel: string;
13
+ sessionLabel: string;
14
+ connectionId: string;
15
+ };
16
+ type OwnedConnection = {
17
+ socket: ServerWebSocket<BrokerConnectionData>;
18
+ instanceId: string;
19
+ machineId: string;
20
+ hostLabel?: string | undefined;
21
+ projectLabel?: string | undefined;
22
+ routeKeys: Set<string>;
23
+ };
24
+ export type SessionLookupResult = {
25
+ status: "found";
26
+ route: RouteKey;
27
+ projectLabel?: string | undefined;
28
+ sessionLabel?: string | undefined;
29
+ hostLabel?: string | undefined;
30
+ } | {
31
+ status: "ambiguous";
32
+ matches: Array<{
33
+ sessionId: string;
34
+ projectLabel?: string | undefined;
35
+ hostLabel?: string | undefined;
36
+ instanceId: string;
37
+ }>;
38
+ } | {
39
+ status: "not_found";
40
+ };
41
+ export declare class RouteRegistry {
42
+ #private;
43
+ registerConnection(socket: ServerWebSocket<BrokerConnectionData>, instanceId: string, machineId: string, hostLabel?: string, projectLabel?: string): void;
44
+ registerRoute(connectionId: string, input: {
45
+ route: RouteKey;
46
+ hostLabel?: string | undefined;
47
+ projectLabel: string;
48
+ sessionLabel: string;
49
+ }): RegisteredRoute;
50
+ unregisterRoute(connectionId: string, route: RouteKey): boolean;
51
+ resolve(route: RouteKey): RegisteredRoute | undefined;
52
+ lookupSession(sessionIdOrPrefix: string, target?: string): SessionLookupResult;
53
+ resolveBySessionId(sessionId: string, target?: string): RouteKey | undefined;
54
+ owner(route: RouteKey): ServerWebSocket<BrokerConnectionData> | undefined;
55
+ ownerByInstance(instanceId: string): ServerWebSocket<BrokerConnectionData> | undefined;
56
+ removeConnection(connectionId: string): void;
57
+ get connectionCount(): number;
58
+ get routeCount(): number;
59
+ listNodes(): Array<{
60
+ connectionId: string;
61
+ machineId: string;
62
+ instanceId: string;
63
+ hostLabel?: string;
64
+ activeRoutesCount: number;
65
+ lastHeartbeatAt?: number;
66
+ }>;
67
+ listMachines(): Array<{
68
+ machineId: string;
69
+ hostLabel: string;
70
+ connectionsCount: number;
71
+ totalRoutesCount: number;
72
+ projects: Array<{
73
+ projectLabel: string;
74
+ sessionLabel?: string;
75
+ sessionId?: string;
76
+ }>;
77
+ }>;
78
+ findConnection(target?: string): OwnedConnection | undefined;
79
+ listActiveSessions(): Array<{
80
+ route: RouteKey;
81
+ projectLabel: string;
82
+ sessionLabel: string;
83
+ hostLabel?: string;
84
+ }>;
85
+ }
86
+ export declare class RouteRegistrationError extends Error {
87
+ readonly code: string;
88
+ constructor(code: string, message: string);
89
+ }
90
+ export declare function serializeRouteKey(route: RouteKey): string;
91
+ export {};
92
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/broker/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAC3C,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,KAA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S;IAmD5D,kBAAkB,IAAI,KAAK,CAAC;QAC1B,KAAK,EAAE,QAAQ,CAAC;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CAYH;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAE7C,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAQzD"}
@@ -0,0 +1,133 @@
1
+ import { z } from "zod";
2
+ import { type BrokerCommand, type CommandResult, type NormalizedNotification, type TelegramRuntimeConfig } from "../protocol";
3
+ import { StateDatabase } from "../state";
4
+ import { TelegramBotApi, VoiceTranscriber } from "../telegram";
5
+ import { type BrokerConnectionData, RouteRegistry } from "./registry";
6
+ declare const LOOPBACK_HOST = "127.0.0.1";
7
+ declare const CONTAINER_HOST = "0.0.0.0";
8
+ export type DashboardSettings = {
9
+ activeProvider?: "groq" | "openai" | "cloudflare" | "custom" | undefined;
10
+ cloudflare?: {
11
+ accountId?: string | undefined;
12
+ apiToken?: string | undefined;
13
+ } | undefined;
14
+ groq?: {
15
+ apiKey?: string | undefined;
16
+ } | undefined;
17
+ openai?: {
18
+ apiKey?: string | undefined;
19
+ } | undefined;
20
+ custom?: {
21
+ endpoint?: string | undefined;
22
+ apiKey?: string | undefined;
23
+ model?: string | undefined;
24
+ } | undefined;
25
+ sessionPromptTtlMinutes?: number | undefined;
26
+ voiceProvider?: "groq" | "openai" | "cloudflare" | "custom" | undefined;
27
+ voiceApiKey?: string | undefined;
28
+ voiceAccountId?: string | undefined;
29
+ voiceEndpoint?: string | undefined;
30
+ voiceModel?: string | undefined;
31
+ };
32
+ declare const HealthResponseSchema: z.ZodObject<{
33
+ service: z.ZodLiteral<"opencode-telegram-link">;
34
+ machineId: z.ZodUUID;
35
+ protocol: z.ZodObject<{
36
+ major: z.ZodNumber;
37
+ minor: z.ZodNumber;
38
+ }, z.core.$strip>;
39
+ }, z.core.$strip>;
40
+ declare const BrokerStatusSchema: z.ZodObject<{
41
+ service: z.ZodLiteral<"opencode-telegram-link">;
42
+ machineId: z.ZodUUID;
43
+ protocol: z.ZodObject<{
44
+ major: z.ZodNumber;
45
+ minor: z.ZodNumber;
46
+ }, z.core.$strip>;
47
+ bindHost: z.ZodEnum<{
48
+ "127.0.0.1": "127.0.0.1";
49
+ "0.0.0.0": "0.0.0.0";
50
+ }>;
51
+ connections: z.ZodNumber;
52
+ routes: z.ZodNumber;
53
+ }, z.core.$strip>;
54
+ export type StartBrokerOptions = {
55
+ stateDirectory?: string;
56
+ bindHost?: typeof LOOPBACK_HOST | typeof CONTAINER_HOST;
57
+ port?: number;
58
+ registrationTimeoutMs?: number;
59
+ heartbeatTimeoutMs?: number;
60
+ idleTimeoutMs?: number;
61
+ maintenanceIntervalMs?: number;
62
+ telegramApiFactory?: (botToken: string) => TelegramBotApi;
63
+ telegramDeliveryIntervalMs?: number;
64
+ telegramPollLongPollSeconds?: number;
65
+ now?: () => number;
66
+ };
67
+ export type StartOrReuseBrokerResult = {
68
+ kind: "started";
69
+ broker: BrokerServer;
70
+ } | {
71
+ kind: "existing";
72
+ machineId: string;
73
+ port: number;
74
+ };
75
+ export declare class BrokerServer {
76
+ #private;
77
+ readonly machineId: string;
78
+ readonly registry: RouteRegistry;
79
+ readonly database: StateDatabase;
80
+ readonly port: number;
81
+ readonly finished: Promise<void>;
82
+ constructor(input: {
83
+ server: Bun.Server<BrokerConnectionData>;
84
+ machineId: string;
85
+ registry: RouteRegistry;
86
+ database: StateDatabase;
87
+ connections: Set<Bun.ServerWebSocket<BrokerConnectionData>>;
88
+ livenessTimer: ReturnType<typeof setInterval>;
89
+ maintenanceTimer: ReturnType<typeof setInterval>;
90
+ removeDiscovery: () => Promise<void>;
91
+ pendingCommands: Map<string, PendingBrokerCommand>;
92
+ telegramRuntimeRef: {
93
+ value: BrokerTelegramRuntime | undefined;
94
+ };
95
+ });
96
+ stop(): Promise<void>;
97
+ sendCommand(command: BrokerCommand, timeoutMs?: number): Promise<CommandResult>;
98
+ }
99
+ export declare function startBroker(options?: StartBrokerOptions): Promise<BrokerServer>;
100
+ export declare function startOrReuseBroker(options?: StartBrokerOptions): Promise<StartOrReuseBrokerResult>;
101
+ export declare function probeBroker(port: number, brokerSecret: string): Promise<z.infer<typeof HealthResponseSchema> | undefined>;
102
+ export declare function fetchBrokerStatus(port: number, brokerSecret: string): Promise<z.infer<typeof BrokerStatusSchema> | undefined>;
103
+ export declare class BrokerPortConflictError extends Error {
104
+ readonly port: number;
105
+ constructor(port: number);
106
+ }
107
+ declare class BrokerTelegramRuntime {
108
+ #private;
109
+ setTranscriber(transcriber: VoiceTranscriber | undefined): void;
110
+ constructor(input: {
111
+ config: TelegramRuntimeConfig;
112
+ database: StateDatabase;
113
+ registry: RouteRegistry;
114
+ dispatcher: {
115
+ sendCommand(command: BrokerCommand): Promise<CommandResult>;
116
+ };
117
+ api: TelegramBotApi;
118
+ deliveryIntervalMs: number;
119
+ pollLongPollSeconds?: number;
120
+ now: () => number;
121
+ });
122
+ start(): void;
123
+ stop(): Promise<void>;
124
+ publish(notification: NormalizedNotification): "queued" | "duplicate";
125
+ }
126
+ type PendingBrokerCommand = {
127
+ connectionId: string;
128
+ commandId: string;
129
+ resolve: (result: CommandResult) => void;
130
+ timeout: ReturnType<typeof setTimeout>;
131
+ };
132
+ export {};
133
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/broker/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,KAAK,aAAa,EAIlB,KAAK,aAAa,EAElB,KAAK,sBAAsB,EAE3B,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AAC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SAAS,GAAG,IAAI;gBAInD,KAAK,EAAE;QACjB,MAAM,EAAE,qBAAqB,CAAC;QAC9B,QAAQ,EAAE,aAAa,CAAC;QACxB,QAAQ,EAAE,aAAa,CAAC;QACxB,UAAU,EAAE;YAAE,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;SAAE,CAAC;QAC5E,GAAG,EAAE,cAAc,CAAC;QACpB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,GAAG,EAAE,MAAM,MAAM,CAAC;KACnB;IA0PD,KAAK,IAAI,IAAI;IASP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B,OAAO,CAAC,YAAY,EAAE,sBAAsB,GAAG,QAAQ,GAAG,WAAW;CAmDtE;AAoQD,KAAK,oBAAoB,GAAG;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;CACxC,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { z } from "zod";
2
+ export declare const ConfigFingerprintSchema: z.ZodString;
3
+ export declare const LocalePreferenceSchema: z.ZodEnum<{
4
+ auto: "auto";
5
+ en: "en";
6
+ "zh-TW": "zh-TW";
7
+ }>;
8
+ export type LocalePreference = z.infer<typeof LocalePreferenceSchema>;
9
+ export declare const NotifierConfigSchema: z.ZodObject<{
10
+ mode: z.ZodDefault<z.ZodLiteral<"local">>;
11
+ role: z.ZodDefault<z.ZodEnum<{
12
+ gateway: "gateway";
13
+ node: "node";
14
+ }>>;
15
+ hostLabel: z.ZodOptional<z.ZodString>;
16
+ locale: z.ZodDefault<z.ZodEnum<{
17
+ auto: "auto";
18
+ en: "en";
19
+ "zh-TW": "zh-TW";
20
+ }>>;
21
+ gateway: z.ZodOptional<z.ZodObject<{
22
+ url: z.ZodString;
23
+ secret: z.ZodString;
24
+ }, z.core.$strip>>;
25
+ telegram: z.ZodOptional<z.ZodObject<{
26
+ botToken: z.ZodOptional<z.ZodString>;
27
+ tokenFile: z.ZodOptional<z.ZodString>;
28
+ userId: z.ZodString;
29
+ chatId: z.ZodString;
30
+ }, z.core.$strict>>;
31
+ notifications: z.ZodPrefault<z.ZodObject<{
32
+ completion: z.ZodDefault<z.ZodBoolean>;
33
+ error: z.ZodDefault<z.ZodBoolean>;
34
+ question: z.ZodDefault<z.ZodBoolean>;
35
+ permission: z.ZodDefault<z.ZodBoolean>;
36
+ includeChildLifecycle: z.ZodDefault<z.ZodBoolean>;
37
+ completionDebounceMs: z.ZodDefault<z.ZodNumber>;
38
+ pluginBufferSize: z.ZodDefault<z.ZodNumber>;
39
+ }, z.core.$strict>>;
40
+ broker: z.ZodPrefault<z.ZodObject<{
41
+ host: z.ZodDefault<z.ZodString>;
42
+ port: z.ZodDefault<z.ZodNumber>;
43
+ }, z.core.$strict>>;
44
+ interaction: z.ZodPrefault<z.ZodObject<{
45
+ sessionPromptTtlMinutes: z.ZodDefault<z.ZodNumber>;
46
+ questionTtlMinutes: z.ZodDefault<z.ZodNumber>;
47
+ }, z.core.$strict>>;
48
+ voice: z.ZodOptional<z.ZodObject<{
49
+ enabled: z.ZodDefault<z.ZodBoolean>;
50
+ provider: z.ZodDefault<z.ZodEnum<{
51
+ groq: "groq";
52
+ openai: "openai";
53
+ cloudflare: "cloudflare";
54
+ custom: "custom";
55
+ }>>;
56
+ apiKey: z.ZodOptional<z.ZodString>;
57
+ apiKeyFile: z.ZodOptional<z.ZodString>;
58
+ accountId: z.ZodOptional<z.ZodString>;
59
+ model: z.ZodDefault<z.ZodString>;
60
+ endpoint: z.ZodOptional<z.ZodString>;
61
+ language: z.ZodDefault<z.ZodString>;
62
+ }, z.core.$strict>>;
63
+ }, z.core.$strict>;
64
+ export type NotifierConfig = z.infer<typeof NotifierConfigSchema>;
65
+ export type ConfigFingerprint = z.infer<typeof ConfigFingerprintSchema>;
66
+ export declare class ConfigValidationError extends Error {
67
+ readonly code: string;
68
+ constructor(code: string, message: string);
69
+ }
70
+ export declare function readNotifierBotToken(config: NotifierConfig): Promise<string>;
71
+ export declare function readVoiceApiKey(config: NotifierConfig): Promise<string | undefined>;
72
+ export declare function assertSecureTokenFile(path: string): Promise<void>;
73
+ export declare function computeNotifierConfigFingerprint(config: NotifierConfig): ConfigFingerprint;
74
+ export declare function sanitizeConfigError(error: unknown): string;
75
+ export declare function redactSensitiveText(input: string): string;
76
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,uBAAuB,aAAqC,CAAC;AAE1E,eAAO,MAAM,sBAAsB;;;;EAAkC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA4G7B,CAAC;AAEL,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBlF;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAQzF;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBvE;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,cAAc,GAAG,iBAAiB,CAmB1F;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAS1D;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,21 @@
1
+ export type DoctorCheckStatus = "pass" | "warn" | "fail";
2
+ export type DoctorCheck = {
3
+ name: string;
4
+ status: DoctorCheckStatus;
5
+ message: string;
6
+ remediation?: string;
7
+ };
8
+ export type DoctorReport = {
9
+ ready: boolean;
10
+ checks: DoctorCheck[];
11
+ };
12
+ export type DoctorOptions = {
13
+ rawConfig?: unknown;
14
+ stateDirectory?: string;
15
+ port?: number;
16
+ fetch?: typeof fetch;
17
+ env?: NodeJS.ProcessEnv;
18
+ };
19
+ export declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
20
+ export declare function formatDoctorReport(report: DoctorReport): string;
21
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,CAAC;AAEF,wBAAsB,SAAS,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAiDlF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAQ/D"}
@@ -0,0 +1,120 @@
1
+ export declare const en: {
2
+ readonly "event.completed": "Task completed";
3
+ readonly "event.error": "Session error";
4
+ readonly "event.question": "Your answer is required";
5
+ readonly "event.permission": "Terminal intervention is required";
6
+ readonly "field.project": "Project";
7
+ readonly "field.session": "Session";
8
+ readonly "field.root": "Root";
9
+ readonly "field.time": "Time";
10
+ readonly "field.summary": "Summary";
11
+ readonly "status.complete": "Status: complete";
12
+ readonly "status.error": "Status: error";
13
+ readonly "status.waiting": "Status: waiting for your answer";
14
+ readonly "status.permission": "Status: permission required";
15
+ readonly "action.reply": "Action: reply to this message to continue the root session.";
16
+ readonly "action.checkTerminal": "Action: check the terminal before continuing.";
17
+ readonly "action.answerQuestion": "Action: answer this exact question or return to the terminal if it is ambiguous.";
18
+ readonly "action.useTerminal": "Action: use the terminal. Telegram permission approval is disabled in V1.";
19
+ readonly "action.permissionChoice": "Action: tap a button below or reply in the terminal.";
20
+ readonly "button.allowOnce": "✅ Allow Once";
21
+ readonly "button.alwaysAllow": "⚡ Always Allow";
22
+ readonly "button.reject": "❌ Reject";
23
+ readonly "feedback.permissionGranted": "Permission granted.";
24
+ readonly "feedback.permissionRejected": "Permission rejected.";
25
+ readonly "interaction.accepted": "Your response was delivered.";
26
+ readonly "interaction.alreadyHandled": "This response was already handled.";
27
+ readonly "interaction.expired": "This notification has expired. Wait for a new notification.";
28
+ readonly "interaction.indeterminate": "OpenCode did not confirm the result. Check the terminal before retrying.";
29
+ readonly "interaction.invalid": "This response is not valid for the pending question.";
30
+ readonly "interaction.offline": "The OpenCode instance is offline. Return to the terminal.";
31
+ readonly "interaction.rejected": "This response was rejected.";
32
+ readonly "interaction.replyRequired": "Reply directly to an actionable notification.";
33
+ readonly "interaction.stale": "This notification is no longer active. Wait for a new notification.";
34
+ readonly "interaction.terminalOnly": "This action must be handled in the OpenCode terminal.";
35
+ readonly "test.message": "OpenCode Telegram Link test notification";
36
+ readonly "cmd.help.title": "🤖 <b>OpenCode Commander - Commands:</b>";
37
+ readonly "cmd.help.status": "Show Gateway & system status";
38
+ readonly "cmd.help.nodes": "List connected node machines";
39
+ readonly "cmd.help.sessions": "List active working sessions";
40
+ readonly "cmd.help.cancel": "Cancel an active session";
41
+ readonly "cmd.help.run": "Dispatch new task to a machine or project";
42
+ readonly "cmd.help.help": "Show this help menu";
43
+ readonly "cmd.status.title": "📊 <b>Gateway System Status:</b>";
44
+ readonly "cmd.nodes.title": "🌐 <b>Connected Machines:</b>";
45
+ readonly "cmd.nodes.empty": "No nodes currently connected.";
46
+ readonly "cmd.sessions.title": "📝 <b>Active Sessions:</b>";
47
+ readonly "cmd.sessions.empty": "No active sessions running.";
48
+ readonly "cmd.cancel.success": "🛑 Task canceled successfully.";
49
+ readonly "cmd.cancel.failed": "❌ Failed to cancel task.";
50
+ readonly "cmd.cancel.notFound": "⚠️ Session not found or target host is offline.";
51
+ readonly "cmd.cancel.ambiguous": "⚠️ Ambiguous session target: multiple sessions matched this ID or prefix. Please provide the exact full Session ID or specify the target project.";
52
+ readonly "cmd.cancel.usage": "ℹ️ Usage: <code>/cancel &lt;session_id&gt;</code>";
53
+ readonly "cmd.run.spawned": "🚀 Task dispatched successfully to";
54
+ readonly "cmd.run.failed": "❌ Failed to dispatch task";
55
+ readonly "cmd.run.notFound": "⚠️ Target machine or project not found. Type /nodes to inspect connected machines.";
56
+ readonly "cmd.run.ambiguous": "⚠️ Ambiguous session target: multiple sessions matched this ID or prefix. Please provide the exact full Session ID or specify the target project.";
57
+ readonly "cmd.run.usage": "ℹ️ Usage: <code>/run &lt;project_or_host&gt; &lt;prompt&gt;</code>\nExample: <code>/run adspower-farm check crawling logs</code>";
58
+ readonly "cmd.unknown": "❓ Unknown command. Type /help to view available commands.";
59
+ };
60
+ export type MessageKey = keyof typeof en;
61
+ export declare const zhTW: {
62
+ readonly "event.completed": "工作已完成";
63
+ readonly "event.error": "Session 發生錯誤";
64
+ readonly "event.question": "需要你的回答";
65
+ readonly "event.permission": "需要權限確認";
66
+ readonly "field.project": "專案";
67
+ readonly "field.session": "Session";
68
+ readonly "field.root": "根 Session";
69
+ readonly "field.time": "時間";
70
+ readonly "field.summary": "執行結論";
71
+ readonly "status.complete": "狀態:已完成";
72
+ readonly "status.error": "狀態:發生錯誤";
73
+ readonly "status.waiting": "狀態:等待你的回答";
74
+ readonly "status.permission": "狀態:需要權限確認";
75
+ readonly "action.reply": "操作:直接回覆此訊息即可繼續交談。";
76
+ readonly "action.checkTerminal": "操作:請在繼續前先檢查終端機。";
77
+ readonly "action.answerQuestion": "操作:請直接回覆此問題,若不明確請回到終端機。";
78
+ readonly "action.useTerminal": "操作:請點擊下方按鈕或在終端機中確認。";
79
+ readonly "action.permissionChoice": "操作:請點擊下方按鈕或在終端機中確認。";
80
+ readonly "button.allowOnce": "✅ 允許本次";
81
+ readonly "button.alwaysAllow": "⚡ 總是允許";
82
+ readonly "button.reject": "❌ 拒絕";
83
+ readonly "feedback.permissionGranted": "權限已允許。";
84
+ readonly "feedback.permissionRejected": "權限已拒絕。";
85
+ readonly "interaction.accepted": "你的回覆已送達。";
86
+ readonly "interaction.alreadyHandled": "此回覆已處理過。";
87
+ readonly "interaction.expired": "此通知已過期,請等待新的通知。";
88
+ readonly "interaction.indeterminate": "OpenCode 尚未確認結果,請回到終端機檢查後再重試。";
89
+ readonly "interaction.invalid": "此回覆不符合目前問題的要求。";
90
+ readonly "interaction.offline": "OpenCode 目前離線,請回到終端機。";
91
+ readonly "interaction.rejected": "此回覆已被拒絕。";
92
+ readonly "interaction.replyRequired": "請直接回覆可操作的通知。";
93
+ readonly "interaction.stale": "此通知已不再有效,請等待新的通知。";
94
+ readonly "interaction.terminalOnly": "此操作必須在 OpenCode 終端機中處理。";
95
+ readonly "test.message": "OpenCode Telegram Link 測試通知";
96
+ readonly "cmd.help.title": "🤖 <b>OpenCode 行動指揮官 - 可用指令:</b>";
97
+ readonly "cmd.help.status": "查看 Gateway 與系統狀態";
98
+ readonly "cmd.help.nodes": "列出所有在線連線中的電腦主機";
99
+ readonly "cmd.help.sessions": "列出目前活躍的工作階段";
100
+ readonly "cmd.help.cancel": "中止正在執行中的任務";
101
+ readonly "cmd.help.run": "向指定主機或專案派發新任務";
102
+ readonly "cmd.help.help": "顯示此說明選單";
103
+ readonly "cmd.status.title": "📊 <b>Gateway 系統狀態:</b>";
104
+ readonly "cmd.nodes.title": "🌐 <b>已連線電腦主機:</b>";
105
+ readonly "cmd.nodes.empty": "目前沒有任何在線電腦。";
106
+ readonly "cmd.sessions.title": "📝 <b>活躍工作階段:</b>";
107
+ readonly "cmd.sessions.empty": "目前沒有任何進行中的工作階段。";
108
+ readonly "cmd.cancel.success": "🛑 任務已成功中止。";
109
+ readonly "cmd.cancel.failed": "❌ 任務中止失敗。";
110
+ readonly "cmd.cancel.notFound": "⚠️ 找不到指定 Session 或目標主機已離線。";
111
+ readonly "cmd.cancel.ambiguous": "⚠️ 目標 Session 不明確:多個工作階段匹配此 ID 或前綴。請提供完整 Session ID 或指定專案名稱。";
112
+ readonly "cmd.cancel.usage": "ℹ️ 使用方式:<code>/cancel &lt;session_id&gt;</code>";
113
+ readonly "cmd.run.spawned": "🚀 任務已成功指派至";
114
+ readonly "cmd.run.failed": "❌ 任務指派失敗";
115
+ readonly "cmd.run.notFound": "⚠️ 找不到指定的目標主機或專案。請先輸入 /nodes 確認。";
116
+ readonly "cmd.run.ambiguous": "⚠️ 目標 Session 不明確:多個工作階段匹配此 ID 或前綴。請提供完整 Session ID 或指定專案名稱。";
117
+ readonly "cmd.run.usage": "ℹ️ 使用方式:<code>/run &lt;主機或專案&gt; &lt;任務指令&gt;</code>\n例如:<code>/run adspower-farm 請檢查爬蟲日誌</code>";
118
+ readonly "cmd.unknown": "❓ 未知指令。請輸入 /help 查看可用指令列表。";
119
+ };
120
+ //# sourceMappingURL=catalogs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogs.d.ts","sourceRoot":"","sources":["../../src/i18n/catalogs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEL,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,EAAE,CAAC;AAEzC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6D8B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type MessageKey } from "./catalogs";
2
+ export type SupportedLocale = "en" | "zh-TW";
3
+ export declare function canonicalizeLocale(locale: string | undefined): SupportedLocale | undefined;
4
+ export declare function resolveLocale(input: {
5
+ explicit?: string;
6
+ openCode?: string;
7
+ system?: string;
8
+ }): SupportedLocale;
9
+ export declare function translate(locale: SupportedLocale, key: MessageKey): string;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,UAAU,EAAQ,MAAM,YAAY,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,OAAO,CAAC;AAO7C,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,CAe1F;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,eAAe,CAOlB;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAE1E"}
@@ -0,0 +1,39 @@
1
+ import type { SupportedLocale } from "../i18n";
2
+ import type { RouteIntent } from "../plugin/client";
3
+ import type { NormalizedNotification, RouteKey } from "../protocol";
4
+ type RouteClient = {
5
+ upsertRoute(intent: RouteIntent): Promise<RouteKey | undefined>;
6
+ removeRoute(projectId: string, sessionId: string): Promise<void>;
7
+ activeRoute(projectId: string, sessionId: string): RouteKey | undefined;
8
+ };
9
+ type NotificationFilters = {
10
+ completion: boolean;
11
+ error: boolean;
12
+ question: boolean;
13
+ permission: boolean;
14
+ };
15
+ export type OpenCodeEventBridgeOptions = {
16
+ broker: RouteClient;
17
+ projectId: string;
18
+ projectLabel: string;
19
+ hostLabel?: string | undefined;
20
+ locale: SupportedLocale;
21
+ now?: () => Date;
22
+ notificationFilters?: Partial<NotificationFilters>;
23
+ includeChildLifecycle?: boolean;
24
+ completionDebounceMs?: number;
25
+ bufferLimit?: number;
26
+ dedupeTtlMs?: number;
27
+ fetchSummary?: (sessionId: string) => Promise<string | undefined>;
28
+ onNotification: (notification: NormalizedNotification) => void | Promise<void>;
29
+ onDiagnostic?: (code: string, eventType: string) => void;
30
+ };
31
+ export declare class OpenCodeEventBridge {
32
+ #private;
33
+ constructor(options: OpenCodeEventBridgeOptions);
34
+ dispose(): void;
35
+ flush(): Promise<void>;
36
+ handle(input: unknown): Promise<void>;
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/opencode/bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SA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IAAI,CAAC,CAAC;IAC/E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D,CAAC;AAEF,qBAAa,mBAAmB;;gBA0BlB,OAAO,EAAE,0BAA0B;IAiB/C,OAAO,IAAI,IAAI;IAST,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAetB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA0X5C"}
@@ -0,0 +1,20 @@
1
+ import { type NotifierConfig } from "../config";
2
+ export type DiscoveredConfigFile = {
3
+ path: string;
4
+ exists: boolean;
5
+ isWorkspace: boolean;
6
+ };
7
+ export declare function parseJsonc<T = Record<string, unknown>>(content: string): T;
8
+ export declare function getCandidateConfigPaths(cwd?: string): string[];
9
+ export declare function discoverOpenCodeConfigFiles(cwd?: string): Promise<DiscoveredConfigFile[]>;
10
+ export declare function generatePluginConfigSnippet(config: NotifierConfig): string;
11
+ export declare function loadResolvedNotifierConfig(explicitOptions?: unknown, cwd?: string): Promise<NotifierConfig | undefined>;
12
+ export declare function injectOpenCodeConfig(targetPath: string, config: NotifierConfig): Promise<{
13
+ targetPath: string;
14
+ backupPath?: string;
15
+ }>;
16
+ export declare function removeOpenCodeConfig(targetPath: string): Promise<{
17
+ modified: boolean;
18
+ backupPath?: string;
19
+ }>;
20
+ //# sourceMappingURL=config-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-helper.d.ts","sourceRoot":"","sources":["../../src/opencode/config-helper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,WAAW,CAAC;AAGtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CA6E1E;AAED,wBAAgB,uBAAuB,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,EAAE,CAgC7E;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAqCjC;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CA+B1E;AAED,wBAAsB,0BAA0B,CAC9C,eAAe,CAAC,EAAE,OAAO,EACzB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CA4FrC;AAED,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA0ItD;AAED,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAwErD"}
@@ -0,0 +1,47 @@
1
+ import type { NormalizedQuestion } from "../protocol";
2
+ export type SessionSourceEvent = {
3
+ kind: "session.upsert" | "session.delete";
4
+ sessionId: string;
5
+ title: string;
6
+ parentId?: string;
7
+ } | {
8
+ kind: "session.busy";
9
+ sessionId: string;
10
+ };
11
+ export type NotificationSourceEvent = {
12
+ kind: "session.completed";
13
+ sessionId: string;
14
+ sourceEventId?: string;
15
+ } | {
16
+ kind: "session.error";
17
+ sessionId: string;
18
+ errorCategory: string;
19
+ sourceEventId?: string;
20
+ } | {
21
+ kind: "question.pending";
22
+ sessionId: string;
23
+ interactionId: string;
24
+ questions: NormalizedQuestion[];
25
+ sourceEventId?: string;
26
+ } | {
27
+ kind: "permission.pending";
28
+ sessionId: string;
29
+ interactionId: string;
30
+ permissionCategory: string;
31
+ sourceEventId?: string;
32
+ };
33
+ export type OpenCodeEventResult = {
34
+ status: "session";
35
+ event: SessionSourceEvent;
36
+ } | {
37
+ status: "notification";
38
+ event: NotificationSourceEvent;
39
+ } | {
40
+ status: "ignored";
41
+ } | {
42
+ status: "invalid";
43
+ eventType: string;
44
+ code: string;
45
+ };
46
+ export declare function normalizeOpenCodeEvent(input: unknown): OpenCodeEventResult;
47
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/opencode/events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAC1B;IACE,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN,MAAM,MAAM,uBAAuB,GAC/B;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEN,MAAM,MAAM,mBAAmB,GAC3B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAChD;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,uBAAuB,CAAA;CAAE,GAC1D;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAmC3D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CA8G1E"}
@@ -0,0 +1,4 @@
1
+ export { OpenCodeEventBridge, type OpenCodeEventBridgeOptions, } from "./bridge";
2
+ export { type DiscoveredConfigFile, discoverOpenCodeConfigFiles, generatePluginConfigSnippet, getCandidateConfigPaths, injectOpenCodeConfig, loadResolvedNotifierConfig, removeOpenCodeConfig, } from "./config-helper";
3
+ export { type NotificationSourceEvent, normalizeOpenCodeEvent, type OpenCodeEventResult, type SessionSourceEvent, } from "./events";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/opencode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,oBAAoB,EACzB,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,uBAAuB,EAC5B,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC"}