omnara 0.1.2 → 0.1.4
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/auth-provider.js +14 -16
- package/dist/auth/auth-provider.js.map +1 -1
- package/dist/auth/cli-auth-service.d.ts +12 -3
- package/dist/auth/cli-auth-service.js +23 -9
- package/dist/auth/cli-auth-service.js.map +1 -1
- package/dist/auth/credential-manager.d.ts +1 -1
- package/dist/auth/credential-manager.js +7 -9
- package/dist/auth/credential-manager.js.map +1 -1
- package/dist/auth/credentials-store.js +14 -20
- package/dist/auth/credentials-store.js.map +1 -1
- package/dist/auth/login-flow.d.ts +2 -2
- package/dist/auth/login-flow.js +128 -39
- package/dist/auth/login-flow.js.map +1 -1
- package/dist/auth/loopback-listener.d.ts +20 -0
- package/dist/auth/loopback-listener.js +155 -0
- package/dist/auth/loopback-listener.js.map +1 -0
- package/dist/auth/pkce.d.ts +6 -0
- package/dist/auth/pkce.js +15 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/supabase-client.d.ts +1 -1
- package/dist/auth/supabase-client.js +3 -6
- package/dist/auth/supabase-client.js.map +1 -1
- package/dist/auth/supabase-config.js +3 -6
- package/dist/auth/supabase-config.js.map +1 -1
- package/dist/cli.js +26 -25
- package/dist/cli.js.map +1 -1
- package/dist/commands/agent.js +36 -38
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/auth.js +13 -16
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/index.d.ts +2 -2
- package/dist/commands/index.js +2 -8
- package/dist/commands/index.js.map +1 -1
- package/dist/http/api-client.js +7 -11
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/user-sessions.d.ts +13 -0
- package/dist/http/user-sessions.js +9 -0
- package/dist/http/user-sessions.js.map +1 -0
- package/dist/orchestrator/agent-orchestrator.d.ts +11 -6
- package/dist/orchestrator/agent-orchestrator.js +226 -57
- package/dist/orchestrator/agent-orchestrator.js.map +1 -1
- package/dist/orchestrator/ai-client.d.ts +5 -4
- package/dist/orchestrator/ai-client.js +17 -14
- package/dist/orchestrator/ai-client.js.map +1 -1
- package/dist/orchestrator/orchestrator-prompt.d.ts +2 -7
- package/dist/orchestrator/orchestrator-prompt.js +7 -154
- package/dist/orchestrator/orchestrator-prompt.js.map +1 -1
- package/dist/orchestrator/orchestrator-prompt.md +405 -0
- package/dist/orchestrator/session.d.ts +7 -3
- package/dist/orchestrator/session.js +56 -34
- package/dist/orchestrator/session.js.map +1 -1
- package/dist/orchestrator/tools/worker-status-tool.d.ts +7 -0
- package/dist/orchestrator/tools/worker-status-tool.js +41 -0
- package/dist/orchestrator/tools/worker-status-tool.js.map +1 -0
- package/dist/orchestrator/tools/worker-tools.d.ts +1 -1
- package/dist/orchestrator/tools/worker-tools.js +73 -89
- package/dist/orchestrator/tools/worker-tools.js.map +1 -1
- package/dist/orchestrator/types.d.ts +19 -29
- package/dist/orchestrator/types.js +22 -25
- package/dist/orchestrator/types.js.map +1 -1
- package/dist/orchestrator/utils/async-queue.d.ts +26 -0
- package/dist/orchestrator/utils/async-queue.js +70 -0
- package/dist/orchestrator/utils/async-queue.js.map +1 -0
- package/dist/orchestrator/utils/session-logger.d.ts +1 -1
- package/dist/orchestrator/utils/session-logger.js +8 -14
- package/dist/orchestrator/utils/session-logger.js.map +1 -1
- package/dist/orchestrator/worker-manager.d.ts +31 -15
- package/dist/orchestrator/worker-manager.js +186 -18
- package/dist/orchestrator/worker-manager.js.map +1 -1
- package/dist/relay/relay-bridge.d.ts +24 -3
- package/dist/relay/relay-bridge.js +382 -90
- package/dist/relay/relay-bridge.js.map +1 -1
- package/dist/relay/relay-service.d.ts +4 -7
- package/dist/relay/relay-service.js +5 -11
- package/dist/relay/relay-service.js.map +1 -1
- package/dist/repl/terminal-repl.js +34 -30
- package/dist/repl/terminal-repl.js.map +1 -1
- package/dist/schemas/generated.d.ts +244 -0
- package/dist/schemas/generated.js +5 -0
- package/dist/schemas/generated.js.map +1 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/scripts/generate-schema-types.js +53 -0
- package/dist/scripts/generate-schema-types.js.map +1 -0
- package/dist/scripts/sync-schemas.d.ts +1 -0
- package/dist/scripts/sync-schemas.js +28 -0
- package/dist/scripts/sync-schemas.js.map +1 -0
- package/dist/utils/prompt.js +4 -10
- package/dist/utils/prompt.js.map +1 -1
- package/dist/voice/voice-service.d.ts +1 -1
- package/dist/voice/voice-service.js +2 -4
- package/dist/voice/voice-service.js.map +1 -1
- package/package.json +6 -2
- 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/generated/relay.d.ts +0 -240
- package/dist/generated/relay.js +0 -2376
- package/dist/generated/relay.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/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.js +0 -63
- package/dist/test-agent.js.map +0 -1
- /package/dist/{test-agent.d.ts → scripts/generate-schema-types.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/orchestrator/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/orchestrator/session.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,OAAO,EAAE,mBAAmB,EAAsB,MAAM,2BAA2B,CAAC;AASpF,MAAM,OAAO,OAAO;IACT,EAAE,CAAS;IAEH,QAAQ,CAAc;IACtB,WAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;IACnD,OAAO,CAA8B;IACrC,SAAS,CAAmB;IAC5B,MAAM,CAAgB;IAE/B,YAAY,GAAkB,IAAI,CAAC;IACnC,QAAQ,GAAyB,IAAI,CAAC;IACtC,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAElC,YACE,EAAU,EACV,QAAqB,EACrB,OAAoC,EACpC,SAA2B;QAE3B,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,mBAAmB,CAAC,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,yFAAyF;QACzF,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YACxB,OAAO;QACT,CA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AAO,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface StatusUpdateEvent {
|
|
2
|
+
message: string;
|
|
3
|
+
metadata?: Record<string, unknown>;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
}
|
|
6
|
+
export type StatusUpdateCallback = (event: StatusUpdateEvent) => void;
|
|
7
|
+
export declare function createWorkerStatusMcpServer(onStatusUpdate: StatusUpdateCallback): import("@anthropic-ai/claude-agent-sdk").McpSdkServerConfigWithInstance;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export function createWorkerStatusMcpServer(onStatusUpdate) {
|
|
4
|
+
return createSdkMcpServer({
|
|
5
|
+
name: 'worker_status',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
tools: [
|
|
8
|
+
tool('send_status_update', `Send a status update message to notify about progress.
|
|
9
|
+
|
|
10
|
+
Use this tool to:
|
|
11
|
+
- Report progress on long-running tasks
|
|
12
|
+
- Notify about important milestones or decisions
|
|
13
|
+
- Provide context about what you're currently working on
|
|
14
|
+
- Signal warnings or issues that don't stop execution
|
|
15
|
+
|
|
16
|
+
The status update will be visible to the orchestrator and tracked in your task's progress history.`, {
|
|
17
|
+
message: z.string().min(1, 'message is required').describe('A concise status update message describing current progress or state'),
|
|
18
|
+
metadata: z.record(z.any()).optional().describe('Optional metadata to attach to this status update'),
|
|
19
|
+
}, async (args) => {
|
|
20
|
+
console.log('[StatusTool] send_status_update called:', {
|
|
21
|
+
message: args.message,
|
|
22
|
+
metadata: args.metadata,
|
|
23
|
+
});
|
|
24
|
+
onStatusUpdate({
|
|
25
|
+
message: args.message,
|
|
26
|
+
metadata: args.metadata,
|
|
27
|
+
timestamp: Date.now(),
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: 'text',
|
|
33
|
+
text: 'Status update sent successfully.',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=worker-status-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-status-tool.js","sourceRoot":"","sources":["../../../src/orchestrator/tools/worker-status-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,MAAM,UAAU,2BAA2B,CAAC,cAAoC;IAC9E,OAAO,kBAAkB,CAAC;QACxB,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE;YACL,IAAI,CACF,oBAAoB,EACpB;;;;;;;;mGAQ2F,EAC3F;gBACE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,QAAQ,CAAC,sEAAsE,CAAC;gBAClI,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mDAAmD,CAAC;aACrG,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;gBACb,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE;oBACrD,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACxB,CAAC,CAAC;gBAEH,cAAc,CAAC;oBACb,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;iBACtB,CAAC,CAAC;gBAEH,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,kCAAkC;yBACzC;qBACF;iBACF,CAAC;YACJ,CAAC,CACF;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WorkerManager } from '../worker-manager';
|
|
1
|
+
import type { WorkerManager } from '../worker-manager.js';
|
|
2
2
|
interface WorkerMcpContext {
|
|
3
3
|
resolveSessionIdBySdk: (sdkSessionId?: string) => string | undefined;
|
|
4
4
|
resolveSessionIdByToolUse: (toolUseId: string) => string | undefined;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
function createWorkerMcpServer(workerManager, context) {
|
|
7
|
-
return (0, claude_agent_sdk_1.createSdkMcpServer)({
|
|
1
|
+
import { createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export function createWorkerMcpServer(workerManager, context) {
|
|
4
|
+
return createSdkMcpServer({
|
|
8
5
|
name: 'worker',
|
|
9
6
|
version: '1.0.0',
|
|
10
7
|
tools: [
|
|
11
|
-
|
|
8
|
+
tool('launch_worker', `Launch a background worker agent to handle tasks autonomously.
|
|
12
9
|
|
|
13
10
|
When to use this tool:
|
|
14
11
|
- Complex tasks requiring multiple steps or operations
|
|
@@ -23,9 +20,9 @@ Usage notes:
|
|
|
23
20
|
- Worker outputs should be trusted - they have the same capabilities as you
|
|
24
21
|
- The worker's result is returned to you, not the user - you must summarize or forward relevant information
|
|
25
22
|
- Worker progress status is automatically included in your context - you can see their current state without additional tools`, {
|
|
26
|
-
task:
|
|
27
|
-
prompt:
|
|
28
|
-
metadata:
|
|
23
|
+
task: 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.'),
|
|
24
|
+
prompt: z.string().min(1, 'prompt is required'),
|
|
25
|
+
metadata: z.record(z.any()).optional(),
|
|
29
26
|
}, async (args, extra) => {
|
|
30
27
|
const typedExtra = extra;
|
|
31
28
|
const toolUseIdRaw = typedExtra?._meta?.['claudecode/toolUseId'];
|
|
@@ -54,106 +51,93 @@ Usage notes:
|
|
|
54
51
|
],
|
|
55
52
|
};
|
|
56
53
|
}),
|
|
57
|
-
|
|
54
|
+
tool('message_worker', `Send a message to a running worker to provide additional context, requirements, or steering.
|
|
58
55
|
|
|
59
56
|
Use this tool to:
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
57
|
+
- Add new requirements or clarifications to an in-progress task
|
|
58
|
+
- Provide additional context the worker might need
|
|
59
|
+
- Correct or redirect the worker's current approach
|
|
60
|
+
- Answer implicit questions or resolve ambiguities
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
62
|
+
**When to use this tool:**
|
|
63
|
+
- User provides additional requirements while a task is in progress
|
|
64
|
+
- User clarifies or corrects their original request
|
|
65
|
+
- User adds context that would help the running worker
|
|
66
|
+
- A logically related request comes in for an existing task
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
**When to launch a NEW worker instead:**
|
|
69
|
+
- The request is for a completely different, unrelated task
|
|
70
|
+
- The user explicitly requests a separate task
|
|
71
|
+
- The new work would conflict with the current worker's objective
|
|
72
|
+
|
|
73
|
+
**Interrupt parameter:**
|
|
74
|
+
- interrupt=true: Stop current work immediately and redirect (use for critical corrections or significant changes in direction)
|
|
75
|
+
- interrupt=false: Queue message for after current turn completes (use for additions, clarifications, or supplementary context)
|
|
76
|
+
|
|
77
|
+
**Guidelines for interrupt:**
|
|
78
|
+
- Use interrupt=true ONLY if:
|
|
79
|
+
- User explicitly says to stop/interrupt current work
|
|
80
|
+
- The new requirement significantly contradicts the current direction
|
|
81
|
+
- The worker is heading down the wrong path and needs immediate correction
|
|
82
|
+
- Use interrupt=false (default) for:
|
|
83
|
+
- Adding requirements that build on current work
|
|
84
|
+
- Providing helpful context or clarifications
|
|
85
|
+
- Making additions that don't conflict with current progress
|
|
86
|
+
|
|
87
|
+
Example 1 (queue):
|
|
88
|
+
User: "Add authentication to my app"
|
|
89
|
+
Orchestrator: [launches worker: "add auth"]
|
|
90
|
+
User: "Make sure it works with Google OAuth"
|
|
91
|
+
Orchestrator: [message_worker: task="add auth", message="User wants Google OAuth integration", interrupt=false]
|
|
92
|
+
|
|
93
|
+
Example 2 (interrupt):
|
|
94
|
+
User: "Refactor the database layer"
|
|
95
|
+
Orchestrator: [launches worker: "refactor database"]
|
|
96
|
+
User: "Wait, actually don't touch the database - just refactor the API layer instead"
|
|
97
|
+
Orchestrator: [message_worker: task="refactor database", message="User wants to change scope - refactor API layer instead, leave database alone", interrupt=true]`, {
|
|
98
|
+
task: z.string().min(1, 'task name is required').describe('The task name of the worker to message'),
|
|
99
|
+
message: z.string().min(1, 'message is required').describe('The message to send to the worker. Be clear and specific about what has changed or what additional context is being provided.'),
|
|
100
|
+
interrupt: z.boolean().default(false).describe('If true, interrupt current generation immediately; if false (default), queue message for next turn'),
|
|
75
101
|
}, async (args) => {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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;
|
|
102
|
+
const success = await workerManager.messageWorker(args.task, args.message, args.interrupt);
|
|
103
|
+
if (!success) {
|
|
104
|
+
const worker = workerManager.getWorkerByTask(args.task);
|
|
105
|
+
if (!worker) {
|
|
94
106
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
lastUpdateAt: new Date(worker.lastUpdateAt).toISOString(),
|
|
107
|
+
content: [
|
|
108
|
+
{
|
|
109
|
+
type: 'text',
|
|
110
|
+
text: JSON.stringify({
|
|
111
|
+
success: false,
|
|
112
|
+
error: `No worker found with task name: ${args.task}`,
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
],
|
|
105
116
|
};
|
|
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) {
|
|
117
|
+
}
|
|
114
118
|
return {
|
|
115
119
|
content: [
|
|
116
120
|
{
|
|
117
121
|
type: 'text',
|
|
118
122
|
text: JSON.stringify({
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
success: false,
|
|
124
|
+
error: `Worker "${args.task}" is not running (status: ${worker.status})`,
|
|
121
125
|
}),
|
|
122
126
|
},
|
|
123
127
|
],
|
|
124
128
|
};
|
|
125
129
|
}
|
|
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
130
|
return {
|
|
150
131
|
content: [
|
|
151
132
|
{
|
|
152
133
|
type: 'text',
|
|
153
134
|
text: JSON.stringify({
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
135
|
+
success: true,
|
|
136
|
+
task: args.task,
|
|
137
|
+
interrupted: args.interrupt,
|
|
138
|
+
message: args.interrupt
|
|
139
|
+
? `Message sent to worker "${args.task}" (interrupted current work)`
|
|
140
|
+
: `Message queued for worker "${args.task}" (will be delivered after current turn)`,
|
|
157
141
|
}),
|
|
158
142
|
},
|
|
159
143
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-tools.js","sourceRoot":"","sources":["../../../src/orchestrator/tools/worker-tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-tools.js","sourceRoot":"","sources":["../../../src/orchestrator/tools/worker-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,MAAM,UAAU,qBAAqB,CACnC,aAA4B,EAC5B,OAAyB;IAEzB,OAAO,kBAAkB,CAAC;QACxB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE;YACL,IAAI,CACF,eAAe,EACf;;;;;;;;;;;;;;8HAcsH,EACtH;gBACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,QAAQ,CAAC,0IAA0I,CAAC;gBACrM,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,oBAAoB,CAAC;gBAC/C,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;aACvC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;gBACpB,MAAM,UAAU,GAAG,KAA8B,CAAC;gBAClD,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,EAAE,CAAC,sBAAsB,CAAC,CAAC;gBACjE,MAAM,SAAS,GAAG,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;gBAE9E,MAAM,YAAY,GAAG,UAAU,EAAE,SAAS,CAAC;gBAC3C,IAAI,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;gBAClE,IAAI,CAAC,eAAe,IAAI,S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AAO,EAAE,CAAC;oBACb,MAAM,MAAM,GAAG,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACxD,IAAI,CAAC,MAAM,EAAE,CAAC;wBACZ,OAAO;4BACL,OAAO,EAAE;gCACP;oCACE,IAAI,EAAE,MAAM;oCACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wCACnB,OAAO,EAAE,KAAK;wCACd,KAAK,EAAE,mCAAmC,IAAI,CAAC,IAAI,EAAE;qCACtD,CAAC;iCACH;6BACF;yBACF,CAAC;oBACJ,CAAC;oBAED,OAAO;wBACL,OAAO,EAAE;4BACP;gCACE,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oCACnB,OAAO,EAAE,KAAK;oCACd,KAAK,EAAE,WAAW,IAAI,CAAC,IAAI,6BAA6B,MAAM,CAAC,MAAM,GAAG;iCACzE,CAAC;6BACH;yBACF;qBACF,CAAC;gBACJ,CAAC;gBAED,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gCACnB,OAAO,EAAE,IAAI;gCACb,IAAI,EAAE,IAAI,CAAC,IAAI;gCACf,WAAW,EAAE,IAAI,CAAC,SAAS;gCAC3B,OAAO,EAAE,IAAI,CAAC,SAAS;oCACrB,CAAC,CAAC,2BAA2B,IAAI,CAAC,IAAI,8BAA8B;oCACpE,CAAC,CAAC,8BAA8B,IAAI,CAAC,IAAI,0CAA0C;6BACtF,CAAC;yBACH;qBACF;iBACF,CAAC;YACJ,CAAC,CACF;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -76,7 +76,7 @@ export type OutboundMessage = {
|
|
|
76
76
|
metadata?: Record<string, unknown>;
|
|
77
77
|
messageId?: string;
|
|
78
78
|
} | {
|
|
79
|
-
type: '
|
|
79
|
+
type: 'session_init_ack';
|
|
80
80
|
sessionId: string;
|
|
81
81
|
parentSessionId?: string | null;
|
|
82
82
|
messageId?: string;
|
|
@@ -96,10 +96,13 @@ export type OutboundMessage = {
|
|
|
96
96
|
workerTask?: string;
|
|
97
97
|
messageId?: string;
|
|
98
98
|
} | {
|
|
99
|
-
type: '
|
|
99
|
+
type: 'agent_complete';
|
|
100
100
|
sessionId: string;
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
success: boolean;
|
|
102
|
+
durationMs?: number;
|
|
103
|
+
costUsd?: number;
|
|
104
|
+
message?: string;
|
|
105
|
+
metadata?: Record<string, unknown>;
|
|
103
106
|
messageId?: string;
|
|
104
107
|
} | {
|
|
105
108
|
type: 'tool_call';
|
|
@@ -107,6 +110,8 @@ export type OutboundMessage = {
|
|
|
107
110
|
toolName: string;
|
|
108
111
|
toolUseId: string;
|
|
109
112
|
input: unknown;
|
|
113
|
+
workerId?: string;
|
|
114
|
+
workerTask?: string;
|
|
110
115
|
messageId?: string;
|
|
111
116
|
} | {
|
|
112
117
|
type: 'tool_result';
|
|
@@ -114,48 +119,33 @@ export type OutboundMessage = {
|
|
|
114
119
|
toolUseId: string;
|
|
115
120
|
content: unknown;
|
|
116
121
|
isError?: boolean;
|
|
122
|
+
workerId?: string;
|
|
123
|
+
workerTask?: string;
|
|
124
|
+
messageId?: string;
|
|
125
|
+
} | {
|
|
126
|
+
type: 'agent_progress';
|
|
127
|
+
sessionId?: string;
|
|
128
|
+
status: string;
|
|
129
|
+
detail?: string;
|
|
130
|
+
metadata?: Record<string, unknown>;
|
|
117
131
|
messageId?: string;
|
|
118
132
|
} | {
|
|
119
133
|
type: 'system';
|
|
120
134
|
sessionId: string;
|
|
121
135
|
subtype: string;
|
|
136
|
+
metadata?: Record<string, unknown>;
|
|
122
137
|
messageId?: string;
|
|
123
138
|
} | {
|
|
124
139
|
type: 'error';
|
|
125
140
|
sessionId?: string;
|
|
126
141
|
message: string;
|
|
127
142
|
messageId?: string;
|
|
128
|
-
} | {
|
|
129
|
-
type: 'worker_update';
|
|
130
|
-
worker: WorkerUpdatePayload;
|
|
131
|
-
sessionId?: string;
|
|
132
|
-
messageId?: string;
|
|
133
143
|
} | {
|
|
134
144
|
type: 'pong';
|
|
135
145
|
messageId?: string;
|
|
136
|
-
} | {
|
|
137
|
-
type: 'result';
|
|
138
|
-
sessionId: string;
|
|
139
|
-
success: boolean;
|
|
140
|
-
durationMs?: number;
|
|
141
|
-
costUsd?: number;
|
|
142
|
-
message?: string;
|
|
143
|
-
messageId?: string;
|
|
144
146
|
};
|
|
145
147
|
export interface SessionSubscriber {
|
|
146
148
|
id: string;
|
|
147
149
|
send: (message: OutboundMessage) => void;
|
|
148
150
|
canSend?: () => boolean;
|
|
149
151
|
}
|
|
150
|
-
export interface WorkerUpdatePayload {
|
|
151
|
-
id: string;
|
|
152
|
-
task: string;
|
|
153
|
-
status: string;
|
|
154
|
-
prompt: string;
|
|
155
|
-
lastUpdateAt: number;
|
|
156
|
-
latestMessage?: string;
|
|
157
|
-
result?: string;
|
|
158
|
-
error?: string;
|
|
159
|
-
originSessionId?: string;
|
|
160
|
-
sessionId: string;
|
|
161
|
-
}
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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'),
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const inboundMessageSchema = z.discriminatedUnion('type', [
|
|
3
|
+
z.object({
|
|
4
|
+
type: z.literal('chat'),
|
|
5
|
+
sessionId: z.string().trim().min(1).optional(),
|
|
6
|
+
text: z.string().min(1, 'text cannot be empty'),
|
|
10
7
|
}),
|
|
11
|
-
|
|
12
|
-
type:
|
|
13
|
-
sessionId:
|
|
14
|
-
parentSessionId:
|
|
15
|
-
metadata:
|
|
8
|
+
z.object({
|
|
9
|
+
type: z.literal('session_init'),
|
|
10
|
+
sessionId: z.string().trim().min(1, 'sessionId is required for session_init'),
|
|
11
|
+
parentSessionId: z.string().trim().min(1).optional(),
|
|
12
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
16
13
|
}),
|
|
17
|
-
|
|
18
|
-
type:
|
|
19
|
-
sessionId:
|
|
14
|
+
z.object({
|
|
15
|
+
type: z.literal('join'),
|
|
16
|
+
sessionId: z.string().trim().min(1, 'sessionId is required to join'),
|
|
20
17
|
}),
|
|
21
|
-
|
|
22
|
-
type:
|
|
23
|
-
sessionId:
|
|
18
|
+
z.object({
|
|
19
|
+
type: z.literal('leave'),
|
|
20
|
+
sessionId: z.string().trim().min(1, 'sessionId is required to leave'),
|
|
24
21
|
}),
|
|
25
|
-
|
|
26
|
-
type:
|
|
22
|
+
z.object({
|
|
23
|
+
type: z.literal('ping'),
|
|
27
24
|
}),
|
|
28
|
-
|
|
29
|
-
type:
|
|
30
|
-
workerId:
|
|
25
|
+
z.object({
|
|
26
|
+
type: z.literal('cancel_worker'),
|
|
27
|
+
workerId: z.string().trim().min(1, 'workerId is required'),
|
|
31
28
|
}),
|
|
32
29
|
]);
|
|
33
30
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/orchestrator/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/orchestrator/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC/D,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAA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;KAC3D,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple async queue for streaming messages to workers.
|
|
3
|
+
* Allows pushing messages and consuming them via async iteration.
|
|
4
|
+
*/
|
|
5
|
+
export declare class AsyncQueue<T> {
|
|
6
|
+
private queue;
|
|
7
|
+
private resolvers;
|
|
8
|
+
private closed;
|
|
9
|
+
/**
|
|
10
|
+
* Push a new item to the queue.
|
|
11
|
+
* If there are waiting consumers, resolve them immediately.
|
|
12
|
+
*/
|
|
13
|
+
push(item: T): void;
|
|
14
|
+
/**
|
|
15
|
+
* Close the queue, signaling that no more items will be added.
|
|
16
|
+
*/
|
|
17
|
+
close(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Check if the queue is closed.
|
|
20
|
+
*/
|
|
21
|
+
isClosed(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Async iterator implementation for consuming items from the queue.
|
|
24
|
+
*/
|
|
25
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple async queue for streaming messages to workers.
|
|
3
|
+
* Allows pushing messages and consuming them via async iteration.
|
|
4
|
+
*/
|
|
5
|
+
export class AsyncQueue {
|
|
6
|
+
queue = [];
|
|
7
|
+
resolvers = [];
|
|
8
|
+
closed = false;
|
|
9
|
+
/**
|
|
10
|
+
* Push a new item to the queue.
|
|
11
|
+
* If there are waiting consumers, resolve them immediately.
|
|
12
|
+
*/
|
|
13
|
+
push(item) {
|
|
14
|
+
if (this.closed) {
|
|
15
|
+
throw new Error('Cannot push to a closed queue');
|
|
16
|
+
}
|
|
17
|
+
if (this.resolvers.length > 0) {
|
|
18
|
+
const resolve = this.resolvers.shift();
|
|
19
|
+
resolve?.({ value: item, done: false });
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.queue.push(item);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Close the queue, signaling that no more items will be added.
|
|
27
|
+
*/
|
|
28
|
+
close() {
|
|
29
|
+
this.closed = true;
|
|
30
|
+
// Resolve all waiting consumers with done: true
|
|
31
|
+
while (this.resolvers.length > 0) {
|
|
32
|
+
const resolve = this.resolvers.shift();
|
|
33
|
+
resolve?.({ value: undefined, done: true });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if the queue is closed.
|
|
38
|
+
*/
|
|
39
|
+
isClosed() {
|
|
40
|
+
return this.closed;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Async iterator implementation for consuming items from the queue.
|
|
44
|
+
*/
|
|
45
|
+
async *[Symbol.asyncIterator]() {
|
|
46
|
+
while (true) {
|
|
47
|
+
// If there are items in the queue, yield them
|
|
48
|
+
if (this.queue.length > 0) {
|
|
49
|
+
const item = this.queue.shift();
|
|
50
|
+
if (item !== undefined) {
|
|
51
|
+
yield item;
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
// If the queue is closed and empty, we're done
|
|
56
|
+
if (this.closed) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Wait for a new item or close
|
|
60
|
+
const result = await new Promise((resolve) => {
|
|
61
|
+
this.resolvers.push(resolve);
|
|
62
|
+
});
|
|
63
|
+
if (result.done) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
yield result.value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=async-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-queue.js","sourceRoot":"","sources":["../../../src/orchestrator/utils/async-queue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,UAAU;IACb,KAAK,GAAQ,EAAE,CAAC;IAChB,SAAS,GAA8C,EAAE,CAAC;IAC1D,MAA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