@miriad-systems/backend 0.1.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/dist/agent-manager.d.ts +69 -0
- package/dist/agent-manager.d.ts.map +1 -0
- package/dist/agent-manager.js +424 -0
- package/dist/agent-manager.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +203 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +60 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +221 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime-client.d.ts +80 -0
- package/dist/runtime-client.d.ts.map +1 -0
- package/dist/runtime-client.js +347 -0
- package/dist/runtime-client.js.map +1 -0
- package/dist/tymbal-bridge.d.ts +47 -0
- package/dist/tymbal-bridge.d.ts.map +1 -0
- package/dist/tymbal-bridge.js +283 -0
- package/dist/tymbal-bridge.js.map +1 -0
- package/dist/types.d.ts +181 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages multiple Claude SDK agent instances within a single runtime process.
|
|
5
|
+
* Handles agent lifecycle: activation, message routing, suspension.
|
|
6
|
+
*
|
|
7
|
+
* Key feature: Streaming input support - messages can be pushed to Claude
|
|
8
|
+
* during execution using the SDK's AsyncIterable prompt feature.
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentState, ActivateAgentMessage, DeliverMessageMessage, SuspendAgentMessage, AgentFrameMessage } from './types.js';
|
|
11
|
+
export interface AgentManagerConfig {
|
|
12
|
+
/** Base path for agent workspaces */
|
|
13
|
+
workspaceBasePath: string;
|
|
14
|
+
/** Callback when agent sends a frame */
|
|
15
|
+
onFrame: (message: AgentFrameMessage) => void;
|
|
16
|
+
/** Callback when agent checks in (SDK ready) */
|
|
17
|
+
onCheckin: (agentId: string) => void;
|
|
18
|
+
/** Callback on agent error */
|
|
19
|
+
onError?: (agentId: string, error: Error) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function parseAgentId(agentId: string): {
|
|
22
|
+
spaceId: string;
|
|
23
|
+
channelId: string;
|
|
24
|
+
callsign: string;
|
|
25
|
+
};
|
|
26
|
+
export declare class AgentManager {
|
|
27
|
+
private readonly config;
|
|
28
|
+
private readonly agents;
|
|
29
|
+
constructor(config: AgentManagerConfig);
|
|
30
|
+
/**
|
|
31
|
+
* Get all agents.
|
|
32
|
+
*/
|
|
33
|
+
getAgents(): AgentState[];
|
|
34
|
+
/**
|
|
35
|
+
* Get a specific agent's state.
|
|
36
|
+
*/
|
|
37
|
+
getAgent(agentId: string): AgentState | null;
|
|
38
|
+
/**
|
|
39
|
+
* Activate an agent (spawn Claude SDK).
|
|
40
|
+
*/
|
|
41
|
+
activate(message: ActivateAgentMessage): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Format a message with sender header.
|
|
44
|
+
*/
|
|
45
|
+
private formatMessage;
|
|
46
|
+
/**
|
|
47
|
+
* Deliver a message to an agent.
|
|
48
|
+
* Auto-activates the agent if it doesn't exist (local runtime is always-on).
|
|
49
|
+
*/
|
|
50
|
+
deliverMessage(message: DeliverMessageMessage): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Suspend an agent (tear down SDK).
|
|
53
|
+
*/
|
|
54
|
+
suspend(message: SuspendAgentMessage): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Suspend all agents (for shutdown).
|
|
57
|
+
*/
|
|
58
|
+
suspendAll(): Promise<void>;
|
|
59
|
+
private ensureWorkspace;
|
|
60
|
+
private getClaudeConfigDir;
|
|
61
|
+
private hasExistingSession;
|
|
62
|
+
private processMessage;
|
|
63
|
+
/**
|
|
64
|
+
* Process the message queue for an agent.
|
|
65
|
+
* Batches all queued messages into a single message to match sandbox behavior.
|
|
66
|
+
*/
|
|
67
|
+
private processQueue;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=agent-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-manager.d.ts","sourceRoot":"","sources":["../src/agent-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EACV,UAAU,EAEV,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,YAAY,CAAC;AA6HpB,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wCAAwC;IACxC,OAAO,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,gDAAgD;IAChD,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnD;AAMD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAUA;AAMD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;gBAE/C,MAAM,EAAE,kBAAkB;IAItC;;OAEG;IACH,SAAS,IAAI,UAAU,EAAE;IAIzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAI5C;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8D5D;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;;OAGG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0DnE;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B1D;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAWjC,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,kBAAkB;YAIZ,cAAc;IAyH5B;;;OAGG;YACW,YAAY;CAmB3B"}
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages multiple Claude SDK agent instances within a single runtime process.
|
|
5
|
+
* Handles agent lifecycle: activation, message routing, suspension.
|
|
6
|
+
*
|
|
7
|
+
* Key feature: Streaming input support - messages can be pushed to Claude
|
|
8
|
+
* during execution using the SDK's AsyncIterable prompt feature.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { randomUUID } from 'node:crypto';
|
|
13
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
14
|
+
import { TymbalBridge } from './tymbal-bridge.js';
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// Message Stream Factory
|
|
17
|
+
// =============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Create a message stream that can push messages to Claude during execution.
|
|
20
|
+
*
|
|
21
|
+
* The stream works as follows:
|
|
22
|
+
* 1. First call to next() yields the initial message immediately
|
|
23
|
+
* 2. Subsequent calls wait for push() to add messages to the queue
|
|
24
|
+
* 3. When Claude asks for next input, we batch all queued messages and yield
|
|
25
|
+
* 4. close() signals no more messages (ends the stream)
|
|
26
|
+
*/
|
|
27
|
+
function createMessageStream(initialContent) {
|
|
28
|
+
const sessionId = randomUUID();
|
|
29
|
+
const queue = [];
|
|
30
|
+
let closed = false;
|
|
31
|
+
let resolveWaiting = null;
|
|
32
|
+
// Helper to create SDKUserMessage from content
|
|
33
|
+
function makeMessage(content) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'user',
|
|
36
|
+
message: {
|
|
37
|
+
role: 'user',
|
|
38
|
+
content,
|
|
39
|
+
},
|
|
40
|
+
parent_tool_use_id: null,
|
|
41
|
+
session_id: sessionId,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const stream = {
|
|
45
|
+
sessionId,
|
|
46
|
+
push(content) {
|
|
47
|
+
if (closed) {
|
|
48
|
+
console.warn('[MessageStream] Cannot push to closed stream');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
queue.push(content);
|
|
52
|
+
// If Claude is waiting for input, resolve immediately with batched messages
|
|
53
|
+
if (resolveWaiting && queue.length > 0) {
|
|
54
|
+
const batched = queue.splice(0).join('\n\n');
|
|
55
|
+
resolveWaiting({ value: makeMessage(batched), done: false });
|
|
56
|
+
resolveWaiting = null;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
close() {
|
|
60
|
+
closed = true;
|
|
61
|
+
// If Claude is waiting, signal end of stream
|
|
62
|
+
if (resolveWaiting) {
|
|
63
|
+
resolveWaiting({ value: undefined, done: true });
|
|
64
|
+
resolveWaiting = null;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
iterable: {
|
|
68
|
+
[Symbol.asyncIterator]() {
|
|
69
|
+
let yieldedInitial = false;
|
|
70
|
+
return {
|
|
71
|
+
async next() {
|
|
72
|
+
// First call: yield initial message immediately
|
|
73
|
+
if (!yieldedInitial) {
|
|
74
|
+
yieldedInitial = true;
|
|
75
|
+
return { value: makeMessage(initialContent), done: false };
|
|
76
|
+
}
|
|
77
|
+
// If stream is closed and queue is empty, we're done
|
|
78
|
+
if (closed && queue.length === 0) {
|
|
79
|
+
return { value: undefined, done: true };
|
|
80
|
+
}
|
|
81
|
+
// If there are queued messages, batch and yield them
|
|
82
|
+
if (queue.length > 0) {
|
|
83
|
+
const batched = queue.splice(0).join('\n\n');
|
|
84
|
+
return { value: makeMessage(batched), done: false };
|
|
85
|
+
}
|
|
86
|
+
// Wait for push() or close()
|
|
87
|
+
return new Promise((resolve) => {
|
|
88
|
+
resolveWaiting = resolve;
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
return stream;
|
|
96
|
+
}
|
|
97
|
+
// =============================================================================
|
|
98
|
+
// Agent ID Parsing
|
|
99
|
+
// =============================================================================
|
|
100
|
+
export function parseAgentId(agentId) {
|
|
101
|
+
const parts = agentId.split(':');
|
|
102
|
+
if (parts.length !== 3) {
|
|
103
|
+
throw new Error(`Invalid agentId format: ${agentId}. Expected spaceId:channelId:callsign`);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
spaceId: parts[0],
|
|
107
|
+
channelId: parts[1],
|
|
108
|
+
callsign: parts[2],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// =============================================================================
|
|
112
|
+
// Agent Manager
|
|
113
|
+
// =============================================================================
|
|
114
|
+
export class AgentManager {
|
|
115
|
+
config;
|
|
116
|
+
agents = new Map();
|
|
117
|
+
constructor(config) {
|
|
118
|
+
this.config = config;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get all agents.
|
|
122
|
+
*/
|
|
123
|
+
getAgents() {
|
|
124
|
+
return Array.from(this.agents.values()).map((instance) => instance.state);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get a specific agent's state.
|
|
128
|
+
*/
|
|
129
|
+
getAgent(agentId) {
|
|
130
|
+
return this.agents.get(agentId)?.state ?? null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Activate an agent (spawn Claude SDK).
|
|
134
|
+
*/
|
|
135
|
+
async activate(message) {
|
|
136
|
+
const { agentId, systemPrompt, mcpServers, workspacePath } = message;
|
|
137
|
+
const { callsign } = parseAgentId(agentId);
|
|
138
|
+
console.log(`[AgentManager] Activating ${agentId}`);
|
|
139
|
+
console.log(`[AgentManager] mcpServers from message:`, JSON.stringify(mcpServers));
|
|
140
|
+
// Check if already active
|
|
141
|
+
const existing = this.agents.get(agentId);
|
|
142
|
+
if (existing && existing.state.status !== 'offline') {
|
|
143
|
+
console.log(`[AgentManager] Agent ${agentId} already active (${existing.state.status})`);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
console.log(`[AgentManager] @${callsign} state: offline → activating`);
|
|
147
|
+
// Always use local config basePath + agentId structure for security
|
|
148
|
+
// (ignore workspacePath from backend to prevent arbitrary path access)
|
|
149
|
+
const resolvedPath = join(this.config.workspaceBasePath, agentId.replace(/:/g, '/'));
|
|
150
|
+
console.log(`[AgentManager] @${callsign} workspace config:`);
|
|
151
|
+
console.log(`[AgentManager] basePath: ${this.config.workspaceBasePath}`);
|
|
152
|
+
console.log(`[AgentManager] backend workspacePath (ignored): ${workspacePath || '(none)'}`);
|
|
153
|
+
console.log(`[AgentManager] resolved: ${resolvedPath}`);
|
|
154
|
+
this.ensureWorkspace(resolvedPath);
|
|
155
|
+
// Create bridge
|
|
156
|
+
const bridge = new TymbalBridge({
|
|
157
|
+
agentId,
|
|
158
|
+
callsign,
|
|
159
|
+
onFrame: this.config.onFrame,
|
|
160
|
+
});
|
|
161
|
+
// Create agent instance
|
|
162
|
+
const instance = {
|
|
163
|
+
state: {
|
|
164
|
+
agentId,
|
|
165
|
+
status: 'activating',
|
|
166
|
+
workspacePath: resolvedPath,
|
|
167
|
+
systemPrompt,
|
|
168
|
+
mcpServers,
|
|
169
|
+
activatedAt: new Date().toISOString(),
|
|
170
|
+
lastActivity: new Date().toISOString(),
|
|
171
|
+
},
|
|
172
|
+
bridge,
|
|
173
|
+
messageQueue: [],
|
|
174
|
+
isProcessing: false,
|
|
175
|
+
messageStream: null,
|
|
176
|
+
};
|
|
177
|
+
console.log(`[AgentManager] Stored mcpServers in state:`, JSON.stringify(instance.state.mcpServers));
|
|
178
|
+
this.agents.set(agentId, instance);
|
|
179
|
+
// Signal checkin (SDK ready)
|
|
180
|
+
// In a real implementation, we'd wait for SDK initialization
|
|
181
|
+
// For now, we mark as online immediately after activation setup
|
|
182
|
+
instance.state.status = 'online';
|
|
183
|
+
instance.state.lastActivity = new Date().toISOString();
|
|
184
|
+
this.config.onCheckin(agentId);
|
|
185
|
+
console.log(`[AgentManager] @${callsign} state: activating → online`);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Format a message with sender header.
|
|
189
|
+
*/
|
|
190
|
+
formatMessage(message) {
|
|
191
|
+
return `--- @${message.sender} says:\n${message.content}`;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Deliver a message to an agent.
|
|
195
|
+
* Auto-activates the agent if it doesn't exist (local runtime is always-on).
|
|
196
|
+
*/
|
|
197
|
+
async deliverMessage(message) {
|
|
198
|
+
const { agentId, systemPrompt, mcpServers } = message;
|
|
199
|
+
let instance = this.agents.get(agentId);
|
|
200
|
+
const { callsign } = parseAgentId(agentId);
|
|
201
|
+
// Auto-activate agent if not found or offline (local runtime is always-on)
|
|
202
|
+
if (!instance || instance.state.status === 'offline') {
|
|
203
|
+
console.log(`[AgentManager] @${callsign} not active, auto-activating for message delivery`);
|
|
204
|
+
if (mcpServers) {
|
|
205
|
+
console.log(`[AgentManager] Auto-activation WITH mcpServers (count: ${mcpServers.length})`);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
console.warn(`[AgentManager] WARNING: Auto-activation WITHOUT mcpServers!`);
|
|
209
|
+
}
|
|
210
|
+
await this.activate({
|
|
211
|
+
type: 'activate',
|
|
212
|
+
agentId,
|
|
213
|
+
systemPrompt: systemPrompt || '',
|
|
214
|
+
workspacePath: '', // Will be ignored, uses local config
|
|
215
|
+
mcpServers, // Now passed from message
|
|
216
|
+
});
|
|
217
|
+
instance = this.agents.get(agentId);
|
|
218
|
+
if (!instance) {
|
|
219
|
+
console.error(`[AgentManager] Failed to auto-activate agent ${agentId}`);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
console.log(`[AgentManager] @${callsign} auto-activated, proceeding with message`);
|
|
223
|
+
}
|
|
224
|
+
// Update mcpServers if provided in message (keeps config fresh even for online agents)
|
|
225
|
+
if (mcpServers && instance) {
|
|
226
|
+
console.log(`[AgentManager] Updating mcpServers for online agent @${callsign} (count: ${mcpServers.length})`);
|
|
227
|
+
instance.state.mcpServers = mcpServers;
|
|
228
|
+
}
|
|
229
|
+
// Format message with sender header
|
|
230
|
+
const formattedContent = this.formatMessage(message);
|
|
231
|
+
// If agent is processing and has an active stream, push to it (mid-execution delivery!)
|
|
232
|
+
if (instance.isProcessing && instance.messageStream) {
|
|
233
|
+
console.log(`[AgentManager] @${callsign} busy with active stream, pushing message mid-execution`);
|
|
234
|
+
instance.messageStream.push(formattedContent);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
// Legacy fallback: queue message if processing but no stream (shouldn't happen with new code)
|
|
238
|
+
if (instance.isProcessing) {
|
|
239
|
+
console.log(`[AgentManager] @${callsign} busy (no stream), queueing message`);
|
|
240
|
+
instance.messageQueue.push(message);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
// Process message (will transition to busy)
|
|
244
|
+
console.log(`[AgentManager] @${callsign} calling processMessage with content length: ${formattedContent.length}`);
|
|
245
|
+
await this.processMessage(instance, formattedContent, systemPrompt);
|
|
246
|
+
console.log(`[AgentManager] @${callsign} processMessage returned`);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Suspend an agent (tear down SDK).
|
|
250
|
+
*/
|
|
251
|
+
async suspend(message) {
|
|
252
|
+
const { agentId, reason } = message;
|
|
253
|
+
const instance = this.agents.get(agentId);
|
|
254
|
+
if (!instance) {
|
|
255
|
+
console.log(`[AgentManager] Agent ${agentId} not found for suspension`);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const { callsign } = parseAgentId(agentId);
|
|
259
|
+
const oldStatus = instance.state.status;
|
|
260
|
+
console.log(`[AgentManager] @${callsign} state: ${oldStatus} → offline (${reason ?? 'no reason'})`);
|
|
261
|
+
// Update state
|
|
262
|
+
instance.state.status = 'offline';
|
|
263
|
+
instance.state.lastActivity = new Date().toISOString();
|
|
264
|
+
// Close any active message stream
|
|
265
|
+
if (instance.messageStream) {
|
|
266
|
+
instance.messageStream.close();
|
|
267
|
+
instance.messageStream = null;
|
|
268
|
+
}
|
|
269
|
+
// Clear message queue
|
|
270
|
+
instance.messageQueue = [];
|
|
271
|
+
instance.isProcessing = false;
|
|
272
|
+
// Optionally remove from map (or keep for restart)
|
|
273
|
+
// this.agents.delete(agentId);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Suspend all agents (for shutdown).
|
|
277
|
+
*/
|
|
278
|
+
async suspendAll() {
|
|
279
|
+
const agentIds = Array.from(this.agents.keys());
|
|
280
|
+
for (const agentId of agentIds) {
|
|
281
|
+
await this.suspend({ type: 'suspend', agentId, reason: 'runtime shutdown' });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// ===========================================================================
|
|
285
|
+
// Private Methods
|
|
286
|
+
// ===========================================================================
|
|
287
|
+
ensureWorkspace(workspace) {
|
|
288
|
+
if (!existsSync(workspace)) {
|
|
289
|
+
console.log(`[AgentManager] Creating workspace: ${workspace}`);
|
|
290
|
+
mkdirSync(workspace, { recursive: true });
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
getClaudeConfigDir(workspace) {
|
|
294
|
+
return join(workspace, '.claude');
|
|
295
|
+
}
|
|
296
|
+
hasExistingSession(workspace) {
|
|
297
|
+
return existsSync(this.getClaudeConfigDir(workspace));
|
|
298
|
+
}
|
|
299
|
+
async processMessage(instance, content, systemPrompt) {
|
|
300
|
+
const { state, bridge } = instance;
|
|
301
|
+
const { callsign } = parseAgentId(state.agentId);
|
|
302
|
+
const oldStatus = instance.state.status;
|
|
303
|
+
instance.isProcessing = true;
|
|
304
|
+
instance.state.status = 'busy';
|
|
305
|
+
instance.state.lastActivity = new Date().toISOString();
|
|
306
|
+
console.log(`[AgentManager] @${callsign} state: ${oldStatus} → busy`);
|
|
307
|
+
const workspace = state.workspacePath;
|
|
308
|
+
const shouldContinue = this.hasExistingSession(workspace);
|
|
309
|
+
const claudeConfigDir = this.getClaudeConfigDir(workspace);
|
|
310
|
+
// Use updated system prompt if provided
|
|
311
|
+
const prompt = systemPrompt ?? state.systemPrompt;
|
|
312
|
+
console.log(`[AgentManager] Processing message for ${state.agentId}`);
|
|
313
|
+
console.log(`[AgentManager] Working directory: ${workspace}`);
|
|
314
|
+
console.log(`[AgentManager] Continue session: ${shouldContinue}`);
|
|
315
|
+
const options = {
|
|
316
|
+
model: 'claude-opus-4-5-20251101',
|
|
317
|
+
systemPrompt: prompt
|
|
318
|
+
? {
|
|
319
|
+
type: 'preset',
|
|
320
|
+
preset: 'claude_code',
|
|
321
|
+
append: prompt,
|
|
322
|
+
}
|
|
323
|
+
: {
|
|
324
|
+
type: 'preset',
|
|
325
|
+
preset: 'claude_code',
|
|
326
|
+
},
|
|
327
|
+
permissionMode: 'bypassPermissions',
|
|
328
|
+
allowDangerouslySkipPermissions: true,
|
|
329
|
+
includePartialMessages: true,
|
|
330
|
+
continue: shouldContinue,
|
|
331
|
+
cwd: workspace,
|
|
332
|
+
env: {
|
|
333
|
+
// Filter out PWD/OLDPWD to prevent parent's cwd from leaking into subprocess
|
|
334
|
+
...Object.fromEntries(Object.entries(process.env).filter(([key]) => !['PWD', 'OLDPWD'].includes(key))),
|
|
335
|
+
CLAUDE_CONFIG_DIR: claudeConfigDir,
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
// Add MCP servers if configured (SDK expects Record<string, McpServerConfig>)
|
|
339
|
+
if (state.mcpServers && state.mcpServers.length > 0) {
|
|
340
|
+
console.log(`[AgentManager] Building MCP config from state.mcpServers (count: ${state.mcpServers.length})`);
|
|
341
|
+
console.log(`[AgentManager] state.mcpServers:`, JSON.stringify(state.mcpServers));
|
|
342
|
+
// Build MCP servers config - use type assertion since SDK uses discriminated unions
|
|
343
|
+
const mcpServers = {};
|
|
344
|
+
for (const server of state.mcpServers) {
|
|
345
|
+
if (server.transport === 'stdio') {
|
|
346
|
+
mcpServers[server.name] = {
|
|
347
|
+
type: 'stdio',
|
|
348
|
+
command: server.command,
|
|
349
|
+
args: server.args,
|
|
350
|
+
env: server.env,
|
|
351
|
+
cwd: server.cwd,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
else if (server.transport === 'sse' || server.transport === 'http') {
|
|
355
|
+
mcpServers[server.name] = {
|
|
356
|
+
type: server.transport,
|
|
357
|
+
url: server.url,
|
|
358
|
+
headers: server.headers,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (Object.keys(mcpServers).length > 0) {
|
|
363
|
+
console.log(`[AgentManager] Built SDK mcpServers:`, JSON.stringify(mcpServers));
|
|
364
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
365
|
+
options.mcpServers = mcpServers;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
console.warn(`[AgentManager] No MCP servers configured for ${state.agentId} (state.mcpServers: ${state.mcpServers})`);
|
|
370
|
+
}
|
|
371
|
+
// Create message stream for this conversation
|
|
372
|
+
// This allows new messages to be pushed to Claude mid-execution
|
|
373
|
+
const messageStream = createMessageStream(content);
|
|
374
|
+
instance.messageStream = messageStream;
|
|
375
|
+
console.log(`[AgentManager] @${callsign} created message stream (sessionId: ${messageStream.sessionId})`);
|
|
376
|
+
try {
|
|
377
|
+
const q = query({
|
|
378
|
+
prompt: messageStream.iterable, // Use stream instead of static string!
|
|
379
|
+
options,
|
|
380
|
+
});
|
|
381
|
+
for await (const message of q) {
|
|
382
|
+
await bridge.processSDKMessage(message);
|
|
383
|
+
}
|
|
384
|
+
await bridge.finalize();
|
|
385
|
+
console.log(`[AgentManager] Query completed for ${state.agentId}`);
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
console.error(`[AgentManager] Query error for ${state.agentId}:`, error);
|
|
389
|
+
this.config.onError?.(state.agentId, error);
|
|
390
|
+
}
|
|
391
|
+
finally {
|
|
392
|
+
// Clean up stream
|
|
393
|
+
if (instance.messageStream) {
|
|
394
|
+
instance.messageStream.close();
|
|
395
|
+
instance.messageStream = null;
|
|
396
|
+
}
|
|
397
|
+
instance.isProcessing = false;
|
|
398
|
+
instance.state.status = 'online';
|
|
399
|
+
instance.state.lastActivity = new Date().toISOString();
|
|
400
|
+
console.log(`[AgentManager] @${callsign} state: busy → online`);
|
|
401
|
+
// Process any queued messages that came in via legacy path
|
|
402
|
+
await this.processQueue(instance);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Process the message queue for an agent.
|
|
407
|
+
* Batches all queued messages into a single message to match sandbox behavior.
|
|
408
|
+
*/
|
|
409
|
+
async processQueue(instance) {
|
|
410
|
+
if (instance.messageQueue.length === 0) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const { callsign } = parseAgentId(instance.state.agentId);
|
|
414
|
+
// Batch all queued messages together
|
|
415
|
+
const queuedMessages = [...instance.messageQueue];
|
|
416
|
+
instance.messageQueue = []; // Clear the queue
|
|
417
|
+
console.log(`[AgentManager] @${callsign} processing ${queuedMessages.length} queued messages as a batch`);
|
|
418
|
+
// Format and combine all message contents with separator
|
|
419
|
+
const combinedContent = queuedMessages.map(msg => this.formatMessage(msg)).join('\n\n');
|
|
420
|
+
// Process as a single message (use first message's metadata)
|
|
421
|
+
await this.processMessage(instance, combinedContent, queuedMessages[0].systemPrompt);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
//# sourceMappingURL=agent-manager.js.map
|
|
@@ -0,0 +1 @@
|
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yD;QACzD,MAAM,eAAe,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAExF,6DAA6D;QAC7D,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IACvF,CAAC;CACF"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Local Runtime CLI
|
|
4
|
+
*
|
|
5
|
+
* Run CAST agents on your local machine.
|
|
6
|
+
*
|
|
7
|
+
* Commands:
|
|
8
|
+
* auth <connection-string> - Authenticate with CAST
|
|
9
|
+
* start [--name <name>] - Start the runtime
|
|
10
|
+
* status - Show runtime status
|
|
11
|
+
* agents - List active agents
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
|