@wanji_dsh/dsh-sales 0.9.7 → 0.10.1
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/.dsh/skills/wanji-sales-assistant/SKILL.md +28 -3
- package/.dsh/skills/wanji-sales-assistant/references/draft-review.md +2 -2
- package/.dsh/skills/wanji-sales-assistant/references/wechat-delivery.md +24 -0
- package/README.md +28 -4
- package/README.zh.md +55 -4
- package/dist/client.js +9988 -667
- package/dist/host.js +4005 -1085
- package/dist/types/{agent-evaluators.d.ts → agent-evaluators-v2.d.ts} +17 -3
- package/dist/types/agent-knowledge.d.ts +11 -2
- package/dist/types/agent.d.ts +21 -8
- package/dist/types/commercial-boundary.d.ts +7 -0
- package/dist/types/customer-intent.d.ts +49 -0
- package/dist/types/customer-materials.d.ts +49 -0
- package/dist/types/dialogue-tasks.d.ts +10 -0
- package/dist/types/draft-edits.d.ts +7 -0
- package/dist/types/evaluation-client.d.ts +2 -6
- package/dist/types/fact-proof.d.ts +2 -1
- package/dist/types/generation-progress.d.ts +32 -0
- package/dist/types/generation-runtime.d.ts +17 -0
- package/dist/types/generation-session-route.d.ts +5 -0
- package/dist/types/generation-sessions.d.ts +36 -0
- package/dist/types/host.d.ts +15 -0
- package/dist/types/knowledge-host.d.ts +22 -3
- package/dist/types/knowledge-judgment-delivery.d.ts +2 -0
- package/dist/types/knowledge-judgments.d.ts +12 -0
- package/dist/types/knowledge-privacy.d.ts +2 -0
- package/dist/types/knowledge-turns.d.ts +22 -0
- package/dist/types/langfuse-config.d.ts +1 -0
- package/dist/types/langfuse-outbox.d.ts +10 -2
- package/dist/types/material-catalog.d.ts +17 -0
- package/dist/types/material-metadata.d.ts +4 -0
- package/dist/types/material-reply.d.ts +24 -0
- package/dist/types/material-request.d.ts +45 -0
- package/dist/types/material-retrieval.d.ts +29 -0
- package/dist/types/model.d.ts +23 -2
- package/dist/types/open-generation.d.ts +5 -2
- package/dist/types/open-review.d.ts +39 -15
- package/dist/types/operation-evidence.d.ts +7 -0
- package/dist/types/percentage-quote.d.ts +6 -0
- package/dist/types/plan-projection.d.ts +2 -0
- package/dist/types/product-evidence.d.ts +4 -0
- package/dist/types/question-relay.d.ts +24 -0
- package/dist/types/question-route.d.ts +4 -0
- package/dist/types/question-tracing.d.ts +84 -0
- package/dist/types/quote-context.d.ts +9 -5
- package/dist/types/response-contract.d.ts +10 -0
- package/dist/types/retrieval-queries.d.ts +4 -0
- package/dist/types/review-turn.d.ts +6 -0
- package/dist/types/sales-context-types.d.ts +15 -0
- package/dist/types/semantic-rerank.d.ts +9 -0
- package/dist/types/sending-policy.d.ts +2 -0
- package/dist/types/server/intent-evaluation.d.ts +27 -0
- package/dist/types/server/intent-host.d.ts +17 -0
- package/dist/types/stream-preview.d.ts +11 -0
- package/dist/types/turn-packet.d.ts +21 -8
- package/dist/types/turn-plan.d.ts +19 -7
- package/dist/types/update/activity.d.ts +28 -0
- package/dist/types/update/coordinator.d.ts +44 -0
- package/dist/types/update/guard.d.ts +3 -0
- package/dist/types/update/integration.d.ts +6 -0
- package/dist/types/update/manager.d.ts +13 -0
- package/dist/types/update/routes.d.ts +6 -0
- package/dist/types/update/state.d.ts +13 -0
- package/dist/types/update/types.d.ts +88 -0
- package/dist/types/update/version.d.ts +1 -0
- package/dist/types/verified-arithmetic.d.ts +5 -0
- package/dist/types/voice-examples.d.ts +1 -0
- package/dist/types/wechat/cua-approval.d.ts +36 -0
- package/dist/types/wechat/cua-sender.d.ts +160 -0
- package/dist/types/wechat/cua-vision.d.ts +31 -0
- package/dist/types/wechat/delivery.d.ts +47 -0
- package/dist/types/wechat/intent-scheduler.d.ts +26 -0
- package/dist/types/wechat/repository-client.d.ts +1 -1
- package/dist/types/wechat/routes.d.ts +9 -7
- package/dist/types/wechat/service.d.ts +12 -3
- package/dist/types/wechat/types.d.ts +5 -0
- package/dist/types/wechat-draft-input.d.ts +3 -0
- package/dist/types/wechat-voice.d.ts +3 -0
- package/dist/types/weknora-http.d.ts +8 -0
- package/dist/wechat-repository-worker.js +248 -22
- package/docs/agent-knowledge-observation.md +58 -0
- package/docs/auto-update.md +41 -0
- package/docs/customer-material-retrieval.md +48 -0
- package/docs/licenses/ccount@2.0.1.txt +24 -0
- package/docs/licenses/character-entities@2.0.2.txt +24 -0
- package/docs/licenses/debug@4.4.3.txt +21 -0
- package/docs/licenses/decode-named-character-reference@1.3.0.txt +24 -0
- package/docs/licenses/dequal@2.0.3.txt +23 -0
- package/docs/licenses/devlop@1.1.0.txt +24 -0
- package/docs/licenses/escape-string-regexp@5.0.0.txt +11 -0
- package/docs/licenses/longest-streak@3.1.0.txt +24 -0
- package/docs/licenses/markdown-table@3.1.0.txt +24 -0
- package/docs/licenses/mdast-util-find-and-replace@3.0.4.txt +24 -0
- package/docs/licenses/mdast-util-from-markdown@2.0.3.txt +24 -0
- package/docs/licenses/mdast-util-gfm-autolink-literal@2.1.0.txt +24 -0
- package/docs/licenses/mdast-util-gfm-footnote@2.1.0.txt +24 -0
- package/docs/licenses/mdast-util-gfm-strikethrough@2.0.1.txt +24 -0
- package/docs/licenses/mdast-util-gfm-table@2.0.1.txt +24 -0
- package/docs/licenses/mdast-util-gfm-task-list-item@2.0.1.txt +24 -0
- package/docs/licenses/mdast-util-gfm@3.0.0.txt +24 -0
- package/docs/licenses/mdast-util-phrasing@4.1.0.txt +25 -0
- package/docs/licenses/mdast-util-to-markdown@2.2.3.txt +24 -0
- package/docs/licenses/mdast-util-to-string@4.0.0.txt +24 -0
- package/docs/licenses/micromark-core-commonmark@2.0.4.txt +24 -0
- package/docs/licenses/micromark-extension-gfm-autolink-literal@2.1.0.txt +24 -0
- package/docs/licenses/micromark-extension-gfm-footnote@2.1.0.txt +24 -0
- package/docs/licenses/micromark-extension-gfm-strikethrough@2.1.0.txt +24 -0
- package/docs/licenses/micromark-extension-gfm-table@2.1.2.txt +24 -0
- package/docs/licenses/micromark-extension-gfm-tagfilter@2.0.0.txt +24 -0
- package/docs/licenses/micromark-extension-gfm-task-list-item@2.1.0.txt +24 -0
- package/docs/licenses/micromark-extension-gfm@3.0.0.txt +24 -0
- package/docs/licenses/micromark-factory-destination@2.0.1.txt +24 -0
- package/docs/licenses/micromark-factory-label@2.0.1.txt +24 -0
- package/docs/licenses/micromark-factory-space@2.1.0.txt +24 -0
- package/docs/licenses/micromark-factory-title@2.0.1.txt +24 -0
- package/docs/licenses/micromark-factory-whitespace@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-character@2.1.1.txt +24 -0
- package/docs/licenses/micromark-util-chunked@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-classify-character@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-combine-extensions@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-decode-numeric-character-reference@2.0.2.txt +24 -0
- package/docs/licenses/micromark-util-decode-string@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-edit-map@1.0.0.txt +24 -0
- package/docs/licenses/micromark-util-encode@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-html-tag-name@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-normalize-identifier@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-resolve-all@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-sanitize-uri@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-subtokenize@2.1.0.txt +24 -0
- package/docs/licenses/micromark-util-symbol@2.0.1.txt +24 -0
- package/docs/licenses/micromark-util-types@2.0.3.txt +24 -0
- package/docs/licenses/micromark@4.0.3.txt +24 -0
- package/docs/licenses/ms@2.1.3.txt +23 -0
- package/docs/licenses/unist-util-is@6.0.1.txt +24 -0
- package/docs/licenses/unist-util-stringify-position@4.0.0.txt +24 -0
- package/docs/licenses/unist-util-visit-parents@6.1.0.txt +24 -0
- package/docs/licenses/unist-util-visit@5.2.0.txt +24 -0
- package/docs/licenses/zwitch@2.0.4.txt +24 -0
- package/docs/sales-agent-evaluation-v2.md +102 -0
- package/docs/wechat-sync.md +23 -0
- package/package.json +21 -7
- package/runtime/customer-materials.json +1935 -0
- package/runtime/documented-operation-references.json +123 -0
- package/runtime/operation-references.json +352 -0
- package/runtime/product-references.json +10 -0
- package/runtime/wechat-manifest.json +1 -1
- package/runtime/wechat-ocr-arm64 +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Contact } from './model.ts';
|
|
2
2
|
import type { SalesKnowledgeContext } from './sales-context-types.ts';
|
|
3
|
+
import { type PendingCompanyTask } from './dialogue-tasks.ts';
|
|
4
|
+
import type { CustomerMaterials } from './customer-materials.ts';
|
|
3
5
|
export declare const salesActions: readonly ["answer", "provide_material", "prepare_confirmation", "clarify", "verify_company", "coordinate_demo", "wait", "stop"];
|
|
4
6
|
export type SalesActionKind = typeof salesActions[number];
|
|
5
7
|
export interface CompanyFact {
|
|
@@ -18,7 +20,7 @@ export declare function currentCompanyFacts(contact: Contact, now?: number): {
|
|
|
18
20
|
};
|
|
19
21
|
export interface Evidence {
|
|
20
22
|
text: string;
|
|
21
|
-
authority: 'customer' | 'customer_background' | 'deal' | 'company' | 'historical_sales';
|
|
23
|
+
authority: 'customer' | 'customer_background' | 'deal' | 'company' | 'historical_sales' | 'product_reference' | 'version_scoped_reference' | 'retrieval_observation';
|
|
22
24
|
}
|
|
23
25
|
export interface BoundItem {
|
|
24
26
|
source_id: string;
|
|
@@ -36,6 +38,8 @@ export interface CustomerProgress {
|
|
|
36
38
|
kind: 'sample' | 'intro' | 'confirmation';
|
|
37
39
|
status: 'requested' | 'received' | 'reviewed';
|
|
38
40
|
})[];
|
|
41
|
+
/** Host-derived work awaiting external evidence, not a commercial fact. */
|
|
42
|
+
pending?: PendingCompanyTask[];
|
|
39
43
|
}
|
|
40
44
|
export declare function buildTurnPacket(contact: Contact, latest: string, knowledge?: SalesKnowledgeContext): {
|
|
41
45
|
schemaVersion: "1.0";
|
|
@@ -55,6 +59,7 @@ export declare function buildTurnPacket(contact: Contact, latest: string, knowle
|
|
|
55
59
|
};
|
|
56
60
|
latest_customer_message: string;
|
|
57
61
|
sources: Record<string, Evidence>;
|
|
62
|
+
selection_rule: string;
|
|
58
63
|
current_company_facts: {
|
|
59
64
|
key: string;
|
|
60
65
|
sourceId: string;
|
|
@@ -151,11 +156,14 @@ export declare function buildTurnPacket(contact: Contact, latest: string, knowle
|
|
|
151
156
|
start_basis?: "activation" | "payment" | "agreement";
|
|
152
157
|
} | null;
|
|
153
158
|
calculation: import("./quote-context.ts").QuoteCalculation | null;
|
|
159
|
+
response_contract: import("./response-contract.ts").AnswerContract;
|
|
154
160
|
data_scope: "anonymized-only" | "customer-authorized";
|
|
161
|
+
material_context: CustomerMaterials | null;
|
|
155
162
|
company_conflicts: string[];
|
|
156
163
|
knowledge: {
|
|
157
164
|
contextId: string | null;
|
|
158
165
|
checkedAt: string | null;
|
|
166
|
+
materials_available: boolean;
|
|
159
167
|
policy_candidates: Record<string, unknown>[];
|
|
160
168
|
rule: string;
|
|
161
169
|
};
|
|
@@ -166,17 +174,22 @@ export declare function buildTurnPacket(contact: Contact, latest: string, knowle
|
|
|
166
174
|
authority: "method_only";
|
|
167
175
|
}[];
|
|
168
176
|
previous_progress: {
|
|
169
|
-
|
|
177
|
+
pending?: PendingCompanyTask[];
|
|
178
|
+
decisions: (BoundItem & {
|
|
179
|
+
topic: string;
|
|
180
|
+
meaning: string;
|
|
181
|
+
} & {
|
|
170
182
|
source_id: string;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
})[];
|
|
184
|
+
artifacts: (BoundItem & {
|
|
185
|
+
kind: "sample" | "intro" | "confirmation";
|
|
186
|
+
status: "requested" | "received" | "reviewed";
|
|
187
|
+
} & {
|
|
174
188
|
source_id: string;
|
|
175
|
-
|
|
176
|
-
|
|
189
|
+
})[];
|
|
190
|
+
stage: "exploring" | "evaluating" | "confirming" | "paused" | "declined";
|
|
177
191
|
source_id: string;
|
|
178
192
|
quote: string;
|
|
179
|
-
stage?: "exploring" | "evaluating" | "confirming" | "paused" | "declined" | undefined;
|
|
180
193
|
} | null;
|
|
181
194
|
};
|
|
182
195
|
export type TurnPacket = ReturnType<typeof buildTurnPacket>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type TurnPacket, type CustomerProgress, type SalesActionKind } from './turn-packet.ts';
|
|
2
2
|
import type { Contact } from './model.ts';
|
|
3
|
+
import { type MaterialNeed } from './customer-materials.ts';
|
|
3
4
|
export interface TurnPlan {
|
|
4
5
|
goal: string;
|
|
5
6
|
customer_decisions: {
|
|
@@ -11,7 +12,9 @@ export interface TurnPlan {
|
|
|
11
12
|
next_action: string;
|
|
12
13
|
action?: SalesActionKind;
|
|
13
14
|
progress?: CustomerProgress;
|
|
15
|
+
material_need?: MaterialNeed;
|
|
14
16
|
}
|
|
17
|
+
export declare function buildTurnPlanCorrection(error: unknown): string;
|
|
15
18
|
export declare function parseTurnPlan(text: string, contact: Contact, latest: string, packet?: TurnPacket): TurnPlan;
|
|
16
19
|
export declare function buildTurnPlanPrompt(contact: Contact, latest: string, contextId?: string, packet?: {
|
|
17
20
|
schemaVersion: "1.0";
|
|
@@ -31,6 +34,7 @@ export declare function buildTurnPlanPrompt(contact: Contact, latest: string, co
|
|
|
31
34
|
};
|
|
32
35
|
latest_customer_message: string;
|
|
33
36
|
sources: Record<string, import("./turn-packet.ts").Evidence>;
|
|
37
|
+
selection_rule: string;
|
|
34
38
|
current_company_facts: {
|
|
35
39
|
key: string;
|
|
36
40
|
sourceId: string;
|
|
@@ -127,11 +131,14 @@ export declare function buildTurnPlanPrompt(contact: Contact, latest: string, co
|
|
|
127
131
|
start_basis?: "activation" | "payment" | "agreement";
|
|
128
132
|
} | null;
|
|
129
133
|
calculation: import("./quote-context.ts").QuoteCalculation | null;
|
|
134
|
+
response_contract: import("./response-contract.ts").AnswerContract;
|
|
130
135
|
data_scope: "anonymized-only" | "customer-authorized";
|
|
136
|
+
material_context: import("./customer-materials.ts").CustomerMaterials | null;
|
|
131
137
|
company_conflicts: string[];
|
|
132
138
|
knowledge: {
|
|
133
139
|
contextId: string | null;
|
|
134
140
|
checkedAt: string | null;
|
|
141
|
+
materials_available: boolean;
|
|
135
142
|
policy_candidates: Record<string, unknown>[];
|
|
136
143
|
rule: string;
|
|
137
144
|
};
|
|
@@ -142,16 +149,21 @@ export declare function buildTurnPlanPrompt(contact: Contact, latest: string, co
|
|
|
142
149
|
authority: "method_only";
|
|
143
150
|
}[];
|
|
144
151
|
previous_progress: {
|
|
145
|
-
|
|
152
|
+
pending?: import("./dialogue-tasks.ts").PendingCompanyTask[];
|
|
153
|
+
decisions: (import("./turn-packet.ts").BoundItem & {
|
|
154
|
+
topic: string;
|
|
155
|
+
meaning: string;
|
|
156
|
+
} & {
|
|
146
157
|
source_id: string;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
158
|
+
})[];
|
|
159
|
+
artifacts: (import("./turn-packet.ts").BoundItem & {
|
|
160
|
+
kind: "sample" | "intro" | "confirmation";
|
|
161
|
+
status: "requested" | "received" | "reviewed";
|
|
162
|
+
} & {
|
|
150
163
|
source_id: string;
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
})[];
|
|
165
|
+
stage: "exploring" | "evaluating" | "confirming" | "paused" | "declined";
|
|
153
166
|
source_id: string;
|
|
154
167
|
quote: string;
|
|
155
|
-
stage?: "exploring" | "evaluating" | "confirming" | "paused" | "declined" | undefined;
|
|
156
168
|
} | null;
|
|
157
169
|
}): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const pause: (signal: AbortSignal, ms?: number) => Promise<void>;
|
|
2
|
+
/** A draining barrier allows descendants of in-flight work to finish. */
|
|
3
|
+
export declare class UpdateActivity {
|
|
4
|
+
private scope;
|
|
5
|
+
private pending;
|
|
6
|
+
private draining;
|
|
7
|
+
run<T>(work: () => Promise<T>, continuation?: boolean): Promise<T>;
|
|
8
|
+
prepare(signal: AbortSignal): Promise<() => void>;
|
|
9
|
+
}
|
|
10
|
+
export interface ClientReadiness {
|
|
11
|
+
revision: number;
|
|
12
|
+
busy: boolean;
|
|
13
|
+
dirty: boolean;
|
|
14
|
+
prepared?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Missing heartbeats remain unknown; a timeout never proves a draft was saved. */
|
|
17
|
+
export declare class UpdateClients {
|
|
18
|
+
private windows;
|
|
19
|
+
private request?;
|
|
20
|
+
private now;
|
|
21
|
+
constructor(now?: () => number);
|
|
22
|
+
heartbeat(id: string, input: ClientReadiness): string | undefined;
|
|
23
|
+
unregister(id: string): void;
|
|
24
|
+
idle(): boolean;
|
|
25
|
+
prepare(id: string): void;
|
|
26
|
+
ready(id: string): boolean;
|
|
27
|
+
cancel(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { UpdateState } from './state.ts';
|
|
2
|
+
import { UpdateActivity, UpdateClients } from './activity.ts';
|
|
3
|
+
import { type UpdateSnapshot, type ResumeIntent } from './types.ts';
|
|
4
|
+
export interface UpdateOptions {
|
|
5
|
+
state: UpdateState;
|
|
6
|
+
manager: () => unknown;
|
|
7
|
+
version: string;
|
|
8
|
+
clients: UpdateClients;
|
|
9
|
+
activity: UpdateActivity;
|
|
10
|
+
sync: {
|
|
11
|
+
prepareUpdate(signal: AbortSignal): Promise<ResumeIntent>;
|
|
12
|
+
resumeAfterUpdate(intent: ResumeIntent): Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
health(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** Scheduling belongs to the plugin; package installation belongs to DSH. */
|
|
17
|
+
export declare class UpdateCoordinator {
|
|
18
|
+
private options;
|
|
19
|
+
private view;
|
|
20
|
+
private record;
|
|
21
|
+
private initialized?;
|
|
22
|
+
private checking?;
|
|
23
|
+
private job?;
|
|
24
|
+
private timer?;
|
|
25
|
+
private lifetime;
|
|
26
|
+
private disposed;
|
|
27
|
+
private invalid;
|
|
28
|
+
private nextCheck;
|
|
29
|
+
private failures;
|
|
30
|
+
constructor(options: UpdateOptions);
|
|
31
|
+
snapshot(): UpdateSnapshot;
|
|
32
|
+
initialize(): Promise<void>;
|
|
33
|
+
private initializeOnce;
|
|
34
|
+
private reconcile;
|
|
35
|
+
private reconcileOwned;
|
|
36
|
+
start(): void;
|
|
37
|
+
private schedule;
|
|
38
|
+
private tick;
|
|
39
|
+
check(): Promise<void>;
|
|
40
|
+
setAutomatic(enabled: boolean): Promise<void>;
|
|
41
|
+
requestInstall(manual?: boolean): Promise<void>;
|
|
42
|
+
private install;
|
|
43
|
+
dispose(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HostContext } from '../knowledge-host.ts';
|
|
2
|
+
import type { WechatSyncService } from '../wechat/service.ts';
|
|
3
|
+
import { UpdateActivity } from './activity.ts';
|
|
4
|
+
import { UpdateCoordinator } from './coordinator.ts';
|
|
5
|
+
/** Optional native services: their absence must not prevent sales from starting. */
|
|
6
|
+
export declare function mountUpdates(ctx: HostContext, storageDir: string, activity: UpdateActivity, sync: WechatSyncService): UpdateCoordinator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Manager, type Candidate, type VersionList, type Phase } from './types.ts';
|
|
2
|
+
export type Capability = {
|
|
3
|
+
status: 'ready';
|
|
4
|
+
manager: Manager;
|
|
5
|
+
installedVersion: string;
|
|
6
|
+
} | {
|
|
7
|
+
status: 'unsupported' | 'migration-required';
|
|
8
|
+
reason: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function probeUpdateCapability(raw: unknown): Promise<Capability>;
|
|
11
|
+
export declare function selectCandidate(list: VersionList, running: string): Candidate | undefined;
|
|
12
|
+
/** A successful install response does not prove that HMR loaded new JavaScript. */
|
|
13
|
+
export declare function activationPhase(installed: string | undefined, running: string): Phase;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HostContext } from '../knowledge-host.ts';
|
|
2
|
+
import type { UpdateCoordinator } from './coordinator.ts';
|
|
3
|
+
import type { UpdateClients } from './activity.ts';
|
|
4
|
+
export declare const UPDATE_METHOD = "wanji-sales-update/request";
|
|
5
|
+
/** Uses the same owner-authenticated shared Fetch channel as sales data routes. */
|
|
6
|
+
export declare function registerUpdateRoutes(ctx: HostContext, coordinator: UpdateCoordinator, clients: UpdateClients): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type UpdateRecord } from './types.ts';
|
|
2
|
+
/** Private updater state, never a copy of the profile's package files or business database. */
|
|
3
|
+
export declare class UpdateState {
|
|
4
|
+
readonly directory: string;
|
|
5
|
+
readonly filename: string;
|
|
6
|
+
readonly lockfile: string;
|
|
7
|
+
constructor(storageDir: string, profile: string);
|
|
8
|
+
private directoryReady;
|
|
9
|
+
read(): Promise<UpdateRecord>;
|
|
10
|
+
write(value: UpdateRecord): Promise<void>;
|
|
11
|
+
held(): Promise<boolean>;
|
|
12
|
+
acquire(): Promise<undefined | (() => Promise<void>)>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME = "@wanji_dsh/dsh-sales";
|
|
2
|
+
export declare const DEFAULT_AUTOMATIC = true;
|
|
3
|
+
export declare const REGISTRY = "https://registry.npmjs.org/";
|
|
4
|
+
export type Phase = 'idle' | 'checking' | 'available' | 'waiting-idle' | 'preparing' | 'installing' | 'verifying' | 'restart-required' | 'updated' | 'failed' | 'recovery-required' | 'unsupported' | 'migration-required';
|
|
5
|
+
export interface Bundle {
|
|
6
|
+
name: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
updatable?: boolean;
|
|
9
|
+
update?: 'registry' | 'git';
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface PublishedVersion {
|
|
13
|
+
version: string;
|
|
14
|
+
tags: readonly string[];
|
|
15
|
+
prerelease: boolean;
|
|
16
|
+
bundle: boolean;
|
|
17
|
+
deprecated?: string;
|
|
18
|
+
incompatible?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export type VersionList = {
|
|
21
|
+
status: 'listed';
|
|
22
|
+
installed: string;
|
|
23
|
+
registry: string | null;
|
|
24
|
+
versions: readonly PublishedVersion[];
|
|
25
|
+
} | {
|
|
26
|
+
status: 'refused';
|
|
27
|
+
problem: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
};
|
|
30
|
+
export interface ChangeResult {
|
|
31
|
+
application: 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled';
|
|
32
|
+
error?: {
|
|
33
|
+
code?: string;
|
|
34
|
+
};
|
|
35
|
+
version?: string;
|
|
36
|
+
restartReason?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface UpdateResult {
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
step: string;
|
|
42
|
+
result: ChangeResult;
|
|
43
|
+
restore?: ChangeResult;
|
|
44
|
+
}
|
|
45
|
+
export interface Manager {
|
|
46
|
+
listBundles(): Promise<readonly Bundle[]>;
|
|
47
|
+
listVersions(name: string, options: {
|
|
48
|
+
registry: string;
|
|
49
|
+
}, signal?: AbortSignal): Promise<VersionList>;
|
|
50
|
+
updateBundle(name: string, version: string, options: {
|
|
51
|
+
registry: string;
|
|
52
|
+
requestId: string;
|
|
53
|
+
}): Promise<UpdateResult>;
|
|
54
|
+
waitForInstall?(requestId: string): Promise<unknown>;
|
|
55
|
+
}
|
|
56
|
+
export interface Candidate {
|
|
57
|
+
version: string;
|
|
58
|
+
registry: string;
|
|
59
|
+
automatic: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface UpdateSnapshot {
|
|
62
|
+
phase: Phase;
|
|
63
|
+
runningVersion: string;
|
|
64
|
+
installedVersion?: string;
|
|
65
|
+
candidate?: Candidate;
|
|
66
|
+
automatic: boolean;
|
|
67
|
+
checkedAt?: number;
|
|
68
|
+
error?: string;
|
|
69
|
+
requestId?: string;
|
|
70
|
+
blocked?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface ResumeIntent {
|
|
73
|
+
workspaceId?: string;
|
|
74
|
+
automatic: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface UpdateRecord {
|
|
77
|
+
schema: 1;
|
|
78
|
+
automatic: boolean;
|
|
79
|
+
requestId?: string;
|
|
80
|
+
from?: string;
|
|
81
|
+
to?: string;
|
|
82
|
+
phase: Phase;
|
|
83
|
+
startedAt?: number;
|
|
84
|
+
checkedAt?: number;
|
|
85
|
+
failedTarget?: string;
|
|
86
|
+
result?: UpdateResult;
|
|
87
|
+
resume?: ResumeIntent;
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RUNNING_VERSION: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Contact } from './model.ts';
|
|
2
|
+
import type { QuoteCalculation } from './quote-context.ts';
|
|
3
|
+
/** Parse only monetary operands selected after business anchors, never model arithmetic. */
|
|
4
|
+
export declare function parseMoney(raw: string): bigint | undefined;
|
|
5
|
+
export declare function partialCalculation(contact: Contact, latest: string): QuoteCalculation | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function voiceExamplePrompt(message: string): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface CuaApproval {
|
|
2
|
+
requestId: string;
|
|
3
|
+
subject: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CuaQuestion {
|
|
6
|
+
questions: {
|
|
7
|
+
id: string;
|
|
8
|
+
intent?: {
|
|
9
|
+
kind: string;
|
|
10
|
+
approve: string;
|
|
11
|
+
reject: string;
|
|
12
|
+
subject?: {
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
options?: {
|
|
17
|
+
label: string;
|
|
18
|
+
}[];
|
|
19
|
+
}[];
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
}
|
|
22
|
+
export interface CuaAnswer {
|
|
23
|
+
answers: {
|
|
24
|
+
id: string;
|
|
25
|
+
selected: string[];
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
/** Present only the sender's WeChat consent through DSH's scoped answerer seam.
|
|
29
|
+
* Pending questions never imply consent; only the owner UI's exact nonce can answer. */
|
|
30
|
+
export declare class CuaApprovalBroker {
|
|
31
|
+
private pending;
|
|
32
|
+
view(workspaceId: string): CuaApproval | undefined;
|
|
33
|
+
answer(workspaceId: string, requestId: string, approved: boolean): void;
|
|
34
|
+
ask(workspaceId: string, request: CuaQuestion, next: () => Promise<CuaAnswer>): Promise<CuaAnswer>;
|
|
35
|
+
close(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { type CuaQuestion, type CuaAnswer } from './cua-approval.ts';
|
|
2
|
+
import type { DeliveryInput, DeliverySource } from './delivery.ts';
|
|
3
|
+
import { type ScreenText } from './cua-vision.ts';
|
|
4
|
+
interface ToolResult {
|
|
5
|
+
results: {
|
|
6
|
+
result: {
|
|
7
|
+
isError: boolean;
|
|
8
|
+
value?: unknown;
|
|
9
|
+
error?: {
|
|
10
|
+
message?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
export interface CuaAgentHandle {
|
|
16
|
+
agent: unknown;
|
|
17
|
+
dispose(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface CuaPermissionDiagnostic {
|
|
20
|
+
accessibility: boolean;
|
|
21
|
+
screenRecording: boolean;
|
|
22
|
+
helper: {
|
|
23
|
+
pid: number;
|
|
24
|
+
path?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
};
|
|
27
|
+
parent: {
|
|
28
|
+
pid: number;
|
|
29
|
+
path?: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
};
|
|
32
|
+
launchApplication?: {
|
|
33
|
+
name: string;
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface CuaServices {
|
|
38
|
+
agents: {
|
|
39
|
+
create(input: {
|
|
40
|
+
sessionId: string;
|
|
41
|
+
meta: {
|
|
42
|
+
cwd: string;
|
|
43
|
+
agentPreset: string;
|
|
44
|
+
};
|
|
45
|
+
setup?: (scope: unknown) => Promise<void>;
|
|
46
|
+
}): Promise<CuaAgentHandle>;
|
|
47
|
+
};
|
|
48
|
+
mountPreset(scope: unknown): Promise<void>;
|
|
49
|
+
registerApproval(scope: unknown, answer: (request: CuaQuestion, next: () => Promise<CuaAnswer>) => Promise<CuaAnswer>): void;
|
|
50
|
+
readScreen?(screenshot: any, signal: AbortSignal): Promise<ScreenText>;
|
|
51
|
+
permissionStatus?(): Promise<CuaPermissionDiagnostic | undefined>;
|
|
52
|
+
tools: {
|
|
53
|
+
execute(input: {
|
|
54
|
+
agent: unknown;
|
|
55
|
+
calls: {
|
|
56
|
+
type: 'tool-call';
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
arguments: string;
|
|
60
|
+
}[];
|
|
61
|
+
signal: AbortSignal;
|
|
62
|
+
}): Promise<ToolResult>;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The PTC executor admits only run_code at the root; raw cua remains a bound subcall. */
|
|
66
|
+
export declare function dispatchCua(services: CuaServices, agent: unknown, method: string, params: Record<string, unknown>, signal: AbortSignal): Promise<unknown>;
|
|
67
|
+
/** Retry only a read whose native geometry was rejected, with a fresh observation
|
|
68
|
+
* between attempts. Never retry an input or send, and never accept a rejected frame. */
|
|
69
|
+
export declare function captureStableScreen(call: (method: string, params: Record<string, unknown>) => Promise<unknown>, appHandle: string, windowId: string): Promise<unknown>;
|
|
70
|
+
interface AxNode {
|
|
71
|
+
id: string;
|
|
72
|
+
role: string;
|
|
73
|
+
line: string;
|
|
74
|
+
strings: string[];
|
|
75
|
+
value?: string;
|
|
76
|
+
label?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Parse only provider-issued addresses and literal strings, never instructions in chat text. */
|
|
79
|
+
export declare function axNodes(tree: string): AxNode[];
|
|
80
|
+
/** AX-only transport through official DSH tools. No screen coordinates, shell input,
|
|
81
|
+
* alternative transport, model-written text, or unobserved element identifiers. */
|
|
82
|
+
export declare class DshWechatSender {
|
|
83
|
+
private approvals;
|
|
84
|
+
approval(workspaceId: string): import("./cua-approval.ts").CuaApproval | undefined;
|
|
85
|
+
answerApproval(workspaceId: string, requestId: string, approved: boolean): void;
|
|
86
|
+
private closed;
|
|
87
|
+
private busy;
|
|
88
|
+
private services;
|
|
89
|
+
private sessions;
|
|
90
|
+
constructor(services: () => CuaServices | undefined);
|
|
91
|
+
private exclusive;
|
|
92
|
+
check(workspaceId: string, cwd: string, signal: AbortSignal, source?: DeliverySource): Promise<{
|
|
93
|
+
ready: boolean;
|
|
94
|
+
reason: string;
|
|
95
|
+
permissionInspection: string;
|
|
96
|
+
controls?: undefined;
|
|
97
|
+
windows?: undefined;
|
|
98
|
+
vision?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
permission?: CuaPermissionDiagnostic | undefined;
|
|
101
|
+
ready: boolean;
|
|
102
|
+
reason: string;
|
|
103
|
+
permissionInspection?: undefined;
|
|
104
|
+
controls?: undefined;
|
|
105
|
+
windows?: undefined;
|
|
106
|
+
vision?: undefined;
|
|
107
|
+
} | {
|
|
108
|
+
ready: boolean;
|
|
109
|
+
reason: string;
|
|
110
|
+
controls: number;
|
|
111
|
+
permissionInspection?: undefined;
|
|
112
|
+
windows?: undefined;
|
|
113
|
+
vision?: undefined;
|
|
114
|
+
} | {
|
|
115
|
+
ready: boolean;
|
|
116
|
+
reason: string;
|
|
117
|
+
windows: {
|
|
118
|
+
title: string;
|
|
119
|
+
onScreen: boolean;
|
|
120
|
+
width: number;
|
|
121
|
+
height: number;
|
|
122
|
+
}[];
|
|
123
|
+
permissionInspection?: undefined;
|
|
124
|
+
controls?: undefined;
|
|
125
|
+
vision?: undefined;
|
|
126
|
+
} | {
|
|
127
|
+
ready: boolean;
|
|
128
|
+
reason: string;
|
|
129
|
+
controls: number;
|
|
130
|
+
vision: {
|
|
131
|
+
width: number;
|
|
132
|
+
height: number;
|
|
133
|
+
regions: number;
|
|
134
|
+
identityMatch: boolean;
|
|
135
|
+
profileWindows: number;
|
|
136
|
+
popupResults: {
|
|
137
|
+
width: number;
|
|
138
|
+
height: number;
|
|
139
|
+
captured: boolean;
|
|
140
|
+
}[];
|
|
141
|
+
labels: {
|
|
142
|
+
text: string;
|
|
143
|
+
x: number;
|
|
144
|
+
y: number;
|
|
145
|
+
width: number;
|
|
146
|
+
height: number;
|
|
147
|
+
}[];
|
|
148
|
+
sourceVisible: boolean;
|
|
149
|
+
};
|
|
150
|
+
permissionInspection?: undefined;
|
|
151
|
+
windows?: undefined;
|
|
152
|
+
}>;
|
|
153
|
+
send(input: DeliveryInput & {
|
|
154
|
+
source: DeliverySource;
|
|
155
|
+
}, check: () => Promise<void>, signal: AbortSignal, cwd: string): Promise<void>;
|
|
156
|
+
private checkUnlocked;
|
|
157
|
+
private sendUnlocked;
|
|
158
|
+
close(): Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface ScreenRegion {
|
|
2
|
+
text: string;
|
|
3
|
+
confidence: number;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ScreenRect {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
confidence: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ScreenText {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
regions: ScreenRegion[];
|
|
20
|
+
rectangles?: ScreenRect[];
|
|
21
|
+
}
|
|
22
|
+
export declare function chatHeading(screen: ScreenText, name: string): ScreenRegion;
|
|
23
|
+
export declare function screenHasIdentity(screen: ScreenText, identity: string): boolean;
|
|
24
|
+
/** Navigate through a detected rectangle beside the exact latest text. A click is
|
|
25
|
+
* discovery only; profile identity, never image geometry, authorizes the next step. */
|
|
26
|
+
export declare function profileAnchor(screen: ScreenText, name: string, text: string): {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
};
|
|
30
|
+
/** The local helper only decodes an image and recognizes text; it has no UI or network API. */
|
|
31
|
+
export declare function recognizeWechatScreen(binary: string, data: Uint8Array, signal: AbortSignal): Promise<ScreenText>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface DeliverySource {
|
|
2
|
+
version: number;
|
|
3
|
+
messageId: string;
|
|
4
|
+
pending: boolean;
|
|
5
|
+
text: string;
|
|
6
|
+
draft: string;
|
|
7
|
+
kind: string;
|
|
8
|
+
accountId: string;
|
|
9
|
+
chatKey: string;
|
|
10
|
+
alias?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DeliveryInput {
|
|
14
|
+
workspaceId: string;
|
|
15
|
+
contactId: string;
|
|
16
|
+
version: number;
|
|
17
|
+
messageId: string;
|
|
18
|
+
text: string;
|
|
19
|
+
automatic: boolean;
|
|
20
|
+
lease: string;
|
|
21
|
+
}
|
|
22
|
+
export type DeliveryStatus = 'awaiting-receipt' | 'unknown' | 'blocked';
|
|
23
|
+
export interface DeliveryDependencies {
|
|
24
|
+
read(workspaceId: string, contactId: string): Promise<DeliverySource>;
|
|
25
|
+
claim(key: string, input: DeliveryInput): Promise<boolean>;
|
|
26
|
+
settle(key: string, status: DeliveryStatus): Promise<void>;
|
|
27
|
+
send(input: DeliveryInput & {
|
|
28
|
+
source: DeliverySource;
|
|
29
|
+
}, check: () => Promise<void>, signal: AbortSignal): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/** One Host-wide desktop queue. A lease binds UI presence, selected chat and opt-in;
|
|
32
|
+
* the durable inbound claim survives restarts even when UI mode resets to off. */
|
|
33
|
+
export declare class DeliveryCoordinator {
|
|
34
|
+
private active?;
|
|
35
|
+
private queue;
|
|
36
|
+
private inFlight;
|
|
37
|
+
pending(workspaceId: string, contactId: string): boolean;
|
|
38
|
+
private readonly deps;
|
|
39
|
+
constructor(deps: DeliveryDependencies);
|
|
40
|
+
open(workspaceId: string, contactId: string, enabled: boolean): Promise<`${string}-${string}-${string}-${string}-${string}`>;
|
|
41
|
+
dispose(): Promise<void>;
|
|
42
|
+
touch(lease: string): void;
|
|
43
|
+
close(lease?: string): void;
|
|
44
|
+
send(input: DeliveryInput, now?: number): Promise<{
|
|
45
|
+
status: 'awaiting-receipt';
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CustomerIntent } from '../customer-intent.ts';
|
|
2
|
+
import type { IntentInput, IntentJob } from '../server/intent-evaluation.ts';
|
|
3
|
+
export type IntentEvaluator = (workspace: string, input: IntentInput, signal: AbortSignal) => Promise<CustomerIntent>;
|
|
4
|
+
interface Queue {
|
|
5
|
+
next(workspace: string): Promise<IntentJob | undefined>;
|
|
6
|
+
read(workspace: string, job: IntentJob): Promise<IntentInput | undefined>;
|
|
7
|
+
finish(workspace: string, id: string, result: CustomerIntent): Promise<boolean>;
|
|
8
|
+
}
|
|
9
|
+
export declare class IntentScheduler {
|
|
10
|
+
private readonly workspaces;
|
|
11
|
+
private timer?;
|
|
12
|
+
private task?;
|
|
13
|
+
private suspended;
|
|
14
|
+
private closed;
|
|
15
|
+
private cancellation?;
|
|
16
|
+
private readonly queue;
|
|
17
|
+
private readonly evaluate;
|
|
18
|
+
constructor(queue: Queue, evaluate: IntentEvaluator);
|
|
19
|
+
wake(workspace: string): void;
|
|
20
|
+
private schedule;
|
|
21
|
+
private run;
|
|
22
|
+
suspend(): Promise<void>;
|
|
23
|
+
resume(): void;
|
|
24
|
+
close(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|