@michengai/dsh-im-connect 0.1.68 → 0.1.71
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/CHANGELOG.md +19 -1
- package/CHANGELOG.zh-CN.md +19 -1
- package/README.md +37 -15
- package/README.zh-CN.md +38 -15
- package/SECURITY.md +2 -2
- package/assets/brands/discord-symbol.svg +3 -0
- package/assets/brands/slack-hash.png +0 -0
- package/assets/brands/slack-hash.svg +6 -0
- package/assets/brands//346/235/245/346/272/220.txt +14 -0
- package/client.js +72 -23
- package/lib/channels/channel-image-download.d.ts +3 -1
- package/lib/channels/channel-image-download.d.ts.map +1 -1
- package/lib/channels/channel-image-download.js +37 -3
- package/lib/channels/channel-image-download.js.map +1 -1
- package/lib/channels/factory.d.ts.map +1 -1
- package/lib/channels/factory.js +4 -0
- package/lib/channels/factory.js.map +1 -1
- package/lib/channels/meta.d.ts.map +1 -1
- package/lib/channels/meta.js +11 -0
- package/lib/channels/meta.js.map +1 -1
- package/lib/channels/slack-markdown.d.ts +34 -0
- package/lib/channels/slack-markdown.d.ts.map +1 -0
- package/lib/channels/slack-markdown.js +161 -0
- package/lib/channels/slack-markdown.js.map +1 -0
- package/lib/channels/slack.d.ts +106 -0
- package/lib/channels/slack.d.ts.map +1 -0
- package/lib/channels/slack.js +804 -0
- package/lib/channels/slack.js.map +1 -0
- package/lib/client.js +72 -23
- package/lib/engine/session-id.d.ts +1 -1
- package/lib/engine/session-id.d.ts.map +1 -1
- package/lib/engine/session-id.js +1 -1
- package/lib/engine/session-id.js.map +1 -1
- package/lib/manager.d.ts +3 -0
- package/lib/manager.d.ts.map +1 -1
- package/lib/manager.js +35 -1
- package/lib/manager.js.map +1 -1
- package/package.json +1 -1
- package/src/channels/channel-image-download.ts +30 -2
- package/src/channels/factory.ts +3 -0
- package/src/channels/meta.ts +11 -0
- package/src/channels/slack-markdown.ts +162 -0
- package/src/channels/slack.ts +828 -0
- package/src/engine/session-id.ts +2 -2
- package/src/manager.ts +27 -1
package/src/engine/session-id.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export const IM_ORIGIN = 'im'
|
|
3
3
|
export const IM_SESSION_PREFIX = 'im:'
|
|
4
4
|
|
|
5
|
-
export type ChannelId = 'dingtalk' | 'feishu' | 'lark' | 'weixin' | 'wecom' | 'qq' | 'telegram' | 'discord'
|
|
5
|
+
export type ChannelId = 'dingtalk' | 'feishu' | 'lark' | 'weixin' | 'wecom' | 'qq' | 'telegram' | 'discord' | 'slack'
|
|
6
6
|
/** 运行实例 ID。旧版首个账号仍可直接使用渠道 ID,新账号使用 `<channel>_<stable>`。 */
|
|
7
7
|
export type ChannelInstanceId = string
|
|
8
8
|
export type ChatKind = 'dm' | 'group'
|
|
@@ -44,7 +44,7 @@ export function isImSessionId(sessionId: string): boolean {
|
|
|
44
44
|
return sessionId.startsWith(IM_SESSION_PREFIX)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const CHANNEL_IDS: readonly ChannelId[] = ['dingtalk', 'feishu', 'lark', 'weixin', 'wecom', 'qq', 'telegram', 'discord']
|
|
47
|
+
const CHANNEL_IDS: readonly ChannelId[] = ['dingtalk', 'feishu', 'lark', 'weixin', 'wecom', 'qq', 'telegram', 'discord', 'slack']
|
|
48
48
|
const STAMP_RE = /^\d{13,}$/
|
|
49
49
|
|
|
50
50
|
export function parseImSessionId(sessionId: string): { channel: ChannelInstanceId; kind: ChatKind; chatId: string } | undefined {
|
package/src/manager.ts
CHANGED
|
@@ -618,7 +618,10 @@ export class ChannelManager {
|
|
|
618
618
|
if (method !== 'POST') { send(405, { ok: false, error: 'method not allowed' }); return }
|
|
619
619
|
const body = await readBody()
|
|
620
620
|
if (action === 'start') {
|
|
621
|
-
const
|
|
621
|
+
const incoming = body.settings as Record<string, unknown> | undefined
|
|
622
|
+
const workspaceError = this.workspaceSaveError(normalizeWorkspacePath(incoming?.cwd))
|
|
623
|
+
if (workspaceError) { send(400, { ok: false, error: workspaceError }); return }
|
|
624
|
+
const pairing = await this.pairing.start(id, pairingSettings(incoming))
|
|
622
625
|
send(pairing.status === 'failed' ? 400 : 200, { ok: pairing.status !== 'failed', pairing, error: pairing.error })
|
|
623
626
|
return
|
|
624
627
|
}
|
|
@@ -914,6 +917,27 @@ export class ChannelManager {
|
|
|
914
917
|
return this.store.cwd || this.engineConfig.cwd
|
|
915
918
|
}
|
|
916
919
|
|
|
920
|
+
/** 宿主已提供工作区列表时,空列表和未登记路径都不能保存。列表不可用时保持原行为。 */
|
|
921
|
+
private workspaceSaveError(cwd: string | undefined): string | undefined {
|
|
922
|
+
const registered = this.registeredWorkspacePaths()
|
|
923
|
+
if (!registered) return undefined
|
|
924
|
+
if (registered.length === 0) return '请先添加工作区'
|
|
925
|
+
if (!cwd || !registered.some(path => sameWorkspacePath(path, cwd))) return '请选择工作区'
|
|
926
|
+
return undefined
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
private registeredWorkspacePaths(): string[] | undefined {
|
|
930
|
+
try {
|
|
931
|
+
const registry = this.ctx.get?.('workspaceRegistry') as { list?: () => Array<{ path?: unknown }> } | undefined
|
|
932
|
+
if (typeof registry?.list !== 'function') return undefined
|
|
933
|
+
const items = registry.list()
|
|
934
|
+
if (!Array.isArray(items)) return undefined
|
|
935
|
+
return items.flatMap(item => typeof item?.path === 'string' && item.path.trim() ? [item.path] : [])
|
|
936
|
+
} catch {
|
|
937
|
+
return undefined
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
917
941
|
private applyWorkspace(cwd?: string): void {
|
|
918
942
|
const next = normalizeWorkspacePath(cwd)
|
|
919
943
|
if (!next) return
|
|
@@ -1211,6 +1235,8 @@ export class ChannelManager {
|
|
|
1211
1235
|
})
|
|
1212
1236
|
if (!assistant) return { ok: false, error: '请选择提供商和模型' }
|
|
1213
1237
|
const cwd = normalizeWorkspacePath(input.cwd ?? previous.cwd ?? this.currentWorkspace())
|
|
1238
|
+
const workspaceError = this.workspaceSaveError(cwd)
|
|
1239
|
+
if (workspaceError) return { ok: false, error: workspaceError }
|
|
1214
1240
|
if (!cwd) return { ok: false, error: '请选择工作区' }
|
|
1215
1241
|
const permission = normalizePermission(input.permission ?? previous.permission ?? this.currentPermission(), this.permissionPresets().names)
|
|
1216
1242
|
if (!permission) return { ok: false, error: '请选择权限' }
|