weacpx 0.5.2 → 0.6.1

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 (51) hide show
  1. package/README.md +15 -3
  2. package/dist/bridge/bridge-main.js +160 -4
  3. package/dist/channels/channel-scope.d.ts +8 -0
  4. package/dist/channels/types.d.ts +11 -0
  5. package/dist/channels/weixin-channel.d.ts +1 -0
  6. package/dist/cli.js +1115 -119
  7. package/dist/commands/command-hints.d.ts +11 -0
  8. package/dist/commands/command-list.d.ts +3 -0
  9. package/dist/commands/config-clone.d.ts +2 -0
  10. package/dist/commands/handlers/agent-handler.d.ts +6 -0
  11. package/dist/commands/handlers/config-handler.d.ts +5 -0
  12. package/dist/commands/handlers/later-handler.d.ts +21 -0
  13. package/dist/commands/handlers/orchestration-handler.d.ts +16 -0
  14. package/dist/commands/handlers/permission-handler.d.ts +9 -0
  15. package/dist/commands/handlers/session-handler.d.ts +37 -0
  16. package/dist/commands/handlers/workspace-handler.d.ts +8 -0
  17. package/dist/commands/help/help-registry.d.ts +4 -0
  18. package/dist/commands/help/help-types.d.ts +12 -0
  19. package/dist/commands/parse-command.d.ts +175 -0
  20. package/dist/commands/router-types.d.ts +144 -0
  21. package/dist/commands/workspace-name.d.ts +4 -0
  22. package/dist/commands/workspace-path.d.ts +4 -0
  23. package/dist/config/agent-templates.d.ts +4 -0
  24. package/dist/config/config-store.d.ts +13 -0
  25. package/dist/config/load-config.d.ts +10 -0
  26. package/dist/config/resolve-agent-command.d.ts +2 -0
  27. package/dist/formatting/render-text.d.ts +23 -0
  28. package/dist/orchestration/async-mutex.d.ts +4 -0
  29. package/dist/orchestration/build-coordinator-prompt.d.ts +66 -0
  30. package/dist/orchestration/orchestration-service.d.ts +471 -0
  31. package/dist/orchestration/progress-line-parser.d.ts +19 -0
  32. package/dist/orchestration/render-delegate-group-result.d.ts +6 -0
  33. package/dist/orchestration/render-delegate-question-package.d.ts +21 -0
  34. package/dist/orchestration/render-delegate-result.d.ts +2 -0
  35. package/dist/orchestration/task-watch-timeouts.d.ts +5 -0
  36. package/dist/plugin-api.d.ts +1 -0
  37. package/dist/scheduled/parse-later-time.d.ts +11 -0
  38. package/dist/scheduled/scheduled-render.d.ts +7 -0
  39. package/dist/scheduled/scheduled-service.d.ts +41 -0
  40. package/dist/scheduled/scheduled-types.d.ts +29 -0
  41. package/dist/sessions/session-service.d.ts +83 -0
  42. package/dist/state/state-store.d.ts +8 -0
  43. package/dist/state/types.d.ts +44 -0
  44. package/dist/transport/tool-event-mode.d.ts +14 -0
  45. package/dist/transport/types.d.ts +129 -0
  46. package/dist/util/path.d.ts +4 -0
  47. package/dist/util/sanitize.d.ts +10 -0
  48. package/dist/util/text.d.ts +3 -0
  49. package/dist/version.d.ts +2 -0
  50. package/dist/weixin/auth/accounts.d.ts +0 -1
  51. package/package.json +1 -1
