@wanji_dsh/dsh-sales 0.11.4 → 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.
- package/README.md +3 -1
- package/README.zh.md +12 -2
- package/config/production.cordis.yml +2 -2
- package/cordis.patch.yml +3 -0
- package/dist/client.js +266 -154
- package/dist/host.js +1274 -937
- package/dist/types/agent-knowledge.d.ts +1 -0
- package/dist/types/agent.d.ts +4 -2
- package/dist/types/company/observations.d.ts +13 -0
- package/dist/types/generation-model-route.d.ts +5 -0
- package/dist/types/generation-progress.d.ts +5 -0
- package/dist/types/generation-runtime.d.ts +5 -2
- package/dist/types/host.d.ts +1 -0
- package/dist/types/langfuse-outbox.d.ts +1 -0
- package/dist/types/question-tracing.d.ts +9 -2
- package/dist/types/server/llm.d.ts +26 -10
- package/dist/types/wechat/routes.d.ts +1 -1
- package/dist/types/wechat/transcription.d.ts +5 -0
- package/package.json +1 -1
- package/runtime/wechat-manifest.json +6 -6
package/dist/types/agent.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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 {};
|
package/dist/types/host.d.ts
CHANGED
|
@@ -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. */
|
|
@@ -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?:
|
|
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
|
-
|
|
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;
|
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
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
|
-
|
|
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 {};
|
|
@@ -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>;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
|
-
"version": "0.11.
|
|
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-
|
|
7
|
-
"sha256": "
|
|
8
|
-
"bytes":
|
|
9
|
-
"unpackedBytes":
|
|
10
|
-
"componentSha256": "
|
|
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",
|