cyrus-edge-worker 0.0.17 → 0.0.18-alpha.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.
- package/dist/AgentSessionManager.d.ts +133 -0
- package/dist/AgentSessionManager.d.ts.map +1 -0
- package/dist/AgentSessionManager.js +613 -0
- package/dist/AgentSessionManager.js.map +1 -0
- package/dist/EdgeWorker.d.ts +56 -69
- package/dist/EdgeWorker.d.ts.map +1 -1
- package/dist/EdgeWorker.js +526 -698
- package/dist/EdgeWorker.js.map +1 -1
- package/dist/SharedApplicationServer.d.ts +2 -1
- package/dist/SharedApplicationServer.d.ts.map +1 -1
- package/dist/SharedApplicationServer.js +4 -2
- package/dist/SharedApplicationServer.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -6
- package/prompts/builder.md +71 -0
- package/prompts/debugger.md +91 -0
- package/prompts/scoper.md +95 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { LinearClient } from '@linear/sdk';
|
|
2
|
+
import type { SDKMessage, SDKSystemMessage, SDKResultMessage, ClaudeRunner } from 'cyrus-claude-runner';
|
|
3
|
+
import type { CyrusAgentSession, CyrusAgentSessionEntry, IssueMinimal, SerializedCyrusAgentSession, SerializedCyrusAgentSessionEntry, Workspace } from 'cyrus-core';
|
|
4
|
+
/**
|
|
5
|
+
* Manages Linear Agent Sessions integration with Claude Code SDK
|
|
6
|
+
* Transforms Claude streaming messages into Agent Session format
|
|
7
|
+
* Handles session lifecycle: create → active → complete/error
|
|
8
|
+
*
|
|
9
|
+
* CURRENTLY BEING HANDLED 'per repository'
|
|
10
|
+
*/
|
|
11
|
+
export declare class AgentSessionManager {
|
|
12
|
+
private linearClient;
|
|
13
|
+
private sessions;
|
|
14
|
+
private entries;
|
|
15
|
+
constructor(linearClient: LinearClient);
|
|
16
|
+
/**
|
|
17
|
+
* Initialize a Linear agent session from webhook
|
|
18
|
+
* The session is already created by Linear, we just need to track it
|
|
19
|
+
*/
|
|
20
|
+
createLinearAgentSession(linearAgentActivitySessionId: string, issueId: string, issueMinimal: IssueMinimal, workspace: Workspace): CyrusAgentSession;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new Agent Session from Claude system initialization
|
|
23
|
+
*/
|
|
24
|
+
updateAgentSessionWithClaudeSessionId(linearAgentActivitySessionId: string, claudeSystemMessage: SDKSystemMessage): void;
|
|
25
|
+
/**
|
|
26
|
+
* Create a session entry from Claude user/assistant message (without syncing to Linear)
|
|
27
|
+
*/
|
|
28
|
+
private createSessionEntry;
|
|
29
|
+
/**
|
|
30
|
+
* Format TodoWrite tool parameter as a nice checklist
|
|
31
|
+
*/
|
|
32
|
+
private formatTodoWriteParameter;
|
|
33
|
+
/**
|
|
34
|
+
* Complete a session from Claude result message
|
|
35
|
+
*/
|
|
36
|
+
completeSession(linearAgentActivitySessionId: string, resultMessage: SDKResultMessage): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Handle streaming Claude messages and route to appropriate methods
|
|
39
|
+
*/
|
|
40
|
+
handleClaudeMessage(linearAgentActivitySessionId: string, message: SDKMessage): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Update session status and metadata
|
|
43
|
+
*/
|
|
44
|
+
private updateSessionStatus;
|
|
45
|
+
/**
|
|
46
|
+
* Add result entry from Claude result message
|
|
47
|
+
*/
|
|
48
|
+
private addResultEntry;
|
|
49
|
+
/**
|
|
50
|
+
* Extract content from Claude message
|
|
51
|
+
*/
|
|
52
|
+
private extractContent;
|
|
53
|
+
/**
|
|
54
|
+
* Extract tool information from Claude assistant message
|
|
55
|
+
*/
|
|
56
|
+
private extractToolInfo;
|
|
57
|
+
/**
|
|
58
|
+
* Sync Agent Session Entry to Linear (create AgentActivity)
|
|
59
|
+
*/
|
|
60
|
+
private syncEntryToLinear;
|
|
61
|
+
/**
|
|
62
|
+
* Get session by ID
|
|
63
|
+
*/
|
|
64
|
+
getSession(linearAgentActivitySessionId: string): CyrusAgentSession | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Get session entries by session ID
|
|
67
|
+
*/
|
|
68
|
+
getSessionEntries(linearAgentActivitySessionId: string): CyrusAgentSessionEntry[];
|
|
69
|
+
/**
|
|
70
|
+
* Get all active sessions
|
|
71
|
+
*/
|
|
72
|
+
getActiveSessions(): CyrusAgentSession[];
|
|
73
|
+
/**
|
|
74
|
+
* Add or update ClaudeRunner for a session
|
|
75
|
+
*/
|
|
76
|
+
addClaudeRunner(linearAgentActivitySessionId: string, claudeRunner: ClaudeRunner): void;
|
|
77
|
+
/**
|
|
78
|
+
* Get all ClaudeRunners
|
|
79
|
+
*/
|
|
80
|
+
getAllClaudeRunners(): ClaudeRunner[];
|
|
81
|
+
/**
|
|
82
|
+
* Get all ClaudeRunners for a specific issue
|
|
83
|
+
*/
|
|
84
|
+
getClaudeRunnersForIssue(issueId: string): ClaudeRunner[];
|
|
85
|
+
/**
|
|
86
|
+
* Get sessions by issue ID
|
|
87
|
+
*/
|
|
88
|
+
getSessionsByIssueId(issueId: string): CyrusAgentSession[];
|
|
89
|
+
/**
|
|
90
|
+
* Get active sessions by issue ID
|
|
91
|
+
*/
|
|
92
|
+
getActiveSessionsByIssueId(issueId: string): CyrusAgentSession[];
|
|
93
|
+
/**
|
|
94
|
+
* Get all sessions
|
|
95
|
+
*/
|
|
96
|
+
getAllSessions(): CyrusAgentSession[];
|
|
97
|
+
/**
|
|
98
|
+
* Create a thought activity
|
|
99
|
+
*/
|
|
100
|
+
createThoughtActivity(sessionId: string, body: string): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Create an action activity
|
|
103
|
+
*/
|
|
104
|
+
createActionActivity(sessionId: string, action: string, parameter: string, result?: string): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Create a response activity
|
|
107
|
+
*/
|
|
108
|
+
createResponseActivity(sessionId: string, body: string): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Create an error activity
|
|
111
|
+
*/
|
|
112
|
+
createErrorActivity(sessionId: string, body: string): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Create an elicitation activity
|
|
115
|
+
*/
|
|
116
|
+
createElicitationActivity(sessionId: string, body: string): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Clear completed sessions older than specified time
|
|
119
|
+
*/
|
|
120
|
+
cleanup(olderThanMs?: number): void;
|
|
121
|
+
/**
|
|
122
|
+
* Serialize Agent Session state for persistence
|
|
123
|
+
*/
|
|
124
|
+
serializeState(): {
|
|
125
|
+
sessions: Record<string, SerializedCyrusAgentSession>;
|
|
126
|
+
entries: Record<string, SerializedCyrusAgentSessionEntry[]>;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Restore Agent Session state from serialized data
|
|
130
|
+
*/
|
|
131
|
+
restoreState(serializedSessions: Record<string, SerializedCyrusAgentSession>, serializedEntries: Record<string, SerializedCyrusAgentSessionEntry[]>): void;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=AgentSessionManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentSessionManager.d.ts","sourceRoot":"","sources":["../src/AgentSessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEb,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAGhB,gBAAgB,EAGhB,YAAY,EACb,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,YAAY,EAAE,2BAA2B,EAAE,gCAAgC,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEnK;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,QAAQ,CAA4C;IAC5D,OAAO,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