@wanji_dsh/dsh-sales 0.11.2 → 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.
@@ -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 {};
@@ -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<Partial<Config>, Config>;
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;
@@ -16,6 +16,7 @@ export interface UpdateOptions {
16
16
  }
17
17
  /** Scheduling belongs to the plugin; package installation belongs to DSH. */
18
18
  export declare class UpdateCoordinator {
19
+ private readonly runDiagnostic;
19
20
  private options;
20
21
  private view;
21
22
  private record;
@@ -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>>;
@@ -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.2",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema": 1,
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "targets": {
5
5
  "win32-x64": {
6
6
  "url": "https://wanjidazi.com/plugins/sales-assistant/runtimes/wanji-wechat-runtime-1.0.2-win32-x64-9748e032830ccf40.tgz",