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.
Files changed (118) hide show
  1. package/README.md +10 -564
  2. package/package.json +10 -72
  3. package/plugin-api.d.ts +2 -0
  4. package/plugin-api.js +5 -0
  5. package/LICENSE +0 -21
  6. package/config.example.json +0 -44
  7. package/dist/bridge/bridge-main.js +0 -2120
  8. package/dist/channels/channel-scope.d.ts +0 -17
  9. package/dist/channels/cli/provider.d.ts +0 -73
  10. package/dist/channels/cli/registry.d.ts +0 -7
  11. package/dist/channels/cli/weixin-provider.d.ts +0 -2
  12. package/dist/channels/create-channel.d.ts +0 -16
  13. package/dist/channels/media-store.d.ts +0 -29
  14. package/dist/channels/media-types.d.ts +0 -28
  15. package/dist/channels/outbound-media-safety.d.ts +0 -7
  16. package/dist/channels/plugin.d.ts +0 -9
  17. package/dist/channels/types.d.ts +0 -115
  18. package/dist/channels/weixin-channel.d.ts +0 -25
  19. package/dist/cli.js +0 -46971
  20. package/dist/commands/command-hints.d.ts +0 -11
  21. package/dist/commands/command-list.d.ts +0 -3
  22. package/dist/commands/config-clone.d.ts +0 -2
  23. package/dist/commands/handlers/agent-handler.d.ts +0 -6
  24. package/dist/commands/handlers/config-handler.d.ts +0 -5
  25. package/dist/commands/handlers/later-handler.d.ts +0 -21
  26. package/dist/commands/handlers/orchestration-handler.d.ts +0 -16
  27. package/dist/commands/handlers/permission-handler.d.ts +0 -9
  28. package/dist/commands/handlers/session-handler.d.ts +0 -37
  29. package/dist/commands/handlers/workspace-handler.d.ts +0 -8
  30. package/dist/commands/help/help-registry.d.ts +0 -4
  31. package/dist/commands/help/help-types.d.ts +0 -12
  32. package/dist/commands/parse-command.d.ts +0 -175
  33. package/dist/commands/router-types.d.ts +0 -144
  34. package/dist/commands/workspace-name.d.ts +0 -4
  35. package/dist/commands/workspace-path.d.ts +0 -4
  36. package/dist/config/agent-templates.d.ts +0 -4
  37. package/dist/config/config-store.d.ts +0 -13
  38. package/dist/config/load-config.d.ts +0 -10
  39. package/dist/config/resolve-agent-command.d.ts +0 -2
  40. package/dist/config/types.d.ts +0 -85
  41. package/dist/formatting/render-text.d.ts +0 -23
  42. package/dist/logging/app-logger.d.ts +0 -23
  43. package/dist/logging/rotating-file-writer.d.ts +0 -2
  44. package/dist/orchestration/async-mutex.d.ts +0 -4
  45. package/dist/orchestration/build-coordinator-prompt.d.ts +0 -66
  46. package/dist/orchestration/orchestration-service.d.ts +0 -471
  47. package/dist/orchestration/orchestration-types.d.ts +0 -181
  48. package/dist/orchestration/progress-line-parser.d.ts +0 -19
  49. package/dist/orchestration/render-delegate-group-result.d.ts +0 -6
  50. package/dist/orchestration/render-delegate-question-package.d.ts +0 -21
  51. package/dist/orchestration/render-delegate-result.d.ts +0 -2
  52. package/dist/orchestration/task-watch-timeouts.d.ts +0 -5
  53. package/dist/perf/perf-log-writer.d.ts +0 -25
  54. package/dist/perf/perf-tracer.d.ts +0 -54
  55. package/dist/plugin-api.d.ts +0 -9
  56. package/dist/plugin-api.js +0 -180
  57. package/dist/plugins/compatibility.d.ts +0 -16
  58. package/dist/plugins/known-plugins.d.ts +0 -9
  59. package/dist/plugins/types.d.ts +0 -18
  60. package/dist/scheduled/parse-later-time.d.ts +0 -11
  61. package/dist/scheduled/scheduled-render.d.ts +0 -7
  62. package/dist/scheduled/scheduled-service.d.ts +0 -41
  63. package/dist/scheduled/scheduled-types.d.ts +0 -29
  64. package/dist/sessions/session-service.d.ts +0 -83
  65. package/dist/state/state-store.d.ts +0 -8
  66. package/dist/state/types.d.ts +0 -44
  67. package/dist/transport/tool-event-mode.d.ts +0 -14
  68. package/dist/transport/types.d.ts +0 -129
  69. package/dist/util/path.d.ts +0 -4
  70. package/dist/util/private-file.d.ts +0 -26
  71. package/dist/util/sanitize.d.ts +0 -10
  72. package/dist/util/text.d.ts +0 -3
  73. package/dist/version.d.ts +0 -3
  74. package/dist/weixin/agent/interface.d.ts +0 -78
  75. package/dist/weixin/api/api.d.ts +0 -76
  76. package/dist/weixin/api/config-cache.d.ts +0 -18
  77. package/dist/weixin/api/session-guard.d.ts +0 -17
  78. package/dist/weixin/api/types.d.ts +0 -203
  79. package/dist/weixin/auth/accounts.d.ts +0 -69
  80. package/dist/weixin/auth/login-qr.d.ts +0 -37
  81. package/dist/weixin/bot.d.ts +0 -56
  82. package/dist/weixin/cdn/aes-ecb.d.ts +0 -6
  83. package/dist/weixin/cdn/cdn-upload.d.ts +0 -17
  84. package/dist/weixin/cdn/cdn-url.d.ts +0 -11
  85. package/dist/weixin/cdn/pic-decrypt.d.ts +0 -9
  86. package/dist/weixin/cdn/upload.d.ts +0 -42
  87. package/dist/weixin/index.d.ts +0 -6
  88. package/dist/weixin/media/media-download.d.ts +0 -18
  89. package/dist/weixin/media/mime.d.ts +0 -6
  90. package/dist/weixin/media/silk-transcode.d.ts +0 -8
  91. package/dist/weixin/messaging/conversation-executor.d.ts +0 -7
  92. package/dist/weixin/messaging/debug-mode.d.ts +0 -9
  93. package/dist/weixin/messaging/deliver-coordinator-message.d.ts +0 -22
  94. package/dist/weixin/messaging/deliver-orchestration-task-notice.d.ts +0 -18
  95. package/dist/weixin/messaging/deliver-orchestration-task-progress.d.ts +0 -16
  96. package/dist/weixin/messaging/error-notice.d.ts +0 -13
  97. package/dist/weixin/messaging/execute-chat-turn.d.ts +0 -12
  98. package/dist/weixin/messaging/final-heads-up.d.ts +0 -5
  99. package/dist/weixin/messaging/handle-weixin-message-turn.d.ts +0 -32
  100. package/dist/weixin/messaging/inbound.d.ts +0 -80
  101. package/dist/weixin/messaging/markdown-filter.d.ts +0 -45
  102. package/dist/weixin/messaging/orchestration-notice-accounts.d.ts +0 -2
  103. package/dist/weixin/messaging/quota-errors.d.ts +0 -8
  104. package/dist/weixin/messaging/quota-manager.d.ts +0 -44
  105. package/dist/weixin/messaging/scheduled-turn.d.ts +0 -22
  106. package/dist/weixin/messaging/send-errors.d.ts +0 -39
  107. package/dist/weixin/messaging/send-media.d.ts +0 -23
  108. package/dist/weixin/messaging/send-orchestration-notice.d.ts +0 -10
  109. package/dist/weixin/messaging/send.d.ts +0 -73
  110. package/dist/weixin/messaging/slash-commands.d.ts +0 -40
  111. package/dist/weixin/monitor/consumer-lock.d.ts +0 -24
  112. package/dist/weixin/monitor/monitor.d.ts +0 -30
  113. package/dist/weixin/storage/ensure-dir.d.ts +0 -1
  114. package/dist/weixin/storage/state-dir.d.ts +0 -2
  115. package/dist/weixin/storage/sync-buf.d.ts +0 -20
  116. package/dist/weixin/util/logger.d.ts +0 -14
  117. package/dist/weixin/util/random.d.ts +0 -10
  118. package/dist/weixin/util/redact.d.ts +0 -21
