Skip to content

Commit 1cdf61d

Browse files
authored
make check safer (microsoft#262931)
1 parent 2a36a52 commit 1cdf61d

File tree

1 file changed

+9
-3
lines changed
  • src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring

1 file changed

+9
-3
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { IPollingResult, OutputMonitorState, IExecution, IRacePollingOrPromptRes
2020
import { getTextResponseFromStream } from './utils.js';
2121
import { IChatWidgetService } from '../../../../../chat/browser/chat.js';
2222
import { ChatAgentLocation } from '../../../../../chat/common/constants.js';
23+
import { isObject, isString } from '../../../../../../../base/common/types.js';
2324

2425
export interface IOutputMonitor extends Disposable {
2526
readonly isIdle: boolean;
@@ -298,9 +299,14 @@ export class OutputMonitor extends Disposable implements IOutputMonitor {
298299
try {
299300
const match = responseText.match(/\{[\s\S]*\}/);
300301
if (match) {
301-
const obj = JSON.parse(match[0]);
302-
if (obj && obj satisfies IConfirmationPrompt) {
303-
return obj;
302+
const obj = JSON.parse(match[0]) as unknown;
303+
if (
304+
isObject(obj) &&
305+
'prompt' in obj && isString(obj.prompt) &&
306+
'options' in obj && Array.isArray(obj.options) &&
307+
obj.options.every(isString)
308+
) {
309+
return { prompt: obj.prompt, options: obj.options };
304310
}
305311
}
306312
} catch {

0 commit comments

Comments
 (0)