@getforgeai/cli 0.1.0-beta.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.
- package/LICENSE +201 -0
- package/README.md +80 -0
- package/dist/bin/forgeai.d.ts +3 -0
- package/dist/bin/forgeai.js +8 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +180 -0
- package/dist/commands/auth-login.d.ts +4 -0
- package/dist/commands/auth-login.js +202 -0
- package/dist/commands/auth-logout.d.ts +2 -0
- package/dist/commands/auth-logout.js +41 -0
- package/dist/commands/auth-status.d.ts +4 -0
- package/dist/commands/auth-status.js +81 -0
- package/dist/commands/cli-list.d.ts +4 -0
- package/dist/commands/cli-list.js +40 -0
- package/dist/commands/cli-unlink.d.ts +4 -0
- package/dist/commands/cli-unlink.js +45 -0
- package/dist/commands/config-set.d.ts +5 -0
- package/dist/commands/config-set.js +63 -0
- package/dist/commands/connect.d.ts +9 -0
- package/dist/commands/connect.js +165 -0
- package/dist/commands/disconnect.d.ts +5 -0
- package/dist/commands/disconnect.js +126 -0
- package/dist/commands/journal-clear.d.ts +2 -0
- package/dist/commands/journal-clear.js +16 -0
- package/dist/commands/journal-list.d.ts +2 -0
- package/dist/commands/journal-list.js +20 -0
- package/dist/commands/journal-status.d.ts +2 -0
- package/dist/commands/journal-status.js +18 -0
- package/dist/commands/mcp-serve.d.ts +13 -0
- package/dist/commands/mcp-serve.js +74 -0
- package/dist/commands/org-list.d.ts +4 -0
- package/dist/commands/org-list.js +56 -0
- package/dist/commands/org-unlink.d.ts +4 -0
- package/dist/commands/org-unlink.js +63 -0
- package/dist/commands/reconnect.d.ts +4 -0
- package/dist/commands/reconnect.js +46 -0
- package/dist/commands/release-open.d.ts +2 -0
- package/dist/commands/release-open.js +43 -0
- package/dist/commands/session-respond.d.ts +2 -0
- package/dist/commands/session-respond.js +29 -0
- package/dist/commands/task-open.d.ts +2 -0
- package/dist/commands/task-open.js +42 -0
- package/dist/commands/vm.d.ts +21 -0
- package/dist/commands/vm.js +122 -0
- package/dist/commands/workflow-open.d.ts +2 -0
- package/dist/commands/workflow-open.js +43 -0
- package/dist/config/config-manager.d.ts +31 -0
- package/dist/config/config-manager.js +70 -0
- package/dist/config/token-manager.d.ts +11 -0
- package/dist/config/token-manager.js +87 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +22 -0
- package/dist/lib/auth-client.d.ts +1670 -0
- package/dist/lib/auth-client.js +10 -0
- package/dist/lib/branch-manager.d.ts +79 -0
- package/dist/lib/branch-manager.js +620 -0
- package/dist/lib/clone-and-checkout.d.ts +6 -0
- package/dist/lib/clone-and-checkout.js +41 -0
- package/dist/lib/connection-manager.d.ts +58 -0
- package/dist/lib/connection-manager.js +436 -0
- package/dist/lib/daemon-entry.d.ts +2 -0
- package/dist/lib/daemon-entry.js +210 -0
- package/dist/lib/daemon.d.ts +38 -0
- package/dist/lib/daemon.js +148 -0
- package/dist/lib/event-journal.d.ts +24 -0
- package/dist/lib/event-journal.js +76 -0
- package/dist/lib/ipc-client.d.ts +10 -0
- package/dist/lib/ipc-client.js +70 -0
- package/dist/lib/ipc-server.d.ts +36 -0
- package/dist/lib/ipc-server.js +70 -0
- package/dist/lib/node-version-guard.d.ts +8 -0
- package/dist/lib/node-version-guard.js +60 -0
- package/dist/lib/open-directory.d.ts +7 -0
- package/dist/lib/open-directory.js +41 -0
- package/dist/lib/repo-manager.d.ts +29 -0
- package/dist/lib/repo-manager.js +103 -0
- package/dist/lib/resilient-emitter.d.ts +53 -0
- package/dist/lib/resilient-emitter.js +160 -0
- package/dist/lib/rest-client.d.ts +164 -0
- package/dist/lib/rest-client.js +139 -0
- package/dist/lib/skill-manager.d.ts +23 -0
- package/dist/lib/skill-manager.js +167 -0
- package/dist/lib/socket-client.d.ts +68 -0
- package/dist/lib/socket-client.js +160 -0
- package/dist/mcp/mcp-probe.d.ts +11 -0
- package/dist/mcp/mcp-probe.js +106 -0
- package/dist/mcp/mcp-response.d.ts +29 -0
- package/dist/mcp/mcp-response.js +67 -0
- package/dist/mcp/mcp-server.d.ts +19 -0
- package/dist/mcp/mcp-server.js +76 -0
- package/dist/mcp/resources/project-conventions.d.ts +4 -0
- package/dist/mcp/resources/project-conventions.js +50 -0
- package/dist/mcp/resources/task-current.d.ts +4 -0
- package/dist/mcp/resources/task-current.js +51 -0
- package/dist/mcp/tools/forge-add-group-dependency.d.ts +4 -0
- package/dist/mcp/tools/forge-add-group-dependency.js +20 -0
- package/dist/mcp/tools/forge-add-task-dependency.d.ts +4 -0
- package/dist/mcp/tools/forge-add-task-dependency.js +20 -0
- package/dist/mcp/tools/forge-ask-human.d.ts +4 -0
- package/dist/mcp/tools/forge-ask-human.js +80 -0
- package/dist/mcp/tools/forge-column-done.d.ts +4 -0
- package/dist/mcp/tools/forge-column-done.js +46 -0
- package/dist/mcp/tools/forge-complete-step.d.ts +4 -0
- package/dist/mcp/tools/forge-complete-step.js +139 -0
- package/dist/mcp/tools/forge-create-task-group.d.ts +4 -0
- package/dist/mcp/tools/forge-create-task-group.js +22 -0
- package/dist/mcp/tools/forge-create-task.d.ts +4 -0
- package/dist/mcp/tools/forge-create-task.js +28 -0
- package/dist/mcp/tools/forge-delete-task-group.d.ts +4 -0
- package/dist/mcp/tools/forge-delete-task-group.js +17 -0
- package/dist/mcp/tools/forge-delete-task.d.ts +4 -0
- package/dist/mcp/tools/forge-delete-task.js +17 -0
- package/dist/mcp/tools/forge-get-task.d.ts +4 -0
- package/dist/mcp/tools/forge-get-task.js +17 -0
- package/dist/mcp/tools/forge-merge-back.d.ts +4 -0
- package/dist/mcp/tools/forge-merge-back.js +179 -0
- package/dist/mcp/tools/forge-release-merge.d.ts +4 -0
- package/dist/mcp/tools/forge-release-merge.js +159 -0
- package/dist/mcp/tools/forge-release-notes.d.ts +4 -0
- package/dist/mcp/tools/forge-release-notes.js +51 -0
- package/dist/mcp/tools/forge-release-tag.d.ts +4 -0
- package/dist/mcp/tools/forge-release-tag.js +125 -0
- package/dist/mcp/tools/forge-remove-group-dependency.d.ts +4 -0
- package/dist/mcp/tools/forge-remove-group-dependency.js +19 -0
- package/dist/mcp/tools/forge-remove-task-dependency.d.ts +4 -0
- package/dist/mcp/tools/forge-remove-task-dependency.js +19 -0
- package/dist/mcp/tools/forge-requeue.d.ts +4 -0
- package/dist/mcp/tools/forge-requeue.js +39 -0
- package/dist/mcp/tools/forge-submit-pr.d.ts +4 -0
- package/dist/mcp/tools/forge-submit-pr.js +68 -0
- package/dist/mcp/tools/forge-update-status.d.ts +4 -0
- package/dist/mcp/tools/forge-update-status.js +77 -0
- package/dist/mcp/tools/forge-update-task-group.d.ts +4 -0
- package/dist/mcp/tools/forge-update-task-group.js +21 -0
- package/dist/mcp/tools/forge-update-task.d.ts +4 -0
- package/dist/mcp/tools/forge-update-task.js +25 -0
- package/dist/mcp/tools/forge-validate-merge.d.ts +4 -0
- package/dist/mcp/tools/forge-validate-merge.js +194 -0
- package/dist/mcp/types.d.ts +39 -0
- package/dist/mcp/types.js +8 -0
- package/dist/methodology/artifact-manager.d.ts +14 -0
- package/dist/methodology/artifact-manager.js +55 -0
- package/dist/orchestrator/agent-registry.d.ts +53 -0
- package/dist/orchestrator/agent-registry.js +96 -0
- package/dist/orchestrator/agent-spawner.d.ts +112 -0
- package/dist/orchestrator/agent-spawner.js +1518 -0
- package/dist/orchestrator/connectors/claude-code-connector.d.ts +3 -0
- package/dist/orchestrator/connectors/claude-code-connector.js +60 -0
- package/dist/orchestrator/connectors/connector.d.ts +95 -0
- package/dist/orchestrator/connectors/connector.js +25 -0
- package/dist/orchestrator/connectors/docker-connector.d.ts +14 -0
- package/dist/orchestrator/connectors/docker-connector.js +337 -0
- package/dist/orchestrator/connectors/native-vm-connector.d.ts +11 -0
- package/dist/orchestrator/connectors/native-vm-connector.js +162 -0
- package/dist/orchestrator/connectors/opencode-connector.d.ts +3 -0
- package/dist/orchestrator/connectors/opencode-connector.js +39 -0
- package/dist/orchestrator/connectors/vm-connector.d.ts +3 -0
- package/dist/orchestrator/connectors/vm-connector.js +139 -0
- package/dist/orchestrator/dispatch-queue.d.ts +43 -0
- package/dist/orchestrator/dispatch-queue.js +93 -0
- package/dist/orchestrator/resume-handler.d.ts +34 -0
- package/dist/orchestrator/resume-handler.js +159 -0
- package/dist/orchestrator/stream-batcher.d.ts +16 -0
- package/dist/orchestrator/stream-batcher.js +50 -0
- package/dist/orchestrator/stream-json-extractor.d.ts +97 -0
- package/dist/orchestrator/stream-json-extractor.js +579 -0
- package/dist/vm/claude-token-manager.d.ts +36 -0
- package/dist/vm/claude-token-manager.js +223 -0
- package/dist/vm/docker-executor.d.ts +131 -0
- package/dist/vm/docker-executor.js +360 -0
- package/dist/vm/docker-process-proxy.d.ts +31 -0
- package/dist/vm/docker-process-proxy.js +105 -0
- package/dist/vm/forge-vm-agent.d.ts +11 -0
- package/dist/vm/forge-vm-agent.js +159 -0
- package/dist/vm/git-credentials.d.ts +43 -0
- package/dist/vm/git-credentials.js +53 -0
- package/dist/vm/image-manager.d.ts +7 -0
- package/dist/vm/image-manager.js +61 -0
- package/dist/vm/log.d.ts +9 -0
- package/dist/vm/log.js +18 -0
- package/dist/vm/mcp-bridge.d.ts +63 -0
- package/dist/vm/mcp-bridge.js +243 -0
- package/dist/vm/mcp-stub.d.ts +15 -0
- package/dist/vm/mcp-stub.js +67 -0
- package/dist/vm/native-addon.d.ts +69 -0
- package/dist/vm/native-addon.js +68 -0
- package/dist/vm/provider-resolver.d.ts +7 -0
- package/dist/vm/provider-resolver.js +27 -0
- package/dist/vm/providers/lima.d.ts +17 -0
- package/dist/vm/providers/lima.js +191 -0
- package/dist/vm/providers/qemu.d.ts +28 -0
- package/dist/vm/providers/qemu.js +260 -0
- package/dist/vm/providers/vfkit.d.ts +40 -0
- package/dist/vm/providers/vfkit.js +371 -0
- package/dist/vm/providers/wsl2.d.ts +27 -0
- package/dist/vm/providers/wsl2.js +226 -0
- package/dist/vm/session-manager.d.ts +130 -0
- package/dist/vm/session-manager.js +494 -0
- package/dist/vm/session-snapshot.d.ts +31 -0
- package/dist/vm/session-snapshot.js +180 -0
- package/dist/vm/types.d.ts +73 -0
- package/dist/vm/types.js +2 -0
- package/dist/vm/vm-helper-client.d.ts +81 -0
- package/dist/vm/vm-helper-client.js +335 -0
- package/dist/vm/vm-helper.d.ts +11 -0
- package/dist/vm/vm-helper.js +156 -0
- package/dist/vm/vm-ipc-protocol.d.ts +84 -0
- package/dist/vm/vm-ipc-protocol.js +9 -0
- package/dist/vm/vm-manager-facade.d.ts +23 -0
- package/dist/vm/vm-manager-facade.js +43 -0
- package/dist/vm/vm-manager.d.ts +74 -0
- package/dist/vm/vm-manager.js +515 -0
- package/dist/vm/vm-process-proxy.d.ts +34 -0
- package/dist/vm/vm-process-proxy.js +64 -0
- package/dist/vm/vsock-bridge.d.ts +44 -0
- package/dist/vm/vsock-bridge.js +140 -0
- package/dist/vm/vsock-protocol.d.ts +98 -0
- package/dist/vm/vsock-protocol.js +57 -0
- package/package.json +65 -0
- package/rootfs/Dockerfile +50 -0
- package/rootfs/forge-mcp-relay.mjs +158 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AgentEntry } from "./connectors/connector.js";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory registry tracking running agent subprocesses.
|
|
4
|
+
* Maps taskId → AgentEntry. No persistence — agents are ephemeral.
|
|
5
|
+
*
|
|
6
|
+
* Supports slot reservation to prevent over-allocation during async spawn pipelines.
|
|
7
|
+
* Flow: reserveSlot() → async spawn → confirmSlot() on success / releaseSlot() on failure.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AgentRegistry {
|
|
10
|
+
private readonly agents;
|
|
11
|
+
private readonly pendingReservations;
|
|
12
|
+
maxSlots: number;
|
|
13
|
+
constructor(agentSlots: number);
|
|
14
|
+
/**
|
|
15
|
+
* Dynamically update the max slot capacity.
|
|
16
|
+
* Called when the server pushes a config update (e.g., admin changed agentSlots in UI).
|
|
17
|
+
*/
|
|
18
|
+
updateMaxSlots(newMaxSlots: number): void;
|
|
19
|
+
register(entry: AgentEntry): void;
|
|
20
|
+
unregister(taskId: string): void;
|
|
21
|
+
getByTaskId(taskId: string): AgentEntry | undefined;
|
|
22
|
+
getActive(): AgentEntry[];
|
|
23
|
+
getActiveCount(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Count agents that are provisioned (RUNNING or IDLE).
|
|
26
|
+
* Used for heartbeat reporting — IDLE agents still occupy a "visible" slot
|
|
27
|
+
* so the UI shows them as provisioned during the idle window.
|
|
28
|
+
*/
|
|
29
|
+
getProvisionedCount(): number;
|
|
30
|
+
hasCapacity(): boolean;
|
|
31
|
+
getAll(): AgentEntry[];
|
|
32
|
+
/**
|
|
33
|
+
* Reserve a slot for an upcoming spawn. Returns false if no capacity.
|
|
34
|
+
* The reservation counts toward capacity to prevent concurrent over-allocation.
|
|
35
|
+
*/
|
|
36
|
+
reserveSlot(taskId: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Confirm a reservation — converts pending reservation to a registered agent.
|
|
39
|
+
*/
|
|
40
|
+
confirmSlot(taskId: string, entry: AgentEntry): void;
|
|
41
|
+
/**
|
|
42
|
+
* Release a reservation without registering (spawn failed).
|
|
43
|
+
*/
|
|
44
|
+
releaseSlot(taskId: string): void;
|
|
45
|
+
getPendingReservationCount(): number;
|
|
46
|
+
/**
|
|
47
|
+
* Check if a task has a pending reservation (spawn in flight).
|
|
48
|
+
* Used to prevent dual-path race conditions where two concurrent spawn
|
|
49
|
+
* attempts pass the getByTaskId() check before either confirms.
|
|
50
|
+
*/
|
|
51
|
+
hasPendingReservation(taskId: string): boolean;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=agent-registry.d.ts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { vmLog } from "../vm/log.js";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory registry tracking running agent subprocesses.
|
|
4
|
+
* Maps taskId → AgentEntry. No persistence — agents are ephemeral.
|
|
5
|
+
*
|
|
6
|
+
* Supports slot reservation to prevent over-allocation during async spawn pipelines.
|
|
7
|
+
* Flow: reserveSlot() → async spawn → confirmSlot() on success / releaseSlot() on failure.
|
|
8
|
+
*/
|
|
9
|
+
export class AgentRegistry {
|
|
10
|
+
agents = new Map();
|
|
11
|
+
pendingReservations = new Set();
|
|
12
|
+
maxSlots;
|
|
13
|
+
constructor(agentSlots) {
|
|
14
|
+
this.maxSlots = agentSlots;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Dynamically update the max slot capacity.
|
|
18
|
+
* Called when the server pushes a config update (e.g., admin changed agentSlots in UI).
|
|
19
|
+
*/
|
|
20
|
+
updateMaxSlots(newMaxSlots) {
|
|
21
|
+
this.maxSlots = newMaxSlots;
|
|
22
|
+
}
|
|
23
|
+
register(entry) {
|
|
24
|
+
if (this.getActiveCount() >= this.maxSlots) {
|
|
25
|
+
throw new Error(`Agent slot limit reached (${this.maxSlots}). Cannot spawn more agents.`);
|
|
26
|
+
}
|
|
27
|
+
this.agents.set(entry.taskId, entry);
|
|
28
|
+
}
|
|
29
|
+
unregister(taskId) {
|
|
30
|
+
this.agents.delete(taskId);
|
|
31
|
+
this.pendingReservations.delete(taskId);
|
|
32
|
+
}
|
|
33
|
+
getByTaskId(taskId) {
|
|
34
|
+
return this.agents.get(taskId);
|
|
35
|
+
}
|
|
36
|
+
getActive() {
|
|
37
|
+
return Array.from(this.agents.values()).filter((e) => e.status === "RUNNING");
|
|
38
|
+
}
|
|
39
|
+
getActiveCount() {
|
|
40
|
+
return this.getActive().length;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Count agents that are provisioned (RUNNING or IDLE).
|
|
44
|
+
* Used for heartbeat reporting — IDLE agents still occupy a "visible" slot
|
|
45
|
+
* so the UI shows them as provisioned during the idle window.
|
|
46
|
+
*/
|
|
47
|
+
getProvisionedCount() {
|
|
48
|
+
return Array.from(this.agents.values()).filter((e) => e.status === "RUNNING" || e.status === "IDLE").length;
|
|
49
|
+
}
|
|
50
|
+
hasCapacity() {
|
|
51
|
+
return (this.getProvisionedCount() + this.pendingReservations.size < this.maxSlots);
|
|
52
|
+
}
|
|
53
|
+
getAll() {
|
|
54
|
+
return Array.from(this.agents.values());
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Reserve a slot for an upcoming spawn. Returns false if no capacity.
|
|
58
|
+
* The reservation counts toward capacity to prevent concurrent over-allocation.
|
|
59
|
+
*/
|
|
60
|
+
reserveSlot(taskId) {
|
|
61
|
+
if (!this.hasCapacity()) {
|
|
62
|
+
vmLog.dim("registry", `Slot reservation rejected for ${taskId} (${this.getProvisionedCount()} provisioned + ${this.pendingReservations.size} pending >= ${this.maxSlots} max)`);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
this.pendingReservations.add(taskId);
|
|
66
|
+
vmLog.dim("registry", `Slot reserved for ${taskId} (${this.pendingReservations.size} pending)`);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Confirm a reservation — converts pending reservation to a registered agent.
|
|
71
|
+
*/
|
|
72
|
+
confirmSlot(taskId, entry) {
|
|
73
|
+
this.pendingReservations.delete(taskId);
|
|
74
|
+
this.agents.set(entry.taskId, entry);
|
|
75
|
+
vmLog.dim("registry", `Slot confirmed for ${taskId} (${this.pendingReservations.size} pending)`);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Release a reservation without registering (spawn failed).
|
|
79
|
+
*/
|
|
80
|
+
releaseSlot(taskId) {
|
|
81
|
+
this.pendingReservations.delete(taskId);
|
|
82
|
+
vmLog.dim("registry", `Slot released for ${taskId} (${this.pendingReservations.size} pending)`);
|
|
83
|
+
}
|
|
84
|
+
getPendingReservationCount() {
|
|
85
|
+
return this.pendingReservations.size;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if a task has a pending reservation (spawn in flight).
|
|
89
|
+
* Used to prevent dual-path race conditions where two concurrent spawn
|
|
90
|
+
* attempts pass the getByTaskId() check before either confirms.
|
|
91
|
+
*/
|
|
92
|
+
hasPendingReservation(taskId) {
|
|
93
|
+
return this.pendingReservations.has(taskId);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=agent-registry.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Socket } from "socket.io-client";
|
|
3
|
+
import type { ClientToServerEvents, ServerToClientEvents } from "@getforgeai/protocol";
|
|
4
|
+
import type { AgentConnector } from "./connectors/connector.js";
|
|
5
|
+
import { AgentRegistry } from "./agent-registry.js";
|
|
6
|
+
import type { createRestClient } from "../lib/rest-client.js";
|
|
7
|
+
import type { createSocketClient } from "../lib/socket-client.js";
|
|
8
|
+
import type { DispatchQueue, DrainContext } from "./dispatch-queue.js";
|
|
9
|
+
type TypedClientSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
|
|
10
|
+
/** Wait for pending fallback REST calls to complete (with timeout). */
|
|
11
|
+
export declare function awaitPendingFallbacks(timeoutMs: number): Promise<void>;
|
|
12
|
+
export declare const DEFAULT_SKILL_NAME = "execute-task";
|
|
13
|
+
/** Mark a task as having called forge_ask_human (called from MCP tool) */
|
|
14
|
+
export declare function markAskHuman(taskId: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Clear all idle windows and their timers.
|
|
17
|
+
* Called on socket disconnect to prevent stale timers emitting on dead sockets.
|
|
18
|
+
* Also unregisters IDLE agents from registry to free slots on reconnect.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clearAllIdleWindows(socket: TypedClientSocket, agentSlots: number): void;
|
|
21
|
+
export declare const TaskDispatchSchema: z.ZodObject<{
|
|
22
|
+
taskId: z.ZodString;
|
|
23
|
+
projectId: z.ZodString;
|
|
24
|
+
assigneeId: z.ZodString;
|
|
25
|
+
taskCommand: z.ZodOptional<z.ZodString>;
|
|
26
|
+
skillSlug: z.ZodOptional<z.ZodString>;
|
|
27
|
+
workflowBaseBranch: z.ZodOptional<z.ZodString>;
|
|
28
|
+
taskBranch: z.ZodOptional<z.ZodString>;
|
|
29
|
+
taskSlug: z.ZodOptional<z.ZodString>;
|
|
30
|
+
projectSlug: z.ZodOptional<z.ZodString>;
|
|
31
|
+
repoUrl: z.ZodOptional<z.ZodString>;
|
|
32
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type DispatchParams = z.infer<typeof TaskDispatchSchema> & {
|
|
35
|
+
orgId: string;
|
|
36
|
+
};
|
|
37
|
+
export type SpawnerContext = {
|
|
38
|
+
restClient: ReturnType<typeof createRestClient>;
|
|
39
|
+
socketClient: ReturnType<typeof createSocketClient>;
|
|
40
|
+
agentType: string;
|
|
41
|
+
agentSlots: number;
|
|
42
|
+
queue: DispatchQueue;
|
|
43
|
+
};
|
|
44
|
+
/** Exported for testing */
|
|
45
|
+
export declare function resetRegistry(): void;
|
|
46
|
+
export declare function getAgentRegistry(agentSlots: number): AgentRegistry;
|
|
47
|
+
export declare function resolveConnector(agentTypeOrName: string): AgentConnector;
|
|
48
|
+
type ProcessHandlerArgs = {
|
|
49
|
+
taskId: string;
|
|
50
|
+
projectId: string;
|
|
51
|
+
registry: AgentRegistry;
|
|
52
|
+
socketClient: ReturnType<typeof createSocketClient>;
|
|
53
|
+
restClient: ReturnType<typeof createRestClient>;
|
|
54
|
+
queue: DispatchQueue;
|
|
55
|
+
spawnAgentFn: (params: DispatchParams) => Promise<void>;
|
|
56
|
+
label: string;
|
|
57
|
+
agentSlots: number;
|
|
58
|
+
/** Session/container ID for log context */
|
|
59
|
+
sessionId?: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Attach exit and error handlers to an agent process.
|
|
63
|
+
* Shared between spawnAgent and handleResume to deduplicate handler code.
|
|
64
|
+
*/
|
|
65
|
+
export declare function attachProcessHandlers(process: NodeJS.EventEmitter, args: ProcessHandlerArgs): void;
|
|
66
|
+
type WorkflowProcessHandlerArgs = ProcessHandlerArgs & {
|
|
67
|
+
workflowId: string;
|
|
68
|
+
stepId: string;
|
|
69
|
+
conversationId: string;
|
|
70
|
+
/** Optional callback invoked on exit instead of default unregister+drain. */
|
|
71
|
+
onExit?: (code: number | null, accumulatedContent: string) => void;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Attach exit and error handlers to a workflow step agent process.
|
|
75
|
+
* Dual-emits: workflow:stream (wizard chat) + agent:stream (activity monitoring).
|
|
76
|
+
* On exit, emits workflow:stream:end with accumulated content for persistence.
|
|
77
|
+
*/
|
|
78
|
+
export declare function attachWorkflowProcessHandlers(process: NodeJS.EventEmitter, args: WorkflowProcessHandlerArgs): void;
|
|
79
|
+
/**
|
|
80
|
+
* Main spawn pipeline — orchestrates the full agent lifecycle.
|
|
81
|
+
* Uses slot reservation to prevent over-allocation during async pipeline.
|
|
82
|
+
*/
|
|
83
|
+
export declare function spawnAgent(params: DispatchParams, ctx: SpawnerContext): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Stop a specific agent by taskId.
|
|
86
|
+
*/
|
|
87
|
+
export declare function stopAgent(taskId: string, ctx: SpawnerContext): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Graceful shutdown of all running agents.
|
|
90
|
+
* Clears queue, unregisters first (prevents exit handler race), then sends SIGTERM,
|
|
91
|
+
* waits up to 10s, then SIGKILL survivors.
|
|
92
|
+
*/
|
|
93
|
+
export declare function stopAllAgents(ctx: SpawnerContext): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Register the task:dispatch Socket.io handler on the CLI socket.
|
|
96
|
+
*/
|
|
97
|
+
export declare function registerDispatchHandler(socket: TypedClientSocket, orgId: string, ctx: SpawnerContext): DrainContext;
|
|
98
|
+
/**
|
|
99
|
+
* Register the task:resume Socket.io handler on the CLI socket (Story 6.4).
|
|
100
|
+
*/
|
|
101
|
+
export declare function registerResumeHandler(socket: TypedClientSocket, orgId: string, ctx: SpawnerContext): void;
|
|
102
|
+
/**
|
|
103
|
+
* Register the workflow:step:dispatch Socket.io handler on the CLI socket (Story 6b-7).
|
|
104
|
+
*/
|
|
105
|
+
export declare function registerWorkflowStepDispatchHandler(socket: TypedClientSocket, orgId: string, ctx: SpawnerContext): void;
|
|
106
|
+
/**
|
|
107
|
+
* Register workflow:agent:dismiss handler — Cloud tells CLI to clear idle window.
|
|
108
|
+
* Called when user advances to next step after approving deliverables.
|
|
109
|
+
*/
|
|
110
|
+
export declare function registerWorkflowAgentDismissHandler(socket: TypedClientSocket, ctx: SpawnerContext): void;
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=agent-spawner.d.ts.map
|