@@ -1,181 +0,0 @@
1
- export type OrchestrationTaskStatus = "needs_confirmation" | "queued" | "running" | "blocked" | "waiting_for_human" | "completed" | "failed" | "cancelled";
2
- export type OrchestrationSourceKind = "human" | "coordinator" | "worker";
3
- export interface OrchestrationOpenQuestionRecord {
4
- questionId: string;
5
- question: string;
6
- whyBlocked: string;
7
- whatIsNeeded: string;
8
- askedAt: string;
9
- status: "open" | "answered" | "superseded";
10
- answeredAt?: string;
11
- answerSource?: "coordinator" | "human";
12
- answerText?: string;
13
- packageId?: string;
14
- lastWakeError?: string;
15
- lastResumeError?: string;
16
- }
17
- export interface OrchestrationReviewPendingRecord {
18
- reviewId: string;
19
- reason: "misrouted_answer";
20
- createdAt: string;
21
- resultId: string;
22
- resultText: string;
23
- }
24
- export interface OrchestrationCorrectionPendingRecord {
25
- requestedAt: string;
26
- reason: "misrouted_answer";
27
- }
28
- export interface OrchestrationTaskRecord {
29
- taskId: string;
30
- sourceHandle: string;
31
- sourceKind: OrchestrationSourceKind;
32
- coordinatorSession: string;
33
- workerSession?: string;
34
- workspace: string;
35
- cwd?: string;
36
- targetAgent: string;
37
- role?: string;
38
- task: string;
39
- status: OrchestrationTaskStatus;
40
- summary: string;
41
- resultText: string;
42
- createdAt: string;
43
- updatedAt: string;
44
- chatKey?: string;
45
- replyContextToken?: string;
46
- accountId?: string;
47
- deliveryAccountId?: string;
48
- coordinatorInjectedAt?: string;
49
- cancelRequestedAt?: string;
50
- cancelCompletedAt?: string;
51
- lastCancelError?: string;
52
- noticePending?: boolean;
53
- noticeSentAt?: string;
54
- lastNoticeError?: string;
55
- injectionPending?: boolean;
56
- injectionAppliedAt?: string;
57
- lastInjectionError?: string;
58
- lastProgressAt?: string;
59
- lastProgressSummary?: string;
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;
65
- openQuestion?: OrchestrationOpenQuestionRecord;
66
- reviewPending?: OrchestrationReviewPendingRecord;
67
- correctionPending?: OrchestrationCorrectionPendingRecord;
68
- eventSeq?: number;
69
- events?: OrchestrationTaskEventRecord[];
70
- }
71
- export type OrchestrationTaskEventType = "created" | "progress" | "status_changed" | "attention_required" | "cancel_requested";
72
- export interface OrchestrationTaskEventRecord {
73
- seq: number;
74
- at: string;
75
- type: OrchestrationTaskEventType;
76
- status?: OrchestrationTaskStatus;
77
- summary?: string;
78
- message?: string;
79
- }
80
- export interface OrchestrationGroupRecord {
81
- groupId: string;
82
- coordinatorSession: string;
83
- title: string;
84
- createdAt: string;
85
- updatedAt: string;
86
- coordinatorInjectedAt?: string;
87
- injectionPending?: boolean;
88
- injectionAppliedAt?: string;
89
- lastInjectionError?: string;
90
- }
91
- export interface OrchestrationGroupSummary {
92
- group: OrchestrationGroupRecord;
93
- tasks: OrchestrationTaskRecord[];
94
- totalTasks: number;
95
- pendingApprovalTasks: number;
96
- runningTasks: number;
97
- completedTasks: number;
98
- failedTasks: number;
99
- cancelledTasks: number;
100
- terminal: boolean;
101
- }
102
- export interface ExternalCoordinatorRecord {
103
- coordinatorSession: string;
104
- workspace?: string;
105
- createdAt: string;
106
- updatedAt: string;
107
- defaultTargetAgent?: string;
108
- }
109
- export interface WorkerBindingRecord {
110
- sourceHandle: string;
111
- coordinatorSession: string;
112
- workspace: string;
113
- cwd?: string;
114
- targetAgent: string;
115
- role?: string;
116
- /** True for ephemeral parallel-slot sessions; excluded from findReusableWorkerSession matching. */
117
- ephemeral?: boolean;
118
- }
119
- export interface OrchestrationQueuedQuestionRecord {
120
- taskId: string;
121
- questionId: string;
122
- enqueuedAt: string;
123
- }
124
- export interface OrchestrationCoordinatorQuestionStateRecord {
125
- activePackageId?: string;
126
- queuedQuestions: OrchestrationQueuedQuestionRecord[];
127
- }
128
- export interface OrchestrationCoordinatorRouteContextRecord {
129
- coordinatorSession: string;
130
- chatKey: string;
131
- sessionAlias?: string;
132
- accountId?: string;
133
- replyContextToken?: string;
134
- channel?: string;
135
- chatType?: "direct" | "group";
136
- senderId?: string;
137
- senderName?: string;
138
- groupId?: string;
139
- isOwner?: boolean;
140
- updatedAt: string;
141
- }
142
- export interface OrchestrationHumanQuestionPackageMessageRecord {
143
- messageId: string;
144
- kind: "initial" | "follow_up";
145
- promptText: string;
146
- createdAt: string;
147
- taskQuestions?: Array<{
148
- taskId: string;
149
- questionId: string;
150
- }>;
151
- routeChatKey?: string;
152
- routeAccountId?: string;
153
- routeReplyContextToken?: string;
154
- deliveredAt?: string;
155
- deliveredChatKey?: string;
156
- deliveryAccountId?: string;
157
- lastDeliveryError?: string;
158
- }
159
- export interface OrchestrationHumanQuestionPackageRecord {
160
- packageId: string;
161
- coordinatorSession: string;
162
- status: "active" | "closed";
163
- createdAt: string;
164
- updatedAt: string;
165
- closedAt?: string;
166
- initialTaskIds: string[];
167
- openTaskIds: string[];
168
- resolvedTaskIds: string[];
169
- messages: OrchestrationHumanQuestionPackageMessageRecord[];
170
- awaitingReplyMessageId?: string;
171
- }
172
- export interface OrchestrationState {
173
- tasks: Record<string, OrchestrationTaskRecord>;
174
- workerBindings: Record<string, WorkerBindingRecord>;
175
- groups: Record<string, OrchestrationGroupRecord>;
176
- humanQuestionPackages: Record<string, OrchestrationHumanQuestionPackageRecord>;
177
- coordinatorQuestionState: Record<string, OrchestrationCoordinatorQuestionStateRecord>;
178
- coordinatorRoutes: Record<string, OrchestrationCoordinatorRouteContextRecord>;
179
- externalCoordinators: Record<string, ExternalCoordinatorRecord>;
180
- }
181
- export declare function createEmptyOrchestrationState(): OrchestrationState;
@@ -1,19 +0,0 @@
1
- export declare const MAX_PROGRESS_SUMMARY_LENGTH = 500;
2
- export interface ProgressLineFeedOptions {
3
- /**
4
- * True when the caller is passing a complete semantic text segment rather
5
- * than arbitrary stream bytes. This lets progress paragraphs without a
6
- * trailing newline surface immediately while keeping the default raw-stream
7
- * parser conservative about partial chunks.
8
- */
9
- segmentComplete?: boolean;
10
- }
11
- export declare class ProgressLineBuffer {
12
- private pending;
13
- feed(segment: string, options?: ProgressLineFeedOptions): string[];
14
- flush(): string[];
15
- private extractLine;
16
- private trimPendingIfHopeless;
17
- }
18
- export declare function sanitizeProgressSummary(summary: string): string;
19
- export declare function stripProgressLines(text: string): string;
@@ -1,6 +0,0 @@
1
- import type { OrchestrationGroupRecord, OrchestrationTaskRecord } from "./orchestration-types";
2
- export declare function renderDelegateGroupResult(group: OrchestrationGroupRecord, tasks: OrchestrationTaskRecord[]): string;
3
- export declare function renderDelegateGroupResultBlocks(groups: Array<{
4
- group: OrchestrationGroupRecord;
5
- tasks: OrchestrationTaskRecord[];
6
- }>): string;
@@ -1,21 +0,0 @@
1
- interface BlockedTaskInput {
2
- taskId: string;
3
- workerSession?: string;
4
- targetAgent: string;
5
- question: string;
6
- whyBlocked: string;
7
- whatIsNeeded: string;
8
- }
9
- interface ContestedReviewInput {
10
- taskId: string;
11
- reviewId: string;
12
- resultId: string;
13
- resultText: string;
14
- }
15
- export interface RenderDelegateQuestionPackageInput {
16
- coordinatorSession: string;
17
- blockedTasks: BlockedTaskInput[];
18
- contestedReviews?: ContestedReviewInput[];
19
- }
20
- export declare function renderDelegateQuestionPackage(input: RenderDelegateQuestionPackageInput): string;
21
- export {};
@@ -1,2 +0,0 @@
1
- import type { OrchestrationTaskRecord } from "./orchestration-types";
2
- export declare function renderDelegateResultBlocks(tasks: OrchestrationTaskRecord[]): string;
@@ -1,5 +0,0 @@
1
- export declare const DEFAULT_TASK_WATCH_TIMEOUT_MS = 60000;
2
- export declare const MAX_TASK_WATCH_TIMEOUT_MS: number;
3
- export declare const DEFAULT_TASK_WATCH_POLL_INTERVAL_MS = 1000;
4
- export declare const MAX_TASK_WATCH_POLL_INTERVAL_MS = 10000;
5
- export declare const TASK_WATCH_RPC_TIMEOUT_PADDING_MS = 5000;
@@ -1,25 +0,0 @@
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;
@@ -1,54 +0,0 @@
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,9 +0,0 @@
1
- export type { ChannelPluginDefinition } from "./channels/plugin.js";
2
- export type { ChannelFactory, CreateChannelDeps } from "./channels/create-channel.js";
3
- export type { ChannelStartInput, ConsumerLock, ConsumerLockMetadata, ConsumerLockOptions, CoordinatorMessageInput, MessageChannelRuntime, ScheduledChannelMessageInput, OrchestrationDeliveryCallbacks, OutboundQuota, ToolUseEvent, ToolUseKind, ToolUseStatus, } from "./channels/types.js";
4
- export type { ChannelCliInput, ChannelCliIo, ChannelCliParseResult, ChannelCliProvider, ChannelCliValidationIssue, } from "./channels/cli/provider.js";
5
- export type { ChannelRuntimeConfig } from "./config/types.js";
6
- export type { CommandHint } from "./commands/command-hints.js";
7
- export type { AppLogger } from "./logging/app-logger.js";
8
- export type { WeacpxPlugin } from "./plugins/types.js";
9
- export { WEACPX_PLUGIN_API_VERSION, WEACPX_PLUGIN_API_SUPPORTED_VERSIONS, WEACPX_PLUGIN_MIN_CORE_VERSION, } from "./plugins/types.js";
@@ -1,180 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
28
- if (canCache)
29
- cache.set(mod, to);
30
- return to;
31
- };
32
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
- var __returnValue = (v) => v;
34
- function __exportSetter(name, newValue) {
35
- this[name] = __returnValue.bind(null, newValue);
36
- }
37
- var __export = (target, all) => {
38
- for (var name in all)
39
- __defProp(target, name, {
40
- get: all[name],
41
- enumerable: true,
42
- configurable: true,
43
- set: __exportSetter.bind(all, name)
44
- });
45
- };
46
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
47
- var __promiseAll = (args) => Promise.all(args);
48
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
49
-
50
- // src/plugins/compatibility.ts
51
- function normalizeCoreVersionForCompat(version) {
52
- const dashIdx = version.indexOf("-");
53
- const plusIdx = version.indexOf("+");
54
- const cutPositions = [dashIdx, plusIdx].filter((i) => i >= 0);
55
- if (cutPositions.length === 0)
56
- return version;
57
- return version.slice(0, Math.min(...cutPositions));
58
- }
59
- function compareSemver(a, b) {
60
- const lhs = parseSemverStrict(a);
61
- const rhs = parseSemverStrict(b);
62
- for (let i = 0;i < 3; i += 1) {
63
- if (lhs[i] < rhs[i])
64
- return -1;
65
- if (lhs[i] > rhs[i])
66
- return 1;
67
- }
68
- return 0;
69
- }
70
- function parseSemverStrict(value) {
71
- const match = SEMVER_RE.exec(value);
72
- if (!match)
73
- throw new Error(`malformed semver: ${value}`);
74
- return [Number(match[1]), Number(match[2]), Number(match[3])];
75
- }
76
- function parseRange(requirement) {
77
- const trimmed = requirement.trim();
78
- if (!trimmed)
79
- throw new Error("empty version requirement");
80
- if (trimmed.startsWith(">=")) {
81
- return { kind: "gte", base: parseSemverStrict(trimmed.slice(2).trim()), raw: trimmed };
82
- }
83
- if (trimmed.startsWith("^")) {
84
- return { kind: "caret", base: parseSemverStrict(trimmed.slice(1).trim()), raw: trimmed };
85
- }
86
- if (trimmed.startsWith(">") || trimmed.startsWith("<") || trimmed.startsWith("~") || trimmed.includes(" ")) {
87
- throw new Error(`unsupported version requirement: ${requirement}`);
88
- }
89
- return { kind: "exact", base: parseSemverStrict(trimmed), raw: trimmed };
90
- }
91
- function isVersionSatisfied(current, requirement) {
92
- const range = parseRange(requirement);
93
- const cur = parseSemverStrict(current);
94
- switch (range.kind) {
95
- case "exact":
96
- return cur[0] === range.base[0] && cur[1] === range.base[1] && cur[2] === range.base[2];
97
- case "gte":
98
- return cmpTuple(cur, range.base) >= 0;
99
- case "caret":
100
- if (cmpTuple(cur, range.base) < 0)
101
- return false;
102
- if (range.base[0] !== 0)
103
- return cur[0] === range.base[0];
104
- if (range.base[1] !== 0)
105
- return cur[0] === 0 && cur[1] === range.base[1];
106
- return cur[0] === 0 && cur[1] === 0 && cur[2] === range.base[2];
107
- }
108
- }
109
- function cmpTuple(a, b) {
110
- for (let i = 0;i < 3; i += 1) {
111
- if (a[i] < b[i])
112
- return -1;
113
- if (a[i] > b[i])
114
- return 1;
115
- }
116
- return 0;
117
- }
118
- function validatePluginCompatibility(metadata, context) {
119
- const { packageName, currentWeacpxVersion } = context;
120
- const apiVersion = metadata.apiVersion;
121
- if (typeof apiVersion !== "number") {
122
- throw new Error(`插件 ${packageName} 缺少必需字段 apiVersion`);
123
- }
124
- if (!WEACPX_PLUGIN_API_SUPPORTED_VERSIONS.includes(apiVersion)) {
125
- const supported = WEACPX_PLUGIN_API_SUPPORTED_VERSIONS.join(", ");
126
- throw new Error(`插件 ${packageName} 使用不支持的 apiVersion ${apiVersion}; supported: ${supported}; ` + `请安装与当前 weacpx 兼容的插件版本 (install a compatible plugin)`);
127
- }
128
- if (!currentWeacpxVersion || currentWeacpxVersion === "unknown") {
129
- return;
130
- }
131
- const normalizedCurrent = normalizeCoreVersionForCompat(currentWeacpxVersion);
132
- if (metadata.minWeacpxVersion !== undefined) {
133
- if (typeof metadata.minWeacpxVersion !== "string") {
134
- throw new Error(`插件 ${packageName} 元数据非法:minWeacpxVersion 必须是字符串 (invalid plugin metadata)`);
135
- }
136
- let satisfied;
137
- try {
138
- satisfied = compareSemver(normalizedCurrent, metadata.minWeacpxVersion) >= 0;
139
- } catch (error) {
140
- const detail = error instanceof Error ? error.message : String(error);
141
- throw new Error(`插件 ${packageName} 元数据非法:minWeacpxVersion (${detail}) (invalid plugin metadata)`);
142
- }
143
- if (!satisfied) {
144
- throw new Error(`插件 ${packageName} requires weacpx >=${metadata.minWeacpxVersion}; ` + `current is ${currentWeacpxVersion}; upgrade weacpx`);
145
- }
146
- }
147
- if (metadata.compatibleWeacpxVersions !== undefined) {
148
- if (typeof metadata.compatibleWeacpxVersions !== "string") {
149
- throw new Error(`插件 ${packageName} 元数据非法:compatibleWeacpxVersions 必须是字符串 (invalid plugin metadata)`);
150
- }
151
- let satisfied;
152
- try {
153
- satisfied = isVersionSatisfied(normalizedCurrent, metadata.compatibleWeacpxVersions);
154
- } catch (error) {
155
- const detail = error instanceof Error ? error.message : String(error);
156
- throw new Error(`插件 ${packageName} 元数据非法:compatibleWeacpxVersions (${detail}) (invalid plugin metadata)`);
157
- }
158
- if (!satisfied) {
159
- throw new Error(`插件 ${packageName} requires weacpx ${metadata.compatibleWeacpxVersions}; ` + `current is ${currentWeacpxVersion}; upgrade weacpx`);
160
- }
161
- }
162
- }
163
- var WEACPX_PLUGIN_API_VERSION = 1, WEACPX_PLUGIN_API_SUPPORTED_VERSIONS, WEACPX_PLUGIN_MIN_CORE_VERSION = "0.5.0", SEMVER_RE;
164
- var init_compatibility = __esm(() => {
165
- WEACPX_PLUGIN_API_SUPPORTED_VERSIONS = [1];
166
- SEMVER_RE = /^(\d+)\.(\d+)\.(\d+)$/;
167
- });
168
-
169
- // src/plugins/types.ts
170
- var init_types = __esm(() => {
171
- init_compatibility();
172
- });
173
-
174
- // src/plugin-api.ts
175
- init_types();
176
- export {
177
- WEACPX_PLUGIN_MIN_CORE_VERSION,
178
- WEACPX_PLUGIN_API_VERSION,
179
- WEACPX_PLUGIN_API_SUPPORTED_VERSIONS
180
- };
@@ -1,16 +0,0 @@
1
- export declare const WEACPX_PLUGIN_API_VERSION: 1;
2
- export declare const WEACPX_PLUGIN_API_SUPPORTED_VERSIONS: readonly number[];
3
- export declare const WEACPX_PLUGIN_MIN_CORE_VERSION: "0.5.0";
4
- export declare function normalizeCoreVersionForCompat(version: string): string;
5
- export declare function compareSemver(a: string, b: string): -1 | 0 | 1;
6
- export declare function isVersionSatisfied(current: string, requirement: string): boolean;
7
- export interface PluginCompatibilityMetadata {
8
- apiVersion?: unknown;
9
- minWeacpxVersion?: unknown;
10
- compatibleWeacpxVersions?: unknown;
11
- }
12
- export interface PluginCompatibilityContext {
13
- packageName: string;
14
- currentWeacpxVersion: string;
15
- }
16
- export declare function validatePluginCompatibility(metadata: PluginCompatibilityMetadata, context: PluginCompatibilityContext): void;
@@ -1,9 +0,0 @@
1
- export interface KnownPlugin {
2
- packageName: string;
3
- channels: string[];
4
- description: string;
5
- official: true;
6
- }
7
- export declare function listKnownPlugins(): KnownPlugin[];
8
- export declare function findKnownPluginByChannel(channelType: string): KnownPlugin | null;
9
- export declare function getMovedChannelInstallHint(channelType: string): string | null;
@@ -1,18 +0,0 @@
1
- import type { ChannelPluginDefinition } from "../channels/plugin.js";
2
- import { WEACPX_PLUGIN_API_VERSION, WEACPX_PLUGIN_API_SUPPORTED_VERSIONS, WEACPX_PLUGIN_MIN_CORE_VERSION } from "./compatibility.js";
3
- export { WEACPX_PLUGIN_API_VERSION, WEACPX_PLUGIN_API_SUPPORTED_VERSIONS, WEACPX_PLUGIN_MIN_CORE_VERSION, };
4
- export interface WeacpxPlugin {
5
- apiVersion: 1;
6
- name?: string;
7
- /**
8
- * Minimum weacpx core version required by this plugin (e.g. "0.3.3").
9
- * First-party plugins must declare this; third-party plugins are encouraged to.
10
- */
11
- minWeacpxVersion?: string;
12
- /**
13
- * Optional explicit weacpx core compatibility range, e.g. ">=0.3.3" or "^0.3.3".
14
- * If both `minWeacpxVersion` and `compatibleWeacpxVersions` are set, both must hold.
15
- */
16
- compatibleWeacpxVersions?: string;
17
- channels?: ChannelPluginDefinition[];
18
- }
@@ -1,11 +0,0 @@
1
- export type LaterTimeParseErrorCode = "missing_time" | "unrecognized_time" | "missing_message" | "past_today_time" | "too_soon" | "out_of_range";
2
- export type LaterTimeParseResult = {
3
- ok: true;
4
- executeAt: Date;
5
- messageStartIndex: number;
6
- } | {
7
- ok: false;
8
- code: LaterTimeParseErrorCode;
9
- value?: string;
10
- };
11
- export declare function parseLaterTime(tokens: string[], now?: Date): LaterTimeParseResult;
@@ -1,7 +0,0 @@
1
- import type { ScheduledTaskRecord } from "./scheduled-types";
2
- export declare function renderLaterHelp(): string;
3
- export declare function renderLaterUnsupportedChannel(): string;
4
- export declare function renderTaskCreated(task: ScheduledTaskRecord, displaySession: string): string;
5
- export declare function renderLaterList(tasks: ScheduledTaskRecord[], displaySession: (internalAlias: string) => string): string;
6
- export declare function preview(text: string): string;
7
- export declare function formatLocalDateTime(date: Date): string;
@@ -1,41 +0,0 @@
1
- import { AsyncMutex } from "../orchestration/async-mutex";
2
- import type { StateStore } from "../state/state-store";
3
- import type { AppState } from "../state/types";
4
- import type { ScheduledSessionMode, ScheduledTaskRecord } from "./scheduled-types";
5
- export interface CreateScheduledTaskInput {
6
- chatKey: string;
7
- sessionAlias: string;
8
- executeAt: Date;
9
- message: string;
10
- sessionMode?: ScheduledSessionMode;
11
- agent?: string;
12
- workspace?: string;
13
- accountId?: string;
14
- replyContextToken?: string;
15
- sourceLabel?: string;
16
- }
17
- export interface ScheduledTaskServiceOptions {
18
- now?: () => Date;
19
- generateId?: () => string;
20
- stateMutex?: AsyncMutex;
21
- }
22
- export declare class ScheduledTaskService {
23
- private readonly state;
24
- private readonly stateStore;
25
- private readonly now;
26
- private readonly generateId;
27
- private readonly stateMutex;
28
- private readonly claimedInThisSession;
29
- constructor(state: AppState, stateStore: Pick<StateStore, "save">, options?: ScheduledTaskServiceOptions);
30
- createTask(input: CreateScheduledTaskInput): Promise<ScheduledTaskRecord>;
31
- listPending(): ScheduledTaskRecord[];
32
- cancelPending(inputId: string): Promise<boolean>;
33
- markStartupMissed(): Promise<void>;
34
- claimDueTasks(): Promise<ScheduledTaskRecord[]>;
35
- markExecuted(id: string): Promise<void>;
36
- markFailed(id: string, error: unknown): Promise<void>;
37
- private nextId;
38
- private mutate;
39
- private save;
40
- }
41
- export declare function normalizeId(input: string): string;
@@ -1,29 +0,0 @@
1
- export declare const LATER_MIN_DELAY_MS = 10000;
2
- export declare const LATER_MAX_DELAY_MS: number;
3
- export declare const LATER_MESSAGE_PREVIEW_CHARS = 120;
4
- export type ScheduledTaskStatus = "pending" | "triggering" | "executed" | "cancelled" | "missed" | "failed";
5
- export type ScheduledSessionMode = "temp" | "bound";
6
- export interface ScheduledTaskRecord {
7
- id: string;
8
- chat_key: string;
9
- session_alias: string;
10
- /** Absent ⇒ "bound" (legacy tasks created before temp mode existed). */
11
- session_mode?: ScheduledSessionMode;
12
- /** Agent snapshot at creation; only set for "temp" tasks. */
13
- agent?: string;
14
- /** Workspace snapshot at creation; only set for "temp" tasks. */
15
- workspace?: string;
16
- execute_at: string;
17
- message: string;
18
- status: ScheduledTaskStatus;
19
- created_at: string;
20
- account_id?: string;
21
- reply_context_token?: string;
22
- source_label?: string;
23
- triggered_at?: string;
24
- executed_at?: string;
25
- cancelled_at?: string;
26
- missed_at?: string;
27
- failed_at?: string;
28
- last_error?: string;
29
- }