omnara 0.4.0 → 0.5.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.
@@ -1,4 +1,4 @@
1
- import { type SDKUserMessage } from '@anthropic-ai/claude-agent-sdk';
1
+ import { type Options, type SDKUserMessage } from '@anthropic-ai/claude-agent-sdk';
2
2
  import type { AgentClient } from './ai-client.js';
3
3
  import type { MessageEnvelope, MessageEnvelopeSchema } from '@omnara/shared-js/schemas';
4
4
  interface UserTextSender extends MessageEnvelopeSchema.SenderRef {
@@ -40,7 +40,7 @@ export declare class Session implements AsyncIterable<SDKUserMessage> {
40
40
  private announcementPromise;
41
41
  private announced;
42
42
  private shouldSummarize;
43
- private systemPromptProvider?;
43
+ private conversationHistory;
44
44
  private readonly sessionInitControl;
45
45
  constructor(id: string, ai: AgentClient, options?: SessionOptions);
46
46
  enqueue(message: UserTextEnvelope): void;
@@ -54,8 +54,24 @@ export declare class Session implements AsyncIterable<SDKUserMessage> {
54
54
  private emitProgress;
55
55
  onEnvelope(cb: (msg: MessageEnvelope) => void | Promise<void>): void;
56
56
  onSessionInit(cb: (control: SessionInitNotification) => void | Promise<void>): void;
57
- setSystemPromptProvider(provider: () => string | Promise<string>): void;
57
+ setOptions(options: Partial<Options>): void;
58
+ getOptions(): Options;
58
59
  cancel(): Promise<void>;
60
+ /**
61
+ * Generate a commit message based on conversation context and the provided diff.
62
+ * Uses the conversation history to understand the intent and context of changes,
63
+ * combined with the diff to produce a meaningful commit message.
64
+ */
65
+ generateCommitMessage(diff: string): Promise<string>;
66
+ /**
67
+ * Build a condensed representation of the conversation history for commit message generation.
68
+ * Limits the context to avoid overwhelming the model while capturing key intent.
69
+ */
70
+ private buildConversationContext;
71
+ /**
72
+ * Build the prompt for commit message generation.
73
+ */
74
+ private buildCommitMessagePrompt;
59
75
  private dispatchEnvelope;
60
76
  private emitSessionInit;
61
77
  }
@@ -9,6 +9,13 @@ export declare class WorktreeManager {
9
9
  private worktreeBasePath;
10
10
  constructor(repoPath: string);
11
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
+ */
12
19
  getWorktreeDirectory(worktreeName: string, workerId: string): Promise<string>;
13
20
  /**
14
21
  * Internal method that performs the actual worktree creation
@@ -35,5 +42,10 @@ export declare class WorktreeManager {
35
42
  * @returns The first valid ref found, or undefined if none exist
36
43
  */
37
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>;
38
50
  commitChanges(worktreeName?: string, message?: string): Promise<void>;
39
51
  }
@@ -1,6 +1,5 @@
1
1
  import type { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
2
- import { type AgentClient } from './ai-client.js';
3
- import { WorktreeManager } from './utils/worktree-manager.js';
2
+ import { type AgentClient, type ModelType } from './ai-client.js';
4
3
  import { Session, type CompleteMessageEnvelope } from './session.js';
5
4
  import type { WorkerStatus } from './worker-types.js';
6
5
  import type { MessageEnvelope } from '@omnara/shared-js/schemas';
@@ -8,8 +7,6 @@ export type { WorkerStatus, WorkerRecord, WorkerSessionMessageEvent } from './wo
8
7
  interface LaunchWorkerOptions {
9
8
  task: string;
10
9
  prompt: string;
11
- work_context: string;
12
- worktree_name: string;
13
10
  originSessionId: string;
14
11
  metadata?: Record<string, unknown>;
15
12
  }
@@ -23,6 +20,8 @@ interface WorkerManagerOptions {
23
20
  metadata?: Record<string, unknown>;
24
21
  }) => Promise<void> | void;
25
22
  repoPath: string;
23
+ /** Working directory for workers. If not set, uses repoPath. Can be updated via setWorkingDirectory(). */
24
+ workingDirectory?: string;
26
25
  }
27
26
  type Worker = {
28
27
  status: WorkerStatus;
@@ -30,7 +29,6 @@ type Worker = {
30
29
  ai: AgentClient;
31
30
  task: string;
32
31
  parentSessionId: string;
33
- worktreeName?: string;
34
32
  directory: string;
35
33
  startedAt: number;
36
34
  lastUpdateAt: number;
@@ -38,17 +36,35 @@ type Worker = {
38
36
  export declare class WorkerManager {
39
37
  private readonly options;
40
38
  private workers;
41
- worktreeManager: WorktreeManager;
39
+ private workerModel;
40
+ private workingDirectory;
42
41
  broadcastMessage: (msg: MessageEnvelope) => Promise<void> | void;
43
42
  broadcastComplete: (complete: CompleteMessageEnvelope) => Promise<void> | void;
44
43
  readonly repoPath: string;
45
44
  private readonly announceWorkerSession?;
46
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;
47
63
  listWorkers(): Worker[];
48
64
  getWorker(id: string): Worker | undefined;
49
65
  getWorkerByTask(task: string): Worker | undefined;
50
66
  cancelWorker(id: string): Promise<boolean>;
51
- launchWorker({ task, prompt, worktree_name, originSessionId, }: LaunchWorkerOptions): Promise<Worker>;
67
+ launchWorker({ task, prompt, originSessionId, metadata, }: LaunchWorkerOptions): Promise<Worker>;
52
68
  /**
53
69
  * Route a user message to a worker by session ID.
54
70
  * Thin wrapper around enqueueMessage.
@@ -62,5 +78,4 @@ export declare class WorkerManager {
62
78
  shutdown(): Promise<void>;
63
79
  private onComplete;
64
80
  onMessage(id: string, msg: MessageEnvelope): Promise<void>;
65
- private commitWorkerChanges;
66
81
  }