dsh-connect 0.7.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +196 -43
- package/README.zh.md +171 -42
- package/client/client.js +817 -0
- package/client/client.js.map +7 -0
- package/client/locale.mjs +227 -0
- package/client/panel-state.mjs +54 -0
- package/client/settings-client.mjs +389 -0
- package/docs/images/settings-advanced-en.png +0 -0
- package/docs/images/settings-advanced-zh.png +0 -0
- package/docs/images/settings-defaults-en.png +0 -0
- package/docs/images/settings-defaults-zh.png +0 -0
- package/docs/images/settings-overview-en.png +0 -0
- package/docs/images/settings-overview-zh.png +0 -0
- package/examples/minimal.config.json +16 -0
- package/lib/binding.d.ts.map +1 -1
- package/lib/binding.js +2 -2
- package/lib/binding.js.map +1 -1
- package/lib/channels/dingtalk/adapter.d.ts +59 -0
- package/lib/channels/dingtalk/adapter.d.ts.map +1 -0
- package/lib/channels/dingtalk/adapter.js +123 -0
- package/lib/channels/dingtalk/adapter.js.map +1 -0
- package/lib/channels/dingtalk/i18n.d.ts +14 -0
- package/lib/channels/dingtalk/i18n.d.ts.map +1 -0
- package/lib/channels/dingtalk/i18n.js +16 -0
- package/lib/channels/dingtalk/i18n.js.map +1 -0
- package/lib/channels/dingtalk/index.d.ts +127 -0
- package/lib/channels/dingtalk/index.d.ts.map +1 -0
- package/lib/channels/dingtalk/index.js +144 -0
- package/lib/channels/dingtalk/index.js.map +1 -0
- package/lib/channels/dingtalk/message.d.ts +49 -0
- package/lib/channels/dingtalk/message.d.ts.map +1 -0
- package/lib/channels/dingtalk/message.js +50 -0
- package/lib/channels/dingtalk/message.js.map +1 -0
- package/lib/channels/dingtalk/stomp.d.ts +36 -0
- package/lib/channels/dingtalk/stomp.d.ts.map +1 -0
- package/lib/channels/dingtalk/stomp.js +107 -0
- package/lib/channels/dingtalk/stomp.js.map +1 -0
- package/lib/channels/dingtalk/stream.d.ts +53 -0
- package/lib/channels/dingtalk/stream.d.ts.map +1 -0
- package/lib/channels/dingtalk/stream.js +199 -0
- package/lib/channels/dingtalk/stream.js.map +1 -0
- package/lib/channels/dingtalk/webhook.d.ts +84 -0
- package/lib/channels/dingtalk/webhook.d.ts.map +1 -0
- package/lib/channels/dingtalk/webhook.js +143 -0
- package/lib/channels/dingtalk/webhook.js.map +1 -0
- package/lib/channels/feishu/adapter.d.ts +133 -0
- package/lib/channels/feishu/adapter.d.ts.map +1 -0
- package/lib/channels/feishu/adapter.js +662 -0
- package/lib/channels/feishu/adapter.js.map +1 -0
- package/lib/channels/feishu/i18n.d.ts +30 -0
- package/lib/channels/feishu/i18n.d.ts.map +1 -0
- package/lib/channels/feishu/i18n.js +42 -0
- package/lib/channels/feishu/i18n.js.map +1 -0
- package/lib/channels/feishu/index.d.ts +82 -0
- package/lib/channels/feishu/index.d.ts.map +1 -0
- package/lib/channels/feishu/index.js +103 -0
- package/lib/channels/feishu/index.js.map +1 -0
- package/lib/channels/feishu/onboard.d.ts +16 -0
- package/lib/channels/feishu/onboard.d.ts.map +1 -0
- package/lib/channels/feishu/onboard.js +86 -0
- package/lib/channels/feishu/onboard.js.map +1 -0
- package/lib/channels/telegram/adapter.d.ts +70 -0
- package/lib/channels/telegram/adapter.d.ts.map +1 -0
- package/lib/channels/telegram/adapter.js +460 -0
- package/lib/channels/telegram/adapter.js.map +1 -0
- package/lib/channels/telegram/client.d.ts +115 -0
- package/lib/channels/telegram/client.d.ts.map +1 -0
- package/lib/channels/telegram/client.js +198 -0
- package/lib/channels/telegram/client.js.map +1 -0
- package/lib/channels/telegram/i18n.d.ts +14 -0
- package/lib/channels/telegram/i18n.d.ts.map +1 -0
- package/lib/channels/telegram/i18n.js +18 -0
- package/lib/channels/telegram/i18n.js.map +1 -0
- package/lib/channels/telegram/index.d.ts +46 -0
- package/lib/channels/telegram/index.d.ts.map +1 -0
- package/lib/channels/telegram/index.js +54 -0
- package/lib/channels/telegram/index.js.map +1 -0
- package/lib/channels/web/adapter.d.ts +103 -0
- package/lib/channels/web/adapter.d.ts.map +1 -0
- package/lib/channels/web/adapter.js +161 -0
- package/lib/channels/web/adapter.js.map +1 -0
- package/lib/channels/web/index.d.ts +47 -0
- package/lib/channels/web/index.d.ts.map +1 -0
- package/lib/channels/web/index.js +59 -0
- package/lib/channels/web/index.js.map +1 -0
- package/lib/chat-key.d.ts +29 -0
- package/lib/chat-key.d.ts.map +1 -0
- package/lib/chat-key.js +38 -0
- package/lib/chat-key.js.map +1 -0
- package/lib/index.d.ts +78 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +312 -9
- package/lib/index.js.map +1 -1
- package/lib/runner.d.ts +55 -2
- package/lib/runner.d.ts.map +1 -1
- package/lib/runner.js +158 -23
- package/lib/runner.js.map +1 -1
- package/lib/scheduler.d.ts.map +1 -1
- package/lib/scheduler.js +2 -2
- package/lib/scheduler.js.map +1 -1
- package/lib/service.d.ts +17 -1
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +47 -3
- package/lib/service.js.map +1 -1
- package/lib/settings/channel-runtime.d.ts +75 -0
- package/lib/settings/channel-runtime.d.ts.map +1 -0
- package/lib/settings/channel-runtime.js +165 -0
- package/lib/settings/channel-runtime.js.map +1 -0
- package/lib/settings/channels.d.ts +62 -0
- package/lib/settings/channels.d.ts.map +1 -0
- package/lib/settings/channels.js +132 -0
- package/lib/settings/channels.js.map +1 -0
- package/lib/settings/credential-store.d.ts +85 -0
- package/lib/settings/credential-store.d.ts.map +1 -0
- package/lib/settings/credential-store.js +142 -0
- package/lib/settings/credential-store.js.map +1 -0
- package/lib/settings/index.d.ts +14 -0
- package/lib/settings/index.d.ts.map +1 -0
- package/lib/settings/index.js +14 -0
- package/lib/settings/index.js.map +1 -0
- package/lib/settings/namespace.d.ts +175 -0
- package/lib/settings/namespace.d.ts.map +1 -0
- package/lib/settings/namespace.js +200 -0
- package/lib/settings/namespace.js.map +1 -0
- package/lib/settings/rpc-client.d.ts +36 -0
- package/lib/settings/rpc-client.d.ts.map +1 -0
- package/lib/settings/rpc-client.js +45 -0
- package/lib/settings/rpc-client.js.map +1 -0
- package/lib/settings/secret-disclosure.d.ts +50 -0
- package/lib/settings/secret-disclosure.d.ts.map +1 -0
- package/lib/settings/secret-disclosure.js +132 -0
- package/lib/settings/secret-disclosure.js.map +1 -0
- package/lib/settings/settings-model.d.ts +124 -0
- package/lib/settings/settings-model.d.ts.map +1 -0
- package/lib/settings/settings-model.js +118 -0
- package/lib/settings/settings-model.js.map +1 -0
- package/lib/settings/settings-rpc.d.ts +130 -0
- package/lib/settings/settings-rpc.d.ts.map +1 -0
- package/lib/settings/settings-rpc.js +233 -0
- package/lib/settings/settings-rpc.js.map +1 -0
- package/lib/settings/settings-service.d.ts +35 -0
- package/lib/settings/settings-service.d.ts.map +1 -0
- package/lib/settings/settings-service.js +171 -0
- package/lib/settings/settings-service.js.map +1 -0
- package/lib/state-dir.d.ts +28 -0
- package/lib/state-dir.d.ts.map +1 -0
- package/lib/state-dir.js +33 -0
- package/lib/state-dir.js.map +1 -0
- package/lib/stream.d.ts.map +1 -1
- package/lib/stream.js +3 -2
- package/lib/stream.js.map +1 -1
- package/package.json +56 -12
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web channel adapter for dsh-connect: enables DSH Web GUI to mirror and
|
|
3
|
+
* interact with Feishu conversations through the unified ChannelAdapter interface.
|
|
4
|
+
* @module dsh-connect/web
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
7
|
+
import z from "@deepseek-ai/schemastery";
|
|
8
|
+
import type { BindingStore } from "../../binding.js";
|
|
9
|
+
export { WebAdapter } from "./adapter.js";
|
|
10
|
+
/** Plugin configuration options. */
|
|
11
|
+
export declare const Config: z<Schemastery.ObjectS<{
|
|
12
|
+
/** Polling interval in milliseconds for detecting new mirror sessions. Default: 1000ms */
|
|
13
|
+
pollIntervalMs: z<number, number>;
|
|
14
|
+
}>, Schemastery.ObjectT<{
|
|
15
|
+
/** Polling interval in milliseconds for detecting new mirror sessions. Default: 1000ms */
|
|
16
|
+
pollIntervalMs: z<number, number>;
|
|
17
|
+
}>>;
|
|
18
|
+
export interface ConnectWebConfig {
|
|
19
|
+
pollIntervalMs?: number;
|
|
20
|
+
}
|
|
21
|
+
interface ConnectLike {
|
|
22
|
+
registerAdapter(adapter: unknown): void;
|
|
23
|
+
/** Public accessor for the binding routing store (added to ConnectService). */
|
|
24
|
+
bindingStore?: BindingStore;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Register and start the Web adapter. This enables the DSH Web GUI to
|
|
28
|
+
* automatically detect and interact with mirrored Feishu conversations.
|
|
29
|
+
* `connect` is the already-constructed `ConnectService` instance (passed from
|
|
30
|
+
* the merged entry, not resolved via `ctx.get`), so its public `bindingStore`
|
|
31
|
+
* getter is read directly.
|
|
32
|
+
*
|
|
33
|
+
* When a user runs `/mirror` in Feishu, the resulting webMirrorSessionId
|
|
34
|
+
* becomes accessible through this adapter, allowing the Web GUI to:
|
|
35
|
+
* - View the shared session history
|
|
36
|
+
* - Send messages (subject to lock ownership)
|
|
37
|
+
* - Receive real-time updates through DSH's session event system
|
|
38
|
+
*/
|
|
39
|
+
export declare function register(connect: ConnectLike, config: (ConnectWebConfig | null) | undefined, ctx: Context): void;
|
|
40
|
+
/**
|
|
41
|
+
* Compatibility shell for the old split-plugin registration path (when `connect`
|
|
42
|
+
* is an already-active, separate plugin). The merged entry calls `register`
|
|
43
|
+
* directly instead, because `ctx.get("connect")` returns undefined inside this
|
|
44
|
+
* plugin's own `apply`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function apply(ctx: Context, config?: ConnectWebConfig | null): void;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channels/web/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,CAAC,MAAM,0BAA0B,CAAC;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,oCAAoC;AACpC,eAAO,MAAM,MAAM;IACjB,0FAA0F;;;IAA1F,0FAA0F;;GAE1F,CAAC;AAEH,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,WAAW;IACnB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,GAAE,gBAAgB,GAAG,IAAI,aAAK,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI,CA4BvG;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,gBAAgB,GAAG,IAAS,GAAG,IAAI,CAM9E"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { WebAdapter } from "./adapter.js";
|
|
3
|
+
export { WebAdapter } from "./adapter.js";
|
|
4
|
+
/** Plugin configuration options. */
|
|
5
|
+
export const Config = z.object({
|
|
6
|
+
/** Polling interval in milliseconds for detecting new mirror sessions. Default: 1000ms */
|
|
7
|
+
pollIntervalMs: z.number(),
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Register and start the Web adapter. This enables the DSH Web GUI to
|
|
11
|
+
* automatically detect and interact with mirrored Feishu conversations.
|
|
12
|
+
* `connect` is the already-constructed `ConnectService` instance (passed from
|
|
13
|
+
* the merged entry, not resolved via `ctx.get`), so its public `bindingStore`
|
|
14
|
+
* getter is read directly.
|
|
15
|
+
*
|
|
16
|
+
* When a user runs `/mirror` in Feishu, the resulting webMirrorSessionId
|
|
17
|
+
* becomes accessible through this adapter, allowing the Web GUI to:
|
|
18
|
+
* - View the shared session history
|
|
19
|
+
* - Send messages (subject to lock ownership)
|
|
20
|
+
* - Receive real-time updates through DSH's session event system
|
|
21
|
+
*/
|
|
22
|
+
export function register(connect, config = {}, ctx) {
|
|
23
|
+
// The DSH loader passes `null` for entries without an explicit config.
|
|
24
|
+
config = config ?? {};
|
|
25
|
+
// Read the BindingStore from the connect service's public getter (part of the
|
|
26
|
+
// service contract), not via `ctx.get("connect")`.
|
|
27
|
+
const bindings = connect.bindingStore;
|
|
28
|
+
if (bindings === undefined) {
|
|
29
|
+
ctx.logger?.warn?.("connect-web: BindingStore not available, mirror detection disabled");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const adapter = new WebAdapter(bindings, {
|
|
34
|
+
pollIntervalMs: config.pollIntervalMs,
|
|
35
|
+
});
|
|
36
|
+
connect.registerAdapter(adapter);
|
|
37
|
+
void adapter.start().catch((error) => {
|
|
38
|
+
ctx.logger?.warn?.(`connect-web: start failed: ${String(error)}`);
|
|
39
|
+
});
|
|
40
|
+
ctx.logger?.info?.("connect-web: Web adapter registered, mirror detection active");
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
ctx.logger?.warn?.(`connect-web: adapter init failed: ${String(error)}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compatibility shell for the old split-plugin registration path (when `connect`
|
|
48
|
+
* is an already-active, separate plugin). The merged entry calls `register`
|
|
49
|
+
* directly instead, because `ctx.get("connect")` returns undefined inside this
|
|
50
|
+
* plugin's own `apply`.
|
|
51
|
+
*/
|
|
52
|
+
export function apply(ctx, config = {}) {
|
|
53
|
+
const connect = ctx.get("connect");
|
|
54
|
+
if (connect === undefined) {
|
|
55
|
+
throw new Error("connect-web: the dsh-connect service is not present; load it before this adapter");
|
|
56
|
+
}
|
|
57
|
+
register(connect, config, ctx);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/channels/web/index.ts"],"names":[],"mappings":"AAMA,OAAO,CAAC,MAAM,0BAA0B,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,oCAAoC;AACpC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,0FAA0F;IAC1F,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;CAC3B,CAAC,CAAC;AAYH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAoB,EAAE,SAAkC,EAAE,EAAE,GAAY;IAC/F,uEAAuE;IACvE,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;IAEtB,8EAA8E;IAC9E,mDAAmD;IACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAEtC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,oEAAoE,CAAC,CAAC;QACzF,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,QAAQ,EAAE;YACvC,cAAc,EAAE,MAAM,CAAC,cAAc;SACtC,CAAC,CAAC;QAEH,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAEjC,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACnC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,8BAA8B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,8DAA8D,CAAC,CAAC;IACrF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,qCAAqC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,SAAkC,EAAE;IACtE,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,SAAS,CAA4B,CAAC;IAC9D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IACtG,CAAC;IACD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thread-scoped chat keys.
|
|
3
|
+
*
|
|
4
|
+
* A chat key is otherwise opaque to the core: every channel picks whatever
|
|
5
|
+
* identifies one conversation (a Feishu `oc_…`, a Telegram chat id, a DingTalk
|
|
6
|
+
* `cid…`). Feishu's `threadIsolation` widens it — a group message inside a
|
|
7
|
+
* thread gets `chatId:thread=<rootId>` so each thread binds its own DSH session
|
|
8
|
+
* and its own runner.
|
|
9
|
+
*
|
|
10
|
+
* The allowlists in the plugin config are written with plain chat ids, so the
|
|
11
|
+
* core reduces a key to its base id before comparing (`baseChatId`). Keeping
|
|
12
|
+
* the encoding here rather than in the Feishu adapter is deliberate: the core
|
|
13
|
+
* gate and the adapter's pre-download gate must agree, and they only do so
|
|
14
|
+
* while a single module owns the format.
|
|
15
|
+
* @module dsh-connect/chat-key
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Encode a chat key with an optional thread id. Outbound sends still target the
|
|
19
|
+
* base chat id (replies land in the thread via `replyRef`).
|
|
20
|
+
*/
|
|
21
|
+
export declare function encodeChatKey(chatId: string, threadId?: string): string;
|
|
22
|
+
/** Decode a possibly thread-scoped chat key back to its base chat id. */
|
|
23
|
+
export declare function decodeChatKey(chatKey: string): {
|
|
24
|
+
chatId: string;
|
|
25
|
+
threadId?: string;
|
|
26
|
+
};
|
|
27
|
+
/** Base chat id of a chat key, thread-scoped or not. */
|
|
28
|
+
export declare function baseChatId(chatKey: string): string;
|
|
29
|
+
//# sourceMappingURL=chat-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-key.d.ts","sourceRoot":"","sources":["../src/chat-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAIpF;AAED,wDAAwD;AACxD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGlD"}
|
package/lib/chat-key.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thread-scoped chat keys.
|
|
3
|
+
*
|
|
4
|
+
* A chat key is otherwise opaque to the core: every channel picks whatever
|
|
5
|
+
* identifies one conversation (a Feishu `oc_…`, a Telegram chat id, a DingTalk
|
|
6
|
+
* `cid…`). Feishu's `threadIsolation` widens it — a group message inside a
|
|
7
|
+
* thread gets `chatId:thread=<rootId>` so each thread binds its own DSH session
|
|
8
|
+
* and its own runner.
|
|
9
|
+
*
|
|
10
|
+
* The allowlists in the plugin config are written with plain chat ids, so the
|
|
11
|
+
* core reduces a key to its base id before comparing (`baseChatId`). Keeping
|
|
12
|
+
* the encoding here rather than in the Feishu adapter is deliberate: the core
|
|
13
|
+
* gate and the adapter's pre-download gate must agree, and they only do so
|
|
14
|
+
* while a single module owns the format.
|
|
15
|
+
* @module dsh-connect/chat-key
|
|
16
|
+
*/
|
|
17
|
+
/** Suffix joining a base chat id to its thread id. */
|
|
18
|
+
const THREAD_SEP = ":thread=";
|
|
19
|
+
/**
|
|
20
|
+
* Encode a chat key with an optional thread id. Outbound sends still target the
|
|
21
|
+
* base chat id (replies land in the thread via `replyRef`).
|
|
22
|
+
*/
|
|
23
|
+
export function encodeChatKey(chatId, threadId) {
|
|
24
|
+
return threadId === undefined || threadId === "" ? chatId : `${chatId}${THREAD_SEP}${threadId}`;
|
|
25
|
+
}
|
|
26
|
+
/** Decode a possibly thread-scoped chat key back to its base chat id. */
|
|
27
|
+
export function decodeChatKey(chatKey) {
|
|
28
|
+
const sep = chatKey.indexOf(THREAD_SEP);
|
|
29
|
+
if (sep === -1)
|
|
30
|
+
return { chatId: chatKey };
|
|
31
|
+
return { chatId: chatKey.slice(0, sep), threadId: chatKey.slice(sep + THREAD_SEP.length) };
|
|
32
|
+
}
|
|
33
|
+
/** Base chat id of a chat key, thread-scoped or not. */
|
|
34
|
+
export function baseChatId(chatKey) {
|
|
35
|
+
const sep = chatKey.indexOf(THREAD_SEP);
|
|
36
|
+
return sep === -1 ? chatKey : chatKey.slice(0, sep);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=chat-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-key.js","sourceRoot":"","sources":["../src/chat-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,sDAAsD;AACtD,MAAM,UAAU,GAAG,UAAU,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,QAAiB;IAC7D,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,EAAE,CAAC;AAClG,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,IAAI,GAAG,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC3C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;AAC7F,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACtD,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dsh-connect` — channel-agnostic messaging bridge core for DeepSeek Harness.
|
|
3
|
-
* Provides the `connect` service; channel adapters register into it and route
|
|
4
|
-
* normalized messages to bound DSH agents, then stream replies back.
|
|
5
|
-
* @module dsh-connect
|
|
6
|
-
*/
|
|
7
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
8
2
|
import z from "@deepseek-ai/schemastery";
|
|
9
3
|
import { ConnectService } from "./service.js";
|
|
10
4
|
import type { ConnectConfig } from "./runner.js";
|
|
5
|
+
import { type ChannelName } from "./settings/channels.js";
|
|
11
6
|
export { ConnectService } from "./service.js";
|
|
12
7
|
export { AgentRunner, resolveConnectConfig } from "./runner.js";
|
|
13
8
|
export { MenuController } from "./menu-controller.js";
|
|
@@ -34,11 +29,37 @@ export type { Command } from "./commands.js";
|
|
|
34
29
|
export { messages } from "./i18n.js";
|
|
35
30
|
export type { Language, Messages } from "./i18n.js";
|
|
36
31
|
export type { ChatType, ChoiceOption, ChoicePrompt, ChoiceResult, InboundMessage, OutboundTarget, SummaryCard, TurnReason, TurnOutcome, AsyncQueue, ChannelAdapter, } from "./types.js";
|
|
32
|
+
export * as feishu from "./channels/feishu/index.js";
|
|
33
|
+
export * as telegram from "./channels/telegram/index.js";
|
|
34
|
+
export * as dingtalk from "./channels/dingtalk/index.js";
|
|
35
|
+
export * as web from "./channels/web/index.js";
|
|
36
|
+
export * as settings from "./settings/index.js";
|
|
37
37
|
/** Cordis plugin name used by loader diagnostics. */
|
|
38
38
|
export declare const name = "connect";
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Host-plane services this plugin must wait for before `apply` runs. All four
|
|
41
|
+
* are rows in the always-loaded `@deepseek-ai/dsh-base` bundle — the shared core
|
|
42
|
+
* of every base-backed profile — so requiring them cannot stall the plugin in
|
|
43
|
+
* any profile that can load `dsh-connect` at all.
|
|
44
|
+
*
|
|
45
|
+
* `credentials` must be listed here, not read lazily inside `apply`: a
|
|
46
|
+
* `ctx.get("credentials")` at apply time returns `undefined`, because this
|
|
47
|
+
* plugin activates before the credentials row does. That silently disabled the
|
|
48
|
+
* whole credential path — `migrateConfigSecrets` never seeded the store (so an
|
|
49
|
+
* upgraded user's working channels displayed "未配置凭据"), `injectSecrets`
|
|
50
|
+
* never merged store-backed secrets into a channel config, and
|
|
51
|
+
* `settings.saveCredentials` threw `not-configured` for every pane save. Note
|
|
52
|
+
* cordis v4 has no `?` optional-inject marker, so `"credentials?"` would be read
|
|
53
|
+
* as a required service literally named `"credentials?"` — that is a syntax
|
|
54
|
+
* hazard, not a reason the service itself is unavailable.
|
|
55
|
+
*/
|
|
40
56
|
export declare const inject: string[];
|
|
41
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Full plugin config: the channel-agnostic core fields plus the channel
|
|
59
|
+
* selector (`channels`), shared `channelDefaults`, per-channel config, and the
|
|
60
|
+
* web-settings state path. Each channel's own `Config` schema is also exported
|
|
61
|
+
* (as `feishu.Config`, etc.) for reference; the merged entry validates loosely.
|
|
62
|
+
*/
|
|
42
63
|
export declare const Config: z<Schemastery.ObjectS<{
|
|
43
64
|
/** Agent preset id composed into each bound session; omit for the roster default. */
|
|
44
65
|
agentPreset: z<string, string>;
|
|
@@ -70,6 +91,16 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
70
91
|
notifyLevel: z<"full" | "important" | "result", "full" | "important" | "result">;
|
|
71
92
|
/** Proactive progress-notice interval ms when a turn stays silent (default: 300000 = 5 min; 0 disables). */
|
|
72
93
|
progressTimeoutMs: z<number, number>;
|
|
94
|
+
/** Channels to activate; default: all built-in channels. */
|
|
95
|
+
channels: z<("feishu" | "web" | "telegram" | "dingtalk")[], ("feishu" | "web" | "telegram" | "dingtalk")[]>;
|
|
96
|
+
/** Keys applied to every channel that doesn't set its own (e.g. a shared `language`). */
|
|
97
|
+
channelDefaults: z<any, any>;
|
|
98
|
+
feishu: z<any, any>;
|
|
99
|
+
telegram: z<any, any>;
|
|
100
|
+
dingtalk: z<any, any>;
|
|
101
|
+
web: z<any, any>;
|
|
102
|
+
/** Optional path to persist web-settings edits (non-secret). */
|
|
103
|
+
settingsStatePath: z<string, string>;
|
|
73
104
|
}>, Schemastery.ObjectT<{
|
|
74
105
|
/** Agent preset id composed into each bound session; omit for the roster default. */
|
|
75
106
|
agentPreset: z<string, string>;
|
|
@@ -101,13 +132,49 @@ export declare const Config: z<Schemastery.ObjectS<{
|
|
|
101
132
|
notifyLevel: z<"full" | "important" | "result", "full" | "important" | "result">;
|
|
102
133
|
/** Proactive progress-notice interval ms when a turn stays silent (default: 300000 = 5 min; 0 disables). */
|
|
103
134
|
progressTimeoutMs: z<number, number>;
|
|
135
|
+
/** Channels to activate; default: all built-in channels. */
|
|
136
|
+
channels: z<("feishu" | "web" | "telegram" | "dingtalk")[], ("feishu" | "web" | "telegram" | "dingtalk")[]>;
|
|
137
|
+
/** Keys applied to every channel that doesn't set its own (e.g. a shared `language`). */
|
|
138
|
+
channelDefaults: z<any, any>;
|
|
139
|
+
feishu: z<any, any>;
|
|
140
|
+
telegram: z<any, any>;
|
|
141
|
+
dingtalk: z<any, any>;
|
|
142
|
+
web: z<any, any>;
|
|
143
|
+
/** Optional path to persist web-settings edits (non-secret). */
|
|
144
|
+
settingsStatePath: z<string, string>;
|
|
104
145
|
}>>;
|
|
146
|
+
/** The merged plugin's config type (core fields + channel selector + settings). */
|
|
147
|
+
export interface ConnectSettingsConfig extends ConnectConfig {
|
|
148
|
+
/** Channels to activate; default: all built-in channels. */
|
|
149
|
+
channels?: ChannelName[];
|
|
150
|
+
/** Keys applied to every channel that doesn't set its own (e.g. a shared `language`). */
|
|
151
|
+
channelDefaults?: Record<string, unknown>;
|
|
152
|
+
feishu?: Record<string, unknown>;
|
|
153
|
+
telegram?: Record<string, unknown>;
|
|
154
|
+
dingtalk?: Record<string, unknown>;
|
|
155
|
+
web?: Record<string, unknown>;
|
|
156
|
+
/** Optional path to persist web-settings edits (non-secret). */
|
|
157
|
+
settingsStatePath?: string;
|
|
158
|
+
}
|
|
159
|
+
/** Convenience alias for the settings stack's channel-orchestration config. */
|
|
160
|
+
export type { ChannelsConfig, ChannelApply } from "./settings/channels.js";
|
|
105
161
|
declare module "@deepseek-ai/cordis" {
|
|
106
162
|
interface Context {
|
|
107
163
|
connect: ConnectService;
|
|
108
164
|
}
|
|
109
165
|
}
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Register the `connect` service and start the enabled channel adapters, then
|
|
168
|
+
* expose the web-settings RPC. `connect` is constructed first and passed *by
|
|
169
|
+
* instance* into each channel's `register` — never resolved via
|
|
170
|
+
* `ctx.get("connect")`, which returns undefined inside this plugin's own
|
|
171
|
+
* `apply` (the fiber is still LOADING until this function resolves).
|
|
172
|
+
*/
|
|
173
|
+
export declare function apply(ctx: Context, config?: ConnectSettingsConfig | null): Promise<void>;
|
|
174
|
+
declare const _default: {
|
|
175
|
+
apply: typeof apply;
|
|
176
|
+
name: string;
|
|
177
|
+
inject: string[];
|
|
178
|
+
};
|
|
179
|
+
export default _default;
|
|
113
180
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,CAAC,MAAM,0BAA0B,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAKL,KAAK,WAAW,EAEjB,MAAM,wBAAwB,CAAC;AAiBhC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7H,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAA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