@elizaos/plugin-agent-orchestrator 2.0.0-alpha.5 → 2.0.0-alpha.537
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 +233 -0
- package/assets/claude-code-skills/eliza-runtime/SKILL.md +123 -0
- package/assets/claude-code-skills/eliza-runtime/references/hooks.md +82 -0
- package/assets/claude-code-skills/eliza-runtime/references/orchestration.md +68 -0
- package/assets/claude-code-skills/eliza-runtime/references/synthesis.md +84 -0
- package/assets/claude-code-skills/eliza-runtime/scripts/eliza-context.sh +103 -0
- package/assets/claude-code-skills/eliza-runtime/scripts/eliza-decision.sh +48 -0
- package/assets/claude-code-skills/eliza-runtime/scripts/eliza-parent.sh +143 -0
- package/dist/actions/coding-task-handlers.d.ts +64 -0
- package/dist/actions/coding-task-handlers.d.ts.map +1 -0
- package/dist/actions/coding-task-helpers.d.ts +35 -0
- package/dist/actions/coding-task-helpers.d.ts.map +1 -0
- package/dist/actions/eval-metadata.d.ts +11 -0
- package/dist/actions/eval-metadata.d.ts.map +1 -0
- package/dist/actions/finalize-workspace.d.ts +11 -0
- package/dist/actions/finalize-workspace.d.ts.map +1 -0
- package/dist/actions/list-agents.d.ts +13 -0
- package/dist/actions/list-agents.d.ts.map +1 -0
- package/dist/actions/manage-issues.d.ts +11 -0
- package/dist/actions/manage-issues.d.ts.map +1 -0
- package/dist/actions/provision-workspace.d.ts +11 -0
- package/dist/actions/provision-workspace.d.ts.map +1 -0
- package/dist/actions/send-to-agent.d.ts +12 -0
- package/dist/actions/send-to-agent.d.ts.map +1 -0
- package/dist/actions/spawn-agent.d.ts +12 -0
- package/dist/actions/spawn-agent.d.ts.map +1 -0
- package/dist/actions/start-coding-task.d.ts +69 -0
- package/dist/actions/start-coding-task.d.ts.map +1 -0
- package/dist/actions/stop-agent.d.ts +12 -0
- package/dist/actions/stop-agent.d.ts.map +1 -0
- package/dist/actions/task-control.d.ts +3 -0
- package/dist/actions/task-control.d.ts.map +1 -0
- package/dist/actions/task-history.d.ts +3 -0
- package/dist/actions/task-history.d.ts.map +1 -0
- package/dist/actions/task-share.d.ts +3 -0
- package/dist/actions/task-share.d.ts.map +1 -0
- package/dist/actions/task-thread-target.d.ts +11 -0
- package/dist/actions/task-thread-target.d.ts.map +1 -0
- package/dist/api/agent-routes.d.ts +18 -0
- package/dist/api/agent-routes.d.ts.map +1 -0
- package/dist/api/bridge-routes.d.ts +32 -0
- package/dist/api/bridge-routes.d.ts.map +1 -0
- package/dist/api/coordinator-routes.d.ts +22 -0
- package/dist/api/coordinator-routes.d.ts.map +1 -0
- package/dist/api/hook-routes.d.ts +18 -0
- package/dist/api/hook-routes.d.ts.map +1 -0
- package/dist/api/issue-routes.d.ts +17 -0
- package/dist/api/issue-routes.d.ts.map +1 -0
- package/dist/api/parent-context-routes.d.ts +17 -0
- package/dist/api/parent-context-routes.d.ts.map +1 -0
- package/dist/api/routes.d.ts +37 -0
- package/dist/api/routes.d.ts.map +1 -0
- package/dist/api/workspace-routes.d.ts +17 -0
- package/dist/api/workspace-routes.d.ts.map +1 -0
- package/dist/index.d.ts +36 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19823 -3387
- package/dist/index.js.map +72 -22
- package/dist/providers/action-examples.d.ts +14 -0
- package/dist/providers/action-examples.d.ts.map +1 -0
- package/dist/providers/active-workspace-context.d.ts +13 -0
- package/dist/providers/active-workspace-context.d.ts.map +1 -0
- package/dist/services/agent-credentials.d.ts +23 -0
- package/dist/services/agent-credentials.d.ts.map +1 -0
- package/dist/services/agent-metrics.d.ts +30 -0
- package/dist/services/agent-metrics.d.ts.map +1 -0
- package/dist/services/agent-selection.d.ts +53 -0
- package/dist/services/agent-selection.d.ts.map +1 -0
- package/dist/services/ansi-utils.d.ts +61 -0
- package/dist/services/ansi-utils.d.ts.map +1 -0
- package/dist/services/claude-code-skill-installer.d.ts +33 -0
- package/dist/services/claude-code-skill-installer.d.ts.map +1 -0
- package/dist/services/config-env.d.ts +23 -0
- package/dist/services/config-env.d.ts.map +1 -0
- package/dist/services/coordinator-event-normalizer.d.ts +50 -0
- package/dist/services/coordinator-event-normalizer.d.ts.map +1 -0
- package/dist/services/custom-validator-runner.d.ts +66 -0
- package/dist/services/custom-validator-runner.d.ts.map +1 -0
- package/dist/services/debug-capture.d.ts +38 -0
- package/dist/services/debug-capture.d.ts.map +1 -0
- package/dist/services/pty-auto-response.d.ts +30 -0
- package/dist/services/pty-auto-response.d.ts.map +1 -0
- package/dist/services/pty-init.d.ts +54 -0
- package/dist/services/pty-init.d.ts.map +1 -0
- package/dist/services/pty-service.d.ts +206 -0
- package/dist/services/pty-service.d.ts.map +1 -0
- package/dist/services/pty-session-io.d.ts +49 -0
- package/dist/services/pty-session-io.d.ts.map +1 -0
- package/dist/services/pty-spawn.d.ts +113 -0
- package/dist/services/pty-spawn.d.ts.map +1 -0
- package/dist/services/pty-types.d.ts +94 -0
- package/dist/services/pty-types.d.ts.map +1 -0
- package/dist/services/repo-input.d.ts +16 -0
- package/dist/services/repo-input.d.ts.map +1 -0
- package/dist/services/session-event-queue.d.ts +25 -0
- package/dist/services/session-event-queue.d.ts.map +1 -0
- package/dist/services/skill-callback-bridge.d.ts +78 -0
- package/dist/services/skill-callback-bridge.d.ts.map +1 -0
- package/dist/services/skill-essentials.d.ts +16 -0
- package/dist/services/skill-essentials.d.ts.map +1 -0
- package/dist/services/skill-lifeops-context-broker.d.ts +20 -0
- package/dist/services/skill-lifeops-context-broker.d.ts.map +1 -0
- package/dist/services/skill-manifest.d.ts +48 -0
- package/dist/services/skill-manifest.d.ts.map +1 -0
- package/dist/services/skill-recommender.d.ts +51 -0
- package/dist/services/skill-recommender.d.ts.map +1 -0
- package/dist/services/stall-classifier.d.ts +69 -0
- package/dist/services/stall-classifier.d.ts.map +1 -0
- package/dist/services/structured-proof-bridge.d.ts +99 -0
- package/dist/services/structured-proof-bridge.d.ts.map +1 -0
- package/dist/services/swarm-coordinator-prompts.d.ts +97 -0
- package/dist/services/swarm-coordinator-prompts.d.ts.map +1 -0
- package/dist/services/swarm-coordinator.d.ts +471 -0
- package/dist/services/swarm-coordinator.d.ts.map +1 -0
- package/dist/services/swarm-decision-loop.d.ts +52 -0
- package/dist/services/swarm-decision-loop.d.ts.map +1 -0
- package/dist/services/swarm-event-triage.d.ts +49 -0
- package/dist/services/swarm-event-triage.d.ts.map +1 -0
- package/dist/services/swarm-history.d.ts +27 -0
- package/dist/services/swarm-history.d.ts.map +1 -0
- package/dist/services/swarm-idle-watchdog.d.ts +22 -0
- package/dist/services/swarm-idle-watchdog.d.ts.map +1 -0
- package/dist/services/task-acceptance.d.ts +8 -0
- package/dist/services/task-acceptance.d.ts.map +1 -0
- package/dist/services/task-agent-auth.d.ts +69 -0
- package/dist/services/task-agent-auth.d.ts.map +1 -0
- package/dist/services/task-agent-frameworks.d.ts +90 -0
- package/dist/services/task-agent-frameworks.d.ts.map +1 -0
- package/dist/services/task-kind.d.ts +3 -0
- package/dist/services/task-kind.d.ts.map +1 -0
- package/dist/services/task-policy.d.ts +17 -0
- package/dist/services/task-policy.d.ts.map +1 -0
- package/dist/services/task-registry.d.ts +550 -0
- package/dist/services/task-registry.d.ts.map +1 -0
- package/dist/services/task-share.d.ts +18 -0
- package/dist/services/task-share.d.ts.map +1 -0
- package/dist/services/task-validation.d.ts +69 -0
- package/dist/services/task-validation.d.ts.map +1 -0
- package/dist/services/task-verifier-runner.d.ts +5 -0
- package/dist/services/task-verifier-runner.d.ts.map +1 -0
- package/dist/services/trajectory-context.d.ts +73 -0
- package/dist/services/trajectory-context.d.ts.map +1 -0
- package/dist/services/trajectory-feedback.d.ts +53 -0
- package/dist/services/trajectory-feedback.d.ts.map +1 -0
- package/dist/services/workspace-git-ops.d.ts +28 -0
- package/dist/services/workspace-git-ops.d.ts.map +1 -0
- package/dist/services/workspace-github.d.ts +60 -0
- package/dist/services/workspace-github.d.ts.map +1 -0
- package/dist/services/workspace-lifecycle.d.ts +18 -0
- package/dist/services/workspace-lifecycle.d.ts.map +1 -0
- package/dist/services/workspace-service.d.ts +121 -0
- package/dist/services/workspace-service.d.ts.map +1 -0
- package/dist/services/workspace-types.d.ts +81 -0
- package/dist/services/workspace-types.d.ts.map +1 -0
- package/package.json +28 -43
- package/scripts/ensure-node-pty.mjs +100 -0
- package/dist/src/actions/messaging.d.ts +0 -24
- package/dist/src/actions/messaging.d.ts.map +0 -1
- package/dist/src/actions/subagent-management.d.ts +0 -7
- package/dist/src/actions/subagent-management.d.ts.map +0 -1
- package/dist/src/actions/task-management.d.ts +0 -9
- package/dist/src/actions/task-management.d.ts.map +0 -1
- package/dist/src/config.d.ts +0 -4
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/providers/orchestrator-config.d.ts +0 -80
- package/dist/src/providers/orchestrator-config.d.ts.map +0 -1
- package/dist/src/providers/task-context.d.ts +0 -3
- package/dist/src/providers/task-context.d.ts.map +0 -1
- package/dist/src/services/agent-orchestrator-service.d.ts +0 -59
- package/dist/src/services/agent-orchestrator-service.d.ts.map +0 -1
- package/dist/src/services/messaging-service.d.ts +0 -111
- package/dist/src/services/messaging-service.d.ts.map +0 -1
- package/dist/src/services/sandbox-service.d.ts +0 -103
- package/dist/src/services/sandbox-service.d.ts.map +0 -1
- package/dist/src/services/subagent-service.d.ts +0 -110
- package/dist/src/services/subagent-service.d.ts.map +0 -1
- package/dist/src/types/index.d.ts +0 -12
- package/dist/src/types/index.d.ts.map +0 -1
- package/dist/src/types/messaging.d.ts +0 -202
- package/dist/src/types/messaging.d.ts.map +0 -1
- package/dist/src/types/sandbox.d.ts +0 -228
- package/dist/src/types/sandbox.d.ts.map +0 -1
- package/dist/src/types/subagent.d.ts +0 -224
- package/dist/src/types/subagent.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -113
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/utils/index.d.ts +0 -7
- package/dist/src/utils/index.d.ts.map +0 -1
- package/dist/src/utils/session.d.ts +0 -106
- package/dist/src/utils/session.d.ts.map +0 -1
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Coordinator: event bridge and autonomous coordination loop.
|
|
3
|
+
*
|
|
4
|
+
* Bridges PTY session events to:
|
|
5
|
+
* 1. SSE clients (frontend dashboard) for real-time status
|
|
6
|
+
* 2. LLM coordination decisions for unhandled blocking prompts
|
|
7
|
+
*
|
|
8
|
+
* The coordinator subscribes to PTYService session events and:
|
|
9
|
+
* - Skips events already handled by auto-response rules (autoResponded=true)
|
|
10
|
+
* - Routes unhandled blocking prompts through supervision levels:
|
|
11
|
+
* - autonomous: LLM decides immediately
|
|
12
|
+
* - confirm: queued for human approval
|
|
13
|
+
* - notify: broadcast only (no action)
|
|
14
|
+
*
|
|
15
|
+
* Heavy logic is extracted into:
|
|
16
|
+
* - swarm-decision-loop.ts (blocked, turn-complete, LLM decisions)
|
|
17
|
+
* - swarm-idle-watchdog.ts (idle session scanning)
|
|
18
|
+
*
|
|
19
|
+
* @module services/swarm-coordinator
|
|
20
|
+
*/
|
|
21
|
+
import type { ServerResponse } from "node:http";
|
|
22
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
23
|
+
import type { PTYService } from "./pty-service.js";
|
|
24
|
+
import type { CodingAgentType } from "./pty-types.js";
|
|
25
|
+
import type { CoordinationLLMResponse, SharedDecision } from "./swarm-coordinator-prompts.js";
|
|
26
|
+
import { SwarmHistory } from "./swarm-history.js";
|
|
27
|
+
import { type CreateTaskThreadInput, type TaskNodeRecord, TaskRegistry, type TaskThreadDetail, type TaskThreadStatus, type TaskThreadSummary } from "./task-registry.js";
|
|
28
|
+
/** Callback injected by server.ts to route chat messages to the user's conversation. */
|
|
29
|
+
export type ChatMessageCallback = (text: string, source?: string) => Promise<void>;
|
|
30
|
+
/** Callback injected by server.ts to relay coordinator events to WebSocket clients. */
|
|
31
|
+
export type WsBroadcastCallback = (event: SwarmEvent) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Listener for in-process consumers of the same event stream that the
|
|
34
|
+
* `wsBroadcast` callback receives (e.g. the verification-room-bridge in
|
|
35
|
+
* plugin-app-control). Returned from `subscribe()`; call to unsubscribe.
|
|
36
|
+
*/
|
|
37
|
+
export type SwarmEventListener = (event: SwarmEvent) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Callback injected by server.ts to route coordinator events through
|
|
40
|
+
* Eliza's full ElizaOS pipeline (conversation memory, personality, actions).
|
|
41
|
+
* Returns a CoordinationLLMResponse parsed from Eliza's natural language
|
|
42
|
+
* response, or null if no actionable JSON block was found.
|
|
43
|
+
*/
|
|
44
|
+
export type AgentDecisionCallback = (eventDescription: string, sessionId: string, taskContext: TaskContext) => Promise<CoordinationLLMResponse | null>;
|
|
45
|
+
/** Per-task summary included in the swarm complete payload. */
|
|
46
|
+
export interface TaskCompletionSummary {
|
|
47
|
+
sessionId: string;
|
|
48
|
+
label: string;
|
|
49
|
+
agentType: string;
|
|
50
|
+
originalTask: string;
|
|
51
|
+
status: string;
|
|
52
|
+
completionSummary: string;
|
|
53
|
+
/** Subagent's working directory — used by synthesis to read the final
|
|
54
|
+
* assistant response from the Claude Code session jsonl after the PTY
|
|
55
|
+
* session has been cleaned up. */
|
|
56
|
+
workdir?: string;
|
|
57
|
+
/** Room the task was spawned from (captured from the originating user
|
|
58
|
+
* message). Used by synthesis to route the final answer back to the
|
|
59
|
+
* same chat channel. */
|
|
60
|
+
roomId?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Callback fired when all tasks in a swarm reach terminal state. */
|
|
63
|
+
export type SwarmCompleteCallback = (payload: {
|
|
64
|
+
tasks: TaskCompletionSummary[];
|
|
65
|
+
total: number;
|
|
66
|
+
completed: number;
|
|
67
|
+
stopped: number;
|
|
68
|
+
errored: number;
|
|
69
|
+
}) => Promise<void>;
|
|
70
|
+
export type SupervisionLevel = "autonomous" | "confirm" | "notify";
|
|
71
|
+
export interface TaskContext {
|
|
72
|
+
threadId: string;
|
|
73
|
+
taskNodeId?: string;
|
|
74
|
+
sessionId: string;
|
|
75
|
+
agentType: CodingAgentType;
|
|
76
|
+
label: string;
|
|
77
|
+
originalTask: string;
|
|
78
|
+
workdir: string;
|
|
79
|
+
/** Repository URL if provided, undefined for scratch directory tasks. */
|
|
80
|
+
repo?: string;
|
|
81
|
+
/** Original parent room for this spawned task, when available. */
|
|
82
|
+
originRoomId?: string;
|
|
83
|
+
/** Read-only parent metadata captured at spawn time. */
|
|
84
|
+
originMetadata?: Record<string, unknown>;
|
|
85
|
+
status: "active" | "blocked" | "tool_running" | "completed" | "error" | "stopped";
|
|
86
|
+
decisions: CoordinationDecision[];
|
|
87
|
+
autoResolvedCount: number;
|
|
88
|
+
registeredAt: number;
|
|
89
|
+
/** Timestamp of the last session event (any type). Used by idle watchdog. */
|
|
90
|
+
lastActivityAt: number;
|
|
91
|
+
/** How many idle checks have been performed on this session. */
|
|
92
|
+
idleCheckCount: number;
|
|
93
|
+
/** True once the initial task has been delivered to the agent. */
|
|
94
|
+
taskDelivered: boolean;
|
|
95
|
+
/** Summary of what the agent accomplished, populated on completion. */
|
|
96
|
+
completionSummary?: string;
|
|
97
|
+
/** Index into sharedDecisions[]: tracks which decisions this agent has already seen. */
|
|
98
|
+
lastSeenDecisionIndex: number;
|
|
99
|
+
/** Timestamp of last coordinator-sent input. Used to suppress stall/turn-complete
|
|
100
|
+
* events for a grace period so the agent has time to process the input. */
|
|
101
|
+
lastInputSentAt?: number;
|
|
102
|
+
/** Timestamp when the task was last transitioned to `stopped`. */
|
|
103
|
+
stoppedAt?: number;
|
|
104
|
+
/** Suppress the generic stop notice when the session is intentionally replaced. */
|
|
105
|
+
suppressStopNotice?: boolean;
|
|
106
|
+
/** Keep the PTY session open after this task completes so callers can reuse it. */
|
|
107
|
+
keepAliveAfterComplete?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface CoordinationDecision {
|
|
110
|
+
timestamp: number;
|
|
111
|
+
event: string;
|
|
112
|
+
promptText: string;
|
|
113
|
+
decision: "respond" | "escalate" | "ignore" | "complete" | "auto_resolved" | "stopped";
|
|
114
|
+
response?: string;
|
|
115
|
+
reasoning: string;
|
|
116
|
+
}
|
|
117
|
+
export interface SwarmEvent {
|
|
118
|
+
type: string;
|
|
119
|
+
sessionId: string;
|
|
120
|
+
timestamp: number;
|
|
121
|
+
data: unknown;
|
|
122
|
+
}
|
|
123
|
+
export interface PendingDecision {
|
|
124
|
+
sessionId: string;
|
|
125
|
+
promptText: string;
|
|
126
|
+
recentOutput: string;
|
|
127
|
+
llmDecision: CoordinationLLMResponse;
|
|
128
|
+
taskContext: TaskContext;
|
|
129
|
+
createdAt: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Context interface exposing internal state and helpers to extracted modules.
|
|
133
|
+
* Implemented by SwarmCoordinator. Passed as `this` to module-level functions.
|
|
134
|
+
*/
|
|
135
|
+
export interface SwarmCoordinatorContext {
|
|
136
|
+
readonly runtime: IAgentRuntime;
|
|
137
|
+
readonly ptyService: PTYService | null;
|
|
138
|
+
readonly taskRegistry: TaskRegistry;
|
|
139
|
+
readonly tasks: Map<string, TaskContext>;
|
|
140
|
+
readonly inFlightDecisions: Set<string>;
|
|
141
|
+
readonly pendingDecisions: Map<string, PendingDecision>;
|
|
142
|
+
/** Buffered task_complete events that arrived while an in-flight decision was running. */
|
|
143
|
+
readonly pendingTurnComplete: Map<string, unknown>;
|
|
144
|
+
/** Fingerprint of the last blocked prompt per session, for re-render dedup. */
|
|
145
|
+
readonly lastBlockedPromptFingerprint: Map<string, string>;
|
|
146
|
+
/** Buffered blocked events that arrived while an in-flight decision was running. */
|
|
147
|
+
readonly pendingBlocked: Map<string, unknown>;
|
|
148
|
+
/** Last-seen output snapshot per session, used by idle watchdog. */
|
|
149
|
+
readonly lastSeenOutput: Map<string, string>;
|
|
150
|
+
/** Timestamp of last tool_running chat notification per session, for throttling. */
|
|
151
|
+
readonly lastToolNotification: Map<string, number>;
|
|
152
|
+
/** Whether LLM decisions are paused (user sent a chat message). */
|
|
153
|
+
readonly isPaused: boolean;
|
|
154
|
+
/** Significant decisions shared across the swarm. */
|
|
155
|
+
readonly sharedDecisions: SharedDecision[];
|
|
156
|
+
/** Get the shared context brief from the planning phase. */
|
|
157
|
+
getSwarmContext(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Guard flag: whether the swarm_complete event has already been fired
|
|
160
|
+
* for the current swarm lifecycle. Set to `true` by `checkAllTasksComplete()`
|
|
161
|
+
* when all tasks reach terminal state. Reset to `false` by:
|
|
162
|
+
* - `stop()`: full coordinator teardown
|
|
163
|
+
* - `registerTask()`: when detecting a new swarm (all previous tasks terminal)
|
|
164
|
+
*/
|
|
165
|
+
swarmCompleteNotified: boolean;
|
|
166
|
+
broadcast(event: SwarmEvent): void;
|
|
167
|
+
/**
|
|
168
|
+
* Register an in-process listener that receives every broadcast event.
|
|
169
|
+
* Returns an unsubscribe function. Listeners run synchronously after the
|
|
170
|
+
* SSE/WS fan-out and must not throw — the coordinator catches and logs
|
|
171
|
+
* any thrown error so a misbehaving listener cannot poison the event
|
|
172
|
+
* stream for other consumers.
|
|
173
|
+
*/
|
|
174
|
+
subscribe(listener: SwarmEventListener): () => void;
|
|
175
|
+
sendChatMessage(text: string, source?: string): boolean;
|
|
176
|
+
log(message: string): void;
|
|
177
|
+
getSupervisionLevel(): SupervisionLevel;
|
|
178
|
+
getAgentDecisionCallback(): AgentDecisionCallback | null;
|
|
179
|
+
getSwarmCompleteCallback(): SwarmCompleteCallback | null;
|
|
180
|
+
recordDecision(taskCtx: TaskContext, decision: CoordinationDecision): Promise<void>;
|
|
181
|
+
syncTaskContext(taskCtx: TaskContext): Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
export declare class SwarmCoordinator implements SwarmCoordinatorContext {
|
|
184
|
+
static serviceType: string;
|
|
185
|
+
readonly runtime: IAgentRuntime;
|
|
186
|
+
readonly taskRegistry: TaskRegistry;
|
|
187
|
+
ptyService: PTYService | null;
|
|
188
|
+
private unsubscribeEvents;
|
|
189
|
+
/** Per-session task context. */
|
|
190
|
+
readonly tasks: Map<string, TaskContext>;
|
|
191
|
+
/** SSE clients receiving live events. */
|
|
192
|
+
private sseClients;
|
|
193
|
+
/** Supervision level (default: autonomous). */
|
|
194
|
+
private supervisionLevel;
|
|
195
|
+
/** Pending confirmations for "confirm" mode. */
|
|
196
|
+
readonly pendingDecisions: Map<string, PendingDecision>;
|
|
197
|
+
/** In-flight decision lock: prevents parallel LLM calls for same session. */
|
|
198
|
+
readonly inFlightDecisions: Set<string>;
|
|
199
|
+
/** Buffered task_complete events that arrived while an in-flight decision was running. */
|
|
200
|
+
readonly pendingTurnComplete: Map<string, unknown>;
|
|
201
|
+
/** Fingerprint of the last blocked prompt per session, for re-render dedup. */
|
|
202
|
+
readonly lastBlockedPromptFingerprint: Map<string, string>;
|
|
203
|
+
/** Buffered blocked events that arrived while an in-flight decision was running. */
|
|
204
|
+
readonly pendingBlocked: Map<string, unknown>;
|
|
205
|
+
/** Callback to send chat messages to the user's conversation UI. */
|
|
206
|
+
private chatCallback;
|
|
207
|
+
/** Callback to relay coordinator events to WebSocket clients. */
|
|
208
|
+
private wsBroadcast;
|
|
209
|
+
/** Callback to route coordinator events through Eliza's full pipeline. */
|
|
210
|
+
private agentDecisionCb;
|
|
211
|
+
/** Callback fired when all swarm tasks complete, for synthesis. */
|
|
212
|
+
private swarmCompleteCb;
|
|
213
|
+
/** Buffer for events arriving before task registration. */
|
|
214
|
+
private unregisteredBuffer;
|
|
215
|
+
/** Idle watchdog timer handle. */
|
|
216
|
+
private idleWatchdogTimer;
|
|
217
|
+
/** Last-seen output snapshot per session, used by idle watchdog to detect data flow. */
|
|
218
|
+
readonly lastSeenOutput: Map<string, string>;
|
|
219
|
+
/** Timestamp of last tool_running chat notification per session, for throttling. */
|
|
220
|
+
readonly lastToolNotification: Map<string, number>;
|
|
221
|
+
/** Whether LLM decisions are paused (user sent a chat message). */
|
|
222
|
+
private _paused;
|
|
223
|
+
/** Significant decisions shared across the swarm (Layer 2). */
|
|
224
|
+
readonly sharedDecisions: SharedDecision[];
|
|
225
|
+
/** Shared context brief generated during swarm planning phase. */
|
|
226
|
+
private _swarmContext;
|
|
227
|
+
/** @see SwarmCoordinatorContext.swarmCompleteNotified */
|
|
228
|
+
swarmCompleteNotified: boolean;
|
|
229
|
+
/** Buffered events during pause, replayed on resume. */
|
|
230
|
+
private pauseBuffer;
|
|
231
|
+
/** Buffered broadcasts waiting for wsBroadcast to be wired. */
|
|
232
|
+
private preBridgeBroadcastBuffer;
|
|
233
|
+
/** In-process listeners subscribed via `subscribe()`. */
|
|
234
|
+
private eventListeners;
|
|
235
|
+
/** Auto-resume timeout handle. */
|
|
236
|
+
private pauseTimeout;
|
|
237
|
+
/** Coordinator startup timestamp: ignore events from sessions created before this. */
|
|
238
|
+
private readonly startedAt;
|
|
239
|
+
/** Active retry timers for unregistered session buffers. */
|
|
240
|
+
private unregisteredRetryTimers;
|
|
241
|
+
/** Turn-complete coalescing timers: debounces rapid events per session. */
|
|
242
|
+
private turnCompleteCoalesceTimers;
|
|
243
|
+
/** Persistent swarm history: JSONL log that survives restarts. */
|
|
244
|
+
readonly history: SwarmHistory;
|
|
245
|
+
constructor(runtime: IAgentRuntime);
|
|
246
|
+
/** Inject a callback (from server.ts) to route messages to the user's chat UI. */
|
|
247
|
+
/** Track whether we've already wired the scratch decision callback. */
|
|
248
|
+
private scratchDecisionWired;
|
|
249
|
+
setChatCallback(cb: ChatMessageCallback): void;
|
|
250
|
+
/**
|
|
251
|
+
* Wire the scratch workspace save prompt callback.
|
|
252
|
+
* Called eagerly from setChatCallback and lazily from handleSessionEvent
|
|
253
|
+
* in case the workspace service wasn't ready at chat-callback time.
|
|
254
|
+
*/
|
|
255
|
+
private wireScratchDecisionCallback;
|
|
256
|
+
/** Inject a callback (from server.ts) to relay events to WebSocket clients. */
|
|
257
|
+
setWsBroadcast(cb: WsBroadcastCallback): void;
|
|
258
|
+
/** Inject a callback fired when all swarm tasks reach terminal state. */
|
|
259
|
+
setSwarmCompleteCallback(cb: SwarmCompleteCallback): void;
|
|
260
|
+
/** Return the swarm complete callback (if wired). */
|
|
261
|
+
getSwarmCompleteCallback(): SwarmCompleteCallback | null;
|
|
262
|
+
/** Set the shared context brief for this swarm. */
|
|
263
|
+
setSwarmContext(context: string): void;
|
|
264
|
+
/** Return the swarm planning context (if set). */
|
|
265
|
+
getSwarmContext(): string;
|
|
266
|
+
/** Inject a callback (from server.ts) to route events through Eliza's pipeline. */
|
|
267
|
+
setAgentDecisionCallback(cb: AgentDecisionCallback): void;
|
|
268
|
+
/** Return the agent decision callback (if wired). */
|
|
269
|
+
getAgentDecisionCallback(): AgentDecisionCallback | null;
|
|
270
|
+
/**
|
|
271
|
+
* Null-safe chat dispatcher.
|
|
272
|
+
*
|
|
273
|
+
* CALLING POLICY. Keep this consistent or you'll either spam users or
|
|
274
|
+
* hide important signals:
|
|
275
|
+
*
|
|
276
|
+
* POST to chat: user must act (auth prompts, "needs your attention"
|
|
277
|
+
* escalations, security violations, unrecoverable
|
|
278
|
+
* errors), or the final result of the swarm (delivered
|
|
279
|
+
* via the synthesis callback, not this method).
|
|
280
|
+
*
|
|
281
|
+
* STAY SILENT: coordinator-internal state transitions (auto-
|
|
282
|
+
* recovery, token refresh, scratch-decision TTL,
|
|
283
|
+
* tool_running progress, mid-task continuation
|
|
284
|
+
* decisions, PTY session-lost on restart). Web UI
|
|
285
|
+
* still sees these via `broadcast()`; chat should
|
|
286
|
+
* not duplicate them, because synthesis will deliver
|
|
287
|
+
* the final outcome once a terminal state is reached.
|
|
288
|
+
*/
|
|
289
|
+
sendChatMessage(text: string, source?: string): boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Initialize the coordinator by subscribing to PTY session events.
|
|
292
|
+
* Called from plugin init after services are ready.
|
|
293
|
+
*/
|
|
294
|
+
start(ptyService: PTYService): Promise<void>;
|
|
295
|
+
private restorePendingTaskContext;
|
|
296
|
+
private restorePendingLlmDecision;
|
|
297
|
+
private rehydratePendingDecisions;
|
|
298
|
+
stop(): Promise<void>;
|
|
299
|
+
/** Whether the coordinator is currently paused. */
|
|
300
|
+
get isPaused(): boolean;
|
|
301
|
+
/** Pause LLM-based decisions. Auto-responses and broadcasts continue. */
|
|
302
|
+
pause(): void;
|
|
303
|
+
/** Resume LLM-based decisions and replay buffered events. */
|
|
304
|
+
resume(): void;
|
|
305
|
+
registerTask(sessionId: string, context: {
|
|
306
|
+
threadId?: string;
|
|
307
|
+
taskNodeId?: string;
|
|
308
|
+
agentType: CodingAgentType;
|
|
309
|
+
label: string;
|
|
310
|
+
originalTask: string;
|
|
311
|
+
workdir: string;
|
|
312
|
+
repo?: string;
|
|
313
|
+
providerSource?: string | null;
|
|
314
|
+
metadata?: Record<string, unknown>;
|
|
315
|
+
}): Promise<void>;
|
|
316
|
+
/**
|
|
317
|
+
* Return the repo URL from the most recently registered task that had one.
|
|
318
|
+
* Useful as a fallback when the user says "in the same repo" without a URL.
|
|
319
|
+
*/
|
|
320
|
+
/**
|
|
321
|
+
* Persisted separately from tasks so it survives task cleanup.
|
|
322
|
+
* Updated whenever a task with a repo is registered.
|
|
323
|
+
*/
|
|
324
|
+
private _lastUsedRepo;
|
|
325
|
+
getLastUsedRepo(): string | undefined;
|
|
326
|
+
/**
|
|
327
|
+
* Async version that also checks disk history, survives process restarts.
|
|
328
|
+
* Callers that can await should prefer this over the sync version.
|
|
329
|
+
*/
|
|
330
|
+
getLastUsedRepoAsync(): Promise<string | undefined>;
|
|
331
|
+
getTaskContext(sessionId: string): TaskContext | undefined;
|
|
332
|
+
private mapDecisionRecord;
|
|
333
|
+
private mapSessionStatus;
|
|
334
|
+
private mapTaskContextStatusToNodeStatus;
|
|
335
|
+
private buildTaskContextFromSession;
|
|
336
|
+
getTaskContextSnapshot(sessionId: string): Promise<TaskContext | null>;
|
|
337
|
+
getAllTaskContexts(): TaskContext[];
|
|
338
|
+
createTaskThread(input: CreateTaskThreadInput): Promise<TaskThreadSummary>;
|
|
339
|
+
planTaskThreadGraph(input: {
|
|
340
|
+
threadId: string;
|
|
341
|
+
title: string;
|
|
342
|
+
originalRequest: string;
|
|
343
|
+
sharedContext?: string;
|
|
344
|
+
subtasks: Array<{
|
|
345
|
+
label: string;
|
|
346
|
+
originalTask: string;
|
|
347
|
+
agentType: CodingAgentType;
|
|
348
|
+
repo?: string;
|
|
349
|
+
}>;
|
|
350
|
+
}): Promise<{
|
|
351
|
+
rootNode: TaskNodeRecord;
|
|
352
|
+
workerNodes: TaskNodeRecord[];
|
|
353
|
+
}>;
|
|
354
|
+
listTaskThreads(options?: {
|
|
355
|
+
includeArchived?: boolean;
|
|
356
|
+
status?: TaskThreadStatus;
|
|
357
|
+
statuses?: TaskThreadStatus[];
|
|
358
|
+
kind?: import("./task-registry.js").TaskThreadKind;
|
|
359
|
+
roomId?: string;
|
|
360
|
+
worldId?: string;
|
|
361
|
+
ownerUserId?: string;
|
|
362
|
+
scenarioId?: string;
|
|
363
|
+
batchId?: string;
|
|
364
|
+
createdAfter?: string;
|
|
365
|
+
createdBefore?: string;
|
|
366
|
+
updatedAfter?: string;
|
|
367
|
+
updatedBefore?: string;
|
|
368
|
+
latestActivityAfter?: number;
|
|
369
|
+
latestActivityBefore?: number;
|
|
370
|
+
hasActiveSession?: boolean;
|
|
371
|
+
search?: string;
|
|
372
|
+
limit?: number;
|
|
373
|
+
}): Promise<TaskThreadSummary[]>;
|
|
374
|
+
getTaskThread(threadId: string): Promise<TaskThreadDetail | null>;
|
|
375
|
+
archiveTaskThread(threadId: string): Promise<void>;
|
|
376
|
+
reopenTaskThread(threadId: string): Promise<void>;
|
|
377
|
+
countTaskThreads(options?: {
|
|
378
|
+
includeArchived?: boolean;
|
|
379
|
+
status?: TaskThreadStatus;
|
|
380
|
+
statuses?: TaskThreadStatus[];
|
|
381
|
+
kind?: import("./task-registry.js").TaskThreadKind;
|
|
382
|
+
roomId?: string;
|
|
383
|
+
worldId?: string;
|
|
384
|
+
ownerUserId?: string;
|
|
385
|
+
scenarioId?: string;
|
|
386
|
+
batchId?: string;
|
|
387
|
+
createdAfter?: string;
|
|
388
|
+
createdBefore?: string;
|
|
389
|
+
updatedAfter?: string;
|
|
390
|
+
updatedBefore?: string;
|
|
391
|
+
latestActivityAfter?: number;
|
|
392
|
+
latestActivityBefore?: number;
|
|
393
|
+
hasActiveSession?: boolean;
|
|
394
|
+
search?: string;
|
|
395
|
+
}): Promise<number>;
|
|
396
|
+
private getLiveTaskContextsForThread;
|
|
397
|
+
private stopLiveThreadSessions;
|
|
398
|
+
private clipText;
|
|
399
|
+
private formatResumePrompt;
|
|
400
|
+
pauseTaskThread(threadId: string, note?: string): Promise<{
|
|
401
|
+
threadId: string;
|
|
402
|
+
stoppedSessionIds: string[];
|
|
403
|
+
}>;
|
|
404
|
+
stopTaskThread(threadId: string, note?: string): Promise<{
|
|
405
|
+
threadId: string;
|
|
406
|
+
stoppedSessionIds: string[];
|
|
407
|
+
}>;
|
|
408
|
+
resumeTaskThread(threadId: string, instruction?: string, agentType?: string): Promise<{
|
|
409
|
+
threadId: string;
|
|
410
|
+
sessionId: string;
|
|
411
|
+
reusedSession: boolean;
|
|
412
|
+
framework: CodingAgentType;
|
|
413
|
+
}>;
|
|
414
|
+
continueTaskThread(threadId: string, instruction: string, agentType?: string): Promise<{
|
|
415
|
+
threadId: string;
|
|
416
|
+
sessionId: string;
|
|
417
|
+
reusedSession: boolean;
|
|
418
|
+
framework: CodingAgentType;
|
|
419
|
+
}>;
|
|
420
|
+
syncTaskContext(taskCtx: TaskContext): Promise<void>;
|
|
421
|
+
private isAutomaticFailoverFramework;
|
|
422
|
+
private getFailoverCandidates;
|
|
423
|
+
private getRecoveryCandidates;
|
|
424
|
+
private shouldPreferAlternativeFrameworkForError;
|
|
425
|
+
private formatFailoverPrompt;
|
|
426
|
+
private formatErrorRecoveryPrompt;
|
|
427
|
+
private handleFrameworkDepletion;
|
|
428
|
+
private attemptTaskFailover;
|
|
429
|
+
private attemptTaskRecovery;
|
|
430
|
+
resumeTaskAfterProviderAuth(sessionId: string, reason: string): Promise<{
|
|
431
|
+
replacementSessionId: string;
|
|
432
|
+
replacementFramework: CodingAgentType;
|
|
433
|
+
replacementLabel: string;
|
|
434
|
+
} | null>;
|
|
435
|
+
markTaskResumedAfterProviderAuth(sessionId: string): Promise<boolean>;
|
|
436
|
+
recordDecision(taskCtx: TaskContext, decision: CoordinationDecision): Promise<void>;
|
|
437
|
+
setTaskDelivered(sessionId: string): Promise<void>;
|
|
438
|
+
/**
|
|
439
|
+
* Schedule a retry check for buffered events from an unregistered session.
|
|
440
|
+
* Uses exponential backoff: 2s → 4s → 8s → 16s, max 30s total.
|
|
441
|
+
*/
|
|
442
|
+
private scheduleUnregisteredRetry;
|
|
443
|
+
/**
|
|
444
|
+
* Register an SSE client. Returns an unsubscribe function.
|
|
445
|
+
* Sends a snapshot of current state on connect.
|
|
446
|
+
*/
|
|
447
|
+
addSseClient(res: ServerResponse): () => void;
|
|
448
|
+
broadcast(event: SwarmEvent): void;
|
|
449
|
+
/** @see SwarmCoordinatorContext.subscribe */
|
|
450
|
+
subscribe(listener: SwarmEventListener): () => void;
|
|
451
|
+
private writeSseEvent;
|
|
452
|
+
handleSessionEvent(sessionId: string, event: string, data: unknown): Promise<void>;
|
|
453
|
+
private handleNormalizedSessionEvent;
|
|
454
|
+
makeCoordinationDecision(taskCtx: TaskContext, promptText: string, recentOutput: string): Promise<CoordinationLLMResponse | null>;
|
|
455
|
+
executeDecision(sessionId: string, decision: CoordinationLLMResponse): Promise<void>;
|
|
456
|
+
/**
|
|
457
|
+
* Public entry point for external callers (e.g. server.ts) to execute
|
|
458
|
+
* a coordination decision on a session. Wraps the internal executeDecision.
|
|
459
|
+
*/
|
|
460
|
+
executeEventDecision(sessionId: string, decision: CoordinationLLMResponse): Promise<void>;
|
|
461
|
+
setSupervisionLevel(level: SupervisionLevel): void;
|
|
462
|
+
getSupervisionLevel(): SupervisionLevel;
|
|
463
|
+
getPendingConfirmations(): PendingDecision[];
|
|
464
|
+
confirmDecision(sessionId: string, approved: boolean, override?: {
|
|
465
|
+
response?: string;
|
|
466
|
+
useKeys?: boolean;
|
|
467
|
+
keys?: string[];
|
|
468
|
+
}): Promise<void>;
|
|
469
|
+
log(message: string): void;
|
|
470
|
+
}
|
|
471
|
+
//# sourceMappingURL=swarm-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-coordinator.d.ts","sourceRoot":"","sources":["../../src/services/swarm-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA+BnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACf,MAAM,gCAAgC,CAAC;AAQxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAalD,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,cAAc,EAGnB,YAAY,EAEZ,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAI5B,wFAAwF;AACxF,MAAM,MAAM,mBAAmB,GAAG,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,KACZ,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,uFAAuF;AACvF,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,gBAAgB,EAAE,MA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AAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IAQpC,eAAe,CACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,uBAAuB,GAChC,OAAO,CAAC,IAAI,CAAC;IAIhB;;;OAGG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,uBAAuB,GAChC,OAAO,CAAC,IAAI,CAAC;IAMhB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAWlD,mBAAmB,IAAI,gBAAgB;IAMvC,uBAAuB,IAAI,eAAe,EAAE;IAItC,eAAe,CACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GACnE,OAAO,CAAC,IAAI,CAAC;IAgHhB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG3B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Coordinator: decision loop and blocked/turn-complete handlers.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from swarm-coordinator.ts for modularity.
|
|
5
|
+
* All functions are pure async helpers that receive a SwarmCoordinatorContext
|
|
6
|
+
* to access shared state and services.
|
|
7
|
+
*
|
|
8
|
+
* @module services/swarm-decision-loop
|
|
9
|
+
*/
|
|
10
|
+
import type { SwarmCoordinatorContext, TaskContext } from "./swarm-coordinator.js";
|
|
11
|
+
import { type CoordinationLLMResponse } from "./swarm-coordinator-prompts.js";
|
|
12
|
+
/**
|
|
13
|
+
* Grace period after the coordinator sends input to an agent (ms).
|
|
14
|
+
* During this window, stall and turn-complete events are suppressed
|
|
15
|
+
* to give the agent time to process the input before re-assessment.
|
|
16
|
+
*/
|
|
17
|
+
export declare const POST_SEND_COOLDOWN_MS = 15000;
|
|
18
|
+
/** Clear all deferred turn-complete timers (used during coordinator shutdown). */
|
|
19
|
+
export declare function clearDeferredTurnCompleteTimers(): void;
|
|
20
|
+
/** Check if a permission prompt references paths outside the workspace. */
|
|
21
|
+
export declare function isOutOfScopeAccess(promptText: string, workdir: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if all registered tasks have reached a terminal state.
|
|
24
|
+
* If so, send a swarm-wide summary message to the chat.
|
|
25
|
+
*/
|
|
26
|
+
export declare function checkAllTasksComplete(ctx: SwarmCoordinatorContext): void;
|
|
27
|
+
/**
|
|
28
|
+
* Ask the LLM to make a coordination decision about a blocked agent.
|
|
29
|
+
*/
|
|
30
|
+
export declare function makeCoordinationDecision(ctx: SwarmCoordinatorContext, taskCtx: TaskContext, promptText: string, recentOutput: string): Promise<CoordinationLLMResponse | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Execute a coordination decision: send response, complete session, escalate, or ignore.
|
|
33
|
+
*/
|
|
34
|
+
export declare function executeDecision(ctx: SwarmCoordinatorContext, sessionId: string, decision: CoordinationLLMResponse): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Handle a "blocked" session event: auto-resolved, escalated, or routed to decision loop.
|
|
37
|
+
*/
|
|
38
|
+
export declare function handleBlocked(ctx: SwarmCoordinatorContext, sessionId: string, taskCtx: TaskContext, data: unknown): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Handle a turn completion event. Instead of immediately stopping the session,
|
|
41
|
+
* ask the LLM whether the overall task is done or the agent needs more turns.
|
|
42
|
+
*/
|
|
43
|
+
export declare function handleTurnComplete(ctx: SwarmCoordinatorContext, sessionId: string, taskCtx: TaskContext, data: unknown): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Handle an autonomous decision for a blocked session: call the LLM and execute immediately.
|
|
46
|
+
*/
|
|
47
|
+
export declare function handleAutonomousDecision(ctx: SwarmCoordinatorContext, sessionId: string, taskCtx: TaskContext, promptText: string, recentOutput: string, promptType?: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Handle a confirm-mode decision: call LLM, then queue for human approval.
|
|
50
|
+
*/
|
|
51
|
+
export declare function handleConfirmDecision(ctx: SwarmCoordinatorContext, sessionId: string, taskCtx: TaskContext, promptText: string, recentOutput: string, promptType?: string): Promise<void>;
|
|
52
|
+
//# sourceMappingURL=swarm-decision-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-decision-loop.d.ts","sourceRoot":"","sources":["../../src/services/swarm-decision-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,OAAO,KAAK,EAEV,uBAAuB,EACvB,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAIL,KAAK,uBAAuB,EAK7B,MAAM,gCAAgC,CAAC;AAuIxC;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAM5C,kFAAkF;AAClF,wBAAgB,+BAA+B,IAAI,IAAI,CAKtD;AA0YD,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CA2BT;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,uBAAuB,GAAG,IAAI,CAExE;AAiSD;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,uBAAuB,EAC5B,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CA8BzC;AAwLD;;GAEG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,uBAAuB,EAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,uBAAuB,GAChC,OAAO,CAAC,IAAI,CAAC,CAyaf;AAID;;GAEG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,uBAAuB,EAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,IAAI,CAAC,CAyUf;AAID;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,uBAAuB,EAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,IAAI,CAAC,CA4Sf;AAID;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,uBAAuB,EAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAqLf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,uBAAuB,EAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAsKf"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Triage — classifies coordinator events as "routine" or "creative"
|
|
3
|
+
* to route them to the fast small-LLM path or the full Eliza pipeline.
|
|
4
|
+
*
|
|
5
|
+
* Tier 1 (auto-response rules at PTY worker) already handled before we get here.
|
|
6
|
+
* This module splits the remaining events into:
|
|
7
|
+
* - "routine": simple approvals, permissions, config prompts → small LLM (~1-2s)
|
|
8
|
+
* - "creative": error recovery, design questions, task evaluation → Eliza (~5-10s)
|
|
9
|
+
*
|
|
10
|
+
* Pure functions — no side effects, same pattern as stall-classifier.ts.
|
|
11
|
+
*
|
|
12
|
+
* @module services/swarm-event-triage
|
|
13
|
+
*/
|
|
14
|
+
import { type IAgentRuntime } from "@elizaos/core";
|
|
15
|
+
export type TriageTier = "routine" | "creative";
|
|
16
|
+
export interface TriageContext {
|
|
17
|
+
/** "blocked" or "turn_complete" */
|
|
18
|
+
eventType: "blocked" | "turn_complete";
|
|
19
|
+
/** The blocking prompt text (empty for turn completions). */
|
|
20
|
+
promptText: string;
|
|
21
|
+
/** Adapter's promptInfo.type if available. */
|
|
22
|
+
promptType?: string;
|
|
23
|
+
/** Recent terminal output (for turn completions). */
|
|
24
|
+
recentOutput?: string;
|
|
25
|
+
/** The original task description. */
|
|
26
|
+
originalTask: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Classify an event tier using only heuristics (prompt type + regex).
|
|
30
|
+
* Returns null if inconclusive.
|
|
31
|
+
*/
|
|
32
|
+
export declare function classifyByHeuristic(ctx: TriageContext): TriageTier | null;
|
|
33
|
+
/**
|
|
34
|
+
* Build a short classifier prompt for ambiguous events.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildTriagePrompt(ctx: TriageContext): string;
|
|
37
|
+
/**
|
|
38
|
+
* Parse the LLM's triage response. Returns null on failure.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseTriageResponse(llmOutput: string): TriageTier | null;
|
|
41
|
+
/**
|
|
42
|
+
* Main entry point: classify an event as routine or creative.
|
|
43
|
+
*
|
|
44
|
+
* 1. Heuristics (0ms)
|
|
45
|
+
* 2. Small LLM classifier (~500ms-1s) if heuristics are inconclusive
|
|
46
|
+
* 3. Default to "creative" if classifier fails (safe default)
|
|
47
|
+
*/
|
|
48
|
+
export declare function classifyEventTier(runtime: IAgentRuntime, ctx: TriageContext, log: (msg: string) => void): Promise<TriageTier>;
|
|
49
|
+
//# sourceMappingURL=swarm-event-triage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-event-triage.d.ts","sourceRoot":"","sources":["../../src/services/swarm-event-triage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,eAAe,CAAC;AAK9D,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,SAAS,EAAE,SAAS,GAAG,eAAe,CAAC;IACvC,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;CACtB;AAmED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,IAAI,CAgCzE;AAID;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAc5D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAaxE;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GACzB,OAAO,CAAC,UAAU,CAAC,CA4BrB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type HistoryEntryType = "task_registered" | "task_completed" | "task_stopped" | "task_error" | "key_decision";
|
|
2
|
+
export interface HistoryEntry {
|
|
3
|
+
timestamp: number;
|
|
4
|
+
type: HistoryEntryType;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
label: string;
|
|
7
|
+
agentType: string;
|
|
8
|
+
repo?: string;
|
|
9
|
+
workdir: string;
|
|
10
|
+
originalTask?: string;
|
|
11
|
+
completionSummary?: string;
|
|
12
|
+
reasoning?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class SwarmHistory {
|
|
15
|
+
private filePath;
|
|
16
|
+
/** In-memory counter to avoid reading the file on every append. */
|
|
17
|
+
private appendCount;
|
|
18
|
+
/** Serializes all file mutations. */
|
|
19
|
+
private mutex;
|
|
20
|
+
constructor(stateDir?: string);
|
|
21
|
+
append(entry: HistoryEntry): Promise<void>;
|
|
22
|
+
readAll(): Promise<HistoryEntry[]>;
|
|
23
|
+
getLastUsedRepo(): Promise<string | undefined>;
|
|
24
|
+
/** Called while holding the mutex — no external callers. */
|
|
25
|
+
private truncateInner;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=swarm-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-history.d.ts","sourceRoot":"","sources":["../../src/services/swarm-history.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,YAAY,GACZ,cAAc,CAAC;AAEnB,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAmCD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,mEAAmE;IACnE,OAAO,CAAC,WAAW,CAAK;IACxB,qCAAqC;IACrC,OAAO,CAAC,KAAK,CAAoB;gBAErB,QAAQ,CAAC,EAAE,MAAM;IAQvB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC1C,OAAO,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IA6BlC,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAUpD,4DAA4D;YAC9C,aAAa;CAgC5B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Coordinator — Idle Watchdog
|
|
3
|
+
*
|
|
4
|
+
* Extracted from swarm-coordinator.ts for modularity.
|
|
5
|
+
* Scans active sessions for idle ones and asks the LLM to assess their state.
|
|
6
|
+
*
|
|
7
|
+
* @module services/swarm-idle-watchdog
|
|
8
|
+
*/
|
|
9
|
+
import type { SwarmCoordinatorContext, TaskContext } from "./swarm-coordinator.js";
|
|
10
|
+
/** How long a session can be idle before the watchdog checks on it (ms). */
|
|
11
|
+
export declare const IDLE_THRESHOLD_MS: number;
|
|
12
|
+
/** Max idle checks before force-escalating a session. */
|
|
13
|
+
export declare const MAX_IDLE_CHECKS = 4;
|
|
14
|
+
/**
|
|
15
|
+
* Scan all active sessions for idle ones. Called periodically by the watchdog timer.
|
|
16
|
+
*/
|
|
17
|
+
export declare function scanIdleSessions(ctx: SwarmCoordinatorContext): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Handle an idle session by asking the LLM to assess its state.
|
|
20
|
+
*/
|
|
21
|
+
export declare function handleIdleCheck(ctx: SwarmCoordinatorContext, taskCtx: TaskContext, idleMinutes: number): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=swarm-idle-watchdog.d.ts.map
|