omnara 0.5.3 → 0.6.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.
Files changed (73) hide show
  1. package/README.md +23 -10
  2. package/bin/omnara.js +56 -17
  3. package/package.json +24 -55
  4. package/dist/auth/auth-provider.d.ts +0 -26
  5. package/dist/auth/cli-auth-service.d.ts +0 -26
  6. package/dist/auth/credential-manager.d.ts +0 -13
  7. package/dist/auth/credentials-store.d.ts +0 -20
  8. package/dist/auth/ensure-cli-credentials.d.ts +0 -8
  9. package/dist/auth/login-flow.d.ts +0 -11
  10. package/dist/auth/loopback-listener.d.ts +0 -20
  11. package/dist/auth/pkce.d.ts +0 -6
  12. package/dist/cli.d.ts +0 -3
  13. package/dist/cli.js +0 -19186
  14. package/dist/cli.js.map +0 -7
  15. package/dist/commands/agent.d.ts +0 -9
  16. package/dist/commands/auth.d.ts +0 -2
  17. package/dist/commands/daemon.d.ts +0 -2
  18. package/dist/commands/index.d.ts +0 -4
  19. package/dist/commands/kill.d.ts +0 -2
  20. package/dist/config/omnara-config.d.ts +0 -19
  21. package/dist/daemon/config-store.d.ts +0 -37
  22. package/dist/daemon/daemon-client.d.ts +0 -27
  23. package/dist/daemon/daemon-launcher.d.ts +0 -39
  24. package/dist/daemon/daemon-service.d.ts +0 -30
  25. package/dist/daemon/directory-registry.d.ts +0 -17
  26. package/dist/daemon/local-control-server.d.ts +0 -38
  27. package/dist/daemon/machine-supervisor.d.ts +0 -61
  28. package/dist/daemon/paths.d.ts +0 -16
  29. package/dist/daemon/run-daemon.d.ts +0 -1
  30. package/dist/daemon/session-pid-registry.d.ts +0 -11
  31. package/dist/daemon/session-runner.d.ts +0 -28
  32. package/dist/daemon/state-store.d.ts +0 -14
  33. package/dist/env/env-mode.d.ts +0 -2
  34. package/dist/http/api-client.d.ts +0 -19
  35. package/dist/http/machines.d.ts +0 -3
  36. package/dist/http/user-sessions.d.ts +0 -16
  37. package/dist/http/workspaces.d.ts +0 -4
  38. package/dist/index.d.ts +0 -1
  39. package/dist/orchestrator/agent-orchestrator.d.ts +0 -103
  40. package/dist/orchestrator/ai-client.d.ts +0 -32
  41. package/dist/orchestrator/orchestrator-prompt.d.ts +0 -8
  42. package/dist/orchestrator/orchestrator-prompt.md +0 -222
  43. package/dist/orchestrator/orchestrator-types.d.ts +0 -168
  44. package/dist/orchestrator/session.d.ts +0 -82
  45. package/dist/orchestrator/tools/worker-tools.d.ts +0 -10
  46. package/dist/orchestrator/utils/completions-manager.d.ts +0 -8
  47. package/dist/orchestrator/utils/envelope-utils.d.ts +0 -13
  48. package/dist/orchestrator/utils/index.d.ts +0 -2
  49. package/dist/orchestrator/utils/session-logger.d.ts +0 -7
  50. package/dist/orchestrator/utils/worker-events.d.ts +0 -7
  51. package/dist/orchestrator/utils/worktree-manager.d.ts +0 -51
  52. package/dist/orchestrator/worker-manager.d.ts +0 -81
  53. package/dist/orchestrator/worker-types.d.ts +0 -23
  54. package/dist/orchestrator-prompt.md +0 -222
  55. package/dist/package-info.d.ts +0 -12
  56. package/dist/relay/relay-bridge.d.ts +0 -65
  57. package/dist/relay/relay-service.d.ts +0 -19
  58. package/dist/schemas/index.d.ts +0 -2
  59. package/dist/utils/backoff.d.ts +0 -6
  60. package/dist/utils/browser.d.ts +0 -1
  61. package/dist/utils/claude-code-check.d.ts +0 -19
  62. package/dist/utils/executable.d.ts +0 -53
  63. package/dist/utils/logger.d.ts +0 -143
  64. package/dist/utils/prompt.d.ts +0 -1
  65. package/dist/utils/version-check.d.ts +0 -47
  66. package/dist/utils/websocket.d.ts +0 -5
  67. package/instrument.mjs +0 -14
  68. package/scripts/build-executable.ts +0 -244
  69. package/scripts/copy-assets.mjs +0 -41
  70. package/scripts/generate-release-json.ts +0 -136
  71. package/scripts/preinstall.js +0 -141
  72. package/scripts/test-preinstall.js +0 -124
  73. package/scripts/upload-release.ts +0 -388
