weacpx 0.6.0 → 0.7.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 (63) hide show
  1. package/dist/bridge/bridge-main.js +66 -24
  2. package/dist/channels/types.d.ts +14 -0
  3. package/dist/cli.js +1268 -407
  4. package/dist/commands/command-hints.d.ts +11 -0
  5. package/dist/commands/command-list.d.ts +3 -0
  6. package/dist/commands/config-clone.d.ts +2 -0
  7. package/dist/commands/handlers/agent-handler.d.ts +6 -0
  8. package/dist/commands/handlers/config-handler.d.ts +5 -0
  9. package/dist/commands/handlers/later-handler.d.ts +21 -0
  10. package/dist/commands/handlers/orchestration-handler.d.ts +16 -0
  11. package/dist/commands/handlers/permission-handler.d.ts +9 -0
  12. package/dist/commands/handlers/session-handler.d.ts +39 -0
  13. package/dist/commands/handlers/session-list-marker.d.ts +1 -0
  14. package/dist/commands/handlers/workspace-handler.d.ts +8 -0
  15. package/dist/commands/help/help-registry.d.ts +4 -0
  16. package/dist/commands/help/help-types.d.ts +12 -0
  17. package/dist/commands/parse-command.d.ts +178 -0
  18. package/dist/commands/router-types.d.ts +144 -0
  19. package/dist/commands/workspace-name.d.ts +4 -0
  20. package/dist/commands/workspace-path.d.ts +4 -0
  21. package/dist/config/agent-templates.d.ts +4 -0
  22. package/dist/config/config-store.d.ts +13 -0
  23. package/dist/config/load-config.d.ts +10 -0
  24. package/dist/config/resolve-agent-command.d.ts +2 -0
  25. package/dist/formatting/render-text.d.ts +23 -0
  26. package/dist/orchestration/async-mutex.d.ts +4 -0
  27. package/dist/orchestration/build-coordinator-prompt.d.ts +66 -0
  28. package/dist/orchestration/orchestration-service.d.ts +471 -0
  29. package/dist/orchestration/progress-line-parser.d.ts +19 -0
  30. package/dist/orchestration/render-delegate-group-result.d.ts +6 -0
  31. package/dist/orchestration/render-delegate-question-package.d.ts +21 -0
  32. package/dist/orchestration/render-delegate-result.d.ts +2 -0
  33. package/dist/orchestration/task-watch-timeouts.d.ts +5 -0
  34. package/dist/plugin-api.d.ts +10 -0
  35. package/dist/plugin-api.js +157 -0
  36. package/dist/{weixin/messaging → runtime}/conversation-executor.d.ts +1 -1
  37. package/dist/runtime/core-home.d.ts +26 -0
  38. package/dist/runtime/turn-lane.d.ts +2 -0
  39. package/dist/scheduled/parse-later-time.d.ts +11 -0
  40. package/dist/scheduled/scheduled-render.d.ts +7 -0
  41. package/dist/scheduled/scheduled-service.d.ts +41 -0
  42. package/dist/scheduled/scheduled-types.d.ts +29 -0
  43. package/dist/sessions/active-turn-registry.d.ts +6 -0
  44. package/dist/sessions/session-service.d.ts +118 -0
  45. package/dist/state/state-store.d.ts +8 -0
  46. package/dist/state/types.d.ts +51 -0
  47. package/dist/transport/tool-event-mode.d.ts +14 -0
  48. package/dist/transport/types.d.ts +129 -0
  49. package/dist/util/path.d.ts +4 -0
  50. package/dist/util/sanitize.d.ts +10 -0
  51. package/dist/util/text.d.ts +3 -0
  52. package/dist/version.d.ts +2 -0
  53. package/dist/weixin/agent/interface.d.ts +1 -0
  54. package/dist/weixin/api/config-cache.d.ts +18 -1
  55. package/dist/weixin/auth/accounts.d.ts +0 -1
  56. package/dist/weixin/bot.d.ts +11 -0
  57. package/dist/weixin/messaging/completion-notice.d.ts +2 -0
  58. package/dist/weixin/messaging/foreground-gate.d.ts +3 -0
  59. package/dist/weixin/messaging/handle-weixin-message-turn.d.ts +4 -0
  60. package/dist/weixin/messaging/inbound.d.ts +7 -0
  61. package/dist/weixin/messaging/quota-manager.d.ts +15 -1
  62. package/dist/weixin/monitor/monitor.d.ts +8 -0
  63. package/package.json +1 -1
@@ -826,6 +826,19 @@ async function defaultRunProcessCommand(command, args) {
826
826
  }
