omnara 0.1.3 → 0.1.5
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/bin/omnara.js +8 -3
- package/dist/auth/auth-provider.d.ts +2 -2
- package/dist/auth/cli-auth-service.d.ts +1 -1
- package/dist/auth/credential-manager.d.ts +1 -1
- package/dist/auth/login-flow.d.ts +2 -2
- package/dist/auth/supabase-client.d.ts +1 -1
- package/dist/cli.js +5940 -44
- package/dist/cli.js.map +7 -1
- package/dist/commands/index.d.ts +2 -2
- package/dist/http/user-sessions.d.ts +13 -0
- package/dist/orchestrator/agent-orchestrator.d.ts +14 -6
- package/dist/orchestrator/ai-client.d.ts +5 -4
- package/dist/orchestrator/orchestrator-prompt.d.ts +3 -2
- package/dist/orchestrator/orchestrator-prompt.md +405 -0
- package/dist/orchestrator/{types.d.ts → orchestrator-types.d.ts} +33 -29
- package/dist/orchestrator/session.d.ts +7 -3
- package/dist/orchestrator/tools/worker-status-tool.d.ts +7 -0
- package/dist/orchestrator/tools/worker-tools.d.ts +2 -1
- package/dist/orchestrator/utils/async-queue.d.ts +26 -0
- package/dist/orchestrator/utils/session-logger.d.ts +1 -1
- package/dist/orchestrator/worker-manager.d.ts +31 -15
- package/dist/relay/relay-bridge.d.ts +24 -3
- package/dist/relay/relay-service.d.ts +4 -7
- package/dist/schemas/index.d.ts +2 -0
- package/dist/voice/voice-service.d.ts +1 -1
- package/package.json +13 -3
- package/scripts/preinstall.js +141 -0
- package/scripts/test-preinstall.js +125 -0
- package/dist/auth/auth-provider.js +0 -58
- package/dist/auth/auth-provider.js.map +0 -1
- package/dist/auth/cli-auth-service.js +0 -47
- package/dist/auth/cli-auth-service.js.map +0 -1
- package/dist/auth/credential-manager.js +0 -73
- package/dist/auth/credential-manager.js.map +0 -1
- package/dist/auth/credentials-store.js +0 -75
- package/dist/auth/credentials-store.js.map +0 -1
- package/dist/auth/login-flow.js +0 -202
- package/dist/auth/login-flow.js.map +0 -1
- package/dist/auth/loopback-listener.js +0 -159
- package/dist/auth/loopback-listener.js.map +0 -1
- package/dist/auth/pkce.js +0 -18
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/supabase-client.js +0 -13
- package/dist/auth/supabase-client.js.map +0 -1
- package/dist/auth/supabase-config.js +0 -24
- package/dist/auth/supabase-config.js.map +0 -1
- package/dist/commands/agent.js +0 -174
- package/dist/commands/agent.js.map +0 -1
- package/dist/commands/auth.js +0 -87
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/hello.d.ts +0 -2
- package/dist/commands/hello.js +0 -12
- package/dist/commands/hello.js.map +0 -1
- package/dist/commands/index.js +0 -9
- package/dist/commands/index.js.map +0 -1
- package/dist/generated/relay.d.ts +0 -240
- package/dist/generated/relay.js +0 -2376
- package/dist/generated/relay.js.map +0 -1
- package/dist/http/api-client.js +0 -122
- package/dist/http/api-client.js.map +0 -1
- package/dist/messaging/proto-codec.d.ts +0 -5
- package/dist/messaging/proto-codec.js +0 -387
- package/dist/messaging/proto-codec.js.map +0 -1
- package/dist/orchestrator/agent-orchestrator.js +0 -423
- package/dist/orchestrator/agent-orchestrator.js.map +0 -1
- package/dist/orchestrator/ai-client.js +0 -74
- package/dist/orchestrator/ai-client.js.map +0 -1
- package/dist/orchestrator/orchestrator-prompt.js +0 -160
- package/dist/orchestrator/orchestrator-prompt.js.map +0 -1
- package/dist/orchestrator/session.js +0 -273
- package/dist/orchestrator/session.js.map +0 -1
- package/dist/orchestrator/tools/worker-tools.js +0 -165
- package/dist/orchestrator/tools/worker-tools.js.map +0 -1
- package/dist/orchestrator/types.js +0 -33
- package/dist/orchestrator/types.js.map +0 -1
- package/dist/orchestrator/utils/session-logger.js +0 -53
- package/dist/orchestrator/utils/session-logger.js.map +0 -1
- package/dist/orchestrator/worker-manager.js +0 -250
- package/dist/orchestrator/worker-manager.js.map +0 -1
- package/dist/relay/relay-bridge.js +0 -309
- package/dist/relay/relay-bridge.js.map +0 -1
- package/dist/relay/relay-service.js +0 -29
- package/dist/relay/relay-service.js.map +0 -1
- package/dist/repl/terminal-repl.js +0 -258
- package/dist/repl/terminal-repl.js.map +0 -1
- package/dist/server/agent-server.d.ts +0 -46
- package/dist/server/agent-server.js +0 -429
- package/dist/server/agent-server.js.map +0 -1
- package/dist/server/ai-client.d.ts +0 -16
- package/dist/server/ai-client.js +0 -74
- package/dist/server/ai-client.js.map +0 -1
- package/dist/server/session.d.ts +0 -35
- package/dist/server/session.js +0 -272
- package/dist/server/session.js.map +0 -1
- package/dist/server/subagents.d.ts +0 -19
- package/dist/server/subagents.js +0 -42
- package/dist/server/subagents.js.map +0 -1
- package/dist/server/tools/worker-tools.d.ts +0 -2
- package/dist/server/tools/worker-tools.js +0 -37
- package/dist/server/tools/worker-tools.js.map +0 -1
- package/dist/server/types.d.ts +0 -120
- package/dist/server/types.js +0 -29
- package/dist/server/types.js.map +0 -1
- package/dist/server/utils/session-logger.d.ts +0 -7
- package/dist/server/utils/session-logger.js +0 -53
- package/dist/server/utils/session-logger.js.map +0 -1
- package/dist/server/worker-manager.d.ts +0 -67
- package/dist/server/worker-manager.js +0 -207
- package/dist/server/worker-manager.js.map +0 -1
- package/dist/test-agent.d.ts +0 -1
- package/dist/test-agent.js +0 -63
- package/dist/test-agent.js.map +0 -1
- package/dist/utils/base64url.d.ts +0 -1
- package/dist/utils/base64url.js +0 -12
- package/dist/utils/base64url.js.map +0 -1
- package/dist/utils/prompt.js +0 -19
- package/dist/utils/prompt.js.map +0 -1
- package/dist/utils/random.d.ts +0 -1
- package/dist/utils/random.js +0 -9
- package/dist/utils/random.js.map +0 -1
- package/dist/voice/voice-service.js +0 -27
- package/dist/voice/voice-service.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-prompt.js","sourceRoot":"","sources":["../../src/orchestrator/orchestrator-prompt.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yGAqJ+D,CAAC"}
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Session = void 0;
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
|
-
const session_logger_1 = require("./utils/session-logger");
|
|
6
|
-
class Session {
|
|
7
|
-
constructor(id, aiClient, onEmpty, onToolUse) {
|
|
8
|
-
this.subscribers = new Map();
|
|
9
|
-
this.sdkSessionId = null;
|
|
10
|
-
this.inflight = null;
|
|
11
|
-
this.lastActivity = Date.now();
|
|
12
|
-
this.id = id;
|
|
13
|
-
this.aiClient = aiClient;
|
|
14
|
-
this.onEmpty = onEmpty;
|
|
15
|
-
this.onToolUse = onToolUse;
|
|
16
|
-
this.logger = (0, session_logger_1.createSessionLogger)(this.id);
|
|
17
|
-
}
|
|
18
|
-
announceInboundMessage(text, origin = 'user', workerId, workerTask) {
|
|
19
|
-
if (!text) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
// Only broadcast worker-origin updates. User messages already show up via `chat` frames.
|
|
23
|
-
if (origin !== 'worker') {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const message = {
|
|
27
|
-
type: 'user_text',
|
|
28
|
-
sessionId: this.id,
|
|
29
|
-
text,
|
|
30
|
-
origin,
|
|
31
|
-
workerId,
|
|
32
|
-
workerTask,
|
|
33
|
-
messageId: (0, crypto_1.randomUUID)(),
|
|
34
|
-
};
|
|
35
|
-
this.broadcast(message);
|
|
36
|
-
}
|
|
37
|
-
get lastActiveAt() {
|
|
38
|
-
return this.lastActivity;
|
|
39
|
-
}
|
|
40
|
-
get sdkSessionIdentifier() {
|
|
41
|
-
return this.sdkSessionId;
|
|
42
|
-
}
|
|
43
|
-
subscribe(subscriber) {
|
|
44
|
-
this.subscribers.set(subscriber.id, subscriber);
|
|
45
|
-
this.safeSend(subscriber, { type: 'session_joined', sessionId: this.id, messageId: (0, crypto_1.randomUUID)() });
|
|
46
|
-
}
|
|
47
|
-
unsubscribe(subscriberId) {
|
|
48
|
-
this.subscribers.delete(subscriberId);
|
|
49
|
-
if (!this.hasSubscribers() && !this.inflight) {
|
|
50
|
-
this.onEmpty(this.id);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
hasSubscribers() {
|
|
54
|
-
return this.subscribers.size > 0;
|
|
55
|
-
}
|
|
56
|
-
close() {
|
|
57
|
-
this.subscribers.clear();
|
|
58
|
-
this.logger.close();
|
|
59
|
-
}
|
|
60
|
-
enqueueUserMessage(text) {
|
|
61
|
-
this.lastActivity = Date.now();
|
|
62
|
-
const previous = this.inflight;
|
|
63
|
-
const task = async () => {
|
|
64
|
-
if (previous) {
|
|
65
|
-
try {
|
|
66
|
-
await previous;
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
// Previous error already reported, continue with new message.
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
await this.processUserMessage(text);
|
|
73
|
-
};
|
|
74
|
-
const promise = task()
|
|
75
|
-
.catch((error) => {
|
|
76
|
-
this.broadcast({
|
|
77
|
-
type: 'error',
|
|
78
|
-
sessionId: this.id,
|
|
79
|
-
message: extractErrorMessage(error),
|
|
80
|
-
messageId: (0, crypto_1.randomUUID)(),
|
|
81
|
-
});
|
|
82
|
-
})
|
|
83
|
-
.finally(() => {
|
|
84
|
-
if (this.inflight === promise) {
|
|
85
|
-
this.inflight = null;
|
|
86
|
-
this.lastActivity = Date.now();
|
|
87
|
-
if (!this.hasSubscribers()) {
|
|
88
|
-
this.onEmpty(this.id);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
this.inflight = promise;
|
|
93
|
-
}
|
|
94
|
-
handleStreamEvent(event) {
|
|
95
|
-
switch (event.type) {
|
|
96
|
-
case 'content_block_delta': {
|
|
97
|
-
const delta = event.delta;
|
|
98
|
-
if (delta?.type === 'text_delta' && delta.text) {
|
|
99
|
-
this.broadcast({
|
|
100
|
-
type: 'assistant_text',
|
|
101
|
-
sessionId: this.id,
|
|
102
|
-
text: delta.text,
|
|
103
|
-
messageId: (0, crypto_1.randomUUID)(),
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
default:
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async processUserMessage(text) {
|
|
113
|
-
const options = this.sdkSessionId ? { resume: this.sdkSessionId } : undefined;
|
|
114
|
-
for await (const message of this.aiClient.streamUserMessage(text, options)) {
|
|
115
|
-
this.routeSdkMessage(message);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
routeSdkMessage(message) {
|
|
119
|
-
switch (message.type) {
|
|
120
|
-
case 'assistant':
|
|
121
|
-
this.handleAssistantMessage(message);
|
|
122
|
-
break;
|
|
123
|
-
case 'stream_event':
|
|
124
|
-
this.handleStreamEvent(message.event);
|
|
125
|
-
break;
|
|
126
|
-
case 'result':
|
|
127
|
-
this.handleResultMessage(message);
|
|
128
|
-
break;
|
|
129
|
-
case 'system':
|
|
130
|
-
this.handleSystemMessage(message);
|
|
131
|
-
break;
|
|
132
|
-
case 'user': {
|
|
133
|
-
const textContent = extractUserContent(message.message.content);
|
|
134
|
-
if (textContent) {
|
|
135
|
-
this.broadcast({
|
|
136
|
-
type: 'user_text',
|
|
137
|
-
sessionId: this.id,
|
|
138
|
-
text: textContent,
|
|
139
|
-
messageId: (0, crypto_1.randomUUID)(),
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
default:
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
handleAssistantMessage(message) {
|
|
149
|
-
const content = message.message.content;
|
|
150
|
-
if (!Array.isArray(content)) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
for (const block of content) {
|
|
154
|
-
if (!block || typeof block !== 'object') {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
const typed = block;
|
|
158
|
-
const blockType = typed.type;
|
|
159
|
-
if (blockType === 'text' && typeof typed.text === 'string') {
|
|
160
|
-
if (typed.text.length > 0) {
|
|
161
|
-
this.broadcast({
|
|
162
|
-
type: 'assistant_text',
|
|
163
|
-
sessionId: this.id,
|
|
164
|
-
text: typed.text,
|
|
165
|
-
messageId: (0, crypto_1.randomUUID)(),
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
else if (blockType === 'tool_use') {
|
|
170
|
-
const toolUseId = typeof typed.id === 'string' ? typed.id : undefined;
|
|
171
|
-
this.broadcast({
|
|
172
|
-
type: 'tool_call',
|
|
173
|
-
sessionId: this.id,
|
|
174
|
-
toolName: typeof typed.name === 'string' ? typed.name : 'unknown',
|
|
175
|
-
toolUseId: toolUseId ?? 'unknown',
|
|
176
|
-
input: typed.input,
|
|
177
|
-
messageId: toolUseId || (0, crypto_1.randomUUID)(),
|
|
178
|
-
});
|
|
179
|
-
if (toolUseId) {
|
|
180
|
-
this.onToolUse?.(toolUseId, this.id);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else if (blockType === 'tool_result') {
|
|
184
|
-
const toolResultId = typeof typed.tool_use_id === 'string' ? typed.tool_use_id : undefined;
|
|
185
|
-
this.broadcast({
|
|
186
|
-
type: 'tool_result',
|
|
187
|
-
sessionId: this.id,
|
|
188
|
-
toolUseId: toolResultId || 'unknown',
|
|
189
|
-
content: typed.content,
|
|
190
|
-
isError: Boolean(typed.is_error),
|
|
191
|
-
messageId: toolResultId || (0, crypto_1.randomUUID)(),
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
handleResultMessage(message) {
|
|
197
|
-
void message;
|
|
198
|
-
this.broadcast({
|
|
199
|
-
type: 'assistant_complete',
|
|
200
|
-
sessionId: this.id,
|
|
201
|
-
messageId: (0, crypto_1.randomUUID)(),
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
handleSystemMessage(message) {
|
|
205
|
-
if (message.subtype === 'init') {
|
|
206
|
-
this.sdkSessionId = message.session_id;
|
|
207
|
-
}
|
|
208
|
-
this.broadcast({
|
|
209
|
-
type: 'system',
|
|
210
|
-
sessionId: this.id,
|
|
211
|
-
subtype: message.subtype,
|
|
212
|
-
messageId: (0, crypto_1.randomUUID)(),
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
logInbound(payload) {
|
|
216
|
-
this.logger.logInbound(payload);
|
|
217
|
-
}
|
|
218
|
-
broadcast(message) {
|
|
219
|
-
this.logger.logOutbound(message);
|
|
220
|
-
for (const [id, subscriber] of this.subscribers) {
|
|
221
|
-
if (subscriber.canSend && !subscriber.canSend()) {
|
|
222
|
-
this.subscribers.delete(id);
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
this.safeSend(subscriber, message);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
safeSend(subscriber, message) {
|
|
229
|
-
try {
|
|
230
|
-
subscriber.send(message);
|
|
231
|
-
}
|
|
232
|
-
catch {
|
|
233
|
-
this.subscribers.delete(subscriber.id);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
exports.Session = Session;
|
|
238
|
-
function extractErrorMessage(error) {
|
|
239
|
-
if (error instanceof Error) {
|
|
240
|
-
return error.message;
|
|
241
|
-
}
|
|
242
|
-
if (typeof error === 'string') {
|
|
243
|
-
return error;
|
|
244
|
-
}
|
|
245
|
-
try {
|
|
246
|
-
return JSON.stringify(error);
|
|
247
|
-
}
|
|
248
|
-
catch {
|
|
249
|
-
return 'Unknown error';
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
function extractUserContent(content) {
|
|
253
|
-
if (typeof content === 'string') {
|
|
254
|
-
return content;
|
|
255
|
-
}
|
|
256
|
-
if (Array.isArray(content)) {
|
|
257
|
-
const texts = [];
|
|
258
|
-
for (const part of content) {
|
|
259
|
-
if (part &&
|
|
260
|
-
typeof part === 'object' &&
|
|
261
|
-
'type' in part &&
|
|
262
|
-
part.type === 'text' &&
|
|
263
|
-
typeof part.text === 'string') {
|
|
264
|
-
texts.push(part.text);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (texts.length > 0) {
|
|
268
|
-
return texts.join('');
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
//# sourceMappingURL=session.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/orchestrator/session.ts"],"names":[],"mappings":";;;AAKA,mCAAoC;AAGpC,2DAAiF;AASjF,MAAa,OAAO;IAalB,YACE,EAAU,EACV,QAAqB,EACrB,OAAoC,EACpC,SAA2B;QAbZ,gBAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;QAK5D,iBAAY,GAAkB,IAAI,CAAC;QACnC,aAAQ,GAAyB,IAAI,CAAC;QACtC,iBAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAQhC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAA,oCAAmB,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,sBAAsB,CAAC,IAAY,EAAE,SAA4B,MAAM,EAAE,QAAiB,EAAE,UAAmB;QAC7G,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;QACT,CAAC;QACD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O,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,eAAe,CAAC;IACzB,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAgB;IAC1C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,IACE,IAAI;gBACJ,OAAO,IAAI,KAAK,QAAQ;gBACxB,MAAM,IAAI,IAAI;gBACb,IAAgC,CAAC,IAAI,KAAK,MAAM;gBACjD,OAAQ,IAAgC,CAAC,IAAI,KAAK,QAAQ,EAC1D,CAAC;gBACD,KAAK,CAAC,IAAI,CAAE,IAAgC,CAAC,IAAc,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createWorkerMcpServer = createWorkerMcpServer;
|
|
4
|
-
const claude_agent_sdk_1 = require("@anthropic-ai/claude-agent-sdk");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
function createWorkerMcpServer(workerManager, context) {
|
|
7
|
-
return (0, claude_agent_sdk_1.createSdkMcpServer)({
|
|
8
|
-
name: 'worker',
|
|
9
|
-
version: '1.0.0',
|
|
10
|
-
tools: [
|
|
11
|
-
(0, claude_agent_sdk_1.tool)('launch_worker', `Launch a background worker agent to handle tasks autonomously.
|
|
12
|
-
|
|
13
|
-
When to use this tool:
|
|
14
|
-
- Complex tasks requiring multiple steps or operations
|
|
15
|
-
- Searches and exploration of the codebase
|
|
16
|
-
- Tasks that can run in parallel with other work
|
|
17
|
-
- Nearly any coding task - prefer delegation over doing work directly
|
|
18
|
-
|
|
19
|
-
Usage notes:
|
|
20
|
-
- Launch multiple workers concurrently whenever possible for maximum performance (use multiple tool calls in a single turn)
|
|
21
|
-
- Provide detailed, autonomous task descriptions including exactly what information should be returned
|
|
22
|
-
- Workers have full access to: file operations (read, write, edit), search (glob, grep), bash commands, git operations, running tests, and can launch their own sub-workers
|
|
23
|
-
- Worker outputs should be trusted - they have the same capabilities as you
|
|
24
|
-
- The worker's result is returned to you, not the user - you must summarize or forward relevant information
|
|
25
|
-
- Worker progress status is automatically included in your context - you can see their current state without additional tools`, {
|
|
26
|
-
task: zod_1.z.string().min(1, 'task name is required').describe('A short, unique name for this task (e.g., "FizzBuzz Python", "Search codebase", "Fix bug #123"). Used to identify and track this worker.'),
|
|
27
|
-
prompt: zod_1.z.string().min(1, 'prompt is required'),
|
|
28
|
-
metadata: zod_1.z.record(zod_1.z.any()).optional(),
|
|
29
|
-
}, async (args, extra) => {
|
|
30
|
-
const typedExtra = extra;
|
|
31
|
-
const toolUseIdRaw = typedExtra?._meta?.['claudecode/toolUseId'];
|
|
32
|
-
const toolUseId = typeof toolUseIdRaw === 'string' ? toolUseIdRaw : undefined;
|
|
33
|
-
const sdkSessionId = typedExtra?.sessionId;
|
|
34
|
-
let parentSessionId = context.resolveSessionIdBySdk(sdkSessionId);
|
|
35
|
-
if (!parentSessionId && toolUseId) {
|
|
36
|
-
parentSessionId = context.resolveSessionIdByToolUse(toolUseId);
|
|
37
|
-
}
|
|
38
|
-
const record = workerManager.launchWorker({
|
|
39
|
-
task: args.task,
|
|
40
|
-
prompt: args.prompt,
|
|
41
|
-
originSessionId: parentSessionId,
|
|
42
|
-
metadata: args.metadata,
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
content: [
|
|
46
|
-
{
|
|
47
|
-
type: 'text',
|
|
48
|
-
text: JSON.stringify({
|
|
49
|
-
workerId: record.id,
|
|
50
|
-
status: record.status,
|
|
51
|
-
message: `Worker launched successfully, task ${args.task} in progress. You will be notified for progress updates.`,
|
|
52
|
-
}),
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
};
|
|
56
|
-
}),
|
|
57
|
-
(0, claude_agent_sdk_1.tool)('get_workers', `Get the current status of one or more background workers by task name.
|
|
58
|
-
|
|
59
|
-
Use this tool to:
|
|
60
|
-
- Check status of multiple workers at once
|
|
61
|
-
- Get current status (running, completed, error, canceled) for each worker
|
|
62
|
-
- Retrieve results or error messages
|
|
63
|
-
- Optionally wait for all workers to complete
|
|
64
|
-
|
|
65
|
-
Parameters:
|
|
66
|
-
- tasks: Array of task names to check
|
|
67
|
-
- wait_timeout: If not provided, returns immediately. If provided (in seconds), polls until ALL workers complete or timeout is reached (max: 600)
|
|
68
|
-
|
|
69
|
-
Returns:
|
|
70
|
-
- workers: Array of worker statuses, one per task
|
|
71
|
-
- allComplete: true if all workers are done (completed, error, or canceled)
|
|
72
|
-
- timedOut: true if wait_timeout was provided and timeout was reached`, {
|
|
73
|
-
tasks: zod_1.z.array(zod_1.z.string().min(1)).min(1, 'at least one task name is required').describe('Array of task names to check (e.g., ["FizzBuzz Python", "FizzBuzz C"])'),
|
|
74
|
-
wait_timeout: zod_1.z.number().optional().describe('If provided, wait for ALL workers to complete up to this many seconds (max: 600). If not provided, returns immediately.'),
|
|
75
|
-
}, async (args) => {
|
|
76
|
-
const waitTimeout = args.wait_timeout;
|
|
77
|
-
const shouldWait = waitTimeout !== undefined && waitTimeout !== null && waitTimeout > 0;
|
|
78
|
-
const timeout = shouldWait ? Math.min(waitTimeout, 600) : 0; // Max 10 minutes
|
|
79
|
-
const pollIntervalMs = 2000; // Poll every 2 seconds
|
|
80
|
-
const checkWorkers = () => {
|
|
81
|
-
const results = args.tasks.map(task => {
|
|
82
|
-
const worker = workerManager.getWorkerByTask(task);
|
|
83
|
-
if (!worker) {
|
|
84
|
-
return {
|
|
85
|
-
found: false,
|
|
86
|
-
task,
|
|
87
|
-
message: `No worker found with task name: ${task}`,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
const isDone = worker.status === 'completed' || worker.status === 'error' || worker.status === 'canceled';
|
|
91
|
-
const latestMessage = worker.progress.length > 0
|
|
92
|
-
? worker.progress[worker.progress.length - 1]?.message
|
|
93
|
-
: undefined;
|
|
94
|
-
return {
|
|
95
|
-
found: true,
|
|
96
|
-
workerId: worker.id,
|
|
97
|
-
task: worker.task,
|
|
98
|
-
status: worker.status,
|
|
99
|
-
isDone,
|
|
100
|
-
latestMessage,
|
|
101
|
-
result: worker.result,
|
|
102
|
-
error: worker.error,
|
|
103
|
-
startedAt: new Date(worker.startedAt).toISOString(),
|
|
104
|
-
lastUpdateAt: new Date(worker.lastUpdateAt).toISOString(),
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
const allComplete = results.every(r => !r.found || r.isDone);
|
|
108
|
-
return { workers: results, allComplete };
|
|
109
|
-
};
|
|
110
|
-
// Get initial status
|
|
111
|
-
const initialCheck = checkWorkers();
|
|
112
|
-
// If not waiting or all already done, return immediately
|
|
113
|
-
if (!shouldWait || initialCheck.allComplete) {
|
|
114
|
-
return {
|
|
115
|
-
content: [
|
|
116
|
-
{
|
|
117
|
-
type: 'text',
|
|
118
|
-
text: JSON.stringify({
|
|
119
|
-
...initialCheck,
|
|
120
|
-
timedOut: false,
|
|
121
|
-
}),
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
// Poll until all done or timeout
|
|
127
|
-
const startTime = Date.now();
|
|
128
|
-
const timeoutMs = timeout * 1000;
|
|
129
|
-
while (Date.now() - startTime < timeoutMs) {
|
|
130
|
-
await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
|
|
131
|
-
const current = checkWorkers();
|
|
132
|
-
if (current.allComplete) {
|
|
133
|
-
return {
|
|
134
|
-
content: [
|
|
135
|
-
{
|
|
136
|
-
type: 'text',
|
|
137
|
-
text: JSON.stringify({
|
|
138
|
-
...current,
|
|
139
|
-
timedOut: false,
|
|
140
|
-
}),
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// Timeout reached, return current status
|
|
147
|
-
const finalCheck = checkWorkers();
|
|
148
|
-
const stillRunning = finalCheck.workers.filter(w => w.found && !w.isDone).map(w => w.task);
|
|
149
|
-
return {
|
|
150
|
-
content: [
|
|
151
|
-
{
|
|
152
|
-
type: 'text',
|
|
153
|
-
text: JSON.stringify({
|
|
154
|
-
...finalCheck,
|
|
155
|
-
timedOut: true,
|
|
156
|
-
message: `Timeout reached after ${timeout} seconds. Still running: ${stillRunning.join(', ')}`,
|
|
157
|
-
}),
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
};
|
|
161
|
-
}),
|
|
162
|
-
],
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=worker-tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-tools.js","sourceRoot":"","sources":["../../../src/orchestrator/tools/worker-tools.ts"],"names":[],"mappings":";;AAeA,sDA2LC;AA1MD,qEAA0E;AAC1E,6BAAwB;AAcxB,SAAgB,qBAAqB,CACnC,aAA4B,EAC5B,OAAyB;IAEzB,OAAO,IAAA,qCAAkB,EAAC;QACxB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE;YACL,IAAA,uBAAI,EACF,eAAe,EACf;;;;;;;;;;;;;;8HAcsH,EACtH;gBACE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CA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
-
exports.inboundMessageSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
exports.inboundMessageSchema = zod_1.z.discriminatedUnion('type', [
|
|
6
|
-
zod_1.z.object({
|
|
7
|
-
type: zod_1.z.literal('chat'),
|
|
8
|
-
sessionId: zod_1.z.string().trim().min(1).optional(),
|
|
9
|
-
text: zod_1.z.string().min(1, 'text cannot be empty'),
|
|
10
|
-
}),
|
|
11
|
-
zod_1.z.object({
|
|
12
|
-
type: zod_1.z.literal('session_init'),
|
|
13
|
-
sessionId: zod_1.z.string().trim().min(1, 'sessionId is required for session_init'),
|
|
14
|
-
parentSessionId: zod_1.z.string().trim().min(1).optional(),
|
|
15
|
-
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
16
|
-
}),
|
|
17
|
-
zod_1.z.object({
|
|
18
|
-
type: zod_1.z.literal('join'),
|
|
19
|
-
sessionId: zod_1.z.string().trim().min(1, 'sessionId is required to join'),
|
|
20
|
-
}),
|
|
21
|
-
zod_1.z.object({
|
|
22
|
-
type: zod_1.z.literal('leave'),
|
|
23
|
-
sessionId: zod_1.z.string().trim().min(1, 'sessionId is required to leave'),
|
|
24
|
-
}),
|
|
25
|
-
zod_1.z.object({
|
|
26
|
-
type: zod_1.z.literal('ping'),
|
|
27
|
-
}),
|
|
28
|
-
zod_1.z.object({
|
|
29
|
-
type: zod_1.z.literal('cancel_worker'),
|
|
30
|
-
workerId: zod_1.z.string().trim().min(1, 'workerId is required'),
|
|
31
|
-
}),
|
|
32
|
-
]);
|
|
33
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/orchestrator/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,oBAAoB,GAAG,OAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC/D,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,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,eAAe,CAAC;QAChC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC;KAC3D,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createSessionLogger = createSessionLogger;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const os_1 = __importDefault(require("os"));
|
|
10
|
-
function getLogDir() {
|
|
11
|
-
return process.env.OMNARA_LOG_DIR ?? path_1.default.join(os_1.default.homedir(), '.omnara', 'omnara-voice');
|
|
12
|
-
}
|
|
13
|
-
function ensureLogDir() {
|
|
14
|
-
const dir = getLogDir();
|
|
15
|
-
try {
|
|
16
|
-
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
// ignore
|
|
20
|
-
}
|
|
21
|
-
return dir;
|
|
22
|
-
}
|
|
23
|
-
function createSessionLogger(sessionId) {
|
|
24
|
-
const dir = ensureLogDir();
|
|
25
|
-
const filePath = path_1.default.join(dir, `${sessionId}.log`);
|
|
26
|
-
const stream = fs_1.default.createWriteStream(filePath, { flags: 'a' });
|
|
27
|
-
const logLine = (direction, payload) => {
|
|
28
|
-
const timestamp = new Date().toISOString();
|
|
29
|
-
const serialized = safeStringify(payload);
|
|
30
|
-
stream.write(`${timestamp} [${direction}] ${serialized}\n`);
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
logInbound: (payload) => logLine('in', payload),
|
|
34
|
-
logOutbound: (message) => logLine('out', message),
|
|
35
|
-
close: () => {
|
|
36
|
-
try {
|
|
37
|
-
stream.end();
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
// ignore close errors
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function safeStringify(value) {
|
|
46
|
-
try {
|
|
47
|
-
return JSON.stringify(value);
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return String(value);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=session-logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-logger.js","sourceRoot":"","sources":["../../../src/orchestrator/utils/session-logger.ts"],"names":[],"mappings":";;;;;AAyBA,kDAsBC;AA/CD,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AAGpB,SAAS,SAAS;IAChB,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,YAAY;IACnB,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,IAAI,CAAC;QACH,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAQD,SAAgB,mBAAmB,CAAC,SAAiB;IACnD,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,MAAM,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,YAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAE9D,MAAM,OAAO,GAAG,CAAC,SAAuB,EAAE,OAAgB,EAAE,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