@@ -1,222 +0,0 @@
1
- # Role: Task Orchestrator
2
-
3
- You are Omnara, an orchestrator agent. Your job is to coordinate work by delegating to worker agents while staying responsive to user interaction.
4
-
5
- ## The Mental Model
6
-
7
- **You stay zoomed out. Workers go zoomed in.**
8
-
9
- You are a coordinator who maintains the big picture. Workers are specialists who dive deep into specific domains. When a worker investigates authentication, they accumulate valuable context about the auth system. That context is an asset - reuse it.
10
-
11
- **Context is valuable. Accuracy over speed.**
12
-
13
- A worker who already understands a domain will do better work than a fresh worker starting from zero. Always prefer routing work to workers with relevant context over launching new workers.
14
-
15
- ---
16
-
17
- ## Tool Restrictions
18
-
19
- **FORBIDDEN tools (delegate these to workers):**
20
- - Write, Edit, Bash, NotebookEdit
21
-
22
- **Allowed tools (read-only, use sparingly):**
23
- - Read, Grep, Glob - For quick lookups (1-2 calls max)
24
- - WebFetch, WebSearch - For external information
25
- - TodoWrite - For tracking multi-step tasks
26
-
27
- **Why?** Using forbidden tools blocks your context. Workers execute operations without blocking you. Your job is to coordinate, not implement.
28
-
29
- ---
30
-
31
- ## The Routing Decision
32
-
33
- When a user request comes in, follow this decision tree:
34
-
35
- ```
36
- New request arrives
37
- |
38
- v
39
- Is there a completed worker whose domain matches this request?
40
- |
41
- YES --> Route to that worker (message_worker)
42
- NO --> Is there a running worker whose domain matches?
43
- |
44
- YES --> Queue message to that worker (message_worker, interrupt=false)
45
- NO --> Launch a new worker
46
- ```
47
-
48
- **How to identify matching domains:** Check the worker-status in your system prompt and [Automated Worker Summary] messages. They show task names, status, worktree, and completion summaries.
49
-
50
- ### When to Route to Existing Workers
51
-
52
- **Workers evolve over time.** A worker's task name reflects what they started with, but they accumulate context as they receive follow-up messages. They may handle related work that wasn't part of their original task but shares context. When deciding whether to route to an existing worker, don't just match on task name - consider whether the worker has touched relevant files, worked in the same domain, or has context that would be useful even if the new request isn't exactly what they originally did.
53
-
54
- Route to an existing worker when:
55
- - The request involves files/code that worker has touched
56
- - The request is in the same feature area
57
- - The request builds on or modifies previous work
58
- - The user is asking about work a worker did
59
- - Understanding prior decisions would be valuable
60
- - **A bug or question comes up related to work a worker previously did** - Message that worker to investigate/fix it instead of investigating yourself or asking the user for direction. The worker has the context and will be more effective.
61
-
62
- ### When to Launch New Workers
63
-
64
- Launch a new worker only when:
65
- - No existing worker has relevant context
66
- - The request is in a completely unrelated domain
67
- - The user explicitly asks for a separate task
68
- - Work would conflict with an existing worker's activity
69
-
70
- ### Routing Examples
71
-
72
- ```
73
- Worker "auth-impl" previously: Implemented login/logout
74
-
75
- User: "Add password reset"
76
- --> Message "auth-impl" (same domain, they know the auth system)
77
-
78
- User: "Add dark mode to settings"
79
- --> Launch new worker (unrelated domain)
80
-
81
- User: "Why did you use JWT instead of sessions?"
82
- --> Message "auth-impl" (they made that decision)
83
- ```
84
-
85
- ---
86
-
87
- ## Using message_worker
88
-
89
- **interrupt=false (default):** Queue message for after current work
90
- - Use for: Follow-up tasks, additional requirements, questions
91
-
92
- **interrupt=true:** Stop current work immediately
93
- - Use only when: User explicitly says stop, or new info contradicts current direction
94
-
95
- **Message content should include:**
96
- - What the user is asking for
97
- - How it relates to the worker's previous work (if not obvious)
98
- - Any new context from the user
99
-
100
- **After messaging:** Don't poll with get_workers. You'll be automatically notified when the worker completes.
101
-
102
- ---
103
-
104
- ## Launching Workers
105
-
106
- When you do need to launch new workers:
107
-
108
- **Provide clear instructions:**
109
- - What to do
110
- - What information to return
111
- - Any relevant context you gathered
112
-
113
- **Use worktree_name for isolation:**
114
- - `worktree_name="feature-x"` creates an isolated git branch
115
- - Multiple workers with same worktree_name share that branch
116
- - Different worktree_names = fully isolated work
117
- - Omit for trivial changes (typos, docs)
118
-
119
- **Example delegation:**
120
- ```
121
- User: "Add rate limiting to the API"
122
-
123
- launch_worker with prompt: "Add rate limiting middleware to the API.
124
- Apply globally with 100 requests per 15 minutes.
125
- Document the configuration in comments."
126
- worktree_name: "add-rate-limiting"
127
- ```
128
-
129
- ---
130
-
131
- ## Multiple Workers
132
-
133
- **Parallel workers are appropriate when:**
134
- - Tasks are in completely different domains
135
- - Tasks don't depend on each other's results
136
- - Example: "Fix auth bug AND add logging feature" - 2 workers, different worktrees
137
-
138
- **Sequential work should reuse the same worker:**
139
- - "Research auth libraries, then implement" - One worker does both
140
- - "Implement feature, then add tests" - Same worker continues
141
-
142
- **Avoid:** Launching parallel workers for tightly related work. The workers won't share context and may make inconsistent decisions.
143
-
144
- ---
145
-
146
- ## Worktree Patterns
147
-
148
- **Same worktree, same worker (preferred for sequential work):**
149
- ```
150
- launch_worker(worktree_name="feature-x", ...)
151
- [worker completes]
152
- message_worker(task="feature-x", message="Now do the next step...")
153
- ```
154
- Context preserved. Worker knows the domain.
155
-
156
- **Different worktrees (for unrelated parallel work):**
157
- ```
158
- launch_worker(worktree_name="feature-x", ...)
159
- launch_worker(worktree_name="feature-y", ...)
160
- ```
161
- Fully isolated. Different features/branches.
162
-
163
- **Same worktree, different workers (rare - only when you want fresh perspective):**
164
- ```
165
- launch_worker(worktree_name="feature-x", ...)
166
- [worker completes]
167
- launch_worker(worktree_name="feature-x", ...) # New worker, context discarded
168
- ```
169
- Use sparingly. Loses accumulated knowledge.
170
-
171
- ---
172
-
173
- ## TodoWrite
174
-
175
- Use for multi-step tasks (2+ sequential steps) to give users visibility.
176
-
177
- **Todo states:** pending, in_progress, completed
178
- **Keep exactly ONE todo in_progress at a time.**
179
-
180
- ```
181
- User: "Add OAuth, then test it"
182
-
183
- TodoWrite:
184
- 1. "Implement OAuth" - in_progress
185
- 2. "Test OAuth flow" - pending
186
-
187
- [Worker completes step 1]
188
- Update: step 1 completed, step 2 in_progress
189
- ```
190
-
191
- Don't use TodoWrite for single tasks or simple lookups.
192
-
193
- ---
194
-
195
- ## Responding to Worker Completions
196
-
197
- When a worker completes, you receive an [Automated Worker Summary] message containing what the worker accomplished.
198
-
199
- **Your response should:**
200
- 1. Report ONLY the new completion (not previously reported ones)
201
- 2. Keep it brief: "The auth worker completed. Login/logout endpoints are implemented."
202
- 3. Note next steps if applicable
203
-
204
- **Don't:** Re-summarize all workers. Re-explain previous completions. Provide comprehensive recaps unless asked.
205
-
206
- ---
207
-
208
- ## Remember
209
-
210
- **Your role:** Coordinator, not implementer. Stay zoomed out.
211
-
212
- **Tool restrictions:** Never use Write, Edit, Bash, NotebookEdit directly. Always delegate.
213
-
214
- **Routing priority:** Existing workers with context > New workers. Context is valuable.
215
-
216
- **Accuracy over speed:** One worker with good context beats two workers duplicating effort.
217
-
218
- **Stay responsive:** Delegate to keep your context unblocked for user interaction.
219
-
220
- **Worker status:** Check worker-status in your system prompt and [Automated Worker Summary] messages. Don't poll with get_workers.
221
-
222
- **When in doubt:** Route to an existing worker if one has relevant context. Otherwise, delegate to a new worker.
@@ -1,168 +0,0 @@
1
- /**
2
- * Internal orchestrator message types for communication between components
3
- * These are NOT wire protocol types - they're internal to the orchestrator
4
- *
5
- * For wire protocol types (sent over WebSocket), use:
6
- * - ControlMessage from @omnara/shared-js/schemas
7
- * - MessageEnvelope from @omnara/shared-js/schemas
8
- */
9
- import { z } from 'zod';
10
- export declare const inboundMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
11
- type: z.ZodLiteral<"chat">;
12
- sessionId: z.ZodOptional<z.ZodString>;
13
- text: z.ZodString;
14
- senderId: z.ZodOptional<z.ZodString>;
15
- senderKind: z.ZodOptional<z.ZodEnum<["user", "agent_session"]>>;
16
- }, "strip", z.ZodTypeAny, {
17
- text: string;
18
- type: "chat";
19
- sessionId?: string | undefined;
20
- senderId?: string | undefined;
21
- senderKind?: "user" | "agent_session" | undefined;
22
- }, {
23
- text: string;
24
- type: "chat";
25
- sessionId?: string | undefined;
26
- senderId?: string | undefined;
27
- senderKind?: "user" | "agent_session" | undefined;
28
- }>, z.ZodObject<{
29
- type: z.ZodLiteral<"session_init">;
30
- sessionId: z.ZodString;
31
- parentSessionId: z.ZodOptional<z.ZodString>;
32
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
33
- }, "strip", z.ZodTypeAny, {
34
- type: "session_init";
35
- sessionId: string;
36
- parentSessionId?: string | undefined;
37
- metadata?: Record<string, unknown> | undefined;
38
- }, {
39
- type: "session_init";
40
- sessionId: string;
41
- parentSessionId?: string | undefined;
42
- metadata?: Record<string, unknown> | undefined;
43
- }>, z.ZodObject<{
44
- type: z.ZodLiteral<"join">;
45
- sessionId: z.ZodString;
46
- }, "strip", z.ZodTypeAny, {
47
- type: "join";
48
- sessionId: string;
49
- }, {
50
- type: "join";
51
- sessionId: string;
52
- }>, z.ZodObject<{
53
- type: z.ZodLiteral<"leave">;
54
- sessionId: z.ZodString;
55
- }, "strip", z.ZodTypeAny, {
56
- type: "leave";
57
- sessionId: string;
58
- }, {
59
- type: "leave";
60
- sessionId: string;
61
- }>, z.ZodObject<{
62
- type: z.ZodLiteral<"ping">;
63
- }, "strip", z.ZodTypeAny, {
64
- type: "ping";
65
- }, {
66
- type: "ping";
67
- }>, z.ZodObject<{
68
- type: z.ZodLiteral<"cancel_worker">;
69
- workerId: z.ZodString;
70
- }, "strip", z.ZodTypeAny, {
71
- type: "cancel_worker";
72
- workerId: string;
73
- }, {
74
- type: "cancel_worker";
75
- workerId: string;
76
- }>]>;
77
- export type InboundMessage = z.infer<typeof inboundMessageSchema>;
78
- export type OutboundMessage = {
79
- type: 'session_created';
80
- sessionId: string;
81
- messageId?: string;
82
- } | {
83
- type: 'session_joined';
84
- sessionId: string;
85
- messageId?: string;
86
- } | {
87
- type: 'session_init';
88
- sessionId: string;
89
- parentSessionId?: string | null;
90
- metadata?: Record<string, unknown>;
91
- messageId?: string;
92
- } | {
93
- type: 'session_init_ack';
94
- sessionId: string;
95
- parentSessionId?: string | null;
96
- messageId?: string;
97
- } | {
98
- type: 'user_text';
99
- sessionId: string;
100
- text: string;
101
- origin?: 'user' | 'worker';
102
- workerId?: string;
103
- workerTask?: string;
104
- metadata?: Record<string, unknown>;
105
- messageId?: string;
106
- } | {
107
- type: 'assistant_text';
108
- sessionId: string;
109
- text: string;
110
- workerId?: string;
111
- workerTask?: string;
112
- messageId?: string;
113
- } | {
114
- type: 'agent_complete';
115
- sessionId: string;
116
- success: boolean;
117
- durationMs?: number;
118
- costUsd?: number;
119
- message?: string;
120
- worktree_path?: string;
121
- branch_name?: string;
122
- metadata?: Record<string, unknown>;
123
- messageId?: string;
124
- } | {
125
- type: 'tool_call';
126
- sessionId: string;
127
- toolName: string;
128
- toolUseId: string;
129
- input: unknown;
130
- workerId?: string;
131
- workerTask?: string;
132
- messageId?: string;
133
- } | {
134
- type: 'tool_result';
135
- sessionId: string;
136
- toolUseId: string;
137
- content: unknown;
138
- isError?: boolean;
139
- workerId?: string;
140
- workerTask?: string;
141
- messageId?: string;
142
- } | {
143
- type: 'agent_progress';
144
- sessionId?: string;
145
- status: string;
146
- detail?: string;
147
- metadata?: Record<string, unknown>;
148
- messageId?: string;
149
- } | {
150
- type: 'system';
151
- sessionId: string;
152
- subtype: string;
153
- metadata?: Record<string, unknown>;
154
- messageId?: string;
155
- } | {
156
- type: 'error';
157
- sessionId?: string;
158
- message: string;
159
- messageId?: string;
160
- } | {
161
- type: 'pong';
162
- messageId?: string;
163
- };
164
- export interface SessionSubscriber {
165
- id: string;
166
- send: (message: OutboundMessage) => void;
167
- canSend?: () => boolean;
168
- }
@@ -1,82 +0,0 @@
1
- import { type Options, type SDKUserMessage } from '@anthropic-ai/claude-agent-sdk';
2
- import type { AgentClient } from './ai-client.js';
3
- import type { MessageEnvelope, MessageEnvelopeSchema } from '@omnara/shared-js/schemas';
4
- interface UserTextSender extends MessageEnvelopeSchema.SenderRef {
5
- kind: 'user';
6
- }
7
- interface UserTextPayload extends MessageEnvelopeSchema.MessagePayload {
8
- content: MessageEnvelopeSchema.TextContent;
9
- }
10
- export interface UserTextEnvelope extends MessageEnvelope {
11
- sender: UserTextSender;
12
- payload: UserTextPayload;
13
- }
14
- interface CompletePayload extends MessageEnvelopeSchema.MessagePayload {
15
- content: MessageEnvelopeSchema.AgentCompleteContent;
16
- }
17
- export interface CompleteMessageEnvelope extends MessageEnvelope {
18
- payload: CompletePayload;
19
- }
20
- export interface SessionInitNotification {
21
- type: 'session_init';
22
- sessionId: string;
23
- parentSessionId: string | null;
24
- metadata?: Record<string, unknown>;
25
- }
26
- interface SessionOptions {
27
- parentSessionId?: string | null;
28
- metadata?: Record<string, unknown>;
29
- sessionType?: string;
30
- summarize?: boolean;
31
- }
32
- export declare class Session implements AsyncIterable<SDKUserMessage> {
33
- id: string;
34
- private ai;
35
- sdkSessionIdentifier?: string;
36
- private envelopeSubscribers;
37
- private sessionInitSubscribers;
38
- private queue;
39
- private generating;
40
- private announcementPromise;
41
- private announced;
42
- private shouldSummarize;
43
- private conversationHistory;
44
- private retryDelayMs;
45
- private retryCount;
46
- private readonly sessionInitControl;
47
- constructor(id: string, ai: AgentClient, options?: SessionOptions);
48
- enqueue(message: UserTextEnvelope): void;
49
- [Symbol.asyncIterator](): AsyncIterator<SDKUserMessage>;
50
- private generate;
51
- private startGenerate;
52
- private captureSdkSessionId;
53
- private collectAssistantSummaryBlocks;
54
- private buildCompletionEnvelope;
55
- private buildErrorCompletionEnvelope;
56
- private resetRetryState;
57
- private summarize;
58
- private emitProgress;
59
- onEnvelope(cb: (msg: MessageEnvelope) => void | Promise<void>): void;
60
- onSessionInit(cb: (control: SessionInitNotification) => void | Promise<void>): void;
61
- setOptions(options: Partial<Options>): void;
62
- getOptions(): Options;
63
- cancel(): Promise<void>;
64
- /**
65
- * Generate a commit message based on conversation context and the provided diff.
66
- * Uses the conversation history to understand the intent and context of changes,
67
- * combined with the diff to produce a meaningful commit message.
68
- */
69
- generateCommitMessage(diff: string): Promise<string>;
70
- /**
71
- * Build a condensed representation of the conversation history for commit message generation.
72
- * Limits the context to avoid overwhelming the model while capturing key intent.
73
- */
74
- private buildConversationContext;
75
- /**
76
- * Build the prompt for commit message generation.
77
- */
78
- private buildCommitMessagePrompt;
79
- private dispatchEnvelope;
80
- private emitSessionInit;
81
- }
82
- export {};
@@ -1,10 +0,0 @@
1
- import type { WorkerManager } from '../worker-manager.js';
2
- export declare const WORKER_LAUNCH_TOOL = "mcp__worker__launch_worker";
3
- export declare const WORKER_MESSAGE_TOOL = "mcp__worker__message_worker";
4
- interface WorkerMcpContext {
5
- resolveSessionIdBySdk: (sdkSessionId?: string) => string | undefined;
6
- resolveSessionIdByToolUse: (toolUseId: string) => string | undefined;
7
- getMainCodingSessionId: () => string | null;
8
- }
9
- export declare function createWorkerMcpServer(workerManager: WorkerManager, context: WorkerMcpContext): import("@anthropic-ai/claude-agent-sdk").McpSdkServerConfigWithInstance;
10
- export {};
@@ -1,8 +0,0 @@
1
- import type { ControlMessageSchema } from '@omnara/shared-js/schemas';
2
- export declare class CompletionsManager {
3
- private slashCommandsCache?;
4
- private filesCache;
5
- fetchSlashCommands(): Promise<string[]>;
6
- fetchFiles(searchPattern?: string): Promise<string[]>;
7
- getCompletion(query: string, limit?: number): Promise<ControlMessageSchema.CompletionItem[]>;
8
- }
@@ -1,13 +0,0 @@
1
- import type { SDKMessage } from '@anthropic-ai/claude-agent-sdk';
2
- import type { MessageEnvelope, MessageEnvelopeSchema } from '@omnara/shared-js/schemas';
3
- type TextBlock = {
4
- type: 'text';
5
- text: string;
6
- };
7
- export declare function createEnvelope(sessionId: string, content: MessageEnvelopeSchema.Content, senderId?: string, metadata?: Record<string, unknown>, payloadMetadata?: Record<string, unknown>): MessageEnvelope;
8
- export declare function toMessageEnvelopes(message: SDKMessage, sessionId: string): MessageEnvelope[];
9
- export declare function normalizeToolArguments(input: unknown): Record<string, unknown>;
10
- export declare function normalizeToolResult(output: unknown): Record<string, unknown>;
11
- export declare function isTextBlock(block: unknown): block is TextBlock;
12
- export declare function extractTextDelta(message: SDKMessage): string | null;
13
- export {};
@@ -1,2 +0,0 @@
1
- export { WorktreeManager } from './worktree-manager.js';
2
- export type { SessionLogger } from './session-logger.js';
@@ -1,7 +0,0 @@
1
- import type { OutboundMessage } from '../orchestrator-types.js';
2
- export type SessionLogger = {
3
- logInbound: (payload: unknown) => void;
4
- logOutbound: (message: OutboundMessage) => void;
5
- close: () => void;
6
- };
7
- export declare function createSessionLogger(sessionId: string): SessionLogger;
@@ -1,7 +0,0 @@
1
- import type { WorkerRecord } from '../worker-types.js';
2
- import type { OutboundMessage } from '../orchestrator-types.js';
3
- export declare function formatWorkerSummary(record: WorkerRecord, override?: string): string;
4
- export declare function createWorkerProgressMessage(record: WorkerRecord): OutboundMessage;
5
- export declare function createWorkerCompletionMessage(record: WorkerRecord, summary: string): OutboundMessage;
6
- export declare function buildWorkerCompletionPrompt(record: WorkerRecord): string;
7
- export declare function buildAgentCompletionMessage(resultText: string | null, summary: string, errorText: string | null): string;
@@ -1,51 +0,0 @@
1
- import { type SimpleGit } from 'simple-git';
2
- import type { WorkspaceConfigSchema } from '@omnara/shared-js/schemas';
3
- export declare class WorktreeManager {
4
- private repoPath;
5
- readonly git: SimpleGit;
6
- private repoName;
7
- private readonly worktrees;
8
- private worktreeUsers;
9
- private worktreeBasePath;
10
- constructor(repoPath: string);
11
- getWorktreeConfig(): Promise<WorkspaceConfigSchema.WorktreeSettings | undefined>;
12
- /**
13
- * Get the directory path for a worktree, creating it if necessary.
14
- *
15
- * @param worktreeName - The name of the worktree (also used as branch name)
16
- * @param workerId - Identifier for the worker using this worktree
17
- * @returns The path to the worktree directory
18
- */
19
- getWorktreeDirectory(worktreeName: string, workerId: string): Promise<string>;
20
- /**
21
- * Internal method that performs the actual worktree creation
22
- * This should only be called by processCreationQueue
23
- */
24
- private createWorktree;
25
- removeWorktreeUser(worktreeName: string, workerId: string, force?: boolean): Promise<void>;
26
- cleanupAll(force?: boolean): Promise<void>;
27
- listActiveWorktrees(): Array<{
28
- worktreeName: string;
29
- branchName: string;
30
- worktreePath: string;
31
- }>;
32
- /**
33
- * Parses the output of 'git worktree list --porcelain'
34
- *
35
- * @param output - Raw output from git worktree list
36
- * @returns Array of worktree paths
37
- */
38
- private parseWorktreeList;
39
- /**
40
- * Find a valid base ref to use when creating new branches
41
- * Tries in order: configured base_ref, main, master, origin/HEAD
42
- * @returns The first valid ref found, or undefined if none exist
43
- */
44
- private findValidBaseRef;
45
- /**
46
- * Stage all changes in the specified worktree by running `git add -A`
47
- * @param worktreePath - Path to the worktree directory
48
- */
49
- stageAllChanges(worktreePath: string): Promise<void>;
50
- commitChanges(worktreeName?: string, message?: string): Promise<void>;
51
- }
@@ -1,81 +0,0 @@
1
- import type { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
2
- import { type AgentClient, type ModelType } from './ai-client.js';
3
- import { Session, type CompleteMessageEnvelope } from './session.js';
4
- import type { WorkerStatus } from './worker-types.js';
5
- import type { MessageEnvelope } from '@omnara/shared-js/schemas';
6
- export type { WorkerStatus, WorkerRecord, WorkerSessionMessageEvent } from './worker-types.js';
7
- interface LaunchWorkerOptions {
8
- task: string;
9
- prompt: string;
10
- originSessionId: string;
11
- metadata?: Record<string, unknown>;
12
- }
13
- interface WorkerManagerOptions {
14
- createClient: (mcpServers?: Record<string, McpServerConfig>, cwd?: string) => AgentClient;
15
- broadcastMessage: (msg: MessageEnvelope) => Promise<void> | void;
16
- broadcastComplete: (complete: CompleteMessageEnvelope) => Promise<void> | void;
17
- announceWorkerSession?: (info: {
18
- sessionId: string;
19
- parentSessionId?: string;
20
- metadata?: Record<string, unknown>;
21
- }) => Promise<void> | void;
22
- repoPath: string;
23
- /** Working directory for workers. If not set, uses repoPath. Can be updated via setWorkingDirectory(). */
24
- workingDirectory?: string;
25
- }
26
- type Worker = {
27
- status: WorkerStatus;
28
- session: Session;
29
- ai: AgentClient;
30
- task: string;
31
- parentSessionId: string;
32
- directory: string;
33
- startedAt: number;
34
- lastUpdateAt: number;
35
- };
36
- export declare class WorkerManager {
37
- private readonly options;
38
- private workers;
39
- private workerModel;
40
- private workingDirectory;
41
- broadcastMessage: (msg: MessageEnvelope) => Promise<void> | void;
42
- broadcastComplete: (complete: CompleteMessageEnvelope) => Promise<void> | void;
43
- readonly repoPath: string;
44
- private readonly announceWorkerSession?;
45
- constructor(options: WorkerManagerOptions);
46
- /**
47
- * Set the working directory for new workers.
48
- * Use this to point workers at a worktree directory.
49
- */
50
- setWorkingDirectory(directory: string): void;
51
- /**
52
- * Get the current working directory used for new workers.
53
- */
54
- getWorkingDirectory(): string;
55
- /**
56
- * Set the model to use for all workers (current running and future).
57
- */
58
- setWorkerModel(model: ModelType): void;
59
- /**
60
- * Get the current model used for workers.
61
- */
62
- getWorkerModel(): ModelType;
63
- listWorkers(): Worker[];
64
- getWorker(id: string): Worker | undefined;
65
- getWorkerByTask(task: string): Worker | undefined;
66
- cancelWorker(id: string): Promise<boolean>;
67
- launchWorker({ task, prompt, originSessionId, metadata, }: LaunchWorkerOptions): Promise<Worker>;
68
- /**
69
- * Route a user message to a worker by session ID.
70
- * Thin wrapper around enqueueMessage.
71
- */
72
- userMessageWorker(sessionId: string, userId: string, message: string): Promise<boolean>;
73
- /**
74
- * Send a message to a worker (running or completed).
75
- * Thin wrapper around enqueueMessage.
76
- */
77
- toolMessageWorker(task: string, message: string): Promise<boolean>;
78
- shutdown(): Promise<void>;
79
- private onComplete;
80
- onMessage(id: string, msg: MessageEnvelope): Promise<void>;
81
- }
@@ -1,23 +0,0 @@
1
- import type { MessageEnvelope } from '@omnara/shared-js/schemas';
2
- import type { Session } from './session.js';
3
- export type WorkerStatus = 'running' | 'completed' | 'error' | 'canceled';
4
- export interface WorkerRecord {
5
- id: string;
6
- task: string;
7
- prompt: string;
8
- sdkSessionId?: string | null;
9
- status: WorkerStatus;
10
- startedAt: number;
11
- lastUpdateAt: number;
12
- originSessionId?: string;
13
- result?: string;
14
- error?: string;
15
- metadata?: Record<string, unknown>;
16
- session?: Session;
17
- worktreePath?: string;
18
- worktreeName?: string;
19
- }
20
- export interface WorkerSessionMessageEvent {
21
- record: WorkerRecord;
22
- message: MessageEnvelope;
23
- }