827
827
  var init_terminate_process_tree = () => {};
828
828
 
829
+ // src/util/text.ts
830
+ function truncateText(text, maxLength, ellipsis = "…") {
831
+ if (text.length <= maxLength)
832
+ return text;
833
+ return text.slice(0, maxLength - ellipsis.length) + ellipsis;
834
+ }
835
+ function escapeForDoubleQuotes(input) {
836
+ return input.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
837
+ }
838
+ function quoteIfNeeded(input) {
839
+ return `"${escapeForDoubleQuotes(input)}"`;
840
+ }
841
+
829
842
  // src/transport/acpx-queue-owner-launcher.ts
830
843
  import { createHash } from "node:crypto";
831
844
  import { spawn as spawn3 } from "node:child_process";
@@ -882,7 +895,13 @@ class AcpxQueueOwnerLauncher {
882
895
  const key = input.acpxRecordId;
883
896
  const previous = this.launchLocks.get(key) ?? Promise.resolve();
884
897
  const next = previous.then(() => this.doLaunch(input), () => this.doLaunch(input));
885
- this.launchLocks.set(key, next.catch(() => {}));
898
+ const tracked = next.catch(() => {});
899
+ this.launchLocks.set(key, tracked);
900
+ tracked.finally(() => {
901
+ if (this.launchLocks.get(key) === tracked) {
902
+ this.launchLocks.delete(key);
903
+ }
904
+ });
886
905
  return next;
887
906
  }
