weacpx 0.7.0 → 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.
- package/README.md +10 -564
- package/package.json +10 -72
- package/plugin-api.d.ts +2 -0
- package/plugin-api.js +5 -0
- package/LICENSE +0 -21
- package/config.example.json +0 -44
- package/dist/bridge/bridge-main.js +0 -2126
- package/dist/channels/channel-scope.d.ts +0 -17
- package/dist/channels/cli/provider.d.ts +0 -73
- package/dist/channels/cli/registry.d.ts +0 -7
- package/dist/channels/cli/weixin-provider.d.ts +0 -2
- package/dist/channels/create-channel.d.ts +0 -16
- package/dist/channels/media-store.d.ts +0 -29
- package/dist/channels/media-types.d.ts +0 -28
- package/dist/channels/outbound-media-safety.d.ts +0 -7
- package/dist/channels/plugin.d.ts +0 -9
- package/dist/channels/types.d.ts +0 -124
- package/dist/channels/weixin-channel.d.ts +0 -25
- package/dist/cli.js +0 -47662
- package/dist/commands/command-hints.d.ts +0 -11
- package/dist/commands/command-list.d.ts +0 -3
- package/dist/commands/config-clone.d.ts +0 -2
- package/dist/commands/handlers/agent-handler.d.ts +0 -6
- package/dist/commands/handlers/config-handler.d.ts +0 -5
- package/dist/commands/handlers/later-handler.d.ts +0 -21
- package/dist/commands/handlers/orchestration-handler.d.ts +0 -16
- package/dist/commands/handlers/permission-handler.d.ts +0 -9
- package/dist/commands/handlers/session-handler.d.ts +0 -39
- package/dist/commands/handlers/session-list-marker.d.ts +0 -1
- package/dist/commands/handlers/workspace-handler.d.ts +0 -8
- package/dist/commands/help/help-registry.d.ts +0 -4
- package/dist/commands/help/help-types.d.ts +0 -12
- package/dist/commands/parse-command.d.ts +0 -178
- package/dist/commands/router-types.d.ts +0 -144
- package/dist/commands/workspace-name.d.ts +0 -4
- package/dist/commands/workspace-path.d.ts +0 -4
- package/dist/config/agent-templates.d.ts +0 -4
- package/dist/config/config-store.d.ts +0 -13
- package/dist/config/load-config.d.ts +0 -10
- package/dist/config/resolve-agent-command.d.ts +0 -2
- package/dist/config/types.d.ts +0 -85
- package/dist/formatting/render-text.d.ts +0 -23
- package/dist/logging/app-logger.d.ts +0 -23
- package/dist/logging/rotating-file-writer.d.ts +0 -2
- package/dist/orchestration/async-mutex.d.ts +0 -4
- package/dist/orchestration/build-coordinator-prompt.d.ts +0 -66
- package/dist/orchestration/orchestration-service.d.ts +0 -471
- package/dist/orchestration/orchestration-types.d.ts +0 -181
- package/dist/orchestration/progress-line-parser.d.ts +0 -19
- package/dist/orchestration/render-delegate-group-result.d.ts +0 -6
- package/dist/orchestration/render-delegate-question-package.d.ts +0 -21
- package/dist/orchestration/render-delegate-result.d.ts +0 -2
- package/dist/orchestration/task-watch-timeouts.d.ts +0 -5
- package/dist/perf/perf-log-writer.d.ts +0 -25
- package/dist/perf/perf-tracer.d.ts +0 -54
- package/dist/plugin-api.d.ts +0 -18
- package/dist/plugin-api.js +0 -337
- package/dist/plugins/compatibility.d.ts +0 -16
- package/dist/plugins/known-plugins.d.ts +0 -9
- package/dist/plugins/types.d.ts +0 -18
- package/dist/runtime/conversation-executor.d.ts +0 -7
- package/dist/runtime/core-home.d.ts +0 -26
- package/dist/runtime/turn-lane.d.ts +0 -2
- package/dist/scheduled/parse-later-time.d.ts +0 -11
- package/dist/scheduled/scheduled-render.d.ts +0 -7
- package/dist/scheduled/scheduled-service.d.ts +0 -41
- package/dist/scheduled/scheduled-types.d.ts +0 -29
- package/dist/sessions/active-turn-registry.d.ts +0 -6
- package/dist/sessions/session-service.d.ts +0 -118
- package/dist/state/state-store.d.ts +0 -8
- package/dist/state/types.d.ts +0 -51
- package/dist/transport/tool-event-mode.d.ts +0 -14
- package/dist/transport/types.d.ts +0 -129
- package/dist/util/path.d.ts +0 -4
- package/dist/util/private-file.d.ts +0 -26
- package/dist/util/sanitize.d.ts +0 -10
- package/dist/util/text.d.ts +0 -3
- package/dist/version.d.ts +0 -3
- package/dist/weixin/agent/interface.d.ts +0 -79
- package/dist/weixin/api/api.d.ts +0 -76
- package/dist/weixin/api/config-cache.d.ts +0 -35
- package/dist/weixin/api/session-guard.d.ts +0 -17
- package/dist/weixin/api/types.d.ts +0 -203
- package/dist/weixin/auth/accounts.d.ts +0 -69
- package/dist/weixin/auth/login-qr.d.ts +0 -37
- package/dist/weixin/bot.d.ts +0 -67
- package/dist/weixin/cdn/aes-ecb.d.ts +0 -6
- package/dist/weixin/cdn/cdn-upload.d.ts +0 -17
- package/dist/weixin/cdn/cdn-url.d.ts +0 -11
- package/dist/weixin/cdn/pic-decrypt.d.ts +0 -9
- package/dist/weixin/cdn/upload.d.ts +0 -42
- package/dist/weixin/index.d.ts +0 -6
- package/dist/weixin/media/media-download.d.ts +0 -18
- package/dist/weixin/media/mime.d.ts +0 -6
- package/dist/weixin/media/silk-transcode.d.ts +0 -8
- package/dist/weixin/messaging/completion-notice.d.ts +0 -2
- package/dist/weixin/messaging/debug-mode.d.ts +0 -9
- package/dist/weixin/messaging/deliver-coordinator-message.d.ts +0 -22
- package/dist/weixin/messaging/deliver-orchestration-task-notice.d.ts +0 -18
- package/dist/weixin/messaging/deliver-orchestration-task-progress.d.ts +0 -16
- package/dist/weixin/messaging/error-notice.d.ts +0 -13
- package/dist/weixin/messaging/execute-chat-turn.d.ts +0 -12
- package/dist/weixin/messaging/final-heads-up.d.ts +0 -5
- package/dist/weixin/messaging/foreground-gate.d.ts +0 -3
- package/dist/weixin/messaging/handle-weixin-message-turn.d.ts +0 -36
- package/dist/weixin/messaging/inbound.d.ts +0 -87
- package/dist/weixin/messaging/markdown-filter.d.ts +0 -45
- package/dist/weixin/messaging/orchestration-notice-accounts.d.ts +0 -2
- package/dist/weixin/messaging/quota-errors.d.ts +0 -8
- package/dist/weixin/messaging/quota-manager.d.ts +0 -58
- package/dist/weixin/messaging/scheduled-turn.d.ts +0 -22
- package/dist/weixin/messaging/send-errors.d.ts +0 -39
- package/dist/weixin/messaging/send-media.d.ts +0 -23
- package/dist/weixin/messaging/send-orchestration-notice.d.ts +0 -10
- package/dist/weixin/messaging/send.d.ts +0 -73
- package/dist/weixin/messaging/slash-commands.d.ts +0 -40
- package/dist/weixin/monitor/consumer-lock.d.ts +0 -24
- package/dist/weixin/monitor/monitor.d.ts +0 -38
- package/dist/weixin/storage/ensure-dir.d.ts +0 -1
- package/dist/weixin/storage/state-dir.d.ts +0 -2
- package/dist/weixin/storage/sync-buf.d.ts +0 -20
- package/dist/weixin/util/logger.d.ts +0 -14
- package/dist/weixin/util/random.d.ts +0 -10
- package/dist/weixin/util/redact.d.ts +0 -21
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { LoggingLevel } from "../config/types";
|
|
2
|
-
type LogContextValue = string | number | boolean | null | undefined | Record<string, unknown> | unknown[];
|
|
3
|
-
interface LogContext {
|
|
4
|
-
[key: string]: LogContextValue;
|
|
5
|
-
}
|
|
6
|
-
interface CreateAppLoggerOptions {
|
|
7
|
-
filePath: string;
|
|
8
|
-
level: LoggingLevel;
|
|
9
|
-
maxSizeBytes: number;
|
|
10
|
-
maxFiles: number;
|
|
11
|
-
retentionDays: number;
|
|
12
|
-
now?: () => Date;
|
|
13
|
-
}
|
|
14
|
-
export interface AppLogger {
|
|
15
|
-
debug: (event: string, message: string, context?: LogContext) => Promise<void>;
|
|
16
|
-
info: (event: string, message: string, context?: LogContext) => Promise<void>;
|
|
17
|
-
error: (event: string, message: string, context?: LogContext) => Promise<void>;
|
|
18
|
-
cleanup: () => Promise<void>;
|
|
19
|
-
flush: () => Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
export declare function createNoopAppLogger(): AppLogger;
|
|
22
|
-
export declare function createAppLogger(options: CreateAppLoggerOptions): AppLogger;
|
|
23
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { OrchestrationGroupRecord, OrchestrationTaskRecord } from "./orchestration-types";
|
|
2
|
-
interface ActiveHumanQuestionPackageView {
|
|
3
|
-
packageId: string;
|
|
4
|
-
promptText: string;
|
|
5
|
-
awaitingReplyMessageId?: string;
|
|
6
|
-
deliveredChatKey?: string;
|
|
7
|
-
deliveryAccountId?: string;
|
|
8
|
-
routeReplyContextToken?: string;
|
|
9
|
-
deliveredAt?: string;
|
|
10
|
-
openTaskIds: string[];
|
|
11
|
-
messageTaskQuestions?: Array<{
|
|
12
|
-
taskId: string;
|
|
13
|
-
questionId: string;
|
|
14
|
-
}>;
|
|
15
|
-
openTaskQuestions?: Array<{
|
|
16
|
-
taskId: string;
|
|
17
|
-
questionId: string;
|
|
18
|
-
question: string;
|
|
19
|
-
whyBlocked: string;
|
|
20
|
-
whatIsNeeded: string;
|
|
21
|
-
}>;
|
|
22
|
-
queuedCount: number;
|
|
23
|
-
}
|
|
24
|
-
export declare function shouldBindHumanReply(input: {
|
|
25
|
-
chatKey?: string;
|
|
26
|
-
accountId?: string;
|
|
27
|
-
replyContextToken?: string;
|
|
28
|
-
activePackage?: {
|
|
29
|
-
awaitingReplyMessageId?: string;
|
|
30
|
-
deliveredChatKey?: string;
|
|
31
|
-
deliveryAccountId?: string;
|
|
32
|
-
routeReplyContextToken?: string;
|
|
33
|
-
messageTaskQuestions?: Array<{
|
|
34
|
-
taskId: string;
|
|
35
|
-
questionId: string;
|
|
36
|
-
}>;
|
|
37
|
-
} | null;
|
|
38
|
-
}): boolean;
|
|
39
|
-
export declare function buildCoordinatorPrompt(input: {
|
|
40
|
-
orchestration: {
|
|
41
|
-
listPendingCoordinatorGroups?: (coordinatorSession: string) => Promise<OrchestrationGroupRecord[]>;
|
|
42
|
-
listPendingCoordinatorResults: (coordinatorSession: string) => Promise<OrchestrationTaskRecord[]>;
|
|
43
|
-
listPendingCoordinatorBlockers?: (coordinatorSession: string) => Promise<OrchestrationTaskRecord[]>;
|
|
44
|
-
listContestedCoordinatorResults?: (coordinatorSession: string) => Promise<OrchestrationTaskRecord[]>;
|
|
45
|
-
getActiveHumanQuestionPackage?: (coordinatorSession: string) => Promise<ActiveHumanQuestionPackageView | null>;
|
|
46
|
-
};
|
|
47
|
-
coordinatorSession: string;
|
|
48
|
-
chatKey?: string;
|
|
49
|
-
accountId?: string;
|
|
50
|
-
replyContextToken?: string;
|
|
51
|
-
userText?: string;
|
|
52
|
-
maxPromptLength?: number;
|
|
53
|
-
}): Promise<{
|
|
54
|
-
promptText: string;
|
|
55
|
-
taskIds: string[];
|
|
56
|
-
groupIds: string[];
|
|
57
|
-
claimHumanReply?: {
|
|
58
|
-
coordinatorSession: string;
|
|
59
|
-
chatKey: string;
|
|
60
|
-
packageId: string;
|
|
61
|
-
messageId: string;
|
|
62
|
-
accountId?: string;
|
|
63
|
-
replyContextToken?: string;
|
|
64
|
-
};
|
|
65
|
-
}>;
|
|
66
|
-
export {};
|
|
@@ -1,471 +0,0 @@
|
|
|
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 {};
|