@wanji_dsh/dsh-sales 0.10.0 → 0.10.2

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.
Files changed (138) hide show
  1. package/.dsh/skills/wanji-sales-assistant/SKILL.md +28 -3
  2. package/.dsh/skills/wanji-sales-assistant/references/draft-review.md +2 -2
  3. package/.dsh/skills/wanji-sales-assistant/references/wechat-delivery.md +24 -0
  4. package/README.md +24 -4
  5. package/README.zh.md +51 -4
  6. package/dist/client.js +9632 -664
  7. package/dist/host.js +3200 -958
  8. package/dist/types/{agent-evaluators.d.ts → agent-evaluators-v2.d.ts} +17 -3
  9. package/dist/types/agent-knowledge.d.ts +11 -2
  10. package/dist/types/agent.d.ts +21 -8
  11. package/dist/types/commercial-boundary.d.ts +7 -0
  12. package/dist/types/customer-intent.d.ts +49 -0
  13. package/dist/types/customer-materials.d.ts +49 -0
  14. package/dist/types/dialogue-tasks.d.ts +10 -0
  15. package/dist/types/draft-edits.d.ts +7 -0
  16. package/dist/types/evaluation-client.d.ts +2 -6
  17. package/dist/types/fact-proof.d.ts +2 -1
  18. package/dist/types/generation-progress.d.ts +32 -0
  19. package/dist/types/generation-runtime.d.ts +17 -0
  20. package/dist/types/generation-session-route.d.ts +5 -0
  21. package/dist/types/generation-sessions.d.ts +36 -0
  22. package/dist/types/host.d.ts +15 -0
  23. package/dist/types/knowledge-host.d.ts +22 -3
  24. package/dist/types/knowledge-judgment-delivery.d.ts +2 -0
  25. package/dist/types/knowledge-judgments.d.ts +12 -0
  26. package/dist/types/knowledge-privacy.d.ts +2 -0
  27. package/dist/types/knowledge-turns.d.ts +22 -0
  28. package/dist/types/langfuse-config.d.ts +1 -0
  29. package/dist/types/langfuse-outbox.d.ts +10 -2
  30. package/dist/types/material-catalog.d.ts +17 -0
  31. package/dist/types/material-metadata.d.ts +4 -0
  32. package/dist/types/material-reply.d.ts +24 -0
  33. package/dist/types/material-request.d.ts +45 -0
  34. package/dist/types/material-retrieval.d.ts +29 -0
  35. package/dist/types/model.d.ts +23 -2
  36. package/dist/types/open-generation.d.ts +5 -2
  37. package/dist/types/open-review.d.ts +39 -15
  38. package/dist/types/operation-evidence.d.ts +7 -0
  39. package/dist/types/percentage-quote.d.ts +6 -0
  40. package/dist/types/plan-projection.d.ts +2 -0
  41. package/dist/types/product-evidence.d.ts +4 -0
  42. package/dist/types/question-relay.d.ts +24 -0
  43. package/dist/types/question-route.d.ts +4 -0
  44. package/dist/types/question-tracing.d.ts +84 -0
  45. package/dist/types/quote-context.d.ts +9 -5
  46. package/dist/types/response-contract.d.ts +10 -0
  47. package/dist/types/retrieval-queries.d.ts +4 -0
  48. package/dist/types/review-turn.d.ts +6 -0
  49. package/dist/types/sales-context-types.d.ts +15 -0
  50. package/dist/types/semantic-rerank.d.ts +9 -0
  51. package/dist/types/sending-policy.d.ts +2 -0
  52. package/dist/types/server/intent-evaluation.d.ts +27 -0
  53. package/dist/types/server/intent-host.d.ts +17 -0
  54. package/dist/types/stream-preview.d.ts +11 -0
  55. package/dist/types/turn-packet.d.ts +21 -8
  56. package/dist/types/turn-plan.d.ts +19 -7
  57. package/dist/types/update/activity.d.ts +1 -1
  58. package/dist/types/verified-arithmetic.d.ts +5 -0
  59. package/dist/types/voice-examples.d.ts +1 -0
  60. package/dist/types/wechat/cua-approval.d.ts +36 -0
  61. package/dist/types/wechat/cua-sender.d.ts +160 -0
  62. package/dist/types/wechat/cua-vision.d.ts +31 -0
  63. package/dist/types/wechat/delivery.d.ts +47 -0
  64. package/dist/types/wechat/intent-scheduler.d.ts +26 -0
  65. package/dist/types/wechat/repository-client.d.ts +1 -1
  66. package/dist/types/wechat/routes.d.ts +9 -7
  67. package/dist/types/wechat/service.d.ts +8 -3
  68. package/dist/types/wechat/types.d.ts +5 -0
  69. package/dist/types/wechat-draft-input.d.ts +3 -0
  70. package/dist/types/wechat-voice.d.ts +3 -0
  71. package/dist/types/weknora-http.d.ts +8 -0
  72. package/dist/wechat-repository-worker.js +248 -22
  73. package/docs/agent-knowledge-observation.md +58 -0
  74. package/docs/customer-material-retrieval.md +48 -0
  75. package/docs/licenses/ccount@2.0.1.txt +24 -0
  76. package/docs/licenses/character-entities@2.0.2.txt +24 -0
  77. package/docs/licenses/debug@4.4.3.txt +21 -0
  78. package/docs/licenses/decode-named-character-reference@1.3.0.txt +24 -0
  79. package/docs/licenses/dequal@2.0.3.txt +23 -0
  80. package/docs/licenses/devlop@1.1.0.txt +24 -0
  81. package/docs/licenses/escape-string-regexp@5.0.0.txt +11 -0
  82. package/docs/licenses/longest-streak@3.1.0.txt +24 -0
  83. package/docs/licenses/markdown-table@3.1.0.txt +24 -0
  84. package/docs/licenses/mdast-util-find-and-replace@3.0.4.txt +24 -0
  85. package/docs/licenses/mdast-util-from-markdown@2.0.3.txt +24 -0
  86. package/docs/licenses/mdast-util-gfm-autolink-literal@2.1.0.txt +24 -0
  87. package/docs/licenses/mdast-util-gfm-footnote@2.1.0.txt +24 -0
  88. package/docs/licenses/mdast-util-gfm-strikethrough@2.0.1.txt +24 -0
  89. package/docs/licenses/mdast-util-gfm-table@2.0.1.txt +24 -0
  90. package/docs/licenses/mdast-util-gfm-task-list-item@2.0.1.txt +24 -0
  91. package/docs/licenses/mdast-util-gfm@3.0.0.txt +24 -0
  92. package/docs/licenses/mdast-util-phrasing@4.1.0.txt +25 -0
  93. package/docs/licenses/mdast-util-to-markdown@2.2.3.txt +24 -0
  94. package/docs/licenses/mdast-util-to-string@4.0.0.txt +24 -0
  95. package/docs/licenses/micromark-core-commonmark@2.0.4.txt +24 -0
  96. package/docs/licenses/micromark-extension-gfm-autolink-literal@2.1.0.txt +24 -0
  97. package/docs/licenses/micromark-extension-gfm-footnote@2.1.0.txt +24 -0
  98. package/docs/licenses/micromark-extension-gfm-strikethrough@2.1.0.txt +24 -0
  99. package/docs/licenses/micromark-extension-gfm-table@2.1.2.txt +24 -0
  100. package/docs/licenses/micromark-extension-gfm-tagfilter@2.0.0.txt +24 -0
  101. package/docs/licenses/micromark-extension-gfm-task-list-item@2.1.0.txt +24 -0
  102. package/docs/licenses/micromark-extension-gfm@3.0.0.txt +24 -0
  103. package/docs/licenses/micromark-factory-destination@2.0.1.txt +24 -0
  104. package/docs/licenses/micromark-factory-label@2.0.1.txt +24 -0
  105. package/docs/licenses/micromark-factory-space@2.1.0.txt +24 -0
  106. package/docs/licenses/micromark-factory-title@2.0.1.txt +24 -0
  107. package/docs/licenses/micromark-factory-whitespace@2.0.1.txt +24 -0
  108. package/docs/licenses/micromark-util-character@2.1.1.txt +24 -0
  109. package/docs/licenses/micromark-util-chunked@2.0.1.txt +24 -0
  110. package/docs/licenses/micromark-util-classify-character@2.0.1.txt +24 -0
  111. package/docs/licenses/micromark-util-combine-extensions@2.0.1.txt +24 -0
  112. package/docs/licenses/micromark-util-decode-numeric-character-reference@2.0.2.txt +24 -0
  113. package/docs/licenses/micromark-util-decode-string@2.0.1.txt +24 -0
  114. package/docs/licenses/micromark-util-edit-map@1.0.0.txt +24 -0
  115. package/docs/licenses/micromark-util-encode@2.0.1.txt +24 -0
  116. package/docs/licenses/micromark-util-html-tag-name@2.0.1.txt +24 -0
  117. package/docs/licenses/micromark-util-normalize-identifier@2.0.1.txt +24 -0
  118. package/docs/licenses/micromark-util-resolve-all@2.0.1.txt +24 -0
  119. package/docs/licenses/micromark-util-sanitize-uri@2.0.1.txt +24 -0
  120. package/docs/licenses/micromark-util-subtokenize@2.1.0.txt +24 -0
  121. package/docs/licenses/micromark-util-symbol@2.0.1.txt +24 -0
  122. package/docs/licenses/micromark-util-types@2.0.3.txt +24 -0
  123. package/docs/licenses/micromark@4.0.3.txt +24 -0
  124. package/docs/licenses/ms@2.1.3.txt +23 -0
  125. package/docs/licenses/unist-util-is@6.0.1.txt +24 -0
  126. package/docs/licenses/unist-util-stringify-position@4.0.0.txt +24 -0
  127. package/docs/licenses/unist-util-visit-parents@6.1.0.txt +24 -0
  128. package/docs/licenses/unist-util-visit@5.2.0.txt +24 -0
  129. package/docs/licenses/zwitch@2.0.4.txt +24 -0
  130. package/docs/sales-agent-evaluation-v2.md +102 -0
  131. package/docs/wechat-sync.md +23 -0
  132. package/package.json +20 -7
  133. package/runtime/customer-materials.json +1935 -0
  134. package/runtime/documented-operation-references.json +123 -0
  135. package/runtime/operation-references.json +352 -0
  136. package/runtime/product-references.json +10 -0
  137. package/runtime/wechat-manifest.json +1 -1
  138. 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
