@wanji_dsh/dsh-sales 0.11.3 → 0.11.5

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.
@@ -1,3 +1,4 @@
1
+ import { type GatewayRequest } from './knowledge-http-correlation.ts';
1
2
  import { LangfuseOutbox, type ObservationEvent } from './langfuse-outbox.ts';
2
3
  export interface KnowledgeExecution {
3
4
  token: symbol;
@@ -27,6 +28,7 @@ interface Options {
27
28
  directory: string;
28
29
  knowledgeBaseId: string;
29
30
  toolPrefix: string;
31
+ requireExplicitScope?: boolean;
30
32
  environment?: 'test' | 'production';
31
33
  material?: {
32
34
  knowledgeBaseId: string;
@@ -40,6 +42,7 @@ export declare function deliverAgentEvent(event: ObservationEvent): Promise<void
40
42
  export declare class AgentKnowledgeObserver {
41
43
  private readonly options;
42
44
  private readonly production;
45
+ private readonly http?;
43
46
  private readonly started;
44
47
  readonly outbox: LangfuseOutbox;
45
48
  private readonly judgments;
@@ -71,7 +74,8 @@ export declare class AgentKnowledgeObserver {
71
74
  private begin;
72
75
  private queue;
73
76
  /** At most 20ms local journal wait; no network or model is awaited by the search. */
74
- start(exec: KnowledgeExecution): Promise<void>;
77
+ start(exec: KnowledgeExecution, httpRequests?: GatewayRequest[]): Promise<void>;
78
+ run<T>(exec: KnowledgeExecution, next: () => Promise<T>): Promise<T>;
75
79
  /** Harness emits a frozen final result. Snapshot synchronously, persist asynchronously. */
76
80
  finish(exec: KnowledgeExecution, result: KnowledgeOutcome): void;
77
81
  recordMaterialMetadata(knowledgeBaseId: string, startedAt: string, elapsedMs: number, status: string): void;
@@ -2,11 +2,13 @@ import { type CustomerProgress } from './turn-packet.ts';
2
2
  export { buildReviewPrompt, applyDeliveryReview, reviewSentences } from './delivery-review.ts';
3
3
  import { type SalesKnowledgeContext } from './sales-context-types.ts';
4
4
  import type { Contact } from './model.ts';
5
- import type { GenerationOptions, GenerationStream, GenerationTimings } from './generation-progress.ts';
5
+ import { type GenerationOptions, type GenerationStream, type GenerationTimings } from './generation-progress.ts';
6
6
  import { type CustomerMaterials } from './customer-materials.ts';
7
7
  /** Uses the Harness connection carrier, including its existing authentication. */
8
8
  export interface RpcTransport {
9
9
  call(channel: string, endpoint: string, payload: unknown, signal?: AbortSignal): Promise<unknown>;
10
+ /** The desktop workbench uses direct model calls. Existing evaluation drivers can still exercise the session API. */
11
+ draftModel?: true;
10
12
  follow?(sessionId: string, signal: AbortSignal): GenerationStream;
11
13
  }
12
14
  export interface SalesReply {
@@ -172,5 +174,5 @@ export declare function buildPrompt(contact: Contact, latest: string, knowledge?
172
174
  quote: string;
173
175
  } | null;
174
176
  }): string;
175
- /** Each generation and delivery review own fresh Sessions; neither can inherit another merchant. */
177
+ /** Each draft and its reviews only receive history belonging to the current merchant. */
176
178
  export declare function generateReply(rpc: RpcTransport, workspaceId: string, contact: Contact, latest: string, signal: AbortSignal, options?: GenerationOptions): Promise<SalesReply>;
@@ -0,0 +1,13 @@
1
+ import type { ObservationEvent } from '../langfuse-outbox.ts';
2
+ export declare const COMPANY_OBSERVATION_TARGET: import("../langfuse-config.ts").Destination;
3
+ export interface CompanyObservationCredentials {
4
+ resolve(ref: string): Promise<{
5
+ value: string;
6
+ source: string;
7
+ } | undefined>;
8
+ }
9
+ /** Host-only transport. The device credential never enters events or the browser. */
10
+ export declare function createCompanyObservationRelay(store: () => CompanyObservationCredentials | undefined, request?: typeof fetch): {
11
+ deviceScope: () => Promise<string | undefined>;
12
+ submit: (event: ObservationEvent, signal: AbortSignal) => Promise<void>;
13
+ };
@@ -0,0 +1,5 @@
1
+ import { type GenerationModel } from './generation-runtime.ts';
2
+ import type { HostContext } from './knowledge-host.ts';
3
+ import { type LlmService } from './server/llm.ts';
4
+ /** Draft computation uses the owner connection and the same Flash route without creating a Harness agent. */
5
+ export declare function registerGenerationModelRoute(ctx: HostContext, llm: LlmService, selectModel: () => GenerationModel | undefined, hasWorkspace: (id: string) => boolean): void;
@@ -30,3 +30,8 @@ export interface GenerationOptions {
30
30
  export interface GenerationStream extends AsyncIterable<unknown> {
31
31
  dispose(): void;
32
32
  }
33
+ export declare const GENERATION_MODEL_ENDPOINT = "wanji-sales-generation/model";
34
+ export interface GenerationExchange {
35
+ prompt: string;
36
+ text: string;
37
+ }
@@ -1,10 +1,14 @@
1
1
  import type { GenerationServices } from './generation-sessions.ts';
2
2
  export declare const SALES_GENERATION_PRESET = "wanji-sales-generation";
3
- type GenerationModel = {
3
+ export type GenerationModel = {
4
4
  provider: string;
5
5
  model: string;
6
6
  reasoningEffort?: string;
7
7
  };
8
+ export declare function generationInstructions(): {
9
+ role: string;
10
+ system: string;
11
+ };
8
12
  /** Permanent product-owned composition; never borrows the coding preset or its AGENTS/tools. */
9
13
  export declare function createGenerationRuntime(sdk: {
10
14
  agents: any;
@@ -22,4 +26,3 @@ export declare function createGenerationRuntime(sdk: {
22
26
  }): GenerationServices & {
23
27
  close(): Promise<void>;
24
28
  };
25
- export {};
@@ -7,6 +7,7 @@ import { type KnowledgeConfig, type HostContext as KnowledgeHostContext } from '
7
7
  import { SalesQuestionObserver } from './question-tracing.ts';
8
8
  import { type SalesQuestionRelay } from './question-relay.ts';
9
9
  export interface Config extends Omit<ProfileConfig, 'requestTimeoutMs'>, KnowledgeConfig {
10
+ wechatAsrApiKeyRef: string;
10
11
  wechatComponentRoot?: string;
11
12
  wechatRuntimeBaseUrl?: string;
12
13
  /** CRM/download/transcription deadline; knowledge keeps the existing requestTimeoutMs. */
@@ -114,7 +114,7 @@ export type SemanticRanker = (query: string, hits: import('./knowledge-types.ts'
114
114
  relevantOnly?: boolean;
115
115
  }) => Promise<import('./knowledge-types.ts').KnowledgeHit[]>;
116
116
  export type QueryExpander = (query: string, signal: AbortSignal) => Promise<string[]>;
117
- type DirectKnowledgeObserver = Pick<AgentKnowledgeObserver, 'start' | 'finish'>;
117
+ type DirectKnowledgeObserver = Pick<AgentKnowledgeObserver, 'run' | 'finish'>;
118
118
  export declare function createKnowledgeHost(tools: ToolService, config: KnowledgeConfig, lifetime?: AbortSignal, outbox?: EvaluationOutbox, evaluationOrWorkspaces?: EvaluationService | (() => {
119
119
  id: string;
120
120
  title: string;
@@ -0,0 +1,14 @@
1
+ export interface GatewayRequest {
2
+ method: string;
3
+ route: string;
4
+ request_id: string;
5
+ }
6
+ export declare class KnowledgeHttpCorrelation {
7
+ private readonly scope;
8
+ private readonly channel;
9
+ private readonly base;
10
+ constructor(baseUrl?: string);
11
+ private readonly capture;
12
+ run<T>(receipts: GatewayRequest[], send: () => T): T;
13
+ close(): void;
14
+ }
@@ -11,6 +11,7 @@ export interface ObservationEvent {
11
11
  question?: {
12
12
  sessionId: string;
13
13
  source: QuestionSource;
14
+ deviceScope?: string;
14
15
  };
15
16
  agent?: {
16
17
  sessionId: string;
@@ -1,3 +1,4 @@
1
+ import { type Destination } from './langfuse-config.ts';
1
2
  import { type ObservationEvent, type QuestionSource } from './langfuse-outbox.ts';
2
3
  type Status = 'answered' | 'no-reply' | 'error' | 'cancelled' | 'interrupted';
3
4
  export interface ObservedQuestion {
@@ -17,6 +18,7 @@ type Options = {
17
18
  directory: string;
18
19
  knowledgeBaseId: string;
19
20
  toolPrefix: string;
21
+ requireExplicitScope?: boolean;
20
22
  deliver?: (event: ObservationEvent) => Promise<void>;
21
23
  } & ({
22
24
  configFile: string;
@@ -25,7 +27,9 @@ type Options = {
25
27
  } | {
26
28
  relay: (event: ObservationEvent, signal: AbortSignal) => Promise<void>;
27
29
  configFile?: never;
28
- environment?: never;
30
+ environment?: 'test' | 'production';
31
+ relayTarget?: Destination;
32
+ deviceScope?: () => Promise<string | undefined>;
29
33
  });
30
34
  type SessionEvent = {
31
35
  type: string;
@@ -46,7 +50,8 @@ export declare class SalesQuestionTurns {
46
50
  private readonly salesSessions;
47
51
  private readonly tools;
48
52
  private readonly knowledgeBaseId;
49
- constructor(toolPrefix: string, knowledgeBaseId: string);
53
+ private readonly requireExplicitScope;
54
+ constructor(toolPrefix: string, knowledgeBaseId: string, requireExplicitScope?: boolean);
50
55
  observe(session: SessionRef, event: SessionEvent): {
51
56
  input: ObservedQuestion;
52
57
  outcome: QuestionOutcome;
@@ -61,6 +66,7 @@ export declare class SalesQuestionObserver {
61
66
  private readonly timer;
62
67
  private readonly turns;
63
68
  private readonly active;
69
+ private readonly owners;
64
70
  private target?;
65
71
  private sanitize?;
66
72
  private delivery?;
@@ -69,6 +75,7 @@ export declare class SalesQuestionObserver {
69
75
  constructor(options: Options);
70
76
  private configure;
71
77
  private event;
78
+ private captureScope;
72
79
  begin(input: ObservedQuestion): Promise<void>;
73
80
  finish(input: ObservedQuestion, outcome: QuestionOutcome): Promise<void>;
74
81
  observe(session: SessionRef, event: SessionEvent, alreadyEvaluated?: boolean): void;
@@ -0,0 +1,2 @@
1
+ /** Accept the built-in DSH account alias only from its owning provider. */
2
+ export declare function isSalesFlash(provider: unknown, model: unknown): boolean;
@@ -1,16 +1,30 @@
1
- export interface LlmService {
2
- stream(options: {
1
+ export type ModelRoute = {
2
+ provider: string;
3
+ model: string;
4
+ reasoningEffort?: string;
5
+ maxTokens?: number;
6
+ };
7
+ type TextContent = {
8
+ type: 'text';
9
+ text: string;
10
+ }[];
11
+ type ModelMessage = {
12
+ role: 'user';
13
+ content: TextContent;
14
+ } | {
15
+ role: 'assistant';
16
+ id: string;
17
+ source: {
18
+ kind: 'model';
3
19
  provider: string;
4
20
  model: string;
5
- maxTokens: number;
21
+ };
22
+ content: TextContent;
23
+ };
24
+ export interface LlmService {
25
+ stream(options: ModelRoute & {
6
26
  system: string;
7
- messages: {
8
- role: 'user';
9
- content: {
10
- type: 'text';
11
- text: string;
12
- }[];
13
- }[];
27
+ messages: ModelMessage[];
14
28
  signal: AbortSignal;
15
29
  }): AsyncIterable<unknown>;
16
30
  }
@@ -23,3 +37,5 @@ export declare function runModel(llm: LlmService, route: {
23
37
  system: string;
24
38
  text: string;
25
39
  }, signal: AbortSignal): Promise<unknown>;
40
+ export declare function collectModelText(llm: LlmService, route: ModelRoute, system: string, messages: ModelMessage[], signal: AbortSignal, maxChars: number, onFailure: (reason: Record<string, unknown>) => never, onText?: (text: string) => void): Promise<string>;
41
+ export {};
@@ -21,8 +21,12 @@ export declare class UpdateCoordinator {
21
21
  private view;
22
22
  private record;
23
23
  private initialized?;
24
+ private statusInitialized?;
25
+ private showVerification;
26
+ private readonly verificationStarted;
24
27
  private checking?;
25
28
  private job?;
29
+ private installing;
26
30
  private timer?;
27
31
  private lifetime;
28
32
  private disposed;
@@ -32,6 +36,7 @@ export declare class UpdateCoordinator {
32
36
  constructor(options: UpdateOptions);
33
37
  snapshot(): UpdateSnapshot;
34
38
  initialize(): Promise<void>;
39
+ initializeForStatus(): Promise<void>;
35
40
  private initializeOnce;
36
41
  private reconcile;
37
42
  private reconcileOwned;
@@ -72,6 +72,8 @@ export interface UpdateSnapshot {
72
72
  requestId?: string;
73
73
  blocked?: string;
74
74
  source?: 'company-market';
75
+ completedStages?: 0 | 1 | 2 | 3;
76
+ retryable?: boolean;
75
77
  }
76
78
  export interface ResumeIntent {
77
79
  workspaceId?: string;
@@ -4,7 +4,7 @@ import { WechatSyncService, type WechatSyncOptions } from './service.ts';
4
4
  /** Shared Harness Fetch routes already restrict access to authenticated owner peers. */
5
5
  export declare function registerWechatRoutes(ctx: HostContext, options: WechatSyncOptions & {
6
6
  sendingEnabled?: boolean;
7
- transcribeVoice?: (audio: Uint8Array, signal: AbortSignal) => Promise<string | undefined>;
7
+ transcribeVoice?: (audio: Uint8Array, signal: AbortSignal, mode: 'draft' | 'manual') => Promise<string | undefined>;
8
8
  }, injected?: WechatSyncService, desktop?: {
9
9
  available(): boolean;
10
10
  sender: DshWechatSender;
@@ -0,0 +1,5 @@
1
+ export declare const DEFAULT_WECHAT_ASR_KEY_REF = "DASHSCOPE_API_KEY";
2
+ export declare class WechatTranscriptionError extends Error {
3
+ constructor(code: 'WECHAT_TRANSCRIPTION_NOT_CONFIGURED' | 'WECHAT_TRANSCRIPTION_AUTH_FAILED' | 'WECHAT_TRANSCRIPTION_UNAVAILABLE' | 'WECHAT_TRANSCRIPTION_INVALID_AUDIO');
4
+ }
5
+ export declare function transcribeWechatWav(audio: Uint8Array, apiKey: string, signal: AbortSignal): Promise<string>;
@@ -6,7 +6,7 @@
6
6
 
7
7
  万机大脑按宿主标识接管安装。销售助手读取插件中心认可的本机安装版本,使用桌面登录态查询公司市场,仅在同一包有更高的正式版本时显示绿点和可用版本。更新路径为「万机插件中心 → 已安装 → 销售助手 → 更新」,面板以文字展示该路径。
8
8
 
9
- 打开应用、展开面板、安装状态或账号变化后重新查询,运行中定期刷新。查询失败时显示「暂时无法检查更新」并清除绿点。安装完成而旧版仍在运行时,显示「已安装,重启后生效」及两个版本,绿点消失。重启后的运行和安装版本应一致。源码链接和旧 npm 安装需通过公司市场安装才可接收公司市场提醒。
9
+ 打开应用、展开面板、安装状态或账号变化后重新查询,运行中定期刷新。查询失败时显示「暂时无法检查更新」并清除绿点。安装完成而旧版仍在运行时,页头显示「重启后生效」和已安装版本,面板展示正在使用和已安装的两个版本。重启后的运行和安装版本应一致。源码链接和旧 npm 安装需通过公司市场安装才可接收公司市场提醒。
10
10
 
11
11
  验收覆盖公司市场有更新、暂无更新、查询失败、账号切换、安装后待重启及重启后版本一致。用标准 DSH 的独立安装回归原 npm 路径,用脱敏样例核对会话和草稿。
12
12
 
@@ -28,9 +28,9 @@ Host 启动后约 5 秒内发起首次检查,运行中约每 30 秒检查一
28
28
 
29
29
  所有已连接销售窗口停止编辑至少 60 秒、没有未保存内容/任务,才开始自动准备。每个窗口需再次确认保存;Host 等待 CRM、生成相关工具和写入完成,停止下一轮微信同步并排空当前采集、消息及媒体提交。准备 30 秒未完成就延后,保留已有业务任务。正在编辑的 CRM 表单也会阻止自动安装。
30
30
 
31
- 断开的窗口不能因为心跳过期就被当成已保存。请重新连接该窗口、保存后关闭;无法确认时保守延后。若窗口已异常退出,在确认内容已保存后可重启应用重新建立窗口状态。界面只展示实际阶段,不模拟下载百分比。安装期间新打开的销售窗口同样暂停编辑。
31
+ 断开的窗口不能因为心跳过期就被当成已保存。请重新连接该窗口、保存后关闭;无法确认时保守延后。若窗口已异常退出,在确认内容已保存后可重启应用重新建立窗口状态。页头和面板按已确认的准备、安装、验证阶段展示完成度(0%、33%、67%、100%)。等待空闲、待重启或无法确认安装状态时显示对应状态。百分比表示阶段完成度。安装期间新打开的销售窗口同样暂停编辑。
32
32
 
33
- 当前实测 Windows Desktop 0.2.2-rc.3 与 Mac 开发 SDK 0.2.2-rc.1 的安装器可能返回 `applied`,实际仍加载旧模块。因此插件分别显示“正在使用”和“已安装”:不一致时提示“已安装,下次重启应用生效”。不会强制重启;可以继续使用,方便时自行重启。重启后由新 Host 检查版本和本地 SQLite,再报告更新生效。微信组件未就绪则保留同步设置并重试,不能把安装成功当作同步成功。
33
+ 当前实测 Windows Desktop 0.2.2-rc.3 与 Mac 开发 SDK 0.2.2-rc.1 的安装器可能返回 `applied`,实际仍加载旧模块。因此插件分别显示“正在使用”和“已安装”:不一致时页头持续显示“重启后生效”和已安装版本,收起面板也能看到。用户可继续使用,方便时自行重启。重启后由新 Host 检查版本和本地 SQLite,再报告更新生效。微信组件未就绪则保留同步设置并重试,不能把安装成功当作同步成功。
34
34
 
35
35
  ## 数据与失败恢复
36
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wanji_dsh/dsh-sales",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
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": {
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "schema": 1,
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "targets": {
5
5
  "win32-x64": {
6
- "url": "https://wanjidazi.com/plugins/sales-assistant/runtimes/wanji-wechat-runtime-1.0.2-win32-x64-9748e032830ccf40.tgz",
7
- "sha256": "9748e032830ccf406049142e9359126ba8a98ddb98313c5d7d036235bbaad066",
8
- "bytes": 22908326,
9
- "unpackedBytes": 47600016,
10
- "componentSha256": "53faf766238bb20c0f6bcd5c4a07a8f80dd5e27bc15bab2cf669f74983223c05"
6
+ "url": "https://wanjidazi.com/plugins/sales-assistant/runtimes/wanji-wechat-runtime-1.0.2-win32-x64-6552234d6562330f.tgz",
7
+ "sha256": "6552234d6562330fe607c9be6deb08d2aa5acb88f0adba2b05a5fd8e11146e44",
8
+ "bytes": 22906951,
9
+ "unpackedBytes": 47600929,
10
+ "componentSha256": "48ecb5f03bfc5645a34dd11a143f0e3c697ef59be9f91e6a1b8bf79949525100"
11
11
  },
12
12
  "darwin-arm64": {
13
13
  "url": "https://wanjidazi.com/plugins/sales-assistant/runtimes/wanji-wechat-runtime-1.0.4-darwin-arm64-f1256982cb2ffe92.tgz",