cyrus-edge-worker 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/AgentSessionManager.d.ts +35 -37
- package/dist/AgentSessionManager.d.ts.map +1 -1
- package/dist/AgentSessionManager.js +102 -402
- package/dist/AgentSessionManager.js.map +1 -1
- package/dist/EdgeWorker.d.ts +25 -7
- package/dist/EdgeWorker.d.ts.map +1 -1
- package/dist/EdgeWorker.js +280 -149
- package/dist/EdgeWorker.js.map +1 -1
- package/dist/procedures/ProcedureRouter.d.ts +5 -3
- package/dist/procedures/ProcedureRouter.d.ts.map +1 -1
- package/dist/procedures/ProcedureRouter.js +25 -11
- package/dist/procedures/ProcedureRouter.js.map +1 -1
- package/dist/procedures/registry.d.ts +5 -5
- package/dist/procedures/registry.js +5 -5
- package/dist/procedures/registry.js.map +1 -1
- package/dist/procedures/types.d.ts +3 -2
- package/dist/procedures/types.d.ts.map +1 -1
- package/package.json +8 -7
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import type { SDKMessage, SDKResultMessage, SDKSystemMessage } from "cyrus-claude-runner";
|
|
3
|
+
import { type CyrusAgentSession, type CyrusAgentSessionEntry, type IAgentRunner, type IIssueTrackerService, type IssueMinimal, type SerializedCyrusAgentSession, type SerializedCyrusAgentSessionEntry, type Workspace } from "cyrus-core";
|
|
3
4
|
import type { ProcedureRouter } from "./procedures/ProcedureRouter.js";
|
|
4
5
|
import type { SharedApplicationServer } from "./SharedApplicationServer.js";
|
|
6
|
+
/**
|
|
7
|
+
* Events emitted by AgentSessionManager
|
|
8
|
+
*/
|
|
9
|
+
export interface AgentSessionManagerEvents {
|
|
10
|
+
subroutineComplete: (data: {
|
|
11
|
+
linearAgentActivitySessionId: string;
|
|
12
|
+
session: CyrusAgentSession;
|
|
13
|
+
}) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type-safe event emitter interface for AgentSessionManager
|
|
17
|
+
*/
|
|
18
|
+
export declare interface AgentSessionManager {
|
|
19
|
+
on<K extends keyof AgentSessionManagerEvents>(event: K, listener: AgentSessionManagerEvents[K]): this;
|
|
20
|
+
emit<K extends keyof AgentSessionManagerEvents>(event: K, ...args: Parameters<AgentSessionManagerEvents[K]>): boolean;
|
|
21
|
+
}
|
|
5
22
|
/**
|
|
6
23
|
* Manages Agent Sessions integration with Claude Code SDK
|
|
7
24
|
* Transforms Claude streaming messages into Agent Session format
|
|
@@ -9,7 +26,7 @@ import type { SharedApplicationServer } from "./SharedApplicationServer.js";
|
|
|
9
26
|
*
|
|
10
27
|
* CURRENTLY BEING HANDLED 'per repository'
|
|
11
28
|
*/
|
|
12
|
-
export declare class AgentSessionManager {
|
|
29
|
+
export declare class AgentSessionManager extends EventEmitter {
|
|
13
30
|
private issueTracker;
|
|
14
31
|
private sessions;
|
|
15
32
|
private entries;
|
|
@@ -20,40 +37,21 @@ export declare class AgentSessionManager {
|
|
|
20
37
|
private sharedApplicationServer?;
|
|
21
38
|
private getParentSessionId?;
|
|
22
39
|
private resumeParentSession?;
|
|
23
|
-
|
|
24
|
-
constructor(issueTracker: IIssueTrackerService, getParentSessionId?: (childSessionId: string) => string | undefined, resumeParentSession?: (parentSessionId: string, prompt: string, childSessionId: string) => Promise<void>, resumeNextSubroutine?: (linearAgentActivitySessionId: string) => Promise<void>, procedureRouter?: ProcedureRouter, sharedApplicationServer?: SharedApplicationServer);
|
|
40
|
+
constructor(issueTracker: IIssueTrackerService, getParentSessionId?: (childSessionId: string) => string | undefined, resumeParentSession?: (parentSessionId: string, prompt: string, childSessionId: string) => Promise<void>, procedureRouter?: ProcedureRouter, sharedApplicationServer?: SharedApplicationServer);
|
|
25
41
|
/**
|
|
26
42
|
* Initialize a Linear agent session from webhook
|
|
27
43
|
* The session is already created by Linear, we just need to track it
|
|
28
44
|
*/
|
|
29
45
|
createLinearAgentSession(linearAgentActivitySessionId: string, issueId: string, issueMinimal: IssueMinimal, workspace: Workspace): CyrusAgentSession;
|
|
30
46
|
/**
|
|
31
|
-
*
|
|
47
|
+
* Update Agent Session with session ID from system initialization
|
|
48
|
+
* Automatically detects whether it's Claude or Gemini based on the runner
|
|
32
49
|
*/
|
|
33
50
|
updateAgentSessionWithClaudeSessionId(linearAgentActivitySessionId: string, claudeSystemMessage: SDKSystemMessage): void;
|
|
34
51
|
/**
|
|
35
|
-
* Create a session entry from
|
|
52
|
+
* Create a session entry from user/assistant message (without syncing to Linear)
|
|
36
53
|
*/
|
|
37
54
|
private createSessionEntry;
|
|
38
|
-
/**
|
|
39
|
-
* Format TodoWrite tool parameter as a nice checklist
|
|
40
|
-
*/
|
|
41
|
-
private formatTodoWriteParameter;
|
|
42
|
-
/**
|
|
43
|
-
* Format tool input for display in Linear agent activities
|
|
44
|
-
* Converts raw tool inputs into user-friendly parameter strings
|
|
45
|
-
*/
|
|
46
|
-
private formatToolParameter;
|
|
47
|
-
/**
|
|
48
|
-
* Format tool action name with description for Bash tool
|
|
49
|
-
* Puts the description in round brackets after the tool name in the action field
|
|
50
|
-
*/
|
|
51
|
-
private formatToolActionName;
|
|
52
|
-
/**
|
|
53
|
-
* Format tool result for display in Linear agent activities
|
|
54
|
-
* Converts raw tool results into formatted Markdown
|
|
55
|
-
*/
|
|
56
|
-
private formatToolResult;
|
|
57
55
|
/**
|
|
58
56
|
* Complete a session from Claude result message
|
|
59
57
|
*/
|
|
@@ -75,7 +73,7 @@ export declare class AgentSessionManager {
|
|
|
75
73
|
*/
|
|
76
74
|
private updateSessionStatus;
|
|
77
75
|
/**
|
|
78
|
-
* Add result entry from
|
|
76
|
+
* Add result entry from result message
|
|
79
77
|
*/
|
|
80
78
|
private addResultEntry;
|
|
81
79
|
/**
|
|
@@ -111,17 +109,17 @@ export declare class AgentSessionManager {
|
|
|
111
109
|
*/
|
|
112
110
|
getActiveSessions(): CyrusAgentSession[];
|
|
113
111
|
/**
|
|
114
|
-
* Add or update
|
|
112
|
+
* Add or update agent runner for a session
|
|
115
113
|
*/
|
|
116
|
-
|
|
114
|
+
addAgentRunner(linearAgentActivitySessionId: string, agentRunner: IAgentRunner): void;
|
|
117
115
|
/**
|
|
118
|
-
* Get all
|
|
116
|
+
* Get all agent runners
|
|
119
117
|
*/
|
|
120
|
-
|
|
118
|
+
getAllAgentRunners(): IAgentRunner[];
|
|
121
119
|
/**
|
|
122
|
-
* Get all
|
|
120
|
+
* Get all agent runners for a specific issue
|
|
123
121
|
*/
|
|
124
|
-
|
|
122
|
+
getAgentRunnersForIssue(issueId: string): IAgentRunner[];
|
|
125
123
|
/**
|
|
126
124
|
* Get sessions by issue ID
|
|
127
125
|
*/
|
|
@@ -135,13 +133,13 @@ export declare class AgentSessionManager {
|
|
|
135
133
|
*/
|
|
136
134
|
getAllSessions(): CyrusAgentSession[];
|
|
137
135
|
/**
|
|
138
|
-
* Get
|
|
136
|
+
* Get agent runner for a specific session
|
|
139
137
|
*/
|
|
140
|
-
|
|
138
|
+
getAgentRunner(linearAgentActivitySessionId: string): IAgentRunner | undefined;
|
|
141
139
|
/**
|
|
142
|
-
* Check if
|
|
140
|
+
* Check if an agent runner exists for a session
|
|
143
141
|
*/
|
|
144
|
-
|
|
142
|
+
hasAgentRunner(linearAgentActivitySessionId: string): boolean;
|
|
145
143
|
/**
|
|
146
144
|
* Create a thought activity
|
|
147
145
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentSessionManager.d.ts","sourceRoot":"","sources":["../src/AgentSessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AgentSessionManager.d.ts","sourceRoot":"","sources":["../src/AgentSessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAIX,UAAU,EACV,gBAAgB,EAEhB,gBAAgB,EAEhB,MAAM,qBAAqB,CA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