- decisions: {
177
+ pending?: PendingCompanyTask[];
178
+ decisions: (BoundItem & {
179
+ topic: string;
180
+ meaning: string;
181
+ } & {
170
182
  source_id: string;
171
- quote: string;
172
- }[];
173
- artifacts: {
183
+ })[];
184
+ artifacts: (BoundItem & {
185
+ kind: "sample" | "intro" | "confirmation";
186
+ status: "requested" | "received" | "reviewed";
187
+ } & {
174
188
  source_id: string;
175
- quote: string;
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
- decisions: {
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
- quote: string;
148
- }[];
149
- artifacts: {
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
- quote: string;
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;
@@ -4,7 +4,7 @@ export declare class UpdateActivity {
4
4
  private scope;
5
5
  private pending;
6
6
  private draining;
7
- run<T>(work: () => Promise<T>): Promise<T>;
7
+ run<T>(work: () => Promise<T>, continuation?: boolean): Promise<T>;
8
8
  prepare(signal: AbortSignal): Promise<() => void>;
9
9
  }
10
10
  export interface ClientReadiness {
@@ -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 {};
@@ -1,4 +1,4 @@
1
- type Method = 'importBatch' | 'listContacts' | 'getContact' | 'listMessages' | 'getMedia' | 'bindCrm' | 'getState' | 'saveState' | 'markHandled' | 'getPairing';
1
+ type Method = 'importBatch' | 'listContacts' | 'getContact' | 'listMessages' | 'getMedia' | 'getDraftVoice' | 'bindCrm' | 'getState' | 'saveState' | 'markHandled' | 'getPairing' | 'getDeliverySource' | 'claimDelivery' | 'settleDelivery' | 'deliveryStatus' | 'queueIntent' | 'seedIntents' | 'nextIntent' | 'getIntentInput' | 'finishIntent';
2
2
  /** SQLite imports execute off the Host event loop so leases/control events remain responsive. */
3
3
  export declare class RepositoryClient {
4
4
  private worker;
@@ -1,9 +1,11 @@
1
+ import type { DshWechatSender } from './cua-sender.ts';
1
2
  import type { HostContext } from '../knowledge-host.ts';
2
- import { WechatSyncService } from './service.ts';
3
- import type { WechatRuntime } from './runtime.ts';
3
+ import { WechatSyncService, type WechatSyncOptions } from './service.ts';
4
4
  /** Shared Harness Fetch routes already restrict access to authenticated owner peers. */
5
- export declare function registerWechatRoutes(ctx: HostContext, options: {
6
- storageDir: string;
7
- componentRoot: string;
8
- runtime?: WechatRuntime;
9
- }, injected?: WechatSyncService): WechatSyncService;
5
+ export declare function registerWechatRoutes(ctx: HostContext, options: WechatSyncOptions & {
6
+ sendingEnabled?: boolean;
7
+ transcribeVoice?: (audio: Uint8Array, signal: AbortSignal) => Promise<string | undefined>;
8
+ }, injected?: WechatSyncService, desktop?: {
9
+ available(): boolean;
10
+ sender: DshWechatSender;
11
+ }): WechatSyncService;
@@ -4,8 +4,10 @@ import { SourceWatcher } from './watcher.ts';
4
4
  import { type NativeBackend } from './native.ts';
5
5
  import type { SyncCapabilities, SyncStatus } from './types.ts';
6
6
  import type { WechatRuntime } from './runtime.ts';
7
+ import { type IntentEvaluator } from './intent-scheduler.ts';
7
8
  import type { ResumeIntent } from '../update/types.ts';
8
- type Options = {
9
+ export type WechatSyncOptions = {
10
+ intentEvaluator?: IntentEvaluator;
9
11
  storageDir: string;
10
12
  componentRoot: string;
11
13
  runtime?: WechatRuntime;
@@ -27,6 +29,8 @@ export declare class WechatSyncService {
27
29
  private dirty;
28
30
  private failures;
29
31
  private interval;
32
+ private intent?;
33
+ private initialImport;
30
34
  private closed;
31
35
  private updatePreparing;
32
36
  private capabilitiesAt;
@@ -36,7 +40,7 @@ export declare class WechatSyncService {
36
40
  private committedRequest?;
37
41
  private mediaCommittedRequest?;
38
42
  private state;
39
- constructor(options: Options);
43
+ constructor(options: WechatSyncOptions);
40
44
  private newNative;
41
45
  capabilities(): Promise<SyncCapabilities>;
42
46
  status(workspace: string): SyncStatus;
@@ -46,6 +50,8 @@ export declare class WechatSyncService {
46
50
  private progress;
47
51
  private repo;
48
52
  data<T = any>(method: Parameters<RepositoryClient['call']>[0], workspace: string, ...args: any[]): Promise<T>;
53
+ openIntent(workspace: string, id: string): Promise<void>;
54
+ private seedIntents;
49
55
  start(workspace: string, automatic?: boolean): Promise<SyncStatus>;
50
56
  sourceChanged(): void;
51
57
  private schedule;
@@ -56,4 +62,3 @@ export declare class WechatSyncService {
56
62
  authorize(workspace: string, requestId: string, approved: boolean): SyncStatus;
57
63
  close(): Promise<void>;
58
64
  }
59
- export {};
@@ -1,3 +1,4 @@
1
+ import type { SalesReply } from '../agent.ts';
1
2
  import type { Contact } from '../model.ts';
2
3
  import type { SalesIncrementalEnvelope } from './batch.ts';
3
4
  export declare const WECHAT_METHOD = "wanji-sales-wechat/request";
@@ -27,6 +28,10 @@ export interface StoredMessage {
27
28
  senderId?: string;
28
29
  }
29
30
  export interface SavedWechatState {
31
+ autoDraftedMessageId?: string;
32
+ autoDraftSuggestion?: Pick<SalesReply, 'judgment' | 'wechat' | 'next_step' | 'no_send'>;
33
+ generationError?: string;
34
+ generationNoReply?: true;
30
35
  draft?: string;
31
36
  draftKind?: 'edited' | 'agent' | 'empty';
32
37
  progress?: Contact['progress'];
@@ -0,0 +1,3 @@
1
+ import type { Contact } from './model.ts';
2
+ export declare function attachmentReply(kind: string): string | undefined;
3
+ export declare function canDraftWechat(contact: Contact): boolean;
@@ -0,0 +1,3 @@
1
+ /** Shared by planning, writing, editing and conversation review; never a fact authority. */
2
+ export { voiceExamplePrompt } from './voice-examples.ts';
3
+ export declare const wechatVoice: string;
@@ -0,0 +1,8 @@
1
+ export interface WeKnoraConnection {
2
+ baseUrl: string;
3
+ apiKey: string;
4
+ tenantId?: string;
5
+ }
6
+ /** Connection values are accepted only from the Host's installation config. */
7
+ export declare function resolveWeKnoraConnection(raw: unknown, label: string): WeKnoraConnection | undefined;
8
+ export declare function readWeKnoraData(response: Response): Promise<Record<string, unknown>>;