weacpx 0.6.1 → 0.8.0
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 +10 -564
- package/package.json +10 -72
- package/plugin-api.d.ts +2 -0
- package/plugin-api.js +5 -0
- package/LICENSE +0 -21
- package/config.example.json +0 -44
- package/dist/bridge/bridge-main.js +0 -2120
- package/dist/channels/channel-scope.d.ts +0 -17
- package/dist/channels/cli/provider.d.ts +0 -73
- package/dist/channels/cli/registry.d.ts +0 -7
- package/dist/channels/cli/weixin-provider.d.ts +0 -2
- package/dist/channels/create-channel.d.ts +0 -16
- package/dist/channels/media-store.d.ts +0 -29
- package/dist/channels/media-types.d.ts +0 -28
- package/dist/channels/outbound-media-safety.d.ts +0 -7
- package/dist/channels/plugin.d.ts +0 -9
- package/dist/channels/types.d.ts +0 -115
- package/dist/channels/weixin-channel.d.ts +0 -25
- package/dist/cli.js +0 -46971
- package/dist/commands/command-hints.d.ts +0 -11
- package/dist/commands/command-list.d.ts +0 -3
- package/dist/commands/config-clone.d.ts +0 -2
- package/dist/commands/handlers/agent-handler.d.ts +0 -6
- package/dist/commands/handlers/config-handler.d.ts +0 -5
- package/dist/commands/handlers/later-handler.d.ts +0 -21
- package/dist/commands/handlers/orchestration-handler.d.ts +0 -16
- package/dist/commands/handlers/permission-handler.d.ts +0 -9
- package/dist/commands/handlers/session-handler.d.ts +0 -37
- package/dist/commands/handlers/workspace-handler.d.ts +0 -8
- package/dist/commands/help/help-registry.d.ts +0 -4
- package/dist/commands/help/help-types.d.ts +0 -12
- package/dist/commands/parse-command.d.ts +0 -175
- package/dist/commands/router-types.d.ts +0 -144
- package/dist/commands/workspace-name.d.ts +0 -4
- package/dist/commands/workspace-path.d.ts +0 -4
- package/dist/config/agent-templates.d.ts +0 -4
- package/dist/config/config-store.d.ts +0 -13
- package/dist/config/load-config.d.ts +0 -10
- package/dist/config/resolve-agent-command.d.ts +0 -2
- package/dist/config/types.d.ts +0 -85
- package/dist/formatting/render-text.d.ts +0 -23
- package/dist/logging/app-logger.d.ts +0 -23
- package/dist/logging/rotating-file-writer.d.ts +0 -2
- package/dist/orchestration/async-mutex.d.ts +0 -4
- package/dist/orchestration/build-coordinator-prompt.d.ts +0 -66
- package/dist/orchestration/orchestration-service.d.ts +0 -471
- package/dist/orchestration/orchestration-types.d.ts +0 -181
- package/dist/orchestration/progress-line-parser.d.ts +0 -19
- package/dist/orchestration/render-delegate-group-result.d.ts +0 -6
- package/dist/orchestration/render-delegate-question-package.d.ts +0 -21
- package/dist/orchestration/render-delegate-result.d.ts +0 -2
- package/dist/orchestration/task-watch-timeouts.d.ts +0 -5
- package/dist/perf/perf-log-writer.d.ts +0 -25
- package/dist/perf/perf-tracer.d.ts +0 -54
- package/dist/plugin-api.d.ts +0 -9
- package/dist/plugin-api.js +0 -180
- package/dist/plugins/compatibility.d.ts +0 -16
- package/dist/plugins/known-plugins.d.ts +0 -9
- package/dist/plugins/types.d.ts +0 -18
- package/dist/scheduled/parse-later-time.d.ts +0 -11
- package/dist/scheduled/scheduled-render.d.ts +0 -7
- package/dist/scheduled/scheduled-service.d.ts +0 -41
- package/dist/scheduled/scheduled-types.d.ts +0 -29
- package/dist/sessions/session-service.d.ts +0 -83
- package/dist/state/state-store.d.ts +0 -8
- package/dist/state/types.d.ts +0 -44
- package/dist/transport/tool-event-mode.d.ts +0 -14
- package/dist/transport/types.d.ts +0 -129
- package/dist/util/path.d.ts +0 -4
- package/dist/util/private-file.d.ts +0 -26
- package/dist/util/sanitize.d.ts +0 -10
- package/dist/util/text.d.ts +0 -3
- package/dist/version.d.ts +0 -3
- package/dist/weixin/agent/interface.d.ts +0 -78
- package/dist/weixin/api/api.d.ts +0 -76
- package/dist/weixin/api/config-cache.d.ts +0 -18
- package/dist/weixin/api/session-guard.d.ts +0 -17
- package/dist/weixin/api/types.d.ts +0 -203
- package/dist/weixin/auth/accounts.d.ts +0 -69
- package/dist/weixin/auth/login-qr.d.ts +0 -37
- package/dist/weixin/bot.d.ts +0 -56
- package/dist/weixin/cdn/aes-ecb.d.ts +0 -6
- package/dist/weixin/cdn/cdn-upload.d.ts +0 -17
- package/dist/weixin/cdn/cdn-url.d.ts +0 -11
- package/dist/weixin/cdn/pic-decrypt.d.ts +0 -9
- package/dist/weixin/cdn/upload.d.ts +0 -42
- package/dist/weixin/index.d.ts +0 -6
- package/dist/weixin/media/media-download.d.ts +0 -18
- package/dist/weixin/media/mime.d.ts +0 -6
- package/dist/weixin/media/silk-transcode.d.ts +0 -8
- package/dist/weixin/messaging/conversation-executor.d.ts +0 -7
- package/dist/weixin/messaging/debug-mode.d.ts +0 -9
- package/dist/weixin/messaging/deliver-coordinator-message.d.ts +0 -22
- package/dist/weixin/messaging/deliver-orchestration-task-notice.d.ts +0 -18
- package/dist/weixin/messaging/deliver-orchestration-task-progress.d.ts +0 -16
- package/dist/weixin/messaging/error-notice.d.ts +0 -13
- package/dist/weixin/messaging/execute-chat-turn.d.ts +0 -12
- package/dist/weixin/messaging/final-heads-up.d.ts +0 -5
- package/dist/weixin/messaging/handle-weixin-message-turn.d.ts +0 -32
- package/dist/weixin/messaging/inbound.d.ts +0 -80
- package/dist/weixin/messaging/markdown-filter.d.ts +0 -45
- package/dist/weixin/messaging/orchestration-notice-accounts.d.ts +0 -2
- package/dist/weixin/messaging/quota-errors.d.ts +0 -8
- package/dist/weixin/messaging/quota-manager.d.ts +0 -44
- package/dist/weixin/messaging/scheduled-turn.d.ts +0 -22
- package/dist/weixin/messaging/send-errors.d.ts +0 -39
- package/dist/weixin/messaging/send-media.d.ts +0 -23
- package/dist/weixin/messaging/send-orchestration-notice.d.ts +0 -10
- package/dist/weixin/messaging/send.d.ts +0 -73
- package/dist/weixin/messaging/slash-commands.d.ts +0 -40
- package/dist/weixin/monitor/consumer-lock.d.ts +0 -24
- package/dist/weixin/monitor/monitor.d.ts +0 -30
- package/dist/weixin/storage/ensure-dir.d.ts +0 -1
- package/dist/weixin/storage/state-dir.d.ts +0 -2
- package/dist/weixin/storage/sync-buf.d.ts +0 -20
- package/dist/weixin/util/logger.d.ts +0 -14
- package/dist/weixin/util/random.d.ts +0 -10
- package/dist/weixin/util/redact.d.ts +0 -21
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { ChannelMediaKind } from "../../channels/media-types.js";
|
|
2
|
-
import type { WeixinMessage, MessageItem } from "../api/types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Restore the per-account context-token cache from disk into memory.
|
|
5
|
-
* Called at bot startup (after login). Missing/unreadable files are tolerated
|
|
6
|
-
* silently; corrupt JSON is logged at warn level and ignored.
|
|
7
|
-
*/
|
|
8
|
-
export declare function restoreContextTokens(accountId: string): void;
|
|
9
|
-
/**
|
|
10
|
-
* Drop all tokens for an account from both the in-memory cache and disk.
|
|
11
|
-
* Called on logout so the next login does not see stale associations.
|
|
12
|
-
*/
|
|
13
|
-
export declare function clearContextTokensForAccount(accountId: string): void;
|
|
14
|
-
/** Store a context token for a given account+user pair (memory + disk). */
|
|
15
|
-
export declare function setContextToken(accountId: string, userId: string, token: string): void;
|
|
16
|
-
/** Retrieve the cached context token for a given account+user pair. */
|
|
17
|
-
export declare function getContextToken(accountId: string, userId: string): string | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Of the given candidate accountIds, return those that have an active
|
|
20
|
-
* context-token cached for the given user. `userId` may be a raw user id
|
|
21
|
-
* or a `weixin:<accountId>:<userId>` chat-key — both forms resolve.
|
|
22
|
-
*/
|
|
23
|
-
export declare function findAccountIdsByContextToken(accountIds: string[], userId: string): string[];
|
|
24
|
-
/** Strip the `weixin:accountId:` prefix from a chat key, returning the bare user id. */
|
|
25
|
-
export declare function normalizeWeixinUserIdFromChatKey(chatKey: string): string;
|
|
26
|
-
/** Inbound context passed to the OpenClaw core pipeline (matches MsgContext shape). */
|
|
27
|
-
export type WeixinMsgContext = {
|
|
28
|
-
Body: string;
|
|
29
|
-
From: string;
|
|
30
|
-
To: string;
|
|
31
|
-
AccountId: string;
|
|
32
|
-
OriginatingChannel: "openclaw-weixin";
|
|
33
|
-
OriginatingTo: string;
|
|
34
|
-
MessageSid: string;
|
|
35
|
-
Timestamp?: number;
|
|
36
|
-
Provider: "openclaw-weixin";
|
|
37
|
-
ChatType: "direct";
|
|
38
|
-
/** Set by monitor after resolveAgentRoute so dispatchReplyFromConfig uses the correct session. */
|
|
39
|
-
SessionKey?: string;
|
|
40
|
-
context_token?: string;
|
|
41
|
-
MediaUrl?: string;
|
|
42
|
-
MediaPath?: string;
|
|
43
|
-
MediaType?: string;
|
|
44
|
-
/** Raw message body for framework command authorization. */
|
|
45
|
-
CommandBody?: string;
|
|
46
|
-
/** Whether the sender is authorized to execute slash commands. */
|
|
47
|
-
CommandAuthorized?: boolean;
|
|
48
|
-
};
|
|
49
|
-
/** Returns true if the message item is a media type (image, video, file, or voice). */
|
|
50
|
-
export declare function isMediaItem(item: MessageItem): boolean;
|
|
51
|
-
export declare function bodyFromItemList(itemList?: MessageItem[]): string;
|
|
52
|
-
export type WeixinInboundMediaOpts = {
|
|
53
|
-
/** Local path to decrypted image file. */
|
|
54
|
-
decryptedPicPath?: string;
|
|
55
|
-
/** Local path to transcoded/raw voice file (.wav or .silk). */
|
|
56
|
-
decryptedVoicePath?: string;
|
|
57
|
-
/** MIME type for the voice file (e.g. "audio/wav" or "audio/silk"). */
|
|
58
|
-
voiceMediaType?: string;
|
|
59
|
-
/** Local path to decrypted file attachment. */
|
|
60
|
-
decryptedFilePath?: string;
|
|
61
|
-
/** MIME type for the file attachment (guessed from file_name). */
|
|
62
|
-
fileMediaType?: string;
|
|
63
|
-
/** Local path to decrypted video file. */
|
|
64
|
-
decryptedVideoPath?: string;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Convert a WeixinMessage from getUpdates to the inbound MsgContext for the core pipeline.
|
|
68
|
-
* Media: only pass MediaPath (local file, after CDN download + decrypt).
|
|
69
|
-
* We never pass MediaUrl — the upstream CDN URL is encrypted/auth-only.
|
|
70
|
-
* Priority when multiple media types present: image > video > file > voice.
|
|
71
|
-
*/
|
|
72
|
-
export declare function weixinMessageToMsgContext(msg: WeixinMessage, accountId: string, opts?: WeixinInboundMediaOpts): WeixinMsgContext;
|
|
73
|
-
/** Extract the context_token from an inbound WeixinMsgContext. */
|
|
74
|
-
export declare function getContextTokenFromMsgContext(ctx: WeixinMsgContext): string | undefined;
|
|
75
|
-
export interface WeixinInboundMediaDescriptor {
|
|
76
|
-
item: MessageItem;
|
|
77
|
-
kind: ChannelMediaKind;
|
|
78
|
-
fileName?: string;
|
|
79
|
-
}
|
|
80
|
-
export declare function extractWeixinMediaDescriptors(itemList?: MessageItem[]): WeixinInboundMediaDescriptor[];
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Streaming markdown filter — character-level state machine that strips
|
|
3
|
-
* unsupported markdown syntax on-the-fly.
|
|
4
|
-
*
|
|
5
|
-
* Outputs as much filtered text as possible on each `feed()` call, only
|
|
6
|
-
* holding back the minimum characters needed for pattern disambiguation
|
|
7
|
-
* (e.g. a trailing `*` that might become `***`).
|
|
8
|
-
*
|
|
9
|
-
* Constructs passed through (not filtered):
|
|
10
|
-
* - Code fences (```)
|
|
11
|
-
* - Inline code (`)
|
|
12
|
-
* - Tables (|...|)
|
|
13
|
-
* - Horizontal rules (---, ***, ___)
|
|
14
|
-
* - Bold (**)
|
|
15
|
-
* - Italic/bold-italic wrapping non-CJK content
|
|
16
|
-
*
|
|
17
|
-
* Constructs filtered (markers stripped, content kept):
|
|
18
|
-
* - Italic/bold-italic wrapping CJK content
|
|
19
|
-
* - Headings H5/H6 (#####, ######)
|
|
20
|
-
* - Images () — removed entirely
|
|
21
|
-
*
|
|
22
|
-
* States:
|
|
23
|
-
* - **sol** (start-of-line): checks for line-start patterns (```, >, #####, indent)
|
|
24
|
-
* - **body**: scans for inline patterns (![, ~~, ***) and outputs safe chars
|
|
25
|
-
* - **fence**: inside a fenced code block, passes through until closing ```
|
|
26
|
-
* - **inline**: accumulating content inside an inline marker pair
|
|
27
|
-
*/
|
|
28
|
-
export declare class StreamingMarkdownFilter {
|
|
29
|
-
private buf;
|
|
30
|
-
private fence;
|
|
31
|
-
private sol;
|
|
32
|
-
private inl;
|
|
33
|
-
feed(delta: string): string;
|
|
34
|
-
flush(): string;
|
|
35
|
-
private pump;
|
|
36
|
-
/** Inside a code fence: pass content and markers through verbatim. */
|
|
37
|
-
private pumpFence;
|
|
38
|
-
/** At start of line: detect and consume line-start patterns, then transition to body. */
|
|
39
|
-
private pumpSOL;
|
|
40
|
-
/** Scan line body for inline pattern triggers; output safe chars eagerly. */
|
|
41
|
-
private pumpBody;
|
|
42
|
-
/** Accumulate inline content until closing marker is found. */
|
|
43
|
-
private pumpInline;
|
|
44
|
-
private static containsCJK;
|
|
45
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export declare const MID_BUDGET = 6;
|
|
2
|
-
export declare const FINAL_BUDGET = 4;
|
|
3
|
-
export interface PendingFinalChunk {
|
|
4
|
-
/** Pre-formatted body, already carrying the (k/N) pagination prefix. */
|
|
5
|
-
text: string;
|
|
6
|
-
/** 1-based chunk index. */
|
|
7
|
-
seq: number;
|
|
8
|
-
/** Total chunk count for this final answer. */
|
|
9
|
-
total: number;
|
|
10
|
-
contextToken?: string;
|
|
11
|
-
accountId?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface QuotaSnapshot {
|
|
14
|
-
remaining: number;
|
|
15
|
-
midUsed: number;
|
|
16
|
-
finalUsed: number;
|
|
17
|
-
midRemaining: number;
|
|
18
|
-
finalRemaining: number;
|
|
19
|
-
}
|
|
20
|
-
export interface QuotaObserver {
|
|
21
|
-
onInbound?(chatKey: string): void;
|
|
22
|
-
onMidReserved?(chatKey: string, snapshot: QuotaSnapshot): void;
|
|
23
|
-
onMidRejected?(chatKey: string, snapshot: QuotaSnapshot): void;
|
|
24
|
-
onFinalReserved?(chatKey: string, snapshot: QuotaSnapshot): void;
|
|
25
|
-
onFinalRejected?(chatKey: string, snapshot: QuotaSnapshot): void;
|
|
26
|
-
}
|
|
27
|
-
export declare class QuotaManager {
|
|
28
|
-
private readonly states;
|
|
29
|
-
private readonly observer;
|
|
30
|
-
private readonly normalizeKey;
|
|
31
|
-
constructor(observer?: QuotaObserver, normalizeKey?: (key: string) => string);
|
|
32
|
-
onInbound(chatKey: string): void;
|
|
33
|
-
reserveMidSegment(chatKey: string): boolean;
|
|
34
|
-
reserveFinal(chatKey: string): boolean;
|
|
35
|
-
finalRemaining(chatKey: string): number;
|
|
36
|
-
enqueuePendingFinal(chatKey: string, chunks: PendingFinalChunk[]): void;
|
|
37
|
-
prependPendingFinal(chatKey: string, chunks: PendingFinalChunk[]): void;
|
|
38
|
-
drainPendingFinalUpToBudget(chatKey: string, available: number): PendingFinalChunk[];
|
|
39
|
-
hasPendingFinal(chatKey: string): boolean;
|
|
40
|
-
countPendingFinal(chatKey: string): number;
|
|
41
|
-
clearPendingFinal(chatKey: string): void;
|
|
42
|
-
snapshot(chatKey: string): QuotaSnapshot;
|
|
43
|
-
private getOrCreate;
|
|
44
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { AppLogger } from "../../logging/app-logger";
|
|
2
|
-
import type { ScheduledChannelMessageInput } from "../../channels/types";
|
|
3
|
-
import type { Agent } from "../agent/interface";
|
|
4
|
-
import type { PendingFinalChunk } from "./quota-manager";
|
|
5
|
-
import { sendMessageWeixin } from "./send";
|
|
6
|
-
export interface ScheduledTurnDeps {
|
|
7
|
-
agent: Agent;
|
|
8
|
-
listAccountIds: () => string[];
|
|
9
|
-
resolveAccount: (accountId: string) => {
|
|
10
|
-
accountId: string;
|
|
11
|
-
baseUrl: string;
|
|
12
|
-
token?: string;
|
|
13
|
-
};
|
|
14
|
-
getContextToken: (accountId: string, userId: string) => string | undefined;
|
|
15
|
-
reserveMidSegment: (chatKey: string) => boolean;
|
|
16
|
-
reserveFinal: (chatKey: string) => boolean;
|
|
17
|
-
finalRemaining?: (chatKey: string) => number;
|
|
18
|
-
enqueuePendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
|
|
19
|
-
sendMessage?: typeof sendMessageWeixin;
|
|
20
|
-
logger: AppLogger;
|
|
21
|
-
}
|
|
22
|
-
export declare function executeScheduledTurn(input: ScheduledChannelMessageInput, deps: ScheduledTurnDeps): Promise<void>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured error type for failed Weixin API calls.
|
|
3
|
-
*
|
|
4
|
-
* Two ways the API signals failure:
|
|
5
|
-
* 1. Non-2xx HTTP status (network / gateway).
|
|
6
|
-
* 2. 2xx HTTP with a JSON body whose `errcode` is non-zero (logical failure,
|
|
7
|
-
* e.g. quota exhausted, invalid context_token, expired session). The
|
|
8
|
-
* original implementation only handled case 1, so logical failures
|
|
9
|
-
* appeared as silent successes — that is why "10 reply quota exhausted"
|
|
10
|
-
* never showed up in the logs.
|
|
11
|
-
*/
|
|
12
|
-
export declare class WeixinSendError extends Error {
|
|
13
|
-
readonly endpoint: string;
|
|
14
|
-
readonly httpStatus: number;
|
|
15
|
-
readonly errcode?: number;
|
|
16
|
-
readonly errmsg?: string;
|
|
17
|
-
readonly textPreview: string;
|
|
18
|
-
constructor(input: {
|
|
19
|
-
endpoint: string;
|
|
20
|
-
httpStatus: number;
|
|
21
|
-
errcode?: number;
|
|
22
|
-
errmsg?: string;
|
|
23
|
-
textPreview: string;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/** Type guard for callers that need to read structured fields. */
|
|
27
|
-
export declare function isWeixinSendError(error: unknown): error is WeixinSendError;
|
|
28
|
-
/**
|
|
29
|
-
* Extract structured fields from any error for logging context.
|
|
30
|
-
* Returns sparse object so spreading into log context only adds what we know.
|
|
31
|
-
*/
|
|
32
|
-
export declare function describeWeixinSendError(error: unknown): {
|
|
33
|
-
message: string;
|
|
34
|
-
errcode?: number;
|
|
35
|
-
errmsg?: string;
|
|
36
|
-
httpStatus?: number;
|
|
37
|
-
endpoint?: string;
|
|
38
|
-
textPreview?: string;
|
|
39
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { WeixinApiOptions } from "../api/api.js";
|
|
2
|
-
import type { OutboundChannelMedia } from "../../channels/media-types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Upload a local file and send it as a weixin message, routing by MIME type:
|
|
5
|
-
* video/* → uploadVideoToWeixin + sendVideoMessageWeixin
|
|
6
|
-
* image/* → uploadFileToWeixin + sendImageMessageWeixin
|
|
7
|
-
* else → uploadFileAttachmentToWeixin + sendFileMessageWeixin
|
|
8
|
-
*
|
|
9
|
-
* Used by both the auto-reply deliver path (monitor.ts) and the outbound
|
|
10
|
-
* sendMedia path (channel.ts) so they stay in sync.
|
|
11
|
-
*/
|
|
12
|
-
export declare function sendWeixinMediaFile(params: {
|
|
13
|
-
media?: OutboundChannelMedia;
|
|
14
|
-
filePath: string;
|
|
15
|
-
to: string;
|
|
16
|
-
text: string;
|
|
17
|
-
opts: WeixinApiOptions & {
|
|
18
|
-
contextToken?: string;
|
|
19
|
-
};
|
|
20
|
-
cdnBaseUrl: string;
|
|
21
|
-
}): Promise<{
|
|
22
|
-
messageId: string;
|
|
23
|
-
}>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { OrchestrationTaskRecord } from "../../orchestration/orchestration-types";
|
|
2
|
-
import { sendMessageWeixin } from "./send.js";
|
|
3
|
-
interface NoticeDeps {
|
|
4
|
-
baseUrl: string;
|
|
5
|
-
token?: string;
|
|
6
|
-
contextToken: string;
|
|
7
|
-
sendMessage?: typeof sendMessageWeixin;
|
|
8
|
-
}
|
|
9
|
-
export declare function sendOrchestrationTaskNotice(task: OrchestrationTaskRecord, deps: NoticeDeps): Promise<void>;
|
|
10
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { WeixinApiOptions } from "../api/api.js";
|
|
2
|
-
import type { UploadedFileInfo } from "../cdn/upload.js";
|
|
3
|
-
export declare function generateClientId(): string;
|
|
4
|
-
/**
|
|
5
|
-
* Convert markdown-formatted model reply to plain text for Weixin delivery.
|
|
6
|
-
* Backed by StreamingMarkdownFilter — preserves code blocks, tables, inline
|
|
7
|
-
* backticks, non-CJK bold/italic; strips CJK italic/bold-italic markers,
|
|
8
|
-
* images, and H5/H6 heading markers.
|
|
9
|
-
*/
|
|
10
|
-
export declare function markdownToPlainText(text: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Send a plain text message downstream.
|
|
13
|
-
* contextToken is required for all reply sends; missing it breaks conversation association.
|
|
14
|
-
*/
|
|
15
|
-
export declare function sendMessageWeixin(params: {
|
|
16
|
-
to: string;
|
|
17
|
-
text: string;
|
|
18
|
-
opts: WeixinApiOptions & {
|
|
19
|
-
contextToken?: string;
|
|
20
|
-
};
|
|
21
|
-
}): Promise<{
|
|
22
|
-
messageId: string;
|
|
23
|
-
}>;
|
|
24
|
-
/**
|
|
25
|
-
* Send an image message downstream using a previously uploaded file.
|
|
26
|
-
* Optionally include a text caption as a separate TEXT item before the image.
|
|
27
|
-
*
|
|
28
|
-
* ImageItem fields:
|
|
29
|
-
* - media.encrypt_query_param: CDN download param
|
|
30
|
-
* - media.aes_key: AES key, base64-encoded
|
|
31
|
-
* - mid_size: original ciphertext file size
|
|
32
|
-
*/
|
|
33
|
-
export declare function sendImageMessageWeixin(params: {
|
|
34
|
-
to: string;
|
|
35
|
-
text: string;
|
|
36
|
-
uploaded: UploadedFileInfo;
|
|
37
|
-
opts: WeixinApiOptions & {
|
|
38
|
-
contextToken?: string;
|
|
39
|
-
};
|
|
40
|
-
}): Promise<{
|
|
41
|
-
messageId: string;
|
|
42
|
-
}>;
|
|
43
|
-
/**
|
|
44
|
-
* Send a video message downstream using a previously uploaded file.
|
|
45
|
-
* VideoItem: media (CDN ref), video_size (ciphertext bytes).
|
|
46
|
-
* Includes an optional text caption sent as a separate TEXT item first.
|
|
47
|
-
*/
|
|
48
|
-
export declare function sendVideoMessageWeixin(params: {
|
|
49
|
-
to: string;
|
|
50
|
-
text: string;
|
|
51
|
-
uploaded: UploadedFileInfo;
|
|
52
|
-
opts: WeixinApiOptions & {
|
|
53
|
-
contextToken?: string;
|
|
54
|
-
};
|
|
55
|
-
}): Promise<{
|
|
56
|
-
messageId: string;
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* Send a file attachment downstream using a previously uploaded file.
|
|
60
|
-
* FileItem: media (CDN ref), file_name, len (plaintext bytes as string).
|
|
61
|
-
* Includes an optional text caption sent as a separate TEXT item first.
|
|
62
|
-
*/
|
|
63
|
-
export declare function sendFileMessageWeixin(params: {
|
|
64
|
-
to: string;
|
|
65
|
-
text: string;
|
|
66
|
-
fileName: string;
|
|
67
|
-
uploaded: UploadedFileInfo;
|
|
68
|
-
opts: WeixinApiOptions & {
|
|
69
|
-
contextToken?: string;
|
|
70
|
-
};
|
|
71
|
-
}): Promise<{
|
|
72
|
-
messageId: string;
|
|
73
|
-
}>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { PendingFinalChunk } from "./quota-manager.js";
|
|
2
|
-
export interface SlashCommandResult {
|
|
3
|
-
/** 是否是斜杠指令(true 表示已处理,不需要继续走 AI) */
|
|
4
|
-
handled: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface SlashCommandContext {
|
|
7
|
-
to: string;
|
|
8
|
-
contextToken?: string;
|
|
9
|
-
baseUrl: string;
|
|
10
|
-
token?: string;
|
|
11
|
-
accountId: string;
|
|
12
|
-
log: (msg: string) => void;
|
|
13
|
-
errLog: (msg: string) => void;
|
|
14
|
-
/** Called when /clear is invoked to reset the agent session. */
|
|
15
|
-
onClear?: () => void | Promise<void>;
|
|
16
|
-
hasPendingFinal?: (chatKey: string) => boolean;
|
|
17
|
-
drainPendingFinal?: (chatKey: string, available: number) => PendingFinalChunk[];
|
|
18
|
-
prependPendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
|
|
19
|
-
reserveFinal?: (chatKey: string) => boolean;
|
|
20
|
-
finalRemaining?: (chatKey: string) => number;
|
|
21
|
-
sendText?: (params: {
|
|
22
|
-
to: string;
|
|
23
|
-
text: string;
|
|
24
|
-
contextToken?: string;
|
|
25
|
-
}) => Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* v1.4: drain the next wave of pending paginated-final chunks parked by an
|
|
29
|
-
* earlier inbound's overflow. Sends up to `finalRemaining(chatKey)` chunks; if
|
|
30
|
-
* any chunks remain after the wave, appends a heads-up tail to this wave's
|
|
31
|
-
* last chunk so the user knows another `/jx` will pull more. No-op when there
|
|
32
|
-
* is nothing pending or the wiring is incomplete.
|
|
33
|
-
*/
|
|
34
|
-
export declare function drainPendingFinalForJx(ctx: SlashCommandContext): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* 尝试处理斜杠指令
|
|
37
|
-
*
|
|
38
|
-
* @returns handled=true 表示该消息已作为指令处理,不需要继续走 AI 管道
|
|
39
|
-
*/
|
|
40
|
-
export declare function handleSlashCommand(content: string, ctx: SlashCommandContext, receivedAt: number, eventTimestamp?: number): Promise<SlashCommandResult>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface WeixinConsumerLockMetadata {
|
|
2
|
-
pid: number;
|
|
3
|
-
mode: "foreground" | "daemon";
|
|
4
|
-
startedAt: string;
|
|
5
|
-
configPath: string;
|
|
6
|
-
statePath: string;
|
|
7
|
-
hostname?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface WeixinConsumerLock {
|
|
10
|
-
acquire: (meta: WeixinConsumerLockMetadata) => Promise<void>;
|
|
11
|
-
release: () => Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export declare class ActiveWeixinConsumerLockError extends Error {
|
|
14
|
-
readonly existing: WeixinConsumerLockMetadata;
|
|
15
|
-
readonly lockFilePath: string;
|
|
16
|
-
constructor(lockFilePath: string, existing: WeixinConsumerLockMetadata);
|
|
17
|
-
}
|
|
18
|
-
interface CreateWeixinConsumerLockOptions {
|
|
19
|
-
lockFilePath?: string;
|
|
20
|
-
isProcessRunning?: (pid: number) => boolean;
|
|
21
|
-
onDiagnostic?: (event: "lock_exists" | "lock_invalid_removed" | "lock_stale_removed" | "lock_active_conflict" | "lock_acquired" | "lock_released", context: Record<string, string | number | boolean | undefined>) => void | Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
export declare function createWeixinConsumerLock(options?: CreateWeixinConsumerLockOptions): WeixinConsumerLock;
|
|
24
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Agent } from "../agent/interface.js";
|
|
2
|
-
import type { PendingFinalChunk } from "../messaging/quota-manager.js";
|
|
3
|
-
import type { RuntimeMediaStore } from "../../channels/media-store.js";
|
|
4
|
-
import type { PerfTracer } from "../../perf/perf-tracer.js";
|
|
5
|
-
export type MonitorWeixinOpts = {
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
cdnBaseUrl: string;
|
|
8
|
-
token?: string;
|
|
9
|
-
accountId: string;
|
|
10
|
-
agent: Agent;
|
|
11
|
-
abortSignal?: AbortSignal;
|
|
12
|
-
longPollTimeoutMs?: number;
|
|
13
|
-
log?: (msg: string) => void;
|
|
14
|
-
onInbound?: (chatKey: string) => void;
|
|
15
|
-
reserveFinal?: (chatKey: string) => boolean;
|
|
16
|
-
finalRemaining?: (chatKey: string) => number;
|
|
17
|
-
hasPendingFinal?: (chatKey: string) => boolean;
|
|
18
|
-
drainPendingFinal?: (chatKey: string, available: number) => PendingFinalChunk[];
|
|
19
|
-
prependPendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
|
|
20
|
-
enqueuePendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
|
|
21
|
-
dropPendingFinal?: (chatKey: string) => void;
|
|
22
|
-
mediaStore?: RuntimeMediaStore;
|
|
23
|
-
allowedMediaRoots?: string[];
|
|
24
|
-
perfTracer?: PerfTracer;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Long-poll loop: getUpdates → process message → call agent → send reply.
|
|
28
|
-
* Runs until aborted.
|
|
29
|
-
*/
|
|
30
|
-
export declare function monitorWeixinProvider(opts: MonitorWeixinOpts): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function ensureDirSync(dir: string): void;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Path to the persistent get_updates_buf file for an account.
|
|
3
|
-
* Stored alongside account data: ~/.openclaw/openclaw-weixin/accounts/{accountId}.sync.json
|
|
4
|
-
*/
|
|
5
|
-
export declare function getSyncBufFilePath(accountId: string): string;
|
|
6
|
-
export type SyncBufData = {
|
|
7
|
-
get_updates_buf: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Load persisted get_updates_buf.
|
|
11
|
-
* Falls back in order:
|
|
12
|
-
* 1. Primary path (normalized accountId, new installs)
|
|
13
|
-
* 2. Compat path (raw accountId derived from pattern, old installs)
|
|
14
|
-
* 3. Legacy single-account path (very old installs without multi-account support)
|
|
15
|
-
*/
|
|
16
|
-
export declare function loadGetUpdatesBuf(filePath: string): string | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Persist get_updates_buf. Creates parent dir if needed.
|
|
19
|
-
*/
|
|
20
|
-
export declare function saveGetUpdatesBuf(filePath: string, getUpdatesBuf: string): void;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Dynamically change the minimum log level at runtime. */
|
|
2
|
-
export declare function setLogLevel(level: string): void;
|
|
3
|
-
export type Logger = {
|
|
4
|
-
info(message: string): void;
|
|
5
|
-
debug(message: string): void;
|
|
6
|
-
warn(message: string): void;
|
|
7
|
-
error(message: string): void;
|
|
8
|
-
/** Returns a child logger whose messages are prefixed with `[accountId]`. */
|
|
9
|
-
withAccount(accountId: string): Logger;
|
|
10
|
-
/** Returns the current main log file path. */
|
|
11
|
-
getLogFilePath(): string;
|
|
12
|
-
close(): void;
|
|
13
|
-
};
|
|
14
|
-
export declare const logger: Logger;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate a prefixed unique ID using timestamp + crypto random bytes.
|
|
3
|
-
* Format: `{prefix}:{timestamp}-{8-char hex}`
|
|
4
|
-
*/
|
|
5
|
-
export declare function generateId(prefix: string): string;
|
|
6
|
-
/**
|
|
7
|
-
* Generate a temporary file name with random suffix.
|
|
8
|
-
* Format: `{prefix}-{timestamp}-{8-char hex}{ext}`
|
|
9
|
-
*/
|
|
10
|
-
export declare function tempFileName(prefix: string, ext: string): string;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Truncate a string, appending a length indicator when trimmed.
|
|
3
|
-
* Returns `""` for empty/undefined input.
|
|
4
|
-
*/
|
|
5
|
-
export declare function truncate(s: string | undefined, max: number): string;
|
|
6
|
-
/**
|
|
7
|
-
* Redact a token/secret: show only the first few chars + total length.
|
|
8
|
-
* Returns `"(none)"` when absent.
|
|
9
|
-
*/
|
|
10
|
-
export declare function redactToken(token: string | undefined, prefixLen?: number): string;
|
|
11
|
-
/**
|
|
12
|
-
* Redact a JSON body string for safe logging. JSON objects are structurally
|
|
13
|
-
* sanitized so secrets and user-authored message bodies are not written to
|
|
14
|
-
* disk. Non-JSON payloads fall back to length-bounded truncation.
|
|
15
|
-
*/
|
|
16
|
-
export declare function redactBody(body: string | undefined, maxLen?: number): string;
|
|
17
|
-
/**
|
|
18
|
-
* Strip query string (which often contains signatures/tokens) from a URL,
|
|
19
|
-
* keeping only origin + pathname.
|
|
20
|
-
*/
|
|
21
|
-
export declare function redactUrl(rawUrl: string): string;
|