github-issue-tower-defence-management 2.204.1 → 2.205.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/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/webServer.js +54 -2
- package/bin/adapter/entry-points/console/webServer.js.map +1 -1
- 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/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/package.json +1 -1
- package/types/adapter/entry-points/cli/index.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/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/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/LiveSessionRepository.d.ts +1 -0
- package/types/domain/usecases/adapter-interfaces/LiveSessionRepository.d.ts.map +1 -1
|
@@ -1,100 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpenAiLiveSessionRepository = void 0;
|
|
4
|
+
const voiceConsoleLiveSessionConfig_1 = require("../voice-console/voiceConsoleLiveSessionConfig");
|
|
4
5
|
const OPENAI_LIVE_SESSIONS_URL = 'https://api.openai.com/v1/live/sessions';
|
|
5
|
-
const LIVE_SESSION_INSTRUCTIONS = 'あなたはオーナーの音声アシスタントです。オーナーは複数の作業セッションからの呼び出しに、順番に声で答えています。アプリが呼び出しの本文を読み上げた後、あなたはオーナーと日本語で短く会話し、そのセッションに送る返事を決める手助けをします。オーナーが送る文を述べたら、その文を一字一句そのまま復唱し、オーナーが「送って」と言ったら、その文をそのまま session_reply_send で送ります。送る文を自分で作ったり言い換えたりしてはいけません。オーナーが「次」と言ったら session_skip を、「もう一度」と言ったら owner_call_repeat を呼びます。オーナーがセッション、そのセッションが動いている PC、その画面、タスク Issue、またはファイルについて尋ねたら、calling_sessions_list、session_screen_read、session_task_issue_read、session_file_read のいずれかを呼び、結果を日本語で短く答えます。これらの道具は読むだけで、PC に書き込んだり操作したりはできません。';
|
|
6
|
-
const SESSION_NAME_PROPERTY = {
|
|
7
|
-
type: 'string',
|
|
8
|
-
description: 'Tmux session name of the session. Omit it to use the session the owner is currently handling.',
|
|
9
|
-
};
|
|
10
|
-
const NO_PARAMETERS_SCHEMA = {
|
|
11
|
-
type: 'object',
|
|
12
|
-
properties: {},
|
|
13
|
-
additionalProperties: false,
|
|
14
|
-
};
|
|
15
|
-
const LIVE_SESSION_TOOLS = [
|
|
16
|
-
{
|
|
17
|
-
type: 'function',
|
|
18
|
-
name: 'session_reply_send',
|
|
19
|
-
parameters: {
|
|
20
|
-
type: 'object',
|
|
21
|
-
properties: { replyText: { type: 'string' } },
|
|
22
|
-
required: ['replyText'],
|
|
23
|
-
additionalProperties: false,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: 'function',
|
|
28
|
-
name: 'session_skip',
|
|
29
|
-
parameters: NO_PARAMETERS_SCHEMA,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: 'function',
|
|
33
|
-
name: 'owner_call_repeat',
|
|
34
|
-
parameters: NO_PARAMETERS_SCHEMA,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: 'function',
|
|
38
|
-
name: 'calling_sessions_list',
|
|
39
|
-
description: 'List the sessions that have an unanswered owner call, with the machine each runs on, the call time and the task issue URL when it can be derived.',
|
|
40
|
-
parameters: NO_PARAMETERS_SCHEMA,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: 'function',
|
|
44
|
-
name: 'session_screen_read',
|
|
45
|
-
description: 'Read the most recent lines of the terminal screen of a session. lineCount defaults to 80 and is at most 300.',
|
|
46
|
-
parameters: {
|
|
47
|
-
type: 'object',
|
|
48
|
-
properties: {
|
|
49
|
-
sessionName: SESSION_NAME_PROPERTY,
|
|
50
|
-
lineCount: {
|
|
51
|
-
type: 'integer',
|
|
52
|
-
minimum: 1,
|
|
53
|
-
maximum: 300,
|
|
54
|
-
description: 'Number of recent screen lines to read. Defaults to 80.',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
additionalProperties: false,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
type: 'function',
|
|
62
|
-
name: 'session_task_issue_read',
|
|
63
|
-
description: 'Read the title, body and latest comment of the task issue of a session.',
|
|
64
|
-
parameters: {
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: { sessionName: SESSION_NAME_PROPERTY },
|
|
67
|
-
additionalProperties: false,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
type: 'function',
|
|
72
|
-
name: 'session_file_read',
|
|
73
|
-
description: 'Read a text file, or list a folder, given by a path relative to the current working folder of a session. Paths outside that folder are refused.',
|
|
74
|
-
parameters: {
|
|
75
|
-
type: 'object',
|
|
76
|
-
properties: {
|
|
77
|
-
sessionName: SESSION_NAME_PROPERTY,
|
|
78
|
-
path: {
|
|
79
|
-
type: 'string',
|
|
80
|
-
description: 'Path relative to the working folder of the session. A folder path returns a sorted listing.',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
required: ['path'],
|
|
84
|
-
additionalProperties: false,
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
];
|
|
88
6
|
const buildLiveSessionRequestBody = (sdpOffer) => JSON.stringify({
|
|
89
7
|
session: {
|
|
90
8
|
model: 'gpt-live-1',
|
|
91
|
-
instructions:
|
|
9
|
+
instructions: voiceConsoleLiveSessionConfig_1.VOICE_CONSOLE_INSTRUCTIONS,
|
|
92
10
|
audio: { output: { voice: 'harema' } },
|
|
93
11
|
delegation: {
|
|
94
12
|
type: 'responses',
|
|
95
13
|
responses: {
|
|
96
14
|
model: 'gpt-6.2-astra',
|
|
97
|
-
tools:
|
|
15
|
+
tools: voiceConsoleLiveSessionConfig_1.VOICE_CONSOLE_TOOL_DEFINITIONS,
|
|
98
16
|
},
|
|
99
17
|
},
|
|
100
18
|
},
|
|
@@ -118,23 +36,35 @@ const readErrorMessage = (body) => {
|
|
|
118
36
|
}
|
|
119
37
|
return body;
|
|
120
38
|
};
|
|
121
|
-
const
|
|
39
|
+
const readLiveSessionResponseFields = (body) => {
|
|
40
|
+
const fields = {
|
|
41
|
+
sessionId: null,
|
|
42
|
+
sdpAnswer: null,
|
|
43
|
+
};
|
|
122
44
|
try {
|
|
123
45
|
const parsed = JSON.parse(body);
|
|
124
|
-
if (typeof parsed
|
|
125
|
-
|
|
126
|
-
|
|
46
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
47
|
+
return fields;
|
|
48
|
+
}
|
|
49
|
+
if ('session' in parsed &&
|
|
50
|
+
typeof parsed.session === 'object' &&
|
|
51
|
+
parsed.session !== null &&
|
|
52
|
+
'id' in parsed.session &&
|
|
53
|
+
typeof parsed.session.id === 'string') {
|
|
54
|
+
fields.sessionId = parsed.session.id;
|
|
55
|
+
}
|
|
56
|
+
if ('transport' in parsed &&
|
|
127
57
|
typeof parsed.transport === 'object' &&
|
|
128
58
|
parsed.transport !== null &&
|
|
129
59
|
'sdp' in parsed.transport &&
|
|
130
60
|
typeof parsed.transport.sdp === 'string') {
|
|
131
|
-
|
|
61
|
+
fields.sdpAnswer = parsed.transport.sdp;
|
|
132
62
|
}
|
|
133
63
|
}
|
|
134
64
|
catch {
|
|
135
|
-
return
|
|
65
|
+
return fields;
|
|
136
66
|
}
|
|
137
|
-
return
|
|
67
|
+
return fields;
|
|
138
68
|
};
|
|
139
69
|
class OpenAiLiveSessionRepository {
|
|
140
70
|
constructor(fetchImplementation = fetch, readApiKey = () => process.env.OPENAI_API_KEY, logError = (message) => console.error(message)) {
|
|
@@ -170,13 +100,22 @@ class OpenAiLiveSessionRepository {
|
|
|
170
100
|
this.logError(`OpenAI live session creation failed with status ${response.status}: ${message}`);
|
|
171
101
|
return { type: 'openAiFailed', status: response.status, message };
|
|
172
102
|
}
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
103
|
+
const fields = readLiveSessionResponseFields(body);
|
|
104
|
+
if (fields.sessionId === null) {
|
|
105
|
+
const message = 'OpenAI live session response has no session.id';
|
|
106
|
+
this.logError(`${message}; reported with status 502`);
|
|
107
|
+
return { type: 'openAiFailed', status: 502, message };
|
|
108
|
+
}
|
|
109
|
+
if (fields.sdpAnswer === null) {
|
|
175
110
|
const message = 'OpenAI live session response has no transport.sdp';
|
|
176
111
|
this.logError(`${message}; reported with status 502`);
|
|
177
112
|
return { type: 'openAiFailed', status: 502, message };
|
|
178
113
|
}
|
|
179
|
-
return {
|
|
114
|
+
return {
|
|
115
|
+
type: 'created',
|
|
116
|
+
sdpAnswer: fields.sdpAnswer,
|
|
117
|
+
sessionId: fields.sessionId,
|
|
118
|
+
};
|
|
180
119
|
}
|
|
181
120
|
}
|
|
182
121
|
exports.OpenAiLiveSessionRepository = OpenAiLiveSessionRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiLiveSessionRepository.js","sourceRoot":"","sources":["../../../src/adapter/repositories/OpenAiLiveSessionRepository.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"OpenAiLiveSessionRepository.js","sourceRoot":"","sources":["../../../src/adapter/repositories/OpenAiLiveSessionRepository.ts"],"names":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AC;YAC9B,MAAM,OAAO,GAAG,gDAAgD,CAAC;YACjE,IAAI,CAAC,QAAQ,CAAC,GAAG,OAAO,4BAA4B,CAAC,CAAC;YACtD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;QACxD,CAAC;QACD,IAAI,MAAM,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YAC9B,MAAM,OAAO,GAAG,mDAAmD,CAAC;YACpE,IAAI,CAAC,QAAQ,CAAC,GAAG,OAAO,4BAA4B,CAAC,CAAC;YACtD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;QACxD,CAAC;QACD,OAAO;YACL,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC;IACJ,CAAC;CACF;AA5DD,kEA4DC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenAiLiveSessionSideband = void 0;
|
|
4
|
+
const OPENAI_LIVE_SESSIONS_ORIGIN = 'wss://api.openai.com/v1/live/sessions';
|
|
5
|
+
const SESSION_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
6
|
+
const isWebSocketWithHeadersConstructor = (value) => typeof value === 'function';
|
|
7
|
+
const createOpenAiVoiceConsoleSocket = (url, headers) => {
|
|
8
|
+
const constructorValue = globalThis.WebSocket;
|
|
9
|
+
if (!isWebSocketWithHeadersConstructor(constructorValue)) {
|
|
10
|
+
throw new Error('global WebSocket is not available in this runtime');
|
|
11
|
+
}
|
|
12
|
+
return new constructorValue(url, { headers });
|
|
13
|
+
};
|
|
14
|
+
const describeError = (error) => error instanceof Error ? error.message : String(error);
|
|
15
|
+
class OpenAiLiveSessionSideband {
|
|
16
|
+
constructor(createSocket = createOpenAiVoiceConsoleSocket, readApiKey = () => process.env.OPENAI_API_KEY, logError = (message) => console.error(message)) {
|
|
17
|
+
this.createSocket = createSocket;
|
|
18
|
+
this.readApiKey = readApiKey;
|
|
19
|
+
this.logError = logError;
|
|
20
|
+
}
|
|
21
|
+
static attachUrl(sessionId) {
|
|
22
|
+
if (!SESSION_ID_PATTERN.test(sessionId)) {
|
|
23
|
+
throw new Error('OpenAI live session id has characters outside [A-Za-z0-9_-]');
|
|
24
|
+
}
|
|
25
|
+
return `${OPENAI_LIVE_SESSIONS_ORIGIN}/${sessionId}/attach`;
|
|
26
|
+
}
|
|
27
|
+
attach(sessionId, handleServerEvent) {
|
|
28
|
+
const url = OpenAiLiveSessionSideband.attachUrl(sessionId);
|
|
29
|
+
const apiKey = this.readApiKey();
|
|
30
|
+
if (apiKey === undefined || apiKey === '') {
|
|
31
|
+
throw new Error('OPENAI_API_KEY is not set for the live session sideband');
|
|
32
|
+
}
|
|
33
|
+
const socket = this.createSocket(url, {
|
|
34
|
+
Authorization: `Bearer ${apiKey}`,
|
|
35
|
+
});
|
|
36
|
+
const send = (event) => {
|
|
37
|
+
socket.send(JSON.stringify(event));
|
|
38
|
+
};
|
|
39
|
+
socket.addEventListener('message', (event) => {
|
|
40
|
+
if (typeof event.data !== 'string') {
|
|
41
|
+
this.logError(`OpenAI live session ${sessionId} received a non-text message`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = JSON.parse(event.data);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
this.logError(`OpenAI live session ${sessionId} received a malformed message: ${describeError(error)}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
handleServerEvent(parsed, send).catch((error) => {
|
|
53
|
+
this.logError(`OpenAI live session ${sessionId} event handling failed: ${describeError(error)}`);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
socket.addEventListener('close', () => {
|
|
57
|
+
this.logError(`OpenAI live session ${sessionId} sideband closed`);
|
|
58
|
+
});
|
|
59
|
+
socket.addEventListener('error', () => {
|
|
60
|
+
this.logError(`OpenAI live session ${sessionId} sideband error`);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.OpenAiLiveSessionSideband = OpenAiLiveSessionSideband;
|
|
65
|
+
//# sourceMappingURL=OpenAiLiveSessionSideband.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenAiLiveSessionSideband.js","sourceRoot":"","sources":["../../../src/adapter/repositories/OpenAiLiveSessionSideband.ts"],"names":[],"mappings":";;;AAEA,MAAM,2BAA2B,GAAG,uCAAuC,CAAC;AAC5E,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AA+B9C,MAAM,iCAAiC,GAAG,CACxC,KAAc,EAC4B,EAAE,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC;AAE3E,MAAM,8BAA8B,GAA8B,CAChE,GAAG,EACH,OAAO,EACP,EAAE;IACF,MAAM,gBAAgB,GAAY,UAAU,CAAC,SAAS,CAAC;IACvD,IAAI,CAAC,iCAAiC,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,IAAI,gBAAgB,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,KAAc,EAAU,EAAE,CAC/C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEzD,MAAa,yBAAyB;IACpC,YACmB,eAA0C,8BAA8B,EACxE,aAAuC,GAAG,EAAE,CAC3D,OAAO,CAAC,GAAG,CAAC,cAAc,EACX,WAAsC,CAAC,OAAO,EAAE,EAAE,CACjE,OAAO,C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C,IAAI,CAAC,CAAC;YAClC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,QAAQ,CACX,uBAAuB,SAAS,kCAAkC,aAAa,CAAC,KAAK,CAAC,EAAE,CACzF,CAAC;gBACF,OAAO;YACT,CAAC;YACD,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBACvD,IAAI,CAAC,QAAQ,CACX,uBAAuB,SAAS,2BAA2B,aAAa,CAAC,KAAK,CAAC,EAAE,CAClF,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACpC,IAAI,CAAC,QAAQ,CAAC,uBAAuB,SAAS,kBAAkB,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACpC,IAAI,CAAC,QAAQ,CAAC,uBAAuB,SAAS,iBAAiB,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjED,8DAiEC"}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VOICE_CONSOLE_TOOL_NAMES = exports.VOICE_CONSOLE_TOOL_DEFINITIONS = exports.VOICE_CONSOLE_INSTRUCTIONS = void 0;
|
|
4
|
+
const NO_PARAMETERS = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {},
|
|
7
|
+
additionalProperties: false,
|
|
8
|
+
};
|
|
9
|
+
const PAGE_PROPERTY = {
|
|
10
|
+
type: 'integer',
|
|
11
|
+
description: 'Page number, starting at 1. Omit it to read page 1. Long text is split into pages of 3000 characters.',
|
|
12
|
+
};
|
|
13
|
+
const STRING_PROPERTY = (description) => ({
|
|
14
|
+
type: 'string',
|
|
15
|
+
description,
|
|
16
|
+
});
|
|
17
|
+
const CLOSE_REASONS = ['completed', 'not_planned'];
|
|
18
|
+
const CLOSE_COMMENT_KINDS = ['none', 'ok', 'text'];
|
|
19
|
+
const SNOOZE_PRESETS = [
|
|
20
|
+
'1h',
|
|
21
|
+
'3h',
|
|
22
|
+
'6h',
|
|
23
|
+
'1d',
|
|
24
|
+
'2d',
|
|
25
|
+
'3d',
|
|
26
|
+
'5d',
|
|
27
|
+
'1w',
|
|
28
|
+
'1month',
|
|
29
|
+
];
|
|
30
|
+
const PULL_REQUEST_REVIEW_ACTIONS = [
|
|
31
|
+
'approve_and_merge',
|
|
32
|
+
'request_changes',
|
|
33
|
+
'unnecessary',
|
|
34
|
+
'totally_wrong',
|
|
35
|
+
];
|
|
36
|
+
exports.VOICE_CONSOLE_INSTRUCTIONS = [
|
|
37
|
+
'あなたはオーナーの音声アシスタントです。オーナーは作業中の GitHub の Issue と Pull Request を、キューの先頭から順に声で確認します。',
|
|
38
|
+
'最初の挨拶では queue_overview を呼び、未処理の todo-by-human と prs の件数を伝えてください。',
|
|
39
|
+
'各タスクでは、current_task_summary を呼び、タイトルと最新の報告の要約を読み上げてください。',
|
|
40
|
+
'オーナーが「もう一度」と言ったら repeat_current_task を呼び、同じタスクの最新の報告の要約を最初のページから読み直してください。位置は動かしません。',
|
|
41
|
+
'最新の報告の要約を読むときは、要約に含まれる判断(オーナーに決めてもらう質問)を、その選択肢(選択肢)とあわせて必ず読み上げてください。判断や選択肢を省略したり、要約に丸めたりしてはいけません。',
|
|
42
|
+
'オーナーが「詳しく」と言ったら current_task_detail を呼び、本文とコメントを、ページごとに続けて読んでください。ページが残っている場合は page を増やして読み続けてください。',
|
|
43
|
+
'タスクや GitHub の URL に関する質問には、必ず読み取りツール(current_task_detail、read_github_url、read_pull_request、read_repository_file、search_issues)を呼んで答えてください。推測で答えてはいけません。',
|
|
44
|
+
'書き込みは必ず二段階で行います。prepare_ で始まるツールを呼んだら、返された readBack の内容をオーナーに読み上げ、オーナーが「はい」と答えた後にだけ confirm_pending_action を呼んでください。オーナーが「はい」以外を答えたら cancel_pending_action を呼んでください。',
|
|
45
|
+
'コメントの本文は、オーナーが口述した文章を一字一句そのまま使ってください。言い換えたり要約したりしてはいけません。',
|
|
46
|
+
'移動は next_task(次のタスク)、previous_task(前のタスク)、jump_to_task(番号指定)で行います。end_of_queue や start_of_queue が返ったら、その旨をオーナーに伝えてください。',
|
|
47
|
+
'ツールがエラーを返したら、そのエラーの内容をオーナーに伝えてください。エラーを隠したり、成功したと言ったりしてはいけません。',
|
|
48
|
+
].join('\n');
|
|
49
|
+
exports.VOICE_CONSOLE_TOOL_DEFINITIONS = [
|
|
50
|
+
{
|
|
51
|
+
type: 'function',
|
|
52
|
+
name: 'queue_overview',
|
|
53
|
+
description: 'Reload the queue from the console data and return the counts of todo-by-human items, prs items and the total, the projects, and the current task position.',
|
|
54
|
+
parameters: NO_PARAMETERS,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'function',
|
|
58
|
+
name: 'current_task_summary',
|
|
59
|
+
description: 'Return the latest robot report summary of the current task, read from the task issue comments. Paginated.',
|
|
60
|
+
parameters: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: { page: PAGE_PROPERTY },
|
|
63
|
+
additionalProperties: false,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: 'function',
|
|
68
|
+
name: 'repeat_current_task',
|
|
69
|
+
description: 'Repeat the latest robot report summary of the current task from page 1, the same output as current_task_summary. Does not move the queue position.',
|
|
70
|
+
parameters: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: { page: PAGE_PROPERTY },
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'function',
|
|
78
|
+
name: 'current_task_detail',
|
|
79
|
+
description: 'Return the full text of the current task: title, status, story, labels, dependencies, the issue body and all comments. Paginated.',
|
|
80
|
+
parameters: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: { page: PAGE_PROPERTY },
|
|
83
|
+
additionalProperties: false,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: 'function',
|
|
88
|
+
name: 'read_github_url',
|
|
89
|
+
description: 'Return the body and all comments of a GitHub issue or pull request URL. Paginated.',
|
|
90
|
+
parameters: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
url: STRING_PROPERTY('GitHub issue or pull request URL.'),
|
|
94
|
+
page: PAGE_PROPERTY,
|
|
95
|
+
},
|
|
96
|
+
required: ['url'],
|
|
97
|
+
additionalProperties: false,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'function',
|
|
102
|
+
name: 'read_pull_request',
|
|
103
|
+
description: 'Return a pull request summary: state, branches, the changed files, the commits and the CI status. Omit url to use the current task when it is a pull request. Paginated.',
|
|
104
|
+
parameters: {
|
|
105
|
+
type: 'object',
|
|
106
|
+
properties: {
|
|
107
|
+
url: STRING_PROPERTY('GitHub pull request URL. Optional.'),
|
|
108
|
+
page: PAGE_PROPERTY,
|
|
109
|
+
},
|
|
110
|
+
additionalProperties: false,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: 'function',
|
|
115
|
+
name: 'read_repository_file',
|
|
116
|
+
description: 'Return the text of a file from a GitHub blob URL, for example https://github.com/owner/repo/blob/main/path. Paginated.',
|
|
117
|
+
parameters: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
properties: {
|
|
120
|
+
url: STRING_PROPERTY('GitHub blob URL of the file.'),
|
|
121
|
+
page: PAGE_PROPERTY,
|
|
122
|
+
},
|
|
123
|
+
required: ['url'],
|
|
124
|
+
additionalProperties: false,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: 'function',
|
|
129
|
+
name: 'search_issues',
|
|
130
|
+
description: 'Search GitHub issues and pull requests with a GitHub search query. A query without a user, org or repo qualifier is limited to the owner account. Paginated.',
|
|
131
|
+
parameters: {
|
|
132
|
+
type: 'object',
|
|
133
|
+
properties: {
|
|
134
|
+
query: STRING_PROPERTY('GitHub issue search query.'),
|
|
135
|
+
page: PAGE_PROPERTY,
|
|
136
|
+
},
|
|
137
|
+
required: ['query'],
|
|
138
|
+
additionalProperties: false,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: 'function',
|
|
143
|
+
name: 'next_task',
|
|
144
|
+
description: 'Move to the next task in the queue and return it.',
|
|
145
|
+
parameters: NO_PARAMETERS,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: 'function',
|
|
149
|
+
name: 'previous_task',
|
|
150
|
+
description: 'Move to the previous task in the queue and return it.',
|
|
151
|
+
parameters: NO_PARAMETERS,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
type: 'function',
|
|
155
|
+
name: 'jump_to_task',
|
|
156
|
+
description: 'Move to the task at a 1-based position in the queue and return it.',
|
|
157
|
+
parameters: {
|
|
158
|
+
type: 'object',
|
|
159
|
+
properties: {
|
|
160
|
+
position: { type: 'integer', description: '1-based queue position.' },
|
|
161
|
+
},
|
|
162
|
+
required: ['position'],
|
|
163
|
+
additionalProperties: false,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
type: 'function',
|
|
168
|
+
name: 'prepare_ok',
|
|
169
|
+
description: 'Prepare, without executing, setting the current task to Awaiting Workspace with the comment ok. Requires confirm_pending_action after the owner says yes.',
|
|
170
|
+
parameters: NO_PARAMETERS,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
type: 'function',
|
|
174
|
+
name: 'prepare_comment_and_move_to_awaiting_workspace',
|
|
175
|
+
description: 'Prepare, without executing, posting the dictated comment on the current task and moving it to Awaiting Workspace. Requires confirm_pending_action after the owner says yes.',
|
|
176
|
+
parameters: {
|
|
177
|
+
type: 'object',
|
|
178
|
+
properties: {
|
|
179
|
+
comment_text: STRING_PROPERTY('Comment text, exactly as dictated.'),
|
|
180
|
+
},
|
|
181
|
+
required: ['comment_text'],
|
|
182
|
+
additionalProperties: false,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: 'function',
|
|
187
|
+
name: 'prepare_comment_only',
|
|
188
|
+
description: 'Prepare, without executing, posting the dictated comment on the current task and keeping its status. Requires confirm_pending_action after the owner says yes.',
|
|
189
|
+
parameters: {
|
|
190
|
+
type: 'object',
|
|
191
|
+
properties: {
|
|
192
|
+
comment_text: STRING_PROPERTY('Comment text, exactly as dictated.'),
|
|
193
|
+
},
|
|
194
|
+
required: ['comment_text'],
|
|
195
|
+
additionalProperties: false,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
type: 'function',
|
|
200
|
+
name: 'prepare_close',
|
|
201
|
+
description: 'Prepare, without executing, closing the current task as completed or not_planned, with an optional comment. Requires confirm_pending_action after the owner says yes.',
|
|
202
|
+
parameters: {
|
|
203
|
+
type: 'object',
|
|
204
|
+
properties: {
|
|
205
|
+
reason: {
|
|
206
|
+
type: 'string',
|
|
207
|
+
enum: CLOSE_REASONS,
|
|
208
|
+
description: 'completed or not_planned.',
|
|
209
|
+
},
|
|
210
|
+
comment_kind: {
|
|
211
|
+
type: 'string',
|
|
212
|
+
enum: CLOSE_COMMENT_KINDS,
|
|
213
|
+
description: 'none for no comment, ok for the comment ok, text for the comment_text.',
|
|
214
|
+
},
|
|
215
|
+
comment_text: STRING_PROPERTY('Comment text, required when comment_kind is text.'),
|
|
216
|
+
},
|
|
217
|
+
required: ['reason', 'comment_kind'],
|
|
218
|
+
additionalProperties: false,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
type: 'function',
|
|
223
|
+
name: 'prepare_snooze',
|
|
224
|
+
description: 'Prepare, without executing, snoozing the current task for a preset duration. Requires confirm_pending_action after the owner says yes.',
|
|
225
|
+
parameters: {
|
|
226
|
+
type: 'object',
|
|
227
|
+
properties: {
|
|
228
|
+
preset: {
|
|
229
|
+
type: 'string',
|
|
230
|
+
enum: SNOOZE_PRESETS,
|
|
231
|
+
description: 'Snooze duration: 1h, 3h, 6h, 1d, 2d, 3d, 5d, 1w or 1month.',
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
required: ['preset'],
|
|
235
|
+
additionalProperties: false,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
type: 'function',
|
|
240
|
+
name: 'prepare_set_status',
|
|
241
|
+
description: 'Prepare, without executing, moving the current task to a status option of its project. Requires confirm_pending_action after the owner says yes.',
|
|
242
|
+
parameters: {
|
|
243
|
+
type: 'object',
|
|
244
|
+
properties: {
|
|
245
|
+
status_name: STRING_PROPERTY('Exact name of a status option of the project.'),
|
|
246
|
+
},
|
|
247
|
+
required: ['status_name'],
|
|
248
|
+
additionalProperties: false,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
type: 'function',
|
|
253
|
+
name: 'prepare_move_to_in_tmux_by_human',
|
|
254
|
+
description: 'Prepare, without executing, moving the current task to In tmux by human. Requires confirm_pending_action after the owner says yes.',
|
|
255
|
+
parameters: NO_PARAMETERS,
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
type: 'function',
|
|
259
|
+
name: 'prepare_pull_request_review',
|
|
260
|
+
description: 'Prepare, without executing, a review action on the current pull request or the pull request related to the current issue: approve_and_merge, request_changes (needs comment_text), unnecessary or totally_wrong. Requires confirm_pending_action after the owner says yes.',
|
|
261
|
+
parameters: {
|
|
262
|
+
type: 'object',
|
|
263
|
+
properties: {
|
|
264
|
+
action: {
|
|
265
|
+
type: 'string',
|
|
266
|
+
enum: PULL_REQUEST_REVIEW_ACTIONS,
|
|
267
|
+
description: 'The review action.',
|
|
268
|
+
},
|
|
269
|
+
comment_text: STRING_PROPERTY('Comment text, exactly as dictated. Required for request_changes.'),
|
|
270
|
+
},
|
|
271
|
+
required: ['action'],
|
|
272
|
+
additionalProperties: false,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
type: 'function',
|
|
277
|
+
name: 'confirm_pending_action',
|
|
278
|
+
description: 'Execute the prepared action with this action_id, only after the owner replied yes (はい). Returns an error when there is no matching prepared action.',
|
|
279
|
+
parameters: {
|
|
280
|
+
type: 'object',
|
|
281
|
+
properties: {
|
|
282
|
+
action_id: STRING_PROPERTY('The actionId returned by the prepare tool.'),
|
|
283
|
+
owner_reply: STRING_PROPERTY('The owner reply, verbatim.'),
|
|
284
|
+
},
|
|
285
|
+
required: ['action_id', 'owner_reply'],
|
|
286
|
+
additionalProperties: false,
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
type: 'function',
|
|
291
|
+
name: 'cancel_pending_action',
|
|
292
|
+
description: 'Discard the prepared action without executing it, for example when the owner does not confirm.',
|
|
293
|
+
parameters: NO_PARAMETERS,
|
|
294
|
+
},
|
|
295
|
+
];
|
|
296
|
+
exports.VOICE_CONSOLE_TOOL_NAMES = exports.VOICE_CONSOLE_TOOL_DEFINITIONS.map((definition) => definition.name);
|
|
297
|
+
//# sourceMappingURL=voiceConsoleLiveSessionConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voiceConsoleLiveSessionConfig.js","sourceRoot":"","sources":["../../../src/adapter/voice-console/voiceConsoleLiveSessionConfig.ts"],"names":[],"mappings":";;;AAcA,MAAM,aAAa,GAA+B;IAChD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,EAAE;IACd,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE,SAAS;IACf,WAAW,EACT,uGAAuG;CAC1G,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,WAAmB,EAA2B,EAAE,CAAC,CAAC;I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A6B;QACnC,WAAW,EACT,4QAA4Q;QAC9Q,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,2BAA2B;oBACjC,WAAW,EAAE,oBAAoB;iBAClC;gBACD,YAAY,EAAE,eAAe,CAC3B,kEAAkE,CACnE;aACF;YACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,oBAAoB,EAAE,KAAK;SAC5B;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EACT,qJAAqJ;QACvJ,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,eAAe,CACxB,4CAA4C,CAC7C;gBACD,WAAW,EAAE,eAAe,CAAC,4BAA4B,CAAC;aAC3D;YACD,QAAQ,EAAE,CAAC,WAAW,EAAE,aAAa,CAAC;YACtC,oBAAoB,EAAE,KAAK;SAC5B;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EACT,gGAAgG;QAClG,UAAU,EAAE,aAAa;KAC1B;CACF,CAAC;AAEW,QAAA,wBAAwB,GACnC,sCAA8B,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paginateText = exports.PAGE_CHARACTER_LIMIT = void 0;
|
|
4
|
+
exports.PAGE_CHARACTER_LIMIT = 3000;
|
|
5
|
+
const countPages = (characters) => Math.max(1, Math.ceil(characters.length / exports.PAGE_CHARACTER_LIMIT));
|
|
6
|
+
const paginateText = (text, page) => {
|
|
7
|
+
const characters = Array.from(text);
|
|
8
|
+
const pageCount = countPages(characters);
|
|
9
|
+
const requestedPage = page ?? 1;
|
|
10
|
+
if (!Number.isInteger(requestedPage) || requestedPage < 1) {
|
|
11
|
+
return { ok: false, error: 'page_out_of_range', pageCount };
|
|
12
|
+
}
|
|
13
|
+
if (requestedPage > pageCount) {
|
|
14
|
+
return { ok: false, error: 'page_out_of_range', pageCount };
|
|
15
|
+
}
|
|
16
|
+
const start = (requestedPage - 1) * exports.PAGE_CHARACTER_LIMIT;
|
|
17
|
+
return {
|
|
18
|
+
ok: true,
|
|
19
|
+
page: requestedPage,
|
|
20
|
+
pageCount,
|
|
21
|
+
text: characters.slice(start, start + exports.PAGE_CHARACTER_LIMIT).join(''),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.paginateText = paginateText;
|
|
25
|
+
//# sourceMappingURL=voiceConsolePaging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voiceConsolePaging.js","sourceRoot":"","sources":["../../../src/adapter/voice-console/voiceConsolePaging.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,IAAI,CAAC;AAMzC,MAAM,UAAU,GAAG,CAAC,UAAoB,EAAU,EAAE,CAClD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,4BAAoB,CAAC,CAAC,CAAC;AAE5D,MAAM,YAAY,GAAG,CAC1B,IAAY,EACZ,IAAwB,EACH,EAAE;IACvB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,CAAC;IAC9D,CAAC;IACD,IAAI,aAAa,GAAG,SAAS,EAAE,CAAC;QAC9B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,CAAC;IAC9D,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC,GAAG,4BAAoB,CAAC;IACzD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,aAAa;QACnB,SAAS;QACT,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,4BAAoB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;KACrE,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,YAAY,gBAoBvB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoiceConsolePendingActionStore = exports.normalizeSpeech = exports.OWNER_CONFIRMATION_REPLY = void 0;
|
|
4
|
+
exports.OWNER_CONFIRMATION_REPLY = 'はい';
|
|
5
|
+
// Speech is compared after removing whitespace and these punctuation marks,
|
|
6
|
+
// so that a split or punctuated transcript of はい still counts.
|
|
7
|
+
const SPEECH_IGNORED_PATTERN = /[\s。、.,!?!?]/g;
|
|
8
|
+
const normalizeSpeech = (speech) => speech.replace(SPEECH_IGNORED_PATTERN, '');
|
|
9
|
+
exports.normalizeSpeech = normalizeSpeech;
|
|
10
|
+
class VoiceConsolePendingActionStore {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.pending = null;
|
|
13
|
+
}
|
|
14
|
+
prepare(action) {
|
|
15
|
+
this.pending = action;
|
|
16
|
+
}
|
|
17
|
+
current() {
|
|
18
|
+
return this.pending;
|
|
19
|
+
}
|
|
20
|
+
confirm(actionId, ownerReply) {
|
|
21
|
+
const action = this.pending;
|
|
22
|
+
if (action === null) {
|
|
23
|
+
return { ok: false, error: 'no_pending_action' };
|
|
24
|
+
}
|
|
25
|
+
if (action.actionId !== actionId) {
|
|
26
|
+
return { ok: false, error: 'action_id_mismatch' };
|
|
27
|
+
}
|
|
28
|
+
if (ownerReply.trim() !== exports.OWNER_CONFIRMATION_REPLY) {
|
|
29
|
+
return { ok: false, error: 'owner_reply_not_yes' };
|
|
30
|
+
}
|
|
31
|
+
this.pending = null;
|
|
32
|
+
return { ok: true, action };
|
|
33
|
+
}
|
|
34
|
+
cancel() {
|
|
35
|
+
this.pending = null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.VoiceConsolePendingActionStore = VoiceConsolePendingActionStore;
|
|
39
|
+
//# sourceMappingURL=voiceConsolePendingAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voiceConsolePendingAction.js","sourceRoot":"","sources":["../../../src/adapter/voice-console/voiceConsolePendingAction.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAE7C,4EAA4E;AAC5E,+DAA+D;AAC/D,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAExC,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE,CACxD,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;AADhC,QAAA,eAAe,mBACiB;AAiB7C,MAAa,8BAA8B;IAA3C;QACU,YAAO,GAA+B,IAAI,CAAC;IA+BrD,CAAC;IA7BC,OAAO,CAAC,MAA2B;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,OAAO,CACL,QAAgB,EAChB,UAAkB;QAElB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,EAAE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