@ganglion/xacpx 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.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +570 -0
  3. package/config.example.json +44 -0
  4. package/dist/bridge/bridge-main.js +2133 -0
  5. package/dist/channels/channel-scope.d.ts +17 -0
  6. package/dist/channels/cli/provider.d.ts +73 -0
  7. package/dist/channels/cli/registry.d.ts +7 -0
  8. package/dist/channels/cli/weixin-provider.d.ts +2 -0
  9. package/dist/channels/create-channel.d.ts +16 -0
  10. package/dist/channels/media-store.d.ts +29 -0
  11. package/dist/channels/media-types.d.ts +28 -0
  12. package/dist/channels/outbound-media-safety.d.ts +7 -0
  13. package/dist/channels/plugin.d.ts +9 -0
  14. package/dist/channels/types.d.ts +124 -0
  15. package/dist/channels/weixin-channel.d.ts +25 -0
  16. package/dist/cli.js +47745 -0
  17. package/dist/commands/command-hints.d.ts +11 -0
  18. package/dist/commands/command-list.d.ts +3 -0
  19. package/dist/commands/config-clone.d.ts +2 -0
  20. package/dist/commands/handlers/agent-handler.d.ts +6 -0
  21. package/dist/commands/handlers/config-handler.d.ts +5 -0
  22. package/dist/commands/handlers/later-handler.d.ts +21 -0
  23. package/dist/commands/handlers/orchestration-handler.d.ts +16 -0
  24. package/dist/commands/handlers/permission-handler.d.ts +9 -0
  25. package/dist/commands/handlers/session-handler.d.ts +39 -0
  26. package/dist/commands/handlers/session-list-marker.d.ts +1 -0
  27. package/dist/commands/handlers/workspace-handler.d.ts +8 -0
  28. package/dist/commands/help/help-registry.d.ts +4 -0
  29. package/dist/commands/help/help-types.d.ts +12 -0
  30. package/dist/commands/parse-command.d.ts +178 -0
  31. package/dist/commands/router-types.d.ts +144 -0
  32. package/dist/commands/workspace-name.d.ts +4 -0
  33. package/dist/commands/workspace-path.d.ts +4 -0
  34. package/dist/config/agent-templates.d.ts +4 -0
  35. package/dist/config/config-store.d.ts +13 -0
  36. package/dist/config/load-config.d.ts +10 -0
  37. package/dist/config/resolve-agent-command.d.ts +2 -0
  38. package/dist/config/types.d.ts +85 -0
  39. package/dist/formatting/render-text.d.ts +23 -0
  40. package/dist/logging/app-logger.d.ts +23 -0
  41. package/dist/logging/rotating-file-writer.d.ts +2 -0
  42. package/dist/orchestration/async-mutex.d.ts +4 -0
  43. package/dist/orchestration/build-coordinator-prompt.d.ts +66 -0
  44. package/dist/orchestration/orchestration-service.d.ts +471 -0
  45. package/dist/orchestration/orchestration-types.d.ts +181 -0
  46. package/dist/orchestration/progress-line-parser.d.ts +19 -0
  47. package/dist/orchestration/render-delegate-group-result.d.ts +6 -0
  48. package/dist/orchestration/render-delegate-question-package.d.ts +21 -0
  49. package/dist/orchestration/render-delegate-result.d.ts +2 -0
  50. package/dist/orchestration/task-watch-timeouts.d.ts +5 -0
  51. package/dist/perf/perf-log-writer.d.ts +25 -0
  52. package/dist/perf/perf-tracer.d.ts +54 -0
  53. package/dist/plugin-api.d.ts +18 -0
  54. package/dist/plugin-api.js +341 -0
  55. package/dist/plugins/compatibility.d.ts +18 -0
  56. package/dist/plugins/known-plugins.d.ts +9 -0
  57. package/dist/plugins/types.d.ts +31 -0
  58. package/dist/runtime/conversation-executor.d.ts +7 -0
  59. package/dist/runtime/core-env.d.ts +28 -0
  60. package/dist/runtime/core-home.d.ts +31 -0
  61. package/dist/runtime/turn-lane.d.ts +2 -0
  62. package/dist/scheduled/parse-later-time.d.ts +11 -0
  63. package/dist/scheduled/scheduled-render.d.ts +7 -0
  64. package/dist/scheduled/scheduled-service.d.ts +41 -0
  65. package/dist/scheduled/scheduled-types.d.ts +29 -0
  66. package/dist/sessions/active-turn-registry.d.ts +6 -0
  67. package/dist/sessions/session-service.d.ts +118 -0
  68. package/dist/state/state-store.d.ts +8 -0
  69. package/dist/state/types.d.ts +51 -0
  70. package/dist/transport/tool-event-mode.d.ts +14 -0
  71. package/dist/transport/types.d.ts +129 -0
  72. package/dist/util/path.d.ts +4 -0
  73. package/dist/util/private-file.d.ts +26 -0
  74. package/dist/util/sanitize.d.ts +10 -0
  75. package/dist/util/text.d.ts +3 -0
  76. package/dist/version.d.ts +3 -0
  77. package/dist/weixin/agent/interface.d.ts +79 -0
  78. package/dist/weixin/api/api.d.ts +76 -0
  79. package/dist/weixin/api/config-cache.d.ts +35 -0
  80. package/dist/weixin/api/session-guard.d.ts +17 -0
  81. package/dist/weixin/api/types.d.ts +203 -0
  82. package/dist/weixin/auth/accounts.d.ts +69 -0
  83. package/dist/weixin/auth/login-qr.d.ts +37 -0
  84. package/dist/weixin/bot.d.ts +67 -0
  85. package/dist/weixin/cdn/aes-ecb.d.ts +6 -0
  86. package/dist/weixin/cdn/cdn-upload.d.ts +17 -0
  87. package/dist/weixin/cdn/cdn-url.d.ts +11 -0
  88. package/dist/weixin/cdn/pic-decrypt.d.ts +9 -0
  89. package/dist/weixin/cdn/upload.d.ts +42 -0
  90. package/dist/weixin/index.d.ts +6 -0
  91. package/dist/weixin/media/media-download.d.ts +18 -0
  92. package/dist/weixin/media/mime.d.ts +6 -0
  93. package/dist/weixin/media/silk-transcode.d.ts +8 -0
  94. package/dist/weixin/messaging/completion-notice.d.ts +2 -0
  95. package/dist/weixin/messaging/debug-mode.d.ts +9 -0
  96. package/dist/weixin/messaging/deliver-coordinator-message.d.ts +22 -0
  97. package/dist/weixin/messaging/deliver-orchestration-task-notice.d.ts +18 -0
  98. package/dist/weixin/messaging/deliver-orchestration-task-progress.d.ts +16 -0
  99. package/dist/weixin/messaging/error-notice.d.ts +13 -0
  100. package/dist/weixin/messaging/execute-chat-turn.d.ts +12 -0
  101. package/dist/weixin/messaging/final-heads-up.d.ts +5 -0
  102. package/dist/weixin/messaging/foreground-gate.d.ts +3 -0
  103. package/dist/weixin/messaging/handle-weixin-message-turn.d.ts +36 -0
  104. package/dist/weixin/messaging/inbound.d.ts +87 -0
  105. package/dist/weixin/messaging/markdown-filter.d.ts +45 -0
  106. package/dist/weixin/messaging/orchestration-notice-accounts.d.ts +2 -0
  107. package/dist/weixin/messaging/quota-errors.d.ts +8 -0
  108. package/dist/weixin/messaging/quota-manager.d.ts +58 -0
  109. package/dist/weixin/messaging/scheduled-turn.d.ts +22 -0
  110. package/dist/weixin/messaging/send-errors.d.ts +39 -0
  111. package/dist/weixin/messaging/send-media.d.ts +23 -0
  112. package/dist/weixin/messaging/send-orchestration-notice.d.ts +10 -0
  113. package/dist/weixin/messaging/send.d.ts +73 -0
  114. package/dist/weixin/messaging/slash-commands.d.ts +40 -0
  115. package/dist/weixin/monitor/consumer-lock.d.ts +24 -0
  116. package/dist/weixin/monitor/monitor.d.ts +38 -0
  117. package/dist/weixin/storage/ensure-dir.d.ts +1 -0
  118. package/dist/weixin/storage/state-dir.d.ts +2 -0
  119. package/dist/weixin/storage/sync-buf.d.ts +20 -0
  120. package/dist/weixin/util/logger.d.ts +14 -0
  121. package/dist/weixin/util/random.d.ts +10 -0
  122. package/dist/weixin/util/redact.d.ts +21 -0
  123. package/package.json +93 -0
