github-issue-tower-defence-management 2.204.1 → 2.206.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.
- package/README.md +1 -1
- package/bin/adapter/entry-points/cli/index.js +2 -0
- package/bin/adapter/entry-points/cli/index.js.map +1 -1
- package/bin/adapter/entry-points/console/dashboardComposeService.js +41 -1
- package/bin/adapter/entry-points/console/dashboardComposeService.js.map +1 -1
- package/bin/adapter/entry-points/console/webServer.js +54 -2
- package/bin/adapter/entry-points/console/webServer.js.map +1 -1
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js +13 -0
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js.map +1 -1
- package/bin/adapter/entry-points/handlers/codexWorkerCountWriter.js +80 -0
- package/bin/adapter/entry-points/handlers/codexWorkerCountWriter.js.map +1 -0
- package/bin/adapter/repositories/GitHubRepositoryFileReader.js +49 -0
- package/bin/adapter/repositories/GitHubRepositoryFileReader.js.map +1 -0
- package/bin/adapter/repositories/OpenAiLiveSessionRepository.js +34 -95
- package/bin/adapter/repositories/OpenAiLiveSessionRepository.js.map +1 -1
- package/bin/adapter/repositories/OpenAiLiveSessionSideband.js +65 -0
- package/bin/adapter/repositories/OpenAiLiveSessionSideband.js.map +1 -0
- package/bin/adapter/repositories/ProcCodexRunningWorkerRepository.js +105 -0
- package/bin/adapter/repositories/ProcCodexRunningWorkerRepository.js.map +1 -0
- package/bin/adapter/voice-console/voiceConsoleLiveSessionConfig.js +297 -0
- package/bin/adapter/voice-console/voiceConsoleLiveSessionConfig.js.map +1 -0
- package/bin/adapter/voice-console/voiceConsolePaging.js +25 -0
- package/bin/adapter/voice-console/voiceConsolePaging.js.map +1 -0
- package/bin/adapter/voice-console/voiceConsolePendingAction.js +39 -0
- package/bin/adapter/voice-console/voiceConsolePendingAction.js.map +1 -0
- package/bin/adapter/voice-console/voiceConsoleQueue.js +88 -0
- package/bin/adapter/voice-console/voiceConsoleQueue.js.map +1 -0
- package/bin/adapter/voice-console/voiceConsoleSession.js +805 -0
- package/bin/adapter/voice-console/voiceConsoleSession.js.map +1 -0
- package/bin/adapter/voice-console/voiceConsoleSideband.js +150 -0
- package/bin/adapter/voice-console/voiceConsoleSideband.js.map +1 -0
- package/bin/adapter/voice-console/voiceConsoleTaskDocument.js +52 -0
- package/bin/adapter/voice-console/voiceConsoleTaskDocument.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/CodexRunningWorkerRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/CodexRunningWorkerRepository.js.map +1 -0
- package/bin/domain/usecases/dashboard/CodexWorkerCountFile.js +5 -0
- package/bin/domain/usecases/dashboard/CodexWorkerCountFile.js.map +1 -0
- package/bin/domain/usecases/dashboard/ComposeDashboardUseCase.js +84 -46
- package/bin/domain/usecases/dashboard/ComposeDashboardUseCase.js.map +1 -1
- package/bin/domain/usecases/dashboard/GenerateTokenStatusUseCase.js +4 -4
- package/bin/domain/usecases/dashboard/GenerateTokenStatusUseCase.js.map +1 -1
- package/package.json +1 -1
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
- package/types/adapter/entry-points/console/dashboardComposeService.d.ts +1 -0
- package/types/adapter/entry-points/console/dashboardComposeService.d.ts.map +1 -1
- package/types/adapter/entry-points/console/webServer.d.ts +5 -0
- package/types/adapter/entry-points/console/webServer.d.ts.map +1 -1
- package/types/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.d.ts.map +1 -1
- package/types/adapter/entry-points/handlers/codexWorkerCountWriter.d.ts +9 -0
- package/types/adapter/entry-points/handlers/codexWorkerCountWriter.d.ts.map +1 -0
- package/types/adapter/repositories/GitHubRepositoryFileReader.d.ts +7 -0
- package/types/adapter/repositories/GitHubRepositoryFileReader.d.ts.map +1 -0
- package/types/adapter/repositories/OpenAiLiveSessionRepository.d.ts.map +1 -1
- package/types/adapter/repositories/OpenAiLiveSessionSideband.d.ts +20 -0
- package/types/adapter/repositories/OpenAiLiveSessionSideband.d.ts.map +1 -0
- package/types/adapter/repositories/ProcCodexRunningWorkerRepository.d.ts +7 -0
- package/types/adapter/repositories/ProcCodexRunningWorkerRepository.d.ts.map +1 -0
- package/types/adapter/voice-console/voiceConsoleLiveSessionConfig.d.ts +16 -0
- package/types/adapter/voice-console/voiceConsoleLiveSessionConfig.d.ts.map +1 -0
- package/types/adapter/voice-console/voiceConsolePaging.d.ts +13 -0
- package/types/adapter/voice-console/voiceConsolePaging.d.ts.map +1 -0
- package/types/adapter/voice-console/voiceConsolePendingAction.d.ts +24 -0
- package/types/adapter/voice-console/voiceConsolePendingAction.d.ts.map +1 -0
- package/types/adapter/voice-console/voiceConsoleQueue.d.ts +15 -0
- package/types/adapter/voice-console/voiceConsoleQueue.d.ts.map +1 -0
- package/types/adapter/voice-console/voiceConsoleSession.d.ts +66 -0
- package/types/adapter/voice-console/voiceConsoleSession.d.ts.map +1 -0
- package/types/adapter/voice-console/voiceConsoleSideband.d.ts +24 -0
- package/types/adapter/voice-console/voiceConsoleSideband.d.ts.map +1 -0
- package/types/adapter/voice-console/voiceConsoleTaskDocument.d.ts +7 -0
- package/types/adapter/voice-console/voiceConsoleTaskDocument.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/CodexRunningWorkerRepository.d.ts +8 -0
- package/types/domain/usecases/adapter-interfaces/CodexRunningWorkerRepository.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/LiveSessionRepository.d.ts +1 -0
- package/types/domain/usecases/adapter-interfaces/LiveSessionRepository.d.ts.map +1 -1
- package/types/domain/usecases/dashboard/CodexWorkerCountFile.d.ts +7 -0
- package/types/domain/usecases/dashboard/CodexWorkerCountFile.d.ts.map +1 -0
- package/types/domain/usecases/dashboard/ComposeDashboardUseCase.d.ts +12 -4
- package/types/domain/usecases/dashboard/ComposeDashboardUseCase.d.ts.map +1 -1
- package/types/domain/usecases/dashboard/GenerateTokenStatusUseCase.d.ts +1 -0
- package/types/domain/usecases/dashboard/GenerateTokenStatusUseCase.d.ts.map +1 -1
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoiceConsoleSession = void 0;
|
|
4
|
+
const voiceConsolePaging_1 = require("./voiceConsolePaging");
|
|
5
|
+
const voiceConsolePendingAction_1 = require("./voiceConsolePendingAction");
|
|
6
|
+
const voiceConsoleQueue_1 = require("./voiceConsoleQueue");
|
|
7
|
+
const voiceConsoleTaskDocument_1 = require("./voiceConsoleTaskDocument");
|
|
8
|
+
// A rejection is a validation outcome returned to the model; it is not logged.
|
|
9
|
+
class VoiceConsoleRejection extends Error {
|
|
10
|
+
constructor(code) {
|
|
11
|
+
super(code);
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const SNOOZE_ACTIONS = {
|
|
16
|
+
'1h': 'snooze_1hour',
|
|
17
|
+
'3h': 'snooze_3hours',
|
|
18
|
+
'6h': 'snooze_6hours',
|
|
19
|
+
'1d': 'snooze_1day',
|
|
20
|
+
'2d': 'snooze_2days',
|
|
21
|
+
'3d': 'snooze_3days',
|
|
22
|
+
'5d': 'snooze_5days',
|
|
23
|
+
'1w': 'snooze_1week',
|
|
24
|
+
'1month': 'snooze_1month',
|
|
25
|
+
};
|
|
26
|
+
const PULL_REQUEST_REVIEW_ACTIONS = [
|
|
27
|
+
'approve_and_merge',
|
|
28
|
+
'request_changes',
|
|
29
|
+
'unnecessary',
|
|
30
|
+
'totally_wrong',
|
|
31
|
+
];
|
|
32
|
+
const CLOSE_REASONS = ['completed', 'not_planned'];
|
|
33
|
+
const CLOSE_COMMENT_KINDS = ['none', 'ok', 'text'];
|
|
34
|
+
const OK_STATUS_NAME = 'Awaiting Workspace';
|
|
35
|
+
const OK_COMMENT_TEXT = 'ok';
|
|
36
|
+
const UNNECESSARY_COMMENT_TEXT = 'This pull request is unnecessary.';
|
|
37
|
+
const TOTALLY_WRONG_COMMENT_TEXT = 'totally wrong';
|
|
38
|
+
const QUALIFIER_PATTERN = /(^|\s)(user|org|repo):/;
|
|
39
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
40
|
+
const describeError = (error) => error instanceof Error ? error.message : String(error);
|
|
41
|
+
const failure = (error) => ({ ok: false, error });
|
|
42
|
+
// The owner's speech counts as yes only when the whole normalised utterance is はい.
|
|
43
|
+
const ownerSpeechSaysYes = (speech) => (0, voiceConsolePendingAction_1.normalizeSpeech)(speech) === voiceConsolePendingAction_1.OWNER_CONFIRMATION_REPLY;
|
|
44
|
+
const parseToolArguments = (argumentsJson) => {
|
|
45
|
+
if (argumentsJson.trim() === '') {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
let parsed;
|
|
49
|
+
try {
|
|
50
|
+
parsed = JSON.parse(argumentsJson);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new VoiceConsoleRejection('invalid_arguments');
|
|
54
|
+
}
|
|
55
|
+
if (!isRecord(parsed)) {
|
|
56
|
+
throw new VoiceConsoleRejection('invalid_arguments');
|
|
57
|
+
}
|
|
58
|
+
return parsed;
|
|
59
|
+
};
|
|
60
|
+
const readString = (args, key) => {
|
|
61
|
+
const value = args[key];
|
|
62
|
+
if (typeof value !== 'string') {
|
|
63
|
+
throw new VoiceConsoleRejection('invalid_arguments');
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
};
|
|
67
|
+
const readNonEmptyString = (args, key, missingError) => {
|
|
68
|
+
const value = args[key];
|
|
69
|
+
if (value === undefined || value === '') {
|
|
70
|
+
throw new VoiceConsoleRejection(missingError);
|
|
71
|
+
}
|
|
72
|
+
if (typeof value !== 'string') {
|
|
73
|
+
throw new VoiceConsoleRejection('invalid_arguments');
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
};
|
|
77
|
+
const readOptionalString = (args, key) => {
|
|
78
|
+
const value = args[key];
|
|
79
|
+
if (value === undefined) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
if (typeof value !== 'string') {
|
|
83
|
+
throw new VoiceConsoleRejection('invalid_arguments');
|
|
84
|
+
}
|
|
85
|
+
return value;
|
|
86
|
+
};
|
|
87
|
+
const readOptionalPage = (args) => {
|
|
88
|
+
const value = args.page;
|
|
89
|
+
if (value === undefined) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
if (typeof value !== 'number') {
|
|
93
|
+
throw new VoiceConsoleRejection('invalid_arguments');
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
};
|
|
97
|
+
const readRequiredPosition = (args) => {
|
|
98
|
+
const value = args.position;
|
|
99
|
+
if (typeof value !== 'number' || !Number.isInteger(value)) {
|
|
100
|
+
throw new VoiceConsoleRejection('invalid_arguments');
|
|
101
|
+
}
|
|
102
|
+
return value;
|
|
103
|
+
};
|
|
104
|
+
const readEnum = (args, key, allowed) => {
|
|
105
|
+
const value = readString(args, key);
|
|
106
|
+
if (!allowed.includes(value)) {
|
|
107
|
+
throw new VoiceConsoleRejection('invalid_arguments');
|
|
108
|
+
}
|
|
109
|
+
return value;
|
|
110
|
+
};
|
|
111
|
+
const safeDecode = (segment) => {
|
|
112
|
+
try {
|
|
113
|
+
return decodeURIComponent(segment);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const parseGithubUrl = (url) => {
|
|
120
|
+
try {
|
|
121
|
+
const parsed = new URL(url);
|
|
122
|
+
return parsed.hostname === 'github.com' ? parsed : null;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const pathSegments = (parsed) => parsed.pathname.split('/').filter((segment) => segment !== '');
|
|
129
|
+
const parseGithubIssueOrPullUrl = (url) => {
|
|
130
|
+
const parsed = parseGithubUrl(url);
|
|
131
|
+
if (parsed === null) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const segments = pathSegments(parsed);
|
|
135
|
+
if (segments.length !== 4 || !/^\d+$/.test(segments[3])) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
if (segments[2] !== 'issues' && segments[2] !== 'pull') {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
return { owner: segments[0], repo: segments[1], kind: segments[2] };
|
|
142
|
+
};
|
|
143
|
+
const isSafeRepositoryFilePath = (filePath) => filePath
|
|
144
|
+
.split('/')
|
|
145
|
+
.every((segment) => segment !== '' &&
|
|
146
|
+
segment !== '.' &&
|
|
147
|
+
segment !== '..' &&
|
|
148
|
+
!segment.includes('\\'));
|
|
149
|
+
const parseGithubBlobUrl = (url) => {
|
|
150
|
+
const parsed = parseGithubUrl(url);
|
|
151
|
+
if (parsed === null) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
const segments = pathSegments(parsed);
|
|
155
|
+
if (segments.length < 5 || segments[2] !== 'blob') {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
const decodedPath = segments.slice(4).map(safeDecode);
|
|
159
|
+
if (decodedPath.some((segment) => segment === null)) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const filePath = decodedPath.join('/');
|
|
163
|
+
if (!isSafeRepositoryFilePath(filePath)) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
owner: segments[0],
|
|
168
|
+
repo: segments[1],
|
|
169
|
+
ref: segments[3],
|
|
170
|
+
filePath,
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
const queueEntryKey = (entry) => `${entry.pjcode}/${entry.tab}/${entry.item.projectItemId}`;
|
|
174
|
+
const toTaskComment = (comment) => ({
|
|
175
|
+
author: comment.author,
|
|
176
|
+
body: comment.body,
|
|
177
|
+
createdAt: comment.createdAt.toISOString(),
|
|
178
|
+
});
|
|
179
|
+
const renderCommentsSection = (comments) => comments.flatMap((comment) => [
|
|
180
|
+
`### ${comment.author} ${comment.createdAt.toISOString()}`,
|
|
181
|
+
comment.body,
|
|
182
|
+
'',
|
|
183
|
+
]);
|
|
184
|
+
const renderIssueDocument = (headerLines, body, comments) => [
|
|
185
|
+
...headerLines,
|
|
186
|
+
'',
|
|
187
|
+
'## Body',
|
|
188
|
+
body,
|
|
189
|
+
'',
|
|
190
|
+
'## Comments',
|
|
191
|
+
...renderCommentsSection(comments),
|
|
192
|
+
].join('\n');
|
|
193
|
+
const renderPullRequestDocument = (detail, commits, ciStatus) => {
|
|
194
|
+
const fileLines = detail.files.map((file) => `- ${file.filename} (${file.status}, +${file.additions} -${file.deletions})`);
|
|
195
|
+
const commitLines = commits.map((commit) => `- ${commit.sha.slice(0, 7)} ${commit.authoredAt.toISOString()} ${commit.author}: ${commit.message.split('\n')[0]}`);
|
|
196
|
+
const ciLines = ciStatus === null
|
|
197
|
+
? ['CI status: unavailable']
|
|
198
|
+
: [
|
|
199
|
+
`CI status: all jobs passed ${ciStatus.isPassedAllCiJob}, CI state success ${ciStatus.isCiStateSuccess}`,
|
|
200
|
+
`Mergeable: ${ciStatus.mergeable ?? 'unknown'}, conflicted ${ciStatus.isConflicted}, branch out of date ${ciStatus.isBranchOutOfDate}`,
|
|
201
|
+
];
|
|
202
|
+
return [
|
|
203
|
+
`# ${detail.title}`,
|
|
204
|
+
`State: ${detail.state}, merged ${detail.merged}, draft ${detail.isDraft}`,
|
|
205
|
+
`Author: ${detail.author}`,
|
|
206
|
+
`Branch: ${detail.headRefName} into ${detail.baseRefName}`,
|
|
207
|
+
`Changed files: ${detail.changedFiles}, +${detail.additions} -${detail.deletions}`,
|
|
208
|
+
...ciLines,
|
|
209
|
+
'',
|
|
210
|
+
'## Changed files',
|
|
211
|
+
...fileLines,
|
|
212
|
+
'',
|
|
213
|
+
'## Commits',
|
|
214
|
+
...commitLines,
|
|
215
|
+
].join('\n');
|
|
216
|
+
};
|
|
217
|
+
const paginatedResult = (base, text, page) => {
|
|
218
|
+
const paged = (0, voiceConsolePaging_1.paginateText)(text, page);
|
|
219
|
+
if (!paged.ok) {
|
|
220
|
+
return { ok: false, error: paged.error, pageCount: paged.pageCount };
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
ok: true,
|
|
224
|
+
...base,
|
|
225
|
+
page: paged.page,
|
|
226
|
+
pageCount: paged.pageCount,
|
|
227
|
+
text: paged.text,
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
class VoiceConsoleSession {
|
|
231
|
+
constructor(deps) {
|
|
232
|
+
this.deps = deps;
|
|
233
|
+
this.entries = [];
|
|
234
|
+
this.loaded = false;
|
|
235
|
+
this.index = 0;
|
|
236
|
+
this.removedKeys = new Set();
|
|
237
|
+
this.pendingActions = new voiceConsolePendingAction_1.VoiceConsolePendingActionStore();
|
|
238
|
+
this.pendingTargetKey = null;
|
|
239
|
+
this.ownerSpeech = '';
|
|
240
|
+
this.assistantSpeech = '';
|
|
241
|
+
this.pendingTargetTitle = null;
|
|
242
|
+
// 'idle': no prepare yet. 'awaiting': prepared, read-back not yet spoken.
|
|
243
|
+
// 'open': the assistant has spoken the prepared item's title, owner speech counts.
|
|
244
|
+
this.readBackState = 'idle';
|
|
245
|
+
}
|
|
246
|
+
// Fed by the sideband with the assistant's output transcript deltas. The
|
|
247
|
+
// read-back window opens once the accumulated assistant speech since the
|
|
248
|
+
// prepare contains the prepared item's normalised title.
|
|
249
|
+
recordAssistantSpeech(delta) {
|
|
250
|
+
if (this.readBackState !== 'awaiting' || this.pendingTargetTitle === null) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
this.assistantSpeech += delta;
|
|
254
|
+
if ((0, voiceConsolePendingAction_1.normalizeSpeech)(this.assistantSpeech).includes((0, voiceConsolePendingAction_1.normalizeSpeech)(this.pendingTargetTitle))) {
|
|
255
|
+
this.readBackState = 'open';
|
|
256
|
+
this.ownerSpeech = '';
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Fed by the sideband with the owner's input transcript deltas. Ignored
|
|
260
|
+
// until the read-back window is open.
|
|
261
|
+
recordOwnerSpeech(delta) {
|
|
262
|
+
if (this.readBackState !== 'open') {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.ownerSpeech += delta;
|
|
266
|
+
}
|
|
267
|
+
async callTool(name, argumentsJson) {
|
|
268
|
+
let args;
|
|
269
|
+
try {
|
|
270
|
+
args = parseToolArguments(argumentsJson);
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
if (error instanceof VoiceConsoleRejection) {
|
|
274
|
+
return JSON.stringify(failure(error.code));
|
|
275
|
+
}
|
|
276
|
+
throw error;
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
return JSON.stringify(await this.dispatch(name, args));
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
if (error instanceof VoiceConsoleRejection) {
|
|
283
|
+
return JSON.stringify(failure(error.code));
|
|
284
|
+
}
|
|
285
|
+
this.deps.logError(`voice console tool ${name} failed: ${describeError(error)}`);
|
|
286
|
+
return JSON.stringify(failure('tool_failed'));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async dispatch(name, args) {
|
|
290
|
+
switch (name) {
|
|
291
|
+
case 'queue_overview':
|
|
292
|
+
return this.queueOverview();
|
|
293
|
+
case 'current_task_summary':
|
|
294
|
+
return this.currentTaskSummary(args);
|
|
295
|
+
case 'repeat_current_task':
|
|
296
|
+
return this.currentTaskSummary(args);
|
|
297
|
+
case 'current_task_detail':
|
|
298
|
+
return this.currentTaskDetail(args);
|
|
299
|
+
case 'read_github_url':
|
|
300
|
+
return this.readGithubUrl(args);
|
|
301
|
+
case 'read_pull_request':
|
|
302
|
+
return this.readPullRequest(args);
|
|
303
|
+
case 'read_repository_file':
|
|
304
|
+
return this.readRepositoryFileTool(args);
|
|
305
|
+
case 'search_issues':
|
|
306
|
+
return this.searchIssuesTool(args);
|
|
307
|
+
case 'next_task':
|
|
308
|
+
return this.moveToNextTask();
|
|
309
|
+
case 'previous_task':
|
|
310
|
+
return this.moveToPreviousTask();
|
|
311
|
+
case 'jump_to_task':
|
|
312
|
+
return this.jumpToTask(args);
|
|
313
|
+
case 'prepare_ok':
|
|
314
|
+
return this.prepareOk();
|
|
315
|
+
case 'prepare_comment_and_move_to_awaiting_workspace':
|
|
316
|
+
return this.prepareCommentAndMoveToAwaitingWorkspace(args);
|
|
317
|
+
case 'prepare_comment_only':
|
|
318
|
+
return this.prepareCommentOnly(args);
|
|
319
|
+
case 'prepare_close':
|
|
320
|
+
return this.prepareClose(args);
|
|
321
|
+
case 'prepare_snooze':
|
|
322
|
+
return this.prepareSnooze(args);
|
|
323
|
+
case 'prepare_set_status':
|
|
324
|
+
return this.prepareSetStatus(args);
|
|
325
|
+
case 'prepare_move_to_in_tmux_by_human':
|
|
326
|
+
return this.prepareMoveToInTmuxByHuman();
|
|
327
|
+
case 'prepare_pull_request_review':
|
|
328
|
+
return this.preparePullRequestReview(args);
|
|
329
|
+
case 'confirm_pending_action':
|
|
330
|
+
return this.confirmPendingAction(args);
|
|
331
|
+
case 'cancel_pending_action':
|
|
332
|
+
return this.cancelPendingAction();
|
|
333
|
+
default:
|
|
334
|
+
return failure('unknown_tool');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
// Queue snapshot
|
|
338
|
+
ensureQueueLoaded() {
|
|
339
|
+
if (!this.loaded) {
|
|
340
|
+
this.reloadQueue();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
reloadQueue() {
|
|
344
|
+
const dataDir = this.deps.consoleDataOutputDir;
|
|
345
|
+
const built = dataDir === null
|
|
346
|
+
? []
|
|
347
|
+
: (0, voiceConsoleQueue_1.buildVoiceConsoleQueue)({
|
|
348
|
+
consoleDataOutputDir: dataDir,
|
|
349
|
+
projectPjcodes: this.deps.projectPjcodes,
|
|
350
|
+
});
|
|
351
|
+
this.applyEntries(built.filter((entry) => !this.removedKeys.has(queueEntryKey(entry))));
|
|
352
|
+
}
|
|
353
|
+
// Keeps the current item when it is still present, otherwise clamps the position.
|
|
354
|
+
applyEntries(visible) {
|
|
355
|
+
const currentKey = this.index < this.entries.length
|
|
356
|
+
? queueEntryKey(this.entries[this.index])
|
|
357
|
+
: null;
|
|
358
|
+
const keptIndex = currentKey === null
|
|
359
|
+
? -1
|
|
360
|
+
: visible.findIndex((entry) => queueEntryKey(entry) === currentKey);
|
|
361
|
+
this.entries = visible;
|
|
362
|
+
this.index =
|
|
363
|
+
keptIndex !== -1
|
|
364
|
+
? keptIndex
|
|
365
|
+
: Math.max(0, Math.min(this.index, visible.length - 1));
|
|
366
|
+
this.loaded = true;
|
|
367
|
+
}
|
|
368
|
+
removeQueueEntry(key) {
|
|
369
|
+
this.removedKeys.add(key);
|
|
370
|
+
this.applyEntries(this.entries.filter((entry) => queueEntryKey(entry) !== key));
|
|
371
|
+
}
|
|
372
|
+
currentEntry() {
|
|
373
|
+
this.ensureQueueLoaded();
|
|
374
|
+
return this.index < this.entries.length ? this.entries[this.index] : null;
|
|
375
|
+
}
|
|
376
|
+
requireCurrentEntry() {
|
|
377
|
+
const entry = this.currentEntry();
|
|
378
|
+
if (entry === null) {
|
|
379
|
+
throw new VoiceConsoleRejection('no_current_task');
|
|
380
|
+
}
|
|
381
|
+
return entry;
|
|
382
|
+
}
|
|
383
|
+
describeEntry(entry) {
|
|
384
|
+
return {
|
|
385
|
+
position: this.index + 1,
|
|
386
|
+
totalCount: this.entries.length,
|
|
387
|
+
pjcode: entry.pjcode,
|
|
388
|
+
tab: entry.tab,
|
|
389
|
+
number: entry.item.number,
|
|
390
|
+
title: entry.item.title,
|
|
391
|
+
url: entry.item.url,
|
|
392
|
+
isPr: entry.item.isPr,
|
|
393
|
+
status: entry.item.status,
|
|
394
|
+
story: entry.item.story,
|
|
395
|
+
labels: entry.item.labels,
|
|
396
|
+
dependedIssueUrls: entry.item.dependedIssueUrls,
|
|
397
|
+
relatedOpenPullRequestUrls: entry.item.relatedOpenPullRequestUrls,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
queueOverview() {
|
|
401
|
+
this.reloadQueue();
|
|
402
|
+
const entry = this.currentEntry();
|
|
403
|
+
const countTab = (entries, tab) => entries.filter((entry) => entry.tab === tab).length;
|
|
404
|
+
const projects = this.deps.projectPjcodes.map((pjcode) => {
|
|
405
|
+
const projectEntries = this.entries.filter((entry) => entry.pjcode === pjcode);
|
|
406
|
+
return {
|
|
407
|
+
pjcode,
|
|
408
|
+
todoByHumanCount: countTab(projectEntries, 'todo-by-human'),
|
|
409
|
+
prsCount: countTab(projectEntries, 'prs'),
|
|
410
|
+
};
|
|
411
|
+
});
|
|
412
|
+
return {
|
|
413
|
+
ok: true,
|
|
414
|
+
totalCount: this.entries.length,
|
|
415
|
+
todoByHumanCount: countTab(this.entries, 'todo-by-human'),
|
|
416
|
+
prsCount: countTab(this.entries, 'prs'),
|
|
417
|
+
projects,
|
|
418
|
+
current: entry === null ? null : this.describeEntry(entry),
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
moveToNextTask() {
|
|
422
|
+
this.ensureQueueLoaded();
|
|
423
|
+
if (this.entries.length === 0) {
|
|
424
|
+
return failure('queue_empty');
|
|
425
|
+
}
|
|
426
|
+
if (this.index + 1 >= this.entries.length) {
|
|
427
|
+
return failure('end_of_queue');
|
|
428
|
+
}
|
|
429
|
+
this.index += 1;
|
|
430
|
+
return { ok: true, ...this.describeEntry(this.entries[this.index]) };
|
|
431
|
+
}
|
|
432
|
+
moveToPreviousTask() {
|
|
433
|
+
this.ensureQueueLoaded();
|
|
434
|
+
if (this.entries.length === 0) {
|
|
435
|
+
return failure('queue_empty');
|
|
436
|
+
}
|
|
437
|
+
if (this.index === 0) {
|
|
438
|
+
return failure('start_of_queue');
|
|
439
|
+
}
|
|
440
|
+
this.index -= 1;
|
|
441
|
+
return { ok: true, ...this.describeEntry(this.entries[this.index]) };
|
|
442
|
+
}
|
|
443
|
+
jumpToTask(args) {
|
|
444
|
+
const position = readRequiredPosition(args);
|
|
445
|
+
this.ensureQueueLoaded();
|
|
446
|
+
if (position < 1 || position > this.entries.length) {
|
|
447
|
+
return failure('position_out_of_range');
|
|
448
|
+
}
|
|
449
|
+
this.index = position - 1;
|
|
450
|
+
return { ok: true, ...this.describeEntry(this.entries[this.index]) };
|
|
451
|
+
}
|
|
452
|
+
// Reading tools
|
|
453
|
+
async currentTaskSummary(args) {
|
|
454
|
+
const entry = this.currentEntry();
|
|
455
|
+
if (entry === null) {
|
|
456
|
+
return failure('no_current_task');
|
|
457
|
+
}
|
|
458
|
+
const page = readOptionalPage(args);
|
|
459
|
+
const repository = this.deps.resolveIssueRepository(entry.item.url);
|
|
460
|
+
const comments = await repository.getIssueOrPullRequestComments(entry.item.url);
|
|
461
|
+
const summary = (0, voiceConsoleTaskDocument_1.extractLatestReportSummary)(comments.map(toTaskComment));
|
|
462
|
+
return paginatedResult({ reportFound: summary !== null }, summary ?? '', page);
|
|
463
|
+
}
|
|
464
|
+
async currentTaskDetail(args) {
|
|
465
|
+
const entry = this.currentEntry();
|
|
466
|
+
if (entry === null) {
|
|
467
|
+
return failure('no_current_task');
|
|
468
|
+
}
|
|
469
|
+
const page = readOptionalPage(args);
|
|
470
|
+
const repository = this.deps.resolveIssueRepository(entry.item.url);
|
|
471
|
+
const body = await repository.getIssueOrPullRequestBody(entry.item.url);
|
|
472
|
+
const comments = await repository.getIssueOrPullRequestComments(entry.item.url);
|
|
473
|
+
const text = renderIssueDocument([
|
|
474
|
+
`# ${entry.item.title}`,
|
|
475
|
+
`URL: ${entry.item.url}`,
|
|
476
|
+
`Status: ${entry.item.status ?? 'none'}`,
|
|
477
|
+
`Story: ${entry.item.story}`,
|
|
478
|
+
`Labels: ${entry.item.labels.join(', ')}`,
|
|
479
|
+
`Depends on: ${entry.item.dependedIssueUrls.join(', ')}`,
|
|
480
|
+
`Created: ${entry.item.createdAt}`,
|
|
481
|
+
], body, comments);
|
|
482
|
+
return paginatedResult({}, text, page);
|
|
483
|
+
}
|
|
484
|
+
async readGithubUrl(args) {
|
|
485
|
+
const url = readString(args, 'url');
|
|
486
|
+
const reference = parseGithubIssueOrPullUrl(url);
|
|
487
|
+
if (reference === null) {
|
|
488
|
+
return failure('invalid_url');
|
|
489
|
+
}
|
|
490
|
+
const page = readOptionalPage(args);
|
|
491
|
+
const repository = this.deps.resolveIssueRepository(url);
|
|
492
|
+
const body = await repository.getIssueOrPullRequestBody(url);
|
|
493
|
+
const comments = await repository.getIssueOrPullRequestComments(url);
|
|
494
|
+
const text = renderIssueDocument([`URL: ${url}`], body, comments);
|
|
495
|
+
return paginatedResult({}, text, page);
|
|
496
|
+
}
|
|
497
|
+
async readPullRequest(args) {
|
|
498
|
+
const explicitUrl = readOptionalString(args, 'url');
|
|
499
|
+
const url = explicitUrl ?? this.currentPullRequestUrl();
|
|
500
|
+
if (url === null) {
|
|
501
|
+
return failure('pull_request_url_required');
|
|
502
|
+
}
|
|
503
|
+
const reference = parseGithubIssueOrPullUrl(url);
|
|
504
|
+
if (reference === null || reference.kind !== 'pull') {
|
|
505
|
+
return failure('invalid_url');
|
|
506
|
+
}
|
|
507
|
+
const page = readOptionalPage(args);
|
|
508
|
+
const repository = this.deps.resolveIssueRepository(url);
|
|
509
|
+
const detail = await repository.getPullRequestDetail(url);
|
|
510
|
+
if (detail === null) {
|
|
511
|
+
return failure('pull_request_not_found');
|
|
512
|
+
}
|
|
513
|
+
const commits = await repository.getPullRequestCommits(url);
|
|
514
|
+
const ciStatus = await repository.getOpenPullRequestCiStatus(url);
|
|
515
|
+
return paginatedResult({}, renderPullRequestDocument(detail, commits, ciStatus), page);
|
|
516
|
+
}
|
|
517
|
+
currentPullRequestUrl() {
|
|
518
|
+
const entry = this.currentEntry();
|
|
519
|
+
if (entry === null) {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
return entry.item.isPr
|
|
523
|
+
? entry.item.url
|
|
524
|
+
: (entry.item.relatedOpenPullRequestUrls[0] ?? null);
|
|
525
|
+
}
|
|
526
|
+
async readRepositoryFileTool(args) {
|
|
527
|
+
const url = readString(args, 'url');
|
|
528
|
+
const reference = parseGithubBlobUrl(url);
|
|
529
|
+
if (reference === null) {
|
|
530
|
+
return failure('invalid_url');
|
|
531
|
+
}
|
|
532
|
+
const page = readOptionalPage(args);
|
|
533
|
+
const text = await this.deps.readRepositoryFile(reference.owner, reference.repo, reference.ref, reference.filePath);
|
|
534
|
+
return paginatedResult({}, text, page);
|
|
535
|
+
}
|
|
536
|
+
async searchIssuesTool(args) {
|
|
537
|
+
const query = readString(args, 'query');
|
|
538
|
+
const page = readOptionalPage(args);
|
|
539
|
+
const scopedQuery = QUALIFIER_PATTERN.test(query)
|
|
540
|
+
? query
|
|
541
|
+
: `user:${await this.deps.getAuthenticatedUserLogin()} ${query}`;
|
|
542
|
+
const results = await this.deps.searchIssues(scopedQuery);
|
|
543
|
+
return paginatedResult({}, JSON.stringify(results), page);
|
|
544
|
+
}
|
|
545
|
+
// Write tools: prepare, then confirm_pending_action
|
|
546
|
+
stageAction(entry, draft) {
|
|
547
|
+
const actionId = this.deps.newActionId();
|
|
548
|
+
const action = {
|
|
549
|
+
actionId,
|
|
550
|
+
requestPath: draft.requestPath,
|
|
551
|
+
body: { ...draft.body, actionId },
|
|
552
|
+
readBack: draft.readBack,
|
|
553
|
+
removesFromQueue: draft.removesFromQueue,
|
|
554
|
+
};
|
|
555
|
+
this.pendingActions.prepare(action);
|
|
556
|
+
this.pendingTargetKey = queueEntryKey(entry);
|
|
557
|
+
this.pendingTargetTitle = entry.item.title;
|
|
558
|
+
this.ownerSpeech = '';
|
|
559
|
+
this.assistantSpeech = '';
|
|
560
|
+
this.readBackState = 'awaiting';
|
|
561
|
+
return {
|
|
562
|
+
ok: true,
|
|
563
|
+
actionId,
|
|
564
|
+
readBack: draft.readBack,
|
|
565
|
+
target: {
|
|
566
|
+
pjcode: entry.pjcode,
|
|
567
|
+
url: entry.item.url,
|
|
568
|
+
title: entry.item.title,
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
triageBody(entry) {
|
|
573
|
+
return {
|
|
574
|
+
pjcode: entry.pjcode,
|
|
575
|
+
issueUrl: entry.item.url,
|
|
576
|
+
projectItemId: entry.item.projectItemId,
|
|
577
|
+
expectedStatusName: entry.item.status,
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
requireStatusOption(entry, statusName) {
|
|
581
|
+
const found = entry.statusOptions.some((option) => option.name === statusName);
|
|
582
|
+
if (!found) {
|
|
583
|
+
throw new VoiceConsoleRejection('unknown_status');
|
|
584
|
+
}
|
|
585
|
+
return statusName;
|
|
586
|
+
}
|
|
587
|
+
prepareOk() {
|
|
588
|
+
const entry = this.requireCurrentEntry();
|
|
589
|
+
const statusName = this.requireStatusOption(entry, OK_STATUS_NAME);
|
|
590
|
+
return this.stageAction(entry, {
|
|
591
|
+
requestPath: '/api/triage',
|
|
592
|
+
body: {
|
|
593
|
+
...this.triageBody(entry),
|
|
594
|
+
action: 'set_status',
|
|
595
|
+
statusName,
|
|
596
|
+
commentBody: OK_COMMENT_TEXT,
|
|
597
|
+
setStatusWhenCommentFails: true,
|
|
598
|
+
},
|
|
599
|
+
readBack: `「${entry.item.title}」に ok のコメントを付け、${statusName} に移します。`,
|
|
600
|
+
removesFromQueue: true,
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
prepareCommentAndMoveToAwaitingWorkspace(args) {
|
|
604
|
+
const commentText = readNonEmptyString(args, 'comment_text', 'comment_text_required');
|
|
605
|
+
const entry = this.requireCurrentEntry();
|
|
606
|
+
const statusName = this.requireStatusOption(entry, OK_STATUS_NAME);
|
|
607
|
+
return this.stageAction(entry, {
|
|
608
|
+
requestPath: '/api/triage',
|
|
609
|
+
body: {
|
|
610
|
+
...this.triageBody(entry),
|
|
611
|
+
action: 'set_status',
|
|
612
|
+
statusName,
|
|
613
|
+
commentBody: commentText,
|
|
614
|
+
},
|
|
615
|
+
readBack: `「${entry.item.title}」にコメント「${commentText}」を付け、${statusName} に移します。`,
|
|
616
|
+
removesFromQueue: true,
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
prepareCommentOnly(args) {
|
|
620
|
+
const commentText = readNonEmptyString(args, 'comment_text', 'comment_text_required');
|
|
621
|
+
const entry = this.requireCurrentEntry();
|
|
622
|
+
return this.stageAction(entry, {
|
|
623
|
+
requestPath: '/api/comment',
|
|
624
|
+
body: {
|
|
625
|
+
pjcode: entry.pjcode,
|
|
626
|
+
url: entry.item.url,
|
|
627
|
+
body: commentText,
|
|
628
|
+
},
|
|
629
|
+
readBack: `「${entry.item.title}」にコメント「${commentText}」を付けます。ステータスは変えません。`,
|
|
630
|
+
removesFromQueue: false,
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
prepareClose(args) {
|
|
634
|
+
const reason = readEnum(args, 'reason', CLOSE_REASONS);
|
|
635
|
+
const commentKind = readEnum(args, 'comment_kind', CLOSE_COMMENT_KINDS);
|
|
636
|
+
const commentText = commentKind === 'text'
|
|
637
|
+
? readNonEmptyString(args, 'comment_text', 'comment_text_required')
|
|
638
|
+
: null;
|
|
639
|
+
const entry = this.requireCurrentEntry();
|
|
640
|
+
const commentBody = commentKind === 'ok'
|
|
641
|
+
? OK_COMMENT_TEXT
|
|
642
|
+
: commentKind === 'text'
|
|
643
|
+
? commentText
|
|
644
|
+
: null;
|
|
645
|
+
const closeAction = reason === 'completed' ? 'close' : 'close_not_planned';
|
|
646
|
+
const reasonJapanese = reason === 'completed' ? '完了' : '完了せず';
|
|
647
|
+
const commentPart = commentBody === null ? '' : `、コメント「${commentBody}」を付けて`;
|
|
648
|
+
return this.stageAction(entry, {
|
|
649
|
+
requestPath: '/api/triage',
|
|
650
|
+
body: {
|
|
651
|
+
pjcode: entry.pjcode,
|
|
652
|
+
action: closeAction,
|
|
653
|
+
issueUrl: entry.item.url,
|
|
654
|
+
projectItemId: entry.item.projectItemId,
|
|
655
|
+
...(commentBody === null ? {} : { commentBody }),
|
|
656
|
+
},
|
|
657
|
+
readBack: `「${entry.item.title}」${commentPart}${reasonJapanese} として閉じます。`,
|
|
658
|
+
removesFromQueue: true,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
prepareSnooze(args) {
|
|
662
|
+
const preset = readString(args, 'preset');
|
|
663
|
+
const action = SNOOZE_ACTIONS[preset];
|
|
664
|
+
if (action === undefined) {
|
|
665
|
+
throw new VoiceConsoleRejection('invalid_preset');
|
|
666
|
+
}
|
|
667
|
+
const entry = this.requireCurrentEntry();
|
|
668
|
+
return this.stageAction(entry, {
|
|
669
|
+
requestPath: '/api/triage',
|
|
670
|
+
body: {
|
|
671
|
+
pjcode: entry.pjcode,
|
|
672
|
+
action,
|
|
673
|
+
issueUrl: entry.item.url,
|
|
674
|
+
projectItemId: entry.item.projectItemId,
|
|
675
|
+
},
|
|
676
|
+
readBack: `「${entry.item.title}」を ${preset} スヌーズします。`,
|
|
677
|
+
removesFromQueue: true,
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
prepareSetStatus(args) {
|
|
681
|
+
const requestedStatus = readString(args, 'status_name');
|
|
682
|
+
const entry = this.requireCurrentEntry();
|
|
683
|
+
const statusName = this.requireStatusOption(entry, requestedStatus);
|
|
684
|
+
return this.stageAction(entry, {
|
|
685
|
+
requestPath: '/api/triage',
|
|
686
|
+
body: {
|
|
687
|
+
...this.triageBody(entry),
|
|
688
|
+
action: 'set_status',
|
|
689
|
+
statusName,
|
|
690
|
+
},
|
|
691
|
+
readBack: `「${entry.item.title}」を ${statusName} に移します。`,
|
|
692
|
+
removesFromQueue: true,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
prepareMoveToInTmuxByHuman() {
|
|
696
|
+
const entry = this.requireCurrentEntry();
|
|
697
|
+
return this.stageAction(entry, {
|
|
698
|
+
requestPath: '/api/intmux',
|
|
699
|
+
body: { ...this.triageBody(entry), action: 'set_intmux' },
|
|
700
|
+
readBack: `「${entry.item.title}」を In tmux by human に移します。`,
|
|
701
|
+
removesFromQueue: true,
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
preparePullRequestReview(args) {
|
|
705
|
+
const action = readEnum(args, 'action', PULL_REQUEST_REVIEW_ACTIONS);
|
|
706
|
+
const entry = this.requireCurrentEntry();
|
|
707
|
+
const prUrl = this.currentPullRequestUrl();
|
|
708
|
+
if (prUrl === null) {
|
|
709
|
+
throw new VoiceConsoleRejection('pull_request_url_required');
|
|
710
|
+
}
|
|
711
|
+
const baseBody = {
|
|
712
|
+
pjcode: entry.pjcode,
|
|
713
|
+
prUrl,
|
|
714
|
+
projectItemId: entry.item.projectItemId,
|
|
715
|
+
expectedStatusName: entry.item.status,
|
|
716
|
+
};
|
|
717
|
+
if (action === 'approve_and_merge') {
|
|
718
|
+
return this.stageAction(entry, {
|
|
719
|
+
requestPath: '/api/review',
|
|
720
|
+
body: { ...baseBody, action },
|
|
721
|
+
readBack: `「${entry.item.title}」のプルリクエスト ${prUrl} を承認してマージします。`,
|
|
722
|
+
removesFromQueue: true,
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
if (action === 'request_changes') {
|
|
726
|
+
const commentText = readNonEmptyString(args, 'comment_text', 'comment_text_required');
|
|
727
|
+
return this.stageAction(entry, {
|
|
728
|
+
requestPath: '/api/review',
|
|
729
|
+
body: { ...baseBody, action, commentBody: commentText },
|
|
730
|
+
readBack: `「${entry.item.title}」のプルリクエスト ${prUrl} に変更依頼「${commentText}」を出します。`,
|
|
731
|
+
removesFromQueue: false,
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
if (action === 'unnecessary') {
|
|
735
|
+
return this.stageAction(entry, {
|
|
736
|
+
requestPath: '/api/review',
|
|
737
|
+
body: {
|
|
738
|
+
...baseBody,
|
|
739
|
+
action,
|
|
740
|
+
issueUrl: entry.item.url,
|
|
741
|
+
commentBody: UNNECESSARY_COMMENT_TEXT,
|
|
742
|
+
issueCommentBody: `The pull request for this issue was unnecessary and has been closed: ${prUrl}\n\nDo not create it again.`,
|
|
743
|
+
},
|
|
744
|
+
readBack: `「${entry.item.title}」のプルリクエスト ${prUrl} は不要だったとして閉じます。`,
|
|
745
|
+
removesFromQueue: true,
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
return this.stageAction(entry, {
|
|
749
|
+
requestPath: '/api/review',
|
|
750
|
+
body: {
|
|
751
|
+
...baseBody,
|
|
752
|
+
action: 'close',
|
|
753
|
+
issueUrl: entry.item.url,
|
|
754
|
+
commentBody: TOTALLY_WRONG_COMMENT_TEXT,
|
|
755
|
+
},
|
|
756
|
+
readBack: `「${entry.item.title}」のプルリクエスト ${prUrl} を内容が違うとして閉じます。`,
|
|
757
|
+
removesFromQueue: true,
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
async confirmPendingAction(args) {
|
|
761
|
+
const actionId = readString(args, 'action_id');
|
|
762
|
+
const ownerReply = (0, voiceConsolePendingAction_1.normalizeSpeech)(readString(args, 'owner_reply'));
|
|
763
|
+
const confirmed = this.pendingActions.confirm(actionId, ownerReply);
|
|
764
|
+
if (!confirmed.ok) {
|
|
765
|
+
return failure(confirmed.error);
|
|
766
|
+
}
|
|
767
|
+
if (this.readBackState !== 'open' ||
|
|
768
|
+
!ownerSpeechSaysYes(this.ownerSpeech)) {
|
|
769
|
+
// Keep the pending action so that a later spoken はい can confirm it.
|
|
770
|
+
// The speech heard so far is consumed, so the next はい is judged alone.
|
|
771
|
+
this.ownerSpeech = '';
|
|
772
|
+
this.pendingActions.prepare(confirmed.action);
|
|
773
|
+
return failure('owner_speech_not_heard');
|
|
774
|
+
}
|
|
775
|
+
const targetKey = this.pendingTargetKey;
|
|
776
|
+
this.pendingTargetKey = null;
|
|
777
|
+
const action = confirmed.action;
|
|
778
|
+
let response;
|
|
779
|
+
try {
|
|
780
|
+
response = await this.deps.runOperation(action.requestPath, action.body);
|
|
781
|
+
}
|
|
782
|
+
catch (error) {
|
|
783
|
+
this.deps.logError(`voice console operation ${action.requestPath} failed: ${describeError(error)}`);
|
|
784
|
+
return failure('tool_failed');
|
|
785
|
+
}
|
|
786
|
+
if (response.statusCode >= 400 || operationBodyFailed(response.body)) {
|
|
787
|
+
return failure(operationErrorText(response.body));
|
|
788
|
+
}
|
|
789
|
+
if (action.removesFromQueue && targetKey !== null) {
|
|
790
|
+
this.removeQueueEntry(targetKey);
|
|
791
|
+
}
|
|
792
|
+
return { ok: true, readBack: action.readBack };
|
|
793
|
+
}
|
|
794
|
+
cancelPendingAction() {
|
|
795
|
+
this.pendingActions.cancel();
|
|
796
|
+
this.pendingTargetKey = null;
|
|
797
|
+
return { ok: true };
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
exports.VoiceConsoleSession = VoiceConsoleSession;
|
|
801
|
+
const operationBodyFailed = (body) => isRecord(body) && body.ok === false;
|
|
802
|
+
const operationErrorText = (body) => isRecord(body) && typeof body.error === 'string'
|
|
803
|
+
? body.error
|
|
804
|
+
: 'operation_failed';
|
|
805
|
+
//# sourceMappingURL=voiceConsoleSession.js.map
|