@@ -0,0 +1,471 @@
1
+ import type { AppConfig } from "../config/types";
2
+ import type { AppLogger } from "../logging/app-logger";
3
+ import type { AppState } from "../state/types";
4
+ import type { ExternalCoordinatorRecord, OrchestrationCoordinatorRouteContextRecord, OrchestrationGroupRecord, OrchestrationGroupSummary, OrchestrationSourceKind, OrchestrationTaskEventRecord, OrchestrationTaskRecord, OrchestrationTaskStatus } from "./orchestration-types";
5
+ import { AsyncMutex } from "./async-mutex";
6
+ export interface RequestDelegateInput {
7
+ sourceHandle: string;
8
+ sourceKind: OrchestrationSourceKind;
9
+ coordinatorSession: string;
10
+ workspace: string;
11
+ cwd?: string;
12
+ targetAgent: string;
13
+ task: string;
14
+ role?: string;
15
+ groupId?: string;
16
+ chatKey?: string;
17
+ replyContextToken?: string;
18
+ accountId?: string;
19
+ parallel?: boolean;
20
+ }
21
+ export interface RequestDelegateRpcInput {
22
+ sourceHandle: string;
23
+ targetAgent: string;
24
+ task: string;
25
+ cwd?: string;
26
+ role?: string;
27
+ groupId?: string;
28
+ parallel?: boolean;
29
+ }
30
+ export interface RequestDelegateResult {
31
+ taskId: string;
32
+ status: OrchestrationTaskStatus;
33
+ workerSession: string;
34
+ }
35
+ export interface RegisterExternalCoordinatorInput {
36
+ coordinatorSession: string;
37
+ workspace?: string;
38
+ defaultTargetAgent?: string;
39
+ }
40
+ export interface RequestDelegateRpcResult {
41
+ taskId: string;
42
+ status: Extract<OrchestrationTaskStatus, "needs_confirmation" | "running" | "queued">;
43
+ workerSession?: string;
44
+ }
45
+ export interface RecordWorkerReplyInput {
46
+ taskId: string;
47
+ sourceHandle: string;
48
+ status?: Extract<OrchestrationTaskStatus, "completed" | "failed" | "cancelled">;
49
+ summary?: string;
50
+ resultText?: string;
51
+ }
52
+ export interface RecordTaskNoticeDeliveryInput {
53
+ taskId: string;
54
+ deliveryAccountId: string;
55
+ }
56
+ export interface MarkTaskErrorInput {
57
+ taskId: string;
58
+ errorMessage: string;
59
+ }
60
+ export interface CancelTaskInput {
61
+ taskId: string;
62
+ sourceHandle?: string;
63
+ coordinatorSession?: string;
64
+ }
65
+ export interface CancelWorkerTaskRequest {
66
+ taskId: string;
67
+ workerSession: string;
68
+ workspace: string;
69
+ cwd?: string;
70
+ targetAgent: string;
71
+ }
72
+ export interface ResumeWorkerTaskRequest {
73
+ taskId: string;
74
+ workerSession: string;
75
+ coordinatorSession: string;
76
+ workspace: string;
77
+ cwd?: string;
78
+ targetAgent: string;
79
+ answer: string;
80
+ }
81
+ export interface WakeCoordinatorRequest {
82
+ coordinatorSession: string;
83
+ }
84
+ export interface DeliverCoordinatorMessageRequest {
85
+ coordinatorSession: string;
86
+ chatKey: string;
87
+ accountId?: string;
88
+ replyContextToken?: string;
89
+ text: string;
90
+ }
91
+ type FrozenCoordinatorDeliveryRoute = Pick<DeliverCoordinatorMessageRequest, "chatKey" | "accountId" | "replyContextToken">;
92
+ export interface ConfirmTaskInput {
93
+ taskId: string;
94
+ coordinatorSession: string;
95
+ }
96
+ export interface WorkerRaiseQuestionInput {
97
+ taskId: string;
98
+ sourceHandle: string;
99
+ question: string;
100
+ whyBlocked: string;
101
+ whatIsNeeded: string;
102
+ }
103
+ export interface CoordinatorTaskQuestionRef {
104
+ taskId: string;
105
+ questionId: string;
106
+ }
107
+ export interface CoordinatorRequestHumanInputResult {
108
+ packageId?: string;
109
+ queuedTaskIds: string[];
110
+ }
111
+ export interface RetryHumanQuestionPackageDeliveryResult {
112
+ packageId: string;
113
+ messageId: string;
114
+ }
115
+ export interface ClaimedActiveHumanReply {
116
+ coordinatorSession: string;
117
+ packageId: string;
118
+ messageId: string;
119
+ chatKey: string;
120
+ promptText: string;
121
+ taskQuestions: CoordinatorTaskQuestionRef[];
122
+ queuedCount: number;
123
+ }
124
+ export interface ActiveHumanQuestionPackage {
125
+ packageId: string;
126
+ promptText: string;
127
+ awaitingReplyMessageId?: string;
128
+ deliveredChatKey?: string;
129
+ deliveryAccountId?: string;
130
+ routeReplyContextToken?: string;
131
+ deliveredAt?: string;
132
+ openTaskIds: string[];
133
+ messageTaskQuestions?: Array<{
134
+ taskId: string;
135
+ questionId: string;
136
+ }>;
137
+ openTaskQuestions?: Array<{
138
+ taskId: string;
139
+ questionId: string;
140
+ question: string;
141
+ whyBlocked: string;
142
+ whatIsNeeded: string;
143
+ }>;
144
+ queuedCount: number;
145
+ }
146
+ export interface OrchestrationServiceDeps {
147
+ now: () => Date;
148
+ createId: () => string;
149
+ loadState: () => Promise<AppState>;
150
+ saveState: (state: AppState) => Promise<void>;
151
+ stateMutex?: AsyncMutex;
152
+ config: AppConfig;
153
+ ensureWorkerSession: (request: EnsureWorkerSessionRequest) => Promise<string>;
154
+ dispatchWorkerTask: (request: DispatchWorkerTaskRequest) => Promise<void>;
155
+ cancelWorkerTask?: (request: CancelWorkerTaskRequest) => Promise<void>;
156
+ resumeWorkerTask?: (request: ResumeWorkerTaskRequest) => Promise<void>;
157
+ closeWorkerSession?: (request: {
158
+ workerSession: string;
159
+ coordinatorSession: string;
160
+ workspace: string;
161
+ cwd?: string;
162
+ targetAgent: string;
163
+ role?: string;
164
+ }) => Promise<void>;
165
+ wakeCoordinatorSession?: (request: WakeCoordinatorRequest) => Promise<void>;
166
+ deliverCoordinatorMessage?: (request: DeliverCoordinatorMessageRequest) => Promise<FrozenCoordinatorDeliveryRoute | void>;
167
+ interruptWorkerTask?: (request: CancelWorkerTaskRequest) => Promise<void>;
168
+ findReusableWorkerSession?: (request: ReusableWorkerLookupRequest) => Promise<string | null | undefined> | string | null | undefined;
169
+ logger?: AppLogger;
170
+ }
171
+ export interface EnsureWorkerSessionRequest {
172
+ workerSession: string;
173
+ sourceHandle: string;
174
+ sourceKind: OrchestrationSourceKind;
175
+ coordinatorSession: string;
176
+ workspace: string;
177
+ cwd?: string;
178
+ targetAgent: string;
179
+ role?: string;
180
+ }
181
+ export interface ReusableWorkerLookupRequest {
182
+ sourceHandle: string;
183
+ sourceKind: OrchestrationSourceKind;
184
+ coordinatorSession: string;
185
+ workspace: string;
186
+ cwd?: string;
187
+ targetAgent: string;
188
+ role?: string;
189
+ }
190
+ export interface DispatchWorkerTaskRequest {
191
+ taskId: string;
192
+ workerSession: string;
193
+ coordinatorSession: string;
194
+ workspace: string;
195
+ cwd?: string;
196
+ targetAgent: string;
197
+ role?: string;
198
+ task: string;
199
+ }
200
+ export interface CancelGroupResult {
201
+ summary: OrchestrationGroupSummary;
202
+ cancelledTaskIds: string[];
203
+ skippedTaskIds: string[];
204
+ }
205
+ export interface CleanTasksResult {
206
+ removedTasks: number;
207
+ removedBindings: number;
208
+ }
209
+ export type ResetGcTrigger = "startup" | "interval";
210
+ export interface PurgeExpiredResetCoordinatorsInput {
211
+ cutoffDays: number;
212
+ trigger: ResetGcTrigger;
213
+ }
214
+ export interface PurgeExpiredResetCoordinatorsResult {
215
+ candidates: number;
216
+ purgedCoordinators: number;
217
+ removed: {
218
+ tasks: number;
219
+ workerBindings: number;
220
+ groups: number;
221
+ coordinatorRoutes: number;
222
+ humanQuestionPackages: number;
223
+ coordinatorQuestionState: number;
224
+ };
225
+ }
226
+ export interface OrchestrationTaskFilter {
227
+ sourceHandle?: string;
228
+ coordinatorSession?: string;
229
+ workspace?: string;
230
+ targetAgent?: string;
231
+ role?: string;
232
+ status?: OrchestrationTaskStatus;
233
+ stuck?: boolean;
234
+ sort?: "updatedAt" | "createdAt";
235
+ order?: "asc" | "desc";
236
+ }
237
+ export interface WatchTaskInput {
238
+ coordinatorSession: string;
239
+ taskId: string;
240
+ afterSeq?: number;
241
+ mode?: "next_event" | "until_attention_or_terminal";
242
+ includeProgress?: boolean;
243
+ timeoutMs?: number;
244
+ pollIntervalMs?: number;
245
+ }
246
+ export interface WatchTaskResult {
247
+ status: "event" | "attention_required" | "terminal" | "timeout" | "not_found";
248
+ task: OrchestrationTaskRecord | null;
249
+ events: OrchestrationTaskEventRecord[];
250
+ nextAfterSeq: number;
251
+ historyTruncated?: boolean;
252
+ }
253
+ export declare function clampWatchTimeout(value: number | undefined): number;
254
+ export interface OrchestrationGroupListFilter {
255
+ coordinatorSession: string;
256
+ status?: "pending" | "running" | "terminal";
257
+ stuck?: boolean;
258
+ sort?: "updatedAt" | "createdAt";
259
+ order?: "asc" | "desc";
260
+ }
261
+ export declare class OrchestrationService {
262
+ private readonly deps;
263
+ private readonly stateMutex;
264
+ private readonly pendingWorkerSessions;
265
+ private readonly pendingLogicalTransportSessions;
266
+ /**
267
+ * Per-agent counter for parallel tasks that have passed the capacity gate
268
+ * but have not yet been persisted as `running` in state (i.e., they are
269
+ * between the gate mutate and the inner persist mutate). This closes the
270
+ * TOCTOU window: a concurrent `reconcileParallelSlots` Phase 3 or a second
271
+ * delegation can see these in-flight starts as occupied slots.
272
+ */
273
+ private readonly pendingParallelStarts;
274
+ constructor(deps: OrchestrationServiceDeps);
275
+ private mutate;
276
+ registerExternalCoordinator(input: RegisterExternalCoordinatorInput): Promise<ExternalCoordinatorRecord>;
277
+ createGroup(input: {
278
+ coordinatorSession: string;
279
+ title: string;
280
+ }): Promise<OrchestrationGroupRecord>;
281
+ getGroupSummary(input: {
282
+ groupId: string;
283
+ coordinatorSession: string;
284
+ }): Promise<OrchestrationGroupSummary | null>;
285
+ listGroupSummaries(input: OrchestrationGroupListFilter): Promise<OrchestrationGroupSummary[]>;
286
+ cancelGroup(input: {
287
+ groupId: string;
288
+ coordinatorSession: string;
289
+ }): Promise<CancelGroupResult>;
290
+ requestDelegate(input: RequestDelegateInput): Promise<RequestDelegateResult>;
291
+ requestDelegate(input: RequestDelegateRpcInput): Promise<RequestDelegateRpcResult>;
292
+ private requestDelegateForHuman;
293
+ requestDelegateFromRpc(input: RequestDelegateRpcInput): Promise<RequestDelegateRpcResult>;
294
+ private runAutoRunRpcWorkerTask;
295
+ private completeAutoRunStartupCancellation;
296
+ private cleanupAutoRunStartupBinding;
297
+ recordWorkerReply(input: RecordWorkerReplyInput): Promise<OrchestrationTaskRecord>;
298
+ markTaskNoticePending(taskId: string): Promise<OrchestrationTaskRecord>;
299
+ markTaskNoticeDelivered(taskId: string, deliveryAccountId: string): Promise<OrchestrationTaskRecord>;
300
+ markTaskNoticeFailed(input: MarkTaskErrorInput): Promise<OrchestrationTaskRecord>;
301
+ listPendingTaskNotices(): Promise<OrchestrationTaskRecord[]>;
302
+ recordTaskNoticeDelivery(input: RecordTaskNoticeDeliveryInput): Promise<OrchestrationTaskRecord>;
303
+ getTask(taskId: string): Promise<OrchestrationTaskRecord | null>;
304
+ watchTask(input: WatchTaskInput): Promise<WatchTaskResult>;
305
+ recordCoordinatorRouteContext(input: {
306
+ coordinatorSession: string;
307
+ chatKey: string;
308
+ sessionAlias?: string;
309
+ accountId?: string;
310
+ replyContextToken?: string;
311
+ channel?: string;
312
+ chatType?: "direct" | "group";
313
+ senderId?: string;
314
+ senderName?: string;
315
+ groupId?: string;
316
+ isOwner?: boolean;
317
+ }): Promise<OrchestrationCoordinatorRouteContextRecord>;
318
+ workerRaiseQuestion(input: WorkerRaiseQuestionInput): Promise<{
319
+ taskId: string;
320
+ questionId: string;
321
+ status: "blocked";
322
+ }>;
323
+ coordinatorAnswerQuestion(input: {
324
+ coordinatorSession: string;
325
+ taskId: string;
326
+ questionId: string;
327
+ answer: string;
328
+ }): Promise<OrchestrationTaskRecord>;
329
+ coordinatorRetractAnswer(input: {
330
+ coordinatorSession: string;
331
+ taskId: string;
332
+ questionId: string;
333
+ }): Promise<OrchestrationTaskRecord>;
334
+ coordinatorRequestHumanInput(input: {
335
+ coordinatorSession: string;
336
+ taskQuestions: CoordinatorTaskQuestionRef[];
337
+ promptText: string;
338
+ expectedActivePackageId?: string;
339
+ }): Promise<CoordinatorRequestHumanInputResult>;
340
+ retryHumanQuestionPackageDelivery(input: {
341
+ coordinatorSession: string;
342
+ packageId: string;
343
+ messageId: string;
344
+ }): Promise<RetryHumanQuestionPackageDeliveryResult>;
345
+ claimActiveHumanReply(input: {
346
+ coordinatorSession: string;
347
+ chatKey: string;
348
+ packageId: string;
349
+ messageId: string;
350
+ accountId?: string;
351
+ replyContextToken?: string;
352
+ }): Promise<ClaimedActiveHumanReply | null>;
353
+ getActiveHumanQuestionPackage(coordinatorSession: string): Promise<ActiveHumanQuestionPackage | null>;
354
+ coordinatorReviewContestedResult(input: {
355
+ coordinatorSession: string;
356
+ taskId: string;
357
+ reviewId: string;
358
+ decision: "accept" | "discard";
359
+ }): Promise<OrchestrationTaskRecord>;
360
+ listTasks(filter?: OrchestrationTaskFilter): Promise<OrchestrationTaskRecord[]>;
361
+ cleanTasks(coordinatorSession: string): Promise<CleanTasksResult>;
362
+ listSessionBlockingTasks(transportSession: string): Promise<OrchestrationTaskRecord[]>;
363
+ purgeSessionReferences(transportSession: string): Promise<CleanTasksResult>;
364
+ purgeExpiredResetCoordinators(input: PurgeExpiredResetCoordinatorsInput): Promise<PurgeExpiredResetCoordinatorsResult>;
365
+ listPendingCoordinatorResults(coordinatorSession: string): Promise<OrchestrationTaskRecord[]>;
366
+ listPendingCoordinatorBlockers(coordinatorSession: string): Promise<OrchestrationTaskRecord[]>;
367
+ listContestedCoordinatorResults(coordinatorSession: string): Promise<OrchestrationTaskRecord[]>;
368
+ listPendingCoordinatorGroups(coordinatorSession: string): Promise<OrchestrationGroupRecord[]>;
369
+ markCoordinatorResultsInjected(taskIds: string[]): Promise<void>;
370
+ markCoordinatorGroupsInjected(groupIds: string[]): Promise<void>;
371
+ markCoordinatorGroupsInjectionFailed(groupIds: string[], errorMessage: string): Promise<void>;
372
+ markTaskInjectionApplied(taskIds: string[]): Promise<void>;
373
+ markTaskInjectionFailed(taskIds: string[], errorMessage: string): Promise<void>;
374
+ recordTaskProgress(taskId: string, summary?: string): Promise<OrchestrationTaskRecord>;
375
+ listHeartbeatTasks(thresholdSeconds: number): Promise<OrchestrationTaskRecord[]>;
376
+ cancelTask(input: CancelTaskInput): Promise<OrchestrationTaskRecord>;
377
+ requestTaskCancellation(input: CancelTaskInput): Promise<OrchestrationTaskRecord>;
378
+ completeTaskCancellation(taskId: string): Promise<OrchestrationTaskRecord>;
379
+ failTaskCancellation(taskId: string, errorMessage: string): Promise<OrchestrationTaskRecord>;
380
+ approveTask(input: ConfirmTaskInput): Promise<OrchestrationTaskRecord>;
381
+ /**
382
+ * Resolves the transport worker-session name for a delegation.
383
+ *
384
+ * For parallel delegations a fresh unique name is minted by appending a
385
+ * `:p-<id>` suffix. That suffix is purely a naming convention for
386
+ * human/log readability — it MUST NOT be treated as the source of truth
387
+ * for ephemerality. `WorkerBindingRecord.ephemeral` is the authoritative
388
+ * marker for whether a session is an ephemeral parallel slot; no code
389
+ * should detect ephemerality by string-matching the session name.
390
+ */
391
+ private resolveWorkerSession;
392
+ private reserveProposedWorkerSession;
393
+ private ensureReservedWorkerSession;
394
+ reserveLogicalTransportSession(transportSession: string): Promise<() => Promise<void>>;
395
+ private buildGroupSummary;
396
+ private canInjectGroupIntoCoordinator;
397
+ private canInjectTaskIntoCoordinator;
398
+ private resolveRpcSourceContext;
399
+ private resolveRpcTargetLocation;
400
+ private assertRpcRequestAllowed;
401
+ private validateRequest;
402
+ private validateRpcRequest;
403
+ private normalizeWorkingDirectory;
404
+ private workspaceLabelFromCwd;
405
+ private cwdWorkerSessionPart;
406
+ private normalizeRole;
407
+ private normalizeGroupId;
408
+ private assertCoordinatorQuestionMatch;
409
+ private assertTaskAnswerIsWithinAwaitedHumanSnapshot;
410
+ private matchesFilter;
411
+ private isTerminalStatus;
412
+ private assertCoordinatorOwnership;
413
+ private assertNeedsConfirmation;
414
+ private assertGroupOwnership;
415
+ private ensureHumanQuestionPackages;
416
+ private ensureCoordinatorQuestionState;
417
+ private ensureCoordinatorRoutes;
418
+ private isExternalCoordinatorSession;
419
+ private assertWorkerSessionDoesNotConflictExternalCoordinator;
420
+ private assertWorkerSessionAvailable;
421
+ private hasActiveTaskWorkerSession;
422
+ /** Count parallel-slot tasks currently holding an acpx session for an agent. */
423
+ private countActiveParallelSlots;
424
+ /**
425
+ * Whether a new parallel task for this agent may start now, or must be queued.
426
+ * The cap comes from the `orchestration.maxParallelTasksPerAgent` config key.
427
+ */
428
+ private canStartParallelTask;
429
+ /**
430
+ * Idempotent reconciliation for parallel slots:
431
+ * 1. close acpx sessions of ephemeral parallel tasks that have terminated
432
+ * (terminal status, no pending review), and drop their worker bindings;
433
+ * 2. drain `queued` parallel tasks into running, up to the per-agent cap.
434
+ * Safe to call repeatedly; close failures are logged and never block draining.
435
+ */
436
+ reconcileParallelSlots(): Promise<void>;
437
+ private assertProposedWorkerSessionDoesNotConflictExternalCoordinator;
438
+ private ensureExternalCoordinators;
439
+ private ensureGroups;
440
+ private removeEmptyGroupsForCoordinator;
441
+ private removeCoordinatorMetadataIfUnused;
442
+ private isResetCoordinatorSession;
443
+ private collectResetCoordinatorCandidates;
444
+ private parseDateMs;
445
+ private resolveResetCoordinatorActivityAtMs;
446
+ private cascadeRemoveCoordinatorRecords;
447
+ private bumpGroupUpdated;
448
+ private getLatestDeliveredPackageMessage;
449
+ private snapshotCoordinatorDeliveryRoute;
450
+ private normalizeFrozenDeliveryRoute;
451
+ private serializeFrozenDeliveryRoute;
452
+ private resolveFrozenPackageMessageRoute;
453
+ private deliverHumanQuestionPackageMessage;
454
+ private recordPackageMessageDeliverySuccess;
455
+ private recordPackageMessageDeliveryError;
456
+ private recordOpenQuestionWakeError;
457
+ private handoffQueuedQuestions;
458
+ private restoreBlockedQuestionAfterResumeFailure;
459
+ private captureTaskHumanPackageContext;
460
+ private resolveTaskFromHumanPackage;
461
+ private detachTaskFromQuestionFlows;
462
+ private reopenActiveHumanPackageForTask;
463
+ private buildReplacementOpenQuestion;
464
+ private resolveLiveMessageTaskQuestions;
465
+ private logEvent;
466
+ private taskContext;
467
+ private groupContext;
468
+ private startWorkerCancellation;
469
+ private appendTaskEvent;
470
+ }
471
+ export {};
@@ -0,0 +1,19 @@
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;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,21 @@
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 {};
@@ -0,0 +1,2 @@
1
+ import type { OrchestrationTaskRecord } from "./orchestration-types";
2
+ export declare function renderDelegateResultBlocks(tasks: OrchestrationTaskRecord[]): string;
@@ -0,0 +1,5 @@
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;
@@ -3,6 +3,7 @@ export type { ChannelFactory, CreateChannelDeps } from "./channels/create-channe
3
3
  export type { ChannelStartInput, ConsumerLock, ConsumerLockMetadata, ConsumerLockOptions, CoordinatorMessageInput, MessageChannelRuntime, ScheduledChannelMessageInput, OrchestrationDeliveryCallbacks, OutboundQuota, ToolUseEvent, ToolUseKind, ToolUseStatus, } from "./channels/types.js";
4
4
  export type { ChannelCliInput, ChannelCliIo, ChannelCliParseResult, ChannelCliProvider, ChannelCliValidationIssue, } from "./channels/cli/provider.js";
5
5
  export type { ChannelRuntimeConfig } from "./config/types.js";
6
+ export type { CommandHint } from "./commands/command-hints.js";
6
7
  export type { AppLogger } from "./logging/app-logger.js";
7
8
  export type { WeacpxPlugin } from "./plugins/types.js";
8
9
  export { WEACPX_PLUGIN_API_VERSION, WEACPX_PLUGIN_API_SUPPORTED_VERSIONS, WEACPX_PLUGIN_MIN_CORE_VERSION, } from "./plugins/types.js";
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,41 @@
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;
@@ -0,0 +1,29 @@
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
+ }