cyrus-core 0.2.3 → 0.2.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/dist/CyrusAgentSession.d.ts +7 -4
- package/dist/CyrusAgentSession.d.ts.map +1 -1
- package/dist/CyrusAgentSession.js +1 -1
- package/dist/StreamingPrompt.d.ts +21 -0
- package/dist/StreamingPrompt.d.ts.map +1 -0
- package/dist/StreamingPrompt.js +76 -0
- package/dist/StreamingPrompt.js.map +1 -0
- package/dist/agent-runner-types.d.ts +324 -0
- package/dist/agent-runner-types.d.ts.map +1 -0
- package/dist/agent-runner-types.js +2 -0
- package/dist/agent-runner-types.js.map +1 -0
- package/dist/config-types.d.ts +1 -1
- package/dist/config-types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/issue-tracker/index.d.ts +1 -1
- package/dist/issue-tracker/index.d.ts.map +1 -1
- package/dist/simple-agent-runner-types.d.ts +206 -0
- package/dist/simple-agent-runner-types.d.ts.map +1 -0
- package/dist/simple-agent-runner-types.js +2 -0
- package/dist/simple-agent-runner-types.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Session types for Linear Agent Sessions integration
|
|
3
|
-
* These types represent the core data structures for tracking
|
|
3
|
+
* These types represent the core data structures for tracking agent sessions in Linear
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { IAgentRunner } from "./agent-runner-types.js";
|
|
6
6
|
import type { AgentSessionStatus, AgentSessionType } from "./issue-tracker/types.js";
|
|
7
7
|
export interface IssueMinimal {
|
|
8
8
|
id: string;
|
|
@@ -27,7 +27,8 @@ export interface CyrusAgentSession {
|
|
|
27
27
|
issue: IssueMinimal;
|
|
28
28
|
workspace: Workspace;
|
|
29
29
|
claudeSessionId?: string;
|
|
30
|
-
|
|
30
|
+
geminiSessionId?: string;
|
|
31
|
+
agentRunner?: IAgentRunner;
|
|
31
32
|
metadata?: {
|
|
32
33
|
model?: string;
|
|
33
34
|
tools?: string[];
|
|
@@ -43,12 +44,14 @@ export interface CyrusAgentSession {
|
|
|
43
44
|
subroutine: string;
|
|
44
45
|
completedAt: number;
|
|
45
46
|
claudeSessionId: string | null;
|
|
47
|
+
geminiSessionId: string | null;
|
|
46
48
|
}>;
|
|
47
49
|
};
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
export interface CyrusAgentSessionEntry {
|
|
51
|
-
claudeSessionId
|
|
53
|
+
claudeSessionId?: string;
|
|
54
|
+
geminiSessionId?: string;
|
|
52
55
|
linearAgentActivityId?: string;
|
|
53
56
|
type: "user" | "assistant" | "system" | "result";
|
|
54
57
|
content: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CyrusAgentSession.d.ts","sourceRoot":"","sources":["../src/CyrusAgentSession.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"CyrusAgentSession.d.ts","sourceRoot":"","sources":["../src/CyrusAgentSession.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EACX,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM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;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE;QACV,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,GAAG,CAAC;QAChB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Session types for Linear Agent Sessions integration
|
|
3
|
-
* These types represent the core data structures for tracking
|
|
3
|
+
* These types represent the core data structures for tracking agent sessions in Linear
|
|
4
4
|
*/
|
|
5
5
|
export {};
|
|
6
6
|
//# sourceMappingURL=CyrusAgentSession.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Streaming prompt controller that implements AsyncIterable<SDKUserMessage>
|
|
4
|
+
*
|
|
5
|
+
* Provides a queue-based async iterator for streaming user messages to agent runners.
|
|
6
|
+
* Used by both ClaudeRunner and GeminiRunner for streaming input support.
|
|
7
|
+
*/
|
|
8
|
+
export declare class StreamingPrompt {
|
|
9
|
+
private messageQueue;
|
|
10
|
+
private resolvers;
|
|
11
|
+
private isComplete;
|
|
12
|
+
private sessionId;
|
|
13
|
+
constructor(sessionId: string | null, initialPrompt?: string);
|
|
14
|
+
updateSessionId(sessionId: string): void;
|
|
15
|
+
addMessage(content: string): void;
|
|
16
|
+
complete(): void;
|
|
17
|
+
get completed(): boolean;
|
|
18
|
+
private processQueue;
|
|
19
|
+
[Symbol.asyncIterator](): AsyncIterator<SDKUserMessage>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=StreamingPrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingPrompt.d.ts","sourceRoot":"","sources":["../src/StreamingPrompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE;;;;;GAKG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,SAAS,CACb;IACJ,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAgB;gBAErB,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,aAAa,CAAC,EAAE,MAAM;IAO5D,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIxC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAmBjC,QAAQ,IAAI,IAAI;IAKhB,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,OAAO,CAAC,YAAY;IAgBpB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,cAAc,CAAC;CAgBvD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming prompt controller that implements AsyncIterable<SDKUserMessage>
|
|
3
|
+
*
|
|
4
|
+
* Provides a queue-based async iterator for streaming user messages to agent runners.
|
|
5
|
+
* Used by both ClaudeRunner and GeminiRunner for streaming input support.
|
|
6
|
+
*/
|
|
7
|
+
export class StreamingPrompt {
|
|
8
|
+
messageQueue = [];
|
|
9
|
+
resolvers = [];
|
|
10
|
+
isComplete = false;
|
|
11
|
+
sessionId;
|
|
12
|
+
constructor(sessionId, initialPrompt) {
|
|
13
|
+
this.sessionId = sessionId;
|
|
14
|
+
if (initialPrompt) {
|
|
15
|
+
this.addMessage(initialPrompt);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
updateSessionId(sessionId) {
|
|
19
|
+
this.sessionId = sessionId;
|
|
20
|
+
}
|
|
21
|
+
addMessage(content) {
|
|
22
|
+
if (this.isComplete) {
|
|
23
|
+
throw new Error("Cannot add message to completed stream");
|
|
24
|
+
}
|
|
25
|
+
const message = {
|
|
26
|
+
type: "user",
|
|
27
|
+
message: {
|
|
28
|
+
role: "user",
|
|
29
|
+
content: content,
|
|
30
|
+
},
|
|
31
|
+
parent_tool_use_id: null,
|
|
32
|
+
session_id: this.sessionId || "pending",
|
|
33
|
+
};
|
|
34
|
+
this.messageQueue.push(message);
|
|
35
|
+
this.processQueue();
|
|
36
|
+
}
|
|
37
|
+
complete() {
|
|
38
|
+
this.isComplete = true;
|
|
39
|
+
this.processQueue();
|
|
40
|
+
}
|
|
41
|
+
get completed() {
|
|
42
|
+
return this.isComplete;
|
|
43
|
+
}
|
|
44
|
+
processQueue() {
|
|
45
|
+
while (this.resolvers.length > 0 &&
|
|
46
|
+
(this.messageQueue.length > 0 || this.isComplete)) {
|
|
47
|
+
const resolver = this.resolvers.shift();
|
|
48
|
+
if (this.messageQueue.length > 0) {
|
|
49
|
+
const message = this.messageQueue.shift();
|
|
50
|
+
resolver({ value: message, done: false });
|
|
51
|
+
}
|
|
52
|
+
else if (this.isComplete) {
|
|
53
|
+
resolver({ value: undefined, done: true });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
[Symbol.asyncIterator]() {
|
|
58
|
+
return {
|
|
59
|
+
next: () => {
|
|
60
|
+
return new Promise((resolve) => {
|
|
61
|
+
if (this.messageQueue.length > 0) {
|
|
62
|
+
const message = this.messageQueue.shift();
|
|
63
|
+
resolve({ value: message, done: false });
|
|
64
|
+
}
|
|
65
|
+
else if (this.isComplete) {
|
|
66
|
+
resolve({ value: undefined, done: true });
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.resolvers.push(resolve);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=StreamingPrompt.js.map
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type { HookCallbackMatcher, HookEvent, McpServerConfig, SDKMessage, SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Message Formatter Interface
|
|
4
|
+
*
|
|
5
|
+
* Forward declaration - implemented by each runner (e.g., ClaudeMessageFormatter, GeminiMessageFormatter)
|
|
6
|
+
*/
|
|
7
|
+
export interface IMessageFormatter {
|
|
8
|
+
formatTodoWriteParameter(jsonContent: string): string;
|
|
9
|
+
formatToolParameter(toolName: string, toolInput: any): string;
|
|
10
|
+
formatToolActionName(toolName: string, toolInput: any, isError: boolean): string;
|
|
11
|
+
formatToolResult(toolName: string, toolInput: any, result: string, isError: boolean): string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Agent Runner Interface
|
|
15
|
+
*
|
|
16
|
+
* This interface provides a provider-agnostic abstraction for AI agent runners.
|
|
17
|
+
* It follows the same pattern as IIssueTrackerService, where type aliases point
|
|
18
|
+
* to provider-specific SDK types (currently Claude SDK).
|
|
19
|
+
*
|
|
20
|
+
* The interface is designed to support multiple AI providers (Claude, Gemini, etc.)
|
|
21
|
+
* through adapter implementations, while maintaining a consistent API surface.
|
|
22
|
+
*
|
|
23
|
+
* ## Architecture Pattern
|
|
24
|
+
*
|
|
25
|
+
* This abstraction uses type aliasing to external SDK types rather than creating
|
|
26
|
+
* new types. This approach:
|
|
27
|
+
* - Maintains compatibility with existing Claude SDK code
|
|
28
|
+
* - Allows gradual migration to provider-agnostic code
|
|
29
|
+
* - Enables adapter pattern implementations for other providers
|
|
30
|
+
* - Preserves type safety and IDE autocomplete
|
|
31
|
+
*
|
|
32
|
+
* ## Usage Example
|
|
33
|
+
*
|
|
34
|
+
* ```typescript
|
|
35
|
+
* class ClaudeRunnerAdapter implements IAgentRunner {
|
|
36
|
+
* async start(prompt: string): Promise<AgentSessionInfo> {
|
|
37
|
+
* // Implementation using Claude SDK
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* async startStreaming(initialPrompt?: string): Promise<AgentSessionInfo> {
|
|
41
|
+
* // Implementation using Claude SDK streaming
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* // ... other methods
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* class GeminiRunnerAdapter implements IAgentRunner {
|
|
48
|
+
* async start(prompt: string): Promise<AgentSessionInfo> {
|
|
49
|
+
* // Implementation using Gemini SDK
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* // ... other methods
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @see {@link AgentRunnerConfig} for configuration options
|
|
57
|
+
* @see {@link AgentSessionInfo} for session information structure
|
|
58
|
+
*/
|
|
59
|
+
export interface IAgentRunner {
|
|
60
|
+
/**
|
|
61
|
+
* Indicates whether this runner supports streaming input
|
|
62
|
+
*
|
|
63
|
+
* When true, the runner supports `startStreaming()`, `addStreamMessage()`, and `completeStream()`.
|
|
64
|
+
* When false, only `start()` should be used - streaming methods may throw or be unavailable.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* if (runner.supportsStreamingInput) {
|
|
69
|
+
* await runner.startStreaming(initialPrompt);
|
|
70
|
+
* runner.addStreamMessage("Additional context");
|
|
71
|
+
* } else {
|
|
72
|
+
* await runner.start(fullPrompt);
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
readonly supportsStreamingInput: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Start a new agent session with a string prompt (legacy/simple mode)
|
|
79
|
+
*
|
|
80
|
+
* This method initiates a complete agent session with a single prompt string.
|
|
81
|
+
* The session runs until completion or until stopped.
|
|
82
|
+
*
|
|
83
|
+
* @param prompt - The initial prompt to send to the agent
|
|
84
|
+
* @returns Session information including session ID and status
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const runner = new ClaudeRunnerAdapter(config);
|
|
89
|
+
* const session = await runner.start("Please analyze this codebase");
|
|
90
|
+
* console.log(`Session started: ${session.sessionId}`);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
start(prompt: string): Promise<AgentSessionInfo>;
|
|
94
|
+
/**
|
|
95
|
+
* Start a new agent session with streaming input support
|
|
96
|
+
*
|
|
97
|
+
* This method enables adding messages to the session dynamically after it has started.
|
|
98
|
+
* Use this for interactive sessions where prompts arrive over time (e.g., from webhooks).
|
|
99
|
+
*
|
|
100
|
+
* Only available when `supportsStreamingInput` is true.
|
|
101
|
+
*
|
|
102
|
+
* @param initialPrompt - Optional initial prompt to send immediately
|
|
103
|
+
* @returns Session information including session ID and status
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* if (runner.supportsStreamingInput) {
|
|
108
|
+
* const session = await runner.startStreaming("Initial task");
|
|
109
|
+
* runner.addStreamMessage("Additional context");
|
|
110
|
+
* runner.completeStream();
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
startStreaming?(initialPrompt?: string): Promise<AgentSessionInfo>;
|
|
115
|
+
/**
|
|
116
|
+
* Add a message to the streaming prompt
|
|
117
|
+
*
|
|
118
|
+
* Only works when the session was started with `startStreaming()`.
|
|
119
|
+
* Messages are queued and sent to the agent as it processes them.
|
|
120
|
+
*
|
|
121
|
+
* Only available when `supportsStreamingInput` is true.
|
|
122
|
+
*
|
|
123
|
+
* @param content - The message content to add to the stream
|
|
124
|
+
* @throws Error if not in streaming mode or if stream is already completed
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* runner.addStreamMessage("New comment from user: Fix the bug in auth.ts");
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
addStreamMessage?(content: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* Complete the streaming prompt (no more messages will be added)
|
|
134
|
+
*
|
|
135
|
+
* This signals to the agent that no more messages will be added to the stream.
|
|
136
|
+
* The agent will complete processing and finish the session.
|
|
137
|
+
*
|
|
138
|
+
* Only available when `supportsStreamingInput` is true.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* runner.addStreamMessage("Final message");
|
|
143
|
+
* runner.completeStream(); // Agent will finish processing
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
completeStream?(): void;
|
|
147
|
+
/**
|
|
148
|
+
* Stop the current agent session
|
|
149
|
+
*
|
|
150
|
+
* Gracefully terminates the running session. Any in-progress operations
|
|
151
|
+
* will be aborted, and the session will transition to stopped state.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* // User unassigned from issue - stop the agent
|
|
156
|
+
* if (runner.isRunning()) {
|
|
157
|
+
* runner.stop();
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
stop(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Check if the session is currently running
|
|
164
|
+
*
|
|
165
|
+
* @returns True if the session is active and processing, false otherwise
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* if (runner.isRunning()) {
|
|
170
|
+
* console.log("Session still active");
|
|
171
|
+
* } else {
|
|
172
|
+
* console.log("Session completed or not started");
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
isRunning(): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Get all messages from the current session
|
|
179
|
+
*
|
|
180
|
+
* Returns a copy of all messages exchanged in the session, including
|
|
181
|
+
* user prompts, assistant responses, system messages, and tool results.
|
|
182
|
+
*
|
|
183
|
+
* @returns Array of all session messages (copy, not reference)
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const messages = runner.getMessages();
|
|
188
|
+
* console.log(`Session has ${messages.length} messages`);
|
|
189
|
+
*
|
|
190
|
+
* // Analyze assistant responses
|
|
191
|
+
* const assistantMessages = messages.filter(m => m.type === 'assistant');
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
getMessages(): AgentMessage[];
|
|
195
|
+
/**
|
|
196
|
+
* Get the message formatter for this runner
|
|
197
|
+
*
|
|
198
|
+
* Returns a formatter that can convert tool messages into human-readable
|
|
199
|
+
* format suitable for display in Linear or other issue trackers.
|
|
200
|
+
* Each runner provides its own formatter that understands its specific message format.
|
|
201
|
+
*
|
|
202
|
+
* @returns The message formatter instance for this runner
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const formatter = runner.getFormatter();
|
|
207
|
+
* const formatted = formatter.formatToolParameter("Read", { file_path: "/test.ts" });
|
|
208
|
+
* console.log(formatted); // "/test.ts"
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
getFormatter(): IMessageFormatter;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Configuration for agent runner
|
|
215
|
+
*
|
|
216
|
+
* This type aliases to the Claude SDK configuration structure. When implementing
|
|
217
|
+
* adapters for other providers (e.g., Gemini), they should map their config to
|
|
218
|
+
* this structure or extend it with provider-specific options.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* const config: AgentRunnerConfig = {
|
|
223
|
+
* workingDirectory: '/path/to/repo',
|
|
224
|
+
* allowedDirectories: ['/path/to/repo'],
|
|
225
|
+
* mcpConfig: {
|
|
226
|
+
* 'linear': { command: 'npx', args: ['-y', '@linear/mcp-server'] }
|
|
227
|
+
* },
|
|
228
|
+
* cyrusHome: '/home/user/.cyrus'
|
|
229
|
+
* };
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export interface AgentRunnerConfig {
|
|
233
|
+
/** Working directory for the agent session */
|
|
234
|
+
workingDirectory?: string;
|
|
235
|
+
/** List of allowed tool patterns (e.g., ["Read(**)", "Edit(**)"]) */
|
|
236
|
+
allowedTools?: string[];
|
|
237
|
+
/** List of disallowed tool patterns */
|
|
238
|
+
disallowedTools?: string[];
|
|
239
|
+
/** Directories the agent can read from */
|
|
240
|
+
allowedDirectories?: string[];
|
|
241
|
+
/** Session ID to resume from a previous session */
|
|
242
|
+
resumeSessionId?: string;
|
|
243
|
+
/** Workspace name for logging and organization */
|
|
244
|
+
workspaceName?: string;
|
|
245
|
+
/** Additional text to append to default system prompt */
|
|
246
|
+
appendSystemPrompt?: string;
|
|
247
|
+
/** Path(s) to MCP configuration file(s) */
|
|
248
|
+
mcpConfigPath?: string | string[];
|
|
249
|
+
/** MCP server configurations (inline) */
|
|
250
|
+
mcpConfig?: Record<string, McpServerConfig>;
|
|
251
|
+
/** AI model to use (e.g., "opus", "sonnet", "haiku") */
|
|
252
|
+
model?: string;
|
|
253
|
+
/** Fallback model if primary is unavailable */
|
|
254
|
+
fallbackModel?: string;
|
|
255
|
+
/** Maximum number of turns before completing session */
|
|
256
|
+
maxTurns?: number;
|
|
257
|
+
/** Cyrus home directory (required) */
|
|
258
|
+
cyrusHome: string;
|
|
259
|
+
/** Prompt template version information */
|
|
260
|
+
promptVersions?: {
|
|
261
|
+
userPromptVersion?: string;
|
|
262
|
+
systemPromptVersion?: string;
|
|
263
|
+
};
|
|
264
|
+
/** Event hooks for customizing agent behavior */
|
|
265
|
+
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
266
|
+
/** Callback for each message received */
|
|
267
|
+
onMessage?: (message: AgentMessage) => void | Promise<void>;
|
|
268
|
+
/** Callback for errors */
|
|
269
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
270
|
+
/** Callback when session completes */
|
|
271
|
+
onComplete?: (messages: AgentMessage[]) => void | Promise<void>;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Information about an agent session
|
|
275
|
+
*
|
|
276
|
+
* Tracks the lifecycle and status of an agent session.
|
|
277
|
+
* The sessionId is initially null and gets assigned by the provider
|
|
278
|
+
* when the first message is processed.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const info: AgentSessionInfo = {
|
|
283
|
+
* sessionId: 'claude-session-abc123',
|
|
284
|
+
* startedAt: new Date(),
|
|
285
|
+
* isRunning: true
|
|
286
|
+
* };
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
export interface AgentSessionInfo {
|
|
290
|
+
/** Unique session identifier (null until first message) */
|
|
291
|
+
sessionId: string | null;
|
|
292
|
+
/** When the session started */
|
|
293
|
+
startedAt: Date;
|
|
294
|
+
/** Whether the session is currently active */
|
|
295
|
+
isRunning: boolean;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Type alias for agent messages
|
|
299
|
+
*
|
|
300
|
+
* Maps to Claude SDK's SDKMessage type, which is a union of:
|
|
301
|
+
* - SDKUserMessage (user inputs)
|
|
302
|
+
* - SDKAssistantMessage (agent responses)
|
|
303
|
+
* - SDKSystemMessage (system prompts)
|
|
304
|
+
* - SDKResultMessage (completion/error results)
|
|
305
|
+
*
|
|
306
|
+
* Other provider adapters should map their message types to this structure.
|
|
307
|
+
*/
|
|
308
|
+
export type AgentMessage = SDKMessage;
|
|
309
|
+
/**
|
|
310
|
+
* Type alias for user messages
|
|
311
|
+
*
|
|
312
|
+
* Maps to Claude SDK's SDKUserMessage type.
|
|
313
|
+
* Used for prompts and user inputs to the agent.
|
|
314
|
+
*/
|
|
315
|
+
export type AgentUserMessage = SDKUserMessage;
|
|
316
|
+
/**
|
|
317
|
+
* Re-export SDK types for convenience
|
|
318
|
+
*
|
|
319
|
+
* These re-exports allow consumers to import all necessary types
|
|
320
|
+
* from a single location (packages/core) without knowing the
|
|
321
|
+
* underlying provider SDK.
|
|
322
|
+
*/
|
|
323
|
+
export type { HookCallbackMatcher, HookEvent, McpServerConfig, SDKAssistantMessage, SDKMessage, SDKResultMessage, SDKUserMessage, } from "@anthropic-ai/claude-agent-sdk";
|
|
324
|
+
//# sourceMappingURL=agent-runner-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runner-types.d.ts","sourceRoot":"","sources":["../src/agent-runner-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,cAAc,EACd,MAAM,gCAAgC,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IACtD,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,MAAM,CAAC;IAC9D,oBAAoB,CACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,GAAG,EACd,OAAO,EAAE,OAAO,GACd,MAAM,CAAC;IACV,gBAAgB,CACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,GAAG,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACd,MAAM,CAAC;CACV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;IAEzC;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEjD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEnE;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,IAAI,IAAI,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AC,SAAS,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;IAC1D,yCAAyC;IACzC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,0BAA0B;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,sCAAsC;IACtC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,gBAAgB;IAChC,2DAA2D;IAC3D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,+BAA+B;IAC/B,SAAS,EAAE,IAAI,CAAC;IAChB,8CAA8C;IAC9C,SAAS,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH,YAAY,EACX,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,cAAc,GACd,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runner-types.js","sourceRoot":"","sources":["../src/agent-runner-types.ts"],"names":[],"mappings":""}
|
package/dist/config-types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { SDKMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
1
2
|
import type { Issue as LinearIssue } from "@linear/sdk";
|
|
2
|
-
import type { SDKMessage } from "cyrus-claude-runner";
|
|
3
3
|
import type { Workspace } from "./CyrusAgentSession.js";
|
|
4
4
|
/**
|
|
5
5
|
* Resolve path with tilde (~) expansion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../src/config-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../src/config-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKhD;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAClC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,KACjB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAEhC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IAGb,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAGvB,gBAAgB,EAAE,MAAM,CAAC;IAGzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eA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 -1,3 +1,4 @@
|
|
|
1
|
+
export type { AgentMessage, AgentRunnerConfig, AgentSessionInfo, AgentUserMessage, HookCallbackMatcher, HookEvent, IAgentRunner, IMessageFormatter, McpServerConfig, SDKAssistantMessage, SDKMessage, SDKResultMessage, SDKUserMessage, } from "./agent-runner-types.js";
|
|
1
2
|
export type { CyrusAgentSession, CyrusAgentSessionEntry, IssueMinimal, Workspace, } from "./CyrusAgentSession.js";
|
|
2
3
|
export type { EdgeConfig, EdgeWorkerConfig, OAuthCallbackHandler, RepositoryConfig, } from "./config-types.js";
|
|
3
4
|
export { resolvePath } from "./config-types.js";
|
|
@@ -6,4 +7,6 @@ export type { AgentActivity, AgentActivityContent, AgentActivityCreateInput, Age
|
|
|
6
7
|
export { AgentActivityContentType, AgentActivitySignal, AgentSessionStatus, AgentSessionType, isAgentSessionCreatedEvent, isAgentSessionCreatedWebhook, isAgentSessionPromptedEvent, isAgentSessionPromptedWebhook, isCommentMentionEvent, isIssueAssignedEvent, isIssueAssignedWebhook, isIssueCommentMentionWebhook, isIssueNewCommentWebhook, isIssueUnassignedEvent, isIssueUnassignedWebhook, isNewCommentEvent, } from "./issue-tracker/index.js";
|
|
7
8
|
export type { SerializableEdgeWorkerState, SerializedCyrusAgentSession, SerializedCyrusAgentSessionEntry, } from "./PersistenceManager.js";
|
|
8
9
|
export { PersistenceManager } from "./PersistenceManager.js";
|
|
10
|
+
export { StreamingPrompt } from "./StreamingPrompt.js";
|
|
11
|
+
export type { IAgentProgressEvent, ISimpleAgentQueryOptions, ISimpleAgentResult, ISimpleAgentRunner, ISimpleAgentRunnerConfig, } from "./simple-agent-runner-types.js";
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"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AA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AAIlC,YAAY,EACX,2BAA2B,EAC3B,2BAA2B,EAC3B,gCAAgC,GAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,YAAY,EACX,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,gCAAgC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { resolvePath } from "./config-types.js";
|
|
|
6
6
|
export { DEFAULT_PROXY_URL } from "./constants.js";
|
|
7
7
|
export { AgentActivityContentType, AgentActivitySignal, AgentSessionStatus, AgentSessionType, isAgentSessionCreatedEvent, isAgentSessionCreatedWebhook, isAgentSessionPromptedEvent, isAgentSessionPromptedWebhook, isCommentMentionEvent, isIssueAssignedEvent, isIssueAssignedWebhook, isIssueCommentMentionWebhook, isIssueNewCommentWebhook, isIssueUnassignedEvent, isIssueUnassignedWebhook, isNewCommentEvent, } from "./issue-tracker/index.js";
|
|
8
8
|
export { PersistenceManager } from "./PersistenceManager.js";
|
|
9
|
+
export { StreamingPrompt } from "./StreamingPrompt.js";
|
|
9
10
|
// Platform-agnostic webhook type aliases - exported from issue-tracker
|
|
10
11
|
// These are now defined in issue-tracker/types.ts as aliases to Linear SDK webhook types
|
|
11
12
|
// EdgeWorker and other high-level code should use these generic names via issue-tracker exports
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,sEAAsE;AACtE,qFAAqF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,sEAAsE;AACtE,qFAAqF;AAgCrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,YAAY;AACZ,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA0CnD,OAAO,EACN,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,6BAA6B,EAC7B,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AASvD,uEAAuE;AACvE,yFAAyF;AACzF,gGAAgG"}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* }
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
export { IIssueTrackerService } from "./IIssueTrackerService.js";
|
|
41
|
+
export type { IIssueTrackerService } from "./IIssueTrackerService.js";
|
|
42
42
|
export type { AgentEventTransportConfig, AgentEventTransportEvents, IAgentEventTransport, } from "./IAgentEventTransport.js";
|
|
43
43
|
export type { AgentActivityCreateInput, AgentActivityPayload, } from "./types.js";
|
|
44
44
|
export * from "./types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/issue-tracker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/issue-tracker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAMtE,YAAY,EACX,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,GACpB,MAAM,2BAA2B,CAAC;AAOnC,YAAY,EACX,wBAAwB,EACxB,oBAAoB,GACpB,MAAM,YAAY,CAAC;AAEpB,cAAc,YAAY,CAAC;AAM3B,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AAczB;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,mBAAmB,qBAAsB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { SDKMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Simple Agent Runner Interface
|
|
4
|
+
*
|
|
5
|
+
* This interface provides a provider-agnostic abstraction for simple agent runners
|
|
6
|
+
* that return enumerated responses. It follows the same pattern as IAgentRunner,
|
|
7
|
+
* where type aliases point to provider-specific SDK types (currently Claude SDK).
|
|
8
|
+
*
|
|
9
|
+
* Simple agent runners are specialized agents that:
|
|
10
|
+
* - Accept a constrained set of valid responses (enumerated type T)
|
|
11
|
+
* - Run until they produce one of the valid responses
|
|
12
|
+
* - Validate the response before returning
|
|
13
|
+
* - Provide progress events during execution
|
|
14
|
+
*
|
|
15
|
+
* ## Architecture Pattern
|
|
16
|
+
*
|
|
17
|
+
* This abstraction uses type aliasing to external SDK types rather than creating
|
|
18
|
+
* new types. This approach:
|
|
19
|
+
* - Maintains compatibility with existing simple-agent-runner code
|
|
20
|
+
* - Allows gradual migration to provider-agnostic code
|
|
21
|
+
* - Enables adapter pattern implementations for other providers
|
|
22
|
+
* - Preserves type safety and IDE autocomplete
|
|
23
|
+
*
|
|
24
|
+
* ## Usage Example
|
|
25
|
+
*
|
|
26
|
+
* ```typescript
|
|
27
|
+
* type IssueAction = "fix" | "skip" | "clarify";
|
|
28
|
+
*
|
|
29
|
+
* const config: ISimpleAgentRunnerConfig<IssueAction> = {
|
|
30
|
+
* validResponses: ["fix", "skip", "clarify"] as const,
|
|
31
|
+
* systemPrompt: "You analyze issues and decide what to do",
|
|
32
|
+
* cyrusHome: "/home/user/.cyrus",
|
|
33
|
+
* onProgress: (event) => {
|
|
34
|
+
* if (event.type === "response-detected") {
|
|
35
|
+
* console.log(`Agent wants to: ${event.candidateResponse}`);
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* const runner = new SimpleAgentRunner(config);
|
|
41
|
+
* const result = await runner.query("What should I do with this bug?");
|
|
42
|
+
* console.log(`Decision: ${result.response}`); // "fix" | "skip" | "clarify"
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @see {@link ISimpleAgentRunnerConfig} for configuration options
|
|
46
|
+
* @see {@link ISimpleAgentResult} for result structure
|
|
47
|
+
* @see {@link IAgentProgressEvent} for progress event types
|
|
48
|
+
*/
|
|
49
|
+
export interface ISimpleAgentRunner<T extends string> {
|
|
50
|
+
/**
|
|
51
|
+
* Query the agent and get an enumerated response
|
|
52
|
+
*
|
|
53
|
+
* This method runs a complete agent session and returns one of the
|
|
54
|
+
* predefined valid responses. The agent will continue running until
|
|
55
|
+
* it produces a valid response or times out.
|
|
56
|
+
*
|
|
57
|
+
* @param question - The question or prompt to send to the agent
|
|
58
|
+
* @param options - Optional configuration for this specific query
|
|
59
|
+
* @returns A result containing the validated response and session metadata
|
|
60
|
+
* @throws Error if the agent times out or fails to produce a valid response
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const result = await runner.query(
|
|
65
|
+
* "Should we merge this PR?",
|
|
66
|
+
* { context: "CI passed, 2 approvals", allowFileReading: true }
|
|
67
|
+
* );
|
|
68
|
+
* console.log(`Decision: ${result.response}`); // "approve" | "reject" | "request-changes"
|
|
69
|
+
* console.log(`Cost: $${result.costUSD}`);
|
|
70
|
+
* console.log(`Duration: ${result.durationMs}ms`);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
query(question: string, options?: ISimpleAgentQueryOptions): Promise<ISimpleAgentResult<T>>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Progress events emitted during agent execution
|
|
77
|
+
*
|
|
78
|
+
* These events allow monitoring the agent's progress as it works toward
|
|
79
|
+
* producing a valid response. Useful for logging, UI updates, or debugging.
|
|
80
|
+
*
|
|
81
|
+
* Event types:
|
|
82
|
+
* - `started`: Session has begun (includes sessionId)
|
|
83
|
+
* - `thinking`: Agent is processing (includes reasoning text)
|
|
84
|
+
* - `tool-use`: Agent is using a tool (includes tool name and input)
|
|
85
|
+
* - `response-detected`: Agent produced a candidate response (may be invalid)
|
|
86
|
+
* - `validating`: Checking if response is valid
|
|
87
|
+
*/
|
|
88
|
+
export type IAgentProgressEvent = {
|
|
89
|
+
type: "started";
|
|
90
|
+
sessionId: string | null;
|
|
91
|
+
} | {
|
|
92
|
+
type: "thinking";
|
|
93
|
+
text: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: "tool-use";
|
|
96
|
+
toolName: string;
|
|
97
|
+
input: unknown;
|
|
98
|
+
} | {
|
|
99
|
+
type: "response-detected";
|
|
100
|
+
candidateResponse: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: "validating";
|
|
103
|
+
response: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Configuration for Simple Agent Runner
|
|
107
|
+
*
|
|
108
|
+
* Defines how the simple agent runner should behave, including valid responses,
|
|
109
|
+
* prompts, timeouts, and progress callbacks.
|
|
110
|
+
*
|
|
111
|
+
* @template T - The enumerated string type for valid responses
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* type Priority = "low" | "medium" | "high" | "critical";
|
|
116
|
+
*
|
|
117
|
+
* const config: ISimpleAgentRunnerConfig<Priority> = {
|
|
118
|
+
* validResponses: ["low", "medium", "high", "critical"] as const,
|
|
119
|
+
* systemPrompt: "Analyze the issue and determine priority level",
|
|
120
|
+
* maxTurns: 10,
|
|
121
|
+
* timeoutMs: 60000,
|
|
122
|
+
* model: "sonnet",
|
|
123
|
+
* cyrusHome: "/home/user/.cyrus",
|
|
124
|
+
* onProgress: (event) => {
|
|
125
|
+
* console.log(`Agent progress: ${event.type}`);
|
|
126
|
+
* }
|
|
127
|
+
* };
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export interface ISimpleAgentRunnerConfig<T extends string> {
|
|
131
|
+
/** Valid response options that the agent must choose from */
|
|
132
|
+
validResponses: readonly T[];
|
|
133
|
+
/** System prompt to guide the agent's behavior */
|
|
134
|
+
systemPrompt?: string;
|
|
135
|
+
/** Maximum number of turns before timeout */
|
|
136
|
+
maxTurns?: number;
|
|
137
|
+
/** Timeout in milliseconds for the entire operation */
|
|
138
|
+
timeoutMs?: number;
|
|
139
|
+
/** Model to use (e.g., "sonnet", "haiku") */
|
|
140
|
+
model?: string;
|
|
141
|
+
/** Fallback model if primary is unavailable */
|
|
142
|
+
fallbackModel?: string;
|
|
143
|
+
/** Working directory for agent execution */
|
|
144
|
+
workingDirectory?: string;
|
|
145
|
+
/** Cyrus home directory */
|
|
146
|
+
cyrusHome: string;
|
|
147
|
+
/** Optional callback for progress events */
|
|
148
|
+
onProgress?: (event: IAgentProgressEvent) => void;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Result from a Simple Agent Runner query
|
|
152
|
+
*
|
|
153
|
+
* Contains the validated response along with session metadata including
|
|
154
|
+
* messages, duration, cost, and session ID.
|
|
155
|
+
*
|
|
156
|
+
* @template T - The enumerated string type for valid responses
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const result: ISimpleAgentResult<"approve" | "reject"> = {
|
|
161
|
+
* response: "approve",
|
|
162
|
+
* messages: [...], // All SDK messages from the session
|
|
163
|
+
* sessionId: "claude-session-123",
|
|
164
|
+
* durationMs: 5432,
|
|
165
|
+
* costUSD: 0.0234
|
|
166
|
+
* };
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export interface ISimpleAgentResult<T extends string> {
|
|
170
|
+
/** The validated response from the agent */
|
|
171
|
+
response: T;
|
|
172
|
+
/** All SDK messages from the session */
|
|
173
|
+
messages: SDKMessage[];
|
|
174
|
+
/** Session ID for debugging/logging */
|
|
175
|
+
sessionId: string | null;
|
|
176
|
+
/** Duration of execution in milliseconds */
|
|
177
|
+
durationMs: number;
|
|
178
|
+
/** Cost in USD (if available) */
|
|
179
|
+
costUSD?: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Options for a Simple Agent Runner query
|
|
183
|
+
*
|
|
184
|
+
* Provides additional configuration that can be specified per-query
|
|
185
|
+
* to customize behavior beyond the runner's base configuration.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const options: ISimpleAgentQueryOptions = {
|
|
190
|
+
* context: "User has premium subscription, last login was 2 days ago",
|
|
191
|
+
* allowFileReading: true,
|
|
192
|
+
* allowedDirectories: ["/home/user/project/src"]
|
|
193
|
+
* };
|
|
194
|
+
*
|
|
195
|
+
* const result = await runner.query("Should we send a reminder email?", options);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export interface ISimpleAgentQueryOptions {
|
|
199
|
+
/** Additional context to provide to the agent */
|
|
200
|
+
context?: string;
|
|
201
|
+
/** Allow the agent to use file reading tools */
|
|
202
|
+
allowFileReading?: boolean;
|
|
203
|
+
/** Allowed directories for file operations */
|
|
204
|
+
allowedDirectories?: string[];
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=simple-agent-runner-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-agent-runner-types.d.ts","sourceRoot":"","sources":["../src/simple-agent-runner-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM;IACnD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CACJ,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,wBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,mBAAmB,GAC5B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,MAAM;IACzD,6DAA6D;IAC7D,cAAc,EAAE,SAAS,CAAC,EAAE,CAAC;IAE7B,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAElB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM;IACnD,4CAA4C;IAC5C,QAAQ,EAAE,CAAC,CAAC;IAEZ,wCAAwC;IACxC,QAAQ,EAAE,UAAU,EAAE,CAAC;IAEvB,uCAAuC;IACvC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IAEnB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,wBAAwB;IACxC,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-agent-runner-types.js","sourceRoot":"","sources":["../src/simple-agent-runner-types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyrus-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Core business logic for Cyrus",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"
|
|
12
|
+
"@anthropic-ai/claude-agent-sdk": "^0.1.52",
|
|
13
|
+
"@linear/sdk": "^64.0.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^20.0.0",
|