cyrus-edge-worker 0.2.5 → 0.2.6
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 +42 -5
- package/dist/AgentSessionManager.d.ts.map +1 -1
- package/dist/AgentSessionManager.js +135 -15
- package/dist/AgentSessionManager.js.map +1 -1
- package/dist/AskUserQuestionHandler.d.ts +96 -0
- package/dist/AskUserQuestionHandler.d.ts.map +1 -0
- package/dist/AskUserQuestionHandler.js +203 -0
- package/dist/AskUserQuestionHandler.js.map +1 -0
- package/dist/EdgeWorker.d.ts +72 -11
- package/dist/EdgeWorker.d.ts.map +1 -1
- package/dist/EdgeWorker.js +469 -124
- package/dist/EdgeWorker.js.map +1 -1
- package/dist/GitService.d.ts +34 -0
- package/dist/GitService.d.ts.map +1 -0
- package/dist/GitService.js +347 -0
- package/dist/GitService.js.map +1 -0
- package/dist/SharedApplicationServer.d.ts +2 -1
- package/dist/SharedApplicationServer.d.ts.map +1 -1
- package/dist/SharedApplicationServer.js +5 -3
- package/dist/SharedApplicationServer.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/procedures/{ProcedureRouter.d.ts → ProcedureAnalyzer.d.ts} +11 -11
- package/dist/procedures/ProcedureAnalyzer.d.ts.map +1 -0
- package/dist/procedures/{ProcedureRouter.js → ProcedureAnalyzer.js} +21 -14
- package/dist/procedures/ProcedureAnalyzer.js.map +1 -0
- package/dist/procedures/index.d.ts +2 -2
- package/dist/procedures/index.d.ts.map +1 -1
- package/dist/procedures/index.js +2 -2
- package/dist/procedures/index.js.map +1 -1
- package/dist/procedures/registry.d.ts +20 -1
- package/dist/procedures/registry.d.ts.map +1 -1
- package/dist/procedures/registry.js +26 -1
- package/dist/procedures/registry.js.map +1 -1
- package/dist/procedures/types.d.ts +29 -5
- package/dist/procedures/types.d.ts.map +1 -1
- package/dist/procedures/types.js +1 -1
- package/dist/prompts/subroutines/user-testing-summary.md +87 -0
- package/dist/prompts/subroutines/user-testing.md +48 -0
- package/dist/prompts/subroutines/validation-fixer.md +56 -0
- package/dist/prompts/subroutines/verifications.md +51 -24
- package/dist/validation/ValidationLoopController.d.ts +54 -0
- package/dist/validation/ValidationLoopController.d.ts.map +1 -0
- package/dist/validation/ValidationLoopController.js +242 -0
- package/dist/validation/ValidationLoopController.js.map +1 -0
- package/dist/validation/index.d.ts +7 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +7 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/types.d.ts +90 -0
- package/dist/validation/types.d.ts.map +1 -0
- package/dist/validation/types.js +33 -0
- package/dist/validation/types.js.map +1 -0
- package/package.json +51 -49
- package/prompts/graphite-orchestrator.md +360 -0
- package/LICENSE +0 -674
- package/dist/procedures/ProcedureRouter.d.ts.map +0 -1
- package/dist/procedures/ProcedureRouter.js.map +0 -1
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for AskUserQuestion tool invocations using Linear's select signal.
|
|
3
|
+
*
|
|
4
|
+
* This handler bridges the Claude SDK's AskUserQuestion tool with Linear's
|
|
5
|
+
* agent elicitation API. When Claude uses the AskUserQuestion tool, this handler:
|
|
6
|
+
* 1. Posts an elicitation activity to Linear with the question and options
|
|
7
|
+
* 2. Stores the pending question with a promise resolver
|
|
8
|
+
* 3. Waits for the "prompted" webhook event from Linear
|
|
9
|
+
* 4. Resolves the promise with the user's response
|
|
10
|
+
*
|
|
11
|
+
* The handler follows the same pattern as RepositoryRouter for pending selections,
|
|
12
|
+
* but is specifically designed for user questions during agent execution.
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://linear.app/developers/agent-signals#select}
|
|
15
|
+
*/
|
|
16
|
+
import { AgentActivitySignal } from "cyrus-core";
|
|
17
|
+
/**
|
|
18
|
+
* Handler for presenting AskUserQuestion tool calls to users via Linear's select signal.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* 1. Create handler instance with dependencies
|
|
22
|
+
* 2. Call `handleAskUserQuestion()` when Claude uses the AskUserQuestion tool
|
|
23
|
+
* 3. The handler posts an elicitation to Linear and returns a promise
|
|
24
|
+
* 4. When the "prompted" webhook arrives, call `handleUserResponse()` to resolve the promise
|
|
25
|
+
*/
|
|
26
|
+
export class AskUserQuestionHandler {
|
|
27
|
+
deps;
|
|
28
|
+
/**
|
|
29
|
+
* Map of agent session ID to pending question data.
|
|
30
|
+
* Used to track questions awaiting user response.
|
|
31
|
+
*/
|
|
32
|
+
pendingQuestions = new Map();
|
|
33
|
+
constructor(deps) {
|
|
34
|
+
this.deps = deps;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Handle an AskUserQuestion tool call by presenting it to the user via Linear.
|
|
38
|
+
*
|
|
39
|
+
* This method:
|
|
40
|
+
* 1. Validates the input (only 1 question allowed)
|
|
41
|
+
* 2. Posts an elicitation activity to Linear with the select signal
|
|
42
|
+
* 3. Returns a promise that resolves when the user responds
|
|
43
|
+
*
|
|
44
|
+
* @param input - The AskUserQuestion tool input (must contain exactly 1 question)
|
|
45
|
+
* @param linearAgentSessionId - Linear agent session ID (for tracking and API calls)
|
|
46
|
+
* @param organizationId - Linear organization/workspace ID
|
|
47
|
+
* @param signal - AbortSignal for cancellation
|
|
48
|
+
* @returns Promise resolving to the user's answer or denial
|
|
49
|
+
*/
|
|
50
|
+
async handleAskUserQuestion(input, linearAgentSessionId, organizationId, signal) {
|
|
51
|
+
// Validate: only 1 question at a time
|
|
52
|
+
if (!input.questions || input.questions.length !== 1) {
|
|
53
|
+
console.error(`[AskUserQuestionHandler] Invalid input: expected exactly 1 question, got ${input.questions?.length ?? 0}`);
|
|
54
|
+
return {
|
|
55
|
+
answered: false,
|
|
56
|
+
message: "Only one question at a time is supported. Please ask each question separately.",
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const question = input.questions[0];
|
|
60
|
+
console.log(`[AskUserQuestionHandler] Handling question for session ${linearAgentSessionId}: ${question.header}`);
|
|
61
|
+
// Check if already cancelled
|
|
62
|
+
if (signal.aborted) {
|
|
63
|
+
return {
|
|
64
|
+
answered: false,
|
|
65
|
+
message: "Operation was cancelled",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// Get issue tracker
|
|
69
|
+
const issueTracker = this.deps.getIssueTracker(organizationId);
|
|
70
|
+
if (!issueTracker) {
|
|
71
|
+
console.error(`[AskUserQuestionHandler] No issue tracker found for organization ${organizationId}`);
|
|
72
|
+
return {
|
|
73
|
+
answered: false,
|
|
74
|
+
message: "Issue tracker not available",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Check for existing pending question for this session
|
|
78
|
+
if (this.pendingQuestions.has(linearAgentSessionId)) {
|
|
79
|
+
console.warn(`[AskUserQuestionHandler] Replacing existing pending question for session ${linearAgentSessionId}`);
|
|
80
|
+
this.cancelPendingQuestion(linearAgentSessionId, "Replaced by new question");
|
|
81
|
+
}
|
|
82
|
+
// Create the options for Linear's select signal
|
|
83
|
+
// Include an "Other" option to allow free-form input
|
|
84
|
+
const options = question.options.map((opt) => ({
|
|
85
|
+
value: opt.label,
|
|
86
|
+
}));
|
|
87
|
+
// Add "Other" option for free-form input
|
|
88
|
+
options.push({ value: "Other" });
|
|
89
|
+
// Build the elicitation body
|
|
90
|
+
// Include the question text and option descriptions for context
|
|
91
|
+
const optionsText = question.options
|
|
92
|
+
.map((opt) => `• **${opt.label}**: ${opt.description}`)
|
|
93
|
+
.join("\n");
|
|
94
|
+
const elicitationBody = `${question.question}\n\n${optionsText}`;
|
|
95
|
+
// Post elicitation to Linear
|
|
96
|
+
try {
|
|
97
|
+
await issueTracker.createAgentActivity({
|
|
98
|
+
agentSessionId: linearAgentSessionId,
|
|
99
|
+
content: {
|
|
100
|
+
type: "elicitation",
|
|
101
|
+
body: elicitationBody,
|
|
102
|
+
},
|
|
103
|
+
signal: AgentActivitySignal.Select,
|
|
104
|
+
signalMetadata: { options },
|
|
105
|
+
});
|
|
106
|
+
console.log(`[AskUserQuestionHandler] Posted elicitation with ${options.length} options for session ${linearAgentSessionId}`);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
const errorMessage = error.message || String(error);
|
|
110
|
+
console.error(`[AskUserQuestionHandler] Failed to post elicitation: ${errorMessage}`);
|
|
111
|
+
return {
|
|
112
|
+
answered: false,
|
|
113
|
+
message: `Failed to present question to user: ${errorMessage}`,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// Create promise to wait for user response
|
|
117
|
+
// Cleanup is handled via AbortSignal when the session ends
|
|
118
|
+
return new Promise((resolve) => {
|
|
119
|
+
// Setup abort handler for session cancellation
|
|
120
|
+
const abortHandler = () => {
|
|
121
|
+
console.log(`[AskUserQuestionHandler] Question cancelled for session ${linearAgentSessionId}`);
|
|
122
|
+
this.pendingQuestions.delete(linearAgentSessionId);
|
|
123
|
+
resolve({
|
|
124
|
+
answered: false,
|
|
125
|
+
message: "Operation was cancelled",
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
129
|
+
// Store pending question
|
|
130
|
+
this.pendingQuestions.set(linearAgentSessionId, {
|
|
131
|
+
question,
|
|
132
|
+
resolve: (result) => {
|
|
133
|
+
// Clean up abort handler before resolving
|
|
134
|
+
signal.removeEventListener("abort", abortHandler);
|
|
135
|
+
this.pendingQuestions.delete(linearAgentSessionId);
|
|
136
|
+
resolve(result);
|
|
137
|
+
},
|
|
138
|
+
signal,
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Handle user response from the "prompted" webhook event.
|
|
144
|
+
*
|
|
145
|
+
* This method is called when Linear sends an AgentSessionPrompted webhook
|
|
146
|
+
* in response to a select signal elicitation.
|
|
147
|
+
*
|
|
148
|
+
* @param linearAgentSessionId - Linear agent session ID
|
|
149
|
+
* @param selectedValue - The value selected by the user (option label or free text)
|
|
150
|
+
* @returns true if a pending question was resolved, false if no pending question found
|
|
151
|
+
*/
|
|
152
|
+
handleUserResponse(linearAgentSessionId, selectedValue) {
|
|
153
|
+
const pendingQuestion = this.pendingQuestions.get(linearAgentSessionId);
|
|
154
|
+
if (!pendingQuestion) {
|
|
155
|
+
console.log(`[AskUserQuestionHandler] No pending question found for session ${linearAgentSessionId}`);
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
console.log(`[AskUserQuestionHandler] User responded to question for session ${linearAgentSessionId}: ${selectedValue}`);
|
|
159
|
+
// Build the answers map
|
|
160
|
+
// The key is the question text, the value is the selected option
|
|
161
|
+
const answers = {
|
|
162
|
+
[pendingQuestion.question.question]: selectedValue,
|
|
163
|
+
};
|
|
164
|
+
// Resolve the pending promise
|
|
165
|
+
pendingQuestion.resolve({
|
|
166
|
+
answered: true,
|
|
167
|
+
answers,
|
|
168
|
+
});
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Check if there's a pending question for this agent session.
|
|
173
|
+
*
|
|
174
|
+
* @param linearAgentSessionId - Linear agent session ID
|
|
175
|
+
* @returns true if there's a pending question
|
|
176
|
+
*/
|
|
177
|
+
hasPendingQuestion(linearAgentSessionId) {
|
|
178
|
+
return this.pendingQuestions.has(linearAgentSessionId);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Cancel a pending question.
|
|
182
|
+
*
|
|
183
|
+
* @param linearAgentSessionId - Linear agent session ID
|
|
184
|
+
* @param reason - Reason for cancellation
|
|
185
|
+
*/
|
|
186
|
+
cancelPendingQuestion(linearAgentSessionId, reason) {
|
|
187
|
+
const pendingQuestion = this.pendingQuestions.get(linearAgentSessionId);
|
|
188
|
+
if (pendingQuestion) {
|
|
189
|
+
console.log(`[AskUserQuestionHandler] Cancelling pending question for session ${linearAgentSessionId}: ${reason}`);
|
|
190
|
+
pendingQuestion.resolve({
|
|
191
|
+
answered: false,
|
|
192
|
+
message: reason,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get the number of pending questions (for debugging/monitoring).
|
|
198
|
+
*/
|
|
199
|
+
get pendingCount() {
|
|
200
|
+
return this.pendingQuestions.size;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=AskUserQuestionHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskUserQuestionHandler.js","sourceRoot":"","sources":["../src/AskUserQuestionHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAiCjD;;;;;;;;GAQG;AACH,MAAM,OAAO,sBAAsB;IAC1B,IAAI,CAA6B;IAEzC;;;OAGG;IACK,gBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;IAEnE,YAAY,IAAgC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,qBAAqB,CAC1B,KAA2B,EAC3B,oBAA4B,EAC5B,cAAsB,EACtB,MAAmB;QAEnB,sCAAsC;QACtC,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtD,OAAO,CAAC,KAAK,CACZ,4EAA4E,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC,EAAE,CAC1G,CAAC;YACF,OAAO;gBACN,QAAQ,EAAE,KAAK;gBACf,OAAO,EACN,gFAAgF;aACjF,CAAC;QACH,CAAC;QAED,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CACV,0DAA0D,oBAAoB,KAAK,QAAQ,CAAC,MAAM,EAAE,C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AAoB,KAAK,MAAM,EAAE,CACrG,CAAC;YACF,eAAe,CAAC,OAAO,CAAC;gBACvB,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,MAAM;aACf,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACf,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;IACnC,CAAC;CACD"}
|
package/dist/EdgeWorker.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import {
|
|
3
|
-
import type { CyrusAgentSession, EdgeWorkerConfig, RepositoryConfig, SerializableEdgeWorkerState } from "cyrus-core";
|
|
2
|
+
import type { CyrusAgentSession, EdgeWorkerConfig, Issue, RepositoryConfig, SerializableEdgeWorkerState } from "cyrus-core";
|
|
4
3
|
import { AgentSessionManager } from "./AgentSessionManager.js";
|
|
5
4
|
import { RepositoryRouter } from "./RepositoryRouter.js";
|
|
6
5
|
import type { EdgeWorkerEvents } from "./types.js";
|
|
@@ -20,16 +19,21 @@ export declare class EdgeWorker extends EventEmitter {
|
|
|
20
19
|
private agentSessionManagers;
|
|
21
20
|
private issueTrackers;
|
|
22
21
|
private linearEventTransport;
|
|
22
|
+
private cliRPCServer;
|
|
23
23
|
private configUpdater;
|
|
24
24
|
private persistenceManager;
|
|
25
25
|
private sharedApplicationServer;
|
|
26
26
|
private cyrusHome;
|
|
27
27
|
private childToParentAgentSession;
|
|
28
|
-
private
|
|
28
|
+
private procedureAnalyzer;
|
|
29
29
|
private configWatcher?;
|
|
30
30
|
private configPath?;
|
|
31
31
|
/** @internal - Exposed for testing only */
|
|
32
32
|
repositoryRouter: RepositoryRouter;
|
|
33
|
+
private gitService;
|
|
34
|
+
private activeWebhookCount;
|
|
35
|
+
/** Handler for AskUserQuestion tool invocations via Linear select signal */
|
|
36
|
+
private askUserQuestionHandler;
|
|
33
37
|
constructor(config: EdgeWorkerConfig);
|
|
34
38
|
/**
|
|
35
39
|
* Start the edge worker
|
|
@@ -39,6 +43,16 @@ export declare class EdgeWorker extends EventEmitter {
|
|
|
39
43
|
* Initialize and register components (routes) before server starts
|
|
40
44
|
*/
|
|
41
45
|
private initializeComponents;
|
|
46
|
+
/**
|
|
47
|
+
* Register the /status endpoint for checking if the process is busy or idle
|
|
48
|
+
* This endpoint is used to determine if the process can be safely restarted
|
|
49
|
+
*/
|
|
50
|
+
private registerStatusEndpoint;
|
|
51
|
+
/**
|
|
52
|
+
* Compute the current status of the Cyrus process
|
|
53
|
+
* @returns "idle" if the process can be safely restarted, "busy" if work is in progress
|
|
54
|
+
*/
|
|
55
|
+
private computeStatus;
|
|
42
56
|
/**
|
|
43
57
|
* Stop the edge worker
|
|
44
58
|
*/
|
|
@@ -58,6 +72,14 @@ export declare class EdgeWorker extends EventEmitter {
|
|
|
58
72
|
* This is triggered by the AgentSessionManager's 'subroutineComplete' event
|
|
59
73
|
*/
|
|
60
74
|
private handleSubroutineTransition;
|
|
75
|
+
/**
|
|
76
|
+
* Handle validation loop fixer - run the fixer prompt
|
|
77
|
+
*/
|
|
78
|
+
private handleValidationLoopFixer;
|
|
79
|
+
/**
|
|
80
|
+
* Handle validation loop rerun - re-run the verifications subroutine
|
|
81
|
+
*/
|
|
82
|
+
private handleValidationLoopRerun;
|
|
61
83
|
/**
|
|
62
84
|
* Start watching config file for changes
|
|
63
85
|
*/
|
|
@@ -157,6 +179,13 @@ export declare class EdgeWorker extends EventEmitter {
|
|
|
157
179
|
* In both cases, the selected repository is cached for future use.
|
|
158
180
|
*/
|
|
159
181
|
private handleRepositorySelectionResponse;
|
|
182
|
+
/**
|
|
183
|
+
* Handle AskUserQuestion response from prompted webhook
|
|
184
|
+
* Branch 2.5: User response to a question posed via AskUserQuestion tool
|
|
185
|
+
*
|
|
186
|
+
* @param webhook The prompted webhook containing user's response
|
|
187
|
+
*/
|
|
188
|
+
private handleAskUserQuestionResponse;
|
|
160
189
|
/**
|
|
161
190
|
* Handle normal prompted activity (existing session continuation)
|
|
162
191
|
* Branch 3 of agentSessionPrompted (see packages/CLAUDE.md)
|
|
@@ -238,11 +267,13 @@ export declare class EdgeWorker extends EventEmitter {
|
|
|
238
267
|
*/
|
|
239
268
|
private formatAgentGuidance;
|
|
240
269
|
/**
|
|
241
|
-
*
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
*
|
|
270
|
+
* Determine the base branch for an issue, considering parent issues and blocked-by relationships
|
|
271
|
+
*
|
|
272
|
+
* Priority order:
|
|
273
|
+
* 1. If issue has graphite label AND has a "blocked by" relationship, use the blocking issue's branch
|
|
274
|
+
* (This enables Graphite stacking where each sub-issue branches off the previous)
|
|
275
|
+
* 2. If issue has a parent, use the parent's branch
|
|
276
|
+
* 3. Fall back to repository's default base branch
|
|
246
277
|
*/
|
|
247
278
|
private determineBaseBranch;
|
|
248
279
|
/**
|
|
@@ -250,9 +281,30 @@ export declare class EdgeWorker extends EventEmitter {
|
|
|
250
281
|
*/
|
|
251
282
|
private convertLinearIssueToCore;
|
|
252
283
|
/**
|
|
253
|
-
*
|
|
284
|
+
* Fetch issues that block this issue (i.e., issues this one is "blocked by")
|
|
285
|
+
* Uses the inverseRelations field with type "blocks"
|
|
286
|
+
*
|
|
287
|
+
* Linear relations work like this:
|
|
288
|
+
* - When Issue A "blocks" Issue B, a relation is created with:
|
|
289
|
+
* - issue = A (the blocker)
|
|
290
|
+
* - relatedIssue = B (the blocked one)
|
|
291
|
+
* - type = "blocks"
|
|
292
|
+
*
|
|
293
|
+
* So to find "who blocks Issue B", we need inverseRelations (where B is the relatedIssue)
|
|
294
|
+
* and look for type === "blocks", then get the `issue` field (the blocker).
|
|
295
|
+
*
|
|
296
|
+
* @param issue The issue to fetch blocking issues for
|
|
297
|
+
* @returns Array of issues that block this one, or empty array if none
|
|
298
|
+
*/
|
|
299
|
+
private fetchBlockingIssues;
|
|
300
|
+
/**
|
|
301
|
+
* Check if an issue has the graphite label
|
|
302
|
+
*
|
|
303
|
+
* @param issue The issue to check
|
|
304
|
+
* @param repository The repository configuration
|
|
305
|
+
* @returns True if the issue has the graphite label
|
|
254
306
|
*/
|
|
255
|
-
private
|
|
307
|
+
private hasGraphiteLabel;
|
|
256
308
|
/**
|
|
257
309
|
* Format Linear comments into a threaded structure that mirrors the Linear UI
|
|
258
310
|
* @param comments Array of Linear comments
|
|
@@ -410,6 +462,15 @@ export declare class EdgeWorker extends EventEmitter {
|
|
|
410
462
|
* @returns Object containing the runner config and runner type to use
|
|
411
463
|
*/
|
|
412
464
|
private buildAgentRunnerConfig;
|
|
465
|
+
/**
|
|
466
|
+
* Create an onAskUserQuestion callback for the ClaudeRunner.
|
|
467
|
+
* This callback delegates to the AskUserQuestionHandler which posts
|
|
468
|
+
* elicitations to Linear and waits for user responses.
|
|
469
|
+
*
|
|
470
|
+
* @param linearAgentSessionId - Linear agent session ID for tracking
|
|
471
|
+
* @param organizationId - Linear organization/workspace ID
|
|
472
|
+
*/
|
|
473
|
+
private createAskUserQuestionCallback;
|
|
413
474
|
/**
|
|
414
475
|
* Build disallowed tools list following the same hierarchy as allowed tools
|
|
415
476
|
*/
|
|
@@ -507,6 +568,6 @@ export declare class EdgeWorker extends EventEmitter {
|
|
|
507
568
|
/**
|
|
508
569
|
* Fetch complete issue details from Linear API
|
|
509
570
|
*/
|
|
510
|
-
fetchFullIssueDetails(issueId: string, repositoryId: string): Promise<
|
|
571
|
+
fetchFullIssueDetails(issueId: string, repositoryId: string): Promise<Issue | null>;
|
|
511
572
|
}
|
|
512
573
|
//# sourceMappingURL=EdgeWorker.d.ts.map
|
package/dist/EdgeWorker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EdgeWorker.d.ts","sourceRoot":"","sources":["../src/EdgeWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"EdgeWorker.d.ts","sourceRoot":"","sources":["../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