@@ -0,0 +1,38 @@
1
+ import type { Agent } from "../agent/interface.js";
2
+ import type { PendingFinalChunk } from "../messaging/quota-manager.js";
3
+ import type { ActiveTurnRegistry } from "../../sessions/active-turn-registry.js";
4
+ import type { RuntimeMediaStore } from "../../channels/media-store.js";
5
+ import type { PerfTracer } from "../../perf/perf-tracer.js";
6
+ export type MonitorWeixinOpts = {
7
+ baseUrl: string;
8
+ cdnBaseUrl: string;
9
+ token?: string;
10
+ accountId: string;
11
+ agent: Agent;
12
+ abortSignal?: AbortSignal;
13
+ longPollTimeoutMs?: number;
14
+ log?: (msg: string) => void;
15
+ onInbound?: (chatKey: string) => void;
16
+ reserveFinal?: (chatKey: string) => boolean;
17
+ finalRemaining?: (chatKey: string) => number;
18
+ hasPendingFinal?: (chatKey: string) => boolean;
19
+ drainPendingFinal?: (chatKey: string, available: number) => PendingFinalChunk[];
20
+ prependPendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
21
+ enqueuePendingFinal?: (chatKey: string, chunks: PendingFinalChunk[]) => void;
22
+ dropPendingFinal?: (chatKey: string) => void;
23
+ mediaStore?: RuntimeMediaStore;
24
+ allowedMediaRoots?: string[];
25
+ perfTracer?: PerfTracer;
26
+ peekCurrentSessionAlias?: (chatKey: string) => string | undefined;
27
+ setBackgroundResult?: (chatKey: string, alias: string, result: {
28
+ text: string;
29
+ status: "done" | "error";
30
+ finished_at: string;
31
+ }) => Promise<void>;
32
+ activeTurns?: ActiveTurnRegistry;
33
+ };
34
+ /**
35
+ * Long-poll loop: getUpdates → process message → call agent → send reply.
36
+ * Runs until aborted.
37
+ */
38
+ export declare function monitorWeixinProvider(opts: MonitorWeixinOpts): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function ensureDirSync(dir: string): void;
@@ -0,0 +1,2 @@
1
+ /** Resolve the OpenClaw state directory (mirrors core logic in src/infra). */
2
+ export declare function resolveStateDir(): string;
@@ -0,0 +1,20 @@
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;
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,21 @@
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;
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@ganglion/xacpx",
3
+ "version": "0.8.0",
4
+ "description": "随时随地通过聊天频道(微信 / 飞书 / 元宝等)远程控制 `acpx` 上的 Claude Code、Codex 等 Agents。",
5
+ "keywords": [
6
+ "acpx",
7
+ "xacpx",
8
+ "weixin-agent-sdk",
9
+ "openclaw",
10
+ "weixin",
11
+ "yuanbao",
12
+ "feishu"
13
+ ],
14
+ "author": "gadzan",
15
+ "license": "MIT",
16
+ "bugs": {
17
+ "url": "https://github.com/gadzan/weacpx/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/gadzan/weacpx.git"
22
+ },
23
+ "type": "module",
24
+ "bin": {
25
+ "xacpx": "./dist/cli.js"
26
+ },
27
+ "exports": {
28
+ "./plugin-api": {
29
+ "types": "./dist/plugin-api.d.ts",
30
+ "default": "./dist/plugin-api.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "README.md",
36
+ "config.example.json"
37
+ ],
38
+ "workspaces": [
39
+ "packages/*"
40
+ ],
41
+ "scripts": {
42
+ "clean:dist": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
43
+ "clean:channel-yuanbao": "node -e \"require('node:fs').rmSync('packages/channel-yuanbao/dist',{recursive:true,force:true})\"",
44
+ "clean:channel-feishu": "node -e \"require('node:fs').rmSync('packages/channel-feishu/dist',{recursive:true,force:true})\"",
45
+ "build": "bun run clean:dist && bun build ./src/cli.ts ./src/bridge/bridge-main.ts ./src/plugin-api.ts --outdir ./dist --target node --external node-pty && bun run build:plugin-api",
46
+ "build:plugin-api": "tsc -p tsconfig.plugin-api.json",
47
+ "build:channel-yuanbao": "bun run build:plugin-api && bun run clean:channel-yuanbao && bun build ./packages/channel-yuanbao/src/index.ts --outdir ./packages/channel-yuanbao/dist --target node --external xacpx && tsc -p packages/channel-yuanbao/tsconfig.json",
48
+ "build:channel-feishu": "bun run build:plugin-api && bun run clean:channel-feishu && bun build ./packages/channel-feishu/src/index.ts --outdir ./packages/channel-feishu/dist --target node --external xacpx && tsc -p packages/channel-feishu/tsconfig.json",
49
+ "build:packages": "bun run build && bun run build:channel-yuanbao && bun run build:channel-feishu",
50
+ "verify:publish": "bun run build:packages && node ./scripts/verify-publish.mjs",
51
+ "publish:xacpx": "bun publish --cwd .",
52
+ "publish:weacpx-compat": "bun publish --cwd weacpx-compat --access public",
53
+ "publish:channel-feishu": "bun publish --cwd packages/channel-feishu --access public",
54
+ "publish:channel-yuanbao": "bun publish --cwd packages/channel-yuanbao --access public",
55
+ "publish:plugins": "bun run publish:channel-yuanbao && bun run publish:channel-feishu",
56
+ "dev": "bun run ./src/cli.ts run",
57
+ "dry-run": "bun run ./src/dry-run.ts",
58
+ "login": "bun run ./src/cli.ts login",
59
+ "start": "node ./dist/cli.js run",
60
+ "daemon:start": "bun run ./src/cli.ts start",
61
+ "daemon:status": "bun run ./src/cli.ts status",
62
+ "daemon:stop": "bun run ./src/cli.ts stop",
63
+ "test": "node ./scripts/run-tests.mjs",
64
+ "test:unit": "node ./scripts/run-tests.mjs tests/unit",
65
+ "test:smoke": "node ./scripts/run-tests.mjs tests/smoke",
66
+ "smoke:local-install": "node ./scripts/smoke-local-install.mjs"
67
+ },
68
+ "dependencies": {
69
+ "@modelcontextprotocol/sdk": "^1.29.0",
70
+ "acpx": "^0.9.0",
71
+ "node-pty": "^1.1.0",
72
+ "proper-lockfile": "^4.1.2",
73
+ "protobufjs": "^7.5.6",
74
+ "qrcode-terminal": "^0.12.0",
75
+ "write-file-atomic": "^8.0.0",
76
+ "ws": "^8.20.0",
77
+ "zod": "^3",
78
+ "zod-to-json-schema": "^3"
79
+ },
80
+ "publishConfig": {
81
+ "registry": "https://registry.npmjs.org/"
82
+ },
83
+ "engines": {
84
+ "node": ">=22"
85
+ },
86
+ "devDependencies": {
87
+ "@types/proper-lockfile": "^4.1.4",
88
+ "@types/write-file-atomic": "^4.0.3",
89
+ "@types/ws": "^8.18.1",
90
+ "bun-types": "^1.3.11",
91
+ "typescript": "^6.0.2"
92
+ }
93
+ }