weacpx 0.4.8 → 0.4.9
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 +6 -5
- package/dist/cli.js +1620 -534
- package/dist/config/types.d.ts +1 -0
- package/dist/orchestration/orchestration-types.d.ts +7 -1
- package/dist/weixin/api/api.d.ts +28 -0
- package/dist/weixin/api/session-guard.d.ts +2 -0
- package/dist/weixin/api/types.d.ts +2 -0
- package/dist/weixin/auth/accounts.d.ts +7 -0
- package/dist/weixin/auth/login-qr.d.ts +6 -0
- package/dist/weixin/index.d.ts +1 -1
- package/dist/weixin/messaging/inbound.d.ts +18 -1
- package/dist/weixin/messaging/markdown-filter.d.ts +45 -0
- package/dist/weixin/messaging/send.d.ts +3 -1
- package/package.json +1 -1
package/dist/config/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type OrchestrationTaskStatus = "needs_confirmation" | "running" | "blocked" | "waiting_for_human" | "completed" | "failed" | "cancelled";
|
|
1
|
+
export type OrchestrationTaskStatus = "needs_confirmation" | "queued" | "running" | "blocked" | "waiting_for_human" | "completed" | "failed" | "cancelled";
|
|
2
2
|
export type OrchestrationSourceKind = "human" | "coordinator" | "worker";
|
|
3
3
|
export interface OrchestrationOpenQuestionRecord {
|
|
4
4
|
questionId: string;
|
|
@@ -58,6 +58,10 @@ export interface OrchestrationTaskRecord {
|
|
|
58
58
|
lastProgressAt?: string;
|
|
59
59
|
lastProgressSummary?: string;
|
|
60
60
|
groupId?: string;
|
|
61
|
+
/** True when this task owns an ephemeral parallel-slot worker session that must be closed on terminal. */
|
|
62
|
+
ephemeralWorkerSession?: boolean;
|
|
63
|
+
/** Idempotency guard: set once the ephemeral worker session has been closed. */
|
|
64
|
+
ephemeralWorkerSessionClosed?: boolean;
|
|
61
65
|
openQuestion?: OrchestrationOpenQuestionRecord;
|
|
62
66
|
reviewPending?: OrchestrationReviewPendingRecord;
|
|
63
67
|
correctionPending?: OrchestrationCorrectionPendingRecord;
|
|
@@ -109,6 +113,8 @@ export interface WorkerBindingRecord {
|
|
|
109
113
|
cwd?: string;
|
|
110
114
|
targetAgent: string;
|
|
111
115
|
role?: string;
|
|
116
|
+
/** True for ephemeral parallel-slot sessions; excluded from findReusableWorkerSession matching. */
|
|
117
|
+
ephemeral?: boolean;
|
|
112
118
|
}
|
|
113
119
|
export interface OrchestrationQueuedQuestionRecord {
|
|
114
120
|
taskId: string;
|
package/dist/weixin/api/api.d.ts
CHANGED
|
@@ -6,6 +6,21 @@ export type WeixinApiOptions = {
|
|
|
6
6
|
/** Long-poll timeout for getUpdates (server may hold the request up to this). */
|
|
7
7
|
longPollTimeoutMs?: number;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Sanitize a user-supplied `botAgent` config value into a wire-safe string.
|
|
11
|
+
*
|
|
12
|
+
* Grammar (UA-style):
|
|
13
|
+
* bot_agent = product *( SP product )
|
|
14
|
+
* product = name "/" version [ SP "(" comment ")" ]
|
|
15
|
+
* name = 1*32( ALPHA / DIGIT / "_" / "." / "-" )
|
|
16
|
+
* version = 1*32( ALPHA / DIGIT / "_" / "." / "+" / "-" )
|
|
17
|
+
* comment = 1*64( printable ASCII minus "(" ")" )
|
|
18
|
+
*
|
|
19
|
+
* Tokens that fail to parse are dropped silently (no partial tokens kept).
|
|
20
|
+
* Returns `DEFAULT_BOT_AGENT` when the input is empty / all tokens dropped /
|
|
21
|
+
* the result exceeds the length cap after truncation.
|
|
22
|
+
*/
|
|
23
|
+
export declare function sanitizeBotAgent(raw: string | undefined): string;
|
|
9
24
|
/** Build the `base_info` payload included in every API request. */
|
|
10
25
|
export declare function buildBaseInfo(): BaseInfo;
|
|
11
26
|
/**
|
|
@@ -19,6 +34,19 @@ export declare function apiGetFetch(params: {
|
|
|
19
34
|
timeoutMs: number;
|
|
20
35
|
label: string;
|
|
21
36
|
}): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Simple POST fetch wrapper for login/auth endpoints.
|
|
39
|
+
* Returns the raw response text on success; throws on HTTP error or timeout.
|
|
40
|
+
*/
|
|
41
|
+
export declare function apiPostFetch(params: {
|
|
42
|
+
baseUrl: string;
|
|
43
|
+
endpoint: string;
|
|
44
|
+
body: string;
|
|
45
|
+
token?: string;
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
label: string;
|
|
48
|
+
abortSignal?: AbortSignal;
|
|
49
|
+
}): Promise<string>;
|
|
22
50
|
/**
|
|
23
51
|
* Long-poll getUpdates. Server should hold the request until new messages or timeout.
|
|
24
52
|
*
|
|
@@ -6,6 +6,8 @@ export declare function pauseSession(accountId: string): void;
|
|
|
6
6
|
export declare function isSessionPaused(accountId: string): boolean;
|
|
7
7
|
/** Milliseconds remaining until the pause expires (0 when not paused). */
|
|
8
8
|
export declare function getRemainingPauseMs(accountId: string): number;
|
|
9
|
+
/** Clear the session pause for a specific account. Used when fresh credentials are detected. */
|
|
10
|
+
export declare function resetSessionPause(accountId: string): void;
|
|
9
11
|
/** Throw if the session is currently paused. Call before any API request. */
|
|
10
12
|
export declare function assertSessionActive(accountId: string): void;
|
|
11
13
|
/**
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
/** Common request metadata attached to every CGI request. */
|
|
6
6
|
export interface BaseInfo {
|
|
7
7
|
channel_version?: string;
|
|
8
|
+
/** UA-style identifier for the upstream app embedding this channel. */
|
|
9
|
+
bot_agent?: string;
|
|
8
10
|
}
|
|
9
11
|
/** proto: UploadMediaType */
|
|
10
12
|
export declare const UploadMediaType: {
|
|
@@ -44,6 +44,13 @@ export declare function clearAllWeixinAccounts(): void;
|
|
|
44
44
|
* `channels.<id>.routeTag`. Matches `feat_weixin_extension` behavior; channel key is `"openclaw-weixin"`.
|
|
45
45
|
*/
|
|
46
46
|
export declare function loadConfigRouteTag(accountId?: string): string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Read `botAgent` from openclaw.json (for callers without an `OpenClawConfig` object).
|
|
49
|
+
* Checks per-account `channels.<id>.accounts[accountId].botAgent` first, then section-level
|
|
50
|
+
* `channels.<id>.botAgent`. Channel key is `"openclaw-weixin"`. Caller is responsible for
|
|
51
|
+
* sanitization (see `sanitizeBotAgent`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadConfigBotAgent(accountId?: string): string | undefined;
|
|
47
54
|
/**
|
|
48
55
|
* No-op stub — config reload is now handled externally via `openclaw gateway restart`.
|
|
49
56
|
*/
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/** Default `bot_type` for ilink get_bot_qrcode / get_qrcode_status (this channel build). */
|
|
2
2
|
export declare const DEFAULT_ILINK_BOT_TYPE = "3";
|
|
3
|
+
/**
|
|
4
|
+
* Build the URL-encoded endpoint for the QR status long-poll. Exported for
|
|
5
|
+
* unit testing — `pollQRStatus` uses this exact helper, so a test on the
|
|
6
|
+
* helper covers the real production path.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildPollQRStatusEndpoint(qrcode: string, verifyCode?: string): string;
|
|
3
9
|
export type WeixinQrStartResult = {
|
|
4
10
|
qrcodeUrl?: string;
|
|
5
11
|
message: string;
|
package/dist/weixin/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export type { Agent, ChatRequest, ChatResponse } from "./agent/interface.js";
|
|
|
2
2
|
export { login, start, logout, isLoggedIn } from "./bot.js";
|
|
3
3
|
export type { LoginOptions, StartOptions } from "./bot.js";
|
|
4
4
|
export { sendMessageWeixin, markdownToPlainText } from "./messaging/send.js";
|
|
5
|
-
export { getContextToken } from "./messaging/inbound.js";
|
|
5
|
+
export { getContextToken, setContextToken, restoreContextTokens, clearContextTokensForAccount, findAccountIdsByContextToken, } from "./messaging/inbound.js";
|
|
6
6
|
export { resolveWeixinAccount, listWeixinAccountIds, clearAllWeixinAccounts } from "./auth/accounts.js";
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import type { ChannelMediaKind } from "../../channels/media-types.js";
|
|
2
2
|
import type { WeixinMessage, MessageItem } from "../api/types.js";
|
|
3
|
-
/**
|
|
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). */
|
|
4
15
|
export declare function setContextToken(accountId: string, userId: string, token: string): void;
|
|
5
16
|
/** Retrieve the cached context token for a given account+user pair. */
|
|
6
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[];
|
|
7
24
|
/** Strip the `weixin:accountId:` prefix from a chat key, returning the bare user id. */
|
|
8
25
|
export declare function normalizeWeixinUserIdFromChatKey(chatKey: string): string;
|
|
9
26
|
/** Inbound context passed to the OpenClaw core pipeline (matches MsgContext shape). */
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
}
|
|
@@ -3,7 +3,9 @@ import type { UploadedFileInfo } from "../cdn/upload.js";
|
|
|
3
3
|
export declare function generateClientId(): string;
|
|
4
4
|
/**
|
|
5
5
|
* Convert markdown-formatted model reply to plain text for Weixin delivery.
|
|
6
|
-
*
|
|
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.
|
|
7
9
|
*/
|
|
8
10
|
export declare function markdownToPlainText(text: string): string;
|
|
9
11
|
/**
|