@wanji_dsh/dsh-sales 0.11.1 → 0.11.3
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 +2 -0
- package/README.zh.md +24 -2
- package/config/langfuse.production.example.json +11 -0
- package/config/production.cordis.yml +36 -0
- package/dist/client.js +16 -9
- package/dist/host.js +968 -454
- package/dist/types/agent-knowledge.d.ts +4 -0
- package/dist/types/company/identity.d.ts +2 -0
- package/dist/types/diagnostics.d.ts +28 -0
- package/dist/types/host.d.ts +6 -1
- package/dist/types/knowledge-host.d.ts +5 -2
- package/dist/types/knowledge-privacy.d.ts +3 -1
- package/dist/types/langfuse-config.d.ts +1 -1
- package/dist/types/production-endpoints.d.ts +8 -0
- package/dist/types/question-tracing.d.ts +2 -0
- package/dist/types/update/coordinator.d.ts +1 -0
- package/dist/types/wechat/runtime.d.ts +1 -0
- package/dist/types/wechat/service.d.ts +2 -0
- package/dist/types/weknora-http.d.ts +1 -1
- package/docs/crm-profile-tool.md +2 -0
- package/docs/crm-profile-tool.zh.md +2 -0
- package/docs/diagnostics.zh.md +43 -0
- package/package.json +4 -1
- package/runtime/wechat-manifest.json +1 -1
|
@@ -27,6 +27,7 @@ interface Options {
|
|
|
27
27
|
directory: string;
|
|
28
28
|
knowledgeBaseId: string;
|
|
29
29
|
toolPrefix: string;
|
|
30
|
+
environment?: 'test' | 'production';
|
|
30
31
|
material?: {
|
|
31
32
|
knowledgeBaseId: string;
|
|
32
33
|
toolPrefix: string;
|
|
@@ -38,6 +39,7 @@ export declare function agentMetricValues(event: ObservationEvent): Record<strin
|
|
|
38
39
|
export declare function deliverAgentEvent(event: ObservationEvent): Promise<void>;
|
|
39
40
|
export declare class AgentKnowledgeObserver {
|
|
40
41
|
private readonly options;
|
|
42
|
+
private readonly production;
|
|
41
43
|
private readonly started;
|
|
42
44
|
readonly outbox: LangfuseOutbox;
|
|
43
45
|
private readonly judgments;
|
|
@@ -64,6 +66,8 @@ export declare class AgentKnowledgeObserver {
|
|
|
64
66
|
private eligible;
|
|
65
67
|
private callScope;
|
|
66
68
|
private rememberDocumentScopes;
|
|
69
|
+
private productionSearchOutput;
|
|
70
|
+
private ownsDestination;
|
|
67
71
|
private begin;
|
|
68
72
|
private queue;
|
|
69
73
|
/** At most 20ms local journal wait; no network or model is awaited by the search. */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const COMPANY_IDENTITY_ENDPOINT = "wanji-sales-company/identity";
|
|
2
|
+
export declare const COMPANY_LOGIN_PATH = "/api/v1/sales-company/device/login";
|
|
3
|
+
export declare function isDingTalkLaunchUrl(url: URL): boolean;
|
|
2
4
|
export declare const COMPANY_FLASH: {
|
|
3
5
|
readonly provider: "wanji-sales-company-flash";
|
|
4
6
|
readonly model: "deepseek-v4.1-flash";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type Outcome = 'started' | 'ok' | 'failed' | 'cancelled' | 'unavailable' | 'pending' | 'skipped';
|
|
2
|
+
type Facts = {
|
|
3
|
+
elapsedMs?: number;
|
|
4
|
+
httpStatus?: number;
|
|
5
|
+
count?: number;
|
|
6
|
+
bytes?: number;
|
|
7
|
+
configured?: boolean;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function diagnosticsDirectory(): string;
|
|
11
|
+
export declare class DiagnosticJournal {
|
|
12
|
+
private readonly hostId;
|
|
13
|
+
private pending;
|
|
14
|
+
private dropped;
|
|
15
|
+
private writes;
|
|
16
|
+
private file?;
|
|
17
|
+
private readonly directory;
|
|
18
|
+
constructor(directory?: string);
|
|
19
|
+
record(operation: string, outcome: Outcome, facts: Facts, error: unknown, operationId?: string): void;
|
|
20
|
+
flush(): Promise<void>;
|
|
21
|
+
private append;
|
|
22
|
+
}
|
|
23
|
+
export declare function withDiagnostics<T>(run: () => T, target?: DiagnosticJournal): T;
|
|
24
|
+
export declare function diagnostic(operation: string, outcome: Outcome, facts?: Facts, error?: unknown): void;
|
|
25
|
+
export declare function diagnosticOperation<T>(run: () => T, operationId?: string): T;
|
|
26
|
+
export declare function diagnosticCallback<A extends unknown[], T>(run: (...args: A) => T): (...args: A) => T;
|
|
27
|
+
export declare function diagnosticHttp(operation: string, send: () => Promise<Response>, signal?: AbortSignal): Promise<Response>;
|
|
28
|
+
export {};
|
package/dist/types/host.d.ts
CHANGED
|
@@ -29,8 +29,13 @@ type KnowledgePostDecision = {
|
|
|
29
29
|
value?: unknown;
|
|
30
30
|
additionalContexts?: unknown[];
|
|
31
31
|
};
|
|
32
|
+
type ConfigInput = Omit<Partial<Config>, 'materialMetadata'> & {
|
|
33
|
+
materialMetadata?: Omit<NonNullable<Config['materialMetadata']>, 'baseUrl'> & {
|
|
34
|
+
baseUrl?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
32
37
|
/** One standard schema validates both capabilities before either registers. */
|
|
33
|
-
export declare const Config: Schema<
|
|
38
|
+
export declare const Config: Schema<ConfigInput, Config>;
|
|
34
39
|
export declare const name = "wanji-sales";
|
|
35
40
|
export declare const inject: string[];
|
|
36
41
|
/** Knowledge routes activate when the web connection service is available; headless CRM stays usable. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AgentKnowledgeObserver } from './agent-knowledge.ts';
|
|
1
2
|
import { type KnowledgeObserver } from './langfuse-collector.ts';
|
|
2
3
|
import { EvaluationOutbox } from './evaluation-outbox.ts';
|
|
3
4
|
import { type EvaluationConnection, type EvaluationService } from './evaluation-client.ts';
|
|
@@ -113,10 +114,12 @@ export type SemanticRanker = (query: string, hits: import('./knowledge-types.ts'
|
|
|
113
114
|
relevantOnly?: boolean;
|
|
114
115
|
}) => Promise<import('./knowledge-types.ts').KnowledgeHit[]>;
|
|
115
116
|
export type QueryExpander = (query: string, signal: AbortSignal) => Promise<string[]>;
|
|
117
|
+
type DirectKnowledgeObserver = Pick<AgentKnowledgeObserver, 'start' | 'finish'>;
|
|
116
118
|
export declare function createKnowledgeHost(tools: ToolService, config: KnowledgeConfig, lifetime?: AbortSignal, outbox?: EvaluationOutbox, evaluationOrWorkspaces?: EvaluationService | (() => {
|
|
117
119
|
id: string;
|
|
118
120
|
title: string;
|
|
119
121
|
path: string;
|
|
120
|
-
}[]), injectedObserver?: KnowledgeObserver, rerank?: SemanticRanker, materialOverride?: MaterialRetriever, expandQuery?: QueryExpander, recordMaterialMetadata?: RecordMaterialMetadata): KnowledgeHandler;
|
|
122
|
+
}[]), injectedObserver?: KnowledgeObserver, rerank?: SemanticRanker, materialOverride?: MaterialRetriever, expandQuery?: QueryExpander, recordMaterialMetadata?: RecordMaterialMetadata, directObserver?: DirectKnowledgeObserver): KnowledgeHandler;
|
|
121
123
|
export declare const inject: string[];
|
|
122
|
-
export declare function apply(ctx: HostContext, config?: unknown, agentStatus?: () => Promise<import('./knowledge-types.ts').AgentTracingStatus>, rerank?: SemanticRanker, expandQuery?: QueryExpander, recordQuestion?: (input: import('./question-tracing.ts').ObservedQuestion, outcome: import('./question-tracing.ts').QuestionOutcome) => Promise<void>, recordMaterialMetadata?: RecordMaterialMetadata): void;
|
|
124
|
+
export declare function apply(ctx: HostContext, config?: unknown, agentStatus?: () => Promise<import('./knowledge-types.ts').AgentTracingStatus>, rerank?: SemanticRanker, expandQuery?: QueryExpander, recordQuestion?: (input: import('./question-tracing.ts').ObservedQuestion, outcome: import('./question-tracing.ts').QuestionOutcome) => Promise<void>, recordMaterialMetadata?: RecordMaterialMetadata, directObserver?: DirectKnowledgeObserver): void;
|
|
125
|
+
export {};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
/** V2 adds original questions/answers, so require a private key and redact before journaling. */
|
|
2
|
-
export declare function readEvaluationPrivacy(path: unknown): Promise<(value: any) => any>;
|
|
2
|
+
export declare function readEvaluationPrivacy(path: unknown, environment?: 'test' | 'production'): Promise<(value: any) => any>;
|
|
3
|
+
export declare function createEvaluationPrivacy(secret: string): (v: any) => any;
|
|
4
|
+
export declare const maskObservationText: (value: string, limit: number) => string;
|
|
@@ -13,7 +13,7 @@ export type SecretReader = (target: Destination) => Promise<Credentials>;
|
|
|
13
13
|
export declare const defaultConfigFile: string;
|
|
14
14
|
export declare function resolveTarget(name: string, value: unknown): Destination;
|
|
15
15
|
export declare function destinationId(target: Destination): string;
|
|
16
|
-
export declare function readTarget(path?: string): Promise<Destination | undefined>;
|
|
16
|
+
export declare function readTarget(path?: string, environment?: 'test' | 'production'): Promise<Destination | undefined>;
|
|
17
17
|
export declare const keychainCredentials: SecretReader;
|
|
18
18
|
export declare function authorization(keys: Credentials): string;
|
|
19
19
|
export declare function api(target: Destination, keys: Credentials, path: string, body?: unknown, request?: typeof fetch): Promise<any>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PRODUCTION_WEKNORA_BASE_URL = "https://wanjidazi.com/sales-kb/api/v1";
|
|
2
|
+
export declare function weknoraEnvironment(value: unknown): 'test' | 'production' | undefined;
|
|
3
|
+
export declare const PRODUCTION_LANGFUSE_BASE_URL = "https://wanjidazi.com/langfuse";
|
|
4
|
+
export declare const PRODUCTION_LANGFUSE_PROJECT_ID = "wanji-sales-test";
|
|
5
|
+
export declare const PRODUCTION_LANGFUSE_CREDENTIALS_REF = "wanji-langfuse-api-production";
|
|
6
|
+
export declare function isProductionLangfuse(target: {
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
}): boolean;
|
|
@@ -20,10 +20,12 @@ type Options = {
|
|
|
20
20
|
deliver?: (event: ObservationEvent) => Promise<void>;
|
|
21
21
|
} & ({
|
|
22
22
|
configFile: string;
|
|
23
|
+
environment?: 'test' | 'production';
|
|
23
24
|
relay?: never;
|
|
24
25
|
} | {
|
|
25
26
|
relay: (event: ObservationEvent, signal: AbortSignal) => Promise<void>;
|
|
26
27
|
configFile?: never;
|
|
28
|
+
environment?: never;
|
|
27
29
|
});
|
|
28
30
|
type SessionEvent = {
|
|
29
31
|
type: string;
|
|
@@ -28,6 +28,7 @@ export declare function runtimeBaseUrl(value: string): string;
|
|
|
28
28
|
export declare class WechatRuntime {
|
|
29
29
|
private readonly options;
|
|
30
30
|
private readonly target;
|
|
31
|
+
private readonly runDiagnostic;
|
|
31
32
|
private readonly lifetime;
|
|
32
33
|
private pending?;
|
|
33
34
|
private root?;
|
|
@@ -63,7 +63,9 @@ export declare class WechatSyncService {
|
|
|
63
63
|
start(workspace: string, automatic?: boolean): Promise<SyncStatus>;
|
|
64
64
|
sourceChanged(): void;
|
|
65
65
|
private schedule;
|
|
66
|
+
private readonly runDiagnostic;
|
|
66
67
|
private cycle;
|
|
68
|
+
private syncCycle;
|
|
67
69
|
pause(workspace: string): SyncStatus;
|
|
68
70
|
prepareUpdate(signal: AbortSignal): Promise<ResumeIntent>;
|
|
69
71
|
resumeAfterUpdate(intent: ResumeIntent): Promise<void>;
|
|
@@ -4,6 +4,6 @@ export interface WeKnoraConnection {
|
|
|
4
4
|
tenantId?: string;
|
|
5
5
|
}
|
|
6
6
|
/** Connection values are accepted only from the Host's installation config. */
|
|
7
|
-
export declare function resolveWeKnoraConnection(raw: unknown, label: string): WeKnoraConnection | undefined;
|
|
7
|
+
export declare function resolveWeKnoraConnection(raw: unknown, label: string, defaultBaseUrl?: string): WeKnoraConnection | undefined;
|
|
8
8
|
export declare function readWeKnoraEnvelope(response: Response): Promise<Record<string, unknown>>;
|
|
9
9
|
export declare function readWeKnoraData(response: Response): Promise<Record<string, unknown>>;
|
package/docs/crm-profile-tool.md
CHANGED
|
@@ -10,6 +10,8 @@ Findings include status, provenance and observed time. Compatible additive requi
|
|
|
10
10
|
|
|
11
11
|
`complete` means processing completed, not that all facts are confirmed. Inspect coverage, call analysisStatus/channelErrors, limitations and unresolved claims. Evidence reading remains bounded and now includes channel/role/time metadata. Private requests include both model stages' responses for diagnosis; no signed recording URL or model key is written into them.
|
|
12
12
|
|
|
13
|
+
New installations default to production CRM: `POST https://group.wanjivip.com/crm/api/v1/integrations/leads/context`. No extra CRM address configuration or external patch is required. An explicit plugin `crmBaseUrl` overrides `WANJI_SALES_CRM_BASE_URL`, which overrides the built-in production root. Upgrades preserve existing explicit test endpoints; remove or update those overrides to use production. CRM selection does not enable knowledge evaluation; production testing gates remain in force.
|
|
14
|
+
|
|
13
15
|
Configure model services/credentials in DSH. CRM uses crmRequestTimeoutMs (default 120000), knowledge retains requestTimeoutMs (30000). ffprobePath and ffmpegPath are required executables. Analysis uses two text calls per recording; independent stereo uses two speech calls. maxModelInputChars is a cumulative per-invocation budget; processing prioritizes recent dated calls when bounded. Versioned caches invalidate v1 mixed-audio results; refresh=true bypasses caches. Offline v1 helpers remain for compatibility and are not used by Native runtime.
|
|
14
16
|
|
|
15
17
|
Run workspace tests, typecheck/build, real Harness smoke and packed Config consumer test. Live CRM evidence and sanitized verification notes are under repository docs/verification; actual customer artifacts stay in private local DSH storage.
|
|
@@ -62,6 +62,8 @@ customerPhone 必须为完整号码;salesName(当前负责人的花名)与
|
|
|
62
62
|
|
|
63
63
|
## 配置与资源
|
|
64
64
|
|
|
65
|
+
插件内置生产 CRM 默认地址 `https://group.wanjivip.com/crm`,查询完整路径为 `POST https://group.wanjivip.com/crm/api/v1/integrations/leads/context`。新安装无需另加 CRM 地址或外部覆盖配置。优先级依次为插件显式 `crmBaseUrl`、环境变量 `WANJI_SALES_CRM_BASE_URL`、内置生产默认地址;测试环境需要显式覆盖。升级不会改写已有实例的显式测试地址,需清除该覆盖或改为生产地址。CRM 环境选择与知识库评测开关独立,生产环境继续关闭知识库测试行为。
|
|
66
|
+
|
|
65
67
|
DSH 模型服务管理所有地址、模型及凭据。插件支持可选 modelProvider/model(必须成对,缺省继承调用 Agent 模型),asr 只支持 provider/language(缺省继承 DSH)。禁止旧版 asr.baseUrl/model/apiKeyEnv/mode。
|
|
66
68
|
|
|
67
69
|
CRM root 配置使用 `crmRequestTimeoutMs`(默认120000)控制每通下载/两路转写总时限;原有 `requestTimeoutMs` 仍只控制知识检索(默认30000)。`analysisTimeoutMs`(默认180000)控制每次辅助模型请求。ffmpegPath、ffprobePath 默认 PATH 下对应程序。
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 销售助手日志收集
|
|
2
|
+
|
|
3
|
+
插件启用后默认在本机写诊断日志。复现一次问题,记下本机时间、DSH 版本、销售助手版本以及出问题的操作,再按下面的路径收集文件。
|
|
4
|
+
|
|
5
|
+
| 场景 | Windows 文件 | 查找内容 |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| 首次安装、启用失败,侧栏没有销售助手 | `%APPDATA%\@deepseek-ai\dsh-desktop\plugin-operations\operations.jsonl` | 记下故障时间附近销售助手的安装或启用状态、错误码。仅摘录相关字段,原文件可能包含本机路径和安装来源。 |
|
|
8
|
+
| 插件激活、升级、调用接口、登录和上传 | `%LOCALAPPDATA%\DSHSales\Logs\host-*.jsonl` | 找到故障时间附近的记录。用 `operationId` 串起同一次操作,`hostId` 区分重启前后的记录。 |
|
|
9
|
+
| 微信组件启动、登录、采集、导入 | `%LOCALAPPDATA%\DSHSales\Logs\collector-*.jsonl` | 核对时间、阶段和错误码。有操作 ID 时可和 Host 同步记录对应。 |
|
|
10
|
+
|
|
11
|
+
把目录粘贴到资源管理器地址栏即可打开。macOS 的 Host 和采集器日志都在 `~/Library/Logs/DSHSales/`。诊断目录随系统用户归属,插件自定义 `storageDir` 不改变日志位置。
|
|
12
|
+
|
|
13
|
+
在 Windows PowerShell 中运行以下命令,可把最近一天的销售助手日志打包到桌面。DSH 安装记录按上表单独摘录。
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
$logDir = Join-Path $env:LOCALAPPDATA 'DSHSales\Logs'
|
|
17
|
+
$files = @(Get-ChildItem -LiteralPath $logDir -File -ErrorAction SilentlyContinue |
|
|
18
|
+
Where-Object { $_.Name -match '^(host|collector)-.+\.jsonl$' -and
|
|
19
|
+
$_.LastWriteTime -ge (Get-Date).AddDays(-1) })
|
|
20
|
+
if ($files.Count -gt 0) {
|
|
21
|
+
$desktop = [Environment]::GetFolderPath('Desktop')
|
|
22
|
+
$zip = Join-Path $desktop ('销售助手日志-' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '.zip')
|
|
23
|
+
Compress-Archive -LiteralPath $files.FullName -DestinationPath $zip
|
|
24
|
+
Write-Output $zip
|
|
25
|
+
} else {
|
|
26
|
+
Write-Output '未找到近一天的销售助手日志。首次安装或启用失败时,请查看 DSH 插件操作记录。'
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 按操作定位
|
|
31
|
+
|
|
32
|
+
| 关键字 | 可定位的问题 |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `host.config`、`host.activation`、`host.web-services`、`install.update` | 配置校验、插件启用、桌面服务注册、包管理器更新交接 |
|
|
35
|
+
| `wechat.runtime`、`wechat.sync` | 组件下载、解压、校验、自检、登录等待和同步结果 |
|
|
36
|
+
| `dingtalk.http.start`、`dingtalk.oauth-challenge`、`dingtalk.status.*`、`dingtalk.model-route` | 请求登录、生成授权入口、等待确认、绑定结果和模型配置。钉钉浏览器端授权回调发生在服务端,需要按时间对照服务端记录。 |
|
|
37
|
+
| `mcp.knowledge`、`mcp.materials`、`knowledge`、`weknora.http` | 工具缺失、调用超时、HTTP 错误、响应解析、知识库范围和素材文件检查。分别核对 MCP 调用和直连 WeKnora。 |
|
|
38
|
+
| `crm.http`、`tool.crm_` | CRM 请求和工具执行,含网络、HTTP 状态和耗时 |
|
|
39
|
+
| `langfuse` | 配置、凭据、项目检查、上传响应、托管转发、队列待重试或已确认。测试配置可查托管转发。生产直连可通过 Host 环境变量注入 API 和脱敏密钥,Windows 使用同一方式。 |
|
|
40
|
+
|
|
41
|
+
Host 日志只写固定事件名、允许的错误码、HTTP 状态、耗时、计数、版本和系统信息。日志中没有请求或响应正文、聊天、手机号、账号、令牌、授权链接和知识库内容。日志留在本机,提交问题时人工发送压缩包。不要打包销售助手数据目录、DSH Profile 或 Langfuse 待上传队列。
|
|
42
|
+
|
|
43
|
+
每个 Host 文件上限 512 KiB。在新建日志时清理七天前或超出最近八份的 Host 文件。写入异常和积压不会阻断插件操作,后续写入恢复后可从 `dropped` 查看丢弃数。可在启动 DSH 的环境里设置 `WANJI_DIAGNOSTICS_ENABLED=false` 关闭销售助手诊断记录。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wanji_dsh/dsh-sales",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Sales workspace with local Windows/macOS WeChat sync, one-time CRM context, Flash drafts and filtered knowledge.",
|
|
6
6
|
"engines": {
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"dist/wechat-repository-worker.js",
|
|
24
24
|
"dist/types/**/*.d.ts",
|
|
25
25
|
"cordis.patch.yml",
|
|
26
|
+
"config/*.yml",
|
|
27
|
+
"config/*.json",
|
|
26
28
|
"locale/*.json",
|
|
27
29
|
"icon.svg",
|
|
28
30
|
"README.md",
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
"docs/crm-profile-tool.zh.md",
|
|
34
36
|
"docs/agent-knowledge-observation.md",
|
|
35
37
|
"docs/langfuse-local.md",
|
|
38
|
+
"docs/diagnostics.zh.md",
|
|
36
39
|
".dsh/skills/",
|
|
37
40
|
"!.dsh/**/__pycache__/**",
|
|
38
41
|
"runtime/*.py",
|