dsh-agent-enhancer 0.4.1 → 0.5.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/README.md +4 -3
- package/lib/client/dsh/settings-catalog.d.ts +3 -3
- package/lib/client/dsh/settings-catalog.d.ts.map +1 -1
- package/lib/client/dsh/settings-features.d.ts +2 -0
- package/lib/client/dsh/settings-features.d.ts.map +1 -1
- package/lib/client/dsh/settings.d.ts.map +1 -1
- package/lib/client/locales.d.ts +171 -1
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/remote/panel.d.ts +19 -0
- package/lib/client/remote/panel.d.ts.map +1 -0
- package/lib/client/remote/qr-code.d.ts +13 -0
- package/lib/client/remote/qr-code.d.ts.map +1 -0
- package/lib/client/remote/qr.d.ts +27 -0
- package/lib/client/remote/qr.d.ts.map +1 -0
- package/lib/client/remote.d.ts +36 -1
- package/lib/client/remote.d.ts.map +1 -1
- package/lib/client/soft-pause/action.d.ts.map +1 -1
- package/lib/client/soft-pause/controller.d.ts +8 -8
- package/lib/client/soft-pause/controller.d.ts.map +1 -1
- package/lib/client/soft-pause/visibility.d.ts +7 -1
- package/lib/client/soft-pause/visibility.d.ts.map +1 -1
- package/lib/client.js +2786 -1096
- package/lib/client.js.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/host/index.d.ts +40 -2
- package/lib/host/index.d.ts.map +1 -1
- package/lib/host/remote/approval-router.d.ts +35 -0
- package/lib/host/remote/approval-router.d.ts.map +1 -0
- package/lib/host/remote/bindings.d.ts +56 -0
- package/lib/host/remote/bindings.d.ts.map +1 -0
- package/lib/host/remote/channels/cursor.d.ts +18 -0
- package/lib/host/remote/channels/cursor.d.ts.map +1 -0
- package/lib/host/remote/channels/poller.d.ts +59 -0
- package/lib/host/remote/channels/poller.d.ts.map +1 -0
- package/lib/host/remote/channels/status.d.ts +31 -0
- package/lib/host/remote/channels/status.d.ts.map +1 -0
- package/lib/host/remote/channels/types.d.ts +57 -0
- package/lib/host/remote/channels/types.d.ts.map +1 -0
- package/lib/host/remote/commands.d.ts +39 -0
- package/lib/host/remote/commands.d.ts.map +1 -0
- package/lib/host/remote/controller.d.ts +118 -0
- package/lib/host/remote/controller.d.ts.map +1 -0
- package/lib/host/remote/feishu/adapter.d.ts +28 -0
- package/lib/host/remote/feishu/adapter.d.ts.map +1 -0
- package/lib/host/remote/feishu/channel.d.ts +49 -0
- package/lib/host/remote/feishu/channel.d.ts.map +1 -0
- package/lib/host/remote/feishu/credentials.d.ts +10 -0
- package/lib/host/remote/feishu/credentials.d.ts.map +1 -0
- package/lib/host/remote/feishu/transport.d.ts +109 -0
- package/lib/host/remote/feishu/transport.d.ts.map +1 -0
- package/lib/host/remote/host-bridge.d.ts +72 -0
- package/lib/host/remote/host-bridge.d.ts.map +1 -0
- package/lib/host/remote/hub.d.ts +117 -0
- package/lib/host/remote/hub.d.ts.map +1 -0
- package/lib/host/remote/ports.d.ts +7 -0
- package/lib/host/remote/ports.d.ts.map +1 -0
- package/lib/host/remote/render.d.ts +33 -0
- package/lib/host/remote/render.d.ts.map +1 -0
- package/lib/host/remote/task-board.d.ts +44 -0
- package/lib/host/remote/task-board.d.ts.map +1 -0
- package/lib/host/remote/telegram/adapter.d.ts +29 -0
- package/lib/host/remote/telegram/adapter.d.ts.map +1 -0
- package/lib/host/remote/telegram/channel.d.ts +51 -0
- package/lib/host/remote/telegram/channel.d.ts.map +1 -0
- package/lib/host/remote/telegram/credentials.d.ts +10 -0
- package/lib/host/remote/telegram/credentials.d.ts.map +1 -0
- package/lib/host/remote/telegram/transport.d.ts +54 -0
- package/lib/host/remote/telegram/transport.d.ts.map +1 -0
- package/lib/host/remote/types.d.ts +60 -0
- package/lib/host/remote/types.d.ts.map +1 -0
- package/lib/host/remote/weixin/adapter.d.ts +40 -0
- package/lib/host/remote/weixin/adapter.d.ts.map +1 -0
- package/lib/host/remote/weixin/capabilities.d.ts +4 -0
- package/lib/host/remote/weixin/capabilities.d.ts.map +1 -0
- package/lib/host/remote/weixin/channel.d.ts +60 -0
- package/lib/host/remote/weixin/channel.d.ts.map +1 -0
- package/lib/host/remote/weixin/credentials.d.ts +17 -0
- package/lib/host/remote/weixin/credentials.d.ts.map +1 -0
- package/lib/host/remote/weixin/cursor.d.ts +2 -0
- package/lib/host/remote/weixin/cursor.d.ts.map +1 -0
- package/lib/host/remote/weixin/login.d.ts +47 -0
- package/lib/host/remote/weixin/login.d.ts.map +1 -0
- package/lib/host/remote/weixin/transport.d.ts +74 -0
- package/lib/host/remote/weixin/transport.d.ts.map +1 -0
- package/lib/host/rpc.d.ts +167 -0
- package/lib/host/rpc.d.ts.map +1 -1
- package/lib/host/soft-pause/gate.d.ts +13 -0
- package/lib/host/soft-pause/gate.d.ts.map +1 -1
- package/lib/host/soft-pause/lineage.d.ts +42 -0
- package/lib/host/soft-pause/lineage.d.ts.map +1 -0
- package/lib/host/soft-pause/live.d.ts.map +1 -1
- package/lib/index.js +4256 -190
- package/lib/index.js.map +4 -4
- package/package.json +14 -12
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BindingStore } from '../bindings.ts';
|
|
2
|
+
import type { ChannelCursor } from '../channels/poller.ts';
|
|
3
|
+
import type { RemoteController } from '../controller.ts';
|
|
4
|
+
import type { ChannelCapabilities } from '../types.ts';
|
|
5
|
+
import { FeishuTransport } from './transport.ts';
|
|
6
|
+
import type { FeishuCredentials } from './transport.ts';
|
|
7
|
+
export interface FeishuAdapterOptions {
|
|
8
|
+
readonly transport: FeishuTransport;
|
|
9
|
+
readonly credentials: FeishuCredentials;
|
|
10
|
+
readonly controller: RemoteController;
|
|
11
|
+
readonly bindings: BindingStore;
|
|
12
|
+
readonly capabilities: ChannelCapabilities;
|
|
13
|
+
readonly cursor?: ChannelCursor;
|
|
14
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
15
|
+
readonly onFatal?: (error: unknown) => void;
|
|
16
|
+
readonly onError?: (error: unknown) => void;
|
|
17
|
+
readonly refresh?: () => Promise<unknown>;
|
|
18
|
+
readonly emptyPageDelayMs?: number;
|
|
19
|
+
}
|
|
20
|
+
/** Feishu channel: same poller, Feishu transport (WebSocket events + HTTP sends). */
|
|
21
|
+
export declare class FeishuAdapter {
|
|
22
|
+
private readonly poller;
|
|
23
|
+
constructor(options: FeishuAdapterOptions);
|
|
24
|
+
stop(): void;
|
|
25
|
+
get running(): boolean;
|
|
26
|
+
run(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/remote/feishu/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAA;IACnC,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAA;IACvC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;IACrC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAA;IAC/B,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAA;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAA;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACnC;AASD,qFAAqF;AACrF,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,OAAO,EAAE,oBAAoB;IAyBzC,IAAI,IAAI,IAAI;IAIZ,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { BindingStore, RemoteChannel } from '../bindings.ts';
|
|
2
|
+
import type { ChannelStatus } from '../channels/status.ts';
|
|
3
|
+
import type { RemoteController } from '../controller.ts';
|
|
4
|
+
import type { ChannelCapabilities } from '../types.ts';
|
|
5
|
+
import type { FeishuCredentialStore } from './credentials.ts';
|
|
6
|
+
import { FeishuTransport } from './transport.ts';
|
|
7
|
+
export interface FeishuChannelOptions {
|
|
8
|
+
readonly capabilities: ChannelCapabilities;
|
|
9
|
+
readonly credentials: FeishuCredentialStore;
|
|
10
|
+
readonly bindings: BindingStore;
|
|
11
|
+
readonly controller: RemoteController;
|
|
12
|
+
readonly refresh: () => Promise<unknown>;
|
|
13
|
+
readonly createTransport?: () => FeishuTransport;
|
|
14
|
+
readonly onError?: (error: unknown) => void;
|
|
15
|
+
readonly emptyPageDelayMs?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface FeishuConnectResult {
|
|
18
|
+
readonly ok: boolean;
|
|
19
|
+
readonly name?: string;
|
|
20
|
+
readonly error?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Feishu: app-credential login, the long connection, binding and the poll loop. */
|
|
23
|
+
export declare class FeishuChannel {
|
|
24
|
+
private readonly options;
|
|
25
|
+
readonly id: RemoteChannel;
|
|
26
|
+
private readonly transport;
|
|
27
|
+
private adapter;
|
|
28
|
+
private credentialsValue;
|
|
29
|
+
private phaseValue;
|
|
30
|
+
private errorValue;
|
|
31
|
+
private generation;
|
|
32
|
+
constructor(options: FeishuChannelOptions);
|
|
33
|
+
get running(): boolean;
|
|
34
|
+
status(): ChannelStatus;
|
|
35
|
+
start(): Promise<void>;
|
|
36
|
+
/** Validate the app credentials, then keep the long connection open. */
|
|
37
|
+
connect(appId: string, appSecret: string): Promise<FeishuConnectResult>;
|
|
38
|
+
logout(): Promise<void>;
|
|
39
|
+
stop(): void;
|
|
40
|
+
/** A proactive push failed: keep the connection, surface the reason. */
|
|
41
|
+
reportSendError(error: unknown): void;
|
|
42
|
+
send(chatId: string, text: string, buttons?: readonly {
|
|
43
|
+
readonly label: string;
|
|
44
|
+
readonly command: string;
|
|
45
|
+
}[]): Promise<void>;
|
|
46
|
+
contextFor(_chatId: string): string | undefined;
|
|
47
|
+
private connectStored;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../src/host/remote/feishu/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGhD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC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ASZ,wEAAwE;IACxE,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI/B,IAAI,CACR,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,GACxE,OAAO,CAAC,IAAI,CAAC;IAehB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI/C,OAAO,CAAC,aAAa;CAkCtB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { FeishuCredentials } from './transport.ts';
|
|
3
|
+
export interface FeishuCredentialStore {
|
|
4
|
+
load(): Promise<FeishuCredentials | undefined>;
|
|
5
|
+
save(credentials: FeishuCredentials): Promise<void>;
|
|
6
|
+
clear(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** App ID + secret storage on the host's credential service; no plaintext fallback. */
|
|
9
|
+
export declare function createFeishuCredentialStore(ctx: Context): FeishuCredentialStore;
|
|
10
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/host/remote/feishu/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAevD,MAAM,WAAW,qBAAqB;IACpC,IAAI,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAA;IAC9C,IAAI,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAiCD,uFAAuF;AACvF,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,qBAAqB,CAgC/E"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { InboundMessage, UpdatesPage } from '../channels/types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Feishu (Lark) bot transport.
|
|
4
|
+
*
|
|
5
|
+
* Two halves of one bot: the HTTP side sends messages and reads the bot
|
|
6
|
+
* identity, the WebSocket side ("长连接") receives events without a public
|
|
7
|
+
* address. Events are queued here and drained by the shared channel poller, so
|
|
8
|
+
* Feishu reuses the same binding and command rules as every other channel.
|
|
9
|
+
*
|
|
10
|
+
* The WebSocket protocol is protobuf-framed, so the official SDK does that one
|
|
11
|
+
* job and is imported lazily: a host that never connects Feishu never loads it,
|
|
12
|
+
* and tests inject a fake loader instead of the real socket.
|
|
13
|
+
*/
|
|
14
|
+
export interface FeishuCredentials {
|
|
15
|
+
readonly appId: string;
|
|
16
|
+
readonly appSecret: string;
|
|
17
|
+
/** Bot display name learned at connect time. */
|
|
18
|
+
readonly name?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class FeishuTransportError extends Error {
|
|
21
|
+
readonly code: string;
|
|
22
|
+
readonly detail: {
|
|
23
|
+
readonly status?: number;
|
|
24
|
+
readonly retryAfterMs?: number;
|
|
25
|
+
};
|
|
26
|
+
constructor(code: string, message: string, detail?: {
|
|
27
|
+
readonly status?: number;
|
|
28
|
+
readonly retryAfterMs?: number;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Minimal structural view of the SDK pieces we use. */
|
|
32
|
+
export interface FeishuSocket {
|
|
33
|
+
start(params: {
|
|
34
|
+
eventDispatcher: FeishuDispatcher;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
close(params?: {
|
|
37
|
+
force?: boolean;
|
|
38
|
+
}): void;
|
|
39
|
+
}
|
|
40
|
+
export interface FeishuDispatcher {
|
|
41
|
+
register(handles: Record<string, (data: unknown) => unknown>): unknown;
|
|
42
|
+
}
|
|
43
|
+
export interface FeishuSdk {
|
|
44
|
+
readonly WSClient: new (params: {
|
|
45
|
+
readonly appId: string;
|
|
46
|
+
readonly appSecret: string;
|
|
47
|
+
readonly autoReconnect?: boolean;
|
|
48
|
+
readonly loggerLevel?: number;
|
|
49
|
+
readonly onError?: (error: Error) => void;
|
|
50
|
+
readonly onReady?: () => void;
|
|
51
|
+
}) => FeishuSocket;
|
|
52
|
+
readonly EventDispatcher: new (params: {
|
|
53
|
+
readonly loggerLevel?: number;
|
|
54
|
+
}) => FeishuDispatcher;
|
|
55
|
+
readonly LoggerLevel?: {
|
|
56
|
+
readonly error?: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export interface FeishuTransportOptions {
|
|
60
|
+
readonly fetchImpl?: typeof fetch;
|
|
61
|
+
readonly apiBase?: string;
|
|
62
|
+
readonly requestTimeoutMs?: number;
|
|
63
|
+
/** How long one `getUpdates` waits for a pushed event before returning empty. */
|
|
64
|
+
readonly waitTimeoutMs?: number;
|
|
65
|
+
readonly loadSdk?: () => Promise<FeishuSdk>;
|
|
66
|
+
}
|
|
67
|
+
/** One `im.message.receive_v1` event; bot DMs only, like the other channels. */
|
|
68
|
+
export declare function parseMessageEvent(data: unknown): InboundMessage | undefined;
|
|
69
|
+
/** One `card.action.trigger` event: the tapped button's command. */
|
|
70
|
+
export declare function parseCardAction(data: unknown): InboundMessage | undefined;
|
|
71
|
+
export declare class FeishuTransport {
|
|
72
|
+
private readonly fetchImpl;
|
|
73
|
+
private readonly apiBase;
|
|
74
|
+
private readonly requestTimeoutMs;
|
|
75
|
+
private readonly waitTimeoutMs;
|
|
76
|
+
private readonly loadSdk;
|
|
77
|
+
private readonly tokens;
|
|
78
|
+
private readonly queue;
|
|
79
|
+
private readonly seen;
|
|
80
|
+
private socket;
|
|
81
|
+
private socketError;
|
|
82
|
+
private waiter;
|
|
83
|
+
constructor(options?: FeishuTransportOptions);
|
|
84
|
+
get lastSocketError(): string | undefined;
|
|
85
|
+
private call;
|
|
86
|
+
private tenantToken;
|
|
87
|
+
/** Confirm the credentials and learn the bot name. */
|
|
88
|
+
validate(credentials: FeishuCredentials): Promise<{
|
|
89
|
+
name?: string;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Open the long connection. Events arrive on the SDK's socket and wait in the
|
|
93
|
+
* queue for `getUpdates`.
|
|
94
|
+
*/
|
|
95
|
+
start(credentials: FeishuCredentials): Promise<void>;
|
|
96
|
+
stop(): void;
|
|
97
|
+
private push;
|
|
98
|
+
private wake;
|
|
99
|
+
private wait;
|
|
100
|
+
/** Push channels have no cursor; keep the empty string so the poller is happy. */
|
|
101
|
+
getUpdates(cursor?: string): Promise<UpdatesPage>;
|
|
102
|
+
sendText(credentials: FeishuCredentials, chatId: string, text: string, options?: {
|
|
103
|
+
readonly buttons?: readonly {
|
|
104
|
+
readonly label: string;
|
|
105
|
+
readonly command: string;
|
|
106
|
+
}[];
|
|
107
|
+
}): Promise<string>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../src/host/remote/feishu/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEpF;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,gDAAgD;IAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EAAE,MAAM;IAErB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,YAA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CAAC;IAO1E;;;OAGG;IACG,KAAK,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0C1D,IAAI,IAAI,IAAI;IAeZ,OAAO,CAAC,IAAI;IAgBZ,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,IAAI;IAcZ,kFAAkF;IAC5E,UAAU,CAAC,MAAM,SAAK,GAAG,OAAO,CAAC,WAAW,CAAC;IAM7C,QAAQ,CACZ,WAAW,EAAE,iBAAiB,EAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS;YAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAO,GACnG,OAAO,CAAC,MAAM,CAAC;CAmCnB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { RemoteController } from './controller.ts';
|
|
3
|
+
import type { SessionRow } from './controller.ts';
|
|
4
|
+
import type { ChannelCapabilities } from './types.ts';
|
|
5
|
+
/** Host effects the bridge cannot perform itself. */
|
|
6
|
+
export interface HostBridgePorts {
|
|
7
|
+
listSessions(): Promise<readonly SessionRow[]>;
|
|
8
|
+
prompt(sessionId: string, text: string, mode: 'queue' | 'steer'): Promise<void>;
|
|
9
|
+
cancel(sessionId: string): Promise<void>;
|
|
10
|
+
setPaused(sessionId: string, paused: boolean): Promise<void>;
|
|
11
|
+
/** Read the last assistant text from history for `详情` on old turns. */
|
|
12
|
+
readAnswer?(sessionId: string): Promise<string | undefined>;
|
|
13
|
+
/** Push one notice to the paired chats; failures belong to the channel. */
|
|
14
|
+
notify?(notice: BridgeNotice): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A moment the user may care about. The bridge decides *when*; the channel
|
|
18
|
+
* decides how to phrase and where to send it.
|
|
19
|
+
*/
|
|
20
|
+
export type BridgeNotice = {
|
|
21
|
+
readonly kind: 'approval' | 'question';
|
|
22
|
+
readonly sessionId: string;
|
|
23
|
+
readonly code: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'decided';
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
readonly decision: 'approve' | 'reject' | 'answered';
|
|
28
|
+
readonly chatId?: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: 'failed';
|
|
31
|
+
readonly sessionId: string;
|
|
32
|
+
readonly error?: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: 'done';
|
|
35
|
+
readonly sessionId: string;
|
|
36
|
+
readonly answer?: string;
|
|
37
|
+
};
|
|
38
|
+
export interface HostBridgeOptions {
|
|
39
|
+
readonly ports: HostBridgePorts;
|
|
40
|
+
readonly capabilities: ChannelCapabilities;
|
|
41
|
+
readonly now?: () => number;
|
|
42
|
+
readonly ttlMs?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Whether a remote chat can actually answer right now. Without it a parsed
|
|
45
|
+
* chat holds every approval forever even though nothing is listening.
|
|
46
|
+
*/
|
|
47
|
+
readonly shouldHold?: () => boolean;
|
|
48
|
+
/** Opt-in diagnostic sink; receives metadata only, never message content. */
|
|
49
|
+
readonly debugLog?: (line: string) => void;
|
|
50
|
+
}
|
|
51
|
+
export interface HostBridge {
|
|
52
|
+
readonly controller: RemoteController;
|
|
53
|
+
/** Re-read sessions and register them on the board; returns the row count. */
|
|
54
|
+
refreshSessions(): Promise<number>;
|
|
55
|
+
dispose(): void;
|
|
56
|
+
}
|
|
57
|
+
/** Text blocks of one assistant message, in order. */
|
|
58
|
+
export declare function assistantText(data: Record<string, unknown>): string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Wire the controller to cordis.
|
|
61
|
+
*
|
|
62
|
+
* The event names come from a working 0.2.x implementation:
|
|
63
|
+
* `session/event`, `approval/request`, `user-questions/request`. The two
|
|
64
|
+
* waterline hooks offer the ask on **both** surfaces and return the first
|
|
65
|
+
* decision that arrives, so sitting at the desktop never requires signing out
|
|
66
|
+
* of remote control to approve something.
|
|
67
|
+
*
|
|
68
|
+
* Deliberately conservative: an untracked session, a multi-question card, or a
|
|
69
|
+
* task that already has a pending falls through to `next()` instead of guessing.
|
|
70
|
+
*/
|
|
71
|
+
export declare function installRemoteHostBridge(ctx: Context, options: HostBridgeOptions): HostBridge;
|
|
72
|
+
//# sourceMappingURL=host-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-bridge.d.ts","sourceRoot":"","sources":["../../../src/host/remote/host-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AA0CrD,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,YAAY,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/E,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5D,uEAAuE;IACvE,UAAU,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC3D,2EAA2E;IAC3E,MAAM,CAAC,CAAC,MAAM,EAAE,YAAY,GAAG,IA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,CAAC,MAAM,CAAC,CAAA;IAClC,OAAO,IAAI,IAAI,CAAA;CAChB;AAsCD,sDAAsD;AACtD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAc/E;AAkDD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAmO5F"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { RemoteChannel } from './bindings.ts';
|
|
3
|
+
import type { HubStatus } from './channels/status.ts';
|
|
4
|
+
import type { ChannelCapabilities } from './types.ts';
|
|
5
|
+
import type { TelegramCredentialStore } from './telegram/credentials.ts';
|
|
6
|
+
import { TelegramTransport } from './telegram/transport.ts';
|
|
7
|
+
import type { FeishuCredentialStore } from './feishu/credentials.ts';
|
|
8
|
+
import { FeishuTransport } from './feishu/transport.ts';
|
|
9
|
+
import type { WeixinCredentialStore } from './weixin/credentials.ts';
|
|
10
|
+
import { WeixinTransport } from './weixin/transport.ts';
|
|
11
|
+
import type { LoginTicket } from './weixin/transport.ts';
|
|
12
|
+
export interface RemoteHubOptions {
|
|
13
|
+
readonly ctx: Context;
|
|
14
|
+
/** plugin-data/<package>/remote — bindings and cursors only. */
|
|
15
|
+
readonly rootDir: string;
|
|
16
|
+
readonly setPaused: (sessionId: string, paused: boolean) => Promise<void>;
|
|
17
|
+
readonly createWeixinTransport?: () => WeixinTransport;
|
|
18
|
+
readonly createTelegramTransport?: () => TelegramTransport;
|
|
19
|
+
readonly createFeishuTransport?: () => FeishuTransport;
|
|
20
|
+
readonly weixinCredentials?: WeixinCredentialStore;
|
|
21
|
+
readonly telegramCredentials?: TelegramCredentialStore;
|
|
22
|
+
readonly feishuCredentials?: FeishuCredentialStore;
|
|
23
|
+
readonly weixinCapabilities?: ChannelCapabilities;
|
|
24
|
+
readonly telegramCapabilities?: ChannelCapabilities;
|
|
25
|
+
readonly feishuCapabilities?: ChannelCapabilities;
|
|
26
|
+
readonly onError?: (error: unknown) => void;
|
|
27
|
+
/** Desktop-side warning channel; used when a push surface goes stale. */
|
|
28
|
+
readonly desktopNotify?: (input: {
|
|
29
|
+
readonly title: string;
|
|
30
|
+
readonly body: string;
|
|
31
|
+
readonly tag: string;
|
|
32
|
+
}) => void;
|
|
33
|
+
/** Tests use 1ms; production polls already held for ~35s. */
|
|
34
|
+
readonly emptyPageDelayMs?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Owns every channel, one task board, one host bridge.
|
|
38
|
+
*
|
|
39
|
+
* The board and the bridge are shared on purpose: host events, the session list
|
|
40
|
+
* and all chats must read the same controller. A channel only adds transport,
|
|
41
|
+
* credentials and its own cursor.
|
|
42
|
+
*/
|
|
43
|
+
export declare class RemoteHub {
|
|
44
|
+
private readonly options;
|
|
45
|
+
private bindings;
|
|
46
|
+
private controller;
|
|
47
|
+
private bridge;
|
|
48
|
+
private weixin;
|
|
49
|
+
private telegram;
|
|
50
|
+
private feishu;
|
|
51
|
+
private phaseValue;
|
|
52
|
+
private errorValue;
|
|
53
|
+
private startingPromise;
|
|
54
|
+
private recoverable;
|
|
55
|
+
private retryTimer;
|
|
56
|
+
private retries;
|
|
57
|
+
private generation;
|
|
58
|
+
private lastWechatWarnAt;
|
|
59
|
+
private readonly weixinCapabilities;
|
|
60
|
+
private readonly telegramCapabilities;
|
|
61
|
+
private readonly feishuCapabilities;
|
|
62
|
+
private readonly weixinCredentials;
|
|
63
|
+
private readonly telegramCredentials;
|
|
64
|
+
private readonly feishuCredentials;
|
|
65
|
+
constructor(options: RemoteHubOptions);
|
|
66
|
+
get running(): boolean;
|
|
67
|
+
private anyRunning;
|
|
68
|
+
status(): HubStatus;
|
|
69
|
+
start(): Promise<HubStatus>;
|
|
70
|
+
private startInternal;
|
|
71
|
+
/** QR login for WeChat; connects when the scan is confirmed. */
|
|
72
|
+
beginWeixinLogin(): Promise<LoginTicket>;
|
|
73
|
+
cancelWeixinLogin(): void;
|
|
74
|
+
/** Validate and connect the Telegram bot. */
|
|
75
|
+
connectTelegram(token: string): Promise<{
|
|
76
|
+
ok: boolean;
|
|
77
|
+
username?: string;
|
|
78
|
+
error?: string;
|
|
79
|
+
}>;
|
|
80
|
+
/** Validate the Feishu app credentials and open the long connection. */
|
|
81
|
+
connectFeishu(appId: string, appSecret: string): Promise<{
|
|
82
|
+
ok: boolean;
|
|
83
|
+
name?: string;
|
|
84
|
+
error?: string;
|
|
85
|
+
}>;
|
|
86
|
+
/** One-shot pairing code for the given channel. */
|
|
87
|
+
issueBindCode(channel: RemoteChannel): {
|
|
88
|
+
code: string;
|
|
89
|
+
expiresAt: number;
|
|
90
|
+
};
|
|
91
|
+
devices(channel?: RemoteChannel): {
|
|
92
|
+
chatId: string;
|
|
93
|
+
boundAt: number;
|
|
94
|
+
channel: RemoteChannel;
|
|
95
|
+
}[];
|
|
96
|
+
revoke(channel: RemoteChannel | undefined, chatId?: string): number;
|
|
97
|
+
logout(channel?: RemoteChannel): Promise<void>;
|
|
98
|
+
/** Session deleted: drop it from the board and clear any chat that followed it. */
|
|
99
|
+
forgetSession(sessionId: string): void;
|
|
100
|
+
stop(): void;
|
|
101
|
+
private disposeChannels;
|
|
102
|
+
private refreshPhase;
|
|
103
|
+
/**
|
|
104
|
+
* WeChat only allows proactive sends while a recent inbound message has
|
|
105
|
+
* renewed the session. Warn while the user is still at the desktop instead
|
|
106
|
+
* of failing silently after they walk away.
|
|
107
|
+
*/
|
|
108
|
+
private checkWechatFreshness;
|
|
109
|
+
private warnWechatStale;
|
|
110
|
+
/** Opt-in diagnostics: create `remote/debug-notices.enabled` in plugin-data. */
|
|
111
|
+
private debugNotice;
|
|
112
|
+
/** Send one notice to every paired chat on a channel that can answer. */
|
|
113
|
+
private pushNotice;
|
|
114
|
+
private scheduleRetry;
|
|
115
|
+
private clearRetry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AAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAU7D,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IASpD,mFAAmF;IACnF,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAOtC,IAAI,IAAI,IAAI;IAcZ,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,YAAY;IAYpB;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,eAAe;IAavB,gFAAgF;IAChF,OAAO,CAAC,WAAW;IAYnB,yEAAyE;IACzE,OAAO,CAAC,UAAU;IAuGlB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,UAAU;CAKnB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { BridgeNotice, HostBridgePorts } from './host-bridge.ts';
|
|
3
|
+
export declare function createHostPorts(ctx: Context, options: {
|
|
4
|
+
readonly setPaused: (sessionId: string, paused: boolean) => Promise<void>;
|
|
5
|
+
readonly notify?: (notice: BridgeNotice) => void;
|
|
6
|
+
}): HostBridgePorts;
|
|
7
|
+
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../../src/host/remote/ports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAMlD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAkDrE,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE;IACP,QAAQ,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA;CACjD,GACA,eAAe,CAsDjB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ChannelCapabilities, Pending, PresentedState, Task } from './types.ts';
|
|
2
|
+
export interface TaskAction {
|
|
3
|
+
readonly id: 'approve' | 'reject' | 'detail';
|
|
4
|
+
readonly label: string;
|
|
5
|
+
/** Text command the action is equivalent to; button callbacks send this back. */
|
|
6
|
+
readonly command: string;
|
|
7
|
+
}
|
|
8
|
+
/** One inline button; `command` is exactly what the user would type. */
|
|
9
|
+
export interface ChannelButton {
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly command: string;
|
|
12
|
+
}
|
|
13
|
+
export interface TaskAction extends ChannelButton {
|
|
14
|
+
readonly id: 'approve' | 'reject' | 'detail';
|
|
15
|
+
}
|
|
16
|
+
/** Actions for the card of one task, as tappable buttons. */
|
|
17
|
+
export declare function taskActionButtons(task: Task): readonly ChannelButton[];
|
|
18
|
+
/** Task-picker buttons for the list: active tasks first, then most recent. */
|
|
19
|
+
export declare function listActionButtons(tasks: readonly Task[], numbers: ReadonlyMap<string, number>): readonly ChannelButton[];
|
|
20
|
+
/** Actions for a pending decision. Buttons are a shortcut for the same words. */
|
|
21
|
+
export declare function decisionActions(pending: Pending): readonly TaskAction[];
|
|
22
|
+
/** One task card in plain text. Buttons are the adapter's job; this is the fallback shape. */
|
|
23
|
+
export declare function renderTaskCard(task: Task, number: number, capabilities: ChannelCapabilities, presented?: PresentedState): string;
|
|
24
|
+
/** Compact list used by the `任务` word. */
|
|
25
|
+
export declare function renderTaskList(tasks: readonly Task[], numbers: ReadonlyMap<string, number>, capabilities: ChannelCapabilities): string;
|
|
26
|
+
/**
|
|
27
|
+
* Split long text for a channel.
|
|
28
|
+
*
|
|
29
|
+
* `maxChars` is a readability budget, not a protocol limit (WeChat accepted
|
|
30
|
+
* 1801 chars in testing). Chunks keep a `(i/n)` marker and prefer newlines.
|
|
31
|
+
*/
|
|
32
|
+
export declare function splitForChannel(text: string, maxChars: number): readonly string[];
|
|
33
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/host/remote/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAYpF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,QAAQ,CAAC,EAAE,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAC7C;AAOD,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,aAAa,EAAE,CA0BtE;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,SAAS,aAAa,EAAE,CAc1B;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,UAAU,EAAE,CAMvE;AAqBD,8FAA8F;AAC9F,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,mBAAmB,EACjC,SAAS,GAAE,cAA2B,GACrC,MAAM,CASR;AAED,0CAA0C;AAC1C,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,YAAY,EAAE,mBAAmB,GAChC,MAAM,CAgBR;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAcjF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Pending, PresentedState, Task, TaskId, TaskState } from './types.ts';
|
|
2
|
+
export type TurnEndReason = 'ok' | 'error' | 'aborted' | 'stopped';
|
|
3
|
+
export type DecideResult = 'ok' | 'no-pending' | 'code-mismatch' | 'expired';
|
|
4
|
+
/**
|
|
5
|
+
* In-memory task board.
|
|
6
|
+
*
|
|
7
|
+
* Pure state transitions: no host services, no channel code. The adapter layer
|
|
8
|
+
* feeds host events in and renders snapshots out. Persisted data lives elsewhere
|
|
9
|
+
* (bindings only; never pending codes).
|
|
10
|
+
*/
|
|
11
|
+
export declare class TaskBoard {
|
|
12
|
+
private readonly tasks;
|
|
13
|
+
get(id: TaskId): Task | undefined;
|
|
14
|
+
list(): readonly Task[];
|
|
15
|
+
size(): number;
|
|
16
|
+
/** Create or refresh a task from a session row. */
|
|
17
|
+
register(id: TaskId, title: string, state: TaskState, at: number): Task;
|
|
18
|
+
rename(id: TaskId, title: string): Task | undefined;
|
|
19
|
+
/** Newest step summary, used by the card body. */
|
|
20
|
+
note(id: TaskId, line: string, at: number): Task | undefined;
|
|
21
|
+
turnStart(id: TaskId, at: number): Task | undefined;
|
|
22
|
+
/** Store the model's final text for this turn (the remote answer). */
|
|
23
|
+
answer(id: TaskId, text: string, at: number): Task | undefined;
|
|
24
|
+
turnEnd(id: TaskId, reason: TurnEndReason, at: number, error?: string): Task | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Record a pending approval/question. Waits are created while the turn runs;
|
|
27
|
+
* an existing pending is a bug (the host would have had to resolve it first).
|
|
28
|
+
*/
|
|
29
|
+
ask(id: TaskId, pending: Pending, at: number): Task | undefined;
|
|
30
|
+
/** Resolve the pending decision with a matching one-shot code. */
|
|
31
|
+
decide(id: TaskId, code: string, now: number): DecideResult;
|
|
32
|
+
/** Drop expired pendings and let their tasks resume running. Returns the dropped codes. */
|
|
33
|
+
expire(now: number): readonly string[];
|
|
34
|
+
/** Drop a pending without deciding it (another client already handled the request). */
|
|
35
|
+
clearPending(id: TaskId): Pending | undefined;
|
|
36
|
+
/** Soft pause: remember what to return to. No-op when already paused. */
|
|
37
|
+
pause(id: TaskId): Task | undefined;
|
|
38
|
+
resume(id: TaskId, now: number): Task | undefined;
|
|
39
|
+
remove(id: TaskId): boolean;
|
|
40
|
+
/** Offline is a presentation fact, not a stored state. */
|
|
41
|
+
presented(id: TaskId, hostOnline: boolean): PresentedState | undefined;
|
|
42
|
+
private replace;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=task-board.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-board.d.ts","sourceRoot":"","sources":["../../../src/host/remote/task-board.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAElF,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;AAElE,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,YAAY,GAAG,eAAe,GAAG,SAAS,CAAA;AAS5E;;;;;;GAMG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA0B;IAEhD,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIjC,IAAI,IAAI,SAAS,IAAI,EAAE;IAIvB,IAAI,IAAI,MAAM;IAId,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,MAA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AM,GAAG,OAAO;IAI3B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS;IAMtE,OAAO,CAAC,OAAO;CAOhB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BindingStore } from '../bindings.ts';
|
|
2
|
+
import type { ChannelCursor } from '../channels/poller.ts';
|
|
3
|
+
import type { RemoteController } from '../controller.ts';
|
|
4
|
+
import type { ChannelCapabilities } from '../types.ts';
|
|
5
|
+
import { TelegramTransport } from './transport.ts';
|
|
6
|
+
import type { TelegramCredentials } from './transport.ts';
|
|
7
|
+
export interface TelegramAdapterOptions {
|
|
8
|
+
readonly transport: TelegramTransport;
|
|
9
|
+
readonly credentials: TelegramCredentials;
|
|
10
|
+
readonly controller: RemoteController;
|
|
11
|
+
readonly bindings: BindingStore;
|
|
12
|
+
readonly capabilities: ChannelCapabilities;
|
|
13
|
+
readonly cursor?: ChannelCursor;
|
|
14
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
15
|
+
readonly onFatal?: (error: unknown) => void;
|
|
16
|
+
readonly onError?: (error: unknown) => void;
|
|
17
|
+
readonly refresh?: () => Promise<unknown>;
|
|
18
|
+
readonly emptyPageDelayMs?: number;
|
|
19
|
+
}
|
|
20
|
+
/** Telegram channel: same poller, Telegram transport. */
|
|
21
|
+
export declare class TelegramAdapter {
|
|
22
|
+
private readonly poller;
|
|
23
|
+
constructor(options: TelegramAdapterOptions);
|
|
24
|
+
stop(): void;
|
|
25
|
+
get running(): boolean;
|
|
26
|
+
contextFor(chatId: string): string | undefined;
|
|
27
|
+
run(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/remote/telegram/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,Y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GAAG,SAAS;IAI9C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BindingStore, RemoteChannel } from '../bindings.ts';
|
|
2
|
+
import type { ChannelStatus } from '../channels/status.ts';
|
|
3
|
+
import type { RemoteController } from '../controller.ts';
|
|
4
|
+
import type { ChannelCapabilities } from '../types.ts';
|
|
5
|
+
import type { TelegramCredentialStore } from './credentials.ts';
|
|
6
|
+
import { TelegramTransport } from './transport.ts';
|
|
7
|
+
export interface TelegramChannelOptions {
|
|
8
|
+
readonly rootDir: string;
|
|
9
|
+
readonly capabilities: ChannelCapabilities;
|
|
10
|
+
readonly credentials: TelegramCredentialStore;
|
|
11
|
+
readonly bindings: BindingStore;
|
|
12
|
+
readonly controller: RemoteController;
|
|
13
|
+
readonly refresh: () => Promise<unknown>;
|
|
14
|
+
readonly createTransport?: () => TelegramTransport;
|
|
15
|
+
readonly onError?: (error: unknown) => void;
|
|
16
|
+
readonly emptyPageDelayMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface TelegramConnectResult {
|
|
19
|
+
readonly ok: boolean;
|
|
20
|
+
readonly username?: string;
|
|
21
|
+
readonly error?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Telegram: token login, binding, the poll loop and the bot credential. */
|
|
24
|
+
export declare class TelegramChannel {
|
|
25
|
+
private readonly options;
|
|
26
|
+
readonly id: RemoteChannel;
|
|
27
|
+
private readonly transport;
|
|
28
|
+
private adapter;
|
|
29
|
+
private cursor;
|
|
30
|
+
private credentialsValue;
|
|
31
|
+
private phaseValue;
|
|
32
|
+
private errorValue;
|
|
33
|
+
private generation;
|
|
34
|
+
constructor(options: TelegramChannelOptions);
|
|
35
|
+
get running(): boolean;
|
|
36
|
+
status(): ChannelStatus;
|
|
37
|
+
start(): Promise<void>;
|
|
38
|
+
/** Validate and switch to a new bot token. */
|
|
39
|
+
connect(token: string): Promise<TelegramConnectResult>;
|
|
40
|
+
logout(): Promise<void>;
|
|
41
|
+
stop(): void;
|
|
42
|
+
/** A proactive push failed: inbound can still work, but the UI must say so. */
|
|
43
|
+
reportSendError(error: unknown): void;
|
|
44
|
+
send(chatId: string, text: string, buttons?: readonly {
|
|
45
|
+
readonly label: string;
|
|
46
|
+
readonly command: string;
|
|
47
|
+
}[]): Promise<void>;
|
|
48
|
+
contextFor(_chatId: string): string | undefined;
|
|
49
|
+
private connectStored;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../src/host/remote/telegram/channel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAGjE,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGlD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAA;IAC1C,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAA;IAC7C,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAA;IAC/B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACxC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,iBAAiB,CAAA;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,O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AAS;IAI/C,OAAO,CAAC,aAAa;CAwBtB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { TelegramCredentials } from './transport.ts';
|
|
3
|
+
export interface TelegramCredentialStore {
|
|
4
|
+
load(): Promise<TelegramCredentials | undefined>;
|
|
5
|
+
save(credentials: TelegramCredentials): Promise<void>;
|
|
6
|
+
clear(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** Token storage on the host's credential service; no plaintext fallback. */
|
|
9
|
+
export declare function createTelegramCredentialStore(ctx: Context): TelegramCredentialStore;
|
|
10
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/host/remote/telegram/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAezD,MAAM,WAAW,uBAAuB;IACtC,IAAI,IAAI,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAA;IAChD,IAAI,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAgCD,6EAA6E;AAC7E,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,uBAAuB,CA8BnF"}
|