888
907
  async doLaunch(input) {
@@ -1013,7 +1032,7 @@ function resolveDefaultWeacpxCommand(env) {
1013
1032
  return "weacpx";
1014
1033
  }
1015
1034
  function quoteCommandPart(value) {
1016
- return `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
1035
+ return quoteIfNeeded(value);
1017
1036
  }
1018
1037
  var init_acpx_queue_owner_launcher = __esm(() => {
1019
1038
  init_spawn_command();
@@ -1032,8 +1051,46 @@ function permissionModeToFlag(permissionMode) {
1032
1051
  }
1033
1052
  }
1034
1053
 
1035
- // src/transport/agent-session-list.ts
1054
+ // src/util/path.ts
1036
1055
  import path2 from "node:path";
1056
+ import { homedir as homedir3 } from "node:os";
1057
+ function normalizePath(input) {
1058
+ const expanded = expandHome(input);
1059
+ if (isWindowsLikePath(expanded)) {
1060
+ return path2.win32.normalize(expanded).replace(/\\/g, "/");
1061
+ }
1062
+ return path2.posix.normalize(expanded.replace(/\\/g, "/"));
1063
+ }
1064
+ function basenameForPath(input) {
1065
+ const normalized = normalizePath(input);
1066
+ if (ROOT_PATH_RE.test(normalized)) {
1067
+ return normalized;
1068
+ }
1069
+ const base = path2.posix.basename(normalized);
1070
+ return base || normalized;
1071
+ }
1072
+ function isSamePath(left, right) {
1073
+ const normalizedLeft = normalizePath(left);
1074
+ const normalizedRight = normalizePath(right);
1075
+ if (isWindowsLikePath(normalizedLeft) || isWindowsLikePath(normalizedRight)) {
1076
+ return normalizedLeft.toLowerCase() === normalizedRight.toLowerCase();
1077
+ }
1078
+ return normalizedLeft === normalizedRight;
1079
+ }
1080
+ function isWindowsLikePath(input) {
1081
+ return WINDOWS_DRIVE_PATH_RE.test(input) || WINDOWS_UNC_PATH_RE.test(input);
1082
+ }
1083
+ function expandHome(input) {
1084
+ return input.startsWith("~") ? homedir3() + input.slice(1) : input;
1085
+ }
1086
+ var WINDOWS_DRIVE_PATH_RE, WINDOWS_UNC_PATH_RE, ROOT_PATH_RE;
1087
+ var init_path = __esm(() => {
1088
+ WINDOWS_DRIVE_PATH_RE = /^[a-zA-Z]:[\\/]/;
1089
+ WINDOWS_UNC_PATH_RE = /^\\\\/;
1090
+ ROOT_PATH_RE = /^(\/|[a-zA-Z]:\/?)$/;
1091
+ });
1092
+
1093
+ // src/transport/agent-session-list.ts
1037
1094
  function isUnknownFilterCwdOption(output) {
1038
1095
  return /(?:unknown|unrecognized) option/i.test(output) && output.includes("--filter-cwd");
1039
1096
  }
@@ -1080,27 +1137,12 @@ function isAgentSessionListResult(value) {
1080
1137
  function filterAgentSessionListByCwd(result, cwd) {
1081
1138
  return {
1082
1139
  ...result,
1083
- sessions: result.sessions.filter((session) => session.cwd && sameAgentSessionCwd(session.cwd, cwd))
1140
+ sessions: result.sessions.filter((session) => session.cwd && isSamePath(session.cwd, cwd))
1084
1141
  };
1085
1142
  }
1086
- function sameAgentSessionCwd(left, right) {
1087
- const normalizedLeft = normalizeAgentSessionCwd(left);
1088
- const normalizedRight = normalizeAgentSessionCwd(right);
1089
- if (isWindowsLikePath(normalizedLeft) || isWindowsLikePath(normalizedRight)) {
1090
- return normalizedLeft.toLowerCase() === normalizedRight.toLowerCase();
1091
- }
1092
- return normalizedLeft === normalizedRight;
1093
- }
1094
- function normalizeAgentSessionCwd(input) {
1095
- if (isWindowsLikePath(input)) {
1096
- return path2.win32.normalize(input).replace(/\\/g, "/");
1097
- }
1098
- return path2.posix.normalize(input.replace(/\\/g, "/"));
1099
- }
1100
- function isWindowsLikePath(input) {
1101
- return /^[a-zA-Z]:[\\/]/.test(input) || input.startsWith("\\\\");
1102
- }
1103
- var init_agent_session_list = () => {};
1143
+ var init_agent_session_list = __esm(() => {
1144
+ init_path();
1145
+ });
1104
1146
 
1105
1147
  // src/bridge/bridge-main.ts
1106
1148
  import { createInterface } from "node:readline";
@@ -1161,7 +1203,7 @@ init_prompt_output();
1161
1203
  init_prompt_media();
1162
1204
  init_streaming_prompt();
1163
1205
  import { copyFile, readdir } from "node:fs/promises";
1164
- import { homedir as homedir3 } from "node:os";
1206
+ import { homedir as homedir4 } from "node:os";
1165
1207
  import { dirname as dirname2, join as join3, win32 } from "node:path";
1166
1208
  import { spawn as spawn4 } from "node:child_process";
1167
1209
 
@@ -1636,7 +1678,7 @@ async function tryRepairAcpxSessionIndex(deps = {}) {
1636
1678
  if (platform !== "win32") {
1637
1679
  return false;
1638
1680
  }
1639
- const home = deps.home ?? process.env.HOME ?? process.env.USERPROFILE ?? homedir3();
1681
+ const home = deps.home ?? process.env.HOME ?? process.env.USERPROFILE ?? homedir4();
1640
1682
  if (!home) {
1641
1683
  return false;
1642
1684
  }
@@ -1,8 +1,11 @@
1
1
  import type { Agent as ChatAgent } from "../weixin/agent/interface.js";
2
+ import type { CommandHint } from "../commands/command-hints.js";
2
3
  import type { OrchestrationTaskRecord } from "../orchestration/orchestration-types.js";
3
4
  import type { AppLogger } from "../logging/app-logger.js";
4
5
  import type { PendingFinalChunk } from "../weixin/messaging/quota-manager.js";
5
6
  import type { PerfTracer } from "../perf/perf-tracer.js";
7
+ import type { SessionService } from "../sessions/session-service.js";
8
+ import type { ActiveTurnRegistry } from "../sessions/active-turn-registry.js";
6
9
  export type { ChatAgent };
7
10
  export interface OutboundQuota {
8
11
  onInbound(chatKey: string): void;
@@ -50,6 +53,17 @@ export interface ChannelStartInput {
50
53
  quota: OutboundQuota;
51
54
  logger: AppLogger;
52
55
  perfTracer?: PerfTracer;
56
+ /**
57
+ * Logical session service. Session-aware channels read it for dispatch-time
58
+ * session binding (current alias) and to persist background turn results.
59
+ */
60
+ sessions?: SessionService;
61
+ /** Shared in-flight turn registry for dispatch-time foreground tracking. */
62
+ activeTurns?: ActiveTurnRegistry;
63
+ /** weacpx 内置命令目录,供支持输入框命令提示的频道使用。 */
64
+ commandHints?: CommandHint[];
65
+ /** weacpx 核心版本字符串,供需要它的频道(如命令同步元数据)使用。 */
66
+ coreVersion?: string;
53
67
  }
54
68
  export interface OrchestrationDeliveryCallbacks {
55
69
  markTaskNoticeDelivered: (taskId: string, accountId: string) => Promise<void>;