weacpx 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -5
- package/config.example.json +7 -1
- package/dist/bridge/bridge-main.js +11 -25
- package/dist/channels/types.d.ts +2 -0
- package/dist/cli.js +1769 -457
- package/dist/config/types.d.ts +7 -0
- package/dist/logging/rotating-file-writer.d.ts +2 -0
- package/dist/orchestration/orchestration-types.d.ts +12 -0
- package/dist/perf/perf-log-writer.d.ts +25 -0
- package/dist/perf/perf-tracer.d.ts +54 -0
- package/dist/weixin/agent/interface.d.ts +7 -0
- package/dist/weixin/bot.d.ts +2 -0
- package/dist/weixin/messaging/handle-weixin-message-turn.d.ts +2 -0
- package/dist/weixin/monitor/monitor.d.ts +2 -0
- package/package.json +2 -2
package/dist/config/types.d.ts
CHANGED
|
@@ -20,11 +20,18 @@ export interface TransportConfig {
|
|
|
20
20
|
nonInteractivePermissions: NonInteractivePermissions;
|
|
21
21
|
}
|
|
22
22
|
export type LoggingLevel = "error" | "info" | "debug";
|
|
23
|
+
export interface PerfLogConfig {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
maxSizeBytes: number;
|
|
26
|
+
maxFiles: number;
|
|
27
|
+
retentionDays: number;
|
|
28
|
+
}
|
|
23
29
|
export interface LoggingConfig {
|
|
24
30
|
level: LoggingLevel;
|
|
25
31
|
maxSizeBytes: number;
|
|
26
32
|
maxFiles: number;
|
|
27
33
|
retentionDays: number;
|
|
34
|
+
perf: PerfLogConfig;
|
|
28
35
|
}
|
|
29
36
|
export interface AgentConfig {
|
|
30
37
|
driver: string;
|
|
@@ -56,10 +56,22 @@ export interface OrchestrationTaskRecord {
|
|
|
56
56
|
injectionAppliedAt?: string;
|
|
57
57
|
lastInjectionError?: string;
|
|
58
58
|
lastProgressAt?: string;
|
|
59
|
+
lastProgressSummary?: string;
|
|
59
60
|
groupId?: string;
|
|
60
61
|
openQuestion?: OrchestrationOpenQuestionRecord;
|
|
61
62
|
reviewPending?: OrchestrationReviewPendingRecord;
|
|
62
63
|
correctionPending?: OrchestrationCorrectionPendingRecord;
|
|
64
|
+
eventSeq?: number;
|
|
65
|
+
events?: OrchestrationTaskEventRecord[];
|
|
66
|
+
}
|
|
67
|
+
export type OrchestrationTaskEventType = "created" | "progress" | "status_changed" | "attention_required" | "cancel_requested";
|
|
68
|
+
export interface OrchestrationTaskEventRecord {
|
|
69
|
+
seq: number;
|
|
70
|
+
at: string;
|
|
71
|
+
type: OrchestrationTaskEventType;
|
|
72
|
+
status?: OrchestrationTaskStatus;
|
|
73
|
+
summary?: string;
|
|
74
|
+
message?: string;
|
|
63
75
|
}
|
|
64
76
|
export interface OrchestrationGroupRecord {
|
|
65
77
|
groupId: string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface PerfPermanentFailure {
|
|
2
|
+
perfLogPath: string;
|
|
3
|
+
failureCount: number;
|
|
4
|
+
lastError: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CreatePerfLogWriterOptions {
|
|
7
|
+
filePath: string;
|
|
8
|
+
maxSizeBytes: number;
|
|
9
|
+
maxFiles: number;
|
|
10
|
+
retentionDays?: number;
|
|
11
|
+
onPermanentFailure: (info: PerfPermanentFailure) => void;
|
|
12
|
+
failureThreshold?: number;
|
|
13
|
+
appendImpl?: (path: string, data: string) => Promise<void>;
|
|
14
|
+
mkdirImpl?: (path: string, opts: {
|
|
15
|
+
recursive: true;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
now?: () => Date;
|
|
18
|
+
}
|
|
19
|
+
export interface PerfLogWriter {
|
|
20
|
+
enqueue(line: string): void;
|
|
21
|
+
flush(): Promise<void>;
|
|
22
|
+
cleanup(): Promise<void>;
|
|
23
|
+
isDisabled(): boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function createPerfLogWriter(options: CreatePerfLogWriterOptions): PerfLogWriter;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AppLogger } from "../logging/app-logger";
|
|
2
|
+
export type SpanOutcome = "ok" | "error" | "aborted";
|
|
3
|
+
export type PerfContext = Record<string, string | number | boolean | null | undefined>;
|
|
4
|
+
export interface PerfSpan {
|
|
5
|
+
readonly traceId: string;
|
|
6
|
+
mark(event: string, context?: PerfContext): void;
|
|
7
|
+
setOutcome(outcome: SpanOutcome, context?: PerfContext): void;
|
|
8
|
+
}
|
|
9
|
+
export interface PerfTracer {
|
|
10
|
+
wrapTurn<T>(seed: {
|
|
11
|
+
chatKey: string;
|
|
12
|
+
kind: "command" | "prompt";
|
|
13
|
+
}, run: (span: PerfSpan) => Promise<T>): Promise<T>;
|
|
14
|
+
flush(): Promise<void>;
|
|
15
|
+
cleanup(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface FormatLineArgs {
|
|
18
|
+
isoNow: Date;
|
|
19
|
+
event: string;
|
|
20
|
+
traceId: string;
|
|
21
|
+
chatKey: string;
|
|
22
|
+
sinceStartMs: number;
|
|
23
|
+
sinceLastMs: number;
|
|
24
|
+
context?: PerfContext;
|
|
25
|
+
}
|
|
26
|
+
export interface FormatSummaryArgs {
|
|
27
|
+
isoNow: Date;
|
|
28
|
+
traceId: string;
|
|
29
|
+
chatKey: string;
|
|
30
|
+
kind: "command" | "prompt";
|
|
31
|
+
outcome: SpanOutcome;
|
|
32
|
+
totalMs: number;
|
|
33
|
+
marks: Array<{
|
|
34
|
+
e: string;
|
|
35
|
+
t: number;
|
|
36
|
+
}>;
|
|
37
|
+
outcomeContext?: PerfContext;
|
|
38
|
+
}
|
|
39
|
+
export interface CreatePerfTracerOptions {
|
|
40
|
+
filePath: string;
|
|
41
|
+
maxSizeBytes: number;
|
|
42
|
+
maxFiles: number;
|
|
43
|
+
retentionDays: number;
|
|
44
|
+
appLogger: AppLogger;
|
|
45
|
+
now?: () => number;
|
|
46
|
+
isoNow?: () => Date;
|
|
47
|
+
randomId?: () => string;
|
|
48
|
+
formatLine?: (args: FormatLineArgs) => string;
|
|
49
|
+
formatSummaryLine?: (args: FormatSummaryArgs) => string;
|
|
50
|
+
}
|
|
51
|
+
export declare function createNoopPerfTracer(): PerfTracer;
|
|
52
|
+
export declare function createPerfTracer(options: CreatePerfTracerOptions): PerfTracer;
|
|
53
|
+
export declare function defaultFormatLine(args: FormatLineArgs): string;
|
|
54
|
+
export declare function defaultFormatSummaryLine(args: FormatSummaryArgs): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChannelMediaAttachment, OutboundChannelMedia } from "../../channels/media-types.js";
|
|
2
2
|
import type { ToolUseEvent } from "../../channels/types.js";
|
|
3
|
+
import type { PerfSpan } from "../../perf/perf-tracer.js";
|
|
3
4
|
/**
|
|
4
5
|
* Agent interface — any AI backend that can handle a chat message.
|
|
5
6
|
*
|
|
@@ -45,6 +46,12 @@ export interface ChatRequest {
|
|
|
45
46
|
abortSignal?: AbortSignal;
|
|
46
47
|
/** Structured tool-use side-channel; see PromptOptions.onToolEvent. */
|
|
47
48
|
onToolEvent?: (event: ToolUseEvent) => void | Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Optional per-turn performance tracing span. When `logging.perf.enabled` is
|
|
51
|
+
* true, the channel handler attaches a `PerfSpan` so downstream layers can
|
|
52
|
+
* inline `request.perfSpan?.mark(event, ctx)` without further plumbing.
|
|
53
|
+
*/
|
|
54
|
+
perfSpan?: PerfSpan;
|
|
48
55
|
}
|
|
49
56
|
export interface ChatRequestMetadata {
|
|
50
57
|
channel?: string;
|
package/dist/weixin/bot.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Agent } from "./agent/interface.js";
|
|
2
2
|
import type { PendingFinalChunk } from "./messaging/quota-manager.js";
|
|
3
3
|
import type { RuntimeMediaStore } from "../channels/media-store.js";
|
|
4
|
+
import type { PerfTracer } from "../perf/perf-tracer.js";
|
|
4
5
|
export type LoginOptions = {
|
|
5
6
|
/** Override the API base URL. */
|
|
6
7
|
baseUrl?: string;
|
|
@@ -29,6 +30,7 @@ export type StartOptions = {
|
|
|
29
30
|
enqueuePendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
|
|
30
31
|
dropPendingFinal?: (chatKey: string) => void;
|
|
31
32
|
mediaStore?: RuntimeMediaStore;
|
|
33
|
+
perfTracer?: PerfTracer;
|
|
32
34
|
};
|
|
33
35
|
/**
|
|
34
36
|
* Interactive QR-code login. Prints the QR code to the terminal and waits
|
|
@@ -3,6 +3,7 @@ import type { WeixinMessage } from "../api/types.js";
|
|
|
3
3
|
import { RuntimeMediaStore } from "../../channels/media-store.js";
|
|
4
4
|
import { downloadMediaFromItem } from "../media/media-download.js";
|
|
5
5
|
import type { PendingFinalChunk } from "./quota-manager.js";
|
|
6
|
+
import { type PerfTracer } from "../../perf/perf-tracer.js";
|
|
6
7
|
export declare function chunkFinalText(text: string, maxBytes: number): string[];
|
|
7
8
|
export declare function resolveMediaTempDir(customRoot?: string): string;
|
|
8
9
|
export type HandleWeixinMessageTurnDeps = {
|
|
@@ -25,6 +26,7 @@ export type HandleWeixinMessageTurnDeps = {
|
|
|
25
26
|
mediaStore?: RuntimeMediaStore;
|
|
26
27
|
downloadMediaFromItemFn?: typeof downloadMediaFromItem;
|
|
27
28
|
allowedMediaRoots?: string[];
|
|
29
|
+
perfTracer?: PerfTracer;
|
|
28
30
|
};
|
|
29
31
|
export declare function getWeixinMessageTurnLane(full: WeixinMessage): "normal" | "control";
|
|
30
32
|
export declare function handleWeixinMessageTurn(full: WeixinMessage, deps: HandleWeixinMessageTurnDeps): Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Agent } from "../agent/interface.js";
|
|
2
2
|
import type { PendingFinalChunk } from "../messaging/quota-manager.js";
|
|
3
3
|
import type { RuntimeMediaStore } from "../../channels/media-store.js";
|
|
4
|
+
import type { PerfTracer } from "../../perf/perf-tracer.js";
|
|
4
5
|
export type MonitorWeixinOpts = {
|
|
5
6
|
baseUrl: string;
|
|
6
7
|
cdnBaseUrl: string;
|
|
@@ -20,6 +21,7 @@ export type MonitorWeixinOpts = {
|
|
|
20
21
|
dropPendingFinal?: (chatKey: string) => void;
|
|
21
22
|
mediaStore?: RuntimeMediaStore;
|
|
22
23
|
allowedMediaRoots?: string[];
|
|
24
|
+
perfTracer?: PerfTracer;
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* Long-poll loop: getUpdates → process message → call agent → send reply.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weacpx",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "使用微信 ClawBot 随时随地通过 `acpx` 控制 Claude Code、Codex 等 Agents。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acpx",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"smoke:local-install": "node ./scripts/smoke-local-install.mjs"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
67
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
68
68
|
"acpx": "^0.6.1",
|
|
69
69
|
"node-pty": "^1.1.0",
|
|
70
70
|
"proper-lockfile": "^4.1.2",
|